@j3m-quantum/ui 1.7.0 → 1.9.1

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/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React22 = require('react');
3
+ var React27 = require('react');
4
4
  var reactSlot = require('@radix-ui/react-slot');
5
5
  var classVarianceAuthority = require('class-variance-authority');
6
6
  var clsx = require('clsx');
@@ -40,6 +40,7 @@ var PopoverPrimitive = require('@radix-ui/react-popover');
40
40
  var HoverCardPrimitive = require('@radix-ui/react-hover-card');
41
41
  var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
42
42
  var ResizablePrimitive = require('react-resizable-panels');
43
+ var reactLeaflet = require('react-leaflet');
43
44
  var reactTable = require('@tanstack/react-table');
44
45
  var dateFns = require('date-fns');
45
46
 
@@ -63,7 +64,7 @@ function _interopNamespace(e) {
63
64
  return Object.freeze(n);
64
65
  }
65
66
 
66
- var React22__namespace = /*#__PURE__*/_interopNamespace(React22);
67
+ var React27__namespace = /*#__PURE__*/_interopNamespace(React27);
67
68
  var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
68
69
  var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
69
70
  var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
@@ -96,8 +97,8 @@ var ResizablePrimitive__namespace = /*#__PURE__*/_interopNamespace(ResizablePrim
96
97
  // src/hooks/use-mobile.ts
97
98
  var MOBILE_BREAKPOINT = 768;
98
99
  function useIsMobile() {
99
- const [isMobile, setIsMobile] = React22__namespace.useState(void 0);
100
- React22__namespace.useEffect(() => {
100
+ const [isMobile, setIsMobile] = React27__namespace.useState(void 0);
101
+ React27__namespace.useEffect(() => {
101
102
  const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
102
103
  const onChange = () => {
103
104
  setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
@@ -138,7 +139,7 @@ var buttonVariants = classVarianceAuthority.cva(
138
139
  }
139
140
  }
140
141
  );
141
- var Button = React22__namespace.forwardRef(
142
+ var Button = React27__namespace.forwardRef(
142
143
  ({ className, variant, size, asChild = false, ...props }, ref) => {
143
144
  const Comp = asChild ? reactSlot.Slot : "button";
144
145
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -502,7 +503,7 @@ function Slider({
502
503
  max = 100,
503
504
  ...props
504
505
  }) {
505
- const _values = React22__namespace.useMemo(
506
+ const _values = React27__namespace.useMemo(
506
507
  () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
507
508
  [value, defaultValue, min, max]
508
509
  );
@@ -788,7 +789,7 @@ function Toggle({
788
789
  }
789
790
  );
790
791
  }
791
- var ToggleGroupContext = React22__namespace.createContext({
792
+ var ToggleGroupContext = React27__namespace.createContext({
792
793
  size: "default",
793
794
  variant: "default",
794
795
  spacing: 0
@@ -825,7 +826,7 @@ function ToggleGroupItem({
825
826
  size,
826
827
  ...props
827
828
  }) {
828
- const context = React22__namespace.useContext(ToggleGroupContext);
829
+ const context = React27__namespace.useContext(ToggleGroupContext);
829
830
  return /* @__PURE__ */ jsxRuntime.jsx(
830
831
  ToggleGroupPrimitive__namespace.Item,
831
832
  {
@@ -855,7 +856,7 @@ function ThemeSwitch({
855
856
  className,
856
857
  size = "default"
857
858
  }) {
858
- const [isChecked, setIsChecked] = React22__namespace.useState(defaultChecked);
859
+ const [isChecked, setIsChecked] = React27__namespace.useState(defaultChecked);
859
860
  const isControlled = checked !== void 0;
860
861
  const currentChecked = isControlled ? checked : isChecked;
861
862
  const handleClick = () => {
@@ -1275,7 +1276,7 @@ function Label2({
1275
1276
  );
1276
1277
  }
1277
1278
  var Form = reactHookForm.FormProvider;
1278
- var FormFieldContext = React22__namespace.createContext(
1279
+ var FormFieldContext = React27__namespace.createContext(
1279
1280
  {}
1280
1281
  );
1281
1282
  var FormField = ({
@@ -1284,8 +1285,8 @@ var FormField = ({
1284
1285
  return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
1285
1286
  };
1286
1287
  var useFormField = () => {
1287
- const fieldContext = React22__namespace.useContext(FormFieldContext);
1288
- const itemContext = React22__namespace.useContext(FormItemContext);
1288
+ const fieldContext = React27__namespace.useContext(FormFieldContext);
1289
+ const itemContext = React27__namespace.useContext(FormItemContext);
1289
1290
  const { getFieldState } = reactHookForm.useFormContext();
1290
1291
  const formState = reactHookForm.useFormState({ name: fieldContext.name });
1291
1292
  const fieldState = getFieldState(fieldContext.name, formState);
@@ -1302,11 +1303,11 @@ var useFormField = () => {
1302
1303
  ...fieldState
1303
1304
  };
1304
1305
  };
1305
- var FormItemContext = React22__namespace.createContext(
1306
+ var FormItemContext = React27__namespace.createContext(
1306
1307
  {}
1307
1308
  );
1308
1309
  function FormItem({ className, ...props }) {
1309
- const id = React22__namespace.useId();
1310
+ const id = React27__namespace.useId();
1310
1311
  return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsxRuntime.jsx(
1311
1312
  "div",
1312
1313
  {
@@ -1554,7 +1555,7 @@ function FieldError({
1554
1555
  errors,
1555
1556
  ...props
1556
1557
  }) {
1557
- const content = React22.useMemo(() => {
1558
+ const content = React27.useMemo(() => {
1558
1559
  if (children) {
1559
1560
  return children;
1560
1561
  }
@@ -2408,8 +2409,8 @@ function CalendarDayButton({
2408
2409
  modifiers,
2409
2410
  ...props
2410
2411
  }) {
2411
- const ref = React22__namespace.useRef(null);
2412
- React22__namespace.useEffect(() => {
2412
+ const ref = React27__namespace.useRef(null);
2413
+ React27__namespace.useEffect(() => {
2413
2414
  if (modifiers.focused) ref.current?.focus();
2414
2415
  }, [modifiers.focused]);
2415
2416
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -2430,9 +2431,9 @@ function CalendarDayButton({
2430
2431
  }
2431
2432
  );
2432
2433
  }
2433
- var CarouselContext = React22__namespace.createContext(null);
2434
+ var CarouselContext = React27__namespace.createContext(null);
2434
2435
  function useCarousel() {
2435
- const context = React22__namespace.useContext(CarouselContext);
2436
+ const context = React27__namespace.useContext(CarouselContext);
2436
2437
  if (!context) {
2437
2438
  throw new Error("useCarousel must be used within a <Carousel />");
2438
2439
  }
@@ -2454,20 +2455,20 @@ function Carousel({
2454
2455
  },
2455
2456
  plugins
2456
2457
  );
2457
- const [canScrollPrev, setCanScrollPrev] = React22__namespace.useState(false);
2458
- const [canScrollNext, setCanScrollNext] = React22__namespace.useState(false);
2459
- const onSelect = React22__namespace.useCallback((api2) => {
2458
+ const [canScrollPrev, setCanScrollPrev] = React27__namespace.useState(false);
2459
+ const [canScrollNext, setCanScrollNext] = React27__namespace.useState(false);
2460
+ const onSelect = React27__namespace.useCallback((api2) => {
2460
2461
  if (!api2) return;
2461
2462
  setCanScrollPrev(api2.canScrollPrev());
2462
2463
  setCanScrollNext(api2.canScrollNext());
2463
2464
  }, []);
2464
- const scrollPrev = React22__namespace.useCallback(() => {
2465
+ const scrollPrev = React27__namespace.useCallback(() => {
2465
2466
  api?.scrollPrev();
2466
2467
  }, [api]);
2467
- const scrollNext = React22__namespace.useCallback(() => {
2468
+ const scrollNext = React27__namespace.useCallback(() => {
2468
2469
  api?.scrollNext();
2469
2470
  }, [api]);
2470
- const handleKeyDown = React22__namespace.useCallback(
2471
+ const handleKeyDown = React27__namespace.useCallback(
2471
2472
  (event) => {
2472
2473
  if (event.key === "ArrowLeft") {
2473
2474
  event.preventDefault();
@@ -2479,11 +2480,11 @@ function Carousel({
2479
2480
  },
2480
2481
  [scrollPrev, scrollNext]
2481
2482
  );
2482
- React22__namespace.useEffect(() => {
2483
+ React27__namespace.useEffect(() => {
2483
2484
  if (!api || !setApi) return;
2484
2485
  setApi(api);
2485
2486
  }, [api, setApi]);
2486
- React22__namespace.useEffect(() => {
2487
+ React27__namespace.useEffect(() => {
2487
2488
  if (!api) return;
2488
2489
  onSelect(api);
2489
2490
  api.on("reInit", onSelect);
@@ -2616,9 +2617,9 @@ function CarouselNext({
2616
2617
  );
2617
2618
  }
2618
2619
  var THEMES = { light: "", dark: ".dark" };
2619
- var ChartContext = React22__namespace.createContext(null);
2620
+ var ChartContext = React27__namespace.createContext(null);
2620
2621
  function useChart() {
2621
- const context = React22__namespace.useContext(ChartContext);
2622
+ const context = React27__namespace.useContext(ChartContext);
2622
2623
  if (!context) {
2623
2624
  throw new Error("useChart must be used within a <ChartContainer />");
2624
2625
  }
@@ -2631,7 +2632,7 @@ function ChartContainer({
2631
2632
  config,
2632
2633
  ...props
2633
2634
  }) {
2634
- const uniqueId = React22__namespace.useId();
2635
+ const uniqueId = React27__namespace.useId();
2635
2636
  const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
2636
2637
  return /* @__PURE__ */ jsxRuntime.jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxRuntime.jsxs(
2637
2638
  "div",
@@ -2692,7 +2693,7 @@ function ChartTooltipContent({
2692
2693
  labelKey
2693
2694
  }) {
2694
2695
  const { config } = useChart();
2695
- const tooltipLabel = React22__namespace.useMemo(() => {
2696
+ const tooltipLabel = React27__namespace.useMemo(() => {
2696
2697
  if (hideLabel || !payload?.length) {
2697
2698
  return null;
2698
2699
  }
@@ -3494,8 +3495,8 @@ function TooltipContent({
3494
3495
  ) });
3495
3496
  }
3496
3497
  function useDetectTheme() {
3497
- const [theme, setTheme] = React22__namespace.useState("light");
3498
- React22__namespace.useEffect(() => {
3498
+ const [theme, setTheme] = React27__namespace.useState("light");
3499
+ React27__namespace.useEffect(() => {
3499
3500
  const isDark = document.documentElement.classList.contains("dark");
3500
3501
  setTheme(isDark ? "dark" : "light");
3501
3502
  const observer = new MutationObserver((mutations) => {
@@ -4144,7 +4145,7 @@ function CommandShortcut({
4144
4145
  }
4145
4146
  );
4146
4147
  }
4147
- var SearchTrigger = React22__namespace.forwardRef(
4148
+ var SearchTrigger = React27__namespace.forwardRef(
4148
4149
  ({
4149
4150
  className,
4150
4151
  placeholder = "Search...",
@@ -4180,7 +4181,7 @@ var SearchTrigger = React22__namespace.forwardRef(
4180
4181
  );
4181
4182
  SearchTrigger.displayName = "SearchTrigger";
4182
4183
  function useSearchShortcut(onOpen, key = "k") {
4183
- React22__namespace.useEffect(() => {
4184
+ React27__namespace.useEffect(() => {
4184
4185
  const down = (e) => {
4185
4186
  if (e.key.toLowerCase() === key.toLowerCase() && (e.metaKey || e.ctrlKey)) {
4186
4187
  e.preventDefault();
@@ -5155,9 +5156,9 @@ var SIDEBAR_WIDTH = "16rem";
5155
5156
  var SIDEBAR_WIDTH_MOBILE = "18rem";
5156
5157
  var SIDEBAR_WIDTH_ICON = "3rem";
5157
5158
  var SIDEBAR_KEYBOARD_SHORTCUT = "b";
5158
- var SidebarContext = React22__namespace.createContext(null);
5159
+ var SidebarContext = React27__namespace.createContext(null);
5159
5160
  function useSidebar() {
5160
- const context = React22__namespace.useContext(SidebarContext);
5161
+ const context = React27__namespace.useContext(SidebarContext);
5161
5162
  if (!context) {
5162
5163
  throw new Error("useSidebar must be used within a SidebarProvider.");
5163
5164
  }
@@ -5173,10 +5174,10 @@ function SidebarProvider({
5173
5174
  ...props
5174
5175
  }) {
5175
5176
  const isMobile = useIsMobile();
5176
- const [openMobile, setOpenMobile] = React22__namespace.useState(false);
5177
- const [_open, _setOpen] = React22__namespace.useState(defaultOpen);
5177
+ const [openMobile, setOpenMobile] = React27__namespace.useState(false);
5178
+ const [_open, _setOpen] = React27__namespace.useState(defaultOpen);
5178
5179
  const open = openProp ?? _open;
5179
- const setOpen = React22__namespace.useCallback(
5180
+ const setOpen = React27__namespace.useCallback(
5180
5181
  (value) => {
5181
5182
  const openState = typeof value === "function" ? value(open) : value;
5182
5183
  if (setOpenProp) {
@@ -5188,10 +5189,10 @@ function SidebarProvider({
5188
5189
  },
5189
5190
  [setOpenProp, open]
5190
5191
  );
5191
- const toggleSidebar = React22__namespace.useCallback(() => {
5192
+ const toggleSidebar = React27__namespace.useCallback(() => {
5192
5193
  return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
5193
5194
  }, [isMobile, setOpen, setOpenMobile]);
5194
- React22__namespace.useEffect(() => {
5195
+ React27__namespace.useEffect(() => {
5195
5196
  const handleKeyDown = (event) => {
5196
5197
  if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
5197
5198
  event.preventDefault();
@@ -5202,7 +5203,7 @@ function SidebarProvider({
5202
5203
  return () => window.removeEventListener("keydown", handleKeyDown);
5203
5204
  }, [toggleSidebar]);
5204
5205
  const state = open ? "expanded" : "collapsed";
5205
- const contextValue = React22__namespace.useMemo(
5206
+ const contextValue = React27__namespace.useMemo(
5206
5207
  () => ({
5207
5208
  state,
5208
5209
  open,
@@ -5660,7 +5661,7 @@ function SidebarMenuSkeleton({
5660
5661
  showIcon = false,
5661
5662
  ...props
5662
5663
  }) {
5663
- const width = React22__namespace.useMemo(() => {
5664
+ const width = React27__namespace.useMemo(() => {
5664
5665
  return `${Math.floor(Math.random() * 40) + 50}%`;
5665
5666
  }, []);
5666
5667
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -5803,7 +5804,7 @@ var sectionVariants = classVarianceAuthority.cva(
5803
5804
  }
5804
5805
  );
5805
5806
  var isGlassVariant = (variant) => variant?.startsWith("glass-") ?? false;
5806
- var Section = React22__namespace.forwardRef(
5807
+ var Section = React27__namespace.forwardRef(
5807
5808
  ({ className, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
5808
5809
  "section",
5809
5810
  {
@@ -5815,7 +5816,7 @@ var Section = React22__namespace.forwardRef(
5815
5816
  )
5816
5817
  );
5817
5818
  Section.displayName = "Section";
5818
- var SectionHeader = React22__namespace.forwardRef(
5819
+ var SectionHeader = React27__namespace.forwardRef(
5819
5820
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
5820
5821
  "div",
5821
5822
  {
@@ -5830,7 +5831,7 @@ var SectionHeader = React22__namespace.forwardRef(
5830
5831
  )
5831
5832
  );
5832
5833
  SectionHeader.displayName = "SectionHeader";
5833
- var SectionTitle = React22__namespace.forwardRef(
5834
+ var SectionTitle = React27__namespace.forwardRef(
5834
5835
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
5835
5836
  "h2",
5836
5837
  {
@@ -5844,7 +5845,7 @@ var SectionTitle = React22__namespace.forwardRef(
5844
5845
  )
5845
5846
  );
5846
5847
  SectionTitle.displayName = "SectionTitle";
5847
- var SectionDescription = React22__namespace.forwardRef(
5848
+ var SectionDescription = React27__namespace.forwardRef(
5848
5849
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
5849
5850
  "p",
5850
5851
  {
@@ -5858,7 +5859,7 @@ var SectionDescription = React22__namespace.forwardRef(
5858
5859
  )
5859
5860
  );
5860
5861
  SectionDescription.displayName = "SectionDescription";
5861
- var SectionContent = React22__namespace.forwardRef(
5862
+ var SectionContent = React27__namespace.forwardRef(
5862
5863
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
5863
5864
  "div",
5864
5865
  {
@@ -5872,7 +5873,7 @@ var SectionContent = React22__namespace.forwardRef(
5872
5873
  )
5873
5874
  );
5874
5875
  SectionContent.displayName = "SectionContent";
5875
- var SectionFooter = React22__namespace.forwardRef(
5876
+ var SectionFooter = React27__namespace.forwardRef(
5876
5877
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
5877
5878
  "div",
5878
5879
  {
@@ -5888,6 +5889,89 @@ var SectionFooter = React22__namespace.forwardRef(
5888
5889
  )
5889
5890
  );
5890
5891
  SectionFooter.displayName = "SectionFooter";
5892
+ function Map2({
5893
+ center,
5894
+ zoom = 13,
5895
+ className,
5896
+ children,
5897
+ ...props
5898
+ }) {
5899
+ return /* @__PURE__ */ jsxRuntime.jsx(
5900
+ reactLeaflet.MapContainer,
5901
+ {
5902
+ center,
5903
+ zoom,
5904
+ className: cn(
5905
+ "w-full rounded-lg border border-border overflow-hidden",
5906
+ "[&_.leaflet-control-zoom]:border-border",
5907
+ "[&_.leaflet-control-zoom]:rounded-md",
5908
+ "[&_.leaflet-control-zoom]:shadow-sm",
5909
+ "[&_.leaflet-control-zoom-in]:rounded-t-md",
5910
+ "[&_.leaflet-control-zoom-in]:border-b",
5911
+ "[&_.leaflet-control-zoom-in]:border-border",
5912
+ "[&_.leaflet-control-zoom-out]:rounded-b-md",
5913
+ "[&_.leaflet-popup-content-wrapper]:rounded-lg",
5914
+ "[&_.leaflet-popup-content-wrapper]:shadow-lg",
5915
+ "[&_.leaflet-popup-content-wrapper]:border",
5916
+ "[&_.leaflet-popup-content-wrapper]:border-border",
5917
+ className
5918
+ ),
5919
+ scrollWheelZoom: true,
5920
+ ...props,
5921
+ children
5922
+ }
5923
+ );
5924
+ }
5925
+ var TILE_LAYERS = {
5926
+ default: {
5927
+ url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
5928
+ attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
5929
+ },
5930
+ dark: {
5931
+ url: "https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",
5932
+ attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>'
5933
+ },
5934
+ satellite: {
5935
+ url: "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
5936
+ attribution: "&copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community"
5937
+ }
5938
+ };
5939
+ function MapTileLayer({
5940
+ variant = "default",
5941
+ ...props
5942
+ }) {
5943
+ const layer = TILE_LAYERS[variant];
5944
+ return /* @__PURE__ */ jsxRuntime.jsx(
5945
+ reactLeaflet.TileLayer,
5946
+ {
5947
+ url: layer.url,
5948
+ attribution: layer.attribution,
5949
+ ...props
5950
+ }
5951
+ );
5952
+ }
5953
+ function MapMarker({
5954
+ position,
5955
+ children,
5956
+ ...props
5957
+ }) {
5958
+ return /* @__PURE__ */ jsxRuntime.jsx(reactLeaflet.Marker, { position, ...props, children });
5959
+ }
5960
+ function MapPopup({
5961
+ children,
5962
+ ...props
5963
+ }) {
5964
+ return /* @__PURE__ */ jsxRuntime.jsx(reactLeaflet.Popup, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm", children }) });
5965
+ }
5966
+ function MapTooltip({
5967
+ children,
5968
+ ...props
5969
+ }) {
5970
+ return /* @__PURE__ */ jsxRuntime.jsx(reactLeaflet.Tooltip, { ...props, children });
5971
+ }
5972
+ function MapZoomControl(props) {
5973
+ return /* @__PURE__ */ jsxRuntime.jsx(reactLeaflet.ZoomControl, { ...props });
5974
+ }
5891
5975
  function DataTableColumnHeader({
5892
5976
  column,
5893
5977
  title,
@@ -6097,7 +6181,7 @@ function SiteHeader({
6097
6181
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-[var(--header-height,3.5rem)] w-full items-center gap-[var(--j3m-spacing-s)] px-[var(--j3m-spacing-m)]", children: [
6098
6182
  trigger,
6099
6183
  trigger && /* @__PURE__ */ jsxRuntime.jsx(Separator, { orientation: "vertical", className: "mr-[var(--j3m-spacing-s)] h-4" }),
6100
- /* @__PURE__ */ jsxRuntime.jsx(Breadcrumb, { className: "hidden sm:block", children: /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbList, { children: breadcrumbs.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(React22__namespace.Fragment, { children: [
6184
+ /* @__PURE__ */ jsxRuntime.jsx(Breadcrumb, { className: "hidden sm:block", children: /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbList, { children: breadcrumbs.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(React27__namespace.Fragment, { children: [
6101
6185
  index > 0 && /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbSeparator, {}),
6102
6186
  /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbItem, { children: item.href ? /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbLink, { href: item.href, children: item.label }) : /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbPage, { children: item.label }) })
6103
6187
  ] }, index)) }) }),
@@ -6704,11 +6788,11 @@ function PlanningWeekCommentPopover({
6704
6788
  open,
6705
6789
  onOpenChange
6706
6790
  }) {
6707
- const [newCommentText, setNewCommentText] = React22__namespace.useState("");
6708
- const [selectedLocationId, setSelectedLocationId] = React22__namespace.useState("");
6709
- const [viewCommentsOpen, setViewCommentsOpen] = React22__namespace.useState(true);
6710
- const [showAddForm, setShowAddForm] = React22__namespace.useState(false);
6711
- const selectedLocation = React22__namespace.useMemo(() => {
6791
+ const [newCommentText, setNewCommentText] = React27__namespace.useState("");
6792
+ const [selectedLocationId, setSelectedLocationId] = React27__namespace.useState("");
6793
+ const [viewCommentsOpen, setViewCommentsOpen] = React27__namespace.useState(true);
6794
+ const [showAddForm, setShowAddForm] = React27__namespace.useState(false);
6795
+ const selectedLocation = React27__namespace.useMemo(() => {
6712
6796
  return locationOptions.find((opt) => opt.id === selectedLocationId);
6713
6797
  }, [locationOptions, selectedLocationId]);
6714
6798
  const handleSubmit = () => {
@@ -6752,8 +6836,8 @@ function PlanningWeekCommentPopover({
6752
6836
  minute: "2-digit"
6753
6837
  }).format(date);
6754
6838
  };
6755
- const prevOpenRef = React22__namespace.useRef(open);
6756
- React22__namespace.useEffect(() => {
6839
+ const prevOpenRef = React27__namespace.useRef(open);
6840
+ React27__namespace.useEffect(() => {
6757
6841
  const wasOpen = prevOpenRef.current;
6758
6842
  prevOpenRef.current = open;
6759
6843
  if (wasOpen && !open) {
@@ -6776,7 +6860,7 @@ function PlanningWeekCommentPopover({
6776
6860
  /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-sm font-semibold", children: "Comments" }),
6777
6861
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: weekLabel })
6778
6862
  ] }),
6779
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2 max-h-[400px] overflow-y-auto", children: [
6863
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2 h-fit overflow-y-auto", children: [
6780
6864
  /* @__PURE__ */ jsxRuntime.jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
6781
6865
  /* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-between h-8 px-2", children: [
6782
6866
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium", children: [
@@ -7107,22 +7191,22 @@ function PlanningTable({
7107
7191
  stickySupplierColumn = true,
7108
7192
  maxHeight = "600px"
7109
7193
  } = config;
7110
- const weeks = React22__namespace.useMemo(
7194
+ const weeks = React27__namespace.useMemo(
7111
7195
  () => generateWeeks(startDate, weekCount),
7112
7196
  [startDate, weekCount]
7113
7197
  );
7114
- const currentWeekKey = React22__namespace.useMemo(() => {
7198
+ const currentWeekKey = React27__namespace.useMemo(() => {
7115
7199
  const currentWeek = weeks.find((w) => w.isCurrentWeek);
7116
7200
  return currentWeek ? getWeekKey(currentWeek.startDate) : null;
7117
7201
  }, [weeks]);
7118
- const columns = React22__namespace.useMemo(
7202
+ const columns = React27__namespace.useMemo(
7119
7203
  () => generateColumns(weeks, config, suppliers),
7120
7204
  [weeks, config, suppliers]
7121
7205
  );
7122
- const [sorting, setSorting] = React22__namespace.useState([]);
7123
- const [columnFilters, setColumnFilters] = React22__namespace.useState([]);
7124
- const [columnVisibility, setColumnVisibility] = React22__namespace.useState({});
7125
- const [rowSelection, setRowSelection] = React22__namespace.useState({});
7206
+ const [sorting, setSorting] = React27__namespace.useState([]);
7207
+ const [columnFilters, setColumnFilters] = React27__namespace.useState([]);
7208
+ const [columnVisibility, setColumnVisibility] = React27__namespace.useState({});
7209
+ const [rowSelection, setRowSelection] = React27__namespace.useState({});
7126
7210
  const table = reactTable.useReactTable({
7127
7211
  data: suppliers,
7128
7212
  columns,
@@ -7329,10 +7413,10 @@ function DeliveryCommentPopover({
7329
7413
  onAddComment,
7330
7414
  deliveryLabel
7331
7415
  }) {
7332
- const [open, setOpen] = React22__namespace.useState(false);
7333
- const [newCommentText, setNewCommentText] = React22__namespace.useState("");
7334
- const [viewCommentsOpen, setViewCommentsOpen] = React22__namespace.useState(true);
7335
- const [showAddForm, setShowAddForm] = React22__namespace.useState(false);
7416
+ const [open, setOpen] = React27__namespace.useState(false);
7417
+ const [newCommentText, setNewCommentText] = React27__namespace.useState("");
7418
+ const [viewCommentsOpen, setViewCommentsOpen] = React27__namespace.useState(true);
7419
+ const [showAddForm, setShowAddForm] = React27__namespace.useState(false);
7336
7420
  const handleSubmit = () => {
7337
7421
  if (newCommentText.trim() && onAddComment) {
7338
7422
  onAddComment(newCommentText.trim());
@@ -7359,8 +7443,8 @@ function DeliveryCommentPopover({
7359
7443
  minute: "2-digit"
7360
7444
  }).format(date);
7361
7445
  };
7362
- const prevOpenRef = React22__namespace.useRef(open);
7363
- React22__namespace.useEffect(() => {
7446
+ const prevOpenRef = React27__namespace.useRef(open);
7447
+ React27__namespace.useEffect(() => {
7364
7448
  const wasOpen = prevOpenRef.current;
7365
7449
  prevOpenRef.current = open;
7366
7450
  if (wasOpen && !open) {
@@ -7382,7 +7466,7 @@ function DeliveryCommentPopover({
7382
7466
  /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-sm font-semibold", children: "Comments" }),
7383
7467
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: deliveryLabel })
7384
7468
  ] }),
7385
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2 max-h-[400px] overflow-y-auto", children: [
7469
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2 h-fit overflow-y-auto", children: [
7386
7470
  /* @__PURE__ */ jsxRuntime.jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
7387
7471
  /* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-between h-8 px-2", children: [
7388
7472
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium", children: [
@@ -7472,8 +7556,8 @@ function ProductionCommentSection({
7472
7556
  comments = [],
7473
7557
  onAddComment
7474
7558
  }) {
7475
- const [showAddForm, setShowAddForm] = React22__namespace.useState(false);
7476
- const [newComment, setNewComment] = React22__namespace.useState("");
7559
+ const [showAddForm, setShowAddForm] = React27__namespace.useState(false);
7560
+ const [newComment, setNewComment] = React27__namespace.useState("");
7477
7561
  const handleSubmit = () => {
7478
7562
  if (newComment.trim() && onAddComment) {
7479
7563
  onAddComment(newComment.trim());
@@ -7629,7 +7713,7 @@ function DeliveryDetailsView({
7629
7713
  onAddComment
7630
7714
  }) {
7631
7715
  const elements = delivery.elements ?? [];
7632
- const categorizedElements = React22__namespace.useMemo(() => {
7716
+ const categorizedElements = React27__namespace.useMemo(() => {
7633
7717
  const sent = [];
7634
7718
  const notSent = [];
7635
7719
  const moved = [];
@@ -7997,15 +8081,15 @@ function WeekDetailDialog({
7997
8081
  }) {
7998
8082
  const production = data?.production;
7999
8083
  const initialProduced = production?.produced ?? 0;
8000
- const [producedValue, setProducedValue] = React22__namespace.useState(initialProduced.toString());
8001
- const [hasChanges, setHasChanges] = React22__namespace.useState(false);
8002
- const [selectedDelivery, setSelectedDelivery] = React22__namespace.useState(null);
8003
- React22__namespace.useEffect(() => {
8084
+ const [producedValue, setProducedValue] = React27__namespace.useState(initialProduced.toString());
8085
+ const [hasChanges, setHasChanges] = React27__namespace.useState(false);
8086
+ const [selectedDelivery, setSelectedDelivery] = React27__namespace.useState(null);
8087
+ React27__namespace.useEffect(() => {
8004
8088
  const newProduced = data?.production?.produced ?? 0;
8005
8089
  setProducedValue(newProduced.toString());
8006
8090
  setHasChanges(false);
8007
8091
  }, [data]);
8008
- React22__namespace.useEffect(() => {
8092
+ React27__namespace.useEffect(() => {
8009
8093
  if (!open) {
8010
8094
  setSelectedDelivery(null);
8011
8095
  }
@@ -8227,13 +8311,13 @@ function CalibrationWeekCell({
8227
8311
  onAddClick,
8228
8312
  ...props
8229
8313
  }) {
8230
- const inputRef = React22__namespace.useRef(null);
8231
- const [localValue, setLocalValue] = React22__namespace.useState(
8314
+ const inputRef = React27__namespace.useRef(null);
8315
+ const [localValue, setLocalValue] = React27__namespace.useState(
8232
8316
  data.entered !== null ? String(data.entered) : ""
8233
8317
  );
8234
- const [isHovered, setIsHovered] = React22__namespace.useState(false);
8235
- const [isEditing, setIsEditing] = React22__namespace.useState(false);
8236
- React22__namespace.useEffect(() => {
8318
+ const [isHovered, setIsHovered] = React27__namespace.useState(false);
8319
+ const [isEditing, setIsEditing] = React27__namespace.useState(false);
8320
+ React27__namespace.useEffect(() => {
8237
8321
  setLocalValue(data.entered !== null ? String(data.entered) : "");
8238
8322
  }, [data.entered]);
8239
8323
  const unitLabel = formatCalibrationUnit(unit);
@@ -8419,11 +8503,11 @@ function CommentPopover({
8419
8503
  open,
8420
8504
  onOpenChange
8421
8505
  }) {
8422
- const [newCommentText, setNewCommentText] = React22__namespace.useState("");
8423
- const [selectedPrefixId, setSelectedPrefixId] = React22__namespace.useState("");
8424
- const [viewCommentsOpen, setViewCommentsOpen] = React22__namespace.useState(true);
8425
- const [showAddForm, setShowAddForm] = React22__namespace.useState(false);
8426
- const selectedPrefixName = React22__namespace.useMemo(() => {
8506
+ const [newCommentText, setNewCommentText] = React27__namespace.useState("");
8507
+ const [selectedPrefixId, setSelectedPrefixId] = React27__namespace.useState("");
8508
+ const [viewCommentsOpen, setViewCommentsOpen] = React27__namespace.useState(true);
8509
+ const [showAddForm, setShowAddForm] = React27__namespace.useState(false);
8510
+ const selectedPrefixName = React27__namespace.useMemo(() => {
8427
8511
  const prefix = availablePrefixes.find((p) => p.id === selectedPrefixId);
8428
8512
  return prefix?.name ?? "";
8429
8513
  }, [availablePrefixes, selectedPrefixId]);
@@ -8455,8 +8539,8 @@ function CommentPopover({
8455
8539
  minute: "2-digit"
8456
8540
  }).format(date);
8457
8541
  };
8458
- const prevOpenRef = React22__namespace.useRef(open);
8459
- React22__namespace.useEffect(() => {
8542
+ const prevOpenRef = React27__namespace.useRef(open);
8543
+ React27__namespace.useEffect(() => {
8460
8544
  const wasOpen = prevOpenRef.current;
8461
8545
  prevOpenRef.current = open;
8462
8546
  if (wasOpen && !open) {
@@ -8479,7 +8563,7 @@ function CommentPopover({
8479
8563
  /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-sm font-semibold", children: "Comments" }),
8480
8564
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: weekLabel })
8481
8565
  ] }),
8482
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2 max-h-[400px] overflow-y-auto", children: [
8566
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2 h-fit overflow-y-auto", children: [
8483
8567
  /* @__PURE__ */ jsxRuntime.jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
8484
8568
  /* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
8485
8569
  Button,
@@ -8685,7 +8769,7 @@ function CalibrationTable({
8685
8769
  onAddComment,
8686
8770
  onAddEarlierWeek
8687
8771
  } = config;
8688
- const calculatedStartDate = React22__namespace.useMemo(() => {
8772
+ const calculatedStartDate = React27__namespace.useMemo(() => {
8689
8773
  if (startDate) return startDate;
8690
8774
  let earliest = null;
8691
8775
  for (const prefix of prefixes) {
@@ -8706,31 +8790,31 @@ function CalibrationTable({
8706
8790
  }
8707
8791
  return earliest ?? /* @__PURE__ */ new Date();
8708
8792
  }, [startDate, prefixes]);
8709
- const [additionalWeeks, setAdditionalWeeks] = React22__namespace.useState(0);
8710
- const weeks = React22__namespace.useMemo(() => {
8793
+ const [additionalWeeks, setAdditionalWeeks] = React27__namespace.useState(0);
8794
+ const weeks = React27__namespace.useMemo(() => {
8711
8795
  const start = new Date(calculatedStartDate);
8712
8796
  start.setDate(start.getDate() - additionalWeeks * 7);
8713
8797
  return generateWeeks(start, weekCount + additionalWeeks);
8714
8798
  }, [calculatedStartDate, weekCount, additionalWeeks]);
8715
- React22__namespace.useMemo(() => {
8799
+ React27__namespace.useMemo(() => {
8716
8800
  const currentWeek = weeks.find((w) => w.isCurrentWeek);
8717
8801
  return currentWeek ? getWeekKey(currentWeek.startDate) : null;
8718
8802
  }, [weeks]);
8719
- const [currentPage, setCurrentPage] = React22__namespace.useState(0);
8720
- const [pageSize, setPageSize] = React22__namespace.useState(defaultPageSize);
8721
- const [searchQuery, setSearchQuery] = React22__namespace.useState("");
8722
- const filteredPrefixes = React22__namespace.useMemo(() => {
8803
+ const [currentPage, setCurrentPage] = React27__namespace.useState(0);
8804
+ const [pageSize, setPageSize] = React27__namespace.useState(defaultPageSize);
8805
+ const [searchQuery, setSearchQuery] = React27__namespace.useState("");
8806
+ const filteredPrefixes = React27__namespace.useMemo(() => {
8723
8807
  if (!searchQuery) return prefixes;
8724
8808
  const query = searchQuery.toLowerCase();
8725
8809
  return prefixes.filter(
8726
8810
  (p) => p.name.toLowerCase().includes(query) || p.typeCode.toLowerCase().includes(query)
8727
8811
  );
8728
8812
  }, [prefixes, searchQuery]);
8729
- const paginatedPrefixes = React22__namespace.useMemo(() => {
8813
+ const paginatedPrefixes = React27__namespace.useMemo(() => {
8730
8814
  const start = currentPage * pageSize;
8731
8815
  return filteredPrefixes.slice(start, start + pageSize);
8732
8816
  }, [filteredPrefixes, currentPage, pageSize]);
8733
- React22__namespace.useMemo(
8817
+ React27__namespace.useMemo(
8734
8818
  () => canSubmitCalibration(prefixes),
8735
8819
  [prefixes]
8736
8820
  );
@@ -8754,7 +8838,7 @@ function CalibrationTable({
8754
8838
  }
8755
8839
  return allComments;
8756
8840
  };
8757
- const availablePrefixes = React22__namespace.useMemo(
8841
+ const availablePrefixes = React27__namespace.useMemo(
8758
8842
  () => prefixes.map((p) => ({ id: p.id, name: p.name })),
8759
8843
  [prefixes]
8760
8844
  );
@@ -8991,14 +9075,14 @@ function CommentDialog({
8991
9075
  open,
8992
9076
  onOpenChange
8993
9077
  }) {
8994
- const [selectedPrefixId, setSelectedPrefixId] = React22__namespace.useState("");
8995
- const [selectedWeekKey, setSelectedWeekKey] = React22__namespace.useState("");
8996
- const [commentText, setCommentText] = React22__namespace.useState("");
8997
- const currentWeek = React22__namespace.useMemo(
9078
+ const [selectedPrefixId, setSelectedPrefixId] = React27__namespace.useState("");
9079
+ const [selectedWeekKey, setSelectedWeekKey] = React27__namespace.useState("");
9080
+ const [commentText, setCommentText] = React27__namespace.useState("");
9081
+ const currentWeek = React27__namespace.useMemo(
8998
9082
  () => weeks.find((w) => w.isCurrentWeek),
8999
9083
  [weeks]
9000
9084
  );
9001
- React22__namespace.useEffect(() => {
9085
+ React27__namespace.useEffect(() => {
9002
9086
  if (open) {
9003
9087
  setSelectedPrefixId(prefixes[0]?.id ?? "");
9004
9088
  setSelectedWeekKey(currentWeek ? getWeekKey(currentWeek.startDate) : weeks[0] ? getWeekKey(weeks[0].startDate) : "");
@@ -9169,6 +9253,1315 @@ function SubmitCalibrationBar({
9169
9253
  );
9170
9254
  }
9171
9255
 
9256
+ // src/blocks/supplier-weekly-loading/types.ts
9257
+ function getLoadingElementStatusLabel(status) {
9258
+ switch (status) {
9259
+ case "loaded":
9260
+ return "Loaded";
9261
+ case "missing":
9262
+ return "Missing";
9263
+ case "moved":
9264
+ return "Moved to another delivery";
9265
+ case "addon":
9266
+ return "Add-on";
9267
+ default:
9268
+ return status;
9269
+ }
9270
+ }
9271
+ function getLoadingDeliveryStatusLabel(status) {
9272
+ switch (status) {
9273
+ case "planned":
9274
+ return "Planned";
9275
+ case "in_progress":
9276
+ return "In Progress";
9277
+ case "loaded":
9278
+ return "Loaded";
9279
+ case "shipped":
9280
+ return "Shipped";
9281
+ case "delivered":
9282
+ return "Delivered";
9283
+ case "cancelled":
9284
+ return "Cancelled";
9285
+ default:
9286
+ return status;
9287
+ }
9288
+ }
9289
+ function getDeliveryVisualState(delivery) {
9290
+ if (delivery.status === "shipped" || delivery.status === "delivered") {
9291
+ return "sent";
9292
+ }
9293
+ if (delivery.isReadyToUnload) {
9294
+ return "ready";
9295
+ }
9296
+ return "normal";
9297
+ }
9298
+ function getLoadingISOWeek(date) {
9299
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
9300
+ const dayNum = d.getUTCDay() || 7;
9301
+ d.setUTCDate(d.getUTCDate() + 4 - dayNum);
9302
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
9303
+ return Math.ceil(((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7);
9304
+ }
9305
+ function getLoadingWeekKey(date) {
9306
+ const year = date.getFullYear();
9307
+ const weekNumber = getLoadingISOWeek(date);
9308
+ return `${year}-W${weekNumber.toString().padStart(2, "0")}`;
9309
+ }
9310
+ function generateLoadingWeek(date) {
9311
+ const monday = new Date(date);
9312
+ const day = monday.getDay();
9313
+ const diff = monday.getDate() - day + (day === 0 ? -6 : 1);
9314
+ monday.setDate(diff);
9315
+ monday.setHours(0, 0, 0, 0);
9316
+ const friday = new Date(monday);
9317
+ friday.setDate(monday.getDate() + 4);
9318
+ const today = /* @__PURE__ */ new Date();
9319
+ today.setHours(0, 0, 0, 0);
9320
+ const isCurrentWeek = monday <= today && today <= friday;
9321
+ const formatDate2 = (d) => {
9322
+ return d.toLocaleDateString("en-US", { month: "short", day: "numeric" });
9323
+ };
9324
+ return {
9325
+ weekKey: getLoadingWeekKey(monday),
9326
+ label: `W${getLoadingISOWeek(monday).toString().padStart(2, "0")}`,
9327
+ startDate: monday,
9328
+ endDate: friday,
9329
+ dateRange: `${formatDate2(monday)} - ${formatDate2(friday)}`,
9330
+ isCurrentWeek
9331
+ };
9332
+ }
9333
+ function groupDeliveriesByDay(deliveries) {
9334
+ const grouped = /* @__PURE__ */ new Map();
9335
+ for (let i = 1; i <= 5; i++) {
9336
+ grouped.set(i, []);
9337
+ }
9338
+ for (const delivery of deliveries) {
9339
+ const dayOfWeek = delivery.date.getDay();
9340
+ if (dayOfWeek >= 1 && dayOfWeek <= 5) {
9341
+ const dayDeliveries = grouped.get(dayOfWeek) ?? [];
9342
+ dayDeliveries.push(delivery);
9343
+ grouped.set(dayOfWeek, dayDeliveries);
9344
+ }
9345
+ }
9346
+ return grouped;
9347
+ }
9348
+ function getDayLabel(dayOfWeek) {
9349
+ const labels = {
9350
+ 1: "Monday",
9351
+ 2: "Tuesday",
9352
+ 3: "Wednesday",
9353
+ 4: "Thursday",
9354
+ 5: "Friday"
9355
+ };
9356
+ return labels[dayOfWeek] ?? "";
9357
+ }
9358
+ function getShortDayLabel(dayOfWeek) {
9359
+ const labels = {
9360
+ 1: "Mon",
9361
+ 2: "Tue",
9362
+ 3: "Wed",
9363
+ 4: "Thu",
9364
+ 5: "Fri"
9365
+ };
9366
+ return labels[dayOfWeek] ?? "";
9367
+ }
9368
+ function extractPrefixes(deliveries) {
9369
+ const prefixMap = /* @__PURE__ */ new Map();
9370
+ for (const delivery of deliveries) {
9371
+ const prefixCode = delivery.prefixScope ?? "GENERAL";
9372
+ if (!prefixMap.has(prefixCode)) {
9373
+ prefixMap.set(prefixCode, {
9374
+ id: prefixCode,
9375
+ name: prefixCode === "GENERAL" ? "General" : prefixCode,
9376
+ typeCode: prefixCode,
9377
+ supplierId: delivery.supplierId,
9378
+ supplierName: delivery.supplierName,
9379
+ totalDeliveries: 0,
9380
+ sentDeliveries: 0,
9381
+ hasRisk: false
9382
+ });
9383
+ }
9384
+ const prefix = prefixMap.get(prefixCode);
9385
+ prefix.totalDeliveries += 1;
9386
+ if (delivery.status === "shipped" || delivery.status === "delivered") {
9387
+ prefix.sentDeliveries += 1;
9388
+ }
9389
+ if (delivery.hasProductionRisk) {
9390
+ prefix.hasRisk = true;
9391
+ }
9392
+ }
9393
+ return Array.from(prefixMap.values());
9394
+ }
9395
+ function groupDeliveriesByPrefixAndDay(deliveries) {
9396
+ const grouped = /* @__PURE__ */ new Map();
9397
+ for (const delivery of deliveries) {
9398
+ const prefixCode = delivery.prefixScope ?? "GENERAL";
9399
+ const dayOfWeek = delivery.date.getDay();
9400
+ if (dayOfWeek < 1 || dayOfWeek > 5) continue;
9401
+ if (!grouped.has(prefixCode)) {
9402
+ const dayMap2 = /* @__PURE__ */ new Map();
9403
+ for (let i = 1; i <= 5; i++) {
9404
+ dayMap2.set(i, []);
9405
+ }
9406
+ grouped.set(prefixCode, dayMap2);
9407
+ }
9408
+ const dayMap = grouped.get(prefixCode);
9409
+ const dayDeliveries = dayMap.get(dayOfWeek) ?? [];
9410
+ dayDeliveries.push(delivery);
9411
+ dayMap.set(dayOfWeek, dayDeliveries);
9412
+ }
9413
+ return grouped;
9414
+ }
9415
+ function getLeftStrokeStyles(state, hasRisk, isHovered) {
9416
+ if (hasRisk) {
9417
+ return {
9418
+ stroke: "border-l-[3px] border-l-red-500",
9419
+ content: "text-foreground",
9420
+ progressBg: "bg-red-500",
9421
+ iconColor: "text-red-600 dark:text-red-400"
9422
+ };
9423
+ }
9424
+ switch (state) {
9425
+ case "sent":
9426
+ return {
9427
+ stroke: "border-l-[3px] border-l-green-500/50",
9428
+ content: "text-muted-foreground/60",
9429
+ progressBg: "bg-green-500",
9430
+ iconColor: "text-green-600 dark:text-green-400"
9431
+ };
9432
+ case "ready":
9433
+ return {
9434
+ stroke: "border-l-[3px] border-l-green-500",
9435
+ content: "text-foreground",
9436
+ progressBg: "bg-green-500",
9437
+ iconColor: "text-green-600 dark:text-green-400"
9438
+ };
9439
+ default:
9440
+ return {
9441
+ stroke: isHovered ? "border-l-[3px] border-l-primary/50" : "border-l-[3px] border-l-border",
9442
+ content: "text-foreground",
9443
+ progressBg: "bg-primary",
9444
+ iconColor: "text-muted-foreground"
9445
+ };
9446
+ }
9447
+ }
9448
+ function DeliveryBadge({
9449
+ delivery,
9450
+ onClick,
9451
+ className
9452
+ }) {
9453
+ const [isHovered, setIsHovered] = React27__namespace.useState(false);
9454
+ const hasComments = delivery.comments.length > 0;
9455
+ const visualState = getDeliveryVisualState(delivery);
9456
+ const styles = getLeftStrokeStyles(visualState, delivery.hasProductionRisk ?? false, isHovered);
9457
+ const prefixTitle = React27__namespace.useMemo(() => {
9458
+ const prefixSet = /* @__PURE__ */ new Set();
9459
+ if (delivery.elements && delivery.elements.length > 0) {
9460
+ for (const element of delivery.elements) {
9461
+ if (element.prefix) {
9462
+ prefixSet.add(element.prefix);
9463
+ }
9464
+ }
9465
+ }
9466
+ if (prefixSet.size === 0 && delivery.prefixScope) {
9467
+ prefixSet.add(delivery.prefixScope);
9468
+ }
9469
+ const prefixes = Array.from(prefixSet);
9470
+ if (prefixes.length === 0) {
9471
+ return delivery.label;
9472
+ }
9473
+ if (prefixes.length > 3) {
9474
+ return `${prefixes.slice(0, 3).join(" \xB7 ")} \xB7 +${prefixes.length - 3}`;
9475
+ }
9476
+ return prefixes.join(" \xB7 ");
9477
+ }, [delivery]);
9478
+ const productionProgress = React27__namespace.useMemo(() => {
9479
+ if (delivery.producedTons !== void 0 && delivery.totalTons !== void 0 && delivery.totalTons > 0) {
9480
+ return Math.min(delivery.producedTons / delivery.totalTons * 100, 100);
9481
+ }
9482
+ if (delivery.producedCount !== void 0 && delivery.totalCount !== void 0 && delivery.totalCount > 0) {
9483
+ return Math.min(delivery.producedCount / delivery.totalCount * 100, 100);
9484
+ }
9485
+ if (delivery.loadedCount !== void 0 && delivery.totalCount !== void 0 && delivery.totalCount > 0) {
9486
+ return Math.min(delivery.loadedCount / delivery.totalCount * 100, 100);
9487
+ }
9488
+ return 0;
9489
+ }, [delivery]);
9490
+ const productionDisplay = React27__namespace.useMemo(() => {
9491
+ if (delivery.producedTons !== void 0 && delivery.totalTons !== void 0) {
9492
+ return `${delivery.producedTons}/${delivery.totalTons}t`;
9493
+ }
9494
+ if (delivery.producedCount !== void 0 && delivery.totalCount !== void 0) {
9495
+ return `${delivery.producedCount}/${delivery.totalCount}`;
9496
+ }
9497
+ if (delivery.loadedCount !== void 0 && delivery.totalCount !== void 0) {
9498
+ return `${delivery.loadedCount}/${delivery.totalCount}`;
9499
+ }
9500
+ return null;
9501
+ }, [delivery]);
9502
+ const handleClick = (e) => {
9503
+ e.stopPropagation();
9504
+ onClick?.();
9505
+ };
9506
+ const handleKeyDown = (e) => {
9507
+ if (e.key === "Enter" || e.key === " ") {
9508
+ e.preventDefault();
9509
+ e.stopPropagation();
9510
+ onClick?.();
9511
+ }
9512
+ };
9513
+ return /* @__PURE__ */ jsxRuntime.jsxs(
9514
+ "button",
9515
+ {
9516
+ type: "button",
9517
+ onClick: handleClick,
9518
+ onKeyDown: handleKeyDown,
9519
+ onMouseEnter: () => setIsHovered(true),
9520
+ onMouseLeave: () => setIsHovered(false),
9521
+ className: cn(
9522
+ // Position relative for comment dot
9523
+ "relative",
9524
+ // Full-width in cell, 90° corners
9525
+ "w-full rounded-none",
9526
+ // Sizing using Quantum tokens:
9527
+ // - h-[80px] card height
9528
+ // - px-6 = 24px horizontal (j3m.spacing.l)
9529
+ // - py-4 = 16px vertical (j3m.spacing.m)
9530
+ "h-[80px] px-6 py-4",
9531
+ // Layout
9532
+ "flex items-center",
9533
+ // Card base: white background, complete border
9534
+ "bg-background border border-border",
9535
+ // Left stroke for status
9536
+ styles.stroke,
9537
+ // Interactive states
9538
+ "cursor-pointer transition-all duration-200 ease-out",
9539
+ "hover:-translate-y-0.5 hover:shadow-[var(--j3m-shadow-md)]",
9540
+ "active:translate-y-0 active:shadow-sm",
9541
+ // Focus state
9542
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1",
9543
+ // Greyed out for sent state
9544
+ visualState === "sent" && "opacity-60",
9545
+ className
9546
+ ),
9547
+ children: [
9548
+ hasComments && /* @__PURE__ */ jsxRuntime.jsx(
9549
+ "span",
9550
+ {
9551
+ className: "absolute -top-1 -right-1 h-3 w-3 rounded-full bg-primary ring-2 ring-background",
9552
+ "aria-label": "Has comments"
9553
+ }
9554
+ ),
9555
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col justify-center gap-3 min-w-0 flex-1 overflow-hidden", children: [
9556
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 overflow-hidden", children: [
9557
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm font-semibold truncate", styles.content), children: prefixTitle }),
9558
+ visualState === "sent" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4 text-green-600 dark:text-green-400 shrink-0" }),
9559
+ delivery.hasProductionRisk && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "h-4 w-4 text-red-500 shrink-0" }),
9560
+ delivery.supplierName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground truncate ml-auto", children: delivery.supplierName })
9561
+ ] }),
9562
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
9563
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Factory, { className: cn("h-3.5 w-3.5 shrink-0", styles.iconColor) }),
9564
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 h-1.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
9565
+ "div",
9566
+ {
9567
+ className: cn("h-full rounded-full transition-all", styles.progressBg),
9568
+ style: { width: `${productionProgress}%` }
9569
+ }
9570
+ ) }),
9571
+ productionDisplay && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9572
+ "text-xs tabular-nums font-medium shrink-0",
9573
+ delivery.isReadyToUnload ? "text-green-600 dark:text-green-400" : delivery.hasProductionRisk ? "text-red-600 dark:text-red-400" : "text-muted-foreground"
9574
+ ), children: productionDisplay })
9575
+ ] })
9576
+ ] })
9577
+ ]
9578
+ }
9579
+ );
9580
+ }
9581
+ function WeeklyLoadingView({
9582
+ week,
9583
+ deliveries,
9584
+ onDeliveryClick,
9585
+ onWeekChange,
9586
+ onDayCommentClick,
9587
+ showNavigation = true,
9588
+ className
9589
+ }) {
9590
+ const weekDays = React27__namespace.useMemo(() => {
9591
+ const days = [];
9592
+ for (let i = 0; i < 5; i++) {
9593
+ const date = dateFns.addDays(week.startDate, i);
9594
+ days.push({
9595
+ date,
9596
+ dayOfWeek: i + 1,
9597
+ isToday: dateFns.isToday(date)
9598
+ });
9599
+ }
9600
+ return days;
9601
+ }, [week.startDate]);
9602
+ const deliveriesByDay = React27__namespace.useMemo(() => {
9603
+ const grouped = /* @__PURE__ */ new Map();
9604
+ for (let i = 1; i <= 5; i++) {
9605
+ grouped.set(i, []);
9606
+ }
9607
+ for (const delivery of deliveries) {
9608
+ const dayOfWeek = delivery.date.getDay();
9609
+ if (dayOfWeek >= 1 && dayOfWeek <= 5) {
9610
+ const dayDeliveries = grouped.get(dayOfWeek) ?? [];
9611
+ dayDeliveries.push(delivery);
9612
+ grouped.set(dayOfWeek, dayDeliveries);
9613
+ }
9614
+ }
9615
+ return grouped;
9616
+ }, [deliveries]);
9617
+ const commentCountByDay = React27__namespace.useMemo(() => {
9618
+ const counts = /* @__PURE__ */ new Map();
9619
+ for (let i = 1; i <= 5; i++) {
9620
+ counts.set(i, 0);
9621
+ }
9622
+ for (const delivery of deliveries) {
9623
+ const dayOfWeek = delivery.date.getDay();
9624
+ if (dayOfWeek >= 1 && dayOfWeek <= 5) {
9625
+ const current = counts.get(dayOfWeek) ?? 0;
9626
+ counts.set(dayOfWeek, current + delivery.comments.length);
9627
+ }
9628
+ }
9629
+ return counts;
9630
+ }, [deliveries]);
9631
+ const totalDeliveries = deliveries.length;
9632
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col", className), children: [
9633
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 border-b border-border p-4 lg:flex-row lg:items-center lg:justify-between", children: [
9634
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
9635
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
9636
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9637
+ "text-2xl font-bold tabular-nums",
9638
+ week.isCurrentWeek && "text-primary"
9639
+ ), children: week.label }),
9640
+ week.isCurrentWeek && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative flex h-2.5 w-2.5", children: [
9641
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75" }),
9642
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative inline-flex rounded-full h-2.5 w-2.5 bg-primary" })
9643
+ ] })
9644
+ ] }),
9645
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
9646
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: week.dateRange }),
9647
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
9648
+ totalDeliveries,
9649
+ " ",
9650
+ totalDeliveries === 1 ? "delivery" : "deliveries"
9651
+ ] })
9652
+ ] })
9653
+ ] }),
9654
+ showNavigation && onWeekChange && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
9655
+ /* @__PURE__ */ jsxRuntime.jsxs(
9656
+ Button,
9657
+ {
9658
+ variant: "outline",
9659
+ size: "icon",
9660
+ className: "h-8 w-8",
9661
+ onClick: () => onWeekChange("prev"),
9662
+ children: [
9663
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" }),
9664
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Previous week" })
9665
+ ]
9666
+ }
9667
+ ),
9668
+ /* @__PURE__ */ jsxRuntime.jsx(
9669
+ Button,
9670
+ {
9671
+ variant: "outline",
9672
+ size: "sm",
9673
+ onClick: () => {
9674
+ },
9675
+ children: "Today"
9676
+ }
9677
+ ),
9678
+ /* @__PURE__ */ jsxRuntime.jsxs(
9679
+ Button,
9680
+ {
9681
+ variant: "outline",
9682
+ size: "icon",
9683
+ className: "h-8 w-8",
9684
+ onClick: () => onWeekChange("next"),
9685
+ children: [
9686
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4" }),
9687
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Next week" })
9688
+ ]
9689
+ }
9690
+ )
9691
+ ] })
9692
+ ] }),
9693
+ /* @__PURE__ */ jsxRuntime.jsxs(ScrollArea, { className: "flex-1", children: [
9694
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "hidden sm:block", children: [
9695
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-5 border-b border-border bg-muted/30", children: weekDays.map(({ date, dayOfWeek, isToday: dayIsToday }) => {
9696
+ const dayCommentCount = commentCountByDay.get(dayOfWeek) ?? 0;
9697
+ return /* @__PURE__ */ jsxRuntime.jsxs(
9698
+ "div",
9699
+ {
9700
+ className: cn(
9701
+ // Relative for positioning comment button
9702
+ "relative",
9703
+ // Compact padding: py-2 px-3 (j3m.spacing.xs / j3m.spacing.s)
9704
+ "flex items-center justify-center gap-2 py-2 px-3",
9705
+ dayIsToday && "bg-primary/5"
9706
+ ),
9707
+ children: [
9708
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9709
+ "text-xs font-medium uppercase tracking-wide",
9710
+ dayIsToday ? "text-primary" : "text-muted-foreground"
9711
+ ), children: getShortDayLabel(dayOfWeek) }),
9712
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9713
+ "text-base font-semibold tabular-nums",
9714
+ dayIsToday ? "text-primary" : "text-foreground"
9715
+ ), children: date.getDate() }),
9716
+ /* @__PURE__ */ jsxRuntime.jsxs(
9717
+ Button,
9718
+ {
9719
+ variant: "ghost",
9720
+ size: "icon",
9721
+ className: cn(
9722
+ "absolute top-1 right-1 h-7 w-7",
9723
+ dayCommentCount > 0 && "text-primary"
9724
+ ),
9725
+ onClick: (e) => {
9726
+ e.stopPropagation();
9727
+ onDayCommentClick?.(dayOfWeek, date);
9728
+ },
9729
+ children: [
9730
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
9731
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-4 w-4" }),
9732
+ dayCommentCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" })
9733
+ ] }),
9734
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: dayCommentCount > 0 ? `${dayCommentCount} comments on ${getShortDayLabel(dayOfWeek)}` : `Add comment for ${getShortDayLabel(dayOfWeek)}` })
9735
+ ]
9736
+ }
9737
+ )
9738
+ ]
9739
+ },
9740
+ dayOfWeek
9741
+ );
9742
+ }) }),
9743
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-5", children: weekDays.map(({ dayOfWeek, isToday: dayIsToday }) => {
9744
+ const dayDeliveries = deliveriesByDay.get(dayOfWeek) ?? [];
9745
+ return /* @__PURE__ */ jsxRuntime.jsx(
9746
+ "div",
9747
+ {
9748
+ className: cn(
9749
+ // Column padding: p-3 = 12px (j3m.spacing.s)
9750
+ "flex flex-col p-3",
9751
+ dayIsToday && "bg-primary/5"
9752
+ ),
9753
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: dayDeliveries.length > 0 ? dayDeliveries.map((delivery) => /* @__PURE__ */ jsxRuntime.jsx(
9754
+ DeliveryBadge,
9755
+ {
9756
+ delivery,
9757
+ onClick: () => onDeliveryClick?.(delivery)
9758
+ },
9759
+ delivery.id
9760
+ )) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-6 text-sm text-muted-foreground/40", children: "\u2014" }) })
9761
+ },
9762
+ dayOfWeek
9763
+ );
9764
+ }) })
9765
+ ] }),
9766
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sm:hidden divide-y divide-border", children: weekDays.map(({ date, dayOfWeek, isToday: dayIsToday }) => {
9767
+ const dayDeliveries = deliveriesByDay.get(dayOfWeek) ?? [];
9768
+ const dayCommentCount = commentCountByDay.get(dayOfWeek) ?? 0;
9769
+ return /* @__PURE__ */ jsxRuntime.jsxs(
9770
+ "div",
9771
+ {
9772
+ className: cn(
9773
+ dayIsToday && "bg-primary/5"
9774
+ ),
9775
+ children: [
9776
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
9777
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
9778
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9779
+ "text-xs font-medium uppercase",
9780
+ dayIsToday ? "text-primary" : "text-muted-foreground"
9781
+ ), children: getShortDayLabel(dayOfWeek) }),
9782
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9783
+ "text-base font-semibold tabular-nums",
9784
+ dayIsToday ? "text-primary" : "text-foreground"
9785
+ ), children: date.getDate() }),
9786
+ dayIsToday && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-primary font-medium", children: "Today" })
9787
+ ] }),
9788
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
9789
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
9790
+ dayDeliveries.length,
9791
+ " ",
9792
+ dayDeliveries.length === 1 ? "delivery" : "deliveries"
9793
+ ] }),
9794
+ /* @__PURE__ */ jsxRuntime.jsxs(
9795
+ Button,
9796
+ {
9797
+ variant: "ghost",
9798
+ size: "icon",
9799
+ className: cn(
9800
+ "h-7 w-7",
9801
+ dayCommentCount > 0 && "text-primary"
9802
+ ),
9803
+ onClick: (e) => {
9804
+ e.stopPropagation();
9805
+ onDayCommentClick?.(dayOfWeek, date);
9806
+ },
9807
+ children: [
9808
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
9809
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-4 w-4" }),
9810
+ dayCommentCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" })
9811
+ ] }),
9812
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Comments" })
9813
+ ]
9814
+ }
9815
+ )
9816
+ ] })
9817
+ ] }),
9818
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3 p-3 pt-0", children: dayDeliveries.length > 0 ? dayDeliveries.map((delivery) => /* @__PURE__ */ jsxRuntime.jsx(
9819
+ DeliveryBadge,
9820
+ {
9821
+ delivery,
9822
+ onClick: () => onDeliveryClick?.(delivery)
9823
+ },
9824
+ delivery.id
9825
+ )) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground/40 py-4 text-center", children: "\u2014" }) })
9826
+ ]
9827
+ },
9828
+ dayOfWeek
9829
+ );
9830
+ }) })
9831
+ ] })
9832
+ ] });
9833
+ }
9834
+ function getStatusBadgeVariant2(status) {
9835
+ switch (status) {
9836
+ case "shipped":
9837
+ case "delivered":
9838
+ return "default";
9839
+ case "loaded":
9840
+ case "in_progress":
9841
+ return "secondary";
9842
+ case "cancelled":
9843
+ return "destructive";
9844
+ case "planned":
9845
+ default:
9846
+ return "outline";
9847
+ }
9848
+ }
9849
+ function getStatusBadgeClasses2(status) {
9850
+ switch (status) {
9851
+ case "shipped":
9852
+ case "delivered":
9853
+ return "border-green-500 text-green-600 bg-green-50 dark:bg-green-950/50";
9854
+ case "loaded":
9855
+ return "border-blue-500 text-blue-600 bg-blue-50 dark:bg-blue-950/50";
9856
+ case "in_progress":
9857
+ return "border-amber-500 text-amber-600 bg-amber-50 dark:bg-amber-950/50";
9858
+ case "cancelled":
9859
+ return "";
9860
+ case "planned":
9861
+ default:
9862
+ return "border-muted-foreground/50 text-muted-foreground";
9863
+ }
9864
+ }
9865
+ function getElementStatusBadgeClasses(status) {
9866
+ switch (status) {
9867
+ case "loaded":
9868
+ return "border-green-500 text-green-600 bg-green-50 dark:bg-green-950/50";
9869
+ case "missing":
9870
+ return "border-muted-foreground/50 text-muted-foreground bg-muted/50";
9871
+ case "moved":
9872
+ return "border-blue-500 text-blue-600 bg-blue-50 dark:bg-blue-950/50";
9873
+ case "addon":
9874
+ return "border-purple-500 text-purple-600 bg-purple-50 dark:bg-purple-950/50";
9875
+ default:
9876
+ return "border-muted-foreground/50 text-muted-foreground";
9877
+ }
9878
+ }
9879
+ function getElementRowBg(status) {
9880
+ switch (status) {
9881
+ case "loaded":
9882
+ return "bg-green-50/30 dark:bg-green-950/10";
9883
+ case "missing":
9884
+ return "bg-muted/30";
9885
+ case "moved":
9886
+ return "bg-blue-50/30 dark:bg-blue-950/10";
9887
+ case "addon":
9888
+ return "bg-purple-50/30 dark:bg-purple-950/10";
9889
+ default:
9890
+ return "";
9891
+ }
9892
+ }
9893
+ function AddCommentDialog({
9894
+ open,
9895
+ onOpenChange,
9896
+ delivery,
9897
+ weekId,
9898
+ onAddComment
9899
+ }) {
9900
+ const [commentText, setCommentText] = React27__namespace.useState("");
9901
+ const handleSubmit = () => {
9902
+ if (commentText.trim() && onAddComment) {
9903
+ onAddComment({
9904
+ author: "Current User",
9905
+ // Would come from auth context in real app
9906
+ text: commentText.trim(),
9907
+ context: "pre_unloading",
9908
+ weekId,
9909
+ deliveryId: delivery.id,
9910
+ supplierId: delivery.supplierId,
9911
+ supplierName: delivery.supplierName,
9912
+ prefixId: delivery.prefixScope,
9913
+ prefixName: delivery.prefixScope
9914
+ });
9915
+ setCommentText("");
9916
+ onOpenChange(false);
9917
+ }
9918
+ };
9919
+ const handleKeyDown = (e) => {
9920
+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
9921
+ e.preventDefault();
9922
+ handleSubmit();
9923
+ }
9924
+ };
9925
+ React27__namespace.useEffect(() => {
9926
+ if (!open) {
9927
+ setCommentText("");
9928
+ }
9929
+ }, [open]);
9930
+ return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "sm:max-w-md", children: [
9931
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
9932
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Add pre-unloading note" }),
9933
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogDescription, { children: [
9934
+ "Add a note for ",
9935
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: delivery.label }),
9936
+ " (",
9937
+ delivery.supplierName,
9938
+ delivery.prefixScope && ` \u2022 ${delivery.prefixScope}`,
9939
+ ")."
9940
+ ] })
9941
+ ] }),
9942
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
9943
+ /* @__PURE__ */ jsxRuntime.jsx(Label2, { htmlFor: "comment-text", className: "text-sm font-medium", children: "Note" }),
9944
+ /* @__PURE__ */ jsxRuntime.jsx(
9945
+ Textarea,
9946
+ {
9947
+ id: "comment-text",
9948
+ placeholder: "Add a note before unloading...",
9949
+ value: commentText,
9950
+ onChange: (e) => setCommentText(e.target.value),
9951
+ onKeyDown: handleKeyDown,
9952
+ className: "min-h-[120px] text-base resize-none",
9953
+ autoFocus: true
9954
+ }
9955
+ ),
9956
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "\u2318+Enter to save" })
9957
+ ] }) }),
9958
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [
9959
+ /* @__PURE__ */ jsxRuntime.jsx(
9960
+ Button,
9961
+ {
9962
+ variant: "ghost",
9963
+ onClick: () => onOpenChange(false),
9964
+ children: "Cancel"
9965
+ }
9966
+ ),
9967
+ /* @__PURE__ */ jsxRuntime.jsxs(
9968
+ Button,
9969
+ {
9970
+ onClick: handleSubmit,
9971
+ disabled: !commentText.trim(),
9972
+ className: "gap-1.5",
9973
+ children: [
9974
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Send, { className: "h-4 w-4" }),
9975
+ "Save note"
9976
+ ]
9977
+ }
9978
+ )
9979
+ ] })
9980
+ ] }) });
9981
+ }
9982
+ function CommentsSection({
9983
+ comments,
9984
+ delivery,
9985
+ weekId,
9986
+ onAddComment
9987
+ }) {
9988
+ const [viewCommentsOpen, setViewCommentsOpen] = React27__namespace.useState(true);
9989
+ const [addDialogOpen, setAddDialogOpen] = React27__namespace.useState(false);
9990
+ const formatDate2 = (date) => {
9991
+ return new Intl.DateTimeFormat("en-US", {
9992
+ month: "short",
9993
+ day: "numeric",
9994
+ hour: "numeric",
9995
+ minute: "2-digit"
9996
+ }).format(date);
9997
+ };
9998
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
9999
+ /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
10000
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10001
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10002
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-4 w-4 text-muted-foreground" }),
10003
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "Notes before unloading" }),
10004
+ comments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "secondary", className: "text-[10px] h-5", children: comments.length })
10005
+ ] }),
10006
+ /* @__PURE__ */ jsxRuntime.jsxs(
10007
+ Button,
10008
+ {
10009
+ variant: "outline",
10010
+ size: "sm",
10011
+ className: "gap-1.5 h-9",
10012
+ onClick: () => setAddDialogOpen(true),
10013
+ children: [
10014
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4" }),
10015
+ "Add note"
10016
+ ]
10017
+ }
10018
+ )
10019
+ ] }),
10020
+ comments.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
10021
+ /* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-between h-8 px-2", children: [
10022
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium", children: viewCommentsOpen ? "Hide comments" : "Show comments" }),
10023
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: cn(
10024
+ "h-4 w-4 transition-transform duration-200",
10025
+ viewCommentsOpen && "rotate-180"
10026
+ ) })
10027
+ ] }) }),
10028
+ /* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { className: "space-y-2 pt-2", children: comments.map((comment) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg bg-muted/50 p-3 space-y-1", children: [
10029
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10030
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10031
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium", children: comment.author }),
10032
+ comment.supplierName && /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", className: "text-[9px] px-1.5 py-0 h-4", children: comment.prefixName ? `${comment.supplierName} - ${comment.prefixName}` : comment.supplierName })
10033
+ ] }),
10034
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: formatDate2(comment.createdAt) })
10035
+ ] }),
10036
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: comment.text })
10037
+ ] }, comment.id)) })
10038
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-dashed p-4 text-center text-sm text-muted-foreground", children: "No pre-unloading notes yet. Add notes before confirming the load." })
10039
+ ] }),
10040
+ /* @__PURE__ */ jsxRuntime.jsx(
10041
+ AddCommentDialog,
10042
+ {
10043
+ open: addDialogOpen,
10044
+ onOpenChange: setAddDialogOpen,
10045
+ delivery,
10046
+ weekId,
10047
+ onAddComment
10048
+ }
10049
+ )
10050
+ ] });
10051
+ }
10052
+ function getDeliveryHeaderStyles(state, hasRisk) {
10053
+ if (hasRisk) {
10054
+ return {
10055
+ iconBg: "bg-red-100 dark:bg-red-950/50",
10056
+ iconColor: "text-red-600 dark:text-red-400"
10057
+ };
10058
+ }
10059
+ switch (state) {
10060
+ case "sent":
10061
+ return {
10062
+ iconBg: "bg-green-100 dark:bg-green-950/50",
10063
+ iconColor: "text-green-600 dark:text-green-400"
10064
+ };
10065
+ case "ready":
10066
+ return {
10067
+ iconBg: "bg-green-100 dark:bg-green-950/50",
10068
+ iconColor: "text-green-600 dark:text-green-400"
10069
+ };
10070
+ default:
10071
+ return {
10072
+ iconBg: "bg-muted",
10073
+ iconColor: "text-muted-foreground"
10074
+ };
10075
+ }
10076
+ }
10077
+ function DeliveryDetailPage({
10078
+ delivery,
10079
+ week,
10080
+ suppliers,
10081
+ userRole,
10082
+ currentSupplierId,
10083
+ onBack,
10084
+ onAddComment,
10085
+ onConfirmLoad
10086
+ }) {
10087
+ const visualState = getDeliveryVisualState(delivery);
10088
+ const headerStyles = getDeliveryHeaderStyles(visualState, delivery.hasProductionRisk ?? false);
10089
+ const loadedCount = delivery.loadedCount ?? delivery.elements.filter((e) => e.status === "loaded").length;
10090
+ const totalCount = delivery.totalCount ?? delivery.elements.length;
10091
+ const loadedPercent = totalCount > 0 ? Math.round(loadedCount / totalCount * 100) : 0;
10092
+ const producedCount = delivery.producedCount ?? loadedCount;
10093
+ const producedPercent = totalCount > 0 ? Math.round(producedCount / totalCount * 100) : 0;
10094
+ const elementsByStatus = React27__namespace.useMemo(() => {
10095
+ const loaded = delivery.elements.filter((e) => e.status === "loaded");
10096
+ const missing = delivery.elements.filter((e) => e.status === "missing");
10097
+ const moved = delivery.elements.filter((e) => e.status === "moved");
10098
+ const addons = delivery.elements.filter((e) => e.status === "addon");
10099
+ return { loaded, missing, moved, addons };
10100
+ }, [delivery.elements]);
10101
+ const preUnloadingComments = delivery.comments.filter((c) => c.context === "pre_unloading");
10102
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-full", children: [
10103
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 px-4 py-3 border-b bg-background sticky top-0 z-10", children: /* @__PURE__ */ jsxRuntime.jsxs(
10104
+ Button,
10105
+ {
10106
+ variant: "ghost",
10107
+ size: "sm",
10108
+ className: "gap-1 -ml-2",
10109
+ onClick: onBack,
10110
+ children: [
10111
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" }),
10112
+ "Back"
10113
+ ]
10114
+ }
10115
+ ) }),
10116
+ /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "flex-1", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 pb-6 space-y-6", children: [
10117
+ /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "pt-4 space-y-4", children: [
10118
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-3", children: [
10119
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
10120
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(
10121
+ "flex items-center justify-center h-12 w-12 rounded-xl shrink-0",
10122
+ headerStyles.iconBg
10123
+ ), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: cn("h-6 w-6", headerStyles.iconColor) }) }),
10124
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10125
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10126
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: delivery.label }),
10127
+ visualState === "sent" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-5 w-5 text-green-600 dark:text-green-400" }),
10128
+ delivery.hasProductionRisk && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "h-5 w-5 text-red-500" })
10129
+ ] }),
10130
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
10131
+ delivery.supplierName,
10132
+ delivery.prefixScope && ` \u2022 ${delivery.prefixScope}`
10133
+ ] })
10134
+ ] })
10135
+ ] }),
10136
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-end gap-1.5", children: [
10137
+ /* @__PURE__ */ jsxRuntime.jsx(
10138
+ Badge,
10139
+ {
10140
+ variant: getStatusBadgeVariant2(delivery.status),
10141
+ className: cn("shrink-0", getStatusBadgeClasses2(delivery.status)),
10142
+ children: getLoadingDeliveryStatusLabel(delivery.status)
10143
+ }
10144
+ ),
10145
+ delivery.isReadyToUnload && /* @__PURE__ */ jsxRuntime.jsx(
10146
+ Badge,
10147
+ {
10148
+ variant: "outline",
10149
+ className: "bg-green-100 dark:bg-green-900/50 border-green-300 dark:border-green-700 text-green-700 dark:text-green-300",
10150
+ children: "Ready to unload"
10151
+ }
10152
+ )
10153
+ ] })
10154
+ ] }),
10155
+ delivery.hasProductionRisk && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border-l-2 border-l-red-500 bg-red-50/50 dark:bg-red-950/30 p-3", children: [
10156
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10157
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "h-4 w-4 text-red-600 dark:text-red-400 shrink-0" }),
10158
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-red-700 dark:text-red-400", children: "Production delay risk" })
10159
+ ] }),
10160
+ delivery.riskReason && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-600 dark:text-red-400 mt-1 ml-6", children: delivery.riskReason })
10161
+ ] }),
10162
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-4 text-sm text-muted-foreground", children: [
10163
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
10164
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Calendar, { className: "h-4 w-4" }),
10165
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: delivery.date.toLocaleDateString("en-US", {
10166
+ weekday: "short",
10167
+ month: "short",
10168
+ day: "numeric"
10169
+ }) })
10170
+ ] }),
10171
+ delivery.destination && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
10172
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "h-4 w-4" }),
10173
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: delivery.destination })
10174
+ ] })
10175
+ ] }),
10176
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg bg-muted/50 p-4 space-y-3", children: [
10177
+ (delivery.producedCount !== void 0 || delivery.producedTons !== void 0) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
10178
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10179
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "Production" }),
10180
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn(
10181
+ "text-sm font-semibold tabular-nums",
10182
+ delivery.isReadyToUnload ? "text-green-600 dark:text-green-400" : delivery.hasProductionRisk ? "text-red-600 dark:text-red-400" : ""
10183
+ ), children: [
10184
+ delivery.producedTons !== void 0 && delivery.totalTons !== void 0 ? `${delivery.producedTons} / ${delivery.totalTons} tons` : `Produced ${producedCount} / ${totalCount}`,
10185
+ delivery.isReadyToUnload && " \u2713"
10186
+ ] })
10187
+ ] }),
10188
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
10189
+ "div",
10190
+ {
10191
+ className: cn(
10192
+ "h-full rounded-full transition-all",
10193
+ delivery.isReadyToUnload ? "bg-green-500" : delivery.hasProductionRisk ? "bg-red-500" : "bg-amber-500"
10194
+ ),
10195
+ style: { width: `${producedPercent}%` }
10196
+ }
10197
+ ) })
10198
+ ] }),
10199
+ /* @__PURE__ */ jsxRuntime.jsx(Separator, { className: "my-2" }),
10200
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
10201
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10202
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "Loading Progress" }),
10203
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm font-semibold tabular-nums", children: [
10204
+ "Loaded ",
10205
+ loadedCount,
10206
+ " / ",
10207
+ totalCount
10208
+ ] })
10209
+ ] }),
10210
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
10211
+ "div",
10212
+ {
10213
+ className: cn(
10214
+ "h-full rounded-full transition-all",
10215
+ loadedPercent === 100 ? "bg-green-500" : "bg-primary"
10216
+ ),
10217
+ style: { width: `${loadedPercent}%` }
10218
+ }
10219
+ ) }),
10220
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 flex-wrap text-xs", children: [
10221
+ elementsByStatus.loaded.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-green-600 dark:text-green-400", children: [
10222
+ elementsByStatus.loaded.length,
10223
+ " Loaded"
10224
+ ] }),
10225
+ elementsByStatus.missing.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground", children: [
10226
+ elementsByStatus.missing.length,
10227
+ " Missing"
10228
+ ] }),
10229
+ elementsByStatus.moved.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-blue-600 dark:text-blue-400", children: [
10230
+ elementsByStatus.moved.length,
10231
+ " Moved"
10232
+ ] }),
10233
+ elementsByStatus.addons.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-purple-600 dark:text-purple-400", children: [
10234
+ elementsByStatus.addons.length,
10235
+ " Add-on"
10236
+ ] })
10237
+ ] })
10238
+ ] })
10239
+ ] })
10240
+ ] }),
10241
+ delivery.elements.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
10242
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10243
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Package, { className: "h-4 w-4 text-muted-foreground" }),
10244
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "Elements to Unload" }),
10245
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground ml-auto", children: [
10246
+ delivery.elements.length,
10247
+ " total"
10248
+ ] })
10249
+ ] }),
10250
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
10251
+ /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "bg-sidebar hover:bg-sidebar", children: [
10252
+ /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold", children: "Prefix" }),
10253
+ /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold", children: "Type" }),
10254
+ /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold text-right", children: "Weight" }),
10255
+ /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold text-right", children: "Size (m\xB2)" }),
10256
+ /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold text-center", children: "Status" })
10257
+ ] }) }),
10258
+ /* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: delivery.elements.map((element) => /* @__PURE__ */ jsxRuntime.jsxs(
10259
+ TableRow,
10260
+ {
10261
+ className: getElementRowBg(element.status),
10262
+ children: [
10263
+ /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "font-medium", children: element.prefix }),
10264
+ /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: element.type }),
10265
+ /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-right tabular-nums", children: element.weight ? /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
10266
+ element.weight,
10267
+ " ",
10268
+ element.weightUnit || "kg"
10269
+ ] }) : "\u2014" }),
10270
+ /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-right tabular-nums", children: element.sizeSqm ?? "\u2014" }),
10271
+ /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-1", children: [
10272
+ /* @__PURE__ */ jsxRuntime.jsx(
10273
+ Badge,
10274
+ {
10275
+ variant: "outline",
10276
+ className: cn(
10277
+ "text-[10px] h-5",
10278
+ getElementStatusBadgeClasses(element.status)
10279
+ ),
10280
+ children: getLoadingElementStatusLabel(element.status)
10281
+ }
10282
+ ),
10283
+ element.status === "moved" && element.actualDeliveryLabel && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[9px] text-blue-600 dark:text-blue-400", children: [
10284
+ "\u2192 ",
10285
+ element.actualDeliveryLabel
10286
+ ] }),
10287
+ element.status === "addon" && element.originalDeliveryLabel && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[9px] text-purple-600 dark:text-purple-400", children: [
10288
+ "from ",
10289
+ element.originalDeliveryLabel
10290
+ ] })
10291
+ ] }) })
10292
+ ]
10293
+ },
10294
+ element.id
10295
+ )) })
10296
+ ] }) })
10297
+ ] }),
10298
+ /* @__PURE__ */ jsxRuntime.jsx(
10299
+ CommentsSection,
10300
+ {
10301
+ comments: preUnloadingComments,
10302
+ delivery,
10303
+ weekId: week.weekKey,
10304
+ onAddComment
10305
+ }
10306
+ ),
10307
+ onConfirmLoad && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "pt-4", children: [
10308
+ /* @__PURE__ */ jsxRuntime.jsx(
10309
+ Button,
10310
+ {
10311
+ className: "w-full h-12 text-base",
10312
+ onClick: () => onConfirmLoad(delivery.id),
10313
+ children: "Start Loading"
10314
+ }
10315
+ ),
10316
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground text-center mt-2", children: "Comments are saved independently." })
10317
+ ] })
10318
+ ] }) })
10319
+ ] });
10320
+ }
10321
+ function SupplierWeeklyLoading({
10322
+ week,
10323
+ deliveries,
10324
+ suppliers,
10325
+ userRole,
10326
+ currentSupplierId,
10327
+ onDeliveryClick,
10328
+ onBack,
10329
+ onAddComment,
10330
+ onConfirmLoad,
10331
+ onWeekChange,
10332
+ showNavigation = true,
10333
+ bordered = true,
10334
+ className
10335
+ }) {
10336
+ const [selectedDelivery, setSelectedDelivery] = React27__namespace.useState(null);
10337
+ const [sheetOpen, setSheetOpen] = React27__namespace.useState(false);
10338
+ const handleDeliveryClick = (delivery) => {
10339
+ setSelectedDelivery(delivery);
10340
+ setSheetOpen(true);
10341
+ onDeliveryClick?.(delivery);
10342
+ };
10343
+ const handleSheetClose = () => {
10344
+ setSheetOpen(false);
10345
+ setTimeout(() => setSelectedDelivery(null), 200);
10346
+ onBack?.();
10347
+ };
10348
+ const Wrapper = bordered ? Card : "div";
10349
+ const Content14 = bordered ? CardContent : "div";
10350
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10351
+ /* @__PURE__ */ jsxRuntime.jsx(
10352
+ Wrapper,
10353
+ {
10354
+ className: cn(
10355
+ "flex flex-col overflow-hidden",
10356
+ // Removed fixed min-height - content-driven sizing
10357
+ !bordered && "border border-border bg-card rounded-lg",
10358
+ className
10359
+ ),
10360
+ children: /* @__PURE__ */ jsxRuntime.jsx(Content14, { className: cn("flex-1 overflow-hidden p-0", !bordered && ""), children: /* @__PURE__ */ jsxRuntime.jsx(
10361
+ WeeklyLoadingView,
10362
+ {
10363
+ week,
10364
+ deliveries,
10365
+ onDeliveryClick: handleDeliveryClick,
10366
+ onWeekChange,
10367
+ showNavigation
10368
+ }
10369
+ ) })
10370
+ }
10371
+ ),
10372
+ /* @__PURE__ */ jsxRuntime.jsx(Sheet, { open: sheetOpen, onOpenChange: (open) => !open && handleSheetClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(
10373
+ SheetContent,
10374
+ {
10375
+ side: "right",
10376
+ className: "w-full sm:max-w-lg p-0 overflow-hidden",
10377
+ children: [
10378
+ /* @__PURE__ */ jsxRuntime.jsx(SheetHeader, { className: "sr-only", children: /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: selectedDelivery?.label ?? "Delivery Details" }) }),
10379
+ selectedDelivery && /* @__PURE__ */ jsxRuntime.jsx(
10380
+ DeliveryDetailPage,
10381
+ {
10382
+ delivery: selectedDelivery,
10383
+ week,
10384
+ suppliers,
10385
+ userRole,
10386
+ currentSupplierId,
10387
+ onBack: handleSheetClose,
10388
+ onAddComment,
10389
+ onConfirmLoad
10390
+ }
10391
+ )
10392
+ ]
10393
+ }
10394
+ ) })
10395
+ ] });
10396
+ }
10397
+ function getStatusBadgeVariant3(status) {
10398
+ switch (status) {
10399
+ case "shipped":
10400
+ case "delivered":
10401
+ return "default";
10402
+ case "loaded":
10403
+ case "in_progress":
10404
+ return "secondary";
10405
+ case "cancelled":
10406
+ return "destructive";
10407
+ case "planned":
10408
+ default:
10409
+ return "outline";
10410
+ }
10411
+ }
10412
+ function getStatusBadgeClasses3(status) {
10413
+ switch (status) {
10414
+ case "shipped":
10415
+ case "delivered":
10416
+ return "border-green-500 text-green-600 bg-green-50 dark:bg-green-950/50";
10417
+ case "loaded":
10418
+ return "border-blue-500 text-blue-600 bg-blue-50 dark:bg-blue-950/50";
10419
+ case "in_progress":
10420
+ return "border-amber-500 text-amber-600 bg-amber-50 dark:bg-amber-950/50";
10421
+ case "cancelled":
10422
+ return "";
10423
+ case "planned":
10424
+ default:
10425
+ return "border-muted-foreground/50 text-muted-foreground";
10426
+ }
10427
+ }
10428
+ function getLeftStrokeStyles2(state, hasRisk, isHovered) {
10429
+ if (hasRisk) {
10430
+ return {
10431
+ stroke: "border-l-2 border-l-red-500",
10432
+ iconColor: "text-muted-foreground"
10433
+ };
10434
+ }
10435
+ switch (state) {
10436
+ case "sent":
10437
+ return {
10438
+ stroke: "border-l-2 border-l-green-500/50",
10439
+ iconColor: "text-muted-foreground/40"
10440
+ };
10441
+ case "ready":
10442
+ return {
10443
+ stroke: "border-l-2 border-l-green-500",
10444
+ iconColor: "text-muted-foreground"
10445
+ };
10446
+ default:
10447
+ return {
10448
+ stroke: isHovered ? "border-l-2 border-l-border" : "border-l-2 border-l-transparent",
10449
+ iconColor: "text-muted-foreground"
10450
+ };
10451
+ }
10452
+ }
10453
+ function DeliveryCard({
10454
+ delivery,
10455
+ onTap,
10456
+ className
10457
+ }) {
10458
+ const [isHovered, setIsHovered] = React27__namespace.useState(false);
10459
+ const hasComments = delivery.comments.length > 0;
10460
+ const visualState = getDeliveryVisualState(delivery);
10461
+ const styles = getLeftStrokeStyles2(visualState, delivery.hasProductionRisk ?? false, isHovered);
10462
+ const productionDisplay = React27__namespace.useMemo(() => {
10463
+ if (delivery.producedTons !== void 0 && delivery.totalTons !== void 0) {
10464
+ return `${delivery.producedTons} / ${delivery.totalTons}t produced`;
10465
+ }
10466
+ if (delivery.producedCount !== void 0 && delivery.totalCount !== void 0) {
10467
+ return `${delivery.producedCount} / ${delivery.totalCount} produced`;
10468
+ }
10469
+ if (delivery.loadedCount !== void 0 && delivery.totalCount !== void 0) {
10470
+ return `Loaded ${delivery.loadedCount} / ${delivery.totalCount}`;
10471
+ }
10472
+ return null;
10473
+ }, [delivery]);
10474
+ const handleClick = () => {
10475
+ onTap?.();
10476
+ };
10477
+ const handleKeyDown = (e) => {
10478
+ if (e.key === "Enter" || e.key === " ") {
10479
+ e.preventDefault();
10480
+ onTap?.();
10481
+ }
10482
+ };
10483
+ return /* @__PURE__ */ jsxRuntime.jsx(
10484
+ "div",
10485
+ {
10486
+ role: "button",
10487
+ tabIndex: 0,
10488
+ onClick: handleClick,
10489
+ onKeyDown: handleKeyDown,
10490
+ onMouseEnter: () => setIsHovered(true),
10491
+ onMouseLeave: () => setIsHovered(false),
10492
+ className: cn(
10493
+ // Full-width, 90° corners (j3m.radius.none)
10494
+ "w-full rounded-none",
10495
+ // Touch-friendly sizing - 56px min-height for iPad
10496
+ "min-h-[56px] p-4",
10497
+ // Card styling: white background, standard border
10498
+ "bg-background border border-border",
10499
+ // Left stroke for status (j3m.stroke.m = 2px)
10500
+ styles.stroke,
10501
+ // Hover/tap state - lift effect like Calibration
10502
+ "cursor-pointer transition-all duration-200 ease-out",
10503
+ "hover:-translate-y-0.5 hover:shadow-[var(--j3m-shadow-md)]",
10504
+ "active:translate-y-0 active:shadow-sm",
10505
+ // Focus state
10506
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
10507
+ // Greyed out for sent state
10508
+ visualState === "sent" && "opacity-60",
10509
+ className
10510
+ ),
10511
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-3", children: [
10512
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3 min-w-0 flex-1", children: [
10513
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(
10514
+ "flex items-center justify-center h-10 w-10 rounded-md shrink-0 bg-muted/50"
10515
+ ), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: cn("h-5 w-5", styles.iconColor) }) }),
10516
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 min-w-0", children: [
10517
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10518
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold truncate", children: delivery.label }),
10519
+ visualState === "sent" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4 text-green-600 dark:text-green-400 shrink-0" }),
10520
+ visualState === "ready" && /* @__PURE__ */ jsxRuntime.jsx(
10521
+ Badge,
10522
+ {
10523
+ variant: "outline",
10524
+ className: "text-[9px] px-1.5 py-0 h-4 bg-green-100 dark:bg-green-900/50 border-green-300 dark:border-green-700 text-green-700 dark:text-green-300",
10525
+ children: "Ready"
10526
+ }
10527
+ ),
10528
+ delivery.hasProductionRisk && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "h-4 w-4 text-red-500 shrink-0" }),
10529
+ hasComments && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative shrink-0", children: [
10530
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-3.5 w-3.5 text-muted-foreground" }),
10531
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -top-0.5 -right-0.5 h-2 w-2 rounded-full bg-primary" })
10532
+ ] })
10533
+ ] }),
10534
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground truncate", children: [
10535
+ delivery.supplierName,
10536
+ delivery.prefixScope && ` \u2022 ${delivery.prefixScope}`
10537
+ ] }),
10538
+ productionDisplay && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 text-xs", children: [
10539
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Package, { className: "h-3 w-3 text-muted-foreground" }),
10540
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn(
10541
+ delivery.isReadyToUnload ? "text-green-600 dark:text-green-400 font-medium" : delivery.hasProductionRisk ? "text-red-600 dark:text-red-400" : "text-muted-foreground"
10542
+ ), children: [
10543
+ delivery.isReadyToUnload ? "\u2713 " : "",
10544
+ productionDisplay
10545
+ ] })
10546
+ ] })
10547
+ ] })
10548
+ ] }),
10549
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 shrink-0", children: [
10550
+ /* @__PURE__ */ jsxRuntime.jsx(
10551
+ Badge,
10552
+ {
10553
+ variant: getStatusBadgeVariant3(delivery.status),
10554
+ className: cn("text-[10px] h-5", getStatusBadgeClasses3(delivery.status)),
10555
+ children: getLoadingDeliveryStatusLabel(delivery.status)
10556
+ }
10557
+ ),
10558
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 text-muted-foreground" })
10559
+ ] })
10560
+ ] })
10561
+ }
10562
+ );
10563
+ }
10564
+
9172
10565
  // src/components/event-calendar/types.ts
