import{e as xn,n as Y,p as Pn,q as wn,s as On,v as w,x as Q,r as nn,y as z,T as U,C as Tn,z as Dn,A as Mn,j as Rn,i as Z,B as Ln,D as An,o as En}from"./-dIGDsTg.js";const Un=/\d/,_n=["-","_","/","."];function Bn(n=""){if(!Un.test(n))return n!==n.toLowerCase()}function en(n,l){const e=_n,o=[];if(!n||typeof n!="string")return o;let r="",a,c;for(const f of n){const d=e.includes(f);if(d===!0){o.push(r),r="",a=void 0;continue}const p=Bn(f);if(c===!1){if(a===!1&&p===!0){o.push(r),r=f,a=p;continue}if(a===!0&&p===!1&&r.length>1){const s=r.at(-1);o.push(r.slice(0,Math.max(0,r.length-1))),r=s+f,a=p;continue}}r+=f,a=p,c=d}return o.push(r),o}function jn(n){return n?n[0].toUpperCase()+n.slice(1):""}function D(n,l){return n?(Array.isArray(n)?n:en(n)).map(e=>jn(e)).join(""):""}function ln(n,l){return n?(Array.isArray(n)?n:en(n)).map(e=>e.toLowerCase()).join("-"):""}const H=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);class E{constructor(l,e,o){this.normal=e,this.property=l,o&&(this.space=o)}}E.prototype.normal={};E.prototype.property={};E.prototype.space=void 0;function tn(n,l){const e={},o={};for(const r of n)Object.assign(e,r.property),Object.assign(o,r.normal);return new E(e,o,l)}function F(n){return n.toLowerCase()}class b{constructor(l,e){this.attribute=e,this.property=l}}b.prototype.attribute="";b.prototype.booleanish=!1;b.prototype.boolean=!1;b.prototype.commaOrSpaceSeparated=!1;b.prototype.commaSeparated=!1;b.prototype.defined=!1;b.prototype.mustUseProperty=!1;b.prototype.number=!1;b.prototype.overloadedBoolean=!1;b.prototype.property="";b.prototype.spaceSeparated=!1;b.prototype.space=void 0;let In=0;const u=M(),y=M(),N=M(),t=M(),g=M(),L=M(),S=M();function M(){return 2**++In}const V=Object.freeze(Object.defineProperty({__proto__:null,boolean:u,booleanish:y,commaOrSpaceSeparated:S,commaSeparated:L,number:t,overloadedBoolean:N,spaceSeparated:g},Symbol.toStringTag,{value:"Module"})),I=Object.keys(V);class $ extends b{constructor(l,e,o,r){let a=-1;if(super(l,e),G(this,"space",r),typeof o=="number")for(;++a4&&e.slice(0,4)==="data"&&Nn.test(l)){if(l.charAt(4)==="-"){const a=l.slice(5).replace(J,Wn);o="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=l.slice(4);if(!J.test(a)){let c=a.replace(Fn,qn);c.charAt(0)!=="-"&&(c="-"+c),l="data"+c}}r=$}return new r(o,l)}function qn(n){return"-"+n.toLowerCase()}function Wn(n){return n.charAt(1).toUpperCase()}const $n=tn([on,zn,un,sn,cn],"html");tn([on,Hn,un,sn,cn],"svg");const Kn=["p","h1","h2","h3","h4","h5","h6","li"];function _(n,l){return n.type===l||typeof n.type=="object"&&n.type.tag===l||n.tag===l}function K(n){return _(n,"text")||_(n,Symbol.for("v-txt"))}function pn(n){return Array.isArray(n.children)||typeof n.children=="string"?n.children:typeof n.children?.default=="function"?n.children.default():[]}function B(n){if(!n)return"";if(Array.isArray(n))return n.map(B).join("");if(K(n))return n.value||n.children||"";const l=pn(n);return Array.isArray(l)?l.map(B).filter(Boolean).join(""):""}function dn(n,l=[]){if(Array.isArray(n))return n.flatMap(o=>dn(o,l));let e=n;return l.some(o=>o==="*"||_(n,o))&&(e=pn(n)||n,!Array.isArray(e)&&Kn.some(o=>_(n,o))&&(e=[e])),e}function fn(n,l=[]){return n=Array.isArray(n)?n:[n],l.length?n.flatMap(e=>fn(dn(e,[l[0]]),l.slice(1))).filter(e=>!(K(e)&&B(e).trim()==="")):n}function gn(n,l=[]){return typeof l=="string"&&(l=l.split(/[,\s]/).map(e=>e.trim()).filter(Boolean)),l.length?fn(n,l).reduce((e,o)=>(K(o)?typeof e[e.length-1]=="string"?e[e.length-1]+=o.children:e.push(o.children):e.push(o),e),[]):n}function Xn(n,l){return l.reduce((e,o)=>{const r=Yn(n,o);return r!==void 0&&(e[o]=r),e},{})}function Yn(n,l){return l.split(".").reduce((e,o)=>e&&e[o],n)}const q="default",mn=/^@|^v-on:/,hn=/^:|^v-bind:/,Zn=/^v-model/,Gn=["select","textarea","input"],Jn=new Set(["math","svg"]),yn=new Set,Qn=Object.fromEntries(["p","a","blockquote","code","pre","code","em","h1","h2","h3","h4","h5","h6","hr","img","ul","ol","li","strong","table","thead","tbody","td","th","tr","script"].map(n=>[n,`prose-${n}`])),ne=["script","base"],ee=xn({name:"MDCRenderer",props:{body:{type:Object,required:!0},data:{type:Object,default:()=>({})},class:{type:[String,Object],default:void 0},tag:{type:[String,Boolean],default:void 0},prose:{type:Boolean,default:void 0},components:{type:Object,default:()=>({})},unwrap:{type:[Boolean,String],default:!1}},async setup(n){const e=On()?.appContext?.app?.$nuxt,o=e?.$route||e?._route,{mdc:r}=e?.$config?.public||{},a=r?.components?.customElements||r?.components?.custom;a&&a.forEach(s=>yn.add(s));const c=w(()=>({...r?.components?.prose&&n.prose!==!1?Qn:{},...r?.components?.map||{},...Q(n.data?.mdc?.components||{}),...n.components})),f=w(()=>{const s=(n.body?.children||[]).map(m=>m.tag||m.type).filter(m=>!X(m));return Array.from(new Set(s)).sort().join(".")}),d=Pn({...n.data});wn(()=>n.data,s=>{Object.assign(d,s)}),await de(n.body,{tags:c.value});function p(s,m){const k=s.split(".").length-1;return s.split(".").reduce((C,P,O)=>O==k&&C?(C[P]=m,C[P]):typeof C=="object"?C[P]:void 0,d)}return{tags:c,contentKey:f,route:o,runtimeData:d,updateRuntimeData:p}},render(n){const{tags:l,tag:e,body:o,data:r,contentKey:a,route:c,unwrap:f,runtimeData:d,updateRuntimeData:p}=n;if(!o)return null;const s={...r,tags:l,$route:c,runtimeData:d,updateRuntimeData:p},m=e!==!1?W(e||s.component?.name||s.component||"div"):void 0;return m?Y(m,{...s.component?.props,class:n.class,...this.$attrs,key:a},{default:k}):k?.();function k(){const C=vn(o,Y,{documentMeta:s,parentScope:s,resolveComponent:W});return C?.default?f?gn(C.default(),typeof f=="string"?f.split(" "):["*"]):C.default():null}}});function le(n,l,e,o){const{documentMeta:r,parentScope:a,resolveComponent:c}=e;if(n.type==="text")return l(U,n.value);if(n.type==="comment")return l(Tn,null,n.value);const f=n.tag,d=Cn(n,r.tags);if(n.tag==="binding")return te(n,l,r,a);const p=bn(d)?k=>k:c;if(ne.includes(D(d).toLowerCase()))return l("pre",{class:"mdc-renderer-dangerous-tag"},"<"+d+">"+B(n)+"");const s=p(d);typeof s=="object"&&(s.tag=f);const m=oe(n,r);return o&&(m.key=o),l(s,m,vn(n,l,{documentMeta:r,parentScope:{...a,...m},resolveComponent:p}))}function vn(n,l,e){const{documentMeta:o,parentScope:r,resolveComponent:a}=e,f=(n.children||[]).reduce((p,s)=>{if(!ce(s))return p[q].children.push(s),p;const m=se(s);return p[m]=p[m]||{props:{},children:[]},s.type==="element"&&(p[m].props=s.props,p[m].children.push(...s.children||[])),p},{[q]:{props:{},children:[]}});return Object.entries(f).reduce((p,[s,{props:m,children:k}])=>(k.length&&(p[s]=(C={})=>{const P=Xn(C,Object.keys(m||{}));let O=k.map((i,h)=>le(i,l,{documentMeta:o,parentScope:{...r,...P},resolveComponent:a},String(i.props?.key||h)));return m?.unwrap&&(O=gn(O,m.unwrap)),pe(O)}),p),{})}function te(n,l,e,o={}){const r={...e.runtimeData,...o,$document:e,$doc:e},a=/\.|\[(\d+)\]/,f=(n.props?.value.trim().split(a).filter(Boolean)).reduce((p,s)=>{if(p&&s in p)return typeof p[s]=="function"?p[s]():p[s]},r),d=n.props?.defaultValue;return l(U,f??d??"")}function oe(n,l){const{tag:e="",props:o={}}=n;return Object.keys(o).reduce(function(r,a){if(a==="__ignoreMap")return r;const c=o[a];if(Zn.test(a))return re(a,c,r,l,{native:Gn.includes(e)});if(a==="v-bind")return ae(a,c,r,l);if(mn.test(a))return ue(a,c,r,l);if(hn.test(a))return ie(a,c,r,l);const{attribute:f}=Vn($n,a);return Array.isArray(c)&&c.every(d=>typeof d=="string")?(r[f]=c.join(" "),r):(r[f]=c,r)},{})}function re(n,l,e,o,{native:r}){const a=n.match(/^v-model:([^=]+)/)?.[1]||"modelValue",c=r?"value":a,f=r?"onInput":`onUpdate:${a}`;return e[c]=j(l,o.runtimeData),e[f]=d=>{o.updateRuntimeData(l,r?d.target?.value:d)},e}function ae(n,l,e,o){const r=j(l,o);return e=Object.assign(e,r),e}function ue(n,l,e,o){return n=n.replace(mn,""),e.on=e.on||{},e.on[n]=()=>j(l,o),e}function ie(n,l,e,o){return n=n.replace(hn,""),e[n]=j(l,o),e}const W=n=>{if(typeof n=="string"){if(X(n))return n;const l=nn(D(n),!1);return!n||l?.name==="AsyncComponentWrapper"||typeof l=="string"?l:"setup"in l?z(()=>new Promise(e=>e(l))):l}return n};function j(n,l){const e=n.split(".").reduce((o,r)=>typeof o=="object"?o[r]:void 0,l);return typeof e>"u"?Dn(n):e}function se(n){let l="";for(const e of Object.keys(n.props||{}))if(!(!e.startsWith("#")&&!e.startsWith("v-slot:"))){l=e.split(/[:#]/,2)[1];break}return l||q}function ce(n){return n.tag==="template"}function bn(n){return Jn.has(n)}function pe(n){const l=[];for(const e of n){const o=l[l.length-1];e.type===U&&o?.type===U?o.children=o.children+e.children:l.push(e)}return l}async function de(n,l){if(!n)return;const e=Array.from(new Set(o(n,l)));await Promise.all(e.map(async r=>{if(r?.render||r?.ssrRender||r?.__ssrInlineRender)return;const a=W(r);a?.__asyncLoader&&!a.__asyncResolved&&await a.__asyncLoader()}));function o(r,a){const c=r.tag;if(r.type==="text"||c==="binding"||r.type==="comment")return[];const f=Cn(r,a.tags);if(bn(f))return[];const d=[];r.type!=="root"&&!X(f)&&d.push(f);for(const p of r.children||[])d.push(...o(p,a));return d}}function Cn(n,l){const e=n.tag;return!e||typeof n.props?.__ignoreMap<"u"?e:l[e]||l[D(e)]||l[ln(n.tag)]||e}function X(n){return(typeof n=="string"?yn.has(n):!1)||H.has(n)}const fe=Object.assign(ee,{__name:"MDCRenderer"});function ge(n){return{type:"root",children:n.value.map(Sn)}}function Sn(n){if(typeof n=="string")return{type:"text",value:n};const[l,e,...o]=n;return{type:"element",tag:l,props:e,children:o.map(Sn)}}const me={},he=["ProseA","ProseBlockquote","ProseCode","ProseEm","ProseH1","ProseH2","ProseH3","ProseH4","ProseH5","ProseH6","ProseHr","ProseImg","ProseLi","ProseOl","ProseP","ProsePre","ProseScript","ProseStrong","ProseTable","ProseTbody","ProseTd","ProseTh","ProseThead","ProseTr","ProseUl"],ye=[],ve={__name:"ContentRenderer",props:{value:{type:Object,required:!0},excerpt:{type:Boolean,default:!1},tag:{type:String,default:"div"},components:{type:Object,default:()=>({})},data:{type:Object,default:()=>({})},prose:{type:Boolean,default:void 0},class:{type:[String,Object],default:void 0},unwrap:{type:[Boolean,String],default:!1}},setup(n){const l=["render","ssrRender","__ssrInlineRender"],e=n,o=import.meta.preview,r=w(()=>{let i=e.value.body||e.value;return e.excerpt&&e.value.excerpt&&(i=e.value.excerpt),i.type==="minimal"||i.type==="minimark"?ge({value:i.value}):i}),a=w(()=>!r.value?.children?.length),c=w(()=>{const{body:i,excerpt:h,...v}=e.value;return{...v,...e.data}}),f=Object.fromEntries(["p","a","blockquote","code","pre","code","em","h1","h2","h3","h4","h5","h6","hr","img","ul","ol","li","strong","table","thead","tbody","td","th","tr","script"].map(i=>[i,`prose-${i}`])),{mdc:d}=Mn().public||{},p=w(()=>e.data.mdc),s=w(()=>({...d?.components?.prose&&e.prose!==!1?f:{},...d?.components?.map||{},...Q(p.value?.components||{}),...e.components})),m=w(()=>r.value?C(r.value,{tags:s.value}):{});function k(i){let h=i;if(typeof i=="string"){if(H.has(i))return i;if(he.includes(D(i)))h=nn(i,!1);else if(ye.includes(D(i))){const x=me[D(i)];h=x?z(x):void 0}if(typeof h=="string")return h}if(!h)return h;const v=h;return"__asyncLoader"in v?v:"setup"in v?z(()=>Promise.resolve(v)):v}function C(i,h){if(!i)return;const v=Array.from(new Set(P(i,h))),x={};for(const[T,R]of v)if(!x[T]){if(typeof R=="object"&&l.some(kn=>Object.hasOwnProperty.call(R,kn))){x[T]=R;continue}x[T]=k(R)}return x}function P(i,h){const v=i.tag;if(i.type==="text"||v==="binding"||i.type==="comment")return[];const x=O(i,h.tags),T=[];i.type!=="root"&&!H.has(x)&&T.push([v,x]);for(const R of i.children||[])T.push(...P(R,h));return T}function O(i,h){const v=i.tag;return!v||typeof i.props?.__ignoreMap<"u"?v:h[v]||h[D(v)]||h[ln(i.tag)]||v}return(i,h)=>a.value?An(i.$slots,"empty",{key:1,body:r.value,data:c.value,dataContentId:Z(o)?n.value.id:void 0}):(En(),Rn(fe,{key:0,body:r.value,data:c.value,class:Ln(e.class),tag:e.tag,prose:e.prose,unwrap:e.unwrap,components:m.value,"data-content-id":Z(o)?n.value.id:void 0},null,8,["body","data","class","tag","prose","unwrap","components","data-content-id"]))}},Ce=Object.assign(ve,{__name:"ContentRenderer"});export{Ce as _};