sanity 3.94.1-next.5.ec6157041e → 3.94.1
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.
- package/dist/BehaviorSubject-CU-WJrzA.mjs +30 -0
- package/dist/BehaviorSubject-CU-WJrzA.mjs.map +1 -0
- package/dist/BroadcastDisplayedDocument-BSV9T3BU.mjs +20 -0
- package/dist/BroadcastDisplayedDocument-BSV9T3BU.mjs.map +1 -0
- package/dist/DisplayedDocumentBroadcaster-DZ65n35Q.mjs +62 -0
- package/dist/DisplayedDocumentBroadcaster-DZ65n35Q.mjs.map +1 -0
- package/dist/LiveQueries-Crz53eU5.mjs +407 -0
- package/dist/LiveQueries-Crz53eU5.mjs.map +1 -0
- package/dist/Observable-CCQtH8Gg.mjs +546 -0
- package/dist/Observable-CCQtH8Gg.mjs.map +1 -0
- package/dist/PostMessageDocuments-BjgsJxz4.mjs +72 -0
- package/dist/PostMessageDocuments-BjgsJxz4.mjs.map +1 -0
- package/dist/PostMessagePerspective-pucY-E6a.mjs +22 -0
- package/dist/PostMessagePerspective-pucY-E6a.mjs.map +1 -0
- package/dist/PostMessagePreviewSnapshots-CRQgRg4_.mjs +71 -0
- package/dist/PostMessagePreviewSnapshots-CRQgRg4_.mjs.map +1 -0
- package/dist/PostMessageRefreshMutations-D944RbO3.mjs +66 -0
- package/dist/PostMessageRefreshMutations-D944RbO3.mjs.map +1 -0
- package/dist/PostMessageSchema-3eOtr1bs.mjs +516 -0
- package/dist/PostMessageSchema-3eOtr1bs.mjs.map +1 -0
- package/dist/PostMessageTelemetry-DMTQDJeN.mjs +20 -0
- package/dist/PostMessageTelemetry-DMTQDJeN.mjs.map +1 -0
- package/dist/PresentationToolGrantsCheck-B0q4AQ3b.mjs +3999 -0
- package/dist/PresentationToolGrantsCheck-B0q4AQ3b.mjs.map +1 -0
- package/dist/QRCodeSVG-hyTW2xeN.mjs +648 -0
- package/dist/QRCodeSVG-hyTW2xeN.mjs.map +1 -0
- package/dist/Refractor-Zss2QEe8.mjs +2568 -0
- package/dist/Refractor-Zss2QEe8.mjs.map +1 -0
- package/dist/SourceContext-QxJD1Wrm.mjs +111 -0
- package/dist/SourceContext-QxJD1Wrm.mjs.map +1 -0
- package/dist/StructureToolProvider-B-7cwz7l.mjs +2287 -0
- package/dist/StructureToolProvider-B-7cwz7l.mjs.map +1 -0
- package/dist/ViteDevServerStopped-CgIEqy9p.mjs +57 -0
- package/dist/ViteDevServerStopped-CgIEqy9p.mjs.map +1 -0
- package/dist/_createContext.mjs +38 -0
- package/dist/_createContext.mjs.map +1 -0
- package/dist/_singletons.mjs +216 -0
- package/dist/_singletons.mjs.map +1 -0
- package/dist/browser-B0Q9qZJS.mjs +478 -0
- package/dist/browser-B0Q9qZJS.mjs.map +1 -0
- package/dist/browser-DmX5VEcE.mjs +324 -0
- package/dist/browser-DmX5VEcE.mjs.map +1 -0
- package/dist/desk.mjs +53 -0
- package/dist/desk.mjs.map +1 -0
- package/dist/first-Cz545eV-.mjs +42 -0
- package/dist/first-Cz545eV-.mjs.map +1 -0
- package/dist/index-B2GCDfau.mjs +96 -0
- package/dist/index-B2GCDfau.mjs.map +1 -0
- package/dist/index-BRIelBPK.mjs +6946 -0
- package/dist/index-BRIelBPK.mjs.map +1 -0
- package/dist/index-BUB137yJ.mjs +144 -0
- package/dist/index-BUB137yJ.mjs.map +1 -0
- package/dist/index-C3PGPrdL.mjs +1192 -0
- package/dist/index-C3PGPrdL.mjs.map +1 -0
- package/dist/index-C9NvTy6s.mjs +319 -0
- package/dist/index-C9NvTy6s.mjs.map +1 -0
- package/dist/index-DCkQlgdi.mjs +4001 -0
- package/dist/index-DCkQlgdi.mjs.map +1 -0
- package/dist/index-DG-3plB0.mjs +71 -0
- package/dist/index-DG-3plB0.mjs.map +1 -0
- package/dist/index-RoxwhtVB.mjs +5600 -0
- package/dist/index-RoxwhtVB.mjs.map +1 -0
- package/dist/index-iMZR29eF.mjs +756 -0
- package/dist/index-iMZR29eF.mjs.map +1 -0
- package/dist/index-wVXq9rWS.mjs +244 -0
- package/dist/index-wVXq9rWS.mjs.map +1 -0
- package/dist/index.mjs +137385 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lodash-Vz5dH_Dm.mjs +3679 -0
- package/dist/lodash-Vz5dH_Dm.mjs.map +1 -0
- package/dist/pane-Bm_57XKB.mjs +5 -0
- package/dist/pane-Bm_57XKB.mjs.map +1 -0
- package/dist/pane-Dopl4BjD.mjs +5 -0
- package/dist/pane-Dopl4BjD.mjs.map +1 -0
- package/dist/presentation-DsIky7Cj.mjs +556 -0
- package/dist/presentation-DsIky7Cj.mjs.map +1 -0
- package/dist/presentation.mjs +10 -0
- package/dist/presentation.mjs.map +1 -0
- package/dist/publishReplay-PuJoYJpp.mjs +92 -0
- package/dist/publishReplay-PuJoYJpp.mjs.map +1 -0
- package/dist/refractor-Bg1S3YDK.mjs +26 -0
- package/dist/refractor-Bg1S3YDK.mjs.map +1 -0
- package/dist/resources-BQsCEzu1.mjs +60 -0
- package/dist/resources-BQsCEzu1.mjs.map +1 -0
- package/dist/resources-BahMtJuO.mjs +177 -0
- package/dist/resources-BahMtJuO.mjs.map +1 -0
- package/dist/resources-CjkBN4z6.mjs +126 -0
- package/dist/resources-CjkBN4z6.mjs.map +1 -0
- package/dist/resources-Dc-6ZcPg.mjs +157 -0
- package/dist/resources-Dc-6ZcPg.mjs.map +1 -0
- package/dist/resources-DqxSuDsr.mjs +37 -0
- package/dist/resources-DqxSuDsr.mjs.map +1 -0
- package/dist/resources-_gTjFWLH.mjs +517 -0
- package/dist/resources-_gTjFWLH.mjs.map +1 -0
- package/dist/resources-kA1bao30.mjs +358 -0
- package/dist/resources-kA1bao30.mjs.map +1 -0
- package/dist/router.mjs +721 -0
- package/dist/router.mjs.map +1 -0
- package/dist/stegaEncodeSourceMap-DCG9Ba1H.mjs +358 -0
- package/dist/stegaEncodeSourceMap-DCG9Ba1H.mjs.map +1 -0
- package/dist/structure.mjs +57 -0
- package/dist/structure.mjs.map +1 -0
- package/dist/structureTool-Bth1vd8r.mjs +13150 -0
- package/dist/structureTool-Bth1vd8r.mjs.map +1 -0
- package/dist/switchMap-DHVUskpL.mjs +54 -0
- package/dist/switchMap-DHVUskpL.mjs.map +1 -0
- package/dist/v4-zH-CAum7.mjs +24798 -0
- package/dist/v4-zH-CAum7.mjs.map +1 -0
- package/dist/version-DoE_JnhG.mjs +5 -0
- package/dist/version-DoE_JnhG.mjs.map +1 -0
- package/lib/_chunks-cjs/version.js +1 -1
- package/lib/_chunks-es/version.mjs +1 -1
- package/package.json +23 -23
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"StructureToolProvider-B-7cwz7l.mjs","sources":["../src/structure/i18n/index.ts","../src/structure/structureBuilder/util/getExtendedProjection.ts","../src/structure/structureBuilder/SerializeError.ts","../src/structure/structureBuilder/Sort.ts","../src/structure/structureBuilder/MenuItem.ts","../src/structure/structureBuilder/MenuItemGroup.ts","../src/structure/structureBuilder/util/validateId.ts","../src/structure/structureBuilder/util/getStructureNodeId.ts","../src/structure/structureBuilder/Component.ts","../src/structure/structureBuilder/Divider.ts","../src/structure/structureBuilder/util/resolveTypeForDocument.ts","../src/structure/structureBuilder/views/View.ts","../src/structure/structureBuilder/views/ComponentView.ts","../src/structure/structureBuilder/views/FormView.ts","../src/structure/structureBuilder/views/index.ts","../src/structure/structureBuilder/Document.ts","../src/structure/structureBuilder/InitialValueTemplateItem.ts","../src/structure/structureBuilder/Intent.ts","../src/structure/structureBuilder/Layout.ts","../src/structure/structureBuilder/GenericList.ts","../src/structure/structureBuilder/DocumentList.ts","../src/structure/structureBuilder/List.ts","../src/structure/structureBuilder/ListItem.ts","../src/structure/structureBuilder/DocumentListItem.ts","../src/structure/structureBuilder/DocumentTypeList.ts","../src/structure/structureBuilder/documentTypeListItems.ts","../src/structure/structureBuilder/createStructureBuilder.ts","../src/structure/StructureToolProvider.tsx"],"sourcesContent":["import {defineLocaleResourceBundle} from 'sanity'\n\n/**\n * The locale namespace for the structure tool\n *\n * @public\n */\nexport const structureLocaleNamespace = 'structure' as const\n\n/**\n * The default locale bundle for the structure tool, which is US English.\n *\n * @internal\n */\nexport const structureUsEnglishLocaleBundle = defineLocaleResourceBundle({\n locale: 'en-US',\n namespace: structureLocaleNamespace,\n resources: () => import('./resources'),\n})\n\n/**\n * The locale resource keys for the structure tool.\n *\n * @alpha\n * @hidden\n */\nexport type {StructureLocaleResourceKeys} from './resources'\n","import {type SchemaType, type SortOrderingItem} from '@sanity/types'\n\nconst IMPLICIT_SCHEMA_TYPE_FIELDS = ['_id', '_type', '_createdAt', '_updatedAt', '_rev']\n\n// Takes a path array and a schema type and builds a GROQ join every time it enters a reference field\nfunction joinReferences(schemaType: SchemaType, path: string[], strict: boolean = false): string {\n const [head, ...tail] = path\n\n if (!('fields' in schemaType)) {\n return ''\n }\n\n const schemaField = schemaType.fields.find((field) => field.name === head)\n if (!schemaField) {\n if (!IMPLICIT_SCHEMA_TYPE_FIELDS.includes(head)) {\n const errorMessage = `The current ordering config targeted the nonexistent field \"${head}\" on schema type \"${schemaType.name}\". It should be one of ${schemaType.fields.map((field) => field.name).join(', ')}`\n if (strict) {\n throw new Error(errorMessage)\n } else {\n // eslint-disable-next-line no-console\n console.warn(errorMessage)\n }\n }\n return ''\n }\n\n if ('to' in schemaField.type && schemaField.type.name === 'reference') {\n const refTypes = schemaField.type.to\n return `${head}->{${refTypes.map((refType) => joinReferences(refType, tail)).join(',')}}`\n }\n\n const tailFields = tail.length > 0 && joinReferences(schemaField.type, tail)\n const tailWrapper = tailFields ? `{${tailFields}}` : ''\n return tail.length > 0 ? `${head}${tailWrapper}` : head\n}\n\nexport function getExtendedProjection(\n schemaType: SchemaType,\n orderBy: SortOrderingItem[],\n strict: boolean = false,\n): string {\n return orderBy\n .map((ordering) => joinReferences(schemaType, ordering.field.split('.'), strict))\n .join(', ')\n}\n","import {type SerializePath} from './StructureNodes'\n\n/** @internal */\nexport class SerializeError extends Error {\n public readonly path: SerializePath\n public helpId?: HELP_URL\n\n constructor(\n message: string,\n parentPath: SerializePath,\n pathSegment: string | number | undefined,\n hint?: string,\n ) {\n super(message)\n this.name = 'SerializeError'\n const segment = typeof pathSegment === 'undefined' ? '<unknown>' : `${pathSegment}`\n this.path = (parentPath || []).concat(hint ? `${segment} (${hint})` : segment)\n }\n\n withHelpUrl(id: HELP_URL): SerializeError {\n this.helpId = id\n return this\n }\n}\n\n/** @internal */\nexport enum HELP_URL {\n ID_REQUIRED = 'structure-node-id-required',\n TITLE_REQUIRED = 'structure-title-required',\n FILTER_REQUIRED = 'structure-filter-required',\n INVALID_LIST_ITEM = 'structure-invalid-list-item',\n COMPONENT_REQUIRED = 'structure-view-component-required',\n DOCUMENT_ID_REQUIRED = 'structure-document-id-required',\n DOCUMENT_TYPE_REQUIRED = 'structure-document-type-required',\n SCHEMA_TYPE_REQUIRED = 'structure-schema-type-required',\n SCHEMA_TYPE_NOT_FOUND = 'structure-schema-type-not-found',\n LIST_ITEMS_MUST_BE_ARRAY = 'structure-list-items-must-be-array',\n QUERY_PROVIDED_FOR_FILTER = 'structure-query-provided-for-filter',\n ACTION_OR_INTENT_REQUIRED = 'structure-action-or-intent-required',\n LIST_ITEM_IDS_MUST_BE_UNIQUE = 'structure-list-item-ids-must-be-unique',\n ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE = 'structure-action-and-intent-mutually-exclusive',\n API_VERSION_REQUIRED_FOR_CUSTOM_FILTER = 'structure-api-version-required-for-custom-filter',\n}\n","import {type SortOrdering} from '@sanity/types'\n\nimport {structureLocaleNamespace} from '../i18n'\n\nexport const ORDER_BY_UPDATED_AT: SortOrdering = {\n title: 'Last edited',\n i18n: {\n title: {\n key: 'menu-items.sort-by.last-edited',\n ns: structureLocaleNamespace,\n },\n },\n name: 'lastEditedDesc',\n by: [{field: '_updatedAt', direction: 'desc'}],\n}\n\nexport const ORDER_BY_CREATED_AT: SortOrdering = {\n title: 'Created',\n i18n: {\n title: {\n key: 'menu-items.sort-by.created',\n ns: structureLocaleNamespace,\n },\n },\n name: 'lastCreatedDesc',\n by: [{field: '_createdAt', direction: 'desc'}],\n}\n\nexport const DEFAULT_SELECTED_ORDERING_OPTION = ORDER_BY_UPDATED_AT\n\nexport const DEFAULT_ORDERING_OPTIONS: SortOrdering[] = [\n ORDER_BY_UPDATED_AT, // _updatedAt\n ORDER_BY_CREATED_AT, // _createdAt\n]\n","import {SortIcon} from '@sanity/icons'\nimport {type SchemaType, type SortOrdering, type SortOrderingItem} from '@sanity/types'\nimport {type I18nTextRecord} from 'sanity'\n\nimport {type Intent} from './Intent'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {DEFAULT_ORDERING_OPTIONS} from './Sort'\nimport {type Serializable, type SerializeOptions, type SerializePath} from './StructureNodes'\nimport {type StructureContext} from './types'\nimport {getExtendedProjection} from './util/getExtendedProjection'\n\n/** @internal */\nexport function maybeSerializeMenuItem(\n item: MenuItem | MenuItemBuilder,\n index: number,\n path: SerializePath,\n): MenuItem {\n return item instanceof MenuItemBuilder ? item.serialize({path, index}) : item\n}\n\n/**\n * Menu item action type\n * @public */\nexport type MenuItemActionType =\n | string\n | ((params: Record<string, string> | undefined, scope?: any) => void)\n\n/**\n * Menu items parameters\n *\n * @public */\nexport type MenuItemParamsType = Record<string, string | unknown | undefined>\n\n/**\n * Interface for menu items\n *\n * @public */\nexport interface MenuItem {\n /**\n * The i18n key and namespace used to populate the localized title. This is\n * the recommend way to set the title if you are localizing your studio.\n */\n i18n?: I18nTextRecord<'title'>\n /**\n * Menu Item title. Note that the `i18n` configuration will take\n * precedence and this title is left here as a fallback if no i18n key is\n * provided and compatibility with older plugins\n */\n title: string\n /** Menu Item action */\n action?: MenuItemActionType\n /** Menu Item intent */\n intent?: Intent\n /** Menu Item group */\n group?: string\n // TODO: align these with TemplateItem['icon']\n /** Menu Item icon */\n icon?: React.ComponentType | React.ReactNode\n /** Menu Item parameters. See {@link MenuItemParamsType} */\n params?: MenuItemParamsType\n /** Determine if it will show the MenuItem as action */\n showAsAction?: boolean\n}\n\n/**\n * Partial menu items\n * @public\n */\nexport type PartialMenuItem = Partial<MenuItem>\n\n/**\n * Class for building menu items.\n *\n * @public */\nexport class MenuItemBuilder implements Serializable<MenuItem> {\n /** menu item option object. See {@link PartialMenuItem} */\n protected spec: PartialMenuItem\n\n constructor(\n /**\n * Structure context. See {@link StructureContext}\n */\n protected _context: StructureContext,\n spec?: MenuItem,\n ) {\n this.spec = spec ? spec : {}\n }\n\n /**\n * Set menu item action\n * @param action - menu item action. See {@link MenuItemActionType}\n * @returns menu item builder based on action provided. See {@link MenuItemBuilder}\n */\n action(action: MenuItemActionType): MenuItemBuilder {\n return this.clone({action})\n }\n\n /**\n * Get menu item action\n * @returns menu item builder action. See {@link PartialMenuItem}\n */\n getAction(): PartialMenuItem['action'] {\n return this.spec.action\n }\n\n /**\n * Set menu item intent\n * @param intent - menu item intent. See {@link Intent}\n * @returns menu item builder based on intent provided. See {@link MenuItemBuilder}\n */\n intent(intent: Intent): MenuItemBuilder {\n return this.clone({intent})\n }\n\n /**\n * Get menu item intent\n * @returns menu item intent. See {@link PartialMenuItem}\n */\n getIntent(): PartialMenuItem['intent'] {\n return this.spec.intent\n }\n\n /**\n * Set menu item title\n * @param title - menu item title\n * @returns menu item builder based on title provided. See {@link MenuItemBuilder}\n */\n title(title: string): MenuItemBuilder {\n return this.clone({title})\n }\n\n /**\n * Get menu item title. Note that the `i18n` configuration will take\n * precedence and this title is left here for compatibility.\n * @returns menu item title\n */\n getTitle(): string | undefined {\n return this.spec.title\n }\n\n /**\n * Set the i18n key and namespace used to populate the localized title.\n * @param i18n - object with i18n key and related namespace\n * @returns menu item builder based on i18n config provided. See {@link MenuItemBuilder}\n */\n i18n(i18n: I18nTextRecord<'title'>): MenuItemBuilder {\n return this.clone({i18n})\n }\n\n /**\n * Get the i18n key and namespace used to populate the localized title.\n * @returns the i18n key and namespace used to populate the localized title.\n */\n getI18n(): I18nTextRecord<'title'> | undefined {\n return this.spec.i18n\n }\n\n /**\n * Set menu item group\n * @param group - menu item group\n * @returns menu item builder based on group provided. See {@link MenuItemBuilder}\n */\n group(group: string): MenuItemBuilder {\n return this.clone({group})\n }\n\n /**\n * Get menu item group\n * @returns menu item group. See {@link PartialMenuItem}\n */\n getGroup(): PartialMenuItem['group'] {\n return this.spec.group\n }\n\n /**\n * Set menu item icon\n * @param icon - menu item icon\n * @returns menu item builder based on icon provided. See {@link MenuItemBuilder}\n */\n icon(icon: React.ComponentType | React.ReactNode): MenuItemBuilder {\n return this.clone({icon})\n }\n\n /**\n * Get menu item icon\n * @returns menu item icon. See {@link PartialMenuItem}\n */\n getIcon(): PartialMenuItem['icon'] {\n return this.spec.icon\n }\n\n /**\n * Set menu item parameters\n * @param params - menu item parameters. See {@link MenuItemParamsType}\n * @returns menu item builder based on parameters provided. See {@link MenuItemBuilder}\n */\n params(params: MenuItemParamsType): MenuItemBuilder {\n return this.clone({params})\n }\n\n /**\n * Get meny item parameters\n * @returns menu item parameters. See {@link PartialMenuItem}\n */\n getParams(): PartialMenuItem['params'] {\n return this.spec.params\n }\n\n /**\n * Set menu item to show as action\n * @param showAsAction - determine if menu item should show as action\n * @returns menu item builder based on if it should show as action. See {@link MenuItemBuilder}\n */\n showAsAction(showAsAction = true): MenuItemBuilder {\n return this.clone({showAsAction: Boolean(showAsAction)})\n }\n\n /**\n * Check if menu item should show as action\n * @returns true if menu item should show as action, false if not. See {@link PartialMenuItem}\n */\n getShowAsAction(): PartialMenuItem['showAsAction'] {\n return this.spec.showAsAction\n }\n\n /** Serialize menu item builder\n * @param options - serialization options. See {@link SerializeOptions}\n * @returns menu item node based on path provided in options. See {@link MenuItem}\n */\n serialize(options: SerializeOptions = {path: []}): MenuItem {\n const {title, action, intent} = this.spec\n if (!title) {\n const hint = typeof action === 'string' ? `action: \"${action}\"` : undefined\n throw new SerializeError(\n '`title` is required for menu item',\n options.path,\n options.index,\n hint,\n ).withHelpUrl(HELP_URL.TITLE_REQUIRED)\n }\n\n if (!action && !intent) {\n throw new SerializeError(\n `\\`action\\` or \\`intent\\` required for menu item with title ${this.spec.title}`,\n options.path,\n options.index,\n `\"${title}\"`,\n ).withHelpUrl(HELP_URL.ACTION_OR_INTENT_REQUIRED)\n }\n\n if (intent && action) {\n throw new SerializeError(\n 'cannot set both `action` AND `intent`',\n options.path,\n options.index,\n `\"${title}\"`,\n ).withHelpUrl(HELP_URL.ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE)\n }\n\n return {...this.spec, title}\n }\n\n /** Clone menu item builder\n * @param withSpec - menu item options. See {@link PartialMenuItem}\n * @returns menu item builder based on context and spec provided. See {@link MenuItemBuilder}\n */\n clone(withSpec?: PartialMenuItem): MenuItemBuilder {\n const builder = new MenuItemBuilder(this._context)\n builder.spec = {...this.spec, ...withSpec}\n return builder\n }\n}\n\n/** @internal */\nexport interface SortMenuItem extends MenuItem {\n params: {\n by: SortOrderingItem[]\n }\n}\n\n/** @internal */\nexport function getOrderingMenuItem(\n context: StructureContext,\n {by, title, i18n}: SortOrdering,\n extendedProjection?: string,\n): MenuItemBuilder {\n let builder = new MenuItemBuilder(context)\n .group('sorting')\n .title(\n context.i18n.t('default-menu-item.fallback-title', {\n // note this lives in the `studio` bundle because that one is loaded by default\n ns: 'studio',\n replace: {title}, // replaces the `{{title}}` option\n }),\n ) // fallback title\n .icon(SortIcon)\n .action('setSortOrder')\n .params({by, extendedProjection})\n\n if (i18n) {\n builder = builder.i18n(i18n)\n }\n\n return builder\n}\n\n/** @internal */\nexport function getOrderingMenuItemsForSchemaType(\n context: StructureContext,\n typeName: SchemaType | string,\n): MenuItemBuilder[] {\n const {schema} = context\n const type = typeof typeName === 'string' ? schema.get(typeName) : typeName\n if (!type || !('orderings' in type)) {\n return []\n }\n\n return (\n type.orderings ? type.orderings.concat(DEFAULT_ORDERING_OPTIONS) : DEFAULT_ORDERING_OPTIONS\n ).map((ordering: SortOrdering) =>\n getOrderingMenuItem(context, ordering, getExtendedProjection(type, ordering.by)),\n )\n}\n","import {type I18nTextRecord} from 'sanity'\n\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {type Serializable, type SerializeOptions, type SerializePath} from './StructureNodes'\nimport {type StructureContext} from './types'\n\n/** @internal */\nexport function maybeSerializeMenuItemGroup(\n item: MenuItemGroup | MenuItemGroupBuilder,\n index: number,\n path: SerializePath,\n): MenuItemGroup {\n return item instanceof MenuItemGroupBuilder ? item.serialize({path, index}) : item\n}\n\n/**\n * Interface for menu item groups\n * @public\n */\nexport interface MenuItemGroup {\n /** Menu group Id */\n id: string\n /** Menu group title */\n title: string\n i18n?: I18nTextRecord<'title'>\n}\n\n/**\n * Class for building menu item groups.\n *\n * @public\n */\nexport class MenuItemGroupBuilder implements Serializable<MenuItemGroup> {\n /** Menu item group ID */\n protected _id: string\n /** Menu item group title */\n protected _title: string\n\n protected _i18n?: I18nTextRecord<'title'>\n\n constructor(\n /**\n * Structure context. See {@link StructureContext}\n */\n protected _context: StructureContext,\n spec?: MenuItemGroup,\n ) {\n this._id = spec ? spec.id : ''\n this._title = spec ? spec.title : ''\n this._i18n = spec ? spec.i18n : undefined\n }\n\n /**\n * Set menu item group ID\n * @param id - menu item group ID\n * @returns menu item group builder based on ID provided. See {@link MenuItemGroupBuilder}\n */\n id(id: string): MenuItemGroupBuilder {\n return new MenuItemGroupBuilder(this._context, {id, title: this._title, i18n: this._i18n})\n }\n\n /**\n * Get menu item group ID\n * @returns menu item group ID\n */\n getId(): string {\n return this._id\n }\n\n /**\n * Set menu item group title\n * @param title - menu item group title\n * @returns menu item group builder based on title provided. See {@link MenuItemGroupBuilder}\n */\n title(title: string): MenuItemGroupBuilder {\n return new MenuItemGroupBuilder(this._context, {title, id: this._id, i18n: this._i18n})\n }\n\n /**\n * Get menu item group title\n * @returns menu item group title\n */\n getTitle(): string {\n return this._title\n }\n\n /**\n * Set the i18n key and namespace used to populate the localized title.\n * @param i18n - object with i18n key and related namespace\n * @returns menu item group builder based on i18n info provided. See {@link MenuItemGroupBuilder}\n */\n i18n(i18n: I18nTextRecord<'title'>): MenuItemGroupBuilder {\n return new MenuItemGroupBuilder(this._context, {i18n, id: this._id, title: this._title})\n }\n\n /**\n * Get the i18n key and namespace used to populate the localized title.\n * @returns the i18n key and namespace used to populate the localized title.\n */\n getI18n(): I18nTextRecord<'title'> | undefined {\n return this._i18n\n }\n\n /**\n * Serialize menu item group builder\n * @param options - serialization options (path). See {@link SerializeOptions}\n * @returns menu item group based on path provided in options. See {@link MenuItemGroup}\n */\n serialize(options: SerializeOptions = {path: []}): MenuItemGroup {\n const {_id, _title, _i18n} = this\n if (!_id) {\n throw new SerializeError(\n '`id` is required for a menu item group',\n options.path,\n options.index,\n _title,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n if (!_title) {\n throw new SerializeError(\n '`title` is required for a menu item group',\n options.path,\n _id,\n ).withHelpUrl(HELP_URL.TITLE_REQUIRED)\n }\n\n return {\n id: _id,\n title: _title,\n i18n: _i18n,\n }\n }\n}\n","import {SerializeError} from '../SerializeError'\nimport {type SerializePath} from '../StructureNodes'\n\nexport const disallowedPattern = /([^A-Za-z0-9-_.])/\n\nexport function validateId(\n id: string,\n parentPath: SerializePath,\n pathSegment: string | number | undefined,\n): string {\n if (typeof id !== 'string') {\n throw new SerializeError(\n `Structure node id must be of type string, got ${typeof id}`,\n parentPath,\n pathSegment,\n )\n }\n\n const [disallowedChar] = id.match(disallowedPattern) || []\n if (disallowedChar) {\n throw new SerializeError(\n `Structure node id cannot contain character \"${disallowedChar}\"`,\n parentPath,\n pathSegment,\n )\n }\n\n if (id.startsWith('__edit__')) {\n throw new SerializeError(\n `Structure node id cannot start with __edit__`,\n parentPath,\n pathSegment,\n )\n }\n\n return id\n}\n","import {camelCase} from 'lodash'\nimport getSlug from 'speakingurl'\n\nimport {disallowedPattern} from './validateId'\n\nexport function getStructureNodeId(title: string, id?: string): string {\n if (id) {\n return id\n }\n\n const camelCased = camelCase(title)\n\n return disallowedPattern.test(camelCased) ? camelCase(getSlug(title)) : camelCased\n}\n","import {type I18nTextRecord} from 'sanity'\n\nimport {type IntentChecker} from './Intent'\nimport {maybeSerializeMenuItem, type MenuItem, type MenuItemBuilder} from './MenuItem'\nimport {\n maybeSerializeMenuItemGroup,\n type MenuItemGroup,\n type MenuItemGroupBuilder,\n} from './MenuItemGroup'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {\n type Child,\n type Serializable,\n type SerializeOptions,\n type StructureNode,\n} from './StructureNodes'\nimport {type UserComponent} from './types'\nimport {getStructureNodeId} from './util/getStructureNodeId'\nimport {validateId} from './util/validateId'\n\n/**\n * Interface for component\n *\n * @public\n */\n// TODO: rename to `StructureComponent` since it clashes with React?\nexport interface Component extends StructureNode {\n /** Component of type {@link UserComponent} */\n component: UserComponent\n /** Component child of type {@link Child} */\n child?: Child\n /** Component menu items, array of type {@link MenuItem} */\n menuItems: MenuItem[]\n /** Component menu item group, array of type {@link MenuItemGroup} */\n menuItemGroups: MenuItemGroup[]\n /** Component options */\n options: {[key: string]: unknown}\n canHandleIntent?: IntentChecker\n}\n\n/**\n * Interface for component input\n *\n * @public\n */\nexport interface ComponentInput extends StructureNode {\n /** Component of type {@link UserComponent} */\n component: UserComponent\n /** Component child of type {@link Child} */\n child?: Child\n /** Component options */\n options?: {[key: string]: unknown}\n /** Component menu items. See {@link MenuItem} and {@link MenuItemBuilder} */\n menuItems?: (MenuItem | MenuItemBuilder)[]\n /** Component menu item groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */\n menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[]\n}\n\n/**\n * Interface for buildable component\n *\n * @public\n */\nexport interface BuildableComponent extends Partial<StructureNode> {\n /** Component of type {@link UserComponent} */\n component?: UserComponent\n /** Component child of type {@link Child} */\n child?: Child\n /** Component options */\n options?: {[key: string]: unknown}\n /** Component menu items. See {@link MenuItem} and {@link MenuItemBuilder} */\n menuItems?: (MenuItem | MenuItemBuilder)[]\n /** Component menu item groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */\n menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[]\n canHandleIntent?: IntentChecker\n}\n\n/**\n * Class for building components\n *\n * @public\n */\nexport class ComponentBuilder implements Serializable<Component> {\n /** component builder option object */\n protected spec: BuildableComponent\n\n constructor(spec?: ComponentInput) {\n this.spec = {options: {}, ...(spec ? spec : {})}\n }\n\n /** Set Component ID\n * @param id - component ID\n * @returns component builder based on ID provided\n */\n id(id: string): ComponentBuilder {\n return this.clone({id})\n }\n\n /** Get ID\n * @returns ID\n */\n getId(): BuildableComponent['id'] {\n return this.spec.id\n }\n\n /** Set Component title\n * @param title - component title\n * @returns component builder based on title provided (and ID)\n */\n title(title: string): ComponentBuilder {\n return this.clone({title, id: getStructureNodeId(title, this.spec.id)})\n }\n\n /** Get Component title\n * @returns title\n */\n getTitle(): BuildableComponent['title'] {\n return this.spec.title\n }\n\n /** Set the i18n key and namespace used to populate the localized title.\n * @param i18n - the key and namespaced used to populate the localized title.\n * @returns component builder based on i18n key and ns provided\n */\n i18n(i18n: I18nTextRecord<'title'>): ComponentBuilder {\n return this.clone({i18n})\n }\n\n /** Get i18n key and namespace used to populate the localized title\n * @returns the i18n key and namespace used to populate the localized title\n */\n getI18n(): I18nTextRecord<'title'> | undefined {\n return this.spec.i18n\n }\n\n /** Set Component child\n * @param child - child component\n * @returns component builder based on child component provided\n */\n child(child: Child): ComponentBuilder {\n return this.clone({child})\n }\n\n /** Get Component child\n * @returns child component\n */\n getChild(): BuildableComponent['child'] {\n return this.spec.child\n }\n\n /** Set component\n * @param component - user built component\n * @returns component builder based on component provided\n */\n component(component: UserComponent): ComponentBuilder {\n return this.clone({component})\n }\n\n /** Get Component\n * @returns component\n */\n getComponent(): BuildableComponent['component'] {\n return this.spec.component\n }\n\n /** Set Component options\n * @param options - component options\n * @returns component builder based on options provided\n */\n options(options: {[key: string]: unknown}): ComponentBuilder {\n return this.clone({options})\n }\n\n /** Get Component options\n * @returns component options\n */\n getOptions(): NonNullable<BuildableComponent['options']> {\n return this.spec.options || {}\n }\n\n /** Set Component menu items\n * @param menuItems - component menu items\n * @returns component builder based on menuItems provided\n */\n menuItems(menuItems: (MenuItem | MenuItemBuilder)[]): ComponentBuilder {\n return this.clone({menuItems})\n }\n\n /** Get Component menu items\n * @returns menu items\n */\n getMenuItems(): BuildableComponent['menuItems'] {\n return this.spec.menuItems\n }\n\n /** Set Component menu item groups\n * @param menuItemGroups - component menu item groups\n * @returns component builder based on menuItemGroups provided\n */\n menuItemGroups(menuItemGroups: (MenuItemGroup | MenuItemGroupBuilder)[]): ComponentBuilder {\n return this.clone({menuItemGroups})\n }\n\n /** Get Component menu item groups\n * @returns menu item groups\n */\n getMenuItemGroups(): BuildableComponent['menuItemGroups'] {\n return this.spec.menuItemGroups\n }\n\n canHandleIntent(canHandleIntent: IntentChecker): ComponentBuilder {\n return this.clone({canHandleIntent})\n }\n\n /** Serialize component\n * @param options - serialization options\n * @returns component object based on path provided in options\n *\n */\n serialize(options: SerializeOptions = {path: []}): Component {\n const {id, title, child, options: componentOptions, component} = this.spec\n if (!id) {\n throw new SerializeError(\n '`id` is required for `component` structure item',\n options.path,\n options.index,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n if (!component) {\n throw new SerializeError(\n '`component` is required for `component` structure item',\n options.path,\n options.index,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n return {\n id: validateId(id, options.path, options.index),\n title,\n type: 'component',\n child,\n component,\n canHandleIntent: this.spec.canHandleIntent,\n options: componentOptions || {},\n menuItems: (this.spec.menuItems || []).map((item, i) =>\n maybeSerializeMenuItem(item, i, options.path),\n ),\n menuItemGroups: (this.spec.menuItemGroups || []).map((item, i) =>\n maybeSerializeMenuItemGroup(item, i, options.path),\n ),\n }\n }\n\n /** Clone component builder (allows for options overriding)\n * @param withSpec - component builder options\n * @returns cloned builder\n */\n clone(withSpec?: BuildableComponent): ComponentBuilder {\n const builder = new ComponentBuilder()\n builder.spec = {...this.spec, ...withSpec}\n return builder\n }\n}\n","import {uniqueId} from 'lodash'\nimport {type I18nTextRecord} from 'sanity'\n\nimport {type Divider, type Serializable} from './StructureNodes'\n\nexport class DividerBuilder implements Serializable<Divider> {\n protected spec: Divider\n\n constructor(spec?: Divider) {\n this.spec = {\n id: uniqueId('__divider__'),\n type: 'divider',\n ...spec,\n }\n }\n\n /** Set the title of the divider\n * @param title - the title of the divider\n * @returns divider builder based on title provided\n */\n title(title: string): DividerBuilder {\n return this.clone({\n title,\n })\n }\n\n /** Get the title of the divider\n * @returns the title of the divider\n */\n getTitle(): Divider['title'] {\n return this.spec.title\n }\n\n /** Set the i18n key and namespace used to populate the localized title.\n * @param i18n - the key and namespaced used to populate the localized title.\n * @returns divider builder based on i18n key and ns provided\n */\n i18n(i18n: I18nTextRecord<'title'>): DividerBuilder {\n return this.clone({\n i18n,\n })\n }\n\n /** Get i18n key and namespace used to populate the localized title\n * @returns the i18n key and namespace used to populate the localized title\n */\n getI18n(): I18nTextRecord<'title'> | undefined {\n return this.spec.i18n\n }\n\n /** Serialize the divider\n * @returns the serialized divider\n */\n serialize(): Divider {\n return {...this.spec}\n }\n\n /** Clone divider builder (allows for options overriding)\n * @param withSpec - divider builder options\n * @returns cloned builder\n */\n clone(withSpec?: Partial<Divider>): DividerBuilder {\n const builder = new DividerBuilder()\n builder.spec = {...this.spec, ...withSpec}\n return builder\n }\n}\n","import {type SanityClient} from '@sanity/client'\nimport {DEFAULT_STUDIO_CLIENT_OPTIONS, getPublishedId, type SourceClientOptions} from 'sanity'\n\nexport async function resolveTypeForDocument(\n getClient: (options: SourceClientOptions) => SanityClient,\n id: string,\n): Promise<string | undefined> {\n const query = '*[sanity::versionOf($publishedId)][0]._type'\n\n const type = await getClient(DEFAULT_STUDIO_CLIENT_OPTIONS).fetch(\n query,\n {publishedId: getPublishedId(id)},\n {tag: 'structure.resolve-type'},\n )\n\n return type\n}\n","import {kebabCase} from 'lodash'\n\nimport {HELP_URL, SerializeError} from '../SerializeError'\nimport {type Serializable, type SerializeOptions, type SerializePath} from '../StructureNodes'\nimport {type View} from '../types'\nimport {validateId} from '../util/validateId'\nimport {type ComponentViewBuilder} from './ComponentView'\nimport {type FormViewBuilder} from './FormView'\n\n/**\n * Interface for base view\n *\n * @public */\nexport interface BaseView {\n /** View id */\n id: string\n /** View Title */\n title: string\n /** View Icon */\n icon?: React.ComponentType | React.ReactNode\n}\n\n/**\n * Class for building generic views.\n *\n * @public\n */\nexport abstract class GenericViewBuilder<TView extends Partial<BaseView>, ConcreteImpl>\n implements Serializable<BaseView>\n{\n /** Generic view option object */\n protected spec: TView = {} as TView\n\n /** Set generic view ID\n * @param id - generic view ID\n * @returns generic view builder based on ID provided.\n */\n id(id: string): ConcreteImpl {\n return this.clone({id})\n }\n /** Get generic view ID\n * @returns generic view ID\n */\n getId(): TView['id'] {\n return this.spec.id\n }\n\n /** Set generic view title\n * @param title - generic view title\n * @returns generic view builder based on title provided and (if provided) its ID.\n */\n title(title: string): ConcreteImpl {\n return this.clone({title, id: this.spec.id || kebabCase(title)})\n }\n\n /** Get generic view title\n * @returns generic view title\n */\n getTitle(): TView['title'] {\n return this.spec.title\n }\n\n /** Set generic view icon\n * @param icon - generic view icon\n * @returns generic view builder based on icon provided.\n */\n icon(icon: React.ComponentType | React.ReactNode): ConcreteImpl {\n return this.clone({icon})\n }\n\n /** Get generic view icon\n * @returns generic view icon\n */\n getIcon(): TView['icon'] {\n return this.spec.icon\n }\n\n /** Serialize generic view\n * @param options - serialization options. See {@link SerializeOptions}\n * @returns generic view object based on path provided in options. See {@link BaseView}\n */\n serialize(options: SerializeOptions = {path: []}): BaseView {\n const {id, title, icon} = this.spec\n if (!id) {\n throw new SerializeError(\n '`id` is required for view item',\n options.path,\n options.index,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n if (!title) {\n throw new SerializeError(\n '`title` is required for view item',\n options.path,\n options.index,\n ).withHelpUrl(HELP_URL.TITLE_REQUIRED)\n }\n\n return {\n id: validateId(id, options.path, options.index),\n title,\n icon,\n }\n }\n\n /** Clone generic view builder (allows for options overriding)\n * @param withSpec - Partial generic view builder options. See {@link BaseView}\n * @returns Generic view builder.\n */\n abstract clone(withSpec?: Partial<BaseView>): ConcreteImpl\n}\n\nfunction isSerializable(view: BaseView | Serializable<BaseView>): view is Serializable<BaseView> {\n return typeof (view as Serializable<BaseView>).serialize === 'function'\n}\n\n/** @internal */\nexport function maybeSerializeView(\n item: View | Serializable<View>,\n index: number,\n path: SerializePath,\n): View {\n return isSerializable(item) ? item.serialize({path, index}) : item\n}\n\n/**\n * View builder. See {@link ComponentViewBuilder} and {@link FormViewBuilder}\n *\n * @public\n */\nexport type ViewBuilder = ComponentViewBuilder | FormViewBuilder\n","import {isRecord} from 'sanity'\n\nimport {HELP_URL, SerializeError} from '../SerializeError'\nimport {type SerializeOptions} from '../StructureNodes'\nimport {type UserViewComponent} from '../types'\nimport {type BaseView, GenericViewBuilder} from './View'\n\n/**\n * Interface for component views.\n *\n * @public */\nexport interface ComponentView<TOptions = Record<string, any>> extends BaseView {\n type: 'component'\n /** Component view components. See {@link UserViewComponent} */\n component: UserViewComponent\n /** Component view options */\n options: TOptions\n}\n\nconst isComponentSpec = (spec: unknown): spec is ComponentView =>\n isRecord(spec) && spec.type === 'component'\n\n/**\n * Class for building a component view.\n *\n * @public */\nexport class ComponentViewBuilder extends GenericViewBuilder<\n Partial<ComponentView>,\n ComponentViewBuilder\n> {\n /** Partial Component view option object. See {@link ComponentView} */\n protected spec: Partial<ComponentView>\n\n constructor(\n /**\n * Component view component or spec\n * @param componentOrSpec - user view component or partial component view. See {@link UserViewComponent} and {@link ComponentView}\n */\n componentOrSpec?: UserViewComponent | Partial<ComponentView>,\n ) {\n const spec = isComponentSpec(componentOrSpec) ? {...componentOrSpec} : {options: {}}\n\n super()\n this.spec = spec\n\n const userComponent =\n typeof componentOrSpec === 'function' ? componentOrSpec : this.spec.component\n\n if (userComponent) {\n // Because we're cloning, this'll return a new instance, so grab the spec from it\n this.spec = this.component(userComponent).spec\n }\n }\n\n /** Set view Component\n * @param component - component view component. See {@link UserViewComponent}\n * @returns component view builder based on component view provided. See {@link ComponentViewBuilder}\n */\n component(component: UserViewComponent): ComponentViewBuilder {\n return this.clone({component})\n }\n\n /** Get view Component\n * @returns Partial component view. See {@link ComponentView}\n */\n getComponent(): Partial<ComponentView>['component'] {\n return this.spec.component\n }\n\n /** Set view Component options\n * @param options - component view options\n * @returns component view builder based on options provided. See {@link ComponentViewBuilder}\n */\n options(options: {[key: string]: any}): ComponentViewBuilder {\n return this.clone({options})\n }\n\n /** Get view Component options\n * @returns component view options. See {@link ComponentView}\n */\n getOptions(): ComponentView['options'] {\n return this.spec.options || {}\n }\n\n /** Serialize view Component\n * @param options - serialization options. See {@link SerializeOptions}\n * @returns component view based on path provided in options. See {@link ComponentView}\n *\n */\n serialize(options: SerializeOptions = {path: []}): ComponentView {\n const base = super.serialize(options)\n\n const component = this.spec.component\n if (typeof component !== 'function') {\n throw new SerializeError(\n '`component` is required and must be a function for `component()` view item',\n options.path,\n options.index,\n ).withHelpUrl(HELP_URL.COMPONENT_REQUIRED)\n }\n\n return {\n ...base,\n component,\n options: this.spec.options || {},\n type: 'component',\n }\n }\n\n /** Clone Component view builder (allows for options overriding)\n * @param withSpec - partial for component view option. See {@link ComponentView}\n * @returns component view builder. See {@link ComponentViewBuilder}\n */\n clone(withSpec?: Partial<ComponentView>): ComponentViewBuilder {\n const builder = new ComponentViewBuilder()\n builder.spec = {...this.spec, ...withSpec}\n return builder\n }\n}\n","import {type SerializeOptions} from '../StructureNodes'\nimport {type BaseView, GenericViewBuilder} from './View'\n\n/**\n * Interface for form views.\n *\n * @public */\nexport interface FormView extends BaseView {\n type: 'form'\n}\n\n/**\n * Class for building a form view.\n *\n * @public */\nexport class FormViewBuilder extends GenericViewBuilder<Partial<BaseView>, FormViewBuilder> {\n /** Document list options. See {@link FormView} */\n protected spec: Partial<FormView>\n\n constructor(spec?: Partial<FormView>) {\n super()\n this.spec = {id: 'editor', title: 'Editor', ...(spec ? spec : {})}\n }\n\n /**\n * Serialize Form view builder\n * @param options - Serialize options. See {@link SerializeOptions}\n * @returns form view builder based on path provided in options. See {@link FormView}\n */\n serialize(options: SerializeOptions = {path: []}): FormView {\n return {\n ...super.serialize(options),\n type: 'form',\n }\n }\n\n /**\n * Clone Form view builder (allows for options overriding)\n * @param withSpec - Partial form view builder options. See {@link FormView}\n * @returns form view builder. See {@link FormViewBuilder}\n */\n clone(withSpec?: Partial<FormView>): FormViewBuilder {\n const builder = new FormViewBuilder()\n builder.spec = {...this.spec, ...withSpec}\n return builder\n }\n}\n","import {type UserViewComponent} from '../types'\nimport {type ComponentView, ComponentViewBuilder} from './ComponentView'\nimport {type FormView, FormViewBuilder} from './FormView'\n\nexport * from './ComponentView'\nexport * from './FormView'\nexport * from './View'\n\n/** @internal */\nexport const form = (spec?: Partial<FormView>): FormViewBuilder => new FormViewBuilder(spec)\n\n/** @internal */\nexport const component = (\n componentOrSpec?: UserViewComponent | Partial<ComponentView>,\n): ComponentViewBuilder => new ComponentViewBuilder(componentOrSpec)\n","import {type SchemaType} from '@sanity/types'\nimport {uniq} from 'lodash'\nimport {type I18nTextRecord} from 'sanity'\n\nimport {type ChildResolver} from './ChildResolver'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {\n type Child,\n type DocumentNode,\n type EditorNode,\n type Serializable,\n type SerializeOptions,\n} from './StructureNodes'\nimport {type StructureContext, type View} from './types'\nimport {getStructureNodeId} from './util/getStructureNodeId'\nimport {resolveTypeForDocument} from './util/resolveTypeForDocument'\nimport {validateId} from './util/validateId'\nimport {form} from './views'\nimport {maybeSerializeView, type ViewBuilder} from './views/View'\n\nconst createDocumentChildResolver =\n ({resolveDocumentNode, getClient}: StructureContext): ChildResolver =>\n async (itemId, {params, path}) => {\n let type = params.type\n\n const parentPath = path.slice(0, path.length - 1)\n const currentSegment = path[path.length - 1]\n\n if (!type) {\n type = await resolveTypeForDocument(getClient, itemId)\n }\n\n if (!type) {\n throw new SerializeError(\n `Failed to resolve document, and no type provided in parameters.`,\n parentPath,\n currentSegment,\n )\n }\n\n return resolveDocumentNode({documentId: itemId, schemaType: type})\n }\n\n/**\n * Interface for options of Partial Documents. See {@link PartialDocumentNode}\n *\n * @public */\nexport interface DocumentOptions {\n /** Document Id */\n id: string\n /** Document Type */\n type: string\n /** Document Template */\n template?: string\n /** Template parameters */\n templateParameters?: Record<string, unknown>\n}\n\n/**\n * Interface for partial document (focused on the document pane)\n *\n * @public */\nexport interface PartialDocumentNode {\n /** Document Id */\n id?: string\n /** Document title */\n title?: string\n /** I18n key and namespace used to populate the localized title */\n i18n?: I18nTextRecord<'title'>\n /** Document children of type {@link Child} */\n child?: Child\n /**\n * Views for the document pane. See {@link ViewBuilder} and {@link View}\n */\n views?: (View | ViewBuilder)[]\n /**\n * Document options. See {@link DocumentOptions}\n */\n options?: Partial<DocumentOptions>\n}\n\n/**\n * A `DocumentBuilder` is used to build a document node.\n *\n * @public */\nexport class DocumentBuilder implements Serializable<DocumentNode> {\n /** Component builder option object See {@link PartialDocumentNode} */\n protected spec: PartialDocumentNode\n\n constructor(\n /**\n * Structure context. See {@link StructureContext}\n */\n protected _context: StructureContext,\n spec?: PartialDocumentNode,\n ) {\n this.spec = spec ? spec : {}\n }\n\n /** Set Document Builder ID\n * @param id - document builder ID\n * @returns document builder based on ID provided. See {@link DocumentBuilder}\n */\n id(id: string): DocumentBuilder {\n return this.clone({id})\n }\n\n /** Get Document Builder ID\n * @returns document ID. See {@link PartialDocumentNode}\n */\n getId(): PartialDocumentNode['id'] {\n return this.spec.id\n }\n\n /** Set Document title\n * @param title - document title\n * @returns document builder based on title provided (and ID). See {@link DocumentBuilder}\n */\n title(title: string): DocumentBuilder {\n return this.clone({title, id: getStructureNodeId(title, this.spec.id)})\n }\n\n /** Get Document title\n * @returns document title. See {@link PartialDocumentNode}\n */\n getTitle(): PartialDocumentNode['title'] {\n return this.spec.title\n }\n\n /** Set the i18n key and namespace used to populate the localized title.\n * @param i18n - the key and namespaced used to populate the localized title.\n * @returns component builder based on i18n key and ns provided\n */\n i18n(i18n: I18nTextRecord<'title'>): DocumentBuilder {\n return this.clone({i18n})\n }\n\n /** Get i18n key and namespace used to populate the localized title\n * @returns the i18n key and namespace used to populate the localized title\n */\n getI18n(): I18nTextRecord<'title'> | undefined {\n return this.spec.i18n\n }\n\n /** Set Document child\n * @param child - document child\n * @returns document builder based on child provided. See {@link DocumentBuilder}\n */\n child(child: Child): DocumentBuilder {\n return this.clone({child})\n }\n\n /** Get Document child\n * @returns document child. See {@link PartialDocumentNode}\n */\n getChild(): PartialDocumentNode['child'] {\n return this.spec.child\n }\n\n /** Set Document ID\n * @param documentId - document ID\n * @returns document builder with document based on ID provided. See {@link DocumentBuilder}\n */\n documentId(documentId: string): DocumentBuilder {\n // Let's try to be a bit helpful and assign an ID from document ID if none is specified\n const paneId = this.spec.id || documentId\n return this.clone({\n id: paneId,\n options: {\n ...this.spec.options,\n id: documentId,\n },\n })\n }\n\n /** Get Document ID\n * @returns document ID. See {@link DocumentOptions}\n */\n getDocumentId(): Partial<DocumentOptions>['id'] {\n return this.spec.options?.id\n }\n\n /** Set Document Type\n * @param documentType - document type\n * @returns document builder with document based on type provided. See {@link DocumentBuilder}\n */\n schemaType(documentType: SchemaType | string): DocumentBuilder {\n return this.clone({\n options: {\n ...this.spec.options,\n type: typeof documentType === 'string' ? documentType : documentType.name,\n },\n })\n }\n\n /** Get Document Type\n * @returns document type. See {@link DocumentOptions}\n */\n getSchemaType(): Partial<DocumentOptions>['type'] {\n return this.spec.options?.type\n }\n\n /** Set Document Template\n * @param templateId - document template ID\n * @param parameters - document template parameters\n * @returns document builder with document based on template provided. See {@link DocumentBuilder}\n */\n initialValueTemplate(templateId: string, parameters?: Record<string, unknown>): DocumentBuilder {\n return this.clone({\n options: {\n ...this.spec.options,\n template: templateId,\n templateParameters: parameters,\n },\n })\n }\n\n /** Get Document Template\n * @returns document template. See {@link DocumentOptions}\n */\n getInitialValueTemplate(): Partial<DocumentOptions>['template'] {\n return this.spec.options?.template\n }\n\n /** Get Document's initial value Template parameters\n * @returns document template parameters. See {@link DocumentOptions}\n */\n getInitialValueTemplateParameters(): Partial<DocumentOptions>['templateParameters'] {\n return this.spec.options?.templateParameters\n }\n\n /** Set Document views\n * @param views - document views. See {@link ViewBuilder} and {@link View}\n * @returns document builder with document based on views provided. See {@link DocumentBuilder}\n */\n views(views: (View | ViewBuilder)[]): DocumentBuilder {\n return this.clone({views})\n }\n\n /** Get Document views\n * @returns document views. See {@link ViewBuilder} and {@link View}\n */\n getViews(): (View | ViewBuilder)[] {\n return this.spec.views || []\n }\n\n /** Serialize Document builder\n * @param options - serialization options. See {@link SerializeOptions}\n * @returns document node based on path, index and hint provided in options. See {@link DocumentNode}\n */\n serialize({path = [], index, hint}: SerializeOptions = {path: []}): DocumentNode {\n const urlId = path[index || path.length - 1]\n\n // Try to grab document ID / editor ID from URL if not defined\n const id = this.spec.id || (urlId && `${urlId}`) || ''\n const options: Partial<DocumentOptions> = {\n id,\n type: undefined,\n template: undefined,\n templateParameters: undefined,\n ...this.spec.options,\n }\n\n if (typeof id !== 'string' || !id) {\n throw new SerializeError(\n '`id` is required for document nodes',\n path,\n index,\n hint,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n if (!options || !options.id) {\n throw new SerializeError(\n 'document id (`id`) is required for document nodes',\n path,\n id,\n hint,\n ).withHelpUrl(HELP_URL.DOCUMENT_ID_REQUIRED)\n }\n\n if (!options || !options.type) {\n throw new SerializeError(\n 'document type (`schemaType`) is required for document nodes',\n path,\n id,\n hint,\n )\n }\n\n const views = (this.spec.views && this.spec.views.length > 0 ? this.spec.views : [form()]).map(\n (item, i) => maybeSerializeView(item, i, path),\n )\n\n const viewIds = views.map((view) => view.id)\n const dupes = uniq(viewIds.filter((viewId, i) => viewIds.includes(viewId, i + 1)))\n if (dupes.length > 0) {\n throw new SerializeError(\n `document node has views with duplicate IDs: ${dupes.join(', ')}`,\n path,\n id,\n hint,\n )\n }\n\n return {\n ...this.spec,\n child: this.spec.child || createDocumentChildResolver(this._context),\n id: validateId(id, path, index),\n type: 'document',\n options: getDocumentOptions(options),\n views,\n }\n }\n\n /** Clone Document builder\n * @param withSpec - partial document node specification used to extend the cloned builder. See {@link PartialDocumentNode}\n * @returns document builder based on context and spec provided. See {@link DocumentBuilder}\n */\n clone(withSpec: PartialDocumentNode = {}): DocumentBuilder {\n const builder = new DocumentBuilder(this._context)\n const options = {...this.spec.options, ...withSpec.options}\n builder.spec = {...this.spec, ...withSpec, options}\n return builder\n }\n}\n\nfunction getDocumentOptions(spec: Partial<DocumentOptions>): DocumentOptions {\n const opts: DocumentOptions = {\n id: spec.id || '',\n type: spec.type || '*',\n }\n\n if (spec.template) {\n opts.template = spec.template\n }\n\n if (spec.templateParameters) {\n opts.templateParameters = spec.templateParameters\n }\n\n return opts\n}\n\n/** @internal */\nexport function documentFromEditor(context: StructureContext, spec?: EditorNode): DocumentBuilder {\n let doc = spec?.type\n ? // Use user-defined document fragment as base if possible\n context.resolveDocumentNode({schemaType: spec.type})\n : // Fall back to plain old document builder\n new DocumentBuilder(context)\n\n if (!spec) return doc\n\n const {id, type, template, templateParameters} = spec.options\n doc = doc.id(spec.id).documentId(id)\n\n if (type) {\n doc = doc.schemaType(type)\n }\n if (template) {\n doc = doc.initialValueTemplate(template, templateParameters)\n }\n if (spec.child) {\n doc = doc.child(spec.child)\n }\n\n return doc\n}\n\n/** @internal */\nexport function documentFromEditorWithInitialValue(\n {resolveDocumentNode, templates}: StructureContext,\n templateId: string,\n parameters?: Record<string, unknown>,\n): DocumentBuilder {\n const template = templates.find((t) => t.id === templateId)\n\n if (!template) {\n throw new Error(`Template with ID \"${templateId}\" not defined`)\n }\n\n return resolveDocumentNode({schemaType: template.schemaType}).initialValueTemplate(\n templateId,\n parameters,\n )\n}\n","import {AddIcon} from '@sanity/icons'\nimport {type InitialValueTemplateItem} from 'sanity'\n\nimport {type BaseIntentParams, type IntentParams} from './Intent'\nimport {type MenuItem, MenuItemBuilder} from './MenuItem'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {type Serializable, type SerializeOptions, type SerializePath} from './StructureNodes'\nimport {type StructureContext} from './types'\n\n/**\n * A `InitialValueTemplateItemBuilder` is used to build a document node with an initial value set.\n *\n * @public\n */\nexport class InitialValueTemplateItemBuilder implements Serializable<InitialValueTemplateItem> {\n /** Initial Value template item option object. See {@link InitialValueTemplateItem} */\n protected spec: Partial<InitialValueTemplateItem>\n\n constructor(\n /**\n * Structure context. See {@link StructureContext}\n */\n protected _context: StructureContext,\n spec?: Partial<InitialValueTemplateItem>,\n ) {\n this.spec = spec ? spec : {}\n }\n\n /** Set initial value template item builder ID\n * @param id - initial value template item ID\n * @returns initial value template item based on ID provided. See {@link InitialValueTemplateItemBuilder}\n */\n id(id: string): InitialValueTemplateItemBuilder {\n return this.clone({id})\n }\n\n /** Get initial value template item builder ID\n * @returns initial value template item ID. See {@link InitialValueTemplateItem}\n */\n getId(): Partial<InitialValueTemplateItem>['id'] {\n return this.spec.id\n }\n\n /** Set initial value template item title\n * @param title - initial value template item title\n * @returns initial value template item based on title provided. See {@link InitialValueTemplateItemBuilder}\n */\n title(title: string): InitialValueTemplateItemBuilder {\n return this.clone({title})\n }\n\n /** Get initial value template item title\n * @returns initial value template item title. See {@link InitialValueTemplateItem}\n */\n getTitle(): Partial<InitialValueTemplateItem>['title'] {\n return this.spec.title\n }\n\n /** Set initial value template item description\n * @param description - initial value template item description\n * @returns initial value template item builder based on description provided. See {@link InitialValueTemplateItemBuilder}\n */\n description(description: string): InitialValueTemplateItemBuilder {\n return this.clone({description})\n }\n\n /** Get initial value template item description\n * @returns initial value template item description. See {@link InitialValueTemplateItem}\n */\n getDescription(): Partial<InitialValueTemplateItem>['description'] {\n return this.spec.description\n }\n\n /** Set initial value template ID\n * @param templateId - initial value template item template ID\n * @returns initial value template item based builder on template ID provided. See {@link InitialValueTemplateItemBuilder}\n */\n templateId(templateId: string): InitialValueTemplateItemBuilder {\n // Let's try to be a bit helpful and assign an ID from template ID if none is specified\n const paneId = this.spec.id || templateId\n return this.clone({\n id: paneId,\n templateId,\n })\n }\n\n /** Get initial value template item template ID\n * @returns initial value template item ID. See {@link InitialValueTemplateItem}\n */\n getTemplateId(): Partial<InitialValueTemplateItem>['templateId'] {\n return this.spec.templateId\n }\n\n /** Get initial value template item template parameters\n * @param parameters - initial value template item parameters\n * @returns initial value template item builder based on parameters provided. See {@link InitialValueTemplateItemBuilder}\n */\n parameters(parameters: {[key: string]: any}): InitialValueTemplateItemBuilder {\n return this.clone({parameters})\n }\n\n /** Get initial value template item template parameters\n * @returns initial value template item parameters. See {@link InitialValueTemplateItem}\n */\n getParameters(): Partial<InitialValueTemplateItem>['parameters'] {\n return this.spec.parameters\n }\n\n /** Serialize initial value template item\n * @param options - serialization options. See {@link SerializeOptions}\n * @returns initial value template item object based on the path, index and hint provided in options. See {@link InitialValueTemplateItem}\n */\n serialize({path = [], index, hint}: SerializeOptions = {path: []}): InitialValueTemplateItem {\n const {spec, _context} = this\n const {templates} = _context\n\n if (typeof spec.id !== 'string' || !spec.id) {\n throw new SerializeError(\n '`id` is required for initial value template item nodes',\n path,\n index,\n hint,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n if (!spec.templateId) {\n throw new SerializeError(\n 'template id (`templateId`) is required for initial value template item nodes',\n path,\n spec.id,\n hint,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n const template = templates.find((t) => t.id === spec.templateId)\n\n if (!template) {\n throw new SerializeError(\n 'template id (`templateId`) is required for initial value template item nodes',\n path,\n spec.id,\n hint,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n return {\n id: spec.id,\n templateId: spec.id,\n schemaType: template.schemaType,\n type: 'initialValueTemplateItem',\n description: spec.description || template.description,\n title: spec.title || template.title,\n subtitle: spec.subtitle,\n icon: spec.icon || template.icon,\n initialDocumentId: spec.initialDocumentId,\n parameters: spec.parameters,\n }\n }\n\n /** Clone generic view builder (allows for options overriding)\n * @param withSpec - initial value template item builder options. See {@link InitialValueTemplateItemBuilder}\n * @returns initial value template item builder based on the context and options provided. See {@link InitialValueTemplateItemBuilder}\n */\n clone(withSpec: Partial<InitialValueTemplateItem> = {}): InitialValueTemplateItemBuilder {\n const builder = new InitialValueTemplateItemBuilder(this._context)\n builder.spec = {...this.spec, ...withSpec}\n return builder\n }\n}\n\n/** @internal */\nexport function defaultInitialValueTemplateItems(\n context: StructureContext,\n): InitialValueTemplateItemBuilder[] {\n const {schema, getStructureBuilder, templates} = context\n\n // Sort templates by their schema type, in order or definition\n const typeNames = schema.getTypeNames()\n const ordered = templates\n // Don't list templates that require parameters\n // TODO: this should use the new-document template items instead maybe?\n .filter((tpl) => !tpl.parameters?.length)\n .sort((a, b) => typeNames.indexOf(a.schemaType) - typeNames.indexOf(b.schemaType))\n\n // Create actual template items out of the templates\n return ordered.map((tpl) => getStructureBuilder().initialValueTemplateItem(tpl.id))\n}\n\n/** @internal */\nexport function maybeSerializeInitialValueTemplateItem(\n item: InitialValueTemplateItem | InitialValueTemplateItemBuilder,\n index: number,\n path: SerializePath,\n): InitialValueTemplateItem {\n return item instanceof InitialValueTemplateItemBuilder ? item.serialize({path, index}) : item\n}\n\n/** @internal */\nexport function menuItemsFromInitialValueTemplateItems(\n context: StructureContext,\n templateItems: InitialValueTemplateItem[],\n): MenuItem[] {\n const {schema, templates} = context\n return templateItems.map((item) => {\n const template = templates.find((t) => t.id === item.templateId)\n const title = item.title || template?.title || 'Create'\n\n const params: BaseIntentParams = {}\n if (template && template.schemaType) {\n params.type = template.schemaType\n }\n\n if (item.templateId) {\n params.template = item.templateId\n }\n\n const intentParams: IntentParams = item.parameters ? [params, item.parameters] : params\n const schemaType = template && schema.get(template.schemaType)\n\n const i18n = item.i18n || template?.i18n\n\n let builder = new MenuItemBuilder(context)\n .title(title)\n .icon((template && template.icon) || schemaType?.icon || AddIcon)\n .intent({type: 'create', params: intentParams})\n\n if (i18n) {\n builder = builder.i18n(i18n)\n }\n\n return builder.serialize()\n })\n}\n","import {type SearchParam} from 'sanity/router'\n\nimport {getTypeNamesFromFilter, type PartialDocumentList} from './DocumentList'\nimport {type StructureNode} from './StructureNodes'\n\n/**\n * Intent parameters (json)\n *\n * @public\n */\nexport type IntentJsonParams = {[key: string]: any}\n\n/**\n * Base intent parameters\n *\n * @public\n * @todo dedupe with core\n */\nexport interface BaseIntentParams {\n /**\n * Document schema type name to create/edit.\n * Required for `create` intents, optional for `edit` (but encouraged, safer and faster)\n */\n type?: string\n\n /**\n * ID of the document to create/edit.\n * Required for `edit` intents, optional for `create`.\n */\n id?: string\n\n /**\n * Name (ID) of initial value template to use for `create` intent. Optional.\n */\n template?: string\n\n /**\n * Experimental field path\n *\n * @beta\n * @experimental\n * @hidden\n */\n path?: string\n\n /**\n * Optional \"mode\" to use for edit intent.\n * Known modes are `structure` and `presentation`.\n */\n mode?: string\n\n /**\n * Arbitrary/custom parameters are generally discouraged - try to keep them to a minimum,\n * or use `payload` (arbitrary JSON-serializable object) instead.\n */\n [key: string]: string | undefined\n}\n\n/** @internal */\nexport const DEFAULT_INTENT_HANDLER = Symbol('Document type list canHandleIntent')\n\n/**\n * Intent parameters\n * See {@link structure.BaseIntentParams} and {@link structure.IntentJsonParams}\n *\n * @public\n */\nexport type IntentParams = BaseIntentParams | [BaseIntentParams, IntentJsonParams]\n\n/**\n * Interface for intents\n * @public */\n// TODO: intents should be unified somewhere\nexport interface Intent {\n /** Intent type */\n type: string\n /** Intent parameters. See {@link IntentParams}\n */\n params?: IntentParams\n\n searchParams?: SearchParam[]\n}\n\n/**\n * Interface for intent checker\n *\n * @public\n */\nexport interface IntentChecker {\n (\n /** Intent name */\n intentName: string,\n /** Intent checker parameter */\n params: {[key: string]: any},\n /** Structure context. See {@link StructureNode} */\n context: {pane: StructureNode; index: number},\n ): boolean\n /** intent checker identify */\n identity?: symbol\n}\n\n/** @internal */\nexport const defaultIntentChecker: IntentChecker = (intentName, params, {pane}): boolean => {\n const isEdit = intentName === 'edit'\n const isCreate = intentName === 'create'\n const typedSpec = pane as PartialDocumentList\n const paneFilter = typedSpec.options?.filter || ''\n const paneParams = typedSpec.options?.params || {}\n const typeNames = typedSpec.schemaTypeName\n ? [typedSpec.schemaTypeName]\n : getTypeNamesFromFilter(paneFilter, paneParams)\n\n const initialValueTemplates = typedSpec.initialValueTemplates || []\n\n if (isCreate && params.template) {\n return initialValueTemplates.some((tpl) => tpl.templateId === params.template)\n }\n\n return (\n (isEdit && params.id && typeNames.includes(params.type)) ||\n (isCreate && typeNames.includes(params.type))\n )\n}\n\ndefaultIntentChecker.identity = DEFAULT_INTENT_HANDLER\n","export const layoutOptions = ['default', 'card', 'media', 'detail', 'block']\n","import {type I18nTextRecord, type InitialValueTemplateItem, type PreviewLayoutKey} from 'sanity'\n\nimport {\n type InitialValueTemplateItemBuilder,\n maybeSerializeInitialValueTemplateItem,\n} from './InitialValueTemplateItem'\nimport {defaultIntentChecker, type IntentChecker} from './Intent'\nimport {layoutOptions} from './Layout'\nimport {maybeSerializeMenuItem, type MenuItem, type MenuItemBuilder} from './MenuItem'\nimport {\n maybeSerializeMenuItemGroup,\n type MenuItemGroup,\n type MenuItemGroupBuilder,\n} from './MenuItemGroup'\nimport {SerializeError} from './SerializeError'\nimport {\n type Child,\n type Serializable,\n type SerializeOptions,\n type StructureNode,\n} from './StructureNodes'\nimport {getStructureNodeId} from './util/getStructureNodeId'\nimport {validateId} from './util/validateId'\n\nfunction noChildResolver() {\n return undefined\n}\n\n/** @internal */\nexport const shallowIntentChecker: IntentChecker = (intentName, params, {pane, index}): boolean => {\n return index <= 1 && defaultIntentChecker(intentName, params, {pane, index})\n}\n\n/**\n * Interface for list display options\n *\n * @public */\nexport interface ListDisplayOptions {\n /** Check if list display should show icons */\n showIcons?: boolean\n}\n\n/**\n * Interface for base generic list\n *\n * @public\n */\nexport interface BaseGenericList extends StructureNode {\n /** List layout key. */\n defaultLayout?: PreviewLayoutKey\n /** Can handle intent. See {@link IntentChecker} */\n canHandleIntent?: IntentChecker\n /** List display options. See {@link ListDisplayOptions} */\n displayOptions?: ListDisplayOptions\n /** List child. See {@link Child} */\n child: Child\n /** List initial values array. See {@link InitialValueTemplateItem} and {@link InitialValueTemplateItemBuilder} */\n initialValueTemplates?: (InitialValueTemplateItem | InitialValueTemplateItemBuilder)[]\n}\n\n/**\n * Interface for generic list\n *\n * @public\n */\n// \"POJO\"/verbatim-version - end result\nexport interface GenericList extends BaseGenericList {\n /** List type */\n type: string\n /** List menu items array. See {@link MenuItem} */\n menuItems: MenuItem[]\n /** List menu item groups array. See {@link MenuItemGroup} */\n menuItemGroups: MenuItemGroup[]\n}\n\n/**\n * Interface for buildable generic list\n *\n * @public\n */\n// Used internally in builder classes to make everything optional\nexport interface BuildableGenericList extends Partial<BaseGenericList> {\n /** List menu items array. See {@link MenuItem} and {@link MenuItemBuilder} */\n menuItems?: (MenuItem | MenuItemBuilder)[]\n /** List menu items groups array. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */\n menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[]\n}\n\n/**\n * Interface for generic list input\n * Allows builders and only requires things not inferrable\n *\n * @public */\n// Input version, allows builders and only requires things not inferrable\nexport interface GenericListInput extends StructureNode {\n /** Input id */\n id: string\n /** Input title */\n title: string\n /** Input menu items groups. See {@link MenuItem} and {@link MenuItemBuilder} */\n menuItems?: (MenuItem | MenuItemBuilder)[]\n /** Input menu items groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */\n menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[]\n /** Input initial value array. See {@link InitialValueTemplateItem} and {@link InitialValueTemplateItemBuilder} */\n initialValueTemplates?: (InitialValueTemplateItem | InitialValueTemplateItemBuilder)[]\n /** Input default layout. */\n defaultLayout?: PreviewLayoutKey\n /** If input can handle intent. See {@link IntentChecker} */\n canHandleIntent?: IntentChecker\n /** Input child of type {@link Child} */\n child?: Child\n}\n\n/**\n * Class for building generic lists\n *\n * @public\n */\nexport abstract class GenericListBuilder<TList extends BuildableGenericList, ConcreteImpl>\n implements Serializable<GenericList>\n{\n /** Check if initial value templates are set */\n protected initialValueTemplatesSpecified = false\n /** Generic list option object */\n protected spec: TList = {} as TList\n\n /** Set generic list ID\n * @param id - generic list ID\n * @returns generic list builder based on ID provided.\n */\n id(id: string): ConcreteImpl {\n return this.clone({id})\n }\n\n /** Get generic list ID\n * @returns generic list ID\n */\n getId(): TList['id'] {\n return this.spec.id\n }\n\n /** Set generic list title\n * @param title - generic list title\n * @returns generic list builder based on title and ID provided.\n */\n title(title: string): ConcreteImpl {\n return this.clone({title, id: getStructureNodeId(title, this.spec.id)})\n }\n\n /** Get generic list title\n * @returns generic list title\n */\n getTitle(): TList['title'] {\n return this.spec.title\n }\n\n /** Set the i18n key and namespace used to populate the localized title.\n * @param i18n - the key and namespaced used to populate the localized title.\n * @returns component builder based on i18n key and ns provided\n */\n i18n(i18n: I18nTextRecord<'title'>): ConcreteImpl {\n return this.clone({i18n})\n }\n\n /** Get i18n key and namespace used to populate the localized title\n * @returns the i18n key and namespace used to populate the localized title\n */\n getI18n(): TList['i18n'] {\n return this.spec.i18n\n }\n\n /** Set generic list layout\n * @param defaultLayout - generic list layout key.\n * @returns generic list builder based on layout provided.\n */\n defaultLayout(defaultLayout: PreviewLayoutKey): ConcreteImpl {\n return this.clone({defaultLayout})\n }\n\n /** Get generic list layout\n * @returns generic list layout\n */\n getDefaultLayout(): TList['defaultLayout'] {\n return this.spec.defaultLayout\n }\n\n /** Set generic list menu items\n * @param menuItems - generic list menu items. See {@link MenuItem} and {@link MenuItemBuilder}\n * @returns generic list builder based on menu items provided.\n */\n menuItems(menuItems: (MenuItem | MenuItemBuilder)[] | undefined): ConcreteImpl {\n return this.clone({menuItems})\n }\n\n /** Get generic list menu items\n * @returns generic list menu items\n */\n getMenuItems(): TList['menuItems'] {\n return this.spec.menuItems\n }\n\n /** Set generic list menu item groups\n * @param menuItemGroups - generic list menu item groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder}\n * @returns generic list builder based on menu item groups provided.\n */\n menuItemGroups(menuItemGroups: (MenuItemGroup | MenuItemGroupBuilder)[]): ConcreteImpl {\n return this.clone({menuItemGroups})\n }\n\n /** Get generic list menu item groups\n * @returns generic list menu item groups\n */\n getMenuItemGroups(): TList['menuItemGroups'] {\n return this.spec.menuItemGroups\n }\n\n /** Set generic list child\n * @param child - generic list child. See {@link Child}\n * @returns generic list builder based on child provided (clone).\n */\n child(child: Child): ConcreteImpl {\n return this.clone({child})\n }\n\n /** Get generic list child\n * @returns generic list child\n */\n getChild(): TList['child'] {\n return this.spec.child\n }\n\n /** Set generic list can handle intent\n * @param canHandleIntent - generic list intent checker. See {@link IntentChecker}\n * @returns generic list builder based on can handle intent provided.\n */\n canHandleIntent(canHandleIntent?: IntentChecker): ConcreteImpl {\n return this.clone({canHandleIntent})\n }\n\n /** Get generic list can handle intent\n * @returns generic list can handle intent\n */\n getCanHandleIntent(): TList['canHandleIntent'] {\n return this.spec.canHandleIntent\n }\n\n /** Set generic list display options\n * @param enabled - allow / disallow for showing icons\n * @returns generic list builder based on display options (showIcons) provided.\n */\n showIcons(enabled = true): ConcreteImpl {\n return this.clone({\n displayOptions: {...this.spec.displayOptions, showIcons: enabled},\n })\n }\n\n /** Get generic list display options\n * @returns generic list display options (specifically showIcons)\n */\n getShowIcons(): boolean | undefined {\n return this.spec.displayOptions ? this.spec.displayOptions.showIcons : undefined\n }\n\n /** Set generic list initial value templates\n * @param templates - generic list initial value templates. See {@link InitialValueTemplateItemBuilder}\n * @returns generic list builder based on templates provided.\n */\n initialValueTemplates(\n templates:\n | InitialValueTemplateItem\n | InitialValueTemplateItemBuilder\n | Array<InitialValueTemplateItem | InitialValueTemplateItemBuilder>,\n ): ConcreteImpl {\n this.initialValueTemplatesSpecified = true\n return this.clone({initialValueTemplates: Array.isArray(templates) ? templates : [templates]})\n }\n\n /** Get generic list initial value templates\n * @returns generic list initial value templates\n */\n getInitialValueTemplates(): TList['initialValueTemplates'] {\n return this.spec.initialValueTemplates\n }\n\n /** Serialize generic list\n * @param options - serialization options. See {@link SerializeOptions}\n * @returns generic list object based on path provided in options. See {@link GenericList}\n */\n serialize(options: SerializeOptions = {path: []}): GenericList {\n const id = this.spec.id || ''\n const path = options.path\n\n const defaultLayout = this.spec.defaultLayout\n if (defaultLayout && !layoutOptions.includes(defaultLayout)) {\n throw new SerializeError(\n `\\`layout\\` must be one of ${layoutOptions.map((item) => `\"${item}\"`).join(', ')}`,\n path,\n id || options.index,\n this.spec.title,\n )\n }\n\n const initialValueTemplates = (this.spec.initialValueTemplates || []).map((item, i) =>\n maybeSerializeInitialValueTemplateItem(item, i, path),\n )\n\n return {\n id: validateId(id, options.path, id || options.index),\n title: this.spec.title,\n i18n: this.spec.i18n,\n type: 'genericList',\n defaultLayout,\n child: this.spec.child || noChildResolver,\n canHandleIntent: this.spec.canHandleIntent || shallowIntentChecker,\n displayOptions: this.spec.displayOptions,\n initialValueTemplates,\n menuItems: (this.spec.menuItems || []).map((item, i) =>\n maybeSerializeMenuItem(item, i, path),\n ),\n menuItemGroups: (this.spec.menuItemGroups || []).map((item, i) =>\n maybeSerializeMenuItemGroup(item, i, path),\n ),\n }\n }\n\n /** Clone generic list builder (allows for options overriding)\n * @param _withSpec - generic list options.\n * @returns generic list builder.\n */\n abstract clone(_withSpec?: object): ConcreteImpl\n}\n","import {generateHelpUrl} from '@sanity/generate-help-url'\nimport {AddIcon} from '@sanity/icons'\nimport {type SchemaType, type SortOrderingItem} from '@sanity/types'\nimport {DEFAULT_STUDIO_CLIENT_OPTIONS, type InitialValueTemplateItem} from 'sanity'\n\nimport {type ChildResolver, type ChildResolverOptions, type ItemChild} from './ChildResolver'\nimport {DocumentBuilder} from './Document'\nimport {\n type BuildableGenericList,\n type GenericList,\n GenericListBuilder,\n type GenericListInput,\n} from './GenericList'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {type Child, type SerializeOptions} from './StructureNodes'\nimport {type StructureContext} from './types'\nimport {resolveTypeForDocument} from './util/resolveTypeForDocument'\n\nconst validateFilter = (spec: PartialDocumentList, options: SerializeOptions) => {\n const filter = spec.options?.filter.trim() || ''\n\n if (['*', '{'].includes(filter[0])) {\n throw new SerializeError(\n `\\`filter\\` cannot start with \\`${filter[0]}\\` - looks like you are providing a query, not a filter`,\n options.path,\n spec.id,\n spec.title,\n ).withHelpUrl(HELP_URL.QUERY_PROVIDED_FOR_FILTER)\n }\n\n return filter\n}\n\nconst createDocumentChildResolverForItem =\n (context: StructureContext): ChildResolver =>\n (itemId: string, options: ChildResolverOptions): ItemChild | Promise<ItemChild> | undefined => {\n const parentItem = options.parent as DocumentList\n const template = options.params?.template\n ? context.templates.find((tpl) => tpl.id === options.params.template)\n : undefined\n const type = template\n ? template.schemaType\n : parentItem.schemaTypeName || resolveTypeForDocument(context.getClient, itemId)\n\n return Promise.resolve(type).then((schemaType) =>\n schemaType\n ? context.resolveDocumentNode({schemaType, documentId: itemId})\n : new DocumentBuilder(context).id('editor').documentId(itemId).schemaType(''),\n )\n }\n\n/**\n * Partial document list\n *\n * @public\n */\nexport interface PartialDocumentList extends BuildableGenericList {\n /** Document list options. See {@link DocumentListOptions} */\n options?: DocumentListOptions\n /** Schema type name */\n schemaTypeName?: string\n}\n\n/**\n * Interface for document list input\n *\n * @public\n */\nexport interface DocumentListInput extends GenericListInput {\n /** Document list options. See {@link DocumentListOptions} */\n options: DocumentListOptions\n}\n\n/**\n * Interface for document list\n *\n * @public\n */\nexport interface DocumentList extends GenericList {\n type: 'documentList'\n /** Document list options. See {@link DocumentListOptions} */\n options: DocumentListOptions\n /** Document list child. See {@link Child} */\n child: Child\n /** Document schema type name */\n schemaTypeName?: string\n}\n\n/**\n * Interface for document List options\n *\n * @public\n */\nexport interface DocumentListOptions {\n /** Document list filter */\n filter: string\n /** Document list parameters */\n params?: Record<string, unknown>\n /** Document list API version */\n apiVersion?: string\n /** Document list API default ordering array. */\n defaultOrdering?: SortOrderingItem[]\n}\n\n/**\n * Class for building document list\n *\n * @public\n */\nexport class DocumentListBuilder extends GenericListBuilder<\n PartialDocumentList,\n DocumentListBuilder\n> {\n /** Document list options. See {@link PartialDocumentList} */\n protected spec: PartialDocumentList\n\n constructor(\n /**\n * Structure context. See {@link StructureContext}\n */\n protected _context: StructureContext,\n spec?: DocumentListInput,\n ) {\n super()\n this.spec = spec || {}\n this.initialValueTemplatesSpecified = Boolean(spec?.initialValueTemplates)\n }\n\n /** Set API version\n * @param apiVersion - API version\n * @returns document list builder based on the options and API version provided. See {@link DocumentListBuilder}\n */\n apiVersion(apiVersion: string): DocumentListBuilder {\n return this.clone({options: {...(this.spec.options || {filter: ''}), apiVersion}})\n }\n\n /** Get API version\n * @returns API version\n */\n getApiVersion(): string | undefined {\n return this.spec.options?.apiVersion\n }\n\n /** Set Document list filter\n * @param filter - GROQ-filter used to determine which documents to display. Do not support joins, since they operate on individual documents, and will ignore order-clauses and projections. See {@link https://www.sanity.io/docs/realtime-updates}\n * @returns document list builder based on the options and filter provided. See {@link DocumentListBuilder}\n */\n filter(filter: string): DocumentListBuilder {\n return this.clone({options: {...this.spec.options, filter}})\n }\n\n /** Get Document list filter\n * @returns filter\n */\n getFilter(): string | undefined {\n return this.spec.options?.filter\n }\n\n /** Set Document list schema type name\n * @param type - schema type name.\n * @returns document list builder based on the schema type name provided. See {@link DocumentListBuilder}\n */\n schemaType(type: SchemaType | string): DocumentListBuilder {\n const schemaTypeName = typeof type === 'string' ? type : type.name\n return this.clone({schemaTypeName})\n }\n\n /** Get Document list schema type name\n * @returns schema type name\n */\n getSchemaType(): string | undefined {\n return this.spec.schemaTypeName\n }\n\n /** Set Document list options' parameters\n * @param params - parameters\n * @returns document list builder based on the options provided. See {@link DocumentListBuilder}\n */\n params(params: Record<string, unknown>): DocumentListBuilder {\n return this.clone({\n options: {...(this.spec.options || {filter: ''}), params},\n })\n }\n\n /** Get Document list options' parameters\n * @returns options\n */\n getParams(): Record<string, unknown> | undefined {\n return this.spec.options?.params\n }\n\n /** Set Document list default ordering\n * @param ordering - default sort ordering array. See {@link SortOrderingItem}\n * @returns document list builder based on ordering provided. See {@link DocumentListBuilder}\n */\n defaultOrdering(ordering: SortOrderingItem[]): DocumentListBuilder {\n if (!Array.isArray(ordering)) {\n throw new Error('`defaultOrdering` must be an array of order clauses')\n }\n\n return this.clone({\n options: {...(this.spec.options || {filter: ''}), defaultOrdering: ordering},\n })\n }\n\n /** Get Document list default ordering\n * @returns default ordering. See {@link SortOrderingItem}\n */\n getDefaultOrdering(): SortOrderingItem[] | undefined {\n return this.spec.options?.defaultOrdering\n }\n\n /** Serialize Document list\n * @param options - serialization options. See {@link SerializeOptions}\n * @returns document list object based on path provided in options. See {@link DocumentList}\n */\n serialize(options: SerializeOptions = {path: []}): DocumentList {\n if (typeof this.spec.id !== 'string' || !this.spec.id) {\n throw new SerializeError(\n '`id` is required for document lists',\n options.path,\n options.index,\n this.spec.title,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n if (!this.spec.options || !this.spec.options.filter) {\n throw new SerializeError(\n '`filter` is required for document lists',\n options.path,\n this.spec.id,\n this.spec.title,\n ).withHelpUrl(HELP_URL.FILTER_REQUIRED)\n }\n\n const hasSimpleFilter = this.spec.options?.filter === '_type == $type'\n if (!hasSimpleFilter && this.spec.options.filter && !this.spec.options.apiVersion) {\n console.warn(\n `No apiVersion specified for document type list with custom filter: \\`${this.spec.options.filter}\\`. This will be required in the future. See %s for more info.`,\n generateHelpUrl(HELP_URL.API_VERSION_REQUIRED_FOR_CUSTOM_FILTER),\n )\n }\n return {\n ...super.serialize(options),\n type: 'documentList',\n schemaTypeName: this.spec.schemaTypeName,\n child: this.spec.child || createDocumentChildResolverForItem(this._context),\n options: {\n ...this.spec.options,\n // @todo: make specifying .apiVersion required when using custom (non-simple) filters in v4\n apiVersion: this.spec.options.apiVersion || DEFAULT_STUDIO_CLIENT_OPTIONS.apiVersion,\n filter: validateFilter(this.spec, options),\n },\n }\n }\n\n /** Clone Document list builder (allows for options overriding)\n * @param withSpec - override document list spec. See {@link PartialDocumentList}\n * @returns document list builder. See {@link DocumentListBuilder}\n */\n clone(withSpec?: PartialDocumentList): DocumentListBuilder {\n const builder = new DocumentListBuilder(this._context)\n builder.spec = {...this.spec, ...withSpec}\n\n if (!this.initialValueTemplatesSpecified) {\n builder.spec.initialValueTemplates = inferInitialValueTemplates(this._context, builder.spec)\n }\n\n if (!builder.spec.schemaTypeName) {\n builder.spec.schemaTypeName = inferTypeName(builder.spec)\n }\n\n return builder\n }\n\n /** Get Document list spec\n * @returns document list spec. See {@link PartialDocumentList}\n */\n getSpec(): PartialDocumentList {\n return this.spec\n }\n}\n\nfunction inferInitialValueTemplates(\n context: StructureContext,\n spec: PartialDocumentList,\n): InitialValueTemplateItem[] | undefined {\n const {document} = context\n const {schemaTypeName, options} = spec\n const {filter, params} = options || {filter: '', params: {}}\n const typeNames = schemaTypeName\n ? [schemaTypeName]\n : Array.from(new Set(getTypeNamesFromFilter(filter, params)))\n\n if (typeNames.length === 0) {\n return undefined\n }\n\n return typeNames\n .flatMap((schemaType) =>\n document.resolveNewDocumentOptions({\n type: 'structure',\n schemaType,\n }),\n )\n .map((option) => ({...option, icon: AddIcon}))\n}\n\nfunction inferTypeName(spec: PartialDocumentList): string | undefined {\n const {options} = spec\n const {filter, params} = options || {filter: '', params: {}}\n const typeNames = getTypeNamesFromFilter(filter, params)\n return typeNames.length === 1 ? typeNames[0] : undefined\n}\n\n/** @internal */\nexport function getTypeNamesFromFilter(\n filter: string,\n params: Record<string, unknown> = {},\n): string[] {\n let typeNames = getTypeNamesFromEqualityFilter(filter, params)\n\n if (typeNames.length === 0) {\n typeNames = getTypeNamesFromInTypesFilter(filter, params)\n }\n\n return typeNames\n}\n\n// From _type == \"movie\" || _type == $otherType\nfunction getTypeNamesFromEqualityFilter(\n filter: string,\n params: Record<string, unknown> = {},\n): string[] {\n const pattern =\n /\\b_type\\s*==\\s*(['\"].*?['\"]|\\$.*?(?:\\s|$))|\\B(['\"].*?['\"]|\\$.*?(?:\\s|$))\\s*==\\s*_type/g\n const matches: string[] = []\n let match\n while ((match = pattern.exec(filter)) !== null) {\n matches.push(match[1] || match[2])\n }\n\n return matches\n .map((candidate) => {\n const typeName = candidate[0] === '$' ? params[candidate.slice(1)] : candidate\n const normalized = ((typeName as string) || '').trim().replace(/^[\"']|[\"']$/g, '')\n return normalized\n })\n .filter(Boolean)\n}\n\n// From _type in [\"dog\", \"cat\", $otherSpecies]\nfunction getTypeNamesFromInTypesFilter(\n filter: string,\n params: Record<string, unknown> = {},\n): string[] {\n const pattern = /\\b_type\\s+in\\s+\\[(.*?)\\]/\n const matches = filter.match(pattern)\n if (!matches) {\n return []\n }\n\n return matches[1]\n .split(/,\\s*/)\n .map((match) => match.trim().replace(/^[\"']+|[\"']+$/g, ''))\n .map((item) => (item[0] === '$' ? params[item.slice(1)] : item))\n .filter(Boolean) as string[]\n}\n","import {find} from 'lodash'\nimport {isRecord} from 'sanity'\n\nimport {type ChildResolver, type ChildResolverOptions} from './ChildResolver'\nimport {DividerBuilder} from './Divider'\nimport {isDocumentListItem} from './DocumentListItem'\nimport {\n type BuildableGenericList,\n type GenericList,\n GenericListBuilder,\n type GenericListInput,\n shallowIntentChecker,\n} from './GenericList'\nimport {type IntentChecker} from './Intent'\nimport {type ListItem, ListItemBuilder} from './ListItem'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {type Divider, type SerializeOptions, type SerializePath} from './StructureNodes'\nimport {type StructureContext} from './types'\n\nconst getArgType = (thing: ListItem) => {\n if (thing instanceof ListBuilder) {\n return 'ListBuilder'\n }\n\n if (isPromise<ListItem>(thing)) {\n return 'Promise'\n }\n\n return Array.isArray(thing) ? 'array' : typeof thing\n}\n\nconst isListItem = (item: ListItem | Divider): item is ListItem => {\n return item.type === 'listItem'\n}\n\nconst defaultCanHandleIntent: IntentChecker = (intentName: string, params, context) => {\n const pane = context.pane as List\n const items = pane.items || []\n return (\n items\n .filter(isDocumentListItem)\n .some((item) => item.schemaType.name === params.type && item._id === params.id) ||\n shallowIntentChecker(intentName, params, context)\n )\n}\n\nconst resolveChildForItem: ChildResolver = (itemId: string, options: ChildResolverOptions) => {\n const parentItem = options.parent as List\n const items = parentItem.items.filter(isListItem)\n const target = (items.find((item) => item.id === itemId) || {child: undefined}).child\n\n if (!target || typeof target !== 'function') {\n return target\n }\n\n return typeof target === 'function' ? target(itemId, options) : target\n}\n\nfunction maybeSerializeListItem(\n item: ListItem | ListItemBuilder | Divider | DividerBuilder,\n index: number,\n path: SerializePath,\n): ListItem | Divider {\n if (item instanceof ListItemBuilder) {\n return item.serialize({path, index})\n }\n\n if (item instanceof DividerBuilder) {\n return item.serialize()\n }\n\n const listItem = item as ListItem\n if (listItem && listItem.type === 'divider') {\n return item as Divider\n }\n\n if (!listItem || listItem.type !== 'listItem') {\n const gotWhat = (listItem && listItem.type) || getArgType(listItem)\n const helpText = gotWhat === 'array' ? ' - did you forget to spread (...moreItems)?' : ''\n throw new SerializeError(\n `List items must be of type \"listItem\", got \"${gotWhat}\"${helpText}`,\n path,\n index,\n ).withHelpUrl(HELP_URL.INVALID_LIST_ITEM)\n }\n\n return item\n}\n\nfunction isPromise<T>(thing: unknown): thing is PromiseLike<T> {\n return isRecord(thing) && typeof thing.then === 'function'\n}\n\n/**\n * Interface for List\n *\n * @public\n */\nexport interface List extends GenericList {\n type: 'list'\n /** List items. See {@link ListItem} and {@link Divider} */\n items: (ListItem | Divider)[]\n}\n\n/**\n * Interface for list input\n *\n * @public\n */\nexport interface ListInput extends GenericListInput {\n /** List input items array. See {@link ListItem}, {@link ListItemBuilder} and {@link Divider} */\n items?: (ListItem | ListItemBuilder | Divider | DividerBuilder)[]\n}\n\n/**\n * Interface for buildable list\n *\n * @public\n */\nexport interface BuildableList extends BuildableGenericList {\n /** List items. See {@link ListItem}, {@link ListItemBuilder} and {@link Divider} */\n items?: (ListItem | ListItemBuilder | Divider | DividerBuilder)[]\n}\n\n/**\n * A `ListBuilder` is used to build a list of items in the structure tool.\n *\n * @public */\nexport class ListBuilder extends GenericListBuilder<BuildableList, ListBuilder> {\n /** buildable list option object. See {@link BuildableList} */\n protected spec: BuildableList\n\n constructor(\n /**\n * Structure context. See {@link StructureContext}\n */\n protected _context: StructureContext,\n spec?: ListInput,\n ) {\n super()\n this.spec = spec ? spec : {}\n this.initialValueTemplatesSpecified = Boolean(spec && spec.initialValueTemplates)\n }\n\n /**\n * Set list builder based on items provided\n * @param items - list items. See {@link ListItemBuilder}, {@link ListItem} and {@link Divider}\n * @returns list builder based on items provided. See {@link ListBuilder}\n */\n items(items: (ListItemBuilder | ListItem | Divider | DividerBuilder)[]): ListBuilder {\n return this.clone({items})\n }\n\n /** Get list builder items\n * @returns list items. See {@link BuildableList}\n */\n getItems(): BuildableList['items'] {\n return this.spec.items\n }\n\n /** Serialize list builder\n * @param options - serialization options. See {@link SerializeOptions}\n * @returns list based on path in options. See {@link List}\n */\n serialize(options: SerializeOptions = {path: []}): List {\n const id = this.spec.id\n if (typeof id !== 'string' || !id) {\n throw new SerializeError(\n '`id` is required for lists',\n options.path,\n options.index,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n const items = typeof this.spec.items === 'undefined' ? [] : this.spec.items\n if (!Array.isArray(items)) {\n throw new SerializeError(\n '`items` must be an array of items',\n options.path,\n options.index,\n ).withHelpUrl(HELP_URL.LIST_ITEMS_MUST_BE_ARRAY)\n }\n\n const path = (options.path || []).concat(id)\n const serializedItems = items.map((item, index) => maybeSerializeListItem(item, index, path))\n const dupes = serializedItems.filter((val, i) => find(serializedItems, {id: val.id}, i + 1))\n\n if (dupes.length > 0) {\n const dupeIds = dupes.map((item) => item.id).slice(0, 5)\n const dupeDesc = dupes.length > 5 ? `${dupeIds.join(', ')}...` : dupeIds.join(', ')\n throw new SerializeError(\n `List items with same ID found (${dupeDesc})`,\n options.path,\n options.index,\n ).withHelpUrl(HELP_URL.LIST_ITEM_IDS_MUST_BE_UNIQUE)\n }\n\n return {\n ...super.serialize(options),\n type: 'list',\n canHandleIntent: this.spec.canHandleIntent || defaultCanHandleIntent,\n child: this.spec.child || resolveChildForItem,\n items: serializedItems,\n }\n }\n\n /**\n * Clone list builder and return new list builder based on context and spec provided\n * @param withSpec - list options. See {@link BuildableList}\n * @returns new list builder based on context and spec provided. See {@link ListBuilder}\n */\n clone(withSpec?: BuildableList): ListBuilder {\n const builder = new ListBuilder(this._context)\n builder.spec = {...this.spec, ...withSpec}\n return builder\n }\n}\n","import {type SchemaType} from '@sanity/types'\nimport {type Observable} from 'rxjs'\nimport {type I18nTextRecord} from 'sanity'\n\nimport {type ChildResolver, type ItemChild} from './ChildResolver'\nimport {ComponentBuilder} from './Component'\nimport {DocumentBuilder} from './Document'\nimport {DocumentListBuilder} from './DocumentList'\nimport {ListBuilder} from './List'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {\n type Collection,\n type CollectionBuilder,\n type Serializable,\n type SerializeOptions,\n} from './StructureNodes'\nimport {type StructureContext} from './types'\nimport {getStructureNodeId} from './util/getStructureNodeId'\nimport {validateId} from './util/validateId'\n\n/**\n * Unserialized list item child.\n * See {@link Collection}, {@link CollectionBuilder}, {@link ChildResolver} and {@link ItemChild}\n *\n * @public\n */\nexport type UnserializedListItemChild =\n | Collection\n | CollectionBuilder\n | ChildResolver\n | Observable<ItemChild>\n\n/**\n * Child of List Item\n * See {@link Collection}, {@link ChildResolver}, {@link ItemChild}\n * @public\n */\nexport type ListItemChild = Collection | ChildResolver | Observable<ItemChild> | undefined\n\n/**\n * Interface for serialize list item options\n *\n * @public\n */\nexport interface ListItemSerializeOptions extends SerializeOptions {\n /** Check if list item title is optional */\n titleIsOptional?: boolean\n}\n\n/**\n * Interface for ist item display options\n *\n * @public */\nexport interface ListItemDisplayOptions {\n /** Check if list item display should show icon */\n showIcon?: boolean\n}\n\n/**\n * interface for list item input\n *\n * @public */\nexport interface ListItemInput {\n /** List item id */\n id: string\n /** List item title */\n title?: string\n /** List item icon */\n icon?: React.ComponentType | React.ReactNode\n /** List item child. See {@link ListItemChild} */\n child?: ListItemChild\n /** List item display options. See {@link ListItemDisplayOptions} */\n displayOptions?: ListItemDisplayOptions\n /** List item schema type. See {@link SchemaType} */\n schemaType?: SchemaType | string\n}\n\n/**\n * Interface for List Item\n *\n * @public */\nexport interface ListItem {\n /** List item id */\n id: string\n /** List item type */\n type: string\n /**\n * The i18n key and namespace used to populate the localized title. This is\n * the recommend way to set the title if you are localizing your studio.\n */\n i18n?: I18nTextRecord<'title'>\n /** List item title. Note that the `i18n` key and namespace will take precedence. */\n title?: string\n /** List item icon */\n icon?: React.ComponentType | React.ReactNode\n /** List item child. See {@link ListItemChild} */\n child?: ListItemChild\n /** List item display options. See {@link ListItemDisplayOptions} */\n displayOptions?: ListItemDisplayOptions\n /** List item schema type. See {@link SchemaType} */\n schemaType?: SchemaType\n}\n\n/**\n * Interface for unserialized list items.\n *\n * @public\n */\nexport interface UnserializedListItem {\n /** List item ID */\n id: string\n /** List item title */\n title: string\n /**\n * The i18n key and namespace used to populate the localized title. This is\n * the recommend way to set the title if you are localizing your studio.\n */\n i18n?: I18nTextRecord<'title'>\n /** List item icon */\n icon?: React.ComponentType | React.ReactNode\n /** List item child. See {@link UnserializedListItemChild} */\n child?: UnserializedListItemChild\n /** List item display options. See {@link ListItemDisplayOptions} */\n displayOptions?: ListItemDisplayOptions\n /** List item schema. See {@link SchemaType} */\n schemaType?: SchemaType | string\n}\n\n/**\n * Partial list item. See {@link UnserializedListItem}\n *\n * @public */\nexport type PartialListItem = Partial<UnserializedListItem>\n\n/**\n * Class for building list items\n *\n * @public */\nexport class ListItemBuilder implements Serializable<ListItem> {\n /** List item option object. See {@link PartialListItem} */\n protected spec: PartialListItem\n\n constructor(\n /**\n * Structure context. See {@link StructureContext}\n */\n protected _context: StructureContext,\n spec?: ListItemInput,\n ) {\n this.spec = spec ? spec : {}\n }\n\n /**\n * Set list item ID\n * @returns list item builder based on ID provided. See {@link ListItemBuilder}\n */\n id(id: string): ListItemBuilder {\n return this.clone({id})\n }\n\n /**\n * Get list item ID\n * @returns list item ID. See {@link PartialListItem}\n */\n getId(): PartialListItem['id'] {\n return this.spec.id\n }\n\n /**\n * Set list item title\n * @returns list item builder based on title provided. See {@link ListItemBuilder}\n */\n title(title: string): ListItemBuilder {\n return this.clone({title, id: getStructureNodeId(title, this.spec.id)})\n }\n\n /**\n * Get list item title\n * @returns list item title. See {@link PartialListItem}\n */\n getTitle(): PartialListItem['title'] {\n return this.spec.title\n }\n\n /** Set the i18n key and namespace used to populate the localized title.\n * @param i18n - the key and namespaced used to populate the localized title.\n * @returns component builder based on i18n key and ns provided\n */\n i18n(i18n: I18nTextRecord<'title'>): ListItemBuilder {\n return this.clone({i18n})\n }\n\n /** Get i18n key and namespace used to populate the localized title\n * @returns the i18n key and namespace used to populate the localized title\n */\n getI18n(): I18nTextRecord<'title'> | undefined {\n return this.spec.i18n\n }\n\n /**\n * Set list item icon\n * @returns list item builder based on icon provided. See {@link ListItemBuilder}\n */\n icon(icon: React.ComponentType | React.ReactNode): ListItemBuilder {\n return this.clone({icon})\n }\n\n /**\n * Set if list item should show icon\n * @returns list item builder based on showIcon provided. See {@link ListItemBuilder}\n */\n showIcon(enabled = true): ListItemBuilder {\n return this.clone({\n displayOptions: {...this.spec.displayOptions, showIcon: enabled},\n })\n }\n\n /**\n * Check if list item should show icon\n * @returns true if it should show the icon, false if not, undefined if not set\n */\n getShowIcon(): boolean | undefined {\n return this.spec.displayOptions ? this.spec.displayOptions.showIcon : undefined\n }\n\n /**\n *Get list item icon\n * @returns list item icon. See {@link PartialListItem}\n */\n getIcon(): PartialListItem['icon'] {\n return this.spec.icon\n }\n\n /**\n * Set list item child\n * @param child - list item child. See {@link UnserializedListItemChild}\n * @returns list item builder based on child provided. See {@link ListItemBuilder}\n */\n child(child: UnserializedListItemChild): ListItemBuilder {\n return this.clone({child})\n }\n\n /**\n * Get list item child\n * @returns list item child. See {@link PartialListItem}\n */\n getChild(): PartialListItem['child'] {\n return this.spec.child\n }\n\n /**\n * Set list item schema type\n * @param schemaType - list item schema type. See {@link SchemaType}\n * @returns list item builder based on schema type provided. See {@link ListItemBuilder}\n */\n schemaType(schemaType: SchemaType | string): ListItemBuilder {\n return this.clone({schemaType})\n }\n\n /**\n * Get list item schema type\n * @returns list item schema type. See {@link PartialListItem}\n */\n getSchemaType(): PartialListItem['schemaType'] {\n const schemaType = this.spec.schemaType\n\n if (typeof schemaType === 'string') {\n return this._context.schema.get(schemaType)\n }\n\n return this.spec.schemaType\n }\n\n /** Serialize list item builder\n * @param options - serialization options. See {@link ListItemSerializeOptions}\n * @returns list item node based on path provided in options. See {@link ListItem}\n */\n serialize(options: ListItemSerializeOptions = {path: []}): ListItem {\n const {id, title, child} = this.spec\n if (typeof id !== 'string' || !id) {\n throw new SerializeError(\n '`id` is required for list items',\n options.path,\n options.index,\n ).withHelpUrl(HELP_URL.ID_REQUIRED)\n }\n\n if (!options.titleIsOptional && (typeof title !== 'string' || !title)) {\n throw new SerializeError('`title` is required for list items', options.path, id).withHelpUrl(\n HELP_URL.TITLE_REQUIRED,\n )\n }\n\n let schemaType = this.spec.schemaType\n if (typeof schemaType === 'string') {\n const type = this._context.schema.get(schemaType)\n if (!type) {\n throw new SerializeError(\n `Could not find type \"${schemaType}\" in schema`,\n options.path,\n id,\n ).withHelpUrl(HELP_URL.SCHEMA_TYPE_NOT_FOUND)\n }\n\n schemaType = type\n }\n\n const serializeOptions = {path: options.path.concat(id), hint: 'child'}\n let listChild =\n child instanceof ComponentBuilder ||\n child instanceof DocumentListBuilder ||\n child instanceof DocumentBuilder ||\n child instanceof ListBuilder\n ? child.serialize(serializeOptions)\n : child\n\n // In the case of a function, create a bound version that will pass the correct serialize\n // context, so we may lazily resolve it at some point in the future without losing context\n if (typeof listChild === 'function') {\n const originalChild = listChild\n listChild = (itemId, childOptions) => {\n return originalChild(itemId, {...childOptions, serializeOptions})\n }\n }\n\n return {\n ...this.spec,\n id: validateId(id, options.path, options.index),\n schemaType,\n child: listChild,\n title,\n type: 'listItem',\n }\n }\n\n /** Clone list item builder\n * @param withSpec - partial list item options. See {@link PartialListItem}\n * @returns list item builder based on context and spec provided. See {@link ListItemBuilder}\n */\n clone(withSpec?: PartialListItem): ListItemBuilder {\n const builder = new ListItemBuilder(this._context)\n builder.spec = {...this.spec, ...withSpec}\n return builder\n }\n}\n","import {type SchemaType} from '@sanity/types'\nimport {isRecord} from 'sanity'\n\nimport {DocumentBuilder} from './Document'\nimport {\n type ListItem,\n ListItemBuilder,\n type ListItemInput,\n type UnserializedListItem,\n} from './ListItem'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {type SerializeOptions} from './StructureNodes'\nimport {type StructureContext} from './types'\n\n/**\n * Interface for document list item input\n *\n * @public\n */\nexport interface DocumentListItemInput extends ListItemInput {\n /** Document list item input schema type. See {@link SchemaType} */\n schemaType: SchemaType | string\n}\n\n/**\n * Interface for document list item\n *\n * @public\n */\nexport interface DocumentListItem extends ListItem {\n /** Document schema type. See {@link SchemaType} */\n schemaType: SchemaType\n /** Document ID */\n _id: string\n}\n\n/**\n * Partial document list item\n *\n * @public\n */\nexport type PartialDocumentListItem = Partial<UnserializedListItem>\n\nconst createDefaultChildResolver =\n (context: StructureContext, spec: PartialDocumentListItem) => (documentId: string) => {\n const schemaType =\n spec.schemaType &&\n (typeof spec.schemaType === 'string' ? spec.schemaType : spec.schemaType.name)\n\n return schemaType\n ? context.resolveDocumentNode({schemaType, documentId})\n : new DocumentBuilder(context).id('documentEditor').documentId(documentId)\n }\n\n/**\n * Class for building a document list item\n *\n * @public\n */\nexport class DocumentListItemBuilder extends ListItemBuilder {\n /** Document list options. See {@link PartialDocumentListItem} */\n protected spec: PartialDocumentListItem\n\n constructor(\n /**\n * Structure context. See {@link StructureContext}\n */\n protected _context: StructureContext,\n spec?: DocumentListItemInput,\n ) {\n super(_context, spec)\n this.spec = spec ? spec : {}\n }\n\n /**\n * Serialize document list item\n * @param options - serialization options. See {@link SerializeOptions}\n * @returns document list item object based on path provided in options. See {@link DocumentListItem}\n */\n serialize(options: SerializeOptions = {path: []}): DocumentListItem {\n const spec = super.serialize({...options, titleIsOptional: true})\n\n if (!spec.schemaType) {\n throw new SerializeError(\n '`schemaType` is required for document list items',\n options.path,\n options.index,\n ).withHelpUrl(HELP_URL.SCHEMA_TYPE_REQUIRED)\n }\n\n const child = spec.child || createDefaultChildResolver(this._context, spec)\n return {...spec, child, schemaType: spec.schemaType, _id: spec.id}\n }\n\n /** Clone Document list item builder (allows for options overriding)\n * @param withSpec - Document list item builder options. See {@link PartialDocumentListItem}\n * @returns document list item builder. See {@link DocumentListItemBuilder}\n */\n clone(withSpec?: PartialDocumentListItem): DocumentListItemBuilder {\n const builder = new DocumentListItemBuilder(this._context)\n builder.spec = {...this.spec, ...withSpec}\n return builder\n }\n}\n\n/** @internal */\nexport function isDocumentListItem(item: unknown): item is DocumentListItem {\n return isRecord(item) && typeof item.schemaType !== 'undefined' && typeof item._id === 'string'\n}\n","import {type SchemaType} from '@sanity/types'\n\nimport {DocumentListBuilder, type DocumentListInput, type PartialDocumentList} from './DocumentList'\nimport {type GenericListInput} from './GenericList'\nimport {DEFAULT_INTENT_HANDLER} from './Intent'\nimport {type Child} from './StructureNodes'\nimport {type StructureContext} from './types'\n\n/**\n * Interface for document type list input\n *\n * @public\n */\nexport interface DocumentTypeListInput extends Partial<GenericListInput> {\n /** Document type list input schema type. See {@link SchemaType} */\n schemaType: SchemaType | string\n}\n\n/**\n * Class for building a document type list\n *\n * @public\n */\nexport class DocumentTypeListBuilder extends DocumentListBuilder {\n /** Document list options. See {@link PartialDocumentList} */\n protected spec: PartialDocumentList\n\n constructor(\n /**\n * Structure context. See {@link StructureContext}\n */\n protected _context: StructureContext,\n spec?: DocumentListInput,\n ) {\n super(_context)\n this.spec = spec ? spec : {}\n }\n\n /**\n * Set Document type list child\n * @param child - Child component. See {@link Child}\n * @returns document type list builder based on child component provided without default intent handler. See {@link DocumentTypeListBuilder}\n */\n child(child: Child): DocumentTypeListBuilder {\n return this.cloneWithoutDefaultIntentHandler({child})\n }\n\n /** Clone Document type list builder (allows for options overriding)\n * @param withSpec - Document type list builder options. See {@link PartialDocumentList}\n * @returns document type list builder. See {@link DocumentTypeListBuilder}\n */\n clone(withSpec?: PartialDocumentList): DocumentTypeListBuilder {\n const parent = super.clone(withSpec)\n const builder = new DocumentTypeListBuilder(this._context)\n builder.spec = {...this.spec, ...parent.getSpec(), ...withSpec}\n return builder\n }\n\n /** Clone Document type list builder (allows for options overriding) and remove default intent handler\n * @param withSpec - Document type list builder options. See {@link PartialDocumentList}\n * @returns document type list builder without default intent handler. See {@link DocumentTypeListBuilder}\n */\n cloneWithoutDefaultIntentHandler(withSpec?: PartialDocumentList): DocumentTypeListBuilder {\n const parent = super.clone(withSpec)\n const builder = new DocumentTypeListBuilder(this._context)\n const canHandleIntent = this.spec.canHandleIntent\n const shouldOverride = canHandleIntent && canHandleIntent.identity === DEFAULT_INTENT_HANDLER\n const override = shouldOverride ? {canHandleIntent: undefined} : {}\n builder.spec = {\n ...parent.getSpec(),\n ...this.spec,\n ...withSpec,\n ...override,\n }\n return builder\n }\n}\n","import {StackCompactIcon, StackIcon} from '@sanity/icons'\nimport {type SchemaType} from '@sanity/types'\nimport {startCase} from 'lodash'\n\nimport {structureLocaleNamespace} from '../i18n'\nimport {type DocumentListBuilder} from './DocumentList'\nimport {DocumentTypeListBuilder, type DocumentTypeListInput} from './DocumentTypeList'\nimport {defaultIntentChecker} from './Intent'\nimport {type List} from './List'\nimport {type ListItem, ListItemBuilder} from './ListItem'\nimport {getOrderingMenuItemsForSchemaType, MenuItemBuilder} from './MenuItem'\nimport {DEFAULT_SELECTED_ORDERING_OPTION} from './Sort'\nimport {type Collection} from './StructureNodes'\nimport {type StructureContext} from './types'\n\nconst BUNDLED_DOC_TYPES = ['sanity.imageAsset', 'sanity.fileAsset']\n\nfunction isBundledDocType(typeName: string) {\n return BUNDLED_DOC_TYPES.includes(typeName)\n}\n\nfunction isDocumentType(schemaType: SchemaType) {\n return schemaType.type?.name === 'document'\n}\n\nfunction isList(collection: Collection): collection is List {\n return collection.type === 'list'\n}\n\nexport function getDocumentTypes({schema}: StructureContext): string[] {\n return schema\n .getTypeNames()\n .filter((n) => {\n const schemaType = schema.get(n)\n return schemaType && isDocumentType(schemaType)\n })\n .filter((n) => !isBundledDocType(n))\n}\n\nexport function getDocumentTypeListItems(context: StructureContext): ListItemBuilder[] {\n const types = getDocumentTypes(context)\n return types.map((typeName) => getDocumentTypeListItem(context, typeName))\n}\n\nexport function getDocumentTypeListItem(\n context: StructureContext,\n typeName: string,\n): ListItemBuilder {\n const {schema} = context\n\n const type = schema.get(typeName)\n if (!type) {\n throw new Error(`Schema type with name \"${typeName}\" not found`)\n }\n\n const title = type.title || startCase(typeName)\n\n return new ListItemBuilder(context)\n .id(typeName)\n .title(title)\n .schemaType(type)\n .child((id, childContext) => {\n const parent = childContext.parent as Collection\n const parentItem = isList(parent)\n ? (parent.items.find((item) => item.id === id) as ListItem)\n : null\n\n let list = getDocumentTypeList(context, typeName)\n if (parentItem && parentItem.title) {\n list = list.title(parentItem.title)\n }\n\n return list\n })\n}\n\nexport function getDocumentTypeList(\n context: StructureContext,\n typeNameOrSpec: string | DocumentTypeListInput,\n): DocumentListBuilder {\n const {schema, resolveDocumentNode} = context\n\n const schemaType = typeof typeNameOrSpec === 'string' ? typeNameOrSpec : typeNameOrSpec.schemaType\n const typeName = typeof schemaType === 'string' ? schemaType : schemaType.name\n const spec: DocumentTypeListInput =\n typeof typeNameOrSpec === 'string' ? {schemaType} : typeNameOrSpec\n\n const type = schema.get(typeName)\n if (!type) {\n throw new Error(`Schema type with name \"${typeName}\" not found`)\n }\n\n const title = type.title || startCase(typeName)\n\n return new DocumentTypeListBuilder(context)\n .id(spec.id || typeName)\n .title(spec.title || title)\n .filter('_type == $type')\n .params({type: typeName})\n .schemaType(type)\n .defaultOrdering(DEFAULT_SELECTED_ORDERING_OPTION.by)\n .menuItemGroups(\n spec.menuItemGroups || [\n {\n id: 'sorting',\n title: 'Sort',\n i18n: {title: {key: 'menu-item-groups.actions-group', ns: structureLocaleNamespace}},\n },\n {\n id: 'layout',\n title: 'Layout',\n i18n: {title: {key: 'menu-item-groups.layout-group', ns: structureLocaleNamespace}},\n },\n {\n id: 'actions',\n title: 'Actions',\n i18n: {title: {key: 'menu-item-groups.sorting-group', ns: structureLocaleNamespace}},\n },\n ],\n )\n .child(\n spec.child ||\n ((documentId: string) => resolveDocumentNode({schemaType: typeName, documentId})),\n )\n .canHandleIntent(spec.canHandleIntent || defaultIntentChecker)\n .menuItems(\n spec.menuItems || [\n // Create new (from action button) will be added in serialization step of GenericList\n\n // Sort by <Y>\n ...getOrderingMenuItemsForSchemaType(context, type),\n\n // Display as <Z>\n new MenuItemBuilder(context)\n .group('layout')\n .i18n({title: {key: 'menu-items.layout.compact-view', ns: structureLocaleNamespace}})\n .title('Compact view') // fallback title\n .icon(StackCompactIcon)\n .action('setLayout')\n .params({layout: 'default'}),\n\n new MenuItemBuilder(context)\n .group('layout')\n .i18n({title: {key: 'menu-items.layout.detailed-view', ns: structureLocaleNamespace}})\n .title('Detailed view') // fallback title\n .icon(StackIcon)\n .action('setLayout')\n .params({layout: 'detail'}),\n\n // Create new (from menu) will be added in serialization step of GenericList\n ],\n )\n}\n","import {type SchemaType} from '@sanity/types'\nimport {isValidElementType} from 'react-is'\nimport {\n getConfigContextFromSource,\n getPublishedId,\n type PerspectiveStack,\n type Source,\n} from 'sanity'\n\nimport {structureLocaleNamespace} from '../i18n'\nimport {ComponentBuilder, type ComponentInput} from './Component'\nimport {DividerBuilder} from './Divider'\nimport {DocumentBuilder, documentFromEditor, documentFromEditorWithInitialValue} from './Document'\nimport {DocumentListBuilder} from './DocumentList'\nimport {DocumentListItemBuilder} from './DocumentListItem'\nimport {\n getDocumentTypeList,\n getDocumentTypeListItem,\n getDocumentTypeListItems,\n} from './documentTypeListItems'\nimport {\n defaultInitialValueTemplateItems,\n InitialValueTemplateItemBuilder,\n menuItemsFromInitialValueTemplateItems,\n} from './InitialValueTemplateItem'\nimport {ListBuilder} from './List'\nimport {ListItemBuilder} from './ListItem'\nimport {getOrderingMenuItem, getOrderingMenuItemsForSchemaType, MenuItemBuilder} from './MenuItem'\nimport {MenuItemGroupBuilder} from './MenuItemGroup'\nimport {type Divider} from './StructureNodes'\nimport {\n type DefaultDocumentNodeResolver,\n type StructureBuilder,\n type StructureContext,\n type UserComponent,\n} from './types'\nimport * as views from './views'\n\n/** @internal */\nexport interface StructureBuilderOptions {\n source: Source\n defaultDocumentNode?: DefaultDocumentNodeResolver\n perspectiveStack: PerspectiveStack\n}\n\nfunction hasIcon(schemaType?: SchemaType | string): boolean {\n if (!schemaType || typeof schemaType === 'string') {\n return false\n }\n\n return Boolean(schemaType.icon)\n}\n\nfunction getDefaultStructure(context: StructureContext): ListBuilder {\n const items = getDocumentTypeListItems(context)\n return new ListBuilder(context)\n .id('__root__')\n .title('Content')\n .i18n({title: {key: 'default-definition.content-title', ns: structureLocaleNamespace}})\n .items(items)\n .showIcons(items.some((item) => hasIcon(item.getSchemaType())))\n}\n\n/** @internal */\nexport function createStructureBuilder({\n defaultDocumentNode,\n source,\n perspectiveStack,\n}: StructureBuilderOptions): StructureBuilder {\n const configContext = getConfigContextFromSource(source)\n const context: StructureContext = {\n ...source,\n getStructureBuilder: () => structureBuilder,\n resolveDocumentNode: (options) => {\n let builder =\n defaultDocumentNode?.(structureBuilder, {...options, ...configContext}) ||\n new DocumentBuilder(context)\n\n if (!builder.getId()) {\n builder = builder.id('documentEditor')\n }\n\n if (options.documentId) {\n builder = builder.documentId(getPublishedId(options.documentId))\n }\n\n return builder.schemaType(options.schemaType)\n },\n perspectiveStack,\n }\n\n const structureBuilder: StructureBuilder = {\n defaults: () => getDefaultStructure(context),\n documentTypeList: (...args) => getDocumentTypeList(context, ...args),\n documentTypeListItem: (...args) => getDocumentTypeListItem(context, ...args),\n documentTypeListItems: (...args) => getDocumentTypeListItems(context, ...args),\n document: (...args) => new DocumentBuilder(context, ...args),\n documentWithInitialValueTemplate: (...args) =>\n documentFromEditorWithInitialValue(context, ...args),\n defaultDocument: context.resolveDocumentNode,\n\n list: (...args) => new ListBuilder(context, ...args),\n listItem: (...args) => new ListItemBuilder(context, ...args),\n\n menuItem: (...args) => new MenuItemBuilder(context, ...args),\n menuItemGroup: (...args) => new MenuItemGroupBuilder(context, ...args),\n menuItemsFromInitialValueTemplateItems: (...args) =>\n menuItemsFromInitialValueTemplateItems(context, ...args),\n\n documentList: (...args) => new DocumentListBuilder(context, ...args),\n documentListItem: (...args) => new DocumentListItemBuilder(context, ...args),\n\n orderingMenuItem: (...args) => getOrderingMenuItem(context, ...args),\n orderingMenuItemsForType: (...args) => getOrderingMenuItemsForSchemaType(context, ...args),\n\n editor: (...args) => documentFromEditor(context, ...args),\n\n defaultInitialValueTemplateItems: (...args) =>\n defaultInitialValueTemplateItems(context, ...args),\n\n initialValueTemplateItem: (\n templateId: string,\n parameters?: Record<string, unknown>,\n ): InitialValueTemplateItemBuilder =>\n new InitialValueTemplateItemBuilder(context, {\n id: templateId,\n parameters,\n templateId,\n }),\n\n component: (spec?: ComponentInput | UserComponent) => {\n return isValidElementType(spec)\n ? new ComponentBuilder().component(spec as UserComponent)\n : new ComponentBuilder(spec as ComponentInput)\n },\n\n divider: (spec?: Divider) => new DividerBuilder(spec),\n\n view: views,\n context,\n }\n\n return structureBuilder\n}\n","import {type ReactNode, useMemo, useState} from 'react'\nimport {useConfigContextFromSource, useDocumentStore, usePerspective, useSource} from 'sanity'\nimport {StructureToolContext} from 'sanity/_singletons'\n\nimport {createStructureBuilder, type DefaultDocumentNodeResolver} from './structureBuilder'\nimport {\n type StructureResolver,\n type StructureToolContextValue,\n type UnresolvedPaneNode,\n} from './types'\n\n/** @internal */\nexport interface StructureToolProviderProps {\n structure?: StructureResolver\n defaultDocumentNode?: DefaultDocumentNodeResolver\n children: ReactNode\n}\n\n/** @internal */\nexport function StructureToolProvider({\n defaultDocumentNode,\n structure: resolveStructure,\n children,\n}: StructureToolProviderProps): React.JSX.Element {\n const [layoutCollapsed, setLayoutCollapsed] = useState(false)\n const source = useSource()\n const configContext = useConfigContextFromSource(source)\n const documentStore = useDocumentStore()\n\n const {perspectiveStack} = usePerspective()\n\n const S = useMemo(() => {\n return createStructureBuilder({\n defaultDocumentNode,\n source,\n perspectiveStack,\n })\n }, [defaultDocumentNode, source, perspectiveStack])\n\n const rootPaneNode = useMemo(() => {\n // TODO: unify types and remove cast\n if (resolveStructure)\n return resolveStructure(S, {\n ...configContext,\n documentStore,\n\n perspectiveStack,\n }) as UnresolvedPaneNode\n return S.defaults() as UnresolvedPaneNode\n }, [resolveStructure, S, configContext, documentStore, perspectiveStack])\n\n const features: StructureToolContextValue['features'] = useMemo(\n () => ({\n backButton: layoutCollapsed,\n resizablePanes: !layoutCollapsed,\n reviewChanges: !layoutCollapsed,\n splitPanes: !layoutCollapsed,\n splitViews: !layoutCollapsed,\n }),\n [layoutCollapsed],\n )\n\n const structureTool: StructureToolContextValue = useMemo(() => {\n return {\n features,\n layoutCollapsed,\n setLayoutCollapsed,\n rootPaneNode,\n structureContext: S.context,\n }\n }, [features, layoutCollapsed, rootPaneNode, S.context])\n\n return (\n <StructureToolContext.Provider value={structureTool}>{children}</StructureToolContext.Provider>\n )\n}\n"],"names":["structureLocaleNamespace","structureUsEnglishLocaleBundle","defineLocaleResourceBundle","locale","namespace","resources","IMPLICIT_SCHEMA_TYPE_FIELDS","joinReferences","schemaType","path","strict","head","tail","schemaField","fields","find","field","name","includes","errorMessage","map","join","Error","console","warn","type","refTypes","to","refType","tailFields","length","tailWrapper","getExtendedProjection","orderBy","ordering","split","SerializeError","constructor","message","parentPath","pathSegment","hint","helpId","segment","concat","withHelpUrl","id","HELP_URL","ID_REQUIRED","TITLE_REQUIRED","FILTER_REQUIRED","INVALID_LIST_ITEM","COMPONENT_REQUIRED","DOCUMENT_ID_REQUIRED","DOCUMENT_TYPE_REQUIRED","SCHEMA_TYPE_REQUIRED","SCHEMA_TYPE_NOT_FOUND","LIST_ITEMS_MUST_BE_ARRAY","QUERY_PROVIDED_FOR_FILTER","ACTION_OR_INTENT_REQUIRED","LIST_ITEM_IDS_MUST_BE_UNIQUE","ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE","API_VERSION_REQUIRED_FOR_CUSTOM_FILTER","ORDER_BY_UPDATED_AT","title","i18n","key","ns","by","direction","ORDER_BY_CREATED_AT","DEFAULT_SELECTED_ORDERING_OPTION","DEFAULT_ORDERING_OPTIONS","maybeSerializeMenuItem","item","index","MenuItemBuilder","serialize","_context","spec","action","clone","getAction","intent","getIntent","getTitle","getI18n","group","getGroup","icon","getIcon","params","getParams","showAsAction","Boolean","getShowAsAction","options","undefined","withSpec","builder","getOrderingMenuItem","context","extendedProjection","t","replace","SortIcon","getOrderingMenuItemsForSchemaType","typeName","schema","get","orderings","maybeSerializeMenuItemGroup","MenuItemGroupBuilder","_id","_title","_i18n","getId","disallowedPattern","validateId","disallowedChar","match","startsWith","getStructureNodeId","camelCased","camelCase","test","getSlug","ComponentBuilder","child","getChild","component","getComponent","getOptions","menuItems","getMenuItems","menuItemGroups","getMenuItemGroups","canHandleIntent","componentOptions","i","DividerBuilder","uniqueId","resolveTypeForDocument","getClient","DEFAULT_STUDIO_CLIENT_OPTIONS","fetch","publishedId","getPublishedId","tag","GenericViewBuilder","kebabCase","isSerializable","view","maybeSerializeView","isComponentSpec","isRecord","ComponentViewBuilder","componentOrSpec","userComponent","base","FormViewBuilder","form","createDocumentChildResolver","resolveDocumentNode","itemId","slice","currentSegment","documentId","DocumentBuilder","paneId","getDocumentId","_a","documentType","getSchemaType","initialValueTemplate","templateId","parameters","template","templateParameters","getInitialValueTemplate","getInitialValueTemplateParameters","views","getViews","urlId","viewIds","dupes","uniq","filter","viewId","getDocumentOptions","opts","documentFromEditor","doc","documentFromEditorWithInitialValue","templates","InitialValueTemplateItemBuilder","description","getDescription","getTemplateId","getParameters","subtitle","initialDocumentId","defaultInitialValueTemplateItems","getStructureBuilder","typeNames","getTypeNames","ordered","tpl","sort","a","b","indexOf","initialValueTemplateItem","maybeSerializeInitialValueTemplateItem","menuItemsFromInitialValueTemplateItems","templateItems","intentParams","AddIcon","DEFAULT_INTENT_HANDLER","Symbol","defaultIntentChecker","intentName","pane","isEdit","isCreate","typedSpec","paneFilter","paneParams","schemaTypeName","getTypeNamesFromFilter","initialValueTemplates","some","identity","layoutOptions","noChildResolver","shallowIntentChecker","GenericListBuilder","initialValueTemplatesSpecified","defaultLayout","getDefaultLayout","getCanHandleIntent","showIcons","enabled","displayOptions","getShowIcons","Array","isArray","getInitialValueTemplates","validateFilter","trim","createDocumentChildResolverForItem","parentItem","parent","Promise","resolve","then","DocumentListBuilder","apiVersion","getApiVersion","getFilter","defaultOrdering","getDefaultOrdering","generateHelpUrl","inferInitialValueTemplates","inferTypeName","getSpec","document","from","Set","flatMap","resolveNewDocumentOptions","option","getTypeNamesFromEqualityFilter","getTypeNamesFromInTypesFilter","pattern","matches","exec","push","candidate","getArgType","thing","ListBuilder","isPromise","isListItem","defaultCanHandleIntent","items","isDocumentListItem","resolveChildForItem","target","maybeSerializeListItem","ListItemBuilder","listItem","gotWhat","helpText","getItems","serializedItems","val","dupeIds","dupeDesc","showIcon","getShowIcon","titleIsOptional","serializeOptions","listChild","originalChild","childOptions","createDefaultChildResolver","DocumentListItemBuilder","DocumentTypeListBuilder","cloneWithoutDefaultIntentHandler","override","BUNDLED_DOC_TYPES","isBundledDocType","isDocumentType","isList","collection","getDocumentTypes","n","getDocumentTypeListItems","getDocumentTypeListItem","startCase","childContext","list","getDocumentTypeList","typeNameOrSpec","StackCompactIcon","layout","StackIcon","hasIcon","getDefaultStructure","createStructureBuilder","defaultDocumentNode","source","perspectiveStack","configContext","getConfigContextFromSource","structureBuilder","defaults","documentTypeList","args","documentTypeListItem","documentTypeListItems","documentWithInitialValueTemplate","defaultDocument","menuItem","menuItemGroup","documentList","documentListItem","orderingMenuItem","orderingMenuItemsForType","editor","isValidElementType","divider","StructureToolProvider","structure","resolveStructure","children","layoutCollapsed","setLayoutCollapsed","useState","useSource","useConfigContextFromSource","documentStore","useDocumentStore","usePerspective","S","useMemo","rootPaneNode","features","backButton","resizablePanes","reviewChanges","splitPanes","splitViews","structureTool","structureContext","StructureToolContext"],"mappings":";;;;;;;;;;AAOO,MAAMA,IAA2B,aAO3BC,KAAiCC,GAA2B;AAAA,EACvEC,QAAQ;AAAA,EACRC,WAAWJ;AAAAA,EACXK,WAAWA,MAAM,OAAO,0BAAa;AACvC,CAAC,GChBKC,KAA8B,CAAC,OAAO,SAAS,cAAc,cAAc,MAAM;AAGvF,SAASC,EAAeC,GAAwBC,GAAgBC,IAAkB,IAAe;AAC/F,QAAM,CAACC,GAAM,GAAGC,CAAI,IAAIH;AAEpB,MAAA,EAAE,YAAYD;AACT,WAAA;AAGT,QAAMK,IAAcL,EAAWM,OAAOC,KAAMC,CAAUA,MAAAA,EAAMC,SAASN,CAAI;AACzE,MAAI,CAACE,GAAa;AAChB,QAAI,CAACP,GAA4BY,SAASP,CAAI,GAAG;AAC/C,YAAMQ,IAAe,+DAA+DR,CAAI,qBAAqBH,EAAWS,IAAI,0BAA0BT,EAAWM,OAAOM,IAAKJ,OAAUA,EAAMC,IAAI,EAAEI,KAAK,IAAI,CAAC;AAC7M,UAAIX;AACI,cAAA,IAAIY,MAAMH,CAAY;AAG5BI,cAAQC,KAAKL,CAAY;AAAA,IAC3B;AAEK,WAAA;AAAA,EAAA;AAGT,MAAI,QAAQN,EAAYY,QAAQZ,EAAYY,KAAKR,SAAS,aAAa;AAC/DS,UAAAA,IAAWb,EAAYY,KAAKE;AAClC,WAAO,GAAGhB,CAAI,MAAMe,EAASN,IAAKQ,CAAAA,MAAYrB,EAAeqB,GAAShB,CAAI,CAAC,EAAES,KAAK,GAAG,CAAC;AAAA,EAAA;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A,EACtB,IACC,CAAC2Q,GAAUX,GAAiBU,GAAcF,EAAExQ,OAAO,CAAC;AAEvD,4BACGmR,GAAqB,UAArB,EAA8B,OAAOF,GAAgBlB,UAAAA,GAAS;AAEnE;"}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
var h = Object.defineProperty;
|
2
|
+
var u = (e, t, r) => t in e ? h(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
3
|
+
var p = (e, t, r) => u(e, typeof t != "symbol" ? t + "" : t, r);
|
4
|
+
import { jsx as s, jsxs as _ } from "react/jsx-runtime";
|
5
|
+
import { d } from "./index-C9NvTy6s.mjs";
|
6
|
+
import { H as D, C as S, a as E, S as v, T as b } from "./v4-zH-CAum7.mjs";
|
7
|
+
import { useState as w, useEffect as V } from "react";
|
8
|
+
const m = "Dev server stopped", g = "The development server has stopped. You may need to restart it to continue working.";
|
9
|
+
class y extends Error {
|
10
|
+
constructor() {
|
11
|
+
super(m);
|
12
|
+
p(this, "ViteDevServerStoppedError");
|
13
|
+
this.name = "ViteDevServerStoppedError", this.ViteDevServerStoppedError = !0;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
const l = void 0, f = (e) => !!e, R = () => {
|
17
|
+
const e = d.c(5), [t, r] = w(!1);
|
18
|
+
let o;
|
19
|
+
e[0] === Symbol.for("react.memo_cache_sentinel") ? (o = () => r(!0), e[0] = o) : o = e[0];
|
20
|
+
const a = o;
|
21
|
+
let n, i;
|
22
|
+
e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = () => {
|
23
|
+
f(l) && l.on("vite:ws:disconnect", a);
|
24
|
+
}, i = [a], e[1] = n, e[2] = i) : (n = e[1], i = e[2]), V(n, i);
|
25
|
+
let c;
|
26
|
+
return e[3] !== t ? (c = {
|
27
|
+
devServerStopped: t
|
28
|
+
}, e[3] = t, e[4] = c) : c = e[4], c;
|
29
|
+
}, T = () => {
|
30
|
+
const {
|
31
|
+
devServerStopped: e
|
32
|
+
} = R();
|
33
|
+
if (e)
|
34
|
+
throw new y();
|
35
|
+
return null;
|
36
|
+
}, O = () => {
|
37
|
+
const e = d.c(1);
|
38
|
+
let t;
|
39
|
+
return e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = f(l) ? /* @__PURE__ */ s(T, {}) : null, e[0] = t) : t = e[0], t;
|
40
|
+
}, $ = () => {
|
41
|
+
const e = d.c(3);
|
42
|
+
let t;
|
43
|
+
e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = [4, 5, 6, 7], e[0] = t) : t = e[0];
|
44
|
+
let r;
|
45
|
+
e[1] === Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ s(D, { children: m }), e[1] = r) : r = e[1];
|
46
|
+
let o;
|
47
|
+
return e[2] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ s(S, { height: "fill", overflow: "auto", paddingY: t, paddingX: 4, sizing: "border", tone: "critical", children: /* @__PURE__ */ s(E, { width: 3, children: /* @__PURE__ */ _(v, { space: 4, children: [
|
48
|
+
r,
|
49
|
+
/* @__PURE__ */ s(S, { border: !0, radius: 2, overflow: "auto", padding: 4, tone: "inherit", children: /* @__PURE__ */ s(v, { space: 4, children: /* @__PURE__ */ s(b, { size: 2, children: g }) }) })
|
50
|
+
] }) }) }), e[2] = o) : o = e[2], o;
|
51
|
+
};
|
52
|
+
export {
|
53
|
+
O as DetectViteDevServerStopped,
|
54
|
+
$ as DevServerStoppedErrorScreen,
|
55
|
+
y as ViteDevServerStoppedError
|
56
|
+
};
|
57
|
+
//# sourceMappingURL=ViteDevServerStopped-CgIEqy9p.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ViteDevServerStopped-CgIEqy9p.mjs","sources":["../src/core/studio/ViteDevServerStopped.tsx"],"sourcesContent":["/* eslint-disable i18next/no-literal-string -- will not support i18n in error boundaries */\nimport {Card, Container, Heading, Stack, Text} from '@sanity/ui'\nimport {type ReactNode, useCallback, useEffect, useState} from 'react'\nimport {type ViteHotContext} from 'vite/types/hot.js'\n\nconst ERROR_TITLE = 'Dev server stopped'\nconst ERROR_DESCRIPTION =\n 'The development server has stopped. You may need to restart it to continue working.'\n\nexport class ViteDevServerStoppedError extends Error {\n ViteDevServerStoppedError: boolean\n\n constructor() {\n super(ERROR_TITLE)\n this.name = 'ViteDevServerStoppedError'\n this.ViteDevServerStoppedError = true\n }\n}\nconst serverHot = import.meta.hot\nconst isViteServer = (hot: unknown): hot is ViteHotContext => Boolean(hot)\n\nconst useDetectViteDevServerStopped = () => {\n const [devServerStopped, setDevServerStopped] = useState(false)\n\n const markDevServerStopped = useCallback(() => setDevServerStopped(true), [])\n\n useEffect(() => {\n // no early return to optimize tree-shaking\n if (isViteServer(serverHot)) {\n serverHot.on('vite:ws:disconnect', markDevServerStopped)\n }\n }, [markDevServerStopped])\n\n return {devServerStopped}\n}\n\nconst ThrowViteServerStopped = () => {\n const {devServerStopped} = useDetectViteDevServerStopped()\n\n if (devServerStopped) throw new ViteDevServerStoppedError()\n\n return null\n}\n\nexport const DetectViteDevServerStopped = (): ReactNode =>\n isViteServer(serverHot) ? <ThrowViteServerStopped /> : null\n\nexport const DevServerStoppedErrorScreen = (): ReactNode => (\n <Card\n height=\"fill\"\n overflow=\"auto\"\n paddingY={[4, 5, 6, 7]}\n paddingX={4}\n sizing=\"border\"\n tone=\"critical\"\n >\n <Container width={3}>\n <Stack space={4}>\n <Heading>{ERROR_TITLE}</Heading>\n\n <Card border radius={2} overflow=\"auto\" padding={4} tone=\"inherit\">\n <Stack space={4}>\n <Text size={2}>{ERROR_DESCRIPTION}</Text>\n </Stack>\n </Card>\n </Stack>\n </Container>\n </Card>\n)\n"],"names":["ERROR_TITLE","ERROR_DESCRIPTION","ViteDevServerStoppedError","Error","constructor","name","serverHot","import","isViteServer","hot","Boolean","useDetectViteDevServerStopped","$","_c","devServerStopped","setDevServerStopped","useState","t0","Symbol","for","markDevServerStopped","t1","t2","on","useEffect","t3","ThrowViteServerStopped","DetectVi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a = "https://www.sanity.io/help/missing-context-error";
|
4
|
+
function p(n, i) {
|
5
|
+
const e = Symbol.for(n);
|
6
|
+
if (typeof document > "u" || typeof window < "u" && typeof window.navigator < "u" && window.navigator.userAgent.includes("jsdom")) {
|
7
|
+
const r = s(i);
|
8
|
+
return r.displayName = n, r;
|
9
|
+
}
|
10
|
+
if (!t[e])
|
11
|
+
t[e] = {
|
12
|
+
context: s(i),
|
13
|
+
version: o
|
14
|
+
};
|
15
|
+
else {
|
16
|
+
if (t[e].version !== o)
|
17
|
+
throw new TypeError(`Duplicate instances of context "${n}" with incompatible versions detected: Expected ${o} but got ${t[e].version}.
|
18
|
+
|
19
|
+
For more information, please visit ${a}`);
|
20
|
+
c.has(o) || (console.warn(`Duplicate instances of context "${n}" detected. This is likely a mistake and may cause unexpected behavior.
|
21
|
+
|
22
|
+
For more information, please visit ${a}`), c.add(o));
|
23
|
+
}
|
24
|
+
return t[e].context;
|
25
|
+
}
|
26
|
+
const c = /* @__PURE__ */ new Set();
|
27
|
+
function d() {
|
28
|
+
if (typeof globalThis < "u") return globalThis;
|
29
|
+
if (typeof window < "u") return window;
|
30
|
+
if (typeof self < "u") return self;
|
31
|
+
if (typeof global < "u") return global;
|
32
|
+
throw new Error("sanity: could not locate global scope");
|
33
|
+
}
|
34
|
+
const t = d();
|
35
|
+
export {
|
36
|
+
p as createContext
|
37
|
+
};
|
38
|
+
//# sourceMappingURL=_createContext.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"_createContext.mjs","sources":["../src/_createContext/createGlobalScopedContext.ts"],"sourcesContent":["import {type Context, createContext} from 'react'\n\nimport {SANITY_VERSION} from '../core/version'\n\nconst MISSING_CONTEXT_HELP_URL = 'https://www.sanity.io/help/missing-context-error'\n\n/**\n * @internal\n * @hidden\n */\nexport function createGlobalScopedContext<ContextType, const T extends ContextType = ContextType>(\n /**\n * It's important to prefix these keys as they are global\n */\n key: `sanity/_singletons/context/${string}`,\n defaultValue: T,\n): Context<ContextType> {\n const symbol = Symbol.for(key)\n\n /**\n * Prevent errors about re-renders on React SSR on Next.js App Router, as well as JSDOM-based\n * environments such as when we extract schemas etc from the studio configuration.\n */\n if (\n typeof document === 'undefined' ||\n (typeof window !== 'undefined' &&\n typeof window.navigator !== 'undefined' &&\n window.navigator.userAgent.includes('jsdom'))\n ) {\n const context = createContext<ContextType>(defaultValue)\n context.displayName = key\n return context\n }\n\n if (!globalScope[symbol]) {\n globalScope[symbol] = {context: createContext<T>(defaultValue), version: SANITY_VERSION}\n } else if (globalScope[symbol].version !== SANITY_VERSION) {\n throw new TypeError(\n `Duplicate instances of context \"${key}\" with incompatible versions detected: Expected ${SANITY_VERSION} but got ${globalScope[symbol].version}.\\n\\n` +\n `For more information, please visit ${MISSING_CONTEXT_HELP_URL}`,\n )\n } else if (!warned.has(SANITY_VERSION)) {\n console.warn(\n `Duplicate instances of context \"${key}\" detected. This is likely a mistake and may cause unexpected behavior.\\n\\n` +\n `For more information, please visit ${MISSING_CONTEXT_HELP_URL}`,\n )\n warned.add(SANITY_VERSION)\n }\n\n return globalScope[symbol].context\n}\n\nconst warned = new Set<typeof SANITY_VERSION>()\n\n/**\n * Gets the global scope instance in a given environment.\n *\n * The strategy is to return the most modern, and if not, the most common:\n * - The `globalThis` variable is the modern approach to accessing the global scope\n * - The `window` variable is the global scope in a web browser\n * - The `self` variable is the global scope in workers and others\n * - The `global` variable is the global scope in Node.js\n */\nfunction getGlobalScope() {\n if (typeof globalThis !== 'undefined') return globalThis\n if (typeof window !== 'undefined') return window\n if (typeof self !== 'undefined') return self\n if (typeof global !== 'undefined') return global\n\n throw new Error('sanity: could not locate global scope')\n}\n\nconst globalScope = getGlobalScope() as any\n"],"names":["MISSING_CONTEXT_HELP_URL","createGlobalScopedContext","key","defaultValue","symbol","Symbol","for","document","window","navigator","userAgent","includes","context","createContext","displayName","globalScope","version","SANITY_VERSION","TypeError","warned","has","warn","add","Set","getGlobalScope","globalThis","self","global","Error"],"mappings":";;AAIA,MAAMA,IAA2B;AAMjBC,SAAAA,EAIdC,GACAC,GACsB;AAChBC,QAAAA,IAASC,OAAOC,IAAIJ,CAAG;AAM7B,MACE,OAAOK,WAAa,OACnB,OAAOC,SAAW,OACjB,OAAOA,OAAOC,YAAc,OAC5BD,OAAOC,UAAUC,UAAUC,SAAS,OAAO,GAC7C;AACMC,UAAAA,IAAUC,EAA2BV,CAAY;AACvDS,WAAAA,EAAQE,cAAcZ,GACfU;AAAAA,EAAAA;AAGL,MAAA,CAACG,EAAYX,CAAM;AACrBW,IAAAA,EAAYX,CAAM,IAAI;AAAA,MAACQ,SAASC,EAAiBV,CAAY;AAAA,MAAGa,SAASC;AAAAA,IAAc;AAAA,OAC9EF;AAAAA,QAAAA,EAAYX,CAAM,EAAEY,YAAYC;AACnC,YAAA,IAAIC,UACR,mCAAmChB,CAAG,mDAAmDe,CAAc,YAAYF,EAAYX,CAAM,EAAEY,OAAO;AAAA;AAAA,qCACtGhB,CAAwB,EAClE;AACS,IAACmB,EAAOC,IAAIH,CAAc,MAC3BI,QAAAA,KACN,mCAAmCnB,CAAG;AAAA;AAAA,qCACEF,CAAwB,EAClE,GACAmB,EAAOG,IAAIL,CAAc;AAAA;AAGpBF,SAAAA,EAAYX,CAAM,EAAEQ;AAC7B;AAEA,MAAMO,wBAAaI,IAA2B;AAW9C,SAASC,IAAiB;AACpB,MAAA,OAAOC,aAAe,IAAoBA,QAAAA;AAC1C,MAAA,OAAOjB,SAAW,IAAoBA,QAAAA;AACtC,MAAA,OAAOkB,OAAS,IAAoBA,QAAAA;AACpC,MAAA,OAAOC,SAAW,IAAoBA,QAAAA;AAEpC,QAAA,IAAIC,MAAM,uCAAuC;AACzD;AAEA,MAAMb,IAAcS,EAAe;"}
|