// @bun
var{defineProperty:X,getOwnPropertyNames:B,getOwnPropertyDescriptor:G}=Object,L=Object.prototype.hasOwnProperty;function U(b){return this[b]}var T=(b)=>{var q=(Y??=new WeakMap).get(b),j;if(q)return q;if(q=X({},"__esModule",{value:!0}),b&&typeof b==="object"||typeof b==="function"){for(var z of B(b))if(!L.call(q,z))X(q,z,{get:U.bind(b,z),enumerable:!(j=G(b,z))||j.enumerable})}return Y.set(b,q),q},Y;var f=(b)=>b;function F(b,q){this[b]=f.bind(null,q)}var _=(b,q)=>{for(var j in q)X(b,j,{get:q[j],enumerable:!0,configurable:!0,set:F.bind(q,j)})};var H=(b,q)=>()=>(b&&(q=b(b=0)),q);var k=import.meta.require;function S(b){let q=[],j=[];return y(b,q),O(b,q,j),P(b,j),A(b,q),{valid:q.length===0,errors:q,warnings:j}}function y(b,q){let j=(b.match(/\{\{/g)||[]).length,z=(b.match(/\}\}/g)||[]).length;if(j!==z)q.push({type:"expression",message:`Unclosed expression brackets: found ${j} opening '{{' and ${z} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function O(b,q,j){for(let z of K){let W=new RegExp(`${z.open}(?:\\s|\\()`,"g"),Z=new RegExp(z.close,"g"),Q=(b.match(W)||[]).length,J=(b.match(Z)||[]).length;if(z.altClose){let $=new RegExp(z.altClose,"g");J+=(b.match($)||[]).length}if(Q>J)q.push({type:"directive",message:`Unclosed @${z.name} directive: found ${Q} opening and ${J} closing`,suggestion:`Add ${Q-J} missing ${z.close} tag(s)`});else if(J>Q)j.push({type:"directive",message:`Extra ${z.close} found: ${J-Q} more closing than opening`,suggestion:`Check for orphaned ${z.close} tags`})}}function P(b,q){for(let j of M)if(j.pattern.test(b))q.push({type:"syntax",message:j.message,suggestion:j.suggestion})}function A(b,q){for(let j of V)if(j.pattern.test(b))q.push({type:"expression",message:`Security warning: ${j.message}`,suggestion:"Remove dangerous code from template expressions"})}function w(b,q){let j=b.slice(0,q).split(`
`);return{line:j.length,column:j[j.length-1].length+1}}function h(b,q,j){let z=[];switch(b){case"if":case"elseif":case"unless":if(j.length===0)z.push({type:"syntax",message:`@${b} requires a condition`,suggestion:`Use @${b}(condition)`});break;case"foreach":if(j.length===0||!j[0].includes(" as "))z.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(j.length===0)z.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(j.length===0)z.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(j.length===0)z.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(j.length===0)z.push({type:"syntax",message:`@${b} requires a path`,suggestion:`Use @${b}('path/to/template')`});break}return z}function R(b){return/@[a-z]+/i.test(b)||/\{\{/.test(b)}function x(b){let q=b.matchAll(/@([a-z]+)/gi),j=new Set;for(let z of q){let W=z[1].toLowerCase();if(!W.startsWith("end"))j.add(W)}return Array.from(j)}var K,M,V;var I=H(()=>{K=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],M=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],V=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}]});I();export{S as validateTemplate,h as validateDirective,R as hasDirectives,w as getPositionInfo,x as extractDirectiveNames};
