@sanity/sdk 3.17.0 → 3.18.0-next.20261127101824

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.
@@ -1,8 +1,8 @@
1
1
  import { m as SanityConfig, s as DocumentResource, t as SanityInstance } from "../createSanityInstance-CBPUL_HD.js";
2
2
  import { n as StateSource, r as BoundStoreAction } from "../createStateSourceAction-Obi1MuDH.js";
3
- import { Ai as createLogger, Ba as CacheTag, Br as ApplicationStatus, Fr as resolveTopic, Ga as FetcherSnapshot, Ha as CursorPage, Hi as parseCommentsOptionsKey, Ja as PagedFetcher, Ka as MutationDefinition, Pr as getTopicState, Qa as definePagedFetcher, Ua as Fetcher, Va as CacheWriter, Vi as getCommentsOptionsKey, Vr as ApplicationStatusUpdate, Wa as FetcherDefinition, Xa as defineFetcher, Y as parseQueryKey, Ya as PagedFetcherDefinition, Za as defineMutation, da as ProjectAccessErrorDetails, fa as getProjectAccessErrorDetails, hn as SetFavoriteInput, kt as GetUsersOptions, lt as PreviewQueryResult, ma as getSignInMethodLabel, mn as FavoriteStatusResponse, pn as FavoriteDocumentContext, q as getQueryKey, qa as MutationResult, r as ApplicationBase, ut as PreviewValue } from "../applications-D2hQr1jp.js";
3
+ import { Ai as createLogger, Ba as CacheTag, Br as ApplicationStatus, Fr as resolveTopic, Ga as FetcherSnapshot, Ha as CursorPage, Hi as parseCommentsOptionsKey, Ja as PagedFetcher, Ka as MutationDefinition, Pr as getTopicState, Qa as definePagedFetcher, Ua as Fetcher, Va as CacheWriter, Vi as getCommentsOptionsKey, Vr as ApplicationStatusUpdate, Wa as FetcherDefinition, Xa as defineFetcher, Y as parseQueryKey, Ya as PagedFetcherDefinition, Za as defineMutation, da as ProjectAccessErrorDetails, fa as getProjectAccessErrorDetails, hn as SetFavoriteInput, kt as GetUsersOptions, lt as PreviewQueryResult, ma as getSignInMethodLabel, mn as FavoriteStatusResponse, pn as FavoriteDocumentContext, q as getQueryKey, qa as MutationResult, r as ApplicationBase, ut as PreviewValue } from "../applications-D8Y0DXJr.js";
4
4
  import { c as parseCommentsQueryOptionsKey, l as parseDocumentCommentsOptionsKey, o as getCommentsQueryOptionsKey, s as getDocumentCommentsOptionsKey } from "../commentsOptions-DM0GW1Eq.js";
5
- import { b as resetMessageBus, n as InstallMessageBusOptions, o as MessageBusConnection, s as MessageBusEmitOptions, x as workerMessages, y as installMessageBus } from "../bus-E7n57Ek8.js";
5
+ import { T as toDashboardApplications, b as resetMessageBus, n as InstallMessageBusOptions, o as MessageBusConnection, s as MessageBusEmitOptions, x as workerMessages, y as installMessageBus } from "../bus-kOUKH5RD.js";
6
6
  import { Auth, ClientError, SanityClient } from "@sanity/client";
7
7
  import { Observable } from "rxjs";
8
8
  import { CurrentUser } from "@sanity/types";
