randmarcomps 1.326.0 → 1.328.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.
@@ -63336,16 +63336,16 @@ function ManufacturerInventoryFinanceCard({
63336
63336
  ] }),
63337
63337
  /* @__PURE__ */ jsxs(CardContent, { className: "space-y-6", children: [
63338
63338
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
63339
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
63339
+ d !== 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
63340
63340
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Max Allowance" }),
63341
63341
  /* @__PURE__ */ jsx("span", { className: "font-bold", children: formatMoney(d) })
63342
63342
  ] }),
63343
63343
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
63344
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Current Funds" }),
63344
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Current value" }),
63345
63345
  /* @__PURE__ */ jsx("span", { className: "font-bold", children: formatMoney(f) })
63346
63346
  ] }),
63347
63347
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
63348
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Available Funds" }),
63348
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Available" }),
63349
63349
  /* @__PURE__ */ jsx(
63350
63350
  "span",
63351
63351
  {
@@ -63355,7 +63355,7 @@ function ManufacturerInventoryFinanceCard({
63355
63355
  )
63356
63356
  ] })
63357
63357
  ] }),
63358
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
63358
+ d !== 0 && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
63359
63359
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
63360
63360
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Budget Usage" }),
63361
63361
  /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip$1, { children: [
@@ -77046,7 +77046,9 @@ function ProductImage({ randmarSKU: t, size: e = "md", alt: n, secondaryContent:
77046
77046
  }
77047
77047
  }
77048
77048
  function F() {
77049
- q && (navigator.clipboard.writeText(q), g(!0), setTimeout(() => g(!1), 2e3));
77049
+ navigator.clipboard.writeText(
77050
+ `https://api.randmar.io/Product/${t}/Video`
77051
+ ), g(!0), setTimeout(() => g(!1), 2e3);
77050
77052
  }
77051
77053
  function te() {
77052
77054
  O && d(!0);
@@ -1079,7 +1079,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const o="<p>An err
1079
1079
  - less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
1080
1080
  - \`null\` or \`undefined\` if the progress is indeterminate.
1081
1081
 
1082
- Defaulting to \`null\`.`}var Root=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:t,value:e,...n},o)=>jsxRuntime.jsx(Root,{ref:o,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(e||0)}%)`}})}));Progress.displayName=Root.displayName;function ManufacturerInventoryFinanceCard({manufacturer:t,isLoading:e}){const{data:n,isLoading:o,isFetching:l}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(t==null?void 0:t.ManufacturerId)??""},{skip:!(t!=null&&t.ManufacturerId)}),d=(t==null?void 0:t.DefaultMaxInventoryValue)??0,f=(n||[]).reduce((_,S)=>_+(S.InventoryValue||0),0),g=d-f,b=Math.round(f/d*100);return e||o||l?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:[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(d)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current Funds"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(f)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Funds"}),jsxRuntime.jsx("span",{className:`font-bold ${g>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(g)})]})]}),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:[b,"%"]}),b>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:b,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:t,isLoading:e}){const n=(t==null?void 0:t.CreditLimit)??0,o=(t==null?void 0:t.OutstandingBalance)??0,l=n-o,d=Math.round(o/n*100);return e?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(o)})]}),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 ${l>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(l)})]})]}),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:[d,"%"]}),d>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:d,className:"h-2"})]})]})]})}function SalesChartCard({statistics:t,loading:e=!1,mode:n="month",chartHeight:o=300,className:l,size:d="default"}){return e?jsxRuntime.jsxs(Card,{className:cn("w-full",l),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:o},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),d==="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",l),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:t,mode:n,chartHeight:o,size:d})})]})}function ManufacturerOverviewPage({applicationId:t,readonly:e,withReports:n,manufacturer:o,userEmail:l}){const{data:d,isLoading:f,isError:g}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:t,withSpecification:!0},{skip:!!o}),[b,_]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),S=React.useCallback(()=>e?!1:b.publicInfo.hasUnsavedChanges||b.qualifications.hasUnsavedChanges||b.billingInfo.hasUnsavedChanges,[e,b]),R=React.useCallback((A,M)=>{_(I=>{var j;return((j=I[A])==null?void 0:j.hasUnsavedChanges)!==M.hasUnsavedChanges?(console.log(`Updating form state for ${A}:`,M.hasUnsavedChanges),{...I,[A]:M}):I})},[]),{NavigationGuardDialog:C}=useRouterNavigationGuard(S),E=o??d;return jsxRuntime.jsxs("div",{className:"@container",children:[g?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:E==null?void 0:E.FiscalYearMonthStart,salesData:E==null?void 0:E.SalesData,isLoading:f}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(E==null?void 0:E.SalesStatistics)??[],loading:f}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",activeOrders:(E==null?void 0:E.ActiveOrderDetails)??void 0,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:E??{},onSave:()=>{},loading:f,readonly:e}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("publicInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:E,readonly:e,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("billingInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("qualifications",{hasUnsavedChanges:A})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",userEmail:l,isLoading:f})]}),jsxRuntime.jsx(C,{})]})}function ManufacturerCategories({categories:t,activeCategory:e,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsx("div",{className:"flex gap-2",children:t.map(o=>jsxRuntime.jsxs(Button,{onClick:()=>n(o.CategoryCode??""),variant:e===o.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[o.CategoryName??"Undefined",o.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${e!==o.CategoryCode?"text-red-500":""}`})]},o.CategoryCode))})})})}function ManufacturerProducts({applicationId:t,manufacturer:e,shopifyHostName:n}){var I,j,q,z;const[o]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[l,d]=React.useState(((j=(I=e.Categories)==null?void 0:I[0])==null?void 0:j.CategoryCode)||""),[f,g]=React.useState(!1),[b,_]=React.useState(!1),{toast:S}=useToast(),{data:R,isLoading:C,isFetching:E}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t,manufacturerId:e.ManufacturerId,categoryCode:l??""},{skip:!e.ManufacturerId||!l}),A=async()=>{try{g(!0),_(!1),await o({routeResellerId:t,manufacturerId:e.ManufacturerId??"",categoryCode:l,shopifyHostName:n}).unwrap()&&S({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(Q){console.error("Error syncing to Shopify:",Q),S({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{g(!1)}},M=()=>{var Q,F;return((F=(Q=e.Categories)==null?void 0:Q.find(V=>V.CategoryCode===l))==null?void 0:F.CategoryName)||l};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(ManufacturerCategories,{categories:e.Categories||[],activeCategory:l,onSelectCategory:d}),n&&((q=e.Categories)==null?void 0:q.findIndex(Q=>Q.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:b,onOpenChange:_,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 mb-4",disabled:f,children:f?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(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 "',M(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:A,disabled:f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:C||E?Array.from({length:4}).map((Q,F)=>jsxRuntime.jsx(ProductCard,{},F)):R!=null&&R.Products&&(R==null?void 0:R.Products.length)>0?(z=[...R.Products].sort((Q,F)=>{const V=Q.OverallPercentileRank??0;return(F.OverallPercentileRank??0)-V}))==null?void 0:z.map(Q=>jsxRuntime.jsx(ProductCard,{applicationId:t,product:Q,viewProductLink:`/${t}/Product/${Q.RandmarSKU}`,shopifyHostname:n},Q.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})})]})}function PartnerRelationshipPage({applicationId:t,partnerId:e,userEmail:n,shopifyHostName:o,isSuperAdmin:l}){var j,q,z;const{data:d,isLoading:f,isFetching:g}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:t,partnerId:e,withSpecification:!0}),b=f||g,{toast:_}=useToast(),[S]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[R,C]=React.useState(!1),[E,A]=React.useState(!1),M=async()=>{try{C(!0),A(!1),await S({routeResellerId:t??"",manufacturerId:e??"",shopifyHostName:o}).unwrap()&&_({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(Q){console.error("Error syncing to Shopify:",Q),_({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{C(!1)}},I=()=>d!=null&&d.Reseller?"reseller-overview":d!=null&&d.Manufacturer?"manufacturer-overview":"";return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:d,loading:b,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((d==null?void 0:d.Manufacturer)||b)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:d==null?void 0:d.Manufacturer,loading:b,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:t,manufacturer:d==null?void 0:d.Manufacturer}),o&&((q=(j=d==null?void 0:d.Manufacturer)==null?void 0:j.Categories)==null?void 0:q.findIndex(Q=>Q.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:E,onOpenChange:A,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:R,children:R?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 "',(z=d==null?void 0:d.Manufacturer)==null?void 0:z.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:M,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:d==null?void 0:d.Reseller,loading:b})]})]}),((d==null?void 0:d.Reseller)||(d==null?void 0:d.Manufacturer))&&!b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:I(),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:[(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(d==null?void 0:d.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"})]}),(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:d.ApplicationId||"",reseller:d==null?void 0:d.Reseller,userEmail:n,isSuperAdmin:l,withoutReports:!0})})}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:d==null?void 0:d.Manufacturer,applicationId:t,userEmail:n})})}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:t,manufacturer:d.Manufacturer,shopifyHostName:o})})})]})}),b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:t,appID:e,isLoading:n,readonly:o,onUnsavedChanges:l})=>{const{toast:d}=useToast(),[f]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[g,b]=React.useState({}),_=React.useMemo(()=>({publicEmail:t.PublicEmail??"",contactName:t.ContactName??"",phone:t.Phone??"",website:t.Website??""}),[t]),{register:S,handleSubmit:R,reset:C,watch:E,formState:{errors:A,isSubmitting:M}}=useForm({defaultValues:_}),I=E(),j=React.useCallback(()=>g?JSON.stringify(I)!==JSON.stringify(g):!1,[I,g]);React.useEffect(()=>{l&&l(j())},[j,l]),React.useEffect(()=>{t&&Object.keys(t).length>0&&(C(_),b(_))},[t,C,_]);const q=async Q=>{let F=!0,V=!1;const te=Object.keys(Q).map(ne=>({key:ne,keyApi:ne.charAt(0).toUpperCase()+ne.slice(1)}));for(const ne of te){const se=Q[ne.key],ge=t[ne.keyApi];if(se!==ge&&se!==void 0){V=!0;try{await f({applicationId:e,fieldName:ne.keyApi,newValue:String(se)}).unwrap()||(F=!1)}catch(oe){console.error(`Error updating ${ne.keyApi}:`,oe),F=!1}}}F&&V?(d({title:"Public info",description:"Information updated successfully",variant:"success"}),b({...Q}),l&&l(!1)):F||d({title:"Updation error",description:"Failed to update",variant:"destructive"})},z=Q=>!Q||Q.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 ",o?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(z(E("contactName"))||z(E("publicEmail"))||z(E("website"))||z(E("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:R(q),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:o,...S("contactName",{}),className:A.contactName||z(E("contactName"))?"input-error-indicator":""}),A.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:A.publicEmail||z(E("publicEmail"))?"input-error-indicator":""}),A.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.website||z(E("website"))?"input-error-indicator":""}),A.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.phone||z(E("phone"))?"input-error-indicator":""}),A.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:M||o,className:o?"hidden":"",children:M?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:t,reseller:e,isLoading:n,withoutReports:o,userEmail:l}){const{toast:d}=useToast(),{Statement:f,CreditLimit:g}=e,[b,_]=React.useState(!1),[S,R]=React.useState(!1),[C,E]=React.useState(!1),[A,M]=React.useState(!1),[I,j]=React.useState(!1),[q,z]=React.useState(l||""),Q=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsx(FormattedNumber,{value:g||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CreditCard}],[F]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),V=async ge=>{_(!1),ge?R(!0):E(!0);let oe="";try{const je=(await F({routeResellerId:t,documentNumber:`ST${t}`})).data;if(!je.url||!je.filename)throw new Error("No data received for download.");if(oe=je.url,ge)window.open(oe);else{const Ne=document.createElement("a");Ne.href=oe,Ne.download=je.filename,document.body.appendChild(Ne),Ne.click(),Ne.remove()}d({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Ae){console.error("Download Error:",Ae),d({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{ge?R(!1):E(!1),oe&&setTimeout(()=>{window.URL.revokeObjectURL(oe)},1e3)}},[te]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),ne=async()=>{if(!q||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(q)){d({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}M(!0);try{await te({routeResellerId:t,emailAddress:q}).unwrap(),d({title:"Success",description:`Statement sent to ${q} successfully.`,variant:"success"}),j(!1)}catch(oe){console.error("Send Email Error:",oe),d({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{M(!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(ge=>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"})]},ge))}),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(ge=>jsxRuntime.jsx("div",{className:ge===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"})]})},ge))})]}),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 se=!o;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:Q.slice(0,3).map((ge,oe)=>jsxRuntime.jsx(BillingItem,{icon:ge.icon,label:ge.label,value:ge.value},oe))}),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:Q.slice(3).map((ge,oe)=>jsxRuntime.jsx("div",{className:oe===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:ge.icon,label:ge.label,value:ge.value})},oe))})]}),se&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsxs(DropdownMenu,{open:b,onOpenChange:_,children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"outline",disabled:S||C,children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Printing..."]}):C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Downloading..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FileText,{className:"mr-2 h-4 w-4"}),"Statement",jsxRuntime.jsx(ChevronDown,{className:"ml-2 h-4 w-4"})]})})}),jsxRuntime.jsxs(DropdownMenuContent,{align:"end",children:[jsxRuntime.jsxs(DropdownMenuItem,{onClick:()=>V(!0),disabled:S,children:[jsxRuntime.jsx(Printer,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Print"})]}),jsxRuntime.jsx(DropdownMenuSeparator,{}),jsxRuntime.jsxs(DropdownMenuItem,{onClick:()=>V(!1),disabled:C,children:[jsxRuntime.jsx(Download,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Download"})]}),jsxRuntime.jsx(DropdownMenuSeparator,{}),jsxRuntime.jsxs(DropdownMenuItem,{onSelect:()=>j(!0),children:[jsxRuntime.jsx(Mail,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Send by Email"})]})]})]}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${t}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:I,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:q,onChange:ge=>z(ge.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",onClick:ne,disabled:A||!q,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"]})})})]})})]})}function BillingItem({icon:t,label:e,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(t,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:e})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:t,setOpen:e,tier:n,onTierChange:o,isLoading:l}){const d=()=>{e(!1)};return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,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,{variant:"outline",onClick:d,disabled:l,children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:o,disabled:l,children:l?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=t=>t===1?"The Best":t===2?"Fixed 12.5% GP on all items":t===3?"Advantageous":t===4?"Buying Group":t===5?"Cost":t,getShippingText=t=>t==="A"?"Free or Custom":t==="B"?"Fixed $10 anywhere":t==="C"?`Free shipping on $150+ orders to your location,
1082
+ Defaulting to \`null\`.`}var Root=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:t,value:e,...n},o)=>jsxRuntime.jsx(Root,{ref:o,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(e||0)}%)`}})}));Progress.displayName=Root.displayName;function ManufacturerInventoryFinanceCard({manufacturer:t,isLoading:e}){const{data:n,isLoading:o,isFetching:l}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(t==null?void 0:t.ManufacturerId)??""},{skip:!(t!=null&&t.ManufacturerId)}),d=(t==null?void 0:t.DefaultMaxInventoryValue)??0,f=(n||[]).reduce((_,S)=>_+(S.InventoryValue||0),0),g=d-f,b=Math.round(f/d*100);return e||o||l?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:[d!==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(d)})]}),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(f)})]}),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 ${g>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(g)})]})]}),d!==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:[b,"%"]}),b>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:b>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:b,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:t,isLoading:e}){const n=(t==null?void 0:t.CreditLimit)??0,o=(t==null?void 0:t.OutstandingBalance)??0,l=n-o,d=Math.round(o/n*100);return e?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(o)})]}),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 ${l>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(l)})]})]}),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:[d,"%"]}),d>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:d,className:"h-2"})]})]})]})}function SalesChartCard({statistics:t,loading:e=!1,mode:n="month",chartHeight:o=300,className:l,size:d="default"}){return e?jsxRuntime.jsxs(Card,{className:cn("w-full",l),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:o},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),d==="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",l),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:t,mode:n,chartHeight:o,size:d})})]})}function ManufacturerOverviewPage({applicationId:t,readonly:e,withReports:n,manufacturer:o,userEmail:l}){const{data:d,isLoading:f,isError:g}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:t,withSpecification:!0},{skip:!!o}),[b,_]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),S=React.useCallback(()=>e?!1:b.publicInfo.hasUnsavedChanges||b.qualifications.hasUnsavedChanges||b.billingInfo.hasUnsavedChanges,[e,b]),R=React.useCallback((A,M)=>{_(I=>{var j;return((j=I[A])==null?void 0:j.hasUnsavedChanges)!==M.hasUnsavedChanges?(console.log(`Updating form state for ${A}:`,M.hasUnsavedChanges),{...I,[A]:M}):I})},[]),{NavigationGuardDialog:C}=useRouterNavigationGuard(S),E=o??d;return jsxRuntime.jsxs("div",{className:"@container",children:[g?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:E==null?void 0:E.FiscalYearMonthStart,salesData:E==null?void 0:E.SalesData,isLoading:f}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(E==null?void 0:E.SalesStatistics)??[],loading:f}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",activeOrders:(E==null?void 0:E.ActiveOrderDetails)??void 0,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:E,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:E??{},onSave:()=>{},loading:f,readonly:e}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("publicInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:E,readonly:e,isLoading:f}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("billingInfo",{hasUnsavedChanges:A})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:E,readonly:e,isLoading:f,onUnsavedChanges:A=>R("qualifications",{hasUnsavedChanges:A})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(E==null?void 0:E.ManufacturerId)??"",userEmail:l,isLoading:f})]}),jsxRuntime.jsx(C,{})]})}function ManufacturerCategories({categories:t,activeCategory:e,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsx("div",{className:"flex gap-2",children:t.map(o=>jsxRuntime.jsxs(Button,{onClick:()=>n(o.CategoryCode??""),variant:e===o.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[o.CategoryName??"Undefined",o.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${e!==o.CategoryCode?"text-red-500":""}`})]},o.CategoryCode))})})})}function ManufacturerProducts({applicationId:t,manufacturer:e,shopifyHostName:n}){var I,j,q,z;const[o]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[l,d]=React.useState(((j=(I=e.Categories)==null?void 0:I[0])==null?void 0:j.CategoryCode)||""),[f,g]=React.useState(!1),[b,_]=React.useState(!1),{toast:S}=useToast(),{data:R,isLoading:C,isFetching:E}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:t,manufacturerId:e.ManufacturerId,categoryCode:l??""},{skip:!e.ManufacturerId||!l}),A=async()=>{try{g(!0),_(!1),await o({routeResellerId:t,manufacturerId:e.ManufacturerId??"",categoryCode:l,shopifyHostName:n}).unwrap()&&S({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(Q){console.error("Error syncing to Shopify:",Q),S({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{g(!1)}},M=()=>{var Q,F;return((F=(Q=e.Categories)==null?void 0:Q.find(V=>V.CategoryCode===l))==null?void 0:F.CategoryName)||l};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(ManufacturerCategories,{categories:e.Categories||[],activeCategory:l,onSelectCategory:d}),n&&((q=e.Categories)==null?void 0:q.findIndex(Q=>Q.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:b,onOpenChange:_,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 mb-4",disabled:f,children:f?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(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 "',M(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:A,disabled:f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:C||E?Array.from({length:4}).map((Q,F)=>jsxRuntime.jsx(ProductCard,{},F)):R!=null&&R.Products&&(R==null?void 0:R.Products.length)>0?(z=[...R.Products].sort((Q,F)=>{const V=Q.OverallPercentileRank??0;return(F.OverallPercentileRank??0)-V}))==null?void 0:z.map(Q=>jsxRuntime.jsx(ProductCard,{applicationId:t,product:Q,viewProductLink:`/${t}/Product/${Q.RandmarSKU}`,shopifyHostname:n},Q.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})})]})}function PartnerRelationshipPage({applicationId:t,partnerId:e,userEmail:n,shopifyHostName:o,isSuperAdmin:l}){var j,q,z;const{data:d,isLoading:f,isFetching:g}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:t,partnerId:e,withSpecification:!0}),b=f||g,{toast:_}=useToast(),[S]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[R,C]=React.useState(!1),[E,A]=React.useState(!1),M=async()=>{try{C(!0),A(!1),await S({routeResellerId:t??"",manufacturerId:e??"",shopifyHostName:o}).unwrap()&&_({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(Q){console.error("Error syncing to Shopify:",Q),_({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{C(!1)}},I=()=>d!=null&&d.Reseller?"reseller-overview":d!=null&&d.Manufacturer?"manufacturer-overview":"";return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:d,loading:b,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((d==null?void 0:d.Manufacturer)||b)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:d==null?void 0:d.Manufacturer,loading:b,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:t,manufacturer:d==null?void 0:d.Manufacturer}),o&&((q=(j=d==null?void 0:d.Manufacturer)==null?void 0:j.Categories)==null?void 0:q.findIndex(Q=>Q.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:E,onOpenChange:A,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:R,children:R?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 "',(z=d==null?void 0:d.Manufacturer)==null?void 0:z.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{className:"bg-green-600 hover:bg-green-700",onClick:M,disabled:R,children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:d==null?void 0:d.Reseller,loading:b})]})]}),((d==null?void 0:d.Reseller)||(d==null?void 0:d.Manufacturer))&&!b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:I(),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:[(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(d==null?void 0:d.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"})]}),(d==null?void 0:d.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:d.ApplicationId||"",reseller:d==null?void 0:d.Reseller,userEmail:n,isSuperAdmin:l,withoutReports:!0})})}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:d==null?void 0:d.Manufacturer,applicationId:t,userEmail:n})})}),(d==null?void 0:d.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:t,manufacturer:d.Manufacturer,shopifyHostName:o})})})]})}),b&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:t,appID:e,isLoading:n,readonly:o,onUnsavedChanges:l})=>{const{toast:d}=useToast(),[f]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[g,b]=React.useState({}),_=React.useMemo(()=>({publicEmail:t.PublicEmail??"",contactName:t.ContactName??"",phone:t.Phone??"",website:t.Website??""}),[t]),{register:S,handleSubmit:R,reset:C,watch:E,formState:{errors:A,isSubmitting:M}}=useForm({defaultValues:_}),I=E(),j=React.useCallback(()=>g?JSON.stringify(I)!==JSON.stringify(g):!1,[I,g]);React.useEffect(()=>{l&&l(j())},[j,l]),React.useEffect(()=>{t&&Object.keys(t).length>0&&(C(_),b(_))},[t,C,_]);const q=async Q=>{let F=!0,V=!1;const te=Object.keys(Q).map(ne=>({key:ne,keyApi:ne.charAt(0).toUpperCase()+ne.slice(1)}));for(const ne of te){const se=Q[ne.key],ge=t[ne.keyApi];if(se!==ge&&se!==void 0){V=!0;try{await f({applicationId:e,fieldName:ne.keyApi,newValue:String(se)}).unwrap()||(F=!1)}catch(oe){console.error(`Error updating ${ne.keyApi}:`,oe),F=!1}}}F&&V?(d({title:"Public info",description:"Information updated successfully",variant:"success"}),b({...Q}),l&&l(!1)):F||d({title:"Updation error",description:"Failed to update",variant:"destructive"})},z=Q=>!Q||Q.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 ",o?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(z(E("contactName"))||z(E("publicEmail"))||z(E("website"))||z(E("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:R(q),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:o,...S("contactName",{}),className:A.contactName||z(E("contactName"))?"input-error-indicator":""}),A.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:A.publicEmail||z(E("publicEmail"))?"input-error-indicator":""}),A.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.website||z(E("website"))?"input-error-indicator":""}),A.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.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:o,...S("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:A.phone||z(E("phone"))?"input-error-indicator":""}),A.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:A.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button,{type:"submit",disabled:M||o,className:o?"hidden":"",children:M?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:t,reseller:e,isLoading:n,withoutReports:o,userEmail:l}){const{toast:d}=useToast(),{Statement:f,CreditLimit:g}=e,[b,_]=React.useState(!1),[S,R]=React.useState(!1),[C,E]=React.useState(!1),[A,M]=React.useState(!1),[I,j]=React.useState(!1),[q,z]=React.useState(l||""),Q=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(f==null?void 0:f.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsx(FormattedNumber,{value:g||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CreditCard}],[F]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),V=async ge=>{_(!1),ge?R(!0):E(!0);let oe="";try{const je=(await F({routeResellerId:t,documentNumber:`ST${t}`})).data;if(!je.url||!je.filename)throw new Error("No data received for download.");if(oe=je.url,ge)window.open(oe);else{const Ne=document.createElement("a");Ne.href=oe,Ne.download=je.filename,document.body.appendChild(Ne),Ne.click(),Ne.remove()}d({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Ae){console.error("Download Error:",Ae),d({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{ge?R(!1):E(!1),oe&&setTimeout(()=>{window.URL.revokeObjectURL(oe)},1e3)}},[te]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),ne=async()=>{if(!q||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(q)){d({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}M(!0);try{await te({routeResellerId:t,emailAddress:q}).unwrap(),d({title:"Success",description:`Statement sent to ${q} successfully.`,variant:"success"}),j(!1)}catch(oe){console.error("Send Email Error:",oe),d({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{M(!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(ge=>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"})]},ge))}),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(ge=>jsxRuntime.jsx("div",{className:ge===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"})]})},ge))})]}),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 se=!o;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:Q.slice(0,3).map((ge,oe)=>jsxRuntime.jsx(BillingItem,{icon:ge.icon,label:ge.label,value:ge.value},oe))}),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:Q.slice(3).map((ge,oe)=>jsxRuntime.jsx("div",{className:oe===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:ge.icon,label:ge.label,value:ge.value})},oe))})]}),se&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsxs(DropdownMenu,{open:b,onOpenChange:_,children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"outline",disabled:S||C,children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Printing..."]}):C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Downloading..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FileText,{className:"mr-2 h-4 w-4"}),"Statement",jsxRuntime.jsx(ChevronDown,{className:"ml-2 h-4 w-4"})]})})}),jsxRuntime.jsxs(DropdownMenuContent,{align:"end",children:[jsxRuntime.jsxs(DropdownMenuItem,{onClick:()=>V(!0),disabled:S,children:[jsxRuntime.jsx(Printer,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Print"})]}),jsxRuntime.jsx(DropdownMenuSeparator,{}),jsxRuntime.jsxs(DropdownMenuItem,{onClick:()=>V(!1),disabled:C,children:[jsxRuntime.jsx(Download,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Download"})]}),jsxRuntime.jsx(DropdownMenuSeparator,{}),jsxRuntime.jsxs(DropdownMenuItem,{onSelect:()=>j(!0),children:[jsxRuntime.jsx(Mail,{className:"mr-2 h-4 w-4"}),jsxRuntime.jsx("span",{children:"Send by Email"})]})]})]}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${t}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:I,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:q,onChange:ge=>z(ge.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",onClick:ne,disabled:A||!q,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"]})})})]})})]})}function BillingItem({icon:t,label:e,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(t,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:e})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:t,setOpen:e,tier:n,onTierChange:o,isLoading:l}){const d=()=>{e(!1)};return jsxRuntime.jsx(Dialog,{open:t,onOpenChange:e,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,{variant:"outline",onClick:d,disabled:l,children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:o,disabled:l,children:l?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=t=>t===1?"The Best":t===2?"Fixed 12.5% GP on all items":t===3?"Advantageous":t===4?"Buying Group":t===5?"Cost":t,getShippingText=t=>t==="A"?"Free or Custom":t==="B"?"Fixed $10 anywhere":t==="C"?`Free shipping on $150+ orders to your location,
1083
1083
  $15 for drop shipped orders under $1,500,
1084
1084
  $10 with opportunities under $1,000`:t==="D"?"$15 under $1,500":t==="E"?"Full shipping charges":t,getTermsText=t=>t==="STRIPE"?"Credit card payment":t==="NET30"?"Net 30 days":t,AccountTier=({isSuperAdmin:t,readonly:e,reseller:n,appID:o,isLoading:l})=>{const{toast:d}=useToast(),[f,g]=React.useState(!1),[b,_]=React.useState(""),[S,{isLoading:R}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),C=Oe=>Oe&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Oe]||"",E=Oe=>Oe&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Oe]||"",A=Oe=>Oe&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Oe]||"",[M,I]=React.useState(C((n==null?void 0:n.Priority)??"")),[j,q]=React.useState(E((n==null?void 0:n.ShippingProfile)??"")),[z,Q]=React.useState(A(n==null?void 0:n.PriceProfile)),F=Oe=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Oe]||Oe,V=Oe=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Oe]||Oe,te=Oe=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Oe]||Oe;React.useEffect(()=>{I(C((n==null?void 0:n.Priority)??"")),q(E((n==null?void 0:n.ShippingProfile)??"")),Q(A(n==null?void 0:n.PriceProfile))},[n]);const ne=async(Oe,Fe,ze,$e)=>{try{(await S({applicationId:o,fieldName:Oe,newValue:Fe})).error?d({title:"Error",description:$e,variant:"destructive"}):d({title:"Success",description:ze,variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},se=async Oe=>{I(Oe);const Fe=F(Oe);ne("Priority",Fe,`Priority updated to ${Fe}`,"Failed to update priority")},ge=async Oe=>{q(Oe);const Fe=V(Oe);ne("ShippingProfile",Fe,`Shipping profile updated to ${Fe}`,"Failed to update shipping profile")},oe=async Oe=>{Q(Oe);const Fe=te(Oe);ne("PriceProfile",Fe,`Pricing profile updated to ${Fe}`,"Failed to update pricing profile")},Ae=async()=>{try{const Oe=await S({applicationId:o,fieldName:"Tier",newValue:b});Oe.error?d({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Oe.data?d({title:"Success",description:`Pricing Tier changed to ${b}`,variant:"success"}):d({title:"Considered",description:"Request being considered",variant:"success"})}catch{d({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{g(!1),_("")}},je=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:t}],Ne=Oe=>{_(Oe),g(!0)};return l?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(Oe=>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"})]})]},Oe))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!e&&jsxRuntime.jsx(Button,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://www.randmar.io/docs/overview/pricingTiers",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,{disabled:e,className:e?"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"}),je.map(Oe=>jsxRuntime.jsx(Button,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Oe.enabled,onClick:()=>Ne(Oe.name),children:Oe.name},Oe.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:R,open:f,setOpen:g,tier:b,onTierChange:Ae}),t&&!e&&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:M,onValueChange:se,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:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`priority-${Oe.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.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:j,onValueChange:ge,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(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`shipping-${Oe.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.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:z,onValueChange:oe,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(Oe=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Oe.value,id:`pricing-${Oe.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Oe.value}`,className:"cursor-pointer text-xs",children:Oe.label})]},Oe.value))})]})]})})]})]})};function OrderCategories({openOrders:t=[],isLoading:e=!1}){const n=(t==null?void 0:t.filter(M=>M.DocumentType==="Order"))||[],o=(t==null?void 0:t.filter(M=>M.DocumentType==="Shipment"))||[],l=n.filter(M=>M.WarehouseCode!=="3PLE"),d=l.reduce((M,I)=>M+(I.Quantity??0),0),f=l.reduce((M,I)=>M+(I.ExtendedPrice??0),0),g=n.filter(M=>M.WarehouseCode==="3PLE"),b=g.reduce((M,I)=>M+(I.Quantity??0),0),_=g.reduce((M,I)=>M+(I.ExtendedPrice??0),0),S=o.reduce((M,I)=>M+(I.Quantity??0),0),R=o.reduce((M,I)=>M+(I.ExtendedPrice??0),0),C=d+b+S,E=f+_+R,A=[{name:"All",icon:Package,color:"bg-blue-500",orders:C,amount:E},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:d,amount:f},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:S,amount:R},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:b,amount:_}];return e?jsxRuntime.jsxs(Card,{className:"w-full @md:col-span-2 @xl:col-span-1",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(M=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-gray-200 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},M))})})]}):jsxRuntime.jsxs(Card,{className:"w-full @md:col-span-2 @xl:col-span-1",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:A.map(M=>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:`${M.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:M.name}),jsxRuntime.jsx("div",{className:`${M.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(M.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:M.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:M.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},M.name))})})]})}function ReportsSection({isLoading:t,userEmail:e,appID:n}){const{toast:o}=useToast(),[l,{isLoading:d}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[b,{isLoading:_}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[S,{isLoading:R}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[C,{isLoading:E}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[A,{isLoading:M}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[I,j]=React.useState(null),[q,z]=React.useState(e),[Q,F]=React.useState(!1),V=[{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}]}],te=async ge=>{j(ge),F(!0)},ne=async()=>{if(!(!I||!n))try{switch(I.id){case"Products":await S({routeResellerId:n,emailAddress:q}).unwrap();break;case"AmazonTrackingFile":await f({routeResellerId:n,emailAddress:q}).unwrap();break;case"WalmartTrackingFile":await l({routeResellerId:n,emailAddress:q}).unwrap();break;case"OpenOrders":await b({routeResellerId:n,emailAddress:q}).unwrap();break;case"Invoices":await C({routeResellerId:n,emailAddress:q}).unwrap();break;case"Statement":await A({routeResellerId:n,emailAddress:q}).unwrap();break;default:throw new Error("invalid report id")}o({title:"Report requested",description:`The ${I.title} will be sent to ${q} shortly.`,variant:"success"}),F(!1)}catch(ge){console.error("Error requesting report:",ge),o({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},se=_||R||g||d||M||E;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:t?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(oe=>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"})]},oe))]},ge))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:V.map(ge=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:ge.name}),ge.reports.map(oe=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(oe.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:oe.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:oe.description})]}),jsxRuntime.jsxs(Button,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>te(oe),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},oe.id))]},ge.name))})}),jsxRuntime.jsx(Dialog,{open:Q,onOpenChange:F,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",I==null?void 0:I.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:q,onChange:ge=>z(ge.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,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),jsxRuntime.jsx(Button,{onClick:ne,disabled:!q||se,children:se?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:t,variant:e,size:n,icon:o,children:l,...d},f)=>jsxRuntime.jsxs("div",{ref:f,className:cn(badgeVariants({variant:e,size:n}),t),...d,children:[o&&jsxRuntime.jsx("span",{className:"mr-1",children:o}),l]}));Badge.displayName="Badge";function QualificationBadge({qualification:t}){return!t.QualificationId||t.QualificationId==="Suspended"?null:t.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$1,{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:t.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),t.QualificationId,t.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:t.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:t,mode:e="month",chartHeight:n,loading:o=!1,size:l="default"}){const[d,f]=React.useState([]),[g,b]=React.useState(!1),_=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(o||!t){f([]);return}let S=[];if(e==="week"){const R=new Map;t.forEach(C=>{var A;const E=((A=C.Day)==null?void 0:A.toString())||"";if(E.length===8){const M=parseInt(E.substring(0,4),10),I=parseInt(E.substring(4,6),10)-1,j=parseInt(E.substring(6,8),10),q=new Date(M,I,j),z=new Date(q);z.setDate(q.getDate()-q.getDay());const Q=`${z.getFullYear()}-${String(z.getMonth()+1).padStart(2,"0")}-${String(z.getDate()).padStart(2,"0")}`,F=R.get(Q)||{price:0,quantity:0};F.price+=C.ExtendedPrice||0,F.quantity+=C.Quantity||0,R.set(Q,F)}}),S=Array.from(R).sort(([C],[E])=>C.localeCompare(E)).map(([C,E])=>({date:`${C.substring(5,7)}/${C.substring(8,10)}`,dollarVolume:E.price,unitsSold:E.quantity}))}else{const R=new Date,C=R.getFullYear(),E=R.getMonth(),A=R.getDate(),M=`${C}-${(E+1).toString().padStart(2,"0")}`,I=Array.from({length:12},(q,z)=>{const Q=new Date(C,E-(11-z),1);return`${Q.getFullYear()}-${(Q.getMonth()+1).toString().padStart(2,"0")}`}),j=Object.fromEntries(I.map(q=>[q,{price:0,quantity:0}]));if(t.forEach(q=>{const z=String(q.Day??0);if(z.length!==8)return;const Q=`${z.substring(0,4)}-${z.substring(4,6)}`;j[Q]&&(j[Q].price+=q.ExtendedPrice??0,j[Q].quantity+=q.Quantity??0)}),S=I.map(q=>{const z=j[q],[Q,F]=q.split("-").map(Number);return{date:new Date(Q,F-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:z.price,unitsSold:z.quantity}}),g){const q=j[M];if(q&&q.price>0&&A>0){const z=new Date(C,E+1,0).getDate();if(A<z){const Q=q.price/A,F=q.quantity/A,V=Q*z,te=F*z,ne=S[S.length-1];ne&&(ne.dollarVolume=V,ne.unitsSold=te)}}}}f(S)},[t,e,g,o]),o?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):d.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:d,series:_,height:n,size:l}),l==="default"&&e==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:g,onCheckedChange:b,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),g&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function ManufacturerCard({manufacturer:t,link:e,linkNewTab:n=!0,actions:o,mainAction:l,loading:d=!1}){var S,R,C;if(d||!t)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 f=t.ManufacturerId||"N/A",g=[t.City,t.Province,t.Country].filter(Boolean),b=g.length>0?g.join(", "):"",_=((S=t.Tags)==null?void 0:S.split(",").map(E=>E.trim()).filter(Boolean))||[];return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(reactRouterDom.Link,{to:e??"#",target:e&&n?"_blank":"_self",children:jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,width:48,height:48})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:"Manufacturer"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:f})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:t.PublicName||"N/A"}),t.Name&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t.Name}),b&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:b})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:t.SalesStatistics&&t.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:t.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:[(!!((R=t.Qualification)!=null&&R.QualificationId)&&((C=t.Qualification)==null?void 0:C.QualificationId)!=="Suspended"||!!t.OpenToWork||!!t.OnHold&&t.OnHold!==0||_.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:t.Qualification??{}}),!!t.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!t.OnHold&&t.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),_.map((E,A)=>jsxRuntime.jsx(Badge,{variant:"outline",children:E},A))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[t.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${t.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:t.Phone})]}),t.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${t.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:t.PublicEmail})]}),t.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:t.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:t.Website})]}),t.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:t.CurrencyCode})]})]})]}),t.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:t.SalesData.SalesYearToDay?formatMoney(t.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast3Months?formatMoney(t.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:t.SalesData.SalesLast30Days?formatMoney(t.SalesData.SalesLast30Days):"—"})]})]})}),(o||l||t.PublicResourcesLink)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[o&&o,t.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:t.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button,{size:"icon",children:jsxRuntime.jsx(HardDriveDownload,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),l&&jsxRuntime.jsx("div",{children:l})]})]})}function OrdersCard({applicationId:t,orders:e=null,loading:n=!1,title:o="Order Details"}){const l=React.useMemo(()=>[{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:g})=>g.original.DocumentNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${t}/Document/${g.original.DocumentNumber}`,className:"font-medium text-primary hover:underline",children:g.original.DocumentNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",g.original.DocumentNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:g})=>formatYYYYMMDDIntToDateString(g.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"OrderNumber",header:"Order Number",cell:({row:g})=>g.original.OrderNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"PONumber",header:"PO Number",cell:({row:g})=>g.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:g})=>g.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:g})=>g.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:g})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:g.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:g})=>g.original.UnitPrice?formatMoney(g.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1}],[t]),d=React.useMemo(()=>{const g={};if(e){const b=Array.from(new Set(e.map(E=>E.WarehouseCode).filter(E=>E!=null)));g.WarehouseCode=b;const _=Array.from(new Set(e.map(E=>E.ShipToName).filter(E=>E!=null)));g.ShipToName=_;const S=Array.from(new Set(e.map(E=>E.DocumentNumber).filter(E=>E!=null)));g.DocumentNumber=S;const R=Array.from(new Set(e.map(E=>E.OrderNumber).filter(E=>E!=null)));g.OrderNumber=R;const C=Array.from(new Set(e.map(E=>E.PONumber).filter(E=>E!=null)));g.PONumber=C}return g},[e]),f=e||[];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.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:o})," "]}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:l,data:f,uniqueValues:d})})]})}function ResellerOverview({appID:t,reseller:e,readonly:n,userEmail:o,isSuperAdmin:l,withoutReports:d=!1}){const{data:f,isLoading:g,isError:b}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:t??"",withSpecification:!0},{skip:!!e}),[_,S]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>n?!1:_.publicInfo.hasUnsavedChanges,[n,_]),C=React.useCallback((q,z)=>{S(Q=>{var F;return((F=Q[q])==null?void 0:F.hasUnsavedChanges)!==z.hasUnsavedChanges?{...Q,[q]:z}:Q})},[]),{NavigationGuardDialog:E}=useRouterNavigationGuard(R),A=e??f,M=!n||!!(A!=null&&A.Statement)&&(A.Statement.Total??0)>0,I=(A==null?void 0:A.QualifiedManufacturers)??[],j=(A==null?void 0:A.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[b?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:(A==null?void 0:A.FiscalYearMonthStart)||1,salesData:A==null?void 0:A.SalesData,isLoading:g}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(A==null?void 0:A.SalesStatistics)??[],loading:g}),jsxRuntime.jsx(OrderCategories,{openOrders:(A==null?void 0:A.ActiveOrderDetails)??[],isLoading:g}),M&&jsxRuntime.jsx(BillingCard,{appID:t,reseller:A||{},withoutReports:d,isLoading:g,userEmail:o}),jsxRuntime.jsx(PublicInfo,{reseller:A||{},appID:t??"",isLoading:g,readonly:n,onUnsavedChanges:q=>C("publicInfo",{hasUnsavedChanges:q})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:l,readonly:n,reseller:A||{},appID:t??"",isLoading:g})]}),g||I.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 @2xl:grid-cols-2 gap-4",children:g?Array.from({length:2}).map((q,z)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},z)):I.map(q=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:q,link:`https://dashboard.randmar.io/${t}/Partner/${q.ManufacturerId}`},q.ManufacturerId))})})]}):jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:j}),jsxRuntime.jsx(OpportunitiesTable,{applicationId:t,opportunities:A==null?void 0:A.Opportunities,loading:g}),jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Active Orders",orders:A==null?void 0:A.ActiveOrderDetails,loading:g}),jsxRuntime.jsx(OrdersCard,{applicationId:t,title:"Completed Orders",orders:A==null?void 0:A.CompletedOrderDetails,loading:g}),jsxRuntime.jsx(ReturnsTable,{applicationId:t,returns:A==null?void 0:A.Returns,loading:g}),!d&&jsxRuntime.jsx(ReportsSection,{appID:t,userEmail:o,isLoading:g})]}),jsxRuntime.jsx(E,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:t,variant:e,...n},o)=>jsxRuntime.jsx("div",{ref:o,role:"alert",className:cn(alertVariants({variant:e}),t),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",t),...e}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",t),...e}));AlertDescription.displayName="AlertDescription";/**
