import{withPathPrefix as s,getPathPrefix as f}from"@redocly/theme/core/utils";import{ServerRoutes as u}from"../constants/index.js";import{removeTrailingSlash as d,isLocalLink as p,addTrailingSlash as R}from"./utils.js";function P(t){return`/page-data${t==="/"?"/index":t}/data.json`}function U(t){const e=f();if(e){const o=t.slice(e.length);return`${e}/page-data${o==="/"?"/index":o}/data.json`}return P(t)}function m(t){return`/page-data/shared/${t}.json`}const L="/app-data.json",_="/eject-component";function E(t){const e=decodeURI(t);return encodeURI(e.replace(/^[\/\s\u0000]+/g,"/"))}function x(t,e){const o=t.indexOf("?")>-1?"&":"?";return`${t}${o}${new URLSearchParams(e).toString()}`}const O=process.env.SERVER_EDITOR_APP_URL||"http://127.0.0.1:3000";function $(t){return/^https?:\/\//.test(t)}function y(t,e,o,i,a,c={}){if(!t)return;const n=i?.[e]||s(u.IDP_LOGIN),r={idpId:t,localePrefix:o,redirectTo:a||"",...c};return x(n,r)}function j({redirects:t,requestedSlug:e,reqUrlSearch:o=""}){if(Object.keys(t||{}).length>0){const i=t[e];let a=i?.to?d(i.to):i?.to;if(a){const n=p(a)?s(a):a;return{location:encodeURI(n+o),type:i?.type||301}}const c=Object.keys(t).find(n=>{const r=n.match(/^(.+)\*$/);return r&&R(e).startsWith(r[1])});if(c){let n=t[c]?.to;if(n){if(n.endsWith("*")){const l=e.replace(c.split("*")[0],"");n=n.replace(/\*$/,l)}let r=p(n)?s(n):n;return o&&(r=d(r)),{location:encodeURI(r+o),type:301}}}}return null}export{_ as EJECT_COMPONENT_URL,L as GLOBAL_DATA_URL,O as SERVER_EDITOR_APP_URL,x as appendQueryParams,y as buildClientLoginUrl,U as getClientPageDataUrl,P as getPageDataUrl,m as getSharedDataUrl,$ as isAbsoluteUrl,j as processRedirects,E as sanitizeRedirectPathname};
