@embedpdf/engine-core 3.0.0-next.14 → 3.0.0-next.16

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 (135) hide show
  1. package/dist/AnnotationList-DcyhF2kU.d.cts +27691 -0
  2. package/dist/AnnotationList-DcyhF2kU.d.ts +27691 -0
  3. package/dist/Change-Ct-dB8D5.cjs +1133 -0
  4. package/dist/Change-Ct-dB8D5.cjs.map +1 -0
  5. package/dist/Change-tMR34hTU.js +978 -0
  6. package/dist/Change-tMR34hTU.js.map +1 -0
  7. package/dist/DocumentRenderService-9IjSQEIU.cjs +121 -0
  8. package/dist/DocumentRenderService-9IjSQEIU.cjs.map +1 -0
  9. package/dist/DocumentRenderService-DFrZ9wfW.js +86 -0
  10. package/dist/DocumentRenderService-DFrZ9wfW.js.map +1 -0
  11. package/dist/{DocumentSecurityService-Ca6EK3-3.d.ts → DocumentSecurityService-D2zA4NKi.d.cts} +100 -112
  12. package/dist/{DocumentSecurityService-CIx1MT0T.d.cts → DocumentSecurityService-YJV9df8P.d.ts} +100 -112
  13. package/dist/LocalDocumentHandle-D02FMm-Z.cjs +53 -0
  14. package/dist/LocalDocumentHandle-D02FMm-Z.cjs.map +1 -0
  15. package/dist/LocalDocumentHandle-DAPdaOt_.js +30 -0
  16. package/dist/LocalDocumentHandle-DAPdaOt_.js.map +1 -0
  17. package/dist/LocalEngine-DBt2-GWF.d.ts +1649 -0
  18. package/dist/LocalEngine-IA9zh3Jh.d.cts +1649 -0
  19. package/dist/PageInsertBlankInput-CXHAM7l6.cjs +17 -0
  20. package/dist/PageInsertBlankInput-CXHAM7l6.cjs.map +1 -0
  21. package/dist/PageInsertBlankInput-DhVYVJ_S.js +12 -0
  22. package/dist/PageInsertBlankInput-DhVYVJ_S.js.map +1 -0
  23. package/dist/authority-BFp6XM04.cjs +2997 -0
  24. package/dist/authority-BFp6XM04.cjs.map +1 -0
  25. package/dist/authority-PuxpGFhJ.js +2506 -0
  26. package/dist/authority-PuxpGFhJ.js.map +1 -0
  27. package/dist/builders-DV62HA3I.js +165 -0
  28. package/dist/builders-DV62HA3I.js.map +1 -0
  29. package/dist/builders-DgTAj_tP.cjs +188 -0
  30. package/dist/builders-DgTAj_tP.cjs.map +1 -0
  31. package/dist/calibrate-DJbi1wuK.cjs +3012 -0
  32. package/dist/calibrate-DJbi1wuK.cjs.map +1 -0
  33. package/dist/calibrate-nQFgCuki.js +2461 -0
  34. package/dist/calibrate-nQFgCuki.js.map +1 -0
  35. package/dist/charmap-Cprti1ta.js +239 -0
  36. package/dist/charmap-Cprti1ta.js.map +1 -0
  37. package/dist/charmap-aYlefQP9.cjs +304 -0
  38. package/dist/charmap-aYlefQP9.cjs.map +1 -0
  39. package/dist/conformance.cjs +18146 -5258
  40. package/dist/conformance.cjs.map +1 -1
  41. package/dist/conformance.d.cts +1024 -170
  42. package/dist/conformance.d.ts +1024 -170
  43. package/dist/conformance.js +18148 -5309
  44. package/dist/conformance.js.map +1 -1
  45. package/dist/format-Bp3QFSH1.cjs +574 -0
  46. package/dist/format-Bp3QFSH1.cjs.map +1 -0
  47. package/dist/format-Dgg428Kb.js +461 -0
  48. package/dist/format-Dgg428Kb.js.map +1 -0
  49. package/dist/index.cjs +342 -116
  50. package/dist/index.d.cts +2 -2
  51. package/dist/index.d.ts +2 -2
  52. package/dist/index.js +14 -5
  53. package/dist/pageRefs-B3ur7Ckm.cjs +51 -0
  54. package/dist/pageRefs-B3ur7Ckm.cjs.map +1 -0
  55. package/dist/pageRefs-DkbuxSCV.js +40 -0
  56. package/dist/pageRefs-DkbuxSCV.js.map +1 -0
  57. package/dist/public.cjs +59 -0
  58. package/dist/public.d.cts +5 -0
  59. package/dist/public.d.ts +5 -0
  60. package/dist/public.js +9 -0
  61. package/dist/resolveAnnotationDraft-7Ke4nV7F.cjs +3646 -0
  62. package/dist/resolveAnnotationDraft-7Ke4nV7F.cjs.map +1 -0
  63. package/dist/resolveAnnotationDraft-CUpf0SMh.js +3167 -0
  64. package/dist/resolveAnnotationDraft-CUpf0SMh.js.map +1 -0
  65. package/dist/{resolver-inAVzsWt.js → resolver-BBggAxQc.js} +298 -145
  66. package/dist/resolver-BBggAxQc.js.map +1 -0
  67. package/dist/{resolver-CYVNV4hn.cjs → resolver-BWSWSF6R.cjs} +351 -144
  68. package/dist/resolver-BWSWSF6R.cjs.map +1 -0
  69. package/dist/runtime-BaDKjxiu.d.ts +1959 -0
  70. package/dist/runtime-CWEuiwbk.d.cts +1959 -0
  71. package/dist/runtime.cjs +986 -297
  72. package/dist/runtime.cjs.map +1 -1
  73. package/dist/runtime.d.cts +5 -1372
  74. package/dist/runtime.d.ts +5 -1372
  75. package/dist/runtime.js +634 -179
  76. package/dist/runtime.js.map +1 -1
  77. package/dist/schema-6S2VmlAj.js +2087 -0
  78. package/dist/schema-6S2VmlAj.js.map +1 -0
  79. package/dist/schema-miH6tWQC.cjs +3046 -0
  80. package/dist/schema-miH6tWQC.cjs.map +1 -0
  81. package/dist/schemas-BE2QGOit.js +1851 -0
  82. package/dist/schemas-BE2QGOit.js.map +1 -0
  83. package/dist/schemas-DljJR9ut.cjs +2798 -0
  84. package/dist/schemas-DljJR9ut.cjs.map +1 -0
  85. package/dist/subtype-CG4WpIRj.js +129 -0
  86. package/dist/subtype-CG4WpIRj.js.map +1 -0
  87. package/dist/subtype-aDt5TFmK.cjs +158 -0
  88. package/dist/subtype-aDt5TFmK.cjs.map +1 -0
  89. package/dist/validation.cjs +578 -0
  90. package/dist/validation.cjs.map +1 -0
  91. package/dist/validation.d.cts +174 -0
  92. package/dist/validation.d.ts +174 -0
  93. package/dist/validation.js +571 -0
  94. package/dist/validation.js.map +1 -0
  95. package/dist/value-BFS1R8ek.cjs +435 -0
  96. package/dist/value-BFS1R8ek.cjs.map +1 -0
  97. package/dist/value-Dhc8eYcx.js +340 -0
  98. package/dist/value-Dhc8eYcx.js.map +1 -0
  99. package/dist/viewport-CHG9qQUb.cjs +671 -0
  100. package/dist/viewport-CHG9qQUb.cjs.map +1 -0
  101. package/dist/viewport-DQR5LyX3.js +540 -0
  102. package/dist/viewport-DQR5LyX3.js.map +1 -0
  103. package/dist/wire.cjs +1242 -420
  104. package/dist/wire.cjs.map +1 -1
  105. package/dist/wire.d.cts +14840 -830
  106. package/dist/wire.d.ts +14840 -830
  107. package/dist/wire.js +985 -261
  108. package/dist/wire.js.map +1 -1
  109. package/package.json +10 -1
  110. package/dist/AbortError-DwuHPK_I.js +0 -27
  111. package/dist/AbortError-DwuHPK_I.js.map +0 -1
  112. package/dist/AbortError-P0RU0Mgg.cjs +0 -38
  113. package/dist/AbortError-P0RU0Mgg.cjs.map +0 -1
  114. package/dist/AnnotationListSnapshot-D9R5n2Kf.d.cts +0 -7101
  115. package/dist/AnnotationListSnapshot-D9R5n2Kf.d.ts +0 -7101
  116. package/dist/Engine-EWWHhEIi.d.ts +0 -1277
  117. package/dist/Engine-FNaAEjfb.d.cts +0 -1277
  118. package/dist/derive-BbsDk_Kz.cjs +0 -880
  119. package/dist/derive-BbsDk_Kz.cjs.map +0 -1
  120. package/dist/derive-DAFJolWu.js +0 -647
  121. package/dist/derive-DAFJolWu.js.map +0 -1
  122. package/dist/format-Bbphf4zR.js +0 -435
  123. package/dist/format-Bbphf4zR.js.map +0 -1
  124. package/dist/format-D_epWlob.cjs +0 -518
  125. package/dist/format-D_epWlob.cjs.map +0 -1
  126. package/dist/resolver-CYVNV4hn.cjs.map +0 -1
  127. package/dist/resolver-inAVzsWt.js.map +0 -1
  128. package/dist/schemas-CFQGvWiu.js +0 -3243
  129. package/dist/schemas-CFQGvWiu.js.map +0 -1
  130. package/dist/schemas-D0g6tKa9.cjs +0 -4694
  131. package/dist/schemas-D0g6tKa9.cjs.map +0 -1
  132. package/dist/viewport-BWeNHZmb.cjs +0 -3503
  133. package/dist/viewport-BWeNHZmb.cjs.map +0 -1
  134. package/dist/viewport-CvMcadfQ.js +0 -3072
  135. package/dist/viewport-CvMcadfQ.js.map +0 -1
