// @bun
var{defineProperty:_,getOwnPropertyNames:k,getOwnPropertyDescriptor:I}=Object,R=Object.prototype.hasOwnProperty;function M(q){return this[q]}var h=(q)=>{var j=(L??=new WeakMap).get(q),G;if(j)return j;if(j=_({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var Q of k(q))if(!R.call(j,Q))_(j,Q,{get:M.bind(q,Q),enumerable:!(G=I(q,Q))||G.enumerable})}return L.set(q,j),j},L;var N=(q)=>q;function b(q,j){this[q]=N.bind(null,j)}var u=(q,j)=>{for(var G in j)_(q,G,{get:j[G],enumerable:!0,configurable:!0,set:b.bind(j,G)})};var C=(q,j)=>()=>(q&&(j=q(q=0)),j);var d=import.meta.require;function T(q){let j=new Map,G=/@(\w+)/g,Q,J=1,K=0;while((Q=G.exec(q))!==null){let W=Q[1],Y=q.slice(K,Q.index);J+=(Y.match(/\n/g)||[]).length,K=Q.index;let $=Q.index-q.lastIndexOf(`
`,Q.index-1);if(w.includes(W)){let X=j.get(W);if(X)X.count++,X.locations.push({line:J,column:$});else j.set(W,{name:W,count:1,locations:[{line:J,column:$}]})}}return Array.from(j.values())}function B(q,j=[]){let G=T(q),Q=new Set(G.map((J)=>J.name));for(let J of j)Q.add(J);for(let J of Array.from(Q))if(!J.startsWith("end"))Q.add(`end${J}`);return w.filter((J)=>!Q.has(J))}function V(q){let j=[],G={conditionals:["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","isset","endisset"],loops:["for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty"],includes:["include","includeIf","includeWhen","includeFirst","once","endonce","extends","section","endsection","yield","parent","push","endpush","prepend","endprepend","stack"],components:["component","endcomponent","slot","endslot","props"],auth:["auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole"],forms:["csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file"],i18n:["translate","lang","choice"],seo:["meta","title","seo","jsonld","canonical","robots","sitemap"]},Q=new Set;for(let K of q)for(let[W,Y]of Object.entries(G))if(Y.includes(K)){Q.add(W);break}for(let K of Q)j.push(`import { process${x(K)} } from './${K}'`);let J=q.filter((K)=>!K.startsWith("end")).map((K)=>`  '${K}': true`).join(`,
`);return`// Tree-shaken directive bundle
// Only includes: ${q.join(", ")}
${j.join(`
`)}

export const activeDirectives = {
${J}
}

export function isDirectiveActive(name: string): boolean {
  return name in activeDirectives
}
`}function O(q,j={}){let G=[],Q=/@if\(([^)]+)\)[\s\S]*?@endif/g,J=q.matchAll(Q);for(let X of J){let Z=X[1].trim();if(E(Z,j)===!1)G.push({start:X.index,end:X.index+X[0].length,reason:`@if condition always false: ${Z}`})}let K=/@unless\(([^)]+)\)[\s\S]*?@endunless/g,W=q.matchAll(K);for(let X of W){let Z=X[1].trim();if(E(Z,j)===!0)G.push({start:X.index,end:X.index+X[0].length,reason:`@unless condition always true: ${Z}`})}let Y=/@env\(['"]development['"]\)[\s\S]*?@endenv/g;if(j.__ENV__==="production"){let X=q.matchAll(Y);for(let Z of X)G.push({start:Z.index,end:Z.index+Z[0].length,reason:"Development-only code in production build"})}let $=/@debug[\s\S]*?@enddebug/g;if(j.__ENV__==="production"){let X=q.matchAll($);for(let Z of X)G.push({start:Z.index,end:Z.index+Z[0].length,reason:"Debug code in production build"})}return G}function S(q,j={}){let G=O(q,j),Q=[];G.sort((K,W)=>W.start-K.start);let J=q;for(let K of G)J=J.slice(0,K.start)+J.slice(K.end),Q.push(K.reason);return{content:J,removed:Q}}function E(q,j){if(q==="true")return!0;if(q==="false")return!1;if(q==="null")return null;if(/^\d+$/.test(q))return Number.parseInt(q,10);if(/^\d+\.\d+$/.test(q))return Number.parseFloat(q);if(/^['"].*['"]$/.test(q))return q.slice(1,-1);if(q in j)return j[q];let G=q.match(/^(\w+)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);if(G){let[,Q,J,K]=G,W=Q in j?j[Q]:void 0,Y=E(K,j);if(W!==void 0&&Y!==void 0)switch(J){case"==":case"===":return W===Y;case"!=":case"!==":return W!==Y;case">":return W>Y;case"<":return W<Y;case">=":return W>=Y;case"<=":return W<=Y}}return}function f(q,j){let G=[],Q=q;return Q=Q.replace(/\{\{\s*(\w+)\s*\}\}/g,(J,K)=>{if(K in j)return G.push(`{{ ${K} }} -> ${j[K]}`),String(j[K]);return J}),Q=Q.replace(/\{\{\s*(\d+)\s*([+\-*])\s*(\d+)\s*\}\}/g,(J,K,W,Y)=>{let $=Number.parseInt(K,10),X=Number.parseInt(Y,10),Z;switch(W){case"+":Z=$+X;break;case"-":Z=$-X;break;case"*":Z=$*X;break;default:return J}return G.push(`{{ ${K} ${W} ${Y} }} -> ${Z}`),String(Z)}),{content:Q,folded:G}}function D(q){let j=q,G=[],Q=0;j=j.replace(/<(pre|code|script|style)([^>]*)>([\s\S]*?)<\/\1>/gi,(J)=>{let K=`__PRESERVE_${Q++}__`;return G.push({marker:K,content:J}),K}),j=j.replace(/\{\{([\s\S]*?)\}\}/g,(J)=>{let K=`__PRESERVE_${Q++}__`;return G.push({marker:K,content:J}),K}),j=j.replace(/\{\{--([\s\S]*?)--\}\}/g,""),j=j.replace(/<!--[\s\S]*?-->/g,""),j=j.replace(/>\s+</g,"><"),j=j.replace(/^\s+/gm,""),j=j.replace(/\s+$/gm,""),j=j.replace(/\s{2,}/g," ");for(let{marker:J,content:K}of G){let W=j.indexOf(J);if(W!==-1)j=j.slice(0,W)+K+j.slice(W+J.length)}return j.trim()}function z(q){let j=new Map,G=new Map,Q=/(['"])([^'"]{10,})\1/g,J;while((J=Q.exec(q))!==null){let Y=J[2];G.set(Y,(G.get(Y)||0)+1)}let K=0,W=q;for(let[Y,$]of G)if($>1){let X=`__STR_${K++}__`;j.set(X,Y);let Z=Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),F=new RegExp(`(['"])${Z}\\1`,"g");W=W.replace(F,X)}return{content:W,pool:j,count:j.size}}function v(q,j={}){let G={...A,...j},Q=new Blob([q]).size,J=q,K=[],W=[],Y=[],$=[],X=0;if(G.target==="production")G.constants={...G.constants,__ENV__:"production"};if(G.deadCodeElimination){let H=S(J,G.constants);if(J=H.content,H.removed.length>0)K.push("Dead code elimination"),W.push(...H.removed.map((y)=>`Removed: ${y}`))}if(G.constantFolding&&Object.keys(G.constants).length>0){let H=f(J,G.constants);if(J=H.content,$=H.folded,$.length>0)K.push("Constant folding")}if(G.treeShake){if(Y=B(J,G.preserveDirectives),Y.length>0)K.push("Tree shaking")}if(G.stringPooling){let H=z(J);if(J=H.content,X=H.count,X>0)K.push("String pooling")}if(G.minifyHtml){let H=D(J);if(H.length<J.length)J=H,K.push("HTML minification")}let Z=new Blob([J]).size,F=Q>0?Math.round((1-Z/Q)*100):0;return{content:J,originalSize:Q,optimizedSize:Z,reduction:F,appliedOptimizations:K,removedDirectives:Y,foldedConstants:$,pooledStrings:X,warnings:W}}async function p(q,j={}){let G={...A,...j},Q=new Map,J=[],K=0,W=0,Y=new Set;for(let[F,H]of q){let y=v(H,G);Q.set(F,y),K+=y.originalSize,W+=y.optimizedSize,J.push(...y.warnings.map((P)=>`${F}: ${P}`));let U=T(H);for(let P of U)Y.add(P.name)}let $;if(G.treeShake)$=V(Array.from(Y));let X;if(G.stringPooling)X=new Map;let Z=K>0?Math.round((1-W/K)*100):0;return{templates:Q,directiveBundle:$,stringPool:X,totalOriginalSize:K,totalOptimizedSize:W,overallReduction:Z,warnings:J}}function x(q){return q.charAt(0).toUpperCase()+q.slice(1)}var A,w;var g=C(()=>{A={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},w=["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty","extends","section","endsection","yield","parent","include","includeIf","includeWhen","includeFirst","once","endonce","push","endpush","prepend","endprepend","stack","component","endcomponent","slot","endslot","props","auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole","csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file","translate","lang","choice","meta","title","seo","jsonld","canonical","robots","sitemap","ts","endts","js","endjs","css","endcss","markdown","endmarkdown","verbatim","endverbatim","env","production","debug","isset","endisset","empty","endempty"]});g();export{z as poolStrings,v as optimizeTemplate,D as minifyHtml,B as getUnusedDirectives,V as generateTreeShakenBundle,f as foldConstants,O as findDeadCode,O as findDeadBranches,E as evaluateConstant,S as eliminateDeadCode,p as createOptimizedBuild,T as analyzeUsage,T as analyzeDirectiveUsage};
