@sanity/client 7.26.2 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +63 -341
  2. package/dist/browserUpload-2tz6Sdqp.js +87 -0
  3. package/dist/browserUpload-2tz6Sdqp.js.map +1 -0
  4. package/dist/browserUpload-CwpNx7Vl.js +87 -0
  5. package/dist/browserUpload-CwpNx7Vl.js.map +1 -0
  6. package/dist/config-3wiPP-sZ.js +126 -0
  7. package/dist/config-3wiPP-sZ.js.map +1 -0
  8. package/dist/csm.d.ts +122 -335
  9. package/dist/csm.js +79 -91
  10. package/dist/csm.js.map +1 -1
  11. package/dist/dist-C9ExSk2R.js +73 -0
  12. package/dist/dist-C9ExSk2R.js.map +1 -0
  13. package/dist/dist-Z8cIRxoB.js +69 -0
  14. package/dist/dist-Z8cIRxoB.js.map +1 -0
  15. package/dist/index.d.ts +112 -6722
  16. package/dist/index.js +2950 -2848
  17. package/dist/index.js.map +1 -1
  18. package/dist/{index.d.cts → index.node.d.ts} +4529 -5322
  19. package/dist/index.node.js +3264 -0
  20. package/dist/index.node.js.map +1 -0
  21. package/dist/isRecord-Kfmt-nk-.js +7 -0
  22. package/dist/isRecord-Kfmt-nk-.js.map +1 -0
  23. package/dist/media-library.d.ts +9 -100
  24. package/dist/media-library.js +36 -14
  25. package/dist/media-library.js.map +1 -1
  26. package/dist/request-BhMuKj0D.js +373 -0
  27. package/dist/request-BhMuKj0D.js.map +1 -0
  28. package/dist/request-SnMg7nUX.js +355 -0
  29. package/dist/request-SnMg7nUX.js.map +1 -0
  30. package/dist/resolveEditInfo-Cz-smq3a.js +339 -0
  31. package/dist/resolveEditInfo-Cz-smq3a.js.map +1 -0
  32. package/dist/rolldown-runtime-vyAXikos.js +9 -0
  33. package/dist/stega.d.ts +78 -7137
  34. package/dist/stega.js +27 -20
  35. package/dist/stega.js.map +1 -1
  36. package/dist/stegaClean-C18wLWau.js +21 -0
  37. package/dist/stegaClean-C18wLWau.js.map +1 -0
  38. package/dist/stegaEncodeSourceMap-DbM2fTN4.js +373 -0
  39. package/dist/stegaEncodeSourceMap-DbM2fTN4.js.map +1 -0
  40. package/dist/stegaEncodeSourceMap-YR3NQ3iz.js +163 -0
  41. package/dist/stegaEncodeSourceMap-YR3NQ3iz.js.map +1 -0
  42. package/dist/{index.browser.d.cts → types-BODIEY7F.d.ts} +4196 -5258
  43. package/dist/types-CfGzbXrl.d.ts +108 -0
  44. package/package.json +80 -142
  45. package/src/SanityClient.ts +101 -137
  46. package/src/agent/actions/AgentActionsClient.ts +12 -12
  47. package/src/agent/actions/commonTypes.ts +2 -1
  48. package/src/agent/actions/generate.ts +26 -6
  49. package/src/agent/actions/patch.ts +27 -7
  50. package/src/agent/actions/prompt.ts +19 -5
  51. package/src/agent/actions/transform.ts +23 -5
  52. package/src/agent/actions/translate.ts +23 -5
  53. package/src/assets/AssetsClient.ts +121 -24
  54. package/src/csm/applySourceDocuments.ts +5 -5
  55. package/src/csm/createEditUrl.ts +1 -1
  56. package/src/csm/draftUtils.ts +23 -5
  57. package/src/csm/index.ts +2 -2
  58. package/src/csm/studioPath.ts +2 -1
  59. package/src/csm/types.ts +8 -2
  60. package/src/data/dataMethods.ts +784 -349
  61. package/src/data/eventsource.ts +82 -49
  62. package/src/data/listen.ts +18 -23
  63. package/src/data/live.ts +60 -35
  64. package/src/data/resolveEventSourceFetch.ts +104 -0
  65. package/src/datasets/DatasetsClient.ts +58 -41
  66. package/src/defineCreateClient.ts +38 -22
  67. package/src/functions/FunctionsClient.ts +66 -0
  68. package/src/functions/invoke.ts +176 -0
  69. package/src/http/browserMiddleware.ts +7 -1
  70. package/src/http/browserUpload.ts +163 -0
  71. package/src/http/errors.ts +61 -6
  72. package/src/http/nodeMiddleware.ts +94 -30
  73. package/src/http/request.ts +304 -87
  74. package/src/http/requestOptions.ts +131 -15
  75. package/src/{index.browser.ts → index.node.ts} +9 -4
  76. package/src/index.ts +4 -3
  77. package/src/mediaLibrary/MediaLibraryVideoClient.ts +27 -12
  78. package/src/projects/ProjectsClient.ts +18 -16
  79. package/src/releases/ReleasesClient.ts +38 -33
  80. package/src/stega/index.ts +1 -2
  81. package/src/stega/stegaEncodeSourceMap.ts +5 -0
  82. package/src/stega/types.ts +2 -2
  83. package/src/types.ts +328 -103
  84. package/src/users/UsersClient.ts +10 -14
  85. package/src/util/shareReplayLatest.ts +1 -1
  86. package/src/validators.ts +1 -1
  87. package/src/warnings.ts +13 -2
  88. package/dist/_chunks-cjs/config.cjs +0 -206
  89. package/dist/_chunks-cjs/config.cjs.map +0 -1
  90. package/dist/_chunks-cjs/isRecord.cjs +0 -6
  91. package/dist/_chunks-cjs/isRecord.cjs.map +0 -1
  92. package/dist/_chunks-cjs/resolveEditInfo.cjs +0 -334
  93. package/dist/_chunks-cjs/resolveEditInfo.cjs.map +0 -1
  94. package/dist/_chunks-cjs/stegaClean.cjs +0 -46
  95. package/dist/_chunks-cjs/stegaClean.cjs.map +0 -1
  96. package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +0 -388
  97. package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +0 -1
  98. package/dist/_chunks-es/config.js +0 -207
  99. package/dist/_chunks-es/config.js.map +0 -1
  100. package/dist/_chunks-es/isRecord.js +0 -7
  101. package/dist/_chunks-es/isRecord.js.map +0 -1
  102. package/dist/_chunks-es/resolveEditInfo.js +0 -335
  103. package/dist/_chunks-es/resolveEditInfo.js.map +0 -1
  104. package/dist/_chunks-es/stegaClean.js +0 -47
  105. package/dist/_chunks-es/stegaClean.js.map +0 -1
  106. package/dist/_chunks-es/stegaEncodeSourceMap.js +0 -389
  107. package/dist/_chunks-es/stegaEncodeSourceMap.js.map +0 -1
  108. package/dist/csm.cjs +0 -99
  109. package/dist/csm.cjs.map +0 -1
  110. package/dist/csm.d.cts +0 -391
  111. package/dist/index.browser.cjs +0 -3106
  112. package/dist/index.browser.cjs.map +0 -1
  113. package/dist/index.browser.d.ts +0 -6802
  114. package/dist/index.browser.js +0 -3082
  115. package/dist/index.browser.js.map +0 -1
  116. package/dist/index.cjs +0 -2946
  117. package/dist/index.cjs.map +0 -1
  118. package/dist/media-library.cjs +0 -20
  119. package/dist/media-library.cjs.map +0 -1
  120. package/dist/media-library.d.cts +0 -117
  121. package/dist/stega.browser.cjs +0 -29
  122. package/dist/stega.browser.cjs.map +0 -1
  123. package/dist/stega.browser.d.cts +0 -7200
  124. package/dist/stega.browser.d.ts +0 -7200
  125. package/dist/stega.browser.js +0 -24
  126. package/dist/stega.browser.js.map +0 -1
  127. package/dist/stega.cjs +0 -29
  128. package/dist/stega.cjs.map +0 -1
  129. package/dist/stega.d.cts +0 -7200
  130. package/src/data/eventsourcePolyfill.ts +0 -7
  131. package/umd/.gitkeep +0 -1
  132. package/umd/sanityClient.js +0 -6543
  133. package/umd/sanityClient.min.js +0 -6
