randmarcomps 1.635.0 → 1.638.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 +17 -17
- package/dist/randmarcomps.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/randmarcomps.js
CHANGED
|
@@ -54560,7 +54560,7 @@ function ResellerOverview({
|
|
|
54560
54560
|
...ft,
|
|
54561
54561
|
[yt]: It
|
|
54562
54562
|
} : ft);
|
|
54563
|
-
}, []), { NavigationGuardDialog: lt } = useRouterNavigationGuard(at), ut = te ?? t, ct = A && !ut, dt = rt && !ut, pt = !n || !!ut?.Statement && (ut.Statement.Total ?? 0)
|
|
54563
|
+
}, []), { NavigationGuardDialog: lt } = useRouterNavigationGuard(at), ut = te ?? t, ct = A && !ut, dt = rt && !ut, pt = !n || !!ut?.Statement && (ut.Statement.Total ?? 0) !== 0, mt = ut?.QualifiedManufacturers ?? [], Ct = ut?.Qualifications ?? [];
|
|
54564
54564
|
return /* @__PURE__ */ jsxs("div", { className: "@container", children: [
|
|
54565
54565
|
dt ? /* @__PURE__ */ jsx(Card, { className: "p-6", children: /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
|
|
54566
54566
|
/* @__PURE__ */ jsx(CircleAlert, { className: "h-4 w-4" }),
|
|
@@ -54614,24 +54614,24 @@ function ResellerOverview({
|
|
|
54614
54614
|
appID: e ?? "",
|
|
54615
54615
|
isLoading: ct
|
|
54616
54616
|
}
|
|
54617
|
+
),
|
|
54618
|
+
ct || mt.length > 0 ? /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
|
|
54619
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { children: "Manufacturers you are qualified for" }) }),
|
|
54620
|
+
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { className: "grid @lg:grid-cols-2 gap-4", children: ct ? Array.from({ length: 2 }).map((yt, It) => /* @__PURE__ */ jsx(ManufacturerCard, { loading: !0 }, It)) : mt.map((yt) => /* @__PURE__ */ jsx(
|
|
54621
|
+
ManufacturerCard,
|
|
54622
|
+
{
|
|
54623
|
+
manufacturer: yt,
|
|
54624
|
+
link: `https://dashboard.randmar.io/${e}/Partner/${yt.ManufacturerId}`
|
|
54625
|
+
},
|
|
54626
|
+
yt.ManufacturerId
|
|
54627
|
+
)) }) })
|
|
54628
|
+
] }) : Ct.length > 0 && /* @__PURE__ */ jsx(
|
|
54629
|
+
ResellerQualificationsCard,
|
|
54630
|
+
{
|
|
54631
|
+
qualifications: Ct
|
|
54632
|
+
}
|
|
54617
54633
|
)
|
|
54618
54634
|
] }),
|
|
54619
|
-
ct || mt.length > 0 ? /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
|
|
54620
|
-
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { children: "Manufacturers you are qualified for" }) }),
|
|
54621
|
-
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { className: "grid @lg:grid-cols-2 gap-4", children: ct ? Array.from({ length: 2 }).map((yt, It) => /* @__PURE__ */ jsx(ManufacturerCard, { loading: !0 }, It)) : mt.map((yt) => /* @__PURE__ */ jsx(
|
|
54622
|
-
ManufacturerCard,
|
|
54623
|
-
{
|
|
54624
|
-
manufacturer: yt,
|
|
54625
|
-
link: `https://dashboard.randmar.io/${e}/Partner/${yt.ManufacturerId}`
|
|
54626
|
-
},
|
|
54627
|
-
yt.ManufacturerId
|
|
54628
|
-
)) }) })
|
|
54629
|
-
] }) : Ct.length > 0 && /* @__PURE__ */ jsx(
|
|
54630
|
-
ResellerQualificationsCard,
|
|
54631
|
-
{
|
|
54632
|
-
qualifications: Ct
|
|
54633
|
-
}
|
|
54634
|
-
),
|
|
54635
54635
|
(ut?.Opportunities?.length ?? 0) > 0 && /* @__PURE__ */ jsx(
|
|
54636
54636
|
OpportunitiesTable,
|
|
54637
54637
|
{
|
|
@@ -484,7 +484,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let a="<p>An error
|
|
|
484
484
|
|
|
485
485
|
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?.ManufacturerId??""},{skip:!e?.ManufacturerId}),o=e?.DefaultMaxInventoryValue??0,l=n.reduce((f,R)=>f+(R.InventoryValue||0),0),c=o-l,d=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-success":"text-destructive"}`,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:[d,"%"]}),d>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-warning"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:d,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:e,isLoading:t}){const n=e?.CreditLimit??0,s=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-success":"text-destructive"}`,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-warning"})]})}),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}),[d,f]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>t?!1:d.publicInfo.hasUnsavedChanges||d.qualifications.hasUnsavedChanges||d.billingInfo.hasUnsavedChanges,[t,d]),S=React.useCallback((rt,st)=>{f(it=>it[rt]?.hasUnsavedChanges!==st.hasUnsavedChanges?(console.log(`Updating form state for ${rt}:`,st.hasUnsavedChanges),{...it,[rt]:st}):it)},[]),{NavigationGuardDialog:te}=useRouterNavigationGuard(R),A=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:A?.FiscalYearMonthStart,salesData:A?.SalesData,isLoading:l}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:A?.SalesStatistics??[],loading:l}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:A?.ManufacturerId??"",activeOrders:A?.ActiveOrderDetails??void 0,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:A,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:A,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:A??{},onSave:()=>{},loading:l,readonly:t}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:A,readonly:t,isLoading:l,onUnsavedChanges:rt=>S("publicInfo",{hasUnsavedChanges:rt})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:A,readonly:t,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:A,readonly:t,isLoading:l,onUnsavedChanges:rt=>S("billingInfo",{hasUnsavedChanges:rt})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:A,readonly:t,isLoading:l,onUnsavedChanges:rt=>S("qualifications",{hasUnsavedChanges:rt})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:A?.ManufacturerId??"",userEmail:a,isLoading:l})]}),jsxRuntime.jsx(te,{})]})}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-destructive":""}`})]},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?.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-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible: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-border hover:bg-accent hover:text-accent-foreground",success:"bg-success text-success-foreground hover:bg-success/90",warning:"bg-warning text-warning-foreground hover:bg-warning/90",info:"bg-info text-info-foreground hover:bg-info/90",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-primary text-primary-foreground hover:bg-primary/80",randmarBlue:"bg-primary text-primary-foreground hover:bg-primary/80",randmarPurple:"bg-primary text-primary-foreground hover:bg-primary/80",randmarGreen:"bg-primary text-primary-foreground hover:bg-primary/80",randmarBlack:"bg-foreground text-background hover:bg-foreground/90",randmarYellow:"bg-primary text-primary-foreground hover:bg-primary/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-warning text-warning"}):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-success"}):jsxRuntime.jsx(RefreshCwOff,{className:"size-4 text-warning"}),jsxRuntime.jsx(Badge,{variant:s?"success":"warning",className:"text-xs",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),d=c.find(isSlottable$1);if(d){const f=d.props.children,R=c.map(S=>S===d?React__namespace.Children.count(f)>1?React__namespace.Children.only(null):React__namespace.isValidElement(f)?f.props.children:null:S);return jsxRuntime.jsx(t,{...l,ref:a,children:React__namespace.isValidElement(f)?React__namespace.cloneElement(f,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 d=o(...c);return a(...c),d}: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){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.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:d,dir:f,name:R,autoComplete:S,disabled:te,required:A,form:rt}=e,st=usePopperScope$1(t),[it,at]=React__namespace.useState(null),[ot,lt]=React__namespace.useState(null),[ut,ct]=React__namespace.useState(!1),dt=useDirection(f),[pt,mt]=useControllableState({prop:s,defaultProp:a??!1,onChange:o,caller:SELECT_NAME}),[Rt,yt]=useControllableState({prop:l,defaultProp:c,onChange:d,caller:SELECT_NAME}),It=React__namespace.useRef(null),ft=it?rt||!!it.closest("form"):!0,[Ct,Mt]=React__namespace.useState(new Set),Dt=Array.from(Ct).map(Vt=>Vt.props.value).join(";");return jsxRuntime.jsx(Root2$7,{...st,children:jsxRuntime.jsxs(SelectProvider,{required:A,scope:t,trigger:it,onTriggerChange:at,valueNode:ot,onValueNodeChange:lt,valueNodeHasChildren:ut,onValueNodeHasChildrenChange:ct,contentId:useId$1(),value:Rt,onValueChange:yt,open:pt,onOpenChange:mt,dir:dt,triggerPointerDownPosRef:It,disabled:te,children:[jsxRuntime.jsx(Collection$1.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Vt=>{Mt(Wt=>new Set(Wt).add(Vt))},[]),onNativeOptionRemove:React__namespace.useCallback(Vt=>{Mt(Wt=>{const $t=new Set(Wt);return $t.delete(Vt),$t})},[]),children:n})}),ft?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:A,tabIndex:-1,name:R,autoComplete:S,value:Rt,onChange:Vt=>yt(Vt.target.value),disabled:te,form:rt,children:[Rt===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(Ct)]},Dt):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,d=useComposedRefs(t,l.onTriggerChange),f=useCollection$1(n),R=React__namespace.useRef("touch"),[S,te,A]=useTypeaheadSearch(st=>{const it=f().filter(lt=>!lt.disabled),at=it.find(lt=>lt.value===l.value),ot=findNextItem(it,st,at);ot!==void 0&&l.onValueChange(ot.value)}),rt=st=>{c||(l.onOpenChange(!0),A()),st&&(l.triggerPointerDownPosRef.current={x:Math.round(st.pageX),y:Math.round(st.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:d,onClick:composeEventHandlers(a.onClick,st=>{st.currentTarget.focus(),R.current!=="mouse"&&rt(st)}),onPointerDown:composeEventHandlers(a.onPointerDown,st=>{R.current=st.pointerType;const it=st.target;it.hasPointerCapture(st.pointerId)&&it.releasePointerCapture(st.pointerId),st.button===0&&st.ctrlKey===!1&&st.pointerType==="mouse"&&(rt(st),st.preventDefault())}),onKeyDown:composeEventHandlers(a.onKeyDown,st=>{const it=S.current!=="";!(st.ctrlKey||st.altKey||st.metaKey)&&st.key.length===1&&te(st.key),!(it&&st.key===" ")&&OPEN_KEYS.includes(st.key)&&(rt(),st.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,d=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:f}=d,R=o!==void 0,S=useComposedRefs(t,d.onValueNodeChange);return useLayoutEffect2(()=>{f(R)},[f,R]),jsxRuntime.jsx(Primitive$4.span,{...c,ref:S,style:{pointerEvents:"none"},children:shouldShowPlaceholder(d.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:d,align:f,alignOffset:R,arrowPadding:S,collisionBoundary:te,collisionPadding:A,sticky:rt,hideWhenDetached:st,avoidCollisions:it,...at}=e,ot=useSelectContext(CONTENT_NAME$4,n),[lt,ut]=React__namespace.useState(null),[ct,dt]=React__namespace.useState(null),pt=useComposedRefs(t,Ut=>ut(Ut)),[mt,Rt]=React__namespace.useState(null),[yt,It]=React__namespace.useState(null),ft=useCollection$1(n),[Ct,Mt]=React__namespace.useState(!1),Dt=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(lt)return hideOthers(lt)},[lt]),useFocusGuards();const Vt=React__namespace.useCallback(Ut=>{const[rr,...qt]=ft().map(Kt=>Kt.ref.current),[Qt]=qt.slice(-1),dr=document.activeElement;for(const Kt of Ut)if(Kt===dr||(Kt?.scrollIntoView({block:"nearest"}),Kt===rr&&ct&&(ct.scrollTop=0),Kt===Qt&&ct&&(ct.scrollTop=ct.scrollHeight),Kt?.focus(),document.activeElement!==dr))return},[ft,ct]),Wt=React__namespace.useCallback(()=>Vt([mt,lt]),[Vt,mt,lt]);React__namespace.useEffect(()=>{Ct&&Wt()},[Ct,Wt]);const{onOpenChange:$t,triggerPointerDownPosRef:Ft}=ot;React__namespace.useEffect(()=>{if(lt){let Ut={x:0,y:0};const rr=Qt=>{Ut={x:Math.abs(Math.round(Qt.pageX)-(Ft.current?.x??0)),y:Math.abs(Math.round(Qt.pageY)-(Ft.current?.y??0))}},qt=Qt=>{Ut.x<=10&&Ut.y<=10?Qt.preventDefault():lt.contains(Qt.target)||$t(!1),document.removeEventListener("pointermove",rr),Ft.current=null};return Ft.current!==null&&(document.addEventListener("pointermove",rr),document.addEventListener("pointerup",qt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",rr),document.removeEventListener("pointerup",qt,{capture:!0})}}},[lt,$t,Ft]),React__namespace.useEffect(()=>{const Ut=()=>$t(!1);return window.addEventListener("blur",Ut),window.addEventListener("resize",Ut),()=>{window.removeEventListener("blur",Ut),window.removeEventListener("resize",Ut)}},[$t]);const[Ht,nr]=useTypeaheadSearch(Ut=>{const rr=ft().filter(dr=>!dr.disabled),qt=rr.find(dr=>dr.ref.current===document.activeElement),Qt=findNextItem(rr,Ut,qt);Qt&&setTimeout(()=>Qt.ref.current.focus())}),Jt=React__namespace.useCallback((Ut,rr,qt)=>{const Qt=!Dt.current&&!qt;(ot.value!==void 0&&ot.value===rr||Qt)&&(Rt(Ut),Qt&&(Dt.current=!0))},[ot.value]),ar=React__namespace.useCallback(()=>lt?.focus(),[lt]),cr=React__namespace.useCallback((Ut,rr,qt)=>{const Qt=!Dt.current&&!qt;(ot.value!==void 0&&ot.value===rr||Qt)&&It(Ut)},[ot.value]),Zt=s==="popper"?SelectPopperPosition:SelectItemAlignedPosition,lr=Zt===SelectPopperPosition?{side:c,sideOffset:d,align:f,alignOffset:R,arrowPadding:S,collisionBoundary:te,collisionPadding:A,sticky:rt,hideWhenDetached:st,avoidCollisions:it}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:lt,viewport:ct,onViewportChange:dt,itemRefCallback:Jt,selectedItem:mt,onItemLeave:ar,itemTextRefCallback:cr,focusSelectedItem:Wt,selectedItemText:yt,position:s,isPositioned:Ct,searchRef:Ht,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:ot.open,onMountAutoFocus:Ut=>{Ut.preventDefault()},onUnmountAutoFocus:composeEventHandlers(a,Ut=>{ot.trigger?.focus({preventScroll:!0}),Ut.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Ut=>Ut.preventDefault(),onDismiss:()=>ot.onOpenChange(!1),children:jsxRuntime.jsx(Zt,{role:"listbox",id:ot.contentId,"data-state":ot.open?"open":"closed",dir:ot.dir,onContextMenu:Ut=>Ut.preventDefault(),...at,...lr,onPlaced:()=>Mt(!0),ref:pt,style:{display:"flex",flexDirection:"column",outline:"none",...at.style},onKeyDown:composeEventHandlers(at.onKeyDown,Ut=>{const rr=Ut.ctrlKey||Ut.altKey||Ut.metaKey;if(Ut.key==="Tab"&&Ut.preventDefault(),!rr&&Ut.key.length===1&&nr(Ut.key),["ArrowUp","ArrowDown","Home","End"].includes(Ut.key)){let Qt=ft().filter(dr=>!dr.disabled).map(dr=>dr.ref.current);if(["ArrowUp","End"].includes(Ut.key)&&(Qt=Qt.slice().reverse()),["ArrowUp","ArrowDown"].includes(Ut.key)){const dr=Ut.target,Kt=Qt.indexOf(dr);Qt=Qt.slice(Kt+1)}setTimeout(()=>Vt(Qt)),Ut.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,d]=React__namespace.useState(null),[f,R]=React__namespace.useState(null),S=useComposedRefs(t,pt=>R(pt)),te=useCollection$1(n),A=React__namespace.useRef(!1),rt=React__namespace.useRef(!0),{viewport:st,selectedItem:it,selectedItemText:at,focusSelectedItem:ot}=l,lt=React__namespace.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&f&&st&&it&&at){const pt=o.trigger.getBoundingClientRect(),mt=f.getBoundingClientRect(),Rt=o.valueNode.getBoundingClientRect(),yt=at.getBoundingClientRect();if(o.dir!=="rtl"){const dr=yt.left-mt.left,Kt=Rt.left-dr,gr=pt.left-Kt,sr=pt.width+gr,or=Math.max(sr,mt.width),xr=window.innerWidth-CONTENT_MARGIN,Rr=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,xr-or)]);c.style.minWidth=sr+"px",c.style.left=Rr+"px"}else{const dr=mt.right-yt.right,Kt=window.innerWidth-Rt.right-dr,gr=window.innerWidth-pt.right-Kt,sr=pt.width+gr,or=Math.max(sr,mt.width),xr=window.innerWidth-CONTENT_MARGIN,Rr=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,xr-or)]);c.style.minWidth=sr+"px",c.style.right=Rr+"px"}const It=te(),ft=window.innerHeight-CONTENT_MARGIN*2,Ct=st.scrollHeight,Mt=window.getComputedStyle(f),Dt=parseInt(Mt.borderTopWidth,10),Vt=parseInt(Mt.paddingTop,10),Wt=parseInt(Mt.borderBottomWidth,10),$t=parseInt(Mt.paddingBottom,10),Ft=Dt+Vt+Ct+$t+Wt,Ht=Math.min(it.offsetHeight*5,Ft),nr=window.getComputedStyle(st),Jt=parseInt(nr.paddingTop,10),ar=parseInt(nr.paddingBottom,10),cr=pt.top+pt.height/2-CONTENT_MARGIN,Zt=ft-cr,lr=it.offsetHeight/2,Ut=it.offsetTop+lr,rr=Dt+Vt+Ut,qt=Ft-rr;if(rr<=cr){const dr=It.length>0&&it===It[It.length-1].ref.current;c.style.bottom="0px";const Kt=f.clientHeight-st.offsetTop-st.offsetHeight,gr=Math.max(Zt,lr+(dr?ar:0)+Kt+Wt),sr=rr+gr;c.style.height=sr+"px"}else{const dr=It.length>0&&it===It[0].ref.current;c.style.top="0px";const gr=Math.max(cr,Dt+st.offsetTop+(dr?Jt:0)+lr)+qt;c.style.height=gr+"px",st.scrollTop=rr-cr+st.offsetTop}c.style.margin=`${CONTENT_MARGIN}px 0`,c.style.minHeight=Ht+"px",c.style.maxHeight=ft+"px",s?.(),requestAnimationFrame(()=>A.current=!0)}},[te,o.trigger,o.valueNode,c,f,st,it,at,o.dir,s]);useLayoutEffect2(()=>lt(),[lt]);const[ut,ct]=React__namespace.useState();useLayoutEffect2(()=>{f&&ct(window.getComputedStyle(f).zIndex)},[f]);const dt=React__namespace.useCallback(pt=>{pt&&rt.current===!0&&(lt(),ot?.(),rt.current=!1)},[lt,ot]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:A,onScrollButtonChange:dt,children:jsxRuntime.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:ut},children:jsxRuntime.jsx(Primitive$4.div,{...a,ref:S,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),d=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,f=>{const R=f.currentTarget,{contentWrapper:S,shouldExpandOnScrollRef:te}=l;if(te?.current&&S){const A=Math.abs(d.current-R.scrollTop);if(A>0){const rt=window.innerHeight-CONTENT_MARGIN*2,st=parseFloat(S.style.minHeight),it=parseFloat(S.style.height),at=Math.max(st,it);if(at<rt){const ot=at+A,lt=Math.min(rt,ot),ut=ot-lt;S.style.height=lt+"px",S.style.bottom==="0px"&&(R.scrollTop=ut>0?ut:0,S.style.justifyContent="flex-end")}}}d.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),d=useSelectContentContext(ITEM_NAME$1,n),f=c.value===s,[R,S]=React__namespace.useState(o??""),[te,A]=React__namespace.useState(!1),rt=useComposedRefs(t,ot=>d.itemRefCallback?.(ot,s,a)),st=useId$1(),it=React__namespace.useRef("touch"),at=()=>{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:st,isSelected:f,onItemTextChange:React__namespace.useCallback(ot=>{S(lt=>lt||(ot?.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":st,"data-highlighted":te?"":void 0,"aria-selected":f&&te,"data-state":f?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:rt,onFocus:composeEventHandlers(l.onFocus,()=>A(!0)),onBlur:composeEventHandlers(l.onBlur,()=>A(!1)),onClick:composeEventHandlers(l.onClick,()=>{it.current!=="mouse"&&at()}),onPointerUp:composeEventHandlers(l.onPointerUp,()=>{it.current==="mouse"&&at()}),onPointerDown:composeEventHandlers(l.onPointerDown,ot=>{it.current=ot.pointerType}),onPointerMove:composeEventHandlers(l.onPointerMove,ot=>{it.current=ot.pointerType,a?d.onItemLeave?.():it.current==="mouse"&&ot.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(l.onPointerLeave,ot=>{ot.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:composeEventHandlers(l.onKeyDown,ot=>{d.searchRef?.current!==""&&ot.key===" "||(SELECTION_KEYS.includes(ot.key)&&at(),ot.key===" "&&ot.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),d=useSelectItemContext(ITEM_TEXT_NAME,n),f=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[R,S]=React__namespace.useState(null),te=useComposedRefs(t,at=>S(at),d.onItemTextChange,at=>c.itemTextRefCallback?.(at,d.value,d.disabled)),A=R?.textContent,rt=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:d.value,disabled:d.disabled,children:A},d.value),[d.disabled,d.value,A]),{onNativeOptionAdd:st,onNativeOptionRemove:it}=f;return useLayoutEffect2(()=>(st(rt),()=>it(rt)),[st,it,rt]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive$4.span,{id:d.textId,...o,ref:te}),d.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 f=d.scrollTop>0;o(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.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 f=d.scrollHeight-d.clientHeight,R=Math.ceil(d.scrollTop)<f;o(R)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.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),d=React__namespace.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return React__namespace.useEffect(()=>()=>d(),[d]),useLayoutEffect2(()=>{c().find(R=>R.ref.current===document.activeElement)?.ref.current?.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,()=>{o.onItemLeave?.(),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:composeEventHandlers(a.onPointerLeave,()=>{d()})})}),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 d=window.HTMLSelectElement.prototype,R=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==t&&R){const S=new Event("change",{bubbles:!0});R.call(c,t),c.dispatchEvent(S)}},[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 d(f){n.current=f,window.clearTimeout(s.current),f!==""&&(s.current=window.setTimeout(()=>d(""),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(f=>f===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(f=>f!==n));const d=l.find(f=>f.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==n?d: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-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 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}){const[s]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[a,o]=React.useState(()=>{const dt=t.Categories?.[0]?.CategoryCode??"";if(typeof window>"u")return dt;const pt=new URLSearchParams(window.location.search).get("category")?.trim();return pt&&t.Categories?.some(Rt=>Rt.CategoryCode===pt)?pt:dt}),[l,c]=React.useState(!1),[d,f]=React.useState(!1),[R,S]=React.useState("percentile"),[te,A]=React.useState(!1),{toast:rt}=useToast(),{data:st,isLoading:it,isFetching:at}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e,manufacturerId:t.ManufacturerId,categoryCode:a??""},{skip:!t.ManufacturerId||!a}),ot=async()=>{try{c(!0),f(!1),await s({routeResellerId:e,manufacturerId:t.ManufacturerId??"",categoryCode:a,shopifyHostName:n}).unwrap()&&rt({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(dt){console.error("Error syncing to Shopify:",dt),rt({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{c(!1)}},lt=()=>t.Categories?.find(dt=>dt.CategoryCode===a)?.CategoryName||a,ut=React.useMemo(()=>st?.Products?[...st.Products].sort((dt,pt)=>R==="price-asc"?(dt.MAP??0)-(pt.MAP??0):R==="price-desc"?(pt.MAP??0)-(dt.MAP??0):R==="name"?(dt.Title??"").localeCompare(pt.Title??""):R==="percentile"?(pt.OverallPercentileRank??0)-(dt.OverallPercentileRank??0):0):[],[st?.Products,R]),ct=React.useMemo(()=>te?ut.filter(dt=>{const pt=dt.Distribution?.Inventory;return!Array.isArray(pt)||pt.length===0?!1:pt.reduce((Rt,yt)=>Rt+(yt?.AvailableQuantity??0),0)>0}):ut,[te,ut]);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:lt(),niche:st?.Niche||"",productsNumber:st?.Products?.length||0,autoreorder:st?.AutoReorder||!1,starred:st?.Starred||!1,isLoading:it||at,children:n&&t.Categories?.findIndex(dt=>dt.AvailableToBuy)!==-1&&jsxRuntime.jsx(Button$1,{className:"bg-success text-success-foreground hover:bg-success/90",disabled:l,onClick:()=>f(!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:[t.Categories?.find(dt=>dt.CategoryCode===a)].filter(Boolean),manufID:t.ManufacturerId,appID:e}),jsxRuntime.jsx(ActiveOrdersCard,{orders:st?.ActiveOrderDetails??void 0,loading:it||at})]})]}),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-4 ms-auto",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Sort by:"}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsxs(Select$1,{value:R,onValueChange:S,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.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Checkbox,{id:"in-stock-filter",checked:te,onCheckedChange:dt=>A(dt===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:"in-stock-filter",className:"text-muted-foreground whitespace-nowrap",children:"In Stock"})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:it||at?Array.from({length:4}).map((dt,pt)=>jsxRuntime.jsx(ProductCard,{},pt)):ct.length>0?ct.map(dt=>jsxRuntime.jsx(ProductCard,{applicationId:e,product:dt,viewProductLink:`/${e}/Product/${dt.RandmarSKU}`,shopifyHostname:n},dt.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:te&&ut.length>0?"No in-stock products found in this category. Try turning off the In Stock filter.":"No products found for this manufacturer category."})]})}),jsxRuntime.jsx(Dialog,{open:d,onOpenChange:f,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 "',lt(),'" 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:()=>f(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-success text-success-foreground hover:bg-success/90",onClick:ot,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}){const{data:o}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),{data:l,isLoading:c,isFetching:d}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:e,partnerId:t,withSpecification:!0}),{toast:f}=useToast(),[R]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[S,te]=React.useState(!1),[A,rt]=React.useState(!1),st=async()=>{try{te(!0),rt(!1),await R({routeResellerId:e??"",manufacturerId:t??"",shopifyHostName:s}).unwrap()&&f({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(ut){console.error("Error syncing to Shopify:",ut),f({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{te(!1)}},it=()=>l?.Manufacturer?"products":l?.Reseller?"reseller-overview":"",at=()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("tab"),ot=()=>{const ut=at();return ut==="assistant"?"assistant":ut==="reseller-overview"&&l?.Reseller?"reseller-overview":ut==="manufacturer-overview"&&l?.Manufacturer?"manufacturer-overview":ut==="products"&&l?.Manufacturer?"products":it()||"assistant"},lt=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||d,withAbout:!0,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[(l?.Manufacturer||c||d)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:l?.Manufacturer,loading:c||d,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l?.Manufacturer&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:e,manufacturer:l?.Manufacturer}),s&&l?.Manufacturer?.Categories?.findIndex(ut=>ut.AvailableToBuy)!==-1&&jsxRuntime.jsxs(Dialog,{open:A,onOpenChange:rt,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"ml-2 bg-success text-success-foreground hover:bg-success/90",disabled:S,children:S?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 "',l?.Manufacturer?.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:()=>rt(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-success text-success-foreground hover:bg-success/90",onClick:st,disabled:S,children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),l?.Reseller&&jsxRuntime.jsx(ResellerCard,{reseller:l?.Reseller,loading:c||d})]})]}),(l?.Reseller||l?.Manufacturer)&&!c&&!d&&jsxRuntime.jsx("div",{className:"w-full p-4 sm:p-6",children:jsxRuntime.jsxs(Tabs,{defaultValue:ot(),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?.Reseller&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",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:"Reseller Overview"}),l?.Manufacturer&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",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:"Manufacturer Overview"}),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?.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?.Reseller,userEmail:n,isSuperAdmin:a,withoutReports:!0})})}),l?.Manufacturer&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:l?.Manufacturer,applicationId:e,userEmail:n})})}),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,{applicationId:e,prompt:lt,thinkingPlaceholderText:"Thinking about the relationship..."})})})]})}),(c||d)&&jsxRuntime.jsx("div",{className:"mt-4 flex h-32 w-full items-center justify-center p-4 sm:p-6",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,d]=React.useState({}),f=React.useMemo(()=>({publicEmail:e.PublicEmail??"",contactName:e.ContactName??"",phone:e.Phone??"",website:e.Website??""}),[e]),{register:R,handleSubmit:S,reset:te,watch:A,formState:{errors:rt,isSubmitting:st}}=useForm({defaultValues:f}),it=A(),at=React.useCallback(()=>c?JSON.stringify(it)!==JSON.stringify(c):!1,[it,c]);React.useEffect(()=>{a&&a(at())},[at,a]),React.useEffect(()=>{e&&Object.keys(e).length>0&&(te(f),d(f))},[e,te,f]);const ot=async ut=>{let ct=!0,dt=!1;const pt=Object.keys(ut).map(mt=>({key:mt,keyApi:mt.charAt(0).toUpperCase()+mt.slice(1)}));for(const mt of pt){const Rt=ut[mt.key],yt=e[mt.keyApi];if(Rt!==yt&&Rt!==void 0){dt=!0;try{await l({applicationId:t,fieldName:mt.keyApi,newValue:String(Rt)}).unwrap()||(ct=!1)}catch(It){console.error(`Error updating ${mt.keyApi}:`,It),ct=!1}}}ct&&dt?(o({title:"Public info",description:"Information updated successfully",variant:"success"}),d({...ut}),a&&a(!1)):ct||o({title:"Updation error",description:"Failed to update",variant:"destructive"})},lt=ut=>!ut||ut.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:[(lt(A("contactName"))||lt(A("publicEmail"))||lt(A("website"))||lt(A("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:S(ot),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:rt.contactName||lt(A("contactName"))?"input-error-indicator":""}),rt.contactName&&jsxRuntime.jsx("p",{className:"text-destructive text-sm",children:rt.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:rt.publicEmail||lt(A("publicEmail"))?"input-error-indicator":""}),rt.publicEmail&&jsxRuntime.jsx("p",{className:"text-destructive text-sm",children:rt.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:rt.website||lt(A("website"))?"input-error-indicator":""}),rt.website&&jsxRuntime.jsx("p",{className:"text-destructive text-sm",children:rt.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:rt.phone||lt(A("phone"))?"input-error-indicator":""}),rt.phone&&jsxRuntime.jsx("p",{className:"text-destructive text-sm",children:rt.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:st||s,className:s?"hidden":"",children:st?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:e,reseller:t,isLoading:n,withoutReports:s,userEmail:a,isSuperAdmin:o}){const{toast:l}=useToast(),{Statement:c,CreditLimit:d}=t,[f,R]=React.useState(!1),[S,te]=React.useState(!1),[A,rt]=React.useState(!1),[st,it]=React.useState(!1),[at,ot]=React.useState(a||""),[lt,ut]=React.useState(!1),[ct,dt]=React.useState(d?.toString()||""),[pt,{isLoading:mt}]=usePostV4PartnerByApplicationIdAccountResellerCreditLimitMutation(),Rt=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:c?.Over0||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar$1},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:c?.Over30||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:c?.Over45||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:c?.Total||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FormattedNumber,{value:d||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),o&&jsxRuntime.jsx(Button$1,{size:"icon",variant:"outline",className:"ml-2",onClick:()=>{ut(!0),dt(d?.toString()||"")},children:jsxRuntime.jsx(SquarePen,{})})]}),icon:CreditCard}],[yt]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),It=async Dt=>{Dt?R(!0):te(!0);try{const Wt=(await yt({routeResellerId:e,documentNumber:`ST${e}`})).data;if(!Wt)throw new Error("No data received for download.");if(Dt)window.open(Wt);else{const $t=document.createElement("a");$t.href=Wt,$t.download=`ST${e}.pdf`,document.body.appendChild($t),$t.click(),$t.remove()}l({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Vt){console.error("Download Error:",Vt),l({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{Dt?R(!1):te(!1)}},[ft]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),Ct=async()=>{if(!at||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(at)){l({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}rt(!0);try{await ft({routeResellerId:e,emailAddress:at}).unwrap(),l({title:"Success",description:`Statement sent to ${at} successfully.`,variant:"success"}),it(!1)}catch(Vt){console.error("Send Email Error:",Vt),l({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{rt(!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(Dt=>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"})]},Dt))}),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(Dt=>jsxRuntime.jsx("div",{className:Dt===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"})]})},Dt))})]}),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 Mt=!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:Rt.slice(0,3).map((Dt,Vt)=>jsxRuntime.jsx(BillingItem,{icon:Dt.icon,label:Dt.label,value:Dt.value},Vt))}),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:Rt.slice(3).map((Dt,Vt)=>jsxRuntime.jsx("div",{className:Vt===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:Dt.icon,label:Dt.label,value:Dt.value})},Vt))})]}),Mt&&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:()=>It(!0),disabled:f,children:f?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:()=>It(!1),disabled:S,children:S?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:()=>it(!0),disabled:A,children:A?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:st,onOpenChange:it,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:at,onChange:Dt=>ot(Dt.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:Ct,disabled:A||!at,children:A?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:lt,onOpenChange:ut,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:ct,onChange:Dt=>dt(Dt.target.value),className:"col-span-3",placeholder:"0.00"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:async()=>{const Dt=Number(ct);if(isNaN(Dt)){l({title:"Invalid Amount",description:"Please enter a valid number for credit limit.",variant:"destructive"});return}try{await pt({applicationId:e,newValue:Dt}).unwrap(),ut(!1),l({title:"Success",description:"Credit limit updated successfully.",variant:"success"})}catch(Vt){console.error("Update Credit Limit Error:",Vt),l({title:"Error",description:"Failed to update credit limit. Please try again.",variant:"destructive"})}},disabled:mt,children:mt?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,
|
|
486
486
|
$15 for drop shipped orders under $1,500,
|
|
487
|
-
$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),[d,f]=React.useState(""),[R,{isLoading:S}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),te=Dt=>Dt&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco",COOPSCO:"coopsco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Dt]||"",A=Dt=>Dt&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Dt]||"",rt=Dt=>Dt&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Dt]||"",[st,it]=React.useState(te(n?.Priority??"")),[at,ot]=React.useState(A(n?.ShippingProfile??"")),[lt,ut]=React.useState(rt(n?.PriceProfile)),ct=Dt=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",coopsco:"COOPSCO",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Dt]||Dt,dt=Dt=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Dt]||Dt,pt=Dt=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Dt]||Dt;React.useEffect(()=>{it(te(n?.Priority??"")),ot(A(n?.ShippingProfile??"")),ut(rt(n?.PriceProfile))},[n]);const mt=async(Dt,Vt,Wt,$t)=>{try{(await R({applicationId:s,fieldName:Dt,newValue:Vt})).error?o({title:"Error",description:$t,variant:"destructive"}):o({title:"Success",description:Wt,variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},Rt=async Dt=>{it(Dt);const Vt=ct(Dt);mt("Priority",Vt,`Priority updated to ${Vt}`,"Failed to update priority")},yt=async Dt=>{ot(Dt);const Vt=dt(Dt);mt("ShippingProfile",Vt,`Shipping profile updated to ${Vt}`,"Failed to update shipping profile")},It=async Dt=>{ut(Dt);const Vt=pt(Dt);mt("PriceProfile",Vt,`Pricing profile updated to ${Vt}`,"Failed to update pricing profile")},ft=async()=>{try{const Dt=await R({applicationId:s,fieldName:"Tier",newValue:d});Dt.error?o({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Dt.data?o({title:"Success",description:`Pricing Tier changed to ${d}`,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),f("")}},Ct=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:e}],Mt=Dt=>{f(Dt),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(Dt=>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"})]})]},Dt))}),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-base font-medium text-foreground",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"success",className:"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?.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-success"})]}),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?.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"}),Ct.map(Dt=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Dt.enabled,onClick:()=>Mt(Dt.name),children:Dt.name},Dt.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:S,open:l,setOpen:c,tier:d,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:st,onValueChange:Rt,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(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`priority-${Dt.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.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:at,onValueChange:yt,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(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`shipping-${Dt.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.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:lt,onValueChange:It,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(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`pricing-${Dt.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]})]})})]})]})};function OrderCategories({openOrders:e=[],isLoading:t=!1}){const n=e?.filter(st=>st.DocumentType==="Order")||[],s=e?.filter(st=>st.DocumentType==="Shipment")||[],a=n.filter(st=>st.WarehouseCode!=="3PLE"),o=a.reduce((st,it)=>st+(it.Quantity??0),0),l=a.reduce((st,it)=>st+(it.ExtendedPrice??0),0),c=n.filter(st=>st.WarehouseCode==="3PLE"),d=c.reduce((st,it)=>st+(it.Quantity??0),0),f=c.reduce((st,it)=>st+(it.ExtendedPrice??0),0),R=s.reduce((st,it)=>st+(it.Quantity??0),0),S=s.reduce((st,it)=>st+(it.ExtendedPrice??0),0),te=o+d+R,A=l+f+S,rt=[{name:"All",icon:Package,stripeClass:"bg-info/60",iconBgClass:"bg-info/90",iconTextClass:"text-info-foreground",orders:te,amount:A},{name:"Processing",icon:RefreshCcw,stripeClass:"bg-warning/60",iconBgClass:"bg-warning/90",iconTextClass:"text-warning-foreground",orders:o,amount:l},{name:"Shipped",icon:Truck,stripeClass:"bg-success/60",iconBgClass:"bg-success/90",iconTextClass:"text-success-foreground",orders:R,amount:S},{name:"Delayed",icon:CircleAlert,stripeClass:"bg-destructive/60",iconBgClass:"bg-destructive/90",iconTextClass:"text-destructive-foreground",orders:d,amount:f}];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(st=>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-border 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"})]})]})]})]})},st))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:rt.map(st=>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:`${st.stripeClass} 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:st.name}),jsxRuntime.jsx("div",{className:`${st.iconBgClass} p-2 rounded-full`,children:jsxRuntime.jsx(st.icon,{className:`size-4 shrink-0 ${st.iconTextClass}`})})]}),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:st.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:st.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},st.name))})})]})}function ReportsSection({isLoading:e,userEmail:t,appID:n}){const{toast:s}=useToast(),[a,{isLoading:o}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[l,{isLoading:c}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[d,{isLoading:f}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[R,{isLoading:S}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[te,{isLoading:A}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[rt,{isLoading:st}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[it,at]=React.useState(null),[ot,lt]=React.useState(t),[ut,ct]=React.useState(!1),[dt,pt]=React.useState("all"),{data:mt,isLoading:Rt}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),yt=[{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}]}],It=async Mt=>{at(Mt),Mt.id==="Products"&&pt("all"),ct(!0)},ft=async()=>{if(!(!it||!n))try{switch(it.id){case"Products":{const Mt={routeResellerId:n,emailAddress:ot};dt&&dt!=="all"&&(Mt.manufacturerId=dt),await R(Mt).unwrap();break}case"AmazonTrackingFile":await l({routeResellerId:n,emailAddress:ot}).unwrap();break;case"WalmartTrackingFile":await a({routeResellerId:n,emailAddress:ot}).unwrap();break;case"OpenOrders":await d({routeResellerId:n,emailAddress:ot}).unwrap();break;case"Invoices":await te({routeResellerId:n,emailAddress:ot}).unwrap();break;case"Statement":await rt({routeResellerId:n,emailAddress:ot}).unwrap();break;default:throw new Error("invalid report id")}s({title:"Report requested",description:`The ${it.title} will be sent to ${ot} shortly.`,variant:"success"}),ct(!1)}catch(Mt){console.error("Error requesting report:",Mt),s({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},Ct=f||S||c||o||st||A;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(Mt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(Dt=>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"})]},Dt))]},Mt))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:yt.map(Mt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:Mt.name}),Mt.reports.map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-muted transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(Dt.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:Dt.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Dt.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>It(Dt),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},Dt.id))]},Mt.name))})}),jsxRuntime.jsx(Dialog,{open:ut,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",it?.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:ot,onChange:Mt=>lt(Mt.target.value),placeholder:"your@email.com",className:"mt-2"})]}),it?.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:dt,onChange:Mt=>pt(Mt.target.value),disabled:Rt,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!Rt&&Array.isArray(mt)&&mt.slice().sort((Mt,Dt)=>(Mt.PublicName||Mt.Name||"").localeCompare(Dt.PublicName||Dt.Name||"")).map(Mt=>Mt?.ManufacturerId?jsxRuntime.jsx("option",{value:Mt.ManufacturerId,children:(Mt.PublicName||Mt.Name||Mt.ManufacturerId)+(Mt.OpenToWork?" (Open to Work)":"")},Mt.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:()=>ct(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ft,disabled:!ot||Ct,children:Ct?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,d]=React.useState(!1),f=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",dotClassName:"bg-primary",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"var(--chart-2)",dotClassName:"bg-chart-2",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(s||!e){l([]);return}let R=[];if(t==="week"){const S=new Map;e.forEach(te=>{const A=te.Day?.toString()||"";if(A.length===8){const rt=parseInt(A.substring(0,4),10),st=parseInt(A.substring(4,6),10)-1,it=parseInt(A.substring(6,8),10),at=new Date(rt,st,it),ot=new Date(at);ot.setDate(at.getDate()-at.getDay());const lt=`${ot.getFullYear()}-${String(ot.getMonth()+1).padStart(2,"0")}-${String(ot.getDate()).padStart(2,"0")}`,ut=S.get(lt)||{price:0,quantity:0};ut.price+=te.ExtendedPrice||0,ut.quantity+=te.Quantity||0,S.set(lt,ut)}}),R=Array.from(S).sort(([te],[A])=>te.localeCompare(A)).map(([te,A])=>({date:`${te.substring(5,7)}/${te.substring(8,10)}`,dollarVolume:A.price,unitsSold:A.quantity}))}else{const S=new Date,te=S.getFullYear(),A=S.getMonth(),rt=S.getDate(),st=`${te}-${(A+1).toString().padStart(2,"0")}`,it=Array.from({length:12},(ot,lt)=>{const ut=new Date(te,A-(11-lt),1);return`${ut.getFullYear()}-${(ut.getMonth()+1).toString().padStart(2,"0")}`}),at=Object.fromEntries(it.map(ot=>[ot,{price:0,quantity:0}]));if(e.forEach(ot=>{const lt=String(ot.Day??0);if(lt.length!==8)return;const ut=`${lt.substring(0,4)}-${lt.substring(4,6)}`;at[ut]&&(at[ut].price+=ot.ExtendedPrice??0,at[ut].quantity+=ot.Quantity??0)}),R=it.map(ot=>{const lt=at[ot],[ut,ct]=ot.split("-").map(Number);return{date:new Date(ut,ct-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:lt.price,unitsSold:lt.quantity}}),c){const ot=at[st];if(ot&&ot.price>0&&rt>0){const lt=new Date(te,A+1,0).getDate();if(rt<lt){const ut=ot.price/rt,ct=ot.quantity/rt,dt=ut*lt,pt=ct*lt,mt=R[R.length-1];mt&&(mt.dollarVolume=dt,mt.unitsSold=pt)}}}}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:f,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:d,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[d,f]=React.useState(!1),R=te=>{te.preventDefault(),te.stopPropagation(),navigator.clipboard.writeText(t),f(!0),setTimeout(()=>f(!1),2e3)},S=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}),d?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-success"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d?"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:S}):S}function ManufacturerCard({manufacturer:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1,appID:l}){const{toast:c}=useToast(),[d,{isLoading:f}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[R,S]=React.useState(!1),[te,A]=React.useState(""),{data:rt}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:l||""},{skip:!l}),st=rt?.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 it=[e.City,e.Province,e.Country].filter(Boolean),at=it.length>0?it.join(", "):"",ot=e.Tags?.split(",").map(ut=>ut.trim()).filter(Boolean)||[],lt=async()=>{if(!(!e?.ManufacturerId||!l||!te))try{await d({routeResellerId:l,emailAddress:te,manufacturerId:e.ManufacturerId}).unwrap(),c({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${te} shortly.`,variant:"success"}),S(!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:"flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:e.ManufacturerId,publicName:e.PublicName,name:e.Name,location:at,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:[(!!e.Qualification?.QualificationId&&e.Qualification?.QualificationId!=="Suspended"||!!e.OpenToWork||!!e.OnHold&&e.OnHold!==0||ot.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"}),ot.map((ut,ct)=>jsxRuntime.jsx(Badge,{variant:"outline",children:ut},ct))]}),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||st&&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,st&&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:()=>S(!0),disabled:f,children:f?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:S,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:te,onChange:ut=>A(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:()=>S(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:lt,disabled:!te||f,children:f?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}){const o=React.useRef(null),l=useIntersectionObserver({elementRef:o,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:c}=useToast(),[d,f]=React.useState(!1),[R,S]=React.useState(!1),[te,A]=React.useState(!1),{data:rt,isLoading:st,isFetching:it}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e||!l}),{data:at,isLoading:ot,isFetching:lt}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t,withSpecification:!1},{skip:!!n||!l}),[ut]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),ct=n??at?.Distribution?.Inventory;React.useEffect(()=>{f(!1)},[t]);const{inventoryQuantity:dt,totalIncomingQuantity:pt}=React.useMemo(()=>{if(!ct||ct.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const It=ct.reduce((Ct,Mt)=>Ct+(Mt.AvailableQuantity||0),0),ft=ct.reduce((Ct,Mt)=>Ct+(Mt.PurchaseOrderQuantity||0),0);return{inventoryQuantity:It,totalIncomingQuantity:ft}},[ct]);if(st||it||ot||lt)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(Skeleton,{className:cn("h-10 w-36 rounded-md",a)})});const Rt=()=>{te||!rt?.IsReseller||(A(!0),ut({routeResellerId:e??"",randmarSku:t??""}).then(It=>{It.error||It.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"}),S(!1)}).catch(It=>{console.error(It),c({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{A(!1)}))};if(!ct)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(rt?.IsReseller&&dt<=0&&pt<=0)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:R,onOpenChange:S,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm 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:()=>S(!1),disabled:te,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:Rt,disabled:te,children:te?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const yt=dt<=0&&pt>0;return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:d,onOpenChange:f,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm",yt?"text-info":dt>0?"text-success":"text-destructive",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),yt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(pt)," Incoming"]}):dt>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(dt)," 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:ct})]})]})})}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 d=Array.from(new Set(t.map(rt=>rt.WarehouseCode).filter(rt=>rt!=null)));c.WarehouseCode=d;const f=Array.from(new Set(t.map(rt=>rt.ShipToName).filter(rt=>rt!=null)));c.ShipToName=f;const R=Array.from(new Set(t.map(rt=>rt.DocumentNumber).filter(rt=>rt!=null)));c.DocumentNumber=R;const S=Array.from(new Set(t.map(rt=>rt.OrderNumber).filter(rt=>rt!=null)));c.OrderNumber=S;const te=Array.from(new Set(t.map(rt=>rt.PONumber).filter(rt=>rt!=null)));c.PONumber=te;const A=Array.from(new Set(t.map(rt=>rt.MPN).filter(rt=>rt!=null)));c.MPN=A}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,loadFullAfterSummary:l=!1}){const c=`${e}|${l?1:0}`,d=React.useRef(c),[f,R]=React.useState(()=>l?!!t:!1);React.useEffect(()=>{d.current!==c&&(d.current=c,R(!1))},[c]),React.useEffect(()=>{l&&t&&R(!0)},[l,t]);const S=l?f:!t,{data:te,isLoading:A,isError:rt}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:e??"",withSpecification:!0},{skip:!e||!S}),[st,it]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),at=React.useCallback(()=>n?!1:st.publicInfo.hasUnsavedChanges,[n,st]),ot=React.useCallback((yt,It)=>{it(ft=>ft[yt]?.hasUnsavedChanges!==It.hasUnsavedChanges?{...ft,[yt]:It}:ft)},[]),{NavigationGuardDialog:lt}=useRouterNavigationGuard(at),ut=te??t,ct=A&&!ut,dt=rt&&!ut,pt=!n||!!ut?.Statement&&(ut.Statement.Total??0)>0,mt=ut?.QualifiedManufacturers??[],Rt=ut?.Qualifications??[];return jsxRuntime.jsxs("div",{className:"@container",children:[dt?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:ut?.FiscalYearMonthStart||1,salesData:ut?.SalesData,isLoading:ct}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:ut?.SalesStatistics??[],loading:ct}),jsxRuntime.jsx(OrderCategories,{openOrders:ut?.ActiveOrderDetails??[],isLoading:ct}),pt&&jsxRuntime.jsx(BillingCard,{appID:e,reseller:ut||{},withoutReports:o,isLoading:ct,userEmail:s,isSuperAdmin:a}),jsxRuntime.jsx(PublicInfo,{reseller:ut||{},appID:e??"",isLoading:ct,readonly:n,onUnsavedChanges:yt=>ot("publicInfo",{hasUnsavedChanges:yt})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:a,readonly:n,reseller:ut||{},appID:e??"",isLoading:ct})]}),ct||mt.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:ct?Array.from({length:2}).map((yt,It)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},It)):mt.map(yt=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:yt,link:`https://dashboard.randmar.io/${e}/Partner/${yt.ManufacturerId}`},yt.ManufacturerId))})})]}):Rt.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:Rt}),(ut?.Opportunities?.length??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:ut?.Opportunities,loading:ct}),(ut?.ActiveOrderDetails?.length??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:ut?.ActiveOrderDetails,loading:ct}),(ut?.CompletedOrderDetails?.length??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:ut?.CompletedOrderDetails,loading:ct}),(ut?.Returns?.length??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:ut?.Returns,loading:ct}),!o&&jsxRuntime.jsx(ReportsSection,{appID:e,userEmail:s,isLoading:ct})]}),jsxRuntime.jsx(lt,{})]})}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 bg-destructive/10 text-foreground [&>svg]:text-destructive",success:"border-success/50 bg-success/10 text-foreground [&>svg]:text-success",warning:"border-warning/50 bg-warning/10 text-foreground [&>svg]:text-warning",info:"border-info/50 bg-info/10 text-foreground [&>svg]:text-info"}},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";function functionalUpdate(e,t){return typeof e=="function"?e(t):e}function makeStateUpdater(e,t){return n=>{t.setState(s=>({...s,[e]:functionalUpdate(n,s[e])}))}}function isFunction$2(e){return e instanceof Function}function isNumberArray(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function flattenBy(e,t){const n=[],s=a=>{a.forEach(o=>{n.push(o);const l=t(o);l!=null&&l.length&&s(l)})};return s(e),n}function memo(e,t,n){let s=[],a;return o=>{let l;n.key&&n.debug&&(l=Date.now());const c=e(o);if(!(c.length!==s.length||c.some((R,S)=>s[S]!==R)))return a;s=c;let f;if(n.key&&n.debug&&(f=Date.now()),a=t(...c),n==null||n.onChange==null||n.onChange(a),n.key&&n.debug&&n!=null&&n.debug()){const R=Math.round((Date.now()-l)*100)/100,S=Math.round((Date.now()-f)*100)/100,te=S/16,A=(rt,st)=>{for(rt=String(rt);rt.length<st;)rt=" "+rt;return rt};console.info(`%c⏱ ${A(S,5)} /${A(R,5)} ms`,`
|
|
487
|
+
$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),[d,f]=React.useState(""),[R,{isLoading:S}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),te=Dt=>Dt&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco",COOPSCO:"coopsco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Dt]||"",A=Dt=>Dt&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Dt]||"",rt=Dt=>Dt&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Dt]||"",[st,it]=React.useState(te(n?.Priority??"")),[at,ot]=React.useState(A(n?.ShippingProfile??"")),[lt,ut]=React.useState(rt(n?.PriceProfile)),ct=Dt=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",coopsco:"COOPSCO",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Dt]||Dt,dt=Dt=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Dt]||Dt,pt=Dt=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Dt]||Dt;React.useEffect(()=>{it(te(n?.Priority??"")),ot(A(n?.ShippingProfile??"")),ut(rt(n?.PriceProfile))},[n]);const mt=async(Dt,Vt,Wt,$t)=>{try{(await R({applicationId:s,fieldName:Dt,newValue:Vt})).error?o({title:"Error",description:$t,variant:"destructive"}):o({title:"Success",description:Wt,variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},Rt=async Dt=>{it(Dt);const Vt=ct(Dt);mt("Priority",Vt,`Priority updated to ${Vt}`,"Failed to update priority")},yt=async Dt=>{ot(Dt);const Vt=dt(Dt);mt("ShippingProfile",Vt,`Shipping profile updated to ${Vt}`,"Failed to update shipping profile")},It=async Dt=>{ut(Dt);const Vt=pt(Dt);mt("PriceProfile",Vt,`Pricing profile updated to ${Vt}`,"Failed to update pricing profile")},ft=async()=>{try{const Dt=await R({applicationId:s,fieldName:"Tier",newValue:d});Dt.error?o({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Dt.data?o({title:"Success",description:`Pricing Tier changed to ${d}`,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),f("")}},Ct=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:e}],Mt=Dt=>{f(Dt),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(Dt=>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"})]})]},Dt))}),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-base font-medium text-foreground",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"success",className:"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?.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-success"})]}),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?.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"}),Ct.map(Dt=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Dt.enabled,onClick:()=>Mt(Dt.name),children:Dt.name},Dt.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:S,open:l,setOpen:c,tier:d,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:st,onValueChange:Rt,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(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`priority-${Dt.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.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:at,onValueChange:yt,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(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`shipping-${Dt.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.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:lt,onValueChange:It,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(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`pricing-${Dt.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]})]})})]})]})};function OrderCategories({openOrders:e=[],isLoading:t=!1}){const n=e?.filter(st=>st.DocumentType==="Order")||[],s=e?.filter(st=>st.DocumentType==="Shipment")||[],a=n.filter(st=>st.WarehouseCode!=="3PLE"),o=a.reduce((st,it)=>st+(it.Quantity??0),0),l=a.reduce((st,it)=>st+(it.ExtendedPrice??0),0),c=n.filter(st=>st.WarehouseCode==="3PLE"),d=c.reduce((st,it)=>st+(it.Quantity??0),0),f=c.reduce((st,it)=>st+(it.ExtendedPrice??0),0),R=s.reduce((st,it)=>st+(it.Quantity??0),0),S=s.reduce((st,it)=>st+(it.ExtendedPrice??0),0),te=o+d+R,A=l+f+S,rt=[{name:"All",icon:Package,stripeClass:"bg-info/60",iconBgClass:"bg-info/90",iconTextClass:"text-info-foreground",orders:te,amount:A},{name:"Processing",icon:RefreshCcw,stripeClass:"bg-warning/60",iconBgClass:"bg-warning/90",iconTextClass:"text-warning-foreground",orders:o,amount:l},{name:"Shipped",icon:Truck,stripeClass:"bg-success/60",iconBgClass:"bg-success/90",iconTextClass:"text-success-foreground",orders:R,amount:S},{name:"Delayed",icon:CircleAlert,stripeClass:"bg-destructive/60",iconBgClass:"bg-destructive/90",iconTextClass:"text-destructive-foreground",orders:d,amount:f}];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(st=>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-border 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"})]})]})]})]})},st))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:rt.map(st=>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:`${st.stripeClass} 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:st.name}),jsxRuntime.jsx("div",{className:`${st.iconBgClass} p-2 rounded-full`,children:jsxRuntime.jsx(st.icon,{className:`size-4 shrink-0 ${st.iconTextClass}`})})]}),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:st.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:st.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},st.name))})})]})}function ReportsSection({isLoading:e,userEmail:t,appID:n}){const{toast:s}=useToast(),[a,{isLoading:o}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[l,{isLoading:c}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[d,{isLoading:f}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[R,{isLoading:S}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[te,{isLoading:A}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[rt,{isLoading:st}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[it,at]=React.useState(null),[ot,lt]=React.useState(t),[ut,ct]=React.useState(!1),[dt,pt]=React.useState("all"),{data:mt,isLoading:Rt}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),yt=[{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}]}],It=async Mt=>{at(Mt),Mt.id==="Products"&&pt("all"),ct(!0)},ft=async()=>{if(!(!it||!n))try{switch(it.id){case"Products":{const Mt={routeResellerId:n,emailAddress:ot};dt&&dt!=="all"&&(Mt.manufacturerId=dt),await R(Mt).unwrap();break}case"AmazonTrackingFile":await l({routeResellerId:n,emailAddress:ot}).unwrap();break;case"WalmartTrackingFile":await a({routeResellerId:n,emailAddress:ot}).unwrap();break;case"OpenOrders":await d({routeResellerId:n,emailAddress:ot}).unwrap();break;case"Invoices":await te({routeResellerId:n,emailAddress:ot}).unwrap();break;case"Statement":await rt({routeResellerId:n,emailAddress:ot}).unwrap();break;default:throw new Error("invalid report id")}s({title:"Report requested",description:`The ${it.title} will be sent to ${ot} shortly.`,variant:"success"}),ct(!1)}catch(Mt){console.error("Error requesting report:",Mt),s({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},Ct=f||S||c||o||st||A;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(Mt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(Dt=>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"})]},Dt))]},Mt))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:yt.map(Mt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:Mt.name}),Mt.reports.map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-muted transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(Dt.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:Dt.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Dt.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>It(Dt),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},Dt.id))]},Mt.name))})}),jsxRuntime.jsx(Dialog,{open:ut,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",it?.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:ot,onChange:Mt=>lt(Mt.target.value),placeholder:"your@email.com",className:"mt-2"})]}),it?.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:dt,onChange:Mt=>pt(Mt.target.value),disabled:Rt,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!Rt&&Array.isArray(mt)&&mt.slice().sort((Mt,Dt)=>(Mt.PublicName||Mt.Name||"").localeCompare(Dt.PublicName||Dt.Name||"")).map(Mt=>Mt?.ManufacturerId?jsxRuntime.jsx("option",{value:Mt.ManufacturerId,children:(Mt.PublicName||Mt.Name||Mt.ManufacturerId)+(Mt.OpenToWork?" (Open to Work)":"")},Mt.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:()=>ct(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ft,disabled:!ot||Ct,children:Ct?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,d]=React.useState(!1),f=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",dotClassName:"bg-primary",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"var(--chart-2)",dotClassName:"bg-chart-2",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(s||!e){l([]);return}let R=[];if(t==="week"){const S=new Map;e.forEach(te=>{const A=te.Day?.toString()||"";if(A.length===8){const rt=parseInt(A.substring(0,4),10),st=parseInt(A.substring(4,6),10)-1,it=parseInt(A.substring(6,8),10),at=new Date(rt,st,it),ot=new Date(at);ot.setDate(at.getDate()-at.getDay());const lt=`${ot.getFullYear()}-${String(ot.getMonth()+1).padStart(2,"0")}-${String(ot.getDate()).padStart(2,"0")}`,ut=S.get(lt)||{price:0,quantity:0};ut.price+=te.ExtendedPrice||0,ut.quantity+=te.Quantity||0,S.set(lt,ut)}}),R=Array.from(S).sort(([te],[A])=>te.localeCompare(A)).map(([te,A])=>({date:`${te.substring(5,7)}/${te.substring(8,10)}`,dollarVolume:A.price,unitsSold:A.quantity}))}else{const S=new Date,te=S.getFullYear(),A=S.getMonth(),rt=S.getDate(),st=`${te}-${(A+1).toString().padStart(2,"0")}`,it=Array.from({length:12},(ot,lt)=>{const ut=new Date(te,A-(11-lt),1);return`${ut.getFullYear()}-${(ut.getMonth()+1).toString().padStart(2,"0")}`}),at=Object.fromEntries(it.map(ot=>[ot,{price:0,quantity:0}]));if(e.forEach(ot=>{const lt=String(ot.Day??0);if(lt.length!==8)return;const ut=`${lt.substring(0,4)}-${lt.substring(4,6)}`;at[ut]&&(at[ut].price+=ot.ExtendedPrice??0,at[ut].quantity+=ot.Quantity??0)}),R=it.map(ot=>{const lt=at[ot],[ut,ct]=ot.split("-").map(Number);return{date:new Date(ut,ct-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:lt.price,unitsSold:lt.quantity}}),c){const ot=at[st];if(ot&&ot.price>0&&rt>0){const lt=new Date(te,A+1,0).getDate();if(rt<lt){const ut=ot.price/rt,ct=ot.quantity/rt,dt=ut*lt,pt=ct*lt,mt=R[R.length-1];mt&&(mt.dollarVolume=dt,mt.unitsSold=pt)}}}}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:f,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:d,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[d,f]=React.useState(!1),R=te=>{te.preventDefault(),te.stopPropagation(),navigator.clipboard.writeText(t),f(!0),setTimeout(()=>f(!1),2e3)},S=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}),d?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-success"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d?"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:S}):S}function ManufacturerCard({manufacturer:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1,appID:l}){const{toast:c}=useToast(),[d,{isLoading:f}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[R,S]=React.useState(!1),[te,A]=React.useState(""),{data:rt}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:l||""},{skip:!l}),st=rt?.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 it=[e.City,e.Province,e.Country].filter(Boolean),at=it.length>0?it.join(", "):"",ot=e.Tags?.split(",").map(ut=>ut.trim()).filter(Boolean)||[],lt=async()=>{if(!(!e?.ManufacturerId||!l||!te))try{await d({routeResellerId:l,emailAddress:te,manufacturerId:e.ManufacturerId}).unwrap(),c({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${te} shortly.`,variant:"success"}),S(!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:"flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:e.ManufacturerId,publicName:e.PublicName,name:e.Name,location:at,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:[(!!e.Qualification?.QualificationId&&e.Qualification?.QualificationId!=="Suspended"||!!e.OpenToWork||!!e.OnHold&&e.OnHold!==0||ot.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"}),ot.map((ut,ct)=>jsxRuntime.jsx(Badge,{variant:"outline",children:ut},ct))]}),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||st&&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,st&&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:()=>S(!0),disabled:f,children:f?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:S,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:te,onChange:ut=>A(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:()=>S(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:lt,disabled:!te||f,children:f?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}){const o=React.useRef(null),l=useIntersectionObserver({elementRef:o,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:c}=useToast(),[d,f]=React.useState(!1),[R,S]=React.useState(!1),[te,A]=React.useState(!1),{data:rt,isLoading:st,isFetching:it}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e||!l}),{data:at,isLoading:ot,isFetching:lt}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t,withSpecification:!1},{skip:!!n||!l}),[ut]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),ct=n??at?.Distribution?.Inventory;React.useEffect(()=>{f(!1)},[t]);const{inventoryQuantity:dt,totalIncomingQuantity:pt}=React.useMemo(()=>{if(!ct||ct.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const It=ct.reduce((Ct,Mt)=>Ct+(Mt.AvailableQuantity||0),0),ft=ct.reduce((Ct,Mt)=>Ct+(Mt.PurchaseOrderQuantity||0),0);return{inventoryQuantity:It,totalIncomingQuantity:ft}},[ct]);if(st||it||ot||lt)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(Skeleton,{className:cn("h-10 w-36 rounded-md",a)})});const Rt=()=>{te||!rt?.IsReseller||(A(!0),ut({routeResellerId:e??"",randmarSku:t??""}).then(It=>{It.error||It.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"}),S(!1)}).catch(It=>{console.error(It),c({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{A(!1)}))};if(!ct)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(rt?.IsReseller&&dt<=0&&pt<=0)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:R,onOpenChange:S,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm 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:()=>S(!1),disabled:te,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:Rt,disabled:te,children:te?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const yt=dt<=0&&pt>0;return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:d,onOpenChange:f,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm",yt?"text-info":dt>0?"text-success":"text-destructive",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),yt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(pt)," Incoming"]}):dt>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(dt)," 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:ct})]})]})})}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 d=Array.from(new Set(t.map(rt=>rt.WarehouseCode).filter(rt=>rt!=null)));c.WarehouseCode=d;const f=Array.from(new Set(t.map(rt=>rt.ShipToName).filter(rt=>rt!=null)));c.ShipToName=f;const R=Array.from(new Set(t.map(rt=>rt.DocumentNumber).filter(rt=>rt!=null)));c.DocumentNumber=R;const S=Array.from(new Set(t.map(rt=>rt.OrderNumber).filter(rt=>rt!=null)));c.OrderNumber=S;const te=Array.from(new Set(t.map(rt=>rt.PONumber).filter(rt=>rt!=null)));c.PONumber=te;const A=Array.from(new Set(t.map(rt=>rt.MPN).filter(rt=>rt!=null)));c.MPN=A}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,loadFullAfterSummary:l=!1}){const c=`${e}|${l?1:0}`,d=React.useRef(c),[f,R]=React.useState(()=>l?!!t:!1);React.useEffect(()=>{d.current!==c&&(d.current=c,R(!1))},[c]),React.useEffect(()=>{l&&t&&R(!0)},[l,t]);const S=l?f:!t,{data:te,isLoading:A,isError:rt}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:e??"",withSpecification:!0},{skip:!e||!S}),[st,it]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),at=React.useCallback(()=>n?!1:st.publicInfo.hasUnsavedChanges,[n,st]),ot=React.useCallback((yt,It)=>{it(ft=>ft[yt]?.hasUnsavedChanges!==It.hasUnsavedChanges?{...ft,[yt]:It}:ft)},[]),{NavigationGuardDialog:lt}=useRouterNavigationGuard(at),ut=te??t,ct=A&&!ut,dt=rt&&!ut,pt=!n||!!ut?.Statement&&(ut.Statement.Total??0)!==0,mt=ut?.QualifiedManufacturers??[],Rt=ut?.Qualifications??[];return jsxRuntime.jsxs("div",{className:"@container",children:[dt?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:ut?.FiscalYearMonthStart||1,salesData:ut?.SalesData,isLoading:ct}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:ut?.SalesStatistics??[],loading:ct}),jsxRuntime.jsx(OrderCategories,{openOrders:ut?.ActiveOrderDetails??[],isLoading:ct}),pt&&jsxRuntime.jsx(BillingCard,{appID:e,reseller:ut||{},withoutReports:o,isLoading:ct,userEmail:s,isSuperAdmin:a}),jsxRuntime.jsx(PublicInfo,{reseller:ut||{},appID:e??"",isLoading:ct,readonly:n,onUnsavedChanges:yt=>ot("publicInfo",{hasUnsavedChanges:yt})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:a,readonly:n,reseller:ut||{},appID:e??"",isLoading:ct}),ct||mt.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:ct?Array.from({length:2}).map((yt,It)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},It)):mt.map(yt=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:yt,link:`https://dashboard.randmar.io/${e}/Partner/${yt.ManufacturerId}`},yt.ManufacturerId))})})]}):Rt.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:Rt})]}),(ut?.Opportunities?.length??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:ut?.Opportunities,loading:ct}),(ut?.ActiveOrderDetails?.length??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:ut?.ActiveOrderDetails,loading:ct}),(ut?.CompletedOrderDetails?.length??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:ut?.CompletedOrderDetails,loading:ct}),(ut?.Returns?.length??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:ut?.Returns,loading:ct}),!o&&jsxRuntime.jsx(ReportsSection,{appID:e,userEmail:s,isLoading:ct})]}),jsxRuntime.jsx(lt,{})]})}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 bg-destructive/10 text-foreground [&>svg]:text-destructive",success:"border-success/50 bg-success/10 text-foreground [&>svg]:text-success",warning:"border-warning/50 bg-warning/10 text-foreground [&>svg]:text-warning",info:"border-info/50 bg-info/10 text-foreground [&>svg]:text-info"}},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";function functionalUpdate(e,t){return typeof e=="function"?e(t):e}function makeStateUpdater(e,t){return n=>{t.setState(s=>({...s,[e]:functionalUpdate(n,s[e])}))}}function isFunction$2(e){return e instanceof Function}function isNumberArray(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function flattenBy(e,t){const n=[],s=a=>{a.forEach(o=>{n.push(o);const l=t(o);l!=null&&l.length&&s(l)})};return s(e),n}function memo(e,t,n){let s=[],a;return o=>{let l;n.key&&n.debug&&(l=Date.now());const c=e(o);if(!(c.length!==s.length||c.some((R,S)=>s[S]!==R)))return a;s=c;let f;if(n.key&&n.debug&&(f=Date.now()),a=t(...c),n==null||n.onChange==null||n.onChange(a),n.key&&n.debug&&n!=null&&n.debug()){const R=Math.round((Date.now()-l)*100)/100,S=Math.round((Date.now()-f)*100)/100,te=S/16,A=(rt,st)=>{for(rt=String(rt);rt.length<st;)rt=" "+rt;return rt};console.info(`%c⏱ ${A(S,5)} /${A(R,5)} ms`,`
|
|
488
488
|
font-size: .6rem;
|
|
489
489
|
font-weight: bold;
|
|
490
490
|
color: hsl(${Math.max(0,Math.min(120-120*te,120))}deg 100% 31%);`,n?.key)}return a}}function getMemoOptions(e,t,n,s){return{debug:()=>{var a;return(a=e?.debugAll)!=null?a:e[t]},key:process.env.NODE_ENV==="development"&&n,onChange:s}}function createCell(e,t,n,s){const a=()=>{var l;return(l=o.getValue())!=null?l:e.options.renderFallbackValue},o={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(s),renderValue:a,getContext:memo(()=>[e,n,t,o],(l,c,d,f)=>({table:l,column:c,row:d,cell:f,getValue:f.getValue,renderValue:f.renderValue}),getMemoOptions(e.options,"debugCells","cell.getContext"))};return e._features.forEach(l=>{l.createCell==null||l.createCell(o,n,t,e)},{}),o}function createColumn(e,t,n,s){var a,o;const c={...e._getDefaultColumnDef(),...t},d=c.accessorKey;let f=(a=(o=c.id)!=null?o:d?typeof String.prototype.replaceAll=="function"?d.replaceAll(".","_"):d.replace(/\./g,"_"):void 0)!=null?a:typeof c.header=="string"?c.header:void 0,R;if(c.accessorFn?R=c.accessorFn:d&&(d.includes(".")?R=te=>{let A=te;for(const st of d.split(".")){var rt;A=(rt=A)==null?void 0:rt[st],process.env.NODE_ENV!=="production"&&A===void 0&&console.warn(`"${st}" in deeply nested key "${d}" returned undefined.`)}return A}:R=te=>te[c.accessorKey]),!f)throw process.env.NODE_ENV!=="production"?new Error(c.accessorFn?"Columns require an id when using an accessorFn":"Columns require an id when using a non-string header"):new Error;let S={id:`${String(f)}`,accessorFn:R,parent:s,depth:n,columnDef:c,columns:[],getFlatColumns:memo(()=>[!0],()=>{var te;return[S,...(te=S.columns)==null?void 0:te.flatMap(A=>A.getFlatColumns())]},getMemoOptions(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:memo(()=>[e._getOrderColumnsFn()],te=>{var A;if((A=S.columns)!=null&&A.length){let rt=S.columns.flatMap(st=>st.getLeafColumns());return te(rt)}return[S]},getMemoOptions(e.options,"debugColumns","column.getLeafColumns"))};for(const te of e._features)te.createColumn==null||te.createColumn(S,e);return S}const debug="debugHeaders";function createHeader(e,t,n){var s;let o={id:(s=n.id)!=null?s:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const l=[],c=d=>{d.subHeaders&&d.subHeaders.length&&d.subHeaders.map(c),l.push(d)};return c(o),l},getContext:()=>({table:e,header:o,column:t})};return e._features.forEach(l=>{l.createHeader==null||l.createHeader(o,e)}),o}const Headers$1={createTable:e=>{e.getHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s,a)=>{var o,l;const c=(o=s?.map(S=>n.find(te=>te.id===S)).filter(Boolean))!=null?o:[],d=(l=a?.map(S=>n.find(te=>te.id===S)).filter(Boolean))!=null?l:[],f=n.filter(S=>!(s!=null&&s.includes(S.id))&&!(a!=null&&a.includes(S.id)));return buildHeaderGroups(t,[...c,...f,...d],e)},getMemoOptions(e.options,debug,"getHeaderGroups")),e.getCenterHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s,a)=>(n=n.filter(o=>!(s!=null&&s.includes(o.id))&&!(a!=null&&a.includes(o.id))),buildHeaderGroups(t,n,e,"center")),getMemoOptions(e.options,debug,"getCenterHeaderGroups")),e.getLeftHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,s)=>{var a;const o=(a=s?.map(l=>n.find(c=>c.id===l)).filter(Boolean))!=null?a:[];return buildHeaderGroups(t,o,e,"left")},getMemoOptions(e.options,debug,"getLeftHeaderGroups")),e.getRightHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,s)=>{var a;const o=(a=s?.map(l=>n.find(c=>c.id===l)).filter(Boolean))!=null?a:[];return buildHeaderGroups(t,o,e,"right")},getMemoOptions(e.options,debug,"getRightHeaderGroups")),e.getFooterGroups=memo(()=>[e.getHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getFooterGroups")),e.getLeftFooterGroups=memo(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getLeftFooterGroups")),e.getCenterFooterGroups=memo(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getCenterFooterGroups")),e.getRightFooterGroups=memo(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getRightFooterGroups")),e.getFlatHeaders=memo(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getFlatHeaders")),e.getLeftFlatHeaders=memo(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getLeftFlatHeaders")),e.getCenterFlatHeaders=memo(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getCenterFlatHeaders")),e.getRightFlatHeaders=memo(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getRightFlatHeaders")),e.getCenterLeafHeaders=memo(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getCenterLeafHeaders")),e.getLeftLeafHeaders=memo(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getLeftLeafHeaders")),e.getRightLeafHeaders=memo(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getRightLeafHeaders")),e.getLeafHeaders=memo(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,s)=>{var a,o,l,c,d,f;return[...(a=(o=t[0])==null?void 0:o.headers)!=null?a:[],...(l=(c=n[0])==null?void 0:c.headers)!=null?l:[],...(d=(f=s[0])==null?void 0:f.headers)!=null?d:[]].map(R=>R.getLeafHeaders()).flat()},getMemoOptions(e.options,debug,"getLeafHeaders"))}};function buildHeaderGroups(e,t,n,s){var a,o;let l=0;const c=function(te,A){A===void 0&&(A=1),l=Math.max(l,A),te.filter(rt=>rt.getIsVisible()).forEach(rt=>{var st;(st=rt.columns)!=null&&st.length&&c(rt.columns,A+1)},0)};c(e);let d=[];const f=(te,A)=>{const rt={depth:A,id:[s,`${A}`].filter(Boolean).join("_"),headers:[]},st=[];te.forEach(it=>{const at=[...st].reverse()[0],ot=it.column.depth===rt.depth;let lt,ut=!1;if(ot&&it.column.parent?lt=it.column.parent:(lt=it.column,ut=!0),at&&at?.column===lt)at.subHeaders.push(it);else{const ct=createHeader(n,lt,{id:[s,A,lt.id,it?.id].filter(Boolean).join("_"),isPlaceholder:ut,placeholderId:ut?`${st.filter(dt=>dt.column===lt).length}`:void 0,depth:A,index:st.length});ct.subHeaders.push(it),st.push(ct)}rt.headers.push(it),it.headerGroup=rt}),d.push(rt),A>0&&f(st,A-1)},R=t.map((te,A)=>createHeader(n,te,{depth:l,index:A}));f(R,l-1),d.reverse();const S=te=>te.filter(rt=>rt.column.getIsVisible()).map(rt=>{let st=0,it=0,at=[0];rt.subHeaders&&rt.subHeaders.length?(at=[],S(rt.subHeaders).forEach(lt=>{let{colSpan:ut,rowSpan:ct}=lt;st+=ut,at.push(ct)})):st=1;const ot=Math.min(...at);return it=it+ot,rt.colSpan=st,rt.rowSpan=it,{colSpan:st,rowSpan:it}});return S((a=(o=d[0])==null?void 0:o.headers)!=null?a:[]),d}const createRow=(e,t,n,s,a,o,l)=>{let c={id:t,index:s,original:n,depth:a,parentId:l,_valuesCache:{},_uniqueValuesCache:{},getValue:d=>{if(c._valuesCache.hasOwnProperty(d))return c._valuesCache[d];const f=e.getColumn(d);if(f!=null&&f.accessorFn)return c._valuesCache[d]=f.accessorFn(c.original,s),c._valuesCache[d]},getUniqueValues:d=>{if(c._uniqueValuesCache.hasOwnProperty(d))return c._uniqueValuesCache[d];const f=e.getColumn(d);if(f!=null&&f.accessorFn)return f.columnDef.getUniqueValues?(c._uniqueValuesCache[d]=f.columnDef.getUniqueValues(c.original,s),c._uniqueValuesCache[d]):(c._uniqueValuesCache[d]=[c.getValue(d)],c._uniqueValuesCache[d])},renderValue:d=>{var f;return(f=c.getValue(d))!=null?f:e.options.renderFallbackValue},subRows:[],getLeafRows:()=>flattenBy(c.subRows,d=>d.subRows),getParentRow:()=>c.parentId?e.getRow(c.parentId,!0):void 0,getParentRows:()=>{let d=[],f=c;for(;;){const R=f.getParentRow();if(!R)break;d.push(R),f=R}return d.reverse()},getAllCells:memo(()=>[e.getAllLeafColumns()],d=>d.map(f=>createCell(e,c,f,f.id)),getMemoOptions(e.options,"debugRows","getAllCells")),_getAllCellsByColumnId:memo(()=>[c.getAllCells()],d=>d.reduce((f,R)=>(f[R.column.id]=R,f),{}),getMemoOptions(e.options,"debugRows","getAllCellsByColumnId"))};for(let d=0;d<e._features.length;d++){const f=e._features[d];f==null||f.createRow==null||f.createRow(c,e)}return c},ColumnFaceting={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},includesString=(e,t,n)=>{var s,a;const o=n==null||(s=n.toString())==null?void 0:s.toLowerCase();return!!(!((a=e.getValue(t))==null||(a=a.toString())==null||(a=a.toLowerCase())==null)&&a.includes(o))};includesString.autoRemove=e=>testFalsey(e);const includesStringSensitive=(e,t,n)=>{var s;return!!(!((s=e.getValue(t))==null||(s=s.toString())==null)&&s.includes(n))};includesStringSensitive.autoRemove=e=>testFalsey(e);const equalsString=(e,t,n)=>{var s;return((s=e.getValue(t))==null||(s=s.toString())==null?void 0:s.toLowerCase())===n?.toLowerCase()};equalsString.autoRemove=e=>testFalsey(e);const arrIncludes=(e,t,n)=>{var s;return(s=e.getValue(t))==null?void 0:s.includes(n)};arrIncludes.autoRemove=e=>testFalsey(e);const arrIncludesAll=(e,t,n)=>!n.some(s=>{var a;return!((a=e.getValue(t))!=null&&a.includes(s))});arrIncludesAll.autoRemove=e=>testFalsey(e)||!(e!=null&&e.length);const arrIncludesSome=(e,t,n)=>n.some(s=>{var a;return(a=e.getValue(t))==null?void 0:a.includes(s)});arrIncludesSome.autoRemove=e=>testFalsey(e)||!(e!=null&&e.length);const equals=(e,t,n)=>e.getValue(t)===n;equals.autoRemove=e=>testFalsey(e);const weakEquals=(e,t,n)=>e.getValue(t)==n;weakEquals.autoRemove=e=>testFalsey(e);const inNumberRange=(e,t,n)=>{let[s,a]=n;const o=e.getValue(t);return o>=s&&o<=a};inNumberRange.resolveFilterValue=e=>{let[t,n]=e,s=typeof t!="number"?parseFloat(t):t,a=typeof n!="number"?parseFloat(n):n,o=t===null||Number.isNaN(s)?-1/0:s,l=n===null||Number.isNaN(a)?1/0:a;if(o>l){const c=o;o=l,l=c}return[o,l]},inNumberRange.autoRemove=e=>testFalsey(e)||testFalsey(e[0])&&testFalsey(e[1]);const filterFns={includesString,includesStringSensitive,equalsString,arrIncludes,arrIncludesAll,arrIncludesSome,equals,weakEquals,inNumberRange};function testFalsey(e){return e==null||e===""}const ColumnFiltering={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:makeStateUpdater("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{const n=t.getCoreRowModel().flatRows[0],s=n?.getValue(e.id);return typeof s=="string"?filterFns.includesString:typeof s=="number"?filterFns.inNumberRange:typeof s=="boolean"||s!==null&&typeof s=="object"?filterFns.equals:Array.isArray(s)?filterFns.arrIncludes:filterFns.weakEquals},e.getFilterFn=()=>{var n,s;return isFunction$2(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(n=(s=t.options.filterFns)==null?void 0:s[e.columnDef.filterFn])!=null?n:filterFns[e.columnDef.filterFn]},e.getCanFilter=()=>{var n,s,a;return((n=e.columnDef.enableColumnFilter)!=null?n:!0)&&((s=t.options.enableColumnFilters)!=null?s:!0)&&((a=t.options.enableFilters)!=null?a:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(s=>s.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>{var n,s;return(n=(s=t.getState().columnFilters)==null?void 0:s.findIndex(a=>a.id===e.id))!=null?n:-1},e.setFilterValue=n=>{t.setColumnFilters(s=>{const a=e.getFilterFn(),o=s?.find(R=>R.id===e.id),l=functionalUpdate(n,o?o.value:void 0);if(shouldAutoRemoveFilter(a,l,e)){var c;return(c=s?.filter(R=>R.id!==e.id))!=null?c:[]}const d={id:e.id,value:l};if(o){var f;return(f=s?.map(R=>R.id===e.id?d:R))!=null?f:[]}return s!=null&&s.length?[...s,d]:[d]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{const n=e.getAllLeafColumns(),s=a=>{var o;return(o=functionalUpdate(t,a))==null?void 0:o.filter(l=>{const c=n.find(d=>d.id===l.id);if(c){const d=c.getFilterFn();if(shouldAutoRemoveFilter(d,l.value,c))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(s)},e.resetColumnFilters=t=>{var n,s;e.setColumnFilters(t?[]:(n=(s=e.initialState)==null?void 0:s.columnFilters)!=null?n:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function shouldAutoRemoveFilter(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}const sum=(e,t,n)=>n.reduce((s,a)=>{const o=a.getValue(e);return s+(typeof o=="number"?o:0)},0),min=(e,t,n)=>{let s;return n.forEach(a=>{const o=a.getValue(e);o!=null&&(s>o||s===void 0&&o>=o)&&(s=o)}),s},max=(e,t,n)=>{let s;return n.forEach(a=>{const o=a.getValue(e);o!=null&&(s<o||s===void 0&&o>=o)&&(s=o)}),s},extent=(e,t,n)=>{let s,a;return n.forEach(o=>{const l=o.getValue(e);l!=null&&(s===void 0?l>=l&&(s=a=l):(s>l&&(s=l),a<l&&(a=l)))}),[s,a]},mean=(e,t)=>{let n=0,s=0;if(t.forEach(a=>{let o=a.getValue(e);o!=null&&(o=+o)>=o&&(++n,s+=o)}),n)return s/n},median=(e,t)=>{if(!t.length)return;const n=t.map(o=>o.getValue(e));if(!isNumberArray(n))return;if(n.length===1)return n[0];const s=Math.floor(n.length/2),a=n.sort((o,l)=>o-l);return n.length%2!==0?a[s]:(a[s-1]+a[s])/2},unique=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),uniqueCount=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,count=(e,t)=>t.length,aggregationFns={sum,min,max,extent,mean,median,unique,uniqueCount,count},ColumnGrouping={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return(t=(n=e.getValue())==null||n.toString==null?void 0:n.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:makeStateUpdater("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(n=>n!=null&&n.includes(e.id)?n.filter(s=>s!==e.id):[...n??[],e.id])},e.getCanGroup=()=>{var n,s;return((n=e.columnDef.enableGrouping)!=null?n:!0)&&((s=t.options.enableGrouping)!=null?s:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.includes(e.id)},e.getGroupedIndex=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const n=e.getCanGroup();return()=>{n&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const n=t.getCoreRowModel().flatRows[0],s=n?.getValue(e.id);if(typeof s=="number")return aggregationFns.sum;if(Object.prototype.toString.call(s)==="[object Date]")return aggregationFns.extent},e.getAggregationFn=()=>{var n,s;if(!e)throw new Error;return isFunction$2(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(n=(s=t.options.aggregationFns)==null?void 0:s[e.columnDef.aggregationFn])!=null?n:aggregationFns[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var n,s;e.setGrouping(t?[]:(n=(s=e.initialState)==null?void 0:s.grouping)!=null?n:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];const s=t.getColumn(n);return s!=null&&s.columnDef.getGroupingValue?(e._groupingValuesCache[n]=s.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,s)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var a;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((a=n.subRows)!=null&&a.length)}}};function orderColumns(e,t,n){if(!(t!=null&&t.length)||!n)return e;const s=e.filter(o=>!t.includes(o.id));return n==="remove"?s:[...t.map(o=>e.find(l=>l.id===o)).filter(Boolean),...s]}const ColumnOrdering={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:makeStateUpdater("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=memo(n=>[_getVisibleLeafColumns(t,n)],n=>n.findIndex(s=>s.id===e.id),getMemoOptions(t.options,"debugColumns","getIndex")),e.getIsFirstColumn=n=>{var s;return((s=_getVisibleLeafColumns(t,n)[0])==null?void 0:s.id)===e.id},e.getIsLastColumn=n=>{var s;const a=_getVisibleLeafColumns(t,n);return((s=a[a.length-1])==null?void 0:s.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var n;e.setColumnOrder(t?[]:(n=e.initialState.columnOrder)!=null?n:[])},e._getOrderColumnsFn=memo(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,n,s)=>a=>{let o=[];if(!(t!=null&&t.length))o=a;else{const l=[...t],c=[...a];for(;c.length&&l.length;){const d=l.shift(),f=c.findIndex(R=>R.id===d);f>-1&&o.push(c.splice(f,1)[0])}o=[...o,...c]}return orderColumns(o,n,s)},getMemoOptions(e.options,"debugTable","_getOrderColumnsFn"))}},getDefaultColumnPinningState=()=>({left:[],right:[]}),ColumnPinning={getInitialState:e=>({columnPinning:getDefaultColumnPinningState(),...e}),getDefaultOptions:e=>({onColumnPinningChange:makeStateUpdater("columnPinning",e)}),createColumn:(e,t)=>{e.pin=n=>{const s=e.getLeafColumns().map(a=>a.id).filter(Boolean);t.setColumnPinning(a=>{var o,l;if(n==="right"){var c,d;return{left:((c=a?.left)!=null?c:[]).filter(S=>!(s!=null&&s.includes(S))),right:[...((d=a?.right)!=null?d:[]).filter(S=>!(s!=null&&s.includes(S))),...s]}}if(n==="left"){var f,R;return{left:[...((f=a?.left)!=null?f:[]).filter(S=>!(s!=null&&s.includes(S))),...s],right:((R=a?.right)!=null?R:[]).filter(S=>!(s!=null&&s.includes(S)))}}return{left:((o=a?.left)!=null?o:[]).filter(S=>!(s!=null&&s.includes(S))),right:((l=a?.right)!=null?l:[]).filter(S=>!(s!=null&&s.includes(S)))}})},e.getCanPin=()=>e.getLeafColumns().some(s=>{var a,o,l;return((a=s.columnDef.enablePinning)!=null?a:!0)&&((o=(l=t.options.enableColumnPinning)!=null?l:t.options.enablePinning)!=null?o:!0)}),e.getIsPinned=()=>{const n=e.getLeafColumns().map(c=>c.id),{left:s,right:a}=t.getState().columnPinning,o=n.some(c=>s?.includes(c)),l=n.some(c=>a?.includes(c));return o?"left":l?"right":!1},e.getPinnedIndex=()=>{var n,s;const a=e.getIsPinned();return a?(n=(s=t.getState().columnPinning)==null||(s=s[a])==null?void 0:s.indexOf(e.id))!=null?n:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(n,s,a)=>{const o=[...s??[],...a??[]];return n.filter(l=>!o.includes(l.column.id))},getMemoOptions(t.options,"debugRows","getCenterVisibleCells")),e.getLeftVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(n,s)=>(s??[]).map(o=>n.find(l=>l.column.id===o)).filter(Boolean).map(o=>({...o,position:"left"})),getMemoOptions(t.options,"debugRows","getLeftVisibleCells")),e.getRightVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(n,s)=>(s??[]).map(o=>n.find(l=>l.column.id===o)).filter(Boolean).map(o=>({...o,position:"right"})),getMemoOptions(t.options,"debugRows","getRightVisibleCells"))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var n,s;return e.setColumnPinning(t?getDefaultColumnPinningState():(n=(s=e.initialState)==null?void 0:s.columnPinning)!=null?n:getDefaultColumnPinningState())},e.getIsSomeColumnsPinned=t=>{var n;const s=e.getState().columnPinning;if(!t){var a,o;return!!((a=s.left)!=null&&a.length||(o=s.right)!=null&&o.length)}return!!((n=s[t])!=null&&n.length)},e.getLeftLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(s=>t.find(a=>a.id===s)).filter(Boolean),getMemoOptions(e.options,"debugColumns","getLeftLeafColumns")),e.getRightLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(s=>t.find(a=>a.id===s)).filter(Boolean),getMemoOptions(e.options,"debugColumns","getRightLeafColumns")),e.getCenterLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s)=>{const a=[...n??[],...s??[]];return t.filter(o=>!a.includes(o.id))},getMemoOptions(e.options,"debugColumns","getCenterLeafColumns"))}};function safelyAccessDocument(e){return e||(typeof document<"u"?document:null)}const defaultColumnSizing={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},getDefaultColumnSizingInfoState=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),ColumnSizing={getDefaultColumnDef:()=>defaultColumnSizing,getInitialState:e=>({columnSizing:{},columnSizingInfo:getDefaultColumnSizingInfoState(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:makeStateUpdater("columnSizing",e),onColumnSizingInfoChange:makeStateUpdater("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var n,s,a;const o=t.getState().columnSizing[e.id];return Math.min(Math.max((n=e.columnDef.minSize)!=null?n:defaultColumnSizing.minSize,(s=o??e.columnDef.size)!=null?s:defaultColumnSizing.size),(a=e.columnDef.maxSize)!=null?a:defaultColumnSizing.maxSize)},e.getStart=memo(n=>[n,_getVisibleLeafColumns(t,n),t.getState().columnSizing],(n,s)=>s.slice(0,e.getIndex(n)).reduce((a,o)=>a+o.getSize(),0),getMemoOptions(t.options,"debugColumns","getStart")),e.getAfter=memo(n=>[n,_getVisibleLeafColumns(t,n),t.getState().columnSizing],(n,s)=>s.slice(e.getIndex(n)+1).reduce((a,o)=>a+o.getSize(),0),getMemoOptions(t.options,"debugColumns","getAfter")),e.resetSize=()=>{t.setColumnSizing(n=>{let{[e.id]:s,...a}=n;return a})},e.getCanResize=()=>{var n,s;return((n=e.columnDef.enableResizing)!=null?n:!0)&&((s=t.options.enableColumnResizing)!=null?s:!0)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let n=0;const s=a=>{if(a.subHeaders.length)a.subHeaders.forEach(s);else{var o;n+=(o=a.column.getSize())!=null?o:0}};return s(e),n},e.getStart=()=>{if(e.index>0){const n=e.headerGroup.headers[e.index-1];return n.getStart()+n.getSize()}return 0},e.getResizeHandler=n=>{const s=t.getColumn(e.column.id),a=s?.getCanResize();return o=>{if(!s||!a||(o.persist==null||o.persist(),isTouchStartEvent(o)&&o.touches&&o.touches.length>1))return;const l=e.getSize(),c=e?e.getLeafHeaders().map(at=>[at.column.id,at.column.getSize()]):[[s.id,s.getSize()]],d=isTouchStartEvent(o)?Math.round(o.touches[0].clientX):o.clientX,f={},R=(at,ot)=>{typeof ot=="number"&&(t.setColumnSizingInfo(lt=>{var ut,ct;const dt=t.options.columnResizeDirection==="rtl"?-1:1,pt=(ot-((ut=lt?.startOffset)!=null?ut:0))*dt,mt=Math.max(pt/((ct=lt?.startSize)!=null?ct:0),-.999999);return lt.columnSizingStart.forEach(Rt=>{let[yt,It]=Rt;f[yt]=Math.round(Math.max(It+It*mt,0)*100)/100}),{...lt,deltaOffset:pt,deltaPercentage:mt}}),(t.options.columnResizeMode==="onChange"||at==="end")&&t.setColumnSizing(lt=>({...lt,...f})))},S=at=>R("move",at),te=at=>{R("end",at),t.setColumnSizingInfo(ot=>({...ot,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},A=safelyAccessDocument(n),rt={moveHandler:at=>S(at.clientX),upHandler:at=>{A?.removeEventListener("mousemove",rt.moveHandler),A?.removeEventListener("mouseup",rt.upHandler),te(at.clientX)}},st={moveHandler:at=>(at.cancelable&&(at.preventDefault(),at.stopPropagation()),S(at.touches[0].clientX),!1),upHandler:at=>{var ot;A?.removeEventListener("touchmove",st.moveHandler),A?.removeEventListener("touchend",st.upHandler),at.cancelable&&(at.preventDefault(),at.stopPropagation()),te((ot=at.touches[0])==null?void 0:ot.clientX)}},it=passiveEventSupported()?{passive:!1}:!1;isTouchStartEvent(o)?(A?.addEventListener("touchmove",st.moveHandler,it),A?.addEventListener("touchend",st.upHandler,it)):(A?.addEventListener("mousemove",rt.moveHandler,it),A?.addEventListener("mouseup",rt.upHandler,it)),t.setColumnSizingInfo(at=>({...at,startOffset:d,startSize:l,deltaOffset:0,deltaPercentage:0,columnSizingStart:c,isResizingColumn:s.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var n;e.setColumnSizing(t?{}:(n=e.initialState.columnSizing)!=null?n:{})},e.resetHeaderSizeInfo=t=>{var n;e.setColumnSizingInfo(t?getDefaultColumnSizingInfoState():(n=e.initialState.columnSizingInfo)!=null?n:getDefaultColumnSizingInfoState())},e.getTotalSize=()=>{var t,n;return(t=(n=e.getHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getLeftTotalSize=()=>{var t,n;return(t=(n=e.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getCenterTotalSize=()=>{var t,n;return(t=(n=e.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getRightTotalSize=()=>{var t,n;return(t=(n=e.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0}}};let passiveSupported=null;function passiveEventSupported(){if(typeof passiveSupported=="boolean")return passiveSupported;let e=!1;try{const t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener("test",n,t),window.removeEventListener("test",n)}catch{e=!1}return passiveSupported=e,passiveSupported}function isTouchStartEvent(e){return e.type==="touchstart"}const ColumnVisibility={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:makeStateUpdater("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(s=>({...s,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{var n,s;const a=e.columns;return(n=a.length?a.some(o=>o.getIsVisible()):(s=t.getState().columnVisibility)==null?void 0:s[e.id])!=null?n:!0},e.getCanHide=()=>{var n,s;return((n=e.columnDef.enableHiding)!=null?n:!0)&&((s=t.options.enableHiding)!=null?s:!0)},e.getToggleVisibilityHandler=()=>n=>{e.toggleVisibility==null||e.toggleVisibility(n.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=memo(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(s=>s.column.getIsVisible()),getMemoOptions(t.options,"debugRows","_getAllVisibleCells")),e.getVisibleCells=memo(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,s,a)=>[...n,...s,...a],getMemoOptions(t.options,"debugRows","getVisibleCells"))},createTable:e=>{const t=(n,s)=>memo(()=>[s(),s().filter(a=>a.getIsVisible()).map(a=>a.id).join("_")],a=>a.filter(o=>o.getIsVisible==null?void 0:o.getIsVisible()),getMemoOptions(e.options,"debugColumns",n));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=n=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(n),e.resetColumnVisibility=n=>{var s;e.setColumnVisibility(n?{}:(s=e.initialState.columnVisibility)!=null?s:{})},e.toggleAllColumnsVisible=n=>{var s;n=(s=n)!=null?s:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((a,o)=>({...a,[o.id]:n||!(o.getCanHide!=null&&o.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>n=>{var s;e.toggleAllColumnsVisible((s=n.target)==null?void 0:s.checked)}}};function _getVisibleLeafColumns(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const GlobalFaceting={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},GlobalFiltering={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:makeStateUpdater("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n;const s=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof s=="string"||typeof s=="number"}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var n,s,a,o;return((n=e.columnDef.enableGlobalFilter)!=null?n:!0)&&((s=t.options.enableGlobalFilter)!=null?s:!0)&&((a=t.options.enableFilters)!=null?a:!0)&&((o=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?o:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>filterFns.includesString,e.getGlobalFilterFn=()=>{var t,n;const{globalFilterFn:s}=e.options;return isFunction$2(s)?s:s==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[s])!=null?t:filterFns[s]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},RowExpanding={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:makeStateUpdater("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{var s,a;if(!t){e._queue(()=>{t=!0});return}if((s=(a=e.options.autoResetAll)!=null?a:e.options.autoResetExpanded)!=null?s:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=s=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(s),e.toggleAllRowsExpanded=s=>{s??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=s=>{var a,o;e.setExpanded(s?{}:(a=(o=e.initialState)==null?void 0:o.expanded)!=null?a:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(s=>s.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>s=>{s.persist==null||s.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const s=e.getState().expanded;return s===!0||Object.values(s).some(Boolean)},e.getIsAllRowsExpanded=()=>{const s=e.getState().expanded;return typeof s=="boolean"?s===!0:!(!Object.keys(s).length||e.getRowModel().flatRows.some(a=>!a.getIsExpanded()))},e.getExpandedDepth=()=>{let s=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(o=>{const l=o.split(".");s=Math.max(s,l.length)}),s},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(s=>{var a;const o=s===!0?!0:!!(s!=null&&s[e.id]);let l={};if(s===!0?Object.keys(t.getRowModel().rowsById).forEach(c=>{l[c]=!0}):l=s,n=(a=n)!=null?a:!o,!o&&n)return{...l,[e.id]:!0};if(o&&!n){const{[e.id]:c,...d}=l;return d}return s})},e.getIsExpanded=()=>{var n;const s=t.getState().expanded;return!!((n=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?n:s===!0||s?.[e.id])},e.getCanExpand=()=>{var n,s,a;return(n=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?n:((s=t.options.enableExpanding)!=null?s:!0)&&!!((a=e.subRows)!=null&&a.length)},e.getIsAllParentsExpanded=()=>{let n=!0,s=e;for(;n&&s.parentId;)s=t.getRow(s.parentId,!0),n=s.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{const n=e.getCanExpand();return()=>{n&&e.toggleExpanded()}}}},defaultPageIndex=0,defaultPageSize=10,getDefaultPaginationState=()=>({pageIndex:defaultPageIndex,pageSize:defaultPageSize}),RowPagination={getInitialState:e=>({...e,pagination:{...getDefaultPaginationState(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:makeStateUpdater("pagination",e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{var s,a;if(!t){e._queue(()=>{t=!0});return}if((s=(a=e.options.autoResetAll)!=null?a:e.options.autoResetPageIndex)!=null?s:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=s=>{const a=o=>functionalUpdate(s,o);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(a)},e.resetPagination=s=>{var a;e.setPagination(s?getDefaultPaginationState():(a=e.initialState.pagination)!=null?a:getDefaultPaginationState())},e.setPageIndex=s=>{e.setPagination(a=>{let o=functionalUpdate(s,a.pageIndex);const l=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return o=Math.max(0,Math.min(o,l)),{...a,pageIndex:o}})},e.resetPageIndex=s=>{var a,o;e.setPageIndex(s?defaultPageIndex:(a=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageIndex)!=null?a:defaultPageIndex)},e.resetPageSize=s=>{var a,o;e.setPageSize(s?defaultPageSize:(a=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageSize)!=null?a:defaultPageSize)},e.setPageSize=s=>{e.setPagination(a=>{const o=Math.max(1,functionalUpdate(s,a.pageSize)),l=a.pageSize*a.pageIndex,c=Math.floor(l/o);return{...a,pageIndex:c,pageSize:o}})},e.setPageCount=s=>e.setPagination(a=>{var o;let l=functionalUpdate(s,(o=e.options.pageCount)!=null?o:-1);return typeof l=="number"&&(l=Math.max(-1,l)),{...a,pageCount:l}}),e.getPageOptions=memo(()=>[e.getPageCount()],s=>{let a=[];return s&&s>0&&(a=[...new Array(s)].fill(null).map((o,l)=>l)),a},getMemoOptions(e.options,"debugTable","getPageOptions")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:s}=e.getState().pagination,a=e.getPageCount();return a===-1?!0:a===0?!1:s<a-1},e.previousPage=()=>e.setPageIndex(s=>s-1),e.nextPage=()=>e.setPageIndex(s=>s+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var s;return(s=e.options.pageCount)!=null?s:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var s;return(s=e.options.rowCount)!=null?s:e.getPrePaginationRowModel().rows.length}}},getDefaultRowPinningState=()=>({top:[],bottom:[]}),RowPinning={getInitialState:e=>({rowPinning:getDefaultRowPinningState(),...e}),getDefaultOptions:e=>({onRowPinningChange:makeStateUpdater("rowPinning",e)}),createRow:(e,t)=>{e.pin=(n,s,a)=>{const o=s?e.getLeafRows().map(d=>{let{id:f}=d;return f}):[],l=a?e.getParentRows().map(d=>{let{id:f}=d;return f}):[],c=new Set([...l,e.id,...o]);t.setRowPinning(d=>{var f,R;if(n==="bottom"){var S,te;return{top:((S=d?.top)!=null?S:[]).filter(st=>!(c!=null&&c.has(st))),bottom:[...((te=d?.bottom)!=null?te:[]).filter(st=>!(c!=null&&c.has(st))),...Array.from(c)]}}if(n==="top"){var A,rt;return{top:[...((A=d?.top)!=null?A:[]).filter(st=>!(c!=null&&c.has(st))),...Array.from(c)],bottom:((rt=d?.bottom)!=null?rt:[]).filter(st=>!(c!=null&&c.has(st)))}}return{top:((f=d?.top)!=null?f:[]).filter(st=>!(c!=null&&c.has(st))),bottom:((R=d?.bottom)!=null?R:[]).filter(st=>!(c!=null&&c.has(st)))}})},e.getCanPin=()=>{var n;const{enableRowPinning:s,enablePinning:a}=t.options;return typeof s=="function"?s(e):(n=s??a)!=null?n:!0},e.getIsPinned=()=>{const n=[e.id],{top:s,bottom:a}=t.getState().rowPinning,o=n.some(c=>s?.includes(c)),l=n.some(c=>a?.includes(c));return o?"top":l?"bottom":!1},e.getPinnedIndex=()=>{var n,s;const a=e.getIsPinned();if(!a)return-1;const o=(n=a==="top"?t.getTopRows():t.getBottomRows())==null?void 0:n.map(l=>{let{id:c}=l;return c});return(s=o?.indexOf(e.id))!=null?s:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var n,s;return e.setRowPinning(t?getDefaultRowPinningState():(n=(s=e.initialState)==null?void 0:s.rowPinning)!=null?n:getDefaultRowPinningState())},e.getIsSomeRowsPinned=t=>{var n;const s=e.getState().rowPinning;if(!t){var a,o;return!!((a=s.top)!=null&&a.length||(o=s.bottom)!=null&&o.length)}return!!((n=s[t])!=null&&n.length)},e._getPinnedRows=(t,n,s)=>{var a;return((a=e.options.keepPinnedRows)==null||a?(n??[]).map(l=>{const c=e.getRow(l,!0);return c.getIsAllParentsExpanded()?c:null}):(n??[]).map(l=>t.find(c=>c.id===l))).filter(Boolean).map(l=>({...l,position:s}))},e.getTopRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,"top"),getMemoOptions(e.options,"debugRows","getTopRows")),e.getBottomRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,"bottom"),getMemoOptions(e.options,"debugRows","getBottomRows")),e.getCenterRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(t,n,s)=>{const a=new Set([...n??[],...s??[]]);return t.filter(o=>!a.has(o.id))},getMemoOptions(e.options,"debugRows","getCenterRows"))}},RowSelection={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:makeStateUpdater("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var n;return e.setRowSelection(t?{}:(n=e.initialState.rowSelection)!=null?n:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const s={...n},a=e.getPreGroupedRowModel().flatRows;return t?a.forEach(o=>{o.getCanSelect()&&(s[o.id]=!0)}):a.forEach(o=>{delete s[o.id]}),s})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{const s=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),a={...n};return e.getRowModel().rows.forEach(o=>{mutateRowIsSelected(a,o.id,s,!0,e)}),a}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getSelectedRowModel")),e.getFilteredSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getFilteredSelectedRowModel")),e.getGroupedSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getGroupedSelectedRowModel")),e.getIsAllRowsSelected=()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState();let s=!!(t.length&&Object.keys(n).length);return s&&t.some(a=>a.getCanSelect()&&!n[a.id])&&(s=!1),s},e.getIsAllPageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows.filter(a=>a.getCanSelect()),{rowSelection:n}=e.getState();let s=!!t.length;return s&&t.some(a=>!n[a.id])&&(s=!1),s},e.getIsSomeRowsSelected=()=>{var t;const n=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return n>0&&n<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,s)=>{const a=e.getIsSelected();t.setRowSelection(o=>{var l;if(n=typeof n<"u"?n:!a,e.getCanSelect()&&a===n)return o;const c={...o};return mutateRowIsSelected(c,e.id,n,(l=s?.selectChildren)!=null?l:!0,t),c})},e.getIsSelected=()=>{const{rowSelection:n}=t.getState();return isRowSelected(e,n)},e.getIsSomeSelected=()=>{const{rowSelection:n}=t.getState();return isSubRowSelected(e,n)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=t.getState();return isSubRowSelected(e,n)==="all"},e.getCanSelect=()=>{var n;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(n=t.options.enableRowSelection)!=null?n:!0},e.getCanSelectSubRows=()=>{var n;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(n=t.options.enableSubRowSelection)!=null?n:!0},e.getCanMultiSelect=()=>{var n;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(n=t.options.enableMultiRowSelection)!=null?n:!0},e.getToggleSelectedHandler=()=>{const n=e.getCanSelect();return s=>{var a;n&&e.toggleSelected((a=s.target)==null?void 0:a.checked)}}}},mutateRowIsSelected=(e,t,n,s,a)=>{var o;const l=a.getRow(t,!0);n?(l.getCanMultiSelect()||Object.keys(e).forEach(c=>delete e[c]),l.getCanSelect()&&(e[t]=!0)):delete e[t],s&&(o=l.subRows)!=null&&o.length&&l.getCanSelectSubRows()&&l.subRows.forEach(c=>mutateRowIsSelected(e,c.id,n,s,a))};function selectRowsFn(e,t){const n=e.getState().rowSelection,s=[],a={},o=function(l,c){return l.map(d=>{var f;const R=isRowSelected(d,n);if(R&&(s.push(d),a[d.id]=d),(f=d.subRows)!=null&&f.length&&(d={...d,subRows:o(d.subRows)}),R)return d}).filter(Boolean)};return{rows:o(t.rows),flatRows:s,rowsById:a}}function isRowSelected(e,t){var n;return(n=t[e.id])!=null?n:!1}function isSubRowSelected(e,t,n){var s;if(!((s=e.subRows)!=null&&s.length))return!1;let a=!0,o=!1;return e.subRows.forEach(l=>{if(!(o&&!a)&&(l.getCanSelect()&&(isRowSelected(l,t)?o=!0:a=!1),l.subRows&&l.subRows.length)){const c=isSubRowSelected(l,t);c==="all"?o=!0:(c==="some"&&(o=!0),a=!1)}}),a?"all":o?"some":!1}const reSplitAlphaNumeric=/([0-9]+)/gm,alphanumeric$1=(e,t,n)=>compareAlphanumeric(toString$1(e.getValue(n)).toLowerCase(),toString$1(t.getValue(n)).toLowerCase()),alphanumericCaseSensitive=(e,t,n)=>compareAlphanumeric(toString$1(e.getValue(n)),toString$1(t.getValue(n))),text=(e,t,n)=>compareBasic(toString$1(e.getValue(n)).toLowerCase(),toString$1(t.getValue(n)).toLowerCase()),textCaseSensitive=(e,t,n)=>compareBasic(toString$1(e.getValue(n)),toString$1(t.getValue(n))),datetime=(e,t,n)=>{const s=e.getValue(n),a=t.getValue(n);return s>a?1:s<a?-1:0},basic=(e,t,n)=>compareBasic(e.getValue(n),t.getValue(n));function compareBasic(e,t){return e===t?0:e>t?1:-1}function toString$1(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function compareAlphanumeric(e,t){const n=e.split(reSplitAlphaNumeric).filter(Boolean),s=t.split(reSplitAlphaNumeric).filter(Boolean);for(;n.length&&s.length;){const a=n.shift(),o=s.shift(),l=parseInt(a,10),c=parseInt(o,10),d=[l,c].sort();if(isNaN(d[0])){if(a>o)return 1;if(o>a)return-1;continue}if(isNaN(d[1]))return isNaN(l)?-1:1;if(l>c)return 1;if(c>l)return-1}return n.length-s.length}const sortingFns={alphanumeric:alphanumeric$1,alphanumericCaseSensitive,text,textCaseSensitive,datetime,basic},RowSorting={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:makeStateUpdater("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{const n=t.getFilteredRowModel().flatRows.slice(10);let s=!1;for(const a of n){const o=a?.getValue(e.id);if(Object.prototype.toString.call(o)==="[object Date]")return sortingFns.datetime;if(typeof o=="string"&&(s=!0,o.split(reSplitAlphaNumeric).length>1))return sortingFns.alphanumeric}return s?sortingFns.text:sortingFns.basic},e.getAutoSortDir=()=>{const n=t.getFilteredRowModel().flatRows[0];return typeof n?.getValue(e.id)=="string"?"asc":"desc"},e.getSortingFn=()=>{var n,s;if(!e)throw new Error;return isFunction$2(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(n=(s=t.options.sortingFns)==null?void 0:s[e.columnDef.sortingFn])!=null?n:sortingFns[e.columnDef.sortingFn]},e.toggleSorting=(n,s)=>{const a=e.getNextSortingOrder(),o=typeof n<"u"&&n!==null;t.setSorting(l=>{const c=l?.find(A=>A.id===e.id),d=l?.findIndex(A=>A.id===e.id);let f=[],R,S=o?n:a==="desc";if(l!=null&&l.length&&e.getCanMultiSort()&&s?c?R="toggle":R="add":l!=null&&l.length&&d!==l.length-1?R="replace":c?R="toggle":R="replace",R==="toggle"&&(o||a||(R="remove")),R==="add"){var te;f=[...l,{id:e.id,desc:S}],f.splice(0,f.length-((te=t.options.maxMultiSortColCount)!=null?te:Number.MAX_SAFE_INTEGER))}else R==="toggle"?f=l.map(A=>A.id===e.id?{...A,desc:S}:A):R==="remove"?f=l.filter(A=>A.id!==e.id):f=[{id:e.id,desc:S}];return f})},e.getFirstSortDir=()=>{var n,s;return((n=(s=e.columnDef.sortDescFirst)!=null?s:t.options.sortDescFirst)!=null?n:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=n=>{var s,a;const o=e.getFirstSortDir(),l=e.getIsSorted();return l?l!==o&&((s=t.options.enableSortingRemoval)==null||s)&&(!(n&&(a=t.options.enableMultiRemove)!=null)||a)?!1:l==="desc"?"asc":"desc":o},e.getCanSort=()=>{var n,s;return((n=e.columnDef.enableSorting)!=null?n:!0)&&((s=t.options.enableSorting)!=null?s:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var n,s;return(n=(s=e.columnDef.enableMultiSort)!=null?s:t.options.enableMultiSort)!=null?n:!!e.accessorFn},e.getIsSorted=()=>{var n;const s=(n=t.getState().sorting)==null?void 0:n.find(a=>a.id===e.id);return s?s.desc?"desc":"asc":!1},e.getSortIndex=()=>{var n,s;return(n=(s=t.getState().sorting)==null?void 0:s.findIndex(a=>a.id===e.id))!=null?n:-1},e.clearSorting=()=>{t.setSorting(n=>n!=null&&n.length?n.filter(s=>s.id!==e.id):[])},e.getToggleSortingHandler=()=>{const n=e.getCanSort();return s=>{n&&(s.persist==null||s.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(s):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var n,s;e.setSorting(t?[]:(n=(s=e.initialState)==null?void 0:s.sorting)!=null?n:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},builtInFeatures=[Headers$1,ColumnVisibility,ColumnOrdering,ColumnPinning,ColumnFaceting,ColumnFiltering,GlobalFaceting,GlobalFiltering,RowSorting,ColumnGrouping,RowExpanding,RowPagination,RowPinning,RowSelection,ColumnSizing];function createTable(e){var t,n;process.env.NODE_ENV!=="production"&&(e.debugAll||e.debugTable)&&console.info("Creating Table Instance...");const s=[...builtInFeatures,...(t=e._features)!=null?t:[]];let a={_features:s};const o=a._features.reduce((te,A)=>Object.assign(te,A.getDefaultOptions==null?void 0:A.getDefaultOptions(a)),{}),l=te=>a.options.mergeOptions?a.options.mergeOptions(o,te):{...o,...te};let d={...{},...(n=e.initialState)!=null?n:{}};a._features.forEach(te=>{var A;d=(A=te.getInitialState==null?void 0:te.getInitialState(d))!=null?A:d});const f=[];let R=!1;const S={_features:s,options:{...o,...e},initialState:d,_queue:te=>{f.push(te),R||(R=!0,Promise.resolve().then(()=>{for(;f.length;)f.shift()();R=!1}).catch(A=>setTimeout(()=>{throw A})))},reset:()=>{a.setState(a.initialState)},setOptions:te=>{const A=functionalUpdate(te,a.options);a.options=l(A)},getState:()=>a.options.state,setState:te=>{a.options.onStateChange==null||a.options.onStateChange(te)},_getRowId:(te,A,rt)=>{var st;return(st=a.options.getRowId==null?void 0:a.options.getRowId(te,A,rt))!=null?st:`${rt?[rt.id,A].join("."):A}`},getCoreRowModel:()=>(a._getCoreRowModel||(a._getCoreRowModel=a.options.getCoreRowModel(a)),a._getCoreRowModel()),getRowModel:()=>a.getPaginationRowModel(),getRow:(te,A)=>{let rt=(A?a.getPrePaginationRowModel():a.getRowModel()).rowsById[te];if(!rt&&(rt=a.getCoreRowModel().rowsById[te],!rt))throw process.env.NODE_ENV!=="production"?new Error(`getRow could not find row with ID: ${te}`):new Error;return rt},_getDefaultColumnDef:memo(()=>[a.options.defaultColumn],te=>{var A;return te=(A=te)!=null?A:{},{header:rt=>{const st=rt.header.column.columnDef;return st.accessorKey?st.accessorKey:st.accessorFn?st.id:null},cell:rt=>{var st,it;return(st=(it=rt.renderValue())==null||it.toString==null?void 0:it.toString())!=null?st:null},...a._features.reduce((rt,st)=>Object.assign(rt,st.getDefaultColumnDef==null?void 0:st.getDefaultColumnDef()),{}),...te}},getMemoOptions(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>a.options.columns,getAllColumns:memo(()=>[a._getColumnDefs()],te=>{const A=function(rt,st,it){return it===void 0&&(it=0),rt.map(at=>{const ot=createColumn(a,at,it,st),lt=at;return ot.columns=lt.columns?A(lt.columns,ot,it+1):[],ot})};return A(te)},getMemoOptions(e,"debugColumns","getAllColumns")),getAllFlatColumns:memo(()=>[a.getAllColumns()],te=>te.flatMap(A=>A.getFlatColumns()),getMemoOptions(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:memo(()=>[a.getAllFlatColumns()],te=>te.reduce((A,rt)=>(A[rt.id]=rt,A),{}),getMemoOptions(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:memo(()=>[a.getAllColumns(),a._getOrderColumnsFn()],(te,A)=>{let rt=te.flatMap(st=>st.getLeafColumns());return A(rt)},getMemoOptions(e,"debugColumns","getAllLeafColumns")),getColumn:te=>{const A=a._getAllFlatColumnsById()[te];return process.env.NODE_ENV!=="production"&&!A&&console.error(`[Table] Column with id '${te}' does not exist.`),A}};Object.assign(a,S);for(let te=0;te<a._features.length;te++){const A=a._features[te];A==null||A.createTable==null||A.createTable(a)}return a}function getCoreRowModel(){return e=>memo(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},s=function(a,o,l){o===void 0&&(o=0);const c=[];for(let f=0;f<a.length;f++){const R=createRow(e,e._getRowId(a[f],f,l),a[f],f,o,void 0,l?.id);if(n.flatRows.push(R),n.rowsById[R.id]=R,c.push(R),e.options.getSubRows){var d;R.originalSubRows=e.options.getSubRows(a[f],f),(d=R.originalSubRows)!=null&&d.length&&(R.subRows=s(R.originalSubRows,o+1,R))}}return c};return n.rows=s(t),n},getMemoOptions(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function expandRows(e){const t=[],n=s=>{var a;t.push(s),(a=s.subRows)!=null&&a.length&&s.getIsExpanded()&&s.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}function filterRows(e,t,n){return n.options.filterFromLeafRows?filterRowModelFromLeafs(e,t,n):filterRowModelFromRoot(e,t,n)}function filterRowModelFromLeafs(e,t,n){var s;const a=[],o={},l=(s=n.options.maxLeafRowFilterDepth)!=null?s:100,c=function(d,f){f===void 0&&(f=0);const R=[];for(let te=0;te<d.length;te++){var S;let A=d[te];const rt=createRow(n,A.id,A.original,A.index,A.depth,void 0,A.parentId);if(rt.columnFilters=A.columnFilters,(S=A.subRows)!=null&&S.length&&f<l){if(rt.subRows=c(A.subRows,f+1),A=rt,t(A)&&!rt.subRows.length){R.push(A),o[A.id]=A,a.push(A);continue}if(t(A)||rt.subRows.length){R.push(A),o[A.id]=A,a.push(A);continue}}else A=rt,t(A)&&(R.push(A),o[A.id]=A,a.push(A))}return R};return{rows:c(e),flatRows:a,rowsById:o}}function filterRowModelFromRoot(e,t,n){var s;const a=[],o={},l=(s=n.options.maxLeafRowFilterDepth)!=null?s:100,c=function(d,f){f===void 0&&(f=0);const R=[];for(let te=0;te<d.length;te++){let A=d[te];if(t(A)){var S;if((S=A.subRows)!=null&&S.length&&f<l){const st=createRow(n,A.id,A.original,A.index,A.depth,void 0,A.parentId);st.subRows=c(A.subRows,f+1),A=st}R.push(A),a.push(A),o[A.id]=A}}return R};return{rows:c(e),flatRows:a,rowsById:o}}function getFilteredRowModel(){return e=>memo(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,s)=>{if(!t.rows.length||!(n!=null&&n.length)&&!s){for(let te=0;te<t.flatRows.length;te++)t.flatRows[te].columnFilters={},t.flatRows[te].columnFiltersMeta={};return t}const a=[],o=[];(n??[]).forEach(te=>{var A;const rt=e.getColumn(te.id);if(!rt)return;const st=rt.getFilterFn();if(!st){process.env.NODE_ENV!=="production"&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${rt.id}.`);return}a.push({id:te.id,filterFn:st,resolvedValue:(A=st.resolveFilterValue==null?void 0:st.resolveFilterValue(te.value))!=null?A:te.value})});const l=(n??[]).map(te=>te.id),c=e.getGlobalFilterFn(),d=e.getAllLeafColumns().filter(te=>te.getCanGlobalFilter());s&&c&&d.length&&(l.push("__global__"),d.forEach(te=>{var A;o.push({id:te.id,filterFn:c,resolvedValue:(A=c.resolveFilterValue==null?void 0:c.resolveFilterValue(s))!=null?A:s})}));let f,R;for(let te=0;te<t.flatRows.length;te++){const A=t.flatRows[te];if(A.columnFilters={},a.length)for(let rt=0;rt<a.length;rt++){f=a[rt];const st=f.id;A.columnFilters[st]=f.filterFn(A,st,f.resolvedValue,it=>{A.columnFiltersMeta[st]=it})}if(o.length){for(let rt=0;rt<o.length;rt++){R=o[rt];const st=R.id;if(R.filterFn(A,st,R.resolvedValue,it=>{A.columnFiltersMeta[st]=it})){A.columnFilters.__global__=!0;break}}A.columnFilters.__global__!==!0&&(A.columnFilters.__global__=!1)}}const S=te=>{for(let A=0;A<l.length;A++)if(te.columnFilters[l[A]]===!1)return!1;return!0};return filterRows(t.rows,S,e)},getMemoOptions(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex()))}function getPaginationRowModel(e){return t=>memo(()=>[t.getState().pagination,t.getPrePaginationRowModel(),t.options.paginateExpandedRows?void 0:t.getState().expanded],(n,s)=>{if(!s.rows.length)return s;const{pageSize:a,pageIndex:o}=n;let{rows:l,flatRows:c,rowsById:d}=s;const f=a*o,R=f+a;l=l.slice(f,R);let S;t.options.paginateExpandedRows?S={rows:l,flatRows:c,rowsById:d}:S=expandRows({rows:l,flatRows:c,rowsById:d}),S.flatRows=[];const te=A=>{S.flatRows.push(A),A.subRows.length&&A.subRows.forEach(te)};return S.rows.forEach(te),S},getMemoOptions(t.options,"debugTable","getPaginationRowModel"))}function getSortedRowModel(){return e=>memo(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;const s=e.getState().sorting,a=[],o=s.filter(d=>{var f;return(f=e.getColumn(d.id))==null?void 0:f.getCanSort()}),l={};o.forEach(d=>{const f=e.getColumn(d.id);f&&(l[d.id]={sortUndefined:f.columnDef.sortUndefined,invertSorting:f.columnDef.invertSorting,sortingFn:f.getSortingFn()})});const c=d=>{const f=d.map(R=>({...R}));return f.sort((R,S)=>{for(let A=0;A<o.length;A+=1){var te;const rt=o[A],st=l[rt.id],it=st.sortUndefined,at=(te=rt?.desc)!=null?te:!1;let ot=0;if(it){const lt=R.getValue(rt.id),ut=S.getValue(rt.id),ct=lt===void 0,dt=ut===void 0;if(ct||dt){if(it==="first")return ct?-1:1;if(it==="last")return ct?1:-1;ot=ct&&dt?0:ct?it:-it}}if(ot===0&&(ot=st.sortingFn(R,S,rt.id)),ot!==0)return at&&(ot*=-1),st.invertSorting&&(ot*=-1),ot}return R.index-S.index}),f.forEach(R=>{var S;a.push(R),(S=R.subRows)!=null&&S.length&&(R.subRows=c(R.subRows))}),f};return{rows:c(n.rows),flatRows:a,rowsById:n.rowsById}},getMemoOptions(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function flexRender(e,t){return e?isReactComponent(e)?React__namespace.createElement(e,t):e:null}function isReactComponent(e){return isClassComponent(e)||typeof e=="function"||isExoticComponent(e)}function isClassComponent(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function isExoticComponent(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function useReactTable(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=React__namespace.useState(()=>({current:createTable(t)})),[s,a]=React__namespace.useState(()=>n.current.initialState);return n.current.setOptions(o=>({...o,...e,state:{...s,...e.state},onStateChange:l=>{a(l),e.onStateChange==null||e.onStateChange(l)}})),n.current}function DataTable({columns:e,data:t,uniqueValues:n,tableClass:s,loading:a,initialSort:o}){const[l,c]=React.useState(o??[]),[d,f]=React.useState([]),[R,S]=React.useState({pageIndex:0,pageSize:10}),[te,A]=React.useState(null),rt=useReactTable({data:a?[]:t,columns:e,getCoreRowModel:getCoreRowModel(),onSortingChange:c,getSortedRowModel:getSortedRowModel(),onColumnFiltersChange:f,getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),onPaginationChange:S,state:{sorting:l,columnFilters:d,pagination:R},manualPagination:a,manualSorting:a,manualFiltering:a}),st=(it,at)=>{it.toggleSorting(at),A(null)};return a?jsxRuntime.jsxs("div",{className:"@container space-y-4",children:[jsxRuntime.jsx("div",{className:`rounded-md border ${s??""}`,children:jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:jsxRuntime.jsx(TableRow,{children:e.map((it,at)=>jsxRuntime.jsx(TableHead,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-header-${at}`))})}),jsxRuntime.jsx(TableBody,{children:Array.from({length:R.pageSize}).map((it,at)=>jsxRuntime.jsx(TableRow,{children:e.map((ot,lt)=>jsxRuntime.jsx(TableCell,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-cell-${at}-${lt}`))},`skeleton-row-${at}`))})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-4 @[35rem]:flex-row @[35rem]:justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-[110px]"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-[70px]"})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"hidden h-8 w-8 lg:flex"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-8"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-8"})]}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8"}),jsxRuntime.jsx(Skeleton,{className:"hidden h-8 w-8 lg:flex"})]})]})]}):jsxRuntime.jsxs("div",{className:"@container space-y-4",children:[jsxRuntime.jsxs(ScrollArea,{className:`rounded-md border ${s??""}`,children:[jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:rt.getHeaderGroups().map(it=>jsxRuntime.jsx(TableRow,{children:it.headers.map(at=>jsxRuntime.jsx(TableHead,{children:at.isPlaceholder?null:at.column.getCanSort()||at.column.getCanFilter()?jsxRuntime.jsxs(Popover,{open:te===at.id,onOpenChange:ot=>A(ot?at.id:null),children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"pl-0",children:[flexRender(at.column.columnDef.header,at.getContext()),at.column.getIsFiltered()?jsxRuntime.jsx(Funnel,{className:"ml-2 h-4 w-4"}):at.column.getIsSorted()==="asc"?jsxRuntime.jsx(ArrowUp,{className:"ml-2 h-4 w-4"}):at.column.getIsSorted()==="desc"?jsxRuntime.jsx(ArrowDown,{className:"ml-2 h-4 w-4"}):jsxRuntime.jsx(ArrowUpDown,{className:"ml-2 h-4 w-4"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56",children:jsxRuntime.jsxs("div",{className:"space-y-2",children:[at.column.getCanSort()&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"w-full justify-start",onClick:()=>st(at.column,!1),children:[jsxRuntime.jsx(ArrowUp,{className:"mr-2 h-4 w-4"}),"Sort Ascending"]}),jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"w-full justify-start",onClick:()=>st(at.column,!0),children:[jsxRuntime.jsx(ArrowDown,{className:"mr-2 h-4 w-4"}),"Sort Descending"]})]}),at.column.getCanFilter()&&jsxRuntime.jsx("div",{className:"px-2 py-1",children:n[at.column.id]?jsxRuntime.jsxs(Select$1,{onValueChange:ot=>at.column.setFilterValue(ot==="all"?void 0:[ot]),children:[jsxRuntime.jsx(SelectTrigger,{children:jsxRuntime.jsx(SelectValue,{placeholder:`Filter ${at.column.columnDef.header}...`})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"all",children:"All"}),n[at.column.id]?.map(ot=>jsxRuntime.jsx(SelectItem,{value:ot||"empty",children:ot||"(Empty)"},ot))]})]}):jsxRuntime.jsx(Input,{placeholder:`Filter ${at.column.columnDef.header}...`,value:at.column.getFilterValue()??"",onChange:ot=>at.column.setFilterValue(ot.target.value),className:"w-full"})})]})})]}):jsxRuntime.jsx("div",{className:"py-2 px-4",children:flexRender(at.column.columnDef.header,at.getContext())})},at.id))},it.id))}),jsxRuntime.jsx(TableBody,{children:rt.getRowModel().rows?.length?rt.getRowModel().rows.map(it=>jsxRuntime.jsx(TableRow,{"data-state":it.getIsSelected()&&"selected",children:it.getVisibleCells().map(at=>jsxRuntime.jsx(TableCell,{children:flexRender(at.column.columnDef.cell,at.getContext())},at.id))},it.id)):jsxRuntime.jsx(TableRow,{children:jsxRuntime.jsx(TableCell,{colSpan:e.length,className:"h-24 text-center",children:"No results."})})})]}),jsxRuntime.jsx(ScrollBar,{orientation:"horizontal"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-4 @[35rem]:flex-row @[35rem]:justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Rows per page"}),jsxRuntime.jsxs(Select$1,{value:`${rt.getState().pagination.pageSize}`,onValueChange:it=>{rt.setPageSize(Number(it))},children:[jsxRuntime.jsx(SelectTrigger,{className:"h-8 w-[70px]",children:jsxRuntime.jsx(SelectValue,{asChild:!0,children:jsxRuntime.jsx("span",{children:rt.getState().pagination.pageSize})})}),jsxRuntime.jsx(SelectContent,{side:"top",children:[10,20,30,40,50].map(it=>jsxRuntime.jsx(SelectItem,{value:`${it}`,children:jsxRuntime.jsx("span",{children:it})},it))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxs(Button$1,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>rt.setPageIndex(0),disabled:!rt.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to first page"}),jsxRuntime.jsx(ChevronsLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>rt.previousPage(),disabled:!rt.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to previous page"}),jsxRuntime.jsx(ChevronLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Page"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:rt.getState().pagination.pageIndex+1}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"of"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:rt.getPageCount()})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>rt.nextPage(),disabled:!rt.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to next page"}),jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>rt.setPageIndex(rt.getPageCount()-1),disabled:!rt.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to last page"}),jsxRuntime.jsx(ChevronsRight,{className:"h-4 w-4"})]})]})]})]})}function PartnerCard({account:e,action:t,loading:n=!1,className:s,withAbout:a=!1}){return n||!e?jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${s}`,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-48 mt-1"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]}),a&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-48"})]})]}):jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${s}`,children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Partner",applicationId:e.ApplicationId,publicName:e.PublicName}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[(e.IsManufacturer||e.IsReseller||e.IsSalesAgency||e.HasShopifyStore||e.IsVendor)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.IsManufacturer&&jsxRuntime.jsx(Badge,{variant:"info",children:"Manufacturer"}),e.IsReseller&&jsxRuntime.jsx(Badge,{variant:"success",children:"Reseller"}),e.IsSalesAgency&&jsxRuntime.jsx(Badge,{variant:"outline",children:"Agency"}),e.HasShopifyStore&&jsxRuntime.jsx(Badge,{variant:"secondary",children:"Shopify"}),e.IsVendor&&jsxRuntime.jsx(Badge,{variant:"outline",children:"Vendor"})]}),a&&e.About&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.About??""}})]})}),jsxRuntime.jsx(CardFooter,{className:"px-6 py-4 flex justify-end gap-2 mt-auto",children:t||jsxRuntime.jsxs(Button$1,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})})]})}function ResellerCard({reseller:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1}){if(o||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsx("div",{className:"flex",children:jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 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 l=[e.City,e.Province,e.Country].filter(Boolean),c=l.length>0?l.join(", "):"Location not provided",d=e.Priority?.trim(),f=!!e.Qualification?.QualificationId&&e.Qualification?.QualificationId!=="Suspended",R=!!e.OnHold&&e.OnHold!==0,S=!!d,te=A=>{const rt=A.toLowerCase();return rt.includes("starter")||rt.includes("basic")?"secondary":rt.includes("exclusive")||rt.includes("jean coutu")||rt.includes("novexco")||rt.includes("coopsco")?"success":"info"};return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Reseller",applicationId:e.ResellerId,publicName:e.PublicName,name:e.Name,location:c,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:[(f||R||S)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[f&&jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),R&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),S&&jsxRuntime.jsx(Badge,{variant:te(d),children:d})]}),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)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:s&&s}),a&&jsxRuntime.jsx("div",{children:a})]})]})}const Table=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{className:"relative w-full overflow-auto",children:jsxRuntime.jsx("table",{ref:n,className:cn("w-full caption-bottom text-sm",e),...t})}));Table.displayName="Table";const TableHeader=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("thead",{ref:n,className:cn("[&_tr]:border-b",e),...t}));TableHeader.displayName="TableHeader";const TableBody=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tbody",{ref:n,className:cn("[&_tr:last-child]:border-0",e),...t}));TableBody.displayName="TableBody";const TableFooter=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tfoot",{ref:n,className:cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));TableFooter.displayName="TableFooter";const TableRow=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tr",{ref:n,className:cn("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));TableRow.displayName="TableRow";const TableHead=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("th",{ref:n,className:cn("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t,children:React__namespace.isValidElement(t.children)&&t.children.type==="span"?t.children:jsxRuntime.jsx("span",{children:t.children})}));TableHead.displayName="TableHead";const TableCell=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("td",{ref:n,className:cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t,children:React__namespace.isValidElement(t.children)&&t.children.type==="span"?t.children:jsxRuntime.jsx("span",{children:t.children})}));TableCell.displayName="TableCell";const TableCaption=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("caption",{ref:n,className:cn("mt-4 text-sm text-muted-foreground",e),...t}));TableCaption.displayName="TableCaption";const APP_SHELL_HEADER_HEIGHT_TOKEN_CLASS="[--rm-shell-header-height:3.5rem]",APP_SHELL_HEADER_HEIGHT_CLASS="h-[var(--rm-shell-header-height)]",APP_SHELL_HEADER_OFFSET_CLASS="pt-[var(--rm-shell-header-height)]",Topbar=React.forwardRef(({onSignOut:e,handleValidSearch:t,rightMenu:n,searchPlaceholder:s},a)=>{const[o,l]=React.useState(""),c=reactRouterDom.useLocation(),{toast:d}=useToast();React.useEffect(()=>{const te=new URLSearchParams(c.search).get("q");te&&l(te)},[c.search]);const f=()=>{const S=o.trim();if(!S||S.length<2){d({title:"Enter more characters to search",description:"At least 2 characters are needed to search products.",variant:"destructive",duration:5e3});return}t(S)},R=S=>{S.key==="Enter"&&f()};return jsxRuntime.jsxs("header",{className:`fixed top-0 right-0 left-0 z-50 flex ${APP_SHELL_HEADER_HEIGHT_TOKEN_CLASS} ${APP_SHELL_HEADER_HEIGHT_CLASS} items-center gap-3 border-b border-primary/20 bg-primary px-4 text-primary-foreground transition-[left] duration-200 ease-linear lg:px-6 peer-data-[state=expanded]:lg:left-(--sidebar-width) peer-data-[collapsible=offcanvas]:lg:left-0 peer-data-[collapsible=icon]:lg:left-(--sidebar-width-icon)`,children:[jsxRuntime.jsx(SidebarTrigger,{className:"h-10 w-10 text-primary-foreground hover:bg-primary-foreground/15 hover:text-primary-foreground focus-visible:ring-primary-foreground focus-visible:ring-offset-primary lg:hidden",children:jsxRuntime.jsx(Menu$1,{className:"h-5 w-5"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center gap-4",children:jsxRuntime.jsx("div",{className:"relative w-full max-w-sm",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{type:"button",className:"absolute left-1 top-1/2 inline-flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-md text-primary-foreground/90 transition-colors hover:bg-primary-foreground/15 hover:text-primary-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-foreground focus-visible:ring-offset-2 focus-visible:ring-offset-primary",onClick:f,"aria-label":"Search",children:jsxRuntime.jsx(Search,{className:"h-4 w-4"})}),jsxRuntime.jsx(Input,{placeholder:s??"Search...","aria-label":s??"Search",className:"h-10 w-full border-primary-foreground/35 bg-primary-foreground/12 pl-10 text-primary-foreground placeholder:text-primary-foreground/70 focus-visible:ring-primary-foreground focus-visible:ring-offset-primary",value:o,onChange:S=>l(S.target.value),onKeyDown:R,ref:a},"topbar-search")]})})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3 text-primary-foreground [&_svg]:text-primary-foreground",children:[n,e&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Button$1,{variant:"ghost",size:"icon",className:"h-10 w-10 text-primary-foreground hover:bg-primary-foreground/15 hover:text-primary-foreground focus-visible:ring-primary-foreground focus-visible:ring-offset-primary",onClick:e,children:[jsxRuntime.jsx(LogOut,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"sr-only",children:"Sign out"})]})})]})]})});Topbar.displayName="Topbar";function ActiveOrdersCard({orders:e,loading:t=!1}){const n=React.useMemo(()=>{if(!e||e.length===0)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const a=e.filter(it=>it.DocumentType==="Order"),o=e.filter(it=>it.DocumentType==="Shipment"),l=a.filter(it=>it.WarehouseCode!=="3PLE"),c=l.reduce((it,at)=>it+(at.Quantity||0),0),d=l.reduce((it,at)=>it+(at.ExtendedPrice||0),0),f=a.filter(it=>it.WarehouseCode==="3PLE"),R=f.reduce((it,at)=>it+(at.Quantity||0),0),S=f.reduce((it,at)=>it+(at.ExtendedPrice||0),0),te=o.length,A=o.reduce((it,at)=>it+(at.ExtendedPrice||0),0),rt=c+R+te,st=d+S+A;return{all:{orders:rt,amount:st},processing:{orders:c,amount:d},shipped:{orders:te,amount:A},delayed:{orders:R,amount:S}}},[e]),s=[{name:"All",icon:Package,stripeClass:"bg-info/60",iconBgClass:"bg-info/90",iconTextClass:"text-info-foreground",orders:n.all.orders,amount:n.all.amount},{name:"Processing",icon:RefreshCcw,stripeClass:"bg-warning/60",iconBgClass:"bg-warning/90",iconTextClass:"text-warning-foreground",orders:n.processing.orders,amount:n.processing.amount},{name:"Shipped",icon:Truck,stripeClass:"bg-success/60",iconBgClass:"bg-success/90",iconTextClass:"text-success-foreground",orders:n.shipped.orders,amount:n.shipped.amount},{name:"Delayed",icon:CircleAlert,stripeClass:"bg-destructive/60",iconBgClass:"bg-destructive/90",iconTextClass:"text-destructive-foreground",orders:n.delayed.orders,amount:n.delayed.amount}];return t?jsxRuntime.jsxs(Card,{className:"@container",children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:[1,2,3,4].map(a=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:"bg-border 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-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]},a))})]}):jsxRuntime.jsxs(Card,{className:"@container",children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:s.map(a=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:`${a.stripeClass} 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:a.name}),jsxRuntime.jsx("div",{className:`${a.iconBgClass} p-2 rounded-full`,children:jsxRuntime.jsx(a.icon,{className:`size-4 shrink-0 ${a.iconTextClass}`})})]}),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:a.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:formatMoney(a.amount)})]})]})]})]},a.name))})]})}var CHECKBOX_NAME="Checkbox",[createCheckboxContext]=createContextScope$2(CHECKBOX_NAME),[CheckboxProviderImpl,useCheckboxContext]=createCheckboxContext(CHECKBOX_NAME);function CheckboxProvider(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:a,disabled:o,form:l,name:c,onCheckedChange:d,required:f,value:R="on",internal_do_not_use_render:S}=e,[te,A]=useControllableState({prop:n,defaultProp:a??!1,onChange:d,caller:CHECKBOX_NAME}),[rt,st]=React__namespace.useState(null),[it,at]=React__namespace.useState(null),ot=React__namespace.useRef(!1),lt=rt?!!l||!!rt.closest("form"):!0,ut={checked:te,disabled:o,setChecked:A,control:rt,setControl:st,name:c,form:l,value:R,hasConsumerStoppedPropagationRef:ot,required:f,defaultChecked:isIndeterminate(a)?!1:a,isFormControl:lt,bubbleInput:it,setBubbleInput:at};return jsxRuntime.jsx(CheckboxProviderImpl,{scope:t,...ut,children:isFunction$1(S)?S(ut):s})}var TRIGGER_NAME$4="CheckboxTrigger",CheckboxTrigger=React__namespace.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},a)=>{const{control:o,value:l,disabled:c,checked:d,required:f,setControl:R,setChecked:S,hasConsumerStoppedPropagationRef:te,isFormControl:A,bubbleInput:rt}=useCheckboxContext(TRIGGER_NAME$4,e),st=useComposedRefs(a,R),it=React__namespace.useRef(d);return React__namespace.useEffect(()=>{const at=o?.form;if(at){const ot=()=>S(it.current);return at.addEventListener("reset",ot),()=>at.removeEventListener("reset",ot)}},[o,S]),jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"checkbox","aria-checked":isIndeterminate(d)?"mixed":d,"aria-required":f,"data-state":getState$3(d),"data-disabled":c?"":void 0,disabled:c,value:l,...s,ref:st,onKeyDown:composeEventHandlers(t,at=>{at.key==="Enter"&&at.preventDefault()}),onClick:composeEventHandlers(n,at=>{S(ot=>isIndeterminate(ot)?!0:!ot),rt&&A&&(te.current=at.isPropagationStopped(),te.current||at.stopPropagation())})})});CheckboxTrigger.displayName=TRIGGER_NAME$4;var Checkbox$1=React__namespace.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:a,defaultChecked:o,required:l,disabled:c,value:d,onCheckedChange:f,form:R,...S}=e;return jsxRuntime.jsx(CheckboxProvider,{__scopeCheckbox:n,checked:a,defaultChecked:o,disabled:c,required:l,onCheckedChange:f,name:s,form:R,value:d,internal_do_not_use_render:({isFormControl:te})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(CheckboxTrigger,{...S,ref:t,__scopeCheckbox:n}),te&&jsxRuntime.jsx(CheckboxBubbleInput,{__scopeCheckbox:n})]})})});Checkbox$1.displayName=CHECKBOX_NAME;var INDICATOR_NAME="CheckboxIndicator",CheckboxIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...a}=e,o=useCheckboxContext(INDICATOR_NAME,n);return jsxRuntime.jsx(Presence,{present:s||isIndeterminate(o.checked)||o.checked===!0,children:jsxRuntime.jsx(Primitive$4.span,{"data-state":getState$3(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});CheckboxIndicator.displayName=INDICATOR_NAME;var BUBBLE_INPUT_NAME="CheckboxBubbleInput",CheckboxBubbleInput=React__namespace.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:c,disabled:d,name:f,value:R,form:S,bubbleInput:te,setBubbleInput:A}=useCheckboxContext(BUBBLE_INPUT_NAME,e),rt=useComposedRefs(n,A),st=usePrevious(o),it=useSize(s);React__namespace.useEffect(()=>{const ot=te;if(!ot)return;const lt=window.HTMLInputElement.prototype,ct=Object.getOwnPropertyDescriptor(lt,"checked").set,dt=!a.current;if(st!==o&&ct){const pt=new Event("click",{bubbles:dt});ot.indeterminate=isIndeterminate(o),ct.call(ot,isIndeterminate(o)?!1:o),ot.dispatchEvent(pt)}},[te,st,o,a]);const at=React__namespace.useRef(isIndeterminate(o)?!1:o);return jsxRuntime.jsx(Primitive$4.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??at.current,required:c,disabled:d,name:f,value:R,form:S,...t,tabIndex:-1,ref:rt,style:{...t.style,...it,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});CheckboxBubbleInput.displayName=BUBBLE_INPUT_NAME;function isFunction$1(e){return typeof e=="function"}function isIndeterminate(e){return e==="indeterminate"}function getState$3(e){return isIndeterminate(e)?"indeterminate":e?"checked":"unchecked"}const Checkbox=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Checkbox$1,{ref:n,className:cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:jsxRuntime.jsx(CheckboxIndicator,{className:cn("flex items-center justify-center text-current"),children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}));Checkbox.displayName=Checkbox$1.displayName;function CheckboxCardList({items:e,selectedIds:t,onSelectedIdsChange:n,disabled:s=!1,loading:a=!1,selectionMode:o="multiple",layout:l="stack",gridColumns:c=2,emptyState:d,loadingState:f,getItemAriaLabel:R,renderItem:S,className:te,...A}){const rt=React__namespace.useId(),st=React__namespace.useMemo(()=>new Set(t),[t]),it=l==="grid"?cn("grid gap-3",c===2&&"grid-cols-1 sm:grid-cols-2"):"space-y-3",at=React__namespace.useCallback(ot=>{if(s||a||ot.disabled)return;const lt=st.has(ot.id);if(o==="single"){n(lt?[]:[ot.id]);return}if(lt){n(t.filter(ut=>ut!==ot.id));return}n([...t,ot.id])},[s,a,n,st,t,o]);return a?jsxRuntime.jsx("div",{className:cn(it,te),role:"status","aria-live":"polite",...A,children:f??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Loading options"}),Array.from({length:l==="grid"?4:3}).map((ot,lt)=>jsxRuntime.jsxs("div",{className:"rounded-xl border border-border bg-card p-4 shadow-sm","aria-hidden":"true",children:[jsxRuntime.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-muted"}),jsxRuntime.jsx("div",{className:"mt-2 h-3 w-1/2 animate-pulse rounded bg-muted"})]},`loading-${lt}`))]})}):e.length===0?jsxRuntime.jsx("div",{className:cn(it,te),...A,children:d??jsxRuntime.jsx("div",{className:"rounded-xl border border-dashed border-border bg-muted/30 p-4 text-sm text-muted-foreground",children:"No options are available."})}):jsxRuntime.jsx("div",{className:cn(it,te),role:"group","aria-disabled":s||void 0,...A,children:e.map((ot,lt)=>{const ut=st.has(ot.id),ct=s||ot.disabled===!0,dt=`${rt}-${lt}-label`,pt=`${rt}-${lt}-description`;return jsxRuntime.jsxs("button",{type:"button",role:"checkbox","aria-checked":ut,"aria-disabled":ct,"aria-label":R?.(ot)??ot.label,"aria-labelledby":S?void 0:dt,"aria-describedby":!S&&ot.description?pt:void 0,disabled:ct,onClick:()=>at(ot),className:cn("flex w-full items-start gap-3 rounded-xl border bg-card p-4 text-left shadow-sm transition-colors transition-shadow","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","hover:bg-muted/30 hover:shadow",ut?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border",ct&&"cursor-not-allowed opacity-60 hover:bg-card hover:shadow-sm"),children:[jsxRuntime.jsx("span",{"aria-hidden":"true",className:cn("mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-primary shadow-sm",ut?"bg-primary text-primary-foreground":"bg-background text-transparent"),children:jsxRuntime.jsx(Check,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"sr-only",children:ot.label}),S(ot,{checked:ut,disabled:ct,index:lt})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(ot.prefix||ot.emphasis)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-baseline gap-1 text-xs",children:[ot.prefix&&jsxRuntime.jsx("span",{className:"font-semibold uppercase tracking-wide text-muted-foreground",children:ot.prefix}),ot.emphasis&&jsxRuntime.jsx("span",{className:"font-semibold text-foreground",children:ot.emphasis})]}),jsxRuntime.jsx("span",{id:dt,className:cn("block text-sm font-medium text-foreground",(ot.prefix||ot.emphasis)&&"mt-1"),children:ot.label}),ot.description&&jsxRuntime.jsx("span",{id:pt,className:"mt-1 block text-sm text-muted-foreground",children:ot.description})]})})]},ot.id)})})}var U=1,Y$1=.9,H=.8,J=.17,p=.1,u=.999,$=.9999,k$1=.99,m=/[\\\/_+.#"@\[\(\{&]/,B$1=/[\\\/_+.#"@\[\(\{&]/g,K$1=/[\s-]/,X=/[\s-]/g;function G(e,t,n,s,a,o,l){if(o===t.length)return a===e.length?U:k$1;var c=`${a},${o}`;if(l[c]!==void 0)return l[c];for(var d=s.charAt(o),f=n.indexOf(d,a),R=0,S,te,A,rt;f>=0;)S=G(e,t,n,s,f+1,o+1,l),S>R&&(f===a?S*=U:m.test(e.charAt(f-1))?(S*=H,A=e.slice(a,f-1).match(B$1),A&&a>0&&(S*=Math.pow(u,A.length))):K$1.test(e.charAt(f-1))?(S*=Y$1,rt=e.slice(a,f-1).match(X),rt&&a>0&&(S*=Math.pow(u,rt.length))):(S*=J,a>0&&(S*=Math.pow(u,f-a))),e.charAt(f)!==t.charAt(o)&&(S*=$)),(S<p&&n.charAt(f-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&n.charAt(f-1)!==s.charAt(o))&&(te=G(e,t,n,s,f+1,o+2,l),te*p>S&&(S=te*p)),S>R&&(R=S),f=n.indexOf(d,f+1);return l[c]=R,R}function D(e){return e.toLowerCase().replace(X," ")}function W(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,G(e,t,D(e),D(t),0,0,{})}var N='[cmdk-group=""]',Y='[cmdk-group-items=""]',be='[cmdk-group-heading=""]',le='[cmdk-item=""]',ce=`${le}:not([aria-disabled="true"])`,Z="cmdk-item-select",T="data-value",Re=(e,t,n)=>W(e,t,n),ue=React__namespace.createContext(void 0),K=()=>React__namespace.useContext(ue),de=React__namespace.createContext(void 0),ee=()=>React__namespace.useContext(de),fe=React__namespace.createContext(void 0),me=React__namespace.forwardRef((e,t)=>{let n=L(()=>{var Jt,ar;return{search:"",value:(ar=(Jt=e.value)!=null?Jt:e.defaultValue)!=null?ar:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=L(()=>new Set),a=L(()=>new Map),o=L(()=>new Map),l=L(()=>new Set),c=pe(e),{label:d,children:f,value:R,onValueChange:S,filter:te,shouldFilter:A,loop:rt,disablePointerSelection:st=!1,vimBindings:it=!0,...at}=e,ot=useId$1(),lt=useId$1(),ut=useId$1(),ct=React__namespace.useRef(null),dt=ke();k(()=>{if(R!==void 0){let Jt=R.trim();n.current.value=Jt,pt.emit()}},[R]),k(()=>{dt(6,Ct)},[]);let pt=React__namespace.useMemo(()=>({subscribe:Jt=>(l.current.add(Jt),()=>l.current.delete(Jt)),snapshot:()=>n.current,setState:(Jt,ar,cr)=>{var Zt,lr,Ut,rr;if(!Object.is(n.current[Jt],ar)){if(n.current[Jt]=ar,Jt==="search")ft(),yt(),dt(1,It);else if(Jt==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let qt=document.getElementById(ut);qt?qt.focus():(Zt=document.getElementById(ot))==null||Zt.focus()}if(dt(7,()=>{var qt;n.current.selectedItemId=(qt=Mt())==null?void 0:qt.id,pt.emit()}),cr||dt(5,Ct),((lr=c.current)==null?void 0:lr.value)!==void 0){let qt=ar??"";(rr=(Ut=c.current).onValueChange)==null||rr.call(Ut,qt);return}}pt.emit()}},emit:()=>{l.current.forEach(Jt=>Jt())}}),[]),mt=React__namespace.useMemo(()=>({value:(Jt,ar,cr)=>{var Zt;ar!==((Zt=o.current.get(Jt))==null?void 0:Zt.value)&&(o.current.set(Jt,{value:ar,keywords:cr}),n.current.filtered.items.set(Jt,Rt(ar,cr)),dt(2,()=>{yt(),pt.emit()}))},item:(Jt,ar)=>(s.current.add(Jt),ar&&(a.current.has(ar)?a.current.get(ar).add(Jt):a.current.set(ar,new Set([Jt]))),dt(3,()=>{ft(),yt(),n.current.value||It(),pt.emit()}),()=>{o.current.delete(Jt),s.current.delete(Jt),n.current.filtered.items.delete(Jt);let cr=Mt();dt(4,()=>{ft(),cr?.getAttribute("id")===Jt&&It(),pt.emit()})}),group:Jt=>(a.current.has(Jt)||a.current.set(Jt,new Set),()=>{o.current.delete(Jt),a.current.delete(Jt)}),filter:()=>c.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:ot,inputId:ut,labelId:lt,listInnerRef:ct}),[]);function Rt(Jt,ar){var cr,Zt;let lr=(Zt=(cr=c.current)==null?void 0:cr.filter)!=null?Zt:Re;return Jt?lr(Jt,n.current.search,ar):0}function yt(){if(!n.current.search||c.current.shouldFilter===!1)return;let Jt=n.current.filtered.items,ar=[];n.current.filtered.groups.forEach(Zt=>{let lr=a.current.get(Zt),Ut=0;lr.forEach(rr=>{let qt=Jt.get(rr);Ut=Math.max(qt,Ut)}),ar.push([Zt,Ut])});let cr=ct.current;Dt().sort((Zt,lr)=>{var Ut,rr;let qt=Zt.getAttribute("id"),Qt=lr.getAttribute("id");return((Ut=Jt.get(Qt))!=null?Ut:0)-((rr=Jt.get(qt))!=null?rr:0)}).forEach(Zt=>{let lr=Zt.closest(Y);lr?lr.appendChild(Zt.parentElement===lr?Zt:Zt.closest(`${Y} > *`)):cr.appendChild(Zt.parentElement===cr?Zt:Zt.closest(`${Y} > *`))}),ar.sort((Zt,lr)=>lr[1]-Zt[1]).forEach(Zt=>{var lr;let Ut=(lr=ct.current)==null?void 0:lr.querySelector(`${N}[${T}="${encodeURIComponent(Zt[0])}"]`);Ut?.parentElement.appendChild(Ut)})}function It(){let Jt=Dt().find(cr=>cr.getAttribute("aria-disabled")!=="true"),ar=Jt?.getAttribute(T);pt.setState("value",ar||void 0)}function ft(){var Jt,ar,cr,Zt;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=s.current.size;return}n.current.filtered.groups=new Set;let lr=0;for(let Ut of s.current){let rr=(ar=(Jt=o.current.get(Ut))==null?void 0:Jt.value)!=null?ar:"",qt=(Zt=(cr=o.current.get(Ut))==null?void 0:cr.keywords)!=null?Zt:[],Qt=Rt(rr,qt);n.current.filtered.items.set(Ut,Qt),Qt>0&&lr++}for(let[Ut,rr]of a.current)for(let qt of rr)if(n.current.filtered.items.get(qt)>0){n.current.filtered.groups.add(Ut);break}n.current.filtered.count=lr}function Ct(){var Jt,ar,cr;let Zt=Mt();Zt&&(((Jt=Zt.parentElement)==null?void 0:Jt.firstChild)===Zt&&((cr=(ar=Zt.closest(N))==null?void 0:ar.querySelector(be))==null||cr.scrollIntoView({block:"nearest"})),Zt.scrollIntoView({block:"nearest"}))}function Mt(){var Jt;return(Jt=ct.current)==null?void 0:Jt.querySelector(`${le}[aria-selected="true"]`)}function Dt(){var Jt;return Array.from(((Jt=ct.current)==null?void 0:Jt.querySelectorAll(ce))||[])}function Vt(Jt){let ar=Dt()[Jt];ar&&pt.setState("value",ar.getAttribute(T))}function Wt(Jt){var ar;let cr=Mt(),Zt=Dt(),lr=Zt.findIndex(rr=>rr===cr),Ut=Zt[lr+Jt];(ar=c.current)!=null&&ar.loop&&(Ut=lr+Jt<0?Zt[Zt.length-1]:lr+Jt===Zt.length?Zt[0]:Zt[lr+Jt]),Ut&&pt.setState("value",Ut.getAttribute(T))}function $t(Jt){let ar=Mt(),cr=ar?.closest(N),Zt;for(;cr&&!Zt;)cr=Jt>0?we(cr,N):De(cr,N),Zt=cr?.querySelector(ce);Zt?pt.setState("value",Zt.getAttribute(T)):Wt(Jt)}let Ft=()=>Vt(Dt().length-1),Ht=Jt=>{Jt.preventDefault(),Jt.metaKey?Ft():Jt.altKey?$t(1):Wt(1)},nr=Jt=>{Jt.preventDefault(),Jt.metaKey?Vt(0):Jt.altKey?$t(-1):Wt(-1)};return React__namespace.createElement(Primitive$4.div,{ref:t,tabIndex:-1,...at,"cmdk-root":"",onKeyDown:Jt=>{var ar;(ar=at.onKeyDown)==null||ar.call(at,Jt);let cr=Jt.nativeEvent.isComposing||Jt.keyCode===229;if(!(Jt.defaultPrevented||cr))switch(Jt.key){case"n":case"j":{it&&Jt.ctrlKey&&Ht(Jt);break}case"ArrowDown":{Ht(Jt);break}case"p":case"k":{it&&Jt.ctrlKey&&nr(Jt);break}case"ArrowUp":{nr(Jt);break}case"Home":{Jt.preventDefault(),Vt(0);break}case"End":{Jt.preventDefault(),Ft();break}case"Enter":{Jt.preventDefault();let Zt=Mt();if(Zt){let lr=new Event(Z);Zt.dispatchEvent(lr)}}}}},React__namespace.createElement("label",{"cmdk-label":"",htmlFor:mt.inputId,id:mt.labelId,style:Te},d),B(e,Jt=>React__namespace.createElement(de.Provider,{value:pt},React__namespace.createElement(ue.Provider,{value:mt},Jt))))}),he=React__namespace.forwardRef((e,t)=>{var n,s;let a=useId$1(),o=React__namespace.useRef(null),l=React__namespace.useContext(fe),c=K(),d=pe(e),f=(s=(n=d.current)==null?void 0:n.forceMount)!=null?s:l?.forceMount;k(()=>{if(!f)return c.item(a,l?.id)},[f]);let R=ve(a,o,[e.value,e.children,o],e.keywords),S=ee(),te=P(dt=>dt.value&&dt.value===R.current),A=P(dt=>f||c.filter()===!1?!0:dt.search?dt.filtered.items.get(a)>0:!0);React__namespace.useEffect(()=>{let dt=o.current;if(!(!dt||e.disabled))return dt.addEventListener(Z,rt),()=>dt.removeEventListener(Z,rt)},[A,e.onSelect,e.disabled]);function rt(){var dt,pt;st(),(pt=(dt=d.current).onSelect)==null||pt.call(dt,R.current)}function st(){S.setState("value",R.current,!0)}if(!A)return null;let{disabled:it,value:at,onSelect:ot,forceMount:lt,keywords:ut,...ct}=e;return React__namespace.createElement(Primitive$4.div,{ref:composeRefs(o,t),...ct,id:a,"cmdk-item":"",role:"option","aria-disabled":!!it,"aria-selected":!!te,"data-disabled":!!it,"data-selected":!!te,onPointerMove:it||c.getDisablePointerSelection()?void 0:st,onClick:it?void 0:rt},e.children)}),Ee=React__namespace.forwardRef((e,t)=>{let{heading:n,children:s,forceMount:a,...o}=e,l=useId$1(),c=React__namespace.useRef(null),d=React__namespace.useRef(null),f=useId$1(),R=K(),S=P(A=>a||R.filter()===!1?!0:A.search?A.filtered.groups.has(l):!0);k(()=>R.group(l),[]),ve(l,c,[e.value,e.heading,d]);let te=React__namespace.useMemo(()=>({id:l,forceMount:a}),[a]);return React__namespace.createElement(Primitive$4.div,{ref:composeRefs(c,t),...o,"cmdk-group":"",role:"presentation",hidden:S?void 0:!0},n&&React__namespace.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),B(e,A=>React__namespace.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},React__namespace.createElement(fe.Provider,{value:te},A))))}),ye=React__namespace.forwardRef((e,t)=>{let{alwaysRender:n,...s}=e,a=React__namespace.useRef(null),o=P(l=>!l.search);return!n&&!o?null:React__namespace.createElement(Primitive$4.div,{ref:composeRefs(a,t),...s,"cmdk-separator":"",role:"separator"})}),Se=React__namespace.forwardRef((e,t)=>{let{onValueChange:n,...s}=e,a=e.value!=null,o=ee(),l=P(f=>f.search),c=P(f=>f.selectedItemId),d=K();return React__namespace.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),React__namespace.createElement(Primitive$4.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":c,id:d.inputId,type:"text",value:a?e.value:l,onChange:f=>{a||o.setState("search",f.target.value),n?.(f.target.value)}})}),Ce=React__namespace.forwardRef((e,t)=>{let{children:n,label:s="Suggestions",...a}=e,o=React__namespace.useRef(null),l=React__namespace.useRef(null),c=P(f=>f.selectedItemId),d=K();return React__namespace.useEffect(()=>{if(l.current&&o.current){let f=l.current,R=o.current,S,te=new ResizeObserver(()=>{S=requestAnimationFrame(()=>{let A=f.offsetHeight;R.style.setProperty("--cmdk-list-height",A.toFixed(1)+"px")})});return te.observe(f),()=>{cancelAnimationFrame(S),te.unobserve(f)}}},[]),React__namespace.createElement(Primitive$4.div,{ref:composeRefs(o,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":s,id:d.listId},B(e,f=>React__namespace.createElement("div",{ref:composeRefs(l,d.listInnerRef),"cmdk-list-sizer":""},f)))}),xe=React__namespace.forwardRef((e,t)=>{let{open:n,onOpenChange:s,overlayClassName:a,contentClassName:o,container:l,...c}=e;return React__namespace.createElement(Root$a,{open:n,onOpenChange:s},React__namespace.createElement(Portal$4,{container:l},React__namespace.createElement(Overlay,{"cmdk-overlay":"",className:a}),React__namespace.createElement(Content$3,{"aria-label":e.label,"cmdk-dialog":"",className:o},React__namespace.createElement(me,{ref:t,...c}))))}),Ie=React__namespace.forwardRef((e,t)=>P(n=>n.filtered.count===0)?React__namespace.createElement(Primitive$4.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Pe=React__namespace.forwardRef((e,t)=>{let{progress:n,children:s,label:a="Loading...",...o}=e;return React__namespace.createElement(Primitive$4.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},B(e,l=>React__namespace.createElement("div",{"aria-hidden":!0},l)))}),_e=Object.assign(me,{List:Ce,Item:he,Input:Se,Group:Ee,Separator:ye,Dialog:xe,Empty:Ie,Loading:Pe});function we(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function De(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function pe(e){let t=React__namespace.useRef(e);return k(()=>{t.current=e}),t}var k=typeof window>"u"?React__namespace.useEffect:React__namespace.useLayoutEffect;function L(e){let t=React__namespace.useRef();return t.current===void 0&&(t.current=e()),t}function P(e){let t=ee(),n=()=>e(t.snapshot());return React__namespace.useSyncExternalStore(t.subscribe,n,n)}function ve(e,t,n,s=[]){let a=React__namespace.useRef(),o=K();return k(()=>{var l;let c=(()=>{var f;for(let R of n){if(typeof R=="string")return R.trim();if(typeof R=="object"&&"current"in R)return R.current?(f=R.current.textContent)==null?void 0:f.trim():a.current}})(),d=s.map(f=>f.trim());o.value(e,c,d),(l=t.current)==null||l.setAttribute(T,c),a.current=c}),a}var ke=()=>{let[e,t]=React__namespace.useState(),n=L(()=>new Map);return k(()=>{n.current.forEach(s=>s()),n.current=new Map},[e]),(s,a)=>{n.current.set(s,a),t({})}};function Me(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function B({asChild:e,children:t},n){return e&&React__namespace.isValidElement(t)?React__namespace.cloneElement(Me(t),{ref:t.ref},n(t.props.children)):n(t)}var Te={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Command=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e,{ref:n,className:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Command.displayName=_e.displayName;const CommandDialog=({children:e,...t})=>jsxRuntime.jsx(Dialog,{...t,children:jsxRuntime.jsx(DialogContent,{className:"overflow-hidden p-0",children:jsxRuntime.jsx(Command,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})})}),CommandInput=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[jsxRuntime.jsx(Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),jsxRuntime.jsx(_e.Input,{ref:n,className:cn("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));CommandInput.displayName=_e.Input.displayName;const CommandList=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.List,{ref:n,className:cn("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));CommandList.displayName=_e.List.displayName;const CommandEmpty=React__namespace.forwardRef((e,t)=>jsxRuntime.jsx(_e.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));CommandEmpty.displayName=_e.Empty.displayName;const CommandGroup=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Group,{ref:n,className:cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));CommandGroup.displayName=_e.Group.displayName;const CommandSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Separator,{ref:n,className:cn("-mx-1 h-px bg-border",e),...t}));CommandSeparator.displayName=_e.Separator.displayName;const CommandItem=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Item,{ref:n,className:cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));CommandItem.displayName=_e.Item.displayName;const CommandShortcut=({className:e,...t})=>jsxRuntime.jsx("span",{className:cn("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});CommandShortcut.displayName="CommandShortcut";const CountryFlag=({countryCode:e,className:t=""})=>{const[n,s]=React.useState(!1),a=e.trim().toUpperCase();React.useEffect(()=>{s(!1)},[a]);const o=React.useMemo(()=>a?`https://purecatamphetamine.github.io/country-flag-icons/3x2/${encodeURIComponent(a)}.svg`:"",[a]);return!a||n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:o,alt:`${a} flag`,className:`inline-block h-auto w-6 ${t}`,loading:"lazy",onError:()=>s(!0)})};function GeneralDocumentCard({document:e,loading:t=!1}){return t?jsxRuntime.jsx("div",{children:"loading..."}):jsxRuntime.jsxs("div",{children:["GENERAL DOCUMENT CARD - ",e?.OrderNumber," for P.O. ",e?.PONumber]})}function ApiImage({path:e,origin:t,...n}){const s=useApiOrigin(),a=React__namespace.useMemo(()=>buildApiUrl(e,t??s),[s,t,e]);return jsxRuntime.jsx("img",{...n,src:a})}var md5={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$1=getAugmentedNamespace(__viteBrowserExternal$1);var hasRequiredMd5;function requireMd5(){return hasRequiredMd5||(hasRequiredMd5=1,(function(e){(function(){var t="input is invalid type",n="finalize already called",s=typeof window=="object",a=s?window:{};a.JS_MD5_NO_WINDOW&&(s=!1);var o=!s&&typeof self=="object",l=!a.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;l?a=commonjsGlobal:o&&(a=self);var c=!a.JS_MD5_NO_COMMON_JS&&!0&&e.exports,d=!a.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),R=[128,32768,8388608,-2147483648],S=[0,8,16,24],te=["hex","array","digest","buffer","arrayBuffer","base64"],A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),rt=[],st;if(d){var it=new ArrayBuffer(68);st=new Uint8Array(it),rt=new Uint32Array(it)}var at=Array.isArray;(a.JS_MD5_NO_NODE_JS||!at)&&(at=function(ft){return Object.prototype.toString.call(ft)==="[object Array]"});var ot=ArrayBuffer.isView;d&&(a.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW||!ot)&&(ot=function(ft){return typeof ft=="object"&&ft.buffer&&ft.buffer.constructor===ArrayBuffer});var lt=function(ft){var Ct=typeof ft;if(Ct==="string")return[ft,!0];if(Ct!=="object"||ft===null)throw new Error(t);if(d&&ft.constructor===ArrayBuffer)return[new Uint8Array(ft),!1];if(!at(ft)&&!ot(ft))throw new Error(t);return[ft,!1]},ut=function(ft){return function(Ct){return new Rt(!0).update(Ct)[ft]()}},ct=function(){var ft=ut("hex");l&&(ft=dt(ft)),ft.create=function(){return new Rt},ft.update=function(Dt){return ft.create().update(Dt)};for(var Ct=0;Ct<te.length;++Ct){var Mt=te[Ct];ft[Mt]=ut(Mt)}return ft},dt=function(ft){var Ct=require$$1,Mt=require$$1.Buffer,Dt;Mt.from&&!a.JS_MD5_NO_BUFFER_FROM?Dt=Mt.from:Dt=function(Wt){return new Mt(Wt)};var Vt=function(Wt){if(typeof Wt=="string")return Ct.createHash("md5").update(Wt,"utf8").digest("hex");if(Wt==null)throw new Error(t);return Wt.constructor===ArrayBuffer&&(Wt=new Uint8Array(Wt)),at(Wt)||ot(Wt)||Wt.constructor===Mt?Ct.createHash("md5").update(Dt(Wt)).digest("hex"):ft(Wt)};return Vt},pt=function(ft){return function(Ct,Mt){return new yt(Ct,!0).update(Mt)[ft]()}},mt=function(){var ft=pt("hex");ft.create=function(Dt){return new yt(Dt)},ft.update=function(Dt,Vt){return ft.create(Dt).update(Vt)};for(var Ct=0;Ct<te.length;++Ct){var Mt=te[Ct];ft[Mt]=pt(Mt)}return ft};function Rt(ft){if(ft)rt[0]=rt[16]=rt[1]=rt[2]=rt[3]=rt[4]=rt[5]=rt[6]=rt[7]=rt[8]=rt[9]=rt[10]=rt[11]=rt[12]=rt[13]=rt[14]=rt[15]=0,this.blocks=rt,this.buffer8=st;else if(d){var Ct=new ArrayBuffer(68);this.buffer8=new Uint8Array(Ct),this.blocks=new Uint32Array(Ct)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}Rt.prototype.update=function(ft){if(this.finalized)throw new Error(n);var Ct=lt(ft);ft=Ct[0];for(var Mt=Ct[1],Dt,Vt=0,Wt,$t=ft.length,Ft=this.blocks,Ht=this.buffer8;Vt<$t;){if(this.hashed&&(this.hashed=!1,Ft[0]=Ft[16],Ft[16]=Ft[1]=Ft[2]=Ft[3]=Ft[4]=Ft[5]=Ft[6]=Ft[7]=Ft[8]=Ft[9]=Ft[10]=Ft[11]=Ft[12]=Ft[13]=Ft[14]=Ft[15]=0),Mt)if(d)for(Wt=this.start;Vt<$t&&Wt<64;++Vt)Dt=ft.charCodeAt(Vt),Dt<128?Ht[Wt++]=Dt:Dt<2048?(Ht[Wt++]=192|Dt>>>6,Ht[Wt++]=128|Dt&63):Dt<55296||Dt>=57344?(Ht[Wt++]=224|Dt>>>12,Ht[Wt++]=128|Dt>>>6&63,Ht[Wt++]=128|Dt&63):(Dt=65536+((Dt&1023)<<10|ft.charCodeAt(++Vt)&1023),Ht[Wt++]=240|Dt>>>18,Ht[Wt++]=128|Dt>>>12&63,Ht[Wt++]=128|Dt>>>6&63,Ht[Wt++]=128|Dt&63);else for(Wt=this.start;Vt<$t&&Wt<64;++Vt)Dt=ft.charCodeAt(Vt),Dt<128?Ft[Wt>>>2]|=Dt<<S[Wt++&3]:Dt<2048?(Ft[Wt>>>2]|=(192|Dt>>>6)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt&63)<<S[Wt++&3]):Dt<55296||Dt>=57344?(Ft[Wt>>>2]|=(224|Dt>>>12)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt>>>6&63)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt&63)<<S[Wt++&3]):(Dt=65536+((Dt&1023)<<10|ft.charCodeAt(++Vt)&1023),Ft[Wt>>>2]|=(240|Dt>>>18)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt>>>12&63)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt>>>6&63)<<S[Wt++&3],Ft[Wt>>>2]|=(128|Dt&63)<<S[Wt++&3]);else if(d)for(Wt=this.start;Vt<$t&&Wt<64;++Vt)Ht[Wt++]=ft[Vt];else for(Wt=this.start;Vt<$t&&Wt<64;++Vt)Ft[Wt>>>2]|=ft[Vt]<<S[Wt++&3];this.lastByteIndex=Wt,this.bytes+=Wt-this.start,Wt>=64?(this.start=Wt-64,this.hash(),this.hashed=!0):this.start=Wt}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},Rt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var ft=this.blocks,Ct=this.lastByteIndex;ft[Ct>>>2]|=R[Ct&3],Ct>=56&&(this.hashed||this.hash(),ft[0]=ft[16],ft[16]=ft[1]=ft[2]=ft[3]=ft[4]=ft[5]=ft[6]=ft[7]=ft[8]=ft[9]=ft[10]=ft[11]=ft[12]=ft[13]=ft[14]=ft[15]=0),ft[14]=this.bytes<<3,ft[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},Rt.prototype.hash=function(){var ft,Ct,Mt,Dt,Vt,Wt,$t=this.blocks;this.first?(ft=$t[0]-680876937,ft=(ft<<7|ft>>>25)-271733879<<0,Dt=(-1732584194^ft&2004318071)+$t[1]-117830708,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt=(-271733879^Dt&(ft^-271733879))+$t[2]-1126478375,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct=(ft^Mt&(Dt^ft))+$t[3]-1316259209,Ct=(Ct<<22|Ct>>>10)+Mt<<0):(ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3,ft+=(Dt^Ct&(Mt^Dt))+$t[0]-680876936,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[1]-389564586,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[2]+606105819,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[3]-1044525330,Ct=(Ct<<22|Ct>>>10)+Mt<<0),ft+=(Dt^Ct&(Mt^Dt))+$t[4]-176418897,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[5]+1200080426,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[6]-1473231341,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[7]-45705983,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Dt^Ct&(Mt^Dt))+$t[8]+1770035416,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[9]-1958414417,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[10]-42063,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[11]-1990404162,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Dt^Ct&(Mt^Dt))+$t[12]+1804603682,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[13]-40341101,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[14]-1502002290,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[15]+1236535329,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[1]-165796510,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[6]-1069501632,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[11]+643717713,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[0]-373897302,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[5]-701558691,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[10]+38016083,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[15]-660478335,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[4]-405537848,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[9]+568446438,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[14]-1019803690,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[3]-187363961,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[8]+1163531501,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[13]-1444681467,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[2]-51403784,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[7]+1735328473,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[12]-1926607734,Ct=(Ct<<20|Ct>>>12)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[5]-378558,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[8]-2022574463,Dt=(Dt<<11|Dt>>>21)+ft<<0,Wt=Dt^ft,Mt+=(Wt^Ct)+$t[11]+1839030562,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Wt^Mt)+$t[14]-35309556,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[1]-1530992060,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[4]+1272893353,Dt=(Dt<<11|Dt>>>21)+ft<<0,Wt=Dt^ft,Mt+=(Wt^Ct)+$t[7]-155497632,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Wt^Mt)+$t[10]-1094730640,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[13]+681279174,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[0]-358537222,Dt=(Dt<<11|Dt>>>21)+ft<<0,Wt=Dt^ft,Mt+=(Wt^Ct)+$t[3]-722521979,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Wt^Mt)+$t[6]+76029189,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[9]-640364487,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[12]-421815835,Dt=(Dt<<11|Dt>>>21)+ft<<0,Wt=Dt^ft,Mt+=(Wt^Ct)+$t[15]+530742520,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Wt^Mt)+$t[2]-995338651,Ct=(Ct<<23|Ct>>>9)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[0]-198630844,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[7]+1126891415,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[14]-1416354905,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[5]-57434055,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[12]+1700485571,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[3]-1894986606,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[10]-1051523,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[1]-2054922799,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[8]+1873313359,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[15]-30611744,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[6]-1560198380,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[13]+1309151649,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[4]-145523070,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[11]-1120210379,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[2]+718787259,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[9]-343485551,Ct=(Ct<<21|Ct>>>11)+Mt<<0,this.first?(this.h0=ft+1732584193<<0,this.h1=Ct-271733879<<0,this.h2=Mt-1732584194<<0,this.h3=Dt+271733878<<0,this.first=!1):(this.h0=this.h0+ft<<0,this.h1=this.h1+Ct<<0,this.h2=this.h2+Mt<<0,this.h3=this.h3+Dt<<0)},Rt.prototype.hex=function(){this.finalize();var ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3;return f[ft>>>4&15]+f[ft&15]+f[ft>>>12&15]+f[ft>>>8&15]+f[ft>>>20&15]+f[ft>>>16&15]+f[ft>>>28&15]+f[ft>>>24&15]+f[Ct>>>4&15]+f[Ct&15]+f[Ct>>>12&15]+f[Ct>>>8&15]+f[Ct>>>20&15]+f[Ct>>>16&15]+f[Ct>>>28&15]+f[Ct>>>24&15]+f[Mt>>>4&15]+f[Mt&15]+f[Mt>>>12&15]+f[Mt>>>8&15]+f[Mt>>>20&15]+f[Mt>>>16&15]+f[Mt>>>28&15]+f[Mt>>>24&15]+f[Dt>>>4&15]+f[Dt&15]+f[Dt>>>12&15]+f[Dt>>>8&15]+f[Dt>>>20&15]+f[Dt>>>16&15]+f[Dt>>>28&15]+f[Dt>>>24&15]},Rt.prototype.toString=Rt.prototype.hex,Rt.prototype.digest=function(){this.finalize();var ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3;return[ft&255,ft>>>8&255,ft>>>16&255,ft>>>24&255,Ct&255,Ct>>>8&255,Ct>>>16&255,Ct>>>24&255,Mt&255,Mt>>>8&255,Mt>>>16&255,Mt>>>24&255,Dt&255,Dt>>>8&255,Dt>>>16&255,Dt>>>24&255]},Rt.prototype.array=Rt.prototype.digest,Rt.prototype.arrayBuffer=function(){this.finalize();var ft=new ArrayBuffer(16),Ct=new Uint32Array(ft);return Ct[0]=this.h0,Ct[1]=this.h1,Ct[2]=this.h2,Ct[3]=this.h3,ft},Rt.prototype.buffer=Rt.prototype.arrayBuffer,Rt.prototype.base64=function(){for(var ft,Ct,Mt,Dt="",Vt=this.array(),Wt=0;Wt<15;)ft=Vt[Wt++],Ct=Vt[Wt++],Mt=Vt[Wt++],Dt+=A[ft>>>2]+A[(ft<<4|Ct>>>4)&63]+A[(Ct<<2|Mt>>>6)&63]+A[Mt&63];return ft=Vt[Wt],Dt+=A[ft>>>2]+A[ft<<4&63]+"==",Dt};function yt(ft,Ct){var Mt,Dt=lt(ft);if(ft=Dt[0],Dt[1]){var Vt=[],Wt=ft.length,$t=0,Ft;for(Mt=0;Mt<Wt;++Mt)Ft=ft.charCodeAt(Mt),Ft<128?Vt[$t++]=Ft:Ft<2048?(Vt[$t++]=192|Ft>>>6,Vt[$t++]=128|Ft&63):Ft<55296||Ft>=57344?(Vt[$t++]=224|Ft>>>12,Vt[$t++]=128|Ft>>>6&63,Vt[$t++]=128|Ft&63):(Ft=65536+((Ft&1023)<<10|ft.charCodeAt(++Mt)&1023),Vt[$t++]=240|Ft>>>18,Vt[$t++]=128|Ft>>>12&63,Vt[$t++]=128|Ft>>>6&63,Vt[$t++]=128|Ft&63);ft=Vt}ft.length>64&&(ft=new Rt(!0).update(ft).array());var Ht=[],nr=[];for(Mt=0;Mt<64;++Mt){var Jt=ft[Mt]||0;Ht[Mt]=92^Jt,nr[Mt]=54^Jt}Rt.call(this,Ct),this.update(nr),this.oKeyPad=Ht,this.inner=!0,this.sharedMemory=Ct}yt.prototype=new Rt,yt.prototype.finalize=function(){if(Rt.prototype.finalize.call(this),this.inner){this.inner=!1;var ft=this.array();Rt.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(ft),Rt.prototype.finalize.call(this)}};var It=ct();It.md5=It,It.md5.hmac=mt(),c?e.exports=It:a.md5=It})()})(md5)),md5.exports}var md5Exports=requireMd5(),Type=(e=>(e.STRING="string",e.NUMBER="number",e.BOOLEAN="boolean",e.OBJECT="object",e))(Type||{});const bodyKey="TheRequestBody",defaultSchemaDescription="Request body content";function getHash(e){return md5Exports.md5(e).substring(0,16)}function deduplicateApiFunctions(e){const t=new Map;return e.map(n=>{const s=n.declaration.name,a=t.get(s)||0;let o=s;return a>0&&(o=`${s}_${a}`),t.set(s,a+1),{...n,declaration:{...n.declaration,name:o}}})}function isSchemaReference(e){return!!e&&"$ref"in e}function isSchemaObject(e){return!!e&&!("$ref"in e)}function getRequestBodySchema(e){if(!e?.content)return;const t=["application/json","application/json-patch+json","multipart/form-data","text/plain"];for(const s of t){const a=e.content[s]?.schema;if(a)return a}return Object.values(e.content).find(s=>s?.schema)?.schema}async function fetchApiFunctions(e){const t=e?.swaggerJsonUrl??DEFAULT_SWAGGER_JSON_URL,n=resolveApiOrigin(t)??resolveApiOrigin(DEFAULT_SWAGGER_JSON_URL),s=buildApiUrl(t,n);try{const a=await fetch(s);if(!a.ok)throw new Error("Failed to fetch Swagger spec");const o=await a.json(),l=[];for(const[c,d]of Object.entries(o.paths)){const f=["get","post","put","delete"];for(const R of f){const S=d[R];if(!S||S["x-allowed-for-chatbots"]!==!0)continue;const te=c.split("/").filter(Boolean);let A;te.length>0&&te[0].toLowerCase()==="v4"?A=te.length>1?te[1]:"api":A=te.length>0?te[0]:"api",A=A.replace(/[{}]/g,"");const rt=getHash(c),st=`${R}-${A.toLowerCase()}-${rt}`,it={},at=[];S.parameters?.forEach(Rt=>{const yt=Rt.schema?.type,It=yt==="integer"||yt==="number"?"number":yt==="boolean"?"boolean":"string";it[Rt.name]={type:It,description:Rt.description||`The ${Rt.name} parameter`},Rt.required&&at.push(Rt.name)});const ot=S.parameters?.filter(Rt=>Rt.in==="path").map(Rt=>Rt.name)||[];if((R==="post"||R==="put")&&S.requestBody){const Rt=getRequestBodySchema(S.requestBody),yt=S.requestBody.description||defaultSchemaDescription;if(Rt&&isSchemaReference(Rt)&&Rt.$ref.startsWith("#/components/schemas/")){const It=Rt.$ref.substring(21),ft=o.components.schemas[It],Ct=isSchemaObject(ft)?ft.properties:void 0,Mt=Ct?JSON.stringify(Ct):"Refer to API schema for details.";it[bodyKey]={type:"string",description:`${yt}. Must be a JSON string with these properties: ${Mt}`}}else it[bodyKey]={type:"string",description:yt};at.push(bodyKey)}const lt={name:st,description:S.description?`${S.summary}
|