9173
10566
  var DEFAULT_WORKING_HOURS = {
9174
10567
  0: { from: 0, to: 0 },
@@ -9231,7 +10624,7 @@ var BADGE_VARIANT_LABELS = {
9231
10624
  colored: "Colored",
9232
10625
  mixed: "Mixed"
9233
10626
  };
9234
- var CalendarContext = React22__namespace.createContext(null);
10627
+ var CalendarContext = React27__namespace.createContext(null);
9235
10628
  function EventCalendarProvider({
9236
10629
  children,
9237
10630
  events: initialEvents = [],
@@ -9246,38 +10639,38 @@ function EventCalendarProvider({
9246
10639
  onEventUpdate,
9247
10640
  onEventDelete
9248
10641
  }) {
9249
- const [selectedDate, setSelectedDate] = React22__namespace.useState(defaultDate);
9250
- const [selectedUserId, setSelectedUserId] = React22__namespace.useState(defaultUserId);
9251
- const [events, setEventsState] = React22__namespace.useState(initialEvents);
9252
- const [users] = React22__namespace.useState(initialUsers);
9253
- const [badgeVariant, setBadgeVariant] = React22__namespace.useState(defaultBadgeVariant);
9254
- const [view, setView] = React22__namespace.useState(defaultView);
9255
- const [workingHours, setWorkingHours] = React22__namespace.useState(defaultWorkingHours);
9256
- const [visibleHours, setVisibleHours] = React22__namespace.useState(defaultVisibleHours);
9257
- React22__namespace.useEffect(() => {
10642
+ const [selectedDate, setSelectedDate] = React27__namespace.useState(defaultDate);
10643
+ const [selectedUserId, setSelectedUserId] = React27__namespace.useState(defaultUserId);
10644
+ const [events, setEventsState] = React27__namespace.useState(initialEvents);
10645
+ const [users] = React27__namespace.useState(initialUsers);
10646
+ const [badgeVariant, setBadgeVariant] = React27__namespace.useState(defaultBadgeVariant);
10647
+ const [view, setView] = React27__namespace.useState(defaultView);
10648
+ const [workingHours, setWorkingHours] = React27__namespace.useState(defaultWorkingHours);
10649
+ const [visibleHours, setVisibleHours] = React27__namespace.useState(defaultVisibleHours);
10650
+ React27__namespace.useEffect(() => {
9258
10651
  setEventsState(initialEvents);
9259
10652
  }, [initialEvents]);
9260
- const setEvents = React22__namespace.useCallback((newEvents) => {
10653
+ const setEvents = React27__namespace.useCallback((newEvents) => {
9261
10654
  setEventsState(newEvents);
9262
10655
  }, []);
9263
- const addEvent = React22__namespace.useCallback((event) => {
10656
+ const addEvent = React27__namespace.useCallback((event) => {
9264
10657
  setEventsState((prev) => [...prev, event]);
9265
10658
  onEventAdd?.(event);
9266
10659
  }, [onEventAdd]);
9267
- const updateEvent = React22__namespace.useCallback((event) => {
10660
+ const updateEvent = React27__namespace.useCallback((event) => {
9268
10661
  setEventsState(
9269
10662
  (prev) => prev.map((e) => e.id === event.id ? event : e)
9270
10663
  );
9271
10664
  onEventUpdate?.(event);
9272
10665
  }, [onEventUpdate]);
9273
- const deleteEvent = React22__namespace.useCallback((eventId) => {
10666
+ const deleteEvent = React27__namespace.useCallback((eventId) => {
9274
10667
  setEventsState((prev) => prev.filter((e) => e.id !== eventId));
9275
10668
  onEventDelete?.(eventId);
9276
10669
  }, [onEventDelete]);
9277
- const goToToday = React22__namespace.useCallback(() => {
10670
+ const goToToday = React27__namespace.useCallback(() => {
9278
10671
  setSelectedDate(/* @__PURE__ */ new Date());
9279
10672
  }, []);
9280
- const goToPrevious = React22__namespace.useCallback(() => {
10673
+ const goToPrevious = React27__namespace.useCallback(() => {
9281
10674
  setSelectedDate((current) => {
9282
10675
  switch (view) {
9283
10676
  case "day":
@@ -9295,7 +10688,7 @@ function EventCalendarProvider({
9295
10688
  }
9296
10689
  });
9297
10690
  }, [view]);
9298
- const goToNext = React22__namespace.useCallback(() => {
10691
+ const goToNext = React27__namespace.useCallback(() => {
9299
10692
  setSelectedDate((current) => {
9300
10693
  switch (view) {
9301
10694
  case "day":
@@ -9313,7 +10706,7 @@ function EventCalendarProvider({
9313
10706
  }
9314
10707
  });
9315
10708
  }, [view]);
9316
- const contextValue = React22__namespace.useMemo(
10709
+ const contextValue = React27__namespace.useMemo(
9317
10710
  () => ({
9318
10711
  // State
9319
10712
  selectedDate,
@@ -9360,7 +10753,7 @@ function EventCalendarProvider({
9360
10753
  return /* @__PURE__ */ jsxRuntime.jsx(CalendarContext.Provider, { value: contextValue, children });
9361
10754
  }
9362
10755
  function useEventCalendar() {
9363
- const context = React22__namespace.useContext(CalendarContext);
10756
+ const context = React27__namespace.useContext(CalendarContext);
9364
10757
  if (!context) {
9365
10758
  throw new Error("useEventCalendar must be used within an EventCalendarProvider");
9366
10759
  }
@@ -9368,14 +10761,14 @@ function useEventCalendar() {
9368
10761
  }
9369
10762
  function useFilteredEvents() {
9370
10763
  const { events, selectedUserId } = useEventCalendar();
9371
- return React22__namespace.useMemo(() => {
10764
+ return React27__namespace.useMemo(() => {
9372
10765
  if (!selectedUserId) return events;
9373
10766
  return events.filter((event) => event.user.id === selectedUserId);
9374
10767
  }, [events, selectedUserId]);
9375
10768
  }
9376
10769
  function useEventsInRange(startDate, endDate) {
9377
10770
  const filteredEvents = useFilteredEvents();
9378
- return React22__namespace.useMemo(() => {
10771
+ return React27__namespace.useMemo(() => {
9379
10772
  return filteredEvents.filter((event) => {
9380
10773
  const eventStart = new Date(event.startDate);
9381
10774
  const eventEnd = new Date(event.endDate);
@@ -9933,8 +11326,8 @@ function MoreEvents({ count, onClick, className }) {
9933
11326
  );
9934
11327
  }
9935
11328
  function TimeIndicator({ className }) {
9936
- const [now, setNow] = React22__namespace.useState(/* @__PURE__ */ new Date());
9937
- React22__namespace.useEffect(() => {
11329
+ const [now, setNow] = React27__namespace.useState(/* @__PURE__ */ new Date());
11330
+ React27__namespace.useEffect(() => {
9938
11331
  const interval = setInterval(() => setNow(/* @__PURE__ */ new Date()), 6e4);
9939
11332
  return () => clearInterval(interval);
9940
11333
  }, []);
@@ -9971,24 +11364,24 @@ function DateBadge({ date, className }) {
9971
11364
  }
9972
11365
  );
9973
11366
  }
9974
- var DragContext = React22__namespace.createContext(null);
11367
+ var DragContext = React27__namespace.createContext(null);
9975
11368
  function DragProvider({
9976
11369
  children,
9977
11370
  snapMinutes = 15,
9978
11371
  onDragStart,
9979
11372
  onDragEnd
9980
11373
  }) {
9981
- const [draggedEvent, setDraggedEventState] = React22__namespace.useState(null);
9982
- const [isDragging, setIsDragging] = React22__namespace.useState(false);
11374
+ const [draggedEvent, setDraggedEventState] = React27__namespace.useState(null);
11375
+ const [isDragging, setIsDragging] = React27__namespace.useState(false);
9983
11376
  const { updateEvent } = useEventCalendar();
9984
- const setDraggedEvent = React22__namespace.useCallback((event) => {
11377
+ const setDraggedEvent = React27__namespace.useCallback((event) => {
9985
11378
  setDraggedEventState(event);
9986
11379
  setIsDragging(!!event);
9987
11380
  if (event) {
9988
11381
  onDragStart?.(event);
9989
11382
  }
9990
11383
  }, [onDragStart]);
9991
- const handleDrop = React22__namespace.useCallback((newStartDate) => {
11384
+ const handleDrop = React27__namespace.useCallback((newStartDate) => {
9992
11385
  if (!draggedEvent) return;
9993
11386
  const snappedDate = snapToInterval(newStartDate, snapMinutes);
9994
11387
  const { startDate, endDate } = calculateDropDates(draggedEvent, snappedDate);
@@ -10001,7 +11394,7 @@ function DragProvider({
10001
11394
  onDragEnd?.(updatedEvent, new Date(startDate), new Date(endDate));
10002
11395
  setDraggedEvent(null);
10003
11396
  }, [draggedEvent, snapMinutes, updateEvent, onDragEnd, setDraggedEvent]);
10004
- const contextValue = React22__namespace.useMemo(
11397
+ const contextValue = React27__namespace.useMemo(
10005
11398
  () => ({
10006
11399
  draggedEvent,
10007
11400
  setDraggedEvent,
@@ -10012,7 +11405,7 @@ function DragProvider({
10012
11405
  return /* @__PURE__ */ jsxRuntime.jsx(DragContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(DragDropHandler, { onDrop: handleDrop, children }) });
10013
11406
  }
10014
11407
  function useDrag() {
10015
- const context = React22__namespace.useContext(DragContext);
11408
+ const context = React27__namespace.useContext(DragContext);
10016
11409
  if (!context) {
10017
11410
  throw new Error("useDrag must be used within a DragProvider");
10018
11411
  }
@@ -10057,7 +11450,7 @@ function DroppableZone({
10057
11450
  }) {
10058
11451
  const { draggedEvent, setDraggedEvent } = useDrag();
10059
11452
  const { updateEvent } = useEventCalendar();
10060
- const [isOver, setIsOver] = React22__namespace.useState(false);
11453
+ const [isOver, setIsOver] = React27__namespace.useState(false);
10061
11454
  const handleDragOver = (e) => {
10062
11455
  e.preventDefault();
10063
11456
  e.dataTransfer.dropEffect = "move";
@@ -10095,23 +11488,23 @@ function DroppableZone({
10095
11488
  function useDroppable({ date, hour, minute = 0, onDrop }) {
10096
11489
  const { draggedEvent, setDraggedEvent } = useDrag();
10097
11490
  const { updateEvent } = useEventCalendar();
10098
- const [isOver, setIsOver] = React22__namespace.useState(false);
10099
- const dropTargetDate = React22__namespace.useMemo(() => {
11491
+ const [isOver, setIsOver] = React27__namespace.useState(false);
11492
+ const dropTargetDate = React27__namespace.useMemo(() => {
10100
11493
  const targetDate = new Date(date);
10101
11494
  if (hour !== void 0) {
10102
11495
  targetDate.setHours(hour, minute, 0, 0);
10103
11496
  }
10104
11497
  return targetDate;
10105
11498
  }, [date, hour, minute]);
10106
- const handleDragOver = React22__namespace.useCallback((e) => {
11499
+ const handleDragOver = React27__namespace.useCallback((e) => {
10107
11500
  e.preventDefault();
10108
11501
  e.dataTransfer.dropEffect = "move";
10109
11502
  if (!isOver) setIsOver(true);
10110
11503
  }, [isOver]);
10111
- const handleDragLeave = React22__namespace.useCallback(() => {
11504
+ const handleDragLeave = React27__namespace.useCallback(() => {
10112
11505
  setIsOver(false);
10113
11506
  }, []);
10114
- const handleDrop = React22__namespace.useCallback((e) => {
11507
+ const handleDrop = React27__namespace.useCallback((e) => {
10115
11508
  e.preventDefault();
10116
11509
  setIsOver(false);
10117
11510
  if (!draggedEvent) return;
@@ -10138,13 +11531,13 @@ function useDroppable({ date, hour, minute = 0, onDrop }) {
10138
11531
  function useDraggable(event, disabled = false) {
10139
11532
  const { setDraggedEvent, draggedEvent } = useDrag();
10140
11533
  const isDragged = draggedEvent?.id === event.id;
10141
- const handleDragStart = React22__namespace.useCallback((e) => {
11534
+ const handleDragStart = React27__namespace.useCallback((e) => {
10142
11535
  if (disabled) return;
10143
11536
  e.dataTransfer.effectAllowed = "move";
10144
11537
  e.dataTransfer.setData("text/plain", event.id);
10145
11538
  setDraggedEvent(event);
10146
11539
  }, [disabled, event, setDraggedEvent]);
10147
- const handleDragEnd = React22__namespace.useCallback(() => {
11540
+ const handleDragEnd = React27__namespace.useCallback(() => {
10148
11541
  setDraggedEvent(null);
10149
11542
  }, [setDraggedEvent]);
10150
11543
  return {
@@ -10185,15 +11578,15 @@ function MonthView({
10185
11578
  }) {
10186
11579
  const { selectedDate, badgeVariant, setSelectedDate, setView } = useEventCalendar();
10187
11580
  const filteredEvents = useFilteredEvents();
10188
- const { singleDayEvents, multiDayEvents } = React22__namespace.useMemo(
11581
+ const { singleDayEvents, multiDayEvents } = React27__namespace.useMemo(
10189
11582
  () => splitEventsByDuration(filteredEvents),
10190
11583
  [filteredEvents]
10191
11584
  );
10192
- const cells = React22__namespace.useMemo(
11585
+ const cells = React27__namespace.useMemo(
10193
11586
  () => getCalendarCells(selectedDate),
10194
11587
  [selectedDate]
10195
11588
  );
10196
- const eventPositions = React22__namespace.useMemo(
11589
+ const eventPositions = React27__namespace.useMemo(
10197
11590
  () => calculateMonthEventPositions(multiDayEvents, singleDayEvents, selectedDate),
10198
11591
  [multiDayEvents, singleDayEvents, selectedDate]
10199
11592
  );
@@ -10375,7 +11768,7 @@ function WeekView({
10375
11768
  visibleHours
10376
11769
  } = useEventCalendar();
10377
11770
  const filteredEvents = useFilteredEvents();
10378
- const { singleDayEvents, multiDayEvents } = React22__namespace.useMemo(
11771
+ const { singleDayEvents, multiDayEvents } = React27__namespace.useMemo(
10379
11772
  () => splitEventsByDuration(filteredEvents),
10380
11773
  [filteredEvents]
10381
11774
  );
@@ -10581,8 +11974,8 @@ function CalendarTimeline({
10581
11974
  firstVisibleHour,
10582
11975
  lastVisibleHour
10583
11976
  }) {
10584
- const [currentTime, setCurrentTime] = React22__namespace.useState(/* @__PURE__ */ new Date());
10585
- React22__namespace.useEffect(() => {
11977
+ const [currentTime, setCurrentTime] = React27__namespace.useState(/* @__PURE__ */ new Date());
11978
+ React27__namespace.useEffect(() => {
10586
11979
  const interval = setInterval(() => {
10587
11980
  setCurrentTime(/* @__PURE__ */ new Date());
10588
11981
  }, 6e4);
@@ -10665,7 +12058,7 @@ function DayView({
10665
12058
  visibleHours
10666
12059
  } = useEventCalendar();
10667
12060
  const filteredEvents = useFilteredEvents();
10668
- const { singleDayEvents, multiDayEvents } = React22__namespace.useMemo(
12061
+ const { singleDayEvents, multiDayEvents } = React27__namespace.useMemo(
10669
12062
  () => splitEventsByDuration(filteredEvents),
10670
12063
  [filteredEvents]
10671
12064
  );
@@ -10673,7 +12066,7 @@ function DayView({
10673
12066
  visibleHours,
10674
12067
  singleDayEvents
10675
12068
  );
10676
- const currentEvents = React22__namespace.useMemo(() => {
12069
+ const currentEvents = React27__namespace.useMemo(() => {
10677
12070
  if (!dateFns.isToday(selectedDate)) return [];
10678
12071
  return getCurrentEvents(singleDayEvents);
10679
12072
  }, [singleDayEvents, selectedDate]);
@@ -10897,8 +12290,8 @@ function CalendarTimeline2({
10897
12290
  firstVisibleHour,
10898
12291
  lastVisibleHour
10899
12292
  }) {
10900
- const [currentTime, setCurrentTime] = React22__namespace.useState(/* @__PURE__ */ new Date());
10901
- React22__namespace.useEffect(() => {
12293
+ const [currentTime, setCurrentTime] = React27__namespace.useState(/* @__PURE__ */ new Date());
12294
+ React27__namespace.useEffect(() => {
10902
12295
  const interval = setInterval(() => {
10903
12296
  setCurrentTime(/* @__PURE__ */ new Date());
10904
12297
  }, 6e4);
@@ -10932,7 +12325,7 @@ function YearView({
10932
12325
  }) {
10933
12326
  const { selectedDate, setSelectedDate, setView } = useEventCalendar();
10934
12327
  const filteredEvents = useFilteredEvents();
10935
- const months = React22__namespace.useMemo(() => {
12328
+ const months = React27__namespace.useMemo(() => {
10936
12329
  const yearStart = dateFns.startOfYear(selectedDate);
10937
12330
  return Array.from({ length: 12 }, (_, i) => dateFns.addMonths(yearStart, i));
10938
12331
  }, [selectedDate]);
@@ -11055,11 +12448,11 @@ function AgendaView({
11055
12448
  }) {
11056
12449
  const { selectedDate, setSelectedDate, setView } = useEventCalendar();
11057
12450
  const filteredEvents = useFilteredEvents();
11058
- const { singleDayEvents, multiDayEvents } = React22__namespace.useMemo(
12451
+ const { singleDayEvents, multiDayEvents } = React27__namespace.useMemo(
11059
12452
  () => splitEventsByDuration(filteredEvents),
11060
12453
  [filteredEvents]
11061
12454
  );
11062
- const eventsByDay = React22__namespace.useMemo(() => {
12455
+ const eventsByDay = React27__namespace.useMemo(() => {
11063
12456
  const allDates = /* @__PURE__ */ new Map();
11064
12457
  singleDayEvents.forEach((event) => {
11065
12458
  const eventDate = dateFns.parseISO(event.startDate);
@@ -11524,16 +12917,16 @@ function EventDialog({
11524
12917
  defaultUserId
11525
12918
  }) {
11526
12919
  const { addEvent, updateEvent, deleteEvent, users } = useEventCalendar();
11527
- const [title, setTitle] = React22__namespace.useState("");
11528
- const [description, setDescription] = React22__namespace.useState("");
11529
- const [startDate, setStartDate] = React22__namespace.useState("");
11530
- const [startTime, setStartTime] = React22__namespace.useState("");
11531
- const [endDate, setEndDate] = React22__namespace.useState("");
11532
- const [endTime, setEndTime] = React22__namespace.useState("");
11533
- const [color, setColor] = React22__namespace.useState("blue");
11534
- const [userId, setUserId] = React22__namespace.useState("");
11535
- const [isSubmitting, setIsSubmitting] = React22__namespace.useState(false);
11536
- React22__namespace.useEffect(() => {
12920
+ const [title, setTitle] = React27__namespace.useState("");
12921
+ const [description, setDescription] = React27__namespace.useState("");
12922
+ const [startDate, setStartDate] = React27__namespace.useState("");
12923
+ const [startTime, setStartTime] = React27__namespace.useState("");
12924
+ const [endDate, setEndDate] = React27__namespace.useState("");
12925
+ const [endTime, setEndTime] = React27__namespace.useState("");
12926
+ const [color, setColor] = React27__namespace.useState("blue");
12927
+ const [userId, setUserId] = React27__namespace.useState("");
12928
+ const [isSubmitting, setIsSubmitting] = React27__namespace.useState(false);
12929
+ React27__namespace.useEffect(() => {
11537
12930
  if (open) {
11538
12931
  if (mode === "edit" && event) {
11539
12932
  const start = dateFns.parseISO(event.startDate);
@@ -11756,7 +13149,7 @@ function QuickAddEvent({
11756
13149
  onOpenDialog,
11757
13150
  onClose
11758
13151
  }) {
11759
- const [title, setTitle] = React22__namespace.useState("");
13152
+ const [title, setTitle] = React27__namespace.useState("");
11760
13153
  const { users } = useEventCalendar();
11761
13154
  const handleSubmit = (e) => {
11762
13155
  e.preventDefault();
@@ -11823,8 +13216,8 @@ var HOUR_OPTIONS = Array.from({ length: 25 }, (_, i) => {
11823
13216
  });
11824
13217
  function ChangeVisibleHoursInput() {
11825
13218
  const { visibleHours, setVisibleHours } = useEventCalendar();
11826
- const [from, setFrom] = React22__namespace.useState(visibleHours.from);
11827
- const [to, setTo] = React22__namespace.useState(visibleHours.to);
13219
+ const [from, setFrom] = React27__namespace.useState(visibleHours.from);
13220
+ const [to, setTo] = React27__namespace.useState(visibleHours.to);
11828
13221
  const handleApply = () => {
11829
13222
  const toHour = to === 0 ? 24 : to;
11830
13223
  setVisibleHours({ from, to: toHour });
@@ -11870,7 +13263,7 @@ var HOUR_OPTIONS2 = Array.from({ length: 25 }, (_, i) => {
11870
13263
  });
11871
13264
  function ChangeWorkingHoursInput() {
11872
13265
  const { workingHours, setWorkingHours } = useEventCalendar();
11873
- const [localWorkingHours, setLocalWorkingHours] = React22__namespace.useState({
13266
+ const [localWorkingHours, setLocalWorkingHours] = React27__namespace.useState({
11874
13267
  ...workingHours
11875
13268
  });
11876
13269
  const handleToggleDay = (dayId) => {
@@ -12019,8 +13412,8 @@ function CalendarSettingsButton({
12019
13412
  );
12020
13413
  }
12021
13414
  function useMediaQuery(query) {
12022
- const [matches, setMatches] = React22__namespace.useState(false);
12023
- React22__namespace.useEffect(() => {
13415
+ const [matches, setMatches] = React27__namespace.useState(false);
13416
+ React27__namespace.useEffect(() => {
12024
13417
  const media = window.matchMedia(query);
12025
13418
  setMatches(media.matches);
12026
13419
  const listener = (event) => {
@@ -12072,11 +13465,11 @@ function BigCalendarInner({
12072
13465
  maxEventsPerDay
12073
13466
  }) {
12074
13467
  const { view, setView } = useEventCalendar();
12075
- const [dialogOpen, setDialogOpen] = React22__namespace.useState(false);
12076
- const [settingsDialogOpen, setSettingsDialogOpen] = React22__namespace.useState(false);
12077
- const [selectedEvent, setSelectedEvent] = React22__namespace.useState(null);
12078
- const [dialogMode, setDialogMode] = React22__namespace.useState("add");
12079
- const [defaultDate, setDefaultDate] = React22__namespace.useState(/* @__PURE__ */ new Date());
13468
+ const [dialogOpen, setDialogOpen] = React27__namespace.useState(false);
13469
+ const [settingsDialogOpen, setSettingsDialogOpen] = React27__namespace.useState(false);
13470
+ const [selectedEvent, setSelectedEvent] = React27__namespace.useState(null);
13471
+ const [dialogMode, setDialogMode] = React27__namespace.useState("add");
13472
+ const [defaultDate, setDefaultDate] = React27__namespace.useState(/* @__PURE__ */ new Date());
12080
13473
  const isMobile = useMediaQuery("(max-width: 768px)");
12081
13474
  const isCompact = compact === "auto" ? isMobile : compact;
12082
13475
  const handleAddClick = () => {
@@ -12394,6 +13787,9 @@ exports.DataTablePagination = DataTablePagination;
12394
13787
  exports.DataTableViewOptions = DataTableViewOptions;
12395
13788
  exports.DateBadge = DateBadge;
12396
13789
  exports.DayView = DayView;
13790
+ exports.DeliveryBadge = DeliveryBadge;
13791
+ exports.DeliveryCard = DeliveryCard;
13792
+ exports.DeliveryDetailPage = DeliveryDetailPage;
12397
13793
  exports.DeliveryIndicator = DeliveryIndicator;
12398
13794
  exports.DeliveryIndicators = DeliveryIndicators;
12399
13795
  exports.Dialog = Dialog;
@@ -12485,6 +13881,12 @@ exports.ItemTitle = ItemTitle;
12485
13881
  exports.Kbd = Kbd;
12486
13882
  exports.KbdGroup = KbdGroup;
12487
13883
  exports.Label = Label2;
13884
+ exports.Map = Map2;
13885
+ exports.MapMarker = MapMarker;
13886
+ exports.MapPopup = MapPopup;
13887
+ exports.MapTileLayer = MapTileLayer;
13888
+ exports.MapTooltip = MapTooltip;
13889
+ exports.MapZoomControl = MapZoomControl;
12488
13890
  exports.Menubar = Menubar;
12489
13891
  exports.MenubarCheckboxItem = MenubarCheckboxItem;
12490
13892
  exports.MenubarContent = MenubarContent;
@@ -12610,6 +14012,7 @@ exports.Slider = Slider;
12610
14012
  exports.Spinner = Spinner;
12611
14013
  exports.SubmitCalibrationBar = SubmitCalibrationBar;
12612
14014
  exports.SupplierCell = SupplierCell;
14015
+ exports.SupplierWeeklyLoading = SupplierWeeklyLoading;
12613
14016
  exports.Switch = Switch;
12614
14017
  exports.Table = Table;
12615
14018
  exports.TableBody = TableBody;
@@ -12644,6 +14047,7 @@ exports.WeekCell = WeekCell;
12644
14047
  exports.WeekDetailDialog = WeekDetailDialog;
12645
14048
  exports.WeekHeader = WeekHeader;
12646
14049
  exports.WeekView = WeekView;
14050
+ exports.WeeklyLoadingView = WeeklyLoadingView;
12647
14051
  exports.YearView = YearView;
12648
14052
  exports.badgeVariants = badgeVariants;
12649
14053
  exports.buttonGroupVariants = buttonGroupVariants;
@@ -12655,12 +14059,14 @@ exports.canSubmitCalibration = canSubmitCalibration;
12655
14059
  exports.cardVariants = cardVariants;
12656
14060
  exports.createDefaultEvent = createDefaultEvent;
12657
14061
  exports.deliveryIndicatorVariants = deliveryIndicatorVariants;
14062
+ exports.extractPrefixes = extractPrefixes;
12658
14063
  exports.formatCalibrationUnit = formatCalibrationUnit;
12659
14064
  exports.formatDateRange = formatDateRange2;
12660
14065
  exports.formatProductionUnit = formatProductionUnit;
12661
14066
  exports.formatTime = formatTime;
12662
14067
  exports.generateColumns = generateColumns;
12663
14068
  exports.generateEventId = generateEventId;
14069
+ exports.generateLoadingWeek = generateLoadingWeek;
12664
14070
  exports.generateLocationOptions = generateLocationOptions;
12665
14071
  exports.generateWeekColumns = generateWeekColumns;
12666
14072
  exports.generateWeeks = generateWeeks;
@@ -12668,6 +14074,8 @@ exports.getCalendarCells = getCalendarCells;
12668
14074
  exports.getCommentLocationLabel = getCommentLocationLabel;
12669
14075
  exports.getCurrentEvents = getCurrentEvents;
12670
14076
  exports.getDayHours = getDayHours;
14077
+ exports.getDayLabel = getDayLabel;
14078
+ exports.getDeliveryVisualState = getDeliveryVisualState;
12671
14079
  exports.getElementShipmentStatus = getElementShipmentStatus;
12672
14080
  exports.getEventBlockStyle = getEventBlockStyle;
12673
14081
  exports.getEventDuration = getEventDuration;
@@ -12677,9 +14085,14 @@ exports.getEventsForDate = getEventsForDate;
12677
14085
  exports.getEventsInRange = getEventsInRange;
12678
14086
  exports.getHeaderLabel = getHeaderLabel;
12679
14087
  exports.getISOWeek = getISOWeek;
14088
+ exports.getLoadingDeliveryStatusLabel = getLoadingDeliveryStatusLabel;
14089
+ exports.getLoadingElementStatusLabel = getLoadingElementStatusLabel;
14090
+ exports.getLoadingISOWeek = getLoadingISOWeek;
14091
+ exports.getLoadingWeekKey = getLoadingWeekKey;
12680
14092
  exports.getMonthCellEvents = getMonthCellEvents;
12681
14093
  exports.getMonthDays = getMonthDays;
12682
14094
  exports.getShipmentStatusLabel = getShipmentStatusLabel;
14095
+ exports.getShortDayLabel = getShortDayLabel;
12683
14096
  exports.getSupplierColumn = getSupplierColumn;
12684
14097
  exports.getTimeHeight = getTimeHeight;
12685
14098
  exports.getTimePosition = getTimePosition;
@@ -12689,6 +14102,8 @@ exports.getWeekDayNames = getWeekDayNames;
12689
14102
  exports.getWeekDays = getWeekDays;
12690
14103
  exports.getWeekKey = getWeekKey;
12691
14104
  exports.getYearMonths = getYearMonths;
14105
+ exports.groupDeliveriesByDay = groupDeliveriesByDay;
14106
+ exports.groupDeliveriesByPrefixAndDay = groupDeliveriesByPrefixAndDay;
12692
14107
  exports.groupEvents = groupEvents;
12693
14108
  exports.isMultiDayEvent = isMultiDayEvent;
12694
14109
  exports.isWorkingHour = isWorkingHour;