package/dist/csm.js CHANGED
@@ -1,101 +1,89 @@
1
- import { getVersionId, getDraftId, getPublishedId, walkMap, resolveMapping, parseJsonPath, toString, get, jsonPath, studioPathToJsonPath, resolveEditInfo, createEditUrl } from "./_chunks-es/resolveEditInfo.js";
2
- import { DRAFTS_FOLDER, VERSION_FOLDER, getVersionFromId, isDraftId, isPublishedId, isVersionId, jsonPathToStudioPath, studioPath } from "./_chunks-es/resolveEditInfo.js";
3
- import { validateApiPerspective } from "./_chunks-es/config.js";
1
+ import { r as validateApiPerspective } from "./config-3wiPP-sZ.js";
2
+ import { S as toString, _ as isPublishedId, a as resolveMapping, c as parseJsonPath, d as VERSION_FOLDER, f as getDraftId, g as isDraftId, h as getVersionId, i as walkMap, l as studioPathToJsonPath, m as getVersionFromId, o as jsonPath, p as getPublishedId, r as createEditUrl, s as jsonPathToStudioPath, t as resolveEditInfo, u as DRAFTS_FOLDER, v as isVersionId, x as studioPath_exports, y as get } from "./resolveEditInfo-Cz-smq3a.js";
3
+ /**
4
+ * This resolves the perspectives to how documents should be resolved when applying optimistic updates,
5
+ * like in `applySourceDocuments`.
6
+ * @internal
7
+ */
4
8
  function resolvePerspectives(perspective) {
5
- if (validateApiPerspective(perspective), Array.isArray(perspective))
6
- return perspective.includes("published") ? perspective : [...perspective, "published"];
7
- switch (perspective) {
8
- case "previewDrafts":
9
- case "drafts":
10
- return ["drafts", "published"];
11
- case "published":
12
- default:
13
- return ["published"];
14
- }
9
+ if (validateApiPerspective(perspective), Array.isArray(perspective)) return perspective.includes("published") ? perspective : [...perspective, "published"];
10
+ switch (perspective) {
11
+ case "previewDrafts":
12
+ case "drafts": return ["drafts", "published"];
13
+ default: return ["published"];
14
+ }
15
15
  }
16
+ /** @internal */
16
17
  function createSourceDocumentResolver(getCachedDocument, _perspective) {
17
- const perspectives = resolvePerspectives(_perspective);
18
- function findDocument(sourceDocument) {
19
- for (const perspective of perspectives) {
20
- let match = null;
21
- if (perspective.startsWith("r") && (match = getCachedDocument({
22
- ...sourceDocument,
23
- _id: getVersionId(sourceDocument._id, perspective)
24
- })), perspective === "drafts" && (match = getCachedDocument({
25
- ...sourceDocument,
26
- _id: getDraftId(sourceDocument._id)
27
- })), perspective === "published" && (match = getCachedDocument({
28
- ...sourceDocument,
29
- _id: getPublishedId(sourceDocument._id)
30
- })), match)
31
- return { ...match, _id: getPublishedId(match._id), _originalId: match._id };
32
- }
33
- return null;
34
- }
35
- return function(sourceDocument) {
36
- return findDocument(sourceDocument);
37
- };
18
+ let perspectives = resolvePerspectives(_perspective);
19
+ function findDocument(sourceDocument) {
20
+ for (let perspective of perspectives) {
21
+ let match = null;
22
+ if (perspective.startsWith("r") && (match = getCachedDocument({
23
+ ...sourceDocument,
24
+ _id: getVersionId(sourceDocument._id, perspective)
25
+ })), perspective === "drafts" && (match = getCachedDocument({
26
+ ...sourceDocument,
27
+ _id: getDraftId(sourceDocument._id)
28
+ })), perspective === "published" && (match = getCachedDocument({
29
+ ...sourceDocument,
30
+ _id: getPublishedId(sourceDocument._id)
31
+ })), match) return {
32
+ ...match,
33
+ _id: getPublishedId(match._id),
34
+ _originalId: match._id
35
+ };
36
+ }
37
+ return null;
38
+ }
39
+ return function resolveSourceDocument(sourceDocument) {
40
+ return findDocument(sourceDocument);
41
+ };
38
42
  }
