@ixo/editor 1.19.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,53 @@
1
+ // src/mantine/hooks/usePanel.ts
2
+ import { useCallback, useMemo, useEffect, useRef } from "react";
3
+ import { create } from "zustand";
4
+ var usePanelStore = create((set) => ({
5
+ activePanel: null,
6
+ registeredPanels: /* @__PURE__ */ new Map(),
7
+ setActivePanel: (panelId) => set({ activePanel: panelId }),
8
+ closePanel: () => set({ activePanel: null }),
9
+ registerPanel: (id, content) => set((state) => {
10
+ const newPanels = new Map(state.registeredPanels);
11
+ newPanels.set(id, content);
12
+ return { registeredPanels: newPanels };
13
+ }),
14
+ unregisterPanel: (id) => set((state) => {
15
+ const newPanels = new Map(state.registeredPanels);
16
+ newPanels.delete(id);
17
+ return { registeredPanels: newPanels };
18
+ })
19
+ }));
20
+ var usePanel = (panelId, content) => {
21
+ const activePanel = usePanelStore((state) => state.activePanel);
22
+ const setActivePanel = usePanelStore((state) => state.setActivePanel);
23
+ const closePanel = usePanelStore((state) => state.closePanel);
24
+ const isOpen = useMemo(() => activePanel === panelId, [activePanel, panelId]);
25
+ const contentRef = useRef(content);
26
+ useEffect(() => {
27
+ contentRef.current = content;
28
+ });
29
+ useEffect(() => {
30
+ const { registerPanel, unregisterPanel } = usePanelStore.getState();
31
+ registerPanel(panelId, contentRef.current);
32
+ return () => {
33
+ unregisterPanel(panelId);
34
+ };
35
+ }, [panelId]);
36
+ useEffect(() => {
37
+ const { registerPanel } = usePanelStore.getState();
38
+ registerPanel(panelId, content);
39
+ }, [content, panelId]);
40
+ const open = useCallback(() => {
41
+ setActivePanel(panelId);
42
+ }, [panelId, setActivePanel]);
43
+ const close = useCallback(() => {
44
+ closePanel();
45
+ }, [closePanel]);
46
+ return { opened: isOpen, open, close };
47
+ };
48
+
1
49
  // src/mantine/context/BlocknoteContext.tsx
