sveld 0.36.9 → 0.36.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import{$ as Tt,A as B,B as J,C as Ve,E as ke,H as lt,I as U,J as dt,K as N,L as z,M as ut,N as ie,O as ae,P as Oe,R as mt,S as ft,T as yt,U as gt,V as $e,W as Ge,X as Ke,Y as ye,Z as Je,_ as ze,ba as bt,ca as We,da as et,ea as xt,fa as ht,ga as Ce,ha as tt,ja as nt,ka as W,la as Xe,ma as St,u as _,w as Re,x as ct,y as be,z as pt}from"./chunk-py1s51tb.js";import{oa as Et}from"./chunk-d802cqsd.js";var Le={a:"HTMLAnchorElement",abbr:"HTMLElement",address:"HTMLElement",applet:"HTMLUnknownElement",area:"HTMLAreaElement",article:"HTMLElement",aside:"HTMLElement",audio:"HTMLAudioElement",b:"HTMLElement",base:"HTMLBaseElement",basefont:"HTMLElement",bdi:"HTMLElement",bdo:"HTMLElement",blockquote:"HTMLQuoteElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",cite:"HTMLElement",code:"HTMLElement",col:"HTMLTableColElement",colgroup:"HTMLTableColElement",data:"HTMLDataElement",datalist:"HTMLDataListElement",dd:"HTMLElement",del:"HTMLModElement",details:"HTMLDetailsElement",dfn:"HTMLElement",dialog:"HTMLDialogElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",dt:"HTMLElement",em:"HTMLElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",figcaption:"HTMLElement",figure:"HTMLElement",font:"HTMLFontElement",footer:"HTMLElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",h2:"HTMLHeadingElement",h3:"HTMLHeadingElement",h4:"HTMLHeadingElement",h5:"HTMLHeadingElement",h6:"HTMLHeadingElement",head:"HTMLHeadElement",header:"HTMLElement",hgroup:"HTMLElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",i:"HTMLElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",ins:"HTMLModElement",kbd:"HTMLElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",main:"HTMLElement",map:"HTMLMapElement",mark:"HTMLElement",marquee:"HTMLMarqueeElement",menu:"HTMLMenuElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",nav:"HTMLElement",noscript:"HTMLElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",picture:"HTMLPictureElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",rp:"HTMLElement",rt:"HTMLElement",ruby:"HTMLElement",s:"HTMLElement",samp:"HTMLElement",script:"HTMLScriptElement",search:"HTMLElement",section:"HTMLElement",select:"HTMLSelectElement",slot:"HTMLSlotElement",small:"HTMLElement",source:"HTMLSourceElement",span:"HTMLSpanElement",strong:"HTMLElement",style:"HTMLStyleElement",sub:"HTMLElement",summary:"HTMLElement",sup:"HTMLElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",td:"HTMLTableCellElement",template:"HTMLTemplateElement",textarea:"HTMLTextAreaElement",tfoot:"HTMLTableSectionElement",th:"HTMLTableCellElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",u:"HTMLElement",ul:"HTMLUListElement",var:"HTMLElement",video:"HTMLVideoElement",wbr:"HTMLElement"};function Pt(e){return e in Le}function we(e){if(Pt(e))return Le[e];return"HTMLElement"}function Ee(){return{syntaxMode:"legacy",scriptLanguage:void 0,source:void 0,parsed:void 0,runesOptionOverride:void 0,sourceLineStartOffsetsCache:void 0,rest_props:void 0,extends:void 0,customElementTag:void 0,componentComment:void 0,componentCommentSource:void 0,generics:null,scriptGenericsAttribute:void 0,diagnosticRecords:[],componentFilePath:"",props:new Map,moduleExports:new Map,propLocalToPublicName:new Map,reactive_vars:new Set,funcDecls:new Map,vars:new Set,valueImportBindingsByLocalName:new Map,pendingCallDefaultCandidates:[],pendingContextKeyCandidates:[],runesPropsDeclarationMetadataByDeclaratorStart:new Map,typedRunesPropsDeclarations:[],explicitPropTypesByName:new Map,explicitVariableTypesByName:new Map,typeImportBindingsByLocalName:new Map,localTypeDeclarationsByName:new Map,wholePropsLocals:new Set,restPropLocals:new Set,componentScope:new Map,scopeDeclarations:new WeakMap,activeScopes:[],slots:new Map,snippetPropLocals:new Set,deferredSlotBlockGenerics:[],events:new Map,eventDescriptions:new Map,forwardedEvents:new Map,jsDocEventNames:new Set,jsDocEventSources:new Map,bindings:new Map,contexts:new Map,typedefs:new Map,variableInfoCache:new Map,variableInfoCacheBuilt:!1}}var vt=new Set(["Component","SvelteComponent","SvelteSelf"]),Mt=new Set(["RegularElement","SvelteElement"]);function te(e){return vt.has(e)}function ne(e){return Mt.has(e)}function Dt({hasTypeScriptType:e,hasJSDocType:t,inferredType:n,finalType:r}){if(e)return"typescript";if(t)return"jsdoc";if(n!==void 0)return"default";if(r!==void 0)return"inferred";return"unknown"}function re(e){let t=e.explicitType??e.jsdocType??e.resolvedType??e.typeSeed,n=e.jsdocParams??e.resolvedParams,r=e.jsdocReturnType??e.resolvedReturnType;if(e.isFunctionDeclaration&&t==="() => any"&&r)t=n&&n.length>0?`(${n.map((c)=>`${c.name}${c.optional?"?":""}: ${c.type}`).join(", ")}) => ${r}`:`() => ${r}`;let i=e.jsdocDescription??e.resolvedDescription;if(i===void 0&&t!==void 0)i=e.typedefs?.get(t)?.description;let p=Dt({hasTypeScriptType:e.explicitType!==void 0,hasJSDocType:e.jsdocType!==void 0||e.jsdocParams!==void 0||e.jsdocReturnType!==void 0||e.resolvedType!==void 0,inferredType:e.inferredTypeForSource,finalType:t}),s=e.initializerIsFunction||e.isFunctionDeclaration||e.inferIsFunctionFromTypeSignature===!0&&(!!e.jsdocParams?.length||e.jsdocReturnType!==void 0||!!e.jsdocType?.includes("=>")||!!e.resolvedType?.includes("=>")||!!e.explicitType?.includes("=>"));return{type:t,typeSource:p,description:i,params:n,returnType:r,isFunction:s}}function Ct(e){if(!e||typeof e!=="object"||!("type"in e))return;let t=String(e.type),n=te(t);if(!n&&!ne(t))return;let r="name"in e&&typeof e.name==="string"?e.name:void 0;if(!r)return;let i=n?{type:"InlineComponent",name:r}:{type:"Element",name:r};if(r==="svelte:element"&&"tag"in e&&e.tag&&typeof e.tag==="object"){let p=e.tag;if(p.type==="Literal"&&typeof p.value==="string")i.thisValue=p.value}return i}function Ne(e,t){if(e.rest_props!==void 0)return;let n=Ct(t);if(n)e.rest_props=n}function k(e,t,n){if(!t||e.has(t))return;e.set(t,n)}function ue(e,t){for(let n=e.activeScopes.length-1;n>=0;n-=1){let r=e.activeScopes[n]?.get(t);if(!r)continue;return r.kind==="prop"?r.publicPropName:void 0}return}function M(e,t=new Set){if(!e||typeof e!=="object"||!("type"in e))return t;switch(e.type){case"Identifier":t.add(e.name);break;case"AssignmentPattern":M(e.left,t);break;case"ArrayPattern":for(let n of e.elements)M(n??void 0,t);break;case"ObjectPattern":for(let n of e.properties)if(n.type==="Property")M(n.value,t);else if(n.type==="RestElement")M(n.argument,t);break;case"RestElement":M(e.argument,t);break}return t}function ve(e,t){let n=M(t);if(!n)return;for(let r of n){let i=ue(e,r);if(i)e.reactive_vars.add(i)}}function me(e){if(!e||typeof e!=="object"||!("type"in e))return!1;switch(String(e.type)){case"BlockStatement":case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"CatchClause":case"EachBlock":case"AwaitBlock":return!0;default:return!1}}function Ae(e){if(!e||typeof e!=="object"||!("type"in e))return!1;let t=String(e.type);return t==="FunctionDeclaration"||t==="FunctionExpression"||t==="ArrowFunctionExpression"}function kt(e,t){let n=e.scopeDeclarations.get(t);if(!n)n=new Map,e.scopeDeclarations.set(t,n);return n}function Lt(e,t,n){let r=[];if(n.id.type==="Identifier")return r.push({kind:"local",name:n.id.name}),r;if(n.id.type!=="ObjectPattern")return r;for(let i of n.id.properties){if(i.type==="RestElement"){if(i.argument.type==="Identifier")r.push({kind:"local",name:i.argument.name});continue}if(i.computed)continue;let p=e.getPropertyName(i.key);if(!p)continue;let s;if(i.value.type==="Identifier")s=i.value.name;else if(i.value.type==="AssignmentPattern"&&i.value.left.type==="Identifier")s=i.value.left.name;if(!s)continue;r.push({kind:"prop",name:s,publicPropName:p})}return r}function Pe(e,t,n,r,i){if(!Re(t))return;let p=i?.allowRunesProps??!1,s=i?.forceProp??!1,c=t;for(let d of c.declarations){if(p&&B(J(d.init),"$props")){for(let x of Lt(e,c,d))k(x.kind==="prop"?n:r,x.name,x.kind==="prop"?{kind:"prop",publicPropName:x.publicPropName}:{kind:"local"});continue}let f=c.kind==="var"?r:n,y=s?"prop":"local";for(let x of M(d.id))k(f,x,y==="prop"?{kind:"prop",publicPropName:x}:{kind:"local"})}}function wt(e,t){if("id"in e&&e.id&&typeof e.id==="object"&&"name"in e.id&&typeof e.id.name==="string")k(t,e.id.name,{kind:"local"});for(let n of e.params)for(let r of M(n))k(t,r,{kind:"local"})}function Nt(e,t,n,r){if(!Array.isArray(t))return;for(let i of t){if(!i||typeof i!=="object"||!("type"in i))continue;switch(i.type){case"VariableDeclaration":Pe(e,i,n,r);break;case"FunctionDeclaration":if(i.id?.name)k(n,i.id.name,{kind:"local"});break;case"ClassDeclaration":if(i.id?.name)k(n,i.id.name,{kind:"local"});break}}}function Rt(e,t,n){if(!n||typeof n!=="object")return;let r="content"in n&&n.content&&typeof n.content==="object"&&"body"in n.content&&Array.isArray(n.content.body)?n.content:("body"in n)&&Array.isArray(n.body)?n:void 0;if(!r||!("body"in r)||!Array.isArray(r.body))return;for(let i of r.body){if(!i||typeof i!=="object"||!("type"in i))continue;switch(i.type){case"ImportDeclaration":for(let p of i.specifiers??[])if(p.local?.name)k(t.componentScope,p.local.name,{kind:"local"});break;case"VariableDeclaration":Pe(e,i,t.componentScope,t.componentScope,{allowRunesProps:!0});break;case"FunctionDeclaration":if(i.id?.name)k(t.componentScope,i.id.name,{kind:"local"});break;case"ClassDeclaration":if(i.id?.name)k(t.componentScope,i.id.name,{kind:"local"});break;case"ExportNamedDeclaration":if(!i.declaration||typeof i.declaration!=="object"||!("type"in i.declaration))break;if(i.declaration.type==="VariableDeclaration")Pe(e,i.declaration,t.componentScope,t.componentScope,{forceProp:!0});else if(i.declaration.type==="FunctionDeclaration"&&i.declaration.id?.name)k(t.componentScope,i.declaration.id.name,{kind:"prop",publicPropName:i.declaration.id.name});break}}}function Ie(e,t){t.componentScope.clear(),t.scopeDeclarations=new WeakMap,t.activeScopes.length=0,Rt(e,t,t.parsed?.instance)}function He(e){return{varScopeStack:[e.componentScope]}}function je(e,t,n,r){if(!me(r))return;let i=kt(t,r),p=n.varScopeStack[n.varScopeStack.length-1]??t.componentScope;switch(String(r.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":wt(r,i);break;case"BlockStatement":Nt(e,r.body,i,p);break;case"CatchClause":if("param"in r)for(let c of M(r.param))k(i,c,{kind:"local"});break;case"EachBlock":{let c=r;for(let d of M(c.context))k(i,d,{kind:"local"});if(typeof c.index==="string")k(i,c.index,{kind:"local"});else if(c.index&&"name"in c.index)k(i,c.index.name,{kind:"local"});break}case"AwaitBlock":{let c=r;for(let d of M(c.value))k(i,d,{kind:"local"});for(let d of M(c.error))k(i,d,{kind:"local"});break}}if(Ae(r))n.varScopeStack.push(i)}function Fe(e,t){if(Ae(t))e.varScopeStack.pop()}var At=new Set(["$state","$derived","$effect","$props","$bindable","$inspect","$host"]);function It(e,t){switch(t?.type){case"MemberExpression":return t.computed||e===t.object;case"MethodDefinition":return!!t.computed;case"MetaProperty":return e===t.meta;case"PropertyDefinition":return t.computed||e===t.value;case"Property":return t.computed||e===t.value;case"ExportSpecifier":case"ImportSpecifier":return e===t.local;case"LabeledStatement":case"BreakStatement":case"ContinueStatement":return!1;default:return!0}}function Ht(e,t){for(let n=t.length-1;n>=0;n-=1)if(t[n]?.has(e))return!0;return!1}function jt(e){let t=new Set;if(!e||typeof e!=="object"||!("type"in e))return t;switch(String(e.type)){case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":{let n=e;if(n.id?.name)t.add(n.id.name);for(let r of n.params??[])M(r,t);break}case"BlockStatement":fe(e.body,t);break;case"CatchClause":M(e.param,t);break;case"EachBlock":{let n=e;if(M(n.context,t),typeof n.index==="string")t.add(n.index);else if(n.index?.name)t.add(n.index.name);break}case"AwaitBlock":{let n=e;M(n.value,t),M(n.error,t);break}}return t}function fe(e,t){if(!Array.isArray(e))return;for(let n of e){if(!n||typeof n!=="object"||!("type"in n))continue;switch(String(n.type)){case"ImportDeclaration":for(let r of n.specifiers??[])if(r.local?.name)t.add(r.local.name);break;case"VariableDeclaration":for(let r of n.declarations??[])M(r.id,t);break;case"FunctionDeclaration":case"ClassDeclaration":{let r=n.id?.name;if(r)t.add(r);break}case"ExportNamedDeclaration":{let r=n.declaration;if(r&&typeof r==="object"&&"type"in r)fe([r],t);break}}}}function Me(e,t){if(!e||typeof e!=="object")return!1;let n=[...t],r=!1;return _(e,{enter(i,p){if(r){this.skip();return}if(me(i))n.push(jt(i));if(p&&i.type==="Identifier"&&At.has(i.name)&&!p.type.startsWith("TS")&&It(i,p)&&!Ht(i.name,n))r=!0,this.skip()},leave(i){if(me(i))n.pop()}}),r}function _e(e){if(!e||typeof e!=="object")return;if("content"in e){let t=e.content,n=t&&typeof t==="object"&&"body"in t?t.body:void 0;if(Array.isArray(n))return n}if("body"in e&&Array.isArray(e.body))return e.body;return}function Be(e){if(e.runesOptionOverride!==void 0)return e.runesOptionOverride?"runes":"legacy";let t=e.parsed;if(!t)return"legacy";let n=new Set;fe(_e(t.module),n);let r=new Set;return fe(_e(t.instance),r),Me(t.module,[n])||Me(t.instance,[n,r])||Me(t.fragment,[n,r])?"runes":"legacy"}var Ft=/[A-Za-z_$][\w$]*/g;function _t(e,t,n){let r=new Map,i=t.typeParameters?.params,p=n.typeArguments?.params;if(!i?.length||!p?.length)return r;for(let s=0;s<i.length;s++){let c=i[s]?.name,d=p[s];if(!c||d?.start===void 0||d?.end===void 0)continue;let f=z(e,d.start,d.end)?.trim();if(f)r.set(c,f)}return r}function Bt(e,t){if(t.size===0)return e;return e.replace(Ft,(n)=>t.get(n)??n)}function oe(e,t,n,r,i=new Set){let p=new Map;if(!n?.type)return p;let s=(c)=>{for(let d of c){if(d?.type!=="TSPropertySignature"||d.computed)continue;if(!d.key)continue;let f=e.getPropertyName(d.key);if(!f)continue;let y=d.typeAnnotation?.start,x=d.typeAnnotation?.end;if(y===void 0||x===void 0)continue;let P=z(t,y+1,x)?.trim();if(!P)continue;p.set(f,{type:P,optional:d.optional===!0,source:N(t,d)})}};switch(n.type){case"TSTypeLiteral":s(n.members??[]);break;case"TSInterfaceDeclaration":s(n.body?.body??[]);break;case"TSTypeAliasDeclaration":{let c=oe(e,t,n.typeAnnotation,r,i);for(let[d,f]of c)p.set(d,f);break}case"TSTypeReference":{let c=Ke(n.typeName);if(!c||i.has(c))break;let d=r.get(c);if(!d)break;i.add(c);let f=oe(e,t,d,r,i);i.delete(c);let y=_t(t,d,n);for(let[x,P]of f)p.set(x,y.size===0?P:{...P,type:Bt(P.type,y)});break}case"TSIntersectionType":for(let c of n.types??[]){let d=oe(e,t,c,r,i);for(let[f,y]of d)p.set(f,y)}break;case"TSParenthesizedType":{let c=oe(e,t,n.typeAnnotation,r,i);for(let[d,f]of c)p.set(d,f);break}}return p}function Ye(e,t,n){if(t.runesPropsDeclarationMetadataByDeclaratorStart.clear(),t.explicitPropTypesByName.clear(),t.explicitVariableTypesByName.clear(),t.typeImportBindingsByLocalName.clear(),t.localTypeDeclarationsByName.clear(),t.typedRunesPropsDeclarations.length=0,!t.source)return;let r=n;t.scriptLanguage=e.resolveScriptLanguage(r),t.customElementTag=r.options?.customElement?.tag,t.runesOptionOverride=r.options?.runes,t.scriptGenericsAttribute=e.resolveScriptGenericsAttribute(r);let i=r.instance?.content?.body??[];for(let p of i){if(!p?.type)continue;if(p.type==="ImportDeclaration"&&p.source?.value)for(let s of p.specifiers??[]){let c=s.local?.name;if(!c)continue;if(!(p.importKind==="type"||s.importKind==="type"))continue;let f,y;if(s.type==="ImportSpecifier")f="named",y=s.imported?.type==="Identifier"?s.imported.name:typeof s.imported?.value==="string"?s.imported.value:void 0;else if(s.type==="ImportDefaultSpecifier")f="default";else if(s.type==="ImportNamespaceSpecifier")f="namespace";if(!f)continue;t.typeImportBindingsByLocalName.set(c,{importedName:y,localName:c,source:String(p.source.value),specifierType:f})}if((p.type==="TSInterfaceDeclaration"||p.type==="TSTypeAliasDeclaration")&&p.id?.name&&p.start!==void 0&&p.end!==void 0)t.localTypeDeclarationsByName.set(p.id.name,{code:z(t,p.start,p.end)?.trim()??"",node:p,start:p.start});if(p.type==="ExportNamedDeclaration"&&p.declaration?.type==="VariableDeclaration")for(let s of p.declaration.declarations??[]){if(s.id?.type!=="Identifier"||!s.id.name)continue;let c=ye(t,s.id.typeAnnotation);if(c)t.explicitPropTypesByName.set(s.id.name,c)}else if(p.type==="VariableDeclaration")for(let s of p.declarations??[]){if(s.id?.type!=="Identifier"||!s.id.name)continue;let c=ye(t,s.id.typeAnnotation);if(c)t.explicitVariableTypesByName.set(s.id.name,c)}}for(let p of i){if(!p||typeof p!=="object"||!("declarations"in p))continue;for(let s of p.declarations??[]){if(!B(J(s.init),"$props"))continue;let c=s.id?.typeAnnotation?void 0:Ve(s.init),d=s.id?.typeAnnotation?.typeAnnotation??c,f=s.id?.typeAnnotation?ye(t,s.id.typeAnnotation):Je(t,c),y=oe(e,t,d,new Map(Array.from(t.localTypeDeclarationsByName.entries(),([I,R])=>[I,R.node]))),x=new Set,P=new Set;if(ze(t,d,x,P),We(t,x,P),s.start!==void 0){let I={canonicalType:f,props:y,referencedImportedTypes:x,referencedLocalTypes:P};if(t.runesPropsDeclarationMetadataByDeclaratorStart.set(s.start,I),f)t.typedRunesPropsDeclarations.push(I)}}}}function qe(e,t,n){for(let r of n.declarations){if(!B(J(r.init),"$props"))continue;if(r.id.type==="Identifier"){t.wholePropsLocals.add(r.id.name),t.restPropLocals.add(r.id.name);let s=$e(t,r.start);if(s)for(let[c,d]of s.props)ie(e,t,c,{name:c,kind:"let",type:d.type,typeSource:"typescript",isFunction:!1,isFunctionDeclaration:!1,isRequired:!d.optional,constant:!1,reactive:!1,source:d.source});continue}if(r.id.type!=="ObjectPattern")continue;let i=W(t,e,n),p=r.id.properties.filter((s)=>{if(s.type!=="Property"||s.computed)return!1;if(!e.getPropertyName(s.key))return!1;if(s.value.type==="Identifier")return!0;return s.value.type==="AssignmentPattern"&&s.value.left.type==="Identifier"}).length;for(let s of r.id.properties){if(s.type==="RestElement"){if(s.argument.type==="Identifier")t.restPropLocals.add(s.argument.name);continue}let c=e.getPropertyName(s.key);if(!c)continue;let d,f;if(s.value.type==="Identifier")d=s.value.name;else{let T=s.value;d=T.left.name,f=T.right}if(!d)continue;if(e.trackPropLocalName(c,d),c==="children")t.snippetPropLocals.add(d);let y=Xe(t,e,s)??(p===1?i:void 0),x=Ge(t,r.start,c),{init:P,bindable:I}=Oe(f),R=P==null?{isFunction:!1}:ae(e,t,P),{value:se,type:Q,isFunction:xe,defaultValue:he}=R,Se=x?.type===void 0&&y?.type===void 0?R.resolvedType:void 0;if(R.pendingCallDefault)t.pendingCallDefaultCandidates.push({propName:c,location:"props",...R.pendingCallDefault});let{type:ce,typeSource:pe,description:le,params:o,returnType:a,isFunction:m}=re({explicitType:x?.type,typeSeed:Q,inferredTypeForSource:Q,jsdocType:y?.type,jsdocDescription:y?.description,jsdocParams:y?.params,jsdocReturnType:y?.returnType,resolvedType:Se,resolvedDescription:R.resolvedDescription,resolvedParams:R.resolvedParams,resolvedReturnType:R.resolvedReturnType,initializerIsFunction:xe,isFunctionDeclaration:!1,inferIsFunctionFromTypeSignature:!0});if(I)t.reactive_vars.add(c);ie(e,t,c,{name:c,...d===c?{}:{localName:d},kind:"let",description:le,binding:y?.binding,deprecated:y?.deprecated,tags:y?.tags,...I?{bindable:!0}:{},type:ce,typeSource:pe,value:se,defaultValue:he,params:o,returnType:a,isFunction:m,isFunctionDeclaration:!1,isRequired:P==null&&x?.optional!==!0,constant:!1,reactive:I,source:N(t,s)})}}}function Ue(e,t){if(e.syntaxMode!=="runes")return;for(let[n,r]of Array.from(e.events.entries())){if(r.type!=="dispatched")continue;if(t.has(n)||e.forwardedEvents.has(n))continue;let i=`on${n}`,p=e.props.get(i);if(!p)continue;let s=p.type!==void 0||p.params!==void 0||p.returnType!==void 0,c=r.detail===void 0||r.detail==="undefined"||r.detail==="null"?"() => void":`(detail: ${r.detail}) => void`;e.props.set(i,{...p,description:p.description??r.description,type:s?p.type:c,typeSource:s?p.typeSource:"inferred",isFunction:!0}),e.events.delete(n)}}var Qe=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion","TSInstantiationExpression"]);function ge(e){if(!e||typeof e!=="object")return;_(e,{enter(t){if(!Qe.has(t.type))return;let n=t.expression;while(n&&Qe.has(n.type))n=n.expression;if(n)this.replace(n)}})}function Te(e,t){let n=t.source?.value;if(typeof n!=="string"||t.importKind==="type")return;for(let r of t.specifiers??[]){if(r.type!=="ImportSpecifier"||r.importKind==="type")continue;let i=r.local?.name;if(!i)continue;let p=r.imported?.name??(typeof r.imported?.value==="string"?r.imported.value:i);e.valueImportBindingsByLocalName.set(i,{localName:i,importedName:p,source:n})}}function De(e,t){if(!t)return;_(t,{enter(n){if(n.type==="ImportDeclaration")Te(e,n);if(n.type==="FunctionDeclaration"){let r=n;if(r.id?.name)e.funcDecls.set(r.id.name,r)}}})}function rt(e,t,n){let r=t+1;while(r<e.length){if(e[r]==="\\"){r+=2;continue}if(e[r]===n)return r+1;r++}return r}function ot(e,t){let n=t+1,r=0;while(n<e.length){let i=e[n];if(i==="\\"){n+=2;continue}if(r===0){if(i==="`")return n+1;if(i==="$"&&e[n+1]==="{"){r=1,n+=2;continue}n++;continue}if(i==="{")r++;else if(i==="}")r--;else if(i==='"'||i==="'"){n=rt(e,n,i);continue}else if(i==="`"){n=ot(e,n);continue}n++}return n}function Vt(e,t){let n=[],r=e.length,i=0;while(i<r){let p=e[i];if(p==='"'||p==="'"){i=rt(e,i,p);continue}if(p==="`"){i=ot(e,i);continue}if(p==="/"&&e[i+1]==="/"){let s=i+2;while(s<r&&e[s]!==`
2
+ `)s++;i=s;continue}if(p==="/"&&e[i+1]==="*"){let s=i,c=i+2;while(c<r&&!(e[c]==="*"&&e[c+1]==="/"))c++;let d=Math.min(c+2,r),f=e.slice(s,d);n.push({end:d+t,isJsDoc:f.startsWith("/**")&&f.length>4,text:f}),i=d;continue}i++}return n}function Ze(e,t,n){if(!e||typeof e!=="object"||!("type"in e))return;let r=e;if(r.type==="FunctionDeclaration"){if(r.id?.type==="Identifier"&&r.id.name)n.push({name:r.id.name,start:t});return}if(r.type==="VariableDeclaration"){for(let i of r.declarations??[])if(i?.id?.type==="Identifier"&&i.id.name)n.push({name:i.id.name,start:t})}}function Ot(e){let t=[];for(let n of e){if(!n||typeof n!=="object"||!("type"in n))continue;let r=n;if(r.start===void 0)continue;if(r.type==="ExportNamedDeclaration"&&r.declaration)Ze(r.declaration,r.start,t);else Ze(r,r.start,t)}return t}function $t(e,t,n){let r;for(let i of e){if(i.end>t)break;if(!i.isJsDoc)continue;if(!tt.test(n.slice(i.end,t)))continue;r=i}return r}function it(e,t){let n=new Map;if(!e.source)return n;let r=[e.parsed?.module,e.parsed?.instance],i=[],p=[];for(let s of r){let c=s?.content;if(!c?.body||c.start===void 0||c.end===void 0)continue;i.push(...Vt(e.source.slice(c.start,c.end),c.start)),p.push(...Ot(c.body))}i.sort((s,c)=>s.end-c.end);for(let s of p){let c=$t(i,s.start,e.source);if(!c)continue;let d=et(c.text),{type:f,description:y}=nt(d);if(!f)continue;n.set(s.name,{type:t.aliasType(f.type),description:y||f.description})}return n}function at(e){if(e==="var")return"let";if(e==="using"||e==="await using")return"const";return e}var Gt=null,st=/^@component/,Kt=/\r/g,Jt=/^\{\s*\}$/;class L{ctx=Ee();static mapToArray(e){return Array.from(e,([t,n])=>n)}static getStaticAttributeValue(e){if(!Array.isArray(e.value))return;return e.value.map((t)=>t.data??t.raw??"").join("").trim()}resolveScriptLanguage(e){let t=[e.instance,e.module].filter((r)=>r!==void 0),n=!1;for(let r of t){let i=r.attributes?.find((s)=>s.name==="lang");if(!i){n=!0;continue}if(L.getStaticAttributeValue(i)?.toLowerCase()==="ts")return"ts"}return n?"js":void 0}resolveScriptGenericsAttribute(e){let t=e.instance?.attributes?.find((s)=>s.name==="generics");if(!t)return;let n=N(this.ctx,t),r=e.instance?.attributes?.find((s)=>s.name==="lang");if((r?L.getStaticAttributeValue(r)?.toLowerCase():void 0)!=="ts"){U(this.ctx,"syntax-skipped","generics",'<script generics="..."> requires lang="ts"; the generics attribute was ignored because the script is not TypeScript.',n);return}let p=L.getStaticAttributeValue(t);if(!p)return;return{value:p,source:n}}resolvePublicPropName(e){return this.ctx.propLocalToPublicName.get(e)??e}trackPropLocalName(e,t=e){this.ctx.propLocalToPublicName.set(t,e)}getPropByLocalOrPublic(e){return this.ctx.props.get(this.resolvePublicPropName(e))}getPropTypeByLocalOrPublic(e){return this.getPropByLocalOrPublic(e)?.type}getExplicitPropType(e){return this.ctx.explicitPropTypesByName.get(e)}getPropertyName(e){if(!e||typeof e!=="object"||!("type"in e))return;if(be(e))return e.name;if(ct(e))return e.value==null?void 0:String(e.value);return}isNumericConstant(e){if(!e||typeof e!=="object"||!("type"in e))return!1;if(e.type!=="MemberExpression")return!1;let t=e,n=t.object&&"name"in t.object?t.object.name:void 0,r=t.property&&"name"in t.property?t.property.name:void 0;if(!n||!r)return!1;if(n==="Number")return["POSITIVE_INFINITY","NEGATIVE_INFINITY","MAX_VALUE","MIN_VALUE","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","EPSILON","NaN"].includes(r);if(n==="Math")return["PI","E","LN2","LN10","LOG2E","LOG10E","SQRT2","SQRT1_2"].includes(r);return!1}resolveLocalVarJSDoc(e){for(let n of this.ctx.vars)if(n.declarations.some((i)=>i.id&&typeof i.id==="object"&&("type"in i.id)&&i.id.type==="Identifier"&&("name"in i.id)&&i.id.name===e))return W(this.ctx,this,n);let t=this.ctx.funcDecls.get(e);if(t)return W(this.ctx,this,t);return}addModuleExport(e,t){if(ut(e)===void 0)return;if(this.ctx.moduleExports.has(e)){let n=this.ctx.moduleExports.get(e);this.ctx.moduleExports.set(e,{...n,...t})}else this.ctx.moduleExports.set(e,t)}aliasType(e){if(e==="*")return"any";return e.trim()}findVariableTypeAndDescription(e){let t=this.getPropByLocalOrPublic(e);if(t?.type)return{type:t.type,description:t.description};if(!this.ctx.variableInfoCacheBuilt)this.ctx.variableInfoCache=it(this.ctx,this),this.ctx.variableInfoCacheBuilt=!0;let n=this.ctx.variableInfoCache.get(e),r=this.ctx.explicitVariableTypesByName.get(e);if(r)return{type:r,description:n?.description};return n??null}accumulateGeneric(e,t){if(this.ctx.generics)this.ctx.generics=[`${this.ctx.generics[0]}, ${e}`,`${this.ctx.generics[1]}, ${t}`];else this.ctx.generics=[e,t]}cleanup(){this.ctx=Ee()}static SCRIPT_BLOCK_REGEX=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi;static TS_DIRECTIVE_REGEX=/\/\/\s*@ts-[^\n\r]*/g;static stripTypeScriptDirectivesFromScripts(e){return L.SCRIPT_BLOCK_REGEX.lastIndex=0,e.replace(L.SCRIPT_BLOCK_REGEX,(t,n,r,i)=>{L.TS_DIRECTIVE_REGEX.lastIndex=0;let p=r.replace(L.TS_DIRECTIVE_REGEX,"");return n+p+i})}parseSvelteComponent(e,t){this.cleanup(),this.ctx.componentFilePath=t.filePath;let n=L.stripTypeScriptDirectivesFromScripts(e);this.ctx.source=n;let r=Et(n);if(Ye(this,this.ctx,r),this.ctx.parsed=r,this.ctx.scriptLanguage==="ts")ge(this.ctx.parsed.module),ge(this.ctx.parsed.instance),ge(this.ctx.parsed.fragment);this.ctx.syntaxMode=Be(this.ctx);let i=this.ctx.parsed.css,p=i?.start!==void 0&&i?.end!==void 0?n.slice(0,i.start)+" ".repeat(i.end-i.start)+n.slice(i.end):n;St(this.ctx,this,p);let s={type:"ComponentRoot",instance:this.ctx.parsed.instance,fragment:this.ctx.parsed.fragment};if(De(this.ctx,this.ctx.parsed?.module),De(this.ctx,this.ctx.parsed?.instance),this.ctx.parsed?.module)_(this.ctx.parsed?.module,{enter:(o)=>{if(o.type==="ImportDeclaration")Te(this.ctx,o);if(o.type==="FunctionDeclaration"){let a=o;if(a.id?.name)this.ctx.funcDecls.set(a.id.name,a)}if(o.type==="VariableDeclaration")this.ctx.vars.add(o);if(o.type==="ExportNamedDeclaration"){if(o.declaration==null)return;if(!o.declaration||typeof o.declaration!=="object"||!("type"in o.declaration))return;let a,m,T=!1,l,u,b,S=!1,v,E,h;if(o.declaration.type==="FunctionDeclaration"){let H=o.declaration;if(!H.id?.name)return;a=H.id.name,m="function",l=void 0,u="() => any",S=!0,T=!0}else if(o.declaration.type==="VariableDeclaration"){let H=o.declaration,j=H.declarations[0];if(!j||typeof j!=="object"||!("id"in j))return;let{id:Y,init:de}=j;if(!Y||typeof Y!=="object"||!("name"in Y))return;let Z=Y.name;a=Z,m=at(H.kind);let C=de==null?{isFunction:!1}:ae(this,this.ctx,de);if({value:l,type:u,isFunction:S,defaultValue:v}=C,E=u,h=C,b=this.getExplicitPropType(Z),h.pendingCallDefault)this.ctx.pendingCallDefaultCandidates.push({propName:Z,location:"moduleExports",...h.pendingCallDefault})}else return;let D=W(this.ctx,this,o),{type:w,typeSource:V,description:O,params:g,returnType:A,isFunction:X}=re({explicitType:b,typeSeed:u,inferredTypeForSource:E,jsdocType:D?.type,jsdocDescription:D?.description,jsdocParams:D?.params,jsdocReturnType:D?.returnType,resolvedType:h?.resolvedType,resolvedDescription:h?.resolvedDescription,resolvedParams:h?.resolvedParams,resolvedReturnType:h?.resolvedReturnType,initializerIsFunction:S,isFunctionDeclaration:T,typedefs:this.ctx.typedefs});this.addModuleExport(a,{name:a,kind:m,description:O,deprecated:D?.deprecated,tags:D?.tags,type:w,typeSource:V,value:l,defaultValue:v,params:g,returnType:A,isFunction:X,isFunctionDeclaration:T,isRequired:!1,constant:m==="const",reactive:!1,source:N(this.ctx,o)})}}});let c,d=new Set,f=new Set,y=[];Ie(this,this.ctx),this.ctx.activeScopes.push(this.ctx.componentScope);let x=He(this.ctx);if(_(s,{enter:(o,a,m)=>{je(this,this.ctx,x,o);let T=this.ctx.scopeDeclarations.get(o);if(T)this.ctx.activeScopes.push(T);if(o.type==="AssignmentExpression")ve(this.ctx,o.left);if(o.type==="UpdateExpression")ve(this.ctx,o.argument);if(o.type==="CallExpression"){let l=o,u=l.callee&&typeof l.callee==="object"&&"name"in l.callee?l.callee.name:void 0;if(u==="createEventDispatcher"){if(a&&typeof a==="object"&&"id"in a&&a.id&&typeof a.id==="object"&&"name"in a.id)c=a.id.name}if(u==="$host"){if(a&&typeof a==="object"&&"id"in a&&a.id&&typeof a.id==="object"&&"name"in a.id)d.add(a.id.name)}if(u==="setContext")mt(this.ctx,this,o,a??void 0);if(u)y.push({name:u,arguments:l.arguments,source:N(this.ctx,l)});if(pt(l.callee)&&be(l.callee.property)&&l.callee.property.name==="dispatchEvent"&&(B(l.callee.object,"$host")||be(l.callee.object)&&d.has(l.callee.object.name))){let b=gt(this.ctx,l);if(b)f.add(b)}}if(o&&typeof o==="object"&&"type"in o&&String(o.type)==="SpreadAttribute"){let l=o;if(l.expression?.name==="$$restProps"||this.ctx.restPropLocals.has(l.expression?.name??""))Ne(this.ctx,a)}if(o.type==="FunctionDeclaration"){let l=o;if(l.id?.name)this.ctx.funcDecls.set(l.id.name,l)}if(o.type==="ImportDeclaration")Te(this.ctx,o);if(o.type==="VariableDeclaration"){if(this.ctx.vars.add(o),a&&typeof a==="object"&&"type"in a&&a.type==="Program"&&o.declarations.some((l)=>B(J(l.init),"$props")))qe(this,this.ctx,o)}if(o.type==="ExportNamedDeclaration"){if(o.declaration==null&&o.specifiers.length===0)return;let l;if(o.declaration==null&&o.specifiers[0]?.type==="ExportSpecifier"){let C=o.specifiers[0],G=C.local&&typeof C.local==="object"&&"name"in C.local?C.local.name:void 0,K=C.exported&&typeof C.exported==="object"&&"name"in C.exported?C.exported.name:void 0;if(!G||!K)return;let q;for(let ee of Array.from(this.ctx.vars))if(ee.declarations.some((F)=>F.id&&typeof F.id==="object"&&("type"in F.id)&&F.id.type==="Identifier"&&F.id.name===G)){q=ee;break}o.declaration=q,l=K}if(o.declaration==null)return;if(!o.declaration||typeof o.declaration!=="object"||!("type"in o.declaration))return;let u,b=!1,S,v,E,h=!1,D=!1,w,V,O,g;if(o.declaration.type==="FunctionDeclaration"){let C=o.declaration;if(!C.id?.name)return;l??=C.id.name,w=C.id.name,u="function",S=void 0,v="() => any",h=!0,b=!0,D=!1}else if(o.declaration.type==="VariableDeclaration"){let C=o.declaration,G=C.declarations[0];if(!G||typeof G!=="object"||!("id"in G))return;let{id:K,init:q}=G;if(K&&typeof K==="object"&&"name"in K){let F=K.name;w=F,l??=F,E=this.getExplicitPropType(F)}else return;u=at(C.kind),D=u==="let"&&q==null;let ee=q==null?{isFunction:!1}:ae(this,this.ctx,q);if({value:S,type:v,isFunction:h,defaultValue:V}=ee,O=v,g=ee,g.pendingCallDefault)this.ctx.pendingCallDefaultCandidates.push({propName:l,location:"props",...g.pendingCallDefault})}else return;let A=W(this.ctx,this,o),{type:X,typeSource:H,description:j,params:Y,returnType:de,isFunction:Z}=re({explicitType:E,typeSeed:v,inferredTypeForSource:O,jsdocType:A?.type,jsdocDescription:A?.description,jsdocParams:A?.params,jsdocReturnType:A?.returnType,resolvedType:g?.resolvedType,resolvedDescription:g?.resolvedDescription,resolvedParams:g?.resolvedParams,resolvedReturnType:g?.resolvedReturnType,initializerIsFunction:h,isFunctionDeclaration:b,typedefs:this.ctx.typedefs});ie(this,this.ctx,l,{name:l,...w!==void 0&&w!==l?{localName:w}:{},kind:u,description:j,binding:A?.binding,deprecated:A?.deprecated,tags:A?.tags,type:X,typeSource:H,value:S,defaultValue:V,params:Y,returnType:de,isFunction:Z,isFunctionDeclaration:b,isRequired:D,constant:u==="const",reactive:this.ctx.reactive_vars.has(l),source:N(this.ctx,o)})}if(o&&typeof o==="object"&&"type"in o&&String(o.type)==="Comment"){let u=o?.data?.trim()??"";if(st.test(u))this.ctx.componentComment=u.replace(st,"").replace(Kt,""),this.ctx.componentCommentSource=N(this.ctx,o)}if(o&&typeof o==="object"&&"type"in o&&String(o.type)==="SlotElement"){let l=o,u=l.attributes?.find((E)=>E.name==="name")?.value,b=(Array.isArray(u)?u[0]:void 0)?.data,S=(l.attributes||[]).filter((E)=>E.name!=="name").reduce((E,h)=>{let D={value:void 0,replace:!1},w=h.value;if(w===void 0||w===!0)return E;let V=Array.isArray(w)?w[0]:w;if(V){let{type:O,expression:g,raw:A,start:X,end:H}=V;if(O==="Text"&&A!==void 0)D.value=JSON.stringify(A);else if(!Array.isArray(w)&&O==="ExpressionTag"&&g&&typeof g==="object"&&"type"in g&&g.type==="Identifier"&&"name"in g&&g.name===h.name)D.value=g.name,D.replace=!0;if(g&&typeof g==="object"&&"type"in g){if(g.type==="Literal"&&"value"in g){let j=g.value;D.value=typeof j==="string"?JSON.stringify(j):String(j)}else if(g.type==="MemberExpression")D.value=lt(this.ctx,this,g);else if(g.type!=="Identifier"){if(X!==void 0&&H!==void 0){if(g.type==="ObjectExpression"||g.type==="TemplateLiteral")D.value=z(this.ctx,X+1,H-1)}}}}if(h.name)E[h.name]=D;return E},{}),v=l.fragment?.nodes?.map(({start:E,end:h})=>{if(E===void 0||h===void 0)return"";return z(this.ctx,E,h)??""}).join("").trim();Ce(this.ctx,{slot_name:b,slot_props:S,slot_fallback:v,source:N(this.ctx,o)})}if(o&&typeof o==="object"&&"type"in o&&String(o.type)==="RenderTag"){let l=o,u=ht(this.ctx,l.expression);if(u){let b;if(u.arguments.length===0)b={};else if(u.arguments.length===1&&typeof u.arguments[0]==="object"&&u.arguments[0]&&"type"in u.arguments[0]&&u.arguments[0].type==="ObjectExpression")b=xt(this.ctx,this,u.arguments[0]);else if(u.arguments.length===1)U(this.ctx,"syntax-skipped",u.publicName,`{@render ${u.publicName}(...)} argument is not a plain object literal; the render call was not mapped to slot metadata.`,N(this.ctx,o));let S=u.publicName==="children"?void 0:u.publicName,v=S===void 0?Gt:S;if(b!==void 0)Ce(this.ctx,{slot_name:S,slot_props:b,source:N(this.ctx,o)});if(b!==void 0||this.ctx.slots.has(v))this.ctx.snippetPropLocals.add(u.trackingName)}}if(o&&typeof o==="object"&&"type"in o&&String(o.type)==="OnDirective"){let l=o;if(l.expression==null&&l.name){if(a!=null&&typeof a==="object"&&"name"in a){let u=typeof a.name==="string"?a.name:void 0,b="type"in a?String(a.type):void 0;if(u&&b){let S=te(b)?{type:"InlineComponent",name:u}:{type:"Element",name:u};this.ctx.forwardedEvents.set(l.name,S);let v=this.ctx.events.get(l.name),E=this.ctx.eventDescriptions.get(l.name),h=v?.deprecated;if(!v)this.ctx.events.set(l.name,{type:"forwarded",name:l.name,element:S,description:E,deprecated:h,source:N(this.ctx,o)});else if(v.type==="forwarded"&&E&&!v.description)this.ctx.events.set(l.name,{...v,description:E,deprecated:v.deprecated??h,source:v.source||N(this.ctx,o)})}}}}if(a&&typeof a==="object"&&"type"in a&&(ne(String(a.type))||te(String(a.type)))&&o&&typeof o==="object"&&"type"in o&&String(o.type)==="BindDirective"){let l=o;if(l.expression?.name){let u=ue(this.ctx,l.expression.name);if(u)this.ctx.reactive_vars.add(u)}if(ne(String(a.type))&&l.name==="this"&&l.expression?.name&&"name"in a&&typeof a.name==="string"){let u=ue(this.ctx,l.expression.name);if(!u)return;let b=a.name;if(this.ctx.bindings.has(u)){let S=this.ctx.bindings.get(u);if(S&&!S.elements.includes(b))this.ctx.bindings.set(u,{...S,elements:[...S.elements,b]})}else this.ctx.bindings.set(u,{elements:[b]})}}},leave:(o)=>{if(this.ctx.scopeDeclarations.has(o))this.ctx.activeScopes.pop();Fe(x,o)}}),c!==void 0){for(let o of y)if(o.name===c){let a=o.arguments[0],m=a&&typeof a==="object"&&"value"in a?a.value:void 0,T=o.arguments[1],l=T&&typeof T==="object"&&"value"in T?T.value:void 0;if(m!=null)yt(this.ctx,{name:String(m),detail:l==null?"":ft(l),has_argument:Boolean(T),source:o.source})}}let P=new Set(f);if(c!==void 0){for(let o of y)if(o.name===c){let a=o.arguments[0],m=a&&typeof a==="object"&&"value"in a?a.value:void 0;if(m!=null)P.add(String(m))}}this.ctx.forwardedEvents.forEach((o,a)=>{let m=this.ctx.events.get(a);if(m&&m.type==="dispatched"&&!P.has(a)){let T=this.ctx.eventDescriptions.get(a),l={type:"forwarded",name:a,element:o,description:T,deprecated:m.deprecated,tags:m.tags,source:m.source};if(m.detail!==void 0&&m.detail!=="undefined")l.detail=m.detail;this.ctx.events.set(a,l)}}),Ue(this.ctx,P);let I=this.ctx.syntaxMode==="runes"?new Set(Array.from(this.ctx.snippetPropLocals,(o)=>this.resolvePublicPropName(o))):new Set,R=L.mapToArray(this.ctx.props).filter((o)=>!I.has(o.name)).map((o)=>{if(this.ctx.bindings.has(o.name)){let a=this.ctx.bindings.get(o.name)?.elements.sort().map((m)=>we(m)).join(" | ");return{...o,type:`null | ${a}`,typeSource:"inferred",reactive:o.reactive||this.ctx.reactive_vars.has(o.name)}}return{...o,reactive:o.reactive||this.ctx.reactive_vars.has(o.name)}});this.ctx.activeScopes.length=0;let se=L.mapToArray(this.ctx.slots).map((o)=>{if(!o.slot_props)return o;if(typeof o.slot_props==="string")return Jt.test(o.slot_props)?{...o,slot_props:"Record<string, never>"}:o;let a=o.slot_props,m=[];for(let l of Object.keys(a)){if(a[l].replace&&a[l].value!==void 0)a[l].value=this.getPropTypeByLocalOrPublic(a[l].value);if(a[l].value===void 0)a[l].value="any";m.push(`${l}: ${a[l].value}`)}let T=m.length===0?"Record<string, never>":m.length===1?`{ ${m[0]} }`:`{
3
+ ${m.join(`;
4
+ `)};
5
+ }`;return{...o,slot_props:T}}).sort((o,a)=>{let m=o.name??"",T=a.name??"";if(m<T)return-1;if(m>T)return 1;return 0});if(this.ctx.deferredSlotBlockGenerics.length>0){let o=[...R.map((a)=>a.type??""),...se.map((a)=>a.slot_props??"")].join(`
6
+ `);for(let{name:a,constraint:m}of this.ctx.deferredSlotBlockGenerics){let T=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!new RegExp(`\\b${T}\\b`).test(o))continue;this.accumulateGeneric(a,m)}}if(this.ctx.scriptGenericsAttribute){if(this.ctx.generics)U(this.ctx,"syntax-skipped","generics",'Both the "generics" script attribute and @generics/@template JSDoc tags declare component generics; the script attribute takes precedence and the JSDoc declaration was ignored.',this.ctx.scriptGenericsAttribute.source);this.ctx.generics=bt(this.ctx.scriptGenericsAttribute.value)}let Q=L.mapToArray(this.ctx.moduleExports),xe=L.mapToArray(this.ctx.events).map((o)=>{switch(o.type){case"forwarded":return{...o,element:o.element.name};case"dispatched":return o;default:return o}}).sort((o,a)=>{let m=o.name.localeCompare(a.name);if(m!==0)return m;let T=o.type.localeCompare(a.type);if(T!==0)return T;if(o.type==="forwarded"&&a.type==="forwarded"){let l=o.element.localeCompare(a.element);if(l!==0)return l}return(o.detail??"").localeCompare(a.detail??"")}),he=L.mapToArray(this.ctx.typedefs),Se=L.mapToArray(this.ctx.contexts),ce={props:new Map(this.ctx.pendingCallDefaultCandidates.filter((o)=>o.location==="props").map((o)=>[o.propName,o])),moduleExports:new Map(this.ctx.pendingCallDefaultCandidates.filter((o)=>o.location==="moduleExports").map((o)=>[o.propName,o]))};for(let o of R)if(o.typeSource==="unknown"){let a=ce.props.get(o.name);if(a)o.type="any";let m=a?a.importSource?`Prop "${o.name}" default calls "${a.calleeName}()" imported from "${a.importSource}"; falling back to "any" pending cross-file resolution.`:`Prop "${o.name}" default calls "${a.calleeName}()", but its return type could not be inferred; falling back to "any".`:`Prop "${o.name}" type could not be inferred; falling back to "${o.type??"any"}".`;U(this.ctx,"prop-unknown-type",o.name,m,o.source)}for(let o of Q)if(o.typeSource==="unknown"&&ce.moduleExports.has(o.name))o.type="any";for(let o of this.ctx.jsDocEventNames){if(P.has(o))continue;if(this.ctx.forwardedEvents.has(o))continue;if(this.ctx.props.has(`on${o}`))continue;U(this.ctx,"event-no-source",o,`@event "${o}" has no matching dispatch or callback prop.`,this.ctx.jsDocEventSources.get(o))}let pe={source:dt(this.ctx,0,this.ctx.source?.length),syntaxMode:this.ctx.syntaxMode,...this.ctx.scriptLanguage?{scriptLanguage:this.ctx.scriptLanguage}:{},props:R,moduleExports:Q,slots:se,events:xe,typedefs:he,generics:this.ctx.generics,rest_props:this.ctx.rest_props,extends:this.ctx.extends,componentComment:this.ctx.componentComment,componentCommentSource:this.ctx.componentCommentSource,contexts:Se,customElementTag:this.ctx.customElementTag,diagnostics:this.ctx.diagnosticRecords.slice()},le=Tt(this.ctx);if(le)pe[ke]=le;return pe}}
7
+ export{L as t};
@@ -0,0 +1 @@
1
+ import{na as a,oa as b}from"./chunk-d802cqsd.js";import"./chunk-nrz6c5ew.js";import"./chunk-ptdfswsv.js";export{a as TemplateParseNotImplementedError,b as parse};
@@ -1,9 +1,9 @@
1
- import{D as ln,E as Ke,F as te,G as Sn,Q as bn,aa as Un,ia as un,v as K,y as cn}from"./chunk-yzabyfqs.js";import{sa as hn}from"./chunk-nrz6c5ew.js";import{ua as B,va as T,wa as Oe,xa as W}from"./chunk-syz2wqmb.js";import{Ba as Ze}from"./chunk-ptdfswsv.js";var At="sveld",xe="0.36.9";var Rt={name:At,version:xe,license:"Apache-2.0",description:"Generate TypeScript definitions and component documentation for your Svelte components.",type:"module",main:"./lib/index.js",types:"./lib/index.d.ts",exports:{".":{types:"./lib/index.d.ts",import:"./lib/index.js",default:"./lib/index.js"},"./browser":{types:"./lib/browser.d.ts",import:"./lib/browser.js",default:"./lib/browser.js"}},scripts:{test:"bun test --parallel","test:fixtures-types":"tsc --project tsconfig.fixtures.json","test:e2e":"bun tests/test-e2e.ts",format:"biome format --write .",lint:"biome lint .","lint:fix":"biome check --write --unsafe .",build:"bun scripts/build.ts",bench:"bun scripts/bench.ts","bench:cache":"bun scripts/bench.ts --cache","bench:mitata":"bun scripts/bench-mitata.ts",fuzz:"bun scripts/fuzz-parser.ts",typecheck:"tsc --noEmit"},devDependencies:{"@biomejs/biome":"2.5.10","@types/bun":"^1.3.14","@types/jest":"^30.0.0","@typescript/typescript6":"^6.0.2",acorn:"^8.18.0",culls:"^0.2.0","estree-walker":"^3.0.3",mitata:"^1.0.34",svelte:"^5.56.9",typescript:"^7.0.2"},bin:{sveld:"cli.js"},files:["lib","cli.js"],repository:{type:"git",url:"git+https://github.com/carbon-design-system/sveld.git"},homepage:"https://github.com/carbon-design-system/sveld",bugs:"https://github.com/carbon-design-system/sveld/issues",keywords:["svelte","svelte component","documentation","docgen","typescript","definitions","JSDocs","vite","vite-plugin"],maintainers:["Eric Liu (https://github.com/metonym)"]};var re="5.56.9";var Ce=1,Nt=new WeakMap;function j(e,t={}){let n=Nt.get(e),o=n?.get(t.entryExports);if(o)return o;let r=Array.from(e,([,i])=>{let{diagnostics:a,...p}=i;return p}).sort((i,a)=>i.moduleName.localeCompare(a.moduleName)),s={schemaVersion:Ce,generator:{name:At,version:xe,svelteVersion:re},total:r.length,components:r};if(t.entryExports&&t.entryExports.length>0)s.totalExports=t.entryExports.length,s.exports=t.entryExports;if(!n)n=new Map,Nt.set(e,n);return n.set(t.entryExports,s),s}import{readFile as Co}from"node:fs/promises";import Eo from"node:path";var Ot={none:0,patch:1,minor:2,major:3};function vo(e,t){return Ot[t]>Ot[e]?t:e}function So(e){return e.reduce((t,n)=>vo(t,n.bump),"none")}function _t(e){let t=[],n=0,o="",r=null;for(let s=0;s<e.length;s++){let i=e[s];if(r){if(o+=i,i==="\\")s++,o+=e[s]??"";else if(i===r)r=null;continue}if(i==='"'||i==="'"||i==="`"){r=i,o+=i;continue}if(i==="<"||i==="("||i==="{"||i==="[")n++;if(i===">"||i===")"||i==="}"||i==="]")n--;if(i==="|"&&n===0){t.push(o.trim()),o="";continue}o+=i}return t.push(o.trim()),new Set(t.filter((s)=>s.length>0))}function Ue(e,t){if(e===t)return"none";if(e===void 0||t===void 0)return"major";let n=_t(e),o=_t(t),r=[...o].some((i)=>!n.has(i)),s=[...n].some((i)=>!o.has(i));if(!r&&!s)return"none";if(r&&!s)return"minor";if(s&&!r)return"major";return"major"}function jt(e,t,n,o){let r=t==="prop"?"prop":"export",s=[],i=new Map(n.map((p)=>[p.name,p])),a=new Map(o.map((p)=>[p.name,p]));for(let[p,c]of a){if(i.has(p))continue;s.push({component:e,kind:t,name:p,bump:c.isRequired?"major":"minor",message:`${r} "${p}" added${c.isRequired?" (required)":""}`})}for(let[p]of i){if(a.has(p))continue;s.push({component:e,kind:t,name:p,bump:"major",message:`${r} "${p}" removed`})}for(let[p,c]of i){let l=a.get(p);if(!l)continue;if(c.isRequired!==l.isRequired)s.push({component:e,kind:t,name:p,bump:l.isRequired?"major":"minor",message:`${r} "${p}" became ${l.isRequired?"required":"optional"}`});let d=Ue(c.type,l.type);if(d!=="none")s.push({component:e,kind:t,name:p,bump:d,message:`${r} "${p}" type changed from \`${c.type??"unknown"}\` to \`${l.type??"unknown"}\``})}return s}function bo(e,t,n){let o=[],r=new Map(t.map((i)=>[i.name,i])),s=new Map(n.map((i)=>[i.name,i]));for(let[i]of s){if(r.has(i))continue;o.push({component:e,kind:"event",name:i,bump:"minor",message:`event "${i}" added`})}for(let[i]of r){if(s.has(i))continue;o.push({component:e,kind:"event",name:i,bump:"major",message:`event "${i}" removed`})}for(let[i,a]of r){let p=s.get(i);if(!p)continue;if(a.type!==p.type){o.push({component:e,kind:"event",name:i,bump:"major",message:`event "${i}" changed from ${a.type} to ${p.type}`});continue}let c=a.type==="dispatched"?a.detail:void 0,l=p.type==="dispatched"?p.detail:void 0,d=Ue(c,l);if(d!=="none")o.push({component:e,kind:"event",name:i,bump:d,message:`event "${i}" detail changed from \`${c??"unknown"}\` to \`${l??"unknown"}\``})}return o}function Mt(e){return e.name??"default"}function Po(e,t,n){let o=[],r=new Map(t.map((i)=>[Mt(i),i])),s=new Map(n.map((i)=>[Mt(i),i]));for(let[i]of s){if(r.has(i))continue;o.push({component:e,kind:"slot",name:i,bump:"minor",message:`slot "${i}" added`})}for(let[i]of r){if(s.has(i))continue;o.push({component:e,kind:"slot",name:i,bump:"major",message:`slot "${i}" removed`})}for(let[i,a]of r){let p=s.get(i);if(!p)continue;let c=Ue(a.slot_props,p.slot_props);if(c!=="none")o.push({component:e,kind:"slot",name:i,bump:c,message:`slot "${i}" props changed from \`${a.slot_props??"none"}\` to \`${p.slot_props??"none"}\``})}return o}var $o=new Set(["description","source","componentCommentSource","tags"]);function Ee(e){if(Array.isArray(e))return e.map(Ee);if(e!==null&&typeof e==="object"){let t={};for(let[n,o]of Object.entries(e)){if($o.has(n))continue;t[n]=Ee(o)}return t}return e}var ko=["generics","rest_props","extends","contexts","typedefs"];function Do(e,t,n){let o=[];for(let r of ko){let s=JSON.stringify(Ee(t[r])),i=JSON.stringify(Ee(n[r]));if(s!==i)o.push({component:e,kind:"shape",name:r,bump:"major",message:`"${r}" changed (breaking)`})}return o}function wo(e,t){let n=t.moduleName;return[...jt(n,"prop",e.props,t.props),...jt(n,"moduleExport",e.moduleExports,t.moduleExports),...bo(n,e.events,t.events),...Po(n,e.slots,t.slots),...Do(n,e,t)]}function To(e,t){let n=[],o=new Map(e.components.map((s)=>[s.moduleName,s])),r=new Map(t.components.map((s)=>[s.moduleName,s]));for(let[s]of r){if(o.has(s))continue;n.push({component:s,kind:"component",bump:"minor",message:`component "${s}" added`})}for(let[s]of o){if(r.has(s))continue;n.push({component:s,kind:"component",bump:"major",message:`component "${s}" removed`})}for(let[s,i]of o){let a=r.get(s);if(!a)continue;n.push(...wo(i,a))}return n}async function Ao(e){let t;try{t=await Co(Eo.resolve(e),"utf-8")}catch(n){if(n.code==="ENOENT")return null;throw n}try{return JSON.parse(t)}catch{throw Error(`sveld: could not parse "${e}" as JSON. Is it a sveld COMPONENT_API.json snapshot?`)}}function Ft(e){if(typeof e.check==="string")return e.check;return e.jsonOptions?.outFile??"COMPONENT_API.json"}async function It(e,t,n={}){let o=await Ao(t);if(o===null)return{snapshotExists:!1,snapshotFile:t,changes:[],bump:"none"};if(o.schemaVersion!==Ce)return{snapshotExists:!0,snapshotFile:t,changes:[{component:"*",kind:"shape",bump:"none",message:`snapshot schemaVersion ${o.schemaVersion} does not match the current schemaVersion ${Ce}; skipping diff`}],bump:"none"};let r=j(e,{entryExports:n.entryExports}),s=To(o,r);return{snapshotExists:!0,snapshotFile:t,changes:s,bump:So(s)}}var Ro={major:"BREAKING",minor:"additive",patch:"patch",none:"no change"};function Bt(e){if(!e.snapshotExists)return`sveld --check: no snapshot found at "${e.snapshotFile}". Run \`sveld --json\` and commit the output first.`;if(e.changes.length===0)return`sveld --check: no API changes detected against "${e.snapshotFile}".`;let t=[],n=e.changes.length;t.push(`sveld --check: ${n} API change${n===1?"":"s"} detected against "${e.snapshotFile}".`),t.push(`Suggested semver bump: ${e.bump}.`);let o=new Map;for(let r of e.changes){let s=o.get(r.component)??[];s.push(r),o.set(r.component,s)}for(let[r,s]of o){t.push(""),t.push(` ${r}`);for(let i of s)t.push(` [${Ro[i.bump]}] ${i.message}`)}return t.join(`
1
+ import{D as ln,E as Ke,F as te,G as Sn,Q as bn,aa as Un,ia as un,v as K,y as cn}from"./chunk-py1s51tb.js";import{sa as hn}from"./chunk-nrz6c5ew.js";import{ua as B,va as T,wa as Oe,xa as W}from"./chunk-syz2wqmb.js";import{Ba as Ze}from"./chunk-ptdfswsv.js";var At="sveld",xe="0.36.10";var Rt={name:At,version:xe,license:"Apache-2.0",description:"Generate TypeScript definitions and component documentation for your Svelte components.",type:"module",main:"./lib/index.js",types:"./lib/index.d.ts",exports:{".":{types:"./lib/index.d.ts",import:"./lib/index.js",default:"./lib/index.js"},"./browser":{types:"./lib/browser.d.ts",import:"./lib/browser.js",default:"./lib/browser.js"}},scripts:{test:"bun test --parallel","test:fixtures-types":"tsc --project tsconfig.fixtures.json","test:e2e":"bun tests/test-e2e.ts",format:"biome format --write .",lint:"biome lint .","lint:fix":"biome check --write --unsafe .",build:"bun scripts/build.ts",bench:"bun scripts/bench.ts","bench:cache":"bun scripts/bench.ts --cache","bench:mitata":"bun scripts/bench-mitata.ts",fuzz:"bun scripts/fuzz-parser.ts",typecheck:"tsc --noEmit"},devDependencies:{"@biomejs/biome":"2.5.10","@sveltejs/acorn-typescript":"1.0.10","@types/bun":"^1.3.14","@types/jest":"^30.0.0","@typescript/typescript6":"^6.0.2",acorn:"^8.18.0",culls:"^0.2.0","estree-walker":"^3.0.3",mitata:"^1.0.34",svelte:"^5.56.9",typescript:"^7.0.2",zimmerframe:"1.1.4"},bin:{sveld:"cli.js"},files:["lib","cli.js"],repository:{type:"git",url:"git+https://github.com/carbon-design-system/sveld.git"},homepage:"https://github.com/carbon-design-system/sveld",bugs:"https://github.com/carbon-design-system/sveld/issues",keywords:["svelte","svelte component","documentation","docgen","typescript","definitions","JSDocs","vite","vite-plugin"],maintainers:["Eric Liu (https://github.com/metonym)"]};var re="5.56.9";var Ce=1,Nt=new WeakMap;function j(e,t={}){let n=Nt.get(e),o=n?.get(t.entryExports);if(o)return o;let r=Array.from(e,([,i])=>{let{diagnostics:a,...p}=i;return p}).sort((i,a)=>i.moduleName.localeCompare(a.moduleName)),s={schemaVersion:Ce,generator:{name:At,version:xe,svelteVersion:re},total:r.length,components:r};if(t.entryExports&&t.entryExports.length>0)s.totalExports=t.entryExports.length,s.exports=t.entryExports;if(!n)n=new Map,Nt.set(e,n);return n.set(t.entryExports,s),s}import{readFile as Co}from"node:fs/promises";import Eo from"node:path";var Ot={none:0,patch:1,minor:2,major:3};function vo(e,t){return Ot[t]>Ot[e]?t:e}function So(e){return e.reduce((t,n)=>vo(t,n.bump),"none")}function _t(e){let t=[],n=0,o="",r=null;for(let s=0;s<e.length;s++){let i=e[s];if(r){if(o+=i,i==="\\")s++,o+=e[s]??"";else if(i===r)r=null;continue}if(i==='"'||i==="'"||i==="`"){r=i,o+=i;continue}if(i==="<"||i==="("||i==="{"||i==="[")n++;if(i===">"||i===")"||i==="}"||i==="]")n--;if(i==="|"&&n===0){t.push(o.trim()),o="";continue}o+=i}return t.push(o.trim()),new Set(t.filter((s)=>s.length>0))}function Ue(e,t){if(e===t)return"none";if(e===void 0||t===void 0)return"major";let n=_t(e),o=_t(t),r=[...o].some((i)=>!n.has(i)),s=[...n].some((i)=>!o.has(i));if(!r&&!s)return"none";if(r&&!s)return"minor";if(s&&!r)return"major";return"major"}function jt(e,t,n,o){let r=t==="prop"?"prop":"export",s=[],i=new Map(n.map((p)=>[p.name,p])),a=new Map(o.map((p)=>[p.name,p]));for(let[p,c]of a){if(i.has(p))continue;s.push({component:e,kind:t,name:p,bump:c.isRequired?"major":"minor",message:`${r} "${p}" added${c.isRequired?" (required)":""}`})}for(let[p]of i){if(a.has(p))continue;s.push({component:e,kind:t,name:p,bump:"major",message:`${r} "${p}" removed`})}for(let[p,c]of i){let l=a.get(p);if(!l)continue;if(c.isRequired!==l.isRequired)s.push({component:e,kind:t,name:p,bump:l.isRequired?"major":"minor",message:`${r} "${p}" became ${l.isRequired?"required":"optional"}`});let d=Ue(c.type,l.type);if(d!=="none")s.push({component:e,kind:t,name:p,bump:d,message:`${r} "${p}" type changed from \`${c.type??"unknown"}\` to \`${l.type??"unknown"}\``})}return s}function bo(e,t,n){let o=[],r=new Map(t.map((i)=>[i.name,i])),s=new Map(n.map((i)=>[i.name,i]));for(let[i]of s){if(r.has(i))continue;o.push({component:e,kind:"event",name:i,bump:"minor",message:`event "${i}" added`})}for(let[i]of r){if(s.has(i))continue;o.push({component:e,kind:"event",name:i,bump:"major",message:`event "${i}" removed`})}for(let[i,a]of r){let p=s.get(i);if(!p)continue;if(a.type!==p.type){o.push({component:e,kind:"event",name:i,bump:"major",message:`event "${i}" changed from ${a.type} to ${p.type}`});continue}let c=a.type==="dispatched"?a.detail:void 0,l=p.type==="dispatched"?p.detail:void 0,d=Ue(c,l);if(d!=="none")o.push({component:e,kind:"event",name:i,bump:d,message:`event "${i}" detail changed from \`${c??"unknown"}\` to \`${l??"unknown"}\``})}return o}function Mt(e){return e.name??"default"}function Po(e,t,n){let o=[],r=new Map(t.map((i)=>[Mt(i),i])),s=new Map(n.map((i)=>[Mt(i),i]));for(let[i]of s){if(r.has(i))continue;o.push({component:e,kind:"slot",name:i,bump:"minor",message:`slot "${i}" added`})}for(let[i]of r){if(s.has(i))continue;o.push({component:e,kind:"slot",name:i,bump:"major",message:`slot "${i}" removed`})}for(let[i,a]of r){let p=s.get(i);if(!p)continue;let c=Ue(a.slot_props,p.slot_props);if(c!=="none")o.push({component:e,kind:"slot",name:i,bump:c,message:`slot "${i}" props changed from \`${a.slot_props??"none"}\` to \`${p.slot_props??"none"}\``})}return o}var $o=new Set(["description","source","componentCommentSource","tags"]);function Ee(e){if(Array.isArray(e))return e.map(Ee);if(e!==null&&typeof e==="object"){let t={};for(let[n,o]of Object.entries(e)){if($o.has(n))continue;t[n]=Ee(o)}return t}return e}var ko=["generics","rest_props","extends","contexts","typedefs"];function Do(e,t,n){let o=[];for(let r of ko){let s=JSON.stringify(Ee(t[r])),i=JSON.stringify(Ee(n[r]));if(s!==i)o.push({component:e,kind:"shape",name:r,bump:"major",message:`"${r}" changed (breaking)`})}return o}function wo(e,t){let n=t.moduleName;return[...jt(n,"prop",e.props,t.props),...jt(n,"moduleExport",e.moduleExports,t.moduleExports),...bo(n,e.events,t.events),...Po(n,e.slots,t.slots),...Do(n,e,t)]}function To(e,t){let n=[],o=new Map(e.components.map((s)=>[s.moduleName,s])),r=new Map(t.components.map((s)=>[s.moduleName,s]));for(let[s]of r){if(o.has(s))continue;n.push({component:s,kind:"component",bump:"minor",message:`component "${s}" added`})}for(let[s]of o){if(r.has(s))continue;n.push({component:s,kind:"component",bump:"major",message:`component "${s}" removed`})}for(let[s,i]of o){let a=r.get(s);if(!a)continue;n.push(...wo(i,a))}return n}async function Ao(e){let t;try{t=await Co(Eo.resolve(e),"utf-8")}catch(n){if(n.code==="ENOENT")return null;throw n}try{return JSON.parse(t)}catch{throw Error(`sveld: could not parse "${e}" as JSON. Is it a sveld COMPONENT_API.json snapshot?`)}}function Ft(e){if(typeof e.check==="string")return e.check;return e.jsonOptions?.outFile??"COMPONENT_API.json"}async function It(e,t,n={}){let o=await Ao(t);if(o===null)return{snapshotExists:!1,snapshotFile:t,changes:[],bump:"none"};if(o.schemaVersion!==Ce)return{snapshotExists:!0,snapshotFile:t,changes:[{component:"*",kind:"shape",bump:"none",message:`snapshot schemaVersion ${o.schemaVersion} does not match the current schemaVersion ${Ce}; skipping diff`}],bump:"none"};let r=j(e,{entryExports:n.entryExports}),s=To(o,r);return{snapshotExists:!0,snapshotFile:t,changes:s,bump:So(s)}}var Ro={major:"BREAKING",minor:"additive",patch:"patch",none:"no change"};function Bt(e){if(!e.snapshotExists)return`sveld --check: no snapshot found at "${e.snapshotFile}". Run \`sveld --json\` and commit the output first.`;if(e.changes.length===0)return`sveld --check: no API changes detected against "${e.snapshotFile}".`;let t=[],n=e.changes.length;t.push(`sveld --check: ${n} API change${n===1?"":"s"} detected against "${e.snapshotFile}".`),t.push(`Suggested semver bump: ${e.bump}.`);let o=new Map;for(let r of e.changes){let s=o.get(r.component)??[];s.push(r),o.set(r.component,s)}for(let[r,s]of o){t.push(""),t.push(` ${r}`);for(let i of s)t.push(` [${Ro[i.bump]}] ${i.message}`)}return t.join(`
2
2
  `)}function Gt(e){let t={kind:"check-report",...e};return W(t)}import{existsSync as No}from"node:fs";import{join as Oo}from"node:path";import{pathToFileURL as _o}from"node:url";var jo=["sveld.config.js","sveld.config.mjs","sveld.config.ts"];function Xi(e){return e}function Mo(e=process.cwd()){for(let t of jo){let n=Oo(e,t);if(No(n))return n}return null}async function Fo(e){let t;try{t=await import(`${_o(e).href}?t=${Date.now()}`)}catch(o){let r=o instanceof Error?o.message:String(o);throw Error(`sveld: failed to load config file "${e}".
3
3
  ${r}`)}let n=t.default;if(!K(n)||Array.isArray(n))throw Error(`sveld: config file "${e}" must export a configuration object as its default export. Did you forget \`export default defineConfig({ ... })\`?`);return n}async function Wt(e=process.cwd()){let t=Mo(e);if(t===null)return{};return Fo(t)}function Lt(...e){return Object.assign({},...e.filter(Boolean))}var He=new Map;function se(e){He.set(e.name,e)}function Xe(e){return He.get(e)}function qi(){return Array.from(He.values())}import{dirname as uo}from"node:path";import{lstatSync as Pn,readdirSync as Rr,readFileSync as Nr,realpathSync as Or,statSync as _r}from"node:fs";import{readFile as jr}from"node:fs/promises";import{dirname as Mr,isAbsolute as Fr,join as Ir,parse as Te,relative as ot,resolve as ue}from"node:path";function ie(e){return e}function L(e){if(e==="")return e;return e.startsWith(".")?e:`./${e}`}import{dirname as Io,resolve as Bo}from"node:path";var Go=/^(['"])(.*)\1$/;function Wo(e,t){let n=e.extends?.import;if(n===void 0)return null;let o=n.replace(Go,"$2");if(!B.test(o))return null;return Bo(Io(t),o)}function ae(e,t){let n=new Map;for(let o of e.values()){let r=t(o.filePath),s=Wo(o,r);if(s===null)continue;let i=n.get(s);if(i===void 0)i=new Set,n.set(s,i);i.add(r)}return n}function ve(e,t){let n=new Set,o=[];for(let r of e)if(!n.has(r))n.add(r),o.push(r);while(o.length>0){let r=o.shift(),s=t.get(r);if(s===void 0)continue;for(let i of s)if(!n.has(i))n.add(i),o.push(i)}return n}var Lo={"prop-unknown-type":"Props without inferred types","context-any-type":"Context values typed as `any`","event-no-source":"@event tags with no dispatch or callback","example-compile-error":"@example blocks that failed to compile","syntax-skipped":"Component syntax sveld skipped"},Vo=["prop-unknown-type","context-any-type","event-no-source","example-compile-error","syntax-skipped"];function Se(e){let t=new Set,n=[];for(let o of e){let r=`${o.component}:${o.kind}:${o.name}`;if(t.has(r))continue;t.add(r),n.push(o)}return n}function Vt(e){if(e.length===0)return"sveld: all types resolved.";let t=[],n=e.length;t.push(`sveld: ${n} unresolved type${n===1?"":"s"} found.`);for(let o of Vo){let r=e.filter((i)=>i.kind===o);if(r.length===0)continue;t.push(""),t.push(`${Lo[o]} (${r.length}):`);let s=new Map;for(let i of r){let a=s.get(i.component)??[];a.push(i),s.set(i.component,a)}for(let[i,a]of s){t.push(` ${i}`);for(let p of a){let c=p.source?` (${i}:${p.source.start.line}:${p.source.start.column})`:"";t.push(` - ${p.message}${c}`)}}}return t.join(`
4
- `)}function Jt(e){return W({kind:"diagnostics",diagnostics:e})}var Jo=/^```([\w-]*)\r?\n([\s\S]*?)\r?\n?```$/,Uo=new Set(["","js","jsx","ts","tsx","javascript","typescript"]);function Ho(e){let t=e.trim();if(t==="")return null;let n=t.match(Jo);if(n){let o=n[1].toLowerCase();if(!Uo.has(o))return null;let r=n[2].trim();return r===""?null:r}if(t.startsWith("<"))return null;return t}function Ut(e){if(!e.isFunction)return"any";return`(${(e.params??[]).map((n)=>`${n.name}${n.optional?"?":""}: any`).join(", ")}) => any`}function be(e,t,n,o,r){let s=(e??[]).filter((a)=>a.name==="example"),i=[];return s.forEach((a,p)=>{let c=Ho(a.body);if(c===null)return;let l=s.length>1;i.push({id:l?`${t}#${p}`:t,name:l?`${n} (example ${p+1})`:n,type:o,code:c,...r?{source:r}:{}})}),i}function Ht(e){return e.name??"default"}function Xt(e){let t=[];for(let n of e.props)t.push(...be(n.tags,`prop:${n.name}`,n.name,Ut(n),n.source));for(let n of e.moduleExports)t.push(...be(n.tags,`export:${n.name}`,n.name,Ut(n),n.source));for(let n of e.slots)t.push(...be(n.tags,`slot:${Ht(n)}`,Ht(n),"any",n.source));for(let n of e.events)t.push(...be(n.tags,`event:${n.name}`,n.name,"any",n.source));return t}import{createHash as Xo}from"node:crypto";import{mkdirSync as Ko,readFileSync as qo,writeFileSync as zo}from"node:fs";import{dirname as Yo,isAbsolute as Qo,join as Zo,resolve as Kt}from"node:path";var qe=2,er=Zo("node_modules",".cache","sveld","parse-cache.json");function ze(){return`${xe}+svelte@${re}`}function zt(e,t){if(typeof t==="string")return Qo(t)?t:Kt(e,t);return Kt(e,er)}function Yt(e){return Xo("sha256").update(e).digest("hex")}function qt(){return{formatVersion:qe,toolchainVersion:ze(),entries:{}}}function tr(e){try{let t=qo(e,"utf-8"),n=JSON.parse(t);if(n.formatVersion!==qe||n.toolchainVersion!==ze())return qt();return n}catch{return qt()}}class Ye{cacheFilePath;file;next=new Map;blocked=new Set;constructor(e){this.cacheFilePath=e,this.file=tr(e)}has(e,t){if(this.blocked.has(e))return!1;let n=this.file.entries[e];return n!==void 0&&n.hash===t}get(e,t){if(this.blocked.has(e))return null;let n=this.file.entries[e];if(n===void 0||n.hash!==t)return null;if(this.next.set(e,n),n.typeScriptMetadata!==void 0)n.parsed[Ke]=n.typeScriptMetadata;return n.parsed}set(e,t,n){this.next.set(e,{hash:t,parsed:n,typeScriptMetadata:n[Ke]})}invalidate(e){this.blocked.add(e)}getGeneratedText(e,t){let n=this.next.get(e);if(n?.generatedText===void 0||n.generatedText.format!==t)return;return n.generatedText.text}setGeneratedText(e,t,n){let o=this.next.get(e);if(o===void 0)return;o.generatedText={format:t,text:n}}save(){Ko(Yo(this.cacheFilePath),{recursive:!0});let e={formatVersion:qe,toolchainVersion:ze(),entries:Object.fromEntries(this.next)};zo(this.cacheFilePath,JSON.stringify(e))}}import{existsSync as De,lstatSync as on,readFileSync as cr}from"node:fs";import{dirname as dn,join as lr,relative as ur,resolve as mn}from"node:path";var Q=null,Qe=null;function q(){if(Q)return Promise.resolve(Q);if(!Qe)Qe=Promise.all([import("./chunk-hpxd4cgm.js"),import("./chunk-n5cjh6db.js")]).then(([e,t])=>(Q={ComponentParser:e.default,parseSvelte:t.parse},Q));return Qe}function Pe(){if(!Q)throw Error("sveld: internal error, parser stack read before loadParserStack() resolved.");return Q}import{existsSync as tn,readFileSync as nr}from"node:fs";import{dirname as et,isAbsolute as or,join as rr,relative as sr,resolve as ke}from"node:path";function Qt(e){if(!K(e))return{};let t=e.svelte;return typeof t==="string"?{svelte:t}:{}}function Zt(e){if(!K(e))return{};let t={};if(typeof e.extends==="string")t.extends=e.extends;if(K(e.compilerOptions)){let n={};if(typeof e.compilerOptions.baseUrl==="string")n.baseUrl=e.compilerOptions.baseUrl;if(K(e.compilerOptions.paths)){let o={};for(let[r,s]of Object.entries(e.compilerOptions.paths))if(Array.isArray(s)&&s.every((i)=>typeof i==="string"))o[r]=s;if(Object.keys(o).length>0)n.paths=o}if(Object.keys(n).length>0)t.compilerOptions=n}return t}var $e=new Map,en=new Map,ir=/\/\*[\s\S]*?\*\/|\/\/.*/g,ar=/[.+?^${}()|[\]\\]/g;function pr(e){let t=e,n=ke(t,"/");while(t!==n){for(let o of["tsconfig.json","jsconfig.json"]){let r=rr(t,o);if(tn(r))return r}t=et(t)}return null}function nn(e){if($e.has(e))return $e.get(e)??null;try{let t=nr(e,"utf-8"),n;try{n=JSON.parse(t)}catch{let r=t.replace(ir,"");n=JSON.parse(r)}let o=Zt(n);if(o.extends){let r=or(o.extends)?o.extends:ke(et(e),o.extends),s=r.endsWith(".json")?r:`${r}.json`;if(tn(s)){let i=nn(s);if(i)o.compilerOptions={...i.compilerOptions,...o.compilerOptions,paths:{...i.compilerOptions?.paths,...o.compilerOptions?.paths}}}}return $e.set(e,o),o}catch{return $e.set(e,null),null}}function pe(e,t){if(e.startsWith(".")||e.startsWith("/"))return e;let n=pr(t);if(!n)return e;let o=nn(n);if(!o?.compilerOptions?.paths)return e;let{baseUrl:r=".",paths:s}=o.compilerOptions,i=et(n),a=ke(i,r);for(let[p,c]of Object.entries(s)){let l=en.get(p);if(!l){let m=p.split("*").map((f)=>f.replace(ar,"\\$&")).join("(.*)");l=new RegExp(`^${m}$`),en.set(p,l)}let d=e.match(l);if(d){let m=c[0];if(!m)continue;let f=m;for(let h=1;h<d.length;h++)f=f.replace("*",d[h]);return ke(a,f)}}return e}function ce(e,t){if(e.startsWith(".")||e.startsWith("/"))return e;let n=pe(e,t);if(n===e)return e;let o=sr(t,n);return o=T(o),o.startsWith(".")?o:`./${o}`}var rn=[".ts",".mts",".cts",".tsx",".js",".mjs",".cjs",".jsx",".d.ts"],dr=/\r?\n/,mr=/^\s*\*+/;function v(e){return e&&typeof e==="object"?e:void 0}function ee(e){return Array.isArray(e)?e:[]}function G(e){return cn(e)?e.name:void 0}function z(e,t){let n=pe(e,t),o=mn(t,n);if(De(o)&&on(o).isFile())return o;for(let r of rn){let s=o+r;if(De(s))return s}if(De(o)&&on(o).isDirectory())for(let r of rn){let s=lr(o,`index${r}`);if(De(s))return s}return null}function fr(e,t){let n=e.slice(0,t).trimEnd();if(!n.endsWith("*/"))return;let o=n.length-2,r=n.lastIndexOf("/**",o);if(r===-1)return;let s=[];for(let i of n.slice(r+3,o).split(dr)){let a=i.replace(mr,"").trim();if(a.startsWith("@"))break;if(a)s.push(a)}return s.join(" ")||void 0}function gr(e,t){let n=e.slice(0,t).trimEnd();if(!n.endsWith("*/"))return;let o=n.length-2,r=n.lastIndexOf("/**",o);if(r===-1)return;return n.slice(r,o+2)}function Z(e,t){if(!t)return;return e.text.slice(t.start,t.end)}function yr(e,t){let n=v(t?.typeAnnotation);if(n?.type!=="TSTypeAnnotation")return;return Z(e,v(n.typeAnnotation))}function tt(e,t){let n=v(t.returnType);return n?.type==="TSTypeAnnotation"?Z(e,v(n.typeAnnotation)):void 0}function sn(e,t){let n=ee(t.params).map((r)=>Z(e,r)??"").join(", "),o=tt(e,t);return`(${n})${o?` => ${o}`:""}`}function fn(e){if(e.type==="Literal"){let t=e.value;if(typeof t==="string")return"string";if(typeof t==="number")return"number";if(typeof t==="boolean")return"boolean"}if(e.type==="TemplateLiteral")return"string";return}function hr(e){if(!e)return;let t=e.lastIndexOf("=>");if(t===-1)return;return e.slice(t+2).trim()||void 0}function an(e){if(e.async||e.generator)return;let t=v(e.body);if(!t)return;let n=[];if(t.type==="BlockStatement"){if(le(t,n),n.length===0)return}else n.push(t);let o;for(let r of n){if(!r)return;let s=fn(r);if(!s)return;if(o===void 0)o=s;else if(o!==s)return}return o}function le(e,t){for(let n of ee(e.body)){if(n.type==="FunctionDeclaration"||n.type==="FunctionExpression"||n.type==="ArrowFunctionExpression")continue;if(n.type==="ReturnStatement"){t.push(v(n.argument)??null);continue}if(n.type==="BlockStatement"){le(n,t);continue}let o=v(n.consequent);if(o?.type==="BlockStatement")le(o,t);else if(o?.type==="ReturnStatement")t.push(v(o.argument)??null);let r=v(n.alternate);if(r?.type==="BlockStatement")le(r,t);else if(r?.type==="ReturnStatement")t.push(v(r.argument)??null);let s=v(n.body);if(s?.type==="BlockStatement")le(s,t)}}function pn(e,t,n){let o=e.filePath,r=fr(e.text,n),s=gr(e.text,n),i=s?un(s):void 0;if(t.type==="VariableDeclaration"){let a=t.kind??"const",p=[];for(let c of ee(t.declarations)){let l=v(c.id),d=G(l);if(!d)continue;let m=yr(e,l),f,g,h,u=v(c.init);if(u)if(u.type==="ArrowFunctionExpression"||u.type==="FunctionExpression"){if(!m)m=sn(e,u);g=tt(e,u)??i??hr(m)??an(u)}else{if(f=Z(e,u),!m)m=fn(u);h=ln(u)??void 0}p.push({name:d,kind:a,type:m,value:f,returnType:g,literalValue:h,description:r,declFile:o,isTypeOnly:!1})}return p}if(t.type==="FunctionDeclaration"||t.type==="TSDeclareFunction"){let a=G(v(t.id));if(!a)return[];return[{name:a,kind:"function",type:sn(e,t),returnType:tt(e,t)??i??an(t),description:r,declFile:o,isTypeOnly:!1}]}if(t.type==="ClassDeclaration"){let a=G(v(t.id));if(!a)return[];return[{name:a,kind:"class",type:a,description:r,declFile:o,isTypeOnly:!1}]}if(t.type==="TSTypeAliasDeclaration"){let a=G(v(t.id));if(!a)return[];return[{name:a,kind:"type",type:Z(e,v(t.typeAnnotation)),description:r,declFile:o,isTypeOnly:!0}]}if(t.type==="TSInterfaceDeclaration"){let a=G(v(t.id));if(!a)return[];return[{name:a,kind:"interface",type:Z(e,v(t.body)),description:r,declFile:o,isTypeOnly:!0}]}if(t.type==="TSEnumDeclaration"){let a=G(v(t.id));if(!a)return[];return[{name:a,kind:"enum",type:a,description:r,declFile:o,isTypeOnly:!1}]}return[]}function xr(e){let t;try{t=cr(e,"utf-8")}catch{return null}let n=`<script lang="ts">
4
+ `)}function Jt(e){return W({kind:"diagnostics",diagnostics:e})}var Jo=/^```([\w-]*)\r?\n([\s\S]*?)\r?\n?```$/,Uo=new Set(["","js","jsx","ts","tsx","javascript","typescript"]);function Ho(e){let t=e.trim();if(t==="")return null;let n=t.match(Jo);if(n){let o=n[1].toLowerCase();if(!Uo.has(o))return null;let r=n[2].trim();return r===""?null:r}if(t.startsWith("<"))return null;return t}function Ut(e){if(!e.isFunction)return"any";return`(${(e.params??[]).map((n)=>`${n.name}${n.optional?"?":""}: any`).join(", ")}) => any`}function be(e,t,n,o,r){let s=(e??[]).filter((a)=>a.name==="example"),i=[];return s.forEach((a,p)=>{let c=Ho(a.body);if(c===null)return;let l=s.length>1;i.push({id:l?`${t}#${p}`:t,name:l?`${n} (example ${p+1})`:n,type:o,code:c,...r?{source:r}:{}})}),i}function Ht(e){return e.name??"default"}function Xt(e){let t=[];for(let n of e.props)t.push(...be(n.tags,`prop:${n.name}`,n.name,Ut(n),n.source));for(let n of e.moduleExports)t.push(...be(n.tags,`export:${n.name}`,n.name,Ut(n),n.source));for(let n of e.slots)t.push(...be(n.tags,`slot:${Ht(n)}`,Ht(n),"any",n.source));for(let n of e.events)t.push(...be(n.tags,`event:${n.name}`,n.name,"any",n.source));return t}import{createHash as Xo}from"node:crypto";import{mkdirSync as Ko,readFileSync as qo,writeFileSync as zo}from"node:fs";import{dirname as Yo,isAbsolute as Qo,join as Zo,resolve as Kt}from"node:path";var qe=2,er=Zo("node_modules",".cache","sveld","parse-cache.json");function ze(){return`${xe}+svelte@${re}`}function zt(e,t){if(typeof t==="string")return Qo(t)?t:Kt(e,t);return Kt(e,er)}function Yt(e){return Xo("sha256").update(e).digest("hex")}function qt(){return{formatVersion:qe,toolchainVersion:ze(),entries:{}}}function tr(e){try{let t=qo(e,"utf-8"),n=JSON.parse(t);if(n.formatVersion!==qe||n.toolchainVersion!==ze())return qt();return n}catch{return qt()}}class Ye{cacheFilePath;file;next=new Map;blocked=new Set;constructor(e){this.cacheFilePath=e,this.file=tr(e)}has(e,t){if(this.blocked.has(e))return!1;let n=this.file.entries[e];return n!==void 0&&n.hash===t}get(e,t){if(this.blocked.has(e))return null;let n=this.file.entries[e];if(n===void 0||n.hash!==t)return null;if(this.next.set(e,n),n.typeScriptMetadata!==void 0)n.parsed[Ke]=n.typeScriptMetadata;return n.parsed}set(e,t,n){this.next.set(e,{hash:t,parsed:n,typeScriptMetadata:n[Ke]})}invalidate(e){this.blocked.add(e)}getGeneratedText(e,t){let n=this.next.get(e);if(n?.generatedText===void 0||n.generatedText.format!==t)return;return n.generatedText.text}setGeneratedText(e,t,n){let o=this.next.get(e);if(o===void 0)return;o.generatedText={format:t,text:n}}save(){Ko(Yo(this.cacheFilePath),{recursive:!0});let e={formatVersion:qe,toolchainVersion:ze(),entries:Object.fromEntries(this.next)};zo(this.cacheFilePath,JSON.stringify(e))}}import{existsSync as De,lstatSync as on,readFileSync as cr}from"node:fs";import{dirname as dn,join as lr,relative as ur,resolve as mn}from"node:path";var Q=null,Qe=null;function q(){if(Q)return Promise.resolve(Q);if(!Qe)Qe=Promise.all([import("./chunk-n9w94djt.js"),import("./chunk-2nrjrvnn.js")]).then(([e,t])=>(Q={ComponentParser:e.default,parseSvelte:t.parse},Q));return Qe}function Pe(){if(!Q)throw Error("sveld: internal error, parser stack read before loadParserStack() resolved.");return Q}import{existsSync as tn,readFileSync as nr}from"node:fs";import{dirname as et,isAbsolute as or,join as rr,relative as sr,resolve as ke}from"node:path";function Qt(e){if(!K(e))return{};let t=e.svelte;return typeof t==="string"?{svelte:t}:{}}function Zt(e){if(!K(e))return{};let t={};if(typeof e.extends==="string")t.extends=e.extends;if(K(e.compilerOptions)){let n={};if(typeof e.compilerOptions.baseUrl==="string")n.baseUrl=e.compilerOptions.baseUrl;if(K(e.compilerOptions.paths)){let o={};for(let[r,s]of Object.entries(e.compilerOptions.paths))if(Array.isArray(s)&&s.every((i)=>typeof i==="string"))o[r]=s;if(Object.keys(o).length>0)n.paths=o}if(Object.keys(n).length>0)t.compilerOptions=n}return t}var $e=new Map,en=new Map,ir=/\/\*[\s\S]*?\*\/|\/\/.*/g,ar=/[.+?^${}()|[\]\\]/g;function pr(e){let t=e,n=ke(t,"/");while(t!==n){for(let o of["tsconfig.json","jsconfig.json"]){let r=rr(t,o);if(tn(r))return r}t=et(t)}return null}function nn(e){if($e.has(e))return $e.get(e)??null;try{let t=nr(e,"utf-8"),n;try{n=JSON.parse(t)}catch{let r=t.replace(ir,"");n=JSON.parse(r)}let o=Zt(n);if(o.extends){let r=or(o.extends)?o.extends:ke(et(e),o.extends),s=r.endsWith(".json")?r:`${r}.json`;if(tn(s)){let i=nn(s);if(i)o.compilerOptions={...i.compilerOptions,...o.compilerOptions,paths:{...i.compilerOptions?.paths,...o.compilerOptions?.paths}}}}return $e.set(e,o),o}catch{return $e.set(e,null),null}}function pe(e,t){if(e.startsWith(".")||e.startsWith("/"))return e;let n=pr(t);if(!n)return e;let o=nn(n);if(!o?.compilerOptions?.paths)return e;let{baseUrl:r=".",paths:s}=o.compilerOptions,i=et(n),a=ke(i,r);for(let[p,c]of Object.entries(s)){let l=en.get(p);if(!l){let m=p.split("*").map((f)=>f.replace(ar,"\\$&")).join("(.*)");l=new RegExp(`^${m}$`),en.set(p,l)}let d=e.match(l);if(d){let m=c[0];if(!m)continue;let f=m;for(let h=1;h<d.length;h++)f=f.replace("*",d[h]);return ke(a,f)}}return e}function ce(e,t){if(e.startsWith(".")||e.startsWith("/"))return e;let n=pe(e,t);if(n===e)return e;let o=sr(t,n);return o=T(o),o.startsWith(".")?o:`./${o}`}var rn=[".ts",".mts",".cts",".tsx",".js",".mjs",".cjs",".jsx",".d.ts"],dr=/\r?\n/,mr=/^\s*\*+/;function v(e){return e&&typeof e==="object"?e:void 0}function ee(e){return Array.isArray(e)?e:[]}function G(e){return cn(e)?e.name:void 0}function z(e,t){let n=pe(e,t),o=mn(t,n);if(De(o)&&on(o).isFile())return o;for(let r of rn){let s=o+r;if(De(s))return s}if(De(o)&&on(o).isDirectory())for(let r of rn){let s=lr(o,`index${r}`);if(De(s))return s}return null}function fr(e,t){let n=e.slice(0,t).trimEnd();if(!n.endsWith("*/"))return;let o=n.length-2,r=n.lastIndexOf("/**",o);if(r===-1)return;let s=[];for(let i of n.slice(r+3,o).split(dr)){let a=i.replace(mr,"").trim();if(a.startsWith("@"))break;if(a)s.push(a)}return s.join(" ")||void 0}function gr(e,t){let n=e.slice(0,t).trimEnd();if(!n.endsWith("*/"))return;let o=n.length-2,r=n.lastIndexOf("/**",o);if(r===-1)return;return n.slice(r,o+2)}function Z(e,t){if(!t)return;return e.text.slice(t.start,t.end)}function yr(e,t){let n=v(t?.typeAnnotation);if(n?.type!=="TSTypeAnnotation")return;return Z(e,v(n.typeAnnotation))}function tt(e,t){let n=v(t.returnType);return n?.type==="TSTypeAnnotation"?Z(e,v(n.typeAnnotation)):void 0}function sn(e,t){let n=ee(t.params).map((r)=>Z(e,r)??"").join(", "),o=tt(e,t);return`(${n})${o?` => ${o}`:""}`}function fn(e){if(e.type==="Literal"){let t=e.value;if(typeof t==="string")return"string";if(typeof t==="number")return"number";if(typeof t==="boolean")return"boolean"}if(e.type==="TemplateLiteral")return"string";return}function hr(e){if(!e)return;let t=e.lastIndexOf("=>");if(t===-1)return;return e.slice(t+2).trim()||void 0}function an(e){if(e.async||e.generator)return;let t=v(e.body);if(!t)return;let n=[];if(t.type==="BlockStatement"){if(le(t,n),n.length===0)return}else n.push(t);let o;for(let r of n){if(!r)return;let s=fn(r);if(!s)return;if(o===void 0)o=s;else if(o!==s)return}return o}function le(e,t){for(let n of ee(e.body)){if(n.type==="FunctionDeclaration"||n.type==="FunctionExpression"||n.type==="ArrowFunctionExpression")continue;if(n.type==="ReturnStatement"){t.push(v(n.argument)??null);continue}if(n.type==="BlockStatement"){le(n,t);continue}let o=v(n.consequent);if(o?.type==="BlockStatement")le(o,t);else if(o?.type==="ReturnStatement")t.push(v(o.argument)??null);let r=v(n.alternate);if(r?.type==="BlockStatement")le(r,t);else if(r?.type==="ReturnStatement")t.push(v(r.argument)??null);let s=v(n.body);if(s?.type==="BlockStatement")le(s,t)}}function pn(e,t,n){let o=e.filePath,r=fr(e.text,n),s=gr(e.text,n),i=s?un(s):void 0;if(t.type==="VariableDeclaration"){let a=t.kind??"const",p=[];for(let c of ee(t.declarations)){let l=v(c.id),d=G(l);if(!d)continue;let m=yr(e,l),f,g,h,u=v(c.init);if(u)if(u.type==="ArrowFunctionExpression"||u.type==="FunctionExpression"){if(!m)m=sn(e,u);g=tt(e,u)??i??hr(m)??an(u)}else{if(f=Z(e,u),!m)m=fn(u);h=ln(u)??void 0}p.push({name:d,kind:a,type:m,value:f,returnType:g,literalValue:h,description:r,declFile:o,isTypeOnly:!1})}return p}if(t.type==="FunctionDeclaration"||t.type==="TSDeclareFunction"){let a=G(v(t.id));if(!a)return[];return[{name:a,kind:"function",type:sn(e,t),returnType:tt(e,t)??i??an(t),description:r,declFile:o,isTypeOnly:!1}]}if(t.type==="ClassDeclaration"){let a=G(v(t.id));if(!a)return[];return[{name:a,kind:"class",type:a,description:r,declFile:o,isTypeOnly:!1}]}if(t.type==="TSTypeAliasDeclaration"){let a=G(v(t.id));if(!a)return[];return[{name:a,kind:"type",type:Z(e,v(t.typeAnnotation)),description:r,declFile:o,isTypeOnly:!0}]}if(t.type==="TSInterfaceDeclaration"){let a=G(v(t.id));if(!a)return[];return[{name:a,kind:"interface",type:Z(e,v(t.body)),description:r,declFile:o,isTypeOnly:!0}]}if(t.type==="TSEnumDeclaration"){let a=G(v(t.id));if(!a)return[];return[{name:a,kind:"enum",type:a,description:r,declFile:o,isTypeOnly:!1}]}return[]}function xr(e){let t;try{t=cr(e,"utf-8")}catch{return null}let n=`<script lang="ts">
5
5
  ${t}
6
- </script>`;try{let o=Pe().parseSvelte(n,{modern:!0}),r=ee(o.instance?.content?.body);return{source:{text:n,filePath:e,dir:dn(e)},body:r}}catch(o){let r=o instanceof Error?o.message:String(o);return console.warn(`Warning: Failed to parse entry export module ${e}: ${r}`),null}}function Cr(e,t){for(let n of e){if(n.type!=="ImportDeclaration")continue;let o=v(n.source)?.value;if(typeof o!=="string")continue;for(let r of ee(n.specifiers)){if(r.type!=="ImportSpecifier")continue;if(G(v(r.local))===t){let s=G(v(r.imported))??t;return{specifier:o,importedName:s}}}}return null}function V(e,t){let n=t.cache.get(e);if(n)return n;if(t.computing.has(e))return[];t.computing.add(e);let o=xr(e);if(!o)return t.computing.delete(e),t.cache.set(e,[]),[];let{source:r,body:s}=o,i=[],a=new Map;for(let c of s){let l=c.type==="ExportNamedDeclaration"?v(c.declaration):c;if(!l)continue;for(let d of pn(r,l,l.start))a.set(d.name,d)}let p=(c)=>{let l=a.get(c);if(l)return l;let d=Cr(s,c);if(!d||d.specifier.endsWith(".svelte"))return null;let m=z(d.specifier,r.dir);if(!m)return null;return V(m,t).find((f)=>f.name===d.importedName)??null};for(let c of s){if(c.type==="ExportAllDeclaration"){let g=v(c.source)?.value;if(typeof g!=="string"||g.endsWith(".svelte"))continue;let h=z(g,r.dir);if(!h)continue;let u=c.exportKind==="type";for(let C of V(h,t))i.push(u?{...C,isTypeOnly:!0}:C);continue}if(c.type!=="ExportNamedDeclaration")continue;let l=v(c.declaration);if(l){i.push(...pn(r,l,c.start));continue}let d=v(c.source)?.value,m=typeof d==="string"?d:void 0;if(m?.endsWith(".svelte"))continue;let f=c.exportKind==="type";for(let g of ee(c.specifiers)){if(g.type!=="ExportSpecifier")continue;let h=G(v(g.exported)),u=G(v(g.local));if(!h||!u||u==="default"||h==="default")continue;let C=f||g.exportKind==="type",y=null;if(m){let S=z(m,r.dir);if(S)y=V(S,t).find((E)=>E.name===u)??null}else y=p(u);if(y?.declFile.endsWith(".svelte"))continue;if(y)i.push({...y,name:h,isTypeOnly:y.isTypeOnly||C});else i.push({name:h,kind:C?"type":"const",declFile:e,isTypeOnly:C})}}return t.computing.delete(e),t.cache.set(e,i),i}async function we(e){await q();let t=mn(e),n=dn(t),o=V(t,{cache:new Map,computing:new Set}),r=new Map;for(let s of o){let{declFile:i,returnType:a,...p}=s,c=T(`./${ur(n,i)}`);r.set(s.name,{...p,source:c})}return Array.from(r.values()).sort((s,i)=>s.name.localeCompare(i.name))}import{lstatSync as Er,readdirSync as vr,readFileSync as Sr}from"node:fs";import{dirname as br,join as gn,resolve as Pr}from"node:path";var yn=new Map;function $r(e){return hn(e,{ecmaVersion:"latest",sourceType:"module"})}function nt(e,t,n=new Set){let o=yn.get(e);if(!o)o=$r(e),yn.set(e,o);let r={};for(let s of o.body)if(s.type==="ExportDefaultDeclaration"){let i=s.declaration.name;if(i in r)r[i].default=!0;else r[i]={source:L(""),default:!0}}else if(s.type==="ExportAllDeclaration"){if(!s.source)continue;let i=pe(s.source.value,t),a=Pr(t,i);if(!Er(a).isFile()){let l=vr(a);for(let d of l)if(d.includes("index")){a=gn(a,d);break}}if(n.has(a))continue;n.add(a);let p=Sr(a,"utf-8"),c=nt(p,br(a),n);n.delete(a);for(let[l,d]of Object.entries(c)){let m=L(T(`./${gn(s.source.value,d.source)}`));r[l]={...d,source:m}}}else if(s.type==="ExportNamedDeclaration")for(let i of s.specifiers){let a=i.exported.name,p=i.local.name,c=a||p;if(c in r){if(s.type==="ExportNamedDeclaration")r[c].mixed=!0;if(!r[c].source)r[c].source=L(ce(s.source?.value??"",t))}else r[c]={source:L(ce(s.source?.value??"",t)),default:p==="default"}}else if(s.type==="ImportDeclaration"){let i=s.specifiers[0].local.name;if(i in r){if(!r[i].source)r[i].source=L(ce(s.source?.value??"",t))}else r[i]={source:L(ce(s.source?.value??"",t)),default:i==="default"}}return r}import{existsSync as kr}from"node:fs";import{dirname as Dr}from"node:path";function xn(){return{cache:new Map,computing:new Set}}var wr=/\.[^./\\]+$/;function Tr(e){if(e.endsWith(".d.ts"))return null;let t=e.replace(wr,".d.ts");return kr(t)?t:null}function Cn(e,t,n){let o=Dr(e);return t.map((r)=>{if(!r.importSource||!r.importedName)return{candidate:r};let s=z(r.importSource,o);if(!s)return{candidate:r,failureReason:"module-not-found"};let i=V(s,n).find((p)=>p.name===r.importedName);if(!i)return{candidate:r,failureReason:"export-not-found"};if(i.returnType)return{candidate:r,type:i.returnType};let a=Tr(s);if(a){let p=V(a,n).find((c)=>c.name===r.importedName);if(p?.returnType)return{candidate:r,type:p.returnType}}return{candidate:r,failureReason:"return-type-unresolved"}})}function En(e,t){switch(t){case"module-not-found":return`Prop "${e.propName}" default calls "${e.calleeName}()", but "${e.importSource}" could not be resolved; falling back to "any".`;case"export-not-found":return`Prop "${e.propName}" default calls "${e.calleeName}()", but "${e.importedName}" is not exported from "${e.importSource}"; falling back to "any".`;case"return-type-unresolved":return`Prop "${e.propName}" default calls "${e.calleeName}()" imported from "${e.importSource}", but its return type could not be resolved; falling back to "any".`}}import{dirname as Ar}from"node:path";function vn(e,t,n){let o=Ar(e);return t.map((r)=>{let s=z(r.importSource,o);if(!s)return{candidate:r};let i=V(s,n).find((a)=>a.name===r.importedName);if(i?.kind!=="const"||i.literalValue===void 0)return{candidate:r};return{candidate:r,key:i.literalValue}})}function de(e){return{failFast:e?.failFast,resolveTypes:e?.resolveTypes===!0,documentExports:e?.documentExports===!0,cache:e?.cache,checkExamples:e?.checkExamples===!0,dryRun:e?.dryRun===!0}}var Br=/-/g;function $n(e,t=[],n=new Set){let o;try{let r=Or(e);if(n.has(r))return t;n.add(r),o=Rr(e,{withFileTypes:!0})}catch{return t}for(let r of o){if(r.name.startsWith("."))continue;let s=Ir(e,r.name),i=r.isSymbolicLink()?_r(s,{throwIfNoEntry:!1}):r;if(!i)continue;if(i.isDirectory())$n(s,t,n);else if(i.isFile()&&r.name.endsWith(".svelte"))t.push(s)}return t}function Gr(e){return $n(e).map((t)=>{let n=Te(t).name.replace(Br,""),o=L(T(`./${ot(e,t)}`));return{moduleName:n,source:o}}).sort((t,n)=>t.source.localeCompare(n.source))}function Wr(e){return Te(e).ext!==".svelte"}function Lr(e,t){let n=e.endsWith("/")?e:`${e}/`;return t.startsWith(n)}function rt(e,t){return{seenPaths:new Set(e.map(([,n])=>t(n.source))),seenModuleNamePaths:new Map(e.map(([n,o])=>[n,t(o.source)])),warnedModuleNames:new Set}}function st(e,t,n,o,r){for(let{moduleName:s,source:i}of Gr(e)){let a=o(i),p=t[s];if(p&&Wr(p.source)&&Lr(p.source,i)){r.seenPaths.delete(o(p.source)),p.source=i,r.seenPaths.add(a),r.seenModuleNamePaths.set(s,a);continue}if(r.seenPaths.has(a))continue;r.seenPaths.add(a);let c=r.seenModuleNamePaths.get(s);if(c===void 0)r.seenModuleNamePaths.set(s,a);else if(c!==a&&!r.warnedModuleNames.has(s))r.warnedModuleNames.add(s),console.warn(`Warning: multiple components named "${s}" found (${T(ot(e,c))} and ${T(ot(e,a))}). Both are included in TypeScript definitions, but only one can be the named export.`);n.push([s,{source:i,default:!1}])}}function it(e,t,n=!1){let o=Pn(e).isFile(),r=o?Mr(e):e,s=ue(r),i=(c)=>Fr(c)?ue(c):ue(s,c),a={};if(o){let c=Nr(e,"utf-8");try{a=nt(c,s,new Set([ue(e)]))}catch(l){if(!n)throw l;let d=l instanceof Error?l.message:String(l);console.warn(`Warning: Failed to parse component exports from ${e}: ${d}`)}}let p=Object.entries(a);if(t){let c=rt(p,i);st(s,a,p,i,c)}return{exports:a,allComponentEntries:p,rootDir:s,resolveComponentFilePath:i}}async function Ae(e){let t=await Promise.all(Array.from(e).map(async(n)=>{try{let o=await jr(n,"utf-8");return{path:n,content:o}}catch(o){return console.warn(`Warning: Failed to read file ${n}:`,o),{path:n,content:null}}}));return new Map(t.map(({path:n,content:o})=>[n,o]))}function H([e,t],n,o,r,s={}){let i=t.source,{ext:a,name:p}=Te(i),c=e;if(n.length===1&&e==="default")c=p;if(a===".svelte"){let l=r(i),d=o.get(l);if(d===null||d===void 0)return null;let m=T(i),f=s.memo?.get(l),g=s.hashes?.get(l),h=f===void 0?g===void 0?null:s.cache?.get(l,g):null,u;if(f!==void 0)u=f;else if(h)u=h;else{let C=new(Pe()).ComponentParser;try{u=C.parseSvelteComponent(d,{moduleName:c,filePath:m})}catch(y){if(s.failFast)throw y;let S=y instanceof Error?y.message:String(y),E=y instanceof Error?y.stack:void 0;return s.onParseError?.({filePath:m,moduleName:c,message:S,stack:E}),null}if(g!==void 0)s.cache?.set(l,g,u);s.memo?.set(l,u)}return{moduleName:c,filePath:m,...u}}return null}function at(e,t){let n=new Set;for(let o of e)for(let[,r]of o)if(Te(r.source).ext===".svelte")n.add(t(r.source));return n}function Re(e){if(e.length===0)return;console.error(`sveld: failed to parse ${e.length} component(s):`);for(let{filePath:t,message:n}of e)console.error(` - ${t}: ${n}`)}async function me(e,t,n={}){let o=n.documentExports===!0,{exports:r,allComponentEntries:s,rootDir:i,resolveComponentFilePath:a}=it(e,t,o),p=o&&Pn(e).isFile()?await we(ue(e)):[],c=Object.entries(r),l=at([c,s],a),d=await Ae(l),m=new Map,f=new Map,g=n.cache===!1?void 0:new Ye(zt(i,n.cache??!0)),h=g?new Map:void 0,u=new Set,C=new Map;if(g)for(let b of l){let x=d.get(b);if(x===null||x===void 0)continue;let k=Yt(x);if(C.set(b,k),!g.has(b,k))u.add(b)}if(l.size>0&&(!g||u.size>0))await q();let y=new Map,S=new Map,E={failFast:n.failFast===!0,onParseError:(b)=>y.set(b.filePath,b),cache:g,hashes:C,memo:S};for(let b of c){let x=H(b,c,d,a,E);if(x)m.set(x.moduleName,x)}for(let b of s){let x=H(b,s,d,a,E);if(x)f.set(x.filePath,x),h?.set(x.filePath,a(b[1].source))}if(g&&u.size>0){let b=ae(f,a),x=ve(u,b);for(let k of x){if(u.has(k))continue;g.invalidate(k),S.delete(k)}for(let k of c){let _=a(k[1].source);if(!x.has(_)||u.has(_))continue;let I=H(k,c,d,a,E);if(I)m.set(I.moduleName,I)}for(let k of s){let _=a(k[1].source);if(!x.has(_)||u.has(_))continue;let I=H(k,s,d,a,E);if(I)f.set(I.filePath,I),h?.set(I.filePath,_)}}let P=Array.from(y.values());if(Re(P),!n.dryRun)g?.save();let A=n.resolveTypes?Xr(m):[],O=n.checkExamples?qr(f):[];if(A.length>0||O.length>0){let{TypeResolver:b}=await import("./chunk-bbeezhqq.js"),x=await b.create(i);try{if(A.length>0)await Kr(A,x,a);if(O.length>0)await zr(O,x,a)}finally{await x?.dispose()}}let D=Vr(f),w=Ur(f);if(D.length>0||w.length>0){await q();let b=xn();for(let{component:x,candidates:k}of D){let _=Cn(a(x.filePath),k,b);Jr(x,_)}for(let{component:x,candidates:k}of w){let _=vn(a(x.filePath),k,b);Hr(x,_)}}let U=Se(Array.from(f.values()).flatMap((b)=>b.diagnostics??[]));return{exports:r,entryExports:p,components:m,allComponentsForTypes:f,errors:P,diagnostics:U,cache:g,resolvedPathByFilePath:h}}function Vr(e){let t=[];for(let n of e.values()){let o=te(n)?.pendingCallDefaultCandidates?.filter((r)=>r.importSource!==void 0);if(!o||o.length===0)continue;t.push({component:n,candidates:o})}return t}function Jr(e,t){for(let{candidate:n,type:o,failureReason:r}of t){let i=(n.location==="props"?e.props:e.moduleExports).find((a)=>a.name===n.propName);if(i?.typeSource!=="unknown")continue;if(o){if(i.type=o,i.typeSource="typescript",n.location==="props")e.diagnostics=(e.diagnostics??[]).filter((a)=>!(a.kind==="prop-unknown-type"&&a.name===n.propName));continue}if(n.location==="props"&&r){let a=e.diagnostics?.find((p)=>p.kind==="prop-unknown-type"&&p.name===n.propName);if(a)a.message=En(n,r)}}}function Ur(e){let t=[];for(let n of e.values()){let o=te(n)?.pendingContextKeyCandidates;if(!o||o.length===0)continue;t.push({component:n,candidates:o})}return t}function Hr(e,t){for(let{candidate:n,key:o}of t){if(!o){console.warn(`Warning: Could not resolve setContext key in ${e.filePath}. Use a string literal, const-bound string, or Symbol(). Skipping context type generation.`);continue}if(e.contexts?.some((r)=>r.key===o))continue;e.contexts=[...e.contexts??[],{key:o,typeName:bn(o),description:n.description,properties:n.properties}]}}function Xr(e){let t=[];for(let n of e.values()){let o=te(n);if(!o?.canonicalPropsType||n.props.length>0)continue;t.push({component:n,metadata:o})}return t}async function Kr(e,t,n){if(!t)return;let o=await t.expandAll(e.map(({component:r,metadata:s})=>({moduleName:r.moduleName,metadata:s,filePath:n(r.filePath)})));for(let{component:r}of e){let s=o.get(n(r.filePath));if(s)Sn(r,s)}}function qr(e){let t=[];for(let n of e.values()){let o=Xt(n);if(o.length===0)continue;t.push({component:n,sources:o})}return t}async function zr(e,t,n){if(!t)return;let o=await t.checkExamples(e.map(({component:r,sources:s})=>({moduleName:r.moduleName,filePath:n(r.filePath),sources:s})));for(let{component:r,sources:s}of e){let i=o.get(n(r.filePath));if(!i||i.length===0)continue;let a=new Map(s.map((c)=>[c.id,c.source])),p=r.diagnostics??[];for(let c of i){let l=a.get(c.id);p.push({component:r.filePath,kind:"example-compile-error",name:c.name,message:c.message,...l?{source:l}:{}})}r.diagnostics=p}}import{existsSync as kn,readFileSync as Yr}from"node:fs";import{join as Dn}from"node:path";function Ne(e){if(e){let n=Dn(process.cwd(),e);if(kn(n))return ie(e);return console.error(`Invalid entry point: ${n}. Pass a valid --entry (or "entry" option), or unset it and`),console.error('set the "svelte" field in your package.json instead.'),null}let t=Dn(process.cwd(),"package.json");if(!kn(t))return console.error("Could not locate a package.json file."),console.error(`Specify an entry point with --entry (or the "entry" option) instead.
6
+ </script>`;try{let o=Pe().parseSvelte(n),r=ee(o.instance?.content?.body);return{source:{text:n,filePath:e,dir:dn(e)},body:r}}catch(o){let r=o instanceof Error?o.message:String(o);return console.warn(`Warning: Failed to parse entry export module ${e}: ${r}`),null}}function Cr(e,t){for(let n of e){if(n.type!=="ImportDeclaration")continue;let o=v(n.source)?.value;if(typeof o!=="string")continue;for(let r of ee(n.specifiers)){if(r.type!=="ImportSpecifier")continue;if(G(v(r.local))===t){let s=G(v(r.imported))??t;return{specifier:o,importedName:s}}}}return null}function V(e,t){let n=t.cache.get(e);if(n)return n;if(t.computing.has(e))return[];t.computing.add(e);let o=xr(e);if(!o)return t.computing.delete(e),t.cache.set(e,[]),[];let{source:r,body:s}=o,i=[],a=new Map;for(let c of s){let l=c.type==="ExportNamedDeclaration"?v(c.declaration):c;if(!l)continue;for(let d of pn(r,l,l.start))a.set(d.name,d)}let p=(c)=>{let l=a.get(c);if(l)return l;let d=Cr(s,c);if(!d||d.specifier.endsWith(".svelte"))return null;let m=z(d.specifier,r.dir);if(!m)return null;return V(m,t).find((f)=>f.name===d.importedName)??null};for(let c of s){if(c.type==="ExportAllDeclaration"){let g=v(c.source)?.value;if(typeof g!=="string"||g.endsWith(".svelte"))continue;let h=z(g,r.dir);if(!h)continue;let u=c.exportKind==="type";for(let C of V(h,t))i.push(u?{...C,isTypeOnly:!0}:C);continue}if(c.type!=="ExportNamedDeclaration")continue;let l=v(c.declaration);if(l){i.push(...pn(r,l,c.start));continue}let d=v(c.source)?.value,m=typeof d==="string"?d:void 0;if(m?.endsWith(".svelte"))continue;let f=c.exportKind==="type";for(let g of ee(c.specifiers)){if(g.type!=="ExportSpecifier")continue;let h=G(v(g.exported)),u=G(v(g.local));if(!h||!u||u==="default"||h==="default")continue;let C=f||g.exportKind==="type",y=null;if(m){let S=z(m,r.dir);if(S)y=V(S,t).find((E)=>E.name===u)??null}else y=p(u);if(y?.declFile.endsWith(".svelte"))continue;if(y)i.push({...y,name:h,isTypeOnly:y.isTypeOnly||C});else i.push({name:h,kind:C?"type":"const",declFile:e,isTypeOnly:C})}}return t.computing.delete(e),t.cache.set(e,i),i}async function we(e){await q();let t=mn(e),n=dn(t),o=V(t,{cache:new Map,computing:new Set}),r=new Map;for(let s of o){let{declFile:i,returnType:a,...p}=s,c=T(`./${ur(n,i)}`);r.set(s.name,{...p,source:c})}return Array.from(r.values()).sort((s,i)=>s.name.localeCompare(i.name))}import{lstatSync as Er,readdirSync as vr,readFileSync as Sr}from"node:fs";import{dirname as br,join as gn,resolve as Pr}from"node:path";var yn=new Map;function $r(e){return hn(e,{ecmaVersion:"latest",sourceType:"module"})}function nt(e,t,n=new Set){let o=yn.get(e);if(!o)o=$r(e),yn.set(e,o);let r={};for(let s of o.body)if(s.type==="ExportDefaultDeclaration"){let i=s.declaration.name;if(i in r)r[i].default=!0;else r[i]={source:L(""),default:!0}}else if(s.type==="ExportAllDeclaration"){if(!s.source)continue;let i=pe(s.source.value,t),a=Pr(t,i);if(!Er(a).isFile()){let l=vr(a);for(let d of l)if(d.includes("index")){a=gn(a,d);break}}if(n.has(a))continue;n.add(a);let p=Sr(a,"utf-8"),c=nt(p,br(a),n);n.delete(a);for(let[l,d]of Object.entries(c)){let m=L(T(`./${gn(s.source.value,d.source)}`));r[l]={...d,source:m}}}else if(s.type==="ExportNamedDeclaration")for(let i of s.specifiers){let a=i.exported.name,p=i.local.name,c=a||p;if(c in r){if(s.type==="ExportNamedDeclaration")r[c].mixed=!0;if(!r[c].source)r[c].source=L(ce(s.source?.value??"",t))}else r[c]={source:L(ce(s.source?.value??"",t)),default:p==="default"}}else if(s.type==="ImportDeclaration"){let i=s.specifiers[0].local.name;if(i in r){if(!r[i].source)r[i].source=L(ce(s.source?.value??"",t))}else r[i]={source:L(ce(s.source?.value??"",t)),default:i==="default"}}return r}import{existsSync as kr}from"node:fs";import{dirname as Dr}from"node:path";function xn(){return{cache:new Map,computing:new Set}}var wr=/\.[^./\\]+$/;function Tr(e){if(e.endsWith(".d.ts"))return null;let t=e.replace(wr,".d.ts");return kr(t)?t:null}function Cn(e,t,n){let o=Dr(e);return t.map((r)=>{if(!r.importSource||!r.importedName)return{candidate:r};let s=z(r.importSource,o);if(!s)return{candidate:r,failureReason:"module-not-found"};let i=V(s,n).find((p)=>p.name===r.importedName);if(!i)return{candidate:r,failureReason:"export-not-found"};if(i.returnType)return{candidate:r,type:i.returnType};let a=Tr(s);if(a){let p=V(a,n).find((c)=>c.name===r.importedName);if(p?.returnType)return{candidate:r,type:p.returnType}}return{candidate:r,failureReason:"return-type-unresolved"}})}function En(e,t){switch(t){case"module-not-found":return`Prop "${e.propName}" default calls "${e.calleeName}()", but "${e.importSource}" could not be resolved; falling back to "any".`;case"export-not-found":return`Prop "${e.propName}" default calls "${e.calleeName}()", but "${e.importedName}" is not exported from "${e.importSource}"; falling back to "any".`;case"return-type-unresolved":return`Prop "${e.propName}" default calls "${e.calleeName}()" imported from "${e.importSource}", but its return type could not be resolved; falling back to "any".`}}import{dirname as Ar}from"node:path";function vn(e,t,n){let o=Ar(e);return t.map((r)=>{let s=z(r.importSource,o);if(!s)return{candidate:r};let i=V(s,n).find((a)=>a.name===r.importedName);if(i?.kind!=="const"||i.literalValue===void 0)return{candidate:r};return{candidate:r,key:i.literalValue}})}function de(e){return{failFast:e?.failFast,resolveTypes:e?.resolveTypes===!0,documentExports:e?.documentExports===!0,cache:e?.cache,checkExamples:e?.checkExamples===!0,dryRun:e?.dryRun===!0}}var Br=/-/g;function $n(e,t=[],n=new Set){let o;try{let r=Or(e);if(n.has(r))return t;n.add(r),o=Rr(e,{withFileTypes:!0})}catch{return t}for(let r of o){if(r.name.startsWith("."))continue;let s=Ir(e,r.name),i=r.isSymbolicLink()?_r(s,{throwIfNoEntry:!1}):r;if(!i)continue;if(i.isDirectory())$n(s,t,n);else if(i.isFile()&&r.name.endsWith(".svelte"))t.push(s)}return t}function Gr(e){return $n(e).map((t)=>{let n=Te(t).name.replace(Br,""),o=L(T(`./${ot(e,t)}`));return{moduleName:n,source:o}}).sort((t,n)=>t.source.localeCompare(n.source))}function Wr(e){return Te(e).ext!==".svelte"}function Lr(e,t){let n=e.endsWith("/")?e:`${e}/`;return t.startsWith(n)}function rt(e,t){return{seenPaths:new Set(e.map(([,n])=>t(n.source))),seenModuleNamePaths:new Map(e.map(([n,o])=>[n,t(o.source)])),warnedModuleNames:new Set}}function st(e,t,n,o,r){for(let{moduleName:s,source:i}of Gr(e)){let a=o(i),p=t[s];if(p&&Wr(p.source)&&Lr(p.source,i)){r.seenPaths.delete(o(p.source)),p.source=i,r.seenPaths.add(a),r.seenModuleNamePaths.set(s,a);continue}if(r.seenPaths.has(a))continue;r.seenPaths.add(a);let c=r.seenModuleNamePaths.get(s);if(c===void 0)r.seenModuleNamePaths.set(s,a);else if(c!==a&&!r.warnedModuleNames.has(s))r.warnedModuleNames.add(s),console.warn(`Warning: multiple components named "${s}" found (${T(ot(e,c))} and ${T(ot(e,a))}). Both are included in TypeScript definitions, but only one can be the named export.`);n.push([s,{source:i,default:!1}])}}function it(e,t,n=!1){let o=Pn(e).isFile(),r=o?Mr(e):e,s=ue(r),i=(c)=>Fr(c)?ue(c):ue(s,c),a={};if(o){let c=Nr(e,"utf-8");try{a=nt(c,s,new Set([ue(e)]))}catch(l){if(!n)throw l;let d=l instanceof Error?l.message:String(l);console.warn(`Warning: Failed to parse component exports from ${e}: ${d}`)}}let p=Object.entries(a);if(t){let c=rt(p,i);st(s,a,p,i,c)}return{exports:a,allComponentEntries:p,rootDir:s,resolveComponentFilePath:i}}async function Ae(e){let t=await Promise.all(Array.from(e).map(async(n)=>{try{let o=await jr(n,"utf-8");return{path:n,content:o}}catch(o){return console.warn(`Warning: Failed to read file ${n}:`,o),{path:n,content:null}}}));return new Map(t.map(({path:n,content:o})=>[n,o]))}function H([e,t],n,o,r,s={}){let i=t.source,{ext:a,name:p}=Te(i),c=e;if(n.length===1&&e==="default")c=p;if(a===".svelte"){let l=r(i),d=o.get(l);if(d===null||d===void 0)return null;let m=T(i),f=s.memo?.get(l),g=s.hashes?.get(l),h=f===void 0?g===void 0?null:s.cache?.get(l,g):null,u;if(f!==void 0)u=f;else if(h)u=h;else{let C=new(Pe()).ComponentParser;try{u=C.parseSvelteComponent(d,{moduleName:c,filePath:m})}catch(y){if(s.failFast)throw y;let S=y instanceof Error?y.message:String(y),E=y instanceof Error?y.stack:void 0;return s.onParseError?.({filePath:m,moduleName:c,message:S,stack:E}),null}if(g!==void 0)s.cache?.set(l,g,u);s.memo?.set(l,u)}return{moduleName:c,filePath:m,...u}}return null}function at(e,t){let n=new Set;for(let o of e)for(let[,r]of o)if(Te(r.source).ext===".svelte")n.add(t(r.source));return n}function Re(e){if(e.length===0)return;console.error(`sveld: failed to parse ${e.length} component(s):`);for(let{filePath:t,message:n}of e)console.error(` - ${t}: ${n}`)}async function me(e,t,n={}){let o=n.documentExports===!0,{exports:r,allComponentEntries:s,rootDir:i,resolveComponentFilePath:a}=it(e,t,o),p=o&&Pn(e).isFile()?await we(ue(e)):[],c=Object.entries(r),l=at([c,s],a),d=await Ae(l),m=new Map,f=new Map,g=n.cache===!1?void 0:new Ye(zt(i,n.cache??!0)),h=g?new Map:void 0,u=new Set,C=new Map;if(g)for(let b of l){let x=d.get(b);if(x===null||x===void 0)continue;let k=Yt(x);if(C.set(b,k),!g.has(b,k))u.add(b)}if(l.size>0&&(!g||u.size>0))await q();let y=new Map,S=new Map,E={failFast:n.failFast===!0,onParseError:(b)=>y.set(b.filePath,b),cache:g,hashes:C,memo:S};for(let b of c){let x=H(b,c,d,a,E);if(x)m.set(x.moduleName,x)}for(let b of s){let x=H(b,s,d,a,E);if(x)f.set(x.filePath,x),h?.set(x.filePath,a(b[1].source))}if(g&&u.size>0){let b=ae(f,a),x=ve(u,b);for(let k of x){if(u.has(k))continue;g.invalidate(k),S.delete(k)}for(let k of c){let _=a(k[1].source);if(!x.has(_)||u.has(_))continue;let I=H(k,c,d,a,E);if(I)m.set(I.moduleName,I)}for(let k of s){let _=a(k[1].source);if(!x.has(_)||u.has(_))continue;let I=H(k,s,d,a,E);if(I)f.set(I.filePath,I),h?.set(I.filePath,_)}}let P=Array.from(y.values());if(Re(P),!n.dryRun)g?.save();let A=n.resolveTypes?Xr(m):[],O=n.checkExamples?qr(f):[];if(A.length>0||O.length>0){let{TypeResolver:b}=await import("./chunk-bbeezhqq.js"),x=await b.create(i);try{if(A.length>0)await Kr(A,x,a);if(O.length>0)await zr(O,x,a)}finally{await x?.dispose()}}let D=Vr(f),w=Ur(f);if(D.length>0||w.length>0){await q();let b=xn();for(let{component:x,candidates:k}of D){let _=Cn(a(x.filePath),k,b);Jr(x,_)}for(let{component:x,candidates:k}of w){let _=vn(a(x.filePath),k,b);Hr(x,_)}}let U=Se(Array.from(f.values()).flatMap((b)=>b.diagnostics??[]));return{exports:r,entryExports:p,components:m,allComponentsForTypes:f,errors:P,diagnostics:U,cache:g,resolvedPathByFilePath:h}}function Vr(e){let t=[];for(let n of e.values()){let o=te(n)?.pendingCallDefaultCandidates?.filter((r)=>r.importSource!==void 0);if(!o||o.length===0)continue;t.push({component:n,candidates:o})}return t}function Jr(e,t){for(let{candidate:n,type:o,failureReason:r}of t){let i=(n.location==="props"?e.props:e.moduleExports).find((a)=>a.name===n.propName);if(i?.typeSource!=="unknown")continue;if(o){if(i.type=o,i.typeSource="typescript",n.location==="props")e.diagnostics=(e.diagnostics??[]).filter((a)=>!(a.kind==="prop-unknown-type"&&a.name===n.propName));continue}if(n.location==="props"&&r){let a=e.diagnostics?.find((p)=>p.kind==="prop-unknown-type"&&p.name===n.propName);if(a)a.message=En(n,r)}}}function Ur(e){let t=[];for(let n of e.values()){let o=te(n)?.pendingContextKeyCandidates;if(!o||o.length===0)continue;t.push({component:n,candidates:o})}return t}function Hr(e,t){for(let{candidate:n,key:o}of t){if(!o){console.warn(`Warning: Could not resolve setContext key in ${e.filePath}. Use a string literal, const-bound string, or Symbol(). Skipping context type generation.`);continue}if(e.contexts?.some((r)=>r.key===o))continue;e.contexts=[...e.contexts??[],{key:o,typeName:bn(o),description:n.description,properties:n.properties}]}}function Xr(e){let t=[];for(let n of e.values()){let o=te(n);if(!o?.canonicalPropsType||n.props.length>0)continue;t.push({component:n,metadata:o})}return t}async function Kr(e,t,n){if(!t)return;let o=await t.expandAll(e.map(({component:r,metadata:s})=>({moduleName:r.moduleName,metadata:s,filePath:n(r.filePath)})));for(let{component:r}of e){let s=o.get(n(r.filePath));if(s)Sn(r,s)}}function qr(e){let t=[];for(let n of e.values()){let o=Xt(n);if(o.length===0)continue;t.push({component:n,sources:o})}return t}async function zr(e,t,n){if(!t)return;let o=await t.checkExamples(e.map(({component:r,sources:s})=>({moduleName:r.moduleName,filePath:n(r.filePath),sources:s})));for(let{component:r,sources:s}of e){let i=o.get(n(r.filePath));if(!i||i.length===0)continue;let a=new Map(s.map((c)=>[c.id,c.source])),p=r.diagnostics??[];for(let c of i){let l=a.get(c.id);p.push({component:r.filePath,kind:"example-compile-error",name:c.name,message:c.message,...l?{source:l}:{}})}r.diagnostics=p}}import{existsSync as kn,readFileSync as Yr}from"node:fs";import{join as Dn}from"node:path";function Ne(e){if(e){let n=Dn(process.cwd(),e);if(kn(n))return ie(e);return console.error(`Invalid entry point: ${n}. Pass a valid --entry (or "entry" option), or unset it and`),console.error('set the "svelte" field in your package.json instead.'),null}let t=Dn(process.cwd(),"package.json");if(!kn(t))return console.error("Could not locate a package.json file."),console.error(`Specify an entry point with --entry (or the "entry" option) instead.
7
7
  `),null;try{let n=Qt(JSON.parse(Yr(t,"utf-8")));if(n.svelte?.trim())return ie(n.svelte);return console.error(`Could not determine an entry point.
8
8
  `),console.error(`Specify an entry point to your Svelte code in the "svelte" field of your package.json, or pass --entry (or the "entry" option).
9
9
  `),null}catch(n){throw console.error("Error reading package.json:",n),n}}import{lstatSync as Qr}from"node:fs";import{resolve as wn}from"node:path";async function Tn(e,t,n=!1){let{exports:o,allComponentEntries:r,rootDir:s,resolveComponentFilePath:i}=it(e,t,n),a=n&&Qr(e).isFile()?await we(wn(e)):[],p=Object.entries(o),c=rt(r,i),l=new Map,d=new Map;await q();let m=new Map,f={onParseError:(y)=>m.set(y.filePath,y)},g=()=>({exports:o,entryExports:a,components:l,allComponentsForTypes:d,errors:Array.from(m.values()),diagnostics:Se(Array.from(d.values()).flatMap((y)=>y.diagnostics??[]))});{let y=at([p,r],i),S=await Ae(y);for(let E of p){let P=H(E,p,S,i,f);if(P)l.set(P.moduleName,P)}for(let E of r){let P=H(E,r,S,i,f);if(P)d.set(P.filePath,P)}Re(g().errors)}let h=ae(d,i),u=(y,S,E,P,A)=>{let O=new Set;for(let D of E){let w=i(D[1].source);if(!P.has(w))continue;let U=H(D,E,A,i,f);if(U)y.set(S(U),U),O.add(w);else for(let[b,x]of y)if(i(x.filePath)===w)y.delete(b)}return O};return{get result(){return g()},update:async(y)=>{let S=y.filter((D)=>B.test(D)).map((D)=>wn(D));if(S.length===0)return{result:g(),reparsed:[]};if(t)st(s,o,r,i,c);let E=ve(S,h);for(let[D,w]of m)if(E.has(i(w.filePath)))m.delete(D);let P=await Ae(E),A=new Set;for(let D of u(l,(w)=>w.moduleName,p,E,P))A.add(D);for(let D of u(d,(w)=>w.filePath,r,E,P))A.add(D);h=ae(d,i);let O=g();return Re(O.errors),{result:O,reparsed:Array.from(A)}}}}import ls from"node:path";var An=!1;function Rn(e){An=e}function J(e){if(!An)console.error(e)}import{mkdir as Zr,readFile as es,writeFile as ts}from"node:fs/promises";import{parse as ns}from"node:path";class R{dryRun;constructor(e){this.dryRun=e?.dryRun===!0}async write(e,t){if(this.dryRun)return console.log(`would write "${T(e)}"`),!0;try{if(await es(e,"utf-8")===t)return!1}catch{}return await Zr(ns(e).dir,{recursive:!0}),await ts(e,t),!0}}var os=new Set(["string","number","boolean"]);function rs(e){return e.map((t)=>({kind:"field",name:t.name,...t.type?{type:{text:t.type}}:{},...t.value===void 0?{}:{default:t.value},...t.description?{description:t.description}:{},...t.deprecated===void 0?{}:{deprecated:t.deprecated}}))}function ss(e){let t=new Map;for(let o of e){if(!o.type||!os.has(o.type.trim()))continue;let r=o.name.toLowerCase(),s=t.get(r);if(s)s.push(o);else t.set(r,[o])}let n=[];for(let[o,r]of t){if(r.length!==1)continue;let s=r[0];n.push({name:o,fieldName:s.name,type:{text:s.type},...s.value===void 0?{}:{default:s.value},...s.description?{description:s.description}:{}})}return n}function is(e){return e.filter((t)=>t.type==="dispatched").map((t)=>({name:t.name,type:{text:`CustomEvent<${t.detail??"unknown"}>`},...t.description?{description:t.description}:{},...t.deprecated===void 0?{}:{deprecated:t.deprecated}}))}function as(e){return e.map((t)=>({name:t.default?"":t.name??"",...t.description?{description:t.description}:{},...t.deprecated===void 0?{}:{deprecated:t.deprecated}}))}function ps(e){let t={kind:"class",name:e.moduleName,...e.componentComment?{description:e.componentComment}:{},members:rs(e.props),attributes:ss(e.props),events:is(e.events),slots:as(e.slots)};if(e.customElementTag)t.tagName=e.customElementTag,t.customElement=!0;return t}function cs(e,t){let n=[{kind:"js",name:e.moduleName,declaration:{name:e.moduleName,module:t}}];if(e.customElementTag)n.push({kind:"custom-element-definition",name:e.customElementTag,declaration:{name:e.moduleName,module:t}});return n}function Nn(e,t={}){let n=j(e),o=t.resolveModulePath??((s)=>s.filePath);return{schemaVersion:"1.0.0",modules:n.components.map((s)=>{let i=o(s);return{kind:"javascript-module",path:i,declarations:[ps(s)],exports:cs(s,i)}})}}function pt(e,t){let n=Nn(e,{resolveModulePath:(o)=>Oe(o.filePath,t.inputDir)});return W(n)}async function ct(e,t){let n=pt(e,t),o=ls.join(process.cwd(),t.outFile);if(await new R({dryRun:t.dryRun}).write(o,n),!t.dryRun)J(`created "${t.outFile}".`)}import lt from"node:path";function On(e){let t=new Map;for(let[o,r]of Object.entries(e)){let s=t.get(r.source)||[];s.push({id:o,exportee:r}),t.set(r.source,s)}let n=[];for(let[o,r]of t){let s=B.test(o),i=r.some(({id:m,exportee:f})=>m!=="default"&&f.default),a=r.some(({exportee:m})=>!m.default),p=s&&i&&a,c=[],l=[],d=[];for(let{id:m,exportee:f}of r){if(m==="default"){l.push(`export { default } from "${o}";`);continue}if(f.default)if(f.mixed)l.push(`export { default as ${m} } from "${o}";`),l.push(`export { default } from "${o}";`);else d.push(`default as ${m}`);else if(s&&!p)d.push(`default as ${m}`);else c.push(m)}if(d.length>0&&c.length>0)n.push(`export { ${[...d,...c].join(", ")} } from "${o}";`);else{if(c.length>0)n.push(`export { ${c.join(", ")} } from "${o}";`);if(d.length>0)n.push(`export { ${d.join(", ")} } from "${o}";`)}n.push(...l)}return n.join(`