43
+ /**
44
+ * Optimistically applies source documents to a result, using the content source map to trace fields.
45
+ * Can be used to apply mutations to documents being edited in a Studio, or any mutation on Content Lake, to a result with extremely low latency.
46
+ * @alpha
47
+ */
39
48
  function applySourceDocuments(result, resultSourceMap, getCachedDocument, updateFn, perspective) {
40
- if (!resultSourceMap) return result;
41
- const resolveDocument = createSourceDocumentResolver(getCachedDocument, perspective), cachedDocuments = resultSourceMap.documents?.map?.(resolveDocument) || [];
42
- return walkMap(JSON.parse(JSON.stringify(result)), (value, path) => {
43
- const resolveMappingResult = resolveMapping(path, resultSourceMap);
44
- if (!resolveMappingResult)
45
- return value;
46
- const { mapping, pathSuffix } = resolveMappingResult;
47
- if (mapping.type !== "value" || mapping.source.type !== "documentValue")
48
- return value;
49
- const sourceDocument = resultSourceMap.documents[mapping.source.document], sourcePath = resultSourceMap.paths[mapping.source.path];
50
- if (sourceDocument) {
51
- const parsedPath = parseJsonPath(sourcePath + pathSuffix), stringifiedPath = toString(parsedPath), cachedDocument = cachedDocuments[mapping.source.document];
52
- if (!cachedDocument)
53
- return value;
54
- const changedValue = cachedDocument ? get(cachedDocument, stringifiedPath, value) : value;
55
- return value === changedValue ? value : updateFn(changedValue, {
56
- cachedDocument,
57
- previousValue: value,
58
- sourceDocument,
59
- sourcePath: parsedPath
60
- });
61
- }
62
- return value;
63
- });
49
+ if (!resultSourceMap) return result;
50
+ let resolveDocument = createSourceDocumentResolver(getCachedDocument, perspective), cachedDocuments = resultSourceMap.documents?.map?.(resolveDocument) || [];
51
+ return walkMap(JSON.parse(JSON.stringify(result)), (value, path) => {
52
+ let resolveMappingResult = resolveMapping(path, resultSourceMap);
53
+ if (!resolveMappingResult) return value;
54
+ let { mapping, pathSuffix } = resolveMappingResult;
55
+ if (mapping.type !== "value" || mapping.source.type !== "documentValue") return value;
56
+ let sourceDocument = resultSourceMap.documents[mapping.source.document], sourcePath = resultSourceMap.paths[mapping.source.path];
57
+ if (sourceDocument) {
58
+ let parsedPath = parseJsonPath(sourcePath + pathSuffix), stringifiedPath = toString(parsedPath), cachedDocument = cachedDocuments[mapping.source.document];
59
+ if (!cachedDocument) return value;
60
+ let changedValue = cachedDocument ? get(cachedDocument, stringifiedPath, value) : value;
61
+ return value === changedValue ? value : updateFn(changedValue, {
62
+ cachedDocument,
63
+ previousValue: value,
64
+ sourceDocument,
65
+ sourcePath: parsedPath
66
+ });
67
+ }
68
+ return value;
69
+ });
64
70
  }
71
+ /**
72
+ * @internal
73
+ */
65
74
  function resolvedKeyedSourcePath(options) {
66
- const { keyedResultPath, pathSuffix, sourceBasePath } = options, inferredResultPath = pathSuffix === void 0 ? [] : parseJsonPath(pathSuffix), inferredPath = keyedResultPath.slice(keyedResultPath.length - inferredResultPath.length), inferredPathSuffix = inferredPath.length ? jsonPath(inferredPath).slice(1) : "";
67
- return parseJsonPath(sourceBasePath + inferredPathSuffix);
75
+ let { keyedResultPath, pathSuffix, sourceBasePath } = options, inferredResultPath = pathSuffix === void 0 ? [] : parseJsonPath(pathSuffix), inferredPath = keyedResultPath.slice(keyedResultPath.length - inferredResultPath.length), inferredPathSuffix = inferredPath.length ? jsonPath(inferredPath).slice(1) : "";
76
+ return parseJsonPath(sourceBasePath + inferredPathSuffix);
68
77
  }
78
+ /** @alpha */
69
79
  function resolveEditUrl(options) {
70
- const { resultSourceMap, studioUrl } = options, resultPath = studioPathToJsonPath(options.resultPath), editInfo = resolveEditInfo({
71
- resultPath,
72
- resultSourceMap,
73
- studioUrl
74
- });
75
- if (editInfo)
76
- return createEditUrl(editInfo);
80
+ let { resultSourceMap, studioUrl } = options, resultPath = studioPathToJsonPath(options.resultPath), editInfo = resolveEditInfo({
81
+ resultPath,
82
+ resultSourceMap,
83
+ studioUrl
84
+ });
85
+ if (editInfo) return createEditUrl(editInfo);
77
86
  }