@@ -293,5 +293,5 @@ export declare function pickProperties<T extends object, K extends keyof T>(valu
293
293
  * @internal
294
294
  */
295
295
  export declare function isDeepEqual<T>(left: T, right: T): boolean;
296
- export { type ApiErrorBody, type ApplicationStatus, type ApplicationStatusUpdate, type CacheTag, type CacheWriter, type CursorPage, type Fetcher, type FetcherDefinition, type FetcherSnapshot, type InstallMessageBusOptions, type MutationDefinition, type MutationResult, type PagedFetcher, type PagedFetcherDefinition, type ProjectAccessErrorDetails, type WorkerConnection, createLogger, defineFetcher, defineMutation, definePagedFetcher, getCommentsOptionsKey, getCommentsQueryOptionsKey, getDocumentCommentsOptionsKey, getProjectAccessErrorDetails, getQueryKey, getSignInMethodLabel, getTopicState, installMessageBus, parseCommentsOptionsKey, parseCommentsQueryOptionsKey, parseDocumentCommentsOptionsKey, parseQueryKey, resetMessageBus, resolveTopic, workerMessages };
296
+ export { type ApiErrorBody, type ApplicationStatus, type ApplicationStatusUpdate, type CacheTag, type CacheWriter, type CursorPage, type Fetcher, type FetcherDefinition, type FetcherSnapshot, type InstallMessageBusOptions, type MutationDefinition, type MutationResult, type PagedFetcher, type PagedFetcherDefinition, type ProjectAccessErrorDetails, type WorkerConnection, createLogger, defineFetcher, defineMutation, definePagedFetcher, getCommentsOptionsKey, getCommentsQueryOptionsKey, getDocumentCommentsOptionsKey, getProjectAccessErrorDetails, getQueryKey, getSignInMethodLabel, getTopicState, installMessageBus, parseCommentsOptionsKey, parseCommentsQueryOptionsKey, parseDocumentCommentsOptionsKey, parseQueryKey, resetMessageBus, resolveTopic, toDashboardApplications, workerMessages };
297
297
  //# sourceMappingURL=_internal.d.ts.map
@@ -4,8 +4,8 @@ import { C as isNetworkFailure, I as getClientErrorApiBody, T as DocumentInacces
4
4
  import { a as getDashboardMessageBus, c as MessageBusError, d as resetMessageBus, f as workerMessages, h as randomUuid, i as resolveTopic, m as randomId, o as isDashboardEnvironment, r as getTopicState, s as requireDashboardMessageBus, t as TopicError, u as installMessageBus } from "../topicStore-CKBdgAz7.js";
5
5
  import { i as pickProperties, n as isObject, t as isDeepEqual } from "../object-CxXlSVg7.js";
6
6
  import { n as getClient } from "../clientStore-eysItBQl.js";
7
- import { i as definePagedFetcher, n as defineFetcher, r as defineMutation, t as toCommentFieldPath } from "../types-C8dSHL5E.js";
8
- import { B as ActionError, C as favoriteScope, E as toFavoriteDocument, G as getProjectAccessErrorDetails, a as parseQueryKey, f as getUsersKey, m as parseUsersKey, n as version, q as getSignInMethodLabel, r as getQueryKey, t as CORE_SDK_VERSION, x as PreferenceError } from "../version-C4jlyyUU.js";
7
+ import { i as definePagedFetcher, n as defineFetcher, r as defineMutation, t as toCommentFieldPath } from "../commentFieldPath-DuhAgFcL.js";
8
+ import { B as ActionError, C as favoriteScope, E as toFavoriteDocument, G as getProjectAccessErrorDetails, a as parseQueryKey, f as getUsersKey, m as parseUsersKey, n as version, q as getSignInMethodLabel, r as getQueryKey, t as CORE_SDK_VERSION, x as PreferenceError } from "../version-Cifb80zd.js";
9
9
  import { ClientError, ConnectionFailedError, ServerError, isTimeoutError } from "@sanity/client";
10
10
  import { EMPTY, catchError, defer, distinctUntilChanged, map, merge } from "rxjs";
11
11
  import "@sanity/types";
@@ -111,6 +111,111 @@ function getCommentsQueryOptionsKey(options) {
111
111
  function parseCommentsQueryOptionsKey(key) {
112
112
  return JSON.parse(key);
113
113
  }
114
+ const loadableInterfaces = ({ activeDeployment, config }, isLocal) => isLocal || config?.mfManifest !== void 0 ? activeDeployment?.interfaces ?? [] : [], loadModules = (base, interfaces) => {
115
+ let entry = interfaces.length === 0 ? null : getApplicationOrigin(base);
116
+ if (entry === null) return {
117
+ views: [],
118
+ webWorkers: []
119
+ };
120
+ let views = [], webWorkers = [];
121
+ for (let extension of interfaces) {
122
+ let module = {
123
+ entry,
124
+ moduleId: `${base.id}/${extension.moduleId}`,
125
+ version: extension.version
126
+ };
127
+ switch (extension.type) {
128
+ case "worker":
129
+ webWorkers.push({
130
+ ...extension,
131
+ module
132
+ });
133
+ break;
134
+ case "app": {
135
+ let { type: _type, ...view } = extension;
136
+ views.push({
137
+ ...view,
138
+ surface: "window",
139
+ module
140
+ });
141
+ break;
142
+ }
143
+ case "panel": {
144
+ let { type, ...view } = extension;
145
+ views.push({
146
+ ...view,
147
+ surface: type,
148
+ module
149
+ });
150
+ break;
151
+ }
152
+ case "tile": {
153
+ let { type, ...view } = extension;
154
+ views.push({
155
+ ...view,
156
+ surface: type,
157
+ module
158
+ });
159
+ break;
160
+ }
161
+ case "asset_source": {
162
+ let { type, ...view } = extension;
163
+ views.push({
164
+ ...view,
165
+ surface: type,
166
+ module
167
+ });
168
+ break;
169
+ }
170
+ }
171
+ }
172
+ return {
173
+ views,
174
+ webWorkers
175
+ };
176
+ }, toApplication = (application) => {
177
+ let { activeDeployment: _activeDeployment, config: _config, ...applicationBase } = application, isLocal = "local" in application;
178
+ return {
179
+ ...application,
180
+ isLocal,
181
+ ...loadModules({
182
+ ...applicationBase,
183
+ isLocal
184
+ }, loadableInterfaces(application, isLocal))
185
+ };
186
+ }, toInstallation = (installation) => {
187
+ let { application } = installation, base = {
188
+ id: installation.id,
189
+ type: "installation",
190
+ isLocal: !1,
191
+ title: application.title,
192
+ name: application.name,
193
+ reference: application.reference,
194
+ icon: application.icon,
195
+ isSingleton: !0,
196
+ visibility: "default",
197
+ slug: application.slug,
198
+ externalUrl: null,
199
+ organizationId: application.organizationId,
200
+ createdAt: installation.createdAt,
201
+ updatedAt: installation.updatedAt
202
+ };
203
+ return {
204
+ ...base,
205
+ type: "installation",
206
+ installation,
207
+ ...loadModules(base, installation.interfaces ?? [])
208
+ };
209
+ };
210
+ /**
211
+ * Shapes the dashboard's published applications and installations into {@link DashboardApplication}s,
212
+ * the entries `useApplications` returns.
213
+ * @beta
214
+ * @category Dashboard
215
+ */
216
+ function toDashboardApplications(entries) {
217
+ return entries.map((entry) => "type" in entry ? toApplication(entry) : toInstallation(entry));
218
+ }
114
219
  /**
115
220
  * Returns the instance's client for one of its application's workers, creating it on first call.
116
221
  *
@@ -982,6 +1087,6 @@ function createGroqSearchFilter(query) {
982
1087
  let tokens = trimmedQuery.match(TOKEN_REGEX) ?? [], reversedIndex = [...tokens].reverse().findIndex((token) => !isNegationToken(token) && !isExactMatchToken(token)), finalIncrementalTokenIndex = reversedIndex === -1 ? -1 : tokens.length - 1 - reversedIndex, finalIncrementalToken = tokens[finalIncrementalTokenIndex], processedTokens = [...tokens];
983
1088
  return finalIncrementalToken !== void 0 && !isPrefixToken(finalIncrementalToken) && processedTokens.splice(finalIncrementalTokenIndex, 1, `${finalIncrementalToken}*`), `[@] match text::query("${processedTokens.join(" ").replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}")`;
984
1089
  }
985
- export { PREVIEW_PROJECTION, createGroqSearchFilter, createLogger, defineFetcher, defineMutation, definePagedFetcher, getApplicationOrigin, getBusFavoriteState, getClientErrorApiBody, getCommentsOptionsKey, getCommentsQueryOptionsKey, getDashboardMessageBus, getDocumentCommentsOptionsKey, getProjectAccessErrorDetails, getQueryKey, getSignInMethodLabel, getTelemetryManager, getTopicState, getUsersKey, getWorkerClient, initTelemetry, installMessageBus, isDashboardEnvironment, isDeepEqual, isMessageBusEnvironment, isStudioConfig, markSdkError, parseCommentsOptionsKey, parseCommentsQueryOptionsKey, parseDocumentCommentsOptionsKey, parseQueryKey, parseUsersKey, pickProperties, randomId, randomUuid, reportError, requireDashboardMessageBus, resetMessageBus, resolveBusFavorite, resolveTopic, setBusFavorite, trackHookMounted, transformProjectionToPreview, workerMessages };
1090
+ export { PREVIEW_PROJECTION, createGroqSearchFilter, createLogger, defineFetcher, defineMutation, definePagedFetcher, getApplicationOrigin, getBusFavoriteState, getClientErrorApiBody, getCommentsOptionsKey, getCommentsQueryOptionsKey, getDashboardMessageBus, getDocumentCommentsOptionsKey, getProjectAccessErrorDetails, getQueryKey, getSignInMethodLabel, getTelemetryManager, getTopicState, getUsersKey, getWorkerClient, initTelemetry, installMessageBus, isDashboardEnvironment, isDeepEqual, isMessageBusEnvironment, isStudioConfig, markSdkError, parseCommentsOptionsKey, parseCommentsQueryOptionsKey, parseDocumentCommentsOptionsKey, parseQueryKey, parseUsersKey, pickProperties, randomId, randomUuid, reportError, requireDashboardMessageBus, resetMessageBus, resolveBusFavorite, resolveTopic, setBusFavorite, toDashboardApplications, trackHookMounted, transformProjectionToPreview, workerMessages };
986
1091
 
987
1092
  //# sourceMappingURL=_internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_internal.js","names":["MAX_CAUSE_DEPTH","\"NODE_ENV\""],"sources":["../../src/comments/legacy/commentsOptions.ts","../../src/applications/applicationOrigin.ts","../../src/comments/commentsOptions.ts","../../src/dashboard/messageBus/workerStore.ts","../../src/errorReporting/isErrorReportingEnabled.ts","../../src/errorReporting/isKnownSdkError.ts","../../src/errorReporting/privacy.ts","../../src/errorReporting/sdkErrorOrigin.ts","../../src/errorReporting/errorReporter.ts","../../src/favorites/busFavorites.ts","../../src/preview/previewConstants.ts","../../src/preview/previewProjectionUtils.ts","../../src/telemetry/environment.ts","../../src/telemetry/events.ts","../../src/telemetry/telemetryManager.ts","../../src/telemetry/initTelemetry.ts","../../src/utils/createGroqSearchFilter.ts"],"sourcesContent":["// fallow-ignore-file code-duplication -- deprecated add-on dataset comments, kept alongside comments/ until removal in the next major\nimport {type Path} from '@sanity/types'\n\nimport {type DocumentHandle} from '../../config/sanityConfig'\nimport {toCommentFieldPath} from '../commentFieldPath'\nimport {type CommentStatus} from './types'\n\n/**\n * Which comments to read.\n * @beta\n * @deprecated Comments have moved to the organization collaboration API. Import from\n * `@sanity/sdk/collaboration`; this add-on dataset API is removed in the next major.\n */\nexport interface CommentsOptions extends DocumentHandle {\n /**\n * Narrow to one field. Omit to get every comment on the document.\n */\n fieldPath?: string | Path\n /** Narrow to open or resolved threads. Omit for both. */\n status?: CommentStatus\n}\n\n/**\n * @beta\n * @deprecated Comments have moved to the organization collaboration API. Import from\n * `@sanity/sdk/collaboration`; this add-on dataset API is removed in the next major.\n */\nexport interface ResolveCommentsOptions extends CommentsOptions {\n signal?: AbortSignal\n}\n\n/**\n * Fields on {@link CommentsOptions} that are deliberately left out of the key\n * below, because neither changes which comments an option set addresses.\n *\n * `source` is the deprecated alias for `resource` and is folded into it before\n * a key is ever built, so keying on both would give one list two keys.\n * `liveEdit` describes the document rather than its comments, which hang off\n * the published id whether or not drafts exist.\n */\ntype CommentsKeyIrrelevantField = 'source' | 'liveEdit'\n\n/**\n * A stable string standing for one set of read options.\n *\n * Only React needs this: it holds one state source steady across renders and\n * defers swapping to a new one while the previous list is still on screen.\n * `fieldPath` is normalised on the way in, so a path array and the equivalent\n * string address the same list.\n *\n * Kept apart from the store it keys, because React imports this to memoize and\n * pulling the store in with it would put both comment stores into every bundle\n * that reads a comment.\n *\n * @internal\n */\nexport function getCommentsOptionsKey(options: CommentsOptions): string {\n return JSON.stringify({\n documentId: options.documentId,\n documentType: options.documentType,\n projectId: options.projectId,\n dataset: options.dataset,\n resource: options.resource,\n perspective: options.perspective,\n fieldPath: options.fieldPath === undefined ? undefined : toCommentFieldPath(options.fieldPath),\n status: options.status,\n // The `Record` half makes a new field on `CommentsOptions` a compile\n // error here unless it is listed above or named as irrelevant. Left to\n // `satisfies CommentsOptions` alone, a forgotten field would just be\n // absent from the key, and a reader would keep the list it had while the\n // caller thought it had asked for a different one.\n } satisfies CommentsOptions &\n Record<Exclude<keyof CommentsOptions, CommentsKeyIrrelevantField>, unknown>)\n}\n\n/** @internal */\nexport function parseCommentsOptionsKey(key: string): CommentsOptions {\n return JSON.parse(key) as CommentsOptions\n}\n","import {type ApplicationBase} from './applications'\n\ntype SanityGlobal = typeof globalThis & {__SANITY_STAGING__?: boolean}\n\n/**\n * The origin an application is served from, or `null` when it has neither an external URL nor\n * a slug to derive one from. Callers treat `null` as \"nothing to load\" rather than failing the\n * whole list on one bad record.\n *\n * @internal\n */\nexport function getApplicationOrigin(\n application: Pick<\n ApplicationBase,\n 'externalUrl' | 'slug' | 'isSingleton' | 'organizationId' | 'isLegacy'\n > & {type?: string},\n): string | null {\n if (application.externalUrl !== null) return new URL(application.externalUrl).origin\n if (application.slug === null) return null\n\n // Read at runtime, not via a bundler define: a remote is built once and runs in whichever\n // host page loaded it, and the host sets this flag. Mirrors workbench's `getSanityEnv`.\n const staging = (globalThis as SanityGlobal).__SANITY_STAGING__ === true\n // Custom (non-legacy) core apps share the singleton host. A record without `isLegacy` comes from\n // a host that predates that address, so it keeps the slug address.\n const isSanityHostedCustomApp = application.type === 'coreApp' && application.isLegacy === false\n if (application.isSingleton || isSanityHostedCustomApp) {\n const domain = staging ? 'run.sanity.work' : 'sanity.run'\n return `https://${application.slug}--apps--${application.organizationId}.${domain}`\n }\n\n const domain = staging ? 'studio.sanity.work' : 'sanity.studio'\n return `https://${application.slug}.${domain}`\n}\n","import {type QueryParams} from '@sanity/client'\nimport {type Path} from '@sanity/types'\n\nimport {type DatasetHandle, type DocumentHandle} from '../config/sanityConfig'\nimport {toCommentFieldPath} from './commentFieldPath'\nimport {type CommentStatus} from './types'\n\n/**\n * Which of a document's comments a read covers.\n *\n * @beta\n */\nexport type CommentsReadScope = 'perspective' | 'exact' | 'all'\n\n/**\n * Which of a document's comments to read.\n * @beta\n */\nexport interface CommentsOptions extends DocumentHandle {\n /** Narrow to one field. Omit to get every comment on the document. */\n fieldPath?: string | Path\n /** Narrow to open or resolved threads. Omit for both. */\n status?: CommentStatus\n /**\n * Which of the document's comments to read.\n *\n * - `'perspective'` follows what you are viewing: a release shows that\n * release's comments, anything else pools draft and published.\n * - `'exact'` matches only the precise document id passed.\n * - `'all'` returns every comment on the document.\n *\n * `'perspective'` recognises a release from the `{releaseName}` form. A\n * stacked `ClientPerspective` array names several layers at once, with no\n * single release to read comments from, so it pools draft and published as\n * any other non-release perspective does. To read the pooled list while a\n * release is in view, pass a non-release `perspective` alongside; to name a\n * release yourself, pass a version id as the `documentId`.\n *\n * A content variant is stored as a version document, so under\n * `'perspective'` its comments form a list of their own, the way a release's\n * do. A variant's draft and published comments are separate lists: pairing\n * them needs the variant's name, which its document id does not carry.\n *\n * @defaultValue 'perspective'\n */\n scope?: CommentsReadScope\n}\n\n/** @beta */\nexport interface ResolveCommentsOptions extends CommentsOptions {\n signal?: AbortSignal\n}\n\n/**\n * An arbitrary comment query, for anything that is not \"comments on this\n * document\" — cross-document views, per-user views, organization-wide activity.\n *\n * @beta\n */\nexport interface CommentsQueryOptions extends DatasetHandle {\n /**\n * GROQ filter applied to comment documents. `_type == \"sanity.comment\"` is\n * added for you, so this only has to say which comments.\n *\n * It is evaluated against every comment the organization can read. The\n * resource picks the organization but does not narrow the results; add a\n * `target.document._ref` prefix condition to keep to one dataset.\n */\n filter: string\n params?: QueryParams\n}\n\n/** @beta */\nexport interface ResolveCommentsQueryOptions extends CommentsQueryOptions {\n signal?: AbortSignal\n}\n\n/**\n * Fields on the read option types that are deliberately left out of the keys\n * below, because none of them changes which comments an option set addresses.\n *\n * `source` is the deprecated alias for `resource` and is folded into it before\n * a key is ever built, so keying on both would give one list two keys.\n * `liveEdit` describes the document rather than its comments, which hang off\n * the published id whether or not drafts exist.\n */\ntype CommentsKeyIrrelevantField = 'source' | 'liveEdit'\n\n/**\n * A stable string standing for one set of document read options.\n *\n * Only React needs this: it holds one state source steady across renders and\n * defers swapping to a new one while the previous list is still on screen.\n * `fieldPath` is normalised on the way in, so a path array and the equivalent\n * string address the same list.\n *\n * Kept apart from the store it keys, because React imports this to memoize and\n * pulling the store in with it would put both comment stores into every bundle\n * that reads a comment.\n *\n * @internal\n */\nexport function getDocumentCommentsOptionsKey(options: CommentsOptions): string {\n return JSON.stringify({\n documentId: options.documentId,\n documentType: options.documentType,\n projectId: options.projectId,\n dataset: options.dataset,\n resource: options.resource,\n perspective: options.perspective,\n fieldPath: options.fieldPath === undefined ? undefined : toCommentFieldPath(options.fieldPath),\n status: options.status,\n scope: options.scope,\n // The `Record` half makes a new field on `CommentsOptions` a compile\n // error here unless it is listed above or named as irrelevant. Left to\n // `satisfies CommentsOptions` alone, a forgotten field would just be\n // absent from the key, and a reader would keep the list it had while the\n // caller thought it had asked for a different one.\n } satisfies CommentsOptions &\n Record<Exclude<keyof CommentsOptions, CommentsKeyIrrelevantField>, unknown>)\n}\n\n/** @internal */\nexport function parseDocumentCommentsOptionsKey(key: string): CommentsOptions {\n return JSON.parse(key) as CommentsOptions\n}\n\n/**\n * The same, for the GROQ escape hatch.\n *\n * @internal\n */\nexport function getCommentsQueryOptionsKey(options: CommentsQueryOptions): string {\n return JSON.stringify({\n filter: options.filter,\n params: options.params,\n projectId: options.projectId,\n dataset: options.dataset,\n resource: options.resource,\n perspective: options.perspective,\n } satisfies CommentsQueryOptions &\n Record<Exclude<keyof CommentsQueryOptions, CommentsKeyIrrelevantField>, unknown>)\n}\n\n/** @internal */\nexport function parseCommentsQueryOptionsKey(key: string): CommentsQueryOptions {\n return JSON.parse(key) as CommentsQueryOptions\n}\n","import {createActionBinder} from '../../store/createActionBinder'\nimport {defineStore} from '../../store/defineStore'\nimport {type MessageBusEmitOptions, workerMessages} from './bus'\nimport {requireDashboardMessageBus} from './store'\n\n/**\n * A view's client for one of its own application's workers, before `useWorker` types it.\n * @internal\n */\nexport interface WorkerConnection {\n post(payload?: unknown, options?: MessageBusEmitOptions): Promise<unknown>\n subscribe(handler: (message: unknown) => void): () => void\n}\n\ninterface DashboardWorkersState {\n workers: {[name: string]: WorkerConnection}\n}\n\nconst bindActionByInstance = createActionBinder<{name: string}, [name: string]>((instance) => ({\n name: instance.instanceId,\n}))\n\nconst dashboardWorkersStore = defineStore<DashboardWorkersState>({\n name: 'dashboardWorkers',\n getInitialState: () => ({workers: {}}),\n})\n\n/**\n * Returns the instance's client for one of its application's workers, creating it on first call.\n *\n * @remarks\n * The client lives with the instance rather than a component, so a render that suspended before\n * committing gets the same client when it renders again, and callers can key caches on it.\n * @internal\n */\nexport const getWorkerClient = bindActionByInstance(\n dashboardWorkersStore,\n ({instance, state}, name: string): WorkerConnection => {\n const current = state.get().workers[name]\n if (current) return current\n const messageBus = requireDashboardMessageBus(instance, `use worker \"${name}\"`)\n const client: WorkerConnection = {\n post: (payload, options) =>\n // Inside the executor, so a closed bus rejects instead of throwing.\n new Promise((resolve) =>\n resolve(messageBus.emit('workers.post', {name, payload}, options)),\n ),\n subscribe: (handler) => {\n const subscription = workerMessages(messageBus, name).subscribe(handler)\n return () => subscription.unsubscribe()\n },\n }\n state.set('addWorker', ({workers}) => ({workers: {...workers, [name]: client}}))\n return client\n },\n)\n","/**\n * localStorage key that forces error reporting on, for debugging the reporter itself.\n */\nconst DEBUG_KEY = 'SANITY_DEBUG_ERROR_REPORTING'\n\n/**\n * Hostnames of a dev server on this machine or the local network, where most errors come from\n * work in progress: loopback and unspecified addresses, private IPv4 ranges, private and\n * link-local IPv6, and `.localhost` and `.local` names.\n */\nconst LOCAL_HOSTNAME_PATTERN =\n /^(?:localhost|.+\\.localhost|.+\\.local|0\\.0\\.0\\.0|127(?:\\.\\d{1,3}){3}|10(?:\\.\\d{1,3}){3}|192\\.168(?:\\.\\d{1,3}){2}|172\\.(?:1[6-9]|2\\d|3[01])(?:\\.\\d{1,3}){2}|169\\.254(?:\\.\\d{1,3}){2}|\\[(?:::1?|f[cd][0-9a-f]{0,2}:[^\\]]*|fe80:[^\\]]*)\\])$/i\n\n/** DOM implementations that run in Node for tests, such as an app's own Vitest or Jest suite. */\nconst TEST_DOM_USER_AGENT_PATTERN = /jsdom|happydom/i\n\n/**\n * Whether the document has an import map with an `@sanity/sdk` entry. The Sanity CLI adds one\n * when an app is deployed with `autoUpdates`, so its presence means Sanity serves the SDK bundle.\n */\nfunction hasSdkPackageInImportMap(): boolean {\n if (typeof document === 'undefined' || !('querySelectorAll' in document)) return false\n\n return Array.from(document.querySelectorAll('script[type=\"importmap\"]')).some((entry) => {\n if (!entry.textContent) return false\n try {\n const imports = JSON.parse(entry.textContent).imports\n return Boolean(imports) && '@sanity/sdk' in imports\n } catch {\n return false\n }\n })\n}\n\n/**\n * How the page loaded the SDK: from the module server for an auto-updating app, or bundled\n * into the app's own build.\n *\n * @internal\n */\nexport function getSdkDelivery(): 'auto-updates' | 'bundled' {\n return hasSdkPackageInImportMap() ? 'auto-updates' : 'bundled'\n}\n\n/**\n * Whether the debug flag is set in localStorage. It also lets the origin filter accept this\n * repo's own source paths, which only appear in local development.\n *\n * @internal\n */\nexport function hasDebugFlag(): boolean {\n try {\n return typeof localStorage !== 'undefined' && Boolean(localStorage.getItem(DEBUG_KEY))\n } catch {\n return false\n }\n}\n\n/**\n * Whether the page runs on a local or development host. An empty hostname counts too: it is what\n * `file://` pages, Electron, and environments that shim `window` without a URL report.\n *\n * @internal\n */\nexport function isLocalDevelopment(): boolean {\n if (typeof window === 'undefined') return false\n const hostname = window.location?.hostname ?? ''\n return hostname === '' || LOCAL_HOSTNAME_PATTERN.test(hostname)\n}\n\n/** A DOM implementation that runs in Node for tests, or a browser driven by test automation. */\nfunction isTestEnvironment(): boolean {\n if (typeof navigator === 'undefined') return false\n return navigator.webdriver === true || TEST_DOM_USER_AGENT_PATTERN.test(navigator.userAgent ?? '')\n}\n\n/**\n * Error reporting runs in browsers, except on a local or development host and in test\n * environments: DOM implementations that run in Node and browsers driven by test automation. The\n * debug flag turns it on anywhere in a browser. It never runs outside a browser.\n *\n * @internal\n */\nexport function isErrorReportingEnabled(): boolean {\n if (typeof window === 'undefined') return false\n if (hasDebugFlag()) return true\n return !isLocalDevelopment() && !isTestEnvironment()\n}\n","import {ClientError, ConnectionFailedError, isTimeoutError, ServerError} from '@sanity/client'\n\nimport {MessageBusError} from '../dashboard/messageBus/bus'\nimport {TopicError} from '../dashboard/messageBus/topicStore'\nimport {DocumentInaccessibleError} from '../document/documentInaccessibleError'\nimport {ActionError} from '../document/processActions/shared'\nimport {PreferenceError} from '../preferences/preferenceError'\nimport {isNetworkFailure} from './isNetworkFailure'\n\nconst MAX_CAUSE_DEPTH = 5\n\n/**\n * Aborting a request on teardown is routine. Matched by name because `DOMException` and abort\n * errors from other libraries do not share a class.\n */\nfunction isAbortError(error: unknown): boolean {\n return error instanceof Error && error.name === 'AbortError'\n}\n\n/** Known errors that cannot be matched by class. */\nconst KNOWN_ERROR_CHECKS: ((error: unknown) => boolean)[] = [\n isTimeoutError,\n isAbortError,\n isNetworkFailure,\n]\n\nfunction isKnownErrorInstance(error: unknown): boolean {\n // Built per call so the classes are read after every module has finished loading\n const knownClasses = [\n ActionError,\n DocumentInaccessibleError,\n MessageBusError,\n PreferenceError,\n TopicError,\n // 4xx and 5xx responses from the Sanity API reflect the app's permissions, queries, or API\n // availability, not a defect in the SDK\n ClientError,\n ServerError,\n // The user is offline\n ConnectionFailedError,\n ]\n return (\n knownClasses.some((knownClass) => error instanceof knownClass) ||\n KNOWN_ERROR_CHECKS.some((check) => check(error))\n )\n}\n\n/**\n * Whether an error is an expected state caused by the app's configuration, the user's\n * permissions, the user's network, or the Sanity API, and so is not worth reporting as an SDK\n * bug. Wrapped errors are checked through their `cause` chain.\n *\n * @internal\n */\nexport function isKnownSdkError(error: unknown): boolean {\n let current = error\n for (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n if (isKnownErrorInstance(current)) return true\n if (!(current instanceof Error) || current.cause === undefined) return false\n current = current.cause\n }\n return false\n}\n","import {type BrowserOptions, type ErrorEvent} from './sentryTypes'\n\n/**\n * Key fragments Sentry denies when `sendDefaultPii` is left unset. The Sentry v11 migration guide\n * uses the same list for headers and query params.\n */\nconst PII_KEY_DENYLIST = ['forwarded', '-ip', 'remote-', 'via', '-user']\n\n/**\n * Turns off every automatic data category that can carry user or customer data. Matches the\n * posture Sanity Studio uses for its own Sentry client.\n *\n * `userInfo: false` also stops Relay from inferring the client IP.\n */\nexport const sdkSentryDataCollection = {\n userInfo: false,\n cookies: false,\n httpHeaders: {\n request: {deny: PII_KEY_DENYLIST},\n response: {deny: PII_KEY_DENYLIST},\n },\n httpBodies: [],\n urlQueryParams: {deny: PII_KEY_DENYLIST},\n genAI: {inputs: false, outputs: false},\n databaseQueryData: false,\n graphQL: {document: false, variables: false},\n queues: false,\n} satisfies NonNullable<BrowserOptions['dataCollection']>\n\nconst KEPT_TAGS = ['handled', 'delivery', 'errorBoundary']\n\n/**\n * Sentry `beforeSend` hook that rebuilds the event from an allowlist of fields. Sentry merges\n * the global and isolation scopes into every event, and when the host page runs the same Sentry\n * version those scopes are the host's: its tags, extras, breadcrumbs, and contexts would be\n * sent along with the SDK's error. Anything not listed here is dropped, and the zeroed IP stops\n * Sentry from filling one in from the connection. Exception messages and stack frames are kept\n * as they are.\n */\nexport function beforeSend(event: ErrorEvent): ErrorEvent {\n const tags: NonNullable<ErrorEvent['tags']> = {}\n for (const key of KEPT_TAGS) {\n const value = event.tags?.[key]\n if (value !== undefined) tags[key] = value\n }\n\n return {\n type: undefined,\n event_id: event.event_id,\n timestamp: event.timestamp,\n platform: event.platform,\n level: event.level,\n release: event.release,\n environment: event.environment,\n message: event.message,\n exception: event.exception,\n sdk: event.sdk,\n tags,\n user: {ip_address: '0.0.0.0'},\n }\n}\n","/**\n * Marks errors that leave SDK code, so the reporter can tell them apart from app errors when\n * the SDK is bundled into the app and stack frame URLs no longer name the SDK. `Symbol.for`\n * keeps the mark readable across two copies of the SDK on one page.\n */\nconst SDK_ORIGIN = Symbol.for('@sanity/sdk/errorOrigin')\n\n/**\n * Marks an error as thrown by SDK code. Errors already marked, and values that are not\n * `Error` instances, are left alone.\n *\n * @internal\n */\nexport function markSdkError(error: unknown): void {\n if (!(error instanceof Error) || Object.hasOwn(error, SDK_ORIGIN)) return\n try {\n Object.defineProperty(error, SDK_ORIGIN, {value: true})\n } catch {\n // A frozen error stays unmarked\n }\n}\n\n/**\n * Whether an error was marked by {@link markSdkError}.\n *\n * @internal\n */\nexport function isSdkError(error: unknown): boolean {\n return error instanceof Error && Object.hasOwn(error, SDK_ORIGIN)\n}\n\nconst MAX_CAUSE_DEPTH = 5\n\n/**\n * The first error marked by {@link markSdkError} in an error and its `cause` chain. An app that\n * catches an SDK error and throws its own error with the SDK error as `cause` still has an SDK\n * bug at the root.\n *\n * @internal\n */\nexport function findSdkErrorInChain(error: unknown): Error | undefined {\n let current = error\n try {\n for (let depth = 0; depth < MAX_CAUSE_DEPTH && current instanceof Error; depth++) {\n if (isSdkError(current)) return current\n current = current.cause\n }\n } catch {\n // A throwing `cause` getter ends the walk\n }\n return undefined\n}\n","import {version} from '../../package.json'\nimport {\n getSdkDelivery,\n hasDebugFlag,\n isErrorReportingEnabled,\n isLocalDevelopment,\n} from './isErrorReportingEnabled'\nimport {isKnownSdkError} from './isKnownSdkError'\nimport {beforeSend, sdkSentryDataCollection} from './privacy'\nimport {findSdkErrorInChain, isSdkError, markSdkError} from './sdkErrorOrigin'\nimport {\n type BrowserOptions,\n type ErrorEvent,\n type Event,\n type EventHint,\n type Scope,\n} from './sentryTypes'\n\n/**\n * The DSN of the SDK project in Sentry. It is a public ingest key, not a secret.\n */\nconst SDK_DSN = 'https://08e08ab0cbf33a49f7f5066597d5e374@sentry.sanity.io/4512347487666176'\n\n/**\n * Events go through the Sanity intake tunnel, which forwards them to Sentry. This avoids ad\n * blockers and customer CSP `connect-src` rules that block the Sentry ingest host.\n */\nconst SDK_TUNNEL = 'https://api.sanity.io/vX/intake/tracing'\n\n/** Most events a single page load may send. A render loop can throw thousands of errors. */\nconst MAX_EVENTS_PER_SESSION = 10\n\n/** Events with the same message inside this window are reported once. */\nconst DUPLICATE_WINDOW_MS = 5 * 60 * 1000\n\n/** Failed loads of the Sentry chunk allowed before the reporter gives up for the page load. */\nconst MAX_LOAD_FAILURES = 3\n\n/** @internal */\nexport interface ReportErrorInfo {\n /** The name of the error boundary that caught the error. */\n errorBoundary?: string\n}\n\n/** @internal */\nexport interface ErrorReporterOptions {\n /** Replaces the fetch transport, for tests. */\n transport?: BrowserOptions['transport']\n}\n\n/**\n * The value of the error that was thrown. When `linkedErrors` adds the causes, they come first\n * and the thrown error is last.\n */\nfunction getThrownValue(event: Event): string | undefined {\n return event.exception?.values?.at(-1)?.value ?? event.message\n}\n\n/**\n * Caps the events per session and drops repeats of the same message inside a time window. For an\n * app error that wraps an SDK error, the SDK error's message is the key, so app messages that\n * vary cannot spend the whole cap on one SDK bug.\n */\nfunction limitEventsIntegration() {\n const seen = new Map<string, number>()\n let sent = 0\n\n return {\n name: 'SdkLimitEvents',\n processEvent(event: Event, hint: EventHint): Event | null {\n if (sent >= MAX_EVENTS_PER_SESSION) return null\n\n const message =\n findSdkErrorInChain(hint.originalException)?.message ?? getThrownValue(event) ?? ''\n const now = Date.now()\n const previous = seen.get(message)\n if (previous !== undefined && now - previous < DUPLICATE_WINDOW_MS) return null\n\n seen.set(message, now)\n sent++\n return event\n },\n }\n}\n\n/**\n * Matches the SDK bundle served by the module server (`@sanity__sdk`, `@sanity__sdk-react`) and\n * the same packages under `node_modules` (`@sanity/sdk`, or `@sanity_sdk-react` in a Vite\n * dependency cache). The package name must end at a path separator or a file extension, so\n * `@sanity/sdk-other` does not match.\n */\nconst SDK_MODULE_PATTERN = /(?:@|%40)sanity(?:__|_|\\/|%2F)sdk(?:-react)?(?=[/.]|$)/\n\n/** This repo's own sources, which only show up in local development with the debug flag set. */\nconst SDK_SOURCE_PATTERN = /\\/packages\\/(?:core|react)\\/(?:src|dist)\\//\n\n/** Frame names the engine uses for code without a URL, such as `JSON.parse (<anonymous>)`. */\nconst BUILTIN_FRAME_PATTERN = /^(?:<.*>|native)$/\n\nfunction isSdkFilename(filename: string): boolean {\n return SDK_MODULE_PATTERN.test(filename) || (hasDebugFlag() && SDK_SOURCE_PATTERN.test(filename))\n}\n\n/**\n * The file of the innermost frame that has a URL. Builtins such as `JSON.parse` and `new URL`\n * sit on top of the stack when they throw, and the code that called them decides the owner.\n */\nfunction getThrowingFilename(event: Event): string | undefined {\n const frames = event.exception?.values?.at(-1)?.stacktrace?.frames ?? []\n for (let index = frames.length - 1; index >= 0; index--) {\n const filename = frames[index]?.filename\n if (filename && !BUILTIN_FRAME_PATTERN.test(filename)) return filename\n }\n return undefined\n}\n\n/**\n * Keeps only events thrown by SDK code. Error boundaries also catch errors thrown by the app\n * rendered beneath them, so ownership is decided in two ways. An error marked by an SDK hook, or\n * with a marked error in its cause chain, is the SDK's. Otherwise the frame that threw decides,\n * which works only when the SDK has its own URL, as with auto-updates or a dev server. Events\n * with neither a mark nor a usable frame are dropped.\n */\nfunction sdkOriginIntegration() {\n return {\n name: 'SdkOrigin',\n processEvent(event: Event, hint: EventHint): Event | null {\n if (findSdkErrorInChain(hint.originalException)) return event\n const filename = getThrowingFilename(event)\n return filename && isSdkFilename(filename) ? event : null\n },\n }\n}\n\n/**\n * Sentry marks every error it is given as already captured, and skips marked errors in every\n * Sentry client on the page. Capturing a copy keeps that mark off the app's own error objects.\n */\nfunction toCapturable(error: Error): Error {\n const copy = new Error(\n error.message,\n error.cause === undefined ? undefined : {cause: error.cause},\n )\n copy.name = error.name\n copy.stack = error.stack\n if (isSdkError(error)) markSdkError(copy)\n return copy\n}\n\nfunction getEnvironment(): string {\n return isLocalDevelopment() ? 'development' : 'production'\n}\n\n/**\n * Creates a reporter that sends unexpected SDK errors to Sentry. It owns its own Sentry client\n * and scope, and installs no global error handlers. Nothing is sent unless `reportError` is\n * called.\n *\n * @internal\n */\nexport function createErrorReporter(options: ErrorReporterOptions = {}): {\n reportError: (error: unknown, info?: ReportErrorInfo) => void\n} {\n let scopePromise: Promise<Scope> | undefined\n let loadFailures = 0\n\n function getScope(): Promise<Scope> {\n scopePromise ??= import('./sentryBrowser')\n .then((sentry) => {\n const client = new sentry.BrowserClient({\n dsn: SDK_DSN,\n tunnel: SDK_TUNNEL,\n // The published package version. `CORE_SDK_VERSION` reads `PKG_VERSION` from the app's\n // environment at runtime, which apps do not set, so it falls back to `<version>-development`\n release: version,\n environment: getEnvironment(),\n dataCollection: sdkSentryDataCollection,\n stackParser: sentry.defaultStackParser,\n transport: options.transport ?? sentry.makeFetchTransport,\n integrations: [\n sentry.linkedErrorsIntegration(),\n sdkOriginIntegration(),\n limitEventsIntegration(),\n ],\n beforeSend: (event: ErrorEvent) => beforeSend(event),\n })\n\n const scope = new sentry.Scope()\n scope.setClient(client)\n client.init()\n return scope\n })\n .catch((error: unknown) => {\n // Let the next report try again, for a chunk that failed to load while offline\n scopePromise = undefined\n loadFailures++\n throw error\n })\n return scopePromise\n }\n\n function reportError(error: unknown, info: ReportErrorInfo = {}): void {\n // This runs inside `componentDidCatch`, where a throw would reach the parent boundary\n try {\n // Sentry builds a synthetic stack for non-Error values, and that stack points into this\n // module, so such values would be attributed to the SDK\n if (\n !(error instanceof Error) ||\n loadFailures >= MAX_LOAD_FAILURES ||\n !isErrorReportingEnabled() ||\n isKnownSdkError(error)\n ) {\n return\n }\n\n const capturable = toCapturable(error)\n const {errorBoundary} = info\n const delivery = getSdkDelivery()\n const tags = errorBoundary\n ? {handled: 'no', delivery, errorBoundary}\n : {handled: 'no', delivery}\n\n getScope()\n .then((scope) => {\n scope.captureException(capturable, {\n mechanism: {handled: false, type: 'generic'},\n captureContext: {tags},\n })\n })\n .catch(() => {\n // Nothing to do. The reporter must not add errors to the app it reports for.\n })\n } catch {\n // Same: never throw into the caller\n }\n }\n\n return {reportError}\n}\n\n/**\n * Reports an unexpected error from the SDK to Sentry, when error reporting is enabled.\n *\n * @internal\n */\nexport const {reportError} = createErrorReporter()\n","import {FETCH_TIMEOUT_DEFAULT} from '@sanity/comlink'\nimport {DocumentId, isPublishedIdEqual} from '@sanity/id-utils'\nimport {catchError, defer, distinctUntilChanged, EMPTY, map, merge, type Observable} from 'rxjs'\n\nimport {requireDashboardMessageBus} from '../dashboard/messageBus/store'\nimport {type CapabilityRecord, type FavoriteDocument} from '../dashboard/messageBus/topics'\nimport {getTopicState, resolveTopic} from '../dashboard/messageBus/topicStore'\nimport {type SanityInstance} from '../store/createSanityInstance'\nimport {type StateSource} from '../store/createStateSourceAction'\nimport {defineMutation} from '../store/fetcherStore'\nimport {\n type FavoriteDocumentContext,\n favoriteScope,\n type FavoriteStatusResponse,\n type SetFavoriteInput,\n toFavoriteDocument,\n} from './favorites'\n\n// Published IDs mirror Dashboard's `_stableId` match.\nconst isSameFavorite = (\n a: FavoriteDocument['document'],\n b: FavoriteDocument['document'],\n): boolean =>\n a.type === b.type &&\n a.resource.id === b.resource.id &&\n a.resource.type === b.resource.type &&\n a.resource.schemaName === b.resource.schemaName &&\n isPublishedIdEqual(DocumentId(a.id), DocumentId(b.id))\n\n/**\n * A state source for whether a document is favorited, matched against the `favorites.documents`\n * the dashboard message bus host publishes. The message bus counterpart to the Comlink\n * {@link favorites} fetcher.\n *\n * @remarks\n * Returns `undefined` until the host publishes `applications.capabilities` and, while it provides\n * `favorites`, `favorites.documents`; use {@link resolveBusFavorite} to wait for them. Returns\n * `false` when the host does not provide `favorites` or the `favorites.documents` read fails.\n * A favorite is identified by its published document ID, type, resource and `schemaName`\n * (workspace), like in Dashboard.\n * @internal\n */\nexport function getBusFavoriteState(\n instance: SanityInstance,\n context: FavoriteDocumentContext,\n): StateSource<boolean | undefined> {\n const capabilities = getTopicState(instance, 'applications.capabilities')\n const documents = getTopicState(instance, 'favorites.documents')\n const target = toFavoriteDocument(context)\n\n const getCurrent = (): boolean | undefined => {\n const provided = capabilities.getCurrent() as CapabilityRecord | undefined\n if (provided === undefined) return undefined\n if (provided.favorites !== true) return false\n // A failed read degrades to \"not favorited\", like the Comlink fetcher.\n try {\n const favorites = documents.getCurrent() as FavoriteDocument[] | undefined\n return favorites?.some((favorite) => isSameFavorite(favorite.document, target))\n } catch {\n return false\n }\n }\n\n const subscribe = (onStoreChanged?: () => void) => {\n const unsubscribes = [\n capabilities.subscribe(onStoreChanged),\n documents.subscribe(onStoreChanged),\n ]\n return () => unsubscribes.forEach((unsubscribe) => unsubscribe())\n }\n\n const observable: Observable<boolean | undefined> = merge(\n capabilities.observable,\n documents.observable.pipe(catchError(() => EMPTY)),\n ).pipe(map(getCurrent), distinctUntilChanged())\n\n return {getCurrent, subscribe, observable}\n}\n\n/**\n * Resolves once {@link getBusFavoriteState} has the next value it waits for: the host's\n * capabilities first, then its `favorites.documents`.\n *\n * @internal\n */\nexport function resolveBusFavorite(instance: SanityInstance): Promise<void> {\n const capabilities = getTopicState(instance, 'applications.capabilities').getCurrent()\n return resolveTopic(\n instance,\n capabilities === undefined ? 'applications.capabilities' : 'favorites.documents',\n )\n}\n\n/**\n * Sets a document's favorite state over the dashboard message bus. The message bus counterpart\n * to `setFavorite`; the host keeps `favorites.documents` current, so there is no cache to\n * invalidate.\n *\n * @internal\n */\nexport const setBusFavorite = defineMutation<SetFavoriteInput, FavoriteStatusResponse>({\n name: 'setBusFavorite',\n scope: favoriteScope,\n mutationFn:\n (instance) =>\n ({isFavorited, ...context}) =>\n defer(() =>\n requireDashboardMessageBus(instance, 'update a favorite').emit(\n 'favorites.update',\n {document: toFavoriteDocument(context), favorited: isFavorited},\n // Matches the reply timeout of the Comlink write.\n {timeout: FETCH_TIMEOUT_DEFAULT},\n ),\n ).pipe(map(() => ({isFavorited}))),\n})\n","/**\n * The fields to check for a title.\n * The order of the items in the array defines the priority.\n *\n * @internal\n */\nexport const TITLE_CANDIDATES = ['title', 'name', 'label', 'heading', 'header', 'caption']\n\n/**\n * The fields to check for a subtitle.\n * The order of the items in the array defines the priority.\n *\n * @internal\n */\nexport const SUBTITLE_CANDIDATES = ['description', 'subtitle', ...TITLE_CANDIDATES]\n\n/**\n * Generates a GROQ projection for preview data without requiring a schema.\n * Uses common field names to make educated guesses about which fields to use.\n *\n * @internal\n */\nexport const PREVIEW_PROJECTION = `{\n // Get all potential title fields\n \"titleCandidates\": {\n ${TITLE_CANDIDATES.map((field) => `\"${field}\": ${field}`).join(',\\n ')}\n },\n // Get all potential subtitle fields\n \"subtitleCandidates\": {\n ${SUBTITLE_CANDIDATES.map((field) => `\"${field}\": ${field}`).join(',\\n ')}\n },\n \"media\": coalesce(\n select(\n defined(asset) => {\"type\": \"image-asset\", \"_ref\": asset._ref},\n defined(image.asset) => {\"type\": \"image-asset\", \"_ref\": image.asset._ref},\n defined(mainImage.asset) => {\"type\": \"image-asset\", \"_ref\": mainImage.asset._ref},\n null\n )\n ),\n _type,\n _id,\n _updatedAt\n}`\n","import {type SanityClient} from '@sanity/client'\nimport {createImageUrlBuilder} from '@sanity/image-url'\n\nimport {getClient} from '../client/clientStore'\nimport {type DocumentResource} from '../config/sanityConfig'\nimport {type SanityInstance} from '../store/createSanityInstance'\nimport {isObject} from '../utils/object'\nimport {SUBTITLE_CANDIDATES, TITLE_CANDIDATES} from './previewConstants'\nimport {type PreviewQueryResult, type PreviewValue} from './types'\n\nconst API_VERSION = 'v2025-05-06'\n\n/**\n * Checks if the provided value has `_ref` property that is a string and starts with `image-`\n */\nfunction hasImageRef<T>(value: unknown): value is T & {_ref: string} {\n return isObject(value) && '_ref' in value && typeof (value as {_ref: unknown})._ref === 'string'\n}\n\n/**\n * Normalizes a media asset to a preview value.\n * Adds a url to a media asset reference using `@sanity/image-url`.\n *\n * @internal\n */\nexport function normalizeMedia(media: unknown, client: SanityClient): PreviewValue['media'] {\n if (!media) return null\n if (!hasImageRef(media)) return null\n\n const builder = createImageUrlBuilder(client)\n const url = builder.image({_ref: media._ref}).url()\n\n return {\n type: 'image-asset',\n _ref: media._ref,\n url,\n }\n}\n\n/**\n * Finds a single field value from a set of candidates based on a priority list of field names.\n * Returns the first non-empty string value found from the candidates matching the priority list order.\n *\n * @internal\n */\nfunction findFirstDefined(\n fieldsToSearch: string[],\n candidates: Record<string, unknown>,\n exclude?: unknown,\n): string | undefined {\n if (!candidates) return undefined\n\n for (const field of fieldsToSearch) {\n const value = candidates[field]\n if (typeof value === 'string' && value.trim() !== '' && value !== exclude) {\n return value\n }\n }\n\n return undefined\n}\n\n/**\n * Transforms a projection result (with titleCandidates, subtitleCandidates, media)\n * into a PreviewValue (with title, subtitle, media).\n *\n * @param projectionResult - The raw projection result from GROQ\n * @param instance - The Sanity instance to use for client configuration\n * @param resource - Data resource for the preview\n * @internal\n */\nexport function transformProjectionToPreview(\n instance: SanityInstance,\n projectionResult: PreviewQueryResult,\n resource?: DocumentResource,\n): PreviewValue {\n const title = findFirstDefined(TITLE_CANDIDATES, projectionResult.titleCandidates)\n const subtitle = findFirstDefined(SUBTITLE_CANDIDATES, projectionResult.subtitleCandidates, title)\n\n // Get a client for the resource (if provided) or use the instance config\n const client = getClient(instance, {\n apiVersion: API_VERSION,\n resource,\n })\n\n return {\n title: String(title || `${projectionResult._type}: ${projectionResult._id}`),\n subtitle: subtitle || undefined,\n media: normalizeMedia(projectionResult.media, client),\n ...(projectionResult._status && {_status: projectionResult._status}),\n }\n}\n","/**\n * Telemetry environment classification.\n *\n * - `'development'` — the SDK is running on the local developer's machine\n * (`localhost` / `127.0.0.1` in the browser, or `NODE_ENV=development`\n * in Node). These are the original dev-only telemetry sessions.\n *\n * - `'production'` — the SDK is running on a production Sanity-controlled\n * domain (Studio deployments on `*.sanity.studio`, the dashboard on\n * `*.sanity.io`) where end users are authenticated Sanity users with\n * Populus consent records. Production telemetry is gated to this\n * allowlist; SDK apps deployed to customer-controlled domains do not\n * emit telemetry. Staging (`*.sanity.work`) and preview\n * (`*.sanity.dev`) hosts are deliberately excluded.\n *\n * @internal\n */\nexport type TelemetryEnvironment = 'development' | 'production'\n\n/**\n * Hostname suffixes that count as Sanity-controlled for the purposes of\n * production telemetry. A user reaching one of these hosts in the\n * browser is authenticated against Sanity and has a Populus consent\n * record, so we apply the same telemetry rules as the Studio's\n * `telemetry-sink`.\n *\n * The leading `.` is required: it ensures suffix matches hit a real\n * subdomain boundary, so apex matches (`sanity.io`, `sanity.studio`)\n * and lookalikes (`evilsanity.studio`) are excluded. Only production\n * hosts are listed; staging (`*.sanity.work`) and preview\n * (`*.sanity.dev`) hosts are excluded by omission.\n *\n * @internal\n */\nconst SANITY_CONTROLLED_HOST_SUFFIXES = ['.sanity.studio', '.sanity.io'] as const\n\nfunction getBrowserHostname(win: Window): string | null {\n const hostname = win.location?.hostname\n return typeof hostname === 'string' && hostname.length > 0 ? hostname.toLowerCase() : null\n}\n\nfunction isLocalHostname(hostname: string): boolean {\n return hostname === 'localhost' || hostname === '127.0.0.1'\n}\n\nfunction isSanityControlledHostname(hostname: string): boolean {\n return SANITY_CONTROLLED_HOST_SUFFIXES.some((suffix) => hostname.endsWith(suffix))\n}\n\n/**\n * Returns the telemetry environment for the current runtime, or `null`\n * when telemetry should not run at all.\n *\n * Browser:\n * - `localhost` / `127.0.0.1` → `'development'`\n * - host matches the Sanity-controlled allowlist → `'production'`\n * - anything else (customer domains, unknown contexts) → `null`\n *\n * Node (scripts, SSR, tests):\n * - `NODE_ENV=development` → `'development'`\n * - otherwise → `null`. Production-side server runtimes don't carry the\n * browser-authenticated user/consent assumption, so we don't enable\n * them under the production gate.\n *\n * Bracket-notation `process.env['NODE_ENV']` is used to avoid bundler\n * dead-code replacement.\n *\n * @internal\n */\nexport function getTelemetryEnvironment(): TelemetryEnvironment | null {\n if (typeof window !== 'undefined') {\n const hostname = getBrowserHostname(window)\n if (!hostname) return null\n if (isLocalHostname(hostname)) return 'development'\n if (isSanityControlledHostname(hostname)) return 'production'\n return null\n }\n\n if (typeof process !== 'undefined' && process.env?.['NODE_ENV'] === 'development') {\n return 'development'\n }\n return null\n}\n\n/**\n * Convenience predicate for \"telemetry can run in this environment\".\n *\n * @internal\n */\nexport function isTelemetryEnabled(): boolean {\n return getTelemetryEnvironment() !== null\n}\n","import {defineEvent} from '@sanity/telemetry'\n\n/**\n * Whether the instance has Studio configuration. Apps include Dashboard and standalone apps.\n * This describes instance configuration, not credential source or who authored a hook call.\n * @internal\n */\nexport type TelemetryRuntimeContext = 'studio' | 'app'\n\n// Keep attribution in event data to preserve the warehouse's data_auth_method convention.\ninterface TelemetryAttribution {\n /** Configured credential source (token/studio/default), distinct from getAuthMethodState's transport. */\n authMethod: string\n runtimeContext: TelemetryRuntimeContext\n}\n\n/** @internal */\nexport const SDKSessionStarted = defineEvent<\n TelemetryAttribution & {\n version: string\n projectId: string\n perspective: string\n }\n>({\n name: 'SDK Session Started',\n version: 1,\n description: 'SDK instance created (environment is recorded in the event context)',\n})\n\n/** @internal */\nexport const SDKHookMounted = defineEvent<\n TelemetryAttribution & {\n hookName: string\n }\n>({\n name: 'SDK Hook Mounted',\n version: 1,\n description: 'An SDK hook was mounted for the first time in this session',\n})\n\n/** @internal */\nexport const SDKSessionEnded = defineEvent<\n TelemetryAttribution & {\n durationSeconds: number\n hooksUsed: string[]\n }\n>({\n name: 'SDK Session Ended',\n version: 1,\n description: 'SDK instance disposed (environment is recorded in the event context)',\n})\n\n/** @internal */\nexport const SDKError = defineEvent<{\n errorType: string\n hookName: string\n}>({\n name: 'SDK Error',\n version: 1,\n description: 'Runtime error caught in the SDK',\n})\n","import {type SanityClient} from '@sanity/client'\nimport {\n type ConsentStatus,\n createBatchedStore,\n type SessionId,\n type TelemetryEvent,\n type TelemetryLogger,\n type TelemetryStore,\n} from '@sanity/telemetry'\n\nimport {createLogger} from '../utils/logger'\nimport {CORE_SDK_VERSION} from '../version'\nimport {type TelemetryEnvironment} from './environment'\nimport {\n SDKError,\n SDKHookMounted,\n SDKSessionEnded,\n SDKSessionStarted,\n type TelemetryRuntimeContext,\n} from './events'\n\nconst FLUSH_INTERVAL_MS = 30_000\nconst CONSENT_TAG = 'telemetry-consent.sdk'\nconst BATCH_TAG = 'telemetry.batch'\n\nconst log = createLogger('telemetry')\n\n/**\n * Manages telemetry for a single SDK instance.\n *\n * Wraps `@sanity/telemetry`'s batched store with SDK-specific concerns:\n * consent caching, session lifecycle events, and hook usage tracking.\n * The `environment` is captured at construction time and recorded in\n * the event context so downstream pipelines can distinguish dev and\n * production sessions.\n *\n * @internal\n */\nexport interface TelemetryManager {\n /**\n * Eagerly resolve and cache the user's consent status.\n * Returns true only when the user has explicitly opted in (`granted`).\n * Call this before logging any events to avoid buffering events that\n * will be dropped on the first flush.\n */\n checkConsent(): Promise<boolean>\n\n /** Log a \"SDK Session Started\" event */\n logSessionStarted(data: {projectId: string; perspective: string}): void\n\n /** Log a \"SDK Hook Mounted\" event (deduplicated per hook name) */\n logHookFirstUsed(hookName: string): void\n\n /** Log a \"SDK Error\" event */\n logError(errorType: string, hookName: string): void\n\n /** Log a \"SDK Session Ended\" event and tear down the store */\n endSession(): void\n\n /** Tear down the store without logging a session-end event */\n dispose(): void\n\n /** The set of hook names used during this session */\n readonly hooksUsed: ReadonlySet<string>\n}\n\ninterface TelemetryManagerOptions {\n sessionId: string\n getClient: () => SanityClient\n projectId: string\n environment: TelemetryEnvironment\n authMethod: string\n runtimeContext: TelemetryRuntimeContext\n}\n\n/**\n * Creates a telemetry manager for a single SDK instance session.\n *\n * The manager initializes a `createBatchedStore` from `@sanity/telemetry`,\n * caches the consent check for the lifetime of the session, and provides\n * typed methods for each SDK telemetry event.\n *\n * @internal\n */\nexport function createTelemetryManager(options: TelemetryManagerOptions): TelemetryManager {\n const {sessionId, getClient, projectId, environment, authMethod, runtimeContext} = options\n const startedAt = Date.now()\n const emittedHooks = new Set<string>()\n\n let cachedConsent: {status: ConsentStatus} | null = null\n\n const resolveConsent = async (): Promise<{status: ConsentStatus}> => {\n if (cachedConsent) return cachedConsent\n try {\n const client = getClient()\n const result = await client.request<{status: ConsentStatus}>({\n url: '/intake/telemetry-status',\n tag: CONSENT_TAG,\n })\n cachedConsent = result\n } catch {\n cachedConsent = {status: 'undetermined'}\n }\n return cachedConsent\n }\n\n const enrichBatch = (batch: TelemetryEvent[]) =>\n batch.map((event) => {\n // Trace events (`trace.start` / `trace.log` / `trace.error` /\n // `trace.complete`) arrive with their own caller-provided `context`.\n // Log / userProperties events don't. Narrow via `in` so `event`\n // stays typed as `TelemetryEvent`, then merge so we don't drop the\n // trace context. SDK-owned fields below win on conflict.\n const existing =\n 'context' in event ? (event.context as Record<string, unknown> | undefined) : undefined\n return {\n ...event,\n context: {\n ...existing,\n version: CORE_SDK_VERSION,\n environment,\n origin: typeof window !== 'undefined' ? window.location.origin : 'node',\n },\n }\n })\n\n const sendEvents = async (batch: TelemetryEvent[]): Promise<unknown> => {\n const client = getClient()\n log.debug('sending event batch', {batchSize: batch.length, environment})\n return client.request({\n url: '/intake/batch',\n method: 'POST',\n body: {projectId, batch: enrichBatch(batch)},\n tag: BATCH_TAG,\n })\n }\n\n const store: TelemetryStore<Record<string, unknown>> = createBatchedStore(\n sessionId as SessionId,\n {\n flushInterval: FLUSH_INTERVAL_MS,\n resolveConsent,\n sendEvents,\n },\n )\n\n const logger: TelemetryLogger<Record<string, unknown>> = store.logger\n\n return {\n async checkConsent() {\n const {status} = await resolveConsent()\n return status === 'granted'\n },\n\n logSessionStarted(data) {\n log.debug('event: SDK Session Started', {\n projectId: data.projectId,\n perspective: data.perspective,\n authMethod,\n runtimeContext,\n version: CORE_SDK_VERSION,\n environment,\n })\n logger.log(SDKSessionStarted, {\n version: CORE_SDK_VERSION,\n ...data,\n authMethod,\n runtimeContext,\n })\n },\n\n logHookFirstUsed(hookName: string) {\n if (emittedHooks.has(hookName)) return\n emittedHooks.add(hookName)\n log.debug('event: SDK Hook Mounted', {hookName, authMethod, runtimeContext})\n logger.log(SDKHookMounted, {hookName, authMethod, runtimeContext})\n },\n\n logError(errorType: string, hookName: string) {\n log.debug('event: SDK Error', {errorType, hookName})\n logger.log(SDKError, {errorType, hookName})\n },\n\n endSession() {\n const durationSeconds = Math.round((Date.now() - startedAt) / 1000)\n log.debug('event: SDK Session Ended', {\n durationSeconds,\n hooksUsed: [...emittedHooks],\n authMethod,\n runtimeContext,\n environment,\n })\n logger.log(SDKSessionEnded, {\n durationSeconds,\n hooksUsed: [...emittedHooks],\n authMethod,\n runtimeContext,\n })\n\n store.flush().catch(() => {\n // Best-effort flush on dispose; swallow errors\n })\n store.end()\n },\n\n dispose() {\n store.end()\n },\n\n get hooksUsed(): ReadonlySet<string> {\n return emittedHooks\n },\n }\n}\n","import {type SanityInstance} from '../store/createSanityInstance'\nimport {createLogger} from '../utils/logger'\nimport {getTelemetryEnvironment} from './environment'\nimport {type TelemetryManager} from './telemetryManager'\n\nconst DEFAULT_TELEMETRY_API_VERSION = '2024-11-12'\n\nconst logger = createLogger('telemetry')\n\n/**\n * Per-instance map of active telemetry managers. Allows the React\n * package (and other consumers) to look up the manager for a given\n * instance and log hook usage / errors without importing the full\n * telemetry module themselves.\n *\n * @internal\n */\nconst telemetryManagers = new WeakMap<SanityInstance, TelemetryManager>()\nconst pendingHooks = new WeakMap<SanityInstance, Set<string>>()\nconst initInFlight = new WeakSet<SanityInstance>()\n\n/**\n * Initializes telemetry for a SDK instance if the runtime environment\n * qualifies. The environment is resolved by `getTelemetryEnvironment()`:\n *\n * - `'development'` — local dev servers (`localhost` / `127.0.0.1`, or\n * Node with `NODE_ENV=development`). This is the original opt-in\n * surface.\n * - `'production'` — apps deployed to Sanity-controlled domains\n * (e.g. `*.sanity.studio`, the dashboard). End users are\n * authenticated Sanity users with Populus consent records, so we\n * apply the same consent gate as the Studio's `telemetry-sink`.\n *\n * Apps on customer-controlled domains return `null` and skip telemetry\n * entirely.\n *\n * `telemetryManager` and `clientStore` are dynamically imported so the\n * telemetry code path stays out of production bundles for apps that\n * don't qualify. Only the lightweight environment check runs at boot.\n *\n * The `projectId` must be passed explicitly because the resource\n * configuration is typically set by the React layer after the\n * instance has already been created.\n *\n * @internal\n */\nexport function initTelemetry(instance: SanityInstance, projectId: string): void {\n const environment = getTelemetryEnvironment()\n if (!environment) {\n logger.trace('initTelemetry skipped: environment not eligible', {internal: true})\n return\n }\n if (!projectId) {\n logger.trace('initTelemetry skipped: no projectId', {internal: true})\n return\n }\n if (telemetryManagers.has(instance) || initInFlight.has(instance)) {\n return\n }\n initInFlight.add(instance)\n\n logger.debug('initializing telemetry', {projectId, environment})\n\n Promise.all([\n import('./telemetryManager'),\n import('../client/clientStore'),\n import('../auth/authStore'),\n import('../auth/authMode'),\n ])\n .then(async ([{createTelemetryManager}, {getClient}, {getTokenState}, {isStudioConfig}]) => {\n if (instance.isDisposed()) {\n initInFlight.delete(instance)\n logger.debug('telemetry skipped: instance disposed before imports resolved')\n return\n }\n\n // Wait for the auth store to resolve a token. The client needs a\n // Bearer token for the consent check and batch POSTs. If the token\n // is already available (e.g. static token config), this resolves\n // immediately. For OAuth/localStorage discovery it waits for the\n // first emission. For unauthenticated apps the promise never\n // resolves, which is fine since telemetry requires auth anyway.\n const token = getTokenState(instance).getCurrent()\n logger.trace('auth token check', {tokenPresent: !!token, internal: true})\n\n if (!token) {\n logger.debug('waiting for auth token')\n const hasToken = await new Promise<boolean>((resolve) => {\n if (instance.isDisposed()) return resolve(false)\n const cleanup = {unsubscribe: () => {}}\n const unsub = instance.onDispose(() => {\n cleanup.unsubscribe()\n resolve(false)\n })\n // The token observable is a `shareReplay({bufferSize: 1, refCount: true})`\n // (see `createStateSourceAction`), so it can deliver a buffered value\n // synchronously while we're still inside `.subscribe(cb)`. At that\n // moment `sub` is in the TDZ, so the callback can't reach it. We\n // gate on a `received` flag and let the post-subscribe block do the\n // unsubscribe in the sync-emission case.\n let received = false\n const sub = getTokenState(instance).observable.subscribe((t) => {\n if (received || !t) return\n received = true\n logger.debug('auth token received')\n unsub()\n resolve(true)\n cleanup.unsubscribe()\n })\n cleanup.unsubscribe = () => sub.unsubscribe()\n if (received) cleanup.unsubscribe()\n })\n if (!hasToken || instance.isDisposed()) {\n initInFlight.delete(instance)\n logger.debug('telemetry skipped: no token resolved or instance disposed')\n return\n }\n }\n\n const config = instance.config\n const perspective = typeof config.perspective === 'string' ? config.perspective : 'published'\n // Studio instances can use explicit tokens. Keep runtime context independent of auth.\n const runtimeContext = isStudioConfig(config) ? 'studio' : 'app'\n const authMethod = config.auth?.token\n ? 'token'\n : config.studio?.auth?.token\n ? 'studio'\n : 'default'\n\n const manager = createTelemetryManager({\n sessionId: instance.instanceId,\n getClient: () => getClient(instance, {apiVersion: DEFAULT_TELEMETRY_API_VERSION}),\n projectId,\n environment,\n authMethod,\n runtimeContext,\n })\n\n const consented = await manager.checkConsent()\n logger.debug('consent check complete', {consented})\n if (!consented || instance.isDisposed()) {\n initInFlight.delete(instance)\n manager.dispose()\n return\n }\n\n initInFlight.delete(instance)\n telemetryManagers.set(instance, manager)\n\n const buffered = pendingHooks.get(instance)\n if (buffered) {\n logger.debug('flushing buffered hooks', {hooks: Array.from(buffered)})\n for (const hookName of buffered) {\n manager.logHookFirstUsed(hookName)\n }\n pendingHooks.delete(instance)\n }\n\n logger.info('telemetry session started', {\n projectId,\n perspective,\n authMethod,\n runtimeContext,\n environment,\n })\n manager.logSessionStarted({\n projectId,\n perspective,\n })\n\n instance.onDispose(() => {\n manager.endSession()\n telemetryManagers.delete(instance)\n logger.debug('telemetry session ended')\n })\n })\n .catch((err) => {\n initInFlight.delete(instance)\n logger.warn('telemetry init failed', {error: err})\n })\n}\n\n/**\n * Retrieves the telemetry manager for an instance, if one exists.\n * Returns undefined when telemetry is disabled or not yet initialized.\n *\n * @internal\n */\nexport function getTelemetryManager(instance: SanityInstance): TelemetryManager | undefined {\n return telemetryManagers.get(instance)\n}\n\n/**\n * Record a hook name for an instance. If the telemetry manager is\n * already initialized the event is logged immediately. Otherwise\n * the name is buffered and flushed when init completes.\n *\n * @internal\n */\nexport function trackHookMounted(instance: SanityInstance, hookName: string): void {\n if (!getTelemetryEnvironment()) return\n\n const manager = findManager(instance)\n if (manager) {\n logger.trace('hook mounted (logged)', {hookName, internal: true})\n manager.logHookFirstUsed(hookName)\n return\n }\n\n const root = getRootInstance(instance)\n let hooks = pendingHooks.get(root)\n if (!hooks) {\n hooks = new Set()\n pendingHooks.set(root, hooks)\n }\n if (!hooks.has(hookName)) {\n logger.trace('hook mounted (buffered)', {hookName, internal: true})\n }\n hooks.add(hookName)\n}\n\nfunction findManager(instance: SanityInstance): TelemetryManager | undefined {\n return telemetryManagers.get(instance)\n}\n\nfunction getRootInstance(instance: SanityInstance): SanityInstance {\n return instance\n}\n","const WILDCARD_TOKEN = '*'\nconst NEGATION_TOKEN = '-'\n// This regex handles simple cases including quoted phrases.\n// More complex query syntaxes might need a more robust parser.\nconst TOKEN_REGEX = /(?:[^\\s\"]+|\"[^\"]*\")+/g\n\n/**\n * @internal\n * Checks if a token starts with the negation character.\n */\nfunction isNegationToken(token: string | undefined): boolean {\n return typeof token !== 'undefined' && token.trim().startsWith(NEGATION_TOKEN)\n}\n\n/**\n * @internal\n * Checks if a token ends with the wildcard character.\n */\nfunction isPrefixToken(token: string | undefined): boolean {\n return typeof token !== 'undefined' && token.trim().endsWith(WILDCARD_TOKEN)\n}\n\n/**\n * @internal\n * Checks if a token is enclosed in double quotes.\n */\nfunction isExactMatchToken(token: string | undefined): boolean {\n // Ensure the token exists, has at least 2 characters, and starts/ends with \"\n return !!token && token.length >= 2 && token.startsWith('\"') && token.endsWith('\"')\n}\n\n/**\n * Creates a GROQ search filter string (`[@] match text::query(\"...\")`)\n * from a raw search query string.\n *\n * It applies wildcard ('*') logic to the last eligible token and escapes\n * backslashes and double quotes within the search term.\n *\n * If the input query is empty or only whitespace, it returns an empty string.\n *\n * @param query - The raw input search string.\n * @returns The GROQ search filter string, or an empty string.\n * @internal\n */\nexport function createGroqSearchFilter(query: string): string {\n // Trim leading/trailing whitespace from the overall query first\n const trimmedQuery = query.trim()\n if (!trimmedQuery) {\n return '' // Return empty if query is empty or just whitespace\n }\n\n // Extract tokens using the regex\n const tokens = trimmedQuery.match(TOKEN_REGEX) ?? []\n\n // Find the index of the last token eligible for wildcard appending\n const reversedTokens = [...tokens].reverse()\n const reversedIndex = reversedTokens.findIndex(\n (token: string) => !isNegationToken(token) && !isExactMatchToken(token),\n )\n const finalIncrementalTokenIndex = reversedIndex === -1 ? -1 : tokens.length - 1 - reversedIndex\n\n // Get the actual token based on the found index\n const finalIncrementalToken = tokens[finalIncrementalTokenIndex]\n\n const processedTokens = [...tokens]\n // If a suitable token was found and it doesn't already end with a wildcard,\n // apply the wildcard.\n if (finalIncrementalToken !== undefined && !isPrefixToken(finalIncrementalToken)) {\n // Replace the identified token with its wildcarded version\n processedTokens.splice(\n finalIncrementalTokenIndex,\n 1,\n `${finalIncrementalToken}${WILDCARD_TOKEN}`,\n )\n }\n\n // Join the tokens back into a space-separated string\n const wildcardSearch = processedTokens.join(' ')\n\n // Escape backslashes and double quotes within the final search term for the\n // GROQ query. Backslashes go first, so the escapes added for quotes are not\n // themselves escaped. Without this a trailing backslash would escape the\n // closing quote and let the input break out of the string literal.\n const escapedSearch = wildcardSearch.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n\n // Construct the final GROQ filter clause\n return `[@] match text::query(\"${escapedSearch}\")`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,sBAAsB,SAAkC;CACtE,OAAO,KAAK,UAAU;EACpB,YAAY,QAAQ;EACpB,cAAc,QAAQ;EACtB,WAAW,QAAQ;EACnB,SAAS,QAAQ;EACjB,UAAU,QAAQ;EAClB,aAAa,QAAQ;EACrB,WAAW,QAAQ,cAAc,KAAA,IAAY,KAAA,IAAY,mBAAmB,QAAQ,SAAS;EAC7F,QAAQ,QAAQ;CAMlB,CAC6E;AAC/E;;AAGA,SAAgB,wBAAwB,KAA8B;CACpE,OAAO,KAAK,MAAM,GAAG;AACvB;;;;;;;;ACnEA,SAAgB,qBACd,aAIe;CACf,IAAI,YAAY,gBAAgB,MAAM,OAAO,IAAI,IAAI,Y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,CAAC,WAAW,GAAc;AAC/E;;;;;AAMA,SAAS,cAAc,OAAoC;CACzD,OAAc,UAAU,UAAe,MAAM,KAAK,CAAC,CAAC,SAAS,GAAc;AAC7E;;;;;AAMA,SAAS,kBAAkB,OAAoC;CAE7D,OAAO,CAAC,CAAC,SAAS,MAAM,UAAU,KAAK,MAAM,WAAW,IAAG,KAAK,MAAM,SAAS,IAAG;AACpF;;;;;;;;;;;;;;AAeA,SAAgB,uBAAuB,OAAuB;CAE5D,IAAM,eAAe,MAAM,KAAK;CAChC,IAAI,CAAC,cACH,OAAO;CAIT,IAAM,SAAS,aAAa,MAAM,WAAW,KAAK,CAAC,GAI7C,gBADiB,CAAC,GAAG,MAAM,CAAC,CAAC,QACA,CAAC,CAAC,WAClC,UAAkB,CAAC,gBAAgB,KAAK,KAAK,CAAC,kBAAkB,KAAK,CACxE,GACM,6BAA6B,kBAAkB,KAAK,KAAK,OAAO,SAAS,IAAI,eAG7E,wBAAwB,OAAO,6BAE/B,kBAAkB,CAAC,GAAG,MAAM;CAsBlC,OAnBI,0BAA0B,KAAA,KAAa,CAAC,cAAc,qBAAqB,KAE7E,gBAAgB,OACd,4BACA,GACA,GAAG,wBACL,GAaK,0BATgB,gBAAgB,KAAK,GAMT,CAAC,CAAC,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,MAG7B,EAAE;AACjD"}
1
+ {"version":3,"file":"_internal.js","names":["MAX_CAUSE_DEPTH","\"NODE_ENV\""],"sources":["../../src/comments/legacy/commentsOptions.ts","../../src/applications/applicationOrigin.ts","../../src/comments/commentsOptions.ts","../../src/dashboard/applications.ts","../../src/dashboard/messageBus/workerStore.ts","../../src/errorReporting/isErrorReportingEnabled.ts","../../src/errorReporting/isKnownSdkError.ts","../../src/errorReporting/privacy.ts","../../src/errorReporting/sdkErrorOrigin.ts","../../src/errorReporting/errorReporter.ts","../../src/favorites/busFavorites.ts","../../src/preview/previewConstants.ts","../../src/preview/previewProjectionUtils.ts","../../src/telemetry/environment.ts","../../src/telemetry/events.ts","../../src/telemetry/telemetryManager.ts","../../src/telemetry/initTelemetry.ts","../../src/utils/createGroqSearchFilter.ts"],"sourcesContent":["// fallow-ignore-file code-duplication -- deprecated add-on dataset comments, kept alongside comments/ until removal in the next major\nimport {type Path} from '@sanity/types'\n\nimport {type DocumentHandle} from '../../config/sanityConfig'\nimport {toCommentFieldPath} from '../commentFieldPath'\nimport {type CommentStatus} from './types'\n\n/**\n * Which comments to read.\n * @beta\n * @deprecated Comments have moved to the organization collaboration API. Import from\n * `@sanity/sdk/collaboration`; this add-on dataset API is removed in the next major.\n */\nexport interface CommentsOptions extends DocumentHandle {\n /**\n * Narrow to one field. Omit to get every comment on the document.\n */\n fieldPath?: string | Path\n /** Narrow to open or resolved threads. Omit for both. */\n status?: CommentStatus\n}\n\n/**\n * @beta\n * @deprecated Comments have moved to the organization collaboration API. Import from\n * `@sanity/sdk/collaboration`; this add-on dataset API is removed in the next major.\n */\nexport interface ResolveCommentsOptions extends CommentsOptions {\n signal?: AbortSignal\n}\n\n/**\n * Fields on {@link CommentsOptions} that are deliberately left out of the key\n * below, because neither changes which comments an option set addresses.\n *\n * `source` is the deprecated alias for `resource` and is folded into it before\n * a key is ever built, so keying on both would give one list two keys.\n * `liveEdit` describes the document rather than its comments, which hang off\n * the published id whether or not drafts exist.\n */\ntype CommentsKeyIrrelevantField = 'source' | 'liveEdit'\n\n/**\n * A stable string standing for one set of read options.\n *\n * Only React needs this: it holds one state source steady across renders and\n * defers swapping to a new one while the previous list is still on screen.\n * `fieldPath` is normalised on the way in, so a path array and the equivalent\n * string address the same list.\n *\n * Kept apart from the store it keys, because React imports this to memoize and\n * pulling the store in with it would put both comment stores into every bundle\n * that reads a comment.\n *\n * @internal\n */\nexport function getCommentsOptionsKey(options: CommentsOptions): string {\n return JSON.stringify({\n documentId: options.documentId,\n documentType: options.documentType,\n projectId: options.projectId,\n dataset: options.dataset,\n resource: options.resource,\n perspective: options.perspective,\n fieldPath: options.fieldPath === undefined ? undefined : toCommentFieldPath(options.fieldPath),\n status: options.status,\n // The `Record` half makes a new field on `CommentsOptions` a compile\n // error here unless it is listed above or named as irrelevant. Left to\n // `satisfies CommentsOptions` alone, a forgotten field would just be\n // absent from the key, and a reader would keep the list it had while the\n // caller thought it had asked for a different one.\n } satisfies CommentsOptions &\n Record<Exclude<keyof CommentsOptions, CommentsKeyIrrelevantField>, unknown>)\n}\n\n/** @internal */\nexport function parseCommentsOptionsKey(key: string): CommentsOptions {\n return JSON.parse(key) as CommentsOptions\n}\n","import {type ApplicationBase} from './applications'\n\ntype SanityGlobal = typeof globalThis & {__SANITY_STAGING__?: boolean}\n\n/**\n * The origin an application is served from, or `null` when it has neither an external URL nor\n * a slug to derive one from. Callers treat `null` as \"nothing to load\" rather than failing the\n * whole list on one bad record.\n *\n * @internal\n */\nexport function getApplicationOrigin(\n application: Pick<\n ApplicationBase,\n 'externalUrl' | 'slug' | 'isSingleton' | 'organizationId' | 'isLegacy'\n > & {type?: string},\n): string | null {\n if (application.externalUrl !== null) return new URL(application.externalUrl).origin\n if (application.slug === null) return null\n\n // Read at runtime, not via a bundler define: a remote is built once and runs in whichever\n // host page loaded it, and the host sets this flag. Mirrors workbench's `getSanityEnv`.\n const staging = (globalThis as SanityGlobal).__SANITY_STAGING__ === true\n // Custom (non-legacy) core apps share the singleton host. A record without `isLegacy` comes from\n // a host that predates that address, so it keeps the slug address.\n const isSanityHostedCustomApp = application.type === 'coreApp' && application.isLegacy === false\n if (application.isSingleton || isSanityHostedCustomApp) {\n const domain = staging ? 'run.sanity.work' : 'sanity.run'\n return `https://${application.slug}--apps--${application.organizationId}.${domain}`\n }\n\n const domain = staging ? 'studio.sanity.work' : 'sanity.studio'\n return `https://${application.slug}.${domain}`\n}\n","import {type QueryParams} from '@sanity/client'\nimport {type Path} from '@sanity/types'\n\nimport {type DatasetHandle, type DocumentHandle} from '../config/sanityConfig'\nimport {toCommentFieldPath} from './commentFieldPath'\nimport {type CommentStatus} from './types'\n\n/**\n * Which of a document's comments a read covers.\n *\n * @beta\n */\nexport type CommentsReadScope = 'perspective' | 'exact' | 'all'\n\n/**\n * Which of a document's comments to read.\n * @beta\n */\nexport interface CommentsOptions extends DocumentHandle {\n /** Narrow to one field. Omit to get every comment on the document. */\n fieldPath?: string | Path\n /** Narrow to open or resolved threads. Omit for both. */\n status?: CommentStatus\n /**\n * Which of the document's comments to read.\n *\n * - `'perspective'` follows what you are viewing: a release shows that\n * release's comments, anything else pools draft and published.\n * - `'exact'` matches only the precise document id passed.\n * - `'all'` returns every comment on the document.\n *\n * `'perspective'` recognises a release from the `{releaseName}` form. A\n * stacked `ClientPerspective` array names several layers at once, with no\n * single release to read comments from, so it pools draft and published as\n * any other non-release perspective does. To read the pooled list while a\n * release is in view, pass a non-release `perspective` alongside; to name a\n * release yourself, pass a version id as the `documentId`.\n *\n * A content variant is stored as a version document, so under\n * `'perspective'` its comments form a list of their own, the way a release's\n * do. A variant's draft and published comments are separate lists: pairing\n * them needs the variant's name, which its document id does not carry.\n *\n * @defaultValue 'perspective'\n */\n scope?: CommentsReadScope\n}\n\n/** @beta */\nexport interface ResolveCommentsOptions extends CommentsOptions {\n signal?: AbortSignal\n}\n\n/**\n * An arbitrary comment query, for anything that is not \"comments on this\n * document\" — cross-document views, per-user views, organization-wide activity.\n *\n * @beta\n */\nexport interface CommentsQueryOptions extends DatasetHandle {\n /**\n * GROQ filter applied to comment documents. `_type == \"sanity.comment\"` is\n * added for you, so this only has to say which comments.\n *\n * It is evaluated against every comment the organization can read. The\n * resource picks the organization but does not narrow the results; add a\n * `target.document._ref` prefix condition to keep to one dataset.\n */\n filter: string\n params?: QueryParams\n}\n\n/** @beta */\nexport interface ResolveCommentsQueryOptions extends CommentsQueryOptions {\n signal?: AbortSignal\n}\n\n/**\n * Fields on the read option types that are deliberately left out of the keys\n * below, because none of them changes which comments an option set addresses.\n *\n * `source` is the deprecated alias for `resource` and is folded into it before\n * a key is ever built, so keying on both would give one list two keys.\n * `liveEdit` describes the document rather than its comments, which hang off\n * the published id whether or not drafts exist.\n */\ntype CommentsKeyIrrelevantField = 'source' | 'liveEdit'\n\n/**\n * A stable string standing for one set of document read options.\n *\n * Only React needs this: it holds one state source steady across renders and\n * defers swapping to a new one while the previous list is still on screen.\n * `fieldPath` is normalised on the way in, so a path array and the equivalent\n * string address the same list.\n *\n * Kept apart from the store it keys, because React imports this to memoize and\n * pulling the store in with it would put both comment stores into every bundle\n * that reads a comment.\n *\n * @internal\n */\nexport function getDocumentCommentsOptionsKey(options: CommentsOptions): string {\n return JSON.stringify({\n documentId: options.documentId,\n documentType: options.documentType,\n projectId: options.projectId,\n dataset: options.dataset,\n resource: options.resource,\n perspective: options.perspective,\n fieldPath: options.fieldPath === undefined ? undefined : toCommentFieldPath(options.fieldPath),\n status: options.status,\n scope: options.scope,\n // The `Record` half makes a new field on `CommentsOptions` a compile\n // error here unless it is listed above or named as irrelevant. Left to\n // `satisfies CommentsOptions` alone, a forgotten field would just be\n // absent from the key, and a reader would keep the list it had while the\n // caller thought it had asked for a different one.\n } satisfies CommentsOptions &\n Record<Exclude<keyof CommentsOptions, CommentsKeyIrrelevantField>, unknown>)\n}\n\n/** @internal */\nexport function parseDocumentCommentsOptionsKey(key: string): CommentsOptions {\n return JSON.parse(key) as CommentsOptions\n}\n\n/**\n * The same, for the GROQ escape hatch.\n *\n * @internal\n */\nexport function getCommentsQueryOptionsKey(options: CommentsQueryOptions): string {\n return JSON.stringify({\n filter: options.filter,\n params: options.params,\n projectId: options.projectId,\n dataset: options.dataset,\n resource: options.resource,\n perspective: options.perspective,\n } satisfies CommentsQueryOptions &\n Record<Exclude<keyof CommentsQueryOptions, CommentsKeyIrrelevantField>, unknown>)\n}\n\n/** @internal */\nexport function parseCommentsQueryOptionsKey(key: string): CommentsQueryOptions {\n return JSON.parse(key) as CommentsQueryOptions\n}\n","import {getApplicationOrigin} from '../applications/applicationOrigin'\nimport {type ApplicationBase, type ApplicationInterface} from '../applications/applications'\nimport {type Installation, type InstallationInclude} from '../installations/installations'\nimport {type RemoteModuleRef, type ValueOf} from './messageBus/topics'\nimport {type View, type WebWorker} from './views'\n\ntype DashboardTopicEntry = Extract<\n NonNullable<ValueOf<'applications.list'>>,\n {ok: true}\n>['value'][number]\n// The published union distinguishes an `Application` (has `type`) from an `Installation` (has not).\ntype DashboardTopicApplication = Extract<DashboardTopicEntry, {type: unknown}>\ntype DashboardTopicInstallation = Exclude<DashboardTopicEntry, {type: unknown}>\n\n/**\n * The shared identity fields of each {@link DashboardApplication}, and the input to module\n * loading. Widens {@link ApplicationBase} so `type` also covers installations.\n * @beta\n * @category Types\n * @category Dashboard\n */\nexport type DashboardApplicationBase = Omit<ApplicationBase, 'type'> & {\n readonly type: ApplicationBase['type'] | 'installation'\n /** Served by a CLI dev server rather than a deployment. */\n readonly isLocal: boolean\n}\n\n/**\n * An installation shaped into the shared application base, with its raw record kept under\n * `installation` for consumers that need the full record.\n * @beta\n * @category Types\n * @category Dashboard\n */\nexport type DashboardInstallation = Omit<DashboardApplicationBase, 'type'> & {\n readonly type: 'installation'\n readonly installation: Installation<InstallationInclude>\n}\n\n/**\n * A dashboard entry — an application or an installation — in one consistent shape, with its\n * loadable views and web workers. `type` distinguishes the kinds and `isLocal` marks dev-server\n * applications; render a list without branching.\n * @beta\n * @category Types\n * @category Dashboard\n */\nexport type DashboardApplication = (DashboardTopicApplication | DashboardInstallation) &\n Pick<DashboardApplicationBase, 'isLocal'> & {\n readonly views: (View<{includeApplication: false}> & {readonly module: RemoteModuleRef})[]\n readonly webWorkers: (WebWorker<{includeApplication: false}> & {\n readonly module: RemoteModuleRef\n })[]\n }\n\n// Only a federated deployment (one with a module federation manifest) exposes loadable modules.\n// A dev server is always federated, whether or not the workbench synthesised a manifest for it.\nconst loadableInterfaces = (\n {activeDeployment, config}: DashboardTopicApplication,\n isLocal: boolean,\n): readonly ApplicationInterface[] =>\n isLocal || config?.mfManifest !== undefined ? (activeDeployment?.interfaces ?? []) : []\n\n// Turns an interface list into views and web workers loaded from `base`'s origin.\nconst loadModules = (\n base: DashboardApplicationBase,\n interfaces: readonly ApplicationInterface[],\n): Pick<DashboardApplication, 'views' | 'webWorkers'> => {\n // Nothing to load without interfaces or an origin to load them from.\n const entry = interfaces.length === 0 ? null : getApplicationOrigin(base)\n if (entry === null) return {views: [], webWorkers: []}\n\n const views: DashboardApplication['views'] = []\n const webWorkers: DashboardApplication['webWorkers'] = []\n\n for (const extension of interfaces) {\n const module: RemoteModuleRef = {\n entry,\n moduleId: `${base.id}/${extension.moduleId}`,\n version: extension.version,\n }\n\n switch (extension.type) {\n case 'worker': {\n webWorkers.push({...extension, module})\n break\n }\n case 'app': {\n const {type: _type, ...view} = extension\n views.push({...view, surface: 'window', module})\n break\n }\n case 'panel': {\n const {type, ...view} = extension\n views.push({...view, surface: type, module})\n break\n }\n case 'tile': {\n const {type, ...view} = extension\n views.push({...view, surface: type, module})\n break\n }\n case 'asset_source': {\n const {type, ...view} = extension\n views.push({...view, surface: type, module})\n break\n }\n }\n }\n\n return {views, webWorkers}\n}\n\nconst toApplication = (application: DashboardTopicApplication): DashboardApplication => {\n const {activeDeployment: _activeDeployment, config: _config, ...applicationBase} = application\n const isLocal = 'local' in application\n return {\n ...application,\n isLocal,\n ...loadModules({...applicationBase, isLocal}, loadableInterfaces(application, isLocal)),\n }\n}\n\nconst toInstallation = (installation: DashboardTopicInstallation): DashboardApplication => {\n const {application} = installation\n // `id` is the installation record's id, not its `applicationId`, so two installs of one app never\n // collide. `organizationId` is the publisher's: the singleton bundle is hosted under the org that\n // published it, and `isSingleton: true` with `externalUrl: null` routes the origin through\n // `getApplicationOrigin`'s singleton branch (`https://<slug>--apps--<publisherOrgId>.sanity.run`).\n // The installing org stays on the raw record. The workbench always serves installations\n // federated, so their interfaces are never gated.\n const base: DashboardApplicationBase = {\n id: installation.id,\n type: 'installation',\n isLocal: false,\n title: application.title,\n name: application.name,\n reference: application.reference,\n icon: application.icon,\n isSingleton: true,\n visibility: 'default',\n slug: application.slug,\n externalUrl: null,\n organizationId: application.organizationId,\n createdAt: installation.createdAt,\n updatedAt: installation.updatedAt,\n }\n // The raw record rides only the entry, not every view's `application`.\n return {\n ...base,\n type: 'installation',\n installation,\n ...loadModules(base, installation.interfaces ?? []),\n }\n}\n\n/**\n * Shapes the dashboard's published applications and installations into {@link DashboardApplication}s,\n * the entries `useApplications` returns.\n * @beta\n * @category Dashboard\n */\nexport function toDashboardApplications(\n entries: readonly DashboardTopicEntry[],\n): DashboardApplication[] {\n return entries.map((entry) => ('type' in entry ? toApplication(entry) : toInstallation(entry)))\n}\n","import {createActionBinder} from '../../store/createActionBinder'\nimport {defineStore} from '../../store/defineStore'\nimport {type MessageBusEmitOptions, workerMessages} from './bus'\nimport {requireDashboardMessageBus} from './store'\n\n/**\n * A view's client for one of its own application's workers, before `useWorker` types it.\n * @internal\n */\nexport interface WorkerConnection {\n post(payload?: unknown, options?: MessageBusEmitOptions): Promise<unknown>\n subscribe(handler: (message: unknown) => void): () => void\n}\n\ninterface DashboardWorkersState {\n workers: {[name: string]: WorkerConnection}\n}\n\nconst bindActionByInstance = createActionBinder<{name: string}, [name: string]>((instance) => ({\n name: instance.instanceId,\n}))\n\nconst dashboardWorkersStore = defineStore<DashboardWorkersState>({\n name: 'dashboardWorkers',\n getInitialState: () => ({workers: {}}),\n})\n\n/**\n * Returns the instance's client for one of its application's workers, creating it on first call.\n *\n * @remarks\n * The client lives with the instance rather than a component, so a render that suspended before\n * committing gets the same client when it renders again, and callers can key caches on it.\n * @internal\n */\nexport const getWorkerClient = bindActionByInstance(\n dashboardWorkersStore,\n ({instance, state}, name: string): WorkerConnection => {\n const current = state.get().workers[name]\n if (current) return current\n const messageBus = requireDashboardMessageBus(instance, `use worker \"${name}\"`)\n const client: WorkerConnection = {\n post: (payload, options) =>\n // Inside the executor, so a closed bus rejects instead of throwing.\n new Promise((resolve) =>\n resolve(messageBus.emit('workers.post', {name, payload}, options)),\n ),\n subscribe: (handler) => {\n const subscription = workerMessages(messageBus, name).subscribe(handler)\n return () => subscription.unsubscribe()\n },\n }\n state.set('addWorker', ({workers}) => ({workers: {...workers, [name]: client}}))\n return client\n },\n)\n","/**\n * localStorage key that forces error reporting on, for debugging the reporter itself.\n */\nconst DEBUG_KEY = 'SANITY_DEBUG_ERROR_REPORTING'\n\n/**\n * Hostnames of a dev server on this machine or the local network, where most errors come from\n * work in progress: loopback and unspecified addresses, private IPv4 ranges, private and\n * link-local IPv6, and `.localhost` and `.local` names.\n */\nconst LOCAL_HOSTNAME_PATTERN =\n /^(?:localhost|.+\\.localhost|.+\\.local|0\\.0\\.0\\.0|127(?:\\.\\d{1,3}){3}|10(?:\\.\\d{1,3}){3}|192\\.168(?:\\.\\d{1,3}){2}|172\\.(?:1[6-9]|2\\d|3[01])(?:\\.\\d{1,3}){2}|169\\.254(?:\\.\\d{1,3}){2}|\\[(?:::1?|f[cd][0-9a-f]{0,2}:[^\\]]*|fe80:[^\\]]*)\\])$/i\n\n/** DOM implementations that run in Node for tests, such as an app's own Vitest or Jest suite. */\nconst TEST_DOM_USER_AGENT_PATTERN = /jsdom|happydom/i\n\n/**\n * Whether the document has an import map with an `@sanity/sdk` entry. The Sanity CLI adds one\n * when an app is deployed with `autoUpdates`, so its presence means Sanity serves the SDK bundle.\n */\nfunction hasSdkPackageInImportMap(): boolean {\n if (typeof document === 'undefined' || !('querySelectorAll' in document)) return false\n\n return Array.from(document.querySelectorAll('script[type=\"importmap\"]')).some((entry) => {\n if (!entry.textContent) return false\n try {\n const imports = JSON.parse(entry.textContent).imports\n return Boolean(imports) && '@sanity/sdk' in imports\n } catch {\n return false\n }\n })\n}\n\n/**\n * How the page loaded the SDK: from the module server for an auto-updating app, or bundled\n * into the app's own build.\n *\n * @internal\n */\nexport function getSdkDelivery(): 'auto-updates' | 'bundled' {\n return hasSdkPackageInImportMap() ? 'auto-updates' : 'bundled'\n}\n\n/**\n * Whether the debug flag is set in localStorage. It also lets the origin filter accept this\n * repo's own source paths, which only appear in local development.\n *\n * @internal\n */\nexport function hasDebugFlag(): boolean {\n try {\n return typeof localStorage !== 'undefined' && Boolean(localStorage.getItem(DEBUG_KEY))\n } catch {\n return false\n }\n}\n\n/**\n * Whether the page runs on a local or development host. An empty hostname counts too: it is what\n * `file://` pages, Electron, and environments that shim `window` without a URL report.\n *\n * @internal\n */\nexport function isLocalDevelopment(): boolean {\n if (typeof window === 'undefined') return false\n const hostname = window.location?.hostname ?? ''\n return hostname === '' || LOCAL_HOSTNAME_PATTERN.test(hostname)\n}\n\n/** A DOM implementation that runs in Node for tests, or a browser driven by test automation. */\nfunction isTestEnvironment(): boolean {\n if (typeof navigator === 'undefined') return false\n return navigator.webdriver === true || TEST_DOM_USER_AGENT_PATTERN.test(navigator.userAgent ?? '')\n}\n\n/**\n * Error reporting runs in browsers, except on a local or development host and in test\n * environments: DOM implementations that run in Node and browsers driven by test automation. The\n * debug flag turns it on anywhere in a browser. It never runs outside a browser.\n *\n * @internal\n */\nexport function isErrorReportingEnabled(): boolean {\n if (typeof window === 'undefined') return false\n if (hasDebugFlag()) return true\n return !isLocalDevelopment() && !isTestEnvironment()\n}\n","import {ClientError, ConnectionFailedError, isTimeoutError, ServerError} from '@sanity/client'\n\nimport {MessageBusError} from '../dashboard/messageBus/bus'\nimport {TopicError} from '../dashboard/messageBus/topicStore'\nimport {DocumentInaccessibleError} from '../document/documentInaccessibleError'\nimport {ActionError} from '../document/processActions/shared'\nimport {PreferenceError} from '../preferences/preferenceError'\nimport {isNetworkFailure} from './isNetworkFailure'\n\nconst MAX_CAUSE_DEPTH = 5\n\n/**\n * Aborting a request on teardown is routine. Matched by name because `DOMException` and abort\n * errors from other libraries do not share a class.\n */\nfunction isAbortError(error: unknown): boolean {\n return error instanceof Error && error.name === 'AbortError'\n}\n\n/** Known errors that cannot be matched by class. */\nconst KNOWN_ERROR_CHECKS: ((error: unknown) => boolean)[] = [\n isTimeoutError,\n isAbortError,\n isNetworkFailure,\n]\n\nfunction isKnownErrorInstance(error: unknown): boolean {\n // Built per call so the classes are read after every module has finished loading\n const knownClasses = [\n ActionError,\n DocumentInaccessibleError,\n MessageBusError,\n PreferenceError,\n TopicError,\n // 4xx and 5xx responses from the Sanity API reflect the app's permissions, queries, or API\n // availability, not a defect in the SDK\n ClientError,\n ServerError,\n // The user is offline\n ConnectionFailedError,\n ]\n return (\n knownClasses.some((knownClass) => error instanceof knownClass) ||\n KNOWN_ERROR_CHECKS.some((check) => check(error))\n )\n}\n\n/**\n * Whether an error is an expected state caused by the app's configuration, the user's\n * permissions, the user's network, or the Sanity API, and so is not worth reporting as an SDK\n * bug. Wrapped errors are checked through their `cause` chain.\n *\n * @internal\n */\nexport function isKnownSdkError(error: unknown): boolean {\n let current = error\n for (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n if (isKnownErrorInstance(current)) return true\n if (!(current instanceof Error) || current.cause === undefined) return false\n current = current.cause\n }\n return false\n}\n","import {type BrowserOptions, type ErrorEvent} from './sentryTypes'\n\n/**\n * Key fragments Sentry denies when `sendDefaultPii` is left unset. The Sentry v11 migration guide\n * uses the same list for headers and query params.\n */\nconst PII_KEY_DENYLIST = ['forwarded', '-ip', 'remote-', 'via', '-user']\n\n/**\n * Turns off every automatic data category that can carry user or customer data. Matches the\n * posture Sanity Studio uses for its own Sentry client.\n *\n * `userInfo: false` also stops Relay from inferring the client IP.\n */\nexport const sdkSentryDataCollection = {\n userInfo: false,\n cookies: false,\n httpHeaders: {\n request: {deny: PII_KEY_DENYLIST},\n response: {deny: PII_KEY_DENYLIST},\n },\n httpBodies: [],\n urlQueryParams: {deny: PII_KEY_DENYLIST},\n genAI: {inputs: false, outputs: false},\n databaseQueryData: false,\n graphQL: {document: false, variables: false},\n queues: false,\n} satisfies NonNullable<BrowserOptions['dataCollection']>\n\nconst KEPT_TAGS = ['handled', 'delivery', 'errorBoundary']\n\n/**\n * Sentry `beforeSend` hook that rebuilds the event from an allowlist of fields. Sentry merges\n * the global and isolation scopes into every event, and when the host page runs the same Sentry\n * version those scopes are the host's: its tags, extras, breadcrumbs, and contexts would be\n * sent along with the SDK's error. Anything not listed here is dropped, and the zeroed IP stops\n * Sentry from filling one in from the connection. Exception messages and stack frames are kept\n * as they are.\n */\nexport function beforeSend(event: ErrorEvent): ErrorEvent {\n const tags: NonNullable<ErrorEvent['tags']> = {}\n for (const key of KEPT_TAGS) {\n const value = event.tags?.[key]\n if (value !== undefined) tags[key] = value\n }\n\n return {\n type: undefined,\n event_id: event.event_id,\n timestamp: event.timestamp,\n platform: event.platform,\n level: event.level,\n release: event.release,\n environment: event.environment,\n message: event.message,\n exception: event.exception,\n sdk: event.sdk,\n tags,\n user: {ip_address: '0.0.0.0'},\n }\n}\n","/**\n * Marks errors that leave SDK code, so the reporter can tell them apart from app errors when\n * the SDK is bundled into the app and stack frame URLs no longer name the SDK. `Symbol.for`\n * keeps the mark readable across two copies of the SDK on one page.\n */\nconst SDK_ORIGIN = Symbol.for('@sanity/sdk/errorOrigin')\n\n/**\n * Marks an error as thrown by SDK code. Errors already marked, and values that are not\n * `Error` instances, are left alone.\n *\n * @internal\n */\nexport function markSdkError(error: unknown): void {\n if (!(error instanceof Error) || Object.hasOwn(error, SDK_ORIGIN)) return\n try {\n Object.defineProperty(error, SDK_ORIGIN, {value: true})\n } catch {\n // A frozen error stays unmarked\n }\n}\n\n/**\n * Whether an error was marked by {@link markSdkError}.\n *\n * @internal\n */\nexport function isSdkError(error: unknown): boolean {\n return error instanceof Error && Object.hasOwn(error, SDK_ORIGIN)\n}\n\nconst MAX_CAUSE_DEPTH = 5\n\n/**\n * The first error marked by {@link markSdkError} in an error and its `cause` chain. An app that\n * catches an SDK error and throws its own error with the SDK error as `cause` still has an SDK\n * bug at the root.\n *\n * @internal\n */\nexport function findSdkErrorInChain(error: unknown): Error | undefined {\n let current = error\n try {\n for (let depth = 0; depth < MAX_CAUSE_DEPTH && current instanceof Error; depth++) {\n if (isSdkError(current)) return current\n current = current.cause\n }\n } catch {\n // A throwing `cause` getter ends the walk\n }\n return undefined\n}\n","import {version} from '../../package.json'\nimport {\n getSdkDelivery,\n hasDebugFlag,\n isErrorReportingEnabled,\n isLocalDevelopment,\n} from './isErrorReportingEnabled'\nimport {isKnownSdkError} from './isKnownSdkError'\nimport {beforeSend, sdkSentryDataCollection} from './privacy'\nimport {findSdkErrorInChain, isSdkError, markSdkError} from './sdkErrorOrigin'\nimport {\n type BrowserOptions,\n type ErrorEvent,\n type Event,\n type EventHint,\n type Scope,\n} from './sentryTypes'\n\n/**\n * The DSN of the SDK project in Sentry. It is a public ingest key, not a secret.\n */\nconst SDK_DSN = 'https://08e08ab0cbf33a49f7f5066597d5e374@sentry.sanity.io/4512347487666176'\n\n/**\n * Events go through the Sanity intake tunnel, which forwards them to Sentry. This avoids ad\n * blockers and customer CSP `connect-src` rules that block the Sentry ingest host.\n */\nconst SDK_TUNNEL = 'https://api.sanity.io/vX/intake/tracing'\n\n/** Most events a single page load may send. A render loop can throw thousands of errors. */\nconst MAX_EVENTS_PER_SESSION = 10\n\n/** Events with the same message inside this window are reported once. */\nconst DUPLICATE_WINDOW_MS = 5 * 60 * 1000\n\n/** Failed loads of the Sentry chunk allowed before the reporter gives up for the page load. */\nconst MAX_LOAD_FAILURES = 3\n\n/** @internal */\nexport interface ReportErrorInfo {\n /** The name of the error boundary that caught the error. */\n errorBoundary?: string\n}\n\n/** @internal */\nexport interface ErrorReporterOptions {\n /** Replaces the fetch transport, for tests. */\n transport?: BrowserOptions['transport']\n}\n\n/**\n * The value of the error that was thrown. When `linkedErrors` adds the causes, they come first\n * and the thrown error is last.\n */\nfunction getThrownValue(event: Event): string | undefined {\n return event.exception?.values?.at(-1)?.value ?? event.message\n}\n\n/**\n * Caps the events per session and drops repeats of the same message inside a time window. For an\n * app error that wraps an SDK error, the SDK error's message is the key, so app messages that\n * vary cannot spend the whole cap on one SDK bug.\n */\nfunction limitEventsIntegration() {\n const seen = new Map<string, number>()\n let sent = 0\n\n return {\n name: 'SdkLimitEvents',\n processEvent(event: Event, hint: EventHint): Event | null {\n if (sent >= MAX_EVENTS_PER_SESSION) return null\n\n const message =\n findSdkErrorInChain(hint.originalException)?.message ?? getThrownValue(event) ?? ''\n const now = Date.now()\n const previous = seen.get(message)\n if (previous !== undefined && now - previous < DUPLICATE_WINDOW_MS) return null\n\n seen.set(message, now)\n sent++\n return event\n },\n }\n}\n\n/**\n * Matches the SDK bundle served by the module server (`@sanity__sdk`, `@sanity__sdk-react`) and\n * the same packages under `node_modules` (`@sanity/sdk`, or `@sanity_sdk-react` in a Vite\n * dependency cache). The package name must end at a path separator or a file extension, so\n * `@sanity/sdk-other` does not match.\n */\nconst SDK_MODULE_PATTERN = /(?:@|%40)sanity(?:__|_|\\/|%2F)sdk(?:-react)?(?=[/.]|$)/\n\n/** This repo's own sources, which only show up in local development with the debug flag set. */\nconst SDK_SOURCE_PATTERN = /\\/packages\\/(?:core|react)\\/(?:src|dist)\\//\n\n/** Frame names the engine uses for code without a URL, such as `JSON.parse (<anonymous>)`. */\nconst BUILTIN_FRAME_PATTERN = /^(?:<.*>|native)$/\n\nfunction isSdkFilename(filename: string): boolean {\n return SDK_MODULE_PATTERN.test(filename) || (hasDebugFlag() && SDK_SOURCE_PATTERN.test(filename))\n}\n\n/**\n * The file of the innermost frame that has a URL. Builtins such as `JSON.parse` and `new URL`\n * sit on top of the stack when they throw, and the code that called them decides the owner.\n */\nfunction getThrowingFilename(event: Event): string | undefined {\n const frames = event.exception?.values?.at(-1)?.stacktrace?.frames ?? []\n for (let index = frames.length - 1; index >= 0; index--) {\n const filename = frames[index]?.filename\n if (filename && !BUILTIN_FRAME_PATTERN.test(filename)) return filename\n }\n return undefined\n}\n\n/**\n * Keeps only events thrown by SDK code. Error boundaries also catch errors thrown by the app\n * rendered beneath them, so ownership is decided in two ways. An error marked by an SDK hook, or\n * with a marked error in its cause chain, is the SDK's. Otherwise the frame that threw decides,\n * which works only when the SDK has its own URL, as with auto-updates or a dev server. Events\n * with neither a mark nor a usable frame are dropped.\n */\nfunction sdkOriginIntegration() {\n return {\n name: 'SdkOrigin',\n processEvent(event: Event, hint: EventHint): Event | null {\n if (findSdkErrorInChain(hint.originalException)) return event\n const filename = getThrowingFilename(event)\n return filename && isSdkFilename(filename) ? event : null\n },\n }\n}\n\n/**\n * Sentry marks every error it is given as already captured, and skips marked errors in every\n * Sentry client on the page. Capturing a copy keeps that mark off the app's own error objects.\n */\nfunction toCapturable(error: Error): Error {\n const copy = new Error(\n error.message,\n error.cause === undefined ? undefined : {cause: error.cause},\n )\n copy.name = error.name\n copy.stack = error.stack\n if (isSdkError(error)) markSdkError(copy)\n return copy\n}\n\nfunction getEnvironment(): string {\n return isLocalDevelopment() ? 'development' : 'production'\n}\n\n/**\n * Creates a reporter that sends unexpected SDK errors to Sentry. It owns its own Sentry client\n * and scope, and installs no global error handlers. Nothing is sent unless `reportError` is\n * called.\n *\n * @internal\n */\nexport function createErrorReporter(options: ErrorReporterOptions = {}): {\n reportError: (error: unknown, info?: ReportErrorInfo) => void\n} {\n let scopePromise: Promise<Scope> | undefined\n let loadFailures = 0\n\n function getScope(): Promise<Scope> {\n scopePromise ??= import('./sentryBrowser')\n .then((sentry) => {\n const client = new sentry.BrowserClient({\n dsn: SDK_DSN,\n tunnel: SDK_TUNNEL,\n // The published package version. `CORE_SDK_VERSION` reads `PKG_VERSION` from the app's\n // environment at runtime, which apps do not set, so it falls back to `<version>-development`\n release: version,\n environment: getEnvironment(),\n dataCollection: sdkSentryDataCollection,\n stackParser: sentry.defaultStackParser,\n transport: options.transport ?? sentry.makeFetchTransport,\n integrations: [\n sentry.linkedErrorsIntegration(),\n sdkOriginIntegration(),\n limitEventsIntegration(),\n ],\n beforeSend: (event: ErrorEvent) => beforeSend(event),\n })\n\n const scope = new sentry.Scope()\n scope.setClient(client)\n client.init()\n return scope\n })\n .catch((error: unknown) => {\n // Let the next report try again, for a chunk that failed to load while offline\n scopePromise = undefined\n loadFailures++\n throw error\n })\n return scopePromise\n }\n\n function reportError(error: unknown, info: ReportErrorInfo = {}): void {\n // This runs inside `componentDidCatch`, where a throw would reach the parent boundary\n try {\n // Sentry builds a synthetic stack for non-Error values, and that stack points into this\n // module, so such values would be attributed to the SDK\n if (\n !(error instanceof Error) ||\n loadFailures >= MAX_LOAD_FAILURES ||\n !isErrorReportingEnabled() ||\n isKnownSdkError(error)\n ) {\n return\n }\n\n const capturable = toCapturable(error)\n const {errorBoundary} = info\n const delivery = getSdkDelivery()\n const tags = errorBoundary\n ? {handled: 'no', delivery, errorBoundary}\n : {handled: 'no', delivery}\n\n getScope()\n .then((scope) => {\n scope.captureException(capturable, {\n mechanism: {handled: false, type: 'generic'},\n captureContext: {tags},\n })\n })\n .catch(() => {\n // Nothing to do. The reporter must not add errors to the app it reports for.\n })\n } catch {\n // Same: never throw into the caller\n }\n }\n\n return {reportError}\n}\n\n/**\n * Reports an unexpected error from the SDK to Sentry, when error reporting is enabled.\n *\n * @internal\n */\nexport const {reportError} = createErrorReporter()\n","import {FETCH_TIMEOUT_DEFAULT} from '@sanity/comlink'\nimport {DocumentId, isPublishedIdEqual} from '@sanity/id-utils'\nimport {catchError, defer, distinctUntilChanged, EMPTY, map, merge, type Observable} from 'rxjs'\n\nimport {requireDashboardMessageBus} from '../dashboard/messageBus/store'\nimport {type CapabilityRecord, type FavoriteDocument} from '../dashboard/messageBus/topics'\nimport {getTopicState, resolveTopic} from '../dashboard/messageBus/topicStore'\nimport {type SanityInstance} from '../store/createSanityInstance'\nimport {type StateSource} from '../store/createStateSourceAction'\nimport {defineMutation} from '../store/fetcherStore'\nimport {\n type FavoriteDocumentContext,\n favoriteScope,\n type FavoriteStatusResponse,\n type SetFavoriteInput,\n toFavoriteDocument,\n} from './favorites'\n\n// Published IDs mirror Dashboard's `_stableId` match.\nconst isSameFavorite = (\n a: FavoriteDocument['document'],\n b: FavoriteDocument['document'],\n): boolean =>\n a.type === b.type &&\n a.resource.id === b.resource.id &&\n a.resource.type === b.resource.type &&\n a.resource.schemaName === b.resource.schemaName &&\n isPublishedIdEqual(DocumentId(a.id), DocumentId(b.id))\n\n/**\n * A state source for whether a document is favorited, matched against the `favorites.documents`\n * the dashboard message bus host publishes. The message bus counterpart to the Comlink\n * {@link favorites} fetcher.\n *\n * @remarks\n * Returns `undefined` until the host publishes `applications.capabilities` and, while it provides\n * `favorites`, `favorites.documents`; use {@link resolveBusFavorite} to wait for them. Returns\n * `false` when the host does not provide `favorites` or the `favorites.documents` read fails.\n * A favorite is identified by its published document ID, type, resource and `schemaName`\n * (workspace), like in Dashboard.\n * @internal\n */\nexport function getBusFavoriteState(\n instance: SanityInstance,\n context: FavoriteDocumentContext,\n): StateSource<boolean | undefined> {\n const capabilities = getTopicState(instance, 'applications.capabilities')\n const documents = getTopicState(instance, 'favorites.documents')\n const target = toFavoriteDocument(context)\n\n const getCurrent = (): boolean | undefined => {\n const provided = capabilities.getCurrent() as CapabilityRecord | undefined\n if (provided === undefined) return undefined\n if (provided.favorites !== true) return false\n // A failed read degrades to \"not favorited\", like the Comlink fetcher.\n try {\n const favorites = documents.getCurrent() as FavoriteDocument[] | undefined\n return favorites?.some((favorite) => isSameFavorite(favorite.document, target))\n } catch {\n return false\n }\n }\n\n const subscribe = (onStoreChanged?: () => void) => {\n const unsubscribes = [\n capabilities.subscribe(onStoreChanged),\n documents.subscribe(onStoreChanged),\n ]\n return () => unsubscribes.forEach((unsubscribe) => unsubscribe())\n }\n\n const observable: Observable<boolean | undefined> = merge(\n capabilities.observable,\n documents.observable.pipe(catchError(() => EMPTY)),\n ).pipe(map(getCurrent), distinctUntilChanged())\n\n return {getCurrent, subscribe, observable}\n}\n\n/**\n * Resolves once {@link getBusFavoriteState} has the next value it waits for: the host's\n * capabilities first, then its `favorites.documents`.\n *\n * @internal\n */\nexport function resolveBusFavorite(instance: SanityInstance): Promise<void> {\n const capabilities = getTopicState(instance, 'applications.capabilities').getCurrent()\n return resolveTopic(\n instance,\n capabilities === undefined ? 'applications.capabilities' : 'favorites.documents',\n )\n}\n\n/**\n * Sets a document's favorite state over the dashboard message bus. The message bus counterpart\n * to `setFavorite`; the host keeps `favorites.documents` current, so there is no cache to\n * invalidate.\n *\n * @internal\n */\nexport const setBusFavorite = defineMutation<SetFavoriteInput, FavoriteStatusResponse>({\n name: 'setBusFavorite',\n scope: favoriteScope,\n mutationFn:\n (instance) =>\n ({isFavorited, ...context}) =>\n defer(() =>\n requireDashboardMessageBus(instance, 'update a favorite').emit(\n 'favorites.update',\n {document: toFavoriteDocument(context), favorited: isFavorited},\n // Matches the reply timeout of the Comlink write.\n {timeout: FETCH_TIMEOUT_DEFAULT},\n ),\n ).pipe(map(() => ({isFavorited}))),\n})\n","/**\n * The fields to check for a title.\n * The order of the items in the array defines the priority.\n *\n * @internal\n */\nexport const TITLE_CANDIDATES = ['title', 'name', 'label', 'heading', 'header', 'caption']\n\n/**\n * The fields to check for a subtitle.\n * The order of the items in the array defines the priority.\n *\n * @internal\n */\nexport const SUBTITLE_CANDIDATES = ['description', 'subtitle', ...TITLE_CANDIDATES]\n\n/**\n * Generates a GROQ projection for preview data without requiring a schema.\n * Uses common field names to make educated guesses about which fields to use.\n *\n * @internal\n */\nexport const PREVIEW_PROJECTION = `{\n // Get all potential title fields\n \"titleCandidates\": {\n ${TITLE_CANDIDATES.map((field) => `\"${field}\": ${field}`).join(',\\n ')}\n },\n // Get all potential subtitle fields\n \"subtitleCandidates\": {\n ${SUBTITLE_CANDIDATES.map((field) => `\"${field}\": ${field}`).join(',\\n ')}\n },\n \"media\": coalesce(\n select(\n defined(asset) => {\"type\": \"image-asset\", \"_ref\": asset._ref},\n defined(image.asset) => {\"type\": \"image-asset\", \"_ref\": image.asset._ref},\n defined(mainImage.asset) => {\"type\": \"image-asset\", \"_ref\": mainImage.asset._ref},\n null\n )\n ),\n _type,\n _id,\n _updatedAt\n}`\n","import {type SanityClient} from '@sanity/client'\nimport {createImageUrlBuilder} from '@sanity/image-url'\n\nimport {getClient} from '../client/clientStore'\nimport {type DocumentResource} from '../config/sanityConfig'\nimport {type SanityInstance} from '../store/createSanityInstance'\nimport {isObject} from '../utils/object'\nimport {SUBTITLE_CANDIDATES, TITLE_CANDIDATES} from './previewConstants'\nimport {type PreviewQueryResult, type PreviewValue} from './types'\n\nconst API_VERSION = 'v2025-05-06'\n\n/**\n * Checks if the provided value has `_ref` property that is a string and starts with `image-`\n */\nfunction hasImageRef<T>(value: unknown): value is T & {_ref: string} {\n return isObject(value) && '_ref' in value && typeof (value as {_ref: unknown})._ref === 'string'\n}\n\n/**\n * Normalizes a media asset to a preview value.\n * Adds a url to a media asset reference using `@sanity/image-url`.\n *\n * @internal\n */\nexport function normalizeMedia(media: unknown, client: SanityClient): PreviewValue['media'] {\n if (!media) return null\n if (!hasImageRef(media)) return null\n\n const builder = createImageUrlBuilder(client)\n const url = builder.image({_ref: media._ref}).url()\n\n return {\n type: 'image-asset',\n _ref: media._ref,\n url,\n }\n}\n\n/**\n * Finds a single field value from a set of candidates based on a priority list of field names.\n * Returns the first non-empty string value found from the candidates matching the priority list order.\n *\n * @internal\n */\nfunction findFirstDefined(\n fieldsToSearch: string[],\n candidates: Record<string, unknown>,\n exclude?: unknown,\n): string | undefined {\n if (!candidates) return undefined\n\n for (const field of fieldsToSearch) {\n const value = candidates[field]\n if (typeof value === 'string' && value.trim() !== '' && value !== exclude) {\n return value\n }\n }\n\n return undefined\n}\n\n/**\n * Transforms a projection result (with titleCandidates, subtitleCandidates, media)\n * into a PreviewValue (with title, subtitle, media).\n *\n * @param projectionResult - The raw projection result from GROQ\n * @param instance - The Sanity instance to use for client configuration\n * @param resource - Data resource for the preview\n * @internal\n */\nexport function transformProjectionToPreview(\n instance: SanityInstance,\n projectionResult: PreviewQueryResult,\n resource?: DocumentResource,\n): PreviewValue {\n const title = findFirstDefined(TITLE_CANDIDATES, projectionResult.titleCandidates)\n const subtitle = findFirstDefined(SUBTITLE_CANDIDATES, projectionResult.subtitleCandidates, title)\n\n // Get a client for the resource (if provided) or use the instance config\n const client = getClient(instance, {\n apiVersion: API_VERSION,\n resource,\n })\n\n return {\n title: String(title || `${projectionResult._type}: ${projectionResult._id}`),\n subtitle: subtitle || undefined,\n media: normalizeMedia(projectionResult.media, client),\n ...(projectionResult._status && {_status: projectionResult._status}),\n }\n}\n","/**\n * Telemetry environment classification.\n *\n * - `'development'` — the SDK is running on the local developer's machine\n * (`localhost` / `127.0.0.1` in the browser, or `NODE_ENV=development`\n * in Node). These are the original dev-only telemetry sessions.\n *\n * - `'production'` — the SDK is running on a production Sanity-controlled\n * domain (Studio deployments on `*.sanity.studio`, the dashboard on\n * `*.sanity.io`) where end users are authenticated Sanity users with\n * Populus consent records. Production telemetry is gated to this\n * allowlist; SDK apps deployed to customer-controlled domains do not\n * emit telemetry. Staging (`*.sanity.work`) and preview\n * (`*.sanity.dev`) hosts are deliberately excluded.\n *\n * @internal\n */\nexport type TelemetryEnvironment = 'development' | 'production'\n\n/**\n * Hostname suffixes that count as Sanity-controlled for the purposes of\n * production telemetry. A user reaching one of these hosts in the\n * browser is authenticated against Sanity and has a Populus consent\n * record, so we apply the same telemetry rules as the Studio's\n * `telemetry-sink`.\n *\n * The leading `.` is required: it ensures suffix matches hit a real\n * subdomain boundary, so apex matches (`sanity.io`, `sanity.studio`)\n * and lookalikes (`evilsanity.studio`) are excluded. Only production\n * hosts are listed; staging (`*.sanity.work`) and preview\n * (`*.sanity.dev`) hosts are excluded by omission.\n *\n * @internal\n */\nconst SANITY_CONTROLLED_HOST_SUFFIXES = ['.sanity.studio', '.sanity.io'] as const\n\nfunction getBrowserHostname(win: Window): string | null {\n const hostname = win.location?.hostname\n return typeof hostname === 'string' && hostname.length > 0 ? hostname.toLowerCase() : null\n}\n\nfunction isLocalHostname(hostname: string): boolean {\n return hostname === 'localhost' || hostname === '127.0.0.1'\n}\n\nfunction isSanityControlledHostname(hostname: string): boolean {\n return SANITY_CONTROLLED_HOST_SUFFIXES.some((suffix) => hostname.endsWith(suffix))\n}\n\n/**\n * Returns the telemetry environment for the current runtime, or `null`\n * when telemetry should not run at all.\n *\n * Browser:\n * - `localhost` / `127.0.0.1` → `'development'`\n * - host matches the Sanity-controlled allowlist → `'production'`\n * - anything else (customer domains, unknown contexts) → `null`\n *\n * Node (scripts, SSR, tests):\n * - `NODE_ENV=development` → `'development'`\n * - otherwise → `null`. Production-side server runtimes don't carry the\n * browser-authenticated user/consent assumption, so we don't enable\n * them under the production gate.\n *\n * Bracket-notation `process.env['NODE_ENV']` is used to avoid bundler\n * dead-code replacement.\n *\n * @internal\n */\nexport function getTelemetryEnvironment(): TelemetryEnvironment | null {\n if (typeof window !== 'undefined') {\n const hostname = getBrowserHostname(window)\n if (!hostname) return null\n if (isLocalHostname(hostname)) return 'development'\n if (isSanityControlledHostname(hostname)) return 'production'\n return null\n }\n\n if (typeof process !== 'undefined' && process.env?.['NODE_ENV'] === 'development') {\n return 'development'\n }\n return null\n}\n\n/**\n * Convenience predicate for \"telemetry can run in this environment\".\n *\n * @internal\n */\nexport function isTelemetryEnabled(): boolean {\n return getTelemetryEnvironment() !== null\n}\n","import {defineEvent} from '@sanity/telemetry'\n\n/**\n * Whether the instance has Studio configuration. Apps include Dashboard and standalone apps.\n * This describes instance configuration, not credential source or who authored a hook call.\n * @internal\n */\nexport type TelemetryRuntimeContext = 'studio' | 'app'\n\n// Keep attribution in event data to preserve the warehouse's data_auth_method convention.\ninterface TelemetryAttribution {\n /** Configured credential source (token/studio/default), distinct from getAuthMethodState's transport. */\n authMethod: string\n runtimeContext: TelemetryRuntimeContext\n}\n\n/** @internal */\nexport const SDKSessionStarted = defineEvent<\n TelemetryAttribution & {\n version: string\n projectId: string\n perspective: string\n }\n>({\n name: 'SDK Session Started',\n version: 1,\n description: 'SDK instance created (environment is recorded in the event context)',\n})\n\n/** @internal */\nexport const SDKHookMounted = defineEvent<\n TelemetryAttribution & {\n hookName: string\n }\n>({\n name: 'SDK Hook Mounted',\n version: 1,\n description: 'An SDK hook was mounted for the first time in this session',\n})\n\n/** @internal */\nexport const SDKSessionEnded = defineEvent<\n TelemetryAttribution & {\n durationSeconds: number\n hooksUsed: string[]\n }\n>({\n name: 'SDK Session Ended',\n version: 1,\n description: 'SDK instance disposed (environment is recorded in the event context)',\n})\n\n/** @internal */\nexport const SDKError = defineEvent<{\n errorType: string\n hookName: string\n}>({\n name: 'SDK Error',\n version: 1,\n description: 'Runtime error caught in the SDK',\n})\n","import {type SanityClient} from '@sanity/client'\nimport {\n type ConsentStatus,\n createBatchedStore,\n type SessionId,\n type TelemetryEvent,\n type TelemetryLogger,\n type TelemetryStore,\n} from '@sanity/telemetry'\n\nimport {createLogger} from '../utils/logger'\nimport {CORE_SDK_VERSION} from '../version'\nimport {type TelemetryEnvironment} from './environment'\nimport {\n SDKError,\n SDKHookMounted,\n SDKSessionEnded,\n SDKSessionStarted,\n type TelemetryRuntimeContext,\n} from './events'\n\nconst FLUSH_INTERVAL_MS = 30_000\nconst CONSENT_TAG = 'telemetry-consent.sdk'\nconst BATCH_TAG = 'telemetry.batch'\n\nconst log = createLogger('telemetry')\n\n/**\n * Manages telemetry for a single SDK instance.\n *\n * Wraps `@sanity/telemetry`'s batched store with SDK-specific concerns:\n * consent caching, session lifecycle events, and hook usage tracking.\n * The `environment` is captured at construction time and recorded in\n * the event context so downstream pipelines can distinguish dev and\n * production sessions.\n *\n * @internal\n */\nexport interface TelemetryManager {\n /**\n * Eagerly resolve and cache the user's consent status.\n * Returns true only when the user has explicitly opted in (`granted`).\n * Call this before logging any events to avoid buffering events that\n * will be dropped on the first flush.\n */\n checkConsent(): Promise<boolean>\n\n /** Log a \"SDK Session Started\" event */\n logSessionStarted(data: {projectId: string; perspective: string}): void\n\n /** Log a \"SDK Hook Mounted\" event (deduplicated per hook name) */\n logHookFirstUsed(hookName: string): void\n\n /** Log a \"SDK Error\" event */\n logError(errorType: string, hookName: string): void\n\n /** Log a \"SDK Session Ended\" event and tear down the store */\n endSession(): void\n\n /** Tear down the store without logging a session-end event */\n dispose(): void\n\n /** The set of hook names used during this session */\n readonly hooksUsed: ReadonlySet<string>\n}\n\ninterface TelemetryManagerOptions {\n sessionId: string\n getClient: () => SanityClient\n projectId: string\n environment: TelemetryEnvironment\n authMethod: string\n runtimeContext: TelemetryRuntimeContext\n}\n\n/**\n * Creates a telemetry manager for a single SDK instance session.\n *\n * The manager initializes a `createBatchedStore` from `@sanity/telemetry`,\n * caches the consent check for the lifetime of the session, and provides\n * typed methods for each SDK telemetry event.\n *\n * @internal\n */\nexport function createTelemetryManager(options: TelemetryManagerOptions): TelemetryManager {\n const {sessionId, getClient, projectId, environment, authMethod, runtimeContext} = options\n const startedAt = Date.now()\n const emittedHooks = new Set<string>()\n\n let cachedConsent: {status: ConsentStatus} | null = null\n\n const resolveConsent = async (): Promise<{status: ConsentStatus}> => {\n if (cachedConsent) return cachedConsent\n try {\n const client = getClient()\n const result = await client.request<{status: ConsentStatus}>({\n url: '/intake/telemetry-status',\n tag: CONSENT_TAG,\n })\n cachedConsent = result\n } catch {\n cachedConsent = {status: 'undetermined'}\n }\n return cachedConsent\n }\n\n const enrichBatch = (batch: TelemetryEvent[]) =>\n batch.map((event) => {\n // Trace events (`trace.start` / `trace.log` / `trace.error` /\n // `trace.complete`) arrive with their own caller-provided `context`.\n // Log / userProperties events don't. Narrow via `in` so `event`\n // stays typed as `TelemetryEvent`, then merge so we don't drop the\n // trace context. SDK-owned fields below win on conflict.\n const existing =\n 'context' in event ? (event.context as Record<string, unknown> | undefined) : undefined\n return {\n ...event,\n context: {\n ...existing,\n version: CORE_SDK_VERSION,\n environment,\n origin: typeof window !== 'undefined' ? window.location.origin : 'node',\n },\n }\n })\n\n const sendEvents = async (batch: TelemetryEvent[]): Promise<unknown> => {\n const client = getClient()\n log.debug('sending event batch', {batchSize: batch.length, environment})\n return client.request({\n url: '/intake/batch',\n method: 'POST',\n body: {projectId, batch: enrichBatch(batch)},\n tag: BATCH_TAG,\n })\n }\n\n const store: TelemetryStore<Record<string, unknown>> = createBatchedStore(\n sessionId as SessionId,\n {\n flushInterval: FLUSH_INTERVAL_MS,\n resolveConsent,\n sendEvents,\n },\n )\n\n const logger: TelemetryLogger<Record<string, unknown>> = store.logger\n\n return {\n async checkConsent() {\n const {status} = await resolveConsent()\n return status === 'granted'\n },\n\n logSessionStarted(data) {\n log.debug('event: SDK Session Started', {\n projectId: data.projectId,\n perspective: data.perspective,\n authMethod,\n runtimeContext,\n version: CORE_SDK_VERSION,\n environment,\n })\n logger.log(SDKSessionStarted, {\n version: CORE_SDK_VERSION,\n ...data,\n authMethod,\n runtimeContext,\n })\n },\n\n logHookFirstUsed(hookName: string) {\n if (emittedHooks.has(hookName)) return\n emittedHooks.add(hookName)\n log.debug('event: SDK Hook Mounted', {hookName, authMethod, runtimeContext})\n logger.log(SDKHookMounted, {hookName, authMethod, runtimeContext})\n },\n\n logError(errorType: string, hookName: string) {\n log.debug('event: SDK Error', {errorType, hookName})\n logger.log(SDKError, {errorType, hookName})\n },\n\n endSession() {\n const durationSeconds = Math.round((Date.now() - startedAt) / 1000)\n log.debug('event: SDK Session Ended', {\n durationSeconds,\n hooksUsed: [...emittedHooks],\n authMethod,\n runtimeContext,\n environment,\n })\n logger.log(SDKSessionEnded, {\n durationSeconds,\n hooksUsed: [...emittedHooks],\n authMethod,\n runtimeContext,\n })\n\n store.flush().catch(() => {\n // Best-effort flush on dispose; swallow errors\n })\n store.end()\n },\n\n dispose() {\n store.end()\n },\n\n get hooksUsed(): ReadonlySet<string> {\n return emittedHooks\n },\n }\n}\n","import {type SanityInstance} from '../store/createSanityInstance'\nimport {createLogger} from '../utils/logger'\nimport {getTelemetryEnvironment} from './environment'\nimport {type TelemetryManager} from './telemetryManager'\n\nconst DEFAULT_TELEMETRY_API_VERSION = '2024-11-12'\n\nconst logger = createLogger('telemetry')\n\n/**\n * Per-instance map of active telemetry managers. Allows the React\n * package (and other consumers) to look up the manager for a given\n * instance and log hook usage / errors without importing the full\n * telemetry module themselves.\n *\n * @internal\n */\nconst telemetryManagers = new WeakMap<SanityInstance, TelemetryManager>()\nconst pendingHooks = new WeakMap<SanityInstance, Set<string>>()\nconst initInFlight = new WeakSet<SanityInstance>()\n\n/**\n * Initializes telemetry for a SDK instance if the runtime environment\n * qualifies. The environment is resolved by `getTelemetryEnvironment()`:\n *\n * - `'development'` — local dev servers (`localhost` / `127.0.0.1`, or\n * Node with `NODE_ENV=development`). This is the original opt-in\n * surface.\n * - `'production'` — apps deployed to Sanity-controlled domains\n * (e.g. `*.sanity.studio`, the dashboard). End users are\n * authenticated Sanity users with Populus consent records, so we\n * apply the same consent gate as the Studio's `telemetry-sink`.\n *\n * Apps on customer-controlled domains return `null` and skip telemetry\n * entirely.\n *\n * `telemetryManager` and `clientStore` are dynamically imported so the\n * telemetry code path stays out of production bundles for apps that\n * don't qualify. Only the lightweight environment check runs at boot.\n *\n * The `projectId` must be passed explicitly because the resource\n * configuration is typically set by the React layer after the\n * instance has already been created.\n *\n * @internal\n */\nexport function initTelemetry(instance: SanityInstance, projectId: string): void {\n const environment = getTelemetryEnvironment()\n if (!environment) {\n logger.trace('initTelemetry skipped: environment not eligible', {internal: true})\n return\n }\n if (!projectId) {\n logger.trace('initTelemetry skipped: no projectId', {internal: true})\n return\n }\n if (telemetryManagers.has(instance) || initInFlight.has(instance)) {\n return\n }\n initInFlight.add(instance)\n\n logger.debug('initializing telemetry', {projectId, environment})\n\n Promise.all([\n import('./telemetryManager'),\n import('../client/clientStore'),\n import('../auth/authStore'),\n import('../auth/authMode'),\n ])\n .then(async ([{createTelemetryManager}, {getClient}, {getTokenState}, {isStudioConfig}]) => {\n if (instance.isDisposed()) {\n initInFlight.delete(instance)\n logger.debug('telemetry skipped: instance disposed before imports resolved')\n return\n }\n\n // Wait for the auth store to resolve a token. The client needs a\n // Bearer token for the consent check and batch POSTs. If the token\n // is already available (e.g. static token config), this resolves\n // immediately. For OAuth/localStorage discovery it waits for the\n // first emission. For unauthenticated apps the promise never\n // resolves, which is fine since telemetry requires auth anyway.\n const token = getTokenState(instance).getCurrent()\n logger.trace('auth token check', {tokenPresent: !!token, internal: true})\n\n if (!token) {\n logger.debug('waiting for auth token')\n const hasToken = await new Promise<boolean>((resolve) => {\n if (instance.isDisposed()) return resolve(false)\n const cleanup = {unsubscribe: () => {}}\n const unsub = instance.onDispose(() => {\n cleanup.unsubscribe()\n resolve(false)\n })\n // The token observable is a `shareReplay({bufferSize: 1, refCount: true})`\n // (see `createStateSourceAction`), so it can deliver a buffered value\n // synchronously while we're still inside `.subscribe(cb)`. At that\n // moment `sub` is in the TDZ, so the callback can't reach it. We\n // gate on a `received` flag and let the post-subscribe block do the\n // unsubscribe in the sync-emission case.\n let received = false\n const sub = getTokenState(instance).observable.subscribe((t) => {\n if (received || !t) return\n received = true\n logger.debug('auth token received')\n unsub()\n resolve(true)\n cleanup.unsubscribe()\n })\n cleanup.unsubscribe = () => sub.unsubscribe()\n if (received) cleanup.unsubscribe()\n })\n if (!hasToken || instance.isDisposed()) {\n initInFlight.delete(instance)\n logger.debug('telemetry skipped: no token resolved or instance disposed')\n return\n }\n }\n\n const config = instance.config\n const perspective = typeof config.perspective === 'string' ? config.perspective : 'published'\n // Studio instances can use explicit tokens. Keep runtime context independent of auth.\n const runtimeContext = isStudioConfig(config) ? 'studio' : 'app'\n const authMethod = config.auth?.token\n ? 'token'\n : config.studio?.auth?.token\n ? 'studio'\n : 'default'\n\n const manager = createTelemetryManager({\n sessionId: instance.instanceId,\n getClient: () => getClient(instance, {apiVersion: DEFAULT_TELEMETRY_API_VERSION}),\n projectId,\n environment,\n authMethod,\n runtimeContext,\n })\n\n const consented = await manager.checkConsent()\n logger.debug('consent check complete', {consented})\n if (!consented || instance.isDisposed()) {\n initInFlight.delete(instance)\n manager.dispose()\n return\n }\n\n initInFlight.delete(instance)\n telemetryManagers.set(instance, manager)\n\n const buffered = pendingHooks.get(instance)\n if (buffered) {\n logger.debug('flushing buffered hooks', {hooks: Array.from(buffered)})\n for (const hookName of buffered) {\n manager.logHookFirstUsed(hookName)\n }\n pendingHooks.delete(instance)\n }\n\n logger.info('telemetry session started', {\n projectId,\n perspective,\n authMethod,\n runtimeContext,\n environment,\n })\n manager.logSessionStarted({\n projectId,\n perspective,\n })\n\n instance.onDispose(() => {\n manager.endSession()\n telemetryManagers.delete(instance)\n logger.debug('telemetry session ended')\n })\n })\n .catch((err) => {\n initInFlight.delete(instance)\n logger.warn('telemetry init failed', {error: err})\n })\n}\n\n/**\n * Retrieves the telemetry manager for an instance, if one exists.\n * Returns undefined when telemetry is disabled or not yet initialized.\n *\n * @internal\n */\nexport function getTelemetryManager(instance: SanityInstance): TelemetryManager | undefined {\n return telemetryManagers.get(instance)\n}\n\n/**\n * Record a hook name for an instance. If the telemetry manager is\n * already initialized the event is logged immediately. Otherwise\n * the name is buffered and flushed when init completes.\n *\n * @internal\n */\nexport function trackHookMounted(instance: SanityInstance, hookName: string): void {\n if (!getTelemetryEnvironment()) return\n\n const manager = findManager(instance)\n if (manager) {\n logger.trace('hook mounted (logged)', {hookName, internal: true})\n manager.logHookFirstUsed(hookName)\n return\n }\n\n const root = getRootInstance(instance)\n let hooks = pendingHooks.get(root)\n if (!hooks) {\n hooks = new Set()\n pendingHooks.set(root, hooks)\n }\n if (!hooks.has(hookName)) {\n logger.trace('hook mounted (buffered)', {hookName, internal: true})\n }\n hooks.add(hookName)\n}\n\nfunction findManager(instance: SanityInstance): TelemetryManager | undefined {\n return telemetryManagers.get(instance)\n}\n\nfunction getRootInstance(instance: SanityInstance): SanityInstance {\n return instance\n}\n","const WILDCARD_TOKEN = '*'\nconst NEGATION_TOKEN = '-'\n// This regex handles simple cases including quoted phrases.\n// More complex query syntaxes might need a more robust parser.\nconst TOKEN_REGEX = /(?:[^\\s\"]+|\"[^\"]*\")+/g\n\n/**\n * @internal\n * Checks if a token starts with the negation character.\n */\nfunction isNegationToken(token: string | undefined): boolean {\n return typeof token !== 'undefined' && token.trim().startsWith(NEGATION_TOKEN)\n}\n\n/**\n * @internal\n * Checks if a token ends with the wildcard character.\n */\nfunction isPrefixToken(token: string | undefined): boolean {\n return typeof token !== 'undefined' && token.trim().endsWith(WILDCARD_TOKEN)\n}\n\n/**\n * @internal\n * Checks if a token is enclosed in double quotes.\n */\nfunction isExactMatchToken(token: string | undefined): boolean {\n // Ensure the token exists, has at least 2 characters, and starts/ends with \"\n return !!token && token.length >= 2 && token.startsWith('\"') && token.endsWith('\"')\n}\n\n/**\n * Creates a GROQ search filter string (`[@] match text::query(\"...\")`)\n * from a raw search query string.\n *\n * It applies wildcard ('*') logic to the last eligible token and escapes\n * backslashes and double quotes within the search term.\n *\n * If the input query is empty or only whitespace, it returns an empty string.\n *\n * @param query - The raw input search string.\n * @returns The GROQ search filter string, or an empty string.\n * @internal\n */\nexport function createGroqSearchFilter(query: string): string {\n // Trim leading/trailing whitespace from the overall query first\n const trimmedQuery = query.trim()\n if (!trimmedQuery) {\n return '' // Return empty if query is empty or just whitespace\n }\n\n // Extract tokens using the regex\n const tokens = trimmedQuery.match(TOKEN_REGEX) ?? []\n\n // Find the index of the last token eligible for wildcard appending\n const reversedTokens = [...tokens].reverse()\n const reversedIndex = reversedTokens.findIndex(\n (token: string) => !isNegationToken(token) && !isExactMatchToken(token),\n )\n const finalIncrementalTokenIndex = reversedIndex === -1 ? -1 : tokens.length - 1 - reversedIndex\n\n // Get the actual token based on the found index\n const finalIncrementalToken = tokens[finalIncrementalTokenIndex]\n\n const processedTokens = [...tokens]\n // If a suitable token was found and it doesn't already end with a wildcard,\n // apply the wildcard.\n if (finalIncrementalToken !== undefined && !isPrefixToken(finalIncrementalToken)) {\n // Replace the identified token with its wildcarded version\n processedTokens.splice(\n finalIncrementalTokenIndex,\n 1,\n `${finalIncrementalToken}${WILDCARD_TOKEN}`,\n )\n }\n\n // Join the tokens back into a space-separated string\n const wildcardSearch = processedTokens.join(' ')\n\n // Escape backslashes and double quotes within the final search term for the\n // GROQ query. Backslashes go first, so the escapes added for quotes are not\n // themselves escaped. Without this a trailing backslash would escape the\n // closing quote and let the input break out of the string literal.\n const escapedSearch = wildcardSearch.replace(/\\\\/g, '\\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AAK,CAAC,CAAC,SAAS,GAAc;AAC7E;;;;;AAMA,SAAS,kBAAkB,OAAoC;CAE7D,OAAO,CAAC,CAAC,SAAS,MAAM,UAAU,KAAK,MAAM,WAAW,IAAG,KAAK,MAAM,SAAS,IAAG;AACpF;;;;;;;;;;;;;;AAeA,SAAgB,uBAAuB,OAAuB;CAE5D,IAAM,eAAe,MAAM,KAAK;CAChC,IAAI,CAAC,cACH,OAAO;CAIT,IAAM,SAAS,aAAa,MAAM,WAAW,KAAK,CAAC,GAI7C,gBADiB,CAAC,GAAG,MAAM,CAAC,CAAC,QACA,CAAC,CAAC,WAClC,UAAkB,CAAC,gBAAgB,KAAK,KAAK,CAAC,kBAAkB,KAAK,CACxE,GACM,6BAA6B,kBAAkB,KAAK,KAAK,OAAO,SAAS,IAAI,eAG7E,wBAAwB,OAAO,6BAE/B,kBAAkB,CAAC,GAAG,MAAM;CAsBlC,OAnBI,0BAA0B,KAAA,KAAa,CAAC,cAAc,qBAAqB,KAE7E,gBAAgB,OACd,4BACA,GACA,GAAG,wBACL,GAaK,0BATgB,gBAAgB,KAAK,GAMT,CAAC,CAAC,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,MAG7B,EAAE;AACjD"}
@@ -3,8 +3,8 @@ import { a as getClientAuthState, b as retryOnCredentialChange, i as getAuthStat
3
3
  import { h as randomUuid, m as randomId } from "../topicStore-CKBdgAz7.js";
4
4
  import { r as omitProperty } from "../object-CxXlSVg7.js";
5
5
  import { r as getClientState } from "../clientStore-eysItBQl.js";
6
- import { t as toCommentFieldPath } from "../types-C8dSHL5E.js";
7
- import { a as compareProjectOrganization, o as observeAppOrganizationId, r as project, t as buildCommentThreads } from "../buildCommentThreads-YikCB5T5.js";
6
+ import { t as toCommentFieldPath } from "../commentFieldPath-DuhAgFcL.js";
7
+ import { a as compareProjectOrganization, o as observeAppOrganizationId, r as project, t as buildCommentThreads } from "../buildCommentThreads-aYpLzq0R.js";
8
8
  import "@sanity/client";
9
9
  import { EMPTY, NEVER, Observable, ReplaySubject, catchError, defer, distinctUntilChanged, filter, first, firstValueFrom, groupBy, map, merge, mergeMap, of, pairwise, partition, race, share, startWith, switchMap, take, tap, throwError } from "rxjs";
10
10
  import "@sanity/types";
@@ -1,3 +1,3 @@
1
- import { $r as PayloadOf, Gr as DocumentActivity, Hr as Capability, Ir as ApplicationActivity, Jr as FavoriteDocument, Kr as EventTopic, Lr as ApplicationConfig, Mr as TopicError, Qr as NavigationTarget, Rr as ApplicationConfigAppType, Ur as CapabilityRecord, Wr as DashboardTopics, Yr as LocalApplication, Zr as NavigationLocation, ai as TopicResult, ci as capabilities, ei as RemoteModuleRef, h as Dock, ii as TopicName, jr as TopicData, ni as StateTopic, oi as Topics, qr as EventTopicDef, ri as StateTopicDef, si as ValueOf, ti as ReplyOf, zr as ApplicationContext } from "../applications-D2hQr1jp.js";
2
- import { C as PanelView, D as WebWorker, E as ViewApplication, O as WindowView, S as AssetSourceView, T as View, _ as WebWorkerProps, a as MessageBusClient, c as MessageBusEmitResult, d as MessageBusErrorDetails, f as MessageBusHost, g as MessageBusStateSource, h as MessageBusQueryOptions, i as MessageBusAbortOptions, l as MessageBusError, m as MessageBusMeta, o as MessageBusConnection, p as MessageBusMessage, r as MessageBus, s as MessageBusEmitOptions, t as ConnectMessageBusOptions, u as MessageBusErrorCode, v as connectMessageBus, w as TileView } from "../bus-E7n57Ek8.js";
3
- export { type ApplicationActivity, type ApplicationConfig, type ApplicationConfigAppType, type ApplicationContext, type AssetSourceView, type Capability, type CapabilityRecord, type ConnectMessageBusOptions, type DashboardTopics, type Dock, type DocumentActivity, type EventTopic, type EventTopicDef, type FavoriteDocument, type LocalApplication, type MessageBus, type MessageBusAbortOptions, type MessageBusClient, type MessageBusConnection, type MessageBusEmitOptions, type MessageBusEmitResult, MessageBusError, type MessageBusErrorCode, type MessageBusErrorDetails, type MessageBusHost, type MessageBusMessage, type MessageBusMeta, type MessageBusQueryOptions, type MessageBusStateSource, type NavigationLocation, type NavigationTarget, type PanelView, type PayloadOf, type RemoteModuleRef, type ReplyOf, type StateTopic, type StateTopicDef, type TileView, type TopicData, TopicError, type TopicName, type TopicResult, type Topics, type ValueOf, type View, type ViewApplication, type WebWorker, type WebWorkerProps, type WindowView, capabilities, connectMessageBus };
1
+ import { $r as PayloadOf, Gr as DocumentActivity, Hr as Capability, Ir as ApplicationActivity, Jr as FavoriteDocument, Kr as EventTopic, Lr as ApplicationConfig, Mr as TopicError, Qr as NavigationTarget, Rr as ApplicationConfigAppType, Ur as CapabilityRecord, Wr as DashboardTopics, Yr as LocalApplication, Zr as NavigationLocation, ai as TopicResult, ci as capabilities, ei as RemoteModuleRef, h as Dock, ii as TopicName, jr as TopicData, ni as StateTopic, oi as Topics, qr as EventTopicDef, ri as StateTopicDef, si as ValueOf, ti as ReplyOf, zr as ApplicationContext } from "../applications-D8Y0DXJr.js";
2
+ import { A as ViewApplication, C as DashboardApplicationBase, D as PanelView, E as AssetSourceView, M as WindowView, O as TileView, S as DashboardApplication, _ as WebWorkerProps, a as MessageBusClient, c as MessageBusEmitResult, d as MessageBusErrorDetails, f as MessageBusHost, g as MessageBusStateSource, h as MessageBusQueryOptions, i as MessageBusAbortOptions, j as WebWorker, k as View, l as MessageBusError, m as MessageBusMeta, o as MessageBusConnection, p as MessageBusMessage, r as MessageBus, s as MessageBusEmitOptions, t as ConnectMessageBusOptions, u as MessageBusErrorCode, v as connectMessageBus, w as DashboardInstallation } from "../bus-kOUKH5RD.js";
3
+ export { type ApplicationActivity, type ApplicationConfig, type ApplicationConfigAppType, type ApplicationContext, type AssetSourceView, type Capability, type CapabilityRecord, type ConnectMessageBusOptions, type DashboardApplication, type DashboardApplicationBase, type DashboardInstallation, type DashboardTopics, type Dock, type DocumentActivity, type EventTopic, type EventTopicDef, type FavoriteDocument, type LocalApplication, type MessageBus, type MessageBusAbortOptions, type MessageBusClient, type MessageBusConnection, type MessageBusEmitOptions, type MessageBusEmitResult, MessageBusError, type MessageBusErrorCode, type MessageBusErrorDetails, type MessageBusHost, type MessageBusMessage, type MessageBusMeta, type MessageBusQueryOptions, type MessageBusStateSource, type NavigationLocation, type NavigationTarget, type PanelView, type PayloadOf, type RemoteModuleRef, type ReplyOf, type StateTopic, type StateTopicDef, type TileView, type TopicData, TopicError, type TopicName, type TopicResult, type Topics, type ValueOf, type View, type ViewApplication, type WebWorker, type WebWorkerProps, type WindowView, capabilities, connectMessageBus };