import{isObject as i,isString as p}from"@redocly/theme/core/openapi";import{isNamedDefinition as a}from"./openapi.js";import{JsonPointer as f}from"./JsonPointer.js";import{urlParse as u}from"./url.js";import{IS_BROWSER as l}from"./dom.js";function w(r,e){const t=[];for(let n=0;n<r.length-1;n++)t.push(e(r[n],!1));return r.length!==0&&t.push(e(r[r.length-1],!0)),t}function A(r,e){const t={};for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=e(r[n],n,r));return t}function R(r,e){const t=[],n=o=>{for(const s of o)t.push(s),s[e]&&n(s[e])};return n(r),t}function c(r){return r.endsWith("/")?r.substring(0,r.length-1):r}function b(r){return!isNaN(parseFloat(r))&&isFinite(r)}function E(r,e,t){const n=new RegExp(`(^|\\n)#\\s?${e}\\s*\\n`,"i"),o=new RegExp(`((\\n|^)#\\s*${e}\\s*(\\n|$)(?:.|\\n)*?)(\\n#|$)`,"i");if(n.test(r))return r.replace(o,`$1

${t}
$4`);{const s=r===""||r.endsWith(`

`)?"":r.endsWith(`
`)?`
`:`

`;return`${r}${s}# ${e}

${t}`}}const W=r=>Array.isArray(r)&&r.some(e=>i(e)),y=r=>r.filter(e=>!!e),C=r=>i(r)&&!Array.isArray(r);function x(r){return/(?:^[a-z][a-z0-9+.-]*:|\/\/)/i.test(r)}function N(r,e){let t;if(e.startsWith("//"))t=`${u(r,!0)?.protocol||"https:"}${e}`;else if(x(e))t=e;else if(!e.startsWith("/"))t=c(r)+"/"+e;else{const n=u(r);n?(n.pathname=e,t=n.toString()):t=e}return c(t)}function I(r){return r.charAt(0).toUpperCase()+r.slice(1)}function L(r){try{if(!r)return"";const e=new URL(r);return e.search="",e.hash="",e.toString()}catch{return r}}function P(r){return r.replace(/["\\]/g,"\\$&")}function T(r){return r.replace(/&#(\d+);/g,(e,t)=>String.fromCharCode(parseInt(t,10))).replace(/&quot;/g,'"').replace(/&amp;/g,"&")}function j(r){return r&&r.replace(/#/g,"_").toLowerCase()}function z(r,e){return e||a(r)&&f.baseName(r)||""}function M(r={},e,t){return typeof e=="string"&&(e=e.split(".")),e.reduce((n,o)=>n&&n[o]?n[o]:t,r)}function g(r){return(...e)=>e.filter(Boolean).join(r)}const D=g(".");function F(r){return l?window?.REFERENCE_DOCS_OPTIONS?.[r]:null}const _=r=>p(r)?r:r?.raw,H=(r,e)=>{const t=r?.[`x-parsed-md-${e}`]||r?.[e];if(!t)return;if(!r?.[`x-parsed-md-${e}`]&&e!=="x-enumDescriptions")return r?.[e];if(e!=="x-enumDescriptions")return d(r,e);let n={};for(const o in t)o.startsWith("x-parsed-md")||(n[o]=t?.[`x-parsed-md-${o}`]||t?.[o]);return Object.keys(n).length?n:t};function B(r){return r.name||r.description}function d(r,e){const t=r?.[`x-parsed-md-${e}`]||r?.[e];return t?.raw?t:{result:t?.result||r?.[e]?.result||r?.[e],raw:r?.[e]}}function U(r,e){return e===r.length-1}function V(r,e){const t=Object.keys(r);return t.indexOf(e)===t.length-1}export{E as appendToMdHeading,y as deleteEmptyArrayItem,D as dottedString,P as escapeHTMLAttrChars,R as flattenByProp,M as get,B as getServerDisplayName,H as getValueFromMdParsedExtension,F as getWindowReferenceOptions,x as isAbsoluteUrl,W as isArrayOfObjects,U as isLastInArray,V as isLastProperty,C as isMergeableObject,b as isNumeric,g as joinStringFactory,A as mapValues,w as mapWithLast,_ as normalizeText,L as removeQueryStringAndHash,N as resolveUrl,j as sanitizeItemId,c as stripTrailingSlash,I as titleize,T as unescapeHTMLChars,z as useSchemaTitle};