78
- export {
79
- DRAFTS_FOLDER,
80
- VERSION_FOLDER,
81
- applySourceDocuments,
82
- createEditUrl,
83
- getDraftId,
84
- getPublishedId,
85
- getVersionFromId,
86
- getVersionId,
87
- isDraftId,
88
- isPublishedId,
89
- isVersionId,
90
- jsonPath,
91
- jsonPathToStudioPath,
92
- parseJsonPath,
93
- resolveEditInfo,
94
- resolveEditUrl,
95
- resolveMapping,
96
- resolvedKeyedSourcePath,
97
- studioPath,
98
- studioPathToJsonPath,
99
- walkMap
100
- };
101
- //# sourceMappingURL=csm.js.map
87
+ export { DRAFTS_FOLDER, VERSION_FOLDER, applySourceDocuments, createEditUrl, getDraftId, getPublishedId, getVersionFromId, getVersionId, isDraftId, isPublishedId, isVersionId, jsonPath, jsonPathToStudioPath, parseJsonPath, resolveEditInfo, resolveEditUrl, resolveMapping, resolvedKeyedSourcePath, studioPath_exports as studioPath, studioPathToJsonPath, walkMap };
88
+
89
+ //# sourceMappingURL=csm.js.map
package/dist/csm.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"csm.js","sources":["../src/csm/resolvePerspectives.ts","../src/csm/createSourceDocumentResolver.ts","../src/csm/applySourceDocuments.ts","../src/csm/resolvedKeyedSourcePath.ts","../src/csm/resolveEditUrl.ts"],"sourcesContent":["import {validateApiPerspective} from '../config'\nimport type {StackablePerspective} from '../types'\nimport type {ClientPerspective} from './types'\n\n/**\n * This resolves the perspectives to how documents should be resolved when applying optimistic updates,\n * like in `applySourceDocuments`.\n * @internal\n */\nexport function resolvePerspectives(\n perspective: Exclude<ClientPerspective, 'raw'>,\n): ('published' | 'drafts' | StackablePerspective)[] {\n validateApiPerspective(perspective)\n\n if (Array.isArray(perspective)) {\n if (!perspective.includes('published')) {\n return [...perspective, 'published']\n }\n return perspective\n }\n switch (perspective) {\n case 'previewDrafts':\n case 'drafts':\n return ['drafts', 'published']\n case 'published':\n default:\n return ['published']\n }\n}\n","import {getDraftId, getPublishedId, getVersionId} from './draftUtils'\nimport {resolvePerspectives} from './resolvePerspectives'\nimport type {ClientPerspective, ContentSourceMapDocuments, SanityDocument} from './types'\n\n/** @internal */\nexport type ResolvedDocument = Partial<SanityDocument> &\n Required<Pick<SanityDocument, '_id' | '_type'>>\n\n/** @internal */\nexport type MatchedDocument = Partial<SanityDocument> &\n Required<Pick<SanityDocument, '_id' | '_type' | '_originalId'>>\n\n/** @internal */\nexport function createSourceDocumentResolver(\n getCachedDocument: (\n sourceDocument: ContentSourceMapDocuments[number],\n ) => ResolvedDocument | null | undefined,\n _perspective: Exclude<ClientPerspective, 'raw'>,\n) {\n const perspectives = resolvePerspectives(_perspective)\n function findDocument(sourceDocument: ContentSourceMapDocuments[number]) {\n for (const perspective of perspectives) {\n let match: ReturnType<typeof getCachedDocument> = null\n if (perspective.startsWith('r')) {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getVersionId(sourceDocument._id, perspective),\n })\n }\n if (perspective === 'drafts') {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getDraftId(sourceDocument._id),\n })\n }\n if (perspective === 'published') {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getPublishedId(sourceDocument._id),\n })\n }\n if (match) {\n return {...match, _id: getPublishedId(match._id), _originalId: match._id}\n }\n }\n return null\n }\n // define resolver that loops over source documents and perspectives\n return function resolveSourceDocument(\n sourceDocument: ContentSourceMapDocuments[number],\n ): MatchedDocument | null {\n return findDocument(sourceDocument)\n }\n}\n","import {createSourceDocumentResolver} from './createSourceDocumentResolver'\nimport {parseJsonPath} from './jsonPath'\nimport {resolveMapping} from './resolveMapping'\nimport * as paths from './studioPath'\nimport type {\n Any,\n ApplySourceDocumentsUpdateFunction,\n ClientPerspective,\n ContentSourceMap,\n ContentSourceMapDocuments,\n Path,\n SanityDocument,\n} from './types'\nimport {walkMap} from './walkMap'\n\n/**\n * Optimistically applies source documents to a result, using the content source map to trace fields.\n * Can be used to apply mutations to documents being edited in a Studio, or any mutation on Content Lake, to a result with extremely low latency.\n * @alpha\n */\nexport function applySourceDocuments<Result = unknown>(\n result: Result,\n resultSourceMap: ContentSourceMap | undefined,\n getCachedDocument: (\n sourceDocument: ContentSourceMapDocuments[number],\n ) =>\n (Partial<SanityDocument> & Required<Pick<SanityDocument, '_id' | '_type'>>) | null | undefined,\n updateFn: ApplySourceDocumentsUpdateFunction,\n perspective: Exclude<ClientPerspective, 'raw'>,\n): Result {\n if (!resultSourceMap) return result\n\n const resolveDocument = createSourceDocumentResolver(getCachedDocument, perspective)\n const cachedDocuments = resultSourceMap.documents?.map?.(resolveDocument) || []\n\n return walkMap(JSON.parse(JSON.stringify(result)), (value, path) => {\n const resolveMappingResult = resolveMapping(path, resultSourceMap)\n if (!resolveMappingResult) {\n return value\n }\n\n const {mapping, pathSuffix} = resolveMappingResult\n if (mapping.type !== 'value') {\n return value\n }\n\n if (mapping.source.type !== 'documentValue') {\n return value\n }\n\n const sourceDocument = resultSourceMap.documents[mapping.source.document]\n const sourcePath = resultSourceMap.paths[mapping.source.path]\n\n if (sourceDocument) {\n const parsedPath = parseJsonPath(sourcePath + pathSuffix)\n const stringifiedPath = paths.toString(parsedPath as Path)\n const cachedDocument = cachedDocuments[mapping.source.document]\n\n if (!cachedDocument) {\n return value\n }\n\n const changedValue = cachedDocument\n ? paths.get<Result[keyof Result]>(cachedDocument, stringifiedPath, value)\n : value\n return value === changedValue\n ? value\n : updateFn<Result[keyof Result]>(changedValue as Any, {\n cachedDocument,\n previousValue: value as Result[keyof Result],\n sourceDocument,\n sourcePath: parsedPath,\n })\n }\n\n return value\n }) as Result\n}\n","import {jsonPath, parseJsonPath} from './jsonPath'\nimport type {ContentSourceMapParsedPath} from './types'\n\n/**\n * @internal\n */\nexport function resolvedKeyedSourcePath(options: {\n keyedResultPath: ContentSourceMapParsedPath\n pathSuffix?: string\n sourceBasePath: string\n}): ContentSourceMapParsedPath {\n const {keyedResultPath, pathSuffix, sourceBasePath} = options\n\n const inferredResultPath = pathSuffix === undefined ? [] : parseJsonPath(pathSuffix)\n\n const inferredPath = keyedResultPath.slice(keyedResultPath.length - inferredResultPath.length)\n\n const inferredPathSuffix = inferredPath.length ? jsonPath(inferredPath).slice(1) : ''\n\n return parseJsonPath(sourceBasePath + inferredPathSuffix)\n}\n","import {createEditUrl} from './createEditUrl'\nimport {studioPathToJsonPath} from './jsonPath'\nimport {resolveEditInfo} from './resolveEditInfo'\nimport type {ResolveEditUrlOptions} from './types'\n\n/** @alpha */\nexport function resolveEditUrl(\n options: ResolveEditUrlOptions,\n): ReturnType<typeof createEditUrl> | undefined {\n const {resultSourceMap, studioUrl} = options\n const resultPath = studioPathToJsonPath(options.resultPath)\n\n const editInfo = resolveEditInfo({\n resultPath,\n resultSourceMap,\n studioUrl,\n })\n if (!editInfo) {\n return undefined\n }\n\n return createEditUrl(editInfo)\n}\n"],"names":["paths.toString","paths.get"],"mappings":";;;AASO,SAAS,oBACd,aACmD;AAGnD,MAFA,uBAAuB,WAAW,GAE9B,MAAM,QAAQ,WAAW;AAC3B,WAAK,YAAY,SAAS,WAAW,IAG9B,cAFE,CAAC,GAAG,aAAa,WAAW;AAIvC,UAAQ,aAAA;AAAA,IACN,KAAK;AAAA,IACL,KAAK;AACH,aAAO,CAAC,UAAU,WAAW;AAAA,IAC/B,KAAK;AAAA,IACL;AACE,aAAO,CAAC,WAAW;AAAA,EAAA;AAEzB;ACfO,SAAS,6BACd,mBAGA,cACA;AACA,QAAM,eAAe,oBAAoB,YAAY;AACrD,WAAS,aAAa,gBAAmD;AACvE,eAAW,eAAe,cAAc;AACtC,UAAI,QAA8C;AAmBlD,UAlBI,YAAY,WAAW,GAAG,MAC5B,QAAQ,kBAAkB;AAAA,QACxB,GAAG;AAAA,QACH,KAAK,aAAa,eAAe,KAAK,WAAW;AAAA,MAAA,CAClD,IAEC,gBAAgB,aAClB,QAAQ,kBAAkB;AAAA,QACxB,GAAG;AAAA,QACH,KAAK,WAAW,eAAe,GAAG;AAAA,MAAA,CACnC,IAEC,gBAAgB,gBAClB,QAAQ,kBAAkB;AAAA,Q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,SAEhD,qBAAqB,eAAe,SAAY,CAAA,IAAK,cAAc,UAAU,GAE7E,eAAe,gBAAgB,MAAM,gBAAgB,SAAS,mBAAmB,MAAM,GAEvF,qBAAqB,aAAa,SAAS,SAAS,YAAY,EAAE,MAAM,CAAC,IAAI;AAEnF,SAAO,cAAc,iBAAiB,kBAAkB;AAC1D;ACdO,SAAS,eACd,SAC8C;AAC9C,QAAM,EAAC,iBAAiB,UAAA,IAAa,SAC/B,aAAa,qBAAqB,QAAQ,UAAU,GAEpD,WAAW,gBAAgB;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AACD,MAAK;AAIL,WAAO,cAAc,QAAQ;AAC/B;"}
1
+ {"version":3,"file":"csm.js","names":["paths.toString","paths.get"],"sources":["../src/csm/resolvePerspectives.ts","../src/csm/createSourceDocumentResolver.ts","../src/csm/applySourceDocuments.ts","../src/csm/resolvedKeyedSourcePath.ts","../src/csm/resolveEditUrl.ts"],"sourcesContent":["import {validateApiPerspective} from '../config'\nimport type {StackablePerspective} from '../types'\nimport type {ClientPerspective} from './types'\n\n/**\n * This resolves the perspectives to how documents should be resolved when applying optimistic updates,\n * like in `applySourceDocuments`.\n * @internal\n */\nexport function resolvePerspectives(\n perspective: Exclude<ClientPerspective, 'raw'>,\n): ('published' | 'drafts' | StackablePerspective)[] {\n validateApiPerspective(perspective)\n\n if (Array.isArray(perspective)) {\n if (!perspective.includes('published')) {\n return [...perspective, 'published']\n }\n return perspective\n }\n switch (perspective) {\n case 'previewDrafts':\n case 'drafts':\n return ['drafts', 'published']\n case 'published':\n default:\n return ['published']\n }\n}\n","import {getDraftId, getPublishedId, getVersionId} from './draftUtils'\nimport {resolvePerspectives} from './resolvePerspectives'\nimport type {ClientPerspective, ContentSourceMapDocuments, SanityDocument} from './types'\n\n/** @internal */\nexport type ResolvedDocument = Partial<SanityDocument> &\n Required<Pick<SanityDocument, '_id' | '_type'>>\n\n/** @internal */\nexport type MatchedDocument = Partial<SanityDocument> &\n Required<Pick<SanityDocument, '_id' | '_type' | '_originalId'>>\n\n/** @internal */\nexport function createSourceDocumentResolver(\n getCachedDocument: (\n sourceDocument: ContentSourceMapDocuments[number],\n ) => ResolvedDocument | null | undefined,\n _perspective: Exclude<ClientPerspective, 'raw'>,\n) {\n const perspectives = resolvePerspectives(_perspective)\n function findDocument(sourceDocument: ContentSourceMapDocuments[number]) {\n for (const perspective of perspectives) {\n let match: ReturnType<typeof getCachedDocument> = null\n if (perspective.startsWith('r')) {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getVersionId(sourceDocument._id, perspective),\n })\n }\n if (perspective === 'drafts') {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getDraftId(sourceDocument._id),\n })\n }\n if (perspective === 'published') {\n match = getCachedDocument({\n ...sourceDocument,\n _id: getPublishedId(sourceDocument._id),\n })\n }\n if (match) {\n return {...match, _id: getPublishedId(match._id), _originalId: match._id}\n }\n }\n return null\n }\n // define resolver that loops over source documents and perspectives\n return function resolveSourceDocument(\n sourceDocument: ContentSourceMapDocuments[number],\n ): MatchedDocument | null {\n return findDocument(sourceDocument)\n }\n}\n","import {createSourceDocumentResolver} from './createSourceDocumentResolver'\nimport {parseJsonPath} from './jsonPath'\nimport {resolveMapping} from './resolveMapping'\nimport * as paths from './studioPath'\nimport type {\n ApplySourceDocumentsUpdateFunction,\n ClientPerspective,\n ContentSourceMap,\n ContentSourceMapDocuments,\n SanityDocument,\n} from './types'\nimport {walkMap} from './walkMap'\n\n/**\n * Optimistically applies source documents to a result, using the content source map to trace fields.\n * Can be used to apply mutations to documents being edited in a Studio, or any mutation on Content Lake, to a result with extremely low latency.\n * @alpha\n */\nexport function applySourceDocuments<Result = unknown>(\n result: Result,\n resultSourceMap: ContentSourceMap | undefined,\n getCachedDocument: (\n sourceDocument: ContentSourceMapDocuments[number],\n ) =>\n | (Partial<SanityDocument> & Required<Pick<SanityDocument, '_id' | '_type'>>)\n | null\n | undefined,\n updateFn: ApplySourceDocumentsUpdateFunction,\n perspective: Exclude<ClientPerspective, 'raw'>,\n): Result {\n if (!resultSourceMap) return result\n\n const resolveDocument = createSourceDocumentResolver(getCachedDocument, perspective)\n const cachedDocuments = resultSourceMap.documents?.map?.(resolveDocument) || []\n\n return walkMap(JSON.parse(JSON.stringify(result)), (value, path) => {\n const resolveMappingResult = resolveMapping(path, resultSourceMap)\n if (!resolveMappingResult) {\n return value\n }\n\n const {mapping, pathSuffix} = resolveMappingResult\n if (mapping.type !== 'value') {\n return value\n }\n\n if (mapping.source.type !== 'documentValue') {\n return value\n }\n\n const sourceDocument = resultSourceMap.documents[mapping.source.document]\n const sourcePath = resultSourceMap.paths[mapping.source.path]\n\n if (sourceDocument) {\n const parsedPath = parseJsonPath(sourcePath + pathSuffix)\n const stringifiedPath = paths.toString(parsedPath)\n const cachedDocument = cachedDocuments[mapping.source.document]\n\n if (!cachedDocument) {\n return value\n }\n\n const changedValue = cachedDocument\n ? paths.get<Result[keyof Result]>(cachedDocument, stringifiedPath, value)\n : value\n return value === changedValue\n ? value\n : updateFn<Result[keyof Result]>(changedValue as Result[keyof Result], {\n cachedDocument,\n previousValue: value as Result[keyof Result],\n sourceDocument,\n sourcePath: parsedPath,\n })\n }\n\n return value\n }) as Result\n}\n","import {jsonPath, parseJsonPath} from './jsonPath'\nimport type {ContentSourceMapParsedPath} from './types'\n\n/**\n * @internal\n */\nexport function resolvedKeyedSourcePath(options: {\n keyedResultPath: ContentSourceMapParsedPath\n pathSuffix?: string\n sourceBasePath: string\n}): ContentSourceMapParsedPath {\n const {keyedResultPath, pathSuffix, sourceBasePath} = options\n\n const inferredResultPath = pathSuffix === undefined ? [] : parseJsonPath(pathSuffix)\n\n const inferredPath = keyedResultPath.slice(keyedResultPath.length - inferredResultPath.length)\n\n const inferredPathSuffix = inferredPath.length ? jsonPath(inferredPath).slice(1) : ''\n\n return parseJsonPath(sourceBasePath + inferredPathSuffix)\n}\n","import {createEditUrl} from './createEditUrl'\nimport {studioPathToJsonPath} from './jsonPath'\nimport {resolveEditInfo} from './resolveEditInfo'\nimport type {ResolveEditUrlOptions} from './types'\n\n/** @alpha */\nexport function resolveEditUrl(\n options: ResolveEditUrlOptions,\n): ReturnType<typeof createEditUrl> | undefined {\n const {resultSourceMap, studioUrl} = options\n const resultPath = studioPathToJsonPath(options.resultPath)\n\n const editInfo = resolveEditInfo({\n resultPath,\n resultSourceMap,\n studioUrl,\n })\n if (!editInfo) {\n return undefined\n }\n\n return createEditUrl(editInfo)\n}\n"],"mappings":";;;;;;;AASA,SAAgB,oBACd,aACmD;CAGnD,IAFA,uBAAuB,WAAW,GAE9B,MAAM,QAAQ,WAAW,GAI3B,OAHK,YAAY,SAAS,WAAW,IAG9B,cAFE,CAAC,GAAG,aAAa,WAAW;CAIvC,QAAQ,aAAR;EACE,KAAK;EACL,KAAK,UACH,OAAO,CAAC,UAAU,WAAW;EAE/B,SACE,OAAO,CAAC,WAAW;CACvB;AACF;;ACfA,SAAgB,6BACd,mBAGA,cACA;CACA,IAAM,eAAe,oBAAoB,YAAY;CACrD,SAAS,aAAa,gBAAmD;EACvE,KAAK,IAAM,eAAe,cAAc;GACtC,IAAI,QAA8C;GAmBlD,IAlBI,YAAY,WAAW,GAAG,MAC5B,QAAQ,kBAAkB;IACxB,GAAG;IACH,KAAK,aAAa,eAAe,KAAK,WAAW;GACnD,CAAC,IAEC,gBAAgB,aAClB,QAAQ,kBAAkB;IACxB,GAAG;IACH,KAAK,WAAW,eAAe,GAAG;GACpC,CAAC,IAEC,gBAAgB,gBAClB,QAAQ,kBAAkB;IACxB,GAAG;IACH,KAAK,eAAe,eAAe,GAAG;GACxC,CAAC,IAEC,OACF,OAAO;IAAC,GAAG;IAAO,KAAK,eAAe,MAAM,GAAG;IAAG,aAAa,MAAM;GAAG;EAE5E;EACA,OAAO;CACT;CAEA,OAAO,SAAS,sBACd,gBACwB;EACxB,OAAO,aAAa,cAAc;CACpC;AACF;;;;;;ACnCA,SAAgB,qBACd,QACA,iBACA,mBAMA,U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;EACA;CACF,CAAC;CACI,cAIL,OAAO,cAAc,QAAQ;AAC/B"}
@@ -0,0 +1,73 @@
1
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports), require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
2
+ Object.defineProperty(exports, "__esModule", { value: !0 });
3
+ var p = {
4
+ 0: 8203,
5
+ 1: 8204,
6
+ 2: 8205,
7
+ 3: 8290,
8
+ 4: 8291,
9
+ 5: 8288,
10
+ 6: 65279,
11
+ 7: 8289,
12
+ 8: 119155,
13
+ 9: 119156,
14
+ a: 119157,
15
+ b: 119158,
16
+ c: 119159,
17
+ d: 119160,
18
+ e: 119161,
19
+ f: 119162
20
+ }, l = {
21
+ 0: 8203,
22
+ 1: 8204,
23
+ 2: 8205,
24
+ 3: 65279
25
+ }, d = {
26
+ 0: String.fromCodePoint(l[0]),
27
+ 1: String.fromCodePoint(l[1]),
28
+ 2: String.fromCodePoint(l[2]),
29
+ 3: String.fromCodePoint(l[3])
30
+ }, u = [
31
+ ,
32
+ ,
33
+ ,
34
+ ,
35
+ ].fill(String.fromCodePoint(l[0])).join("");
36
+ function A(e) {
37
+ let r = JSON.stringify(e), t = new TextEncoder().encode(r), i = "";
38
+ for (let c = 0; c < t.length; c++) {
39
+ let n = t[c];
40
+ i += d[n >> 6 & 3] + d[n >> 4 & 3] + d[n >> 2 & 3] + d[n & 3];
41
+ }
42
+ return u + i;
43
+ }
44
+ function I(e) {
45
+ return !Number.isNaN(Number(e)) || /[a-z]/i.test(e) && !/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(e) ? !1 : !!Date.parse(e);
46
+ }
47
+ function S(e) {
48
+ try {
49
+ new URL(e, e.startsWith("/") ? "https://acme.com" : void 0);
50
+ } catch {
51
+ return !1;
52
+ }
53
+ return !0;
54
+ }
55
+ function y(e, r, t = "auto") {
56
+ return t === !0 || t === "auto" && (I(e) || S(e)) ? e : `${e}${A(r)}`;
57
+ }
58
+ Object.fromEntries(Object.entries(d).map((e) => [e[1], +e[0]])), Object.fromEntries(Object.entries(p).map((e) => e.reverse()));
59
+ var h = `${Object.values(p).map((e) => `\\u{${e.toString(16)}}`).join("")}`, x = exports.VERCEL_STEGA_REGEX = RegExp(`[${h}]{4,}`, "gu");
60
+ function P(e) {
61
+ return {
62
+ cleaned: e.replace(x, ""),
63
+ encoded: e.match(x)?.[0] || ""
64
+ };
65
+ }
66
+ function w(e) {
67
+ return e && JSON.parse(P(JSON.stringify(e)).cleaned);
68
+ }
69
+ exports.VERCEL_STEGA_REGEX = x, exports.vercelStegaClean = w, exports.vercelStegaCombine = y;
70
+ }));
71
+ export { require_dist as t };
72
+
73
+ //# sourceMappingURL=dist-C9ExSk2R.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dist-C9ExSk2R.js","names":[],"sources":["../node_modules/.pnpm/@vercel+stega@1.1.0/node_modules/@vercel/stega/dist/index.js"],"sourcesContent":["\"use strict\";Object.defineProperty(exports, \"__esModule\", {value: true});var p={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},l={0:8203,1:8204,2:8205,3:65279},d={0:String.fromCodePoint(l[0]),1:String.fromCodePoint(l[1]),2:String.fromCodePoint(l[2]),3:String.fromCodePoint(l[3])},u=new Array(4).fill(String.fromCodePoint(l[0])).join(\"\"),g=String.fromCharCode(0);function A(e){let r=JSON.stringify(e),t=new TextEncoder().encode(r),i=\"\";for(let c=0;c<t.length;c++){let n=t[c];i+=d[n>>6&3]+d[n>>4&3]+d[n>>2&3]+d[n&3]}return u+i}function C(e){let r=JSON.stringify(e);return Array.from(r).map(t=>{let i=t.charCodeAt(0);if(i>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${r} on character ${t} (${i})`);return Array.from(i.toString(16).padStart(2,\"0\")).map(c=>String.fromCodePoint(p[c])).join(\"\")}).join(\"\")}function I(e){return!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\\d+(?:[-:\\/]\\d+){2}(?:T\\d+(?:[-:\\/]\\d+){1,2}(\\.\\d+)?Z?)?/.test(e)?!1:!!Date.parse(e)}function S(e){try{new URL(e,e.startsWith(\"/\")?\"https://acme.com\":void 0)}catch (e2){return!1}return!0}function y(e,r,t=\"auto\"){return t===!0||t===\"auto\"&&(I(e)||S(e))?e:`${e}${A(r)}`}var m=Object.fromEntries(Object.entries(d).map(e=>[e[1],+e[0]])),T=Object.fromEntries(Object.entries(p).map(e=>e.reverse())),h=`${Object.values(p).map(e=>`\\\\u{${e.toString(16)}}`).join(\"\")}`,x= exports.VERCEL_STEGA_REGEX =new RegExp(`[${h}]{4,}`,\"gu\");function X(e){let r=e.match(x);if(r)return E(r[0],!0)[0]}function M(e){let r=e.match(x);if(r)return r.map(t=>E(t)).flat()}function E(e,r=!1){let t=Array.from(e),i=1/0,c=-1;for(let n=0;n<t.length;++n)t[n]===u[0]&&t[n+1]===u[1]&&t[n+2]===u[2]&&t[n+3]===u[3]&&(i=Math.min(i,n),c=Math.max(c,n));if(c===-1)return _(t,r);for(let n=i;n<=c;++n)if(!((t.length-n)%4))try{let f=t.slice(n+4),s=new Uint8Array(f.length/4);for(let o=0;o<s.length;o++)s[o]=m[f[o*4]]<<6|m[f[o*4+1]]<<4|m[f[o*4+2]]<<2|m[f[o*4+3]];let a=new TextDecoder().decode(s);if(r){let o=a.indexOf(g);return o===-1&&(o=a.length),[JSON.parse(a.slice(0,o))]}return a.split(g).filter(Boolean).map(o=>JSON.parse(o))}catch (e3){}return[]}function _(e,r){var f;let t=[];for(let s=e.length*.5;s--;){let a=`${T[e[s*2].codePointAt(0)]}${T[e[s*2+1].codePointAt(0)]}`;t.unshift(String.fromCharCode(parseInt(a,16)))}let i=[],c=[t.join(\"\")],n=10;for(;c.length;){let s=c.shift();try{if(i.push(JSON.parse(s)),r)return i}catch(a){if(!n--)throw a;let o=+((f=a.message.match(/\\sposition\\s(\\d+)$/))==null?void 0:f[1]);if(!o)throw a;c.unshift(s.substring(0,o),s.substring(o))}}return i}function P(e){var r;return{cleaned:e.replace(x,\"\"),encoded:((r=e.match(x))==null?void 0:r[0])||\"\"}}function w(e){return e&&JSON.parse(P(JSON.stringify(e)).cleaned)}exports.VERCEL_STEGA_REGEX = x; exports.legacyStegaEncode = C; exports.vercelStegaClean = w; exports.vercelStegaCombine = y; exports.vercelStegaDecode = X; exports.vercelStegaDecodeAll = M; exports.vercelStegaEncode = A; exports.vercelStegaSplit = P;\n"],"x_google_ignoreList":[0],"mappings":";CAAa,OAAO,eAAe,SAAS,cAAc,EAAC,OAAO,GAAI,CAAC;CAAE,IAAI,IAAE;EAAC,GAAE;EAAK,GAAE;EAAK,GAAE;EAAK,GAAE;EAAK,GAAE;EAAK,GAAE;EAAK,GAAE;EAAM,GAAE;EAAK,GAAE;EAAO,GAAE;EAAO,GAAE;EAAO,GAAE;EAAO,GAAE;EAAO,GAAE;EAAO,GAAE;EAAO,GAAE;CAAM,GAAE,IAAE;EAAC,GAAE;EAAK,GAAE;EAAK,GAAE;EAAK,GAAE;CAAK,GAAE,IAAE;EAAC,GAAE,OAAO,cAAc,EAAE,EAAE;EAAE,GAAE,OAAO,cAAc,EAAE,EAAE;EAAE,GAAE,OAAO,cAAc,EAAE,EAAE;EAAE,GAAE,OAAO,cAAc,EAAE,EAAE;CAAC,GAAE,IAAE;;;;;CAAW,CAAC,CAAC,KAAK,OAAO,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE;CAA2B,SAAS,EAAE,GAAE;EAAC,IAAI,IAAE,KAAK,UAAU,CAAC,GAAE,IAAE,IAAI,YAAY,CAAC,CAAC,OAAO,CAAC,GAAE,IAAE;EAAG,KAAI,IAAI,IAAE,GAAE,IAAE,EAAE,QAAO,KAAI;GAAC,IAAI,IAAE,EAAE;GAAG,KAAG,EAAE,KAAG,IAAE,KAAG,EAAE,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AAA7F,QAAQ,qBAAqB,GAAkC,QAAQ,mBAAmB,GAAG,QAAQ,qBAAqB"}
@@ -0,0 +1,69 @@
1
+ var p = {
2
+ 0: 8203,
3
+ 1: 8204,
4
+ 2: 8205,
5
+ 3: 8290,
6
+ 4: 8291,
7
+ 5: 8288,
8
+ 6: 65279,
9
+ 7: 8289,
10
+ 8: 119155,
11
+ 9: 119156,
12
+ a: 119157,
13
+ b: 119158,
14
+ c: 119159,
15
+ d: 119160,
16
+ e: 119161,
17
+ f: 119162
18
+ }, l = {
19
+ 0: 8203,
20
+ 1: 8204,
21
+ 2: 8205,
22
+ 3: 65279
23
+ }, d = {
24
+ 0: String.fromCodePoint(l[0]),
25
+ 1: String.fromCodePoint(l[1]),
26
+ 2: String.fromCodePoint(l[2]),
27
+ 3: String.fromCodePoint(l[3])
28
+ }, u = [
29
+ ,
30
+ ,
31
+ ,
32
+ ,
33
+ ].fill(String.fromCodePoint(l[0])).join("");
34
+ function A(e) {
35
+ let r = JSON.stringify(e), t = new TextEncoder().encode(r), i = "";
36
+ for (let c = 0; c < t.length; c++) {
37
+ let n = t[c];
38
+ i += d[n >> 6 & 3] + d[n >> 4 & 3] + d[n >> 2 & 3] + d[n & 3];
39
+ }
40
+ return u + i;
41
+ }
42
+ function I(e) {
43
+ return !Number.isNaN(Number(e)) || /[a-z]/i.test(e) && !/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(e) ? !1 : !!Date.parse(e);
44
+ }
45
+ function S(e) {
46
+ try {
47
+ new URL(e, e.startsWith("/") ? "https://acme.com" : void 0);
48
+ } catch {
49
+ return !1;
50
+ }
51
+ return !0;
52
+ }
53
+ function y(e, r, t = "auto") {
54
+ return t === !0 || t === "auto" && (I(e) || S(e)) ? e : `${e}${A(r)}`;
55
+ }
56
+ Object.fromEntries(Object.entries(d).map((e) => [e[1], +e[0]])), Object.fromEntries(Object.entries(p).map((e) => e.reverse()));
57
+ var h = `${Object.values(p).map((e) => `\\u{${e.toString(16)}}`).join("")}`, x = RegExp(`[${h}]{4,}`, "gu");
58
+ function P(e) {
59
+ return {
60
+ cleaned: e.replace(x, ""),
61
+ encoded: e.match(x)?.[0] || ""
62
+ };
63
+ }
64
+ function w(e) {
65
+ return e && JSON.parse(P(JSON.stringify(e)).cleaned);
66
+ }
67
+ export { y as n, w as t };
68
+
69
+ //# sourceMappingURL=dist-Z8cIRxoB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dist-Z8cIRxoB.js","names":[],"sources":["../node_modules/.pnpm/@vercel+stega@1.1.0/node_modules/@vercel/stega/dist/index.mjs"],"sourcesContent":["var p={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},l={0:8203,1:8204,2:8205,3:65279},d={0:String.fromCodePoint(l[0]),1:String.fromCodePoint(l[1]),2:String.fromCodePoint(l[2]),3:String.fromCodePoint(l[3])},u=new Array(4).fill(String.fromCodePoint(l[0])).join(\"\"),g=String.fromCharCode(0);function A(e){let r=JSON.stringify(e),t=new TextEncoder().encode(r),i=\"\";for(let c=0;c<t.length;c++){let n=t[c];i+=d[n>>6&3]+d[n>>4&3]+d[n>>2&3]+d[n&3]}return u+i}function C(e){let r=JSON.stringify(e);return Array.from(r).map(t=>{let i=t.charCodeAt(0);if(i>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${r} on character ${t} (${i})`);return Array.from(i.toString(16).padStart(2,\"0\")).map(c=>String.fromCodePoint(p[c])).join(\"\")}).join(\"\")}function I(e){return!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\\d+(?:[-:\\/]\\d+){2}(?:T\\d+(?:[-:\\/]\\d+){1,2}(\\.\\d+)?Z?)?/.test(e)?!1:!!Date.parse(e)}function S(e){try{new URL(e,e.startsWith(\"/\")?\"https://acme.com\":void 0)}catch{return!1}return!0}function y(e,r,t=\"auto\"){return t===!0||t===\"auto\"&&(I(e)||S(e))?e:`${e}${A(r)}`}var m=Object.fromEntries(Object.entries(d).map(e=>[e[1],+e[0]])),T=Object.fromEntries(Object.entries(p).map(e=>e.reverse())),h=`${Object.values(p).map(e=>`\\\\u{${e.toString(16)}}`).join(\"\")}`,x=new RegExp(`[${h}]{4,}`,\"gu\");function X(e){let r=e.match(x);if(r)return E(r[0],!0)[0]}function M(e){let r=e.match(x);if(r)return r.map(t=>E(t)).flat()}function E(e,r=!1){let t=Array.from(e),i=1/0,c=-1;for(let n=0;n<t.length;++n)t[n]===u[0]&&t[n+1]===u[1]&&t[n+2]===u[2]&&t[n+3]===u[3]&&(i=Math.min(i,n),c=Math.max(c,n));if(c===-1)return _(t,r);for(let n=i;n<=c;++n)if(!((t.length-n)%4))try{let f=t.slice(n+4),s=new Uint8Array(f.length/4);for(let o=0;o<s.length;o++)s[o]=m[f[o*4]]<<6|m[f[o*4+1]]<<4|m[f[o*4+2]]<<2|m[f[o*4+3]];let a=new TextDecoder().decode(s);if(r){let o=a.indexOf(g);return o===-1&&(o=a.length),[JSON.parse(a.slice(0,o))]}return a.split(g).filter(Boolean).map(o=>JSON.parse(o))}catch{}return[]}function _(e,r){var f;let t=[];for(let s=e.length*.5;s--;){let a=`${T[e[s*2].codePointAt(0)]}${T[e[s*2+1].codePointAt(0)]}`;t.unshift(String.fromCharCode(parseInt(a,16)))}let i=[],c=[t.join(\"\")],n=10;for(;c.length;){let s=c.shift();try{if(i.push(JSON.parse(s)),r)return i}catch(a){if(!n--)throw a;let o=+((f=a.message.match(/\\sposition\\s(\\d+)$/))==null?void 0:f[1]);if(!o)throw a;c.unshift(s.substring(0,o),s.substring(o))}}return i}function P(e){var r;return{cleaned:e.replace(x,\"\"),encoded:((r=e.match(x))==null?void 0:r[0])||\"\"}}function w(e){return e&&JSON.parse(P(JSON.stringify(e)).cleaned)}export{x as VERCEL_STEGA_REGEX,C as legacyStegaEncode,w as vercelStegaClean,y as vercelStegaCombine,X as vercelStegaDec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