2
- import React, { createContext, useContext, useState, useCallback, useRef, useEffect } from "react";
50
+ import React, { createContext, useContext, useState, useCallback as useCallback2, useRef as useRef2, useEffect as useEffect2 } from "react";
3
51
  var BlocknoteContext = createContext({
4
52
  docType: "flow",
5
53
  sharedProposals: {},
@@ -21,53 +69,14 @@ var BlocknoteContext = createContext({
21
69
  });
22
70
  var BlocknoteProvider = ({ children, editor, handlers, blockRequirements, editable }) => {
23
71
  const [sharedProposals, setSharedProposals] = useState({});
24
- const sharedProposalsRef = useRef({});
72
+ const sharedProposalsRef = useRef2({});
25
73
  const [activeDrawerId, setActiveDrawerId] = useState(null);
26
74
  const [drawerContent, setDrawerContent] = useState(null);
27
- const initialDocType = editor?.getDocType?.() || "flow";
28
- console.log("[BlocknoteContext] Initial docType from editor:", initialDocType);
29
- const [docType, setDocType] = useState(initialDocType);
30
- useEffect(() => {
31
- console.log("[BlocknoteContext] docType state updated to:", docType);
32
- }, [docType]);
33
- useEffect(() => {
34
- if (!editor?._yRoot) {
35
- console.log("[BlocknoteContext] No editor._yRoot, skipping observer setup");
36
- return;
37
- }
38
- const updateDocType = () => {
39
- const authoritativeDocType = editor._authoritativeDocType;
40
- if (authoritativeDocType) {
41
- console.log("[BlocknoteContext] Using authoritative local docType:", authoritativeDocType);
42
- if (authoritativeDocType !== docType) {
43
- console.log("[BlocknoteContext] Setting docType to authoritative value:", authoritativeDocType);
44
- setDocType(authoritativeDocType);
45
- }
46
- return;
47
- }
48
- const newDocType = editor.getDocType?.() || "flow";
49
- console.log("[BlocknoteContext] updateDocType() called, newDocType from YMap:", newDocType, "current docType:", docType);
50
- if (newDocType !== docType) {
51
- console.log("[BlocknoteContext] docType changed from", docType, "to", newDocType, "(remote or initial change)");
52
- setDocType(newDocType);
53
- }
54
- };
55
- console.log("[BlocknoteContext] Setting up observer, calling updateDocType() initially");
56
- updateDocType();
57
- const observer = () => {
58
- console.log("[BlocknoteContext] YMap observer triggered, calling updateDocType()");
59
- updateDocType();
60
- };
61
- editor._yRoot?.observe(observer);
62
- return () => {
63
- console.log("[BlocknoteContext] Unobserving YMap");
64
- editor._yRoot?.unobserve(observer);
65
- };
66
- }, [editor, docType]);
67
- useEffect(() => {
75
+ const docType = editor?.docType || "flow";
76
+ useEffect2(() => {
68
77
  sharedProposalsRef.current = sharedProposals;
69
78
  }, [sharedProposals]);
70
- const fetchSharedProposal = useCallback(
79
+ const fetchSharedProposal = useCallback2(
71
80
  async (proposalId, contractAddress, force = false) => {
72
81
  const cacheKey = `${contractAddress}:${proposalId}`;
73
82
  const cached = sharedProposalsRef.current[cacheKey];
@@ -106,7 +115,7 @@ var BlocknoteProvider = ({ children, editor, handlers, blockRequirements, editab
106
115
  },
107
116
  [handlers]
108
117
  );
109
- const invalidateProposal = useCallback((proposalId) => {
118
+ const invalidateProposal = useCallback2((proposalId) => {
110
119
  setSharedProposals((prev) => {
111
120
  const updated = { ...prev };
112
121
  Object.keys(updated).forEach((key) => {
@@ -121,17 +130,17 @@ var BlocknoteProvider = ({ children, editor, handlers, blockRequirements, editab
121
130
  return updated;
122
131
  });
123
132
  }, []);
124
- const subscribeToProposal = useCallback(
133
+ const subscribeToProposal = useCallback2(
125
134
  (cacheKey) => {
126
135
  return sharedProposals[cacheKey]?.proposal;
127
136
  },
128
137
  [sharedProposals]
129
138
  );
130
- const openDrawer = useCallback((id, content) => {
139
+ const openDrawer = useCallback2((id, content) => {
131
140
  setActiveDrawerId(id);
132
141
  setDrawerContent(content);
133
142
  }, []);
134
- const closeDrawer = useCallback(() => {
143
+ const closeDrawer = useCallback2(() => {
135
144
  setActiveDrawerId(null);
136
145
  setDrawerContent(null);
137
146
  }, []);
@@ -191,7 +200,7 @@ import React6 from "react";
191
200
  import { Tabs } from "@mantine/core";
192
201
 
193
202
  // src/mantine/components/ConditionsTab.tsx
194
- import React5, { useCallback as useCallback5 } from "react";
203
+ import React5, { useCallback as useCallback6 } from "react";
195
204
  import { Stack as Stack4, SegmentedControl as SegmentedControl2, Button as Button3, Text as Text2, Alert as Alert2 } from "@mantine/core";
196
205
 
197
206
  // src/mantine/blocks/utils/conditionUtils.ts
@@ -268,11 +277,11 @@ function hasEnableConditions(conditionConfig) {
268
277
  }
269
278
 
270
279
  // src/mantine/blocks/components/ConditionBuilder/ConditionBuilderTab.tsx
271
- import React4, { useCallback as useCallback4 } from "react";
280
+ import React4, { useCallback as useCallback5 } from "react";
272
281
  import { Stack as Stack3, SegmentedControl, Button as Button2, Text, Alert } from "@mantine/core";
273
282
 
274
283
  // src/mantine/blocks/components/ConditionBuilder/ConditionRow.tsx
275
- import React3, { useCallback as useCallback3, useMemo } from "react";
284
+ import React3, { useCallback as useCallback4, useMemo as useMemo2 } from "react";
276
285
  import { Card, Stack as Stack2, TextInput as TextInput2, Select as Select2, Group, Button } from "@mantine/core";
277
286
 
278
287
  // src/mantine/blocks/apiRequest/types.ts
@@ -524,28 +533,28 @@ function getPropertyByName(blockType, propertyName) {
524
533
  }
525
534
 
526
535
  // src/mantine/blocks/components/ConditionBuilder/PropertyValueInput.tsx
527
- import React2, { useCallback as useCallback2 } from "react";
536
+ import React2, { useCallback as useCallback3 } from "react";
528
537
  import { TextInput, NumberInput, Switch, Select, Stack } from "@mantine/core";
529
538
  function PropertyValueInput({ property, value, onChange, disabled = false }) {
530
- const handleStringChange = useCallback2(
539
+ const handleStringChange = useCallback3(
531
540
  (event) => {
532
541
  onChange(event.currentTarget.value);
533
542
  },
534
543
  [onChange]
535
544
  );
536
- const handleNumberChange = useCallback2(
545
+ const handleNumberChange = useCallback3(
537
546
  (val) => {
538
547
  onChange(typeof val === "number" ? val : parseFloat(val) || 0);
539
548
  },
540
549
  [onChange]
541
550
  );
542
- const handleBooleanChange = useCallback2(
551
+ const handleBooleanChange = useCallback3(
543
552
  (event) => {
544
553
  onChange(event.currentTarget.checked);
545
554
  },
546
555
  [onChange]
547
556
  );
548
- const handleSelectChange = useCallback2(
557
+ const handleSelectChange = useCallback3(
549
558
  (val) => {
550
559
  if (val === null) return;
551
560
  if (val === "true") onChange(true);
@@ -580,15 +589,15 @@ function PropertyValueInput({ property, value, onChange, disabled = false }) {
580
589
 
581
590
  // src/mantine/blocks/components/ConditionBuilder/ConditionRow.tsx
582
591
  function ConditionRow({ condition, availableBlocks, onUpdate, onDelete }) {
583
- const availableProperties = useMemo(() => {
592
+ const availableProperties = useMemo2(() => {
584
593
  if (!condition.sourceBlockType) return [];
585
594
  return getConditionableProperties(condition.sourceBlockType);
586
595
  }, [condition.sourceBlockType]);
587
- const selectedProperty = useMemo(() => {
596
+ const selectedProperty = useMemo2(() => {
588
597
  if (!condition.sourceBlockType || !condition.rule.property) return null;
589
598
  return getPropertyByName(condition.sourceBlockType, condition.rule.property);
590
599
  }, [condition.sourceBlockType, condition.rule.property]);
591
- const availableOperators = useMemo(() => {
600
+ const availableOperators = useMemo2(() => {
592
601
  if (!selectedProperty) return [];
593
602
  const baseOperators = [
594
603
  { value: "equals", label: "equals" },
@@ -607,13 +616,13 @@ function ConditionRow({ condition, availableBlocks, onUpdate, onDelete }) {
607
616
  }
608
617
  return baseOperators;
609
618
  }, [selectedProperty]);
610
- const handleNameChange = useCallback3(
619
+ const handleNameChange = useCallback4(
611
620
  (name) => {
612
621
  onUpdate({ ...condition, name });
613
622
  },
614
623
  [condition, onUpdate]
615
624
  );
616
- const handleSourceBlockChange = useCallback3(
625
+ const handleSourceBlockChange = useCallback4(
617
626
  (value) => {
618
627
  if (!value) {
619
628
  const updatedCondition2 = {
@@ -636,7 +645,7 @@ function ConditionRow({ condition, availableBlocks, onUpdate, onDelete }) {
636
645
  },
637
646
  [condition, onUpdate]
638
647
  );
639
- const handlePropertyChange = useCallback3(
648
+ const handlePropertyChange = useCallback4(
640
649
  (property) => {
641
650
  if (!property) return;
642
651
  onUpdate({
@@ -651,7 +660,7 @@ function ConditionRow({ condition, availableBlocks, onUpdate, onDelete }) {
651
660
  },
652
661
  [condition, onUpdate]
653
662
  );
654
- const handleOperatorChange = useCallback3(
663
+ const handleOperatorChange = useCallback4(
655
664
  (operator) => {
656
665
  if (!operator) return;
657
666
  onUpdate({
@@ -664,7 +673,7 @@ function ConditionRow({ condition, availableBlocks, onUpdate, onDelete }) {
664
673
  },
665
674
  [condition, onUpdate]
666
675
  );
667
- const handleValueChange = useCallback3(
676
+ const handleValueChange = useCallback4(
668
677
  (value) => {
669
678
  onUpdate({
670
679
  ...condition,
@@ -676,7 +685,7 @@ function ConditionRow({ condition, availableBlocks, onUpdate, onDelete }) {
676
685
  },
677
686
  [condition, onUpdate]
678
687
  );
679
- const handleActionChange = useCallback3(
688
+ const handleActionChange = useCallback4(
680
689
  (action) => {
681
690
  if (!action) return;
682
691
  onUpdate({
@@ -689,7 +698,7 @@ function ConditionRow({ condition, availableBlocks, onUpdate, onDelete }) {
689
698
  },
690
699
  [condition, onUpdate]
691
700
  );
692
- const handleMessageChange = useCallback3(
701
+ const handleMessageChange = useCallback4(
693
702
  (message) => {
694
703
  onUpdate({
695
704
  ...condition,
@@ -749,7 +758,7 @@ function ConditionRow({ condition, availableBlocks, onUpdate, onDelete }) {
749
758
  function ConditionsTab({ block, editor }) {
750
759
  const currentConditions = parseConditionConfig(block.props.conditions);
751
760
  const availableBlocks = getAvailableBlocks(editor?.document || [], block.id);
752
- const updateConditions = useCallback5(
761
+ const updateConditions = useCallback6(
753
762
  (newConfig) => {
754
763
  const conditionsString = stringifyConditionConfig(newConfig);
755
764
  editor.updateBlock(block, {
@@ -761,7 +770,7 @@ function ConditionsTab({ block, editor }) {
761
770
  },
762
771
  [editor, block]
763
772
  );
764
- const handleModeChange = useCallback5(
773
+ const handleModeChange = useCallback6(
765
774
  (mode) => {
766
775
  updateConditions({
767
776
  ...currentConditions,
@@ -770,7 +779,7 @@ function ConditionsTab({ block, editor }) {
770
779
  },
771
780
  [currentConditions, updateConditions]
772
781
  );
773
- const handleAddCondition = useCallback5(() => {
782
+ const handleAddCondition = useCallback6(() => {
774
783
  const newCondition = createDefaultCondition();
775
784
  const newConfig = {
776
785
  ...currentConditions,
@@ -780,7 +789,7 @@ function ConditionsTab({ block, editor }) {
780
789
  };
781
790
  updateConditions(newConfig);
782
791
  }, [currentConditions, updateConditions]);
783
- const handleUpdateCondition = useCallback5(
792
+ const handleUpdateCondition = useCallback6(
784
793
  (index, updatedCondition) => {
785
794
  const newConditions = [...currentConditions.conditions];
786
795
  newConditions[index] = updatedCondition;
@@ -792,7 +801,7 @@ function ConditionsTab({ block, editor }) {
792
801
  },
793
802
  [currentConditions, updateConditions]
794
803
  );
795
- const handleDeleteCondition = useCallback5(
804
+ const handleDeleteCondition = useCallback6(
796
805
  (index) => {
797
806
  const newConditions = currentConditions.conditions.filter((_, i) => i !== index);
798
807
  updateConditions({
@@ -850,7 +859,7 @@ function ReusablePanel({ extraTabs, context }) {
850
859
  }
851
860
 
852
861
  // src/mantine/blocks/checkbox/template/GeneralTab.tsx
853
- import React7, { useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
862
+ import React7, { useEffect as useEffect3, useMemo as useMemo3, useState as useState2 } from "react";
854
863
  import { Divider, SegmentedControl as SegmentedControl3, Stack as Stack5, Switch as Switch2, Text as Text3, TextInput as TextInput3, Textarea, PillsInput, Pill } from "@mantine/core";
855
864
  var GeneralTab = ({
856
865
  title,
@@ -869,19 +878,19 @@ var GeneralTab = ({
869
878
  const [localMode, setLocalMode] = useState2(allowedMode);
870
879
  const [localValues, setLocalValues] = useState2(allowedValues);
871
880
  const [inputValue, setInputValue] = useState2("");
872
- useEffect2(() => {
881
+ useEffect3(() => {
873
882
  setLocalTitle(title || "");
874
883
  }, [title]);
875
- useEffect2(() => {
884
+ useEffect3(() => {
876
885
  setLocalDescription(description || "");
877
886
  }, [description]);
878
- useEffect2(() => {
887
+ useEffect3(() => {
879
888
  setLocalInitialChecked(initialChecked);
880
889
  }, [initialChecked]);
881
- useEffect2(() => {
890
+ useEffect3(() => {
882
891
  setLocalMode(allowedMode);
883
892
  }, [allowedMode]);
884
- useEffect2(() => {
893
+ useEffect3(() => {
885
894
  setLocalValues(allowedValues);
886
895
  }, [allowedValues]);
887
896
  const handleModeChange = (value) => {
@@ -912,7 +921,7 @@ var GeneralTab = ({
912
921
  onAllowedChange(localMode, newValues);
913
922
  }
914
923
  };
915
- const allowedHint = useMemo2(() => {
924
+ const allowedHint = useMemo3(() => {
916
925
  if (localMode === "all") {
917
926
  return "Everyone in the flow can toggle this checkbox.";
918
927
  }
@@ -978,54 +987,6 @@ var GeneralTab = ({
978
987
  ))))));
979
988
  };
980
989
 
981
- // src/mantine/hooks/usePanel.ts
982
- import { useCallback as useCallback6, useMemo as useMemo3, useEffect as useEffect3, useRef as useRef2 } from "react";
983
- import { create } from "zustand";
984
- var usePanelStore = create((set) => ({
985
- activePanel: null,
986
- registeredPanels: /* @__PURE__ */ new Map(),
987
- setActivePanel: (panelId) => set({ activePanel: panelId }),
988
- closePanel: () => set({ activePanel: null }),
989
- registerPanel: (id, content) => set((state) => {
990
- const newPanels = new Map(state.registeredPanels);
991
- newPanels.set(id, content);
992
- return { registeredPanels: newPanels };
993
- }),
994
- unregisterPanel: (id) => set((state) => {
995
- const newPanels = new Map(state.registeredPanels);
996
- newPanels.delete(id);
997
- return { registeredPanels: newPanels };
998
- })
999
- }));
1000
- var usePanel = (panelId, content) => {
1001
- const activePanel = usePanelStore((state) => state.activePanel);
1002
- const setActivePanel = usePanelStore((state) => state.setActivePanel);
1003
- const closePanel = usePanelStore((state) => state.closePanel);
1004
- const isOpen = useMemo3(() => activePanel === panelId, [activePanel, panelId]);
1005
- const contentRef = useRef2(content);
1006
- useEffect3(() => {
1007
- contentRef.current = content;
1008
- });
1009
- useEffect3(() => {
1010
- const { registerPanel, unregisterPanel } = usePanelStore.getState();
1011
- registerPanel(panelId, contentRef.current);
1012
- return () => {
1013
- unregisterPanel(panelId);
1014
- };
1015
- }, [panelId]);
1016
- useEffect3(() => {
1017
- const { registerPanel } = usePanelStore.getState();
1018
- registerPanel(panelId, content);
1019
- }, [content, panelId]);
1020
- const open = useCallback6(() => {
1021
- setActivePanel(panelId);
1022
- }, [panelId, setActivePanel]);
1023
- const close = useCallback6(() => {
1024
- closePanel();
1025
- }, [closePanel]);
1026
- return { opened: isOpen, open, close };
1027
- };
1028
-
1029
990
  // src/mantine/blocks/checkbox/template/TemplateConfig.tsx
1030
991
  var TemplateConfig = ({ editor, block }) => {
1031
992
  const { closePanel } = usePanelStore();
@@ -2237,7 +2198,22 @@ var GeneralTab2 = ({ initialConfig, onSave }) => {
2237
2198
  }
2238
2199
  };
2239
2200
  const typeConfig = selectedType ? getListTypeConfig(selectedType) : null;
2240
- return /* @__PURE__ */ React14.createElement(Stack8, { gap: "lg" }, /* @__PURE__ */ React14.createElement(Accordion, { value: accordionValue, onChange: setAccordionValue }, /* @__PURE__ */ React14.createElement(Accordion.Item, { value: "type" }, /* @__PURE__ */ React14.createElement(Accordion.Control, null, /* @__PURE__ */ React14.createElement(Text6, { fw: 600 }, "Choose List Type")), /* @__PURE__ */ React14.createElement(Accordion.Panel, null, /* @__PURE__ */ React14.createElement(Stack8, { gap: "sm", mt: "md" }, listTypes.map((listType) => /* @__PURE__ */ React14.createElement(
2201
+ return /* @__PURE__ */ React14.createElement(Stack8, { gap: "lg" }, /* @__PURE__ */ React14.createElement(Accordion, { value: accordionValue, onChange: setAccordionValue }, /* @__PURE__ */ React14.createElement(Accordion.Item, { value: "type" }, /* @__PURE__ */ React14.createElement(
2202
+ Accordion.Control,
2203
+ {
2204
+ styles: {
2205
+ control: {
2206
+ "&:hover": {
2207
+ backgroundColor: "var(--mantine-color-dark-7) !important"
2208
+ }
2209
+ },
2210
+ chevron: {
2211
+ color: "var(--mantine-color-dark-1)"
2212
+ }
2213
+ }
2214
+ },
2215
+ /* @__PURE__ */ React14.createElement(Text6, { fw: 600 }, "Choose List Type")
2216
+ ), /* @__PURE__ */ React14.createElement(Accordion.Panel, null, /* @__PURE__ */ React14.createElement(Stack8, { gap: "sm", mt: "md" }, listTypes.map((listType) => /* @__PURE__ */ React14.createElement(
2241
2217
  Card4,
2242
2218
  {
2243
2219
  key: listType.id,
@@ -2248,6 +2224,11 @@ var GeneralTab2 = ({ initialConfig, onSave }) => {
2248
2224
  style: {
2249
2225
  cursor: "pointer"
2250
2226
  },
2227
+ styles: {
2228
+ root: {
2229
+ border: "1px solid var(--mantine-color-gray-8)"
2230
+ }
2231
+ },
2251
2232
  onClick: () => handleTypeSelect(listType.id)
2252
2233
  },
2253
2234
  /* @__PURE__ */ React14.createElement(Group4, { gap: "md", align: "flex-start" }, /* @__PURE__ */ React14.createElement(
@@ -2267,7 +2248,22 @@ var GeneralTab2 = ({ initialConfig, onSave }) => {
2267
2248
  },
2268
2249
  listType.icon
2269
2250
  ), /* @__PURE__ */ React14.createElement(Stack8, { gap: 2, style: { flex: 1 } }, /* @__PURE__ */ React14.createElement(Text6, { size: "md", fw: 600 }, listType.name), /* @__PURE__ */ React14.createElement(Text6, { size: "sm", c: "dimmed" }, listType.description)))
2270
- ))))), selectedType && typeConfig && /* @__PURE__ */ React14.createElement(Accordion.Item, { value: "configure" }, /* @__PURE__ */ React14.createElement(Accordion.Control, null, /* @__PURE__ */ React14.createElement(Text6, { fw: 600 }, "Configure ", typeConfig.metadata.name)), /* @__PURE__ */ React14.createElement(Accordion.Panel, null, /* @__PURE__ */ React14.createElement(Stack8, { gap: "md", mt: "md" }, /* @__PURE__ */ React14.createElement(Text6, { size: "sm", c: "dimmed" }, typeConfig.metadata.description), /* @__PURE__ */ React14.createElement(Stack8, { gap: "sm" }, typeConfig.configFields.map((field) => renderConfigField(field))))))), selectedType && /* @__PURE__ */ React14.createElement(Button4, { onClick: handleSaveConfig, disabled: !isConfigValid(), fullWidth: true }, "Save Configuration"));
2251
+ ))))), selectedType && typeConfig && /* @__PURE__ */ React14.createElement(Accordion.Item, { value: "configure" }, /* @__PURE__ */ React14.createElement(
2252
+ Accordion.Control,
2253
+ {
2254
+ styles: {
2255
+ control: {
2256
+ "&:hover": {
2257
+ backgroundColor: "var(--mantine-color-dark-7)"
2258
+ }
2259
+ },
2260
+ chevron: {
2261
+ color: "var(--mantine-color-dark-1)"
2262
+ }
2263
+ }
2264
+ },
2265
+ /* @__PURE__ */ React14.createElement(Text6, { fw: 600 }, "Configure ", typeConfig.metadata.name)
2266
+ ), /* @__PURE__ */ React14.createElement(Accordion.Panel, null, /* @__PURE__ */ React14.createElement(Stack8, { gap: "md", mt: "md" }, /* @__PURE__ */ React14.createElement(Text6, { size: "sm", c: "dimmed" }, typeConfig.metadata.description), /* @__PURE__ */ React14.createElement(Stack8, { gap: "sm" }, typeConfig.configFields.map((field) => renderConfigField(field))))))), selectedType && /* @__PURE__ */ React14.createElement(Button4, { onClick: handleSaveConfig, disabled: !isConfigValid(), fullWidth: true }, "Save Configuration"));
2271
2267
  };
2272
2268
 
2273
2269
  // src/mantine/blocks/list/template/TemplateConfig.tsx
@@ -2329,6 +2325,7 @@ var TemplateConfig2 = ({ editor, block }) => {
2329
2325
  p: "md",
2330
2326
  shadow: "sm",
2331
2327
  style: {
2328
+ flex: 1,
2332
2329
  display: "flex",
2333
2330
  flexDirection: "column"
2334
2331
  }
@@ -2687,7 +2684,37 @@ var ListActionsMenu = ({ options, selectionMode, onSelectActionClick, value, onC
2687
2684
  opt.label
2688
2685
  );
2689
2686
  };
2690
- return /* @__PURE__ */ React32.createElement(Menu, { shadow: "md", width: 220 }, /* @__PURE__ */ React32.createElement(Menu.Target, null, /* @__PURE__ */ React32.createElement(ActionIcon4, { variant: "subtle", size: "sm", "aria-label": "List actions", title: "List actions" }, /* @__PURE__ */ React32.createElement(IconAdjustmentsHorizontal, { size: 18 }))), /* @__PURE__ */ React32.createElement(Menu.Dropdown, null, /* @__PURE__ */ React32.createElement(Menu.Label, null, /* @__PURE__ */ React32.createElement(Text20, { c: "dimmed" }, "Order By")), options.map((opt) => /* @__PURE__ */ React32.createElement(React32.Fragment, { key: opt.key }, renderItem(opt, "desc"), renderItem(opt, "asc"))), /* @__PURE__ */ React32.createElement(Menu.Divider, null), /* @__PURE__ */ React32.createElement(Menu.Item, { leftSection: /* @__PURE__ */ React32.createElement(IconAdjustments, { size: 16 }) }, "Smart Filter"), /* @__PURE__ */ React32.createElement(Menu.Divider, null), /* @__PURE__ */ React32.createElement(Menu.Item, { onClick: () => onSelectActionClick(selectionMode === "single" ? null : "single"), leftSection: /* @__PURE__ */ React32.createElement(IconCheckbox2, { size: 16 }) }, "Single Select"), /* @__PURE__ */ React32.createElement(Menu.Item, { onClick: () => onSelectActionClick(selectionMode === "multi" ? null : "multi"), leftSection: /* @__PURE__ */ React32.createElement(IconCheckbox2, { size: 16 }) }, "Multi Select"), onDownloadCsv && /* @__PURE__ */ React32.createElement(React32.Fragment, null, /* @__PURE__ */ React32.createElement(Menu.Divider, null), /* @__PURE__ */ React32.createElement(Menu.Item, { onClick: onDownloadCsv, leftSection: /* @__PURE__ */ React32.createElement(IconDownload, { size: 16 }) }, "Download CSV"))));
2687
+ return /* @__PURE__ */ React32.createElement(
2688
+ Menu,
2689
+ {
2690
+ shadow: "md",
2691
+ width: 220,
2692
+ styles: {
2693
+ dropdown: {
2694
+ backgroundColor: "var(--mantine-color-dark-7)",
2695
+ borderColor: "var(--mantine-color-dark-4)"
2696
+ },
2697
+ item: {
2698
+ color: "#fff",
2699
+ backgroundColor: "var(--mantine-color-dark-7)",
2700
+ "&:hover": {
2701
+ backgroundColor: "var(--mantine-color-dark-6)"
2702
+ },
2703
+ '&[data-active="true"]': {
2704
+ backgroundColor: "var(--mantine-color-dark-5)"
2705
+ }
2706
+ },
2707
+ label: {
2708
+ color: "#fff"
2709
+ },
2710
+ divider: {
2711
+ borderColor: "var(--mantine-color-dark-4)"
2712
+ }
2713
+ }
2714
+ },
2715
+ /* @__PURE__ */ React32.createElement(Menu.Target, null, /* @__PURE__ */ React32.createElement(ActionIcon4, { variant: "subtle", size: "sm", "aria-label": "List actions", title: "List actions" }, /* @__PURE__ */ React32.createElement(IconAdjustmentsHorizontal, { size: 18 }))),
2716
+ /* @__PURE__ */ React32.createElement(Menu.Dropdown, null, /* @__PURE__ */ React32.createElement(Menu.Label, null, /* @__PURE__ */ React32.createElement(Text20, null, "Order By")), options.map((opt) => /* @__PURE__ */ React32.createElement(React32.Fragment, { key: opt.key }, renderItem(opt, "desc"), renderItem(opt, "asc"))), /* @__PURE__ */ React32.createElement(Menu.Divider, null), /* @__PURE__ */ React32.createElement(Menu.Item, { leftSection: /* @__PURE__ */ React32.createElement(IconAdjustments, { size: 16 }) }, "Smart Filter"), /* @__PURE__ */ React32.createElement(Menu.Divider, null), /* @__PURE__ */ React32.createElement(Menu.Item, { onClick: () => onSelectActionClick(selectionMode === "single" ? null : "single"), leftSection: /* @__PURE__ */ React32.createElement(IconCheckbox2, { size: 16 }) }, "Single Select"), /* @__PURE__ */ React32.createElement(Menu.Item, { onClick: () => onSelectActionClick(selectionMode === "multi" ? null : "multi"), leftSection: /* @__PURE__ */ React32.createElement(IconCheckbox2, { size: 16 }) }, "Multi Select"), onDownloadCsv && /* @__PURE__ */ React32.createElement(React32.Fragment, null, /* @__PURE__ */ React32.createElement(Menu.Divider, null), /* @__PURE__ */ React32.createElement(Menu.Item, { onClick: onDownloadCsv, leftSection: /* @__PURE__ */ React32.createElement(IconDownload, { size: 16 }) }, "Download CSV")))
2717
+ );
2691
2718
  };
2692
2719
 
2693
2720
  // src/core/lib/sortListItems.ts
@@ -9864,65 +9891,2505 @@ var NotifyBlockSpec = createReactBlockSpec7(
9864
9891
  }
9865
9892
  );
9866
9893
 
9867
- // src/mantine/blocks/list/ui/ListBlocksToolbar.tsx
9868
- import React111 from "react";
9869
- import { ActionIcon as ActionIcon20, Group as Group37, Tooltip as Tooltip8 } from "@mantine/core";
9870
- import { IconChevronUp as IconChevronUp4, IconChevronDown as IconChevronDown4 } from "@tabler/icons-react";
9871
- var ListBlocksToolbar = () => {
9872
- const { broadcastCollapse } = useListBlocksUI();
9873
- return /* @__PURE__ */ React111.createElement(Group37, { gap: "xs" }, /* @__PURE__ */ React111.createElement(Tooltip8, { label: "Collapse all lists", withArrow: true }, /* @__PURE__ */ React111.createElement(ActionIcon20, { c: "dimmed", variant: "subtle", size: "sm", "aria-label": "Collapse all lists", onClick: () => broadcastCollapse("collapse") }, /* @__PURE__ */ React111.createElement(IconChevronUp4, { size: 18 }))), /* @__PURE__ */ React111.createElement(Tooltip8, { label: "Expand all lists", withArrow: true }, /* @__PURE__ */ React111.createElement(ActionIcon20, { c: "dimmed", variant: "subtle", size: "sm", "aria-label": "Expand all lists", onClick: () => broadcastCollapse("expand") }, /* @__PURE__ */ React111.createElement(IconChevronDown4, { size: 18 }))));
9894
+ // src/mantine/blocks/claim/ClaimBlockSpec.tsx
9895
+ import React119 from "react";
9896
+ import { createReactBlockSpec as createReactBlockSpec8 } from "@blocknote/react";
9897
+
9898
+ // src/mantine/blocks/claim/ClaimBlock.tsx
9899
+ import React118 from "react";
9900
+
9901
+ // src/mantine/blocks/claim/template/TemplateView.tsx
9902
+ import React114, { useMemo as useMemo20 } from "react";
9903
+ import { Card as Card24, Group as Group38, Stack as Stack84, Text as Text59, ActionIcon as ActionIcon20, Badge as Badge16 } from "@mantine/core";
9904
+
9905
+ // src/mantine/blocks/claim/template/TemplateConfig.tsx
9906
+ import React113, { useCallback as useCallback21 } from "react";
9907
+ import { Paper as Paper13, CloseButton as CloseButton8, Title as Title9 } from "@mantine/core";
9908
+
9909
+ // src/mantine/blocks/claim/template/GeneralTab.tsx
9910
+ import React112, { useEffect as useEffect20, useState as useState31, useCallback as useCallback20, useMemo as useMemo19 } from "react";
9911
+ import { Stack as Stack83, Text as Text58, TextInput as TextInput39, Textarea as Textarea22 } from "@mantine/core";
9912
+
9913
+ // src/mantine/components/CollectionSelector.tsx
9914
+ import React111, { useState as useState30, useEffect as useEffect19 } from "react";
9915
+ import { Stack as Stack82, Text as Text57, TextInput as TextInput38, Button as Button28, Group as Group37, Checkbox as Checkbox10, Loader as Loader7, Alert as Alert12 } from "@mantine/core";
9916
+ var CollectionSelector = ({
9917
+ did,
9918
+ selectedCollections,
9919
+ onDidChange,
9920
+ onCollectionsChange,
9921
+ onAdminAddressChange,
9922
+ currentAdminAddress
9923
+ }) => {
9924
+ console.log("[CollectionSelector] Rendered with selectedCollections:", selectedCollections);
9925
+ const handlers = useBlocknoteHandlers();
9926
+ const [localDid, setLocalDid] = useState30(did || "");
9927
+ const [collections, setCollections] = useState30([]);
9928
+ const [loading, setLoading] = useState30(false);
9929
+ const [error, setError] = useState30(null);
9930
+ useEffect19(() => {
9931
+ setLocalDid(did || "");
9932
+ }, [did]);
9933
+ const handleDidChange = (value) => {
9934
+ setLocalDid(value);
9935
+ onDidChange(value);
9936
+ };
9937
+ const handleGetCollections = async () => {
9938
+ if (!localDid.trim()) {
9939
+ setError("Please enter a DID first");
9940
+ return;
9941
+ }
9942
+ setLoading(true);
9943
+ setError(null);
9944
+ try {
9945
+ const response = await handlers.getClaimCollections({ deedDid: localDid });
9946
+ const { adminAddress, collections: fetchedCollections } = response || { adminAddress: "", collections: [] };
9947
+ setCollections(fetchedCollections || []);
9948
+ if (onAdminAddressChange && adminAddress && (!currentAdminAddress || currentAdminAddress === "")) {
9949
+ onAdminAddressChange(adminAddress);
9950
+ }
9951
+ if (!fetchedCollections || fetchedCollections.length === 0) {
9952
+ setError("No claim collections found for this DID");
9953
+ }
9954
+ } catch (err) {
9955
+ console.error("Error fetching claim collections:", err);
9956
+ setError(err instanceof Error ? err.message : "Failed to fetch claim collections");
9957
+ setCollections([]);
9958
+ } finally {
9959
+ setLoading(false);
9960
+ }
9961
+ };
9962
+ const handleToggleCollection = (collectionId) => {
9963
+ if (!collectionId) return;
9964
+ console.log("[CollectionSelector] Toggle collection:", collectionId);
9965
+ console.log("[CollectionSelector] Current selectedCollections:", selectedCollections);
9966
+ const currentSelections = selectedCollections || [];
9967
+ const newSelected = currentSelections.includes(collectionId) ? currentSelections.filter((id) => id !== collectionId) : [...currentSelections, collectionId];
9968
+ console.log("[CollectionSelector] New selectedCollections:", newSelected);
9969
+ onCollectionsChange(newSelected);
9970
+ };
9971
+ const getCollectionName = (collection) => {
9972
+ if (!collection) return "Unnamed Collection";
9973
+ return collection.protocol?.profile?.name || collection.name || "Unnamed Collection";
9974
+ };
9975
+ return /* @__PURE__ */ React111.createElement(Stack82, { gap: "lg" }, /* @__PURE__ */ React111.createElement(Stack82, { gap: "xs" }, /* @__PURE__ */ React111.createElement(Text57, { size: "sm", fw: 600 }, "DID"), /* @__PURE__ */ React111.createElement(Group37, { gap: "xs", align: "flex-start", wrap: "nowrap" }, /* @__PURE__ */ React111.createElement(
9976
+ TextInput38,
9977
+ {
9978
+ placeholder: "Enter DID",
9979
+ value: localDid,
9980
+ onChange: (event) => handleDidChange(event.currentTarget.value),
9981
+ description: "The DID identifier for fetching claim collections",
9982
+ style: { flex: 1 }
9983
+ }
9984
+ ), /* @__PURE__ */ React111.createElement(Button28, { onClick: handleGetCollections, disabled: !localDid.trim() || loading, style: { marginTop: "1px" } }, loading ? /* @__PURE__ */ React111.createElement(Loader7, { size: "xs", color: "white" }) : "Get Collections"))), error && /* @__PURE__ */ React111.createElement(Alert12, { color: "red", title: "Error" }, error), collections && collections.length > 0 && /* @__PURE__ */ React111.createElement(Stack82, { gap: "xs" }, /* @__PURE__ */ React111.createElement(Text57, { size: "sm", fw: 600 }, "Claim Collections"), /* @__PURE__ */ React111.createElement(Stack82, { gap: "sm" }, collections.map((collection) => {
9985
+ if (!collection || !collection.id) return null;
9986
+ return /* @__PURE__ */ React111.createElement(
9987
+ Checkbox10,
9988
+ {
9989
+ key: collection.id,
9990
+ label: /* @__PURE__ */ React111.createElement(Stack82, { gap: 2 }, /* @__PURE__ */ React111.createElement(Text57, { size: "sm", fw: 500 }, getCollectionName(collection)), /* @__PURE__ */ React111.createElement(Text57, { size: "xs", c: "dimmed", style: { fontFamily: "monospace" } }, "ID: ", collection.id), collection.description && /* @__PURE__ */ React111.createElement(Text57, { size: "xs", c: "dimmed" }, collection.description)),
9991
+ checked: selectedCollections?.includes(collection.id) ?? false,
9992
+ onChange: () => handleToggleCollection(collection.id)
9993
+ }
9994
+ );
9995
+ }))), selectedCollections && selectedCollections.length > 0 && /* @__PURE__ */ React111.createElement(Stack82, { gap: "xs" }, /* @__PURE__ */ React111.createElement(Text57, { size: "sm", c: "dimmed" }, selectedCollections.length, " collection", selectedCollections.length !== 1 ? "s" : "", " selected")));
9874
9996
  };
9875
9997
 
9876
- // src/mantine/blocks/registry/blockRegistry.ts
9877
- var BlockRegistry = class {
9878
- constructor() {
9879
- this.blocks = /* @__PURE__ */ new Map();
9880
- }
9881
- register(entry) {
9882
- this.blocks.set(entry.type, entry);
9883
- }
9884
- get(type) {
9885
- return this.blocks.get(type);
9886
- }
9887
- getAll() {
9888
- return new Map(this.blocks);
9889
- }
9890
- getValidDependencies(type) {
9891
- const entry = this.get(type);
9892
- return entry?.validDependencies || [];
9893
- }
9894
- getPropSchema(type) {
9895
- const entry = this.get(type);
9896
- return entry?.propSchema;
9897
- }
9898
- isValidDependency(blockType, dependencyType) {
9899
- const validDeps = this.getValidDependencies(blockType);
9900
- return validDeps.includes(dependencyType);
9901
- }
9998
+ // src/mantine/blocks/claim/template/GeneralTab.tsx
9999
+ var GeneralTab6 = ({
10000
+ title,
10001
+ description,
10002
+ deedDid,
10003
+ selectedCollections,
10004
+ adminAddress,
10005
+ onTitleChange,
10006
+ onDescriptionChange,
10007
+ onDeedDidChange,
10008
+ onSelectedCollectionsChange,
10009
+ onAdminAddressChange
10010
+ }) => {
10011
+ const [localTitle, setLocalTitle] = useState31(title || "");
10012
+ const [localDescription, setLocalDescription] = useState31(description || "");
10013
+ useEffect20(() => {
10014
+ setLocalTitle(title || "");
10015
+ }, [title]);
10016
+ useEffect20(() => {
10017
+ setLocalDescription(description || "");
10018
+ }, [description]);
10019
+ const parsedSelectedCollections = useMemo19(() => {
10020
+ try {
10021
+ return JSON.parse(selectedCollections || "[]");
10022
+ } catch {
10023
+ return [];
10024
+ }
10025
+ }, [selectedCollections]);
10026
+ const handleCollectionsChange = useCallback20(
10027
+ (collections) => {
10028
+ console.log("[Claim GeneralTab] handleCollectionsChange called with:", collections);
10029
+ const stringified = JSON.stringify(collections || []);
10030
+ console.log("[Claim GeneralTab] Stringified:", stringified);
10031
+ onSelectedCollectionsChange(stringified);
10032
+ },
10033
+ [onSelectedCollectionsChange]
10034
+ );
10035
+ const handleAdminAddressChange = useCallback20(
10036
+ (adminAddress2) => {
10037
+ if (onAdminAddressChange) {
10038
+ onAdminAddressChange(adminAddress2);
10039
+ }
10040
+ },
10041
+ [onAdminAddressChange]
10042
+ );
10043
+ return /* @__PURE__ */ React112.createElement(Stack83, { gap: "lg" }, /* @__PURE__ */ React112.createElement(Stack83, { gap: "xs" }, /* @__PURE__ */ React112.createElement(Text58, { size: "sm", fw: 600 }, "Title"), /* @__PURE__ */ React112.createElement(
10044
+ TextInput39,
10045
+ {
10046
+ placeholder: "e.g. Claim Title",
10047
+ value: localTitle,
10048
+ onChange: (event) => {
10049
+ const newTitle = event.currentTarget.value;
10050
+ setLocalTitle(newTitle);
10051
+ onTitleChange(newTitle);
10052
+ }
10053
+ }
10054
+ )), /* @__PURE__ */ React112.createElement(Stack83, { gap: "xs" }, /* @__PURE__ */ React112.createElement(Text58, { size: "sm", fw: 600 }, "Description"), /* @__PURE__ */ React112.createElement(
10055
+ Textarea22,
10056
+ {
10057
+ placeholder: "Describe what this claim is about",
10058
+ minRows: 3,
10059
+ value: localDescription,
10060
+ onChange: (event) => {
10061
+ const newDescription = event.currentTarget.value;
10062
+ setLocalDescription(newDescription);
10063
+ onDescriptionChange(newDescription);
10064
+ }
10065
+ }
10066
+ )), /* @__PURE__ */ React112.createElement(
10067
+ CollectionSelector,
10068
+ {
10069
+ did: deedDid,
10070
+ selectedCollections: parsedSelectedCollections,
10071
+ onDidChange: onDeedDidChange,
10072
+ onCollectionsChange: handleCollectionsChange,
10073
+ onAdminAddressChange: handleAdminAddressChange,
10074
+ currentAdminAddress: adminAddress
10075
+ }
10076
+ ));
9902
10077
  };
9903
- var blockRegistry = new BlockRegistry();
9904
- blockRegistry.register({
9905
- type: "proposal",
9906
- propSchema: {
9907
- title: "",
9908
- description: "",
9909
- icon: "\u{1F4DD}",
9910
- proposalId: "",
9911
- status: "draft",
9912
- contractAddress: "",
9913
- coreAddress: "",
9914
- createdProposalId: ""
9915
- },
9916
- validDependencies: [],
9917
- defaultProps: {
9918
- icon: "\u{1F4DD}",
9919
- status: "draft"
9920
- }
9921
- });
9922
- blockRegistry.register({
9923
- type: "proposalVote",
9924
- propSchema: {
9925
- title: "",
10078
+
10079
+ // src/mantine/blocks/claim/template/TemplateConfig.tsx
10080
+ var TemplateConfig6 = ({ editor, block }) => {
10081
+ const { closePanel } = usePanelStore();
10082
+ const updateProp = useCallback21(
10083
+ (key, value) => {
10084
+ console.log("[Claim TemplateConfig] Updating prop:", key, value);
10085
+ editor.updateBlock(block, {
10086
+ props: {
10087
+ ...block.props,
10088
+ [key]: value
10089
+ }
10090
+ });
10091
+ },
10092
+ [editor, block]
10093
+ );
10094
+ return /* @__PURE__ */ React113.createElement(
10095
+ Paper13,
10096
+ {
10097
+ p: "md",
10098
+ shadow: "sm",
10099
+ style: {
10100
+ height: "100%",
10101
+ display: "flex",
10102
+ flexDirection: "column"
10103
+ }
10104
+ },
10105
+ /* @__PURE__ */ React113.createElement(
10106
+ "div",
10107
+ {
10108
+ style: {
10109
+ display: "flex",
10110
+ justifyContent: "space-between",
10111
+ alignItems: "center",
10112
+ marginBottom: "1rem"
10113
+ }
10114
+ },
10115
+ /* @__PURE__ */ React113.createElement(Title9, { order: 3 }, "Claim Settings"),
10116
+ /* @__PURE__ */ React113.createElement(CloseButton8, { onClick: closePanel })
10117
+ ),
10118
+ /* @__PURE__ */ React113.createElement(
10119
+ ReusablePanel,
10120
+ {
10121
+ extraTabs: [
10122
+ {
10123
+ label: "General",
10124
+ value: "general",
10125
+ content: /* @__PURE__ */ React113.createElement(
10126
+ GeneralTab6,
10127
+ {
10128
+ title: block.props.title || "",
10129
+ description: block.props.description || "",
10130
+ deedDid: block.props.deedDid || "",
10131
+ selectedCollections: block.props.selectedCollections || "[]",
10132
+ adminAddress: block.props.adminAddress || "",
10133
+ onTitleChange: (value) => updateProp("title", value),
10134
+ onDescriptionChange: (value) => updateProp("description", value),
10135
+ onDeedDidChange: (value) => updateProp("deedDid", value),
10136
+ onSelectedCollectionsChange: (value) => updateProp("selectedCollections", value),
10137
+ onAdminAddressChange: (value) => updateProp("adminAddress", value)
10138
+ }
10139
+ )
10140
+ }
10141
+ ],
10142
+ context: { editor, block }
10143
+ }
10144
+ )
10145
+ );
10146
+ };
10147
+
10148
+ // src/mantine/blocks/claim/template/TemplateView.tsx
10149
+ var CLAIM_TEMPLATE_PANEL_ID = "claim-template-panel";
10150
+ var ClaimTemplateView = ({ editor, block }) => {
10151
+ const panelId = `${CLAIM_TEMPLATE_PANEL_ID}-${block.id}`;
10152
+ const panelContent = useMemo20(() => /* @__PURE__ */ React114.createElement(TemplateConfig6, { editor, block }), [editor, block]);
10153
+ const { open } = usePanel(panelId, panelContent);
10154
+ return /* @__PURE__ */ React114.createElement(Card24, { withBorder: true, padding: "md", radius: "md", style: { width: "100%", cursor: "pointer", position: "relative" }, onClick: open }, /* @__PURE__ */ React114.createElement(Badge16, { size: "xs", variant: "light", color: "gray", style: { position: "absolute", top: 8, right: 8 } }, "Template"), /* @__PURE__ */ React114.createElement(Group38, { wrap: "nowrap", justify: "space-between", align: "center" }, /* @__PURE__ */ React114.createElement(Group38, { wrap: "nowrap", align: "center" }, /* @__PURE__ */ React114.createElement(ActionIcon20, { variant: "light", color: "blue", size: "lg", radius: "xl", style: { flexShrink: 0 } }, getIcon(block.props.icon, 18, 1.5, "square-check")), /* @__PURE__ */ React114.createElement(Stack84, { gap: "xs", style: { flex: 1 } }, /* @__PURE__ */ React114.createElement(Text59, { fw: 500, size: "sm", contentEditable: false }, block.props.title || "Claim Title"), /* @__PURE__ */ React114.createElement(Text59, { size: "xs", c: "dimmed", contentEditable: false }, block.props.description || "Claim description")))));
10155
+ };
10156
+
10157
+ // src/mantine/blocks/claim/flow/FlowView.tsx
10158
+ import React117, { useState as useState34, useEffect as useEffect23, useMemo as useMemo23, useCallback as useCallback23 } from "react";
10159
+ import { Stack as Stack87, Text as Text62, Loader as Loader10, Center as Center5, Alert as Alert14, Title as Title11, Flex as Flex22, ActionIcon as ActionIcon23 } from "@mantine/core";
10160
+ import { IconSettings as IconSettings3, IconRefresh as IconRefresh2, IconAlertCircle as IconAlertCircle3 } from "@tabler/icons-react";
10161
+
10162
+ // src/mantine/blocks/claim/flow/ClaimCollectionsList.tsx
10163
+ import React116, { useMemo as useMemo22, useState as useState33, useEffect as useEffect22 } from "react";
10164
+ import { Stack as Stack86, Text as Text61, ActionIcon as ActionIcon22, Tooltip as Tooltip8, Loader as Loader9, Center as Center4 } from "@mantine/core";
10165
+
10166
+ // src/mantine/blocks/claim/flow/ClaimsListSheet.tsx
10167
+ import React115, { useState as useState32, useEffect as useEffect21, useCallback as useCallback22, useMemo as useMemo21 } from "react";
10168
+ import { CloseButton as CloseButton9, Title as Title10, Loader as Loader8, Stack as Stack85, Text as Text60, Button as Button29, ActionIcon as ActionIcon21, Alert as Alert13 } from "@mantine/core";
10169
+ import { IconArrowLeft as IconArrowLeft2, IconAlertCircle as IconAlertCircle2 } from "@tabler/icons-react";
10170
+ import { Survey, SurveyModel } from "@ixo/surveys";
10171
+
10172
+ // src/mantine/blocks/claim/flow/theme.ts
10173
+ var palette = {
10174
+ // Neutral
10175
+ Neutral50: "#FAFAFA",
10176
+ Neutral100: "#F8F8F8",
10177
+ Neutral200: "#F1F1F1",
10178
+ Neutral300: "#EBEBEB",
10179
+ Neutral500: "#D7D7D7",
10180
+ Neutral800: "#9A9A9A",
10181
+ Black: "#000000",
10182
+ // Neutral Dark
10183
+ NeutralDark50: "#050505",
10184
+ NeutralDark100: "#070707",
10185
+ NeutralDark200: "#0E0E0E",
10186
+ NeutralDark300: "#141414",
10187
+ NeutralDark500: "#282828",
10188
+ NeutralDark800: "#656565",
10189
+ // White
10190
+ White: "#FFFFFF",
10191
+ WhiteSecondary: "#D7ECE3",
10192
+ // EmergingBlue
10193
+ accentActive: "#0EB8DC",
10194
+ accentSecondary: "#20798C",
10195
+ accentHover: "#17C6EB",
10196
+ accentLight: "#ADEBF8",
10197
+ // CompanionBlue
10198
+ companionBlue: "#e8f9fd",
10199
+ // EmergingLighter
10200
+ accentLighter: "rgba(173,235,248,0.2)",
10201
+ accentDarker: "#296DAB",
10202
+ darkestBlue: "#000000",
10203
+ // Contribution
10204
+ contributionBlue: "rgba(22, 143, 168, 1)",
10205
+ // Danger
10206
+ dangerFull: "#E2223B",
10207
+ dangerBrighter: "#FCCFD5",
10208
+ dangerBright: "#F9909E",
10209
+ dangerDark: "#A11C43",
10210
+ // Success
10211
+ successFull: "#61B43A",
10212
+ successDarker: "#47822b",
10213
+ successBright: "#F4FCF0",
10214
+ successSecondary: "#1CBD6A",
10215
+ orangeFull: "#ED9526",
10216
+ orangeBright: "#FDC681",
10217
+ // Transparent
10218
+ transparent: "rgba(255, 255, 255, 0)",
10219
+ whiteTransparentDarker: "rgba(255, 255, 255, 0.10)",
10220
+ whiteTransparent: "rgba(255, 255, 255, 0.30)",
10221
+ whiteTransparentSecondary: "rgba(255, 255, 255, 0.65)",
10222
+ successTransparent: "rgba(67, 175, 98, 0.30)",
10223
+ // Glassmorphics
10224
+ glass: "rgba(255, 255, 255, 0.06)",
10225
+ glassGradient: "linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(153, 153, 153, 0.03) 100%)",
10226
+ glassDarker: "rgba(0, 0, 0, 0.5)",
10227
+ glassLighter: "rgba(255, 255, 255, 0.3)",
10228
+ // Gradients
10229
+ offsetCertificateGradient: "linear-gradient(45deg, rgba(59,152,51,1) 0%, rgba(70,193,193,1) 100%)",
10230
+ contributionCertificateGradient: "linear-gradient(45deg, rgba(22,143,168,1) 0%, rgba(30,204,183,1) 100%)",
10231
+ carbonCertificateGradient: "linear-gradient(55.09deg, rgba(54, 101, 135, 1) -2.49%, rgba(30, 173, 204, 1) 109.08%)",
10232
+ shadowGradient: "linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.2) 100%)"
10233
+ };
10234
+ var surveyTheme = {
10235
+ backgroundImageFit: "cover",
10236
+ backgroundImageAttachment: "scroll",
10237
+ backgroundOpacity: 0,
10238
+ cssVariables: {
10239
+ "-sjs-editorpanel-backcolor": palette.glassDarker,
10240
+ "--sjs-editor-background": palette.glassDarker,
10241
+ "--sjs-general-backcolor": palette.Black,
10242
+ "--sjs-general-backcolor-dark": palette.Black,
10243
+ "--sjs-general-backcolor-dim": palette.transparent,
10244
+ "--sjs-general-backcolor-dim-light": palette.glassDarker,
10245
+ "--sjs-general-backcolor-dim-dark": palette.glassDarker,
10246
+ "--sjs-general-forecolor": palette.White,
10247
+ "--sjs-general-forecolor-light": palette.White,
10248
+ "--sjs-general-dim-forecolor": palette.White,
10249
+ "--sjs-general-dim-forecolor-light": palette.White,
10250
+ "--sjs-font-surveytitle-color": palette.White,
10251
+ "--sjs-primary-backcolor": palette.accentActive,
10252
+ "--sjs-primary-backcolor-light": palette.accentLight,
10253
+ "--sjs-primary-backcolor-dark": palette.accentHover,
10254
+ "--sjs-primary-forecolor": "rgba(255, 255, 255, 1)",
10255
+ "--sjs-primary-forecolor-light": "rgba(255, 255, 255, 0.25)",
10256
+ "--sjs-base-unit": "8px",
10257
+ "--sjs-editorpanel-cornerRadius": "30px",
10258
+ "--sjs-questionpanel-cornerRadius": "12px",
10259
+ "--sjs-secondary-backcolor": "rgba(255, 152, 20, 1)",
10260
+ "--sjs-secondary-backcolor-light": "rgba(255, 152, 20, 0.1)",
10261
+ "--sjs-secondary-backcolor-semi-light": "rgba(255, 152, 20, 0.25)",
10262
+ "--sjs-secondary-forecolor": "rgba(255, 255, 255, 1)",
10263
+ "--sjs-secondary-forecolor-light": "rgba(255, 255, 255, 0.25)",
10264
+ "--sjs-shadow-small": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
10265
+ "--sjs-shadow-small-reset": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
10266
+ "--sjs-shadow-medium": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
10267
+ "--sjs-shadow-large": "0px 8px 16px 0px rgba(0, 0, 0, 0.1)",
10268
+ "--sjs-shadow-inner": "0px 0px 0px 0px rgba(0, 0, 0, 0.15)",
10269
+ "--sjs-shadow-inner-reset": "0px 0px 0px 0px rgba(0, 0, 0, 0.15)",
10270
+ "--sjs-border-light": "rgba(0, 0, 0, 0.09)",
10271
+ "--sjs-border-default": "rgba(0, 0, 0, 0.16)",
10272
+ "--sjs-border-inside": "rgba(0, 0, 0, 0.16)",
10273
+ "--sjs-special-red": "rgba(229, 10, 62, 1)",
10274
+ "--sjs-special-red-light": "rgba(229, 10, 62, 0.1)",
10275
+ "--sjs-special-red-forecolor": "rgba(255, 255, 255, 1)",
10276
+ "--sjs-special-green": "rgba(25, 179, 148, 1)",
10277
+ "--sjs-special-green-light": "rgba(25, 179, 148, 0.1)",
10278
+ "--sjs-special-green-forecolor": "rgba(255, 255, 255, 1)",
10279
+ "--sjs-special-blue": "rgba(67, 127, 217, 1)",
10280
+ "--sjs-special-blue-light": "rgba(67, 127, 217, 0.1)",
10281
+ "--sjs-special-blue-forecolor": "rgba(255, 255, 255, 1)",
10282
+ "--sjs-special-yellow": "rgba(255, 152, 20, 1)",
10283
+ "--sjs-special-yellow-light": "rgba(255, 152, 20, 0.1)",
10284
+ "--sjs-special-yellow-forecolor": "rgba(255, 255, 255, 1)",
10285
+ "--sjs-article-font-xx-large-textDecoration": "none",
10286
+ "--sjs-article-font-xx-large-fontWeight": "700",
10287
+ "--sjs-article-font-xx-large-fontStyle": "normal",
10288
+ "--sjs-article-font-xx-large-fontStretch": "normal",
10289
+ "--sjs-article-font-xx-large-letterSpacing": "0",
10290
+ "--sjs-article-font-xx-large-lineHeight": "64px",
10291
+ "--sjs-article-font-xx-large-paragraphIndent": "0px",
10292
+ "--sjs-article-font-xx-large-textCase": "none",
10293
+ "--sjs-article-font-x-large-textDecoration": "none",
10294
+ "--sjs-article-font-x-large-fontWeight": "700",
10295
+ "--sjs-article-font-x-large-fontStyle": "normal",
10296
+ "--sjs-article-font-x-large-fontStretch": "normal",
10297
+ "--sjs-article-font-x-large-letterSpacing": "0",
10298
+ "--sjs-article-font-x-large-lineHeight": "56px",
10299
+ "--sjs-article-font-x-large-paragraphIndent": "0px",
10300
+ "--sjs-article-font-x-large-textCase": "none",
10301
+ "--sjs-article-font-large-textDecoration": "none",
10302
+ "--sjs-article-font-large-fontWeight": "700",
10303
+ "--sjs-article-font-large-fontStyle": "normal",
10304
+ "--sjs-article-font-large-fontStretch": "normal",
10305
+ "--sjs-article-font-large-letterSpacing": "0",
10306
+ "--sjs-article-font-large-lineHeight": "40px",
10307
+ "--sjs-article-font-large-paragraphIndent": "0px",
10308
+ "--sjs-article-font-large-textCase": "none",
10309
+ "--sjs-article-font-medium-textDecoration": "none",
10310
+ "--sjs-article-font-medium-fontWeight": "700",
10311
+ "--sjs-article-font-medium-fontStyle": "normal",
10312
+ "--sjs-article-font-medium-fontStretch": "normal",
10313
+ "--sjs-article-font-medium-letterSpacing": "0",
10314
+ "--sjs-article-font-medium-lineHeight": "32px",
10315
+ "--sjs-article-font-medium-paragraphIndent": "0px",
10316
+ "--sjs-article-font-medium-textCase": "none",
10317
+ "--sjs-article-font-default-textDecoration": "none",
10318
+ "--sjs-article-font-default-fontWeight": "400",
10319
+ "--sjs-article-font-default-fontStyle": "normal",
10320
+ "--sjs-article-font-default-fontStretch": "normal",
10321
+ "--sjs-article-font-default-letterSpacing": "0",
10322
+ "--sjs-article-font-default-lineHeight": "28px",
10323
+ "--sjs-article-font-default-paragraphIndent": "0px",
10324
+ "--sjs-article-font-default-textCase": "none"
10325
+ },
10326
+ themeName: "userTheme",
10327
+ colorPalette: "dark",
10328
+ isPanelless: true
10329
+ };
10330
+
10331
+ // src/mantine/blocks/claim/flow/ClaimsListSheet.tsx
10332
+ var ClaimsListSheet = ({ collectionId, collectionName, deedId, adminAddress, userAddress, onSubmitComplete }) => {
10333
+ const { closePanel } = usePanelStore();
10334
+ const handlers = useBlocknoteHandlers();
10335
+ const [viewMode, setViewMode] = useState32("list");
10336
+ const [claims, setClaims] = useState32([]);
10337
+ const [loading, setLoading] = useState32(true);
10338
+ const [error, setError] = useState32(null);
10339
+ const [surveyJson, setSurveyJson] = useState32(null);
10340
+ const [surveyLoading, setSurveyLoading] = useState32(false);
10341
+ const [surveyError, setSurveyError] = useState32(null);
10342
+ const fetchClaims = useCallback22(async () => {
10343
+ try {
10344
+ setLoading(true);
10345
+ setError(null);
10346
+ const result = await handlers.getClaimsPerUserAddress({
10347
+ collectionId,
10348
+ userAddress
10349
+ });
10350
+ setClaims(result || []);
10351
+ } catch (err) {
10352
+ console.error("Error fetching claims:", err);
10353
+ setError(err instanceof Error ? err.message : "Failed to fetch claims");
10354
+ setClaims([]);
10355
+ } finally {
10356
+ setLoading(false);
10357
+ }
10358
+ }, [collectionId, userAddress, handlers]);
10359
+ const fetchSurveyTemplate = useCallback22(async () => {
10360
+ try {
10361
+ setSurveyLoading(true);
10362
+ setSurveyError(null);
10363
+ const result = await handlers.getDeedSurveyTemplate(deedId);
10364
+ if (result) {
10365
+ setSurveyJson(result.surveyTemplate);
10366
+ } else {
10367
+ setSurveyError("No survey template found for this deed");
10368
+ }
10369
+ } catch (err) {
10370
+ console.error("Error fetching survey template:", err);
10371
+ setSurveyError(err instanceof Error ? err.message : "Failed to load survey template");
10372
+ } finally {
10373
+ setSurveyLoading(false);
10374
+ }
10375
+ }, [deedId, handlers]);
10376
+ useEffect21(() => {
10377
+ fetchClaims();
10378
+ }, [fetchClaims]);
10379
+ const surveyModel = useMemo21(() => {
10380
+ if (!surveyJson) return null;
10381
+ const model = new SurveyModel(surveyJson);
10382
+ model.applyTheme(surveyTheme);
10383
+ model.showQuestionNumbers = "off";
10384
+ model.questionsOnPageMode = "singlePage";
10385
+ return model;
10386
+ }, [surveyJson]);
10387
+ const handleSurveyComplete = useCallback22(
10388
+ async (sender) => {
10389
+ const surveyData = sender.data;
10390
+ console.log("Survey completed:", surveyData);
10391
+ try {
10392
+ const pin = await handlers.requestPin({
10393
+ title: "Verify Identity",
10394
+ description: "Enter your PIN to submit the claim",
10395
+ submitText: "Verify"
10396
+ });
10397
+ if (!adminAddress) {
10398
+ throw new Error("Admin address is not set. Please configure the claim block first.");
10399
+ }
10400
+ const result = await handlers.submitClaim({
10401
+ surveyData,
10402
+ deedDid: deedId,
10403
+ collectionId,
10404
+ adminAddress,
10405
+ pin
10406
+ });
10407
+ console.log("Claim submitted successfully:", result);
10408
+ closePanel();
10409
+ onSubmitComplete?.();
10410
+ } catch (error2) {
10411
+ console.error("Failed to submit claim:", error2);
10412
+ setSurveyError(error2 instanceof Error ? error2.message : "Failed to submit claim");
10413
+ }
10414
+ },
10415
+ [handlers, deedId, collectionId, adminAddress, closePanel, onSubmitComplete]
10416
+ );
10417
+ useEffect21(() => {
10418
+ if (surveyModel) {
10419
+ surveyModel.onComplete.add(handleSurveyComplete);
10420
+ return () => {
10421
+ surveyModel.onComplete.remove(handleSurveyComplete);
10422
+ };
10423
+ }
10424
+ return void 0;
10425
+ }, [surveyModel, handleSurveyComplete]);
10426
+ const handleNewClaim = () => {
10427
+ if (!surveyJson) {
10428
+ fetchSurveyTemplate();
10429
+ }
10430
+ setViewMode("survey");
10431
+ };
10432
+ const handleBackToList = () => {
10433
+ setViewMode("list");
10434
+ setSurveyError(null);
10435
+ fetchClaims();
10436
+ };
10437
+ const getClaimStatus = (paymentsStatus) => {
10438
+ if (paymentsStatus.approval === "PAID") {
10439
+ return "approved";
10440
+ }
10441
+ if (paymentsStatus.rejection === "PAID") {
10442
+ return "rejected";
10443
+ }
10444
+ return "pending";
10445
+ };
10446
+ const getStatusColor = (status) => {
10447
+ switch (status) {
10448
+ case "approved":
10449
+ return "green";
10450
+ case "rejected":
10451
+ return "red";
10452
+ case "pending":
10453
+ default:
10454
+ return "yellow";
10455
+ }
10456
+ };
10457
+ const formatDate = (dateString) => {
10458
+ try {
10459
+ return new Date(dateString).toLocaleDateString();
10460
+ } catch {
10461
+ return dateString;
10462
+ }
10463
+ };
10464
+ return /* @__PURE__ */ React115.createElement(
10465
+ "div",
10466
+ {
10467
+ style: {
10468
+ height: "100%",
10469
+ display: "flex",
10470
+ flexDirection: "column",
10471
+ overflow: "hidden"
10472
+ }
10473
+ },
10474
+ /* @__PURE__ */ React115.createElement(
10475
+ "div",
10476
+ {
10477
+ style: {
10478
+ display: "flex",
10479
+ justifyContent: "space-between",
10480
+ alignItems: "center",
10481
+ marginBottom: "1rem"
10482
+ }
10483
+ },
10484
+ /* @__PURE__ */ React115.createElement("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" } }, viewMode === "survey" && /* @__PURE__ */ React115.createElement(ActionIcon21, { variant: "subtle", onClick: handleBackToList }, /* @__PURE__ */ React115.createElement(IconArrowLeft2, { size: 20 })), /* @__PURE__ */ React115.createElement(Title10, { order: 3 }, viewMode === "list" ? collectionName : "Submit New Claim")),
10485
+ /* @__PURE__ */ React115.createElement(CloseButton9, { onClick: closePanel })
10486
+ ),
10487
+ /* @__PURE__ */ React115.createElement(
10488
+ "div",
10489
+ {
10490
+ style: {
10491
+ flex: 1,
10492
+ overflow: "hidden",
10493
+ position: "relative"
10494
+ }
10495
+ },
10496
+ /* @__PURE__ */ React115.createElement(
10497
+ "div",
10498
+ {
10499
+ style: {
10500
+ position: "absolute",
10501
+ top: 0,
10502
+ left: 0,
10503
+ right: 0,
10504
+ bottom: 0,
10505
+ display: "flex",
10506
+ flexDirection: "column",
10507
+ overflow: "auto",
10508
+ transform: viewMode === "list" ? "translateX(0)" : "translateX(-100%)",
10509
+ opacity: viewMode === "list" ? 1 : 0,
10510
+ transition: "transform 0.3s ease-out, opacity 0.3s ease-out",
10511
+ pointerEvents: viewMode === "list" ? "auto" : "none"
10512
+ }
10513
+ },
10514
+ /* @__PURE__ */ React115.createElement(Stack85, { gap: "md", style: { flex: 1 } }, /* @__PURE__ */ React115.createElement(Button29, { onClick: handleNewClaim, fullWidth: true }, "New Claim"), loading ? /* @__PURE__ */ React115.createElement(Stack85, { align: "center", justify: "center", style: { flex: 1 } }, /* @__PURE__ */ React115.createElement(Loader8, { size: "lg" }), /* @__PURE__ */ React115.createElement(Text60, { size: "sm", c: "dimmed" }, "Loading claims...")) : error ? /* @__PURE__ */ React115.createElement(Alert13, { color: "red", title: "Failed to load claims", icon: /* @__PURE__ */ React115.createElement(IconAlertCircle2, { size: 18 }) }, /* @__PURE__ */ React115.createElement(Text60, { size: "sm" }, error)) : claims.length === 0 ? /* @__PURE__ */ React115.createElement(Stack85, { align: "center", justify: "center", style: { flex: 1 } }, /* @__PURE__ */ React115.createElement(Text60, { size: "sm", c: "dimmed", ta: "center" }, 'No claims found. Click "New Claim" to submit your first claim.')) : /* @__PURE__ */ React115.createElement(Stack85, { gap: "xs" }, claims.map((claim) => {
10515
+ const status = getClaimStatus(claim.paymentsStatus);
10516
+ return /* @__PURE__ */ React115.createElement(ListItemContainer, { key: claim.claimId }, /* @__PURE__ */ React115.createElement(Stack85, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React115.createElement(Text60, { size: "sm", fw: 500 }, "Claim #", claim.claimId.slice(-8)), /* @__PURE__ */ React115.createElement(Text60, { size: "xs", c: "dimmed" }, "Submitted: ", formatDate(claim.submissionDate))), /* @__PURE__ */ React115.createElement(Text60, { size: "xs", fw: 500, c: getStatusColor(status) }, status.toUpperCase()));
10517
+ })))
10518
+ ),
10519
+ /* @__PURE__ */ React115.createElement(
10520
+ "div",
10521
+ {
10522
+ style: {
10523
+ position: "absolute",
10524
+ top: 0,
10525
+ left: 0,
10526
+ right: 0,
10527
+ bottom: 0,
10528
+ display: "flex",
10529
+ flexDirection: "column",
10530
+ overflow: "auto",
10531
+ transform: viewMode === "survey" ? "translateX(0)" : "translateX(100%)",
10532
+ opacity: viewMode === "survey" ? 1 : 0,
10533
+ transition: "transform 0.3s ease-out, opacity 0.3s ease-out",
10534
+ pointerEvents: viewMode === "survey" ? "auto" : "none"
10535
+ }
10536
+ },
10537
+ /* @__PURE__ */ React115.createElement("div", null, surveyLoading && /* @__PURE__ */ React115.createElement(Stack85, { align: "center", justify: "center", style: { height: "100%" } }, /* @__PURE__ */ React115.createElement(Loader8, { size: "lg" }), /* @__PURE__ */ React115.createElement(Text60, { size: "sm", c: "dimmed" }, "Loading survey template...")), surveyError && /* @__PURE__ */ React115.createElement(Stack85, { align: "center", justify: "center", style: { height: "100%", padding: "1rem" } }, /* @__PURE__ */ React115.createElement(Text60, { size: "sm", c: "red" }, surveyError)), !surveyLoading && !surveyError && surveyModel && /* @__PURE__ */ React115.createElement(Survey, { model: surveyModel }))
10538
+ )
10539
+ )
10540
+ );
10541
+ };
10542
+
10543
+ // src/mantine/blocks/claim/flow/ClaimCollectionsList.tsx
10544
+ import { IconArrowRight as IconArrowRight2 } from "@tabler/icons-react";
10545
+ var CollectionItem = ({ collection, deedId, adminAddress, userRole, onRefresh }) => {
10546
+ const handlers = useBlocknoteHandlers();
10547
+ const currentUser = handlers.getCurrentUser();
10548
+ const getCollectionName = (collection2) => {
10549
+ return collection2.protocol?.profile?.name || collection2.name || "Unnamed Collection";
10550
+ };
10551
+ const isServiceAgent = userRole === "SA" /* ServiceProvider */;
10552
+ const canAccessClaims = isServiceAgent;
10553
+ const claimsPanelId = `claims-list-${collection.id}`;
10554
+ const collectionName = getCollectionName(collection);
10555
+ const claimsPanelContent = useMemo22(
10556
+ () => /* @__PURE__ */ React116.createElement(
10557
+ ClaimsListSheet,
10558
+ {
10559
+ collectionId: collection.id,
10560
+ collectionName,
10561
+ deedId,
10562
+ adminAddress,
10563
+ userAddress: currentUser.address,
10564
+ onSubmitComplete: onRefresh
10565
+ }
10566
+ ),
10567
+ [collection.id, collectionName, deedId, adminAddress, currentUser.address, onRefresh]
10568
+ );
10569
+ const { open: openClaimsPanel } = usePanel(claimsPanelId, claimsPanelContent);
10570
+ const handleClick = () => {
10571
+ if (canAccessClaims) {
10572
+ openClaimsPanel();
10573
+ }
10574
+ };
10575
+ return /* @__PURE__ */ React116.createElement("div", { style: { opacity: canAccessClaims ? 1 : 0.5 } }, /* @__PURE__ */ React116.createElement(ListItemContainer, null, /* @__PURE__ */ React116.createElement(Stack86, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React116.createElement(Text61, { size: "sm", fw: 500, c: canAccessClaims ? void 0 : "dimmed" }, getCollectionName(collection)), collection.description && /* @__PURE__ */ React116.createElement(Text61, { size: "xs", c: "dimmed" }, collection.description)), /* @__PURE__ */ React116.createElement(Tooltip8, { label: "You need to apply to be a service agent first", disabled: canAccessClaims, position: "left", withArrow: true }, /* @__PURE__ */ React116.createElement(ActionIcon22, { variant: "subtle", size: "lg", onClick: handleClick, disabled: !canAccessClaims, style: { cursor: canAccessClaims ? "pointer" : "not-allowed" } }, /* @__PURE__ */ React116.createElement(IconArrowRight2, { size: 20 })))));
10576
+ };
10577
+ var ClaimCollectionsList = ({ collections, deedId, adminAddress, userAddress, onRefresh }) => {
10578
+ const handlers = useBlocknoteHandlers();
10579
+ const [userRoles, setUserRoles] = useState33({});
10580
+ const [loadingRoles, setLoadingRoles] = useState33(true);
10581
+ useEffect22(() => {
10582
+ const fetchUserRoles = async () => {
10583
+ if (!collections || collections.length === 0 || !userAddress || !adminAddress) {
10584
+ setLoadingRoles(false);
10585
+ return;
10586
+ }
10587
+ try {
10588
+ setLoadingRoles(true);
10589
+ const collectionIds = collections.map((c) => c.id);
10590
+ const roles = await handlers.getUserRoles({
10591
+ userAddress,
10592
+ adminAddress,
10593
+ deedDid: deedId,
10594
+ collectionIds
10595
+ });
10596
+ const rolesMap = {};
10597
+ collections.forEach((collection) => {
10598
+ const roleData = roles?.find((r) => r.collectionId === collection.id);
10599
+ rolesMap[collection.id] = roleData?.role || null;
10600
+ });
10601
+ setUserRoles(rolesMap);
10602
+ } catch (error) {
10603
+ console.error("Error fetching user roles:", error);
10604
+ const rolesMap = {};
10605
+ collections.forEach((collection) => {
10606
+ rolesMap[collection.id] = null;
10607
+ });
10608
+ setUserRoles(rolesMap);
10609
+ } finally {
10610
+ setLoadingRoles(false);
10611
+ }
10612
+ };
10613
+ fetchUserRoles();
10614
+ }, [collections, userAddress, adminAddress, handlers, deedId]);
10615
+ if (!collections || collections.length === 0) {
10616
+ return /* @__PURE__ */ React116.createElement(Text61, { size: "sm", c: "dimmed", ta: "center", py: "md" }, "No claim collections found");
10617
+ }
10618
+ if (loadingRoles) {
10619
+ return /* @__PURE__ */ React116.createElement(Center4, { py: "md" }, /* @__PURE__ */ React116.createElement(Loader9, { size: "sm" }));
10620
+ }
10621
+ return /* @__PURE__ */ React116.createElement(Stack86, { gap: "md", px: 5 }, collections.map((collection) => /* @__PURE__ */ React116.createElement(CollectionItem, { key: collection.id, collection, deedId, adminAddress, userRole: userRoles[collection.id] || null, onRefresh })));
10622
+ };
10623
+
10624
+ // src/mantine/blocks/claim/flow/FlowView.tsx
10625
+ var CLAIM_FLOW_PANEL_ID = "claim-flow-panel";
10626
+ var ClaimFlowView = ({ editor, block }) => {
10627
+ const { editable } = useBlocknoteContext();
10628
+ const handlers = useBlocknoteHandlers();
10629
+ const currentUser = handlers.getCurrentUser();
10630
+ const [collections, setCollections] = useState34([]);
10631
+ const [loading, setLoading] = useState34(false);
10632
+ const [error, setError] = useState34(null);
10633
+ const panelId = `${CLAIM_FLOW_PANEL_ID}-${block.id}`;
10634
+ const panelContent = useMemo23(() => /* @__PURE__ */ React117.createElement(TemplateConfig6, { editor, block }), [editor, block]);
10635
+ const { open } = usePanel(panelId, panelContent);
10636
+ const selectedCollectionIds = useMemo23(() => {
10637
+ try {
10638
+ return JSON.parse(block.props.selectedCollections || "[]");
10639
+ } catch {
10640
+ return [];
10641
+ }
10642
+ }, [block.props.selectedCollections]);
10643
+ const did = block.props.deedDid;
10644
+ const adminAddress = block.props.adminAddress || "";
10645
+ const fetchCollections = useCallback23(async () => {
10646
+ if (!did || selectedCollectionIds.length === 0) {
10647
+ setCollections([]);
10648
+ return;
10649
+ }
10650
+ setLoading(true);
10651
+ setError(null);
10652
+ try {
10653
+ const response = await handlers.getClaimCollections({ deedDid: did });
10654
+ const { adminAddress: adminAddress2, collections: allCollections } = response || { adminAddress: "", collections: [] };
10655
+ if (adminAddress2 && (!block.props.adminAddress || block.props.adminAddress === "")) {
10656
+ editor.updateBlock(block, {
10657
+ props: {
10658
+ ...block.props,
10659
+ adminAddress: adminAddress2
10660
+ }
10661
+ });
10662
+ }
10663
+ const selectedCollections = (allCollections || []).filter((c) => selectedCollectionIds.includes(c?.id));
10664
+ setCollections(selectedCollections);
10665
+ } catch (err) {
10666
+ console.error("Error fetching collections:", err);
10667
+ setError(err instanceof Error ? err.message : "Failed to fetch collections");
10668
+ } finally {
10669
+ setLoading(false);
10670
+ }
10671
+ }, [did, selectedCollectionIds, handlers, editor, block]);
10672
+ useEffect23(() => {
10673
+ fetchCollections();
10674
+ }, [fetchCollections]);
10675
+ if (!did) {
10676
+ return /* @__PURE__ */ React117.createElement(Center5, { py: "xl" }, /* @__PURE__ */ React117.createElement(Text62, { size: "sm", c: "dimmed" }, "Please configure the claim block in template mode first"));
10677
+ }
10678
+ if (selectedCollectionIds.length === 0) {
10679
+ return /* @__PURE__ */ React117.createElement(Center5, { py: "xl" }, /* @__PURE__ */ React117.createElement(Text62, { size: "sm", c: "dimmed" }, "No claim collections selected"));
10680
+ }
10681
+ return /* @__PURE__ */ React117.createElement(Stack87, { w: "100%" }, /* @__PURE__ */ React117.createElement(Flex22, { px: 5, align: "center", justify: "space-between" }, /* @__PURE__ */ React117.createElement(Title11, { order: 4 }, "Submit Claims"), /* @__PURE__ */ React117.createElement(Flex22, { gap: "xs" }, /* @__PURE__ */ React117.createElement(ActionIcon23, { variant: "subtle", size: "sm", onClick: fetchCollections, loading }, /* @__PURE__ */ React117.createElement(IconRefresh2, { size: 18 })), editable && /* @__PURE__ */ React117.createElement(ActionIcon23, { variant: "subtle", size: "sm", onClick: open }, /* @__PURE__ */ React117.createElement(IconSettings3, { size: 18 })))), loading ? /* @__PURE__ */ React117.createElement(Center5, { py: "xl" }, /* @__PURE__ */ React117.createElement(Loader10, { size: "md" })) : error ? /* @__PURE__ */ React117.createElement(Alert14, { color: "red", title: "Failed to load collections", icon: /* @__PURE__ */ React117.createElement(IconAlertCircle3, { size: 18 }) }, /* @__PURE__ */ React117.createElement(Text62, { size: "sm" }, error)) : /* @__PURE__ */ React117.createElement(ClaimCollectionsList, { collections, deedId: did, adminAddress, userAddress: currentUser.address, onRefresh: fetchCollections }));
10682
+ };
10683
+
10684
+ // src/mantine/blocks/claim/ClaimBlock.tsx
10685
+ function ClaimBlock({ editor, block }) {
10686
+ const { docType } = useBlocknoteContext();
10687
+ if (docType === "template") {
10688
+ return /* @__PURE__ */ React118.createElement(ClaimTemplateView, { editor, block });
10689
+ }
10690
+ return /* @__PURE__ */ React118.createElement(ClaimFlowView, { editor, block });
10691
+ }
10692
+
10693
+ // src/mantine/blocks/claim/ClaimBlockSpec.tsx
10694
+ var ClaimBlockSpec = createReactBlockSpec8(
10695
+ {
10696
+ type: "claim",
10697
+ propSchema: {
10698
+ title: { default: "" },
10699
+ description: { default: "" },
10700
+ icon: { default: "square-check" },
10701
+ deedDid: { default: "" },
10702
+ selectedCollections: { default: "[]" },
10703
+ adminAddress: { default: "" }
10704
+ },
10705
+ content: "none"
10706
+ },
10707
+ {
10708
+ render: (props) => {
10709
+ const ixoProps = props;
10710
+ return /* @__PURE__ */ React119.createElement(ClaimBlock, { ...ixoProps });
10711
+ }
10712
+ }
10713
+ );
10714
+
10715
+ // src/mantine/blocks/bid/BidBlockSpec.tsx
10716
+ import React130 from "react";
10717
+ import { createReactBlockSpec as createReactBlockSpec9 } from "@blocknote/react";
10718
+
10719
+ // src/mantine/blocks/bid/BidBlock.tsx
10720
+ import React129 from "react";
10721
+
10722
+ // src/mantine/blocks/bid/template/TemplateView.tsx
10723
+ import React123, { useMemo as useMemo25 } from "react";
10724
+ import { Card as Card25, Group as Group39, Stack as Stack89, Text as Text64, ActionIcon as ActionIcon24, Badge as Badge17 } from "@mantine/core";
10725
+
10726
+ // src/mantine/blocks/bid/template/TemplateConfig.tsx
10727
+ import React122, { useCallback as useCallback25 } from "react";
10728
+ import { Paper as Paper14, CloseButton as CloseButton10, Title as Title12 } from "@mantine/core";
10729
+
10730
+ // src/mantine/blocks/bid/template/GeneralTab.tsx
10731
+ import React120, { useEffect as useEffect24, useState as useState35 } from "react";
10732
+ import { Stack as Stack88, Text as Text63, TextInput as TextInput40, Textarea as Textarea23 } from "@mantine/core";
10733
+ var GeneralTab7 = ({ title, description, onTitleChange, onDescriptionChange }) => {
10734
+ const [localTitle, setLocalTitle] = useState35(title || "");
10735
+ const [localDescription, setLocalDescription] = useState35(description || "");
10736
+ useEffect24(() => {
10737
+ setLocalTitle(title || "");
10738
+ }, [title]);
10739
+ useEffect24(() => {
10740
+ setLocalDescription(description || "");
10741
+ }, [description]);
10742
+ return /* @__PURE__ */ React120.createElement(Stack88, { gap: "lg" }, /* @__PURE__ */ React120.createElement(Stack88, { gap: "xs" }, /* @__PURE__ */ React120.createElement(Text63, { size: "sm", fw: 600 }, "Title"), /* @__PURE__ */ React120.createElement(
10743
+ TextInput40,
10744
+ {
10745
+ placeholder: "e.g. Bid Title",
10746
+ value: localTitle,
10747
+ onChange: (event) => {
10748
+ const newTitle = event.currentTarget.value;
10749
+ setLocalTitle(newTitle);
10750
+ onTitleChange(newTitle);
10751
+ }
10752
+ }
10753
+ )), /* @__PURE__ */ React120.createElement(Stack88, { gap: "xs" }, /* @__PURE__ */ React120.createElement(Text63, { size: "sm", fw: 600 }, "Description"), /* @__PURE__ */ React120.createElement(
10754
+ Textarea23,
10755
+ {
10756
+ placeholder: "Describe what this bid is about",
10757
+ minRows: 3,
10758
+ value: localDescription,
10759
+ onChange: (event) => {
10760
+ const newDescription = event.currentTarget.value;
10761
+ setLocalDescription(newDescription);
10762
+ onDescriptionChange(newDescription);
10763
+ }
10764
+ }
10765
+ )));
10766
+ };
10767
+
10768
+ // src/mantine/blocks/bid/template/CollectionsTab.tsx
10769
+ import React121, { useCallback as useCallback24, useMemo as useMemo24 } from "react";
10770
+ var CollectionsTab = ({ did, selectedCollections, adminAddress, onDidChange, onSelectedCollectionsChange, onAdminAddressChange }) => {
10771
+ const parsedSelectedCollections = useMemo24(() => {
10772
+ try {
10773
+ return JSON.parse(selectedCollections || "[]");
10774
+ } catch {
10775
+ return [];
10776
+ }
10777
+ }, [selectedCollections]);
10778
+ const handleCollectionsChange = useCallback24(
10779
+ (collections) => {
10780
+ onSelectedCollectionsChange(JSON.stringify(collections || []));
10781
+ },
10782
+ [onSelectedCollectionsChange]
10783
+ );
10784
+ const handleAdminAddressChange = useCallback24(
10785
+ (adminAddress2) => {
10786
+ if (onAdminAddressChange) {
10787
+ onAdminAddressChange(adminAddress2);
10788
+ }
10789
+ },
10790
+ [onAdminAddressChange]
10791
+ );
10792
+ return /* @__PURE__ */ React121.createElement(
10793
+ CollectionSelector,
10794
+ {
10795
+ did,
10796
+ selectedCollections: parsedSelectedCollections,
10797
+ onDidChange,
10798
+ onCollectionsChange: handleCollectionsChange,
10799
+ onAdminAddressChange: handleAdminAddressChange,
10800
+ currentAdminAddress: adminAddress
10801
+ }
10802
+ );
10803
+ };
10804
+
10805
+ // src/mantine/blocks/bid/template/TemplateConfig.tsx
10806
+ var TemplateConfig7 = ({ editor, block }) => {
10807
+ const { closePanel } = usePanelStore();
10808
+ const updateProp = useCallback25(
10809
+ (key, value) => {
10810
+ editor.updateBlock(block, {
10811
+ props: {
10812
+ ...block.props,
10813
+ [key]: value
10814
+ }
10815
+ });
10816
+ },
10817
+ [editor, block]
10818
+ );
10819
+ return /* @__PURE__ */ React122.createElement(
10820
+ Paper14,
10821
+ {
10822
+ p: "md",
10823
+ shadow: "sm",
10824
+ style: {
10825
+ height: "100%",
10826
+ display: "flex",
10827
+ flexDirection: "column"
10828
+ }
10829
+ },
10830
+ /* @__PURE__ */ React122.createElement(
10831
+ "div",
10832
+ {
10833
+ style: {
10834
+ display: "flex",
10835
+ justifyContent: "space-between",
10836
+ alignItems: "center",
10837
+ marginBottom: "1rem"
10838
+ }
10839
+ },
10840
+ /* @__PURE__ */ React122.createElement(Title12, { order: 3 }, "Bid Settings"),
10841
+ /* @__PURE__ */ React122.createElement(CloseButton10, { onClick: closePanel })
10842
+ ),
10843
+ /* @__PURE__ */ React122.createElement(
10844
+ ReusablePanel,
10845
+ {
10846
+ extraTabs: [
10847
+ {
10848
+ label: "General",
10849
+ value: "general",
10850
+ content: /* @__PURE__ */ React122.createElement(
10851
+ GeneralTab7,
10852
+ {
10853
+ title: block.props.title || "",
10854
+ description: block.props.description || "",
10855
+ onTitleChange: (value) => updateProp("title", value),
10856
+ onDescriptionChange: (value) => updateProp("description", value)
10857
+ }
10858
+ )
10859
+ },
10860
+ {
10861
+ label: "Collections",
10862
+ value: "collections",
10863
+ content: /* @__PURE__ */ React122.createElement(
10864
+ CollectionsTab,
10865
+ {
10866
+ did: block.props.did || "",
10867
+ selectedCollections: block.props.selectedCollections || "[]",
10868
+ adminAddress: block.props.adminAddress || "",
10869
+ onDidChange: (value) => updateProp("did", value),
10870
+ onSelectedCollectionsChange: (value) => updateProp("selectedCollections", value),
10871
+ onAdminAddressChange: (value) => updateProp("adminAddress", value)
10872
+ }
10873
+ )
10874
+ }
10875
+ ],
10876
+ context: { editor, block }
10877
+ }
10878
+ )
10879
+ );
10880
+ };
10881
+
10882
+ // src/mantine/blocks/bid/template/TemplateView.tsx
10883
+ var BID_TEMPLATE_PANEL_ID = "bid-template-panel";
10884
+ var BidTemplateView = ({ editor, block }) => {
10885
+ const panelId = `${BID_TEMPLATE_PANEL_ID}-${block.id}`;
10886
+ const panelContent = useMemo25(() => /* @__PURE__ */ React123.createElement(TemplateConfig7, { editor, block }), [editor, block]);
10887
+ const { open } = usePanel(panelId, panelContent);
10888
+ const selectedCollectionsCount = useMemo25(() => {
10889
+ try {
10890
+ const parsed = JSON.parse(block.props.selectedCollections || "[]");
10891
+ return parsed.length;
10892
+ } catch {
10893
+ return 0;
10894
+ }
10895
+ }, [block.props.selectedCollections]);
10896
+ const didDisplay = block.props.did ? `${block.props.did.substring(0, 15)}...${block.props.did.substring(block.props.did.length - 10)}` : "No DID configured";
10897
+ return /* @__PURE__ */ React123.createElement(Card25, { withBorder: true, padding: "md", radius: "md", style: { width: "100%", cursor: "pointer", position: "relative" }, onClick: open }, /* @__PURE__ */ React123.createElement(Badge17, { size: "xs", variant: "light", color: "gray", style: { position: "absolute", top: 8, right: 8 } }, "Template"), /* @__PURE__ */ React123.createElement(Group39, { wrap: "nowrap", justify: "space-between", align: "center" }, /* @__PURE__ */ React123.createElement(Group39, { wrap: "nowrap", align: "center" }, /* @__PURE__ */ React123.createElement(ActionIcon24, { variant: "light", color: "blue", size: "lg", radius: "xl", style: { flexShrink: 0 } }, getIcon("dollar-sign", 18, 1.5)), /* @__PURE__ */ React123.createElement(Stack89, { gap: "xs", style: { flex: 1 } }, /* @__PURE__ */ React123.createElement(Text64, { fw: 500, size: "sm", contentEditable: false }, "Bid Block"), /* @__PURE__ */ React123.createElement(Text64, { size: "xs", c: "dimmed", contentEditable: false }, block.props.did ? didDisplay : "Configure bid settings"), selectedCollectionsCount > 0 && /* @__PURE__ */ React123.createElement(Text64, { size: "xs", c: "blue", contentEditable: false }, selectedCollectionsCount, " collection", selectedCollectionsCount !== 1 ? "s" : "", " selected")))));
10898
+ };
10899
+
10900
+ // src/mantine/blocks/bid/flow/FlowView.tsx
10901
+ import React128, { useState as useState40, useEffect as useEffect29, useMemo as useMemo30, useCallback as useCallback28 } from "react";
10902
+ import { Stack as Stack94, Text as Text69, Loader as Loader15, Center as Center8, Alert as Alert17, Title as Title15, Flex as Flex23, ActionIcon as ActionIcon27 } from "@mantine/core";
10903
+ import { IconSettings as IconSettings4, IconRefresh as IconRefresh3, IconAlertCircle as IconAlertCircle6 } from "@tabler/icons-react";
10904
+
10905
+ // src/mantine/blocks/bid/flow/ClaimCollectionsList.tsx
10906
+ import React127, { useMemo as useMemo29, useState as useState39, useEffect as useEffect28 } from "react";
10907
+ import { Stack as Stack93, Text as Text68, Button as Button31, Menu as Menu2, Badge as Badge20, Collapse as Collapse4, Loader as Loader14, Center as Center7, ActionIcon as ActionIcon26 } from "@mantine/core";
10908
+ import { IconChevronDown as IconChevronDown4, IconArrowDown as IconArrowDown3, IconArrowUp as IconArrowUp3 } from "@tabler/icons-react";
10909
+
10910
+ // src/mantine/blocks/bid/flow/BidSurveyPanel.tsx
10911
+ import React124, { useMemo as useMemo26, useState as useState36, useEffect as useEffect25, useCallback as useCallback26 } from "react";
10912
+ import { Paper as Paper15, CloseButton as CloseButton11, Title as Title13, Loader as Loader11, Stack as Stack90, Text as Text65 } from "@mantine/core";
10913
+ import { Survey as Survey2, SurveyModel as SurveyModel2 } from "@ixo/surveys";
10914
+ var SURVEY_THEME_VARIABLES = Object.entries(surveyTheme.cssVariables ?? {}).reduce((acc, [key, value]) => {
10915
+ acc[key] = value;
10916
+ return acc;
10917
+ }, {});
10918
+ var SURVEY_THEME_BACKGROUND = SURVEY_THEME_VARIABLES["--sjs-general-backcolor"] ?? "#050505";
10919
+ var SURVEY_THEME_FOREGROUND = SURVEY_THEME_VARIABLES["--sjs-general-forecolor"] ?? "#ffffff";
10920
+ var BidSurveyPanel = ({ deedId, collectionId, role, onSubmitComplete }) => {
10921
+ const { closePanel } = usePanelStore();
10922
+ const handlers = useBlocknoteHandlers();
10923
+ const [surveyJson, setSurveyJson] = useState36(null);
10924
+ const [loading, setLoading] = useState36(true);
10925
+ const [error, setError] = useState36(null);
10926
+ const roleLabel = role === "service_agent" ? "Service Agent" : "Evaluation Agent";
10927
+ useEffect25(() => {
10928
+ const fetchSurveyTemplate = async () => {
10929
+ try {
10930
+ setLoading(true);
10931
+ setError(null);
10932
+ const result = role === "service_agent" ? await handlers.getBidContributorSurveyTemplate(deedId) : await handlers.getBidEvaluatorSurveyTemplate(deedId);
10933
+ if (result) {
10934
+ setSurveyJson(result.surveyTemplate);
10935
+ } else {
10936
+ setError("No survey template found for this role");
10937
+ }
10938
+ } catch (err) {
10939
+ console.error("Error fetching survey template:", err);
10940
+ setError(err instanceof Error ? err.message : "Failed to load survey template");
10941
+ } finally {
10942
+ setLoading(false);
10943
+ }
10944
+ };
10945
+ fetchSurveyTemplate();
10946
+ }, [deedId, role, handlers]);
10947
+ const surveyModel = useMemo26(() => {
10948
+ if (!surveyJson) return null;
10949
+ const model = new SurveyModel2(surveyJson);
10950
+ model.applyTheme(surveyTheme);
10951
+ model.showQuestionNumbers = "off";
10952
+ model.questionsOnPageMode = "singlePage";
10953
+ return model;
10954
+ }, [surveyJson]);
10955
+ const surveyContainerStyle = useMemo26(
10956
+ () => ({
10957
+ flex: 1,
10958
+ overflow: "auto",
10959
+ backgroundColor: SURVEY_THEME_BACKGROUND,
10960
+ color: SURVEY_THEME_FOREGROUND,
10961
+ ...SURVEY_THEME_VARIABLES
10962
+ }),
10963
+ []
10964
+ );
10965
+ const handleSurveyComplete = useCallback26(
10966
+ async (sender) => {
10967
+ const surveyData = sender.data;
10968
+ console.log("Survey completed:", surveyData);
10969
+ try {
10970
+ const bidRole = role === "service_agent" ? "SA" /* serviceProviders */ : "EA" /* evaluators */;
10971
+ await handlers.submitBid({
10972
+ collectionId,
10973
+ role: bidRole,
10974
+ surveyAnswers: surveyData
10975
+ });
10976
+ console.log("Bid submitted successfully");
10977
+ closePanel();
10978
+ onSubmitComplete?.();
10979
+ } catch (error2) {
10980
+ console.error("Failed to submit bid:", error2);
10981
+ setError(error2 instanceof Error ? error2.message : "Failed to submit bid");
10982
+ }
10983
+ },
10984
+ [handlers, collectionId, role, closePanel, onSubmitComplete]
10985
+ );
10986
+ useEffect25(() => {
10987
+ if (surveyModel) {
10988
+ surveyModel.onComplete.add(handleSurveyComplete);
10989
+ return () => {
10990
+ surveyModel.onComplete.remove(handleSurveyComplete);
10991
+ };
10992
+ }
10993
+ return void 0;
10994
+ }, [surveyModel, handleSurveyComplete]);
10995
+ return /* @__PURE__ */ React124.createElement(
10996
+ Paper15,
10997
+ {
10998
+ p: "md",
10999
+ shadow: "sm",
11000
+ style: {
11001
+ height: "100%",
11002
+ display: "flex",
11003
+ flexDirection: "column"
11004
+ }
11005
+ },
11006
+ /* @__PURE__ */ React124.createElement(
11007
+ "div",
11008
+ {
11009
+ style: {
11010
+ display: "flex",
11011
+ justifyContent: "space-between",
11012
+ alignItems: "center",
11013
+ marginBottom: "1rem"
11014
+ }
11015
+ },
11016
+ /* @__PURE__ */ React124.createElement(Title13, { order: 3 }, roleLabel, " Application"),
11017
+ /* @__PURE__ */ React124.createElement(CloseButton11, { onClick: closePanel })
11018
+ ),
11019
+ /* @__PURE__ */ React124.createElement("div", { style: surveyContainerStyle }, loading && /* @__PURE__ */ React124.createElement(Stack90, { align: "center", justify: "center", style: { height: "100%" } }, /* @__PURE__ */ React124.createElement(Loader11, { size: "lg" }), /* @__PURE__ */ React124.createElement(Text65, { size: "sm", c: "dimmed" }, "Loading survey template...")), error && /* @__PURE__ */ React124.createElement(Stack90, { align: "center", justify: "center", style: { height: "100%", padding: "1rem" } }, /* @__PURE__ */ React124.createElement(Text65, { size: "sm", c: "red" }, error)), !loading && !error && surveyModel && /* @__PURE__ */ React124.createElement(Survey2, { model: surveyModel }))
11020
+ );
11021
+ };
11022
+
11023
+ // src/mantine/blocks/bid/flow/BidsList.tsx
11024
+ import React126, { useState as useState38, useEffect as useEffect27, useMemo as useMemo28, useCallback as useCallback27 } from "react";
11025
+ import { Stack as Stack92, Text as Text67, Loader as Loader13, Center as Center6, Alert as Alert16, Badge as Badge19, Group as Group41, ActionIcon as ActionIcon25 } from "@mantine/core";
11026
+ import { IconAlertCircle as IconAlertCircle5, IconArrowRight as IconArrowRight3 } from "@tabler/icons-react";
11027
+
11028
+ // src/mantine/blocks/bid/flow/BidViewPanel.tsx
11029
+ import React125, { useMemo as useMemo27, useState as useState37, useEffect as useEffect26 } from "react";
11030
+ import { Paper as Paper16, CloseButton as CloseButton12, Title as Title14, Loader as Loader12, Stack as Stack91, Text as Text66, Badge as Badge18, Button as Button30, Group as Group40, Modal as Modal2, Textarea as Textarea24, Alert as Alert15 } from "@mantine/core";
11031
+ import { Survey as Survey3, SurveyModel as SurveyModel3 } from "@ixo/surveys";
11032
+ import { IconCheck as IconCheck2, IconX as IconX4, IconAlertCircle as IconAlertCircle4 } from "@tabler/icons-react";
11033
+ var SURVEY_THEME_VARIABLES2 = Object.entries(surveyTheme.cssVariables ?? {}).reduce((acc, [key, value]) => {
11034
+ acc[key] = value;
11035
+ return acc;
11036
+ }, {});
11037
+ var SURVEY_THEME_BACKGROUND2 = SURVEY_THEME_VARIABLES2["--sjs-general-backcolor"] ?? "#050505";
11038
+ var SURVEY_THEME_FOREGROUND2 = SURVEY_THEME_VARIABLES2["--sjs-general-forecolor"] ?? "#ffffff";
11039
+ var BidViewPanel = ({ bid, deedId, adminAddress, onRefresh }) => {
11040
+ const { closePanel } = usePanelStore();
11041
+ const handlers = useBlocknoteHandlers();
11042
+ const [surveyJson, setSurveyJson] = useState37(null);
11043
+ const [loading, setLoading] = useState37(true);
11044
+ const [error, setError] = useState37(null);
11045
+ const [actionLoading, setActionLoading] = useState37(false);
11046
+ const [actionError, setActionError] = useState37(null);
11047
+ const [rejectModalOpen, setRejectModalOpen] = useState37(false);
11048
+ const [rejectReason, setRejectReason] = useState37("");
11049
+ useEffect26(() => {
11050
+ const fetchSurveyTemplate = async () => {
11051
+ try {
11052
+ setLoading(true);
11053
+ setError(null);
11054
+ let result;
11055
+ if (bid.role === "service_agent" || bid.role === "SA") {
11056
+ result = await handlers.getBidContributorSurveyTemplate(deedId);
11057
+ } else if (bid.role === "evaluation_agent" || bid.role === "EA") {
11058
+ result = await handlers.getBidEvaluatorSurveyTemplate(deedId);
11059
+ } else {
11060
+ setError(`Unknown role: ${bid.role}`);
11061
+ setLoading(false);
11062
+ return;
11063
+ }
11064
+ if (result) {
11065
+ setSurveyJson(result.surveyTemplate);
11066
+ } else {
11067
+ setError("No survey template found for this role");
11068
+ }
11069
+ } catch (err) {
11070
+ console.error("Error fetching survey template:", err);
11071
+ setError(err instanceof Error ? err.message : "Failed to load survey template");
11072
+ } finally {
11073
+ setLoading(false);
11074
+ }
11075
+ };
11076
+ fetchSurveyTemplate();
11077
+ }, [deedId, bid.role, handlers]);
11078
+ const surveyModel = useMemo27(() => {
11079
+ if (!surveyJson) return null;
11080
+ const model = new SurveyModel3(surveyJson);
11081
+ model.applyTheme(surveyTheme);
11082
+ model.showQuestionNumbers = "off";
11083
+ model.questionsOnPageMode = "singlePage";
11084
+ model.mode = "display";
11085
+ let bidData;
11086
+ try {
11087
+ bidData = typeof bid.data === "string" ? JSON.parse(bid.data) : bid.data;
11088
+ } catch {
11089
+ bidData = bid.data;
11090
+ }
11091
+ model.data = bidData;
11092
+ return model;
11093
+ }, [surveyJson, bid.data]);
11094
+ const surveyContainerStyle = useMemo27(
11095
+ () => ({
11096
+ flex: 1,
11097
+ overflow: "auto",
11098
+ backgroundColor: SURVEY_THEME_BACKGROUND2,
11099
+ color: SURVEY_THEME_FOREGROUND2,
11100
+ ...SURVEY_THEME_VARIABLES2
11101
+ }),
11102
+ []
11103
+ );
11104
+ const getRoleLabel = (role) => {
11105
+ if (role === "service_agent" || role === "SA") return "Service Agent";
11106
+ if (role === "evaluation_agent" || role === "EA") return "Evaluation Agent";
11107
+ return role;
11108
+ };
11109
+ const getRoleBadge = (role) => {
11110
+ const roleConfig = {
11111
+ service_agent: { color: "blue", label: "Service Agent" },
11112
+ SA: { color: "blue", label: "Service Agent" },
11113
+ evaluation_agent: { color: "green", label: "Evaluation Agent" },
11114
+ EA: { color: "green", label: "Evaluation Agent" }
11115
+ };
11116
+ const config = roleConfig[role] || { color: "gray", label: role };
11117
+ return /* @__PURE__ */ React125.createElement(Badge18, { size: "sm", color: config.color }, config.label);
11118
+ };
11119
+ const handleApproveBid = async () => {
11120
+ try {
11121
+ setActionLoading(true);
11122
+ setActionError(null);
11123
+ if (bid.role === "service_agent" || bid.role === "SA") {
11124
+ await handlers.approveServiceAgentApplication({
11125
+ adminAddress,
11126
+ collectionId: bid.collection,
11127
+ agentQuota: 30,
11128
+ deedDid: deedId,
11129
+ currentUserAddress: bid.address
11130
+ });
11131
+ } else if (bid.role === "evaluation_agent" || bid.role === "EA") {
11132
+ await handlers.approveEvaluatorApplication({
11133
+ adminAddress,
11134
+ collectionId: bid.collection,
11135
+ deedDid: deedId,
11136
+ evaluatorAddress: bid.address,
11137
+ agentQuota: 10
11138
+ });
11139
+ } else {
11140
+ throw new Error(`Unknown role: ${bid.role}`);
11141
+ }
11142
+ await handlers.approveBid({
11143
+ bidId: bid.id,
11144
+ collectionId: bid.collection,
11145
+ did: bid.did
11146
+ });
11147
+ closePanel();
11148
+ onRefresh?.();
11149
+ } catch (err) {
11150
+ console.error("Error approving bid:", err);
11151
+ setActionError(err instanceof Error ? err.message : "Failed to approve bid");
11152
+ } finally {
11153
+ setActionLoading(false);
11154
+ }
11155
+ };
11156
+ const handleRejectBid = async () => {
11157
+ if (!rejectReason.trim()) {
11158
+ setActionError("Please provide a reason for rejection");
11159
+ return;
11160
+ }
11161
+ try {
11162
+ setActionLoading(true);
11163
+ setActionError(null);
11164
+ await handlers.rejectBid({
11165
+ bidId: bid.id,
11166
+ collectionId: bid.collection,
11167
+ did: deedId,
11168
+ reason: rejectReason
11169
+ });
11170
+ setRejectModalOpen(false);
11171
+ closePanel();
11172
+ onRefresh?.();
11173
+ } catch (err) {
11174
+ console.error("Error rejecting bid:", err);
11175
+ setActionError(err instanceof Error ? err.message : "Failed to reject bid");
11176
+ } finally {
11177
+ setActionLoading(false);
11178
+ }
11179
+ };
11180
+ const openRejectModal = () => {
11181
+ setRejectReason("");
11182
+ setActionError(null);
11183
+ setRejectModalOpen(true);
11184
+ };
11185
+ return /* @__PURE__ */ React125.createElement(
11186
+ Paper16,
11187
+ {
11188
+ p: "md",
11189
+ shadow: "sm",
11190
+ style: {
11191
+ height: "100%",
11192
+ display: "flex",
11193
+ flexDirection: "column"
11194
+ }
11195
+ },
11196
+ /* @__PURE__ */ React125.createElement(
11197
+ "div",
11198
+ {
11199
+ style: {
11200
+ display: "flex",
11201
+ justifyContent: "space-between",
11202
+ alignItems: "center",
11203
+ marginBottom: "1rem"
11204
+ }
11205
+ },
11206
+ /* @__PURE__ */ React125.createElement(Stack91, { gap: "xs" }, /* @__PURE__ */ React125.createElement(Title14, { order: 3 }, getRoleLabel(bid.role), " Bid"), getRoleBadge(bid.role)),
11207
+ /* @__PURE__ */ React125.createElement(CloseButton12, { onClick: closePanel })
11208
+ ),
11209
+ !loading && !error && /* @__PURE__ */ React125.createElement(Stack91, { gap: "md", mb: "md" }, actionError && /* @__PURE__ */ React125.createElement(Alert15, { color: "red", icon: /* @__PURE__ */ React125.createElement(IconAlertCircle4, { size: 16 }), onClose: () => setActionError(null), withCloseButton: true }, actionError), /* @__PURE__ */ React125.createElement(Group40, { justify: "flex-end" }, /* @__PURE__ */ React125.createElement(Button30, { variant: "outline", color: "red", leftSection: /* @__PURE__ */ React125.createElement(IconX4, { size: 16 }), onClick: openRejectModal, loading: actionLoading, disabled: actionLoading }, "Reject"), /* @__PURE__ */ React125.createElement(Button30, { variant: "filled", color: "green", leftSection: /* @__PURE__ */ React125.createElement(IconCheck2, { size: 16 }), onClick: handleApproveBid, loading: actionLoading, disabled: actionLoading }, "Approve"))),
11210
+ /* @__PURE__ */ React125.createElement("div", { style: surveyContainerStyle }, loading && /* @__PURE__ */ React125.createElement(Stack91, { align: "center", justify: "center", style: { height: "100%" } }, /* @__PURE__ */ React125.createElement(Loader12, { size: "lg" }), /* @__PURE__ */ React125.createElement(Text66, { size: "sm", c: "dimmed" }, "Loading bid details...")), error && /* @__PURE__ */ React125.createElement(Stack91, { align: "center", justify: "center", style: { height: "100%", padding: "1rem" } }, /* @__PURE__ */ React125.createElement(Text66, { size: "sm", c: "red" }, error)), !loading && !error && surveyModel && /* @__PURE__ */ React125.createElement(Survey3, { model: surveyModel })),
11211
+ /* @__PURE__ */ React125.createElement(Modal2, { opened: rejectModalOpen, onClose: () => setRejectModalOpen(false), title: "Reject Bid", centered: true }, /* @__PURE__ */ React125.createElement(Stack91, { gap: "md" }, /* @__PURE__ */ React125.createElement(Text66, { size: "sm" }, "Please provide a reason for rejecting this bid:"), /* @__PURE__ */ React125.createElement(Textarea24, { placeholder: "Enter rejection reason...", value: rejectReason, onChange: (e) => setRejectReason(e.currentTarget.value), minRows: 3 }), /* @__PURE__ */ React125.createElement(Group40, { justify: "flex-end" }, /* @__PURE__ */ React125.createElement(Button30, { variant: "outline", onClick: () => setRejectModalOpen(false), disabled: actionLoading }, "Cancel"), /* @__PURE__ */ React125.createElement(Button30, { color: "red", onClick: handleRejectBid, loading: actionLoading, disabled: !rejectReason.trim() }, "Reject Bid"))))
11212
+ );
11213
+ };
11214
+
11215
+ // src/mantine/blocks/bid/flow/BidsList.tsx
11216
+ var BidItem = ({ bid, deedId, adminAddress, onRefresh }) => {
11217
+ const handlers = useBlocknoteHandlers();
11218
+ const [userProfile, setUserProfile] = useState38(null);
11219
+ const [loadingProfile, setLoadingProfile] = useState38(false);
11220
+ useEffect27(() => {
11221
+ const fetchUserProfile = async () => {
11222
+ if (!bid.did) return;
11223
+ try {
11224
+ setLoadingProfile(true);
11225
+ const profile = await handlers.getMatrixInfoPerDid(bid.did);
11226
+ setUserProfile(profile);
11227
+ } catch (error) {
11228
+ console.error("Failed to fetch user profile:", error);
11229
+ } finally {
11230
+ setLoadingProfile(false);
11231
+ }
11232
+ };
11233
+ fetchUserProfile();
11234
+ }, [bid.did, handlers]);
11235
+ const bidPanelId = `bid-view-${bid.id}`;
11236
+ const bidPanelContent = useMemo28(() => /* @__PURE__ */ React126.createElement(BidViewPanel, { bid, deedId, adminAddress, onRefresh }), [bid, deedId, adminAddress, onRefresh]);
11237
+ const { open: openBidPanel } = usePanel(bidPanelId, bidPanelContent);
11238
+ const displayName = userProfile?.displayname || bid.did;
11239
+ const getRoleBadge = (role) => {
11240
+ const roleConfig = {
11241
+ service_agent: { color: "blue", label: "Service Agent" },
11242
+ SA: { color: "blue", label: "Service Agent" },
11243
+ evaluation_agent: { color: "green", label: "Evaluation Agent" },
11244
+ EA: { color: "green", label: "Evaluation Agent" }
11245
+ };
11246
+ const config = roleConfig[role] || { color: "gray", label: role };
11247
+ return /* @__PURE__ */ React126.createElement(Badge19, { size: "xs", variant: "light", color: config.color }, config.label);
11248
+ };
11249
+ const getStatusBadge = (status) => {
11250
+ const statusConfig = {
11251
+ pending: { color: "yellow", label: "Pending" },
11252
+ approved: { color: "green", label: "Approved" },
11253
+ rejected: { color: "red", label: "Rejected" }
11254
+ };
11255
+ const config = statusConfig[status] || { color: "gray", label: status };
11256
+ return /* @__PURE__ */ React126.createElement(Badge19, { size: "sm", color: config.color }, config.label);
11257
+ };
11258
+ const formatDate = (dateString) => {
11259
+ try {
11260
+ const date = new Date(dateString);
11261
+ return date.toLocaleDateString(void 0, {
11262
+ year: "numeric",
11263
+ month: "short",
11264
+ day: "numeric"
11265
+ });
11266
+ } catch {
11267
+ return dateString;
11268
+ }
11269
+ };
11270
+ const displayDate = bid.created || "";
11271
+ const displayStatus = bid.status;
11272
+ const displayReason = bid.reason;
11273
+ return /* @__PURE__ */ React126.createElement(ListItemContainer, null, /* @__PURE__ */ React126.createElement(Stack92, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React126.createElement(Group41, { gap: "xs" }, /* @__PURE__ */ React126.createElement(Text67, { size: "xs", fw: 500 }, loadingProfile ? "Loading..." : displayName), userProfile?.verified && /* @__PURE__ */ React126.createElement(Text67, { size: "xs", c: "blue", fw: 600, title: "Verified user" }, "\u2713"), getRoleBadge(bid.role)), /* @__PURE__ */ React126.createElement(Text67, { size: "xs", c: "dimmed" }, "Submitted: ", formatDate(displayDate)), displayStatus === "rejected" && displayReason && /* @__PURE__ */ React126.createElement(Text67, { size: "xs", c: "red" }, "Reason: ", displayReason)), /* @__PURE__ */ React126.createElement(Group41, { gap: "xs" }, displayStatus && getStatusBadge(displayStatus), /* @__PURE__ */ React126.createElement(ActionIcon25, { variant: "subtle", size: "lg", onClick: openBidPanel }, /* @__PURE__ */ React126.createElement(IconArrowRight3, { size: 20 }))));
11274
+ };
11275
+ var BidsList = ({ collectionId, deedId, adminAddress, onRefresh }) => {
11276
+ const handlers = useBlocknoteHandlers();
11277
+ const [bids, setBids] = useState38([]);
11278
+ const [loading, setLoading] = useState38(true);
11279
+ const [error, setError] = useState38(null);
11280
+ const fetchBids = useCallback27(async () => {
11281
+ if (!collectionId) {
11282
+ setLoading(false);
11283
+ return;
11284
+ }
11285
+ try {
11286
+ setLoading(true);
11287
+ setError(null);
11288
+ const response = await handlers.queryBids({ collectionId });
11289
+ setBids(response?.data || []);
11290
+ } catch (err) {
11291
+ console.error("Error fetching bids:", err);
11292
+ setError(err instanceof Error ? err.message : "Failed to fetch bids");
11293
+ setBids([]);
11294
+ } finally {
11295
+ setLoading(false);
11296
+ }
11297
+ }, [collectionId, handlers]);
11298
+ useEffect27(() => {
11299
+ fetchBids();
11300
+ }, [fetchBids]);
11301
+ const handleRefresh = useCallback27(() => {
11302
+ fetchBids();
11303
+ onRefresh();
11304
+ }, [fetchBids, onRefresh]);
11305
+ if (loading) {
11306
+ return /* @__PURE__ */ React126.createElement(Center6, { py: "md" }, /* @__PURE__ */ React126.createElement(Loader13, { size: "sm" }));
11307
+ }
11308
+ if (error) {
11309
+ return /* @__PURE__ */ React126.createElement(Alert16, { color: "red", icon: /* @__PURE__ */ React126.createElement(IconAlertCircle5, { size: 16 }), py: "xs" }, /* @__PURE__ */ React126.createElement(Text67, { size: "xs" }, error));
11310
+ }
11311
+ if (!bids || bids.length === 0) {
11312
+ return /* @__PURE__ */ React126.createElement(Text67, { size: "xs", c: "dimmed", ta: "center", py: "sm" }, "No bids submitted yet");
11313
+ }
11314
+ return /* @__PURE__ */ React126.createElement(Stack92, { gap: "xs", pl: "md" }, bids.map((bid) => /* @__PURE__ */ React126.createElement(BidItem, { key: bid.id, bid, deedId, adminAddress, onRefresh: handleRefresh })));
11315
+ };
11316
+
11317
+ // src/mantine/blocks/bid/flow/ClaimCollectionsList.tsx
11318
+ var CollectionItem2 = ({ collection, deedId, adminAddress, userRole, onRefresh }) => {
11319
+ const [isExpanded, setIsExpanded] = useState39(false);
11320
+ const getCollectionName = (collection2) => {
11321
+ return collection2.protocol?.profile?.name || collection2.name || "Unnamed Collection";
11322
+ };
11323
+ const getRoleBadge = (role) => {
11324
+ const roleConfig = {
11325
+ ["SA" /* ServiceProvider */]: { label: "Service Agent", color: "blue" },
11326
+ ["EA" /* Evaluator */]: { label: "Evaluation Agent", color: "green" },
11327
+ ["PO" /* Owner */]: { label: "Owner", color: "violet" },
11328
+ ["IA" /* Investor */]: { label: "Investor", color: "orange" }
11329
+ };
11330
+ const config = roleConfig[role] || { label: role, color: "gray" };
11331
+ return /* @__PURE__ */ React127.createElement(Badge20, { size: "sm", color: config.color }, config.label);
11332
+ };
11333
+ const serviceAgentPanelId = `bid-survey-${collection.id}-service_agent`;
11334
+ const serviceAgentPanelContent = useMemo29(
11335
+ () => /* @__PURE__ */ React127.createElement(
11336
+ BidSurveyPanel,
11337
+ {
11338
+ deedId,
11339
+ collectionId: collection.id,
11340
+ role: "service_agent",
11341
+ onSubmitComplete: onRefresh
11342
+ }
11343
+ ),
11344
+ [deedId, collection.id, onRefresh]
11345
+ );
11346
+ const { open: openServiceAgent } = usePanel(serviceAgentPanelId, serviceAgentPanelContent);
11347
+ const evaluationAgentPanelId = `bid-survey-${collection.id}-evaluation_agent`;
11348
+ const evaluationAgentPanelContent = useMemo29(
11349
+ () => /* @__PURE__ */ React127.createElement(
11350
+ BidSurveyPanel,
11351
+ {
11352
+ deedId,
11353
+ collectionId: collection.id,
11354
+ role: "evaluation_agent",
11355
+ onSubmitComplete: onRefresh
11356
+ }
11357
+ ),
11358
+ [deedId, collection.id, onRefresh]
11359
+ );
11360
+ const { open: openEvaluationAgent } = usePanel(evaluationAgentPanelId, evaluationAgentPanelContent);
11361
+ const renderActionButton = () => {
11362
+ if (userRole === "PO" /* Owner */) {
11363
+ return /* @__PURE__ */ React127.createElement(ActionIcon26, { variant: "subtle", size: "lg", onClick: () => setIsExpanded(!isExpanded) }, isExpanded ? /* @__PURE__ */ React127.createElement(IconArrowUp3, { size: 20 }) : /* @__PURE__ */ React127.createElement(IconArrowDown3, { size: 20 }));
11364
+ } else if (userRole === "SA" /* ServiceProvider */ || userRole === "EA" /* Evaluator */) {
11365
+ return getRoleBadge(userRole);
11366
+ } else {
11367
+ return /* @__PURE__ */ React127.createElement(Menu2, { shadow: "md", width: 200 }, /* @__PURE__ */ React127.createElement(Menu2.Target, null, /* @__PURE__ */ React127.createElement(Button31, { size: "xs", variant: "light", rightSection: /* @__PURE__ */ React127.createElement(IconChevronDown4, { size: 14 }) }, "Apply")), /* @__PURE__ */ React127.createElement(Menu2.Dropdown, null, /* @__PURE__ */ React127.createElement(Menu2.Label, null, "Select Role"), /* @__PURE__ */ React127.createElement(Menu2.Item, { onClick: openServiceAgent }, "Service Agent"), /* @__PURE__ */ React127.createElement(Menu2.Item, { onClick: openEvaluationAgent }, "Evaluation Agent")));
11368
+ }
11369
+ };
11370
+ return /* @__PURE__ */ React127.createElement(Stack93, { gap: "xs" }, /* @__PURE__ */ React127.createElement(ListItemContainer, null, /* @__PURE__ */ React127.createElement(Stack93, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React127.createElement(Text68, { size: "sm", fw: 500 }, getCollectionName(collection)), collection.description && /* @__PURE__ */ React127.createElement(Text68, { size: "xs", c: "dimmed" }, collection.description)), renderActionButton()), userRole === "PO" /* Owner */ && /* @__PURE__ */ React127.createElement(Collapse4, { in: isExpanded }, /* @__PURE__ */ React127.createElement(BidsList, { collectionId: collection.id, deedId, adminAddress, onRefresh })));
11371
+ };
11372
+ var ClaimCollectionsList2 = ({ collections, deedId, adminAddress, userAddress, onRefresh }) => {
11373
+ const handlers = useBlocknoteHandlers();
11374
+ const [userRoles, setUserRoles] = useState39({});
11375
+ const [loadingRoles, setLoadingRoles] = useState39(true);
11376
+ useEffect28(() => {
11377
+ const fetchUserRoles = async () => {
11378
+ if (!collections || collections.length === 0 || !userAddress || !adminAddress) {
11379
+ setLoadingRoles(false);
11380
+ return;
11381
+ }
11382
+ try {
11383
+ setLoadingRoles(true);
11384
+ const collectionIds = collections.map((c) => c.id);
11385
+ const roles = await handlers.getUserRoles({
11386
+ userAddress,
11387
+ adminAddress,
11388
+ deedDid: deedId,
11389
+ collectionIds
11390
+ });
11391
+ const rolesMap = {};
11392
+ collections.forEach((collection) => {
11393
+ const roleData = roles?.find((r) => r.collectionId === collection.id);
11394
+ rolesMap[collection.id] = roleData?.role || null;
11395
+ });
11396
+ setUserRoles(rolesMap);
11397
+ } catch (error) {
11398
+ console.error("Error fetching user roles:", error);
11399
+ const rolesMap = {};
11400
+ collections.forEach((collection) => {
11401
+ rolesMap[collection.id] = null;
11402
+ });
11403
+ setUserRoles(rolesMap);
11404
+ } finally {
11405
+ setLoadingRoles(false);
11406
+ }
11407
+ };
11408
+ fetchUserRoles();
11409
+ }, [collections, userAddress, adminAddress, handlers, deedId]);
11410
+ if (!collections || collections.length === 0) {
11411
+ return /* @__PURE__ */ React127.createElement(Text68, { size: "sm", c: "dimmed", ta: "center", py: "md" }, "No claim collections found");
11412
+ }
11413
+ if (loadingRoles) {
11414
+ return /* @__PURE__ */ React127.createElement(Center7, { py: "md" }, /* @__PURE__ */ React127.createElement(Loader14, { size: "sm" }));
11415
+ }
11416
+ return /* @__PURE__ */ React127.createElement(Stack93, { gap: "md", px: 5 }, collections.map((collection) => /* @__PURE__ */ React127.createElement(CollectionItem2, { key: collection.id, collection, deedId, adminAddress, userRole: userRoles[collection.id] || null, onRefresh })));
11417
+ };
11418
+
11419
+ // src/mantine/blocks/bid/flow/FlowView.tsx
11420
+ var BID_FLOW_PANEL_ID = "bid-flow-panel";
11421
+ var BidFlowView = ({ editor, block }) => {
11422
+ const { editable } = useBlocknoteContext();
11423
+ const handlers = useBlocknoteHandlers();
11424
+ const [collections, setCollections] = useState40([]);
11425
+ const [loading, setLoading] = useState40(false);
11426
+ const [error, setError] = useState40(null);
11427
+ const [userAddress, setUserAddress] = useState40("");
11428
+ const panelId = `${BID_FLOW_PANEL_ID}-${block.id}`;
11429
+ const panelContent = useMemo30(() => /* @__PURE__ */ React128.createElement(TemplateConfig7, { editor, block }), [editor, block]);
11430
+ const { open } = usePanel(panelId, panelContent);
11431
+ const selectedCollectionIds = useMemo30(() => {
11432
+ try {
11433
+ return JSON.parse(block.props.selectedCollections || "[]");
11434
+ } catch {
11435
+ return [];
11436
+ }
11437
+ }, [block.props.selectedCollections]);
11438
+ const did = block.props.did;
11439
+ const adminAddress = block.props.adminAddress || "";
11440
+ useEffect29(() => {
11441
+ const fetchUserAddress = () => {
11442
+ try {
11443
+ const user = handlers.getCurrentUser();
11444
+ setUserAddress(user?.address || "");
11445
+ } catch (err) {
11446
+ console.error("Error fetching current user:", err);
11447
+ setUserAddress("");
11448
+ }
11449
+ };
11450
+ fetchUserAddress();
11451
+ }, [handlers]);
11452
+ const fetchCollections = useCallback28(async () => {
11453
+ if (!did || selectedCollectionIds.length === 0) {
11454
+ setCollections([]);
11455
+ return;
11456
+ }
11457
+ setLoading(true);
11458
+ setError(null);
11459
+ try {
11460
+ const response = await handlers.getClaimCollections({ deedDid: did });
11461
+ const { adminAddress: adminAddress2, collections: allCollections } = response || { adminAddress: "", collections: [] };
11462
+ if (adminAddress2 && (!block.props.adminAddress || block.props.adminAddress === "")) {
11463
+ editor.updateBlock(block, {
11464
+ props: {
11465
+ ...block.props,
11466
+ adminAddress: adminAddress2
11467
+ }
11468
+ });
11469
+ }
11470
+ const selectedCollections = (allCollections || []).filter((c) => selectedCollectionIds.includes(c?.id));
11471
+ setCollections(selectedCollections);
11472
+ } catch (err) {
11473
+ console.error("Error fetching collections:", err);
11474
+ setError(err instanceof Error ? err.message : "Failed to fetch collections");
11475
+ } finally {
11476
+ setLoading(false);
11477
+ }
11478
+ }, [did, selectedCollectionIds, handlers, editor, block]);
11479
+ useEffect29(() => {
11480
+ fetchCollections();
11481
+ }, [fetchCollections]);
11482
+ if (!did) {
11483
+ return /* @__PURE__ */ React128.createElement(Center8, { py: "xl" }, /* @__PURE__ */ React128.createElement(Text69, { size: "sm", c: "dimmed" }, "Please configure the bid block in template mode first"));
11484
+ }
11485
+ if (selectedCollectionIds.length === 0) {
11486
+ return /* @__PURE__ */ React128.createElement(Center8, { py: "xl" }, /* @__PURE__ */ React128.createElement(Text69, { size: "sm", c: "dimmed" }, "No claim collections selected"));
11487
+ }
11488
+ return /* @__PURE__ */ React128.createElement(Stack94, { w: "100%" }, /* @__PURE__ */ React128.createElement(Flex23, { px: 5, align: "center", justify: "space-between" }, /* @__PURE__ */ React128.createElement(Title15, { order: 4 }, "Bid Application"), /* @__PURE__ */ React128.createElement(Flex23, { gap: "xs" }, /* @__PURE__ */ React128.createElement(ActionIcon27, { variant: "subtle", size: "sm", onClick: fetchCollections, loading }, /* @__PURE__ */ React128.createElement(IconRefresh3, { size: 18 })), editable && /* @__PURE__ */ React128.createElement(ActionIcon27, { variant: "subtle", size: "sm", onClick: open }, /* @__PURE__ */ React128.createElement(IconSettings4, { size: 18 })))), loading ? /* @__PURE__ */ React128.createElement(Center8, { py: "xl" }, /* @__PURE__ */ React128.createElement(Loader15, { size: "md" })) : error ? /* @__PURE__ */ React128.createElement(Alert17, { color: "red", title: "Failed to load collections", icon: /* @__PURE__ */ React128.createElement(IconAlertCircle6, { size: 18 }) }, /* @__PURE__ */ React128.createElement(Text69, { size: "sm" }, error)) : /* @__PURE__ */ React128.createElement(ClaimCollectionsList2, { collections, deedId: did, adminAddress, userAddress, onRefresh: fetchCollections }));
11489
+ };
11490
+
11491
+ // src/mantine/blocks/bid/BidBlock.tsx
11492
+ function BidBlock({ editor, block }) {
11493
+ const { docType } = useBlocknoteContext();
11494
+ if (docType === "template") {
11495
+ return /* @__PURE__ */ React129.createElement(BidTemplateView, { editor, block });
11496
+ }
11497
+ return /* @__PURE__ */ React129.createElement(BidFlowView, { editor, block });
11498
+ }
11499
+
11500
+ // src/mantine/blocks/bid/BidBlockSpec.tsx
11501
+ var BidBlockSpec = createReactBlockSpec9(
11502
+ {
11503
+ type: "bid",
11504
+ propSchema: {
11505
+ title: { default: "" },
11506
+ description: { default: "" },
11507
+ did: { default: "" },
11508
+ selectedCollections: { default: "[]" },
11509
+ adminAddress: { default: "" }
11510
+ },
11511
+ content: "none"
11512
+ },
11513
+ {
11514
+ render: (props) => {
11515
+ const ixoProps = props;
11516
+ return /* @__PURE__ */ React130.createElement(BidBlock, { ...ixoProps });
11517
+ }
11518
+ }
11519
+ );
11520
+
11521
+ // src/mantine/blocks/evaluator/EvaluatorBlock.tsx
11522
+ import React137 from "react";
11523
+
11524
+ // src/mantine/blocks/evaluator/template/TemplateView.tsx
11525
+ import React133, { useMemo as useMemo32 } from "react";
11526
+ import { Card as Card26, Group as Group42, Stack as Stack96, Text as Text71, ActionIcon as ActionIcon28, Badge as Badge21 } from "@mantine/core";
11527
+
11528
+ // src/mantine/blocks/evaluator/template/TemplateConfig.tsx
11529
+ import React132, { useCallback as useCallback30 } from "react";
11530
+ import { Paper as Paper17, CloseButton as CloseButton13, Title as Title16 } from "@mantine/core";
11531
+
11532
+ // src/mantine/blocks/evaluator/template/GeneralTab.tsx
11533
+ import React131, { useEffect as useEffect30, useState as useState41, useCallback as useCallback29, useMemo as useMemo31 } from "react";
11534
+ import { Stack as Stack95, Text as Text70, TextInput as TextInput41, Textarea as Textarea25 } from "@mantine/core";
11535
+ var GeneralTab8 = ({
11536
+ title,
11537
+ description,
11538
+ deedDid,
11539
+ selectedCollections,
11540
+ adminAddress,
11541
+ onTitleChange,
11542
+ onDescriptionChange,
11543
+ onDeedDidChange,
11544
+ onSelectedCollectionsChange,
11545
+ onAdminAddressChange
11546
+ }) => {
11547
+ const [localTitle, setLocalTitle] = useState41(title || "");
11548
+ const [localDescription, setLocalDescription] = useState41(description || "");
11549
+ useEffect30(() => {
11550
+ setLocalTitle(title || "");
11551
+ }, [title]);
11552
+ useEffect30(() => {
11553
+ setLocalDescription(description || "");
11554
+ }, [description]);
11555
+ const parsedSelectedCollections = useMemo31(() => {
11556
+ try {
11557
+ return JSON.parse(selectedCollections || "[]");
11558
+ } catch {
11559
+ return [];
11560
+ }
11561
+ }, [selectedCollections]);
11562
+ const handleCollectionsChange = useCallback29(
11563
+ (collections) => {
11564
+ console.log("[Evaluator GeneralTab] handleCollectionsChange called with:", collections);
11565
+ const stringified = JSON.stringify(collections || []);
11566
+ console.log("[Evaluator GeneralTab] Stringified:", stringified);
11567
+ onSelectedCollectionsChange(stringified);
11568
+ },
11569
+ [onSelectedCollectionsChange]
11570
+ );
11571
+ const handleAdminAddressChange = useCallback29(
11572
+ (adminAddress2) => {
11573
+ if (onAdminAddressChange) {
11574
+ onAdminAddressChange(adminAddress2);
11575
+ }
11576
+ },
11577
+ [onAdminAddressChange]
11578
+ );
11579
+ return /* @__PURE__ */ React131.createElement(Stack95, { gap: "lg" }, /* @__PURE__ */ React131.createElement(Stack95, { gap: "xs" }, /* @__PURE__ */ React131.createElement(Text70, { size: "sm", fw: 600 }, "Title"), /* @__PURE__ */ React131.createElement(
11580
+ TextInput41,
11581
+ {
11582
+ placeholder: "e.g. Evaluator Title",
11583
+ value: localTitle,
11584
+ onChange: (event) => {
11585
+ const newTitle = event.currentTarget.value;
11586
+ setLocalTitle(newTitle);
11587
+ onTitleChange(newTitle);
11588
+ }
11589
+ }
11590
+ )), /* @__PURE__ */ React131.createElement(Stack95, { gap: "xs" }, /* @__PURE__ */ React131.createElement(Text70, { size: "sm", fw: 600 }, "Description"), /* @__PURE__ */ React131.createElement(
11591
+ Textarea25,
11592
+ {
11593
+ placeholder: "Describe what this evaluator block is about",
11594
+ minRows: 3,
11595
+ value: localDescription,
11596
+ onChange: (event) => {
11597
+ const newDescription = event.currentTarget.value;
11598
+ setLocalDescription(newDescription);
11599
+ onDescriptionChange(newDescription);
11600
+ }
11601
+ }
11602
+ )), /* @__PURE__ */ React131.createElement(
11603
+ CollectionSelector,
11604
+ {
11605
+ did: deedDid,
11606
+ selectedCollections: parsedSelectedCollections,
11607
+ onDidChange: onDeedDidChange,
11608
+ onCollectionsChange: handleCollectionsChange,
11609
+ onAdminAddressChange: handleAdminAddressChange,
11610
+ currentAdminAddress: adminAddress
11611
+ }
11612
+ ));
11613
+ };
11614
+
11615
+ // src/mantine/blocks/evaluator/template/TemplateConfig.tsx
11616
+ var TemplateConfig8 = ({ editor, block }) => {
11617
+ const { closePanel } = usePanelStore();
11618
+ const updateProp = useCallback30(
11619
+ (key, value) => {
11620
+ console.log("[Evaluator TemplateConfig] Updating prop:", key, value);
11621
+ editor.updateBlock(block, {
11622
+ props: {
11623
+ ...block.props,
11624
+ [key]: value
11625
+ }
11626
+ });
11627
+ },
11628
+ [editor, block]
11629
+ );
11630
+ return /* @__PURE__ */ React132.createElement(
11631
+ Paper17,
11632
+ {
11633
+ p: "md",
11634
+ shadow: "sm",
11635
+ style: {
11636
+ height: "100%",
11637
+ display: "flex",
11638
+ flexDirection: "column"
11639
+ }
11640
+ },
11641
+ /* @__PURE__ */ React132.createElement(
11642
+ "div",
11643
+ {
11644
+ style: {
11645
+ display: "flex",
11646
+ justifyContent: "space-between",
11647
+ alignItems: "center",
11648
+ marginBottom: "1rem"
11649
+ }
11650
+ },
11651
+ /* @__PURE__ */ React132.createElement(Title16, { order: 3 }, "Evaluator Settings"),
11652
+ /* @__PURE__ */ React132.createElement(CloseButton13, { onClick: closePanel })
11653
+ ),
11654
+ /* @__PURE__ */ React132.createElement(
11655
+ ReusablePanel,
11656
+ {
11657
+ extraTabs: [
11658
+ {
11659
+ label: "General",
11660
+ value: "general",
11661
+ content: /* @__PURE__ */ React132.createElement(
11662
+ GeneralTab8,
11663
+ {
11664
+ title: block.props.title || "",
11665
+ description: block.props.description || "",
11666
+ deedDid: block.props.deedDid || "",
11667
+ selectedCollections: block.props.selectedCollections || "[]",
11668
+ adminAddress: block.props.adminAddress || "",
11669
+ onTitleChange: (value) => updateProp("title", value),
11670
+ onDescriptionChange: (value) => updateProp("description", value),
11671
+ onDeedDidChange: (value) => updateProp("deedDid", value),
11672
+ onSelectedCollectionsChange: (value) => updateProp("selectedCollections", value),
11673
+ onAdminAddressChange: (value) => updateProp("adminAddress", value)
11674
+ }
11675
+ )
11676
+ }
11677
+ ],
11678
+ context: { editor, block }
11679
+ }
11680
+ )
11681
+ );
11682
+ };
11683
+
11684
+ // src/mantine/blocks/evaluator/template/TemplateView.tsx
11685
+ var EVALUATOR_TEMPLATE_PANEL_ID = "evaluator-template-panel";
11686
+ var EvaluatorTemplateView = ({ editor, block }) => {
11687
+ const panelId = `${EVALUATOR_TEMPLATE_PANEL_ID}-${block.id}`;
11688
+ const panelContent = useMemo32(() => /* @__PURE__ */ React133.createElement(TemplateConfig8, { editor, block }), [editor, block]);
11689
+ const { open } = usePanel(panelId, panelContent);
11690
+ return /* @__PURE__ */ React133.createElement(Card26, { withBorder: true, padding: "md", radius: "md", style: { width: "100%", cursor: "pointer", position: "relative" }, onClick: open }, /* @__PURE__ */ React133.createElement(Badge21, { size: "xs", variant: "light", color: "gray", style: { position: "absolute", top: 8, right: 8 } }, "Template"), /* @__PURE__ */ React133.createElement(Group42, { wrap: "nowrap", justify: "space-between", align: "center" }, /* @__PURE__ */ React133.createElement(Group42, { wrap: "nowrap", align: "center" }, /* @__PURE__ */ React133.createElement(ActionIcon28, { variant: "light", color: "blue", size: "lg", radius: "xl", style: { flexShrink: 0 } }, getIcon(block.props.icon, 18, 1.5, "checklist")), /* @__PURE__ */ React133.createElement(Stack96, { gap: "xs", style: { flex: 1 } }, /* @__PURE__ */ React133.createElement(Text71, { fw: 500, size: "sm", contentEditable: false }, block.props.title || "Evaluator Title"), /* @__PURE__ */ React133.createElement(Text71, { size: "xs", c: "dimmed", contentEditable: false }, block.props.description || "Evaluator description")))));
11691
+ };
11692
+
11693
+ // src/mantine/blocks/evaluator/flow/FlowView.tsx
11694
+ import React136, { useState as useState44, useEffect as useEffect33, useMemo as useMemo35, useCallback as useCallback32 } from "react";
11695
+ import { Stack as Stack99, Text as Text74, Loader as Loader18, Center as Center10, Alert as Alert19, Title as Title18, Flex as Flex24, ActionIcon as ActionIcon31 } from "@mantine/core";
11696
+ import { IconSettings as IconSettings5, IconRefresh as IconRefresh5, IconAlertCircle as IconAlertCircle8 } from "@tabler/icons-react";
11697
+
11698
+ // src/mantine/blocks/evaluator/flow/ClaimCollectionsList.tsx
11699
+ import React135, { useMemo as useMemo34, useState as useState43, useEffect as useEffect32 } from "react";
11700
+ import { Stack as Stack98, Text as Text73, ActionIcon as ActionIcon30, Tooltip as Tooltip9, Loader as Loader17, Center as Center9 } from "@mantine/core";
11701
+
11702
+ // src/mantine/blocks/evaluator/flow/ClaimsList.tsx
11703
+ import React134, { useState as useState42, useEffect as useEffect31, useCallback as useCallback31, useMemo as useMemo33 } from "react";
11704
+ import { Paper as Paper18, CloseButton as CloseButton14, Title as Title17, Loader as Loader16, Stack as Stack97, Text as Text72, ActionIcon as ActionIcon29, Alert as Alert18, Badge as Badge22, Group as Group43, Button as Button32, Divider as Divider7 } from "@mantine/core";
11705
+ import { IconAlertCircle as IconAlertCircle7, IconArrowRight as IconArrowRight4, IconRefresh as IconRefresh4, IconArrowLeft as IconArrowLeft3 } from "@tabler/icons-react";
11706
+ import { Survey as Survey4, SurveyModel as SurveyModel4 } from "@ixo/surveys";
11707
+
11708
+ // src/mantine/blocks/evaluator/flow/theme.ts
11709
+ var IXO_PALETTE = {
11710
+ // Neutral
11711
+ Neutral50: "#FAFAFA",
11712
+ Neutral100: "#F8F8F8",
11713
+ Neutral200: "#F1F1F1",
11714
+ Neutral300: "#EBEBEB",
11715
+ Neutral500: "#D7D7D7",
11716
+ Neutral800: "#9A9A9A",
11717
+ Black: "#000000",
11718
+ // Neutral Dark
11719
+ NeutralDark50: "#050505",
11720
+ NeutralDark100: "#070707",
11721
+ NeutralDark200: "#0E0E0E",
11722
+ NeutralDark300: "#141414",
11723
+ NeutralDark500: "#282828",
11724
+ NeutralDark800: "#656565",
11725
+ // White
11726
+ White: "#FFFFFF",
11727
+ WhiteSecondary: "#D7ECE3",
11728
+ // EmergingBlue
11729
+ accentActive: "#0EB8DC",
11730
+ accentSecondary: "#20798C",
11731
+ accentHover: "#17C6EB",
11732
+ accentLight: "#ADEBF8",
11733
+ // CompanionBlue
11734
+ companionBlue: "#e8f9fd",
11735
+ // EmergingLighter
11736
+ accentLighter: "rgba(173,235,248,0.2)",
11737
+ accentDarker: "#296DAB",
11738
+ darkestBlue: "#000000",
11739
+ // Contribution
11740
+ contributionBlue: "rgba(22, 143, 168, 1)",
11741
+ // Danger
11742
+ dangerFull: "#E2223B",
11743
+ dangerBrighter: "#FCCFD5",
11744
+ dangerBright: "#F9909E",
11745
+ dangerDark: "#A11C43",
11746
+ // Success
11747
+ successFull: "#61B43A",
11748
+ successDarker: "#47822b",
11749
+ successBright: "#F4FCF0",
11750
+ successSecondary: "#1CBD6A",
11751
+ orangeFull: "#ED9526",
11752
+ orangeBright: "#FDC681",
11753
+ // Transparent
11754
+ transparent: "rgba(255, 255, 255, 0)",
11755
+ whiteTransparentDarker: "rgba(255, 255, 255, 0.10)",
11756
+ whiteTransparent: "rgba(255, 255, 255, 0.30)",
11757
+ whiteTransparentSecondary: "rgba(255, 255, 255, 0.65)",
11758
+ successTransparent: "rgba(67, 175, 98, 0.30)",
11759
+ // Glassmorphics
11760
+ glass: "rgba(255, 255, 255, 0.06)",
11761
+ glassGradient: "linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(153, 153, 153, 0.03) 100%)",
11762
+ glassDarker: "rgba(0, 0, 0, 0.5)",
11763
+ glassLighter: "rgba(255, 255, 255, 0.3)",
11764
+ // Gradients
11765
+ offsetCertificateGradient: "linear-gradient(45deg, rgba(59,152,51,1) 0%, rgba(70,193,193,1) 100%)",
11766
+ contributionCertificateGradient: "linear-gradient(45deg, rgba(22,143,168,1) 0%, rgba(30,204,183,1) 100%)",
11767
+ carbonCertificateGradient: "linear-gradient(55.09deg, rgba(54, 101, 135, 1) -2.49%, rgba(30, 173, 204, 1) 109.08%)",
11768
+ shadowGradient: "linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.2) 100%)"
11769
+ };
11770
+ var surveyTheme2 = {
11771
+ backgroundImageFit: "cover",
11772
+ backgroundImageAttachment: "scroll",
11773
+ backgroundOpacity: 0,
11774
+ cssVariables: {
11775
+ "-sjs-editorpanel-backcolor": IXO_PALETTE.glassDarker,
11776
+ "--sjs-editor-background": IXO_PALETTE.glassDarker,
11777
+ "--sjs-general-backcolor": IXO_PALETTE.Black,
11778
+ "--sjs-general-backcolor-dark": IXO_PALETTE.Black,
11779
+ "--sjs-general-backcolor-dim": IXO_PALETTE.transparent,
11780
+ "--sjs-general-backcolor-dim-light": IXO_PALETTE.glassDarker,
11781
+ "--sjs-general-backcolor-dim-dark": IXO_PALETTE.glassDarker,
11782
+ "--sjs-general-forecolor": IXO_PALETTE.White,
11783
+ "--sjs-general-forecolor-light": IXO_PALETTE.White,
11784
+ "--sjs-general-dim-forecolor": IXO_PALETTE.White,
11785
+ "--sjs-general-dim-forecolor-light": IXO_PALETTE.White,
11786
+ "--sjs-font-surveytitle-color": IXO_PALETTE.White,
11787
+ "--sjs-primary-backcolor": IXO_PALETTE.accentActive,
11788
+ "--sjs-primary-backcolor-light": IXO_PALETTE.accentLight,
11789
+ "--sjs-primary-backcolor-dark": IXO_PALETTE.accentHover,
11790
+ "--sjs-primary-forecolor": "rgba(255, 255, 255, 1)",
11791
+ "--sjs-primary-forecolor-light": "rgba(255, 255, 255, 0.25)",
11792
+ "--sjs-base-unit": "8px",
11793
+ "--sjs-editorpanel-cornerRadius": "30px",
11794
+ "--sjs-questionpanel-cornerRadius": "12px",
11795
+ "--sjs-secondary-backcolor": "rgba(255, 152, 20, 1)",
11796
+ "--sjs-secondary-backcolor-light": "rgba(255, 152, 20, 0.1)",
11797
+ "--sjs-secondary-backcolor-semi-light": "rgba(255, 152, 20, 0.25)",
11798
+ "--sjs-secondary-forecolor": "rgba(255, 255, 255, 1)",
11799
+ "--sjs-secondary-forecolor-light": "rgba(255, 255, 255, 0.25)",
11800
+ "--sjs-shadow-small": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
11801
+ "--sjs-shadow-small-reset": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
11802
+ "--sjs-shadow-medium": "0px 0px 0px 0px rgba(0, 0, 0, 0)",
11803
+ "--sjs-shadow-large": "0px 8px 16px 0px rgba(0, 0, 0, 0.1)",
11804
+ "--sjs-shadow-inner": "0px 0px 0px 0px rgba(0, 0, 0, 0.15)",
11805
+ "--sjs-shadow-inner-reset": "0px 0px 0px 0px rgba(0, 0, 0, 0.15)",
11806
+ "--sjs-border-light": "rgba(0, 0, 0, 0.09)",
11807
+ "--sjs-border-default": "rgba(0, 0, 0, 0.16)",
11808
+ "--sjs-border-inside": "rgba(0, 0, 0, 0.16)",
11809
+ "--sjs-special-red": "rgba(229, 10, 62, 1)",
11810
+ "--sjs-special-red-light": "rgba(229, 10, 62, 0.1)",
11811
+ "--sjs-special-red-forecolor": "rgba(255, 255, 255, 1)",
11812
+ "--sjs-special-green": "rgba(25, 179, 148, 1)",
11813
+ "--sjs-special-green-light": "rgba(25, 179, 148, 0.1)",
11814
+ "--sjs-special-green-forecolor": "rgba(255, 255, 255, 1)",
11815
+ "--sjs-special-blue": "rgba(67, 127, 217, 1)",
11816
+ "--sjs-special-blue-light": "rgba(67, 127, 217, 0.1)",
11817
+ "--sjs-special-blue-forecolor": "rgba(255, 255, 255, 1)",
11818
+ "--sjs-special-yellow": "rgba(255, 152, 20, 1)",
11819
+ "--sjs-special-yellow-light": "rgba(255, 152, 20, 0.1)",
11820
+ "--sjs-special-yellow-forecolor": "rgba(255, 255, 255, 1)",
11821
+ "--sjs-article-font-xx-large-textDecoration": "none",
11822
+ "--sjs-article-font-xx-large-fontWeight": "700",
11823
+ "--sjs-article-font-xx-large-fontStyle": "normal",
11824
+ "--sjs-article-font-xx-large-fontStretch": "normal",
11825
+ "--sjs-article-font-xx-large-letterSpacing": "0",
11826
+ "--sjs-article-font-xx-large-lineHeight": "64px",
11827
+ "--sjs-article-font-xx-large-paragraphIndent": "0px",
11828
+ "--sjs-article-font-xx-large-textCase": "none",
11829
+ "--sjs-article-font-x-large-textDecoration": "none",
11830
+ "--sjs-article-font-x-large-fontWeight": "700",
11831
+ "--sjs-article-font-x-large-fontStyle": "normal",
11832
+ "--sjs-article-font-x-large-fontStretch": "normal",
11833
+ "--sjs-article-font-x-large-letterSpacing": "0",
11834
+ "--sjs-article-font-x-large-lineHeight": "56px",
11835
+ "--sjs-article-font-x-large-paragraphIndent": "0px",
11836
+ "--sjs-article-font-x-large-textCase": "none",
11837
+ "--sjs-article-font-large-textDecoration": "none",
11838
+ "--sjs-article-font-large-fontWeight": "700",
11839
+ "--sjs-article-font-large-fontStyle": "normal",
11840
+ "--sjs-article-font-large-fontStretch": "normal",
11841
+ "--sjs-article-font-large-letterSpacing": "0",
11842
+ "--sjs-article-font-large-lineHeight": "40px",
11843
+ "--sjs-article-font-large-paragraphIndent": "0px",
11844
+ "--sjs-article-font-large-textCase": "none",
11845
+ "--sjs-article-font-medium-textDecoration": "none",
11846
+ "--sjs-article-font-medium-fontWeight": "700",
11847
+ "--sjs-article-font-medium-fontStyle": "normal",
11848
+ "--sjs-article-font-medium-fontStretch": "normal",
11849
+ "--sjs-article-font-medium-letterSpacing": "0",
11850
+ "--sjs-article-font-medium-lineHeight": "32px",
11851
+ "--sjs-article-font-medium-paragraphIndent": "0px",
11852
+ "--sjs-article-font-medium-textCase": "none",
11853
+ "--sjs-article-font-default-textDecoration": "none",
11854
+ "--sjs-article-font-default-fontWeight": "400",
11855
+ "--sjs-article-font-default-fontStyle": "normal",
11856
+ "--sjs-article-font-default-fontStretch": "normal",
11857
+ "--sjs-article-font-default-letterSpacing": "0",
11858
+ "--sjs-article-font-default-lineHeight": "28px",
11859
+ "--sjs-article-font-default-paragraphIndent": "0px",
11860
+ "--sjs-article-font-default-textCase": "none"
11861
+ },
11862
+ themeName: "ixoTheme",
11863
+ colorPalette: "dark"
11864
+ };
11865
+
11866
+ // src/mantine/blocks/evaluator/flow/ClaimsList.tsx
11867
+ var SURVEY_THEME_VARIABLES3 = Object.entries(surveyTheme2.cssVariables ?? {}).reduce((acc, [key, value]) => {
11868
+ acc[key] = value;
11869
+ return acc;
11870
+ }, {});
11871
+ var SURVEY_THEME_BACKGROUND3 = SURVEY_THEME_VARIABLES3["--sjs-general-backcolor"] ?? "#050505";
11872
+ var SURVEY_THEME_FOREGROUND3 = SURVEY_THEME_VARIABLES3["--sjs-general-forecolor"] ?? "#ffffff";
11873
+ var ClaimsList = ({ collectionId, collectionName, deedId, adminAddress, onEvaluationComplete }) => {
11874
+ const { closePanel } = usePanelStore();
11875
+ const handlers = useBlocknoteHandlers();
11876
+ const [viewMode, setViewMode] = useState42("list");
11877
+ const [claims, setClaims] = useState42([]);
11878
+ const [loading, setLoading] = useState42(true);
11879
+ const [error, setError] = useState42(null);
11880
+ const [selectedClaim, setSelectedClaim] = useState42(null);
11881
+ const [claimData, setClaimData] = useState42(null);
11882
+ const [surveyJson, setSurveyJson] = useState42(null);
11883
+ const [surveyLoading, setSurveyLoading] = useState42(false);
11884
+ const [surveyError, setSurveyError] = useState42(null);
11885
+ const [evaluating, setEvaluating] = useState42(false);
11886
+ const fetchClaims = useCallback31(async () => {
11887
+ try {
11888
+ setLoading(true);
11889
+ setError(null);
11890
+ const result = await handlers.getClaimsPerCollectionId({
11891
+ collectionId
11892
+ });
11893
+ setClaims(result || []);
11894
+ } catch (err) {
11895
+ console.error("Error fetching claims:", err);
11896
+ setError(err instanceof Error ? err.message : "Failed to fetch claims");
11897
+ setClaims([]);
11898
+ } finally {
11899
+ setLoading(false);
11900
+ }
11901
+ }, [collectionId, handlers]);
11902
+ useEffect31(() => {
11903
+ fetchClaims();
11904
+ }, [fetchClaims]);
11905
+ const fetchClaimAndSurvey = useCallback31(
11906
+ async (claim) => {
11907
+ try {
11908
+ setSurveyLoading(true);
11909
+ setSurveyError(null);
11910
+ const claimDataResult = await handlers.getClaimData(collectionId, claim.claimId);
11911
+ setClaimData(claimDataResult);
11912
+ const surveyResult = await handlers.getBidContributorSurveyTemplate(deedId);
11913
+ if (surveyResult) {
11914
+ setSurveyJson(surveyResult.surveyTemplate);
11915
+ } else {
11916
+ setSurveyError("No survey template found for this deed");
11917
+ }
11918
+ } catch (err) {
11919
+ console.error("Error fetching claim data:", err);
11920
+ setSurveyError(err instanceof Error ? err.message : "Failed to load claim data");
11921
+ } finally {
11922
+ setSurveyLoading(false);
11923
+ }
11924
+ },
11925
+ [collectionId, deedId, handlers]
11926
+ );
11927
+ const handleViewClaim = useCallback31(
11928
+ (claim) => {
11929
+ setSelectedClaim(claim);
11930
+ fetchClaimAndSurvey(claim);
11931
+ setViewMode("survey");
11932
+ },
11933
+ [fetchClaimAndSurvey]
11934
+ );
11935
+ const handleBackToList = useCallback31(() => {
11936
+ setViewMode("list");
11937
+ setSelectedClaim(null);
11938
+ setClaimData(null);
11939
+ setSurveyJson(null);
11940
+ setSurveyError(null);
11941
+ setEvaluating(false);
11942
+ fetchClaims();
11943
+ }, [fetchClaims]);
11944
+ const surveyModel = useMemo33(() => {
11945
+ if (!surveyJson || !claimData) return null;
11946
+ const model = new SurveyModel4(surveyJson);
11947
+ model.applyTheme(surveyTheme2);
11948
+ model.showQuestionNumbers = "off";
11949
+ model.questionsOnPageMode = "singlePage";
11950
+ model.mode = "display";
11951
+ if (claimData) {
11952
+ model.data = claimData;
11953
+ }
11954
+ return model;
11955
+ }, [surveyJson, claimData]);
11956
+ const surveyContainerStyle = useMemo33(
11957
+ () => ({
11958
+ flex: 1,
11959
+ overflow: "auto",
11960
+ backgroundColor: SURVEY_THEME_BACKGROUND3,
11961
+ color: SURVEY_THEME_FOREGROUND3,
11962
+ ...SURVEY_THEME_VARIABLES3,
11963
+ padding: "1rem"
11964
+ }),
11965
+ []
11966
+ );
11967
+ const handleApprove = useCallback31(async () => {
11968
+ if (!selectedClaim) return;
11969
+ try {
11970
+ setEvaluating(true);
11971
+ setSurveyError(null);
11972
+ const currentUser = handlers.getCurrentUser();
11973
+ await handlers.evaluateClaim(
11974
+ currentUser.address,
11975
+ // granteeAddress (evaluator address)
11976
+ deedId,
11977
+ // deed DID
11978
+ {
11979
+ claimId: selectedClaim.claimId,
11980
+ collectionId,
11981
+ adminAddress,
11982
+ status: void 0,
11983
+ // Optional - pass undefined for now
11984
+ verificationProof: "",
11985
+ // Required - empty string for now
11986
+ amount: void 0
11987
+ // Optional - pass undefined for now
11988
+ }
11989
+ );
11990
+ console.log("Claim approved successfully:", selectedClaim.claimId);
11991
+ handleBackToList();
11992
+ } catch (error2) {
11993
+ console.error("Failed to approve claim:", error2);
11994
+ setSurveyError(error2 instanceof Error ? error2.message : "Failed to approve claim");
11995
+ setEvaluating(false);
11996
+ }
11997
+ }, [selectedClaim, handlers, deedId, collectionId, adminAddress, handleBackToList]);
11998
+ const handleReject = useCallback31(async () => {
11999
+ if (!selectedClaim) return;
12000
+ try {
12001
+ setEvaluating(true);
12002
+ setSurveyError(null);
12003
+ console.log("Rejecting claim:", selectedClaim.claimId);
12004
+ handleBackToList();
12005
+ } catch (error2) {
12006
+ console.error("Failed to reject claim:", error2);
12007
+ setSurveyError(error2 instanceof Error ? error2.message : "Failed to reject claim");
12008
+ } finally {
12009
+ setEvaluating(false);
12010
+ }
12011
+ }, [selectedClaim, handleBackToList]);
12012
+ return /* @__PURE__ */ React134.createElement(
12013
+ Paper18,
12014
+ {
12015
+ p: "md",
12016
+ shadow: "sm",
12017
+ style: {
12018
+ height: "100%",
12019
+ display: "flex",
12020
+ flexDirection: "column",
12021
+ overflow: "hidden"
12022
+ }
12023
+ },
12024
+ /* @__PURE__ */ React134.createElement(
12025
+ "div",
12026
+ {
12027
+ style: {
12028
+ display: "flex",
12029
+ justifyContent: "space-between",
12030
+ alignItems: "center",
12031
+ marginBottom: "1rem"
12032
+ }
12033
+ },
12034
+ /* @__PURE__ */ React134.createElement("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" } }, viewMode === "survey" && /* @__PURE__ */ React134.createElement(ActionIcon29, { variant: "subtle", onClick: handleBackToList }, /* @__PURE__ */ React134.createElement(IconArrowLeft3, { size: 20 })), /* @__PURE__ */ React134.createElement(Title17, { order: 3 }, viewMode === "list" ? `${collectionName} - Claims` : `Evaluate Claim #${selectedClaim?.claimId.slice(-8)}`), viewMode === "list" && !loading && claims.length > 0 && /* @__PURE__ */ React134.createElement(Badge22, { size: "lg", variant: "light" }, claims.length)),
12035
+ /* @__PURE__ */ React134.createElement(Group43, { gap: "xs" }, viewMode === "list" && /* @__PURE__ */ React134.createElement(ActionIcon29, { variant: "subtle", onClick: fetchClaims, loading, title: "Refresh claims" }, /* @__PURE__ */ React134.createElement(IconRefresh4, { size: 18 })), /* @__PURE__ */ React134.createElement(CloseButton14, { onClick: closePanel }))
12036
+ ),
12037
+ /* @__PURE__ */ React134.createElement(
12038
+ "div",
12039
+ {
12040
+ style: {
12041
+ flex: 1,
12042
+ overflow: "hidden",
12043
+ position: "relative"
12044
+ }
12045
+ },
12046
+ /* @__PURE__ */ React134.createElement(
12047
+ "div",
12048
+ {
12049
+ style: {
12050
+ position: "absolute",
12051
+ top: 0,
12052
+ left: 0,
12053
+ right: 0,
12054
+ bottom: 0,
12055
+ display: "flex",
12056
+ flexDirection: "column",
12057
+ overflow: "auto",
12058
+ transform: viewMode === "list" ? "translateX(0)" : "translateX(-100%)",
12059
+ opacity: viewMode === "list" ? 1 : 0,
12060
+ transition: "transform 0.3s ease-out, opacity 0.3s ease-out",
12061
+ pointerEvents: viewMode === "list" ? "auto" : "none"
12062
+ }
12063
+ },
12064
+ /* @__PURE__ */ React134.createElement(Stack97, { gap: "md", style: { flex: 1 } }, loading ? /* @__PURE__ */ React134.createElement(Stack97, { align: "center", justify: "center", style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Loader16, { size: "lg" }), /* @__PURE__ */ React134.createElement(Text72, { size: "sm", c: "dimmed" }, "Loading claims...")) : error ? /* @__PURE__ */ React134.createElement(Alert18, { color: "red", title: "Failed to load claims", icon: /* @__PURE__ */ React134.createElement(IconAlertCircle7, { size: 18 }) }, /* @__PURE__ */ React134.createElement(Text72, { size: "sm" }, error)) : claims.length === 0 ? /* @__PURE__ */ React134.createElement(Stack97, { align: "center", justify: "center", style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Text72, { size: "sm", c: "dimmed", ta: "center" }, "No claims found for this collection.")) : /* @__PURE__ */ React134.createElement(Stack97, { gap: "xs" }, claims.map((claim) => /* @__PURE__ */ React134.createElement(ClaimListItem, { key: claim.claimId, claim, onViewClaim: () => handleViewClaim(claim) }))))
12065
+ ),
12066
+ /* @__PURE__ */ React134.createElement(
12067
+ "div",
12068
+ {
12069
+ style: {
12070
+ position: "absolute",
12071
+ top: 0,
12072
+ left: 0,
12073
+ right: 0,
12074
+ bottom: 0,
12075
+ display: "flex",
12076
+ flexDirection: "column",
12077
+ overflow: "auto",
12078
+ transform: viewMode === "survey" ? "translateX(0)" : "translateX(100%)",
12079
+ opacity: viewMode === "survey" ? 1 : 0,
12080
+ transition: "transform 0.3s ease-out, opacity 0.3s ease-out",
12081
+ pointerEvents: viewMode === "survey" ? "auto" : "none"
12082
+ }
12083
+ },
12084
+ surveyLoading ? /* @__PURE__ */ React134.createElement(Stack97, { align: "center", justify: "center", style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Loader16, { size: "lg" }), /* @__PURE__ */ React134.createElement(Text72, { size: "sm", c: "dimmed" }, "Loading claim data...")) : surveyError ? /* @__PURE__ */ React134.createElement(Stack97, { style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Alert18, { color: "red", title: "Failed to load claim data", icon: /* @__PURE__ */ React134.createElement(IconAlertCircle7, { size: 18 }) }, /* @__PURE__ */ React134.createElement(Text72, { size: "sm" }, surveyError))) : /* @__PURE__ */ React134.createElement(React134.Fragment, null, /* @__PURE__ */ React134.createElement("div", { style: surveyContainerStyle }, surveyModel && /* @__PURE__ */ React134.createElement(Survey4, { model: surveyModel })), /* @__PURE__ */ React134.createElement(Divider7, { my: "md" }), /* @__PURE__ */ React134.createElement(Stack97, { gap: "sm" }, /* @__PURE__ */ React134.createElement(Button32, { color: "green", onClick: handleApprove, loading: evaluating, disabled: evaluating }, "Approve Claim"), /* @__PURE__ */ React134.createElement(Button32, { color: "red", variant: "outline", onClick: handleReject, loading: evaluating, disabled: evaluating }, "Reject Claim")))
12085
+ )
12086
+ )
12087
+ );
12088
+ };
12089
+ var ClaimListItem = ({ claim, onViewClaim }) => {
12090
+ const handlers = useBlocknoteHandlers();
12091
+ const [userProfile, setUserProfile] = useState42(null);
12092
+ const [loadingProfile, setLoadingProfile] = useState42(false);
12093
+ useEffect31(() => {
12094
+ const fetchUserProfile = async () => {
12095
+ if (!claim.agentDid) return;
12096
+ try {
12097
+ setLoadingProfile(true);
12098
+ const profile = await handlers.getMatrixInfoPerDid(claim.agentDid);
12099
+ setUserProfile(profile);
12100
+ } catch (error) {
12101
+ console.error("Failed to fetch user profile:", error);
12102
+ } finally {
12103
+ setLoadingProfile(false);
12104
+ }
12105
+ };
12106
+ fetchUserProfile();
12107
+ }, [claim.agentDid, handlers]);
12108
+ const getClaimStatus = (claim2) => {
12109
+ if ("status" in claim2 && claim2.status) {
12110
+ const status = String(claim2.status).toLowerCase();
12111
+ switch (status) {
12112
+ case "approved":
12113
+ return { status: "Approved", color: "green" };
12114
+ case "rejected":
12115
+ return { status: "Rejected", color: "red" };
12116
+ case "pending":
12117
+ return { status: "Pending", color: "yellow" };
12118
+ default:
12119
+ return { status: "Unknown", color: "gray" };
12120
+ }
12121
+ }
12122
+ if ("paymentsStatus" in claim2 && claim2.paymentsStatus) {
12123
+ const paymentsStatus = claim2.paymentsStatus;
12124
+ if (paymentsStatus.approval === "PAID") {
12125
+ return { status: "Approved", color: "green" };
12126
+ }
12127
+ if (paymentsStatus.rejection === "PAID") {
12128
+ return { status: "Rejected", color: "red" };
12129
+ }
12130
+ if (paymentsStatus.evaluation === "PAID" || paymentsStatus.submission === "PAID") {
12131
+ return { status: "Pending", color: "yellow" };
12132
+ }
12133
+ }
12134
+ return { status: "Pending", color: "yellow" };
12135
+ };
12136
+ const formatDate = (dateString) => {
12137
+ if (!dateString) return "N/A";
12138
+ try {
12139
+ return new Date(dateString).toLocaleDateString();
12140
+ } catch {
12141
+ return dateString;
12142
+ }
12143
+ };
12144
+ const claimStatus = getClaimStatus(claim);
12145
+ const displayName = userProfile?.displayname || (claim.agentAddress ? `${claim.agentAddress.slice(0, 12)}...` : "Unknown");
12146
+ return /* @__PURE__ */ React134.createElement(
12147
+ "div",
12148
+ {
12149
+ onClick: onViewClaim,
12150
+ onKeyDown: (e) => {
12151
+ if (e.key === "Enter" || e.key === " ") {
12152
+ e.preventDefault();
12153
+ onViewClaim();
12154
+ }
12155
+ },
12156
+ role: "button",
12157
+ tabIndex: 0,
12158
+ style: { cursor: "pointer" }
12159
+ },
12160
+ /* @__PURE__ */ React134.createElement(ListItemContainer, null, /* @__PURE__ */ React134.createElement(Stack97, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Text72, { size: "sm", fw: 500 }, "Claim #", claim.claimId.slice(-8)), /* @__PURE__ */ React134.createElement(Text72, { size: "xs", c: "dimmed" }, "Submitted: ", formatDate(claim.submissionDate || claim.submittedAt)), claim.agentDid && /* @__PURE__ */ React134.createElement(Group43, { gap: 4 }, /* @__PURE__ */ React134.createElement(Text72, { size: "xs", c: "dimmed" }, "Agent: ", loadingProfile ? "Loading..." : displayName), userProfile?.verified && /* @__PURE__ */ React134.createElement(Text72, { size: "xs", c: "blue", fw: 600, title: "Verified user" }, "\u2713"))), /* @__PURE__ */ React134.createElement(Stack97, { gap: 4, align: "flex-end" }, /* @__PURE__ */ React134.createElement(Badge22, { color: claimStatus.color, size: "sm" }, claimStatus.status), /* @__PURE__ */ React134.createElement(ActionIcon29, { variant: "subtle", size: "sm" }, /* @__PURE__ */ React134.createElement(IconArrowRight4, { size: 16 }))))
12161
+ );
12162
+ };
12163
+
12164
+ // src/mantine/blocks/evaluator/flow/ClaimCollectionsList.tsx
12165
+ import { IconArrowRight as IconArrowRight5 } from "@tabler/icons-react";
12166
+ var CollectionItem3 = ({ collection, deedId, adminAddress, userRole, onRefresh }) => {
12167
+ const handlers = useBlocknoteHandlers();
12168
+ const currentUser = handlers.getCurrentUser();
12169
+ const getCollectionName = (collection2) => {
12170
+ return collection2.protocol?.profile?.name || collection2.name || "Unnamed Collection";
12171
+ };
12172
+ const isEvaluator = userRole === "EA" /* Evaluator */;
12173
+ const canEvaluateClaims = isEvaluator;
12174
+ const claimsPanelId = `evaluator-claims-list-${collection.id}`;
12175
+ const collectionName = getCollectionName(collection);
12176
+ const claimsPanelContent = useMemo34(
12177
+ () => /* @__PURE__ */ React135.createElement(
12178
+ ClaimsList,
12179
+ {
12180
+ collectionId: collection.id,
12181
+ collectionName,
12182
+ deedId,
12183
+ adminAddress,
12184
+ userAddress: currentUser.address,
12185
+ onEvaluationComplete: onRefresh
12186
+ }
12187
+ ),
12188
+ [collection.id, collectionName, deedId, adminAddress, currentUser.address, onRefresh]
12189
+ );
12190
+ const { open: openClaimsPanel } = usePanel(claimsPanelId, claimsPanelContent);
12191
+ const handleClick = () => {
12192
+ if (canEvaluateClaims) {
12193
+ openClaimsPanel();
12194
+ }
12195
+ };
12196
+ return /* @__PURE__ */ React135.createElement("div", { style: { opacity: canEvaluateClaims ? 1 : 0.5 } }, /* @__PURE__ */ React135.createElement(ListItemContainer, null, /* @__PURE__ */ React135.createElement(Stack98, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React135.createElement(Text73, { size: "sm", fw: 500, c: canEvaluateClaims ? void 0 : "dimmed" }, getCollectionName(collection)), collection.description && /* @__PURE__ */ React135.createElement(Text73, { size: "xs", c: "dimmed" }, collection.description)), /* @__PURE__ */ React135.createElement(Tooltip9, { label: "You need to be an evaluator agent to review claims", disabled: canEvaluateClaims, position: "left", withArrow: true }, /* @__PURE__ */ React135.createElement(ActionIcon30, { variant: "subtle", size: "lg", onClick: handleClick, disabled: !canEvaluateClaims, style: { cursor: canEvaluateClaims ? "pointer" : "not-allowed" } }, /* @__PURE__ */ React135.createElement(IconArrowRight5, { size: 20 })))));
12197
+ };
12198
+ var ClaimCollectionsList3 = ({ collections, deedId, adminAddress, userAddress, onRefresh }) => {
12199
+ const handlers = useBlocknoteHandlers();
12200
+ const [userRoles, setUserRoles] = useState43({});
12201
+ const [loadingRoles, setLoadingRoles] = useState43(true);
12202
+ useEffect32(() => {
12203
+ const fetchUserRoles = async () => {
12204
+ if (!collections || collections.length === 0 || !userAddress || !adminAddress) {
12205
+ setLoadingRoles(false);
12206
+ return;
12207
+ }
12208
+ try {
12209
+ setLoadingRoles(true);
12210
+ const collectionIds = collections.map((c) => c.id);
12211
+ const roles = await handlers.getUserRoles({
12212
+ userAddress,
12213
+ adminAddress,
12214
+ deedDid: deedId,
12215
+ collectionIds
12216
+ });
12217
+ const rolesMap = {};
12218
+ collections.forEach((collection) => {
12219
+ const roleData = roles?.find((r) => r.collectionId === collection.id);
12220
+ rolesMap[collection.id] = roleData?.role || null;
12221
+ });
12222
+ setUserRoles(rolesMap);
12223
+ } catch (error) {
12224
+ console.error("Error fetching user roles:", error);
12225
+ const rolesMap = {};
12226
+ collections.forEach((collection) => {
12227
+ rolesMap[collection.id] = null;
12228
+ });
12229
+ setUserRoles(rolesMap);
12230
+ } finally {
12231
+ setLoadingRoles(false);
12232
+ }
12233
+ };
12234
+ fetchUserRoles();
12235
+ }, [collections, userAddress, adminAddress, handlers, deedId]);
12236
+ if (!collections || collections.length === 0) {
12237
+ return /* @__PURE__ */ React135.createElement(Text73, { size: "sm", c: "dimmed", ta: "center", py: "md" }, "No claim collections found");
12238
+ }
12239
+ if (loadingRoles) {
12240
+ return /* @__PURE__ */ React135.createElement(Center9, { py: "md" }, /* @__PURE__ */ React135.createElement(Loader17, { size: "sm" }));
12241
+ }
12242
+ return /* @__PURE__ */ React135.createElement(Stack98, { gap: "md", px: 5 }, collections.map((collection) => /* @__PURE__ */ React135.createElement(CollectionItem3, { key: collection.id, collection, deedId, adminAddress, userRole: userRoles[collection.id] || null, onRefresh })));
12243
+ };
12244
+
12245
+ // src/mantine/blocks/evaluator/flow/FlowView.tsx
12246
+ var EvaluatorFlowView = ({ editor, block }) => {
12247
+ const { editable } = useBlocknoteContext();
12248
+ const handlers = useBlocknoteHandlers();
12249
+ const currentUser = handlers.getCurrentUser();
12250
+ const [collections, setCollections] = useState44([]);
12251
+ const [loading, setLoading] = useState44(false);
12252
+ const [error, setError] = useState44(null);
12253
+ const selectedCollectionIds = useMemo35(() => {
12254
+ try {
12255
+ return JSON.parse(block.props.selectedCollections || "[]");
12256
+ } catch {
12257
+ return [];
12258
+ }
12259
+ }, [block.props.selectedCollections]);
12260
+ const did = block.props.deedDid;
12261
+ const adminAddress = block.props.adminAddress || "";
12262
+ const fetchCollections = useCallback32(async () => {
12263
+ if (!did || selectedCollectionIds.length === 0) {
12264
+ setCollections([]);
12265
+ return;
12266
+ }
12267
+ setLoading(true);
12268
+ setError(null);
12269
+ try {
12270
+ const response = await handlers.getClaimCollections({ deedDid: did });
12271
+ const { adminAddress: adminAddress2, collections: allCollections } = response || { adminAddress: "", collections: [] };
12272
+ if (adminAddress2 && (!block.props.adminAddress || block.props.adminAddress === "")) {
12273
+ editor.updateBlock(block, {
12274
+ props: {
12275
+ ...block.props,
12276
+ adminAddress: adminAddress2
12277
+ }
12278
+ });
12279
+ }
12280
+ const selectedCollections = (allCollections || []).filter((c) => selectedCollectionIds.includes(c?.id));
12281
+ setCollections(selectedCollections);
12282
+ } catch (err) {
12283
+ console.error("Error fetching collections:", err);
12284
+ setError(err instanceof Error ? err.message : "Failed to fetch collections");
12285
+ } finally {
12286
+ setLoading(false);
12287
+ }
12288
+ }, [did, selectedCollectionIds, handlers, editor, block]);
12289
+ useEffect33(() => {
12290
+ fetchCollections();
12291
+ }, [fetchCollections]);
12292
+ if (!did) {
12293
+ return /* @__PURE__ */ React136.createElement(Center10, { py: "xl" }, /* @__PURE__ */ React136.createElement(Text74, { size: "sm", c: "dimmed" }, "Please configure the evaluator block in template mode first"));
12294
+ }
12295
+ if (selectedCollectionIds.length === 0) {
12296
+ return /* @__PURE__ */ React136.createElement(Center10, { py: "xl" }, /* @__PURE__ */ React136.createElement(Text74, { size: "sm", c: "dimmed" }, "No claim collections selected"));
12297
+ }
12298
+ return /* @__PURE__ */ React136.createElement(Stack99, { w: "100%" }, /* @__PURE__ */ React136.createElement(Flex24, { px: 5, align: "center", justify: "space-between" }, /* @__PURE__ */ React136.createElement(Title18, { order: 4 }, "Evaluate Claims"), /* @__PURE__ */ React136.createElement(Flex24, { gap: "xs" }, /* @__PURE__ */ React136.createElement(ActionIcon31, { variant: "subtle", size: "sm", onClick: fetchCollections, loading }, /* @__PURE__ */ React136.createElement(IconRefresh5, { size: 18 })), editable && /* @__PURE__ */ React136.createElement(ActionIcon31, { variant: "subtle", size: "sm" }, /* @__PURE__ */ React136.createElement(IconSettings5, { size: 18 })))), loading ? /* @__PURE__ */ React136.createElement(Center10, { py: "xl" }, /* @__PURE__ */ React136.createElement(Loader18, { size: "md" })) : error ? /* @__PURE__ */ React136.createElement(Alert19, { color: "red", title: "Failed to load collections", icon: /* @__PURE__ */ React136.createElement(IconAlertCircle8, { size: 18 }) }, /* @__PURE__ */ React136.createElement(Text74, { size: "sm" }, error)) : /* @__PURE__ */ React136.createElement(ClaimCollectionsList3, { collections, deedId: did, adminAddress, userAddress: currentUser.address, onRefresh: fetchCollections }));
12299
+ };
12300
+
12301
+ // src/mantine/blocks/evaluator/EvaluatorBlock.tsx
12302
+ function EvaluatorBlock({ editor, block }) {
12303
+ const { docType } = useBlocknoteContext();
12304
+ if (docType === "template") {
12305
+ return /* @__PURE__ */ React137.createElement(EvaluatorTemplateView, { editor, block });
12306
+ }
12307
+ return /* @__PURE__ */ React137.createElement(EvaluatorFlowView, { editor, block });
12308
+ }
12309
+
12310
+ // src/mantine/blocks/evaluator/EvaluatorBlockSpec.tsx
12311
+ import React138 from "react";
12312
+ import { createReactBlockSpec as createReactBlockSpec10 } from "@blocknote/react";
12313
+ var EvaluatorBlockSpec = createReactBlockSpec10(
12314
+ {
12315
+ type: "evaluator",
12316
+ propSchema: {
12317
+ title: { default: "" },
12318
+ description: { default: "" },
12319
+ icon: { default: "checklist" },
12320
+ deedDid: { default: "" },
12321
+ selectedCollections: { default: "[]" },
12322
+ adminAddress: { default: "" }
12323
+ },
12324
+ content: "none"
12325
+ },
12326
+ {
12327
+ render: (props) => {
12328
+ const ixoProps = props;
12329
+ return /* @__PURE__ */ React138.createElement(EvaluatorBlock, { ...ixoProps });
12330
+ }
12331
+ }
12332
+ );
12333
+
12334
+ // src/mantine/blocks/list/ui/ListBlocksToolbar.tsx
12335
+ import React139 from "react";
12336
+ import { ActionIcon as ActionIcon32, Group as Group44, Tooltip as Tooltip10 } from "@mantine/core";
12337
+ import { IconChevronUp as IconChevronUp4, IconChevronDown as IconChevronDown5 } from "@tabler/icons-react";
12338
+ var ListBlocksToolbar = () => {
12339
+ const { broadcastCollapse } = useListBlocksUI();
12340
+ return /* @__PURE__ */ React139.createElement(Group44, { gap: "xs" }, /* @__PURE__ */ React139.createElement(Tooltip10, { label: "Collapse all lists", withArrow: true }, /* @__PURE__ */ React139.createElement(ActionIcon32, { c: "dimmed", variant: "subtle", size: "sm", "aria-label": "Collapse all lists", onClick: () => broadcastCollapse("collapse") }, /* @__PURE__ */ React139.createElement(IconChevronUp4, { size: 18 }))), /* @__PURE__ */ React139.createElement(Tooltip10, { label: "Expand all lists", withArrow: true }, /* @__PURE__ */ React139.createElement(ActionIcon32, { c: "dimmed", variant: "subtle", size: "sm", "aria-label": "Expand all lists", onClick: () => broadcastCollapse("expand") }, /* @__PURE__ */ React139.createElement(IconChevronDown5, { size: 18 }))));
12341
+ };
12342
+
12343
+ // src/mantine/blocks/registry/blockRegistry.ts
12344
+ var BlockRegistry = class {
12345
+ constructor() {
12346
+ this.blocks = /* @__PURE__ */ new Map();
12347
+ }
12348
+ register(entry) {
12349
+ this.blocks.set(entry.type, entry);
12350
+ }
12351
+ get(type) {
12352
+ return this.blocks.get(type);
12353
+ }
12354
+ getAll() {
12355
+ return new Map(this.blocks);
12356
+ }
12357
+ getValidDependencies(type) {
12358
+ const entry = this.get(type);
12359
+ return entry?.validDependencies || [];
12360
+ }
12361
+ getPropSchema(type) {
12362
+ const entry = this.get(type);
12363
+ return entry?.propSchema;
12364
+ }
12365
+ isValidDependency(blockType, dependencyType) {
12366
+ const validDeps = this.getValidDependencies(blockType);
12367
+ return validDeps.includes(dependencyType);
12368
+ }
12369
+ };
12370
+ var blockRegistry = new BlockRegistry();
12371
+ blockRegistry.register({
12372
+ type: "proposal",
12373
+ propSchema: {
12374
+ title: "",
12375
+ description: "",
12376
+ icon: "\u{1F4DD}",
12377
+ proposalId: "",
12378
+ status: "draft",
12379
+ contractAddress: "",
12380
+ coreAddress: "",
12381
+ createdProposalId: ""
12382
+ },
12383
+ validDependencies: [],
12384
+ defaultProps: {
12385
+ icon: "\u{1F4DD}",
12386
+ status: "draft"
12387
+ }
12388
+ });
12389
+ blockRegistry.register({
12390
+ type: "proposalVote",
12391
+ propSchema: {
12392
+ title: "",
9926
12393
  subtitle: "",
9927
12394
  icon: "\u{1F5F3}\uFE0F",
9928
12395
  status: "open",
@@ -9997,12 +12464,39 @@ blockRegistry.register({
9997
12464
  status: "idle"
9998
12465
  }
9999
12466
  });
12467
+ blockRegistry.register({
12468
+ type: "bid",
12469
+ propSchema: {
12470
+ title: "",
12471
+ description: "",
12472
+ did: "",
12473
+ selectedCollections: "[]",
12474
+ adminAddress: ""
12475
+ },
12476
+ validDependencies: [],
12477
+ defaultProps: {}
12478
+ });
12479
+ blockRegistry.register({
12480
+ type: "claim",
12481
+ propSchema: {
12482
+ title: "",
12483
+ description: "",
12484
+ icon: "square-check",
12485
+ deedDid: "",
12486
+ selectedCollections: "[]",
12487
+ adminAddress: ""
12488
+ },
12489
+ validDependencies: [],
12490
+ defaultProps: {
12491
+ icon: "square-check"
12492
+ }
12493
+ });
10000
12494
 
10001
12495
  // src/mantine/blocks/hooks/useBlockDependencies.ts
10002
- import { useMemo as useMemo19, useEffect as useEffect19, useState as useState30, useCallback as useCallback20 } from "react";
12496
+ import { useMemo as useMemo36, useEffect as useEffect34, useState as useState45, useCallback as useCallback33 } from "react";
10003
12497
 
10004
12498
  // src/mantine/blocks/hooks/useDependsOn.ts
10005
- import { useMemo as useMemo20 } from "react";
12499
+ import { useMemo as useMemo37 } from "react";
10006
12500
 
10007
12501
  // src/mantine/blocks/index.ts
10008
12502
  var blockSpecs = {
@@ -10012,7 +12506,10 @@ var blockSpecs = {
10012
12506
  overview: OverviewBlock,
10013
12507
  proposal: ProposalBlockSpec,
10014
12508
  apiRequest: ApiRequestBlockSpec,
10015
- notify: NotifyBlockSpec
12509
+ notify: NotifyBlockSpec,
12510
+ claim: ClaimBlockSpec,
12511
+ bid: BidBlockSpec,
12512
+ evaluator: EvaluatorBlockSpec
10016
12513
  };
10017
12514
  var getExtraSlashMenuItems = (editor) => {
10018
12515
  const slashMenuList = [
@@ -10196,6 +12693,60 @@ var getExtraSlashMenuItems = (editor) => {
10196
12693
  aliases: ["notify", "notification", "email", "alert", "message", "bird"],
10197
12694
  group: "Basics",
10198
12695
  subtext: "Send notifications via Email, SMS, or WhatsApp"
12696
+ },
12697
+ {
12698
+ title: "Claim",
12699
+ onItemClick: () => {
12700
+ editor.insertBlocks(
12701
+ [
12702
+ {
12703
+ type: "claim",
12704
+ props: {}
12705
+ }
12706
+ ],
12707
+ editor.getTextCursorPosition().block,
12708
+ "after"
12709
+ );
12710
+ },
12711
+ aliases: ["claim", "submission", "form", "attestation"],
12712
+ group: "DAO",
12713
+ subtext: "Create and manage claims with submission tracking"
12714
+ },
12715
+ {
12716
+ title: "Bid",
12717
+ onItemClick: () => {
12718
+ editor.insertBlocks(
12719
+ [
12720
+ {
12721
+ type: "bid",
12722
+ props: {}
12723
+ }
12724
+ ],
12725
+ editor.getTextCursorPosition().block,
12726
+ "after"
12727
+ );
12728
+ },
12729
+ aliases: ["bid", "offer", "tender"],
12730
+ group: "DAO",
12731
+ subtext: "Create and submit bids"
12732
+ },
12733
+ {
12734
+ title: "Evaluator",
12735
+ onItemClick: () => {
12736
+ editor.insertBlocks(
12737
+ [
12738
+ {
12739
+ type: "evaluator",
12740
+ props: {}
12741
+ }
12742
+ ],
12743
+ editor.getTextCursorPosition().block,
12744
+ "after"
12745
+ );
12746
+ },
12747
+ aliases: ["evaluator", "evaluate", "review", "assessment"],
12748
+ group: "DAO",
12749
+ subtext: "Evaluate and review submitted claims"
10199
12750
  }
10200
12751
  ];
10201
12752
  const yRoot = editor?._yRoot;
@@ -10220,7 +12771,8 @@ function useCreateIxoEditor(options) {
10220
12771
  formattingToolbar = true,
10221
12772
  linkToolbar = true,
10222
12773
  filePanel = true,
10223
- tableHandles = true
12774
+ tableHandles = true,
12775
+ docType = "flow"
10224
12776
  } = options || {};
10225
12777
  const defaultUploadFile = uploadFile || (async (file) => {
10226
12778
  return new Promise((resolve, reject) => {
@@ -10263,6 +12815,7 @@ function useCreateIxoEditor(options) {
10263
12815
  tableHandles
10264
12816
  };
10265
12817
  ixoEditor.mode = "flow";
12818
+ ixoEditor.docType = docType;
10266
12819
  ixoEditor.isEditable = editable;
10267
12820
  return ixoEditor;
10268
12821
  }
@@ -10274,15 +12827,15 @@ import { useCreateBlockNote as useCreateBlockNote2 } from "@blocknote/react";
10274
12827
  import { BlockNoteSchema as BlockNoteSchema2, defaultBlockSpecs as defaultBlockSpecs2, defaultInlineContentSpecs as defaultInlineContentSpecs2, defaultStyleSpecs as defaultStyleSpecs2 } from "@blocknote/core";
10275
12828
 
10276
12829
  // src/core/hooks/useMatrixProvider.ts
10277
- import { useEffect as useEffect20, useState as useState31, useRef as useRef4, useCallback as useCallback21, useMemo as useMemo21 } from "react";
12830
+ import { useEffect as useEffect35, useState as useState46, useRef as useRef4, useCallback as useCallback34, useMemo as useMemo38 } from "react";
10278
12831
  import { MatrixProvider } from "@ixo/matrix-crdt";
10279
12832
  function useMatrixProvider({ matrixClient, roomId, yDoc }) {
10280
- const [matrixProvider, setProvider] = useState31(null);
10281
- const [status, setStatus] = useState31("disconnected");
12833
+ const [matrixProvider, setProvider] = useState46(null);
12834
+ const [status, setStatus] = useState46("disconnected");
10282
12835
  const isMountedRef = useRef4(true);
10283
12836
  const providerRef = useRef4(null);
10284
12837
  const retryTimeoutRef = useRef4(null);
10285
- const providerOptions = useMemo21(
12838
+ const providerOptions = useMemo38(
10286
12839
  () => ({
10287
12840
  translator: {
10288
12841
  updateEventType: "matrix-crdt.doc_update",
@@ -10295,22 +12848,22 @@ function useMatrixProvider({ matrixClient, roomId, yDoc }) {
10295
12848
  }),
10296
12849
  []
10297
12850
  );
10298
- const handleDocumentAvailable = useCallback21(() => {
12851
+ const handleDocumentAvailable = useCallback34(() => {
10299
12852
  if (isMountedRef.current) {
10300
12853
  setStatus("connected");
10301
12854
  }
10302
12855
  }, []);
10303
- const handleDocumentUnavailable = useCallback21(() => {
12856
+ const handleDocumentUnavailable = useCallback34(() => {
10304
12857
  if (isMountedRef.current) {
10305
12858
  setStatus("failed");
10306
12859
  }
10307
12860
  }, []);
10308
- const handleCanWriteChanged = useCallback21(() => {
12861
+ const handleCanWriteChanged = useCallback34(() => {
10309
12862
  if (isMountedRef.current && providerRef.current) {
10310
12863
  setStatus(providerRef.current.canWrite ? "connected" : "failed");
10311
12864
  }
10312
12865
  }, []);
10313
- const initProvider = useCallback21(async () => {
12866
+ const initProvider = useCallback34(async () => {
10314
12867
  if (!isMountedRef.current) return;
10315
12868
  if (retryTimeoutRef.current) {
10316
12869
  clearTimeout(retryTimeoutRef.current);
@@ -10344,7 +12897,7 @@ function useMatrixProvider({ matrixClient, roomId, yDoc }) {
10344
12897
  }
10345
12898
  }
10346
12899
  }, [matrixClient, providerOptions, handleDocumentAvailable, handleDocumentUnavailable, handleCanWriteChanged]);
10347
- useEffect20(() => {
12900
+ useEffect35(() => {
10348
12901
  isMountedRef.current = true;
10349
12902
  initProvider();
10350
12903
  return () => {
@@ -10361,7 +12914,7 @@ function useMatrixProvider({ matrixClient, roomId, yDoc }) {
10361
12914
  setStatus("disconnected");
10362
12915
  };
10363
12916
  }, [initProvider]);
10364
- useEffect20(() => {
12917
+ useEffect35(() => {
10365
12918
  return () => {
10366
12919
  isMountedRef.current = false;
10367
12920
  };
@@ -10370,17 +12923,17 @@ function useMatrixProvider({ matrixClient, roomId, yDoc }) {
10370
12923
  }
10371
12924
 
10372
12925
  // src/mantine/hooks/useCollaborativeYDoc.ts
10373
- import { useMemo as useMemo22 } from "react";
12926
+ import { useMemo as useMemo39 } from "react";
10374
12927
  import * as Y from "yjs";
10375
12928
  function useCollaborativeYDoc(_options) {
10376
- return useMemo22(() => {
12929
+ return useMemo39(() => {
10377
12930
  const doc = new Y.Doc();
10378
12931
  return doc;
10379
12932
  }, []);
10380
12933
  }
10381
12934
 
10382
12935
  // src/mantine/hooks/useCollaborativeIxoEditor.ts
10383
- import { useMemo as useMemo23, useEffect as useEffect21 } from "react";
12936
+ import { useMemo as useMemo40, useEffect as useEffect36 } from "react";
10384
12937
  function useCreateCollaborativeIxoEditor(options) {
10385
12938
  const yDoc = useCollaborativeYDoc(options);
10386
12939
  const {
@@ -10394,11 +12947,12 @@ function useCreateCollaborativeIxoEditor(options) {
10394
12947
  linkToolbar = true,
10395
12948
  filePanel = true,
10396
12949
  tableHandles = true,
12950
+ docType = "flow",
10397
12951
  user,
10398
12952
  matrixClient,
10399
12953
  permissions = { write: false }
10400
12954
  } = options || {};
10401
- const memoizedUser = useMemo23(
12955
+ const memoizedUser = useMemo40(
10402
12956
  () => ({
10403
12957
  id: user?.id || "",
10404
12958
  name: user?.name || "",
@@ -10413,7 +12967,7 @@ function useCreateCollaborativeIxoEditor(options) {
10413
12967
  matrixClient,
10414
12968
  roomId: options.roomId
10415
12969
  });
10416
- const defaultUploadFile = useMemo23(
12970
+ const defaultUploadFile = useMemo40(
10417
12971
  () => uploadFile || (async (file) => {
10418
12972
  return new Promise((resolve, reject) => {
10419
12973
  const reader = new FileReader();
@@ -10427,7 +12981,7 @@ function useCreateCollaborativeIxoEditor(options) {
10427
12981
  }),
10428
12982
  [uploadFile]
10429
12983
  );
10430
- const schema = useMemo23(
12984
+ const schema = useMemo40(
10431
12985
  () => BlockNoteSchema2.create({
10432
12986
  blockSpecs: {
10433
12987
  ...defaultBlockSpecs2,
@@ -10442,11 +12996,11 @@ function useCreateCollaborativeIxoEditor(options) {
10442
12996
  }),
10443
12997
  []
10444
12998
  );
10445
- const root = useMemo23(() => yDoc.getMap("root"), [yDoc]);
10446
- const documentFragment = useMemo23(() => yDoc.getXmlFragment("document"), [yDoc]);
10447
- const flowArray = useMemo23(() => yDoc.getArray("flow"), [yDoc]);
10448
- const userFragment = useMemo23(() => yDoc.getMap(memoizedUser.id), [yDoc, memoizedUser.id]);
10449
- const collaborationConfig = useMemo23(
12999
+ const root = useMemo40(() => yDoc.getMap("root"), [yDoc]);
13000
+ const documentFragment = useMemo40(() => yDoc.getXmlFragment("document"), [yDoc]);
13001
+ const flowArray = useMemo40(() => yDoc.getArray("flow"), [yDoc]);
13002
+ const userFragment = useMemo40(() => yDoc.getMap(memoizedUser.id), [yDoc, memoizedUser.id]);
13003
+ const collaborationConfig = useMemo40(
10450
13004
  () => ({
10451
13005
  provider: matrixProvider,
10452
13006
  fragment: documentFragment,
@@ -10458,7 +13012,7 @@ function useCreateCollaborativeIxoEditor(options) {
10458
13012
  }),
10459
13013
  [matrixProvider, documentFragment, memoizedUser.name, memoizedUser.color]
10460
13014
  );
10461
- const ixoConfig = useMemo23(
13015
+ const ixoConfig = useMemo40(
10462
13016
  () => ({
10463
13017
  theme,
10464
13018
  editable,
@@ -10477,7 +13031,7 @@ function useCreateCollaborativeIxoEditor(options) {
10477
13031
  uploadFile: defaultUploadFile,
10478
13032
  collaboration: collaborationConfig
10479
13033
  });
10480
- const titleText = useMemo23(() => yDoc.getText("title"), [yDoc]);
13034
+ const titleText = useMemo40(() => yDoc.getText("title"), [yDoc]);
10481
13035
  let ixoEditor;
10482
13036
  if (editor) {
10483
13037
  ixoEditor = editor;
@@ -10486,6 +13040,7 @@ function useCreateCollaborativeIxoEditor(options) {
10486
13040
  ixoEditor._yFlow = flowArray;
10487
13041
  ixoEditor.mode = editable ? "template" : "flow";
10488
13042
  ixoEditor.user = memoizedUser;
13043
+ ixoEditor.docType = docType;
10489
13044
  ixoEditor.getUserProps = (block) => {
10490
13045
  return userFragment.get(block.id) || {};
10491
13046
  };
@@ -10525,27 +13080,13 @@ function useCreateCollaborativeIxoEditor(options) {
10525
13080
  ixoEditor.getFlow = () => {
10526
13081
  return flowArray.toArray();
10527
13082
  };
10528
- ixoEditor.getDocType = () => {
10529
- const docType = root.get("docType") || "";
10530
- console.log("[useCollaborativeIxoEditor] getDocType() called, returning:", docType);
10531
- return docType;
10532
- };
10533
- ixoEditor.setDocType = (value) => {
10534
- if (!permissions.write) {
10535
- console.warn("Cannot set doc type: write permission denied");
10536
- return;
10537
- }
10538
- console.log("[useCollaborativeIxoEditor] setDocType() called, setting docType to:", value);
10539
- ixoEditor._authoritativeDocType = value;
10540
- root.set("docType", value);
10541
- };
10542
13083
  }
10543
- useEffect21(() => {
13084
+ useEffect36(() => {
10544
13085
  if (ixoEditor) {
10545
13086
  ixoEditor.isEditable = editable;
10546
13087
  }
10547
13088
  }, [ixoEditor, editable]);
10548
- useEffect21(() => {
13089
+ useEffect36(() => {
10549
13090
  if (connectionStatus !== "connected") {
10550
13091
  return;
10551
13092
  }
@@ -10562,8 +13103,6 @@ function useCreateCollaborativeIxoEditor(options) {
10562
13103
  root.set("doc_id", options.docId || `flow_${Date.now()}`);
10563
13104
  root.set("createdAt", (/* @__PURE__ */ new Date()).toISOString());
10564
13105
  root.set("createdBy", memoizedUser.id || "anonymous");
10565
- root.set("docType", "");
10566
- console.log("[useCollaborativeIxoEditor] Initializing docType to empty string for new document");
10567
13106
  if (titleText.length === 0 && options.title) {
10568
13107
  titleText.insert(0, options.title);
10569
13108
  }
@@ -10579,20 +13118,42 @@ function useCreateCollaborativeIxoEditor(options) {
10579
13118
  }
10580
13119
 
10581
13120
  // src/mantine/IxoEditor.tsx
10582
- import React113 from "react";
13121
+ import React141 from "react";
10583
13122
  import { getDefaultReactSlashMenuItems, SuggestionMenuController } from "@blocknote/react";
10584
13123
  import { BlockNoteView } from "@blocknote/mantine";
10585
13124
  import { filterSuggestionItems } from "@blocknote/core";
10586
- import { Flex as Flex22, MantineProvider, Text as Text57 } from "@mantine/core";
13125
+ import { Flex as Flex25, MantineProvider, Text as Text75 } from "@mantine/core";
10587
13126
 
10588
13127
  // src/mantine/components/PanelContent.tsx
10589
- import React112 from "react";
13128
+ import React140 from "react";
10590
13129
  import { Box as Box22 } from "@mantine/core";
10591
- function PanelContent() {
13130
+ var panelStyles = {
13131
+ light: {
13132
+ backgroundColor: "#ffffff",
13133
+ // editor background
13134
+ color: "#1a1a1a",
13135
+ // main text color
13136
+ border: "1px solid #e0e0e0",
13137
+ // border color
13138
+ // mimic menu/sidebar visual balance
13139
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)"
13140
+ },
13141
+ dark: {
13142
+ backgroundColor: "#1f1f1f",
13143
+ // editor background
13144
+ color: "#f0f0f0",
13145
+ // main text color
13146
+ border: "1px solid #1a1a1a",
13147
+ // border color
13148
+ // mimic menu/sidebar visual balance
13149
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)"
13150
+ }
13151
+ };
13152
+ function PanelContent({ theme }) {
10592
13153
  const { activePanel, registeredPanels } = usePanelStore();
10593
13154
  const isOpen = activePanel !== null;
10594
13155
  const content = activePanel ? registeredPanels.get(activePanel) : null;
10595
- return /* @__PURE__ */ React112.createElement(
13156
+ return /* @__PURE__ */ React140.createElement(
10596
13157
  Box22,
10597
13158
  {
10598
13159
  pos: "sticky",
@@ -10602,7 +13163,9 @@ function PanelContent() {
10602
13163
  width: isOpen ? "50%" : "0",
10603
13164
  height: "calc(100vh - 150px)",
10604
13165
  transition: "width 0.2s ease",
10605
- overflow: isOpen ? "auto" : "hidden"
13166
+ overflow: isOpen ? "auto" : "hidden",
13167
+ ...isOpen && panelStyles[theme]
13168
+ // You can switch between light/dark based on your theme
10606
13169
  }
10607
13170
  },
10608
13171
  isOpen && content
@@ -10619,7 +13182,7 @@ function IxoEditorContent({
10619
13182
  onSelectionChange,
10620
13183
  children
10621
13184
  }) {
10622
- return /* @__PURE__ */ React113.createElement("div", { style: { display: "flex", height: "100%" } }, /* @__PURE__ */ React113.createElement("div", { className: `ixo-editor ixo-editor--theme-${config.theme} ${className}`, style: { flex: 1 } }, /* @__PURE__ */ React113.createElement(
13185
+ return /* @__PURE__ */ React141.createElement("div", { style: { display: "flex", height: "100%" } }, /* @__PURE__ */ React141.createElement("div", { className: `ixo-editor ixo-editor--theme-${config.theme} ${className}`, style: { flex: 1 } }, /* @__PURE__ */ React141.createElement(
10623
13186
  BlockNoteView,
10624
13187
  {
10625
13188
  editor,
@@ -10634,7 +13197,7 @@ function IxoEditorContent({
10634
13197
  onChange,
10635
13198
  onSelectionChange
10636
13199
  },
10637
- config.slashMenu && /* @__PURE__ */ React113.createElement(
13200
+ config.slashMenu && /* @__PURE__ */ React141.createElement(
10638
13201
  SuggestionMenuController,
10639
13202
  {
10640
13203
  triggerCharacter: "/",
@@ -10646,7 +13209,7 @@ function IxoEditorContent({
10646
13209
  }
10647
13210
  ),
10648
13211
  children
10649
- )), /* @__PURE__ */ React113.createElement(PanelContent, null));
13212
+ )), /* @__PURE__ */ React141.createElement(PanelContent, { theme: config.theme }));
10650
13213
  }
10651
13214
  function IxoEditor({
10652
13215
  editor,
@@ -10657,7 +13220,8 @@ function IxoEditor({
10657
13220
  children,
10658
13221
  mantineTheme,
10659
13222
  handlers,
10660
- blockRequirements
13223
+ blockRequirements,
13224
+ isPanelVisible
10661
13225
  }) {
10662
13226
  if (!editor) {
10663
13227
  return null;
@@ -10672,9 +13236,21 @@ function IxoEditor({
10672
13236
  tableHandles: true
10673
13237
  };
10674
13238
  const isEditable = editable;
10675
- const editorContent = /* @__PURE__ */ React113.createElement(BlocknoteProvider, { editor, handlers, blockRequirements, editable: isEditable }, /* @__PURE__ */ React113.createElement(ListBlocksUIProvider, null, /* @__PURE__ */ React113.createElement(Flex22, { pr: 25, justify: "flex-end", align: "center", gap: "xs" }, /* @__PURE__ */ React113.createElement(Text57, { size: "xs", c: "dimmed", tt: "uppercase" }, "Global actions"), /* @__PURE__ */ React113.createElement(ListBlocksToolbar, null)), /* @__PURE__ */ React113.createElement(IxoEditorContent, { editor, config, isEditable, className, onChange, onSelectionChange }, children)));
13239
+ const editorContent = /* @__PURE__ */ React141.createElement(BlocknoteProvider, { editor, handlers, blockRequirements, editable: isEditable }, /* @__PURE__ */ React141.createElement(ListBlocksUIProvider, null, /* @__PURE__ */ React141.createElement(Flex25, { pr: 25, justify: "flex-end", align: "center", gap: "xs" }, /* @__PURE__ */ React141.createElement(Text75, { size: "xs", c: "dimmed", tt: "uppercase" }, "Global actions"), /* @__PURE__ */ React141.createElement(ListBlocksToolbar, null)), /* @__PURE__ */ React141.createElement(
13240
+ IxoEditorContent,
13241
+ {
13242
+ isPanelVisible,
13243
+ editor,
13244
+ config,
13245
+ isEditable,
13246
+ className,
13247
+ onChange,
13248
+ onSelectionChange
13249
+ },
13250
+ children
13251
+ )));
10676
13252
  if (mantineTheme) {
10677
- return /* @__PURE__ */ React113.createElement(MantineProvider, { theme: mantineTheme }, editorContent);
13253
+ return /* @__PURE__ */ React141.createElement(MantineProvider, { theme: mantineTheme }, editorContent);
10678
13254
  }
10679
13255
  return editorContent;
10680
13256
  }
@@ -10738,6 +13314,8 @@ async function getEntity(entityId) {
10738
13314
  }
10739
13315
 
10740
13316
  export {
13317
+ usePanelStore,
13318
+ usePanel,
10741
13319
  BlocknoteProvider,
10742
13320
  useBlocknoteContext,
10743
13321
  useBlocknoteHandlers,
@@ -10758,4 +13336,4 @@ export {
10758
13336
  ixoGraphQLClient,
10759
13337
  getEntity
10760
13338
  };
10761
- //# sourceMappingURL=chunk-FDLWSUB5.mjs.map
13339
+ //# sourceMappingURL=chunk-XEZXD5ZV.mjs.map