{"version":3,"sources":["../../../src/client/components/client-page.tsx"],"sourcesContent":["'use client'\n\nimport type { ParsedUrlQuery } from 'querystring'\nimport type { Params } from '../../server/request/params'\nimport { LayoutRouterContext } from '../../shared/lib/app-router-context.shared-runtime'\nimport { use } from 'react'\nimport { urlSearchParamsToParsedUrlQuery } from '../route-params'\nimport { SearchParamsContext } from '../../shared/lib/hooks-client-context.shared-runtime'\n\n/**\n * When the Page is a client component we send the params and searchParams to this client wrapper\n * where they are turned into dynamically tracked values before being passed to the actual Page component.\n *\n * additionally we may send promises representing the params and searchParams. We don't ever use these passed\n * values but it can be necessary for the sender to send a Promise that doesn't resolve in certain situations.\n * It is up to the caller to decide if the promises are needed.\n */\nexport function ClientPageRoot({\n  Component,\n  serverProvidedParams,\n}: {\n  Component: React.ComponentType<any>\n  serverProvidedParams: null | {\n    searchParams: ParsedUrlQuery\n    params: Params\n    promises: Array<Promise<any>> | null\n  }\n}) {\n  let searchParams: ParsedUrlQuery\n  let params: Params\n  if (serverProvidedParams !== null) {\n    searchParams = serverProvidedParams.searchParams\n    params = serverProvidedParams.params\n  } else {\n    // When Cache Components is enabled, the server does not pass the params as\n    // props; they are parsed on the client and passed via context.\n    const layoutRouterContext = use(LayoutRouterContext)\n    params =\n      layoutRouterContext !== null ? layoutRouterContext.parentParams : {}\n\n    // This is an intentional behavior change: when Cache Components is enabled,\n    // client segments receive the \"canonical\" search params, not the\n    // rewritten ones. Users should either call useSearchParams directly or pass\n    // the rewritten ones in from a Server Component.\n    // TODO: Log a deprecation error when this object is accessed\n    searchParams = urlSearchParamsToParsedUrlQuery(use(SearchParamsContext)!)\n  }\n\n  if (typeof window === 'undefined') {\n    let clientSearchParams: Promise<ParsedUrlQuery>\n    let clientParams: Promise<Params>\n\n    const { createSearchParamsFromClient } =\n      require('../../server/request/search-params') as typeof import('../../server/request/search-params')\n    clientSearchParams = createSearchParamsFromClient(searchParams)\n\n    const { createParamsFromClient } =\n      require('../../server/request/params') as typeof import('../../server/request/params')\n    clientParams = createParamsFromClient(params)\n\n    return <Component params={clientParams} searchParams={clientSearchParams} />\n  } else {\n    const { createRenderSearchParamsFromClient } =\n      require('../request/search-params.browser') as typeof import('../request/search-params.browser')\n    const clientSearchParams = createRenderSearchParamsFromClient(searchParams)\n    const { createRenderParamsFromClient } =\n      require('../request/params.browser') as typeof import('../request/params.browser')\n    const clientParams = createRenderParamsFromClient(params)\n\n    return <Component params={clientParams} searchParams={clientSearchParams} />\n  }\n}\n"],"names":["ClientPageRoot","Component","serverProvidedParams","searchParams","params","layoutRouterContext","use","LayoutRouterContext","parentParams","urlSearchParamsToParsedUrlQuery","SearchParamsContext","window","clientSearchParams","clientParams","createSearchParamsFromClient","require","createParamsFromClient","createRenderSearchParamsFromClient","createRenderParamsFromClient"],"mappings":"AAAA;;;;;+BAiBgBA;;;eAAAA;;;;+CAboB;uBAChB;6BAC4B;iDACZ;AAU7B,SAASA,eAAe,EAC7BC,SAAS,EACTC,oBAAoB,EAQrB;IACC,IAAIC;IACJ,IAAIC;IACJ,IAAIF,yBAAyB,MAAM;QACjCC,eAAeD,qBAAqBC,YAAY;QAChDC,SAASF,qBAAqBE,MAAM;IACtC,OAAO;QACL,2EAA2E;QAC3E,+DAA+D;QAC/D,MAAMC,sBAAsBC,IAAAA,UAAG,EAACC,kDAAmB;QACnDH,SACEC,wBAAwB,OAAOA,oBAAoBG,YAAY,GAAG,CAAC;QAErE,4EAA4E;QAC5E,iEAAiE;QACjE,4EAA4E;QAC5E,iDAAiD;QACjD,6DAA6D;QAC7DL,eAAeM,IAAAA,4CAA+B,EAACH,IAAAA,UAAG,EAACI,oDAAmB;IACxE;IAEA,IAAI,OAAOC,WAAW,aAAa;QACjC,IAAIC;QACJ,IAAIC;QAEJ,MAAM,EAAEC,4BAA4B,EAAE,GACpCC,QAAQ;QACVH,qBAAqBE,6BAA6BX;QAElD,MAAM,EAAEa,sBAAsB,EAAE,GAC9BD,QAAQ;QACVF,eAAeG,uBAAuBZ;QAEtC,qBAAO,qBAACH;YAAUG,QAAQS;YAAcV,cAAcS;;IACxD,OAAO;QACL,MAAM,EAAEK,kCAAkC,EAAE,GAC1CF,QAAQ;QACV,MAAMH,qBAAqBK,mCAAmCd;QAC9D,MAAM,EAAEe,4BAA4B,EAAE,GACpCH,QAAQ;QACV,MAAMF,eAAeK,6BAA6Bd;QAElD,qBAAO,qBAACH;YAAUG,QAAQS;YAAcV,cAAcS;;IACxD;AACF","ignoreList":[0]}