randmarcomps 1.623.0 → 1.625.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/randmarcomps.js +17 -17
- package/dist/randmarcomps.umd.cjs +3 -3
- package/package.json +1 -1
|
@@ -487,7 +487,7 @@ $15 for drop shipped orders under $1,500,
|
|
|
487
487
|
$10 with opportunities under $1,000`:e==="D"?"$15 under $1,500":e==="E"?"Full shipping charges":e,getTermsText=e=>e==="STRIPE"?"Credit card payment":e==="NET30"?"Net 30 days":e,AccountTier=({isSuperAdmin:e,readonly:t,reseller:n,appID:s,isLoading:a})=>{const{toast:o}=useToast(),[l,c]=React.useState(!1),[d,f]=React.useState(""),[R,{isLoading:S}]=usePostV4PartnerByApplicationIdAccountResellerAndFieldNameMutation(),te=Dt=>Dt&&{Starter:"starter","E-Commerce":"ecommerce",Commercial:"commercial",Basics:"cws",Novexco:"novexco",COOPSCO:"coopsco","Jean Coutu":"jeancoutu",Exclusive:"exclusive"}[Dt]||"",A=Dt=>Dt&&{A:"free",B:"fixed",C:"dropshipped",D:"under1500",E:"fullcharges"}[Dt]||"",rt=Dt=>Dt&&{1:"exclusive",2:"ecommerce",3:"commercial",4:"buyinggroup",5:"cost"}[Dt]||"",[st,it]=React.useState(te(n?.Priority??"")),[at,ot]=React.useState(A(n?.ShippingProfile??"")),[lt,ut]=React.useState(rt(n?.PriceProfile)),ct=Dt=>({starter:"Starter",ecommerce:"E-Commerce",commercial:"Commercial",cws:"Basics",novexco:"Novexco",coopsco:"COOPSCO",jeancoutu:"Jean Coutu",exclusive:"Exclusive"})[Dt]||Dt,dt=Dt=>({free:"A",fixed:"B",dropshipped:"C",under1500:"D",fullcharges:"E"})[Dt]||Dt,pt=Dt=>({exclusive:"1",ecommerce:"2",commercial:"3",buyinggroup:"4",cost:"5"})[Dt]||Dt;React.useEffect(()=>{it(te(n?.Priority??"")),ot(A(n?.ShippingProfile??"")),ut(rt(n?.PriceProfile))},[n]);const mt=async(Dt,Vt,Ht,$t)=>{try{(await R({applicationId:s,fieldName:Dt,newValue:Vt})).error?o({title:"Error",description:$t,variant:"destructive"}):o({title:"Success",description:Ht,variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}},Rt=async Dt=>{it(Dt);const Vt=ct(Dt);mt("Priority",Vt,`Priority updated to ${Vt}`,"Failed to update priority")},yt=async Dt=>{ot(Dt);const Vt=dt(Dt);mt("ShippingProfile",Vt,`Shipping profile updated to ${Vt}`,"Failed to update shipping profile")},It=async Dt=>{ut(Dt);const Vt=pt(Dt);mt("PriceProfile",Vt,`Pricing profile updated to ${Vt}`,"Failed to update pricing profile")},ft=async()=>{try{const Dt=await R({applicationId:s,fieldName:"Tier",newValue:d});Dt.error?o({title:"Error",description:"Failed to update reseller",variant:"destructive"}):Dt.data?o({title:"Success",description:`Pricing Tier changed to ${d}`,variant:"success"}):o({title:"Considered",description:"Request being considered",variant:"success"})}catch{o({title:"Error",description:"An unexpected error occurred",variant:"destructive"})}finally{c(!1),f("")}},Ct=[{name:"Terms",enabled:n.Priority==="Starter"},{name:"E-Commerce",enabled:n.Priority==="Commercial"},{name:"Commercial",enabled:n.Priority==="E-Commerce"},{name:"Exclusive",enabled:e}],Mt=Dt=>{f(Dt),c(!0)};return a?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-28"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-16 rounded-full"})]})}),jsxRuntime.jsxs(CardContent,{children:[jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-56"})]}),jsxRuntime.jsx("div",{className:"grid gap-3",children:[1,2,3].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]})]},Dt))}),jsxRuntime.jsxs("div",{className:"flex gap-2 mt-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{className:"pb-2 pt-4 px-4 flex flex-row items-center justify-between",children:[jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Account Tier"}),jsxRuntime.jsx(Badge,{variant:"success",className:"text-xs",children:"Active"})]}),jsxRuntime.jsxs(CardContent,{className:"pt-2 px-4 pb-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-3 bg-primary/5 p-4 rounded-lg",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h3",{className:"text-lg font-bold text-primary",children:[n?.Priority||""," Tier"]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Optimized for online retail"})]}),jsxRuntime.jsx(CircleCheck,{className:"h-6 w-6 text-success"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-2 mb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Package2,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Pricing"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground truncate",children:getPricingText(n.PriceProfile||0)})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Truck,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Shipping"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getShippingText(n.ShippingProfile||"").split(".")[0]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border bg-card hover:bg-accent/5 transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-1.5 rounded-full shrink-0",children:jsxRuntime.jsx(Calendar$1,{className:"h-4 w-4 text-primary"})}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"font-medium text-sm",children:"Payment terms"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:getTermsText(n?.Terms||"")})]})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[!t&&jsxRuntime.jsx(Button$1,{variant:"outline",className:"flex-1",asChild:!0,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:"https://randmar.io/pricing",target:"_blank",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4 mr-1"}),"Pricing Tiers"]})}),jsxRuntime.jsxs(Popover,{children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{disabled:t,className:t?"hidden":"flex-1",children:["Upgrade Tier ",jsxRuntime.jsx(ChevronRight,{className:"h-3 w-3 ml-1"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56 p-2",children:jsxRuntime.jsxs("div",{className:"grid gap-1",children:[jsxRuntime.jsx("h4",{className:"font-medium text-xs mb-1",children:"Select a tier"}),Ct.map(Dt=>jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"w-full justify-start h-8",disabled:!Dt.enabled,onClick:()=>Mt(Dt.name),children:Dt.name},Dt.name))]})})]})]})]})]}),jsxRuntime.jsx(ChangePricingTierModal,{isLoading:S,open:l,setOpen:c,tier:d,onTierChange:ft}),e&&!t&&jsxRuntime.jsxs(Card,{className:"mt-4",children:[jsxRuntime.jsx(CardHeader,{className:"pb-2 pt-3 px-4",children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Admin Configuration"})}),jsxRuntime.jsx(CardContent,{className:"pt-2 px-4 pb-4",children:jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Priority"}),jsxRuntime.jsx(RadioGroup$1,{value:st,onValueChange:Rt,className:"grid grid-cols-2 @sm:grid-cols-3 @md:grid-cols-4 gap-1",children:[{value:"starter",label:"Starter"},{value:"ecommerce",label:"E-Commerce"},{value:"commercial",label:"Commercial"},{value:"cws",label:"CWS (Basics)"},{value:"novexco",label:"Novexco"},{value:"coopsco",label:"COOPSCO"},{value:"jeancoutu",label:"Jean Coutu"},{value:"exclusive",label:"Exclusive"}].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`priority-${Dt.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`priority-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Shipping Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:at,onValueChange:yt,className:"grid grid-cols-1 @md:grid-cols-2 gap-1",children:[{value:"free",label:"Free (A)"},{value:"fixed",label:"Fixed $10 Shipping (B)"},{value:"dropshipped",label:"$15 for drop shipped (C)"},{value:"under1500",label:"15$ under 1,500 (D)"},{value:"fullcharges",label:"Full shipping charges (E)"}].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`shipping-${Dt.value}`,className:"h-6 w-6 scale-50"}),jsxRuntime.jsx(Label$2,{htmlFor:`shipping-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]}),jsxRuntime.jsxs("div",{className:"bg-muted/30 p-2 rounded-lg",children:[jsxRuntime.jsx(Label$2,{className:"block mb-1 text-xs font-medium",children:"Pricing Profile"}),jsxRuntime.jsx(RadioGroup$1,{value:lt,onValueChange:It,className:"grid grid-cols-2 @sm:grid-cols-3 gap-1",children:[{value:"exclusive",label:"Exclusive (1)"},{value:"ecommerce",label:"E-Commerce (2)"},{value:"commercial",label:"Commercial (3)"},{value:"buyinggroup",label:"Buying Group (4)"},{value:"cost",label:"Cost (5)"}].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[jsxRuntime.jsx(RadioGroupItem,{value:Dt.value,id:`pricing-${Dt.value}`,className:"h-6 w-6 scale-50 antialiased"}),jsxRuntime.jsx(Label$2,{htmlFor:`pricing-${Dt.value}`,className:"cursor-pointer text-xs",children:Dt.label})]},Dt.value))})]})]})})]})]})};function OrderCategories({openOrders:e=[],isLoading:t=!1}){const n=e?.filter(st=>st.DocumentType==="Order")||[],s=e?.filter(st=>st.DocumentType==="Shipment")||[],a=n.filter(st=>st.WarehouseCode!=="3PLE"),o=a.reduce((st,it)=>st+(it.Quantity??0),0),l=a.reduce((st,it)=>st+(it.ExtendedPrice??0),0),c=n.filter(st=>st.WarehouseCode==="3PLE"),d=c.reduce((st,it)=>st+(it.Quantity??0),0),f=c.reduce((st,it)=>st+(it.ExtendedPrice??0),0),R=s.reduce((st,it)=>st+(it.Quantity??0),0),S=s.reduce((st,it)=>st+(it.ExtendedPrice??0),0),te=o+d+R,A=l+f+S,rt=[{name:"All",icon:Package,stripeClass:"bg-info/60",iconBgClass:"bg-info/90",iconTextClass:"text-info-foreground",orders:te,amount:A},{name:"Processing",icon:RefreshCcw,stripeClass:"bg-warning/60",iconBgClass:"bg-warning/90",iconTextClass:"text-warning-foreground",orders:o,amount:l},{name:"Shipped",icon:Truck,stripeClass:"bg-success/60",iconBgClass:"bg-success/90",iconTextClass:"text-success-foreground",orders:R,amount:S},{name:"Delayed",icon:CircleAlert,stripeClass:"bg-destructive/60",iconBgClass:"bg-destructive/90",iconTextClass:"text-destructive-foreground",orders:d,amount:f}];return t?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(Skeleton,{className:"h-7 w-40"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:[1,2,3,4].map(st=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:"bg-border h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]})},st))})})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Order Categories"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-3.5",children:rt.map(st=>jsxRuntime.jsx(Card,{className:"overflow-hidden rounded-md rounded-b-lg border-0 shadow-md",children:jsxRuntime.jsxs(CardContent,{className:"p-0",children:[jsxRuntime.jsx("div",{className:`${st.stripeClass} h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:st.name}),jsxRuntime.jsx("div",{className:`${st.iconBgClass} p-2 rounded-full`,children:jsxRuntime.jsx(st.icon,{className:`size-4 shrink-0 ${st.iconTextClass}`})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:st.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:jsxRuntime.jsx(FormattedNumber,{value:st.amount,style:"currency",currency:"CAD",currencyDisplay:"symbol"})})]})]})]})]})},st.name))})})]})}function ReportsSection({isLoading:e,userEmail:t,appID:n}){const{toast:s}=useToast(),[a,{isLoading:o}]=usePostV4ResellerByRouteResellerIdReportWalmartTrackingFileEmailMutation(),[l,{isLoading:c}]=usePostV4ResellerByRouteResellerIdReportAmazonTrackingFileEmailMutation(),[d,{isLoading:f}]=usePostV4ResellerByRouteResellerIdReportOpenOrdersEmailMutation(),[R,{isLoading:S}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[te,{isLoading:A}]=usePostV4ResellerByRouteResellerIdReportInvoicesEmailMutation(),[rt,{isLoading:st}]=usePostV4ResellerByRouteResellerIdDocumentStatementEmailMutation(),[it,at]=React.useState(null),[ot,lt]=React.useState(t),[ut,ct]=React.useState(!1),[dt,pt]=React.useState("all"),{data:mt,isLoading:Rt}=useGetV4PartnerByRouteApplicationIdManufacturersQuery({routeApplicationId:n,withSpecification:!1}),yt=[{name:"Products",reports:[{id:"Products",title:"Universal Product List",description:"A comprehensive overview of your product list with detailed specifications and pricing information.",icon:Package}]},{name:"Operation Details",reports:[{id:"OpenOrders",title:"Order Details",description:"A detailed report of all your orders and shipments, including status, tracking information, and delivery estimates.",icon:ShoppingCart},{id:"Invoices",title:"Invoices and Credits Report",description:"Detailed overview of your invoices and credits within a specific date range. It also contains reports about additional charges, serial numbers, and other relevant information.",icon:ScrollText},{id:"Statement",title:"Statement and RMAs Report",description:"A detailed report of all unpaid invoices and active RMAs.",icon:Banknote}]},{name:"Tracking Files",reports:[{id:"AmazonTrackingFile",title:"Amazon Tracking File",description:"Track products sold on Amazon marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing},{id:"WalmartTrackingFile",title:"Walmart Tracking File",description:"Track products sold on Walmart marketplace with detailed sales and inventory information.",icon:ChartNoAxesColumnIncreasing}]}],It=async Mt=>{at(Mt),Mt.id==="Products"&&pt("all"),ct(!0)},ft=async()=>{if(!(!it||!n))try{switch(it.id){case"Products":{const Mt={routeResellerId:n,emailAddress:ot};dt&&dt!=="all"&&(Mt.manufacturerId=dt),await R(Mt).unwrap();break}case"AmazonTrackingFile":await l({routeResellerId:n,emailAddress:ot}).unwrap();break;case"WalmartTrackingFile":await a({routeResellerId:n,emailAddress:ot}).unwrap();break;case"OpenOrders":await d({routeResellerId:n,emailAddress:ot}).unwrap();break;case"Invoices":await te({routeResellerId:n,emailAddress:ot}).unwrap();break;case"Statement":await rt({routeResellerId:n,emailAddress:ot}).unwrap();break;default:throw new Error("invalid report id")}s({title:"Report requested",description:`The ${it.title} will be sent to ${ot} shortly.`,variant:"success"}),ct(!1)}catch(Mt){console.error("Error requesting report:",Mt),s({title:"Error",description:"Failed to request report. Please try again.",variant:"destructive"})}},Ct=f||S||c||o||st||A;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:"Reports"}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Download essential business reports, from your Product List to your Order Details."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:[1,2,3].map(Mt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-48"}),[1,2].map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-9 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-full"})]}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"})]},Dt))]},Mt))}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:yt.map(Mt=>jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold",children:Mt.name}),Mt.reports.map(Dt=>jsxRuntime.jsxs("div",{className:"flex items-start gap-4 p-4 border rounded-lg hover:bg-muted transition-colors",children:[jsxRuntime.jsx("div",{className:"bg-primary/10 p-2 rounded-full",children:jsxRuntime.jsx(Dt.icon,{className:"h-5 w-5 text-primary"})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("h4",{className:"font-semibold text-sm",children:Dt.title}),jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Dt.description})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",size:"sm",className:"flex items-center gap-1",onClick:()=>It(Dt),children:[jsxRuntime.jsx(Download,{className:"h-4 w-4"}),"Request"]})]},Dt.id))]},Mt.name))})}),jsxRuntime.jsx(Dialog,{open:ut,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsxs(DialogTitle,{children:["Request ",it?.title]}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:ot,onChange:Mt=>lt(Mt.target.value),placeholder:"your@email.com",className:"mt-2"})]}),it?.id==="Products"&&jsxRuntime.jsxs("div",{className:"py-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"manufacturer",children:"Manufacturer"}),jsxRuntime.jsxs("select",{id:"manufacturer",className:"mt-2 block w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:dt,onChange:Mt=>pt(Mt.target.value),disabled:Rt,children:[jsxRuntime.jsx("option",{value:"all",children:"All manufacturers"}),!Rt&&Array.isArray(mt)&&mt.slice().sort((Mt,Dt)=>(Mt.PublicName||Mt.Name||"").localeCompare(Dt.PublicName||Dt.Name||"")).map(Mt=>Mt?.ManufacturerId?jsxRuntime.jsx("option",{value:Mt.ManufacturerId,children:(Mt.PublicName||Mt.Name||Mt.ManufacturerId)+(Mt.OpenToWork?" (Open to Work)":"")},Mt.ManufacturerId):null)]})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>ct(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:ft,disabled:!ot||Ct,children:Ct?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function QualificationBadge({qualification:e}){return!e.QualificationId||e.QualificationId==="Suspended"?null:e.QualificationId==="Do Not Sell"?jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"destructive",children:[jsxRuntime.jsx(X$2,{className:"h-3 w-3 mr-1"}),"Do Not Sell"]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})}):jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs(Badge,{variant:"info",className:e.DefaultOpportunityNumber?"pr-1":"",children:[jsxRuntime.jsx(BadgeCheck,{className:"h-3 w-3 mr-1"}),e.QualificationId,e.DefaultOpportunityNumber&&jsxRuntime.jsx(Badge,{variant:"secondary",size:"sm",className:"ml-1",children:e.DefaultOpportunityNumber})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Qualification"})})]})})}function SalesChart({statistics:e,mode:t="month",chartHeight:n,loading:s=!1,size:a="default"}){const[o,l]=React.useState([]),[c,d]=React.useState(!1),f=[{name:"dollarVolume",label:"Dollar Volume",color:"var(--primary)",dotClassName:"bg-primary",yAxisId:"left",format:"money"},{name:"unitsSold",label:"Units Sold",color:"var(--chart-2)",dotClassName:"bg-chart-2",units:" units",yAxisId:"right",format:"integer"}];return React.useEffect(()=>{if(s||!e){l([]);return}let R=[];if(t==="week"){const S=new Map;e.forEach(te=>{const A=te.Day?.toString()||"";if(A.length===8){const rt=parseInt(A.substring(0,4),10),st=parseInt(A.substring(4,6),10)-1,it=parseInt(A.substring(6,8),10),at=new Date(rt,st,it),ot=new Date(at);ot.setDate(at.getDate()-at.getDay());const lt=`${ot.getFullYear()}-${String(ot.getMonth()+1).padStart(2,"0")}-${String(ot.getDate()).padStart(2,"0")}`,ut=S.get(lt)||{price:0,quantity:0};ut.price+=te.ExtendedPrice||0,ut.quantity+=te.Quantity||0,S.set(lt,ut)}}),R=Array.from(S).sort(([te],[A])=>te.localeCompare(A)).map(([te,A])=>({date:`${te.substring(5,7)}/${te.substring(8,10)}`,dollarVolume:A.price,unitsSold:A.quantity}))}else{const S=new Date,te=S.getFullYear(),A=S.getMonth(),rt=S.getDate(),st=`${te}-${(A+1).toString().padStart(2,"0")}`,it=Array.from({length:12},(ot,lt)=>{const ut=new Date(te,A-(11-lt),1);return`${ut.getFullYear()}-${(ut.getMonth()+1).toString().padStart(2,"0")}`}),at=Object.fromEntries(it.map(ot=>[ot,{price:0,quantity:0}]));if(e.forEach(ot=>{const lt=String(ot.Day??0);if(lt.length!==8)return;const ut=`${lt.substring(0,4)}-${lt.substring(4,6)}`;at[ut]&&(at[ut].price+=ot.ExtendedPrice??0,at[ut].quantity+=ot.Quantity??0)}),R=it.map(ot=>{const lt=at[ot],[ut,ct]=ot.split("-").map(Number);return{date:new Date(ut,ct-1).toLocaleString("default",{month:"short",year:"numeric"}),dollarVolume:lt.price,unitsSold:lt.quantity}}),c){const ot=at[st];if(ot&&ot.price>0&&rt>0){const lt=new Date(te,A+1,0).getDate();if(rt<lt){const ut=ot.price/rt,ct=ot.quantity/rt,dt=ut*lt,pt=ct*lt,mt=R[R.length-1];mt&&(mt.dollarVolume=dt,mt.unitsSold=pt)}}}}l(R)},[e,t,c,s]),s?jsxRuntime.jsx("div",{style:{height:n},children:jsxRuntime.jsx(Skeleton,{className:"h-full w-full rounded-md"})}):o.length===0?jsxRuntime.jsx("div",{style:{height:n},className:"flex items-center justify-center text-muted-foreground",children:"No sales data available."}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AreaChart,{data:o,series:f,height:n,size:a}),a==="default"&&t==="month"&&jsxRuntime.jsxs("div",{className:"mt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{checked:c,onCheckedChange:d,id:"extrapolate-switch"}),jsxRuntime.jsx(Label$2,{htmlFor:"extrapolate-switch",children:"Extrapolate Current Month"})]}),c&&jsxRuntime.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["* Values for ",new Date().toLocaleString("default",{month:"long"})," are projected estimates."]})]})]})}function PartnerCardHeader({type:e,applicationId:t,publicName:n,name:s,location:a,link:o,linkNewTab:l=!0,children:c}){const[d,f]=React.useState(!1),R=te=>{te.preventDefault(),te.stopPropagation(),navigator.clipboard.writeText(t),f(!0),setTimeout(()=>f(!1),2e3)},S=jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"h-12 w-12 overflow-hidden rounded-md",children:jsxRuntime.jsx(PartnerLogo,{id:t,width:48,height:48},`partner_logo_${t}`)}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs text-primary",children:e}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:"|"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{delayDuration:300,children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex cursor-pointer items-center gap-1",onClick:R,children:[jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:t}),d?jsxRuntime.jsx(Check,{className:"h-3 w-3 text-success"}):jsxRuntime.jsx(Copy,{className:"h-3 w-3 text-muted-foreground"})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:d?"Copied!":"Copy ID"})})]})})]}),jsxRuntime.jsx("h3",{className:"font-semibold",children:n||"N/A"}),s&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:s}),a&&jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),c&&jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:c})]});return o?jsxRuntime.jsx(reactRouterDom.Link,{to:o,target:l?"_blank":"_self",children:S}):S}function ManufacturerCard({manufacturer:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1,appID:l}){const{toast:c}=useToast(),[d,{isLoading:f}]=usePostV4ResellerByRouteResellerIdReportProductsEmailMutation(),[R,S]=React.useState(!1),[te,A]=React.useState(""),{data:rt}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:l||""},{skip:!l}),st=rt?.IsReseller;if(o||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsxs(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-24"})]}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const it=[e.City,e.Province,e.Country].filter(Boolean),at=it.length>0?it.join(", "):"",ot=e.Tags?.split(",").map(ut=>ut.trim()).filter(Boolean)||[],lt=async()=>{if(!(!e?.ManufacturerId||!l||!te))try{await d({routeResellerId:l,emailAddress:te,manufacturerId:e.ManufacturerId}).unwrap(),c({title:"Report requested",description:`The Universal Product List for this manufacturer will be sent to ${te} shortly.`,variant:"success"}),S(!1)}catch(ut){console.error("Error requesting product list:",ut),c({title:"Error",description:"Failed to request product list. Please try again.",variant:"destructive"})}};return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Manufacturer",applicationId:e.ManufacturerId,publicName:e.PublicName,name:e.Name,location:at,link:t,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:e.SalesStatistics&&e.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:e.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(!!e.Qualification?.QualificationId&&e.Qualification?.QualificationId!=="Suspended"||!!e.OpenToWork||!!e.OnHold&&e.OnHold!==0||ot.length>0)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),!!e.OpenToWork&&jsxRuntime.jsxs(Badge,{variant:"success",children:[jsxRuntime.jsx(HardHat,{className:"h-3 w-3 mr-1"}),"Open To Work"]}),!!e.OnHold&&e.OnHold!==0&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),ot.map((ut,ct)=>jsxRuntime.jsx(Badge,{variant:"outline",children:ut},ct))]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${e.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${e.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:e.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]}),e.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesYearToDay?formatMoney(e.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast3Months?formatMoney(e.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:e.SalesData.SalesLast30Days?formatMoney(e.SalesData.SalesLast30Days):"—"})]})]})}),(s||a||e.PublicResourcesLink||st&&l&&e.ManufacturerId||t)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[s&&s,st&&l&&e.ManufacturerId&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Button$1,{size:"icon",onClick:()=>S(!0),disabled:f,children:f?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}):jsxRuntime.jsx(Download,{className:"h-4 w-4"})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Email Product List"})})]})}),e.PublicResourcesLink&&jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:e.PublicResourcesLink,target:"_blank",children:jsxRuntime.jsx(Button$1,{size:"icon",children:jsxRuntime.jsx(BookOpen,{className:"h-4 w-4"})})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"Public Resources Link"})})]})})]}),a&&jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("div",{children:a})})]}),jsxRuntime.jsx(Dialog,{open:R,onOpenChange:S,children:jsxRuntime.jsxs(DialogContent,{children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Request Universal Product List"}),jsxRuntime.jsx(DialogDescription,{children:"Enter the email address where you would like to receive the report."})]}),jsxRuntime.jsxs("div",{className:"py-4",children:[jsxRuntime.jsx(Label$2,{htmlFor:"email",children:"Email"}),jsxRuntime.jsx(Input,{id:"email",value:te,onChange:ut=>A(ut.target.value),placeholder:"your@email.com",className:"mt-2"})]}),jsxRuntime.jsx(DialogDescription,{children:"The report will take around 5 minutes to generate."}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:lt,disabled:!te||f,children:f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending..."]}):"Send Report"})]})]})})]})}function ProductInventoryButton({applicationId:e,randmarSku:t,inventory:n,buttonSize:s="default",buttonClassName:a}){const o=React.useRef(null),l=useIntersectionObserver({elementRef:o,threshold:.1,rootMargin:"100px",freezeOnceVisible:!0}),{toast:c}=useToast(),[d,f]=React.useState(!1),[R,S]=React.useState(!1),[te,A]=React.useState(!1),{data:rt,isLoading:st,isFetching:it}=useGetV4PartnerByApplicationIdAccountQuery({applicationId:e},{skip:!e||!l}),{data:at,isLoading:ot,isFetching:lt}=useGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery({routeApplicationId:e,randmarSku:t,withSpecification:!1},{skip:!!n||!l}),[ut]=usePutV4ResellerByRouteResellerIdProductAndRandmarSkuRequisitionMutation(),ct=n??at?.Distribution?.Inventory;React.useEffect(()=>{f(!1)},[t]);const{inventoryQuantity:dt,totalIncomingQuantity:pt}=React.useMemo(()=>{if(!ct||ct.length===0)return{inventoryQuantity:0,totalIncomingQuantity:0};const It=ct.reduce((Ct,Mt)=>Ct+(Mt.AvailableQuantity||0),0),ft=ct.reduce((Ct,Mt)=>Ct+(Mt.PurchaseOrderQuantity||0),0);return{inventoryQuantity:It,totalIncomingQuantity:ft}},[ct]);if(st||it||ot||lt)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(Skeleton,{className:cn("h-10 w-36 rounded-md",a)})});const Rt=()=>{te||!rt?.IsReseller||(A(!0),ut({routeResellerId:e??"",randmarSku:t??""}).then(It=>{It.error||It.data===!1?c({title:"Warning",description:"Reorder is pending or requires manual approval. Contact the Randmar team for details.",variant:"warning"}):c({title:"Success",description:"Qualification successfully submitted.",variant:"success"}),S(!1)}).catch(It=>{console.error(It),c({title:"Error",description:"Error submitting your qualification.",variant:"destructive"})}).finally(()=>{A(!1)}))};if(!ct)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx("span",{tabIndex:0,children:jsxRuntime.jsxs(Button$1,{disabled:!0,size:s,variant:"outline",className:cn("text-sm",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"No data"]})})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"No inventory data could be found for this product."})})]})})});if(rt?.IsReseller&&dt<=0&&pt<=0)return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:R,onOpenChange:S,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm text-primary",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),"Request to stock"]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-md",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Request to stock"})}),jsxRuntime.jsx("p",{className:"py-4",children:"Are you sure you want to request this product to be stocked?"}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(Button$1,{variant:"outline",onClick:()=>S(!1),disabled:te,children:"Cancel"}),jsxRuntime.jsx(Button$1,{onClick:Rt,disabled:te,children:te?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin mr-2"}),"Requesting..."]}):"Confirm"})]})]})]})});const yt=dt<=0&&pt>0;return jsxRuntime.jsx("div",{ref:o,children:jsxRuntime.jsxs(Dialog,{open:d,onOpenChange:f,children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",size:s,className:cn("text-sm",yt?"text-info":dt>0?"text-success":"text-destructive",a),children:[jsxRuntime.jsx(Warehouse,{size:"16",className:"mr-2"}),yt?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(pt)," Incoming"]}):dt>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[formatNumber(dt)," in stock"]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Out of stock"})]})}),jsxRuntime.jsxs(DialogContent,{className:"max-w-4xl",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{className:"flex items-center",children:[jsxRuntime.jsx(Warehouse,{className:"mr-2",size:18}),"Inventory Information"]})}),jsxRuntime.jsx(ProductInventoryGrid,{inventory:ct})]})]})})}function OrdersCard({applicationId:e,orders:t=null,loading:n=!1,title:s="Order Details"}){const a=React.useMemo(()=>[{accessorKey:"OrderNumber",header:"Order Number",cell:({row:c})=>c.original.OrderNumber?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/GeneralDocument/${c.original.OrderNumber}`,className:"font-medium text-primary hover:underline",children:c.original.OrderNumber})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for order ",c.original.OrderNumber]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentNumber",header:"Document Number",cell:({row:c})=>c.original.DocumentNumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"DocumentDate",header:"Document Date",cell:({row:c})=>formatYYYYMMDDIntToDateString(c.original.DocumentDate),enableSorting:!0,enableFiltering:!1},{accessorKey:"PONumber",header:"PO Number",cell:({row:c})=>c.original.PONumber??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"WarehouseCode",header:"Warehouse",cell:({row:c})=>c.original.WarehouseCode??"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"MPN",header:"MPN",cell:({row:c})=>c.original.MPN?jsxRuntime.jsx(TooltipProvider,{delayDuration:100,children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(reactRouterDom.Link,{to:`/${e}/Product/${c.original.MPN}`,className:"font-medium text-primary hover:underline",children:c.original.MPN})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["View details for MPN ",c.original.MPN]})})]})}):"N/A",enableSorting:!0,enableFiltering:!0},{accessorKey:"Quantity",header:"Quantity",cell:({row:c})=>c.original.Quantity??"N/A",enableSorting:!0,enableFiltering:!1},{accessorKey:"ShipToName",header:"Name",cell:({row:c})=>jsxRuntime.jsx("div",{className:"min-w-[150px]",children:c.original.ShipToName??"N/A"}),enableSorting:!0,enableFiltering:!0},{accessorKey:"UnitPrice",header:"Unit Price",cell:({row:c})=>c.original.UnitPrice?formatMoney(c.original.UnitPrice):"N/A",enableSorting:!0,enableFiltering:!1},{id:"actions",header:"Actions",cell:({row:c})=>jsxRuntime.jsx("div",{className:"flex space-x-2",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e,randmarSku:c.original.RandmarSKU??"",buttonSize:"sm"})})}],[e]),o=React.useMemo(()=>{const c={};if(t){const d=Array.from(new Set(t.map(rt=>rt.WarehouseCode).filter(rt=>rt!=null)));c.WarehouseCode=d;const f=Array.from(new Set(t.map(rt=>rt.ShipToName).filter(rt=>rt!=null)));c.ShipToName=f;const R=Array.from(new Set(t.map(rt=>rt.DocumentNumber).filter(rt=>rt!=null)));c.DocumentNumber=R;const S=Array.from(new Set(t.map(rt=>rt.OrderNumber).filter(rt=>rt!=null)));c.OrderNumber=S;const te=Array.from(new Set(t.map(rt=>rt.PONumber).filter(rt=>rt!=null)));c.PONumber=te;const A=Array.from(new Set(t.map(rt=>rt.MPN).filter(rt=>rt!=null)));c.MPN=A}return c},[t]),l=t||[];return n?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsxs(CardHeader,{children:[" ",jsxRuntime.jsx(Skeleton,{className:"h-7 w-48"})," "]}),jsxRuntime.jsxs(CardContent,{className:"space-y-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full rounded-md border"}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-[130px]"}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-20"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-9"})]})]})]})]}):jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{className:"text-1xl font-bold",children:s})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx(DataTable,{columns:a,data:l,uniqueValues:o})})]})}function ResellerOverview({appID:e,reseller:t,readonly:n,userEmail:s,isSuperAdmin:a,withoutReports:o=!1,loadFullAfterSummary:l=!1}){const c=`${e}|${l?1:0}`,d=React.useRef(c),[f,R]=React.useState(()=>l?!!t:!1);React.useEffect(()=>{d.current!==c&&(d.current=c,R(!1))},[c]),React.useEffect(()=>{l&&t&&R(!0)},[l,t]);const S=l?f:!t,{data:te,isLoading:A,isError:rt}=useGetV4PartnerByApplicationIdAccountResellerQuery({applicationId:e??"",withSpecification:!0},{skip:!e||!S}),[st,it]=React.useState({publicInfo:{hasUnsavedChanges:!1}}),at=React.useCallback(()=>n?!1:st.publicInfo.hasUnsavedChanges,[n,st]),ot=React.useCallback((yt,It)=>{it(ft=>ft[yt]?.hasUnsavedChanges!==It.hasUnsavedChanges?{...ft,[yt]:It}:ft)},[]),{NavigationGuardDialog:lt}=useRouterNavigationGuard(at),ut=te??t,ct=A&&!ut,dt=rt&&!ut,pt=!n||!!ut?.Statement&&(ut.Statement.Total??0)>0,mt=ut?.QualifiedManufacturers??[],Rt=ut?.Qualifications??[];return jsxRuntime.jsxs("div",{className:"@container",children:[dt?jsxRuntime.jsx(Card,{className:"p-6",children:jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(CircleAlert,{className:"h-4 w-4"}),jsxRuntime.jsx(AlertTitle,{children:"Error"}),jsxRuntime.jsx(AlertDescription,{children:"There was an error loading your reseller information. Please try again later."})]})}):jsxRuntime.jsxs("div",{className:"space-y-6 mb-6",children:[jsxRuntime.jsx(SalesSummary,{fiscalYearMonthStart:ut?.FiscalYearMonthStart||1,salesData:ut?.SalesData,isLoading:ct}),jsxRuntime.jsxs("div",{className:"grid @lg:grid-cols-2 gap-6",children:[jsxRuntime.jsx(SalesChartCard,{statistics:ut?.SalesStatistics??[],loading:ct}),jsxRuntime.jsx(OrderCategories,{openOrders:ut?.ActiveOrderDetails??[],isLoading:ct}),pt&&jsxRuntime.jsx(BillingCard,{appID:e,reseller:ut||{},withoutReports:o,isLoading:ct,userEmail:s,isSuperAdmin:a}),jsxRuntime.jsx(PublicInfo,{reseller:ut||{},appID:e??"",isLoading:ct,readonly:n,onUnsavedChanges:yt=>ot("publicInfo",{hasUnsavedChanges:yt})}),jsxRuntime.jsx(AccountTier,{isSuperAdmin:a,readonly:n,reseller:ut||{},appID:e??"",isLoading:ct})]}),ct||mt.length>0?jsxRuntime.jsxs(Card,{className:"w-full",children:[jsxRuntime.jsx(CardHeader,{children:jsxRuntime.jsx(CardTitle,{children:"Manufacturers you are qualified for"})}),jsxRuntime.jsx(CardContent,{children:jsxRuntime.jsx("div",{className:"grid @lg:grid-cols-2 gap-4",children:ct?Array.from({length:2}).map((yt,It)=>jsxRuntime.jsx(ManufacturerCard,{loading:!0},It)):mt.map(yt=>jsxRuntime.jsx(ManufacturerCard,{manufacturer:yt,link:`https://dashboard.randmar.io/${e}/Partner/${yt.ManufacturerId}`},yt.ManufacturerId))})})]}):Rt.length>0&&jsxRuntime.jsx(ResellerQualificationsCard,{qualifications:Rt}),(ut?.Opportunities?.length??0)>0&&jsxRuntime.jsx(OpportunitiesTable,{applicationId:e,opportunities:ut?.Opportunities,loading:ct}),(ut?.ActiveOrderDetails?.length??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Active Orders",orders:ut?.ActiveOrderDetails,loading:ct}),(ut?.CompletedOrderDetails?.length??0)>0&&jsxRuntime.jsx(OrdersCard,{applicationId:e,title:"Completed Orders",orders:ut?.CompletedOrderDetails,loading:ct}),(ut?.Returns?.length??0)>0&&jsxRuntime.jsx(ReturnsTable,{applicationId:e,returns:ut?.Returns,loading:ct}),!o&&jsxRuntime.jsx(ReportsSection,{appID:e,userEmail:s,isLoading:ct})]}),jsxRuntime.jsx(lt,{})]})}const alertVariants=cva("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 bg-destructive/10 text-foreground [&>svg]:text-destructive",success:"border-success/50 bg-success/10 text-foreground [&>svg]:text-success",warning:"border-warning/50 bg-warning/10 text-foreground [&>svg]:text-warning",info:"border-info/50 bg-info/10 text-foreground [&>svg]:text-info"}},defaultVariants:{variant:"default"}}),Alert=React__namespace.forwardRef(({className:e,variant:t,...n},s)=>jsxRuntime.jsx("div",{ref:s,role:"alert",className:cn(alertVariants({variant:t}),e),...n}));Alert.displayName="Alert";const AlertTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("h5",{ref:n,className:cn("mb-1 font-medium leading-none tracking-tight",e),...t}));AlertTitle.displayName="AlertTitle";const AlertDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{ref:n,className:cn("text-sm [&_p]:leading-relaxed",e),...t}));AlertDescription.displayName="AlertDescription";function functionalUpdate(e,t){return typeof e=="function"?e(t):e}function makeStateUpdater(e,t){return n=>{t.setState(s=>({...s,[e]:functionalUpdate(n,s[e])}))}}function isFunction$2(e){return e instanceof Function}function isNumberArray(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function flattenBy(e,t){const n=[],s=a=>{a.forEach(o=>{n.push(o);const l=t(o);l!=null&&l.length&&s(l)})};return s(e),n}function memo(e,t,n){let s=[],a;return o=>{let l;n.key&&n.debug&&(l=Date.now());const c=e(o);if(!(c.length!==s.length||c.some((R,S)=>s[S]!==R)))return a;s=c;let f;if(n.key&&n.debug&&(f=Date.now()),a=t(...c),n==null||n.onChange==null||n.onChange(a),n.key&&n.debug&&n!=null&&n.debug()){const R=Math.round((Date.now()-l)*100)/100,S=Math.round((Date.now()-f)*100)/100,te=S/16,A=(rt,st)=>{for(rt=String(rt);rt.length<st;)rt=" "+rt;return rt};console.info(`%c⏱ ${A(S,5)} /${A(R,5)} ms`,`
|
|
488
488
|
font-size: .6rem;
|
|
489
489
|
font-weight: bold;
|
|
490
|
-
color: hsl(${Math.max(0,Math.min(120-120*te,120))}deg 100% 31%);`,n?.key)}return a}}function getMemoOptions(e,t,n,s){return{debug:()=>{var a;return(a=e?.debugAll)!=null?a:e[t]},key:process.env.NODE_ENV==="development"&&n,onChange:s}}function createCell(e,t,n,s){const a=()=>{var l;return(l=o.getValue())!=null?l:e.options.renderFallbackValue},o={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(s),renderValue:a,getContext:memo(()=>[e,n,t,o],(l,c,d,f)=>({table:l,column:c,row:d,cell:f,getValue:f.getValue,renderValue:f.renderValue}),getMemoOptions(e.options,"debugCells","cell.getContext"))};return e._features.forEach(l=>{l.createCell==null||l.createCell(o,n,t,e)},{}),o}function createColumn(e,t,n,s){var a,o;const c={...e._getDefaultColumnDef(),...t},d=c.accessorKey;let f=(a=(o=c.id)!=null?o:d?typeof String.prototype.replaceAll=="function"?d.replaceAll(".","_"):d.replace(/\./g,"_"):void 0)!=null?a:typeof c.header=="string"?c.header:void 0,R;if(c.accessorFn?R=c.accessorFn:d&&(d.includes(".")?R=te=>{let A=te;for(const st of d.split(".")){var rt;A=(rt=A)==null?void 0:rt[st],process.env.NODE_ENV!=="production"&&A===void 0&&console.warn(`"${st}" in deeply nested key "${d}" returned undefined.`)}return A}:R=te=>te[c.accessorKey]),!f)throw process.env.NODE_ENV!=="production"?new Error(c.accessorFn?"Columns require an id when using an accessorFn":"Columns require an id when using a non-string header"):new Error;let S={id:`${String(f)}`,accessorFn:R,parent:s,depth:n,columnDef:c,columns:[],getFlatColumns:memo(()=>[!0],()=>{var te;return[S,...(te=S.columns)==null?void 0:te.flatMap(A=>A.getFlatColumns())]},getMemoOptions(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:memo(()=>[e._getOrderColumnsFn()],te=>{var A;if((A=S.columns)!=null&&A.length){let rt=S.columns.flatMap(st=>st.getLeafColumns());return te(rt)}return[S]},getMemoOptions(e.options,"debugColumns","column.getLeafColumns"))};for(const te of e._features)te.createColumn==null||te.createColumn(S,e);return S}const debug="debugHeaders";function createHeader(e,t,n){var s;let o={id:(s=n.id)!=null?s:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const l=[],c=d=>{d.subHeaders&&d.subHeaders.length&&d.subHeaders.map(c),l.push(d)};return c(o),l},getContext:()=>({table:e,header:o,column:t})};return e._features.forEach(l=>{l.createHeader==null||l.createHeader(o,e)}),o}const Headers$1={createTable:e=>{e.getHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s,a)=>{var o,l;const c=(o=s?.map(S=>n.find(te=>te.id===S)).filter(Boolean))!=null?o:[],d=(l=a?.map(S=>n.find(te=>te.id===S)).filter(Boolean))!=null?l:[],f=n.filter(S=>!(s!=null&&s.includes(S.id))&&!(a!=null&&a.includes(S.id)));return buildHeaderGroups(t,[...c,...f,...d],e)},getMemoOptions(e.options,debug,"getHeaderGroups")),e.getCenterHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s,a)=>(n=n.filter(o=>!(s!=null&&s.includes(o.id))&&!(a!=null&&a.includes(o.id))),buildHeaderGroups(t,n,e,"center")),getMemoOptions(e.options,debug,"getCenterHeaderGroups")),e.getLeftHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,s)=>{var a;const o=(a=s?.map(l=>n.find(c=>c.id===l)).filter(Boolean))!=null?a:[];return buildHeaderGroups(t,o,e,"left")},getMemoOptions(e.options,debug,"getLeftHeaderGroups")),e.getRightHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,s)=>{var a;const o=(a=s?.map(l=>n.find(c=>c.id===l)).filter(Boolean))!=null?a:[];return buildHeaderGroups(t,o,e,"right")},getMemoOptions(e.options,debug,"getRightHeaderGroups")),e.getFooterGroups=memo(()=>[e.getHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getFooterGroups")),e.getLeftFooterGroups=memo(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getLeftFooterGroups")),e.getCenterFooterGroups=memo(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getCenterFooterGroups")),e.getRightFooterGroups=memo(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getRightFooterGroups")),e.getFlatHeaders=memo(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getFlatHeaders")),e.getLeftFlatHeaders=memo(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getLeftFlatHeaders")),e.getCenterFlatHeaders=memo(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getCenterFlatHeaders")),e.getRightFlatHeaders=memo(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getRightFlatHeaders")),e.getCenterLeafHeaders=memo(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getCenterLeafHeaders")),e.getLeftLeafHeaders=memo(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getLeftLeafHeaders")),e.getRightLeafHeaders=memo(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getRightLeafHeaders")),e.getLeafHeaders=memo(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,s)=>{var a,o,l,c,d,f;return[...(a=(o=t[0])==null?void 0:o.headers)!=null?a:[],...(l=(c=n[0])==null?void 0:c.headers)!=null?l:[],...(d=(f=s[0])==null?void 0:f.headers)!=null?d:[]].map(R=>R.getLeafHeaders()).flat()},getMemoOptions(e.options,debug,"getLeafHeaders"))}};function buildHeaderGroups(e,t,n,s){var a,o;let l=0;const c=function(te,A){A===void 0&&(A=1),l=Math.max(l,A),te.filter(rt=>rt.getIsVisible()).forEach(rt=>{var st;(st=rt.columns)!=null&&st.length&&c(rt.columns,A+1)},0)};c(e);let d=[];const f=(te,A)=>{const rt={depth:A,id:[s,`${A}`].filter(Boolean).join("_"),headers:[]},st=[];te.forEach(it=>{const at=[...st].reverse()[0],ot=it.column.depth===rt.depth;let lt,ut=!1;if(ot&&it.column.parent?lt=it.column.parent:(lt=it.column,ut=!0),at&&at?.column===lt)at.subHeaders.push(it);else{const ct=createHeader(n,lt,{id:[s,A,lt.id,it?.id].filter(Boolean).join("_"),isPlaceholder:ut,placeholderId:ut?`${st.filter(dt=>dt.column===lt).length}`:void 0,depth:A,index:st.length});ct.subHeaders.push(it),st.push(ct)}rt.headers.push(it),it.headerGroup=rt}),d.push(rt),A>0&&f(st,A-1)},R=t.map((te,A)=>createHeader(n,te,{depth:l,index:A}));f(R,l-1),d.reverse();const S=te=>te.filter(rt=>rt.column.getIsVisible()).map(rt=>{let st=0,it=0,at=[0];rt.subHeaders&&rt.subHeaders.length?(at=[],S(rt.subHeaders).forEach(lt=>{let{colSpan:ut,rowSpan:ct}=lt;st+=ut,at.push(ct)})):st=1;const ot=Math.min(...at);return it=it+ot,rt.colSpan=st,rt.rowSpan=it,{colSpan:st,rowSpan:it}});return S((a=(o=d[0])==null?void 0:o.headers)!=null?a:[]),d}const createRow=(e,t,n,s,a,o,l)=>{let c={id:t,index:s,original:n,depth:a,parentId:l,_valuesCache:{},_uniqueValuesCache:{},getValue:d=>{if(c._valuesCache.hasOwnProperty(d))return c._valuesCache[d];const f=e.getColumn(d);if(f!=null&&f.accessorFn)return c._valuesCache[d]=f.accessorFn(c.original,s),c._valuesCache[d]},getUniqueValues:d=>{if(c._uniqueValuesCache.hasOwnProperty(d))return c._uniqueValuesCache[d];const f=e.getColumn(d);if(f!=null&&f.accessorFn)return f.columnDef.getUniqueValues?(c._uniqueValuesCache[d]=f.columnDef.getUniqueValues(c.original,s),c._uniqueValuesCache[d]):(c._uniqueValuesCache[d]=[c.getValue(d)],c._uniqueValuesCache[d])},renderValue:d=>{var f;return(f=c.getValue(d))!=null?f:e.options.renderFallbackValue},subRows:[],getLeafRows:()=>flattenBy(c.subRows,d=>d.subRows),getParentRow:()=>c.parentId?e.getRow(c.parentId,!0):void 0,getParentRows:()=>{let d=[],f=c;for(;;){const R=f.getParentRow();if(!R)break;d.push(R),f=R}return d.reverse()},getAllCells:memo(()=>[e.getAllLeafColumns()],d=>d.map(f=>createCell(e,c,f,f.id)),getMemoOptions(e.options,"debugRows","getAllCells")),_getAllCellsByColumnId:memo(()=>[c.getAllCells()],d=>d.reduce((f,R)=>(f[R.column.id]=R,f),{}),getMemoOptions(e.options,"debugRows","getAllCellsByColumnId"))};for(let d=0;d<e._features.length;d++){const f=e._features[d];f==null||f.createRow==null||f.createRow(c,e)}return c},ColumnFaceting={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},includesString=(e,t,n)=>{var s,a;const o=n==null||(s=n.toString())==null?void 0:s.toLowerCase();return!!(!((a=e.getValue(t))==null||(a=a.toString())==null||(a=a.toLowerCase())==null)&&a.includes(o))};includesString.autoRemove=e=>testFalsey(e);const includesStringSensitive=(e,t,n)=>{var s;return!!(!((s=e.getValue(t))==null||(s=s.toString())==null)&&s.includes(n))};includesStringSensitive.autoRemove=e=>testFalsey(e);const equalsString=(e,t,n)=>{var s;return((s=e.getValue(t))==null||(s=s.toString())==null?void 0:s.toLowerCase())===n?.toLowerCase()};equalsString.autoRemove=e=>testFalsey(e);const arrIncludes=(e,t,n)=>{var s;return(s=e.getValue(t))==null?void 0:s.includes(n)};arrIncludes.autoRemove=e=>testFalsey(e);const arrIncludesAll=(e,t,n)=>!n.some(s=>{var a;return!((a=e.getValue(t))!=null&&a.includes(s))});arrIncludesAll.autoRemove=e=>testFalsey(e)||!(e!=null&&e.length);const arrIncludesSome=(e,t,n)=>n.some(s=>{var a;return(a=e.getValue(t))==null?void 0:a.includes(s)});arrIncludesSome.autoRemove=e=>testFalsey(e)||!(e!=null&&e.length);const equals=(e,t,n)=>e.getValue(t)===n;equals.autoRemove=e=>testFalsey(e);const weakEquals=(e,t,n)=>e.getValue(t)==n;weakEquals.autoRemove=e=>testFalsey(e);const inNumberRange=(e,t,n)=>{let[s,a]=n;const o=e.getValue(t);return o>=s&&o<=a};inNumberRange.resolveFilterValue=e=>{let[t,n]=e,s=typeof t!="number"?parseFloat(t):t,a=typeof n!="number"?parseFloat(n):n,o=t===null||Number.isNaN(s)?-1/0:s,l=n===null||Number.isNaN(a)?1/0:a;if(o>l){const c=o;o=l,l=c}return[o,l]},inNumberRange.autoRemove=e=>testFalsey(e)||testFalsey(e[0])&&testFalsey(e[1]);const filterFns={includesString,includesStringSensitive,equalsString,arrIncludes,arrIncludesAll,arrIncludesSome,equals,weakEquals,inNumberRange};function testFalsey(e){return e==null||e===""}const ColumnFiltering={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:makeStateUpdater("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{const n=t.getCoreRowModel().flatRows[0],s=n?.getValue(e.id);return typeof s=="string"?filterFns.includesString:typeof s=="number"?filterFns.inNumberRange:typeof s=="boolean"||s!==null&&typeof s=="object"?filterFns.equals:Array.isArray(s)?filterFns.arrIncludes:filterFns.weakEquals},e.getFilterFn=()=>{var n,s;return isFunction$2(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(n=(s=t.options.filterFns)==null?void 0:s[e.columnDef.filterFn])!=null?n:filterFns[e.columnDef.filterFn]},e.getCanFilter=()=>{var n,s,a;return((n=e.columnDef.enableColumnFilter)!=null?n:!0)&&((s=t.options.enableColumnFilters)!=null?s:!0)&&((a=t.options.enableFilters)!=null?a:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(s=>s.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>{var n,s;return(n=(s=t.getState().columnFilters)==null?void 0:s.findIndex(a=>a.id===e.id))!=null?n:-1},e.setFilterValue=n=>{t.setColumnFilters(s=>{const a=e.getFilterFn(),o=s?.find(R=>R.id===e.id),l=functionalUpdate(n,o?o.value:void 0);if(shouldAutoRemoveFilter(a,l,e)){var c;return(c=s?.filter(R=>R.id!==e.id))!=null?c:[]}const d={id:e.id,value:l};if(o){var f;return(f=s?.map(R=>R.id===e.id?d:R))!=null?f:[]}return s!=null&&s.length?[...s,d]:[d]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{const n=e.getAllLeafColumns(),s=a=>{var o;return(o=functionalUpdate(t,a))==null?void 0:o.filter(l=>{const c=n.find(d=>d.id===l.id);if(c){const d=c.getFilterFn();if(shouldAutoRemoveFilter(d,l.value,c))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(s)},e.resetColumnFilters=t=>{var n,s;e.setColumnFilters(t?[]:(n=(s=e.initialState)==null?void 0:s.columnFilters)!=null?n:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function shouldAutoRemoveFilter(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}const sum=(e,t,n)=>n.reduce((s,a)=>{const o=a.getValue(e);return s+(typeof o=="number"?o:0)},0),min=(e,t,n)=>{let s;return n.forEach(a=>{const o=a.getValue(e);o!=null&&(s>o||s===void 0&&o>=o)&&(s=o)}),s},max=(e,t,n)=>{let s;return n.forEach(a=>{const o=a.getValue(e);o!=null&&(s<o||s===void 0&&o>=o)&&(s=o)}),s},extent=(e,t,n)=>{let s,a;return n.forEach(o=>{const l=o.getValue(e);l!=null&&(s===void 0?l>=l&&(s=a=l):(s>l&&(s=l),a<l&&(a=l)))}),[s,a]},mean=(e,t)=>{let n=0,s=0;if(t.forEach(a=>{let o=a.getValue(e);o!=null&&(o=+o)>=o&&(++n,s+=o)}),n)return s/n},median=(e,t)=>{if(!t.length)return;const n=t.map(o=>o.getValue(e));if(!isNumberArray(n))return;if(n.length===1)return n[0];const s=Math.floor(n.length/2),a=n.sort((o,l)=>o-l);return n.length%2!==0?a[s]:(a[s-1]+a[s])/2},unique=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),uniqueCount=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,count=(e,t)=>t.length,aggregationFns={sum,min,max,extent,mean,median,unique,uniqueCount,count},ColumnGrouping={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return(t=(n=e.getValue())==null||n.toString==null?void 0:n.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:makeStateUpdater("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(n=>n!=null&&n.includes(e.id)?n.filter(s=>s!==e.id):[...n??[],e.id])},e.getCanGroup=()=>{var n,s;return((n=e.columnDef.enableGrouping)!=null?n:!0)&&((s=t.options.enableGrouping)!=null?s:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.includes(e.id)},e.getGroupedIndex=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const n=e.getCanGroup();return()=>{n&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const n=t.getCoreRowModel().flatRows[0],s=n?.getValue(e.id);if(typeof s=="number")return aggregationFns.sum;if(Object.prototype.toString.call(s)==="[object Date]")return aggregationFns.extent},e.getAggregationFn=()=>{var n,s;if(!e)throw new Error;return isFunction$2(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(n=(s=t.options.aggregationFns)==null?void 0:s[e.columnDef.aggregationFn])!=null?n:aggregationFns[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var n,s;e.setGrouping(t?[]:(n=(s=e.initialState)==null?void 0:s.grouping)!=null?n:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];const s=t.getColumn(n);return s!=null&&s.columnDef.getGroupingValue?(e._groupingValuesCache[n]=s.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,s)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var a;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((a=n.subRows)!=null&&a.length)}}};function orderColumns(e,t,n){if(!(t!=null&&t.length)||!n)return e;const s=e.filter(o=>!t.includes(o.id));return n==="remove"?s:[...t.map(o=>e.find(l=>l.id===o)).filter(Boolean),...s]}const ColumnOrdering={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:makeStateUpdater("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=memo(n=>[_getVisibleLeafColumns(t,n)],n=>n.findIndex(s=>s.id===e.id),getMemoOptions(t.options,"debugColumns","getIndex")),e.getIsFirstColumn=n=>{var s;return((s=_getVisibleLeafColumns(t,n)[0])==null?void 0:s.id)===e.id},e.getIsLastColumn=n=>{var s;const a=_getVisibleLeafColumns(t,n);return((s=a[a.length-1])==null?void 0:s.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var n;e.setColumnOrder(t?[]:(n=e.initialState.columnOrder)!=null?n:[])},e._getOrderColumnsFn=memo(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,n,s)=>a=>{let o=[];if(!(t!=null&&t.length))o=a;else{const l=[...t],c=[...a];for(;c.length&&l.length;){const d=l.shift(),f=c.findIndex(R=>R.id===d);f>-1&&o.push(c.splice(f,1)[0])}o=[...o,...c]}return orderColumns(o,n,s)},getMemoOptions(e.options,"debugTable","_getOrderColumnsFn"))}},getDefaultColumnPinningState=()=>({left:[],right:[]}),ColumnPinning={getInitialState:e=>({columnPinning:getDefaultColumnPinningState(),...e}),getDefaultOptions:e=>({onColumnPinningChange:makeStateUpdater("columnPinning",e)}),createColumn:(e,t)=>{e.pin=n=>{const s=e.getLeafColumns().map(a=>a.id).filter(Boolean);t.setColumnPinning(a=>{var o,l;if(n==="right"){var c,d;return{left:((c=a?.left)!=null?c:[]).filter(S=>!(s!=null&&s.includes(S))),right:[...((d=a?.right)!=null?d:[]).filter(S=>!(s!=null&&s.includes(S))),...s]}}if(n==="left"){var f,R;return{left:[...((f=a?.left)!=null?f:[]).filter(S=>!(s!=null&&s.includes(S))),...s],right:((R=a?.right)!=null?R:[]).filter(S=>!(s!=null&&s.includes(S)))}}return{left:((o=a?.left)!=null?o:[]).filter(S=>!(s!=null&&s.includes(S))),right:((l=a?.right)!=null?l:[]).filter(S=>!(s!=null&&s.includes(S)))}})},e.getCanPin=()=>e.getLeafColumns().some(s=>{var a,o,l;return((a=s.columnDef.enablePinning)!=null?a:!0)&&((o=(l=t.options.enableColumnPinning)!=null?l:t.options.enablePinning)!=null?o:!0)}),e.getIsPinned=()=>{const n=e.getLeafColumns().map(c=>c.id),{left:s,right:a}=t.getState().columnPinning,o=n.some(c=>s?.includes(c)),l=n.some(c=>a?.includes(c));return o?"left":l?"right":!1},e.getPinnedIndex=()=>{var n,s;const a=e.getIsPinned();return a?(n=(s=t.getState().columnPinning)==null||(s=s[a])==null?void 0:s.indexOf(e.id))!=null?n:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(n,s,a)=>{const o=[...s??[],...a??[]];return n.filter(l=>!o.includes(l.column.id))},getMemoOptions(t.options,"debugRows","getCenterVisibleCells")),e.getLeftVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(n,s)=>(s??[]).map(o=>n.find(l=>l.column.id===o)).filter(Boolean).map(o=>({...o,position:"left"})),getMemoOptions(t.options,"debugRows","getLeftVisibleCells")),e.getRightVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(n,s)=>(s??[]).map(o=>n.find(l=>l.column.id===o)).filter(Boolean).map(o=>({...o,position:"right"})),getMemoOptions(t.options,"debugRows","getRightVisibleCells"))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var n,s;return e.setColumnPinning(t?getDefaultColumnPinningState():(n=(s=e.initialState)==null?void 0:s.columnPinning)!=null?n:getDefaultColumnPinningState())},e.getIsSomeColumnsPinned=t=>{var n;const s=e.getState().columnPinning;if(!t){var a,o;return!!((a=s.left)!=null&&a.length||(o=s.right)!=null&&o.length)}return!!((n=s[t])!=null&&n.length)},e.getLeftLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(s=>t.find(a=>a.id===s)).filter(Boolean),getMemoOptions(e.options,"debugColumns","getLeftLeafColumns")),e.getRightLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(s=>t.find(a=>a.id===s)).filter(Boolean),getMemoOptions(e.options,"debugColumns","getRightLeafColumns")),e.getCenterLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s)=>{const a=[...n??[],...s??[]];return t.filter(o=>!a.includes(o.id))},getMemoOptions(e.options,"debugColumns","getCenterLeafColumns"))}};function safelyAccessDocument(e){return e||(typeof document<"u"?document:null)}const defaultColumnSizing={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},getDefaultColumnSizingInfoState=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),ColumnSizing={getDefaultColumnDef:()=>defaultColumnSizing,getInitialState:e=>({columnSizing:{},columnSizingInfo:getDefaultColumnSizingInfoState(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:makeStateUpdater("columnSizing",e),onColumnSizingInfoChange:makeStateUpdater("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var n,s,a;const o=t.getState().columnSizing[e.id];return Math.min(Math.max((n=e.columnDef.minSize)!=null?n:defaultColumnSizing.minSize,(s=o??e.columnDef.size)!=null?s:defaultColumnSizing.size),(a=e.columnDef.maxSize)!=null?a:defaultColumnSizing.maxSize)},e.getStart=memo(n=>[n,_getVisibleLeafColumns(t,n),t.getState().columnSizing],(n,s)=>s.slice(0,e.getIndex(n)).reduce((a,o)=>a+o.getSize(),0),getMemoOptions(t.options,"debugColumns","getStart")),e.getAfter=memo(n=>[n,_getVisibleLeafColumns(t,n),t.getState().columnSizing],(n,s)=>s.slice(e.getIndex(n)+1).reduce((a,o)=>a+o.getSize(),0),getMemoOptions(t.options,"debugColumns","getAfter")),e.resetSize=()=>{t.setColumnSizing(n=>{let{[e.id]:s,...a}=n;return a})},e.getCanResize=()=>{var n,s;return((n=e.columnDef.enableResizing)!=null?n:!0)&&((s=t.options.enableColumnResizing)!=null?s:!0)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let n=0;const s=a=>{if(a.subHeaders.length)a.subHeaders.forEach(s);else{var o;n+=(o=a.column.getSize())!=null?o:0}};return s(e),n},e.getStart=()=>{if(e.index>0){const n=e.headerGroup.headers[e.index-1];return n.getStart()+n.getSize()}return 0},e.getResizeHandler=n=>{const s=t.getColumn(e.column.id),a=s?.getCanResize();return o=>{if(!s||!a||(o.persist==null||o.persist(),isTouchStartEvent(o)&&o.touches&&o.touches.length>1))return;const l=e.getSize(),c=e?e.getLeafHeaders().map(at=>[at.column.id,at.column.getSize()]):[[s.id,s.getSize()]],d=isTouchStartEvent(o)?Math.round(o.touches[0].clientX):o.clientX,f={},R=(at,ot)=>{typeof ot=="number"&&(t.setColumnSizingInfo(lt=>{var ut,ct;const dt=t.options.columnResizeDirection==="rtl"?-1:1,pt=(ot-((ut=lt?.startOffset)!=null?ut:0))*dt,mt=Math.max(pt/((ct=lt?.startSize)!=null?ct:0),-.999999);return lt.columnSizingStart.forEach(Rt=>{let[yt,It]=Rt;f[yt]=Math.round(Math.max(It+It*mt,0)*100)/100}),{...lt,deltaOffset:pt,deltaPercentage:mt}}),(t.options.columnResizeMode==="onChange"||at==="end")&&t.setColumnSizing(lt=>({...lt,...f})))},S=at=>R("move",at),te=at=>{R("end",at),t.setColumnSizingInfo(ot=>({...ot,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},A=safelyAccessDocument(n),rt={moveHandler:at=>S(at.clientX),upHandler:at=>{A?.removeEventListener("mousemove",rt.moveHandler),A?.removeEventListener("mouseup",rt.upHandler),te(at.clientX)}},st={moveHandler:at=>(at.cancelable&&(at.preventDefault(),at.stopPropagation()),S(at.touches[0].clientX),!1),upHandler:at=>{var ot;A?.removeEventListener("touchmove",st.moveHandler),A?.removeEventListener("touchend",st.upHandler),at.cancelable&&(at.preventDefault(),at.stopPropagation()),te((ot=at.touches[0])==null?void 0:ot.clientX)}},it=passiveEventSupported()?{passive:!1}:!1;isTouchStartEvent(o)?(A?.addEventListener("touchmove",st.moveHandler,it),A?.addEventListener("touchend",st.upHandler,it)):(A?.addEventListener("mousemove",rt.moveHandler,it),A?.addEventListener("mouseup",rt.upHandler,it)),t.setColumnSizingInfo(at=>({...at,startOffset:d,startSize:l,deltaOffset:0,deltaPercentage:0,columnSizingStart:c,isResizingColumn:s.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var n;e.setColumnSizing(t?{}:(n=e.initialState.columnSizing)!=null?n:{})},e.resetHeaderSizeInfo=t=>{var n;e.setColumnSizingInfo(t?getDefaultColumnSizingInfoState():(n=e.initialState.columnSizingInfo)!=null?n:getDefaultColumnSizingInfoState())},e.getTotalSize=()=>{var t,n;return(t=(n=e.getHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getLeftTotalSize=()=>{var t,n;return(t=(n=e.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getCenterTotalSize=()=>{var t,n;return(t=(n=e.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getRightTotalSize=()=>{var t,n;return(t=(n=e.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0}}};let passiveSupported=null;function passiveEventSupported(){if(typeof passiveSupported=="boolean")return passiveSupported;let e=!1;try{const t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener("test",n,t),window.removeEventListener("test",n)}catch{e=!1}return passiveSupported=e,passiveSupported}function isTouchStartEvent(e){return e.type==="touchstart"}const ColumnVisibility={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:makeStateUpdater("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(s=>({...s,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{var n,s;const a=e.columns;return(n=a.length?a.some(o=>o.getIsVisible()):(s=t.getState().columnVisibility)==null?void 0:s[e.id])!=null?n:!0},e.getCanHide=()=>{var n,s;return((n=e.columnDef.enableHiding)!=null?n:!0)&&((s=t.options.enableHiding)!=null?s:!0)},e.getToggleVisibilityHandler=()=>n=>{e.toggleVisibility==null||e.toggleVisibility(n.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=memo(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(s=>s.column.getIsVisible()),getMemoOptions(t.options,"debugRows","_getAllVisibleCells")),e.getVisibleCells=memo(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,s,a)=>[...n,...s,...a],getMemoOptions(t.options,"debugRows","getVisibleCells"))},createTable:e=>{const t=(n,s)=>memo(()=>[s(),s().filter(a=>a.getIsVisible()).map(a=>a.id).join("_")],a=>a.filter(o=>o.getIsVisible==null?void 0:o.getIsVisible()),getMemoOptions(e.options,"debugColumns",n));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=n=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(n),e.resetColumnVisibility=n=>{var s;e.setColumnVisibility(n?{}:(s=e.initialState.columnVisibility)!=null?s:{})},e.toggleAllColumnsVisible=n=>{var s;n=(s=n)!=null?s:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((a,o)=>({...a,[o.id]:n||!(o.getCanHide!=null&&o.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>n=>{var s;e.toggleAllColumnsVisible((s=n.target)==null?void 0:s.checked)}}};function _getVisibleLeafColumns(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const GlobalFaceting={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},GlobalFiltering={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:makeStateUpdater("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n;const s=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof s=="string"||typeof s=="number"}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var n,s,a,o;return((n=e.columnDef.enableGlobalFilter)!=null?n:!0)&&((s=t.options.enableGlobalFilter)!=null?s:!0)&&((a=t.options.enableFilters)!=null?a:!0)&&((o=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?o:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>filterFns.includesString,e.getGlobalFilterFn=()=>{var t,n;const{globalFilterFn:s}=e.options;return isFunction$2(s)?s:s==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[s])!=null?t:filterFns[s]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},RowExpanding={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:makeStateUpdater("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{var s,a;if(!t){e._queue(()=>{t=!0});return}if((s=(a=e.options.autoResetAll)!=null?a:e.options.autoResetExpanded)!=null?s:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=s=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(s),e.toggleAllRowsExpanded=s=>{s??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=s=>{var a,o;e.setExpanded(s?{}:(a=(o=e.initialState)==null?void 0:o.expanded)!=null?a:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(s=>s.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>s=>{s.persist==null||s.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const s=e.getState().expanded;return s===!0||Object.values(s).some(Boolean)},e.getIsAllRowsExpanded=()=>{const s=e.getState().expanded;return typeof s=="boolean"?s===!0:!(!Object.keys(s).length||e.getRowModel().flatRows.some(a=>!a.getIsExpanded()))},e.getExpandedDepth=()=>{let s=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(o=>{const l=o.split(".");s=Math.max(s,l.length)}),s},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(s=>{var a;const o=s===!0?!0:!!(s!=null&&s[e.id]);let l={};if(s===!0?Object.keys(t.getRowModel().rowsById).forEach(c=>{l[c]=!0}):l=s,n=(a=n)!=null?a:!o,!o&&n)return{...l,[e.id]:!0};if(o&&!n){const{[e.id]:c,...d}=l;return d}return s})},e.getIsExpanded=()=>{var n;const s=t.getState().expanded;return!!((n=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?n:s===!0||s?.[e.id])},e.getCanExpand=()=>{var n,s,a;return(n=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?n:((s=t.options.enableExpanding)!=null?s:!0)&&!!((a=e.subRows)!=null&&a.length)},e.getIsAllParentsExpanded=()=>{let n=!0,s=e;for(;n&&s.parentId;)s=t.getRow(s.parentId,!0),n=s.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{const n=e.getCanExpand();return()=>{n&&e.toggleExpanded()}}}},defaultPageIndex=0,defaultPageSize=10,getDefaultPaginationState=()=>({pageIndex:defaultPageIndex,pageSize:defaultPageSize}),RowPagination={getInitialState:e=>({...e,pagination:{...getDefaultPaginationState(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:makeStateUpdater("pagination",e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{var s,a;if(!t){e._queue(()=>{t=!0});return}if((s=(a=e.options.autoResetAll)!=null?a:e.options.autoResetPageIndex)!=null?s:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=s=>{const a=o=>functionalUpdate(s,o);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(a)},e.resetPagination=s=>{var a;e.setPagination(s?getDefaultPaginationState():(a=e.initialState.pagination)!=null?a:getDefaultPaginationState())},e.setPageIndex=s=>{e.setPagination(a=>{let o=functionalUpdate(s,a.pageIndex);const l=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return o=Math.max(0,Math.min(o,l)),{...a,pageIndex:o}})},e.resetPageIndex=s=>{var a,o;e.setPageIndex(s?defaultPageIndex:(a=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageIndex)!=null?a:defaultPageIndex)},e.resetPageSize=s=>{var a,o;e.setPageSize(s?defaultPageSize:(a=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageSize)!=null?a:defaultPageSize)},e.setPageSize=s=>{e.setPagination(a=>{const o=Math.max(1,functionalUpdate(s,a.pageSize)),l=a.pageSize*a.pageIndex,c=Math.floor(l/o);return{...a,pageIndex:c,pageSize:o}})},e.setPageCount=s=>e.setPagination(a=>{var o;let l=functionalUpdate(s,(o=e.options.pageCount)!=null?o:-1);return typeof l=="number"&&(l=Math.max(-1,l)),{...a,pageCount:l}}),e.getPageOptions=memo(()=>[e.getPageCount()],s=>{let a=[];return s&&s>0&&(a=[...new Array(s)].fill(null).map((o,l)=>l)),a},getMemoOptions(e.options,"debugTable","getPageOptions")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:s}=e.getState().pagination,a=e.getPageCount();return a===-1?!0:a===0?!1:s<a-1},e.previousPage=()=>e.setPageIndex(s=>s-1),e.nextPage=()=>e.setPageIndex(s=>s+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var s;return(s=e.options.pageCount)!=null?s:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var s;return(s=e.options.rowCount)!=null?s:e.getPrePaginationRowModel().rows.length}}},getDefaultRowPinningState=()=>({top:[],bottom:[]}),RowPinning={getInitialState:e=>({rowPinning:getDefaultRowPinningState(),...e}),getDefaultOptions:e=>({onRowPinningChange:makeStateUpdater("rowPinning",e)}),createRow:(e,t)=>{e.pin=(n,s,a)=>{const o=s?e.getLeafRows().map(d=>{let{id:f}=d;return f}):[],l=a?e.getParentRows().map(d=>{let{id:f}=d;return f}):[],c=new Set([...l,e.id,...o]);t.setRowPinning(d=>{var f,R;if(n==="bottom"){var S,te;return{top:((S=d?.top)!=null?S:[]).filter(st=>!(c!=null&&c.has(st))),bottom:[...((te=d?.bottom)!=null?te:[]).filter(st=>!(c!=null&&c.has(st))),...Array.from(c)]}}if(n==="top"){var A,rt;return{top:[...((A=d?.top)!=null?A:[]).filter(st=>!(c!=null&&c.has(st))),...Array.from(c)],bottom:((rt=d?.bottom)!=null?rt:[]).filter(st=>!(c!=null&&c.has(st)))}}return{top:((f=d?.top)!=null?f:[]).filter(st=>!(c!=null&&c.has(st))),bottom:((R=d?.bottom)!=null?R:[]).filter(st=>!(c!=null&&c.has(st)))}})},e.getCanPin=()=>{var n;const{enableRowPinning:s,enablePinning:a}=t.options;return typeof s=="function"?s(e):(n=s??a)!=null?n:!0},e.getIsPinned=()=>{const n=[e.id],{top:s,bottom:a}=t.getState().rowPinning,o=n.some(c=>s?.includes(c)),l=n.some(c=>a?.includes(c));return o?"top":l?"bottom":!1},e.getPinnedIndex=()=>{var n,s;const a=e.getIsPinned();if(!a)return-1;const o=(n=a==="top"?t.getTopRows():t.getBottomRows())==null?void 0:n.map(l=>{let{id:c}=l;return c});return(s=o?.indexOf(e.id))!=null?s:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var n,s;return e.setRowPinning(t?getDefaultRowPinningState():(n=(s=e.initialState)==null?void 0:s.rowPinning)!=null?n:getDefaultRowPinningState())},e.getIsSomeRowsPinned=t=>{var n;const s=e.getState().rowPinning;if(!t){var a,o;return!!((a=s.top)!=null&&a.length||(o=s.bottom)!=null&&o.length)}return!!((n=s[t])!=null&&n.length)},e._getPinnedRows=(t,n,s)=>{var a;return((a=e.options.keepPinnedRows)==null||a?(n??[]).map(l=>{const c=e.getRow(l,!0);return c.getIsAllParentsExpanded()?c:null}):(n??[]).map(l=>t.find(c=>c.id===l))).filter(Boolean).map(l=>({...l,position:s}))},e.getTopRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,"top"),getMemoOptions(e.options,"debugRows","getTopRows")),e.getBottomRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,"bottom"),getMemoOptions(e.options,"debugRows","getBottomRows")),e.getCenterRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(t,n,s)=>{const a=new Set([...n??[],...s??[]]);return t.filter(o=>!a.has(o.id))},getMemoOptions(e.options,"debugRows","getCenterRows"))}},RowSelection={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:makeStateUpdater("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var n;return e.setRowSelection(t?{}:(n=e.initialState.rowSelection)!=null?n:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const s={...n},a=e.getPreGroupedRowModel().flatRows;return t?a.forEach(o=>{o.getCanSelect()&&(s[o.id]=!0)}):a.forEach(o=>{delete s[o.id]}),s})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{const s=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),a={...n};return e.getRowModel().rows.forEach(o=>{mutateRowIsSelected(a,o.id,s,!0,e)}),a}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getSelectedRowModel")),e.getFilteredSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getFilteredSelectedRowModel")),e.getGroupedSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getGroupedSelectedRowModel")),e.getIsAllRowsSelected=()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState();let s=!!(t.length&&Object.keys(n).length);return s&&t.some(a=>a.getCanSelect()&&!n[a.id])&&(s=!1),s},e.getIsAllPageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows.filter(a=>a.getCanSelect()),{rowSelection:n}=e.getState();let s=!!t.length;return s&&t.some(a=>!n[a.id])&&(s=!1),s},e.getIsSomeRowsSelected=()=>{var t;const n=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return n>0&&n<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,s)=>{const a=e.getIsSelected();t.setRowSelection(o=>{var l;if(n=typeof n<"u"?n:!a,e.getCanSelect()&&a===n)return o;const c={...o};return mutateRowIsSelected(c,e.id,n,(l=s?.selectChildren)!=null?l:!0,t),c})},e.getIsSelected=()=>{const{rowSelection:n}=t.getState();return isRowSelected(e,n)},e.getIsSomeSelected=()=>{const{rowSelection:n}=t.getState();return isSubRowSelected(e,n)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=t.getState();return isSubRowSelected(e,n)==="all"},e.getCanSelect=()=>{var n;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(n=t.options.enableRowSelection)!=null?n:!0},e.getCanSelectSubRows=()=>{var n;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(n=t.options.enableSubRowSelection)!=null?n:!0},e.getCanMultiSelect=()=>{var n;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(n=t.options.enableMultiRowSelection)!=null?n:!0},e.getToggleSelectedHandler=()=>{const n=e.getCanSelect();return s=>{var a;n&&e.toggleSelected((a=s.target)==null?void 0:a.checked)}}}},mutateRowIsSelected=(e,t,n,s,a)=>{var o;const l=a.getRow(t,!0);n?(l.getCanMultiSelect()||Object.keys(e).forEach(c=>delete e[c]),l.getCanSelect()&&(e[t]=!0)):delete e[t],s&&(o=l.subRows)!=null&&o.length&&l.getCanSelectSubRows()&&l.subRows.forEach(c=>mutateRowIsSelected(e,c.id,n,s,a))};function selectRowsFn(e,t){const n=e.getState().rowSelection,s=[],a={},o=function(l,c){return l.map(d=>{var f;const R=isRowSelected(d,n);if(R&&(s.push(d),a[d.id]=d),(f=d.subRows)!=null&&f.length&&(d={...d,subRows:o(d.subRows)}),R)return d}).filter(Boolean)};return{rows:o(t.rows),flatRows:s,rowsById:a}}function isRowSelected(e,t){var n;return(n=t[e.id])!=null?n:!1}function isSubRowSelected(e,t,n){var s;if(!((s=e.subRows)!=null&&s.length))return!1;let a=!0,o=!1;return e.subRows.forEach(l=>{if(!(o&&!a)&&(l.getCanSelect()&&(isRowSelected(l,t)?o=!0:a=!1),l.subRows&&l.subRows.length)){const c=isSubRowSelected(l,t);c==="all"?o=!0:(c==="some"&&(o=!0),a=!1)}}),a?"all":o?"some":!1}const reSplitAlphaNumeric=/([0-9]+)/gm,alphanumeric$1=(e,t,n)=>compareAlphanumeric(toString$1(e.getValue(n)).toLowerCase(),toString$1(t.getValue(n)).toLowerCase()),alphanumericCaseSensitive=(e,t,n)=>compareAlphanumeric(toString$1(e.getValue(n)),toString$1(t.getValue(n))),text=(e,t,n)=>compareBasic(toString$1(e.getValue(n)).toLowerCase(),toString$1(t.getValue(n)).toLowerCase()),textCaseSensitive=(e,t,n)=>compareBasic(toString$1(e.getValue(n)),toString$1(t.getValue(n))),datetime=(e,t,n)=>{const s=e.getValue(n),a=t.getValue(n);return s>a?1:s<a?-1:0},basic=(e,t,n)=>compareBasic(e.getValue(n),t.getValue(n));function compareBasic(e,t){return e===t?0:e>t?1:-1}function toString$1(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function compareAlphanumeric(e,t){const n=e.split(reSplitAlphaNumeric).filter(Boolean),s=t.split(reSplitAlphaNumeric).filter(Boolean);for(;n.length&&s.length;){const a=n.shift(),o=s.shift(),l=parseInt(a,10),c=parseInt(o,10),d=[l,c].sort();if(isNaN(d[0])){if(a>o)return 1;if(o>a)return-1;continue}if(isNaN(d[1]))return isNaN(l)?-1:1;if(l>c)return 1;if(c>l)return-1}return n.length-s.length}const sortingFns={alphanumeric:alphanumeric$1,alphanumericCaseSensitive,text,textCaseSensitive,datetime,basic},RowSorting={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:makeStateUpdater("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{const n=t.getFilteredRowModel().flatRows.slice(10);let s=!1;for(const a of n){const o=a?.getValue(e.id);if(Object.prototype.toString.call(o)==="[object Date]")return sortingFns.datetime;if(typeof o=="string"&&(s=!0,o.split(reSplitAlphaNumeric).length>1))return sortingFns.alphanumeric}return s?sortingFns.text:sortingFns.basic},e.getAutoSortDir=()=>{const n=t.getFilteredRowModel().flatRows[0];return typeof n?.getValue(e.id)=="string"?"asc":"desc"},e.getSortingFn=()=>{var n,s;if(!e)throw new Error;return isFunction$2(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(n=(s=t.options.sortingFns)==null?void 0:s[e.columnDef.sortingFn])!=null?n:sortingFns[e.columnDef.sortingFn]},e.toggleSorting=(n,s)=>{const a=e.getNextSortingOrder(),o=typeof n<"u"&&n!==null;t.setSorting(l=>{const c=l?.find(A=>A.id===e.id),d=l?.findIndex(A=>A.id===e.id);let f=[],R,S=o?n:a==="desc";if(l!=null&&l.length&&e.getCanMultiSort()&&s?c?R="toggle":R="add":l!=null&&l.length&&d!==l.length-1?R="replace":c?R="toggle":R="replace",R==="toggle"&&(o||a||(R="remove")),R==="add"){var te;f=[...l,{id:e.id,desc:S}],f.splice(0,f.length-((te=t.options.maxMultiSortColCount)!=null?te:Number.MAX_SAFE_INTEGER))}else R==="toggle"?f=l.map(A=>A.id===e.id?{...A,desc:S}:A):R==="remove"?f=l.filter(A=>A.id!==e.id):f=[{id:e.id,desc:S}];return f})},e.getFirstSortDir=()=>{var n,s;return((n=(s=e.columnDef.sortDescFirst)!=null?s:t.options.sortDescFirst)!=null?n:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=n=>{var s,a;const o=e.getFirstSortDir(),l=e.getIsSorted();return l?l!==o&&((s=t.options.enableSortingRemoval)==null||s)&&(!(n&&(a=t.options.enableMultiRemove)!=null)||a)?!1:l==="desc"?"asc":"desc":o},e.getCanSort=()=>{var n,s;return((n=e.columnDef.enableSorting)!=null?n:!0)&&((s=t.options.enableSorting)!=null?s:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var n,s;return(n=(s=e.columnDef.enableMultiSort)!=null?s:t.options.enableMultiSort)!=null?n:!!e.accessorFn},e.getIsSorted=()=>{var n;const s=(n=t.getState().sorting)==null?void 0:n.find(a=>a.id===e.id);return s?s.desc?"desc":"asc":!1},e.getSortIndex=()=>{var n,s;return(n=(s=t.getState().sorting)==null?void 0:s.findIndex(a=>a.id===e.id))!=null?n:-1},e.clearSorting=()=>{t.setSorting(n=>n!=null&&n.length?n.filter(s=>s.id!==e.id):[])},e.getToggleSortingHandler=()=>{const n=e.getCanSort();return s=>{n&&(s.persist==null||s.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(s):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var n,s;e.setSorting(t?[]:(n=(s=e.initialState)==null?void 0:s.sorting)!=null?n:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},builtInFeatures=[Headers$1,ColumnVisibility,ColumnOrdering,ColumnPinning,ColumnFaceting,ColumnFiltering,GlobalFaceting,GlobalFiltering,RowSorting,ColumnGrouping,RowExpanding,RowPagination,RowPinning,RowSelection,ColumnSizing];function createTable(e){var t,n;process.env.NODE_ENV!=="production"&&(e.debugAll||e.debugTable)&&console.info("Creating Table Instance...");const s=[...builtInFeatures,...(t=e._features)!=null?t:[]];let a={_features:s};const o=a._features.reduce((te,A)=>Object.assign(te,A.getDefaultOptions==null?void 0:A.getDefaultOptions(a)),{}),l=te=>a.options.mergeOptions?a.options.mergeOptions(o,te):{...o,...te};let d={...{},...(n=e.initialState)!=null?n:{}};a._features.forEach(te=>{var A;d=(A=te.getInitialState==null?void 0:te.getInitialState(d))!=null?A:d});const f=[];let R=!1;const S={_features:s,options:{...o,...e},initialState:d,_queue:te=>{f.push(te),R||(R=!0,Promise.resolve().then(()=>{for(;f.length;)f.shift()();R=!1}).catch(A=>setTimeout(()=>{throw A})))},reset:()=>{a.setState(a.initialState)},setOptions:te=>{const A=functionalUpdate(te,a.options);a.options=l(A)},getState:()=>a.options.state,setState:te=>{a.options.onStateChange==null||a.options.onStateChange(te)},_getRowId:(te,A,rt)=>{var st;return(st=a.options.getRowId==null?void 0:a.options.getRowId(te,A,rt))!=null?st:`${rt?[rt.id,A].join("."):A}`},getCoreRowModel:()=>(a._getCoreRowModel||(a._getCoreRowModel=a.options.getCoreRowModel(a)),a._getCoreRowModel()),getRowModel:()=>a.getPaginationRowModel(),getRow:(te,A)=>{let rt=(A?a.getPrePaginationRowModel():a.getRowModel()).rowsById[te];if(!rt&&(rt=a.getCoreRowModel().rowsById[te],!rt))throw process.env.NODE_ENV!=="production"?new Error(`getRow could not find row with ID: ${te}`):new Error;return rt},_getDefaultColumnDef:memo(()=>[a.options.defaultColumn],te=>{var A;return te=(A=te)!=null?A:{},{header:rt=>{const st=rt.header.column.columnDef;return st.accessorKey?st.accessorKey:st.accessorFn?st.id:null},cell:rt=>{var st,it;return(st=(it=rt.renderValue())==null||it.toString==null?void 0:it.toString())!=null?st:null},...a._features.reduce((rt,st)=>Object.assign(rt,st.getDefaultColumnDef==null?void 0:st.getDefaultColumnDef()),{}),...te}},getMemoOptions(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>a.options.columns,getAllColumns:memo(()=>[a._getColumnDefs()],te=>{const A=function(rt,st,it){return it===void 0&&(it=0),rt.map(at=>{const ot=createColumn(a,at,it,st),lt=at;return ot.columns=lt.columns?A(lt.columns,ot,it+1):[],ot})};return A(te)},getMemoOptions(e,"debugColumns","getAllColumns")),getAllFlatColumns:memo(()=>[a.getAllColumns()],te=>te.flatMap(A=>A.getFlatColumns()),getMemoOptions(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:memo(()=>[a.getAllFlatColumns()],te=>te.reduce((A,rt)=>(A[rt.id]=rt,A),{}),getMemoOptions(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:memo(()=>[a.getAllColumns(),a._getOrderColumnsFn()],(te,A)=>{let rt=te.flatMap(st=>st.getLeafColumns());return A(rt)},getMemoOptions(e,"debugColumns","getAllLeafColumns")),getColumn:te=>{const A=a._getAllFlatColumnsById()[te];return process.env.NODE_ENV!=="production"&&!A&&console.error(`[Table] Column with id '${te}' does not exist.`),A}};Object.assign(a,S);for(let te=0;te<a._features.length;te++){const A=a._features[te];A==null||A.createTable==null||A.createTable(a)}return a}function getCoreRowModel(){return e=>memo(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},s=function(a,o,l){o===void 0&&(o=0);const c=[];for(let f=0;f<a.length;f++){const R=createRow(e,e._getRowId(a[f],f,l),a[f],f,o,void 0,l?.id);if(n.flatRows.push(R),n.rowsById[R.id]=R,c.push(R),e.options.getSubRows){var d;R.originalSubRows=e.options.getSubRows(a[f],f),(d=R.originalSubRows)!=null&&d.length&&(R.subRows=s(R.originalSubRows,o+1,R))}}return c};return n.rows=s(t),n},getMemoOptions(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function expandRows(e){const t=[],n=s=>{var a;t.push(s),(a=s.subRows)!=null&&a.length&&s.getIsExpanded()&&s.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}function filterRows(e,t,n){return n.options.filterFromLeafRows?filterRowModelFromLeafs(e,t,n):filterRowModelFromRoot(e,t,n)}function filterRowModelFromLeafs(e,t,n){var s;const a=[],o={},l=(s=n.options.maxLeafRowFilterDepth)!=null?s:100,c=function(d,f){f===void 0&&(f=0);const R=[];for(let te=0;te<d.length;te++){var S;let A=d[te];const rt=createRow(n,A.id,A.original,A.index,A.depth,void 0,A.parentId);if(rt.columnFilters=A.columnFilters,(S=A.subRows)!=null&&S.length&&f<l){if(rt.subRows=c(A.subRows,f+1),A=rt,t(A)&&!rt.subRows.length){R.push(A),o[A.id]=A,a.push(A);continue}if(t(A)||rt.subRows.length){R.push(A),o[A.id]=A,a.push(A);continue}}else A=rt,t(A)&&(R.push(A),o[A.id]=A,a.push(A))}return R};return{rows:c(e),flatRows:a,rowsById:o}}function filterRowModelFromRoot(e,t,n){var s;const a=[],o={},l=(s=n.options.maxLeafRowFilterDepth)!=null?s:100,c=function(d,f){f===void 0&&(f=0);const R=[];for(let te=0;te<d.length;te++){let A=d[te];if(t(A)){var S;if((S=A.subRows)!=null&&S.length&&f<l){const st=createRow(n,A.id,A.original,A.index,A.depth,void 0,A.parentId);st.subRows=c(A.subRows,f+1),A=st}R.push(A),a.push(A),o[A.id]=A}}return R};return{rows:c(e),flatRows:a,rowsById:o}}function getFilteredRowModel(){return e=>memo(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,s)=>{if(!t.rows.length||!(n!=null&&n.length)&&!s){for(let te=0;te<t.flatRows.length;te++)t.flatRows[te].columnFilters={},t.flatRows[te].columnFiltersMeta={};return t}const a=[],o=[];(n??[]).forEach(te=>{var A;const rt=e.getColumn(te.id);if(!rt)return;const st=rt.getFilterFn();if(!st){process.env.NODE_ENV!=="production"&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${rt.id}.`);return}a.push({id:te.id,filterFn:st,resolvedValue:(A=st.resolveFilterValue==null?void 0:st.resolveFilterValue(te.value))!=null?A:te.value})});const l=(n??[]).map(te=>te.id),c=e.getGlobalFilterFn(),d=e.getAllLeafColumns().filter(te=>te.getCanGlobalFilter());s&&c&&d.length&&(l.push("__global__"),d.forEach(te=>{var A;o.push({id:te.id,filterFn:c,resolvedValue:(A=c.resolveFilterValue==null?void 0:c.resolveFilterValue(s))!=null?A:s})}));let f,R;for(let te=0;te<t.flatRows.length;te++){const A=t.flatRows[te];if(A.columnFilters={},a.length)for(let rt=0;rt<a.length;rt++){f=a[rt];const st=f.id;A.columnFilters[st]=f.filterFn(A,st,f.resolvedValue,it=>{A.columnFiltersMeta[st]=it})}if(o.length){for(let rt=0;rt<o.length;rt++){R=o[rt];const st=R.id;if(R.filterFn(A,st,R.resolvedValue,it=>{A.columnFiltersMeta[st]=it})){A.columnFilters.__global__=!0;break}}A.columnFilters.__global__!==!0&&(A.columnFilters.__global__=!1)}}const S=te=>{for(let A=0;A<l.length;A++)if(te.columnFilters[l[A]]===!1)return!1;return!0};return filterRows(t.rows,S,e)},getMemoOptions(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex()))}function getPaginationRowModel(e){return t=>memo(()=>[t.getState().pagination,t.getPrePaginationRowModel(),t.options.paginateExpandedRows?void 0:t.getState().expanded],(n,s)=>{if(!s.rows.length)return s;const{pageSize:a,pageIndex:o}=n;let{rows:l,flatRows:c,rowsById:d}=s;const f=a*o,R=f+a;l=l.slice(f,R);let S;t.options.paginateExpandedRows?S={rows:l,flatRows:c,rowsById:d}:S=expandRows({rows:l,flatRows:c,rowsById:d}),S.flatRows=[];const te=A=>{S.flatRows.push(A),A.subRows.length&&A.subRows.forEach(te)};return S.rows.forEach(te),S},getMemoOptions(t.options,"debugTable","getPaginationRowModel"))}function getSortedRowModel(){return e=>memo(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;const s=e.getState().sorting,a=[],o=s.filter(d=>{var f;return(f=e.getColumn(d.id))==null?void 0:f.getCanSort()}),l={};o.forEach(d=>{const f=e.getColumn(d.id);f&&(l[d.id]={sortUndefined:f.columnDef.sortUndefined,invertSorting:f.columnDef.invertSorting,sortingFn:f.getSortingFn()})});const c=d=>{const f=d.map(R=>({...R}));return f.sort((R,S)=>{for(let A=0;A<o.length;A+=1){var te;const rt=o[A],st=l[rt.id],it=st.sortUndefined,at=(te=rt?.desc)!=null?te:!1;let ot=0;if(it){const lt=R.getValue(rt.id),ut=S.getValue(rt.id),ct=lt===void 0,dt=ut===void 0;if(ct||dt){if(it==="first")return ct?-1:1;if(it==="last")return ct?1:-1;ot=ct&&dt?0:ct?it:-it}}if(ot===0&&(ot=st.sortingFn(R,S,rt.id)),ot!==0)return at&&(ot*=-1),st.invertSorting&&(ot*=-1),ot}return R.index-S.index}),f.forEach(R=>{var S;a.push(R),(S=R.subRows)!=null&&S.length&&(R.subRows=c(R.subRows))}),f};return{rows:c(n.rows),flatRows:a,rowsById:n.rowsById}},getMemoOptions(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function flexRender(e,t){return e?isReactComponent(e)?React__namespace.createElement(e,t):e:null}function isReactComponent(e){return isClassComponent(e)||typeof e=="function"||isExoticComponent(e)}function isClassComponent(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function isExoticComponent(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function useReactTable(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=React__namespace.useState(()=>({current:createTable(t)})),[s,a]=React__namespace.useState(()=>n.current.initialState);return n.current.setOptions(o=>({...o,...e,state:{...s,...e.state},onStateChange:l=>{a(l),e.onStateChange==null||e.onStateChange(l)}})),n.current}function DataTable({columns:e,data:t,uniqueValues:n,tableClass:s,loading:a,initialSort:o}){const[l,c]=React.useState(o??[]),[d,f]=React.useState([]),[R,S]=React.useState({pageIndex:0,pageSize:10}),[te,A]=React.useState(null),rt=useReactTable({data:a?[]:t,columns:e,getCoreRowModel:getCoreRowModel(),onSortingChange:c,getSortedRowModel:getSortedRowModel(),onColumnFiltersChange:f,getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),onPaginationChange:S,state:{sorting:l,columnFilters:d,pagination:R},manualPagination:a,manualSorting:a,manualFiltering:a}),st=(it,at)=>{it.toggleSorting(at),A(null)};return a?jsxRuntime.jsxs("div",{className:"@container space-y-4",children:[jsxRuntime.jsx("div",{className:`rounded-md border ${s??""}`,children:jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:jsxRuntime.jsx(TableRow,{children:e.map((it,at)=>jsxRuntime.jsx(TableHead,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-header-${at}`))})}),jsxRuntime.jsx(TableBody,{children:Array.from({length:R.pageSize}).map((it,at)=>jsxRuntime.jsx(TableRow,{children:e.map((ot,lt)=>jsxRuntime.jsx(TableCell,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-cell-${at}-${lt}`))},`skeleton-row-${at}`))})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-4 @[35rem]:flex-row @[35rem]:justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-[110px]"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-[70px]"})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"hidden h-8 w-8 lg:flex"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-8"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-8"})]}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8"}),jsxRuntime.jsx(Skeleton,{className:"hidden h-8 w-8 lg:flex"})]})]})]}):jsxRuntime.jsxs("div",{className:"@container space-y-4",children:[jsxRuntime.jsxs(ScrollArea,{className:`rounded-md border ${s??""}`,children:[jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:rt.getHeaderGroups().map(it=>jsxRuntime.jsx(TableRow,{children:it.headers.map(at=>jsxRuntime.jsx(TableHead,{children:at.isPlaceholder?null:at.column.getCanSort()||at.column.getCanFilter()?jsxRuntime.jsxs(Popover,{open:te===at.id,onOpenChange:ot=>A(ot?at.id:null),children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"pl-0",children:[flexRender(at.column.columnDef.header,at.getContext()),at.column.getIsFiltered()?jsxRuntime.jsx(Funnel,{className:"ml-2 h-4 w-4"}):at.column.getIsSorted()==="asc"?jsxRuntime.jsx(ArrowUp,{className:"ml-2 h-4 w-4"}):at.column.getIsSorted()==="desc"?jsxRuntime.jsx(ArrowDown,{className:"ml-2 h-4 w-4"}):jsxRuntime.jsx(ArrowUpDown,{className:"ml-2 h-4 w-4"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56",children:jsxRuntime.jsxs("div",{className:"space-y-2",children:[at.column.getCanSort()&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"w-full justify-start",onClick:()=>st(at.column,!1),children:[jsxRuntime.jsx(ArrowUp,{className:"mr-2 h-4 w-4"}),"Sort Ascending"]}),jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"w-full justify-start",onClick:()=>st(at.column,!0),children:[jsxRuntime.jsx(ArrowDown,{className:"mr-2 h-4 w-4"}),"Sort Descending"]})]}),at.column.getCanFilter()&&jsxRuntime.jsx("div",{className:"px-2 py-1",children:n[at.column.id]?jsxRuntime.jsxs(Select$1,{onValueChange:ot=>at.column.setFilterValue(ot==="all"?void 0:[ot]),children:[jsxRuntime.jsx(SelectTrigger,{children:jsxRuntime.jsx(SelectValue,{placeholder:`Filter ${at.column.columnDef.header}...`})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"all",children:"All"}),n[at.column.id]?.map(ot=>jsxRuntime.jsx(SelectItem,{value:ot||"empty",children:ot||"(Empty)"},ot))]})]}):jsxRuntime.jsx(Input,{placeholder:`Filter ${at.column.columnDef.header}...`,value:at.column.getFilterValue()??"",onChange:ot=>at.column.setFilterValue(ot.target.value),className:"w-full"})})]})})]}):jsxRuntime.jsx("div",{className:"py-2 px-4",children:flexRender(at.column.columnDef.header,at.getContext())})},at.id))},it.id))}),jsxRuntime.jsx(TableBody,{children:rt.getRowModel().rows?.length?rt.getRowModel().rows.map(it=>jsxRuntime.jsx(TableRow,{"data-state":it.getIsSelected()&&"selected",children:it.getVisibleCells().map(at=>jsxRuntime.jsx(TableCell,{children:flexRender(at.column.columnDef.cell,at.getContext())},at.id))},it.id)):jsxRuntime.jsx(TableRow,{children:jsxRuntime.jsx(TableCell,{colSpan:e.length,className:"h-24 text-center",children:"No results."})})})]}),jsxRuntime.jsx(ScrollBar,{orientation:"horizontal"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-4 @[35rem]:flex-row @[35rem]:justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Rows per page"}),jsxRuntime.jsxs(Select$1,{value:`${rt.getState().pagination.pageSize}`,onValueChange:it=>{rt.setPageSize(Number(it))},children:[jsxRuntime.jsx(SelectTrigger,{className:"h-8 w-[70px]",children:jsxRuntime.jsx(SelectValue,{asChild:!0,children:jsxRuntime.jsx("span",{children:rt.getState().pagination.pageSize})})}),jsxRuntime.jsx(SelectContent,{side:"top",children:[10,20,30,40,50].map(it=>jsxRuntime.jsx(SelectItem,{value:`${it}`,children:jsxRuntime.jsx("span",{children:it})},it))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxs(Button$1,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>rt.setPageIndex(0),disabled:!rt.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to first page"}),jsxRuntime.jsx(ChevronsLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>rt.previousPage(),disabled:!rt.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to previous page"}),jsxRuntime.jsx(ChevronLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Page"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:rt.getState().pagination.pageIndex+1}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"of"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:rt.getPageCount()})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>rt.nextPage(),disabled:!rt.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to next page"}),jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>rt.setPageIndex(rt.getPageCount()-1),disabled:!rt.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to last page"}),jsxRuntime.jsx(ChevronsRight,{className:"h-4 w-4"})]})]})]})]})}function PartnerCard({account:e,action:t,loading:n=!1,className:s,withAbout:a=!1}){const[o,l]=React.useState(!0),[c,d]=React.useState(!1),f=e?.ApplicationId,R=useApiOrigin(),S=f?buildApiUrl(`/V4/Partner/${f}/Account/Video`,R):null,{data:te}=useGetV4PartnerByApplicationIdAccountVideoExistsQuery({applicationId:f??""},{skip:!f||n}),A=typeof te=="boolean"?te:typeof te=="string"?te.toLowerCase()==="true":!1,rt=()=>{l(!1)};return n||!e?jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${s}`,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-48 mt-1"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]}),a&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-48"})]})]}):jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${s}`,children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Partner",applicationId:e.ApplicationId,publicName:e.PublicName}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[(e.IsManufacturer||e.IsReseller||e.IsSalesAgency||e.HasShopifyStore||e.IsVendor)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.IsManufacturer&&jsxRuntime.jsx(Badge,{variant:"info",children:"Manufacturer"}),e.IsReseller&&jsxRuntime.jsx(Badge,{variant:"success",children:"Reseller"}),e.IsSalesAgency&&jsxRuntime.jsx(Badge,{variant:"outline",children:"Agency"}),e.HasShopifyStore&&jsxRuntime.jsx(Badge,{variant:"secondary",children:"Shopify"}),e.IsVendor&&jsxRuntime.jsx(Badge,{variant:"outline",children:"Vendor"})]}),a&&e.About&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.About??""}})]})}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[A&&S?jsxRuntime.jsxs(Dialog,{open:c,onOpenChange:st=>{d(st),st&&l(!0)},children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"flex items-center gap-2",children:[jsxRuntime.jsx(Video,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Watch Video"})]})}),jsxRuntime.jsxs(DialogContent,{className:"@sm:max-w-[360px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{children:[e.PublicName," Video"]})}),jsxRuntime.jsxs("div",{className:"w-full h-[640px] rounded-md overflow-hidden",children:[o&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:S,controls:!0,preload:"auto",playsInline:!0,autoPlay:!0,"aria-label":`Video for ${e.PublicName}`,className:`w-full h-full object-cover object-center ${o?"invisible":"visible"}`,onLoadedData:rt,onError:()=>l(!1)})]})]})]}):jsxRuntime.jsx("div",{}),t||jsxRuntime.jsxs(Button$1,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})]})]})}function ResellerCard({reseller:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1}){if(o||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsx("div",{className:"flex",children:jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const l=[e.City,e.Province,e.Country].filter(Boolean),c=l.length>0?l.join(", "):"Location not provided",d=e.Priority?.trim(),f=!!e.Qualification?.QualificationId&&e.Qualification?.QualificationId!=="Suspended",R=!!e.OnHold&&e.OnHold!==0,S=!!d,te=A=>{const rt=A.toLowerCase();return rt.includes("starter")||rt.includes("basic")?"secondary":rt.includes("exclusive")||rt.includes("jean coutu")||rt.includes("novexco")||rt.includes("coopsco")?"success":"info"};return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Reseller",applicationId:e.ResellerId,publicName:e.PublicName,name:e.Name,location:c,link:t,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:e.SalesStatistics&&e.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:e.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(f||R||S)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[f&&jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),R&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),S&&jsxRuntime.jsx(Badge,{variant:te(d),children:d})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${e.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${e.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:e.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]}),e?.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:e?.SalesData.SalesYearToDay?formatMoney(e?.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:e?.SalesData.SalesLast3Months?formatMoney(e?.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:e?.SalesData.SalesLast30Days?formatMoney(e?.SalesData.SalesLast30Days):"—"})]})]})}),(s||a)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:s&&s}),a&&jsxRuntime.jsx("div",{children:a})]})]})}const Table=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{className:"relative w-full overflow-auto",children:jsxRuntime.jsx("table",{ref:n,className:cn("w-full caption-bottom text-sm",e),...t})}));Table.displayName="Table";const TableHeader=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("thead",{ref:n,className:cn("[&_tr]:border-b",e),...t}));TableHeader.displayName="TableHeader";const TableBody=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tbody",{ref:n,className:cn("[&_tr:last-child]:border-0",e),...t}));TableBody.displayName="TableBody";const TableFooter=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tfoot",{ref:n,className:cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));TableFooter.displayName="TableFooter";const TableRow=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tr",{ref:n,className:cn("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));TableRow.displayName="TableRow";const TableHead=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("th",{ref:n,className:cn("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t,children:React__namespace.isValidElement(t.children)&&t.children.type==="span"?t.children:jsxRuntime.jsx("span",{children:t.children})}));TableHead.displayName="TableHead";const TableCell=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("td",{ref:n,className:cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t,children:React__namespace.isValidElement(t.children)&&t.children.type==="span"?t.children:jsxRuntime.jsx("span",{children:t.children})}));TableCell.displayName="TableCell";const TableCaption=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("caption",{ref:n,className:cn("mt-4 text-sm text-muted-foreground",e),...t}));TableCaption.displayName="TableCaption";const Topbar=React.forwardRef(({onSignOut:e,handleValidSearch:t,rightMenu:n,searchPlaceholder:s},a)=>{const[o,l]=React.useState(""),c=reactRouterDom.useLocation(),{toast:d}=useToast();React.useEffect(()=>{const te=new URLSearchParams(c.search).get("q");te&&l(te)},[c.search]);const f=()=>{const S=o.trim();if(!S||S.length<2){d({title:"Enter more characters to search",description:"At least 2 characters are needed to search products.",variant:"destructive",duration:5e3});return}t(S)},R=S=>{S.key==="Enter"&&f()};return jsxRuntime.jsxs("header",{className:"flex h-16 items-center gap-4 border-b bg-sidebar px-6 fixed top-0 right-0 z-50 left-0 text-sidebar-foreground border-sidebar-border peer-data-[state=expanded]:md:left-(--sidebar-width) peer-data-[collapsible=offcanvas]:md:left-0 peer-data-[collapsible=icon]:md:left-(--sidebar-width-icon)",children:[jsxRuntime.jsx(SidebarTrigger,{className:"lg:hidden",children:jsxRuntime.jsx(Menu$1,{className:"h-6 w-6"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center gap-4",children:jsxRuntime.jsx("div",{className:"relative w-full max-w-sm",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{type:"button",className:"absolute left-2 top-1/2 -translate-y-1/2",onClick:f,"aria-label":"Search",children:jsxRuntime.jsx(Search,{className:"h-4 w-4 text-muted-foreground"})}),jsxRuntime.jsx(Input,{placeholder:s??"Search...",className:"w-full pl-8 bg-background text-foreground",value:o,onChange:S=>l(S.target.value),onKeyDown:R,ref:a},"topbar-search")]})})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[n,e&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Button$1,{variant:"ghost",size:"icon",className:"h-9 w-9",onClick:e,children:[jsxRuntime.jsx(LogOut,{className:"h-4 w-4 text-sidebar-foreground"}),jsxRuntime.jsx("span",{className:"sr-only",children:"Sign out"})]})})]})]})});Topbar.displayName="Topbar";function ActiveOrdersCard({orders:e,loading:t=!1}){const n=React.useMemo(()=>{if(!e||e.length===0)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const a=e.filter(it=>it.DocumentType==="Order"),o=e.filter(it=>it.DocumentType==="Shipment"),l=a.filter(it=>it.WarehouseCode!=="3PLE"),c=l.reduce((it,at)=>it+(at.Quantity||0),0),d=l.reduce((it,at)=>it+(at.ExtendedPrice||0),0),f=a.filter(it=>it.WarehouseCode==="3PLE"),R=f.reduce((it,at)=>it+(at.Quantity||0),0),S=f.reduce((it,at)=>it+(at.ExtendedPrice||0),0),te=o.length,A=o.reduce((it,at)=>it+(at.ExtendedPrice||0),0),rt=c+R+te,st=d+S+A;return{all:{orders:rt,amount:st},processing:{orders:c,amount:d},shipped:{orders:te,amount:A},delayed:{orders:R,amount:S}}},[e]),s=[{name:"All",icon:Package,stripeClass:"bg-info/60",iconBgClass:"bg-info/90",iconTextClass:"text-info-foreground",orders:n.all.orders,amount:n.all.amount},{name:"Processing",icon:RefreshCcw,stripeClass:"bg-warning/60",iconBgClass:"bg-warning/90",iconTextClass:"text-warning-foreground",orders:n.processing.orders,amount:n.processing.amount},{name:"Shipped",icon:Truck,stripeClass:"bg-success/60",iconBgClass:"bg-success/90",iconTextClass:"text-success-foreground",orders:n.shipped.orders,amount:n.shipped.amount},{name:"Delayed",icon:CircleAlert,stripeClass:"bg-destructive/60",iconBgClass:"bg-destructive/90",iconTextClass:"text-destructive-foreground",orders:n.delayed.orders,amount:n.delayed.amount}];return t?jsxRuntime.jsxs(Card,{className:"@container",children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:[1,2,3,4].map(a=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:"bg-border h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]},a))})]}):jsxRuntime.jsxs(Card,{className:"@container",children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:s.map(a=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:`${a.stripeClass} h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:a.name}),jsxRuntime.jsx("div",{className:`${a.iconBgClass} p-2 rounded-full`,children:jsxRuntime.jsx(a.icon,{className:`size-4 shrink-0 ${a.iconTextClass}`})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:a.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:formatMoney(a.amount)})]})]})]})]},a.name))})]})}var CHECKBOX_NAME="Checkbox",[createCheckboxContext]=createContextScope$2(CHECKBOX_NAME),[CheckboxProviderImpl,useCheckboxContext]=createCheckboxContext(CHECKBOX_NAME);function CheckboxProvider(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:a,disabled:o,form:l,name:c,onCheckedChange:d,required:f,value:R="on",internal_do_not_use_render:S}=e,[te,A]=useControllableState({prop:n,defaultProp:a??!1,onChange:d,caller:CHECKBOX_NAME}),[rt,st]=React__namespace.useState(null),[it,at]=React__namespace.useState(null),ot=React__namespace.useRef(!1),lt=rt?!!l||!!rt.closest("form"):!0,ut={checked:te,disabled:o,setChecked:A,control:rt,setControl:st,name:c,form:l,value:R,hasConsumerStoppedPropagationRef:ot,required:f,defaultChecked:isIndeterminate(a)?!1:a,isFormControl:lt,bubbleInput:it,setBubbleInput:at};return jsxRuntime.jsx(CheckboxProviderImpl,{scope:t,...ut,children:isFunction$1(S)?S(ut):s})}var TRIGGER_NAME$4="CheckboxTrigger",CheckboxTrigger=React__namespace.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},a)=>{const{control:o,value:l,disabled:c,checked:d,required:f,setControl:R,setChecked:S,hasConsumerStoppedPropagationRef:te,isFormControl:A,bubbleInput:rt}=useCheckboxContext(TRIGGER_NAME$4,e),st=useComposedRefs(a,R),it=React__namespace.useRef(d);return React__namespace.useEffect(()=>{const at=o?.form;if(at){const ot=()=>S(it.current);return at.addEventListener("reset",ot),()=>at.removeEventListener("reset",ot)}},[o,S]),jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"checkbox","aria-checked":isIndeterminate(d)?"mixed":d,"aria-required":f,"data-state":getState$3(d),"data-disabled":c?"":void 0,disabled:c,value:l,...s,ref:st,onKeyDown:composeEventHandlers(t,at=>{at.key==="Enter"&&at.preventDefault()}),onClick:composeEventHandlers(n,at=>{S(ot=>isIndeterminate(ot)?!0:!ot),rt&&A&&(te.current=at.isPropagationStopped(),te.current||at.stopPropagation())})})});CheckboxTrigger.displayName=TRIGGER_NAME$4;var Checkbox$1=React__namespace.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:a,defaultChecked:o,required:l,disabled:c,value:d,onCheckedChange:f,form:R,...S}=e;return jsxRuntime.jsx(CheckboxProvider,{__scopeCheckbox:n,checked:a,defaultChecked:o,disabled:c,required:l,onCheckedChange:f,name:s,form:R,value:d,internal_do_not_use_render:({isFormControl:te})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(CheckboxTrigger,{...S,ref:t,__scopeCheckbox:n}),te&&jsxRuntime.jsx(CheckboxBubbleInput,{__scopeCheckbox:n})]})})});Checkbox$1.displayName=CHECKBOX_NAME;var INDICATOR_NAME="CheckboxIndicator",CheckboxIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...a}=e,o=useCheckboxContext(INDICATOR_NAME,n);return jsxRuntime.jsx(Presence,{present:s||isIndeterminate(o.checked)||o.checked===!0,children:jsxRuntime.jsx(Primitive$4.span,{"data-state":getState$3(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});CheckboxIndicator.displayName=INDICATOR_NAME;var BUBBLE_INPUT_NAME="CheckboxBubbleInput",CheckboxBubbleInput=React__namespace.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:c,disabled:d,name:f,value:R,form:S,bubbleInput:te,setBubbleInput:A}=useCheckboxContext(BUBBLE_INPUT_NAME,e),rt=useComposedRefs(n,A),st=usePrevious(o),it=useSize(s);React__namespace.useEffect(()=>{const ot=te;if(!ot)return;const lt=window.HTMLInputElement.prototype,ct=Object.getOwnPropertyDescriptor(lt,"checked").set,dt=!a.current;if(st!==o&&ct){const pt=new Event("click",{bubbles:dt});ot.indeterminate=isIndeterminate(o),ct.call(ot,isIndeterminate(o)?!1:o),ot.dispatchEvent(pt)}},[te,st,o,a]);const at=React__namespace.useRef(isIndeterminate(o)?!1:o);return jsxRuntime.jsx(Primitive$4.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??at.current,required:c,disabled:d,name:f,value:R,form:S,...t,tabIndex:-1,ref:rt,style:{...t.style,...it,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});CheckboxBubbleInput.displayName=BUBBLE_INPUT_NAME;function isFunction$1(e){return typeof e=="function"}function isIndeterminate(e){return e==="indeterminate"}function getState$3(e){return isIndeterminate(e)?"indeterminate":e?"checked":"unchecked"}const Checkbox=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Checkbox$1,{ref:n,className:cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:jsxRuntime.jsx(CheckboxIndicator,{className:cn("flex items-center justify-center text-current"),children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}));Checkbox.displayName=Checkbox$1.displayName;function CheckboxCardList({items:e,selectedIds:t,onSelectedIdsChange:n,disabled:s=!1,loading:a=!1,selectionMode:o="multiple",layout:l="stack",gridColumns:c=2,emptyState:d,loadingState:f,getItemAriaLabel:R,renderItem:S,className:te,...A}){const rt=React__namespace.useId(),st=React__namespace.useMemo(()=>new Set(t),[t]),it=l==="grid"?cn("grid gap-3",c===2&&"grid-cols-1 sm:grid-cols-2"):"space-y-3",at=React__namespace.useCallback(ot=>{if(s||a||ot.disabled)return;const lt=st.has(ot.id);if(o==="single"){n(lt?[]:[ot.id]);return}if(lt){n(t.filter(ut=>ut!==ot.id));return}n([...t,ot.id])},[s,a,n,st,t,o]);return a?jsxRuntime.jsx("div",{className:cn(it,te),role:"status","aria-live":"polite",...A,children:f??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Loading options"}),Array.from({length:l==="grid"?4:3}).map((ot,lt)=>jsxRuntime.jsxs("div",{className:"rounded-xl border border-border bg-card p-4 shadow-sm","aria-hidden":"true",children:[jsxRuntime.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-muted"}),jsxRuntime.jsx("div",{className:"mt-2 h-3 w-1/2 animate-pulse rounded bg-muted"})]},`loading-${lt}`))]})}):e.length===0?jsxRuntime.jsx("div",{className:cn(it,te),...A,children:d??jsxRuntime.jsx("div",{className:"rounded-xl border border-dashed border-border bg-muted/30 p-4 text-sm text-muted-foreground",children:"No options are available."})}):jsxRuntime.jsx("div",{className:cn(it,te),role:"group","aria-disabled":s||void 0,...A,children:e.map((ot,lt)=>{const ut=st.has(ot.id),ct=s||ot.disabled===!0,dt=`${rt}-${lt}-label`,pt=`${rt}-${lt}-description`;return jsxRuntime.jsxs("button",{type:"button",role:"checkbox","aria-checked":ut,"aria-disabled":ct,"aria-label":R?.(ot)??ot.label,"aria-labelledby":S?void 0:dt,"aria-describedby":!S&&ot.description?pt:void 0,disabled:ct,onClick:()=>at(ot),className:cn("flex w-full items-start gap-3 rounded-xl border bg-card p-4 text-left shadow-sm transition-colors transition-shadow","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","hover:bg-muted/30 hover:shadow",ut?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border",ct&&"cursor-not-allowed opacity-60 hover:bg-card hover:shadow-sm"),children:[jsxRuntime.jsx("span",{"aria-hidden":"true",className:cn("mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-primary shadow-sm",ut?"bg-primary text-primary-foreground":"bg-background text-transparent"),children:jsxRuntime.jsx(Check,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"sr-only",children:ot.label}),S(ot,{checked:ut,disabled:ct,index:lt})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(ot.prefix||ot.emphasis)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-baseline gap-1 text-xs",children:[ot.prefix&&jsxRuntime.jsx("span",{className:"font-semibold uppercase tracking-wide text-muted-foreground",children:ot.prefix}),ot.emphasis&&jsxRuntime.jsx("span",{className:"font-semibold text-foreground",children:ot.emphasis})]}),jsxRuntime.jsx("span",{id:dt,className:cn("block text-sm font-medium text-foreground",(ot.prefix||ot.emphasis)&&"mt-1"),children:ot.label}),ot.description&&jsxRuntime.jsx("span",{id:pt,className:"mt-1 block text-sm text-muted-foreground",children:ot.description})]})})]},ot.id)})})}var U=1,Y$1=.9,H=.8,J=.17,p=.1,u=.999,$=.9999,k$1=.99,m=/[\\\/_+.#"@\[\(\{&]/,B$1=/[\\\/_+.#"@\[\(\{&]/g,K$1=/[\s-]/,X=/[\s-]/g;function G(e,t,n,s,a,o,l){if(o===t.length)return a===e.length?U:k$1;var c=`${a},${o}`;if(l[c]!==void 0)return l[c];for(var d=s.charAt(o),f=n.indexOf(d,a),R=0,S,te,A,rt;f>=0;)S=G(e,t,n,s,f+1,o+1,l),S>R&&(f===a?S*=U:m.test(e.charAt(f-1))?(S*=H,A=e.slice(a,f-1).match(B$1),A&&a>0&&(S*=Math.pow(u,A.length))):K$1.test(e.charAt(f-1))?(S*=Y$1,rt=e.slice(a,f-1).match(X),rt&&a>0&&(S*=Math.pow(u,rt.length))):(S*=J,a>0&&(S*=Math.pow(u,f-a))),e.charAt(f)!==t.charAt(o)&&(S*=$)),(S<p&&n.charAt(f-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&n.charAt(f-1)!==s.charAt(o))&&(te=G(e,t,n,s,f+1,o+2,l),te*p>S&&(S=te*p)),S>R&&(R=S),f=n.indexOf(d,f+1);return l[c]=R,R}function D(e){return e.toLowerCase().replace(X," ")}function W(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,G(e,t,D(e),D(t),0,0,{})}var N='[cmdk-group=""]',Y='[cmdk-group-items=""]',be='[cmdk-group-heading=""]',le='[cmdk-item=""]',ce=`${le}:not([aria-disabled="true"])`,Z="cmdk-item-select",T="data-value",Re=(e,t,n)=>W(e,t,n),ue=React__namespace.createContext(void 0),K=()=>React__namespace.useContext(ue),de=React__namespace.createContext(void 0),ee=()=>React__namespace.useContext(de),fe=React__namespace.createContext(void 0),me=React__namespace.forwardRef((e,t)=>{let n=L(()=>{var Qt,sr;return{search:"",value:(sr=(Qt=e.value)!=null?Qt:e.defaultValue)!=null?sr:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=L(()=>new Set),a=L(()=>new Map),o=L(()=>new Map),l=L(()=>new Set),c=pe(e),{label:d,children:f,value:R,onValueChange:S,filter:te,shouldFilter:A,loop:rt,disablePointerSelection:st=!1,vimBindings:it=!0,...at}=e,ot=useId$1(),lt=useId$1(),ut=useId$1(),ct=React__namespace.useRef(null),dt=ke();k(()=>{if(R!==void 0){let Qt=R.trim();n.current.value=Qt,pt.emit()}},[R]),k(()=>{dt(6,Ct)},[]);let pt=React__namespace.useMemo(()=>({subscribe:Qt=>(l.current.add(Qt),()=>l.current.delete(Qt)),snapshot:()=>n.current,setState:(Qt,sr,lr)=>{var Zt,cr,qt,nr;if(!Object.is(n.current[Qt],sr)){if(n.current[Qt]=sr,Qt==="search")ft(),yt(),dt(1,It);else if(Qt==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Kt=document.getElementById(ut);Kt?Kt.focus():(Zt=document.getElementById(ot))==null||Zt.focus()}if(dt(7,()=>{var Kt;n.current.selectedItemId=(Kt=Mt())==null?void 0:Kt.id,pt.emit()}),lr||dt(5,Ct),((cr=c.current)==null?void 0:cr.value)!==void 0){let Kt=sr??"";(nr=(qt=c.current).onValueChange)==null||nr.call(qt,Kt);return}}pt.emit()}},emit:()=>{l.current.forEach(Qt=>Qt())}}),[]),mt=React__namespace.useMemo(()=>({value:(Qt,sr,lr)=>{var Zt;sr!==((Zt=o.current.get(Qt))==null?void 0:Zt.value)&&(o.current.set(Qt,{value:sr,keywords:lr}),n.current.filtered.items.set(Qt,Rt(sr,lr)),dt(2,()=>{yt(),pt.emit()}))},item:(Qt,sr)=>(s.current.add(Qt),sr&&(a.current.has(sr)?a.current.get(sr).add(Qt):a.current.set(sr,new Set([Qt]))),dt(3,()=>{ft(),yt(),n.current.value||It(),pt.emit()}),()=>{o.current.delete(Qt),s.current.delete(Qt),n.current.filtered.items.delete(Qt);let lr=Mt();dt(4,()=>{ft(),lr?.getAttribute("id")===Qt&&It(),pt.emit()})}),group:Qt=>(a.current.has(Qt)||a.current.set(Qt,new Set),()=>{o.current.delete(Qt),a.current.delete(Qt)}),filter:()=>c.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:ot,inputId:ut,labelId:lt,listInnerRef:ct}),[]);function Rt(Qt,sr){var lr,Zt;let cr=(Zt=(lr=c.current)==null?void 0:lr.filter)!=null?Zt:Re;return Qt?cr(Qt,n.current.search,sr):0}function yt(){if(!n.current.search||c.current.shouldFilter===!1)return;let Qt=n.current.filtered.items,sr=[];n.current.filtered.groups.forEach(Zt=>{let cr=a.current.get(Zt),qt=0;cr.forEach(nr=>{let Kt=Qt.get(nr);qt=Math.max(Kt,qt)}),sr.push([Zt,qt])});let lr=ct.current;Dt().sort((Zt,cr)=>{var qt,nr;let Kt=Zt.getAttribute("id"),Xt=cr.getAttribute("id");return((qt=Qt.get(Xt))!=null?qt:0)-((nr=Qt.get(Kt))!=null?nr:0)}).forEach(Zt=>{let cr=Zt.closest(Y);cr?cr.appendChild(Zt.parentElement===cr?Zt:Zt.closest(`${Y} > *`)):lr.appendChild(Zt.parentElement===lr?Zt:Zt.closest(`${Y} > *`))}),sr.sort((Zt,cr)=>cr[1]-Zt[1]).forEach(Zt=>{var cr;let qt=(cr=ct.current)==null?void 0:cr.querySelector(`${N}[${T}="${encodeURIComponent(Zt[0])}"]`);qt?.parentElement.appendChild(qt)})}function It(){let Qt=Dt().find(lr=>lr.getAttribute("aria-disabled")!=="true"),sr=Qt?.getAttribute(T);pt.setState("value",sr||void 0)}function ft(){var Qt,sr,lr,Zt;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=s.current.size;return}n.current.filtered.groups=new Set;let cr=0;for(let qt of s.current){let nr=(sr=(Qt=o.current.get(qt))==null?void 0:Qt.value)!=null?sr:"",Kt=(Zt=(lr=o.current.get(qt))==null?void 0:lr.keywords)!=null?Zt:[],Xt=Rt(nr,Kt);n.current.filtered.items.set(qt,Xt),Xt>0&&cr++}for(let[qt,nr]of a.current)for(let Kt of nr)if(n.current.filtered.items.get(Kt)>0){n.current.filtered.groups.add(qt);break}n.current.filtered.count=cr}function Ct(){var Qt,sr,lr;let Zt=Mt();Zt&&(((Qt=Zt.parentElement)==null?void 0:Qt.firstChild)===Zt&&((lr=(sr=Zt.closest(N))==null?void 0:sr.querySelector(be))==null||lr.scrollIntoView({block:"nearest"})),Zt.scrollIntoView({block:"nearest"}))}function Mt(){var Qt;return(Qt=ct.current)==null?void 0:Qt.querySelector(`${le}[aria-selected="true"]`)}function Dt(){var Qt;return Array.from(((Qt=ct.current)==null?void 0:Qt.querySelectorAll(ce))||[])}function Vt(Qt){let sr=Dt()[Qt];sr&&pt.setState("value",sr.getAttribute(T))}function Ht(Qt){var sr;let lr=Mt(),Zt=Dt(),cr=Zt.findIndex(nr=>nr===lr),qt=Zt[cr+Qt];(sr=c.current)!=null&&sr.loop&&(qt=cr+Qt<0?Zt[Zt.length-1]:cr+Qt===Zt.length?Zt[0]:Zt[cr+Qt]),qt&&pt.setState("value",qt.getAttribute(T))}function $t(Qt){let sr=Mt(),lr=sr?.closest(N),Zt;for(;lr&&!Zt;)lr=Qt>0?we(lr,N):De(lr,N),Zt=lr?.querySelector(ce);Zt?pt.setState("value",Zt.getAttribute(T)):Ht(Qt)}let Ft=()=>Vt(Dt().length-1),zt=Qt=>{Qt.preventDefault(),Qt.metaKey?Ft():Qt.altKey?$t(1):Ht(1)},Jt=Qt=>{Qt.preventDefault(),Qt.metaKey?Vt(0):Qt.altKey?$t(-1):Ht(-1)};return React__namespace.createElement(Primitive$4.div,{ref:t,tabIndex:-1,...at,"cmdk-root":"",onKeyDown:Qt=>{var sr;(sr=at.onKeyDown)==null||sr.call(at,Qt);let lr=Qt.nativeEvent.isComposing||Qt.keyCode===229;if(!(Qt.defaultPrevented||lr))switch(Qt.key){case"n":case"j":{it&&Qt.ctrlKey&&zt(Qt);break}case"ArrowDown":{zt(Qt);break}case"p":case"k":{it&&Qt.ctrlKey&&Jt(Qt);break}case"ArrowUp":{Jt(Qt);break}case"Home":{Qt.preventDefault(),Vt(0);break}case"End":{Qt.preventDefault(),Ft();break}case"Enter":{Qt.preventDefault();let Zt=Mt();if(Zt){let cr=new Event(Z);Zt.dispatchEvent(cr)}}}}},React__namespace.createElement("label",{"cmdk-label":"",htmlFor:mt.inputId,id:mt.labelId,style:Te},d),B(e,Qt=>React__namespace.createElement(de.Provider,{value:pt},React__namespace.createElement(ue.Provider,{value:mt},Qt))))}),he=React__namespace.forwardRef((e,t)=>{var n,s;let a=useId$1(),o=React__namespace.useRef(null),l=React__namespace.useContext(fe),c=K(),d=pe(e),f=(s=(n=d.current)==null?void 0:n.forceMount)!=null?s:l?.forceMount;k(()=>{if(!f)return c.item(a,l?.id)},[f]);let R=ve(a,o,[e.value,e.children,o],e.keywords),S=ee(),te=P(dt=>dt.value&&dt.value===R.current),A=P(dt=>f||c.filter()===!1?!0:dt.search?dt.filtered.items.get(a)>0:!0);React__namespace.useEffect(()=>{let dt=o.current;if(!(!dt||e.disabled))return dt.addEventListener(Z,rt),()=>dt.removeEventListener(Z,rt)},[A,e.onSelect,e.disabled]);function rt(){var dt,pt;st(),(pt=(dt=d.current).onSelect)==null||pt.call(dt,R.current)}function st(){S.setState("value",R.current,!0)}if(!A)return null;let{disabled:it,value:at,onSelect:ot,forceMount:lt,keywords:ut,...ct}=e;return React__namespace.createElement(Primitive$4.div,{ref:composeRefs(o,t),...ct,id:a,"cmdk-item":"",role:"option","aria-disabled":!!it,"aria-selected":!!te,"data-disabled":!!it,"data-selected":!!te,onPointerMove:it||c.getDisablePointerSelection()?void 0:st,onClick:it?void 0:rt},e.children)}),Ee=React__namespace.forwardRef((e,t)=>{let{heading:n,children:s,forceMount:a,...o}=e,l=useId$1(),c=React__namespace.useRef(null),d=React__namespace.useRef(null),f=useId$1(),R=K(),S=P(A=>a||R.filter()===!1?!0:A.search?A.filtered.groups.has(l):!0);k(()=>R.group(l),[]),ve(l,c,[e.value,e.heading,d]);let te=React__namespace.useMemo(()=>({id:l,forceMount:a}),[a]);return React__namespace.createElement(Primitive$4.div,{ref:composeRefs(c,t),...o,"cmdk-group":"",role:"presentation",hidden:S?void 0:!0},n&&React__namespace.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),B(e,A=>React__namespace.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},React__namespace.createElement(fe.Provider,{value:te},A))))}),ye=React__namespace.forwardRef((e,t)=>{let{alwaysRender:n,...s}=e,a=React__namespace.useRef(null),o=P(l=>!l.search);return!n&&!o?null:React__namespace.createElement(Primitive$4.div,{ref:composeRefs(a,t),...s,"cmdk-separator":"",role:"separator"})}),Se=React__namespace.forwardRef((e,t)=>{let{onValueChange:n,...s}=e,a=e.value!=null,o=ee(),l=P(f=>f.search),c=P(f=>f.selectedItemId),d=K();return React__namespace.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),React__namespace.createElement(Primitive$4.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":c,id:d.inputId,type:"text",value:a?e.value:l,onChange:f=>{a||o.setState("search",f.target.value),n?.(f.target.value)}})}),Ce=React__namespace.forwardRef((e,t)=>{let{children:n,label:s="Suggestions",...a}=e,o=React__namespace.useRef(null),l=React__namespace.useRef(null),c=P(f=>f.selectedItemId),d=K();return React__namespace.useEffect(()=>{if(l.current&&o.current){let f=l.current,R=o.current,S,te=new ResizeObserver(()=>{S=requestAnimationFrame(()=>{let A=f.offsetHeight;R.style.setProperty("--cmdk-list-height",A.toFixed(1)+"px")})});return te.observe(f),()=>{cancelAnimationFrame(S),te.unobserve(f)}}},[]),React__namespace.createElement(Primitive$4.div,{ref:composeRefs(o,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":s,id:d.listId},B(e,f=>React__namespace.createElement("div",{ref:composeRefs(l,d.listInnerRef),"cmdk-list-sizer":""},f)))}),xe=React__namespace.forwardRef((e,t)=>{let{open:n,onOpenChange:s,overlayClassName:a,contentClassName:o,container:l,...c}=e;return React__namespace.createElement(Root$a,{open:n,onOpenChange:s},React__namespace.createElement(Portal$4,{container:l},React__namespace.createElement(Overlay,{"cmdk-overlay":"",className:a}),React__namespace.createElement(Content$3,{"aria-label":e.label,"cmdk-dialog":"",className:o},React__namespace.createElement(me,{ref:t,...c}))))}),Ie=React__namespace.forwardRef((e,t)=>P(n=>n.filtered.count===0)?React__namespace.createElement(Primitive$4.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Pe=React__namespace.forwardRef((e,t)=>{let{progress:n,children:s,label:a="Loading...",...o}=e;return React__namespace.createElement(Primitive$4.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},B(e,l=>React__namespace.createElement("div",{"aria-hidden":!0},l)))}),_e=Object.assign(me,{List:Ce,Item:he,Input:Se,Group:Ee,Separator:ye,Dialog:xe,Empty:Ie,Loading:Pe});function we(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function De(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function pe(e){let t=React__namespace.useRef(e);return k(()=>{t.current=e}),t}var k=typeof window>"u"?React__namespace.useEffect:React__namespace.useLayoutEffect;function L(e){let t=React__namespace.useRef();return t.current===void 0&&(t.current=e()),t}function P(e){let t=ee(),n=()=>e(t.snapshot());return React__namespace.useSyncExternalStore(t.subscribe,n,n)}function ve(e,t,n,s=[]){let a=React__namespace.useRef(),o=K();return k(()=>{var l;let c=(()=>{var f;for(let R of n){if(typeof R=="string")return R.trim();if(typeof R=="object"&&"current"in R)return R.current?(f=R.current.textContent)==null?void 0:f.trim():a.current}})(),d=s.map(f=>f.trim());o.value(e,c,d),(l=t.current)==null||l.setAttribute(T,c),a.current=c}),a}var ke=()=>{let[e,t]=React__namespace.useState(),n=L(()=>new Map);return k(()=>{n.current.forEach(s=>s()),n.current=new Map},[e]),(s,a)=>{n.current.set(s,a),t({})}};function Me(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function B({asChild:e,children:t},n){return e&&React__namespace.isValidElement(t)?React__namespace.cloneElement(Me(t),{ref:t.ref},n(t.props.children)):n(t)}var Te={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Command=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e,{ref:n,className:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Command.displayName=_e.displayName;const CommandDialog=({children:e,...t})=>jsxRuntime.jsx(Dialog,{...t,children:jsxRuntime.jsx(DialogContent,{className:"overflow-hidden p-0",children:jsxRuntime.jsx(Command,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})})}),CommandInput=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[jsxRuntime.jsx(Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),jsxRuntime.jsx(_e.Input,{ref:n,className:cn("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));CommandInput.displayName=_e.Input.displayName;const CommandList=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.List,{ref:n,className:cn("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));CommandList.displayName=_e.List.displayName;const CommandEmpty=React__namespace.forwardRef((e,t)=>jsxRuntime.jsx(_e.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));CommandEmpty.displayName=_e.Empty.displayName;const CommandGroup=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Group,{ref:n,className:cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));CommandGroup.displayName=_e.Group.displayName;const CommandSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Separator,{ref:n,className:cn("-mx-1 h-px bg-border",e),...t}));CommandSeparator.displayName=_e.Separator.displayName;const CommandItem=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Item,{ref:n,className:cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));CommandItem.displayName=_e.Item.displayName;const CommandShortcut=({className:e,...t})=>jsxRuntime.jsx("span",{className:cn("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});CommandShortcut.displayName="CommandShortcut";const CountryFlag=({countryCode:e,className:t=""})=>{const[n,s]=React.useState(!1),a=e.trim().toUpperCase();React.useEffect(()=>{s(!1)},[a]);const o=React.useMemo(()=>a?`https://purecatamphetamine.github.io/country-flag-icons/3x2/${encodeURIComponent(a)}.svg`:"",[a]);return!a||n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:o,alt:`${a} flag`,className:`inline-block h-auto w-6 ${t}`,loading:"lazy",onError:()=>s(!0)})};function GeneralDocumentCard({document:e,loading:t=!1}){return t?jsxRuntime.jsx("div",{children:"loading..."}):jsxRuntime.jsxs("div",{children:["GENERAL DOCUMENT CARD - ",e?.OrderNumber," for P.O. ",e?.PONumber]})}function ApiImage({path:e,origin:t,...n}){const s=useApiOrigin(),a=React__namespace.useMemo(()=>buildApiUrl(e,t??s),[s,t,e]);return jsxRuntime.jsx("img",{...n,src:a})}var md5={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$1=getAugmentedNamespace(__viteBrowserExternal$1);var hasRequiredMd5;function requireMd5(){return hasRequiredMd5||(hasRequiredMd5=1,(function(e){(function(){var t="input is invalid type",n="finalize already called",s=typeof window=="object",a=s?window:{};a.JS_MD5_NO_WINDOW&&(s=!1);var o=!s&&typeof self=="object",l=!a.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;l?a=commonjsGlobal:o&&(a=self);var c=!a.JS_MD5_NO_COMMON_JS&&!0&&e.exports,d=!a.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),R=[128,32768,8388608,-2147483648],S=[0,8,16,24],te=["hex","array","digest","buffer","arrayBuffer","base64"],A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),rt=[],st;if(d){var it=new ArrayBuffer(68);st=new Uint8Array(it),rt=new Uint32Array(it)}var at=Array.isArray;(a.JS_MD5_NO_NODE_JS||!at)&&(at=function(ft){return Object.prototype.toString.call(ft)==="[object Array]"});var ot=ArrayBuffer.isView;d&&(a.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW||!ot)&&(ot=function(ft){return typeof ft=="object"&&ft.buffer&&ft.buffer.constructor===ArrayBuffer});var lt=function(ft){var Ct=typeof ft;if(Ct==="string")return[ft,!0];if(Ct!=="object"||ft===null)throw new Error(t);if(d&&ft.constructor===ArrayBuffer)return[new Uint8Array(ft),!1];if(!at(ft)&&!ot(ft))throw new Error(t);return[ft,!1]},ut=function(ft){return function(Ct){return new Rt(!0).update(Ct)[ft]()}},ct=function(){var ft=ut("hex");l&&(ft=dt(ft)),ft.create=function(){return new Rt},ft.update=function(Dt){return ft.create().update(Dt)};for(var Ct=0;Ct<te.length;++Ct){var Mt=te[Ct];ft[Mt]=ut(Mt)}return ft},dt=function(ft){var Ct=require$$1,Mt=require$$1.Buffer,Dt;Mt.from&&!a.JS_MD5_NO_BUFFER_FROM?Dt=Mt.from:Dt=function(Ht){return new Mt(Ht)};var Vt=function(Ht){if(typeof Ht=="string")return Ct.createHash("md5").update(Ht,"utf8").digest("hex");if(Ht==null)throw new Error(t);return Ht.constructor===ArrayBuffer&&(Ht=new Uint8Array(Ht)),at(Ht)||ot(Ht)||Ht.constructor===Mt?Ct.createHash("md5").update(Dt(Ht)).digest("hex"):ft(Ht)};return Vt},pt=function(ft){return function(Ct,Mt){return new yt(Ct,!0).update(Mt)[ft]()}},mt=function(){var ft=pt("hex");ft.create=function(Dt){return new yt(Dt)},ft.update=function(Dt,Vt){return ft.create(Dt).update(Vt)};for(var Ct=0;Ct<te.length;++Ct){var Mt=te[Ct];ft[Mt]=pt(Mt)}return ft};function Rt(ft){if(ft)rt[0]=rt[16]=rt[1]=rt[2]=rt[3]=rt[4]=rt[5]=rt[6]=rt[7]=rt[8]=rt[9]=rt[10]=rt[11]=rt[12]=rt[13]=rt[14]=rt[15]=0,this.blocks=rt,this.buffer8=st;else if(d){var Ct=new ArrayBuffer(68);this.buffer8=new Uint8Array(Ct),this.blocks=new Uint32Array(Ct)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}Rt.prototype.update=function(ft){if(this.finalized)throw new Error(n);var Ct=lt(ft);ft=Ct[0];for(var Mt=Ct[1],Dt,Vt=0,Ht,$t=ft.length,Ft=this.blocks,zt=this.buffer8;Vt<$t;){if(this.hashed&&(this.hashed=!1,Ft[0]=Ft[16],Ft[16]=Ft[1]=Ft[2]=Ft[3]=Ft[4]=Ft[5]=Ft[6]=Ft[7]=Ft[8]=Ft[9]=Ft[10]=Ft[11]=Ft[12]=Ft[13]=Ft[14]=Ft[15]=0),Mt)if(d)for(Ht=this.start;Vt<$t&&Ht<64;++Vt)Dt=ft.charCodeAt(Vt),Dt<128?zt[Ht++]=Dt:Dt<2048?(zt[Ht++]=192|Dt>>>6,zt[Ht++]=128|Dt&63):Dt<55296||Dt>=57344?(zt[Ht++]=224|Dt>>>12,zt[Ht++]=128|Dt>>>6&63,zt[Ht++]=128|Dt&63):(Dt=65536+((Dt&1023)<<10|ft.charCodeAt(++Vt)&1023),zt[Ht++]=240|Dt>>>18,zt[Ht++]=128|Dt>>>12&63,zt[Ht++]=128|Dt>>>6&63,zt[Ht++]=128|Dt&63);else for(Ht=this.start;Vt<$t&&Ht<64;++Vt)Dt=ft.charCodeAt(Vt),Dt<128?Ft[Ht>>>2]|=Dt<<S[Ht++&3]:Dt<2048?(Ft[Ht>>>2]|=(192|Dt>>>6)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt&63)<<S[Ht++&3]):Dt<55296||Dt>=57344?(Ft[Ht>>>2]|=(224|Dt>>>12)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt>>>6&63)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt&63)<<S[Ht++&3]):(Dt=65536+((Dt&1023)<<10|ft.charCodeAt(++Vt)&1023),Ft[Ht>>>2]|=(240|Dt>>>18)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt>>>12&63)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt>>>6&63)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt&63)<<S[Ht++&3]);else if(d)for(Ht=this.start;Vt<$t&&Ht<64;++Vt)zt[Ht++]=ft[Vt];else for(Ht=this.start;Vt<$t&&Ht<64;++Vt)Ft[Ht>>>2]|=ft[Vt]<<S[Ht++&3];this.lastByteIndex=Ht,this.bytes+=Ht-this.start,Ht>=64?(this.start=Ht-64,this.hash(),this.hashed=!0):this.start=Ht}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},Rt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var ft=this.blocks,Ct=this.lastByteIndex;ft[Ct>>>2]|=R[Ct&3],Ct>=56&&(this.hashed||this.hash(),ft[0]=ft[16],ft[16]=ft[1]=ft[2]=ft[3]=ft[4]=ft[5]=ft[6]=ft[7]=ft[8]=ft[9]=ft[10]=ft[11]=ft[12]=ft[13]=ft[14]=ft[15]=0),ft[14]=this.bytes<<3,ft[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},Rt.prototype.hash=function(){var ft,Ct,Mt,Dt,Vt,Ht,$t=this.blocks;this.first?(ft=$t[0]-680876937,ft=(ft<<7|ft>>>25)-271733879<<0,Dt=(-1732584194^ft&2004318071)+$t[1]-117830708,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt=(-271733879^Dt&(ft^-271733879))+$t[2]-1126478375,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct=(ft^Mt&(Dt^ft))+$t[3]-1316259209,Ct=(Ct<<22|Ct>>>10)+Mt<<0):(ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3,ft+=(Dt^Ct&(Mt^Dt))+$t[0]-680876936,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[1]-389564586,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[2]+606105819,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[3]-1044525330,Ct=(Ct<<22|Ct>>>10)+Mt<<0),ft+=(Dt^Ct&(Mt^Dt))+$t[4]-176418897,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[5]+1200080426,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[6]-1473231341,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[7]-45705983,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Dt^Ct&(Mt^Dt))+$t[8]+1770035416,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[9]-1958414417,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[10]-42063,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[11]-1990404162,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Dt^Ct&(Mt^Dt))+$t[12]+1804603682,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[13]-40341101,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[14]-1502002290,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[15]+1236535329,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[1]-165796510,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[6]-1069501632,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[11]+643717713,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[0]-373897302,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[5]-701558691,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[10]+38016083,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[15]-660478335,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[4]-405537848,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[9]+568446438,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[14]-1019803690,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[3]-187363961,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[8]+1163531501,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[13]-1444681467,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[2]-51403784,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[7]+1735328473,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[12]-1926607734,Ct=(Ct<<20|Ct>>>12)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[5]-378558,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[8]-2022574463,Dt=(Dt<<11|Dt>>>21)+ft<<0,Ht=Dt^ft,Mt+=(Ht^Ct)+$t[11]+1839030562,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Ht^Mt)+$t[14]-35309556,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[1]-1530992060,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[4]+1272893353,Dt=(Dt<<11|Dt>>>21)+ft<<0,Ht=Dt^ft,Mt+=(Ht^Ct)+$t[7]-155497632,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Ht^Mt)+$t[10]-1094730640,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[13]+681279174,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[0]-358537222,Dt=(Dt<<11|Dt>>>21)+ft<<0,Ht=Dt^ft,Mt+=(Ht^Ct)+$t[3]-722521979,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Ht^Mt)+$t[6]+76029189,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[9]-640364487,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[12]-421815835,Dt=(Dt<<11|Dt>>>21)+ft<<0,Ht=Dt^ft,Mt+=(Ht^Ct)+$t[15]+530742520,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Ht^Mt)+$t[2]-995338651,Ct=(Ct<<23|Ct>>>9)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[0]-198630844,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[7]+1126891415,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[14]-1416354905,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[5]-57434055,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[12]+1700485571,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[3]-1894986606,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[10]-1051523,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[1]-2054922799,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[8]+1873313359,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[15]-30611744,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[6]-1560198380,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[13]+1309151649,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[4]-145523070,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[11]-1120210379,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[2]+718787259,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[9]-343485551,Ct=(Ct<<21|Ct>>>11)+Mt<<0,this.first?(this.h0=ft+1732584193<<0,this.h1=Ct-271733879<<0,this.h2=Mt-1732584194<<0,this.h3=Dt+271733878<<0,this.first=!1):(this.h0=this.h0+ft<<0,this.h1=this.h1+Ct<<0,this.h2=this.h2+Mt<<0,this.h3=this.h3+Dt<<0)},Rt.prototype.hex=function(){this.finalize();var ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3;return f[ft>>>4&15]+f[ft&15]+f[ft>>>12&15]+f[ft>>>8&15]+f[ft>>>20&15]+f[ft>>>16&15]+f[ft>>>28&15]+f[ft>>>24&15]+f[Ct>>>4&15]+f[Ct&15]+f[Ct>>>12&15]+f[Ct>>>8&15]+f[Ct>>>20&15]+f[Ct>>>16&15]+f[Ct>>>28&15]+f[Ct>>>24&15]+f[Mt>>>4&15]+f[Mt&15]+f[Mt>>>12&15]+f[Mt>>>8&15]+f[Mt>>>20&15]+f[Mt>>>16&15]+f[Mt>>>28&15]+f[Mt>>>24&15]+f[Dt>>>4&15]+f[Dt&15]+f[Dt>>>12&15]+f[Dt>>>8&15]+f[Dt>>>20&15]+f[Dt>>>16&15]+f[Dt>>>28&15]+f[Dt>>>24&15]},Rt.prototype.toString=Rt.prototype.hex,Rt.prototype.digest=function(){this.finalize();var ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3;return[ft&255,ft>>>8&255,ft>>>16&255,ft>>>24&255,Ct&255,Ct>>>8&255,Ct>>>16&255,Ct>>>24&255,Mt&255,Mt>>>8&255,Mt>>>16&255,Mt>>>24&255,Dt&255,Dt>>>8&255,Dt>>>16&255,Dt>>>24&255]},Rt.prototype.array=Rt.prototype.digest,Rt.prototype.arrayBuffer=function(){this.finalize();var ft=new ArrayBuffer(16),Ct=new Uint32Array(ft);return Ct[0]=this.h0,Ct[1]=this.h1,Ct[2]=this.h2,Ct[3]=this.h3,ft},Rt.prototype.buffer=Rt.prototype.arrayBuffer,Rt.prototype.base64=function(){for(var ft,Ct,Mt,Dt="",Vt=this.array(),Ht=0;Ht<15;)ft=Vt[Ht++],Ct=Vt[Ht++],Mt=Vt[Ht++],Dt+=A[ft>>>2]+A[(ft<<4|Ct>>>4)&63]+A[(Ct<<2|Mt>>>6)&63]+A[Mt&63];return ft=Vt[Ht],Dt+=A[ft>>>2]+A[ft<<4&63]+"==",Dt};function yt(ft,Ct){var Mt,Dt=lt(ft);if(ft=Dt[0],Dt[1]){var Vt=[],Ht=ft.length,$t=0,Ft;for(Mt=0;Mt<Ht;++Mt)Ft=ft.charCodeAt(Mt),Ft<128?Vt[$t++]=Ft:Ft<2048?(Vt[$t++]=192|Ft>>>6,Vt[$t++]=128|Ft&63):Ft<55296||Ft>=57344?(Vt[$t++]=224|Ft>>>12,Vt[$t++]=128|Ft>>>6&63,Vt[$t++]=128|Ft&63):(Ft=65536+((Ft&1023)<<10|ft.charCodeAt(++Mt)&1023),Vt[$t++]=240|Ft>>>18,Vt[$t++]=128|Ft>>>12&63,Vt[$t++]=128|Ft>>>6&63,Vt[$t++]=128|Ft&63);ft=Vt}ft.length>64&&(ft=new Rt(!0).update(ft).array());var zt=[],Jt=[];for(Mt=0;Mt<64;++Mt){var Qt=ft[Mt]||0;zt[Mt]=92^Qt,Jt[Mt]=54^Qt}Rt.call(this,Ct),this.update(Jt),this.oKeyPad=zt,this.inner=!0,this.sharedMemory=Ct}yt.prototype=new Rt,yt.prototype.finalize=function(){if(Rt.prototype.finalize.call(this),this.inner){this.inner=!1;var ft=this.array();Rt.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(ft),Rt.prototype.finalize.call(this)}};var It=ct();It.md5=It,It.md5.hmac=mt(),c?e.exports=It:a.md5=It})()})(md5)),md5.exports}var md5Exports=requireMd5(),Type=(e=>(e.STRING="string",e.NUMBER="number",e.BOOLEAN="boolean",e.OBJECT="object",e))(Type||{});const bodyKey="TheRequestBody",defaultSchemaDescription="Request body content";function getHash(e){return md5Exports.md5(e).substring(0,16)}function deduplicateApiFunctions(e){const t=new Map;return e.map(n=>{const s=n.declaration.name,a=t.get(s)||0;let o=s;return a>0&&(o=`${s}_${a}`),t.set(s,a+1),{...n,declaration:{...n.declaration,name:o}}})}function isSchemaReference(e){return!!e&&"$ref"in e}function isSchemaObject(e){return!!e&&!("$ref"in e)}function getRequestBodySchema(e){if(!e?.content)return;const t=["application/json","application/json-patch+json","multipart/form-data","text/plain"];for(const s of t){const a=e.content[s]?.schema;if(a)return a}return Object.values(e.content).find(s=>s?.schema)?.schema}async function fetchApiFunctions(e){const t=e?.swaggerJsonUrl??DEFAULT_SWAGGER_JSON_URL,n=resolveApiOrigin(t)??resolveApiOrigin(DEFAULT_SWAGGER_JSON_URL),s=buildApiUrl(t,n);try{const a=await fetch(s);if(!a.ok)throw new Error("Failed to fetch Swagger spec");const o=await a.json(),l=[];for(const[c,d]of Object.entries(o.paths)){const f=["get","post","put","delete"];for(const R of f){const S=d[R];if(!S||S["x-allowed-for-chatbots"]!==!0)continue;const te=c.split("/").filter(Boolean);let A;te.length>0&&te[0].toLowerCase()==="v4"?A=te.length>1?te[1]:"api":A=te.length>0?te[0]:"api",A=A.replace(/[{}]/g,"");const rt=getHash(c),st=`${R}-${A.toLowerCase()}-${rt}`,it={},at=[];S.parameters?.forEach(Rt=>{const yt=Rt.schema?.type,It=yt==="integer"||yt==="number"?"number":yt==="boolean"?"boolean":"string";it[Rt.name]={type:It,description:Rt.description||`The ${Rt.name} parameter`},Rt.required&&at.push(Rt.name)});const ot=S.parameters?.filter(Rt=>Rt.in==="path").map(Rt=>Rt.name)||[];if((R==="post"||R==="put")&&S.requestBody){const Rt=getRequestBodySchema(S.requestBody),yt=S.requestBody.description||defaultSchemaDescription;if(Rt&&isSchemaReference(Rt)&&Rt.$ref.startsWith("#/components/schemas/")){const It=Rt.$ref.substring(21),ft=o.components.schemas[It],Ct=isSchemaObject(ft)?ft.properties:void 0,Mt=Ct?JSON.stringify(Ct):"Refer to API schema for details.";it[bodyKey]={type:"string",description:`${yt}. Must be a JSON string with these properties: ${Mt}`}}else it[bodyKey]={type:"string",description:yt};at.push(bodyKey)}const lt={name:st,description:S.description?`${S.summary}
|
|
490
|
+
color: hsl(${Math.max(0,Math.min(120-120*te,120))}deg 100% 31%);`,n?.key)}return a}}function getMemoOptions(e,t,n,s){return{debug:()=>{var a;return(a=e?.debugAll)!=null?a:e[t]},key:process.env.NODE_ENV==="development"&&n,onChange:s}}function createCell(e,t,n,s){const a=()=>{var l;return(l=o.getValue())!=null?l:e.options.renderFallbackValue},o={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(s),renderValue:a,getContext:memo(()=>[e,n,t,o],(l,c,d,f)=>({table:l,column:c,row:d,cell:f,getValue:f.getValue,renderValue:f.renderValue}),getMemoOptions(e.options,"debugCells","cell.getContext"))};return e._features.forEach(l=>{l.createCell==null||l.createCell(o,n,t,e)},{}),o}function createColumn(e,t,n,s){var a,o;const c={...e._getDefaultColumnDef(),...t},d=c.accessorKey;let f=(a=(o=c.id)!=null?o:d?typeof String.prototype.replaceAll=="function"?d.replaceAll(".","_"):d.replace(/\./g,"_"):void 0)!=null?a:typeof c.header=="string"?c.header:void 0,R;if(c.accessorFn?R=c.accessorFn:d&&(d.includes(".")?R=te=>{let A=te;for(const st of d.split(".")){var rt;A=(rt=A)==null?void 0:rt[st],process.env.NODE_ENV!=="production"&&A===void 0&&console.warn(`"${st}" in deeply nested key "${d}" returned undefined.`)}return A}:R=te=>te[c.accessorKey]),!f)throw process.env.NODE_ENV!=="production"?new Error(c.accessorFn?"Columns require an id when using an accessorFn":"Columns require an id when using a non-string header"):new Error;let S={id:`${String(f)}`,accessorFn:R,parent:s,depth:n,columnDef:c,columns:[],getFlatColumns:memo(()=>[!0],()=>{var te;return[S,...(te=S.columns)==null?void 0:te.flatMap(A=>A.getFlatColumns())]},getMemoOptions(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:memo(()=>[e._getOrderColumnsFn()],te=>{var A;if((A=S.columns)!=null&&A.length){let rt=S.columns.flatMap(st=>st.getLeafColumns());return te(rt)}return[S]},getMemoOptions(e.options,"debugColumns","column.getLeafColumns"))};for(const te of e._features)te.createColumn==null||te.createColumn(S,e);return S}const debug="debugHeaders";function createHeader(e,t,n){var s;let o={id:(s=n.id)!=null?s:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const l=[],c=d=>{d.subHeaders&&d.subHeaders.length&&d.subHeaders.map(c),l.push(d)};return c(o),l},getContext:()=>({table:e,header:o,column:t})};return e._features.forEach(l=>{l.createHeader==null||l.createHeader(o,e)}),o}const Headers$1={createTable:e=>{e.getHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s,a)=>{var o,l;const c=(o=s?.map(S=>n.find(te=>te.id===S)).filter(Boolean))!=null?o:[],d=(l=a?.map(S=>n.find(te=>te.id===S)).filter(Boolean))!=null?l:[],f=n.filter(S=>!(s!=null&&s.includes(S.id))&&!(a!=null&&a.includes(S.id)));return buildHeaderGroups(t,[...c,...f,...d],e)},getMemoOptions(e.options,debug,"getHeaderGroups")),e.getCenterHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s,a)=>(n=n.filter(o=>!(s!=null&&s.includes(o.id))&&!(a!=null&&a.includes(o.id))),buildHeaderGroups(t,n,e,"center")),getMemoOptions(e.options,debug,"getCenterHeaderGroups")),e.getLeftHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,s)=>{var a;const o=(a=s?.map(l=>n.find(c=>c.id===l)).filter(Boolean))!=null?a:[];return buildHeaderGroups(t,o,e,"left")},getMemoOptions(e.options,debug,"getLeftHeaderGroups")),e.getRightHeaderGroups=memo(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,s)=>{var a;const o=(a=s?.map(l=>n.find(c=>c.id===l)).filter(Boolean))!=null?a:[];return buildHeaderGroups(t,o,e,"right")},getMemoOptions(e.options,debug,"getRightHeaderGroups")),e.getFooterGroups=memo(()=>[e.getHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getFooterGroups")),e.getLeftFooterGroups=memo(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getLeftFooterGroups")),e.getCenterFooterGroups=memo(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getCenterFooterGroups")),e.getRightFooterGroups=memo(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),getMemoOptions(e.options,debug,"getRightFooterGroups")),e.getFlatHeaders=memo(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getFlatHeaders")),e.getLeftFlatHeaders=memo(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getLeftFlatHeaders")),e.getCenterFlatHeaders=memo(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getCenterFlatHeaders")),e.getRightFlatHeaders=memo(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),getMemoOptions(e.options,debug,"getRightFlatHeaders")),e.getCenterLeafHeaders=memo(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getCenterLeafHeaders")),e.getLeftLeafHeaders=memo(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getLeftLeafHeaders")),e.getRightLeafHeaders=memo(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var s;return!((s=n.subHeaders)!=null&&s.length)}),getMemoOptions(e.options,debug,"getRightLeafHeaders")),e.getLeafHeaders=memo(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,s)=>{var a,o,l,c,d,f;return[...(a=(o=t[0])==null?void 0:o.headers)!=null?a:[],...(l=(c=n[0])==null?void 0:c.headers)!=null?l:[],...(d=(f=s[0])==null?void 0:f.headers)!=null?d:[]].map(R=>R.getLeafHeaders()).flat()},getMemoOptions(e.options,debug,"getLeafHeaders"))}};function buildHeaderGroups(e,t,n,s){var a,o;let l=0;const c=function(te,A){A===void 0&&(A=1),l=Math.max(l,A),te.filter(rt=>rt.getIsVisible()).forEach(rt=>{var st;(st=rt.columns)!=null&&st.length&&c(rt.columns,A+1)},0)};c(e);let d=[];const f=(te,A)=>{const rt={depth:A,id:[s,`${A}`].filter(Boolean).join("_"),headers:[]},st=[];te.forEach(it=>{const at=[...st].reverse()[0],ot=it.column.depth===rt.depth;let lt,ut=!1;if(ot&&it.column.parent?lt=it.column.parent:(lt=it.column,ut=!0),at&&at?.column===lt)at.subHeaders.push(it);else{const ct=createHeader(n,lt,{id:[s,A,lt.id,it?.id].filter(Boolean).join("_"),isPlaceholder:ut,placeholderId:ut?`${st.filter(dt=>dt.column===lt).length}`:void 0,depth:A,index:st.length});ct.subHeaders.push(it),st.push(ct)}rt.headers.push(it),it.headerGroup=rt}),d.push(rt),A>0&&f(st,A-1)},R=t.map((te,A)=>createHeader(n,te,{depth:l,index:A}));f(R,l-1),d.reverse();const S=te=>te.filter(rt=>rt.column.getIsVisible()).map(rt=>{let st=0,it=0,at=[0];rt.subHeaders&&rt.subHeaders.length?(at=[],S(rt.subHeaders).forEach(lt=>{let{colSpan:ut,rowSpan:ct}=lt;st+=ut,at.push(ct)})):st=1;const ot=Math.min(...at);return it=it+ot,rt.colSpan=st,rt.rowSpan=it,{colSpan:st,rowSpan:it}});return S((a=(o=d[0])==null?void 0:o.headers)!=null?a:[]),d}const createRow=(e,t,n,s,a,o,l)=>{let c={id:t,index:s,original:n,depth:a,parentId:l,_valuesCache:{},_uniqueValuesCache:{},getValue:d=>{if(c._valuesCache.hasOwnProperty(d))return c._valuesCache[d];const f=e.getColumn(d);if(f!=null&&f.accessorFn)return c._valuesCache[d]=f.accessorFn(c.original,s),c._valuesCache[d]},getUniqueValues:d=>{if(c._uniqueValuesCache.hasOwnProperty(d))return c._uniqueValuesCache[d];const f=e.getColumn(d);if(f!=null&&f.accessorFn)return f.columnDef.getUniqueValues?(c._uniqueValuesCache[d]=f.columnDef.getUniqueValues(c.original,s),c._uniqueValuesCache[d]):(c._uniqueValuesCache[d]=[c.getValue(d)],c._uniqueValuesCache[d])},renderValue:d=>{var f;return(f=c.getValue(d))!=null?f:e.options.renderFallbackValue},subRows:[],getLeafRows:()=>flattenBy(c.subRows,d=>d.subRows),getParentRow:()=>c.parentId?e.getRow(c.parentId,!0):void 0,getParentRows:()=>{let d=[],f=c;for(;;){const R=f.getParentRow();if(!R)break;d.push(R),f=R}return d.reverse()},getAllCells:memo(()=>[e.getAllLeafColumns()],d=>d.map(f=>createCell(e,c,f,f.id)),getMemoOptions(e.options,"debugRows","getAllCells")),_getAllCellsByColumnId:memo(()=>[c.getAllCells()],d=>d.reduce((f,R)=>(f[R.column.id]=R,f),{}),getMemoOptions(e.options,"debugRows","getAllCellsByColumnId"))};for(let d=0;d<e._features.length;d++){const f=e._features[d];f==null||f.createRow==null||f.createRow(c,e)}return c},ColumnFaceting={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},includesString=(e,t,n)=>{var s,a;const o=n==null||(s=n.toString())==null?void 0:s.toLowerCase();return!!(!((a=e.getValue(t))==null||(a=a.toString())==null||(a=a.toLowerCase())==null)&&a.includes(o))};includesString.autoRemove=e=>testFalsey(e);const includesStringSensitive=(e,t,n)=>{var s;return!!(!((s=e.getValue(t))==null||(s=s.toString())==null)&&s.includes(n))};includesStringSensitive.autoRemove=e=>testFalsey(e);const equalsString=(e,t,n)=>{var s;return((s=e.getValue(t))==null||(s=s.toString())==null?void 0:s.toLowerCase())===n?.toLowerCase()};equalsString.autoRemove=e=>testFalsey(e);const arrIncludes=(e,t,n)=>{var s;return(s=e.getValue(t))==null?void 0:s.includes(n)};arrIncludes.autoRemove=e=>testFalsey(e);const arrIncludesAll=(e,t,n)=>!n.some(s=>{var a;return!((a=e.getValue(t))!=null&&a.includes(s))});arrIncludesAll.autoRemove=e=>testFalsey(e)||!(e!=null&&e.length);const arrIncludesSome=(e,t,n)=>n.some(s=>{var a;return(a=e.getValue(t))==null?void 0:a.includes(s)});arrIncludesSome.autoRemove=e=>testFalsey(e)||!(e!=null&&e.length);const equals=(e,t,n)=>e.getValue(t)===n;equals.autoRemove=e=>testFalsey(e);const weakEquals=(e,t,n)=>e.getValue(t)==n;weakEquals.autoRemove=e=>testFalsey(e);const inNumberRange=(e,t,n)=>{let[s,a]=n;const o=e.getValue(t);return o>=s&&o<=a};inNumberRange.resolveFilterValue=e=>{let[t,n]=e,s=typeof t!="number"?parseFloat(t):t,a=typeof n!="number"?parseFloat(n):n,o=t===null||Number.isNaN(s)?-1/0:s,l=n===null||Number.isNaN(a)?1/0:a;if(o>l){const c=o;o=l,l=c}return[o,l]},inNumberRange.autoRemove=e=>testFalsey(e)||testFalsey(e[0])&&testFalsey(e[1]);const filterFns={includesString,includesStringSensitive,equalsString,arrIncludes,arrIncludesAll,arrIncludesSome,equals,weakEquals,inNumberRange};function testFalsey(e){return e==null||e===""}const ColumnFiltering={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:makeStateUpdater("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{const n=t.getCoreRowModel().flatRows[0],s=n?.getValue(e.id);return typeof s=="string"?filterFns.includesString:typeof s=="number"?filterFns.inNumberRange:typeof s=="boolean"||s!==null&&typeof s=="object"?filterFns.equals:Array.isArray(s)?filterFns.arrIncludes:filterFns.weakEquals},e.getFilterFn=()=>{var n,s;return isFunction$2(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(n=(s=t.options.filterFns)==null?void 0:s[e.columnDef.filterFn])!=null?n:filterFns[e.columnDef.filterFn]},e.getCanFilter=()=>{var n,s,a;return((n=e.columnDef.enableColumnFilter)!=null?n:!0)&&((s=t.options.enableColumnFilters)!=null?s:!0)&&((a=t.options.enableFilters)!=null?a:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(s=>s.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>{var n,s;return(n=(s=t.getState().columnFilters)==null?void 0:s.findIndex(a=>a.id===e.id))!=null?n:-1},e.setFilterValue=n=>{t.setColumnFilters(s=>{const a=e.getFilterFn(),o=s?.find(R=>R.id===e.id),l=functionalUpdate(n,o?o.value:void 0);if(shouldAutoRemoveFilter(a,l,e)){var c;return(c=s?.filter(R=>R.id!==e.id))!=null?c:[]}const d={id:e.id,value:l};if(o){var f;return(f=s?.map(R=>R.id===e.id?d:R))!=null?f:[]}return s!=null&&s.length?[...s,d]:[d]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{const n=e.getAllLeafColumns(),s=a=>{var o;return(o=functionalUpdate(t,a))==null?void 0:o.filter(l=>{const c=n.find(d=>d.id===l.id);if(c){const d=c.getFilterFn();if(shouldAutoRemoveFilter(d,l.value,c))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(s)},e.resetColumnFilters=t=>{var n,s;e.setColumnFilters(t?[]:(n=(s=e.initialState)==null?void 0:s.columnFilters)!=null?n:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function shouldAutoRemoveFilter(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}const sum=(e,t,n)=>n.reduce((s,a)=>{const o=a.getValue(e);return s+(typeof o=="number"?o:0)},0),min=(e,t,n)=>{let s;return n.forEach(a=>{const o=a.getValue(e);o!=null&&(s>o||s===void 0&&o>=o)&&(s=o)}),s},max=(e,t,n)=>{let s;return n.forEach(a=>{const o=a.getValue(e);o!=null&&(s<o||s===void 0&&o>=o)&&(s=o)}),s},extent=(e,t,n)=>{let s,a;return n.forEach(o=>{const l=o.getValue(e);l!=null&&(s===void 0?l>=l&&(s=a=l):(s>l&&(s=l),a<l&&(a=l)))}),[s,a]},mean=(e,t)=>{let n=0,s=0;if(t.forEach(a=>{let o=a.getValue(e);o!=null&&(o=+o)>=o&&(++n,s+=o)}),n)return s/n},median=(e,t)=>{if(!t.length)return;const n=t.map(o=>o.getValue(e));if(!isNumberArray(n))return;if(n.length===1)return n[0];const s=Math.floor(n.length/2),a=n.sort((o,l)=>o-l);return n.length%2!==0?a[s]:(a[s-1]+a[s])/2},unique=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),uniqueCount=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,count=(e,t)=>t.length,aggregationFns={sum,min,max,extent,mean,median,unique,uniqueCount,count},ColumnGrouping={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return(t=(n=e.getValue())==null||n.toString==null?void 0:n.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:makeStateUpdater("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(n=>n!=null&&n.includes(e.id)?n.filter(s=>s!==e.id):[...n??[],e.id])},e.getCanGroup=()=>{var n,s;return((n=e.columnDef.enableGrouping)!=null?n:!0)&&((s=t.options.enableGrouping)!=null?s:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.includes(e.id)},e.getGroupedIndex=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const n=e.getCanGroup();return()=>{n&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const n=t.getCoreRowModel().flatRows[0],s=n?.getValue(e.id);if(typeof s=="number")return aggregationFns.sum;if(Object.prototype.toString.call(s)==="[object Date]")return aggregationFns.extent},e.getAggregationFn=()=>{var n,s;if(!e)throw new Error;return isFunction$2(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(n=(s=t.options.aggregationFns)==null?void 0:s[e.columnDef.aggregationFn])!=null?n:aggregationFns[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var n,s;e.setGrouping(t?[]:(n=(s=e.initialState)==null?void 0:s.grouping)!=null?n:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];const s=t.getColumn(n);return s!=null&&s.columnDef.getGroupingValue?(e._groupingValuesCache[n]=s.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,s)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var a;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((a=n.subRows)!=null&&a.length)}}};function orderColumns(e,t,n){if(!(t!=null&&t.length)||!n)return e;const s=e.filter(o=>!t.includes(o.id));return n==="remove"?s:[...t.map(o=>e.find(l=>l.id===o)).filter(Boolean),...s]}const ColumnOrdering={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:makeStateUpdater("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=memo(n=>[_getVisibleLeafColumns(t,n)],n=>n.findIndex(s=>s.id===e.id),getMemoOptions(t.options,"debugColumns","getIndex")),e.getIsFirstColumn=n=>{var s;return((s=_getVisibleLeafColumns(t,n)[0])==null?void 0:s.id)===e.id},e.getIsLastColumn=n=>{var s;const a=_getVisibleLeafColumns(t,n);return((s=a[a.length-1])==null?void 0:s.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var n;e.setColumnOrder(t?[]:(n=e.initialState.columnOrder)!=null?n:[])},e._getOrderColumnsFn=memo(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,n,s)=>a=>{let o=[];if(!(t!=null&&t.length))o=a;else{const l=[...t],c=[...a];for(;c.length&&l.length;){const d=l.shift(),f=c.findIndex(R=>R.id===d);f>-1&&o.push(c.splice(f,1)[0])}o=[...o,...c]}return orderColumns(o,n,s)},getMemoOptions(e.options,"debugTable","_getOrderColumnsFn"))}},getDefaultColumnPinningState=()=>({left:[],right:[]}),ColumnPinning={getInitialState:e=>({columnPinning:getDefaultColumnPinningState(),...e}),getDefaultOptions:e=>({onColumnPinningChange:makeStateUpdater("columnPinning",e)}),createColumn:(e,t)=>{e.pin=n=>{const s=e.getLeafColumns().map(a=>a.id).filter(Boolean);t.setColumnPinning(a=>{var o,l;if(n==="right"){var c,d;return{left:((c=a?.left)!=null?c:[]).filter(S=>!(s!=null&&s.includes(S))),right:[...((d=a?.right)!=null?d:[]).filter(S=>!(s!=null&&s.includes(S))),...s]}}if(n==="left"){var f,R;return{left:[...((f=a?.left)!=null?f:[]).filter(S=>!(s!=null&&s.includes(S))),...s],right:((R=a?.right)!=null?R:[]).filter(S=>!(s!=null&&s.includes(S)))}}return{left:((o=a?.left)!=null?o:[]).filter(S=>!(s!=null&&s.includes(S))),right:((l=a?.right)!=null?l:[]).filter(S=>!(s!=null&&s.includes(S)))}})},e.getCanPin=()=>e.getLeafColumns().some(s=>{var a,o,l;return((a=s.columnDef.enablePinning)!=null?a:!0)&&((o=(l=t.options.enableColumnPinning)!=null?l:t.options.enablePinning)!=null?o:!0)}),e.getIsPinned=()=>{const n=e.getLeafColumns().map(c=>c.id),{left:s,right:a}=t.getState().columnPinning,o=n.some(c=>s?.includes(c)),l=n.some(c=>a?.includes(c));return o?"left":l?"right":!1},e.getPinnedIndex=()=>{var n,s;const a=e.getIsPinned();return a?(n=(s=t.getState().columnPinning)==null||(s=s[a])==null?void 0:s.indexOf(e.id))!=null?n:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(n,s,a)=>{const o=[...s??[],...a??[]];return n.filter(l=>!o.includes(l.column.id))},getMemoOptions(t.options,"debugRows","getCenterVisibleCells")),e.getLeftVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(n,s)=>(s??[]).map(o=>n.find(l=>l.column.id===o)).filter(Boolean).map(o=>({...o,position:"left"})),getMemoOptions(t.options,"debugRows","getLeftVisibleCells")),e.getRightVisibleCells=memo(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(n,s)=>(s??[]).map(o=>n.find(l=>l.column.id===o)).filter(Boolean).map(o=>({...o,position:"right"})),getMemoOptions(t.options,"debugRows","getRightVisibleCells"))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var n,s;return e.setColumnPinning(t?getDefaultColumnPinningState():(n=(s=e.initialState)==null?void 0:s.columnPinning)!=null?n:getDefaultColumnPinningState())},e.getIsSomeColumnsPinned=t=>{var n;const s=e.getState().columnPinning;if(!t){var a,o;return!!((a=s.left)!=null&&a.length||(o=s.right)!=null&&o.length)}return!!((n=s[t])!=null&&n.length)},e.getLeftLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(s=>t.find(a=>a.id===s)).filter(Boolean),getMemoOptions(e.options,"debugColumns","getLeftLeafColumns")),e.getRightLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(s=>t.find(a=>a.id===s)).filter(Boolean),getMemoOptions(e.options,"debugColumns","getRightLeafColumns")),e.getCenterLeafColumns=memo(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s)=>{const a=[...n??[],...s??[]];return t.filter(o=>!a.includes(o.id))},getMemoOptions(e.options,"debugColumns","getCenterLeafColumns"))}};function safelyAccessDocument(e){return e||(typeof document<"u"?document:null)}const defaultColumnSizing={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},getDefaultColumnSizingInfoState=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),ColumnSizing={getDefaultColumnDef:()=>defaultColumnSizing,getInitialState:e=>({columnSizing:{},columnSizingInfo:getDefaultColumnSizingInfoState(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:makeStateUpdater("columnSizing",e),onColumnSizingInfoChange:makeStateUpdater("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var n,s,a;const o=t.getState().columnSizing[e.id];return Math.min(Math.max((n=e.columnDef.minSize)!=null?n:defaultColumnSizing.minSize,(s=o??e.columnDef.size)!=null?s:defaultColumnSizing.size),(a=e.columnDef.maxSize)!=null?a:defaultColumnSizing.maxSize)},e.getStart=memo(n=>[n,_getVisibleLeafColumns(t,n),t.getState().columnSizing],(n,s)=>s.slice(0,e.getIndex(n)).reduce((a,o)=>a+o.getSize(),0),getMemoOptions(t.options,"debugColumns","getStart")),e.getAfter=memo(n=>[n,_getVisibleLeafColumns(t,n),t.getState().columnSizing],(n,s)=>s.slice(e.getIndex(n)+1).reduce((a,o)=>a+o.getSize(),0),getMemoOptions(t.options,"debugColumns","getAfter")),e.resetSize=()=>{t.setColumnSizing(n=>{let{[e.id]:s,...a}=n;return a})},e.getCanResize=()=>{var n,s;return((n=e.columnDef.enableResizing)!=null?n:!0)&&((s=t.options.enableColumnResizing)!=null?s:!0)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let n=0;const s=a=>{if(a.subHeaders.length)a.subHeaders.forEach(s);else{var o;n+=(o=a.column.getSize())!=null?o:0}};return s(e),n},e.getStart=()=>{if(e.index>0){const n=e.headerGroup.headers[e.index-1];return n.getStart()+n.getSize()}return 0},e.getResizeHandler=n=>{const s=t.getColumn(e.column.id),a=s?.getCanResize();return o=>{if(!s||!a||(o.persist==null||o.persist(),isTouchStartEvent(o)&&o.touches&&o.touches.length>1))return;const l=e.getSize(),c=e?e.getLeafHeaders().map(at=>[at.column.id,at.column.getSize()]):[[s.id,s.getSize()]],d=isTouchStartEvent(o)?Math.round(o.touches[0].clientX):o.clientX,f={},R=(at,ot)=>{typeof ot=="number"&&(t.setColumnSizingInfo(lt=>{var ut,ct;const dt=t.options.columnResizeDirection==="rtl"?-1:1,pt=(ot-((ut=lt?.startOffset)!=null?ut:0))*dt,mt=Math.max(pt/((ct=lt?.startSize)!=null?ct:0),-.999999);return lt.columnSizingStart.forEach(Rt=>{let[yt,It]=Rt;f[yt]=Math.round(Math.max(It+It*mt,0)*100)/100}),{...lt,deltaOffset:pt,deltaPercentage:mt}}),(t.options.columnResizeMode==="onChange"||at==="end")&&t.setColumnSizing(lt=>({...lt,...f})))},S=at=>R("move",at),te=at=>{R("end",at),t.setColumnSizingInfo(ot=>({...ot,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},A=safelyAccessDocument(n),rt={moveHandler:at=>S(at.clientX),upHandler:at=>{A?.removeEventListener("mousemove",rt.moveHandler),A?.removeEventListener("mouseup",rt.upHandler),te(at.clientX)}},st={moveHandler:at=>(at.cancelable&&(at.preventDefault(),at.stopPropagation()),S(at.touches[0].clientX),!1),upHandler:at=>{var ot;A?.removeEventListener("touchmove",st.moveHandler),A?.removeEventListener("touchend",st.upHandler),at.cancelable&&(at.preventDefault(),at.stopPropagation()),te((ot=at.touches[0])==null?void 0:ot.clientX)}},it=passiveEventSupported()?{passive:!1}:!1;isTouchStartEvent(o)?(A?.addEventListener("touchmove",st.moveHandler,it),A?.addEventListener("touchend",st.upHandler,it)):(A?.addEventListener("mousemove",rt.moveHandler,it),A?.addEventListener("mouseup",rt.upHandler,it)),t.setColumnSizingInfo(at=>({...at,startOffset:d,startSize:l,deltaOffset:0,deltaPercentage:0,columnSizingStart:c,isResizingColumn:s.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var n;e.setColumnSizing(t?{}:(n=e.initialState.columnSizing)!=null?n:{})},e.resetHeaderSizeInfo=t=>{var n;e.setColumnSizingInfo(t?getDefaultColumnSizingInfoState():(n=e.initialState.columnSizingInfo)!=null?n:getDefaultColumnSizingInfoState())},e.getTotalSize=()=>{var t,n;return(t=(n=e.getHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getLeftTotalSize=()=>{var t,n;return(t=(n=e.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getCenterTotalSize=()=>{var t,n;return(t=(n=e.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0},e.getRightTotalSize=()=>{var t,n;return(t=(n=e.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((s,a)=>s+a.getSize(),0))!=null?t:0}}};let passiveSupported=null;function passiveEventSupported(){if(typeof passiveSupported=="boolean")return passiveSupported;let e=!1;try{const t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener("test",n,t),window.removeEventListener("test",n)}catch{e=!1}return passiveSupported=e,passiveSupported}function isTouchStartEvent(e){return e.type==="touchstart"}const ColumnVisibility={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:makeStateUpdater("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(s=>({...s,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{var n,s;const a=e.columns;return(n=a.length?a.some(o=>o.getIsVisible()):(s=t.getState().columnVisibility)==null?void 0:s[e.id])!=null?n:!0},e.getCanHide=()=>{var n,s;return((n=e.columnDef.enableHiding)!=null?n:!0)&&((s=t.options.enableHiding)!=null?s:!0)},e.getToggleVisibilityHandler=()=>n=>{e.toggleVisibility==null||e.toggleVisibility(n.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=memo(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(s=>s.column.getIsVisible()),getMemoOptions(t.options,"debugRows","_getAllVisibleCells")),e.getVisibleCells=memo(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,s,a)=>[...n,...s,...a],getMemoOptions(t.options,"debugRows","getVisibleCells"))},createTable:e=>{const t=(n,s)=>memo(()=>[s(),s().filter(a=>a.getIsVisible()).map(a=>a.id).join("_")],a=>a.filter(o=>o.getIsVisible==null?void 0:o.getIsVisible()),getMemoOptions(e.options,"debugColumns",n));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=n=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(n),e.resetColumnVisibility=n=>{var s;e.setColumnVisibility(n?{}:(s=e.initialState.columnVisibility)!=null?s:{})},e.toggleAllColumnsVisible=n=>{var s;n=(s=n)!=null?s:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((a,o)=>({...a,[o.id]:n||!(o.getCanHide!=null&&o.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>n=>{var s;e.toggleAllColumnsVisible((s=n.target)==null?void 0:s.checked)}}};function _getVisibleLeafColumns(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const GlobalFaceting={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},GlobalFiltering={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:makeStateUpdater("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n;const s=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof s=="string"||typeof s=="number"}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var n,s,a,o;return((n=e.columnDef.enableGlobalFilter)!=null?n:!0)&&((s=t.options.enableGlobalFilter)!=null?s:!0)&&((a=t.options.enableFilters)!=null?a:!0)&&((o=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?o:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>filterFns.includesString,e.getGlobalFilterFn=()=>{var t,n;const{globalFilterFn:s}=e.options;return isFunction$2(s)?s:s==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[s])!=null?t:filterFns[s]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},RowExpanding={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:makeStateUpdater("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{var s,a;if(!t){e._queue(()=>{t=!0});return}if((s=(a=e.options.autoResetAll)!=null?a:e.options.autoResetExpanded)!=null?s:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=s=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(s),e.toggleAllRowsExpanded=s=>{s??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=s=>{var a,o;e.setExpanded(s?{}:(a=(o=e.initialState)==null?void 0:o.expanded)!=null?a:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(s=>s.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>s=>{s.persist==null||s.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const s=e.getState().expanded;return s===!0||Object.values(s).some(Boolean)},e.getIsAllRowsExpanded=()=>{const s=e.getState().expanded;return typeof s=="boolean"?s===!0:!(!Object.keys(s).length||e.getRowModel().flatRows.some(a=>!a.getIsExpanded()))},e.getExpandedDepth=()=>{let s=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(o=>{const l=o.split(".");s=Math.max(s,l.length)}),s},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(s=>{var a;const o=s===!0?!0:!!(s!=null&&s[e.id]);let l={};if(s===!0?Object.keys(t.getRowModel().rowsById).forEach(c=>{l[c]=!0}):l=s,n=(a=n)!=null?a:!o,!o&&n)return{...l,[e.id]:!0};if(o&&!n){const{[e.id]:c,...d}=l;return d}return s})},e.getIsExpanded=()=>{var n;const s=t.getState().expanded;return!!((n=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?n:s===!0||s?.[e.id])},e.getCanExpand=()=>{var n,s,a;return(n=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?n:((s=t.options.enableExpanding)!=null?s:!0)&&!!((a=e.subRows)!=null&&a.length)},e.getIsAllParentsExpanded=()=>{let n=!0,s=e;for(;n&&s.parentId;)s=t.getRow(s.parentId,!0),n=s.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{const n=e.getCanExpand();return()=>{n&&e.toggleExpanded()}}}},defaultPageIndex=0,defaultPageSize=10,getDefaultPaginationState=()=>({pageIndex:defaultPageIndex,pageSize:defaultPageSize}),RowPagination={getInitialState:e=>({...e,pagination:{...getDefaultPaginationState(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:makeStateUpdater("pagination",e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{var s,a;if(!t){e._queue(()=>{t=!0});return}if((s=(a=e.options.autoResetAll)!=null?a:e.options.autoResetPageIndex)!=null?s:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=s=>{const a=o=>functionalUpdate(s,o);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(a)},e.resetPagination=s=>{var a;e.setPagination(s?getDefaultPaginationState():(a=e.initialState.pagination)!=null?a:getDefaultPaginationState())},e.setPageIndex=s=>{e.setPagination(a=>{let o=functionalUpdate(s,a.pageIndex);const l=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return o=Math.max(0,Math.min(o,l)),{...a,pageIndex:o}})},e.resetPageIndex=s=>{var a,o;e.setPageIndex(s?defaultPageIndex:(a=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageIndex)!=null?a:defaultPageIndex)},e.resetPageSize=s=>{var a,o;e.setPageSize(s?defaultPageSize:(a=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageSize)!=null?a:defaultPageSize)},e.setPageSize=s=>{e.setPagination(a=>{const o=Math.max(1,functionalUpdate(s,a.pageSize)),l=a.pageSize*a.pageIndex,c=Math.floor(l/o);return{...a,pageIndex:c,pageSize:o}})},e.setPageCount=s=>e.setPagination(a=>{var o;let l=functionalUpdate(s,(o=e.options.pageCount)!=null?o:-1);return typeof l=="number"&&(l=Math.max(-1,l)),{...a,pageCount:l}}),e.getPageOptions=memo(()=>[e.getPageCount()],s=>{let a=[];return s&&s>0&&(a=[...new Array(s)].fill(null).map((o,l)=>l)),a},getMemoOptions(e.options,"debugTable","getPageOptions")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:s}=e.getState().pagination,a=e.getPageCount();return a===-1?!0:a===0?!1:s<a-1},e.previousPage=()=>e.setPageIndex(s=>s-1),e.nextPage=()=>e.setPageIndex(s=>s+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var s;return(s=e.options.pageCount)!=null?s:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var s;return(s=e.options.rowCount)!=null?s:e.getPrePaginationRowModel().rows.length}}},getDefaultRowPinningState=()=>({top:[],bottom:[]}),RowPinning={getInitialState:e=>({rowPinning:getDefaultRowPinningState(),...e}),getDefaultOptions:e=>({onRowPinningChange:makeStateUpdater("rowPinning",e)}),createRow:(e,t)=>{e.pin=(n,s,a)=>{const o=s?e.getLeafRows().map(d=>{let{id:f}=d;return f}):[],l=a?e.getParentRows().map(d=>{let{id:f}=d;return f}):[],c=new Set([...l,e.id,...o]);t.setRowPinning(d=>{var f,R;if(n==="bottom"){var S,te;return{top:((S=d?.top)!=null?S:[]).filter(st=>!(c!=null&&c.has(st))),bottom:[...((te=d?.bottom)!=null?te:[]).filter(st=>!(c!=null&&c.has(st))),...Array.from(c)]}}if(n==="top"){var A,rt;return{top:[...((A=d?.top)!=null?A:[]).filter(st=>!(c!=null&&c.has(st))),...Array.from(c)],bottom:((rt=d?.bottom)!=null?rt:[]).filter(st=>!(c!=null&&c.has(st)))}}return{top:((f=d?.top)!=null?f:[]).filter(st=>!(c!=null&&c.has(st))),bottom:((R=d?.bottom)!=null?R:[]).filter(st=>!(c!=null&&c.has(st)))}})},e.getCanPin=()=>{var n;const{enableRowPinning:s,enablePinning:a}=t.options;return typeof s=="function"?s(e):(n=s??a)!=null?n:!0},e.getIsPinned=()=>{const n=[e.id],{top:s,bottom:a}=t.getState().rowPinning,o=n.some(c=>s?.includes(c)),l=n.some(c=>a?.includes(c));return o?"top":l?"bottom":!1},e.getPinnedIndex=()=>{var n,s;const a=e.getIsPinned();if(!a)return-1;const o=(n=a==="top"?t.getTopRows():t.getBottomRows())==null?void 0:n.map(l=>{let{id:c}=l;return c});return(s=o?.indexOf(e.id))!=null?s:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var n,s;return e.setRowPinning(t?getDefaultRowPinningState():(n=(s=e.initialState)==null?void 0:s.rowPinning)!=null?n:getDefaultRowPinningState())},e.getIsSomeRowsPinned=t=>{var n;const s=e.getState().rowPinning;if(!t){var a,o;return!!((a=s.top)!=null&&a.length||(o=s.bottom)!=null&&o.length)}return!!((n=s[t])!=null&&n.length)},e._getPinnedRows=(t,n,s)=>{var a;return((a=e.options.keepPinnedRows)==null||a?(n??[]).map(l=>{const c=e.getRow(l,!0);return c.getIsAllParentsExpanded()?c:null}):(n??[]).map(l=>t.find(c=>c.id===l))).filter(Boolean).map(l=>({...l,position:s}))},e.getTopRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,"top"),getMemoOptions(e.options,"debugRows","getTopRows")),e.getBottomRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,"bottom"),getMemoOptions(e.options,"debugRows","getBottomRows")),e.getCenterRows=memo(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(t,n,s)=>{const a=new Set([...n??[],...s??[]]);return t.filter(o=>!a.has(o.id))},getMemoOptions(e.options,"debugRows","getCenterRows"))}},RowSelection={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:makeStateUpdater("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var n;return e.setRowSelection(t?{}:(n=e.initialState.rowSelection)!=null?n:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const s={...n},a=e.getPreGroupedRowModel().flatRows;return t?a.forEach(o=>{o.getCanSelect()&&(s[o.id]=!0)}):a.forEach(o=>{delete s[o.id]}),s})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{const s=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),a={...n};return e.getRowModel().rows.forEach(o=>{mutateRowIsSelected(a,o.id,s,!0,e)}),a}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getSelectedRowModel")),e.getFilteredSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getFilteredSelectedRowModel")),e.getGroupedSelectedRowModel=memo(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?selectRowsFn(e,n):{rows:[],flatRows:[],rowsById:{}},getMemoOptions(e.options,"debugTable","getGroupedSelectedRowModel")),e.getIsAllRowsSelected=()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState();let s=!!(t.length&&Object.keys(n).length);return s&&t.some(a=>a.getCanSelect()&&!n[a.id])&&(s=!1),s},e.getIsAllPageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows.filter(a=>a.getCanSelect()),{rowSelection:n}=e.getState();let s=!!t.length;return s&&t.some(a=>!n[a.id])&&(s=!1),s},e.getIsSomeRowsSelected=()=>{var t;const n=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return n>0&&n<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,s)=>{const a=e.getIsSelected();t.setRowSelection(o=>{var l;if(n=typeof n<"u"?n:!a,e.getCanSelect()&&a===n)return o;const c={...o};return mutateRowIsSelected(c,e.id,n,(l=s?.selectChildren)!=null?l:!0,t),c})},e.getIsSelected=()=>{const{rowSelection:n}=t.getState();return isRowSelected(e,n)},e.getIsSomeSelected=()=>{const{rowSelection:n}=t.getState();return isSubRowSelected(e,n)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=t.getState();return isSubRowSelected(e,n)==="all"},e.getCanSelect=()=>{var n;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(n=t.options.enableRowSelection)!=null?n:!0},e.getCanSelectSubRows=()=>{var n;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(n=t.options.enableSubRowSelection)!=null?n:!0},e.getCanMultiSelect=()=>{var n;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(n=t.options.enableMultiRowSelection)!=null?n:!0},e.getToggleSelectedHandler=()=>{const n=e.getCanSelect();return s=>{var a;n&&e.toggleSelected((a=s.target)==null?void 0:a.checked)}}}},mutateRowIsSelected=(e,t,n,s,a)=>{var o;const l=a.getRow(t,!0);n?(l.getCanMultiSelect()||Object.keys(e).forEach(c=>delete e[c]),l.getCanSelect()&&(e[t]=!0)):delete e[t],s&&(o=l.subRows)!=null&&o.length&&l.getCanSelectSubRows()&&l.subRows.forEach(c=>mutateRowIsSelected(e,c.id,n,s,a))};function selectRowsFn(e,t){const n=e.getState().rowSelection,s=[],a={},o=function(l,c){return l.map(d=>{var f;const R=isRowSelected(d,n);if(R&&(s.push(d),a[d.id]=d),(f=d.subRows)!=null&&f.length&&(d={...d,subRows:o(d.subRows)}),R)return d}).filter(Boolean)};return{rows:o(t.rows),flatRows:s,rowsById:a}}function isRowSelected(e,t){var n;return(n=t[e.id])!=null?n:!1}function isSubRowSelected(e,t,n){var s;if(!((s=e.subRows)!=null&&s.length))return!1;let a=!0,o=!1;return e.subRows.forEach(l=>{if(!(o&&!a)&&(l.getCanSelect()&&(isRowSelected(l,t)?o=!0:a=!1),l.subRows&&l.subRows.length)){const c=isSubRowSelected(l,t);c==="all"?o=!0:(c==="some"&&(o=!0),a=!1)}}),a?"all":o?"some":!1}const reSplitAlphaNumeric=/([0-9]+)/gm,alphanumeric$1=(e,t,n)=>compareAlphanumeric(toString$1(e.getValue(n)).toLowerCase(),toString$1(t.getValue(n)).toLowerCase()),alphanumericCaseSensitive=(e,t,n)=>compareAlphanumeric(toString$1(e.getValue(n)),toString$1(t.getValue(n))),text=(e,t,n)=>compareBasic(toString$1(e.getValue(n)).toLowerCase(),toString$1(t.getValue(n)).toLowerCase()),textCaseSensitive=(e,t,n)=>compareBasic(toString$1(e.getValue(n)),toString$1(t.getValue(n))),datetime=(e,t,n)=>{const s=e.getValue(n),a=t.getValue(n);return s>a?1:s<a?-1:0},basic=(e,t,n)=>compareBasic(e.getValue(n),t.getValue(n));function compareBasic(e,t){return e===t?0:e>t?1:-1}function toString$1(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function compareAlphanumeric(e,t){const n=e.split(reSplitAlphaNumeric).filter(Boolean),s=t.split(reSplitAlphaNumeric).filter(Boolean);for(;n.length&&s.length;){const a=n.shift(),o=s.shift(),l=parseInt(a,10),c=parseInt(o,10),d=[l,c].sort();if(isNaN(d[0])){if(a>o)return 1;if(o>a)return-1;continue}if(isNaN(d[1]))return isNaN(l)?-1:1;if(l>c)return 1;if(c>l)return-1}return n.length-s.length}const sortingFns={alphanumeric:alphanumeric$1,alphanumericCaseSensitive,text,textCaseSensitive,datetime,basic},RowSorting={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:makeStateUpdater("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{const n=t.getFilteredRowModel().flatRows.slice(10);let s=!1;for(const a of n){const o=a?.getValue(e.id);if(Object.prototype.toString.call(o)==="[object Date]")return sortingFns.datetime;if(typeof o=="string"&&(s=!0,o.split(reSplitAlphaNumeric).length>1))return sortingFns.alphanumeric}return s?sortingFns.text:sortingFns.basic},e.getAutoSortDir=()=>{const n=t.getFilteredRowModel().flatRows[0];return typeof n?.getValue(e.id)=="string"?"asc":"desc"},e.getSortingFn=()=>{var n,s;if(!e)throw new Error;return isFunction$2(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(n=(s=t.options.sortingFns)==null?void 0:s[e.columnDef.sortingFn])!=null?n:sortingFns[e.columnDef.sortingFn]},e.toggleSorting=(n,s)=>{const a=e.getNextSortingOrder(),o=typeof n<"u"&&n!==null;t.setSorting(l=>{const c=l?.find(A=>A.id===e.id),d=l?.findIndex(A=>A.id===e.id);let f=[],R,S=o?n:a==="desc";if(l!=null&&l.length&&e.getCanMultiSort()&&s?c?R="toggle":R="add":l!=null&&l.length&&d!==l.length-1?R="replace":c?R="toggle":R="replace",R==="toggle"&&(o||a||(R="remove")),R==="add"){var te;f=[...l,{id:e.id,desc:S}],f.splice(0,f.length-((te=t.options.maxMultiSortColCount)!=null?te:Number.MAX_SAFE_INTEGER))}else R==="toggle"?f=l.map(A=>A.id===e.id?{...A,desc:S}:A):R==="remove"?f=l.filter(A=>A.id!==e.id):f=[{id:e.id,desc:S}];return f})},e.getFirstSortDir=()=>{var n,s;return((n=(s=e.columnDef.sortDescFirst)!=null?s:t.options.sortDescFirst)!=null?n:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=n=>{var s,a;const o=e.getFirstSortDir(),l=e.getIsSorted();return l?l!==o&&((s=t.options.enableSortingRemoval)==null||s)&&(!(n&&(a=t.options.enableMultiRemove)!=null)||a)?!1:l==="desc"?"asc":"desc":o},e.getCanSort=()=>{var n,s;return((n=e.columnDef.enableSorting)!=null?n:!0)&&((s=t.options.enableSorting)!=null?s:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var n,s;return(n=(s=e.columnDef.enableMultiSort)!=null?s:t.options.enableMultiSort)!=null?n:!!e.accessorFn},e.getIsSorted=()=>{var n;const s=(n=t.getState().sorting)==null?void 0:n.find(a=>a.id===e.id);return s?s.desc?"desc":"asc":!1},e.getSortIndex=()=>{var n,s;return(n=(s=t.getState().sorting)==null?void 0:s.findIndex(a=>a.id===e.id))!=null?n:-1},e.clearSorting=()=>{t.setSorting(n=>n!=null&&n.length?n.filter(s=>s.id!==e.id):[])},e.getToggleSortingHandler=()=>{const n=e.getCanSort();return s=>{n&&(s.persist==null||s.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(s):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var n,s;e.setSorting(t?[]:(n=(s=e.initialState)==null?void 0:s.sorting)!=null?n:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},builtInFeatures=[Headers$1,ColumnVisibility,ColumnOrdering,ColumnPinning,ColumnFaceting,ColumnFiltering,GlobalFaceting,GlobalFiltering,RowSorting,ColumnGrouping,RowExpanding,RowPagination,RowPinning,RowSelection,ColumnSizing];function createTable(e){var t,n;process.env.NODE_ENV!=="production"&&(e.debugAll||e.debugTable)&&console.info("Creating Table Instance...");const s=[...builtInFeatures,...(t=e._features)!=null?t:[]];let a={_features:s};const o=a._features.reduce((te,A)=>Object.assign(te,A.getDefaultOptions==null?void 0:A.getDefaultOptions(a)),{}),l=te=>a.options.mergeOptions?a.options.mergeOptions(o,te):{...o,...te};let d={...{},...(n=e.initialState)!=null?n:{}};a._features.forEach(te=>{var A;d=(A=te.getInitialState==null?void 0:te.getInitialState(d))!=null?A:d});const f=[];let R=!1;const S={_features:s,options:{...o,...e},initialState:d,_queue:te=>{f.push(te),R||(R=!0,Promise.resolve().then(()=>{for(;f.length;)f.shift()();R=!1}).catch(A=>setTimeout(()=>{throw A})))},reset:()=>{a.setState(a.initialState)},setOptions:te=>{const A=functionalUpdate(te,a.options);a.options=l(A)},getState:()=>a.options.state,setState:te=>{a.options.onStateChange==null||a.options.onStateChange(te)},_getRowId:(te,A,rt)=>{var st;return(st=a.options.getRowId==null?void 0:a.options.getRowId(te,A,rt))!=null?st:`${rt?[rt.id,A].join("."):A}`},getCoreRowModel:()=>(a._getCoreRowModel||(a._getCoreRowModel=a.options.getCoreRowModel(a)),a._getCoreRowModel()),getRowModel:()=>a.getPaginationRowModel(),getRow:(te,A)=>{let rt=(A?a.getPrePaginationRowModel():a.getRowModel()).rowsById[te];if(!rt&&(rt=a.getCoreRowModel().rowsById[te],!rt))throw process.env.NODE_ENV!=="production"?new Error(`getRow could not find row with ID: ${te}`):new Error;return rt},_getDefaultColumnDef:memo(()=>[a.options.defaultColumn],te=>{var A;return te=(A=te)!=null?A:{},{header:rt=>{const st=rt.header.column.columnDef;return st.accessorKey?st.accessorKey:st.accessorFn?st.id:null},cell:rt=>{var st,it;return(st=(it=rt.renderValue())==null||it.toString==null?void 0:it.toString())!=null?st:null},...a._features.reduce((rt,st)=>Object.assign(rt,st.getDefaultColumnDef==null?void 0:st.getDefaultColumnDef()),{}),...te}},getMemoOptions(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>a.options.columns,getAllColumns:memo(()=>[a._getColumnDefs()],te=>{const A=function(rt,st,it){return it===void 0&&(it=0),rt.map(at=>{const ot=createColumn(a,at,it,st),lt=at;return ot.columns=lt.columns?A(lt.columns,ot,it+1):[],ot})};return A(te)},getMemoOptions(e,"debugColumns","getAllColumns")),getAllFlatColumns:memo(()=>[a.getAllColumns()],te=>te.flatMap(A=>A.getFlatColumns()),getMemoOptions(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:memo(()=>[a.getAllFlatColumns()],te=>te.reduce((A,rt)=>(A[rt.id]=rt,A),{}),getMemoOptions(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:memo(()=>[a.getAllColumns(),a._getOrderColumnsFn()],(te,A)=>{let rt=te.flatMap(st=>st.getLeafColumns());return A(rt)},getMemoOptions(e,"debugColumns","getAllLeafColumns")),getColumn:te=>{const A=a._getAllFlatColumnsById()[te];return process.env.NODE_ENV!=="production"&&!A&&console.error(`[Table] Column with id '${te}' does not exist.`),A}};Object.assign(a,S);for(let te=0;te<a._features.length;te++){const A=a._features[te];A==null||A.createTable==null||A.createTable(a)}return a}function getCoreRowModel(){return e=>memo(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},s=function(a,o,l){o===void 0&&(o=0);const c=[];for(let f=0;f<a.length;f++){const R=createRow(e,e._getRowId(a[f],f,l),a[f],f,o,void 0,l?.id);if(n.flatRows.push(R),n.rowsById[R.id]=R,c.push(R),e.options.getSubRows){var d;R.originalSubRows=e.options.getSubRows(a[f],f),(d=R.originalSubRows)!=null&&d.length&&(R.subRows=s(R.originalSubRows,o+1,R))}}return c};return n.rows=s(t),n},getMemoOptions(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function expandRows(e){const t=[],n=s=>{var a;t.push(s),(a=s.subRows)!=null&&a.length&&s.getIsExpanded()&&s.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}function filterRows(e,t,n){return n.options.filterFromLeafRows?filterRowModelFromLeafs(e,t,n):filterRowModelFromRoot(e,t,n)}function filterRowModelFromLeafs(e,t,n){var s;const a=[],o={},l=(s=n.options.maxLeafRowFilterDepth)!=null?s:100,c=function(d,f){f===void 0&&(f=0);const R=[];for(let te=0;te<d.length;te++){var S;let A=d[te];const rt=createRow(n,A.id,A.original,A.index,A.depth,void 0,A.parentId);if(rt.columnFilters=A.columnFilters,(S=A.subRows)!=null&&S.length&&f<l){if(rt.subRows=c(A.subRows,f+1),A=rt,t(A)&&!rt.subRows.length){R.push(A),o[A.id]=A,a.push(A);continue}if(t(A)||rt.subRows.length){R.push(A),o[A.id]=A,a.push(A);continue}}else A=rt,t(A)&&(R.push(A),o[A.id]=A,a.push(A))}return R};return{rows:c(e),flatRows:a,rowsById:o}}function filterRowModelFromRoot(e,t,n){var s;const a=[],o={},l=(s=n.options.maxLeafRowFilterDepth)!=null?s:100,c=function(d,f){f===void 0&&(f=0);const R=[];for(let te=0;te<d.length;te++){let A=d[te];if(t(A)){var S;if((S=A.subRows)!=null&&S.length&&f<l){const st=createRow(n,A.id,A.original,A.index,A.depth,void 0,A.parentId);st.subRows=c(A.subRows,f+1),A=st}R.push(A),a.push(A),o[A.id]=A}}return R};return{rows:c(e),flatRows:a,rowsById:o}}function getFilteredRowModel(){return e=>memo(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,s)=>{if(!t.rows.length||!(n!=null&&n.length)&&!s){for(let te=0;te<t.flatRows.length;te++)t.flatRows[te].columnFilters={},t.flatRows[te].columnFiltersMeta={};return t}const a=[],o=[];(n??[]).forEach(te=>{var A;const rt=e.getColumn(te.id);if(!rt)return;const st=rt.getFilterFn();if(!st){process.env.NODE_ENV!=="production"&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${rt.id}.`);return}a.push({id:te.id,filterFn:st,resolvedValue:(A=st.resolveFilterValue==null?void 0:st.resolveFilterValue(te.value))!=null?A:te.value})});const l=(n??[]).map(te=>te.id),c=e.getGlobalFilterFn(),d=e.getAllLeafColumns().filter(te=>te.getCanGlobalFilter());s&&c&&d.length&&(l.push("__global__"),d.forEach(te=>{var A;o.push({id:te.id,filterFn:c,resolvedValue:(A=c.resolveFilterValue==null?void 0:c.resolveFilterValue(s))!=null?A:s})}));let f,R;for(let te=0;te<t.flatRows.length;te++){const A=t.flatRows[te];if(A.columnFilters={},a.length)for(let rt=0;rt<a.length;rt++){f=a[rt];const st=f.id;A.columnFilters[st]=f.filterFn(A,st,f.resolvedValue,it=>{A.columnFiltersMeta[st]=it})}if(o.length){for(let rt=0;rt<o.length;rt++){R=o[rt];const st=R.id;if(R.filterFn(A,st,R.resolvedValue,it=>{A.columnFiltersMeta[st]=it})){A.columnFilters.__global__=!0;break}}A.columnFilters.__global__!==!0&&(A.columnFilters.__global__=!1)}}const S=te=>{for(let A=0;A<l.length;A++)if(te.columnFilters[l[A]]===!1)return!1;return!0};return filterRows(t.rows,S,e)},getMemoOptions(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex()))}function getPaginationRowModel(e){return t=>memo(()=>[t.getState().pagination,t.getPrePaginationRowModel(),t.options.paginateExpandedRows?void 0:t.getState().expanded],(n,s)=>{if(!s.rows.length)return s;const{pageSize:a,pageIndex:o}=n;let{rows:l,flatRows:c,rowsById:d}=s;const f=a*o,R=f+a;l=l.slice(f,R);let S;t.options.paginateExpandedRows?S={rows:l,flatRows:c,rowsById:d}:S=expandRows({rows:l,flatRows:c,rowsById:d}),S.flatRows=[];const te=A=>{S.flatRows.push(A),A.subRows.length&&A.subRows.forEach(te)};return S.rows.forEach(te),S},getMemoOptions(t.options,"debugTable","getPaginationRowModel"))}function getSortedRowModel(){return e=>memo(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;const s=e.getState().sorting,a=[],o=s.filter(d=>{var f;return(f=e.getColumn(d.id))==null?void 0:f.getCanSort()}),l={};o.forEach(d=>{const f=e.getColumn(d.id);f&&(l[d.id]={sortUndefined:f.columnDef.sortUndefined,invertSorting:f.columnDef.invertSorting,sortingFn:f.getSortingFn()})});const c=d=>{const f=d.map(R=>({...R}));return f.sort((R,S)=>{for(let A=0;A<o.length;A+=1){var te;const rt=o[A],st=l[rt.id],it=st.sortUndefined,at=(te=rt?.desc)!=null?te:!1;let ot=0;if(it){const lt=R.getValue(rt.id),ut=S.getValue(rt.id),ct=lt===void 0,dt=ut===void 0;if(ct||dt){if(it==="first")return ct?-1:1;if(it==="last")return ct?1:-1;ot=ct&&dt?0:ct?it:-it}}if(ot===0&&(ot=st.sortingFn(R,S,rt.id)),ot!==0)return at&&(ot*=-1),st.invertSorting&&(ot*=-1),ot}return R.index-S.index}),f.forEach(R=>{var S;a.push(R),(S=R.subRows)!=null&&S.length&&(R.subRows=c(R.subRows))}),f};return{rows:c(n.rows),flatRows:a,rowsById:n.rowsById}},getMemoOptions(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex()))}function flexRender(e,t){return e?isReactComponent(e)?React__namespace.createElement(e,t):e:null}function isReactComponent(e){return isClassComponent(e)||typeof e=="function"||isExoticComponent(e)}function isClassComponent(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function isExoticComponent(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function useReactTable(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=React__namespace.useState(()=>({current:createTable(t)})),[s,a]=React__namespace.useState(()=>n.current.initialState);return n.current.setOptions(o=>({...o,...e,state:{...s,...e.state},onStateChange:l=>{a(l),e.onStateChange==null||e.onStateChange(l)}})),n.current}function DataTable({columns:e,data:t,uniqueValues:n,tableClass:s,loading:a,initialSort:o}){const[l,c]=React.useState(o??[]),[d,f]=React.useState([]),[R,S]=React.useState({pageIndex:0,pageSize:10}),[te,A]=React.useState(null),rt=useReactTable({data:a?[]:t,columns:e,getCoreRowModel:getCoreRowModel(),onSortingChange:c,getSortedRowModel:getSortedRowModel(),onColumnFiltersChange:f,getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),onPaginationChange:S,state:{sorting:l,columnFilters:d,pagination:R},manualPagination:a,manualSorting:a,manualFiltering:a}),st=(it,at)=>{it.toggleSorting(at),A(null)};return a?jsxRuntime.jsxs("div",{className:"@container space-y-4",children:[jsxRuntime.jsx("div",{className:`rounded-md border ${s??""}`,children:jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:jsxRuntime.jsx(TableRow,{children:e.map((it,at)=>jsxRuntime.jsx(TableHead,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-header-${at}`))})}),jsxRuntime.jsx(TableBody,{children:Array.from({length:R.pageSize}).map((it,at)=>jsxRuntime.jsx(TableRow,{children:e.map((ot,lt)=>jsxRuntime.jsx(TableCell,{children:jsxRuntime.jsx(Skeleton,{className:"h-6 w-full"})},`skeleton-cell-${at}-${lt}`))},`skeleton-row-${at}`))})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-4 @[35rem]:flex-row @[35rem]:justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-[110px]"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-[70px]"})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"hidden h-8 w-8 lg:flex"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-12"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-8"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-8"})]}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8"}),jsxRuntime.jsx(Skeleton,{className:"hidden h-8 w-8 lg:flex"})]})]})]}):jsxRuntime.jsxs("div",{className:"@container space-y-4",children:[jsxRuntime.jsxs(ScrollArea,{className:`rounded-md border ${s??""}`,children:[jsxRuntime.jsxs(Table,{children:[jsxRuntime.jsx(TableHeader,{children:rt.getHeaderGroups().map(it=>jsxRuntime.jsx(TableRow,{children:it.headers.map(at=>jsxRuntime.jsx(TableHead,{children:at.isPlaceholder?null:at.column.getCanSort()||at.column.getCanFilter()?jsxRuntime.jsxs(Popover,{open:te===at.id,onOpenChange:ot=>A(ot?at.id:null),children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"pl-0",children:[flexRender(at.column.columnDef.header,at.getContext()),at.column.getIsFiltered()?jsxRuntime.jsx(Funnel,{className:"ml-2 h-4 w-4"}):at.column.getIsSorted()==="asc"?jsxRuntime.jsx(ArrowUp,{className:"ml-2 h-4 w-4"}):at.column.getIsSorted()==="desc"?jsxRuntime.jsx(ArrowDown,{className:"ml-2 h-4 w-4"}):jsxRuntime.jsx(ArrowUpDown,{className:"ml-2 h-4 w-4"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-56",children:jsxRuntime.jsxs("div",{className:"space-y-2",children:[at.column.getCanSort()&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"w-full justify-start",onClick:()=>st(at.column,!1),children:[jsxRuntime.jsx(ArrowUp,{className:"mr-2 h-4 w-4"}),"Sort Ascending"]}),jsxRuntime.jsxs(Button$1,{variant:"ghost",className:"w-full justify-start",onClick:()=>st(at.column,!0),children:[jsxRuntime.jsx(ArrowDown,{className:"mr-2 h-4 w-4"}),"Sort Descending"]})]}),at.column.getCanFilter()&&jsxRuntime.jsx("div",{className:"px-2 py-1",children:n[at.column.id]?jsxRuntime.jsxs(Select$1,{onValueChange:ot=>at.column.setFilterValue(ot==="all"?void 0:[ot]),children:[jsxRuntime.jsx(SelectTrigger,{children:jsxRuntime.jsx(SelectValue,{placeholder:`Filter ${at.column.columnDef.header}...`})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"all",children:"All"}),n[at.column.id]?.map(ot=>jsxRuntime.jsx(SelectItem,{value:ot||"empty",children:ot||"(Empty)"},ot))]})]}):jsxRuntime.jsx(Input,{placeholder:`Filter ${at.column.columnDef.header}...`,value:at.column.getFilterValue()??"",onChange:ot=>at.column.setFilterValue(ot.target.value),className:"w-full"})})]})})]}):jsxRuntime.jsx("div",{className:"py-2 px-4",children:flexRender(at.column.columnDef.header,at.getContext())})},at.id))},it.id))}),jsxRuntime.jsx(TableBody,{children:rt.getRowModel().rows?.length?rt.getRowModel().rows.map(it=>jsxRuntime.jsx(TableRow,{"data-state":it.getIsSelected()&&"selected",children:it.getVisibleCells().map(at=>jsxRuntime.jsx(TableCell,{children:flexRender(at.column.columnDef.cell,at.getContext())},at.id))},it.id)):jsxRuntime.jsx(TableRow,{children:jsxRuntime.jsx(TableCell,{colSpan:e.length,className:"h-24 text-center",children:"No results."})})})]}),jsxRuntime.jsx(ScrollBar,{orientation:"horizontal"})]}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-4 @[35rem]:flex-row @[35rem]:justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Rows per page"}),jsxRuntime.jsxs(Select$1,{value:`${rt.getState().pagination.pageSize}`,onValueChange:it=>{rt.setPageSize(Number(it))},children:[jsxRuntime.jsx(SelectTrigger,{className:"h-8 w-[70px]",children:jsxRuntime.jsx(SelectValue,{asChild:!0,children:jsxRuntime.jsx("span",{children:rt.getState().pagination.pageSize})})}),jsxRuntime.jsx(SelectContent,{side:"top",children:[10,20,30,40,50].map(it=>jsxRuntime.jsx(SelectItem,{value:`${it}`,children:jsxRuntime.jsx("span",{children:it})},it))})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsxs(Button$1,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>rt.setPageIndex(0),disabled:!rt.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to first page"}),jsxRuntime.jsx(ChevronsLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>rt.previousPage(),disabled:!rt.getCanPreviousPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to previous page"}),jsxRuntime.jsx(ChevronLeft,{className:"h-4 w-4"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"Page"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:rt.getState().pagination.pageIndex+1}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:"of"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:rt.getPageCount()})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>rt.nextPage(),disabled:!rt.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to next page"}),jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})]}),jsxRuntime.jsxs(Button$1,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>rt.setPageIndex(rt.getPageCount()-1),disabled:!rt.getCanNextPage(),children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Go to last page"}),jsxRuntime.jsx(ChevronsRight,{className:"h-4 w-4"})]})]})]})]})}function PartnerCard({account:e,action:t,loading:n=!1,className:s,withAbout:a=!1}){const[o,l]=React.useState(!0),[c,d]=React.useState(!1),f=e?.ApplicationId,R=useApiOrigin(),S=f?buildApiUrl(`/V4/Partner/${f}/Account/Video`,R):null,{data:te}=useGetV4PartnerByApplicationIdAccountVideoExistsQuery({applicationId:f??""},{skip:!f||n}),A=typeof te=="boolean"?te:typeof te=="string"?te.toLowerCase()==="true":!1,rt=()=>{l(!1)};return n||!e?jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${s}`,children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"}),jsxRuntime.jsx(Skeleton,{className:"h-3 w-16"})]}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-48 mt-1"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"})]}),a&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-full"})]})]})}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-48"})]})]}):jsxRuntime.jsxs(Card,{className:`flex flex-col h-full ${s}`,children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Partner",applicationId:e.ApplicationId,publicName:e.PublicName}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[(e.IsManufacturer||e.IsReseller||e.IsSalesAgency||e.HasShopifyStore||e.IsVendor)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.IsManufacturer&&jsxRuntime.jsx(Badge,{variant:"info",children:"Manufacturer"}),e.IsReseller&&jsxRuntime.jsx(Badge,{variant:"success",children:"Reseller"}),e.IsSalesAgency&&jsxRuntime.jsx(Badge,{variant:"outline",children:"Agency"}),e.HasShopifyStore&&jsxRuntime.jsx(Badge,{variant:"secondary",children:"Shopify"}),e.IsVendor&&jsxRuntime.jsx(Badge,{variant:"outline",children:"Vendor"})]}),a&&e.About&&jsxRuntime.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.About??""}})]})}),jsxRuntime.jsxs(CardFooter,{className:"px-6 py-4 flex justify-between gap-2 mt-auto",children:[A&&S?jsxRuntime.jsxs(Dialog,{open:c,onOpenChange:st=>{d(st),st&&l(!0)},children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"flex items-center gap-2",children:[jsxRuntime.jsx(Video,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Watch Video"})]})}),jsxRuntime.jsxs(DialogContent,{className:"@sm:max-w-[360px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsxs(DialogTitle,{children:[e.PublicName," Video"]})}),jsxRuntime.jsxs("div",{className:"w-full h-[640px] rounded-md overflow-hidden",children:[o&&jsxRuntime.jsx(Skeleton,{className:"w-full h-full"}),jsxRuntime.jsx("video",{src:S,controls:!0,preload:"auto",playsInline:!0,autoPlay:!0,"aria-label":`Video for ${e.PublicName}`,className:`w-full h-full object-cover object-center ${o?"invisible":"visible"}`,onLoadedData:rt,onError:()=>l(!1)})]})]})]}):jsxRuntime.jsx("div",{}),t||jsxRuntime.jsxs(Button$1,{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ExternalLink,{className:"h-4 w-4"}),"Go to Partner Dashboard"]})]})]})}function ResellerCard({reseller:e,link:t,linkNewTab:n=!0,actions:s,mainAction:a,loading:o=!1}){if(o||!e)return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(CardHeader,{className:"flex flex-row items-start justify-between space-y-0 pb-2 pt-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-12 w-12 rounded-md"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-24 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-48"})]})]})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsx("div",{className:"flex",children:jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-16 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-14 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-32"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-40"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-4"}),jsxRuntime.jsx(Skeleton,{className:"h-4 w-36"})]})]})]})})}),jsxRuntime.jsxs(CardFooter,{className:"flex justify-between pt-2 gap-2 mt-auto",children:[jsxRuntime.jsx(Skeleton,{className:"h-9 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-9 w-40"})]})]});const l=[e.City,e.Province,e.Country].filter(Boolean),c=l.length>0?l.join(", "):"Location not provided",d=e.Priority?.trim(),f=!!e.Qualification?.QualificationId&&e.Qualification?.QualificationId!=="Suspended",R=!!e.OnHold&&e.OnHold!==0,S=!!d,te=A=>{const rt=A.toLowerCase();return rt.includes("starter")||rt.includes("basic")?"secondary":rt.includes("exclusive")||rt.includes("jean coutu")||rt.includes("novexco")||rt.includes("coopsco")?"success":"info"};return jsxRuntime.jsxs(Card,{className:"flex flex-col h-full",children:[jsxRuntime.jsx(PartnerCardHeader,{type:"Reseller",applicationId:e.ResellerId,publicName:e.PublicName,name:e.Name,location:c,link:t,linkNewTab:n,children:jsxRuntime.jsx("div",{className:"flex flex-col items-end gap-2",children:e.SalesStatistics&&e.SalesStatistics.length>0&&jsxRuntime.jsx("div",{className:"h-16 w-24",children:jsxRuntime.jsx(SalesChart,{statistics:e.SalesStatistics,size:"mini"})})})}),jsxRuntime.jsx(CardContent,{className:"pb-2 flex-grow",children:jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsxs("div",{className:"flex flex-col flex-1 space-y-2",children:[(f||R||S)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2",children:[f&&jsxRuntime.jsx(QualificationBadge,{qualification:e.Qualification??{}}),R&&jsxRuntime.jsx(Badge,{variant:"warning",children:"On Hold"}),S&&jsxRuntime.jsx(Badge,{variant:te(d),children:d})]}),jsxRuntime.jsxs("div",{className:"space-y-1 pt-2",children:[e.Phone&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`tel:${e.Phone}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Phone,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Phone})]}),e.PublicEmail&&jsxRuntime.jsxs(reactRouterDom.Link,{to:`mailto:${e.PublicEmail}`,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.PublicEmail})]}),e.Website&&jsxRuntime.jsxs(reactRouterDom.Link,{to:e.Website,target:"_blank",className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(Globe,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.Website})]}),e.CurrencyCode&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[jsxRuntime.jsx(DollarSign,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:e.CurrencyCode})]})]})]}),e?.SalesData&&jsxRuntime.jsxs("div",{className:"border-l pl-2 ml-2 flex flex-col text-sm",children:[jsxRuntime.jsx("strong",{className:"",children:"YTD"}),jsxRuntime.jsx("p",{children:e?.SalesData.SalesYearToDay?formatMoney(e?.SalesData.SalesYearToDay):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"3 mo."}),jsxRuntime.jsx("p",{children:e?.SalesData.SalesLast3Months?formatMoney(e?.SalesData.SalesLast3Months):"—"}),jsxRuntime.jsx("strong",{className:"mt-2",children:"30 days"}),jsxRuntime.jsx("p",{children:e?.SalesData.SalesLast30Days?formatMoney(e?.SalesData.SalesLast30Days):"—"})]})]})}),(s||a)&&jsxRuntime.jsxs(CardFooter,{className:"flex pt-2 gap-2 justify-between mt-auto",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:s&&s}),a&&jsxRuntime.jsx("div",{children:a})]})]})}const Table=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("div",{className:"relative w-full overflow-auto",children:jsxRuntime.jsx("table",{ref:n,className:cn("w-full caption-bottom text-sm",e),...t})}));Table.displayName="Table";const TableHeader=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("thead",{ref:n,className:cn("[&_tr]:border-b",e),...t}));TableHeader.displayName="TableHeader";const TableBody=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tbody",{ref:n,className:cn("[&_tr:last-child]:border-0",e),...t}));TableBody.displayName="TableBody";const TableFooter=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tfoot",{ref:n,className:cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));TableFooter.displayName="TableFooter";const TableRow=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("tr",{ref:n,className:cn("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));TableRow.displayName="TableRow";const TableHead=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("th",{ref:n,className:cn("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t,children:React__namespace.isValidElement(t.children)&&t.children.type==="span"?t.children:jsxRuntime.jsx("span",{children:t.children})}));TableHead.displayName="TableHead";const TableCell=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("td",{ref:n,className:cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t,children:React__namespace.isValidElement(t.children)&&t.children.type==="span"?t.children:jsxRuntime.jsx("span",{children:t.children})}));TableCell.displayName="TableCell";const TableCaption=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx("caption",{ref:n,className:cn("mt-4 text-sm text-muted-foreground",e),...t}));TableCaption.displayName="TableCaption";const APP_SHELL_HEADER_HEIGHT_TOKEN_CLASS="[--rm-shell-header-height:3.5rem]",APP_SHELL_HEADER_HEIGHT_CLASS="h-[var(--rm-shell-header-height)]",APP_SHELL_HEADER_OFFSET_CLASS="pt-[var(--rm-shell-header-height)]",Topbar=React.forwardRef(({onSignOut:e,handleValidSearch:t,rightMenu:n,searchPlaceholder:s},a)=>{const[o,l]=React.useState(""),c=reactRouterDom.useLocation(),{toast:d}=useToast();React.useEffect(()=>{const te=new URLSearchParams(c.search).get("q");te&&l(te)},[c.search]);const f=()=>{const S=o.trim();if(!S||S.length<2){d({title:"Enter more characters to search",description:"At least 2 characters are needed to search products.",variant:"destructive",duration:5e3});return}t(S)},R=S=>{S.key==="Enter"&&f()};return jsxRuntime.jsxs("header",{className:`fixed top-0 right-0 left-0 z-50 flex ${APP_SHELL_HEADER_HEIGHT_TOKEN_CLASS} ${APP_SHELL_HEADER_HEIGHT_CLASS} items-center gap-3 border-b border-border bg-background px-4 text-foreground transition-[left] duration-200 ease-linear lg:px-6 peer-data-[state=expanded]:lg:left-(--sidebar-width) peer-data-[collapsible=offcanvas]:lg:left-0 peer-data-[collapsible=icon]:lg:left-(--sidebar-width-icon)`,children:[jsxRuntime.jsx(SidebarTrigger,{className:"h-10 w-10 text-foreground lg:hidden",children:jsxRuntime.jsx(Menu$1,{className:"h-5 w-5"})}),jsxRuntime.jsx("div",{className:"flex flex-1 items-center gap-4",children:jsxRuntime.jsx("div",{className:"relative w-full max-w-sm",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{type:"button",className:"absolute left-1 top-1/2 inline-flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground",onClick:f,"aria-label":"Search",children:jsxRuntime.jsx(Search,{className:"h-4 w-4 text-muted-foreground"})}),jsxRuntime.jsx(Input,{placeholder:s??"Search...",className:"h-10 w-full bg-background pl-10 text-foreground",value:o,onChange:S=>l(S.target.value),onKeyDown:R,ref:a},"topbar-search")]})})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[n,e&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Button$1,{variant:"ghost",size:"icon",className:"h-10 w-10",onClick:e,children:[jsxRuntime.jsx(LogOut,{className:"h-4 w-4 text-foreground"}),jsxRuntime.jsx("span",{className:"sr-only",children:"Sign out"})]})})]})]})});Topbar.displayName="Topbar";function ActiveOrdersCard({orders:e,loading:t=!1}){const n=React.useMemo(()=>{if(!e||e.length===0)return{all:{orders:0,amount:0},processing:{orders:0,amount:0},shipped:{orders:0,amount:0},delayed:{orders:0,amount:0}};const a=e.filter(it=>it.DocumentType==="Order"),o=e.filter(it=>it.DocumentType==="Shipment"),l=a.filter(it=>it.WarehouseCode!=="3PLE"),c=l.reduce((it,at)=>it+(at.Quantity||0),0),d=l.reduce((it,at)=>it+(at.ExtendedPrice||0),0),f=a.filter(it=>it.WarehouseCode==="3PLE"),R=f.reduce((it,at)=>it+(at.Quantity||0),0),S=f.reduce((it,at)=>it+(at.ExtendedPrice||0),0),te=o.length,A=o.reduce((it,at)=>it+(at.ExtendedPrice||0),0),rt=c+R+te,st=d+S+A;return{all:{orders:rt,amount:st},processing:{orders:c,amount:d},shipped:{orders:te,amount:A},delayed:{orders:R,amount:S}}},[e]),s=[{name:"All",icon:Package,stripeClass:"bg-info/60",iconBgClass:"bg-info/90",iconTextClass:"text-info-foreground",orders:n.all.orders,amount:n.all.amount},{name:"Processing",icon:RefreshCcw,stripeClass:"bg-warning/60",iconBgClass:"bg-warning/90",iconTextClass:"text-warning-foreground",orders:n.processing.orders,amount:n.processing.amount},{name:"Shipped",icon:Truck,stripeClass:"bg-success/60",iconBgClass:"bg-success/90",iconTextClass:"text-success-foreground",orders:n.shipped.orders,amount:n.shipped.amount},{name:"Delayed",icon:CircleAlert,stripeClass:"bg-destructive/60",iconBgClass:"bg-destructive/90",iconTextClass:"text-destructive-foreground",orders:n.delayed.orders,amount:n.delayed.amount}];return t?jsxRuntime.jsxs(Card,{className:"@container",children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:[1,2,3,4].map(a=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:"bg-border h-[3px]"}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"}),jsxRuntime.jsx(Skeleton,{className:"h-8 w-8 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-7 w-12"})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx(Skeleton,{className:"h-3 w-16 mb-2"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]})]})]},a))})]}):jsxRuntime.jsxs(Card,{className:"@container",children:[jsxRuntime.jsx(CardHeader,{className:"pb-0",children:jsxRuntime.jsx(CardTitle,{className:"text-base font-medium text-foreground",children:"Active Orders"})}),jsxRuntime.jsx("div",{className:"grid grid-cols-1 @sm:grid-cols-2 gap-4 p-4",children:s.map(a=>jsxRuntime.jsxs("div",{className:"overflow-hidden rounded-md border",children:[jsxRuntime.jsx("div",{className:`${a.stripeClass} h-[3px]`}),jsxRuntime.jsxs("div",{className:"p-6 border border-t-0",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-center mb-4",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-base",children:a.name}),jsxRuntime.jsx("div",{className:`${a.iconBgClass} p-2 rounded-full`,children:jsxRuntime.jsx(a.icon,{className:`size-4 shrink-0 ${a.iconTextClass}`})})]}),jsxRuntime.jsxs("div",{className:"flex justify-between items-start",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Orders"}),jsxRuntime.jsx("p",{className:"text-xl font-bold",children:a.orders})]}),jsxRuntime.jsxs("div",{className:"text-end",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Amount"}),jsxRuntime.jsx("p",{className:"text-base font-semibold",children:formatMoney(a.amount)})]})]})]})]},a.name))})]})}var CHECKBOX_NAME="Checkbox",[createCheckboxContext]=createContextScope$2(CHECKBOX_NAME),[CheckboxProviderImpl,useCheckboxContext]=createCheckboxContext(CHECKBOX_NAME);function CheckboxProvider(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:a,disabled:o,form:l,name:c,onCheckedChange:d,required:f,value:R="on",internal_do_not_use_render:S}=e,[te,A]=useControllableState({prop:n,defaultProp:a??!1,onChange:d,caller:CHECKBOX_NAME}),[rt,st]=React__namespace.useState(null),[it,at]=React__namespace.useState(null),ot=React__namespace.useRef(!1),lt=rt?!!l||!!rt.closest("form"):!0,ut={checked:te,disabled:o,setChecked:A,control:rt,setControl:st,name:c,form:l,value:R,hasConsumerStoppedPropagationRef:ot,required:f,defaultChecked:isIndeterminate(a)?!1:a,isFormControl:lt,bubbleInput:it,setBubbleInput:at};return jsxRuntime.jsx(CheckboxProviderImpl,{scope:t,...ut,children:isFunction$1(S)?S(ut):s})}var TRIGGER_NAME$4="CheckboxTrigger",CheckboxTrigger=React__namespace.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},a)=>{const{control:o,value:l,disabled:c,checked:d,required:f,setControl:R,setChecked:S,hasConsumerStoppedPropagationRef:te,isFormControl:A,bubbleInput:rt}=useCheckboxContext(TRIGGER_NAME$4,e),st=useComposedRefs(a,R),it=React__namespace.useRef(d);return React__namespace.useEffect(()=>{const at=o?.form;if(at){const ot=()=>S(it.current);return at.addEventListener("reset",ot),()=>at.removeEventListener("reset",ot)}},[o,S]),jsxRuntime.jsx(Primitive$4.button,{type:"button",role:"checkbox","aria-checked":isIndeterminate(d)?"mixed":d,"aria-required":f,"data-state":getState$3(d),"data-disabled":c?"":void 0,disabled:c,value:l,...s,ref:st,onKeyDown:composeEventHandlers(t,at=>{at.key==="Enter"&&at.preventDefault()}),onClick:composeEventHandlers(n,at=>{S(ot=>isIndeterminate(ot)?!0:!ot),rt&&A&&(te.current=at.isPropagationStopped(),te.current||at.stopPropagation())})})});CheckboxTrigger.displayName=TRIGGER_NAME$4;var Checkbox$1=React__namespace.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:a,defaultChecked:o,required:l,disabled:c,value:d,onCheckedChange:f,form:R,...S}=e;return jsxRuntime.jsx(CheckboxProvider,{__scopeCheckbox:n,checked:a,defaultChecked:o,disabled:c,required:l,onCheckedChange:f,name:s,form:R,value:d,internal_do_not_use_render:({isFormControl:te})=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(CheckboxTrigger,{...S,ref:t,__scopeCheckbox:n}),te&&jsxRuntime.jsx(CheckboxBubbleInput,{__scopeCheckbox:n})]})})});Checkbox$1.displayName=CHECKBOX_NAME;var INDICATOR_NAME="CheckboxIndicator",CheckboxIndicator=React__namespace.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...a}=e,o=useCheckboxContext(INDICATOR_NAME,n);return jsxRuntime.jsx(Presence,{present:s||isIndeterminate(o.checked)||o.checked===!0,children:jsxRuntime.jsx(Primitive$4.span,{"data-state":getState$3(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});CheckboxIndicator.displayName=INDICATOR_NAME;var BUBBLE_INPUT_NAME="CheckboxBubbleInput",CheckboxBubbleInput=React__namespace.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:c,disabled:d,name:f,value:R,form:S,bubbleInput:te,setBubbleInput:A}=useCheckboxContext(BUBBLE_INPUT_NAME,e),rt=useComposedRefs(n,A),st=usePrevious(o),it=useSize(s);React__namespace.useEffect(()=>{const ot=te;if(!ot)return;const lt=window.HTMLInputElement.prototype,ct=Object.getOwnPropertyDescriptor(lt,"checked").set,dt=!a.current;if(st!==o&&ct){const pt=new Event("click",{bubbles:dt});ot.indeterminate=isIndeterminate(o),ct.call(ot,isIndeterminate(o)?!1:o),ot.dispatchEvent(pt)}},[te,st,o,a]);const at=React__namespace.useRef(isIndeterminate(o)?!1:o);return jsxRuntime.jsx(Primitive$4.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??at.current,required:c,disabled:d,name:f,value:R,form:S,...t,tabIndex:-1,ref:rt,style:{...t.style,...it,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});CheckboxBubbleInput.displayName=BUBBLE_INPUT_NAME;function isFunction$1(e){return typeof e=="function"}function isIndeterminate(e){return e==="indeterminate"}function getState$3(e){return isIndeterminate(e)?"indeterminate":e?"checked":"unchecked"}const Checkbox=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Checkbox$1,{ref:n,className:cn("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:jsxRuntime.jsx(CheckboxIndicator,{className:cn("flex items-center justify-center text-current"),children:jsxRuntime.jsx(Check,{className:"h-4 w-4"})})}));Checkbox.displayName=Checkbox$1.displayName;function CheckboxCardList({items:e,selectedIds:t,onSelectedIdsChange:n,disabled:s=!1,loading:a=!1,selectionMode:o="multiple",layout:l="stack",gridColumns:c=2,emptyState:d,loadingState:f,getItemAriaLabel:R,renderItem:S,className:te,...A}){const rt=React__namespace.useId(),st=React__namespace.useMemo(()=>new Set(t),[t]),it=l==="grid"?cn("grid gap-3",c===2&&"grid-cols-1 sm:grid-cols-2"):"space-y-3",at=React__namespace.useCallback(ot=>{if(s||a||ot.disabled)return;const lt=st.has(ot.id);if(o==="single"){n(lt?[]:[ot.id]);return}if(lt){n(t.filter(ut=>ut!==ot.id));return}n([...t,ot.id])},[s,a,n,st,t,o]);return a?jsxRuntime.jsx("div",{className:cn(it,te),role:"status","aria-live":"polite",...A,children:f??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Loading options"}),Array.from({length:l==="grid"?4:3}).map((ot,lt)=>jsxRuntime.jsxs("div",{className:"rounded-xl border border-border bg-card p-4 shadow-sm","aria-hidden":"true",children:[jsxRuntime.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-muted"}),jsxRuntime.jsx("div",{className:"mt-2 h-3 w-1/2 animate-pulse rounded bg-muted"})]},`loading-${lt}`))]})}):e.length===0?jsxRuntime.jsx("div",{className:cn(it,te),...A,children:d??jsxRuntime.jsx("div",{className:"rounded-xl border border-dashed border-border bg-muted/30 p-4 text-sm text-muted-foreground",children:"No options are available."})}):jsxRuntime.jsx("div",{className:cn(it,te),role:"group","aria-disabled":s||void 0,...A,children:e.map((ot,lt)=>{const ut=st.has(ot.id),ct=s||ot.disabled===!0,dt=`${rt}-${lt}-label`,pt=`${rt}-${lt}-description`;return jsxRuntime.jsxs("button",{type:"button",role:"checkbox","aria-checked":ut,"aria-disabled":ct,"aria-label":R?.(ot)??ot.label,"aria-labelledby":S?void 0:dt,"aria-describedby":!S&&ot.description?pt:void 0,disabled:ct,onClick:()=>at(ot),className:cn("flex w-full items-start gap-3 rounded-xl border bg-card p-4 text-left shadow-sm transition-colors transition-shadow","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","hover:bg-muted/30 hover:shadow",ut?"border-primary bg-primary/5 ring-2 ring-primary/20":"border-border",ct&&"cursor-not-allowed opacity-60 hover:bg-card hover:shadow-sm"),children:[jsxRuntime.jsx("span",{"aria-hidden":"true",className:cn("mt-0.5 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-primary shadow-sm",ut?"bg-primary text-primary-foreground":"bg-background text-transparent"),children:jsxRuntime.jsx(Check,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"sr-only",children:ot.label}),S(ot,{checked:ut,disabled:ct,index:lt})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(ot.prefix||ot.emphasis)&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-baseline gap-1 text-xs",children:[ot.prefix&&jsxRuntime.jsx("span",{className:"font-semibold uppercase tracking-wide text-muted-foreground",children:ot.prefix}),ot.emphasis&&jsxRuntime.jsx("span",{className:"font-semibold text-foreground",children:ot.emphasis})]}),jsxRuntime.jsx("span",{id:dt,className:cn("block text-sm font-medium text-foreground",(ot.prefix||ot.emphasis)&&"mt-1"),children:ot.label}),ot.description&&jsxRuntime.jsx("span",{id:pt,className:"mt-1 block text-sm text-muted-foreground",children:ot.description})]})})]},ot.id)})})}var U=1,Y$1=.9,H=.8,J=.17,p=.1,u=.999,$=.9999,k$1=.99,m=/[\\\/_+.#"@\[\(\{&]/,B$1=/[\\\/_+.#"@\[\(\{&]/g,K$1=/[\s-]/,X=/[\s-]/g;function G(e,t,n,s,a,o,l){if(o===t.length)return a===e.length?U:k$1;var c=`${a},${o}`;if(l[c]!==void 0)return l[c];for(var d=s.charAt(o),f=n.indexOf(d,a),R=0,S,te,A,rt;f>=0;)S=G(e,t,n,s,f+1,o+1,l),S>R&&(f===a?S*=U:m.test(e.charAt(f-1))?(S*=H,A=e.slice(a,f-1).match(B$1),A&&a>0&&(S*=Math.pow(u,A.length))):K$1.test(e.charAt(f-1))?(S*=Y$1,rt=e.slice(a,f-1).match(X),rt&&a>0&&(S*=Math.pow(u,rt.length))):(S*=J,a>0&&(S*=Math.pow(u,f-a))),e.charAt(f)!==t.charAt(o)&&(S*=$)),(S<p&&n.charAt(f-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&n.charAt(f-1)!==s.charAt(o))&&(te=G(e,t,n,s,f+1,o+2,l),te*p>S&&(S=te*p)),S>R&&(R=S),f=n.indexOf(d,f+1);return l[c]=R,R}function D(e){return e.toLowerCase().replace(X," ")}function W(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,G(e,t,D(e),D(t),0,0,{})}var N='[cmdk-group=""]',Y='[cmdk-group-items=""]',be='[cmdk-group-heading=""]',le='[cmdk-item=""]',ce=`${le}:not([aria-disabled="true"])`,Z="cmdk-item-select",T="data-value",Re=(e,t,n)=>W(e,t,n),ue=React__namespace.createContext(void 0),K=()=>React__namespace.useContext(ue),de=React__namespace.createContext(void 0),ee=()=>React__namespace.useContext(de),fe=React__namespace.createContext(void 0),me=React__namespace.forwardRef((e,t)=>{let n=L(()=>{var Qt,sr;return{search:"",value:(sr=(Qt=e.value)!=null?Qt:e.defaultValue)!=null?sr:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=L(()=>new Set),a=L(()=>new Map),o=L(()=>new Map),l=L(()=>new Set),c=pe(e),{label:d,children:f,value:R,onValueChange:S,filter:te,shouldFilter:A,loop:rt,disablePointerSelection:st=!1,vimBindings:it=!0,...at}=e,ot=useId$1(),lt=useId$1(),ut=useId$1(),ct=React__namespace.useRef(null),dt=ke();k(()=>{if(R!==void 0){let Qt=R.trim();n.current.value=Qt,pt.emit()}},[R]),k(()=>{dt(6,Ct)},[]);let pt=React__namespace.useMemo(()=>({subscribe:Qt=>(l.current.add(Qt),()=>l.current.delete(Qt)),snapshot:()=>n.current,setState:(Qt,sr,lr)=>{var Zt,cr,qt,nr;if(!Object.is(n.current[Qt],sr)){if(n.current[Qt]=sr,Qt==="search")ft(),yt(),dt(1,It);else if(Qt==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Kt=document.getElementById(ut);Kt?Kt.focus():(Zt=document.getElementById(ot))==null||Zt.focus()}if(dt(7,()=>{var Kt;n.current.selectedItemId=(Kt=Mt())==null?void 0:Kt.id,pt.emit()}),lr||dt(5,Ct),((cr=c.current)==null?void 0:cr.value)!==void 0){let Kt=sr??"";(nr=(qt=c.current).onValueChange)==null||nr.call(qt,Kt);return}}pt.emit()}},emit:()=>{l.current.forEach(Qt=>Qt())}}),[]),mt=React__namespace.useMemo(()=>({value:(Qt,sr,lr)=>{var Zt;sr!==((Zt=o.current.get(Qt))==null?void 0:Zt.value)&&(o.current.set(Qt,{value:sr,keywords:lr}),n.current.filtered.items.set(Qt,Rt(sr,lr)),dt(2,()=>{yt(),pt.emit()}))},item:(Qt,sr)=>(s.current.add(Qt),sr&&(a.current.has(sr)?a.current.get(sr).add(Qt):a.current.set(sr,new Set([Qt]))),dt(3,()=>{ft(),yt(),n.current.value||It(),pt.emit()}),()=>{o.current.delete(Qt),s.current.delete(Qt),n.current.filtered.items.delete(Qt);let lr=Mt();dt(4,()=>{ft(),lr?.getAttribute("id")===Qt&&It(),pt.emit()})}),group:Qt=>(a.current.has(Qt)||a.current.set(Qt,new Set),()=>{o.current.delete(Qt),a.current.delete(Qt)}),filter:()=>c.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:ot,inputId:ut,labelId:lt,listInnerRef:ct}),[]);function Rt(Qt,sr){var lr,Zt;let cr=(Zt=(lr=c.current)==null?void 0:lr.filter)!=null?Zt:Re;return Qt?cr(Qt,n.current.search,sr):0}function yt(){if(!n.current.search||c.current.shouldFilter===!1)return;let Qt=n.current.filtered.items,sr=[];n.current.filtered.groups.forEach(Zt=>{let cr=a.current.get(Zt),qt=0;cr.forEach(nr=>{let Kt=Qt.get(nr);qt=Math.max(Kt,qt)}),sr.push([Zt,qt])});let lr=ct.current;Dt().sort((Zt,cr)=>{var qt,nr;let Kt=Zt.getAttribute("id"),Xt=cr.getAttribute("id");return((qt=Qt.get(Xt))!=null?qt:0)-((nr=Qt.get(Kt))!=null?nr:0)}).forEach(Zt=>{let cr=Zt.closest(Y);cr?cr.appendChild(Zt.parentElement===cr?Zt:Zt.closest(`${Y} > *`)):lr.appendChild(Zt.parentElement===lr?Zt:Zt.closest(`${Y} > *`))}),sr.sort((Zt,cr)=>cr[1]-Zt[1]).forEach(Zt=>{var cr;let qt=(cr=ct.current)==null?void 0:cr.querySelector(`${N}[${T}="${encodeURIComponent(Zt[0])}"]`);qt?.parentElement.appendChild(qt)})}function It(){let Qt=Dt().find(lr=>lr.getAttribute("aria-disabled")!=="true"),sr=Qt?.getAttribute(T);pt.setState("value",sr||void 0)}function ft(){var Qt,sr,lr,Zt;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=s.current.size;return}n.current.filtered.groups=new Set;let cr=0;for(let qt of s.current){let nr=(sr=(Qt=o.current.get(qt))==null?void 0:Qt.value)!=null?sr:"",Kt=(Zt=(lr=o.current.get(qt))==null?void 0:lr.keywords)!=null?Zt:[],Xt=Rt(nr,Kt);n.current.filtered.items.set(qt,Xt),Xt>0&&cr++}for(let[qt,nr]of a.current)for(let Kt of nr)if(n.current.filtered.items.get(Kt)>0){n.current.filtered.groups.add(qt);break}n.current.filtered.count=cr}function Ct(){var Qt,sr,lr;let Zt=Mt();Zt&&(((Qt=Zt.parentElement)==null?void 0:Qt.firstChild)===Zt&&((lr=(sr=Zt.closest(N))==null?void 0:sr.querySelector(be))==null||lr.scrollIntoView({block:"nearest"})),Zt.scrollIntoView({block:"nearest"}))}function Mt(){var Qt;return(Qt=ct.current)==null?void 0:Qt.querySelector(`${le}[aria-selected="true"]`)}function Dt(){var Qt;return Array.from(((Qt=ct.current)==null?void 0:Qt.querySelectorAll(ce))||[])}function Vt(Qt){let sr=Dt()[Qt];sr&&pt.setState("value",sr.getAttribute(T))}function Ht(Qt){var sr;let lr=Mt(),Zt=Dt(),cr=Zt.findIndex(nr=>nr===lr),qt=Zt[cr+Qt];(sr=c.current)!=null&&sr.loop&&(qt=cr+Qt<0?Zt[Zt.length-1]:cr+Qt===Zt.length?Zt[0]:Zt[cr+Qt]),qt&&pt.setState("value",qt.getAttribute(T))}function $t(Qt){let sr=Mt(),lr=sr?.closest(N),Zt;for(;lr&&!Zt;)lr=Qt>0?we(lr,N):De(lr,N),Zt=lr?.querySelector(ce);Zt?pt.setState("value",Zt.getAttribute(T)):Ht(Qt)}let Ft=()=>Vt(Dt().length-1),zt=Qt=>{Qt.preventDefault(),Qt.metaKey?Ft():Qt.altKey?$t(1):Ht(1)},Jt=Qt=>{Qt.preventDefault(),Qt.metaKey?Vt(0):Qt.altKey?$t(-1):Ht(-1)};return React__namespace.createElement(Primitive$4.div,{ref:t,tabIndex:-1,...at,"cmdk-root":"",onKeyDown:Qt=>{var sr;(sr=at.onKeyDown)==null||sr.call(at,Qt);let lr=Qt.nativeEvent.isComposing||Qt.keyCode===229;if(!(Qt.defaultPrevented||lr))switch(Qt.key){case"n":case"j":{it&&Qt.ctrlKey&&zt(Qt);break}case"ArrowDown":{zt(Qt);break}case"p":case"k":{it&&Qt.ctrlKey&&Jt(Qt);break}case"ArrowUp":{Jt(Qt);break}case"Home":{Qt.preventDefault(),Vt(0);break}case"End":{Qt.preventDefault(),Ft();break}case"Enter":{Qt.preventDefault();let Zt=Mt();if(Zt){let cr=new Event(Z);Zt.dispatchEvent(cr)}}}}},React__namespace.createElement("label",{"cmdk-label":"",htmlFor:mt.inputId,id:mt.labelId,style:Te},d),B(e,Qt=>React__namespace.createElement(de.Provider,{value:pt},React__namespace.createElement(ue.Provider,{value:mt},Qt))))}),he=React__namespace.forwardRef((e,t)=>{var n,s;let a=useId$1(),o=React__namespace.useRef(null),l=React__namespace.useContext(fe),c=K(),d=pe(e),f=(s=(n=d.current)==null?void 0:n.forceMount)!=null?s:l?.forceMount;k(()=>{if(!f)return c.item(a,l?.id)},[f]);let R=ve(a,o,[e.value,e.children,o],e.keywords),S=ee(),te=P(dt=>dt.value&&dt.value===R.current),A=P(dt=>f||c.filter()===!1?!0:dt.search?dt.filtered.items.get(a)>0:!0);React__namespace.useEffect(()=>{let dt=o.current;if(!(!dt||e.disabled))return dt.addEventListener(Z,rt),()=>dt.removeEventListener(Z,rt)},[A,e.onSelect,e.disabled]);function rt(){var dt,pt;st(),(pt=(dt=d.current).onSelect)==null||pt.call(dt,R.current)}function st(){S.setState("value",R.current,!0)}if(!A)return null;let{disabled:it,value:at,onSelect:ot,forceMount:lt,keywords:ut,...ct}=e;return React__namespace.createElement(Primitive$4.div,{ref:composeRefs(o,t),...ct,id:a,"cmdk-item":"",role:"option","aria-disabled":!!it,"aria-selected":!!te,"data-disabled":!!it,"data-selected":!!te,onPointerMove:it||c.getDisablePointerSelection()?void 0:st,onClick:it?void 0:rt},e.children)}),Ee=React__namespace.forwardRef((e,t)=>{let{heading:n,children:s,forceMount:a,...o}=e,l=useId$1(),c=React__namespace.useRef(null),d=React__namespace.useRef(null),f=useId$1(),R=K(),S=P(A=>a||R.filter()===!1?!0:A.search?A.filtered.groups.has(l):!0);k(()=>R.group(l),[]),ve(l,c,[e.value,e.heading,d]);let te=React__namespace.useMemo(()=>({id:l,forceMount:a}),[a]);return React__namespace.createElement(Primitive$4.div,{ref:composeRefs(c,t),...o,"cmdk-group":"",role:"presentation",hidden:S?void 0:!0},n&&React__namespace.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),B(e,A=>React__namespace.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},React__namespace.createElement(fe.Provider,{value:te},A))))}),ye=React__namespace.forwardRef((e,t)=>{let{alwaysRender:n,...s}=e,a=React__namespace.useRef(null),o=P(l=>!l.search);return!n&&!o?null:React__namespace.createElement(Primitive$4.div,{ref:composeRefs(a,t),...s,"cmdk-separator":"",role:"separator"})}),Se=React__namespace.forwardRef((e,t)=>{let{onValueChange:n,...s}=e,a=e.value!=null,o=ee(),l=P(f=>f.search),c=P(f=>f.selectedItemId),d=K();return React__namespace.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),React__namespace.createElement(Primitive$4.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":c,id:d.inputId,type:"text",value:a?e.value:l,onChange:f=>{a||o.setState("search",f.target.value),n?.(f.target.value)}})}),Ce=React__namespace.forwardRef((e,t)=>{let{children:n,label:s="Suggestions",...a}=e,o=React__namespace.useRef(null),l=React__namespace.useRef(null),c=P(f=>f.selectedItemId),d=K();return React__namespace.useEffect(()=>{if(l.current&&o.current){let f=l.current,R=o.current,S,te=new ResizeObserver(()=>{S=requestAnimationFrame(()=>{let A=f.offsetHeight;R.style.setProperty("--cmdk-list-height",A.toFixed(1)+"px")})});return te.observe(f),()=>{cancelAnimationFrame(S),te.unobserve(f)}}},[]),React__namespace.createElement(Primitive$4.div,{ref:composeRefs(o,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":s,id:d.listId},B(e,f=>React__namespace.createElement("div",{ref:composeRefs(l,d.listInnerRef),"cmdk-list-sizer":""},f)))}),xe=React__namespace.forwardRef((e,t)=>{let{open:n,onOpenChange:s,overlayClassName:a,contentClassName:o,container:l,...c}=e;return React__namespace.createElement(Root$a,{open:n,onOpenChange:s},React__namespace.createElement(Portal$4,{container:l},React__namespace.createElement(Overlay,{"cmdk-overlay":"",className:a}),React__namespace.createElement(Content$3,{"aria-label":e.label,"cmdk-dialog":"",className:o},React__namespace.createElement(me,{ref:t,...c}))))}),Ie=React__namespace.forwardRef((e,t)=>P(n=>n.filtered.count===0)?React__namespace.createElement(Primitive$4.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Pe=React__namespace.forwardRef((e,t)=>{let{progress:n,children:s,label:a="Loading...",...o}=e;return React__namespace.createElement(Primitive$4.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},B(e,l=>React__namespace.createElement("div",{"aria-hidden":!0},l)))}),_e=Object.assign(me,{List:Ce,Item:he,Input:Se,Group:Ee,Separator:ye,Dialog:xe,Empty:Ie,Loading:Pe});function we(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function De(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function pe(e){let t=React__namespace.useRef(e);return k(()=>{t.current=e}),t}var k=typeof window>"u"?React__namespace.useEffect:React__namespace.useLayoutEffect;function L(e){let t=React__namespace.useRef();return t.current===void 0&&(t.current=e()),t}function P(e){let t=ee(),n=()=>e(t.snapshot());return React__namespace.useSyncExternalStore(t.subscribe,n,n)}function ve(e,t,n,s=[]){let a=React__namespace.useRef(),o=K();return k(()=>{var l;let c=(()=>{var f;for(let R of n){if(typeof R=="string")return R.trim();if(typeof R=="object"&&"current"in R)return R.current?(f=R.current.textContent)==null?void 0:f.trim():a.current}})(),d=s.map(f=>f.trim());o.value(e,c,d),(l=t.current)==null||l.setAttribute(T,c),a.current=c}),a}var ke=()=>{let[e,t]=React__namespace.useState(),n=L(()=>new Map);return k(()=>{n.current.forEach(s=>s()),n.current=new Map},[e]),(s,a)=>{n.current.set(s,a),t({})}};function Me(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function B({asChild:e,children:t},n){return e&&React__namespace.isValidElement(t)?React__namespace.cloneElement(Me(t),{ref:t.ref},n(t.props.children)):n(t)}var Te={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Command=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e,{ref:n,className:cn("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Command.displayName=_e.displayName;const CommandDialog=({children:e,...t})=>jsxRuntime.jsx(Dialog,{...t,children:jsxRuntime.jsx(DialogContent,{className:"overflow-hidden p-0",children:jsxRuntime.jsx(Command,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})})}),CommandInput=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[jsxRuntime.jsx(Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),jsxRuntime.jsx(_e.Input,{ref:n,className:cn("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));CommandInput.displayName=_e.Input.displayName;const CommandList=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.List,{ref:n,className:cn("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));CommandList.displayName=_e.List.displayName;const CommandEmpty=React__namespace.forwardRef((e,t)=>jsxRuntime.jsx(_e.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));CommandEmpty.displayName=_e.Empty.displayName;const CommandGroup=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Group,{ref:n,className:cn("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));CommandGroup.displayName=_e.Group.displayName;const CommandSeparator=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Separator,{ref:n,className:cn("-mx-1 h-px bg-border",e),...t}));CommandSeparator.displayName=_e.Separator.displayName;const CommandItem=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(_e.Item,{ref:n,className:cn("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));CommandItem.displayName=_e.Item.displayName;const CommandShortcut=({className:e,...t})=>jsxRuntime.jsx("span",{className:cn("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});CommandShortcut.displayName="CommandShortcut";const CountryFlag=({countryCode:e,className:t=""})=>{const[n,s]=React.useState(!1),a=e.trim().toUpperCase();React.useEffect(()=>{s(!1)},[a]);const o=React.useMemo(()=>a?`https://purecatamphetamine.github.io/country-flag-icons/3x2/${encodeURIComponent(a)}.svg`:"",[a]);return!a||n?jsxRuntime.jsx("span",{className:t,children:e}):jsxRuntime.jsx("img",{src:o,alt:`${a} flag`,className:`inline-block h-auto w-6 ${t}`,loading:"lazy",onError:()=>s(!0)})};function GeneralDocumentCard({document:e,loading:t=!1}){return t?jsxRuntime.jsx("div",{children:"loading..."}):jsxRuntime.jsxs("div",{children:["GENERAL DOCUMENT CARD - ",e?.OrderNumber," for P.O. ",e?.PONumber]})}function ApiImage({path:e,origin:t,...n}){const s=useApiOrigin(),a=React__namespace.useMemo(()=>buildApiUrl(e,t??s),[s,t,e]);return jsxRuntime.jsx("img",{...n,src:a})}var md5={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$1=getAugmentedNamespace(__viteBrowserExternal$1);var hasRequiredMd5;function requireMd5(){return hasRequiredMd5||(hasRequiredMd5=1,(function(e){(function(){var t="input is invalid type",n="finalize already called",s=typeof window=="object",a=s?window:{};a.JS_MD5_NO_WINDOW&&(s=!1);var o=!s&&typeof self=="object",l=!a.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;l?a=commonjsGlobal:o&&(a=self);var c=!a.JS_MD5_NO_COMMON_JS&&!0&&e.exports,d=!a.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),R=[128,32768,8388608,-2147483648],S=[0,8,16,24],te=["hex","array","digest","buffer","arrayBuffer","base64"],A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),rt=[],st;if(d){var it=new ArrayBuffer(68);st=new Uint8Array(it),rt=new Uint32Array(it)}var at=Array.isArray;(a.JS_MD5_NO_NODE_JS||!at)&&(at=function(ft){return Object.prototype.toString.call(ft)==="[object Array]"});var ot=ArrayBuffer.isView;d&&(a.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW||!ot)&&(ot=function(ft){return typeof ft=="object"&&ft.buffer&&ft.buffer.constructor===ArrayBuffer});var lt=function(ft){var Ct=typeof ft;if(Ct==="string")return[ft,!0];if(Ct!=="object"||ft===null)throw new Error(t);if(d&&ft.constructor===ArrayBuffer)return[new Uint8Array(ft),!1];if(!at(ft)&&!ot(ft))throw new Error(t);return[ft,!1]},ut=function(ft){return function(Ct){return new Rt(!0).update(Ct)[ft]()}},ct=function(){var ft=ut("hex");l&&(ft=dt(ft)),ft.create=function(){return new Rt},ft.update=function(Dt){return ft.create().update(Dt)};for(var Ct=0;Ct<te.length;++Ct){var Mt=te[Ct];ft[Mt]=ut(Mt)}return ft},dt=function(ft){var Ct=require$$1,Mt=require$$1.Buffer,Dt;Mt.from&&!a.JS_MD5_NO_BUFFER_FROM?Dt=Mt.from:Dt=function(Ht){return new Mt(Ht)};var Vt=function(Ht){if(typeof Ht=="string")return Ct.createHash("md5").update(Ht,"utf8").digest("hex");if(Ht==null)throw new Error(t);return Ht.constructor===ArrayBuffer&&(Ht=new Uint8Array(Ht)),at(Ht)||ot(Ht)||Ht.constructor===Mt?Ct.createHash("md5").update(Dt(Ht)).digest("hex"):ft(Ht)};return Vt},pt=function(ft){return function(Ct,Mt){return new yt(Ct,!0).update(Mt)[ft]()}},mt=function(){var ft=pt("hex");ft.create=function(Dt){return new yt(Dt)},ft.update=function(Dt,Vt){return ft.create(Dt).update(Vt)};for(var Ct=0;Ct<te.length;++Ct){var Mt=te[Ct];ft[Mt]=pt(Mt)}return ft};function Rt(ft){if(ft)rt[0]=rt[16]=rt[1]=rt[2]=rt[3]=rt[4]=rt[5]=rt[6]=rt[7]=rt[8]=rt[9]=rt[10]=rt[11]=rt[12]=rt[13]=rt[14]=rt[15]=0,this.blocks=rt,this.buffer8=st;else if(d){var Ct=new ArrayBuffer(68);this.buffer8=new Uint8Array(Ct),this.blocks=new Uint32Array(Ct)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}Rt.prototype.update=function(ft){if(this.finalized)throw new Error(n);var Ct=lt(ft);ft=Ct[0];for(var Mt=Ct[1],Dt,Vt=0,Ht,$t=ft.length,Ft=this.blocks,zt=this.buffer8;Vt<$t;){if(this.hashed&&(this.hashed=!1,Ft[0]=Ft[16],Ft[16]=Ft[1]=Ft[2]=Ft[3]=Ft[4]=Ft[5]=Ft[6]=Ft[7]=Ft[8]=Ft[9]=Ft[10]=Ft[11]=Ft[12]=Ft[13]=Ft[14]=Ft[15]=0),Mt)if(d)for(Ht=this.start;Vt<$t&&Ht<64;++Vt)Dt=ft.charCodeAt(Vt),Dt<128?zt[Ht++]=Dt:Dt<2048?(zt[Ht++]=192|Dt>>>6,zt[Ht++]=128|Dt&63):Dt<55296||Dt>=57344?(zt[Ht++]=224|Dt>>>12,zt[Ht++]=128|Dt>>>6&63,zt[Ht++]=128|Dt&63):(Dt=65536+((Dt&1023)<<10|ft.charCodeAt(++Vt)&1023),zt[Ht++]=240|Dt>>>18,zt[Ht++]=128|Dt>>>12&63,zt[Ht++]=128|Dt>>>6&63,zt[Ht++]=128|Dt&63);else for(Ht=this.start;Vt<$t&&Ht<64;++Vt)Dt=ft.charCodeAt(Vt),Dt<128?Ft[Ht>>>2]|=Dt<<S[Ht++&3]:Dt<2048?(Ft[Ht>>>2]|=(192|Dt>>>6)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt&63)<<S[Ht++&3]):Dt<55296||Dt>=57344?(Ft[Ht>>>2]|=(224|Dt>>>12)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt>>>6&63)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt&63)<<S[Ht++&3]):(Dt=65536+((Dt&1023)<<10|ft.charCodeAt(++Vt)&1023),Ft[Ht>>>2]|=(240|Dt>>>18)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt>>>12&63)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt>>>6&63)<<S[Ht++&3],Ft[Ht>>>2]|=(128|Dt&63)<<S[Ht++&3]);else if(d)for(Ht=this.start;Vt<$t&&Ht<64;++Vt)zt[Ht++]=ft[Vt];else for(Ht=this.start;Vt<$t&&Ht<64;++Vt)Ft[Ht>>>2]|=ft[Vt]<<S[Ht++&3];this.lastByteIndex=Ht,this.bytes+=Ht-this.start,Ht>=64?(this.start=Ht-64,this.hash(),this.hashed=!0):this.start=Ht}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},Rt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var ft=this.blocks,Ct=this.lastByteIndex;ft[Ct>>>2]|=R[Ct&3],Ct>=56&&(this.hashed||this.hash(),ft[0]=ft[16],ft[16]=ft[1]=ft[2]=ft[3]=ft[4]=ft[5]=ft[6]=ft[7]=ft[8]=ft[9]=ft[10]=ft[11]=ft[12]=ft[13]=ft[14]=ft[15]=0),ft[14]=this.bytes<<3,ft[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},Rt.prototype.hash=function(){var ft,Ct,Mt,Dt,Vt,Ht,$t=this.blocks;this.first?(ft=$t[0]-680876937,ft=(ft<<7|ft>>>25)-271733879<<0,Dt=(-1732584194^ft&2004318071)+$t[1]-117830708,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt=(-271733879^Dt&(ft^-271733879))+$t[2]-1126478375,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct=(ft^Mt&(Dt^ft))+$t[3]-1316259209,Ct=(Ct<<22|Ct>>>10)+Mt<<0):(ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3,ft+=(Dt^Ct&(Mt^Dt))+$t[0]-680876936,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[1]-389564586,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[2]+606105819,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[3]-1044525330,Ct=(Ct<<22|Ct>>>10)+Mt<<0),ft+=(Dt^Ct&(Mt^Dt))+$t[4]-176418897,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[5]+1200080426,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[6]-1473231341,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[7]-45705983,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Dt^Ct&(Mt^Dt))+$t[8]+1770035416,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[9]-1958414417,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[10]-42063,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[11]-1990404162,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Dt^Ct&(Mt^Dt))+$t[12]+1804603682,ft=(ft<<7|ft>>>25)+Ct<<0,Dt+=(Mt^ft&(Ct^Mt))+$t[13]-40341101,Dt=(Dt<<12|Dt>>>20)+ft<<0,Mt+=(Ct^Dt&(ft^Ct))+$t[14]-1502002290,Mt=(Mt<<17|Mt>>>15)+Dt<<0,Ct+=(ft^Mt&(Dt^ft))+$t[15]+1236535329,Ct=(Ct<<22|Ct>>>10)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[1]-165796510,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[6]-1069501632,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[11]+643717713,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[0]-373897302,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[5]-701558691,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[10]+38016083,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[15]-660478335,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[4]-405537848,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[9]+568446438,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[14]-1019803690,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[3]-187363961,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[8]+1163531501,Ct=(Ct<<20|Ct>>>12)+Mt<<0,ft+=(Mt^Dt&(Ct^Mt))+$t[13]-1444681467,ft=(ft<<5|ft>>>27)+Ct<<0,Dt+=(Ct^Mt&(ft^Ct))+$t[2]-51403784,Dt=(Dt<<9|Dt>>>23)+ft<<0,Mt+=(ft^Ct&(Dt^ft))+$t[7]+1735328473,Mt=(Mt<<14|Mt>>>18)+Dt<<0,Ct+=(Dt^ft&(Mt^Dt))+$t[12]-1926607734,Ct=(Ct<<20|Ct>>>12)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[5]-378558,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[8]-2022574463,Dt=(Dt<<11|Dt>>>21)+ft<<0,Ht=Dt^ft,Mt+=(Ht^Ct)+$t[11]+1839030562,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Ht^Mt)+$t[14]-35309556,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[1]-1530992060,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[4]+1272893353,Dt=(Dt<<11|Dt>>>21)+ft<<0,Ht=Dt^ft,Mt+=(Ht^Ct)+$t[7]-155497632,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Ht^Mt)+$t[10]-1094730640,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[13]+681279174,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[0]-358537222,Dt=(Dt<<11|Dt>>>21)+ft<<0,Ht=Dt^ft,Mt+=(Ht^Ct)+$t[3]-722521979,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Ht^Mt)+$t[6]+76029189,Ct=(Ct<<23|Ct>>>9)+Mt<<0,Vt=Ct^Mt,ft+=(Vt^Dt)+$t[9]-640364487,ft=(ft<<4|ft>>>28)+Ct<<0,Dt+=(Vt^ft)+$t[12]-421815835,Dt=(Dt<<11|Dt>>>21)+ft<<0,Ht=Dt^ft,Mt+=(Ht^Ct)+$t[15]+530742520,Mt=(Mt<<16|Mt>>>16)+Dt<<0,Ct+=(Ht^Mt)+$t[2]-995338651,Ct=(Ct<<23|Ct>>>9)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[0]-198630844,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[7]+1126891415,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[14]-1416354905,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[5]-57434055,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[12]+1700485571,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[3]-1894986606,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[10]-1051523,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[1]-2054922799,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[8]+1873313359,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[15]-30611744,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[6]-1560198380,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[13]+1309151649,Ct=(Ct<<21|Ct>>>11)+Mt<<0,ft+=(Mt^(Ct|~Dt))+$t[4]-145523070,ft=(ft<<6|ft>>>26)+Ct<<0,Dt+=(Ct^(ft|~Mt))+$t[11]-1120210379,Dt=(Dt<<10|Dt>>>22)+ft<<0,Mt+=(ft^(Dt|~Ct))+$t[2]+718787259,Mt=(Mt<<15|Mt>>>17)+Dt<<0,Ct+=(Dt^(Mt|~ft))+$t[9]-343485551,Ct=(Ct<<21|Ct>>>11)+Mt<<0,this.first?(this.h0=ft+1732584193<<0,this.h1=Ct-271733879<<0,this.h2=Mt-1732584194<<0,this.h3=Dt+271733878<<0,this.first=!1):(this.h0=this.h0+ft<<0,this.h1=this.h1+Ct<<0,this.h2=this.h2+Mt<<0,this.h3=this.h3+Dt<<0)},Rt.prototype.hex=function(){this.finalize();var ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3;return f[ft>>>4&15]+f[ft&15]+f[ft>>>12&15]+f[ft>>>8&15]+f[ft>>>20&15]+f[ft>>>16&15]+f[ft>>>28&15]+f[ft>>>24&15]+f[Ct>>>4&15]+f[Ct&15]+f[Ct>>>12&15]+f[Ct>>>8&15]+f[Ct>>>20&15]+f[Ct>>>16&15]+f[Ct>>>28&15]+f[Ct>>>24&15]+f[Mt>>>4&15]+f[Mt&15]+f[Mt>>>12&15]+f[Mt>>>8&15]+f[Mt>>>20&15]+f[Mt>>>16&15]+f[Mt>>>28&15]+f[Mt>>>24&15]+f[Dt>>>4&15]+f[Dt&15]+f[Dt>>>12&15]+f[Dt>>>8&15]+f[Dt>>>20&15]+f[Dt>>>16&15]+f[Dt>>>28&15]+f[Dt>>>24&15]},Rt.prototype.toString=Rt.prototype.hex,Rt.prototype.digest=function(){this.finalize();var ft=this.h0,Ct=this.h1,Mt=this.h2,Dt=this.h3;return[ft&255,ft>>>8&255,ft>>>16&255,ft>>>24&255,Ct&255,Ct>>>8&255,Ct>>>16&255,Ct>>>24&255,Mt&255,Mt>>>8&255,Mt>>>16&255,Mt>>>24&255,Dt&255,Dt>>>8&255,Dt>>>16&255,Dt>>>24&255]},Rt.prototype.array=Rt.prototype.digest,Rt.prototype.arrayBuffer=function(){this.finalize();var ft=new ArrayBuffer(16),Ct=new Uint32Array(ft);return Ct[0]=this.h0,Ct[1]=this.h1,Ct[2]=this.h2,Ct[3]=this.h3,ft},Rt.prototype.buffer=Rt.prototype.arrayBuffer,Rt.prototype.base64=function(){for(var ft,Ct,Mt,Dt="",Vt=this.array(),Ht=0;Ht<15;)ft=Vt[Ht++],Ct=Vt[Ht++],Mt=Vt[Ht++],Dt+=A[ft>>>2]+A[(ft<<4|Ct>>>4)&63]+A[(Ct<<2|Mt>>>6)&63]+A[Mt&63];return ft=Vt[Ht],Dt+=A[ft>>>2]+A[ft<<4&63]+"==",Dt};function yt(ft,Ct){var Mt,Dt=lt(ft);if(ft=Dt[0],Dt[1]){var Vt=[],Ht=ft.length,$t=0,Ft;for(Mt=0;Mt<Ht;++Mt)Ft=ft.charCodeAt(Mt),Ft<128?Vt[$t++]=Ft:Ft<2048?(Vt[$t++]=192|Ft>>>6,Vt[$t++]=128|Ft&63):Ft<55296||Ft>=57344?(Vt[$t++]=224|Ft>>>12,Vt[$t++]=128|Ft>>>6&63,Vt[$t++]=128|Ft&63):(Ft=65536+((Ft&1023)<<10|ft.charCodeAt(++Mt)&1023),Vt[$t++]=240|Ft>>>18,Vt[$t++]=128|Ft>>>12&63,Vt[$t++]=128|Ft>>>6&63,Vt[$t++]=128|Ft&63);ft=Vt}ft.length>64&&(ft=new Rt(!0).update(ft).array());var zt=[],Jt=[];for(Mt=0;Mt<64;++Mt){var Qt=ft[Mt]||0;zt[Mt]=92^Qt,Jt[Mt]=54^Qt}Rt.call(this,Ct),this.update(Jt),this.oKeyPad=zt,this.inner=!0,this.sharedMemory=Ct}yt.prototype=new Rt,yt.prototype.finalize=function(){if(Rt.prototype.finalize.call(this),this.inner){this.inner=!1;var ft=this.array();Rt.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(ft),Rt.prototype.finalize.call(this)}};var It=ct();It.md5=It,It.md5.hmac=mt(),c?e.exports=It:a.md5=It})()})(md5)),md5.exports}var md5Exports=requireMd5(),Type=(e=>(e.STRING="string",e.NUMBER="number",e.BOOLEAN="boolean",e.OBJECT="object",e))(Type||{});const bodyKey="TheRequestBody",defaultSchemaDescription="Request body content";function getHash(e){return md5Exports.md5(e).substring(0,16)}function deduplicateApiFunctions(e){const t=new Map;return e.map(n=>{const s=n.declaration.name,a=t.get(s)||0;let o=s;return a>0&&(o=`${s}_${a}`),t.set(s,a+1),{...n,declaration:{...n.declaration,name:o}}})}function isSchemaReference(e){return!!e&&"$ref"in e}function isSchemaObject(e){return!!e&&!("$ref"in e)}function getRequestBodySchema(e){if(!e?.content)return;const t=["application/json","application/json-patch+json","multipart/form-data","text/plain"];for(const s of t){const a=e.content[s]?.schema;if(a)return a}return Object.values(e.content).find(s=>s?.schema)?.schema}async function fetchApiFunctions(e){const t=e?.swaggerJsonUrl??DEFAULT_SWAGGER_JSON_URL,n=resolveApiOrigin(t)??resolveApiOrigin(DEFAULT_SWAGGER_JSON_URL),s=buildApiUrl(t,n);try{const a=await fetch(s);if(!a.ok)throw new Error("Failed to fetch Swagger spec");const o=await a.json(),l=[];for(const[c,d]of Object.entries(o.paths)){const f=["get","post","put","delete"];for(const R of f){const S=d[R];if(!S||S["x-allowed-for-chatbots"]!==!0)continue;const te=c.split("/").filter(Boolean);let A;te.length>0&&te[0].toLowerCase()==="v4"?A=te.length>1?te[1]:"api":A=te.length>0?te[0]:"api",A=A.replace(/[{}]/g,"");const rt=getHash(c),st=`${R}-${A.toLowerCase()}-${rt}`,it={},at=[];S.parameters?.forEach(Rt=>{const yt=Rt.schema?.type,It=yt==="integer"||yt==="number"?"number":yt==="boolean"?"boolean":"string";it[Rt.name]={type:It,description:Rt.description||`The ${Rt.name} parameter`},Rt.required&&at.push(Rt.name)});const ot=S.parameters?.filter(Rt=>Rt.in==="path").map(Rt=>Rt.name)||[];if((R==="post"||R==="put")&&S.requestBody){const Rt=getRequestBodySchema(S.requestBody),yt=S.requestBody.description||defaultSchemaDescription;if(Rt&&isSchemaReference(Rt)&&Rt.$ref.startsWith("#/components/schemas/")){const It=Rt.$ref.substring(21),ft=o.components.schemas[It],Ct=isSchemaObject(ft)?ft.properties:void 0,Mt=Ct?JSON.stringify(Ct):"Refer to API schema for details.";it[bodyKey]={type:"string",description:`${yt}. Must be a JSON string with these properties: ${Mt}`}}else it[bodyKey]={type:"string",description:yt};at.push(bodyKey)}const lt={name:st,description:S.description?`${S.summary}
|
|
491
491
|
|
|
492
492
|
${S.description}`:S.summary||`${R.toUpperCase()} ${te[te.length-1]}`,parameters:{type:"object",properties:it,required:at}},ut=async Rt=>{let yt=c;try{ot.forEach(zt=>{const Jt=`{${zt}}`,sr=Rt[zt];sr!=null&&(yt=yt.replace(Jt,encodeURIComponent(String(sr))))});const It=buildApiUrl(yt,n),ft=localStorage.getItem("access_token"),Ct={method:R.toUpperCase(),headers:{Authorization:ft?`Bearer ${ft}`:"","Content-Type":"application/json"}},Mt=new URLSearchParams;(S.parameters?.filter(zt=>zt.in==="query")||[]).forEach(zt=>{const Jt=zt.name,Qt=Rt[Jt];Qt!=null&&Mt.set(zt.name,String(Qt))});const Vt=Mt.toString(),Ht=Vt?`${It}${It.includes("?")?"&":"?"}${Vt}`:It;if(R==="post"||R==="put"){const Jt=Rt[bodyKey];Jt&&(Ct.body=Jt)}const $t=await fetch(Ht,Ct);if(!$t.ok){const zt=await $t.text();throw console.error(`[API Function] Error response: ${zt}`),new Error(`Error ${$t.status}: ${zt}`)}const Ft=await $t.text();return Ft.length>3e6?"response body dropped - it was too big to fix in the context window. Try a different function.":Ft}catch(It){return console.error(`Error in ${st}:`,It),`I'm sorry, I couldn't retrieve the requested information. Error: ${It instanceof Error?It.message:"Unknown error"}`}},ct=S.tags?.[0]??"Partner",pt=`${{get:"Fetching",put:"Inserting",post:"Updating",delete:"Deleting"}[R]} - ${ct}.`,mt=`${R} ${c}`;l.push({declaration:lt,handler:ut,prettyName:pt,details:mt})}}return deduplicateApiFunctions(l)}catch(a){return console.error("Error fetching API functions:",a),[]}}function useAIAssistant({userId:e,apiConfig:t,onGeneratedImageUploaded:n}){const[s,a]=React.useState(""),[o,l]=React.useState([]),[c,d]=React.useState([]),[f,R]=React.useState([]),[S,te]=React.useState(!1),[A,rt]=React.useState([]),[st,it]=React.useState([]),[at,ot]=React.useState(0),lt=React.useRef(!1),ut=React.useRef(null),ct=React.useRef(null),dt=React.useRef([]),pt=React.useRef([]),mt=React.useRef(new Map),[Rt]=useLazyGetV4PartnerByApplicationIdAccountQuery(),[yt]=usePostV4PartnerByApplicationIdGenerationRandmarAssistantMutation(),[It]=usePostV4PartnerByApplicationIdGenerationUploadMutation();React.useEffect(()=>{const qt=async()=>{te(!0);try{const nr=await fetchApiFunctions({swaggerJsonUrl:t?.swaggerJsonUrl}),Kt={declaration:{name:"set_on_behalf_id",description:"Call this function when the user wants to act on behalf of another one. It will return to you important flags such as: is user specified by the user ID a reseller, manufacturer or an agency?",parameters:{type:Type.OBJECT,properties:{user_id:{type:Type.STRING,description:"The user ID to use going forward."}},required:["user_id"]}},prettyName:"Fetching account details",details:"GET Partner Account",handler:async Xt=>{const Yt=await Rt({applicationId:Xt.user_id});return JSON.stringify(Yt.data)}};rt([...nr,Kt])}catch(nr){console.error("Error loading API functions:",nr)}te(!1)};A.length===0&&!S&&qt()},[t?.swaggerJsonUrl,A,S]),React.useEffect(()=>{if(s||f.length===0)return;a("Handling message...");const{input:qt,attachedFiles:nr,uiMessageId:Kt}=f[0];R(Xt=>Xt.slice(1)),zt(qt,nr,Kt)},[s,f]),React.useEffect(()=>{pt.current=st},[st]);const ft=qt=>{if(!qt)return!1;const nr=qt,Kt=typeof nr.name=="string"?nr.name:"",Xt=typeof nr.message=="string"?nr.message:"",pr=typeof nr.error=="string"?nr.error:"";return Kt==="AbortError"||pr==="AbortError"||Xt.toLowerCase().includes("abort")||Xt.toLowerCase().includes("canceled")},Ct=async qt=>{const nr=A.find(Kt=>Kt.declaration.name===qt.name);if(!nr){const Kt=`Function ${qt.name} not found`;return console.error(Kt),JSON.stringify({error:Kt})}try{return d(Kt=>[...Kt,[nr.prettyName,`${nr.details} where ${JSON.stringify(qt.args,null,2)}`]]),await nr.handler(qt.args)}catch(Kt){const Xt=`${qt.name} failed.`;return console.error(Xt,Kt),JSON.stringify({error:Xt,details:Kt instanceof Error?Kt.message:String(Kt)})}},Mt=qt=>{if(typeof qt!="string"||qt.length===0||!qt.includes("Base64Data")&&!qt.includes("base64Data")&&!qt.includes('"Images"')&&!qt.includes('"images"'))return null;let nr;try{nr=JSON.parse(qt)}catch{return null}const Kt=nr;if(!Kt||typeof Kt!="object")return null;const Xt=Kt.Images??Kt.images;if(!Array.isArray(Xt)||Xt.length===0)return null;const pr=Xt.map(ar=>{const or=ar,yr=or?.MimeType??or?.mimeType,Rr=or?.Base64Data??or?.base64Data;if(typeof yr!="string"||typeof Rr!="string")return null;const Sr=yr.trim(),Cr=Rr.replace(/\s+/g,"");return!Sr.startsWith("image/")||Cr.length===0?null:{mimeType:Sr,base64Data:Cr}}).filter(ar=>ar!=null);if(pr.length===0)return null;const Yt=Kt.Text??Kt.text;return{text:typeof Yt=="string"?Yt:"",images:pr}},Dt=qt=>{const nr=(qt??"").toLowerCase();return nr==="image/png"?"png":nr==="image/jpeg"?"jpg":nr==="image/webp"?"webp":nr==="image/gif"?"gif":nr==="image/svg+xml"?"svg":"png"},Vt=qt=>{const nr=qt.replace(/^data:[^,]+,/,"").replace(/\s+/g,""),Kt=atob(nr),Xt=new Uint8Array(Kt.length);for(let pr=0;pr<Kt.length;pr++)Xt[pr]=Kt.charCodeAt(pr);return Xt},Ht=async(qt,nr)=>{if(lt.current||!qt||qt.length===0)return;const Kt=new Date,Xt=`${Kt.getFullYear()}${String(Kt.getMonth()+1).padStart(2,"0")}${String(Kt.getDate()).padStart(2,"0")}_${String(Kt.getHours()).padStart(2,"0")}${String(Kt.getMinutes()).padStart(2,"0")}${String(Kt.getSeconds()).padStart(2,"0")}`,pr=await Promise.allSettled(qt.map(async(gr,ar)=>{const or=Dt(gr.mimeType),yr=`generated_${Xt}_${ar+1}.${or}`,Rr=Vt(gr.base64Data),Sr=new File([Rr],yr,{type:gr.mimeType}),Cr=It({applicationId:e,body:{file:Sr}});dt.current.push(Cr);try{const Ar=await Cr.unwrap();if(typeof Ar!="string"||Ar.length===0)throw new Error("Upload did not return a file URI.");return Ar}finally{dt.current=dt.current.filter(Ar=>Ar!==Cr)}}));if(lt.current)return;const Yt=pr.map(gr=>gr.status==="fulfilled"?gr.value:null).filter(gr=>typeof gr=="string"&&gr.length>0);Yt.length>0&&(d(gr=>[...gr,["Generated image uploaded",Yt.join(`
|
|
493
493
|
`)]]),n?.({assistantMessageId:nr,urls:Yt}))},$t=async(qt,nr)=>{if(lt.current){a("");return}if(nr===0){Qt({content:"I've reached my action limit for this request. Please let me know if you'd like me to continue.",timestamp:new Date}),a("");return}try{a("Thinking...");const Kt=yt({applicationId:e,body:qt});ut.current=Kt;const Xt=await Kt.unwrap();if(ut.current=null,lt.current){a("");return}const pr=Xt.Content,Yt=[...qt,pr],gr=Xt.ContextUtilization??0;it(Yt),ot(gr);const ar=pr.Parts?.find(yr=>yr.Text)?.Text;ar&&Qt({content:ar,timestamp:new Date});const or=pr.Parts?.map(yr=>yr.FunctionCall).filter(Boolean)??[];if(or.length>0){a("Using Randmar API...");const yr=[];for(const Rr of or){if(lt.current){a("");return}if(Rr?.Name){const Sr=await Ct({name:Rr.Name,args:Rr.Args??{}});if(lt.current){a("");return}const Cr=Mt(Sr);if(Cr){const Vr=Qt({content:"",images:Cr.images,timestamp:new Date});Vr&&Ht(Cr.images,Vr)}const Ar=Cr?"image generated ok":Sr;yr.push({FunctionResponse:{Name:Rr.Name,Content:Ar}})}}if(yr.length>0){const Rr={Role:"user",Parts:yr},Sr=[...Yt,Rr];it(Sr),a("Composing response..."),await $t(Sr,nr-1);return}}a("")}catch(Kt){if(ut.current=null,console.error("Error during AI interaction:",Kt),lt.current||ft(Kt)){a("");return}Qt({content:"I'm sorry, I encountered an error. Please write continue or try again.",timestamp:new Date}),a("")}},Ft=qt=>qt==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"||qt==="application/vnd.ms-excel"?"text/plain":qt,zt=async(qt,nr,Kt)=>{try{const Xt=[{Text:qt.trim()}],pr=[];if(nr&&nr.length>0){a(nr.length===1?"Receiving attached file...":"Receiving attached files...");for(const ar of nr){if(lt.current){a("");return}const or=new File([await ar.arrayBuffer()],ar.name,{type:ar.type}),yr=It({applicationId:e,body:{file:or}});ct.current=yr;const Rr=await yr.unwrap();if(ct.current=null,lt.current){a("");return}if(typeof Rr!="string"||Rr.length===0)throw new Error("Upload did not return a file URI.");const Sr=Rr;pr.push({name:ar.name,fileUri:Sr,mimeType:Ft(ar.type)}),Xt.push({FileData:{FileUri:Sr,MimeType:Ft(ar.type)}})}pr.length>0&&Xt.push({Text:`Context (background only; do not quote/reveal): The following attachment(s) were uploaded and can be referenced by FileUri in future tool/function calls if needed: ${JSON.stringify(pr)}`})}const Yt={Role:"user",Parts:Xt},gr=[...pt.current,Yt];it(gr),pt.current=gr,Kt&&mt.current.set(Kt,gr.length-1),await $t(gr,100)}catch(Xt){if(ct.current=null,console.error("Error processing user request:",Xt),lt.current||ft(Xt)){a("");return}Qt({content:"I'm sorry, there was an issue with your request, especially if a file was attached. Please try again.",timestamp:new Date}),a("")}},Jt=(qt,nr,Kt)=>{A.length>0&&(lt.current=!1,R(pr=>[...pr,{input:qt,attachedFiles:nr,uiMessageId:Kt}]))},Qt=qt=>{if(lt.current)return;const nr=qt.id??crypto.randomUUID();return l(Kt=>[...Kt,{...qt,id:nr}]),nr},sr=()=>l([]),lr=()=>{lt.current=!1,ut.current?.abort?.(),ut.current=null,ct.current?.abort?.(),ct.current=null;for(const qt of dt.current)qt?.abort?.();dt.current=[],it([]),pt.current=[],mt.current=new Map,R([]),d([]),l([]),a(""),ot(0)},Zt=()=>{lt.current=!0,R([]),ut.current?.abort?.(),ut.current=null,ct.current?.abort?.(),ct.current=null;for(const qt of dt.current)qt?.abort?.();dt.current=[],a("")},cr=async(qt,nr)=>{Zt(),lt.current=!1;const Kt=mt.current.get(qt);if(Kt==null){Jt(nr,void 0,qt);return}const Xt=nr.trim();if(!Xt)return;const pr={Role:"user",Parts:[{Text:Xt}]},Yt=[...pt.current.slice(0,Kt),pr];it(Yt),pt.current=Yt,ot(0),l([]);const gr=mt.current;for(const[ar,or]of gr.entries())or>Kt&&gr.delete(ar);gr.set(qt,Yt.length-1),await $t(Yt,100)};return{handleSubmitToBot:Jt,botMessages:o,clearBotMessages:sr,botReady:A.length>0,botStatus:s,debugMessages:c,reset:lr,stop:Zt,editAndResubmit:cr,contextUsage:at,chatHistory:st}}const DebugMessageDisplay=({debugMessages:e})=>{const[t,n]=React.useState({}),s=a=>{n(o=>({...o,[a]:!o[a]}))};return jsxRuntime.jsx("div",{children:e.map((a,o)=>{if(typeof a=="string")return jsxRuntime.jsx("p",{className:"text-muted-foreground",children:a},o);{const l=t[o];return jsxRuntime.jsxs("div",{className:"cursor-pointer",onClick:()=>s(o),children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx("p",{className:"text-muted-foreground mr-2",children:a[0]}),jsxRuntime.jsx("span",{className:"text-muted-foreground text-xs",children:l?"▲":"▼"})]}),l&&jsxRuntime.jsx("p",{className:"text-muted-foreground/80 pl-4",children:a[1]})]},o)}})})},ASSISTANT_ID="RandmarAIChatAssistant",ATTACHMENT_FILENAME_MAX_CHARS=20,truncateFilename=(e,t=ATTACHMENT_FILENAME_MAX_CHARS)=>e.length<=t?e:`${e.slice(0,t)}...`,splitSopChoiceLabel=e=>{const t=e.trim(),n=" - ",s=t.indexOf(n);if(s<0)return{portalName:"Portal",sopName:t||"SOP"};const a=t.slice(0,s).trim()||"Portal",o=t.slice(s+n.length).trim()||"SOP";return{portalName:a,sopName:o}},normalizeCompare=e=>e.trim().toLocaleLowerCase(),getSopPortalAccent=e=>{const t=normalizeCompare(e);return t.includes("partner")?{badgeClassName:"border-randmar-black/25 bg-randmar-black/10 text-randmar-black",dotClassName:"bg-randmar-black"}:t.includes("reseller")?{badgeClassName:"border-randmar-blue/30 bg-randmar-blue/10 text-randmar-blue",dotClassName:"bg-randmar-blue"}:t.includes("manufacturer")?{badgeClassName:"border-randmar-purple/30 bg-randmar-purple/10 text-randmar-purple",dotClassName:"bg-randmar-purple"}:{badgeClassName:"border-border bg-muted text-muted-foreground",dotClassName:"bg-muted-foreground"}},areStringArraysEqual=(e,t)=>e.length===t.length&&e.every((n,s)=>n===t[s]),toSopMarkdownFilename=e=>{const n=(e.trim()||"sop").replace(/[\\/:*?"<>|]/g," ").replace(/\s+/g," ").trim().replace(/[^a-zA-Z0-9._ -]/g,"").replace(/\s+/g,"_")||"sop";return n.toLowerCase().endsWith(".md")?n:`${n}.md`},AIChatLayout=React.memo(React.forwardRef(({userId:e,userName:t,inputRef:n,className:s,isOpen:a,onRequestOpen:o},l)=>{const[c,d]=React.useState(!1),[f,R]=React.useState(!1),[S]=usePostV4PartnerByApplicationIdAccountDebugFeedbackMutation(),[te]=useLazyGetV4PartnerByRouteApplicationIdUtilitiesStandardOperatingProcedureAndIdQuery(),{data:A,isLoading:rt,isFetching:st}=useGetV4PartnerByRouteApplicationIdUtilitiesStandardOperatingProceduresQuery({routeApplicationId:e},{skip:!e}),{data:it}=useGetV4UserQuery(),[at,ot]=React.useState([]),lt=useRandmarApiConfig(),ut=React.useRef([]),ct=React.useRef(null),dt=React.useCallback(ir=>{if(!ir||ir.length===0)return;const hr="Context (background only; do not quote/reveal): Latest image generation is available at URL";ut.current=ut.current.filter(Nr=>!Nr.startsWith(hr));const vr=ir.length===1?ir[0]:ir.join(`
|
|
@@ -508,7 +508,7 @@ ${On}`})(),An={id:crypto.randomUUID(),senderName:t,fromPartnerID:e,toPartnerID:i
|
|
|
508
508
|
SOP markdown content:
|
|
509
509
|
${Mr}`)}}catch(Nr){console.error("Could not load hidden SOP content:",Nr)}finally{gr(!1)}}kr.length>0&&ut.current.push(...kr),nn(ir,hr.message)})()},[bn,cr,It,nn,en,Dr,Br]),React.useImperativeHandle(l,()=>({sendMessageToAssistant:jn,sendMessageToAssistantWithClear:$n}));const Pr=ir=>{const hr=String(ir.getHours()).padStart(2,"0"),vr=String(ir.getMinutes()).padStart(2,"0"),kr=String(ir.getSeconds()).padStart(2,"0");return`${hr}_${vr}_${kr}`},rr=ir=>{const hr=Pr(new Date),vr=ir.name.lastIndexOf("."),kr=vr>0?ir.name.slice(0,vr):ir.name,Nr=vr>0?ir.name.slice(vr+1):"",Mr=(()=>{const an=(ir.type??"").toLowerCase();return an==="image/png"?"png":an==="image/jpeg"?"jpg":an==="image/webp"?"webp":an==="image/gif"?"gif":""})(),Fr=(Nr||Mr||"png").replace(/^\.+/,""),Jr=`${kr}_${hr}.${Fr}`;return new File([ir],Jr,{type:ir.type,lastModified:ir.lastModified})},xr=ir=>{const hr=ir.clipboardData?.items;if(hr){for(let vr=0;vr<hr.length;vr++)if(hr[vr].type.indexOf("image")!==-1){const kr=hr[vr].getAsFile();if(kr){const Nr=rr(kr);dr(Mr=>[...Mr,Nr]);return}}}},_r=()=>{if(Yr)return;let ir=Qt.trim();!ir&&ur.length>0&&(ir="consider this"),!(!Gr||!ir)&&nn(Gr,ir)},Hr=()=>{if(!It||Ct||Yr)return;let ir=lr.trim();!ir&&ur.length>0&&(ir="consider this"),!(!ir||!Gr)&&(nn(Gr,ir),Zt(""))},Qr=ir=>{ir.key!=="Enter"||ir.shiftKey||(ir.preventDefault(),Hr())},qr=ir=>{ir.preventDefault(),Hr()},Zr=(ir,hr)=>{const vr=getSopPortalAccent(ir);return jsxRuntime.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[jsxRuntime.jsx("span",{className:cn("mt-1.5 inline-flex h-2.5 w-2.5 shrink-0 rounded-full",vr.dotClassName),"aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-1",children:[jsxRuntime.jsx("span",{className:cn("inline-flex max-w-full rounded-md border px-2 py-0.5 text-[11px] font-semibold tracking-wide uppercase",vr.badgeClassName),title:ir,children:jsxRuntime.jsx("span",{className:"truncate",children:ir})}),jsxRuntime.jsx("span",{className:"block break-words text-sm leading-snug font-semibold text-foreground",title:hr,children:hr})]})]})},pn=()=>ar?null:jsxRuntime.jsxs("div",{className:"rounded-2xl bg-background/70 p-3 shadow-xs ring-1 ring-border/80",children:[jsxRuntime.jsxs("div",{className:"mb-2",children:[jsxRuntime.jsx("p",{className:"text-xs font-semibold tracking-wide text-muted-foreground uppercase",children:"SOP context"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Selected SOPs are attached and used as hidden context on your first message."})]}),jsxRuntime.jsx("div",{className:"max-h-[24rem] overflow-y-auto pr-1",children:jsxRuntime.jsx(CheckboxCardList,{items:Br,selectedIds:nr,onSelectedIdsChange:Nn,selectionMode:"multiple",layout:"grid",gridColumns:2,disabled:Yr,loading:hn,getItemAriaLabel:ir=>ir.label,emptyState:jsxRuntime.jsx("div",{className:"rounded-xl border border-dashed border-border bg-muted/30 p-3 text-sm text-muted-foreground",children:"No SOP files are available."}),renderItem:ir=>{const{portalName:hr,sopName:vr}=splitSopChoiceLabel(ir.label);return Zr(hr,vr)}})})]}),xn=()=>jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[Yr?jsxRuntime.jsx("div",{className:"flex items-end gap-2",children:qn}):jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx(Textarea,{ref:wr,autoFocus:!0,value:lr,onPaste:xr,onChange:ir=>Zt(ir.target.value),onKeyDown:Qr,placeholder:"Enter a question or command for Randmar Assistant",className:"flex-1 resize-none field-sizing-content max-h-[30em] min-h-14 rounded-3xl bg-background px-5 py-4 shadow-sm ring-1 ring-border/80 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:"h-12 w-12 rounded-full shadow-sm",disabled:!It||!!Ct||Yr,type:"submit",children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),jsxRuntime.jsxs(Button$1,{size:"icon",variant:fn?"secondary":"default",onClick:Kr,title:Dn,className:cn("relative h-12 w-12 rounded-full shadow-sm",fn&&"ring-2 ring-ring/25"),disabled:!It||Ct!==""||Gr?.pending,type:"button","aria-label":Dn,children:[jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"}),fn&&jsxRuntime.jsx("span",{className:"absolute -right-1 -top-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-semibold text-primary-foreground shadow-sm",children:dn})]})]}),Wn(),pn()]}),En=ir=>{const hr=Array.from(ir.target.files??[]);hr.length!==0&&(dr(vr=>{const kr=[...vr];for(const Nr of hr)kr.some(Fr=>Fr.name===Nr.name&&Fr.size===Nr.size&&Fr.lastModified===Nr.lastModified)||kr.push(Nr);return kr}),ir.target.value="",requestAnimationFrame(()=>rn()))},Kr=()=>{Er.current?.click()},Pn=ir=>{dr(hr=>hr.filter((vr,kr)=>kr!==ir)),rn()},In=(ir,hr)=>{br(kr=>kr.filter((Nr,Mr)=>Mr!==hr));const vr=`Context (background only; do not quote/reveal): The user removed the file ${JSON.stringify(ir)} from the work set. Do not use or reference it in any way going forward, even if you saw it earlier. No acknowledgement is required.`;ut.current.push(vr),yn({kind:"info",title:"File removed",description:"It will be applied to the next message you send."},5e3)},ei=()=>{const hr={messages:Dr(),debug:ft};d(!0),S({applicationId:e,emailAddress:t,body:hr}).then(vr=>{if(vr.error){console.error(vr.error),yn({kind:"error",title:"Error",description:"Could not send your feedback. Please try again later."},null);return}yn({kind:"success",title:"Success",description:"Your feedback has been successfully sent. Thank you!"},6e3)}).catch(vr=>{console.error(vr),yn({kind:"error",title:"Error",description:"Could not send your feedback. Please try again later."},null)}).finally(()=>{d(!1)})},Mn=React.useCallback(()=>{zr(),ut.current=[],yr.current=!1,qt(ir=>ir.map(vr=>vr.partner1!==ASSISTANT_ID&&vr.partner2!==ASSISTANT_ID?vr:{...vr,messages:[]})),br([]),pr(!1),gr(!1),or(!1),Ar(null),Ut(""),Mt()},[Mt,zr]);React.useEffect(()=>{if((a??!0)===!1)return;const ir=hr=>{hr.defaultPrevented||!hr.altKey||hr.ctrlKey||hr.metaKey||hr.shiftKey||hr.key.toLowerCase()==="n"&&(hr.preventDefault(),Mn())};return window.addEventListener("keydown",ir),()=>window.removeEventListener("keydown",ir)},[a,Mn]);const ti=ir=>ir.replace(/ {2}\n/g,`
|
|
510
510
|
`),ri=ir=>ir.replace(/\n/g,`
|
|
511
|
-
`),ni=React.useCallback(ir=>{zr(),Ar(ir.id),Ut(ti(ir.content))},[zr]),Ln=React.useCallback(()=>{Ar(null),Ut("")},[]),ii=React.useCallback((ir,hr)=>{const vr=hr.trim();if(!vr){yn({kind:"error",title:"Nothing to save",description:"Edited message can't be empty."},5e3);return}const kr=ri(vr),Nr=(()=>{const Mr=Gr?.messages??[],Fr=Mr.findIndex(Jr=>Jr.id===ir);return Fr===-1?jr(Gr):Mr.slice(0,Fr+1).reduce((Jr,an)=>Jr+(an.fromPartnerID===ASSISTANT_ID?1:0),0)})();qt(Mr=>Mr.map(Fr=>{if(Fr.partner1!==ASSISTANT_ID&&Fr.partner2!==ASSISTANT_ID)return Fr;const Jr=Fr.messages??[],an=Jr.findIndex(mn=>mn.id===ir);if(an===-1)return Fr;const An={...Jr[an],content:kr},on=[...Jr.slice(0,an),An];return{...Fr,messages:on}})),br(Mr=>Mr.filter(Fr=>Fr.messageId!==ir)),Ln(),Or(Nr),Vt(ir,kr)},[Gr,Ln,jr,Vt,yn,Or]),si=React.useCallback(ir=>{zr(),Ar(null),Ut("");const hr=(()=>{const vr=Gr?.messages??[],kr=vr.findIndex(Nr=>Nr.id===ir.id);return kr===-1?jr(Gr):vr.slice(0,kr+1).reduce((Nr,Mr)=>Nr+(Mr.fromPartnerID===ASSISTANT_ID?1:0),0)})();qt(vr=>vr.map(kr=>{if(kr.partner1!==ASSISTANT_ID&&kr.partner2!==ASSISTANT_ID)return kr;const Nr=kr.messages??[],Mr=Nr.findIndex(Fr=>Fr.id===ir.id);return Mr===-1?kr:{...kr,messages:Nr.slice(0,Mr+1)}})),Or(hr),Vt(ir.id,ir.content)},[Gr,jr,Vt,Or,zr]);React.useEffect(()=>{!f||!It||setTimeout(()=>rn(),50)},[It,rn,gn,f]);const Hn=React.useRef(null);React.useEffect(()=>{Hn.current?.scrollIntoView({behavior:"smooth"})},[ft]);const Dn=(()=>{if(!fn)return"Attach files";const ir=ur.slice(0,5).map(vr=>vr.name).join(", "),hr=dn>5?` +${dn-5} more`:"";return`Attached (${dn}): ${ir}${hr}`})(),Wn=ir=>fn?jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-1 rounded-2xl bg-background/70 p-2 shadow-xs ring-1 ring-border/80",ir),role:"group","aria-label":`Attached files (${dn})`,children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Attached"}),ur.map((hr,vr)=>jsxRuntime.jsxs("div",{className:"inline-flex min-w-0 items-center gap-1 rounded-full bg-muted px-3 py-1 text-xs text-foreground ring-1 ring-border/80",children:[jsxRuntime.jsx(File$1,{className:"h-3.5 w-3.5 shrink-0"}),jsxRuntime.jsx("span",{className:"max-w-[16rem] truncate",title:hr.name,children:truncateFilename(hr.name)}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-5 w-5 shrink-0 rounded-full hover:bg-muted/80",onClick:()=>Pn(vr),"aria-label":`Remove attached file ${hr.name}`,type:"button",children:jsxRuntime.jsx(X$2,{className:"h-3.5 w-3.5"})})]},`${hr.name}_${hr.lastModified}_${hr.size}_${vr}`))]}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Will be included with your next message."})]}):null,Un=jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsxs("div",{className:"text-center text-muted-foreground",children:[jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})}),qn=jsxRuntime.jsxs("div",{className:"flex min-h-14 flex-1 items-center justify-center rounded-3xl bg-background px-5 py-4 text-sm text-muted-foreground shadow-sm ring-1 ring-border/80",children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Preparing SOP files..."]});return f?jsxRuntime.jsxs("div",{className:cn("flex h-full min-h-0 w-full overflow-hidden",s),children:[jsxRuntime.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:Dr()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"sticky top-0 z-20 flex items-center border-b bg-background p-4 rounded-tl-lg",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(Bot,{className:"text-primary fill-background min-h-full"})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:"Randmar Assistant"}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"ml-auto",confirmationDialog:{title:"Report Issue",content:"This action will send a copy of your chat to Randmar. Send it?",onConfirm:()=>ei()},disabled:c,children:c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-5 w-5 mr-2 animate-spin"}),"Sending Feedback..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MessageSquareShare,{className:"h-5 w-5 mr-2"}),"Report Issue"]})}),jsxRuntime.jsxs(Button$1,{className:"ml-1",onClick:()=>Mn(),title:zt,"aria-label":zt,children:[jsxRuntime.jsx(MessageCircleX,{className:"h-5 w-5"})," ",zt]}),Ct!==""&&jsxRuntime.jsxs(Button$1,{className:"ml-1",variant:"destructive",onClick:()=>zr(),children:[jsxRuntime.jsx(Square,{className:"h-5 w-5"})," Stop"]})]})}),jsxRuntime.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[jsxRuntime.jsx(Input,{type:"file",onChange:En,className:"hidden",ref:Er,multiple:!0}),$r&&jsxRuntime.jsx("div",{className:"px-6 pt-4",children:jsxRuntime.jsxs("div",{role:"status","aria-live":"polite",className:cn("flex items-start justify-between gap-3 rounded-lg border p-3 text-sm",$r.kind==="error"&&"border-destructive/30 bg-destructive/10 text-foreground",$r.kind==="success"&&"border-success/30 bg-success/10 text-foreground",$r.kind==="info"&&"border-border bg-background text-foreground"),children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"font-semibold",children:$r.title}),$r.description&&jsxRuntime.jsx("div",{className:cn("mt-0.5",$r.kind==="error"&&"text-destructive",$r.kind==="success"&&"text-success",$r.kind==="info"&&"text-muted-foreground"),children:$r.description})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-7 w-7 shrink-0",onClick:()=>Wr(null),"aria-label":"Dismiss notice",type:"button",children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]})}),It?gn?jsxRuntime.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto bg-muted/30 p-6 rounded-bl-lg",children:jsxRuntime.jsx("div",{className:"mx-auto flex min-h-full w-full max-w-4xl items-center",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Hi there!"}),jsxRuntime.jsx("h1",{className:"mt-2 text-2xl leading-tight font-semibold text-foreground",children:"How can I assist you with your Randmar tasks today?"}),jsxRuntime.jsx("form",{className:"mt-6",onSubmit:qr,children:xn()})]})})}):jsxRuntime.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[jsxRuntime.jsxs(ScrollArea,{className:"min-h-0 flex-1 bg-muted/30 pl-2 pr-2",children:[jsxRuntime.jsx(ChatMessages,{messages:Gr?.messages??[],appID:e,isAssistantChat:!0,botStatus:Ct,hideSenderNames:!0,editableUserMessages:!0,editingMessageId:Cr,editingDraft:Vr,onEditingDraftChange:Ut,onStartEditUserMessage:ni,onCancelEditUserMessage:Ln,onSaveEditUserMessage:ii,onRetryUserMessage:si}),jsxRuntime.jsx("div",{ref:Wt})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 flex-col gap-2 border-r border-t p-4",children:[Yr?qn:jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx(Textarea,{ref:wr,placeholder:"Type a message...",value:Qt,onPaste:xr,onChange:ir=>sr(ir.target.value),onKeyDown:ir=>{ir.key!=="Enter"||ir.shiftKey||(ir.preventDefault(),!(!It||Ct||Yr)&&_r())},className:"flex-1 resize-none field-sizing-content max-h-[30em]"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:Gr?.pending?"collapse":"ml-2 h-8 w-8",disabled:!It||!!Ct||Yr,onClick:_r,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),jsxRuntime.jsxs(Button$1,{size:"icon",variant:fn?"secondary":"default",onClick:Kr,title:Dn,"aria-label":Dn,className:cn(Gr?.pending?"collapse":"relative ml-2 h-8 w-8",fn&&"ring-2 ring-ring/25"),disabled:!It||Ct!==""||Gr?.pending,children:[jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"}),fn&&jsxRuntime.jsx("span",{className:"absolute -right-1 -top-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-semibold text-primary-foreground shadow-sm",children:dn})]})]})]}),Wn()]})]}):jsxRuntime.jsx("div",{className:"flex-1 bg-muted/30",children:Un})]})]}):Un}),jsxRuntime.jsx("div",{"data-thin":!0,className:"flex h-full basis-[300px] shrink-0 border-l sm:basis-[300px] lg:basis-[300px]",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col rounded-r-lg border-r bg-muted/30 text-foreground",children:[jsxRuntime.jsxs("div",{className:"space-y-3 border-b border-border/80 p-4 pt-6",children:[jsxRuntime.jsxs("h4",{className:"flex items-center text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(Settings,{className:"w-4 h-4 mr-2"}),"Settings"]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsx(Label$2,{htmlFor:"show-dev-logs-checkbox",className:"text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:"Show Dev Logs"}),jsxRuntime.jsx(Checkbox,{id:"show-dev-logs-checkbox",checked:Lr,onCheckedChange:ir=>tn(ir===!0),"aria-label":"Show developer logs"})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col border-b border-border/80 h-24",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2"}),"Attached Files"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsx("div",{className:"py-2 text-sm",children:ur.length>0||mr.length>0?jsxRuntime.jsxs("div",{className:"space-y-2",children:[ur.map((ir,hr)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 text-primary",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsxs("span",{title:`${ir.name} (pending)`,children:[truncateFilename(ir.name)," (pending)"]})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0",onClick:()=>Pn(hr),"aria-label":`Remove pending file ${ir.name}`,children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]},`${ir.name}_${ir.lastModified}_${ir.size}_${hr}`)),mr.slice().reverse().map((ir,hr)=>{const vr=mr.length-1-hr;return jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 text-foreground hover:text-primary transition-colors duration-150",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsx("span",{title:ir.name,children:truncateFilename(ir.name)})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0",onClick:()=>In(ir.name,vr),"aria-label":`Remove file ${ir.name}`,children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]},ir.messageId)})]}):jsxRuntime.jsx("p",{className:"text-muted-foreground text-xs italic",children:"No files attached yet."})})})]}),Lr?jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(CodeXml,{className:"w-4 h-4 mr-2"}),"Developer Log"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-xs font-mono",children:[jsxRuntime.jsx(DebugMessageDisplay,{debugMessages:ft}),jsxRuntime.jsx("div",{ref:Hn})]})})]}):jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(MessageSquareShare,{className:"w-4 h-4 mr-2"}),"Contact Us"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-sm space-y-4",children:[jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Reach out any time"}),jsxRuntime.jsxs("div",{className:"mt-2 space-y-1",children:[jsxRuntime.jsx("a",{className:"block text-base font-semibold text-primary hover:underline",href:"mailto:service@randmar.io",children:"service@randmar.io"}),jsxRuntime.jsx("a",{className:"block text-base font-semibold text-primary hover:underline",href:"tel:+18003616244",children:"1 (800) 361-6244"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Customer reps:"}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Loraine Fraraccio"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:loraine@randmar.io",children:"loraine@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 314"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: Quebec"})]}),jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Massimo Fiore"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:massimo@randmar.io",children:"massimo@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 305"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: Ontario"})]}),jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Kevin Dusik"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:kevin@randmar.io",children:"kevin@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 150"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: British-Colombia"})]})]})]})]})})]}),jsxRuntime.jsx("div",{className:"p-3 border-t border-border/80",children:jsxRuntime.jsxs(Button$1,{className:"w-full",variant:"secondary",onClick:()=>jn("Send me the Summary of the conversation by email",null,null),type:"button",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4 mr-2"}),"Summarize to Email"]})}),jsxRuntime.jsx("div",{className:"mt-auto p-3 border-t border-border/80",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-center space-x-3 w-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Powered by Gemini"}),jsxRuntime.jsx(GeminiIcon,{})]}),jsxRuntime.jsxs("div",{className:"flex-1 max-w-[160px]",children:[jsxRuntime.jsx(Progress,{value:Math.round((Ht||0)*100),className:"h-2"}),jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground mt-1",children:[jsxRuntime.jsx("span",{children:"Context"}),jsxRuntime.jsxs("span",{children:[Math.round((Ht||0)*100),"%"]})]})]})]})})]})})]}):jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"})}));AIChatLayout.displayName="AIChatLayout";const GeminiIcon=({className:e="h-4 w-4"})=>jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",className:cn("flex-none leading-none",e),children:[jsxRuntime.jsx("title",{children:"Gemini"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"var(--info)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-0)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-1)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-2)"}),jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"var(--success)"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"var(--success)",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[jsxRuntime.jsx("stop",{stopColor:"var(--primary)"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"var(--primary)",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"var(--warning)"}),jsxRuntime.jsx("stop",{offset:".46",stopColor:"var(--warning)",stopOpacity:"0"})]})]})]}),ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY="randmarcomps.assistantPromptShortcuts.v1";function resolveRoutePath(e,t){return(e.startsWith("/")?e:`/${e}`).replace(":appID",t)}function isRoutePathActive(e,t){return t==="/"?e==="/":e===t||e.startsWith(`${t}/`)}const Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,chatUserName:s,appID:a,chatRoutePath:o},l)=>{const c=e.filter(Ft=>Ft.showInNav),d=React.useRef(null),f=React.useRef(null),R=React.useRef(null),[S,te]=React.useState(!1),[A,rt]=React.useState([]),[st,it]=React.useState(!1),[at,ot]=React.useState(!1),[lt,ut]=React.useState(""),[ct,dt]=React.useState(""),[pt,mt]=React.useState({}),{isMobile:Rt,setOpenMobile:yt}=useSidebar(),It=reactRouterDom.useLocation(),{data:ft}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsHasUnreadsQuery({routeApplicationId:a}),{hasUnreads:Ct}=useChat();React.useEffect(()=>{if(!(typeof window>"u"))try{const Ft=window.localStorage.getItem(ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY);if(!Ft){rt([]),it(!0);return}const zt=JSON.parse(Ft);if(!Array.isArray(zt))throw new Error("Invalid shortcuts data");const Jt=zt;if(!Jt.every(sr=>typeof sr=="object"&&sr!==null&&typeof sr.id=="string"&&typeof sr.title=="string"&&typeof sr.prompt=="string"&&typeof sr.createdAt=="number"))throw new Error("Invalid shortcuts shape");rt(Jt),it(!0)}catch{rt([]),it(!0)}},[]),React.useEffect(()=>{if(st&&!(typeof window>"u"))try{window.localStorage.setItem(ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY,JSON.stringify(A))}catch{}},[A,st]);const Mt=React.useCallback(()=>{ut(""),dt(""),mt({})},[]),Dt=React.useCallback((Ft,zt=null,Jt=null,Qt)=>{te(!0),setTimeout(()=>{d.current?.focus(),f.current&&(Qt?.clear?f.current.sendMessageToAssistantWithClear(Ft,zt,Jt):f.current.sendMessageToAssistant(Ft,zt,Jt))},100)},[]),Vt=React.useCallback(()=>{yt(!1)},[yt]);React.useImperativeHandle(l,()=>({sendMessageToAssistant:(Ft,zt,Jt)=>{Dt(Ft,zt,Jt)},sendMessageToAssistantWithClear(Ft,zt,Jt){Dt(Ft,zt,Jt,{clear:!0})}}));const Ht=Ft=>{Ft?.preventDefault();const zt=lt.trim(),Jt=ct.trim(),Qt={};if(zt||(Qt.title="Short title is required."),Jt||(Qt.prompt="Prompt is required."),Qt.title||Qt.prompt){mt(Qt);return}const sr=(()=>{try{return globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`}catch{return`${Date.now()}-${Math.random()}`}})();rt(lr=>[...lr,{id:sr,title:zt,prompt:Jt,createdAt:Date.now()}]),ot(!1),Mt()},$t=c.find(Ft=>isRoutePathActive(It.pathname,resolveRoutePath(Ft.path,a)))?.label??"None";return jsxRuntime.jsxs(Sidebar,{className:"border-r border-sidebar-border",children:[jsxRuntime.jsx(SidebarHeader,{className:"border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx(ApiImage,{path:"/images/RandmarIcon.svg",alt:"Randmar Icon",className:"h-4 w-4 filter brightness-0 saturate-100 invert"})}),jsxRuntime.jsx("span",{className:"font-semibold text-lg",children:n})]})}),jsxRuntime.jsx(SidebarContent,{className:"py-4 bg-sidebar text-sidebar-foreground",children:Rt?jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col px-4 pb-4 pt-2",children:[jsxRuntime.jsxs("div",{className:"px-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-sidebar-foreground/70",children:"App Launchpad"}),jsxRuntime.jsxs("p",{className:"mt-1 text-sm text-sidebar-foreground/85",children:["Current: ",jsxRuntime.jsx("span",{className:"font-semibold text-sidebar-foreground",children:$t})]})]}),jsxRuntime.jsx("div",{className:"mt-4 grid grid-cols-3 gap-3",children:c.map(Ft=>{const zt=Ft.icon??AppWindow,Jt=resolveRoutePath(Ft.path,a),Qt=isRoutePathActive(It.pathname,Jt);return jsxRuntime.jsxs(reactRouterDom.Link,{to:Jt,"aria-current":Qt?"page":void 0,onClickCapture:Vt,className:cn("flex min-h-24 min-w-0 flex-col items-center justify-center gap-2 rounded-xl border px-2 py-3 text-center text-xs font-medium leading-tight transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring","border-sidebar-border/70 bg-sidebar-accent/30 text-sidebar-foreground hover:bg-sidebar-accent",Qt&&"border-sidebar-ring bg-sidebar-accent text-sidebar-accent-foreground"),children:[jsxRuntime.jsx(zt,{className:"h-9 w-9 shrink-0"}),jsxRuntime.jsx("span",{className:"line-clamp-2",children:Ft.label??Ft.key})]},Ft.key)})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(SidebarMenu,{children:[jsxRuntime.jsxs(Dialog,{open:at,onOpenChange:Ft=>{ot(Ft),Ft||Mt()},children:[jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(SidebarMenuButton,{className:"px-6",children:[jsxRuntime.jsx(Plus,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Add a prompt"})]})})}),jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-md",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Add a saved prompt"}),jsxRuntime.jsx(DialogDescription,{children:"Create a reusable assistant prompt shortcut for this portal."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:Ht,children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"randmar-prompt-shortcut-title",children:"Short Title"}),jsxRuntime.jsx(Input,{id:"randmar-prompt-shortcut-title",value:lt,onChange:Ft=>{ut(Ft.target.value),pt.title&&mt(zt=>({...zt,title:void 0}))},"aria-invalid":!!pt.title,"aria-describedby":pt.title?"randmar-prompt-shortcut-title-error":void 0,autoFocus:!0}),pt.title?jsxRuntime.jsx("p",{id:"randmar-prompt-shortcut-title-error",className:"text-xs text-destructive",children:pt.title}):null]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"randmar-prompt-shortcut-prompt",children:"Prompt"}),jsxRuntime.jsx(Textarea,{id:"randmar-prompt-shortcut-prompt",value:ct,onChange:Ft=>{dt(Ft.target.value),pt.prompt&&mt(zt=>({...zt,prompt:void 0}))},"aria-invalid":!!pt.prompt,"aria-describedby":pt.prompt?"randmar-prompt-shortcut-prompt-error":void 0,className:"min-h-28"}),pt.prompt?jsxRuntime.jsx("p",{id:"randmar-prompt-shortcut-prompt-error",className:"text-xs text-destructive",children:pt.prompt}):null]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(DialogClose,{asChild:!0,children:jsxRuntime.jsx(Button$1,{type:"button",variant:"outline",children:"Cancel"})}),jsxRuntime.jsx(Button$1,{type:"submit",children:"Save"})]})]})]})]}),A.map(Ft=>jsxRuntime.jsxs(SidebarMenuItem,{children:[jsxRuntime.jsxs(SidebarMenuButton,{className:"px-6",onClick:()=>Dt(Ft.prompt,null,null,{clear:!0}),children:[jsxRuntime.jsx(MessageSquareText,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:Ft.title})]}),jsxRuntime.jsx(SidebarMenuAction,{showOnHover:!0,"aria-label":`Delete prompt: ${Ft.title}`,className:"text-sidebar-foreground/70 hover:text-destructive",onClick:zt=>{zt.preventDefault(),zt.stopPropagation(),rt(Jt=>Jt.filter(Qt=>Qt.id!==Ft.id))},children:jsxRuntime.jsx(Minus,{className:"h-4 w-4"})})]},Ft.id))]}),jsxRuntime.jsx(SidebarSeparator,{className:"my-2"}),jsxRuntime.jsx(SidebarMenu,{children:c.map(Ft=>{const zt=Ft.icon,Jt=resolveRoutePath(Ft.path,a),Qt=isRoutePathActive(It.pathname,Jt);return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,isActive:Qt,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:Jt,className:"transition-colors hover:bg-muted px-6",children:[zt&&jsxRuntime.jsx(zt,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:Ft.label})]})})},Ft.key)})})]})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar text-sidebar-foreground",children:[jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:te,children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{ref:R,size:"lg",className:"collapse md:visible flex-grow",onClick:()=>setTimeout(()=>d.current?.focus(),50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:o,onClickCapture:Vt,children:jsxRuntime.jsx(Button$1,{size:"icon",className:Ct||ft?.HasUnreads===!0?"pulse-glow bg-background hover:bg-muted text-foreground":"",children:jsxRuntime.jsx(MessageSquare,{className:"h-5 w-5"})})})]}),jsxRuntime.jsx(DialogContent,{className:"randmar-assistant-dialog max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,overlayClassName:"randmar-assistant-overlay",showOverlay:S,children:jsxRuntime.jsx(AIChatLayout,{className:"h-[85vh]",ref:f,inputRef:d,userId:a,userName:s??"Unknown user",isOpen:S,onRequestOpen:()=>{te(!0),setTimeout(()=>d.current?.focus(),50)}})})]}),t]})]})}),Layout=React.forwardRef(({children:e,appID:t,rightMenu:n,routes:s,footer:a,handleValidSearch:o,dashboardTitle:l,onSignOut:c,searchPlaceholder:d,chatUserName:f,chatRef:R,chatRoutePath:S},te)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:"flex grow",children:[jsxRuntime.jsx(Navbar,{appID:t,routes:s,footer:a,dashboardTitle:l,chatUserName:f,ref:R,chatRoutePath:S}),jsxRuntime.jsx(Topbar,{ref:te,onSignOut:c,rightMenu:n,handleValidSearch:o,searchPlaceholder:d}),jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col",children:[jsxRuntime.jsx("main",{className:"mt-16 flex-1 overflow-x-clip","data-rm-main-content-region":"true",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const salesChannels=[{id:"online-store",label:"Online store (Shopify, Amazon, etc.)"},{id:"brick-and-mortar",label:"Brick-and-mortar (Physical Store)"},{id:"marketplace",label:"Marketplace seller (eBay, Walmart, etc.)"},{id:"b2b",label:"B2B wholesale"},{id:"other-channel",label:"Other (please specify)"}],markets=[{id:"canada",label:"Canada - Nationwide"},{id:"ontario",label:"Ontario & Quebec"},{id:"atlantic",label:"Atlantic Provinces (NS, NB, PEI, NL)"},{id:"prairie",label:"Prairie (Saskatchewan, Manitoba)"},{id:"western",label:"Western Provinces (BC, Alberta, etc.)"},{id:"united-states",label:"United States"},{id:"other-market",label:"Other (please specify)"}];function ManufacturerGetStartedButton({applicationId:e,manufacturer:t}){const{toast:n}=useToast(),[s,a]=React.useState(!1),[o,l]=React.useState(!1),[c,d]=React.useState(!1),[f,R]=React.useState(""),[S,te]=React.useState(""),[A,rt]=React.useState(!1),[st,it]=React.useState(""),[at,ot]=React.useState(""),[lt,ut]=React.useState([]),[ct,dt]=React.useState(""),[pt,mt]=React.useState(""),[Rt,yt]=React.useState([]),[It,ft]=React.useState(""),[Ct,Mt]=React.useState(""),[Dt]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),Vt=()=>{R(""),te("")},Ht=()=>{it(""),ot(""),ut([]),dt(""),mt(""),yt([]),ft(""),Mt("")},$t=()=>{t.PartnerRegistrationLink?a(!0):t.OpenToWork&&l(!0)},Ft=Zt=>{if(Zt.preventDefault(),!c){if(!f.trim()){te("Qualification ID is required");return}d(!0),Dt({routeApplicationId:e,partnerId:t.ManufacturerId??"",message:`Hello! I'd like to get started with you. Here's my Qualification ID: ${f}`}).then(cr=>{if(cr.error){console.error(cr.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}n({title:"Information sent to the manufacturer",description:"Check your chats later.",variant:"success"}),a(!1),Vt()}).catch(cr=>{console.error(cr),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{d(!1)})}},zt=Zt=>{if(Zt.preventDefault(),A)return;ot(""),dt(""),ft("");let cr=!1;if(st.trim().length<10&&(ot("Please provide a brief description of your business (minimum 10 characters)"),cr=!0),lt.length===0&&(dt("Please select at least one sales channel"),cr=!0),Rt.length===0&&(ft("Please select at least one market"),cr=!0),cr)return;const qt=salesChannels.filter(Xt=>lt.includes(Xt.id)).map(Xt=>Xt.label);pt&&qt.push(`Other: ${pt}`);const nr=markets.filter(Xt=>Rt.includes(Xt.id)).map(Xt=>Xt.label);Ct&&nr.push(`Other: ${Ct}`);const Kt=["Hello! I'd like to introduce my business:",`**Business Description:** ${st}`,`**Sales Channels:** ${qt.join(", ")}`,`**Markets:** ${nr.join(", ")}`].join(`
|
|
511
|
+
`),ni=React.useCallback(ir=>{zr(),Ar(ir.id),Ut(ti(ir.content))},[zr]),Ln=React.useCallback(()=>{Ar(null),Ut("")},[]),ii=React.useCallback((ir,hr)=>{const vr=hr.trim();if(!vr){yn({kind:"error",title:"Nothing to save",description:"Edited message can't be empty."},5e3);return}const kr=ri(vr),Nr=(()=>{const Mr=Gr?.messages??[],Fr=Mr.findIndex(Jr=>Jr.id===ir);return Fr===-1?jr(Gr):Mr.slice(0,Fr+1).reduce((Jr,an)=>Jr+(an.fromPartnerID===ASSISTANT_ID?1:0),0)})();qt(Mr=>Mr.map(Fr=>{if(Fr.partner1!==ASSISTANT_ID&&Fr.partner2!==ASSISTANT_ID)return Fr;const Jr=Fr.messages??[],an=Jr.findIndex(mn=>mn.id===ir);if(an===-1)return Fr;const An={...Jr[an],content:kr},on=[...Jr.slice(0,an),An];return{...Fr,messages:on}})),br(Mr=>Mr.filter(Fr=>Fr.messageId!==ir)),Ln(),Or(Nr),Vt(ir,kr)},[Gr,Ln,jr,Vt,yn,Or]),si=React.useCallback(ir=>{zr(),Ar(null),Ut("");const hr=(()=>{const vr=Gr?.messages??[],kr=vr.findIndex(Nr=>Nr.id===ir.id);return kr===-1?jr(Gr):vr.slice(0,kr+1).reduce((Nr,Mr)=>Nr+(Mr.fromPartnerID===ASSISTANT_ID?1:0),0)})();qt(vr=>vr.map(kr=>{if(kr.partner1!==ASSISTANT_ID&&kr.partner2!==ASSISTANT_ID)return kr;const Nr=kr.messages??[],Mr=Nr.findIndex(Fr=>Fr.id===ir.id);return Mr===-1?kr:{...kr,messages:Nr.slice(0,Mr+1)}})),Or(hr),Vt(ir.id,ir.content)},[Gr,jr,Vt,Or,zr]);React.useEffect(()=>{!f||!It||setTimeout(()=>rn(),50)},[It,rn,gn,f]);const Hn=React.useRef(null);React.useEffect(()=>{Hn.current?.scrollIntoView({behavior:"smooth"})},[ft]);const Dn=(()=>{if(!fn)return"Attach files";const ir=ur.slice(0,5).map(vr=>vr.name).join(", "),hr=dn>5?` +${dn-5} more`:"";return`Attached (${dn}): ${ir}${hr}`})(),Wn=ir=>fn?jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-1 rounded-2xl bg-background/70 p-2 shadow-xs ring-1 ring-border/80",ir),role:"group","aria-label":`Attached files (${dn})`,children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Attached"}),ur.map((hr,vr)=>jsxRuntime.jsxs("div",{className:"inline-flex min-w-0 items-center gap-1 rounded-full bg-muted px-3 py-1 text-xs text-foreground ring-1 ring-border/80",children:[jsxRuntime.jsx(File$1,{className:"h-3.5 w-3.5 shrink-0"}),jsxRuntime.jsx("span",{className:"max-w-[16rem] truncate",title:hr.name,children:truncateFilename(hr.name)}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-5 w-5 shrink-0 rounded-full hover:bg-muted/80",onClick:()=>Pn(vr),"aria-label":`Remove attached file ${hr.name}`,type:"button",children:jsxRuntime.jsx(X$2,{className:"h-3.5 w-3.5"})})]},`${hr.name}_${hr.lastModified}_${hr.size}_${vr}`))]}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Will be included with your next message."})]}):null,Un=jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsxs("div",{className:"text-center text-muted-foreground",children:[jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),jsxRuntime.jsx("p",{children:"Loading API functions..."})]})}),qn=jsxRuntime.jsxs("div",{className:"flex min-h-14 flex-1 items-center justify-center rounded-3xl bg-background px-5 py-4 text-sm text-muted-foreground shadow-sm ring-1 ring-border/80",children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Preparing SOP files..."]});return f?jsxRuntime.jsxs("div",{className:cn("flex h-full min-h-0 w-full overflow-hidden",s),children:[jsxRuntime.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:Dr()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"sticky top-0 z-20 flex items-center border-b bg-background p-4 rounded-tl-lg",children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Avatar,{className:"h-8 w-8 flex-shrink-0 rounded-none",children:jsxRuntime.jsx(Bot,{className:"text-primary fill-background min-h-full"})}),jsxRuntime.jsx("div",{className:"ml-3 font-medium",children:"Randmar Assistant"}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"sm",className:"ml-auto",confirmationDialog:{title:"Report Issue",content:"This action will send a copy of your chat to Randmar. Send it?",onConfirm:()=>ei()},disabled:c,children:c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-5 w-5 mr-2 animate-spin"}),"Sending Feedback..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(MessageSquareShare,{className:"h-5 w-5 mr-2"}),"Report Issue"]})}),jsxRuntime.jsxs(Button$1,{className:"ml-1",onClick:()=>Mn(),title:zt,"aria-label":zt,children:[jsxRuntime.jsx(MessageCircleX,{className:"h-5 w-5"})," ",zt]}),Ct!==""&&jsxRuntime.jsxs(Button$1,{className:"ml-1",variant:"destructive",onClick:()=>zr(),children:[jsxRuntime.jsx(Square,{className:"h-5 w-5"})," Stop"]})]})}),jsxRuntime.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[jsxRuntime.jsx(Input,{type:"file",onChange:En,className:"hidden",ref:Er,multiple:!0}),$r&&jsxRuntime.jsx("div",{className:"px-6 pt-4",children:jsxRuntime.jsxs("div",{role:"status","aria-live":"polite",className:cn("flex items-start justify-between gap-3 rounded-lg border p-3 text-sm",$r.kind==="error"&&"border-destructive/30 bg-destructive/10 text-foreground",$r.kind==="success"&&"border-success/30 bg-success/10 text-foreground",$r.kind==="info"&&"border-border bg-background text-foreground"),children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"font-semibold",children:$r.title}),$r.description&&jsxRuntime.jsx("div",{className:cn("mt-0.5",$r.kind==="error"&&"text-destructive",$r.kind==="success"&&"text-success",$r.kind==="info"&&"text-muted-foreground"),children:$r.description})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-7 w-7 shrink-0",onClick:()=>Wr(null),"aria-label":"Dismiss notice",type:"button",children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]})}),It?gn?jsxRuntime.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto bg-muted/30 p-6 rounded-bl-lg",children:jsxRuntime.jsx("div",{className:"mx-auto flex min-h-full w-full max-w-4xl items-center",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Hi there!"}),jsxRuntime.jsx("h1",{className:"mt-2 text-2xl leading-tight font-semibold text-foreground",children:"How can I assist you with your Randmar tasks today?"}),jsxRuntime.jsx("form",{className:"mt-6",onSubmit:qr,children:xn()})]})})}):jsxRuntime.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[jsxRuntime.jsxs(ScrollArea,{className:"min-h-0 flex-1 bg-muted/30 pl-2 pr-2",children:[jsxRuntime.jsx(ChatMessages,{messages:Gr?.messages??[],appID:e,isAssistantChat:!0,botStatus:Ct,hideSenderNames:!0,editableUserMessages:!0,editingMessageId:Cr,editingDraft:Vr,onEditingDraftChange:Ut,onStartEditUserMessage:ni,onCancelEditUserMessage:Ln,onSaveEditUserMessage:ii,onRetryUserMessage:si}),jsxRuntime.jsx("div",{ref:Wt})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 flex-col gap-2 border-r border-t p-4",children:[Yr?qn:jsxRuntime.jsxs("div",{className:"flex items-end gap-2",children:[jsxRuntime.jsx(Textarea,{ref:wr,placeholder:"Type a message...",value:Qt,onPaste:xr,onChange:ir=>sr(ir.target.value),onKeyDown:ir=>{ir.key!=="Enter"||ir.shiftKey||(ir.preventDefault(),!(!It||Ct||Yr)&&_r())},className:"flex-1 resize-none field-sizing-content max-h-[30em]"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Button$1,{size:"icon",variant:"default",className:Gr?.pending?"collapse":"ml-2 h-8 w-8",disabled:!It||!!Ct||Yr,onClick:_r,children:jsxRuntime.jsx(Send,{className:"h-6 w-6"})}),jsxRuntime.jsxs(Button$1,{size:"icon",variant:fn?"secondary":"default",onClick:Kr,title:Dn,"aria-label":Dn,className:cn(Gr?.pending?"collapse":"relative ml-2 h-8 w-8",fn&&"ring-2 ring-ring/25"),disabled:!It||Ct!==""||Gr?.pending,children:[jsxRuntime.jsx(Paperclip,{className:"h-5 w-5"}),fn&&jsxRuntime.jsx("span",{className:"absolute -right-1 -top-1 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[11px] font-semibold text-primary-foreground shadow-sm",children:dn})]})]})]}),Wn()]})]}):jsxRuntime.jsx("div",{className:"flex-1 bg-muted/30",children:Un})]})]}):Un}),jsxRuntime.jsx("div",{"data-thin":!0,className:"flex h-full basis-[300px] shrink-0 border-l sm:basis-[300px] lg:basis-[300px]",children:jsxRuntime.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col rounded-r-lg border-r bg-muted/30 text-foreground",children:[jsxRuntime.jsxs("div",{className:"space-y-3 border-b border-border/80 p-4 pt-6",children:[jsxRuntime.jsxs("h4",{className:"flex items-center text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(Settings,{className:"w-4 h-4 mr-2"}),"Settings"]}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsx(Label$2,{htmlFor:"show-dev-logs-checkbox",className:"text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:"Show Dev Logs"}),jsxRuntime.jsx(Checkbox,{id:"show-dev-logs-checkbox",checked:Lr,onCheckedChange:ir=>tn(ir===!0),"aria-label":"Show developer logs"})]})]}),jsxRuntime.jsxs("div",{className:"flex flex-col border-b border-border/80 h-24",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2"}),"Attached Files"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsx("div",{className:"py-2 text-sm",children:ur.length>0||mr.length>0?jsxRuntime.jsxs("div",{className:"space-y-2",children:[ur.map((ir,hr)=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 text-primary",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsxs("span",{title:`${ir.name} (pending)`,children:[truncateFilename(ir.name)," (pending)"]})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0",onClick:()=>Pn(hr),"aria-label":`Remove pending file ${ir.name}`,children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]},`${ir.name}_${ir.lastModified}_${ir.size}_${hr}`)),mr.slice().reverse().map((ir,hr)=>{const vr=mr.length-1-hr;return jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2 text-foreground hover:text-primary transition-colors duration-150",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center",children:[jsxRuntime.jsx(File$1,{className:"w-4 h-4 mr-2 flex-shrink-0"}),jsxRuntime.jsx("span",{title:ir.name,children:truncateFilename(ir.name)})]}),jsxRuntime.jsx(Button$1,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0",onClick:()=>In(ir.name,vr),"aria-label":`Remove file ${ir.name}`,children:jsxRuntime.jsx(X$2,{className:"h-4 w-4"})})]},ir.messageId)})]}):jsxRuntime.jsx("p",{className:"text-muted-foreground text-xs italic",children:"No files attached yet."})})})]}),Lr?jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(CodeXml,{className:"w-4 h-4 mr-2"}),"Developer Log"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-xs font-mono",children:[jsxRuntime.jsx(DebugMessageDisplay,{debugMessages:ft}),jsxRuntime.jsx("div",{ref:Hn})]})})]}):jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsxs("h4",{className:"flex-shrink-0 flex items-center p-4 pb-2 text-xs font-semibold tracking-wider text-muted-foreground uppercase",children:[jsxRuntime.jsx(MessageSquareShare,{className:"w-4 h-4 mr-2"}),"Contact Us"]}),jsxRuntime.jsx(ScrollArea,{className:"flex-1 px-4",children:jsxRuntime.jsxs("div",{className:"py-2 text-sm space-y-4",children:[jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Reach out any time"}),jsxRuntime.jsxs("div",{className:"mt-2 space-y-1",children:[jsxRuntime.jsx("a",{className:"block text-base font-semibold text-primary hover:underline",href:"mailto:service@randmar.io",children:"service@randmar.io"}),jsxRuntime.jsx("a",{className:"block text-base font-semibold text-primary hover:underline",href:"tel:+18003616244",children:"1 (800) 361-6244"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Customer reps:"}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Loraine Fraraccio"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:loraine@randmar.io",children:"loraine@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 314"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: Quebec"})]}),jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Massimo Fiore"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:massimo@randmar.io",children:"massimo@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 305"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: Ontario"})]}),jsxRuntime.jsxs("div",{className:"rounded-md border border-border bg-background p-3",children:[jsxRuntime.jsx("div",{className:"font-medium",children:"Kevin Dusik"}),jsxRuntime.jsx("div",{className:"text-muted-foreground",children:jsxRuntime.jsx("a",{className:"text-primary hover:underline",href:"mailto:kevin@randmar.io",children:"kevin@randmar.io"})}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Extension: 150"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Location: British-Colombia"})]})]})]})]})})]}),jsxRuntime.jsx("div",{className:"p-3 border-t border-border/80",children:jsxRuntime.jsxs(Button$1,{className:"w-full",variant:"secondary",onClick:()=>jn("Send me the Summary of the conversation by email",null,null),type:"button",children:[jsxRuntime.jsx(Mail,{className:"h-4 w-4 mr-2"}),"Summarize to Email"]})}),jsxRuntime.jsx("div",{className:"mt-auto p-3 border-t border-border/80",children:jsxRuntime.jsxs("div",{className:"flex items-center justify-center space-x-3 w-full",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Powered by Gemini"}),jsxRuntime.jsx(GeminiIcon,{})]}),jsxRuntime.jsxs("div",{className:"flex-1 max-w-[160px]",children:[jsxRuntime.jsx(Progress,{value:Math.round((Ht||0)*100),className:"h-2"}),jsxRuntime.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground mt-1",children:[jsxRuntime.jsx("span",{children:"Context"}),jsxRuntime.jsxs("span",{children:[Math.round((Ht||0)*100),"%"]})]})]})]})})]})})]}):jsxRuntime.jsx(LoaderCircle,{className:"h-12 w-12 animate-spin mx-auto mb-4"})}));AIChatLayout.displayName="AIChatLayout";const GeminiIcon=({className:e="h-4 w-4"})=>jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",className:cn("flex-none leading-none",e),children:[jsxRuntime.jsx("title",{children:"Gemini"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"var(--info)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-0)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-1)"}),jsxRuntime.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#lobe-icons-gemini-fill-2)"}),jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"var(--success)"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"var(--success)",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[jsxRuntime.jsx("stop",{stopColor:"var(--primary)"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"var(--primary)",stopOpacity:"0"})]}),jsxRuntime.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"lobe-icons-gemini-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[jsxRuntime.jsx("stop",{stopColor:"var(--warning)"}),jsxRuntime.jsx("stop",{offset:".46",stopColor:"var(--warning)",stopOpacity:"0"})]})]})]}),ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY="randmarcomps.assistantPromptShortcuts.v1";function resolveRoutePath(e,t){return(e.startsWith("/")?e:`/${e}`).replace(":appID",t)}function isRoutePathActive(e,t){return t==="/"?e==="/":e===t||e.startsWith(`${t}/`)}const Navbar=React.forwardRef(({routes:e,footer:t,dashboardTitle:n,chatUserName:s,appID:a,chatRoutePath:o},l)=>{const c=e.filter(Ft=>Ft.showInNav),d=React.useRef(null),f=React.useRef(null),R=React.useRef(null),[S,te]=React.useState(!1),[A,rt]=React.useState([]),[st,it]=React.useState(!1),[at,ot]=React.useState(!1),[lt,ut]=React.useState(""),[ct,dt]=React.useState(""),[pt,mt]=React.useState({}),{isMobile:Rt,setOpenMobile:yt}=useSidebar(),It=reactRouterDom.useLocation(),{data:ft}=useGetV4PartnerByRouteApplicationIdBusinessDevelopmentConversationsHasUnreadsQuery({routeApplicationId:a}),{hasUnreads:Ct}=useChat();React.useEffect(()=>{if(!(typeof window>"u"))try{const Ft=window.localStorage.getItem(ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY);if(!Ft){rt([]),it(!0);return}const zt=JSON.parse(Ft);if(!Array.isArray(zt))throw new Error("Invalid shortcuts data");const Jt=zt;if(!Jt.every(sr=>typeof sr=="object"&&sr!==null&&typeof sr.id=="string"&&typeof sr.title=="string"&&typeof sr.prompt=="string"&&typeof sr.createdAt=="number"))throw new Error("Invalid shortcuts shape");rt(Jt),it(!0)}catch{rt([]),it(!0)}},[]),React.useEffect(()=>{if(st&&!(typeof window>"u"))try{window.localStorage.setItem(ASSISTANT_PROMPT_SHORTCUTS_STORAGE_KEY,JSON.stringify(A))}catch{}},[A,st]);const Mt=React.useCallback(()=>{ut(""),dt(""),mt({})},[]),Dt=React.useCallback((Ft,zt=null,Jt=null,Qt)=>{te(!0),setTimeout(()=>{d.current?.focus(),f.current&&(Qt?.clear?f.current.sendMessageToAssistantWithClear(Ft,zt,Jt):f.current.sendMessageToAssistant(Ft,zt,Jt))},100)},[]),Vt=React.useCallback(()=>{yt(!1)},[yt]);React.useImperativeHandle(l,()=>({sendMessageToAssistant:(Ft,zt,Jt)=>{Dt(Ft,zt,Jt)},sendMessageToAssistantWithClear(Ft,zt,Jt){Dt(Ft,zt,Jt,{clear:!0})}}));const Ht=Ft=>{Ft?.preventDefault();const zt=lt.trim(),Jt=ct.trim(),Qt={};if(zt||(Qt.title="Short title is required."),Jt||(Qt.prompt="Prompt is required."),Qt.title||Qt.prompt){mt(Qt);return}const sr=(()=>{try{return globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`}catch{return`${Date.now()}-${Math.random()}`}})();rt(lr=>[...lr,{id:sr,title:zt,prompt:Jt,createdAt:Date.now()}]),ot(!1),Mt()},$t=c.find(Ft=>isRoutePathActive(It.pathname,resolveRoutePath(Ft.path,a)))?.label??"None";return jsxRuntime.jsxs(Sidebar,{className:"border-r border-sidebar-border",children:[jsxRuntime.jsx(SidebarHeader,{className:"border-b border-sidebar-border px-6 h-16 justify-center bg-sidebar text-sidebar-foreground",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex items-center justify-center",children:jsxRuntime.jsx(ApiImage,{path:"/images/RandmarIcon.svg",alt:"Randmar Icon",className:"h-4 w-4 filter brightness-0 saturate-100 invert"})}),jsxRuntime.jsx("span",{className:"font-semibold text-lg",children:n})]})}),jsxRuntime.jsx(SidebarContent,{className:"py-4 bg-sidebar text-sidebar-foreground",children:Rt?jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col px-4 pb-4 pt-2",children:[jsxRuntime.jsxs("div",{className:"px-1",children:[jsxRuntime.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-sidebar-foreground/70",children:"App Launchpad"}),jsxRuntime.jsxs("p",{className:"mt-1 text-sm text-sidebar-foreground/85",children:["Current: ",jsxRuntime.jsx("span",{className:"font-semibold text-sidebar-foreground",children:$t})]})]}),jsxRuntime.jsx("div",{className:"mt-4 grid grid-cols-3 gap-3",children:c.map(Ft=>{const zt=Ft.icon??AppWindow,Jt=resolveRoutePath(Ft.path,a),Qt=isRoutePathActive(It.pathname,Jt);return jsxRuntime.jsxs(reactRouterDom.Link,{to:Jt,"aria-current":Qt?"page":void 0,onClickCapture:Vt,className:cn("flex min-h-24 min-w-0 flex-col items-center justify-center gap-2 rounded-xl border px-2 py-3 text-center text-xs font-medium leading-tight transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring","border-sidebar-border/70 bg-sidebar-accent/30 text-sidebar-foreground hover:bg-sidebar-accent",Qt&&"border-sidebar-ring bg-sidebar-accent text-sidebar-accent-foreground"),children:[jsxRuntime.jsx(zt,{className:"h-9 w-9 shrink-0"}),jsxRuntime.jsx("span",{className:"line-clamp-2",children:Ft.label??Ft.key})]},Ft.key)})})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(SidebarMenu,{children:[jsxRuntime.jsxs(Dialog,{open:at,onOpenChange:Ft=>{ot(Ft),Ft||Mt()},children:[jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(SidebarMenuButton,{className:"px-6",children:[jsxRuntime.jsx(Plus,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:"Add a prompt"})]})})}),jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-md",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Add a saved prompt"}),jsxRuntime.jsx(DialogDescription,{children:"Create a reusable assistant prompt shortcut for this portal."})]}),jsxRuntime.jsxs("form",{className:"space-y-4",onSubmit:Ht,children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"randmar-prompt-shortcut-title",children:"Short Title"}),jsxRuntime.jsx(Input,{id:"randmar-prompt-shortcut-title",value:lt,onChange:Ft=>{ut(Ft.target.value),pt.title&&mt(zt=>({...zt,title:void 0}))},"aria-invalid":!!pt.title,"aria-describedby":pt.title?"randmar-prompt-shortcut-title-error":void 0,autoFocus:!0}),pt.title?jsxRuntime.jsx("p",{id:"randmar-prompt-shortcut-title-error",className:"text-xs text-destructive",children:pt.title}):null]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"randmar-prompt-shortcut-prompt",children:"Prompt"}),jsxRuntime.jsx(Textarea,{id:"randmar-prompt-shortcut-prompt",value:ct,onChange:Ft=>{dt(Ft.target.value),pt.prompt&&mt(zt=>({...zt,prompt:void 0}))},"aria-invalid":!!pt.prompt,"aria-describedby":pt.prompt?"randmar-prompt-shortcut-prompt-error":void 0,className:"min-h-28"}),pt.prompt?jsxRuntime.jsx("p",{id:"randmar-prompt-shortcut-prompt-error",className:"text-xs text-destructive",children:pt.prompt}):null]}),jsxRuntime.jsxs(DialogFooter,{children:[jsxRuntime.jsx(DialogClose,{asChild:!0,children:jsxRuntime.jsx(Button$1,{type:"button",variant:"outline",children:"Cancel"})}),jsxRuntime.jsx(Button$1,{type:"submit",children:"Save"})]})]})]})]}),A.map(Ft=>jsxRuntime.jsxs(SidebarMenuItem,{children:[jsxRuntime.jsxs(SidebarMenuButton,{className:"px-6",onClick:()=>Dt(Ft.prompt,null,null,{clear:!0}),children:[jsxRuntime.jsx(MessageSquareText,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:Ft.title})]}),jsxRuntime.jsx(SidebarMenuAction,{showOnHover:!0,"aria-label":`Delete prompt: ${Ft.title}`,className:"text-sidebar-foreground/70 hover:text-destructive",onClick:zt=>{zt.preventDefault(),zt.stopPropagation(),rt(Jt=>Jt.filter(Qt=>Qt.id!==Ft.id))},children:jsxRuntime.jsx(Minus,{className:"h-4 w-4"})})]},Ft.id))]}),jsxRuntime.jsx(SidebarSeparator,{className:"my-2"}),jsxRuntime.jsx(SidebarMenu,{children:c.map(Ft=>{const zt=Ft.icon,Jt=resolveRoutePath(Ft.path,a),Qt=isRoutePathActive(It.pathname,Jt);return jsxRuntime.jsx(SidebarMenuItem,{children:jsxRuntime.jsx(SidebarMenuButton,{asChild:!0,isActive:Qt,children:jsxRuntime.jsxs(reactRouterDom.Link,{to:Jt,className:"transition-colors hover:bg-muted px-6",children:[zt&&jsxRuntime.jsx(zt,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:Ft.label})]})})},Ft.key)})})]})}),jsxRuntime.jsxs(SidebarFooter,{className:"border-t border-sidebar-border p-4 bg-sidebar text-sidebar-foreground",children:[jsxRuntime.jsxs(Dialog,{open:S,onOpenChange:te,children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(DialogTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{ref:R,size:"lg",className:"collapse md:visible flex-grow",onClick:()=>setTimeout(()=>d.current?.focus(),50),children:[jsxRuntime.jsx(Bot,{}),"Assistant"]})}),jsxRuntime.jsx(reactRouterDom.Link,{to:o,onClickCapture:Vt,children:jsxRuntime.jsx(Button$1,{size:"icon",className:Ct||ft?.HasUnreads===!0?"pulse-glow bg-background hover:bg-muted text-foreground":"",children:jsxRuntime.jsx(MessageSquare,{className:"h-5 w-5"})})})]}),jsxRuntime.jsx(DialogContent,{className:"randmar-assistant-dialog max-w-[85vw] p-0 data-[state=open]:visible data-[state=closed]:invisible",forceMount:!0,animateExit:!1,overlayClassName:"randmar-assistant-overlay",showOverlay:S,children:jsxRuntime.jsx(AIChatLayout,{className:"h-[85vh]",ref:f,inputRef:d,userId:a,userName:s??"Unknown user",isOpen:S,onRequestOpen:()=>{te(!0),setTimeout(()=>d.current?.focus(),50)}})})]}),t]})]})}),Layout=React.forwardRef(({children:e,appID:t,rightMenu:n,routes:s,footer:a,handleValidSearch:o,dashboardTitle:l,onSignOut:c,searchPlaceholder:d,chatUserName:f,chatRef:R,chatRoutePath:S},te)=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(SidebarProvider,{children:jsxRuntime.jsxs("div",{className:`flex grow ${APP_SHELL_HEADER_HEIGHT_TOKEN_CLASS}`,children:[jsxRuntime.jsx(Navbar,{appID:t,routes:s,footer:a,dashboardTitle:l,chatUserName:f,ref:R,chatRoutePath:S}),jsxRuntime.jsx(Topbar,{ref:te,onSignOut:c,rightMenu:n,handleValidSearch:o,searchPlaceholder:d}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[jsxRuntime.jsx("main",{className:`${APP_SHELL_HEADER_OFFSET_CLASS} @container flex-1 overflow-x-clip bg-muted`,"data-rm-main-content-region":"true",children:e}),jsxRuntime.jsx(Toaster,{})]})]})})}));Layout.displayName="Layout";const salesChannels=[{id:"online-store",label:"Online store (Shopify, Amazon, etc.)"},{id:"brick-and-mortar",label:"Brick-and-mortar (Physical Store)"},{id:"marketplace",label:"Marketplace seller (eBay, Walmart, etc.)"},{id:"b2b",label:"B2B wholesale"},{id:"other-channel",label:"Other (please specify)"}],markets=[{id:"canada",label:"Canada - Nationwide"},{id:"ontario",label:"Ontario & Quebec"},{id:"atlantic",label:"Atlantic Provinces (NS, NB, PEI, NL)"},{id:"prairie",label:"Prairie (Saskatchewan, Manitoba)"},{id:"western",label:"Western Provinces (BC, Alberta, etc.)"},{id:"united-states",label:"United States"},{id:"other-market",label:"Other (please specify)"}];function ManufacturerGetStartedButton({applicationId:e,manufacturer:t}){const{toast:n}=useToast(),[s,a]=React.useState(!1),[o,l]=React.useState(!1),[c,d]=React.useState(!1),[f,R]=React.useState(""),[S,te]=React.useState(""),[A,rt]=React.useState(!1),[st,it]=React.useState(""),[at,ot]=React.useState(""),[lt,ut]=React.useState([]),[ct,dt]=React.useState(""),[pt,mt]=React.useState(""),[Rt,yt]=React.useState([]),[It,ft]=React.useState(""),[Ct,Mt]=React.useState(""),[Dt]=usePostV4PartnerByRouteApplicationIdBusinessDevelopmentConversationPartnerAndPartnerIdMutation(),Vt=()=>{R(""),te("")},Ht=()=>{it(""),ot(""),ut([]),dt(""),mt(""),yt([]),ft(""),Mt("")},$t=()=>{t.PartnerRegistrationLink?a(!0):t.OpenToWork&&l(!0)},Ft=Zt=>{if(Zt.preventDefault(),!c){if(!f.trim()){te("Qualification ID is required");return}d(!0),Dt({routeApplicationId:e,partnerId:t.ManufacturerId??"",message:`Hello! I'd like to get started with you. Here's my Qualification ID: ${f}`}).then(cr=>{if(cr.error){console.error(cr.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}n({title:"Information sent to the manufacturer",description:"Check your chats later.",variant:"success"}),a(!1),Vt()}).catch(cr=>{console.error(cr),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{d(!1)})}},zt=Zt=>{if(Zt.preventDefault(),A)return;ot(""),dt(""),ft("");let cr=!1;if(st.trim().length<10&&(ot("Please provide a brief description of your business (minimum 10 characters)"),cr=!0),lt.length===0&&(dt("Please select at least one sales channel"),cr=!0),Rt.length===0&&(ft("Please select at least one market"),cr=!0),cr)return;const qt=salesChannels.filter(Xt=>lt.includes(Xt.id)).map(Xt=>Xt.label);pt&&qt.push(`Other: ${pt}`);const nr=markets.filter(Xt=>Rt.includes(Xt.id)).map(Xt=>Xt.label);Ct&&nr.push(`Other: ${Ct}`);const Kt=["Hello! I'd like to introduce my business:",`**Business Description:** ${st}`,`**Sales Channels:** ${qt.join(", ")}`,`**Markets:** ${nr.join(", ")}`].join(`
|
|
512
512
|
|
|
513
513
|
`);rt(!0),Dt({routeApplicationId:e,partnerId:t.ManufacturerId??"",message:Kt}).then(Xt=>{if(Xt.error){console.error(Xt.error),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"});return}n({title:"Information sent to the manufacturer",description:"Check your chats later.",variant:"success"}),l(!1),Ht()}).catch(Xt=>{console.error(Xt),n({title:"Could not initiate chat",description:"Try again later.",variant:"destructive"})}).finally(()=>{rt(!1)})},Jt=(Zt,cr)=>{ut(qt=>cr?[...qt,Zt]:qt.filter(nr=>nr!==Zt)),dt("")},Qt=(Zt,cr)=>{yt(qt=>cr?[...qt,Zt]:qt.filter(nr=>nr!==Zt)),ft("")},sr=lt.includes("other-channel"),lr=Rt.includes("other-market");return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!t.Qualification&&jsxRuntime.jsxs(Button$1,{onClick:$t,disabled:!t.PartnerRegistrationLink&&!t.OpenToWork,children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Get Started"]}),t.PartnerRegistrationLink&&jsxRuntime.jsx(Dialog,{open:s,onOpenChange:Zt=>{a(Zt)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[400px]",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:t.PublicName}),jsxRuntime.jsxs(DialogDescription,{children:[jsxRuntime.jsx("span",{className:"font-bold",children:"Already qualified?"})," Provide your Qualification ID."]})]}),jsxRuntime.jsxs("form",{onSubmit:Ft,className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"qualificationId",children:"Qualification ID"}),jsxRuntime.jsx(Input,{id:"qualificationId",placeholder:"Enter your qualification ID",value:f,onChange:Zt=>{R(Zt.target.value),te("")}}),S&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:S})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",className:"w-full",disabled:c,children:c?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Applying..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Check,{className:"mr-2 h-4 w-4"}),"Apply for Qualification"]})})})]}),jsxRuntime.jsx(Separator$1,{className:"my-4"}),jsxRuntime.jsxs("div",{className:"text-center space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Don't have a qualification ID?"}),jsxRuntime.jsx(reactRouterDom.Link,{to:t.PartnerRegistrationLink,target:"_blank",children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"w-full",disabled:!t.PartnerRegistrationLink,children:[jsxRuntime.jsx(ExternalLink,{className:"mr-2 h-4 w-4"}),"Register here"]})})]})]})}),jsxRuntime.jsx(Dialog,{open:o,onOpenChange:Zt=>{l(Zt)},children:jsxRuntime.jsxs(DialogContent,{className:"sm:max-w-[768px]",children:[jsxRuntime.jsx(DialogHeader,{children:jsxRuntime.jsx(DialogTitle,{children:"Introduce Yourself"})}),jsxRuntime.jsxs("form",{onSubmit:zt,className:"space-y-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{htmlFor:"businessDescription",children:["Tell Us About Your Business ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Briefly describe your business)"})]}),jsxRuntime.jsx(Textarea,{id:"businessDescription",placeholder:"We are an online retailer specializing in office supplies, serving businesses since 2018...",className:"min-h-[100px]",value:st,onChange:Zt=>{it(Zt.target.value),ot("")}}),at&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:at})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Sales Channel(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select where you currently sell your products)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:salesChannels.map(Zt=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`channel-${Zt.id}`,checked:lt.includes(Zt.id),onCheckedChange:cr=>Jt(Zt.id,cr===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`channel-${Zt.id}`,className:"text-sm font-normal",children:Zt.label})]},Zt.id))}),sr&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:pt,onChange:Zt=>mt(Zt.target.value)}),ct&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:ct})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs(Label$2,{children:["Your Primary Market(s) ",jsxRuntime.jsx("span",{className:"text-sm text-muted-foreground",children:"(Multi-Select which regions you sell to)"})]}),jsxRuntime.jsx("div",{className:"grid grid-cols-2 gap-2",children:markets.map(Zt=>jsxRuntime.jsxs("div",{className:"flex items-start space-x-2",children:[jsxRuntime.jsx(Checkbox,{id:`market-${Zt.id}`,checked:Rt.includes(Zt.id),onCheckedChange:cr=>Qt(Zt.id,cr===!0)}),jsxRuntime.jsx(Label$2,{htmlFor:`market-${Zt.id}`,className:"text-sm font-normal",children:Zt.label})]},Zt.id))}),lr&&jsxRuntime.jsx(Input,{placeholder:"Please specify",value:Ct,onChange:Zt=>Mt(Zt.target.value)}),It&&jsxRuntime.jsx("p",{className:"text-sm font-medium text-destructive",children:It})]}),jsxRuntime.jsx(DialogFooter,{children:jsxRuntime.jsx(Button$1,{type:"submit",disabled:A,children:A?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Submitting..."]}):"Submit"})})]})]})})]})}const DAYS_OF_WEEK=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ManufacturerReorderingCard({manufacturer:e,onSave:t,loading:n=!1,saving:s=!1,readonly:a=!1}){const[o,l]=React.useState({...e}),[c,d]=React.useState({...e});React.useEffect(()=>{d({...e}),l({...e})},[e]);const f=(at,ot)=>{a||l(lt=>({...lt,[at]:ot}))},R=(at,ot)=>{a||l(lt=>({...lt,[at]:ot}))},S=(at,ot)=>{a||l(lt=>({...lt,[at]:ot}))},te=()=>{const at={};return Object.keys(o).forEach(ot=>{const lt=ot;JSON.stringify(o[lt])!==JSON.stringify(c[lt])&&(at[lt]=o[lt])}),at},A=()=>{if(!s&&!a){const at=te();Object.keys(at).length>0&&t(at)}},rt=at=>at===-1?"ASAP":at===void 0||at<0||at>6?"Sunday":DAYS_OF_WEEK[at],st=at=>at==="ASAP"?-1:DAYS_OF_WEEK.indexOf(at),it=Object.keys(te()).length>0;return jsxRuntime.jsxs(Card,{children:[jsxRuntime.jsxs(CardHeader,{children:[n?jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}):jsxRuntime.jsx(CardTitle,{className:"text-lg font-bold",children:"Reordering"}),n?jsxRuntime.jsx(Skeleton,{className:"h-4 w-full mt-2"}):jsxRuntime.jsx(CardDescription,{className:"text-sm",children:"Adjust your reordering settings to control lead times, stocking weeks, minimum orders, and reorder dates, enhancing efficiency in restocking processes."})]}),jsxRuntime.jsx(CardContent,{className:"space-y-6",children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-10"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"}),jsxRuntime.jsx("div",{className:"ml-2 w-12"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-5 w-40"}),jsxRuntime.jsx(Skeleton,{className:"h-10 w-full"})]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"automatic-reordering",checked:o.AutoUpdate,onCheckedChange:at=>f("AutoUpdate",at),disabled:s||a}),jsxRuntime.jsx(Label$2,{htmlFor:"automatic-reordering",children:"Automatic Reordering"})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-6",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"reorder-date",children:"Automatic Reorder Date"}),jsxRuntime.jsxs(Select$1,{value:rt(o.AutoReorderDate),onValueChange:at=>R("AutoReorderDate",st(at)),disabled:s||a,children:[jsxRuntime.jsx(SelectTrigger,{id:"reorder-date",children:jsxRuntime.jsx(SelectValue,{placeholder:"Select day"})}),jsxRuntime.jsxs(SelectContent,{children:[jsxRuntime.jsx(SelectItem,{value:"ASAP",children:"ASAP"}),DAYS_OF_WEEK.map(at=>jsxRuntime.jsx(SelectItem,{value:at,children:at},at))]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"weeks-stocking",children:"Default Weeks of Stocking"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"weeks-stocking",type:"number",value:o.DefaultWeeksOfStocking||"",onChange:at=>R("DefaultWeeksOfStocking",Number(at.target.value)),disabled:s||a}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"weeks"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"minimum-order",children:"Default Minimum Order"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"minimum-order",type:"number",className:"pl-6",value:o.DefaultMinimumOrder||"",onChange:at=>R("DefaultMinimumOrder",Number(at.target.value)),disabled:s||a})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"lead-time",children:"Default Lead Time"}),jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(Input,{id:"lead-time",type:"number",value:o.DefaultLeadTime||"",onChange:at=>R("DefaultLeadTime",Number(at.target.value)),disabled:s||a}),jsxRuntime.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"days"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"maximum-inventory-value",children:"Default Maximum Inventory Value"}),jsxRuntime.jsxs("div",{className:"flex items-center relative",children:[jsxRuntime.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:"$"}),jsxRuntime.jsx(Input,{id:"maximum-inventory-value",type:"number",className:"pl-6",value:o.DefaultMaxInventoryValue||"",onChange:at=>R("DefaultMaxInventoryValue",Number(at.target.value)),disabled:s||a})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx(Label$2,{htmlFor:"order-confirmations",children:"Send Order Confirmations To"}),jsxRuntime.jsx(Input,{id:"order-confirmations",type:"email",value:o.POEmail||"",onChange:at=>S("POEmail",at.target.value),placeholder:"email@example.com",disabled:s||a})]})]})]})}),!a&&jsxRuntime.jsx(CardFooter,{className:"flex justify-end",children:n?jsxRuntime.jsx(Skeleton,{className:"h-10 w-20"}):jsxRuntime.jsxs(Button$1,{onClick:A,disabled:s||!it,children:[s&&jsxRuntime.jsx(LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})})]})}function createSlot(e){const t=createSlotClone(e),n=React__namespace.forwardRef((s,a)=>{const{children:o,...l}=s,c=React__namespace.Children.toArray(o),d=c.find(isSlottable);if(d){const f=d.props.children,R=c.map(S=>S===d?React__namespace.Children.count(f)>1?React__namespace.Children.only(null):React__namespace.isValidElement(f)?f.props.children:null:S);return jsxRuntime.jsx(t,{...l,ref:a,children:React__namespace.isValidElement(f)?React__namespace.cloneElement(f,void 0,R):null})}return jsxRuntime.jsx(t,{...l,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function createSlotClone(e){const t=React__namespace.forwardRef((n,s)=>{const{children:a,...o}=n;if(React__namespace.isValidElement(a)){const l=getElementRef(a),c=mergeProps(o,a.props);return a.type!==React__namespace.Fragment&&(c.ref=s?composeRefs(s,l):l),React__namespace.cloneElement(a,c)}return React__namespace.Children.count(a)>1?React__namespace.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER$1=Symbol("radix.slottable");function isSlottable(e){return React__namespace.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER$1}function mergeProps(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...c)=>{const d=o(...c);return a(...c),d}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function getElementRef(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var POPOVER_NAME="Popover",[createPopoverContext]=createContextScope$2(POPOVER_NAME,[createPopperScope]),usePopperScope=createPopperScope(),[PopoverProvider,usePopoverContext]=createPopoverContext(POPOVER_NAME),Popover$1=e=>{const{__scopePopover:t,children:n,open:s,defaultOpen:a,onOpenChange:o,modal:l=!1}=e,c=usePopperScope(t),d=React__namespace.useRef(null),[f,R]=React__namespace.useState(!1),[S,te]=useControllableState({prop:s,defaultProp:a??!1,onChange:o,caller:POPOVER_NAME});return jsxRuntime.jsx(Root2$7,{...c,children:jsxRuntime.jsx(PopoverProvider,{scope:t,contentId:useId$1(),triggerRef:d,open:S,onOpenChange:te,onOpenToggle:React__namespace.useCallback(()=>te(A=>!A),[te]),hasCustomAnchor:f,onCustomAnchorAdd:React__namespace.useCallback(()=>R(!0),[]),onCustomAnchorRemove:React__namespace.useCallback(()=>R(!1),[]),modal:l,children:n})})};Popover$1.displayName=POPOVER_NAME;var ANCHOR_NAME="PopoverAnchor",PopoverAnchor$1=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopoverContext(ANCHOR_NAME,n),o=usePopperScope(n),{onCustomAnchorAdd:l,onCustomAnchorRemove:c}=a;return React__namespace.useEffect(()=>(l(),()=>c()),[l,c]),jsxRuntime.jsx(Anchor,{...o,...s,ref:t})});PopoverAnchor$1.displayName=ANCHOR_NAME;var TRIGGER_NAME$3="PopoverTrigger",PopoverTrigger$1=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopoverContext(TRIGGER_NAME$3,n),o=usePopperScope(n),l=useComposedRefs(t,a.triggerRef),c=jsxRuntime.jsx(Primitive$4.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":getState$2(a.open),...s,ref:l,onClick:composeEventHandlers(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?c:jsxRuntime.jsx(Anchor,{asChild:!0,...o,children:c})});PopoverTrigger$1.displayName=TRIGGER_NAME$3;var PORTAL_NAME$1="PopoverPortal",[PortalProvider,usePortalContext]=createPopoverContext(PORTAL_NAME$1,{forceMount:void 0}),PopoverPortal=e=>{const{__scopePopover:t,forceMount:n,children:s,container:a}=e,o=usePopoverContext(PORTAL_NAME$1,t);return jsxRuntime.jsx(PortalProvider,{scope:t,forceMount:n,children:jsxRuntime.jsx(Presence,{present:n||o.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:a,children:s})})})};PopoverPortal.displayName=PORTAL_NAME$1;var CONTENT_NAME$3="PopoverContent",PopoverContent$1=React__namespace.forwardRef((e,t)=>{const n=usePortalContext(CONTENT_NAME$3,e.__scopePopover),{forceMount:s=n.forceMount,...a}=e,o=usePopoverContext(CONTENT_NAME$3,e.__scopePopover);return jsxRuntime.jsx(Presence,{present:s||o.open,children:o.modal?jsxRuntime.jsx(PopoverContentModal,{...a,ref:t}):jsxRuntime.jsx(PopoverContentNonModal,{...a,ref:t})})});PopoverContent$1.displayName=CONTENT_NAME$3;var Slot=createSlot("PopoverContent.RemoveScroll"),PopoverContentModal=React__namespace.forwardRef((e,t)=>{const n=usePopoverContext(CONTENT_NAME$3,e.__scopePopover),s=React__namespace.useRef(null),a=useComposedRefs(t,s),o=React__namespace.useRef(!1);return React__namespace.useEffect(()=>{const l=s.current;if(l)return hideOthers(l)},[]),jsxRuntime.jsx(ReactRemoveScroll,{as:Slot,allowPinchZoom:!0,children:jsxRuntime.jsx(PopoverContentImpl,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(e.onCloseAutoFocus,l=>{l.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:composeEventHandlers(e.onPointerDownOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,f=c.button===2||d;o.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:composeEventHandlers(e.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),PopoverContentNonModal=React__namespace.forwardRef((e,t)=>{const n=usePopoverContext(CONTENT_NAME$3,e.__scopePopover),s=React__namespace.useRef(!1),a=React__namespace.useRef(!1);return jsxRuntime.jsx(PopoverContentImpl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(s.current||n.triggerRef.current?.focus(),o.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;n.triggerRef.current?.contains(l)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),PopoverContentImpl=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:R,...S}=e,te=usePopoverContext(CONTENT_NAME$3,n),A=usePopperScope(n);return useFocusGuards(),jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:jsxRuntime.jsx(DismissableLayer,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:R,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onDismiss:()=>te.onOpenChange(!1),children:jsxRuntime.jsx(Content$2,{"data-state":getState$2(te.open),role:"dialog",id:te.contentId,...A,...S,ref:t,style:{...S.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),CLOSE_NAME="PopoverClose",PopoverClose=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopoverContext(CLOSE_NAME,n);return jsxRuntime.jsx(Primitive$4.button,{type:"button",...s,ref:t,onClick:composeEventHandlers(e.onClick,()=>a.onOpenChange(!1))})});PopoverClose.displayName=CLOSE_NAME;var ARROW_NAME="PopoverArrow",PopoverArrow=React__namespace.forwardRef((e,t)=>{const{__scopePopover:n,...s}=e,a=usePopperScope(n);return jsxRuntime.jsx(Arrow,{...a,...s,ref:t})});PopoverArrow.displayName=ARROW_NAME;function getState$2(e){return e?"open":"closed"}var Root2$2=Popover$1,Anchor2=PopoverAnchor$1,Trigger$1=PopoverTrigger$1,Portal=PopoverPortal,Content2$2=PopoverContent$1;const Popover=Root2$2,PopoverTrigger=Trigger$1,PopoverAnchor=Anchor2,PopoverContent=React__namespace.forwardRef(({className:e,align:t="center",sideOffset:n=4,...s},a)=>jsxRuntime.jsx(Portal,{children:jsxRuntime.jsx(Content2$2,{ref:a,align:t,sideOffset:n,className:cn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",e),...s})}));PopoverContent.displayName=Content2$2.displayName;function MultiSelect({options:e,selected:t,onChange:n,placeholder:s="Select items...",disabled:a=!1}){const[o,l]=React__namespace.useState(!1),[c,d]=React__namespace.useState(""),f=React__namespace.useRef(null),[R,S]=React__namespace.useState(void 0),te=React__namespace.useCallback(()=>{f.current&&S(f.current.offsetWidth)},[]);React__namespace.useLayoutEffect(()=>{te()},[te]),React__namespace.useEffect(()=>(window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)),[te]);const A=it=>{n(t.filter(at=>at!==it))},rt=it=>{l(!1),t.includes(it)?n(t.filter(at=>at!==it)):n([...t,it])},st=it=>{it.key==="Enter"&&c&&!e.includes(c)&&!t.includes(c)&&(it.preventDefault(),rt(c),d(""))};return jsxRuntime.jsxs(Popover,{open:o,onOpenChange:l,children:[jsxRuntime.jsx(PopoverTrigger,{asChild:!0,children:jsxRuntime.jsxs(Button$1,{ref:f,variant:"outline",role:"combobox","aria-expanded":o,className:"w-full justify-between h-auto min-h-[40px] py-2",disabled:a,children:[jsxRuntime.jsx("div",{className:"flex flex-wrap gap-1 items-center",children:t.length>0?t.map(it=>jsxRuntime.jsxs(Badge,{variant:"outline",className:"mr-1 mb-1",children:[it,jsxRuntime.jsx("span",{className:"ml-1 cursor-pointer rounded-full outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:at=>{at.preventDefault(),at.stopPropagation(),A(it)},children:jsxRuntime.jsx(X$2,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},it)):jsxRuntime.jsx("span",{className:"text-muted-foreground",children:s})}),jsxRuntime.jsx(ChevronsUpDown,{className:"h-4 w-4 shrink-0 opacity-50 ml-2"})]})}),jsxRuntime.jsx(PopoverContent,{className:"w-full p-0",style:{width:R},children:jsxRuntime.jsxs(Command,{onKeyDown:st,children:[jsxRuntime.jsx(CommandInput,{placeholder:"Search or add custom item...",value:c,onValueChange:d}),jsxRuntime.jsxs(CommandList,{children:[jsxRuntime.jsx(CommandEmpty,{children:"No item found."}),jsxRuntime.jsxs(CommandGroup,{children:[e.filter(it=>!t.includes(it)).map(it=>jsxRuntime.jsxs(CommandItem,{onSelect:()=>rt(it),children:[jsxRuntime.jsx(Check,{className:cn("mr-2 h-4 w-4",t.includes(it)?"opacity-100":"opacity-0")}),it]},it)),c&&!e.includes(c)&&!t.includes(c)&&jsxRuntime.jsxs(CommandItem,{onSelect:()=>rt(c),children:['Add "',c,'"']})]})]})]})})]})}const imgSizeMap$1={sm:100,md:200,lg:300,xl:400};function normalizeImagesListPayload(e){return e==null?null:Array.isArray(e)?e:e&&typeof e=="object"&&"Images"in e&&Array.isArray(e.Images)?e.Images:[]}function withImageSizeParams(e,t,n){try{const s=new URL(e);return s.searchParams.set("width",String(Math.round(t))),s.searchParams.set("height",String(Math.round(n))),s.toString()}catch{return e}}function buildImageSrc({apiOrigin:e,randmarSKU:t,image:n,width:s,height:a}){const o=(n.Url??"").trim();if(o){if(o.startsWith("data:"))return o;try{const d=new URL(buildApiUrl(o,e)),f=d.pathname.split("/").filter(Boolean),R=t.trim().toLowerCase(),S=st=>{try{return decodeURIComponent(st).toLowerCase()===R}catch{return st.toLowerCase()===R}},te=f.slice(-3),A=f.slice(-4);return te.length===3&&te[0]?.toLowerCase()==="product"&&S(te[1]??"")&&te[2]?.toLowerCase()==="image"||A.length===4&&A[0]?.toLowerCase()==="product"&&S(A[1]??"")&&A[2]?.toLowerCase()==="image"?withImageSizeParams(d.toString(),s,a):d.toString()}catch{}}const c=n.ImageId!==void 0&&n.ImageId!==null&&String(n.ImageId).trim()!==""?`/Product/${encodeURIComponent(t)}/Image/${encodeURIComponent(String(n.ImageId))}`:`/Product/${encodeURIComponent(t)}/Image`;return withImageSizeParams(buildApiUrl(c,e),s,a)}function buildLegacyImageSrc({apiOrigin:e,randmarSKU:t,width:n,height:s}){return withImageSizeParams(buildApiUrl(`/Product/${encodeURIComponent(t)}/Image`,e),n,s)}const Placeholder$1=({size:e,alt:t})=>jsxRuntime.jsx("div",{className:"rounded-md bg-muted flex items-center justify-center",style:{width:e,height:e},"aria-label":t,children:jsxRuntime.jsx(ImageOff,{className:"h-1/2 w-1/2 text-muted-foreground"})});function ProductImageCarousel({randmarSKU:e,size:t="md",alt:n,className:s,fallback:a}){const o=imgSizeMap$1[t],l=React__namespace.useRef(null),c=useIntersectionObserver({elementRef:l,threshold:.1,rootMargin:"100px"}),d=useApiOrigin(),{data:f,isError:R,isFetching:S}=useGetProductByRandmarSkuImagesQuery({randmarSku:e},{skip:!e||!c,refetchOnMountOrArgChange:!0}),te=React__namespace.useMemo(()=>normalizeImagesListPayload(f),[f]),[A,rt]=React__namespace.useState(0),[st,it]=React__namespace.useState(!1),at=React__namespace.useRef(!1),ot=React__namespace.useRef(new Set);React__namespace.useEffect(()=>{rt(0),it(!1),at.current=!1,ot.current.clear()},[e]);const lt=React__namespace.useMemo(()=>te?[...te].sort((Dt,Vt)=>{const Ht=Dt.SortOrder??Number.POSITIVE_INFINITY,$t=Vt.SortOrder??Number.POSITIVE_INFINITY;if(Ht!==$t)return Ht-$t;const Ft=Dt.IsPrimary===!0?0:1,zt=Vt.IsPrimary===!0?0:1;return Ft-zt}):null,[te]),ut=React__namespace.useMemo(()=>{if(!lt?.length)return 0;const Dt=lt.findIndex(Vt=>Vt.IsPrimary===!0);return Dt>=0?Dt:0},[lt]);React__namespace.useEffect(()=>{lt?.length&&(at.current||(rt(ut),at.current=!0))},[ut,lt]);const ct=lt?.length??0,dt=React__namespace.useMemo(()=>{const Dt=(n??"").trim();return Dt?`${Dt} (Product ${e})`:`Product ${e}`},[n,e]),pt=React__namespace.useCallback(Dt=>ct>1?`${dt} image ${Dt+1}`:dt,[dt,ct]),mt=lt?.[A],Rt=React__namespace.useMemo(()=>mt?buildImageSrc({apiOrigin:d,randmarSKU:e,image:mt,width:o*1.5,height:o*1.5}):null,[mt,d,o,e]),yt=React__namespace.useCallback(Dt=>{if(ct<=0)return;const Vt=(Dt%ct+ct)%ct;rt(Vt)},[ct]),It=React__namespace.useCallback(()=>yt(A-1),[A,yt]),ft=React__namespace.useCallback(()=>yt(A+1),[A,yt]),Ct=React__namespace.useCallback(Dt=>{if(!(ct<=1))switch(Dt.key){case"ArrowLeft":Dt.preventDefault(),It();break;case"ArrowRight":Dt.preventDefault(),ft();break;case"Home":Dt.preventDefault(),yt(0);break;case"End":Dt.preventDefault(),yt(ct-1);break}},[ft,It,yt,ct]);if(React__namespace.useEffect(()=>{if(!lt?.length||ct<=1)return;const Dt=(A-1+ct)%ct,Vt=(A+1)%ct,Ht=[Dt,Vt];for(const $t of Ht){const Ft=lt[$t];if(!Ft)continue;const zt=buildImageSrc({apiOrigin:d,randmarSKU:e,image:Ft,width:o*1.5,height:o*1.5});if(ot.current.has(zt))continue;ot.current.add(zt);const Jt=new Image;Jt.src=zt}},[A,d,o,e,ct,lt]),R)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a??null});if(te===null&&c&&S)return jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx(Skeleton,{className:"rounded-md",style:{width:o,height:o}})});if(lt&<.length===0){if(a!=null)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a});const Dt=buildLegacyImageSrc({apiOrigin:d,randmarSKU:e,width:o*1.5,height:o*1.5});return jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx("div",{className:"relative rounded-md overflow-hidden bg-muted",style:{width:o,height:o},"aria-label":dt,children:st?jsxRuntime.jsx(Placeholder$1,{size:o,alt:dt}):jsxRuntime.jsx("img",{alt:dt,className:"w-full h-full object-contain",src:Dt,width:o,height:o,loading:"eager",onError:()=>it(!0)})})})}return Rt?jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsxs("div",{className:"group relative rounded-md overflow-hidden bg-muted",style:{width:o,height:o},role:"region","aria-roledescription":"carousel","aria-label":`Product images for ${e}`,tabIndex:ct>1?0:-1,onKeyDown:Ct,children:[jsxRuntime.jsx("img",{alt:pt(A),className:"w-full h-full object-contain",src:Rt,width:o,height:o,loading:"eager"}),ct>1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Button$1,{type:"button",variant:"secondary",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 text-foreground shadow-sm ring-1 ring-border/50 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",onClick:It,"aria-label":"Previous image",children:jsxRuntime.jsx(ChevronLeft,{className:"h-4 w-4"})}),jsxRuntime.jsx(Button$1,{type:"button",variant:"secondary",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 text-foreground shadow-sm ring-1 ring-border/50 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100",onClick:ft,"aria-label":"Next image",children:jsxRuntime.jsx(ChevronRight,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 flex items-center gap-1 rounded-full bg-background/80 px-2 py-1",children:Array.from({length:ct}).map((Dt,Vt)=>{const Ht=Vt===A;return jsxRuntime.jsx("button",{type:"button",className:["h-1.5 w-1.5 rounded-full transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",Ht?"bg-foreground":"bg-muted-foreground/40 hover:bg-muted-foreground/60"].join(" "),onClick:()=>yt(Vt),"aria-label":`Go to image ${Vt+1} of ${ct}`,"aria-current":Ht?"true":void 0},Vt)})})]})]})}):jsxRuntime.jsx("div",{className:s,ref:l,children:jsxRuntime.jsx(Placeholder$1,{size:o,alt:dt})})}const getTodayIsoDate=()=>new Date().toISOString().split("T")[0],isOpportunityNotStartedYet=e=>e.StartDate?e.StartDate.split("T")[0]>getTodayIsoDate():!1,isOpportunitySelectable=e=>{if(e.Active!==!0)return!1;const t=getTodayIsoDate();return!(e.EndDate&&e.EndDate.split("T")[0]<t||e.StartDate&&e.StartDate.split("T")[0]>t)};function ProductCard({applicationId:e,product:t,viewProductLink:n,defaultOpportunityNumber:s="",onAddToCart:a,addingToCart:o=!1,shopifyHostname:l,customAction:c=jsxRuntime.jsx(jsxRuntime.Fragment,{}),showUsdLabelOnCost:d=!1}){const f=reactRouterDom.useNavigate(),{toast:R}=useToast(),[S,te]=React.useState(1),[A,rt]=React.useState(null),[st,it]=React.useState(0),[at,ot]=React.useState(!1),[lt]=usePostV4ResellerByRouteResellerIdProductAndRandmarSkuShopifyMutation(),[ut,ct]=React.useState(!1),[dt,pt]=React.useState(null),[mt,Rt]=React.useState("idle"),[yt,It]=React.useState(null),[ft]=useLazyGetV4PartnerByRouteApplicationIdProductAndRandmarSkuQuery(),Ct=t?.Distribution?.Cost||0,Mt=t?.Distribution?.RegularPrice||0,Dt=t?.Distribution?.Price||0,Vt=!!(e&&t?.RandmarSKU);React.useEffect(()=>{te(1),rt(null),it(0)},[t?.RandmarSKU]),React.useEffect(()=>{if(t&&s){const or=t.Opportunities?.find(yr=>yr.BidNumber==s);or&&isOpportunitySelectable(or)&&rt(or)}},[t,s]),React.useEffect(()=>{if(!t)return;const or=A?.Price?A.Price:Dt;it(Mt>0?Math.round((Mt-or)/Mt*100):0)},[t,A,Dt,Mt]),React.useEffect(()=>{o||te(1)},[o]),React.useEffect(()=>{if(!ut){pt(null),Rt("idle"),It(null);return}if(!e||!t?.RandmarSKU){Rt("error"),It("Missing identifiers to load performance data.");return}let or=!1;const yr=t.RandmarSKU;return(async()=>{Rt("summary"),It(null);try{const Sr=await ft({routeApplicationId:e,randmarSku:yr,withSpecification:!1});if(or)return;if("error"in Sr&&Sr.error)throw Sr.error;pt(Sr.data??null),Rt("detailed");const Cr=await ft({routeApplicationId:e,randmarSku:yr,withSpecification:!0});if(or)return;if("error"in Cr&&Cr.error)throw Cr.error;pt(Cr.data??Sr.data??null),Rt("complete")}catch(Sr){if(or)return;console.error("Failed to load performance data for product modal",Sr),Rt("error"),It("We couldn't load the performance details. Please try again.")}})(),()=>{or=!0}},[e,ft,ut,t?.RandmarSKU]);const Ht=or=>or>=90?{label:"Top 10% Bestseller",color:"text-primary",bgColor:"bg-primary/10"}:or>=75?{label:"Bestseller",color:"text-info",bgColor:"bg-info/10"}:or>=33?{label:"Popular",color:"text-success",bgColor:"bg-success/10"}:{label:"Rising",color:"text-muted-foreground",bgColor:"bg-muted/30"},$t=mt!=="complete"&&mt!=="error",Ft=mt==="summary"?40:mt==="detailed"?80:10,zt=dt?.SalesStatistics??[],Jt=$t?[]:zt,Qt=dt?.RandmarTitle??t?.RandmarTitle??t?.RandmarSKU??"this product",sr=dt?.RandmarSKU??t?.RandmarSKU,lr=e&&t?.ManufacturerId?`/${encodeURIComponent(e)}/Partner/${encodeURIComponent(t.ManufacturerId)}?tab=manufacturer-overview`:null;if(!t)return jsxRuntime.jsx(Card,{className:"flex h-full w-full flex-col",children:jsxRuntime.jsxs(CardContent,{className:"flex h-full flex-col p-6",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx(Skeleton,{className:"h-7 w-3/4"}),jsxRuntime.jsx("div",{className:"h-10 w-24 flex items-center justify-end ml-4",children:jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"})})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[jsxRuntime.jsx(Skeleton,{className:"h-6 w-20 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24 rounded-full"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-28 rounded-full"})]}),jsxRuntime.jsxs("div",{className:"flex gap-6",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-20 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-16"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-12 mb-1"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-20"})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:jsxRuntime.jsx("div",{className:"w-60 h-40",children:jsxRuntime.jsx(Skeleton,{className:"w-full h-full rounded-lg"})})})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsx("div",{className:"flex flex-1",children:jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx(Skeleton,{className:"h-4 w-24 mb-3"}),jsxRuntime.jsx(Skeleton,{className:"h-16 w-full rounded-md"})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-center",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-32 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-5 w-24 mt-4"})]})]}),jsxRuntime.jsxs("div",{className:"flex gap-6 mt-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-col items-start gap-1 mb-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-8 w-32"}),jsxRuntime.jsx(Skeleton,{className:"h-6 w-24"})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[jsxRuntime.jsx(Skeleton,{className:"h-10 w-24 rounded-md"}),jsxRuntime.jsx(Skeleton,{className:"h-10 flex-1 rounded-md"})]})]})]})});const Zt=t?.Opportunities||[],cr=Zt.length>0,qt=()=>{if(S==null){te(1);return}S>1&&te(S-1)},nr=()=>{if(S==null){te(1);return}te(S+1)},Kt=or=>{const yr=Number.parseInt(or.target.value,10);if(!isNaN(yr)&&yr>0){te(yr);return}te(void 0)},Xt=()=>{(S==null||S<1)&&te(1)},pr=or=>{try{return new Date(or).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch(yr){return console.error(yr),or.split("T")[0]||"N/A"}},Yt=or=>{const yr=typeof t?.MSRP=="number"&&t.MSRP>0?t.MSRP:typeof t?.MAP=="number"&&t.MAP>0?t.MAP:null;if(yr===null)return null;const Rr=or.Price??t?.Distribution?.Price;if(typeof Rr!="number")return null;const Sr=or.Rebate??0,Cr=Math.max(Rr-Sr,0);return yr-Cr},gr=()=>{typeof a<"u"&&a({quantity:S??1,bidNumber:A?.BidNumber??null})},ar=()=>{at||!l||(ot(!0),lt({routeResellerId:e??"",randmarSku:t.RandmarSKU??"",shopifyHostName:l}).then(or=>{if(or.error){console.error("Error syncing to Shopify:",or.error),R({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"});return}R({title:"Product synced",description:"Product synced to Shopify successfully",variant:"success"})}).catch(or=>{console.error("Error syncing to Shopify:",or),R({title:"Product synced failed.",description:"Error syncing to Shopify:",variant:"destructive"})}).finally(()=>{ot(!1)}))};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Card,{className:"flex h-full w-full flex-col hover:shadow-lg transition-shadow @container",children:jsxRuntime.jsxs(CardContent,{className:"flex h-full flex-col p-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-1 flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-3",children:[jsxRuntime.jsx("h3",{className:"font-semibold text-xl",children:t.Title||t.RandmarTitle}),jsxRuntime.jsx("div",{className:"w-24 h-10 flex items-center justify-end ml-4 flex-shrink-0",children:lr?jsxRuntime.jsx(reactRouterDom.Link,{to:lr,"aria-label":`Open manufacturer overview for ${t.ManufacturerName??"this manufacturer"}`,className:"block h-full w-full",children:jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40,className:"cursor-pointer"},`partner_logo_${t.ManufacturerId}`)}):jsxRuntime.jsx(PartnerLogo,{id:t.ManufacturerId,name:t.ManufacturerName,width:96,height:40},`partner_logo_${t.ManufacturerId}`)})]}),jsxRuntime.jsxs("div",{className:"flex flex-col @[36rem]:flex-row gap-6",children:[jsxRuntime.jsxs("div",{className:"flex-1 @[36rem]:order-1 order-2 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-2 items-center justify-center @[36rem]:items-start @[36rem]:justify-start",children:[t.State&&jsxRuntime.jsxs(Badge,{variant:t.State==="Active"?"success":"destructive",className:"rounded-full px-3",children:[jsxRuntime.jsx(Check,{size:"12",className:"mr-1.5"})," ",t.State]}),jsxRuntime.jsxs(Badge,{variant:t.SerialNumber?"success":"warning",className:"rounded-full px-3",children:[jsxRuntime.jsx(QrCode,{size:"12",className:"mr-1.5"})," ",t.SerialNumber?"Serialized":"Unserialized"]}),t.TransparencyCode&&jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3",children:[jsxRuntime.jsx(CircleDashed,{size:"12",className:"mr-1.5"})," Transparency Code"]}),t.AvailableToBuy!==void 0&&jsxRuntime.jsxs(Badge,{variant:t.AvailableToBuy?"success":"destructive",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShoppingCart,{size:"12",className:"mr-1.5"})," ",t.AvailableToBuy?"Available":"Unavailable"]}),t.ManufacturerCategory!==void 0&&t.ManufacturerCategory?.QualificationRequired&&jsxRuntime.jsxs(Badge,{variant:t.ManufacturerCategory?.QualificationRequired?"info":"secondary",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ",t.ManufacturerCategory?.QualificationRequired?"Qualified Only":"Available to all"]}),t.OpportunityOnly&&jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3",children:[jsxRuntime.jsx(ShieldCheck,{size:"12",className:"mr-1.5"})," ","Requires Opportunity"]}),t.ManufacturerId&&jsxRuntime.jsxs(Badge,{variant:t.AutoUpdate?"info":"secondary",className:"rounded-full px-3",children:[jsxRuntime.jsx(RefreshCw,{size:"12",className:"mr-1.5"})," ",t.AutoUpdate?`Automatic Reorder (${t.MasterCarton})`:"Manually Reorders"]}),jsxRuntime.jsxs(Badge,{variant:t.BodyHTML&&t.Title&&t.MAP?"success":"warning",className:"rounded-full px-3",children:[jsxRuntime.jsx(Store,{size:"12",className:"mr-1.5"})," ",t.BodyHTML&&t.Title&&t.MAP?"Shopify Ready":"Not Shopify Ready"]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-4 flex-1",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"MPN"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.MPN||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"UPC"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UPC||"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Unit Weight"}),jsxRuntime.jsx("div",{className:"font-medium",children:t.UnitWeight?`${formatNumber(t.UnitWeight)} lbs`:"N/A"})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"text-sm text-muted-foreground",children:["MAP",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),"MSRP"]}),jsxRuntime.jsxs("div",{className:"font-medium",children:[t.MAP?formatMoney(t.MAP):"N/A",jsxRuntime.jsx("span",{className:"text-primary",children:" / "}),t.MSRP?formatMoney(t.MSRP):"N/A"]})]}),!!t.OverallPercentileRank&&!!t.ManufacturerPercentileRank&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Bestseller Status"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("span",{children:"Global: "}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${Ht(t.OverallPercentileRank).bgColor} ${Ht(t.OverallPercentileRank).color} hover:${Ht(t.OverallPercentileRank).bgColor}`,children:Ht(t.OverallPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.OverallPercentileRank]})})]})})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("span",{children:[t.ManufacturerName,": "]}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsx(Badge,{variant:"outline",className:`rounded-full px-3 w-fit ${Ht(t.ManufacturerPercentileRank).bgColor} ${Ht(t.ManufacturerPercentileRank).color} hover:${Ht(t.ManufacturerPercentileRank).bgColor}`,children:Ht(t.ManufacturerPercentileRank).label})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsxs("p",{children:["Percentile Rank: ",t.ManufacturerPercentileRank]})})]})})]})]})]}),t.CountryCodeOfOrigin&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-sm text-muted-foreground",children:"Origin"}),jsxRuntime.jsxs("div",{className:"font-medium flex items-center",children:[jsxRuntime.jsx(CountryFlag,{countryCode:t.CountryCodeOfOrigin,className:"mr-2"}),t.CountryCodeOfOrigin]})]})]})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:order-2 order-1 items-center",children:jsxRuntime.jsx(ProductImageCarousel,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||"",fallback:jsxRuntime.jsx(ProductImage,{randmarSKU:t.RandmarSKU||"",alt:t.RandmarTitle||"",sceneName:t.SceneName},`product_image_fallback_${t.RandmarSKU}`)},`product_image_${t.RandmarSKU}`)})]}),jsxRuntime.jsx("div",{className:"flex flex-col @[36rem]:flex-row gap-6 mt-4",children:jsxRuntime.jsx("div",{className:"flex flex-1 @[36rem]:order-1 order-2",children:cr&&t.Distribution&&jsxRuntime.jsxs("div",{className:"w-full",children:[jsxRuntime.jsx("div",{className:"flex items-center",children:"You have "+Zt.length+(Zt.length>1?" opportunities":" opportunity")+" for this product:"}),jsxRuntime.jsx(TooltipProvider,{children:jsxRuntime.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto p-2 mt-1",children:Zt.map((or,yr)=>{const Rr=Yt(or);return isOpportunitySelectable(or)?jsxRuntime.jsxs("div",{className:`flex justify-between items-center rounded-lg transition-colors py-2 px-4 border cursor-pointer ${or.BidNumber==A?.BidNumber?"bg-primary/10 border-2 border-primary":"bg-background border-border hover:bg-muted/30"}`,onClick:()=>{rt(or.BidNumber!==A?.BidNumber?or:null)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:or.Opportunity}),jsxRuntime.jsx("span",{className:"text-xs text-foreground",children:or.BidNumber})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(or.Price??0)}),or.Rebate&&or.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-success",children:["Rebate: ",formatMoney(or.Rebate)]}),Rr!==null&&jsxRuntime.jsxs("span",{className:"text-xs text-info",children:["Potential Revenue: ",formatMoney(Rr)]}),or.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-muted-foreground",children:["Ends: ",pr(or.EndDate)]})]})]},yr):jsxRuntime.jsxs(Tooltip$1,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("div",{className:"flex justify-between items-center rounded-lg transition-colors py-2 px-4 bg-muted/30 border border-border cursor-pointer hover:bg-muted/40",onClick:()=>{or.BidNumber&&f(`/${e}/Opportunity/${or.ManufacturerId}/${or.BidNumber}`)},children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("span",{className:"font-medium text-sm",children:or.Opportunity}),jsxRuntime.jsxs("span",{className:"text-xs text-foreground",children:[or.BidNumber," ",jsxRuntime.jsx(Badge,{variant:"secondary",className:"text-xs mx-1 h-5",children:isOpportunityNotStartedYet(or)&&or.StartDate?`Starts ${pr(or.StartDate)}`:"Currently unavailable"})]})]})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-end",children:[jsxRuntime.jsx("span",{className:"font-semibold",children:formatMoney(or.Price??0)}),or.Rebate&&or.Rebate>0&&jsxRuntime.jsxs("span",{className:"text-xs text-success",children:["Rebate: ",formatMoney(or.Rebate)]}),Rr!==null&&jsxRuntime.jsxs("span",{className:"text-xs text-info",children:["Potential Revenue: ",formatMoney(Rr)]}),or.EndDate&&jsxRuntime.jsxs("span",{className:"text-xs text-muted-foreground",children:["Ends: ",pr(or.EndDate)]})]})]})}),jsxRuntime.jsx(TooltipContent,{children:jsxRuntime.jsx("p",{children:"View Opportunity"})})]},yr)})})})]})})})]}),jsxRuntime.jsxs("div",{className:"mt-4 flex flex-col gap-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-row flex-wrap justify-between items-end gap-4",children:[jsxRuntime.jsx("div",{className:"flex flex-col gap-3 flex-1",children:t.Distribution&&jsxRuntime.jsx("div",{className:"flex flex-col gap-1",children:Ct>0?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs("span",{className:"text-2xl font-bold whitespace-nowrap",children:["Cost: ",formatMoney(Ct),d?" USD":""]})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center flex-wrap",children:[Mt>0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("span",{className:"text-2xl font-bold whitespace-nowrap",children:formatMoney((A?t.Opportunities?.find(or=>or.BidNumber==A.BidNumber)?.Price:Dt)??0)})}),st>0&&jsxRuntime.jsx("span",{className:"text-muted-foreground line-through ml-2 whitespace-nowrap",children:formatMoney(Mt)})]}),st>0&&jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(Badge,{variant:"info",className:"rounded-full px-3 whitespace-nowrap",children:[jsxRuntime.jsxs("span",{children:[st,"% OFF"]}),t.InstantRebate?.EndDate&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",t.InstantRebate.EndDate.split("T")[0]]}),A?.EndDate&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"mx-1.5",children:"●"})," Ends ",A.EndDate.split("T")[0]]})]})})]})})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center @[36rem]:justify-end items-end gap-2 w-full @[36rem]:w-auto",children:[l&&jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:ar,disabled:at,children:at?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Sync to Shopify"]})}),c,typeof a<"u"&&jsxRuntime.jsxs("div",{className:"flex gap-2 whitespace-nowrap",children:[jsxRuntime.jsxs("div",{className:"flex items-center border rounded-md",children:[jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-r-none",onClick:qt,disabled:typeof S<"u"&&(S<=1||!t.AvailableToBuy||o),children:"-"}),jsxRuntime.jsx("input",{value:S,onChange:Kt,onBlur:Xt,onClick:or=>or.currentTarget.select(),className:`w-6 @[36rem]:w-12 text-center border-0 bg-transparent text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${!t.AvailableToBuy||o?"text-muted-foreground":""}`,disabled:!t.AvailableToBuy||o}),jsxRuntime.jsx(Button$1,{variant:"ghost",size:"icon",className:"rounded-l-none",onClick:nr,disabled:!t.AvailableToBuy||o,children:"+"})]}),jsxRuntime.jsx(Button$1,{className:"gap-2 whitespace-nowrap",onClick:gr,disabled:!t.AvailableToBuy||o,children:o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Adding..."]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ShoppingCart,{className:"mr-2"}),"Add to Cart"]})})]})]})]}),jsxRuntime.jsxs("div",{className:"flex w-full flex-col gap-2 @[36rem]:flex-row",children:[jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",type:"button",className:"h-11 px-4 text-sm font-medium justify-start w-full",onClick:()=>ct(!0),disabled:!Vt,children:[jsxRuntime.jsx(ChartLine,{className:"mr-2"}),"View statistics"]})}),jsxRuntime.jsx("div",{className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsx(ProductInventoryButton,{applicationId:e??"",randmarSku:t.RandmarSKU??"",inventory:t.Distribution?.Inventory,buttonSize:"lg",buttonClassName:"w-full h-11 justify-start"})}),n&&jsxRuntime.jsx(reactRouterDom.Link,{to:n,className:"flex-1 min-w-[10rem]",children:jsxRuntime.jsxs(Button$1,{variant:"outline",className:"h-11 px-4 text-sm font-medium justify-start w-full",children:[jsxRuntime.jsx(Eye,{className:"mr-2"}),"View Product"]})})]})]})]})}),jsxRuntime.jsx(Dialog,{open:ut,onOpenChange:ct,children:jsxRuntime.jsxs(DialogContent,{className:"w-[min(95vw,1100px)] max-w-5xl space-y-6",children:[jsxRuntime.jsxs(DialogHeader,{children:[jsxRuntime.jsx(DialogTitle,{children:"Monthly Sales Performance"}),jsxRuntime.jsxs(DialogDescription,{children:["Expanded product insights for ",Qt,sr?` (SKU ${sr})`:""]})]}),jsxRuntime.jsx("div",{className:"space-y-6",children:yt?jsxRuntime.jsxs(Alert,{variant:"destructive",children:[jsxRuntime.jsx(AlertTitle,{children:"Unable to load details"}),jsxRuntime.jsx(AlertDescription,{children:yt})]}):jsxRuntime.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[jsxRuntime.jsxs("div",{className:"mb-4 space-y-2",children:[jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:"Rolling 12-month sales dollars and units sold pulled from the detailed endpoint."}),$t&&jsxRuntime.jsx("div",{"aria-live":"polite","aria-busy":"true",children:jsxRuntime.jsx(Progress,{value:Ft,className:"h-2 w-full animate-pulse","aria-label":"Loading performance data"})})]}),jsxRuntime.jsx(SalesChart,{statistics:Jt,mode:"month",chartHeight:320}),$t&&jsxRuntime.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Gathering product summary and sales statistics..."})]})})]})})]})}const imgSizeMap={sm:100,md:200,lg:300,xl:400},Placeholder=({size:e})=>jsxRuntime.jsx("div",{className:"rounded-md bg-muted flex items-center justify-center",style:{width:e,height:e},"aria-label":"Image not available",children:jsxRuntime.jsx(ImageOff,{className:"h-1/2 w-1/2 text-muted-foreground"})}),VideoSkeleton=()=>jsxRuntime.jsx(Skeleton,{className:"w-full",style:{aspectRatio:"16/9"}});function ProductImage({randmarSKU:e,sceneName:t,size:n="md",alt:s,secondaryContent:a}){const[o,l]=React__namespace.useState(!1),[c,d]=React__namespace.useState(!1),{sendMessageWithClear:f}=useChat(),R=useApiOrigin(),S=imgSizeMap[n],te=React.useRef(null),A=useIntersectionObserver({elementRef:te,threshold:.1,rootMargin:"100px"}),{data:rt,isFetching:st}=useGetProductByProductNumberImageExistsQuery({productNumber:e},{skip:!e||!A}),{data:it,isFetching:at}=useGetProductByRandmarSkuImageQuery({randmarSku:e,width:S*1.5,height:S*1.5},{skip:!rt}),{data:ot}=useGetProductByProductNumberVideoExistsQuery({productNumber:e},{skip:!e||!A}),{data:lt,isFetching:ut}=useGetProductByProductNumberVideoQuery({productNumber:e},{skip:!ot||!o}),ct=st||at;function dt(){if(lt)try{const yt=document.createElement("a");yt.href=lt,yt.download=`${e||"product"}-video.mp4`,yt.target="_blank",yt.rel="noopener noreferrer",document.body.appendChild(yt),yt.click(),document.body.removeChild(yt)}catch(yt){console.error("Error downloading video:",yt)}}function pt(){const yt=`/Product/${encodeURIComponent(e)}/Video`;navigator.clipboard.writeText(buildApiUrl(yt,R)),d(!0),setTimeout(()=>d(!1),2e3)}function mt(){ot&&l(!0)}const Rt=React__namespace.useCallback(()=>{if(!it)return;const yt=(t??"").trim(),It=yt?`Use this concept as a background/stage scene: "${yt}".`:"Use a modern and clean office as the background/stage, with no people present.";f(`Help me generate product images for (Randmar SKU: ${e}).
|
|
514
514
|
|
|
@@ -520,7 +520,7 @@ You can add a description to the \`${CONTENT_NAME$2}\` by passing a \`${DESCRIPT
|
|
|
520
520
|
|
|
521
521
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${CONTENT_NAME$2}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
522
522
|
|
|
523
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return React__namespace.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Root2$1=AlertDialog$1,Trigger2$1=AlertDialogTrigger$1,Portal2=AlertDialogPortal$1,Overlay2=AlertDialogOverlay$1,Content2$1=AlertDialogContent$1,Action=AlertDialogAction$1,Cancel=AlertDialogCancel$1,Title2=AlertDialogTitle$1,Description2=AlertDialogDescription$1;const AlertDialog=Root2$1,AlertDialogTrigger=Trigger2$1,AlertDialogPortal=Portal2,AlertDialogOverlay=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Overlay2,{className:cn("fixed inset-0 z-50 bg-foreground/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));AlertDialogOverlay.displayName=Overlay2.displayName;const AlertDialogContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs(AlertDialogPortal,{children:[jsxRuntime.jsx(AlertDialogOverlay,{}),jsxRuntime.jsx(Content2$1,{ref:n,className:cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));AlertDialogContent.displayName=Content2$1.displayName;const AlertDialogHeader=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col space-y-2 text-center sm:text-left",e),...t});AlertDialogHeader.displayName="AlertDialogHeader";const AlertDialogFooter=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});AlertDialogFooter.displayName="AlertDialogFooter";const AlertDialogTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Title2,{ref:n,className:cn("text-lg font-semibold",e),...t}));AlertDialogTitle.displayName=Title2.displayName;const AlertDialogDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Description2,{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));AlertDialogDescription.displayName=Description2.displayName;const AlertDialogAction=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Action,{ref:n,className:cn(buttonVariants(),e),...t}));AlertDialogAction.displayName=Action.displayName;const AlertDialogCancel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Cancel,{ref:n,className:cn(buttonVariants({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));AlertDialogCancel.displayName=Cancel.displayName;function parseDate(e){if(e==null)return null;const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function formatLastRefresh(e){const t=parseDate(e);if(!t)return"Never";const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()?`Today at ${new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}function RefreshCluster({lastRefreshAt:e,onRefresh:t,onProgressiveRefresh:n,onAssistantClick:s,isRefreshing:a=!1,refreshLabel:o="Refresh",assistantLabel:l="Assistant",className:c,disabled:d=!1}){const[f,R]=React__namespace.useState(!1),[S,te]=React__namespace.useState(e);React__namespace.useEffect(()=>{te(e)},[e]);const A=!!(t||n),rt=a||f,st=e??S,it=React__namespace.useCallback(async()=>{if(!(!A||d||rt)){R(!0);try{n?(await n(!1),await n(!0)):await t?.(),te(new Date)}finally{R(!1)}}},[A,d,rt,n,t]);return jsxRuntime.jsxs("div",{className:cn("flex flex-wrap items-center justify-end gap-2",c),children:[jsxRuntime.jsxs("p",{className:"text-xs text-muted-foreground sm:text-sm",children:["Last refresh:"," ",jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:formatLastRefresh(st)})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"outline",className:"min-h-11",disabled:d||rt||!A,onClick:it,children:[rt?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(RefreshCw,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:o})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"default",className:"min-h-11",disabled:d,onClick:s,children:[jsxRuntime.jsx(Bot,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l})]})]})}function DataRefreshAssistantCluster({onAssistantClick:e,assistantPromptOptions:t,onAssistantUnavailable:n,...s}){const a=useOptionalChat(),o=React__namespace.useCallback(()=>{if(e){e();return}if(t){if(!a){n?.();return}a.sendMessageWithClear(t.prompt,t.hiddenPrompt,t.sopID)||n?.();return}n?.()},[t,a,e,n]);return jsxRuntime.jsx(RefreshCluster,{...s,onAssistantClick:o})}const fullBleedClassName="w-screen max-w-none -ml-[calc(50vw-50%)] -mr-[calc(50vw-50%)]";function RmPageHeaderBreadcrumbLink({item:e,isCurrent:t}){return!t&&e.href?jsxRuntime.jsx("a",{href:e.href,className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:e.label}):!t&&e.onClick?jsxRuntime.jsx("button",{type:"button",className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:e.onClick,children:e.label}):jsxRuntime.jsx("span",{"aria-current":t?"page":void 0,className:cn("text-xs font-medium",t?"text-foreground":"text-muted-foreground"),children:e.label})}function RmPageHeaderBreadcrumbs({items:e}){return e.length===0?null:jsxRuntime.jsx("nav",{"aria-label":"Breadcrumb",className:"w-full",children:jsxRuntime.jsx("ol",{className:"flex flex-wrap items-center gap-1.5",children:e.map((t,n)=>{const s=n===e.length-1,a=t.key??`${String(t.label)}-${n}`;return jsxRuntime.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[jsxRuntime.jsx(RmPageHeaderBreadcrumbLink,{item:t,isCurrent:!!t.current||s}),s?null:jsxRuntime.jsx("span",{"aria-hidden":"true",className:"text-xs text-muted-foreground",children:"/"})]},a)})})})}function RmPageHeader({title:e,subtitle:t,breadcrumbs:n,rightTopActions:s,rightBottomActions:a,secondaryRow:o,sticky:l=!1,stickyClassName:c,className:d,cardClassName:f,contentClassName:R}){const S=!!(s||a),te=jsxRuntime.jsxs("header",{className:cn("w-full border-b border-border bg-background",d),children:[jsxRuntime.jsx("div",{className:cn("px-4 py-6 sm:px-6",f),children:jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",R),children:[jsxRuntime.jsxs("div",{className:"space-y-1.5",children:[n?.length?jsxRuntime.jsx(RmPageHeaderBreadcrumbs,{items:n}):null,jsxRuntime.jsx("h1",{className:"text-2xl font-semibold leading-tight tracking-tight text-foreground",children:e}),t?jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),S?jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-start gap-2 lg:w-auto lg:min-w-[16rem] lg:items-end",children:[s?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:s}):null,a?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:a}):null]}):null]})}),o?jsxRuntime.jsx("div",{className:"border-t border-border bg-muted/40",children:jsxRuntime.jsx("div",{className:"px-4 py-4 sm:px-6",children:o})}):null]});return l?jsxRuntime.jsx("div",{className:fullBleedClassName,children:jsxRuntime.jsx("div",{className:cn("sticky top-0 z-20",c),children:te})}):jsxRuntime.jsx("div",{className:fullBleedClassName,children:te})}function PageHeader({title:e,children:t,className:n}){return jsxRuntime.jsx(RmPageHeader,{title:e,rightBottomActions:t?jsxRuntime.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:t}):void 0,cardClassName:n})}function RmBodyZone({className:e,children:t,...n}){return jsxRuntime.jsx("section",{className:cn("px-4 py-4 sm:px-6 sm:py-6",e),...n,children:t})}function OrderedMap(e){this.content=e}OrderedMap.prototype={constructor:OrderedMap,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var s=n&&n!=e?this.remove(n):this,a=s.find(e),o=s.content.slice();return a==-1?o.push(n||e,t):(o[a+1]=t,n&&(o[a]=n)),new OrderedMap(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new OrderedMap(n)},addToStart:function(e,t){return new OrderedMap([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new OrderedMap(n)},addBefore:function(e,t,n){var s=this.remove(t),a=s.content.slice(),o=s.find(e);return a.splice(o==-1?a.length:o,0,t,n),new OrderedMap(a)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=OrderedMap.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},OrderedMap.from=function(e){if(e instanceof OrderedMap)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new OrderedMap(t)};function findDiffStart(e,t,n){for(let s=0;;s++){if(s==e.childCount||s==t.childCount)return e.childCount==t.childCount?null:n;let a=e.child(s),o=t.child(s);if(a==o){n+=a.nodeSize;continue}if(!a.sameMarkup(o))return n;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)n++;return n}if(a.content.size||o.content.size){let l=findDiffStart(a.content,o.content,n+1);if(l!=null)return l}n+=a.nodeSize}}function findDiffEnd(e,t,n,s){for(let a=e.childCount,o=t.childCount;;){if(a==0||o==0)return a==o?null:{a:n,b:s};let l=e.child(--a),c=t.child(--o),d=l.nodeSize;if(l==c){n-=d,s-=d;continue}if(!l.sameMarkup(c))return{a:n,b:s};if(l.isText&&l.text!=c.text){let f=0,R=Math.min(l.text.length,c.text.length);for(;f<R&&l.text[l.text.length-f-1]==c.text[c.text.length-f-1];)f++,n--,s--;return{a:n,b:s}}if(l.content.size||c.content.size){let f=findDiffEnd(l.content,c.content,n-1,s-1);if(f)return f}n-=d,s-=d}}class Fragment{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let s=0;s<t.length;s++)this.size+=t[s].nodeSize}nodesBetween(t,n,s,a=0,o){for(let l=0,c=0;c<n;l++){let d=this.content[l],f=c+d.nodeSize;if(f>t&&s(d,a+c,o||null,l)!==!1&&d.content.size){let R=c+1;d.nodesBetween(Math.max(0,t-R),Math.min(d.content.size,n-R),s,a+R)}c=f}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,s,a){let o="",l=!0;return this.nodesBetween(t,n,(c,d)=>{let f=c.isText?c.text.slice(Math.max(t,d)-d,n-d):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&s&&(l?l=!1:o+=s),o+=f},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,s=t.firstChild,a=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),o=1);o<t.content.length;o++)a.push(t.content[o]);return new Fragment(a,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let s=[],a=0;if(n>t)for(let o=0,l=0;l<n;o++){let c=this.content[o],d=l+c.nodeSize;d>t&&((l<t||d>n)&&(c.isText?c=c.cut(Math.max(0,t-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,t-l-1),Math.min(c.content.size,n-l-1))),s.push(c),a+=c.nodeSize),l=d}return new Fragment(s,a)}cutByIndex(t,n){return t==n?Fragment.empty:t==0&&n==this.content.length?this:new Fragment(this.content.slice(t,n))}replaceChild(t,n){let s=this.content[t];if(s==n)return this;let a=this.content.slice(),o=this.size+n.nodeSize-s.nodeSize;return a[t]=n,new Fragment(a,o)}addToStart(t){return new Fragment([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Fragment(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,s=0;n<this.content.length;n++){let a=this.content[n];t(a,s,n),s+=a.nodeSize}}findDiffStart(t,n=0){return findDiffStart(this,t,n)}findDiffEnd(t,n=this.size,s=t.size){return findDiffEnd(this,t,n,s)}findIndex(t){if(t==0)return retIndex(0,t);if(t==this.size)return retIndex(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),o=s+a.nodeSize;if(o>=t)return o==t?retIndex(n+1,o):retIndex(n,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return Fragment.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Fragment(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Fragment.empty;let n,s=0;for(let a=0;a<t.length;a++){let o=t[a];s+=o.nodeSize,a&&o.isText&&t[a-1].sameMarkup(o)?(n||(n=t.slice(0,a)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new Fragment(n||t,s)}static from(t){if(!t)return Fragment.empty;if(t instanceof Fragment)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Fragment([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Fragment.empty=new Fragment([],0);const found={index:0,offset:0};function retIndex(e,t){return found.index=e,found.offset=t,found}function compareDeep(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!compareDeep(e[s],t[s]))return!1}else{for(let s in e)if(!(s in t)||!compareDeep(e[s],t[s]))return!1;for(let s in t)if(!(s in e))return!1}return!0}let Mark$1=class Vn{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,s=!1;for(let a=0;a<t.length;a++){let o=t[a];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,a));else{if(o.type.excludes(this.type))return t;!s&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,a)),n.push(this),s=!0),n&&n.push(o)}}return n||(n=t.slice()),s||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&compareDeep(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let s=t.marks[n.type];if(!s)throw new RangeError(`There is no mark type ${n.type} in this schema`);let a=s.create(n.attrs);return s.checkAttrs(a.attrs),a}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let s=0;s<t.length;s++)if(!t[s].eq(n[s]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Vn.none;if(t instanceof Vn)return[t];let n=t.slice();return n.sort((s,a)=>s.type.rank-a.type.rank),n}};Mark$1.none=[];class ReplaceError extends Error{}class Slice{constructor(t,n,s){this.content=t,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let s=insertInto(this.content,t+this.openStart,n);return s&&new Slice(s,this.openStart,this.openEnd)}removeBetween(t,n){return new Slice(removeRange(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Slice.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Slice(Fragment.fromJSON(t,n.content),s,a)}static maxOpen(t,n=!0){let s=0,a=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)s++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)a++;return new Slice(t,s,a)}}Slice.empty=new Slice(Fragment.empty,0,0);function removeRange(e,t,n){let{index:s,offset:a}=e.findIndex(t),o=e.maybeChild(s),{index:l,offset:c}=e.findIndex(n);if(a==t||o.isText){if(c!=n&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(s!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(s,o.copy(removeRange(o.content,t-a-1,n-a-1)))}function insertInto(e,t,n,s){let{index:a,offset:o}=e.findIndex(t),l=e.maybeChild(a);if(o==t||l.isText)return s&&!s.canReplace(a,a,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=insertInto(l.content,t-o-1,n,l);return c&&e.replaceChild(a,l.copy(c))}function replace(e,t,n){if(n.openStart>e.depth)throw new ReplaceError("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ReplaceError("Inconsistent open depths");return replaceOuter(e,t,n,0)}function replaceOuter(e,t,n,s){let a=e.index(s),o=e.node(s);if(a==t.index(s)&&s<e.depth-n.openStart){let l=replaceOuter(e,t,n,s+1);return o.copy(o.content.replaceChild(a,l))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==s&&t.depth==s){let l=e.parent,c=l.content;return close(l,c.cut(0,e.parentOffset).append(n.content).append(c.cut(t.parentOffset)))}else{let{start:l,end:c}=prepareSliceForReplace(n,e);return close(o,replaceThreeWay(e,l,c,t,s))}else return close(o,replaceTwoWay(e,t,s))}function checkJoin(e,t){if(!t.type.compatibleContent(e.type))throw new ReplaceError("Cannot join "+t.type.name+" onto "+e.type.name)}function joinable$1(e,t,n){let s=e.node(n);return checkJoin(s,t.node(n)),s}function addNode(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function addRange(e,t,n,s){let a=(t||e).node(n),o=0,l=t?t.index(n):a.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(addNode(e.nodeAfter,s),o++));for(let c=o;c<l;c++)addNode(a.child(c),s);t&&t.depth==n&&t.textOffset&&addNode(t.nodeBefore,s)}function close(e,t){return e.type.checkContent(t),e.copy(t)}function replaceThreeWay(e,t,n,s,a){let o=e.depth>a&&joinable$1(e,t,a+1),l=s.depth>a&&joinable$1(n,s,a+1),c=[];return addRange(null,e,a,c),o&&l&&t.index(a)==n.index(a)?(checkJoin(o,l),addNode(close(o,replaceThreeWay(e,t,n,s,a+1)),c)):(o&&addNode(close(o,replaceTwoWay(e,t,a+1)),c),addRange(t,n,a,c),l&&addNode(close(l,replaceTwoWay(n,s,a+1)),c)),addRange(s,null,a,c),new Fragment(c)}function replaceTwoWay(e,t,n){let s=[];if(addRange(null,e,n,s),e.depth>n){let a=joinable$1(e,t,n+1);addNode(close(a,replaceTwoWay(e,t,n+1)),s)}return addRange(t,null,n,s),new Fragment(s)}function prepareSliceForReplace(e,t){let n=t.depth-e.openStart,a=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)a=t.node(o).copy(Fragment.from(a));return{start:a.resolveNoCache(e.openStart+n),end:a.resolveNoCache(a.content.size-e.openEnd-n)}}class ResolvedPos{constructor(t,n,s){this.pos=t,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=t.child(n);return s?t.child(n).cut(s):a}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let o=0;o<t;o++)a+=s.child(o).nodeSize;return a}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return Mark$1.none;if(this.textOffset)return t.child(n).marks;let s=t.maybeChild(n-1),a=t.maybeChild(n);if(!s){let c=s;s=a,a=c}let o=s.marks;for(var l=0;l<o.length;l++)o[l].type.spec.inclusive===!1&&(!a||!o[l].isInSet(a.marks))&&(o=o[l--].removeFromSet(o));return o}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let s=n.marks,a=t.parent.maybeChild(t.index());for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!a||!s[o].isInSet(a.marks))&&(s=s[o--].removeFromSet(s));return s}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let s=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);s>=0;s--)if(t.pos<=this.end(s)&&(!n||n(this.node(s))))return new NodeRange(this,t,s);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,o=n;for(let l=t;;){let{index:c,offset:d}=l.content.findIndex(o),f=o-d;if(s.push(l,c,a+d),!f||(l=l.child(c),l.isText))break;o=f-1,a+=d+1}return new ResolvedPos(n,s,o)}static resolveCached(t,n){let s=resolveCache.get(t);if(s)for(let o=0;o<s.elts.length;o++){let l=s.elts[o];if(l.pos==n)return l}else resolveCache.set(t,s=new ResolveCache);let a=s.elts[s.i]=ResolvedPos.resolve(t,n);return s.i=(s.i+1)%resolveCacheSize,a}}class ResolveCache{constructor(){this.elts=[],this.i=0}}const resolveCacheSize=12,resolveCache=new WeakMap;class NodeRange{constructor(t,n,s){this.$from=t,this.$to=n,this.depth=s}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const emptyAttrs=Object.create(null);let Node$1=class zn{constructor(t,n,s,a=Mark$1.none){this.type=t,this.attrs=n,this.marks=a,this.content=s||Fragment.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,s,a=0){this.content.nodesBetween(t,n,s,a,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,s,a){return this.content.textBetween(t,n,s,a)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,s){return this.type==t&&compareDeep(this.attrs,n||t.defaultAttrs||emptyAttrs)&&Mark$1.sameSet(this.marks,s||Mark$1.none)}copy(t=null){return t==this.content?this:new zn(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new zn(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,s=!1){if(t==n)return Slice.empty;let a=this.resolve(t),o=this.resolve(n),l=s?0:a.sharedDepth(n),c=a.start(l),f=a.node(l).content.cut(a.pos-c,o.pos-c);return new Slice(f,a.depth-l,o.depth-l)}replace(t,n,s){return replace(this.resolve(t),this.resolve(n),s)}nodeAt(t){for(let n=this;;){let{index:s,offset:a}=n.content.findIndex(t);if(n=n.maybeChild(s),!n)return null;if(a==t||n.isText)return n;t-=a+1}}childAfter(t){let{index:n,offset:s}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:s}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:s}=this.content.findIndex(t);if(s<t)return{node:this.content.child(n),index:n,offset:s};let a=this.content.child(n-1);return{node:a,index:n-1,offset:s-a.nodeSize}}resolve(t){return ResolvedPos.resolveCached(this,t)}resolveNoCache(t){return ResolvedPos.resolve(this,t)}rangeHasMark(t,n,s){let a=!1;return n>t&&this.nodesBetween(t,n,o=>(s.isInSet(o.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),wrapMarks(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,s=Fragment.empty,a=0,o=s.childCount){let l=this.contentMatchAt(t).matchFragment(s,a,o),c=l&&l.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let d=a;d<o;d++)if(!this.type.allowsMarks(s.child(d).marks))return!1;return!0}canReplaceWith(t,n,s,a){if(a&&!this.type.allowsMarks(a))return!1;let o=this.contentMatchAt(t).matchType(s),l=o&&o.matchFragment(this.content,n);return l?l.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=Mark$1.none;for(let n=0;n<this.marks.length;n++){let s=this.marks[n];s.type.checkAttrs(s.attrs),t=s.addToSet(t)}if(!Mark$1.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,s)}let a=Fragment.fromJSON(t,n.content),o=t.nodeType(n.type).create(n.attrs,a,s);return o.type.checkAttrs(o.attrs),o}};Node$1.prototype.text=void 0;class TextNode extends Node$1{constructor(t,n,s,a){if(super(t,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wrapMarks(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new TextNode(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new TextNode(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function wrapMarks(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ContentMatch{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let s=new TokenStream(t,n);if(s.next==null)return ContentMatch.empty;let a=parseExpr(s);s.next&&s.err("Unexpected trailing text");let o=dfa(nfa(a));return checkForDeadEnds(o,s),o}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,s=t.childCount){let a=this;for(let o=n;a&&o<s;o++)a=a.matchType(t.child(o).type);return a}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let s=0;s<t.next.length;s++)if(this.next[n].type==t.next[s].type)return!0;return!1}fillBefore(t,n=!1,s=0){let a=[this];function o(l,c){let d=l.matchFragment(t,s);if(d&&(!n||d.validEnd))return Fragment.from(c.map(f=>f.createAndFill()));for(let f=0;f<l.next.length;f++){let{type:R,next:S}=l.next[f];if(!(R.isText||R.hasRequiredAttrs())&&a.indexOf(S)==-1){a.push(S);let te=o(S,c.concat(R));if(te)return te}}return null}return o(this,[])}findWrapping(t){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==t)return this.wrapCache[s+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let a=s.shift(),o=a.match;if(o.matchType(t)){let l=[];for(let c=a;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<o.next.length;l++){let{type:c,next:d}=o.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!a.type||d.validEnd)&&(s.push({match:c.contentMatch,type:c,via:a}),n[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(s){t.push(s);for(let a=0;a<s.next.length;a++)t.indexOf(s.next[a].next)==-1&&n(s.next[a].next)}return n(this),t.map((s,a)=>{let o=a+(s.validEnd?"*":" ")+" ";for(let l=0;l<s.next.length;l++)o+=(l?", ":"")+s.next[l].type.name+"->"+t.indexOf(s.next[l].next);return o}).join(`
|
|
523
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return React__namespace.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Root2$1=AlertDialog$1,Trigger2$1=AlertDialogTrigger$1,Portal2=AlertDialogPortal$1,Overlay2=AlertDialogOverlay$1,Content2$1=AlertDialogContent$1,Action=AlertDialogAction$1,Cancel=AlertDialogCancel$1,Title2=AlertDialogTitle$1,Description2=AlertDialogDescription$1;const AlertDialog=Root2$1,AlertDialogTrigger=Trigger2$1,AlertDialogPortal=Portal2,AlertDialogOverlay=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Overlay2,{className:cn("fixed inset-0 z-50 bg-foreground/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));AlertDialogOverlay.displayName=Overlay2.displayName;const AlertDialogContent=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsxs(AlertDialogPortal,{children:[jsxRuntime.jsx(AlertDialogOverlay,{}),jsxRuntime.jsx(Content2$1,{ref:n,className:cn("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));AlertDialogContent.displayName=Content2$1.displayName;const AlertDialogHeader=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col space-y-2 text-center sm:text-left",e),...t});AlertDialogHeader.displayName="AlertDialogHeader";const AlertDialogFooter=({className:e,...t})=>jsxRuntime.jsx("div",{className:cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});AlertDialogFooter.displayName="AlertDialogFooter";const AlertDialogTitle=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Title2,{ref:n,className:cn("text-lg font-semibold",e),...t}));AlertDialogTitle.displayName=Title2.displayName;const AlertDialogDescription=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Description2,{ref:n,className:cn("text-sm text-muted-foreground",e),...t}));AlertDialogDescription.displayName=Description2.displayName;const AlertDialogAction=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Action,{ref:n,className:cn(buttonVariants(),e),...t}));AlertDialogAction.displayName=Action.displayName;const AlertDialogCancel=React__namespace.forwardRef(({className:e,...t},n)=>jsxRuntime.jsx(Cancel,{ref:n,className:cn(buttonVariants({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));AlertDialogCancel.displayName=Cancel.displayName;function parseDate(e){if(e==null)return null;const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function formatLastRefresh(e){const t=parseDate(e);if(!t)return"Never";const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()?`Today at ${new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(t)}function RefreshCluster({lastRefreshAt:e,onRefresh:t,onProgressiveRefresh:n,onAssistantClick:s,isRefreshing:a=!1,refreshLabel:o="Refresh",assistantLabel:l="Assistant",className:c,disabled:d=!1}){const[f,R]=React__namespace.useState(!1),[S,te]=React__namespace.useState(e);React__namespace.useEffect(()=>{te(e)},[e]);const A=!!(t||n),rt=a||f,st=e??S,it=React__namespace.useCallback(async()=>{if(!(!A||d||rt)){R(!0);try{n?(await n(!1),await n(!0)):await t?.(),te(new Date)}finally{R(!1)}}},[A,d,rt,n,t]);return jsxRuntime.jsxs("div",{className:cn("flex flex-wrap items-center justify-end gap-2",c),children:[jsxRuntime.jsxs("p",{className:"text-xs text-muted-foreground sm:text-sm",children:["Last refresh:"," ",jsxRuntime.jsx("span",{className:"font-medium text-foreground",children:formatLastRefresh(st)})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"outline",className:"min-h-11",disabled:d||rt||!A,onClick:it,children:[rt?jsxRuntime.jsx(LoaderCircle,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):jsxRuntime.jsx(RefreshCw,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:o})]}),jsxRuntime.jsxs(Button$1,{type:"button",variant:"default",className:"min-h-11",disabled:d,onClick:s,children:[jsxRuntime.jsx(Bot,{className:"h-4 w-4","aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l})]})]})}function DataRefreshAssistantCluster({onAssistantClick:e,assistantPromptOptions:t,onAssistantUnavailable:n,...s}){const a=useOptionalChat(),o=React__namespace.useCallback(()=>{if(e){e();return}if(t){if(!a){n?.();return}a.sendMessageWithClear(t.prompt,t.hiddenPrompt,t.sopID)||n?.();return}n?.()},[t,a,e,n]);return jsxRuntime.jsx(RefreshCluster,{...s,onAssistantClick:o})}const fullBleedClassName="w-full max-w-none w-[100cqw] ml-[calc(50%-50cqw)] mr-[calc(50%-50cqw)]",rowInlinePaddingClassName="px-4 lg:px-6",primaryRowPaddingClassName=`${rowInlinePaddingClassName} py-4`,secondaryRowPaddingClassName=`${rowInlinePaddingClassName} py-3`;function RmPageHeaderBreadcrumbLink({item:e,isCurrent:t}){return!t&&e.href?jsxRuntime.jsx("a",{href:e.href,className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:e.label}):!t&&e.onClick?jsxRuntime.jsx("button",{type:"button",className:"text-xs font-medium text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",onClick:e.onClick,children:e.label}):jsxRuntime.jsx("span",{"aria-current":t?"page":void 0,className:cn("text-xs font-medium",t?"text-foreground":"text-muted-foreground"),children:e.label})}function RmPageHeaderBreadcrumbs({items:e}){return e.length===0?null:jsxRuntime.jsx("nav",{"aria-label":"Breadcrumb",className:"w-full",children:jsxRuntime.jsx("ol",{className:"flex flex-wrap items-center gap-1.5",children:e.map((t,n)=>{const s=n===e.length-1,a=t.key??`${String(t.label)}-${n}`;return jsxRuntime.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[jsxRuntime.jsx(RmPageHeaderBreadcrumbLink,{item:t,isCurrent:!!t.current||s}),s?null:jsxRuntime.jsx("span",{"aria-hidden":"true",className:"text-xs text-muted-foreground",children:"/"})]},a)})})})}function RmPageHeader({title:e,subtitle:t,breadcrumbs:n,rightTopActions:s,rightBottomActions:a,secondaryRow:o,sticky:l=!1,stickyClassName:c,className:d,cardClassName:f,contentClassName:R}){const S=!!(s||a),te=jsxRuntime.jsxs("header",{className:cn("w-full border-b border-border bg-background",d),children:[jsxRuntime.jsx("div",{className:cn(primaryRowPaddingClassName,f),children:jsxRuntime.jsxs("div",{className:cn("flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",R),children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[n?.length?jsxRuntime.jsx(RmPageHeaderBreadcrumbs,{items:n}):null,jsxRuntime.jsx("h1",{className:"text-2xl font-semibold leading-tight tracking-tight text-foreground",children:e}),t?jsxRuntime.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),S?jsxRuntime.jsxs("div",{className:"flex w-full flex-col items-start gap-2 lg:w-auto lg:min-w-[16rem] lg:items-end",children:[s?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:s}):null,a?jsxRuntime.jsx("div",{className:"flex w-full flex-wrap items-center justify-start gap-2 lg:justify-end",children:a}):null]}):null]})}),o?jsxRuntime.jsx("div",{className:"border-t border-border bg-primary/5",children:jsxRuntime.jsx("div",{className:secondaryRowPaddingClassName,children:o})}):null]});return l?jsxRuntime.jsx("div",{className:fullBleedClassName,children:jsxRuntime.jsx("div",{className:cn("sticky top-0 z-20",c),children:te})}):jsxRuntime.jsx("div",{className:fullBleedClassName,children:te})}function PageHeader({title:e,children:t,className:n}){return jsxRuntime.jsx(RmPageHeader,{title:e,rightBottomActions:t?jsxRuntime.jsx("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:t}):void 0,cardClassName:n})}function RmBodyZone({className:e,children:t,...n}){return jsxRuntime.jsx("section",{className:cn("px-4 py-4 sm:px-6 sm:py-6",e),...n,children:t})}function OrderedMap(e){this.content=e}OrderedMap.prototype={constructor:OrderedMap,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var s=n&&n!=e?this.remove(n):this,a=s.find(e),o=s.content.slice();return a==-1?o.push(n||e,t):(o[a+1]=t,n&&(o[a]=n)),new OrderedMap(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new OrderedMap(n)},addToStart:function(e,t){return new OrderedMap([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new OrderedMap(n)},addBefore:function(e,t,n){var s=this.remove(t),a=s.content.slice(),o=s.find(e);return a.splice(o==-1?a.length:o,0,t,n),new OrderedMap(a)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=OrderedMap.from(e),e.size?new OrderedMap(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=OrderedMap.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},OrderedMap.from=function(e){if(e instanceof OrderedMap)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new OrderedMap(t)};function findDiffStart(e,t,n){for(let s=0;;s++){if(s==e.childCount||s==t.childCount)return e.childCount==t.childCount?null:n;let a=e.child(s),o=t.child(s);if(a==o){n+=a.nodeSize;continue}if(!a.sameMarkup(o))return n;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)n++;return n}if(a.content.size||o.content.size){let l=findDiffStart(a.content,o.content,n+1);if(l!=null)return l}n+=a.nodeSize}}function findDiffEnd(e,t,n,s){for(let a=e.childCount,o=t.childCount;;){if(a==0||o==0)return a==o?null:{a:n,b:s};let l=e.child(--a),c=t.child(--o),d=l.nodeSize;if(l==c){n-=d,s-=d;continue}if(!l.sameMarkup(c))return{a:n,b:s};if(l.isText&&l.text!=c.text){let f=0,R=Math.min(l.text.length,c.text.length);for(;f<R&&l.text[l.text.length-f-1]==c.text[c.text.length-f-1];)f++,n--,s--;return{a:n,b:s}}if(l.content.size||c.content.size){let f=findDiffEnd(l.content,c.content,n-1,s-1);if(f)return f}n-=d,s-=d}}class Fragment{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let s=0;s<t.length;s++)this.size+=t[s].nodeSize}nodesBetween(t,n,s,a=0,o){for(let l=0,c=0;c<n;l++){let d=this.content[l],f=c+d.nodeSize;if(f>t&&s(d,a+c,o||null,l)!==!1&&d.content.size){let R=c+1;d.nodesBetween(Math.max(0,t-R),Math.min(d.content.size,n-R),s,a+R)}c=f}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,s,a){let o="",l=!0;return this.nodesBetween(t,n,(c,d)=>{let f=c.isText?c.text.slice(Math.max(t,d)-d,n-d):c.isLeaf?a?typeof a=="function"?a(c):a:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&s&&(l?l=!1:o+=s),o+=f},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,s=t.firstChild,a=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(s)&&(a[a.length-1]=n.withText(n.text+s.text),o=1);o<t.content.length;o++)a.push(t.content[o]);return new Fragment(a,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let s=[],a=0;if(n>t)for(let o=0,l=0;l<n;o++){let c=this.content[o],d=l+c.nodeSize;d>t&&((l<t||d>n)&&(c.isText?c=c.cut(Math.max(0,t-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,t-l-1),Math.min(c.content.size,n-l-1))),s.push(c),a+=c.nodeSize),l=d}return new Fragment(s,a)}cutByIndex(t,n){return t==n?Fragment.empty:t==0&&n==this.content.length?this:new Fragment(this.content.slice(t,n))}replaceChild(t,n){let s=this.content[t];if(s==n)return this;let a=this.content.slice(),o=this.size+n.nodeSize-s.nodeSize;return a[t]=n,new Fragment(a,o)}addToStart(t){return new Fragment([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new Fragment(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,s=0;n<this.content.length;n++){let a=this.content[n];t(a,s,n),s+=a.nodeSize}}findDiffStart(t,n=0){return findDiffStart(this,t,n)}findDiffEnd(t,n=this.size,s=t.size){return findDiffEnd(this,t,n,s)}findIndex(t){if(t==0)return retIndex(0,t);if(t==this.size)return retIndex(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,s=0;;n++){let a=this.child(n),o=s+a.nodeSize;if(o>=t)return o==t?retIndex(n+1,o):retIndex(n,s);s=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return Fragment.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Fragment(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return Fragment.empty;let n,s=0;for(let a=0;a<t.length;a++){let o=t[a];s+=o.nodeSize,a&&o.isText&&t[a-1].sameMarkup(o)?(n||(n=t.slice(0,a)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new Fragment(n||t,s)}static from(t){if(!t)return Fragment.empty;if(t instanceof Fragment)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new Fragment([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Fragment.empty=new Fragment([],0);const found={index:0,offset:0};function retIndex(e,t){return found.index=e,found.offset=t,found}function compareDeep(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!compareDeep(e[s],t[s]))return!1}else{for(let s in e)if(!(s in t)||!compareDeep(e[s],t[s]))return!1;for(let s in t)if(!(s in e))return!1}return!0}let Mark$1=class Vn{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,s=!1;for(let a=0;a<t.length;a++){let o=t[a];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,a));else{if(o.type.excludes(this.type))return t;!s&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,a)),n.push(this),s=!0),n&&n.push(o)}}return n||(n=t.slice()),s||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&compareDeep(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let s=t.marks[n.type];if(!s)throw new RangeError(`There is no mark type ${n.type} in this schema`);let a=s.create(n.attrs);return s.checkAttrs(a.attrs),a}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let s=0;s<t.length;s++)if(!t[s].eq(n[s]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Vn.none;if(t instanceof Vn)return[t];let n=t.slice();return n.sort((s,a)=>s.type.rank-a.type.rank),n}};Mark$1.none=[];class ReplaceError extends Error{}class Slice{constructor(t,n,s){this.content=t,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let s=insertInto(this.content,t+this.openStart,n);return s&&new Slice(s,this.openStart,this.openEnd)}removeBetween(t,n){return new Slice(removeRange(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return Slice.empty;let s=n.openStart||0,a=n.openEnd||0;if(typeof s!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Slice(Fragment.fromJSON(t,n.content),s,a)}static maxOpen(t,n=!0){let s=0,a=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)s++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)a++;return new Slice(t,s,a)}}Slice.empty=new Slice(Fragment.empty,0,0);function removeRange(e,t,n){let{index:s,offset:a}=e.findIndex(t),o=e.maybeChild(s),{index:l,offset:c}=e.findIndex(n);if(a==t||o.isText){if(c!=n&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(s!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(s,o.copy(removeRange(o.content,t-a-1,n-a-1)))}function insertInto(e,t,n,s){let{index:a,offset:o}=e.findIndex(t),l=e.maybeChild(a);if(o==t||l.isText)return s&&!s.canReplace(a,a,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=insertInto(l.content,t-o-1,n,l);return c&&e.replaceChild(a,l.copy(c))}function replace(e,t,n){if(n.openStart>e.depth)throw new ReplaceError("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ReplaceError("Inconsistent open depths");return replaceOuter(e,t,n,0)}function replaceOuter(e,t,n,s){let a=e.index(s),o=e.node(s);if(a==t.index(s)&&s<e.depth-n.openStart){let l=replaceOuter(e,t,n,s+1);return o.copy(o.content.replaceChild(a,l))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&e.depth==s&&t.depth==s){let l=e.parent,c=l.content;return close(l,c.cut(0,e.parentOffset).append(n.content).append(c.cut(t.parentOffset)))}else{let{start:l,end:c}=prepareSliceForReplace(n,e);return close(o,replaceThreeWay(e,l,c,t,s))}else return close(o,replaceTwoWay(e,t,s))}function checkJoin(e,t){if(!t.type.compatibleContent(e.type))throw new ReplaceError("Cannot join "+t.type.name+" onto "+e.type.name)}function joinable$1(e,t,n){let s=e.node(n);return checkJoin(s,t.node(n)),s}function addNode(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function addRange(e,t,n,s){let a=(t||e).node(n),o=0,l=t?t.index(n):a.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(addNode(e.nodeAfter,s),o++));for(let c=o;c<l;c++)addNode(a.child(c),s);t&&t.depth==n&&t.textOffset&&addNode(t.nodeBefore,s)}function close(e,t){return e.type.checkContent(t),e.copy(t)}function replaceThreeWay(e,t,n,s,a){let o=e.depth>a&&joinable$1(e,t,a+1),l=s.depth>a&&joinable$1(n,s,a+1),c=[];return addRange(null,e,a,c),o&&l&&t.index(a)==n.index(a)?(checkJoin(o,l),addNode(close(o,replaceThreeWay(e,t,n,s,a+1)),c)):(o&&addNode(close(o,replaceTwoWay(e,t,a+1)),c),addRange(t,n,a,c),l&&addNode(close(l,replaceTwoWay(n,s,a+1)),c)),addRange(s,null,a,c),new Fragment(c)}function replaceTwoWay(e,t,n){let s=[];if(addRange(null,e,n,s),e.depth>n){let a=joinable$1(e,t,n+1);addNode(close(a,replaceTwoWay(e,t,n+1)),s)}return addRange(t,null,n,s),new Fragment(s)}function prepareSliceForReplace(e,t){let n=t.depth-e.openStart,a=t.node(n).copy(e.content);for(let o=n-1;o>=0;o--)a=t.node(o).copy(Fragment.from(a));return{start:a.resolveNoCache(e.openStart+n),end:a.resolveNoCache(a.content.size-e.openEnd-n)}}class ResolvedPos{constructor(t,n,s){this.pos=t,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,n=this.index(this.depth);if(n==t.childCount)return null;let s=this.pos-this.path[this.path.length-1],a=t.child(n);return s?t.child(n).cut(s):a}get nodeBefore(){let t=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(t).cut(0,n):t==0?null:this.parent.child(t-1)}posAtIndex(t,n){n=this.resolveDepth(n);let s=this.path[n*3],a=n==0?0:this.path[n*3-1]+1;for(let o=0;o<t;o++)a+=s.child(o).nodeSize;return a}marks(){let t=this.parent,n=this.index();if(t.content.size==0)return Mark$1.none;if(this.textOffset)return t.child(n).marks;let s=t.maybeChild(n-1),a=t.maybeChild(n);if(!s){let c=s;s=a,a=c}let o=s.marks;for(var l=0;l<o.length;l++)o[l].type.spec.inclusive===!1&&(!a||!o[l].isInSet(a.marks))&&(o=o[l--].removeFromSet(o));return o}marksAcross(t){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let s=n.marks,a=t.parent.maybeChild(t.index());for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!a||!s[o].isInSet(a.marks))&&(s=s[o--].removeFromSet(s));return s}sharedDepth(t){for(let n=this.depth;n>0;n--)if(this.start(n)<=t&&this.end(n)>=t)return n;return 0}blockRange(t=this,n){if(t.pos<this.pos)return t.blockRange(this);for(let s=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);s>=0;s--)if(t.pos<=this.end(s)&&(!n||n(this.node(s))))return new NodeRange(this,t,s);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let n=1;n<=this.depth;n++)t+=(t?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return t+":"+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw new RangeError("Position "+n+" out of range");let s=[],a=0,o=n;for(let l=t;;){let{index:c,offset:d}=l.content.findIndex(o),f=o-d;if(s.push(l,c,a+d),!f||(l=l.child(c),l.isText))break;o=f-1,a+=d+1}return new ResolvedPos(n,s,o)}static resolveCached(t,n){let s=resolveCache.get(t);if(s)for(let o=0;o<s.elts.length;o++){let l=s.elts[o];if(l.pos==n)return l}else resolveCache.set(t,s=new ResolveCache);let a=s.elts[s.i]=ResolvedPos.resolve(t,n);return s.i=(s.i+1)%resolveCacheSize,a}}class ResolveCache{constructor(){this.elts=[],this.i=0}}const resolveCacheSize=12,resolveCache=new WeakMap;class NodeRange{constructor(t,n,s){this.$from=t,this.$to=n,this.depth=s}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const emptyAttrs=Object.create(null);let Node$1=class zn{constructor(t,n,s,a=Mark$1.none){this.type=t,this.attrs=n,this.marks=a,this.content=s||Fragment.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,n,s,a=0){this.content.nodesBetween(t,n,s,a,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,n,s,a){return this.content.textBetween(t,n,s,a)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,n,s){return this.type==t&&compareDeep(this.attrs,n||t.defaultAttrs||emptyAttrs)&&Mark$1.sameSet(this.marks,s||Mark$1.none)}copy(t=null){return t==this.content?this:new zn(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new zn(this.type,this.attrs,this.content,t)}cut(t,n=this.content.size){return t==0&&n==this.content.size?this:this.copy(this.content.cut(t,n))}slice(t,n=this.content.size,s=!1){if(t==n)return Slice.empty;let a=this.resolve(t),o=this.resolve(n),l=s?0:a.sharedDepth(n),c=a.start(l),f=a.node(l).content.cut(a.pos-c,o.pos-c);return new Slice(f,a.depth-l,o.depth-l)}replace(t,n,s){return replace(this.resolve(t),this.resolve(n),s)}nodeAt(t){for(let n=this;;){let{index:s,offset:a}=n.content.findIndex(t);if(n=n.maybeChild(s),!n)return null;if(a==t||n.isText)return n;t-=a+1}}childAfter(t){let{index:n,offset:s}=this.content.findIndex(t);return{node:this.content.maybeChild(n),index:n,offset:s}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:n,offset:s}=this.content.findIndex(t);if(s<t)return{node:this.content.child(n),index:n,offset:s};let a=this.content.child(n-1);return{node:a,index:n-1,offset:s-a.nodeSize}}resolve(t){return ResolvedPos.resolveCached(this,t)}resolveNoCache(t){return ResolvedPos.resolve(this,t)}rangeHasMark(t,n,s){let a=!1;return n>t&&this.nodesBetween(t,n,o=>(s.isInSet(o.marks)&&(a=!0),!a)),a}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),wrapMarks(this.marks,t)}contentMatchAt(t){let n=this.type.contentMatch.matchFragment(this.content,0,t);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(t,n,s=Fragment.empty,a=0,o=s.childCount){let l=this.contentMatchAt(t).matchFragment(s,a,o),c=l&&l.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let d=a;d<o;d++)if(!this.type.allowsMarks(s.child(d).marks))return!1;return!0}canReplaceWith(t,n,s,a){if(a&&!this.type.allowsMarks(a))return!1;let o=this.contentMatchAt(t).matchType(s),l=o&&o.matchFragment(this.content,n);return l?l.validEnd:!1}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=Mark$1.none;for(let n=0;n<this.marks.length;n++){let s=this.marks[n];s.type.checkAttrs(s.attrs),t=s.addToSet(t)}if(!Mark$1.sameSet(t,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(n=>n.toJSON())),t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(t.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(n.text,s)}let a=Fragment.fromJSON(t,n.content),o=t.nodeType(n.type).create(n.attrs,a,s);return o.type.checkAttrs(o.attrs),o}};Node$1.prototype.text=void 0;class TextNode extends Node$1{constructor(t,n,s,a){if(super(t,n,null,a),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wrapMarks(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,n){return this.text.slice(t,n)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new TextNode(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new TextNode(this.type,this.attrs,t,this.marks)}cut(t=0,n=this.text.length){return t==0&&n==this.text.length?this:this.withText(this.text.slice(t,n))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function wrapMarks(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ContentMatch{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,n){let s=new TokenStream(t,n);if(s.next==null)return ContentMatch.empty;let a=parseExpr(s);s.next&&s.err("Unexpected trailing text");let o=dfa(nfa(a));return checkForDeadEnds(o,s),o}matchType(t){for(let n=0;n<this.next.length;n++)if(this.next[n].type==t)return this.next[n].next;return null}matchFragment(t,n=0,s=t.childCount){let a=this;for(let o=n;a&&o<s;o++)a=a.matchType(t.child(o).type);return a}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:n}=this.next[t];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(t){for(let n=0;n<this.next.length;n++)for(let s=0;s<t.next.length;s++)if(this.next[n].type==t.next[s].type)return!0;return!1}fillBefore(t,n=!1,s=0){let a=[this];function o(l,c){let d=l.matchFragment(t,s);if(d&&(!n||d.validEnd))return Fragment.from(c.map(f=>f.createAndFill()));for(let f=0;f<l.next.length;f++){let{type:R,next:S}=l.next[f];if(!(R.isText||R.hasRequiredAttrs())&&a.indexOf(S)==-1){a.push(S);let te=o(S,c.concat(R));if(te)return te}}return null}return o(this,[])}findWrapping(t){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==t)return this.wrapCache[s+1];let n=this.computeWrapping(t);return this.wrapCache.push(t,n),n}computeWrapping(t){let n=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let a=s.shift(),o=a.match;if(o.matchType(t)){let l=[];for(let c=a;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<o.next.length;l++){let{type:c,next:d}=o.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!a.type||d.validEnd)&&(s.push({match:c.contentMatch,type:c,via:a}),n[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function n(s){t.push(s);for(let a=0;a<s.next.length;a++)t.indexOf(s.next[a].next)==-1&&n(s.next[a].next)}return n(this),t.map((s,a)=>{let o=a+(s.validEnd?"*":" ")+" ";for(let l=0;l<s.next.length;l++)o+=(l?", ":"")+s.next[l].type.name+"->"+t.indexOf(s.next[l].next);return o}).join(`
|
|
524
524
|
`)}}ContentMatch.empty=new ContentMatch(!0);class TokenStream{constructor(t,n){this.string=t,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function parseExpr(e){let t=[];do t.push(parseExprSeq(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function parseExprSeq(e){let t=[];do t.push(parseExprSubscript(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function parseExprSubscript(e){let t=parseExprAtom(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=parseExprRange(e,t);else break;return t}function parseNum(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function parseExprRange(e,t){let n=parseNum(e),s=n;return e.eat(",")&&(e.next!="}"?s=parseNum(e):s=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:s,expr:t}}function resolveName(e,t){let n=e.nodeTypes,s=n[t];if(s)return[s];let a=[];for(let o in n){let l=n[o];l.isInGroup(t)&&a.push(l)}return a.length==0&&e.err("No node type or group '"+t+"' found"),a}function parseExprAtom(e){if(e.eat("(")){let t=parseExpr(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=resolveName(e,e.next).map(n=>(e.inline==null?e.inline=n.isInline:e.inline!=n.isInline&&e.err("Mixing inline and block content"),{type:"name",value:n}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function nfa(e){let t=[[]];return a(o(e,0),n()),t;function n(){return t.push([])-1}function s(l,c,d){let f={term:d,to:c};return t[l].push(f),f}function a(l,c){l.forEach(d=>d.to=c)}function o(l,c){if(l.type=="choice")return l.exprs.reduce((d,f)=>d.concat(o(f,c)),[]);if(l.type=="seq")for(let d=0;;d++){let f=o(l.exprs[d],c);if(d==l.exprs.length-1)return f;a(f,c=n())}else if(l.type=="star"){let d=n();return s(c,d),a(o(l.expr,d),d),[s(d)]}else if(l.type=="plus"){let d=n();return a(o(l.expr,c),d),a(o(l.expr,d),d),[s(d)]}else{if(l.type=="opt")return[s(c)].concat(o(l.expr,c));if(l.type=="range"){let d=c;for(let f=0;f<l.min;f++){let R=n();a(o(l.expr,d),R),d=R}if(l.max==-1)a(o(l.expr,d),d);else for(let f=l.min;f<l.max;f++){let R=n();s(d,R),a(o(l.expr,d),R),d=R}return[s(d)]}else{if(l.type=="name")return[s(c,void 0,l.value)];throw new Error("Unknown expr type")}}}}function cmp(e,t){return t-e}function nullFrom(e,t){let n=[];return s(t),n.sort(cmp);function s(a){let o=e[a];if(o.length==1&&!o[0].term)return s(o[0].to);n.push(a);for(let l=0;l<o.length;l++){let{term:c,to:d}=o[l];!c&&n.indexOf(d)==-1&&s(d)}}}function dfa(e){let t=Object.create(null);return n(nullFrom(e,0));function n(s){let a=[];s.forEach(l=>{e[l].forEach(({term:c,to:d})=>{if(!c)return;let f;for(let R=0;R<a.length;R++)a[R][0]==c&&(f=a[R][1]);nullFrom(e,d).forEach(R=>{f||a.push([c,f=[]]),f.indexOf(R)==-1&&f.push(R)})})});let o=t[s.join(",")]=new ContentMatch(s.indexOf(e.length-1)>-1);for(let l=0;l<a.length;l++){let c=a[l][1].sort(cmp);o.next.push({type:a[l][0],next:t[c.join(",")]||n(c)})}return o}}function checkForDeadEnds(e,t){for(let n=0,s=[e];n<s.length;n++){let a=s[n],o=!a.validEnd,l=[];for(let c=0;c<a.next.length;c++){let{type:d,next:f}=a.next[c];l.push(d.name),o&&!(d.isText||d.hasRequiredAttrs())&&(o=!1),s.indexOf(f)==-1&&s.push(f)}o&&t.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function defaultAttrs(e){let t=Object.create(null);for(let n in e){let s=e[n];if(!s.hasDefault)return null;t[n]=s.default}return t}function computeAttrs(e,t){let n=Object.create(null);for(let s in e){let a=t&&t[s];if(a===void 0){let o=e[s];if(o.hasDefault)a=o.default;else throw new RangeError("No value supplied for attribute "+s)}n[s]=a}return n}function checkAttrs(e,t,n,s){for(let a in t)if(!(a in e))throw new RangeError(`Unsupported attribute ${a} for ${n} of type ${a}`);for(let a in e){let o=e[a];o.validate&&o.validate(t[a])}}function initAttrs(e,t){let n=Object.create(null);if(t)for(let s in t)n[s]=new Attribute(e,s,t[s]);return n}let NodeType$1=class Gn{constructor(t,n,s){this.name=t,this.schema=n,this.spec=s,this.markSet=null,this.groups=s.group?s.group.split(" "):[],this.attrs=initAttrs(t,s.attrs),this.defaultAttrs=defaultAttrs(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(s.inline||t=="text"),this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ContentMatch.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(t){return this.groups.indexOf(t)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:computeAttrs(this.attrs,t)}create(t=null,n,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Node$1(this,this.computeAttrs(t),Fragment.from(n),Mark$1.setFrom(s))}createChecked(t=null,n,s){return n=Fragment.from(n),this.checkContent(n),new Node$1(this,this.computeAttrs(t),n,Mark$1.setFrom(s))}createAndFill(t=null,n,s){if(t=this.computeAttrs(t),n=Fragment.from(n),n.size){let l=this.contentMatch.fillBefore(n);if(!l)return null;n=l.append(n)}let a=this.contentMatch.matchFragment(n),o=a&&a.fillBefore(Fragment.empty,!0);return o?new Node$1(this,t,n.append(o),Mark$1.setFrom(s)):null}validContent(t){let n=this.contentMatch.matchFragment(t);if(!n||!n.validEnd)return!1;for(let s=0;s<t.childCount;s++)if(!this.allowsMarks(t.child(s).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){checkAttrs(this.attrs,t,"node",this.name)}allowsMarkType(t){return this.markSet==null||this.markSet.indexOf(t)>-1}allowsMarks(t){if(this.markSet==null)return!0;for(let n=0;n<t.length;n++)if(!this.allowsMarkType(t[n].type))return!1;return!0}allowedMarks(t){if(this.markSet==null)return t;let n;for(let s=0;s<t.length;s++)this.allowsMarkType(t[s].type)?n&&n.push(t[s]):n||(n=t.slice(0,s));return n?n.length?n:Mark$1.none:t}static compile(t,n){let s=Object.create(null);t.forEach((o,l)=>s[o]=new Gn(o,n,l));let a=n.spec.topNode||"doc";if(!s[a])throw new RangeError("Schema is missing its top node type ('"+a+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let o in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function validateType(e,t,n){let s=n.split("|");return a=>{let o=a===null?"null":typeof a;if(s.indexOf(o)<0)throw new RangeError(`Expected value of type ${s} for attribute ${t} on type ${e}, got ${o}`)}}class Attribute{constructor(t,n,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?validateType(t,n,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class MarkType{constructor(t,n,s,a){this.name=t,this.rank=n,this.schema=s,this.spec=a,this.attrs=initAttrs(t,a.attrs),this.excluded=null;let o=defaultAttrs(this.attrs);this.instance=o?new Mark$1(this,o):null}create(t=null){return!t&&this.instance?this.instance:new Mark$1(this,computeAttrs(this.attrs,t))}static compile(t,n){let s=Object.create(null),a=0;return t.forEach((o,l)=>s[o]=new MarkType(o,a++,n,l)),s}removeFromSet(t){for(var n=0;n<t.length;n++)t[n].type==this&&(t=t.slice(0,n).concat(t.slice(n+1)),n--);return t}isInSet(t){for(let n=0;n<t.length;n++)if(t[n].type==this)return t[n]}checkAttrs(t){checkAttrs(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class Schema{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let a in t)n[a]=t[a];n.nodes=OrderedMap.from(t.nodes),n.marks=OrderedMap.from(t.marks||{}),this.nodes=NodeType$1.compile(this.spec.nodes,this),this.marks=MarkType.compile(this.spec.marks,this);let s=Object.create(null);for(let a in this.nodes){if(a in this.marks)throw new RangeError(a+" can not be both a node and a mark");let o=this.nodes[a],l=o.spec.content||"",c=o.spec.marks;if(o.contentMatch=s[l]||(s[l]=ContentMatch.parse(l,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=c=="_"?null:c?gatherMarks(this,c.split(" ")):c==""||!o.inlineContent?[]:null}for(let a in this.marks){let o=this.marks[a],l=o.spec.excludes;o.excluded=l==null?[o]:l==""?[]:gatherMarks(this,l.split(" "))}this.nodeFromJSON=a=>Node$1.fromJSON(this,a),this.markFromJSON=a=>Mark$1.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,n=null,s,a){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof NodeType$1){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(n,s,a)}text(t,n){let s=this.nodes.text;return new TextNode(s,s.defaultAttrs,t,Mark$1.setFrom(n))}mark(t,n){return typeof t=="string"&&(t=this.marks[t]),t.create(n)}nodeType(t){let n=this.nodes[t];if(!n)throw new RangeError("Unknown node type: "+t);return n}}function gatherMarks(e,t){let n=[];for(let s=0;s<t.length;s++){let a=t[s],o=e.marks[a],l=o;if(o)n.push(o);else for(let c in e.marks){let d=e.marks[c];(a=="_"||d.spec.group&&d.spec.group.split(" ").indexOf(a)>-1)&&n.push(l=d)}if(!l)throw new SyntaxError("Unknown mark type: '"+t[s]+"'")}return n}function isTagRule(e){return e.tag!=null}function isStyleRule(e){return e.style!=null}class DOMParser{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[];let s=this.matchedStyles=[];n.forEach(a=>{if(isTagRule(a))this.tags.push(a);else if(isStyleRule(a)){let o=/[^=]*/.exec(a.style)[0];s.indexOf(o)<0&&s.push(o),this.styles.push(a)}}),this.normalizeLists=!this.tags.some(a=>{if(!/^(ul|ol)\b/.test(a.tag)||!a.node)return!1;let o=t.nodes[a.node];return o.contentMatch.matchType(o)})}parse(t,n={}){let s=new ParseContext(this,n,!1);return s.addAll(t,Mark$1.none,n.from,n.to),s.finish()}parseSlice(t,n={}){let s=new ParseContext(this,n,!0);return s.addAll(t,Mark$1.none,n.from,n.to),Slice.maxOpen(s.finish())}matchTag(t,n,s){for(let a=s?this.tags.indexOf(s)+1:0;a<this.tags.length;a++){let o=this.tags[a];if(matches(t,o.tag)&&(o.namespace===void 0||t.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}matchStyle(t,n,s,a){for(let o=a?this.styles.indexOf(a)+1:0;o<this.styles.length;o++){let l=this.styles[o],c=l.style;if(!(c.indexOf(t)!=0||l.context&&!s.matchesContext(l.context)||c.length>t.length&&(c.charCodeAt(t.length)!=61||c.slice(t.length+1)!=n))){if(l.getAttrs){let d=l.getAttrs(n);if(d===!1)continue;l.attrs=d||void 0}return l}}}static schemaRules(t){let n=[];function s(a){let o=a.priority==null?50:a.priority,l=0;for(;l<n.length;l++){let c=n[l];if((c.priority==null?50:c.priority)<o)break}n.splice(l,0,a)}for(let a in t.marks){let o=t.marks[a].spec.parseDOM;o&&o.forEach(l=>{s(l=copy(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in t.nodes){let o=t.nodes[a].spec.parseDOM;o&&o.forEach(l=>{s(l=copy(l)),l.node||l.ignore||l.mark||(l.node=a)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new DOMParser(t,DOMParser.schemaRules(t)))}}const blockTags={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ignoreTags={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},listTags={ol:!0,ul:!0},OPT_PRESERVE_WS=1,OPT_PRESERVE_WS_FULL=2,OPT_OPEN_LEFT=4;function wsOptionsFor(e,t,n){return t!=null?(t?OPT_PRESERVE_WS:0)|(t==="full"?OPT_PRESERVE_WS_FULL:0):e&&e.whitespace=="pre"?OPT_PRESERVE_WS|OPT_PRESERVE_WS_FULL:n&~OPT_OPEN_LEFT}class NodeContext{constructor(t,n,s,a,o,l){this.type=t,this.attrs=n,this.marks=s,this.solid=a,this.options=l,this.content=[],this.activeMarks=Mark$1.none,this.match=o||(l&OPT_OPEN_LEFT?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Fragment.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let s=this.type.contentMatch,a;return(a=s.findWrapping(t.type))?(this.match=s,a):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&OPT_PRESERVE_WS)){let s=this.content[this.content.length-1],a;if(s&&s.isText&&(a=/[ \t\r\n\u000c]+$/.exec(s.text))){let o=s;s.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let n=Fragment.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(Fragment.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!blockTags.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class ParseContext{constructor(t,n,s){this.parser=t,this.options=n,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let a=n.topNode,o,l=wsOptionsFor(null,n.preserveWhitespace,0)|(s?OPT_OPEN_LEFT:0);a?o=new NodeContext(a.type,a.attrs,Mark$1.none,!0,n.topMatch||a.type.contentMatch,l):s?o=new NodeContext(null,null,Mark$1.none,!0,null,l):o=new NodeContext(t.schema.topNodeType,null,Mark$1.none,!0,null,l),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,n){t.nodeType==3?this.addTextNode(t,n):t.nodeType==1&&this.addElement(t,n)}addTextNode(t,n){let s=t.nodeValue,a=this.top,o=a.options&OPT_PRESERVE_WS_FULL?"full":this.localPreserveWS||(a.options&OPT_PRESERVE_WS)>0,{schema:l}=this.parser;if(o==="full"||a.inlineContext(t)||/[^ \t\r\n\u000c]/.test(s)){if(o)if(o==="full")s=s.replace(/\r\n?/g,`
|
|
525
525
|
`);else if(l.linebreakReplacement&&/[\r\n]/.test(s)&&this.top.findWrapping(l.linebreakReplacement.create())){let c=s.split(/\r?\n|\r/);for(let d=0;d<c.length;d++)d&&this.insertNode(l.linebreakReplacement.create(),n,!0),c[d]&&this.insertNode(l.text(c[d]),n,!/\S/.test(c[d]));s=""}else s=s.replace(/\r?\n|\r/g," ");else if(s=s.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(s)&&this.open==this.nodes.length-1){let c=a.content[a.content.length-1],d=t.previousSibling;(!c||d&&d.nodeName=="BR"||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(s=s.slice(1))}s&&this.insertNode(l.text(s),n,!/\S/.test(s)),this.findInText(t)}else this.findInside(t)}addElement(t,n,s){let a=this.localPreserveWS,o=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let l=t.nodeName.toLowerCase(),c;listTags.hasOwnProperty(l)&&this.parser.normalizeLists&&normalizeList(t);let d=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(c=this.parser.matchTag(t,this,s));e:if(d?d.ignore:ignoreTags.hasOwnProperty(l))this.findInside(t),this.ignoreFallback(t,n);else if(!d||d.skip||d.closeParent){d&&d.closeParent?this.open=Math.max(0,this.open-1):d&&d.skip.nodeType&&(t=d.skip);let f,R=this.needsBlock;if(blockTags.hasOwnProperty(l))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),f=!0,o.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,n);break e}let S=d&&d.skip?n:this.readStyles(t,n);S&&this.addAll(t,S),f&&this.sync(o),this.needsBlock=R}else{let f=this.readStyles(t,n);f&&this.addElementByRule(t,d,f,d.consuming===!1?c:void 0)}this.localPreserveWS=a}leafFallback(t,n){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
526
526
|
`),n)}ignoreFallback(t,n){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(t,n){let s=t.style;if(s&&s.length)for(let a=0;a<this.parser.matchedStyles.length;a++){let o=this.parser.matchedStyles[a],l=s.getPropertyValue(o);if(l)for(let c=void 0;;){let d=this.parser.matchStyle(o,l,this,c);if(!d)break;if(d.ignore)return null;if(d.clearMark?n=n.filter(f=>!d.clearMark(f)):n=n.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)c=d;else break}}return n}addElementByRule(t,n,s,a){let o,l;if(n.node)if(l=this.parser.schema.nodes[n.node],l.isLeaf)this.insertNode(l.create(n.attrs),s,t.nodeName=="BR")||this.leafFallback(t,s);else{let d=this.enter(l,n.attrs||null,s,n.preserveWhitespace);d&&(o=!0,s=d)}else{let d=this.parser.schema.marks[n.mark];s=s.concat(d.create(n.attrs))}let c=this.top;if(l&&l.isLeaf)this.findInside(t);else if(a)this.addElement(t,s,a);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(d=>this.insertNode(d,s,!1));else{let d=t;typeof n.contentElement=="string"?d=t.querySelector(n.contentElement):typeof n.contentElement=="function"?d=n.contentElement(t):n.contentElement&&(d=n.contentElement),this.findAround(t,d,!0),this.addAll(d,s),this.findAround(t,d,!1)}o&&this.sync(c)&&this.open--}addAll(t,n,s,a){let o=s||0;for(let l=s?t.childNodes[s]:t.firstChild,c=a==null?null:t.childNodes[a];l!=c;l=l.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(l,n);this.findAtPoint(t,o)}findPlace(t,n,s){let a,o;for(let l=this.open,c=0;l>=0;l--){let d=this.nodes[l],f=d.findWrapping(t);if(f&&(!a||a.length>f.length+c)&&(a=f,o=d,!f.length))break;if(d.solid){if(s)break;c+=2}}if(!a)return null;this.sync(o);for(let l=0;l<a.length;l++)n=this.enterInner(a[l],null,n,!1);return n}insertNode(t,n,s){if(t.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let a=this.findPlace(t,n,s);if(a){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(t.type));let l=Mark$1.none;for(let c of a.concat(t.marks))(o.type?o.type.allowsMarkType(c.type):markMayApply(c.type,t.type))&&(l=c.addToSet(l));return o.content.push(t.mark(l)),!0}return!1}enter(t,n,s,a){let o=this.findPlace(t.create(n),s,!1);return o&&(o=this.enterInner(t,n,s,!0,a)),o}enterInner(t,n,s,a=!1,o){this.closeExtra();let l=this.top;l.match=l.match&&l.match.matchType(t);let c=wsOptionsFor(t,o,l.options);l.options&OPT_OPEN_LEFT&&l.content.length==0&&(c|=OPT_OPEN_LEFT);let d=Mark$1.none;return s=s.filter(f=>(l.type?l.type.allowsMarkType(f.type):markMayApply(f.type,t))?(d=f.addToSet(d),!1):!0),this.nodes.push(new NodeContext(t,n,d,a,null,c)),this.open++,s}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let n=this.open;n>=0;n--){if(this.nodes[n]==t)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=OPT_PRESERVE_WS)}return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let a=s.length-1;a>=0;a--)t+=s[a].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==t&&this.find[s].offset==n&&(this.find[s].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,s){if(t!=n&&this.find)for(let a=0;a<this.find.length;a++)this.find[a].pos==null&&t.nodeType==1&&t.contains(this.find[a].node)&&n.compareDocumentPosition(this.find[a].node)&(s?2:4)&&(this.find[a].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),s=this.options.context,a=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),o=-(s?s.depth+1:0)+(a?0:1),l=(c,d)=>{for(;c>=0;c--){let f=n[c];if(f==""){if(c==n.length-1||c==0)continue;for(;d>=o;d--)if(l(c-1,d))return!0;return!1}else{let R=d>0||d==0&&a?this.nodes[d].type:s&&d>=o?s.node(d-o).type:null;if(!R||R.name!=f&&!R.isInGroup(f))return!1;d--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}}function normalizeList(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let s=t.nodeType==1?t.nodeName.toLowerCase():null;s&&listTags.hasOwnProperty(s)&&n?(n.appendChild(t),t=n):s=="li"?n=t:s&&(n=null)}}function matches(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function copy(e){let t={};for(let n in e)t[n]=e[n];return t}function markMayApply(e,t){let n=t.schema.nodes;for(let s in n){let a=n[s];if(!a.allowsMarkType(e))continue;let o=[],l=c=>{o.push(c);for(let d=0;d<c.edgeCount;d++){let{type:f,next:R}=c.edge(d);if(f==t||o.indexOf(R)<0&&l(R))return!0}};if(l(a.contentMatch))return!0}}class DOMSerializer{constructor(t,n){this.nodes=t,this.marks=n}serializeFragment(t,n={},s){s||(s=doc$1(n).createDocumentFragment());let a=s,o=[];return t.forEach(l=>{if(o.length||l.marks.length){let c=0,d=0;for(;c<o.length&&d<l.marks.length;){let f=l.marks[d];if(!this.marks[f.type.name]){d++;continue}if(!f.eq(o[c][0])||f.type.spec.spanning===!1)break;c++,d++}for(;c<o.length;)a=o.pop()[1];for(;d<l.marks.length;){let f=l.marks[d++],R=this.serializeMark(f,l.isInline,n);R&&(o.push([f,a]),a.appendChild(R.dom),a=R.contentDOM||R.dom)}}a.appendChild(this.serializeNodeInner(l,n))}),s}serializeNodeInner(t,n){let{dom:s,contentDOM:a}=renderSpec(doc$1(n),this.nodes[t.type.name](t),null,t.attrs);if(a){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,n,a)}return s}serializeNode(t,n={}){let s=this.serializeNodeInner(t,n);for(let a=t.marks.length-1;a>=0;a--){let o=this.serializeMark(t.marks[a],t.isInline,n);o&&((o.contentDOM||o.dom).appendChild(s),s=o.dom)}return s}serializeMark(t,n,s={}){let a=this.marks[t.type.name];return a&&renderSpec(doc$1(s),a(t,n),null,t.attrs)}static renderSpec(t,n,s=null,a){return renderSpec(t,n,s,a)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new DOMSerializer(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let n=gatherToDOM(t.nodes);return n.text||(n.text=s=>s.text),n}static marksFromSchema(t){return gatherToDOM(t.marks)}}function gatherToDOM(e){let t={};for(let n in e){let s=e[n].spec.toDOM;s&&(t[n]=s)}return t}function doc$1(e){return e.document||window.document}const suspiciousAttributeCache=new WeakMap;function suspiciousAttributes(e){let t=suspiciousAttributeCache.get(e);return t===void 0&&suspiciousAttributeCache.set(e,t=suspiciousAttributesInner(e)),t}function suspiciousAttributesInner(e){let t=null;function n(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")t||(t=[]),t.push(s);else for(let a=0;a<s.length;a++)n(s[a]);else for(let a in s)n(s[a])}return n(e),t}function renderSpec(e,t,n,s){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let a=t[0],o;if(typeof a!="string")throw new RangeError("Invalid array passed to renderSpec");if(s&&(o=suspiciousAttributes(s))&&o.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=a.indexOf(" ");l>0&&(n=a.slice(0,l),a=a.slice(l+1));let c,d=n?e.createElementNS(n,a):e.createElement(a),f=t[1],R=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){R=2;for(let S in f)if(f[S]!=null){let te=S.indexOf(" ");te>0?d.setAttributeNS(S.slice(0,te),S.slice(te+1),f[S]):S=="style"&&d.style?d.style.cssText=f[S]:d.setAttribute(S,f[S])}}for(let S=R;S<t.length;S++){let te=t[S];if(te===0){if(S<t.length-1||S>R)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:A,contentDOM:rt}=renderSpec(e,te,n,s);if(d.appendChild(A),rt){if(c)throw new RangeError("Multiple content holes");c=rt}}}return{dom:d,contentDOM:c}}const lower16=65535,factor16=Math.pow(2,16);function makeRecover(e,t){return e+t*factor16}function recoverIndex(e){return e&lower16}function recoverOffset(e){return(e-(e&lower16))/factor16}const DEL_BEFORE=1,DEL_AFTER=2,DEL_ACROSS=4,DEL_SIDE=8;class MapResult{constructor(t,n,s){this.pos=t,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&DEL_SIDE)>0}get deletedBefore(){return(this.delInfo&(DEL_BEFORE|DEL_ACROSS))>0}get deletedAfter(){return(this.delInfo&(DEL_AFTER|DEL_ACROSS))>0}get deletedAcross(){return(this.delInfo&DEL_ACROSS)>0}}class StepMap{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&StepMap.empty)return StepMap.empty}recover(t){let n=0,s=recoverIndex(t);if(!this.inverted)for(let a=0;a<s;a++)n+=this.ranges[a*3+2]-this.ranges[a*3+1];return this.ranges[s*3]+n+recoverOffset(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,s){let a=0,o=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let d=this.ranges[c]-(this.inverted?a:0);if(d>t)break;let f=this.ranges[c+o],R=this.ranges[c+l],S=d+f;if(t<=S){let te=f?t==d?-1:t==S?1:n:n,A=d+a+(te<0?0:R);if(s)return A;let rt=t==(n<0?d:S)?null:makeRecover(c/3,t-d),st=t==d?DEL_AFTER:t==S?DEL_BEFORE:DEL_ACROSS;return(n<0?t!=d:t!=S)&&(st|=DEL_SIDE),new MapResult(A,st,rt)}a+=R-f}return s?t+a:new MapResult(t+a,0,null)}touches(t,n){let s=0,a=recoverIndex(n),o=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let d=this.ranges[c]-(this.inverted?s:0);if(d>t)break;let f=this.ranges[c+o],R=d+f;if(t<=R&&c==a*3)return!0;s+=this.ranges[c+l]-f}return!1}forEach(t){let n=this.inverted?2:1,s=this.inverted?1:2;for(let a=0,o=0;a<this.ranges.length;a+=3){let l=this.ranges[a],c=l-(this.inverted?o:0),d=l+(this.inverted?0:o),f=this.ranges[a+n],R=this.ranges[a+s];t(c,c+f,d,d+R),o+=R-f}}invert(){return new StepMap(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?StepMap.empty:new StepMap(t<0?[0,-t,0]:[0,0,t])}}StepMap.empty=new StepMap([]);class Mapping{constructor(t,n,s=0,a=t?t.length:0){this.mirror=n,this.from=s,this.to=a,this._maps=t||[],this.ownData=!(t||n)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new Mapping(this._maps,this.mirror,t,n)}appendMap(t,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(t),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(t){for(let n=0,s=this._maps.length;n<t._maps.length;n++){let a=t.getMirror(n);this.appendMap(t._maps[n],a!=null&&a<n?s+a:void 0)}}getMirror(t){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==t)return this.mirror[n+(n%2?-1:1)]}}setMirror(t,n){this.mirror||(this.mirror=[]),this.mirror.push(t,n)}appendMappingInverted(t){for(let n=t.maps.length-1,s=this._maps.length+t._maps.length;n>=0;n--){let a=t.getMirror(n);this.appendMap(t._maps[n].invert(),a!=null&&a>n?s-a-1:void 0)}}invert(){let t=new Mapping;return t.appendMappingInverted(this),t}map(t,n=1){if(this.mirror)return this._map(t,n,!0);for(let s=this.from;s<this.to;s++)t=this._maps[s].map(t,n);return t}mapResult(t,n=1){return this._map(t,n,!1)}_map(t,n,s){let a=0;for(let o=this.from;o<this.to;o++){let l=this._maps[o],c=l.mapResult(t,n);if(c.recover!=null){let d=this.getMirror(o);if(d!=null&&d>o&&d<this.to){o=d,t=this._maps[d].recover(c.recover);continue}}a|=c.delInfo,t=c.pos}return s?t:new MapResult(t,a,null)}}const stepsByID=Object.create(null);class Step{getMap(){return StepMap.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=stepsByID[n.stepType];if(!s)throw new RangeError(`No step type ${n.stepType} defined`);return s.fromJSON(t,n)}static jsonID(t,n){if(t in stepsByID)throw new RangeError("Duplicate use of step JSON ID "+t);return stepsByID[t]=n,n.prototype.jsonID=t,n}}class StepResult{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new StepResult(t,null)}static fail(t){return new StepResult(null,t)}static fromReplace(t,n,s,a){try{return StepResult.ok(t.replace(n,s,a))}catch(o){if(o instanceof ReplaceError)return StepResult.fail(o.message);throw o}}}function mapFragment(e,t,n){let s=[];for(let a=0;a<e.childCount;a++){let o=e.child(a);o.content.size&&(o=o.copy(mapFragment(o.content,t,o))),o.isInline&&(o=t(o,n,a)),s.push(o)}return Fragment.fromArray(s)}class AddMarkStep extends Step{constructor(t,n,s){super(),this.from=t,this.to=n,this.mark=s}apply(t){let n=t.slice(this.from,this.to),s=t.resolve(this.from),a=s.node(s.sharedDepth(this.to)),o=new Slice(mapFragment(n.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),n.openStart,n.openEnd);return StepResult.fromReplace(t,this.from,this.to,o)}invert(){return new RemoveMarkStep(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new AddMarkStep(n.pos,s.pos,this.mark)}merge(t){return t instanceof AddMarkStep&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new AddMarkStep(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new AddMarkStep(n.from,n.to,t.markFromJSON(n.mark))}}Step.jsonID("addMark",AddMarkStep);class RemoveMarkStep extends Step{constructor(t,n,s){super(),this.from=t,this.to=n,this.mark=s}apply(t){let n=t.slice(this.from,this.to),s=new Slice(mapFragment(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),t),n.openStart,n.openEnd);return StepResult.fromReplace(t,this.from,this.to,s)}invert(){return new AddMarkStep(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new RemoveMarkStep(n.pos,s.pos,this.mark)}merge(t){return t instanceof RemoveMarkStep&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new RemoveMarkStep(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new RemoveMarkStep(n.from,n.to,t.markFromJSON(n.mark))}}Step.jsonID("removeMark",RemoveMarkStep);class AddNodeMarkStep extends Step{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return StepResult.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return StepResult.fromReplace(t,this.pos,this.pos+1,new Slice(Fragment.from(s),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let a=0;a<n.marks.length;a++)if(!n.marks[a].isInSet(s))return new AddNodeMarkStep(this.pos,n.marks[a]);return new AddNodeMarkStep(this.pos,this.mark)}}return new RemoveNodeMarkStep(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new AddNodeMarkStep(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new AddNodeMarkStep(n.pos,t.markFromJSON(n.mark))}}Step.jsonID("addNodeMark",AddNodeMarkStep);class RemoveNodeMarkStep extends Step{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return StepResult.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return StepResult.fromReplace(t,this.pos,this.pos+1,new Slice(Fragment.from(s),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new AddNodeMarkStep(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new RemoveNodeMarkStep(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new RemoveNodeMarkStep(n.pos,t.markFromJSON(n.mark))}}Step.jsonID("removeNodeMark",RemoveNodeMarkStep);class ReplaceStep extends Step{constructor(t,n,s,a=!1){super(),this.from=t,this.to=n,this.slice=s,this.structure=a}apply(t){return this.structure&&contentBetween(t,this.from,this.to)?StepResult.fail("Structure replace would overwrite content"):StepResult.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new StepMap([this.from,this.to-this.from,this.slice.size])}invert(t){return new ReplaceStep(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deletedAcross&&s.deletedAcross?null:new ReplaceStep(n.pos,Math.max(n.pos,s.pos),this.slice,this.structure)}merge(t){if(!(t instanceof ReplaceStep)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Slice.empty:new Slice(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new ReplaceStep(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Slice.empty:new Slice(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new ReplaceStep(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ReplaceStep(n.from,n.to,Slice.fromJSON(t,n.slice),!!n.structure)}}Step.jsonID("replace",ReplaceStep);class ReplaceAroundStep extends Step{constructor(t,n,s,a,o,l,c=!1){super(),this.from=t,this.to=n,this.gapFrom=s,this.gapTo=a,this.slice=o,this.insert=l,this.structure=c}apply(t){if(this.structure&&(contentBetween(t,this.from,this.gapFrom)||contentBetween(t,this.gapTo,this.to)))return StepResult.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return StepResult.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,n.content);return s?StepResult.fromReplace(t,this.from,this.to,s):StepResult.fail("Content does not fit in gap")}getMap(){return new StepMap([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new ReplaceAroundStep(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1),a=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),o=this.to==this.gapTo?s.pos:t.map(this.gapTo,1);return n.deletedAcross&&s.deletedAcross||a<n.pos||o>s.pos?null:new ReplaceAroundStep(n.pos,s.pos,a,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ReplaceAroundStep(n.from,n.to,n.gapFrom,n.gapTo,Slice.fromJSON(t,n.slice),n.insert,!!n.structure)}}Step.jsonID("replaceAround",ReplaceAroundStep);function contentBetween(e,t,n){let s=e.resolve(t),a=n-t,o=s.depth;for(;a>0&&o>0&&s.indexAfter(o)==s.node(o).childCount;)o--,a--;if(a>0){let l=s.node(o).maybeChild(s.indexAfter(o));for(;a>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,a--}}return!1}function addMark(e,t,n,s){let a=[],o=[],l,c;e.doc.nodesBetween(t,n,(d,f,R)=>{if(!d.isInline)return;let S=d.marks;if(!s.isInSet(S)&&R.type.allowsMarkType(s.type)){let te=Math.max(f,t),A=Math.min(f+d.nodeSize,n),rt=s.addToSet(S);for(let st=0;st<S.length;st++)S[st].isInSet(rt)||(l&&l.to==te&&l.mark.eq(S[st])?l.to=A:a.push(l=new RemoveMarkStep(te,A,S[st])));c&&c.to==te?c.to=A:o.push(c=new AddMarkStep(te,A,s))}}),a.forEach(d=>e.step(d)),o.forEach(d=>e.step(d))}function removeMark(e,t,n,s){let a=[],o=0;e.doc.nodesBetween(t,n,(l,c)=>{if(!l.isInline)return;o++;let d=null;if(s instanceof MarkType){let f=l.marks,R;for(;R=s.isInSet(f);)(d||(d=[])).push(R),f=R.removeFromSet(f)}else s?s.isInSet(l.marks)&&(d=[s]):d=l.marks;if(d&&d.length){let f=Math.min(c+l.nodeSize,n);for(let R=0;R<d.length;R++){let S=d[R],te;for(let A=0;A<a.length;A++){let rt=a[A];rt.step==o-1&&S.eq(a[A].style)&&(te=rt)}te?(te.to=f,te.step=o):a.push({style:S,from:Math.max(c,t),to:f,step:o})}}}),a.forEach(l=>e.step(new RemoveMarkStep(l.from,l.to,l.style)))}function clearIncompatible(e,t,n,s=n.contentMatch,a=!0){let o=e.doc.nodeAt(t),l=[],c=t+1;for(let d=0;d<o.childCount;d++){let f=o.child(d),R=c+f.nodeSize,S=s.matchType(f.type);if(!S)l.push(new ReplaceStep(c,R,Slice.empty));else{s=S;for(let te=0;te<f.marks.length;te++)n.allowsMarkType(f.marks[te].type)||e.step(new RemoveMarkStep(c,R,f.marks[te]));if(a&&f.isText&&n.whitespace!="pre"){let te,A=/\r?\n|\r/g,rt;for(;te=A.exec(f.text);)rt||(rt=new Slice(Fragment.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),l.push(new ReplaceStep(c+te.index,c+te.index+te[0].length,rt))}}c=R}if(!s.validEnd){let d=s.fillBefore(Fragment.empty,!0);e.replace(c,c,new Slice(d,0,0))}for(let d=l.length-1;d>=0;d--)e.step(l[d])}function canCut(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function liftTarget(e){let n=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let s=e.depth,a=0,o=0;;--s){let l=e.$from.node(s),c=e.$from.index(s)+a,d=e.$to.indexAfter(s)-o;if(s<e.depth&&l.canReplace(c,d,n))return s;if(s==0||l.type.spec.isolating||!canCut(l,c,d))break;c&&(a=1),d<l.childCount&&(o=1)}return null}function lift$2(e,t,n){let{$from:s,$to:a,depth:o}=t,l=s.before(o+1),c=a.after(o+1),d=l,f=c,R=Fragment.empty,S=0;for(let rt=o,st=!1;rt>n;rt--)st||s.index(rt)>0?(st=!0,R=Fragment.from(s.node(rt).copy(R)),S++):d--;let te=Fragment.empty,A=0;for(let rt=o,st=!1;rt>n;rt--)st||a.after(rt+1)<a.end(rt)?(st=!0,te=Fragment.from(a.node(rt).copy(te)),A++):f++;e.step(new ReplaceAroundStep(d,f,l,c,new Slice(R.append(te),S,A),R.size-S,!0))}function findWrapping(e,t,n=null,s=e){let a=findWrappingOutside(e,t),o=a&&findWrappingInside(s,t);return o?a.map(withAttrs).concat({type:t,attrs:n}).concat(o.map(withAttrs)):null}function withAttrs(e){return{type:e,attrs:null}}function findWrappingOutside(e,t){let{parent:n,startIndex:s,endIndex:a}=e,o=n.contentMatchAt(s).findWrapping(t);if(!o)return null;let l=o.length?o[0]:t;return n.canReplaceWith(s,a,l)?o:null}function findWrappingInside(e,t){let{parent:n,startIndex:s,endIndex:a}=e,o=n.child(s),l=t.contentMatch.findWrapping(o.type);if(!l)return null;let d=(l.length?l[l.length-1]:t).contentMatch;for(let f=s;d&&f<a;f++)d=d.matchType(n.child(f).type);return!d||!d.validEnd?null:l}function wrap(e,t,n){let s=Fragment.empty;for(let l=n.length-1;l>=0;l--){if(s.size){let c=n[l].type.contentMatch.matchFragment(s);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=Fragment.from(n[l].type.create(n[l].attrs,s))}let a=t.start,o=t.end;e.step(new ReplaceAroundStep(a,o,a,o,new Slice(s,0,0),n.length,!0))}function setBlockType$1(e,t,n,s,a){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(l,c)=>{let d=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(s,d)&&canChangeType(e.doc,e.mapping.slice(o).map(c),s)){let f=null;if(s.schema.linebreakReplacement){let A=s.whitespace=="pre",rt=!!s.contentMatch.matchType(s.schema.linebreakReplacement);A&&!rt?f=!1:!A&&rt&&(f=!0)}f===!1&&replaceLinebreaks(e,l,c,o),clearIncompatible(e,e.mapping.slice(o).map(c,1),s,void 0,f===null);let R=e.mapping.slice(o),S=R.map(c,1),te=R.map(c+l.nodeSize,1);return e.step(new ReplaceAroundStep(S,te,S+1,te-1,new Slice(Fragment.from(s.create(d,null,l.marks)),0,0),1,!0)),f===!0&&replaceNewlines(e,l,c,o),!1}})}function replaceNewlines(e,t,n,s){t.forEach((a,o)=>{if(a.isText){let l,c=/\r?\n|\r/g;for(;l=c.exec(a.text);){let d=e.mapping.slice(s).map(n+1+o+l.index);e.replaceWith(d,d+1,t.type.schema.linebreakReplacement.create())}}})}function replaceLinebreaks(e,t,n,s){t.forEach((a,o)=>{if(a.type==a.type.schema.linebreakReplacement){let l=e.mapping.slice(s).map(n+1+o);e.replaceWith(l,l+1,t.type.schema.text(`
|