1085
1085
  * table-core
@@ -1140,7 +1140,7 @@ Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=1
1140
1140
  Use <ProductCard product={data} applicationId={applicationId}>`],basicComponents=["<Card> <CardHeader> <CardTitle>...</CardTitle> <CardDescription>...</CardDescription> </CardHeader> <CardContent> ... </CardContent> </Card>","<Badge>...</Badge>",'<Tabs defaultValue="eg1"> <TabsList> <TabsTrigger value="eg1">Example1</TabsTrigger> <TabsTrigger value="eg2">Example2</TabsTrigger> </TabsList> <TabsContent value="eg1"> ... </TabsContent> <TabsContent value="eg2"> ... </TabsContent> </Tabs>',"<ScrollArea>...</ScrollArea>","<ScrollArea orientation='horizontal'>...</ScrollArea>"],GetJSXFromAI=async(t,e,n,o,l=3)=>{const d="In addition to basic html tags, You have access to these beautiful Handmade Components. Try to use them even when you get an array of search results. For example, use ProductCard when ContentType is Product:",f="You also have access to these few Shadcn UI components:",g='Here is the data to display to the user (If a Handmade Component is a good fit for the data, use it. Otherwise, use regular html tags) (You have access to this data object in React via the data variable. Do not use JSON.parse, it is already parsed. For example, if data is an array, you can use {data.map(item, idx => <>...</>)} directly. CAUTION: when using map, you must use implicit return rather than a block body, as shown before. AGAIN: never use JSON.parse - data is already parsed and never a block body with arrow functions such as: (item => { return "EXAMPLE - DO NOT DO THIS" }):',b="Only output a single JSX code snippet. Start with <> and end with </>. All other code will be ignored, so make sure to place all CSS styles inline. Use CSS flex layouts when there is a lot of stuff to display.",_=JSON.stringify(n),S=[e,d,...complexComponents,f,...basicComponents,b,g,_,b].join(`\r
