UNPKG

svgfusion

Version:

Convert SVG files into blazing-fast React and Vue 3 components with automatic color extraction, full TypeScript support, and seamless integration into any modern workflow.

30 lines 120 kB
import {toReactProp,camelCase}from'svgfusion-utils';export{formatComponentName,pascalCase,sanitizeComponentName,svgToComponentName}from'svgfusion-utils';import {ComponentGenerator}from'svgfusion-core';var mt=Object.defineProperty;var Lr=(e,t,r)=>t in e?mt(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r;var H=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Rr=(e,t)=>()=>(e&&(t=e(e=0)),t);var zr=(e,t)=>{for(var r in t)mt(e,r,{get:t[r],enumerable:true});};var ge=(e,t,r)=>Lr(e,t+"",r);var ft={};zr(ft,{__debug:()=>Ir,check:()=>Pr,default:()=>cs,doc:()=>st,format:()=>dt,formatWithCursor:()=>ct,getSupportInfo:()=>Tr,util:()=>ot,version:()=>Or});function iu(e,t,r){return nu.diff(e,t,r)}function su(e){let t=e.indexOf("\r");return t!==-1?e.charAt(t+1)===` `?"crlf":"cr":"lf"}function Ke(e){switch(e){case "cr":return "\r";case "crlf":return `\r `;default:return ` `}}function Kt(e,t){let r;switch(t){case ` `:r=/\n/gu;break;case "\r":r=/\r/gu;break;case `\r `:r=/\r\n/gu;break;default:throw new Error(`Unexpected "eol" ${JSON.stringify(t)}.`)}let u=e.match(r);return u?u.length:0}function ou(e){return ke(false,e,/\r\n?/gu,` `)}function lu(e){let t=e.length;for(;t>0&&(e[t-1]==="\r"||e[t-1]===` `);)t--;return t<e.length?e.slice(0,t):e}function Du(e){if(typeof e=="string")return te;if(Array.isArray(e))return j;if(!e)return;let{type:t}=e;if(Xt.has(t))return t}function cu(e){let t=e===null?"null":typeof e;if(t!=="string"&&t!=="object")return `Unexpected doc '${t}', Expected it to be 'string' or 'object'.`;if(re(e))throw new Error("doc is valid.");let r=Object.prototype.toString.call(e);if(r!=="[object Object]")return `Unexpected doc '${r}'.`;let u=pu([...Xt].map(n=>`'${n}'`));return `Unexpected doc.type '${e.type}'. Expected it to be ${u}.`}function fu(e,t,r,u){let n=[e];for(;n.length>0;){let i=n.pop();if(i===Ft){r(n.pop());continue}r&&n.push(i,Ft);let s=re(i);if(!s)throw new ie(i);if(t?.(i)!==false)switch(s){case j:case P:{let o=s===j?i:i.parts;for(let a=o.length,l=a-1;l>=0;--l)n.push(o[l]);break}case x:n.push(i.flatContents,i.breakContents);break;case S:if(u&&i.expandedStates)for(let o=i.expandedStates.length,a=o-1;a>=0;--a)n.push(i.expandedStates[a]);else n.push(i.contents);break;case _:case W:case V:case T:case L:n.push(i.contents);break;case te:case q:case M:case R:case w:case A:break;default:throw new ie(i)}}}function Se(e,t){if(typeof e=="string")return t(e);let r=new Map;return u(e);function u(i){if(r.has(i))return r.get(i);let s=n(i);return r.set(i,s),s}function n(i){switch(re(i)){case j:return t(i.map(u));case P:return t({...i,parts:i.parts.map(u)});case x:return t({...i,breakContents:u(i.breakContents),flatContents:u(i.flatContents)});case S:{let{expandedStates:s,contents:o}=i;return s?(s=s.map(u),o=s[0]):o=u(o),t({...i,contents:o,expandedStates:s})}case _:case W:case V:case T:case L:return t({...i,contents:u(i.contents)});case te:case q:case M:case R:case w:case A:return t(i);default:throw new ie(i)}}}function Ye(e,t,r){let u=r,n=false;function i(s){if(n)return false;let o=t(s);o!==void 0&&(n=true,u=o);}return Xe(e,i),u}function hu(e){if(e.type===S&&e.break||e.type===w&&e.hard||e.type===A)return true}function mu(e){return Ye(e,hu,false)}function gt(e){if(e.length>0){let t=b(false,e,-1);!t.expandedStates&&!t.break&&(t.break="propagated");}return null}function Fu(e){let t=new Set,r=[];function u(i){if(i.type===A&&gt(r),i.type===S){if(r.push(i),t.has(i))return false;t.add(i);}}function n(i){i.type===S&&r.pop().break&&gt(r);}Xe(e,u,n,true);}function gu(e){return e.type===w&&!e.hard?e.soft?"":" ":e.type===x?e.flatContents:e}function Cu(e){return Se(e,gu)}function Ct(e){for(e=[...e];e.length>=2&&b(false,e,-2).type===w&&b(false,e,-1).type===A;)e.length-=2;if(e.length>0){let t=ce(b(false,e,-1));e[e.length-1]=t;}return e}function ce(e){switch(re(e)){case W:case V:case S:case L:case T:{let t=ce(e.contents);return {...e,contents:t}}case x:return {...e,breakContents:ce(e.breakContents),flatContents:ce(e.flatContents)};case P:return {...e,parts:Ct(e.parts)};case j:return Ct(e);case te:return lu(e);case _:case q:case M:case R:case w:case A:break;default:throw new ie(e)}return e}function Yt(e){return ce(Eu(e))}function yu(e){switch(re(e)){case P:if(e.parts.every(t=>t===""))return "";break;case S:if(!e.contents&&!e.id&&!e.break&&!e.expandedStates)return "";if(e.contents.type===S&&e.contents.id===e.id&&e.contents.break===e.break&&e.contents.expandedStates===e.expandedStates)return e.contents;break;case _:case W:case V:case L:if(!e.contents)return "";break;case x:if(!e.flatContents&&!e.breakContents)return "";break;case j:{let t=[];for(let r of e){if(!r)continue;let[u,...n]=Array.isArray(r)?r:[r];typeof u=="string"&&typeof b(false,t,-1)=="string"?t[t.length-1]+=u:t.push(u),t.push(...n);}return t.length===0?"":t.length===1?t[0]:t}case te:case q:case M:case R:case w:case T:case A:break;default:throw new ie(e)}return e}function Eu(e){return Se(e,t=>yu(t))}function vu(e,t=rr){return Se(e,r=>typeof r=="string"?ur(t,r.split(` `)):r)}function bu(e){if(e.type===w)return true}function wu(e){return Ye(e,bu,false)}function Ee(e,t){return e.type===T?{...e,contents:t(e.contents)}:t(e)}function we(e){return O(e),{type:W,contents:e}}function se(e,t){return O(t),{type:_,contents:t,n:e}}function Qt(e,t={}){return O(e),Zt(t.expandedStates,true),{type:S,id:t.id,contents:e,break:!!t.shouldBreak,expandedStates:t.expandedStates}}function Su(e){return se(Number.NEGATIVE_INFINITY,e)}function xu(e){return se({type:"root"},e)}function Bu(e){return se(-1,e)}function Au(e,t){return Qt(e[0],{...t,expandedStates:e})}function $u(e){return ku(e),{type:P,parts:e}}function Nu(e,t="",r={}){return O(e),t!==""&&O(t),{type:x,breakContents:e,flatContents:t,groupId:r.groupId}}function Ou(e,t){return O(e),{type:V,contents:e,groupId:t.groupId,negate:t.negate}}function Me(e){return O(e),{type:L,contents:e}}function ur(e,t){O(e),Zt(t);let r=[];for(let u=0;u<t.length;u++)u!==0&&r.push(e),r.push(t[u]);return r}function nr(e,t,r){O(e);let u=e;if(t>0){for(let n=0;n<Math.floor(t/r);++n)u=we(u);u=se(t%r,u),u=se(Number.NEGATIVE_INFINITY,u);}return u}function ju(e,t){return O(t),e?{type:T,label:e,contents:t}:t}function I(e){var t;if(!e)return "";if(Array.isArray(e)){let r=[];for(let u of e)if(Array.isArray(u))r.push(...I(u));else {let n=I(u);n!==""&&r.push(n);}return r}return e.type===x?{...e,breakContents:I(e.breakContents),flatContents:I(e.flatContents)}:e.type===S?{...e,contents:I(e.contents),expandedStates:(t=e.expandedStates)==null?void 0:t.map(I)}:e.type===P?{type:"fill",parts:e.parts.map(I)}:e.contents?{...e,contents:I(e.contents)}:e}function Wu(e){let t=Object.create(null),r=new Set;return u(I(e));function u(i,s,o){var a,l;if(typeof i=="string")return JSON.stringify(i);if(Array.isArray(i)){let D=i.map(u).filter(Boolean);return D.length===1?D[0]:`[${D.join(", ")}]`}if(i.type===w){let D=((a=o?.[s+1])==null?void 0:a.type)===A;return i.literal?D?"literalline":"literallineWithoutBreakParent":i.hard?D?"hardline":"hardlineWithoutBreakParent":i.soft?"softline":"line"}if(i.type===A)return ((l=o?.[s-1])==null?void 0:l.type)===w&&o[s-1].hard?void 0:"breakParent";if(i.type===M)return "trim";if(i.type===W)return "indent("+u(i.contents)+")";if(i.type===_)return i.n===Number.NEGATIVE_INFINITY?"dedentToRoot("+u(i.contents)+")":i.n<0?"dedent("+u(i.contents)+")":i.n.type==="root"?"markAsRoot("+u(i.contents)+")":"align("+JSON.stringify(i.n)+", "+u(i.contents)+")";if(i.type===x)return "ifBreak("+u(i.breakContents)+(i.flatContents?", "+u(i.flatContents):"")+(i.groupId?(i.flatContents?"":', ""')+`, { groupId: ${n(i.groupId)} }`:"")+")";if(i.type===V){let D=[];i.negate&&D.push("negate: true"),i.groupId&&D.push(`groupId: ${n(i.groupId)}`);let f=D.length>0?`, { ${D.join(", ")} }`:"";return `indentIfBreak(${u(i.contents)}${f})`}if(i.type===S){let D=[];i.break&&i.break!=="propagated"&&D.push("shouldBreak: true"),i.id&&D.push(`id: ${n(i.id)}`);let f=D.length>0?`, { ${D.join(", ")} }`:"";return i.expandedStates?`conditionalGroup([${i.expandedStates.map(p=>u(p)).join(",")}]${f})`:`group(${u(i.contents)}${f})`}if(i.type===P)return `fill([${i.parts.map(D=>u(D)).join(", ")}])`;if(i.type===L)return "lineSuffix("+u(i.contents)+")";if(i.type===R)return "lineSuffixBoundary";if(i.type===T)return `label(${JSON.stringify(i.label)}, ${u(i.contents)})`;if(i.type===q)return "cursor";throw new Error("Unknown doc type "+i.type)}function n(i){if(typeof i!="symbol")return JSON.stringify(String(i));if(i in t)return t[i];let s=i.description||"symbol";for(let o=0;;o++){let a=s+(o>0?` #${o}`:"");if(!r.has(a))return r.add(a),t[i]=`Symbol.for(${JSON.stringify(a)})`}}}function Mu(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function Vu(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101631&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129673||e>=129679&&e<=129734||e>=129742&&e<=129756||e>=129759&&e<=129769||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function zu(e){if(!e)return 0;if(!Ru.test(e))return e.length;e=e.replace(_u()," ");let t=0;for(let r of e){let u=r.codePointAt(0);u<=31||u>=127&&u<=159||u>=768&&u<=879||(t+=Lu(u)?1:2);}return t}function ir(){return {value:"",length:0,queue:[]}}function Gu(e,t){return Le(e,{type:"indent"},t)}function qu(e,t,r){return t===Number.NEGATIVE_INFINITY?e.root||ir():t<0?Le(e,{type:"dedent"},r):t?t.type==="root"?{...e,root:e}:Le(e,{type:typeof t=="string"?"stringAlign":"numberAlign",n:t},r):e}function Le(e,t,r){let u=t.type==="dedent"?e.queue.slice(0,-1):[...e.queue,t],n="",i=0,s=0,o=0;for(let d of u)switch(d.type){case "indent":D(),r.useTabs?a(1):l(r.tabWidth);break;case "stringAlign":D(),n+=d.n,i+=d.n.length;break;case "numberAlign":s+=1,o+=d.n;break;default:throw new Error(`Unexpected type '${d.type}'`)}return p(),{...e,value:n,length:i,queue:u};function a(d){n+=" ".repeat(d),i+=r.tabWidth*d;}function l(d){n+=" ".repeat(d),i+=d;}function D(){r.useTabs?f():p();}function f(){s>0&&a(s),c();}function p(){o>0&&l(o),c();}function c(){s=0,o=0;}}function Re(e){let t=0,r=0,u=e.length;e:for(;u--;){let n=e[u];if(n===ue){r++;continue}for(let i=n.length-1;i>=0;i--){let s=n[i];if(s===" "||s===" ")t++;else {e[u]=n.slice(0,i+1);break e}}}if(t>0||r>0)for(e.length=u+1;r-- >0;)e.push(ue);return t}function Ce(e,t,r,u,n,i){if(r===Number.POSITIVE_INFINITY)return true;let s=t.length,o=[e],a=[];for(;r>=0;){if(o.length===0){if(s===0)return true;o.push(t[--s]);continue}let{mode:l,doc:D}=o.pop(),f=re(D);switch(f){case te:a.push(D),r-=et(D);break;case j:case P:{let p=f===j?D:D.parts,c=D[Ve]??0;for(let d=p.length-1;d>=c;d--)o.push({mode:l,doc:p[d]});break}case W:case _:case V:case T:o.push({mode:l,doc:D.contents});break;case M:r+=Re(a);break;case S:{if(i&&D.break)return false;let p=D.break?k:l,c=D.expandedStates&&p===k?b(false,D.expandedStates,-1):D.contents;o.push({mode:p,doc:c});break}case x:{let p=(D.groupId?n[D.groupId]||$:l)===k?D.breakContents:D.flatContents;p&&o.push({mode:l,doc:p});break}case w:if(l===k||D.hard)return true;D.soft||(a.push(" "),r--);break;case L:u=true;break;case R:if(u)return false;break}}return false}function Be(e,t){let r={},u=t.printWidth,n=Ke(t.endOfLine),i=0,s=[{ind:ir(),mode:k,doc:e}],o=[],a=false,l=[],D=0;for(Fu(e);s.length>0;){let{ind:p,mode:c,doc:d}=s.pop();switch(re(d)){case te:{let h=n!==` `?ke(false,d,` `,n):d;o.push(h),s.length>0&&(i+=et(h));break}case j:for(let h=d.length-1;h>=0;h--)s.push({ind:p,mode:c,doc:d[h]});break;case q:if(D>=2)throw new Error("There are too many 'cursor' in doc.");o.push(ue),D++;break;case W:s.push({ind:Gu(p,t),mode:c,doc:d.contents});break;case _:s.push({ind:qu(p,d.n,t),mode:c,doc:d.contents});break;case M:i-=Re(o);break;case S:switch(c){case $:if(!a){s.push({ind:p,mode:d.break?k:$,doc:d.contents});break}case k:{a=false;let h={ind:p,mode:$,doc:d.contents},m=u-i,F=l.length>0;if(!d.break&&Ce(h,s,m,F,r))s.push(h);else if(d.expandedStates){let y=b(false,d.expandedStates,-1);if(d.break){s.push({ind:p,mode:k,doc:y});break}else for(let C=1;C<d.expandedStates.length+1;C++)if(C>=d.expandedStates.length){s.push({ind:p,mode:k,doc:y});break}else {let E=d.expandedStates[C],g={ind:p,mode:$,doc:E};if(Ce(g,s,m,F,r)){s.push(g);break}}}else s.push({ind:p,mode:k,doc:d.contents});break}}d.id&&(r[d.id]=b(false,s,-1).mode);break;case P:{let h=u-i,m=d[Ve]??0,{parts:F}=d,y=F.length-m;if(y===0)break;let C=F[m+0],E=F[m+1],g={ind:p,mode:$,doc:C},v={ind:p,mode:k,doc:C},B=Ce(g,[],h,l.length>0,r,true);if(y===1){B?s.push(g):s.push(v);break}let U={ind:p,mode:$,doc:E},De={ind:p,mode:k,doc:E};if(y===2){B?s.push(U,g):s.push(De,v);break}let Vr=F[m+2],Oe={ind:p,mode:c,doc:{...d,[Ve]:m+2}};Ce({ind:p,mode:$,doc:[C,E,Vr]},[],h,l.length>0,r,true)?s.push(Oe,U,g):B?s.push(Oe,De,g):s.push(Oe,De,v);break}case x:case V:{let h=d.groupId?r[d.groupId]:c;if(h===k){let m=d.type===x?d.breakContents:d.negate?d.contents:we(d.contents);m&&s.push({ind:p,mode:c,doc:m});}if(h===$){let m=d.type===x?d.flatContents:d.negate?we(d.contents):d.contents;m&&s.push({ind:p,mode:c,doc:m});}break}case L:l.push({ind:p,mode:c,doc:d.contents});break;case R:l.length>0&&s.push({ind:p,mode:c,doc:Qe});break;case w:switch(c){case $:if(d.hard)a=true;else {d.soft||(o.push(" "),i+=1);break}case k:if(l.length>0){s.push({ind:p,mode:c,doc:d},...l.reverse()),l.length=0;break}d.literal?p.root?(o.push(n,p.root.value),i=p.root.length):(o.push(n),i=0):(i-=Re(o),o.push(n+p.value),i=p.length);break}break;case T:s.push({ind:p,mode:c,doc:d.contents});break;case A:break;default:throw new ie(d)}s.length===0&&l.length>0&&(s.push(...l.reverse()),l.length=0);}let f=o.indexOf(ue);if(f!==-1){let p=o.indexOf(ue,f+1);if(p===-1)return {formatted:o.filter(m=>m!==ue).join("")};let c=o.slice(0,f).join(""),d=o.slice(f+1,p).join(""),h=o.slice(p+1).join("");return {formatted:c+d+h,cursorNodeStart:c.length,cursorNodeText:d}}return {formatted:o.join("")}}function Ju(e,t,r=0){let u=0;for(let n=r;n<e.length;++n)e[n]===" "?u=u+t-u%t:u++;return u}function Ku(e){return e!==null&&typeof e=="object"}function*Ae(e,t){let{getVisitorKeys:r,filter:u=()=>true}=t,n=i=>Xu(i)&&u(i);for(let i of r(e)){let s=e[i];if(Array.isArray(s))for(let o of s)n(o)&&(yield o);else n(s)&&(yield s);}}function*Yu(e,t){let r=[e];for(let u=0;u<r.length;u++){let n=r[u];for(let i of Ae(n,t))yield i,r.push(i);}}function Zu(e,t){return Ae(e,t).next().done}function he(e){return (t,r,u)=>{let n=!!(u!=null&&u.backwards);if(r===false)return false;let{length:i}=t,s=r;for(;s>=0&&s<i;){let o=t.charAt(s);if(e instanceof RegExp){if(!e.test(o))return s}else if(!e.includes(o))return s;n?s--:s++;}return s===-1||s===i?s:false}}function en(e,t,r){let u=!!(r!=null&&r.backwards);if(t===false)return false;let n=e.charAt(t);if(u){if(e.charAt(t-1)==="\r"&&n===` `)return t-2;if(n===` `||n==="\r"||n==="\u2028"||n==="\u2029")return t-1}else {if(n==="\r"&&e.charAt(t+1)===` `)return t+2;if(n===` `||n==="\r"||n==="\u2028"||n==="\u2029")return t+1}return t}function tn(e,t,r={}){let u=G(e,r.backwards?t-1:t,r),n=ee(e,u,r);return u!==n}function rn(e){return Array.isArray(e)&&e.length>0}function sn(e){return e?t=>e(t,lr):nn}function on(e){let t=e.type||e.kind||"(unknown type)",r=String(e.name||e.id&&(typeof e.id=="object"?e.id.name:e.id)||e.key&&(typeof e.key=="object"?e.key.name:e.key)||e.value&&(typeof e.value=="object"?"":String(e.value))||e.operator||"");return r.length>20&&(r=r.slice(0,19)+"\u2026"),t+(r?" "+r:"")}function rt(e,t){(e.comments??(e.comments=[])).push(t),t.printed=false,t.nodeDescription=on(e);}function de(e,t){t.leading=true,t.trailing=false,rt(e,t);}function X(e,t,r){t.leading=false,t.trailing=false,r&&(t.marker=r),rt(e,t);}function fe(e,t){t.leading=false,t.trailing=true,rt(e,t);}function ut(e,t){if(Pe.has(e))return Pe.get(e);let{printer:{getCommentChildNodes:r,canAttachComment:u,getVisitorKeys:n},locStart:i,locEnd:s}=t;if(!u)return [];let o=(r?.(e,t)??[...Ae(e,{getVisitorKeys:$e(n)})]).flatMap(a=>u(a)?[a]:ut(a,t));return o.sort((a,l)=>i(a)-i(l)||s(a)-s(l)),Pe.set(e,o),o}function Dr(e,t,r,u){let{locStart:n,locEnd:i}=r,s=n(t),o=i(t),a=ut(e,r),l,D,f=0,p=a.length;for(;f<p;){let c=f+p>>1,d=a[c],h=n(d),m=i(d);if(h<=s&&o<=m)return Dr(d,t,r,d);if(m<=s){l=d,f=c+1;continue}if(o<=h){D=d,p=c;continue}throw new Error("Comment location overlaps with node location")}if(u?.type==="TemplateLiteral"){let{quasis:c}=u,d=Ie(c,t,r);l&&Ie(c,l,r)!==d&&(l=null),D&&Ie(c,D,r)!==d&&(D=null);}return {enclosingNode:u,precedingNode:l,followingNode:D}}function an(e,t){let{comments:r}=e;if(delete e.comments,!un(r)||!t.printer.canAttachComment)return;let u=[],{printer:{experimentalFeatures:{avoidAstMutation:n=false}={},handleComments:i={}},originalText:s}=t,{ownLine:o=Te,endOfLine:a=Te,remaining:l=Te}=i,D=r.map((f,p)=>({...Dr(e,f,t),comment:f,text:s,options:t,ast:e,isLastComment:r.length-1===p}));for(let[f,p]of D.entries()){let{comment:c,precedingNode:d,enclosingNode:h,followingNode:m,text:F,options:y,ast:C,isLastComment:E}=p,g;if(n?g=[p]:(c.enclosingNode=h,c.precedingNode=d,c.followingNode=m,g=[c,F,y,C,E]),ln(F,y,D,f))c.placement="ownLine",o(...g)||(m?de(m,c):d?fe(d,c):X(h||C,c));else if(Dn(F,y,D,f))c.placement="endOfLine",a(...g)||(d?fe(d,c):m?de(m,c):X(h||C,c));else if(c.placement="remaining",!l(...g))if(d&&m){let v=u.length;v>0&&u[v-1].followingNode!==m&&yt(u,y),u.push(p);}else d?fe(d,c):m?de(m,c):X(h||C,c);}if(yt(u,t),!n)for(let f of r)delete f.precedingNode,delete f.enclosingNode,delete f.followingNode;}function ln(e,t,r,u){let{comment:n,precedingNode:i}=r[u],{locStart:s,locEnd:o}=t,a=s(n);if(i)for(let l=u-1;l>=0;l--){let{comment:D,precedingNode:f}=r[l];if(f!==i||!pr(e.slice(o(D),a)))break;a=s(D);}return z(e,a,{backwards:true})}function Dn(e,t,r,u){let{comment:n,followingNode:i}=r[u],{locStart:s,locEnd:o}=t,a=o(n);if(i)for(let l=u+1;l<r.length;l++){let{comment:D,followingNode:f}=r[l];if(f!==i||!pr(e.slice(a,s(D))))break;a=o(D);}return z(e,a)}function yt(e,t){var r,u;let n=e.length;if(n===0)return;let{precedingNode:i,followingNode:s}=e[0],o=t.locStart(s),a;for(a=n;a>0;--a){let{comment:l,precedingNode:D,followingNode:f}=e[a-1];Ge.strictEqual(D,i),Ge.strictEqual(f,s);let p=t.originalText.slice(t.locEnd(l),o);if(((u=(r=t.printer).isGap)==null?void 0:u.call(r,p,t))??/^[\s(]*$/u.test(p))o=t.locStart(l);else break}for(let[l,{comment:D}]of e.entries())l<a?fe(i,D):de(s,D);for(let l of [i,s])l.comments&&l.comments.length>1&&l.comments.sort((D,f)=>t.locStart(D)-t.locStart(f));e.length=0;}function Ie(e,t,r){let u=r.locStart(t)-1;for(let n=1;n<e.length;++n)if(u<r.locStart(e[n]))return n-1;return 0}function pn(e,t){let r=t-1;r=G(e,r,{backwards:true}),r=ee(e,r,{backwards:true}),r=G(e,r,{backwards:true});let u=ee(e,r,{backwards:true});return r!==u}function cr(e,t){let r=e.node;return r.printed=true,t.printer.printComment(e,t)}function cn(e,t){var r;let u=e.node,n=[cr(e,t)],{printer:i,originalText:s,locStart:o,locEnd:a}=t;if((r=i.isBlockComment)!=null&&r.call(i,u)){let D=z(s,a(u))?z(s,o(u),{backwards:true})?Q:tr:" ";n.push(D);}else n.push(Q);let l=ee(s,G(s,a(u)));return l!==false&&z(s,l)&&n.push(Q),n}function dn(e,t,r){var u;let n=e.node,i=cr(e,t),{printer:s,originalText:o,locStart:a}=t,l=(u=s.isBlockComment)==null?void 0:u.call(s,n);if(r!=null&&r.hasLineSuffix&&!(r!=null&&r.isBlock)||z(o,a(n),{backwards:true})){let D=nt(o,a(n));return {doc:Me([Q,D?Q:"",i]),isBlock:l,hasLineSuffix:true}}return !l||r!=null&&r.hasLineSuffix?{doc:[Me([" ",i]),xe],isBlock:l,hasLineSuffix:true}:{doc:[" ",i],isBlock:l,hasLineSuffix:false}}function fn(e,t){let r=e.node;if(!r)return {};let u=t[Symbol.for("printedComments")];if((r.comments||[]).filter(o=>!u.has(o)).length===0)return {leading:"",trailing:""};let n=[],i=[],s;return e.each(()=>{let o=e.node;if(u!=null&&u.has(o))return;let{leading:a,trailing:l}=o;a?n.push(cn(e,t)):l&&(s=dn(e,t,s),i.push(s.doc));},"comments"),{leading:n,trailing:i}}function hn(e,t,r){let{leading:u,trailing:n}=fn(e,r);return !u&&!n?t:Ee(t,i=>[u,i,n])}function mn(e){let{[Symbol.for("comments")]:t,[Symbol.for("printedComments")]:r}=e;for(let u of t){if(!u.printed&&!r.has(u))throw new Error('Comment "'+u.value.trim()+'" was not printed. Please report this error!');delete u.printed;}}function Fn(e){return ()=>{}}function fr({plugins:e=[],showDeprecated:t=false}={}){let r=e.flatMap(n=>n.languages??[]),u=[];for(let n of En(Object.assign({},...e.map(({options:i})=>i),Cn)))!t&&n.deprecated||(Array.isArray(n.choices)&&(t||(n.choices=n.choices.filter(i=>!i.deprecated)),n.name==="parser"&&(n.choices=[...n.choices,...yn(n.choices,r,e)])),n.pluginDefaults=Object.fromEntries(e.filter(i=>{var s;return ((s=i.defaultOptions)==null?void 0:s[n.name])!==void 0}).map(i=>[i.name,i.defaultOptions[n.name]])),u.push(n));return {languages:r,options:u}}function*yn(e,t,r){let u=new Set(e.map(n=>n.value));for(let n of t)if(n.parsers){for(let i of n.parsers)if(!u.has(i)){u.add(i);let s=r.find(a=>a.parsers&&Object.prototype.hasOwnProperty.call(a.parsers,i)),o=n.name;s!=null&&s.name&&(o+=` (plugin: ${s.name})`),yield {value:i,description:o};}}}function En(e){let t=[];for(let[r,u]of Object.entries(e)){let n={name:r,...u};Array.isArray(n.default)&&(n.default=b(false,n.default,-1).value),t.push(n);}return t}function hr(e){if(e=e instanceof URL?e:new URL(e),e.protocol!=="file:")throw new TypeError(`URL must be a file URL: received "${e.protocol}"`);return e}function kn(e){return e=hr(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function Sn(e){e=hr(e);let t=decodeURIComponent(e.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");return e.hostname!==""&&(t=`\\\\${e.hostname}${t}`),t}function xn(e){return wn?Sn(e):kn(e)}function xt(e,t){if(!t)return;let r=An(t).toLowerCase();return e.find(({filenames:u})=>u?.some(n=>n.toLowerCase()===r))??e.find(({extensions:u})=>u?.some(n=>r.endsWith(n)))}function $n(e,t){if(t)return e.find(({name:r})=>r.toLowerCase()===t)??e.find(({aliases:r})=>r?.includes(t))??e.find(({extensions:r})=>r?.includes(`.${t}`))}function Bt(e,t){if(t){if(String(t).startsWith("file:"))try{t=Bn(t);}catch{return}if(typeof t=="string")return e.find(({isSupported:r})=>r?.({filepath:t}))}}function Nn(e,t){let r=bn(false,e.plugins).flatMap(n=>n.languages??[]),u=$n(r,t.language)??xt(r,t.physicalFile)??xt(r,t.file)??Bt(r,t.physicalFile)??Bt(r,t.file)??(t.physicalFile,void 0);return u?.parsers[0]}function $t(e,t,r,u){return [`Invalid ${N.red(u.key(e))} value.`,`Expected ${N.blue(r)},`,`but received ${t===Fr?N.gray("nothing"):N.red(u.value(t))}.`].join(" ")}function gr({text:e,list:t},r){let u=[];return e&&u.push(`- ${N.blue(e)}`),t&&u.push([`- ${N.blue(t.title)}:`].concat(t.values.map(n=>gr(n,r-At.length).replace(/^|\n/g,`$&${At}`))).join(` `)),Cr(u,r)}function Cr(e,t){if(e.length===1)return e[0];let[r,u]=e,[n,i]=e.map(s=>s.split(` `,1)[0].length);return n>t&&n>i?u:r}function In(e,t){if(e===t)return 0;let r=e;e.length>t.length&&(e=t,t=r);let u=e.length,n=t.length;for(;u>0&&e.charCodeAt(~-u)===t.charCodeAt(~-n);)u--,n--;let i=0;for(;i<u&&e.charCodeAt(i)===t.charCodeAt(i);)i++;if(u-=i,n-=i,u===0)return n;let s,o,a,l,D=0,f=0;for(;D<u;)Nt[D]=e.charCodeAt(i+D),je[D]=++D;for(;f<n;)for(s=t.charCodeAt(i+f),a=f++,o=f,D=0;D<u;D++)l=s===Nt[D]?a:a+1,a=je[D],o=je[D]=a>o?l>o?o+1:l:l>a?a+1:l;return o}function Wn(e,t){let r=new e(t),u=Object.create(r);for(let n of jn)n in t&&(u[n]=_n(t[n],r,J.prototype[n].length));return u}function _n(e,t,r){return typeof e=="function"?(...u)=>e(...u.slice(0,r-1),t,...u.slice(r-1)):()=>e}function Ot({from:e,to:t}){return {from:[e],to:t}}function zn(e,t){let r=Object.create(null);for(let u of e){let n=u[t];if(r[n])throw new Error(`Duplicate ${t} ${JSON.stringify(n)}`);r[n]=u;}return r}function Gn(e,t){let r=new Map;for(let u of e){let n=u[t];if(r.has(n))throw new Error(`Duplicate ${t} ${JSON.stringify(n)}`);r.set(n,u);}return r}function qn(){let e=Object.create(null);return t=>{let r=JSON.stringify(t);return e[r]?true:(e[r]=true,false)}}function Jn(e,t){let r=[],u=[];for(let n of e)t(n)?r.push(n):u.push(n);return [r,u]}function Un(e){return e===Math.floor(e)}function Hn(e,t){if(e===t)return 0;let r=typeof e,u=typeof t,n=["undefined","object","boolean","number","string"];return r!==u?n.indexOf(r)-n.indexOf(u):r!=="string"?Number(e)-Number(t):e.localeCompare(t)}function Kn(e){return (...t)=>{let r=e(...t);return typeof r=="string"?new Error(r):r}}function Pt(e){return e===void 0?{}:e}function Er(e){if(typeof e=="string")return {text:e};let{text:t,list:r}=e;return Xn((t||r)!==void 0,"Unexpected `expected` result, there should be at least one field."),r?{text:t,list:{title:r.title,values:r.values.map(Er)}}:{text:t}}function Tt(e,t){return e===true?true:e===false?{value:t}:e}function It(e,t,r=false){return e===false?false:e===true?r?true:[{value:t}]:"value"in e?[e]:e.length===0?false:e}function jt(e,t){return typeof e=="string"||"key"in e?{from:t,to:e}:"from"in e?{from:e.from,to:e.to}:{from:t,to:e.to}}function qe(e,t){return e===void 0?[]:Array.isArray(e)?e.map(r=>jt(r,t)):[jt(e,t)]}function Wt(e,t){let r=qe(typeof e=="object"&&"redirect"in e?e.redirect:e,t);return r.length===0?{remain:t,redirect:r}:typeof e=="object"&&"remain"in e?{remain:e.remain,redirect:r}:{redirect:r}}function Xn(e,t){if(!e)throw new Error(t)}function ii(e,t,{logger:r=false,isCLI:u=false,passThrough:n=false,FlagSchema:i,descriptor:s}={}){if(u){if(!i)throw new Error("'FlagSchema' option is required.");if(!s)throw new Error("'descriptor' option is required.")}else s=ne;let o=n?Array.isArray(n)?(p,c)=>n.includes(p)?{[p]:c}:void 0:(p,c)=>({[p]:c}):(p,c,d)=>{let{_:h,...m}=d.schemas;return yr(p,c,{...d,schemas:m})},a=si(t,{isCLI:u,FlagSchema:i}),l=new ni(a,{logger:r,unknown:o,descriptor:s}),D=r!==false;D&&We&&(l._hasDeprecationWarned=We);let f=l.normalize(e);return D&&(We=l._hasDeprecationWarned),f}function si(e,{isCLI:t,FlagSchema:r}){let u=[];t&&u.push(Vn.create({name:"_"}));for(let n of e)u.push(oi(n,{isCLI:t,optionInfos:e,FlagSchema:r})),n.alias&&t&&u.push(Mn.create({name:n.alias,sourceName:n.name}));return u}function oi(e,{isCLI:t,optionInfos:r,FlagSchema:u}){let{name:n}=e,i={name:n},s,o={};switch(e.type){case "int":s=Qn,t&&(i.preprocess=Number);break;case "string":s=_t;break;case "choice":s=Yn,i.choices=e.choices.map(a=>a!=null&&a.redirect?{...a,redirect:{to:{key:e.name,value:a.redirect}}}:a);break;case "boolean":s=Rn;break;case "flag":s=u,i.flags=r.flatMap(a=>[a.alias,a.description&&a.name,a.oppositeDescription&&`no-${a.name}`].filter(Boolean));break;case "path":s=_t;break;default:throw new Error(`Unexpected type ${e.type}`)}if(e.exception?i.validate=(a,l,D)=>e.exception(a)||l.validate(a,D):i.validate=(a,l,D)=>a===void 0||l.validate(a,D),e.redirect&&(o.redirect=a=>a?{to:typeof e.redirect=="string"?e.redirect:{key:e.redirect.option,value:e.redirect.value}}:void 0),e.deprecated&&(o.deprecated=true),t&&!e.array){let a=i.preprocess||(l=>l);i.preprocess=(l,D,f)=>D.preprocess(a(Array.isArray(l)?b(false,l,-1):l),f);}return e.array?Ln.create({...t?{preprocess:a=>Array.isArray(a)?a:[a]}:{},...o,valueSchema:s.create(i)}):s.create({...i,...o})}function br(e,t){if(!t)throw new Error("parserName is required.");let r=vr(false,e,n=>n.parsers&&Object.prototype.hasOwnProperty.call(n.parsers,t));if(r)return r;let u=`Couldn't resolve parser "${t}".`;throw u+=" Plugins must be explicitly added to the standalone bundle.",new dr(u)}function Di(e,t){if(!t)throw new Error("astFormat is required.");let r=vr(false,e,n=>n.printers&&Object.prototype.hasOwnProperty.call(n.printers,t));if(r)return r;let u=`Couldn't find plugin for AST format "${t}".`;throw u+=" Plugins must be explicitly added to the standalone bundle.",new dr(u)}function it({plugins:e,parser:t}){let r=br(e,t);return wr(r,t)}function wr(e,t){let r=e.parsers[t];return typeof r=="function"?r():r}function pi(e,t){let r=e.printers[t];return typeof r=="function"?r():r}async function ci(e,t={}){var r;let u={...e};if(!u.parser)if(u.filepath){if(u.parser=On(u,{physicalFile:u.filepath}),!u.parser)throw new Et(`No parser could be inferred for file "${u.filepath}".`)}else throw new Et("No parser and no file path given, couldn't infer a parser.");let n=fr({plugins:e.plugins,showDeprecated:true}).options,i={...Mt,...Object.fromEntries(n.filter(p=>p.default!==void 0).map(p=>[p.name,p.default]))},s=br(u.plugins,u.parser),o=await wr(s,u.parser);u.astFormat=o.astFormat,u.locEnd=o.locEnd,u.locStart=o.locStart;let a=(r=s.printers)!=null&&r[o.astFormat]?s:Di(u.plugins,o.astFormat),l=await pi(a,o.astFormat);u.printer=l;let D=a.defaultOptions?Object.fromEntries(Object.entries(a.defaultOptions).filter(([,p])=>p!==void 0)):{},f={...i,...D};for(let[p,c]of Object.entries(f))(u[p]===null||u[p]===void 0)&&(u[p]=c);return u.parser==="json"&&(u.trailingComma="none"),ai(u,n,{passThrough:Object.keys(Mt),...t})}async function fi(e,t){let r=await it(t),u=r.preprocess?r.preprocess(e,t):e;t.originalText=u;let n;try{n=await r.parse(u,t,t);}catch(i){hi(i,e);}return {text:u,ast:n}}function hi(e,t){let{loc:r}=e;if(r){let u=(0, di.codeFrameColumns)(t,r,{highlightCode:true});throw e.message+=` `+u,e.codeFrame=u,e}throw e}async function mi(e,t,r,u,n){let{embeddedLanguageFormatting:i,printer:{embed:s,hasPrettierIgnore:o=()=>false,getVisitorKeys:a}}=r;if(!s||i!=="auto")return;if(s.length>2)throw new Error("printer.embed has too many parameters. The API changed in Prettier v3. Please update your plugin. See https://prettier.io/docs/plugins#optional-embed");let l=$e(s.getVisitorKeys??a),D=[];c();let f=e.stack;for(let{print:d,node:h,pathStack:m}of D)try{e.stack=m;let F=await d(p,t,e,r);F&&n.set(h,F);}catch(F){if(globalThis.PRETTIER_DEBUG)throw F}e.stack=f;function p(d,h){return Fi(d,h,r,u)}function c(){let{node:d}=e;if(d===null||typeof d!="object"||o(e))return;for(let m of l(d))Array.isArray(d[m])?e.each(c,m):e.call(c,m);let h=s(e,r);if(h){if(typeof h=="function"){D.push({print:h,node:d,pathStack:[...e.stack]});return}n.set(d,h);}}}async function Fi(e,t,r,u){let n=await oe({...r,...t,parentParser:r.parser,originalText:e,cursorOffset:void 0,rangeStart:void 0,rangeEnd:void 0},{passThrough:true}),{ast:i}=await me(e,n),s=await u(i,n);return Yt(s)}function gi(e,t){let{originalText:r,[Symbol.for("comments")]:u,locStart:n,locEnd:i,[Symbol.for("printedComments")]:s}=t,{node:o}=e,a=n(o),l=i(o);for(let D of u)n(D)>=a&&i(D)<=l&&s.add(D);return r.slice(a,l)}async function Ne(e,t){({ast:e}=await kr(e,t));let r=new Map,u=new Hu(e),n=gn(t),i=new Map;await mi(u,o,t,Ne,i);let s=await Vt(u,t,o,void 0,i);if(mn(t),t.cursorOffset>=0){if(t.nodeAfterCursor&&!t.nodeBeforeCursor)return [Z,s];if(t.nodeBeforeCursor&&!t.nodeAfterCursor)return [s,Z]}return s;function o(l,D){return l===void 0||l===u?a(D):Array.isArray(l)?u.call(()=>a(D),...l):u.call(()=>a(D),l)}function a(l){n(u);let D=u.node;if(D==null)return "";let f=D&&typeof D=="object"&&l===void 0;if(f&&r.has(D))return r.get(D);let p=Vt(u,t,o,l,i);return f&&r.set(D,p),p}}function Vt(e,t,r,u,n){var i;let{node:s}=e,{printer:o}=t,a;switch((i=o.hasPrettierIgnore)!=null&&i.call(o,e)?a=Ci(e,t):n.has(s)?a=n.get(s):a=o.print(e,t,r,u),s){case t.cursorNode:a=Ee(a,l=>[Z,l,Z]);break;case t.nodeBeforeCursor:a=Ee(a,l=>[l,Z]);break;case t.nodeAfterCursor:a=Ee(a,l=>[Z,l]);break}return o.printComment&&(!o.willPrintOwnComments||!o.willPrintOwnComments(e,t))&&(a=hn(e,a,t)),a}async function kr(e,t){let r=e.comments??[];t[Symbol.for("comments")]=r,t[Symbol.for("printedComments")]=new Set,an(e,t);let{printer:{preprocess:u}}=t;return e=u?await u(e,t):e,{ast:e,comments:r}}function yi(e,t){let{cursorOffset:r,locStart:u,locEnd:n}=t,i=$e(t.printer.getVisitorKeys),s=c=>u(c)<=r&&n(c)>=r,o=e,a=[e];for(let c of Yu(e,{getVisitorKeys:i,filter:s}))a.push(c),o=c;if(Zu(o,{getVisitorKeys:i}))return {cursorNode:o};let l,D,f=-1,p=Number.POSITIVE_INFINITY;for(;a.length>0&&(l===void 0||D===void 0);){o=a.pop();let c=l!==void 0,d=D!==void 0;for(let h of Ae(o,{getVisitorKeys:i})){if(!c){let m=n(h);m<=r&&m>f&&(l=h,f=m);}if(!d){let m=u(h);m>=r&&m<p&&(D=h,p=m);}}}return {nodeBeforeCursor:l,nodeAfterCursor:D}}function Ei(e,t){let{printer:{massageAstNode:r,getVisitorKeys:u}}=t;if(!r)return e;let n=$e(u),i=r.ignoredProperties??new Set;return s(e);function s(o,a){if(!(o!==null&&typeof o=="object"))return o;if(Array.isArray(o))return o.map(p=>s(p,a)).filter(Boolean);let l={},D=new Set(n(o));for(let p in o)!Object.prototype.hasOwnProperty.call(o,p)||i.has(p)||(D.has(p)?l[p]=s(o[p],o):l[p]=o[p]);let f=r(o,l,a);if(f!==null)return f??l}}function Si(e,t){let r=[e.node,...e.parentNodes],u=new Set([t.node,...t.parentNodes]);return r.find(n=>xr.has(n.type)&&u.has(n))}function Lt(e){let t=wi(false,e,r=>r.type!=="Program"&&r.type!=="File");return t===-1?e:e.slice(0,t+1)}function xi(e,t,{locStart:r,locEnd:u}){let n=e.node,i=t.node;if(n===i)return {startNode:n,endNode:i};let s=r(e.node);for(let a of Lt(t.parentNodes))if(r(a)>=s)i=a;else break;let o=u(t.node);for(let a of Lt(e.parentNodes)){if(u(a)<=o)n=a;else break;if(n===i)break}return {startNode:n,endNode:i}}function Je(e,t,r,u,n=[],i){let{locStart:s,locEnd:o}=r,a=s(e),l=o(e);if(!(t>l||t<a||i==="rangeEnd"&&t===a||i==="rangeStart"&&t===l)){for(let D of ut(e,r)){let f=Je(D,t,r,u,[e,...n],i);if(f)return f}if(!u||u(e,n[0]))return {node:e,parentNodes:n}}}function Bi(e,t){return t!=="DeclareExportDeclaration"&&e!=="TypeParameterDeclaration"&&(e==="Directive"||e==="TypeAlias"||e==="TSExportAssignment"||e.startsWith("Declare")||e.startsWith("TSDeclare")||e.endsWith("Statement")||e.endsWith("Declaration"))}function Rt(e,t,r){if(!t)return false;switch(e.parser){case "flow":case "hermes":case "babel":case "babel-flow":case "babel-ts":case "typescript":case "acorn":case "espree":case "meriyah":case "oxc":case "oxc-ts":case "__babel_estree":return Bi(t.type,r?.type);case "json":case "json5":case "jsonc":case "json-stringify":return xr.has(t.type);case "graphql":return Ai.has(t.kind);case "vue":return t.tag!=="root"}return false}function $i(e,t,r){let{rangeStart:u,rangeEnd:n,locStart:i,locEnd:s}=t;Ge.ok(n>u);let o=e.slice(u,n).search(/\S/u),a=o===-1;if(!a)for(u+=o;n>u&&!/\S/u.test(e[n-1]);--n);let l=Je(r,u,t,(c,d)=>Rt(t,c,d),[],"rangeStart"),D=a?l:Je(r,n,t,c=>Rt(t,c),[],"rangeEnd");if(!l||!D)return {rangeStart:0,rangeEnd:0};let f,p;if(ki(t)){let c=Si(l,D);f=c,p=c;}else ({startNode:f,endNode:p}=xi(l,D,t));return {rangeStart:Math.min(i(f),i(p)),rangeEnd:Math.max(s(f),s(p))}}async function Ar(e,t,r=0){if(!e||e.trim().length===0)return {formatted:"",cursorOffset:-1,comments:[]};let{ast:u,text:n}=await me(e,t);t.cursorOffset>=0&&(t={...t,...Sr(u,t)});let i=await Ne(u,t);r>0&&(i=nr([Q,i],r,t.tabWidth));let s=Be(i,t);if(r>0){let a=s.formatted.trim();s.cursorNodeStart!==void 0&&(s.cursorNodeStart-=s.formatted.indexOf(a),s.cursorNodeStart<0&&(s.cursorNodeStart=0,s.cursorNodeText=s.cursorNodeText.trimStart()),s.cursorNodeStart+s.cursorNodeText.length>a.length&&(s.cursorNodeText=s.cursorNodeText.trimEnd())),s.formatted=a+Ke(t.endOfLine);}let o=t[Symbol.for("comments")];if(t.cursorOffset>=0){let a,l,D,f;if((t.cursorNode||t.nodeBeforeCursor||t.nodeAfterCursor)&&s.cursorNodeText)if(D=s.cursorNodeStart,f=s.cursorNodeText,t.cursorNode)a=t.locStart(t.cursorNode),l=n.slice(a,t.locEnd(t.cursorNode));else {if(!t.nodeBeforeCursor&&!t.nodeAfterCursor)throw new Error("Cursor location must contain at least one of cursorNode, nodeBeforeCursor, nodeAfterCursor");a=t.nodeBeforeCursor?t.locEnd(t.nodeBeforeCursor):0;let F=t.nodeAfterCursor?t.locStart(t.nodeAfterCursor):n.length;l=n.slice(a,F);}else a=0,l=n,D=0,f=s.formatted;let p=t.cursorOffset-a;if(l===f)return {formatted:s.formatted,cursorOffset:D+p,comments:o};let c=l.split("");c.splice(p,0,zt);let d=f.split(""),h=iu(c,d),m=D;for(let F of h)if(F.removed){if(F.value.includes(zt))break}else m+=F.count;return {formatted:s.formatted,cursorOffset:m,comments:o}}return {formatted:s.formatted,cursorOffset:-1,comments:o}}async function Ni(e,t){let{ast:r,text:u}=await me(e,t),{rangeStart:n,rangeEnd:i}=$i(u,t,r),s=u.slice(n,i),o=Math.min(n,u.lastIndexOf(` `,n)+1),a=u.slice(o,n).match(/^\s*/u)[0],l=tt(a,t.tabWidth),D=await Ar(s,{...t,rangeStart:0,rangeEnd:Number.POSITIVE_INFINITY,cursorOffset:t.cursorOffset>n&&t.cursorOffset<=i?t.cursorOffset-n:-1,endOfLine:"lf"},l),f=D.formatted.trimEnd(),{cursorOffset:p}=t;p>i?p+=f.length-s.length:D.cursorOffset>=0&&(p=D.cursorOffset+n);let c=u.slice(0,n)+f+u.slice(i);if(t.endOfLine!=="lf"){let d=Ke(t.endOfLine);p>=0&&d===`\r `&&(p+=Kt(c.slice(0,p),` `)),c=ke(false,c,` `,d);}return {formatted:c,cursorOffset:p,comments:D.comments}}function _e(e,t,r){return typeof t!="number"||Number.isNaN(t)||t<0||t>e.length?r:t}function Gt(e,t){let{cursorOffset:r,rangeStart:u,rangeEnd:n}=t;return r=_e(e,r,-1),u=_e(e,u,0),n=_e(e,n,e.length),{...t,cursorOffset:r,rangeStart:u,rangeEnd:n}}function $r(e,t){let{cursorOffset:r,rangeStart:u,rangeEnd:n,endOfLine:i}=Gt(e,t),s=e.charAt(0)===Br;if(s&&(e=e.slice(1),r--,u--,n--),i==="auto"&&(i=su(e)),e.includes("\r")){let o=a=>Kt(e.slice(0,Math.max(a,0)),`\r `);r-=o(r),u-=o(u),n-=o(n),e=ou(e);}return {hasBOM:s,text:e,options:Gt(e,{...t,cursorOffset:r,rangeStart:u,rangeEnd:n,endOfLine:i})}}async function qt(e,t){let r=await it(t);return !r.hasPragma||r.hasPragma(e)}async function Oi(e,t){var r;let u=await it(t);return (r=u.hasIgnorePragma)==null?void 0:r.call(u,e)}async function Nr(e,t){let{hasBOM:r,text:u,options:n}=$r(e,await oe(t));if(n.rangeStart>=n.rangeEnd&&u!==""||n.requirePragma&&!await qt(u,n)||n.checkIgnorePragma&&await Oi(u,n))return {formatted:e,cursorOffset:t.cursorOffset,comments:[]};let i;return n.rangeStart>0||n.rangeEnd<u.length?i=await Ni(u,n):(!n.requirePragma&&n.insertPragma&&n.printer.insertPragma&&!await qt(u,n)&&(u=n.printer.insertPragma(u)),i=await Ar(u,n)),r&&(i.formatted=Br+i.formatted,i.cursorOffset>=0&&i.cursorOffset++),i}async function Pi(e,t,r){let{text:u,options:n}=$r(e,await oe(t)),i=await me(u,n);return r&&(r.preprocessForPrint&&(i.ast=await kr(i.ast,n)),r.massage&&(i.ast=vi(i.ast,n))),i}async function Ti(e,t){t=await oe(t);let r=await Ne(e,t);return Be(r,t)}async function Ii(e,t){let r=Wu(e),{formatted:u}=await Nr(r,{...t,parser:"__js_expression"});return u}async function ji(e,t){t=await oe(t);let{ast:r}=await me(e,t);return t.cursorOffset>=0&&(t={...t,...Sr(r,t)}),Ne(r,t)}async function Wi(e,t){return Be(e,await oe(t))}function Li(e,t){if(t===false)return false;if(e.charAt(t)==="/"&&e.charAt(t+1)==="*"){for(let r=t+2;r<e.length;++r)if(e.charAt(r)==="*"&&e.charAt(r+1)==="/")return r+2}return t}function Ri(e,t){return t===false?false:e.charAt(t)==="/"&&e.charAt(t+1)==="/"?ar(e,t):t}function zi(e,t){let r=null,u=t;for(;u!==r;)r=u,u=G(e,u),u=at(e,u),u=lt(e,u),u=ee(e,u);return u}function Gi(e,t){let r=null,u=t;for(;u!==r;)r=u,u=or(e,u),u=at(e,u),u=G(e,u);return u=lt(e,u),u=ee(e,u),u!==false&&z(e,u)}function qi(e,t){let r=e.lastIndexOf(` `);return r===-1?0:tt(e.slice(r+1).match(/^[\t ]*/u)[0],t)}function Ui(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Hi(e,t){let r=e.match(new RegExp(`(${Ui(t)})+`,"gu"));return r===null?0:r.reduce((u,n)=>Math.max(u,n.length/t.length),0)}function Xi(e,t){let r=Dt(e,t);return r===false?"":e.charAt(r)}function Zi(e,t){let r=t===true||t===ye?ye:Jt,u=r===ye?Jt:ye,n=0,i=0;for(let s of e)s===r?n++:s===u&&i++;return n>i?u:r}function es(e,t,r){for(let u=t;u<r;++u)if(e.charAt(u)===` `)return true;return false}function rs(e,t,r={}){return G(e,r.backwards?t-1:t,r)!==t}function ns(e,t,r){let u=t==='"'?"'":'"',n=ke(false,e,/\\(.)|(["'])/gsu,(i,s,o)=>s===u?s:o===t?"\\"+o:o||(r&&/^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/u.test(s)?s:"\\"+s));return t+n+t}function ss(e,t,r){return Dt(e,r(t))}function os(e,t){return arguments.length===2||typeof t=="number"?Dt(e,t):ss(...arguments)}function as(e,t,r){return nt(e,r(t))}function ls(e,t){return arguments.length===2||typeof t=="number"?nt(e,t):as(...arguments)}function Ds(e,t,r){return pt(e,r(t))}function ps(e,t){return arguments.length===2||typeof t=="number"?pt(e,t):Ds(...arguments)}function Y(e,t=1){return async(...r)=>{let u=r[t]??{},n=u.plugins??[];return r[t]={...u,plugins:Array.isArray(n)?n:Object.values(n)},e(...r)}}async function dt(e,t){let{formatted:r}=await ct(e,{...t,cursorOffset:-1});return r}async function Pr(e,t){return await dt(e,t)===e}var Gr,Ue,qr,Jr,Ur,Hr,Ut,Kr,He,Xr,Yr,Zr,Qr,pe,eu,Ht,tu,ke,ru,uu,nu,te,j,q,W,_,M,S,P,x,V,L,R,w,T,A,Xt,au,b,re,pu,du,ie,Ft,Xe,Ze,O,Zt,ku,Pu,xe,Tu,Qe,er,tr,Iu,Q,rr,Z,_u,Lu,Ru,et,k,$,ue,Ve,tt,K,ze,ve,Uu,Hu,sr,Ge,Xu,Qu,G,or,ar,ee,z,un,lr,nn,$e,Pe,Te,pr,nt,gn,dr,Et,Cn,vn,bn,vt,bt,wt,kt,St,wn,Bn,An,On,ne,mr,N,Pn,Fr,be,At,Tn,je,Nt,yr,jn,J,Mn,Vn,Ln,Rn,Yn,Zn,Qn,_t,ei,ti,ri,ui,ni,We,ai,li,vr,Mt,oe,di,me,Ci,Sr,vi,bi,wi,ki,xr,Ai,Br,zt,st,_i,Mi,Vi,Or,ot,at,lt,Dt,pt,Ji,Ki,Yi,ye,Jt,Qi,ts,us,is,ct,Tr,Ir,cs,ht=Rr(()=>{Gr=Object.create,Ue=Object.defineProperty,qr=Object.getOwnPropertyDescriptor,Jr=Object.getOwnPropertyNames,Ur=Object.getPrototypeOf,Hr=Object.prototype.hasOwnProperty,Ut=e=>{throw TypeError(e)},Kr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),He=(e,t)=>{for(var r in t)Ue(e,r,{get:t[r],enumerable:true});},Xr=(e,t,r,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Jr(t))!Hr.call(e,n)&&n!==r&&Ue(e,n,{get:()=>t[n],enumerable:!(u=qr(t,n))||u.enumerable});return e},Yr=(e,t,r)=>(r=e!=null?Gr(Ur(e)):{},Xr(t||!e||!e.__esModule?Ue(r,"default",{value:e,enumerable:true}):r,e)),Zr=(e,t,r)=>t.has(e)||Ut("Cannot "+r),Qr=(e,t,r)=>t.has(e)?Ut("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),pe=(e,t,r)=>(Zr(e,t,"access private method"),r),eu=Kr(e=>{Object.defineProperty(e,"__esModule",{value:true});function t(){return new Proxy({},{get:()=>i=>i})}var r=/\r\n|[\n\r\u2028\u2029]/;function u(i,s,o){let a=Object.assign({column:0,line:-1},i.start),l=Object.assign({},a,i.end),{linesAbove:D=2,linesBelow:f=3}=o||{},p=a.line,c=a.column,d=l.line,h=l.column,m=Math.max(p-(D+1),0),F=Math.min(s.length,d+f);p===-1&&(m=0),d===-1&&(F=s.length);let y=d-p,C={};if(y)for(let E=0;E<=y;E++){let g=E+p;if(!c)C[g]=true;else if(E===0){let v=s[g-1].length;C[g]=[c,v-c+1];}else if(E===y)C[g]=[0,h];else {let v=s[g-E].length;C[g]=[0,v];}}else c===h?c?C[p]=[c,0]:C[p]=true:C[p]=[c,h-c];return {start:m,end:F,markerLines:C}}function n(i,s,o={}){let a=t(),l=i.split(r),{start:D,end:f,markerLines:p}=u(s,l,o),c=s.start&&typeof s.start.column=="number",d=String(f).length,h=i.split(r,f).slice(D,f).map((m,F)=>{let y=D+1+F,C=` ${` ${y}`.slice(-d)} |`,E=p[y],g=!p[y+1];if(E){let v="";if(Array.isArray(E)){let B=m.slice(0,Math.max(E[0]-1,0)).replace(/[^\t]/g," "),U=E[1]||1;v=[` `,a.gutter(C.replace(/\d/g," "))," ",B,a.marker("^").repeat(U)].join(""),g&&o.message&&(v+=" "+a.message(o.message));}return [a.marker(">"),a.gutter(C),m.length>0?` ${m}`:"",v].join("")}else return ` ${a.gutter(C)}${m.length>0?` ${m}`:""}`}).join(` `);return o.message&&!c&&(h=`${" ".repeat(d+1)}${o.message} ${h}`),h}e.codeFrameColumns=n;}),Ht={};He(Ht,{__debug:()=>Ir,check:()=>Pr,doc:()=>st,format:()=>dt,formatWithCursor:()=>ct,getSupportInfo:()=>Tr,util:()=>ot,version:()=>Or});tu=(e,t,r,u)=>{if(!(e&&t==null))return t.replaceAll?t.replaceAll(r,u):r.global?t.replace(r,u):t.split(r).join(u)},ke=tu,ru=class{diff(e,t,r={}){let u;typeof r=="function"?(u=r,r={}):"callback"in r&&(u=r.callback);let n=this.castInput(e,r),i=this.castInput(t,r),s=this.removeEmpty(this.tokenize(n,r)),o=this.removeEmpty(this.tokenize(i,r));return this.diffWithOptionsObj(s,o,r,u)}diffWithOptionsObj(e,t,r,u){var n;let i=F=>{if(F=this.postProcess(F,r),u){setTimeout(function(){u(F);},0);return}else return F},s=t.length,o=e.length,a=1,l=s+o;r.maxEditLength!=null&&(l=Math.min(l,r.maxEditLength));let D=(n=r.timeout)!==null&&n!==void 0?n:1/0,f=Date.now()+D,p=[{oldPos:-1,lastComponent:void 0}],c=this.extractCommon(p[0],t,e,0,r);if(p[0].oldPos+1>=o&&c+1>=s)return i(this.buildValues(p[0].lastComponent,t,e));let d=-1/0,h=1/0,m=()=>{for(let F=Math.max(d,-a);F<=Math.min(h,a);F+=2){let y,C=p[F-1],E=p[F+1];C&&(p[F-1]=void 0);let g=false;if(E){let B=E.oldPos-F;g=E&&0<=B&&B<s;}let v=C&&C.oldPos+1<o;if(!g&&!v){p[F]=void 0;continue}if(!v||g&&C.oldPos<E.oldPos?y=this.addToPath(E,true,false,0,r):y=this.addToPath(C,false,true,1,r),c=this.extractCommon(y,t,e,F,r),y.oldPos+1>=o&&c+1>=s)return i(this.buildValues(y.lastComponent,t,e))||true;p[F]=y,y.oldPos+1>=o&&(h=Math.min(h,F-1)),c+1>=s&&(d=Math.max(d,F+1));}a++;};if(u)(function F(){setTimeout(function(){if(a>l||Date.now()>f)return u(void 0);m()||F();},0);})();else for(;a<=l&&Date.now()<=f;){let F=m();if(F)return F}}addToPath(e,t,r,u,n){let i=e.lastComponent;return i&&!n.oneChangePerToken&&i.added===t&&i.removed===r?{oldPos:e.oldPos+u,lastComponent:{count:i.count+1,added:t,removed:r,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+u,lastComponent:{count:1,added:t,removed:r,previousComponent:i}}}extractCommon(e,t,r,u,n){let i=t.length,s=r.length,o=e.oldPos,a=o-u,l=0;for(;a+1<i&&o+1<s&&this.equals(r[o+1],t[a+1],n);)a++,o++,l++,n.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:false,removed:false});return l&&!n.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:false,removed:false}),e.oldPos=o,a}equals(e,t,r){return r.comparator?r.comparator(e,t):e===t||!!r.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join("")}postProcess(e,t){return e}get useLongestToken(){return false}buildValues(e,t,r){let u=[],n;for(;e;)u.push(e),n=e.previousComponent,delete e.previousComponent,e=n;u.reverse();let i=u.length,s=0,o=0,a=0;for(;s<i;s++){let l=u[s];if(l.removed)l.value=this.join(r.slice(a,a+l.count)),a+=l.count;else {if(!l.added&&this.useLongestToken){let D=t.slice(o,o+l.count);D=D.map(function(f,p){let c=r[a+p];return c.length>f.length?c:f}),l.value=this.join(D);}else l.value=this.join(t.slice(o,o+l.count));o+=l.count,l.added||(a+=l.count);}}return u}},uu=class extends ru{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}},nu=new uu;te="string",j="array",q="cursor",W="indent",_="align",M="trim",S="group",P="fill",x="if-break",V="indent-if-break",L="line-suffix",R="line-suffix-boundary",w="line",T="label",A="break-parent",Xt=new Set([q,W,_,M,S,P,x,V,L,R,w,T,A]),au=(e,t,r)=>{if(!(e&&t==null))return Array.isArray(t)||typeof t=="string"?t[r<0?t.length+r:r]:t.at(r)},b=au;re=Du,pu=e=>new Intl.ListFormat("en-US",{type:"disjunction"}).format(e);du=class extends Error{constructor(t){super(cu(t));ge(this,"name","InvalidDocError");this.doc=t;}},ie=du,Ft={};Xe=fu;Ze=()=>{},O=Ze,Zt=Ze,ku=Ze;Pu={type:R},xe={type:A},Tu={type:M},Qe={type:w,hard:true},er={type:w,hard:true,literal:true},tr={type:w},Iu={type:w,soft:true},Q=[Qe,xe],rr=[er,xe],Z={type:q};_u=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB