@superdoc-dev/cli 0.4.0-next.1 → 0.4.0-next.10

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +505 -168
  3. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -25713,9 +25713,9 @@ var init_jszip_ChlR43oI_es = __esm(() => {
25713
25713
  });
25714
25714
  });
25715
25715
 
25716
- // ../../packages/superdoc/dist/chunks/xml-js-DLE8mr0n.es.js
25716
+ // ../../packages/superdoc/dist/chunks/xml-js-40FWvL78.es.js
25717
25717
  var require_events, require_inherits_browser, require_stream_browser, require_dist, require_shams$1, require_shams, require_es_object_atoms, require_es_errors, require_eval, require_range, require_ref, require_syntax, require_type, require_uri, require_abs, require_floor, require_max, require_min, require_pow, require_round, require_isNaN, require_sign, require_gOPD, require_gopd, require_es_define_property, require_has_symbols, require_Reflect_getPrototypeOf, require_Object_getPrototypeOf, require_implementation, require_function_bind, require_functionCall, require_functionApply, require_reflectApply, require_actualApply, require_call_bind_apply_helpers, require_get, require_get_proto, require_hasown, require_get_intrinsic, require_call_bound, require_is_arguments, require_is_regex, require_safe_regex_test, require_generator_function, require_is_generator_function, require_is_callable, require_for_each, require_possible_typed_array_names, require_available_typed_arrays, require_define_data_property, require_has_property_descriptors, require_set_function_length, require_applyBind, require_call_bind, require_which_typed_array, require_is_typed_array, require_types, require_isBufferBrowser, require_util, require_buffer_list, require_destroy, require_errors_browser, require_state, require_browser, require__stream_writable, require__stream_duplex, require_safe_buffer, require_string_decoder, require_end_of_stream, require_async_iterator, require_from_browser, require__stream_readable, require__stream_transform, require__stream_passthrough, require_pipeline, require_stream_browserify, require_sax, require_array_helper, require_options_helper, require_xml2js, require_xml2json, require_js2xml, require_json2xml, require_lib;
