// @bun
var{defineProperty:_,getOwnPropertyNames:b,getOwnPropertyDescriptor:D}=Object,v=Object.prototype.hasOwnProperty;function H(q){return this[q]}var R=(q)=>{var z=(K??=new WeakMap).get(q),G;if(z)return z;if(z=_({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var E of b(q))if(!v.call(z,E))_(z,E,{get:H.bind(q,E),enumerable:!(G=D(q,E))||G.enumerable})}return K.set(q,z),z},K;var T=(q)=>q;function P(q,z){this[q]=T.bind(null,z)}var C=(q,z)=>{for(var G in z)_(q,G,{get:z[G],enumerable:!0,configurable:!0,set:P.bind(z,G)})};var k=(q,z)=>()=>(q&&(z=q(q=0)),z);var f=import.meta.require;function w(q,z=""){let G=`${q}${z}`,E=0;for(let F=0;F<G.length;F++){let L=G.charCodeAt(F);E=(E<<5)-E+L,E=E&E}return`stx-${Math.abs(E).toString(36)}`}function W(q,z,G={}){let{prefix:E="",preserveHost:F=!0,scopeKeyframes:L=!0,scopeCustomProperties:J=!1}=G;if(!q.trim())return"";let X=$(q),U=[],Q=new Map;if(L)for(let O of X){let V=O.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(V){let Y=V[1],Z=`${z}_${Y}`;Q.set(Y,Z)}}for(let O of X){let V=B(O,z,E,F,Q,J);U.push(V)}return U.join(`

`)}function $(q){let z=[],G=q.replace(/\/\*[\s\S]*?\*\//g,""),E=0,F="",L=!1,J="";for(let X=0;X<G.length;X++){let U=G[X];if(U==="@"&&E===0)L=!0;if(U==="{")E++;else if(U==="}"){if(E--,E===0){if(L){J+=U;let Q=J.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(Q){let[,O,V,Y]=Q;if(O==="keyframes")z.push({selector:`@keyframes ${V.trim()}`,declarations:Y.trim()});else if(O==="media"||O==="supports"||O==="container"){let Z=$(Y);z.push({selector:`@${O} ${V.trim()}`,declarations:Z.map((j)=>`${j.selector} { ${j.declarations} }`).join(`
`)})}else z.push({selector:`@${O} ${V.trim()}`,declarations:Y.trim()})}J="",L=!1}else if(F.trim()){F+=U;let Q=F.match(/([^{]+)\{([^}]*)\}/);if(Q)z.push({selector:Q[1].trim(),declarations:Q[2].trim()});F=""}continue}}if(L)J+=U;else F+=U}return z}function B(q,z,G,E,F,L){let{selector:J,declarations:X}=q;if(J.startsWith("@")){if(J.startsWith("@keyframes")){let O=J.replace("@keyframes ","").trim();return`@keyframes ${F.get(O)||O} { ${X} }`}if(J.startsWith("@media")||J.startsWith("@supports")||J.startsWith("@container")){let V=$(`x { ${X} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((Y)=>B(Y,z,G,E,F,L)).join(`
  `);return`${J} {
  ${V}
}`}return`${J} { ${X} }`}let U=S(J,z,G,E),Q=X;for(let[O,V]of F)Q=Q.replace(new RegExp(`\\b${O}\\b`,"g"),V);if(L)Q=Q.replace(/--([a-z-]+)/gi,`--${z}-$1`);return`${U} { ${Q} }`}function S(q,z,G,E){let F=q.split(",").map((J)=>J.trim()),L=[];for(let J of F){if(J.startsWith(":host")){if(E)L.push(J);else{let U=J.replace(/:host(\([^)]*\))?/,`.${z}$1`);L.push(U)}continue}if(J.includes("::slotted")){L.push(J);continue}if(J===":root"){L.push(`:root .${z}`);continue}let X=G?`${G} .${z}`:`.${z}`;L.push(`${X} ${J}`)}return L.join(", ")}function N(q){let z=q.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i),G=z?z[1]:"",E=z?q.replace(/<style\b[^>]*>[\s\S]*?<\/style>/i,""):q;return{css:G,templateWithoutStyle:E}}function g(q,z,G="head"){if(!z.trim())return q;let E=`<style data-stx-scoped>
${z}
</style>`;switch(G){case"head":if(q.includes("</head>"))return q.replace("</head>",`${E}
</head>`);return E+q;case"body-start":if(q.includes("<body"))return q.replace(/(<body[^>]*>)/,`$1
${E}`);return E+q;case"body-end":{let F=q.lastIndexOf("</body>");if(F!==-1)return q.slice(0,F)+E+`
`+q.slice(F);return q+E}default:return q}}function i(q){return q.trim()}function u(q,z){if(!/<style\s+[^>]*\bscoped\b/i.test(q))return{html:q,hasScoped:!1};let G=w(z),E=`data-v-${G}`,F=q,L=/<style\s+([^>]*\bscoped\b[^>]*)>([\s\S]*?)<\/style>/gi,J=!1;if(F=F.replace(L,(X,U,Q)=>{J=!0;let O=M(Q,E),V=U.replace(/\bscoped\b/gi,"").trim(),Y=V?` ${V}`:"";return`<style data-stx-scoped="${G}"${Y}>${O}</style>`}),!J)return{html:q,hasScoped:!1};return F=A(F,E),{html:F,hasScoped:!0}}function M(q,z){return W(q,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${z}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${z}]`)}function A(q,z){let G=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return q.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(E,F,L)=>{if(G.has(F.toLowerCase()))return E;if(E.includes(z))return E;if(F.toLowerCase()==="style"||F.toLowerCase()==="script")return E;if(L)return E.replace(`<${F}${L}`,`<${F} ${z}${L}`);if(E.endsWith("/>"))return`<${F} ${z} />`;return`<${F} ${z}>`})}var I=()=>{};I();export{u as processScopedStyles};
