@superdoc-dev/cli 0.2.0-next.142 → 0.2.0-next.143

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.
Files changed (2) hide show
  1. package/dist/index.js +547 -487
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -660,18 +660,17 @@ function isTextAddress(value) {
660
660
  return false;
661
661
  return range.start <= range.end;
662
662
  }
663
- function isSDAddress(value) {
663
+ function isBlockNodeAddress(value) {
664
664
  if (!isRecord(value))
665
665
  return false;
666
- if (typeof value.kind !== "string" || !SD_ADDRESS_KINDS.has(value.kind))
666
+ if (value.kind !== "block")
667
+ return false;
668
+ if (typeof value.nodeType !== "string" || !BLOCK_NODE_TYPES_SET.has(value.nodeType))
667
669
  return false;
668
- if (typeof value.stability !== "string" || !SD_ADDRESS_STABILITIES.has(value.stability))
670
+ if (typeof value.nodeId !== "string")
669
671
  return false;
670
672
  return true;
671
673
  }
672
- function isValidTarget(value) {
673
- return isTextAddress(value) || isSDAddress(value);
674
- }
675
674
  function assertNoUnknownFields(input, allowlist, operationName) {
676
675
  for (const key of Object.keys(input)) {
677
676
  if (!allowlist.has(key)) {
@@ -697,12 +696,12 @@ function validateNestingPolicyValue(value) {
697
696
  throw new DocumentApiValidationError("INVALID_INPUT", `nestingPolicy.tables must be one of: forbid, allow. Got "${String(value.tables)}".`, { field: "nestingPolicy.tables", value: value.tables });
698
697
  }
699
698
  }
700
- var SD_ADDRESS_KINDS, SD_ADDRESS_STABILITIES, NESTING_POLICY_ALLOWED_KEYS;
699
+ var BLOCK_NODE_TYPES_SET, NESTING_POLICY_ALLOWED_KEYS;
701
700
  var init_validation_primitives = __esm(() => {
701
+ init_base();
702
702
  init_placement();
703
703
  init_errors2();
704
- SD_ADDRESS_KINDS = new Set(["content", "inline", "annotation", "section"]);
705
- SD_ADDRESS_STABILITIES = new Set(["stable", "ephemeral"]);
704
+ BLOCK_NODE_TYPES_SET = new Set(BLOCK_NODE_TYPES);
706
705
  NESTING_POLICY_ALLOWED_KEYS = new Set(["tables"]);
707
706
  });
708
707
 
@@ -1419,8 +1418,8 @@ var init_operation_definitions = __esm(() => {
1419
1418
  },
1420
1419
  insert: {
1421
1420
  memberPath: "insert",
1422
- description: "Insert inline content at a text position within an existing block, or at the end of the document when target is omitted. " + "This is NOT for creating sibling blocks use create.paragraph, create.heading, or lists.insert for that. " + "Accepts two input shapes: legacy string-based (value + type) or structural SDFragment (content). " + "Supports text (default), markdown, and html content types via the `type` field in legacy mode. " + "Structural mode accepts an SDFragment with typed nodes (paragraphs, tables, images, etc.).",
1423
- expectedResult: "Returns a TextMutationReceipt with applied status; receipt reports NO_OP if the insertion point is invalid or content is empty.",
1421
+ description: "Insert content into the document. Two input shapes: " + "legacy string-based (value + type) inserts inline content at a text position within an existing block; " + "structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. " + "When target is omitted, content appends at the end of the document. " + "Legacy mode supports text (default), markdown, and html content types via the `type` field. " + "Structural mode uses `placement` (before/after/insideStart/insideEnd) to position relative to the target block.",
1422
+ expectedResult: "Returns an SDMutationReceipt with applied status; resolution reports a TextAddress for legacy text insertion or a BlockNodeAddress for structural insertion. Receipt reports NO_OP if the insertion point is invalid or content is empty.",
1424
1423
  requiresDocumentContext: true,
1425
1424
  metadata: mutationOperation({
1426
1425
  idempotency: "non-idempotent",
@@ -1458,7 +1457,7 @@ var init_operation_definitions = __esm(() => {
1458
1457
  },
1459
1458
  replace: {
1460
1459
  memberPath: "replace",
1461
- description: "Replace content at a contiguous document selection. " + "Text path accepts a SelectionTarget or ref plus replacement text. " + "Structural path accepts an SDAddress, SelectionTarget, or ref plus SDFragment content.",
1460
+ description: "Replace content at a contiguous document selection. " + "Text path accepts a SelectionTarget or ref plus replacement text. " + "Structural path accepts a BlockNodeAddress (replaces whole block), SelectionTarget (expands to full covered block boundaries), or ref plus SDFragment content.",
1462
1461
  expectedResult: "Returns an SDMutationReceipt with applied status; receipt reports NO_OP if the target range already contains identical content.",
1463
1462
  requiresDocumentContext: true,
1464
1463
  metadata: mutationOperation({
@@ -7552,7 +7551,7 @@ function buildInternalContractSchemas() {
7552
7551
  operations
7553
7552
  };
7554
7553
  }
7555
- var nodeTypeValues, blockNodeTypeValues, deletableBlockNodeTypeValues, inlineNodeTypeValues, knownTargetKindValues, SHARED_DEFS, rangeSchema, positionSchema, inlineAnchorSchema, targetKindSchema, textAddressSchema, textTargetSchema, blockNodeAddressSchema, deletableBlockNodeAddressSchema, paragraphAddressSchema, headingAddressSchema, listItemAddressSchema, paragraphTargetSchema, sectionAddressSchema, inlineNodeAddressSchema, nodeAddressSchema, commentAddressSchema, trackedChangeAddressSchema, entityAddressSchema, selectionTargetSchema, targetLocatorSchema, deleteBehaviorSchema, resolvedHandleSchema, pageInfoSchema, receiptSuccessSchema, textMutationRangeSchema, textMutationResolutionSchema, textMutationSuccessSchema, matchRunSchema, matchBlockSchema, trackChangeRefSchema, createParagraphSuccessSchema, createHeadingSuccessSchema, headingLevelSchema, listsInsertSuccessSchema, listsMutateItemSuccessSchema, listsExitSuccessSchema, nodeSummarySchema, nodeInfoSchema, matchContextSchema, unknownNodeDiagnosticSchema, textSelectorSchema, nodeSelectorSchema, selectorShorthandSchema, sdTextSelectorSchema, sdNodeSelectorSchema, sdSelectorSchema, sdAddressSchema, sdReadOptionsSchema, sdFindInputSchema, sdNodeResultSchema, sdFindResultSchema, sdMutationResolutionSchema, sdMutationSuccessSchema, documentInfoCountsSchema, documentInfoOutlineItemSchema, documentInfoCapabilitiesSchema, documentInfoSchema, listKindSchema, listInsertPositionSchema, listItemInfoSchema, listItemDomainItemSchema, listsListResultSchema, sectionBreakTypeSchema, sectionOrientationSchema, sectionVerticalAlignSchema, sectionDirectionSchema, sectionHeaderFooterKindSchema, sectionHeaderFooterVariantSchema, sectionLineNumberRestartSchema, sectionPageNumberFormatSchema, sectionRangeDomainSchema, sectionPageMarginsSchema, sectionHeaderFooterMarginsSchema, sectionPageSetupSchema, sectionColumnsSchema, sectionLineNumberingSchema, sectionPageNumberingSchema, sectionHeaderFooterRefsSchema, sectionBorderSpecSchema, sectionPageBordersSchema, sectionInfoSchema, sectionResolvedHandleSchema, sectionDomainItemSchema, sectionsListResultSchema, sectionMutationSuccessSchema, documentMutationSuccessSchema, paragraphMutationTargetSchema, paragraphMutationSuccessSchema, createSectionBreakSuccessSchema, commentInfoSchema, commentDomainItemSchema, commentsListResultSchema, trackChangeInfoSchema, trackChangeDomainItemSchema, trackChangesListResultSchema, capabilityReasonCodeSchema, capabilityReasonsSchema, capabilityFlagSchema, operationRuntimeCapabilitySchema, operationCapabilitiesSchema, inlinePropertyCapabilitySchema, inlinePropertyCapabilitiesByKeySchema, formatCapabilitiesSchema, planEngineCapabilitiesSchema, capabilitiesOutputSchema, strictEmptyObjectSchema, insertInputSchema, tableLocatorSchema, _tableScopedRowLocatorSchema, _tableScopedColumnLocatorSchema, mergeRangeLocatorSchema, mixedRowLocatorOneOf, tableCreateLocationSchema, tableMutationSuccessSchema, createTableSuccessSchema, tableMutationFailureCodes, tableMutationFailureSchema, tableMutationResultSchema, createTableResultSchema, historyActionSuccessSchema, historyActionFailureSchema, formatInlineAliasOperationSchemas, tocMutationFailureCodes, tocMutationFailureSchema, tocMutationSuccessSchema, tocEntryMutationFailureCodes, tocEntryMutationFailureSchema, tocEntryMutationSuccessSchema, hyperlinkTargetSchema, hyperlinkReadPropertiesSchema, hyperlinkDestinationSchema, hyperlinkSpecSchema, hyperlinkPatchSchema, hyperlinkDomainSchema, hyperlinkMutationSuccessSchema, hyperlinkMutationFailureCodes, hyperlinkMutationFailureSchema, hyperlinkInfoSchema, contentControlTargetSchema, contentControlMutationSuccessSchema, contentControlMutationFailureSchema, ccListResultSchema, ccInfoSchema, refListQuerySchema, discoveryOutputSchema, receiptFailureSchema, refFailureSchema, bookmarkAddressSchema, bookmarkMutation, footnoteAddressSchema, footnoteConfigScopeSchema, footnoteNumberingSchema, footnoteMutation, footnoteConfig, crossRefAddressSchema, crossRefTargetSchema, crossRefDisplaySchema, crossRefMutation, indexAddressSchema, indexEntryAddressSchema, indexConfigSchema, indexEntryDataSchema, indexEntryPatchSchema, indexMutation, indexEntryMutation, captionAddressSchema, captionMutation, captionConfig, fieldAddressSchema, fieldMutation, citationAddressSchema, citationSourceAddressSchema, bibliographyAddressSchema, citationMutation, citationSourceMutation, bibliographyMutation, citationPersonSchema, citationSourceFieldsSchema, tocCreateLocationSchema, authoritiesAddressSchema, authorityEntryAddressSchema, authoritiesConfigSchema, authorityEntryDataSchema, authorityEntryPatchSchema, authoritiesMutation, authorityEntryMutation, operationSchemas;
7554
+ var nodeTypeValues, blockNodeTypeValues, deletableBlockNodeTypeValues, inlineNodeTypeValues, knownTargetKindValues, SHARED_DEFS, rangeSchema, positionSchema, inlineAnchorSchema, targetKindSchema, textAddressSchema, textTargetSchema, blockNodeAddressSchema, deletableBlockNodeAddressSchema, paragraphAddressSchema, headingAddressSchema, listItemAddressSchema, paragraphTargetSchema, sectionAddressSchema, inlineNodeAddressSchema, nodeAddressSchema, commentAddressSchema, trackedChangeAddressSchema, entityAddressSchema, selectionTargetSchema, targetLocatorSchema, deleteBehaviorSchema, resolvedHandleSchema, pageInfoSchema, receiptSuccessSchema, textMutationRangeSchema, textMutationResolutionSchema, textMutationSuccessSchema, matchRunSchema, matchBlockSchema, trackChangeRefSchema, createParagraphSuccessSchema, createHeadingSuccessSchema, headingLevelSchema, listsInsertSuccessSchema, listsMutateItemSuccessSchema, listsExitSuccessSchema, nodeSummarySchema, nodeInfoSchema, matchContextSchema, unknownNodeDiagnosticSchema, textSelectorSchema, nodeSelectorSchema, selectorShorthandSchema, sdTextSelectorSchema, sdNodeSelectorSchema, sdSelectorSchema, sdReadOptionsSchema, sdFindInputSchema, sdNodeResultSchema, sdFindResultSchema, sdMutationResolutionSchema, sdMutationSuccessSchema, documentInfoCountsSchema, documentInfoOutlineItemSchema, documentInfoCapabilitiesSchema, documentInfoSchema, listKindSchema, listInsertPositionSchema, listItemInfoSchema, listItemDomainItemSchema, listsListResultSchema, sectionBreakTypeSchema, sectionOrientationSchema, sectionVerticalAlignSchema, sectionDirectionSchema, sectionHeaderFooterKindSchema, sectionHeaderFooterVariantSchema, sectionLineNumberRestartSchema, sectionPageNumberFormatSchema, sectionRangeDomainSchema, sectionPageMarginsSchema, sectionHeaderFooterMarginsSchema, sectionPageSetupSchema, sectionColumnsSchema, sectionLineNumberingSchema, sectionPageNumberingSchema, sectionHeaderFooterRefsSchema, sectionBorderSpecSchema, sectionPageBordersSchema, sectionInfoSchema, sectionResolvedHandleSchema, sectionDomainItemSchema, sectionsListResultSchema, sectionMutationSuccessSchema, documentMutationSuccessSchema, paragraphMutationTargetSchema, paragraphMutationSuccessSchema, createSectionBreakSuccessSchema, commentInfoSchema, commentDomainItemSchema, commentsListResultSchema, trackChangeInfoSchema, trackChangeDomainItemSchema, trackChangesListResultSchema, capabilityReasonCodeSchema, capabilityReasonsSchema, capabilityFlagSchema, operationRuntimeCapabilitySchema, operationCapabilitiesSchema, inlinePropertyCapabilitySchema, inlinePropertyCapabilitiesByKeySchema, formatCapabilitiesSchema, planEngineCapabilitiesSchema, capabilitiesOutputSchema, strictEmptyObjectSchema, sdFragmentSchema, placementSchema, nestingPolicySchema, insertInputSchema, tableLocatorSchema, _tableScopedRowLocatorSchema, _tableScopedColumnLocatorSchema, mergeRangeLocatorSchema, mixedRowLocatorOneOf, tableCreateLocationSchema, tableMutationSuccessSchema, createTableSuccessSchema, tableMutationFailureCodes, tableMutationFailureSchema, tableMutationResultSchema, createTableResultSchema, historyActionSuccessSchema, historyActionFailureSchema, formatInlineAliasOperationSchemas, tocMutationFailureCodes, tocMutationFailureSchema, tocMutationSuccessSchema, tocEntryMutationFailureCodes, tocEntryMutationFailureSchema, tocEntryMutationSuccessSchema, hyperlinkTargetSchema, hyperlinkReadPropertiesSchema, hyperlinkDestinationSchema, hyperlinkSpecSchema, hyperlinkPatchSchema, hyperlinkDomainSchema, hyperlinkMutationSuccessSchema, hyperlinkMutationFailureCodes, hyperlinkMutationFailureSchema, hyperlinkInfoSchema, contentControlTargetSchema, contentControlMutationSuccessSchema, contentControlMutationFailureSchema, ccListResultSchema, ccInfoSchema, refListQuerySchema, discoveryOutputSchema, receiptFailureSchema, refFailureSchema, bookmarkAddressSchema, bookmarkMutation, footnoteAddressSchema, footnoteConfigScopeSchema, footnoteNumberingSchema, footnoteMutation, footnoteConfig, crossRefAddressSchema, crossRefTargetSchema, crossRefDisplaySchema, crossRefMutation, indexAddressSchema, indexEntryAddressSchema, indexConfigSchema, indexEntryDataSchema, indexEntryPatchSchema, indexMutation, indexEntryMutation, captionAddressSchema, captionMutation, captionConfig, fieldAddressSchema, fieldMutation, citationAddressSchema, citationSourceAddressSchema, bibliographyAddressSchema, citationMutation, citationSourceMutation, bibliographyMutation, citationPersonSchema, citationSourceFieldsSchema, tocCreateLocationSchema, authoritiesAddressSchema, authorityEntryAddressSchema, authoritiesConfigSchema, authorityEntryDataSchema, authorityEntryPatchSchema, authoritiesMutation, authorityEntryMutation, operationSchemas;
7556
7555
  var init_schemas = __esm(() => {
7557
7556
  init_command_catalog();
7558
7557
  init_types2();
@@ -7890,23 +7889,12 @@ var init_schemas = __esm(() => {
7890
7889
  }, ["type", "pattern"]);
7891
7890
  sdNodeSelectorSchema = objectSchema({
7892
7891
  type: { const: "node" },
7893
- kind: { enum: ["content", "inline"] },
7894
- nodeKind: { type: "string" }
7892
+ kind: { enum: ["block", "inline"] },
7893
+ nodeType: { type: "string" }
7895
7894
  }, ["type"]);
7896
7895
  sdSelectorSchema = {
7897
7896
  oneOf: [sdTextSelectorSchema, sdNodeSelectorSchema]
7898
7897
  };
7899
- sdAddressSchema = objectSchema({
7900
- kind: { enum: ["content", "inline", "annotation", "section"] },
7901
- stability: { enum: ["stable", "ephemeral"] },
7902
- nodeId: { type: "string" },
7903
- anchor: objectSchema({
7904
- start: objectSchema({ blockId: { type: "string" }, offset: { type: "integer" } }, ["blockId", "offset"]),
7905
- end: objectSchema({ blockId: { type: "string" }, offset: { type: "integer" } }, ["blockId", "offset"])
7906
- }),
7907
- evaluatedRevision: { type: "string" },
7908
- path: arraySchema({ oneOf: [{ type: "string" }, { type: "integer" }] })
7909
- }, ["kind", "stability"]);
7910
7898
  sdReadOptionsSchema = objectSchema({
7911
7899
  includeResolved: { type: "boolean" },
7912
7900
  includeProvenance: { type: "boolean" },
@@ -7914,14 +7902,14 @@ var init_schemas = __esm(() => {
7914
7902
  });
7915
7903
  sdFindInputSchema = objectSchema({
7916
7904
  select: sdSelectorSchema,
7917
- within: sdAddressSchema,
7905
+ within: blockNodeAddressSchema,
7918
7906
  limit: { type: "integer" },
7919
7907
  offset: { type: "integer" },
7920
7908
  options: sdReadOptionsSchema
7921
7909
  }, ["select"]);
7922
7910
  sdNodeResultSchema = objectSchema({
7923
7911
  node: { type: "object" },
7924
- address: sdAddressSchema,
7912
+ address: nodeAddressSchema,
7925
7913
  context: { type: "object" }
7926
7914
  }, ["node", "address"]);
7927
7915
  sdFindResultSchema = objectSchema({
@@ -7931,10 +7919,10 @@ var init_schemas = __esm(() => {
7931
7919
  items: arraySchema(sdNodeResultSchema)
7932
7920
  }, ["total", "limit", "offset", "items"]);
7933
7921
  sdMutationResolutionSchema = objectSchema({
7934
- requestedTarget: sdAddressSchema,
7935
- target: sdAddressSchema,
7922
+ target: { oneOf: [textAddressSchema, blockNodeAddressSchema] },
7923
+ range: textMutationRangeSchema,
7936
7924
  selectionTarget: selectionTargetSchema
7937
- }, ["target"]);
7925
+ }, ["target", "range"]);
7938
7926
  sdMutationSuccessSchema = objectSchema({
7939
7927
  success: { const: true },
7940
7928
  resolution: sdMutationResolutionSchema,
@@ -8241,11 +8229,28 @@ var init_schemas = __esm(() => {
8241
8229
  planEngine: planEngineCapabilitiesSchema
8242
8230
  }, ["global", "format", "operations", "planEngine"]);
8243
8231
  strictEmptyObjectSchema = objectSchema({});
8244
- insertInputSchema = objectSchema({
8245
- target: textAddressSchema,
8246
- value: { type: "string" },
8247
- type: { type: "string", enum: ["text", "markdown", "html"] }
8248
- }, ["value"]);
8232
+ sdFragmentSchema = {
8233
+ oneOf: [{ type: "object" }, { type: "array", items: { type: "object" } }]
8234
+ };
8235
+ placementSchema = { enum: ["before", "after", "insideStart", "insideEnd"] };
8236
+ nestingPolicySchema = objectSchema({
8237
+ tables: { enum: ["forbid", "allow"] }
8238
+ });
8239
+ insertInputSchema = {
8240
+ oneOf: [
8241
+ objectSchema({
8242
+ target: textAddressSchema,
8243
+ value: { type: "string" },
8244
+ type: { type: "string", enum: ["text", "markdown", "html"] }
8245
+ }, ["value"]),
8246
+ objectSchema({
8247
+ target: blockNodeAddressSchema,
8248
+ content: sdFragmentSchema,
8249
+ placement: placementSchema,
8250
+ nestingPolicy: nestingPolicySchema
8251
+ }, ["content"])
8252
+ ]
8253
+ };
8249
8254
  tableLocatorSchema = {
8250
8255
  ...objectSchema({
8251
8256
  target: blockNodeAddressSchema,
@@ -8710,14 +8715,14 @@ var init_schemas = __esm(() => {
8710
8715
  {
8711
8716
  oneOf: [
8712
8717
  objectSchema({
8713
- target: { oneOf: [sdAddressSchema, textAddressSchema, selectionTargetSchema] },
8714
- content: { type: "object" },
8715
- nestingPolicy: { type: "object" }
8718
+ target: { oneOf: [blockNodeAddressSchema, selectionTargetSchema] },
8719
+ content: sdFragmentSchema,
8720
+ nestingPolicy: nestingPolicySchema
8716
8721
  }, ["target", "content"]),
8717
8722
  objectSchema({
8718
8723
  ref: { type: "string" },
8719
- content: { type: "object" },
8720
- nestingPolicy: { type: "object" }
8724
+ content: sdFragmentSchema,
8725
+ nestingPolicy: nestingPolicySchema
8721
8726
  }, ["ref", "content"])
8722
8727
  ]
8723
8728
  }
@@ -9786,7 +9791,7 @@ var init_schemas = __esm(() => {
9786
9791
  "query.match": {
9787
9792
  input: objectSchema({
9788
9793
  select: { oneOf: [textSelectorSchema, nodeSelectorSchema] },
9789
- within: nodeAddressSchema,
9794
+ within: blockNodeAddressSchema,
9790
9795
  require: { enum: ["any", "first", "exactlyOne", "all"] },
9791
9796
  mode: { enum: ["strict", "candidates"] },
9792
9797
  includeNodes: { type: "boolean" },
@@ -9796,7 +9801,7 @@ var init_schemas = __esm(() => {
9796
9801
  output: (() => {
9797
9802
  const textMatchItemSchema = discoveryItemSchema({
9798
9803
  matchKind: { const: "text" },
9799
- address: nodeAddressSchema,
9804
+ address: blockNodeAddressSchema,
9800
9805
  target: selectionTargetSchema,
9801
9806
  snippet: { type: "string" },
9802
9807
  highlightRange: rangeSchema,
@@ -9815,13 +9820,13 @@ var init_schemas = __esm(() => {
9815
9820
  const selectWhereSchema = objectSchema({
9816
9821
  by: { const: "select", type: "string" },
9817
9822
  select: { oneOf: [textSelectorSchema, nodeSelectorSchema] },
9818
- within: nodeAddressSchema,
9823
+ within: blockNodeAddressSchema,
9819
9824
  require: { enum: ["first", "exactlyOne", "all"] }
9820
9825
  }, ["by", "select", "require"]);
9821
9826
  const refWhereSchema = objectSchema({
9822
9827
  by: { const: "ref", type: "string" },
9823
9828
  ref: { type: "string" },
9824
- within: nodeAddressSchema
9829
+ within: blockNodeAddressSchema
9825
9830
  }, ["by", "ref"]);
9826
9831
  const targetWhereSchema = objectSchema({
9827
9832
  by: { const: "target", type: "string" },
@@ -9831,13 +9836,13 @@ var init_schemas = __esm(() => {
9831
9836
  const insertWhereSchema = objectSchema({
9832
9837
  by: { const: "select", type: "string" },
9833
9838
  select: { oneOf: [textSelectorSchema, nodeSelectorSchema] },
9834
- within: nodeAddressSchema,
9839
+ within: blockNodeAddressSchema,
9835
9840
  require: { enum: ["first", "exactlyOne"] }
9836
9841
  }, ["by", "select", "require"]);
9837
9842
  const assertWhereSchema = objectSchema({
9838
9843
  by: { const: "select", type: "string" },
9839
9844
  select: { oneOf: [textSelectorSchema, nodeSelectorSchema] },
9840
- within: nodeAddressSchema
9845
+ within: blockNodeAddressSchema
9841
9846
  }, ["by", "select"]);
9842
9847
  const replacementBlockSchema = objectSchema({ text: { type: "string" } }, ["text"]);
9843
9848
  const replacementPayloadSchema = {
@@ -10983,7 +10988,7 @@ var init_schemas = __esm(() => {
10983
10988
  "images.removeCaption": imagesMutationSchemaSet(objectSchema({ imageId: { type: "string" } }, ["imageId"])),
10984
10989
  "hyperlinks.list": {
10985
10990
  input: objectSchema({
10986
- within: nodeAddressSchema,
10991
+ within: blockNodeAddressSchema,
10987
10992
  hrefPattern: { type: "string" },
10988
10993
  anchor: { type: "string" },
10989
10994
  textPattern: { type: "string" },
@@ -12161,6 +12166,9 @@ var init_comments = __esm(() => {
12161
12166
  function executeFind(adapter, input) {
12162
12167
  return adapter.find(input);
12163
12168
  }
12169
+ var init_find = __esm(() => {
12170
+ init_errors2();
12171
+ });
12164
12172
 
12165
12173
  // ../../packages/document-api/src/format/format.ts
12166
12174
  function validateTargetLocator(input, operation) {
@@ -12850,29 +12858,18 @@ var init_fragment_validator = __esm(() => {
12850
12858
  });
12851
12859
 
12852
12860
  // ../../packages/document-api/src/receipt-bridge.ts
12853
- function textAddressToSDAddress(textAddr) {
12861
+ function buildResolution(resolution) {
12854
12862
  return {
12855
- kind: "content",
12856
- stability: "stable",
12857
- nodeId: textAddr.blockId,
12858
- anchor: {
12859
- start: { blockId: textAddr.blockId, offset: textAddr.range.start },
12860
- end: { blockId: textAddr.blockId, offset: textAddr.range.end }
12861
- }
12862
- };
12863
- }
12864
- function buildSDResolution(resolution) {
12865
- return {
12866
- ...resolution.requestedTarget ? { requestedTarget: textAddressToSDAddress(resolution.requestedTarget) } : {},
12867
- target: textAddressToSDAddress(resolution.target),
12868
- ...resolution.selectionTarget ? { selectionTarget: resolution.selectionTarget } : undefined
12863
+ target: resolution.target,
12864
+ range: resolution.range,
12865
+ ...resolution.selectionTarget ? { selectionTarget: resolution.selectionTarget } : {}
12869
12866
  };
12870
12867
  }
12871
12868
  function textReceiptToSDReceipt(receipt2) {
12872
12869
  if (receipt2.success) {
12873
12870
  return {
12874
12871
  success: true,
12875
- resolution: receipt2.resolution ? buildSDResolution(receipt2.resolution) : undefined
12872
+ resolution: receipt2.resolution ? buildResolution(receipt2.resolution) : undefined
12876
12873
  };
12877
12874
  }
12878
12875
  const failure = {
@@ -12897,7 +12894,22 @@ function textReceiptToSDReceipt(receipt2) {
12897
12894
  return {
12898
12895
  success: false,
12899
12896
  failure,
12900
- resolution: receipt2.resolution ? buildSDResolution(receipt2.resolution) : undefined
12897
+ resolution: receipt2.resolution ? buildResolution(receipt2.resolution) : undefined
12898
+ };
12899
+ }
12900
+ function buildStructuralReceipt(success, params, failure) {
12901
+ const resolution = {
12902
+ target: params.target,
12903
+ range: params.range,
12904
+ ...params.selectionTarget ? { selectionTarget: params.selectionTarget } : {}
12905
+ };
12906
+ if (success) {
12907
+ return { success: true, resolution };
12908
+ }
12909
+ return {
12910
+ success: false,
12911
+ failure: { code: failure?.code ?? "INTERNAL_ERROR", message: failure?.message ?? "" },
12912
+ resolution
12901
12913
  };
12902
12914
  }
12903
12915
 
@@ -12954,8 +12966,8 @@ function validateStructuralInsertInput(input) {
12954
12966
  }
12955
12967
  assertNoUnknownFields(input, STRUCTURAL_INSERT_ALLOWED_KEYS, "insert");
12956
12968
  const { target, content, placement: placement2, nestingPolicy } = input;
12957
- if (target !== undefined && !isValidTarget(target)) {
12958
- throw new DocumentApiValidationError("INVALID_TARGET", "target must be a valid address (SDAddress or TextAddress).", {
12969
+ if (target !== undefined && !isBlockNodeAddress(target)) {
12970
+ throw new DocumentApiValidationError("INVALID_TARGET", 'target must be a BlockNodeAddress ({ kind: "block", nodeType, nodeId }).', {
12959
12971
  field: "target",
12960
12972
  value: target
12961
12973
  });
@@ -13188,8 +13200,11 @@ function validateStructuralReplaceInput(input) {
13188
13200
  fields: ["target", "ref"]
13189
13201
  });
13190
13202
  }
13191
- if (hasTarget && !isSDAddress(target) && !isTextAddress(target) && !isSelectionTarget(target)) {
13192
- throw new DocumentApiValidationError("INVALID_TARGET", "target must be a valid address (SDAddress, TextAddress, or SelectionTarget).", { field: "target", value: target });
13203
+ if (hasTarget && !isBlockNodeAddress(target) && !isSelectionTarget(target)) {
13204
+ throw new DocumentApiValidationError("INVALID_TARGET", "target must be a BlockNodeAddress or SelectionTarget.", {
13205
+ field: "target",
13206
+ value: target
13207
+ });
13193
13208
  }
13194
13209
  if (hasRef && typeof refValue !== "string") {
13195
13210
  throw new DocumentApiValidationError("INVALID_TARGET", "ref must be a string.", {
@@ -16409,7 +16424,11 @@ function createDocumentApi(adapters) {
16409
16424
  },
16410
16425
  query: {
16411
16426
  match(input) {
16412
- return adapters.query.match(input);
16427
+ if (!input || typeof input !== "object") {
16428
+ throw new DocumentApiValidationError("INVALID_INPUT", "query.match requires a QueryMatchInput or selector object.", { value: input });
16429
+ }
16430
+ const normalized = "select" in input ? input : { select: input };
16431
+ return adapters.query.match(normalized);
16413
16432
  }
16414
16433
  },
16415
16434
  ranges: {
@@ -16452,6 +16471,7 @@ var init_src = __esm(() => {
16452
16471
  init_errors2();
16453
16472
  init_ranges();
16454
16473
  init_comments();
16474
+ init_find();
16455
16475
  init_format();
16456
16476
  init_inline_run_patch();
16457
16477
  init_styles();
@@ -38780,7 +38800,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
38780
38800
  emptyOptions2 = {};
38781
38801
  });
38782
38802
 
38783
- // ../../packages/superdoc/dist/chunks/SuperConverter-BParsWaS.es.js
38803
+ // ../../packages/superdoc/dist/chunks/SuperConverter-voJQZ_PC.es.js
38784
38804
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
38785
38805
  const fieldValue = extension$1.config[field];
38786
38806
  if (typeof fieldValue === "function")
@@ -39594,18 +39614,17 @@ function isTextAddress2(value) {
39594
39614
  return false;
39595
39615
  return range.start <= range.end;
39596
39616
  }
39597
- function isSDAddress2(value) {
39617
+ function isBlockNodeAddress2(value) {
39598
39618
  if (!isRecord3(value))
39599
39619
  return false;
39600
- if (typeof value.kind !== "string" || !SD_ADDRESS_KINDS2.has(value.kind))
39620
+ if (value.kind !== "block")
39621
+ return false;
39622
+ if (typeof value.nodeType !== "string" || !BLOCK_NODE_TYPES_SET2.has(value.nodeType))
39601
39623
  return false;
39602
- if (typeof value.stability !== "string" || !SD_ADDRESS_STABILITIES2.has(value.stability))
39624
+ if (typeof value.nodeId !== "string")
39603
39625
  return false;
39604
39626
  return true;
39605
39627
  }
39606
- function isValidTarget2(value) {
39607
- return isTextAddress2(value) || isSDAddress2(value);
39608
- }
39609
39628
  function assertNoUnknownFields3(input, allowlist, operationName) {
39610
39629
  for (const key of Object.keys(input))
39611
39630
  if (!allowlist.has(key))
@@ -42005,35 +42024,18 @@ function validateLegacyInlineContent2(item, parentType) {
42005
42024
  throw new DocumentApiValidationError2("INVALID_PAYLOAD", `Inline image content in ${parentType} requires a non-empty "src" string field.`, { field: "src" });
42006
42025
  }
42007
42026
  }
42008
- function textAddressToSDAddress2(textAddr) {
42027
+ function buildResolution2(resolution) {
42009
42028
  return {
42010
- kind: "content",
42011
- stability: "stable",
42012
- nodeId: textAddr.blockId,
42013
- anchor: {
42014
- start: {
42015
- blockId: textAddr.blockId,
42016
- offset: textAddr.range.start
42017
- },
42018
- end: {
42019
- blockId: textAddr.blockId,
42020
- offset: textAddr.range.end
42021
- }
42022
- }
42023
- };
42024
- }
42025
- function buildSDResolution2(resolution) {
42026
- return {
42027
- ...resolution.requestedTarget ? { requestedTarget: textAddressToSDAddress2(resolution.requestedTarget) } : {},
42028
- target: textAddressToSDAddress2(resolution.target),
42029
- ...resolution.selectionTarget ? { selectionTarget: resolution.selectionTarget } : undefined
42029
+ target: resolution.target,
42030
+ range: resolution.range,
42031
+ ...resolution.selectionTarget ? { selectionTarget: resolution.selectionTarget } : {}
42030
42032
  };
42031
42033
  }
42032
42034
  function textReceiptToSDReceipt2(receipt2) {
42033
42035
  if (receipt2.success)
42034
42036
  return {
42035
42037
  success: true,
42036
- resolution: receipt2.resolution ? buildSDResolution2(receipt2.resolution) : undefined
42038
+ resolution: receipt2.resolution ? buildResolution2(receipt2.resolution) : undefined
42037
42039
  };
42038
42040
  const failure = {
42039
42041
  code: "INTERNAL_ERROR",
@@ -42056,7 +42058,27 @@ function textReceiptToSDReceipt2(receipt2) {
42056
42058
  return {
42057
42059
  success: false,
42058
42060
  failure,
42059
- resolution: receipt2.resolution ? buildSDResolution2(receipt2.resolution) : undefined
42061
+ resolution: receipt2.resolution ? buildResolution2(receipt2.resolution) : undefined
42062
+ };
42063
+ }
42064
+ function buildStructuralReceipt2(success, params, failure) {
42065
+ const resolution = {
42066
+ target: params.target,
42067
+ range: params.range,
42068
+ ...params.selectionTarget ? { selectionTarget: params.selectionTarget } : {}
42069
+ };
42070
+ if (success)
42071
+ return {
42072
+ success: true,
42073
+ resolution
42074
+ };
42075
+ return {
42076
+ success: false,
42077
+ failure: {
42078
+ code: failure?.code ?? "INTERNAL_ERROR",
42079
+ message: failure?.message ?? ""
42080
+ },
42081
+ resolution
42060
42082
  };
42061
42083
  }
42062
42084
  function isStructuralInsertInput2(input) {
@@ -42104,8 +42126,8 @@ function validateStructuralInsertInput2(input) {
42104
42126
  throw new DocumentApiValidationError2("INVALID_INPUT", '"type" field is only valid with legacy string input ("value"), not with structural "content".', { field: "type" });
42105
42127
  assertNoUnknownFields3(input, STRUCTURAL_INSERT_ALLOWED_KEYS2, "insert");
42106
42128
  const { target, content: content$2, placement: placement2, nestingPolicy } = input;
42107
- if (target !== undefined && !isValidTarget2(target))
42108
- throw new DocumentApiValidationError2("INVALID_TARGET", "target must be a valid address (SDAddress or TextAddress).", {
42129
+ if (target !== undefined && !isBlockNodeAddress2(target))
42130
+ throw new DocumentApiValidationError2("INVALID_TARGET", 'target must be a BlockNodeAddress ({ kind: "block", nodeType, nodeId }).', {
42109
42131
  field: "target",
42110
42132
  value: target
42111
42133
  });
@@ -42305,8 +42327,8 @@ function validateStructuralReplaceInput2(input) {
42305
42327
  throw new DocumentApiValidationError2("INVALID_INPUT", 'Structural replace must provide either "target" or "ref", not both.', { fields: ["target", "ref"] });
42306
42328
  if (!hasTarget && !hasRef)
42307
42329
  throw new DocumentApiValidationError2("INVALID_TARGET", "Structural replace requires a target or ref.", { fields: ["target", "ref"] });
42308
- if (hasTarget && !isSDAddress2(target) && !isTextAddress2(target) && !isSelectionTarget2(target))
42309
- throw new DocumentApiValidationError2("INVALID_TARGET", "target must be a valid address (SDAddress, TextAddress, or SelectionTarget).", {
42330
+ if (hasTarget && !isBlockNodeAddress2(target) && !isSelectionTarget2(target))
42331
+ throw new DocumentApiValidationError2("INVALID_TARGET", "target must be a BlockNodeAddress or SelectionTarget.", {
42310
42332
  field: "target",
42311
42333
  value: target
42312
42334
  });
@@ -45167,7 +45189,10 @@ function createDocumentApi2(adapters) {
45167
45189
  }
45168
45190
  },
45169
45191
  query: { match(input) {
45170
- return adapters.query.match(input);
45192
+ if (!input || typeof input !== "object")
45193
+ throw new DocumentApiValidationError2("INVALID_INPUT", "query.match requires a QueryMatchInput or selector object.", { value: input });
45194
+ const normalized = "select" in input ? input : { select: input };
45195
+ return adapters.query.match(normalized);
45171
45196
  } },
45172
45197
  ranges: { resolve(input) {
45173
45198
  return executeResolveRange2(adapters.ranges, input);
@@ -63483,7 +63508,7 @@ var isRegExp = (value) => {
63483
63508
  }, decode$72 = (attrs) => {
63484
63509
  const { pos } = attrs || {};
63485
63510
  return pos?.toString();
63486
- }, attributes_default$6, DocumentApiValidationError2, NODE_TYPES2, BLOCK_NODE_TYPES2, DELETABLE_BLOCK_NODE_TYPES2, INLINE_NODE_TYPES2, SELECTION_EDGE_NODE_TYPES2, MARK_KEYS2, INLINE_DIRECTIVES2, SD_CONTENT_NODE_KINDS2, SD_INLINE_NODE_KINDS2, PLACEMENT_VALUES2, TABLE_NESTING_POLICY_VALUES2, DEFAULT_NESTING_POLICY2, SD_ADDRESS_KINDS2, SD_ADDRESS_STABILITIES2, NESTING_POLICY_ALLOWED_KEYS2, schemaBooleanOrNull2 = () => ({ oneOf: [{ type: "boolean" }, { type: "null" }] }), schemaStringOrNull2 = () => ({ oneOf: [{
63511
+ }, attributes_default$6, DocumentApiValidationError2, NODE_TYPES2, BLOCK_NODE_TYPES2, DELETABLE_BLOCK_NODE_TYPES2, INLINE_NODE_TYPES2, SELECTION_EDGE_NODE_TYPES2, MARK_KEYS2, INLINE_DIRECTIVES2, SD_CONTENT_NODE_KINDS2, SD_INLINE_NODE_KINDS2, PLACEMENT_VALUES2, TABLE_NESTING_POLICY_VALUES2, DEFAULT_NESTING_POLICY2, BLOCK_NODE_TYPES_SET2, NESTING_POLICY_ALLOWED_KEYS2, schemaBooleanOrNull2 = () => ({ oneOf: [{ type: "boolean" }, { type: "null" }] }), schemaStringOrNull2 = () => ({ oneOf: [{
63487
63512
  type: "string",
63488
63513
  minLength: 1
63489
63514
  }, { type: "null" }] }), schemaNumberOrNull2 = () => ({ oneOf: [{ type: "number" }, { type: "null" }] }), schemaObjectOrNull2 = (properties) => ({ oneOf: [{
@@ -63523,7 +63548,7 @@ var isRegExp = (value) => {
63523
63548
  tracked: false,
63524
63549
  carrier: runAttributeCarrier2(runPropertyKey ?? key),
63525
63550
  schema
63526
- }), INLINE_PROPERTY_REGISTRY2, INLINE_PROPERTY_KEY_SET2, INLINE_PROPERTY_BY_KEY2, UNDERLINE_OBJECT_ALLOWED_KEYS2, SHADING_ALLOWED_KEYS2, BORDER_ALLOWED_KEYS2, FIT_TEXT_ALLOWED_KEYS2, LANG_ALLOWED_KEYS2, RFONTS_ALLOWED_KEYS2, EAST_ASIAN_LAYOUT_ALLOWED_KEYS2, STYLISTIC_SET_ALLOWED_KEYS2, VERT_ALIGN_VALUES2, NONE_FAILURES2, NONE_THROWS2, T_NOT_FOUND2, T_NOT_FOUND_CAPABLE2, T_PLAN_ENGINE2, T_NOT_FOUND_COMMAND2, T_NOT_FOUND_COMMAND_TRACKED2, T_IMAGE_COMMAND2, T_CC_READ2, T_CC_MUTATION2, T_CC_TYPED2, T_CC_TYPED_READ2, T_CC_RAW2, T_QUERY_MATCH2, T_SECTION_CREATE2, T_SECTION_READ2, T_PARAGRAPH_MUTATION2, T_SECTION_MUTATION2, T_SECTION_SETTINGS_MUTATION2, T_HEADER_FOOTER_MUTATION2, T_REF_READ_LIST2, T_REF_MUTATION2, T_REF_MUTATION_REMOVE2, T_REF_INSERT2, FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS2, OPERATION_DEFINITIONS2, OPERATION_IDS2, COMMAND_CATALOG3, PARAGRAPH_ALIGNMENTS2, TAB_STOP_ALIGNMENTS2, TAB_STOP_LEADERS2, BORDER_SIDES2, CLEAR_BORDER_SIDES2, LINE_RULES2, PARAGRAPH_BLOCK_TYPES2, SET_STYLE_KEYS2, CLEAR_STYLE_KEYS2, RESET_DIRECT_FORMATTING_KEYS2, SET_ALIGNMENT_KEYS2, CLEAR_ALIGNMENT_KEYS2, SET_INDENTATION_KEYS2, CLEAR_INDENTATION_KEYS2, SET_SPACING_KEYS2, CLEAR_SPACING_KEYS2, SET_KEEP_OPTIONS_KEYS2, SET_OUTLINE_LEVEL_KEYS2, SET_FLOW_OPTIONS_KEYS2, SET_TAB_STOP_KEYS2, CLEAR_TAB_STOP_KEYS2, CLEAR_ALL_TAB_STOPS_KEYS2, SET_BORDER_KEYS2, CLEAR_BORDER_KEYS2, SET_SHADING_KEYS2, CLEAR_SHADING_KEYS2, ST_ON_OFF_ON_VALUES2, ST_ON_OFF_OFF_VALUES2, ST_UNDERLINE_VALUES2, ST_UNDERLINE_VALUE_SET2, ST_VERTICAL_ALIGN_RUN2, ST_EM2, ST_TEXT_ALIGNMENT2, ST_TEXT_DIRECTION2, ST_TEXTBOX_TIGHT_WRAP2, ST_TEXT_TRANSFORM2, ST_JUSTIFICATION2, FONT_FAMILY_SCHEMA2, COLOR_SCHEMA2, SPACING_SCHEMA2, INDENT_SCHEMA2, UNDERLINE_SCHEMA2, BORDER_PROPERTIES_SCHEMA2, SHADING_SCHEMA2, LANG_SCHEMA2, EAST_ASIAN_LAYOUT_SCHEMA2, FIT_TEXT_SCHEMA2, NUMBERING_PROPERTIES_SCHEMA2, FRAME_PR_SCHEMA2, PARAGRAPH_BORDERS_SCHEMA2, TAB_STOP_SCHEMA2, PROPERTY_REGISTRY3, ALLOWED_KEYS_BY_CHANNEL2, PROPERTY_INDEX2, EXCLUDED_KEYS2, INPUT_ALLOWED_KEYS2, TARGET_ALLOWED_KEYS2, OPTIONS_ALLOWED_KEYS2, VALID_CHANNELS2, Z_ORDER_RELATIVE_HEIGHT_MAX2 = 4294967295, nodeTypeValues2, blockNodeTypeValues2, deletableBlockNodeTypeValues2, inlineNodeTypeValues2, rangeSchema2, textAddressSchema2, textTargetSchema2, blockNodeAddressSchema2, deletableBlockNodeAddressSchema2, paragraphAddressSchema2, headingAddressSchema2, listItemAddressSchema2, paragraphTargetSchema2, sectionAddressSchema2, nodeAddressSchema2, commentAddressSchema2, trackedChangeAddressSchema2, entityAddressSchema2, selectionTargetSchema2, deleteBehaviorSchema2, resolvedHandleSchema2, pageInfoSchema2, receiptSuccessSchema2, textMutationResolutionSchema2, textMutationSuccessSchema2, matchBlockSchema2, trackChangeRefSchema2, createParagraphSuccessSchema2, createHeadingSuccessSchema2, headingLevelSchema2, listsInsertSuccessSchema2, listsMutateItemSuccessSchema2, textSelectorSchema2, nodeSelectorSchema2, sdSelectorSchema2, sdAddressSchema2, sdMutationResolutionSchema2, sdMutationSuccessSchema2, documentInfoCountsSchema2, documentInfoOutlineItemSchema2, documentInfoCapabilitiesSchema2, listKindSchema2, listInsertPositionSchema2, sectionBreakTypeSchema2, sectionOrientationSchema2, sectionVerticalAlignSchema2, sectionDirectionSchema2, sectionHeaderFooterKindSchema2, sectionHeaderFooterVariantSchema2, sectionLineNumberRestartSchema2, sectionPageNumberFormatSchema2, sectionRangeDomainSchema2, sectionPageMarginsSchema2, sectionHeaderFooterMarginsSchema2, sectionPageSetupSchema2, sectionColumnsSchema2, sectionLineNumberingSchema2, sectionPageNumberingSchema2, sectionHeaderFooterRefsSchema2, sectionBorderSpecSchema2, sectionPageBordersSchema2, sectionMutationSuccessSchema2, documentMutationSuccessSchema2, paragraphMutationTargetSchema2, paragraphMutationSuccessSchema2, createSectionBreakSuccessSchema2, capabilityReasonsSchema2, capabilityFlagSchema2, operationRuntimeCapabilitySchema2, operationCapabilitiesSchema2, inlinePropertyCapabilitySchema2, formatCapabilitiesSchema2, planEngineCapabilitiesSchema2, tableCreateLocationSchema2, formatInlineAliasOperationSchemas2, tocMutationFailureSchema2, tocMutationSuccessSchema2, tocEntryMutationFailureSchema2, tocEntryMutationSuccessSchema2, hyperlinkTargetSchema2, hyperlinkReadPropertiesSchema2, hyperlinkSpecSchema2, hyperlinkPatchSchema2, hyperlinkDomainSchema2, hyperlinkMutationSuccessSchema2, hyperlinkMutationFailureSchema2, contentControlTargetSchema2, contentControlMutationSuccessSchema2, contentControlMutationFailureSchema2, ccListResultSchema2, ccInfoSchema2, refFailureSchema2, bookmarkAddressSchema2, bookmarkMutation2, footnoteAddressSchema2, footnoteConfigScopeSchema2, footnoteNumberingSchema2, footnoteMutation2, footnoteConfig2, crossRefAddressSchema2, crossRefTargetSchema2, crossRefDisplaySchema2, crossRefMutation2, indexAddressSchema2, indexEntryAddressSchema2, indexConfigSchema2, indexEntryDataSchema2, indexEntryPatchSchema2, indexMutation2, indexEntryMutation2, captionAddressSchema2, captionMutation2, captionConfig2, fieldAddressSchema2, fieldMutation2, citationAddressSchema2, citationSourceAddressSchema2, bibliographyAddressSchema2, citationMutation2, citationSourceMutation2, bibliographyMutation2, citationPersonSchema2, citationSourceFieldsSchema2, tocCreateLocationSchema2, authoritiesAddressSchema2, authorityEntryAddressSchema2, authoritiesConfigSchema2, authorityEntryDataSchema2, authorityEntryPatchSchema2, authoritiesMutation2, authorityEntryMutation2, GROUP_METADATA2, STEP_OP_CATALOG_UNFROZEN2, PUBLIC_STEP_OP_CATALOG_UNFROZEN2, PUBLIC_MUTATION_STEP_OP_IDS2, PUBLIC_MUTATION_STEP_OP_SET2, CAPABILITY_REASON_CODES2, VALID_EDGE_VALUES2, VALID_EDGE_NODE_TYPES2, VALID_DOCUMENT_EDGES2, VALID_REF_BOUNDARIES2, VALID_ANCHOR_KINDS2, RESOLVE_RANGE_ALLOWED_KEYS2, CREATE_COMMENT_ALLOWED_KEYS2, PATCH_COMMENT_ALLOWED_KEYS2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, INLINE_ALIAS_INPUT_ALLOWED_KEYS2, DELETE_INPUT_ALLOWED_KEYS2, VALID_BEHAVIORS2, CONTENT_KIND_SET2, INLINE_KIND_SET2, LEGACY_TOP_LEVEL_TYPES2, LEGACY_INSERT_ALLOWED_KEYS2, STRUCTURAL_INSERT_ALLOWED_KEYS2, VALID_INSERT_TYPES2, TEXT_REPLACE_ALLOWED_KEYS2, STRUCTURAL_REPLACE_ALLOWED_KEYS2, SECTION_BREAK_TYPES$1, SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, VALID_BLOCK_NODE_TYPES2, TABLE_LOCATOR_OPS2, ROW_LOCATOR_OPS2, COLUMN_LOCATOR_OPS2, MERGE_RANGE_LOCATOR_OPS2, HEADER_FOOTER_KINDS$1, HEADER_FOOTER_VARIANTS$1, DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS3, HEADER_FOOTER_VARIANTS3, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2, VALID_WRAP_TYPES2, VALID_WRAP_SIDES2, VALID_IMAGE_SIZE_UNITS2, PATCH_FIELDS2, ADAPTER_GATED_PREFIXES2, _buffers, _defaultCollectionId = null, _nextCollectionId = 1, generateV2HandlerEntity = (handlerName, translator$215) => ({
63551
+ }), INLINE_PROPERTY_REGISTRY2, INLINE_PROPERTY_KEY_SET2, INLINE_PROPERTY_BY_KEY2, UNDERLINE_OBJECT_ALLOWED_KEYS2, SHADING_ALLOWED_KEYS2, BORDER_ALLOWED_KEYS2, FIT_TEXT_ALLOWED_KEYS2, LANG_ALLOWED_KEYS2, RFONTS_ALLOWED_KEYS2, EAST_ASIAN_LAYOUT_ALLOWED_KEYS2, STYLISTIC_SET_ALLOWED_KEYS2, VERT_ALIGN_VALUES2, NONE_FAILURES2, NONE_THROWS2, T_NOT_FOUND2, T_NOT_FOUND_CAPABLE2, T_PLAN_ENGINE2, T_NOT_FOUND_COMMAND2, T_NOT_FOUND_COMMAND_TRACKED2, T_IMAGE_COMMAND2, T_CC_READ2, T_CC_MUTATION2, T_CC_TYPED2, T_CC_TYPED_READ2, T_CC_RAW2, T_QUERY_MATCH2, T_SECTION_CREATE2, T_SECTION_READ2, T_PARAGRAPH_MUTATION2, T_SECTION_MUTATION2, T_SECTION_SETTINGS_MUTATION2, T_HEADER_FOOTER_MUTATION2, T_REF_READ_LIST2, T_REF_MUTATION2, T_REF_MUTATION_REMOVE2, T_REF_INSERT2, FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS2, OPERATION_DEFINITIONS2, OPERATION_IDS2, COMMAND_CATALOG3, PARAGRAPH_ALIGNMENTS2, TAB_STOP_ALIGNMENTS2, TAB_STOP_LEADERS2, BORDER_SIDES2, CLEAR_BORDER_SIDES2, LINE_RULES2, PARAGRAPH_BLOCK_TYPES2, SET_STYLE_KEYS2, CLEAR_STYLE_KEYS2, RESET_DIRECT_FORMATTING_KEYS2, SET_ALIGNMENT_KEYS2, CLEAR_ALIGNMENT_KEYS2, SET_INDENTATION_KEYS2, CLEAR_INDENTATION_KEYS2, SET_SPACING_KEYS2, CLEAR_SPACING_KEYS2, SET_KEEP_OPTIONS_KEYS2, SET_OUTLINE_LEVEL_KEYS2, SET_FLOW_OPTIONS_KEYS2, SET_TAB_STOP_KEYS2, CLEAR_TAB_STOP_KEYS2, CLEAR_ALL_TAB_STOPS_KEYS2, SET_BORDER_KEYS2, CLEAR_BORDER_KEYS2, SET_SHADING_KEYS2, CLEAR_SHADING_KEYS2, ST_ON_OFF_ON_VALUES2, ST_ON_OFF_OFF_VALUES2, ST_UNDERLINE_VALUES2, ST_UNDERLINE_VALUE_SET2, ST_VERTICAL_ALIGN_RUN2, ST_EM2, ST_TEXT_ALIGNMENT2, ST_TEXT_DIRECTION2, ST_TEXTBOX_TIGHT_WRAP2, ST_TEXT_TRANSFORM2, ST_JUSTIFICATION2, FONT_FAMILY_SCHEMA2, COLOR_SCHEMA2, SPACING_SCHEMA2, INDENT_SCHEMA2, UNDERLINE_SCHEMA2, BORDER_PROPERTIES_SCHEMA2, SHADING_SCHEMA2, LANG_SCHEMA2, EAST_ASIAN_LAYOUT_SCHEMA2, FIT_TEXT_SCHEMA2, NUMBERING_PROPERTIES_SCHEMA2, FRAME_PR_SCHEMA2, PARAGRAPH_BORDERS_SCHEMA2, TAB_STOP_SCHEMA2, PROPERTY_REGISTRY3, ALLOWED_KEYS_BY_CHANNEL2, PROPERTY_INDEX2, EXCLUDED_KEYS2, INPUT_ALLOWED_KEYS2, TARGET_ALLOWED_KEYS2, OPTIONS_ALLOWED_KEYS2, VALID_CHANNELS2, Z_ORDER_RELATIVE_HEIGHT_MAX2 = 4294967295, nodeTypeValues2, blockNodeTypeValues2, deletableBlockNodeTypeValues2, inlineNodeTypeValues2, rangeSchema2, textAddressSchema2, textTargetSchema2, blockNodeAddressSchema2, deletableBlockNodeAddressSchema2, paragraphAddressSchema2, headingAddressSchema2, listItemAddressSchema2, paragraphTargetSchema2, sectionAddressSchema2, nodeAddressSchema2, commentAddressSchema2, trackedChangeAddressSchema2, entityAddressSchema2, selectionTargetSchema2, deleteBehaviorSchema2, resolvedHandleSchema2, pageInfoSchema2, receiptSuccessSchema2, textMutationRangeSchema2, textMutationResolutionSchema2, textMutationSuccessSchema2, matchBlockSchema2, trackChangeRefSchema2, createParagraphSuccessSchema2, createHeadingSuccessSchema2, headingLevelSchema2, listsInsertSuccessSchema2, listsMutateItemSuccessSchema2, textSelectorSchema2, nodeSelectorSchema2, sdMutationResolutionSchema2, sdMutationSuccessSchema2, documentInfoCountsSchema2, documentInfoOutlineItemSchema2, documentInfoCapabilitiesSchema2, listKindSchema2, listInsertPositionSchema2, sectionBreakTypeSchema2, sectionOrientationSchema2, sectionVerticalAlignSchema2, sectionDirectionSchema2, sectionHeaderFooterKindSchema2, sectionHeaderFooterVariantSchema2, sectionLineNumberRestartSchema2, sectionPageNumberFormatSchema2, sectionRangeDomainSchema2, sectionPageMarginsSchema2, sectionHeaderFooterMarginsSchema2, sectionPageSetupSchema2, sectionColumnsSchema2, sectionLineNumberingSchema2, sectionPageNumberingSchema2, sectionHeaderFooterRefsSchema2, sectionBorderSpecSchema2, sectionPageBordersSchema2, sectionMutationSuccessSchema2, documentMutationSuccessSchema2, paragraphMutationTargetSchema2, paragraphMutationSuccessSchema2, createSectionBreakSuccessSchema2, capabilityReasonsSchema2, capabilityFlagSchema2, operationRuntimeCapabilitySchema2, operationCapabilitiesSchema2, inlinePropertyCapabilitySchema2, formatCapabilitiesSchema2, planEngineCapabilitiesSchema2, sdFragmentSchema2, placementSchema2, nestingPolicySchema2, tableCreateLocationSchema2, formatInlineAliasOperationSchemas2, tocMutationFailureSchema2, tocMutationSuccessSchema2, tocEntryMutationFailureSchema2, tocEntryMutationSuccessSchema2, hyperlinkTargetSchema2, hyperlinkReadPropertiesSchema2, hyperlinkSpecSchema2, hyperlinkPatchSchema2, hyperlinkDomainSchema2, hyperlinkMutationSuccessSchema2, hyperlinkMutationFailureSchema2, contentControlTargetSchema2, contentControlMutationSuccessSchema2, contentControlMutationFailureSchema2, ccListResultSchema2, ccInfoSchema2, refFailureSchema2, bookmarkAddressSchema2, bookmarkMutation2, footnoteAddressSchema2, footnoteConfigScopeSchema2, footnoteNumberingSchema2, footnoteMutation2, footnoteConfig2, crossRefAddressSchema2, crossRefTargetSchema2, crossRefDisplaySchema2, crossRefMutation2, indexAddressSchema2, indexEntryAddressSchema2, indexConfigSchema2, indexEntryDataSchema2, indexEntryPatchSchema2, indexMutation2, indexEntryMutation2, captionAddressSchema2, captionMutation2, captionConfig2, fieldAddressSchema2, fieldMutation2, citationAddressSchema2, citationSourceAddressSchema2, bibliographyAddressSchema2, citationMutation2, citationSourceMutation2, bibliographyMutation2, citationPersonSchema2, citationSourceFieldsSchema2, tocCreateLocationSchema2, authoritiesAddressSchema2, authorityEntryAddressSchema2, authoritiesConfigSchema2, authorityEntryDataSchema2, authorityEntryPatchSchema2, authoritiesMutation2, authorityEntryMutation2, GROUP_METADATA2, STEP_OP_CATALOG_UNFROZEN2, PUBLIC_STEP_OP_CATALOG_UNFROZEN2, PUBLIC_MUTATION_STEP_OP_IDS2, PUBLIC_MUTATION_STEP_OP_SET2, CAPABILITY_REASON_CODES2, VALID_EDGE_VALUES2, VALID_EDGE_NODE_TYPES2, VALID_DOCUMENT_EDGES2, VALID_REF_BOUNDARIES2, VALID_ANCHOR_KINDS2, RESOLVE_RANGE_ALLOWED_KEYS2, CREATE_COMMENT_ALLOWED_KEYS2, PATCH_COMMENT_ALLOWED_KEYS2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, INLINE_ALIAS_INPUT_ALLOWED_KEYS2, DELETE_INPUT_ALLOWED_KEYS2, VALID_BEHAVIORS2, CONTENT_KIND_SET2, INLINE_KIND_SET2, LEGACY_TOP_LEVEL_TYPES2, LEGACY_INSERT_ALLOWED_KEYS2, STRUCTURAL_INSERT_ALLOWED_KEYS2, VALID_INSERT_TYPES2, TEXT_REPLACE_ALLOWED_KEYS2, STRUCTURAL_REPLACE_ALLOWED_KEYS2, SECTION_BREAK_TYPES$1, SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, VALID_BLOCK_NODE_TYPES2, TABLE_LOCATOR_OPS2, ROW_LOCATOR_OPS2, COLUMN_LOCATOR_OPS2, MERGE_RANGE_LOCATOR_OPS2, HEADER_FOOTER_KINDS$1, HEADER_FOOTER_VARIANTS$1, DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS3, HEADER_FOOTER_VARIANTS3, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2, VALID_WRAP_TYPES2, VALID_WRAP_SIDES2, VALID_IMAGE_SIZE_UNITS2, PATCH_FIELDS2, ADAPTER_GATED_PREFIXES2, _buffers, _defaultCollectionId = null, _nextCollectionId = 1, generateV2HandlerEntity = (handlerName, translator$215) => ({
63527
63552
  handlerName,
63528
63553
  handler: (params) => {
63529
63554
  const { nodes } = params;
@@ -75603,7 +75628,7 @@ var isRegExp = (value) => {
75603
75628
  state.kern = kernNode.attributes["w:val"];
75604
75629
  }
75605
75630
  }, SuperConverter;
75606
- var init_SuperConverter_BParsWaS_es = __esm(() => {
75631
+ var init_SuperConverter_voJQZ_PC_es = __esm(() => {
75607
75632
  init_rolldown_runtime_B2q5OVn9_es();
75608
75633
  init_jszip_ChlR43oI_es();
75609
75634
  init_xml_js_DLE8mr0n_es();
@@ -78149,13 +78174,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
78149
78174
  ]);
78150
78175
  TABLE_NESTING_POLICY_VALUES2 = new Set(["forbid", "allow"]);
78151
78176
  DEFAULT_NESTING_POLICY2 = Object.freeze({ tables: "forbid" });
78152
- SD_ADDRESS_KINDS2 = new Set([
78153
- "content",
78154
- "inline",
78155
- "annotation",
78156
- "section"
78157
- ]);
78158
- SD_ADDRESS_STABILITIES2 = new Set(["stable", "ephemeral"]);
78177
+ BLOCK_NODE_TYPES_SET2 = new Set(BLOCK_NODE_TYPES2);
78159
78178
  NESTING_POLICY_ALLOWED_KEYS2 = new Set(["tables"]);
78160
78179
  UNDERLINE_OBJECT_SCHEMA2 = {
78161
78180
  type: "object",
@@ -78647,8 +78666,8 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
78647
78666
  },
78648
78667
  insert: {
78649
78668
  memberPath: "insert",
78650
- description: "Insert inline content at a text position within an existing block, or at the end of the document when target is omitted. This is NOT for creating sibling blocks — use create.paragraph, create.heading, or lists.insert for that. Accepts two input shapes: legacy string-based (value + type) or structural SDFragment (content). Supports text (default), markdown, and html content types via the `type` field in legacy mode. Structural mode accepts an SDFragment with typed nodes (paragraphs, tables, images, etc.).",
78651
- expectedResult: "Returns a TextMutationReceipt with applied status; receipt reports NO_OP if the insertion point is invalid or content is empty.",
78669
+ description: "Insert content into the document. Two input shapes: legacy string-based (value + type) inserts inline content at a text position within an existing block; structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. When target is omitted, content appends at the end of the document. Legacy mode supports text (default), markdown, and html content types via the `type` field. Structural mode uses `placement` (before/after/insideStart/insideEnd) to position relative to the target block.",
78670
+ expectedResult: "Returns an SDMutationReceipt with applied status; resolution reports a TextAddress for legacy text insertion or a BlockNodeAddress for structural insertion. Receipt reports NO_OP if the insertion point is invalid or content is empty.",
78652
78671
  requiresDocumentContext: true,
78653
78672
  metadata: mutationOperation2({
78654
78673
  idempotency: "non-idempotent",
@@ -78686,7 +78705,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
78686
78705
  },
78687
78706
  replace: {
78688
78707
  memberPath: "replace",
78689
- description: "Replace content at a contiguous document selection. Text path accepts a SelectionTarget or ref plus replacement text. Structural path accepts an SDAddress, SelectionTarget, or ref plus SDFragment content.",
78708
+ description: "Replace content at a contiguous document selection. Text path accepts a SelectionTarget or ref plus replacement text. Structural path accepts a BlockNodeAddress (replaces whole block), SelectionTarget (expands to full covered block boundaries), or ref plus SDFragment content.",
78690
78709
  expectedResult: "Returns an SDMutationReceipt with applied status; receipt reports NO_OP if the target range already contains identical content.",
78691
78710
  requiresDocumentContext: true,
78692
78711
  metadata: mutationOperation2({
@@ -84458,7 +84477,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
84458
84477
  resolvedHandleSchema2 = ref2("ResolvedHandle");
84459
84478
  pageInfoSchema2 = ref2("PageInfo");
84460
84479
  receiptSuccessSchema2 = ref2("ReceiptSuccess");
84461
- ref2("TextMutationRange");
84480
+ textMutationRangeSchema2 = ref2("TextMutationRange");
84462
84481
  textMutationResolutionSchema2 = ref2("TextMutationResolution");
84463
84482
  textMutationSuccessSchema2 = ref2("TextMutationSuccess");
84464
84483
  ref2("MatchRun");
@@ -84540,41 +84559,18 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
84540
84559
  kind: { enum: ["block", "inline"] }
84541
84560
  }, ["type"]);
84542
84561
  objectSchema2({ nodeType: { enum: [...nodeTypeValues2] } }, ["nodeType"]);
84543
- sdSelectorSchema2 = { oneOf: [objectSchema2({
84544
- type: { const: "text" },
84545
- pattern: { type: "string" },
84546
- mode: { enum: ["contains", "regex"] },
84547
- caseSensitive: { type: "boolean" }
84548
- }, ["type", "pattern"]), objectSchema2({
84549
- type: { const: "node" },
84550
- kind: { enum: ["content", "inline"] },
84551
- nodeKind: { type: "string" }
84552
- }, ["type"])] };
84553
- sdAddressSchema2 = objectSchema2({
84554
- kind: { enum: [
84555
- "content",
84556
- "inline",
84557
- "annotation",
84558
- "section"
84559
- ] },
84560
- stability: { enum: ["stable", "ephemeral"] },
84561
- nodeId: { type: "string" },
84562
- anchor: objectSchema2({
84563
- start: objectSchema2({
84564
- blockId: { type: "string" },
84565
- offset: { type: "integer" }
84566
- }, ["blockId", "offset"]),
84567
- end: objectSchema2({
84568
- blockId: { type: "string" },
84569
- offset: { type: "integer" }
84570
- }, ["blockId", "offset"])
84571
- }),
84572
- evaluatedRevision: { type: "string" },
84573
- path: arraySchema2({ oneOf: [{ type: "string" }, { type: "integer" }] })
84574
- }, ["kind", "stability"]);
84575
84562
  objectSchema2({
84576
- select: sdSelectorSchema2,
84577
- within: sdAddressSchema2,
84563
+ select: { oneOf: [objectSchema2({
84564
+ type: { const: "text" },
84565
+ pattern: { type: "string" },
84566
+ mode: { enum: ["contains", "regex"] },
84567
+ caseSensitive: { type: "boolean" }
84568
+ }, ["type", "pattern"]), objectSchema2({
84569
+ type: { const: "node" },
84570
+ kind: { enum: ["block", "inline"] },
84571
+ nodeType: { type: "string" }
84572
+ }, ["type"])] },
84573
+ within: blockNodeAddressSchema2,
84578
84574
  limit: { type: "integer" },
84579
84575
  offset: { type: "integer" },
84580
84576
  options: objectSchema2({
@@ -84598,7 +84594,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
84598
84594
  },
84599
84595
  items: arraySchema2(objectSchema2({
84600
84596
  node: { type: "object" },
84601
- address: sdAddressSchema2,
84597
+ address: nodeAddressSchema2,
84602
84598
  context: { type: "object" }
84603
84599
  }, ["node", "address"]))
84604
84600
  }, [
@@ -84608,10 +84604,10 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
84608
84604
  "items"
84609
84605
  ]);
84610
84606
  sdMutationResolutionSchema2 = objectSchema2({
84611
- requestedTarget: sdAddressSchema2,
84612
- target: sdAddressSchema2,
84607
+ target: { oneOf: [textAddressSchema2, blockNodeAddressSchema2] },
84608
+ range: textMutationRangeSchema2,
84613
84609
  selectionTarget: selectionTargetSchema2
84614
- }, ["target"]);
84610
+ }, ["target", "range"]);
84615
84611
  sdMutationSuccessSchema2 = objectSchema2({
84616
84612
  success: { const: true },
84617
84613
  resolution: sdMutationResolutionSchema2,
@@ -85082,6 +85078,17 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
85082
85078
  "planEngine"
85083
85079
  ]);
85084
85080
  objectSchema2({});
85081
+ sdFragmentSchema2 = { oneOf: [{ type: "object" }, {
85082
+ type: "array",
85083
+ items: { type: "object" }
85084
+ }] };
85085
+ placementSchema2 = { enum: [
85086
+ "before",
85087
+ "after",
85088
+ "insideStart",
85089
+ "insideEnd"
85090
+ ] };
85091
+ nestingPolicySchema2 = objectSchema2({ tables: { enum: ["forbid", "allow"] } });
85085
85092
  objectSchema2({
85086
85093
  target: textAddressSchema2,
85087
85094
  value: { type: "string" },
@@ -85093,7 +85100,12 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
85093
85100
  "html"
85094
85101
  ]
85095
85102
  }
85096
- }, ["value"]);
85103
+ }, ["value"]), objectSchema2({
85104
+ target: blockNodeAddressSchema2,
85105
+ content: sdFragmentSchema2,
85106
+ placement: placementSchema2,
85107
+ nestingPolicy: nestingPolicySchema2
85108
+ }, ["content"]);
85097
85109
  ({ ...objectSchema2({
85098
85110
  target: blockNodeAddressSchema2,
85099
85111
  nodeId: { type: "string" }
@@ -85668,17 +85680,13 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
85668
85680
  "lossy",
85669
85681
  "diagnostics"
85670
85682
  ]), receiptResultSchemaFor2("clearContent"), receiptFailureResultSchemaFor2("clearContent"), sdMutationResultSchemaFor2("insert"), sdMutationFailureSchemaFor2("insert"), { ...targetLocatorWithPayload2({ text: { type: "string" } }, ["text"]) }, objectSchema2({
85671
- target: { oneOf: [
85672
- sdAddressSchema2,
85673
- textAddressSchema2,
85674
- selectionTargetSchema2
85675
- ] },
85676
- content: { type: "object" },
85677
- nestingPolicy: { type: "object" }
85683
+ target: { oneOf: [blockNodeAddressSchema2, selectionTargetSchema2] },
85684
+ content: sdFragmentSchema2,
85685
+ nestingPolicy: nestingPolicySchema2
85678
85686
  }, ["target", "content"]), objectSchema2({
85679
85687
  ref: { type: "string" },
85680
- content: { type: "object" },
85681
- nestingPolicy: { type: "object" }
85688
+ content: sdFragmentSchema2,
85689
+ nestingPolicy: nestingPolicySchema2
85682
85690
  }, ["ref", "content"]), sdMutationResultSchemaFor2("replace"), sdMutationFailureSchemaFor2("replace"), { ...targetLocatorWithPayload2({ behavior: deleteBehaviorSchema2 }) }, textMutationResultSchemaFor2("delete"), textMutationFailureSchemaFor2("delete"), { ...targetLocatorWithPayload2({ inline: buildInlineRunPatchSchema2() }, ["inline"]) }, textMutationResultSchemaFor2("format.apply"), textMutationFailureSchemaFor2("format.apply"), { ...formatInlineAliasOperationSchemas2 }, objectSchema2({
85683
85691
  offset: {
85684
85692
  type: "number",
@@ -86479,7 +86487,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86479
86487
  ] }
86480
86488
  }), objectSchema2({ id: { type: "string" } }, ["id"]), objectSchema2({ id: { type: "string" } }, ["id"]), objectSchema2({ scope: { enum: ["all"] } }, ["scope"]), receiptResultSchemaFor2("trackChanges.decide"), receiptFailureResultSchemaFor2("trackChanges.decide"), objectSchema2({
86481
86489
  select: { oneOf: [textSelectorSchema2, nodeSelectorSchema2] },
86482
- within: nodeAddressSchema2,
86490
+ within: blockNodeAddressSchema2,
86483
86491
  require: { enum: [
86484
86492
  "any",
86485
86493
  "first",
@@ -86499,7 +86507,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86499
86507
  }, ["select"]), (() => {
86500
86508
  const textMatchItemSchema = discoveryItemSchema2({
86501
86509
  matchKind: { const: "text" },
86502
- address: nodeAddressSchema2,
86510
+ address: blockNodeAddressSchema2,
86503
86511
  target: selectionTargetSchema2,
86504
86512
  snippet: { type: "string" },
86505
86513
  highlightRange: rangeSchema2,
@@ -86539,7 +86547,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86539
86547
  type: "string"
86540
86548
  },
86541
86549
  select: { oneOf: [textSelectorSchema2, nodeSelectorSchema2] },
86542
- within: nodeAddressSchema2,
86550
+ within: blockNodeAddressSchema2,
86543
86551
  require: { enum: [
86544
86552
  "first",
86545
86553
  "exactlyOne",
@@ -86556,7 +86564,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86556
86564
  type: "string"
86557
86565
  },
86558
86566
  ref: { type: "string" },
86559
- within: nodeAddressSchema2
86567
+ within: blockNodeAddressSchema2
86560
86568
  }, ["by", "ref"]),
86561
86569
  objectSchema2({
86562
86570
  by: {
@@ -86572,7 +86580,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86572
86580
  type: "string"
86573
86581
  },
86574
86582
  select: { oneOf: [textSelectorSchema2, nodeSelectorSchema2] },
86575
- within: nodeAddressSchema2,
86583
+ within: blockNodeAddressSchema2,
86576
86584
  require: { enum: ["first", "exactlyOne"] }
86577
86585
  }, [
86578
86586
  "by",
@@ -86585,7 +86593,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
86585
86593
  type: "string"
86586
86594
  },
86587
86595
  select: { oneOf: [textSelectorSchema2, nodeSelectorSchema2] },
86588
- within: nodeAddressSchema2
86596
+ within: blockNodeAddressSchema2
86589
86597
  }, ["by", "select"]);
86590
86598
  const replacementBlockSchema = objectSchema2({ text: { type: "string" } }, ["text"]);
86591
86599
  const replacementPayloadSchema = { oneOf: [objectSchema2({ text: { type: "string" } }, ["text"]), objectSchema2({ blocks: arraySchema2(replacementBlockSchema) }, ["blocks"])] };
@@ -87844,7 +87852,7 @@ var init_SuperConverter_BParsWaS_es = __esm(() => {
87844
87852
  imageId: { type: "string" },
87845
87853
  text: { type: "string" }
87846
87854
  }, ["imageId", "text"])), imagesMutationSchemaSet2(objectSchema2({ imageId: { type: "string" } }, ["imageId"])), objectSchema2({
87847
- within: nodeAddressSchema2,
87855
+ within: blockNodeAddressSchema2,
87848
87856
  hrefPattern: { type: "string" },
87849
87857
  anchor: { type: "string" },
87850
87858
  textPattern: { type: "string" },
@@ -136045,7 +136053,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
136045
136053
  init_remark_gfm_z_sDF4ss_es();
136046
136054
  });
136047
136055
 
136048
- // ../../packages/superdoc/dist/chunks/src-DLZxEXCY.es.js
136056
+ // ../../packages/superdoc/dist/chunks/src-D_53T9-x.es.js
136049
136057
  function deleteProps(obj, propOrProps) {
136050
136058
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
136051
136059
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -144647,11 +144655,6 @@ function assertUnambiguous(matches2, blockId) {
144647
144655
  matchCount: matches2.length
144648
144656
  });
144649
144657
  }
144650
- function findInlineWithinTextBlock(index2, blockId) {
144651
- const matches2 = findTextBlockCandidates(index2, blockId);
144652
- assertUnambiguous(matches2, blockId);
144653
- return matches2[0];
144654
- }
144655
144658
  function resolveTextTarget(editor, target) {
144656
144659
  const matches2 = findTextBlockCandidates(getBlockIndex(editor), target.blockId);
144657
144660
  assertUnambiguous(matches2, target.blockId);
@@ -144835,42 +144838,20 @@ function resolveWithinScope(index2, query2, diagnostics) {
144835
144838
  ok: true,
144836
144839
  range: undefined
144837
144840
  };
144838
- if (query2.within.kind === "block") {
144839
- const within$1 = findBlockById(index2, query2.within);
144840
- if (!within$1) {
144841
- addDiagnostic2(diagnostics, `Within block "${query2.within.nodeType}" with id "${query2.within.nodeId}" was not found in the document.`);
144842
- return { ok: false };
144843
- }
144844
- return {
144845
- ok: true,
144846
- range: {
144847
- start: within$1.pos,
144848
- end: within$1.end
144849
- }
144850
- };
144851
- }
144852
- if (query2.within.anchor.start.blockId !== query2.within.anchor.end.blockId) {
144853
- addDiagnostic2(diagnostics, "Inline within anchors that span multiple blocks are not supported.");
144854
- return { ok: false };
144855
- }
144856
- const block = findInlineWithinTextBlock(index2, query2.within.anchor.start.blockId);
144857
- if (!block) {
144858
- addDiagnostic2(diagnostics, `Within inline anchor block "${query2.within.anchor.start.blockId}" was not found in the document.`);
144859
- return { ok: false };
144860
- }
144861
- const resolved = resolveTextRangeInBlock(block.node, block.pos, {
144862
- start: query2.within.anchor.start.offset,
144863
- end: query2.within.anchor.end.offset
144864
- });
144865
- if (!resolved) {
144866
- addDiagnostic2(diagnostics, "Inline within anchor offsets could not be resolved in the target block.");
144841
+ let within$1 = findBlockById(index2, query2.within);
144842
+ if (!within$1 && query2.within.kind === "block")
144843
+ try {
144844
+ within$1 = findBlockByNodeIdOnly(index2, query2.within.nodeId);
144845
+ } catch {}
144846
+ if (!within$1) {
144847
+ addDiagnostic2(diagnostics, `Within block "${query2.within.nodeType}" with id "${query2.within.nodeId}" was not found in the document.`);
144867
144848
  return { ok: false };
144868
144849
  }
144869
144850
  return {
144870
144851
  ok: true,
144871
144852
  range: {
144872
- start: resolved.from,
144873
- end: resolved.to
144853
+ start: within$1.pos,
144854
+ end: within$1.end
144874
144855
  }
144875
144856
  };
144876
144857
  }
@@ -147336,7 +147317,7 @@ function buildTextContext(editor, address2, matchFrom, matchTo, textRanges) {
147336
147317
  textRanges: textRanges?.length ? textRanges : undefined
147337
147318
  };
147338
147319
  }
147339
- function toTextAddress$1(editor, block, range) {
147320
+ function toTextAddress$2(editor, block, range) {
147340
147321
  const blockStart = block.pos + 1;
147341
147322
  const blockEnd = block.end - 1;
147342
147323
  if (range.from < blockStart || range.to > blockEnd)
@@ -147603,7 +147584,7 @@ function executeTextSelector(editor, index2, query2, diagnostics) {
147603
147584
  return;
147604
147585
  if (!source)
147605
147586
  source = block;
147606
- return toTextAddress$1(editor, block, range);
147587
+ return toTextAddress$2(editor, block, range);
147607
147588
  }).filter((range) => Boolean(range));
147608
147589
  if (!source)
147609
147590
  source = findCandidateByPos(textBlocks, match$1.from) ?? findBlockByPos(index2, match$1.from);
@@ -148600,39 +148581,50 @@ function translateToInternalQuery(input2) {
148600
148581
  const { select: select2, within: within$1, limit, offset: offset$1 } = input2;
148601
148582
  if (within$1)
148602
148583
  validateWithinAddress(within$1);
148603
- if (select2.type === "text")
148604
- return {
148605
- select: {
148606
- type: "text",
148607
- pattern: select2.pattern,
148608
- ...select2.mode != null && { mode: select2.mode },
148609
- ...select2.caseSensitive != null && { caseSensitive: select2.caseSensitive }
148610
- },
148611
- limit,
148612
- offset: offset$1,
148613
- includeNodes: true
148614
- };
148584
+ if (select2.type === "node") {
148585
+ const raw = select2;
148586
+ if ("nodeKind" in raw && raw.nodeKind != null)
148587
+ throw new DocumentApiAdapterError("INVALID_INPUT", `"nodeKind" is no longer supported on node selectors. Use "nodeType" instead: { type: 'node', nodeType: '${String(raw.nodeKind)}' }.`, {
148588
+ field: "select.nodeKind",
148589
+ value: raw.nodeKind
148590
+ });
148591
+ if (raw.kind === "content")
148592
+ throw new DocumentApiAdapterError("INVALID_INPUT", `kind: 'content' is no longer supported on node selectors. Use kind: 'block' instead.`, {
148593
+ field: "select.kind",
148594
+ value: raw.kind
148595
+ });
148596
+ }
148615
148597
  return {
148616
- select: {
148617
- type: "node",
148618
- ...select2.nodeKind != null && { nodeType: select2.nodeKind },
148619
- ...select2.kind === "content" && { kind: "block" },
148620
- ...select2.kind === "inline" && { kind: "inline" }
148621
- },
148598
+ select: select2,
148622
148599
  limit,
148623
148600
  offset: offset$1,
148624
148601
  includeNodes: true
148625
148602
  };
148626
148603
  }
148627
- function validateWithinAddress(sdAddress) {
148628
- if (sdAddress.kind === "content" && sdAddress.nodeId)
148629
- return { nodeId: sdAddress.nodeId };
148630
- throw new DocumentApiAdapterError("INVALID_TARGET", `"within" scope requires a content-kind SDAddress with a nodeId. Got kind="${sdAddress.kind}".`, {
148604
+ function validateWithinAddress(address2) {
148605
+ if (address2.kind === "block" && "nodeId" in address2 && typeof address2.nodeId === "string")
148606
+ return {
148607
+ nodeId: address2.nodeId,
148608
+ nodeType: address2.nodeType
148609
+ };
148610
+ throw new DocumentApiAdapterError("INVALID_TARGET", '"within" scope requires a BlockNodeAddress with a nodeId.', {
148631
148611
  field: "within",
148632
- value: sdAddress
148612
+ value: address2
148633
148613
  });
148634
148614
  }
148635
- function resolveWithinNodeType(index2, nodeId) {
148615
+ function resolveWithinAddress(index2, nodeId, expectedNodeType) {
148616
+ if (expectedNodeType) {
148617
+ const match$2 = findBlockByIdStrict(index2, {
148618
+ kind: "block",
148619
+ nodeType: expectedNodeType,
148620
+ nodeId
148621
+ });
148622
+ return {
148623
+ kind: "block",
148624
+ nodeType: match$2.nodeType,
148625
+ nodeId: match$2.nodeId
148626
+ };
148627
+ }
148636
148628
  const match$1 = findBlockByNodeIdOnly(index2, nodeId);
148637
148629
  return {
148638
148630
  kind: "block",
@@ -148640,28 +148632,6 @@ function resolveWithinNodeType(index2, nodeId) {
148640
148632
  nodeId: match$1.nodeId
148641
148633
  };
148642
148634
  }
148643
- function toSDAddress(address2) {
148644
- if (address2.kind === "block")
148645
- return {
148646
- kind: "content",
148647
- stability: "stable",
148648
- nodeId: address2.nodeId
148649
- };
148650
- return {
148651
- kind: "inline",
148652
- stability: "ephemeral",
148653
- anchor: {
148654
- start: {
148655
- blockId: address2.anchor.start.blockId,
148656
- offset: address2.anchor.start.offset
148657
- },
148658
- end: {
148659
- blockId: address2.anchor.end.blockId,
148660
- offset: address2.anchor.end.offset
148661
- }
148662
- }
148663
- };
148664
- }
148665
148635
  function projectMatchToSDNodeResult(editor, address2, blockIndex) {
148666
148636
  if (address2.kind === "block") {
148667
148637
  const candidate = blockIndex.byId.get(`${address2.nodeType}:${address2.nodeId}`);
@@ -148671,12 +148641,12 @@ function projectMatchToSDNodeResult(editor, address2, blockIndex) {
148671
148641
  return null;
148672
148642
  return {
148673
148643
  node: projectContentNode(found2.node),
148674
- address: toSDAddress(address2)
148644
+ address: address2
148675
148645
  };
148676
148646
  }
148677
148647
  return {
148678
148648
  node: projectContentNode(candidate.node),
148679
- address: toSDAddress(address2)
148649
+ address: address2
148680
148650
  };
148681
148651
  }
148682
148652
  const inlineCandidate = findInlineByAnchor(getInlineIndex(editor), address2);
@@ -148684,13 +148654,13 @@ function projectMatchToSDNodeResult(editor, address2, blockIndex) {
148684
148654
  if (inlineCandidate.node)
148685
148655
  return {
148686
148656
  node: projectInlineNode(inlineCandidate.node),
148687
- address: toSDAddress(address2)
148657
+ address: address2
148688
148658
  };
148689
148659
  const markProjected = projectMarkBasedInline(editor, inlineCandidate);
148690
148660
  if (markProjected)
148691
148661
  return {
148692
148662
  node: markProjected,
148693
- address: toSDAddress(address2)
148663
+ address: address2
148694
148664
  };
148695
148665
  }
148696
148666
  return {
@@ -148698,15 +148668,15 @@ function projectMatchToSDNodeResult(editor, address2, blockIndex) {
148698
148668
  kind: "run",
148699
148669
  run: { text: resolveTextByBlockId(editor, address2.anchor) }
148700
148670
  },
148701
- address: toSDAddress(address2)
148671
+ address: address2
148702
148672
  };
148703
148673
  }
148704
148674
  function sdFindAdapter(editor, input2) {
148705
148675
  const query2 = translateToInternalQuery(input2);
148706
148676
  const index2 = getBlockIndex(editor);
148707
148677
  if (input2.within) {
148708
- const { nodeId } = validateWithinAddress(input2.within);
148709
- query2.within = resolveWithinNodeType(index2, nodeId);
148678
+ const { nodeId, nodeType } = validateWithinAddress(input2.within);
148679
+ query2.within = resolveWithinAddress(index2, nodeId, nodeType);
148710
148680
  }
148711
148681
  const diagnostics = [];
148712
148682
  const isInlineSelector = query2.select.type !== "text" && isInlineQuery(query2.select);
@@ -148731,41 +148701,29 @@ function findBlocksByTypeAndId(blockIndex, nodeType, nodeId) {
148731
148701
  return [byIdMatch];
148732
148702
  return blockIndex.candidates.filter((candidate) => candidate.nodeType === nodeType && candidate.nodeId === nodeId);
148733
148703
  }
148734
- function buildBlockAddress(nodeId) {
148735
- return {
148736
- kind: "content",
148737
- stability: "stable",
148738
- nodeId
148739
- };
148740
- }
148741
148704
  function buildInlineAddress(address2) {
148742
- return {
148743
- kind: "inline",
148744
- stability: "ephemeral",
148745
- anchor: {
148746
- start: {
148747
- blockId: address2.anchor.start.blockId,
148748
- offset: address2.anchor.start.offset
148749
- },
148750
- end: {
148751
- blockId: address2.anchor.end.blockId,
148752
- offset: address2.anchor.end.offset
148753
- }
148754
- }
148755
- };
148705
+ return address2;
148756
148706
  }
148757
148707
  function getNodeAdapter(editor, address2) {
148758
148708
  const blockIndex = getBlockIndex(editor);
148759
148709
  if (address2.kind === "block") {
148760
148710
  const matches2 = findBlocksByTypeAndId(blockIndex, address2.nodeType, address2.nodeId);
148761
- if (matches2.length === 0)
148762
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Node "${address2.nodeType}" not found for id "${address2.nodeId}".`);
148763
148711
  if (matches2.length > 1)
148764
148712
  throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Multiple nodes share ${address2.nodeType} id "${address2.nodeId}".`);
148765
- const candidate$1 = matches2[0];
148713
+ let candidate$1 = matches2[0];
148714
+ if (!candidate$1)
148715
+ try {
148716
+ candidate$1 = findBlockByNodeIdOnly(blockIndex, address2.nodeId);
148717
+ } catch {}
148718
+ if (!candidate$1)
148719
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Node "${address2.nodeType}" not found for id "${address2.nodeId}".`);
148766
148720
  return {
148767
148721
  node: projectContentNode(candidate$1.node),
148768
- address: buildBlockAddress(address2.nodeId)
148722
+ address: {
148723
+ kind: "block",
148724
+ nodeType: candidate$1.nodeType,
148725
+ nodeId: candidate$1.nodeId
148726
+ }
148769
148727
  };
148770
148728
  }
148771
148729
  const candidate = findInlineByAnchor(getInlineIndex(editor), address2);
@@ -148815,10 +148773,14 @@ function resolveBlockById(editor, nodeId, nodeType) {
148815
148773
  }
148816
148774
  function getNodeByIdAdapter(editor, input2) {
148817
148775
  const { nodeId, nodeType } = input2;
148818
- const { candidate } = resolveBlockById(editor, nodeId, nodeType);
148776
+ const { candidate, resolvedType } = resolveBlockById(editor, nodeId, nodeType);
148819
148777
  return {
148820
148778
  node: projectContentNode(candidate.node),
148821
- address: buildBlockAddress(nodeId)
148779
+ address: {
148780
+ kind: "block",
148781
+ nodeType: resolvedType,
148782
+ nodeId: candidate.nodeId
148783
+ }
148822
148784
  };
148823
148785
  }
148824
148786
  function getTextAdapter(editor, _input) {
@@ -152047,36 +152009,52 @@ function buildMarksFromLegacyRun(schema, run2) {
152047
152009
  marks.push(schema.marks.highlight.create({ color: run2.highlight }));
152048
152010
  return marks;
152049
152011
  }
152050
- function resolveInsertTarget(editor, target) {
152051
- if (!target)
152052
- return resolveDocumentEndTarget(editor);
152053
- const index2 = getBlockIndex(editor);
152054
- let candidate;
152012
+ function findBlockByTarget(index2, target, operationName) {
152013
+ const nodeId = target.kind === "block" ? target.nodeId : target.blockId;
152055
152014
  try {
152056
- candidate = findBlockByNodeIdOnly(index2, target.blockId);
152015
+ if (target.kind === "block") {
152016
+ const typed = findBlockById(index2, target);
152017
+ if (typed)
152018
+ return typed;
152019
+ return findBlockByNodeIdOnly(index2, nodeId);
152020
+ }
152021
+ return findBlockByNodeIdOnly(index2, nodeId);
152057
152022
  } catch {
152058
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve insert target for block "${target.blockId}".`);
152023
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve ${operationName} target for block "${nodeId}".`);
152059
152024
  }
152025
+ }
152026
+ function resolveInsertTarget(editor, target) {
152027
+ if (!target)
152028
+ return resolveDocumentEndTarget(editor);
152029
+ const candidate = findBlockByTarget(getBlockIndex(editor), target, "insert");
152060
152030
  return {
152061
152031
  insertPos: candidate.end,
152062
152032
  structuralEnd: false,
152063
- effectiveTarget: target,
152033
+ effectiveTarget: target.kind === "block" ? {
152034
+ kind: "text",
152035
+ blockId: target.nodeId,
152036
+ range: {
152037
+ start: 0,
152038
+ end: 0
152039
+ }
152040
+ } : target,
152064
152041
  targetNode: candidate.node,
152065
152042
  targetNodePos: candidate.pos
152066
152043
  };
152067
152044
  }
152068
152045
  function resolveReplaceTarget(editor, target) {
152069
- const index2 = getBlockIndex(editor);
152070
- let candidate;
152071
- try {
152072
- candidate = findBlockByNodeIdOnly(index2, target.blockId);
152073
- } catch {
152074
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${target.blockId}".`);
152075
- }
152046
+ const candidate = findBlockByTarget(getBlockIndex(editor), target, "replace");
152076
152047
  return {
152077
152048
  from: candidate.pos,
152078
152049
  to: candidate.end,
152079
- effectiveTarget: target
152050
+ effectiveTarget: target.kind === "block" ? {
152051
+ kind: "text",
152052
+ blockId: target.nodeId,
152053
+ range: {
152054
+ start: 0,
152055
+ end: 0
152056
+ }
152057
+ } : target
152080
152058
  };
152081
152059
  }
152082
152060
  function resolveDocumentEndTarget(editor) {
@@ -152317,17 +152295,16 @@ function ensureTableSeparators(jsonNodes) {
152317
152295
  if (jsonNodes[i$1].type === "table" && jsonNodes[i$1 + 1].type === "table")
152318
152296
  jsonNodes.splice(i$1 + 1, 0, { type: "paragraph" });
152319
152297
  }
152320
- function narrowToTextAddress(target) {
152298
+ function targetBlockId$1(target) {
152299
+ return target.kind === "block" ? target.nodeId : target.blockId;
152300
+ }
152301
+ function toTextAddress$1(target) {
152321
152302
  if (target.kind === "text")
152322
152303
  return target;
152323
- const sd = target;
152324
152304
  return {
152325
152305
  kind: "text",
152326
- blockId: sd.nodeId ?? "",
152327
- range: sd.anchor ? {
152328
- start: sd.anchor.start.offset,
152329
- end: sd.anchor.end.offset
152330
- } : {
152306
+ blockId: target.nodeId,
152307
+ range: {
152331
152308
  start: 0,
152332
152309
  end: 0
152333
152310
  }
@@ -152668,6 +152645,8 @@ function buildSelectionResolutionFromOutcome(stepOutcome, compiled, stepId) {
152668
152645
  return buildSelectionResolutionFromCompiled(compiled, stepId);
152669
152646
  }
152670
152647
  function insertStructuredWrapper(editor, input2, options) {
152648
+ if (isStructuralInsertInput2(input2) && input2.target)
152649
+ return executeStructuralInsertDirect(editor, input2, options);
152671
152650
  return textReceiptToSDReceipt2(insertStructuredInner(editor, input2, options));
152672
152651
  }
152673
152652
  function insertStructuredInner(editor, input2, options) {
@@ -152856,14 +152835,13 @@ function insertStructuredInner(editor, input2, options) {
152856
152835
  function executeStructuralInsertWrapper(editor, input2, options) {
152857
152836
  const { content: content3, target, placement: placement2, nestingPolicy } = input2;
152858
152837
  const mode = options?.changeMode ?? "direct";
152859
- const textTarget = target ? narrowToTextAddress(target) : undefined;
152860
152838
  let resolved;
152861
152839
  try {
152862
- resolved = resolveInsertTarget(editor, textTarget);
152840
+ resolved = resolveInsertTarget(editor, target);
152863
152841
  } catch (err) {
152864
152842
  if (err instanceof DocumentApiAdapterError)
152865
152843
  throw err;
152866
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve insert target${textTarget ? ` for block "${textTarget.blockId}"` : ""}.`);
152844
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve insert target${target ? ` for block "${target.nodeId}"` : ""}.`);
152867
152845
  }
152868
152846
  const effectiveTarget = resolved.effectiveTarget ?? {
152869
152847
  kind: "text",
@@ -152879,7 +152857,6 @@ function executeStructuralInsertWrapper(editor, input2, options) {
152879
152857
  else
152880
152858
  insertPos = resolved.insertPos;
152881
152859
  const resolution = buildTextMutationResolution({
152882
- requestedTarget: textTarget,
152883
152860
  target: effectiveTarget,
152884
152861
  range: {
152885
152862
  from: insertPos,
@@ -152890,7 +152867,7 @@ function executeStructuralInsertWrapper(editor, input2, options) {
152890
152867
  try {
152891
152868
  if (options?.dryRun) {
152892
152869
  executeStructuralInsert(editor, {
152893
- target: textTarget,
152870
+ target,
152894
152871
  content: content3,
152895
152872
  placement: placement2,
152896
152873
  nestingPolicy,
@@ -152904,7 +152881,7 @@ function executeStructuralInsertWrapper(editor, input2, options) {
152904
152881
  }
152905
152882
  if (!(executeDomainCommand(editor, () => {
152906
152883
  return executeStructuralInsert(editor, {
152907
- target: textTarget,
152884
+ target,
152908
152885
  content: content3,
152909
152886
  placement: placement2,
152910
152887
  nestingPolicy,
@@ -152939,10 +152916,78 @@ function executeStructuralInsertWrapper(editor, input2, options) {
152939
152916
  };
152940
152917
  }
152941
152918
  }
152919
+ function executeStructuralInsertDirect(editor, input2, options) {
152920
+ const { content: content3, target, placement: placement2, nestingPolicy } = input2;
152921
+ const mode = options?.changeMode ?? "direct";
152922
+ let resolved;
152923
+ try {
152924
+ resolved = resolveInsertTarget(editor, target);
152925
+ } catch (err) {
152926
+ if (err instanceof DocumentApiAdapterError)
152927
+ throw err;
152928
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve insert target for block "${target.nodeId}".`);
152929
+ }
152930
+ let insertPos;
152931
+ if (resolved.targetNode && resolved.targetNodePos !== undefined)
152932
+ insertPos = resolvePlacement(editor.state.doc, resolved.targetNodePos, resolved.targetNode, placement2);
152933
+ else
152934
+ insertPos = resolved.insertPos;
152935
+ const receiptParams = {
152936
+ target,
152937
+ range: {
152938
+ from: insertPos,
152939
+ to: insertPos
152940
+ }
152941
+ };
152942
+ try {
152943
+ if (options?.dryRun) {
152944
+ executeStructuralInsert(editor, {
152945
+ target,
152946
+ content: content3,
152947
+ placement: placement2,
152948
+ nestingPolicy,
152949
+ changeMode: mode,
152950
+ dryRun: true
152951
+ });
152952
+ return buildStructuralReceipt2(true, receiptParams);
152953
+ }
152954
+ if (executeDomainCommand(editor, () => {
152955
+ return executeStructuralInsert(editor, {
152956
+ target,
152957
+ content: content3,
152958
+ placement: placement2,
152959
+ nestingPolicy,
152960
+ changeMode: mode
152961
+ }).success;
152962
+ }, {
152963
+ expectedRevision: options?.expectedRevision,
152964
+ changeMode: mode
152965
+ }).steps[0]?.effect !== "changed")
152966
+ return buildStructuralReceipt2(false, receiptParams, {
152967
+ code: "INVALID_TARGET",
152968
+ message: "Structural insert failed."
152969
+ });
152970
+ return buildStructuralReceipt2(true, receiptParams);
152971
+ } catch (err) {
152972
+ if (err instanceof DocumentApiAdapterError)
152973
+ throw err;
152974
+ return buildStructuralReceipt2(false, receiptParams, {
152975
+ code: "INVALID_TARGET",
152976
+ message: `Structural insert failed: ${err instanceof Error ? err.message : String(err)}`
152977
+ });
152978
+ }
152979
+ }
152942
152980
  function replaceStructuredWrapper(editor, input2, options) {
152943
152981
  if (!isStructuralReplaceInput2(input2))
152944
152982
  throw new DocumentApiAdapterError("INVALID_INPUT", 'replaceStructured requires structural content input with a "content" field.');
152945
- return textReceiptToSDReceipt2(executeStructuralReplaceWrapper(editor, input2, options));
152983
+ const blockTarget = input2.target && "kind" in input2.target && input2.target.kind === "block" ? input2.target : undefined;
152984
+ const textReceipt = executeStructuralReplaceWrapper(editor, input2, options);
152985
+ if (!blockTarget)
152986
+ return textReceiptToSDReceipt2(textReceipt);
152987
+ const sdReceipt = textReceiptToSDReceipt2(textReceipt);
152988
+ if (sdReceipt.resolution)
152989
+ sdReceipt.resolution.target = blockTarget;
152990
+ return sdReceipt;
152946
152991
  }
152947
152992
  function resolveStructuralLocator(editor, input2) {
152948
152993
  const { target, ref: ref$1 } = input2;
@@ -152971,7 +153016,7 @@ function resolveStructuralLocator(editor, input2) {
152971
153016
  effectiveSelectionTarget: buildEffectiveSelectionTarget(expanded)
152972
153017
  };
152973
153018
  }
152974
- return { textTarget: narrowToTextAddress(target) };
153019
+ return { textTarget: target };
152975
153020
  }
152976
153021
  if (ref$1 !== undefined) {
152977
153022
  if (ref$1.startsWith("text:"))
@@ -153141,7 +153186,7 @@ function executeStructuralReplaceWrapper(editor, input2, options) {
153141
153186
  } catch (err) {
153142
153187
  if (err instanceof DocumentApiAdapterError)
153143
153188
  throw err;
153144
- throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${textTarget.blockId}".`);
153189
+ throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${targetBlockId$1(textTarget)}".`);
153145
153190
  }
153146
153191
  effectiveRange = {
153147
153192
  from: resolvedBlock.from,
@@ -153150,13 +153195,13 @@ function executeStructuralReplaceWrapper(editor, input2, options) {
153150
153195
  }
153151
153196
  const coveredText = editor.state.doc.textBetween(effectiveRange.from, effectiveRange.to, `
153152
153197
  `, "");
153198
+ const textAddr = toTextAddress$1(textTarget);
153153
153199
  let resolution;
153154
153200
  if (effectiveSelectionTarget)
153155
153201
  resolution = selectionTargetToResolution(effectiveSelectionTarget, effectiveRange, coveredText);
153156
153202
  else
153157
153203
  resolution = buildTextMutationResolution({
153158
- requestedTarget: isRefBased ? undefined : textTarget,
153159
- target: textTarget,
153204
+ target: textAddr,
153160
153205
  range: effectiveRange,
153161
153206
  text: coveredText
153162
153207
  });
@@ -221875,9 +221920,9 @@ var Node$13 = class Node$14 {
221875
221920
  return false;
221876
221921
  return Boolean(checker(attrs));
221877
221922
  }, SuperToolbar, ICONS, TEXTS, tableActionsOptions;
221878
- var init_src_DLZxEXCY_es = __esm(() => {
221923
+ var init_src_D_53T9_x_es = __esm(() => {
221879
221924
  init_rolldown_runtime_B2q5OVn9_es();
221880
- init_SuperConverter_BParsWaS_es();
221925
+ init_SuperConverter_voJQZ_PC_es();
221881
221926
  init_jszip_ChlR43oI_es();
221882
221927
  init_uuid_qzgm05fK_es();
221883
221928
  init_constants_CMPtQbp7_es();
@@ -255725,8 +255770,8 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
255725
255770
 
255726
255771
  // ../../packages/superdoc/dist/super-editor.es.js
255727
255772
  var init_super_editor_es = __esm(() => {
255728
- init_src_DLZxEXCY_es();
255729
- init_SuperConverter_BParsWaS_es();
255773
+ init_src_D_53T9_x_es();
255774
+ init_SuperConverter_voJQZ_PC_es();
255730
255775
  init_jszip_ChlR43oI_es();
255731
255776
  init_xml_js_DLE8mr0n_es();
255732
255777
  init_constants_CMPtQbp7_es();
@@ -257196,11 +257241,6 @@ function assertUnambiguous2(matches2, blockId) {
257196
257241
  });
257197
257242
  }
257198
257243
  }
257199
- function findInlineWithinTextBlock2(index2, blockId) {
257200
- const matches2 = findTextBlockCandidates2(index2, blockId);
257201
- assertUnambiguous2(matches2, blockId);
257202
- return matches2[0];
257203
- }
257204
257244
  function resolveTextTarget2(editor, target) {
257205
257245
  const index2 = getBlockIndex2(editor);
257206
257246
  const matches2 = findTextBlockCandidates2(index2, target.blockId);
@@ -257367,32 +257407,17 @@ function dedupeDiagnostics2(diagnostics) {
257367
257407
  function resolveWithinScope2(index2, query2, diagnostics) {
257368
257408
  if (!query2.within)
257369
257409
  return { ok: true, range: undefined };
257370
- if (query2.within.kind === "block") {
257371
- const within2 = findBlockById2(index2, query2.within);
257372
- if (!within2) {
257373
- addDiagnostic3(diagnostics, `Within block "${query2.within.nodeType}" with id "${query2.within.nodeId}" was not found in the document.`);
257374
- return { ok: false };
257375
- }
257376
- return { ok: true, range: { start: within2.pos, end: within2.end } };
257377
- }
257378
- if (query2.within.anchor.start.blockId !== query2.within.anchor.end.blockId) {
257379
- addDiagnostic3(diagnostics, "Inline within anchors that span multiple blocks are not supported.");
257380
- return { ok: false };
257381
- }
257382
- const block = findInlineWithinTextBlock2(index2, query2.within.anchor.start.blockId);
257383
- if (!block) {
257384
- addDiagnostic3(diagnostics, `Within inline anchor block "${query2.within.anchor.start.blockId}" was not found in the document.`);
257385
- return { ok: false };
257410
+ let within2 = findBlockById2(index2, query2.within);
257411
+ if (!within2 && query2.within.kind === "block") {
257412
+ try {
257413
+ within2 = findBlockByNodeIdOnly2(index2, query2.within.nodeId);
257414
+ } catch {}
257386
257415
  }
257387
- const resolved = resolveTextRangeInBlock2(block.node, block.pos, {
257388
- start: query2.within.anchor.start.offset,
257389
- end: query2.within.anchor.end.offset
257390
- });
257391
- if (!resolved) {
257392
- addDiagnostic3(diagnostics, "Inline within anchor offsets could not be resolved in the target block.");
257416
+ if (!within2) {
257417
+ addDiagnostic3(diagnostics, `Within block "${query2.within.nodeType}" with id "${query2.within.nodeId}" was not found in the document.`);
257393
257418
  return { ok: false };
257394
257419
  }
257395
- return { ok: true, range: { start: resolved.from, end: resolved.to } };
257420
+ return { ok: true, range: { start: within2.pos, end: within2.end } };
257396
257421
  }
257397
257422
  function scopeByRange2(candidates, range) {
257398
257423
  if (!range)
@@ -266654,62 +266679,38 @@ function translateToInternalQuery2(input2) {
266654
266679
  const { select: select2, within: within2, limit, offset: offset2 } = input2;
266655
266680
  if (within2)
266656
266681
  validateWithinAddress2(within2);
266657
- if (select2.type === "text") {
266658
- return {
266659
- select: {
266660
- type: "text",
266661
- pattern: select2.pattern,
266662
- ...select2.mode != null && { mode: select2.mode },
266663
- ...select2.caseSensitive != null && { caseSensitive: select2.caseSensitive }
266664
- },
266665
- limit,
266666
- offset: offset2,
266667
- includeNodes: true
266668
- };
266682
+ if (select2.type === "node") {
266683
+ const raw = select2;
266684
+ if ("nodeKind" in raw && raw.nodeKind != null) {
266685
+ throw new DocumentApiAdapterError3("INVALID_INPUT", `"nodeKind" is no longer supported on node selectors. Use "nodeType" instead: ` + `{ type: 'node', nodeType: '${String(raw.nodeKind)}' }.`, { field: "select.nodeKind", value: raw.nodeKind });
266686
+ }
266687
+ if (raw.kind === "content") {
266688
+ throw new DocumentApiAdapterError3("INVALID_INPUT", `kind: 'content' is no longer supported on node selectors. Use kind: 'block' instead.`, { field: "select.kind", value: raw.kind });
266689
+ }
266669
266690
  }
266670
- const nodeSelect = {
266671
- type: "node",
266672
- ...select2.nodeKind != null && { nodeType: select2.nodeKind },
266673
- ...select2.kind === "content" && { kind: "block" },
266674
- ...select2.kind === "inline" && { kind: "inline" }
266675
- };
266676
266691
  return {
266677
- select: nodeSelect,
266692
+ select: select2,
266678
266693
  limit,
266679
266694
  offset: offset2,
266680
266695
  includeNodes: true
266681
266696
  };
266682
266697
  }
266683
- function validateWithinAddress2(sdAddress) {
266684
- if (sdAddress.kind === "content" && sdAddress.nodeId) {
266685
- return { nodeId: sdAddress.nodeId };
266698
+ function validateWithinAddress2(address2) {
266699
+ if (address2.kind === "block" && "nodeId" in address2 && typeof address2.nodeId === "string") {
266700
+ return { nodeId: address2.nodeId, nodeType: address2.nodeType };
266686
266701
  }
266687
- throw new DocumentApiAdapterError3("INVALID_TARGET", `"within" scope requires a content-kind SDAddress with a nodeId. Got kind="${sdAddress.kind}".`, { field: "within", value: sdAddress });
266688
- }
266689
- function resolveWithinNodeType2(index2, nodeId) {
266690
- const match2 = findBlockByNodeIdOnly2(index2, nodeId);
266691
- return {
266692
- kind: "block",
266693
- nodeType: match2.nodeType,
266694
- nodeId: match2.nodeId
266695
- };
266702
+ throw new DocumentApiAdapterError3("INVALID_TARGET", '"within" scope requires a BlockNodeAddress with a nodeId.', {
266703
+ field: "within",
266704
+ value: address2
266705
+ });
266696
266706
  }
266697
- function toSDAddress2(address2) {
266698
- if (address2.kind === "block") {
266699
- return {
266700
- kind: "content",
266701
- stability: "stable",
266702
- nodeId: address2.nodeId
266703
- };
266707
+ function resolveWithinAddress2(index2, nodeId, expectedNodeType) {
266708
+ if (expectedNodeType) {
266709
+ const match3 = findBlockByIdStrict2(index2, { kind: "block", nodeType: expectedNodeType, nodeId });
266710
+ return { kind: "block", nodeType: match3.nodeType, nodeId: match3.nodeId };
266704
266711
  }
266705
- return {
266706
- kind: "inline",
266707
- stability: "ephemeral",
266708
- anchor: {
266709
- start: { blockId: address2.anchor.start.blockId, offset: address2.anchor.start.offset },
266710
- end: { blockId: address2.anchor.end.blockId, offset: address2.anchor.end.offset }
266711
- }
266712
- };
266712
+ const match2 = findBlockByNodeIdOnly2(index2, nodeId);
266713
+ return { kind: "block", nodeType: match2.nodeType, nodeId: match2.nodeId };
266713
266714
  }
266714
266715
  function projectMatchToSDNodeResult2(editor, address2, blockIndex) {
266715
266716
  if (address2.kind === "block") {
@@ -266720,12 +266721,12 @@ function projectMatchToSDNodeResult2(editor, address2, blockIndex) {
266720
266721
  return null;
266721
266722
  return {
266722
266723
  node: projectContentNode2(found3.node),
266723
- address: toSDAddress2(address2)
266724
+ address: address2
266724
266725
  };
266725
266726
  }
266726
266727
  return {
266727
266728
  node: projectContentNode2(candidate.node),
266728
- address: toSDAddress2(address2)
266729
+ address: address2
266729
266730
  };
266730
266731
  }
266731
266732
  const inlineIndex = getInlineIndex2(editor);
@@ -266734,26 +266735,26 @@ function projectMatchToSDNodeResult2(editor, address2, blockIndex) {
266734
266735
  if (inlineCandidate.node) {
266735
266736
  return {
266736
266737
  node: projectInlineNode2(inlineCandidate.node),
266737
- address: toSDAddress2(address2)
266738
+ address: address2
266738
266739
  };
266739
266740
  }
266740
266741
  const markProjected = projectMarkBasedInline2(editor, inlineCandidate);
266741
266742
  if (markProjected) {
266742
- return { node: markProjected, address: toSDAddress2(address2) };
266743
+ return { node: markProjected, address: address2 };
266743
266744
  }
266744
266745
  }
266745
266746
  const resolvedText = resolveTextByBlockId2(editor, address2.anchor);
266746
266747
  return {
266747
266748
  node: { kind: "run", run: { text: resolvedText } },
266748
- address: toSDAddress2(address2)
266749
+ address: address2
266749
266750
  };
266750
266751
  }
266751
266752
  function sdFindAdapter2(editor, input2) {
266752
266753
  const query2 = translateToInternalQuery2(input2);
266753
266754
  const index2 = getBlockIndex2(editor);
266754
266755
  if (input2.within) {
266755
- const { nodeId } = validateWithinAddress2(input2.within);
266756
- query2.within = resolveWithinNodeType2(index2, nodeId);
266756
+ const { nodeId, nodeType } = validateWithinAddress2(input2.within);
266757
+ query2.within = resolveWithinAddress2(index2, nodeId, nodeType);
266757
266758
  }
266758
266759
  const diagnostics = [];
266759
266760
  const isInlineSelector = query2.select.type !== "text" && isInlineQuery2(query2.select);
@@ -266797,37 +266798,28 @@ function findBlocksByTypeAndId2(blockIndex, nodeType, nodeId) {
266797
266798
  return [byIdMatch];
266798
266799
  return blockIndex.candidates.filter((candidate) => candidate.nodeType === nodeType && candidate.nodeId === nodeId);
266799
266800
  }
266800
- function buildBlockAddress2(nodeId) {
266801
- return {
266802
- kind: "content",
266803
- stability: "stable",
266804
- nodeId
266805
- };
266806
- }
266807
266801
  function buildInlineAddress2(address2) {
266808
- return {
266809
- kind: "inline",
266810
- stability: "ephemeral",
266811
- anchor: {
266812
- start: { blockId: address2.anchor.start.blockId, offset: address2.anchor.start.offset },
266813
- end: { blockId: address2.anchor.end.blockId, offset: address2.anchor.end.offset }
266814
- }
266815
- };
266802
+ return address2;
266816
266803
  }
266817
266804
  function getNodeAdapter2(editor, address2) {
266818
266805
  const blockIndex = getBlockIndex2(editor);
266819
266806
  if (address2.kind === "block") {
266820
266807
  const matches3 = findBlocksByTypeAndId2(blockIndex, address2.nodeType, address2.nodeId);
266821
- if (matches3.length === 0) {
266822
- throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Node "${address2.nodeType}" not found for id "${address2.nodeId}".`);
266823
- }
266824
266808
  if (matches3.length > 1) {
266825
266809
  throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Multiple nodes share ${address2.nodeType} id "${address2.nodeId}".`);
266826
266810
  }
266827
- const candidate2 = matches3[0];
266811
+ let candidate2 = matches3[0];
266812
+ if (!candidate2) {
266813
+ try {
266814
+ candidate2 = findBlockByNodeIdOnly2(blockIndex, address2.nodeId);
266815
+ } catch {}
266816
+ }
266817
+ if (!candidate2) {
266818
+ throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Node "${address2.nodeType}" not found for id "${address2.nodeId}".`);
266819
+ }
266828
266820
  return {
266829
266821
  node: projectContentNode2(candidate2.node),
266830
- address: buildBlockAddress2(address2.nodeId)
266822
+ address: { kind: "block", nodeType: candidate2.nodeType, nodeId: candidate2.nodeId }
266831
266823
  };
266832
266824
  }
266833
266825
  const inlineIndex = getInlineIndex2(editor);
@@ -266875,13 +266867,14 @@ function resolveBlockById2(editor, nodeId, nodeType) {
266875
266867
  }
266876
266868
  function getNodeByIdAdapter2(editor, input2) {
266877
266869
  const { nodeId, nodeType } = input2;
266878
- const { candidate } = resolveBlockById2(editor, nodeId, nodeType);
266870
+ const { candidate, resolvedType } = resolveBlockById2(editor, nodeId, nodeType);
266879
266871
  return {
266880
266872
  node: projectContentNode2(candidate.node),
266881
- address: buildBlockAddress2(nodeId)
266873
+ address: { kind: "block", nodeType: resolvedType, nodeId: candidate.nodeId }
266882
266874
  };
266883
266875
  }
266884
266876
  var init_get_node_adapter = __esm(() => {
266877
+ init_node_address_resolver();
266885
266878
  init_index_cache();
266886
266879
  init_inline_address_resolver();
266887
266880
  init_sd_projection();
@@ -327933,37 +327926,41 @@ var init_node_materializer = __esm(() => {
327933
327926
  });
327934
327927
 
327935
327928
  // ../../packages/super-editor/src/document-api-adapters/structural-write-engine/target-resolver.ts
327929
+ function findBlockByTarget2(index3, target, operationName) {
327930
+ const nodeId = target.kind === "block" ? target.nodeId : target.blockId;
327931
+ try {
327932
+ if (target.kind === "block") {
327933
+ const typed = findBlockById2(index3, target);
327934
+ if (typed)
327935
+ return typed;
327936
+ return findBlockByNodeIdOnly2(index3, nodeId);
327937
+ }
327938
+ return findBlockByNodeIdOnly2(index3, nodeId);
327939
+ } catch {
327940
+ throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve ${operationName} target for block "${nodeId}".`);
327941
+ }
327942
+ }
327936
327943
  function resolveInsertTarget2(editor, target) {
327937
327944
  if (!target) {
327938
327945
  return resolveDocumentEndTarget2(editor);
327939
327946
  }
327940
327947
  const index3 = getBlockIndex2(editor);
327941
- let candidate;
327942
- try {
327943
- candidate = findBlockByNodeIdOnly2(index3, target.blockId);
327944
- } catch {
327945
- throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve insert target for block "${target.blockId}".`);
327946
- }
327948
+ const candidate = findBlockByTarget2(index3, target, "insert");
327947
327949
  return {
327948
327950
  insertPos: candidate.end,
327949
327951
  structuralEnd: false,
327950
- effectiveTarget: target,
327952
+ effectiveTarget: target.kind === "block" ? { kind: "text", blockId: target.nodeId, range: { start: 0, end: 0 } } : target,
327951
327953
  targetNode: candidate.node,
327952
327954
  targetNodePos: candidate.pos
327953
327955
  };
327954
327956
  }
327955
327957
  function resolveReplaceTarget2(editor, target) {
327956
327958
  const index3 = getBlockIndex2(editor);
327957
- let candidate;
327958
- try {
327959
- candidate = findBlockByNodeIdOnly2(index3, target.blockId);
327960
- } catch {
327961
- throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${target.blockId}".`);
327962
- }
327959
+ const candidate = findBlockByTarget2(index3, target, "replace");
327963
327960
  return {
327964
327961
  from: candidate.pos,
327965
327962
  to: candidate.end,
327966
- effectiveTarget: target
327963
+ effectiveTarget: target.kind === "block" ? { kind: "text", blockId: target.nodeId, range: { start: 0, end: 0 } } : target
327967
327964
  };
327968
327965
  }
327969
327966
  function resolveDocumentEndTarget2(editor) {
@@ -328261,15 +328258,13 @@ function ensureTableSeparators2(jsonNodes) {
328261
328258
  }
328262
328259
  }
328263
328260
  }
328264
- function narrowToTextAddress2(target) {
328261
+ function targetBlockId2(target) {
328262
+ return target.kind === "block" ? target.nodeId : target.blockId;
328263
+ }
328264
+ function toTextAddress3(target) {
328265
328265
  if (target.kind === "text")
328266
328266
  return target;
328267
- const sd = target;
328268
- return {
328269
- kind: "text",
328270
- blockId: sd.nodeId ?? "",
328271
- range: sd.anchor ? { start: sd.anchor.start.offset, end: sd.anchor.end.offset } : { start: 0, end: 0 }
328272
- };
328267
+ return { kind: "text", blockId: target.nodeId, range: { start: 0, end: 0 } };
328273
328268
  }
328274
328269
  function normalizeWriteLocator2(request) {
328275
328270
  const hasBlockId = request.blockId !== undefined;
@@ -328560,6 +328555,9 @@ function buildSelectionResolutionFromOutcome2(stepOutcome, compiled, stepId) {
328560
328555
  return buildSelectionResolutionFromCompiled2(compiled, stepId);
328561
328556
  }
328562
328557
  function insertStructuredWrapper2(editor, input2, options) {
328558
+ if (isStructuralInsertInput(input2) && input2.target) {
328559
+ return executeStructuralInsertDirect2(editor, input2, options);
328560
+ }
328563
328561
  return textReceiptToSDReceipt(insertStructuredInner2(editor, input2, options));
328564
328562
  }
328565
328563
  function insertStructuredInner2(editor, input2, options) {
@@ -328730,14 +328728,13 @@ function insertStructuredInner2(editor, input2, options) {
328730
328728
  function executeStructuralInsertWrapper2(editor, input2, options) {
328731
328729
  const { content: content5, target, placement: placement2, nestingPolicy } = input2;
328732
328730
  const mode = options?.changeMode ?? "direct";
328733
- const textTarget = target ? narrowToTextAddress2(target) : undefined;
328734
328731
  let resolved;
328735
328732
  try {
328736
- resolved = resolveInsertTarget2(editor, textTarget);
328733
+ resolved = resolveInsertTarget2(editor, target);
328737
328734
  } catch (err) {
328738
328735
  if (err instanceof DocumentApiAdapterError3)
328739
328736
  throw err;
328740
- throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve insert target${textTarget ? ` for block "${textTarget.blockId}"` : ""}.`);
328737
+ throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve insert target${target ? ` for block "${target.nodeId}"` : ""}.`);
328741
328738
  }
328742
328739
  const effectiveTarget = resolved.effectiveTarget ?? {
328743
328740
  kind: "text",
@@ -328752,7 +328749,6 @@ function executeStructuralInsertWrapper2(editor, input2, options) {
328752
328749
  }
328753
328750
  const resolvedRange = { from: insertPos, to: insertPos };
328754
328751
  const resolution = buildTextMutationResolution2({
328755
- requestedTarget: textTarget,
328756
328752
  target: effectiveTarget,
328757
328753
  range: resolvedRange,
328758
328754
  text: ""
@@ -328760,7 +328756,7 @@ function executeStructuralInsertWrapper2(editor, input2, options) {
328760
328756
  try {
328761
328757
  if (options?.dryRun) {
328762
328758
  executeStructuralInsert2(editor, {
328763
- target: textTarget,
328759
+ target,
328764
328760
  content: content5,
328765
328761
  placement: placement2,
328766
328762
  nestingPolicy,
@@ -328771,7 +328767,7 @@ function executeStructuralInsertWrapper2(editor, input2, options) {
328771
328767
  }
328772
328768
  const receipt2 = executeDomainCommand2(editor, () => {
328773
328769
  const result = executeStructuralInsert2(editor, {
328774
- target: textTarget,
328770
+ target,
328775
328771
  content: content5,
328776
328772
  placement: placement2,
328777
328773
  nestingPolicy,
@@ -328799,11 +328795,77 @@ function executeStructuralInsertWrapper2(editor, input2, options) {
328799
328795
  };
328800
328796
  }
328801
328797
  }
328798
+ function executeStructuralInsertDirect2(editor, input2, options) {
328799
+ const { content: content5, target, placement: placement2, nestingPolicy } = input2;
328800
+ const mode = options?.changeMode ?? "direct";
328801
+ let resolved;
328802
+ try {
328803
+ resolved = resolveInsertTarget2(editor, target);
328804
+ } catch (err) {
328805
+ if (err instanceof DocumentApiAdapterError3)
328806
+ throw err;
328807
+ throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve insert target for block "${target.nodeId}".`);
328808
+ }
328809
+ let insertPos;
328810
+ if (resolved.targetNode && resolved.targetNodePos !== undefined) {
328811
+ insertPos = resolvePlacement2(editor.state.doc, resolved.targetNodePos, resolved.targetNode, placement2);
328812
+ } else {
328813
+ insertPos = resolved.insertPos;
328814
+ }
328815
+ const range = { from: insertPos, to: insertPos };
328816
+ const receiptParams = { target, range };
328817
+ try {
328818
+ if (options?.dryRun) {
328819
+ executeStructuralInsert2(editor, {
328820
+ target,
328821
+ content: content5,
328822
+ placement: placement2,
328823
+ nestingPolicy,
328824
+ changeMode: mode,
328825
+ dryRun: true
328826
+ });
328827
+ return buildStructuralReceipt(true, receiptParams);
328828
+ }
328829
+ const receipt2 = executeDomainCommand2(editor, () => {
328830
+ const result = executeStructuralInsert2(editor, {
328831
+ target,
328832
+ content: content5,
328833
+ placement: placement2,
328834
+ nestingPolicy,
328835
+ changeMode: mode
328836
+ });
328837
+ return result.success;
328838
+ }, { expectedRevision: options?.expectedRevision, changeMode: mode });
328839
+ if (receipt2.steps[0]?.effect !== "changed") {
328840
+ return buildStructuralReceipt(false, receiptParams, {
328841
+ code: "INVALID_TARGET",
328842
+ message: "Structural insert failed."
328843
+ });
328844
+ }
328845
+ return buildStructuralReceipt(true, receiptParams);
328846
+ } catch (err) {
328847
+ if (err instanceof DocumentApiAdapterError3)
328848
+ throw err;
328849
+ const message = err instanceof Error ? err.message : String(err);
328850
+ return buildStructuralReceipt(false, receiptParams, {
328851
+ code: "INVALID_TARGET",
328852
+ message: `Structural insert failed: ${message}`
328853
+ });
328854
+ }
328855
+ }
328802
328856
  function replaceStructuredWrapper2(editor, input2, options) {
328803
328857
  if (!isStructuralReplaceInput(input2)) {
328804
328858
  throw new DocumentApiAdapterError3("INVALID_INPUT", 'replaceStructured requires structural content input with a "content" field.');
328805
328859
  }
328806
- return textReceiptToSDReceipt(executeStructuralReplaceWrapper2(editor, input2, options));
328860
+ const blockTarget = input2.target && "kind" in input2.target && input2.target.kind === "block" ? input2.target : undefined;
328861
+ const textReceipt = executeStructuralReplaceWrapper2(editor, input2, options);
328862
+ if (!blockTarget)
328863
+ return textReceiptToSDReceipt(textReceipt);
328864
+ const sdReceipt = textReceiptToSDReceipt(textReceipt);
328865
+ if (sdReceipt.resolution) {
328866
+ sdReceipt.resolution.target = blockTarget;
328867
+ }
328868
+ return sdReceipt;
328807
328869
  }
328808
328870
  function resolveStructuralLocator2(editor, input2) {
328809
328871
  const { target, ref: ref4 } = input2;
@@ -328827,7 +328889,7 @@ function resolveStructuralLocator2(editor, input2) {
328827
328889
  effectiveSelectionTarget: buildEffectiveSelectionTarget2(expanded)
328828
328890
  };
328829
328891
  }
328830
- return { textTarget: narrowToTextAddress2(target) };
328892
+ return { textTarget: target };
328831
328893
  }
328832
328894
  if (ref4 !== undefined) {
328833
328895
  if (ref4.startsWith("text:")) {
@@ -328976,19 +329038,19 @@ function executeStructuralReplaceWrapper2(editor, input2, options) {
328976
329038
  } catch (err) {
328977
329039
  if (err instanceof DocumentApiAdapterError3)
328978
329040
  throw err;
328979
- throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${textTarget.blockId}".`);
329041
+ throw new DocumentApiAdapterError3("TARGET_NOT_FOUND", `Cannot resolve replace target for block "${targetBlockId2(textTarget)}".`);
328980
329042
  }
328981
329043
  effectiveRange = { from: resolvedBlock.from, to: resolvedBlock.to };
328982
329044
  }
328983
329045
  const coveredText = editor.state.doc.textBetween(effectiveRange.from, effectiveRange.to, `
328984
329046
  `, "");
329047
+ const textAddr = toTextAddress3(textTarget);
328985
329048
  let resolution;
328986
329049
  if (effectiveSelectionTarget) {
328987
329050
  resolution = selectionTargetToResolution2(effectiveSelectionTarget, effectiveRange, coveredText);
328988
329051
  } else {
328989
329052
  resolution = buildTextMutationResolution2({
328990
- requestedTarget: isRefBased ? undefined : textTarget,
328991
- target: textTarget,
329053
+ target: textAddr,
328992
329054
  range: effectiveRange,
328993
329055
  text: coveredText
328994
329056
  });
@@ -329230,7 +329292,7 @@ function resolveImportedId2(candidate) {
329230
329292
  const attrs = candidate.attrs ?? {};
329231
329293
  return toNonEmptyString2(attrs.importedId);
329232
329294
  }
329233
- function toTextAddress3(candidate) {
329295
+ function toTextAddress4(candidate) {
329234
329296
  const { start: start2, end } = candidate.anchor;
329235
329297
  if (start2.blockId !== end.blockId)
329236
329298
  return null;
@@ -329252,7 +329314,7 @@ function listCommentAnchors2(editor) {
329252
329314
  const commentId = resolveCommentId2(candidate);
329253
329315
  if (!commentId)
329254
329316
  continue;
329255
- const target = toTextAddress3(candidate);
329317
+ const target = toTextAddress4(candidate);
329256
329318
  if (!target)
329257
329319
  continue;
329258
329320
  const dedupeKey = `${commentId}|${target.blockId}:${target.range.start}:${target.range.end}`;
@@ -337227,7 +337289,7 @@ var init_tables_adapter = __esm(() => {
337227
337289
  });
337228
337290
 
337229
337291
  // ../../packages/super-editor/src/document-api-adapters/plan-engine/register-executors.ts
337230
- function targetBlockId2(t) {
337292
+ function targetBlockId3(t) {
337231
337293
  return t?.kind === "range" ? t.blockId : "";
337232
337294
  }
337233
337295
  function selectionTargetToRange2(t) {
@@ -337408,7 +337470,7 @@ function registerBuiltInExecutors2() {
337408
337470
  op: step3.op,
337409
337471
  effect: "noop",
337410
337472
  matchCount: targets.length,
337411
- data: { domain: "table", tableId: targetBlockId2(targets[0]) }
337473
+ data: { domain: "table", tableId: targetBlockId3(targets[0]) }
337412
337474
  };
337413
337475
  }
337414
337476
  const handler3 = step3._handler;
@@ -337434,7 +337496,7 @@ function registerBuiltInExecutors2() {
337434
337496
  data: { domain: "table", tableId: "" }
337435
337497
  };
337436
337498
  }
337437
- const input2 = buildTableInput2(step3.op, targetBlockId2(targets[0]), step3.args);
337499
+ const input2 = buildTableInput2(step3.op, targetBlockId3(targets[0]), step3.args);
337438
337500
  const result = adapterFn(ctx2.editor, input2, { changeMode: ctx2.changeMode });
337439
337501
  if (result.success)
337440
337502
  ctx2.commandDispatched = true;
@@ -337443,7 +337505,7 @@ function registerBuiltInExecutors2() {
337443
337505
  op: step3.op,
337444
337506
  effect: result.success ? "changed" : "noop",
337445
337507
  matchCount: result.success ? 1 : 0,
337446
- data: { domain: "table", tableId: targetBlockId2(targets[0]) }
337508
+ data: { domain: "table", tableId: targetBlockId3(targets[0]) }
337447
337509
  };
337448
337510
  }
337449
337511
  });
@@ -337552,7 +337614,7 @@ function registerBuiltInExecutors2() {
337552
337614
  op: step3.op,
337553
337615
  effect: "noop",
337554
337616
  matchCount: _targets.length,
337555
- data: { domain: "table", tableId: targetBlockId2(_targets[0]) }
337617
+ data: { domain: "table", tableId: targetBlockId3(_targets[0]) }
337556
337618
  };
337557
337619
  }
337558
337620
  const handler3 = step3._handler;
@@ -401145,15 +401207,14 @@ function validateQuerySelect(value2, path3) {
401145
401207
  };
401146
401208
  }
401147
401209
  if (type2 === "node") {
401148
- expectOnlyKeys(obj, ["type", "nodeKind", "kind", "nodeType"], path3);
401149
- const rawNodeKind = obj.nodeKind ?? obj.nodeType;
401150
- const nodeKind = rawNodeKind != null ? String(rawNodeKind) : undefined;
401151
- if (obj.kind != null && obj.kind !== "content" && obj.kind !== "inline" && !NODE_KINDS2.has(obj.kind)) {
401152
- throw new CliError("VALIDATION_ERROR", `${path3}.kind must be "content", "inline", "block", or "inline".`);
401210
+ expectOnlyKeys(obj, ["type", "nodeType", "kind"], path3);
401211
+ const nodeType2 = obj.nodeType != null ? String(obj.nodeType) : undefined;
401212
+ if (obj.kind != null && !NODE_KINDS2.has(obj.kind)) {
401213
+ throw new CliError("VALIDATION_ERROR", `${path3}.kind must be "block" or "inline".`);
401153
401214
  }
401154
401215
  return {
401155
401216
  type: "node",
401156
- nodeKind,
401217
+ nodeType: nodeType2,
401157
401218
  kind: obj.kind
401158
401219
  };
401159
401220
  }
@@ -401163,7 +401224,7 @@ function validateQuerySelect(value2, path3) {
401163
401224
  expectOnlyKeys(obj, ["type"], path3);
401164
401225
  return {
401165
401226
  type: "node",
401166
- nodeKind: type2
401227
+ nodeType: type2
401167
401228
  };
401168
401229
  }
401169
401230
  function validateQuery(value2, path3 = "query") {
@@ -401173,12 +401234,11 @@ function validateQuery(value2, path3 = "query") {
401173
401234
  select: validateQuerySelect(obj.select, `${path3}.select`)
401174
401235
  };
401175
401236
  if (obj.within != null) {
401176
- const within2 = expectRecord(obj.within, `${path3}.within`);
401177
- if (within2.kind === "content" && typeof within2.nodeId === "string") {
401178
- query3.within = within2;
401179
- } else {
401180
- query3.within = validateNodeAddress(obj.within, `${path3}.within`);
401237
+ const within2 = validateNodeAddress(obj.within, `${path3}.within`);
401238
+ if (within2.kind !== "block") {
401239
+ throw new CliError("VALIDATION_ERROR", `${path3}.within must be a BlockNodeAddress (kind: "block").`);
401181
401240
  }
401241
+ query3.within = within2;
401182
401242
  }
401183
401243
  if (obj.limit != null) {
401184
401244
  query3.limit = expectNonNegativeInteger(obj.limit, `${path3}.limit`);
@@ -401226,7 +401286,7 @@ function buildFlatFindQueryDraft(parsed) {
401226
401286
  return {
401227
401287
  select: {
401228
401288
  type: "node",
401229
- nodeKind: getStringOption(parsed, "node-type"),
401289
+ nodeType: getStringOption(parsed, "node-type"),
401230
401290
  kind: getStringOption(parsed, "kind")
401231
401291
  },
401232
401292
  limit: getNumberOption(parsed, "limit"),
@@ -401236,7 +401296,7 @@ function buildFlatFindQueryDraft(parsed) {
401236
401296
  const kind2 = getStringOption(parsed, "kind");
401237
401297
  const select2 = kind2 ? {
401238
401298
  type: "node",
401239
- nodeKind: selectorType,
401299
+ nodeType: selectorType,
401240
401300
  kind: kind2
401241
401301
  } : {
401242
401302
  type: selectorType