25718
- var init_xml_js_DLE8mr0n_es = __esm(() => {
25718
+ var init_xml_js_40FWvL78_es = __esm(() => {
25719
25719
  init_rolldown_runtime_B2q5OVn9_es();
25720
25720
  init_jszip_ChlR43oI_es();
25721
25721
  require_events = /* @__PURE__ */ __commonJSMin((exports, module) => {
@@ -32263,9 +32263,13 @@ var init_xml_js_DLE8mr0n_es = __esm(() => {
32263
32263
  clearBuffers(parser);
32264
32264
  parser.q = parser.c = "";
32265
32265
  parser.bufferCheckPosition = sax$1.MAX_BUFFER_LENGTH;
32266
+ parser.encoding = null;
32266
32267
  parser.opt = opt || {};
32267
32268
  parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags;
32268
32269
  parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase";
32270
+ parser.opt.maxEntityCount = parser.opt.maxEntityCount || 512;
32271
+ parser.opt.maxEntityDepth = parser.opt.maxEntityDepth || 4;
32272
+ parser.entityCount = parser.entityDepth = 0;
32269
32273
  parser.tags = [];
32270
32274
  parser.closed = parser.closedRoot = parser.sawRoot = false;
32271
32275
  parser.tag = parser.error = null;
@@ -32368,6 +32372,24 @@ var init_xml_js_DLE8mr0n_es = __esm(() => {
32368
32372
  function createStream(strict, opt) {
32369
32373
  return new SAXStream(strict, opt);
32370
32374
  }
32375
+ function determineBufferEncoding(data, isEnd) {
32376
+ if (data.length >= 2) {
32377
+ if (data[0] === 255 && data[1] === 254)
32378
+ return "utf-16le";
32379
+ if (data[0] === 254 && data[1] === 255)
32380
+ return "utf-16be";
32381
+ }
32382
+ if (data.length >= 3 && data[0] === 239 && data[1] === 187 && data[2] === 191)
32383
+ return "utf8";
32384
+ if (data.length >= 4) {
32385
+ if (data[0] === 60 && data[1] === 0 && data[2] === 63 && data[3] === 0)
32386
+ return "utf-16le";
32387
+ if (data[0] === 0 && data[1] === 60 && data[2] === 0 && data[3] === 63)
32388
+ return "utf-16be";
32389
+ return "utf8";
32390
+ }
32391
+ return isEnd ? "utf8" : null;
32392
+ }
32371
32393
  function SAXStream(strict, opt) {
32372
32394
  if (!(this instanceof SAXStream))
32373
32395
  return new SAXStream(strict, opt);
@@ -32384,6 +32406,7 @@ var init_xml_js_DLE8mr0n_es = __esm(() => {
32384
32406
  me._parser.error = null;
32385
32407
  };
32386
32408
  this._decoder = null;
32409
+ this._decoderBuffer = null;
32387
32410
  streamWraps.forEach(function(ev) {
32388
32411
  Object.defineProperty(me, "on" + ev, {
32389
32412
  get: function() {
@@ -32403,11 +32426,31 @@ var init_xml_js_DLE8mr0n_es = __esm(() => {
32403
32426
  });
32404
32427
  }
32405
32428
  SAXStream.prototype = Object.create(Stream$3.prototype, { constructor: { value: SAXStream } });
32429
+ SAXStream.prototype._decodeBuffer = function(data, isEnd) {
32430
+ if (this._decoderBuffer) {
32431
+ data = Buffer2.concat([this._decoderBuffer, data]);
32432
+ this._decoderBuffer = null;
32433
+ }
32434
+ if (!this._decoder) {
32435
+ var encoding = determineBufferEncoding(data, isEnd);
32436
+ if (!encoding) {
32437
+ this._decoderBuffer = data;
32438
+ return "";
32439
+ }
32440
+ this._parser.encoding = encoding;
32441
+ this._decoder = new TextDecoder(encoding);
32442
+ }
32443
+ return this._decoder.decode(data, { stream: !isEnd });
32444
+ };
32406
32445
  SAXStream.prototype.write = function(data) {
32407
- if (typeof Buffer2 === "function" && typeof Buffer2.isBuffer === "function" && Buffer2.isBuffer(data)) {
32408
- if (!this._decoder)
32409
- this._decoder = new TextDecoder("utf8");
32410
- data = this._decoder.decode(data, { stream: true });
32446
+ if (typeof Buffer2 === "function" && typeof Buffer2.isBuffer === "function" && Buffer2.isBuffer(data))
32447
+ data = this._decodeBuffer(data, false);
32448
+ else if (this._decoderBuffer) {
32449
+ var remaining = this._decodeBuffer(Buffer2.alloc(0), true);
32450
+ if (remaining) {
32451
+ this._parser.write(remaining);
32452
+ this.emit("data", remaining);
32453
+ }
32411
32454
  }
32412
32455
  this._parser.write(data.toString());
32413
32456
  this.emit("data", data);
@@ -32416,7 +32459,13 @@ var init_xml_js_DLE8mr0n_es = __esm(() => {
32416
32459
  SAXStream.prototype.end = function(chunk) {
32417
32460
  if (chunk && chunk.length)
32418
32461
  this.write(chunk);
32419
- if (this._decoder) {
32462
+ if (this._decoderBuffer) {
32463
+ var finalChunk = this._decodeBuffer(Buffer2.alloc(0), true);
32464
+ if (finalChunk) {
32465
+ this._parser.write(finalChunk);
32466
+ this.emit("data", finalChunk);
32467
+ }
32468
+ } else if (this._decoder) {
32420
32469
  var remaining = this._decoder.decode();
32421
32470
  if (remaining) {
32422
32471
  this._parser.write(remaining);
@@ -32776,6 +32825,31 @@ var init_xml_js_DLE8mr0n_es = __esm(() => {
32776
32825
  function emit(parser, event, data) {
32777
32826
  parser[event] && parser[event](data);
32778
32827
  }
32828
+ function getDeclaredEncoding(body) {
32829
+ var match = body && body.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);
32830
+ return match ? match[2] : null;
32831
+ }
32832
+ function normalizeEncodingName(encoding) {
32833
+ if (!encoding)
32834
+ return null;
32835
+ return encoding.toLowerCase().replace(/[^a-z0-9]/g, "");
32836
+ }
32837
+ function encodingsMatch(detectedEncoding, declaredEncoding) {
32838
+ const detected = normalizeEncodingName(detectedEncoding);
32839
+ const declared = normalizeEncodingName(declaredEncoding);
32840
+ if (!detected || !declared)
32841
+ return true;
32842
+ if (declared === "utf16")
32843
+ return detected === "utf16le" || detected === "utf16be";
32844
+ return detected === declared;
32845
+ }
32846
+ function validateXmlDeclarationEncoding(parser, data) {
32847
+ if (!parser.strict || !parser.encoding || !data || data.name !== "xml")
32848
+ return;
32849
+ var declaredEncoding = getDeclaredEncoding(data.body);
32850
+ if (declaredEncoding && !encodingsMatch(parser.encoding, declaredEncoding))
32851
+ strictFail(parser, "XML declaration encoding " + declaredEncoding + " does not match detected stream encoding " + parser.encoding.toUpperCase());
32852
+ }
32779
32853
  function emitNode(parser, nodeType, data) {
32780
32854
  if (parser.textNode)
32781
32855
  closeText(parser);
@@ -33314,10 +33388,12 @@ Actual: ` + parser.attribValue);
33314
33388
  continue;
33315
33389
  case S.PROC_INST_ENDING:
33316
33390
  if (c === ">") {
33317
- emitNode(parser, "onprocessinginstruction", {
33391
+ const procInstEndData = {
33318
33392
  name: parser.procInstName,
33319
33393
  body: parser.procInstBody
33320
- });
33394
+ };
33395
+ validateXmlDeclarationEncoding(parser, procInstEndData);
33396
+ emitNode(parser, "onprocessinginstruction", procInstEndData);
33321
33397
  parser.procInstName = parser.procInstBody = "";
33322
33398
  parser.state = S.TEXT;
33323
33399
  } else {
@@ -33514,9 +33590,14 @@ Actual: ` + parser.attribValue);
33514
33590
  if (c === ";") {
33515
33591
  var parsedEntity = parseEntity(parser);
33516
33592
  if (parser.opt.unparsedEntities && !Object.values(sax$1.XML_ENTITIES).includes(parsedEntity)) {
33593
+ if ((parser.entityCount += 1) > parser.opt.maxEntityCount)
33594
+ error(parser, "Parsed entity count exceeds max entity count");
33595
+ if ((parser.entityDepth += 1) > parser.opt.maxEntityDepth)
33596
+ error(parser, "Parsed entity depth exceeds max entity depth");
33517
33597
  parser.entity = "";
33518
33598
  parser.state = returnState;
33519
33599
  parser.write(parsedEntity);
33600
+ parser.entityDepth -= 1;
33520
33601
  } else {
33521
33602
  parser[buffer$2] += parsedEntity;
33522
33603
  parser.entity = "";
@@ -34459,7 +34540,7 @@ var init_uuid_qzgm05fK_es = __esm(() => {
34459
34540
  v5_default = v35("v5", 80, sha1);
34460
34541
  });
34461
34542
 
34462
- // ../../packages/superdoc/dist/chunks/constants-CMPtQbp7.es.js
34543
+ // ../../packages/superdoc/dist/chunks/constants-Qqwopz80.es.js
34463
34544
  function computeCrc32Hex(data) {
34464
34545
  let crc = 4294967295;
34465
34546
  for (let i2 = 0;i2 < data.length; i2++)
@@ -34851,8 +34932,8 @@ var import_lib, CRC32_TABLE, REMOTE_RESOURCE_PATTERN, DATA_URI_PATTERN, getArray
34851
34932
  return "webp";
34852
34933
  return null;
34853
34934
  }, COMMENT_FILE_BASENAMES, COMMENT_RELATIONSHIP_TYPES;
34854
- var init_constants_CMPtQbp7_es = __esm(() => {
34855
- init_xml_js_DLE8mr0n_es();
34935
+ var init_constants_Qqwopz80_es = __esm(() => {
34936
+ init_xml_js_40FWvL78_es();
34856
34937
  import_lib = require_lib();
34857
34938
  CRC32_TABLE = new Uint32Array(256);
34858
34939
  for (let i2 = 0;i2 < 256; i2++) {
@@ -41059,7 +41140,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
41059
41140
  emptyOptions2 = {};
41060
41141
  });
41061
41142
 
41062
- // ../../packages/superdoc/dist/chunks/SuperConverter-V-8WDjnK.es.js
41143
+ // ../../packages/superdoc/dist/chunks/SuperConverter-C9MZOwsC.es.js
41063
41144
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
41064
41145
  const fieldValue = extension$1.config[field];
41065
41146
  if (typeof fieldValue === "function")
@@ -50688,6 +50769,18 @@ function buildPath(existingPath = [], node3, branch) {
50688
50769
  path2.push(branch);
50689
50770
  return path2;
50690
50771
  }
50772
+ function isInlineNode(node3, schema) {
50773
+ if (!node3 || typeof node3 !== "object" || typeof node3.type !== "string")
50774
+ return false;
50775
+ const nodeType = schema?.nodes?.[node3.type];
50776
+ if (nodeType) {
50777
+ if (typeof nodeType.isInline === "boolean")
50778
+ return nodeType.isInline;
50779
+ if (nodeType.spec?.group && typeof nodeType.spec.group === "string")
50780
+ return nodeType.spec.group.split(" ").includes("inline");
50781
+ }
50782
+ return INLINE_FALLBACK_TYPES.has(node3.type);
50783
+ }
50691
50784
  function getTableStyleId(path2) {
50692
50785
  const tbl = path2.find((ancestor) => ancestor.name === "w:tbl");
50693
50786
  if (!tbl)
@@ -50700,6 +50793,76 @@ function getTableStyleId(path2) {
50700
50793
  return;
50701
50794
  return tblStyle.attributes?.["w:val"];
50702
50795
  }
50796
+ function cloneParagraphAttrsForFragment(attrs, { keepSectPr = false } = {}) {
50797
+ if (!attrs)
50798
+ return {};
50799
+ const nextAttrs = { ...attrs };
50800
+ if (attrs.paragraphProperties && typeof attrs.paragraphProperties === "object") {
50801
+ nextAttrs.paragraphProperties = { ...attrs.paragraphProperties };
50802
+ if (!keepSectPr)
50803
+ delete nextAttrs.paragraphProperties.sectPr;
50804
+ }
50805
+ if (!keepSectPr)
50806
+ delete nextAttrs.pageBreakSource;
50807
+ return nextAttrs;
50808
+ }
50809
+ function hasSectionBreakAttrs(attrs) {
50810
+ return Boolean(attrs?.paragraphProperties?.sectPr);
50811
+ }
50812
+ function cloneWrapperParagraphAttrs(attrs) {
50813
+ return cloneParagraphAttrsForFragment(attrs, { keepSectPr: true });
50814
+ }
50815
+ function normalizeParagraphChildren(children, schema, textblockAttrs) {
50816
+ const normalized = [];
50817
+ let pendingInline = [];
50818
+ const flushInline = () => {
50819
+ if (!pendingInline.length)
50820
+ return;
50821
+ normalized.push({
50822
+ type: "paragraph",
50823
+ attrs: null,
50824
+ content: pendingInline,
50825
+ marks: []
50826
+ });
50827
+ pendingInline = [];
50828
+ };
50829
+ for (const child of children || []) {
50830
+ if (isInlineNode(child, schema)) {
50831
+ pendingInline.push(child);
50832
+ continue;
50833
+ }
50834
+ flushInline();
50835
+ if (child != null)
50836
+ normalized.push(child);
50837
+ }
50838
+ flushInline();
50839
+ const lastNodeIndex = normalized.length - 1;
50840
+ const isSingleBlockResult = normalized.length === 1 && normalized[0] != null && normalized[0]?.type !== "paragraph";
50841
+ const paragraphIndexes = normalized.reduce((indexes, node3, index2) => {
50842
+ if (node3?.type === "paragraph")
50843
+ indexes.push(index2);
50844
+ return indexes;
50845
+ }, []);
50846
+ const lastParagraphIndex = paragraphIndexes.length ? paragraphIndexes[paragraphIndexes.length - 1] : -1;
50847
+ const shouldAttachWrapperParagraph = isSingleBlockResult || hasSectionBreakAttrs(textblockAttrs) && lastNodeIndex !== lastParagraphIndex;
50848
+ paragraphIndexes.forEach((index2) => {
50849
+ normalized[index2] = {
50850
+ ...normalized[index2],
50851
+ attrs: cloneParagraphAttrsForFragment(textblockAttrs, { keepSectPr: !shouldAttachWrapperParagraph && index2 === lastParagraphIndex })
50852
+ };
50853
+ });
50854
+ if (shouldAttachWrapperParagraph) {
50855
+ const lastNode = normalized[lastNodeIndex];
50856
+ normalized[lastNodeIndex] = {
50857
+ ...lastNode,
50858
+ attrs: {
50859
+ ...lastNode?.attrs || {},
50860
+ wrapperParagraph: cloneWrapperParagraphAttrs(textblockAttrs)
50861
+ }
50862
+ };
50863
+ }
50864
+ return normalized;
50865
+ }
50703
50866
  function generateParagraphProperties(params) {
50704
50867
  const { node: node3 } = params;
50705
50868
  const { attrs = {} } = node3;
@@ -50784,6 +50947,21 @@ function translateParagraphNode(params) {
50784
50947
  attributes
50785
50948
  };
50786
50949
  }
50950
+ function partitionEncodedParagraphAttrs(encodedAttrs = {}) {
50951
+ const identityAttrs = {};
50952
+ const shareableAttrs = {};
50953
+ Object.entries(encodedAttrs).forEach(([key, value]) => {
50954
+ if (IDENTITY_ATTR_NAMES.has(key)) {
50955
+ identityAttrs[key] = value;
50956
+ return;
50957
+ }
50958
+ shareableAttrs[key] = value;
50959
+ });
50960
+ return {
50961
+ identityAttrs,
50962
+ shareableAttrs
50963
+ };
50964
+ }
50787
50965
  function generateDocxRandomId(length = 8) {
50788
50966
  return Math.floor(Math.random() * 2147483648).toString(16).toUpperCase().padStart(length, "0").slice(0, length);
50789
50967
  }
@@ -50934,7 +51112,6 @@ function normalizeTableCellContent(content$2, editor) {
50934
51112
  return content$2;
50935
51113
  const normalized = [];
50936
51114
  const pendingForNextBlock = [];
50937
- const schema = editor?.schema;
50938
51115
  const cloneBlock = (node3) => {
50939
51116
  if (!node3)
50940
51117
  return node3;
@@ -50949,28 +51126,12 @@ function normalizeTableCellContent(content$2, editor) {
50949
51126
  node3.content = [];
50950
51127
  return node3.content;
50951
51128
  };
50952
- const isInlineNode = (node3) => {
50953
- if (!node3 || typeof node3.type !== "string")
50954
- return false;
50955
- if (node3.type === "text")
50956
- return true;
50957
- if (node3.type === "bookmarkStart" || node3.type === "bookmarkEnd")
50958
- return true;
50959
- const nodeType = schema?.nodes?.[node3.type];
50960
- if (nodeType) {
50961
- if (typeof nodeType.isInline === "boolean")
50962
- return nodeType.isInline;
50963
- if (nodeType.spec?.group && typeof nodeType.spec.group === "string")
50964
- return nodeType.spec.group.split(" ").includes("inline");
50965
- }
50966
- return false;
50967
- };
50968
51129
  for (const node3 of content$2) {
50969
51130
  if (!node3 || typeof node3.type !== "string") {
50970
51131
  normalized.push(node3);
50971
51132
  continue;
50972
51133
  }
50973
- if (!isInlineNode(node3)) {
51134
+ if (!isInlineNode(node3, editor?.schema)) {
50974
51135
  const blockNode = cloneBlock(node3);
50975
51136
  if (pendingForNextBlock.length) {
50976
51137
  const blockContent = ensureArray(blockNode);
@@ -50984,7 +51145,7 @@ function normalizeTableCellContent(content$2, editor) {
50984
51145
  pendingForNextBlock.push(node3);
50985
51146
  else {
50986
51147
  const lastNode = normalized[normalized.length - 1];
50987
- if (!lastNode || typeof lastNode.type !== "string" || isInlineNode(lastNode)) {
51148
+ if (!lastNode || typeof lastNode.type !== "string" || isInlineNode(lastNode, editor?.schema)) {
50988
51149
  pendingForNextBlock.push(node3);
50989
51150
  continue;
50990
51151
  }
@@ -50997,7 +51158,7 @@ function normalizeTableCellContent(content$2, editor) {
50997
51158
  if (pendingForNextBlock.length) {
50998
51159
  if (normalized.length) {
50999
51160
  const lastNode = normalized[normalized.length - 1];
51000
- if (lastNode && typeof lastNode.type === "string" && !isInlineNode(lastNode)) {
51161
+ if (lastNode && typeof lastNode.type === "string" && !isInlineNode(lastNode, editor?.schema)) {
51001
51162
  ensureArray(lastNode).push(...pendingForNextBlock);
51002
51163
  pendingForNextBlock.length = 0;
51003
51164
  }
@@ -61056,7 +61217,7 @@ function handleHtmlPaste(html2, editor, source) {
61056
61217
  cleanedHtml = htmlHandler(html2, editor);
61057
61218
  if (cleanedHtml?.dataset)
61058
61219
  cleanedHtml.dataset.superdocImport = "true";
61059
- let doc$2 = DOMParser$1.fromSchema(editor.schema).parse(cleanedHtml);
61220
+ let doc$2 = DOMParser$1.fromSchema(editor.schema).parse(cleanedHtml, { preserveWhitespace: true });
61060
61221
  doc$2 = mergeAdjacentTableFragments(doc$2);
61061
61222
  doc$2 = wrapTextsInRuns(doc$2);
61062
61223
  const { dispatch, state } = editor.view;
@@ -66848,13 +67009,38 @@ function translateDocumentPartObj(params) {
66848
67009
  ...params,
66849
67010
  nodes: node3.content
66850
67011
  });
66851
- return {
67012
+ const result = {
66852
67013
  name: "w:sdt",
66853
67014
  elements: [generateSdtPrForDocPartObj(attrs), {
66854
67015
  name: "w:sdtContent",
66855
67016
  elements: childContent
66856
67017
  }]
66857
67018
  };
67019
+ if (!attrs.wrapperParagraph)
67020
+ return result;
67021
+ return wrapDocumentPartInParagraph(result, attrs.wrapperParagraph);
67022
+ }
67023
+ function wrapDocumentPartInParagraph(sdtNode, wrapperParagraphAttrs) {
67024
+ const elements = [];
67025
+ const pPr = generateParagraphProperties({ node: {
67026
+ type: "paragraph",
67027
+ attrs: wrapperParagraphAttrs
67028
+ } });
67029
+ if (pPr)
67030
+ elements.push(pPr);
67031
+ elements.push(sdtNode);
67032
+ const attributes = {
67033
+ ...extractRawParagraphXmlAttributes(wrapperParagraphAttrs),
67034
+ ...translator.decodeAttributes({ node: { attrs: wrapperParagraphAttrs } })
67035
+ };
67036
+ return {
67037
+ name: "w:p",
67038
+ elements,
67039
+ ...Object.keys(attributes).length ? { attributes } : {}
67040
+ };
67041
+ }
67042
+ function extractRawParagraphXmlAttributes(attrs = {}) {
67043
+ return Object.fromEntries(Object.entries(attrs).filter(([key]) => key.includes(":")));
66858
67044
  }
66859
67045
  function sanitizeId(id) {
66860
67046
  if (typeof id === "string" && id.trim() !== "")
@@ -77195,8 +77381,8 @@ var isRegExp = (value) => {
77195
77381
  }
77196
77382
  }
77197
77383
  return css;
77198
- }, SUPPORTED_ALTERNATE_CONTENT_REQUIRES, XML_NODE_NAME$36 = "mc:AlternateContent", SD_NODE_NAME$32, validXmlAttributes$12, config$35, translator$31, translator$37, translator$39, translator$40, translator$208, translator$51, translator$54, translator$57, translator$65, translator$80, translator$85, translator$86, translator$87, translator$89, translator$102, translator$78, translator$111, propertyTranslators$16, translator$113, translator$118, translator$119, translator$45, translator$209, translator$48, translator$201, translator$103, translator$203, translator$133, translator$204, translator$169, translator$206, propertyTranslators$15, translator$121, translator$127, translator$120, translator$144, translator$145, translator$146, translator$147, propertyTranslators$14, translator$151, translator$190, translator$183, translator$191, translator$192, translator$195, translator$196, propertyTranslators$13, translator$126, handleParagraphNode$1 = (params) => {
77199
- const { nodes, nodeListHandler, filename } = params;
77384
+ }, SUPPORTED_ALTERNATE_CONTENT_REQUIRES, XML_NODE_NAME$36 = "mc:AlternateContent", SD_NODE_NAME$32, validXmlAttributes$12, config$35, translator$31, translator$37, translator$39, translator$40, translator$208, translator$51, translator$54, translator$57, translator$65, translator$80, translator$85, translator$86, translator$87, translator$89, translator$102, translator$78, translator$111, propertyTranslators$16, translator$113, translator$118, translator$119, translator$45, translator$209, translator$48, translator$201, translator$103, translator$203, translator$133, translator$204, translator$169, translator$206, propertyTranslators$15, translator$121, translator$127, translator$120, translator$144, translator$145, translator$146, translator$147, propertyTranslators$14, translator$151, translator$190, translator$183, translator$191, translator$192, translator$195, translator$196, propertyTranslators$13, translator$126, INLINE_FALLBACK_TYPES, handleParagraphNode$1 = (params) => {
77385
+ const { nodes, nodeListHandler, filename, editor } = params;
77200
77386
  const node3 = carbonCopy(nodes[0]);
77201
77387
  let schemaNode;
77202
77388
  const pPr = node3.elements?.find((el) => el.name === "w:pPr");
@@ -77240,17 +77426,27 @@ var isRegExp = (value) => {
77240
77426
  schemaNode.attrs.paragraphProperties = inlineParagraphProperties;
77241
77427
  schemaNode.attrs.rsidRDefault = node3.attributes?.["w:rsidRDefault"];
77242
77428
  schemaNode.attrs.filename = filename;
77243
- if (schemaNode && schemaNode.content)
77244
- schemaNode = {
77245
- ...schemaNode,
77246
- content: mergeTextNodes(schemaNode.content)
77247
- };
77248
77429
  const sectPr = pPr?.elements?.find((el) => el.name === "w:sectPr");
77249
77430
  if (sectPr) {
77250
77431
  schemaNode.attrs.paragraphProperties.sectPr = sectPr;
77251
77432
  schemaNode.attrs.pageBreakSource = "sectPr";
77252
77433
  }
77253
- return schemaNode;
77434
+ const normalizedNodes = normalizeParagraphChildren(schemaNode.content, editor?.schema, schemaNode.attrs).map((node$1) => {
77435
+ if (node$1?.type !== "paragraph" || !Array.isArray(node$1.content))
77436
+ return node$1;
77437
+ return {
77438
+ ...node$1,
77439
+ content: mergeTextNodes(node$1.content)
77440
+ };
77441
+ });
77442
+ if (!normalizedNodes.length)
77443
+ return {
77444
+ ...schemaNode,
77445
+ content: mergeTextNodes(schemaNode.content || [])
77446
+ };
77447
+ if (normalizedNodes.length === 1 && normalizedNodes[0]?.type === "paragraph")
77448
+ return normalizedNodes[0];
77449
+ return normalizedNodes;
77254
77450
  }, encode$62 = (attributes) => {
77255
77451
  return attributes["w:rsidDel"];
77256
77452
  }, decode$64 = (attrs) => {
@@ -77279,15 +77475,36 @@ var isRegExp = (value) => {
77279
77475
  return attributes["w14:textId"];
77280
77476
  }, decode$58 = (attrs) => {
77281
77477
  return attrs.textId;
77282
- }, attributes_default$5, XML_NODE_NAME$35 = "w:p", SD_NODE_NAME$31 = "paragraph", encode$55 = (params, encodedAttrs = {}) => {
77478
+ }, attributes_default$5, XML_NODE_NAME$35 = "w:p", SD_NODE_NAME$31 = "paragraph", IDENTITY_ATTR_NAMES, encode$55 = (params, encodedAttrs = {}) => {
77283
77479
  const node3 = handleParagraphNode$1(params);
77284
77480
  if (!node3)
77285
77481
  return;
77286
- if (encodedAttrs && Object.keys(encodedAttrs).length)
77482
+ if (encodedAttrs && Object.keys(encodedAttrs).length) {
77483
+ if (Array.isArray(node3)) {
77484
+ const { identityAttrs, shareableAttrs } = partitionEncodedParagraphAttrs(encodedAttrs);
77485
+ let appliedIdentityAttrs = false;
77486
+ return node3.map((child) => {
77487
+ if (child?.type !== "paragraph")
77488
+ return child;
77489
+ const attrs = {
77490
+ ...child.attrs || {},
77491
+ ...shareableAttrs
77492
+ };
77493
+ if (!appliedIdentityAttrs) {
77494
+ Object.assign(attrs, identityAttrs);
77495
+ appliedIdentityAttrs = true;
77496
+ }
77497
+ return {
77498
+ ...child,
77499
+ attrs
77500
+ };
77501
+ });
77502
+ }
77287
77503
  node3.attrs = {
77288
77504
  ...node3.attrs,
77289
77505
  ...encodedAttrs
77290
77506
  };
77507
+ }
77291
77508
  return node3;
77292
77509
  }, decode$57 = (params, decodedAttrs = {}) => {
77293
77510
  const translated = translateParagraphNode(params);
@@ -88989,7 +89206,7 @@ var isRegExp = (value) => {
88989
89206
  };
88990
89207
  const schemaNode = translator.encode(params);
88991
89208
  return {
88992
- nodes: schemaNode ? [schemaNode] : [],
89209
+ nodes: Array.isArray(schemaNode) ? schemaNode : schemaNode ? [schemaNode] : [],
88993
89210
  consumed: 1
88994
89211
  };
88995
89212
  }, paragraphNodeHandlerEntity, handleSdtNode = (params) => {
@@ -91154,12 +91371,12 @@ var isRegExp = (value) => {
91154
91371
  state.kern = kernNode.attributes["w:val"];
91155
91372
  }
91156
91373
  }, SuperConverter;
91157
- var init_SuperConverter_V_8WDjnK_es = __esm(() => {
91374
+ var init_SuperConverter_C9MZOwsC_es = __esm(() => {
91158
91375
  init_rolldown_runtime_B2q5OVn9_es();
91159
91376
  init_jszip_ChlR43oI_es();
91160
- init_xml_js_DLE8mr0n_es();
91377
+ init_xml_js_40FWvL78_es();
91161
91378
  init_uuid_qzgm05fK_es();
91162
- init_constants_CMPtQbp7_es();
91379
+ init_constants_Qqwopz80_es();
91163
91380
  init_unified_BRHLwnjP_es();
91164
91381
  init_lib_HnbxUP96_es();
91165
91382
  init_lib_DAB30bX1_es();
@@ -106225,6 +106442,34 @@ var init_SuperConverter_V_8WDjnK_es = __esm(() => {
106225
106442
  translator$129
106226
106443
  ];
106227
106444
  translator$126 = NodeTranslator.from(createNestedPropertiesTranslator("w:pPr", "paragraphProperties", propertyTranslators$13));
106445
+ INLINE_FALLBACK_TYPES = new Set([
106446
+ "text",
106447
+ "run",
106448
+ "bookmarkStart",
106449
+ "bookmarkEnd",
106450
+ "tab",
106451
+ "lineBreak",
106452
+ "hardBreak",
106453
+ "commentRangeStart",
106454
+ "commentRangeEnd",
106455
+ "commentReference",
106456
+ "permStart",
106457
+ "permEnd",
106458
+ "footnoteReference",
106459
+ "endnoteReference",
106460
+ "fieldAnnotation",
106461
+ "structuredContent",
106462
+ "passthroughInline",
106463
+ "page-number",
106464
+ "total-page-number",
106465
+ "pageReference",
106466
+ "crossReference",
106467
+ "citation",
106468
+ "authorityEntry",
106469
+ "sequenceField",
106470
+ "indexEntry",
106471
+ "tableOfContentsEntry"
106472
+ ]);
106228
106473
  attrConfig$22 = Object.freeze({
106229
106474
  xmlName: "w:rsidDel",
106230
106475
  sdName: "rsidDel",
@@ -106275,6 +106520,7 @@ var init_SuperConverter_V_8WDjnK_es = __esm(() => {
106275
106520
  attrConfig$25,
106276
106521
  attrConfig$22
106277
106522
  ];
106523
+ IDENTITY_ATTR_NAMES = new Set(["paraId", "textId"]);
106278
106524
  config$34 = {
106279
106525
  xmlName: XML_NODE_NAME$35,
106280
106526
  sdNodeOrKeyName: SD_NODE_NAME$31,
@@ -128498,7 +128744,7 @@ var init_remark_stringify_D8vxv_XI_es = __esm(() => {
128498
128744
  eol = /\r?\n|\r/g;
128499
128745
  });
128500
128746
 
128501
- // ../../packages/superdoc/dist/chunks/DocxZipper-BBJ5zSyW.es.js
128747
+ // ../../packages/superdoc/dist/chunks/DocxZipper-gWkmvJfR.es.js
128502
128748
  function getLens2(b64) {
128503
128749
  var len$1 = b64.length;
128504
128750
  if (len$1 % 4 > 0)
@@ -129193,11 +129439,11 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
129193
129439
  return `image/${MIME_TYPE_FOR_EXT[detectedType] || detectedType}`;
129194
129440
  }
129195
129441
  }, DocxZipper_default;
129196
- var init_DocxZipper_BBJ5zSyW_es = __esm(() => {
129442
+ var init_DocxZipper_gWkmvJfR_es = __esm(() => {
129197
129443
  init_rolldown_runtime_B2q5OVn9_es();
129198
129444
  init_jszip_ChlR43oI_es();
129199
- init_xml_js_DLE8mr0n_es();
129200
- init_constants_CMPtQbp7_es();
129445
+ init_xml_js_40FWvL78_es();
129446
+ init_constants_Qqwopz80_es();
129201
129447
  buffer2 = {};
129202
129448
  base64Js2 = {};
129203
129449
  base64Js2.byteLength = byteLength2;
@@ -138692,11 +138938,20 @@ var assign, keys2, forEach2 = (obj, f2) => {
138692
138938
  }
138693
138939
  }
138694
138940
  return true;
138695
- }, hasProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key), equalFlat = (a, b) => a === b || size(a) === size(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && equals(b[key], val));
138941
+ }, hasProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key), equalFlat = (a, b) => a === b || size(a) === size(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && equals(b[key], val)), freeze, deepFreeze = (o) => {
138942
+ for (const key in o) {
138943
+ const c = o[key];
138944
+ if (typeof c === "object" || typeof c === "function") {
138945
+ deepFreeze(o[key]);
138946
+ }
138947
+ }
138948
+ return freeze(o);
138949
+ };
138696
138950
  var init_object = __esm(() => {
138697
138951
  init_equality();
138698
138952
  assign = Object.assign;
138699
138953
  keys2 = Object.keys;
138954
+ freeze = Object.freeze;
138700
138955
  });
138701
138956
 
138702
138957
  // ../../node_modules/.pnpm/lib0@0.2.117/node_modules/lib0/function.js
@@ -138995,7 +139250,7 @@ var createIterator = (next) => ({
138995
139250
  return { done, value: done ? undefined : fmap(value) };
138996
139251
  });
138997
139252
 
138998
- // ../../node_modules/.pnpm/yjs@13.6.19/node_modules/yjs/dist/yjs.mjs
139253
+ // ../../node_modules/.pnpm/yjs@13.6.30/node_modules/yjs/dist/yjs.mjs
138999
139254
  class DeleteItem {
139000
139255
  constructor(clock, len3) {
139001
139256
  this.clock = clock;
@@ -139693,6 +139948,7 @@ class ContentJSON {
139693
139948
  class ContentAny {
139694
139949
  constructor(arr) {
139695
139950
  this.arr = arr;
139951
+ isDevMode && deepFreeze(arr);
139696
139952
  }
139697
139953
  getLength() {
139698
139954
  return this.arr.length;
@@ -139840,9 +140096,12 @@ class ContentType {
139840
140096
  }
139841
140097
  var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes, clientid) => {
139842
140098
  const structs = transaction.doc.store.clients.get(clientid);
139843
- for (let i4 = 0;i4 < deletes.length; i4++) {
139844
- const del = deletes[i4];
139845
- iterateStructs(transaction, structs, del.clock, del.len, f2);
140099
+ if (structs != null) {
140100
+ const lastStruct = structs[structs.length - 1];
140101
+ const clockState = lastStruct.id.clock + lastStruct.length;
140102
+ for (let i4 = 0, del = deletes[i4];i4 < deletes.length && del.clock < clockState; del = deletes[++i4]) {
140103
+ iterateStructs(transaction, structs, del.clock, del.len, f2);
140104
+ }
139846
140105
  }
139847
140106
  }), findIndexDS = (dis, clock) => {
139848
140107
  let left = 0;
@@ -139872,7 +140131,7 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
139872
140131
  const left = dels[j - 1];
139873
140132
  const right = dels[i4];
139874
140133
  if (left.clock + left.len >= right.clock) {
139875
- left.len = max(left.len, right.clock + right.len - left.clock);
140134
+ dels[j - 1] = new DeleteItem(left.clock, max(left.len, right.clock + right.len - left.clock));
139876
140135
  } else {
139877
140136
  if (j < i4) {
139878
140137
  dels[j] = right;
@@ -140095,13 +140354,13 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
140095
140354
  const addStackToRestSS = () => {
140096
140355
  for (const item of stack2) {
140097
140356
  const client = item.id.client;
140098
- const unapplicableItems = clientsStructRefs.get(client);
140099
- if (unapplicableItems) {
140100
- unapplicableItems.i--;
140101
- restStructs.clients.set(client, unapplicableItems.refs.slice(unapplicableItems.i));
140357
+ const inapplicableItems = clientsStructRefs.get(client);
140358
+ if (inapplicableItems) {
140359
+ inapplicableItems.i--;
140360
+ restStructs.clients.set(client, inapplicableItems.refs.slice(inapplicableItems.i));
140102
140361
  clientsStructRefs.delete(client);
140103
- unapplicableItems.i = 0;
140104
- unapplicableItems.refs = [];
140362
+ inapplicableItems.i = 0;
140363
+ inapplicableItems.refs = [];
140105
140364
  } else {
140106
140365
  restStructs.clients.set(client, [item]);
140107
140366
  }
@@ -140299,6 +140558,13 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
140299
140558
  t = t.right;
140300
140559
  }
140301
140560
  return createRelativePosition(type, null, assoc);
140561
+ }, getItemWithOffset = (store, id2) => {
140562
+ const item = getItem(store, id2);
140563
+ const diff = id2.clock - item.id.clock;
140564
+ return {
140565
+ item,
140566
+ diff
140567
+ };
140302
140568
  }, createAbsolutePositionFromRelativePosition = (rpos, doc3, followUndoneDeletions = true) => {
140303
140569
  const store = doc3.store;
140304
140570
  const rightID = rpos.item;
@@ -140311,7 +140577,7 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
140311
140577
  if (getState(store, rightID.client) <= rightID.clock) {
140312
140578
  return null;
140313
140579
  }
140314
- const res = followUndoneDeletions ? followRedone(store, rightID) : { item: getItem(store, rightID), diff: 0 };
140580
+ const res = followUndoneDeletions ? followRedone(store, rightID) : getItemWithOffset(store, rightID);
140315
140581
  const right = res.item;
140316
140582
  if (!(right instanceof Item4)) {
140317
140583
  return null;
@@ -140537,15 +140803,19 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
140537
140803
  event._path = null;
140538
140804
  });
140539
140805
  events.sort((event1, event2) => event1.path.length - event2.path.length);
140540
- callEventHandlerListeners(type._dEH, events, transaction);
140806
+ fs.push(() => {
140807
+ callEventHandlerListeners(type._dEH, events, transaction);
140808
+ });
140809
+ }
140810
+ });
140811
+ fs.push(() => doc3.emit("afterTransaction", [transaction, doc3]));
140812
+ fs.push(() => {
140813
+ if (transaction._needFormattingCleanup) {
140814
+ cleanupYTextAfterTransaction(transaction);
140541
140815
  }
140542
140816
  });
140543
140817
  });
140544
- fs.push(() => doc3.emit("afterTransaction", [transaction, doc3]));
140545
140818
  callAll(fs, []);
140546
- if (transaction._needFormattingCleanup) {
140547
- cleanupYTextAfterTransaction(transaction);
140548
- }
140549
140819
  } finally {
140550
140820
  if (doc3.gc) {
140551
140821
  tryGcDeleteSet(ds, store, doc3.gcFilter);
@@ -140641,7 +140911,7 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
140641
140911
  return result;
140642
140912
  }, clearUndoManagerStackItem = (tr, um, stackItem) => {
140643
140913
  iterateDeletedStructs(tr, stackItem.deletions, (item) => {
140644
- if (item instanceof Item4 && um.scope.some((type) => isParentOf(type, item))) {
140914
+ if (item instanceof Item4 && um.scope.some((type) => type === tr.doc || isParentOf(type, item))) {
140645
140915
  keepItem(item, false);
140646
140916
  }
140647
140917
  });
@@ -140665,13 +140935,13 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
140665
140935
  }
140666
140936
  struct = item;
140667
140937
  }
140668
- if (!struct.deleted && scope.some((type) => isParentOf(type, struct))) {
140938
+ if (!struct.deleted && scope.some((type) => type === transaction.doc || isParentOf(type, struct))) {
140669
140939
  itemsToDelete.push(struct);
140670
140940
  }
140671
140941
  }
140672
140942
  });
140673
140943
  iterateDeletedStructs(transaction, stackItem.deletions, (struct) => {
140674
- if (struct instanceof Item4 && scope.some((type) => isParentOf(type, struct)) && !isDeleted(stackItem.insertions, struct.id)) {
140944
+ if (struct instanceof Item4 && scope.some((type) => type === transaction.doc || isParentOf(type, struct)) && !isDeleted(stackItem.insertions, struct.id)) {
140675
140945
  itemsToRedo.add(struct);
140676
140946
  }
140677
140947
  });
@@ -140887,6 +141157,8 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
140887
141157
  child = child._item.parent;
140888
141158
  }
140889
141159
  return path2;
141160
+ }, warnPrematureAccess = () => {
141161
+ warn2("Invalid access: Add Yjs type to a document before reading data.");
140890
141162
  }, maxSearchMarker = 80, globalSearchMarkerTimestamp = 0, refreshMarkerTimestamp = (marker) => {
140891
141163
  marker.timestamp = globalSearchMarkerTimestamp++;
140892
141164
  }, overwriteMarker = (marker, p2, index2) => {
@@ -140979,6 +141251,7 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
140979
141251
  }
140980
141252
  callEventHandlerListeners(changedType._eH, event, transaction);
140981
141253
  }, typeListSlice = (type, start, end) => {
141254
+ type.doc ?? warnPrematureAccess();
140982
141255
  if (start < 0) {
140983
141256
  start = type._length + start;
140984
141257
  }
@@ -141005,6 +141278,7 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
141005
141278
  }
141006
141279
  return cs;
141007
141280
  }, typeListToArray = (type) => {
141281
+ type.doc ?? warnPrematureAccess();
141008
141282
  const cs = [];
141009
141283
  let n = type._start;
141010
141284
  while (n !== null) {
@@ -141033,6 +141307,7 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
141033
141307
  }, typeListForEach = (type, f2) => {
141034
141308
  let index2 = 0;
141035
141309
  let n = type._start;
141310
+ type.doc ?? warnPrematureAccess();
141036
141311
  while (n !== null) {
141037
141312
  if (n.countable && !n.deleted) {
141038
141313
  const c = n.content.getContent();
@@ -141082,6 +141357,7 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
141082
141357
  }
141083
141358
  };
141084
141359
  }, typeListGet = (type, index2) => {
141360
+ type.doc ?? warnPrematureAccess();
141085
141361
  const marker = findMarker(type, index2);
141086
141362
  let n = type._start;
141087
141363
  if (marker !== null) {
@@ -141246,6 +141522,8 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
141246
141522
  case Boolean:
141247
141523
  case Array:
141248
141524
  case String:
141525
+ case Date:
141526
+ case BigInt:
141249
141527
  content2 = new ContentAny([value]);
141250
141528
  break;
141251
141529
  case Uint8Array:
@@ -141264,10 +141542,12 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
141264
141542
  }
141265
141543
  new Item4(createID(ownClientId, getState(doc3.store, ownClientId)), left, left && left.lastId, null, null, parent, key, content2).integrate(transaction, 0);
141266
141544
  }, typeMapGet = (parent, key) => {
141545
+ parent.doc ?? warnPrematureAccess();
141267
141546
  const val = parent._map.get(key);
141268
141547
  return val !== undefined && !val.deleted ? val.content.getContent()[val.length - 1] : undefined;
141269
141548
  }, typeMapGetAll = (parent) => {
141270
141549
  const res = {};
141550
+ parent.doc ?? warnPrematureAccess();
141271
141551
  parent._map.forEach((value, key) => {
141272
141552
  if (!value.deleted) {
141273
141553
  res[key] = value.content.getContent()[value.length - 1];
@@ -141275,6 +141555,7 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
141275
141555
  });
141276
141556
  return res;
141277
141557
  }, typeMapHas = (parent, key) => {
141558
+ parent.doc ?? warnPrematureAccess();
141278
141559
  const val = parent._map.get(key);
141279
141560
  return val !== undefined && !val.deleted;
141280
141561
  }, typeMapGetAllSnapshot = (parent, snapshot2) => {
@@ -141289,7 +141570,10 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
141289
141570
  }
141290
141571
  });
141291
141572
  return res;
141292
- }, createMapIterator = (map6) => iteratorFilter(map6.entries(), (entry) => !entry[1].deleted), YArrayEvent, YArray, readYArray = (_decoder) => new YArray, YMapEvent, YMap, readYMap = (_decoder) => new YMap, equalAttrs = (a, b) => a === b || typeof a === "object" && typeof b === "object" && a && b && equalFlat(a, b), findNextPosition = (transaction, pos, count) => {
141573
+ }, createMapIterator = (type) => {
141574
+ type.doc ?? warnPrematureAccess();
141575
+ return iteratorFilter(type._map.entries(), (entry) => !entry[1].deleted);
141576
+ }, YArrayEvent, YArray, readYArray = (_decoder) => new YArray, YMapEvent, YMap, readYMap = (_decoder) => new YMap, equalAttrs = (a, b) => a === b || typeof a === "object" && typeof b === "object" && a && b && equalFlat(a, b), findNextPosition = (transaction, pos, count) => {
141293
141577
  while (pos.right !== null && count > 0) {
141294
141578
  switch (pos.right.content.constructor) {
141295
141579
  case ContentFormat:
@@ -141594,7 +141878,7 @@ var iterateDeletedStructs = (transaction, ds, f2) => ds.clients.forEach((deletes
141594
141878
  }
141595
141879
  }
141596
141880
  return new ContentJSON(cs);
141597
- }, readContentAny = (decoder) => {
141881
+ }, isDevMode, readContentAny = (decoder) => {
141598
141882
  const len3 = decoder.readLen();
141599
141883
  const cs = [];
141600
141884
  for (let i4 = 0;i4 < len3; i4++) {
@@ -141728,6 +142012,7 @@ var init_yjs = __esm(() => {
141728
142012
  init_logging_node();
141729
142013
  init_time();
141730
142014
  init_object();
142015
+ init_environment();
141731
142016
  generateNewClientId = uint32;
141732
142017
  Doc = class Doc extends ObservableV2 {
141733
142018
  constructor({ guid = uuidv4(), collectionid = null, gc = true, gcFilter = () => true, meta = null, autoLoad = false, shouldLoad = true } = {}) {
@@ -142088,7 +142373,7 @@ var init_yjs = __esm(() => {
142088
142373
  deleteFilter = () => true,
142089
142374
  trackedOrigins = new Set([null]),
142090
142375
  ignoreRemoteMapChanges = false,
142091
- doc: doc3 = isArray2(typeScope) ? typeScope[0].doc : typeScope.doc
142376
+ doc: doc3 = isArray2(typeScope) ? typeScope[0].doc : typeScope instanceof Doc ? typeScope : typeScope.doc
142092
142377
  } = {}) {
142093
142378
  super();
142094
142379
  this.scope = [];
@@ -142107,7 +142392,7 @@ var init_yjs = __esm(() => {
142107
142392
  this.ignoreRemoteMapChanges = ignoreRemoteMapChanges;
142108
142393
  this.captureTimeout = captureTimeout;
142109
142394
  this.afterTransactionHandler = (transaction) => {
142110
- if (!this.captureTransaction(transaction) || !this.scope.some((type) => transaction.changedParentTypes.has(type)) || !this.trackedOrigins.has(transaction.origin) && (!transaction.origin || !this.trackedOrigins.has(transaction.origin.constructor))) {
142395
+ if (!this.captureTransaction(transaction) || !this.scope.some((type) => transaction.changedParentTypes.has(type) || type === this.doc) || !this.trackedOrigins.has(transaction.origin) && (!transaction.origin || !this.trackedOrigins.has(transaction.origin.constructor))) {
142111
142396
  return;
142112
142397
  }
142113
142398
  const undoing = this.undoing;
@@ -142140,7 +142425,7 @@ var init_yjs = __esm(() => {
142140
142425
  this.lastChange = now;
142141
142426
  }
142142
142427
  iterateDeletedStructs(transaction, transaction.deleteSet, (item) => {
142143
- if (item instanceof Item4 && this.scope.some((type) => isParentOf(type, item))) {
142428
+ if (item instanceof Item4 && this.scope.some((type) => type === transaction.doc || isParentOf(type, item))) {
142144
142429
  keepItem(item, true);
142145
142430
  }
142146
142431
  });
@@ -142157,10 +142442,12 @@ var init_yjs = __esm(() => {
142157
142442
  });
142158
142443
  }
142159
142444
  addToScope(ytypes) {
142445
+ const tmpSet = new Set(this.scope);
142160
142446
  ytypes = isArray2(ytypes) ? ytypes : [ytypes];
142161
142447
  ytypes.forEach((ytype) => {
142162
- if (this.scope.every((yt) => yt !== ytype)) {
142163
- if (ytype.doc !== this.doc)
142448
+ if (!tmpSet.has(ytype)) {
142449
+ tmpSet.add(ytype);
142450
+ if (ytype instanceof AbstractType ? ytype.doc !== this.doc : ytype !== this.doc)
142164
142451
  warn2("[yjs#509] Not same Y.Doc");
142165
142452
  this.scope.push(ytype);
142166
142453
  }
@@ -142249,7 +142536,8 @@ var init_yjs = __esm(() => {
142249
142536
  return arr;
142250
142537
  }
142251
142538
  get length() {
142252
- return this._prelimContent === null ? this._length : this._prelimContent.length;
142539
+ this.doc ?? warnPrematureAccess();
142540
+ return this._length;
142253
142541
  }
142254
142542
  _callObserver(transaction, parentSubs) {
142255
142543
  super._callObserver(transaction, parentSubs);
@@ -142347,6 +142635,7 @@ var init_yjs = __esm(() => {
142347
142635
  callTypeObservers(this, transaction, new YMapEvent(this, transaction, parentSubs));
142348
142636
  }
142349
142637
  toJSON() {
142638
+ this.doc ?? warnPrematureAccess();
142350
142639
  const map6 = {};
142351
142640
  this._map.forEach((item, key) => {
142352
142641
  if (!item.deleted) {
@@ -142357,18 +142646,19 @@ var init_yjs = __esm(() => {
142357
142646
  return map6;
142358
142647
  }
142359
142648
  get size() {
142360
- return [...createMapIterator(this._map)].length;
142649
+ return [...createMapIterator(this)].length;
142361
142650
  }
142362
142651
  keys() {
142363
- return iteratorMap(createMapIterator(this._map), (v) => v[0]);
142652
+ return iteratorMap(createMapIterator(this), (v) => v[0]);
142364
142653
  }
142365
142654
  values() {
142366
- return iteratorMap(createMapIterator(this._map), (v) => v[1].content.getContent()[v[1].length - 1]);
142655
+ return iteratorMap(createMapIterator(this), (v) => v[1].content.getContent()[v[1].length - 1]);
142367
142656
  }
142368
142657
  entries() {
142369
- return iteratorMap(createMapIterator(this._map), (v) => [v[0], v[1].content.getContent()[v[1].length - 1]]);
142658
+ return iteratorMap(createMapIterator(this), (v) => [v[0], v[1].content.getContent()[v[1].length - 1]]);
142370
142659
  }
142371
142660
  forEach(f2) {
142661
+ this.doc ?? warnPrematureAccess();
142372
142662
  this._map.forEach((item, key) => {
142373
142663
  if (!item.deleted) {
142374
142664
  f2(item.content.getContent()[item.length - 1], key, this);
@@ -142622,6 +142912,7 @@ var init_yjs = __esm(() => {
142622
142912
  this._hasFormatting = false;
142623
142913
  }
142624
142914
  get length() {
142915
+ this.doc ?? warnPrematureAccess();
142625
142916
  return this._length;
142626
142917
  }
142627
142918
  _integrate(y, item) {
@@ -142650,6 +142941,7 @@ var init_yjs = __esm(() => {
142650
142941
  }
142651
142942
  }
142652
142943
  toString() {
142944
+ this.doc ?? warnPrematureAccess();
142653
142945
  let str = "";
142654
142946
  let n = this._start;
142655
142947
  while (n !== null) {
@@ -142687,6 +142979,7 @@ var init_yjs = __esm(() => {
142687
142979
  }
142688
142980
  }
142689
142981
  toDelta(snapshot2, prevSnapshot, computeYChange) {
142982
+ this.doc ?? warnPrematureAccess();
142690
142983
  const ops = [];
142691
142984
  const currentAttributes = new Map;
142692
142985
  const doc3 = this.doc;
@@ -142869,6 +143162,7 @@ var init_yjs = __esm(() => {
142869
143162
  this._root = root2;
142870
143163
  this._currentNode = root2._start;
142871
143164
  this._firstCall = true;
143165
+ root2.doc ?? warnPrematureAccess();
142872
143166
  }
142873
143167
  [Symbol.iterator]() {
142874
143168
  return this;
@@ -142883,8 +143177,9 @@ var init_yjs = __esm(() => {
142883
143177
  n = type._start;
142884
143178
  } else {
142885
143179
  while (n !== null) {
142886
- if (n.right !== null) {
142887
- n = n.right;
143180
+ const nxt = n.next;
143181
+ if (nxt !== null) {
143182
+ n = nxt;
142888
143183
  break;
142889
143184
  } else if (n.parent === this._root) {
142890
143185
  n = null;
@@ -142926,6 +143221,7 @@ var init_yjs = __esm(() => {
142926
143221
  return el;
142927
143222
  }
142928
143223
  get length() {
143224
+ this.doc ?? warnPrematureAccess();
142929
143225
  return this._prelimContent === null ? this._length : this._prelimContent.length;
142930
143226
  }
142931
143227
  createTreeWalker(filter) {
@@ -143047,11 +143343,9 @@ var init_yjs = __esm(() => {
143047
143343
  const el = new YXmlElement(this.nodeName);
143048
143344
  const attrs = this.getAttributes();
143049
143345
  forEach2(attrs, (value, key) => {
143050
- if (typeof value === "string") {
143051
- el.setAttribute(key, value);
143052
- }
143346
+ el.setAttribute(key, value);
143053
143347
  });
143054
- el.insert(0, this.toArray().map((item) => item instanceof AbstractType ? item.clone() : item));
143348
+ el.insert(0, this.toArray().map((v) => v instanceof AbstractType ? v.clone() : v));
143055
143349
  return el;
143056
143350
  }
143057
143351
  toString() {
@@ -143255,6 +143549,7 @@ var init_yjs = __esm(() => {
143255
143549
  return null;
143256
143550
  }
143257
143551
  };
143552
+ isDevMode = getVariable("node_env") === "development";
143258
143553
  typeRefs = [
143259
143554
  readYArray,
143260
143555
  readYMap,
@@ -143331,8 +143626,7 @@ var init_yjs = __esm(() => {
143331
143626
  if (this.left && this.left.constructor === Item4) {
143332
143627
  this.parent = this.left.parent;
143333
143628
  this.parentSub = this.left.parentSub;
143334
- }
143335
- if (this.right && this.right.constructor === Item4) {
143629
+ } else if (this.right && this.right.constructor === Item4) {
143336
143630
  this.parent = this.right.parent;
143337
143631
  this.parentSub = this.right.parentSub;
143338
143632
  }
@@ -154303,7 +154597,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
154303
154597
  init_remark_gfm_z_sDF4ss_es();
154304
154598
  });
154305
154599
 
154306
- // ../../packages/superdoc/dist/chunks/src-1kVu_IvJ.es.js
154600
+ // ../../packages/superdoc/dist/chunks/src-8sGn3qa5.es.js
154307
154601
  function deleteProps(obj, propOrProps) {
154308
154602
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
154309
154603
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -164714,6 +165008,7 @@ async function measureParagraphBlock(block, maxWidth) {
164714
165008
  let hasSeenTextRun = false;
164715
165009
  let tabStopCursor = 0;
164716
165010
  let pendingTabAlignment = null;
165011
+ let pendingLeader = null;
164717
165012
  let pendingRunSpacing = 0;
164718
165013
  let lastAppliedTabAlign = null;
164719
165014
  const warnedTabVals = /* @__PURE__ */ new Set;
@@ -164746,12 +165041,17 @@ async function measureParagraphBlock(block, maxWidth) {
164746
165041
  startX = Math.max(0, target - segmentWidth / 2);
164747
165042
  else
164748
165043
  startX = Math.max(0, target);
165044
+ if (pendingLeader) {
165045
+ const effectiveIndent = lines.length === 0 ? indentLeft + rawFirstLineOffset : indentLeft;
165046
+ pendingLeader.to = startX + effectiveIndent;
165047
+ }
164749
165048
  currentLine.width = roundValue(startX);
164750
165049
  lastAppliedTabAlign = {
164751
165050
  target,
164752
165051
  val
164753
165052
  };
164754
165053
  pendingTabAlignment = null;
165054
+ pendingLeader = null;
164755
165055
  return startX;
164756
165056
  };
164757
165057
  const alignSegmentAtTab = (segmentText, font, runContext, segmentStartChar) => {
@@ -164854,6 +165154,7 @@ async function measureParagraphBlock(block, maxWidth) {
164854
165154
  }
164855
165155
  tabStopCursor = 0;
164856
165156
  pendingTabAlignment = null;
165157
+ pendingLeader = null;
164857
165158
  lastAppliedTabAlign = null;
164858
165159
  pendingRunSpacing = 0;
164859
165160
  continue;
@@ -164898,12 +165199,14 @@ async function measureParagraphBlock(block, maxWidth) {
164898
165199
  };
164899
165200
  tabStopCursor = 0;
164900
165201
  pendingTabAlignment = null;
165202
+ pendingLeader = null;
164901
165203
  lastAppliedTabAlign = null;
164902
165204
  pendingRunSpacing = 0;
164903
165205
  continue;
164904
165206
  }
164905
165207
  if (isTabRun$1(run2)) {
164906
165208
  activeTabGroup = null;
165209
+ pendingLeader = null;
164907
165210
  if (!currentLine)
164908
165211
  currentLine = {
164909
165212
  fromRun: runIndex,
@@ -164929,18 +165232,19 @@ async function measureParagraphBlock(block, maxWidth) {
164929
165232
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
164930
165233
  currentLine.toRun = runIndex;
164931
165234
  currentLine.toChar = 1;
165235
+ let currentLeader = null;
164932
165236
  if (stop && stop.leader && stop.leader !== "none") {
164933
165237
  const leaderStyle = stop.leader;
164934
- const relativeTarget = clampedTarget - effectiveIndent;
164935
- const from$1 = Math.min(originX, relativeTarget);
164936
- const to = Math.max(originX, relativeTarget);
165238
+ const from$1 = Math.min(originX + effectiveIndent, clampedTarget);
165239
+ const to = Math.max(originX + effectiveIndent, clampedTarget);
164937
165240
  if (!currentLine.leaders)
164938
165241
  currentLine.leaders = [];
164939
- currentLine.leaders.push({
165242
+ currentLeader = {
164940
165243
  from: from$1,
164941
165244
  to,
164942
165245
  style: leaderStyle
164943
- });
165246
+ };
165247
+ currentLine.leaders.push(currentLeader);
164944
165248
  }
164945
165249
  if (stop) {
164946
165250
  validateTabStopVal(stop);
@@ -164957,6 +165261,8 @@ async function measureParagraphBlock(block, maxWidth) {
164957
165261
  const beforeDecimal = groupMeasure.beforeDecimalWidth ?? groupMeasure.totalWidth;
164958
165262
  groupStartX = Math.max(0, relativeTarget - beforeDecimal);
164959
165263
  }
165264
+ if (currentLeader)
165265
+ currentLeader.to = groupStartX + effectiveIndent;
164960
165266
  activeTabGroup = {
164961
165267
  measure: groupMeasure,
164962
165268
  startX: groupStartX,
@@ -164967,13 +165273,16 @@ async function measureParagraphBlock(block, maxWidth) {
164967
165273
  currentLine.width = roundValue(groupStartX);
164968
165274
  }
164969
165275
  pendingTabAlignment = null;
165276
+ pendingLeader = null;
164970
165277
  } else
164971
165278
  pendingTabAlignment = {
164972
165279
  target: clampedTarget - effectiveIndent,
164973
165280
  val: stop.val
164974
165281
  };
164975
- } else
165282
+ } else {
164976
165283
  pendingTabAlignment = null;
165284
+ pendingLeader = null;
165285
+ }
164977
165286
  pendingRunSpacing = 0;
164978
165287
  continue;
164979
165288
  }
@@ -165026,6 +165335,7 @@ async function measureParagraphBlock(block, maxWidth) {
165026
165335
  lines.push(completedLine);
165027
165336
  tabStopCursor = 0;
165028
165337
  pendingTabAlignment = null;
165338
+ pendingLeader = null;
165029
165339
  lastAppliedTabAlign = null;
165030
165340
  activeTabGroup = null;
165031
165341
  currentLine = {
@@ -165125,6 +165435,7 @@ async function measureParagraphBlock(block, maxWidth) {
165125
165435
  lines.push(completedLine);
165126
165436
  tabStopCursor = 0;
165127
165437
  pendingTabAlignment = null;
165438
+ pendingLeader = null;
165128
165439
  lastAppliedTabAlign = null;
165129
165440
  currentLine = {
165130
165441
  fromRun: runIndex,
@@ -165213,6 +165524,7 @@ async function measureParagraphBlock(block, maxWidth) {
165213
165524
  lines.push(completedLine);
165214
165525
  tabStopCursor = 0;
165215
165526
  pendingTabAlignment = null;
165527
+ pendingLeader = null;
165216
165528
  lastAppliedTabAlign = null;
165217
165529
  currentLine = {
165218
165530
  fromRun: runIndex,
@@ -165299,6 +165611,7 @@ async function measureParagraphBlock(block, maxWidth) {
165299
165611
  lines.push(completedLine);
165300
165612
  tabStopCursor = 0;
165301
165613
  pendingTabAlignment = null;
165614
+ pendingLeader = null;
165302
165615
  lastAppliedTabAlign = null;
165303
165616
  activeTabGroup = null;
165304
165617
  currentLine = {
@@ -165355,6 +165668,7 @@ async function measureParagraphBlock(block, maxWidth) {
165355
165668
  lines.push(completedLine);
165356
165669
  tabStopCursor = 0;
165357
165670
  pendingTabAlignment = null;
165671
+ pendingLeader = null;
165358
165672
  currentLine = null;
165359
165673
  }
165360
165674
  const lineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
@@ -165399,6 +165713,7 @@ async function measureParagraphBlock(block, maxWidth) {
165399
165713
  lines.push(completedLine);
165400
165714
  tabStopCursor = 0;
165401
165715
  pendingTabAlignment = null;
165716
+ pendingLeader = null;
165402
165717
  currentLine = null;
165403
165718
  }
165404
165719
  } else if (isLastChunk) {
@@ -165518,6 +165833,7 @@ async function measureParagraphBlock(block, maxWidth) {
165518
165833
  lines.push(completedLine);
165519
165834
  tabStopCursor = 0;
165520
165835
  pendingTabAlignment = null;
165836
+ pendingLeader = null;
165521
165837
  currentLine = {
165522
165838
  fromRun: runIndex,
165523
165839
  fromChar: wordStartChar,
@@ -165570,6 +165886,7 @@ async function measureParagraphBlock(block, maxWidth) {
165570
165886
  lines.push(completedLine);
165571
165887
  tabStopCursor = 0;
165572
165888
  pendingTabAlignment = null;
165889
+ pendingLeader = null;
165573
165890
  currentLine = null;
165574
165891
  charPosInRun = wordEndNoSpace + 1;
165575
165892
  continue;
@@ -165607,6 +165924,7 @@ async function measureParagraphBlock(block, maxWidth) {
165607
165924
  }
165608
165925
  if (!isLastSegment) {
165609
165926
  pendingTabAlignment = null;
165927
+ pendingLeader = null;
165610
165928
  if (!currentLine)
165611
165929
  currentLine = {
165612
165930
  fromRun: runIndex,
@@ -165640,20 +165958,23 @@ async function measureParagraphBlock(block, maxWidth) {
165640
165958
  target: clampedTarget - effectiveIndent,
165641
165959
  val: stop.val
165642
165960
  };
165643
- } else
165961
+ } else {
165644
165962
  pendingTabAlignment = null;
165963
+ pendingLeader = null;
165964
+ }
165645
165965
  if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
165646
165966
  const leaderStyle = stop.leader;
165647
- const relativeTarget = clampedTarget - effectiveIndent;
165648
- const from$1 = Math.min(originX, relativeTarget);
165649
- const to = Math.max(originX, relativeTarget);
165967
+ const from$1 = Math.min(originX + effectiveIndent, clampedTarget);
165968
+ const to = Math.max(originX + effectiveIndent, clampedTarget);
165650
165969
  if (!currentLine.leaders)
165651
165970
  currentLine.leaders = [];
165652
- currentLine.leaders.push({
165971
+ const leader = {
165653
165972
  from: from$1,
165654
165973
  to,
165655
165974
  style: leaderStyle
165656
- });
165975
+ };
165976
+ currentLine.leaders.push(leader);
165977
+ pendingLeader = leader;
165657
165978
  }
165658
165979
  }
165659
165980
  }
@@ -197681,7 +198002,8 @@ function findAllBibliographies(doc$12) {
197681
198002
  let occurrenceIndex = 0;
197682
198003
  doc$12.descendants((node3, pos) => {
197683
198004
  if (node3.type.name === "bibliography") {
197684
- const commandNodeId = node3.attrs?.sdBlockId;
198005
+ const rawBlockId = node3.attrs?.sdBlockId;
198006
+ const commandNodeId = rawBlockId != null ? String(rawBlockId) : undefined;
197685
198007
  const nodeId = resolvePublicReferenceBlockNodeId(node3, occurrenceIndex);
197686
198008
  occurrenceIndex += 1;
197687
198009
  results.push({
@@ -197754,9 +198076,9 @@ function resolveSourceTarget(editor, target) {
197754
198076
  function resolveParentBlockId$1(doc$12, pos) {
197755
198077
  const resolved = doc$12.resolve(pos);
197756
198078
  for (let depth = resolved.depth;depth >= 0; depth--) {
197757
- const blockId = resolved.node(depth).attrs?.sdBlockId;
197758
- if (blockId)
197759
- return blockId;
198079
+ const rawBlockId = resolved.node(depth).attrs?.sdBlockId;
198080
+ if (rawBlockId != null)
198081
+ return String(rawBlockId);
197760
198082
  }
197761
198083
  return "";
197762
198084
  }
@@ -198104,10 +198426,11 @@ function bibliographyInsertWrapper(editor, input2, options) {
198104
198426
  function bibliographyConfigureWrapper(editor, input2, options) {
198105
198427
  rejectTrackedMode("citations.bibliography.configure", options);
198106
198428
  const resolved = resolveBibliographyTarget(editor.state.doc, input2.target);
198429
+ const stableNodeId = resolved.commandNodeId ?? resolved.nodeId;
198107
198430
  const address2 = {
198108
198431
  kind: "block",
198109
198432
  nodeType: "bibliography",
198110
- nodeId: resolved.nodeId
198433
+ nodeId: stableNodeId
198111
198434
  };
198112
198435
  if (options?.dryRun)
198113
198436
  return bibSuccess(address2);
@@ -198125,7 +198448,12 @@ function bibliographyConfigureWrapper(editor, input2, options) {
198125
198448
  }, { expectedRevision: options?.expectedRevision })))
198126
198449
  return bibFailure("NO_OP", "Configure produced no change.");
198127
198450
  syncBibliographyStyleToConverter(editor, input2.style);
198128
- return bibSuccess(address2);
198451
+ const bibliographies = findAllBibliographies(editor.state.doc);
198452
+ return bibSuccess({
198453
+ kind: "block",
198454
+ nodeType: "bibliography",
198455
+ nodeId: (bibliographies.find((bibliography) => bibliography.pos === resolved.pos) ?? bibliographies.find((bibliography) => bibliography.commandNodeId === stableNodeId))?.nodeId ?? resolvePostMutationBibliographyId(editor.state.doc, stableNodeId)
198456
+ });
198129
198457
  }
198130
198458
  function bibliographyRebuildWrapper(editor, input2, options) {
198131
198459
  rejectTrackedMode("citations.bibliography.rebuild", options);
@@ -221376,7 +221704,25 @@ var Node$13 = class Node$14 {
221376
221704
  this.onMouseLeave = null;
221377
221705
  this.hoveredSdtId = null;
221378
221706
  }
221379
- }, cssToken = (varName, fallback) => ({
221707
+ }, isRtlParagraph = (attrs) => attrs?.direction === "rtl" || attrs?.rtl === true, resolveTextAlign = (alignment$1, isRtl) => {
221708
+ switch (alignment$1) {
221709
+ case "center":
221710
+ case "right":
221711
+ case "left":
221712
+ return alignment$1;
221713
+ case "justify":
221714
+ default:
221715
+ return isRtl ? "right" : "left";
221716
+ }
221717
+ }, applyRtlStyles = (element3, attrs) => {
221718
+ const rtl = isRtlParagraph(attrs);
221719
+ if (rtl) {
221720
+ element3.setAttribute("dir", "rtl");
221721
+ element3.style.direction = "rtl";
221722
+ }
221723
+ element3.style.textAlign = resolveTextAlign(attrs?.alignment, rtl);
221724
+ return rtl;
221725
+ }, shouldUseSegmentPositioning = (hasExplicitPositioning, hasSegments, isRtl) => hasExplicitPositioning && hasSegments && !isRtl, cssToken = (varName, fallback) => ({
221380
221726
  css: `var(${varName}, ${fallback})`,
221381
221727
  fallback
221382
221728
  }), LIST_MARKER_GAP = 8, DEFAULT_PAGE_HEIGHT_PX = 1056, DEFAULT_VIRTUALIZED_PAGE_GAP = 72, COMMENT_HIGHLIGHT_EXTERNAL, COMMENT_HIGHLIGHT_EXTERNAL_ACTIVE, COMMENT_HIGHLIGHT_EXTERNAL_FADED, COMMENT_HIGHLIGHT_INTERNAL, COMMENT_HIGHLIGHT_INTERNAL_ACTIVE, COMMENT_HIGHLIGHT_INTERNAL_FADED, COMMENT_HIGHLIGHT_EXTERNAL_NESTED_BORDER, COMMENT_HIGHLIGHT_INTERNAL_NESTED_BORDER, LINK_DATASET_KEYS, MAX_HREF_LENGTH = 2048, SAFE_ANCHOR_PATTERN, MAX_DATA_URL_LENGTH, VALID_IMAGE_DATA_URL, MAX_RESIZE_MULTIPLIER = 3, FALLBACK_MAX_DIMENSION = 1000, MIN_IMAGE_DIMENSION = 20, AMBIGUOUS_LINK_PATTERNS, linkMetrics, TRACK_CHANGE_BASE_CLASS, TRACK_CHANGE_FOCUSED_CLASS = "track-change-focused", TRACK_CHANGE_MODIFIER_CLASS, LINK_TARGET_SET, normalizeAnchor$1 = (value) => {
@@ -222043,27 +222389,12 @@ var Node$13 = class Node$14 {
222043
222389
  console.warn(`[DomPainter] Failed to set data attribute "${key$1}":`, error);
222044
222390
  }
222045
222391
  });
222046
- }, resolveParagraphDirection = (attrs) => {
222047
- if (attrs?.direction)
222048
- return attrs.direction;
222049
- if (attrs?.rtl === true)
222050
- return "rtl";
222051
- if (attrs?.rtl === false)
222052
- return "ltr";
222053
- }, applyParagraphDirection = (element3, attrs) => {
222054
- const direction = resolveParagraphDirection(attrs);
222055
- if (!direction)
222056
- return;
222057
- element3.setAttribute("dir", direction);
222058
- element3.style.direction = direction;
222059
222392
  }, applyParagraphBlockStyles = (element3, attrs) => {
222060
222393
  if (!attrs)
222061
222394
  return;
222062
222395
  if (attrs.styleId)
222063
222396
  element3.setAttribute("styleid", attrs.styleId);
222064
- applyParagraphDirection(element3, attrs);
222065
- if (attrs.alignment)
222066
- element3.style.textAlign = attrs.alignment === "justify" ? "left" : attrs.alignment;
222397
+ applyRtlStyles(element3, attrs);
222067
222398
  if (attrs.dropCap)
222068
222399
  element3.classList.add("sd-editor-dropcap");
222069
222400
  const indent2 = attrs.indent;
@@ -225930,7 +226261,7 @@ var Node$13 = class Node$14 {
225930
226261
  return;
225931
226262
  const trimmed = value.trim();
225932
226263
  return trimmed ? trimmed : undefined;
225933
- }, AUTO_SPACING_DEFAULT_MULTIPLIER = 1.15, AUTO_SPACING_LINE_DEFAULT = 240, normalizeAlignment = (value) => {
226264
+ }, AUTO_SPACING_DEFAULT_MULTIPLIER = 1.15, AUTO_SPACING_LINE_DEFAULT = 240, normalizeAlignment = (value, isRtl = false) => {
225934
226265
  switch (value) {
225935
226266
  case "center":
225936
226267
  case "right":
@@ -225941,11 +226272,14 @@ var Node$13 = class Node$14 {
225941
226272
  case "distribute":
225942
226273
  case "numTab":
225943
226274
  case "thaiDistribute":
226275
+ case "lowKashida":
226276
+ case "mediumKashida":
226277
+ case "highKashida":
225944
226278
  return "justify";
225945
226279
  case "end":
225946
- return "right";
226280
+ return isRtl ? "left" : "right";
225947
226281
  case "start":
225948
- return "left";
226282
+ return isRtl ? "right" : "left";
225949
226283
  default:
225950
226284
  return;
225951
226285
  }
@@ -226205,10 +226539,11 @@ var Node$13 = class Node$14 {
226205
226539
  resolvedParagraphProperties = paragraphProperties;
226206
226540
  else
226207
226541
  resolvedParagraphProperties = resolveParagraphProperties(converterContext, paragraphProperties, converterContext.tableInfo);
226542
+ const isRtl = resolvedParagraphProperties.rightToLeft === true;
226208
226543
  const normalizedSpacing = normalizeParagraphSpacing(resolvedParagraphProperties.spacing, Boolean(resolvedParagraphProperties.numberingProperties));
226209
226544
  const normalizedIndent = normalizeIndentTwipsToPx(resolvedParagraphProperties.indent);
226210
226545
  const normalizedTabStops = normalizeOoxmlTabs(resolvedParagraphProperties.tabStops);
226211
- const normalizedAlignment = normalizeAlignment(resolvedParagraphProperties.justification);
226546
+ const normalizedAlignment = normalizeAlignment(resolvedParagraphProperties.justification, isRtl);
226212
226547
  const normalizedBorders = normalizeParagraphBorders(resolvedParagraphProperties.borders);
226213
226548
  const normalizedShading = normalizeParagraphShading(resolvedParagraphProperties.shading);
226214
226549
  const paragraphDecimalSeparator = DEFAULT_DECIMAL_SEPARATOR;
@@ -226237,8 +226572,10 @@ var Node$13 = class Node$14 {
226237
226572
  keepLines: resolvedParagraphProperties.keepLines,
226238
226573
  floatAlignment,
226239
226574
  pageBreakBefore: resolvedParagraphProperties.pageBreakBefore,
226240
- direction: normalizedDirection,
226241
- rtl: normalizedDirection === "rtl" ? true : normalizedDirection === "ltr" ? false : undefined
226575
+ ...normalizedDirection ? {
226576
+ direction: normalizedDirection,
226577
+ rtl: isRtl
226578
+ } : {}
226242
226579
  };
226243
226580
  if (normalizedNumberingProperties && normalizedListRendering) {
226244
226581
  const markerRunAttrs = computeRunAttrs(resolveRunProperties(converterContext, resolvedParagraphProperties.runProperties, resolvedParagraphProperties, converterContext.tableInfo, true, Boolean(paragraphProperties.numberingProperties)), converterContext);
@@ -228757,16 +229094,17 @@ var Node$13 = class Node$14 {
228757
229094
  const originX = cursorX;
228758
229095
  const { target, nextIndex, stop } = getNextTabStopPx(cursorX + effectiveIndent, tabStops, tabStopCursor);
228759
229096
  tabStopCursor = nextIndex;
228760
- const relativeTarget = (Number.isFinite(maxAbsWidth) ? Math.min(target, maxAbsWidth) : target) - effectiveIndent;
229097
+ const clampedTarget = Number.isFinite(maxAbsWidth) ? Math.min(target, maxAbsWidth) : target;
229098
+ const relativeTarget = clampedTarget - effectiveIndent;
228761
229099
  lineWidth = Math.max(lineWidth, relativeTarget);
229100
+ let currentLeader = null;
228762
229101
  if (stop?.leader && stop.leader !== "none") {
228763
- const from$1 = Math.min(originX, relativeTarget);
228764
- const to = Math.max(originX, relativeTarget);
228765
- leaders.push({
228766
- from: from$1,
228767
- to,
229102
+ currentLeader = {
229103
+ from: Math.min(originX + effectiveIndent, clampedTarget),
229104
+ to: Math.max(originX + effectiveIndent, clampedTarget),
228768
229105
  style: stop.leader
228769
- });
229106
+ };
229107
+ leaders.push(currentLeader);
228770
229108
  }
228771
229109
  const stopVal = stop?.val ?? "start";
228772
229110
  if (stopVal === "end" || stopVal === "center" || stopVal === "decimal") {
@@ -228781,6 +229119,8 @@ var Node$13 = class Node$14 {
228781
229119
  const beforeDecimal = groupMeasure.beforeDecimalWidth ?? groupMeasure.totalWidth;
228782
229120
  groupStartX = Math.max(0, relativeTarget - beforeDecimal);
228783
229121
  }
229122
+ if (currentLeader)
229123
+ currentLeader.to = groupStartX + effectiveIndent;
228784
229124
  pendingTabAlignStartX = groupStartX;
228785
229125
  } else
228786
229126
  cursorX = Math.max(cursorX, relativeTarget);
@@ -233865,16 +234205,16 @@ var Node$13 = class Node$14 {
233865
234205
  return;
233866
234206
  console.log(...args$1);
233867
234207
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
233868
- var init_src_1kVu_IvJ_es = __esm(() => {
234208
+ var init_src_8sGn3qa5_es = __esm(() => {
233869
234209
  init_rolldown_runtime_B2q5OVn9_es();
233870
- init_SuperConverter_V_8WDjnK_es();
234210
+ init_SuperConverter_C9MZOwsC_es();
233871
234211
  init_jszip_ChlR43oI_es();
233872
234212
  init_uuid_qzgm05fK_es();
233873
- init_constants_CMPtQbp7_es();
234213
+ init_constants_Qqwopz80_es();
233874
234214
  init_unified_BRHLwnjP_es();
233875
234215
  init_remark_gfm_z_sDF4ss_es();
233876
234216
  init_remark_stringify_D8vxv_XI_es();
233877
- init_DocxZipper_BBJ5zSyW_es();
234217
+ init_DocxZipper_gWkmvJfR_es();
233878
234218
  init_vue_LcaAh_pz_es();
233879
234219
  init__plugin_vue_export_helper_DBsdbQXw_es();
233880
234220
  init_eventemitter3_C8I7im8Y_es();
@@ -236361,7 +236701,8 @@ ${err.toString()}`);
236361
236701
  },
236362
236702
  id: {},
236363
236703
  docPartGallery: {},
236364
- docPartUnique: { default: true }
236704
+ docPartUnique: { default: false },
236705
+ wrapperParagraph: { default: null }
236365
236706
  };
236366
236707
  }
236367
236708
  });
@@ -254499,16 +254840,11 @@ function print() { __p += __j.call(arguments, '') }
254499
254840
  el.classList.add(CLASS_NAMES$1.line);
254500
254841
  applyStyles(el, lineStyles(line.lineHeight));
254501
254842
  el.dataset.layoutEpoch = String(this.layoutEpoch);
254502
- const paragraphAttrs = block.attrs ?? {};
254503
- const styleId = paragraphAttrs.styleId;
254843
+ const styleId = (block.attrs ?? {}).styleId;
254504
254844
  if (styleId)
254505
254845
  el.setAttribute("styleid", styleId);
254506
- applyParagraphDirection(el, paragraphAttrs);
254507
- const alignment$1 = paragraphAttrs.alignment;
254508
- if (alignment$1 === "center" || alignment$1 === "right")
254509
- el.style.textAlign = alignment$1;
254510
- else
254511
- el.style.textAlign = "left";
254846
+ const pAttrs = block.attrs;
254847
+ const isRtl = applyRtlStyles(el, pAttrs);
254512
254848
  if (lineRange.pmStart != null)
254513
254849
  el.dataset.pmStart = String(lineRange.pmStart);
254514
254850
  if (lineRange.pmEnd != null)
@@ -254706,7 +255042,7 @@ function print() { __p += __j.call(arguments, '') }
254706
255042
  });
254707
255043
  if (spacingPerSpace !== 0)
254708
255044
  el.style.wordSpacing = `${spacingPerSpace}px`;
254709
- if (hasExplicitPositioning && line.segments) {
255045
+ if (shouldUseSegmentPositioning(hasExplicitPositioning ?? false, Boolean(line.segments), isRtl)) {
254710
255046
  const paraIndent = block.attrs?.indent;
254711
255047
  const indentLeft = paraIndent?.left ?? 0;
254712
255048
  const firstLine = paraIndent?.firstLine ?? 0;
@@ -254719,8 +255055,9 @@ function print() { __p += __j.call(arguments, '') }
254719
255055
  const fallbackListTextStartPx = typeof wordLayout?.marker?.textStartX === "number" && Number.isFinite(wordLayout.marker.textStartX) ? wordLayout.marker.textStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : undefined;
254720
255056
  const indentOffset = isListParagraph ? isFirstLineOfPara ? resolvedListTextStartPx ?? fallbackListTextStartPx ?? indentLeft : indentLeft : indentLeft + firstLineOffsetForCumX;
254721
255057
  let cumulativeX = 0;
255058
+ const segments = line.segments;
254722
255059
  const segmentsByRun = /* @__PURE__ */ new Map;
254723
- line.segments.forEach((segment) => {
255060
+ segments.forEach((segment) => {
254724
255061
  const list5 = segmentsByRun.get(segment.runIndex);
254725
255062
  if (list5)
254726
255063
  list5.push(segment);
@@ -267187,13 +267524,13 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
267187
267524
 
267188
267525
  // ../../packages/superdoc/dist/super-editor.es.js
267189
267526
  var init_super_editor_es = __esm(() => {
267190
- init_src_1kVu_IvJ_es();
267191
- init_SuperConverter_V_8WDjnK_es();
267527
+ init_src_8sGn3qa5_es();
267528
+ init_SuperConverter_C9MZOwsC_es();
267192
267529
  init_jszip_ChlR43oI_es();
267193
- init_xml_js_DLE8mr0n_es();
267194
- init_constants_CMPtQbp7_es();
267530
+ init_xml_js_40FWvL78_es();
267531
+ init_constants_Qqwopz80_es();
267195
267532
  init_unified_BRHLwnjP_es();
267196
- init_DocxZipper_BBJ5zSyW_es();
267533
+ init_DocxZipper_gWkmvJfR_es();
267197
267534
  init_vue_LcaAh_pz_es();
267198
267535
  init_eventemitter3_C8I7im8Y_es();
267199
267536
  init_zipper_DqXT7uTa_es();
@@ -318169,7 +318506,7 @@ var require_src = __commonJS((exports) => {
318169
318506
  exports.retry = retry;
318170
318507
  });
318171
318508
 
318172
- // ../../node_modules/.pnpm/@hocuspocus+provider@2.15.3_y-protocols@1.0.7_yjs@13.6.19__yjs@13.6.19/node_modules/@hocuspocus/provider/dist/hocuspocus-provider.esm.js
318509
+ // ../../node_modules/.pnpm/@hocuspocus+provider@2.15.3_y-protocols@1.0.7_yjs@13.6.30__yjs@13.6.30/node_modules/@hocuspocus/provider/dist/hocuspocus-provider.esm.js
318173
318510
  class VarStoragePolyfill3 {
318174
318511
  constructor() {
318175
318512
  this.map = new Map;
@@ -319856,7 +320193,7 @@ var init_broadcastchannel = __esm(() => {
319856
320193
  BC2 = typeof BroadcastChannel === "undefined" ? LocalStoragePolyfill2 : BroadcastChannel;
319857
320194
  });
319858
320195
 
319859
- // ../../node_modules/.pnpm/y-protocols@1.0.7_yjs@13.6.19/node_modules/y-protocols/sync.js
320196
+ // ../../node_modules/.pnpm/y-protocols@1.0.7_yjs@13.6.30/node_modules/y-protocols/sync.js
319860
320197
  var messageYjsSyncStep12 = 0, messageYjsSyncStep22 = 1, messageYjsUpdate2 = 2, writeSyncStep12 = (encoder, doc4) => {
319861
320198
  writeVarUint(encoder, messageYjsSyncStep12);
319862
320199
  const sv = encodeStateVector(doc4);
@@ -319899,7 +320236,7 @@ var init_sync = __esm(() => {
319899
320236
  readUpdate2 = readSyncStep22;
319900
320237
  });
319901
320238
 
319902
- // ../../node_modules/.pnpm/y-protocols@1.0.7_yjs@13.6.19/node_modules/y-protocols/auth.js
320239
+ // ../../node_modules/.pnpm/y-protocols@1.0.7_yjs@13.6.30/node_modules/y-protocols/auth.js
319903
320240
  var messagePermissionDenied = 0, readAuthMessage2 = (decoder, y3, permissionDeniedHandler) => {
319904
320241
  switch (readVarUint(decoder)) {
319905
320242
  case messagePermissionDenied:
@@ -319910,7 +320247,7 @@ var init_auth = __esm(() => {
319910
320247
  init_decoding();
319911
320248
  });
319912
320249
 
319913
- // ../../node_modules/.pnpm/y-protocols@1.0.7_yjs@13.6.19/node_modules/y-protocols/awareness.js
320250
+ // ../../node_modules/.pnpm/y-protocols@1.0.7_yjs@13.6.30/node_modules/y-protocols/awareness.js
319914
320251
  var outdatedTimeout2 = 30000, Awareness2, removeAwarenessStates2 = (awareness, clients, origin) => {
319915
320252
  const removed = [];
319916
320253
  for (let i4 = 0;i4 < clients.length; i4++) {
@@ -320099,7 +320436,7 @@ var init_url = __esm(() => {
320099
320436
  init_object();
320100
320437
  });
320101
320438
 
320102
- // ../../node_modules/.pnpm/y-websocket@3.0.0_yjs@13.6.19/node_modules/y-websocket/src/y-websocket.js
320439
+ // ../../node_modules/.pnpm/y-websocket@3.0.0_yjs@13.6.30/node_modules/y-websocket/src/y-websocket.js
320103
320440
  var messageSync = 0, messageQueryAwareness = 3, messageAwareness = 1, messageAuth = 2, messageHandlers, messageReconnectTimeout = 30000, permissionDeniedHandler = (provider, reason2) => console.warn(`Permission denied to access ${provider.url}.
320104
320441
  ${reason2}`), readMessage = (provider, buf, emitSynced) => {
320105
320442
  const decoder = createDecoder(buf);