package/dist/runtime.js CHANGED
@@ -1,128 +1,412 @@
1
- import { $ as shiftsExistingAnnotationIndices, A as EdgeResolver, B as worstVerdict, C as validateSearchQuery, D as wordAt, E as matchLiteral, F as sameEffectiveValue, G as refsOf, H as dictEntries, I as assessmentOf, J as encodeFieldRefKey, K as stableStringify, L as combine, M as restrictionsFor, N as evaluateStep, O as wordBefore, P as restrictionsOf, Q as invalidatesWeakIndexRefs, R as conclude, S as matchRegex, T as foldOptionsFor, U as parsePdfValue, V as changedKeys, W as pdfValueEquals, X as semanticEqual, Y as appearanceImpactOf, Z as changesAnnotationList, _ as textSegmentsForRange, _t as createPageImageHandle, a as pdfPermissions, at as sniffBinaryMetadata, b as matchPageText, c as canonicalSearchQuery, ct as UNKNOWN_WEAK_ANNOTATION_STATE, d as searchSegmentsForRange, dt as decodeStableIdKey, et as buildCommentThreads, f as buildPageTextLayout, ft as encodeStableIdKey, g as textGlyphQuad, gt as DEFAULT_PDF_SAVE_MODE, h as textGlyphAt, ht as richTextPlainText, i as materializePdfPermissions, it as normalizeAttachmentFileSource, j as USAGE_INCOMPLETE, k as DEFAULT_EDGE_RESOLVER_BUDGET, l as searchContentEpoch, lt as knownWeakAnnotationState, m as expandTextRangeToWord, mt as richTextParagraphsFromPlainText, n as caps, nt as normalizeAnnotationDraft, o as PDF_BITS, ot as resolveBinarySource, p as expandTextRangeToLine, pt as isValidPageObjectNumber, q as decodeFieldRefKey, r as collab, rt as normalizeAnnotationPatch, s as decodePdfBits, st as NO_ANNOTATION_FLAGS, t as viewportForPoint, tt as isStateAnnotation, u as searchRectsForRange, ut as revisionTokensEqual, v as SEARCH_SNIPPET_CONTEXT, vt as decodeSubmitFormFlags, w as validateSearchRegex, x as SEARCH_REGEX_MAX_LENGTH, y as buildSnippet, z as primaryFinding } from "./viewport-CvMcadfQ.js";
2
- import { A as isRotatedGeometryRun, C as refKey, D as _defineProperty, E as serializeError, F as pdfRectFromOriginSize, I as pdfRectHeight, L as pdfRectSize, M as pdfQuadBounds, N as pdfQuadCorners, O as glyphLooseBounds, P as pdfQuadFromCorners, R as pdfRectToOriginSize, S as classifyRelation, T as deserializeError, _ as assertWritableMeasure, a as measurementPoint, b as toOriginalRange, c as scaleOf, d as measureFromRatio, f as METRES, g as assertPdfFloat, h as squareOf, i as measurementReadout, j as normalizePdfRect, k as glyphLooseQuad, l as validAreaBoundary, m as squareMetres, n as isDimension, o as pathLength, p as areaUnitLabel, r as isReadout, s as polygonArea, t as deriveMeasurementLabel, u as measureFromKnownLength, v as SEARCH_FOLD_VERSION, w as EngineError, x as buildThreads, y as foldText, z as pdfRectWidth } from "./derive-DAFJolWu.js";
3
- import { a as charBoundaryAtTextOffset, c as sliceTextByChars, d as PDF_SUBTYPE_TO_CODE, f as PdfAnnotationSubtypeCode, i as boundaryTextOffset, l as ANNOTATION_SUBTYPES, m as EngineErrorCode, n as validNumberFormat, o as charMapViolation, p as subtypeFromCode, r as PAGE_INSERT_BLANK_MAX_COUNT, s as charRangeForTextOffsets, t as formatMeasurement, u as PDF_CODE_TO_SUBTYPE } from "./format-Bbphf4zR.js";
4
- import { S as protectedCapabilities, _ as levelAllows, a as expandRawScope, b as lockNameCovers, c as parseScope, d as MissingIdentity, f as PermissionDenied, g as fieldLockFor, h as deriveProtection, i as checkSetGroup, l as validateScopeArray, m as SIGNATURE_POLICY_VERSION, n as checkCapability, o as expandedCapabilities, r as checkCollab, s as filterMatches, t as checkAnyCapability, u as InvalidScope, v as levelFromPermission, x as minLevel, y as lockCovers } from "./resolver-inAVzsWt.js";
5
- import { n as isAbortError, t as AbortError } from "./AbortError-DwuHPK_I.js";
6
- //#region src/promise/AbortablePromise.ts
7
- let _Symbol$species;
8
- _Symbol$species = Symbol.species;
1
+ import { C as outlineItemAfter, E as OUTLINE_READ_LIMITS, S as deletedAttachmentOf, T as outlineItemWithChildren, _ as assertChoiceDefault, a as objectNumbersReferencedBy, b as isNoOpWrite, c as defaultEntryOfDraft, d as formFieldAfter, f as formFieldOfDraft, g as widgetAfterPatch, h as fitWidgetToFamily, i as objectNumbersNamedBy, l as fieldAfterReset, m as widgetsAfterDisplay, n as isUndoChange, o as resolveChangeResources, p as topRowOf, r as itemWrote, s as formEffectOps, t as isSkippedItem, u as fieldAfterValue, v as fieldValueWriteOf, w as outlineItemOfDraft, x as valueEntriesEqual, y as isAtDefault } from "./Change-tMR34hTU.js";
2
+ import { $ as pdfAppearanceTurnOf, A as createPdfTextLayout, At as pageTransform, B as mapActionNode, C as resolveAnnotationPatch, Ct as isRotatedGeometryRun, D as pageGeometryOf, Dt as pdfPointOf, E as createTextLayout, Et as pageQuadOf, F as pdfAnnotationOf, Ft as renderSize, G as mapLinkTarget, H as mapAnnotationActions, I as pdfAnnotationPatchOf, It as PRINT_PAPER, J as pageDestinationOf, K as mapPageActions, L as pageMeasureOf, Lt as printScale, M as pageAnnotationOf, Mt as renderMatrix, N as pageAnnotationPatchOf, Nt as renderTargetArea, O as pageSearchSliceOf, Ot as pdfQuadOf, P as pdfAnnotationDraftOf, Pt as renderTransform, R as pageViewportsOf, Rt as actionTreeOf, S as resolveAnnotationDraft, St as glyphLooseQuad, T as shapeForRect, Tt as pagePointOf, U as mapDocumentActions, V as mapActionTree, W as mapFieldActions, X as ANNOTATION_DEFAULTS, Y as pdfDestinationOf, Z as annotationDefaultsOf, _ as pagePointUnturned, _t as outlineItemRefsEqual, a as squareMetres, at as bundleCodec, b as pageTurnOfDrawn, bt as isAbortError, c as foldText, ct as manifestBytesOf, d as appearanceTurnOf, dt as assertAnnotationResources, et as ATTACHMENT_LIMITS, f as applyAnnotationPatch, ft as hasAnnotationResources, g as pagePointTurned, gt as resolveBinarySource, h as pageGlyphLooseQuad, ht as sniffBinaryMetadata, i as areaUnitLabel, it as assertAnnotationBundleManifest, j as pageAnnotationDraftOf, jt as renderAreaTransform, k as pageTextSegmentOf, kt as pdfRectOf, l as toOriginalRange, lt as ANNOTATION_RESOURCE_ROLE_NAMES, m as pageGlyphLooseBounds, mt as withFileFromResource, n as measureFromRatio, nt as AnnotationTransfer, o as squareOf, ot as DEFAULT_BUNDLE_LIMITS, p as drawnPointsOf, pt as resolveAnnotationResources, r as METRES, rt as assertAnnotationBundle, s as SEARCH_FOLD_VERSION, st as assertWithinLimit, t as measureFromKnownLength, tt as toAttachmentRef, u as annotationOfDraft, ut as annotationResourceBuffers, v as pagePointsBounds, vt as toOutlineItemRef, w as resolveRectCommand, wt as pageBoxOf, x as pageTurnOfUpright, xt as glyphLooseBounds, y as pageQuadBounds, yt as AbortError, z as pdfMeasureOf } from "./calibrate-nQFgCuki.js";
3
+ import { a as deletedFieldOf, c as formExportRowsOf, d as decodeSubmitFormFlags, f as fieldScriptOf, g as writesScripts, h as widgetActionsOf, i as formValuesImportFacts, l as WIDGET_ACTION_EVENTS, m as needsScriptRight, n as WIDGET_FLAG_NAMES, o as formResetFacts, p as isFieldScript, r as formImportFacts, s as fieldMatches, t as fieldValueOf, u as actionWriteOf } from "./value-Dhc8eYcx.js";
4
+ import { B as deletedWith, C as measurementPoint, Ct as pdfRectToOriginSize, D as validAreaBoundary, E as scaleOf, Et as quarterTurnOf, F as buildCommentThreads, I as isStateAnnotation, K as bundlePageMapping, L as standardStateModelOf, M as appearanceChangeOf, N as appearanceImpactOf, O as DRAWN_RECT_KINDS, P as semanticEqual, Q as ANNOTATION_FIELD_SPACES, R as buildThreads, S as measurementReadout, St as pdfRectSize, T as polygonArea, Tt as pdfRectWidth, X as resourceIdOf, Z as compareIsoDateTime, _ as assertPdfFloat, _t as pdfQuadBounds, at as sameColor, b as isDimension, bt as pdfRectHeight, c as assertRichTextAgreement, ct as richTextPlainText, d as faceForFreeTextFont, dt as pdfPointsBounds, et as ANNOTATION_FIELD_NAMES, f as familyKey, ft as pdfTurnOfDrawn, g as touchesCaption, gt as normalizePdfRect, h as resolveMeasurementDraft, ht as normalizePdfQuad, i as assertDeclaredFields, it as rgbOf, j as UNBAKED_KINDS, lt as pdfPointTurned, m as isStandardFontName, mt as isSamePdfRect, ot as DEFAULT_RICH_TEXT_BODY, p as freeTextFontForFace, pt as pdfTurnOfUpright, rt as colorOf, st as richTextParagraphsFromPlainText, tt as ANNOTATION_RESOURCE_ROLES, u as STANDARD_FACES, ut as pdfPointUnturned, v as assertWritableMeasure, vt as pdfQuarterTurnBox, w as pathLength, wt as pdfRectTurnedBounds, x as isReadout, xt as pdfRectIntersection, y as deriveMeasurementLabel, yt as pdfRectFromOriginSize, z as classifyRelation } from "./resolveAnnotationDraft-CUpf0SMh.js";
5
+ import { _ as serializeError, a as formWidget, c as STANDARD_FONTS, d as pageRefsEqual, f as toPageRef, g as deserializeError, h as EngineError, i as encodeFieldRefKey, l as decodePageKey, m as annotationKey, n as validNumberFormat, o as toFieldRef, p as isValidPageObjectNumber, r as decodeFieldRefKey, s as NO_ANNOTATION_FLAGS, t as formatMeasurement, u as encodePageKey, v as _defineProperty, y as EngineErrorCode } from "./format-Dgg428Kb.js";
6
+ import { $ as pageWidgetOf, A as restrictionsOf, B as pdfValueEquals, C as matchPageText, Ct as imageSourceOfBytes, D as USAGE_INCOMPLETE, Dt as pageBoxesOf, E as EdgeResolver, Et as DEFAULT_MEDIA_BOX, F as primaryFinding, G as mapOutlineItem, H as stableStringify, I as worstVerdict, J as pdfOutlineDraftOf, K as pageOutlineItemOf, L as changedKeys, M as assessmentOf, N as combine, O as restrictionsFor, Ot as pageRotationOf, P as conclude, Q as pageFormSnapshotOf, R as dictEntries, S as buildSnippet, St as createPageImageHandle, T as DEFAULT_EDGE_RESOLVER_BUDGET, Tt as resolvePageLayers, U as placedWidgetOf, V as refsOf, W as draftWritesScripts, X as pageFieldActionsOf, Y as pdfOutlinePatchOf, Z as pageFormFieldOf, _ as isKeptRefusal, _t as generateUuidV7, a as annotationWriteCapability, at as pageListOf, b as searchContentEpoch, bt as checkImageQuality, c as authorizeAnnotationUpdate, ct as annotationPatchBetween, d as authorizeFieldWrite, dt as concatAnnotationLists, et as pdfFormFieldDraftOf, f as authorizeUnprotected, ft as closeExportSelection, g as changeFingerprint, gt as generateUuid, h as deletedOutlineItemsOf, ht as familyOfSubtype, i as annotationWriteCapabilities, it as pageLayoutOf, j as sameEffectiveValue, k as evaluateStep, l as authorizeCapability, lt as mergeAnnotationPatch, m as decodePdfBits, mt as normalizeAttachmentFileSource, n as allowsFieldWrite, nt as pageAppearancesOf, o as authorizeAnnotationCreate, ot as pageSpaceBoxesOf, p as PDF_BITS, pt as annotationImportFacts, q as pageOutlineOf, r as allowsSomeFieldWrite, rt as pdfRenderTargetOf, s as authorizeAnnotationDelete, st as visibleBoxesOf, t as allowsCapability, tt as pdfWidgetPlacementOf, u as authorizeFieldGroup, ut as deletedAnnotationsOf, v as opIdOf, vt as DEFAULT_PDF_SAVE_MODE, w as searchQueryOf, wt as printDpiOf, x as SEARCH_SNIPPET_CONTEXT, xt as checkRenderUsage, y as canonicalSearchQuery, yt as resolvePageExtract, z as parsePdfValue } from "./authority-PuxpGFhJ.js";
7
+ import { A as MissingIdentity, C as lockCovers, D as decodeAnnotKey, E as protectedCapabilities, O as encodeAnnotKey, S as levelFromPermission, T as minLevel, _ as deriveProtection, a as checkFieldAction, b as isProtectableCapability, c as expandRawScope, d as filterMatches, f as parseScope, g as SIGNATURE_POLICY_VERSION, h as PROTECTABLE_CAPABILITIES, i as checkCollab, j as PermissionDenied, k as InvalidScope, l as expandedCapabilities, n as checkAnyFieldAction, o as checkSetGroup, p as validateScopeArray, r as checkCapability, s as collabTargetOf, t as checkAnyCapability, u as fieldRightsOf, v as describeProtection, w as lockNameCovers, x as levelAllows, y as fieldLockFor } from "./resolver-BBggAxQc.js";
8
+ import { S as AbortablePromise, _ as OBJECT_NUMBER_CEILING, a as reorderedList, b as objectNumbersIn, c as validateSearchQuery, d as matchLiteral, f as wordAt, g as assertFormBundleManifest, h as assertFormBundle, i as reorderPart, l as validateSearchRegex, m as FormTransfer, n as anchorOf, o as SEARCH_REGEX_MAX_LENGTH, p as wordBefore, r as positionIndex, s as matchRegex, t as viewportForPoint, u as foldOptionsFor, v as OBJECT_NUMBER_ISSUE_LIMIT, x as parseObjectNumberRanges, y as formatObjectNumberRanges } from "./viewport-DQR5LyX3.js";
9
+ import { a as sliceText, d as shownAppearances, i as charRangeForTextOffsets, l as ANNOTATION_APPEARANCE_MODES, n as charBoundaryAtTextOffset, r as charMapViolation, t as boundaryTextOffset, u as appearanceModesOf } from "./charmap-Cprti1ta.js";
10
+ import { a as subtypeFromCode, i as PdfAnnotationSubtypeCode, n as PDF_CODE_TO_SUBTYPE, r as PDF_SUBTYPE_TO_CODE, t as ANNOTATION_SUBTYPES } from "./subtype-CG4WpIRj.js";
11
+ import { n as pageRefsIn, t as mapPageRefs } from "./pageRefs-DkbuxSCV.js";
12
+ import { t as PAGE_INSERT_BLANK_MAX_COUNT } from "./PageInsertBlankInput-DhVYVJ_S.js";
13
+ import { i as pdfPermissions, n as collab, r as materializePdfPermissions, t as caps } from "./builders-DV62HA3I.js";
14
+ import { n as isLocalPage, r as LOCAL_ENGINE_BRAND, t as isLocalDocument } from "./LocalDocumentHandle-DAPdaOt_.js";
15
+ import { a as snapTileScale, i as snapFullPageViewport, n as appearanceLatticeScale, o as isLocalEngine, r as snapAppearanceScale, t as CONTINUOUS_RENDER_POLICY } from "./DocumentRenderService-DFrZ9wfW.js";
16
+ //#region src/events/DocumentEventStream.ts
9
17
  /**
10
- * Awaitable Promise subclass with abort and progress.
11
- *
12
- * Symbol.species returns plain Promise so chained .then/.catch/.finally
13
- * return regular promises and never try to synthesize a new
14
- * AbortablePromise (which would have no executor).
18
+ * `on(type, listener)` built on a stream's `subscribe`, so both engines
19
+ * filter the same way and a type listener counts as a subscriber (the cloud
20
+ * opens its live stream for the first one).
21
+ */
22
+ function subscribeToType(subscribe, type, listener) {
23
+ return subscribe((event) => {
24
+ if (event.type === type) listener(event);
25
+ });
26
+ }
27
+ //#endregion
28
+ //#region src/events/EventHub.ts
29
+ /**
30
+ * The in-process implementation of `DocumentEventStream`, shared by both
31
+ * engine shells (one hub per open `DocumentHandle`). The engine that
32
+ * performs a mutation publishes here at confirmation time; the cloud
33
+ * engine's remote channel will also publish here for other sessions'
34
+ * mutations — listeners never learn which transport delivered an event.
15
35
  *
16
- * Settlement contract:
17
- * - The first settlement wins. resolve/reject handed to the executor
18
- * are wrapped so that any subsequent call (whether by the executor,
19
- * by abort(), or by both racing) becomes a silent no-op.
20
- * - abort() rejects the public promise with AbortError immediately,
21
- * even if the executor never observes the AbortSignal. The executor
22
- * still receives the AbortSignal so it can stop real work
23
- * cooperatively (release a queue slot, abort fetch, post a worker
24
- * abort, etc.). Anything the executor does after that — including
25
- * a late resolve(value), a late reject(error), or a rejected inner
26
- * Promise inside AbortablePromise.run — is dropped silently.
27
- * - abort() after settlement is a no-op.
36
+ * Delivery contract:
37
+ * - synchronous fan-out in subscription order;
38
+ * - error isolation: a throwing listener is re-thrown on a microtask
39
+ * (so it surfaces to the host's unhandled-error reporting) without
40
+ * blocking other listeners or failing the mutation path;
41
+ * - `lastServerId` tracks the highest remote cursor seen, for the
42
+ * remote channel's reconnect/backfill.
28
43
  */