1141
1141
  `),E=await new GoogleGenAI({apiKey:t}).chats.create({model:o?"gemini-2.5-pro-preview-03-25":"gemini-2.0-flash-lite"}).sendMessage({message:S}),A=trimJSXString(E.text??"");return A&&!containsBlockArrowFunc(A)?A:l==0?"<p>Could not generate visuals for this data.</p>":await GetJSXFromAI(t,e,n,o,l-1)};function containsBlockArrowFunc(t){return t.replace(/\s+/g,"").indexOf("=>{")>=0}function trimJSXString(t){const e=t.indexOf("<"),n=t.lastIndexOf("</");return e===-1||n===-1?"":t.slice(e,t.indexOf(">",n)+1)}function AiGeneratedContent(t){const[e,n]=React.useState(""),{apiKey:o}=useGeminiApiKey();return React.useEffect(()=>{if(!o||!t.prompt||!t.data)return;n("");let l=!1;return GetJSXFromAI(o,t.prompt,t.data,t.smartAndSlow===!0).then(d=>{l||n(d)}),()=>{l=!0}},[t.prompt,t.data,n,o,t.smartAndSlow]),e?jsxRuntime.jsx(source_default,{bindings:{data:t.data},components:{ResellerCard,ManufacturerCard,PartnerCard,ProductCard,Card,CardHeader,CardTitle,CardContent,CardDescription,Badge,Tabs,TabsList,TabsContent,TabsTrigger,ScrollArea},jsx:e}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(Skeleton,{className:"h-32 w-32",children:jsxRuntime.jsx(Bot,{className:"m-auto align-middle h-full"})})})}var CHECKBOX_NAME="Checkbox",[createCheckboxContext,createCheckboxScope]=createContextScope(CHECKBOX_NAME),[CheckboxProviderImpl,useCheckboxContext]=createCheckboxContext(CHECKBOX_NAME);function CheckboxProvider(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:l,disabled:d,form:f,name:g,onCheckedChange:b,required:_,value:S="on",internal_do_not_use_render:R}=t,[C,E]=useControllableState({prop:n,defaultProp:l??!1,onChange:b,caller:CHECKBOX_NAME}),[A,M]=React__namespace.useState(null),[I,j]=React__namespace.useState(null),q=React__namespace.useRef(!1),z=A?!!f||!!A.closest("form"):!0,Q={checked:C,disabled:d,setChecked:E,control:A,setControl:M,name:g,form:f,value:S,hasConsumerStoppedPropagationRef:q,required:_,defaultChecked:isIndeterminate(l)?!1:l,isFormControl:z,bubbleInput:I,setBubbleInput:j};return jsxRuntime.jsx(CheckboxProviderImpl,{scope:e,...Q,children:isFunction$1(R)?R(Q):o})}var TRIGGER_NAME$3="CheckboxTrigger",CheckboxTrigger=React__namespace.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...o},l)=>{const{control:d,value:f,disabled:g,checked:b,required:_,setControl:S,setChecked:R,hasConsumerStoppedPropagationRef:C,isFormControl:E,bubbleInput:A}=useCheckboxContext(TRIGGER_NAME$3,t),M=useComposedRefs(l,S),I=React__namespace.useRef(b);return React__namespace.useEffect(()=>{const j=d==null?void 0:d.form;if(j){const q=()=>R(I.current);return j.addEventListener("reset",q),()=>j.removeEventListener("reset",q)}},[d,R]),jsxRuntime.jsx(Primitive.button,{type:"button",role:"checkbox","aria-checked":isIndeterminate(b)?"mixed":b,"aria-required":_,"data-state":getState$1(b),"data-disabled":g?"":void 0,disabled:g,value:f,...o,ref:M,onKeyDown:composeEventHandlers(e,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:composeEventHandlers(n,j=>{R(q=>isIndeterminate(q)?!0:!q),A&&E&&(C.current=j.isPropagationStopped(),C.current||j.stopPropagation())})})});CheckboxTrigger.displayName=TRIGGER_NAME$3;var Checkbox$1=React__namespace.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:o,checked:l,defaultChecked:d,required:f,disabled:g,value:b,onCheckedChange:_,form:S,...R}=t;return jsxRuntime.jsx(CheckboxProvider,{__scopeCheckbox:n,checked:l,defaultChecked:d,disabled:g,required:f,onCheckedChange:_,name:o,form:S,value:b,internal_do_not_use_render:({isFormControl:C})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(CheckboxTrigger,{...R,ref:e,__scopeCheckbox:n}),C&&jsxRuntime.jsx(CheckboxBubbleInput,{__scopeCheckbox:n})]})})});Checkbox$1.displayName=CHECKBOX_NAME;var INDICATOR_NAME="CheckboxIndicator",CheckboxIndicator=React__namespace.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...l}=t,d=useCheckboxContext(INDICATOR_NAME,n);return jsxRuntime.jsx(Presence,{present:o||isIndeterminate(d.checked)||d.checked===!0,children:jsxRuntime.jsx(Primitive.span,{"data-state":getState$1(d.checked),"data-disabled":d.disabled?"":void 0,...l,ref:e,style:{pointerEvents:"none",...t.style}})})});CheckboxIndicator.displayName=INDICATOR_NAME;var BUBBLE_INPUT_NAME$1="CheckboxBubbleInput",CheckboxBubbleInput=React__namespace.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:o,hasConsumerStoppedPropagationRef:l,checked:d,defaultChecked:f,required:g,disabled:b,name:_,value:S,form:R,bubbleInput:C,setBubbleInput:E}=useCheckboxContext(BUBBLE_INPUT_NAME$1,t),A=useComposedRefs(n,E),M=usePrevious(d),I=useSize(o);React__namespace.useEffect(()=>{const q=C;if(!q)return;const z=window.HTMLInputElement.prototype,F=Object.getOwnPropertyDescriptor(z,"checked").set,V=!l.current;if(M!==d&&F){const te=new Event("click",{bubbles:V});q.indeterminate=isIndeterminate(d),F.call(q,isIndeterminate(d)?!1:d),q.dispatchEvent(te)}},[C,M,d,l]);const j=React__namespace.useRef(isIndeterminate(d)?!1:d);return jsxRuntime.jsx(Primitive.input,{type:"checkbox","aria-hidden":!0,defaultChecked:f??j.current,required:g,disabled:b,name:_,value:S,form:R,...e,tabIndex:-1,ref:A,style:{...e.style,...I,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});CheckboxBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function isFunction$1(t){return typeof t=="function"}function isIndeterminate(t){return t==="indeterminate"}function getState$1(t){return isIndeterminate(t)?"indeterminate":t?"checked":"unchecked"}const Checkbox=React__namespace.forwardRef(({className:t,...e},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-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...e,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;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(t,e,n,o,l,d,f){if(d===e.length)return l===t.length?U:k$1;var g=`${l},${d}`;if(f[g]!==void 0)return f[g];for(var b=o.charAt(d),_=n.indexOf(b,l),S=0,R,C,E,A;_>=0;)R=G(t,e,n,o,_+1,d+1,f),R>S&&(_===l?R*=U:m.test(t.charAt(_-1))?(R*=H,E=t.slice(l,_-1).match(B$1),E&&l>0&&(R*=Math.pow(u,E.length))):K$1.test(t.charAt(_-1))?(R*=Y$1,A=t.slice(l,_-1).match(X),A&&l>0&&(R*=Math.pow(u,A.length))):(R*=J,l>0&&(R*=Math.pow(u,_-l))),t.charAt(_)!==e.charAt(d)&&(R*=$)),(R<p&&n.charAt(_-1)===o.charAt(d+1)||o.charAt(d+1)===o.charAt(d)&&n.charAt(_-1)!==o.charAt(d))&&(C=G(t,e,n,o,_+1,d+2,f),C*p>R&&(R=C*p)),R>S&&(S=R),_=n.indexOf(b,_+1);return f[g]=S,S}function D(t){return t.toLowerCase().replace(X," ")}function W(t,e,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,G(t,e,D(t),D(e),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=(t,e,n)=>W(t,e,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((t,e)=>{let n=L(()=>{var He,Ze;return{search:"",value:(Ze=(He=t.value)!=null?He:t.defaultValue)!=null?Ze:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),o=L(()=>new Set),l=L(()=>new Map),d=L(()=>new Map),f=L(()=>new Set),g=pe(t),{label:b,children:_,value:S,onValueChange:R,filter:C,shouldFilter:E,loop:A,disablePointerSelection:M=!1,vimBindings:I=!0,...j}=t,q=useId(),z=useId(),Q=useId(),F=React__namespace.useRef(null),V=ke();k(()=>{if(S!==void 0){let He=S.trim();n.current.value=He,te.emit()}},[S]),k(()=>{V(6,je)},[]);let te=React__namespace.useMemo(()=>({subscribe:He=>(f.current.add(He),()=>f.current.delete(He)),snapshot:()=>n.current,setState:(He,Ze,tt)=>{var Ye,Qe,Xe,st;if(!Object.is(n.current[He],Ze)){if(n.current[He]=Ze,He==="search")Ae(),ge(),V(1,oe);else if(He==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let rt=document.getElementById(Q);rt?rt.focus():(Ye=document.getElementById(q))==null||Ye.focus()}if(V(7,()=>{var rt;n.current.selectedItemId=(rt=Ne())==null?void 0:rt.id,te.emit()}),tt||V(5,je),((Qe=g.current)==null?void 0:Qe.value)!==void 0){let rt=Ze??"";(st=(Xe=g.current).onValueChange)==null||st.call(Xe,rt);return}}te.emit()}},emit:()=>{f.current.forEach(He=>He())}}),[]),ne=React__namespace.useMemo(()=>({value:(He,Ze,tt)=>{var Ye;Ze!==((Ye=d.current.get(He))==null?void 0:Ye.value)&&(d.current.set(He,{value:Ze,keywords:tt}),n.current.filtered.items.set(He,se(Ze,tt)),V(2,()=>{ge(),te.emit()}))},item:(He,Ze)=>(o.current.add(He),Ze&&(l.current.has(Ze)?l.current.get(Ze).add(He):l.current.set(Ze,new Set([He]))),V(3,()=>{Ae(),ge(),n.current.value||oe(),te.emit()}),()=>{d.current.delete(He),o.current.delete(He),n.current.filtered.items.delete(He);let tt=Ne();V(4,()=>{Ae(),(tt==null?void 0:tt.getAttribute("id"))===He&&oe(),te.emit()})}),group:He=>(l.current.has(He)||l.current.set(He,new Set),()=>{d.current.delete(He),l.current.delete(He)}),filter:()=>g.current.shouldFilter,label:b||t["aria-label"],getDisablePointerSelection:()=>g.current.disablePointerSelection,listId:q,inputId:Q,labelId:z,listInnerRef:F}),[]);function se(He,Ze){var tt,Ye;let Qe=(Ye=(tt=g.current)==null?void 0:tt.filter)!=null?Ye:Re;return He?Qe(He,n.current.search,Ze):0}function ge(){if(!n.current.search||g.current.shouldFilter===!1)return;let He=n.current.filtered.items,Ze=[];n.current.filtered.groups.forEach(Ye=>{let Qe=l.current.get(Ye),Xe=0;Qe.forEach(st=>{let rt=He.get(st);Xe=Math.max(rt,Xe)}),Ze.push([Ye,Xe])});let tt=F.current;Oe().sort((Ye,Qe)=>{var Xe,st;let rt=Ye.getAttribute("id"),at=Qe.getAttribute("id");return((Xe=He.get(at))!=null?Xe:0)-((st=He.get(rt))!=null?st:0)}).forEach(Ye=>{let Qe=Ye.closest(Y);Qe?Qe.appendChild(Ye.parentElement===Qe?Ye:Ye.closest(`${Y} > *`)):tt.appendChild(Ye.parentElement===tt?Ye:Ye.closest(`${Y} > *`))}),Ze.sort((Ye,Qe)=>Qe[1]-Ye[1]).forEach(Ye=>{var Qe;let Xe=(Qe=F.current)==null?void 0:Qe.querySelector(`${N}[${T}="${encodeURIComponent(Ye[0])}"]`);Xe==null||Xe.parentElement.appendChild(Xe)})}function oe(){let He=Oe().find(tt=>tt.getAttribute("aria-disabled")!=="true"),Ze=He==null?void 0:He.getAttribute(T);te.setState("value",Ze||void 0)}function Ae(){var He,Ze,tt,Ye;if(!n.current.search||g.current.shouldFilter===!1){n.current.filtered.count=o.current.size;return}n.current.filtered.groups=new Set;let Qe=0;for(let Xe of o.current){let st=(Ze=(He=d.current.get(Xe))==null?void 0:He.value)!=null?Ze:"",rt=(Ye=(tt=d.current.get(Xe))==null?void 0:tt.keywords)!=null?Ye:[],at=se(st,rt);n.current.filtered.items.set(Xe,at),at>0&&Qe++}for(let[Xe,st]of l.current)for(let rt of st)if(n.current.filtered.items.get(rt)>0){n.current.filtered.groups.add(Xe);break}n.current.filtered.count=Qe}function je(){var He,Ze,tt;let Ye=Ne();Ye&&(((He=Ye.parentElement)==null?void 0:He.firstChild)===Ye&&((tt=(Ze=Ye.closest(N))==null?void 0:Ze.querySelector(be))==null||tt.scrollIntoView({block:"nearest"})),Ye.scrollIntoView({block:"nearest"}))}function Ne(){var He;return(He=F.current)==null?void 0:He.querySelector(`${le}[aria-selected="true"]`)}function Oe(){var He;return Array.from(((He=F.current)==null?void 0:He.querySelectorAll(ce))||[])}function Fe(He){let Ze=Oe()[He];Ze&&te.setState("value",Ze.getAttribute(T))}function ze(He){var Ze;let tt=Ne(),Ye=Oe(),Qe=Ye.findIndex(st=>st===tt),Xe=Ye[Qe+He];(Ze=g.current)!=null&&Ze.loop&&(Xe=Qe+He<0?Ye[Ye.length-1]:Qe+He===Ye.length?Ye[0]:Ye[Qe+He]),Xe&&te.setState("value",Xe.getAttribute(T))}function $e(He){let Ze=Ne(),tt=Ze==null?void 0:Ze.closest(N),Ye;for(;tt&&!Ye;)tt=He>0?we(tt,N):De(tt,N),Ye=tt==null?void 0:tt.querySelector(ce);Ye?te.setState("value",Ye.getAttribute(T)):ze(He)}let Be=()=>Fe(Oe().length-1),qe=He=>{He.preventDefault(),He.metaKey?Be():He.altKey?$e(1):ze(1)},Ge=He=>{He.preventDefault(),He.metaKey?Fe(0):He.altKey?$e(-1):ze(-1)};return React__namespace.createElement(Primitive.div,{ref:e,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:He=>{var Ze;(Ze=j.onKeyDown)==null||Ze.call(j,He);let tt=He.nativeEvent.isComposing||He.keyCode===229;if(!(He.defaultPrevented||tt))switch(He.key){case"n":case"j":{I&&He.ctrlKey&&qe(He);break}case"ArrowDown":{qe(He);break}case"p":case"k":{I&&He.ctrlKey&&Ge(He);break}case"ArrowUp":{Ge(He);break}case"Home":{He.preventDefault(),Fe(0);break}case"End":{He.preventDefault(),Be();break}case"Enter":{He.preventDefault();let Ye=Ne();if(Ye){let Qe=new Event(Z);Ye.dispatchEvent(Qe)}}}}},React__namespace.createElement("label",{"cmdk-label":"",htmlFor:ne.inputId,id:ne.labelId,style:Te},b),B(t,He=>React__namespace.createElement(de.Provider,{value:te},React__namespace.createElement(ue.Provider,{value:ne},He))))}),he=React__namespace.forwardRef((t,e)=>{var n,o;let l=useId(),d=React__namespace.useRef(null),f=React__namespace.useContext(fe),g=K(),b=pe(t),_=(o=(n=b.current)==null?void 0:n.forceMount)!=null?o:f==null?void 0:f.forceMount;k(()=>{if(!_)return g.item(l,f==null?void 0:f.id)},[_]);let S=ve(l,d,[t.value,t.children,d],t.keywords),R=ee(),C=P(V=>V.value&&V.value===S.current),E=P(V=>_||g.filter()===!1?!0:V.search?V.filtered.items.get(l)>0:!0);React__namespace.useEffect(()=>{let V=d.current;if(!(!V||t.disabled))return V.addEventListener(Z,A),()=>V.removeEventListener(Z,A)},[E,t.onSelect,t.disabled]);function A(){var V,te;M(),(te=(V=b.current).onSelect)==null||te.call(V,S.current)}function M(){R.setState("value",S.current,!0)}if(!E)return null;let{disabled:I,value:j,onSelect:q,forceMount:z,keywords:Q,...F}=t;return React__namespace.createElement(Primitive.div,{ref:composeRefs(d,e),...F,id:l,"cmdk-item":"",role:"option","aria-disabled":!!I,"aria-selected":!!C,"data-disabled":!!I,"data-selected":!!C,onPointerMove:I||g.getDisablePointerSelection()?void 0:M,onClick:I?void 0:A},t.children)}),Ee=React__namespace.forwardRef((t,e)=>{let{heading:n,children:o,forceMount:l,...d}=t,f=useId(),g=React__namespace.useRef(null),b=React__namespace.useRef(null),_=useId(),S=K(),R=P(E=>l||S.filter()===!1?!0:E.search?E.filtered.groups.has(f):!0);k(()=>S.group(f),[]),ve(f,g,[t.value,t.heading,b]);let C=React__namespace.useMemo(()=>({id:f,forceMount:l}),[l]);return React__namespace.createElement(Primitive.div,{ref:composeRefs(g,e),...d,"cmdk-group":"",role:"presentation",hidden:R?void 0:!0},n&&React__namespace.createElement("div",{ref:b,"cmdk-group-heading":"","aria-hidden":!0,id:_},n),B(t,E=>React__namespace.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?_:void 0},React__namespace.createElement(fe.Provider,{value:C},E))))}),ye=React__namespace.forwardRef((t,e)=>{let{alwaysRender:n,...o}=t,l=React__namespace.useRef(null),d=P(f=>!f.search);return!n&&!d?null:React__namespace.createElement(Primitive.div,{ref:composeRefs(l,e),...o,"cmdk-separator":"",role:"separator"})}),Se=React__namespace.forwardRef((t,e)=>{let{onValueChange:n,...o}=t,l=t.value!=null,d=ee(),f=P(_=>_.search),g=P(_=>_.selectedItemId),b=K();return React__namespace.useEffect(()=>{t.value!=null&&d.setState("search",t.value)},[t.value]),React__namespace.createElement(Primitive.input,{ref:e,...o,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":b.listId,"aria-labelledby":b.labelId,"aria-activedescendant":g,id:b.inputId,type:"text",value:l?t.value:f,onChange:_=>{l||d.setState("search",_.target.value),n==null||n(_.target.value)}})}),Ce=React__namespace.forwardRef((t,e)=>{let{children:n,label:o="Suggestions",...l}=t,d=React__namespace.useRef(null),f=React__namespace.useRef(null),g=P(_=>_.selectedItemId),b=K();return React__namespace.useEffect(()=>{if(f.current&&d.current){let _=f.current,S=d.current,R,C=new ResizeObserver(()=>{R=requestAnimationFrame(()=>{let E=_.offsetHeight;S.style.setProperty("--cmdk-list-height",E.toFixed(1)+"px")})});return C.observe(_),()=>{cancelAnimationFrame(R),C.unobserve(_)}}},[]),React__namespace.createElement(Primitive.div,{ref:composeRefs(d,e),...l,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":g,"aria-label":o,id:b.listId},B(t,_=>React__namespace.createElement("div",{ref:composeRefs(f,b.listInnerRef),"cmdk-list-sizer":""},_)))}),xe=React__namespace.forwardRef((t,e)=>{let{open:n,onOpenChange:o,overlayClassName:l,contentClassName:d,container:f,...g}=t;return React__namespace.createElement(Root$8,{open:n,onOpenChange:o},React__namespace.createElement(Portal$4,{container:f},React__namespace.createElement(Overlay,{"cmdk-overlay":"",className:l}),React__namespace.createElement(Content$2,{"aria-label":t.label,"cmdk-dialog":"",className:d},React__namespace.createElement(me,{ref:e,...g}))))}),Ie=React__namespace.forwardRef((t,e)=>P(n=>n.filtered.count===0)?React__namespace.createElement(Primitive.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),Pe=React__namespace.forwardRef((t,e)=>{let{progress:n,children:o,label:l="Loading...",...d}=t;return React__namespace.createElement(Primitive.div,{ref:e,...d,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":l},B(t,f=>React__namespace.createElement("div",{"aria-hidden":!0},f)))}),_e=Object.assign(me,{List:Ce,Item:he,Input:Se,Group:Ee,Separator:ye,Dialog:xe,Empty:Ie,Loading:Pe});function we(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function De(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}function pe(t){let e=React__namespace.useRef(t);return k(()=>{e.current=t}),e}var k=typeof window>"u"?React__namespace.useEffect:React__namespace.useLayoutEffect;function L(t){let e=React__namespace.useRef();return e.current===void 0&&(e.current=t()),e}function P(t){let e=ee(),n=()=>t(e.snapshot());return React__namespace.useSyncExternalStore(e.subscribe,n,n)}function ve(t,e,n,o=[]){let l=React__namespace.useRef(),d=K();return k(()=>{var f;let g=(()=>{var _;for(let S of n){if(typeof S=="string")return S.trim();if(typeof S=="object"&&"current"in S)return S.current?(_=S.current.textContent)==null?void 0:_.trim():l.current}})(),b=o.map(_=>_.trim());d.value(t,g,b),(f=e.current)==null||f.setAttribute(T,g),l.current=g}),l}var ke=()=>{let[t,e]=React__namespace.useState(),n=L(()=>new Map);return k(()=>{n.current.forEach(o=>o()),n.current=new Map},[t]),(o,l)=>{n.current.set(o,l),e({})}};function Me(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function B({asChild:t,children:e},n){return t&&React__namespace.isValidElement(e)?React__namespace.cloneElement(Me(e),{ref:e.ref},n(e.props.children)):n(e)}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:t,...e},n)=>jsxRuntime.jsx(_e,{ref:n,className:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e}));Command.displayName=_e.displayName;const CommandDialog=({children:t,...e})=>jsxRuntime.jsx(Dialog,{...e,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:t})})}),CommandInput=React__namespace.forwardRef(({className:t,...e},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",t),...e})]}));CommandInput.displayName=_e.Input.displayName;const CommandList=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(_e.List,{ref:n,className:cn("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...e}));CommandList.displayName=_e.List.displayName;const CommandEmpty=React__namespace.forwardRef((t,e)=>jsxRuntime.jsx(_e.Empty,{ref:e,className:"py-6 text-center text-sm",...t}));CommandEmpty.displayName=_e.Empty.displayName;const CommandGroup=React__namespace.forwardRef(({className:t,...e},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",t),...e}));CommandGroup.displayName=_e.Group.displayName;const CommandSeparator=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(_e.Separator,{ref:n,className:cn("-mx-1 h-px bg-border",t),...e}));CommandSeparator.displayName=_e.Separator.displayName;const CommandItem=React__namespace.forwardRef(({className:t,...e},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",t),...e}));CommandItem.displayName=_e.Item.displayName;const CommandShortcut=({className:t,...e})=>jsxRuntime.jsx("span",{className:cn("ml-auto text-xs tracking-widest text-muted-foreground",t),...e});CommandShortcut.displayName="CommandShortcut";function GeneralDocumentCard({document:t,loading:e=!1}){return e?jsxRuntime.jsx("div",{children:"loading..."}):jsxRuntime.jsxs("div",{children:["GENERAL DOCUMENT CARD - ",t==null?void 0:t.OrderNumber," for P.O. ",t==null?void 0:t.PONumber]})}const Navbar=React.forwardRef(({routes:t,footer:e,dashboardTitle:n,withRandmarAssistant:o,chatUserName:l,appID:d},f)=>{const g=t.filter(C=>C.showInNav),b=React.useRef(null),_=React.useRef(null),S=React.useRef(null),{data:R}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsHasUnreadsQuery({routeApplicationId:d});return React.useImperativeHandle(f,()=>({setActiveChatAndSendMessage:(C,E)=>{var A;(A=S.current)==null||A.click(),setTimeout(()=>{var M;(M=b.current)==null||M.focus(),_.current&&_.current.setActiveChatAndSendMessage(C,E)},100)}})),jsxRuntime.jsxs(Sidebar,{className:"border-r border-sidebar-border",children:[jsxRuntime.jsx(SidebarHeader,{className:"border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx("img",{src:"https://api.randmar.io/images/RandmarIcon.svg",alt:"Randmar Icon",className:"h-4 w-4 filter brightness-0 saturate-100 invert"})}),jsxRuntime.jsx("span",{className:"font-semibold text-lg",children:n})]})}),jsxRuntime.jsx(SidebarContent,{className:"py-4 bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsx(SidebarMenu,{children:g.map(C=>{const E=C.icon,A=`/${C.path}`;return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:A,className:"transition-colors hover:bg-muted px-6",children:[E&&jsxRuntime.jsx(E,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:C.label})]})})},C.key)})})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar-background text-sidebar-foreground",children:[o===!0&&jsxRuntime.jsxs(Dialog,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:S,size:"lg",className:"collapse md:visible flex-grow",onClick:()=>setTimeout(()=>{var C;return(C=b.current)==null?void 0:C.focus()},50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),(R==null?void 0:R.HasUnreads)===!0&&jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{size:"icon",className:"pulse-glow bg-white hover:bg-gray-200 text-black collapse md:visible",onClick:()=>setTimeout(()=>{var C;return(C=b.current)==null?void 0:C.focus()},50),children:jsxRuntime.jsx(MessageSquare,{className:"h-5 w-5"})})})]}),jsxRuntime.jsx(DialogContent,{className:"max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,children:jsxRuntime.jsx(ChatLayout,{className:"h-[85vh]",ref:_,inputRef:b,userId:d,userName:l??"Unknown user"})})]}),e]})]})}),Layout=React.forwardRef(({children:t,appID:e,rightMenu:n,routes:o,footer:l,handleValidSearch:d,dashboardTitle:f,onSignOut:g,searchPlaceholder:b,withRandmarAssistant:_,chatUserName:S,chatRef:R},C)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{appID:e,routes:o,footer:l,dashboardTitle:f,withRandmarAssistant:_,chatUserName:S,ref:R}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col",children:[jsxRuntime.jsx(Topbar,{ref:C,onSignOut:g,rightMenu:n,handleValidSearch:d,searchPlaceholder:b}),jsxRuntime.jsx("main",{className:"flex-1 mt-16",children:t}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const salesChannels=[{id:"online-store",label:"Online store (Shopify, Amazon, etc.)"},{id:"brick-and-mortar",label:"Brick-and-mortar (Physical Store)"},{id:"marketplace",label:"Marketplace seller (eBay, Walmart, etc.)"},{id:"b2b",label:"B2B wholesale"},{id:"other-channel",label:"Other (please specify)"}],markets=[{id:"canada",label:"Canada - Nationwide"},{id:"ontario",label:"Ontario & Quebec"},{id:"atlantic",label:"Atlantic Provinces (NS, NB, PEI, NL)"},{id:"prairie",label:"Prairie (Saskatchewan, Manitoba)"},{id:"western",label:"Western Provinces (BC, Alberta, etc.)"},{id:"united-states",label:"United States"},{id:"other-market",label:"Other (please specify)"}];function ManufacturerGetStartedButton({applicationId:t,manufacturer:e}){const{toast:n}=useToast(),[o,l]=React.useState(!1),[d,f]=React.useState(!1),[g,b]=React.useState(!1),[_,S]=React.useState(""),[R,C]=React.useState(""),[E,A]=React.useState(!1),[M,I]=React.useState(""),[j,q]=React.useState(""),[z,Q]=React.useState([]),[F,V]=React.useState(""),[te,ne]=React.useState(""),[se,ge]=React.useState([]),[oe,Ae]=React.useState(""),[je,Ne]=React.useState(""),[Oe]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),{sendMessage:Fe}=useChat(),ze=()=>{S(""),C("")},$e=()=>{I(""),q(""),Q([]),V(""),ne(""),ge([]),Ae(""),Ne("")},Be=()=>{e.PartnerRegistrationLink?l(!0):e.OpenToWork&&f(!0)},qe=Qe=>{if(Qe.preventDefault(),!g){if(!_.trim()){C("Qualification ID is required");return}b(!0),Oe({routeApplicationId:t,partnerId:e.ManufacturerId??"",message:`Hello! I'd like to get started with you. Here's my Qualification ID: ${_}`}).then(Xe=>{var rt;if(Xe.error){console.error(Xe.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}const st=(rt=Xe.data)==null?void 0:rt.ConversationId;st&&Fe(st)?(l(!1),ze()):n({title:"Could not send message",description:"Try again later.",variant:"destructive"})}).catch(Xe=>{console.error(Xe),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{b(!1)})}},Ge=Qe=>{if(Qe.preventDefault(),E)return;q(""),V(""),Ae("");let Xe=!1;if(M.trim().length<10&&(q("Please provide a brief description of your business (minimum 10 characters)"),Xe=!0),z.length===0&&(V("Please select at least one sales channel"),Xe=!0),se.length===0&&(Ae("Please select at least one market"),Xe=!0),Xe)return;const st=salesChannels.filter(ot=>z.includes(ot.id)).map(ot=>ot.label);te&&st.push(`Other: ${te}`);const rt=markets.filter(ot=>se.includes(ot.id)).map(ot=>ot.label);je&&rt.push(`Other: ${je}`);const at=["Hello! I'd like to introduce my business:",`**Business Description:** ${M}`,`**Sales Channels:** ${st.join(", ")}`,`**Markets:** ${rt.join(", ")}`].join(`
