UNPKG

@visulima/ono

Version:

Ono is an error-parsing library that pretty prints JavaScript errors on a web page or the terminal.

318 lines (293 loc) 195 kB
var Ao=Object.defineProperty;var f=(e,t)=>Ao(e,"name",{value:t,configurable:!0});import{createRequire as Do}from"node:module";import{parseStacktrace as Ht}from"@visulima/error/stacktrace";import{renderError as Bo,getErrorCauses as Lo}from"@visulima/error/error";import{ruleBasedFinder as Ut,errorHintFinder as Vt}from"@visulima/error/solution";import{s as S,a as E,b as _o,c as Fo,d as Mo,n as kt,e as xt,f as Oo}from"./packem_shared/clipboard-CI3XgYla.js";import Ze from"isomorphic-dompurify";import{t as Po,g as No}from"./packem_shared/process-B37didfB.js";import{parseStacktrace as at,codeFrame as st}from"@visulima/error";import Gt from"@visulima/error/solution/ai/prompt";const Io=Do(import.meta.url),ie=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Re=f(e=>{if(typeof ie<"u"&&ie.versions&&ie.versions.node){const[t,o]=ie.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return ie.getBuiltinModule(e)}return Io(e)},"__cjs_getBuiltinModule"),{createRequire:zo}=Re("node:module"),{readFile:Ro}=Re("node:fs/promises"),{fileURLToPath:jo}=Re("node:url"),{createHash:qo}=Re("node:crypto");var Wo=Object.defineProperty,R=f((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"y$3"),Ho=Object.defineProperty,$=R((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"w");const Uo=zo(import.meta.url),Y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,it=$(e=>{if(typeof Y<"u"&&Y.versions&&Y.versions.node){const[t,o]=Y.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return Y.getBuiltinModule(e)}return Uo(e)},"__cjs_getBuiltinModule"),oe=Y,{execFileSync:Vo}=it("node:child_process"),xe=it("node:fs"),Go=it("node:tty");var Zo=Object.defineProperty,Ko=$((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"p$2"),Qo=Object.defineProperty,Zt=Ko((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"e"),Jo=Object.defineProperty,Xo=Zt((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"E");const Kt=String.raw,yt=Kt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Yo=Xo(()=>new RegExp(Kt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${yt}(?:\u200D${yt})*`,"gu"),"default");var er=Object.defineProperty,tr=Zt((e,t)=>er(e,"name",{value:t,configurable:!0}),"p");const re=new Set(["\x1B","›"]),je="\x07",Qt="[",lt="m",Ae="]8;;",or=39,rr=/[\u200B\uFEFF\u2060-\u2064]/g,nr=new RegExp(`(?:\\${Qt}(?<code>\\d+)m|\\${Ae}(?<uri>.*)${je})`),ar=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),le=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,ye=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,Se=Yo();tr(e=>e.replace(Se,""),"stripEmoji");var sr=Object.defineProperty,N=$((e,t)=>sr(e,"name",{value:t,configurable:!0}),"f$1"),ir=Object.defineProperty,j=N((e,t)=>ir(e,"name",{value:t,configurable:!0}),"c"),lr=Object.defineProperty,_e=j((e,t)=>lr(e,"name",{value:t,configurable:!0}),"E$1");function H(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}f(H,"F$1");R(H,"M");$(H,"M$2");N(H,"M");j(H,"A");_e(H,"isAmbiguous");function U(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}f(U,"M");R(U,"N");$(U,"A$1");N(U,"C");j(U,"D$1");_e(U,"isFullWidth");function V(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<=94198||e>=94208&&e<=101589||e>=101631&&e<=101662||e>=101760&&e<=101874||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<=128728||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<=129674||e>=129678&&e<=129734||e===129736||e>=129741&&e<=129756||e>=129759&&e<=129770||e>=129775&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}f(V,"N");R(V,"L");$(V,"N$3");N(V,"T");j(V,"C");_e(V,"isWide");function ne(e){return H(e)?"ambiguous":U(e)?"fullwidth":e===8361||e>=65377&&e<=65470||e>=65474&&e<=65479||e>=65482&&e<=65487||e>=65490&&e<=65495||e>=65498&&e<=65500||e>=65512&&e<=65518?"halfwidth":e>=32&&e<=126||e===162||e===163||e===165||e===166||e===172||e===175||e>=10214&&e<=10221||e===10629||e===10630?"narrow":V(e)?"wide":"neutral"}f(ne,"z");R(ne,"J");$(ne,"F$1");N(ne,"R");j(ne,"t");_e(ne,"getCategory");var cr=Object.defineProperty,ct=j((e,t)=>cr(e,"name",{value:t,configurable:!0}),"e");function G(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}f(G,"L$2");R(G,"_");$(G,"j$3");N(G,"O");j(G,"r");ct(G,"validate");function Z(e){return G(e),ne(e)}f(Z,"P$1");R(Z,"P");$(Z,"y$3");N(Z,"v");j(Z,"eastAsianWidthType");ct(Z,"eastAsianWidthType");function me(e,{ambiguousAsWide:t=!1}={}){return G(e),U(e)||V(e)||t&&H(e)?2:1}f(me,"Q");R(me,"le");$(me,"Y$1");N(me,"J");j(me,"eastAsianWidth");ct(me,"eastAsianWidth");var dr=Object.defineProperty,Fe=j((e,t)=>dr(e,"name",{value:t,configurable:!0}),"b");const $t=new Map,$e=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Ce=Fe(e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other","getCharType"),pr=Fe((e,t)=>{const o=Math.floor(e/65536),n=e%65536;let r=$t.get(o);if(r||(r=new Map,$t.set(o,r)),r.has(n))return r.get(n);let s;if(Ce(e)==="latin")s=t.width.regular;else if(Ce(e)==="control")s=t.width.control;else if(Ce(e)==="wide")s=t.width.wide;else switch(Z(e)){case"ambiguous":{s=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{s=t.width.fullWidth;break}case"wide":{s=t.width.wide;break}default:s=t.width.regular}return r.set(n,s),s},"getCachedCharWidth"),hr=Fe(e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,"isCombiningCharacter"),Ke=Fe((e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const o={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?Ke(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},n=Math.max(0,o.truncation.limit-o.truncation.ellipsisWidth),{length:r}=e,s=r>1e4;let a=0,l=0,i=r,d=!1;const c=e.includes("\x1B")||e.includes("›");for(;a<r;){if(c&&(e[a]==="\x1B"||e[a]==="›")){if(e.startsWith("\x1B]8;;",a)){const w="\x1B]8;;\x07",y=w.length,D=e.indexOf("\x07",a+5);if(D!==-1){const F=e.indexOf(w,D+1);if(F!==-1){const ae=F+y,M=e.slice(D+1,F).replace(le,""),I=Ke(M,{ambiguousIsNarrow:o.width.ambiguousIsNarrow,ansiWidth:o.width.ansi,controlWidth:o.width.control,countAnsiEscapeCodes:!1,ellipsis:o.truncation.ellipsis,ellipsisWidth:o.truncation.ellipsisWidth,emojiWidth:o.width.emoji,fullWidth:o.width.fullWidth,halfWidth:o.width.halfWidth,limit:Math.max(0,n-l),regularWidth:o.width.regular,tabWidth:o.width.tab,wideWidth:o.width.wide}),se=I.width;if(I.truncated)d=!0,i=Math.min(i,a);else if(l+se>n&&(i=Math.min(i,a),d=!0,l+se>o.truncation.limit))break;if(l+=se,a=ae,d&&l>=o.truncation.limit)break;continue}}}if(le.lastIndex=a,le.test(e)){const w=le.lastIndex-a,y=o.truncation.countAnsiEscapeCodes?w:o.width.ansi;if(l+y>n&&(i=Math.min(i,a),l+y>o.truncation.limit)){d=!0;break}l+=y,a=le.lastIndex;continue}}const u=e.codePointAt(a);if(u===8203||u===65279||u>=8288&&u<=8292){a+=1;continue}if(u===9){if(l+o.width.tab>n&&(i=Math.min(i,a),l+o.width.tab>o.truncation.limit)){d=!0;break}l+=o.width.tab,a+=1;continue}if($e.lastIndex=a,$e.test(e)){const w=($e.lastIndex-a)*o.width.regular;if(l+w>n){const y=Math.floor((n-l)/o.width.regular);if(i=Math.min(i,a+y),l+w>o.truncation.limit){d=!0;break}}l+=w,a=$e.lastIndex;continue}if((u<=31||u>=127&&u<=159)&&(ye.lastIndex=a,ye.test(e))){const w=(ye.lastIndex-a)*o.width.control;if(l+w>n&&(i=Math.min(i,a+Math.floor((n-l)/o.width.control)),l+w>o.truncation.limit)){d=!0;break}l+=w,a=ye.lastIndex;continue}if(Se.lastIndex=a,Se.test(e)){if(l+o.width.emoji>n&&(i=Math.min(i,a),l+o.width.emoji>o.truncation.limit)){d=!0;break}l+=o.width.emoji,a=Se.lastIndex;continue}const m=e.codePointAt(a)??0;if(hr(m)){a+=m>65535?2:1;continue}let g;if(s)g=pr(m,o);else switch(Ce(m)){case"control":{g=o.width.control;break}case"latin":{g=o.width.regular;break}case"wide":{g=o.width.wide;break}case"zero":{g=0;break}default:switch(Z(m)){case"ambiguous":{g=o.width.ambiguousIsNarrow?o.width.regular:o.width.wide;break}case"fullwidth":{g=o.width.fullWidth;break}case"wide":{g=o.width.wide;break}default:g=o.width.regular}}if(l+g>n&&(i=Math.min(i,a),l+g>o.truncation.limit)){d=!0;break}l+=g,a+=m>65535?2:1}let h=l,p=!1;return d&&o.truncation.limit>=o.truncation.ellipsisWidth&&(h=o.truncation.limit,p=!0),{ellipsed:p,index:d?i:r,truncated:d,width:h}},"getStringTruncatedWidth");var ur=Object.defineProperty,gr=$((e,t)=>ur(e,"name",{value:t,configurable:!0}),"i$1"),mr=Object.defineProperty,fr=gr((e,t)=>mr(e,"name",{value:t,configurable:!0}),"e"),wr=Object.defineProperty,br=fr((e,t)=>wr(e,"name",{value:t,configurable:!0}),"r");const k=br((e,t={})=>Ke(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"getStringWidth");var vr=Object.defineProperty,kr=$((e,t)=>vr(e,"name",{value:t,configurable:!0}),"g"),xr=Object.defineProperty,yr=kr((e,t)=>xr(e,"name",{value:t,configurable:!0}),"s"),$r=Object.defineProperty,dt=yr((e,t)=>$r(e,"name",{value:t,configurable:!0}),"n");const Er=dt((e,t)=>Math.floor((e-t)/2),"halfDiff"),Sr=dt((e,t)=>e-t,"fullDiff"),Et=dt((e,t={})=>{const o=t.align??"center";if(o==="left")return e;const n=t.split??` `,r=t.pad??" ",s=o==="right"?Sr:Er;let a=!1;Array.isArray(e)||(a=!0,e=String(e).split(n));let l,i=0;return e=e.map(d=>(d=String(d),l=k(d,t.stringWidthOptions),i=Math.max(l,i),{str:d,width:l})).map(d=>Array.from({length:s(i,d.width)+1}).join(r)+d.str),a?e.join(n):e},"alignText");var Cr=Object.defineProperty,Jt=$((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"x$1"),Tr=Object.defineProperty,K=Jt((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"m"),Ar=Object.defineProperty,Dr=K((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"n");class Xt{static{f(this,"Wt")}static{R(this,"Se")}static{$(this,"T")}static{Jt(this,"w")}static{K(this,"u")}static{Dr(this,"AnsiStateTracker")}activeForeground=null;activeBackground=null;activeFormatting=[];processEscape(t){const o=/\x1B\[(\d+)m/.exec(t);if(!o)return;const n=Number.parseInt(o[1],10);switch(n){case 0:{this.activeForeground=null,this.activeBackground=null,this.activeFormatting=[];break}case 39:{this.activeForeground=null;break}case 49:{this.activeBackground=null;break}default:if(n>=30&&n<=37||n>=90&&n<=97)this.activeForeground=t;else if(n>=40&&n<=47||n>=100&&n<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(n))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(n)){const r={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[n];r&&(this.activeFormatting=this.activeFormatting.filter(s=>!s.includes(r)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const o={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].reverse().forEach(n=>{const r=o[n];r&&t.push(r)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}}var Ir=Object.defineProperty,Yt=K((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"o");const eo=Yt((e,t)=>{if(!re.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const o=!0,n=e.slice(t+1,t+1+Ae.length).join("")===Ae;return{isInsideEscape:o,isInsideLinkEscape:n}},"checkEscapeSequence"),zr=Yt((e,t={})=>{const o=new Xt;let n="",r=!1,s=!1,a="",l="",i=!1;const d=[...e];for(let c=0;c<d.length;c++){const h=d[c];if(h&&re.has(h)){if(n){const m=t.getWidth?.(n)??0,g={isEscapeSequence:!1,isGrapheme:!0,text:n,width:m};if(i&&(g.isHyperlink=!0,g.hyperlinkUrl=l),t.onSegment?.(g,o)===!1)return;n=""}if(r=!0,a=h,s=eo(d,c).isInsideLinkEscape,s){let m=c+1;for(l="";m<d.length;){const w=d[m];if(w===je)break;l+=w,m+=1}l=l.slice(4);const g={hyperlinkUrl:l,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(g,o)===!1)return;c=m,i=!0,r=!1,s=!1,a="";continue}if(c+1<d.length&&d[c+1]==="\\"&&i){const m={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(m,o)===!1)return;i=!1,l="",c+=1,r=!1,a="";continue}}if(r){if(a!==h&&(a+=h),h===lt){r=!1,o.processEscape(a);const m={isEscapeSequence:!0,isGrapheme:!1,text:a,width:0};if(t.onSegment?.(m,o)===!1)return;a=""}continue}n+=h;const p=t.getWidth?.(n)??0,u={isEscapeSequence:!1,isGrapheme:!0,text:n,width:p};if(i&&(u.isHyperlink=!0,u.hyperlinkUrl=l),t.onSegment?.(u,o)===!1)return;n=""}if(n){const c=t.getWidth?.(n)??0,h={isEscapeSequence:!1,isGrapheme:!0,text:n,width:c};i&&(h.isHyperlink=!0,h.hyperlinkUrl=l),t.onSegment?.(h,o)}if(a){const c={isEscapeSequence:!0,isGrapheme:!1,text:a,width:0};t.onSegment?.(c,o)}},"processAnsiString");var Br=Object.defineProperty,Lr=K((e,t)=>Br(e,"name",{value:t,configurable:!0}),"t$1");const St=Lr(e=>`${re.values().next().value}${Qt}${e}${lt}`,"wrapAnsiCode");var Rr=Object.defineProperty,jr=K((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"t");const Ct=jr(e=>`${re.values().next().value}${Ae}${e}${je}`,"wrapAnsiHyperlink");var _r=Object.defineProperty,Fr=K((e,t)=>_r(e,"name",{value:t,configurable:!0}),"l");const Mr=Fr(e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",o,n;const r=e.join(` `),s=[...r];let a=0;for(const[l,i]of s.entries()){if(t+=i,re.has(i)){const c=nr.exec(r.slice(a))?.groups??{};if(c.code!==void 0){const h=Number.parseFloat(c.code);o=h===or?void 0:h}else c.uri!==void 0&&(n=c.uri.length===0?void 0:c.uri)}const d=ar.get(Number(o));s[l+1]===` `?(n&&(t+=Ct("")),o&&d&&(t+=St(d))):i===` `&&(o&&d&&(t+=St(o)),n&&(t+=Ct(n))),a+=i.length}return t},"preserveAnsi");var Or=Object.defineProperty,P=K((e,t)=>Or(e,"name",{value:t,configurable:!0}),"h");const He=P(e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},"resetAnsiAtLineBreak"),q=P(e=>{const t=e.split(" ");let o=t.length;for(;o>0&&k(t[o-1])===0;)o--;return o===t.length?e:t.slice(0,o).join(" ")+t.slice(o).join("")},"stringVisibleTrimSpacesRight"),to=P((e,t,o)=>{if(e.length===0)return[""];if(t<=0)return[e];const n=[],r=new Xt;let s="",a=0,l=!1,i=!1,d="";for(let c=0;c<e.length;c++){const h=e[c];if(re.has(h)){l=!0,d=h,s+=h,i=eo([...e],c).isInsideLinkEscape;continue}if(l){d+=h,s+=h,i?h===je&&(l=i=!1):h===lt&&(l=!1,r.processEscape(d));continue}const p=k(h),u=h===" ";if(p===0){s+=h;continue}if(a+p>t&&(s&&n.push(s+r.getEndEscapesForAllActiveAttributes()),s=r.getStartEscapesForAllActiveAttributes(),a=k(s),u&&o)){for(;c<e.length&&e[c]===" "&&(c+=1,!(c>=e.length)););c<e.length&&c--;continue}if(s+=h,a+=p,a===t&&c<e.length-1&&(n.push(s+r.getEndEscapesForAllActiveAttributes()),s=r.getStartEscapesForAllActiveAttributes(),a=k(s),c+1<e.length&&e[c+1]===" "&&o)){for(c+=1;c<e.length&&e[c]===" ";)c+=1;c--}}return s&&n.push(s+r.getEndEscapesForAllActiveAttributes()),o?n.map(c=>q(c)):n},"wrapWithBreakAtWidth"),Pr=P((e,t,o)=>{if(e.length===0)return[];const n=o?e.trim():e;if(n.length===0)return[];const r=[];let s="",a=0;return zr(n,{getWidth:k,onSegment:P((l,i)=>{if(l.isEscapeSequence)s+=l.text;else{const d=l.text===" ";if(l.width===0)return s+=l.text,!0;if(a+l.width>t&&(s&&r.push(s),s=i.getStartEscapesForAllActiveAttributes(),a=0,d))return o||r.push(i.getStartEscapesForAllActiveAttributes()+l.text),!0;s+=l.text,a+=l.width}return!0},"onSegment")}),s&&r.push(s),o?r.map(l=>q(l)):r},"wrapCharByChar"),Nr=P((e,t,o)=>{if(e.length===0)return[];const n=o?e.trim():e;if(n.length===0)return[];const r=n.split(/(?=\s)|(?<=\s)/),s=[];let a="",l=0,i=0;for(;i<r.length;){const d=r[i],c=/^\s+$/.test(d),h=k(d);if(d.length===0){i+=1;continue}if(o&&c&&l===0){i+=1;continue}if(l+h>t&&l>0){o?s.push(q(a)):s.push(a),a="",l=0;continue}a+=d,l+=h,i+=1}return a&&(o?s.push(q(a)):s.push(a)),s},"wrapWithWordBoundaries"),qr=P((e,t,o)=>{if(e.length===0)return[];const n=o?e.trim():e;if(n.length===0)return[];const r=n.split(/(?=\s)|(?<=\s)/),s=[];let a="",l=0,i=0;for(;i<r.length;){const d=r[i],c=/^\s+$/.test(d),h=k(d);if(d.length===0){i+=1;continue}if(o&&c&&l===0){i+=1;continue}if(h>t){a&&s.push(He(o?q(a):a));const p=to(d,t,o);if(p.length>0){for(let u=0;u<p.length-1;u++)s.push(p[u]);a=p[p.length-1],l=k(a)}else a="",l=0;i+=1;continue}if(l+h>t&&l>0&&(s.push(He(o?q(a):a)),a="",l=0,o&&c)){i+=1;continue}a+=d,l+=h,i+=1}return a&&s.push(He(o?q(a):a)),s},"wrapAndBreakWords"),te={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},oo=P((e,t={})=>{const{removeZeroWidthCharacters:o=!0,trim:n=!0,width:r=80,wrapMode:s=te.PRESERVE_WORDS}=t;if(n&&e.trim()==="")return"";let a=String(e).normalize("NFC").replaceAll(`\r `,` `);return o&&(a=a.replaceAll(rr,"")),a.split(` `).map(l=>{if(n&&l.trim()==="")return"";let i;switch(s){case te.BREAK_AT_CHARACTERS:{i=Pr(l,r,n);break}case te.BREAK_WORDS:{i=qr(l,r,n);break}case te.STRICT_WIDTH:{i=to(l,r,n);break}default:i=Nr(l,r,n)}return Mr(i)}).join(` `)},"wordWrap");var Wr=Object.defineProperty,Q=$((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"e");const ro=80,no=24,Qe=Q((e,t,{shell:o,env:n}={})=>Vo(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:o,env:n}).trim(),"exec"),Te=Q((e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),"create"),ao=Q((e,t)=>{const{columns:o,rows:n}=Te(e,t);if(!(Number.isNaN(o)||Number.isNaN(n))&&!(o===ro&&n===no))return{columns:o,rows:n}},"createIfNotDefault");function fe(){const{env:e,stdout:t,stderr:o}=oe;if(t?.columns&&t?.rows)return Te(t.columns,t.rows);if(o?.columns&&o?.rows)return Te(o.columns,o.rows);if(e.COLUMNS&&e.LINES)return Te(e.COLUMNS,e.LINES);const n={columns:ro,rows:no};return oe.platform==="win32"?Ue()??n:oe.platform==="darwin"?Tt()??Ue()??n:Tt()??Ue()??Hr()??n}f(fe,"tt$1");R(fe,"ue");$(fe,"O");Q(fe,"terminalSize");const Tt=Q(()=>{try{const e=oe.platform==="darwin"?xe.constants.O_EVTONLY|xe.constants.O_NONBLOCK:xe.constants.O_NONBLOCK,{columns:t,rows:o}=Go.WriteStream(xe.openSync("/dev/tty",e));return{columns:t,rows:o}}catch{}},"devTty"),Ue=Q(()=>{try{const e=Qe("tput",["cols"],{env:{TERM:"dumb",...oe.env}}),t=Qe("tput",["lines"],{env:{TERM:"dumb",...oe.env}});if(e&&t)return ao(e,t)}catch{}},"tput"),Hr=Q(()=>{try{const e=Qe("resize",["-u"]).match(/\d+/g);if(e.length===2)return ao(e[0],e[1])}catch{}},"resize"),Ur={arrow:{bottom:"↑",bottomLeft:"↗",bottomRight:"↖",left:"→",right:"←",top:"↓",topLeft:"↘",topRight:"↙"},bold:{bottom:"━",bottomLeft:"┗",bottomRight:"┛",left:"┃",right:"┃",top:"━",topLeft:"┏",topRight:"┓"},classic:{bottom:"-",bottomLeft:"+",bottomRight:"+",left:"|",right:"|",top:"-",topLeft:"+",topRight:"+"},double:{bottom:"═",bottomLeft:"╚",bottomRight:"╝",left:"║",right:"║",top:"═",topLeft:"╔",topRight:"╗"},doubleSingle:{bottom:"═",bottomLeft:"╘",bottomRight:"╛",left:"│",right:"│",top:"═",topLeft:"╒",topRight:"╕"},round:{bottom:"─",bottomLeft:"╰",bottomRight:"╯",left:"│",right:"│",top:"─",topLeft:"╭",topRight:"╮"},single:{bottom:"─",bottomLeft:"└",bottomRight:"┘",left:"│",right:"│",top:"─",topLeft:"┌",topRight:"┐"},singleDouble:{bottom:"─",bottomLeft:"╙",bottomRight:"╜",left:"║",right:"║",top:"─",topLeft:"╓",topRight:"╖"}};var Vr=Object.defineProperty,Gr=$((e,t)=>Vr(e,"name",{value:t,configurable:!0}),"n");const so=Gr(e=>{let t=0;for(const o of e.split(` `))t=Math.max(t,k(o));return t},"widestLine");var Zr=Object.defineProperty,T=$((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"s");const O=` `,A=" ",ue="none",At=T(e=>typeof e=="number"?{bottom:e,left:e*3,right:e*3,top:e}:{bottom:0,left:0,right:0,top:0,...e},"getObject"),ge=T(e=>e===ue?0:2,"getBorderWidth"),Kr=T(e=>{const t=["topLeft","topRight","bottomRight","bottomLeft","left","right","top","bottom"];let o;if(e===ue){e={};for(const n of t)e[n]=""}if(typeof e=="string"){const n=Ur[e];if(n===void 0)throw new TypeError(`Invalid border style: ${e}`);o=n}else{typeof e.vertical=="string"&&(e.left=e.vertical,e.right=e.vertical),typeof e.horizontal=="string"&&(e.top=e.horizontal,e.bottom=e.horizontal);for(const n of t)if(e[n]===null||typeof e[n]!="string")throw new TypeError(`Invalid border style: ${n}`);o=e}return o},"getBorderChars"),Dt=T((e,t,o,n,r)=>{let s="";e=t(e);const a=k(e);switch(r){case"left":{s=e+n(o.slice(a),k(o.slice(a)));break}case"right":{s=`${n(o.slice(a+2),k(o.slice(a))+2)} ${e} `;break}default:{if(o=o.slice(a),o.length%2===1)o=o.slice(Math.floor(o.length/2)),s=n(o.slice(1),k(o.slice(1)))+e+n(o,k(o));else{o=o.slice(o.length/2);const l=k(o);s=n(o,l)+e+n(o,l)}break}}return s},"wrapText"),Qr=T((e,{height:t,padding:o,textAlignment:n,width:r})=>{e=Et(e,{align:n});let s=e.split(O);const a=so(e),l=r-o.left-o.right;if(a>l){const c=[];for(const h of s){const p=oo(h,{width:l,wrapMode:te.BREAK_WORDS}),u=Et(p,{align:n}).split(` `),m=Math.max(...u.map(g=>k(g)));for(const g of u){let w;switch(n){case"center":{w=A.repeat((l-m)/2)+g;break}case"right":{w=A.repeat(l-m)+g;break}default:{w=g;break}}c.push(w)}}s=c}n==="center"&&a<l?s=s.map(c=>A.repeat((l-a)/2)+c):n==="right"&&a<l&&(s=s.map(c=>A.repeat(l-a)+c));const i=A.repeat(o.left),d=A.repeat(o.right);return s=s.map(c=>{const h=i+c+d,p=r-k(h);return h+A.repeat(Math.max(p,0))}),o.top>0&&(s=[...Array.from({length:o.top}).fill(A.repeat(r)),...s]),o.bottom>0&&(s=[...s,...Array.from({length:o.bottom}).fill(A.repeat(r))]),t&&s.length>t?s=s.slice(0,t):t&&s.length<t&&(s=[...s,...Array.from({length:t-s.length}).fill(A.repeat(r))]),s.join(O)},"makeContentText"),Jr=T((e,t,o,n)=>{const r=T((p,u,m)=>n.borderColor?n.borderColor(p,u,m):p,"colorizeBorder"),s=T(p=>n.headerTextColor?n.headerTextColor(p):p,"colorizeHeaderText"),a=T(p=>n.footerTextColor?n.footerTextColor(p):p,"colorizeFooterText"),l=T(p=>n.textColor?n.textColor(p):p,"colorizeContent"),i=Kr(n.borderStyle);let d=A.repeat(n.margin.left);if(n.float==="center"){const p=Math.max((o-t-ge(n.borderStyle))/2,0);d=A.repeat(p)}else if(n.float==="right"){const p=Math.max(o-t-n.margin.right-ge(n.borderStyle),0);d=A.repeat(p)}let c="";if(n.margin.top&&(c+=O.repeat(n.margin.top)),n.borderStyle!==ue||n.headerText){let p=r(i.top.repeat(t),"top",t);n.headerText&&(p=Dt(n.headerText,s,i.top.repeat(t),(m,g)=>r(m,"top",g),n.headerAlignment));const u=r(d+i.topLeft,"topLeft",k(d+i.topLeft));c+=u+p+r(i.topRight,"topRight",k(i.topRight))+O}const h=e.split(O);if(c+=h.map(p=>d+r(i.left,"left",k(i.left))+l(p)+r(i.right,"right",k(i.right))).join(O),n.borderStyle!==ue||n.footerText){const p=O+r(d+i.bottomLeft,"bottomLeft",k(d+i.bottomLeft));let u=r(i.bottom.repeat(t),"bottom",t);n.footerText&&(u=Dt(n.footerText,a,i.bottom.repeat(t),(m,g)=>r(m,"bottom",g),n.footerAlignment)),c+=p+u+r(i.bottomRight,"bottomRight",k(i.bottomRight))}return n.margin.bottom&&(c+=O.repeat(n.margin.bottom)),c},"boxContent"),Xr=T(e=>{if(e.fullscreen){let t=fe();typeof e.fullscreen=="function"&&(t=e.fullscreen(t.columns,t.rows)),e.width||(e.width=t.columns),e.height||(e.height=t.rows)}return e.width&&(e.width=Math.max(1,e.width-ge(e.borderStyle))),e.height&&(e.height=Math.max(1,e.height-ge(e.borderStyle))),e},"sanitizeOptions"),It=T((e,t)=>t===ue?e:` ${e} `,"formatTitle"),Yr=T((e,t,o)=>{o=Xr(o);const n=o.width!==void 0,r=ge(o.borderStyle),s=t-o.margin.left-o.margin.right-r,a=so(oo(e,{trim:!1,width:t-r,wrapMode:te.BREAK_WORDS}))+o.padding.left+o.padding.right;if(o.headerText&&n?(o.headerText=o.headerText.slice(0,Math.max(0,o.width-2)),o.headerText&&(o.headerText=It(o.headerText,o.borderStyle))):o.headerText&&(o.headerText=o.headerText.slice(0,Math.max(0,s-2)),o.headerText&&(o.headerText=It(o.headerText,o.borderStyle),k(o.headerText)>a&&(o.width=k(o.headerText)))),o.width=o.width||a,!n){if(o.margin.left&&o.margin.right&&o.width>s){const l=(t-o.width-r)/(o.margin.left+o.margin.right);o.margin.left=Math.max(0,Math.floor(o.margin.left*l)),o.margin.right=Math.max(0,Math.floor(o.margin.right*l))}o.width=Math.min(o.width,t-r-o.margin.left-o.margin.right)}return o.width-(o.padding.left+o.padding.right)<=0&&(o.padding.left=0,o.padding.right=0),o.height&&o.height-(o.padding.top+o.padding.bottom)<=0&&(o.padding.top=0,o.padding.bottom=0),o},"determineDimensions"),en=T((e,t={})=>{if(t.borderColor!==void 0&&typeof t.borderColor!="function")throw new Error('"borderColor" is not a valid function');if(t.textColor!==void 0&&typeof t.textColor!="function")throw new Error('"textColor" is not a valid function');let o={borderStyle:"single",dimBorder:!1,float:"left",footerAlignment:"right",headerAlignment:"left",textAlignment:"left",transformTabToSpace:4,...t};o.padding=At(t.padding??0),o.margin=At(t.margin),o.transformTabToSpace&&(e=e.replaceAll(" "," ".repeat(o.transformTabToSpace)));const{columns:n}=fe();return o=Yr(e,n,o),Jr(Qr(e,o),o.width,n,o)},"boxen");var tn=Object.defineProperty,on=f((e,t)=>tn(e,"name",{value:t,configurable:!0}),"t$3");const rn=["cjs","mjs"],nn=["mdoc"],we=on(e=>{const t=(e.split("?")[0]??e).split(".").pop()?.toLowerCase();if(!t||rn.includes(t))return"javascript";if(nn.includes(t))return"markdown";switch(t){case"js":return"javascript";case"json":return"json";case"json5":return"json5";case"jsonc":return"jsonc";case"jsx":return"jsx";case"sql":return"sql";case"ts":return"typescript";case"tsx":return"tsx";case"xml":return"xml";case"md":return"markdown";case"mdx":return"mdx";case"svelte":return"svelte";case"vue":return"vue";case"html":return"html";case"css":return"css";case"scss":return"scss";case"less":return"less";case"sass":return"sass";case"stylus":return"stylus";case"styl":return"styl";default:return"javascript"}},"findLanguageBasedOnExtension");var an=Object.defineProperty,io=f((e,t)=>an(e,"name",{value:t,configurable:!0}),"o$4");const de=new Map,be=io(async e=>{if(/^(?:http|https|file|data):/.test(e)){if(de.has(e))return de.get(e);if(e.startsWith("file:"))try{const t=jo(e),o=await Ro(t,"utf8");return de.set(e,o),o}catch{return}try{const t=await fetch(e);if(!t.ok)return;const o=await t.text();return de.set(e,o),o}catch{return}}},"getFileSource");io(()=>{de.clear()},"clearFileSourceCache");var sn=Object.defineProperty,Me=f((e,t)=>sn(e,"name",{value:t,configurable:!0}),"d$2");const ln=Me(e=>e.replace(/^\s*#+\s*/,"").trim(),"sanitizeTitle"),cn=Me(async(e,t,o=!1)=>{const n=[...t,Ut,Vt],r=Ht(e,{frameLimit:1})[0]??{};for await(const s of n.sort((a,l)=>a.priority-l.priority)){const{handle:a}=s;if(typeof a!="function")continue;const l=await a(e,{file:r.file??"",language:we(r.file??""),line:r.line??0,snippet:r.file?await be(r.file):""});if(l)return l}},"runSolutionFinders"),lo=Me(async(e,t)=>{const{solutionFinders:o=[],solutionTitle:n,color:r,debug:s=!1,...a}=t,l=Bo(e,{...a,...r?.codeFrame}),i=await cn(e,o,s);if(!i)return{errorAnsi:l,solutionBox:void 0};const d=ln(i.header??n??"A possible solution to this error"),c=en(i.body,{borderStyle:"round",padding:{top:1,right:2,bottom:1,left:2},margin:{top:0,right:0,bottom:0,left:0},headerText:`💡 ${d}`,headerAlignment:"left",textAlignment:"left",...r?.boxen});return{errorAnsi:l,solutionBox:c}},"buildOutput");Me(async(e,t={})=>{const{logger:o=console,...n}=t,{errorAnsi:r,solutionBox:s}=await lo(e,n);o.error(r),s&&(o.log(""),o.log(s))},"terminalOutput");const zt="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-help-circle%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%2210%22%20%2F%3E%20%3Cpath%20d%3D%22M9.09%209a3%203%200%200%201%205.83%201c0%202-3%203-3%203%22%20%2F%3E%20%3Cpath%20d%3D%22M12%2017h.01%22%20%2F%3E%20%3C%2Fsvg%3E",Bt="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-keyboard%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Cpath%20d%3D%22M10%208h.01%22%20%2F%3E%20%3Cpath%20d%3D%22M12%2012h.01%22%20%2F%3E%20%3Cpath%20d%3D%22M14%208h.01%22%20%2F%3E%20%3Cpath%20d%3D%22M16%2012h.01%22%20%2F%3E%20%3Cpath%20d%3D%22M18%208h.01%22%20%2F%3E%20%3Cpath%20d%3D%22M6%208h.01%22%20%2F%3E%20%3Cpath%20d%3D%22M7%2016h10%22%20%2F%3E%20%3Cpath%20d%3D%22M8%2012h.01%22%20%2F%3E%20%3Crect%20width%3D%2220%22%20height%3D%2216%22%20x%3D%222%22%20y%3D%224%22%20rx%3D%222%22%20%2F%3E%20%3C%2Fsvg%3E";var dn=Object.defineProperty,pn=f((e,t)=>dn(e,"name",{value:t,configurable:!0}),"o$3");const hn=` <div id="ono-shortcuts-modal" class="fixed inset-0 z-50 hidden backdrop-blur-xl items-center justify-center p-2" role="dialog" aria-modal="true" aria-hidden="true" aria-labelledby="ono-shortcuts-title"> <div class="bg-[var(--ono-surface)] rounded-[var(--ono-radius-lg)] shadow-[var(--ono-elevation-2)] max-w-md w-full max-h-[90vh] overflow-auto"> <div class="flex items-center justify-between px-4 py-2 border-b border-[var(--ono-border)]"> <div class="flex items-center gap-2"> <span class="dui shrink-0 size-4" style="-webkit-mask-image:url('${Bt}'); mask-image:url('${Bt}')"></span> <h3 id="ono-shortcuts-title" class="font-semibold text-[var(--ono-text)] text-lg">Keyboard shortcuts</h3> </div> <button type="button" data-ono-action="close-shortcuts-modal" aria-label="Close keyboard shortcuts" class="text-[var(--ono-text-muted)] hover:text-[var(--ono-text)] p-1 text-xl font-bold"> × </button> </div> <div class="p-4"> <ul class="grid grid-cols-1 gap-3"> <li class="flex items-start justify-between gap-3"> <span class="text-sm text-[var(--ono-text)]">Move focus</span> <div class="flex items-center gap-1 shrink-0"> <kbd class="text-xs bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)] px-2 py-1 rounded">Tab</kbd> <span class="text-[11px] text-[var(--ono-text-muted)]">or</span> <kbd class="text-xs bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)] px-2 py-1 rounded">Shift</kbd> <kbd class="text-xs bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)] px-2 py-1 rounded">Tab</kbd> </div> </li> <li class="flex items-start justify-between gap-3"> <span class="text-sm text-[var(--ono-text)]">Activate controls</span> <div class="flex items-center gap-1 shrink-0"> <kbd class="text-xs bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)] px-2 py-1 rounded">Enter</kbd> <span class="text-[11px] text-[var(--ono-text-muted)]">or</span> <kbd class="text-xs bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)] px-2 py-1 rounded">Space</kbd> </div> </li> <li class="flex items-start justify-between gap-3"> <span class="text-sm text-[var(--ono-text)]">Open this help</span> <div class="flex items-center gap-1 shrink-0"> <kbd class="text-xs bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)] px-2 py-1 rounded">Shift</kbd> <kbd class="text-xs bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)] px-2 py-1 rounded">/</kbd> <kbd class="text-xs bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)] px-2 py-1 rounded cursor-help" title="to open this help">?</kbd> </div> </li> <li class="flex items-start justify-between gap-3"> <span class="text-sm text-[var(--ono-text)]">Close dialogs</span> <div class="flex items-center gap-1 shrink-0"> <kbd class="text-xs bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)] px-2 py-1 rounded">Esc</kbd> </div> </li> </ul> </div> </div> </div> `,un=` const bindShortcutsModal = () => { const modal = document.getElementById('ono-shortcuts-modal'); if (!modal) return; const openButtons = document.querySelectorAll('[data-ono-action="open-shortcuts-modal"]'); const closeButtons = document.querySelectorAll('[data-ono-action="close-shortcuts-modal"]'); const showModal = () => { modal.classList.remove('hidden'); modal.setAttribute('aria-hidden', 'false'); modal.focus(); }; const hideModal = () => { modal.classList.add('hidden'); modal.setAttribute('aria-hidden', 'true'); }; // Bind open buttons openButtons.forEach(button => { button.addEventListener('click', showModal); }); // Bind close buttons closeButtons.forEach(button => { button.addEventListener('click', hideModal); }); // Handle Escape key const handleEscape = (e) => { if (e.key === 'Escape' && !modal.classList.contains('hidden')) { hideModal(); } }; document.addEventListener('keydown', handleEscape); // Click outside modal to close modal.addEventListener('click', (e) => { if (e.target === modal) { hideModal(); } }); }; `,co=pn(()=>{const e=` <button type="button" aria-label="Open keyboard shortcuts" title="Keyboard shortcuts" data-ono-action="open-shortcuts-modal" class="flex justify-center items-center size-9 rounded-[var(--ono-radius-md)] shadow-[var(--ono-elevation-1)] bg-[var(--ono-surface)] text-[var(--ono-text)] hover:bg-[var(--ono-hover-overlay)] focus:outline-hidden focus:bg-[var(--ono-hover-overlay)] disabled:opacity-50 disabled:pointer-events-none cursor-pointer"> <span class="dui shrink-0 size-4" style="-webkit-mask-image:url('${zt}'); mask-image:url('${zt}')"></span> <span class="sr-only">Keyboard shortcuts</span> </button> `;return{html:hn+e,script:un.trim()}},"shortcutsButton");var Je=(e=>(e.appcode="AppCode",e["android-studio"]="Android Studio",e.atom="Atom",e["atom-beta"]="Atom Beta",e.brackets="Brackets",e.clion="CLion",e.code="Visual Studio Code",e["code-insiders"]="Visual Studio Code Insiders",e.codium="VSCodium",e.cursor="Cursor",e.emacs="GNU Emacs",e.emacsforosx="GNU Emacs for Mac OS X",e.intellij="IntelliJ IDEA",e.idea="IntelliJ IDEA",e.nano="GNU nano",e.neovim="NeoVim",e["notepad++"]="Notepad++",e.phpstorm="PhpStorm",e.pycharm="PyCharm",e.rider="Rider",e.rubymine="RubyMine",e.sublime="SublimeText",e.textmate="TextMate",e.vim="Vim",e.visualstudio="Visual Studio",e.vscode="Visual Studio Code",e.vscodium="VSCodium",e.webstorm="WebStorm",e.xcode="Xcode",e.zed="Zed",e))(Je||{}),gn=Object.defineProperty,mn=f((e,t)=>gn(e,"name",{value:t,configurable:!0}),"t$2");const fn=mn(e=>{let t='<option value="">Auto-detected Editor</option>';return Object.keys(Je).forEach(o=>{const n=e&&String(e)===String(o);t+=`<option value="${String(o)}" ${n?"selected":""}>${Je[o]}</option>`}),`<div class="relative inline-block"> <label for="editor-selector" class="sr-only">Editor</label> <select id="editor-selector" class="peer py-2 px-3 pe-9 block w-56 bg-[var(--ono-surface)] border border-[var(--ono-border)] rounded-[var(--ono-radius-md)] text-sm text-[var(--ono-text)] shadow-[var(--ono-elevation-1)] hover:bg-[var(--ono-hover-overlay)] focus:outline-hidden focus:ring-1 focus:ring-[var(--ono-red-orange)]"> ${t} </select> </div>`},"editorSelector"),Lt="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-moon-star%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Cpath%20d%3D%22M18%205h4%22%20%2F%3E%20%3Cpath%20d%3D%22M20%203v4%22%20%2F%3E%20%3Cpath%20d%3D%22M20.985%2012.486a9%209%200%201%201-9.473-9.472c.405-.022.617.46.402.803a6%206%200%200%200%208.268%208.268c.344-.215.825-.004.803.401%22%20%2F%3E%20%3C%2Fsvg%3E",Rt="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-sun%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%224%22%20%2F%3E%20%3Cpath%20d%3D%22M12%202v2%22%20%2F%3E%20%3Cpath%20d%3D%22M12%2020v2%22%20%2F%3E%20%3Cpath%20d%3D%22m4.93%204.93%201.41%201.41%22%20%2F%3E%20%3Cpath%20d%3D%22m17.66%2017.66%201.41%201.41%22%20%2F%3E%20%3Cpath%20d%3D%22M2%2012h2%22%20%2F%3E%20%3Cpath%20d%3D%22M20%2012h2%22%20%2F%3E%20%3Cpath%20d%3D%22m6.34%2017.66-1.41%201.41%22%20%2F%3E%20%3Cpath%20d%3D%22m19.07%204.93-1.41%201.41%22%20%2F%3E%20%3C%2Fsvg%3E";var wn=Object.defineProperty,bn=f((e,t)=>wn(e,"name",{value:t,configurable:!0}),"n$8");const vn=bn((e="auto")=>{const t="flex justify-center items-center size-9 rounded-[var(--ono-radius-md)] shadow-[var(--ono-elevation-1)] bg-[var(--ono-surface)] text-[var(--ono-text)] hover:bg-[var(--ono-hover-overlay)] focus:outline-hidden focus:bg-[var(--ono-hover-overlay)] disabled:opacity-50 disabled:pointer-events-none cursor-pointer";return{html:` <div id="ono-theme-switch" class="flex items-center"> <div class="inline-block"> <button type="button" aria-label="Switch to dark mode" title="Dark mode" class="ono-theme-btn ono-theme-dark hidden ${t}" data-ono-theme="dark"> <span class="inline-flex shrink-0 justify-center items-center size-4"> <span class="dui" style="-webkit-mask-image: url('${Lt}'); mask-image: url('${Lt}')"></span> </span> </button> </div> <div class="inline-block"> <button type="button" aria-label="Switch to light mode" title="Light mode" class="ono-theme-btn ono-theme-light ${t}" data-ono-theme="light"> <span class="inline-flex shrink-0 justify-center items-center size-4"> <span class="dui" style="-webkit-mask-image: url('${Rt}'); mask-image: url('${Rt}')"></span> </span> </button> </div> </div>`,script:` // Theme switching functions function setTheme(theme) { if (theme === 'dark') { addClass(document.documentElement, 'dark'); removeClass(document.documentElement, 'light'); } else { removeClass(document.documentElement, 'dark'); addClass(document.documentElement, 'light'); } localStorage.setItem('ono:theme', theme); } function getStoredTheme() { return localStorage.getItem('ono:theme') || '${e}'; } function getSystemTheme() { return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; } function applyTheme() { const stored = getStoredTheme(); const theme = stored === 'auto' ? getSystemTheme() : stored; setTheme(theme); } function showDarkButton() { const darkBtn = $('.ono-theme-dark'); const lightBtn = $('.ono-theme-light'); if (darkBtn && lightBtn) { removeClass(darkBtn, 'hidden'); addClass(lightBtn, 'hidden'); } } function showLightButton() { const darkBtn = $('.ono-theme-dark'); const lightBtn = $('.ono-theme-light'); if (darkBtn && lightBtn) { addClass(darkBtn, 'hidden'); removeClass(lightBtn, 'hidden'); } } // Listen for system theme changes window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function() { if (getStoredTheme() === 'auto') { applyTheme(); } }); // Handle theme toggle buttons document.addEventListener('click', function(e) { const btn = e.target.closest('[data-ono-theme]'); if (btn) { const theme = btn.getAttribute('data-ono-theme'); setTheme(theme); } }); ready(function() { applyTheme(); // Show appropriate button based on current theme if (document.documentElement.classList.contains('dark')) { showLightButton(); } else { showDarkButton(); } // Listen for theme changes const observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === 'attributes' && mutation.attributeName === 'class') { if (document.documentElement.classList.contains('dark')) { showLightButton(); } else { showDarkButton(); } } }); }); observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] }); });`}},"themeToggle");var kn=Object.defineProperty,xn=f((e,t)=>kn(e,"name",{value:t,configurable:!0}),"a$2");const yn=xn((e,t=!1)=>{const o=vn(e.theme),n=co();return{html:`<div class="w-full flex gap-3 items-center"> ${t?`<nav class="flex gap-1"> <button type="button" class="px-2 py-1 rounded-[var(--ono-radius-md)] text-xs bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)] shadow-[var(--ono-elevation-1)]" title="View stack trace">Stack</button> <button type="button" class="px-2 py-1 rounded-[var(--ono-radius-md)] text-xs bg-[var(--ono-white-smoke)] text-[var(--ono-text)] shadow-[var(--ono-elevation-1)]" title="View request context">Context</button> </nav>`:""} <div class="grow"></div> ${e.openInEditorUrl?fn(e.editor):""} ${n.html} ${o.html} </div>`,script:`${o.script}${n.script}${e.openInEditorUrl?` bindShortcutsModal(); // Initialize editor selector from localStorage if available (function(){ 'use strict'; function ready(fn) { if (document.readyState !== 'loading') fn(); else document.addEventListener('DOMContentLoaded', fn); } ready(function(){ try { var saved = localStorage.getItem('ono:editor'); var sel = document.getElementById('editor-selector'); if (sel && saved && sel.value !== saved) { sel.value = saved; sel.dispatchEvent(new Event('change', { bubbles: true })); } } catch(_) {} }); })(); `:` bindShortcutsModal(); `} `}},"headerBar"),$n=`<!-- @license lucide-static v0.553.0 - ISC --> <svg class="lucide lucide-blocks" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2" /> <rect x="14" y="2" width="8" height="8" rx="1" /> </svg> `,En=`<!-- @license lucide-static v0.553.0 - ISC --> <svg class="lucide lucide-layers" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /> <path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /> <path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" /> </svg> `,Sn=`<!-- @license lucide-static v0.553.0 - ISC --> <svg class="lucide lucide-square-dashed" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M5 3a2 2 0 0 0-2 2" /> <path d="M19 3a2 2 0 0 1 2 2" /> <path d="M21 19a2 2 0 0 1-2 2" /> <path d="M5 21a2 2 0 0 1-2-2" /> <path d="M9 3h1" /> <path d="M9 21h1" /> <path d="M14 3h1" /> <path d="M14 21h1" /> <path d="M3 9v1" /> <path d="M21 9v1" /> <path d="M3 14v1" /> <path d="M21 14v1" /> </svg> `;var Cn=Object.defineProperty,Tn=f((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"e$1");const po=Tn((...e)=>e.filter(t=>typeof t=="string"&&t.length>0).join(" "),"cn");var An=Object.defineProperty,jt=f((e,t)=>An(e,"name",{value:t,configurable:!0}),"r$3");const Dn=jt(e=>{const t=jt(o=>{if(o.icon)return S(o.icon);switch(o.id){case"context":return $n;case"stack":return En;default:return Sn}},"getIcon");return{html:`<nav class="flex gap-1 p-1 rounded-[var(--ono-radius-md)] bg-[var(--ono-surface-muted)] shadow-[var(--ono-elevation-1)]" role="tablist"> ${e.map(o=>{const n=po("relative px-3 py-1.5 rounded-[var(--ono-radius-md)] text-sm font-medium cursor-pointer text-[var(--ono-text-muted)] dark:text-[var(--ono-