sanity 3.94.1 → 3.94.2-next.0.91a5116c07
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/lib/_chunks-cjs/version.js +1 -1
- package/lib/_chunks-es/version.mjs +1 -1
- package/package.json +25 -25
- package/dist/BehaviorSubject-CU-WJrzA.mjs +0 -30
- package/dist/BehaviorSubject-CU-WJrzA.mjs.map +0 -1
- package/dist/BroadcastDisplayedDocument-BSV9T3BU.mjs +0 -20
- package/dist/BroadcastDisplayedDocument-BSV9T3BU.mjs.map +0 -1
- package/dist/DisplayedDocumentBroadcaster-DZ65n35Q.mjs +0 -62
- package/dist/DisplayedDocumentBroadcaster-DZ65n35Q.mjs.map +0 -1
- package/dist/LiveQueries-Crz53eU5.mjs +0 -407
- package/dist/LiveQueries-Crz53eU5.mjs.map +0 -1
- package/dist/Observable-CCQtH8Gg.mjs +0 -546
- package/dist/Observable-CCQtH8Gg.mjs.map +0 -1
- package/dist/PostMessageDocuments-BjgsJxz4.mjs +0 -72
- package/dist/PostMessageDocuments-BjgsJxz4.mjs.map +0 -1
- package/dist/PostMessagePerspective-pucY-E6a.mjs +0 -22
- package/dist/PostMessagePerspective-pucY-E6a.mjs.map +0 -1
- package/dist/PostMessagePreviewSnapshots-CRQgRg4_.mjs +0 -71
- package/dist/PostMessagePreviewSnapshots-CRQgRg4_.mjs.map +0 -1
- package/dist/PostMessageRefreshMutations-D944RbO3.mjs +0 -66
- package/dist/PostMessageRefreshMutations-D944RbO3.mjs.map +0 -1
- package/dist/PostMessageSchema-3eOtr1bs.mjs +0 -516
- package/dist/PostMessageSchema-3eOtr1bs.mjs.map +0 -1
- package/dist/PostMessageTelemetry-DMTQDJeN.mjs +0 -20
- package/dist/PostMessageTelemetry-DMTQDJeN.mjs.map +0 -1
- package/dist/PresentationToolGrantsCheck-B0q4AQ3b.mjs +0 -3999
- package/dist/PresentationToolGrantsCheck-B0q4AQ3b.mjs.map +0 -1
- package/dist/QRCodeSVG-hyTW2xeN.mjs +0 -648
- package/dist/QRCodeSVG-hyTW2xeN.mjs.map +0 -1
- package/dist/Refractor-Zss2QEe8.mjs +0 -2568
- package/dist/Refractor-Zss2QEe8.mjs.map +0 -1
- package/dist/SourceContext-QxJD1Wrm.mjs +0 -111
- package/dist/SourceContext-QxJD1Wrm.mjs.map +0 -1
- package/dist/StructureToolProvider-B-7cwz7l.mjs +0 -2287
- package/dist/StructureToolProvider-B-7cwz7l.mjs.map +0 -1
- package/dist/ViteDevServerStopped-CgIEqy9p.mjs +0 -57
- package/dist/ViteDevServerStopped-CgIEqy9p.mjs.map +0 -1
- package/dist/_createContext.mjs +0 -38
- package/dist/_createContext.mjs.map +0 -1
- package/dist/_singletons.mjs +0 -216
- package/dist/_singletons.mjs.map +0 -1
- package/dist/browser-B0Q9qZJS.mjs +0 -478
- package/dist/browser-B0Q9qZJS.mjs.map +0 -1
- package/dist/browser-DmX5VEcE.mjs +0 -324
- package/dist/browser-DmX5VEcE.mjs.map +0 -1
- package/dist/desk.mjs +0 -53
- package/dist/desk.mjs.map +0 -1
- package/dist/first-Cz545eV-.mjs +0 -42
- package/dist/first-Cz545eV-.mjs.map +0 -1
- package/dist/index-B2GCDfau.mjs +0 -96
- package/dist/index-B2GCDfau.mjs.map +0 -1
- package/dist/index-BRIelBPK.mjs +0 -6946
- package/dist/index-BRIelBPK.mjs.map +0 -1
- package/dist/index-BUB137yJ.mjs +0 -144
- package/dist/index-BUB137yJ.mjs.map +0 -1
- package/dist/index-C3PGPrdL.mjs +0 -1192
- package/dist/index-C3PGPrdL.mjs.map +0 -1
- package/dist/index-C9NvTy6s.mjs +0 -319
- package/dist/index-C9NvTy6s.mjs.map +0 -1
- package/dist/index-DCkQlgdi.mjs +0 -4001
- package/dist/index-DCkQlgdi.mjs.map +0 -1
- package/dist/index-DG-3plB0.mjs +0 -71
- package/dist/index-DG-3plB0.mjs.map +0 -1
- package/dist/index-RoxwhtVB.mjs +0 -5600
- package/dist/index-RoxwhtVB.mjs.map +0 -1
- package/dist/index-iMZR29eF.mjs +0 -756
- package/dist/index-iMZR29eF.mjs.map +0 -1
- package/dist/index-wVXq9rWS.mjs +0 -244
- package/dist/index-wVXq9rWS.mjs.map +0 -1
- package/dist/index.mjs +0 -137385
- package/dist/index.mjs.map +0 -1
- package/dist/lodash-Vz5dH_Dm.mjs +0 -3679
- package/dist/lodash-Vz5dH_Dm.mjs.map +0 -1
- package/dist/pane-Bm_57XKB.mjs +0 -5
- package/dist/pane-Bm_57XKB.mjs.map +0 -1
- package/dist/pane-Dopl4BjD.mjs +0 -5
- package/dist/pane-Dopl4BjD.mjs.map +0 -1
- package/dist/presentation-DsIky7Cj.mjs +0 -556
- package/dist/presentation-DsIky7Cj.mjs.map +0 -1
- package/dist/presentation.mjs +0 -10
- package/dist/presentation.mjs.map +0 -1
- package/dist/publishReplay-PuJoYJpp.mjs +0 -92
- package/dist/publishReplay-PuJoYJpp.mjs.map +0 -1
- package/dist/refractor-Bg1S3YDK.mjs +0 -26
- package/dist/refractor-Bg1S3YDK.mjs.map +0 -1
- package/dist/resources-BQsCEzu1.mjs +0 -60
- package/dist/resources-BQsCEzu1.mjs.map +0 -1
- package/dist/resources-BahMtJuO.mjs +0 -177
- package/dist/resources-BahMtJuO.mjs.map +0 -1
- package/dist/resources-CjkBN4z6.mjs +0 -126
- package/dist/resources-CjkBN4z6.mjs.map +0 -1
- package/dist/resources-Dc-6ZcPg.mjs +0 -157
- package/dist/resources-Dc-6ZcPg.mjs.map +0 -1
- package/dist/resources-DqxSuDsr.mjs +0 -37
- package/dist/resources-DqxSuDsr.mjs.map +0 -1
- package/dist/resources-_gTjFWLH.mjs +0 -517
- package/dist/resources-_gTjFWLH.mjs.map +0 -1
- package/dist/resources-kA1bao30.mjs +0 -358
- package/dist/resources-kA1bao30.mjs.map +0 -1
- package/dist/router.mjs +0 -721
- package/dist/router.mjs.map +0 -1
- package/dist/stegaEncodeSourceMap-DCG9Ba1H.mjs +0 -358
- package/dist/stegaEncodeSourceMap-DCG9Ba1H.mjs.map +0 -1
- package/dist/structure.mjs +0 -57
- package/dist/structure.mjs.map +0 -1
- package/dist/structureTool-Bth1vd8r.mjs +0 -13150
- package/dist/structureTool-Bth1vd8r.mjs.map +0 -1
- package/dist/switchMap-DHVUskpL.mjs +0 -54
- package/dist/switchMap-DHVUskpL.mjs.map +0 -1
- package/dist/v4-zH-CAum7.mjs +0 -24798
- package/dist/v4-zH-CAum7.mjs.map +0 -1
- package/dist/version-DoE_JnhG.mjs +0 -5
- package/dist/version-DoE_JnhG.mjs.map +0 -1
package/dist/router.mjs.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"router.mjs","sources":["../src/router/useRouter.ts","../src/router/useLink.ts","../src/router/useIntentLink.ts","../src/router/IntentLink.tsx","../src/router/Link.tsx","../src/router/_parseRoute.ts","../src/router/utils/arrayify.ts","../src/router/_findMatchingRoutes.ts","../src/router/encodeURIComponentExcept.ts","../src/router/utils/debug.ts","../src/router/_resolvePathFromState.ts","../src/router/utils/parseScopedParams.ts","../src/router/_resolveStateFromPath.ts","../src/router/utils/base64url.ts","../src/router/utils/jsonParamsEncoding.ts","../src/router/utils/paramsEncoding.ts","../src/router/route.ts","../src/router/stickyParams.ts","../src/router/types.ts","../src/router/RouterProvider.tsx","../src/router/RouteScope.tsx","../src/router/useStateLink.ts","../src/router/StateLink.tsx","../src/router/useRouterState.ts","../src/router/withRouter.tsx"],"sourcesContent":["import {useContext} from 'react'\nimport {RouterContext} from 'sanity/_singletons'\n\nimport {type RouterContextValue} from './types'\n\n/**\n * Returns the router context value.\n * @public\n *\n * @returns The router context value.\n * {@link RouterContextValue}\n * @throws An error if the router context value is missing.\n *\n * @example\n * ```tsx\n * const router = useRouter()\n * ```\n */\nexport function useRouter(): RouterContextValue {\n const router = useContext(RouterContext)\n\n if (!router) {\n throw new Error('Router: missing context value')\n }\n\n return router\n}\n","import {useCallback} from 'react'\n\nimport {useRouter} from './useRouter'\n\nfunction isLeftClickEvent(event: React.MouseEvent) {\n return event.button === 0\n}\n\nfunction isModifiedEvent(event: React.MouseEvent) {\n return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)\n}\n\n/**\n * @public\n */\nexport interface UseLinkOptions {\n /**\n * The URL that the link should navigate to.\n */\n href?: string\n\n /**\n * The event handler function that should be called when the link is clicked.\n */\n onClick?: React.MouseEventHandler<HTMLElement>\n\n /**\n * Whether the link should replace the current URL in the browser history.\n */\n replace?: boolean\n\n /**\n * The target window or frame that the linked document will open in.\n */\n target?: string\n}\n\n/**\n * Returns an object with an `onClick` function that can be used as a click handler for a link.\n *\n * @public\n *\n * @param options - An object containing the properties for the link.\n * See {@link UseLinkOptions}\n *\n * @returns An object with an `onClick` function.\n *\n * @example\n * ```tsx\n * const linkProps = useLink({\n * href: 'https://www.sanity.io',\n * target: '_blank'\n * })\n *\n * <a {...linkProps}>Link</a>\n * ```\n */\nexport function useLink(options: UseLinkOptions): {onClick: React.MouseEventHandler<HTMLElement>} {\n const {onClick: onClickProp, href, target, replace = false} = options\n const {navigateUrl} = useRouter()\n\n const onClick = useCallback(\n (event: React.MouseEvent<HTMLElement>): void => {\n if (event.isDefaultPrevented()) {\n return\n }\n\n if (!href) return\n\n if (onClickProp) {\n onClickProp(event)\n }\n\n if (isModifiedEvent(event) || !isLeftClickEvent(event)) {\n return\n }\n\n // If target prop is set (e.g. to \"_blank\") let browser handle link.\n if (target) {\n return\n }\n\n event.preventDefault()\n\n navigateUrl({path: href, replace})\n },\n [href, navigateUrl, onClickProp, replace, target],\n )\n\n return {onClick: onClick}\n}\n","import {useMemo} from 'react'\n\nimport {type IntentParameters, type SearchParam} from './types'\nimport {useLink} from './useLink'\nimport {useRouter} from './useRouter'\n\n/**\n * @public\n */\nexport interface UseIntentLinkOptions {\n /**\n * The name of the intent to trigger.\n */\n intent: string\n\n /**\n * An optional click event handler.\n */\n onClick?: React.MouseEventHandler<HTMLElement>\n\n /**\n * Optional parameters to pass to the intent. See {@link IntentParameters}\n */\n params?: IntentParameters\n\n /**\n * Whether to replace the current URL in the browser history.\n */\n replace?: boolean\n\n /**\n * The target window or frame to open the link in.\n */\n target?: string\n searchParams?: SearchParam[]\n}\n\n/**\n *\n * Returns props for an anchor element that will trigger an intent when clicked.\n *\n * @example\n * ```tsx\n * const {onClick, href} = useIntentLink({\n * intent: 'edit',\n * params: {id: 'foo'}\n * })\n *\n * <a href={href} onClick={onClick}>Link to \"foo\" editor</a>\n * ```\n *\n * @public\n *\n * @param options - Options to use for the link\n * {@link UseIntentLinkOptions}\n *\n * @returns - An object with `onClick` and `href` props to use for the link\n */\nexport function useIntentLink(options: UseIntentLinkOptions): {\n onClick: React.MouseEventHandler<HTMLElement>\n href: string\n} {\n const {intent, onClick: onClickProp, params, replace, target, searchParams} = options\n const {resolveIntentLink} = useRouter()\n const href = useMemo(\n () => resolveIntentLink(intent, params, searchParams),\n [intent, params, searchParams, resolveIntentLink],\n )\n const {onClick} = useLink({href, onClick: onClickProp, replace, target})\n\n return {onClick, href}\n}\n","import {type ForwardedRef, forwardRef, type HTMLProps} from 'react'\n\nimport {type IntentParameters, type SearchParam} from './types'\nimport {useIntentLink} from './useIntentLink'\n\n/**\n * Props for the {@link IntentLink} component.\n *\n * @public\n */\nexport interface IntentLinkProps {\n /**\n * The name of the intent.\n */\n intent: string\n\n /**\n * The parameters to include in the intent.\n * {@link IntentParameters}\n */\n params?: IntentParameters\n\n /**\n * Whether to replace the current URL in the browser history instead of adding a new entry.\n */\n replace?: boolean\n\n /**\n * search params to include in the intent.\n */\n searchParams?: SearchParam[]\n}\n\n/**\n * @public\n *\n * @param props - Props to pass to `IntentLink` component.\n * See {@link IntentLinkProps}\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * return <IntentLink intent=\"edit\" params={{id: 'abc123'}}>Edit</IntentLink>\n * }\n * ```\n */\nexport const IntentLink = forwardRef(function IntentLink(\n props: IntentLinkProps & HTMLProps<HTMLAnchorElement>,\n ref: ForwardedRef<HTMLAnchorElement>,\n) {\n const {intent, params, target, searchParams, ...restProps} = props\n const {onClick, href} = useIntentLink({\n intent,\n params,\n target,\n onClick: props.onClick,\n searchParams,\n })\n\n return <a {...restProps} href={href} onClick={onClick} ref={ref} target={target} />\n})\n","import {type ForwardedRef, forwardRef, type HTMLProps} from 'react'\n\nimport {useLink} from './useLink'\n\n/**\n * Props for the {@link Link} component.\n *\n * @public\n */\nexport interface LinkProps {\n /**\n * Whether to replace the current URL in the browser history instead of adding a new entry.\n */\n replace?: boolean\n}\n\n/**\n * A component that creates an HTML anchor element.\n *\n * @public\n *\n * @param props - Props to pass to the `Link` component.\n * See {@link LinkProps}\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * return (\n * <Link href=\"https://www.sanity.io\" target=\"_blank\" replace>\n * Go to Sanity\n * </Link>\n * )\n * }\n * ```\n */\nexport const Link = forwardRef(function Link(\n props: LinkProps & HTMLProps<HTMLAnchorElement>,\n ref: ForwardedRef<HTMLAnchorElement>,\n) {\n const {onClick: onClickProp, href, target, replace, ...restProps} = props\n const {onClick} = useLink({onClick: onClickProp, href, target, replace})\n\n return <a {...restProps} onClick={onClick} href={href} target={target} ref={ref} />\n})\n","import {type Route, type RouteSegment} from './types'\n\nconst VALID_PARAM_SEGMENT = /^[a-zA-Z0-9_-]+$/\n\nfunction createSegment(segment: string): RouteSegment | null {\n if (!segment) {\n return null\n }\n\n if (segment.startsWith(':')) {\n const paramName = segment.slice(1)\n\n if (!VALID_PARAM_SEGMENT.test(paramName)) {\n const addendum = segment.includes('*')\n ? ' Splats are not supported. Consider using child routes instead'\n : ''\n // eslint-disable-next-line no-console\n console.error(\n new Error(`Warning: Param segments \"${segment}\" includes invalid characters.${addendum}`),\n )\n }\n\n return {type: 'param', name: paramName}\n }\n\n return {type: 'dir', name: segment}\n}\n\n/** @internal */\nexport function _parseRoute(route: string): Route {\n const [pathname] = route.split('?')\n\n const segments = pathname.split('/').map(createSegment).filter(Boolean) as RouteSegment[]\n\n return {\n raw: route,\n segments: segments,\n }\n}\n","export function arrayify<T>(val: Array<T> | T): Array<T> {\n if (Array.isArray(val)) {\n return val\n }\n\n return val ? [val] : []\n}\n","import {difference, intersection, isPlainObject, pick} from 'lodash'\n\nimport {\n type InternalSearchParam,\n type MatchError,\n type MatchOk,\n type MatchResult,\n type RouterNode,\n type RouterState,\n} from './types'\nimport {arrayify} from './utils/arrayify'\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return isPlainObject(value)\n}\n\nfunction createMatchError(\n node: RouterNode,\n missingKeys: string[],\n unmappableStateKeys: string[],\n): MatchError {\n return {type: 'error', node, missingKeys, unmappableStateKeys}\n}\n\nfunction createMatchOk(\n node: RouterNode,\n matchedState: Record<string, string>,\n searchParams: InternalSearchParam[],\n child?: MatchOk | undefined,\n): MatchOk {\n return {type: 'ok', node, matchedState, searchParams, child}\n}\n\n/** @internal */\nexport function _findMatchingRoutes(node: RouterNode, _state?: RouterState): MatchResult {\n if (!_state) {\n return createMatchOk(node, {}, [])\n }\n\n const scopedState = node.scope ? (_state[node.scope] as RouterState) : _state\n\n const {_searchParams: searchParams = [], ...state} = scopedState || {}\n\n const requiredParams = node.route.segments\n .filter((seg) => seg.type === 'param')\n .map((seg) => seg.name)\n\n const stateKeys = isRecord(state) ? Object.keys(state) : []\n\n // These are params found in both the state and the route definition\n const consumedParams = intersection(stateKeys, requiredParams)\n\n // these are params found in the route definition but not in the state, can't map them to a route\n const missingParams = difference(requiredParams, consumedParams)\n\n // these are params found in the state but not in the route definition\n const remainingParams = difference(stateKeys, consumedParams)\n\n if (missingParams.length > 0) {\n return createMatchError(node, missingParams, [])\n }\n\n const scopedParams = searchParams.map(([key, value]): InternalSearchParam => [[key], value])\n\n const consumedState = pick(state, consumedParams) as Record<string, string>\n\n if (remainingParams.length === 0) {\n return createMatchOk(node, consumedState, scopedParams)\n }\n\n const children = arrayify(\n (typeof node.children === 'function'\n ? node.children(isRecord(state) ? state : {})\n : node.children) || [],\n )\n\n if (remainingParams.length > 0 && children.length === 0) {\n // our state includes extra keys that's not consumed by child routes\n return createMatchError(node, [], remainingParams)\n }\n\n const remainingState = pick(state, remainingParams)\n\n const childResult = children.map((childNode) => _findMatchingRoutes(childNode, remainingState))\n\n // Look for a matching route\n const found = childResult.find((res): res is MatchOk => res.type === 'ok')\n return found\n ? createMatchOk(node, consumedState, scopedParams, found)\n : createMatchError(node, [], remainingParams)\n}\n","/**\n * Like encodeURIComponent, but supports a custom set of unescaped characters.\n * @param uriComponent - A value representing an unencoded URI component.\n * @param unescaped - a string containing characters to not escape\n */\nexport function encodeURIComponentExcept(\n uriComponent: string | number | boolean,\n unescaped: string,\n): string {\n const chars = [...String(uriComponent)]\n let res = ''\n for (let i = 0; i < chars.length; i++) {\n const char = chars[i]\n if (unescaped.includes(char)) {\n res += char\n } else {\n res += encodeURIComponent(char)\n }\n }\n return res\n}\n","import Debug from 'debug'\n\nexport const debug = Debug('state-router')\n","import {_findMatchingRoutes} from './_findMatchingRoutes'\nimport {encodeURIComponentExcept} from './encodeURIComponentExcept'\nimport {type InternalSearchParam, type MatchOk, type RouterNode, type RouterState} from './types'\nimport {debug} from './utils/debug'\n\n/** @internal */\nexport function _resolvePathFromState(node: RouterNode, _state: RouterState): string {\n debug('Resolving path from state %o', _state)\n\n const match = _findMatchingRoutes(node, _state)\n if (match.type === 'error') {\n const unmappable = match.unmappableStateKeys\n if (unmappable.length > 0) {\n throw new Error(\n `Unable to find matching route for state. Could not map the following state key${\n unmappable.length == 1 ? '' : 's'\n } to a valid url: ${unmappable.map(quote).join(', ')}`,\n )\n }\n const missingKeys = match.missingKeys\n throw new Error(\n `Unable to find matching route for state. State object is missing the following key${\n missingKeys.length == 1 ? '' : 's'\n } defined in route: ${missingKeys.map(quote).join(', ')}`,\n )\n }\n\n const {path, searchParams} = pathFromMatchResult(match)\n\n const search = searchParams.length > 0 ? encodeParams(searchParams) : ''\n\n return `/${path.join('/')}${search ? `?${search}` : ''}`\n}\n\nfunction bracketify(value: string): string {\n return `[${value}]`\n}\n\nfunction encodeParams(params: InternalSearchParam[]): string {\n return params\n .flatMap(([key, value]) => {\n if (value === undefined) {\n return []\n }\n return [encodeSearchParamKey(serializeScopedPath(key)), encodeSearchParamValue(value)].join(\n '=',\n )\n })\n .join('&')\n}\n\nfunction serializeScopedPath(scopedPath: string[]): string {\n const [head, ...tail] = scopedPath\n\n return tail.length > 0 ? [head, ...tail.map(bracketify)].join('') : head\n}\n\nfunction encodeSearchParamValue(value: string): string {\n return encodeURIComponentExcept(value, '/')\n}\n\nfunction encodeSearchParamKey(value: string): string {\n return encodeURIComponentExcept(value, '[]')\n}\n\nfunction pathFromMatchResult(match: MatchOk): {\n path: string[]\n searchParams: InternalSearchParam[]\n} {\n const matchedState = match.matchedState\n\n const base = match.node.route.segments.map((segment) => {\n if (segment.type === 'dir') {\n return segment.name\n }\n\n const transform = match.node.transform && match.node.transform[segment.name]\n\n return transform\n ? transform.toPath(matchedState[segment.name] as any)\n : matchedState[segment.name]\n })\n\n const childMatch = match.child ? pathFromMatchResult(match.child) : undefined\n\n const searchParams = childMatch?.searchParams\n ? [...match.searchParams, ...childMatch.searchParams]\n : match.searchParams\n\n return {\n searchParams: addNodeScope(match.node, searchParams),\n path: [...(base || []), ...(childMatch?.path || [])],\n }\n}\n\nfunction addNodeScope(\n node: RouterNode,\n searchParams: InternalSearchParam[],\n): InternalSearchParam[] {\n const scope = node.scope\n return scope && !node.__unsafe_disableScopedSearchParams\n ? searchParams.map(([namespaces, value]) => [[scope, ...namespaces], value])\n : searchParams\n}\n\nfunction quote(value: string): string {\n return `\"${value}\"`\n}\n","import {type InternalSearchParam} from '../types'\n\nexport function parseScopedParams(params: [key: string, value: string][]): InternalSearchParam[] {\n return params.map(([key, value]) => [parse(key), value])\n}\n\nconst OPEN = 1\nconst CLOSED = 0\n\nfunction parse(str: string) {\n const result = []\n let i = 0\n let state = CLOSED\n while (i < str.length) {\n const nextBracketIdx = str.indexOf('[', i)\n if (nextBracketIdx === -1) {\n result.push(str.slice(i, str.length))\n break\n }\n if (state === OPEN) {\n throw new Error('Nested brackets not supported')\n }\n state = OPEN\n if (nextBracketIdx > i) {\n result.push(str.slice(i, nextBracketIdx))\n i = nextBracketIdx\n }\n\n const nextClosing = str.indexOf(']', nextBracketIdx)\n if (nextClosing === -1) {\n if (state === OPEN) {\n throw new Error('Unclosed bracket')\n }\n break\n }\n state = CLOSED\n result.push(str.slice(i + 1, nextClosing))\n i = nextClosing + 1\n }\n return result\n}\n","import {\n type InternalSearchParam,\n type RouterNode,\n type RouterState,\n type SearchParam,\n} from './types'\nimport {arrayify} from './utils/arrayify'\nimport {debug} from './utils/debug'\nimport {parseScopedParams} from './utils/parseScopedParams'\n\nfunction matchPath(\n node: RouterNode,\n path: string,\n searchParams: InternalSearchParam[],\n): RouterState | null {\n const parts = path.split('/').filter(Boolean)\n const segmentsLength = node.route.segments.length\n\n if (parts.length < segmentsLength) {\n return null\n }\n\n const state: RouterState = {}\n const isMatching = node.route.segments.every((segment, i) => {\n if (segment.type === 'dir') {\n return segment.name === parts[i]\n }\n\n const transform = node.transform && node.transform[segment.name]\n\n state[segment.name] = transform ? transform.toState(parts[i]) : parts[i]\n\n return true\n })\n\n if (!isMatching) {\n return null\n }\n\n const rest = parts.slice(segmentsLength)\n\n let childState: RouterState | null = null\n\n const children =\n typeof node.children === 'function' ? arrayify(node.children(state)) : node.children\n\n const unscopedParams = removeScope(node.scope, searchParams)\n\n children.some((childNode) => {\n if (childNode) {\n const childParams = childNode.scope\n ? unscopedParams.filter(([namespaces]) => childNode.scope === namespaces[0])\n : unscopedParams\n\n childState = matchPath(childNode, rest.join('/'), childParams)\n return childState\n }\n return undefined\n })\n\n if (rest.length > 0 && !childState) {\n return null\n }\n\n const selfParams = unscopedParams.flatMap(([namespace, value]): SearchParam[] => {\n return namespace.length === 1 ? [[namespace[0], value]] : []\n })\n\n const mergedState: RouterState = {\n ...state,\n ...(childState === null ? {} : childState),\n ...(selfParams.length > 0 ? {_searchParams: selfParams} : {}),\n }\n\n return node.scope ? {[node.scope]: mergedState} : mergedState\n}\n\n/**\n * @internal\n */\nexport function _resolveStateFromPath(node: RouterNode, path: string): Record<string, any> | null {\n debug('resolving state from path %s', path)\n\n const [pathname, search] = path.split('?')\n const urlSearchParams = Array.from(new URLSearchParams(search).entries())\n\n const pathMatch = matchPath(node, pathname, parseScopedParams(urlSearchParams))\n\n debug('resolved: %o', pathMatch || null)\n\n return pathMatch || null\n}\n\nfunction removeScope(\n scope: string | undefined,\n searchParams: InternalSearchParam[],\n): InternalSearchParam[] {\n return scope\n ? searchParams.map(([namespaces, value]) => [\n namespaces[0] === scope ? namespaces.slice(1) : namespaces,\n value,\n ])\n : searchParams\n}\n","/**\n * `atob()` and `btoa()` do not support Unicode characters outside of the Latin1 range,\n * but we obviously want to support the full range of Unicode characters in our router.\n *\n * Additionally, we would prefer not to use characters like `+` and `=` in URLs, as they\n * have specific meanings there and may be misinterpreted. Thus, this uses base64url instead\n * of the more common base64.\n */\n\n/**\n * Encodes a string as base64url\n *\n * @param str - String to encode\n * @returns Encoded string\n * @internal\n */\nexport function encodeBase64Url(str: string): string {\n return encodeBase64(str).replace(/\\//g, '_').replace(/\\+/g, '-').replace(/[=]+$/, '')\n}\n\n/**\n * Decodes a base64url-encoded string\n *\n * @param str - String to decode\n * @returns Decoded string\n * @internal\n */\nexport function decodeBase64Url(str: string): string {\n return decodeBase64(str.replace(/-/g, '+').replace(/_/g, '/'))\n}\n\nfunction percentToByte(p: string) {\n return String.fromCharCode(parseInt(p.slice(1), 16))\n}\n\nfunction encodeBase64(str: string): string {\n return btoa(encodeURIComponent(str).replace(/%[0-9A-F]{2}/g, percentToByte))\n}\n\nfunction byteToPercent(b: string) {\n return `%${`00${b.charCodeAt(0).toString(16)}`.slice(-2)}`\n}\n\nfunction decodeBase64(str: string): string {\n return decodeURIComponent(Array.from(atob(str), byteToPercent).join(''))\n}\n","import {decodeBase64Url, encodeBase64Url} from './base64url'\n\n/**\n * Decode a path segment containing JSON parameters\n *\n * @param pathSegment - The path segment to decode\n * @returns The decoded parameters\n * @internal\n * @hidden\n */\nexport function decodeJsonParams(pathSegment = ''): Record<string, unknown> {\n const segment = decodeURIComponent(pathSegment)\n\n if (!segment) {\n return {}\n }\n\n // Because of high-unicode characters (eg outside of the latin1 range), we prefer base64url\n // since it also removes characters we'd rather not put in our URLs (eg '=' and '/')\n try {\n return JSON.parse(decodeBase64Url(segment))\n } catch (err) {\n // Fall-through: previously we used plain base64 encoding instead of base64url\n }\n\n try {\n return JSON.parse(atob(segment))\n } catch (err) {\n // Fall-through: before _that_, we used plain URI encoding\n }\n\n try {\n return JSON.parse(segment)\n } catch (err) {\n console.warn('Failed to parse JSON parameters')\n }\n\n return {}\n}\n\n/**\n * Encodes a set of parameters as a path segment, using base64url\n *\n * @param params - Paramters to encode\n * @returns The encoded parameters as a path segment\n * @internal\n * @hidden\n */\nexport function encodeJsonParams(params?: Record<string, unknown>): string {\n return params ? encodeBase64Url(JSON.stringify(params)) : ''\n}\n","export function decodeParams(pathSegment: string): Record<string, string> {\n return pathSegment.split(';').reduce<Record<string, string>>((params, pair) => {\n const [key, value] = pair.split('=')\n\n params[decodeURIComponent(key)] = decodeURIComponent(value)\n\n return params\n }, {})\n}\n\nexport function encodeParams(params: Record<string, string | undefined | null>): string {\n return Object.entries(params)\n .filter(([, value]) => value !== undefined && value !== null)\n .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value as string)}`)\n .join(';')\n}\n","import {_parseRoute} from './_parseRoute'\nimport {_resolvePathFromState} from './_resolvePathFromState'\nimport {_resolveStateFromPath} from './_resolveStateFromPath'\nimport {type RouteChildren, type Router, type RouteTransform} from './types'\nimport {decodeJsonParams, encodeJsonParams} from './utils/jsonParamsEncoding'\nimport {decodeParams, encodeParams} from './utils/paramsEncoding'\n\n/**\n * @public\n */\nexport interface RouteNodeOptions {\n /**\n * The path of the route node.\n */\n path?: string\n /**\n * The children of the route node. See {@link RouteChildren}\n */\n children?: RouteChildren\n /**\n * The transforms to apply to the route node. See {@link RouteTransform}\n */\n transform?: {\n [key: string]: RouteTransform<any>\n }\n /**\n * The scope of the route node.\n */\n scope?: string\n\n /**\n * Optionally disable scoping of search params\n * Scoped search params will be represented as scope[param]=value in the url\n * Disabling this will still scope search params based on any parent scope unless the parent scope also has disabled search params scoping\n * Caution: enabling this can cause conflicts with multiple plugins defining search params with the same name\n */\n __unsafe_disableScopedSearchParams?: boolean\n}\n\n/**\n * Interface for the {@link route} object.\n *\n * @public\n */\nexport interface RouteObject {\n /**\n * Creates a new router.\n * Returns {@link Router}\n * See {@link RouteNodeOptions} and {@link RouteChildren}\n */\n create: (\n routeOrOpts: RouteNodeOptions | string,\n childrenOrOpts?: RouteNodeOptions | RouteChildren | null,\n children?: Router | RouteChildren,\n ) => Router\n\n /**\n * Creates a new router for handling intents.\n * Returns {@link Router}\n */\n intents: (base: string) => Router\n\n /**\n * Creates a new router scope.\n * Returns {@link Router}\n */\n scope(\n scopeName: string,\n routeOrOpts: RouteNodeOptions | string,\n childrenOrOpts?: RouteNodeOptions | RouteChildren | null,\n children?: Router | RouteChildren,\n ): Router\n}\n\n/**\n * An object containing functions for creating routers and router scopes.\n * See {@link RouteObject}\n *\n * @public\n *\n * @example\n * ```ts\n * const router = route.create({\n * path: \"/foo\",\n * children: [\n * route.create({\n * path: \"/bar\",\n * children: [\n * route.create({\n * path: \"/:baz\",\n * transform: {\n * baz: {\n * toState: (id) => ({ id }),\n * toPath: (state) => state.id,\n * },\n * },\n * }),\n * ],\n * }),\n * ],\n * });\n * ```\n */\nexport const route: RouteObject = {\n create: (routeOrOpts, childrenOrOpts, children) =>\n _createNode(normalizeArgs(routeOrOpts, childrenOrOpts, children)),\n intents: (base: string) => {\n const basePath = normalize(base).join('/')\n\n return route.create(`${basePath}/:intent`, [\n route.create(\n ':params',\n {\n transform: {\n params: {\n toState: decodeParams,\n toPath: encodeParams,\n },\n },\n },\n [\n route.create(':payload', {\n transform: {\n payload: {\n toState: decodeJsonParams,\n toPath: encodeJsonParams,\n },\n },\n }),\n ],\n ),\n ])\n },\n scope(\n scopeName: string,\n routeOrOpts: RouteNodeOptions | string,\n childrenOrOpts?: RouteNodeOptions | RouteChildren | null,\n children?: Router | RouteChildren,\n ) {\n const options = normalizeArgs(routeOrOpts, childrenOrOpts, children)\n\n return _createNode({\n ...options,\n scope: scopeName,\n })\n },\n}\n\nfunction normalizeChildren(children: any): RouteChildren {\n if (Array.isArray(children) || typeof children === 'function') {\n return children\n }\n return children ? [children] : []\n}\n\nfunction isRoute(val?: RouteNodeOptions | Router | RouteChildren) {\n return val && '_isRoute' in val\n}\n\nfunction normalizeArgs(...args: any[]): RouteNodeOptions\nfunction normalizeArgs(\n path: string | RouteNodeOptions,\n childrenOrOpts?: RouteNodeOptions | Router | RouteChildren,\n children?: Router | RouteChildren,\n): RouteNodeOptions {\n if (typeof path === 'object') {\n return path\n }\n\n if (\n Array.isArray(childrenOrOpts) ||\n typeof childrenOrOpts === 'function' ||\n isRoute(childrenOrOpts)\n ) {\n return {path, children: normalizeChildren(childrenOrOpts)}\n }\n\n if (children) {\n return {path, ...childrenOrOpts, children: normalizeChildren(children)}\n }\n\n return {path, ...childrenOrOpts}\n}\n\nfunction normalize(...paths: string[]) {\n return paths.reduce<string[]>((acc, path) => acc.concat(path.split('/')), []).filter(Boolean)\n}\n\nconst EMPTY_STATE = {}\n\nfunction isRoot(pathname: string): boolean {\n // it is the root if every segment is an empty string\n return pathname.split('/').every((segment) => !segment)\n}\n\n/**\n * @internal\n * @param options - Route node options\n */\nexport function _createNode(options: RouteNodeOptions): Router {\n // eslint-disable-next-line camelcase\n const {path, scope, transform, children, __unsafe_disableScopedSearchParams} = options\n\n if (!path) {\n throw new TypeError('Missing path')\n }\n\n const parsedRoute = _parseRoute(path)\n\n return {\n _isRoute: true, // todo: make a Router class instead\n scope,\n // eslint-disable-next-line camelcase\n __unsafe_disableScopedSearchParams,\n route: parsedRoute,\n children: children || [],\n transform,\n encode(state) {\n return _resolvePathFromState(this, state)\n },\n decode(_path) {\n return _resolveStateFromPath(this, _path)\n },\n isRoot: isRoot,\n isNotFound(pathname: string): boolean {\n return this.decode(pathname) === null\n },\n getBasePath(): string {\n return this.encode(EMPTY_STATE)\n },\n getRedirectBase(pathname: string): string | null {\n if (isRoot(pathname)) {\n const basePath = this.getBasePath()\n // Check if basepath is something different than given\n if (pathname !== basePath) {\n return basePath\n }\n }\n return null\n },\n }\n}\n","/**\n * @internal\n */\nexport const STICKY_PARAMS: string[] = ['perspective', 'excludedPerspectives']\n","/**\n * @public\n */\nexport interface RouteSegment {\n /**\n * The name of the segment.\n */\n name: string\n /**\n * The type of the segment.\n * Can be either \"dir\" or \"param\".\n */\n type: 'dir' | 'param'\n}\n\n/**\n * @public\n */\nexport interface RouteTransform<T> {\n /**\n * Converts a path string to a state object.\n */\n toState: (value: string) => T\n\n /**\n * Converts a state object to a path string.\n */\n toPath: (value: T) => string\n}\n\n/**\n * @public\n */\nexport interface Route {\n /**\n * The raw string representation of the route.\n */\n raw: string\n /**\n * An array of route segments that make up the route.\n * See {@link RouteSegment}\n */\n segments: RouteSegment[]\n /**\n * An optional object containing route transforms.\n * See {@link RouteTransform} and {@link RouterState}\n */\n transform?: {\n [key: string]: RouteTransform<RouterState>\n }\n}\n\n/**\n * @public\n */\nexport type RouteChildren =\n | RouterNode[]\n | ((state: RouterState) => Router | RouterNode | RouterNode[] | undefined | false)\n\n/**\n * @public\n */\nexport interface RouterNode {\n /**\n * The route information for this node. See {@link Route}\n */\n route: Route\n /**\n * An optional scope for this node.\n */\n scope?: string\n\n /**\n * Optionally disable scoping of search params\n * Scoped search params will be represented as scope[param]=value in the url\n * Disabling this will still scope search params based on any parent scope unless the parent scope also has disabled search params scoping\n * Caution: enabling this can cause conflicts with multiple plugins defining search params with the same name\n */\n __unsafe_disableScopedSearchParams?: boolean\n\n /**\n * An optional object containing transforms to apply to this node.\n * See {@link RouteTransform} and {@link RouterState}\n */\n transform?: {\n [key: string]: RouteTransform<RouterState>\n }\n /**\n * The child nodes of this node. See {@link RouteChildren}\n */\n children: RouteChildren\n}\n\n/**\n * @public\n */\nexport interface Router extends RouterNode {\n /**\n * Indicates whether this router is a route.\n * @internal\n */\n _isRoute: boolean\n /**\n * Encodes the specified router state into a path string.\n * See {@link RouterState}\n *\n */\n encode: (state: RouterState) => string\n\n /**\n * Decodes the specified path string into a router state.\n * See {@link RouterState}\n */\n decode: (path: string) => RouterState | null\n\n /**\n * Determines whether the specified path is not found.\n */\n isNotFound: (path: string) => boolean\n\n /**\n * Gets the base path of this router.\n */\n getBasePath: () => string\n\n /**\n * Gets the redirect base of this router.\n */\n getRedirectBase: (pathname: string) => string | null\n\n /**\n * Determines whether the specified path is the root path.\n */\n isRoot: (path: string) => boolean\n}\n\n/** @internal */\nexport type InternalSearchParam = [scopedPath: string[], value: string]\n\n/** @internal */\nexport interface MatchOk {\n type: 'ok'\n node: RouterNode\n matchedState: Record<string, string>\n searchParams: InternalSearchParam[]\n child: MatchOk | undefined\n}\n\n/** @internal */\nexport interface MatchError {\n type: 'error'\n node: RouterNode\n /**\n * Parameters found in the route string but not provided as a key in the state object\n */\n missingKeys: string[]\n /**\n * These are keys found in the state object but not in the route definition (and can't be mapped to a child route)\n */\n unmappableStateKeys: string[]\n}\n/** @internal */\nexport type MatchResult = MatchError | MatchOk\n\n/**\n * @public\n */\nexport interface NavigateBaseOptions {\n replace?: boolean\n}\n\n/**\n * @public\n */\nexport interface NavigateOptions extends NavigateBaseOptions {\n stickyParams?: Record<string, string | undefined | null>\n}\n\n/**\n * @public\n */\nexport interface NavigateOptionsWithState extends NavigateOptions {\n state?: RouterState | null\n}\n\n/**\n * @public\n */\nexport interface RouterContextValue {\n /**\n * Resolves the path from the given router state. See {@link RouterState}\n *\n * When state is null, it will resolve the path from the current state\n * and navigate to the root path.\n */\n resolvePathFromState: (state: RouterState | null) => string\n\n /**\n * Resolves the intent link for the given intent name and parameters.\n * See {@link IntentParameters}\n */\n resolveIntentLink: (\n intentName: string,\n params?: IntentParameters,\n searchParams?: SearchParam[],\n ) => string\n\n /**\n * Navigates to the given URL.\n * The function requires an object that has a path and an optional replace property.\n */\n navigateUrl: (opts: {path: string; replace?: boolean}) => void\n\n /**\n * @deprecated Use `navigate({stickyParams: params, ...options})` instead\n */\n navigateStickyParams: (\n params: NavigateOptions['stickyParams'],\n options?: NavigateBaseOptions,\n ) => void\n\n /**\n * Updates the router state and navigates to a new path.\n * Allows specifying new state values and optionally merging sticky parameters.\n *\n * See {@link RouterState} and {@link NavigateOptions}\n *\n * @public\n *\n * @example Navigate with sticky params only, staying on the current path\n * ```tsx\n * router.navigate({stickyParams: {baz: 'qux'}})\n * ```\n * @remarks `null` sticky parameter value will remove the sticky parameter from the url\n *\n * @example Navigate with state and sticky params\n * ```tsx\n * router.navigate({stickyParams: {baz: 'qux'}, state: {foo: 'bar'}})\n * ```\n *\n * @example Navigate to root path\n * ```tsx\n * router.navigate({stickyParams: {baz: 'qux'}, state: null})\n * ```\n */\n navigate: {\n // legacy, state-first version - for when you want to navigate to a new state\n (nextState: RouterState, options?: NavigateOptions): void\n // Options version - for staying where you are (omit state) or going to root (state: null)\n (options: NavigateOptions & {state?: RouterState | null}): void\n }\n\n /**\n * Navigates to the given intent.\n * See {@link RouterState} and {@link NavigateBaseOptions}\n */\n navigateIntent: (\n intentName: string,\n params?: IntentParameters,\n options?: NavigateBaseOptions,\n ) => void\n\n /**\n * The current router state. See {@link RouterState}\n */\n state: RouterState\n\n /**\n * The current router state. See {@link RouterState}\n */\n stickyParams: Record<string, string | undefined | null>\n}\n\n/**\n * Base intent parameters\n *\n * @public\n * @todo dedupe with core/structure\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 /* Name (ID) of initial value template to use for `create` intent. Optional. */\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/**\n * Intent parameters (json)\n *\n * @public\n */\nexport type IntentJsonParams = {[key: string]: any}\n\n/**\n * @public\n * @todo dedupe with intent types in core\n */\nexport type IntentParameters = BaseIntentParams | [BaseIntentParams, IntentJsonParams]\n\n/**\n * @public\n */\nexport type SearchParam = [key: string, value: string]\n\n/**\n * @public\n */\nexport type RouterState = Record<string, unknown> & {_searchParams?: SearchParam[]}\n\nexport const isNavigateOptions = (\n maybeNavigateOptions: unknown,\n): maybeNavigateOptions is NavigateOptions & {state?: RouterState | null} => {\n if (\n typeof maybeNavigateOptions !== 'object' ||\n maybeNavigateOptions === null ||\n Array.isArray(maybeNavigateOptions)\n ) {\n return false\n }\n\n const hasNavigationProps =\n 'replace' in maybeNavigateOptions ||\n 'stickyParams' in maybeNavigateOptions ||\n 'state' in maybeNavigateOptions\n\n if (!hasNavigationProps) {\n return false\n }\n\n // if state exists then it should be of RouterState type\n if ('state' in maybeNavigateOptions) {\n const {state} = maybeNavigateOptions as {state: unknown}\n // allow null or undefined or RouterState (including empty object)\n return state === null || state === undefined || typeof state === 'object'\n }\n\n return true\n}\n\n/**\n * Type representing either a new router state or navigation options with an optional state.\n * @internal\n */\nexport type NextStateOrOptions = RouterState | (NavigateOptions & {state?: RouterState | null})\n","import {fromPairs, partition, toPairs} from 'lodash'\nimport {type ReactNode, useCallback, useMemo} from 'react'\nimport {RouterContext} from 'sanity/_singletons'\n\nimport {STICKY_PARAMS} from './stickyParams'\nimport {\n type IntentParameters,\n isNavigateOptions,\n type NavigateBaseOptions,\n type NavigateOptions,\n type NextStateOrOptions,\n type Router,\n type RouterContextValue,\n type RouterState,\n type SearchParam,\n} from './types'\n\n/**\n * The props for the {@link RouterProvider} component.\n *\n * @public\n */\nexport interface RouterProviderProps {\n /**\n * A function that is called when the user navigates to a new path.\n * Takes an object containing the path to navigate to and an optional `replace` flag.\n */\n onNavigate: (opts: {path: string; replace?: boolean}) => void\n /**\n * The router object that is used to handle navigation. See {@link Router}\n */\n router: Router\n /**\n * The current state of the router. See {@link RouterState}\n */\n state: RouterState\n /**\n * The child elements to render.\n */\n children: ReactNode\n}\n\n/**\n * @example\n * ```tsx\n * import {\n * NavigateOptions,\n * route,\n * RouterProvider,\n * RouterState\n * } from 'sanity'\n * import {useCallback, useMemo} from 'react'\n *\n * function Root() {\n * const [router] = useState(() => route.create('/'))\n *\n * const [state, setState] = useState<RouterState>({})\n *\n * const handleNavigate = useCallback((\n * path: string,\n * options?: NavigateOptions\n * ) => {\n * console.log('navigate', path, options)\n *\n * setState(router.decode(path))\n * }, [router])\n *\n * return (\n * <RouterProvider\n * onNavigate={handleNavigate}\n * router={router}\n * state={state}\n * >\n * <div>This is a routed application</div>\n * </RouterProvider>\n * )\n * }\n * ```\n *\n * @param props - The component props.\n * {@link RouterProviderProps}\n *\n * @public\n */\nexport function RouterProvider(props: RouterProviderProps): React.JSX.Element {\n const {onNavigate, router: routerProp, state} = props\n\n const resolveIntentLink = useCallback(\n (intentName: string, parameters?: IntentParameters, _searchParams?: SearchParam[]): string => {\n const [params, payload] = Array.isArray(parameters) ? parameters : [parameters]\n return routerProp.encode({\n intent: intentName,\n params,\n payload,\n _searchParams: toPairs({\n ...fromPairs((state._searchParams ?? []).filter(([key]) => STICKY_PARAMS.includes(key))),\n ...fromPairs(_searchParams ?? []),\n }),\n })\n },\n [routerProp, state._searchParams],\n )\n\n const resolvePathFromState = useCallback(\n (nextState: RouterState | null): string => {\n const currentStateParams = state._searchParams || []\n const nextStateParams = nextState?._searchParams || []\n const nextParams = STICKY_PARAMS.reduce((acc, param) => {\n return replaceStickyParam(\n acc,\n param,\n findParam(nextStateParams, param) ?? findParam(currentStateParams, param),\n )\n }, nextStateParams || [])\n\n return routerProp.encode({\n ...nextState,\n _searchParams: nextParams,\n })\n },\n [routerProp, state],\n )\n\n const navigate: RouterContextValue['navigate'] = useCallback(\n (nextStateOrOptions: NextStateOrOptions, maybeOptions?: NavigateOptions) => {\n // Determine options and state based on input pattern\n const isOptionsOnlyPattern = isNavigateOptions(nextStateOrOptions) && !maybeOptions\n const options = isOptionsOnlyPattern ? nextStateOrOptions : maybeOptions || {}\n\n const baseState = isNavigateOptions(nextStateOrOptions)\n ? (getStateFromOptions(nextStateOrOptions, state) ?? state)\n : nextStateOrOptions\n\n const currentParams = state._searchParams || []\n const nextStickyParams =\n options.stickyParams ??\n Object.fromEntries(currentParams.filter(([key]) => STICKY_PARAMS.includes(key)))\n\n validateStickyParams(nextStickyParams)\n\n const nextParams = baseState._searchParams || []\n const mergedParams = mergeStickyParams(nextParams, nextStickyParams)\n\n onNavigate({\n path: resolvePathFromState({...baseState, _searchParams: mergedParams}),\n replace: options.replace,\n })\n },\n [onNavigate, resolvePathFromState, state],\n )\n\n const handleNavigateStickyParams = useCallback(\n (params: NavigateOptions['stickyParams'], options: NavigateBaseOptions = {}) =>\n navigate({stickyParams: params, ...options, state: undefined}),\n [navigate],\n )\n\n const navigateIntent = useCallback(\n (intentName: string, params?: IntentParameters, options: NavigateBaseOptions = {}) => {\n onNavigate({path: resolveIntentLink(intentName, params), replace: options.replace})\n },\n [onNavigate, resolveIntentLink],\n )\n\n const [routerState, stickyParams] = useMemo(() => {\n if (!state._searchParams) {\n return [state, null]\n }\n const {_searchParams, ...rest} = state\n const [sticky, restParams] = partition(_searchParams, ([key]) => STICKY_PARAMS.includes(key))\n if (sticky.length === 0) {\n return [state, null]\n }\n return [{...rest, _searchParams: restParams}, sticky]\n }, [state])\n\n const stickyParamsByName = useMemo(() => Object.fromEntries(stickyParams || []), [stickyParams])\n\n const router: RouterContextValue = useMemo(\n () => ({\n navigate,\n navigateIntent,\n navigateStickyParams: handleNavigateStickyParams,\n navigateUrl: onNavigate,\n resolveIntentLink,\n resolvePathFromState,\n state: routerState,\n stickyParams: stickyParamsByName,\n }),\n [\n handleNavigateStickyParams,\n navigate,\n navigateIntent,\n onNavigate,\n resolveIntentLink,\n resolvePathFromState,\n routerState,\n stickyParamsByName,\n ],\n )\n\n return <RouterContext.Provider value={router}>{props.children}</RouterContext.Provider>\n}\n\nfunction replaceStickyParam(\n current: SearchParam[],\n param: string,\n value: string | undefined,\n): SearchParam[] {\n const filtered = current.filter(([key]) => key !== param)\n return value === undefined || value == '' ? filtered : [...filtered, [param, value]]\n}\n\nfunction mergeStickyParams(\n currentParams: SearchParam[],\n newParams?: Record<string, string | undefined | null>,\n): SearchParam[] {\n if (!newParams) return currentParams\n\n // Remove old sticky params before merging new ones\n const filteredParams = currentParams.filter(([key]) => !Object.hasOwn(newParams, key))\n\n // Type guard function to filter out undefined values\n const isValidSearchParam = (\n entry: [string, string | undefined | null],\n ): entry is [string, string] => entry[1] !== undefined\n\n const convertNullSearchParam = (entry: [string, string | null]): [string, string] => [\n entry[0],\n entry[1] === null ? '' : entry[1],\n ]\n\n // Convert newParams into the correct SearchParam format\n const newEntries = Object.entries(newParams)\n .filter(isValidSearchParam)\n .map(convertNullSearchParam)\n\n return [...filteredParams, ...newEntries]\n}\n\nfunction findParam(searchParams: SearchParam[], key: string): string | undefined {\n const entry = searchParams.find(([k]) => k === key)\n return entry ? entry[1] : undefined\n}\n\nfunction getStateFromOptions(\n nextStateOrOptions: NextStateOrOptions,\n state: RouterState,\n): RouterState | null {\n const isOptionsOnly = isNavigateOptions(nextStateOrOptions)\n\n if (isOptionsOnly) {\n if (nextStateOrOptions.state === null) {\n return {}\n }\n return nextStateOrOptions.state ?? state\n }\n return null\n}\n\nfunction validateStickyParams(nextStickyParams: Record<string, string | undefined | null>) {\n const hasInvalidParam = Object.keys(nextStickyParams).some(\n (param) => !STICKY_PARAMS.includes(param),\n )\n if (hasInvalidParam) throw new Error('One or more parameters are not sticky')\n}\n","/* eslint-disable camelcase */\nimport {type ReactNode, useCallback, useEffect, useMemo, useRef} from 'react'\nimport {RouterContext} from 'sanity/_singletons'\n\nimport {\n isNavigateOptions,\n type NavigateOptions,\n type NextStateOrOptions,\n type RouterContextValue,\n type RouterState,\n} from './types'\nimport {useRouter} from './useRouter'\n\nfunction addScope(\n routerState: Record<string, any>,\n scope: string,\n scopedState: Record<string, any>,\n) {\n return (\n scopedState && {\n ...routerState,\n [scope]: scopedState,\n }\n )\n}\n\n/**\n * Props for the {@link RouteScope} component.\n *\n * @public\n */\nexport interface RouteScopeProps {\n /**\n * The scope for the nested routes.\n */\n scope: string\n\n /**\n * Optionally disable scoping of search params\n * Scoped search params will be represented as scope[param]=value in the url\n * Disabling this will still scope search params based on any parent scope unless the parent scope also has disabled search params scoping\n * Caution: enabling this can cause conflicts with multiple plugins defining search params with the same name\n */\n __unsafe_disableScopedSearchParams?: boolean\n /**\n * The content to display inside the route scope.\n */\n children: ReactNode\n}\n\n/**\n * A component that wraps a scoped router context, so that calls to\n * `useRouter()`, `useRouterState()`, and usage of `<StateLink />`\n * will be prefixed with the scope segment.\n *\n * @public\n *\n * @param props - Props to pass `RouteScope` component.\n * See {@link RouteScopeProps}\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * return (\n * <RouteScope scope=\"foo\">\n * <StateLink state={{bar: 'baz'}}>Link</StateLink>\n * </RouteScope>\n * )\n * }\n * ```\n */\nexport const RouteScope = function RouteScope(props: RouteScopeProps): React.JSX.Element {\n const {children, scope, __unsafe_disableScopedSearchParams} = props\n const parentRouter = useRouter()\n const {resolvePathFromState: parent_resolvePathFromState, navigate: parent_navigate} =\n parentRouter\n\n const parentStateRef = useRef(parentRouter.state)\n useEffect(() => {\n parentStateRef.current = parentRouter.state\n }, [parentRouter.state])\n\n const resolveNextParentState = useCallback(\n (_nextState: RouterState | null) => {\n if (_nextState === null) return null\n\n const {_searchParams, ...nextState} = _nextState || {}\n const nextParentState = addScope(parentStateRef.current, scope, nextState)\n if (__unsafe_disableScopedSearchParams) {\n // Move search params to parent scope\n nextParentState._searchParams = _searchParams\n } else {\n nextParentState[scope]._searchParams = _searchParams\n }\n return nextParentState\n },\n [scope, __unsafe_disableScopedSearchParams],\n )\n\n const resolvePathFromState = useCallback(\n (nextState: RouterState | null) =>\n parent_resolvePathFromState(resolveNextParentState(nextState)),\n [parent_resolvePathFromState, resolveNextParentState],\n )\n\n const navigate: RouterContextValue['navigate'] = useCallback(\n (nextStateOrOptions: NextStateOrOptions, maybeOptions?: NavigateOptions) => {\n // Check if it's the options-only pattern\n if (isNavigateOptions(nextStateOrOptions) && !maybeOptions) {\n const options = nextStateOrOptions\n const {state} = options\n\n //keep the current state but apply other options\n if (state) {\n const nextState = resolveNextParentState(state)\n const resolvedState = nextState === null ? {} : nextState\n\n return parent_navigate(resolvedState, options)\n }\n\n //keep the current state\n return parent_navigate(options)\n }\n\n const nextState = isNavigateOptions(nextStateOrOptions)\n ? resolveNextParentState(null)\n : resolveNextParentState(nextStateOrOptions)\n\n return parent_navigate(nextState === null ? {} : nextState, maybeOptions || {})\n },\n [parent_navigate, resolveNextParentState],\n )\n\n const childRouter: RouterContextValue = useMemo(() => {\n const parentState = parentRouter.state\n const childState =\n typeof parentState[scope] === 'object' ? ({...parentState[scope]} as RouterState) : {}\n if (__unsafe_disableScopedSearchParams) {\n childState._searchParams = parentState._searchParams\n }\n return {\n ...parentRouter,\n navigate,\n resolvePathFromState,\n state: childState,\n }\n }, [scope, parentRouter, navigate, resolvePathFromState, __unsafe_disableScopedSearchParams])\n\n return <RouterContext.Provider value={childRouter}>{children}</RouterContext.Provider>\n}\nRouteScope.displayName = 'RouteScope'\n","import {type MouseEventHandler, useMemo} from 'react'\n\nimport {useLink} from './useLink'\nimport {useRouter} from './useRouter'\n\nconst EMPTY_STATE = {}\n\n/**\n * @public\n */\nexport interface UseStateLinkOptions {\n /**\n * The click event handler for the link.\n */\n onClick?: MouseEventHandler<HTMLElement>\n /**\n * Whether to replace the current history entry instead of adding a new one.\n */\n replace?: boolean\n /**\n * The state object to update when the link is clicked.\n */\n state?: Record<string, unknown>\n /**\n * The target window or frame to open the linked document in.\n */\n target?: string\n /**\n * Whether to navigate to the index page of the linked document.\n */\n toIndex?: boolean\n}\n\n/**\n * @public\n *\n * @param options - Options to use for the link\n * {@link UseStateLinkOptions}\n *\n * @returns - An object with `onClick` and `href` props to use for the link\n *\n * @example\n * ```tsx\n * const {onClick, href} = useStateLink({state: {foo: 'bar'}})\n * ```\n */\nexport function useStateLink(options: UseStateLinkOptions): {\n onClick: MouseEventHandler<HTMLElement>\n href: string\n} {\n const {onClick: onClickProp, replace, state, target, toIndex = false} = options\n\n if (state && toIndex) {\n throw new Error('Passing both `state` and `toIndex={true}` as props to StateLink is invalid')\n }\n\n if (!state && !toIndex) {\n // eslint-disable-next-line no-console\n console.error(\n new Error(\n 'No state passed to StateLink. If you want to link to an empty state, its better to use the the `toIndex` property',\n ),\n )\n }\n\n const {resolvePathFromState} = useRouter()\n\n const href = useMemo(\n () => resolvePathFromState(toIndex ? EMPTY_STATE : state || EMPTY_STATE),\n [resolvePathFromState, state, toIndex],\n )\n\n const {onClick} = useLink({href, onClick: onClickProp, replace, target})\n\n return {onClick, href}\n}\n","import {type ForwardedRef, forwardRef, type HTMLProps} from 'react'\n\nimport {useStateLink} from './useStateLink'\n\n/**\n * Props for the {@link StateLink} component.\n *\n * @public\n */\nexport interface StateLinkProps {\n /**\n * Whether to replace the current history entry instead of adding a new one.\n */\n replace?: boolean\n /**\n * The state to associate with the link.\n */\n state?: Record<string, unknown>\n /**\n * Whether to navigate to the index page of the app.\n */\n toIndex?: boolean\n}\n\n/**\n * A component that creates a link that updates the URL state.\n *\n * @remarks\n * This component uses the {@link useStateLink} hook\n * to create a link that updates the URL state.\n *\n * @param props - Props to pass to the `StateLink` component.\n * See {@link StateLinkProps}.\n *\n * @public\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * return <StateLink state={{foo: 'bar'}}>Link</StateLink>\n * }\n * ```\n */\nexport const StateLink = forwardRef(function StateLink(\n props: StateLinkProps & Omit<HTMLProps<HTMLAnchorElement>, 'href'>,\n ref: ForwardedRef<HTMLAnchorElement>,\n) {\n const {onClick: onClickProp, replace, state, target, toIndex = false, ...restProps} = props\n const {onClick, href} = useStateLink({\n onClick: onClickProp,\n replace,\n state,\n target,\n toIndex,\n })\n\n return <a {...restProps} href={href} onClick={onClick} ref={ref} />\n})\n","import {identity} from 'lodash'\nimport {useMemo} from 'react'\n\nimport {type RouterState} from './types'\nimport {useRouter} from './useRouter'\n\n/**\n * @public\n *\n * @param selector - A selector function that receives the router state and returns a value. See {@link RouterState}\n *\n * @returns The value returned by the selector function or RouterState. See {@link RouterState}\n *\n * @example\n * ```tsx\n * const {activeTool} = useRouterState(state => state.tool)\n * ```\n */\nexport function useRouterState<R = RouterState>(selector: (routerState: RouterState) => R): R\n\n/**\n * @public\n *\n * @returns The router state. See {@link RouterState}\n *\n * @example\n * ```tsx\n * const routerState = useRouterState()\n * ```\n */\nexport function useRouterState(): RouterState\n\n/**\n * @public\n */\nexport function useRouterState(\n selector: (routerState: RouterState) => unknown = identity,\n): unknown {\n const {state} = useRouter()\n return useMemo(() => selector(state), [selector, state])\n}\n","import {type ComponentType, type FunctionComponent} from 'react'\n\nimport {type RouterContextValue} from './types'\nimport {useRouter} from './useRouter'\n\n/**\n * A higher-order component that injects the `router` object from the `useRouter` hook\n * into the props of the wrapped component.\n *\n * @internal\n * @deprecated - Use the `useRouter` hook instead.\n *\n * @param Component - The component to wrap.\n *\n * @returns The wrapped component.\n *\n * @example\n * ```tsx\n * function MyComponent(props) {\n * return <div>{props.router.state.myParam}</div>\n * }\n *\n * export default withRouter(MyComponent)\n * ```\n */\nexport function withRouter<Props extends {router: RouterContextValue}>(\n Component: ComponentType<Props>,\n): FunctionComponent<Omit<Props, 'router'>> {\n function WithRouter(props: Omit<Props, 'router'>) {\n const router = useRouter()\n\n return <Component {...(props as Props)} router={router} />\n }\n\n WithRouter.displayName = `withRouter(${Component.displayName || Component.name})`\n\n return WithRouter\n}\n\n/**\n * @internal\n * @deprecated - Use the `useRouter` hook instead.\n */\nexport interface WithRouterProps {\n /**\n * The `router` object from the `useRouter` hook.\n * {@link RouterContextValue}\n */\n router: RouterContextValue\n /**\n * A function that renders the wrapped component with the `router` object as a parameter.\n */\n children: (router: RouterContextValue) => React.JSX.Element\n}\n\n/**\n * A higher-order component that injects the router object into its child component.\n *\n * @internal\n * @deprecated - Use the `useRouter` hook instead.\n *\n * @returns The rendered component.\n *\n * @example\n * ```tsx\n * function MyComponent(props: {router: Router}) {\n * const {location} = props.router\n * const {pathname} = location\n * return <p>The current path is: {pathname}</p>\n * }\n *\n * function App() {\n * return (\n * <Router>\n * <WithRouter>\n * {router => <MyComponent router={router} />}\n * </WithRouter>\n * </Router>\n * )\n * }\n * ```\n */\nexport const WithRouter = withRouter((props: WithRouterProps) => props.children(props.router))\n"],"names":["useRouter","router","useContext","RouterContext","Error","isLeftClickEvent","event","button","isModifiedEvent","metaKey","altKey","ctrlKey","shiftKey","useLink","options","$","_c","onClick","onClickProp","href","target","replace","t0","undefined","navigateUrl","t1","isDefaultPrevented","preventDefault","path","t2","useIntentLink","intent","params","searchParams","resolveIntentLink","t3","IntentLink","forwardRef","props","ref","restProps","Link","VALID_PARAM_SEGMENT","createSegment","segment","startsWith","paramName","slice","test","addendum","includes","error","type","name","_parseRoute","route","pathname","split","segments","map","filter","Boolean","raw","arrayify","val","Array","isArray","isRecord","value","isPlainObject","createMatchError","node","missingKeys","unmappableStateKeys","createMatchOk","matchedState","child","_findMatchingRoutes","_state","scopedState","scope","_searchParams","state","requiredParams","seg","stateKeys","Object","keys","consumedParams","intersection","missingParams","difference","remainingParams","length","scopedParams","key","consumedState","pick","children","remainingState","found","childNode","find","res","encodeURIComponentExcept","uriComponent","unescaped","chars","String","i","char","encodeURIComponent","debug","Debug","_resolvePathFromState","match","unmappable","quote","join","pathFromMatchResult","search","encodeParams","bracketify","flatMap","encodeSearchParamKey","serializeScopedPath","encodeSearchParamValue","scopedPath","head","tail","base","transform","toPath","childMatch","addNodeScope","__unsafe_disableScopedSearchParams","namespaces","parseScopedParams","parse","OPEN","CLOSED","str","result","nextBracketIdx","indexOf","push","nextClosing","matchPath","parts","segmentsLength","every","toState","rest","childState","unscopedParams","removeScope","some","childParams","selfParams","namespace","mergedState","_resolveStateFromPath","urlSearchParams","from","URLSearchParams","entries","pathMatch","encodeBase64Url","encodeBase64","decodeBase64Url","decodeBase64","percentToByte","p","fromCharCode","parseInt","btoa","byteToPercent","b","charCodeAt","toString","decodeURIComponent","atob","decodeJsonParams","pathSegment","JSON","console","warn","encodeJsonParams","stringify","decodeParams","reduce","pair","create","routeOrOpts","childrenOrOpts","_createNode","normalizeArgs","intents","basePath","normalize","payload","scopeName","normalizeChildren","isRoute","paths","acc","concat","EMPTY_STATE","isRoot","TypeError","parsedRoute","_isRoute","encode","decode","_path","isNotFound","getBasePath","getRedirectBase","STICKY_PARAMS","isNavigateOptions","maybeNavigateOptions","RouterProvider","onNavigate","routerProp","useCallback","intentName","parameters","toPairs","fromPairs","resolvePathFromState","nextState","currentStateParams","nextStateParams","nextParams","param","replaceStickyParam","findParam","navigate","nextStateOrOptions","maybeOptions","baseState","getStateFromOptions","currentParams","nextStickyParams","stickyParams","fromEntries","validateStickyParams","mergedParams","mergeStickyParams","handleNavigateStickyParams","navigateIntent","routerState","useMemo","sticky","restParams","partition","stickyParamsByName","navigateStickyParams","current","filtered","newParams","filteredParams","hasOwn","isValidSearchParam","entry","convertNullSearchParam","newEntries","k","addScope","RouteScope","parentRouter","parent_resolvePathFromState","parent_navigate","parentStateRef","useRef","useEffect","_nextState","nextParentState","resolveNextParentState","nextState_0","t4","nextState_1","nextState_2","t5","parentState","t6","childRouter","t7","displayName","useStateLink","toIndex","StateLink","useRouterState","selector","identity","withRouter","Component","WithRouter","jsx"],"mappings":";;;;;;;AAkBO,SAAAA,IAAA;AACLC,QAAAA,IAAeC,G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AA9BG,IAAC,gBAAAiR,EAAAF,GAAA,EAAelR,GAAAA,GAAyBrB,QAAAA,EAAU,CAAA,GAAAc,OAAAd,GAAAc,OAAAO,GAAAP,OAAAU,KAAAA,IAAAV,EAAA,CAAA,GAAnDU;AAAAA,EAAAA;AAGTgR,SAAAA,EAAWT,cAAc,cAAcQ,EAAUR,eAAeQ,EAAUnP,IAAI,KAEvEoP;AACT;AA6CaA,MAAAA,KAAaF,GAAW,CAACjQ,MAA2BA,EAAM4D,SAAS5D,EAAMrC,MAAM,CAAC;"}
|
@@ -1,358 +0,0 @@
|
|
1
|
-
import { i as I, C as H } from "./index-RoxwhtVB.mjs";
|
2
|
-
const D = /_key\s*==\s*['"](.*)['"]/;
|
3
|
-
function K(t) {
|
4
|
-
return typeof t == "string" ? D.test(t.trim()) : typeof t == "object" && "_key" in t;
|
5
|
-
}
|
6
|
-
function L(t) {
|
7
|
-
if (!Array.isArray(t))
|
8
|
-
throw new Error("Path is not an array");
|
9
|
-
return t.reduce((e, r, i) => {
|
10
|
-
const n = typeof r;
|
11
|
-
if (n === "number")
|
12
|
-
return `${e}[${r}]`;
|
13
|
-
if (n === "string")
|
14
|
-
return `${e}${i === 0 ? "" : "."}${r}`;
|
15
|
-
if (K(r) && r._key)
|
16
|
-
return `${e}[_key=="${r._key}"]`;
|
17
|
-
if (Array.isArray(r)) {
|
18
|
-
const [s, o] = r;
|
19
|
-
return `${e}[${s}:${o}]`;
|
20
|
-
}
|
21
|
-
throw new Error(`Unsupported path segment \`${JSON.stringify(r)}\``);
|
22
|
-
}, "");
|
23
|
-
}
|
24
|
-
const A = {
|
25
|
-
"\f": "\\f",
|
26
|
-
"\n": "\\n",
|
27
|
-
"\r": "\\r",
|
28
|
-
" ": "\\t",
|
29
|
-
"'": "\\'",
|
30
|
-
"\\": "\\\\"
|
31
|
-
}, x = {
|
32
|
-
"\\f": "\f",
|
33
|
-
"\\n": `
|
34
|
-
`,
|
35
|
-
"\\r": "\r",
|
36
|
-
"\\t": " ",
|
37
|
-
"\\'": "'",
|
38
|
-
"\\\\": "\\"
|
39
|
-
};
|
40
|
-
function X(t) {
|
41
|
-
return `$${t.map((e) => typeof e == "string" ? `['${e.replace(/[\f\n\r\t'\\]/g, (r) => A[r])}']` : typeof e == "number" ? `[${e}]` : e._key !== "" ? `[?(@._key=='${e._key.replace(/['\\]/g, (r) => A[r])}')]` : `[${e._index}]`).join("")}`;
|
42
|
-
}
|
43
|
-
function j(t) {
|
44
|
-
const e = [], r = /\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;
|
45
|
-
let i;
|
46
|
-
for (; (i = r.exec(t)) !== null; ) {
|
47
|
-
if (i[1] !== void 0) {
|
48
|
-
const n = i[1].replace(/\\(\\|f|n|r|t|')/g, (s) => x[s]);
|
49
|
-
e.push(n);
|
50
|
-
continue;
|
51
|
-
}
|
52
|
-
if (i[2] !== void 0) {
|
53
|
-
e.push(parseInt(i[2], 10));
|
54
|
-
continue;
|
55
|
-
}
|
56
|
-
if (i[3] !== void 0) {
|
57
|
-
const n = i[3].replace(/\\(\\')/g, (s) => x[s]);
|
58
|
-
e.push({
|
59
|
-
_key: n,
|
60
|
-
_index: -1
|
61
|
-
});
|
62
|
-
continue;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
return e;
|
66
|
-
}
|
67
|
-
function C(t) {
|
68
|
-
return t.map((e) => {
|
69
|
-
if (typeof e == "string" || typeof e == "number")
|
70
|
-
return e;
|
71
|
-
if (e._key !== "")
|
72
|
-
return { _key: e._key };
|
73
|
-
if (e._index !== -1)
|
74
|
-
return e._index;
|
75
|
-
throw new Error(`invalid segment:${JSON.stringify(e)}`);
|
76
|
-
});
|
77
|
-
}
|
78
|
-
function z(t) {
|
79
|
-
return t.map((e) => {
|
80
|
-
if (typeof e == "string" || typeof e == "number")
|
81
|
-
return e;
|
82
|
-
if (e._index !== -1)
|
83
|
-
return e._index;
|
84
|
-
throw new Error(`invalid segment:${JSON.stringify(e)}`);
|
85
|
-
});
|
86
|
-
}
|
87
|
-
function B(t, e) {
|
88
|
-
if (!(e != null && e.mappings))
|
89
|
-
return;
|
90
|
-
const r = X(z(t));
|
91
|
-
if (e.mappings[r] !== void 0)
|
92
|
-
return {
|
93
|
-
mapping: e.mappings[r],
|
94
|
-
matchedPath: r,
|
95
|
-
pathSuffix: ""
|
96
|
-
};
|
97
|
-
const i = Object.entries(e.mappings).filter(([p]) => r.startsWith(p)).sort(([p], [d]) => d.length - p.length);
|
98
|
-
if (i.length == 0)
|
99
|
-
return;
|
100
|
-
const [n, s] = i[0], o = r.substring(n.length);
|
101
|
-
return { mapping: s, matchedPath: n, pathSuffix: o };
|
102
|
-
}
|
103
|
-
function Q(t) {
|
104
|
-
return t !== null && Array.isArray(t);
|
105
|
-
}
|
106
|
-
function $(t, e, r = []) {
|
107
|
-
if (Q(t))
|
108
|
-
return t.map((i, n) => {
|
109
|
-
if (I(i)) {
|
110
|
-
const s = i._key;
|
111
|
-
if (typeof s == "string")
|
112
|
-
return $(i, e, r.concat({ _key: s, _index: n }));
|
113
|
-
}
|
114
|
-
return $(i, e, r.concat(n));
|
115
|
-
});
|
116
|
-
if (I(t)) {
|
117
|
-
if (t._type === "block" || t._type === "span") {
|
118
|
-
const i = { ...t };
|
119
|
-
return t._type === "block" ? i.children = $(t.children, e, r.concat("children")) : t._type === "span" && (i.text = $(t.text, e, r.concat("text"))), i;
|
120
|
-
}
|
121
|
-
return Object.fromEntries(
|
122
|
-
Object.entries(t).map(([i, n]) => [i, $(n, e, r.concat(i))])
|
123
|
-
);
|
124
|
-
}
|
125
|
-
return e(t, r);
|
126
|
-
}
|
127
|
-
function Y(t, e, r) {
|
128
|
-
return $(t, (i, n) => {
|
129
|
-
if (typeof i != "string")
|
130
|
-
return i;
|
131
|
-
const s = B(n, e);
|
132
|
-
if (!s)
|
133
|
-
return i;
|
134
|
-
const { mapping: o, matchedPath: p } = s;
|
135
|
-
if (o.type !== "value" || o.source.type !== "documentValue")
|
136
|
-
return i;
|
137
|
-
const d = e.documents[o.source.document], u = e.paths[o.source.path], h = j(p), y = j(u).concat(n.slice(h.length));
|
138
|
-
return r({
|
139
|
-
sourcePath: y,
|
140
|
-
sourceDocument: d,
|
141
|
-
resultPath: n,
|
142
|
-
value: i
|
143
|
-
});
|
144
|
-
});
|
145
|
-
}
|
146
|
-
const Z = "drafts", v = "versions", E = ".", N = `${Z}${E}`, g = `${v}${E}`;
|
147
|
-
function W(t) {
|
148
|
-
return t.startsWith(N);
|
149
|
-
}
|
150
|
-
function m(t) {
|
151
|
-
return t.startsWith(g);
|
152
|
-
}
|
153
|
-
function tt(t) {
|
154
|
-
return !W(t) && !m(t);
|
155
|
-
}
|
156
|
-
function et(t) {
|
157
|
-
if (!m(t)) return;
|
158
|
-
const [e, r, ...i] = t.split(E);
|
159
|
-
return r;
|
160
|
-
}
|
161
|
-
function nt(t) {
|
162
|
-
return m(t) ? t.split(E).slice(2).join(E) : W(t) ? t.slice(N.length) : t;
|
163
|
-
}
|
164
|
-
function rt(t) {
|
165
|
-
const {
|
166
|
-
baseUrl: e,
|
167
|
-
workspace: r = "default",
|
168
|
-
tool: i = "default",
|
169
|
-
id: n,
|
170
|
-
type: s,
|
171
|
-
path: o,
|
172
|
-
projectId: p,
|
173
|
-
dataset: d
|
174
|
-
} = t;
|
175
|
-
if (!e)
|
176
|
-
throw new Error("baseUrl is required");
|
177
|
-
if (!o)
|
178
|
-
throw new Error("path is required");
|
179
|
-
if (!n)
|
180
|
-
throw new Error("id is required");
|
181
|
-
if (e !== "/" && e.endsWith("/"))
|
182
|
-
throw new Error("baseUrl must not end with a slash");
|
183
|
-
const u = r === "default" ? void 0 : r, h = i === "default" ? void 0 : i, y = nt(n), k = Array.isArray(o) ? L(C(o)) : o, f = new URLSearchParams({
|
184
|
-
baseUrl: e,
|
185
|
-
id: y,
|
186
|
-
type: s,
|
187
|
-
path: k
|
188
|
-
});
|
189
|
-
if (u && f.set("workspace", u), h && f.set("tool", h), p && f.set("projectId", p), d && f.set("dataset", d), tt(n))
|
190
|
-
f.set("perspective", "published");
|
191
|
-
else if (m(n)) {
|
192
|
-
const P = et(n);
|
193
|
-
f.set("perspective", P);
|
194
|
-
}
|
195
|
-
const l = [e === "/" ? "" : e];
|
196
|
-
u && l.push(u);
|
197
|
-
const w = [
|
198
|
-
"mode=presentation",
|
199
|
-
`id=${y}`,
|
200
|
-
`type=${s}`,
|
201
|
-
`path=${encodeURIComponent(k)}`
|
202
|
-
];
|
203
|
-
return h && w.push(`tool=${h}`), l.push("intent", "edit", `${w.join(";")}?${f}`), l.join("/");
|
204
|
-
}
|
205
|
-
function it(t) {
|
206
|
-
let e = typeof t == "string" ? t : t.baseUrl;
|
207
|
-
return e !== "/" && (e = e.replace(/\/$/, "")), typeof t == "string" ? { baseUrl: e } : { ...t, baseUrl: e };
|
208
|
-
}
|
209
|
-
const T = ({ sourcePath: t, resultPath: e, value: r }) => {
|
210
|
-
if (st(r) || at(r))
|
211
|
-
return !1;
|
212
|
-
const i = t.at(-1);
|
213
|
-
return !(t.at(-2) === "slug" && i === "current" || typeof i == "string" && (i.startsWith("_") || i.endsWith("Id")) || t.some(
|
214
|
-
(n) => n === "meta" || n === "metadata" || n === "openGraph" || n === "seo"
|
215
|
-
) || U(t) || U(e) || typeof i == "string" && ot.has(i));
|
216
|
-
}, ot = /* @__PURE__ */ new Set([
|
217
|
-
"color",
|
218
|
-
"colour",
|
219
|
-
"currency",
|
220
|
-
"email",
|
221
|
-
"format",
|
222
|
-
"gid",
|
223
|
-
"hex",
|
224
|
-
"href",
|
225
|
-
"hsl",
|
226
|
-
"hsla",
|
227
|
-
"icon",
|
228
|
-
"id",
|
229
|
-
"index",
|
230
|
-
"key",
|
231
|
-
"language",
|
232
|
-
"layout",
|
233
|
-
"link",
|
234
|
-
"linkAction",
|
235
|
-
"locale",
|
236
|
-
"lqip",
|
237
|
-
"page",
|
238
|
-
"path",
|
239
|
-
"ref",
|
240
|
-
"rgb",
|
241
|
-
"rgba",
|
242
|
-
"route",
|
243
|
-
"secret",
|
244
|
-
"slug",
|
245
|
-
"status",
|
246
|
-
"tag",
|
247
|
-
"template",
|
248
|
-
"theme",
|
249
|
-
"type",
|
250
|
-
"textTheme",
|
251
|
-
"unit",
|
252
|
-
"url",
|
253
|
-
"username",
|
254
|
-
"variant",
|
255
|
-
"website"
|
256
|
-
]);
|
257
|
-
function st(t) {
|
258
|
-
return /^\d{4}-\d{2}-\d{2}/.test(t) ? !!Date.parse(t) : !1;
|
259
|
-
}
|
260
|
-
function at(t) {
|
261
|
-
try {
|
262
|
-
new URL(t, t.startsWith("/") ? "https://acme.com" : void 0);
|
263
|
-
} catch {
|
264
|
-
return !1;
|
265
|
-
}
|
266
|
-
return !0;
|
267
|
-
}
|
268
|
-
function U(t) {
|
269
|
-
return t.some((e) => typeof e == "string" && e.match(/type/i) !== null);
|
270
|
-
}
|
271
|
-
const S = 20;
|
272
|
-
function ct(t, e, r) {
|
273
|
-
var d, u, h, y, k, f, l, w, P;
|
274
|
-
const { filter: i, logger: n, enabled: s } = r;
|
275
|
-
if (!s) {
|
276
|
-
const a = "config.enabled must be true, don't call this function otherwise";
|
277
|
-
throw (d = n == null ? void 0 : n.error) == null || d.call(n, `[@sanity/client]: ${a}`, { result: t, resultSourceMap: e, config: r }), new TypeError(a);
|
278
|
-
}
|
279
|
-
if (!e)
|
280
|
-
return (u = n == null ? void 0 : n.error) == null || u.call(n, "[@sanity/client]: Missing Content Source Map from response body", {
|
281
|
-
result: t,
|
282
|
-
resultSourceMap: e,
|
283
|
-
config: r
|
284
|
-
}), t;
|
285
|
-
if (!r.studioUrl) {
|
286
|
-
const a = "config.studioUrl must be defined";
|
287
|
-
throw (h = n == null ? void 0 : n.error) == null || h.call(n, `[@sanity/client]: ${a}`, { result: t, resultSourceMap: e, config: r }), new TypeError(a);
|
288
|
-
}
|
289
|
-
const o = {
|
290
|
-
encoded: [],
|
291
|
-
skipped: []
|
292
|
-
}, p = Y(
|
293
|
-
t,
|
294
|
-
e,
|
295
|
-
({ sourcePath: a, sourceDocument: _, resultPath: b, value: c }) => {
|
296
|
-
if ((typeof i == "function" ? i({ sourcePath: a, resultPath: b, filterDefault: T, sourceDocument: _, value: c }) : T({ sourcePath: a, resultPath: b, value: c })) === !1)
|
297
|
-
return n && o.skipped.push({
|
298
|
-
path: O(a),
|
299
|
-
value: `${c.slice(0, S)}${c.length > S ? "..." : ""}`,
|
300
|
-
length: c.length
|
301
|
-
}), c;
|
302
|
-
n && o.encoded.push({
|
303
|
-
path: O(a),
|
304
|
-
value: `${c.slice(0, S)}${c.length > S ? "..." : ""}`,
|
305
|
-
length: c.length
|
306
|
-
});
|
307
|
-
const { baseUrl: R, workspace: V, tool: M } = it(
|
308
|
-
typeof r.studioUrl == "function" ? r.studioUrl(_) : r.studioUrl
|
309
|
-
);
|
310
|
-
if (!R) return c;
|
311
|
-
const { _id: q, _type: J, _projectId: F, _dataset: G } = _;
|
312
|
-
return H(
|
313
|
-
c,
|
314
|
-
{
|
315
|
-
origin: "sanity.io",
|
316
|
-
href: rt({
|
317
|
-
baseUrl: R,
|
318
|
-
workspace: V,
|
319
|
-
tool: M,
|
320
|
-
id: q,
|
321
|
-
type: J,
|
322
|
-
path: a,
|
323
|
-
...!r.omitCrossDatasetReferenceData && { dataset: G, projectId: F }
|
324
|
-
})
|
325
|
-
},
|
326
|
-
// We use custom logic to determine if we should skip encoding
|
327
|
-
!1
|
328
|
-
);
|
329
|
-
}
|
330
|
-
);
|
331
|
-
if (n) {
|
332
|
-
const a = o.skipped.length, _ = o.encoded.length;
|
333
|
-
if ((a || _) && ((y = (n == null ? void 0 : n.groupCollapsed) || n.log) == null || y("[@sanity/client]: Encoding source map into result"), (k = n.log) == null || k.call(
|
334
|
-
n,
|
335
|
-
`[@sanity/client]: Paths encoded: ${o.encoded.length}, skipped: ${o.skipped.length}`
|
336
|
-
)), o.encoded.length > 0 && ((f = n == null ? void 0 : n.log) == null || f.call(n, "[@sanity/client]: Table of encoded paths"), (l = (n == null ? void 0 : n.table) || n.log) == null || l(o.encoded)), o.skipped.length > 0) {
|
337
|
-
const b = /* @__PURE__ */ new Set();
|
338
|
-
for (const { path: c } of o.skipped)
|
339
|
-
b.add(c.replace(D, "0").replace(/\[\d+\]/g, "[]"));
|
340
|
-
(w = n == null ? void 0 : n.log) == null || w.call(n, "[@sanity/client]: List of skipped paths", [...b.values()]);
|
341
|
-
}
|
342
|
-
(a || _) && ((P = n == null ? void 0 : n.groupEnd) == null || P.call(n));
|
343
|
-
}
|
344
|
-
return p;
|
345
|
-
}
|
346
|
-
function O(t) {
|
347
|
-
return L(C(t));
|
348
|
-
}
|
349
|
-
var ft = /* @__PURE__ */ Object.freeze({
|
350
|
-
__proto__: null,
|
351
|
-
stegaEncodeSourceMap: ct
|
352
|
-
});
|
353
|
-
export {
|
354
|
-
Y as encodeIntoResult,
|
355
|
-
ct as stegaEncodeSourceMap,
|
356
|
-
ft as stegaEncodeSourceMap$1
|
357
|
-
};
|
358
|
-
//# sourceMappingURL=stegaEncodeSourceMap-DCG9Ba1H.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"stegaEncodeSourceMap-DCG9Ba1H.mjs","sources":["../../../node_modules/.pnpm/@sanity+client@7.6.0_debug@4.4.1/node_modules/@sanity/client/dist/_chunks-es/stegaEncodeSourceMap.js"],"sourcesContent":["import { isRecord, C } from \"./stegaClean.js\";\nconst reKeySegment = /_key\\s*==\\s*['\"](.*)['\"]/;\nfunction isKeySegment(segment) {\n return typeof segment == \"string\" ? reKeySegment.test(segment.trim()) : typeof segment == \"object\" && \"_key\" in segment;\n}\nfunction toString(path) {\n if (!Array.isArray(path))\n throw new Error(\"Path is not an array\");\n return path.reduce((target, segment, i) => {\n const segmentType = typeof segment;\n if (segmentType === \"number\")\n return `${target}[${segment}]`;\n if (segmentType === \"string\")\n return `${target}${i === 0 ? \"\" : \".\"}${segment}`;\n if (isKeySegment(segment) && segment._key)\n return `${target}[_key==\"${segment._key}\"]`;\n if (Array.isArray(segment)) {\n const [from, to] = segment;\n return `${target}[${from}:${to}]`;\n }\n throw new Error(`Unsupported path segment \\`${JSON.stringify(segment)}\\``);\n }, \"\");\n}\nconst ESCAPE = {\n \"\\f\": \"\\\\f\",\n \"\\n\": \"\\\\n\",\n \"\\r\": \"\\\\r\",\n \"\t\": \"\\\\t\",\n \"'\": \"\\\\'\",\n \"\\\\\": \"\\\\\\\\\"\n}, UNESCAPE = {\n \"\\\\f\": \"\\f\",\n \"\\\\n\": `\n`,\n \"\\\\r\": \"\\r\",\n \"\\\\t\": \"\t\",\n \"\\\\'\": \"'\",\n \"\\\\\\\\\": \"\\\\\"\n};\nfunction jsonPath(path) {\n return `$${path.map((segment) => typeof segment == \"string\" ? `['${segment.replace(/[\\f\\n\\r\\t'\\\\]/g, (match) => ESCAPE[match])}']` : typeof segment == \"number\" ? `[${segment}]` : segment._key !== \"\" ? `[?(@._key=='${segment._key.replace(/['\\\\]/g, (match) => ESCAPE[match])}')]` : `[${segment._index}]`).join(\"\")}`;\n}\nfunction parseJsonPath(path) {\n const parsed = [], parseRe = /\\['(.*?)'\\]|\\[(\\d+)\\]|\\[\\?\\(@\\._key=='(.*?)'\\)\\]/g;\n let match;\n for (; (match = parseRe.exec(path)) !== null; ) {\n if (match[1] !== void 0) {\n const key = match[1].replace(/\\\\(\\\\|f|n|r|t|')/g, (m) => UNESCAPE[m]);\n parsed.push(key);\n continue;\n }\n if (match[2] !== void 0) {\n parsed.push(parseInt(match[2], 10));\n continue;\n }\n if (match[3] !== void 0) {\n const _key = match[3].replace(/\\\\(\\\\')/g, (m) => UNESCAPE[m]);\n parsed.push({\n _key,\n _index: -1\n });\n continue;\n }\n }\n return parsed;\n}\nfunction jsonPathToStudioPath(path) {\n return path.map((segment) => {\n if (typeof segment == \"string\" || typeof segment == \"number\")\n return segment;\n if (segment._key !== \"\")\n return { _key: segment._key };\n if (segment._index !== -1)\n return segment._index;\n throw new Error(`invalid segment:${JSON.stringify(segment)}`);\n });\n}\nfunction jsonPathToMappingPath(path) {\n return path.map((segment) => {\n if (typeof segment == \"string\" || typeof segment == \"number\")\n return segment;\n if (segment._index !== -1)\n return segment._index;\n throw new Error(`invalid segment:${JSON.stringify(segment)}`);\n });\n}\nfunction resolveMapping(resultPath, csm) {\n if (!csm?.mappings)\n return;\n const resultMappingPath = jsonPath(jsonPathToMappingPath(resultPath));\n if (csm.mappings[resultMappingPath] !== void 0)\n return {\n mapping: csm.mappings[resultMappingPath],\n matchedPath: resultMappingPath,\n pathSuffix: \"\"\n };\n const mappings = Object.entries(csm.mappings).filter(([key]) => resultMappingPath.startsWith(key)).sort(([key1], [key2]) => key2.length - key1.length);\n if (mappings.length == 0)\n return;\n const [matchedPath, mapping] = mappings[0], pathSuffix = resultMappingPath.substring(matchedPath.length);\n return { mapping, matchedPath, pathSuffix };\n}\nfunction isArray(value) {\n return value !== null && Array.isArray(value);\n}\nfunction walkMap(value, mappingFn, path = []) {\n if (isArray(value))\n return value.map((v, idx) => {\n if (isRecord(v)) {\n const _key = v._key;\n if (typeof _key == \"string\")\n return walkMap(v, mappingFn, path.concat({ _key, _index: idx }));\n }\n return walkMap(v, mappingFn, path.concat(idx));\n });\n if (isRecord(value)) {\n if (value._type === \"block\" || value._type === \"span\") {\n const result = { ...value };\n return value._type === \"block\" ? result.children = walkMap(value.children, mappingFn, path.concat(\"children\")) : value._type === \"span\" && (result.text = walkMap(value.text, mappingFn, path.concat(\"text\"))), result;\n }\n return Object.fromEntries(\n Object.entries(value).map(([k, v]) => [k, walkMap(v, mappingFn, path.concat(k))])\n );\n }\n return mappingFn(value, path);\n}\nfunction encodeIntoResult(result, csm, encoder) {\n return walkMap(result, (value, path) => {\n if (typeof value != \"string\")\n return value;\n const resolveMappingResult = resolveMapping(path, csm);\n if (!resolveMappingResult)\n return value;\n const { mapping, matchedPath } = resolveMappingResult;\n if (mapping.type !== \"value\" || mapping.source.type !== \"documentValue\")\n return value;\n const sourceDocument = csm.documents[mapping.source.document], sourcePath = csm.paths[mapping.source.path], matchPathSegments = parseJsonPath(matchedPath), fullSourceSegments = parseJsonPath(sourcePath).concat(path.slice(matchPathSegments.length));\n return encoder({\n sourcePath: fullSourceSegments,\n sourceDocument,\n resultPath: path,\n value\n });\n });\n}\nconst DRAFTS_FOLDER = \"drafts\", VERSION_FOLDER = \"versions\", PATH_SEPARATOR = \".\", DRAFTS_PREFIX = `${DRAFTS_FOLDER}${PATH_SEPARATOR}`, VERSION_PREFIX = `${VERSION_FOLDER}${PATH_SEPARATOR}`;\nfunction isDraftId(id) {\n return id.startsWith(DRAFTS_PREFIX);\n}\nfunction isVersionId(id) {\n return id.startsWith(VERSION_PREFIX);\n}\nfunction isPublishedId(id) {\n return !isDraftId(id) && !isVersionId(id);\n}\nfunction getVersionFromId(id) {\n if (!isVersionId(id)) return;\n const [_versionPrefix, versionId, ..._publishedId] = id.split(PATH_SEPARATOR);\n return versionId;\n}\nfunction getPublishedId(id) {\n return isVersionId(id) ? id.split(PATH_SEPARATOR).slice(2).join(PATH_SEPARATOR) : isDraftId(id) ? id.slice(DRAFTS_PREFIX.length) : id;\n}\nfunction createEditUrl(options) {\n const {\n baseUrl,\n workspace: _workspace = \"default\",\n tool: _tool = \"default\",\n id: _id,\n type,\n path,\n projectId,\n dataset\n } = options;\n if (!baseUrl)\n throw new Error(\"baseUrl is required\");\n if (!path)\n throw new Error(\"path is required\");\n if (!_id)\n throw new Error(\"id is required\");\n if (baseUrl !== \"/\" && baseUrl.endsWith(\"/\"))\n throw new Error(\"baseUrl must not end with a slash\");\n const workspace = _workspace === \"default\" ? void 0 : _workspace, tool = _tool === \"default\" ? void 0 : _tool, id = getPublishedId(_id), stringifiedPath = Array.isArray(path) ? toString(jsonPathToStudioPath(path)) : path, searchParams = new URLSearchParams({\n baseUrl,\n id,\n type,\n path: stringifiedPath\n });\n if (workspace && searchParams.set(\"workspace\", workspace), tool && searchParams.set(\"tool\", tool), projectId && searchParams.set(\"projectId\", projectId), dataset && searchParams.set(\"dataset\", dataset), isPublishedId(_id))\n searchParams.set(\"perspective\", \"published\");\n else if (isVersionId(_id)) {\n const versionId = getVersionFromId(_id);\n searchParams.set(\"perspective\", versionId);\n }\n const segments = [baseUrl === \"/\" ? \"\" : baseUrl];\n workspace && segments.push(workspace);\n const routerParams = [\n \"mode=presentation\",\n `id=${id}`,\n `type=${type}`,\n `path=${encodeURIComponent(stringifiedPath)}`\n ];\n return tool && routerParams.push(`tool=${tool}`), segments.push(\"intent\", \"edit\", `${routerParams.join(\";\")}?${searchParams}`), segments.join(\"/\");\n}\nfunction resolveStudioBaseRoute(studioUrl) {\n let baseUrl = typeof studioUrl == \"string\" ? studioUrl : studioUrl.baseUrl;\n return baseUrl !== \"/\" && (baseUrl = baseUrl.replace(/\\/$/, \"\")), typeof studioUrl == \"string\" ? { baseUrl } : { ...studioUrl, baseUrl };\n}\nconst filterDefault = ({ sourcePath, resultPath, value }) => {\n if (isValidDate(value) || isValidURL(value))\n return !1;\n const endPath = sourcePath.at(-1);\n return !(sourcePath.at(-2) === \"slug\" && endPath === \"current\" || typeof endPath == \"string\" && (endPath.startsWith(\"_\") || endPath.endsWith(\"Id\")) || sourcePath.some(\n (path) => path === \"meta\" || path === \"metadata\" || path === \"openGraph\" || path === \"seo\"\n ) || hasTypeLike(sourcePath) || hasTypeLike(resultPath) || typeof endPath == \"string\" && denylist.has(endPath));\n}, denylist = /* @__PURE__ */ new Set([\n \"color\",\n \"colour\",\n \"currency\",\n \"email\",\n \"format\",\n \"gid\",\n \"hex\",\n \"href\",\n \"hsl\",\n \"hsla\",\n \"icon\",\n \"id\",\n \"index\",\n \"key\",\n \"language\",\n \"layout\",\n \"link\",\n \"linkAction\",\n \"locale\",\n \"lqip\",\n \"page\",\n \"path\",\n \"ref\",\n \"rgb\",\n \"rgba\",\n \"route\",\n \"secret\",\n \"slug\",\n \"status\",\n \"tag\",\n \"template\",\n \"theme\",\n \"type\",\n \"textTheme\",\n \"unit\",\n \"url\",\n \"username\",\n \"variant\",\n \"website\"\n]);\nfunction isValidDate(dateString) {\n return /^\\d{4}-\\d{2}-\\d{2}/.test(dateString) ? !!Date.parse(dateString) : !1;\n}\nfunction isValidURL(url) {\n try {\n new URL(url, url.startsWith(\"/\") ? \"https://acme.com\" : void 0);\n } catch {\n return !1;\n }\n return !0;\n}\nfunction hasTypeLike(path) {\n return path.some((segment) => typeof segment == \"string\" && segment.match(/type/i) !== null);\n}\nconst TRUNCATE_LENGTH = 20;\nfunction stegaEncodeSourceMap(result, resultSourceMap, config) {\n const { filter, logger, enabled } = config;\n if (!enabled) {\n const msg = \"config.enabled must be true, don't call this function otherwise\";\n throw logger?.error?.(`[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);\n }\n if (!resultSourceMap)\n return logger?.error?.(\"[@sanity/client]: Missing Content Source Map from response body\", {\n result,\n resultSourceMap,\n config\n }), result;\n if (!config.studioUrl) {\n const msg = \"config.studioUrl must be defined\";\n throw logger?.error?.(`[@sanity/client]: ${msg}`, { result, resultSourceMap, config }), new TypeError(msg);\n }\n const report = {\n encoded: [],\n skipped: []\n }, resultWithStega = encodeIntoResult(\n result,\n resultSourceMap,\n ({ sourcePath, sourceDocument, resultPath, value }) => {\n if ((typeof filter == \"function\" ? filter({ sourcePath, resultPath, filterDefault, sourceDocument, value }) : filterDefault({ sourcePath, resultPath, value })) === !1)\n return logger && report.skipped.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? \"...\" : \"\"}`,\n length: value.length\n }), value;\n logger && report.encoded.push({\n path: prettyPathForLogging(sourcePath),\n value: `${value.slice(0, TRUNCATE_LENGTH)}${value.length > TRUNCATE_LENGTH ? \"...\" : \"\"}`,\n length: value.length\n });\n const { baseUrl, workspace, tool } = resolveStudioBaseRoute(\n typeof config.studioUrl == \"function\" ? config.studioUrl(sourceDocument) : config.studioUrl\n );\n if (!baseUrl) return value;\n const { _id: id, _type: type, _projectId: projectId, _dataset: dataset } = sourceDocument;\n return C(\n value,\n {\n origin: \"sanity.io\",\n href: createEditUrl({\n baseUrl,\n workspace,\n tool,\n id,\n type,\n path: sourcePath,\n ...!config.omitCrossDatasetReferenceData && { dataset, projectId }\n })\n },\n // We use custom logic to determine if we should skip encoding\n !1\n );\n }\n );\n if (logger) {\n const isSkipping = report.skipped.length, isEncoding = report.encoded.length;\n if ((isSkipping || isEncoding) && ((logger?.groupCollapsed || logger.log)?.(\"[@sanity/client]: Encoding source map into result\"), logger.log?.(\n `[@sanity/client]: Paths encoded: ${report.encoded.length}, skipped: ${report.skipped.length}`\n )), report.encoded.length > 0 && (logger?.log?.(\"[@sanity/client]: Table of encoded paths\"), (logger?.table || logger.log)?.(report.encoded)), report.skipped.length > 0) {\n const skipped = /* @__PURE__ */ new Set();\n for (const { path } of report.skipped)\n skipped.add(path.replace(reKeySegment, \"0\").replace(/\\[\\d+\\]/g, \"[]\"));\n logger?.log?.(\"[@sanity/client]: List of skipped paths\", [...skipped.values()]);\n }\n (isSkipping || isEncoding) && logger?.groupEnd?.();\n }\n return resultWithStega;\n}\nfunction prettyPathForLogging(path) {\n return toString(jsonPathToStudioPath(path));\n}\nvar stegaEncodeSourceMap$1 = /* @__PURE__ */ Object.freeze({\n __proto__: null,\n stegaEncodeSourceMap\n});\nexport {\n encodeIntoResult,\n stegaEncodeSourceMap,\n stegaEncodeSourceMap$1\n};\n//# sourceMappingURL=stegaEncodeSourceMap.js.map\n"],"names":["reKeySegment","isKeySegment","segment","toString","path","target","segmentType","from","to","ESCAPE","UNESCAPE","jsonPath","match","parseJsonPath","parsed","parseRe","key","m","_key","jsonPathToStudioPath","jsonPathToMappingPath","resolveMapping","resultPath","csm","resultMappingPath","mappings","key1","key2","matchedPath","mapping","pathSuffix","isArray","value","walkMap","mappingFn","v","idx","isRecord","result","k","encodeIntoResult","encoder","resolveMappingResult","sourceDocument","sourcePath","matchPathSegments","fullSourceSegments","DRAFTS_FOLDER","VERSION_FOLDER","PATH_SEPARATOR","DRAFTS_PREFIX","VERSION_PREFIX","isDraftId","id","isVersionId","isPublishedId","getVersionFromId","_versionPrefix","versionId","_publishedId","getPublishedId","createEditUrl","options","baseUrl","_workspace","_tool","_id","type","projectId","dataset","workspace","tool","stringifiedPath","searchParams","segments","routerParams","resolveStudioBaseRoute","studioUrl","filterDefault","isValidDate","isValidURL","endPath","hasTypeLike","denylist","dateString","url","TRUNCATE_LENGTH","stegaEncodeSourceMap","resultSourceMap","config","filter","logger","enabled","msg","_a","_b","_c","report","resultWithStega","prettyPathForLogging","C","isSkipping","isEncoding","_d","_e","_f","_g","skipped","_h","_i","stegaEncodeSourceMap$1"],"mappings":";AACA,MAAMA,IAAe;AACrB,SAASC,EAAaC,GAAS;AAC7B,SAAO,OAAOA,KAAW,WAAWF,EAAa,KAAKE,EAAQ,KAAI,CAAE,IAAI,OAAOA,KAAW,YAAY,UAAUA;AAClH;AACA,SAASC,EAASC,GAAM;AACtB,MAAI,CAAC,MAAM,QAAQA,CAAI;AACrB,UAAM,IAAI,MAAM,sBAAsB;AACxC,SAAOA,EAAK,OAAO,CAACC,GAAQH,GAAS,MAAM;AACzC,UAAMI,IAAc,OAAOJ;AAC3B,QAAII,MAAgB;AAClB,aAAO,GAAGD,CAAM,IAAIH,CAAO;AAC7B,QAAII,MAAgB;AAClB,aAAO,GAAGD,CAAM,GAAG,MAAM,IAAI,KAAK,GAAG,GAAGH,CAAO;AACjD,QAAID,EAAaC,CAAO,KAAKA,EAAQ;AACnC,aAAO,GAAGG,CAAM,WAAWH,EAAQ,IAAI;AACzC,QAAI,MAAM,QAAQA,CAAO,GAAG;AAC1B,YAAM,CAACK,GAAMC,CAAE,IAAIN;AACnB,aAAO,GAAGG,CAAM,IAAIE,CAAI,IAAIC,CAAE;AAAA,IACpC;AACI,UAAM,IAAI,MAAM,8BAA8B,KAAK,UAAUN,CAAO,CAAC,IAAI;AAAA,EAC1E,GAAE,EAAE;AACP;AACA,MAAMO,IAAS;AAAA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