1142
1142
 
1143
- `);A(!0),Oe({routeApplicationId:t,partnerId:e.ManufacturerId??"",message:at}).then(ot=>{var Ct;if(ot.error){console.error(ot.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}const Ue=(Ct=ot.data)==null?void 0:Ct.ConversationId;Ue&&Fe(Ue)?(f(!1),$e()):n({title:"Could not send message",description:"Try again later.",variant:"destructive"})}).catch(ot=>{console.error(ot),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{A(!1)})},He=(Qe,Xe)=>{Q(st=>Xe?[...st,Qe]:st.filter(rt=>rt!==Qe)),V("")},Ze=(Qe,Xe)=>{ge(st=>Xe?[...st,Qe]:st.filter(rt=>rt!==Qe)),Ae("")},tt=z.includes("other-channel"),Ye=se.includes("other-market");return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!e.Qualification&&jsxRuntime.jsxs(Button,{onClick:Be,disabled:!e.PartnerRegistrationLink&&!e.OpenToWork,children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Get Started"]}),e.PartnerRegistrationLink&&jsxRuntime.jsx(Dialog,{open:o,onOpenChange:Qe=>{l(Qe)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[400px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:e.PublicName}),jsxRuntime.jsxs(DialogDescription,{children:[jsxRuntime.jsx("span",{className:"font-bold",children:"Already qualified?"})," Provide your Qualification ID."]})]}),jsxRuntime.jsxs("form",{onSubmit:qe,className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"qualificationId",children:"Qualification ID"}),jsxRuntime.jsx(Input,{id:"qualificationId",placeholder:"Enter your qualification ID",value:_,onChange:Qe=>{S(Qe.target.value),C("")}}),R&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:R})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",className:"w-full",disabled:g,children:g?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Applying..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Apply for Qualification"]})})})]}),jsxRuntime.jsx(Separator$1,{className:"my-4"}),jsxRuntime.jsxs("div",{className:"text-center space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Don't have a qualification ID?"}),jsxRuntime.jsx(reactRouterDom.Link,{to:e.PartnerRegistrationLink,target:"_blank",children:jsxRuntime.jsxs(Button,{variant:"outline",className:"w-full",disabled:!e.PartnerRegistrationLink,children:[jsxRuntime.jsx(ExternalLink,{className:"mr-2 h-4 w-4"}),"Register here"]})})]})]})}),jsxRuntime.jsx(Dialog,{open:d,onOpenChange:Qe=>{f(Qe)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[768px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Introduce Yourself"})}),jsxRuntime.jsxs("form",{onSubmit:Ge,className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{htmlFor:"businessDescription",children:["Tell Us About Your Business ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Briefly describe your business)"})]}),jsxRuntime.jsx(Textarea,{id:"businessDescription",placeholder:"We are an online retailer specializing in office supplies, serving businesses since 2018...",className:"min-h-[100px]",value:M,onChange:Qe=>{I(Qe.target.value),q("")}}),j&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:j})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Sales Channel(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select where you currently sell your products)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:salesChannels.map(Qe=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`channel-${Qe.id}`,checked:z.includes(Qe.id),onCheckedChange:Xe=>He(Qe.id,Xe===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`channel-${Qe.id}`,className:"text-sm font-normal",children:Qe.label})]},Qe.id))}),tt&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:te,onChange:Qe=>ne(Qe.target.value)}),F&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:F})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Your Primary Market(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select which regions you sell to)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:markets.map(Qe=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`market-${Qe.id}`,checked:se.includes(Qe.id),onCheckedChange:Xe=>Ze(Qe.id,Xe===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`market-${Qe.id}`,className:"text-sm font-normal",children:Qe.label})]},Qe.id))}),Ye&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:je,onChange:Qe=>Ne(Qe.target.value)}),oe&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:oe})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",disabled:E,children:E?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Submitting..."]}):"Submit"})})]})]})})]})}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection,useCollection,createCollectionScope]=createCollection(SELECT_NAME),[createSelectContext,createSelectScope]=createContextScope(SELECT_NAME,[createCollectionScope,createPopperScope]),usePopperScope$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$1=t=>{const{__scopeSelect:e,children:n,open:o,defaultOpen:l,onOpenChange:d,value:f,defaultValue:g,onValueChange:b,dir:_,name:S,autoComplete:R,disabled:C,required:E,form:A}=t,M=usePopperScope$1(e),[I,j]=React__namespace.useState(null),[q,z]=React__namespace.useState(null),[Q,F]=React__namespace.useState(!1),V=useDirection(_),[te,ne]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:SELECT_NAME}),[se,ge]=useControllableState({prop:f,defaultProp:g,onChange:b,caller:SELECT_NAME}),oe=React__namespace.useRef(null),Ae=I?A||!!I.closest("form"):!0,[je,Ne]=React__namespace.useState(new Set),Oe=Array.from(je).map(Fe=>Fe.props.value).join(";");return jsxRuntime.jsx(Root2$6,{...M,children:jsxRuntime.jsxs(SelectProvider,{required:E,scope:e,trigger:I,onTriggerChange:j,valueNode:q,onValueNodeChange:z,valueNodeHasChildren:Q,onValueNodeHasChildrenChange:F,contentId:useId(),value:se,onValueChange:ge,open:te,onOpenChange:ne,dir:V,triggerPointerDownPosRef:oe,disabled:C,children:[jsxRuntime.jsx(Collection.Provider,{scope:e,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:t.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Fe=>{Ne(ze=>new Set(ze).add(Fe))},[]),onNativeOptionRemove:React__namespace.useCallback(Fe=>{Ne(ze=>{const $e=new Set(ze);return $e.delete(Fe),$e})},[]),children:n})}),Ae?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:E,tabIndex:-1,name:S,autoComplete:R,value:se,onChange:Fe=>ge(Fe.target.value),disabled:C,form:A,children:[se===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(je)]},Oe):null]})})};Select$1.displayName=SELECT_NAME;var TRIGGER_NAME$2="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:o=!1,...l}=t,d=usePopperScope$1(n),f=useSelectContext(TRIGGER_NAME$2,n),g=f.disabled||o,b=useComposedRefs(e,f.onTriggerChange),_=useCollection(n),S=React__namespace.useRef("touch"),[R,C,E]=useTypeaheadSearch(M=>{const I=_().filter(z=>!z.disabled),j=I.find(z=>z.value===f.value),q=findNextItem(I,M,j);q!==void 0&&f.onValueChange(q.value)}),A=M=>{g||(f.onOpenChange(!0),E()),M&&(f.triggerPointerDownPosRef.current={x:Math.round(M.pageX),y:Math.round(M.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...d,children:jsxRuntime.jsx(Primitive.button,{type:"button",role:"combobox","aria-controls":f.contentId,"aria-expanded":f.open,"aria-required":f.required,"aria-autocomplete":"none",dir:f.dir,"data-state":f.open?"open":"closed",disabled:g,"data-disabled":g?"":void 0,"data-placeholder":shouldShowPlaceholder(f.value)?"":void 0,...l,ref:b,onClick:composeEventHandlers(l.onClick,M=>{M.currentTarget.focus(),S.current!=="mouse"&&A(M)}),onPointerDown:composeEventHandlers(l.onPointerDown,M=>{S.current=M.pointerType;const I=M.target;I.hasPointerCapture(M.pointerId)&&I.releasePointerCapture(M.pointerId),M.button===0&&M.ctrlKey===!1&&M.pointerType==="mouse"&&(A(M),M.preventDefault())}),onKeyDown:composeEventHandlers(l.onKeyDown,M=>{const I=R.current!=="";!(M.ctrlKey||M.altKey||M.metaKey)&&M.key.length===1&&C(M.key),!(I&&M.key===" ")&&OPEN_KEYS.includes(M.key)&&(A(),M.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$2;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,className:o,style:l,children:d,placeholder:f="",...g}=t,b=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:_}=b,S=d!==void 0,R=useComposedRefs(e,b.onValueNodeChange);return useLayoutEffect2(()=>{_(S)},[_,S]),jsxRuntime.jsx(Primitive.span,{...g,ref:R,style:{pointerEvents:"none"},children:shouldShowPlaceholder(b.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:f}):d})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,children:o,...l}=t;return jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...l,ref:e,children:o||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$2="SelectPortal",SelectPortal=t=>jsxRuntime.jsx(Portal$5,{asChild:!0,...t});SelectPortal.displayName=PORTAL_NAME$2;var CONTENT_NAME$2="SelectContent",SelectContent$1=React__namespace.forwardRef((t,e)=>{const n=useSelectContext(CONTENT_NAME$2,t.__scopeSelect),[o,l]=React__namespace.useState();if(useLayoutEffect2(()=>{l(new DocumentFragment)},[]),!n.open){const d=o;return d?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:t.__scopeSelect,children:jsxRuntime.jsx(Collection.Slot,{scope:t.__scopeSelect,children:jsxRuntime.jsx("div",{children:t.children})})}),d):null}return jsxRuntime.jsx(SelectContentImpl,{...t,ref:e})});SelectContent$1.displayName=CONTENT_NAME$2;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$2),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,position:o="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:d,onPointerDownOutside:f,side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:A,hideWhenDetached:M,avoidCollisions:I,...j}=t,q=useSelectContext(CONTENT_NAME$2,n),[z,Q]=React__namespace.useState(null),[F,V]=React__namespace.useState(null),te=useComposedRefs(e,Xe=>Q(Xe)),[ne,se]=React__namespace.useState(null),[ge,oe]=React__namespace.useState(null),Ae=useCollection(n),[je,Ne]=React__namespace.useState(!1),Oe=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(z)return hideOthers(z)},[z]),useFocusGuards();const Fe=React__namespace.useCallback(Xe=>{const[st,...rt]=Ae().map(Ue=>Ue.ref.current),[at]=rt.slice(-1),ot=document.activeElement;for(const Ue of Xe)if(Ue===ot||(Ue==null||Ue.scrollIntoView({block:"nearest"}),Ue===st&&F&&(F.scrollTop=0),Ue===at&&F&&(F.scrollTop=F.scrollHeight),Ue==null||Ue.focus(),document.activeElement!==ot))return},[Ae,F]),ze=React__namespace.useCallback(()=>Fe([ne,z]),[Fe,ne,z]);React__namespace.useEffect(()=>{je&&ze()},[je,ze]);const{onOpenChange:$e,triggerPointerDownPosRef:Be}=q;React__namespace.useEffect(()=>{if(z){let Xe={x:0,y:0};const st=at=>{var ot,Ue;Xe={x:Math.abs(Math.round(at.pageX)-(((ot=Be.current)==null?void 0:ot.x)??0)),y:Math.abs(Math.round(at.pageY)-(((Ue=Be.current)==null?void 0:Ue.y)??0))}},rt=at=>{Xe.x<=10&&Xe.y<=10?at.preventDefault():z.contains(at.target)||$e(!1),document.removeEventListener("pointermove",st),Be.current=null};return Be.current!==null&&(document.addEventListener("pointermove",st),document.addEventListener("pointerup",rt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",st),document.removeEventListener("pointerup",rt,{capture:!0})}}},[z,$e,Be]),React__namespace.useEffect(()=>{const Xe=()=>$e(!1);return window.addEventListener("blur",Xe),window.addEventListener("resize",Xe),()=>{window.removeEventListener("blur",Xe),window.removeEventListener("resize",Xe)}},[$e]);const[qe,Ge]=useTypeaheadSearch(Xe=>{const st=Ae().filter(ot=>!ot.disabled),rt=st.find(ot=>ot.ref.current===document.activeElement),at=findNextItem(st,Xe,rt);at&&setTimeout(()=>at.ref.current.focus())}),He=React__namespace.useCallback((Xe,st,rt)=>{const at=!Oe.current&&!rt;(q.value!==void 0&&q.value===st||at)&&(se(Xe),at&&(Oe.current=!0))},[q.value]),Ze=React__namespace.useCallback(()=>z==null?void 0:z.focus(),[z]),tt=React__namespace.useCallback((Xe,st,rt)=>{const at=!Oe.current&&!rt;(q.value!==void 0&&q.value===st||at)&&oe(Xe)},[q.value]),Ye=o==="popper"?SelectPopperPosition:SelectItemAlignedPosition,Qe=Ye===SelectPopperPosition?{side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:A,hideWhenDetached:M,avoidCollisions:I}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:z,viewport:F,onViewportChange:V,itemRefCallback:He,selectedItem:ne,onItemLeave:Ze,itemTextRefCallback:tt,focusSelectedItem:ze,selectedItemText:ge,position:o,isPositioned:je,searchRef:qe,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:q.open,onMountAutoFocus:Xe=>{Xe.preventDefault()},onUnmountAutoFocus:composeEventHandlers(l,Xe=>{var st;(st=q.trigger)==null||st.focus({preventScroll:!0}),Xe.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:Xe=>Xe.preventDefault(),onDismiss:()=>q.onOpenChange(!1),children:jsxRuntime.jsx(Ye,{role:"listbox",id:q.contentId,"data-state":q.open?"open":"closed",dir:q.dir,onContextMenu:Xe=>Xe.preventDefault(),...j,...Qe,onPlaced:()=>Ne(!0),ref:te,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:composeEventHandlers(j.onKeyDown,Xe=>{const st=Xe.ctrlKey||Xe.altKey||Xe.metaKey;if(Xe.key==="Tab"&&Xe.preventDefault(),!st&&Xe.key.length===1&&Ge(Xe.key),["ArrowUp","ArrowDown","Home","End"].includes(Xe.key)){let at=Ae().filter(ot=>!ot.disabled).map(ot=>ot.ref.current);if(["ArrowUp","End"].includes(Xe.key)&&(at=at.slice().reverse()),["ArrowUp","ArrowDown"].includes(Xe.key)){const ot=Xe.target,Ue=at.indexOf(ot);at=at.slice(Ue+1)}setTimeout(()=>Fe(at)),Xe.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:o,...l}=t,d=useSelectContext(CONTENT_NAME$2,n),f=useSelectContentContext(CONTENT_NAME$2,n),[g,b]=React__namespace.useState(null),[_,S]=React__namespace.useState(null),R=useComposedRefs(e,te=>S(te)),C=useCollection(n),E=React__namespace.useRef(!1),A=React__namespace.useRef(!0),{viewport:M,selectedItem:I,selectedItemText:j,focusSelectedItem:q}=f,z=React__namespace.useCallback(()=>{if(d.trigger&&d.valueNode&&g&&_&&M&&I&&j){const te=d.trigger.getBoundingClientRect(),ne=_.getBoundingClientRect(),se=d.valueNode.getBoundingClientRect(),ge=j.getBoundingClientRect();if(d.dir!=="rtl"){const ot=ge.left-ne.left,Ue=se.left-ot,Ct=te.left-Ue,Je=te.width+Ct,yt=Math.max(Je,ne.width),Mt=window.innerWidth-CONTENT_MARGIN,qt=clamp(Ue,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,Mt-yt)]);g.style.minWidth=Je+"px",g.style.left=qt+"px"}else{const ot=ne.right-ge.right,Ue=window.innerWidth-se.right-ot,Ct=window.innerWidth-te.right-Ue,Je=te.width+Ct,yt=Math.max(Je,ne.width),Mt=window.innerWidth-CONTENT_MARGIN,qt=clamp(Ue,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,Mt-yt)]);g.style.minWidth=Je+"px",g.style.right=qt+"px"}const oe=C(),Ae=window.innerHeight-CONTENT_MARGIN*2,je=M.scrollHeight,Ne=window.getComputedStyle(_),Oe=parseInt(Ne.borderTopWidth,10),Fe=parseInt(Ne.paddingTop,10),ze=parseInt(Ne.borderBottomWidth,10),$e=parseInt(Ne.paddingBottom,10),Be=Oe+Fe+je+$e+ze,qe=Math.min(I.offsetHeight*5,Be),Ge=window.getComputedStyle(M),He=parseInt(Ge.paddingTop,10),Ze=parseInt(Ge.paddingBottom,10),tt=te.top+te.height/2-CONTENT_MARGIN,Ye=Ae-tt,Qe=I.offsetHeight/2,Xe=I.offsetTop+Qe,st=Oe+Fe+Xe,rt=Be-st;if(st<=tt){const ot=oe.length>0&&I===oe[oe.length-1].ref.current;g.style.bottom="0px";const Ue=_.clientHeight-M.offsetTop-M.offsetHeight,Ct=Math.max(Ye,Qe+(ot?Ze:0)+Ue+ze),Je=st+Ct;g.style.height=Je+"px"}else{const ot=oe.length>0&&I===oe[0].ref.current;g.style.top="0px";const Ct=Math.max(tt,Oe+M.offsetTop+(ot?He:0)+Qe)+rt;g.style.height=Ct+"px",M.scrollTop=st-tt+M.offsetTop}g.style.margin=`${CONTENT_MARGIN}px 0`,g.style.minHeight=qe+"px",g.style.maxHeight=Ae+"px",o==null||o(),requestAnimationFrame(()=>E.current=!0)}},[C,d.trigger,d.valueNode,g,_,M,I,j,d.dir,o]);useLayoutEffect2(()=>z(),[z]);const[Q,F]=React__namespace.useState();useLayoutEffect2(()=>{_&&F(window.getComputedStyle(_).zIndex)},[_]);const V=React__namespace.useCallback(te=>{te&&A.current===!0&&(z(),q==null||q(),A.current=!1)},[z,q]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:g,shouldExpandOnScrollRef:E,onScrollButtonChange:V,children:jsxRuntime.jsx("div",{ref:b,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:Q},children:jsxRuntime.jsx(Primitive.div,{...l,ref:R,style:{boxSizing:"border-box",maxHeight:"100%",...l.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,align:o="start",collisionPadding:l=CONTENT_MARGIN,...d}=t,f=usePopperScope$1(n);return jsxRuntime.jsx(Content$1,{...f,...d,ref:e,align:o,collisionPadding:l,style:{boxSizing:"border-box",...d.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$2,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:o,...l}=t,d=useSelectContentContext(VIEWPORT_NAME,n),f=useSelectViewportContext(VIEWPORT_NAME,n),g=useComposedRefs(e,d.onViewportChange),b=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:o}),jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...l,ref:g,style:{position:"relative",flex:1,overflow:"hidden auto",...l.style},onScroll:composeEventHandlers(l.onScroll,_=>{const S=_.currentTarget,{contentWrapper:R,shouldExpandOnScrollRef:C}=f;if(C!=null&&C.current&&R){const E=Math.abs(b.current-S.scrollTop);if(E>0){const A=window.innerHeight-CONTENT_MARGIN*2,M=parseFloat(R.style.minHeight),I=parseFloat(R.style.height),j=Math.max(M,I);if(j<A){const q=j+E,z=Math.min(A,q),Q=q-z;R.style.height=z+"px",R.style.bottom==="0px"&&(S.scrollTop=Q>0?Q:0,R.style.justifyContent="flex-end")}}}b.current=S.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t,l=useId();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:l,children:jsxRuntime.jsx(Primitive.div,{role:"group","aria-labelledby":l,...o,ref:e})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t,l=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive.div,{id:l.id,...o,ref:e})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME),SelectItem$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,value:o,disabled:l=!1,textValue:d,...f}=t,g=useSelectContext(ITEM_NAME,n),b=useSelectContentContext(ITEM_NAME,n),_=g.value===o,[S,R]=React__namespace.useState(d??""),[C,E]=React__namespace.useState(!1),A=useComposedRefs(e,q=>{var z;return(z=b.itemRefCallback)==null?void 0:z.call(b,q,o,l)}),M=useId(),I=React__namespace.useRef("touch"),j=()=>{l||(g.onValueChange(o),g.onOpenChange(!1))};if(o==="")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:o,disabled:l,textId:M,isSelected:_,onItemTextChange:React__namespace.useCallback(q=>{R(z=>z||((q==null?void 0:q.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection.ItemSlot,{scope:n,value:o,disabled:l,textValue:S,children:jsxRuntime.jsx(Primitive.div,{role:"option","aria-labelledby":M,"data-highlighted":C?"":void 0,"aria-selected":_&&C,"data-state":_?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...f,ref:A,onFocus:composeEventHandlers(f.onFocus,()=>E(!0)),onBlur:composeEventHandlers(f.onBlur,()=>E(!1)),onClick:composeEventHandlers(f.onClick,()=>{I.current!=="mouse"&&j()}),onPointerUp:composeEventHandlers(f.onPointerUp,()=>{I.current==="mouse"&&j()}),onPointerDown:composeEventHandlers(f.onPointerDown,q=>{I.current=q.pointerType}),onPointerMove:composeEventHandlers(f.onPointerMove,q=>{var z;I.current=q.pointerType,l?(z=b.onItemLeave)==null||z.call(b):I.current==="mouse"&&q.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(f.onPointerLeave,q=>{var z;q.currentTarget===document.activeElement&&((z=b.onItemLeave)==null||z.call(b))}),onKeyDown:composeEventHandlers(f.onKeyDown,q=>{var Q;((Q=b.searchRef)==null?void 0:Q.current)!==""&&q.key===" "||(SELECTION_KEYS.includes(q.key)&&j(),q.key===" "&&q.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,className:o,style:l,...d}=t,f=useSelectContext(ITEM_TEXT_NAME,n),g=useSelectContentContext(ITEM_TEXT_NAME,n),b=useSelectItemContext(ITEM_TEXT_NAME,n),_=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[S,R]=React__namespace.useState(null),C=useComposedRefs(e,j=>R(j),b.onItemTextChange,j=>{var q;return(q=g.itemTextRefCallback)==null?void 0:q.call(g,j,b.value,b.disabled)}),E=S==null?void 0:S.textContent,A=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:b.value,disabled:b.disabled,children:E},b.value),[b.disabled,b.value,E]),{onNativeOptionAdd:M,onNativeOptionRemove:I}=_;return useLayoutEffect2(()=>(M(A),()=>I(A)),[M,I,A]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive.span,{id:b.textId,...d,ref:C}),b.isSelected&&f.valueNode&&!f.valueNodeHasChildren?ReactDOM__namespace.createPortal(d.children,f.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...o,ref:e}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((t,e)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,t.__scopeSelect),o=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,t.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(e,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollTop>0;d(_)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...t,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop-b.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((t,e)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,t.__scopeSelect),o=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,t.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(e,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollHeight-b.clientHeight,S=Math.ceil(b.scrollTop)<_;d(S)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...t,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop+b.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:o,...l}=t,d=useSelectContentContext("SelectScrollButton",n),f=React__namespace.useRef(null),g=useCollection(n),b=React__namespace.useCallback(()=>{f.current!==null&&(window.clearInterval(f.current),f.current=null)},[]);return React__namespace.useEffect(()=>()=>b(),[b]),useLayoutEffect2(()=>{var S;const _=g().find(R=>R.ref.current===document.activeElement);(S=_==null?void 0:_.ref.current)==null||S.scrollIntoView({block:"nearest"})},[g]),jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...l,ref:e,style:{flexShrink:0,...l.style},onPointerDown:composeEventHandlers(l.onPointerDown,()=>{f.current===null&&(f.current=window.setInterval(o,50))}),onPointerMove:composeEventHandlers(l.onPointerMove,()=>{var _;(_=d.onItemLeave)==null||_.call(d),f.current===null&&(f.current=window.setInterval(o,50))}),onPointerLeave:composeEventHandlers(l.onPointerLeave,()=>{b()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t;return jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...o,ref:e})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t,l=usePopperScope$1(n),d=useSelectContext(ARROW_NAME$1,n),f=useSelectContentContext(ARROW_NAME$1,n);return d.open&&f.position==="popper"?jsxRuntime.jsx(Arrow,{...l,...o,ref:e}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:t,value:e,...n},o)=>{const l=React__namespace.useRef(null),d=useComposedRefs(o,l),f=usePrevious(e);return React__namespace.useEffect(()=>{const g=l.current;if(!g)return;const b=window.HTMLSelectElement.prototype,S=Object.getOwnPropertyDescriptor(b,"value").set;if(f!==e&&S){const R=new Event("change",{bubbles:!0});S.call(g,e),g.dispatchEvent(R)}},[f,e]),jsxRuntime.jsx(Primitive.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:d,defaultValue:e})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME;function shouldShowPlaceholder(t){return t===""||t===void 0}function useTypeaheadSearch(t){const e=useCallbackRef$1(t),n=React__namespace.useRef(""),o=React__namespace.useRef(0),l=React__namespace.useCallback(f=>{const g=n.current+f;e(g),function b(_){n.current=_,window.clearTimeout(o.current),_!==""&&(o.current=window.setTimeout(()=>b(""),1e3))}(g)},[e]),d=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(o.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(o.current),[]),[n,l,d]}function findNextItem(t,e,n){const l=e.length>1&&Array.from(e).every(_=>_===e[0])?e[0]:e,d=n?t.indexOf(n):-1;let f=wrapArray(t,Math.max(d,0));l.length===1&&(f=f.filter(_=>_!==n));const b=f.find(_=>_.textValue.toLowerCase().startsWith(l.toLowerCase()));return b!==n?b:void 0}function wrapArray(t,e){return t.map((n,o)=>t[(e+o)%t.length])}var Root2$2=Select$1,Trigger$1=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$2=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item$1=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select=Root2$2,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:t,children:e,...n},o)=>jsxRuntime.jsxs(Trigger$1,{ref:o,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[e,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger$1.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",t),...e,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",t),...e,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:t,children:e,position:n="popper",...o},l)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$2,{ref:l,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",t),position:n,...o,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:e}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2$2.displayName;const SelectLabel=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",t),...e}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:t,children:e,...n},o)=>jsxRuntime.jsxs(Item$1,{ref:o,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",t),...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:e})]}));SelectItem.displayName=Item$1.displayName;const SelectSeparator=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",t),...e}));SelectSeparator.displayName=Separator.displayName;const DAYS_OF_WEEK=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ManufacturerReorderingCard({manufacturer:t,onSave:e,loading:n=!1,saving:o=!1,readonly:l=!1}){const[d,f]=React.useState({...t}),[g,b]=React.useState({...t});React.useEffect(()=>{b({...t}),f({...t})},[t]);const _=(j,q)=>{l||f(z=>({...z,[j]:q}))},S=(j,q)=>{l||f(z=>({...z,[j]:q}))},R=(j,q)=>{l||f(z=>({...z,[j]:q}))},C=()=>{const j={};return Object.keys(d).forEach(q=>{const z=q;JSON.stringify(d[z])!==JSON.stringify(g[z])&&(j[z]=d[z])}),j},E=()=>{if(!o&&!l){const j=C();Object.keys(j).length>0&&e(j)}},A=j=>j===-1?"ASAP":j===void 0||j<0||j>6?"Sunday":DAYS_OF_WEEK[j],M=j=>j==="ASAP"?-1:DAYS_OF_WEEK.indexOf(j),I=Object.keys(C()).length>0;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[n?jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}):jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Reordering"}),n?jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}):jsxRuntime.jsx(CardDescription,{className:"text-sm",children:"Adjust your reordering settings to control lead times, stocking weeks, minimum orders, and reorder dates, enhancing efficiency in restocking processes."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"automatic-reordering",checked:d.AutoUpdate,onCheckedChange:j=>_("AutoUpdate",j),disabled:o||l}),jsxRuntime.jsx(Label$2,{htmlFor:"automatic-reordering",children:"Automatic Reordering"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"reorder-date",children:"Automatic Reorder Date"}),jsxRuntime.jsxs(Select,{value:A(d.AutoReorderDate),onValueChange:j=>S("AutoReorderDate",M(j)),disabled:o||l,children:[jsxRuntime.jsx(SelectTrigger,{id:"reorder-date",children:jsxRuntime.jsx(SelectValue,{placeholder:"Select day"})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"ASAP",children:"ASAP"}),DAYS_OF_WEEK.map(j=>jsxRuntime.jsx(SelectItem,{value:j,children:j},j))]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"weeks-stocking",children:"Default Weeks of Stocking"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"weeks-stocking",type:"number",value:d.DefaultWeeksOfStocking||"",onChange:j=>S("DefaultWeeksOfStocking",Number(j.target.value)),disabled:o||l}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"weeks"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"minimum-order",children:"Default Minimum Order"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"minimum-order",type:"number",className:"pl-6",value:d.DefaultMinimumOrder||"",onChange:j=>S("DefaultMinimumOrder",Number(j.target.value)),disabled:o||l})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"lead-time",children:"Default Lead Time"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"lead-time",type:"number",value:d.DefaultLeadTime||"",onChange:j=>S("DefaultLeadTime",Number(j.target.value)),disabled:o||l}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"days"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"maximum-inventory-value",children:"Default Maximum Inventory Value"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"maximum-inventory-value",type:"number",className:"pl-6",value:d.DefaultMaxInventoryValue||"",onChange:j=>S("DefaultMaxInventoryValue",Number(j.target.value)),disabled:o||l})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"order-confirmations",children:"Send Order Confirmations To"}),jsxRuntime.jsx(Input,{id:"order-confirmations",type:"email",value:d.POEmail||"",onChange:j=>R("POEmail",j.target.value),placeholder:"email@example.com",disabled:o||l})]})]})]})}),!l&&jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button,{onClick:E,disabled:o||!I,children:[o&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}var POPOVER_NAME="Popover",[createPopoverContext,createPopoverScope]=createContextScope(POPOVER_NAME,[createPopperScope]),usePopperScope=createPopperScope(),[PopoverProvider,usePopoverContext]=createPopoverContext(POPOVER_NAME),Popover$1=t=>{const{__scopePopover:e,children:n,open:o,defaultOpen:l,onOpenChange:d,modal:f=!1}=t,g=usePopperScope(e),b=React__namespace.useRef(null),[_,S]=React__namespace.useState(!1),[R,C]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:POPOVER_NAME});return jsxRuntime.jsx(Root2$6,{...g,children:jsxRuntime.jsx(PopoverProvider,{scope:e,contentId:useId(),triggerRef:b,open:R,onOpenChange:C,onOpenToggle:React__namespace.useCallback(()=>C(E=>!E),[C]),hasCustomAnchor:_,onCustomAnchorAdd:React__namespace.useCallback(()=>S(!0),[]),onCustomAnchorRemove:React__namespace.useCallback(()=>S(!1),[]),modal:f,children:n})})};Popover$1.displayName=POPOVER_NAME;var ANCHOR_NAME="PopoverAnchor",PopoverAnchor$1=React__namespace.forwardRef((t,e)=>{const{__scopePopover:n,...o}=t,l=usePopoverContext(ANCHOR_NAME,n),d=usePopperScope(n),{onCustomAnchorAdd:f,onCustomAnchorRemove:g}=l;return React__namespace.useEffect(()=>(f(),()=>g()),[f,g]),jsxRuntime.jsx(Anchor,{...d,...o,ref:e})});PopoverAnchor$1.displayName=ANCHOR_NAME;var TRIGGER_NAME$1="PopoverTrigger",PopoverTrigger$1=React__namespace.forwardRef((t,e)=>{const{__scopePopover:n,...o}=t,l=usePopoverContext(TRIGGER_NAME$1,n),d=usePopperScope(n),f=useComposedRefs(e,l.triggerRef),g=jsxRuntime.jsx(Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":getState(l.open),...o,ref:f,onClick:composeEventHandlers(t.onClick,l.onOpenToggle)});return l.hasCustomAnchor?g:jsxRuntime.jsx(Anchor,{asChild:!0,...d,children:g})});PopoverTrigger$1.displayName=TRIGGER_NAME$1;var PORTAL_NAME$1="PopoverPortal",[PortalProvider,usePortalContext]=createPopoverContext(PORTAL_NAME$1,{forceMount:void 0}),PopoverPortal=t=>{const{__scopePopover:e,forceMount:n,children:o,container:l}=t,d=usePopoverContext(PORTAL_NAME$1,e);return jsxRuntime.jsx(PortalProvider,{scope:e,forceMount:n,children:jsxRuntime.jsx(Presence,{present:n||d.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:l,children:o})})})};PopoverPortal.displayName=PORTAL_NAME$1;var CONTENT_NAME$1="PopoverContent",PopoverContent$1=React__namespace.forwardRef((t,e)=>{const n=usePortalContext(CONTENT_NAME$1,t.__scopePopover),{forceMount:o=n.forceMount,...l}=t,d=usePopoverContext(CONTENT_NAME$1,t.__scopePopover);return jsxRuntime.jsx(Presence,{present:o||d.open,children:d.modal?jsxRuntime.jsx(PopoverContentModal,{...l,ref:e}):jsxRuntime.jsx(PopoverContentNonModal,{...l,ref:e})})});PopoverContent$1.displayName=CONTENT_NAME$1;var Slot=createSlot("PopoverContent.RemoveScroll"),PopoverContentModal=React__namespace.forwardRef((t,e)=>{const n=usePopoverContext(CONTENT_NAME$1,t.__scopePopover),o=React__namespace.useRef(null),l=useComposedRefs(e,o),d=React__namespace.useRef(!1);return React__namespace.useEffect(()=>{const f=o.current;if(f)return hideOthers(f)},[]),jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(PopoverContentImpl,{...t,ref:l,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(t.onCloseAutoFocus,f=>{var g;f.preventDefault(),d.current||(g=n.triggerRef.current)==null||g.focus()}),onPointerDownOutside:composeEventHandlers(t.onPointerDownOutside,f=>{const g=f.detail.originalEvent,b=g.button===0&&g.ctrlKey===!0,_=g.button===2||b;d.current=_},{checkForDefaultPrevented:!1}),onFocusOutside:composeEventHandlers(t.onFocusOutside,f=>f.preventDefault(),{checkForDefaultPrevented:!1})})})}),PopoverContentNonModal=React__namespace.forwardRef((t,e)=>{const n=usePopoverContext(CONTENT_NAME$1,t.__scopePopover),o=React__namespace.useRef(!1),l=React__namespace.useRef(!1);return jsxRuntime.jsx(PopoverContentImpl,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:d=>{var f,g;(f=t.onCloseAutoFocus)==null||f.call(t,d),d.defaultPrevented||(o.current||(g=n.triggerRef.current)==null||g.focus(),d.preventDefault()),o.current=!1,l.current=!1},onInteractOutside:d=>{var b,_;(b=t.onInteractOutside)==null||b.call(t,d),d.defaultPrevented||(o.current=!0,d.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const f=d.target;((_=n.triggerRef.current)==null?void 0:_.contains(f))&&d.preventDefault(),d.detail.originalEvent.type==="focusin"&&l.current&&d.preventDefault()}})}),PopoverContentImpl=React__namespace.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:o,onOpenAutoFocus:l,onCloseAutoFocus:d,disableOutsidePointerEvents:f,onEscapeKeyDown:g,onPointerDownOutside:b,onFocusOutside:_,onInteractOutside:S,...R}=t,C=usePopoverContext(CONTENT_NAME$1,n),E=usePopperScope(n);return useFocusGuards(),jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:l,onUnmountAutoFocus:d,children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:f,onInteractOutside:S,onEscapeKeyDown:g,onPointerDownOutside:b,onFocusOutside:_,onDismiss:()=>C.onOpenChange(!1),children:jsxRuntime.jsx(Content$1,{"data-state":getState(C.open),role:"dialog",id:C.contentId,...E,...R,ref:e,style:{...R.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),CLOSE_NAME="PopoverClose",PopoverClose=React__namespace.forwardRef((t,e)=>{const{__scopePopover:n,...o}=t,l=usePopoverContext(CLOSE_NAME,n);return jsxRuntime.jsx(Primitive.button,{type:"button",...o,ref:e,onClick:composeEventHandlers(t.onClick,()=>l.onOpenChange(!1))})});PopoverClose.displayName=CLOSE_NAME;var ARROW_NAME="PopoverArrow",PopoverArrow=React__namespace.forwardRef((t,e)=>{const{__scopePopover:n,...o}=t,l=usePopperScope(n);return jsxRuntime.jsx(Arrow,{...l,...o,ref:e})});PopoverArrow.displayName=ARROW_NAME;function getState(t){return t?"open":"closed"}var Root2$1=Popover$1,Anchor2=PopoverAnchor$1,Trigger=PopoverTrigger$1,Portal=PopoverPortal,Content2$1=PopoverContent$1;const Popover=Root2$1,PopoverTrigger=Trigger,PopoverAnchor=Anchor2,PopoverContent=React__namespace.forwardRef(({className:t,align:e="center",sideOffset:n=4,...o},l)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsx(Content2$1,{ref:l,align:e,sideOffset:n,className:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",t),...o})}));PopoverContent.displayName=Content2$1.displayName;function MultiSelect({options:t,selected:e,onChange:n,placeholder:o="Select items...",disabled:l=!1}){const[d,f]=React__namespace.useState(!1),[g,b]=React__namespace.useState(""),_=React__namespace.useRef(null),[S,R]=React__namespace.useState(void 0),C=React__namespace.useCallback(()=>{_.current&&R(_.current.offsetWidth)},[]);React__namespace.useLayoutEffect(()=>{C()},[C]),React__namespace.useEffect(()=>(window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)),[C]);const E=I=>{n(e.filter(j=>j!==I))},A=I=>{f(!1),e.includes(I)?n(e.filter(j=>j!==I)):n([...e,I])},M=I=>{I.key==="Enter"&&g&&!t.includes(g)&&!e.includes(g)&&(I.preventDefault(),A(g),b(""))};return jsxRuntime.jsxs(Popover,{open:d,onOpenChange:f,children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:_,variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between h-auto min-h-[40px] py-2",disabled:l,children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1 items-center",children:e.length>0?e.map(I=>jsxRuntime.jsxs(Badge,{variant:"outline",className:"mr-1 mb-1",children:[I,jsxRuntime.jsx("span",{className:"ml-1 cursor-pointer ring-offset-background rounded-full outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",onClick:j=>{j.preventDefault(),j.stopPropagation(),E(I)},children:jsxRuntime.jsx(X$1,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},I)):jsxRuntime.jsx("span",{className:"text-muted-foreground",children:o})}),jsxRuntime.jsx(ChevronsUpDown,{className:"h-4 w-4 shrink-0 opacity-50 ml-2"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-full p-0",style:{width:S},children:jsxRuntime.jsxs(Command,{onKeyDown:M,children:[jsxRuntime.jsx(CommandInput,{placeholder:"Search or add custom item...",value:g,onValueChange:b}),jsxRuntime.jsxs(CommandList,{children:[jsxRuntime.jsx(CommandEmpty,{children:"No item found."}),jsxRuntime.jsxs(CommandGroup,{children:[t.filter(I=>!e.includes(I)).map(I=>jsxRuntime.jsxs(CommandItem,{onSelect:()=>A(I),children:[jsxRuntime.jsx(Check,{className:cn("mr-2 h-4 w-4",e.includes(I)?"opacity-100":"opacity-0")}),I]},I)),g&&!t.includes(g)&&!e.includes(g)&&jsxRuntime.jsxs(CommandItem,{onSelect:()=>A(g),children:['Add "',g,'"']})]})]})]})})]})}const imgSizeMap={sm:100,md:200,lg:300,xl:400},Placeholder=({size:t})=>jsxRuntime.jsx("div",{className:"rounded-md bg-muted flex items-center justify-center",style:{width:t,height:t},"aria-label":"Image not available",children:jsxRuntime.jsx(ImageOff,{className:"h-1/2 w-1/2 text-muted-foreground"})}),VideoSkeleton=()=>jsxRuntime.jsx(Skeleton,{className:"w-full",style:{aspectRatio:"16/9"}});function ProductImage({randmarSKU:t,size:e="md",alt:n,secondaryContent:o}){const[l,d]=React__namespace.useState(!1),[f,g]=React__namespace.useState(!1),[b,_]=React__namespace.useState(!1),S=imgSizeMap[e],R=React.useRef(null),C=useIntersectionObserver({elementRef:R,threshold:.1,rootMargin:"100px"}),{data:E,isFetching:A}=useGetProductByProductNumberImageExistsQuery({productNumber:t},{skip:!t||!C}),{data:M,isFetching:I}=useGetProductByRandmarSkuImageQuery({randmarSku:t,width:S*1.5,height:S*1.5},{skip:!E}),{data:j}=useGetProductByProductNumberVideoExistsQuery({productNumber:t},{skip:!t||!C}),{data:q,isFetching:z}=useGetProductByProductNumberVideoQuery({productNumber:t},{skip:!j||!l}),Q=A||I;async function F(){if(q){_(!0);try{const se=await(await fetch(q)).blob(),ge=window.URL.createObjectURL(se),oe=document.createElement("a");oe.href=ge,oe.download=`${t||"product"}-video.mp4`,document.body.appendChild(oe),oe.click(),document.body.removeChild(oe),window.URL.revokeObjectURL(ge)}catch(ne){console.error("Error downloading video:",ne)}finally{_(!1)}}}function V(){q&&(navigator.clipboard.writeText(q),g(!0),setTimeout(()=>g(!1),2e3))}function te(){j&&d(!0)}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:l,onOpenChange:d,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:z||!q?jsxRuntime.jsx(VideoSkeleton,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:o?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:q,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:o})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:q,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:V,children:f?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:F,disabled:b,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",ref:R,children:[Q?jsxRuntime.jsx(Skeleton,{className:"rounded-md",style:{width:S,height:S}}):M?jsxRuntime.jsx("img",{alt:n||`Product ${t}`,className:`rounded-md ${j?"cursor-pointer":""}`,onClick:te,src:M,width:S,height:S}):jsxRuntime.jsx(Placeholder,{size:S}),j==!0&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:te,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}function ResellerBillingOverviewCard({reseller:t,actions:e,loading:n=!1}){return n||!t?jsxRuntime.jsx(ResellerBillingOverviewSkeleton,{}):jsxRuntime.jsx(ResellerBillingOverviewData,{reseller:t,actions:e})}function ResellerBillingOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-40"})})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:Array(3).fill(0).map((t,e)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},e))}),jsxRuntime.jsx("div",{className:"space-y-4",children:Array(2).fill(0).map((t,e)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},e))})]}),jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-28 rounded-md"})})]})]})}function ResellerBillingOverviewData({reseller:t,actions:e}){const n=t.Statement||{},o=[{title:"0 - 30 Days",amount:n.Over0||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"31 - 45 Days",amount:n.Over30||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"45+ Days",amount:n.Over45||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"}],l=[{title:"Total",amount:n.Total||0,icon:jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-white"}),color:"bg-green-500"},{title:"Credit Limit",amount:t.CreditLimit||0,icon:jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:o.map((d,f)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:d.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${d.color}`,children:d.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:formatMoney(d.amount)})})]},f))}),jsxRuntime.jsx("div",{className:"space-y-4",children:l.map((d,f)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:d.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${d.color}`,children:d.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:formatMoney(d.amount)})})]},f))})]}),e&&jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:e})]})]})}function ResellerQualificationsCard({qualifications:t=[],loading:e=!1}){return e?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{className:"p-6",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 @lg:grid-cols-5 gap-4 gap-y-8",children:Array.from({length:10}).map((n,o)=>jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]},o))})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{children:t&&t.length>0?jsxRuntime.jsx("div",{className:"p-6",children:jsxRuntime.jsx("div",{className:"flex grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 @lg:grid-cols-5 gap-4 gap-y-8",children:t.map((n,o)=>jsxRuntime.jsx(ManufacturerLogo,{manufacturerId:n.ManufacturerId,opportunityNumber:n.DefaultOpportunityNumber},`${n.ManufacturerId}-${o}`))})}):jsxRuntime.jsx("p",{children:"No qualification available."})})]})}function ManufacturerLogo({manufacturerId:t,opportunityNumber:e}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx("div",{className:"h-12 w-full items-center justify-center mb-2",children:jsxRuntime.jsx(PartnerLogo,{id:t,width:96,height:48})}),e&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs",children:e})]})}function SalesOverviewCard({salesData:t,salesStatistics:e=[],loading:n=!1}){return n||!t?jsxRuntime.jsx(SalesOverviewSkeleton,{}):jsxRuntime.jsx(SalesOverviewData,{salesData:t,salesStatistics:e})}function SalesOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg @sm:text-xl",children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})})}),jsxRuntime.jsxs(CardContent,{className:"pt-4 px-3 @sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 @lg:grid-cols-3 gap-4",children:Array(3).fill(0).map((t,e)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},e))}),jsxRuntime.jsx("div",{className:"mt-6",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-[250px] w-full rounded-lg"})]})})]})]})}function SalesOverviewData({salesData:t,salesStatistics:e=[]}){const n=[{title:"Last 30 days",amount:t.SalesLast30Days||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"},{title:"Last 3 months",amount:t.SalesLast3Months||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-amber-500"},{title:"Year to date",amount:t.SalesYearToDay||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-emerald-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg @sm:text-xl",children:"Sales Overview"})}),jsxRuntime.jsxs(CardContent,{className:"pt-4 px-3 @sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 @lg:grid-cols-3 gap-4",children:n.map((o,l)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"text-sm @sm:text-base font-medium",children:o.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${o.color}`,children:o.icon})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base @sm:text-lg font-bold",children:formatMoney(o.amount)})]})]},l))}),jsxRuntime.jsx("div",{className:"mt-6",children:e&&e.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-4",children:"Sales Trend"}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsx(SalesChart,{statistics:e,chartHeight:300,mode:"week"})})]})})]})]})}var ROOT_NAME="AlertDialog",[createAlertDialogContext,createAlertDialogScope]=createContextScope(ROOT_NAME,[createDialogScope]),useDialogScope=createDialogScope(),AlertDialog$1=t=>{const{__scopeAlertDialog:e,...n}=t,o=useDialogScope(e);return jsxRuntime.jsx(Root$8,{...o,...n,modal:!0})};AlertDialog$1.displayName=ROOT_NAME;var TRIGGER_NAME="AlertDialogTrigger",AlertDialogTrigger$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Trigger$5,{...l,...o,ref:e})});AlertDialogTrigger$1.displayName=TRIGGER_NAME;var PORTAL_NAME="AlertDialogPortal",AlertDialogPortal$1=t=>{const{__scopeAlertDialog:e,...n}=t,o=useDialogScope(e);return jsxRuntime.jsx(Portal$4,{...o,...n})};AlertDialogPortal$1.displayName=PORTAL_NAME;var OVERLAY_NAME="AlertDialogOverlay",AlertDialogOverlay$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Overlay,{...l,...o,ref:e})});AlertDialogOverlay$1.displayName=OVERLAY_NAME;var CONTENT_NAME="AlertDialogContent",[AlertDialogContentProvider,useAlertDialogContentContext]=createAlertDialogContext(CONTENT_NAME),Slottable=createSlottable("AlertDialogContent"),AlertDialogContent$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...l}=t,d=useDialogScope(n),f=React__namespace.useRef(null),g=useComposedRefs(e,f),b=React__namespace.useRef(null);return jsxRuntime.jsx(WarningProvider,{contentName:CONTENT_NAME,titleName:TITLE_NAME,docsSlug:"alert-dialog",children:jsxRuntime.jsx(AlertDialogContentProvider,{scope:n,cancelRef:b,children:jsxRuntime.jsxs(Content$2,{role:"alertdialog",...d,...l,ref:g,onOpenAutoFocus:composeEventHandlers(l.onOpenAutoFocus,_=>{var S;_.preventDefault(),(S=b.current)==null||S.focus({preventScroll:!0})}),onPointerDownOutside:_=>_.preventDefault(),onInteractOutside:_=>_.preventDefault(),children:[jsxRuntime.jsx(Slottable,{children:o}),jsxRuntime.jsx(DescriptionWarning,{contentRef:f})]})})})});AlertDialogContent$1.displayName=CONTENT_NAME;var TITLE_NAME="AlertDialogTitle",AlertDialogTitle$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Title$1,{...l,...o,ref:e})});AlertDialogTitle$1.displayName=TITLE_NAME;var DESCRIPTION_NAME="AlertDialogDescription",AlertDialogDescription$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Description$1,{...l,...o,ref:e})});AlertDialogDescription$1.displayName=DESCRIPTION_NAME;var ACTION_NAME="AlertDialogAction",AlertDialogAction$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Close$1,{...l,...o,ref:e})});AlertDialogAction$1.displayName=ACTION_NAME;var CANCEL_NAME="AlertDialogCancel",AlertDialogCancel$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:l}=useAlertDialogContentContext(CANCEL_NAME,n),d=useDialogScope(n),f=useComposedRefs(e,l);return jsxRuntime.jsx(Close$1,{...d,...o,ref:f})});AlertDialogCancel$1.displayName=CANCEL_NAME;var DescriptionWarning=({contentRef:t})=>{const e=`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
1143
+ `);A(!0),Oe({routeApplicationId:t,partnerId:e.ManufacturerId??"",message:at}).then(ot=>{var Ct;if(ot.error){console.error(ot.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}const Ue=(Ct=ot.data)==null?void 0:Ct.ConversationId;Ue&&Fe(Ue)?(f(!1),$e()):n({title:"Could not send message",description:"Try again later.",variant:"destructive"})}).catch(ot=>{console.error(ot),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{A(!1)})},He=(Qe,Xe)=>{Q(st=>Xe?[...st,Qe]:st.filter(rt=>rt!==Qe)),V("")},Ze=(Qe,Xe)=>{ge(st=>Xe?[...st,Qe]:st.filter(rt=>rt!==Qe)),Ae("")},tt=z.includes("other-channel"),Ye=se.includes("other-market");return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!e.Qualification&&jsxRuntime.jsxs(Button,{onClick:Be,disabled:!e.PartnerRegistrationLink&&!e.OpenToWork,children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Get Started"]}),e.PartnerRegistrationLink&&jsxRuntime.jsx(Dialog,{open:o,onOpenChange:Qe=>{l(Qe)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[400px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:e.PublicName}),jsxRuntime.jsxs(DialogDescription,{children:[jsxRuntime.jsx("span",{className:"font-bold",children:"Already qualified?"})," Provide your Qualification ID."]})]}),jsxRuntime.jsxs("form",{onSubmit:qe,className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"qualificationId",children:"Qualification ID"}),jsxRuntime.jsx(Input,{id:"qualificationId",placeholder:"Enter your qualification ID",value:_,onChange:Qe=>{S(Qe.target.value),C("")}}),R&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:R})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",className:"w-full",disabled:g,children:g?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Applying..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Apply for Qualification"]})})})]}),jsxRuntime.jsx(Separator$1,{className:"my-4"}),jsxRuntime.jsxs("div",{className:"text-center space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Don't have a qualification ID?"}),jsxRuntime.jsx(reactRouterDom.Link,{to:e.PartnerRegistrationLink,target:"_blank",children:jsxRuntime.jsxs(Button,{variant:"outline",className:"w-full",disabled:!e.PartnerRegistrationLink,children:[jsxRuntime.jsx(ExternalLink,{className:"mr-2 h-4 w-4"}),"Register here"]})})]})]})}),jsxRuntime.jsx(Dialog,{open:d,onOpenChange:Qe=>{f(Qe)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[768px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Introduce Yourself"})}),jsxRuntime.jsxs("form",{onSubmit:Ge,className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{htmlFor:"businessDescription",children:["Tell Us About Your Business ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Briefly describe your business)"})]}),jsxRuntime.jsx(Textarea,{id:"businessDescription",placeholder:"We are an online retailer specializing in office supplies, serving businesses since 2018...",className:"min-h-[100px]",value:M,onChange:Qe=>{I(Qe.target.value),q("")}}),j&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:j})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Sales Channel(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select where you currently sell your products)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:salesChannels.map(Qe=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`channel-${Qe.id}`,checked:z.includes(Qe.id),onCheckedChange:Xe=>He(Qe.id,Xe===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`channel-${Qe.id}`,className:"text-sm font-normal",children:Qe.label})]},Qe.id))}),tt&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:te,onChange:Qe=>ne(Qe.target.value)}),F&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:F})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Your Primary Market(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select which regions you sell to)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:markets.map(Qe=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`market-${Qe.id}`,checked:se.includes(Qe.id),onCheckedChange:Xe=>Ze(Qe.id,Xe===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`market-${Qe.id}`,className:"text-sm font-normal",children:Qe.label})]},Qe.id))}),Ye&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:je,onChange:Qe=>Ne(Qe.target.value)}),oe&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:oe})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button,{type:"submit",disabled:E,children:E?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Submitting..."]}):"Submit"})})]})]})})]})}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection,useCollection,createCollectionScope]=createCollection(SELECT_NAME),[createSelectContext,createSelectScope]=createContextScope(SELECT_NAME,[createCollectionScope,createPopperScope]),usePopperScope$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$1=t=>{const{__scopeSelect:e,children:n,open:o,defaultOpen:l,onOpenChange:d,value:f,defaultValue:g,onValueChange:b,dir:_,name:S,autoComplete:R,disabled:C,required:E,form:A}=t,M=usePopperScope$1(e),[I,j]=React__namespace.useState(null),[q,z]=React__namespace.useState(null),[Q,F]=React__namespace.useState(!1),V=useDirection(_),[te,ne]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:SELECT_NAME}),[se,ge]=useControllableState({prop:f,defaultProp:g,onChange:b,caller:SELECT_NAME}),oe=React__namespace.useRef(null),Ae=I?A||!!I.closest("form"):!0,[je,Ne]=React__namespace.useState(new Set),Oe=Array.from(je).map(Fe=>Fe.props.value).join(";");return jsxRuntime.jsx(Root2$6,{...M,children:jsxRuntime.jsxs(SelectProvider,{required:E,scope:e,trigger:I,onTriggerChange:j,valueNode:q,onValueNodeChange:z,valueNodeHasChildren:Q,onValueNodeHasChildrenChange:F,contentId:useId(),value:se,onValueChange:ge,open:te,onOpenChange:ne,dir:V,triggerPointerDownPosRef:oe,disabled:C,children:[jsxRuntime.jsx(Collection.Provider,{scope:e,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:t.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Fe=>{Ne(ze=>new Set(ze).add(Fe))},[]),onNativeOptionRemove:React__namespace.useCallback(Fe=>{Ne(ze=>{const $e=new Set(ze);return $e.delete(Fe),$e})},[]),children:n})}),Ae?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:E,tabIndex:-1,name:S,autoComplete:R,value:se,onChange:Fe=>ge(Fe.target.value),disabled:C,form:A,children:[se===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(je)]},Oe):null]})})};Select$1.displayName=SELECT_NAME;var TRIGGER_NAME$2="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:o=!1,...l}=t,d=usePopperScope$1(n),f=useSelectContext(TRIGGER_NAME$2,n),g=f.disabled||o,b=useComposedRefs(e,f.onTriggerChange),_=useCollection(n),S=React__namespace.useRef("touch"),[R,C,E]=useTypeaheadSearch(M=>{const I=_().filter(z=>!z.disabled),j=I.find(z=>z.value===f.value),q=findNextItem(I,M,j);q!==void 0&&f.onValueChange(q.value)}),A=M=>{g||(f.onOpenChange(!0),E()),M&&(f.triggerPointerDownPosRef.current={x:Math.round(M.pageX),y:Math.round(M.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...d,children:jsxRuntime.jsx(Primitive.button,{type:"button",role:"combobox","aria-controls":f.contentId,"aria-expanded":f.open,"aria-required":f.required,"aria-autocomplete":"none",dir:f.dir,"data-state":f.open?"open":"closed",disabled:g,"data-disabled":g?"":void 0,"data-placeholder":shouldShowPlaceholder(f.value)?"":void 0,...l,ref:b,onClick:composeEventHandlers(l.onClick,M=>{M.currentTarget.focus(),S.current!=="mouse"&&A(M)}),onPointerDown:composeEventHandlers(l.onPointerDown,M=>{S.current=M.pointerType;const I=M.target;I.hasPointerCapture(M.pointerId)&&I.releasePointerCapture(M.pointerId),M.button===0&&M.ctrlKey===!1&&M.pointerType==="mouse"&&(A(M),M.preventDefault())}),onKeyDown:composeEventHandlers(l.onKeyDown,M=>{const I=R.current!=="";!(M.ctrlKey||M.altKey||M.metaKey)&&M.key.length===1&&C(M.key),!(I&&M.key===" ")&&OPEN_KEYS.includes(M.key)&&(A(),M.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$2;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,className:o,style:l,children:d,placeholder:f="",...g}=t,b=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:_}=b,S=d!==void 0,R=useComposedRefs(e,b.onValueNodeChange);return useLayoutEffect2(()=>{_(S)},[_,S]),jsxRuntime.jsx(Primitive.span,{...g,ref:R,style:{pointerEvents:"none"},children:shouldShowPlaceholder(b.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:f}):d})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,children:o,...l}=t;return jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...l,ref:e,children:o||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$2="SelectPortal",SelectPortal=t=>jsxRuntime.jsx(Portal$5,{asChild:!0,...t});SelectPortal.displayName=PORTAL_NAME$2;var CONTENT_NAME$2="SelectContent",SelectContent$1=React__namespace.forwardRef((t,e)=>{const n=useSelectContext(CONTENT_NAME$2,t.__scopeSelect),[o,l]=React__namespace.useState();if(useLayoutEffect2(()=>{l(new DocumentFragment)},[]),!n.open){const d=o;return d?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:t.__scopeSelect,children:jsxRuntime.jsx(Collection.Slot,{scope:t.__scopeSelect,children:jsxRuntime.jsx("div",{children:t.children})})}),d):null}return jsxRuntime.jsx(SelectContentImpl,{...t,ref:e})});SelectContent$1.displayName=CONTENT_NAME$2;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$2),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,position:o="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:d,onPointerDownOutside:f,side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:A,hideWhenDetached:M,avoidCollisions:I,...j}=t,q=useSelectContext(CONTENT_NAME$2,n),[z,Q]=React__namespace.useState(null),[F,V]=React__namespace.useState(null),te=useComposedRefs(e,Xe=>Q(Xe)),[ne,se]=React__namespace.useState(null),[ge,oe]=React__namespace.useState(null),Ae=useCollection(n),[je,Ne]=React__namespace.useState(!1),Oe=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(z)return hideOthers(z)},[z]),useFocusGuards();const Fe=React__namespace.useCallback(Xe=>{const[st,...rt]=Ae().map(Ue=>Ue.ref.current),[at]=rt.slice(-1),ot=document.activeElement;for(const Ue of Xe)if(Ue===ot||(Ue==null||Ue.scrollIntoView({block:"nearest"}),Ue===st&&F&&(F.scrollTop=0),Ue===at&&F&&(F.scrollTop=F.scrollHeight),Ue==null||Ue.focus(),document.activeElement!==ot))return},[Ae,F]),ze=React__namespace.useCallback(()=>Fe([ne,z]),[Fe,ne,z]);React__namespace.useEffect(()=>{je&&ze()},[je,ze]);const{onOpenChange:$e,triggerPointerDownPosRef:Be}=q;React__namespace.useEffect(()=>{if(z){let Xe={x:0,y:0};const st=at=>{var ot,Ue;Xe={x:Math.abs(Math.round(at.pageX)-(((ot=Be.current)==null?void 0:ot.x)??0)),y:Math.abs(Math.round(at.pageY)-(((Ue=Be.current)==null?void 0:Ue.y)??0))}},rt=at=>{Xe.x<=10&&Xe.y<=10?at.preventDefault():z.contains(at.target)||$e(!1),document.removeEventListener("pointermove",st),Be.current=null};return Be.current!==null&&(document.addEventListener("pointermove",st),document.addEventListener("pointerup",rt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",st),document.removeEventListener("pointerup",rt,{capture:!0})}}},[z,$e,Be]),React__namespace.useEffect(()=>{const Xe=()=>$e(!1);return window.addEventListener("blur",Xe),window.addEventListener("resize",Xe),()=>{window.removeEventListener("blur",Xe),window.removeEventListener("resize",Xe)}},[$e]);const[qe,Ge]=useTypeaheadSearch(Xe=>{const st=Ae().filter(ot=>!ot.disabled),rt=st.find(ot=>ot.ref.current===document.activeElement),at=findNextItem(st,Xe,rt);at&&setTimeout(()=>at.ref.current.focus())}),He=React__namespace.useCallback((Xe,st,rt)=>{const at=!Oe.current&&!rt;(q.value!==void 0&&q.value===st||at)&&(se(Xe),at&&(Oe.current=!0))},[q.value]),Ze=React__namespace.useCallback(()=>z==null?void 0:z.focus(),[z]),tt=React__namespace.useCallback((Xe,st,rt)=>{const at=!Oe.current&&!rt;(q.value!==void 0&&q.value===st||at)&&oe(Xe)},[q.value]),Ye=o==="popper"?SelectPopperPosition:SelectItemAlignedPosition,Qe=Ye===SelectPopperPosition?{side:g,sideOffset:b,align:_,alignOffset:S,arrowPadding:R,collisionBoundary:C,collisionPadding:E,sticky:A,hideWhenDetached:M,avoidCollisions:I}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:z,viewport:F,onViewportChange:V,itemRefCallback:He,selectedItem:ne,onItemLeave:Ze,itemTextRefCallback:tt,focusSelectedItem:ze,selectedItemText:ge,position:o,isPositioned:je,searchRef:qe,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:q.open,onMountAutoFocus:Xe=>{Xe.preventDefault()},onUnmountAutoFocus:composeEventHandlers(l,Xe=>{var st;(st=q.trigger)==null||st.focus({preventScroll:!0}),Xe.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:Xe=>Xe.preventDefault(),onDismiss:()=>q.onOpenChange(!1),children:jsxRuntime.jsx(Ye,{role:"listbox",id:q.contentId,"data-state":q.open?"open":"closed",dir:q.dir,onContextMenu:Xe=>Xe.preventDefault(),...j,...Qe,onPlaced:()=>Ne(!0),ref:te,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:composeEventHandlers(j.onKeyDown,Xe=>{const st=Xe.ctrlKey||Xe.altKey||Xe.metaKey;if(Xe.key==="Tab"&&Xe.preventDefault(),!st&&Xe.key.length===1&&Ge(Xe.key),["ArrowUp","ArrowDown","Home","End"].includes(Xe.key)){let at=Ae().filter(ot=>!ot.disabled).map(ot=>ot.ref.current);if(["ArrowUp","End"].includes(Xe.key)&&(at=at.slice().reverse()),["ArrowUp","ArrowDown"].includes(Xe.key)){const ot=Xe.target,Ue=at.indexOf(ot);at=at.slice(Ue+1)}setTimeout(()=>Fe(at)),Xe.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:o,...l}=t,d=useSelectContext(CONTENT_NAME$2,n),f=useSelectContentContext(CONTENT_NAME$2,n),[g,b]=React__namespace.useState(null),[_,S]=React__namespace.useState(null),R=useComposedRefs(e,te=>S(te)),C=useCollection(n),E=React__namespace.useRef(!1),A=React__namespace.useRef(!0),{viewport:M,selectedItem:I,selectedItemText:j,focusSelectedItem:q}=f,z=React__namespace.useCallback(()=>{if(d.trigger&&d.valueNode&&g&&_&&M&&I&&j){const te=d.trigger.getBoundingClientRect(),ne=_.getBoundingClientRect(),se=d.valueNode.getBoundingClientRect(),ge=j.getBoundingClientRect();if(d.dir!=="rtl"){const ot=ge.left-ne.left,Ue=se.left-ot,Ct=te.left-Ue,Je=te.width+Ct,yt=Math.max(Je,ne.width),Mt=window.innerWidth-CONTENT_MARGIN,qt=clamp(Ue,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,Mt-yt)]);g.style.minWidth=Je+"px",g.style.left=qt+"px"}else{const ot=ne.right-ge.right,Ue=window.innerWidth-se.right-ot,Ct=window.innerWidth-te.right-Ue,Je=te.width+Ct,yt=Math.max(Je,ne.width),Mt=window.innerWidth-CONTENT_MARGIN,qt=clamp(Ue,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,Mt-yt)]);g.style.minWidth=Je+"px",g.style.right=qt+"px"}const oe=C(),Ae=window.innerHeight-CONTENT_MARGIN*2,je=M.scrollHeight,Ne=window.getComputedStyle(_),Oe=parseInt(Ne.borderTopWidth,10),Fe=parseInt(Ne.paddingTop,10),ze=parseInt(Ne.borderBottomWidth,10),$e=parseInt(Ne.paddingBottom,10),Be=Oe+Fe+je+$e+ze,qe=Math.min(I.offsetHeight*5,Be),Ge=window.getComputedStyle(M),He=parseInt(Ge.paddingTop,10),Ze=parseInt(Ge.paddingBottom,10),tt=te.top+te.height/2-CONTENT_MARGIN,Ye=Ae-tt,Qe=I.offsetHeight/2,Xe=I.offsetTop+Qe,st=Oe+Fe+Xe,rt=Be-st;if(st<=tt){const ot=oe.length>0&&I===oe[oe.length-1].ref.current;g.style.bottom="0px";const Ue=_.clientHeight-M.offsetTop-M.offsetHeight,Ct=Math.max(Ye,Qe+(ot?Ze:0)+Ue+ze),Je=st+Ct;g.style.height=Je+"px"}else{const ot=oe.length>0&&I===oe[0].ref.current;g.style.top="0px";const Ct=Math.max(tt,Oe+M.offsetTop+(ot?He:0)+Qe)+rt;g.style.height=Ct+"px",M.scrollTop=st-tt+M.offsetTop}g.style.margin=`${CONTENT_MARGIN}px 0`,g.style.minHeight=qe+"px",g.style.maxHeight=Ae+"px",o==null||o(),requestAnimationFrame(()=>E.current=!0)}},[C,d.trigger,d.valueNode,g,_,M,I,j,d.dir,o]);useLayoutEffect2(()=>z(),[z]);const[Q,F]=React__namespace.useState();useLayoutEffect2(()=>{_&&F(window.getComputedStyle(_).zIndex)},[_]);const V=React__namespace.useCallback(te=>{te&&A.current===!0&&(z(),q==null||q(),A.current=!1)},[z,q]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:g,shouldExpandOnScrollRef:E,onScrollButtonChange:V,children:jsxRuntime.jsx("div",{ref:b,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:Q},children:jsxRuntime.jsx(Primitive.div,{...l,ref:R,style:{boxSizing:"border-box",maxHeight:"100%",...l.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,align:o="start",collisionPadding:l=CONTENT_MARGIN,...d}=t,f=usePopperScope$1(n);return jsxRuntime.jsx(Content$1,{...f,...d,ref:e,align:o,collisionPadding:l,style:{boxSizing:"border-box",...d.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$2,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:o,...l}=t,d=useSelectContentContext(VIEWPORT_NAME,n),f=useSelectViewportContext(VIEWPORT_NAME,n),g=useComposedRefs(e,d.onViewportChange),b=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:o}),jsxRuntime.jsx(Collection.Slot,{scope:n,children:jsxRuntime.jsx(Primitive.div,{"data-radix-select-viewport":"",role:"presentation",...l,ref:g,style:{position:"relative",flex:1,overflow:"hidden auto",...l.style},onScroll:composeEventHandlers(l.onScroll,_=>{const S=_.currentTarget,{contentWrapper:R,shouldExpandOnScrollRef:C}=f;if(C!=null&&C.current&&R){const E=Math.abs(b.current-S.scrollTop);if(E>0){const A=window.innerHeight-CONTENT_MARGIN*2,M=parseFloat(R.style.minHeight),I=parseFloat(R.style.height),j=Math.max(M,I);if(j<A){const q=j+E,z=Math.min(A,q),Q=q-z;R.style.height=z+"px",R.style.bottom==="0px"&&(S.scrollTop=Q>0?Q:0,R.style.justifyContent="flex-end")}}}b.current=S.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t,l=useId();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:l,children:jsxRuntime.jsx(Primitive.div,{role:"group","aria-labelledby":l,...o,ref:e})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t,l=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive.div,{id:l.id,...o,ref:e})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME),SelectItem$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,value:o,disabled:l=!1,textValue:d,...f}=t,g=useSelectContext(ITEM_NAME,n),b=useSelectContentContext(ITEM_NAME,n),_=g.value===o,[S,R]=React__namespace.useState(d??""),[C,E]=React__namespace.useState(!1),A=useComposedRefs(e,q=>{var z;return(z=b.itemRefCallback)==null?void 0:z.call(b,q,o,l)}),M=useId(),I=React__namespace.useRef("touch"),j=()=>{l||(g.onValueChange(o),g.onOpenChange(!1))};if(o==="")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:o,disabled:l,textId:M,isSelected:_,onItemTextChange:React__namespace.useCallback(q=>{R(z=>z||((q==null?void 0:q.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection.ItemSlot,{scope:n,value:o,disabled:l,textValue:S,children:jsxRuntime.jsx(Primitive.div,{role:"option","aria-labelledby":M,"data-highlighted":C?"":void 0,"aria-selected":_&&C,"data-state":_?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...f,ref:A,onFocus:composeEventHandlers(f.onFocus,()=>E(!0)),onBlur:composeEventHandlers(f.onBlur,()=>E(!1)),onClick:composeEventHandlers(f.onClick,()=>{I.current!=="mouse"&&j()}),onPointerUp:composeEventHandlers(f.onPointerUp,()=>{I.current==="mouse"&&j()}),onPointerDown:composeEventHandlers(f.onPointerDown,q=>{I.current=q.pointerType}),onPointerMove:composeEventHandlers(f.onPointerMove,q=>{var z;I.current=q.pointerType,l?(z=b.onItemLeave)==null||z.call(b):I.current==="mouse"&&q.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(f.onPointerLeave,q=>{var z;q.currentTarget===document.activeElement&&((z=b.onItemLeave)==null||z.call(b))}),onKeyDown:composeEventHandlers(f.onKeyDown,q=>{var Q;((Q=b.searchRef)==null?void 0:Q.current)!==""&&q.key===" "||(SELECTION_KEYS.includes(q.key)&&j(),q.key===" "&&q.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,className:o,style:l,...d}=t,f=useSelectContext(ITEM_TEXT_NAME,n),g=useSelectContentContext(ITEM_TEXT_NAME,n),b=useSelectItemContext(ITEM_TEXT_NAME,n),_=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[S,R]=React__namespace.useState(null),C=useComposedRefs(e,j=>R(j),b.onItemTextChange,j=>{var q;return(q=g.itemTextRefCallback)==null?void 0:q.call(g,j,b.value,b.disabled)}),E=S==null?void 0:S.textContent,A=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:b.value,disabled:b.disabled,children:E},b.value),[b.disabled,b.value,E]),{onNativeOptionAdd:M,onNativeOptionRemove:I}=_;return useLayoutEffect2(()=>(M(A),()=>I(A)),[M,I,A]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive.span,{id:b.textId,...d,ref:C}),b.isSelected&&f.valueNode&&!f.valueNodeHasChildren?ReactDOM__namespace.createPortal(d.children,f.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive.span,{"aria-hidden":!0,...o,ref:e}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((t,e)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,t.__scopeSelect),o=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,t.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(e,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollTop>0;d(_)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...t,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop-b.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((t,e)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,t.__scopeSelect),o=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,t.__scopeSelect),[l,d]=React__namespace.useState(!1),f=useComposedRefs(e,o.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let g=function(){const _=b.scrollHeight-b.clientHeight,S=Math.ceil(b.scrollTop)<_;d(S)};const b=n.viewport;return g(),b.addEventListener("scroll",g),()=>b.removeEventListener("scroll",g)}},[n.viewport,n.isPositioned]),l?jsxRuntime.jsx(SelectScrollButtonImpl,{...t,ref:f,onAutoScroll:()=>{const{viewport:g,selectedItem:b}=n;g&&b&&(g.scrollTop=g.scrollTop+b.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:o,...l}=t,d=useSelectContentContext("SelectScrollButton",n),f=React__namespace.useRef(null),g=useCollection(n),b=React__namespace.useCallback(()=>{f.current!==null&&(window.clearInterval(f.current),f.current=null)},[]);return React__namespace.useEffect(()=>()=>b(),[b]),useLayoutEffect2(()=>{var S;const _=g().find(R=>R.ref.current===document.activeElement);(S=_==null?void 0:_.ref.current)==null||S.scrollIntoView({block:"nearest"})},[g]),jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...l,ref:e,style:{flexShrink:0,...l.style},onPointerDown:composeEventHandlers(l.onPointerDown,()=>{f.current===null&&(f.current=window.setInterval(o,50))}),onPointerMove:composeEventHandlers(l.onPointerMove,()=>{var _;(_=d.onItemLeave)==null||_.call(d),f.current===null&&(f.current=window.setInterval(o,50))}),onPointerLeave:composeEventHandlers(l.onPointerLeave,()=>{b()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t;return jsxRuntime.jsx(Primitive.div,{"aria-hidden":!0,...o,ref:e})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((t,e)=>{const{__scopeSelect:n,...o}=t,l=usePopperScope$1(n),d=useSelectContext(ARROW_NAME$1,n),f=useSelectContentContext(ARROW_NAME$1,n);return d.open&&f.position==="popper"?jsxRuntime.jsx(Arrow,{...l,...o,ref:e}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:t,value:e,...n},o)=>{const l=React__namespace.useRef(null),d=useComposedRefs(o,l),f=usePrevious(e);return React__namespace.useEffect(()=>{const g=l.current;if(!g)return;const b=window.HTMLSelectElement.prototype,S=Object.getOwnPropertyDescriptor(b,"value").set;if(f!==e&&S){const R=new Event("change",{bubbles:!0});S.call(g,e),g.dispatchEvent(R)}},[f,e]),jsxRuntime.jsx(Primitive.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:d,defaultValue:e})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME;function shouldShowPlaceholder(t){return t===""||t===void 0}function useTypeaheadSearch(t){const e=useCallbackRef$1(t),n=React__namespace.useRef(""),o=React__namespace.useRef(0),l=React__namespace.useCallback(f=>{const g=n.current+f;e(g),function b(_){n.current=_,window.clearTimeout(o.current),_!==""&&(o.current=window.setTimeout(()=>b(""),1e3))}(g)},[e]),d=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(o.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(o.current),[]),[n,l,d]}function findNextItem(t,e,n){const l=e.length>1&&Array.from(e).every(_=>_===e[0])?e[0]:e,d=n?t.indexOf(n):-1;let f=wrapArray(t,Math.max(d,0));l.length===1&&(f=f.filter(_=>_!==n));const b=f.find(_=>_.textValue.toLowerCase().startsWith(l.toLowerCase()));return b!==n?b:void 0}function wrapArray(t,e){return t.map((n,o)=>t[(e+o)%t.length])}var Root2$2=Select$1,Trigger$1=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$2=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item$1=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select=Root2$2,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:t,children:e,...n},o)=>jsxRuntime.jsxs(Trigger$1,{ref:o,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...n,children:[e,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger$1.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",t),...e,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",t),...e,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:t,children:e,position:n="popper",...o},l)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$2,{ref:l,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",t),position:n,...o,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:e}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2$2.displayName;const SelectLabel=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",t),...e}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:t,children:e,...n},o)=>jsxRuntime.jsxs(Item$1,{ref:o,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",t),...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:e})]}));SelectItem.displayName=Item$1.displayName;const SelectSeparator=React__namespace.forwardRef(({className:t,...e},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",t),...e}));SelectSeparator.displayName=Separator.displayName;const DAYS_OF_WEEK=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ManufacturerReorderingCard({manufacturer:t,onSave:e,loading:n=!1,saving:o=!1,readonly:l=!1}){const[d,f]=React.useState({...t}),[g,b]=React.useState({...t});React.useEffect(()=>{b({...t}),f({...t})},[t]);const _=(j,q)=>{l||f(z=>({...z,[j]:q}))},S=(j,q)=>{l||f(z=>({...z,[j]:q}))},R=(j,q)=>{l||f(z=>({...z,[j]:q}))},C=()=>{const j={};return Object.keys(d).forEach(q=>{const z=q;JSON.stringify(d[z])!==JSON.stringify(g[z])&&(j[z]=d[z])}),j},E=()=>{if(!o&&!l){const j=C();Object.keys(j).length>0&&e(j)}},A=j=>j===-1?"ASAP":j===void 0||j<0||j>6?"Sunday":DAYS_OF_WEEK[j],M=j=>j==="ASAP"?-1:DAYS_OF_WEEK.indexOf(j),I=Object.keys(C()).length>0;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[n?jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}):jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Reordering"}),n?jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}):jsxRuntime.jsx(CardDescription,{className:"text-sm",children:"Adjust your reordering settings to control lead times, stocking weeks, minimum orders, and reorder dates, enhancing efficiency in restocking processes."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"automatic-reordering",checked:d.AutoUpdate,onCheckedChange:j=>_("AutoUpdate",j),disabled:o||l}),jsxRuntime.jsx(Label$2,{htmlFor:"automatic-reordering",children:"Automatic Reordering"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"reorder-date",children:"Automatic Reorder Date"}),jsxRuntime.jsxs(Select,{value:A(d.AutoReorderDate),onValueChange:j=>S("AutoReorderDate",M(j)),disabled:o||l,children:[jsxRuntime.jsx(SelectTrigger,{id:"reorder-date",children:jsxRuntime.jsx(SelectValue,{placeholder:"Select day"})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"ASAP",children:"ASAP"}),DAYS_OF_WEEK.map(j=>jsxRuntime.jsx(SelectItem,{value:j,children:j},j))]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"weeks-stocking",children:"Default Weeks of Stocking"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"weeks-stocking",type:"number",value:d.DefaultWeeksOfStocking||"",onChange:j=>S("DefaultWeeksOfStocking",Number(j.target.value)),disabled:o||l}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"weeks"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"minimum-order",children:"Default Minimum Order"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"minimum-order",type:"number",className:"pl-6",value:d.DefaultMinimumOrder||"",onChange:j=>S("DefaultMinimumOrder",Number(j.target.value)),disabled:o||l})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"lead-time",children:"Default Lead Time"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"lead-time",type:"number",value:d.DefaultLeadTime||"",onChange:j=>S("DefaultLeadTime",Number(j.target.value)),disabled:o||l}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"days"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"maximum-inventory-value",children:"Default Maximum Inventory Value"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"maximum-inventory-value",type:"number",className:"pl-6",value:d.DefaultMaxInventoryValue||"",onChange:j=>S("DefaultMaxInventoryValue",Number(j.target.value)),disabled:o||l})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"order-confirmations",children:"Send Order Confirmations To"}),jsxRuntime.jsx(Input,{id:"order-confirmations",type:"email",value:d.POEmail||"",onChange:j=>R("POEmail",j.target.value),placeholder:"email@example.com",disabled:o||l})]})]})]})}),!l&&jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button,{onClick:E,disabled:o||!I,children:[o&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}var POPOVER_NAME="Popover",[createPopoverContext,createPopoverScope]=createContextScope(POPOVER_NAME,[createPopperScope]),usePopperScope=createPopperScope(),[PopoverProvider,usePopoverContext]=createPopoverContext(POPOVER_NAME),Popover$1=t=>{const{__scopePopover:e,children:n,open:o,defaultOpen:l,onOpenChange:d,modal:f=!1}=t,g=usePopperScope(e),b=React__namespace.useRef(null),[_,S]=React__namespace.useState(!1),[R,C]=useControllableState({prop:o,defaultProp:l??!1,onChange:d,caller:POPOVER_NAME});return jsxRuntime.jsx(Root2$6,{...g,children:jsxRuntime.jsx(PopoverProvider,{scope:e,contentId:useId(),triggerRef:b,open:R,onOpenChange:C,onOpenToggle:React__namespace.useCallback(()=>C(E=>!E),[C]),hasCustomAnchor:_,onCustomAnchorAdd:React__namespace.useCallback(()=>S(!0),[]),onCustomAnchorRemove:React__namespace.useCallback(()=>S(!1),[]),modal:f,children:n})})};Popover$1.displayName=POPOVER_NAME;var ANCHOR_NAME="PopoverAnchor",PopoverAnchor$1=React__namespace.forwardRef((t,e)=>{const{__scopePopover:n,...o}=t,l=usePopoverContext(ANCHOR_NAME,n),d=usePopperScope(n),{onCustomAnchorAdd:f,onCustomAnchorRemove:g}=l;return React__namespace.useEffect(()=>(f(),()=>g()),[f,g]),jsxRuntime.jsx(Anchor,{...d,...o,ref:e})});PopoverAnchor$1.displayName=ANCHOR_NAME;var TRIGGER_NAME$1="PopoverTrigger",PopoverTrigger$1=React__namespace.forwardRef((t,e)=>{const{__scopePopover:n,...o}=t,l=usePopoverContext(TRIGGER_NAME$1,n),d=usePopperScope(n),f=useComposedRefs(e,l.triggerRef),g=jsxRuntime.jsx(Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":getState(l.open),...o,ref:f,onClick:composeEventHandlers(t.onClick,l.onOpenToggle)});return l.hasCustomAnchor?g:jsxRuntime.jsx(Anchor,{asChild:!0,...d,children:g})});PopoverTrigger$1.displayName=TRIGGER_NAME$1;var PORTAL_NAME$1="PopoverPortal",[PortalProvider,usePortalContext]=createPopoverContext(PORTAL_NAME$1,{forceMount:void 0}),PopoverPortal=t=>{const{__scopePopover:e,forceMount:n,children:o,container:l}=t,d=usePopoverContext(PORTAL_NAME$1,e);return jsxRuntime.jsx(PortalProvider,{scope:e,forceMount:n,children:jsxRuntime.jsx(Presence,{present:n||d.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:l,children:o})})})};PopoverPortal.displayName=PORTAL_NAME$1;var CONTENT_NAME$1="PopoverContent",PopoverContent$1=React__namespace.forwardRef((t,e)=>{const n=usePortalContext(CONTENT_NAME$1,t.__scopePopover),{forceMount:o=n.forceMount,...l}=t,d=usePopoverContext(CONTENT_NAME$1,t.__scopePopover);return jsxRuntime.jsx(Presence,{present:o||d.open,children:d.modal?jsxRuntime.jsx(PopoverContentModal,{...l,ref:e}):jsxRuntime.jsx(PopoverContentNonModal,{...l,ref:e})})});PopoverContent$1.displayName=CONTENT_NAME$1;var Slot=createSlot("PopoverContent.RemoveScroll"),PopoverContentModal=React__namespace.forwardRef((t,e)=>{const n=usePopoverContext(CONTENT_NAME$1,t.__scopePopover),o=React__namespace.useRef(null),l=useComposedRefs(e,o),d=React__namespace.useRef(!1);return React__namespace.useEffect(()=>{const f=o.current;if(f)return hideOthers(f)},[]),jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(PopoverContentImpl,{...t,ref:l,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(t.onCloseAutoFocus,f=>{var g;f.preventDefault(),d.current||(g=n.triggerRef.current)==null||g.focus()}),onPointerDownOutside:composeEventHandlers(t.onPointerDownOutside,f=>{const g=f.detail.originalEvent,b=g.button===0&&g.ctrlKey===!0,_=g.button===2||b;d.current=_},{checkForDefaultPrevented:!1}),onFocusOutside:composeEventHandlers(t.onFocusOutside,f=>f.preventDefault(),{checkForDefaultPrevented:!1})})})}),PopoverContentNonModal=React__namespace.forwardRef((t,e)=>{const n=usePopoverContext(CONTENT_NAME$1,t.__scopePopover),o=React__namespace.useRef(!1),l=React__namespace.useRef(!1);return jsxRuntime.jsx(PopoverContentImpl,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:d=>{var f,g;(f=t.onCloseAutoFocus)==null||f.call(t,d),d.defaultPrevented||(o.current||(g=n.triggerRef.current)==null||g.focus(),d.preventDefault()),o.current=!1,l.current=!1},onInteractOutside:d=>{var b,_;(b=t.onInteractOutside)==null||b.call(t,d),d.defaultPrevented||(o.current=!0,d.detail.originalEvent.type==="pointerdown"&&(l.current=!0));const f=d.target;((_=n.triggerRef.current)==null?void 0:_.contains(f))&&d.preventDefault(),d.detail.originalEvent.type==="focusin"&&l.current&&d.preventDefault()}})}),PopoverContentImpl=React__namespace.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:o,onOpenAutoFocus:l,onCloseAutoFocus:d,disableOutsidePointerEvents:f,onEscapeKeyDown:g,onPointerDownOutside:b,onFocusOutside:_,onInteractOutside:S,...R}=t,C=usePopoverContext(CONTENT_NAME$1,n),E=usePopperScope(n);return useFocusGuards(),jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:l,onUnmountAutoFocus:d,children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:f,onInteractOutside:S,onEscapeKeyDown:g,onPointerDownOutside:b,onFocusOutside:_,onDismiss:()=>C.onOpenChange(!1),children:jsxRuntime.jsx(Content$1,{"data-state":getState(C.open),role:"dialog",id:C.contentId,...E,...R,ref:e,style:{...R.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),CLOSE_NAME="PopoverClose",PopoverClose=React__namespace.forwardRef((t,e)=>{const{__scopePopover:n,...o}=t,l=usePopoverContext(CLOSE_NAME,n);return jsxRuntime.jsx(Primitive.button,{type:"button",...o,ref:e,onClick:composeEventHandlers(t.onClick,()=>l.onOpenChange(!1))})});PopoverClose.displayName=CLOSE_NAME;var ARROW_NAME="PopoverArrow",PopoverArrow=React__namespace.forwardRef((t,e)=>{const{__scopePopover:n,...o}=t,l=usePopperScope(n);return jsxRuntime.jsx(Arrow,{...l,...o,ref:e})});PopoverArrow.displayName=ARROW_NAME;function getState(t){return t?"open":"closed"}var Root2$1=Popover$1,Anchor2=PopoverAnchor$1,Trigger=PopoverTrigger$1,Portal=PopoverPortal,Content2$1=PopoverContent$1;const Popover=Root2$1,PopoverTrigger=Trigger,PopoverAnchor=Anchor2,PopoverContent=React__namespace.forwardRef(({className:t,align:e="center",sideOffset:n=4,...o},l)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsx(Content2$1,{ref:l,align:e,sideOffset:n,className:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",t),...o})}));PopoverContent.displayName=Content2$1.displayName;function MultiSelect({options:t,selected:e,onChange:n,placeholder:o="Select items...",disabled:l=!1}){const[d,f]=React__namespace.useState(!1),[g,b]=React__namespace.useState(""),_=React__namespace.useRef(null),[S,R]=React__namespace.useState(void 0),C=React__namespace.useCallback(()=>{_.current&&R(_.current.offsetWidth)},[]);React__namespace.useLayoutEffect(()=>{C()},[C]),React__namespace.useEffect(()=>(window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)),[C]);const E=I=>{n(e.filter(j=>j!==I))},A=I=>{f(!1),e.includes(I)?n(e.filter(j=>j!==I)):n([...e,I])},M=I=>{I.key==="Enter"&&g&&!t.includes(g)&&!e.includes(g)&&(I.preventDefault(),A(g),b(""))};return jsxRuntime.jsxs(Popover,{open:d,onOpenChange:f,children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button,{ref:_,variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between h-auto min-h-[40px] py-2",disabled:l,children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1 items-center",children:e.length>0?e.map(I=>jsxRuntime.jsxs(Badge,{variant:"outline",className:"mr-1 mb-1",children:[I,jsxRuntime.jsx("span",{className:"ml-1 cursor-pointer ring-offset-background rounded-full outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",onClick:j=>{j.preventDefault(),j.stopPropagation(),E(I)},children:jsxRuntime.jsx(X$1,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},I)):jsxRuntime.jsx("span",{className:"text-muted-foreground",children:o})}),jsxRuntime.jsx(ChevronsUpDown,{className:"h-4 w-4 shrink-0 opacity-50 ml-2"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-full p-0",style:{width:S},children:jsxRuntime.jsxs(Command,{onKeyDown:M,children:[jsxRuntime.jsx(CommandInput,{placeholder:"Search or add custom item...",value:g,onValueChange:b}),jsxRuntime.jsxs(CommandList,{children:[jsxRuntime.jsx(CommandEmpty,{children:"No item found."}),jsxRuntime.jsxs(CommandGroup,{children:[t.filter(I=>!e.includes(I)).map(I=>jsxRuntime.jsxs(CommandItem,{onSelect:()=>A(I),children:[jsxRuntime.jsx(Check,{className:cn("mr-2 h-4 w-4",e.includes(I)?"opacity-100":"opacity-0")}),I]},I)),g&&!t.includes(g)&&!e.includes(g)&&jsxRuntime.jsxs(CommandItem,{onSelect:()=>A(g),children:['Add "',g,'"']})]})]})]})})]})}const imgSizeMap={sm:100,md:200,lg:300,xl:400},Placeholder=({size:t})=>jsxRuntime.jsx("div",{className:"rounded-md bg-muted flex items-center justify-center",style:{width:t,height:t},"aria-label":"Image not available",children:jsxRuntime.jsx(ImageOff,{className:"h-1/2 w-1/2 text-muted-foreground"})}),VideoSkeleton=()=>jsxRuntime.jsx(Skeleton,{className:"w-full",style:{aspectRatio:"16/9"}});function ProductImage({randmarSKU:t,size:e="md",alt:n,secondaryContent:o}){const[l,d]=React__namespace.useState(!1),[f,g]=React__namespace.useState(!1),[b,_]=React__namespace.useState(!1),S=imgSizeMap[e],R=React.useRef(null),C=useIntersectionObserver({elementRef:R,threshold:.1,rootMargin:"100px"}),{data:E,isFetching:A}=useGetProductByProductNumberImageExistsQuery({productNumber:t},{skip:!t||!C}),{data:M,isFetching:I}=useGetProductByRandmarSkuImageQuery({randmarSku:t,width:S*1.5,height:S*1.5},{skip:!E}),{data:j}=useGetProductByProductNumberVideoExistsQuery({productNumber:t},{skip:!t||!C}),{data:q,isFetching:z}=useGetProductByProductNumberVideoQuery({productNumber:t},{skip:!j||!l}),Q=A||I;async function F(){if(q){_(!0);try{const se=await(await fetch(q)).blob(),ge=window.URL.createObjectURL(se),oe=document.createElement("a");oe.href=ge,oe.download=`${t||"product"}-video.mp4`,document.body.appendChild(oe),oe.click(),document.body.removeChild(oe),window.URL.revokeObjectURL(ge)}catch(ne){console.error("Error downloading video:",ne)}finally{_(!1)}}}function V(){navigator.clipboard.writeText(`https://api.randmar.io/Product/${t}/Video`),g(!0),setTimeout(()=>g(!1),2e3)}function te(){j&&d(!0)}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dialog,{open:l,onOpenChange:d,children:jsxRuntime.jsx(DialogContent,{className:"max-w-4xl p-0 overflow-hidden",children:z||!q?jsxRuntime.jsx(VideoSkeleton,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:o?jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsxs("video",{className:"w-full rounded-l-lg max-h-[720px] object-contain",controls:!0,autoPlay:!0,muted:!0,loop:!0,children:[jsxRuntime.jsx("source",{src:q,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsx("div",{className:"flex-grow min-w-[400px] h-[70vh] p-6",children:o})]}):jsxRuntime.jsxs("div",{className:"w-full relative",children:[jsxRuntime.jsxs("video",{className:"w-full max-h-[720px] object-contain",controls:!0,autoPlay:!0,children:[jsxRuntime.jsx("source",{src:q,type:"video/mp4"}),"Your browser does not support the video tag."]}),jsxRuntime.jsxs("div",{className:"absolute top-2 right-12 flex gap-1",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:V,children:f?jsxRuntime.jsx(Check,{className:"h-4 w-4"}):jsxRuntime.jsx(Copy,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Copy video link"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",onClick:F,disabled:b,children:jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download video"})})]})})]})]})})})}),jsxRuntime.jsxs("div",{className:"relative w-max h-max",ref:R,children:[Q?jsxRuntime.jsx(Skeleton,{className:"rounded-md",style:{width:S,height:S}}):M?jsxRuntime.jsx("img",{alt:n||`Product ${t}`,className:`rounded-md ${j?"cursor-pointer":""}`,onClick:te,src:M,width:S,height:S}):jsxRuntime.jsx(Placeholder,{size:S}),j==!0&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button,{variant:"secondary",size:"icon",className:"absolute top-2 right-2",onClick:te,children:jsxRuntime.jsx(Play,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Play video"})})]})})]})]})}function ResellerBillingOverviewCard({reseller:t,actions:e,loading:n=!1}){return n||!t?jsxRuntime.jsx(ResellerBillingOverviewSkeleton,{}):jsxRuntime.jsx(ResellerBillingOverviewData,{reseller:t,actions:e})}function ResellerBillingOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-40"})})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:Array(3).fill(0).map((t,e)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},e))}),jsxRuntime.jsx("div",{className:"space-y-4",children:Array(2).fill(0).map((t,e)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},e))})]}),jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-28 rounded-md"})})]})]})}function ResellerBillingOverviewData({reseller:t,actions:e}){const n=t.Statement||{},o=[{title:"0 - 30 Days",amount:n.Over0||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"31 - 45 Days",amount:n.Over30||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"},{title:"45+ Days",amount:n.Over45||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-primary"}],l=[{title:"Total",amount:n.Total||0,icon:jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-white"}),color:"bg-green-500"},{title:"Credit Limit",amount:t.CreditLimit||0,icon:jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx("div",{className:"space-y-4",children:o.map((d,f)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:d.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${d.color}`,children:d.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:formatMoney(d.amount)})})]},f))}),jsxRuntime.jsx("div",{className:"space-y-4",children:l.map((d,f)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center",children:[jsxRuntime.jsx("h3",{className:"text-sm sm:text-base font-medium",children:d.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${d.color}`,children:d.icon})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("p",{className:"text-base sm:text-lg font-bold",children:formatMoney(d.amount)})})]},f))})]}),e&&jsxRuntime.jsx("div",{className:"flex justify-end mt-4",children:e})]})]})}function ResellerQualificationsCard({qualifications:t=[],loading:e=!1}){return e?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{className:"p-6",children:jsxRuntime.jsx("div",{className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 @lg:grid-cols-5 gap-4 gap-y-8",children:Array.from({length:10}).map((n,o)=>jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-24 rounded-md mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]},o))})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Qualifications"})}),jsxRuntime.jsx(CardContent,{children:t&&t.length>0?jsxRuntime.jsx("div",{className:"p-6",children:jsxRuntime.jsx("div",{className:"flex grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 @lg:grid-cols-5 gap-4 gap-y-8",children:t.map((n,o)=>jsxRuntime.jsx(ManufacturerLogo,{manufacturerId:n.ManufacturerId,opportunityNumber:n.DefaultOpportunityNumber},`${n.ManufacturerId}-${o}`))})}):jsxRuntime.jsx("p",{children:"No qualification available."})})]})}function ManufacturerLogo({manufacturerId:t,opportunityNumber:e}){return jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx("div",{className:"h-12 w-full items-center justify-center mb-2",children:jsxRuntime.jsx(PartnerLogo,{id:t,width:96,height:48})}),e&&jsxRuntime.jsx(Badge,{variant:"outline",className:"text-xs",children:e})]})}function SalesOverviewCard({salesData:t,salesStatistics:e=[],loading:n=!1}){return n||!t?jsxRuntime.jsx(SalesOverviewSkeleton,{}):jsxRuntime.jsx(SalesOverviewData,{salesData:t,salesStatistics:e})}function SalesOverviewSkeleton(){return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg @sm:text-xl",children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})})}),jsxRuntime.jsxs(CardContent,{className:"pt-4 px-3 @sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 @lg:grid-cols-3 gap-4",children:Array(3).fill(0).map((t,e)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-28"})]})]},e))}),jsxRuntime.jsx("div",{className:"mt-6",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-[250px] w-full rounded-lg"})]})})]})]})}function SalesOverviewData({salesData:t,salesStatistics:e=[]}){const n=[{title:"Last 30 days",amount:t.SalesLast30Days||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-blue-500"},{title:"Last 3 months",amount:t.SalesLast3Months||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-amber-500"},{title:"Year to date",amount:t.SalesYearToDay||0,icon:jsxRuntime.jsx(Calendar,{className:"h-5 w-5 text-white"}),color:"bg-emerald-500"}];return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-lg @sm:text-xl",children:"Sales Overview"})}),jsxRuntime.jsxs(CardContent,{className:"pt-4 px-3 @sm:px-6",children:[jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 @lg:grid-cols-3 gap-4",children:n.map((o,l)=>jsxRuntime.jsxs("div",{className:"border rounded-lg p-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"text-sm @sm:text-base font-medium",children:o.title}),jsxRuntime.jsx("div",{className:`p-2 rounded-full ${o.color}`,children:o.icon})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base @sm:text-lg font-bold",children:formatMoney(o.amount)})]})]},l))}),jsxRuntime.jsx("div",{className:"mt-6",children:e&&e.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("h3",{className:"text-sm font-medium mb-4",children:"Sales Trend"}),jsxRuntime.jsx("div",{className:"space-y-6",children:jsxRuntime.jsx(SalesChart,{statistics:e,chartHeight:300,mode:"week"})})]})})]})]})}var ROOT_NAME="AlertDialog",[createAlertDialogContext,createAlertDialogScope]=createContextScope(ROOT_NAME,[createDialogScope]),useDialogScope=createDialogScope(),AlertDialog$1=t=>{const{__scopeAlertDialog:e,...n}=t,o=useDialogScope(e);return jsxRuntime.jsx(Root$8,{...o,...n,modal:!0})};AlertDialog$1.displayName=ROOT_NAME;var TRIGGER_NAME="AlertDialogTrigger",AlertDialogTrigger$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Trigger$5,{...l,...o,ref:e})});AlertDialogTrigger$1.displayName=TRIGGER_NAME;var PORTAL_NAME="AlertDialogPortal",AlertDialogPortal$1=t=>{const{__scopeAlertDialog:e,...n}=t,o=useDialogScope(e);return jsxRuntime.jsx(Portal$4,{...o,...n})};AlertDialogPortal$1.displayName=PORTAL_NAME;var OVERLAY_NAME="AlertDialogOverlay",AlertDialogOverlay$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Overlay,{...l,...o,ref:e})});AlertDialogOverlay$1.displayName=OVERLAY_NAME;var CONTENT_NAME="AlertDialogContent",[AlertDialogContentProvider,useAlertDialogContentContext]=createAlertDialogContext(CONTENT_NAME),Slottable=createSlottable("AlertDialogContent"),AlertDialogContent$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...l}=t,d=useDialogScope(n),f=React__namespace.useRef(null),g=useComposedRefs(e,f),b=React__namespace.useRef(null);return jsxRuntime.jsx(WarningProvider,{contentName:CONTENT_NAME,titleName:TITLE_NAME,docsSlug:"alert-dialog",children:jsxRuntime.jsx(AlertDialogContentProvider,{scope:n,cancelRef:b,children:jsxRuntime.jsxs(Content$2,{role:"alertdialog",...d,...l,ref:g,onOpenAutoFocus:composeEventHandlers(l.onOpenAutoFocus,_=>{var S;_.preventDefault(),(S=b.current)==null||S.focus({preventScroll:!0})}),onPointerDownOutside:_=>_.preventDefault(),onInteractOutside:_=>_.preventDefault(),children:[jsxRuntime.jsx(Slottable,{children:o}),jsxRuntime.jsx(DescriptionWarning,{contentRef:f})]})})})});AlertDialogContent$1.displayName=CONTENT_NAME;var TITLE_NAME="AlertDialogTitle",AlertDialogTitle$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Title$1,{...l,...o,ref:e})});AlertDialogTitle$1.displayName=TITLE_NAME;var DESCRIPTION_NAME="AlertDialogDescription",AlertDialogDescription$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Description$1,{...l,...o,ref:e})});AlertDialogDescription$1.displayName=DESCRIPTION_NAME;var ACTION_NAME="AlertDialogAction",AlertDialogAction$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,l=useDialogScope(n);return jsxRuntime.jsx(Close$1,{...l,...o,ref:e})});AlertDialogAction$1.displayName=ACTION_NAME;var CANCEL_NAME="AlertDialogCancel",AlertDialogCancel$1=React__namespace.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:l}=useAlertDialogContentContext(CANCEL_NAME,n),d=useDialogScope(n),f=useComposedRefs(e,l);return jsxRuntime.jsx(Close$1,{...d,...o,ref:f})});AlertDialogCancel$1.displayName=CANCEL_NAME;var DescriptionWarning=({contentRef:t})=>{const e=`\`${CONTENT_NAME}\` requires a description for the component to be accessible for screen reader users.
1144
1144
 
1145
1145
  You can add a description to the \`${CONTENT_NAME}\` by passing a \`${DESCRIPTION_NAME}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
1146
1146
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.326.0",
4
+ "version": "1.328.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [