import{useMemo as l}from"react";import{components as c}from"@redocly-markdoc/components";import{Ast as u}from"@markdoc/markdoc";import{PageNavigation as f}from"@redocly/theme/components/PageNavigation/PageNavigation";import{tags as g,components as d}from"@redocly/theme/markdoc/default";import{Breadcrumbs as _}from"@redocly/theme/components/Breadcrumbs/Breadcrumbs";import{withPathPrefix as a}from"@redocly/theme/core/utils";import{OPENAPI_DOCS_TEMPLATE_ID as h,ServerRoutes as P}from"../../../../constants/index.js";import{getCssPropertyValue as S}from"../../../../shared/utils.js";import{isBrowser as v}from"../../../../shared/jsUtils.js";import*as O from"../../markdown/markdoc/custom-components/index.js";import*as C from"../../markdown/markdoc/nodes/index.js";import T from"../../markdown/markdoc/tags/index.js";import{usePageData as y,useSidebarSiblingsData as A}from"../../../../client/providers/page-data/hooks";import{otelTelemetry as I}from"../../../../client/app/telemetry/otel/telemetry.js";import{getMockServerDocsConfig as D}from"./mock-server-config";function $(o="",e="",t="/"){return o.endsWith(t)&&(o=o.slice(0,-t.length)),e.startsWith(t)&&(e=e.slice(t.length)),!o||!e?o+e:o+t+e}function i(o){return({operationHttpVerb:e,operationPath:t,lang:r,action:n,state:m,serverUrl:s})=>I.send({type:"openapi_docs",payload:{event_type:o,operationHttpVerb:e,operationPath:t,lang:r,action:n,state:m,serverUrl:s}})}function R(o){if(o)return Object.entries(o).reduce((e,[t,r])=>(e[t]=u.fromJSON(JSON.stringify(r)),e),{})}function F(o,{markdown:e,baseSlug:t}){return l(()=>{const n=v();return o.options.oAuth2RedirectURI=n?`${window.location.origin}${a(P.REPLAY_OAUTH2_CALLBACK)}`:null,o.options.routingBasePath=a(t),o.options.mockServer=D(o.options.mockServer,t),o.options.scrollYOffset=n?parseInt(S("--navbar-height"),10):0,o.options.markdocOptions={tags:{...T,...g},nodes:{...C},components:{...O,...d,...c,...globalThis.__LOADER.markdocComponents},...e,partials:R(e?.partials)},o.options.unstable_hooks={...o.options.unstable_hooks,MiddlePanelFooter:()=>{const{templateId:m}=y()||{},{nextPage:s,prevPage:p}=A()||{};return m===h?null:f({nextPage:s,prevPage:p})},MiddlePanelHeader:()=>_({})},o.options.events={codeSamplesLanguageSwitch:i("samples_language_switch"),codeSamplesCopy:i("code_samples_copy"),panelToggle:i("panel_toggle"),targetServerSwitch:i("target_server_switch")},o},[o,e,t])}export{$ as joinWithSeparator,F as usePatchedStore};
