randmarcomps 1.512.0 → 1.513.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.
@@ -60751,14 +60751,14 @@ function ManufacturerInventoryFinanceCard({
60751
60751
  isLoading: t
60752
60752
  }) {
60753
60753
  const {
60754
- data: n,
60754
+ data: n = [],
60755
60755
  isLoading: a,
60756
60756
  isFetching: s
60757
60757
  } = useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({
60758
60758
  routeManufacturerId: (e == null ? void 0 : e.ManufacturerId) ?? ""
60759
60759
  }, {
60760
60760
  skip: !(e != null && e.ManufacturerId)
60761
- }), o = (e == null ? void 0 : e.DefaultMaxInventoryValue) ?? 0, l = (n || []).reduce((g, A) => g + (A.InventoryValue || 0), 0), c = o - l, f = Math.round(l / o * 100);
60761
+ }), o = (e == null ? void 0 : e.DefaultMaxInventoryValue) ?? 0, l = n.reduce((g, A) => g + (A.InventoryValue || 0), 0), c = o - l, f = o > 0 ? Math.round(l / o * 100) : 0;
60762
60762
  return t || a || s ? /* @__PURE__ */ jsxs(Card, { children: [
60763
60763
  /* @__PURE__ */ jsxs(CardHeader, { children: [
60764
60764
  /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-3/4" }),
@@ -60810,7 +60810,7 @@ function ManufacturerInventoryFinanceCard({
60810
60810
  /* @__PURE__ */ jsx(
60811
60811
  "span",
60812
60812
  {
60813
- className: `font-bold ${c >= 0 ? "text-emerald-600 dark:text-emerald-500" : "text-red-600 dark:text-red-500"}`,
60813
+ className: `font-bold ${c >= 0 ? "text-emerald-600" : "text-red-600"}`,
60814
60814
  children: formatMoney(c)
60815
60815
  }
60816
60816
  )
@@ -1260,7 +1260,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let a="<p>An error
1260
1260
  - less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
1261
1261
  - \`null\` or \`undefined\` if the progress is indeterminate.
1262
1262
 
1263
- Defaulting to \`null\`.`}var Root$2=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:e,value:t,...n},s)=>jsxRuntime.jsx(Root$2,{ref:s,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Progress.displayName=Root$2.displayName;function ManufacturerInventoryFinanceCard({manufacturer:e,isLoading:t}){const{data:n,isLoading:s,isFetching:a}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(e==null?void 0:e.ManufacturerId)??""},{skip:!(e!=null&&e.ManufacturerId)}),o=(e==null?void 0:e.DefaultMaxInventoryValue)??0,l=(n||[]).reduce((g,R)=>g+(R.InventoryValue||0),0),c=o-l,f=Math.round(l/o*100);return t||s||a?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-muted-foreground"}),"Inventory Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current inventory financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[o!==0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Max Allowance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(o)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current value"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(l)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available"}),jsxRuntime.jsx("span",{className:`font-bold ${c>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(c)})]})]}),o!==0&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Budget Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[f,"%"]}),f>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:f>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:f,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:e,isLoading:t}){const n=(e==null?void 0:e.CreditLimit)??0,s=(e==null?void 0:e.OutstandingBalance)??0,a=n-s,o=Math.round(s/n*100);return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-muted-foreground"}),"Credit Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current credit financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Limit"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(n)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Outstanding Balance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(s)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Credit"}),jsxRuntime.jsx("span",{className:`font-bold ${a>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(a)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[o,"%"]}),o>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:o>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:o,className:"h-2"})]})]})]})}function SalesChartCard({statistics:e,loading:t=!1,mode:n="month",chartHeight:s=300,className:a,size:o="default"}){return t?jsxRuntime.jsxs(Card,{className:cn("w-full",a),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:s},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),o==="default"&&n==="month"&&jsxRuntime.jsxs("div",{className:"mt-4 flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 rounded-md"})]})]})]}):jsxRuntime.jsxs(Card,{className:cn("w-full",a),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:n==="week"?"Weekly Sales Performance":"Monthly Sales Performance"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(SalesChart,{statistics:e,mode:n,chartHeight:s,size:o})})]})}function ManufacturerOverviewPage({applicationId:e,readonly:t,withReports:n,manufacturer:s,userEmail:a}){const{data:o,isLoading:l,isError:c}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:e,withSpecification:!0},{skip:!!s}),[f,g]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>t?!1:f.publicInfo.hasUnsavedChanges||f.qualifications.hasUnsavedChanges||f.billingInfo.hasUnsavedChanges,[t,f]),A=React.useCallback((Ye,nt)=>{g(et=>{var rt;return((rt=et[Ye])==null?void 0:rt.hasUnsavedChanges)!==nt.hasUnsavedChanges?(console.log(`Updating form state for ${Ye}:`,nt.hasUnsavedChanges),{...et,[Ye]:nt}):et})},[]),{NavigationGuardDialog:V}=useRouterNavigationGuard(R),Ve=s??o;return jsxRuntime.jsxs("div",{className:"@container",children:[c?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your manufacturer information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:Ve==null?void 0:Ve.FiscalYearMonthStart,salesData:Ve==null?void 0:Ve.SalesData,isLoading:l}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(Ve==null?void 0:Ve.SalesStatistics)??[],loading:l}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(Ve==null?void 0:Ve.ManufacturerId)??"",activeOrders:(Ve==null?void 0:Ve.ActiveOrderDetails)??void 0,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:Ve,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:Ve,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:Ve??{},onSave:()=>{},loading:l,readonly:t}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("publicInfo",{hasUnsavedChanges:Ye})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:Ve,readonly:t,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("billingInfo",{hasUnsavedChanges:Ye})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("qualifications",{hasUnsavedChanges:Ye})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(Ve==null?void 0:Ve.ManufacturerId)??"",userEmail:a,isLoading:l})]}),jsxRuntime.jsx(V,{})]})}function ManufacturerCategories({categories:e,activeCategory:t,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsxs("div",{className:"flex gap-2 items-baseline",children:[jsxRuntime.jsx("p",{children:"Category filter:"}),e.map(s=>jsxRuntime.jsxs(Button$1,{onClick:()=>n(s.CategoryCode??""),variant:t===s.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[s.CategoryName??"Undefined",s.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${t!==s.CategoryCode?"text-red-500":""}`})]},s.CategoryCode))]})})})}function CategoryStats(e){const{data:t,isLoading:n,isFetching:s}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e.appID,manufacturerId:e.manufID,categoryCode:e.categoryCode});return jsxRuntime.jsx(Card,{className:"w-full",children:jsxRuntime.jsx(CardContent,{className:"p-4 space-y-1",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:e.categoryName}),jsxRuntime.jsx(SalesChart,{statistics:(t==null?void 0:t.SalesStatistics)??[],loading:n||s,chartHeight:300})]})})})}function ManufacturerCategoriesStats(e){return(e.categories??[]).filter(n=>n.CategoryName).map(n=>jsxRuntime.jsx(CategoryStats,{appID:e.appID,manufID:e.manufID,categoryCode:n.CategoryCode,categoryName:n.CategoryName},`${e.manufID}-${n.CategoryCode}`))}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:e,variant:t,size:n,icon:s,children:a,...o},l)=>jsxRuntime.jsxs("div",{ref:l,className:cn(badgeVariants({variant:t,size:n}),e),...o,children:[s&&jsxRuntime.jsx("span",{className:"mr-1",children:s}),a]}));Badge.displayName="Badge";function ManufacturerCategorySummary({name:e="N/A",niche:t="N/A",productsNumber:n=0,autoreorder:s=!1,starred:a=!1,isLoading:o=!1,children:l}){return o?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-4",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"space-y-1 flex-1",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-28 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-48 bg-muted rounded-md animate-pulse"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-12 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-5 bg-muted rounded-md animate-pulse"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-8 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-32 bg-muted rounded-md animate-pulse"})]}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1 flex-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-16 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-6 bg-muted rounded-md animate-pulse"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex-1 flex flex-col items-end",children:[jsxRuntime.jsx("div",{className:"h-3 w-20 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-6 w-16 bg-muted rounded-md animate-pulse"})]})]})]})]})]}):jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"grid grid-cols-[1fr_auto] items-start gap-4 pt-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Category Name"}),jsxRuntime.jsx("h3",{className:"text-lg font-semibold leading-none tracking-tight",children:e})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Niche"}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:t})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Package,{className:"h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end justify-between gap-4 h-full",children:[l,jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starred"}),a?jsxRuntime.jsx(Star,{className:"h-5 w-5 fill-yellow-400 text-yellow-400"}):jsxRuntime.jsx(Star,{className:"h-5 w-5 text-muted-foreground"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col items-end",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Auto-reorder"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s?jsxRuntime.jsx(RefreshCw,{className:"size-4 text-green-600"}):jsxRuntime.jsx(RefreshCwOff,{className:"size-4 text-amber-600"}),jsxRuntime.jsx(Badge,{variant:s?"default":"secondary",className:cn("text-xs",s?"text-green-600 bg-green-100 hover:bg-green-200":"text-amber-600 bg-amber-100 hover:bg-amber-200"),children:s?"Enabled":"Disabled"})]})]})]})]})})}function createSlot$1(e){const t=createSlotClone$1(e),n=React__namespace.forwardRef((s,a)=>{const{children:o,...l}=s,c=React__namespace.Children.toArray(o),f=c.find(isSlottable$1);if(f){const g=f.props.children,R=c.map(A=>A===f?React__namespace.Children.count(g)>1?React__namespace.Children.only(null):React__namespace.isValidElement(g)?g.props.children:null:A);return jsxRuntime.jsx(t,{...l,ref:a,children:React__namespace.isValidElement(g)?React__namespace.cloneElement(g,void 0,R):null})}return jsxRuntime.jsx(t,{...l,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function createSlotClone$1(e){const t=React__namespace.forwardRef((n,s)=>{const{children:a,...o}=n;if(React__namespace.isValidElement(a)){const l=getElementRef$1(a),c=mergeProps$1(o,a.props);return a.type!==React__namespace.Fragment&&(c.ref=s?composeRefs(s,l):l),React__namespace.cloneElement(a,c)}return React__namespace.Children.count(a)>1?React__namespace.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER$2=Symbol("radix.slottable");function isSlottable$1(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$2}function mergeProps$1(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...c)=>{const f=o(...c);return a(...c),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function getElementRef$1(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection$1,useCollection$1,createCollectionScope$1]=createCollection(SELECT_NAME),[createSelectContext]=createContextScope$2(SELECT_NAME,[createCollectionScope$1,createPopperScope]),usePopperScope$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$2=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:a,onOpenChange:o,value:l,defaultValue:c,onValueChange:f,dir:g,name:R,autoComplete:A,disabled:V,required:Ve,form:Ye}=e,nt=usePopperScope$1(t),[et,rt]=React__namespace.useState(null),[st,ot]=React__namespace.useState(null),[ct,lt]=React__namespace.useState(!1),at=useDirection(g),[ut,pt]=useControllableState({prop:s,defaultProp:a??!1,onChange:o,caller:SELECT_NAME}),[mt,It]=useControllableState({prop:l,defaultProp:c,onChange:f,caller:SELECT_NAME}),Rt=React__namespace.useRef(null),ft=et?Ye||!!et.closest("form"):!0,[Mt,yt]=React__namespace.useState(new Set),Ct=Array.from(Mt).map(Ft=>Ft.props.value).join(";");return jsxRuntime.jsx(Root2$7,{...nt,children:jsxRuntime.jsxs(SelectProvider,{required:Ve,scope:t,trigger:et,onTriggerChange:rt,valueNode:st,onValueNodeChange:ot,valueNodeHasChildren:ct,onValueNodeHasChildrenChange:lt,contentId:useId$1(),value:mt,onValueChange:It,open:ut,onOpenChange:pt,dir:at,triggerPointerDownPosRef:Rt,disabled:V,children:[jsxRuntime.jsx(Collection$1.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Ft=>{yt(Ht=>new Set(Ht).add(Ft))},[]),onNativeOptionRemove:React__namespace.useCallback(Ft=>{yt(Ht=>{const Dt=new Set(Ht);return Dt.delete(Ft),Dt})},[]),children:n})}),ft?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:Ve,tabIndex:-1,name:R,autoComplete:A,value:mt,onChange:Ft=>It(Ft.target.value),disabled:V,form:Ye,children:[mt===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(Mt)]},Ct):null]})})};Select$2.displayName=SELECT_NAME;var TRIGGER_NAME$5="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...a}=e,o=usePopperScope$1(n),l=useSelectContext(TRIGGER_NAME$5,n),c=l.disabled||s,f=useComposedRefs(t,l.onTriggerChange),g=useCollection$1(n),R=React__namespace.useRef("touch"),[A,V,Ve]=useTypeaheadSearch(nt=>{const et=g().filter(ot=>!ot.disabled),rt=et.find(ot=>ot.value===l.value),st=findNextItem(et,nt,rt);st!==void 0&&l.onValueChange(st.value)}),Ye=nt=>{c||(l.onOpenChange(!0),Ve()),nt&&(l.triggerPointerDownPosRef.current={x:Math.round(nt.pageX),y:Math.round(nt.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...o,children:jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":shouldShowPlaceholder(l.value)?"":void 0,...a,ref:f,onClick:composeEventHandlers(a.onClick,nt=>{nt.currentTarget.focus(),R.current!=="mouse"&&Ye(nt)}),onPointerDown:composeEventHandlers(a.onPointerDown,nt=>{R.current=nt.pointerType;const et=nt.target;et.hasPointerCapture(nt.pointerId)&&et.releasePointerCapture(nt.pointerId),nt.button===0&&nt.ctrlKey===!1&&nt.pointerType==="mouse"&&(Ye(nt),nt.preventDefault())}),onKeyDown:composeEventHandlers(a.onKeyDown,nt=>{const et=A.current!=="";!(nt.ctrlKey||nt.altKey||nt.metaKey)&&nt.key.length===1&&V(nt.key),!(et&&nt.key===" ")&&OPEN_KEYS.includes(nt.key)&&(Ye(),nt.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$5;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,children:o,placeholder:l="",...c}=e,f=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:g}=f,R=o!==void 0,A=useComposedRefs(t,f.onValueNodeChange);return useLayoutEffect2(()=>{g(R)},[g,R]),jsxRuntime.jsx(Primitive$4.span,{...c,ref:A,style:{pointerEvents:"none"},children:shouldShowPlaceholder(f.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:l}):o})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...a}=e;return jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$2="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$5,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME$2;var CONTENT_NAME$4="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME$4,e.__scopeSelect),[s,a]=React__namespace.useState();if(useLayoutEffect2(()=>{a(new DocumentFragment)},[]),!n.open){const o=s;return o?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection$1.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),o):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME$4;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$4),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot$1("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:c,sideOffset:f,align:g,alignOffset:R,arrowPadding:A,collisionBoundary:V,collisionPadding:Ve,sticky:Ye,hideWhenDetached:nt,avoidCollisions:et,...rt}=e,st=useSelectContext(CONTENT_NAME$4,n),[ot,ct]=React__namespace.useState(null),[lt,at]=React__namespace.useState(null),ut=useComposedRefs(t,Yt=>ct(Yt)),[pt,mt]=React__namespace.useState(null),[It,Rt]=React__namespace.useState(null),ft=useCollection$1(n),[Mt,yt]=React__namespace.useState(!1),Ct=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(ot)return hideOthers(ot)},[ot]),useFocusGuards();const Ft=React__namespace.useCallback(Yt=>{const[fn,...Jt]=ft().map(Kt=>Kt.ref.current),[mn]=Jt.slice(-1),gn=document.activeElement;for(const Kt of Yt)if(Kt===gn||(Kt==null||Kt.scrollIntoView({block:"nearest"}),Kt===fn&&lt&&(lt.scrollTop=0),Kt===mn&&lt&&(lt.scrollTop=lt.scrollHeight),Kt==null||Kt.focus(),document.activeElement!==gn))return},[ft,lt]),Ht=React__namespace.useCallback(()=>Ft([pt,ot]),[Ft,pt,ot]);React__namespace.useEffect(()=>{Mt&&Ht()},[Mt,Ht]);const{onOpenChange:Dt,triggerPointerDownPosRef:$t}=st;React__namespace.useEffect(()=>{if(ot){let Yt={x:0,y:0};const fn=mn=>{var gn,Kt;Yt={x:Math.abs(Math.round(mn.pageX)-(((gn=$t.current)==null?void 0:gn.x)??0)),y:Math.abs(Math.round(mn.pageY)-(((Kt=$t.current)==null?void 0:Kt.y)??0))}},Jt=mn=>{Yt.x<=10&&Yt.y<=10?mn.preventDefault():ot.contains(mn.target)||Dt(!1),document.removeEventListener("pointermove",fn),$t.current=null};return $t.current!==null&&(document.addEventListener("pointermove",fn),document.addEventListener("pointerup",Jt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",fn),document.removeEventListener("pointerup",Jt,{capture:!0})}}},[ot,Dt,$t]),React__namespace.useEffect(()=>{const Yt=()=>Dt(!1);return window.addEventListener("blur",Yt),window.addEventListener("resize",Yt),()=>{window.removeEventListener("blur",Yt),window.removeEventListener("resize",Yt)}},[Dt]);const[zt,en]=useTypeaheadSearch(Yt=>{const fn=ft().filter(gn=>!gn.disabled),Jt=fn.find(gn=>gn.ref.current===document.activeElement),mn=findNextItem(fn,Yt,Jt);mn&&setTimeout(()=>mn.ref.current.focus())}),Xt=React__namespace.useCallback((Yt,fn,Jt)=>{const mn=!Ct.current&&!Jt;(st.value!==void 0&&st.value===fn||mn)&&(mt(Yt),mn&&(Ct.current=!0))},[st.value]),sn=React__namespace.useCallback(()=>ot==null?void 0:ot.focus(),[ot]),un=React__namespace.useCallback((Yt,fn,Jt)=>{const mn=!Ct.current&&!Jt;(st.value!==void 0&&st.value===fn||mn)&&Rt(Yt)},[st.value]),Qt=s==="popper"?SelectPopperPosition:SelectItemAlignedPosition,pn=Qt===SelectPopperPosition?{side:c,sideOffset:f,align:g,alignOffset:R,arrowPadding:A,collisionBoundary:V,collisionPadding:Ve,sticky:Ye,hideWhenDetached:nt,avoidCollisions:et}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:ot,viewport:lt,onViewportChange:at,itemRefCallback:Xt,selectedItem:pt,onItemLeave:sn,itemTextRefCallback:un,focusSelectedItem:Ht,selectedItemText:It,position:s,isPositioned:Mt,searchRef:zt,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:st.open,onMountAutoFocus:Yt=>{Yt.preventDefault()},onUnmountAutoFocus:composeEventHandlers(a,Yt=>{var fn;(fn=st.trigger)==null||fn.focus({preventScroll:!0}),Yt.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Yt=>Yt.preventDefault(),onDismiss:()=>st.onOpenChange(!1),children:jsxRuntime.jsx(Qt,{role:"listbox",id:st.contentId,"data-state":st.open?"open":"closed",dir:st.dir,onContextMenu:Yt=>Yt.preventDefault(),...rt,...pn,onPlaced:()=>yt(!0),ref:ut,style:{display:"flex",flexDirection:"column",outline:"none",...rt.style},onKeyDown:composeEventHandlers(rt.onKeyDown,Yt=>{const fn=Yt.ctrlKey||Yt.altKey||Yt.metaKey;if(Yt.key==="Tab"&&Yt.preventDefault(),!fn&&Yt.key.length===1&&en(Yt.key),["ArrowUp","ArrowDown","Home","End"].includes(Yt.key)){let mn=ft().filter(gn=>!gn.disabled).map(gn=>gn.ref.current);if(["ArrowUp","End"].includes(Yt.key)&&(mn=mn.slice().reverse()),["ArrowUp","ArrowDown"].includes(Yt.key)){const gn=Yt.target,Kt=mn.indexOf(gn);mn=mn.slice(Kt+1)}setTimeout(()=>Ft(mn)),Yt.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...a}=e,o=useSelectContext(CONTENT_NAME$4,n),l=useSelectContentContext(CONTENT_NAME$4,n),[c,f]=React__namespace.useState(null),[g,R]=React__namespace.useState(null),A=useComposedRefs(t,ut=>R(ut)),V=useCollection$1(n),Ve=React__namespace.useRef(!1),Ye=React__namespace.useRef(!0),{viewport:nt,selectedItem:et,selectedItemText:rt,focusSelectedItem:st}=l,ot=React__namespace.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&g&&nt&&et&&rt){const ut=o.trigger.getBoundingClientRect(),pt=g.getBoundingClientRect(),mt=o.valueNode.getBoundingClientRect(),It=rt.getBoundingClientRect();if(o.dir!=="rtl"){const gn=It.left-pt.left,Kt=mt.left-gn,Tn=ut.left-Kt,hn=ut.width+Tn,Sn=Math.max(hn,pt.width),vn=window.innerWidth-CONTENT_MARGIN,Rn=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,vn-Sn)]);c.style.minWidth=hn+"px",c.style.left=Rn+"px"}else{const gn=pt.right-It.right,Kt=window.innerWidth-mt.right-gn,Tn=window.innerWidth-ut.right-Kt,hn=ut.width+Tn,Sn=Math.max(hn,pt.width),vn=window.innerWidth-CONTENT_MARGIN,Rn=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,vn-Sn)]);c.style.minWidth=hn+"px",c.style.right=Rn+"px"}const Rt=V(),ft=window.innerHeight-CONTENT_MARGIN*2,Mt=nt.scrollHeight,yt=window.getComputedStyle(g),Ct=parseInt(yt.borderTopWidth,10),Ft=parseInt(yt.paddingTop,10),Ht=parseInt(yt.borderBottomWidth,10),Dt=parseInt(yt.paddingBottom,10),$t=Ct+Ft+Mt+Dt+Ht,zt=Math.min(et.offsetHeight*5,$t),en=window.getComputedStyle(nt),Xt=parseInt(en.paddingTop,10),sn=parseInt(en.paddingBottom,10),un=ut.top+ut.height/2-CONTENT_MARGIN,Qt=ft-un,pn=et.offsetHeight/2,Yt=et.offsetTop+pn,fn=Ct+Ft+Yt,Jt=$t-fn;if(fn<=un){const gn=Rt.length>0&&et===Rt[Rt.length-1].ref.current;c.style.bottom="0px";const Kt=g.clientHeight-nt.offsetTop-nt.offsetHeight,Tn=Math.max(Qt,pn+(gn?sn:0)+Kt+Ht),hn=fn+Tn;c.style.height=hn+"px"}else{const gn=Rt.length>0&&et===Rt[0].ref.current;c.style.top="0px";const Tn=Math.max(un,Ct+nt.offsetTop+(gn?Xt:0)+pn)+Jt;c.style.height=Tn+"px",nt.scrollTop=fn-un+nt.offsetTop}c.style.margin=`${CONTENT_MARGIN}px 0`,c.style.minHeight=zt+"px",c.style.maxHeight=ft+"px",s==null||s(),requestAnimationFrame(()=>Ve.current=!0)}},[V,o.trigger,o.valueNode,c,g,nt,et,rt,o.dir,s]);useLayoutEffect2(()=>ot(),[ot]);const[ct,lt]=React__namespace.useState();useLayoutEffect2(()=>{g&&lt(window.getComputedStyle(g).zIndex)},[g]);const at=React__namespace.useCallback(ut=>{ut&&Ye.current===!0&&(ot(),st==null||st(),Ye.current=!1)},[ot,st]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:Ve,onScrollButtonChange:at,children:jsxRuntime.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:ct},children:jsxRuntime.jsx(Primitive$4.div,{...a,ref:A,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=CONTENT_MARGIN,...o}=e,l=usePopperScope$1(n);return jsxRuntime.jsx(Content$2,{...l,...o,ref:t,align:s,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME$4,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...a}=e,o=useSelectContentContext(VIEWPORT_NAME,n),l=useSelectViewportContext(VIEWPORT_NAME,n),c=useComposedRefs(t,o.onViewportChange),f=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),jsxRuntime.jsx(Collection$1.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:composeEventHandlers(a.onScroll,g=>{const R=g.currentTarget,{contentWrapper:A,shouldExpandOnScrollRef:V}=l;if(V!=null&&V.current&&A){const Ve=Math.abs(f.current-R.scrollTop);if(Ve>0){const Ye=window.innerHeight-CONTENT_MARGIN*2,nt=parseFloat(A.style.minHeight),et=parseFloat(A.style.height),rt=Math.max(nt,et);if(rt<Ye){const st=rt+Ve,ot=Math.min(Ye,st),ct=st-ot;A.style.height=ot+"px",A.style.bottom==="0px"&&(R.scrollTop=ct>0?ct:0,A.style.justifyContent="flex-end")}}}f.current=R.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=useId$1();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:a,children:jsxRuntime.jsx(Primitive$4.div,{role:"group","aria-labelledby":a,...s,ref:t})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive$4.div,{id:a.id,...s,ref:t})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME$1="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME$1),SelectItem$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:o,...l}=e,c=useSelectContext(ITEM_NAME$1,n),f=useSelectContentContext(ITEM_NAME$1,n),g=c.value===s,[R,A]=React__namespace.useState(o??""),[V,Ve]=React__namespace.useState(!1),Ye=useComposedRefs(t,st=>{var ot;return(ot=f.itemRefCallback)==null?void 0:ot.call(f,st,s,a)}),nt=useId$1(),et=React__namespace.useRef("touch"),rt=()=>{a||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:s,disabled:a,textId:nt,isSelected:g,onItemTextChange:React__namespace.useCallback(st=>{A(ot=>ot||((st==null?void 0:st.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection$1.ItemSlot,{scope:n,value:s,disabled:a,textValue:R,children:jsxRuntime.jsx(Primitive$4.div,{role:"option","aria-labelledby":nt,"data-highlighted":V?"":void 0,"aria-selected":g&&V,"data-state":g?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:Ye,onFocus:composeEventHandlers(l.onFocus,()=>Ve(!0)),onBlur:composeEventHandlers(l.onBlur,()=>Ve(!1)),onClick:composeEventHandlers(l.onClick,()=>{et.current!=="mouse"&&rt()}),onPointerUp:composeEventHandlers(l.onPointerUp,()=>{et.current==="mouse"&&rt()}),onPointerDown:composeEventHandlers(l.onPointerDown,st=>{et.current=st.pointerType}),onPointerMove:composeEventHandlers(l.onPointerMove,st=>{var ot;et.current=st.pointerType,a?(ot=f.onItemLeave)==null||ot.call(f):et.current==="mouse"&&st.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(l.onPointerLeave,st=>{var ot;st.currentTarget===document.activeElement&&((ot=f.onItemLeave)==null||ot.call(f))}),onKeyDown:composeEventHandlers(l.onKeyDown,st=>{var ct;((ct=f.searchRef)==null?void 0:ct.current)!==""&&st.key===" "||(SELECTION_KEYS.includes(st.key)&&rt(),st.key===" "&&st.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME$1;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,...o}=e,l=useSelectContext(ITEM_TEXT_NAME,n),c=useSelectContentContext(ITEM_TEXT_NAME,n),f=useSelectItemContext(ITEM_TEXT_NAME,n),g=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[R,A]=React__namespace.useState(null),V=useComposedRefs(t,rt=>A(rt),f.onItemTextChange,rt=>{var st;return(st=c.itemTextRefCallback)==null?void 0:st.call(c,rt,f.value,f.disabled)}),Ve=R==null?void 0:R.textContent,Ye=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:f.value,disabled:f.disabled,children:Ve},f.value),[f.disabled,f.value,Ve]),{onNativeOptionAdd:nt,onNativeOptionRemove:et}=g;return useLayoutEffect2(()=>(nt(Ye),()=>et(Ye)),[nt,et,Ye]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive$4.span,{id:f.textId,...o,ref:V}),f.isSelected&&l.valueNode&&!l.valueNodeHasChildren?ReactDOM__namespace.createPortal(o.children,l.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...s,ref:t}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),s=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[a,o]=React__namespace.useState(!1),l=useComposedRefs(t,s.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let c=function(){const g=f.scrollTop>0;o(g)};const f=n.viewport;return c(),f.addEventListener("scroll",c),()=>f.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:f}=n;c&&f&&(c.scrollTop=c.scrollTop-f.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),s=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[a,o]=React__namespace.useState(!1),l=useComposedRefs(t,s.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let c=function(){const g=f.scrollHeight-f.clientHeight,R=Math.ceil(f.scrollTop)<g;o(R)};const f=n.viewport;return c(),f.addEventListener("scroll",c),()=>f.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:f}=n;c&&f&&(c.scrollTop=c.scrollTop+f.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=e,o=useSelectContentContext("SelectScrollButton",n),l=React__namespace.useRef(null),c=useCollection$1(n),f=React__namespace.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return React__namespace.useEffect(()=>()=>f(),[f]),useLayoutEffect2(()=>{var R;const g=c().find(A=>A.ref.current===document.activeElement);(R=g==null?void 0:g.ref.current)==null||R.scrollIntoView({block:"nearest"})},[c]),jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:composeEventHandlers(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:composeEventHandlers(a.onPointerMove,()=>{var g;(g=o.onItemLeave)==null||g.call(o),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:composeEventHandlers(a.onPointerLeave,()=>{f()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...s,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=usePopperScope$1(n),o=useSelectContext(ARROW_NAME$1,n),l=useSelectContentContext(ARROW_NAME$1,n);return o.open&&l.position==="popper"?jsxRuntime.jsx(Arrow,{...a,...s,ref:t}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME$1="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const a=React__namespace.useRef(null),o=useComposedRefs(s,a),l=usePrevious(t);return React__namespace.useEffect(()=>{const c=a.current;if(!c)return;const f=window.HTMLSelectElement.prototype,R=Object.getOwnPropertyDescriptor(f,"value").set;if(l!==t&&R){const A=new Event("change",{bubbles:!0});R.call(c,t),c.dispatchEvent(A)}},[l,t]),jsxRuntime.jsx(Primitive$4.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:o,defaultValue:t})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function shouldShowPlaceholder(e){return e===""||e===void 0}function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),s=React__namespace.useRef(0),a=React__namespace.useCallback(l=>{const c=n.current+l;t(c),(function f(g){n.current=g,window.clearTimeout(s.current),g!==""&&(s.current=window.setTimeout(()=>f(""),1e3))})(c)},[t]),o=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,o]}function findNextItem(e,t,n){const a=t.length>1&&Array.from(t).every(g=>g===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let l=wrapArray(e,Math.max(o,0));a.length===1&&(l=l.filter(g=>g!==n));const f=l.find(g=>g.textValue.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function wrapArray(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Root2$3=Select$2,Trigger$2=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$3=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item$2=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select$1=Root2$3,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsxs(Trigger$2,{ref:s,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger$2.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:e,children:t,position:n="popper",...s},a)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$3,{ref:a,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2$3.displayName;const SelectLabel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",e),...t}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsxs(Item$2,{ref:s,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:t})]}));SelectItem.displayName=Item$2.displayName;const SelectSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",e),...t}));SelectSeparator.displayName=Separator.displayName;function ManufacturerProducts({applicationId:e,manufacturer:t,shopifyHostName:n}){var ot,ct,lt,at,ut;const[s]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[a,o]=React.useState(((ct=(ot=t.Categories)==null?void 0:ot[0])==null?void 0:ct.CategoryCode)||""),[l,c]=React.useState(!1),[f,g]=React.useState(!1),[R,A]=React.useState("percentile"),{toast:V}=useToast(),{data:Ve,isLoading:Ye,isFetching:nt}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e,manufacturerId:t.ManufacturerId,categoryCode:a??""},{skip:!t.ManufacturerId||!a}),et=async()=>{try{c(!0),g(!1),await s({routeResellerId:e,manufacturerId:t.ManufacturerId??"",categoryCode:a,shopifyHostName:n}).unwrap()&&V({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(pt){console.error("Error syncing to Shopify:",pt),V({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{c(!1)}},rt=()=>{var pt,mt;return((mt=(pt=t.Categories)==null?void 0:pt.find(It=>It.CategoryCode===a))==null?void 0:mt.CategoryName)||a},st=React.useMemo(()=>Ve!=null&&Ve.Products?[...Ve.Products].sort((pt,mt)=>R==="price-asc"?(pt.MAP??0)-(mt.MAP??0):R==="price-desc"?(mt.MAP??0)-(pt.MAP??0):R==="name"?(pt.Title??"").localeCompare(mt.Title??""):R==="percentile"?(mt.OverallPercentileRank??0)-(pt.OverallPercentileRank??0):0):[],[Ve==null?void 0:Ve.Products,R]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:a,onSelectCategory:o}),jsxRuntime.jsx("div",{className:"mb-4 w-full",children:jsxRuntime.jsx(ManufacturerCategorySummary,{name:rt(),niche:(Ve==null?void 0:Ve.Niche)||"",productsNumber:((lt=Ve==null?void 0:Ve.Products)==null?void 0:lt.length)||0,autoreorder:(Ve==null?void 0:Ve.AutoReorder)||!1,starred:(Ve==null?void 0:Ve.Starred)||!1,isLoading:Ye||nt,children:n&&((at=t.Categories)==null?void 0:at.findIndex(pt=>pt.AvailableToBuy))!==-1&&jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",disabled:l,onClick:()=>g(!0),children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Category to Shopify"]})})})}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx(ManufacturerCategoriesStats,{categories:[(ut=t.Categories)==null?void 0:ut.find(pt=>pt.CategoryCode===a)].filter(Boolean),manufID:t.ManufacturerId,appID:e}),jsxRuntime.jsx(ActiveOrdersCard,{orders:(Ve==null?void 0:Ve.ActiveOrderDetails)??void 0,loading:Ye||nt})]})]}),jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:a,onSelectCategory:o}),jsxRuntime.jsxs("div",{className:"flex justify-between items-center mt-7 mb-4",children:[jsxRuntime.jsx("h4",{className:"text-xl md:text-2xl text-foreground font-bold",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 ms-auto",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Sort by:"}),jsxRuntime.jsxs(Select$1,{value:R,onValueChange:A,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[220px]",children:jsxRuntime.jsx(SelectValue,{})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"price-asc",children:"MAP: Low to High"}),jsxRuntime.jsx(SelectItem,{value:"price-desc",children:"MAP: High to Low"}),jsxRuntime.jsx(SelectItem,{value:"name",children:"Name"}),jsxRuntime.jsx(SelectItem,{value:"percentile",children:"Best Selling"})]})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:Ye||nt?Array.from({length:4}).map((pt,mt)=>jsxRuntime.jsx(ProductCard,{},mt)):st.length>0?st.map(pt=>jsxRuntime.jsx(ProductCard,{applicationId:e,product:pt,viewProductLink:`/${e}/Product/${pt.RandmarSKU}`,shopifyHostname:n},pt.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:g,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the category "',rt(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>g(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:et,disabled:l,children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})})]})}function PartnerRelationshipPage({applicationId:e,partnerId:t,userEmail:n,shopifyHostName:s,isSuperAdmin:a}){var ct,lt,at;const{data:o}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),{data:l,isLoading:c,isFetching:f}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:e,partnerId:t,withSpecification:!0}),{toast:g}=useToast(),[R]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[A,V]=React.useState(!1),[Ve,Ye]=React.useState(!1),nt=async()=>{try{V(!0),Ye(!1),await R({routeResellerId:e??"",manufacturerId:t??"",shopifyHostName:s}).unwrap()&&g({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(ut){console.error("Error syncing to Shopify:",ut),g({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{V(!1)}},et=()=>l!=null&&l.Manufacturer?"products":l!=null&&l.Reseller?"reseller-overview":"",rt=()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("tab"),st=()=>{const ut=rt();return ut==="assistant"?"assistant":ut==="reseller-overview"&&(l!=null&&l.Reseller)?"reseller-overview":ut==="manufacturer-overview"&&(l!=null&&l.Manufacturer)?"manufacturer-overview":ut==="products"&&(l!=null&&l.Manufacturer)?"products":et()||"assistant"},ot=usePartnershipAssistantPrompt(o,l);return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:l,loading:c||f,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((l==null?void 0:l.Manufacturer)||c||f)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:l==null?void 0:l.Manufacturer,loading:c||f,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:e,manufacturer:l==null?void 0:l.Manufacturer}),s&&((lt=(ct=l==null?void 0:l.Manufacturer)==null?void 0:ct.Categories)==null?void 0:lt.findIndex(ut=>ut.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:Ve,onOpenChange:Ye,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:A,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Manufacturer to Shopify"]})})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the manufacturer "',(at=l==null?void 0:l.Manufacturer)==null?void 0:at.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>Ye(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:nt,disabled:A,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:l==null?void 0:l.Reseller,loading:c||f})]})]}),((l==null?void 0:l.Reseller)||(l==null?void 0:l.Manufacturer))&&!c&&!f&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:st(),className:"w-full",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"products",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Products"}),jsxRuntime.jsxs(TabsTrigger,{value:"assistant",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:[jsxRuntime.jsx(Bot,{className:"mr-2 w-4 h-4"}),"Assistant"]})]}),(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:l.ApplicationId||"",reseller:l==null?void 0:l.Reseller,userEmail:n,isSuperAdmin:a,withoutReports:!0})})}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:l==null?void 0:l.Manufacturer,applicationId:e,userEmail:n})})}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:e,manufacturer:l.Manufacturer,shopifyHostName:s})})}),jsxRuntime.jsx(TabsContent,{value:"assistant",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(AssistantInsight,{prompt:ot,thinkingPlaceholderText:"Thinking about the relationship..."})})})]})}),(c||f)&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:e,appID:t,isLoading:n,readonly:s,onUnsavedChanges:a})=>{const{toast:o}=useToast(),[l]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[c,f]=React.useState({}),g=React.useMemo(()=>({publicEmail:e.PublicEmail??"",contactName:e.ContactName??"",phone:e.Phone??"",website:e.Website??""}),[e]),{register:R,handleSubmit:A,reset:V,watch:Ve,formState:{errors:Ye,isSubmitting:nt}}=useForm({defaultValues:g}),et=Ve(),rt=React.useCallback(()=>c?JSON.stringify(et)!==JSON.stringify(c):!1,[et,c]);React.useEffect(()=>{a&&a(rt())},[rt,a]),React.useEffect(()=>{e&&Object.keys(e).length>0&&(V(g),f(g))},[e,V,g]);const st=async ct=>{let lt=!0,at=!1;const ut=Object.keys(ct).map(pt=>({key:pt,keyApi:pt.charAt(0).toUpperCase()+pt.slice(1)}));for(const pt of ut){const mt=ct[pt.key],It=e[pt.keyApi];if(mt!==It&&mt!==void 0){at=!0;try{await l({applicationId:t,fieldName:pt.keyApi,newValue:String(mt)}).unwrap()||(lt=!1)}catch(Rt){console.error(`Error updating ${pt.keyApi}:`,Rt),lt=!1}}}lt&&at?(o({title:"Public info",description:"Information updated successfully",variant:"success"}),f({...ct}),a&&a(!1)):lt||o({title:"Updation error",description:"Failed to update",variant:"destructive"})},ot=ct=>!ct||ct.trim()==="";return n?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})})]})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{className:"text-1xl font-bold",children:["Public Information ",s?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(ot(Ve("contactName"))||ot(Ve("publicEmail"))||ot(Ve("website"))||ot(Ve("phone")))&&jsxRuntime.jsxs(Alert,{variant:"destructive",className:"mb-6",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Missing information"}),jsxRuntime.jsx(AlertDescription,{children:"All fields are required to get started at working with Manufacturers."})]}),jsxRuntime.jsxs("form",{onSubmit:A(st),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"contactName",children:"Main Representative *"}),jsxRuntime.jsx(Input,{id:"contactName",placeholder:"John Doe",readOnly:s,...R("contactName",{}),className:Ye.contactName||ot(Ve("contactName"))?"input-error-indicator":""}),Ye.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.contactName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"publicEmail",children:"Public Email *"}),jsxRuntime.jsx(Input,{id:"publicEmail",placeholder:"contact@company.com",readOnly:s,...R("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:Ye.publicEmail||ot(Ve("publicEmail"))?"input-error-indicator":""}),Ye.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.publicEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",readOnly:s,...R("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:Ye.website||ot(Ve("website"))?"input-error-indicator":""}),Ye.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone Number *"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"+1 (555) 123-4567",readOnly:s,...R("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:Ye.phone||ot(Ve("phone"))?"input-error-indicator":""}),Ye.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:nt||s,className:s?"hidden":"",children:nt?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:e,reseller:t,isLoading:n,withoutReports:s,userEmail:a,isSuperAdmin:o}){const{toast:l}=useToast(),{Statement:c,CreditLimit:f}=t,[g,R]=React.useState(!1),[A,V]=React.useState(!1),[Ve,Ye]=React.useState(!1),[nt,et]=React.useState(!1),[rt,st]=React.useState(a||""),[ot,ct]=React.useState(!1),[lt,at]=React.useState((f==null?void 0:f.toString())||""),[ut,{isLoading:pt}]=usePostV4PartnerByApplicationIdAccountResellerCreditLimitMutation(),mt=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar$1},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FormattedNumber,{value:f||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),o&&jsxRuntime.jsx(Button$1,{size:"icon",variant:"outline",className:"ml-2",onClick:()=>{ct(!0),at((f==null?void 0:f.toString())||"")},children:jsxRuntime.jsx(SquarePen,{})})]}),icon:CreditCard}],[It]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),Rt=async Ct=>{Ct?R(!0):V(!0);try{const Ht=(await It({routeResellerId:e,documentNumber:`ST${e}`})).data;if(!Ht)throw new Error("No data received for download.");if(Ct)window.open(Ht);else{const Dt=document.createElement("a");Dt.href=Ht,Dt.download=`ST${e}.pdf`,document.body.appendChild(Dt),Dt.click(),Dt.remove()}l({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Ft){console.error("Download Error:",Ft),l({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{Ct?R(!1):V(!1)}},[ft]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),Mt=async()=>{if(!rt||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(rt)){l({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}Ye(!0);try{await ft({routeResellerId:e,emailAddress:rt}).unwrap(),l({title:"Success",description:`Statement sent to ${rt} successfully.`,variant:"success"}),et(!1)}catch(Ft){console.error("Send Email Error:",Ft),l({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{Ye(!1)}};if(n)return jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-36"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:[1,2,3].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]},Ct))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:[1,2].map(Ct=>jsxRuntime.jsx("div",{className:Ct===2?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]})},Ct))})]}),jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-28"})]})]})]});const yt=!s;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:mt.slice(0,3).map((Ct,Ft)=>jsxRuntime.jsx(BillingItem,{icon:Ct.icon,label:Ct.label,value:Ct.value},Ft))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:mt.slice(3).map((Ct,Ft)=>jsxRuntime.jsx("div",{className:Ft===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:Ct.icon,label:Ct.label,value:Ct.value})},Ft))})]}),yt&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Rt(!0),disabled:g,children:g?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Printer,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Print Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Rt(!1),disabled:A,children:A?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>et(!0),disabled:Ve,children:Ve?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Mail,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Statement"})})]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${e}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button$1,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:nt,onOpenChange:et,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Statement by Email"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the recipient's email address below. The statement will be sent as a PDF attachment."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:rt,onChange:Ct=>st(Ct.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:Mt,disabled:Ve||!rt,children:Ve?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"}),"Send"]})})})]})}),jsxRuntime.jsx(Dialog,{open:ot,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Edit Credit Limit"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the new credit limit for this reseller."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"creditLimit",className:"text-right",children:"Amount"}),jsxRuntime.jsx(Input,{id:"creditLimit",type:"number",value:lt,onChange:Ct=>at(Ct.target.value),className:"col-span-3",placeholder:"0.00"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:async()=>{const Ct=Number(lt);if(isNaN(Ct)){l({title:"Invalid Amount",description:"Please enter a valid number for credit limit.",variant:"destructive"});return}try{await ut({applicationId:e,newValue:Ct}).unwrap(),ct(!1),l({title:"Success",description:"Credit limit updated successfully.",variant:"success"})}catch(Ft){console.error("Update Credit Limit Error:",Ft),l({title:"Error",description:"Failed to update credit limit. Please try again.",variant:"destructive"})}},disabled:pt,children:pt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function BillingItem({icon:e,label:t,value:n}){return jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(e,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:t})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:e,setOpen:t,tier:n,onTierChange:s,isLoading:a}){const o=()=>{t(!1)};return jsxRuntime.jsx(Dialog,{open:e,onOpenChange:t,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Change Pricing Tier"})}),jsxRuntime.jsxs("div",{className:"grid gap-1.5 py-2",children:[jsxRuntime.jsxs("p",{className:"text-lg text-muted-foreground",children:["Requested Pricing Tier: ",jsxRuntime.jsx("span",{className:"font-bold",children:n})]}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If your account qualifies, your pricing will update immediately."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If not, we'll review your request and notify you of the decision."})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:o,disabled:a,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:s,disabled:a,children:a?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=e=>e===1?"The Best":e===2?"Fixed 12.5% GP on all items":e===3?"Advantageous":e===4?"Buying Group":e===5?"Cost":e,getShippingText=e=>e==="A"?"Free or Custom":e==="B"?"Fixed $10 anywhere":e==="C"?`Free shipping on $150+ orders to your location,
1263
+ Defaulting to \`null\`.`}var Root$2=Progress$1,Indicator=ProgressIndicator;const Progress=React__namespace.forwardRef(({className:e,value:t,...n},s)=>jsxRuntime.jsx(Root$2,{ref:s,className:cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:jsxRuntime.jsx(Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Progress.displayName=Root$2.displayName;function ManufacturerInventoryFinanceCard({manufacturer:e,isLoading:t}){const{data:n=[],isLoading:s,isFetching:a}=useGetV4ManufacturerByRouteManufacturerIdInventoryValueQuery({routeManufacturerId:(e==null?void 0:e.ManufacturerId)??""},{skip:!(e!=null&&e.ManufacturerId)}),o=(e==null?void 0:e.DefaultMaxInventoryValue)??0,l=n.reduce((g,R)=>g+(R.InventoryValue||0),0),c=o-l,f=o>0?Math.round(l/o*100):0;return t||s||a?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DollarSign,{className:"h-5 w-5 text-muted-foreground"}),"Inventory Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current inventory financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[o!==0&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Max Allowance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(o)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Current value"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(l)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available"}),jsxRuntime.jsx("span",{className:`font-bold ${c>=0?"text-emerald-600":"text-red-600"}`,children:formatMoney(c)})]})]}),o!==0&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Budget Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[f,"%"]}),f>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:f>80?"High usage alert":"Budget usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:f,className:"h-2"})]})]})]})}function ManufacturerCreditFinanceCard({manufacturer:e,isLoading:t}){const n=(e==null?void 0:e.CreditLimit)??0,s=(e==null?void 0:e.OutstandingBalance)??0,a=n-s,o=Math.round(s/n*100);return t?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/2 mt-2"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/4"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-1/3"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-2 w-full"})]})]})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsxs(CardTitle,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(CreditCard,{className:"h-5 w-5 text-muted-foreground"}),"Credit Finance"]}),jsxRuntime.jsx(CardDescription,{children:"Current credit financial status"})]}),jsxRuntime.jsxs(CardContent,{className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Limit"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(n)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Outstanding Balance"}),jsxRuntime.jsx("span",{className:"font-bold",children:formatMoney(s)})]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Available Credit"}),jsxRuntime.jsx("span",{className:`font-bold ${a>=0?"text-emerald-600 dark:text-emerald-500":"text-red-600 dark:text-red-500"}`,children:formatMoney(a)})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Credit Usage"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:[o,"%"]}),o>80&&jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4 text-amber-500"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:o>80?"High credit usage alert":"Credit usage"})})]})})]}),jsxRuntime.jsx(Progress,{value:o,className:"h-2"})]})]})]})}function SalesChartCard({statistics:e,loading:t=!1,mode:n="month",chartHeight:s=300,className:a,size:o="default"}){return t?jsxRuntime.jsxs(Card,{className:cn("w-full",a),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-48 rounded-md"})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsx("div",{style:{height:s},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}),o==="default"&&n==="month"&&jsxRuntime.jsxs("div",{className:"mt-4 flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40 rounded-md"})]})]})]}):jsxRuntime.jsxs(Card,{className:cn("w-full",a),children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:n==="week"?"Weekly Sales Performance":"Monthly Sales Performance"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(SalesChart,{statistics:e,mode:n,chartHeight:s,size:o})})]})}function ManufacturerOverviewPage({applicationId:e,readonly:t,withReports:n,manufacturer:s,userEmail:a}){const{data:o,isLoading:l,isError:c}=useGetV4PartnerByApplicationIdAccountManufacturerQuery({applicationId:e,withSpecification:!0},{skip:!!s}),[f,g]=React.useState({publicInfo:{hasUnsavedChanges:!1},qualifications:{hasUnsavedChanges:!1},billingInfo:{hasUnsavedChanges:!1}}),R=React.useCallback(()=>t?!1:f.publicInfo.hasUnsavedChanges||f.qualifications.hasUnsavedChanges||f.billingInfo.hasUnsavedChanges,[t,f]),A=React.useCallback((Ye,nt)=>{g(et=>{var rt;return((rt=et[Ye])==null?void 0:rt.hasUnsavedChanges)!==nt.hasUnsavedChanges?(console.log(`Updating form state for ${Ye}:`,nt.hasUnsavedChanges),{...et,[Ye]:nt}):et})},[]),{NavigationGuardDialog:V}=useRouterNavigationGuard(R),Ve=s??o;return jsxRuntime.jsxs("div",{className:"@container",children:[c?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your manufacturer information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:Ve==null?void 0:Ve.FiscalYearMonthStart,salesData:Ve==null?void 0:Ve.SalesData,isLoading:l}),jsxRuntime.jsxs("div",{className:"grid @2xl:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(Ve==null?void 0:Ve.SalesStatistics)??[],loading:l}),jsxRuntime.jsx(ManufacturerResellerOrdersSection,{manufacturerId:(Ve==null?void 0:Ve.ManufacturerId)??"",activeOrders:(Ve==null?void 0:Ve.ActiveOrderDetails)??void 0,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerInventoryFinanceCard,{manufacturer:Ve,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerCreditFinanceCard,{manufacturer:Ve,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerReorderingCard,{manufacturer:Ve??{},onSave:()=>{},loading:l,readonly:t}),n&&jsxRuntime.jsx(ManufacturerPublicInfoSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("publicInfo",{hasUnsavedChanges:Ye})}),n&&jsxRuntime.jsx(OpenToWorkSection,{manufacturer:Ve,readonly:t,isLoading:l}),n&&jsxRuntime.jsx(ManufacturerBillingInfoSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("billingInfo",{hasUnsavedChanges:Ye})}),n&&jsxRuntime.jsx(ManufacturerQualificationsSection,{manufacturer:Ve,readonly:t,isLoading:l,onUnsavedChanges:Ye=>A("qualifications",{hasUnsavedChanges:Ye})})]}),n&&jsxRuntime.jsx(ManufacturerReportsSection,{manufacturerId:(Ve==null?void 0:Ve.ManufacturerId)??"",userEmail:a,isLoading:l})]}),jsxRuntime.jsx(V,{})]})}function ManufacturerCategories({categories:e,activeCategory:t,onSelectCategory:n}){return jsxRuntime.jsx("div",{className:"grid",children:jsxRuntime.jsx("div",{className:"flex overflow-x-auto small-scrollbar pb-4",children:jsxRuntime.jsxs("div",{className:"flex gap-2 items-baseline",children:[jsxRuntime.jsx("p",{children:"Category filter:"}),e.map(s=>jsxRuntime.jsxs(Button$1,{onClick:()=>n(s.CategoryCode??""),variant:t===s.CategoryCode?"default":"outline",size:"sm",className:"px-3 py-1.5 text-xs whitespace-nowrap rounded-full",children:[s.CategoryName??"Undefined",s.QualificationRequired&&jsxRuntime.jsx(ShieldCheck,{className:`ml-1 w-5 h-5 ${t!==s.CategoryCode?"text-red-500":""}`})]},s.CategoryCode))]})})})}function CategoryStats(e){const{data:t,isLoading:n,isFetching:s}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e.appID,manufacturerId:e.manufID,categoryCode:e.categoryCode});return jsxRuntime.jsx(Card,{className:"w-full",children:jsxRuntime.jsx(CardContent,{className:"p-4 space-y-1",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:e.categoryName}),jsxRuntime.jsx(SalesChart,{statistics:(t==null?void 0:t.SalesStatistics)??[],loading:n||s,chartHeight:300})]})})})}function ManufacturerCategoriesStats(e){return(e.categories??[]).filter(n=>n.CategoryName).map(n=>jsxRuntime.jsx(CategoryStats,{appID:e.appID,manufID:e.manufID,categoryCode:n.CategoryCode,categoryName:n.CategoryName},`${e.manufID}-${n.CategoryCode}`))}const badgeVariants=cva("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input hover:bg-accent hover:text-accent-foreground",success:"bg-green-600 text-white hover:bg-green-700",warning:"bg-yellow-500 text-white hover:bg-yellow-600",info:"bg-blue-500 text-white hover:bg-blue-600",ghost:"bg-background hover:bg-accent hover:text-accent-foreground",randmarRed:"bg-randmar-red text-white hover:bg-randmar-red/80",randmarBlue:"bg-randmar-blue text-white hover:bg-randmar-blue/80",randmarPurple:"bg-randmar-purple text-white hover:bg-randmar-purple/80",randmarGreen:"bg-randmar-green text-black hover:bg-randmar-green/80",randmarBlack:"bg-randmar-black text-white hover:bg-randmar-black/80",randmarYellow:"bg-randmar-yellow text-black hover:bg-randmar-yellow/80"},size:{default:"h-6",sm:"h-5 text-[10px]",lg:"h-7 px-3"}},defaultVariants:{variant:"default",size:"default"}}),Badge=React__namespace.forwardRef(({className:e,variant:t,size:n,icon:s,children:a,...o},l)=>jsxRuntime.jsxs("div",{ref:l,className:cn(badgeVariants({variant:t,size:n}),e),...o,children:[s&&jsxRuntime.jsx("span",{className:"mr-1",children:s}),a]}));Badge.displayName="Badge";function ManufacturerCategorySummary({name:e="N/A",niche:t="N/A",productsNumber:n=0,autoreorder:s=!1,starred:a=!1,isLoading:o=!1,children:l}){return o?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{className:"pb-4",children:jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"space-y-1 flex-1",children:jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-28 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-48 bg-muted rounded-md animate-pulse"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-12 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-5 w-5 bg-muted rounded-md animate-pulse"})]})]})}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-8 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-32 bg-muted rounded-md animate-pulse"})]}),jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1 flex-1",children:[jsxRuntime.jsx("div",{className:"h-3 w-16 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-4 w-6 bg-muted rounded-md animate-pulse"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex-1 flex flex-col items-end",children:[jsxRuntime.jsx("div",{className:"h-3 w-20 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4 bg-muted rounded-md animate-pulse"}),jsxRuntime.jsx("div",{className:"h-6 w-16 bg-muted rounded-md animate-pulse"})]})]})]})]})]}):jsxRuntime.jsx(Card,{children:jsxRuntime.jsxs(CardContent,{className:"grid grid-cols-[1fr_auto] items-start gap-4 pt-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Category Name"}),jsxRuntime.jsx("h3",{className:"text-lg font-semibold leading-none tracking-tight",children:e})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Niche"}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:t})]}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Package,{className:"h-4 w-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n})]})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end justify-between gap-4 h-full",children:[l,jsxRuntime.jsxs("div",{className:"flex flex-col items-end gap-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starred"}),a?jsxRuntime.jsx(Star,{className:"h-5 w-5 fill-yellow-400 text-yellow-400"}):jsxRuntime.jsx(Star,{className:"h-5 w-5 text-muted-foreground"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 flex flex-col items-end",children:[jsxRuntime.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Auto-reorder"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s?jsxRuntime.jsx(RefreshCw,{className:"size-4 text-green-600"}):jsxRuntime.jsx(RefreshCwOff,{className:"size-4 text-amber-600"}),jsxRuntime.jsx(Badge,{variant:s?"default":"secondary",className:cn("text-xs",s?"text-green-600 bg-green-100 hover:bg-green-200":"text-amber-600 bg-amber-100 hover:bg-amber-200"),children:s?"Enabled":"Disabled"})]})]})]})]})})}function createSlot$1(e){const t=createSlotClone$1(e),n=React__namespace.forwardRef((s,a)=>{const{children:o,...l}=s,c=React__namespace.Children.toArray(o),f=c.find(isSlottable$1);if(f){const g=f.props.children,R=c.map(A=>A===f?React__namespace.Children.count(g)>1?React__namespace.Children.only(null):React__namespace.isValidElement(g)?g.props.children:null:A);return jsxRuntime.jsx(t,{...l,ref:a,children:React__namespace.isValidElement(g)?React__namespace.cloneElement(g,void 0,R):null})}return jsxRuntime.jsx(t,{...l,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function createSlotClone$1(e){const t=React__namespace.forwardRef((n,s)=>{const{children:a,...o}=n;if(React__namespace.isValidElement(a)){const l=getElementRef$1(a),c=mergeProps$1(o,a.props);return a.type!==React__namespace.Fragment&&(c.ref=s?composeRefs(s,l):l),React__namespace.cloneElement(a,c)}return React__namespace.Children.count(a)>1?React__namespace.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER$2=Symbol("radix.slottable");function isSlottable$1(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$2}function mergeProps$1(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...c)=>{const f=o(...c);return a(...c),f}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function getElementRef$1(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var OPEN_KEYS=[" ","Enter","ArrowUp","ArrowDown"],SELECTION_KEYS=[" ","Enter"],SELECT_NAME="Select",[Collection$1,useCollection$1,createCollectionScope$1]=createCollection(SELECT_NAME),[createSelectContext]=createContextScope$2(SELECT_NAME,[createCollectionScope$1,createPopperScope]),usePopperScope$1=createPopperScope(),[SelectProvider,useSelectContext]=createSelectContext(SELECT_NAME),[SelectNativeOptionsProvider,useSelectNativeOptionsContext]=createSelectContext(SELECT_NAME),Select$2=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:a,onOpenChange:o,value:l,defaultValue:c,onValueChange:f,dir:g,name:R,autoComplete:A,disabled:V,required:Ve,form:Ye}=e,nt=usePopperScope$1(t),[et,rt]=React__namespace.useState(null),[st,ot]=React__namespace.useState(null),[ct,lt]=React__namespace.useState(!1),at=useDirection(g),[ut,pt]=useControllableState({prop:s,defaultProp:a??!1,onChange:o,caller:SELECT_NAME}),[mt,It]=useControllableState({prop:l,defaultProp:c,onChange:f,caller:SELECT_NAME}),Rt=React__namespace.useRef(null),ft=et?Ye||!!et.closest("form"):!0,[Mt,yt]=React__namespace.useState(new Set),Ct=Array.from(Mt).map(Ft=>Ft.props.value).join(";");return jsxRuntime.jsx(Root2$7,{...nt,children:jsxRuntime.jsxs(SelectProvider,{required:Ve,scope:t,trigger:et,onTriggerChange:rt,valueNode:st,onValueNodeChange:ot,valueNodeHasChildren:ct,onValueNodeHasChildrenChange:lt,contentId:useId$1(),value:mt,onValueChange:It,open:ut,onOpenChange:pt,dir:at,triggerPointerDownPosRef:Rt,disabled:V,children:[jsxRuntime.jsx(Collection$1.Provider,{scope:t,children:jsxRuntime.jsx(SelectNativeOptionsProvider,{scope:e.__scopeSelect,onNativeOptionAdd:React__namespace.useCallback(Ft=>{yt(Ht=>new Set(Ht).add(Ft))},[]),onNativeOptionRemove:React__namespace.useCallback(Ft=>{yt(Ht=>{const Dt=new Set(Ht);return Dt.delete(Ft),Dt})},[]),children:n})}),ft?jsxRuntime.jsxs(SelectBubbleInput,{"aria-hidden":!0,required:Ve,tabIndex:-1,name:R,autoComplete:A,value:mt,onChange:Ft=>It(Ft.target.value),disabled:V,form:Ye,children:[mt===void 0?jsxRuntime.jsx("option",{value:""}):null,Array.from(Mt)]},Ct):null]})})};Select$2.displayName=SELECT_NAME;var TRIGGER_NAME$5="SelectTrigger",SelectTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...a}=e,o=usePopperScope$1(n),l=useSelectContext(TRIGGER_NAME$5,n),c=l.disabled||s,f=useComposedRefs(t,l.onTriggerChange),g=useCollection$1(n),R=React__namespace.useRef("touch"),[A,V,Ve]=useTypeaheadSearch(nt=>{const et=g().filter(ot=>!ot.disabled),rt=et.find(ot=>ot.value===l.value),st=findNextItem(et,nt,rt);st!==void 0&&l.onValueChange(st.value)}),Ye=nt=>{c||(l.onOpenChange(!0),Ve()),nt&&(l.triggerPointerDownPosRef.current={x:Math.round(nt.pageX),y:Math.round(nt.pageY)})};return jsxRuntime.jsx(Anchor,{asChild:!0,...o,children:jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":shouldShowPlaceholder(l.value)?"":void 0,...a,ref:f,onClick:composeEventHandlers(a.onClick,nt=>{nt.currentTarget.focus(),R.current!=="mouse"&&Ye(nt)}),onPointerDown:composeEventHandlers(a.onPointerDown,nt=>{R.current=nt.pointerType;const et=nt.target;et.hasPointerCapture(nt.pointerId)&&et.releasePointerCapture(nt.pointerId),nt.button===0&&nt.ctrlKey===!1&&nt.pointerType==="mouse"&&(Ye(nt),nt.preventDefault())}),onKeyDown:composeEventHandlers(a.onKeyDown,nt=>{const et=A.current!=="";!(nt.ctrlKey||nt.altKey||nt.metaKey)&&nt.key.length===1&&V(nt.key),!(et&&nt.key===" ")&&OPEN_KEYS.includes(nt.key)&&(Ye(),nt.preventDefault())})})})});SelectTrigger$1.displayName=TRIGGER_NAME$5;var VALUE_NAME="SelectValue",SelectValue$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,children:o,placeholder:l="",...c}=e,f=useSelectContext(VALUE_NAME,n),{onValueNodeHasChildrenChange:g}=f,R=o!==void 0,A=useComposedRefs(t,f.onValueNodeChange);return useLayoutEffect2(()=>{g(R)},[g,R]),jsxRuntime.jsx(Primitive$4.span,{...c,ref:A,style:{pointerEvents:"none"},children:shouldShowPlaceholder(f.value)?jsxRuntime.jsx(jsxRuntime.Fragment,{children:l}):o})});SelectValue$1.displayName=VALUE_NAME;var ICON_NAME="SelectIcon",SelectIcon=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...a}=e;return jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});SelectIcon.displayName=ICON_NAME;var PORTAL_NAME$2="SelectPortal",SelectPortal=e=>jsxRuntime.jsx(Portal$5,{asChild:!0,...e});SelectPortal.displayName=PORTAL_NAME$2;var CONTENT_NAME$4="SelectContent",SelectContent$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContext(CONTENT_NAME$4,e.__scopeSelect),[s,a]=React__namespace.useState();if(useLayoutEffect2(()=>{a(new DocumentFragment)},[]),!n.open){const o=s;return o?ReactDOM__namespace.createPortal(jsxRuntime.jsx(SelectContentProvider,{scope:e.__scopeSelect,children:jsxRuntime.jsx(Collection$1.Slot,{scope:e.__scopeSelect,children:jsxRuntime.jsx("div",{children:e.children})})}),o):null}return jsxRuntime.jsx(SelectContentImpl,{...e,ref:t})});SelectContent$1.displayName=CONTENT_NAME$4;var CONTENT_MARGIN=10,[SelectContentProvider,useSelectContentContext]=createSelectContext(CONTENT_NAME$4),CONTENT_IMPL_NAME="SelectContentImpl",Slot$1=createSlot$1("SelectContent.RemoveScroll"),SelectContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:c,sideOffset:f,align:g,alignOffset:R,arrowPadding:A,collisionBoundary:V,collisionPadding:Ve,sticky:Ye,hideWhenDetached:nt,avoidCollisions:et,...rt}=e,st=useSelectContext(CONTENT_NAME$4,n),[ot,ct]=React__namespace.useState(null),[lt,at]=React__namespace.useState(null),ut=useComposedRefs(t,Yt=>ct(Yt)),[pt,mt]=React__namespace.useState(null),[It,Rt]=React__namespace.useState(null),ft=useCollection$1(n),[Mt,yt]=React__namespace.useState(!1),Ct=React__namespace.useRef(!1);React__namespace.useEffect(()=>{if(ot)return hideOthers(ot)},[ot]),useFocusGuards();const Ft=React__namespace.useCallback(Yt=>{const[fn,...Jt]=ft().map(Kt=>Kt.ref.current),[mn]=Jt.slice(-1),gn=document.activeElement;for(const Kt of Yt)if(Kt===gn||(Kt==null||Kt.scrollIntoView({block:"nearest"}),Kt===fn&&lt&&(lt.scrollTop=0),Kt===mn&&lt&&(lt.scrollTop=lt.scrollHeight),Kt==null||Kt.focus(),document.activeElement!==gn))return},[ft,lt]),Ht=React__namespace.useCallback(()=>Ft([pt,ot]),[Ft,pt,ot]);React__namespace.useEffect(()=>{Mt&&Ht()},[Mt,Ht]);const{onOpenChange:Dt,triggerPointerDownPosRef:$t}=st;React__namespace.useEffect(()=>{if(ot){let Yt={x:0,y:0};const fn=mn=>{var gn,Kt;Yt={x:Math.abs(Math.round(mn.pageX)-(((gn=$t.current)==null?void 0:gn.x)??0)),y:Math.abs(Math.round(mn.pageY)-(((Kt=$t.current)==null?void 0:Kt.y)??0))}},Jt=mn=>{Yt.x<=10&&Yt.y<=10?mn.preventDefault():ot.contains(mn.target)||Dt(!1),document.removeEventListener("pointermove",fn),$t.current=null};return $t.current!==null&&(document.addEventListener("pointermove",fn),document.addEventListener("pointerup",Jt,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",fn),document.removeEventListener("pointerup",Jt,{capture:!0})}}},[ot,Dt,$t]),React__namespace.useEffect(()=>{const Yt=()=>Dt(!1);return window.addEventListener("blur",Yt),window.addEventListener("resize",Yt),()=>{window.removeEventListener("blur",Yt),window.removeEventListener("resize",Yt)}},[Dt]);const[zt,en]=useTypeaheadSearch(Yt=>{const fn=ft().filter(gn=>!gn.disabled),Jt=fn.find(gn=>gn.ref.current===document.activeElement),mn=findNextItem(fn,Yt,Jt);mn&&setTimeout(()=>mn.ref.current.focus())}),Xt=React__namespace.useCallback((Yt,fn,Jt)=>{const mn=!Ct.current&&!Jt;(st.value!==void 0&&st.value===fn||mn)&&(mt(Yt),mn&&(Ct.current=!0))},[st.value]),sn=React__namespace.useCallback(()=>ot==null?void 0:ot.focus(),[ot]),un=React__namespace.useCallback((Yt,fn,Jt)=>{const mn=!Ct.current&&!Jt;(st.value!==void 0&&st.value===fn||mn)&&Rt(Yt)},[st.value]),Qt=s==="popper"?SelectPopperPosition:SelectItemAlignedPosition,pn=Qt===SelectPopperPosition?{side:c,sideOffset:f,align:g,alignOffset:R,arrowPadding:A,collisionBoundary:V,collisionPadding:Ve,sticky:Ye,hideWhenDetached:nt,avoidCollisions:et}:{};return jsxRuntime.jsx(SelectContentProvider,{scope:n,content:ot,viewport:lt,onViewportChange:at,itemRefCallback:Xt,selectedItem:pt,onItemLeave:sn,itemTextRefCallback:un,focusSelectedItem:Ht,selectedItemText:It,position:s,isPositioned:Mt,searchRef:zt,children:jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,children:jsxRuntime.jsx(FocusScope,{asChild:!0,trapped:st.open,onMountAutoFocus:Yt=>{Yt.preventDefault()},onUnmountAutoFocus:composeEventHandlers(a,Yt=>{var fn;(fn=st.trigger)==null||fn.focus({preventScroll:!0}),Yt.preventDefault()}),children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Yt=>Yt.preventDefault(),onDismiss:()=>st.onOpenChange(!1),children:jsxRuntime.jsx(Qt,{role:"listbox",id:st.contentId,"data-state":st.open?"open":"closed",dir:st.dir,onContextMenu:Yt=>Yt.preventDefault(),...rt,...pn,onPlaced:()=>yt(!0),ref:ut,style:{display:"flex",flexDirection:"column",outline:"none",...rt.style},onKeyDown:composeEventHandlers(rt.onKeyDown,Yt=>{const fn=Yt.ctrlKey||Yt.altKey||Yt.metaKey;if(Yt.key==="Tab"&&Yt.preventDefault(),!fn&&Yt.key.length===1&&en(Yt.key),["ArrowUp","ArrowDown","Home","End"].includes(Yt.key)){let mn=ft().filter(gn=>!gn.disabled).map(gn=>gn.ref.current);if(["ArrowUp","End"].includes(Yt.key)&&(mn=mn.slice().reverse()),["ArrowUp","ArrowDown"].includes(Yt.key)){const gn=Yt.target,Kt=mn.indexOf(gn);mn=mn.slice(Kt+1)}setTimeout(()=>Ft(mn)),Yt.preventDefault()}})})})})})})});SelectContentImpl.displayName=CONTENT_IMPL_NAME;var ITEM_ALIGNED_POSITION_NAME="SelectItemAlignedPosition",SelectItemAlignedPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...a}=e,o=useSelectContext(CONTENT_NAME$4,n),l=useSelectContentContext(CONTENT_NAME$4,n),[c,f]=React__namespace.useState(null),[g,R]=React__namespace.useState(null),A=useComposedRefs(t,ut=>R(ut)),V=useCollection$1(n),Ve=React__namespace.useRef(!1),Ye=React__namespace.useRef(!0),{viewport:nt,selectedItem:et,selectedItemText:rt,focusSelectedItem:st}=l,ot=React__namespace.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&g&&nt&&et&&rt){const ut=o.trigger.getBoundingClientRect(),pt=g.getBoundingClientRect(),mt=o.valueNode.getBoundingClientRect(),It=rt.getBoundingClientRect();if(o.dir!=="rtl"){const gn=It.left-pt.left,Kt=mt.left-gn,Tn=ut.left-Kt,hn=ut.width+Tn,Sn=Math.max(hn,pt.width),vn=window.innerWidth-CONTENT_MARGIN,Rn=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,vn-Sn)]);c.style.minWidth=hn+"px",c.style.left=Rn+"px"}else{const gn=pt.right-It.right,Kt=window.innerWidth-mt.right-gn,Tn=window.innerWidth-ut.right-Kt,hn=ut.width+Tn,Sn=Math.max(hn,pt.width),vn=window.innerWidth-CONTENT_MARGIN,Rn=clamp(Kt,[CONTENT_MARGIN,Math.max(CONTENT_MARGIN,vn-Sn)]);c.style.minWidth=hn+"px",c.style.right=Rn+"px"}const Rt=V(),ft=window.innerHeight-CONTENT_MARGIN*2,Mt=nt.scrollHeight,yt=window.getComputedStyle(g),Ct=parseInt(yt.borderTopWidth,10),Ft=parseInt(yt.paddingTop,10),Ht=parseInt(yt.borderBottomWidth,10),Dt=parseInt(yt.paddingBottom,10),$t=Ct+Ft+Mt+Dt+Ht,zt=Math.min(et.offsetHeight*5,$t),en=window.getComputedStyle(nt),Xt=parseInt(en.paddingTop,10),sn=parseInt(en.paddingBottom,10),un=ut.top+ut.height/2-CONTENT_MARGIN,Qt=ft-un,pn=et.offsetHeight/2,Yt=et.offsetTop+pn,fn=Ct+Ft+Yt,Jt=$t-fn;if(fn<=un){const gn=Rt.length>0&&et===Rt[Rt.length-1].ref.current;c.style.bottom="0px";const Kt=g.clientHeight-nt.offsetTop-nt.offsetHeight,Tn=Math.max(Qt,pn+(gn?sn:0)+Kt+Ht),hn=fn+Tn;c.style.height=hn+"px"}else{const gn=Rt.length>0&&et===Rt[0].ref.current;c.style.top="0px";const Tn=Math.max(un,Ct+nt.offsetTop+(gn?Xt:0)+pn)+Jt;c.style.height=Tn+"px",nt.scrollTop=fn-un+nt.offsetTop}c.style.margin=`${CONTENT_MARGIN}px 0`,c.style.minHeight=zt+"px",c.style.maxHeight=ft+"px",s==null||s(),requestAnimationFrame(()=>Ve.current=!0)}},[V,o.trigger,o.valueNode,c,g,nt,et,rt,o.dir,s]);useLayoutEffect2(()=>ot(),[ot]);const[ct,lt]=React__namespace.useState();useLayoutEffect2(()=>{g&&lt(window.getComputedStyle(g).zIndex)},[g]);const at=React__namespace.useCallback(ut=>{ut&&Ye.current===!0&&(ot(),st==null||st(),Ye.current=!1)},[ot,st]);return jsxRuntime.jsx(SelectViewportProvider,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:Ve,onScrollButtonChange:at,children:jsxRuntime.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:ct},children:jsxRuntime.jsx(Primitive$4.div,{...a,ref:A,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});SelectItemAlignedPosition.displayName=ITEM_ALIGNED_POSITION_NAME;var POPPER_POSITION_NAME="SelectPopperPosition",SelectPopperPosition=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=CONTENT_MARGIN,...o}=e,l=usePopperScope$1(n);return jsxRuntime.jsx(Content$2,{...l,...o,ref:t,align:s,collisionPadding:a,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});SelectPopperPosition.displayName=POPPER_POSITION_NAME;var[SelectViewportProvider,useSelectViewportContext]=createSelectContext(CONTENT_NAME$4,{}),VIEWPORT_NAME="SelectViewport",SelectViewport=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...a}=e,o=useSelectContentContext(VIEWPORT_NAME,n),l=useSelectViewportContext(VIEWPORT_NAME,n),c=useComposedRefs(t,o.onViewportChange),f=React__namespace.useRef(0);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),jsxRuntime.jsx(Collection$1.Slot,{scope:n,children:jsxRuntime.jsx(Primitive$4.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:composeEventHandlers(a.onScroll,g=>{const R=g.currentTarget,{contentWrapper:A,shouldExpandOnScrollRef:V}=l;if(V!=null&&V.current&&A){const Ve=Math.abs(f.current-R.scrollTop);if(Ve>0){const Ye=window.innerHeight-CONTENT_MARGIN*2,nt=parseFloat(A.style.minHeight),et=parseFloat(A.style.height),rt=Math.max(nt,et);if(rt<Ye){const st=rt+Ve,ot=Math.min(Ye,st),ct=st-ot;A.style.height=ot+"px",A.style.bottom==="0px"&&(R.scrollTop=ct>0?ct:0,A.style.justifyContent="flex-end")}}}f.current=R.scrollTop})})})]})});SelectViewport.displayName=VIEWPORT_NAME;var GROUP_NAME="SelectGroup",[SelectGroupContextProvider,useSelectGroupContext]=createSelectContext(GROUP_NAME),SelectGroup$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=useId$1();return jsxRuntime.jsx(SelectGroupContextProvider,{scope:n,id:a,children:jsxRuntime.jsx(Primitive$4.div,{role:"group","aria-labelledby":a,...s,ref:t})})});SelectGroup$1.displayName=GROUP_NAME;var LABEL_NAME="SelectLabel",SelectLabel$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=useSelectGroupContext(LABEL_NAME,n);return jsxRuntime.jsx(Primitive$4.div,{id:a.id,...s,ref:t})});SelectLabel$1.displayName=LABEL_NAME;var ITEM_NAME$1="SelectItem",[SelectItemContextProvider,useSelectItemContext]=createSelectContext(ITEM_NAME$1),SelectItem$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:o,...l}=e,c=useSelectContext(ITEM_NAME$1,n),f=useSelectContentContext(ITEM_NAME$1,n),g=c.value===s,[R,A]=React__namespace.useState(o??""),[V,Ve]=React__namespace.useState(!1),Ye=useComposedRefs(t,st=>{var ot;return(ot=f.itemRefCallback)==null?void 0:ot.call(f,st,s,a)}),nt=useId$1(),et=React__namespace.useRef("touch"),rt=()=>{a||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return jsxRuntime.jsx(SelectItemContextProvider,{scope:n,value:s,disabled:a,textId:nt,isSelected:g,onItemTextChange:React__namespace.useCallback(st=>{A(ot=>ot||((st==null?void 0:st.textContent)??"").trim())},[]),children:jsxRuntime.jsx(Collection$1.ItemSlot,{scope:n,value:s,disabled:a,textValue:R,children:jsxRuntime.jsx(Primitive$4.div,{role:"option","aria-labelledby":nt,"data-highlighted":V?"":void 0,"aria-selected":g&&V,"data-state":g?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:Ye,onFocus:composeEventHandlers(l.onFocus,()=>Ve(!0)),onBlur:composeEventHandlers(l.onBlur,()=>Ve(!1)),onClick:composeEventHandlers(l.onClick,()=>{et.current!=="mouse"&&rt()}),onPointerUp:composeEventHandlers(l.onPointerUp,()=>{et.current==="mouse"&&rt()}),onPointerDown:composeEventHandlers(l.onPointerDown,st=>{et.current=st.pointerType}),onPointerMove:composeEventHandlers(l.onPointerMove,st=>{var ot;et.current=st.pointerType,a?(ot=f.onItemLeave)==null||ot.call(f):et.current==="mouse"&&st.currentTarget.focus({preventScroll:!0})}),onPointerLeave:composeEventHandlers(l.onPointerLeave,st=>{var ot;st.currentTarget===document.activeElement&&((ot=f.onItemLeave)==null||ot.call(f))}),onKeyDown:composeEventHandlers(l.onKeyDown,st=>{var ct;((ct=f.searchRef)==null?void 0:ct.current)!==""&&st.key===" "||(SELECTION_KEYS.includes(st.key)&&rt(),st.key===" "&&st.preventDefault())})})})})});SelectItem$1.displayName=ITEM_NAME$1;var ITEM_TEXT_NAME="SelectItemText",SelectItemText=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,...o}=e,l=useSelectContext(ITEM_TEXT_NAME,n),c=useSelectContentContext(ITEM_TEXT_NAME,n),f=useSelectItemContext(ITEM_TEXT_NAME,n),g=useSelectNativeOptionsContext(ITEM_TEXT_NAME,n),[R,A]=React__namespace.useState(null),V=useComposedRefs(t,rt=>A(rt),f.onItemTextChange,rt=>{var st;return(st=c.itemTextRefCallback)==null?void 0:st.call(c,rt,f.value,f.disabled)}),Ve=R==null?void 0:R.textContent,Ye=React__namespace.useMemo(()=>jsxRuntime.jsx("option",{value:f.value,disabled:f.disabled,children:Ve},f.value),[f.disabled,f.value,Ve]),{onNativeOptionAdd:nt,onNativeOptionRemove:et}=g;return useLayoutEffect2(()=>(nt(Ye),()=>et(Ye)),[nt,et,Ye]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Primitive$4.span,{id:f.textId,...o,ref:V}),f.isSelected&&l.valueNode&&!l.valueNodeHasChildren?ReactDOM__namespace.createPortal(o.children,l.valueNode):null]})});SelectItemText.displayName=ITEM_TEXT_NAME;var ITEM_INDICATOR_NAME="SelectItemIndicator",SelectItemIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return useSelectItemContext(ITEM_INDICATOR_NAME,n).isSelected?jsxRuntime.jsx(Primitive$4.span,{"aria-hidden":!0,...s,ref:t}):null});SelectItemIndicator.displayName=ITEM_INDICATOR_NAME;var SCROLL_UP_BUTTON_NAME="SelectScrollUpButton",SelectScrollUpButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),s=useSelectViewportContext(SCROLL_UP_BUTTON_NAME,e.__scopeSelect),[a,o]=React__namespace.useState(!1),l=useComposedRefs(t,s.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let c=function(){const g=f.scrollTop>0;o(g)};const f=n.viewport;return c(),f.addEventListener("scroll",c),()=>f.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:f}=n;c&&f&&(c.scrollTop=c.scrollTop-f.offsetHeight)}}):null});SelectScrollUpButton$1.displayName=SCROLL_UP_BUTTON_NAME;var SCROLL_DOWN_BUTTON_NAME="SelectScrollDownButton",SelectScrollDownButton$1=React__namespace.forwardRef((e,t)=>{const n=useSelectContentContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),s=useSelectViewportContext(SCROLL_DOWN_BUTTON_NAME,e.__scopeSelect),[a,o]=React__namespace.useState(!1),l=useComposedRefs(t,s.onScrollButtonChange);return useLayoutEffect2(()=>{if(n.viewport&&n.isPositioned){let c=function(){const g=f.scrollHeight-f.clientHeight,R=Math.ceil(f.scrollTop)<g;o(R)};const f=n.viewport;return c(),f.addEventListener("scroll",c),()=>f.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?jsxRuntime.jsx(SelectScrollButtonImpl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:f}=n;c&&f&&(c.scrollTop=c.scrollTop+f.offsetHeight)}}):null});SelectScrollDownButton$1.displayName=SCROLL_DOWN_BUTTON_NAME;var SelectScrollButtonImpl=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=e,o=useSelectContentContext("SelectScrollButton",n),l=React__namespace.useRef(null),c=useCollection$1(n),f=React__namespace.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return React__namespace.useEffect(()=>()=>f(),[f]),useLayoutEffect2(()=>{var R;const g=c().find(A=>A.ref.current===document.activeElement);(R=g==null?void 0:g.ref.current)==null||R.scrollIntoView({block:"nearest"})},[c]),jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:composeEventHandlers(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:composeEventHandlers(a.onPointerMove,()=>{var g;(g=o.onItemLeave)==null||g.call(o),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:composeEventHandlers(a.onPointerLeave,()=>{f()})})}),SEPARATOR_NAME="SelectSeparator",SelectSeparator$1=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return jsxRuntime.jsx(Primitive$4.div,{"aria-hidden":!0,...s,ref:t})});SelectSeparator$1.displayName=SEPARATOR_NAME;var ARROW_NAME$1="SelectArrow",SelectArrow=React__namespace.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=usePopperScope$1(n),o=useSelectContext(ARROW_NAME$1,n),l=useSelectContentContext(ARROW_NAME$1,n);return o.open&&l.position==="popper"?jsxRuntime.jsx(Arrow,{...a,...s,ref:t}):null});SelectArrow.displayName=ARROW_NAME$1;var BUBBLE_INPUT_NAME$1="SelectBubbleInput",SelectBubbleInput=React__namespace.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const a=React__namespace.useRef(null),o=useComposedRefs(s,a),l=usePrevious(t);return React__namespace.useEffect(()=>{const c=a.current;if(!c)return;const f=window.HTMLSelectElement.prototype,R=Object.getOwnPropertyDescriptor(f,"value").set;if(l!==t&&R){const A=new Event("change",{bubbles:!0});R.call(c,t),c.dispatchEvent(A)}},[l,t]),jsxRuntime.jsx(Primitive$4.select,{...n,style:{...VISUALLY_HIDDEN_STYLES,...n.style},ref:o,defaultValue:t})});SelectBubbleInput.displayName=BUBBLE_INPUT_NAME$1;function shouldShowPlaceholder(e){return e===""||e===void 0}function useTypeaheadSearch(e){const t=useCallbackRef$1(e),n=React__namespace.useRef(""),s=React__namespace.useRef(0),a=React__namespace.useCallback(l=>{const c=n.current+l;t(c),(function f(g){n.current=g,window.clearTimeout(s.current),g!==""&&(s.current=window.setTimeout(()=>f(""),1e3))})(c)},[t]),o=React__namespace.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return React__namespace.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,o]}function findNextItem(e,t,n){const a=t.length>1&&Array.from(t).every(g=>g===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let l=wrapArray(e,Math.max(o,0));a.length===1&&(l=l.filter(g=>g!==n));const f=l.find(g=>g.textValue.toLowerCase().startsWith(a.toLowerCase()));return f!==n?f:void 0}function wrapArray(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Root2$3=Select$2,Trigger$2=SelectTrigger$1,Value=SelectValue$1,Icon=SelectIcon,Portal$1=SelectPortal,Content2$3=SelectContent$1,Viewport=SelectViewport,Group=SelectGroup$1,Label=SelectLabel$1,Item$2=SelectItem$1,ItemText=SelectItemText,ItemIndicator=SelectItemIndicator,ScrollUpButton=SelectScrollUpButton$1,ScrollDownButton=SelectScrollDownButton$1,Separator=SelectSeparator$1;const Select$1=Root2$3,SelectGroup=Group,SelectValue=Value,SelectTrigger=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsxs(Trigger$2,{ref:s,className:cn("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,jsxRuntime.jsx(Icon,{asChild:!0,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));SelectTrigger.displayName=Trigger$2.displayName;const SelectScrollUpButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollUpButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronUp,{className:"h-4 w-4"})}));SelectScrollUpButton.displayName=ScrollUpButton.displayName;const SelectScrollDownButton=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(ScrollDownButton,{ref:n,className:cn("flex cursor-default items-center justify-center py-1",e),...t,children:jsxRuntime.jsx(ChevronDown,{className:"h-4 w-4"})}));SelectScrollDownButton.displayName=ScrollDownButton.displayName;const SelectContent=React__namespace.forwardRef(({className:e,children:t,position:n="popper",...s},a)=>jsxRuntime.jsx(Portal$1,{children:jsxRuntime.jsxs(Content2$3,{ref:a,className:cn("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[jsxRuntime.jsx(SelectScrollUpButton,{}),jsxRuntime.jsx(Viewport,{className:cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),jsxRuntime.jsx(SelectScrollDownButton,{})]})}));SelectContent.displayName=Content2$3.displayName;const SelectLabel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Label,{ref:n,className:cn("px-2 py-1.5 text-sm font-semibold",e),...t}));SelectLabel.displayName=Label.displayName;const SelectItem=React__namespace.forwardRef(({className:e,children:t,...n},s)=>jsxRuntime.jsxs(Item$2,{ref:s,className:cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(ItemIndicator,{children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}),jsxRuntime.jsx(ItemText,{children:t})]}));SelectItem.displayName=Item$2.displayName;const SelectSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Separator,{ref:n,className:cn("-mx-1 my-1 h-px bg-muted",e),...t}));SelectSeparator.displayName=Separator.displayName;function ManufacturerProducts({applicationId:e,manufacturer:t,shopifyHostName:n}){var ot,ct,lt,at,ut;const[s]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeShopifyMutation(),[a,o]=React.useState(((ct=(ot=t.Categories)==null?void 0:ot[0])==null?void 0:ct.CategoryCode)||""),[l,c]=React.useState(!1),[f,g]=React.useState(!1),[R,A]=React.useState("percentile"),{toast:V}=useToast(),{data:Ve,isLoading:Ye,isFetching:nt}=useGetV4ResellerByRouteResellerIdManufacturerAndManufacturerIdCategoryCodeQuery({routeResellerId:e,manufacturerId:t.ManufacturerId,categoryCode:a??""},{skip:!t.ManufacturerId||!a}),et=async()=>{try{c(!0),g(!1),await s({routeResellerId:e,manufacturerId:t.ManufacturerId??"",categoryCode:a,shopifyHostName:n}).unwrap()&&V({title:"Success",description:"Category synced to Shopify successfully",variant:"success"})}catch(pt){console.error("Error syncing to Shopify:",pt),V({title:"Error",description:"Error syncing category to Shopify.",variant:"destructive"})}finally{c(!1)}},rt=()=>{var pt,mt;return((mt=(pt=t.Categories)==null?void 0:pt.find(It=>It.CategoryCode===a))==null?void 0:mt.CategoryName)||a},st=React.useMemo(()=>Ve!=null&&Ve.Products?[...Ve.Products].sort((pt,mt)=>R==="price-asc"?(pt.MAP??0)-(mt.MAP??0):R==="price-desc"?(mt.MAP??0)-(pt.MAP??0):R==="name"?(pt.Title??"").localeCompare(mt.Title??""):R==="percentile"?(mt.OverallPercentileRank??0)-(pt.OverallPercentileRank??0):0):[],[Ve==null?void 0:Ve.Products,R]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"mb-4",children:[jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:a,onSelectCategory:o}),jsxRuntime.jsx("div",{className:"mb-4 w-full",children:jsxRuntime.jsx(ManufacturerCategorySummary,{name:rt(),niche:(Ve==null?void 0:Ve.Niche)||"",productsNumber:((lt=Ve==null?void 0:Ve.Products)==null?void 0:lt.length)||0,autoreorder:(Ve==null?void 0:Ve.AutoReorder)||!1,starred:(Ve==null?void 0:Ve.Starred)||!1,isLoading:Ye||nt,children:n&&((at=t.Categories)==null?void 0:at.findIndex(pt=>pt.AvailableToBuy))!==-1&&jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",disabled:l,onClick:()=>g(!0),children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Category to Shopify"]})})})}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsx(ManufacturerCategoriesStats,{categories:[(ut=t.Categories)==null?void 0:ut.find(pt=>pt.CategoryCode===a)].filter(Boolean),manufID:t.ManufacturerId,appID:e}),jsxRuntime.jsx(ActiveOrdersCard,{orders:(Ve==null?void 0:Ve.ActiveOrderDetails)??void 0,loading:Ye||nt})]})]}),jsxRuntime.jsx(ManufacturerCategories,{categories:t.Categories||[],activeCategory:a,onSelectCategory:o}),jsxRuntime.jsxs("div",{className:"flex justify-between items-center mt-7 mb-4",children:[jsxRuntime.jsx("h4",{className:"text-xl md:text-2xl text-foreground font-bold",children:"Products"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 ms-auto",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"Sort by:"}),jsxRuntime.jsxs(Select$1,{value:R,onValueChange:A,children:[jsxRuntime.jsx(SelectTrigger,{className:"w-[220px]",children:jsxRuntime.jsx(SelectValue,{})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"price-asc",children:"MAP: Low to High"}),jsxRuntime.jsx(SelectItem,{value:"price-desc",children:"MAP: High to Low"}),jsxRuntime.jsx(SelectItem,{value:"name",children:"Name"}),jsxRuntime.jsx(SelectItem,{value:"percentile",children:"Best Selling"})]})]})]})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4 mb-4",children:Ye||nt?Array.from({length:4}).map((pt,mt)=>jsxRuntime.jsx(ProductCard,{},mt)):st.length>0?st.map(pt=>jsxRuntime.jsx(ProductCard,{applicationId:e,product:pt,viewProductLink:`/${e}/Product/${pt.RandmarSKU}`,shopifyHostname:n},pt.RandmarSKU)):jsxRuntime.jsxs(Alert,{variant:"warning",className:"col-span-1 @md:col-span-2",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Warning"}),jsxRuntime.jsx(AlertDescription,{children:"No products found for this manufacturer category."})]})}),jsxRuntime.jsx(Dialog,{open:f,onOpenChange:g,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the category "',rt(),'" to Shopify? This will add all products in this category to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>g(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:et,disabled:l,children:l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})})]})}function PartnerRelationshipPage({applicationId:e,partnerId:t,userEmail:n,shopifyHostName:s,isSuperAdmin:a}){var ct,lt,at;const{data:o}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e}),{data:l,isLoading:c,isFetching:f}=useGetV4PartnerByRouteApplicationIdPartnerAndPartnerIdQuery({routeApplicationId:e,partnerId:t,withSpecification:!0}),{toast:g}=useToast(),[R]=usePostV4ResellerByRouteResellerIdManufacturerAndManufacturerIdShopifyMutation(),[A,V]=React.useState(!1),[Ve,Ye]=React.useState(!1),nt=async()=>{try{V(!0),Ye(!1),await R({routeResellerId:e??"",manufacturerId:t??"",shopifyHostName:s}).unwrap()&&g({title:"Success",description:"Manufacturer synced to Shopify successfully",variant:"success"})}catch(ut){console.error("Error syncing to Shopify:",ut),g({title:"Error",description:"Error syncing manufacturer to Shopify.",variant:"destructive"})}finally{V(!1)}},et=()=>l!=null&&l.Manufacturer?"products":l!=null&&l.Reseller?"reseller-overview":"",rt=()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("tab"),st=()=>{const ut=rt();return ut==="assistant"?"assistant":ut==="reseller-overview"&&(l!=null&&l.Reseller)?"reseller-overview":ut==="manufacturer-overview"&&(l!=null&&l.Manufacturer)?"manufacturer-overview":ut==="products"&&(l!=null&&l.Manufacturer)?"products":et()||"assistant"},ot=usePartnershipAssistantPrompt(o,l);return jsxRuntime.jsxs("div",{className:"@container",children:[jsxRuntime.jsxs("div",{className:"grid gap-4 @2xl:grid-cols-2",children:[jsxRuntime.jsx(PartnerCard,{account:l,loading:c||f,withAbout:!0,withVoice:!1,action:" "}),jsxRuntime.jsxs("div",{className:"grid gap-4",children:[((l==null?void 0:l.Manufacturer)||c||f)&&jsxRuntime.jsx(ManufacturerCard,{manufacturer:l==null?void 0:l.Manufacturer,loading:c||f,mainAction:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(ManufacturerGetStartedButton,{applicationId:e,manufacturer:l==null?void 0:l.Manufacturer}),s&&((lt=(ct=l==null?void 0:l.Manufacturer)==null?void 0:ct.Categories)==null?void 0:lt.findIndex(ut=>ut.AvailableToBuy))!==-1&&jsxRuntime.jsxs(Dialog,{open:Ve,onOpenChange:Ye,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700 ml-2",disabled:A,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2 h-4 w-4"}),"Sync Manufacturer to Shopify"]})})}),jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Confirm Sync to Shopify"}),jsxRuntime.jsxs(DialogDescription,{children:['Are you sure you want to sync the manufacturer "',(at=l==null?void 0:l.Manufacturer)==null?void 0:at.PublicName,'" to Shopify? This will add all products from this manufacturer to your Shopify store.']})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>Ye(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{className:"bg-green-600 hover:bg-green-700",onClick:nt,disabled:A,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Syncing..."]}):"Confirm Sync"})]})]})]})]})}),(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(ResellerCard,{reseller:l==null?void 0:l.Reseller,loading:c||f})]})]}),((l==null?void 0:l.Reseller)||(l==null?void 0:l.Manufacturer))&&!c&&!f&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4",children:jsxRuntime.jsxs(Tabs,{defaultValue:st(),className:"w-full",children:[jsxRuntime.jsxs(TabsList,{className:"inline-flex h-auto items-center justify-center rounded-none border-b bg-transparent p-0",children:[(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(TabsTrigger,{value:"reseller-overview",className:"reseller-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Reseller Overview"}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"manufacturer-overview",className:"manufacturer-theme relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Manufacturer Overview"}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsTrigger,{value:"products",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:"Products"}),jsxRuntime.jsxs(TabsTrigger,{value:"assistant",className:"relative h-12 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 text-sm font-medium text-muted-foreground shadow-none transition-none hover:text-foreground data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none cursor-pointer",children:[jsxRuntime.jsx(Bot,{className:"mr-2 w-4 h-4"}),"Assistant"]})]}),(l==null?void 0:l.Reseller)&&jsxRuntime.jsx(TabsContent,{value:"reseller-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ResellerOverview,{readonly:!0,appID:l.ApplicationId||"",reseller:l==null?void 0:l.Reseller,userEmail:n,isSuperAdmin:a,withoutReports:!0})})}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"manufacturer-overview",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerOverviewPage,{readonly:!0,manufacturer:l==null?void 0:l.Manufacturer,applicationId:e,userEmail:n})})}),(l==null?void 0:l.Manufacturer)&&jsxRuntime.jsx(TabsContent,{value:"products",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(ManufacturerProducts,{applicationId:e,manufacturer:l.Manufacturer,shopifyHostName:s})})}),jsxRuntime.jsx(TabsContent,{value:"assistant",children:jsxRuntime.jsx("div",{className:"mt-4",children:jsxRuntime.jsx(AssistantInsight,{prompt:ot,thinkingPlaceholderText:"Thinking about the relationship..."})})})]})}),(c||f)&&jsxRuntime.jsx("div",{className:"max-w-6xl mx-auto p-4 mt-4 flex justify-center items-center h-32",children:jsxRuntime.jsx(LoaderCircle,{className:"h-8 w-8 animate-spin text-primary"})})]})}const PublicInfo=({reseller:e,appID:t,isLoading:n,readonly:s,onUnsavedChanges:a})=>{const{toast:o}=useToast(),[l]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),[c,f]=React.useState({}),g=React.useMemo(()=>({publicEmail:e.PublicEmail??"",contactName:e.ContactName??"",phone:e.Phone??"",website:e.Website??""}),[e]),{register:R,handleSubmit:A,reset:V,watch:Ve,formState:{errors:Ye,isSubmitting:nt}}=useForm({defaultValues:g}),et=Ve(),rt=React.useCallback(()=>c?JSON.stringify(et)!==JSON.stringify(c):!1,[et,c]);React.useEffect(()=>{a&&a(rt())},[rt,a]),React.useEffect(()=>{e&&Object.keys(e).length>0&&(V(g),f(g))},[e,V,g]);const st=async ct=>{let lt=!0,at=!1;const ut=Object.keys(ct).map(pt=>({key:pt,keyApi:pt.charAt(0).toUpperCase()+pt.slice(1)}));for(const pt of ut){const mt=ct[pt.key],It=e[pt.keyApi];if(mt!==It&&mt!==void 0){at=!0;try{await l({applicationId:t,fieldName:pt.keyApi,newValue:String(mt)}).unwrap()||(lt=!1)}catch(Rt){console.error(`Error updating ${pt.keyApi}:`,Rt),lt=!1}}}lt&&at?(o({title:"Public info",description:"Information updated successfully",variant:"success"}),f({...ct}),a&&a(!1)):lt||o({title:"Updation error",description:"Failed to update",variant:"destructive"})},ot=ct=>!ct||ct.trim()==="";return n?jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Public Information"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"})})]})})]}):jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsxs(CardTitle,{className:"text-1xl font-bold",children:["Public Information ",s?"(read only)":""]})}),jsxRuntime.jsxs(CardContent,{children:[(ot(Ve("contactName"))||ot(Ve("publicEmail"))||ot(Ve("website"))||ot(Ve("phone")))&&jsxRuntime.jsxs(Alert,{variant:"destructive",className:"mb-6",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Missing information"}),jsxRuntime.jsx(AlertDescription,{children:"All fields are required to get started at working with Manufacturers."})]}),jsxRuntime.jsxs("form",{onSubmit:A(st),className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"contactName",children:"Main Representative *"}),jsxRuntime.jsx(Input,{id:"contactName",placeholder:"John Doe",readOnly:s,...R("contactName",{}),className:Ye.contactName||ot(Ve("contactName"))?"input-error-indicator":""}),Ye.contactName&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.contactName.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"publicEmail",children:"Public Email *"}),jsxRuntime.jsx(Input,{id:"publicEmail",placeholder:"contact@company.com",readOnly:s,...R("publicEmail",{pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}}),className:Ye.publicEmail||ot(Ve("publicEmail"))?"input-error-indicator":""}),Ye.publicEmail&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.publicEmail.message})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"website",children:"Website *"}),jsxRuntime.jsx(Input,{id:"website",placeholder:"https://company.com",readOnly:s,...R("website",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:Ye.website||ot(Ve("website"))?"input-error-indicator":""}),Ye.website&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.website.message})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-sm font-medium leading-none",htmlFor:"phone",children:"Phone Number *"}),jsxRuntime.jsx(Input,{id:"phone",placeholder:"+1 (555) 123-4567",readOnly:s,...R("phone",{pattern:{value:/^.{7,}$/,message:"Must be at least 7 characters"}}),className:Ye.phone||ot(Ve("phone"))?"input-error-indicator":""}),Ye.phone&&jsxRuntime.jsx("p",{className:"text-red-500 text-sm",children:Ye.phone.message})]}),jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:nt||s,className:s?"hidden":"",children:nt?"Saving...":"Save"})})]})]})]})};function BillingCard({appID:e,reseller:t,isLoading:n,withoutReports:s,userEmail:a,isSuperAdmin:o}){const{toast:l}=useToast(),{Statement:c,CreditLimit:f}=t,[g,R]=React.useState(!1),[A,V]=React.useState(!1),[Ve,Ye]=React.useState(!1),[nt,et]=React.useState(!1),[rt,st]=React.useState(a||""),[ot,ct]=React.useState(!1),[lt,at]=React.useState((f==null?void 0:f.toString())||""),[ut,{isLoading:pt}]=usePostV4PartnerByApplicationIdAccountResellerCreditLimitMutation(),mt=[{label:"0 - 30 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over0)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:Calendar$1},{label:"31 - 45 Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over30)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarDays},{label:"45+ Days",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Over45)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:CalendarRange},{label:"Total",value:jsxRuntime.jsx(FormattedNumber,{value:(c==null?void 0:c.Total)||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),icon:DollarSign},{label:"Credit Limit",value:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FormattedNumber,{value:f||0,style:"currency",currency:"CAD",currencyDisplay:"symbol"}),o&&jsxRuntime.jsx(Button$1,{size:"icon",variant:"outline",className:"ml-2",onClick:()=>{ct(!0),at((f==null?void 0:f.toString())||"")},children:jsxRuntime.jsx(SquarePen,{})})]}),icon:CreditCard}],[It]=useLazyGetV4ResellerByRouteResellerIdDocumentAndDocumentNumberPdfQuery(),Rt=async Ct=>{Ct?R(!0):V(!0);try{const Ht=(await It({routeResellerId:e,documentNumber:`ST${e}`})).data;if(!Ht)throw new Error("No data received for download.");if(Ct)window.open(Ht);else{const Dt=document.createElement("a");Dt.href=Ht,Dt.download=`ST${e}.pdf`,document.body.appendChild(Dt),Dt.click(),Dt.remove()}l({title:"Success",description:"Statement downloaded successfully.",variant:"success"})}catch(Ft){console.error("Download Error:",Ft),l({title:"Error",description:"An error occurred while downloading the statement. Please try again.",variant:"destructive"})}finally{Ct?R(!1):V(!1)}},[ft]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),Mt=async()=>{if(!rt||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(rt)){l({title:"Invalid Email",description:"Please enter a valid email address.",variant:"destructive"});return}Ye(!0);try{await ft({routeResellerId:e,emailAddress:rt}).unwrap(),l({title:"Success",description:`Statement sent to ${rt} successfully.`,variant:"success"}),et(!1)}catch(Ft){console.error("Send Email Error:",Ft),l({title:"Error",description:"An error occurred while sending the statement. Please try again.",variant:"destructive"})}finally{Ye(!1)}};if(n)return jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-36"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:[1,2,3].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]},Ct))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:[1,2].map(Ct=>jsxRuntime.jsx("div",{className:Ct===2?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-24"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 ms-auto"})]})},Ct))})]}),jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-28"})]})]})]});const yt=!s;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"border-b p-6 md:p-5",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Billing Overview"})}),jsxRuntime.jsxs(CardContent,{className:"p-6 md:p-5",children:[jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 sm:divide-x divide-border",children:[jsxRuntime.jsx("div",{className:"space-y-6 sm:pe-4",children:mt.slice(0,3).map((Ct,Ft)=>jsxRuntime.jsx(BillingItem,{icon:Ct.icon,label:Ct.label,value:Ct.value},Ft))}),jsxRuntime.jsx("div",{className:"space-y-6 sm:ps-4 pt-6 sm:pt-0 mt-6 sm:mt-0 border-t sm:border-t-0 border-border",children:mt.slice(3).map((Ct,Ft)=>jsxRuntime.jsx("div",{className:Ft===1?"pt-6 mt-6 border-t border-border":"",children:jsxRuntime.jsx(BillingItem,{icon:Ct.icon,label:Ct.label,value:Ct.value})},Ft))})]}),yt&&jsxRuntime.jsxs("div",{className:"flex justify-end mt-6 gap-2",children:[jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Rt(!0),disabled:g,children:g?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Printer,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Print Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>Rt(!1),disabled:A,children:A?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Download Statement"})})]})}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{variant:"outline",size:"icon",onClick:()=>et(!0),disabled:Ve,children:Ve?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Mail,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Statement"})})]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:`${window.location.hostname==="dashboard.randmar.io"?"":"https://dashboard.randmar.io"}/${e}/PayInvoice`,target:window.location.hostname==="dashboard.randmar.io"?"_self":"_blank",children:jsxRuntime.jsxs(Button$1,{children:[jsxRuntime.jsx(CreditCard,{className:"mr-2 h-4 w-4"}),"Pay Invoices"]})})]})]})]}),jsxRuntime.jsx(Dialog,{open:nt,onOpenChange:et,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Send Statement by Email"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the recipient's email address below. The statement will be sent as a PDF attachment."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",className:"text-right",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",type:"email",value:rt,onChange:Ct=>st(Ct.target.value),className:"col-span-3",placeholder:"recipient@example.com"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:Mt,disabled:Ve||!rt,children:Ve?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Send,{className:"mr-2 h-4 w-4"}),"Send"]})})})]})}),jsxRuntime.jsx(Dialog,{open:ot,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Edit Credit Limit"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the new credit limit for this reseller."})]}),jsxRuntime.jsx("div",{className:"grid gap-4 py-4",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"creditLimit",className:"text-right",children:"Amount"}),jsxRuntime.jsx(Input,{id:"creditLimit",type:"number",value:lt,onChange:Ct=>at(Ct.target.value),className:"col-span-3",placeholder:"0.00"})]})}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",onClick:async()=>{const Ct=Number(lt);if(isNaN(Ct)){l({title:"Invalid Amount",description:"Please enter a valid number for credit limit.",variant:"destructive"});return}try{await ut({applicationId:e,newValue:Ct}).unwrap(),ct(!1),l({title:"Success",description:"Credit limit updated successfully.",variant:"success"})}catch(Ft){console.error("Update Credit Limit Error:",Ft),l({title:"Error",description:"Failed to update credit limit. Please try again.",variant:"destructive"})}},disabled:pt,children:pt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})})]})})]})}function BillingItem({icon:e,label:t,value:n}){return jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap gap-1.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(e,{className:"size-4 text-muted-foreground"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:t})]}),jsxRuntime.jsx("span",{className:"text-base font-semibold ms-auto",children:n})]})}function ChangePricingTierModal({open:e,setOpen:t,tier:n,onTierChange:s,isLoading:a}){const o=()=>{t(!1)};return jsxRuntime.jsx(Dialog,{open:e,onOpenChange:t,children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[425px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Change Pricing Tier"})}),jsxRuntime.jsxs("div",{className:"grid gap-1.5 py-2",children:[jsxRuntime.jsxs("p",{className:"text-lg text-muted-foreground",children:["Requested Pricing Tier: ",jsxRuntime.jsx("span",{className:"font-bold",children:n})]}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If your account qualifies, your pricing will update immediately."}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"If not, we'll review your request and notify you of the decision."})]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:o,disabled:a,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:s,disabled:a,children:a?"Loading...":`Apply for ${n}`})]})]})})}const getPricingText=e=>e===1?"The Best":e===2?"Fixed 12.5% GP on all items":e===3?"Advantageous":e===4?"Buying Group":e===5?"Cost":e,getShippingText=e=>e==="A"?"Free or Custom":e==="B"?"Fixed $10 anywhere":e==="C"?`Free shipping on $150+ orders to your location,
1264
1264
  $15 for drop shipped orders under $1,500,
1265
1265
  $10 with opportunities under $1,000`:e==="D"?"$15 under $1,500":e==="E"?"Full shipping charges":e,getTermsText=e=>e==="STRIPE"?"Credit card payment":e==="NET30"?"Net 30 days":e,AccountTier=({isSuperAdmin:e,readonly:t,reseller:n,appID:s,isLoading:a})=>{const{toast:o}=useToast(),[l,c]=React.useState(!1),[f,g]=React.useState(""),[R,{isLoading:A}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),V=Ct=>Ct&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco",COOPSCO:"coopsco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Ct]||"",Ve=Ct=>Ct&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Ct]||"",Ye=Ct=>Ct&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Ct]||"",[nt,et]=React.useState(V((n==null?void 0:n.Priority)??"")),[rt,st]=React.useState(Ve((n==null?void 0:n.ShippingProfile)??"")),[ot,ct]=React.useState(Ye(n==null?void 0:n.PriceProfile)),lt=Ct=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",coopsco:"COOPSCO",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Ct]||Ct,at=Ct=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Ct]||Ct,ut=Ct=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Ct]||Ct;React.useEffect(()=>{et(V((n==null?void 0:n.Priority)??"")),st(Ve((n==null?void 0:n.ShippingProfile)??"")),ct(Ye(n==null?void 0:n.PriceProfile))},[n]);const pt=async(Ct,Ft,Ht,Dt)=>{try{(await R({applicationId:s,fieldName:Ct,newValue:Ft})).error?o({title:"Error",description:Dt,variant:"destructive"}):o({title:"Success",description:Ht,variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},mt=async Ct=>{et(Ct);const Ft=lt(Ct);pt("Priority",Ft,`Priority updated to ${Ft}`,"Failed to update priority")},It=async Ct=>{st(Ct);const Ft=at(Ct);pt("ShippingProfile",Ft,`Shipping profile updated to ${Ft}`,"Failed to update shipping profile")},Rt=async Ct=>{ct(Ct);const Ft=ut(Ct);pt("PriceProfile",Ft,`Pricing profile updated to ${Ft}`,"Failed to update pricing profile")},ft=async()=>{try{const Ct=await R({applicationId:s,fieldName:"Tier",newValue:f});Ct.error?o({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Ct.data?o({title:"Success",description:`Pricing Tier changed to ${f}`,variant:"success"}):o({title:"Considered",description:"Request being considered",variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{c(!1),g("")}},Mt=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:e}],yt=Ct=>{g(Ct),c(!0)};return a?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},Ct))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"secondary",className:"bg-green-100 text-green-700 hover:bg-green-200 text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[(n==null?void 0:n.Priority)||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-green-600"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText((n==null?void 0:n.Terms)||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!t&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://randmar.io/pricing",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:t,className:t?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),Mt.map(Ct=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Ct.enabled,onClick:()=>yt(Ct.name),children:Ct.name},Ct.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:A,open:l,setOpen:c,tier:f,onTierChange:ft}),e&&!t&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:nt,onValueChange:mt,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"coopsco",label:"COOPSCO"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ct.value,id:`priority-${Ct.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Ct.value}`,className:"cursor-pointer text-xs",children:Ct.label})]},Ct.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:rt,onValueChange:It,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ct.value,id:`shipping-${Ct.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Ct.value}`,className:"cursor-pointer text-xs",children:Ct.label})]},Ct.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:ot,onValueChange:Rt,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Ct.value,id:`pricing-${Ct.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Ct.value}`,className:"cursor-pointer text-xs",children:Ct.label})]},Ct.value))})]})]})})]})]})};function OrderCategories({openOrders:e=[],isLoading:t=!1}){const n=(e==null?void 0:e.filter(nt=>nt.DocumentType==="Order"))||[],s=(e==null?void 0:e.filter(nt=>nt.DocumentType==="Shipment"))||[],a=n.filter(nt=>nt.WarehouseCode!=="3PLE"),o=a.reduce((nt,et)=>nt+(et.Quantity??0),0),l=a.reduce((nt,et)=>nt+(et.ExtendedPrice??0),0),c=n.filter(nt=>nt.WarehouseCode==="3PLE"),f=c.reduce((nt,et)=>nt+(et.Quantity??0),0),g=c.reduce((nt,et)=>nt+(et.ExtendedPrice??0),0),R=s.reduce((nt,et)=>nt+(et.Quantity??0),0),A=s.reduce((nt,et)=>nt+(et.ExtendedPrice??0),0),V=o+f+R,Ve=l+g+A,Ye=[{name:"All",icon:Package,color:"bg-blue-500",orders:V,amount:Ve},{name:"Processing",icon:RefreshCcw,color:"bg-yellow-500",orders:o,amount:l},{name:"Shipped",icon:Truck,color:"bg-green-500",orders:R,amount:A},{name:"Delayed",icon:CircleAlert,color:"bg-red-500",orders:f,amount:g}];return t?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(nt=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-gray-200 h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},nt))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:Ye.map(nt=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${nt.color} bg-opacity-60 h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:nt.name}),jsxRuntime.jsx("div",{className:`${nt.color} bg-opacity-90 p-2 rounded-full`,children:jsxRuntime.jsx(nt.icon,{className:"size-4 shrink-0 text-white"})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:nt.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:nt.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},nt.name))})})]})}function ReportsSection({isLoading:e,userEmail:t,appID:n}){const{toast:s}=useToast(),[a,{isLoading:o}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[l,{isLoading:c}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[R,{isLoading:A}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[V,{isLoading:Ve}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[Ye,{isLoading:nt}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[et,rt]=React.useState(null),[st,ot]=React.useState(t),[ct,lt]=React.useState(!1),[at,ut]=React.useState("all"),{data:pt,isLoading:mt}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),It=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],Rt=async yt=>{rt(yt),yt.id==="Products"&&ut("all"),lt(!0)},ft=async()=>{if(!(!et||!n))try{switch(et.id){case"Products":{const yt={routeResellerId:n,emailAddress:st};at&&at!=="all"&&(yt.manufacturerId=at),await R(yt).unwrap();break}case"AmazonTrackingFile":await l({routeResellerId:n,emailAddress:st}).unwrap();break;case"WalmartTrackingFile":await a({routeResellerId:n,emailAddress:st}).unwrap();break;case"OpenOrders":await f({routeResellerId:n,emailAddress:st}).unwrap();break;case"Invoices":await V({routeResellerId:n,emailAddress:st}).unwrap();break;case"Statement":await Ye({routeResellerId:n,emailAddress:st}).unwrap();break;default:throw new Error("invalid report id")}s({title:"Report requested",description:`The ${et.title} will be sent to ${st} shortly.`,variant:"success"}),lt(!1)}catch(yt){console.error("Error requesting report:",yt),s({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},Mt=g||A||c||o||nt||Ve;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(yt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},Ct))]},yt))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:It.map(yt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:yt.name}),yt.reports.map(Ct=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-gray-100 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(Ct.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:Ct.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Ct.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>Rt(Ct),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},Ct.id))]},yt.name))})}),jsxRuntime.jsx(Dialog,{open:ct,onOpenChange:lt,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",et==null?void 0:et.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:st,onChange:yt=>ot(yt.target.value),placeholder:"your@email.com",className:"mt-2"})]}),(et==null?void 0:et.id)==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:at,onChange:yt=>ut(yt.target.value),disabled:mt,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!mt&&Array.isArray(pt)&&pt.slice().sort((yt,Ct)=>(yt.PublicName||yt.Name||"").localeCompare(Ct.PublicName||Ct.Name||"")).map(yt=>yt!=null&&yt.ManufacturerId?jsxRuntime.jsx("option",{value:yt.ManufacturerId,children:(yt.PublicName||yt.Name||yt.ManufacturerId)+(yt.OpenToWork?" (Open to Work)":"")},yt.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>lt(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ft,disabled:!st||Mt,children:Mt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:e}){return!e.QualificationId||e.QualificationId==="Suspended"?null:e.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$2,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:e.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),e.QualificationId,e.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:e.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:e,mode:t="month",chartHeight:n,loading:s=!1,size:a="default"}){const[o,l]=React.useState([]),[c,f]=React.useState(!1),g=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"#888",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(s||!e){l([]);return}let R=[];if(t==="week"){const A=new Map;e.forEach(V=>{var Ye;const Ve=((Ye=V.Day)==null?void 0:Ye.toString())||"";if(Ve.length===8){const nt=parseInt(Ve.substring(0,4),10),et=parseInt(Ve.substring(4,6),10)-1,rt=parseInt(Ve.substring(6,8),10),st=new Date(nt,et,rt),ot=new Date(st);ot.setDate(st.getDate()-st.getDay());const ct=`${ot.getFullYear()}-${String(ot.getMonth()+1).padStart(2,"0")}-${String(ot.getDate()).padStart(2,"0")}`,lt=A.get(ct)||{price:0,quantity:0};lt.price+=V.ExtendedPrice||0,lt.quantity+=V.Quantity||0,A.set(ct,lt)}}),R=Array.from(A).sort(([V],[Ve])=>V.localeCompare(Ve)).map(([V,Ve])=>({date:`${V.substring(5,7)}/${V.substring(8,10)}`,dollarVolume:Ve.price,unitsSold:Ve.quantity}))}else{const A=new Date,V=A.getFullYear(),Ve=A.getMonth(),Ye=A.getDate(),nt=`${V}-${(Ve+1).toString().padStart(2,"0")}`,et=Array.from({length:12},(st,ot)=>{const ct=new Date(V,Ve-(11-ot),1);return`${ct.getFullYear()}-${(ct.getMonth()+1).toString().padStart(2,"0")}`}),rt=Object.fromEntries(et.map(st=>[st,{price:0,quantity:0}]));if(e.forEach(st=>{const ot=String(st.Day??0);if(ot.length!==8)return;const ct=`${ot.substring(0,4)}-${ot.substring(4,6)}`;rt[ct]&&(rt[ct].price+=st.ExtendedPrice??0,rt[ct].quantity+=st.Quantity??0)}),R=et.map(st=>{const ot=rt[st],[ct,lt]=st.split("-").map(Number);return{date:new Date(ct,lt-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:ot.price,unitsSold:ot.quantity}}),c){const st=rt[nt];if(st&&st.price>0&&Ye>0){const ot=new Date(V,Ve+1,0).getDate();if(Ye<ot){const ct=st.price/Ye,lt=st.quantity/Ye,at=ct*ot,ut=lt*ot,pt=R[R.length-1];pt&&(pt.dollarVolume=at,pt.unitsSold=ut)}}}}l(R)},[e,t,c,s]),s?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):o.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:o,series:g,height:n,size:a}),a==="default"&&t==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:c,onCheckedChange:f,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),c&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:e,applicationId:t,publicName:n,name:s,location:a,link:o,linkNewTab:l=!0,children:c}){const[f,g]=React.useState(!1),R=V=>{V.preventDefault(),V.stopPropagation(),navigator.clipboard.writeText(t),g(!0),setTimeout(()=>g(!1),2e3)},A=jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t,width:48,height:48},`partner_logo_${t}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:e}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:R,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t}),f?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-green-500"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:f?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),s&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:s}),a&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),c&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:c})]});return o?jsxRuntime.jsx(reactRouterDom.Link,{to:o,target:l?"_blank":"_self",children:A}):A}function ManufacturerCard({manufacturer:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1,appID:l}){var ct,lt,at;const{toast:c}=useToast(),[f,{isLoading:g}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[R,A]=React.useState(!1),[V,Ve]=React.useState(""),{data:Ye}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:l||""},{skip:!l}),nt=Ye==null?void 0:Ye.IsReseller;if(o||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const et=[e.City,e.Province,e.Country].filter(Boolean),rt=et.length>0?et.join(", "):"",st=((ct=e.Tags)==null?void 0:ct.split(",").map(ut=>ut.trim()).filter(Boolean))||[],ot=async()=>{if(!(!(e!=null&&e.ManufacturerId)||!l||!V))try{await f({routeResellerId:l,emailAddress:V,manufacturerId:e.ManufacturerId}).unwrap(),c({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${V} shortly.`,variant:"success"}),A(!1)}catch(ut){console.error("Error requesting product list:",ut),c({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"manufacturer-theme flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:e.ManufacturerId,publicName:e.PublicName,name:e.Name,location:rt,link:t,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:e.SalesStatistics&&e.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:e.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!((lt=e.Qualification)!=null&&lt.QualificationId)&&((at=e.Qualification)==null?void 0:at.QualificationId)!=="Suspended"||!!e.OpenToWork||!!e.OnHold&&e.OnHold!==0||st.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),!!e.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),st.map((ut,pt)=>jsxRuntime.jsx(Badge,{variant:"outline",children:ut},pt))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${e.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${e.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:e.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]}),e.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesYearToDay?formatMoney(e.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast3Months?formatMoney(e.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast30Days?formatMoney(e.SalesData.SalesLast30Days):"—"})]})]})}),(s||a||e.PublicResourcesLink||nt&&l&&e.ManufacturerId||t)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s&&s,nt&&l&&e.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>A(!0),disabled:g,children:g?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),e.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:e.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(BookOpen,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("div",{children:a})})]}),jsxRuntime.jsx(Dialog,{open:R,onOpenChange:A,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:V,onChange:ut=>Ve(ut.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ot,disabled:!V||g,children:g?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:e,randmarSku:t,inventory:n,buttonSize:s="default",buttonClassName:a}){var Rt;const o=React.useRef(null),l=useIntersectionObserver({elementRef:o,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:c}=useToast(),[f,g]=React.useState(!1),[R,A]=React.useState(!1),[V,Ve]=React.useState(!1),{data:Ye,isLoading:nt,isFetching:et}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e||!l}),{data:rt,isLoading:st,isFetching:ot}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t,withSpecification:!1},{skip:!!n||!l}),[ct]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),lt=n??((Rt=rt==null?void 0:rt.Distribution)==null?void 0:Rt.Inventory);React.useEffect(()=>{g(!1)},[t]);const{inventoryQuantity:at,totalIncomingQuantity:ut}=React.useMemo(()=>{if(!lt||lt.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const ft=lt.reduce((yt,Ct)=>yt+(Ct.AvailableQuantity||0),0),Mt=lt.reduce((yt,Ct)=>yt+(Ct.PurchaseOrderQuantity||0),0);return{inventoryQuantity:ft,totalIncomingQuantity:Mt}},[lt]);if(nt||et||st||ot)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(Skeleton,{className:cn("h-10 w-36 rounded-md",a)})});const mt=()=>{V||!(Ye!=null&&Ye.IsReseller)||(Ve(!0),ct({routeResellerId:e??"",randmarSku:t??""}).then(ft=>{ft.error||ft.data===!1?c({title:"Warning",description:"Reorder is pending or requires manual approval. Contact the Randmar team for details.",variant:"warning"}):c({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),A(!1)}).catch(ft=>{console.error(ft),c({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{Ve(!1)}))};if(!lt)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:s,variant:"outline",className:cn("text-sm",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(Ye!=null&&Ye.IsReseller&&at<=0&&ut<=0)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:R,onOpenChange:A,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm reseller-theme text-primary",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>A(!1),disabled:V,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:mt,disabled:V,children:V?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const It=at<=0&&ut>0;return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:f,onOpenChange:g,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm",It?"manufacturer-theme text-primary":at>0?"text-green-700":"text-red-700",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),It?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(ut)," Incoming"]}):at>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(at)," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:lt})]})]})})}function OrdersCard({applicationId:e,orders:t=null,loading:n=!1,title:s="Order Details"}){const a=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:c})=>c.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/GeneralDocument/${c.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:c.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",c.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:c})=>c.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:c})=>formatYYYYMMDDIntToDateString(c.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:c})=>c.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:c})=>c.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:c})=>c.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Product/${c.original.MPN}`,className:"font-medium text-primary hover:underline",children:c.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",c.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:c})=>c.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:c})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:c.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:c})=>c.original.UnitPrice?formatMoney(c.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:c})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e,randmarSku:c.original.RandmarSKU??"",buttonSize:"sm"})})}],[e]),o=React.useMemo(()=>{const c={};if(t){const f=Array.from(new Set(t.map(Ye=>Ye.WarehouseCode).filter(Ye=>Ye!=null)));c.WarehouseCode=f;const g=Array.from(new Set(t.map(Ye=>Ye.ShipToName).filter(Ye=>Ye!=null)));c.ShipToName=g;const R=Array.from(new Set(t.map(Ye=>Ye.DocumentNumber).filter(Ye=>Ye!=null)));c.DocumentNumber=R;const A=Array.from(new Set(t.map(Ye=>Ye.OrderNumber).filter(Ye=>Ye!=null)));c.OrderNumber=A;const V=Array.from(new Set(t.map(Ye=>Ye.PONumber).filter(Ye=>Ye!=null)));c.PONumber=V;const Ve=Array.from(new Set(t.map(Ye=>Ye.MPN).filter(Ye=>Ye!=null)));c.MPN=Ve}return c},[t]),l=t||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:s})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:a,data:l,uniqueValues:o})})]})}function ResellerOverview({appID:e,reseller:t,readonly:n,userEmail:s,isSuperAdmin:a,withoutReports:o=!1}){var st,ot,ct,lt;const{data:l,isLoading:c,isError:f}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:e??"",withSpecification:!0},{skip:!!t}),[g,R]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),A=React.useCallback(()=>n?!1:g.publicInfo.hasUnsavedChanges,[n,g]),V=React.useCallback((at,ut)=>{R(pt=>{var mt;return((mt=pt[at])==null?void 0:mt.hasUnsavedChanges)!==ut.hasUnsavedChanges?{...pt,[at]:ut}:pt})},[]),{NavigationGuardDialog:Ve}=useRouterNavigationGuard(A),Ye=t??l,nt=!n||!!(Ye!=null&&Ye.Statement)&&(Ye.Statement.Total??0)>0,et=(Ye==null?void 0:Ye.QualifiedManufacturers)??[],rt=(Ye==null?void 0:Ye.Qualifications)??[];return jsxRuntime.jsxs("div",{className:"@container",children:[f?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:(Ye==null?void 0:Ye.FiscalYearMonthStart)||1,salesData:Ye==null?void 0:Ye.SalesData,isLoading:c}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:(Ye==null?void 0:Ye.SalesStatistics)??[],loading:c}),jsxRuntime.jsx(OrderCategories,{openOrders:(Ye==null?void 0:Ye.ActiveOrderDetails)??[],isLoading:c}),nt&&jsxRuntime.jsx(BillingCard,{appID:e,reseller:Ye||{},withoutReports:o,isLoading:c,userEmail:s,isSuperAdmin:a}),jsxRuntime.jsx(PublicInfo,{reseller:Ye||{},appID:e??"",isLoading:c,readonly:n,onUnsavedChanges:at=>V("publicInfo",{hasUnsavedChanges:at})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:a,readonly:n,reseller:Ye||{},appID:e??"",isLoading:c})]}),c||et.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:c?Array.from({length:2}).map((at,ut)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},ut)):et.map(at=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:at,link:`https://dashboard.randmar.io/${e}/Partner/${at.ManufacturerId}`},at.ManufacturerId))})})]}):rt.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:rt}),(((st=Ye==null?void 0:Ye.Opportunities)==null?void 0:st.length)??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:Ye==null?void 0:Ye.Opportunities,loading:c}),(((ot=Ye==null?void 0:Ye.ActiveOrderDetails)==null?void 0:ot.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:Ye==null?void 0:Ye.ActiveOrderDetails,loading:c}),(((ct=Ye==null?void 0:Ye.CompletedOrderDetails)==null?void 0:ct.length)??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:Ye==null?void 0:Ye.CompletedOrderDetails,loading:c}),(((lt=Ye==null?void 0:Ye.Returns)==null?void 0:lt.length)??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:Ye==null?void 0:Ye.Returns,loading:c}),!o&&jsxRuntime.jsx(ReportsSection,{appID:e,userEmail:s,isLoading:c})]}),jsxRuntime.jsx(Ve,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",success:"border-green-500/50 bg-green-50 text-green-700 dark:border-green-500 dark:bg-green-950 dark:text-green-400 [&>svg]:text-green-500",warning:"border-yellow-500/50 bg-yellow-50 text-yellow-700 dark:border-yellow-500 dark:bg-yellow-950 dark:text-yellow-400 [&>svg]:text-yellow-500",info:"border-blue-500/50 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950 dark:text-blue-400 [&>svg]:text-blue-500"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:e,variant:t,...n},s)=>jsxRuntime.jsx("div",{ref:s,role:"alert",className:cn(alertVariants({variant:t}),e),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",e),...t}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",e),...t}));AlertDescription.displayName="AlertDescription";/**
1266
1266
  * table-core
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "randmarcomps",
3
3
  "private": false,
4
- "version": "1.512.0",
4
+ "version": "1.513.0",
5
5
  "description": "The UI library enabling speed and consistency in Randmar frontends.",
6
6
  "type": "module",
7
7
  "files": [