/**
 * Minified by jsDelivr using Terser v5.48.0.
 * Original file: /npm/@marko/language-tools@2.8.1/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";const _importMetaUrl=require("url").pathToFileURL(__filename).href;var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(t,e)=>{for(var r in e)__defProp(t,r,{get:e[r],enumerable:!0})},__copyProps=(t,e,r,s)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let a of __getOwnPropNames(e))__hasOwnProp.call(t,a)||a===r||__defProp(t,a,{get:()=>e[a],enumerable:!(s=__getOwnPropDesc(e,a))||s.enumerable});return t},__toESM=(t,e,r)=>(r=null!=t?__create(__getProtoOf(t)):{},__copyProps(!e&&t&&t.__esModule?r:__defProp(r,"default",{value:t,enumerable:!0}),t)),__toCommonJS=t=>__copyProps(__defProp({},"__esModule",{value:!0}),t),index_exports={};__export(index_exports,{INTERNAL_API_EXPORT_NAME:()=>INTERNAL_API_EXPORT_NAME,INTERNAL_API_VAR:()=>INTERNAL_API_VAR,NodeType:()=>NodeType,Processors:()=>processors_exports,Project:()=>project_exports,ScriptLang:()=>ScriptLang,UNFINISHED:()=>UNFINISHED,extractCSSModule:()=>extractCSSModule,extractHTML:()=>extractHTML,extractScript:()=>extractScript,extractStyle:()=>extractStyle,getExt:()=>getExt,getLines:()=>import_htmljs_parser2.getLines,getLocation:()=>import_htmljs_parser2.getLocation,getPosition:()=>import_htmljs_parser2.getPosition,isControlFlowTag:()=>isControlFlowTag,isDefinitionFile:()=>isDefinitionFile,normalizePath:()=>normalizePath,parse:()=>parse,writeStyleModuleType:()=>writeStyleModuleType}),module.exports=__toCommonJS(index_exports);var import_htmljs_parser=require("htmljs-parser");function getNodeAtOffset(t,e){const r=childAtOffset(t,e.body);return r?visitChildNode(t,r):childAtOffset(t,e.static)||e}function visitChildNode(t,e){switch(e.type){case 1:case 16:return visitTag(t,e);default:return e}}function visitTag(t,e){const{body:r}=e;if(r&&t>e.open.end){const s=childAtOffset(t,r);return s?visitChildNode(t,s):e}const{attrs:s}=e;if(s&&t>s[0].start){const r=childAtOffset(t,s);return r?visitAttrNode(t,r):e}const{var:a}=e;if(a&&t>a.start&&t<=a.end)return a;const{args:n}=e;if(n&&t>n.start&&t<=n.end)return n;const{params:i}=e;if(i&&t>i.start&&t<=i.end)return i;const{typeParams:o}=e;if(o&&t>o.start&&t<=o.end)return o;const{typeArgs:c}=e;if(c&&t>c.start&&t<=c.end)return c;const{name:p}=e;return p&&t<=p.end?p:e}function visitAttrNode(t,e){if(10===e.type){const{value:r}=e;if(r&&t>r.start)return r;const{name:s}=e;if(t>s.start&&t<=s.end)return s}return e}function childAtOffset(t,e){let r=e.length-1;if(-1===r)return;let s=0;for(;s<r;){const a=1+s+r>>>1;e[a].start<t?s=a:r=a-1}const a=e[s];return t>a.start&&t<=a.end?a:void 0}var import_path=__toESM(require("path")),sepReg=/\//g,normalizePath="/"===import_path.default.sep?t=>t:t=>t.replace(sepReg,import_path.default.sep),import_htmljs_parser2=require("htmljs-parser"),styleBlockReg=/((?:\.[^\s\\/:*?"<>|({]+)*)\s*\{/y,UNFINISHED=Number.MAX_SAFE_INTEGER,NodeType=(t=>(t[t.Program=0]="Program",t[t.Tag=1]="Tag",t[t.OpenTagName=2]="OpenTagName",t[t.ShorthandId=3]="ShorthandId",t[t.ShorthandClassName=4]="ShorthandClassName",t[t.TagTypeArgs=5]="TagTypeArgs",t[t.TagTypeParams=6]="TagTypeParams",t[t.TagVar=7]="TagVar",t[t.TagArgs=8]="TagArgs",t[t.TagParams=9]="TagParams",t[t.AttrNamed=10]="AttrNamed",t[t.AttrName=11]="AttrName",t[t.AttrArgs=12]="AttrArgs",t[t.AttrValue=13]="AttrValue",t[t.AttrMethod=14]="AttrMethod",t[t.AttrSpread=15]="AttrSpread",t[t.AttrTag=16]="AttrTag",t[t.Text=17]="Text",t[t.CDATA=18]="CDATA",t[t.Doctype=19]="Doctype",t[t.Declaration=20]="Declaration",t[t.Comment=21]="Comment",t[t.Placeholder=22]="Placeholder",t[t.Scriptlet=23]="Scriptlet",t[t.Import=24]="Import",t[t.Export=25]="Export",t[t.Class=26]="Class",t[t.Style=27]="Style",t[t.Static=28]="Static",t))(NodeType||{});function parse(t,e="index.marko"){const r=new Builder(t),s=(0,import_htmljs_parser.createParser)(r);s.parse(t);const a=r.end();return{read:s.read,locationAt:s.locationAt,positionAt:s.positionAt,nodeAt:t=>getNodeAtOffset(t,a),filename:normalizePath(e),program:a,code:t}}var Builder=class{#t;#e;#r;#s;#a;#n;#i;constructor(t){this.#t=t,this.#e=this.#s={type:0,comments:void 0,parent:void 0,static:[],body:[],start:0,end:t.length}}end(){return this.#e.comments=this.#i,this.#e}onText(t){pushBody(this.#s,{type:17,parent:this.#s,start:t.start,end:t.end})}onCDATA(t){pushBody(this.#s,{type:18,parent:this.#s,value:t.value,start:t.start,end:t.end})}onDoctype(t){pushBody(this.#s,{type:19,parent:this.#s,value:t.value,start:t.start,end:t.end})}onDeclaration(t){pushBody(this.#s,{type:20,parent:this.#s,value:t.value,start:t.start,end:t.end})}onComment(t){const e={type:21,parent:this.#s,value:t.value,start:t.start,end:t.end};this.#i?this.#i.push(e):this.#i=[e]}onPlaceholder(t){pushBody(this.#s,{type:22,parent:this.#s,comments:this.#i,value:t.value,escape:t.escape,start:t.start,end:t.end}),this.#i=void 0}onScriptlet(t){pushBody(this.#s,{type:23,parent:this.#s,comments:this.#i,value:t.value,block:t.block,start:t.start,end:t.end}),this.#i=void 0}onOpenTagStart(t){this.#r=t}onOpenTagName(t){let e,r=!0,s=t.start,a=1,n=import_htmljs_parser.TagType.html;if(this.#r&&(r=!1,s=this.#r.start,this.#r=void 0),!t.expressions.length)switch(e=this.#t.slice(t.start,t.end)||"div"){case"style":{styleBlockReg.lastIndex=t.end;const e=styleBlockReg.exec(this.#t);if(e){const[{length:r},s]=e;return this.#e.static.push(this.#a={type:27,parent:this.#e,comments:this.#i,ext:s||void 0,value:{start:t.end+r,end:UNFINISHED},start:t.start,end:UNFINISHED}),this.#i=void 0,import_htmljs_parser.TagType.statement}n=import_htmljs_parser.TagType.text;break}case"class":return this.#e.static.push(this.#a={type:26,parent:this.#e,comments:this.#i,start:t.start,end:UNFINISHED}),this.#i=void 0,import_htmljs_parser.TagType.statement;case"export":return this.#e.static.push(this.#a={type:25,parent:this.#e,comments:this.#i,start:t.start,end:UNFINISHED}),this.#i=void 0,import_htmljs_parser.TagType.statement;case"import":return this.#e.static.push(this.#a={type:24,parent:this.#e,comments:this.#i,start:t.start,end:UNFINISHED}),this.#i=void 0,import_htmljs_parser.TagType.statement;case"server":case"client":case"static":return this.#e.static.push(this.#a={type:28,parent:this.#e,comments:this.#i,start:t.start,end:UNFINISHED}),this.#i=void 0,import_htmljs_parser.TagType.statement;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"link":case"meta":case"param":case"source":case"track":case"wbr":case"const":case"debug":case"id":case"let":case"lifecycle":case"log":case"return":n=import_htmljs_parser.TagType.void;break;case"html-comment":case"html-script":case"html-style":case"script":case"textarea":n=import_htmljs_parser.TagType.text;break;default:"@"===e[0]&&(a=16)}const i=this.#s,o=UNFINISHED,c={type:2,parent:void 0,quasis:t.quasis,expressions:t.expressions,start:t.start,end:t.end},p=this.#s=c.parent={type:a,parent:i,comments:this.#i,owner:void 0,concise:r,selfClosed:!1,hasAttrTags:!1,open:{start:s,end:o},nameText:e,name:c,var:void 0,args:void 0,params:void 0,shorthandId:void 0,shorthandClassNames:void 0,typeArgs:void 0,typeParams:void 0,attrs:void 0,bodyType:n,body:void 0,close:void 0,start:s,end:o};if(this.#i=void 0,16===p.type){let t=i,e=p.nameText.slice(1);for(;1===t.type&&isControlFlowTag(t);)t.hasAttrTags=!0,t=t.parent;switch(t.type){case 16:p.owner=t.owner,t.hasAttrTags=!0,e=`${t.nameText}:${e}`;break;case 1:p.owner=t,t.hasAttrTags=!0,e=`${t.nameText||"*"}:${e}`}p.nameText=e}return pushBody(i,p),this.#r=void 0,n}onTagShorthandId(t){const e=this.#s;e.shorthandId={type:3,parent:e,quasis:t.quasis,expressions:t.expressions,start:t.start,end:t.end}}onTagShorthandClass(t){const e=this.#s,r={type:4,parent:e,quasis:t.quasis,expressions:t.expressions,start:t.start,end:t.end};e.shorthandClassNames?e.shorthandClassNames.push(r):e.shorthandClassNames=[r]}onTagTypeArgs(t){const e=this.#s;e.typeArgs={type:5,parent:e,value:t.value,start:t.start,end:t.end}}onTagTypeParams(t){const e=this.#s;e.typeParams={type:6,parent:e,value:t.value,start:t.start,end:t.end}}onTagVar(t){const e=this.#s;e.var={type:7,parent:e,value:t.value,start:t.start,end:t.end}}onTagParams(t){const e=this.#s;e.params={type:9,parent:e,value:t.value,start:t.start,end:t.end}}onTagArgs(t){const e=this.#s;e.args={type:8,parent:e,value:t.value,start:t.start,end:t.end}}onAttrName(t){const e=this.#s,r={type:11,parent:void 0,start:t.start,end:t.end};pushAttr(e,this.#n=r.parent={type:10,parent:e,name:r,value:void 0,args:void 0,start:t.start,end:t.end})}onAttrArgs(t){const e=this.#n;e.args={type:12,parent:e,value:t.value,start:t.start,end:t.end},e.end=t.end}onAttrValue(t){const e=this.#n;e.value={type:13,parent:e,value:t.value,bound:t.bound,start:t.start,end:t.end},e.end=t.end}onAttrMethod(t){const e=this.#n;e.value={type:14,parent:e,typeParams:t.typeParams,params:t.params,body:t.body,async:t.async,start:t.start,end:t.end},e.end=t.end}onAttrSpread(t){const e=this.#s;pushAttr(e,{type:15,parent:e,value:t.value,start:t.start,end:t.end})}onOpenTagEnd(t){if(this.#a)27===this.#a.type&&(this.#a.value.end=t.end-1),this.#a.end=t.end,this.#a=void 0;else{this.#n=void 0;const e=this.#s;e.open.end=t.end,(t.selfClosed||e.bodyType===import_htmljs_parser.TagType.void)&&(this.#s=e.parent,e.end=t.end,e.selfClosed=t.selfClosed)}}onCloseTagStart(t){this.#s.close={start:t.start,end:UNFINISHED}}onCloseTagEnd(t){const e=this.#s;hasCloseTag(e)&&(e.close.end=t.end),e.end=t.end,this.#s=e.parent,this.#i=void 0}};function pushBody(t,e){t.body?t.body.push(e):t.body=[e]}function pushAttr(t,e){t.attrs?t.attrs.push(e):t.attrs=[e]}function hasCloseTag(t){return void 0!==t.close}function isControlFlowTag(t){switch(t.nameText){case"if":case"else":case"else-if":case"for":case"while":return!0;default:return!1}}var emptyView={offsetAt(t){},offsetsAt:t=>[],rangeAt(t,e){},tokensIn:(t,e)=>[]},Extractor=class{#o;#c="";#p=[];constructor(t){this.#o=t}write(t){return this.#c+=t,this}copy(t){if(t)if("string"==typeof t)this.#c+=t;else{let e,r=0;if(Array.isArray(t)){if(!t.length)return this;t.length>1&&(e=t.slice(1)),r=1,t=t[0]}const{code:s}=this.#o,a=Math.min(t.start,s.length),n=Math.max(a,Math.min(s.length,t.end))-a;this.#p.push({generatedStart:this.#c.length,sourceStart:a,generatedLength:n,sourceLength:n,mapping:r,linkedSources:e}),this.#c+=s.slice(a,a+n)}return this}anchor(t,e){if(t){const{code:r}=this.#o,s=Math.min(t.start,r.length),a=Math.max(s,Math.min(r.length,t.end))-s;this.#p.push({generatedStart:this.#c.length,sourceStart:s,generatedLength:0,sourceLength:a,mapping:e?3:2,linkedSources:void 0})}return this}end(){return new Extracted(this.#o,this.#c,this.#p)}},Extracted=class{constructor(t,e,r){this.parsed=t,this.#c=e,this.#p=r}parsed;#c;#p;#d;#h;#l;#u;hoverOffsetAt(t){for(const e of this.#p)if(3===e.mapping&&t>=e.sourceStart&&t<=e.sourceStart+e.sourceLength)return e.generatedStart}hoverLocationAt(t){for(const e of this.#p)if(3===e.mapping&&e.generatedStart===t)return this.parsed.locationAt({start:e.sourceStart,end:e.sourceStart+e.sourceLength})}get#m(){return this.#u||(this.#u=(0,import_htmljs_parser2.getLines)(this.#c))}get#g(){return this.#l??=this.#p.length?new GeneratedToSourceView(this.#p):emptyView}get#f(){if(this.#d)return this.#d;let t;for(const e of this.#p)0===e.mapping&&(t?t.push(e):t=[e]);return this.#d=t?new SourceToGeneratedView(t.sort(sortBySourceThenGenerated)):emptyView}get#y(){if(this.#h)return this.#h;let t=!1;for(const e of this.#p)if(1===e.mapping){t=!0;break}if(!t)return this.#h=this.#f;const e=[];for(const t of this.#p)if(!(t.mapping>=2)&&(e.push(t),t.linkedSources))for(const r of t.linkedSources){const s=Math.min(t.generatedLength,Math.max(0,r.end-r.start));e.push({generatedStart:t.generatedStart,sourceStart:r.start,generatedLength:s,sourceLength:s,mapping:1,linkedSources:void 0})}return this.#h=new SourceToGeneratedView(e.sort(sortBySourceThenGenerated))}sourceOffsetAt(t){return this.#g.offsetAt(t)}sourcePositionAt(t){const e=this.sourceOffsetAt(t);if(void 0!==e)return this.parsed.positionAt(e)}sourceRangeAt(t,e){return this.#g.rangeAt(t,e)}sourceLocationAt(t,e){const r=this.sourceRangeAt(t,e);if(r)return this.parsed.locationAt(r)}generatedOffsetAt(t){return this.#f.offsetAt(t)}generatedOffsetsAt(t){const e=this.#y.offsetsAt(t);return e.length>1?[...new Set(e)].sort(compareNumbers):e}sourceRangesAt(t,e){const r=[];for(const s of this.#g.tokensIn(t,e)){if(s.mapping>=2){pushUniqueRange(r,s.sourceStart,s.sourceStart+s.sourceLength);continue}const a=Math.max(0,t-s.generatedStart),n=Math.min(s.generatedLength,e-s.generatedStart);if(pushUniqueRange(r,s.sourceStart+a,s.sourceStart+n),s.linkedSources)for(const t of s.linkedSources){const e=Math.max(0,t.end-t.start);pushUniqueRange(r,t.start+Math.min(a,e),t.start+Math.min(n,e))}}return r}generatedPositionAt(t){const e=this.generatedOffsetAt(t);if(void 0!==e)return(0,import_htmljs_parser2.getPosition)(this.#m,e)}generatedRangeAt(t,e){return this.#f.rangeAt(t,e)}generatedLocationAt(t,e){const r=this.generatedRangeAt(t,e);if(r)return(0,import_htmljs_parser2.getLocation)(this.#m,r.start,r.end)}toString(){return this.#c}},TokenView=class{#p;#T;#x;constructor(t){this.#p=t,this.#T=t.length-1}get#w(){if(this.#x)return this.#x;const t=this.#p,e=new Array(t.length);let r=-1;for(let s=0;s<t.length;s++){const a=t[s],n=this.inStart(a)+this.inLength(a);n>r&&(r=n),e[s]=r}return this.#x=e}offsetAt(t){const e=this.#v(t);if(e)return this.outStart(e)+(t-this.inStart(e))}offsetsAt(t){const e=[],r=this.#p;let s=0,a=this.#T;for(;s<a;){const e=1+s+a>>>1;this.inStart(r[e])<=t?s=e:a=e-1}const n=this.#w;for(let a=s;a>=0&&n[a]>=t;a--){const s=r[a],n=t-this.inStart(s);n>=0&&n<=this.inLength(s)&&e.push(this.outStart(s)+n)}return e}tokensIn(t,e){const r=[],s=this.#p;if(!s.length)return r;const a=this.#w;let n=0,i=this.#T;if(a[i]<=t)return r;for(;n<i;){const e=n+i>>1;a[e]>t?i=e:n=e+1}for(let a=i;a<s.length;a++){const n=s[a],i=this.inStart(n);if(i>=e)break;i+this.inLength(n)>t&&r.push(n)}return r}rangeAt(t,e){if(t>=e)return this.#A(t);const r=this.#p,s=this.#w;let a=0,n=this.#T;if(s[n]<=t)return this.#A(t);for(;a<n;){const e=a+n>>1;s[e]>t?n=e:a=e+1}const i=r[n],o=this.inStart(i);if(o>=e)return this.#A(t);for(n=this.#T;a<n;){const t=1+a+n>>>1;this.inStart(r[t])<e?a=t:n=t-1}const c=r[a],p=this.outStart(i)+Math.max(0,t-o),d=this.outStart(c)+(c.mapping>=2?c.sourceLength:Math.min(this.inLength(c),e-this.inStart(c)));return d<p?{start:p,end:this.outStart(i)+(i.mapping>=2?i.sourceLength:Math.min(this.inLength(i),e-o))}:{start:p,end:d}}#A(t){const e=this.offsetAt(t);if(void 0!==e)return{start:e,end:e}}#v(t){const e=this.#p;let r=0,s=this.#T;for(;r<s;){const a=1+r+s>>>1;this.inStart(e[a])<=t?r=a:s=a-1}const a=this.#w;for(let s=r;s>=0&&a[s]>=t;s--){const r=e[s],a=t-this.inStart(r);if(a>=0&&a<=this.inLength(r))return r}}},GeneratedToSourceView=class extends TokenView{inStart(t){return t.generatedStart}inLength(t){return t.generatedLength}outStart(t){return t.sourceStart}},SourceToGeneratedView=class extends TokenView{inStart(t){return t.sourceStart}inLength(t){return t.sourceLength}outStart(t){return t.generatedStart}};function sortBySourceThenGenerated(t,e){const r=t.sourceStart-e.sourceStart;return 0===r?e.generatedStart-t.generatedStart:r}function compareNumbers(t,e){return t-e}function pushUniqueRange(t,e,r){for(const s of t)if(s.start===e&&s.end===r)return;t.push({start:e,end:r})}function findStyleSelectors(t,e=0){const r=new Map,s=[],a=[],n=[];let i=!1,o=null;const c=t.length;let p=0;const d=()=>!!a.length&&a[a.length-1];for(;p<c;){const h=t[p],l=t[p+1];if("/"===h&&"*"===l){for(p+=2;p<c&&("*"!==t[p]||"/"!==t[p+1]);)p++;p+=2}else if("/"===h&&"/"===l)for(p+=2;p<c&&"\n"!==t[p];)p++;else if('"'===h||"'"===h)p=skipString(t,p);else if(isInterpolationStart(h)&&"{"===l)p=skipBalanced(t,p+1);else if(":"===h){let e=p+1;for(;e<c&&isNameChar(t[e]);)e++;const r=t.slice(p+1,e).toLowerCase();if("global"===r||"local"===r){const s="global"===r;if("("===t[e])o=s;else{let r=e;for(;r<c&&isWhitespace(t[r]);)r++;"{"===t[r]?o=s:i=s}}p=e}else if("("===h)n.push(o??(n.length?n[n.length-1]:i)),o=null,p++;else if(")"===h)n.pop(),p++;else if("."===h||"#"===h){const e=p+1;if(isNameStart(t[e])){let r=e+1;for(;r<c&&isNameChar(t[r]);)r++;if(!isInterpolationStart(t[r])||"{"!==t[r+1]){(n.length?n[n.length-1]:i)||s.push({start:e,end:r})}p=r}else p++}else if("{"===h){for(const a of s){const s=t.slice(a.start,a.end),n={start:a.start+e,end:a.end+e},i=r.get(s);i?i.push(n):r.set(s,[n])}s.length=0,a.push(o??d()),o=null,n.length=0,i=d(),p++}else"}"===h?(s.length=0,a.pop(),n.length=0,i=d(),p++):";"===h?(s.length=0,n.length=0,i=d(),p++):","===h?(i=d(),p++):p++}return r}function skipString(t,e){const r=t[e],s=t.length;let a=e+1;for(;a<s;){const e=t[a];if("\\"===e)a+=2;else{if(e===r)return a+1;a++}}return a}function skipBalanced(t,e){const r=t.length;let s=0,a=e;for(;a<r;){const e=t[a];if("{"===e)s++;else if("}"===e&&0===--s)return a+1;a++}return a}function isNameStart(t){if(void 0===t)return!1;const e=t.charCodeAt(0);return e>=97&&e<=122||e>=65&&e<=90||"_"===t||"-"===t||e>=128}function isNameChar(t){const e=t.charCodeAt(0);return e>=48&&e<=57||isNameStart(t)}function isInterpolationStart(t){return"#"===t||"@"===t||"$"===t}function isWhitespace(t){return" "===t||"\t"===t||"\n"===t||"\r"===t||"\f"===t}function extractCSSModule(t){const{code:e,fileName:r}=t,s=new Extractor(createSource(e,r));return s.write("export default {} as unknown as "),writeStyleModuleType(s,findStyleSelectors(e)),s.write(";\n"),s.end()}function writeStyleModuleType(t,e){t.write("{");for(const r of e.values())t.write(' "').copy(r).write('": string;');t.write(" }")}function createSource(t,e){const r=(0,import_htmljs_parser2.getLines)(t);return{code:t,filename:normalizePath(e),positionAt:t=>(0,import_htmljs_parser2.getPosition)(r,t),locationAt:t=>(0,import_htmljs_parser2.getLocation)(r,t.start,t.end)}}var builtinTagsRegex=/^(?:a(?:(?:bbr|cronym|ddress|pplet|r(?:ea|ticle)|side|udio))?|b(?:(?:ase(?:font)?|d[io]|gsound|ig|l(?:ink|ockquote)|ody|r|utton))?|c(?:a(?:nvas|ption)|enter|ite|o(?:de|l(?:group)?|mmand|ntent))|d(?:ata(?:list)?|d|e(?:l|tails)|fn|i(?:alog|r|v)|l|t)|e(?:lement|m(?:bed)?)|f(?:i(?:eldset|g(?:caption|ure))|o(?:nt|oter|rm)|rame(?:set)?)|h(?:1|2|3|4|5|6|ead(?:er)?|group|r|tml)|i(?:(?:frame|m(?:age|g)|n(?:put|s)|sindex))?|k(?:bd|eygen)|l(?:abel|egend|i(?:(?:nk|sting))?)|m(?:a(?:in|p|r(?:k|quee)|th)|e(?:nu(?:item)?|t(?:a|er))|ulticol)|n(?:av|extid|o(?:br|embed|frames|script))|o(?:bject|l|pt(?:group|ion)|utput)|p(?:(?:aram|icture|laintext|r(?:e|ogress)))?|q|r(?:bc?|p|tc?|uby)|s(?:(?:amp|cript|e(?:ction|lect)|hadow|lot|mall|ource|pa(?:cer|n)|t(?:r(?:ike|ong)|yle)|u(?:b|mmary|p)|vg))?|t(?:able|body|d|e(?:mplate|xtarea)|foot|h(?:ead)?|i(?:me|tle)|r(?:ack)?|t)|ul?|v(?:ar|ideo)|wbr|xmp)$/;function isHTMLTag(t){return builtinTagsRegex.test(t)}function getAttributeValueType(t){if(void 0!==t&&"="===t[0]){switch(t=t.substring(1).trim()){case"NaN":case"Infinity":case"-Infinity":return 1;case"null":case"false":case"undefined":return;case"true":return 0}return/^"(?:[^"\\]|\\.)*"$/.test(t)||/^'(?:[^'\\]|\\.)*'$/.test(t)||/^`(?:[^`\\$]|\\.|\$(?!\{))*`$/.test(t)?2:/^-?0[oO]?[0-7](?:_?[0-7]+)*n?$/.test(t)||/^-?0[xX][0-9a-fA-F](?:_?[0-9a-fA-F]+)*n?$/.test(t)||/^-?0[bB][01](?:_?[01]+)*n?$/.test(t)||/^-?\d(?:_?\d+)*(?:[.eE]\d(?:_?\d+)*|n?|\.?)$/.test(t)?1:3}}function extractHTML(t){return new HTMLExtractor(t).end()}var HTMLExtractor=class{#S;#_;#E;#b;constructor(t){this.#S=new Extractor(t),this.#_=t.read.bind(t),this.#E={},this.#b=0,t.program.body.forEach(t=>this.#N(t))}end(){return{extracted:this.#S.end(),nodeDetails:this.#E}}#N(t){var e;let r=!1,s=!1,a=!1;switch(t.type){case 16:null==(e=t.body)||e.forEach(t=>{this.#N(t)&&(r=!0)});break;case 1:{if("script"===t.nameText||"style"===t.nameText)break;const e=""+this.#b++;({isDynamic:a,hasDynamicAttrs:s,hasDynamicBody:r}=this.#C(t,e)),this.#E[e]={hasDynamicAttrs:s,hasDynamicBody:r};break}case 17:this.#S.copy(t);break;case 22:a="!"===this.#_({start:t.start+1,end:t.start+2}),this.#S.write("placeholder")}return a||r}#C(t,e){const r=!t.nameText||!isHTMLTag(t.nameText);let s=!1,a=!1;return r?this.#I(t):({hasDynamicAttrs:s,hasDynamicBody:a}=this.#R(t,e)),{isDynamic:r,hasDynamicAttrs:s,hasDynamicBody:a}}#R(t,e){var r,s;let a=!1,n=!1;return this.#S.write("<"),this.#S.copy(isEmptyRange(t.name)?t.nameText:t.name),this.#S.write(` data-marko-node-id="${e}"`),null==(r=t.attrs)||r.forEach(t=>{10===t.type?this.#$(t):15===t.type&&(a=!0)}),this.#S.write(">"),isVoidTag(t.nameText)||(null==(s=t.body)||s.forEach(t=>{this.#N(t)&&(n=!0)}),this.#S.write(`</${t.nameText}>`)),{hasDynamicAttrs:a,hasDynamicBody:n}}#I(t){t.body&&(this.#S.write("<div>"),t.body.forEach(t=>this.#N(t)),this.#S.write("</div>"))}#$(t){this.#S.write(" ");const e=this.#_(t.name);if(/:(?:scoped|(?:no-update(?:-if)?))$/.test(e)?this.#S.copy({start:t.name.start,end:t.name.start+e.lastIndexOf(":")}):this.#S.copy(t.name),void 0===t.value||t.name.start===t.name.end||14===t.value.type)return;const r=this.#_(t.value),s=getAttributeValueType(r);if(void 0!==s)switch(s){case 0:break;case 1:this.#S.write('="'),this.#S.copy({start:t.value.start+r.search(/[^=\s]/g),end:t.value.end}),this.#S.write('"');break;case 2:this.#S.write('="'),this.#S.copy({start:t.value.start+r.search(/[^=\s]/g)+1,end:t.value.end-1}),this.#S.write('"');break;case 3:this.#S.write('="dynamic"')}}};function isVoidTag(t){switch(t){case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"link":case"meta":case"param":case"source":case"track":case"wbr":return!0;default:return!1}}function isEmptyRange(t){return t.start===t.end}var import_path3=__toESM(require("path")),import_relative_import_path=require("relative-import-path"),import_compiler=require("@marko/compiler"),import_babel=require("@marko/compiler/internal/babel");function isTextOnlyScript(t){if("script"!==t.nameText||t.args||t.attrs||!t.body)return!1;for(const e of t.body)if(17!==e.type)return!1;return!0}var plugins=["exportDefaultFrom","importAssertions","typescript"],ScriptParser=class{#o;#M=new Map;constructor(t){this.#o=t}tagName(t){return this.#P(t)}tagShorthandId(t){return this.#P(t)}tagShorthandClassName(t){return this.#P(t)}tagVar(t){const e=t.value.start-1,r=this.#M.get(e)??this.#k(e,`(${this.#o.read(t.value)})=>0`);if(r)return r.params[0]}tagParams(t){const e=t.start,r=this.#M.get(e)??this.#k(e,`(${this.#o.read(t.value)})=>0`);if(r)return r.params}tagTypeParams(t){const e=t.value.start-1,r=this.#M.get(e)??this.#k(e,`<${this.#o.read(t.value)}>()=>0`);if(r)return r.typeParameters}tagArgs(t){const e=t.value.start-2,r=this.#M.get(e)??this.#k(e,`_(${this.#o.read(t.value)})`);if(r)return r.arguments}tagTypeArgs(t){const e=t.value.start-2,r=this.#M.get(e)??this.#k(e,`_<${this.#o.read(t.value)}>()`);if(r)return r.typeParameters}attrValue(t){const e=t.value.start;return(this.#M.get(e)??this.#k(e,this.#o.read(t.value)))||void 0}attrSpread(t){const e=t.value.start;return(this.#M.get(e)??this.#k(e,this.#o.read(t.value)))||void 0}attrMethod(t){const e=t.async?"{async _":"{_",r=t.params.start-e.length,s=this.#M.get(r)??this.#k(r,`${e}${this.#o.read({start:t.params.start,end:t.body.end})}}`);if(s)return s.properties[0]}attrArgs(t){const e=t.value.start;return(this.#M.get(e)??this.#k(e,this.#o.read(t.value)))||void 0}placeholder(t){const e=t.value.start;return(this.#M.get(e)??this.#k(e,this.#o.read(t.value)))||void 0}scriptBody(t){if(!isTextOnlyScript(t))return;const e=t.body[0].start,r=this.#M.get(e)??this.#L(e,this.#o.read({start:e,end:t.body[t.body.length-1].end}));return r||void 0}scriptlet(t){const e=t.value.start,r=this.#M.get(e)??this.#L(e,this.#o.read(t.value));if(r)return r}import(t){const e=this.#M.get(t.start)??this.#L(t.start,this.#o.read(t));if(e)return e[0]}export(t){const e=this.#M.get(t.start)??this.#L(t.start,this.#o.read(t));if(e)return e[0]}class(t){return(this.#M.get(t.start)??this.#k(t.start,this.#o.read(t)))||void 0}static(t){const e=t.start+7,r=this.#M.get(e)??this.#L(e,this.#o.read({start:e,end:t.end}));if(r)return r}#P(t){const{expressions:e}=t;if(!e.length)return;const r=[];for(const t of e){const e=t.value.start,s=this.#M.get(e)??this.#k(e,this.#o.read(t.value));if(!s)return;r.push(s)}return r.length?r:void 0}#L(t,e){try{const r=this.#o.positionAt(t),s=(0,import_babel.parse)(e,{plugins:plugins,startIndex:t,startLine:r.line+1,startColumn:r.character,strictMode:!0,errorRecovery:!0,sourceType:"module",allowUndeclaredExports:!0,allowSuperOutsideMethod:!0,allowAwaitOutsideFunction:!0,allowReturnOutsideFunction:!0,sourceFilename:this.#o.filename}).program.body;if(s.length)return this.#M.set(t,s),s}catch{}this.#M.set(t,!1)}#k(t,e){try{const r=this.#o.positionAt(t),s=(0,import_babel.parseExpression)(e,{plugins:plugins,startIndex:t,startLine:r.line+1,startColumn:r.character,strictMode:!0,errorRecovery:!0,sourceType:"module",allowUndeclaredExports:!0,allowSuperOutsideMethod:!0,allowAwaitOutsideFunction:!0,allowReturnOutsideFunction:!0,sourceFilename:this.#o.filename});return this.#M.set(t,s),s}catch{this.#M.set(t,!1)}}},VISITOR_KEYS=import_compiler.types.VISITOR_KEYS,getVisitorKeys=t=>VISITOR_KEYS[t.type]||[],ATTR_UNNAMED="value",Scopes=new WeakMap,BoundAttrValueRange=new WeakMap;function crawlProgramScope(t,e){var r;const{program:s}=t,a=[],n=[],i=new Map,o=hasTagVars(s.body),c={parent:void 0,hoists:!1,bindings:{}};c.bindings.input={type:1,name:"input",node:s,scope:c,hoisted:!1},function r(s,a){var c;for(const d of s)switch(d.type){case 1:case 16:if(d.var){a.bindings??={};const r=e.tagVar(d.var);if(r){p(a,r);for(const e of getVarIdentifiers(t,r,"",ATTR_UNNAMED)){const{name:t,range:r,objectPath:s,sourceName:i}=e,o=a.bindings[t]={type:0,name:t,node:d,scope:a,hoisted:!1,mutated:!1,range:r,objectPath:s,sourceName:i};n.push(o)}}}if(d.body){const t={parent:a,hoists:!1,bindings:{}};if(o&&d.params){t.bindings??={};const r=e.tagParams(d.params);if(r)for(const e of r){p(t,e);for(const r of getIdentifiers(e))t.bindings[r]={type:1,name:r,node:d,scope:t,hoisted:!1}}}const s=o&&e.scriptBody(d);if(s){const t=i.get(a);t?t.push(...s):i.set(a,[...s])}else r(d.body,t);Scopes.set(d.body,t)}if(d.attrs)for(const t of d.attrs)switch(t.type){case 15:o&&p(a,e.attrSpread(t));break;case 10:switch(null==(c=t.value)?void 0:c.type){case 13:{if(!o&&!t.value.bound)break;let r=e.attrValue(t.value);if(r)if(t.value.bound){let e;if("TSAsExpression"!==r.type&&"TSSatisfiesExpression"!==r.type||(e={start:r.expression.end+1,end:r.end},r=r.expression),"Identifier"===r.type){const s=resolveWritableVar(a,r.name);s&&markMutated(s),BoundAttrValueRange.set(t.value,{types:e,value:{start:r.start,end:r.end},member:void 0})}else"MemberExpression"===r.type&&BoundAttrValueRange.set(t.value,{types:e,value:{start:r.start,end:r.property.start-1},member:{start:r.property.start,end:r.property.end,computed:r.computed}})}else p(a,r);break}case 14:o&&p(a,e.attrMethod(t.value))}}}}(s.body,c),Scopes.set(s.body,c);for(const t of n){const{scope:e,name:s}=t;let a=e.parent;for(;a;){const e=null==(r=a.bindings)?void 0:r[s];if(e){2===e.type&&(t.hoisted=!0,e.bindings.push(t));break}if(a===c){t.hoisted=!0,c.bindings[s]={type:2,scope:c,bindings:[t],hoisted:!1};break}a=a.parent}if(t.hoisted)for(e.hoists=!0,a=e.parent;a&&!a.hoists&&a!==c;)a.hoists=!0,a=a.parent}for(const[t,e]of i){const r=new Set,s=[];for(const n of e)trackMutations(n,t,a,r,s);flushMutations(t,a,r,s)}if(a.length)return a.sort(byStart);function p(t,e){e&&traverse(e,e=>{switch(e.type){case"FunctionDeclaration":case"FunctionExpression":case"ObjectMethod":case"ArrowFunctionExpression":case"ClassMethod":case"ClassPrivateMethod":{const r=i.get(t);return r?r.push(e):i.set(t,[e]),!0}}})}}function getProgramBindings(t){const{bindings:e}=Scopes.get(t.body);let r,s;for(const t in e){const a=e[t];switch(a.type){case 2:{const e={name:t,sources:a.bindings.map(t=>t.range)};r?r.push(e):r=[e];break}case 0:{const e={name:t,sources:[a.range]};s?s.push(e):s=[e];break}}}if(r||s)return{all:s?r?[...s,...r]:s:r,vars:s,hoists:r}}function getMutatedVars(t){var e,r;return null==(r=null==(e=Scopes.get(t.parent.body))?void 0:e.mutatedVars)?void 0:r.get(t)}function getHoistSources(t){let e;if(t){const{bindings:r}=Scopes.get(t);for(const t in r){const s=r[t];s.hoisted&&(e?e.push(s):e=[s])}}return e}function isMutatedVar(t,e){const r=Scopes.get(t.body),s=r&&resolveWritableVar(r,e);return!!s&&s.mutated}function hasHoists(t){return!!t.body&&Scopes.get(t.body).hoists}function getBoundAttrRange(t){return BoundAttrValueRange.get(t)}function hasTagVars(t){if(t)for(const e of t)switch(e.type){case 1:case 16:if(e.var||hasTagVars(e.body))return!0}return!1}function resolveWritableVar(t,e){var r;let s=t;do{const t=null==(r=s.bindings)?void 0:r[e];if(t)return 0===t.type&&void 0!==t.sourceName?t:void 0}while(s=s.parent)}function*getIdentifiers(t){for(const e of getIdentifierNodes(t))yield e.name}function*getIdentifierNodes(t){switch(t.type){case"Identifier":yield t;break;case"ObjectPattern":for(const e of t.properties)"RestElement"===e.type?yield*getIdentifierNodes(e.argument):yield*getIdentifierNodes(e.value);break;case"ArrayPattern":for(const e of t.elements)e&&("RestElement"===e.type?yield*getIdentifierNodes(e.argument):yield*getIdentifierNodes(e));break;case"AssignmentPattern":yield*getIdentifierNodes(t.left)}}function*getVarIdentifiers(t,e,r,s){switch(e.type){case"Identifier":yield{name:e.name,range:{start:e.start,end:e.start+e.name.length},objectPath:r,sourceName:s};break;case"ObjectPattern":for(const a of e.properties)if("RestElement"===a.type)yield*getVarIdentifiers(t,a.argument,r,s);else{let e,s;"Identifier"===a.key.type?(e=a.key.name,s=`.${e}`):(e=t.read(a.key),s=`[${e}]`),yield*getVarIdentifiers(t,a.value,r+s,e)}break;case"ArrayPattern":{let s=-1;for(const a of e.elements)s++,a&&("RestElement"===a.type?yield*getVarIdentifiers(t,a.argument,r):yield*getVarIdentifiers(t,a,r+`[${s}]`));break}case"AssignmentPattern":yield*getVarIdentifiers(t,e.left,r,s)}}function trackMutations(t,e,r,s,a){if(!t)return;let n=s,i=a;switch(t.type){case"BlockStatement":i===a&&(n=new Set(n),i=[]);break;case"ForInStatement":case"ForOfStatement":if("VariableDeclaration"!==t.left.type)for(const e of getIdentifierNodes(t.left))a.push(e);n=new Set(n),i=[];break;case"ForStatement":n=new Set(n),i=[];break;case"ArrowFunctionExpression":case"ObjectMethod":case"ClassMethod":case"ClassPrivateMethod":n=new Set(n),i=[];for(const r of t.params)trackShadows(r,e,n);break;case"FunctionExpression":n=new Set(n),i=[],t.id&&trackShadows(t.id,e,n);for(const r of t.params)trackShadows(r,e,n);break;case"FunctionDeclaration":t.id&&trackShadows(t.id,e,s),n=new Set(n),i=[];for(const r of t.params)trackShadows(r,e,n);break;case"ClassExpression":n=new Set(n),i=[],t.id&&trackShadows(t.id,e,n);break;case"ClassDeclaration":t.id&&trackShadows(t.id,e,s),n=new Set(n),i=[];break;case"CatchClause":n=new Set(n),i=[],t.param&&trackShadows(t.param,e,n);break;case"VariableDeclaration":for(const r of t.declarations)trackShadows(r.id,e,n);break;case"UpdateExpression":"Identifier"===t.argument.type&&a.push(t.argument);break;case"AssignmentExpression":if("Identifier"===t.left.type)a.push(t.left);else for(const e of getIdentifierNodes(t.left))a.push(e)}for(const s of getVisitorKeys(t)){const a=t[s];if(Array.isArray(a))for(const t of a)trackMutations(t,e,r,n,i);else trackMutations(a,e,r,n,i)}i!==a&&i.length&&flushMutations(e,r,n,i)}function markMutated(t){if(t.mutated)return;t.mutated=!0;const e=t.scope.mutatedVars??=new Map,r=e.get(t.node);if(r){let e=r.length;for(;e&&r[e-1].range.start>t.range.start;)e--;r.splice(e,0,t)}else e.set(t.node,[t])}function flushMutations(t,e,r,s){for(const{name:a,start:n}of s){if(null==n||r.has(a))continue;const s=resolveWritableVar(t,a);s&&(markMutated(s),e.push({start:n,binding:s}))}}function trackShadows(t,e,r){for(const s of getIdentifiers(t))resolveWritableVar(e,s)&&r.add(s)}function traverse(t,e){if(t&&!e(t))for(const r of getVisitorKeys(t)){const s=t[r];if(Array.isArray(s))for(const t of s)traverse(t,e);else traverse(s,e)}}function byStart(t,e){return t.start-e.start}var import_fs=__toESM(require("fs")),import_path2=__toESM(require("path"));function getComponentFilename(t){const e=import_path2.default.dirname(t);let r=import_path2.default.basename(t,".marko");r.endsWith(".d")&&(r=r.slice(0,-2));const s="index"===r,a=`(${r.replace(/[.*+?^$[\]()|\\:!{}]/g,"\\$&")}\\.${s?"|":""})`,n=new RegExp(`^${a}component(-browser)?\\.\\w+$`);for(const t of tryReaddirSync(e))if(n.test(t))return import_path2.default.join(e,t)}function tryReaddirSync(t){try{return import_fs.default.readdirSync(t)}catch{return[]}}var REG_DISCOVERABLE_TAG=/[\\/](?:components|tags)[\\/]([^\\/]+?)(?:[\\/](?:index|\1))?(?:\.d)?\.marko$/i,REG_WORD_START=/(?:^|[^\p{L}\p{N}]+)([\p{L}\p{N}])/gu;function getComponentName(t){const e=REG_DISCOVERABLE_TAG.exec(t);if(!e)return;const r=e[1].replace(REG_WORD_START,(t,e)=>e.toUpperCase()).replace(/[^\p{L}\p{N}]/gu,"");return new RegExp("^\\p{L}","u").test(r)?r:void 0}var RuntimeAPI={tags:"tags",class:"class"};function getRuntimeAPI(t,e,r){const s=detectAPIFromTranslator(t);return{interop:!s,api:s||detectAPIFromFileName(r.filename,e)||detectAPIFromProgram(r,r.program)||("tags"===e.exclusiveTagDiscoveryDirs?RuntimeAPI.tags:RuntimeAPI.class)}}function detectAPIFromTranslator(t){if("tags"===(null==t?void 0:t.preferAPI))return RuntimeAPI.tags}function detectAPIFromFileName(t,e){var r;const s=getTagsDir(t);if(s&&!(null==(r=e.manualTagsDirs)?void 0:r.has(s)))return RuntimeAPI.tags}function getTagsDir(t){var e;const r=null==(e=/\/|\\/.exec(t))?void 0:e[0];if(r){let e=t.length-1;for(;e>0;){const s=t.lastIndexOf(r,e);switch(e-s){case 4:if(t.startsWith("tags",s+1))return t.slice(0,s+5);break;case 10:if(t.startsWith("components",s+1))return!1}e=s-1}}return!1}function detectAPIFromProgram(t,e){if(e.comments)switch(t.read(e.comments[0].value).trim()){case"use tags":return RuntimeAPI.tags;case"use class":return RuntimeAPI.class}if(e.static)for(const t of e.static)switch(t.type){case 26:case 27:return RuntimeAPI.class}return detectAPIFromBody(t,e.body)}function detectAPIFromBody(t,e){if(e)for(const r of e){const e=detectAPIFromChild(t,r);if(e)return e}}function detectAPIFromChild(t,e){switch(e.type){case 23:return RuntimeAPI.class;case 1:case 16:return detectAPIFromTag(t,e)}}function detectAPIFromTag(t,e){var r;if(e.var)return RuntimeAPI.tags;switch(e.nameText){case"await-reorderer":case"include-html":case"include-text":case"init-components":case"macro":case"module-code":case"while":return RuntimeAPI.class;case"const":case"debug":case"define":case"id":case"let":case"lifecycle":case"log":case"return":case"try":return RuntimeAPI.tags}if(e.attrs)for(const s of e.attrs)if(15!==s.type){if(13===(null==(r=s.value)?void 0:r.type)&&s.value.bound)return RuntimeAPI.tags;if(s.args)return RuntimeAPI.class;if(/:/.test(t.read(s.name)))return RuntimeAPI.class}return detectAPIFromBody(t,e.body)}var MaybeInputTypedefReg=/@typedef\b[\s\S]*\bInput\b/,tagReg=/@(typedef|template)\b/g,identifierReg=/[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*/y,spaceReg=/\s*/y;function getJSDocInputType(t){if(!MaybeInputTypedefReg.test(t))return;const e=stripCommentDecorations(t);let r,s,a=!1;for(tagReg.lastIndex=0;s=tagReg.exec(e);){let t,n=skipSpace(e,tagReg.lastIndex);if("{"===e[n]){const r=closingBracket(e,n,"{","}");-1!==r&&(t=e.slice(n+1,r),n=skipSpace(e,r+1))}if("typedef"===s[1]){const t=identifierAt(e,n);"Input"===t&&(a=!0),t&&(n+=t.length)}else{let s=(null==t?void 0:t.trim())||void 0;for(;;){let t,a;if("["===e[n]){const r=closingBracket(e,n,"[","]");if(-1===r)break;const s=e.slice(n+1,r),i=s.indexOf("=");t=(-1===i?s:s.slice(0,i)).trim(),a=-1===i?void 0:s.slice(i+1).trim()||void 0,n=r+1}else(t=identifierAt(e,n))&&(n+=t.length);if(!t)break;const i={name:t,constraint:s,default:a};if(s=void 0,r?r.push(i):r=[i],n=skipSpace(e,n),","!==e[n])break;n=skipSpace(e,n+1)}}tagReg.lastIndex=n}return a?{typeParameters:r}:void 0}function stripCommentDecorations(t){return t.replace(/^\/\*\*?/,"").replace(/\*\/$/,"").replace(/^[ \t]*\*(?!\/)/gm,"")}function skipSpace(t,e){return spaceReg.lastIndex=e,spaceReg.test(t),spaceReg.lastIndex}function identifierAt(t,e){var r;return identifierReg.lastIndex=e,null==(r=identifierReg.exec(t))?void 0:r[0]}function closingBracket(t,e,r,s){let a=0;for(let n=e;n<t.length;n++){const e=t[n];if('"'===e||"'"===e||"`"===e)for(;++n<t.length&&t[n]!==e;)"\\"===t[n]&&n++;else if(e===r)a++;else if(e===s&&! --a)return n}return-1}var SEP_EMPTY="",SEP_SPACE=" ",SEP_COMMA_SPACE=", ",SEP_COMMA_NEW_LINE=",\n",VAR_LOCAL_PREFIX="__marko_internal_",INTERNAL_API_VAR=`${VAR_LOCAL_PREFIX}api`,INTERNAL_API_EXPORT_NAME="~api",VAR_SHARED_PREFIX="Marko._.",ATTR_UNNAMED2="value",REG_EXT=/(?<=[/\\][^/\\]+)\.[^.]+$/,REG_BLOCK=/\s*{/y,REG_NEW_LINE=/^|(\r?\n)/g,REG_ATTR_ARG_LITERAL=/(["'])((?:\\.|(?!\1)[^\\])*)\1\s*([,)])/y,REG_TAG_IMPORT=/(?<=(['"]))<([^'">]+)>(?=\1)/,REG_INPUT_TYPE=/\s*(interface|type)\s+Input\b/y,REG_OBJECT_PROPERTY=/^[_$a-z][_$a-z0-9]*$/i,REG_COMMENT_PRAGMA=/\/\/(?:\s*@ts-|\/\s*<)/y,REG_TAG_NAME_IDENTIFIER=/^[A-Z][a-zA-Z0-9_$]+$/,REG_NODE_MODULES=/[\\/]node_modules[\\/]/,IF_TAG_ALTERNATES=new WeakMap,TAG_ID=new WeakMap,RENDER_VAR=new WeakMap,TEMPLATE_VAR=new WeakMap,WROTE_COMMENT=new WeakSet,START_OF_FILE={start:0,end:0},templateNameReg=/(?<![.\w$])Template(?![\w$])/,ScriptLang=(t=>(t.js="js",t.ts="ts",t))(ScriptLang||{});function extractScript(t){return new ScriptExtractor(t).end()}var ScriptExtractor=class{#t;#O;#D;#F;#o;#S;#V;#_;#B;#j;#G;#W=!1;#H=1;#U=new WeakMap;#q=[0];constructor(t){const{parsed:e,lookup:r,scriptLang:s}=t,{api:a,interop:n}=getRuntimeAPI(t.translator,t.lookup,e);this.#t=e.code,this.#O=e.filename,this.#D=a,this.#F=n,this.#j=s,this.#o=e,this.#B=r,this.#S=new Extractor(e),this.#V=new ScriptParser(e),this.#_=e.read.bind(e),this.#G=crawlProgramScope(this.#o,this.#V),this.#J(e.program)}end(){return this.#S.end()}#J(t){this.#K(t);const e=this.#D===RuntimeAPI.class?getComponentFilename(this.#O):void 0,r=this.#X(t);let s;for(const e of t.static)switch(e.type){case 26:this.#z(e),s={start:e.start+5,end:e.end};break;case 25:this.#z(e),this.#S.copy(e).write("\n");break;case 24:{const t=REG_TAG_IMPORT.exec(this.#_(e));if(this.#z(e),t){const[,,r]=t,s=resolveTagImport(this.#O,this.#B.getTag(r));if(s){const[{length:r}]=t,a=e.start+t.index,n=a+r;this.#S.copy({start:e.start,end:a}).write(s).copy({start:n,end:e.end}).write("\n");break}}this.#S.copy(e).write("\n");break}case 28:{let t=e.start+7,r=e.end;this.#z(e),this.#Y(REG_BLOCK,t)&&(t=REG_BLOCK.lastIndex,r--),this.#S.copy({start:t,end:r}).write("\n");break}}let a="",n="",i="",o="";const c=!s&&void 0!==e;if(r){if(r.typeParameters){let t=SEP_EMPTY;a=n="<";for(const e of r.typeParameters)a+=t+e.name+(e.constraint?` extends ${e.constraint}`:"")+(e.default?` = ${e.default}`:""),n+=t+e.name,i+=t+"any",t=SEP_COMMA_SPACE;if(a+=">",n+=">","js"===this.#j)for(const t of r.typeParameters)o+=`\n* @template ${t.constraint?`{${removeNewLines(t.constraint)}} `:""}${t.default?`[${t.name} = ${removeNewLines(t.default)}]`:t.name}`}}else"ts"===this.#j?this.#S.write(c?"export type Input = Component['input'];\n":"export interface Input {}\n"):this.#S.write("/** @typedef {Record<string, unknown>} Input */\n");if(this.#D===RuntimeAPI.class)if(c){const t=`"${stripExt((0,import_relative_import_path.relativeImportPath)(this.#O,e))}"`;"ts"===this.#j?n?this.#S.write(`import type Component from ${t};\nexport type { Component };\n`):this.#S.write(`export interface Component extends ${varShared("ResolveComponent")}<typeof import(${t})> {}\n`):n?this.#S.write(`/** @import Component from ${t} */\n`):this.#S.write(`/** @typedef {${varShared("ResolveComponent")}<typeof import(${t})>} Component */\n`)}else{const t=s||" {}";"ts"===this.#j?this.#S.write(`abstract class Component${a} extends Marko.Component<Input${n}>`).copy(t).write("\nexport { type Component }\n"):(this.#S.write(`/**${o}\n    * @extends {Marko.Component<Input${n}>}\n    * @abstract\n    */\n`),this.#S.write("export class Component extends Marko.Component").copy(t).write("\n"))}const p=!!getReturnTag(t),d=p?varLocal("template"):"";p||this.#S.write("("),"ts"===this.#j?this.#S.write(`function ${d}${a}(this: void) {\n`):this.#S.write(`/**${o}\n* @this {void}\n*/\nfunction ${d}() {\n`),this.#S.write(`  const input = ${this.#Q(`Input${n}`)};${this.#D===RuntimeAPI.class?`\n  const component = ${this.#Q(`Component${n}`)};\n  const state = ${varShared("state")}(component);\n  const out = ${this.#Q("Marko.Out")};`:""}\n  const $signal = ${this.#Q("AbortSignal")};\n  const $global = ${varShared("getGlobal")}(\n    // @ts-expect-error We expect the compiler to error because we are checking if the MarkoRun.Context is defined.\n    (${varShared("error")}, ${this.#Q("MarkoRun.Context")})\n  );\n`);const h=this.#Z(t),l=getProgramBindings(t);if(l)for(const t of l.all)this.#S.write("const ").copy(t.sources).write(` = ${varShared("hoist")}(() => ${varLocal(`hoist__${t.name}`)});\n`);if(null==h?void 0:h.content){if(this.#tt(h.content),l){if(l.vars)for(const t of l.vars)this.#S.write(`var ${varLocal(`hoist__${t.name}`)} = `).copy(t.sources[0]).write(";\n");l.hoists&&this.#S.write(`var {${l.hoists.map(t=>`${t.name}: ${varLocal(`hoist__${t.name}`)}`).join(SEP_COMMA_SPACE)}} = ${varShared("hoisted")}(${this.#et(t.body)});\n`)}this.#rt()}this.#S.write(`${varShared("noop")}({ ${l?l.all.map(t=>t.name).join(SEP_COMMA_SPACE)+SEP_COMMA_SPACE:""}${this.#D===RuntimeAPI.class?"component, state, out, ":""}input, $global, $signal });\n`),p?this.#S.write(`return ${varLocal("return")};\n}\n`):this.#S.write("return;\n})();\n");let u=varShared("Template");const m=varLocal("apply"),g=varLocal("input"),f=a.slice(1,-1),y=INTERNAL_API_VAR,T=p?`${varShared("ReturnOf")}<typeof ${d+n}>`:"void",x=this.#D===RuntimeAPI.class?', "class"':"";let w;if(a){const t=varLocal("key"),e=`<${m} = 1>(m?: ${m}) => ${m} extends 0 | 2\n    ? ${a}() => ${varShared("Renderer")}<Input${n}, ${T}, ${m}>\n    : ${m} extends 1\n    ? () => <${g}, ${f}>(input: Marko.Directives & Input${n} & ${varShared("Relate")}<${g}, Marko.Directives & Input${n}>) => ${varShared("ReturnWithScope")}<${g}, ${T}>\n    : () => <${g}, ${f}>(input: ${varShared("TagInput")}<${g}, Input${n}>) => ${varShared("ReturnWithRestAttrTagsScope")}<${g}, ${T}>`,r=e=>`${varShared(e)}<Input${n}, ${T}, ${t}>`;u=varShared("GenericTemplate"),w=`{\n  [${t} in keyof ${varShared("TemplateMethods")}]: ${a}(...args: ${r("MethodParams")}) => ${r("MethodReturn")};\n} & { [${varShared("anyInput")}]: Input<${i}> }, ${e}${x}`}else w="Input"+(x||p?`, ${T}${x}`:"");const v=`${u}<${w}>`;this.#F&&this.#S.write(`const ${y} = "${this.#D}";\nexport { ${y} as "${INTERNAL_API_EXPORT_NAME}" };\n`);const A=getComponentName(this.#O),S=this.#W?"Input":A&&!this.#t.includes(A)?A:void 0,_="ts"===this.#j?`class Template extends ${v} {}`:`/**\n * @extends {${removeNewLines(v)}}\n */\nclass Template extends (${u}) {}`,E=S?`const ${S} = new `:"export default new ";templateNameReg.test(this.#t)?this.#S.write(E).anchor(START_OF_FILE).write(`(\n${_}\n);\n`):this.#S.write(`${_}\n${E}`).anchor(START_OF_FILE).write("Template();\n"),S&&this.#S.write(`export default ${S};\n`),this.#z(t)}#K(t){const e=t.static.length?t.static[0].comments:t.body.length?t.body[0].comments:t.comments;if(e)for(const t of e)this.#Y(REG_COMMENT_PRAGMA,t.start)&&(WROTE_COMMENT.add(t),this.#S.copy(t).write("\n"))}#z(t){if(t.comments)for(const e of t.comments)if(!WROTE_COMMENT.has(e))if("/"===this.#t.charAt(e.start+1))this.#S.write("//").copy(e.value).write("\n");else if("!"===this.#t.charAt(e.start+1)){this.#S.write("/*");let t=e.value.start;for(const{index:r}of this.#_(e.value).matchAll(/\*\//g))this.#S.copy({start:t,end:t=e.value.start+r+1}).write("\\");this.#S.copy({start:t,end:e.value.end}),this.#S.write("*/")}else this.#S.write("/*").copy(e.value).write("*/")}#st(t,e){const r=this.#at(e);t||r?("ts"===this.#j?(this.#S.write("return new (class MarkoReturn<Return = void> {\n"),r&&(this.#S.write(`readonly [${varShared("scope")}] = `),this.#nt(e),this.#S.write(";\n")),this.#S.write("declare return: Return;\nconstructor(_?: Return) {}\n})(\n")):(this.#S.write("return new (/**\n* @template [Return=void]\n*/\nclass MarkoReturn {\n"),r&&(this.#S.write(`[${varShared("scope")}] = `),this.#nt(e),this.#S.write(";\n")),this.#S.write("/** @type {Return} */\nreturn;\n/** @param {Return} [_] */\nconstructor(_) {}\n})(\n")),this.#S.copy(t),this.#S.write(");\n")):this.#S.write(`return ${varShared("voidReturn")};\n`)}#tt(t,e=!1){var r,s;const a=t.length-1;let n,i=0;for(this.#q.push(0);i<=a;){const a=t[i++];switch(a.type){case 1:switch(a.nameText){case"return":n=a;break;case"if":{const t=IF_TAG_ALTERNATES.get(a);let s=!1;if(!e){if(s=hasHoists(a),!s&&t)for(const{node:e}of t)if(s=hasHoists(e))break;s&&this.#S.write(`const ${this.#it(a,!0)} = (() => {\n`)}this.#z(a),this.#S.write("if ("),this.#ot(a,this.#ct(null==(r=a.args)?void 0:r.value)||this.#pt(a,ATTR_UNNAMED2)),this.#S.write("\n) {\n");const n=this.#Z(a);(null==n?void 0:n.content)&&(this.#tt(n.content,!0),this.#at(a.body)&&(this.#S.write("return {\nscope: "),this.#nt(a.body),this.#S.write("\n};\n")),this.#rt());let i=!0;if(t)for(const{node:e,condition:r}of t){this.#z(e),r?this.#S.write("\n} else if (\n").copy(r).write("\n) {\n"):"else"===e.nameText?(i=!1,this.#S.write("\n} else {\n")):(this.#S.write("\n} else if ("),this.#ot(e,void 0),this.#S.write(") {\n"));const t=this.#Z(e);(null==t?void 0:t.content)&&(this.#tt(t.content,!0),this.#at(e.body)&&(this.#S.write("return {\nscope: "),this.#nt(e.body),this.#S.write("\n};\n")),this.#rt())}i&&s?this.#S.write("\n} else {\nreturn undefined;\n}\n"):this.#S.write("\n}\n"),s&&this.#S.write("\n})();\n");break}case"for":{hasHoists(a)&&this.#S.write(`const ${this.#it(a,!0)} = `),this.#S.write(`${varShared(getForTagRuntime(this.#o,a))}({\n`).anchor(a.name),this.#dt(a),this.#S.write("\n}"+SEP_COMMA_NEW_LINE).copy(a.typeParams).write("(\n"),this.#z(a),a.params&&this.#ht(a.params.value),this.#S.write("\n) => {\n");const t=this.#Z(a);(null==t?void 0:t.content)&&this.#tt(t.content),this.#st(void 0,(null==t?void 0:t.content)&&a.body),(null==t?void 0:t.content)&&this.#rt(),this.#S.write("\n});\n");break}case"while":{this.#z(a),this.#S.write("while (\n"),this.#ot(a,this.#ct(null==(s=a.args)?void 0:s.value)),this.#S.write("\n) {\n");const t=this.#Z(a);(null==t?void 0:t.content)&&(this.#tt(t.content),this.#rt()),this.#S.write("\n}\n");break}default:this.#C(a)}break;case 22:this.#lt(a);break;case 23:this.#ut(a)}}return n&&(this.#S.write(`var ${varLocal("return")} = ${varShared("returnTag")}(`),this.#mt(n,this.#Z(n)),this.#S.write(");\n")),void 0!==n}#C(t){const e=t.nameText,r=e?this.#B.getTag(e):void 0,s=resolveTagImport(this.#O,r),a=!s&&(null==r?void 0:r.html),n=hasHoists(t),i=t.var&&!a&&getMutatedVars(t);let o,c,p=!1;if(!r||s){const r=e&&REG_TAG_NAME_IDENTIFIER.test(e),a=null==s?void 0:s.endsWith(".marko");r||a||!s?(c=this.#gt(t,!0),this.#S.write(`const ${c} = (\n`),r?s?(this.#S.write(`${varShared("fallbackTemplate")}(\n// @ts-ignore\n${e},\n`),a?(this.#S.write(`${varShared("resolveTemplate")}(import("${s}")).`),this.#ft(t)):this.#S.write(varShared("any")),this.#S.write(")")):this.#S.copy(t.name):a?(p=!0,this.#S.write(`${varShared("resolveTemplate")}(import("${s}")).`),this.#ft(t)):this.#yt(t),this.#S.write("\n);\n")):c=varShared("missingTag");const n=this.#Tt(t);n&&(this.#xt(n,c),this.#S.write(";\n"))}(n||t.var)&&(o=this.#it(t,!0),t.var&&(this.#q[this.#q.length-1]++,this.#S.write("{const "),"style"===e?(this.#S.copy(t.var.value).write(" = "),this.#wt(t),this.#S.write(";\n")):a?this.#S.copy(t.var.value).write(` = ${varShared("el")}(${JSON.stringify(r.name)});\n`):(this.#ht(t.var.value),this.#S.write(` = ${varShared("returned")}(() => ${o});\n`))),!n&&a||this.#S.write(`const ${o} = `)),a?this.#S.write(`${varShared("renderNativeTag")}("`).copy(isEmptyRange2(t.name)?e:t.name).write('")'):c?this.#S.write(`${varShared(p?"renderTemplate":"renderDynamicTag")}(${c}`).anchor(t.name).write(")"):this.#S.write(varShared("missingTag"));const d=this.#Z(t),h=!(!d||this.#vt(t)||!hasRestAttrTags(d));if(t.typeArgs?this.#S.write(h?"<2>()":"<0>()").copy(t.typeArgs).write("()("):this.#S.write(h?`(${varShared("withRestAttrTags")})()(`:"()()("),this.#mt(t,d,h),this.#S.write(");\n"),i)for(const t of i)this.#S.write(`const ${varLocal(`change__${t.name}`)} = ${varShared("change")}(${JSON.stringify(t.name)+(t.sourceName&&t.sourceName!==t.name?`, ${JSON.stringify(t.sourceName)}`:"")}, ${o}.return${t.objectPath||""});\n`)}#wt(t){const e=this.#At(t);"ts"===this.#j?(this.#S.write(`${varShared("any")} as `),writeStyleModuleType(this.#S,e)):(this.#S.write("/** @type {"),writeStyleModuleType(this.#S,e),this.#S.write(`} */(${varShared("any")})`))}#At(t){const e=new Map;if(t.body)for(const r of t.body)if(17===r.type){const t=findStyleSelectors(this.#t.slice(r.start,r.end),r.start);for(const[r,s]of t){const t=e.get(r);t?t.push(...s):e.set(r,s)}}return e}#rt(){const t=this.#q.pop();t&&this.#S.write("}".repeat(t))}#yt(t){const e=this.#St(t);e?this.#S.copy(e):this.#S.write(`${varShared("interpolated")}\``).copy(t.name).write("`")}#lt(t){this.#z(t),this.#S.write("[").copy(t.value).write("];\n")}#ot(t,e){e?this.#S.copy(e):this.#S.write("(").anchor(t.name).write("undefined)")}#ut(t){this.#z(t),this.#S.copy(t.value).write(";\n")}#dt(t){let e=!1;t.shorthandId&&(e=!0,this.#S.write(`id: ${varShared("interpolated")}\``).copy({start:t.shorthandId.start+1,end:t.shorthandId.end}).write("`"+SEP_COMMA_NEW_LINE));const r=t.shorthandClassNames?this.#_t(t.attrs):void 0;if(t.shorthandClassNames){let s=SEP_EMPTY;e=!0,this.#S.write(r?`class: ${varShared("mergeClasses")}(${varShared("interpolated")}\``:`class: ${varShared("interpolated")}\``);for(const e of t.shorthandClassNames)this.#S.write(s).copy({start:e.start+1,end:e.end}),s=SEP_SPACE;this.#S.write("`"),r&&(this.#S.write(", (\n"),this.#ht(r.value.value),this.#S.write("\n))")),this.#S.write(SEP_COMMA_NEW_LINE)}if(t.attrs){e=!0;for(const e of t.attrs)if(e!==r){switch(e.type){case 15:this.#S.write("...(\n"),this.#ht(e.value),this.#S.write("\n)");break;case 10:{const r=isEmptyRange2(e.name),s=e.value,a=s&&13!==s.type?void 0:this.#Et(e),n=r?e.name:void 0;let i=r?ATTR_UNNAMED2:e.name;if(a&&(i={start:e.name.start,end:a.start-1}),s)switch(s.type){case 14:s.async&&this.#S.write("async "),this.#S.write('"').anchor(n).copy(i).write('"').copy(s.typeParams),this.#ht(s.params),this.#ht(s.body);break;case 13:{const e=s.bound&&getBoundAttrRange(s);if(this.#S.write('"').anchor(n).copy(i).write('": '),e)if(this.#S.write("(\n"),e.member)if(e.member.computed)this.#S.copy(e.value).copy({start:e.value.end,end:e.value.end+1}).copy(e.member).copy({start:e.member.end,end:e.member.end+1}).copy(e.types).write(`\n)${SEP_COMMA_NEW_LINE}"`).anchor(n).copy(i).write('Change": (\n'),a?this.#S.copy(e.value).write("[`${\n").copy(e.member).write("\n}Change`] && ((\n// @ts-ignore\n_\n)=>{\n").copy(e.value).write("[`${\n").copy(e.member).write("\n}Change`](").copy(a).write("(_));\n})"):this.#S.copy(e.value).write("[`${\n").copy(e.member).write("\n}Change`]"),this.#S.write(")");else{const t={start:e.value.start,end:e.member.end};this.#S.copy(t).copy(e.types).write(`\n)${SEP_COMMA_NEW_LINE}"`).anchor(n).copy(i).write('Change": (\n'),a?this.#S.copy(t).write("Change && ((\n// @ts-ignore\n_\n)=>{\n").copy(t).write("Change(").copy(a).write("(_));\n})"):this.#S.copy(t).write("Change"),this.#S.write(")")}else{const r=this.#_(e.value);this.#S.copy(e.value).write(" ").copy(e.types).write(`\n)${SEP_COMMA_NEW_LINE}"`).anchor(n).copy(i).write(`Change"(\n// @ts-ignore\n_${r}\n) {\n${isMutatedVar(t.parent,r)?varLocal(`change__${r}.`):""}`).copy(e.value).write("= ").copy(a).write(`(_${r});\n}`)}else this.#ht(s.value),this.#S.write("\n");break}}else if(e.args)if(this.#S.write('"').copy(i).write('": '),this.#D===RuntimeAPI.class&&"string"!=typeof i&&this.#_(i).startsWith("on")){const t=this.#bt(REG_ATTR_ARG_LITERAL,e.args.value.start);if(t){const r=","===t[3],s=t[2],a=t.index;if(REG_OBJECT_PROPERTY.test(t[2])){const t=a+1;this.#S.write("component.").copy({start:t,end:t+s.length})}else this.#S.write("component[").copy({start:a,end:a+s.length+2}).write("]");r&&this.#S.write(".bind(component, ").copy({start:a+t[0].length,end:e.args.value.end}).write(")")}else this.#S.write(`${varShared("bind")}(component, \n`).copy(e.args.value).write("\n)")}else this.#S.copy(e.args);else this.#S.write('"').anchor(n).copy(i).write('": '+(a?'""':"true"));break}}this.#S.write(SEP_COMMA_NEW_LINE)}}return e}#Nt(t,e){const{staticAttrTags:r}=t;hasRestAttrTags(t)?(this.#S.write("..."),this.#Ct(t,e),this.#S.write(SEP_COMMA_NEW_LINE)):r&&this.#It(r[0])}#Ct(t,e){const{staticAttrTags:r,dynamicAttrTagParents:s}=t;r||1!==s.length||"for"!==s[0].nameText?(this.#S.write(`${varShared("attrTags")}(${e})([\n`),this.#Rt(t,e),this.#S.write("])")):this.#$t(s,e,"")}#Rt({staticAttrTags:t,dynamicAttrTagParents:e},r,s=0){if(t)for(let e=s;e<t.length;e++)this.#S.write("{\n"),this.#It(t[e]),this.#S.write(`}${SEP_COMMA_NEW_LINE}`);e&&this.#$t(e,r)}#It(t){for(const e of t)this.#S.write('"').anchor(e.name).write(`${this.#Mt(e)}": `),this.#mt(e,this.#Z(e)),this.#S.write(SEP_COMMA_NEW_LINE)}#Pt(t,e){const r=1===t.type?this.#Tt(t):this.#kt(t);let s=`...${varShared("givenAttrTags")}(`;for(const t in r)(null==e?void 0:e.some(e=>r[t].tags.includes(e)))||(this.#S.write(`${s}${JSON.stringify(t)}`),s=SEP_COMMA_SPACE);s===SEP_COMMA_SPACE&&this.#S.write(`)${SEP_COMMA_NEW_LINE}`)}#Lt(t){let e=getFirstAttrTag(t);const r=IF_TAG_ALTERNATES.get(t);if(!e&&r)for(const{node:t}of r)if(e=getFirstAttrTag(t))break;e&&this.#S.anchor(e.name)}#$t(t,e,r=SEP_COMMA_NEW_LINE){var s,a,n;for(const i of t){switch(i.nameText){case"if":{const t=IF_TAG_ALTERNATES.get(i),r=this.#ct(null==(s=i.args)?void 0:s.value)||this.#pt(i,ATTR_UNNAMED2);this.#z(i),this.#S.write("(("),r&&this.#Lt(i),this.#S.write("\n"),this.#ot(i,r),this.#S.write("\n) ? "),this.#Ot(i,e);let a=!0;if(t)for(const{node:r,condition:s}of t)this.#z(r),s?this.#S.write(": (\n").copy(s).write("\n) ? "):"else"===r.nameText?(a=!1,this.#S.write(": ")):(this.#S.write(": "),this.#ot(r,void 0),this.#S.write(" ? ")),this.#Ot(r,e);a&&this.#S.write(` : ${varShared("never")}`),this.#S.write(")");break}case"for":this.#S.write(`${varShared(getForAttrTagRuntime(this.#o,i))}(`),this.#Lt(i),this.#S.write("{\n").anchor(i.name),this.#dt(i),this.#S.write("\n}, \n"),this.#z(i),this.#S.copy(i.typeParams).write("(\n").copy(null==(a=i.params)?void 0:a.value).write("\n) => "),this.#Ot(i,e,!0),this.#S.write(")");break;case"while":this.#z(i),this.#S.write("(("),i.args&&this.#Lt(i),this.#S.write("\n"),this.#ot(i,this.#ct(null==(n=i.args)?void 0:n.value)),this.#S.write("\n) ? "),this.#Ot(i,e),this.#S.write(` : ${varShared("never")})`)}this.#S.write(r)}}#mt(t,e,r){var s;t.params||this.#z(t);const a=this.#vt(t),n=r?e:void 0;let i=!1,o=!0;if(a)i=!0,this.#S.copy(a.value),e||t.attrs||t.shorthandId||t.shorthandClassNames?this.#S.write(",\n{\n"):o=!1;else{if(this.#S.write("{\n"),n){const e=getInputStart(t);this.#S.anchor(void 0===e?t.name:{start:e,end:e})}t.args&&(i=!0,this.#S.write("[").copy({start:t.args.start,end:t.args.start+1}).write('"value"').copy({start:t.args.end-1,end:t.args.end}).write(`]: ${varShared("tuple")}(`).copy(t.args.value).write(")").write(",\n"))}this.#dt(t)&&(i=!0);let c=!1;if(isTextOnlyScript(t)?(this.#S.write(`async ${this.#D===RuntimeAPI.tags?"value":`[${varShared("never")}]`}(){`),this.#ht({start:t.body[0].start,end:t.body[t.body.length-1].end}),this.#S.write(`\n}${SEP_COMMA_NEW_LINE}`)):e?(n?e.staticAttrTags&&this.#It(e.staticAttrTags[0]):(i=!0,16===t.type&&hasRestAttrTags(e)&&this.#Pt(t,void 0),this.#Nt(e,a?varShared("any"):this.#Dt(t))),c=void 0!==e.content):t.close&&(c=!0),t.params||c){if(this.#S.write("[").anchor(t.name),this.#F){const e=this.#gt(16===t.type?t.owner:t);e?this.#S.write(`${varShared("contentFor")}(${e})`):this.#S.write(varShared("content"))}else this.#S.write('"content"');this.#S.write("]: "),t.params?(this.#S.write("("),this.#z(t),this.#S.copy(t.typeParams).write("(\n"),this.#ht(t.params.value),this.#S.write("\n) => {\n")):this.#S.write("(() => {\n");let r=!1;(null==e?void 0:e.content)&&(r=this.#tt(e.content)),t.params||this.#S.write("return () => {\n"),this.#st(r?varLocal("return"):void 0,t.body),(null==e?void 0:e.content)&&this.#rt(),t.params?this.#S.write("})"):this.#S.write("}\n})()"),this.#S.write(SEP_COMMA_NEW_LINE)}16===t.type&&this.#S.write("[").anchor(t.name).write(`Symbol.iterator]: ${varShared("any")}${SEP_COMMA_NEW_LINE}`),n&&(this.#S.write("[").anchor(t.name).write(`${varShared("restAttrTags")}]: [\n`),this.#Rt(n,this.#Dt(t),1),this.#S.write(`]${SEP_COMMA_NEW_LINE}`),this.#Pt(t,null==(s=n.staticAttrTags)?void 0:s[0])),i||this.#S.anchor(t.name),o&&this.#S.write("\n}")}#ft(t){this.#S.anchor(t.name,!0).write("default")}#vt(t){return t.args&&(this.#D===RuntimeAPI.tags||this.#St(t))?t.args:void 0}#Q(t){return"ts"===this.#j?`${varShared("any")} as ${t}`:`/** @type {${t}} */(${varShared("any")})`}#ht(t){const e=this.#G;if(!e)return this.#S.copy(t);const r=e.length;let s=t.start,a=0;for(;;){let n=r;for(;a<n;){const t=a+n>>>1;e[t].start>=s?n=t:a=t+1}const i=n!==r&&e[n];if(!i||i.start>=t.end)return void this.#S.copy({start:s,end:t.end});this.#S.copy({start:s,end:i.start}),this.#S.write(`${varLocal(`change__${i.binding.name}`)}.`),s=i.start,a=n+1}}#Z(t){var e;const{body:r}=t;if(!r)return;const s=r.length-1;let a,n,i,o,c=0;for(;c<=s;){const t=r[c++];switch(t.type){case 16:if(n){const e=i.get(t.nameText)||0;i.set(t.nameText,e+1),e<n.length?n[e].push(t):n.push([t])}else n=[[t]],i=new Map([[t.nameText,1]]);break;case 1:{let n=!1;switch(t.nameText){case"for":case"while":n||=t.hasAttrTags;break;case"if":{let a;n||=t.hasAttrTags;t:for(;c<=s;){const t=r[c++];switch(t.type){case 17:if(this.#Ft(t))continue t;break;case 1:switch(t.nameText){case"else-if":{const r={condition:this.#ct(null==(e=t.args)?void 0:e.value)||this.#pt(t,ATTR_UNNAMED2),node:t};n||=t.hasAttrTags,a?a.push(r):a=[r];continue t}case"else":{const e={condition:this.#pt(t,"if"),node:t};if(n||=t.hasAttrTags,a?a.push(e):a=[e],e.condition)continue t;break t}}}c--;break}IF_TAG_ALTERNATES.set(t,a)}}n?o?o.push(t):o=[t]:a?a.push(t):a=[t];break}case 17:this.#Ft(t)||(a?a.push(t):a=[t]);break;default:a?a.push(t):a=[t]}}return a||n||o?{content:a,staticAttrTags:n,dynamicAttrTagParents:o}:void 0}#Ot(t,e,r){const s=this.#Z(t);(null==s?void 0:s.content)&&(this.#S.write(r?"{\n":"(() => {\n"),this.#tt(s.content),this.#S.write("return ")),(null==s?void 0:s.staticAttrTags)||(null==s?void 0:s.dynamicAttrTagParents)?r||s.content?this.#Ct(s,e):(this.#S.write("{\n"),this.#Nt(s,e),this.#S.write("}")):this.#S.write(r?(null==s?void 0:s.content)?"{}":"({})":varShared("never")),(null==s?void 0:s.content)&&(this.#rt(),this.#S.write(r?";\n}":";\n})()"))}#pt(t,e){if(t.attrs)for(const r of t.attrs)if(isValueAttribute(r)&&(this.#_(r.name)||ATTR_UNNAMED2)===e)return r.value.value}#ct(t){if(!t)return;const{start:e}=t;let r=t.end-1;for(;r>=e;){if(!isWhitespaceCode(this.#t.charCodeAt(r))){if(","===this.#t.charAt(r))return{start:e,end:r};break}r--}return t}#Ft(t){let e=t.start;for(;e<t.end;){if(!isWhitespaceCode(this.#t.charCodeAt(e)))return!1;e++}return!0}#X(t){return"ts"===this.#j?this.#Vt(t):this.#Bt(t)}#Vt(t){var e;for(const r of t.static)if(25===r.type){if(this.#Y(REG_INPUT_TYPE,r.start+7)){this.#W=!0;const t=this.#V.export(r),s=null==t?void 0:t.declaration;return{typeParameters:null==(e=null==s?void 0:s.typeParameters)?void 0:e.params.map(t=>({name:t.name,constraint:t.constraint?this.#_(t.constraint):void 0,default:t.default?this.#_(t.default):void 0}))}}}else if(24===r.type){const t=this.#V.import(r);if(t)for(const e of t.specifiers)if("Input"===e.local.name)return{typeParameters:void 0}}}#Bt(t){return this.#jt(t.static)||this.#jt(t.body)||this.#Gt(t)}#jt(t){for(const e of t){const t=this.#Gt(e);if(t)return t}}#Gt(t){const e=t.comments;if(e)for(const t of e)if("*"===this.#t.charAt(t.start+1)){const e=getJSDocInputType(this.#_(t));if(e)return this.#W=!0,WROTE_COMMENT.add(t),this.#S.write("/*").copy(t.value).write("*/"),e}}#St(t){if(1===t.name.expressions.length&&isEmptyRange2(t.name.quasis[0])&&isEmptyRange2(t.name.quasis[1]))return t.name.expressions[0].value}#it(t,e=!1){let r=RENDER_VAR.get(t);return!r&&e&&RENDER_VAR.set(t,r=varLocal("rendered_"+this.#Wt(t))),r}#gt(t,e=!1){let r=TEMPLATE_VAR.get(t);return!r&&e&&TEMPLATE_VAR.set(t,r=varLocal("tag_"+this.#Wt(t))),r}#Wt(t){let e=TAG_ID.get(t);return void 0===e&&(e=this.#H++,TAG_ID.set(t,e)),e}#at(t){return!(!getHoistSources(t)&&!this.#et(t))}#nt(t){const e=getHoistSources(t),r=this.#et(t);if(!e)return void(r&&this.#S.write(r));this.#S.write("{ "+(r?`...${r}, `:""));let s=SEP_EMPTY;for(const t of e)this.#S.write(s).copy(t.range),s=SEP_COMMA_SPACE;this.#S.write(" }")}#et(t){let e;if(t)for(const r of t)if(1===r.type){const t=this.#it(r);!t||r.var&&!hasHoists(r)||(e?e.push(t):e=[t])}if(e)return 1===e.length?`${varShared("readScope")}(${e[0]})`:`${varShared("readScopes")}({ ${e.join(SEP_COMMA_SPACE)} })`}#Et(t){const e=t.name.start,r=t.name.end;for(let t=r-1;t-- >e;)if(":"===this.#t.charAt(t))return{start:t+1,end:r}}#_t(t){var e;if(t)for(const r of t)if(10===r.type&&!r.args&&13===(null==(e=r.value)?void 0:e.type)&&!r.value.bound&&"class"===this.#_(r.name))return r}#Mt(t){var e;const{nameText:r}=t;return(null==(e=this.#B.getTag(r))?void 0:e.targetProperty)||r.slice(r.lastIndexOf(":")+1)}#Ht(t){let e=`"${this.#Mt(t)}"`,r=t.parent;for(;r;){if(16===r.type)e=`"${this.#Mt(r)}",${e}`;else if(!isControlFlowTag(r))break;r=r.parent}return e}#Dt(t){if(16===t.type){const e=t.owner&&this.#gt(t.owner);return e?`${e},${this.#Ht(t)}`:varShared("any")}return this.#gt(t)||varShared("any")}#xt(t,e,r){this.#S.write(`${varShared(r?"nestedAttrTagNames":"attrTagNames")}(${e},input=>{\n`);for(const e in t){const{tags:r,nested:s}=t[e];for(const t of r)this.#S.write('input["').copy(t.name).write('"];\n');s&&this.#xt(s,`input["@${e}"]`,!0)}this.#S.write("});")}#Tt(t){return this.#U.has(t)||this.#U.set(t,this.#kt(t)),this.#U.get(t)}#kt(t,e){if(!t.hasAttrTags||!t.body)return e;const r=e||{};for(const e of t.body)switch(e.type){case 16:{const t=this.#Mt(e),s=r[t];s?(s.tags.push(e),s.nested=this.#kt(e,s.nested)):r[t]={tags:[e],nested:this.#kt(e)};break}case 1:isControlFlowTag(e)&&this.#kt(e,r)}return r}#Y(t,e){return t.lastIndex=e,t.test(this.#t)}#bt(t,e){return t.lastIndex=e,t.exec(this.#t)}};function getForTagType(t,e){if(e.attrs)for(const r of e.attrs){if(15===r.type)return 0;switch(t.read(r.name)){case"of":return 1;case"in":return 2;case"to":return 3;case"until":return 4}}return 0}function getForTagRuntime(t,e){switch(getForTagType(t,e)){case 1:return"forOfTag";case 2:return"forInTag";case 3:return"forToTag";case 4:return"forUntilTag";default:return"forTag"}}function getForAttrTagRuntime(t,e){switch(getForTagType(t,e)){case 1:return"forOfAttrTag";case 2:return"forInAttrTag";case 3:return"forToAttrTag";case 4:return"forUntilAttrTag";default:return"forAttrTag"}}function getFirstAttrTag(t){if(t.body)for(const e of t.body){if(16===e.type)return e;if(1===e.type&&e.hasAttrTags&&isControlFlowTag(e)){const t=getFirstAttrTag(e);if(t)return t}}}function getInputStart(t){var e,r,s;return minStart(minStart(minStart(null==(r=null==(e=t.attrs)?void 0:e[0])?void 0:r.start,t.args),t.shorthandId),null==(s=t.shorthandClassNames)?void 0:s[0])}function minStart(t,e){return e&&(void 0===t||e.start<t)?e.start:t}function hasRestAttrTags({staticAttrTags:t,dynamicAttrTagParents:e}){return!!(e||t&&t.length>1)}function varLocal(t){return VAR_LOCAL_PREFIX+t}function varShared(t){return VAR_SHARED_PREFIX+t}function getReturnTag(t){if(t.body)for(const e of t.body)if(1===e.type&&"return"===e.nameText)return e}function isValueAttribute(t){var e;return 10===t.type&&13===(null==(e=t.value)?void 0:e.type)}function resolveTagImport(t,e){const r=resolveTagFile(e);if(!e||!r)return;if(!t)return r;const s=normalizePath(r);return packageImportPath(t,e,s)||(0,import_relative_import_path.relativeImportPath)(t,s)}function packageImportPath(t,e,r){const{packageName:s,packageRoot:a}=e;if(!s||!a||!REG_NODE_MODULES.test(r))return;if(!isWithin(a,r)||isWithin(a,t))return;return`${s}/${import_path3.default.relative(a,r).split(import_path3.default.sep).join("/")}`}function isWithin(t,e){const r=import_path3.default.relative(t,e);return!!r&&".."!==r&&!r.startsWith(`..${import_path3.default.sep}`)&&!import_path3.default.isAbsolute(r)}function resolveTagFile(t){return t&&(t.types||t.template||t.renderer)}function isWhitespaceCode(t){return t<=32}function stripExt(t){return t.replace(REG_EXT,"")}function removeNewLines(t){return t.replace(REG_NEW_LINE," ")}function isEmptyRange2(t){return t.start===t.end}function extractStyle(t){const{parsed:e,lookup:r}=t,s=new Map,{read:a,program:n,code:i}=e;let o=0;for(const t of n.static)27===t.type&&d(t.ext||".css").copy(t.value);for(const t of n.body)p(t);const c=new Map;for(const[t,e]of s)c.set(t,e.end());return c;function p(t){var e,s;switch(t.type){case 16:if(t.body)for(const e of t.body)p(e);break;case 1:if(t.body)if("style"===t.nameText){const e=t.shorthandClassNames?a(t.shorthandClassNames.at(-1)):".css";for(const r of t.body)switch(r.type){case 17:d(e).copy(r);break;case 22:d(e).write(`var(--_${o++})`)}}else for(const e of t.body)p(e);if(t.attrs)for(const n of t.attrs)if(10===n.type&&13===(null==(e=n.value)?void 0:e.type)&&/^['"]$/.test(i[n.value.value.start])){const e=a(n.name);("#style"===e||"style"===e&&t.nameText&&(null==(s=r.getTag(t.nameText))?void 0:s.html))&&d(".css").write(":root{").copy({start:n.value.value.start+1,end:n.value.value.end-1}).write("}")}}}function d(t){let r=s.get(t);return r||s.set(t,r=new Extractor(e)),r}}var processors_exports={};function getExt(t){const e=t.lastIndexOf(".");if(-1!==e)return t.slice(e)}__export(processors_exports,{create:()=>create,extensions:()=>extensions,getProcessorExtension:()=>getProcessorExtension,has:()=>has,isCSSModule:()=>isCSSModule});var css_module_default={extensions:[".module.css",".module.scss",".module.less"],create:({ts:t})=>({getScriptExtension:()=>t.Extension.Ts,getScriptKind:()=>t.ScriptKind.TS,extract:(t,e)=>extractCSSModule({code:e,fileName:t}),print:({extracted:t})=>({code:t.toString()}),printTypes({sourceFile:e,printer:r}){let s="";for(const a of e.statements)s+=r.printNode(t.EmitHint.Unspecified,a,e)+"\n";return{code:s}}})},import_path5=__toESM(require("path")),project_exports={};__export(project_exports,{clearCaches:()=>clearCaches,getCache:()=>getCache,getCompiler:()=>getCompiler,getConfig:()=>getConfig,getScriptLang:()=>getScriptLang,getTagLookup:()=>getTagLookup,getTypeLibs:()=>getTypeLibs,setDefaultCompilerMeta:()=>setDefaultCompilerMeta,setDefaultTypePaths:()=>setDefaultTypePaths});var import_module=require("module"),import_path4=__toESM(require("path")),import_url=require("url"),TAB=9,LF=10,CR=13,STAR=42,SLASH=47,BACKSLASH=92,SPACES=" ".repeat(128);function stripComments(t){let e=t.indexOf("/");if(-1===e)return t;let r=nextQuote(t,0),s="",a=0;for(;-1!==e;){for(;-1!==r&&r<e;){const s=nextQuote(t,r+1);if(-1===s){e=-1;break}s>e&&(e=t.indexOf("/",s+1)),r=nextQuote(t,s+1)}if(-1===e)break;let n;const i=t.charCodeAt(e+1);if(i===SLASH)n=t.indexOf("\n",e+2),-1===n&&(n=t.length);else{if(i!==STAR){e=t.indexOf("/",e+1);continue}if(n=t.indexOf("*/",e+2),-1===n)break;n+=2}s+=t.slice(a,e)+blank(t,e,n),a=n,e=t.indexOf("/",n),-1!==r&&r<n&&(r=nextQuote(t,n))}return a?s+t.slice(a):t}function nextQuote(t,e){let r=t.indexOf('"',e);for(;-1!==r&&isEscaped(t,r);)r=t.indexOf('"',r+1);return r}function isEscaped(t,e){let r=e;for(;t.charCodeAt(r-1)===BACKSLASH;)r--;return(e-r)%2==1}function blank(t,e,r){let s="",a=e;for(let n=e;n<r;n++){const e=t.charCodeAt(n);e!==TAB&&e!==LF&&e!==CR||(s+=spaces(n-a)+t[n],a=n+1)}return s+spaces(r-a)}function spaces(t){return t<=SPACES.length?SPACES.slice(0,t):" ".repeat(t)}var defaultMeta,shippedInternalTypesFile=import_path4.default.join(import_path4.default.dirname((0,import_url.fileURLToPath)(_importMetaUrl)),"../marko.internal.d.ts"),defaultTypeLibs={},ignoreErrors=t=>{},metaByDir=new Map,metaByTranslator=new Map;function getCompiler(t){return getMeta(t).compiler}function getCache(t){return getMeta(t).config.cache}function getConfig(t){return getMeta(t).config}function getTagLookup(t){return getTagLookupForProject(getMeta(t),t)}function getTypeLibs(t,e,r){const s=getConfig(t);let a=s.cache.get(getTypeLibs);if(a)return a;const n={moduleResolution:e.ModuleResolutionKind.Bundler},i=import_path4.default.join(t,".marko-run/routes.d.ts"),o=import_path4.default.join(t,"_.d.ts"),c=s.translator.runtimeTypes||"marko",p=defaultTypeLibs.internalTypesFile||shippedInternalTypesFile,{resolvedTypeReferenceDirective:d}=e.resolveTypeReferenceDirective(c,o,n,r),{resolvedTypeReferenceDirective:h}=e.resolveTypeReferenceDirective("@marko/run",o,n,r),l=(null==d?void 0:d.resolvedFileName)||defaultTypeLibs.markoTypesFile,u=null==h?void 0:h.resolvedFileName;if(!l)throw new Error(`Could not resolve the "${c}" types from ${t}.`);if(!r.fileExists(p))throw new Error(`Could not find the marko internal types at ${p}.`);return s.cache.set(getTypeLibs,a={internalTypesFile:p,markoTypesFile:l,markoTypesCode:r.readFile(l)||"",markoRunTypesFile:u,markoRunGeneratedTypesFile:r.fileExists(i)?i:void 0}),a}function getScriptLang(t,e,r,s){if(t.endsWith(".d.marko"))return"ts";const a=import_path4.default.dirname(t),n=getConfig(a),i=n.cache.get(getScriptLang);let o=null==i?void 0:i.get(a);if(!o){const t=r.findConfigFile(a,s.fileExists.bind(s),"marko.json");if(t)try{const e=s.readFile(t);if(e){const t=tryParseJSONWithComments(e);if(t){const e=t["script-lang"]||t.scriptLang;void 0!==e&&(o="ts"===e?"ts":"js")}}}catch{}void 0===o&&(o=/[/\\]node_modules[/\\]/.test(a)?"js":e),i?i.set(a,o):n.cache.set(getScriptLang,new Map([[a,o]]))}return o}function clearCaches(){defaultMeta&&clearCacheForMeta(defaultMeta);for(const t of metaByTranslator.values())clearCacheForMeta(t)}function setDefaultTypePaths(t){Object.assign(defaultTypeLibs,t)}function setDefaultCompilerMeta(t,e){const{translator:r}=e;if("object"!=typeof r)throw new Error("Translator must be fully resolved and loaded.");defaultMeta={compiler:t,config:{...e,cache:new Map,translator:r}},t.configure(defaultMeta.config)}function getMeta(t){if(!t){if(!defaultMeta)throw new Error("@marko/compiler must be installed or compiler registered.");return defaultMeta}if(defaultMeta)try{return loadMeta(t)}catch{return metaByDir.set(t,defaultMeta),defaultMeta}return loadMeta(t)}function loadMeta(t){let e=metaByDir.get(t);if(!e){const r=(0,import_module.createRequire)(import_path4.default.join(t,"_.js")),s=(()=>{try{return r.resolve("@marko/compiler/config")}catch{return(0,import_module.createRequire)(r.resolve("marko/package.json")).resolve("@marko/compiler/config")}})(),a=interopDefault(r(s)),n=r.resolve(a.translator);if(e=metaByTranslator.get(n),!e){const t=r(import_path4.default.dirname(s));e={compiler:t,config:{...a,cache:new Map,translator:r(n)}},t.configure(e.config),metaByTranslator.set(n,e)}metaByDir.set(t,e)}return e}function getTagLookupForProject(t,e){const r=t.config.cache.get(getTagLookupForProject);let s=null==r?void 0:r.get(e);if(void 0===s){try{s=t.compiler.taglib.buildLookup(e,t.config.translator,ignoreErrors)}catch{t!==defaultMeta&&(s=getTagLookupForProject(getMeta(),e))}r?r.set(e,s):t.config.cache.set(getTagLookupForProject,new Map([[e,s]]))}return s}function clearCacheForMeta(t){t.config.cache.clear(),t.compiler.taglib.clearCaches()}function tryParseJSONWithComments(t){try{return JSON.parse(stripComments(t))}catch{return}}function interopDefault(t){return t.default||t}var isRemapExtensionReg=/\.ts$/,skipRemapExtensionsReg=/\.(?:[cm]?jsx?|json|marko|css|less|sass|scss|styl|stylus|pcss|postcss|sss|a?png|jpe?g|jfif|pipeg|pjp|gif|svg|ico|web[pm]|avif|mp4|ogg|mp3|wav|flac|aac|opus|woff2?|eot|[ot]tf|webmanifest|pdf|txt)$/,markoProcessor={extensions:[".marko"],create({ts:t,host:e,configFile:r}){const s=e.getCurrentDirectory?e.getCurrentDirectory():t.sys.getCurrentDirectory(),a=r&&/tsconfig/.test(r)?"ts":"js",n=getTypeLibs(s,t,e),i=[n.internalTypesFile,n.markoTypesFile],o=(t,r)=>e.fileExists(import_path5.default.join(r,"..",`${t}.ts`))&&`${t}.js`,c={output:"source",stripTypes:!0,sourceMaps:!0,babelConfig:{babelrc:!1,configFile:!1,browserslistConfigFile:!1,plugins:[{visitor:{"ImportDeclaration|ExportNamedDeclaration"(t){var e;const{node:r}=t,s=null==(e=r.source)?void 0:e.value,a="importKind"in r?r.importKind:void 0;if(!("."!==(null==s?void 0:s[0])||a&&"value"!==a||skipRemapExtensionsReg.test(s))){const e=t.hub.file.opts.filename,a=isRemapExtensionReg.test(s)?`${s.slice(0,-2)}js`:o(s,e)||o(`${s}/index`,e);a&&(r.source.value=a)}}}}],caller:{name:"@marko/type-check",supportsStaticESM:!0,supportsDynamicImport:!0,supportsTopLevelAwait:!0,supportsExportNamespaceFrom:!0}}};return n.markoRunTypesFile&&i.push(n.markoRunTypesFile),n.markoRunGeneratedTypesFile&&i.push(n.markoRunGeneratedTypesFile),{getRootNames:()=>i,getScriptExtension:r=>"ts"===getScriptLang(r,a,t,e)?t.Extension.Ts:t.Extension.Js,getScriptKind:r=>"ts"===getScriptLang(r,a,t,e)?t.ScriptKind.TS:t.ScriptKind.JS,extract(r,s){const n=parse(s,r),i=import_path5.default.dirname(n.filename);return extractScript({ts:t,parsed:n,translator:getConfig(i).translator,lookup:getTagLookup(i),scriptLang:getScriptLang(r,a,t,e)})},print({extracted:{parsed:t}}){const{code:e,map:r}=getCompiler(import_path5.default.dirname(t.filename)).compileSync(t.code,t.filename,c);return{code:e,map:r}},printTypes({printer:e,typeChecker:r,sourceFile:s,formatSettings:a}){var n,i,o;let c="";const y=a.newLineCharacter,T=a.convertTabsToSpaces?" ".repeat(a.indentSize):"\t";let x,w,v,A;for(const e of s.statements)t.isExportAssignment(e)?(x=e,w=t.isIdentifier(e.expression)?e.expression.text:void 0):t.isClassDeclaration(e)&&"Component"===(null==(n=e.name)?void 0:n.escapedText)?v=e:t.isFunctionDeclaration(e)&&"___marko_internal_template"===(null==(i=e.name)?void 0:i.escapedText)&&(A=e);for(const r of s.statements){if(r===x||r===v||r===A||l(r)||g(r)||p(r)||h(r)||d(r)||u(r)||m(r)||w&&f(r,w))continue;const a=e.printNode(t.EmitHint.Unspecified,r,s);/^(?:import|export) /.test(a)||(c+="static "),c+=a+y}if(null==v?void 0:v.members.length){c+=`class {${y}`;for(const r of v.members)t.isPropertyDeclaration(r)?c+=`${T}declare ${e.printNode(t.EmitHint.Unspecified,r,s)+y}`:t.isMethodDeclaration(r)||t.isGetAccessorDeclaration(r)||t.isSetAccessorDeclaration(r)?c+=`${T+e.printNode(t.EmitHint.Unspecified,r,s).replace(/;\s*$/,"")} { return ${castType("any")}; }${y}`:t.isIndexSignatureDeclaration(r)&&(c+=T+e.printNode(t.EmitHint.Unspecified,r,s)+y);c+=`}${y}`}const S=function(e){var r;for(const s of e.statements)if(t.isFunctionDeclaration(s)&&"___marko_internal_template"===(null==(r=s.name)?void 0:r.escapedText))return s}(t.getOriginalNode(s));if(S){const t=null==(o=r.getSignatureFromDeclaration(S))?void 0:o.getReturnType();if(t){const e=t.getProperties(),s=1===e.length&&"value"===e[0].name&&r.getPropertyOfType(t,"value")||void 0;c+="<return ",c+=s?`= ${castType(r.typeToString(r.getTypeOfSymbol(s)))}`:`...${castType(r.typeToString(t))}`,c+=`/>${y}`}}return{code:c}}};function p(e){var r,s;return t.isImportDeclaration(e)&&"Component"===(null==(s=null==(r=e.importClause)?void 0:r.name)?void 0:s.escapedText)}function d(e){return t.isTypeAliasDeclaration(e)&&"Input"===e.name.escapedText&&t.isIndexedAccessTypeNode(e.type)&&t.isTypeReferenceNode(e.type.objectType)&&t.isIdentifier(e.type.objectType.typeName)&&"Component"===e.type.objectType.typeName.escapedText&&t.isLiteralTypeNode(e.type.indexType)&&t.isStringLiteral(e.type.indexType.literal)&&"input"===e.type.indexType.literal.text}function h(e){return t.isTypeAliasDeclaration(e)&&"Input"===e.name.escapedText&&t.isTypeLiteralNode(e.type)&&!e.typeParameters&&0===e.type.members.length||t.isInterfaceDeclaration(e)&&"Input"===e.name.escapedText&&!e.heritageClauses&&!e.typeParameters&&0===e.members.length}function l(e){var r;return t.isClassDeclaration(e)&&"Template"===(null==(r=e.name)?void 0:r.escapedText)||f(e,"Template_base")}function u(t){return f(t,INTERNAL_API_VAR)}function m(e){if(!t.isExportDeclaration(e)||e.moduleSpecifier||!e.exportClause||!t.isNamedExports(e.exportClause)||1!==e.exportClause.elements.length)return!1;const[{name:r,propertyName:s}]=e.exportClause.elements;return(t.isStringLiteral(r)||t.isIdentifier(r))&&r.text===INTERNAL_API_EXPORT_NAME&&!!s&&t.isIdentifier(s)&&s.text===INTERNAL_API_VAR}function g(e){return t.isExportDeclaration(e)?e.exportClause&&t.isNamedExports(e.exportClause)&&1===e.exportClause.elements.length&&t.isIdentifier(e.exportClause.elements[0].name)&&"Component"===e.exportClause.elements[0].name.escapedText:!!t.isTypeAliasDeclaration(e)&&"Component"===e.name.text}function f(e,r){if(t.isVariableStatement(e))for(const s of e.declarationList.declarations)if(t.isIdentifier(s.name)&&s.name.text===r)return!0}}},marko_default=markoProcessor;function castType(t){return"any"===t?"1 as any":`(1 as any as ${t})`}var configs=[marko_default,css_module_default],simpleExtensions=new Set,compoundExtensions=[];for(const t of configs)for(const e of t.extensions)-1===e.indexOf(".",1)?simpleExtensions.add(e):compoundExtensions.push(e);var cssModuleExtensions=new Set(css_module_default.extensions),extensions=configs.flatMap(t=>t.extensions);function create(t){const e={};for(const r of configs){const s=r.create(t);for(const t of r.extensions)e[t]=s}return e}function getProcessorExtension(t){const e=getExt(t);if(e&&simpleExtensions.has(e))return e;if(compoundExtensions.length){const e=t.toLowerCase();for(const t of compoundExtensions)if(e.endsWith(t))return t}}function has(t){return void 0!==getProcessorExtension(t)}function isCSSModule(t){const e=getProcessorExtension(t);return void 0!==e&&cssModuleExtensions.has(e)}function isDefinitionFile(t){return/\.d\.[^.]+$/.test(t)}
//# sourceMappingURL=/sm/0c0649a0cbc6e61ad719d6875945a77d0a2deab6ef5c56fb24c5d0bd2aea2e25.map