🆙 Add cms i using 🆙

This commit is contained in:
Remco committed 2025-11-25 22:42:56 +01:00
1 parent 94704e0925
commit d44196149e
35591 files changed
+3601123

No files matched your search

@@ -0,0 +1,93 @@
"use strict";var Je=Object.create;var J=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var Ke=(h,e)=>{for(var t in e)J(h,t,{get:e[t],enumerable:!0})},oe=(h,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ue(e))!Ve.call(h,r)&&r!==t&&J(h,r,{get:()=>e[r],enumerable:!(n=Xe(e,r))||n.enumerable});return h};var g=(h,e,t)=>(t=h!=null?Je(Me(h)):{},oe(e||!h||!h.__esModule?J(t,"default",{value:h,enumerable:!0}):t,h)),Qe=h=>oe(J({},"__esModule",{value:!0}),h);var at={};Ke(at,{BladeFormatter:()=>N,Formatter:()=>A});module.exports=Qe(at);var ze=g(require("ignore")),B=g(require("path")),j=g(require("fs")),f=g(require("process")),b=g(require("chalk")),He=g(require("glob")),se=g(require("util")),v=g(require("lodash")),ae=g(require("find-config"));var R=g(require("js-beautify")),i=g(require("lodash")),it=g(require("vscode-textmate")),w=g(require("detect-indent")),De=g(require("aigle")),Le=g(require("xregexp")),q=require("@shufo/tailwindcss-class-sorter"),ie=require("html-attribute-sorter");var xe=require("fs"),Ce=g(require("lodash")),re=g(require("vscode-oniguruma")),Be=g(require("path"));var x=g(require("lodash")),ue=g(require("fs")),me=g(require("os")),V=g(require("chalk")),K=g(require("prettier/standalone")),Q=g(require("@prettier/plugin-php/standalone")),Ge=g(require("detect-indent"));var W=g(require("lodash")),k="@",$=["@alert","@pushonce","@push","@slot","@switch","@unless","@verbatim","@prependonce","@prepend","@once","@error","@empty","@guest","@isset","@permission","@permissions","@canany","@cannot","@can","@role","@hasrole","@hasanyrole","@hasallroles","@unlessrole","@hasexactroles","@if","@production","@env","@while","@auth","@forelse","@for","@foreach","@php","@component","@section","@customdirective"],le=W.default.map($,h=>h.substring(1)),E=["@endalert","@endpushonce","@endpush","@endslot","@endswitch","@endunless","@endverbatim","@show","@stop","@endprependonce","@endprepend","@endonce","@enderror","@append","@overwrite","@endempty","@endguest","@endisset","@endpermission","@endpermissions","@endcanany","@endcannot","@endcan","@endrole","@endhasrole","@endhasanyrole","@endhasallroles","@endunlessrole","@endhasexactroles","@endif","@endproduction","@endenv","@endwhile","@endauth","@endforelse","@endforeach","@endfor","@endphp","@endcomponent","@endsection","@endcustomdirective"],D=["@elseenv","@elseif","@elsecanany","@elsecannot","@elsecan","@else","@elsecustomdirective"],Y={"@section":2,"@push":2,"@prepend":2,"@slot":2},ce=["@forelse","@if"],ee=["@empty"],he=["@default"],T=["@forelse","@if","@for","@foreach","@while","@sectionmissing","@case"],X=["@endforelse","@endif","@endforeach","@endfor","@endwhile","@break"],te=["@button","@class","@include","@disabled","@checked","@json"],O=["@set","@json","@selected","@checked","@disabled","@php","@include","@includeif","@includewhen","@includeunless","@includefirst","@button","@class","@props","@aware"],pe=["@if","@while","@case","@isset","@empty","@elseif","@component","@hassection","@unless"],U=["@hassection"],M=["@charset","@color-profile","@counter-style","@font-face","@font-feature-values","@import","@keyframes","@media","@namespace","@page","@property","@supports"];function de(h,e){return W.default.filter(h.tokens,t=>{let n=e.substring(t.startIndex,t.endIndex).trim();return W.default.includes($,n)||W.default.includes(E,n)}).length>=2}var y="\\(((?:[^)(]+|\\((?:[^)(]+|\\((?:[^)(]+|\\((?:[^)(]+|\\([^)(]*\\))*\\))*\\))*\\))*)\\)?";var _=h=>{let e={get(){return null}};return x.default.isUndefined(h)||x.default.isNull(h)?e:h};async function G(h){return new Promise((e,t)=>{ue.default.readFile(h,(n,r)=>n?t(n):e(r))})}function z(h){return h?h.split(/\r\n|\n|\r/):""}var F=1e3,ge={noPhpSyntaxCheck:!1,printWidth:F,trailingCommaPHP:!0,phpVersion:"8.1",singleQuote:!0};function L(h,e={}){let t={...ge,...e};try{return K.default.format(h.replace(/\n$/,""),{parser:"php",printWidth:1e3,singleQuote:t.singleQuote,phpVersion:t.phpVersion,trailingCommaPHP:t.trailingCommaPHP,plugins:[Q.default]})}catch(n){if(t.noPhpSyntaxCheck===!1)throw n;return h}}function C(h,e={}){let t={...ge,...e};try{return K.default.format(`<?php echo ${h} ?>`,{parser:"php",printWidth:t.printWidth,singleQuote:t.singleQuote,phpVersion:t.phpVersion,trailingCommaPHP:t.trailingCommaPHP,plugins:[Q.default]}).replace(/<\?php echo (.*)?\?>/gs,(n,r)=>r.trim().replace(/;\s*$/,""))}catch(n){if(t.noPhpSyntaxCheck===!1)throw n;return h}}function fe(h){let e=`<?php tmp_func${h}; ?>`,{ast:t}=K.default.__debug.parse(e,{parser:"php",phpVersion:"8.0",plugins:[Q.default]});try{return t.children[0].expression.arguments.length||0}catch{return 0}}function ye(h){return Promise.all(x.default.map(h,async e=>{process.stdout.write(`path: ${V.default.bold(e.path)}:${e.line}
`),process.stdout.write(V.default.red(`--${e.original}
`)),process.stdout.write(V.default.green(`++${e.formatted}
`))}))}function _e(h,e,t){let n=x.default.map(e,(r,s)=>x.default.isEmpty(r)||r===t[s]?null:{path:h,line:s+1,original:r,formatted:t[s]});return x.default.without(n,null)}async function Ze(h){let e=x.default.without($,"@switch","@forelse","@php").join("|"),t=new RegExp(`(?!\\/\\*.*?\\*\\/)(${e})(\\s*?)${y}`,"gmi");return new Promise(n=>n(h)).then(n=>x.default.replace(n,t,(r,s,a,l)=>L(`<?php ${s.substr("1")}${a}(${l}) ?>`).replace(/<\?php\s(.*?)(\s*?)\((.*?)\);*\s\?>\n/gs,(o,c,d,p)=>`@${c.trim()}${d}(${p.trim()})`).replace(/([\n\s]*)->([\n\s]*)/gs,"->").replace(/,\)$/,")").replace(/(?:\n\s*)* as(?= (?:&{0,1}\$[\w]+|list|\[\$[\w]+))/g," as"))).then(n=>L(n))}async function we(h){return Ze(h)}function ve(h){let e=x.default.without(T,"@case"),t=x.default.without(X,"@break");return new Promise(n=>n(h)).then(n=>{let r=new RegExp(`(${e.join("|")})([\\s]*?)${y}`,"gis");return x.default.replace(n,r,(s,a,l,o)=>`<beautifyTag start="${a}${l}" exp="^^^${x.default.escape(o)}^^^">`)}).then(n=>{let r=new RegExp(`(?!end=".*)(${t.join("|")})(?!.*")`,"gi");return x.default.replace(n,r,(s,a)=>`</beautifyTag end="${a}">`)})}function Pe(h){return new Promise(e=>e(h)).then(e=>x.default.replace(e,/<beautifyTag.*?start="(.*?)".*?exp=".*?\^\^\^(.*?)\^\^\^.*?"\s*>/gs,(t,n,r)=>`${n}(${x.default.unescape(r)})`)).then(e=>x.default.replace(e,/<\/beautifyTag.*?end="(.*?)"\s*>/gs,(t,n)=>`${n}`))}var qe=["/\\*\\* phptag_start \\*\\*/","/\\*\\* end_phptag \\*\\*/","/\\*escaped\\*/","__BLADE__;","/\\* blade_comment_start \\*/","/\\* blade_comment_end \\*/","/\\*\\*\\*script_placeholder\\*\\*\\*/","beautifyTag","@customdirective","@elsecustomdirective","@endcustomdirective"];function $e(h){if(new RegExp(qe.join("|")).test(h))throw new Error(["Can't format blade: something goes wrong.","Please check if template is too complicated or not. Or simplify template might solves issue."].join(`
`));return h}function ne(h){return h.replace(/\$/g,"$$$$")}function be(h){switch(h){case"LF":return`
`;case"CRLF":return`\r
`;default:return me.default.EOL}}var Z=class{constructor(e,t){return(async()=>{var n;return this.vsctm=(n=e.default)!=null?n:e,this.oniguruma=t||re.default||re,await this.loadWasm(),this})()}async loadWasm(){var t;let e=await xe.promises.readFile(require.resolve("vscode-oniguruma/release/onig.wasm"));if(await((t=this.oniguruma)==null?void 0:t.loadWASM(e.buffer)),!this.initCalled){try{this.oniguruma.loadWASM(e.buffer)}catch{this.initCalled=!0}this.initCalled=!0}}createRegistry(){return this.registry=new this.vsctm.Registry({loadGrammar:e=>e==="text.html.php.blade"?G(Be.default.resolve(__dirname,"../syntaxes/blade.tmLanguage.json")).then(t=>this.vsctm.parseRawGrammar(t.toString(),"./blade.tmLanguage.json")):null,onigLib:Promise.resolve({createOnigScanner:e=>new this.oniguruma.OnigScanner(e),createOnigString:e=>new this.oniguruma.OnigString(e)})}),this.registry}tokenizeLines(e,t){return Ce.default.map(e,n=>{var r;return t.tokenizeLine(n,(r=this.vsctm)==null?void 0:r.INITIAL)})}};function et(h){return h.split(`
`)}function tt(h){return h.trim().startsWith("*")}function nt(h){return h.length>1}function rt(h){return` ${h}`}function Ie(h){let e=et(h);if(!nt(e))return h;let t=!1;return e.map((r,s)=>{if(s===0||t)return r;if(!tt(r))return t=!0,r;let a=r.trim();return rt(a)}).join(`
`)}var Re=g(require("lodash"));function Ee(h){let e=["@unless"];return Re.default.replace(h,new RegExp(`(?<!@)(${e.join("|")})\\s*${y}`,"gi"),(t,n,r)=>`${n} (${r})`)}var A=class{constructor(e){this.options={noPhpSyntaxCheck:!1,...e},this.vsctm=_(this.options).vsctm||it,this.oniguruma=_(this.options).oniguruma,this.indentCharacter=_(this.options).useTabs?" ":" ",this.indentSize=_(this.options).indentSize||4,this.wrapLineLength=_(this.options).wrapLineLength||120,this.wrapAttributes=_(this.options).wrapAttributes||"auto",this.currentIndentLevel=0,this.shouldBeIndent=!1,this.isInsideCommentBlock=!1,this.stack=[],this.ignoredLines=[],this.curlyBracesWithJSs=[],this.rawBlocks=[],this.rawPhpTags=[],this.inlineDirectives=[],this.conditions=[],this.inlinePhpDirectives=[],this.rawPropsBlocks=[],this.bladeDirectives=[],this.bladeDirectivesInStyle=[],this.bladeComments=[],this.phpComments=[],this.bladeBraces=[],this.rawBladeBraces=[],this.nonnativeScripts=[],this.scripts=[],this.htmlAttributes=[],this.xData=[],this.xInit=[],this.htmlTags=[],this.templatingStrings=[],this.stringLiteralInPhp=[],this.shorthandBindings=[],this.componentAttributes=[],this.customDirectives=[],this.directivesInScript=[],this.unbalancedDirectives=[],this.escapedBladeDirectives=[],this.result=[],this.diffs=[],this.defaultPhpFormatOption={noPhpSyntaxCheck:this.options.noPhpSyntaxCheck,printWidth:this.wrapLineLength},this.endOfLine=be(_(this.options).endOfLine)}formatContent(e){return new Promise(t=>t(e)).then(t=>this.preserveIgnoredLines(t)).then(t=>this.preserveNonnativeScripts(t)).then(t=>this.preserveCurlyBraceForJS(t)).then(t=>this.preserveRawPhpTags(t)).then(t=>this.preserveEscapedBladeDirective(t)).then(t=>we(t)).then(t=>this.preserveBladeComment(t)).then(t=>this.preserveBladeBrace(t)).then(t=>this.preserveRawBladeBrace(t)).then(t=>this.preserveConditions(t)).then(t=>this.preserveInlineDirective(t)).then(t=>this.preserveInlinePhpDirective(t)).then(t=>this.preserveBladeDirectivesInScripts(t)).then(t=>this.preserveBladeDirectivesInStyles(t)).then(t=>this.preserveCustomDirective(t)).then(t=>this.preserveUnbalancedDirective(t)).then(t=>this.breakLineBeforeAndAfterDirective(t)).then(async t=>(this.bladeDirectives=await this.formatPreservedBladeDirectives(this.bladeDirectives),t)).then(t=>this.preserveScripts(t)).then(t=>this.sortTailwindcssClasses(t)).then(t=>this.formatXInit(t)).then(t=>this.formatXData(t)).then(t=>this.preserveComponentAttribute(t)).then(t=>this.preserveShorthandBinding(t)).then(t=>this.sortHtmlAttributes(t)).then(t=>this.preservePhpBlock(t)).then(t=>this.preserveHtmlAttributes(t)).then(t=>this.preserveHtmlTags(t)).then(t=>this.formatAsHtml(t)).then(t=>this.formatAsBlade(t)).then(t=>this.restoreHtmlTags(t)).then(t=>this.restoreHtmlAttributes(t)).then(t=>this.restorePhpBlock(t)).then(t=>this.restoreShorthandBinding(t)).then(t=>this.restoreComponentAttribute(t)).then(t=>this.restoreXData(t)).then(t=>this.restoreXInit(t)).then(t=>this.restoreScripts(t)).then(t=>this.restoreUnbalancedDirective(t)).then(t=>this.restoreCustomDirective(t)).then(t=>this.restoreBladeDirectivesInStyles(t)).then(t=>this.restoreBladeDirectivesInScripts(t)).then(t=>this.restoreInlinePhpDirective(t)).then(t=>this.restoreInlineDirective(t)).then(t=>this.restoreConditions(t)).then(t=>this.restoreRawBladeBrace(t)).then(t=>this.restoreBladeBrace(t)).then(t=>this.restoreBladeComment(t)).then(t=>this.restoreEscapedBladeDirective(t)).then(t=>this.restoreRawPhpTags(t)).then(t=>this.restoreCurlyBraceForJS(t)).then(t=>this.restoreNonnativeScripts(t)).then(t=>this.restoreIgnoredLines(t)).then(t=>Ee(t)).then(t=>$e(t))}formatAsHtml(e){let t={indent_size:_(this.options).indentSize||4,wrap_line_length:_(this.options).wrapLineLength||120,wrap_attributes:_(this.options).wrapAttributes||"auto",end_with_newline:_(this.options).endWithNewline||!0,max_preserve_newlines:_(this.options).noMultipleEmptyLines?1:void 0,css:{end_with_newline:!1},eol:this.endOfLine},n=new Promise(r=>r(e)).then(r=>ve(r)).then(r=>R.default.html_beautify(r,t)).then(r=>Pe(r));return Promise.resolve(n)}async sortTailwindcssClasses(e){return this.options.sortTailwindcssClasses?i.default.replace(e,/(?<=\s+(?!:)class\s*=\s*([\"\']))(.*?)(?=\1)/gis,(t,n,r)=>{if(i.default.isEmpty(r))return r;if(this.options.tailwindcssConfigPath){let s={tailwindConfigPath:this.options.tailwindcssConfigPath};return(0,q.sortClasses)(r,s)}if(this.options.tailwindcssConfig){let s={tailwindConfig:this.options.tailwindcssConfig};return(0,q.sortClasses)(r,s)}return(0,q.sortClasses)(r)}):e}async preserveIgnoredLines(e){return i.default.chain(e).replace(/(^(?<!.+)^{{--\s*blade-formatter-disable\s*--}}.*?)([\r\n]*)$(?![\r\n])/gis,(t,n,r)=>this.storeIgnoredLines(`${n}${r.replace(/^\n/,"")}`)).replace(/(?:({{--\s*?blade-formatter-disable\s*?--}}|<!--\s*?prettier-ignore-start\s*?-->|{{--\s*?prettier-ignore-start\s*?--}})).*?(?:({{--\s*?blade-formatter-enable\s*?--}}|<!--\s*?prettier-ignore-end\s*?-->|{{--\s*?prettier-ignore-end\s*?--}})) Line truncated
${s.trim()}
`),e=i.default.replace(e,new RegExp(`(?<=<.*?(?<!=)>).*?(${i.default.without(E,"@endphp").join("|")})(?=<.*?>)`,"gmis"),s=>`
${s.trim()}
`);let t=["@case",...D];e=i.default.replace(e,new RegExp(`(\\s*?)(${t.join("|")})(\\s*?)${y}(\\s*)`,"gmi"),s=>`
${s.trim()}
`),e=i.default.replace(e,new RegExp(`\\s*?(?!(${i.default.without(D,"@else").join("|")}))@else\\s+`,"gim"),s=>`
${s.trim()}
`),e=i.default.replace(e,/@case\S*?\s*?@case/gim,s=>`${s.replace(`
`,"")}`);let n=["@break"];i.default.forEach(n,s=>{e=i.default.replace(e,new RegExp(`(\\s*?)${s}\\s+`,"gmi"),a=>`
${a.trim()}
`)}),i.default.forEach(["@default"],s=>{e=i.default.replace(e,new RegExp(`(\\s*?)${s}\\s*`,"gmi"),a=>`
${a.trim()}
`)});let r=i.default.chain($).map(s=>i.default.replace(s,/@/,"")).value();return i.default.forEach(r,s=>{try{let a=Le.default.matchRecursive(e,`\\@${s}`,`\\@end${s}`,"gmi",{valueNames:[null,"left","match","right"]});if(i.default.isEmpty(a))return;for(let l of a)if(l.name==="match"){new RegExp($.join("|")).test(l.value)&&(e=i.default.replace(e,l.value,this.breakLineBeforeAndAfterDirective(ne(l.value))));let o=new RegExp(`^(\\s*?)${y}(.*)`,"gmis"),c=i.default.replace(`${l.value}`,o,(d,p,u,m)=>m.trim()===""?`${p}(${u.trim()})
${m.trim()}`:`${p}(${u.trim()})
${m.trim()}
`);e=i.default.replace(e,l.value,ne(c))}}catch{}}),e}async preserveEscapedBladeDirective(e){return i.default.replace(e,/@@\w*/gim,t=>this.storeEscapedBladeDirective(t))}async preserveBladeComment(e){return i.default.replace(e,/\{\{--(.*?)--\}\}/gs,t=>this.storeBladeComment(t))}preservePhpComment(e){return i.default.replace(e,/\/\*(?:[^*]|[\r\n]|(?:\*+(?:[^*\/]|[\r\n])))*\*+\//gi,t=>this.storePhpComment(t))}async preserveBladeBrace(e){return i.default.replace(e,/\{\{(.*?)\}\}/gs,(t,n)=>n===""?this.storeBladeBrace(n,n.length):/\S/.test(n)?this.storeBladeBrace(n.trim(),n.trim().length):this.storeBladeBrace(" ",1))}async preserveRawBladeBrace(e){return i.default.replace(e,/\{!!(.*?)!!\}/gs,(t,n)=>n===""?this.storeRawBladeBrace(n):/\S/.test(n)?this.storeRawBladeBrace(n.trim()):this.storeRawBladeBrace(" "))}async preserveConditions(e){let t=new RegExp(`(${pe.join("|")})(\\s*?)${y}`,"gi");return i.default.replace(e,t,(n,r,s,a)=>`${r}${s}(${this.storeConditions(a)})`)}preserveUnbalancedDirective(e){let t=new RegExp(`((${U.join("|")})(?!.*?\\2)(?:\\s|\\(.*?\\)))+(?=.*?@endif)`,"gis"),n=i.default.replace(e,t,(r,s)=>`${this.storeUnbalancedDirective(s)}`);return t.test(n)&&(n=this.preserveUnbalancedDirective(n)),n}async preserveRawPhpTags(e){return i.default.replace(e,/<\?php(.*?)\?>/gms,t=>this.storeRawPhpTags(t))}async preserveNonnativeScripts(e){return i.default.replace(e,/<script[^>]*?type=(["'])(?!text\/javascript)[^\1]*?\1[^>]*?>.*?<\/script>/gis,t=>this.storeNonnativeScripts(t))}async preserveScripts(e){return i.default.replace(e,/<script.*?>.*?<\/script>/gis,t=>this.storeScripts(t))}async preserveHtmlAttributes(e){return i.default.replace(e,/(?<=<[\w]*?[\s].*?)[\w\-\_\:]+?=(["']).*?(?<!\\)\1(?=.*?(?<!=)>)/gms,t=>`${this.storeHtmlAttribute(t)}`)}async sortHtmlAttributes(e){var n;let t=(n=this.options.sortHtmlAttributes)!=null?n:"none";if(!i.default.isEmpty(t)&&t!=="none"){let r=this.options.customHtmlAttributesOrder;if(i.default.isArray(r))return(0,ie.sortAttributes)(e,{order:t,customRegexes:r});let s=i.default.chain(r).split(",").map(i.default.trim).value();return(0,ie.sortAttributes)(e,{order:t,customRegexes:s})}return e}async preserveShorthandBinding(e){return i.default.replace(e,/(?<=<(?!livewire:)[^<]*?(\s|x-bind)):{1}(?<!=>)[\w\-_.]*?=(["'])(?!=>)[^]*?\2(?=[^>]*?\/*?>)/gim,t=>`${this.storeShorthandBinding(t)}`)}async preserveComponentAttribute(e){return i.default.replace(e,/(?<=<(x-|livewire:)[^<]*?\s):{1,2}(?<!=>)[\w\-_.]*?=(["'])(?!=>)[^]*?\2(?=[^>]*?\/*?>)/gim,t=>`${this.storeComponentAttribute(t)}`)}async formatXData(e){return i.default.replace(e,/(\s*)x-data="(.*?)"(\s*)/gs,(t,n,r,s)=>`${n}x-data="${this.storeXData(r)}"${s}`)}async formatXInit(e){return i.default.replace(e,/(\s*)x-init="(.*?)"(\s*)/gs,(t,n,r,s)=>`${n}x-init="${this.storeXInit(r)}"${s}`)}preserveStringLiteralInPhp(e){return i.default.replace(e,/(\"([^\\]|\\.)*?\"|\'([^\\]|\\.)*?\')/gm,t=>`${this.storeStringLiteralInPhp(t)}`)}storeIgnoredLines(e){return this.getIgnoredLinePlaceholder(this.ignoredLines.push(e)-1)}storeCurlyBraceForJS(e){return this.getCurlyBraceForJSPlaceholder(this.curlyBracesWithJSs.push(e)-1)}storeRawBlock(e){return this.getRawPlaceholder(this.rawBlocks.push(e)-1)}storeInlineDirective(e){return this.getInlinePlaceholder(this.inlineDirectives.push(e)-1,e.length)}storeConditions(e){return this.getConditionPlaceholder(this.conditions.push(e)-1)}storeInlinePhpDirective(e){return this.getInlinePhpPlaceholder(this.inlinePhpDirectives.push(e)-1)}storeRawPropsBlock(e){return this.getRawPropsPlaceholder(this.rawPropsBlocks.push(e)-1)}storeBladeDirective(e){return this.getBladeDirectivePlaceholder(this.bladeDirectives.push(e)-1)}storeBladeDirectiveInStyle(e){return this.getBladeDirectiveInStylePlaceholder((this.bladeDirectivesInStyle.push(e)-1).toString())}storeEscapedBladeDirective(e){return this.getEscapedBladeDirectivePlaceholder((this.escapedBladeDirectives.push(e)-1).toString())}storeBladeComment(e){return this.getBladeCommentPlaceholder(this.bladeComments.push(e)-1)}storePhpComment(e){return this.getPhpCommentPlaceholder((this.phpComments.push(e)-1).toString())}storeHtmlTag(e){return this.getHtmlTagPlaceholder((this.htmlTags.push(e)-1).toString())}storeInlineCustomDirective(e){return this.getInlineCustomDirectivePlaceholder((this.customDirectives.push(e)-1).toString())}storeBeginCustomDirective(e){return this.getBeginCustomDirectivePlaceholder((this.customDirectives.push(e)-1).toString())}storeElseCustomDirective(e){return this.getElseCustomDirectivePlaceholder((this.customDirectives.push(e)-1).toString())}storeEndCustomDirective(e){return this.getEndCustomDirectivePlaceholder((this.customDirectives.push(e)-1).toString())}storeUnbalancedDirective(e){return this.getUnbalancedDirectivePlaceholder((this.unbalancedDirectives.push(e)-1).toString())}storeBladeBrace(e,t){let n=this.bladeBraces.push(e)-1,r="{{ }}";return this.getBladeBracePlaceholder(n,t+r.length)}storeRawBladeBrace(e){let t=this.rawBladeBraces.push(e)-1;return Line truncated
${r}
?>`,this.defaultPhpFormatOption).trim():r.split(`
`).length>1?r=L(`<?php${r}?>`,this.defaultPhpFormatOption).trimRight(`
`):r=`<?php${r}?>`,i.default.replace(r,/^(\s*)?<\?php(.*?)\?>/gms,(c,d,p)=>{if(this.isInline(r))return`@php${p}@endphp`;let u=this.preserveStringLiteralInPhp(p);u=this.preservePhpComment(u);let m=this.indentRawBlock(l,u);return m=this.restorePhpComment(m),`@php${this.restoreStringLiteralInPhp(m)}@endphp`})})}async restoreRawPropsBlock(e){let t=this.getRawPropsPlaceholder("(\\d+)");return i.default.replace(e,new RegExp(t,"gms"),(n,r)=>`@props(${C(this.rawPropsBlocks[r],{...this.defaultPhpFormatOption,printWidth:F}).trimRight()})`)}isInline(e){return i.default.split(e,`
`).length===1}isMultilineStatement(e){return L(`<?php${e}?>`,this.defaultPhpFormatOption).trimRight().split(`
`).length>1}indentRawBlock(e,t){if(this.isInline(t))return`${e.indent}${t}`;let r=e.amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:(r+1)*this.indentSize),a=this.indentCharacter.repeat(r<0?0:r*this.indentSize),l=t.split(`
`);return i.default.chain(l).map((o,c)=>c===0?o.trim():c===l.length-1?a+o:s+o).join(`
`).value()}indentBladeDirectiveBlock(e,t){if(i.default.isEmpty(e.indent))return t;if(this.isInline(t))return`${e.indent}${t}`;let r=e.amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:r*this.indentSize),a=this.indentCharacter.repeat(r<0?0:r*this.indentSize),l=t.split(`
`);return i.default.chain(l).map((o,c)=>c===l.length-1?a+o:s+o).value().join(`
`)}indentScriptBlock(e,t){if(i.default.isEmpty(e.indent))return t;if(this.isInline(t))return`${t}`;let r=e.amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:r*this.indentSize),a=this.indentCharacter.repeat(r<0?0:r*this.indentSize),o=i.default.replace(t,/`.*?`/gs,d=>this.storeTemplatingString(d)).split(`
`),c=i.default.chain(o).map((d,p)=>p===0?d:p===o.length-1?a+d:i.default.isEmpty(d)?d:s+d).value().join(`
`);return this.restoreTemplatingString(`${c}`)}indentRawPhpBlock(e,t){if(i.default.isEmpty(e.indent))return t;if(this.isInline(t))return`${t}`;let r=e.amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:r*this.indentSize),a=t.split(`
`);return i.default.chain(a).map((l,o)=>o===0?l.trim():s+l).value().join(`
`)}indentComponentAttribute(e,t){if(i.default.isEmpty(e))return t;if(this.isInline(t))return`${t}`;if(this.isInline(t)&&/\S/.test(e))return`${t}`;let r=(0,w.default)(e).amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:r*this.indentSize),a=t.split(`
`);return i.default.chain(a).map((l,o)=>o===0?l.trim():s+l).value().join(`
`)}indentPhpComment(e,t){if(i.default.isEmpty(e.indent))return t;if(this.isInline(t))return`${t}`;let r=e.amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:r*this.indentSize),a=t.split(`
`),l=!1;return i.default.chain(a).map((o,c)=>c===0?o.trim():o.trim().startsWith("*")?o.trim().endsWith("*/")&&l?o:s+o:(l=!0,o)).join(`
`).value()}restoreBladeDirectivesInStyles(e){return i.default.replace(e,/(?<=<style[^>]*?(?<!=)>)(.*?)(?=<\/style>)/gis,t=>{let n=t,r=new RegExp(`${this.getBladeDirectiveInStylePlaceholder("(\\d+)")} {\\s*?/\\* inline_directive \\*/\\s*?}`,"gmi");n=i.default.replace(n,r,(o,c)=>this.bladeDirectivesInStyle[c]);let s=new RegExp(`}\\s*?${this.getBladeDirectiveInStylePlaceholder("(\\d+)")} {\\s*?/\\*else\\*/`,"gmi");n=i.default.replace(n,s,(o,c)=>`${this.bladeDirectivesInStyle[c]}`);let a=new RegExp(`${this.getBladeDirectiveInStylePlaceholder("(\\d+)")} {\\s*?/\\*start\\*/`,"gmi");n=i.default.replace(n,a,(o,c)=>`${this.bladeDirectivesInStyle[c]}`);let l=new RegExp(`}\\s*?/\\* ${this.getBladeDirectiveInStylePlaceholder("(\\d+)")} \\*/`,"gmi");return n=i.default.replace(n,l,(o,c)=>`${this.bladeDirectivesInStyle[c]}`),n})}restoreBladeDirectivesInScripts(e){let t=new RegExp(`${this.getBladeDirectivePlaceholder("(\\d+)")}`,"gm"),n=i.default.replace(e,t,(r,s)=>{var c;let a=this.getBladeDirectivePlaceholder(s.toString()),l=(c=e.match(new RegExp(`^(.*?)${a}`,"gmi")))!=null?c:[""],o=(0,w.default)(l[0]);return this.indentBladeDirectiveBlock(o,this.bladeDirectives[s])});return n=i.default.replace(n,/(?<=<script[^>]*?(?<!=)>)(.*?)(?=<\/script>)/gis,r=>{let s=r;return s=i.default.replace(s,new RegExp(`if \\( \\/\\*(?:(?:${this.getBladeDirectiveInScriptPlaceholder("(\\d+)")}).*?)\\*\\/ \\) \\{`,"gis"),(a,l)=>`${this.directivesInScript[l]}`),s=i.default.replace(s,new RegExp(`} \\/\\* (?:${this.getBladeDirectiveInScriptPlaceholder("(\\d+)")}) \\*\\/ {(\\s*?\\(___directive_condition_\\d+___\\))?`,"gim"),(a,l,o)=>i.default.isUndefined(o)?`${this.directivesInScript[l].trim()}`:`${this.directivesInScript[l].trim()} ${(o!=null?o:"").trim()}`),s=i.default.replace(s,new RegExp(`} \\/\\*(?:${this.getBladeDirectiveInScriptPlaceholder("(\\d+)")})\\*\\/`,"gis"),(a,l)=>`${this.directivesInScript[l]}`),s=i.default.replace(s,new RegExp(`${this.getRawPlaceholder("(\\d+)")}`,"gm"),(a,l)=>{var u;let o=this.rawBlocks[l],c=this.getRawPlaceholder(l.toString()),d=(u=e.match(new RegExp(`^(.*?)${c}`,"gmi")))!=null?u:[""],p=(0,w.default)(d[0]);return this.isInline(o)&&this.isMultilineStatement(o)?o=L(`<?php
${o}
?>`,this.defaultPhpFormatOption).trim():o.split(`
`).length>1?o=L(`<?php${o}?>`,this.defaultPhpFormatOption).trim():o=`<?php${o}?>`,i.default.replace(o,/^(\s*)?<\?php(.*?)\?>/gms,(m,S,P)=>{if(this.isInline(o))return`@php${P}@endphp`;let I=this.preserveStringLiteralInPhp(P),Ne=this.indentRawBlock(p,I);return`@php${this.restoreStringLiteralInPhp(Ne)}@endphp`})}),s=i.default.replace(s,/(?<=[\S]+)(\s*?)\/\*\*\*script_placeholder\*\*\*\/(\s)?/gim,(a,l,o)=>{if(o!==void 0)return o;let c=l!=null?l:"",d=o!=null?o:"";return c+d}),s}),t.test(n)&&(n=this.restoreBladeDirectivesInScripts(n)),n}async formatPreservedBladeDirectives(e){return De.default.map(e,async t=>{let n=await this.formatAsHtml(t);return(await this.formatAsBlade(n)).trimRight(`
`)})}restoreBladeComment(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getBladeCommentPlaceholder("(\\d+)")}`,"gms"),(n,r)=>this.bladeComments[r].replace(/{{--(?=\S)/g,"{{-- ").replace(/(?<=\S)--}}/g," --}}")))}restorePhpComment(e){return i.default.replace(e,new RegExp(`${this.getPhpCommentPlaceholder("(\\d+)")};{0,1}`,"gms"),(t,n)=>{var o;let r=this.getPhpCommentPlaceholder(n.toString()),s=(o=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?o:[""],a=(0,w.default)(s[0]),l=Ie(this.phpComments[n]);return this.indentPhpComment(a,l)})}async restoreEscapedBladeDirective(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getEscapedBladeDirectivePlaceholder("(\\d+)")}`,"gms"),(n,r)=>this.escapedBladeDirectives[r]))}restoreBladeBrace(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getBladeBracePlaceholder("(\\d+)")}`,"gm"),(n,r)=>{var c;let s=this.getBladeBracePlaceholder(r.toString()),a=(c=e.match(new RegExp(`^(.*?)${s}`,"gmi")))!=null?c:[""],l=(0,w.default)(a[0]),o=this.bladeBraces[r];return o.trim()===""?`{{${o}}}`:this.isInline(o)?`{{ ${C(o,{...this.defaultPhpFormatOption,trailingCommaPHP:!1,printWidth:F}).replace(/([\n\s]*)->([\n\s]*)/gs,"->").split(`
`).map(d=>d.trim()).join("").trimRight(`
`)} }}`:`{{ ${this.indentRawPhpBlock(l,C(o,this.defaultPhpFormatOption).replace(/([\n\s]*)->([\n\s]*)/gs,"->").trim().trimRight(`
`))} }}`}))}restoreRawBladeBrace(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getRawBladeBracePlaceholder("(\\d+)")}`,"gms"),(n,r)=>{var c;let s=this.getRawBladeBracePlaceholder(r),a=(c=e.match(new RegExp(`^(.*?)${s}`,"gmi")))!=null?c:[""],l=(0,w.default)(a[0]),o=this.rawBladeBraces[r];return o.trim()===""?`{!!${o}!!}`:this.indentRawPhpBlock(l,`{!! ${C(o,this.defaultPhpFormatOption).replace(/([\n\s]*)->([\n\s]*)/gs,"->").trim()} !!}`)}))}restoreInlineDirective(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getInlinePlaceholder("(\\d+)")}`,"gms"),(n,r)=>this.inlineDirectives[r]))}restoreConditions(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getConditionPlaceholder("(\\d+)")}`,"gms"),(n,r)=>{var c;let s=this.getConditionPlaceholder(r),a=(c=e.match(new RegExp(`^(.*?)${s}`,"gmi")))!=null?c:[""],l=(0,w.default)(a[0]),o=this.conditions[r];return this.formatExpressionInsideBladeDirective(o,l)}))}restoreUnbalancedDirective(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,/@if \(unbalanced___(\d+)___\)/gms,(n,r)=>this.unbalancedDirectives[r]))}restoreInlinePhpDirective(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getInlinePhpPlaceholder("(\\d+)")}`,"gm"),(n,r)=>{var c;let s=this.inlinePhpDirectives[r],a=this.getInlinePhpPlaceholder(r),l=(c=e.match(new RegExp(`^(.*?)${a}`,"gmi")))!=null?c:[""],o=(0,w.default)(l[0]);return s.includes("@php")?`${C(s,{...this.defaultPhpFormatOption,printWidth:F}).replace(/([\n\s]*)->([\n\s]*)/gs,"->").trim().trimRight(`
`)}`:new RegExp(te.join("|"),"gi").test(s)?i.default.replace(s,new RegExp(`(?<=@(${i.default.map(te,p=>p.substring(1)).join("|")}).*?\\()(.*)(?=\\))`,"gis"),(p,u,m)=>{let S=this.wrapLineLength;return["button","class"].includes(u)&&(S=80),u==="include"&&(S=this.wrapLineLength-4-r.length-o.amount),this.formatExpressionInsideBladeDirective(m,o,S)}):`${C(s,{...this.defaultPhpFormatOption,printWidth:F}).trimEnd()}`}))}restoreRawPhpTags(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getRawPhpTagPlaceholder("(\\d+)")}`,"gms"),(n,r)=>{var s;try{let a=this.rawPhpTags[r],o=/(?<=<\?php\s*?)\/\*.*?\*\/(?=\s*?\?>)/gim.test(a)&&this.isInline(a),c=this.getRawPhpTagPlaceholder(r),d=(s=e.match(new RegExp(`^(.*?)${c}`,"gmi")))!=null?s:[""],p=(0,w.default)(d[0]);if(o)return a;let u=L(this.rawPhpTags[r],this.defaultPhpFormatOption).trim().trimRight(`
`);if(this.isInline(u))return u;let m=this.preservePhpComment(u);return p.indent&&(m=this.indentRawPhpBlock(p,m)),this.restorePhpComment(m)}catch{return`${this.rawPhpTags[r]}`}}))}restoreNonnativeScripts(e){return i.default.replace(e,new RegExp(`${this.getNonnativeScriptPlaceholder("(\\d+)")}`,"gmi"),(t,n)=>`${this.nonnativeScripts[n]}`)}restoreScripts(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getScriptPlaceholder("(\\d+)")}`,"gim"),(n,r)=>{var p;let s=this.scripts[r],a=this.getScriptPlaceholder(r),l=(p=e.match(new RegExp(`^(.*?)${a}`,"gmi")))!=null?p:[""],o=(0,w.default)(l[0]),c=_(this.options).useTabs||!1,d={indent_size:_(this.options).indentSize||4,wrap_line_length:_(this.options).wrapLineLength||120,wrap_attributes:_(this.options).wrapAttributes||"auto",indent_with_tabs:c,end_with_newline:!1,templating:["php"]};return c?this.indentScriptBlock(o,i.default.replace(R.default.html_beautify(s,d),/\t/g," ".repeat(this.indentSize))):this.indentScriptBlock(o,R.default.html_beautify(s,d))}))}async restoreCustomDirective(e){return this.restoreInlineCustomDirective(e).then(t=>this.restoreBeginCustomDirective(t)).then(t=>this.restoreElseCustomDirective(t)).then(t=>this.restoreEndCustomDirective(t))}async restoreInlineCustomDirective(e){return i.default.replace(e,new RegExp(`${this.getInlineCustomDirectivePlaceholder("(\\d+)")}`,"gim"),(t,n)=>{var o;let r=this.getInlineCustomDirectivePlaceholder(n.toString()),s=(o=e.match(new RegExp(`^(.*?)${i.default.escapeRegExp(r)}`,"gmi")))!=null?o:[""],a=(0,w.default)(s[0]),l=`${this.customDirectives[n]}`;return i.default.replace(l,/(@[a-zA-z0-9\-_]+)(.*)/gis,(c,d,p)=>{try{let u=C(`func${p}`,{...this.defaultPhpFormatOption,printWidth:F}).replace(/([\n\s]*)->([\n\s]*)/gs,"->").replace(/,(\s*?\))$/gm,(m,S)=>S).trim().substring(4);return`${d}${this.indentComponentAttribute(a.indent,u)}`}catch{return`${c}`}})})}async restoreBeginCustomDirective(e){return i.default.replace(e,new RegExp(`@customdirective\\(___(\\d+)___\\)\\s*?(${y})*`,"gim"),(t,n)=>{var o;let r=this.getBeginCustomDirectivePlaceholder(n.toString()),s=(o=e.match(new RegExp(`^(.*?)${i.default.escapeRegExp(r)}`,"gmi")))!=null?o:[""],a=(0,w.default)(s[0]),l=`${this.customDirectives[n]}`;return i.default.replace(l,/(@[a-zA-z0-9\-_]+)(.*)/gis,(c,d,p)=>{try{let u=C(`func${p}`,{...this.defaultPhpFormatOption,trailingCommaPHP:!1}).replace(/([\n\s]*)->([\n\s]*)/gs,"->").trim().substring(4);return`${d}${this.indentComponentAttribute(a.indent,u)}`}catch{return`${c}`}})})}async restoreElseCustomDirective(e){return i.default.replace(e,/@else\(___(\d+)___\)/gim,(t,n)=>`${this.customDirectives[n]}`)}async restoreEndCustomDirective(e){return i.default.replace(e,/@endcustomdirective\(___(\d+)___\)/gim,(t,n)=>`${this.customDirectives[n]}`)}async restoreHtmlTags(e){return i.default.replace(e,new RegExp(`${this.getHtmlTagPlaceholder("(\\d+)")}`,"gim"),(t,n)=>{var p;let r=this.getHtmlTagPlaceholder(n.toString()),s=(p=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?p:[""],a=(0,w.default)(s[0]),l={indent_size:_(this.options).indentSize||4,wrap_line_length:_(this.options).wrapLineLength||120,wrap_attributes:_(this.options).wrapAttributes||"auto",end_with_newline:!1,templating:["php"]},o=this.htmlTags[n],c=i.default.first(o.match(/(<(textarea|pre).*?(?<!=)>)(?=.*?<\/\2>)/gis));if(c===void 0)return`${this.indentScriptBlock(a,R.default.html_beautify(o,l))}`;let d=o.substring(c.length,o.length);return`${this.indentScriptBlock(a,R.default.html_beautify(c,l))}${d}`})}restoreHtmlAttributes(e){return i.default.replace(e,new RegExp(`${this.getHtmlAttributePlaceholder("(\\d+)")}`,"gms"),(t,n)=>this.htmlAttributes[n])}restoreXData(e){return i.default.replace(e,new RegExp(`${this.getXDataPlaceholder("(\\d+)")}`,"gm"),(t,n)=>{var u;let r=this.getXDataPlaceholder(n.toString()),s=(u=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?u:[""],a=(0,w.default)(s[0]),l=this.formatJS(this.xData[n]).split(`
`),o=a.amount/(this.indentCharacter===" "?4:1),c=l[0],d=this.indentCharacter.repeat(o<0?0:o),p=l.map(m=>d+m);return p[0]=c,`${p.join(`
`)}`})}restoreXInit(e){return i.default.replace(e,new RegExp(`${this.getXInitPlaceholder("(\\d+)")}`,"gm"),(t,n)=>{var u;let r=this.getXInitPlaceholder(n.toString()),s=(u=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?u:[""],a=(0,w.default)(s[0]),l=this.formatJS(this.xInit[n]).split(`
`),o=a.amount/(this.indentCharacter===" "?4:1),c=l[0],d=this.indentCharacter.repeat(o<0?0:o),p=l.map(m=>d+m);return p[0]=c,`${p.join(`
`)}`})}restoreTemplatingString(e){return i.default.replace(e,new RegExp(`${this.getTemplatingStringPlaceholder("(\\d+)")}`,"gms"),(t,n)=>this.templatingStrings[n])}restoreStringLiteralInPhp(e){return i.default.replace(e,new RegExp(`${this.getStringLiteralInPhpPlaceholder("(\\d+)")}`,"gms"),(t,n)=>this.stringLiteralInPhp[n])}restoreComponentAttribute(e){return i.default.replace(e,new RegExp(`${this.getComponentAttributePlaceholder("(\\d+)")}`,"gim"),(t,n)=>{var c;let r=this.getComponentAttributePlaceholder(n),s=(c=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?c:[""],a=(0,w.default)(s[0]),l=this.componentAttributes[n],o=i.default.replace(l,/(:{1,2}.*?=)(["'])(.*?)(?=\2)/gis,(d,p,u,m)=>{if(m==="")return d;if(p.startsWith("::"))return`${p}${u}${R.default.js_beautify(m,{wrap_line_length:this.wrapLineLength-a.amount,brace_style:"preserve-inline"}).trim()}`;if(this.isInline(m))try{return`${p}${u}${C(m,{...this.defaultPhpFormatOption,printWidth:this.wrapLineLength-a.amount}).trimEnd()}`}catch{return`${p}${u}${m}`}return`${p}${u}${C(m,{...this.defaultPhpFormatOption,printWidth:this.wrapLineLength-a.amount}).trimEnd()}`});return`${this.indentComponentAttribute(a.indent,o)}`})}restoreShorthandBinding(e){return i.default.replace(e,new RegExp(`${this.getShorthandBindingPlaceholder("(\\d+)")}`,"gms"),(t,n)=>{var c;let r=this.getShorthandBindingPlaceholder(n),s=(c=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?c:[""],a=(0,w.default)(s[0]),l=this.shorthandBindings[n],o=i.default.replace(l,/(:{1,2}.*?=)(["'])(.*?)(?=\2)/gis,(d,p,u,m)=>{let S={wrap_line_length:this.wrapLineLength-a.amount,brace_style:"preserve-inline"};if(m==="")return d;if(this.isInline(m))try{return`${p}${u}${R.default.js_beautify(m,S).trimEnd()}`}catch{return`${p}${u}${m}`}return`${p}${u}${R.default.js_beautify(m,S).trimEnd()}`});return`${this.indentComponentAttribute(a.indent,o)}`})}async formatAsBlade(e){this.currentIndentLevel=0,this.shouldBeIndent=!1;let t=z(e),n=await new Z(this.vsctm,this.oniguruma);return n.createRegistry(e).loadGrammar("text.html.php.blade").then(a=>n.tokenizeLines(t,a)).then(a=>this.formatTokenizedLines(t,a)).catch(a=>{throw a})}formatTokenizedLines(e,t){this.result=[],this.stack=[];for(let n=0;n<e.length;n+=1){let r=e[n],s=t[n];this.processLine(s,r)}return this.result.join(this.endOfLine)}processLine(e,t){this.processTokenizeResult(e,t)}processKeyword(e){if(i.default.includes(T,e)){i.default.last(this.stack)==="@case"&&e==="@case"&&this.decrementIndentLevel(),e==="@case"&&(this.shouldBeIndent=!0),this.stack.push(e);return}if(i.default.includes(X,e)){if(e==="@break"){this.decrementIndentLevel(),this.stack.pop(),this.stack.push(e);return}if(i.default.last(this.stack)!=="@hassection"){this.stack.pop();return}}if(i.default.includes(he,e)&&(this.shouldBeIndent=!0,this.stack.push(e)),i.default.includes(ee,e)&&i.default.includes(ce,i.default.last(this.stack))&&(this.decrementIndentLevel(),this.shouldBeIndent=!0),i.default.includes($,e)&&(i.default.last(this.stack)==="@section"&&e==="@section"?(this.currentIndentLevel>0&&this.decrementIndentLevel(),this.shouldBeIndent=!0,this.stack.push(e)):(this.shouldBeIndent=!0,this.stack.push(e))),i.default.includes(E,e)){if(e==="@endswitch"&&i.default.last(this.stack)==="@default"){this.decrementIndentLevel(2),this.shouldBeIndent=!1;return}this.decrementIndentLevel(),this.shouldBeIndent=!1,this.stack.pop()}i.default.includes(D,e)&&(this.decrementIndentLevel(),this.shouldBeIndent=!0)}processToken(e,t){if(i.default.includes(e.scopes,"punctuation.definition.comment.begin.blade")&&(this.isInsideCommentBlock=!0),this.argumentCheck){let{count:n,inString:r,stack:s}=this.argumentCheck;if(!r&&t===")"){if(s.push(t),n[t]+=1,n["("]===n[t]){let a=s.join("");fe(a)>=this.argumentCheck.unindentOn&&(this.shouldBeIndent=!1),this.argumentCheck=!1}return}s.push(t),r===t?this.argumentCheck.inString=!1:!r&&(t==='"'||t==="'")&&(this.argumentCheck.inString=t),t==="("&&!r&&(n[t]+=1)}i.default.includes(e.scopes,"punctuation.definition.comment.end.blade")&&(this.isInsideCommentBlock=!1),(t==="{{--"||t.includes("{{--"))&&(this.isInsideCommentBlock=!0),(t==="--}}"||t.includes("--}}"))&&(this.isInsideCommentBlock=!1),i.default.includes(e.scopes,"keyword.blade")&&(this.isInsideCommentBlock||(this.processKeyword(t.toLowerCase()),i.default.includes(Object.keys(Y),t.toLowerCase())&&(this.argumentCheck={unindentOn:Y[t.toLowerCase()],stack:[],inString:!1,count:{"(":0,")":0}})))}processTokenizeResult(e,t){if(this.shouldBeIndent&&(this.incrementIndentLevel(),this.shouldBeIndent=!1),de(e,t)){this.insertFormattedLineToResult(t);return}for(let n=0;n<e.tokens.length;n+=1){let r=e.tokens[n],s=t.substring(r.startIndex,r.endIndex).trim();this.processToken(r,s)}this.insertFormattedLineToResult(t)}insertFormattedLineToResult(e){let n=(0,w.default)(e).amount+this.indentSize*this.currentIndentLevel,r=this.indentCharacter.repeat(n<0?0:n)+e.trim();e.length===0&&this.result.push(e),e.length!==0&&r.length>0&&this.result.push(r),r!==e&&this.diffs.puLine truncated
)`).replace(/,[\n\s]*?\)/gs,")").replace(/,(\s*?\))$/gm,(l,o)=>o).trim();return this.options.useTabs&&(a=i.default.replace(a,/(?<=^ *) {4}/gm," ".repeat(this.indentSize))),a=a.replace(/func\((.*)\)/gis,(l,o)=>o),this.isInline(a.trim())&&(a=a.trim()),this.indentRawPhpBlock(t,a)}formatJS(e){let t=e,n={js:[],entangle:[]};return Object.keys(n).forEach(r=>{t=t.replace(new RegExp(`@${r}\\((?:[^)(]+|\\((?:[^)(]+|\\([^)(]*\\))*\\))*\\)`,"gs"),s=>{let a=n[r].push(s)-1;return this.getPlaceholder(r,a,s.length)})}),t=R.default.js_beautify(t,{brace_style:"preserve-inline"}),Object.keys(n).forEach(r=>{t=t.replace(new RegExp(this.getPlaceholder(r,"_*(\\d+)"),"gms"),(s,a)=>n[r][a])}),t}};var Ae=g(require("path")),ke=g(require("fs")),Te=g(require("ajv")),Oe=g(require("find-config")),st=new Te.default,Fe=[".bladeformatterrc.json",".bladeformatterrc"];function je(h){for(let e=0;e<Fe.length;e+=1){let t=(0,Oe.default)(Fe[e],{cwd:Ae.default.dirname(h),home:!1});if(t)return t}return null}async function We(h){if(h===null)return;let e=JSON.parse((await ke.default.promises.readFile(h)).toString()),t={type:"object",properties:{indentSize:{type:"integer",nullable:!0},wrapLineLength:{type:"integer",nullable:!0},wrapAttributes:{type:"string",enum:["auto","force","force-aligned","force-expand-multiline","aligned-multiple","preserve","preserve-aligned"],nullable:!0},endWithNewline:{type:"boolean",nullable:!0},endOfLine:{type:"string",enum:["LF","CRLF"],nullable:!0},useTabs:{type:"boolean",nullable:!0},sortTailwindcssClasses:{type:"boolean",nullable:!0},tailwindcssConfigPath:{type:"string",nullable:!0},sortHtmlAttributes:{type:"string",enum:["none","alphabetical","code-guide","idiomatic","vuejs","custom"],nullable:!0},customHtmlAttributesOrder:{type:"array",nullable:!0,items:{type:"string"},default:[]},noMultipleEmptyLines:{type:"boolean",nullable:!0},noPhpSyntaxCheck:{type:"boolean",nullable:!0}},additionalProperties:!0},n=st.compile(t);if(!n(e))throw n;return e}var H=class extends Error{};var N=class{constructor(e={},t=[]){var n;this.currentTargetPath=".",this.paths=t,this.options=e,this.targetFiles=[],this.errors=[],this.diffs=[],this.outputs=[],this.formattedFiles=[],this.ignoreFile="",this.fulFillFiles=[],this.targetFiles=[],this.runtimeConfigPath=(n=e.runtimeConfigPath)!=null?n:null,this.runtimeConfigCache={}}async format(e,t={}){this.options=this.options||t;let n=B.default.resolve(f.default.cwd(),"target");return await this.readIgnoreFile(n),await this.findTailwindConfig(n),await this.readRuntimeConfig(n),new A(this.options).formatContent(e).catch(r=>{throw new H(r)})}async formatFromCLI(){try{this.printPreamble(),await this.readIgnoreFile(f.default.cwd()),await this.processPaths(),this.printResults()}catch{}}fileExists(e){return j.default.promises.access(e,j.default.constants.F_OK).then(()=>!0).catch(()=>!1)}async readIgnoreFile(e){let t=".bladeignore",n,r=B.default.dirname(e);if(this.options.ignoreFilePath?n=this.options.ignoreFilePath:n=(0,ae.default)(t,{cwd:r}),!!n)try{this.ignoreFile=(await j.default.promises.readFile(n)).toString()}catch{}}async findTailwindConfig(e){if(!this.options.sortTailwindcssClasses)return;let t="tailwind.config.js",n;if(this.options.tailwindcssConfigPath)if(this.runtimeConfigPath){let r=B.default.dirname(this.runtimeConfigPath);n=B.default.resolve(r,this.options.tailwindcssConfigPath)}else B.default.isAbsolute(this.options.tailwindcssConfigPath)?n=B.default.resolve(this.options.tailwindcssConfigPath):n=B.default.resolve(this.options.tailwindcssConfigPath);else{let r=B.default.dirname(e);n=(0,ae.default)(t,{cwd:r})}n&&(this.options.tailwindcssConfigPath=n)}async readRuntimeConfig(e){var n,r;v.default.isEmpty(this.runtimeConfigCache)&&(this.options=v.default.merge(this.options,this.runtimeConfigCache));let t;if(this.options.runtimeConfigPath?t=this.options.runtimeConfigPath:t=je(e),!v.default.isNull(t)){this.runtimeConfigPath=t;try{let s=await We(t);this.options=v.default.merge(this.options,s),this.runtimeConfigCache=this.options,this.options.sortTailwindcssClasses&&await this.findTailwindConfig(e)}catch(s){s instanceof SyntaxError&&(f.default.stdout.write(b.default.red.bold(`
Blade Formatter JSON Syntax Error:
`)),f.default.stdout.write(se.default.format(s)),f.default.exit(1)),f.default.stdout.write(b.default.red.bold(`
Blade Formatter Config Error: ${B.default.basename(t)}
`)),f.default.stdout.write(`\`${s.errors[0].instancePath.replace("/","")}\` ${s.errors[0].message}
`),(n=s.errors[0].params)!=null&&n.allowedValues&&console.log((r=s.errors[0].params)==null?void 0:r.allowedValues),f.default.exit(1)}}}async processPaths(){await Promise.all(v.default.map(this.paths,async e=>this.processPath(e)))}async processPath(e){await N.globFiles(e).then(t=>v.default.map(t,n=>B.default.relative(".",n))).then(t=>this.filterFiles(t)).then(this.fulFillFiles).then(t=>this.formatFiles(t))}static globFiles(e){return new Promise((t,n)=>{(0,He.default)(e,(r,s)=>r?n(r):t(s))})}async filterFiles(e){if(this.ignoreFile==="")return e;let t=/^\.\.*/,n=v.default.filter(e,a=>t.test(B.default.relative(".",a))),r=v.default.xor(e,n),s=(0,ze.default)().add(this.ignoreFile).filter(r);return v.default.concat(n,s)}static fulFillFiles(e){return this.targetFiles.push(e),Promise.resolve(e)}async formatFiles(e){await Promise.all(v.default.map(e,async t=>this.formatFile(t)))}async formatFile(e){await this.findTailwindConfig(e),await this.readRuntimeConfig(e),await G(e).then(t=>Promise.resolve(t.toString("utf-8"))).then(t=>new A(this.options).formatContent(t)).then(t=>this.checkFormatted(e,t)).then(t=>this.writeToFile(e,t)).catch(t=>{this.handleError(e,t)})}async checkFormatted(e,t){this.printFormattedOutput(e,t);let n=j.default.readFileSync(e,"utf-8"),r=z(n),s=z(t),a=_e(e,r,s);return this.diffs.push(a),this.outputs.push(t),a.length>0&&((this.options.progress||this.options.write)&&f.default.stdout.write(b.default.green("F")),this.options.checkFormatted&&(f.default.stdout.write(`${e}
`),f.default.exitCode=1),this.formattedFiles.push(e)),a.length===0&&(this.options.progress||this.options.write)&&f.default.stdout.write(b.default.green(".")),Promise.resolve(t)}printFormattedOutput(e,t){this.options.write||this.options.checkFormatted||(f.default.stdout.write(`${t}`),v.default.last(this.paths)===e||v.default.last(this.targetFiles)===e)||(this.paths.length>1||this.targetFiles.length>1)&&f.default.stdout.write(`
`)}writeToFile(e,t){this.options.write&&(this.options.checkFormatted||t.length===0||v.default.isNull(t)||v.default.isEmpty(t)||j.default.writeFile(e,t,n=>{n&&(f.default.stdout.write(`${b.default.red(n.message)}
`),f.default.exit(1))}))}handleError(e,t){(this.options.progress||this.options.write)&&f.default.stdout.write(b.default.red("E")),f.default.exitCode=1,this.errors.push({path:e,message:t.message,error:t})}printPreamble(){this.options.checkFormatted&&f.default.stdout.write(`Check formatting...
`)}async printResults(){this.printDescription(),this.printDifferences(),this.printFormattedFiles(),this.printErrors()}printDescription(){if(!this.options.write)return;let e=`
`;f.default.stdout.write(e),f.default.stdout.write(b.default.bold.green(`Fixed: F
`)),f.default.stdout.write(b.default.bold.red(`Errors: E
`)),f.default.stdout.write(b.default.bold("Not Changed: ")+b.default.bold.green(`.
`))}printFormattedFiles(){if(this.formattedFiles.length===0){this.options.checkFormatted&&f.default.stdout.write(b.default.bold(`
All matched files are formatted!
`));return}if(!this.options.write){this.options.checkFormatted&&f.default.stdout.write(`
Above file(s) are formattable. Forgot to run formatter? Use ${b.default.bold("--write")} option to overwrite.
`);return}f.default.stdout.write(b.default.bold(`
Formatted Files:
`)),v.default.each(this.formattedFiles,e=>f.default.stdout.write(`${b.default.bold(e)}
`))}printDifferences(){if(this.options.diff){if(f.default.stdout.write(b.default.bold(`
Differences:
`)),v.default.filter(this.diffs,e=>e.length>0).length===0){f.default.stdout.write((0,b.default)(`No changes found.
`));return}v.default.each(this.diffs,e=>ye(e))}}printErrors(){v.default.isEmpty(this.errors)||(f.default.stdout.write(b.default.red.bold(`
Errors:
`)),v.default.each(this.errors,e=>f.default.stdout.write(`${se.default.format(e)}
`)))}};0&&(module.exports={BladeFormatter,Formatter});
//# sourceMappingURL=bundle.js.map
@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../src/main.ts", "../src/formatter.ts", "../src/vsctm.ts", "../src/util.ts", "../src/indent.ts", "../src/regex.ts", "../src/comment.ts", "../src/space.ts", "../src/runtimeConfig.ts", "../src/errors/formatError.ts"],
"sourcesContent": ["import ignore from 'ignore';\n\nimport nodepath from 'path';\nimport fs from 'fs';\nimport process from 'process';\nimport chalk from 'chalk';\nimport glob from 'glob';\nimport nodeutil from 'util';\nimport _ from 'lodash';\nimport findConfig from 'find-config';\nimport { Config as TailwindConfig } from 'tailwindcss/types/config';\nimport Formatter from './formatter';\nimport * as util from './util';\nimport {\n findRuntimeConfig,\n readRuntimeConfig,\n EndOfLine,\n RuntimeConfig,\n SortHtmlAttributes,\n WrapAttributes,\n} from './runtimeConfig';\nimport FormatError from './errors/formatError';\n\nexport type CLIOption = {\n write?: boolean;\n diff?: boolean;\n checkFormatted?: boolean;\n progress?: boolean;\n ignoreFilePath?: string;\n runtimeConfigPath?: string;\n};\n\nexport type FormatterOption = {\n indentSize?: number;\n wrapLineLength?: number;\n wrapAttributes?: WrapAttributes;\n endWithNewline?: boolean;\n endOfLine?: EndOfLine;\n useTabs?: boolean;\n sortTailwindcssClasses?: true;\n tailwindcssConfigPath?: string;\n tailwindcssConfig?: TailwindConfig;\n sortHtmlAttributes?: SortHtmlAttributes;\n customHtmlAttributesOrder?: string[] | string;\n noMultipleEmptyLines?: boolean;\n noPhpSyntaxCheck?: boolean;\n};\n\nexport type BladeFormatterOption = CLIOption & FormatterOption;\n\nclass BladeFormatter {\n diffs: any;\n\n errors: any;\n\n formattedFiles: any;\n\n ignoreFile: any;\n\n options: FormatterOption & CLIOption;\n\n outputs: any;\n\n currentTargetPath: string;\n\n paths: any;\n\n targetFiles: any;\n\n fulFillFiles: any;\n\n static targetFiles: any;\n\n runtimeConfigPath: string | null;\n\n runtimeConfigCache: RuntimeConfig;\n\n constructor(options: BladeFormatterOption = {}, paths: any = []) {\n this.currentTargetPath = '.';\n this.paths = paths;\n this.options = options;\n this.targetFiles = [];\n this.errors = [];\n this.diffs = [];\n this.outputs = [];\n this.formattedFiles = [];\n this.ignoreFile = '';\n this.fulFillFiles = [];\n this.targetFiles = [];\n this.runtimeConfigPath = options.runtimeConfigPath ?? null;\n this.runtimeConfigCache = {};\n }\n\n async format(content: any, opts: BladeFormatterOption = {}) {\n this.options = this.options || opts;\n const target = nodepath.resolve(process.cwd(), 'target');\n await this.readIgnoreFile(target);\n await this.findTailwindConfig(target);\n await this.readRuntimeConfig(target);\n return new Formatter(this.options).formatContent(content).catch((err) => {\n throw new FormatError(err);\n });\n }\n\n async formatFromCLI() {\n try {\n this.printPreamble();\n await this.readIgnoreFile(process.cwd());\n await this.processPaths();\n this.printResults();\n } catch (error) {\n // do nothing\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n fileExists(filepath: string) {\n return fs.promises\n .access(filepath, fs.constants.F_OK)\n .then(() => true)\n .catch(() => false);\n }\n\n async readIgnoreFile(filePath: string) {\n const configFilename = '.bladeignore';\n\n let configFilePath: string | null;\n const worakingDir = nodepath.dirname(filePath);\n\n if (this.options.ignoreFilePath) {\n configFilePath = this.options.ignoreFilePath;\n } else {\n configFilePath = findConfig(configFilename, { cwd: worakingDir });\n }\n\n if (!configFilePath) {\n return;\n }\n\n try {\n this.ignoreFile = (await fs.promises.readFile(configFilePath)).toString();\n } catch (err) {\n // do nothing\n }\n }\n\n async findTailwindConfig(filePath: string) {\n if (!this.options.sortTailwindcssClasses) {\n return;\n }\n\n const configFilename = 'tailwind.config.js';\n\n let configFilePath: string | null | undefined;\n\n if (this.options.tailwindcssConfigPath) {\n if (this.runtimeConfigPath) {\n const workingDir = nodepath.dirname(this.runtimeConfigPath);\n configFilePath = nodepath.resolve(workingDir, this.options.tailwindcssConfigPath);\n } else if (nodepath.isAbsolute(this.options.tailwindcssConfigPath)) {\n configFilePath = nodepath.resolve(this.options.tailwindcssConfigPath);\n } else {\n configFilePath = nodepath.resolve(this.options.tailwindcssConfigPath);\n }\n } else {\n // lookup tailwind config\n const workingDir = nodepath.dirname(filePath);\n configFilePath = findConfig(configFilename, { cwd: workingDir });\n }\n\n if (!configFilePath) {\n return;\n }\n\n this.options.tailwindcssConfigPath = configFilePath;\n }\n\n async readRuntimeConfig(filePath: string): Promise<RuntimeConfig | undefined> {\n if (_.isEmpty(this.runtimeConfigCache)) {\n this.options = _.merge(this.options, this.runtimeConfigCache);\n }\n\n let configFile: string | null;\n\n if (this.options.runtimeConfigPath) {\n confiLine truncated
"mappings": "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 truncated
"names": ["main_exports", "__export", "BladeFormatter", "Formatter", "__toCommonJS", "import_ignore", "import_path", "import_fs", "import_process", "import_chalk", "import_glob", "import_util", "import_lodash", "import_find_config", "import_js_beautify", "import_lodash", "vscodeTmModule", "import_detect_indent", "import_aigle", "import_xregexp", "import_tailwindcss_class_sorter", "import_html_attribute_sorter", "import_fs", "import_lodash", "vscodeOniguruma", "import_path", "import_lodash", "import_fs", "import_os", "import_chalk", "import_standalone", "import_detect_indent", "import_lodash", "directivePrefix", "indentStartTokens", "indentStartTokensWithoutPrefix", "_", "token", "indentEndTokens", "indentElseTokens", "optionalStartWithoutEndTokens", "tokenForIndentStartOrElseTokens", "indentStartOrElseTokens", "indentStartAndEndTokens", "phpKeywordStartTokens", "phpKeywordEndTokens", "inlinePhpDirectives", "inlineFunctionTokens", "conditionalTokens", "unbalancedStartTokens", "cssAtRuleTokens", "hasStartAndEndToken", "tokenizeLineResult", "originalLine", "tokenStruct", "nestedParenthesisRegex", "optional", "obj", "chain", "_", "readFile", "path", "resolve", "reject", "fs", "error", "data", "splitByLines", "content", "printWidthForInline", "defaultFormatPhpOption", "formatStringAsPhp", "params", "options", "prettier", "phpPlugin", "formatRawStringAsPhp", "match", "p1", "getArgumentsCount", "expression", "code", "ast", "printDiffs", "diffs", "_", "diff", "chalk", "generateDiff", "path", "originalLines", "formattedLines", "originalLine", "index", "prettifyPhpContentWithUnescapedTags", "content", "directives", "indentStartTokens", "directiveRegexes", "nestedParenthesisRegex", "resolve", "res", "match", "p1", "p2", "p3", "formatStringAsPhp", "match2", "j1", "j2", "j3", "formatAsPhp", "content", "prettifyPhpContentWithUnescapedTags", "preserveDirectives", "content", "startTokens", "_", "phpKeywordStartTokens", "endTokens", "phpKeywordEndTokens", "resolve", "res", "regex", "nestedParenthesisRegex", "match", "p1", "p2", "p3", "revertDirectives", "content", "resolve", "res", "_", "match", "p1", "p2", "escapeTags", "checkResult", "formatted", "escapeReplacementString", "string", "getEndOfLine", "endOfLine", "os", "VscodeTextmate", "vsctm", "oniguruma", "_a", "vscodeOniguruma", "wasm", "fs", "scopeName", "readFile", "path", "content", "sources", "str", "splitedLines", "grammar", "_", "line", "splitByLines", "content", "isCommentedLine", "line", "isMultiline", "lines", "addPrefixToLine", "formatPhpComment", "comment", "nonCommentLineExists", "row", "trimmedLine", "import_lodash", "adjustSpaces", "content", "directivesRequiredSpace", "_", "nestedParenthesisRegex", "_matched", "p1", "p2", "Formatter", "options", "optional", "vscodeTmModule", "getEndOfLine", "content", "resolve", "target", "formatAsPhp", "adjustSpaces", "formattedResult", "checkResult", "data", "promise", "preserveDirectives", "preserved", "beautify", "revertDirectives", "_", "_match", "p1", "p2", "match", "contentUnformatted", "negativeLookAhead", "indentStartTokens", "indentEndTokens", "indentElseTokens", "inlineNegativeLookAhead", "inlineFunctionTokens", "phpKeywordStartTokens", "unbalancedStartTokens", "cssAtRuleTokens", "inlineRegex", "nestedParenthesisRegex", "regex", "formatted", "p3", "p4", "p5", "p6", "p7", "result", "beginStr", "elseStr", "directivePrefix", "indentStartTokensWithoutPrefix", "replaced", "targetTokens", "inlineFunctionDirectives", "inlineFunctionRegex", "endTokens", "matched", "formatRawStringAsPhp", "printWidthForInline", "indentStartOrElseTokens", "_matched", "inside", "customStartRegex", "startRegex", "elseRegex", "endRegex", "endStr", "unbalancedConditions", "unbalancedEchos", "directive", "directives", "x", "recursivelyMatched", "xregexp", "escapeReplacementString", "innerRegex", "conditionalTokens", "_a", "strategy", "regexes", "customRegexes", "value", "length", "index", "brace", "replace", "gap", "attribute", "template", "rawBlock", "placeholder", "matchedLine", "indent", "detectIndent", "formatStringAsPhp", "_q1", "q2", "indented", "indentLevel", "prefix", "prefixForEnd", "lines", "line", "prefixSpaces", "withoutCommentLine", "group1", "group2", "Aigle", "formattedAsHtml", "res", "formatPhpComment", "bladeBrace", "inlinePhpDirectives", "token", "match2", "wrapLength", "inlinedComment", "script", "useTabs", "_m", "openingTag", "restofTag", "firstLine", "offsettedLines", "beautifyOpts", "splitedLines", "splitByLines", "vsctmModule", "VscodeTextmate", "grammar", "tokenizedLines", "err", "i", "originalLine", "tokenizeLineResult", "phpKeywordEndTokens", "indentStartAndEndTokens", "tokenForIndentStartOrElseTokens", "tokenStruct", "count", "inString", "stack", "expression", "getArgumentsCount", "optionalStartWithoutEndTokens", "hasStartAndEndToken", "j", "whitespaces", "formattedLine", "level", "matchedExpression", "formatTarget", "formattedExpression", "jsCode", "code", "tempVarStore", "m", "import_path", "import_fs", "importLine truncated
}
@@ -0,0 +1,105 @@
"use strict";var tt=Object.create;var X=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var at=(h,e)=>{for(var t in e)X(h,t,{get:e[t],enumerable:!0})},ce=(h,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of rt(e))!st.call(h,r)&&r!==t&&X(h,r,{get:()=>e[r],enumerable:!(n=nt(e,r))||n.enumerable});return h};var m=(h,e,t)=>(t=h!=null?tt(it(h)):{},ce(e||!h||!h.__esModule?X(t,"default",{value:h,enumerable:!0}):t,h)),ot=h=>ce(X({},"__esModule",{value:!0}),h);var _t={};at(_t,{default:()=>Ye});module.exports=ot(_t);var Ue=m(require("yargs")),Ve=m(require("concat-stream")),Ke=require("vscode-oniguruma"),W=m(require("chalk")),Ge=m(require("lodash")),Qe=m(require("os")),qe=require("fs"),Ze=require("yargs/helpers");var Ne=m(require("ignore")),B=m(require("path")),H=m(require("fs")),f=m(require("process")),$=m(require("chalk")),Je=m(require("glob")),ae=m(require("util")),v=m(require("lodash")),oe=m(require("find-config"));var R=m(require("js-beautify")),i=m(require("lodash")),ft=m(require("vscode-textmate")),w=m(require("detect-indent")),Fe=m(require("aigle")),ke=m(require("xregexp")),Y=require("@shufo/tailwindcss-class-sorter"),se=require("html-attribute-sorter");var Be=require("fs"),Ie=m(require("lodash")),ie=m(require("vscode-oniguruma")),Re=m(require("path"));var S=m(require("lodash")),ge=m(require("fs")),fe=m(require("os")),K=m(require("chalk")),G=m(require("prettier/standalone")),Q=m(require("@prettier/plugin-php/standalone")),lt=m(require("detect-indent"));var z=m(require("lodash")),A="@",P=["@alert","@pushonce","@push","@slot","@switch","@unless","@verbatim","@prependonce","@prepend","@once","@error","@empty","@guest","@isset","@permission","@permissions","@canany","@cannot","@can","@role","@hasrole","@hasanyrole","@hasallroles","@unlessrole","@hasexactroles","@if","@production","@env","@while","@auth","@forelse","@for","@foreach","@php","@component","@section","@customdirective"],he=z.default.map(P,h=>h.substring(1)),E=["@endalert","@endpushonce","@endpush","@endslot","@endswitch","@endunless","@endverbatim","@show","@stop","@endprependonce","@endprepend","@endonce","@enderror","@append","@overwrite","@endempty","@endguest","@endisset","@endpermission","@endpermissions","@endcanany","@endcannot","@endcan","@endrole","@endhasrole","@endhasanyrole","@endhasallroles","@endunlessrole","@endhasexactroles","@endif","@endproduction","@endenv","@endwhile","@endauth","@endforelse","@endforeach","@endfor","@endphp","@endcomponent","@endsection","@endcustomdirective"],D=["@elseenv","@elseif","@elsecanany","@elsecannot","@elsecan","@else","@elsecustomdirective"],ee={"@section":2,"@push":2,"@prepend":2,"@slot":2},pe=["@forelse","@if"],te=["@empty"],de=["@default"],T=["@forelse","@if","@for","@foreach","@while","@sectionmissing","@case"],M=["@endforelse","@endif","@endforeach","@endfor","@endwhile","@break"],ne=["@button","@class","@include","@disabled","@checked","@json"],O=["@set","@json","@selected","@checked","@disabled","@php","@include","@includeif","@includewhen","@includeunless","@includefirst","@button","@class","@props","@aware"],ue=["@if","@while","@case","@isset","@empty","@elseif","@component","@hassection","@unless"],U=["@hassection"],V=["@charset","@color-profile","@counter-style","@font-face","@font-feature-values","@import","@keyframes","@media","@namespace","@page","@property","@supports"];function me(h,e){return z.default.filter(h.tokens,t=>{let n=e.substring(t.startIndex,t.endIndex).trim();return z.default.includes(P,n)||z.default.includes(E,n)}).length>=2}var y="\\(((?:[^)(]+|\\((?:[^)(]+|\\((?:[^)(]+|\\((?:[^)(]+|\\([^)(]*\\))*\\))*\\))*\\))*)\\)?";var _=h=>{let e={get(){return null}};return S.default.isUndefined(h)||S.default.isNull(h)?e:h};async function q(h){return new Promise((e,t)=>{ge.default.readFile(h,(n,r)=>n?t(n):e(r))})}function N(h){return h?h.split(/\r\n|\n|\r/):""}var F=1e3,ye={noPhpSyntaxCheck:!1,printWidth:F,trailingCommaPHP:!0,phpVersion:"8.1",singleQuote:!0};function L(h,e={}){let t={...ye,...e};try{return G.default.format(h.replace(/\n$/,""),{parser:"php",printWidth:1e3,singleQuote:t.singleQuote,phpVersion:t.phpVersion,trailingCommaPHP:t.trailingCommaPHP,plugins:[Q.default]})}catch(n){if(t.noPhpSyntaxCheck===!1)throw n;return h}}function C(h,e={}){let t={...ye,...e};try{return G.default.format(`<?php echo ${h} ?>`,{parser:"php",printWidth:t.printWidth,singleQuote:t.singleQuote,phpVersion:t.phpVersion,trailingCommaPHP:t.trailingCommaPHP,plugins:[Q.default]}).replace(/<\?php echo (.*)?\?>/gs,(n,r)=>r.trim().replace(/;\s*$/,""))}catch(n){if(t.noPhpSyntaxCheck===!1)throw n;return h}}function _e(h){let e=`<?php tmp_func${h}; ?>`,{ast:t}=G.default.__debug.parse(e,{parser:"php",phpVersion:"8.0",plugins:[Q.default]});try{return t.children[0].expression.arguments.length||0}catch{return 0}}function we(h){return Promise.all(S.default.map(h,async e=>{process.stdout.writLine truncated
`),process.stdout.write(K.default.red(`--${e.original}
`)),process.stdout.write(K.default.green(`++${e.formatted}
`))}))}function ve(h,e,t){let n=S.default.map(e,(r,s)=>S.default.isEmpty(r)||r===t[s]?null:{path:h,line:s+1,original:r,formatted:t[s]});return S.default.without(n,null)}async function ct(h){let e=S.default.without(P,"@switch","@forelse","@php").join("|"),t=new RegExp(`(?!\\/\\*.*?\\*\\/)(${e})(\\s*?)${y}`,"gmi");return new Promise(n=>n(h)).then(n=>S.default.replace(n,t,(r,s,a,l)=>L(`<?php ${s.substr("1")}${a}(${l}) ?>`).replace(/<\?php\s(.*?)(\s*?)\((.*?)\);*\s\?>\n/gs,(o,c,d,p)=>`@${c.trim()}${d}(${p.trim()})`).replace(/([\n\s]*)->([\n\s]*)/gs,"->").replace(/,\)$/,")").replace(/(?:\n\s*)* as(?= (?:&{0,1}\$[\w]+|list|\[\$[\w]+))/g," as"))).then(n=>L(n))}async function be(h){return ct(h)}function Pe(h){let e=S.default.without(T,"@case"),t=S.default.without(M,"@break");return new Promise(n=>n(h)).then(n=>{let r=new RegExp(`(${e.join("|")})([\\s]*?)${y}`,"gis");return S.default.replace(n,r,(s,a,l,o)=>`<beautifyTag start="${a}${l}" exp="^^^${S.default.escape(o)}^^^">`)}).then(n=>{let r=new RegExp(`(?!end=".*)(${t.join("|")})(?!.*")`,"gi");return S.default.replace(n,r,(s,a)=>`</beautifyTag end="${a}">`)})}function $e(h){return new Promise(e=>e(h)).then(e=>S.default.replace(e,/<beautifyTag.*?start="(.*?)".*?exp=".*?\^\^\^(.*?)\^\^\^.*?"\s*>/gs,(t,n,r)=>`${n}(${S.default.unescape(r)})`)).then(e=>S.default.replace(e,/<\/beautifyTag.*?end="(.*?)"\s*>/gs,(t,n)=>`${n}`))}var ht=["/\\*\\* phptag_start \\*\\*/","/\\*\\* end_phptag \\*\\*/","/\\*escaped\\*/","__BLADE__;","/\\* blade_comment_start \\*/","/\\* blade_comment_end \\*/","/\\*\\*\\*script_placeholder\\*\\*\\*/","beautifyTag","@customdirective","@elsecustomdirective","@endcustomdirective"];function xe(h){if(new RegExp(ht.join("|")).test(h))throw new Error(["Can't format blade: something goes wrong.","Please check if template is too complicated or not. Or simplify template might solves issue."].join(`
`));return h}function re(h){return h.replace(/\$/g,"$$$$")}function Se(h){switch(h){case"LF":return`
`;case"CRLF":return`\r
`;default:return fe.default.EOL}}var Z=class{constructor(e,t){return(async()=>{var n;return this.vsctm=(n=e.default)!=null?n:e,this.oniguruma=t||ie.default||ie,await this.loadWasm(),this})()}async loadWasm(){var t;let e=await Be.promises.readFile(require.resolve("vscode-oniguruma/release/onig.wasm"));if(await((t=this.oniguruma)==null?void 0:t.loadWASM(e.buffer)),!this.initCalled){try{this.oniguruma.loadWASM(e.buffer)}catch{this.initCalled=!0}this.initCalled=!0}}createRegistry(){return this.registry=new this.vsctm.Registry({loadGrammar:e=>e==="text.html.php.blade"?q(Re.default.resolve(__dirname,"../syntaxes/blade.tmLanguage.json")).then(t=>this.vsctm.parseRawGrammar(t.toString(),"./blade.tmLanguage.json")):null,onigLib:Promise.resolve({createOnigScanner:e=>new this.oniguruma.OnigScanner(e),createOnigString:e=>new this.oniguruma.OnigString(e)})}),this.registry}tokenizeLines(e,t){return Ie.default.map(e,n=>{var r;return t.tokenizeLine(n,(r=this.vsctm)==null?void 0:r.INITIAL)})}};function dt(h){return h.split(`
`)}function ut(h){return h.trim().startsWith("*")}function mt(h){return h.length>1}function gt(h){return` ${h}`}function Ee(h){let e=dt(h);if(!mt(e))return h;let t=!1;return e.map((r,s)=>{if(s===0||t)return r;if(!ut(r))return t=!0,r;let a=r.trim();return gt(a)}).join(`
`)}var De=m(require("lodash"));function Le(h){let e=["@unless"];return De.default.replace(h,new RegExp(`(?<!@)(${e.join("|")})\\s*${y}`,"gi"),(t,n,r)=>`${n} (${r})`)}var j=class{constructor(e){this.options={noPhpSyntaxCheck:!1,...e},this.vsctm=_(this.options).vsctm||ft,this.oniguruma=_(this.options).oniguruma,this.indentCharacter=_(this.options).useTabs?" ":" ",this.indentSize=_(this.options).indentSize||4,this.wrapLineLength=_(this.options).wrapLineLength||120,this.wrapAttributes=_(this.options).wrapAttributes||"auto",this.currentIndentLevel=0,this.shouldBeIndent=!1,this.isInsideCommentBlock=!1,this.stack=[],this.ignoredLines=[],this.curlyBracesWithJSs=[],this.rawBlocks=[],this.rawPhpTags=[],this.inlineDirectives=[],this.conditions=[],this.inlinePhpDirectives=[],this.rawPropsBlocks=[],this.bladeDirectives=[],this.bladeDirectivesInStyle=[],this.bladeComments=[],this.phpComments=[],this.bladeBraces=[],this.rawBladeBraces=[],this.nonnativeScripts=[],this.scripts=[],this.htmlAttributes=[],this.xData=[],this.xInit=[],this.htmlTags=[],this.templatingStrings=[],this.stringLiteralInPhp=[],this.shorthandBindings=[],this.componentAttributes=[],this.customDirectives=[],this.directivesInScript=[],this.unbalancedDirectives=[],this.escapedBladeDirectives=[],this.result=[],this.diffs=[],this.defaultPhpFormatOption={noPhpSyntaxCheck:this.options.noPhpSyntaxCheck,printWidth:this.wrapLineLength},this.endOfLine=Se(_(this.options).endOfLine)}formatContent(e){return new Promise(t=>t(e)).then(t=>this.preserveIgnoredLines(t)).then(t=>this.preserveNonnativeScripts(t)).then(t=>this.preserveCurlyBraceForJS(t)).then(t=>this.preserveRawPhpTags(t)).then(t=>this.preserveEscapedBladeDirective(t)).then(t=>be(t)).then(t=>this.preserveBladeComment(t)).then(t=>this.preserveBladeBrace(t)).then(t=>this.preserveRawBladeBrace(t)).then(t=>this.preserveConditions(t)).then(t=>this.preserveInlineDirective(t)).then(t=>this.preserveInlinePhpDirective(t)).then(t=>this.preserveBladeDirectivesInScripts(t)).then(t=>this.preserveBladeDirectivesInStyles(t)).then(t=>this.preserveCustomDirective(t)).then(t=>this.preserveUnbalancedDirective(t)).then(t=>this.breakLineBeforeAndAfterDirective(t)).then(async t=>(this.bladeDirectives=await this.formatPreservedBladeDirectives(this.bladeDirectives),t)).then(t=>this.preserveScripts(t)).then(t=>this.sortTailwindcssClasses(t)).then(t=>this.formatXInit(t)).then(t=>this.formatXData(t)).then(t=>this.preserveComponentAttribute(t)).then(t=>this.preserveShorthandBinding(t)).then(t=>this.sortHtmlAttributes(t)).then(t=>this.preservePhpBlock(t)).then(t=>this.preserveHtmlAttributes(t)).then(t=>this.preserveHtmlTags(t)).then(t=>this.formatAsHtml(t)).then(t=>this.formatAsBlade(t)).then(t=>this.restoreHtmlTags(t)).then(t=>this.restoreHtmlAttributes(t)).then(t=>this.restorePhpBlock(t)).then(t=>this.restoreShorthandBinding(t)).then(t=>this.restoreComponentAttribute(t)).then(t=>this.restoreXData(t)).then(t=>this.restoreXInit(t)).then(t=>this.restoreScripts(t)).then(t=>this.restoreUnbalancedDirective(t)).then(t=>this.restoreCustomDirective(t)).then(t=>this.restoreBladeDirectivesInStyles(t)).then(t=>this.restoreBladeDirectivesInScripts(t)).then(t=>this.restoreInlinePhpDirective(t)).then(t=>this.restoreInlineDirective(t)).then(t=>this.restoreConditions(t)).then(t=>this.restoreRawBladeBrace(t)).then(t=>this.restoreBladeBrace(t)).then(t=>this.restoreBladeComment(t)).then(t=>this.restoreEscapedBladeDirective(t)).then(t=>this.restoreRawPhpTags(t)).then(t=>this.restoreCurlyBraceForJS(t)).then(t=>this.restoreNonnativeScripts(t)).then(t=>this.restoreIgnoredLines(t)).then(t=>Le(t)).then(t=>xe(t))}formatAsHtml(e){let t={indent_size:_(this.options).indentSize||4,wrap_line_length:_(this.options).wrapLineLength||120,wrap_attributes:_(this.options).wrapAttributes||"auto",end_with_newline:_(this.options).endWithNewline||!0,max_preserve_newlines:_(this.options).noMultipleEmptyLines?1:void 0,css:{end_with_newline:!1},eol:this.endOfLine},n=new Promise(r=>r(e)).then(r=>Pe(r)).then(r=>R.default.html_beautify(r,t)).then(r=>$e(r));return Promise.resolve(n)}async sortTailwindcssClasses(e){return this.options.sortTailwindcssClasses?i.default.replace(e,/(?<=\s+(?!:)class\s*=\s*([\"\']))(.*?)(?=\1)/gis,(t,n,r)=>{if(i.default.isEmpty(r))return r;if(this.options.tailwindcssConfigPath){let s={tailwindConfigPath:this.options.tailwindcssConfigPath};return(0,Y.sortClasses)(r,s)}if(this.options.tailwindcssConfig){let s={tailwindConfig:this.options.tailwindcssConfig};return(0,Y.sortClasses)(r,s)}return(0,Y.sortClasses)(r)}):e}async preserveIgnoredLines(e){return i.default.chain(e).replace(/(^(?<!.+)^{{--\s*blade-formatter-disable\s*--}}.*?)([\r\n]*)$(?![\r\n])/gis,(t,n,r)=>this.storeIgnoredLines(`${n}${r.replace(/^\n/,"")}`)).replace(/(?:({{--\s*?blade-formatter-disable\s*?--}}|<!--\s*?prettier-ignore-start\s*?-->|{{--\s*?prettier-ignore-start\s*?--}})).*?(?:({{--\s*?blade-formatter-enable\s*?--}}|<!--\s*?prettier-ignore-end\s*?-->|{{--\s*?prettier-ignore-end\s*?--}})) Line truncated
${s.trim()}
`),e=i.default.replace(e,new RegExp(`(?<=<.*?(?<!=)>).*?(${i.default.without(E,"@endphp").join("|")})(?=<.*?>)`,"gmis"),s=>`
${s.trim()}
`);let t=["@case",...D];e=i.default.replace(e,new RegExp(`(\\s*?)(${t.join("|")})(\\s*?)${y}(\\s*)`,"gmi"),s=>`
${s.trim()}
`),e=i.default.replace(e,new RegExp(`\\s*?(?!(${i.default.without(D,"@else").join("|")}))@else\\s+`,"gim"),s=>`
${s.trim()}
`),e=i.default.replace(e,/@case\S*?\s*?@case/gim,s=>`${s.replace(`
`,"")}`);let n=["@break"];i.default.forEach(n,s=>{e=i.default.replace(e,new RegExp(`(\\s*?)${s}\\s+`,"gmi"),a=>`
${a.trim()}
`)}),i.default.forEach(["@default"],s=>{e=i.default.replace(e,new RegExp(`(\\s*?)${s}\\s*`,"gmi"),a=>`
${a.trim()}
`)});let r=i.default.chain(P).map(s=>i.default.replace(s,/@/,"")).value();return i.default.forEach(r,s=>{try{let a=ke.default.matchRecursive(e,`\\@${s}`,`\\@end${s}`,"gmi",{valueNames:[null,"left","match","right"]});if(i.default.isEmpty(a))return;for(let l of a)if(l.name==="match"){new RegExp(P.join("|")).test(l.value)&&(e=i.default.replace(e,l.value,this.breakLineBeforeAndAfterDirective(re(l.value))));let o=new RegExp(`^(\\s*?)${y}(.*)`,"gmis"),c=i.default.replace(`${l.value}`,o,(d,p,u,g)=>g.trim()===""?`${p}(${u.trim()})
${g.trim()}`:`${p}(${u.trim()})
${g.trim()}
`);e=i.default.replace(e,l.value,re(c))}}catch{}}),e}async preserveEscapedBladeDirective(e){return i.default.replace(e,/@@\w*/gim,t=>this.storeEscapedBladeDirective(t))}async preserveBladeComment(e){return i.default.replace(e,/\{\{--(.*?)--\}\}/gs,t=>this.storeBladeComment(t))}preservePhpComment(e){return i.default.replace(e,/\/\*(?:[^*]|[\r\n]|(?:\*+(?:[^*\/]|[\r\n])))*\*+\//gi,t=>this.storePhpComment(t))}async preserveBladeBrace(e){return i.default.replace(e,/\{\{(.*?)\}\}/gs,(t,n)=>n===""?this.storeBladeBrace(n,n.length):/\S/.test(n)?this.storeBladeBrace(n.trim(),n.trim().length):this.storeBladeBrace(" ",1))}async preserveRawBladeBrace(e){return i.default.replace(e,/\{!!(.*?)!!\}/gs,(t,n)=>n===""?this.storeRawBladeBrace(n):/\S/.test(n)?this.storeRawBladeBrace(n.trim()):this.storeRawBladeBrace(" "))}async preserveConditions(e){let t=new RegExp(`(${ue.join("|")})(\\s*?)${y}`,"gi");return i.default.replace(e,t,(n,r,s,a)=>`${r}${s}(${this.storeConditions(a)})`)}preserveUnbalancedDirective(e){let t=new RegExp(`((${U.join("|")})(?!.*?\\2)(?:\\s|\\(.*?\\)))+(?=.*?@endif)`,"gis"),n=i.default.replace(e,t,(r,s)=>`${this.storeUnbalancedDirective(s)}`);return t.test(n)&&(n=this.preserveUnbalancedDirective(n)),n}async preserveRawPhpTags(e){return i.default.replace(e,/<\?php(.*?)\?>/gms,t=>this.storeRawPhpTags(t))}async preserveNonnativeScripts(e){return i.default.replace(e,/<script[^>]*?type=(["'])(?!text\/javascript)[^\1]*?\1[^>]*?>.*?<\/script>/gis,t=>this.storeNonnativeScripts(t))}async preserveScripts(e){return i.default.replace(e,/<script.*?>.*?<\/script>/gis,t=>this.storeScripts(t))}async preserveHtmlAttributes(e){return i.default.replace(e,/(?<=<[\w]*?[\s].*?)[\w\-\_\:]+?=(["']).*?(?<!\\)\1(?=.*?(?<!=)>)/gms,t=>`${this.storeHtmlAttribute(t)}`)}async sortHtmlAttributes(e){var n;let t=(n=this.options.sortHtmlAttributes)!=null?n:"none";if(!i.default.isEmpty(t)&&t!=="none"){let r=this.options.customHtmlAttributesOrder;if(i.default.isArray(r))return(0,se.sortAttributes)(e,{order:t,customRegexes:r});let s=i.default.chain(r).split(",").map(i.default.trim).value();return(0,se.sortAttributes)(e,{order:t,customRegexes:s})}return e}async preserveShorthandBinding(e){return i.default.replace(e,/(?<=<(?!livewire:)[^<]*?(\s|x-bind)):{1}(?<!=>)[\w\-_.]*?=(["'])(?!=>)[^]*?\2(?=[^>]*?\/*?>)/gim,t=>`${this.storeShorthandBinding(t)}`)}async preserveComponentAttribute(e){return i.default.replace(e,/(?<=<(x-|livewire:)[^<]*?\s):{1,2}(?<!=>)[\w\-_.]*?=(["'])(?!=>)[^]*?\2(?=[^>]*?\/*?>)/gim,t=>`${this.storeComponentAttribute(t)}`)}async formatXData(e){return i.default.replace(e,/(\s*)x-data="(.*?)"(\s*)/gs,(t,n,r,s)=>`${n}x-data="${this.storeXData(r)}"${s}`)}async formatXInit(e){return i.default.replace(e,/(\s*)x-init="(.*?)"(\s*)/gs,(t,n,r,s)=>`${n}x-init="${this.storeXInit(r)}"${s}`)}preserveStringLiteralInPhp(e){return i.default.replace(e,/(\"([^\\]|\\.)*?\"|\'([^\\]|\\.)*?\')/gm,t=>`${this.storeStringLiteralInPhp(t)}`)}storeIgnoredLines(e){return this.getIgnoredLinePlaceholder(this.ignoredLines.push(e)-1)}storeCurlyBraceForJS(e){return this.getCurlyBraceForJSPlaceholder(this.curlyBracesWithJSs.push(e)-1)}storeRawBlock(e){return this.getRawPlaceholder(this.rawBlocks.push(e)-1)}storeInlineDirective(e){return this.getInlinePlaceholder(this.inlineDirectives.push(e)-1,e.length)}storeConditions(e){return this.getConditionPlaceholder(this.conditions.push(e)-1)}storeInlinePhpDirective(e){return this.getInlinePhpPlaceholder(this.inlinePhpDirectives.push(e)-1)}storeRawPropsBlock(e){return this.getRawPropsPlaceholder(this.rawPropsBlocks.push(e)-1)}storeBladeDirective(e){return this.getBladeDirectivePlaceholder(this.bladeDirectives.push(e)-1)}storeBladeDirectiveInStyle(e){return this.getBladeDirectiveInStylePlaceholder((this.bladeDirectivesInStyle.push(e)-1).toString())}storeEscapedBladeDirective(e){return this.getEscapedBladeDirectivePlaceholder((this.escapedBladeDirectives.push(e)-1).toString())}storeBladeComment(e){return this.getBladeCommentPlaceholder(this.bladeComments.push(e)-1)}storePhpComment(e){return this.getPhpCommentPlaceholder((this.phpComments.push(e)-1).toString())}storeHtmlTag(e){return this.getHtmlTagPlaceholder((this.htmlTags.push(e)-1).toString())}storeInlineCustomDirective(e){return this.getInlineCustomDirectivePlaceholder((this.customDirectives.push(e)-1).toString())}storeBeginCustomDirective(e){return this.getBeginCustomDirectivePlaceholder((this.customDirectives.push(e)-1).toString())}storeElseCustomDirective(e){return this.getElseCustomDirectivePlaceholder((this.customDirectives.push(e)-1).toString())}storeEndCustomDirective(e){return this.getEndCustomDirectivePlaceholder((this.customDirectives.push(e)-1).toString())}storeUnbalancedDirective(e){return this.getUnbalancedDirectivePlaceholder((this.unbalancedDirectives.push(e)-1).toString())}storeBladeBrace(e,t){let n=this.bladeBraces.push(e)-1,r="{{ }}";return this.getBladeBracePlaceholder(n,t+r.length)}storeRawBladeBrace(e){let t=this.rawBladeBraces.push(e)-1;return Line truncated
${r}
?>`,this.defaultPhpFormatOption).trim():r.split(`
`).length>1?r=L(`<?php${r}?>`,this.defaultPhpFormatOption).trimRight(`
`):r=`<?php${r}?>`,i.default.replace(r,/^(\s*)?<\?php(.*?)\?>/gms,(c,d,p)=>{if(this.isInline(r))return`@php${p}@endphp`;let u=this.preserveStringLiteralInPhp(p);u=this.preservePhpComment(u);let g=this.indentRawBlock(l,u);return g=this.restorePhpComment(g),`@php${this.restoreStringLiteralInPhp(g)}@endphp`})})}async restoreRawPropsBlock(e){let t=this.getRawPropsPlaceholder("(\\d+)");return i.default.replace(e,new RegExp(t,"gms"),(n,r)=>`@props(${C(this.rawPropsBlocks[r],{...this.defaultPhpFormatOption,printWidth:F}).trimRight()})`)}isInline(e){return i.default.split(e,`
`).length===1}isMultilineStatement(e){return L(`<?php${e}?>`,this.defaultPhpFormatOption).trimRight().split(`
`).length>1}indentRawBlock(e,t){if(this.isInline(t))return`${e.indent}${t}`;let r=e.amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:(r+1)*this.indentSize),a=this.indentCharacter.repeat(r<0?0:r*this.indentSize),l=t.split(`
`);return i.default.chain(l).map((o,c)=>c===0?o.trim():c===l.length-1?a+o:s+o).join(`
`).value()}indentBladeDirectiveBlock(e,t){if(i.default.isEmpty(e.indent))return t;if(this.isInline(t))return`${e.indent}${t}`;let r=e.amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:r*this.indentSize),a=this.indentCharacter.repeat(r<0?0:r*this.indentSize),l=t.split(`
`);return i.default.chain(l).map((o,c)=>c===l.length-1?a+o:s+o).value().join(`
`)}indentScriptBlock(e,t){if(i.default.isEmpty(e.indent))return t;if(this.isInline(t))return`${t}`;let r=e.amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:r*this.indentSize),a=this.indentCharacter.repeat(r<0?0:r*this.indentSize),o=i.default.replace(t,/`.*?`/gs,d=>this.storeTemplatingString(d)).split(`
`),c=i.default.chain(o).map((d,p)=>p===0?d:p===o.length-1?a+d:i.default.isEmpty(d)?d:s+d).value().join(`
`);return this.restoreTemplatingString(`${c}`)}indentRawPhpBlock(e,t){if(i.default.isEmpty(e.indent))return t;if(this.isInline(t))return`${t}`;let r=e.amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:r*this.indentSize),a=t.split(`
`);return i.default.chain(a).map((l,o)=>o===0?l.trim():s+l).value().join(`
`)}indentComponentAttribute(e,t){if(i.default.isEmpty(e))return t;if(this.isInline(t))return`${t}`;if(this.isInline(t)&&/\S/.test(e))return`${t}`;let r=(0,w.default)(e).amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:r*this.indentSize),a=t.split(`
`);return i.default.chain(a).map((l,o)=>o===0?l.trim():s+l).value().join(`
`)}indentPhpComment(e,t){if(i.default.isEmpty(e.indent))return t;if(this.isInline(t))return`${t}`;let r=e.amount/this.indentSize,s=this.indentCharacter.repeat(r<0?0:r*this.indentSize),a=t.split(`
`),l=!1;return i.default.chain(a).map((o,c)=>c===0?o.trim():o.trim().startsWith("*")?o.trim().endsWith("*/")&&l?o:s+o:(l=!0,o)).join(`
`).value()}restoreBladeDirectivesInStyles(e){return i.default.replace(e,/(?<=<style[^>]*?(?<!=)>)(.*?)(?=<\/style>)/gis,t=>{let n=t,r=new RegExp(`${this.getBladeDirectiveInStylePlaceholder("(\\d+)")} {\\s*?/\\* inline_directive \\*/\\s*?}`,"gmi");n=i.default.replace(n,r,(o,c)=>this.bladeDirectivesInStyle[c]);let s=new RegExp(`}\\s*?${this.getBladeDirectiveInStylePlaceholder("(\\d+)")} {\\s*?/\\*else\\*/`,"gmi");n=i.default.replace(n,s,(o,c)=>`${this.bladeDirectivesInStyle[c]}`);let a=new RegExp(`${this.getBladeDirectiveInStylePlaceholder("(\\d+)")} {\\s*?/\\*start\\*/`,"gmi");n=i.default.replace(n,a,(o,c)=>`${this.bladeDirectivesInStyle[c]}`);let l=new RegExp(`}\\s*?/\\* ${this.getBladeDirectiveInStylePlaceholder("(\\d+)")} \\*/`,"gmi");return n=i.default.replace(n,l,(o,c)=>`${this.bladeDirectivesInStyle[c]}`),n})}restoreBladeDirectivesInScripts(e){let t=new RegExp(`${this.getBladeDirectivePlaceholder("(\\d+)")}`,"gm"),n=i.default.replace(e,t,(r,s)=>{var c;let a=this.getBladeDirectivePlaceholder(s.toString()),l=(c=e.match(new RegExp(`^(.*?)${a}`,"gmi")))!=null?c:[""],o=(0,w.default)(l[0]);return this.indentBladeDirectiveBlock(o,this.bladeDirectives[s])});return n=i.default.replace(n,/(?<=<script[^>]*?(?<!=)>)(.*?)(?=<\/script>)/gis,r=>{let s=r;return s=i.default.replace(s,new RegExp(`if \\( \\/\\*(?:(?:${this.getBladeDirectiveInScriptPlaceholder("(\\d+)")}).*?)\\*\\/ \\) \\{`,"gis"),(a,l)=>`${this.directivesInScript[l]}`),s=i.default.replace(s,new RegExp(`} \\/\\* (?:${this.getBladeDirectiveInScriptPlaceholder("(\\d+)")}) \\*\\/ {(\\s*?\\(___directive_condition_\\d+___\\))?`,"gim"),(a,l,o)=>i.default.isUndefined(o)?`${this.directivesInScript[l].trim()}`:`${this.directivesInScript[l].trim()} ${(o!=null?o:"").trim()}`),s=i.default.replace(s,new RegExp(`} \\/\\*(?:${this.getBladeDirectiveInScriptPlaceholder("(\\d+)")})\\*\\/`,"gis"),(a,l)=>`${this.directivesInScript[l]}`),s=i.default.replace(s,new RegExp(`${this.getRawPlaceholder("(\\d+)")}`,"gm"),(a,l)=>{var u;let o=this.rawBlocks[l],c=this.getRawPlaceholder(l.toString()),d=(u=e.match(new RegExp(`^(.*?)${c}`,"gmi")))!=null?u:[""],p=(0,w.default)(d[0]);return this.isInline(o)&&this.isMultilineStatement(o)?o=L(`<?php
${o}
?>`,this.defaultPhpFormatOption).trim():o.split(`
`).length>1?o=L(`<?php${o}?>`,this.defaultPhpFormatOption).trim():o=`<?php${o}?>`,i.default.replace(o,/^(\s*)?<\?php(.*?)\?>/gms,(g,x,b)=>{if(this.isInline(o))return`@php${b}@endphp`;let I=this.preserveStringLiteralInPhp(b),et=this.indentRawBlock(p,I);return`@php${this.restoreStringLiteralInPhp(et)}@endphp`})}),s=i.default.replace(s,/(?<=[\S]+)(\s*?)\/\*\*\*script_placeholder\*\*\*\/(\s)?/gim,(a,l,o)=>{if(o!==void 0)return o;let c=l!=null?l:"",d=o!=null?o:"";return c+d}),s}),t.test(n)&&(n=this.restoreBladeDirectivesInScripts(n)),n}async formatPreservedBladeDirectives(e){return Fe.default.map(e,async t=>{let n=await this.formatAsHtml(t);return(await this.formatAsBlade(n)).trimRight(`
`)})}restoreBladeComment(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getBladeCommentPlaceholder("(\\d+)")}`,"gms"),(n,r)=>this.bladeComments[r].replace(/{{--(?=\S)/g,"{{-- ").replace(/(?<=\S)--}}/g," --}}")))}restorePhpComment(e){return i.default.replace(e,new RegExp(`${this.getPhpCommentPlaceholder("(\\d+)")};{0,1}`,"gms"),(t,n)=>{var o;let r=this.getPhpCommentPlaceholder(n.toString()),s=(o=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?o:[""],a=(0,w.default)(s[0]),l=Ee(this.phpComments[n]);return this.indentPhpComment(a,l)})}async restoreEscapedBladeDirective(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getEscapedBladeDirectivePlaceholder("(\\d+)")}`,"gms"),(n,r)=>this.escapedBladeDirectives[r]))}restoreBladeBrace(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getBladeBracePlaceholder("(\\d+)")}`,"gm"),(n,r)=>{var c;let s=this.getBladeBracePlaceholder(r.toString()),a=(c=e.match(new RegExp(`^(.*?)${s}`,"gmi")))!=null?c:[""],l=(0,w.default)(a[0]),o=this.bladeBraces[r];return o.trim()===""?`{{${o}}}`:this.isInline(o)?`{{ ${C(o,{...this.defaultPhpFormatOption,trailingCommaPHP:!1,printWidth:F}).replace(/([\n\s]*)->([\n\s]*)/gs,"->").split(`
`).map(d=>d.trim()).join("").trimRight(`
`)} }}`:`{{ ${this.indentRawPhpBlock(l,C(o,this.defaultPhpFormatOption).replace(/([\n\s]*)->([\n\s]*)/gs,"->").trim().trimRight(`
`))} }}`}))}restoreRawBladeBrace(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getRawBladeBracePlaceholder("(\\d+)")}`,"gms"),(n,r)=>{var c;let s=this.getRawBladeBracePlaceholder(r),a=(c=e.match(new RegExp(`^(.*?)${s}`,"gmi")))!=null?c:[""],l=(0,w.default)(a[0]),o=this.rawBladeBraces[r];return o.trim()===""?`{!!${o}!!}`:this.indentRawPhpBlock(l,`{!! ${C(o,this.defaultPhpFormatOption).replace(/([\n\s]*)->([\n\s]*)/gs,"->").trim()} !!}`)}))}restoreInlineDirective(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getInlinePlaceholder("(\\d+)")}`,"gms"),(n,r)=>this.inlineDirectives[r]))}restoreConditions(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getConditionPlaceholder("(\\d+)")}`,"gms"),(n,r)=>{var c;let s=this.getConditionPlaceholder(r),a=(c=e.match(new RegExp(`^(.*?)${s}`,"gmi")))!=null?c:[""],l=(0,w.default)(a[0]),o=this.conditions[r];return this.formatExpressionInsideBladeDirective(o,l)}))}restoreUnbalancedDirective(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,/@if \(unbalanced___(\d+)___\)/gms,(n,r)=>this.unbalancedDirectives[r]))}restoreInlinePhpDirective(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getInlinePhpPlaceholder("(\\d+)")}`,"gm"),(n,r)=>{var c;let s=this.inlinePhpDirectives[r],a=this.getInlinePhpPlaceholder(r),l=(c=e.match(new RegExp(`^(.*?)${a}`,"gmi")))!=null?c:[""],o=(0,w.default)(l[0]);return s.includes("@php")?`${C(s,{...this.defaultPhpFormatOption,printWidth:F}).replace(/([\n\s]*)->([\n\s]*)/gs,"->").trim().trimRight(`
`)}`:new RegExp(ne.join("|"),"gi").test(s)?i.default.replace(s,new RegExp(`(?<=@(${i.default.map(ne,p=>p.substring(1)).join("|")}).*?\\()(.*)(?=\\))`,"gis"),(p,u,g)=>{let x=this.wrapLineLength;return["button","class"].includes(u)&&(x=80),u==="include"&&(x=this.wrapLineLength-4-r.length-o.amount),this.formatExpressionInsideBladeDirective(g,o,x)}):`${C(s,{...this.defaultPhpFormatOption,printWidth:F}).trimEnd()}`}))}restoreRawPhpTags(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getRawPhpTagPlaceholder("(\\d+)")}`,"gms"),(n,r)=>{var s;try{let a=this.rawPhpTags[r],o=/(?<=<\?php\s*?)\/\*.*?\*\/(?=\s*?\?>)/gim.test(a)&&this.isInline(a),c=this.getRawPhpTagPlaceholder(r),d=(s=e.match(new RegExp(`^(.*?)${c}`,"gmi")))!=null?s:[""],p=(0,w.default)(d[0]);if(o)return a;let u=L(this.rawPhpTags[r],this.defaultPhpFormatOption).trim().trimRight(`
`);if(this.isInline(u))return u;let g=this.preservePhpComment(u);return p.indent&&(g=this.indentRawPhpBlock(p,g)),this.restorePhpComment(g)}catch{return`${this.rawPhpTags[r]}`}}))}restoreNonnativeScripts(e){return i.default.replace(e,new RegExp(`${this.getNonnativeScriptPlaceholder("(\\d+)")}`,"gmi"),(t,n)=>`${this.nonnativeScripts[n]}`)}restoreScripts(e){return new Promise(t=>t(e)).then(t=>i.default.replace(t,new RegExp(`${this.getScriptPlaceholder("(\\d+)")}`,"gim"),(n,r)=>{var p;let s=this.scripts[r],a=this.getScriptPlaceholder(r),l=(p=e.match(new RegExp(`^(.*?)${a}`,"gmi")))!=null?p:[""],o=(0,w.default)(l[0]),c=_(this.options).useTabs||!1,d={indent_size:_(this.options).indentSize||4,wrap_line_length:_(this.options).wrapLineLength||120,wrap_attributes:_(this.options).wrapAttributes||"auto",indent_with_tabs:c,end_with_newline:!1,templating:["php"]};return c?this.indentScriptBlock(o,i.default.replace(R.default.html_beautify(s,d),/\t/g," ".repeat(this.indentSize))):this.indentScriptBlock(o,R.default.html_beautify(s,d))}))}async restoreCustomDirective(e){return this.restoreInlineCustomDirective(e).then(t=>this.restoreBeginCustomDirective(t)).then(t=>this.restoreElseCustomDirective(t)).then(t=>this.restoreEndCustomDirective(t))}async restoreInlineCustomDirective(e){return i.default.replace(e,new RegExp(`${this.getInlineCustomDirectivePlaceholder("(\\d+)")}`,"gim"),(t,n)=>{var o;let r=this.getInlineCustomDirectivePlaceholder(n.toString()),s=(o=e.match(new RegExp(`^(.*?)${i.default.escapeRegExp(r)}`,"gmi")))!=null?o:[""],a=(0,w.default)(s[0]),l=`${this.customDirectives[n]}`;return i.default.replace(l,/(@[a-zA-z0-9\-_]+)(.*)/gis,(c,d,p)=>{try{let u=C(`func${p}`,{...this.defaultPhpFormatOption,printWidth:F}).replace(/([\n\s]*)->([\n\s]*)/gs,"->").replace(/,(\s*?\))$/gm,(g,x)=>x).trim().substring(4);return`${d}${this.indentComponentAttribute(a.indent,u)}`}catch{return`${c}`}})})}async restoreBeginCustomDirective(e){return i.default.replace(e,new RegExp(`@customdirective\\(___(\\d+)___\\)\\s*?(${y})*`,"gim"),(t,n)=>{var o;let r=this.getBeginCustomDirectivePlaceholder(n.toString()),s=(o=e.match(new RegExp(`^(.*?)${i.default.escapeRegExp(r)}`,"gmi")))!=null?o:[""],a=(0,w.default)(s[0]),l=`${this.customDirectives[n]}`;return i.default.replace(l,/(@[a-zA-z0-9\-_]+)(.*)/gis,(c,d,p)=>{try{let u=C(`func${p}`,{...this.defaultPhpFormatOption,trailingCommaPHP:!1}).replace(/([\n\s]*)->([\n\s]*)/gs,"->").trim().substring(4);return`${d}${this.indentComponentAttribute(a.indent,u)}`}catch{return`${c}`}})})}async restoreElseCustomDirective(e){return i.default.replace(e,/@else\(___(\d+)___\)/gim,(t,n)=>`${this.customDirectives[n]}`)}async restoreEndCustomDirective(e){return i.default.replace(e,/@endcustomdirective\(___(\d+)___\)/gim,(t,n)=>`${this.customDirectives[n]}`)}async restoreHtmlTags(e){return i.default.replace(e,new RegExp(`${this.getHtmlTagPlaceholder("(\\d+)")}`,"gim"),(t,n)=>{var p;let r=this.getHtmlTagPlaceholder(n.toString()),s=(p=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?p:[""],a=(0,w.default)(s[0]),l={indent_size:_(this.options).indentSize||4,wrap_line_length:_(this.options).wrapLineLength||120,wrap_attributes:_(this.options).wrapAttributes||"auto",end_with_newline:!1,templating:["php"]},o=this.htmlTags[n],c=i.default.first(o.match(/(<(textarea|pre).*?(?<!=)>)(?=.*?<\/\2>)/gis));if(c===void 0)return`${this.indentScriptBlock(a,R.default.html_beautify(o,l))}`;let d=o.substring(c.length,o.length);return`${this.indentScriptBlock(a,R.default.html_beautify(c,l))}${d}`})}restoreHtmlAttributes(e){return i.default.replace(e,new RegExp(`${this.getHtmlAttributePlaceholder("(\\d+)")}`,"gms"),(t,n)=>this.htmlAttributes[n])}restoreXData(e){return i.default.replace(e,new RegExp(`${this.getXDataPlaceholder("(\\d+)")}`,"gm"),(t,n)=>{var u;let r=this.getXDataPlaceholder(n.toString()),s=(u=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?u:[""],a=(0,w.default)(s[0]),l=this.formatJS(this.xData[n]).split(`
`),o=a.amount/(this.indentCharacter===" "?4:1),c=l[0],d=this.indentCharacter.repeat(o<0?0:o),p=l.map(g=>d+g);return p[0]=c,`${p.join(`
`)}`})}restoreXInit(e){return i.default.replace(e,new RegExp(`${this.getXInitPlaceholder("(\\d+)")}`,"gm"),(t,n)=>{var u;let r=this.getXInitPlaceholder(n.toString()),s=(u=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?u:[""],a=(0,w.default)(s[0]),l=this.formatJS(this.xInit[n]).split(`
`),o=a.amount/(this.indentCharacter===" "?4:1),c=l[0],d=this.indentCharacter.repeat(o<0?0:o),p=l.map(g=>d+g);return p[0]=c,`${p.join(`
`)}`})}restoreTemplatingString(e){return i.default.replace(e,new RegExp(`${this.getTemplatingStringPlaceholder("(\\d+)")}`,"gms"),(t,n)=>this.templatingStrings[n])}restoreStringLiteralInPhp(e){return i.default.replace(e,new RegExp(`${this.getStringLiteralInPhpPlaceholder("(\\d+)")}`,"gms"),(t,n)=>this.stringLiteralInPhp[n])}restoreComponentAttribute(e){return i.default.replace(e,new RegExp(`${this.getComponentAttributePlaceholder("(\\d+)")}`,"gim"),(t,n)=>{var c;let r=this.getComponentAttributePlaceholder(n),s=(c=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?c:[""],a=(0,w.default)(s[0]),l=this.componentAttributes[n],o=i.default.replace(l,/(:{1,2}.*?=)(["'])(.*?)(?=\2)/gis,(d,p,u,g)=>{if(g==="")return d;if(p.startsWith("::"))return`${p}${u}${R.default.js_beautify(g,{wrap_line_length:this.wrapLineLength-a.amount,brace_style:"preserve-inline"}).trim()}`;if(this.isInline(g))try{return`${p}${u}${C(g,{...this.defaultPhpFormatOption,printWidth:this.wrapLineLength-a.amount}).trimEnd()}`}catch{return`${p}${u}${g}`}return`${p}${u}${C(g,{...this.defaultPhpFormatOption,printWidth:this.wrapLineLength-a.amount}).trimEnd()}`});return`${this.indentComponentAttribute(a.indent,o)}`})}restoreShorthandBinding(e){return i.default.replace(e,new RegExp(`${this.getShorthandBindingPlaceholder("(\\d+)")}`,"gms"),(t,n)=>{var c;let r=this.getShorthandBindingPlaceholder(n),s=(c=e.match(new RegExp(`^(.*?)${r}`,"gmi")))!=null?c:[""],a=(0,w.default)(s[0]),l=this.shorthandBindings[n],o=i.default.replace(l,/(:{1,2}.*?=)(["'])(.*?)(?=\2)/gis,(d,p,u,g)=>{let x={wrap_line_length:this.wrapLineLength-a.amount,brace_style:"preserve-inline"};if(g==="")return d;if(this.isInline(g))try{return`${p}${u}${R.default.js_beautify(g,x).trimEnd()}`}catch{return`${p}${u}${g}`}return`${p}${u}${R.default.js_beautify(g,x).trimEnd()}`});return`${this.indentComponentAttribute(a.indent,o)}`})}async formatAsBlade(e){this.currentIndentLevel=0,this.shouldBeIndent=!1;let t=N(e),n=await new Z(this.vsctm,this.oniguruma);return n.createRegistry(e).loadGrammar("text.html.php.blade").then(a=>n.tokenizeLines(t,a)).then(a=>this.formatTokenizedLines(t,a)).catch(a=>{throw a})}formatTokenizedLines(e,t){this.result=[],this.stack=[];for(let n=0;n<e.length;n+=1){let r=e[n],s=t[n];this.processLine(s,r)}return this.result.join(this.endOfLine)}processLine(e,t){this.processTokenizeResult(e,t)}processKeyword(e){if(i.default.includes(T,e)){i.default.last(this.stack)==="@case"&&e==="@case"&&this.decrementIndentLevel(),e==="@case"&&(this.shouldBeIndent=!0),this.stack.push(e);return}if(i.default.includes(M,e)){if(e==="@break"){this.decrementIndentLevel(),this.stack.pop(),this.stack.push(e);return}if(i.default.last(this.stack)!=="@hassection"){this.stack.pop();return}}if(i.default.includes(de,e)&&(this.shouldBeIndent=!0,this.stack.push(e)),i.default.includes(te,e)&&i.default.includes(pe,i.default.last(this.stack))&&(this.decrementIndentLevel(),this.shouldBeIndent=!0),i.default.includes(P,e)&&(i.default.last(this.stack)==="@section"&&e==="@section"?(this.currentIndentLevel>0&&this.decrementIndentLevel(),this.shouldBeIndent=!0,this.stack.push(e)):(this.shouldBeIndent=!0,this.stack.push(e))),i.default.includes(E,e)){if(e==="@endswitch"&&i.default.last(this.stack)==="@default"){this.decrementIndentLevel(2),this.shouldBeIndent=!1;return}this.decrementIndentLevel(),this.shouldBeIndent=!1,this.stack.pop()}i.default.includes(D,e)&&(this.decrementIndentLevel(),this.shouldBeIndent=!0)}processToken(e,t){if(i.default.includes(e.scopes,"punctuation.definition.comment.begin.blade")&&(this.isInsideCommentBlock=!0),this.argumentCheck){let{count:n,inString:r,stack:s}=this.argumentCheck;if(!r&&t===")"){if(s.push(t),n[t]+=1,n["("]===n[t]){let a=s.join("");_e(a)>=this.argumentCheck.unindentOn&&(this.shouldBeIndent=!1),this.argumentCheck=!1}return}s.push(t),r===t?this.argumentCheck.inString=!1:!r&&(t==='"'||t==="'")&&(this.argumentCheck.inString=t),t==="("&&!r&&(n[t]+=1)}i.default.includes(e.scopes,"punctuation.definition.comment.end.blade")&&(this.isInsideCommentBlock=!1),(t==="{{--"||t.includes("{{--"))&&(this.isInsideCommentBlock=!0),(t==="--}}"||t.includes("--}}"))&&(this.isInsideCommentBlock=!1),i.default.includes(e.scopes,"keyword.blade")&&(this.isInsideCommentBlock||(this.processKeyword(t.toLowerCase()),i.default.includes(Object.keys(ee),t.toLowerCase())&&(this.argumentCheck={unindentOn:ee[t.toLowerCase()],stack:[],inString:!1,count:{"(":0,")":0}})))}processTokenizeResult(e,t){if(this.shouldBeIndent&&(this.incrementIndentLevel(),this.shouldBeIndent=!1),me(e,t)){this.insertFormattedLineToResult(t);return}for(let n=0;n<e.tokens.length;n+=1){let r=e.tokens[n],s=t.substring(r.startIndex,r.endIndex).trim();this.processToken(r,s)}this.insertFormattedLineToResult(t)}insertFormattedLineToResult(e){let n=(0,w.default)(e).amount+this.indentSize*this.currentIndentLevel,r=this.indentCharacter.repeat(n<0?0:n)+e.trim();e.length===0&&this.result.push(e),e.length!==0&&r.length>0&&this.result.push(r),r!==e&&this.diffs.Line truncated
)`).replace(/,[\n\s]*?\)/gs,")").replace(/,(\s*?\))$/gm,(l,o)=>o).trim();return this.options.useTabs&&(a=i.default.replace(a,/(?<=^ *) {4}/gm," ".repeat(this.indentSize))),a=a.replace(/func\((.*)\)/gis,(l,o)=>o),this.isInline(a.trim())&&(a=a.trim()),this.indentRawPhpBlock(t,a)}formatJS(e){let t=e,n={js:[],entangle:[]};return Object.keys(n).forEach(r=>{t=t.replace(new RegExp(`@${r}\\((?:[^)(]+|\\((?:[^)(]+|\\([^)(]*\\))*\\))*\\)`,"gs"),s=>{let a=n[r].push(s)-1;return this.getPlaceholder(r,a,s.length)})}),t=R.default.js_beautify(t,{brace_style:"preserve-inline"}),Object.keys(n).forEach(r=>{t=t.replace(new RegExp(this.getPlaceholder(r,"_*(\\d+)"),"gms"),(s,a)=>n[r][a])}),t}};var Te=m(require("path")),Oe=m(require("fs")),je=m(require("ajv")),He=m(require("find-config")),yt=new je.default,Ae=[".bladeformatterrc.json",".bladeformatterrc"];function We(h){for(let e=0;e<Ae.length;e+=1){let t=(0,He.default)(Ae[e],{cwd:Te.default.dirname(h),home:!1});if(t)return t}return null}async function ze(h){if(h===null)return;let e=JSON.parse((await Oe.default.promises.readFile(h)).toString()),t={type:"object",properties:{indentSize:{type:"integer",nullable:!0},wrapLineLength:{type:"integer",nullable:!0},wrapAttributes:{type:"string",enum:["auto","force","force-aligned","force-expand-multiline","aligned-multiple","preserve","preserve-aligned"],nullable:!0},endWithNewline:{type:"boolean",nullable:!0},endOfLine:{type:"string",enum:["LF","CRLF"],nullable:!0},useTabs:{type:"boolean",nullable:!0},sortTailwindcssClasses:{type:"boolean",nullable:!0},tailwindcssConfigPath:{type:"string",nullable:!0},sortHtmlAttributes:{type:"string",enum:["none","alphabetical","code-guide","idiomatic","vuejs","custom"],nullable:!0},customHtmlAttributesOrder:{type:"array",nullable:!0,items:{type:"string"},default:[]},noMultipleEmptyLines:{type:"boolean",nullable:!0},noPhpSyntaxCheck:{type:"boolean",nullable:!0}},additionalProperties:!0},n=yt.compile(t);if(!n(e))throw n;return e}var J=class extends Error{};var k=class{constructor(e={},t=[]){var n;this.currentTargetPath=".",this.paths=t,this.options=e,this.targetFiles=[],this.errors=[],this.diffs=[],this.outputs=[],this.formattedFiles=[],this.ignoreFile="",this.fulFillFiles=[],this.targetFiles=[],this.runtimeConfigPath=(n=e.runtimeConfigPath)!=null?n:null,this.runtimeConfigCache={}}async format(e,t={}){this.options=this.options||t;let n=B.default.resolve(f.default.cwd(),"target");return await this.readIgnoreFile(n),await this.findTailwindConfig(n),await this.readRuntimeConfig(n),new j(this.options).formatContent(e).catch(r=>{throw new J(r)})}async formatFromCLI(){try{this.printPreamble(),await this.readIgnoreFile(f.default.cwd()),await this.processPaths(),this.printResults()}catch{}}fileExists(e){return H.default.promises.access(e,H.default.constants.F_OK).then(()=>!0).catch(()=>!1)}async readIgnoreFile(e){let t=".bladeignore",n,r=B.default.dirname(e);if(this.options.ignoreFilePath?n=this.options.ignoreFilePath:n=(0,oe.default)(t,{cwd:r}),!!n)try{this.ignoreFile=(await H.default.promises.readFile(n)).toString()}catch{}}async findTailwindConfig(e){if(!this.options.sortTailwindcssClasses)return;let t="tailwind.config.js",n;if(this.options.tailwindcssConfigPath)if(this.runtimeConfigPath){let r=B.default.dirname(this.runtimeConfigPath);n=B.default.resolve(r,this.options.tailwindcssConfigPath)}else B.default.isAbsolute(this.options.tailwindcssConfigPath)?n=B.default.resolve(this.options.tailwindcssConfigPath):n=B.default.resolve(this.options.tailwindcssConfigPath);else{let r=B.default.dirname(e);n=(0,oe.default)(t,{cwd:r})}n&&(this.options.tailwindcssConfigPath=n)}async readRuntimeConfig(e){var n,r;v.default.isEmpty(this.runtimeConfigCache)&&(this.options=v.default.merge(this.options,this.runtimeConfigCache));let t;if(this.options.runtimeConfigPath?t=this.options.runtimeConfigPath:t=We(e),!v.default.isNull(t)){this.runtimeConfigPath=t;try{let s=await ze(t);this.options=v.default.merge(this.options,s),this.runtimeConfigCache=this.options,this.options.sortTailwindcssClasses&&await this.findTailwindConfig(e)}catch(s){s instanceof SyntaxError&&(f.default.stdout.write($.default.red.bold(`
Blade Formatter JSON Syntax Error:
`)),f.default.stdout.write(ae.default.format(s)),f.default.exit(1)),f.default.stdout.write($.default.red.bold(`
Blade Formatter Config Error: ${B.default.basename(t)}
`)),f.default.stdout.write(`\`${s.errors[0].instancePath.replace("/","")}\` ${s.errors[0].message}
`),(n=s.errors[0].params)!=null&&n.allowedValues&&console.log((r=s.errors[0].params)==null?void 0:r.allowedValues),f.default.exit(1)}}}async processPaths(){await Promise.all(v.default.map(this.paths,async e=>this.processPath(e)))}async processPath(e){await k.globFiles(e).then(t=>v.default.map(t,n=>B.default.relative(".",n))).then(t=>this.filterFiles(t)).then(this.fulFillFiles).then(t=>this.formatFiles(t))}static globFiles(e){return new Promise((t,n)=>{(0,Je.default)(e,(r,s)=>r?n(r):t(s))})}async filterFiles(e){if(this.ignoreFile==="")return e;let t=/^\.\.*/,n=v.default.filter(e,a=>t.test(B.default.relative(".",a))),r=v.default.xor(e,n),s=(0,Ne.default)().add(this.ignoreFile).filter(r);return v.default.concat(n,s)}static fulFillFiles(e){return this.targetFiles.push(e),Promise.resolve(e)}async formatFiles(e){await Promise.all(v.default.map(e,async t=>this.formatFile(t)))}async formatFile(e){await this.findTailwindConfig(e),await this.readRuntimeConfig(e),await q(e).then(t=>Promise.resolve(t.toString("utf-8"))).then(t=>new j(this.options).formatContent(t)).then(t=>this.checkFormatted(e,t)).then(t=>this.writeToFile(e,t)).catch(t=>{this.handleError(e,t)})}async checkFormatted(e,t){this.printFormattedOutput(e,t);let n=H.default.readFileSync(e,"utf-8"),r=N(n),s=N(t),a=ve(e,r,s);return this.diffs.push(a),this.outputs.push(t),a.length>0&&((this.options.progress||this.options.write)&&f.default.stdout.write($.default.green("F")),this.options.checkFormatted&&(f.default.stdout.write(`${e}
`),f.default.exitCode=1),this.formattedFiles.push(e)),a.length===0&&(this.options.progress||this.options.write)&&f.default.stdout.write($.default.green(".")),Promise.resolve(t)}printFormattedOutput(e,t){this.options.write||this.options.checkFormatted||(f.default.stdout.write(`${t}`),v.default.last(this.paths)===e||v.default.last(this.targetFiles)===e)||(this.paths.length>1||this.targetFiles.length>1)&&f.default.stdout.write(`
`)}writeToFile(e,t){this.options.write&&(this.options.checkFormatted||t.length===0||v.default.isNull(t)||v.default.isEmpty(t)||H.default.writeFile(e,t,n=>{n&&(f.default.stdout.write(`${$.default.red(n.message)}
`),f.default.exit(1))}))}handleError(e,t){(this.options.progress||this.options.write)&&f.default.stdout.write($.default.red("E")),f.default.exitCode=1,this.errors.push({path:e,message:t.message,error:t})}printPreamble(){this.options.checkFormatted&&f.default.stdout.write(`Check formatting...
`)}async printResults(){this.printDescription(),this.printDifferences(),this.printFormattedFiles(),this.printErrors()}printDescription(){if(!this.options.write)return;let e=`
`;f.default.stdout.write(e),f.default.stdout.write($.default.bold.green(`Fixed: F
`)),f.default.stdout.write($.default.bold.red(`Errors: E
`)),f.default.stdout.write($.default.bold("Not Changed: ")+$.default.bold.green(`.
`))}printFormattedFiles(){if(this.formattedFiles.length===0){this.options.checkFormatted&&f.default.stdout.write($.default.bold(`
All matched files are formatted!
`));return}if(!this.options.write){this.options.checkFormatted&&f.default.stdout.write(`
Above file(s) are formattable. Forgot to run formatter? Use ${$.default.bold("--write")} option to overwrite.
`);return}f.default.stdout.write($.default.bold(`
Formatted Files:
`)),v.default.each(this.formattedFiles,e=>f.default.stdout.write(`${$.default.bold(e)}
`))}printDifferences(){if(this.options.diff){if(f.default.stdout.write($.default.bold(`
Differences:
`)),v.default.filter(this.diffs,e=>e.length>0).length===0){f.default.stdout.write((0,$.default)(`No changes found.
`));return}v.default.each(this.diffs,e=>we(e))}}printErrors(){v.default.isEmpty(this.errors)||(f.default.stdout.write($.default.red.bold(`
Errors:
`)),v.default.each(this.errors,e=>f.default.stdout.write(`${ae.default.format(e)}
`)))}};var le="blade-formatter";var Me="1.32.12";async function Ye(){let h=await(0,Ue.default)((0,Ze.hideBin)(process.argv)).usage(`${W.default.green(le)} ${Me}
An opinionated blade template formatter for Laravel.
${W.default.yellow("Usage:")} $0 [options] [file glob | ...]`).wrap(null).example('$0 "resources/views/**/*.blade.php" --write',"Format all files in views directory").option("check-formatted",{alias:"c",type:"boolean",description:"Only checks files are formatted or not",default:!1}).option("write",{alias:"w",type:"boolean",description:"Write to file",default:!1}).option("diff",{alias:"d",type:"boolean",description:"Show diffs",default:!1}).option("end-with-newline",{alias:"e",type:"boolean",description:"End output with newline",default:!0}).option("end-of-line",{type:"string",description:"End of line character(s). [LF|CRLF]",default:Qe.default.EOL===`\r
`?"CRLF":"LF"}).option("indent-size",{alias:"i",type:"integer",description:"Indentation size",default:4}).option("wrap-line-length",{alias:"wrap",type:"integer",description:"The length of line wrap size",default:120}).option("wrap-attributes",{alias:"wrap-atts",type:"string",description:`The way to wrap attributes.
[auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned]`,default:"auto"}).option("sort-tailwindcss-classes",{alias:"sort-classes",type:"boolean",description:"Sort tailwindcss classes",default:!1}).option("tailwindcss-config-path",{alias:["tailwindcssConfigPath"],type:"string",description:"Specify path of tailwind config",default:null}).option("sort-html-attributes",{alias:"sort-attributes",type:"string",choices:["none","alphabetical","code-guide","idiomatic","vuejs","custom"],description:"Sort HTML attributes.",default:"none",defaultDescription:"none"}).option("custom-html-attributes-order",{type:"string",description:"Comma separated custom HTML attributes order. To enable this you must specify sort html attributes option as `custom`. You can use regex for attribute names.",default:null}).option("no-multiple-empty-lines",{type:"boolean",description:"Merge multiple blank lines into a single blank line",default:!1}).option("multiple-empty-lines",{type:"boolean",description:"this is a workaround for combine strict && boolean option",hidden:!0,default:!0}).option("no-php-syntax-check",{type:"boolean",description:"Disable PHP sytnax checking",default:!1}).option("php-syntax-check",{type:"boolean",description:"this is a workaround for combine strict && boolean option",hidden:!0,default:!0}).option("progress",{alias:"p",type:"boolean",description:"Print progress",default:!1}).option("stdin",{type:"boolean",description:"format code provided on <STDIN>",default:!1}).option("config",{alias:["runtimeConfigPath"],type:"string",description:"Use this configuration, overriding .bladeformatterrc config options if present",default:null}).option("ignore-path",{alias:["ignoreFilePath"],type:"string",description:"Specify path of ignore file",default:null}).help("h").alias("h","help").strictOptions().fail(function(r,s){if(s)throw s;process.stdout.write(`${W.default.red("error: ")}${r}
`),process.stdout.write(`${W.default.yellow("Usage: ")} ${le} [options] [file glob | ...]
`),process.stdout.write(`For more information try ${W.default.green("--help")}
`),process.exit(1)}).epilog(`Copyright Shuhei Hayashibara 2022
For more information, see https://github.com/shufo/blade-formatter`),e=await qe.promises.readFile(require.resolve("vscode-oniguruma/release/onig.wasm"));await(0,Ke.loadWASM)(e.buffer);let t=Ge.default.chain(h.argv).set("noMultipleEmptyLines",!h.argv.multipleEmptyLines).set("noPhpSyntaxCheck",!h.argv.phpSyntaxCheck).value();if(h.argv.stdin){await process.stdin.pipe((0,Ve.default)({encoding:"string"},r=>new k(t).format(r).then(s=>{s!==void 0&&process.stdout.write(s)}).catch(s=>{process.stdout.write(`${s.toString()}
`),process.exit(1)})));return}if(h.argv._.length===0){h.showHelp();return}await new k(t,h.argv._).formatFromCLI()}0&&(module.exports={});
//# sourceMappingURL=cli-bundle.js.map
@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../src/cli.ts", "../src/main.ts", "../src/formatter.ts", "../src/vsctm.ts", "../src/util.ts", "../src/indent.ts", "../src/regex.ts", "../src/comment.ts", "../src/space.ts", "../src/runtimeConfig.ts", "../src/errors/formatError.ts", "../package.json"],
"sourcesContent": ["import yargs from 'yargs';\nimport concat from 'concat-stream';\nimport { loadWASM } from 'vscode-oniguruma';\nimport chalk from 'chalk';\nimport _ from 'lodash';\n\nimport os from 'os';\nimport { promises as fs } from 'fs';\n\nimport { hideBin } from 'yargs/helpers';\nimport { BladeFormatter } from './main';\nimport { name, version } from '../package.json';\n\nexport default async function cli() {\n // @ts-ignore\n const parsed = await yargs(hideBin(process.argv))\n .usage(\n `${chalk.green(name)} ${version}\\nAn opinionated blade template formatter for Laravel. \\n\\n ${chalk.yellow(\n `Usage:`,\n )} $0 [options] [file glob | ...]`,\n )\n .wrap(null)\n .example('$0 \"resources/views/**/*.blade.php\" --write', 'Format all files in views directory')\n .option('check-formatted', {\n alias: 'c',\n type: 'boolean',\n description: 'Only checks files are formatted or not',\n default: false,\n })\n .option('write', {\n alias: 'w',\n type: 'boolean',\n description: 'Write to file',\n default: false,\n })\n .option('diff', {\n alias: 'd',\n type: 'boolean',\n description: 'Show diffs',\n default: false,\n })\n .option('end-with-newline', {\n alias: 'e',\n type: 'boolean',\n description: 'End output with newline',\n default: true,\n })\n .option('end-of-line', {\n type: 'string',\n description: 'End of line character(s). [LF|CRLF]',\n default: os.EOL === '\\r\\n' ? 'CRLF' : 'LF',\n })\n .option('indent-size', {\n alias: 'i',\n type: 'integer',\n description: 'Indentation size',\n default: 4,\n })\n .option('wrap-line-length', {\n alias: 'wrap',\n type: 'integer',\n description: 'The length of line wrap size',\n default: 120,\n })\n .option('wrap-attributes', {\n alias: 'wrap-atts',\n type: 'string',\n description: `The way to wrap attributes.\\n[auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned]`,\n default: 'auto',\n })\n .option('sort-tailwindcss-classes', {\n alias: 'sort-classes',\n type: 'boolean',\n description: 'Sort tailwindcss classes',\n default: false,\n })\n .option('tailwindcss-config-path', {\n alias: ['tailwindcssConfigPath'],\n type: 'string',\n description: 'Specify path of tailwind config',\n default: null,\n })\n .option('sort-html-attributes', {\n alias: 'sort-attributes',\n type: 'string',\n choices: ['none', 'alphabetical', 'code-guide', 'idiomatic', 'vuejs', 'custom'],\n description: 'Sort HTML attributes.',\n default: 'none',\n defaultDescription: 'none',\n })\n .option('custom-html-attributes-order', {\n type: 'string',\n description:\n 'Comma separated custom HTML attributes order. To enable this you must specify sort html attributes option as `custom`. You can use regex for attribute names.',\n default: null,\n })\n .option('no-multiple-empty-lines', {\n type: 'boolean',\n description: 'Merge multiple blank lines into a single blank line',\n default: false,\n })\n .option('multiple-empty-lines', {\n type: 'boolean',\n description: 'this is a workaround for combine strict && boolean option',\n hidden: true,\n default: true,\n })\n .option('no-php-syntax-check', {\n type: 'boolean',\n description: 'Disable PHP sytnax checking',\n default: false,\n })\n .option('php-syntax-check', {\n type: 'boolean',\n description: 'this is a workaround for combine strict && boolean option',\n hidden: true,\n default: true,\n })\n .option('progress', {\n alias: 'p',\n type: 'boolean',\n description: 'Print progress',\n default: false,\n })\n .option('stdin', {\n type: 'boolean',\n description: 'format code provided on <STDIN>',\n default: false,\n })\n .option('config', {\n alias: ['runtimeConfigPath'],\n type: 'string',\n description: 'Use this configuration, overriding .bladeformatterrc config options if present',\n default: null,\n })\n .option('ignore-path', {\n alias: ['ignoreFilePath'],\n type: 'string',\n description: 'Specify path of ignore file',\n default: null,\n })\n .help('h')\n .alias('h', 'help')\n .strictOptions()\n .fail(function (msg, err) {\n if (err) throw err; // preserve stack\n process.stdout.write(`${chalk.red(`error: `)}${msg}\\n\\n`);\n process.stdout.write(`${chalk.yellow(`Usage: `)} ${name} [options] [file glob | ...]\\n\\n`);\n process.stdout.write(`For more information try ${chalk.green(`--help`)}\\n`);\n process.exit(1);\n })\n .epilog(`Copyright Shuhei Hayashibara 2022\\nFor more information, see https://github.com/shufo/blade-formatter`);Line truncated
"mappings": "ykBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,IAAA,IAAAI,GAAkB,oBAClBC,GAAmB,4BACnBC,GAAyB,4BACzBC,EAAkB,oBAClBC,GAAc,qBAEdC,GAAe,iBACfC,GAA+B,cAE/BC,GAAwB,yBCTxB,IAAAC,GAAmB,qBAEnBC,EAAqB,mBACrBC,EAAe,iBACfC,EAAoB,sBACpBC,EAAkB,oBAClBC,GAAiB,mBACjBC,GAAqB,mBACrBC,EAAc,qBACdC,GAAuB,0BCPvB,IAAAC,EAA4C,0BAC5CC,EAAc,qBACdC,GAAgC,8BAChCC,EAAyB,4BACzBC,GAAkB,oBAClBC,GAAoB,sBACpBC,EAA4B,2CAC5BC,GAA+B,iCCT/B,IAAAC,GAA+B,cAC/BC,GAAc,qBACdC,GAAiC,+BACjCC,GAAiB,mBCFjB,IAAAC,EAAc,qBACdC,GAAe,iBACfC,GAAe,iBACfC,EAAkB,oBAClBC,EAAqB,kCAErBA,EAAsB,8CACtBC,GAAyB,4BCRzB,IAAAC,EAAc,qBAEDC,EAAkB,IAElBC,EAAoB,CAC/B,SACA,YACA,QACA,QACA,UACA,UACA,YACA,eACA,WACA,QACA,SACA,SACA,SACA,SACA,cACA,eACA,UACA,UACA,OACA,QACA,WACA,cACA,eACA,cACA,iBACA,MACA,cACA,OACA,SACA,QACA,WACA,OACA,WACA,OACA,aACA,WACA,kBACF,EAEaC,GAAiC,EAAAC,QAAE,IAAIF,EAAoBG,GAAUA,EAAM,UAAU,CAAC,CAAC,EAEvFC,EAAkB,CAC7B,YACA,eACA,WACA,WACA,aACA,aACA,eACA,QACA,QACA,kBACA,cACA,WACA,YACA,UACA,aACA,YACA,YACA,YACA,iBACA,kBACA,aACA,aACA,UACA,WACA,cACA,iBACA,kBACA,iBACA,oBACA,SACA,iBACA,UACA,YACA,WACA,cACA,cACA,UACA,UACA,gBACA,cACA,qBACF,EAEaC,EAAmB,CAC9B,WACA,UACA,cACA,cACA,WACA,QACA,sBACF,EAGaC,GAAgC,CAC3C,WAAY,EACZ,QAAS,EACT,WAAY,EACZ,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 truncated
"names": ["cli_exports", "__export", "cli", "__toCommonJS", "import_yargs", "import_concat_stream", "import_vscode_oniguruma", "import_chalk", "import_lodash", "import_os", "import_fs", "import_helpers", "import_ignore", "import_path", "import_fs", "import_process", "import_chalk", "import_glob", "import_util", "import_lodash", "import_find_config", "import_js_beautify", "import_lodash", "vscodeTmModule", "import_detect_indent", "import_aigle", "import_xregexp", "import_tailwindcss_class_sorter", "import_html_attribute_sorter", "import_fs", "import_lodash", "vscodeOniguruma", "import_path", "import_lodash", "import_fs", "import_os", "import_chalk", "import_standalone", "import_detect_indent", "import_lodash", "directivePrefix", "indentStartTokens", "indentStartTokensWithoutPrefix", "_", "token", "indentEndTokens", "indentElseTokens", "optionalStartWithoutEndTokens", "tokenForIndentStartOrElseTokens", "indentStartOrElseTokens", "indentStartAndEndTokens", "phpKeywordStartTokens", "phpKeywordEndTokens", "inlinePhpDirectives", "inlineFunctionTokens", "conditionalTokens", "unbalancedStartTokens", "cssAtRuleTokens", "hasStartAndEndToken", "tokenizeLineResult", "originalLine", "tokenStruct", "nestedParenthesisRegex", "optional", "obj", "chain", "_", "readFile", "path", "resolve", "reject", "fs", "error", "data", "splitByLines", "content", "printWidthForInline", "defaultFormatPhpOption", "formatStringAsPhp", "params", "options", "prettier", "phpPlugin", "formatRawStringAsPhp", "match", "p1", "getArgumentsCount", "expression", "code", "ast", "printDiffs", "diffs", "_", "diff", "chalk", "generateDiff", "path", "originalLines", "formattedLines", "originalLine", "index", "prettifyPhpContentWithUnescapedTags", "content", "directives", "indentStartTokens", "directiveRegexes", "nestedParenthesisRegex", "resolve", "res", "match", "p1", "p2", "p3", "formatStringAsPhp", "match2", "j1", "j2", "j3", "formatAsPhp", "content", "prettifyPhpContentWithUnescapedTags", "preserveDirectives", "content", "startTokens", "_", "phpKeywordStartTokens", "endTokens", "phpKeywordEndTokens", "resolve", "res", "regex", "nestedParenthesisRegex", "match", "p1", "p2", "p3", "revertDirectives", "content", "resolve", "res", "_", "match", "p1", "p2", "escapeTags", "checkResult", "formatted", "escapeReplacementString", "string", "getEndOfLine", "endOfLine", "os", "VscodeTextmate", "vsctm", "oniguruma", "_a", "vscodeOniguruma", "wasm", "fs", "scopeName", "readFile", "path", "content", "sources", "str", "splitedLines", "grammar", "_", "line", "splitByLines", "content", "isCommentedLine", "line", "isMultiline", "lines", "addPrefixToLine", "formatPhpComment", "comment", "nonCommentLineExists", "row", "trimmedLine", "import_lodash", "adjustSpaces", "content", "directivesRequiredSpace", "_", "nestedParenthesisRegex", "_matched", "p1", "p2", "Formatter", "options", "optional", "vscodeTmModule", "getEndOfLine", "content", "resolve", "target", "formatAsPhp", "adjustSpaces", "formattedResult", "checkResult", "data", "promise", "preserveDirectives", "preserved", "beautify", "revertDirectives", "_", "_match", "p1", "p2", "match", "contentUnformatted", "negativeLookAhead", "indentStartTokens", "indentEndTokens", "indentElseTokens", "inlineNegativeLookAhead", "inlineFunctionTokens", "phpKeywordStartTokens", "unbalancedStartTokens", "cssAtRuleTokens", "inlineRegex", "nestedParenthesisRegex", "regex", "formatted", "p3", "p4", "p5", "p6", "p7", "result", "beginStr", "elseStr", "directivePrefix", "indentStartTokensWithoutPrefix", "replaced", "targetTokens", "inlineFunctionDirectives", "inlineFunctionRegex", "endTokens", "matched", "formatRawStringAsPhp", "printWidthForInline", "indentStartOrElseTokens", "_matched", "inside", "customStartRegex", "startRegex", "elseRegex", "endRegex", "endStr", "unbalancedConditions", "unbalancedEchos", "directive", "directives", "x", "recursivelyMatched", "xregexp", "escapeReplacementString", "innerRegex", "conditionalTokens", "_a", "strategy", "regexes", "customRegexes", "value", "length", "index", "brace", "replace", "gap", "attribute", "template", "rawBlock", "placeholder", "matchedLine", "indent", "detectIndent", "formatStringAsPhp", "_q1", "q2", "indented", "indentLevel", "prefix", "prefixForEnd", "lines", "line", "prefixSpaces", "withoutCommentLine", "group1", "group2", "Aigle", "formattedAsHtml", "res", "formatPhpComment", "bladeBrace", "inlinePhpDirectives", "token", "match2", "wrapLength", "inlinedComment", "script", "useTabs", "_m", "openingTag", "restofTag", "firstLine", "offsettedLines", "beautifyOpts", "splitedLines", "splitByLines", "vsctmModule", "VscodeTextmate", "grammar", "tokenizedLines", "err", "i", "originalLine", "tokenizeLineResult", "phpKeywordEndTokens", "indentStartAndEndTokens", "tokenForIndentStartOrElseTokens", "tokenStruct", "count", "inString", "stack", "expression", "getArgumentsCount", "optionalStartWithoutEndTokens", "hasStartAndEndToken", "j", "whitespaces", "formattedLine", "level", "matchedExpressLine truncated
}
@@ -0,0 +1,11 @@
/**
* Formats php comment
*
* @param comment
* @returns string
*/
export declare function formatPhpComment(comment: string): string;
declare const _default: {
formatPhpComment: typeof formatPhpComment;
};
export default _default;
@@ -0,0 +1,2 @@
export default class FormatError extends Error {
}
@@ -0,0 +1,216 @@
import detectIndent from 'detect-indent';
import { FormatterOption, CLIOption, BladeFormatterOption } from './main';
import * as util from './util';
export default class Formatter {
argumentCheck: any;
bladeBraces: any;
bladeComments: any;
bladeDirectives: any;
htmlAttributes: Array<string>;
currentIndentLevel: number;
diffs: any;
indentCharacter: any;
indentSize: any;
inlineDirectives: any;
conditions: any;
inlinePhpDirectives: any;
isInsideCommentBlock: any;
oniguruma: any;
options: FormatterOption & CLIOption;
rawBladeBraces: any;
ignoredLines: any;
curlyBracesWithJSs: any;
rawBlocks: any;
rawPhpTags: any;
rawPropsBlocks: any;
result: any;
nonnativeScripts: Array<string>;
scripts: any;
xData: any;
xInit: any;
htmlTags: Array<string>;
shouldBeIndent: any;
stack: any;
templatingStrings: any;
stringLiteralInPhp: Array<string>;
shorthandBindings: Array<string>;
componentAttributes: Array<string>;
customDirectives: Array<string>;
directivesInScript: Array<string>;
unbalancedDirectives: Array<string>;
escapedBladeDirectives: Array<string>;
phpComments: Array<string>;
vsctm: any;
wrapAttributes: any;
wrapLineLength: any;
defaultPhpFormatOption: util.FormatPhpOption;
endOfLine: string;
bladeDirectivesInStyle: Array<string>;
constructor(options: BladeFormatterOption);
formatContent(content: any): Promise<any>;
formatAsHtml(data: any): Promise<any>;
sortTailwindcssClasses(content: any): Promise<any>;
preserveIgnoredLines(content: any): Promise<any>;
preserveCurlyBraceForJS(content: any): Promise<any>;
preservePhpBlock(content: any): Promise<any>;
preservePropsBlock(content: any): Promise<any>;
preserveRawPhpBlock(content: any): Promise<any>;
preserveHtmlTags(content: string): Promise<any>;
/**
* preserve custom directives
* @param content
* @returns
*/
preserveCustomDirective(content: string): string;
preserveInlineDirective(content: string): string;
preserveInlinePhpDirective(content: any): Promise<any>;
preserveBladeDirectivesInScripts(content: any): any;
preserveBladeDirectivesInStyles(content: string): any;
/**
*
* @param content string between <script>~</script>
* @returns string
*/
preserveCustomDirectiveInScript(content: string): string;
/**
* Recursively insert line break before and after directives
* @param content string
* @returns
*/
breakLineBeforeAndAfterDirective(content: string): string;
preserveEscapedBladeDirective(content: string): Promise<any>;
preserveBladeComment(content: any): Promise<any>;
preservePhpComment(content: string): any;
preserveBladeBrace(content: any): Promise<any>;
preserveRawBladeBrace(content: any): Promise<any>;
preserveConditions(content: any): Promise<any>;
/**
* preserve unbalanced directive like @hasSection
*/
preserveUnbalancedDirective(content: any): string;
preserveRawPhpTags(content: any): Promise<any>;
preserveNonnativeScripts(content: string): Promise<any>;
preserveScripts(content: any): Promise<any>;
preserveHtmlAttributes(content: any): Promise<any>;
sortHtmlAttributes(content: string): Promise<string>;
preserveShorthandBinding(content: string): Promise<any>;
preserveComponentAttribute(content: string): Promise<any>;
formatXData(content: any): Promise<any>;
formatXInit(content: any): Promise<any>;
preserveStringLiteralInPhp(content: any): any;
storeIgnoredLines(value: any): any;
storeCurlyBraceForJS(value: any): any;
storeRawBlock(value: any): any;
storeInlineDirective(value: any): any;
storeConditions(value: any): any;
storeInlinePhpDirective(value: any): any;
storeRawPropsBlock(value: any): any;
storeBladeDirective(value: any): any;
storeBladeDirectiveInStyle(value: string): any;
storeEscapedBladeDirective(value: string): any;
storeBladeComment(value: any): any;
storePhpComment(value: string): any;
storeHtmlTag(value: string): any;
storeInlineCustomDirective(value: string): any;
storeBeginCustomDirective(value: string): any;
storeElseCustomDirective(value: string): any;
storeEndCustomDirective(value: string): any;
storeUnbalancedDirective(value: string): any;
storeBladeBrace(value: any, length: any): any;
storeRawBladeBrace(value: any): any;
storeRawPhpTags(value: any): any;
storeNonnativeScripts(value: string): any;
storeScripts(value: any): any;
storeHtmlAttribute(value: string): any;
storeShorthandBinding(value: any): any;
storeComponentAttribute(value: any): any;
storeXData(value: any): any;
storeXInit(value: any): any;
storeTemplatingString(value: any): any;
storeStringLiteralInPhp(value: any): any;
storeBladeDirectiveInScript(value: string): any;
getIgnoredLinePlaceholder(replace: any): any;
getCurlyBraceForJSPlaceholder(replace: any): any;
getRawPlaceholder(replace: any): any;
getInlinePlaceholder(replace: any, length?: number): any;
getConditionPlaceholder(replace: any): any;
getInlinePhpPlaceholder(replace: any): any;
getRawPropsPlaceholder(replace: any): any;
getBladeDirectivePlaceholder(replace: any): any;
getBladeDirectiveInStylePlaceholder(replace: string): any;
getEscapedBladeDirectivePlaceholder(replace: string): any;
getBladeCommentPlaceholder(replace: any): any;
getPhpCommentPlaceholder(replace: string): any;
getBladeBracePlaceholder(replace: any, length?: number): any;
getRawBladeBracePlaceholder(replace: any): any;
getRawPhpTagPlaceholder(replace: any): any;
getNonnativeScriptPlaceholder(replace: string): any;
getScriptPlaceholder(replace: any): any;
getHtmlTagPlaceholder(replace: string): any;
getInlineCustomDirectivePlaceholder(replace: string): any;
getBeginCustomDirectivePlaceholder(replace: string): any;
getElseCustomDirectivePlaceholder(replace: string): any;
getEndCustomDirectivePlaceholder(replace: string): any;
getUnbalancedDirectivePlaceholder(replace: string): any;
getHtmlAttributePlaceholder(replace: string, length: any): any;
getShorthandBindingPlaceholder(replace: string, length?: any): any;
getComponentAttributePlaceholder(replace: string): any;
getXInitPlaceholder(replace: any): any;
getPlaceholder(attribute: string, replace: any, length?: any): any;
getXDataPlaceholder(replace: any): any;
getTemplatingStringPlaceholder(replace: any): any;
getStringLiteralInPhpPlaceholder(replace: any): any;
getBladeDirectiveInScriptPlaceholder(replace: any): any;
restoreIgnoredLines(content: any): any;
restoreCurlyBraceForJS(content: any): any;
restorePhpBlock(content: any): Promise<any>;
restoreRawPhpBlock(content: any): Promise<any>;
restoreRawPropsBlock(content: any): Promise<any>;
isInline(content: any): boolean;
isMultilineStatement(rawBlock: any): boolean;
indentRawBlock(indent: detectIndent.Indent, content: any): any;
indentBladeDirectiveBlock(indent: detectIndent.Indent, content: any): any;
indentScriptBlock(indent: detectIndent.Indent, content: any): any;
indentRawPhpBlock(indent: detectIndent.Indent, content: any): any;
indentComponentAttribute(prefix: string, content: string): any;
indentPhpComment(indent: detectIndent.Indent, content: string): any;
restoreBladeDirectivesInStyles(content: string): any;
restoreBladeDirectivesInScripts(content: any): any;
formatPreservedBladeDirectives(directives: any): Promise<any[]>;
restoreBladeComment(content: any): Promise<any>;
restorePhpComment(content: string): any;
restoreEscapedBladeDirective(content: any): Promise<any>;
restoreBladeBrace(content: any): Promise<any>;
restoreRawBladeBrace(content: any): Promise<any>;
restoreInlineDirective(content: any): Promise<any>;
restoreConditions(content: any): Promise<any>;
restoreUnbalancedDirective(content: any): Promise<any>;
restoreInlinePhpDirective(content: any): Promise<any>;
restoreRawPhpTags(content: any): Promise<any>;
restoreNonnativeScripts(content: string): any;
restoreScripts(content: any): Promise<any>;
restoreCustomDirective(content: string): Promise<any>;
restoreInlineCustomDirective(content: string): Promise<any>;
restoreBeginCustomDirective(content: string): Promise<any>;
restoreElseCustomDirective(content: string): Promise<any>;
restoreEndCustomDirective(content: string): Promise<any>;
restoreHtmlTags(content: any): Promise<any>;
restoreHtmlAttributes(content: string): any;
restoreXData(content: any): any;
restoreXInit(content: any): any;
restoreTemplatingString(content: any): any;
restoreStringLiteralInPhp(content: any): any;
restoreComponentAttribute(content: string): string;
restoreShorthandBinding(content: any): any;
formatAsBlade(content: any): Promise<any>;
formatTokenizedLines(splitedLines: any, tokenizedLines: any): any;
processLine(tokenizeLineResult: any, originalLine: any): void;
processKeyword(token: any): void;
processToken(tokenStruct: any, token: any): void;
processTokenizeResult(tokenizeLineResult: any, originalLine: any): void;
insertFormattedLineToResult(originalLine: any): void;
incrementIndentLevel(level?: number): void;
decrementIndentLevel(level?: number): void;
formatExpressionInsideBladeDirective(matchedExpression: string, indent: detectIndent.Indent, wrapLength?: number | undefined): any;
formatJS(jsCode: string): string;
}
@@ -0,0 +1,22 @@
export declare const directivePrefix = "@";
export declare const indentStartTokens: string[];
export declare const indentStartTokensWithoutPrefix: any;
export declare const indentEndTokens: string[];
export declare const indentElseTokens: string[];
export declare const optionalStartWithoutEndTokens: {
'@section': number;
'@push': number;
'@prepend': number;
'@slot': number;
};
export declare const tokenForIndentStartOrElseTokens: string[];
export declare const indentStartOrElseTokens: string[];
export declare const indentStartAndEndTokens: string[];
export declare const phpKeywordStartTokens: string[];
export declare const phpKeywordEndTokens: string[];
export declare const inlinePhpDirectives: string[];
export declare const inlineFunctionTokens: string[];
export declare const conditionalTokens: string[];
export declare const unbalancedStartTokens: string[];
export declare const cssAtRuleTokens: string[];
export declare function hasStartAndEndToken(tokenizeLineResult: any, originalLine: any): boolean;
@@ -0,0 +1,67 @@
import { Config as TailwindConfig } from 'tailwindcss/types/config';
import Formatter from './formatter';
import { EndOfLine, RuntimeConfig, SortHtmlAttributes, WrapAttributes } from './runtimeConfig';
export type CLIOption = {
write?: boolean;
diff?: boolean;
checkFormatted?: boolean;
progress?: boolean;
ignoreFilePath?: string;
runtimeConfigPath?: string;
};
export type FormatterOption = {
indentSize?: number;
wrapLineLength?: number;
wrapAttributes?: WrapAttributes;
endWithNewline?: boolean;
endOfLine?: EndOfLine;
useTabs?: boolean;
sortTailwindcssClasses?: true;
tailwindcssConfigPath?: string;
tailwindcssConfig?: TailwindConfig;
sortHtmlAttributes?: SortHtmlAttributes;
customHtmlAttributesOrder?: string[] | string;
noMultipleEmptyLines?: boolean;
noPhpSyntaxCheck?: boolean;
};
export type BladeFormatterOption = CLIOption & FormatterOption;
declare class BladeFormatter {
diffs: any;
errors: any;
formattedFiles: any;
ignoreFile: any;
options: FormatterOption & CLIOption;
outputs: any;
currentTargetPath: string;
paths: any;
targetFiles: any;
fulFillFiles: any;
static targetFiles: any;
runtimeConfigPath: string | null;
runtimeConfigCache: RuntimeConfig;
constructor(options?: BladeFormatterOption, paths?: any);
format(content: any, opts?: BladeFormatterOption): Promise<any>;
formatFromCLI(): Promise<void>;
fileExists(filepath: string): any;
readIgnoreFile(filePath: string): Promise<void>;
findTailwindConfig(filePath: string): Promise<void>;
readRuntimeConfig(filePath: string): Promise<RuntimeConfig | undefined>;
processPaths(): Promise<void>;
processPath(path: any): Promise<void>;
static globFiles(path: any): Promise<unknown>;
filterFiles(paths: any): Promise<any>;
static fulFillFiles(paths: any): Promise<any>;
formatFiles(paths: any): Promise<void>;
formatFile(path: any): Promise<void>;
checkFormatted(path: any, formatted: any): Promise<any>;
printFormattedOutput(path: any, formatted: any): void;
writeToFile(path: any, content: any): void;
handleError(path: any, error: any): void;
printPreamble(): void;
printResults(): Promise<void>;
printDescription(): void;
printFormattedFiles(): void;
printDifferences(): void;
printErrors(): void;
}
export { BladeFormatter, Formatter };
@@ -0,0 +1 @@
export declare const nestedParenthesisRegex = "\\(((?:[^)(]+|\\((?:[^)(]+|\\((?:[^)(]+|\\((?:[^)(]+|\\([^)(]*\\))*\\))*\\))*\\))*)\\)?";
@@ -0,0 +1,19 @@
export type WrapAttributes = 'auto' | 'force' | 'force-aligned' | 'force-expand-multiline' | 'aligned-multiple' | 'preserve' | 'preserve-aligned';
export type SortHtmlAttributes = 'none' | 'alphabetical' | 'code-guide' | 'idiomatic' | 'vuejs' | 'custom';
export type EndOfLine = 'LF' | 'CRLF';
export interface RuntimeConfig {
indentSize?: number;
wrapLineLength?: number;
wrapAttributes?: WrapAttributes;
endWithNewline?: boolean;
endOfLine?: EndOfLine;
useTabs?: boolean;
sortTailwindcssClasses?: boolean;
tailwindcssConfigPath?: string;
sortHtmlAttributes?: SortHtmlAttributes;
customHtmlAttributesOrder?: string[] | string;
noMultipleEmptyLines?: boolean;
noPhpSyntaxCheck?: boolean;
}
export declare function findRuntimeConfig(filePath: string): string | null;
export declare function readRuntimeConfig(filePath: string | null): Promise<RuntimeConfig | undefined>;
@@ -0,0 +1,6 @@
/**
* Adjust spaces in blade directives
* @param content
* @returns
*/
export declare function adjustSpaces(content: string): string;
@@ -0,0 +1,35 @@
import { EndOfLine } from './runtimeConfig';
export declare const optional: (obj: any) => any;
export declare function readFile(path: any): Promise<unknown>;
export declare function splitByLines(content: any): any;
export type FormatPhpOption = {
noPhpSyntaxCheck?: boolean;
printWidth?: number;
trailingCommaPHP?: boolean;
phpVersion?: string;
singleQuote?: boolean;
};
export declare const printWidthForInline = 1000;
export declare function formatStringAsPhp(content: any, params?: FormatPhpOption): any;
export declare function formatRawStringAsPhp(content: string, params?: FormatPhpOption): any;
export declare function getArgumentsCount(expression: any): any;
export declare function normalizeIndentLevel(length: any): any;
export declare function printDiffs(diffs: any): Promise<any>;
export declare function generateDiff(path: any, originalLines: any, formattedLines: any): any;
export declare function prettifyPhpContentWithUnescapedTags(content: any): Promise<any>;
export declare function prettifyPhpContentWithEscapedTags(content: any): Promise<any>;
export declare function removeSemicolon(content: any): Promise<any>;
export declare function formatAsPhp(content: any): Promise<any>;
export declare function preserveOriginalPhpTagInHtml(content: any): Promise<any>;
export declare function revertOriginalPhpTagInHtml(content: any): Promise<any>;
export declare function indent(content: any, level: any, options: any): any;
export declare function unindent(directive: any, content: any, level: any, options: any): any;
export declare function preserveDirectives(content: any): Promise<any>;
export declare function preserveDirectivesInTag(content: any): Promise<unknown>;
export declare function revertDirectives(content: any): Promise<any>;
export declare function revertDirectivesInTag(content: any): Promise<any>;
export declare function printDescription(): void;
export declare function checkResult(formatted: any): any;
export declare function escapeReplacementString(string: string): string;
export declare function debugLog(...content: any): any;
export declare function getEndOfLine(endOfLine?: EndOfLine): string;
@@ -0,0 +1,14 @@
export declare class VscodeTextmate {
oniguruma: any;
registry: any;
vsctm: any;
initCalled: any;
constructor(vsctm: any, oniguruma: any);
loadWasm(): Promise<void>;
createRegistry(): any;
tokenizeLines(splitedLines: any, grammar: any): any;
}
declare const _default: {
VscodeTextmate: typeof VscodeTextmate;
};
export default _default;