@ixo/editor 1.27.0 → 1.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -216,7 +216,6 @@ function parseConditionConfig(conditionsString) {
216
216
  try {
217
217
  return JSON.parse(conditionsString);
218
218
  } catch (error) {
219
- console.error("[parseConditionConfig] Failed to parse conditions:", error);
220
219
  return {
221
220
  enabled: false,
222
221
  mode: "all_must_pass",
@@ -230,7 +229,6 @@ function stringifyConditionConfig(config) {
230
229
  try {
231
230
  return JSON.stringify(config);
232
231
  } catch (error) {
233
- console.error("[stringifyConditionConfig] Failed to stringify conditions:", error);
234
232
  return JSON.stringify({
235
233
  enabled: false,
236
234
  mode: "all_must_pass",
@@ -290,7 +288,6 @@ function parseResponseSchema(schemaString) {
290
288
  try {
291
289
  return JSON.parse(schemaString);
292
290
  } catch (error) {
293
- console.warn("Failed to parse response schema:", error);
294
291
  return null;
295
292
  }
296
293
  }
@@ -1342,7 +1339,6 @@ function evaluateCondition(condition, sourceBlock, _currentUser) {
1342
1339
  passes = sourceValue !== "" && sourceValue !== null && sourceValue !== void 0;
1343
1340
  break;
1344
1341
  default:
1345
- console.warn(`[evaluateCondition] Unknown operator: ${rule.operator}`);
1346
1342
  passes = false;
1347
1343
  }
1348
1344
  return {
@@ -1517,8 +1513,7 @@ var useSharedProposal = ({ proposalId, contractAddress, autoFetch = true }) => {
1517
1513
  const cacheKey = `${contractAddress}:${proposalId}`;
1518
1514
  useEffect5(() => {
1519
1515
  if (!proposalId || !contractAddress || !autoFetch) return;
1520
- fetchSharedProposal(proposalId, contractAddress).then(setLocalProposal).catch((error) => {
1521
- console.error("Failed to fetch proposal:", error);
1516
+ fetchSharedProposal(proposalId, contractAddress).then(setLocalProposal).catch(() => {
1522
1517
  });
1523
1518
  }, [proposalId, contractAddress, fetchSharedProposal, autoFetch]);
1524
1519
  useEffect5(() => {
@@ -2343,7 +2338,6 @@ var GeneralTab2 = ({ initialConfig, onSave }) => {
2343
2338
  const user = handlers.getCurrentUser();
2344
2339
  handleConfigChange("address", user.address);
2345
2340
  } catch (error) {
2346
- console.error("Failed to get current user:", error);
2347
2341
  }
2348
2342
  }
2349
2343
  };
@@ -2508,7 +2502,6 @@ var TemplateConfig2 = ({ editor, block }) => {
2508
2502
  listConfig = JSON.parse(block.props.listConfig);
2509
2503
  }
2510
2504
  } catch (error) {
2511
- console.error("Failed to parse listConfig:", error);
2512
2505
  }
2513
2506
  let sortOptions = {};
2514
2507
  try {
@@ -2516,7 +2509,6 @@ var TemplateConfig2 = ({ editor, block }) => {
2516
2509
  sortOptions = JSON.parse(block.props.sortOptions);
2517
2510
  }
2518
2511
  } catch (error) {
2519
- console.error("Failed to parse sortOptions:", error);
2520
2512
  }
2521
2513
  let filterOptions = {};
2522
2514
  try {
@@ -2524,7 +2516,6 @@ var TemplateConfig2 = ({ editor, block }) => {
2524
2516
  filterOptions = JSON.parse(block.props.filterOptions);
2525
2517
  }
2526
2518
  } catch (error) {
2527
- console.error("Failed to parse filterOptions:", error);
2528
2519
  }
2529
2520
  const initialConfig = listType && listConfig ? {
2530
2521
  type: listType,
@@ -2659,7 +2650,6 @@ var LinkedResourcesList = ({ items, isMultiSelect, isItemChecked, onItemCheck, c
2659
2650
  return /* @__PURE__ */ React26.createElement(Text8, { size: "sm", c: "dimmed", ta: "center", py: "md" }, "No linked resources found");
2660
2651
  }
2661
2652
  const rows = items.map((item, index) => {
2662
- console.log(item);
2663
2653
  const title = item.description || item.id || `Resource ${index + 1}`;
2664
2654
  const isChecked = isItemChecked?.(item.id);
2665
2655
  return /* @__PURE__ */ React26.createElement(ListItemContainer, { onClick: () => onItemCheck?.(item.id, !isChecked), key: item.id || index, isChecked: !!isChecked }, /* @__PURE__ */ React26.createElement(Flex3, { align: "center", gap: "sm" }, /* @__PURE__ */ React26.createElement(
@@ -3176,7 +3166,6 @@ var ListSelectionPanel = ({ selectedIds, listType }) => {
3176
3166
  setItemData({ id: selectedItemId });
3177
3167
  }
3178
3168
  } catch (err) {
3179
- console.error("Failed to fetch item details:", err);
3180
3169
  setError(err instanceof Error ? err.message : "Failed to fetch item details");
3181
3170
  } finally {
3182
3171
  setLoading(false);
@@ -3464,7 +3453,6 @@ var ListFlowView = ({ block, editor }) => {
3464
3453
  try {
3465
3454
  return JSON.parse(block.props.listConfig);
3466
3455
  } catch (error2) {
3467
- console.error("Failed to parse listConfig:", error2);
3468
3456
  return {};
3469
3457
  }
3470
3458
  }
@@ -3475,7 +3463,6 @@ var ListFlowView = ({ block, editor }) => {
3475
3463
  try {
3476
3464
  return JSON.parse(block.props.sortOptions);
3477
3465
  } catch (error2) {
3478
- console.error("Failed to parse listSortConfigOptions:", error2);
3479
3466
  return {};
3480
3467
  }
3481
3468
  }
@@ -3486,7 +3473,6 @@ var ListFlowView = ({ block, editor }) => {
3486
3473
  try {
3487
3474
  return JSON.parse(block.props.filterOptions);
3488
3475
  } catch (error2) {
3489
- console.error("Failed to parse listSortConfigOptions:", error2);
3490
3476
  return {};
3491
3477
  }
3492
3478
  }
@@ -3497,7 +3483,6 @@ var ListFlowView = ({ block, editor }) => {
3497
3483
  try {
3498
3484
  return JSON.parse(block.props.filter);
3499
3485
  } catch (error2) {
3500
- console.error("Failed to parse listSortConfigOptions:", error2);
3501
3486
  return {};
3502
3487
  }
3503
3488
  }
@@ -3508,7 +3493,6 @@ var ListFlowView = ({ block, editor }) => {
3508
3493
  try {
3509
3494
  return JSON.parse(block.props.sort);
3510
3495
  } catch (error2) {
3511
- console.error("Failed to parse listSortConfig:", error2);
3512
3496
  return {};
3513
3497
  }
3514
3498
  }
@@ -4000,7 +3984,6 @@ var GeneralTab3 = ({ title, description, coreAddress, onTitleChange, onDescripti
4000
3984
  useEffect9(() => {
4001
3985
  const fetchGroups = async () => {
4002
3986
  if (!handlers?.getDAOGroups) {
4003
- console.warn("getDAOGroups handler not available");
4004
3987
  return;
4005
3988
  }
4006
3989
  setLoadingGroups(true);
@@ -4008,7 +3991,6 @@ var GeneralTab3 = ({ title, description, coreAddress, onTitleChange, onDescripti
4008
3991
  const daoGroups = await handlers.getDAOGroups();
4009
3992
  setGroups(daoGroups);
4010
3993
  } catch (error) {
4011
- console.error("Failed to fetch DAO groups:", error);
4012
3994
  } finally {
4013
3995
  setLoadingGroups(false);
4014
3996
  }
@@ -6100,7 +6082,6 @@ var ActionsPanel = ({ actions, editingIndex, onSave, onCancel, isTemplateMode =
6100
6082
  if (!currentActionConfig) return;
6101
6083
  const validation = currentActionConfig.validateData(actionData);
6102
6084
  if (!validation.isValid) {
6103
- console.error("Validation errors:", validation.errors);
6104
6085
  return;
6105
6086
  }
6106
6087
  const action = {
@@ -6259,7 +6240,6 @@ var ActionsTab = ({ actions, onActionsChange, editor, block }) => {
6259
6240
  try {
6260
6241
  return JSON.parse(actionsJson);
6261
6242
  } catch (error) {
6262
- console.error("Failed to parse actions:", error);
6263
6243
  return [];
6264
6244
  }
6265
6245
  };
@@ -6561,9 +6541,6 @@ var useFlowBusinessLogic = ({ block, editor }) => {
6561
6541
  setProposalContractAddress(resolvedAddress);
6562
6542
  }
6563
6543
  } catch (error) {
6564
- if (!isCancelled) {
6565
- console.error("Failed to fetch proposal contract address:", error);
6566
- }
6567
6544
  }
6568
6545
  };
6569
6546
  void loadProposalContract();
@@ -6581,7 +6558,6 @@ var useFlowBusinessLogic = ({ block, editor }) => {
6581
6558
  }, [proposal, status]);
6582
6559
  const handleExecuteProposal = async () => {
6583
6560
  if (!handlers || !proposalContractAddress || !proposalId) {
6584
- console.error("Execute proposal: Missing required data");
6585
6561
  return;
6586
6562
  }
6587
6563
  setIsExecuting(true);
@@ -6595,7 +6571,6 @@ var useFlowBusinessLogic = ({ block, editor }) => {
6595
6571
  await refetch();
6596
6572
  } catch (error) {
6597
6573
  const message = error instanceof Error ? error.message : "Failed to execute proposal";
6598
- console.error("Failed to execute proposal:", error);
6599
6574
  setExecutionError(message);
6600
6575
  } finally {
6601
6576
  setIsExecuting(false);
@@ -6684,9 +6659,6 @@ var useVoteBusinessLogic = ({ block, editor }) => {
6684
6659
  setProposalContractAddress(resolvedAddress);
6685
6660
  }
6686
6661
  } catch (error) {
6687
- if (!isCancelled) {
6688
- console.error("[ProposalVote] Failed to fetch proposal contract address:", error);
6689
- }
6690
6662
  }
6691
6663
  };
6692
6664
  void loadProposalContract();
@@ -6707,9 +6679,6 @@ var useVoteBusinessLogic = ({ block, editor }) => {
6707
6679
  setUserVote(vote);
6708
6680
  }
6709
6681
  } catch (error) {
6710
- if (!isCancelled) {
6711
- console.error("[ProposalVote] Failed to fetch user vote:", error);
6712
- }
6713
6682
  }
6714
6683
  };
6715
6684
  void loadUserVote();
@@ -6725,7 +6694,6 @@ var useVoteBusinessLogic = ({ block, editor }) => {
6725
6694
  const vote = await handlers.getVote(voteParams.proposalContractAddress, voteParams.proposalId.toString(), user.address);
6726
6695
  setUserVote(vote);
6727
6696
  } catch (err) {
6728
- console.error("Failed to vote:", err);
6729
6697
  setLocalError("Failed to submit vote");
6730
6698
  }
6731
6699
  };
@@ -6987,7 +6955,6 @@ var ActionsTab2 = ({ actions, onActionsChange, editor, block, isProposalCreated
6987
6955
  try {
6988
6956
  return JSON.parse(actionsJson);
6989
6957
  } catch (error) {
6990
- console.error("Failed to parse actions:", error);
6991
6958
  return [];
6992
6959
  }
6993
6960
  };
@@ -7117,7 +7084,6 @@ var FlowConfig = ({ editor, block }) => {
7117
7084
  useEffect16(() => {
7118
7085
  const fetchGroups = async () => {
7119
7086
  if (!handlers?.getDAOGroups) {
7120
- console.warn("getDAOGroups handler not available");
7121
7087
  return;
7122
7088
  }
7123
7089
  setLoadingGroups(true);
@@ -7125,7 +7091,6 @@ var FlowConfig = ({ editor, block }) => {
7125
7091
  const daoGroups = await handlers.getDAOGroups();
7126
7092
  setGroups(daoGroups);
7127
7093
  } catch (error) {
7128
- console.error("Failed to fetch DAO groups:", error);
7129
7094
  } finally {
7130
7095
  setLoadingGroups(false);
7131
7096
  }
@@ -7329,12 +7294,9 @@ var ProposalFlowView = ({ block, editor }) => {
7329
7294
  // src/mantine/blocks/proposal/ProposalBlock.tsx
7330
7295
  function ProposalBlock({ editor, block }) {
7331
7296
  const { docType } = useBlocknoteContext();
7332
- console.log("[ProposalBlock] Rendering with docType:", docType);
7333
7297
  if (docType === "template") {
7334
- console.log("[ProposalBlock] Rendering ProposalTemplateView (docType is template)");
7335
7298
  return /* @__PURE__ */ React94.createElement(ProposalTemplateView, { editor, block });
7336
7299
  }
7337
- console.log("[ProposalBlock] Rendering ProposalFlowView (docType is flow)");
7338
7300
  return /* @__PURE__ */ React94.createElement(ProposalFlowView, { block, editor });
7339
7301
  }
7340
7302
 
@@ -7641,37 +7603,27 @@ function getNestedValue(obj, path) {
7641
7603
  }
7642
7604
  function resolveSingleReference(blockId, propPath, editorDocument) {
7643
7605
  if (!editorDocument || !Array.isArray(editorDocument)) {
7644
- console.warn("Invalid editor document provided to resolveSingleReference");
7645
7606
  return void 0;
7646
7607
  }
7647
7608
  const block = editorDocument.find((b) => b.id === blockId);
7648
7609
  if (!block) {
7649
- console.warn(`Block not found: ${blockId}`);
7650
7610
  return void 0;
7651
7611
  }
7652
7612
  if (propPath.startsWith("response.")) {
7653
7613
  const responseData = block.props.response;
7654
7614
  if (!responseData) {
7655
- console.warn(`No response data in block ${blockId}`);
7656
7615
  return void 0;
7657
7616
  }
7658
7617
  try {
7659
7618
  const parsedResponse = typeof responseData === "string" ? JSON.parse(responseData) : responseData;
7660
7619
  const innerPath = propPath.substring("response.".length);
7661
7620
  const value2 = getNestedValue(parsedResponse, innerPath);
7662
- if (value2 === void 0) {
7663
- console.warn(`Property not found in response: ${innerPath} in block ${blockId}`);
7664
- }
7665
7621
  return value2;
7666
7622
  } catch (error) {
7667
- console.warn(`Failed to parse response JSON for block ${blockId}:`, error);
7668
7623
  return void 0;
7669
7624
  }
7670
7625
  }
7671
7626
  const value = getNestedValue(block.props, propPath);
7672
- if (value === void 0) {
7673
- console.warn(`Property not found: ${propPath} in block ${blockId}`);
7674
- }
7675
7627
  return value;
7676
7628
  }
7677
7629
  function resolveReferences(input, editorDocument, options = {}) {
@@ -8280,7 +8232,6 @@ var ApiRequestFlowView = ({ editor, block, isDisabled }) => {
8280
8232
  if (schema && schema.fields.length > 0) {
8281
8233
  const errors = validateResponseAgainstSchema(responseData, schema);
8282
8234
  if (errors.length > 0) {
8283
- console.warn("Response validation warnings:", errors);
8284
8235
  setValidationWarnings(errors);
8285
8236
  setShowDetails(true);
8286
8237
  } else {
@@ -8818,7 +8769,6 @@ var EnumChecklistBlockContent = ({ block, editor }) => {
8818
8769
  try {
8819
8770
  return JSON.parse(block.props.listConfig);
8820
8771
  } catch (error) {
8821
- console.error("Failed to parse listConfig:", error);
8822
8772
  return {};
8823
8773
  }
8824
8774
  }
@@ -8829,7 +8779,6 @@ var EnumChecklistBlockContent = ({ block, editor }) => {
8829
8779
  try {
8830
8780
  return new Set(JSON.parse(block.props.selectedIds));
8831
8781
  } catch (error) {
8832
- console.error("Failed to parse selectedIds:", error);
8833
8782
  return /* @__PURE__ */ new Set();
8834
8783
  }
8835
8784
  }
@@ -9565,7 +9514,6 @@ var CollectionSelector = ({
9565
9514
  onAdminAddressChange,
9566
9515
  currentAdminAddress
9567
9516
  }) => {
9568
- console.log("[CollectionSelector] Rendered with selectedCollections:", selectedCollections);
9569
9517
  const handlers = useBlocknoteHandlers();
9570
9518
  const [localDid, setLocalDid] = useState31(did || "");
9571
9519
  const [collections, setCollections] = useState31([]);
@@ -9596,7 +9544,6 @@ var CollectionSelector = ({
9596
9544
  setError("No claim collections found for this DID");
9597
9545
  }
9598
9546
  } catch (err) {
9599
- console.error("Error fetching claim collections:", err);
9600
9547
  setError(err instanceof Error ? err.message : "Failed to fetch claim collections");
9601
9548
  setCollections([]);
9602
9549
  } finally {
@@ -9605,11 +9552,8 @@ var CollectionSelector = ({
9605
9552
  };
9606
9553
  const handleToggleCollection = (collectionId) => {
9607
9554
  if (!collectionId) return;
9608
- console.log("[CollectionSelector] Toggle collection:", collectionId);
9609
- console.log("[CollectionSelector] Current selectedCollections:", selectedCollections);
9610
9555
  const currentSelections = selectedCollections || [];
9611
9556
  const newSelected = currentSelections.includes(collectionId) ? currentSelections.filter((id) => id !== collectionId) : [...currentSelections, collectionId];
9612
- console.log("[CollectionSelector] New selectedCollections:", newSelected);
9613
9557
  onCollectionsChange(newSelected);
9614
9558
  };
9615
9559
  const getCollectionName = (collection) => {
@@ -9671,9 +9615,7 @@ var GeneralTab6 = ({
9671
9615
  }, [selectedCollections]);
9672
9616
  const handleCollectionsChange = useCallback20(
9673
9617
  (collections) => {
9674
- console.log("[Claim GeneralTab] handleCollectionsChange called with:", collections);
9675
9618
  const stringified = JSON.stringify(collections || []);
9676
- console.log("[Claim GeneralTab] Stringified:", stringified);
9677
9619
  onSelectedCollectionsChange(stringified);
9678
9620
  },
9679
9621
  [onSelectedCollectionsChange]
@@ -9729,7 +9671,6 @@ var TemplateConfig6 = ({ editor, block }) => {
9729
9671
  const { closePanel } = usePanelStore();
9730
9672
  const updateProp = useCallback21(
9731
9673
  (key, value) => {
9732
- console.log("[Claim TemplateConfig] Updating prop:", key, value);
9733
9674
  editor.updateBlock(block, {
9734
9675
  props: {
9735
9676
  ...block.props,
@@ -9803,12 +9744,12 @@ var ClaimTemplateView = ({ editor, block }) => {
9803
9744
  };
9804
9745
 
9805
9746
  // src/mantine/blocks/claim/flow/FlowView.tsx
9806
- import React124, { useState as useState35, useEffect as useEffect24, useMemo as useMemo23, useCallback as useCallback23 } from "react";
9747
+ import React124, { useState as useState35, useEffect as useEffect24, useMemo as useMemo23, useCallback as useCallback23, useRef as useRef5 } from "react";
9807
9748
  import { Stack as Stack88, Text as Text62, Loader as Loader11, Center as Center5, Alert as Alert15, Title as Title11, Flex as Flex22, ActionIcon as ActionIcon16 } from "@mantine/core";
9808
9749
  import { IconSettings as IconSettings3, IconRefresh as IconRefresh2, IconAlertCircle as IconAlertCircle3 } from "@tabler/icons-react";
9809
9750
 
9810
9751
  // src/mantine/blocks/claim/flow/ClaimCollectionsList.tsx
9811
- import React123, { useMemo as useMemo22, useState as useState34, useEffect as useEffect23 } from "react";
9752
+ import React123, { useMemo as useMemo22, useState as useState34, useEffect as useEffect23, useRef as useRef4 } from "react";
9812
9753
  import { Stack as Stack87, Text as Text61, ActionIcon as ActionIcon15, Tooltip as Tooltip8, Loader as Loader10, Center as Center4 } from "@mantine/core";
9813
9754
 
9814
9755
  // src/mantine/blocks/claim/flow/ClaimsListSheet.tsx
@@ -9987,7 +9928,9 @@ var ClaimsListSheet = ({ collectionId, collectionName, deedId, adminAddress, use
9987
9928
  const [surveyJson, setSurveyJson] = useState33(null);
9988
9929
  const [surveyLoading, setSurveyLoading] = useState33(false);
9989
9930
  const [surveyError, setSurveyError] = useState33(null);
9931
+ console.log("[ClaimsListSheet] render", { collectionId, collectionName, deedId, adminAddress, userAddress, viewMode });
9990
9932
  const fetchClaims = useCallback22(async () => {
9933
+ console.log("[ClaimsListSheet] fetchClaims start", { collectionId, userAddress });
9991
9934
  try {
9992
9935
  setLoading(true);
9993
9936
  setError(null);
@@ -9995,36 +9938,51 @@ var ClaimsListSheet = ({ collectionId, collectionName, deedId, adminAddress, use
9995
9938
  collectionId,
9996
9939
  userAddress
9997
9940
  });
9998
- setClaims(result || []);
9941
+ console.log("[ClaimsListSheet] fetchClaims result", result);
9942
+ if (!result) {
9943
+ alert("Error in ClaimsListSheet.tsx:37 - getClaimsPerUserAddress() returned no data");
9944
+ }
9945
+ setClaims(Array.isArray(result) ? result : []);
9999
9946
  } catch (err) {
10000
- console.error("Error fetching claims:", err);
10001
- setError(err instanceof Error ? err.message : "Failed to fetch claims");
9947
+ const errorMsg = err instanceof Error ? err.message : "Failed to fetch claims";
9948
+ alert(`Error in ClaimsListSheet.tsx:37 - getClaimsPerUserAddress() failed: ${errorMsg}`);
9949
+ setError(errorMsg);
10002
9950
  setClaims([]);
10003
9951
  } finally {
10004
9952
  setLoading(false);
10005
9953
  }
10006
- }, [collectionId, userAddress, handlers]);
9954
+ }, [collectionId, userAddress]);
10007
9955
  const fetchSurveyTemplate = useCallback22(async () => {
9956
+ console.log("[ClaimsListSheet] fetchSurveyTemplate start", { deedId });
10008
9957
  try {
10009
9958
  setSurveyLoading(true);
10010
9959
  setSurveyError(null);
10011
9960
  const result = await handlers.getDeedSurveyTemplate(deedId);
10012
- if (result) {
9961
+ console.log("[ClaimsListSheet] fetchSurveyTemplate result", result);
9962
+ if (!result) {
9963
+ alert("Error in ClaimsListSheet.tsx:65 - getDeedSurveyTemplate() returned no data");
9964
+ setSurveyError("No data returned from getDeedSurveyTemplate");
9965
+ } else if (result?.surveyTemplate) {
10013
9966
  setSurveyJson(result.surveyTemplate);
10014
9967
  } else {
9968
+ alert("Error in ClaimsListSheet.tsx:65 - getDeedSurveyTemplate() returned data without surveyTemplate");
10015
9969
  setSurveyError("No survey template found for this deed");
10016
9970
  }
10017
9971
  } catch (err) {
10018
- console.error("Error fetching survey template:", err);
10019
- setSurveyError(err instanceof Error ? err.message : "Failed to load survey template");
9972
+ const errorMsg = err instanceof Error ? err.message : "Failed to load survey template";
9973
+ alert(`Error in ClaimsListSheet.tsx:65 - getDeedSurveyTemplate() failed: ${errorMsg}`);
9974
+ setSurveyError(errorMsg);
9975
+ setSurveyJson(null);
10020
9976
  } finally {
10021
9977
  setSurveyLoading(false);
10022
9978
  }
10023
- }, [deedId, handlers]);
9979
+ }, [deedId]);
10024
9980
  useEffect22(() => {
9981
+ console.log("[ClaimsListSheet] useEffect fetchClaims");
10025
9982
  fetchClaims();
10026
9983
  }, [fetchClaims]);
10027
9984
  const surveyModel = useMemo21(() => {
9985
+ console.log("[ClaimsListSheet] surveyModel useMemo", { hasSurveyJson: !!surveyJson });
10028
9986
  if (!surveyJson) return null;
10029
9987
  const model = new SurveyModel(surveyJson);
10030
9988
  model.applyTheme(surveyTheme);
@@ -10034,17 +9992,28 @@ var ClaimsListSheet = ({ collectionId, collectionName, deedId, adminAddress, use
10034
9992
  }, [surveyJson]);
10035
9993
  const handleSurveyComplete = useCallback22(
10036
9994
  async (sender) => {
9995
+ console.log("[ClaimsListSheet] handleSurveyComplete fired", { data: sender?.data });
10037
9996
  const surveyData = sender.data;
10038
- console.log("Survey completed:", surveyData);
10039
9997
  try {
10040
9998
  const pin = await handlers.requestPin({
10041
9999
  title: "Verify Identity",
10042
10000
  description: "Enter your PIN to submit the claim",
10043
10001
  submitText: "Verify"
10044
10002
  });
10003
+ console.log("[ClaimsListSheet] requestPin resolved", { hasPin: !!pin });
10004
+ if (!pin) {
10005
+ alert("Error in ClaimsListSheet.tsx:107 - requestPin() returned no data");
10006
+ throw new Error("No PIN provided");
10007
+ }
10045
10008
  if (!adminAddress) {
10046
10009
  throw new Error("Admin address is not set. Please configure the claim block first.");
10047
10010
  }
10011
+ console.log("[ClaimsListSheet] submitClaim payload", {
10012
+ deedId,
10013
+ collectionId,
10014
+ adminAddress,
10015
+ surveyDataKeys: Object.keys(surveyData || {})
10016
+ });
10048
10017
  const result = await handlers.submitClaim({
10049
10018
  surveyData,
10050
10019
  deedDid: deedId,
@@ -10052,37 +10021,58 @@ var ClaimsListSheet = ({ collectionId, collectionName, deedId, adminAddress, use
10052
10021
  adminAddress,
10053
10022
  pin
10054
10023
  });
10055
- console.log("Claim submitted successfully:", result);
10024
+ console.log("[ClaimsListSheet] submitClaim result", result);
10025
+ if (!result) {
10026
+ alert("Error in ClaimsListSheet.tsx:119 - submitClaim() returned no data");
10027
+ throw new Error("No result returned from submitClaim");
10028
+ }
10056
10029
  closePanel();
10057
10030
  onSubmitComplete?.();
10058
10031
  } catch (error2) {
10059
- console.error("Failed to submit claim:", error2);
10060
- setSurveyError(error2 instanceof Error ? error2.message : "Failed to submit claim");
10032
+ const errorMsg = error2 instanceof Error ? error2.message : "Failed to submit claim";
10033
+ if (error2 instanceof Error && error2.message === "No PIN provided") {
10034
+ } else if (error2 instanceof Error && error2.message === "No result returned from submitClaim") {
10035
+ } else if (error2 instanceof Error && error2.message.includes("requestPin")) {
10036
+ alert(`Error in ClaimsListSheet.tsx:107 - requestPin() failed: ${errorMsg}`);
10037
+ } else if (error2 instanceof Error && error2.message.includes("submitClaim")) {
10038
+ alert(`Error in ClaimsListSheet.tsx:119 - submitClaim() failed: ${errorMsg}`);
10039
+ } else {
10040
+ alert(`Error in ClaimsListSheet.tsx:107-119 - Handler failed: ${errorMsg}`);
10041
+ }
10042
+ console.error("[ClaimsListSheet] handleSurveyComplete error", error2);
10043
+ setSurveyError(errorMsg);
10061
10044
  }
10062
10045
  },
10063
10046
  [handlers, deedId, collectionId, adminAddress, closePanel, onSubmitComplete]
10064
10047
  );
10065
10048
  useEffect22(() => {
10066
10049
  if (surveyModel) {
10050
+ console.log("[ClaimsListSheet] register surveyModel.onComplete listener");
10067
10051
  surveyModel.onComplete.add(handleSurveyComplete);
10068
10052
  return () => {
10053
+ console.log("[ClaimsListSheet] cleanup surveyModel.onComplete listener");
10069
10054
  surveyModel.onComplete.remove(handleSurveyComplete);
10070
10055
  };
10071
10056
  }
10072
10057
  return void 0;
10073
10058
  }, [surveyModel, handleSurveyComplete]);
10074
10059
  const handleNewClaim = () => {
10060
+ console.log("[ClaimsListSheet] handleNewClaim", { hasSurveyJson: !!surveyJson });
10075
10061
  if (!surveyJson) {
10076
10062
  fetchSurveyTemplate();
10077
10063
  }
10078
10064
  setViewMode("survey");
10079
10065
  };
10080
10066
  const handleBackToList = () => {
10067
+ console.log("[ClaimsListSheet] handleBackToList");
10081
10068
  setViewMode("list");
10082
10069
  setSurveyError(null);
10083
10070
  fetchClaims();
10084
10071
  };
10085
10072
  const getClaimStatus = (paymentsStatus) => {
10073
+ if (!paymentsStatus) {
10074
+ return "pending";
10075
+ }
10086
10076
  if (paymentsStatus.approval === "PAID") {
10087
10077
  return "approved";
10088
10078
  }
@@ -10190,18 +10180,37 @@ var ClaimsListSheet = ({ collectionId, collectionName, deedId, adminAddress, use
10190
10180
 
10191
10181
  // src/mantine/blocks/claim/flow/ClaimCollectionsList.tsx
10192
10182
  import { IconArrowRight as IconArrowRight2 } from "@tabler/icons-react";
10183
+ var isClientFulfillmentError = (error) => {
10184
+ const message = error instanceof Error ? error.message : String(error ?? "");
10185
+ return /client(?:.+)?(cannot|can't).+fulfil?/i.test(message);
10186
+ };
10193
10187
  var CollectionItem = ({ collection, deedId, adminAddress, userRole, onRefresh }) => {
10194
- const handlers = useBlocknoteHandlers();
10195
- const currentUser = handlers.getCurrentUser();
10196
- const getCollectionName = (collection2) => {
10197
- return collection2.protocol?.profile?.name || collection2.name || "Unnamed Collection";
10198
- };
10188
+ console.log("[CollectionItem] RENDER START", { collectionId: collection.id, userRole });
10189
+ const { getCurrentUser } = useBlocknoteHandlers();
10190
+ let currentUser;
10191
+ try {
10192
+ console.log("[CollectionItem] Calling getCurrentUser...");
10193
+ currentUser = getCurrentUser();
10194
+ console.log("[CollectionItem] getCurrentUser result:", currentUser);
10195
+ if (!currentUser) {
10196
+ alert("Error in ClaimCollectionsList.tsx:31 - getCurrentUser() returned no data");
10197
+ currentUser = { address: "" };
10198
+ }
10199
+ } catch (err) {
10200
+ console.log("[CollectionItem] getCurrentUser ERROR:", err);
10201
+ alert(`Error in ClaimCollectionsList.tsx:31 - getCurrentUser() failed: ${err instanceof Error ? err.message : String(err)}`);
10202
+ currentUser = { address: "" };
10203
+ }
10204
+ const getCollectionName = (collection2) => collection2.protocol?.profile?.name || collection2.name || "Unnamed Collection";
10199
10205
  const isServiceAgent = userRole === "SA" /* ServiceProvider */;
10200
10206
  const canAccessClaims = isServiceAgent;
10201
10207
  const claimsPanelId = `claims-list-${collection.id}`;
10202
10208
  const collectionName = getCollectionName(collection);
10203
- const claimsPanelContent = useMemo22(
10204
- () => /* @__PURE__ */ React123.createElement(
10209
+ console.log("[CollectionItem] Panel setup", { claimsPanelId, collectionName, canAccessClaims });
10210
+ console.log("[CollectionItem] Creating claimsPanelContent useMemo...");
10211
+ const claimsPanelContent = useMemo22(() => {
10212
+ console.log("[CollectionItem] claimsPanelContent useMemo EXECUTING", { collectionId: collection.id });
10213
+ return /* @__PURE__ */ React123.createElement(
10205
10214
  ClaimsListSheet,
10206
10215
  {
10207
10216
  collectionId: collection.id,
@@ -10211,130 +10220,293 @@ var CollectionItem = ({ collection, deedId, adminAddress, userRole, onRefresh })
10211
10220
  userAddress: currentUser.address,
10212
10221
  onSubmitComplete: onRefresh
10213
10222
  }
10214
- ),
10215
- [collection.id, collectionName, deedId, adminAddress, currentUser.address, onRefresh]
10216
- );
10223
+ );
10224
+ }, [collection.id, collectionName, deedId, adminAddress, currentUser.address, onRefresh]);
10225
+ console.log("[CollectionItem] Calling usePanel with panelId:", claimsPanelId);
10217
10226
  const { open: openClaimsPanel } = usePanel(claimsPanelId, claimsPanelContent);
10227
+ console.log("[CollectionItem] usePanel returned");
10218
10228
  const handleClick = () => {
10229
+ console.log("[CollectionItem] handleClick called", { canAccessClaims });
10219
10230
  if (canAccessClaims) {
10231
+ console.log("[CollectionItem] Opening claims panel...");
10220
10232
  openClaimsPanel();
10221
10233
  }
10222
10234
  };
10223
- return /* @__PURE__ */ React123.createElement("div", { style: { opacity: canAccessClaims ? 1 : 0.5 } }, /* @__PURE__ */ React123.createElement(ListItemContainer, null, /* @__PURE__ */ React123.createElement(Stack87, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React123.createElement(Text61, { size: "sm", fw: 500, c: canAccessClaims ? void 0 : "dimmed" }, getCollectionName(collection)), collection.description && /* @__PURE__ */ React123.createElement(Text61, { size: "xs", c: "dimmed" }, collection.description)), /* @__PURE__ */ React123.createElement(Tooltip8, { label: "You need to apply to be a service agent first", disabled: canAccessClaims, position: "left", withArrow: true }, /* @__PURE__ */ React123.createElement(ActionIcon15, { variant: "subtle", size: "lg", onClick: handleClick, disabled: !canAccessClaims, style: { cursor: canAccessClaims ? "pointer" : "not-allowed" } }, /* @__PURE__ */ React123.createElement(IconArrowRight2, { size: 20 })))));
10235
+ return /* @__PURE__ */ React123.createElement("div", { style: { opacity: canAccessClaims ? 1 : 0.5 } }, /* @__PURE__ */ React123.createElement(ListItemContainer, null, /* @__PURE__ */ React123.createElement(Stack87, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React123.createElement(Text61, { size: "sm", fw: 500, c: canAccessClaims ? void 0 : "dimmed" }, collectionName), collection.description && /* @__PURE__ */ React123.createElement(Text61, { size: "xs", c: "dimmed" }, collection.description)), /* @__PURE__ */ React123.createElement(Tooltip8, { label: "You need to apply to be a service agent first", disabled: canAccessClaims, position: "left", withArrow: true }, /* @__PURE__ */ React123.createElement(ActionIcon15, { variant: "subtle", size: "lg", onClick: handleClick, disabled: !canAccessClaims, style: { cursor: canAccessClaims ? "pointer" : "not-allowed" } }, /* @__PURE__ */ React123.createElement(IconArrowRight2, { size: 20 })))));
10224
10236
  };
10225
10237
  var ClaimCollectionsList = ({ collections, deedId, adminAddress, userAddress, onRefresh }) => {
10226
- const handlers = useBlocknoteHandlers();
10238
+ console.log("[ClaimCollectionsList] RENDER START", {
10239
+ collectionsCount: collections.length,
10240
+ deedId,
10241
+ adminAddress,
10242
+ userAddress
10243
+ });
10244
+ const { getUserRoles } = useBlocknoteHandlers();
10245
+ const getUserRolesRef = useRef4(getUserRoles);
10246
+ useEffect23(() => {
10247
+ getUserRolesRef.current = getUserRoles;
10248
+ }, [getUserRoles]);
10249
+ console.log("[ClaimCollectionsList] getUserRoles handler obtained");
10227
10250
  const [userRoles, setUserRoles] = useState34({});
10228
10251
  const [loadingRoles, setLoadingRoles] = useState34(true);
10252
+ console.log("[ClaimCollectionsList] State:", { userRoles, loadingRoles });
10253
+ const failedRequestKeyRef = useRef4(null);
10254
+ console.log("[ClaimCollectionsList] Creating collectionIdsKey useMemo...");
10255
+ const collectionIdsKey = useMemo22(() => {
10256
+ const key = collections.map((c) => c.id).sort().join("|");
10257
+ console.log("[ClaimCollectionsList] collectionIdsKey computed:", key);
10258
+ return key;
10259
+ }, [collections]);
10260
+ console.log("[ClaimCollectionsList] Creating requestKey useMemo...");
10261
+ const requestKey = useMemo22(() => {
10262
+ const key = [userAddress, adminAddress, deedId, collectionIdsKey].filter(Boolean).join("|");
10263
+ console.log("[ClaimCollectionsList] requestKey computed:", key);
10264
+ return key;
10265
+ }, [userAddress, adminAddress, deedId, collectionIdsKey]);
10229
10266
  useEffect23(() => {
10267
+ console.log("[ClaimCollectionsList] useEffect TRIGGERED");
10268
+ let isMounted = true;
10269
+ const setEmptyRoles = () => {
10270
+ console.log("[ClaimCollectionsList] setEmptyRoles called");
10271
+ const rolesMap = {};
10272
+ collections.forEach((collection) => {
10273
+ rolesMap[collection.id] = null;
10274
+ });
10275
+ if (isMounted) {
10276
+ console.log("[ClaimCollectionsList] Setting empty roles map");
10277
+ setUserRoles(rolesMap);
10278
+ }
10279
+ };
10230
10280
  const fetchUserRoles = async () => {
10231
- if (!collections || collections.length === 0 || !userAddress || !adminAddress) {
10281
+ console.log("[ClaimCollectionsList] fetchUserRoles CALLED");
10282
+ if (!collections.length || !userAddress || !adminAddress) {
10283
+ console.log("[ClaimCollectionsList] EARLY RETURN - missing data", { collectionsLength: collections.length, userAddress, adminAddress });
10284
+ setLoadingRoles(false);
10285
+ return;
10286
+ }
10287
+ if (!requestKey || failedRequestKeyRef.current === requestKey) {
10288
+ console.log("[ClaimCollectionsList] EARLY RETURN - no requestKey or failed request", { requestKey, failedKey: failedRequestKeyRef.current });
10289
+ setLoadingRoles(false);
10290
+ return;
10291
+ }
10292
+ const getUserRolesFn = getUserRolesRef.current;
10293
+ if (typeof getUserRolesFn !== "function") {
10294
+ console.log("[ClaimCollectionsList] getUserRoles is not a function");
10295
+ setEmptyRoles();
10232
10296
  setLoadingRoles(false);
10233
10297
  return;
10234
10298
  }
10235
10299
  try {
10300
+ console.log("[ClaimCollectionsList] Setting loadingRoles=true");
10236
10301
  setLoadingRoles(true);
10237
- const collectionIds = collections.map((c) => c.id);
10238
- const roles = await handlers.getUserRoles({
10302
+ console.log("[ClaimCollectionsList] Calling getUserRoles handler...");
10303
+ const roles = await getUserRolesFn({
10239
10304
  userAddress,
10240
10305
  adminAddress,
10241
10306
  deedDid: deedId,
10242
- collectionIds
10307
+ collectionIds: collections.map((c) => c.id)
10243
10308
  });
10309
+ console.log("[ClaimCollectionsList] getUserRoles response:", roles);
10310
+ if (!roles) {
10311
+ alert("Error in ClaimCollectionsList.tsx:147 - getUserRoles() returned no data");
10312
+ }
10313
+ console.log("[ClaimCollectionsList] Building roles map...");
10244
10314
  const rolesMap = {};
10245
10315
  collections.forEach((collection) => {
10246
10316
  const roleData = roles?.find((r) => r.collectionId === collection.id);
10247
10317
  rolesMap[collection.id] = roleData?.role || null;
10248
10318
  });
10249
- setUserRoles(rolesMap);
10319
+ console.log("[ClaimCollectionsList] Roles map built:", rolesMap);
10320
+ if (isMounted) {
10321
+ console.log("[ClaimCollectionsList] Setting user roles state");
10322
+ setUserRoles(rolesMap);
10323
+ }
10250
10324
  } catch (error) {
10251
- console.error("Error fetching user roles:", error);
10252
- const rolesMap = {};
10253
- collections.forEach((collection) => {
10254
- rolesMap[collection.id] = null;
10255
- });
10256
- setUserRoles(rolesMap);
10325
+ console.log("[ClaimCollectionsList] getUserRoles ERROR:", error);
10326
+ const errorMsg = error instanceof Error ? error.message : String(error);
10327
+ alert(`Error in ClaimCollectionsList.tsx:147 - getUserRoles() failed: ${errorMsg}`);
10328
+ if (isClientFulfillmentError(error)) {
10329
+ console.log("[ClaimCollectionsList] Client fulfillment error - caching failed request");
10330
+ failedRequestKeyRef.current = requestKey;
10331
+ } else {
10332
+ console.log("[ClaimCollectionsList] Not a client fulfillment error");
10333
+ failedRequestKeyRef.current = null;
10334
+ }
10335
+ setEmptyRoles();
10257
10336
  } finally {
10258
- setLoadingRoles(false);
10337
+ if (isMounted) {
10338
+ console.log("[ClaimCollectionsList] Setting loadingRoles=false");
10339
+ setLoadingRoles(false);
10340
+ }
10259
10341
  }
10260
10342
  };
10261
10343
  fetchUserRoles();
10262
- }, [collections, userAddress, adminAddress, handlers, deedId]);
10263
- if (!collections || collections.length === 0) {
10344
+ return () => {
10345
+ console.log("[ClaimCollectionsList] useEffect CLEANUP");
10346
+ isMounted = false;
10347
+ };
10348
+ }, [collections, userAddress, adminAddress, deedId, requestKey]);
10349
+ if (!collections?.length) {
10350
+ console.log("[ClaimCollectionsList] RENDER: No collections found");
10264
10351
  return /* @__PURE__ */ React123.createElement(Text61, { size: "sm", c: "dimmed", ta: "center", py: "md" }, "No claim collections found");
10265
10352
  }
10266
10353
  if (loadingRoles) {
10354
+ console.log("[ClaimCollectionsList] RENDER: Loading roles...");
10267
10355
  return /* @__PURE__ */ React123.createElement(Center4, { py: "md" }, /* @__PURE__ */ React123.createElement(Loader10, { size: "sm" }));
10268
10356
  }
10269
- return /* @__PURE__ */ React123.createElement(Stack87, { gap: "md", px: 5 }, collections.map((collection) => /* @__PURE__ */ React123.createElement(CollectionItem, { key: collection.id, collection, deedId, adminAddress, userRole: userRoles[collection.id] || null, onRefresh })));
10357
+ console.log("[ClaimCollectionsList] RENDER: Rendering collection items", { collectionsCount: collections.length });
10358
+ return /* @__PURE__ */ React123.createElement(Stack87, { gap: "md", px: 5 }, collections.map((collection) => {
10359
+ console.log("[ClaimCollectionsList] Rendering CollectionItem:", collection.id);
10360
+ return /* @__PURE__ */ React123.createElement(
10361
+ CollectionItem,
10362
+ {
10363
+ key: collection.id,
10364
+ collection,
10365
+ deedId,
10366
+ adminAddress,
10367
+ userRole: userRoles[collection.id] || null,
10368
+ onRefresh
10369
+ }
10370
+ );
10371
+ }));
10270
10372
  };
10271
10373
 
10272
10374
  // src/mantine/blocks/claim/flow/FlowView.tsx
10273
10375
  var CLAIM_FLOW_PANEL_ID = "claim-flow-panel";
10274
10376
  var ClaimFlowView = ({ editor, block }) => {
10377
+ console.log("[FlowView] RENDER START", { blockId: block.id });
10275
10378
  const { editable } = useBlocknoteContext();
10276
- const handlers = useBlocknoteHandlers();
10277
- const currentUser = handlers.getCurrentUser();
10379
+ console.log("[FlowView] editable:", editable);
10380
+ const { getCurrentUser, getClaimCollections } = useBlocknoteHandlers();
10381
+ console.log("[FlowView] handlers obtained");
10382
+ const getClaimCollectionsRef = useRef5(getClaimCollections);
10383
+ useEffect24(() => {
10384
+ getClaimCollectionsRef.current = getClaimCollections;
10385
+ }, [getClaimCollections]);
10386
+ let currentUser;
10387
+ try {
10388
+ console.log("[FlowView] Calling getCurrentUser...");
10389
+ currentUser = getCurrentUser();
10390
+ console.log("[FlowView] getCurrentUser result:", currentUser);
10391
+ if (!currentUser) {
10392
+ alert("Error in FlowView.tsx:16 - getCurrentUser() returned no data");
10393
+ currentUser = { address: "" };
10394
+ }
10395
+ } catch (err) {
10396
+ console.log("[FlowView] getCurrentUser ERROR:", err);
10397
+ alert(`Error in FlowView.tsx:16 - getCurrentUser() failed: ${err instanceof Error ? err.message : String(err)}`);
10398
+ currentUser = { address: "" };
10399
+ }
10278
10400
  const [collections, setCollections] = useState35([]);
10279
10401
  const [loading, setLoading] = useState35(false);
10280
10402
  const [error, setError] = useState35(null);
10403
+ console.log("[FlowView] State initialized", { collectionsCount: collections.length, loading, error });
10281
10404
  const panelId = `${CLAIM_FLOW_PANEL_ID}-${block.id}`;
10282
- const panelContent = useMemo23(() => /* @__PURE__ */ React124.createElement(TemplateConfig6, { editor, block }), [editor, block]);
10405
+ console.log("[FlowView] Creating panelContent useMemo...");
10406
+ const panelContent = useMemo23(() => {
10407
+ console.log("[FlowView] panelContent useMemo EXECUTING");
10408
+ return /* @__PURE__ */ React124.createElement(TemplateConfig6, { editor, block });
10409
+ }, [editor, block]);
10410
+ console.log("[FlowView] Calling usePanel with panelId:", panelId);
10283
10411
  const { open } = usePanel(panelId, panelContent);
10412
+ console.log("[FlowView] usePanel returned");
10284
10413
  const selectedCollectionIds = useMemo23(() => {
10414
+ console.log("[FlowView] selectedCollectionIds useMemo EXECUTING");
10285
10415
  try {
10286
- return JSON.parse(block.props.selectedCollections || "[]");
10416
+ const parsed = JSON.parse(block.props.selectedCollections || "[]");
10417
+ console.log("[FlowView] selectedCollectionIds parsed:", parsed);
10418
+ return parsed;
10287
10419
  } catch {
10420
+ console.log("[FlowView] selectedCollectionIds parse error, returning []");
10288
10421
  return [];
10289
10422
  }
10290
10423
  }, [block.props.selectedCollections]);
10424
+ const selectedCollectionIdsKey = useMemo23(() => [...selectedCollectionIds].sort().join("|"), [selectedCollectionIds]);
10291
10425
  const did = block.props.deedDid;
10292
10426
  const adminAddress = block.props.adminAddress || "";
10427
+ console.log("[FlowView] Block props:", { did, adminAddress, selectedCollectionIds });
10428
+ const [fetchedAdminAddress, setFetchedAdminAddress] = useState35(null);
10293
10429
  const fetchCollections = useCallback23(async () => {
10430
+ console.log("[FlowView] fetchCollections CALLED", { did, selectedCollectionIdsLength: selectedCollectionIds.length });
10294
10431
  if (!did || selectedCollectionIds.length === 0) {
10432
+ console.log("[FlowView] fetchCollections EARLY RETURN (no did or collections)");
10295
10433
  setCollections([]);
10296
10434
  return;
10297
10435
  }
10436
+ console.log("[FlowView] fetchCollections setting loading=true");
10298
10437
  setLoading(true);
10299
10438
  setError(null);
10300
10439
  try {
10301
- const response = await handlers.getClaimCollections({ deedDid: did });
10302
- const { adminAddress: adminAddress2, collections: allCollections } = response || { adminAddress: "", collections: [] };
10303
- if (adminAddress2 && (!block.props.adminAddress || block.props.adminAddress === "")) {
10304
- editor.updateBlock(block, {
10305
- props: {
10306
- ...block.props,
10307
- adminAddress: adminAddress2
10308
- }
10309
- });
10440
+ console.log("[FlowView] fetchCollections calling getClaimCollections...");
10441
+ const response = await getClaimCollectionsRef.current({ deedDid: did });
10442
+ console.log("[FlowView] getClaimCollections response:", response);
10443
+ if (!response) {
10444
+ console.log("[FlowView] getClaimCollections returned NO DATA");
10445
+ alert("Error in FlowView.tsx:47 - getClaimCollections() returned no data");
10446
+ setError("No data returned from getClaimCollections");
10447
+ return;
10448
+ }
10449
+ const { adminAddress: responseAdminAddress, collections: allCollections } = response || { adminAddress: "", collections: [] };
10450
+ console.log("[FlowView] Destructured response:", { adminAddress: responseAdminAddress, allCollectionsCount: allCollections?.length });
10451
+ if (responseAdminAddress) {
10452
+ console.log("[FlowView] Storing fetched adminAddress for block update");
10453
+ setFetchedAdminAddress(responseAdminAddress);
10310
10454
  }
10311
10455
  const selectedCollections = (allCollections || []).filter((c) => selectedCollectionIds.includes(c?.id));
10456
+ console.log("[FlowView] Filtered collections:", { selectedCount: selectedCollections.length });
10457
+ console.log("[FlowView] Setting collections state...");
10312
10458
  setCollections(selectedCollections);
10459
+ console.log("[FlowView] Collections state SET");
10313
10460
  } catch (err) {
10314
- console.error("Error fetching collections:", err);
10315
- setError(err instanceof Error ? err.message : "Failed to fetch collections");
10461
+ console.log("[FlowView] getClaimCollections ERROR:", err);
10462
+ const errorMsg = err instanceof Error ? err.message : "Failed to fetch collections";
10463
+ alert(`Error in FlowView.tsx:47 - getClaimCollections() failed: ${errorMsg}`);
10464
+ setError(errorMsg);
10316
10465
  } finally {
10466
+ console.log("[FlowView] fetchCollections setting loading=false");
10317
10467
  setLoading(false);
10318
10468
  }
10319
- }, [did, selectedCollectionIds, handlers, editor, block]);
10469
+ }, [did, selectedCollectionIds, selectedCollectionIdsKey]);
10320
10470
  useEffect24(() => {
10471
+ if (fetchedAdminAddress && (!block.props.adminAddress || block.props.adminAddress === "")) {
10472
+ console.log("[FlowView] useEffect updating block adminAddress:", fetchedAdminAddress);
10473
+ editor.updateBlock(block, {
10474
+ props: {
10475
+ ...block.props,
10476
+ adminAddress: fetchedAdminAddress
10477
+ }
10478
+ });
10479
+ console.log("[FlowView] Block adminAddress updated in useEffect");
10480
+ setFetchedAdminAddress(null);
10481
+ }
10482
+ }, [fetchedAdminAddress, block.props.adminAddress, editor, block]);
10483
+ useEffect24(() => {
10484
+ console.log("[FlowView] useEffect TRIGGERED - calling fetchCollections");
10321
10485
  fetchCollections();
10486
+ console.log("[FlowView] useEffect fetchCollections call COMPLETED");
10322
10487
  }, [fetchCollections]);
10323
10488
  if (!did) {
10489
+ console.log("[FlowView] RENDER: No DID - showing config message");
10324
10490
  return /* @__PURE__ */ React124.createElement(Center5, { py: "xl" }, /* @__PURE__ */ React124.createElement(Text62, { size: "sm", c: "dimmed" }, "Please configure the claim block in template mode first"));
10325
10491
  }
10326
10492
  if (selectedCollectionIds.length === 0) {
10493
+ console.log("[FlowView] RENDER: No collections selected");
10327
10494
  return /* @__PURE__ */ React124.createElement(Center5, { py: "xl" }, /* @__PURE__ */ React124.createElement(Text62, { size: "sm", c: "dimmed" }, "No claim collections selected"));
10328
10495
  }
10329
- return /* @__PURE__ */ React124.createElement(Stack88, { w: "100%" }, /* @__PURE__ */ React124.createElement(Flex22, { px: 5, align: "center", justify: "space-between" }, /* @__PURE__ */ React124.createElement(Title11, { order: 4 }, "Submit Claims"), /* @__PURE__ */ React124.createElement(Flex22, { gap: "xs" }, /* @__PURE__ */ React124.createElement(ActionIcon16, { variant: "subtle", size: "sm", onClick: fetchCollections, loading }, /* @__PURE__ */ React124.createElement(IconRefresh2, { size: 18 })), editable && /* @__PURE__ */ React124.createElement(ActionIcon16, { variant: "subtle", size: "sm", onClick: open }, /* @__PURE__ */ React124.createElement(IconSettings3, { size: 18 })))), loading ? /* @__PURE__ */ React124.createElement(Center5, { py: "xl" }, /* @__PURE__ */ React124.createElement(Loader11, { size: "md" })) : error ? /* @__PURE__ */ React124.createElement(Alert15, { color: "red", title: "Failed to load collections", icon: /* @__PURE__ */ React124.createElement(IconAlertCircle3, { size: 18 }) }, /* @__PURE__ */ React124.createElement(Text62, { size: "sm" }, error)) : /* @__PURE__ */ React124.createElement(ClaimCollectionsList, { collections, deedId: did, adminAddress, userAddress: currentUser.address, onRefresh: fetchCollections }));
10496
+ console.log("[FlowView] RENDER: Main view", { loading, error, collectionsCount: collections.length });
10497
+ return /* @__PURE__ */ React124.createElement(Stack88, { w: "100%" }, /* @__PURE__ */ React124.createElement(Flex22, { px: 5, align: "center", justify: "space-between" }, /* @__PURE__ */ React124.createElement(Title11, { order: 4 }, "Submit Claims"), /* @__PURE__ */ React124.createElement(Flex22, { gap: "xs" }, /* @__PURE__ */ React124.createElement(ActionIcon16, { variant: "subtle", size: "sm", onClick: fetchCollections, loading }, /* @__PURE__ */ React124.createElement(IconRefresh2, { size: 18 })), editable && /* @__PURE__ */ React124.createElement(ActionIcon16, { variant: "subtle", size: "sm", onClick: open }, /* @__PURE__ */ React124.createElement(IconSettings3, { size: 18 })))), loading ? /* @__PURE__ */ React124.createElement(React124.Fragment, null, console.log("[FlowView] RENDER: Showing loader"), /* @__PURE__ */ React124.createElement(Center5, { py: "xl" }, /* @__PURE__ */ React124.createElement(Loader11, { size: "md" }))) : error ? /* @__PURE__ */ React124.createElement(React124.Fragment, null, console.log("[FlowView] RENDER: Showing error"), /* @__PURE__ */ React124.createElement(Alert15, { color: "red", title: "Failed to load collections", icon: /* @__PURE__ */ React124.createElement(IconAlertCircle3, { size: 18 }) }, /* @__PURE__ */ React124.createElement(Text62, { size: "sm" }, error))) : /* @__PURE__ */ React124.createElement(React124.Fragment, null, console.log("[FlowView] RENDER: Rendering ClaimCollectionsList"), /* @__PURE__ */ React124.createElement(ClaimCollectionsList, { collections, deedId: did, adminAddress, userAddress: currentUser.address, onRefresh: fetchCollections })));
10330
10498
  };
10331
10499
 
10332
10500
  // src/mantine/blocks/claim/ClaimBlock.tsx
10333
10501
  function ClaimBlock({ editor, block }) {
10502
+ console.log("[ClaimBlock] RENDER START", { blockId: block.id, docType: "..." });
10334
10503
  const { docType } = useBlocknoteContext();
10504
+ console.log("[ClaimBlock] docType:", docType);
10335
10505
  if (docType === "template") {
10506
+ console.log("[ClaimBlock] Rendering TEMPLATE view");
10336
10507
  return /* @__PURE__ */ React125.createElement(ClaimTemplateView, { editor, block });
10337
10508
  }
10509
+ console.log("[ClaimBlock] Rendering FLOW view");
10338
10510
  return /* @__PURE__ */ React125.createElement(ClaimFlowView, { editor, block });
10339
10511
  }
10340
10512
 
@@ -10547,12 +10719,12 @@ var BidTemplateView = ({ editor, block }) => {
10547
10719
  };
10548
10720
 
10549
10721
  // src/mantine/blocks/bid/flow/FlowView.tsx
10550
- import React135, { useState as useState41, useEffect as useEffect30, useMemo as useMemo30, useCallback as useCallback28 } from "react";
10722
+ import React135, { useState as useState41, useEffect as useEffect30, useMemo as useMemo30, useCallback as useCallback28, useRef as useRef7 } from "react";
10551
10723
  import { Stack as Stack94, Text as Text68, Loader as Loader16, Center as Center8, Alert as Alert18, Title as Title15, Flex as Flex23, ActionIcon as ActionIcon19 } from "@mantine/core";
10552
10724
  import { IconSettings as IconSettings4, IconRefresh as IconRefresh3, IconAlertCircle as IconAlertCircle6 } from "@tabler/icons-react";
10553
10725
 
10554
10726
  // src/mantine/blocks/bid/flow/ClaimCollectionsList.tsx
10555
- import React134, { useMemo as useMemo29, useState as useState40, useEffect as useEffect29 } from "react";
10727
+ import React134, { useMemo as useMemo29, useState as useState40, useEffect as useEffect29, useRef as useRef6 } from "react";
10556
10728
  import { Stack as Stack93, Text as Text67, Button as Button30, Menu as Menu2, Badge as Badge20, Collapse as Collapse5, Loader as Loader15, Center as Center7, ActionIcon as ActionIcon18 } from "@mantine/core";
10557
10729
  import { IconChevronDown as IconChevronDown5, IconArrowDown as IconArrowDown3, IconArrowUp as IconArrowUp3 } from "@tabler/icons-react";
10558
10730
 
@@ -10585,7 +10757,6 @@ var BidSurveyPanel = ({ deedId, collectionId, role, onSubmitComplete }) => {
10585
10757
  setError("No survey template found for this role");
10586
10758
  }
10587
10759
  } catch (err) {
10588
- console.error("Error fetching survey template:", err);
10589
10760
  setError(err instanceof Error ? err.message : "Failed to load survey template");
10590
10761
  } finally {
10591
10762
  setLoading(false);
@@ -10614,7 +10785,6 @@ var BidSurveyPanel = ({ deedId, collectionId, role, onSubmitComplete }) => {
10614
10785
  const handleSurveyComplete = useCallback26(
10615
10786
  async (sender) => {
10616
10787
  const surveyData = sender.data;
10617
- console.log("Survey completed:", surveyData);
10618
10788
  try {
10619
10789
  const bidRole = role === "service_agent" ? "SA" /* serviceProviders */ : "EA" /* evaluators */;
10620
10790
  await handlers.submitBid({
@@ -10622,11 +10792,9 @@ var BidSurveyPanel = ({ deedId, collectionId, role, onSubmitComplete }) => {
10622
10792
  role: bidRole,
10623
10793
  surveyAnswers: surveyData
10624
10794
  });
10625
- console.log("Bid submitted successfully");
10626
10795
  closePanel();
10627
10796
  onSubmitComplete?.();
10628
10797
  } catch (error2) {
10629
- console.error("Failed to submit bid:", error2);
10630
10798
  setError(error2 instanceof Error ? error2.message : "Failed to submit bid");
10631
10799
  }
10632
10800
  },
@@ -10716,7 +10884,6 @@ var BidViewPanel = ({ bid, deedId, adminAddress, onRefresh }) => {
10716
10884
  setError("No survey template found for this role");
10717
10885
  }
10718
10886
  } catch (err) {
10719
- console.error("Error fetching survey template:", err);
10720
10887
  setError(err instanceof Error ? err.message : "Failed to load survey template");
10721
10888
  } finally {
10722
10889
  setLoading(false);
@@ -10796,7 +10963,6 @@ var BidViewPanel = ({ bid, deedId, adminAddress, onRefresh }) => {
10796
10963
  closePanel();
10797
10964
  onRefresh?.();
10798
10965
  } catch (err) {
10799
- console.error("Error approving bid:", err);
10800
10966
  setActionError(err instanceof Error ? err.message : "Failed to approve bid");
10801
10967
  } finally {
10802
10968
  setActionLoading(false);
@@ -10820,7 +10986,6 @@ var BidViewPanel = ({ bid, deedId, adminAddress, onRefresh }) => {
10820
10986
  closePanel();
10821
10987
  onRefresh?.();
10822
10988
  } catch (err) {
10823
- console.error("Error rejecting bid:", err);
10824
10989
  setActionError(err instanceof Error ? err.message : "Failed to reject bid");
10825
10990
  } finally {
10826
10991
  setActionLoading(false);
@@ -10872,15 +11037,15 @@ var BidItem = ({ bid, deedId, adminAddress, onRefresh }) => {
10872
11037
  try {
10873
11038
  setLoadingProfile(true);
10874
11039
  const profile = await handlers.getMatrixInfoPerDid(bid.did);
10875
- setUserProfile(profile);
11040
+ setUserProfile(profile || null);
10876
11041
  } catch (error) {
10877
- console.error("Failed to fetch user profile:", error);
11042
+ setUserProfile(null);
10878
11043
  } finally {
10879
11044
  setLoadingProfile(false);
10880
11045
  }
10881
11046
  };
10882
11047
  fetchUserProfile();
10883
- }, [bid.did, handlers]);
11048
+ }, [bid.did]);
10884
11049
  const bidPanelId = `bid-view-${bid.id}`;
10885
11050
  const bidPanelContent = useMemo28(() => /* @__PURE__ */ React133.createElement(BidViewPanel, { bid, deedId, adminAddress, onRefresh }), [bid, deedId, adminAddress, onRefresh]);
10886
11051
  const { open: openBidPanel } = usePanel(bidPanelId, bidPanelContent);
@@ -10935,15 +11100,14 @@ var BidsList = ({ collectionId, deedId, adminAddress, onRefresh }) => {
10935
11100
  setLoading(true);
10936
11101
  setError(null);
10937
11102
  const response = await handlers.queryBids({ collectionId });
10938
- setBids(response?.data || []);
11103
+ setBids(Array.isArray(response?.data) ? response.data : []);
10939
11104
  } catch (err) {
10940
- console.error("Error fetching bids:", err);
10941
11105
  setError(err instanceof Error ? err.message : "Failed to fetch bids");
10942
11106
  setBids([]);
10943
11107
  } finally {
10944
11108
  setLoading(false);
10945
11109
  }
10946
- }, [collectionId, handlers]);
11110
+ }, [collectionId]);
10947
11111
  useEffect28(() => {
10948
11112
  fetchBids();
10949
11113
  }, [fetchBids]);
@@ -10964,6 +11128,10 @@ var BidsList = ({ collectionId, deedId, adminAddress, onRefresh }) => {
10964
11128
  };
10965
11129
 
10966
11130
  // src/mantine/blocks/bid/flow/ClaimCollectionsList.tsx
11131
+ var isClientFulfillmentError2 = (error) => {
11132
+ const message = error instanceof Error ? error.message : String(error ?? "");
11133
+ return /client(?:.+)?(cannot|can't).+fulfil?/i.test(message);
11134
+ };
10967
11135
  var CollectionItem2 = ({ collection, deedId, adminAddress, userRole, onRefresh }) => {
10968
11136
  const [isExpanded, setIsExpanded] = useState40(false);
10969
11137
  const getCollectionName = (collection2) => {
@@ -11019,19 +11187,49 @@ var CollectionItem2 = ({ collection, deedId, adminAddress, userRole, onRefresh }
11019
11187
  return /* @__PURE__ */ React134.createElement(Stack93, { gap: "xs" }, /* @__PURE__ */ React134.createElement(ListItemContainer, null, /* @__PURE__ */ React134.createElement(Stack93, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React134.createElement(Text67, { size: "sm", fw: 500 }, getCollectionName(collection)), collection.description && /* @__PURE__ */ React134.createElement(Text67, { size: "xs", c: "dimmed" }, collection.description)), renderActionButton()), userRole === "PO" /* Owner */ && /* @__PURE__ */ React134.createElement(Collapse5, { in: isExpanded }, /* @__PURE__ */ React134.createElement(BidsList, { collectionId: collection.id, deedId, adminAddress, onRefresh })));
11020
11188
  };
11021
11189
  var ClaimCollectionsList2 = ({ collections, deedId, adminAddress, userAddress, onRefresh }) => {
11022
- const handlers = useBlocknoteHandlers();
11190
+ const { getUserRoles } = useBlocknoteHandlers();
11191
+ const getUserRolesRef = useRef6(getUserRoles);
11192
+ useEffect29(() => {
11193
+ getUserRolesRef.current = getUserRoles;
11194
+ }, [getUserRoles]);
11023
11195
  const [userRoles, setUserRoles] = useState40({});
11024
11196
  const [loadingRoles, setLoadingRoles] = useState40(true);
11197
+ const failedRequestKeyRef = useRef6(null);
11198
+ const collectionIdsKey = useMemo29(
11199
+ () => collections.map((c) => c.id).sort().join("|"),
11200
+ [collections]
11201
+ );
11202
+ const requestKey = useMemo29(() => [userAddress, adminAddress, deedId, collectionIdsKey].filter(Boolean).join("|"), [userAddress, adminAddress, deedId, collectionIdsKey]);
11025
11203
  useEffect29(() => {
11204
+ let isMounted = true;
11205
+ const setEmptyRoles = () => {
11206
+ const rolesMap = {};
11207
+ collections.forEach((collection) => {
11208
+ rolesMap[collection.id] = null;
11209
+ });
11210
+ if (isMounted) {
11211
+ setUserRoles(rolesMap);
11212
+ }
11213
+ };
11026
11214
  const fetchUserRoles = async () => {
11027
11215
  if (!collections || collections.length === 0 || !userAddress || !adminAddress) {
11028
11216
  setLoadingRoles(false);
11029
11217
  return;
11030
11218
  }
11219
+ if (!requestKey || failedRequestKeyRef.current === requestKey) {
11220
+ setLoadingRoles(false);
11221
+ return;
11222
+ }
11223
+ const getUserRolesFn = getUserRolesRef.current;
11224
+ if (typeof getUserRolesFn !== "function") {
11225
+ setEmptyRoles();
11226
+ setLoadingRoles(false);
11227
+ return;
11228
+ }
11031
11229
  try {
11032
11230
  setLoadingRoles(true);
11033
11231
  const collectionIds = collections.map((c) => c.id);
11034
- const roles = await handlers.getUserRoles({
11232
+ const roles = await getUserRolesFn({
11035
11233
  userAddress,
11036
11234
  adminAddress,
11037
11235
  deedDid: deedId,
@@ -11044,18 +11242,23 @@ var ClaimCollectionsList2 = ({ collections, deedId, adminAddress, userAddress, o
11044
11242
  });
11045
11243
  setUserRoles(rolesMap);
11046
11244
  } catch (error) {
11047
- console.error("Error fetching user roles:", error);
11048
- const rolesMap = {};
11049
- collections.forEach((collection) => {
11050
- rolesMap[collection.id] = null;
11051
- });
11052
- setUserRoles(rolesMap);
11245
+ if (isClientFulfillmentError2(error)) {
11246
+ failedRequestKeyRef.current = requestKey;
11247
+ } else {
11248
+ failedRequestKeyRef.current = null;
11249
+ }
11250
+ setEmptyRoles();
11053
11251
  } finally {
11054
- setLoadingRoles(false);
11252
+ if (isMounted) {
11253
+ setLoadingRoles(false);
11254
+ }
11055
11255
  }
11056
11256
  };
11057
11257
  fetchUserRoles();
11058
- }, [collections, userAddress, adminAddress, handlers, deedId]);
11258
+ return () => {
11259
+ isMounted = false;
11260
+ };
11261
+ }, [collections, userAddress, adminAddress, deedId, requestKey]);
11059
11262
  if (!collections || collections.length === 0) {
11060
11263
  return /* @__PURE__ */ React134.createElement(Text67, { size: "sm", c: "dimmed", ta: "center", py: "md" }, "No claim collections found");
11061
11264
  }
@@ -11069,62 +11272,75 @@ var ClaimCollectionsList2 = ({ collections, deedId, adminAddress, userAddress, o
11069
11272
  var BID_FLOW_PANEL_ID = "bid-flow-panel";
11070
11273
  var BidFlowView = ({ editor, block }) => {
11071
11274
  const { editable } = useBlocknoteContext();
11072
- const handlers = useBlocknoteHandlers();
11275
+ const { getCurrentUser, getClaimCollections } = useBlocknoteHandlers();
11276
+ const getClaimCollectionsRef = useRef7(getClaimCollections);
11277
+ const getCurrentUserRef = useRef7(getCurrentUser);
11278
+ useEffect30(() => {
11279
+ getClaimCollectionsRef.current = getClaimCollections;
11280
+ getCurrentUserRef.current = getCurrentUser;
11281
+ }, [getCurrentUser, getClaimCollections]);
11073
11282
  const [collections, setCollections] = useState41([]);
11074
11283
  const [loading, setLoading] = useState41(false);
11075
11284
  const [error, setError] = useState41(null);
11076
11285
  const [userAddress, setUserAddress] = useState41("");
11286
+ const adminAddressUpdatedRef = useRef7(false);
11077
11287
  const panelId = `${BID_FLOW_PANEL_ID}-${block.id}`;
11078
11288
  const panelContent = useMemo30(() => /* @__PURE__ */ React135.createElement(TemplateConfig7, { editor, block }), [editor, block]);
11079
11289
  const { open } = usePanel(panelId, panelContent);
11080
11290
  const selectedCollectionIds = useMemo30(() => {
11081
11291
  try {
11082
- return JSON.parse(block.props.selectedCollections || "[]");
11292
+ const parsed = JSON.parse(block.props.selectedCollections || "[]");
11293
+ return Array.isArray(parsed) ? parsed : [];
11083
11294
  } catch {
11084
11295
  return [];
11085
11296
  }
11086
11297
  }, [block.props.selectedCollections]);
11298
+ const selectedCollectionIdsStr = useMemo30(() => JSON.stringify(selectedCollectionIds.sort()), [selectedCollectionIds]);
11087
11299
  const did = block.props.did;
11088
11300
  const adminAddress = block.props.adminAddress || "";
11089
11301
  useEffect30(() => {
11090
11302
  const fetchUserAddress = () => {
11091
11303
  try {
11092
- const user = handlers.getCurrentUser();
11304
+ const user = getCurrentUserRef.current();
11093
11305
  setUserAddress(user?.address || "");
11094
11306
  } catch (err) {
11095
- console.error("Error fetching current user:", err);
11096
11307
  setUserAddress("");
11097
11308
  }
11098
11309
  };
11099
11310
  fetchUserAddress();
11100
- }, [handlers]);
11311
+ }, []);
11101
11312
  const fetchCollections = useCallback28(async () => {
11102
11313
  if (!did || selectedCollectionIds.length === 0) {
11103
11314
  setCollections([]);
11104
11315
  return;
11105
11316
  }
11317
+ if (loading) {
11318
+ return;
11319
+ }
11106
11320
  setLoading(true);
11107
11321
  setError(null);
11108
11322
  try {
11109
- const response = await handlers.getClaimCollections({ deedDid: did });
11110
- const { adminAddress: adminAddress2, collections: allCollections } = response || { adminAddress: "", collections: [] };
11111
- if (adminAddress2 && (!block.props.adminAddress || block.props.adminAddress === "")) {
11323
+ const response = await getClaimCollectionsRef.current({ deedDid: did });
11324
+ const { adminAddress: fetchedAdminAddress = "", collections: allCollections = [] } = response || {};
11325
+ const currentAdminAddress = block.props.adminAddress || "";
11326
+ if (fetchedAdminAddress && !currentAdminAddress && !adminAddressUpdatedRef.current) {
11327
+ adminAddressUpdatedRef.current = true;
11112
11328
  editor.updateBlock(block, {
11113
11329
  props: {
11114
11330
  ...block.props,
11115
- adminAddress: adminAddress2
11331
+ adminAddress: fetchedAdminAddress
11116
11332
  }
11117
11333
  });
11118
11334
  }
11119
- const selectedCollections = (allCollections || []).filter((c) => selectedCollectionIds.includes(c?.id));
11335
+ const selectedCollections = Array.isArray(allCollections) ? allCollections.filter((c) => c && selectedCollectionIds.includes(c.id)) : [];
11120
11336
  setCollections(selectedCollections);
11121
11337
  } catch (err) {
11122
- console.error("Error fetching collections:", err);
11123
11338
  setError(err instanceof Error ? err.message : "Failed to fetch collections");
11339
+ setCollections([]);
11124
11340
  } finally {
11125
11341
  setLoading(false);
11126
11342
  }
11127
- }, [did, selectedCollectionIds, handlers, editor, block]);
11343
+ }, [did, selectedCollectionIdsStr]);
11128
11344
  useEffect30(() => {
11129
11345
  fetchCollections();
11130
11346
  }, [fetchCollections]);
@@ -11209,9 +11425,7 @@ var GeneralTab8 = ({
11209
11425
  }, [selectedCollections]);
11210
11426
  const handleCollectionsChange = useCallback29(
11211
11427
  (collections) => {
11212
- console.log("[Evaluator GeneralTab] handleCollectionsChange called with:", collections);
11213
11428
  const stringified = JSON.stringify(collections || []);
11214
- console.log("[Evaluator GeneralTab] Stringified:", stringified);
11215
11429
  onSelectedCollectionsChange(stringified);
11216
11430
  },
11217
11431
  [onSelectedCollectionsChange]
@@ -11267,7 +11481,6 @@ var TemplateConfig8 = ({ editor, block }) => {
11267
11481
  const { closePanel } = usePanelStore();
11268
11482
  const updateProp = useCallback30(
11269
11483
  (key, value) => {
11270
- console.log("[Evaluator TemplateConfig] Updating prop:", key, value);
11271
11484
  editor.updateBlock(block, {
11272
11485
  props: {
11273
11486
  ...block.props,
@@ -11341,12 +11554,12 @@ var EvaluatorTemplateView = ({ editor, block }) => {
11341
11554
  };
11342
11555
 
11343
11556
  // src/mantine/blocks/evaluator/flow/FlowView.tsx
11344
- import React143, { useState as useState45, useEffect as useEffect34, useMemo as useMemo35, useCallback as useCallback32 } from "react";
11557
+ import React143, { useState as useState45, useEffect as useEffect34, useMemo as useMemo35, useCallback as useCallback32, useRef as useRef9 } from "react";
11345
11558
  import { Stack as Stack98, Text as Text72, Loader as Loader19, Center as Center10, Alert as Alert20, Title as Title18, Flex as Flex24, ActionIcon as ActionIcon22 } from "@mantine/core";
11346
11559
  import { IconSettings as IconSettings5, IconRefresh as IconRefresh5, IconAlertCircle as IconAlertCircle8 } from "@tabler/icons-react";
11347
11560
 
11348
11561
  // src/mantine/blocks/evaluator/flow/ClaimCollectionsList.tsx
11349
- import React142, { useMemo as useMemo34, useState as useState44, useEffect as useEffect33 } from "react";
11562
+ import React142, { useMemo as useMemo34, useState as useState44, useEffect as useEffect33, useRef as useRef8 } from "react";
11350
11563
  import { Stack as Stack97, Text as Text71, ActionIcon as ActionIcon21, Tooltip as Tooltip9, Loader as Loader18, Center as Center9 } from "@mantine/core";
11351
11564
 
11352
11565
  // src/mantine/blocks/evaluator/flow/ClaimsList.tsx
@@ -11540,15 +11753,14 @@ var ClaimsList = ({ collectionId, collectionName, deedId, adminAddress, onEvalua
11540
11753
  const result = await handlers.getClaimsPerCollectionId({
11541
11754
  collectionId
11542
11755
  });
11543
- setClaims(result || []);
11756
+ setClaims(Array.isArray(result) ? result : []);
11544
11757
  } catch (err) {
11545
- console.error("Error fetching claims:", err);
11546
11758
  setError(err instanceof Error ? err.message : "Failed to fetch claims");
11547
11759
  setClaims([]);
11548
11760
  } finally {
11549
11761
  setLoading(false);
11550
11762
  }
11551
- }, [collectionId, handlers]);
11763
+ }, [collectionId]);
11552
11764
  useEffect32(() => {
11553
11765
  fetchClaims();
11554
11766
  }, [fetchClaims]);
@@ -11558,21 +11770,23 @@ var ClaimsList = ({ collectionId, collectionName, deedId, adminAddress, onEvalua
11558
11770
  setSurveyLoading(true);
11559
11771
  setSurveyError(null);
11560
11772
  const claimDataResult = await handlers.getClaimData(collectionId, claim.claimId);
11561
- setClaimData(claimDataResult);
11773
+ setClaimData(claimDataResult || null);
11562
11774
  const surveyResult = await handlers.getBidContributorSurveyTemplate(deedId);
11563
- if (surveyResult) {
11775
+ if (surveyResult?.surveyTemplate) {
11564
11776
  setSurveyJson(surveyResult.surveyTemplate);
11565
11777
  } else {
11566
11778
  setSurveyError("No survey template found for this deed");
11567
11779
  }
11568
11780
  } catch (err) {
11569
- console.error("Error fetching claim data:", err);
11570
11781
  setSurveyError(err instanceof Error ? err.message : "Failed to load claim data");
11782
+ setClaimData(null);
11783
+ setSurveyJson(null);
11571
11784
  } finally {
11572
11785
  setSurveyLoading(false);
11573
11786
  }
11574
11787
  },
11575
- [collectionId, deedId, handlers]
11788
+ // eslint-disable-next-line react-hooks/exhaustive-deps
11789
+ [collectionId, deedId]
11576
11790
  );
11577
11791
  const handleViewClaim = useCallback31(
11578
11792
  (claim) => {
@@ -11637,10 +11851,8 @@ var ClaimsList = ({ collectionId, collectionName, deedId, adminAddress, onEvalua
11637
11851
  // Optional - pass undefined for now
11638
11852
  }
11639
11853
  );
11640
- console.log("Claim approved successfully:", selectedClaim.claimId);
11641
11854
  handleBackToList();
11642
11855
  } catch (error2) {
11643
- console.error("Failed to approve claim:", error2);
11644
11856
  setSurveyError(error2 instanceof Error ? error2.message : "Failed to approve claim");
11645
11857
  setEvaluating(false);
11646
11858
  }
@@ -11650,10 +11862,8 @@ var ClaimsList = ({ collectionId, collectionName, deedId, adminAddress, onEvalua
11650
11862
  try {
11651
11863
  setEvaluating(true);
11652
11864
  setSurveyError(null);
11653
- console.log("Rejecting claim:", selectedClaim.claimId);
11654
11865
  handleBackToList();
11655
11866
  } catch (error2) {
11656
- console.error("Failed to reject claim:", error2);
11657
11867
  setSurveyError(error2 instanceof Error ? error2.message : "Failed to reject claim");
11658
11868
  } finally {
11659
11869
  setEvaluating(false);
@@ -11746,15 +11956,15 @@ var ClaimListItem = ({ claim, onViewClaim }) => {
11746
11956
  try {
11747
11957
  setLoadingProfile(true);
11748
11958
  const profile = await handlers.getMatrixInfoPerDid(claim.agentDid);
11749
- setUserProfile(profile);
11959
+ setUserProfile(profile || null);
11750
11960
  } catch (error) {
11751
- console.error("Failed to fetch user profile:", error);
11961
+ setUserProfile(null);
11752
11962
  } finally {
11753
11963
  setLoadingProfile(false);
11754
11964
  }
11755
11965
  };
11756
11966
  fetchUserProfile();
11757
- }, [claim.agentDid, handlers]);
11967
+ }, [claim.agentDid]);
11758
11968
  const getClaimStatus = (claim2) => {
11759
11969
  if ("status" in claim2 && claim2.status) {
11760
11970
  const status = String(claim2.status).toLowerCase();
@@ -11813,9 +12023,17 @@ var ClaimListItem = ({ claim, onViewClaim }) => {
11813
12023
 
11814
12024
  // src/mantine/blocks/evaluator/flow/ClaimCollectionsList.tsx
11815
12025
  import { IconArrowRight as IconArrowRight5 } from "@tabler/icons-react";
12026
+ var isClientFulfillmentError3 = (error) => {
12027
+ const message = error instanceof Error ? error.message : String(error ?? "");
12028
+ return /client(?:.+)?(cannot|can't).+fulfil?/i.test(message);
12029
+ };
11816
12030
  var CollectionItem3 = ({ collection, deedId, adminAddress, userRole, onRefresh }) => {
11817
- const handlers = useBlocknoteHandlers();
11818
- const currentUser = handlers.getCurrentUser();
12031
+ const { getCurrentUser } = useBlocknoteHandlers();
12032
+ const getCurrentUserRef = useRef8(getCurrentUser);
12033
+ useEffect33(() => {
12034
+ getCurrentUserRef.current = getCurrentUser;
12035
+ }, [getCurrentUser]);
12036
+ const currentUser = getCurrentUserRef.current();
11819
12037
  const getCollectionName = (collection2) => {
11820
12038
  return collection2.protocol?.profile?.name || collection2.name || "Unnamed Collection";
11821
12039
  };
@@ -11846,19 +12064,49 @@ var CollectionItem3 = ({ collection, deedId, adminAddress, userRole, onRefresh }
11846
12064
  return /* @__PURE__ */ React142.createElement("div", { style: { opacity: canEvaluateClaims ? 1 : 0.5 } }, /* @__PURE__ */ React142.createElement(ListItemContainer, null, /* @__PURE__ */ React142.createElement(Stack97, { gap: 4, style: { flex: 1 } }, /* @__PURE__ */ React142.createElement(Text71, { size: "sm", fw: 500, c: canEvaluateClaims ? void 0 : "dimmed" }, getCollectionName(collection)), collection.description && /* @__PURE__ */ React142.createElement(Text71, { size: "xs", c: "dimmed" }, collection.description)), /* @__PURE__ */ React142.createElement(Tooltip9, { label: "You need to be an evaluator agent to review claims", disabled: canEvaluateClaims, position: "left", withArrow: true }, /* @__PURE__ */ React142.createElement(ActionIcon21, { variant: "subtle", size: "lg", onClick: handleClick, disabled: !canEvaluateClaims, style: { cursor: canEvaluateClaims ? "pointer" : "not-allowed" } }, /* @__PURE__ */ React142.createElement(IconArrowRight5, { size: 20 })))));
11847
12065
  };
11848
12066
  var ClaimCollectionsList3 = ({ collections, deedId, adminAddress, userAddress, onRefresh }) => {
11849
- const handlers = useBlocknoteHandlers();
12067
+ const { getUserRoles } = useBlocknoteHandlers();
12068
+ const getUserRolesRef = useRef8(getUserRoles);
12069
+ useEffect33(() => {
12070
+ getUserRolesRef.current = getUserRoles;
12071
+ }, [getUserRoles]);
11850
12072
  const [userRoles, setUserRoles] = useState44({});
11851
12073
  const [loadingRoles, setLoadingRoles] = useState44(true);
12074
+ const failedRequestKeyRef = useRef8(null);
12075
+ const collectionIdsKey = useMemo34(
12076
+ () => collections.map((c) => c.id).sort().join("|"),
12077
+ [collections]
12078
+ );
12079
+ const requestKey = useMemo34(() => [userAddress, adminAddress, deedId, collectionIdsKey].filter(Boolean).join("|"), [userAddress, adminAddress, deedId, collectionIdsKey]);
11852
12080
  useEffect33(() => {
12081
+ let isMounted = true;
12082
+ const setEmptyRoles = () => {
12083
+ const rolesMap = {};
12084
+ collections.forEach((collection) => {
12085
+ rolesMap[collection.id] = null;
12086
+ });
12087
+ if (isMounted) {
12088
+ setUserRoles(rolesMap);
12089
+ }
12090
+ };
11853
12091
  const fetchUserRoles = async () => {
11854
12092
  if (!collections || collections.length === 0 || !userAddress || !adminAddress) {
11855
12093
  setLoadingRoles(false);
11856
12094
  return;
11857
12095
  }
12096
+ if (!requestKey || failedRequestKeyRef.current === requestKey) {
12097
+ setLoadingRoles(false);
12098
+ return;
12099
+ }
12100
+ const getUserRolesFn = getUserRolesRef.current;
12101
+ if (typeof getUserRolesFn !== "function") {
12102
+ setEmptyRoles();
12103
+ setLoadingRoles(false);
12104
+ return;
12105
+ }
11858
12106
  try {
11859
12107
  setLoadingRoles(true);
11860
12108
  const collectionIds = collections.map((c) => c.id);
11861
- const roles = await handlers.getUserRoles({
12109
+ const roles = await getUserRolesFn({
11862
12110
  userAddress,
11863
12111
  adminAddress,
11864
12112
  deedDid: deedId,
@@ -11871,18 +12119,23 @@ var ClaimCollectionsList3 = ({ collections, deedId, adminAddress, userAddress, o
11871
12119
  });
11872
12120
  setUserRoles(rolesMap);
11873
12121
  } catch (error) {
11874
- console.error("Error fetching user roles:", error);
11875
- const rolesMap = {};
11876
- collections.forEach((collection) => {
11877
- rolesMap[collection.id] = null;
11878
- });
11879
- setUserRoles(rolesMap);
12122
+ if (isClientFulfillmentError3(error)) {
12123
+ failedRequestKeyRef.current = requestKey;
12124
+ } else {
12125
+ failedRequestKeyRef.current = null;
12126
+ }
12127
+ setEmptyRoles();
11880
12128
  } finally {
11881
- setLoadingRoles(false);
12129
+ if (isMounted) {
12130
+ setLoadingRoles(false);
12131
+ }
11882
12132
  }
11883
12133
  };
11884
12134
  fetchUserRoles();
11885
- }, [collections, userAddress, adminAddress, handlers, deedId]);
12135
+ return () => {
12136
+ isMounted = false;
12137
+ };
12138
+ }, [collections, userAddress, adminAddress, deedId, requestKey]);
11886
12139
  if (!collections || collections.length === 0) {
11887
12140
  return /* @__PURE__ */ React142.createElement(Text71, { size: "sm", c: "dimmed", ta: "center", py: "md" }, "No claim collections found");
11888
12141
  }
@@ -11895,47 +12148,69 @@ var ClaimCollectionsList3 = ({ collections, deedId, adminAddress, userAddress, o
11895
12148
  // src/mantine/blocks/evaluator/flow/FlowView.tsx
11896
12149
  var EvaluatorFlowView = ({ editor, block }) => {
11897
12150
  const { editable } = useBlocknoteContext();
11898
- const handlers = useBlocknoteHandlers();
11899
- const currentUser = handlers.getCurrentUser();
12151
+ const { getCurrentUser, getClaimCollections } = useBlocknoteHandlers();
12152
+ const getCurrentUserRef = useRef9(getCurrentUser);
12153
+ const getClaimCollectionsRef = useRef9(getClaimCollections);
12154
+ useEffect34(() => {
12155
+ getCurrentUserRef.current = getCurrentUser;
12156
+ getClaimCollectionsRef.current = getClaimCollections;
12157
+ }, [getCurrentUser, getClaimCollections]);
11900
12158
  const [collections, setCollections] = useState45([]);
11901
12159
  const [loading, setLoading] = useState45(false);
11902
12160
  const [error, setError] = useState45(null);
12161
+ const [userAddress, setUserAddress] = useState45("");
12162
+ const adminAddressUpdatedRef = useRef9(false);
11903
12163
  const selectedCollectionIds = useMemo35(() => {
11904
12164
  try {
11905
- return JSON.parse(block.props.selectedCollections || "[]");
12165
+ const parsed = JSON.parse(block.props.selectedCollections || "[]");
12166
+ return Array.isArray(parsed) ? parsed : [];
11906
12167
  } catch {
11907
12168
  return [];
11908
12169
  }
11909
12170
  }, [block.props.selectedCollections]);
12171
+ const selectedCollectionIdsStr = useMemo35(() => JSON.stringify([...selectedCollectionIds].sort()), [selectedCollectionIds]);
11910
12172
  const did = block.props.deedDid;
11911
12173
  const adminAddress = block.props.adminAddress || "";
12174
+ useEffect34(() => {
12175
+ try {
12176
+ const currentUser = getCurrentUserRef.current();
12177
+ setUserAddress(currentUser?.address || "");
12178
+ } catch (err) {
12179
+ setUserAddress("");
12180
+ }
12181
+ }, []);
11912
12182
  const fetchCollections = useCallback32(async () => {
11913
12183
  if (!did || selectedCollectionIds.length === 0) {
11914
12184
  setCollections([]);
11915
12185
  return;
11916
12186
  }
12187
+ if (loading) {
12188
+ return;
12189
+ }
11917
12190
  setLoading(true);
11918
12191
  setError(null);
11919
12192
  try {
11920
- const response = await handlers.getClaimCollections({ deedDid: did });
11921
- const { adminAddress: adminAddress2, collections: allCollections } = response || { adminAddress: "", collections: [] };
11922
- if (adminAddress2 && (!block.props.adminAddress || block.props.adminAddress === "")) {
12193
+ const response = await getClaimCollectionsRef.current({ deedDid: did });
12194
+ const { adminAddress: fetchedAdminAddress = "", collections: allCollections = [] } = response || {};
12195
+ const currentAdminAddress = block.props.adminAddress || "";
12196
+ if (fetchedAdminAddress && !currentAdminAddress && !adminAddressUpdatedRef.current) {
12197
+ adminAddressUpdatedRef.current = true;
11923
12198
  editor.updateBlock(block, {
11924
12199
  props: {
11925
12200
  ...block.props,
11926
- adminAddress: adminAddress2
12201
+ adminAddress: fetchedAdminAddress
11927
12202
  }
11928
12203
  });
11929
12204
  }
11930
- const selectedCollections = (allCollections || []).filter((c) => selectedCollectionIds.includes(c?.id));
12205
+ const selectedCollections = Array.isArray(allCollections) ? allCollections.filter((c) => c && selectedCollectionIds.includes(c.id)) : [];
11931
12206
  setCollections(selectedCollections);
11932
12207
  } catch (err) {
11933
- console.error("Error fetching collections:", err);
11934
12208
  setError(err instanceof Error ? err.message : "Failed to fetch collections");
12209
+ setCollections([]);
11935
12210
  } finally {
11936
12211
  setLoading(false);
11937
12212
  }
11938
- }, [did, selectedCollectionIds, handlers, editor, block]);
12213
+ }, [did, selectedCollectionIdsStr]);
11939
12214
  useEffect34(() => {
11940
12215
  fetchCollections();
11941
12216
  }, [fetchCollections]);
@@ -11945,7 +12220,7 @@ var EvaluatorFlowView = ({ editor, block }) => {
11945
12220
  if (selectedCollectionIds.length === 0) {
11946
12221
  return /* @__PURE__ */ React143.createElement(Center10, { py: "xl" }, /* @__PURE__ */ React143.createElement(Text72, { size: "sm", c: "dimmed" }, "No claim collections selected"));
11947
12222
  }
11948
- return /* @__PURE__ */ React143.createElement(Stack98, { w: "100%" }, /* @__PURE__ */ React143.createElement(Flex24, { px: 5, align: "center", justify: "space-between" }, /* @__PURE__ */ React143.createElement(Title18, { order: 4 }, "Evaluate Claims"), /* @__PURE__ */ React143.createElement(Flex24, { gap: "xs" }, /* @__PURE__ */ React143.createElement(ActionIcon22, { variant: "subtle", size: "sm", onClick: fetchCollections, loading }, /* @__PURE__ */ React143.createElement(IconRefresh5, { size: 18 })), editable && /* @__PURE__ */ React143.createElement(ActionIcon22, { variant: "subtle", size: "sm" }, /* @__PURE__ */ React143.createElement(IconSettings5, { size: 18 })))), loading ? /* @__PURE__ */ React143.createElement(Center10, { py: "xl" }, /* @__PURE__ */ React143.createElement(Loader19, { size: "md" })) : error ? /* @__PURE__ */ React143.createElement(Alert20, { color: "red", title: "Failed to load collections", icon: /* @__PURE__ */ React143.createElement(IconAlertCircle8, { size: 18 }) }, /* @__PURE__ */ React143.createElement(Text72, { size: "sm" }, error)) : /* @__PURE__ */ React143.createElement(ClaimCollectionsList3, { collections, deedId: did, adminAddress, userAddress: currentUser.address, onRefresh: fetchCollections }));
12223
+ return /* @__PURE__ */ React143.createElement(Stack98, { w: "100%" }, /* @__PURE__ */ React143.createElement(Flex24, { px: 5, align: "center", justify: "space-between" }, /* @__PURE__ */ React143.createElement(Title18, { order: 4 }, "Evaluate Claims"), /* @__PURE__ */ React143.createElement(Flex24, { gap: "xs" }, /* @__PURE__ */ React143.createElement(ActionIcon22, { variant: "subtle", size: "sm", onClick: fetchCollections, loading }, /* @__PURE__ */ React143.createElement(IconRefresh5, { size: 18 })), editable && /* @__PURE__ */ React143.createElement(ActionIcon22, { variant: "subtle", size: "sm" }, /* @__PURE__ */ React143.createElement(IconSettings5, { size: 18 })))), loading ? /* @__PURE__ */ React143.createElement(Center10, { py: "xl" }, /* @__PURE__ */ React143.createElement(Loader19, { size: "md" })) : error ? /* @__PURE__ */ React143.createElement(Alert20, { color: "red", title: "Failed to load collections", icon: /* @__PURE__ */ React143.createElement(IconAlertCircle8, { size: 18 }) }, /* @__PURE__ */ React143.createElement(Text72, { size: "sm" }, error)) : /* @__PURE__ */ React143.createElement(ClaimCollectionsList3, { collections, deedId: did, adminAddress, userAddress, onRefresh: fetchCollections }));
11949
12224
  };
11950
12225
 
11951
12226
  // src/mantine/blocks/evaluator/EvaluatorBlock.tsx
@@ -12475,14 +12750,14 @@ import { useCreateBlockNote as useCreateBlockNote2 } from "@blocknote/react";
12475
12750
  import { BlockNoteSchema as BlockNoteSchema2, defaultBlockSpecs as defaultBlockSpecs2, defaultInlineContentSpecs as defaultInlineContentSpecs2, defaultStyleSpecs as defaultStyleSpecs2 } from "@blocknote/core";
12476
12751
 
12477
12752
  // src/core/hooks/useMatrixProvider.ts
12478
- import { useEffect as useEffect36, useState as useState47, useRef as useRef4, useCallback as useCallback34, useMemo as useMemo38 } from "react";
12753
+ import { useEffect as useEffect36, useState as useState47, useRef as useRef10, useCallback as useCallback34, useMemo as useMemo38 } from "react";
12479
12754
  import { MatrixProvider } from "@ixo/matrix-crdt";
12480
12755
  function useMatrixProvider({ matrixClient, roomId, yDoc }) {
12481
12756
  const [matrixProvider, setProvider] = useState47(null);
12482
12757
  const [status, setStatus] = useState47("disconnected");
12483
- const isMountedRef = useRef4(true);
12484
- const providerRef = useRef4(null);
12485
- const retryTimeoutRef = useRef4(null);
12758
+ const isMountedRef = useRef10(true);
12759
+ const providerRef = useRef10(null);
12760
+ const retryTimeoutRef = useRef10(null);
12486
12761
  const providerOptions = useMemo38(
12487
12762
  () => ({
12488
12763
  translator: {
@@ -12534,7 +12809,6 @@ function useMatrixProvider({ matrixClient, roomId, yDoc }) {
12534
12809
  provider.dispose();
12535
12810
  }
12536
12811
  } catch (err) {
12537
- console.error("Matrix setup failed", err);
12538
12812
  if (isMountedRef.current) {
12539
12813
  setStatus("failed");
12540
12814
  retryTimeoutRef.current = setTimeout(() => {
@@ -12694,7 +12968,6 @@ function useCreateCollaborativeIxoEditor(options) {
12694
12968
  };
12695
12969
  ixoEditor.updateUserProps = (block, updates) => {
12696
12970
  if (!permissions.write) {
12697
- console.warn("Cannot update user props: write permission denied");
12698
12971
  return;
12699
12972
  }
12700
12973
  const prev = userFragment.get(block.id) || {};
@@ -12713,7 +12986,6 @@ function useCreateCollaborativeIxoEditor(options) {
12713
12986
  };
12714
12987
  ixoEditor.updateFlowMetadata = (updates) => {
12715
12988
  if (!permissions.write) {
12716
- console.warn("Cannot update flow metadata: write permission denied");
12717
12989
  return;
12718
12990
  }
12719
12991
  Object.entries(updates).forEach(([key, value]) => {
@@ -12729,48 +13001,30 @@ function useCreateCollaborativeIxoEditor(options) {
12729
13001
  return flowArray.toArray();
12730
13002
  };
12731
13003
  ixoEditor.setCoverImage = (imageData) => {
12732
- console.log("[setCoverImage] Called with:", imageData);
12733
- console.log("[setCoverImage] Permissions:", permissions);
12734
13004
  if (!permissions.write) {
12735
- console.warn("[setCoverImage] Cannot set cover image: write permission denied");
12736
13005
  return;
12737
13006
  }
12738
13007
  if (imageData === void 0 || imageData === null) {
12739
- console.log("[setCoverImage] Removing coverImage from yDoc root...");
12740
13008
  root.delete("coverImage");
12741
- console.log("[setCoverImage] Delete complete. Verifying:", root.get("coverImage"));
12742
13009
  } else {
12743
- console.log("[setCoverImage] Setting coverImage in yDoc root...");
12744
13010
  root.set("coverImage", imageData);
12745
- console.log("[setCoverImage] Set complete. Verifying:", root.get("coverImage"));
12746
13011
  }
12747
13012
  };
12748
13013
  ixoEditor.getCoverImage = () => {
12749
- const result = root.get("coverImage");
12750
- console.log("[getCoverImage] Retrieved:", result);
12751
- return result;
13014
+ return root.get("coverImage");
12752
13015
  };
12753
13016
  ixoEditor.setLogo = (imageData) => {
12754
- console.log("[setLogo] Called with:", imageData);
12755
- console.log("[setLogo] Permissions:", permissions);
12756
13017
  if (!permissions.write) {
12757
- console.warn("[setLogo] Cannot set logo: write permission denied");
12758
13018
  return;
12759
13019
  }
12760
13020
  if (imageData === void 0 || imageData === null) {
12761
- console.log("[setLogo] Removing logo from yDoc root...");
12762
13021
  root.delete("logo");
12763
- console.log("[setLogo] Delete complete. Verifying:", root.get("logo"));
12764
13022
  } else {
12765
- console.log("[setLogo] Setting logo in yDoc root...");
12766
13023
  root.set("logo", imageData);
12767
- console.log("[setLogo] Set complete. Verifying:", root.get("logo"));
12768
13024
  }
12769
13025
  };
12770
13026
  ixoEditor.getLogo = () => {
12771
- const result = root.get("logo");
12772
- console.log("[getLogo] Retrieved:", result);
12773
- return result;
13027
+ return root.get("logo");
12774
13028
  };
12775
13029
  }
12776
13030
  useEffect37(() => {
@@ -12810,36 +13064,31 @@ function useCreateCollaborativeIxoEditor(options) {
12810
13064
  }
12811
13065
 
12812
13066
  // src/mantine/components/CoverImage.tsx
12813
- import React147, { useState as useState48, useRef as useRef5, useEffect as useEffect38 } from "react";
13067
+ import React147, { useState as useState48, useRef as useRef11, useEffect as useEffect38 } from "react";
12814
13068
  import { Box as Box23, Button as Button32, Group as Group45 } from "@mantine/core";
12815
13069
  function CoverImage({ coverImageUrl, logoUrl }) {
12816
13070
  const { editor, handlers, editable } = useBlocknoteContext();
12817
13071
  const [isHovering, setIsHovering] = useState48(false);
12818
- const [isLogoHovering, setIsLogoHovering] = useState48(false);
12819
13072
  const [isRepositioning, setIsRepositioning] = useState48(false);
12820
13073
  const [coverPosition, setCoverPosition] = useState48(50);
12821
- const coverFileInputRef = useRef5(null);
12822
- const logoFileInputRef = useRef5(null);
12823
- const [coverImageData, setCoverImageData] = useState48(editor?.getCoverImage?.());
12824
- const [logoData, setLogoData] = useState48(editor?.getLogo?.());
13074
+ const coverFileInputRef = useRef11(null);
13075
+ const logoFileInputRef = useRef11(null);
13076
+ const [coverImageData, setCoverImageData] = useState48(() => editor?.getCoverImage?.());
13077
+ const [logoData, setLogoData] = useState48(() => editor?.getLogo?.());
12825
13078
  useEffect38(() => {
12826
13079
  if (!editor?._yRoot) {
12827
- console.log("CoverImage: No yRoot available");
12828
13080
  return;
12829
13081
  }
12830
13082
  const root = editor._yRoot;
12831
13083
  const observer = () => {
12832
13084
  const cover = root.get("coverImage");
12833
13085
  const logo = root.get("logo");
12834
- console.log("CoverImage: Observer triggered", { cover, logo });
12835
13086
  setCoverImageData(cover);
12836
13087
  setLogoData(logo);
12837
13088
  };
12838
- console.log("CoverImage: Setting up observer, initial values...");
12839
13089
  observer();
12840
13090
  root.observe(observer);
12841
13091
  return () => {
12842
- console.log("CoverImage: Cleaning up observer");
12843
13092
  root.unobserve(observer);
12844
13093
  };
12845
13094
  }, [editor]);
@@ -12847,33 +13096,19 @@ function CoverImage({ coverImageUrl, logoUrl }) {
12847
13096
  const logoSrc = logoData?.url || logoUrl;
12848
13097
  const hasCover = !!coverUrl;
12849
13098
  const hasLogo = !!logoSrc;
12850
- console.log("CoverImage: Render state", {
12851
- coverImageData,
12852
- logoData,
12853
- coverUrl,
12854
- logoSrc,
12855
- hasCover,
12856
- editable
12857
- });
12858
13099
  const handleFileSelect = async (event, type) => {
12859
13100
  const file = event.target.files?.[0];
12860
13101
  if (!file || !handlers?.publicFileUpload || !editor) {
12861
- console.log("CoverImage: Missing dependencies", { file: !!file, handlers: !!handlers?.publicFileUpload, editor: !!editor });
12862
13102
  return;
12863
13103
  }
12864
13104
  try {
12865
- console.log("CoverImage: Uploading file...", { type, fileName: file.name });
12866
13105
  const uploadedData = await handlers.publicFileUpload(file);
12867
- console.log("CoverImage: Upload successful", uploadedData);
12868
13106
  if (type === "cover") {
12869
13107
  editor.setCoverImage?.(uploadedData);
12870
- console.log("CoverImage: setCoverImage called, checking if set...", editor.getCoverImage?.());
12871
13108
  } else {
12872
13109
  editor.setLogo?.(uploadedData);
12873
- console.log("CoverImage: setLogo called, checking if set...", editor.getLogo?.());
12874
13110
  }
12875
13111
  } catch (error) {
12876
- console.error("CoverImage: Failed to upload file:", error);
12877
13112
  }
12878
13113
  };
12879
13114
  const handleAddCover = () => {
@@ -12887,7 +13122,6 @@ function CoverImage({ coverImageUrl, logoUrl }) {
12887
13122
  };
12888
13123
  const handleRemoveCover = () => {
12889
13124
  if (!editor) return;
12890
- console.log("CoverImage: Removing cover image...");
12891
13125
  editor.setCoverImage?.(void 0);
12892
13126
  };
12893
13127
  const handleAddLogo = () => {
@@ -12898,7 +13132,6 @@ function CoverImage({ coverImageUrl, logoUrl }) {
12898
13132
  };
12899
13133
  const handleRemoveLogo = () => {
12900
13134
  if (!editor) return;
12901
- console.log("CoverImage: Removing logo...");
12902
13135
  editor.setLogo?.(void 0);
12903
13136
  };
12904
13137
  const handleMouseMove = (e) => {
@@ -12918,51 +13151,74 @@ function CoverImage({ coverImageUrl, logoUrl }) {
12918
13151
  style: {
12919
13152
  position: "relative",
12920
13153
  width: "100%",
12921
- minHeight: hasLogo ? "100px" : "60px",
12922
- backgroundColor: "#1f1f1f",
12923
- marginBottom: hasLogo ? "70px" : "0"
13154
+ minHeight: hasLogo ? "140px" : "48px",
13155
+ backgroundColor: "transparent",
13156
+ marginBottom: "0"
12924
13157
  },
12925
13158
  onMouseEnter: () => editable && setIsHovering(true),
12926
13159
  onMouseLeave: () => editable && setIsHovering(false)
12927
13160
  },
12928
13161
  /* @__PURE__ */ React147.createElement("input", { ref: coverFileInputRef, type: "file", accept: "image/*", style: { display: "none" }, onChange: (e) => handleFileSelect(e, "cover") }),
12929
13162
  /* @__PURE__ */ React147.createElement("input", { ref: logoFileInputRef, type: "file", accept: "image/*", style: { display: "none" }, onChange: (e) => handleFileSelect(e, "logo") }),
12930
- editable && isHovering && /* @__PURE__ */ React147.createElement(
12931
- Button32,
13163
+ editable && isHovering && !logoSrc && /* @__PURE__ */ React147.createElement(
13164
+ Group45,
12932
13165
  {
12933
- variant: "filled",
12934
- size: "xs",
12935
- onClick: handleAddCover,
13166
+ gap: "xs",
12936
13167
  style: {
12937
13168
  position: "absolute",
12938
- top: "0",
12939
- right: "60px",
12940
- zIndex: 10,
12941
- backgroundColor: "rgba(255, 255, 255, 0.9)",
12942
- color: "#37352f",
12943
- fontSize: "12px",
12944
- fontWeight: 500,
12945
- padding: "4px 8px",
12946
- height: "auto"
13169
+ top: "12px",
13170
+ left: "96px",
13171
+ zIndex: 10
12947
13172
  }
12948
13173
  },
12949
- "Add cover"
13174
+ /* @__PURE__ */ React147.createElement(
13175
+ Button32,
13176
+ {
13177
+ variant: "filled",
13178
+ size: "xs",
13179
+ onClick: handleAddLogo,
13180
+ style: {
13181
+ backgroundColor: "rgba(255, 255, 255, 0.9)",
13182
+ color: "#37352f",
13183
+ fontSize: "12px",
13184
+ fontWeight: 500,
13185
+ padding: "4px 8px",
13186
+ height: "auto"
13187
+ }
13188
+ },
13189
+ "Add icon"
13190
+ ),
13191
+ /* @__PURE__ */ React147.createElement(
13192
+ Button32,
13193
+ {
13194
+ variant: "filled",
13195
+ size: "xs",
13196
+ onClick: handleAddCover,
13197
+ style: {
13198
+ backgroundColor: "rgba(255, 255, 255, 0.9)",
13199
+ color: "#37352f",
13200
+ fontSize: "12px",
13201
+ fontWeight: 500,
13202
+ padding: "4px 8px",
13203
+ height: "auto"
13204
+ }
13205
+ },
13206
+ "Add cover"
13207
+ )
12950
13208
  ),
12951
- /* @__PURE__ */ React147.createElement(
13209
+ logoSrc && /* @__PURE__ */ React147.createElement(
12952
13210
  Box23,
12953
13211
  {
12954
13212
  style: {
12955
- position: "absolute",
12956
- bottom: "-60px",
13213
+ position: "relative",
12957
13214
  insetInlineStart: "96px",
12958
13215
  width: "120px",
12959
13216
  height: "120px",
13217
+ marginTop: "16px",
12960
13218
  zIndex: 11
12961
- },
12962
- onMouseEnter: () => editable && setIsLogoHovering(true),
12963
- onMouseLeave: () => editable && setIsLogoHovering(false)
13219
+ }
12964
13220
  },
12965
- logoSrc && /* @__PURE__ */ React147.createElement(
13221
+ /* @__PURE__ */ React147.createElement(
12966
13222
  "img",
12967
13223
  {
12968
13224
  src: logoSrc,
@@ -12977,91 +13233,51 @@ function CoverImage({ coverImageUrl, logoUrl }) {
12977
13233
  }
12978
13234
  }
12979
13235
  ),
12980
- editable && isHovering && /* @__PURE__ */ React147.createElement(React147.Fragment, null, logoSrc ? (
12981
- // Logo exists: Show Change/Remove buttons when hovering anywhere
13236
+ editable && isHovering && /* @__PURE__ */ React147.createElement(
13237
+ Group45,
13238
+ {
13239
+ gap: "xs",
13240
+ style: {
13241
+ position: "absolute",
13242
+ top: "0",
13243
+ left: "130px",
13244
+ zIndex: 12
13245
+ }
13246
+ },
12982
13247
  /* @__PURE__ */ React147.createElement(
12983
- Group45,
13248
+ Button32,
12984
13249
  {
12985
- gap: "xs",
13250
+ variant: "filled",
13251
+ size: "xs",
13252
+ onClick: handleChangeLogo,
12986
13253
  style: {
12987
- position: "absolute",
12988
- top: "0",
12989
- left: "130px",
12990
- zIndex: 12
13254
+ backgroundColor: "rgba(255, 255, 255, 0.9)",
13255
+ color: "#37352f",
13256
+ fontSize: "12px",
13257
+ fontWeight: 500,
13258
+ padding: "4px 8px",
13259
+ height: "auto"
12991
13260
  }
12992
13261
  },
12993
- /* @__PURE__ */ React147.createElement(
12994
- Button32,
12995
- {
12996
- variant: "filled",
12997
- size: "xs",
12998
- onClick: handleChangeLogo,
12999
- style: {
13000
- backgroundColor: "rgba(255, 255, 255, 0.9)",
13001
- color: "#37352f",
13002
- fontSize: "12px",
13003
- fontWeight: 500,
13004
- padding: "4px 8px",
13005
- height: "auto"
13006
- }
13007
- },
13008
- "Change"
13009
- ),
13010
- /* @__PURE__ */ React147.createElement(
13011
- Button32,
13012
- {
13013
- variant: "filled",
13014
- size: "xs",
13015
- onClick: handleRemoveLogo,
13016
- style: {
13017
- backgroundColor: "rgba(255, 255, 255, 0.9)",
13018
- color: "#37352f",
13019
- fontSize: "12px",
13020
- fontWeight: 500,
13021
- padding: "4px 8px",
13022
- height: "auto"
13023
- }
13024
- },
13025
- "Remove"
13026
- )
13027
- )
13028
- ) : (
13029
- // No logo: Show "Add icon" button
13262
+ "Change"
13263
+ ),
13030
13264
  /* @__PURE__ */ React147.createElement(
13031
13265
  Button32,
13032
13266
  {
13033
13267
  variant: "filled",
13034
13268
  size: "xs",
13035
- onClick: handleAddLogo,
13269
+ onClick: handleRemoveLogo,
13036
13270
  style: {
13037
- position: "absolute",
13038
- top: "50%",
13039
- left: "50%",
13040
- transform: "translate(-50%, -50%)",
13041
13271
  backgroundColor: "rgba(255, 255, 255, 0.9)",
13042
13272
  color: "#37352f",
13043
13273
  fontSize: "12px",
13044
13274
  fontWeight: 500,
13045
13275
  padding: "4px 8px",
13046
- height: "auto",
13047
- zIndex: 12
13276
+ height: "auto"
13048
13277
  }
13049
13278
  },
13050
- "Add icon"
13279
+ "Remove"
13051
13280
  )
13052
- )),
13053
- !logoSrc && /* @__PURE__ */ React147.createElement(
13054
- Box23,
13055
- {
13056
- style: {
13057
- width: "100%",
13058
- height: "100%",
13059
- borderRadius: "100%",
13060
- border: editable && isLogoHovering ? "2px dashed rgba(255, 255, 255, 0.3)" : "none",
13061
- backgroundColor: editable && isLogoHovering ? "rgba(255, 255, 255, 0.05)" : "transparent",
13062
- transition: "all 0.2s ease"
13063
- }
13064
- }
13065
13281
  )
13066
13282
  )
13067
13283
  );
@@ -13178,9 +13394,7 @@ function CoverImage({ coverImageUrl, logoUrl }) {
13178
13394
  width: "120px",
13179
13395
  height: "120px",
13180
13396
  zIndex: 11
13181
- },
13182
- onMouseEnter: () => editable && setIsLogoHovering(true),
13183
- onMouseLeave: () => editable && setIsLogoHovering(false)
13397
+ }
13184
13398
  },
13185
13399
  logoSrc && /* @__PURE__ */ React147.createElement(
13186
13400
  "img",
@@ -13503,4 +13717,4 @@ export {
13503
13717
  ixoGraphQLClient,
13504
13718
  getEntity
13505
13719
  };
13506
- //# sourceMappingURL=chunk-S45RB34V.mjs.map
13720
+ //# sourceMappingURL=chunk-YDHPP6BI.mjs.map