29
- var AbortablePromise = class AbortablePromise extends Promise {
30
- static get [_Symbol$species]() {
31
- return Promise;
32
- }
33
- constructor(executor) {
34
- const ctrl = new AbortController();
35
- const progressCbs = /* @__PURE__ */ new Set();
36
- const state = { settled: false };
37
- let capturedReject;
38
- super((resolve, reject) => {
39
- capturedReject = reject;
40
- const wrappedResolve = (value) => {
41
- if (state.settled) return;
42
- state.settled = true;
43
- resolve(value);
44
- };
45
- const wrappedReject = (reason) => {
46
- if (state.settled) return;
47
- state.settled = true;
48
- reject(reason);
49
- };
50
- const progress = (p) => {
51
- if (state.settled) return;
52
- for (const cb of progressCbs) try {
53
- cb(p);
54
- } catch {}
55
- };
56
- executor(wrappedResolve, wrappedReject, progress, ctrl.signal);
44
+ var EventHub = class {
45
+ constructor(onListenerError = (err) => {
46
+ queueMicrotask(() => {
47
+ throw err;
57
48
  });
58
- _defineProperty(this, "signal", void 0);
59
- _defineProperty(this, "_ctrl", void 0);
60
- _defineProperty(this, "_progressCbs", void 0);
61
- _defineProperty(this, "_state", void 0);
62
- _defineProperty(this, "_internalReject", void 0);
63
- this._ctrl = ctrl;
64
- this.signal = ctrl.signal;
65
- this._progressCbs = progressCbs;
66
- this._state = state;
67
- this._internalReject = capturedReject;
68
- }
69
- /**
70
- * Abort the underlying operation.
71
- *
72
- * - If the promise has already settled, this is a no-op.
73
- * - Otherwise the public promise rejects synchronously with an
74
- * AbortError (wrapping the supplied reason if it is not already an
75
- * AbortError) and the AbortSignal fires for any cooperative
76
- * cancellation the executor wired up.
77
- */
78
- abort(reason) {
79
- if (this._state.settled) return;
80
- if (this._ctrl.signal.aborted) return;
81
- const err = reason instanceof AbortError ? reason : new AbortError(reason);
82
- this._state.settled = true;
83
- this._ctrl.abort(err);
84
- this._internalReject(err);
49
+ }) {
50
+ this.onListenerError = onListenerError;
51
+ _defineProperty(this, "listeners", /* @__PURE__ */ new Set());
52
+ _defineProperty(this, "serverId", null);
85
53
  }
86
- /**
87
- * Subscribe to progress events. Returns an unsubscribe function.
88
- */
89
- onProgress(cb) {
90
- this._progressCbs.add(cb);
54
+ subscribe(listener) {
55
+ this.listeners.add(listener);
91
56
  return () => {
92
- this._progressCbs.delete(cb);
57
+ this.listeners.delete(listener);
93
58
  };
94
59
  }
95
- /**
96
- * Wrap a value in an already-resolved AbortablePromise. Mirrors Promise.resolve.
97
- */
98
- static resolveValue(value) {
99
- return new AbortablePromise((resolve) => resolve(value));
60
+ on(type, listener) {
61
+ return subscribeToType((all) => this.subscribe(all), type, listener);
62
+ }
63
+ publish(event) {
64
+ if ("origin" in event) {
65
+ const { serverId } = event.origin;
66
+ if (serverId !== null) this.serverId = this.serverId === null ? serverId : Math.max(this.serverId, serverId);
67
+ }
68
+ for (const listener of [...this.listeners]) try {
69
+ listener(event);
70
+ } catch (err) {
71
+ this.onListenerError(err);
72
+ }
73
+ }
74
+ lastServerId() {
75
+ return this.serverId;
76
+ }
77
+ /** Drop every listener (handle close). Idempotent. */
78
+ clear() {
79
+ this.listeners.clear();
80
+ }
81
+ };
82
+ /**
83
+ * Stamps provenance onto events a mutation path produces. One per open
84
+ * handle: the engine shell constructs it with the instance's `sessionId`
85
+ * (and, on cloud, the authenticated `sub` when known) and hands it to the
86
+ * mutation services — they publish results, never build origins.
87
+ */
88
+ var SessionEventPublisher = class {
89
+ constructor(hub, sessionId, sub = null) {
90
+ this.hub = hub;
91
+ this.sessionId = sessionId;
92
+ this.sub = sub;
100
93
  }
101
94
  /**
102
- * Wrap a thrown reason in an already-rejected AbortablePromise.
95
+ * Publish what one write of this session just committed: one
96
+ * event per fact, in order, all carrying the write's `opId` as
97
+ * `origin.tx`.
103
98
  */
104
- static rejectReason(reason) {
105
- return new AbortablePromise((_resolve, reject) => reject(reason));
99
+ publishWrite(opId, ...events) {
100
+ this.publishChange(opId, events);
106
101
  }
107
102
  /**
108
- * Run an async function as an AbortablePromise so callers get .abort() and .signal.
109
- * The async function receives the AbortSignal (and a progress emitter) so it can
110
- * cooperate with the abort.
111
- *
112
- * If abort() fires while the inner async function is still running, the
113
- * public promise rejects with AbortError immediately. The inner async
114
- * function's eventual settlement (resolve or reject) is funneled through
115
- * the wrapped settlers and silently dropped — including a late rejection
116
- * from the underlying work, which prevents an UnhandledRejection because
117
- * the .then(resolve, reject) below "handles" it via the no-op.
103
+ * Publish what one change committed: its events as {@link publishWrite}
104
+ * does, and for an undo, the `opId` of the change it undid.
118
105
  */
119
- static run(fn) {
120
- return new AbortablePromise((resolve, reject, progress, signal) => {
121
- fn(signal, progress).then(resolve, reject);
106
+ publishChange(opId, events, undoOf) {
107
+ const ts = Date.now();
108
+ events.forEach((event, index) => {
109
+ this.hub.publish({
110
+ ...event,
111
+ origin: {
112
+ kind: "local",
113
+ sessionId: this.sessionId,
114
+ sub: this.sub,
115
+ ts,
116
+ serverId: null,
117
+ tx: {
118
+ id: opId,
119
+ index,
120
+ count: events.length
121
+ },
122
+ ...undoOf !== void 0 ? { undoOf } : {}
123
+ }
124
+ });
122
125
  });
123
126
  }
124
127
  };
125
128
  //#endregion
129
+ //#region src/events/changeEvents.ts
130
+ /**
131
+ * The events a change publishes: each op's events as its single verb
132
+ * publishes them, in op order. An op an undo left alone entirely publishes
133
+ * nothing. The publisher stamps them all with the change's `opId`.
134
+ */
135
+ function changeEvents(result) {
136
+ return result.items.flatMap(itemEvents);
137
+ }
138
+ function itemEvents(item) {
139
+ if (isSkippedItem(item)) return [];
140
+ switch (item.type) {
141
+ case "annotations.create": {
142
+ const { type: _type, ...result } = item;
143
+ return [{
144
+ type: "annotations.created",
145
+ ...result
146
+ }];
147
+ }
148
+ case "annotations.update": {
149
+ const { type: _type, skipped: _skipped, ...result } = item;
150
+ return [{
151
+ type: "annotations.updated",
152
+ ...result
153
+ }];
154
+ }
155
+ case "annotations.delete": {
156
+ const { type: _type, ...result } = item;
157
+ return [{
158
+ type: "annotations.deleted",
159
+ deleted: deletedAnnotationsOf(result),
160
+ ...result
161
+ }];
162
+ }
163
+ case "annotations.reorder": {
164
+ const { type: _type, ...result } = item;
165
+ return [{
166
+ type: "annotations.reordered",
167
+ ...result
168
+ }];
169
+ }
170
+ case "annotations.restore": {
171
+ const { type: _type, ...result } = item;
172
+ return [{
173
+ type: "annotations.restored",
174
+ ...result
175
+ }];
176
+ }
177
+ case "annotations.import": {
178
+ const { type: _type, ...result } = item;
179
+ return annotationImportFacts(result).map((fact) => ({
180
+ type: "annotations.created",
181
+ ...fact
182
+ }));
183
+ }
184
+ case "forms.import": {
185
+ const { type: _type, ...result } = item;
186
+ return formImportFacts(result).map((fact) => ({
187
+ type: "forms.created",
188
+ ...fact
189
+ }));
190
+ }
191
+ case "forms.importValues": {
192
+ const { type: _type, ...result } = item;
193
+ return formValuesImportFacts(result).map((fact) => ({
194
+ type: "forms.valueSet",
195
+ ...fact
196
+ }));
197
+ }
198
+ case "forms.setValue": {
199
+ const { type: _type, ...result } = item;
200
+ return [{
201
+ type: "forms.valueSet",
202
+ ...result
203
+ }];
204
+ }
205
+ case "forms.reset": {
206
+ const { type: _type, skipped: _skipped, ...result } = item;
207
+ return formResetFacts(result).map((fact) => ({
208
+ type: "forms.valueSet",
209
+ ...fact
210
+ }));
211
+ }
212
+ case "forms.setDisplay":
213
+ case "forms.setAppearanceText":
214
+ case "forms.setSignatureAppearance": {
215
+ const { type: _type, ...result } = item;
216
+ return [{
217
+ type: "forms.updated",
218
+ ...result
219
+ }];
220
+ }
221
+ case "forms.update": {
222
+ const { type: _type, skipped: _skipped, ...result } = item;
223
+ return [{
224
+ type: "forms.updated",
225
+ ...result
226
+ }];
227
+ }
228
+ case "forms.create": {
229
+ const { type: _type, ...result } = item;
230
+ return [{
231
+ type: "forms.created",
232
+ ...result
233
+ }];
234
+ }
235
+ case "forms.delete": {
236
+ const { type: _type, ...result } = item;
237
+ return [{
238
+ type: "forms.deleted",
239
+ deleted: deletedFieldOf(result),
240
+ ...result
241
+ }];
242
+ }
243
+ case "forms.restore": {
244
+ const { type: _type, ...result } = item;
245
+ return [{
246
+ type: "forms.restored",
247
+ ...result
248
+ }];
249
+ }
250
+ case "forms.addWidget": {
251
+ const { type: _type, ...result } = item;
252
+ return [{
253
+ type: "forms.widgetAdded",
254
+ ...result
255
+ }];
256
+ }
257
+ case "forms.removeWidget": {
258
+ const { type: _type, ...result } = item;
259
+ return [{
260
+ type: "forms.widgetRemoved",
261
+ ...result
262
+ }];
263
+ }
264
+ case "forms.deleteWidget": {
265
+ const { type: _type, ...result } = item;
266
+ return [{
267
+ type: "forms.widgetDeleted",
268
+ ...result
269
+ }];
270
+ }
271
+ case "forms.restoreWidget": {
272
+ const { type: _type, ...result } = item;
273
+ return [{
274
+ type: "forms.widgetRestored",
275
+ ...result
276
+ }];
277
+ }
278
+ case "forms.reorderWidgets": {
279
+ const { type: _type, ...result } = item;
280
+ return [{
281
+ type: "forms.widgetsReordered",
282
+ ...result
283
+ }];
284
+ }
285
+ case "forms.reorderCalculations": {
286
+ const { type: _type, ...result } = item;
287
+ return [{
288
+ type: "forms.calculationsReordered",
289
+ ...result
290
+ }];
291
+ }
292
+ case "forms.updateWidget": {
293
+ const { type: _type, skipped: _skipped, ...result } = item;
294
+ return [{
295
+ type: "forms.widgetUpdated",
296
+ ...result
297
+ }];
298
+ }
299
+ case "metadata.update": {
300
+ const { type: _type, skipped: _skipped, ...result } = item;
301
+ return [{
302
+ type: "metadata.updated",
303
+ ...result
304
+ }];
305
+ }
306
+ case "metadata.updateCustom": {
307
+ const { type: _type, skipped: _skipped, ...result } = item;
308
+ return [{
309
+ type: "metadata.customUpdated",
310
+ ...result
311
+ }];
312
+ }
313
+ case "outline.create": {
314
+ const { type: _type, ...result } = item;
315
+ return [{
316
+ type: "outline.created",
317
+ ...result
318
+ }];
319
+ }
320
+ case "outline.update": {
321
+ const { type: _type, skipped: _skipped, ...result } = item;
322
+ return [{
323
+ type: "outline.updated",
324
+ ...result
325
+ }];
326
+ }
327
+ case "outline.move": {
328
+ const { type: _type, ...result } = item;
329
+ return [{
330
+ type: "outline.moved",
331
+ ...result
332
+ }];
333
+ }
334
+ case "outline.delete": {
335
+ const { type: _type, ...result } = item;
336
+ return [{
337
+ type: "outline.deleted",
338
+ deleted: deletedOutlineItemsOf(result),
339
+ ...result
340
+ }];
341
+ }
342
+ case "outline.restore": {
343
+ const { type: _type, ...result } = item;
344
+ return [{
345
+ type: "outline.restored",
346
+ ...result
347
+ }];
348
+ }
349
+ case "pages.rotate": {
350
+ const { type: _type, ...result } = item;
351
+ return [{
352
+ type: "pages.rotated",
353
+ ...result
354
+ }];
355
+ }
356
+ case "pages.reorder": {
357
+ const { type: _type, ...result } = item;
358
+ return [{
359
+ type: "pages.reordered",
360
+ ...result
361
+ }];
362
+ }
363
+ case "pages.delete": {
364
+ const { type: _type, ...result } = item;
365
+ return [{
366
+ type: "pages.deleted",
367
+ ...result
368
+ }];
369
+ }
370
+ case "pages.insertBlank":
371
+ case "pages.insert": {
372
+ const { type: _type, ...result } = item;
373
+ return [{
374
+ type: "pages.inserted",
375
+ ...result
376
+ }];
377
+ }
378
+ case "pages.restore": {
379
+ const { type: _type, ...result } = item;
380
+ return [{
381
+ type: "pages.restored",
382
+ ...result
383
+ }];
384
+ }
385
+ case "attachments.create": {
386
+ const { type: _type, ...result } = item;
387
+ return [{
388
+ type: "attachments.created",
389
+ ...result
390
+ }];
391
+ }
392
+ case "attachments.delete": {
393
+ const { type: _type, ...result } = item;
394
+ return [{
395
+ type: "attachments.deleted",
396
+ deleted: deletedAttachmentOf(result),
397
+ ...result
398
+ }];
399
+ }
400
+ case "attachments.restore": {
401
+ const { type: _type, ...result } = item;
402
+ return [{
403
+ type: "attachments.restored",
404
+ ...result
405
+ }];
406
+ }
407
+ }
408
+ }
409
+ //#endregion
126
410
  //#region src/engine/document-security-state.ts
127
411
  function securityStateFromHead(head) {
128
412
  return {
@@ -168,20 +452,20 @@ function permissionInfoWithAdvisory(info, pdfBits) {
168
452
  }
169
453
  /**
170
454
  * Translate a {@link PdfBits} view into the capability-shaped
171
- * {@link PdfPermissionAdvisory}. The rules here MUST mirror the bit
172
- * combinations the scope resolver uses for `pdf.permissions`
173
- * expansion — `doc.print.high` requires bit 12 AND bit 3, etc.
455
+ * {@link PdfPermissionAdvisory}: what `pdf.permissions` grants on a file
456
+ * with these bits.
174
457
  */
175
458
  function advisoryFromPdfBits(b) {
459
+ const granted = new Set(materializePdfPermissions(b));
176
460
  return {
177
- canPrint: b.bit3,
178
- canPrintHigh: b.bit12 && b.bit3,
179
- canCopy: b.bit5,
180
- canAnnotate: b.bit6,
181
- canFillForms: b.bit6 || b.bit9,
182
- canModifyForms: b.bit6 && b.bit4,
183
- canModifyPages: b.bit4,
184
- canAssemble: b.bit11
461
+ canPrint: granted.has("doc.print"),
462
+ canPrintHigh: granted.has("doc.print.high"),
463
+ canCopy: granted.has("doc.text.copy"),
464
+ canAnnotate: granted.has("doc.annotate.modify"),
465
+ canFillForms: granted.has("doc.forms.fill"),
466
+ canModifyForms: granted.has("doc.forms.modify"),
467
+ canModifyPages: granted.has("doc.pages.modify"),
468
+ canAssemble: granted.has("doc.pages.assemble")
185
469
  };
186
470
  }
187
471
  function securityStateFromProbe(info, opts = {}) {
@@ -211,68 +495,95 @@ function securityStateFromProbe(info, opts = {}) {
211
495
  };
212
496
  }
213
497
  //#endregion
214
- //#region src/engine/DocumentRenderService.ts
215
- const CONTINUOUS_RENDER_POLICY = { kind: "continuous" };
498
+ //#region src/scheduling/place.ts
499
+ const PLACE_ORDER = {
500
+ elsewhere: 0,
501
+ near: 1,
502
+ visible: 2
503
+ };
504
+ /** More device pixels than any screen shows, so pixels never outweigh the rest of a rank. */
505
+ const PIXEL_SPAN = 2 ** 40;
506
+ const ELSEWHERE = {
507
+ place: "elsewhere",
508
+ pixels: 0
509
+ };
510
+ const ON_SCREEN = {
511
+ place: "visible",
512
+ pixels: 0
513
+ };
514
+ /** Whether `a` is the better place: on screen before near before elsewhere, then more pixels. */
515
+ function placedBefore(a, b) {
516
+ const order = PLACE_ORDER[a.place] - PLACE_ORDER[b.place];
517
+ return order !== 0 ? order > 0 : a.pixels > b.pixels;
518
+ }
216
519
  /**
217
- * Conform a FULL-PAGE viewport to a render policy — the ONE snap
218
- * implementation, shared by every engine and plugin. Pure and explicit
219
- * by design:
220
- *
221
- * - `continuous` → identity (local/cloud plugin code stays byte-identical).
222
- * - `lattice` → returns a `width`-kind viewport at the smallest ladder
223
- * width ≥ the requested detail (snap UP: always crisp, CSS downscales
224
- * for free), capped at the largest width — detail beyond the cap is the
225
- * tile pyramid's job, by design.
226
- * - `scale`-kind requests convert through the page's width in PDF user
227
- * units — pass `opts.pageWidth` (the caller has it from the layout);
228
- * omitting it for a scale viewport under a lattice policy is a
229
- * programmer error and throws `InvalidArg`.
520
+ * A job's place in one view: its page's role there, except that a part of a
521
+ * visible page that's off screen (a tile of the ring around what shows) is
522
+ * `near`.
230
523
  */
231
- function snapFullPageViewport(policy, viewport, opts) {
232
- if (policy.kind === "continuous") return viewport;
233
- if (policy.fullPage.widths.length === 0) throw new EngineError(EngineErrorCode.InvalidArg, "render policy has an empty width ladder");
234
- const widths = [...policy.fullPage.widths].sort((a, b) => a - b);
235
- let requested;
236
- if (viewport.kind === "width") requested = viewport.width;
237
- else {
238
- const pageWidth = opts?.pageWidth;
239
- if (pageWidth === void 0 || pageWidth <= 0) throw new EngineError(EngineErrorCode.InvalidArg, "snapping a scale viewport to a width lattice requires opts.pageWidth");
240
- requested = (viewport.scale ?? 1) * pageWidth;
241
- }
524
+ function placeIn(entry, job) {
525
+ if (!entry) return ELSEWHERE;
526
+ if (entry.role === "near") return {
527
+ place: "near",
528
+ pixels: 0
529
+ };
530
+ if (job.region && entry.visible && !overlaps(job.region, entry.visible)) return {
531
+ place: "near",
532
+ pixels: 0
533
+ };
242
534
  return {
243
- kind: "width",
244
- width: widths.find((width) => width >= requested) ?? widths[widths.length - 1]
535
+ place: "visible",
536
+ pixels: entry.pixels
245
537
  };
246
538
  }
247
539
  /**
248
- * Conform an annotation-appearance scale to the policy's appearance
249
- * lattice. Same discipline as {@link snapFullPageViewport}: identity on
250
- * continuous (and when the policy carries no appearance block), snap UP,
251
- * cap at the largest point. Callers derive `scale` from the page's
252
- * effective render scale (`snappedWidth / pageWidth`, × devicePixelRatio
253
- * as needed) so composites stay crisp against the page raster.
540
+ * A job's place among a document's views: in the view it serves, or, when it
541
+ * serves none (or one that said nothing), the best place its page has in any
542
+ * view. A job about the whole document serves what's shown, so it counts as
543
+ * on screen. While no view says anything, every job is on screen alike, and
544
+ * jobs run in the order they were asked.
254
545
  */
255
- function snapAppearanceScale(policy, scale) {
256
- if (policy.kind === "continuous" || policy.appearances === void 0) return scale;
257
- if (policy.appearances.scales.length === 0) throw new EngineError(EngineErrorCode.InvalidArg, "render policy has an empty appearance-scale lattice");
258
- const scales = [...policy.appearances.scales].sort((a, b) => a - b);
259
- return scales.find((s) => s >= scale) ?? scales[scales.length - 1];
546
+ function placeFor(job, views) {
547
+ if (views.size === 0 || !job.page) return ON_SCREEN;
548
+ const objectNumber = job.page.objectNumber;
549
+ const served = job.view === void 0 ? void 0 : views.get(job.view);
550
+ if (served) return placeIn(served.get(objectNumber), job);
551
+ let best = ELSEWHERE;
552
+ for (const pages of views.values()) {
553
+ const placed = placeIn(pages.get(objectNumber), job);
554
+ if (placedBefore(placed, best)) best = placed;
555
+ }
556
+ return best;
260
557
  }
261
558
  /**
262
- * Conform a tile-pyramid scale to the policy's tile lattice — the third
263
- * member of the `snap<PolicyBlock><Quantity>` family. Identity on
264
- * continuous and while the deployment doesn't advertise a `tiles` block
265
- * (the block is reserved until the deep-zoom vertical ships server-side;
266
- * the tiling client uses its own default pyramid then — see
267
- * plugin-render). Snap UP, cap at the largest scale: per-tile cost is
268
- * constant by construction (`tileSize²` pixels regardless of level), so
269
- * the cap bounds artifact COUNT, not memory.
559
+ * How soon a job runs among those that may run: higher first. It compares, in
560
+ * turn:
561
+ * 1. background last: a `low` call is about nothing the views show;
562
+ * 2. where its page is: on screen, then just off it, then elsewhere;
563
+ * 3. its priority: `high` (the picture of the page itself) before `auto`;
564
+ * 4. a whole page before a part of one: a tile is only of use once its page
565
+ * is there;
566
+ * 5. the device pixels its page shows.
567
+ * Equal ranks run in the order they were asked, so a caller sequences its own work.
270
568
  */
271
- function snapTileScale(policy, scale) {
272
- if (policy.kind === "continuous" || policy.tiles === void 0) return scale;
273
- if (policy.tiles.scales.length === 0) throw new EngineError(EngineErrorCode.InvalidArg, "render policy has an empty tile-scale lattice");
274
- const scales = [...policy.tiles.scales].sort((a, b) => a - b);
275
- return scales.find((s) => s >= scale) ?? scales[scales.length - 1];
569
+ function rank(job, placed) {
570
+ let level = job.priority === "low" ? 0 : 1;
571
+ level = level * 3 + PLACE_ORDER[placed.place];
572
+ level = level * 2 + (job.priority === "high" ? 1 : 0);
573
+ level = level * 2 + (job.region ? 0 : 1);
574
+ return level * PIXEL_SPAN + Math.min(PIXEL_SPAN - 1, Math.round(placed.pixels));
575
+ }
576
+ /**
577
+ * Whether rank `a` beats rank `b` on more than pixels (any of the first four
578
+ * steps of {@link rank}). A running job gives way only to a job that clearly
579
+ * outranks it, so two pages on screen never stop each other's work, and jobs
580
+ * don't flip back and forth while the camera moves.
581
+ */
582
+ function clearlyOutranks(a, b) {
583
+ return Math.floor(a / PIXEL_SPAN) > Math.floor(b / PIXEL_SPAN);
584
+ }
585
+ function overlaps(a, b) {
586
+ return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;
276
587
  }
277
588
  //#endregion
278
589
  //#region src/engine/passwordPrompt.ts
@@ -280,7 +591,7 @@ function snapTileScale(policy, scale) {
280
591
  * Derive the high-level password prompt from the raw security state.
281
592
  *
282
593
  * The function is pure and total — every `DocumentSecurityState`
283
- * maps to exactly one `PasswordPrompt`. Use this as the SINGLE source
594
+ * maps to exactly one `PasswordPrompt`. Use this as the single source
284
595
  * of truth wherever the SDK exposes a "do you need a password?" flag:
285
596
  * both `LocalDocumentSecurityService` and `CloudDocumentSecurityService`
286
597
  * call it, so the contract can never drift.
@@ -310,15 +621,17 @@ function snapTileScale(policy, scale) {
310
621
  *
311
622
  * 6. fallthrough → { state: 'none' } open and nothing more available
312
623
  */
313
- function passwordPromptFromState(state) {
624
+ function passwordPromptFromState(state, incorrect = false) {
314
625
  if (state.encryption.state === "none") return { state: "none" };
315
626
  if (!state.permissions.known) return {
316
627
  state: "required",
317
- hint: null
628
+ hint: null,
629
+ incorrect
318
630
  };
319
631
  if (state.encryption.requiresPassword && state.permissions.openedAs === "none") return {
320
632
  state: "required",
321
- hint: "user"
633
+ hint: "user",
634
+ incorrect
322
635
  };
323
636
  if (state.permissions.openedAs === "owner") return { state: "none" };
324
637
  if (state.permissions.canUpgradeToOwner) return {
@@ -328,6 +641,150 @@ function passwordPromptFromState(state) {
328
641
  return { state: "none" };
329
642
  }
330
643
  //#endregion
644
+ //#region src/engine/attachmentVerbs.ts
645
+ /**
646
+ * `doc.attachments` on any engine: the reads `rest` holds (`list`,
647
+ * `download`), and each write as a one-op change through `apply`, so a verb
648
+ * has its op's checks, events and undo (its `opId` undoes it) and answers as
649
+ * its single verb did.
650
+ */
651
+ function attachmentVerbs(rest, apply) {
652
+ const one = (op, type, options, answer) => AbortablePromise.run(async (signal) => {
653
+ const item = (await apply({ ops: [await op()] }, options?.opId === void 0 ? {} : { opId: options.opId }).abortWith(signal)).items[0];
654
+ if (!item || item.type !== type) throw new EngineError(EngineErrorCode.Unknown, `${type} wrote nothing`);
655
+ return answer(item);
656
+ });
657
+ return {
658
+ list: () => rest.list(),
659
+ download: (ref) => rest.download(ref),
660
+ create: (file, options) => one(async () => {
661
+ const { wireFile, resource } = await normalizeAttachmentFileSource(file, "file");
662
+ const { resources: _resources, ...metadata } = wireFile;
663
+ return {
664
+ type: "attachments.create",
665
+ file: metadata,
666
+ resources: { file: new Uint8Array(resource.bytes) }
667
+ };
668
+ }, "attachments.create", options, (item) => ({
669
+ attachment: item.attachment,
670
+ meta: item.meta
671
+ })),
672
+ delete: (ref, options) => one(async () => ({
673
+ type: "attachments.delete",
674
+ ref
675
+ }), "attachments.delete", options, (item) => ({ meta: item.meta }))
676
+ };
677
+ }
678
+ //#endregion
679
+ //#region src/engine/outlineVerbs.ts
680
+ /**
681
+ * `doc.outline` on any engine: its read, and each verb as a one-op change
682
+ * through `apply`, so a verb has its op's checks, events and undo (its
683
+ * `opId` undoes it) and answers with the op's item.
684
+ */
685
+ function outlineVerbs(get, apply) {
686
+ const one = (op, options) => AbortablePromise.run(async (signal) => {
687
+ const result = await apply({ ops: [op] }, options?.opId === void 0 ? {} : { opId: options.opId }).abortWith(signal);
688
+ const type = op.type;
689
+ const item = result.items[0];
690
+ if (!item || item.type !== type) throw new EngineError(EngineErrorCode.Unknown, `${type} wrote nothing`);
691
+ const { type: _type, skipped: _skipped, ...answer } = item;
692
+ return answer;
693
+ });
694
+ return {
695
+ get,
696
+ create: (data, options) => one({
697
+ type: "outline.create",
698
+ parent: options?.parent ?? null,
699
+ data,
700
+ ...options?.position === void 0 ? {} : { position: options.position },
701
+ ...options?.objectNumber === void 0 ? {} : { objectNumber: options.objectNumber }
702
+ }, options),
703
+ update: (ref, patch, options) => one({
704
+ type: "outline.update",
705
+ ref,
706
+ patch
707
+ }, options),
708
+ move: (refs, parent, position, options) => one({
709
+ type: "outline.move",
710
+ refs,
711
+ parent,
712
+ position
713
+ }, options),
714
+ delete: (ref, options) => one({
715
+ type: "outline.delete",
716
+ ref
717
+ }, options)
718
+ };
719
+ }
720
+ //#endregion
721
+ //#region src/engine/pageVerbs.ts
722
+ /**
723
+ * `doc.pages` on any engine: what `rest` holds (the reads, extract, flatten
724
+ * and the page names), and each structure verb as a one-op change through
725
+ * `apply`, so a verb has its op's checks, events and undo (its `opId` undoes
726
+ * it) and answers as its single verb did.
727
+ */
728
+ function pageVerbs(rest, apply) {
729
+ const one = (op, options, answer) => AbortablePromise.run(async (signal) => {
730
+ const result = await apply({ ops: [op] }, options?.opId === void 0 ? {} : { opId: options.opId }).abortWith(signal);
731
+ const type = op.type;
732
+ const item = result.items[0];
733
+ if (!item || item.type !== type) throw new EngineError(EngineErrorCode.Unknown, `${type} wrote nothing`);
734
+ return answer(item);
735
+ });
736
+ return {
737
+ list: () => rest.list(),
738
+ setName: (input, options) => rest.setName(input, options),
739
+ removeName: (input, options) => rest.removeName(input, options),
740
+ flatten: (pages, options) => rest.flatten(pages, options),
741
+ extract: (pages, options) => rest.extract(pages, options),
742
+ reorder: (pages, position, options) => one({
743
+ type: "pages.reorder",
744
+ pages,
745
+ position
746
+ }, options, (item) => ({
747
+ pages: item.pages,
748
+ layout: item.layout,
749
+ meta: item.meta
750
+ })),
751
+ rotate: (pages, rotation, options) => one({
752
+ type: "pages.rotate",
753
+ pages,
754
+ rotation
755
+ }, options, (item) => ({
756
+ layout: item.layout,
757
+ meta: item.meta
758
+ })),
759
+ delete: (pages, options) => one({
760
+ type: "pages.delete",
761
+ pages
762
+ }, options, (item) => ({
763
+ layout: item.layout,
764
+ meta: item.meta
765
+ })),
766
+ insert: (bytes, position, options) => one({
767
+ type: "pages.insert",
768
+ source: bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes),
769
+ ...position === void 0 ? {} : { position }
770
+ }, options, (item) => ({
771
+ insertedPages: item.insertedPages,
772
+ layout: item.layout,
773
+ meta: item.meta
774
+ })),
775
+ insertBlank: (spec, position, options) => one({
776
+ type: "pages.insertBlank",
777
+ spec,
778
+ ...position === void 0 ? {} : { position },
779
+ ...options?.objectNumbers === void 0 ? {} : { objectNumbers: options.objectNumbers }
780
+ }, options, (item) => ({
781
+ insertedPages: item.insertedPages,
782
+ layout: item.layout,
783
+ meta: item.meta
784
+ }))
785
+ };
786
+ }
787
+ //#endregion
331
788
  //#region src/wire/WirePack.ts
332
789
  /**
333
790
  * Singleton empty transfer list. Frozen so accidental in-place
@@ -340,10 +797,8 @@ const EMPTY_TRANSFER = Object.freeze([]);
340
797
  *
341
798
  * The `transfer` argument is optional; omitting it (or passing `[]`)
342
799
  * is the explicit, type-checked way to say "I declare this message
343
- * carries no transferables." That's structurally identical to the
344
- * shape the v2 walker generated for non-binary messages, but here
345
- * the declaration is at construction time, in the producer's own
346
- * code, where the knowledge actually lives.
800
+ * carries no transferables." The declaration is made at construction
801
+ * time, in the producer's own code, where the knowledge actually lives.
347
802
  *
348
803
  * wirePack({ kind: 'metadata.read', jobId, docId })
349
804
  * wirePack({ kind: 'open.fatMem', jobId, docId, bytes }, [bytes])
@@ -356,6 +811,6 @@ function wirePack(payload, transfer = EMPTY_TRANSFER) {
356
811
  };
357
812
  }
358
813
  //#endregion
359
- export { ANNOTATION_SUBTYPES, AbortError, AbortablePromise, CONTINUOUS_RENDER_POLICY, DEFAULT_EDGE_RESOLVER_BUDGET, DEFAULT_PDF_SAVE_MODE, EMPTY_TRANSFER, EdgeResolver, EngineError, EngineErrorCode, InvalidScope, METRES, MissingIdentity, NO_ANNOTATION_FLAGS, PAGE_INSERT_BLANK_MAX_COUNT, PDF_BITS, PDF_CODE_TO_SUBTYPE, PDF_SUBTYPE_TO_CODE, PdfAnnotationSubtypeCode, PermissionDenied, SEARCH_FOLD_VERSION, SEARCH_REGEX_MAX_LENGTH, SEARCH_SNIPPET_CONTEXT, SIGNATURE_POLICY_VERSION, UNKNOWN_WEAK_ANNOTATION_STATE, USAGE_INCOMPLETE, advisoryFromPdfBits, appearanceImpactOf, areaUnitLabel, assertPdfFloat, assertWritableMeasure, assessmentOf, boundaryTextOffset, buildCommentThreads, buildPageTextLayout, buildSnippet, buildThreads, canonicalSearchQuery, caps, changedKeys, changesAnnotationList, charBoundaryAtTextOffset, charMapViolation, charRangeForTextOffsets, checkAnyCapability, checkCapability, checkCollab, checkSetGroup, classifyRelation, collab, combine, conclude, createPageImageHandle, decodeFieldRefKey, decodePdfBits, decodeStableIdKey, decodeSubmitFormFlags, deriveMeasurementLabel, deriveProtection, deserializeError, dictEntries, encodeFieldRefKey, encodeStableIdKey, evaluateStep, expandRawScope, expandTextRangeToLine, expandTextRangeToWord, expandedCapabilities, fieldLockFor, filterMatches, foldOptionsFor, foldText, formatMeasurement, glyphLooseBounds, glyphLooseQuad, invalidatesWeakIndexRefs, isAbortError, isDimension, isReadout, isRotatedGeometryRun, isStateAnnotation, isValidPageObjectNumber, knownWeakAnnotationState, levelAllows, levelFromPermission, lockCovers, lockNameCovers, matchLiteral, matchPageText, matchRegex, materializePdfPermissions, measureFromKnownLength, measureFromRatio, measurementPoint, measurementReadout, minLevel, normalizeAnnotationDraft, normalizeAnnotationPatch, normalizeAttachmentFileSource, normalizePdfRect, parsePdfValue, parseScope, passwordPromptFromState, pathLength, pdfPermissions, pdfQuadBounds, pdfQuadCorners, pdfQuadFromCorners, pdfRectFromOriginSize, pdfRectHeight, pdfRectSize, pdfRectToOriginSize, pdfRectWidth, pdfValueEquals, permissionInfoFromProbe, permissionInfoWithAdvisory, polygonArea, primaryFinding, protectedCapabilities, refKey, refsOf, resolveBinarySource, restrictionsFor, restrictionsOf, revisionTokensEqual, richTextParagraphsFromPlainText, richTextPlainText, sameEffectiveValue, scaleOf, searchContentEpoch, searchRectsForRange, searchSegmentsForRange, securityStateFromHead, securityStateFromProbe, semanticEqual, serializeError, shiftsExistingAnnotationIndices, sliceTextByChars, snapAppearanceScale, snapFullPageViewport, snapTileScale, sniffBinaryMetadata, squareMetres, squareOf, stableStringify, subtypeFromCode, textGlyphAt, textGlyphQuad, textSegmentsForRange, toOriginalRange, validAreaBoundary, validNumberFormat, validateScopeArray, validateSearchQuery, validateSearchRegex, viewportForPoint, wirePack, wordAt, wordBefore, worstVerdict };
814
+ export { ANNOTATION_APPEARANCE_MODES, ANNOTATION_DEFAULTS, ANNOTATION_FIELD_NAMES, ANNOTATION_FIELD_SPACES, ANNOTATION_RESOURCE_ROLES, ANNOTATION_RESOURCE_ROLE_NAMES, ANNOTATION_SUBTYPES, ATTACHMENT_LIMITS, AbortError, AbortablePromise, AnnotationTransfer, CONTINUOUS_RENDER_POLICY, DEFAULT_BUNDLE_LIMITS, DEFAULT_EDGE_RESOLVER_BUDGET, DEFAULT_MEDIA_BOX, DEFAULT_PDF_SAVE_MODE, DEFAULT_RICH_TEXT_BODY, DRAWN_RECT_KINDS, EMPTY_TRANSFER, EdgeResolver, EngineError, EngineErrorCode, EventHub, FormTransfer, InvalidScope, LOCAL_ENGINE_BRAND, METRES, MissingIdentity, NO_ANNOTATION_FLAGS, OBJECT_NUMBER_CEILING, OBJECT_NUMBER_ISSUE_LIMIT, OUTLINE_READ_LIMITS, PAGE_INSERT_BLANK_MAX_COUNT, PDF_BITS, PDF_CODE_TO_SUBTYPE, PDF_SUBTYPE_TO_CODE, PRINT_PAPER, PROTECTABLE_CAPABILITIES, PdfAnnotationSubtypeCode, PermissionDenied, SEARCH_FOLD_VERSION, SEARCH_REGEX_MAX_LENGTH, SEARCH_SNIPPET_CONTEXT, SIGNATURE_POLICY_VERSION, STANDARD_FACES, STANDARD_FONTS, SessionEventPublisher, UNBAKED_KINDS, USAGE_INCOMPLETE, WIDGET_ACTION_EVENTS, WIDGET_FLAG_NAMES, actionTreeOf, actionWriteOf, advisoryFromPdfBits, allowsCapability, allowsFieldWrite, allowsSomeFieldWrite, anchorOf, annotationDefaultsOf, annotationImportFacts, annotationKey, annotationOfDraft, annotationPatchBetween, annotationResourceBuffers, annotationWriteCapabilities, annotationWriteCapability, appearanceChangeOf, appearanceImpactOf, appearanceLatticeScale, appearanceModesOf, appearanceTurnOf, applyAnnotationPatch, areaUnitLabel, assertAnnotationBundle, assertAnnotationBundleManifest, assertAnnotationResources, assertChoiceDefault, assertDeclaredFields, assertFormBundle, assertFormBundleManifest, assertPdfFloat, assertRichTextAgreement, assertWithinLimit, assertWritableMeasure, assessmentOf, attachmentVerbs, authorizeAnnotationCreate, authorizeAnnotationDelete, authorizeAnnotationUpdate, authorizeCapability, authorizeFieldGroup, authorizeFieldWrite, authorizeUnprotected, boundaryTextOffset, buildCommentThreads, buildSnippet, buildThreads, bundleCodec, bundlePageMapping, canonicalSearchQuery, caps, changeEvents, changeFingerprint, changedKeys, charBoundaryAtTextOffset, charMapViolation, charRangeForTextOffsets, checkAnyCapability, checkAnyFieldAction, checkCapability, checkCollab, checkFieldAction, checkImageQuality, checkRenderUsage, checkSetGroup, classifyRelation, clearlyOutranks, closeExportSelection, collab, collabTargetOf, colorOf, combine, compareIsoDateTime, concatAnnotationLists, conclude, createPageImageHandle, createPdfTextLayout, createTextLayout, decodeAnnotKey, decodeFieldRefKey, decodePageKey, decodePdfBits, decodeSubmitFormFlags, defaultEntryOfDraft, deletedAnnotationsOf, deletedAttachmentOf, deletedFieldOf, deletedOutlineItemsOf, deletedWith, deriveMeasurementLabel, deriveProtection, describeProtection, deserializeError, dictEntries, draftWritesScripts, drawnPointsOf, encodeAnnotKey, encodeFieldRefKey, encodePageKey, evaluateStep, expandRawScope, expandedCapabilities, faceForFreeTextFont, familyKey, familyOfSubtype, fieldAfterReset, fieldAfterValue, fieldLockFor, fieldMatches, fieldRightsOf, fieldScriptOf, fieldValueOf, fieldValueWriteOf, filterMatches, fitWidgetToFamily, foldOptionsFor, foldText, formEffectOps, formExportRowsOf, formFieldAfter, formFieldOfDraft, formImportFacts, formResetFacts, formValuesImportFacts, formWidget, formatMeasurement, formatObjectNumberRanges, freeTextFontForFace, generateUuid, generateUuidV7, glyphLooseBounds, glyphLooseQuad, hasAnnotationResources, imageSourceOfBytes, isAbortError, isAtDefault, isDimension, isFieldScript, isKeptRefusal, isLocalDocument, isLocalEngine, isLocalPage, isNoOpWrite, isProtectableCapability, isReadout, isRotatedGeometryRun, isSamePdfRect, isSkippedItem, isStandardFontName, isStateAnnotation, isUndoChange, isValidPageObjectNumber, itemWrote, levelAllows, levelFromPermission, lockCovers, lockNameCovers, manifestBytesOf, mapActionNode, mapActionTree, mapAnnotationActions, mapDocumentActions, mapFieldActions, mapLinkTarget, mapOutlineItem, mapPageActions, mapPageRefs, matchLiteral, matchPageText, matchRegex, materializePdfPermissions, measureFromKnownLength, measureFromRatio, measurementPoint, measurementReadout, mergeAnnotationPatch, minLevel, needsScriptRight, normalizeAttachmentFileSource, normalizePdfQuad, normalizePdfRect, objectNumbersIn, objectNumbersNamedBy, objectNumbersReferencedBy, opIdOf, outlineItemAfter, outlineItemOfDraft, outlineItemRefsEqual, outlineItemWithChildren, outlineVerbs, pageAnnotationDraftOf, pageAnnotationOf, pageAnnotationPatchOf, pageAppearancesOf, pageBoxOf, pageBoxesOf, pageDestinationOf, pageFieldActionsOf, pageFormFieldOf, pageFormSnapshotOf, pageGeometryOf, pageGlyphLooseBounds, pageGlyphLooseQuad, pageLayoutOf, pageListOf, pageMeasureOf, pageOutlineItemOf, pageOutlineOf, pagePointOf, pagePointTurned, pagePointUnturned, pagePointsBounds, pageQuadBounds, pageQuadOf, pageRefsEqual, pageRefsIn, pageRotationOf, pageSearchSliceOf, pageSpaceBoxesOf, pageTextSegmentOf, pageTransform, pageTurnOfDrawn, pageTurnOfUpright, pageVerbs, pageViewportsOf, pageWidgetOf, parseObjectNumberRanges, parsePdfValue, parseScope, passwordPromptFromState, pathLength, pdfAnnotationDraftOf, pdfAnnotationOf, pdfAnnotationPatchOf, pdfAppearanceTurnOf, pdfDestinationOf, pdfFormFieldDraftOf, pdfMeasureOf, pdfOutlineDraftOf, pdfOutlinePatchOf, pdfPermissions, pdfPointOf, pdfPointTurned, pdfPointUnturned, pdfPointsBounds, pdfQuadBounds, pdfQuadOf, pdfQuarterTurnBox, pdfRectFromOriginSize, pdfRectHeight, pdfRectIntersection, pdfRectOf, pdfRectSize, pdfRectToOriginSize, pdfRectTurnedBounds, pdfRectWidth, pdfRenderTargetOf, pdfTurnOfDrawn, pdfTurnOfUpright, pdfValueEquals, pdfWidgetPlacementOf, permissionInfoFromProbe, permissionInfoWithAdvisory, placeFor, placeIn, placedBefore, placedWidgetOf, polygonArea, positionIndex, primaryFinding, printDpiOf, printScale, protectedCapabilities, quarterTurnOf, rank, refsOf, renderAreaTransform, renderMatrix, renderSize, renderTargetArea, renderTransform, reorderPart, reorderedList, resolveAnnotationDraft, resolveAnnotationPatch, resolveAnnotationResources, resolveBinarySource, resolveChangeResources, resolveMeasurementDraft, resolvePageExtract, resolvePageLayers, resolveRectCommand, resourceIdOf, restrictionsFor, restrictionsOf, rgbOf, richTextParagraphsFromPlainText, richTextPlainText, sameColor, sameEffectiveValue, scaleOf, searchContentEpoch, searchQueryOf, securityStateFromHead, securityStateFromProbe, semanticEqual, serializeError, shapeForRect, shownAppearances, sliceText, snapAppearanceScale, snapFullPageViewport, snapTileScale, sniffBinaryMetadata, squareMetres, squareOf, stableStringify, standardStateModelOf, subscribeToType, subtypeFromCode, toAttachmentRef, toFieldRef, toOriginalRange, toOutlineItemRef, toPageRef, topRowOf, touchesCaption, validAreaBoundary, validNumberFormat, validateScopeArray, validateSearchQuery, validateSearchRegex, valueEntriesEqual, viewportForPoint, visibleBoxesOf, widgetActionsOf, widgetAfterPatch, widgetsAfterDisplay, wirePack, withFileFromResource, wordAt, wordBefore, worstVerdict, writesScripts };
360
815
 
361
816
  //# sourceMappingURL=runtime.js.map