leek-box-cli 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.mjs +3 -3
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -135,7 +135,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
|
|
|
135
135
|
`;if(zl({isTty:i,viewportRows:a,previousOutputHeight:this.lastOutputHeight,nextOutputHeight:t,isUnmounting:this.isUnmounting})){let n=this.shouldSync();n&&this.options.stdout.write(Nc),this.options.stdout.write(be+this.fullStaticOutput+o),this.lastOutput=e,this.lastOutputToRender=o,this.lastOutputHeight=t,this.log.sync(o),n&&this.options.stdout.write(Pc);return}if(r){let e=this.shouldSync();e&&this.options.stdout.write(Nc),this.log.clear(),this.options.stdout.write(n),this.log(o),e&&this.options.stdout.write(Pc)}else(e!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(o);this.lastOutput=e,this.lastOutputToRender=o,this.lastOutputHeight=t}initKittyKeyboard(){if(!this.options.kittyKeyboard)return;let e=this.options.kittyKeyboard,t=e.mode??`auto`;if(t===`disabled`)return;let n=e.flags??[`disambiguateEscapeCodes`];if(t===`enabled`){this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(n);return}!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(n)}confirmKittySupport(e){let{stdin:t,stdout:n}=this.options,r=[],i=()=>{this.cancelKittyDetection=void 0,clearTimeout(o),t.removeListener(`data`,a);let e=Ll(r);r=[],e.length>0&&t.unshift(Uint8Array.from(e))},a=t=>{let n=typeof t==`string`?El.encode(t):t;for(let e of n)r.push(e);Il(r)&&(i(),this.isUnmounted||this.enableKittyProtocol(e))};t.on(`data`,a);let o=setTimeout(i,200);this.cancelKittyDetection=i,n.write(`\x1B[?u`)}enableKittyProtocol(e){this.options.stdout.write(`\u001B[>${Cl(e)}u`),this.kittyProtocolEnabled=!0,this.kittyFlags=e}beginSuspend(){if(this.isSuspended)throw Error(`The terminal is already suspended. Resume the current suspension before suspending again.`);if(this.isSuspended=!0,!(!this.interactive||this.isUnmounted||this.isUnmounting))try{let e=this.options.stdout,{canWriteToStdout:t}=Z(e);Vl(this.throttledOnRender,t),Vl(this.throttledLog,t),t&&(this.log.clear(),this.log.done(),this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,`\x1B[<u`),this.alternateScreen&&this.writeBestEffort(this.options.stdout,Se)),this.pauseInput?.()}catch(e){this.isSuspended=!1;try{this.resumeInput?.()}catch{}throw e}}async endSuspend(){if(!this.isSuspended||(this.isSuspended=!1,this.resumeInput?.(),!this.interactive||this.isUnmounted||this.isUnmounting))return;let e=this.options.stdout,{canWriteToStdout:t}=Z(e);t&&(this.alternateScreen&&this.writeBestEffort(this.options.stdout,xe),this.kittyProtocolEnabled&&this.kittyFlags&&this.writeBestEffort(this.options.stdout,`\u001B[>${Cl(this.kittyFlags)}u`)),this.lastOutput=``,this.lastOutputToRender=``,this.lastOutputHeight=0,this.log.reset();try{this.calculateLayout(),this.onRender(),await this.waitUntilRenderFlush()}catch{}}},Ul=(e,t)=>{let r={stdout:n.stdout,stdin:n.stdin,stderr:n.stderr,debug:!1,exitOnCtrlC:!0,patchConsole:!0,maxFps:30,incrementalRendering:!1,concurrent:!1,alternateScreen:!1,...Wl(t)},i=Gl(r.stdout,()=>new Hl(r));return i.render(e),{rerender:i.render,unmount(){i.unmount()},waitUntilExit:i.waitUntilExit,waitUntilRenderFlush:i.waitUntilRenderFlush,cleanup(){i.unmount()},clear:i.clear}},Wl=(e={})=>e instanceof o?{stdout:e,stdin:n.stdin}:e,Gl=(e,t)=>{let r=Ic.get(e);if(r===void 0){let n=t();return Ic.set(e,n),n}return n.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
|
|
136
136
|
`),r};function Kl({count:e=1}){return W.createElement(`ink-text`,null,`
|
|
137
137
|
`.repeat(e))}var ql=new TextDecoder,Jl=/^(?:\x1b)([a-zA-Z0-9])$/,Yl=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Xl={OP:`f1`,OQ:`f2`,OR:`f3`,OS:`f4`,"[P":`f1`,"[Q":`f2`,"[R":`f3`,"[S":`f4`,"[11~":`f1`,"[12~":`f2`,"[13~":`f3`,"[14~":`f4`,"[[A":`f1`,"[[B":`f2`,"[[C":`f3`,"[[D":`f4`,"[[E":`f5`,"[15~":`f5`,"[17~":`f6`,"[18~":`f7`,"[19~":`f8`,"[20~":`f9`,"[21~":`f10`,"[23~":`f11`,"[24~":`f12`,"[A":`up`,"[B":`down`,"[C":`right`,"[D":`left`,"[E":`clear`,"[F":`end`,"[H":`home`,OA:`up`,OB:`down`,OC:`right`,OD:`left`,OE:`clear`,OF:`end`,OH:`home`,"[1~":`home`,"[2~":`insert`,"[3~":`delete`,"[4~":`end`,"[5~":`pageup`,"[6~":`pagedown`,"[[5~":`pageup`,"[[6~":`pagedown`,"[7~":`home`,"[8~":`end`,"[a":`up`,"[b":`down`,"[c":`right`,"[d":`left`,"[e":`clear`,"[2$":`insert`,"[3$":`delete`,"[5$":`pageup`,"[6$":`pagedown`,"[7$":`home`,"[8$":`end`,Oa:`up`,Ob:`down`,Oc:`right`,Od:`left`,Oe:`clear`,"[2^":`insert`,"[3^":`delete`,"[5^":`pageup`,"[6^":`pagedown`,"[7^":`home`,"[8^":`end`,"[Z":`tab`},Zl=[...Object.values(Xl),`backspace`],Ql=e=>[`[a`,`[b`,`[c`,`[d`,`[e`,`[2$`,`[3$`,`[5$`,`[6$`,`[7$`,`[8$`,`[Z`].includes(e),$l=e=>[`Oa`,`Ob`,`Oc`,`Od`,`Oe`,`[2^`,`[3^`,`[5^`,`[6^`,`[7^`,`[8^`].includes(e),eu=/^\x1b\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,tu=/^\x1b\[(\d+);(\d+):(\d+)([A-Za-z~])$/,nu={A:`up`,B:`down`,C:`right`,D:`left`,E:`clear`,F:`end`,H:`home`,P:`f1`,Q:`f2`,R:`f3`,S:`f4`},ru={2:`insert`,3:`delete`,5:`pageup`,6:`pagedown`,7:`home`,8:`end`,11:`f1`,12:`f2`,13:`f3`,14:`f4`,15:`f5`,17:`f6`,18:`f7`,19:`f8`,20:`f9`,21:`f10`,23:`f11`,24:`f12`},iu={27:`escape`,9:`tab`,127:`backspace`,8:`backspace`,57358:`capslock`,57359:`scrolllock`,57360:`numlock`,57361:`printscreen`,57362:`pause`,57363:`menu`,57376:`f13`,57377:`f14`,57378:`f15`,57379:`f16`,57380:`f17`,57381:`f18`,57382:`f19`,57383:`f20`,57384:`f21`,57385:`f22`,57386:`f23`,57387:`f24`,57388:`f25`,57389:`f26`,57390:`f27`,57391:`f28`,57392:`f29`,57393:`f30`,57394:`f31`,57395:`f32`,57396:`f33`,57397:`f34`,57398:`f35`,57399:`kp0`,57400:`kp1`,57401:`kp2`,57402:`kp3`,57403:`kp4`,57404:`kp5`,57405:`kp6`,57406:`kp7`,57407:`kp8`,57408:`kp9`,57409:`kpdecimal`,57410:`kpdivide`,57411:`kpmultiply`,57412:`kpsubtract`,57413:`kpadd`,57414:`kpenter`,57415:`kpequal`,57416:`kpseparator`,57417:`kpleft`,57418:`kpright`,57419:`kpup`,57420:`kpdown`,57421:`kppageup`,57422:`kppagedown`,57423:`kphome`,57424:`kpend`,57425:`kpinsert`,57426:`kpdelete`,57427:`kpbegin`,57428:`mediaplay`,57429:`mediapause`,57430:`mediaplaypause`,57431:`mediareverse`,57432:`mediastop`,57433:`mediafastforward`,57434:`mediarewind`,57435:`mediatracknext`,57436:`mediatrackprevious`,57437:`mediarecord`,57438:`lowervolume`,57439:`raisevolume`,57440:`mutevolume`,57441:`leftshift`,57442:`leftcontrol`,57443:`leftalt`,57444:`leftsuper`,57445:`lefthyper`,57446:`leftmeta`,57447:`rightshift`,57448:`rightcontrol`,57449:`rightalt`,57450:`rightsuper`,57451:`righthyper`,57452:`rightmeta`,57453:`isoLevel3Shift`,57454:`isoLevel5Shift`},au=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),ou=e=>au(e)?String.fromCodePoint(e):`?`;function su(e){return e===3?`release`:e===2?`repeat`:`press`}function cu(e){return{ctrl:!!(e&wl.ctrl),shift:!!(e&wl.shift),meta:!!(e&(wl.meta|wl.alt)),super:!!(e&wl.super),hyper:!!(e&wl.hyper),capsLock:!!(e&wl.capsLock),numLock:!!(e&wl.numLock)}}var lu=e=>{let t=eu.exec(e);if(!t)return null;let n=parseInt(t[1],10),r=t[2]?Math.max(0,parseInt(t[2],10)-1):0,i=t[3]?parseInt(t[3],10):1,a=t[4];if(!au(n))return null;let o;a&&(o=a.split(`:`).map(e=>ou(parseInt(e,10))).join(``));let s,c;return n===32?(s=`space`,c=!0):n===13?(s=`return`,c=!0):iu[n]?(s=iu[n],c=!1):n>=1&&n<=26?(s=String.fromCodePoint(n+96),c=!1):(s=ou(n).toLowerCase(),c=!0),c&&!o&&(o=ou(n)),{name:s,...cu(r),eventType:su(i),sequence:e,raw:e,isKittyProtocol:!0,isPrintable:c,text:o}},uu=e=>{let t=tu.exec(e);if(!t)return null;let n=parseInt(t[1],10),r=Math.max(0,parseInt(t[2],10)-1),i=parseInt(t[3],10),a=t[4],o=a===`~`?ru[n]:nu[a];return o?{name:o,...cu(r),eventType:su(i),sequence:e,raw:e,isKittyProtocol:!0,isPrintable:!1}:null},du=(e=``)=>{let t;e instanceof Uint8Array?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B`+ql.decode(e)):e=ql.decode(e):e!==void 0&&typeof e!=`string`?e=String(e):e||=``;let n=lu(e);if(n)return n;let r=uu(e);if(r)return r;if(eu.test(e))return{name:``,ctrl:!1,meta:!1,shift:!1,sequence:e,raw:e,isKittyProtocol:!0,isPrintable:!1};let i={name:``,ctrl:!1,meta:!1,shift:!1,sequence:e,raw:e};if(i.sequence=i.sequence||e||i.name,e===`\r`||e===`\x1B\r`)i.raw=void 0,i.name=`return`,i.meta=e.length===2;else if(e===`
|
|
138
|
-
`)i.name=`enter`;else if(e===` `)i.name=`tab`;else if(e===`\b`||e===`\x1B\b`)i.name=`backspace`,i.meta=e.charAt(0)===`\x1B`;else if(e===``||e===`\x1B`)i.name=`backspace`,i.meta=e.charAt(0)===`\x1B`;else if(e===`\x1B`||e===`\x1B\x1B`)i.name=`escape`,i.meta=e.length===2;else if(e===` `||e===`\x1B `)i.name=`space`,i.meta=e.length===2;else if(e.length===1&&e<=``)i.name=String.fromCharCode(e.charCodeAt(0)+97-1),i.ctrl=!0;else if(e.length===1&&e>=`0`&&e<=`9`)i.name=`number`;else if(e.length===1&&e>=`a`&&e<=`z`)i.name=e;else if(e.length===1&&e>=`A`&&e<=`Z`)i.name=e.toLowerCase(),i.shift=!0;else if(t=Jl.exec(e))i.name=t[1].toLowerCase(),i.meta=!0,i.shift=/^[A-Z]$/.test(t[1]);else if(t=Yl.exec(e)){let n=[...e];n[0]===`\x1B`&&n[1]===`\x1B`&&(i.meta=!0);let r=[t[1],t[2],t[4],t[6]].filter(Boolean).join(``),a=(t[3]||t[5]||1)-1;i.ctrl=!!(a&4),i.meta=i.meta||!!(a&10),i.shift=!!(a&1),i.code=r,i.name=Xl[r]??``,i.shift=Ql(r)||i.shift,i.ctrl=$l(r)||i.ctrl}return i},fu=()=>(0,W.useContext)($c),pu=(e,t={})=>{let{setRawMode:n,internal_exitOnCtrlC:r,internal_eventEmitter:i}=fu();(0,W.useEffect)(()=>{if(t.isActive!==!1)return n(!0),()=>{n(!1)}},[t.isActive,n]);let a=(0,W.useEffectEvent)(t=>{let n=du(t),i={upArrow:n.name===`up`,downArrow:n.name===`down`,leftArrow:n.name===`left`,rightArrow:n.name===`right`,pageDown:n.name===`pagedown`,pageUp:n.name===`pageup`,home:n.name===`home`,end:n.name===`end`,return:n.name===`return`,escape:n.name===`escape`,ctrl:n.ctrl,shift:n.shift,tab:n.name===`tab`,backspace:n.name===`backspace`,delete:n.name===`delete`,meta:n.meta,super:n.super??!1,hyper:n.hyper??!1,capsLock:n.capsLock??!1,numLock:n.numLock??!1,eventType:n.eventType},a;a=n.isKittyProtocol?n.isPrintable?n.text??n.name:n.ctrl&&n.name.length===1?n.name:``:n.ctrl?n.name??``:n.sequence,!n.isKittyProtocol&&Zl.includes(n.name)&&(a=``),a.startsWith(`\x1B`)&&(a=a.slice(1)),a.length===1&&/[A-Z]/.test(a)&&(i.shift=!0),!(a===`c`&&i.ctrl&&r)&&Io.discreteUpdates(()=>{e(a,i)})});(0,W.useEffect)(()=>{if(t.isActive!==!1)return i.on(`input`,a),()=>{i.removeListener(`input`,a)}},[t.isActive,i])},mu=()=>(0,W.useContext)(Qc),hu=()=>(0,W.useContext)(el),gu=()=>{let{stdout:e}=hu(),[t,n]=(0,W.useState)(()=>nr(e));return(0,W.useEffect)(()=>{let t=()=>{n(nr(e))};return e.on(`resize`,t),()=>{e.off(`resize`,t)}},[e]),t},_u={width:0,height:0,left:0,top:0},vu=e=>{if(e)return e.parentNode?vu(e.parentNode):e.nodeName===`ink-root`?e:void 0},yu=e=>{let[t,n]=(0,W.useState)(_u),[r,i]=(0,W.useState)(!1),a=(0,W.useCallback)(()=>{let t=e.current?.yogaNode?.getComputedLayout()??_u;n(e=>e.width!==t.width||e.height!==t.height||e.left!==t.left||e.top!==t.top?t:e),i(!!e.current)},[e]);return(0,W.useEffect)(a),(0,W.useEffect)(()=>{let t=vu(e.current);if(t)return za(t,a)}),(0,W.useMemo)(()=>({...t,hasMeasured:r}),[t,r])},bu=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},xu=(e=>e?bu(e):bu),Su=e=>e;function Cu(e,t=Su){let n=W.useSyncExternalStore(e.subscribe,W.useCallback(()=>t(e.getState()),[e,t]),W.useCallback(()=>t(e.getInitialState()),[e,t]));return W.useDebugValue(n),n}var wu=e=>{let t=xu(e),n=e=>Cu(t,e);return Object.assign(n,t),n},Tu=(e=>e?wu(e):wu),Eu=[`single`,`double`,`round`,`bold`,`singleDouble`,`doubleSingle`,`classic`,`arrow`],Du=[`red-up`,`green-up`],Ou={"red-up":`涨红跌绿`,"green-up":`涨绿跌红`},ku=`red-up`,Au={classic:{label:`经典紫蓝`,primary:`magenta`,accent:`blue`,highlight:`cyan`,foreground:`white`},ocean:{label:`海洋青蓝`,primary:`cyan`,accent:`blue`,highlight:`cyan`,foreground:`white`},forest:{label:`森林绿`,primary:`green`,accent:`green`,highlight:`green`,foreground:`white`},sunset:{label:`日落黄红`,primary:`yellow`,accent:`red`,highlight:`yellow`,foreground:`white`},gray:{label:`低调灰`,primary:`gray`,accent:`gray`,highlight:`gray`,foreground:`white`}},ju=Object.keys(Au),Mu={requestTimeoutMs:{min:1e3,max:6e4,step:1e3},minimumRequestDurationMs:{min:0,max:5e3,step:250},quotePollIntervalMs:{min:1e3,max:6e4,step:500},minuteChartPollIntervalMs:{min:5e3,max:3e5,step:5e3},klinePollIntervalMs:{min:3e4,max:18e5,step:3e4}},Nu={themePreset:`classic`,trendColorMode:ku,borderStyle:`round`,requestTimeoutMs:8e3,minimumRequestDurationMs:0,quotePollIntervalMs:5e3,minuteChartPollIntervalMs:3e4,klinePollIntervalMs:3e5},Pu=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),Fu=e=>{let t=Pu(e.requestTimeoutMs,Mu.requestTimeoutMs.min,Mu.requestTimeoutMs.max);return{...e,requestTimeoutMs:t,minimumRequestDurationMs:Math.min(t,Pu(e.minimumRequestDurationMs,Mu.minimumRequestDurationMs.min,Mu.minimumRequestDurationMs.max)),quotePollIntervalMs:Pu(e.quotePollIntervalMs,Mu.quotePollIntervalMs.min,Mu.quotePollIntervalMs.max),minuteChartPollIntervalMs:Pu(e.minuteChartPollIntervalMs,Mu.minuteChartPollIntervalMs.min,Mu.minuteChartPollIntervalMs.max),klinePollIntervalMs:Pu(e.klinePollIntervalMs,Mu.klinePollIntervalMs.min,Mu.klinePollIntervalMs.max)}},Iu=e=>({themePreset:e.themePreset,trendColorMode:e.trendColorMode,borderStyle:e.borderStyle,requestTimeoutMs:e.requestTimeoutMs,minimumRequestDurationMs:e.minimumRequestDurationMs,quotePollIntervalMs:e.quotePollIntervalMs,minuteChartPollIntervalMs:e.minuteChartPollIntervalMs,klinePollIntervalMs:e.klinePollIntervalMs}),Lu=(e,t)=>e.themePreset===t.themePreset&&e.trendColorMode===t.trendColorMode&&e.borderStyle===t.borderStyle&&e.requestTimeoutMs===t.requestTimeoutMs&&e.minimumRequestDurationMs===t.minimumRequestDurationMs&&e.quotePollIntervalMs===t.quotePollIntervalMs&&e.minuteChartPollIntervalMs===t.minuteChartPollIntervalMs&&e.klinePollIntervalMs===t.klinePollIntervalMs,Ru=(e,t)=>{let n={};return e.themePreset!==t.themePreset&&(n.themePreset=e.themePreset),e.trendColorMode!==t.trendColorMode&&(n.trendColorMode=e.trendColorMode),e.borderStyle!==t.borderStyle&&(n.borderStyle=e.borderStyle),e.requestTimeoutMs!==t.requestTimeoutMs&&(n.requestTimeoutMs=e.requestTimeoutMs),e.minimumRequestDurationMs!==t.minimumRequestDurationMs&&(n.minimumRequestDurationMs=e.minimumRequestDurationMs),e.quotePollIntervalMs!==t.quotePollIntervalMs&&(n.quotePollIntervalMs=e.quotePollIntervalMs),e.minuteChartPollIntervalMs!==t.minuteChartPollIntervalMs&&(n.minuteChartPollIntervalMs=e.minuteChartPollIntervalMs),e.klinePollIntervalMs!==t.klinePollIntervalMs&&(n.klinePollIntervalMs=e.klinePollIntervalMs),n},zu=Tu()(e=>({...Nu,updateSettings:t=>e(e=>Fu({...Iu(e),...t})),adjustNumericSetting:(t,n)=>e(e=>{let r=Mu[t],i=Pu(e[t]+r.step*n,r.min,r.max);return Fu({...Iu(e),[t]:i})}),resetSettings:()=>e(Nu),hydrateSettings:t=>e(Fu(t))}));function Bu(){return zu(e=>Au[e.themePreset])}var Vu=Tu()(e=>({open:!1,toggle:()=>e(e=>({open:!e.open})),close:()=>e({open:!1})}));function Hu(e){return e instanceof Error?e.message:String(e)}var Uu=n.platform===`win32`,Wu=/^(?:sh|sz|bj)\d{6}$/,Gu=(e,t)=>{if(typeof e!=`object`||!e)throw Error(`第 ${t+1} 项不是对象`);let n=e;if(typeof n.code!=`string`||!Wu.test(n.code))throw Error(`第 ${t+1} 项 code 无效`);if(typeof n.name!=`string`||n.name.trim()===``)throw Error(`第 ${t+1} 项 name 无效`);if(typeof n.addedAt!=`string`||!Number.isFinite(Date.parse(n.addedAt)))throw Error(`第 ${t+1} 项 addedAt 无效`);return{code:n.code,name:n.name,addedAt:n.addedAt}};function Ku(e){if(!Array.isArray(e))throw Error(`stocks 不是数组`);let t=e.map(Gu),n=new Set;for(let[e,r]of t.entries()){if(n.has(r.code))throw Error(`第 ${e+1} 项 code 重复: ${r.code}`);n.add(r.code)}return t}var qu=25,Ju=2e3,Yu=3e4,Xu=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Zu=e=>{if(typeof e!=`string`||!ju.includes(e))throw Error(`theme.preset 无效`);return e},Qu=e=>{if(e===void 0)return ku;if(typeof e!=`string`||!Du.includes(e))throw Error(`theme.trendColorMode 无效`);return e},$u=(e,t,n)=>{if(typeof e!=`number`||!Number.isInteger(e)||e<n.min||e>n.max)throw Error(`${t} 无效`);return e};function ed(e){if(!Xu(e))throw Error(`顶层数据不是对象`);let t=e.theme;if(!Xu(t))throw Error(`theme 无效`);let n=t.borderStyle;if(typeof n!=`string`||!Eu.includes(n))throw Error(`theme.borderStyle 无效`);let r=e.request;if(!Xu(r))throw Error(`request 无效`);let i=$u(r.timeoutMs,`request.timeoutMs`,Mu.requestTimeoutMs),a=$u(r.minimumDurationMs,`request.minimumDurationMs`,Mu.minimumRequestDurationMs);if(a>i)throw Error(`request.minimumDurationMs 不能大于 request.timeoutMs`);return{theme:{preset:Zu(t.preset),trendColorMode:Qu(t.trendColorMode),borderStyle:n},request:{timeoutMs:i,minimumDurationMs:a,quotePollIntervalMs:$u(r.quotePollIntervalMs,`request.quotePollIntervalMs`,Mu.quotePollIntervalMs),minuteChartPollIntervalMs:$u(r.minuteChartPollIntervalMs,`request.minuteChartPollIntervalMs`,Mu.minuteChartPollIntervalMs),klinePollIntervalMs:$u(r.klinePollIntervalMs,`request.klinePollIntervalMs`,Mu.klinePollIntervalMs)},stocks:Ku(e.stocks)}}function td(e){return{themePreset:e.theme.preset,trendColorMode:e.theme.trendColorMode,borderStyle:e.theme.borderStyle,requestTimeoutMs:e.request.timeoutMs,minimumRequestDurationMs:e.request.minimumDurationMs,quotePollIntervalMs:e.request.quotePollIntervalMs,minuteChartPollIntervalMs:e.request.minuteChartPollIntervalMs,klinePollIntervalMs:e.request.klinePollIntervalMs}}var nd=[{code:`sz002156`,name:`富通微电`},{code:`sh600584`,name:`长电科技`},{code:`sh688825`,name:`长鑫科技`}],rd=()=>{let e=new Date().toISOString();return nd.map(t=>({...t,addedAt:e}))},id=(e,t)=>({theme:{preset:e.themePreset,trendColorMode:e.trendColorMode,borderStyle:e.borderStyle},request:{timeoutMs:e.requestTimeoutMs,minimumDurationMs:e.minimumRequestDurationMs,quotePollIntervalMs:e.quotePollIntervalMs,minuteChartPollIntervalMs:e.minuteChartPollIntervalMs,klinePollIntervalMs:e.klinePollIntervalMs},stocks:t}),ad=()=>{let e=n.env.XDG_CONFIG_HOME;if(e)return O(e,`leek-box-cli`);if(Uu){let e=n.env.APPDATA;if(e)return O(e,`leek-box-cli`)}return O(c(),`.config`,`leek-box-cli`)};function od(){return O(ad(),`settings.json`)}var sd=e=>e.charCodeAt(0)===65279?e.slice(1):e,cd=async e=>{try{return JSON.parse(sd(await x(e,`utf8`)))}catch(e){if(e.code===`ENOENT`)return;throw e}},ld=async()=>{let e=od();try{let t=await cd(e);return t===void 0?void 0:ed(t)}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`设置文件损坏: ${e} (${n})`)}},ud=async e=>{let t=ed(e),r=od();await b(D(r),{recursive:!0});let i=`${r}.${n.pid}.${v()}.tmp`;try{await T(i,`${JSON.stringify(t,null,2)}\n`,`utf8`),await S(i,r)}finally{await C(i,{force:!0})}},dd=e=>new Promise(t=>setTimeout(t,e)),fd=e=>{try{return n.kill(e,0),!0}catch(e){return e.code!==`ESRCH`}},pd=async e=>{let t;try{t=await x(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return!0;throw e}let n=!1;try{let e=JSON.parse(t);if(!Xu(e)||typeof e.token!=`string`||typeof e.pid!=`number`||!Number.isInteger(e.pid)||e.pid<=0||typeof e.createdAt!=`number`||!Number.isFinite(e.createdAt))throw Error(`lock metadata 无效`);n=!fd(e.pid)||Date.now()-e.createdAt>=Yu}catch{try{let t=await w(e);n=Date.now()-t.mtimeMs>=Ju}catch(e){if(e.code===`ENOENT`)return!0;throw e}}if(!n)return!1;try{return await x(e,`utf8`)===t&&(await C(e),!0)}catch(e){if(e.code===`ENOENT`)return!0;throw e}},md=async(e,t)=>{let r=`${e}.${n.pid}.${v()}.tmp`;try{await T(r,t,{encoding:`utf8`,flag:`wx`}),await y(r,e)}finally{await C(r,{force:!0})}};async function hd(e){let t=od(),r=`${t}.lock`,i=v(),a=JSON.stringify({token:i,pid:n.pid,createdAt:Date.now()});await b(D(t),{recursive:!0});let o=Date.now(),s=!1;for(;!s;)try{await md(r,a),s=!0}catch(e){if(e.code!==`EEXIST`)throw e;if(await pd(r))continue;if(Date.now()-o>=Ju)throw Error(`设置文件正被其他进程占用, 请稍后重试`);await dd(qu)}let c;try{c={ok:!0,value:await e()}}catch(e){c={ok:!1,error:e}}let l;try{await x(r,`utf8`)===a&&await C(r)}catch(e){e.code!==`ENOENT`&&(l=e)}if(!c.ok)throw c.error;if(l)throw l;return c.value}var gd=async()=>{let e=await ld();if(e)return e;let t=id(Nu,rd());return await ud(t),t};async function _d(){return await ld()??hd(gd)}var vd=_d;async function yd(e){await hd(async()=>{let t=await gd();await ud(id({...td(t),...e},t.stocks))})}async function bd(){return(await vd()).stocks}async function xd(e){let t=Ku(e);return hd(async()=>{let e=await gd(),n=new Set(e.stocks.map(e=>e.code)),r=t.filter(e=>!n.has(e.code));return r.length>0&&await ud({...e,stocks:[...e.stocks,...r]}),r.length})}async function Sd(e){let t=new Set(e);return t.size===0?0:hd(async()=>{let e=await gd(),n=e.stocks.filter(e=>!t.has(e.code)),r=e.stocks.length-n.length;return r>0&&await ud({...e,stocks:n}),r})}var Cd={loadStocks:bd};function wd(e=Cd){return Tu()(t=>({entries:[],errorMessage:void 0,resetToken:0,loadEntries:async()=>{t({errorMessage:void 0});try{t({entries:await e.loadStocks()})}catch(e){t({entries:[],errorMessage:Hu(e)})}},removeByCodes:e=>{let n=new Set(e);t(e=>({entries:e.entries.filter(e=>!n.has(e.code)),resetToken:e.resetToken+1}))},resetSelection:()=>t(e=>({resetToken:e.resetToken+1}))}))}var Td=wd(),Ed=e=>e.type===`confirm`,Dd=e=>e.type===`confirm`||e.type===`removing`||e.type===`done`||e.type===`error`,Od={stocksRemove:Sd,commitRemoval:e=>Td.getState().removeByCodes(e),resetSelection:()=>Td.getState().resetSelection()};function kd(e=Od){return Tu()((t,n)=>({step:{type:`idle`},targets:[],open:e=>{n().step.type===`idle`&&e.length!==0&&t({step:{type:`confirm`},targets:e})},confirmDelete:async()=>{if(n().step.type!==`confirm`)return;let r=n().targets.map(e=>e.code),i=r.length;t({step:{type:`removing`}});try{let n=await e.stocksRemove(r);if(n===0){t({step:{type:`error`,message:`所选 ${i} 个条目已不在自选股中.`}});return}e.commitRemoval(r);let a=i-n;if(a>0){t({step:{type:`done`,message:`已删除 ${n} 个股票, ${a} 个条目已不在自选股中.`},targets:[]});return}t({step:{type:`idle`},targets:[]})}catch(e){t({step:{type:`error`,message:`删除失败: ${Hu(e)}`}})}},cancel:()=>{n().step.type===`confirm`&&(t({step:{type:`idle`},targets:[]}),e.resetSelection())},dismiss:()=>{(n().step.type===`done`||n().step.type===`error`)&&t({step:{type:`idle`},targets:[]})}}))}var Ad=kd(),jd=e=>typeof e==`object`&&e?e:void 0,Md=(e,t)=>{let n=Number.parseFloat(e[t]??``);return Number.isFinite(n)?n:0},Nd=e=>{let t=Number.parseFloat(typeof e==`string`||typeof e==`number`?String(e):``);return Number.isFinite(t)?t:0},Pd=e=>{if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let[e=``,r=``,i=``]=n.split(` `);if(!/^(?:[01]\d|2[0-3])[0-5]\d$/.test(e)||e>`1500`)continue;let a=Number.parseFloat(r);if(!Number.isFinite(a)||a<=0)continue;let o=Number.parseFloat(i);t.push({time:e,price:a,volume:Number.isFinite(o)?o:0})}return t};function Fd(e){let t=[];for(let n of e.split(`;`)){let e=/^v_([a-z]{2}\d{6})="([^"]*)"/.exec(n.trim());if(!e)continue;let r=e[2].split(`~`);if(r.length<50)continue;let i=r[1].trim();i&&t.push({code:e[1],name:i,current:Md(r,3),prevClose:Md(r,4),open:Md(r,5),high:Md(r,33),low:Md(r,34),change:Md(r,31),changePercent:Md(r,32),timestamp:r[30],volume:Md(r,36),turnover:Md(r,37),turnoverRate:Md(r,38),amplitude:Md(r,43),marketCap:Md(r,45),volumeRatio:Md(r,49)})}if(t.length===0)throw Error(`未查询到任何行情数据, 请检查股票代码`);return t}function Id(e,t){return Pd(jd(jd(jd(jd(e)?.data)?.[t])?.data)?.data)}function Ld(e,t){let n=jd(jd(jd(e)?.data)?.[t])?.data;return Array.isArray(n)?n.flatMap(e=>{let t=jd(e),n=t?.date;if(typeof n!=`string`||!/^\d{8}$/.test(n))return[];let r=`${n.slice(0,4)}-${n.slice(4,6)}-${n.slice(6,8)}`,i=Nd(t?.prec);return[{sessionDate:r,points:Pd(t?.data).map(e=>({...e,sessionDate:r,prevClose:i}))}]}).sort((e,t)=>e.sessionDate.localeCompare(t.sessionDate)).slice(-5).flatMap(e=>e.points):[]}function Rd(e,t,n=`day`,r=`qfq`){let i=jd(jd(jd(e)?.data)?.[t]),a=i?.[`${r}${n}`],o=Array.isArray(a)&&a.length>0?a:i?.[n];if(!Array.isArray(o))return[];let s=[];for(let e of o){if(!Array.isArray(e))continue;let[t,n,r,i,a,o]=e;if(typeof t!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(t))continue;let c=Nd(n),l=Nd(r),u=Nd(i),d=Nd(a),f=Nd(o);[c,l,u,d].some(e=>e<=0)||s.push({date:t,open:c,close:l,high:u,low:d,volume:Math.max(0,f)})}return s}var zd=(e,t)=>e<=0?Promise.resolve():t?.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason)};t?.addEventListener(`abort`,a,{once:!0})}),Bd=async(e,t)=>{let{requestTimeoutMs:n,minimumRequestDurationMs:r}=zu.getState(),i=AbortSignal.timeout(n),a=e?AbortSignal.any([e,i]):i,o=Date.now(),s=await t(a);return await zd(r-(Date.now()-o),e),s};function Vd(e){let t=e.trim().toUpperCase();if(t=t.replace(/\.(SH|SZ|BJ)$/,``),t=t.replace(/^(SH|SZ|BJ)/,``),!/^\d{6}$/.test(t))return;let n;if(t.startsWith(`6`)||t.startsWith(`5`))n=`sh`;else if(t.startsWith(`0`)||t.startsWith(`1`)||t.startsWith(`3`))n=`sz`;else if(t.startsWith(`4`)||t.startsWith(`8`)||t.startsWith(`92`))n=`bj`;else return;return`${n}${t}`}async function Hd(e,t){return e.length===0?[]:Bd(t,async t=>{let n=await fetch(`https://qt.gtimg.cn/q=${e.join(`,`)}`,{signal:t});if(!n.ok)throw Error(`行情接口请求失败: HTTP ${n.status}`);let r=await n.arrayBuffer();return Fd(new TextDecoder(`gbk`).decode(r))})}async function Ud(e,t){return Bd(t,async t=>{let n=await fetch(`https://web.ifzq.gtimg.cn/appstock/app/minute/query?code=${e}`,{signal:t});if(!n.ok)throw Error(`分时接口请求失败: HTTP ${n.status}`);return Id(await n.json(),e)})}async function Wd(e,t){return Bd(t,async t=>{let n=await fetch(`https://web.ifzq.gtimg.cn/appstock/app/day/query?code=${e}`,{signal:t});if(!n.ok)throw Error(`五日行情接口请求失败: HTTP ${n.status}`);return Ld(await n.json(),e)})}var Gd=e=>{let t=new Map;for(let n of[...e].sort((e,t)=>e.date.localeCompare(t.date))){let e=n.date.slice(0,4),r=t.get(e);if(!r){t.set(e,{...n});continue}r.date=n.date,r.close=n.close,r.high=Math.max(r.high,n.high),r.low=Math.min(r.low,n.low),r.volume+=n.volume}return[...t.values()]};async function Kd(e,t){return Bd(t.signal,async n=>{let r=t.period===`year`?`month`:t.period,i=t.period===`year`?`hfq`:`qfq`,a=t.period===`year`?t.barCount*12:t.barCount,o=encodeURIComponent(`${e},${r},,,${a},${i}`),s=await fetch(`https://web.ifzq.gtimg.cn/appstock/app/fqkline/get?param=${o}`,{signal:n});if(!s.ok)throw Error(`K 线行情接口请求失败: HTTP ${s.status}`);let c=Rd(await s.json(),e,r,i);return(t.period===`year`?Gd(c):c).slice(-t.barCount)})}var qd={day:{barCount:60},week:{barCount:60},month:{barCount:60},year:{barCount:30}},Jd=`intraday`,Yd=e=>e!==`intraday`&&e!==`five-day`,Xd={fetchIntraday:Ud,fetchFiveDay:Wd,fetchHistorical:Kd};function Zd(e=Xd){return Tu()((t,n)=>({stock:void 0,period:Jd,status:`loading`,points:[],open:(e,n)=>t({stock:{code:e,name:n},period:Jd,status:`loading`,points:[],errorMessage:void 0}),close:()=>t({stock:void 0}),setPeriod:e=>{n().period!==e&&t({period:e,status:`loading`,points:[],errorMessage:void 0})},refreshChart:async(r,i,a)=>{try{let o;if(i===`intraday`)o=await e.fetchIntraday(r,a);else if(i===`five-day`)o=await e.fetchFiveDay?.(r,a);else if(Yd(i)){let t=qd[i];o=await e.fetchHistorical?.(r,{period:i,...t,signal:a})}if(!o)throw Error(`${i===`five-day`?`五日`:`K 线`}行情数据源不可用`);if(n().stock?.code!==r||n().period!==i||a?.aborted)return;t({status:`ready`,points:o,errorMessage:void 0})}catch(e){if(n().stock?.code!==r||n().period!==i||a?.aborted)return;t({status:`error`,errorMessage:Hu(e)})}}}))}var Qd=Zd();function $d(){let e=Vu(e=>e.open),t=Qd(e=>e.stock!==void 0),n=Ad(e=>Dd(e.step));return{overlayOpen:e||t||n,dialogMenuOpen:e,dialogStockDetailOpen:t,dialogRemoveConfirmOpen:n}}var ef=B((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Q=B(((e,t)=>{t.exports=ef()}))();function $({bright:e=!1,color:t,...n}){let{overlayOpen:r}=$d(),i=Bu(),a=!e&&r;return(0,Q.jsx)(pl,{...n,color:t??i.foreground,dimColor:a})}function tf({title:e,bright:t=!1,top:n,left:r,right:i}){return(0,Q.jsxs)(fl,{position:`absolute`,top:n,left:r,right:i,children:[(0,Q.jsx)($,{bright:t,children:`|`}),e,(0,Q.jsx)($,{bright:t,children:`|`})]})}function nf(e){let{bright:t=!1,fullScreen:n,title:r,extra:i,footer:a,children:o}=e,{width:s,height:c,backgroundColor:l}=e,{columns:u,rows:d}=gu(),f=zu(e=>e.borderStyle),p=Bu();return(0,Q.jsxs)(fl,{flexDirection:`column`,width:n?u:s,height:n?d:c,borderStyle:f,borderColor:p.primary,borderDimColor:t===!1,children:[r?(0,Q.jsx)(tf,{title:r,bright:t,top:-1,left:1}):void 0,i?(0,Q.jsx)(tf,{title:i,bright:t,top:-1,right:1}):void 0,(0,Q.jsx)(fl,{flexGrow:1,flexDirection:`column`,padding:1,backgroundColor:l,children:o}),a]})}var rf=new Intl.DateTimeFormat(`en-CA`,{timeZone:`Asia/Shanghai`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function af(e,t){let n=rf.formatToParts(e),r=e=>n.find(t=>t.type===e)?.value??``,i=`${r(`year`)}-${r(`month`)}-${r(`day`)}`,a=`${r(`hour`)}:${r(`minute`)}`;switch(t){case`date-time`:return`${i} ${a}:${r(`second`)}`;case`date`:return i;case`time`:return`${a}:${r(`second`)}`;case`hour-minute`:return a}}var of={"date-time":1e3,date:6e4,time:1e3,"hour-minute":6e4};function sf(e){let[t,n]=(0,W.useState)(()=>new Date);return(0,W.useEffect)(()=>{let t=setInterval(()=>n(new Date),of[e]);return()=>clearInterval(t)},[e]),af(t,e)}function cf(e){let{hint:t,bright:n=!1}=e,r=sf(`date-time`),i=Bu();return(0,Q.jsxs)(fl,{justifyContent:`space-between`,paddingX:1,backgroundColor:n?i.accent:`gray`,children:[(0,Q.jsx)(fl,{flexShrink:0,children:t&&(0,Q.jsx)($,{bright:n,color:`white`,children:t})}),(0,Q.jsx)(fl,{flexShrink:0,children:(0,Q.jsx)($,{bright:n,color:`white`,children:r})})]})}function lf(e){let{title:t,extra:n,hint:r,width:i,children:a}=e,{rows:o,columns:s}=gu();return(0,Q.jsx)(fl,{position:`absolute`,top:0,left:0,width:s,height:o,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,children:(0,Q.jsx)(nf,{bright:!0,title:t,extra:n,width:i,backgroundColor:`black`,footer:(0,Q.jsx)(cf,{hint:r,bright:!0}),children:a})})}var uf=[{type:`theme`,label:`主题色系`,description:`界面配色`},{type:`trendColor`,label:`涨跌颜色`,description:`选择涨绿或跌绿`},{type:`border`,label:`卡片边框`,description:`边框样式`},{type:`numeric`,label:`请求超时`,description:`单次请求最长等待`,setting:`requestTimeoutMs`},{type:`numeric`,label:`请求最短耗时`,description:`避免加载闪烁`,setting:`minimumRequestDurationMs`},{type:`numeric`,label:`看板刷新间隔`,description:`自选股票看板自动刷新频率`,setting:`quotePollIntervalMs`},{type:`numeric`,label:`分时图刷新间隔`,description:`分时与五日图自动刷新频率`,setting:`minuteChartPollIntervalMs`},{type:`numeric`,label:`K 线刷新间隔`,description:`日/周/月/年 K 线自动刷新频率`,setting:`klinePollIntervalMs`}],df=(e,t,n)=>e[(e.indexOf(t)+n+e.length)%e.length]??t,ff=e=>e===0?`关闭`:e<1e3?`${e} ms`:e%6e4==0?`${e/6e4} 分钟`:e%1e3==0?`${e/1e3} 秒`:`${(e/1e3).toFixed(2)} 秒`;function pf(){let[e,t]=(0,W.useState)(0),{overlayOpen:n}=$d(),r=zu(),i=t=>{let n=uf[e];n&&(n.type===`theme`?r.updateSettings({themePreset:df(ju,r.themePreset,t)}):n.type===`trendColor`?r.updateSettings({trendColorMode:df(Du,r.trendColorMode,t)}):n.type===`border`?r.updateSettings({borderStyle:df(Eu,r.borderStyle,t)}):r.adjustNumericSetting(n.setting,t))};pu((e,n)=>{n.ctrl||(n.upArrow?t(e=>(e-1+uf.length)%uf.length):n.downArrow?t(e=>(e+1)%uf.length):n.leftArrow?i(-1):n.rightArrow||n.return?i(1):e===`d`&&r.resetSettings())},{isActive:!n});let a=uf.map((t,n)=>({label:t.label,description:t.description,selected:n===e,value:t.type===`theme`?Au[r.themePreset].label:t.type===`trendColor`?Ou[r.trendColorMode]:t.type===`border`?r.borderStyle:ff(r[t.setting])}));return{overlayOpen:n,appearanceRows:a.slice(0,3),requestRows:a.slice(3)}}function mf({rows:e,highlight:t}){return e.map(e=>(0,Q.jsxs)(fl,{justifyContent:`space-between`,children:[(0,Q.jsxs)($,{color:e.selected?`black`:void 0,backgroundColor:e.selected?t:void 0,children:[e.selected?`› `:` `,e.label,(0,Q.jsxs)($,{color:`gray`,backgroundColor:e.selected?t:void 0,children:[`(`,e.description,`)`]})]}),(0,Q.jsx)($,{color:e.selected?t:`gray`,children:e.value})]},e.label))}function hf({title:e,hint:t}){let n=Bu(),{overlayOpen:r,appearanceRows:i,requestRows:a}=pf();return(0,Q.jsxs)(nf,{fullScreen:!0,bright:!r,title:(0,Q.jsx)($,{color:n.primary,children:e}),footer:(0,Q.jsx)(cf,{hint:t,bright:!r}),children:[(0,Q.jsx)($,{color:n.primary,children:`外观`}),(0,Q.jsx)(mf,{rows:i,highlight:n.highlight}),(0,Q.jsxs)(fl,{marginTop:1,flexDirection:`column`,children:[(0,Q.jsx)($,{color:n.primary,children:`请求与刷新`}),(0,Q.jsx)(mf,{rows:a,highlight:n.highlight})]}),(0,Q.jsx)(fl,{marginTop:1,flexDirection:`column`,children:(0,Q.jsx)($,{color:`gray`,children:`请求最短耗时用于避免加载状态闪烁, 且不会超过请求超时.`})})]})}var gf=Tu()(e=>({screen:`stock-list`,goTo:t=>e({screen:t})})),_f={error:`red`,warning:`yellow`,success:`green`};function vf({tone:e,msg:t}){return(0,Q.jsx)($,{bold:!0,color:_f[e],children:t})}function yf({prompt:e,onSubmit:t,placeholder:n}){let{overlayOpen:r}=$d(),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(!1);return pu((e,n)=>{o||(n.return?(s(!0),t(i)):n.backspace||n.delete?a(e=>e.slice(0,-1)):!n.ctrl&&!n.meta&&e&&a(t=>t+e))},{isActive:!r&&!o}),(0,Q.jsx)(fl,{children:(0,Q.jsxs)($,{children:[e,o?(0,Q.jsx)($,{color:`green`,children:i}):(0,Q.jsxs)($,{children:[i,(0,Q.jsx)($,{color:`gray`,children:`█`}),!i&&n?n:void 0]})]})})}function bf({tone:e,msg:t,to:n,onReturn:r}){let i=gf(e=>e.goTo);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vf,{tone:e,msg:t}),(0,Q.jsx)(Kl,{}),(0,Q.jsx)(yf,{prompt:`按 Enter 返回操作页...`,onSubmit:()=>{r?.(),i(n)}})]})}var xf=e=>e>0?e.toFixed(2):`--`,Sf=e=>`${e>0?`+`:``}${e.toFixed(2)}`,Cf=e=>`${e>0?`+`:``}${e.toFixed(2)}%`,wf=(e,t=ku)=>e===0?`gray`:e>0==(t===`green-up`)?`green`:`red`,Tf=e=>e>=1e4?`${(e/1e4).toFixed(1)}万手`:e>0?`${Math.round(e)}手`:`--`,Ef=e=>e>=1e4?`${(e/1e4).toFixed(2)}亿`:e>0?`${e.toFixed(1)}万`:`--`,Df=e=>e>0?`${e.toFixed(2)}%`:`--`,Of=e=>e>0?e.toFixed(2):`--`,kf=e=>e>0?`${e.toFixed(2)}亿`:`--`;function Af(e){let t=e.trim();if(t===`y`||t===`Y`)return`y`;if(t===`n`||t===`N`)return`n`}var jf=`错误: 必须选择 y (是) 或 n (否).`,Mf=e=>e.type===`input-code`,Nf=e=>e.type===`confirm`,Pf=e=>e.type===`already-exists`||e.type===`done`||e.type===`error`,Ff={stocksAdd:xd,fetchQuotes:Hd,normalizeCode:Vd,now:()=>new Date().toISOString()},If={error:void 0,resetToken:0},Lf=`无法识别股票代码, 请用英文逗号分隔 6 位股票代码.`;function Rf(e=Ff){let t=0,n=e=>e!==t;return Tu()((r,i)=>{let a=()=>r(e=>({codeInput:{error:Lf,resetToken:e.codeInput.resetToken+1}}));return{step:{type:`input-code`},codeInput:If,confirmInput:If,reset:()=>{t+=1,r({step:{type:`input-code`},codeInput:If,confirmInput:If})},handleCodeInput:async o=>{if(!Mf(i().step))return;let s=t,c=o.split(`,`).map(e=>e.trim());if(c.length===0||c.some(e=>e===``)){a();return}let l=c.map(t=>e.normalizeCode(t));if(l.some(e=>e===void 0)){a();return}let u=[...new Set(l)];r(e=>({codeInput:{error:void 0,resetToken:e.codeInput.resetToken+1}})),r({step:{type:`checking`,codes:u}});try{let t=await e.fetchQuotes(u);if(n(s))return;let i=new Map(t.map(e=>[e.code,e])),a=u.filter(e=>!i.has(e));if(a.length>0){r({step:{type:`error`,message:`未找到股票代码: ${a.join(`, `)}.`}});return}r({step:{type:`confirm`,entries:u.map(e=>{let t=i.get(e);return{code:e,name:t.name,current:t.current}})}})}catch(e){n(s)||r({step:{type:`error`,message:Hu(e)}})}},handleConfirm:async a=>{let o=Af(a);if(!o){r(e=>({confirmInput:{error:jf,resetToken:e.confirmInput.resetToken+1}}));return}if(r(e=>({confirmInput:{error:void 0,resetToken:e.confirmInput.resetToken+1}})),o===`n`){r({step:{type:`done`,message:`已取消.`}});return}let s=t,c=i().step;if(Nf(c)){r({step:{type:`saving`,entries:c.entries}});try{let t=e.now(),i=await e.stocksAdd(c.entries.map(e=>({code:e.code,name:e.name,addedAt:t})));if(n(s))return;if(i===0){r({step:{type:`already-exists`,entries:c.entries}});return}r({step:{type:`done`,message:`已添加 ${i} 个股票, ${c.entries.length-i} 个已在自选股中.`}})}catch(e){n(s)||r({step:{type:`error`,message:`写入自选股失败: ${Hu(e)}`}})}}}}})}var zf=Rf();function Bf(){let e=zf(e=>e.step),t=zf(e=>e.codeInput),n=zf(e=>e.confirmInput),r=zf(e=>e.handleCodeInput),i=zf(e=>e.handleConfirm),a=zf(e=>e.reset);return(0,W.useEffect)(()=>{a()},[a]),{step:e,codeInput:t,confirmInput:n,handleCodeInput:r,handleConfirm:i,reset:a}}function Vf({title:e,hint:t}){let{overlayOpen:n}=$d(),r=Bu(),{step:i,codeInput:a,confirmInput:o,handleCodeInput:s,handleConfirm:c,reset:l}=Bf(),u;if(Pf(i))u=(0,Q.jsx)(bf,{tone:i.type===`already-exists`?`warning`:i.type===`done`?`success`:`error`,msg:i.type===`already-exists`?`${i.entries.map(e=>`${e.name} (${e.code})`).join(`, `)} 已在自选股中.`:i.message,to:`stock-add`,onReturn:l});else switch(i.type){case`input-code`:u=(0,Q.jsxs)(Q.Fragment,{children:[a.error&&(0,Q.jsx)($,{color:`red`,children:a.error}),(0,Q.jsx)(yf,{prompt:`请输入股票代码, 用英文逗号分隔: `,placeholder:(0,Q.jsx)($,{color:`gray`,children:`支持 600000, sh600000, 600000.SH 等写法`}),onSubmit:s},`code-${a.resetToken}`)]});break;case`checking`:u=(0,Q.jsxs)($,{color:`cyan`,children:[`正在验证股票代码: `,i.codes.join(`, `),`...`]});break;case`confirm`:u=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{color:`cyan`,children:`找到以下股票:`}),i.entries.map(e=>(0,Q.jsxs)($,{children:[e.name,` (`,e.code,`), 现价 `,xf(e.current)]},e.code)),o.error&&(0,Q.jsx)($,{color:`red`,children:o.error}),(0,Q.jsx)(yf,{prompt:`确认添加到自选股? (y/n): `,onSubmit:c},`confirm-${o.resetToken}`)]});break;case`saving`:u=(0,Q.jsxs)($,{color:`cyan`,children:[`正在添加 `,i.entries.length,` 个股票...`]})}return(0,Q.jsx)(nf,{fullScreen:!0,bright:!n,title:(0,Q.jsx)($,{color:r.primary,children:e}),footer:(0,Q.jsx)(cf,{hint:t,bright:!n}),children:u})}function Hf(e){let{segments:t,selected:n,bright:r=!1}=e;return(0,Q.jsx)($,{bright:r,inverse:n,children:t.map((e,t)=>(0,Q.jsx)($,{bright:r,color:e.color,children:e.text},t))})}var Uf=(e,t)=>e+` `.repeat(Math.max(0,t.width-Mt(e))),Wf=e=>e.map((t,n)=>({...t,text:n<e.length-1?`${t.text} `:t.text})),Gf=new Map([{key:`code`,kind:`code`,title:`代码`,width:9,render:e=>e.code},{key:`name`,kind:`name`,title:`名称`,width:9,render:e=>e.name},{key:`current`,kind:`value`,title:`现价`,width:8,render:e=>xf(e.current),color:(e,t)=>wf(e.change,t)},{key:`changePercent`,kind:`changePercent`,title:`涨跌幅`,width:9,render:e=>Cf(e.changePercent),color:(e,t)=>wf(e.changePercent,t),suspendedText:`停牌`},{key:`change`,kind:`value`,title:`涨跌额`,width:8,render:e=>Sf(e.change),color:(e,t)=>wf(e.change,t)},{key:`open`,kind:`value`,title:`今开`,width:7,render:e=>xf(e.open)},{key:`prevClose`,kind:`value`,title:`昨收`,width:7,render:e=>xf(e.prevClose)},{key:`high`,kind:`value`,title:`最高`,width:7,render:e=>xf(e.high)},{key:`low`,kind:`value`,title:`最低`,width:7,render:e=>xf(e.low)},{key:`volume`,kind:`value`,title:`成交量`,width:11,render:e=>Tf(e.volume)},{key:`turnover`,kind:`value`,title:`成交额`,width:9,render:e=>Ef(e.turnover)},{key:`turnoverRate`,kind:`value`,title:`换手率`,width:7,render:e=>Df(e.turnoverRate)},{key:`amplitude`,kind:`value`,title:`振幅`,width:7,render:e=>Df(e.amplitude)},{key:`volumeRatio`,kind:`value`,title:`量比`,width:7,render:e=>Of(e.volumeRatio)},{key:`marketCap`,kind:`value`,title:`总市值`,width:10,render:e=>kf(e.marketCap)}].map(e=>[e.key,e])),Kf=e=>Wf(e.map(e=>({text:Uf(e.title,e),color:`gray`}))),qf=(e,t,n=ku)=>{let r=t.current<=0;return Wf(e.map(e=>({text:Uf(r?e.suspendedText??`--`:e.render(t),e),color:r||!e.color?`gray`:e.color(t,n)})))},Jf=(e,t,n)=>Wf(e.map(e=>({text:Uf(e.kind===`code`?t:e.kind===`name`?n:e.kind===`changePercent`?`无数据`:`--`,e),color:`gray`}))),Yf=[`name`,`code`,`current`,`changePercent`,`change`,`open`,`high`,`low`,`volume`,`turnover`,`turnoverRate`,`marketCap`],Xf=[`open`,`prevClose`,`high`,`low`,`volume`,`turnover`,`turnoverRate`,`amplitude`,`volumeRatio`,`marketCap`],Zf=Yf.reduce((e,t)=>{let n=Gf.get(t);return n&&e.push(n),e},[]),Qf=Xf.reduce((e,t)=>{let n=Gf.get(t);return n&&e.push(n),e},[]),$f=()=>Zf.reduce((e,t)=>e+t.width,0)+(Zf.length-1),ep=()=>Qf.reduce((e,t)=>e+t.width,0)+(Qf.length-1);function tp(e,{enabled:t=!0,intervalMs:n,restartKey:r,onError:i}){let a=(0,W.useRef)(e),o=(0,W.useRef)(n),s=(0,W.useRef)(i),c=(0,W.useRef)({});(0,W.useEffect)(()=>{a.current=e,o.current=n,s.current=i},[e,n,i]);let l=(0,W.useCallback)(()=>c.current.refresh?.(),[]);return(0,W.useEffect)(()=>{if(!t){c.current={};return}let e=!0,n=!1,r,i,l=()=>{r&&=(clearTimeout(r),void 0)},u=(t=o.current)=>{!e||n||r||(r=setTimeout(()=>{r=void 0,f()},t))},d=async()=>{if(!e||n)return;let t=Date.now();n=!0,i=new AbortController;let r=i;try{await a.current(r.signal)}catch(e){r.signal.aborted||s.current?.(e)}finally{i===r&&(i=void 0),n=!1,u(Math.max(0,o.current-(Date.now()-t)))}},f=()=>void d();return c.current={refresh:()=>{n||(l(),f())},reschedule:()=>{n||(l(),u())}},f(),()=>{e=!1,c.current={},l(),i?.abort()}},[t,r]),(0,W.useEffect)(()=>{c.current.reschedule?.()},[n]),{refresh:l}}var np={fetchQuotes:Hd,loadStocks:bd},rp=(e,t)=>Math.min(Math.max(e,0),t-1),ip=(e,t,n,r,i)=>{let a=rp(t+e,n),o=Math.max(0,n-i);return e===1&&a>=r+i?Math.min(a-i+1,o):e===-1&&a<r?a:Math.min(r,o)},ap=(e,t)=>{if(!t)return 0;let n=e.findIndex(e=>e.code===t);return n<0?0:n},op=(e,t)=>e.code===t.code&&e.name===t.name&&e.current===t.current&&e.prevClose===t.prevClose&&e.open===t.open&&e.high===t.high&&e.low===t.low&&e.change===t.change&&e.changePercent===t.changePercent&&e.timestamp===t.timestamp&&e.volume===t.volume&&e.turnover===t.turnover&&e.turnoverRate===t.turnoverRate&&e.amplitude===t.amplitude&&e.marketCap===t.marketCap&&e.volumeRatio===t.volumeRatio;function sp(e=np){return Tu()((t,n)=>({step:{type:`loading`},selectedCode:void 0,scrollOffset:0,refreshQuotes:async n=>{try{let r=await e.loadStocks();if(n?.aborted)return;if(r.length===0){t({step:{type:`empty`},selectedCode:void 0,scrollOffset:0});return}let i=await e.fetchQuotes(r.map(e=>e.code),n);if(n?.aborted)return;t(e=>{let t=e.step.type===`table`?e.step.rows:[],n=new Map(t.filter(e=>e.kind===`quote`).map(e=>[e.code,e.quote])),a=new Map(i.map(e=>{let t=n.get(e.code);return[e.code,t&&op(t,e)?t:e]})),o=r.map(e=>{let t=a.get(e.code);return t?{kind:`quote`,code:e.code,name:t.name,quote:t}:{kind:`missing`,code:e.code,name:e.name}}),s=ap(t,e.selectedCode),c=e.selectedCode?o.findIndex(t=>t.code===e.selectedCode):-1,l=c>=0?c:rp(s,o.length),u=Math.max(0,s-e.scrollOffset);return{step:{type:`table`,rows:o},selectedCode:o[l]?.code,scrollOffset:Math.max(0,l-u)}})}catch(e){if(n?.aborted)return;let r=Hu(e);t(e=>e.step.type===`table`?{step:{...e.step,errorLine:r}}:{step:{type:`error`,message:r}})}},moveSelection:(e,r)=>{let{step:i,selectedCode:a,scrollOffset:o}=n();if(i.type!==`table`||i.rows.length===0)return;let s=ap(i.rows,a),c=rp(s+e,i.rows.length);t({selectedCode:i.rows[c]?.code,scrollOffset:ip(e,s,i.rows.length,o,r)})}}))}var cp=sp(),lp=(e,t,n)=>{if(e<=n)return{start:0,end:e};let r=e-n,i=Math.min(Math.max(t,0),r);return{start:i,end:i+n}};function up(){let e=(0,W.useRef)(null),t=yu(e),n=cp(e=>e.step),r=cp(e=>e.selectedCode),i=cp(e=>e.scrollOffset),a=zu(e=>e.quotePollIntervalMs),o=cp(e=>e.moveSelection),{overlayOpen:s}=$d(),c=t.hasMeasured?Math.max(1,Math.floor(t.height)):1,l=n.type===`table`?lp(n.rows.length,i,c):{start:0,end:0};(0,W.useEffect)(()=>{cp.setState({step:{type:`loading`}})},[]);let{refresh:u}=tp(e=>cp.getState().refreshQuotes(e),{intervalMs:a});return pu((e,t)=>{if(!t.ctrl){if(t.upArrow)o(-1,c);else if(t.downArrow)o(1,c);else if(t.return){let e=cp.getState();if(e.step.type!==`table`||!e.selectedCode)return;let t=e.step.rows.find(t=>t.code===e.selectedCode);t&&Qd.getState().open(t.code,t.name)}else e===`r`&&u()}},{isActive:!s}),{rowsRef:e,step:n,selectedCode:r,window:l}}function dp({title:e,hint:t}){let{overlayOpen:n}=$d(),r=Bu(),i=zu(e=>e.trendColorMode),{rowsRef:a,step:o,selectedCode:s,window:c}=up(),l;switch(o.type){case`loading`:l=(0,Q.jsx)($,{color:`cyan`,children:`正在获取行情数据...`});break;case`empty`:l=(0,Q.jsx)($,{color:`yellow`,children:`自选股为空, 按 esc 打开菜单添加自选股.`});break;case`error`:l=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{color:`red`,children:o.message}),(0,Q.jsx)($,{color:`gray`,children:`行情接口异常, 稍后自动重试`})]});break;case`table`:l=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Hf,{segments:Kf(Zf)}),(0,Q.jsx)(fl,{ref:a,flexDirection:`column`,flexGrow:1,overflow:`hidden`,children:o.rows.slice(c.start,c.end).map(e=>(0,Q.jsx)(Hf,{segments:e.kind===`quote`?qf(Zf,e.quote,i):Jf(Zf,e.code,e.name),selected:e.code===s},e.code))}),o.errorLine?(0,Q.jsxs)($,{color:`yellow`,children:[`刷新失败: `,o.errorLine,`, 稍后自动重试`]}):void 0]})}return(0,Q.jsx)(nf,{fullScreen:!0,bright:!n,title:(0,Q.jsx)($,{color:r.primary,children:e}),footer:(0,Q.jsx)(cf,{hint:t,bright:!n}),children:l})}function fp(e){return(0,Q.jsx)(fl,{flexGrow:1,flexBasis:0,minWidth:0,...e})}function pp({label:e,hint:t,selected:n,cursor:r}){let i=Bu();return(0,Q.jsx)(fp,{children:(0,Q.jsxs)($,{inverse:r,wrap:`truncate-end`,children:[(0,Q.jsxs)($,{color:n?i.primary:void 0,children:[n?`[x] `:`[ ] `,e]}),t?(0,Q.jsxs)($,{color:`gray`,children:[` (`,t,`)`]}):void 0]})})}function mp(e,t=3){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function hp(e,t,n){if(t<=0)return 0;let r=Math.min(Math.max(e,0),t-1),i=r%3;return n===`left`?i>0?r-1:r:n===`right`?i<2&&r+1<t?r+1:r:n===`up`?r-3>=0?r-3:r:r+3<t?r+3:r}function gp(e,t,n,r){let i=Math.max(0,t-r),a=Math.floor(Math.max(e,0)/3),o=Math.min(Math.max(n,0),i);return a<o?o=a:a>=o+r&&(o=a-r+1),Math.min(Math.max(o,0),i)}function _p(e,t,n){if(e<=n)return{start:0,end:e};let r=e-n,i=Math.min(Math.max(t,0),r);return{start:i,end:i+n}}function vp({items:e,getKey:t,isActive:n,onSubmit:r}){let i=(0,W.useRef)(null),a=yu(i),[o,s]=(0,W.useState)(0),[c,l]=(0,W.useState)(0),[u,d]=(0,W.useState)(()=>new Set),f=e.length,p=a.hasMeasured?Math.max(1,Math.floor(a.height)):1,m=Math.ceil(f/3),h=_p(m,c,p);return pu((n,i)=>{if(!i.ctrl){if(i.leftArrow||i.rightArrow||i.upArrow||i.downArrow){let e=i.leftArrow?`left`:i.rightArrow?`right`:i.upArrow?`up`:`down`,t=hp(o,f,e);s(t),l(gp(t,m,c,Math.max(1,p)))}else if(n===` `){let n=e[o];if(!n)return;let r=t(n);d(e=>{let t=new Set(e);return t.has(r)?t.delete(r):t.add(r),t})}else if(i.return){let n=e.filter(e=>u.has(t(e)));n.length>0&&r(n)}}},{isActive:n}),{gridRef:i,cursor:o,selectedKeys:u,visibleRange:h}}function yp(e){let{items:t,getKey:n,getLabel:r,getHint:i,isActive:a,onSubmit:o}=e,{gridRef:s,cursor:c,selectedKeys:l,visibleRange:u}=vp({items:t,getKey:n,isActive:a,onSubmit:o}),d=mp(t);return(0,Q.jsx)(fl,{ref:s,flexDirection:`column`,flexGrow:1,overflow:`hidden`,children:d.slice(u.start,u.end).map((e,t)=>{let o=u.start+t;return(0,Q.jsx)(fl,{columnGap:2,children:Array.from({length:3},(t,s)=>{let u=e[s];if(!u)return(0,Q.jsx)(fp,{},`empty-${s}`);let d=o*3+s,f=n(u);return(0,Q.jsx)(pp,{label:r(u),hint:i?.(u),selected:l.has(f),cursor:a&&d===c},f)})},o)})})}function bp(){let e=Td(e=>e.entries),t=Td(e=>e.errorMessage),n=Td(e=>e.resetToken),r=Td(e=>e.loadEntries),i=Ad(e=>e.open);return(0,W.useEffect)(()=>{r()},[r]),{entries:e,errorMessage:t,resetToken:n,open:i}}function xp({title:e,hint:t}){let{overlayOpen:n}=$d(),r=Bu(),{entries:i,errorMessage:a,resetToken:o,open:s}=bp(),c;return c=i.length===0?a?(0,Q.jsx)($,{color:`red`,children:a}):(0,Q.jsx)($,{color:`yellow`,children:`自选股为空, 按 esc 打开菜单添加自选股.`}):(0,Q.jsx)(yp,{items:i,getKey:e=>e.code,getLabel:e=>e.name,getHint:e=>e.code,isActive:!n,onSubmit:s},o),(0,Q.jsx)(nf,{fullScreen:!0,bright:!n,title:(0,Q.jsx)($,{color:r.primary,children:e}),footer:(0,Q.jsx)(cf,{hint:t,bright:!n}),children:c})}var Sp={"stock-list":{Component:dp,title:`自选股票看板`,description:`自选股票看板`,hint:`菜单(esc) 刷新(r) 选择(↑/↓) 详情(enter) 退出(q)`,menuLabel:`自选股票看板`},"stock-add":{Component:Vf,title:`添加自选股`,description:`添加自选股`,hint:`菜单(esc) 退出(q)`,menuLabel:`添加自选股`},"stock-remove":{Component:xp,title:`删除自选股`,description:`删除自选股`,hint:`菜单(esc) 移动(↑/↓/←/→) 选择(空格) 删除(enter) 退出(q)`,menuLabel:`删除自选股`},settings:{Component:hf,title:`设置`,description:`配置主题, 涨跌颜色与请求参数`,hint:`菜单(esc) 选择(↑/↓) 调整(←/→/enter) 默认值(d) 退出(q)`,menuLabel:`设置`}},Cp=Object.keys(Sp),wp=e=>e!==void 0&&Object.hasOwn(Sp,e),Tp=e=>wp(e)?e:`stock-list`,Ep=[...Object.entries(Sp).map(([e,t],n)=>({label:`${n+1}) ${t.menuLabel}`,screen:e})),{label:`${Object.keys(Sp).length+1}) 退出程序`,screen:void 0}],Dp=45;function Op(){let e=gf(e=>e.goTo),t=Vu(e=>e.close),{exit:n}=mu(),[r,i]=(0,W.useState)(0),a=r=>{r.screen?(t(),e(r.screen)):n()};return pu((e,t)=>{if(t.upArrow)i(e=>(e+Ep.length-1)%Ep.length);else if(t.downArrow)i(e=>(e+1)%Ep.length);else if(t.return)a(Ep[r]);else if(/^[1-9]$/.test(e)){let t=Number(e)-1,n=Ep[t];if(!n)return;i(t),a(n)}}),{width:Dp,menuItems:Ep,highlight:r}}function kp(){let{highlight:e,width:t,menuItems:n}=Op(),r=Bu();return(0,Q.jsx)(lf,{title:(0,Q.jsx)($,{bright:!0,color:r.primary,children:`菜单`}),width:t,children:n.map((t,n)=>(0,Q.jsxs)($,{bright:!0,color:n===e?`black`:void 0,backgroundColor:n===e?r.highlight:void 0,children:[n===e?`> `:` `,t.label]},t.label))})}function Ap(){let e=Ad(e=>e.step),t=Ad(e=>e.targets);if(pu((e,t)=>{if(t.ctrl)return;let n=Ad.getState();e===`y`||e===`Y`?n.confirmDelete():(e===`n`||e===`N`)&&n.cancel()},{isActive:Ed(e)}),Dd(e))return{stage:e.type,entries:t,message:e.type===`done`||e.type===`error`?e.message:void 0}}var jp=`取消(esc/n) 确定(y)`,Mp=`关闭(esc)`,Np=60,Pp=22;function Fp(){let e=Bu(),{columns:t}=gu(),n=Ap();if(!n)return;let{stage:r,entries:i,message:a}=n,o=i.length,s=r===`error`,c=r===`done`,l=s?`删除失败`:c?`删除完成`:r===`removing`?`正在删除 ${o} 个股票...`:`确定删除选中的 ${o} 个股票?`,u=s||c?a:i.map(e=>`${e.name} (${e.code})`).join(`, `),d=r===`confirm`?jp:s||c?Mp:void 0,f=Math.max(Mt(l),Math.min(Mt(u??``),Np),Mt(d??``)+Pp,24),p=Math.min(Math.max(t-2,1),f+4+6);return(0,Q.jsx)(lf,{title:(0,Q.jsx)($,{bright:!0,color:s?`red`:e.primary,children:l}),hint:d,width:p,children:(0,Q.jsx)($,{bright:!0,color:s?`red`:c?e.primary:`gray`,children:u})})}var Ip=e=>{if(!/^\d{4}$/.test(e))return;let t=Number(e.slice(0,2))*60+Number(e.slice(2))-570;return t<0?0:t>120?t-90:t},Lp=(e,t)=>{if(t<=0)return[];let n=Array.from({length:t},()=>({sum:0,count:0,minPrice:0,maxPrice:0,lastPrice:0,volume:0})),r=-1,i=0;for(let a of e){let e=Ip(a.time);if(e===void 0)continue;let o=Math.min(t-1,Math.floor(e/240*t)),s=n[o];s.sum+=a.price,s.count+=1,s.minPrice=s.count===1?a.price:Math.min(s.minPrice,a.price),s.maxPrice=s.count===1?a.price:Math.max(s.maxPrice,a.price),s.lastPrice=a.price,s.volume+=Math.max(0,a.volume-i),i=a.volume,r=Math.max(r,o)}let a=[],o=0;for(let e=0;e<t;e++){let t=n[e];t.count>0?(o=t.lastPrice,a.push({avgPrice:t.sum/t.count,maxPrice:t.maxPrice,minPrice:t.minPrice,lastPrice:t.lastPrice,volume:t.volume})):e<r?a.push({avgPrice:o,maxPrice:o,minPrice:o,lastPrice:o,volume:0}):a.push({avgPrice:0,maxPrice:0,minPrice:0,lastPrice:0,volume:0})}return a},Rp=e=>`date`in e,zp=e=>`sessionDate`in e,Bp=e=>!Rp(e)&&!zp(e),Vp=(e,t)=>{let n=new Map;for(let t of e){let e=n.get(t.sessionDate)??[];e.push(t),n.set(t.sessionDate,e)}let r=[...n.entries()].sort(([e],[t])=>e.localeCompare(t));if(r.length===0)return Array.from({length:t},()=>({avgPrice:0,maxPrice:0,minPrice:0,lastPrice:0,volume:0}));let i=[];for(let e=0;e<r.length;e++){let n=Math.floor(e/r.length*t),a=Math.floor((e+1)/r.length*t)-n;if(a<=0)continue;let o=r[e][1].sort((e,t)=>e.time.localeCompare(t.time));i.push(...Lp(o,a))}return i},Hp=(e,t)=>e.length===0?Array.from({length:t},()=>({avgPrice:0,maxPrice:0,minPrice:0,lastPrice:0,volume:0})):Array.from({length:t},(n,r)=>{let i=t<=1?0:r/(t-1)*(e.length-1),a=e[Math.floor(i)],o=e[Math.min(Math.ceil(i),e.length-1)],s=i-Math.floor(i),c=a.close+(o.close-a.close)*s,l=e[Math.round(i)];return{avgPrice:c,maxPrice:Math.max(a.high,o.high),minPrice:Math.min(a.low,o.low),lastPrice:c,volume:l.volume}}),Up=(e,t)=>t<3?1<<t+e*3:1<<6+e,Wp=e=>String.fromCharCode(10240+e),Gp=e=>{let{points:t,period:n,prevClose:r,width:i,priceHeight:a,volumeHeight:o,trendColorMode:s=ku}=e,c=t.filter(Bp),l=t.filter(zp),u=t.filter(Rp),d=n===`intraday`,f=n===`five-day`,p=d?Lp(c,i):f?Vp(l,i):Hp(u,i),m=d?r:f?l[0]?.prevClose:u[0]?.close,h=d?r:void 0,g=1/0,_=-1/0;for(let e of p)e.avgPrice<=0||(g=Math.min(g,e.minPrice),_=Math.max(_,e.maxPrice));h!==void 0&&(g=Math.min(g,h),_=Math.max(_,h)),Number.isFinite(g)||(g=0,_=1),_===g&&(_+=1);let v=a*4,y=i*2,b=e=>Math.round((_-e)/(_-g)*(v-1)),x=(e,t)=>t===void 0?`gray`:wf(e-t,s),S=x(p.map(e=>e.lastPrice).filter(e=>e>0).at(-1)??0,m),C=p.map((e,t)=>{if(d)return S;if(e.lastPrice<=0)return`gray`;let n=p[t+1]?.lastPrice;if(n!==void 0&&n>0)return x(n,e.lastPrice);let r=p[t-1]?.lastPrice;return x(e.lastPrice,r!==void 0&&r>0?r:void 0)}),w=Array.from({length:a+o+1},()=>Array.from({length:i},()=>({ch:` `,color:void 0}))),T=Array.from({length:a},()=>new Uint16Array(i)),E=-1;for(let e=0;e<i;e++)p[e].avgPrice>0&&(E=e);let D;for(let e=0;e<y;e++){let t=e/2;if(t>E){D=void 0;continue}let n=p[Math.floor(t)];if(n.avgPrice<=0){D=void 0;continue}let r=p[Math.min(Math.floor(t)+1,i-1)],a=b(r.avgPrice>0?n.lastPrice+(r.lastPrice-n.lastPrice)*(t-Math.floor(t)):n.lastPrice),o=Math.floor(e/2),s=T[Math.floor(a/4)];if(s[o]=s[o]|Up(e%2,a%4),D!==void 0){let t=Math.min(D,a),n=Math.max(D,a);for(let r=t+1;r<n;r++){let t=T[Math.floor(r/4)];t[o]=t[o]|Up(e%2,r%4)}}D=a}let O=Array.from({length:a},()=>new Uint16Array(i));if(h!==void 0){let e=b(h),t=Math.floor(e/4);for(let n=0;n<y;n++){if(n%3==2)continue;let r=Math.floor(n/2);if(T[t][r]!==0)continue;let i=O[t];i[r]=i[r]|Up(n%2,e%4)}}for(let e=0;e<a;e++)for(let t=0;t<i;t++){let n=T[e][t]|O[e][t];n!==0&&(w[e][t]={ch:Wp(n),color:T[e][t]===0?`gray`:C[t]})}let k=Array.from({length:o},()=>new Uint16Array(i)),A=Math.max(...p.map(e=>e.volume),0);for(let e=0;e<i;e++){let t=p[e];if(t.volume<=0||A<=0)continue;let n=o*4,r=Math.max(1,Math.round(t.volume/A*n));for(let t=n-r;t<n;t++){let n=k[Math.floor(t/4)];n[e]=n[e]|Up(0,t%4)|Up(1,t%4)}}let j=Array.from({length:i},()=>void 0),M=m;for(let e=0;e<i;e++){let t=p[e];t.lastPrice<=0||(j[e]=M===void 0?`gray`:wf(t.lastPrice-M,s),M=t.lastPrice)}for(let e=0;e<o;e++)for(let t=0;t<i;t++){let n=k[e][t];n!==0&&(w[a+e][t]={ch:Wp(n),color:j[t]})}let N=[],P=(e,t)=>Math.max(0,Math.min(i-t.length,e-Math.floor(t.length/2)));if(d)N.push({col:0,labelCol:0,label:`09:30`},{col:Math.floor(i/2),labelCol:Math.max(0,Math.floor((i-11)/2)),label:`11:30/13:00`},{col:i-1,labelCol:Math.max(0,i-5),label:`15:00`});else if(f&&l.length>0){let e=[...new Set(l.map(e=>e.sessionDate))].sort();for(let t=0;t<e.length;t++){let n=Math.min(i-1,Math.floor((t+.5)/e.length*i)),r=e[t].slice(5);N.push({col:n,labelCol:P(n,r),label:r})}}else if(u.length>0){let e=e=>n===`year`?e.date.slice(0,4):n===`month`?e.date.slice(0,7):n===`week`?e.date.slice(2):e.date.slice(5),t=e(u[0]),r=e(u[Math.floor((u.length-1)/2)]),a=e(u.at(-1));N.push({col:0,labelCol:0,label:t},{col:Math.floor(i/2),labelCol:Math.max(0,Math.floor((i-r.length)/2)),label:r},{col:i-1,labelCol:Math.max(0,i-a.length),label:a})}for(let{col:e}of N)for(let t=0;t<a+o;t++)w[t][e].ch===` `&&(w[t][e]={ch:`┊`,color:`gray`});let F=w[a+o],I=(e,t)=>{for(let n=0;n<t.length&&e+n<i;n++)F[e+n]={ch:t[n],color:`gray`}};for(let e of N)I(e.labelCol,e.label);return w},Kp=9,qp=4;function Jp({points:e,period:t,prevClose:n,width:r,priceHeight:i=Kp,volumeHeight:a=qp,bright:o=!1,trendColorMode:s}){let c=Gp({points:e,period:t,prevClose:n,width:r,priceHeight:i,volumeHeight:a,trendColorMode:s});return(0,Q.jsx)(fl,{flexDirection:`column`,children:c.map((e,t)=>{let n=[];for(let t of e){let e=n.at(-1);e&&e.color===t.color?e.text+=t.ch:n.push({text:t.ch,color:t.color})}return(0,Q.jsx)($,{bright:o,children:n.map((e,t)=>(0,Q.jsx)($,{bright:o,color:e.color,children:e.text},t))},t)})})}var Yp=new Map([[`sh`,`沪`],[`sz`,`深`],[`bj`,`北`]]);function Xp({code:e,bright:t=!1}){let n=e.slice(0,2).toLowerCase(),r=Yp.get(n);if(r)return(0,Q.jsx)($,{bright:t,color:`white`,backgroundColor:`red`,children:r})}var Zp=[{key:`1`,value:`intraday`,label:`分时`},{key:`2`,value:`five-day`,label:`五日`},{key:`3`,value:`day`,label:`日K`},{key:`4`,value:`week`,label:`周K`},{key:`5`,value:`month`,label:`月K`},{key:`6`,value:`year`,label:`年K`}];function Qp(){let e=Qd(e=>e.stock),t=Qd(e=>e.period),n=Qd(e=>e.status),r=Qd(e=>e.points),i=Qd(e=>e.errorMessage),a=zu(e=>e.minuteChartPollIntervalMs),o=zu(e=>e.klinePollIntervalMs),s=Vu(e=>e.open),c=cp(t=>{if(t.step.type!==`table`)return;let n=t.step.rows.find(t=>t.code===e?.code);return n?.kind===`quote`?n.quote:void 0});if(pu((e,t)=>{if(t.ctrl)return;let n=Zp.find(t=>t.key===e);n&&Qd.getState().setPeriod(n.value)},{isActive:e!==void 0&&!s}),tp(async n=>{e&&await Qd.getState().refreshChart(e.code,t,n)},{enabled:e!==void 0,intervalMs:t===`intraday`||t===`five-day`?a:o,restartKey:e?`${e.code}:${t}`:void 0}),e)return{stock:e,quote:c,suspended:c?c.current<=0:!1,period:t,status:n,points:r,errorMessage:i}}var $p=ep()+4+6,em=$p-4;function tm(){let e=zu(e=>e.trendColorMode),t=Qp();if(!t)return;let{stock:n,quote:r,suspended:i,period:a,status:o,points:s,errorMessage:c}=t,l=Zp.find(e=>e.value===a)?.label??``;return(0,Q.jsxs)(lf,{title:(0,Q.jsxs)($,{bright:!0,children:[(0,Q.jsx)(Xp,{code:n.code,bright:!0}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{bright:!0,children:n.name}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{bright:!0,color:`gray`,children:n.code}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{bright:!0,color:!r||i?`gray`:wf(r.change,e),children:r?xf(r.current):`--`}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{bright:!0,color:!r||i?`gray`:wf(r.changePercent,e),children:r?i?`停牌`:Cf(r.changePercent):`--`}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{bright:!0,color:!r||i?`gray`:wf(r.change,e),children:r?Sf(r.change):`--`})]}),extra:(0,Q.jsx)($,{bright:!0,children:Zp.map((e,t)=>(0,Q.jsxs)($,{bright:!0,color:e.value===a?`cyan`:`gray`,children:[t>0?` `:``,`[`,e.key,`]`,e.label]},e.value))}),width:$p,children:[(0,Q.jsxs)(fl,{flexDirection:`column`,children:[(0,Q.jsx)(Hf,{bright:!0,segments:Kf(Qf)}),(0,Q.jsx)(Hf,{bright:!0,segments:r?qf(Qf,r,e):Jf(Qf,n.code,n.name)})]}),(0,Q.jsx)(fl,{marginTop:1,height:14,children:o===`loading`?(0,Q.jsxs)($,{bright:!0,color:`gray`,children:[`正在获取`,l,`行情...`]}):o===`error`?(0,Q.jsx)($,{bright:!0,color:`red`,children:c}):s.length===0?(0,Q.jsxs)($,{bright:!0,color:`gray`,children:[`暂无`,l,`行情数据`]}):(0,Q.jsx)(Jp,{bright:!0,points:s,period:a,prevClose:r?.prevClose,trendColorMode:e,width:em})})]})}var nm=$f()+4;function rm({children:e}){let{columns:t,rows:n}=gu(),r=t>=nm,i=n>=26;return r&&i?e:(0,Q.jsxs)(fl,{width:t,height:n,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,children:[(0,Q.jsx)($,{color:`yellow`,children:`终端尺寸过小:`}),(0,Q.jsxs)(fl,{children:[(0,Q.jsx)($,{color:r?`green`:`red`,children:`宽度 = ${t}`}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{color:i?`green`:`red`,children:`高度 = ${n}`})]}),(0,Q.jsx)(fl,{height:1}),(0,Q.jsx)($,{color:`gray`,children:`所需最小尺寸:`}),(0,Q.jsx)($,{color:`gray`,children:`宽度 = ${nm} 高度 = 26`})]})}function im(){let{exit:e}=mu(),{overlayOpen:t,dialogMenuOpen:n,dialogStockDetailOpen:r,dialogRemoveConfirmOpen:i}=$d(),a=Sp[gf(e=>e.screen)];return pu((n,i)=>{if(i.escape){if(r){Qd.getState().close();return}let e=Ad.getState().step;if(e.type===`confirm`){Ad.getState().cancel();return}if(e.type===`done`||e.type===`error`){Ad.getState().dismiss();return}if(Dd(e))return;Vu.getState().toggle();return}n===`q`&&!t&&e()}),(0,Q.jsxs)(rm,{children:[(0,Q.jsx)(a.Component,{title:a.title,hint:a.hint}),n&&(0,Q.jsx)(kp,{}),r&&(0,Q.jsx)(tm,{}),i&&(0,Q.jsx)(Fp,{})]})}function am(e){if((e===e.toLowerCase()||e===e.toUpperCase())&&(e=e.toLowerCase()),e.indexOf(`-`)===-1&&e.indexOf(`_`)===-1)return e;{let t=``,n=!1,r=e.match(/^-+/);for(let i=r?r[0].length:0;i<e.length;i++){let r=e.charAt(i);n&&(n=!1,r=r.toUpperCase()),i!==0&&(r===`-`||r===`_`)?n=!0:r!==`-`&&r!==`_`&&(t+=r)}return t}}function om(e,t){let n=e.toLowerCase();t||=`-`;let r=``;for(let i=0;i<e.length;i++){let a=n.charAt(i),o=e.charAt(i);r+=a!==o&&i>0?`${t}${n.charAt(i)}`:o}return r}function sm(e){return e==null?!1:typeof e==`number`||/^0x[0-9a-f]+$/i.test(e)?!0:!/^0[^.]/.test(e)&&/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function cm(e){if(Array.isArray(e))return e.map(e=>typeof e==`string`?e:e+``);e=e.trim();let t=0,n=null,r=null,i=null,a=[];for(let o=0;o<e.length;o++){if(n=r,r=e.charAt(o),r===` `&&!i){n!==` `&&t++;continue}r===i?i=null:(r===`'`||r===`"`)&&!i&&(i=r),a[t]||(a[t]=``),a[t]+=r}return a}var lm;(function(e){e.BOOLEAN=`boolean`,e.STRING=`string`,e.NUMBER=`number`,e.ARRAY=`array`})(lm||={});var um,dm=class{constructor(e){um=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),r=cm(e),i=typeof e==`string`,a=fm(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":`no-`,"parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),s=Object.assign(Object.create(null),n.default),c=n.configObjects||[],l=n.envPrefix,u=o[`populate--`],d=u?`--`:`_`,f=Object.create(null),p=Object.create(null),m=n.__||um.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},g=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,_=RegExp(`^--`+o[`negation-prefix`]+`(.+)`);[].concat(n.array||[]).filter(Boolean).forEach(function(e){let t=typeof e==`object`?e.key:e,n=Object.keys(e).map(function(e){return{boolean:`bools`,string:`strings`,number:`numbers`}[e]}).filter(Boolean).pop();n&&(h[n][t]=!0),h.arrays[t]=!0,h.keys.push(t)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(e){h.bools[e]=!0,h.keys.push(e)}),[].concat(n.string||[]).filter(Boolean).forEach(function(e){h.strings[e]=!0,h.keys.push(e)}),[].concat(n.number||[]).filter(Boolean).forEach(function(e){h.numbers[e]=!0,h.keys.push(e)}),[].concat(n.count||[]).filter(Boolean).forEach(function(e){h.counts[e]=!0,h.keys.push(e)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(e){h.normalize[e]=!0,h.keys.push(e)}),typeof n.narg==`object`&&Object.entries(n.narg).forEach(([e,t])=>{typeof t==`number`&&(h.nargs[e]=t,h.keys.push(e))}),typeof n.coerce==`object`&&Object.entries(n.coerce).forEach(([e,t])=>{typeof t==`function`&&(h.coercions[e]=t,h.keys.push(e))}),n.config!==void 0&&(Array.isArray(n.config)||typeof n.config==`string`?[].concat(n.config).filter(Boolean).forEach(function(e){h.configs[e]=!0}):typeof n.config==`object`&&Object.entries(n.config).forEach(([e,t])=>{(typeof t==`boolean`||typeof t==`function`)&&(h.configs[e]=t)})),L(n.key,a,n.default,h.arrays),Object.keys(s).forEach(function(e){(h.aliases[e]||[]).forEach(function(t){s[t]=s[e]})});let v=null;oe();let y=[],b=Object.assign(Object.create(null),{_:[]}),x={};for(let e=0;e<r.length;e++){let t=r[e],n=t.replace(/^-{3,}/,`---`),i,a,s,c,l,u;if(t!==`--`&&/^-/.test(t)&&ne(t))S(t);else if(n.match(/^---+(=|$)/)){S(t);continue}else if(t.match(/^--.+=/)||!o[`short-option-groups`]&&t.match(/^-.+=/))c=t.match(/^--?([^=]+)=([\s\S]*)$/),c!==null&&Array.isArray(c)&&c.length>=3&&(R(c[1],h.arrays)?e=w(e,c[1],r,c[2]):R(c[1],h.nargs)===!1?T(c[1],c[2],!0):e=C(e,c[1],r,c[2]));else if(t.match(_)&&o[`boolean-negation`])c=t.match(_),c!==null&&Array.isArray(c)&&c.length>=2&&(a=c[1],T(a,R(a,h.arrays)?[!1]:!1));else if(t.match(/^--.+/)||!o[`short-option-groups`]&&t.match(/^-[^-]+/))c=t.match(/^--?(.+)/),c!==null&&Array.isArray(c)&&c.length>=2&&(a=c[1],R(a,h.arrays)?e=w(e,a,r):R(a,h.nargs)===!1?(l=r[e+1],l!==void 0&&(!l.match(/^-/)||l.match(g))&&!R(a,h.bools)&&!R(a,h.counts)||/^(true|false)$/.test(l)?(T(a,l),e++):T(a,re(a))):e=C(e,a,r));else if(t.match(/^-.\..+=/))c=t.match(/^-([^=]+)=([\s\S]*)$/),c!==null&&Array.isArray(c)&&c.length>=3&&T(c[1],c[2]);else if(t.match(/^-.\..+/)&&!t.match(g))l=r[e+1],c=t.match(/^-(.\..+)/),c!==null&&Array.isArray(c)&&c.length>=2&&(a=c[1],l!==void 0&&!l.match(/^-/)&&!R(a,h.bools)&&!R(a,h.counts)?(T(a,l),e++):T(a,re(a)));else if(t.match(/^-[^-]+/)&&!t.match(g)){s=t.slice(1,-1).split(``),i=!1;for(let n=0;n<s.length;n++){if(l=t.slice(n+2),s[n+1]&&s[n+1]===`=`){u=t.slice(n+3),a=s[n],R(a,h.arrays)?e=w(e,a,r,u):R(a,h.nargs)===!1?T(a,u):e=C(e,a,r,u),i=!0;break}if(l===`-`){T(s[n],l);continue}if(/[A-Za-z]/.test(s[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&R(l,h.bools)===!1){T(s[n],l),i=!0;break}if(s[n+1]&&s[n+1].match(/\W/)){T(s[n],l),i=!0;break}T(s[n],re(s[n]))}a=t.slice(-1)[0],!i&&a!==`-`&&(R(a,h.arrays)?e=w(e,a,r):R(a,h.nargs)===!1?(l=r[e+1],l!==void 0&&(!/^(-|--)[^-]/.test(l)||l.match(g))&&!R(a,h.bools)&&!R(a,h.counts)||/^(true|false)$/.test(l)?(T(a,l),e++):T(a,re(a))):e=C(e,a,r))}else if(t.match(/^-[0-9]$/)&&t.match(g)&&R(t.slice(1),h.bools))a=t.slice(1),T(a,re(a));else if(t===`--`){y=r.slice(e+1);break}else if(o[`halt-at-non-option`]){y=r.slice(e);break}else S(t)}M(b,!0),M(b,!1),k(b),j(),F(b,h.aliases,s,!0),N(b),o[`set-placeholder-key`]&&P(b),Object.keys(h.counts).forEach(function(e){I(b,e.split(`.`))||T(e,0)}),u&&y.length&&(b[d]=[]),y.forEach(function(e){b[d].push(e)}),o[`camel-case-expansion`]&&o[`strip-dashed`]&&Object.keys(b).filter(e=>e!==`--`&&e.includes(`-`)).forEach(e=>{delete b[e]}),o[`strip-aliased`]&&[].concat(...Object.keys(a).map(e=>a[e])).forEach(e=>{o[`camel-case-expansion`]&&e.includes(`-`)&&delete b[e.split(`.`).map(e=>am(e)).join(`.`)],delete b[e]});function S(e){let t=O(`_`,e);(typeof t==`string`||typeof t==`number`)&&b._.push(t)}function C(e,t,n,r){let i,a=R(t,h.nargs);if(a=typeof a!=`number`||isNaN(a)?1:a,a===0)return ae(r)||(v=Error(m(`Argument unexpected for: %s`,t))),T(t,re(t)),e;let s=+!ae(r);if(o[`nargs-eats-options`])n.length-(e+1)+s<a&&(v=Error(m(`Not enough arguments following: %s`,t))),s=a;else{for(i=e+1;i<n.length&&(!n[i].match(/^-[^0-9]/)||n[i].match(g)||ne(n[i]));i++)s++;s<a&&(v=Error(m(`Not enough arguments following: %s`,t)))}let c=Math.min(s,a);for(!ae(r)&&c>0&&(T(t,r),c--),i=e+1;i<c+e+1;i++)T(t,n[i]);return e+c}function w(e,t,n,r){let a=[],c=r||n[e+1],l=R(t,h.nargs);if(R(t,h.bools)&&!/^(true|false)$/.test(c))a.push(!0);else if(ae(c)||ae(r)&&/^-/.test(c)&&!g.test(c)&&!ne(c)){if(s[t]!==void 0){let e=s[t];a=Array.isArray(e)?e:[e]}}else{ae(r)||a.push(D(t,r,!0));for(let r=e+1;r<n.length&&!(!o[`greedy-arrays`]&&a.length>0||l&&typeof l==`number`&&a.length>=l||(c=n[r],/^-/.test(c)&&!g.test(c)&&!ne(c)));r++)e=r,a.push(D(t,c,i))}return typeof l==`number`&&(l&&a.length<l||isNaN(l)&&a.length===0)&&(v=Error(m(`Not enough arguments following: %s`,t))),T(t,a),e}function T(e,t,n=i){/-/.test(e)&&o[`camel-case-expansion`]&&E(e,e.split(`.`).map(function(e){return am(e)}).join(`.`));let r=D(e,t,n),a=e.split(`.`);ee(b,a,r),h.aliases[e]&&h.aliases[e].forEach(function(e){let t=e.split(`.`);ee(b,t,r)}),a.length>1&&o[`dot-notation`]&&(h.aliases[a[0]]||[]).forEach(function(t){let n=t.split(`.`),i=[].concat(a);i.shift(),n=n.concat(i),(h.aliases[e]||[]).includes(n.join(`.`))||ee(b,n,r)}),R(e,h.normalize)&&!R(e,h.arrays)&&[e].concat(h.aliases[e]||[]).forEach(function(e){Object.defineProperty(x,e,{enumerable:!0,get(){return t},set(e){t=typeof e==`string`?um.normalize(e):e}})})}function E(e,t){h.aliases[e]&&h.aliases[e].length||(h.aliases[e]=[t],f[t]=!0),h.aliases[t]&&h.aliases[t].length||E(t,e)}function D(e,t,n){n&&(t=hm(t)),(R(e,h.bools)||R(e,h.counts))&&typeof t==`string`&&(t=t===`true`);let r=Array.isArray(t)?t.map(function(t){return O(e,t)}):O(e,t);return R(e,h.counts)&&(ae(r)||typeof r==`boolean`)&&(r=pm()),R(e,h.normalize)&&R(e,h.arrays)&&(r=Array.isArray(t)?t.map(e=>um.normalize(e)):um.normalize(t)),r}function O(e,t){return!o[`parse-positional-numbers`]&&e===`_`||!R(e,h.strings)&&!R(e,h.bools)&&!Array.isArray(t)&&(sm(t)&&o[`parse-numbers`]&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))||!ae(t)&&R(e,h.numbers))&&(t=Number(t)),t}function k(e){let t=Object.create(null);F(t,h.aliases,s),Object.keys(h.configs).forEach(function(n){let r=e[n]||t[n];if(r)try{let e=null,t=um.resolve(um.cwd(),r),i=h.configs[n];if(typeof i==`function`){try{e=i(t)}catch(t){e=t}if(e instanceof Error){v=e;return}}else e=um.require(t);A(e)}catch(t){t.name===`PermissionDenied`?v=t:e[n]&&(v=Error(m(`Invalid JSON config file: %s`,r)))}})}function A(e,t){Object.keys(e).forEach(function(n){let r=e[n],i=t?t+`.`+n:n;typeof r==`object`&&r&&!Array.isArray(r)&&o[`dot-notation`]?A(r,i):(!I(b,i.split(`.`))||R(i,h.arrays)&&o[`combine-arrays`])&&T(i,r)})}function j(){c!==void 0&&c.forEach(function(e){A(e)})}function M(e,t){if(l===void 0)return;let n=typeof l==`string`?l:``,r=um.env();Object.keys(r).forEach(function(i){if(n===``||i.lastIndexOf(n,0)===0){let a=i.split(`__`).map(function(e,t){return t===0&&(e=e.substring(n.length)),am(e)});(t&&h.configs[a.join(`.`)]||!t)&&!I(e,a)&&T(a.join(`.`),r[i])}})}function N(e){let t,n=new Set;Object.keys(e).forEach(function(r){if(!n.has(r)&&(t=R(r,h.coercions),typeof t==`function`))try{let i=O(r,t(e[r]));[].concat(h.aliases[r]||[],r).forEach(t=>{n.add(t),e[t]=i})}catch(e){v=e}})}function P(e){return h.keys.forEach(t=>{~t.indexOf(`.`)||e[t]===void 0&&(e[t]=void 0)}),e}function F(e,t,n,r=!1){Object.keys(n).forEach(function(i){I(e,i.split(`.`))||(ee(e,i.split(`.`),n[i]),r&&(p[i]=!0),(t[i]||[]).forEach(function(t){I(e,t.split(`.`))||ee(e,t.split(`.`),n[i])}))})}function I(e,t){let n=e;o[`dot-notation`]||(t=[t.join(`.`)]),t.slice(0,-1).forEach(function(e){n=n[e]||{}});let r=t[t.length-1];return typeof n==`object`&&r in n}function ee(e,t,n){let r=e;o[`dot-notation`]||(t=[t.join(`.`)]),t.slice(0,-1).forEach(function(e){e=mm(e),typeof r==`object`&&r[e]===void 0&&(r[e]={}),typeof r[e]!=`object`||Array.isArray(r[e])?(Array.isArray(r[e])?r[e].push({}):r[e]=[r[e],{}],r=r[e][r[e].length-1]):r=r[e]});let i=mm(t[t.length-1]),a=R(t.join(`.`),h.arrays),s=Array.isArray(n),c=o[`duplicate-arguments-array`];!c&&R(i,h.nargs)&&(c=!0,(!ae(r[i])&&h.nargs[i]===1||Array.isArray(r[i])&&r[i].length===h.nargs[i])&&(r[i]=void 0)),n===pm()?r[i]=pm(r[i]):Array.isArray(r[i])?c&&a&&s?r[i]=o[`flatten-duplicate-arrays`]?r[i].concat(n):(Array.isArray(r[i][0])?r[i]:[r[i]]).concat([n]):!c&&!!a==!!s?r[i]=n:r[i]=r[i].concat([n]):r[i]===void 0&&a?r[i]=s?n:[n]:c&&!(r[i]===void 0||R(i,h.counts)||R(i,h.bools))?r[i]=[r[i],n]:r[i]=n}function L(...e){e.forEach(function(e){Object.keys(e||{}).forEach(function(e){h.aliases[e]||(h.aliases[e]=[].concat(a[e]||[]),h.aliases[e].concat(e).forEach(function(t){if(/-/.test(t)&&o[`camel-case-expansion`]){let n=am(t);n!==e&&h.aliases[e].indexOf(n)===-1&&(h.aliases[e].push(n),f[n]=!0)}}),h.aliases[e].concat(e).forEach(function(t){if(t.length>1&&/[A-Z]/.test(t)&&o[`camel-case-expansion`]){let n=om(t,`-`);n!==e&&h.aliases[e].indexOf(n)===-1&&(h.aliases[e].push(n),f[n]=!0)}}),h.aliases[e].forEach(function(t){h.aliases[t]=[e].concat(h.aliases[e].filter(function(e){return t!==e}))}))})})}function R(e,t){let n=[].concat(h.aliases[e]||[],e),r=Object.keys(t),i=n.find(e=>r.includes(e));return i?t[i]:!1}function z(e){let t=Object.keys(h);return[].concat(t.map(e=>h[e])).some(function(t){return Array.isArray(t)?t.includes(e):t[e]})}function te(e,...t){return[].concat(...t).some(function(t){let n=e.match(t);return n&&z(n[1])})}function B(e){if(e.match(g)||!e.match(/^-[^-]+/))return!1;let t=!0,n,r=e.slice(1).split(``);for(let i=0;i<r.length;i++){if(n=e.slice(i+2),!z(r[i])){t=!1;break}if(r[i+1]&&r[i+1]===`=`||n===`-`||/[A-Za-z]/.test(r[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(n)||r[i+1]&&r[i+1].match(/\W/))break}return t}function ne(e){return o[`unknown-options-as-args`]&&V(e)}function V(e){return e=e.replace(/^-{3,}/,`--`),e.match(g)||B(e)?!1:!te(e,/^-+([^=]+?)=[\s\S]*$/,_,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function re(e){return!R(e,h.bools)&&!R(e,h.counts)&&`${e}`in s?s[e]:ie(H(e))}function ie(e){return{[lm.BOOLEAN]:!0,[lm.STRING]:``,[lm.NUMBER]:void 0,[lm.ARRAY]:[]}[e]}function H(e){let t=lm.BOOLEAN;return R(e,h.strings)?t=lm.STRING:R(e,h.numbers)?t=lm.NUMBER:R(e,h.bools)?t=lm.BOOLEAN:R(e,h.arrays)&&(t=lm.ARRAY),t}function ae(e){return e===void 0}function oe(){Object.keys(h.counts).find(e=>R(e,h.arrays)?(v=Error(m(`Invalid configuration: %s, opts.count excludes opts.array.`,e)),!0):R(e,h.nargs)?(v=Error(m(`Invalid configuration: %s, opts.count excludes opts.narg.`,e)),!0):!1)}return{aliases:Object.assign({},h.aliases),argv:Object.assign(x,b),configuration:o,defaulted:Object.assign({},p),error:v,newAliases:Object.assign({},f)}}};function fm(e){let t=[],n=Object.create(null),r=!0;for(Object.keys(e).forEach(function(n){t.push([].concat(e[n],n))});r;){r=!1;for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++)if(t[e].filter(function(e){return t[n].indexOf(e)!==-1}).length){t[e]=t[e].concat(t[n]),t.splice(n,1),r=!0;break}}return t.forEach(function(e){e=e.filter(function(e,t,n){return n.indexOf(e)===t});let t=e.pop();t!==void 0&&typeof t==`string`&&(n[t]=e)}),n}function pm(e){return e===void 0?1:e+1}function mm(e){return e===`__proto__`?`___proto___`:e}function hm(e){return typeof e==`string`&&(e[0]===`'`||e[0]===`"`)&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}var gm=process&&{}.YARGS_MIN_NODE_VERSION?Number({}.YARGS_MIN_NODE_VERSION):20,_m=(process==null?void 0:process.versions)?.node??(process==null?void 0:process.version)?.slice(1);if(_m&&Number(_m.match(/^([^.]+)/)[1])<gm)throw Error(`yargs parser supports a minimum Node.js version of ${gm}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var vm=(process,{}),ym=t?t(import.meta.url):void 0,bm=new dm({cwd:process.cwd,env:()=>vm,format:g,normalize:k,resolve:A,require:e=>{if(ym!==void 0)return ym(e);if(e.match(/\.json$/))return JSON.parse(j(e,`utf8`));throw Error(`only .json config files are supported in ESM`)}}),xm=function(e,t){return bm.parse(e.slice(),t).argv};xm.detailed=function(e,t){return bm.parse(e.slice(),t)},xm.camelCase=am,xm.decamelize=om,xm.looksLikeNumber=sm;var Sm=e=>typeof e==`object`&&!!e,Cm=e=>!(!Sm(e)||e instanceof RegExp||e instanceof Error||e instanceof Date||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof Promise||e instanceof ArrayBuffer||e instanceof DataView||ArrayBuffer.isView(e)||globalThis.Blob&&e instanceof globalThis.Blob||typeof e.$$typeof==`symbol`||typeof e.asymmetricMatch==`function`),wm=Symbol(`mapObjectSkip`),Tm=(e,t)=>{if(t){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t)?.enumerable);return[...t,...n]}return Object.keys(e)},Em=(e,t,n,r=new WeakMap)=>{let{target:i={},...a}={deep:!1,includeSymbols:!1,...n};if(r.has(e))return r.get(e);r.set(e,i);let o=e=>e.map(e=>Cm(e)?Em(e,t,a,r):e);if(Array.isArray(e))return o(e);for(let n of Tm(e,a.includeSymbols)){let s=e[n],c=t(n,s);if(c===wm)continue;if(!Array.isArray(c))throw TypeError(`Mapper must return an array or mapObjectSkip, got ${c===null?`null`:typeof c}`);if(c.length<2)throw TypeError(`Mapper must return an array with at least 2 elements [key, value], got ${c.length} elements`);let[l,u,{shouldRecurse:d=!0}={}]=c;if(l!==`__proto__`){a.deep&&d&&Cm(u)&&(u=Array.isArray(u)?o(u):Em(u,t,a,r));try{i[l]=u}catch(e){if(e.name===`TypeError`&&e.message.includes(`read only`))continue;throw e}}}return i};function Dm(e,t,n){if(!Sm(e))throw TypeError(`Expected an object, got \`${e}\` (${typeof e})`);if(Array.isArray(e))throw TypeError(`Expected an object, got an array`);return Em(e,(n,r)=>t(n,r,e),n)}var Om=/[\p{Lu}]/u,km=/[\p{Ll}]/u,Am=/^[\p{Lu}](?![\p{Lu}])/u,jm=/[_.\- ]+/,Mm=/([\p{Alpha}\p{N}_]|$)/u,Nm=RegExp(`^`+jm.source),Pm=new RegExp(jm.source+Mm.source,`gu`),Fm=new RegExp(String.raw`\d+`+Mm.source,`gu`),Im=(e,t,n,r)=>{let i=!1,a=!1,o=!1,s=!1;for(let c=0;c<e.length;c++){let l=e[c];s=c>2?e[c-3]===`-`:!0,i&&Om.test(l)?(e=e.slice(0,c)+`-`+e.slice(c),i=!1,o=a,a=!0,c++):a&&o&&km.test(l)&&(!s||r)?(e=e.slice(0,c-1)+`-`+e.slice(c-1),o=a,a=!1,i=!0):(i=t(l)===l&&n(l)!==l,o=a,a=n(l)===l&&t(l)!==l)}return e},Lm=(e,t)=>e.replace(Am,e=>t(e)),Rm=(e,t,n)=>{let r=``,i=!1,a=!1,o=[...e];for(let e=0;e<o.length;e++){let s=o[e],c=Om.test(s),l=e+1<o.length&&Om.test(o[e+1]);i&&/[\p{Alpha}]/u.test(s)?(r+=s,i=!1,a=c):n&&c&&(a||l)?(r+=s,a=!0):/\d/.test(s)?(r+=s,i=!0,a=!1):jm.test(s)?(r+=s,a=!1):(r+=t(s),i=!1,a=!1)}return r},zm=(e,t,{capitalizeAfterNumber:n})=>{let r=n?(e,n,r,i)=>{let a=i.charAt(r+e.length);return jm.test(a)?e:n?e.slice(0,-n.length)+t(n):e}:e=>e;return e.replaceAll(Fm,r).replaceAll(Pm,(e,n)=>t(n))};function Bm(e,t){if(!(typeof e==`string`||Array.isArray(e)))throw TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,capitalizeAfterNumber:!0,...t},e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length>0).join(`-`):e.trim(),e.length===0)return``;let n=e.match(/^[_$]*/)[0];if(e=e.slice(n.length),e.length===0)return n;let r=t.locale===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t.locale),i=t.locale===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t.locale);return e.length===1?jm.test(e)?n:n+(t.pascalCase?i(e):r(e)):(e!==r(e)&&(e=Im(e,r,i,t.preserveConsecutiveUppercase)),e=e.replace(Nm,``),e=t.capitalizeAfterNumber?t.preserveConsecutiveUppercase?Lm(e,r):r(e):Rm(e,r,t.preserveConsecutiveUppercase),t.pascalCase&&e.length>0&&(e=i(e[0])+e.slice(1)),n+zm(e,i,t))}var Vm=class extends Map{#e=0;#t=new Map;#n=new Map;#r;#i;#a;constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge==`number`&&e.maxAge===0)throw TypeError("`maxAge` must be a number greater than 0");this.#r=e.maxSize,this.#i=e.maxAge||1/0,this.#a=e.onEviction}get __oldCache(){return this.#n}#o(e){if(typeof this.#a==`function`)for(let[t,n]of e)this.#a(t,n.value)}#s(e,t){return typeof t.expiry==`number`&&t.expiry<=Date.now()&&(typeof this.#a==`function`&&this.#a(e,t.value),this.delete(e))}#c(e,t){if(this.#s(e,t)===!1)return t.value}#l(e,t){return t.expiry?this.#c(e,t):t.value}#u(e,t){let n=t.get(e);return this.#l(e,n)}#d(e,t){this.#t.set(e,t),this.#e++,this.#e>=this.#r&&(this.#e=0,this.#o(this.#n),this.#n=this.#t,this.#t=new Map)}#f(e,t){this.#n.delete(e),this.#d(e,t)}*#p(){for(let e of this.#n){let[t,n]=e;this.#t.has(t)||this.#s(t,n)===!1&&(yield e)}for(let e of this.#t){let[t,n]=e;this.#s(t,n)===!1&&(yield e)}}get(e){if(this.#t.has(e)){let t=this.#t.get(e);return this.#l(e,t)}if(this.#n.has(e)){let t=this.#n.get(e);if(this.#s(e,t)===!1)return this.#f(e,t),t.value}}set(e,t,{maxAge:n=this.#i}={}){let r=typeof n==`number`&&n!==1/0?Date.now()+n:void 0;return this.#t.has(e)?this.#t.set(e,{value:t,expiry:r}):this.#d(e,{value:t,expiry:r}),this}has(e){return this.#t.has(e)?!this.#s(e,this.#t.get(e)):this.#n.has(e)?!this.#s(e,this.#n.get(e)):!1}peek(e){if(this.#t.has(e))return this.#u(e,this.#t);if(this.#n.has(e))return this.#u(e,this.#n)}expiresIn(e){let t=this.#t.get(e)??this.#n.get(e);if(t)return t.expiry?t.expiry-Date.now():1/0}delete(e){let t=this.#t.delete(e);return t&&this.#e--,this.#n.delete(e)||t}clear(){this.#t.clear(),this.#n.clear(),this.#e=0}resize(e){if(!(e&&e>0))throw TypeError("`maxSize` must be a number greater than 0");let t=[...this.#p()],n=t.length-e;n<0?(this.#t=new Map(t),this.#n=new Map,this.#e=t.length):(n>0&&this.#o(t.slice(0,n)),this.#n=new Map(t.slice(n)),this.#t=new Map,this.#e=0),this.#r=e}evict(e=1){let t=Number(e);if(!t||t<=0)return;let n=[...this.#p()],r=Math.trunc(Math.min(t,Math.max(n.length-1,0)));r<=0||(this.#o(n.slice(0,r)),this.#n=new Map(n.slice(r)),this.#t=new Map,this.#e=0)}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.#t){let[t,n]=e;this.#s(t,n)===!1&&(yield[t,n.value])}for(let e of this.#n){let[t,n]=e;this.#t.has(t)||this.#s(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.#t];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.#s(n,r)===!1&&(yield[n,r.value])}e=[...this.#n];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.#t.has(n)||this.#s(n,r)===!1&&(yield[n,r.value])}}*entriesAscending(){for(let[e,t]of this.#p())yield[e,t.value]}get size(){if(!this.#e)return this.#n.size;let e=0;for(let t of this.#n.keys())this.#t.has(t)||e++;return Math.min(this.#e+e,this.#r)}get maxSize(){return this.#r}get maxAge(){return this.#i}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,r]of this.entriesAscending())e.call(t,r,n,this)}get[Symbol.toStringTag](){return`QuickLRU`}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},Hm=(e,t)=>e.some(e=>typeof e==`string`?e===t:(e.lastIndex=0,e.test(t))),Um=e=>e.trim()!==``&&!Number.isNaN(Number(e)),Wm=new Vm({maxSize:1e5}),Gm=e=>ArrayBuffer.isView(e)||e instanceof Date||e instanceof RegExp||e instanceof Error||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof Promise,Km=e=>typeof e==`object`&&!!e&&!Gm(e),qm=(e,t={},n=new WeakMap,r)=>{if(!Km(e))return e;if(n.has(e))return n.get(e);let{exclude:i,pascalCase:a=!1,stopPaths:o,deep:s=!1,preserveConsecutiveUppercase:c=!1}=t,l=new Set(o);if(Array.isArray(e)){let i=[];n.set(e,i);for(let a of e)i.push(Km(a)?qm(a,t,n,r):a);return i}let u={};n.set(e,u);let d=Dm(e,(e=>(r,o)=>{if(s&&Km(o)){let i=e===void 0?r:`${e}.${r}`;l.has(i)||(o=Array.isArray(o)?o.map(e=>Km(e)?qm(e,t,n,i):e):qm(o,t,n,i))}if(typeof r==`string`&&!Um(r)&&!(i&&Hm(i,r))){let e=a?`${r}_`:r;Wm.has(e)?r=Wm.get(e):(r=Bm(r,{pascalCase:a,locale:!1,preserveConsecutiveUppercase:c}),r.length<100&&Wm.set(e,r))}return[r,o]})(r),{deep:!1});Object.assign(u,d);let f=Object.getOwnPropertySymbols(e);for(let i of f)u[i]=s&&Km(e[i])?qm(e[i],t,n,r):e[i];return u};function Jm(e,t){let n=new WeakMap;return Array.isArray(e)?e.map(e=>Km(e)?qm(e,t,n,void 0):e):qm(e,t,n)}function Ym(e){let t=0,n=e.length;for(;t<n&&(e[t]===`\r`||e[t]===`
|
|
138
|
+
`)i.name=`enter`;else if(e===` `)i.name=`tab`;else if(e===`\b`||e===`\x1B\b`)i.name=`backspace`,i.meta=e.charAt(0)===`\x1B`;else if(e===``||e===`\x1B`)i.name=`backspace`,i.meta=e.charAt(0)===`\x1B`;else if(e===`\x1B`||e===`\x1B\x1B`)i.name=`escape`,i.meta=e.length===2;else if(e===` `||e===`\x1B `)i.name=`space`,i.meta=e.length===2;else if(e.length===1&&e<=``)i.name=String.fromCharCode(e.charCodeAt(0)+97-1),i.ctrl=!0;else if(e.length===1&&e>=`0`&&e<=`9`)i.name=`number`;else if(e.length===1&&e>=`a`&&e<=`z`)i.name=e;else if(e.length===1&&e>=`A`&&e<=`Z`)i.name=e.toLowerCase(),i.shift=!0;else if(t=Jl.exec(e))i.name=t[1].toLowerCase(),i.meta=!0,i.shift=/^[A-Z]$/.test(t[1]);else if(t=Yl.exec(e)){let n=[...e];n[0]===`\x1B`&&n[1]===`\x1B`&&(i.meta=!0);let r=[t[1],t[2],t[4],t[6]].filter(Boolean).join(``),a=(t[3]||t[5]||1)-1;i.ctrl=!!(a&4),i.meta=i.meta||!!(a&10),i.shift=!!(a&1),i.code=r,i.name=Xl[r]??``,i.shift=Ql(r)||i.shift,i.ctrl=$l(r)||i.ctrl}return i},fu=()=>(0,W.useContext)($c),pu=(e,t={})=>{let{setRawMode:n,internal_exitOnCtrlC:r,internal_eventEmitter:i}=fu();(0,W.useEffect)(()=>{if(t.isActive!==!1)return n(!0),()=>{n(!1)}},[t.isActive,n]);let a=(0,W.useEffectEvent)(t=>{let n=du(t),i={upArrow:n.name===`up`,downArrow:n.name===`down`,leftArrow:n.name===`left`,rightArrow:n.name===`right`,pageDown:n.name===`pagedown`,pageUp:n.name===`pageup`,home:n.name===`home`,end:n.name===`end`,return:n.name===`return`,escape:n.name===`escape`,ctrl:n.ctrl,shift:n.shift,tab:n.name===`tab`,backspace:n.name===`backspace`,delete:n.name===`delete`,meta:n.meta,super:n.super??!1,hyper:n.hyper??!1,capsLock:n.capsLock??!1,numLock:n.numLock??!1,eventType:n.eventType},a;a=n.isKittyProtocol?n.isPrintable?n.text??n.name:n.ctrl&&n.name.length===1?n.name:``:n.ctrl?n.name??``:n.sequence,!n.isKittyProtocol&&Zl.includes(n.name)&&(a=``),a.startsWith(`\x1B`)&&(a=a.slice(1)),a.length===1&&/[A-Z]/.test(a)&&(i.shift=!0),!(a===`c`&&i.ctrl&&r)&&Io.discreteUpdates(()=>{e(a,i)})});(0,W.useEffect)(()=>{if(t.isActive!==!1)return i.on(`input`,a),()=>{i.removeListener(`input`,a)}},[t.isActive,i])},mu=()=>(0,W.useContext)(Qc),hu=()=>(0,W.useContext)(el),gu=()=>{let{stdout:e}=hu(),[t,n]=(0,W.useState)(()=>nr(e));return(0,W.useEffect)(()=>{let t=()=>{n(nr(e))};return e.on(`resize`,t),()=>{e.off(`resize`,t)}},[e]),t},_u={width:0,height:0,left:0,top:0},vu=e=>{if(e)return e.parentNode?vu(e.parentNode):e.nodeName===`ink-root`?e:void 0},yu=e=>{let[t,n]=(0,W.useState)(_u),[r,i]=(0,W.useState)(!1),a=(0,W.useCallback)(()=>{let t=e.current?.yogaNode?.getComputedLayout()??_u;n(e=>e.width!==t.width||e.height!==t.height||e.left!==t.left||e.top!==t.top?t:e),i(!!e.current)},[e]);return(0,W.useEffect)(a),(0,W.useEffect)(()=>{let t=vu(e.current);if(t)return za(t,a)}),(0,W.useMemo)(()=>({...t,hasMeasured:r}),[t,r])},bu=e=>e>0?e.toFixed(2):`--`,xu=e=>`${e>0?`+`:``}${e.toFixed(2)}`,Su=e=>`${e>0?`+`:``}${e.toFixed(2)}%`,Cu=[`red-up`,`green-up`],wu={"red-up":`涨红跌绿`,"green-up":`涨绿跌红`},Tu=`red-up`,Eu=(e,t=Tu)=>e===0?`gray`:e>0==(t===`green-up`)?`green`:`red`,Du=e=>e>=1e4?`${(e/1e4).toFixed(1)}万手`:e>0?`${Math.round(e)}手`:`--`,Ou=e=>e>=1e4?`${(e/1e4).toFixed(2)}亿`:e>0?`${e.toFixed(1)}万`:`--`,ku=e=>e>0?`${e.toFixed(2)}%`:`--`,Au=e=>e>0?e.toFixed(2):`--`,ju=e=>e>0?`${e.toFixed(2)}亿`:`--`,Mu=[`single`,`double`,`round`,`bold`,`singleDouble`,`doubleSingle`,`classic`,`arrow`],Nu={classic:{label:`经典紫蓝`,primary:`magenta`,accent:`blue`,highlight:`cyan`,foreground:`white`},ocean:{label:`海洋青蓝`,primary:`cyan`,accent:`blue`,highlight:`cyan`,foreground:`white`},forest:{label:`森林绿`,primary:`green`,accent:`green`,highlight:`green`,foreground:`white`},sunset:{label:`日落黄红`,primary:`yellow`,accent:`red`,highlight:`yellow`,foreground:`white`},gray:{label:`低调灰`,primary:`gray`,accent:`gray`,highlight:`gray`,foreground:`white`}},Pu=Object.keys(Nu),Fu={requestTimeoutMs:{min:1e3,max:6e4,step:1e3},minimumRequestDurationMs:{min:0,max:5e3,step:250},quotePollIntervalMs:{min:1e3,max:6e4,step:500},minuteChartPollIntervalMs:{min:5e3,max:3e5,step:5e3},klinePollIntervalMs:{min:3e4,max:18e5,step:3e4}},Iu={themePreset:`classic`,trendColorMode:Tu,borderStyle:`round`,requestTimeoutMs:8e3,minimumRequestDurationMs:0,quotePollIntervalMs:5e3,minuteChartPollIntervalMs:3e4,klinePollIntervalMs:3e5},Lu=/^(?:sh|sz|bj)\d{6}$/,Ru=(e,t)=>{if(typeof e!=`object`||!e)throw Error(`第 ${t+1} 项不是对象`);let n=e;if(typeof n.code!=`string`||!Lu.test(n.code))throw Error(`第 ${t+1} 项 code 无效`);if(typeof n.name!=`string`||n.name.trim()===``)throw Error(`第 ${t+1} 项 name 无效`);if(typeof n.addedAt!=`string`||!Number.isFinite(Date.parse(n.addedAt)))throw Error(`第 ${t+1} 项 addedAt 无效`);return{code:n.code,name:n.name,addedAt:n.addedAt}};function zu(e){if(!Array.isArray(e))throw Error(`stocks 不是数组`);let t=e.map(Ru),n=new Set;for(let[e,r]of t.entries()){if(n.has(r.code))throw Error(`第 ${e+1} 项 code 重复: ${r.code}`);n.add(r.code)}return t}var Bu=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Vu=e=>{if(typeof e!=`string`||!Pu.includes(e))throw Error(`theme.preset 无效`);return e},Hu=e=>{if(e===void 0)return Tu;if(typeof e!=`string`||!Cu.includes(e))throw Error(`theme.trendColorMode 无效`);return e},Uu=(e,t,n)=>{if(typeof e!=`number`||!Number.isInteger(e)||e<n.min||e>n.max)throw Error(`${t} 无效`);return e};function Wu(e){if(!Bu(e))throw Error(`顶层数据不是对象`);let t=e.theme;if(!Bu(t))throw Error(`theme 无效`);let n=t.borderStyle;if(typeof n!=`string`||!Mu.includes(n))throw Error(`theme.borderStyle 无效`);let r=e.request;if(!Bu(r))throw Error(`request 无效`);let i=Uu(r.timeoutMs,`request.timeoutMs`,Fu.requestTimeoutMs),a=Uu(r.minimumDurationMs,`request.minimumDurationMs`,Fu.minimumRequestDurationMs);if(a>i)throw Error(`request.minimumDurationMs 不能大于 request.timeoutMs`);return{theme:{preset:Vu(t.preset),trendColorMode:Hu(t.trendColorMode),borderStyle:n},request:{timeoutMs:i,minimumDurationMs:a,quotePollIntervalMs:Uu(r.quotePollIntervalMs,`request.quotePollIntervalMs`,Fu.quotePollIntervalMs),minuteChartPollIntervalMs:Uu(r.minuteChartPollIntervalMs,`request.minuteChartPollIntervalMs`,Fu.minuteChartPollIntervalMs),klinePollIntervalMs:Uu(r.klinePollIntervalMs,`request.klinePollIntervalMs`,Fu.klinePollIntervalMs)},stocks:zu(e.stocks)}}function Gu(e){return{themePreset:e.theme.preset,trendColorMode:e.theme.trendColorMode,borderStyle:e.theme.borderStyle,requestTimeoutMs:e.request.timeoutMs,minimumRequestDurationMs:e.request.minimumDurationMs,quotePollIntervalMs:e.request.quotePollIntervalMs,minuteChartPollIntervalMs:e.request.minuteChartPollIntervalMs,klinePollIntervalMs:e.request.klinePollIntervalMs}}function Ku(e,t){return{theme:{preset:e.themePreset,trendColorMode:e.trendColorMode,borderStyle:e.borderStyle},request:{timeoutMs:e.requestTimeoutMs,minimumDurationMs:e.minimumRequestDurationMs,quotePollIntervalMs:e.quotePollIntervalMs,minuteChartPollIntervalMs:e.minuteChartPollIntervalMs,klinePollIntervalMs:e.klinePollIntervalMs},stocks:t}}var qu=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Ju=(e=>e?qu(e):qu),Yu=e=>e;function Xu(e,t=Yu){let n=W.useSyncExternalStore(e.subscribe,W.useCallback(()=>t(e.getState()),[e,t]),W.useCallback(()=>t(e.getInitialState()),[e,t]));return W.useDebugValue(n),n}var Zu=e=>{let t=Ju(e),n=e=>Xu(t,e);return Object.assign(n,t),n},Qu=(e=>e?Zu(e):Zu),$u=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),ed=e=>{let t=$u(e.requestTimeoutMs,Fu.requestTimeoutMs.min,Fu.requestTimeoutMs.max);return{...e,requestTimeoutMs:t,minimumRequestDurationMs:Math.min(t,$u(e.minimumRequestDurationMs,Fu.minimumRequestDurationMs.min,Fu.minimumRequestDurationMs.max)),quotePollIntervalMs:$u(e.quotePollIntervalMs,Fu.quotePollIntervalMs.min,Fu.quotePollIntervalMs.max),minuteChartPollIntervalMs:$u(e.minuteChartPollIntervalMs,Fu.minuteChartPollIntervalMs.min,Fu.minuteChartPollIntervalMs.max),klinePollIntervalMs:$u(e.klinePollIntervalMs,Fu.klinePollIntervalMs.min,Fu.klinePollIntervalMs.max)}},td=e=>({themePreset:e.themePreset,trendColorMode:e.trendColorMode,borderStyle:e.borderStyle,requestTimeoutMs:e.requestTimeoutMs,minimumRequestDurationMs:e.minimumRequestDurationMs,quotePollIntervalMs:e.quotePollIntervalMs,minuteChartPollIntervalMs:e.minuteChartPollIntervalMs,klinePollIntervalMs:e.klinePollIntervalMs}),nd=(e,t)=>e.themePreset===t.themePreset&&e.trendColorMode===t.trendColorMode&&e.borderStyle===t.borderStyle&&e.requestTimeoutMs===t.requestTimeoutMs&&e.minimumRequestDurationMs===t.minimumRequestDurationMs&&e.quotePollIntervalMs===t.quotePollIntervalMs&&e.minuteChartPollIntervalMs===t.minuteChartPollIntervalMs&&e.klinePollIntervalMs===t.klinePollIntervalMs,rd=(e,t)=>{let n={};return e.themePreset!==t.themePreset&&(n.themePreset=e.themePreset),e.trendColorMode!==t.trendColorMode&&(n.trendColorMode=e.trendColorMode),e.borderStyle!==t.borderStyle&&(n.borderStyle=e.borderStyle),e.requestTimeoutMs!==t.requestTimeoutMs&&(n.requestTimeoutMs=e.requestTimeoutMs),e.minimumRequestDurationMs!==t.minimumRequestDurationMs&&(n.minimumRequestDurationMs=e.minimumRequestDurationMs),e.quotePollIntervalMs!==t.quotePollIntervalMs&&(n.quotePollIntervalMs=e.quotePollIntervalMs),e.minuteChartPollIntervalMs!==t.minuteChartPollIntervalMs&&(n.minuteChartPollIntervalMs=e.minuteChartPollIntervalMs),e.klinePollIntervalMs!==t.klinePollIntervalMs&&(n.klinePollIntervalMs=e.klinePollIntervalMs),n},id=Qu()(e=>({...Iu,updateSettings:t=>e(e=>ed({...td(e),...t})),adjustNumericSetting:(t,n)=>e(e=>{let r=Fu[t],i=$u(e[t]+r.step*n,r.min,r.max);return ed({...td(e),[t]:i})}),resetSettings:()=>e(Iu),hydrateSettings:t=>e(ed(t))}));function ad(){return id(e=>Nu[e.themePreset])}var od=Qu()(e=>({open:!1,toggle:()=>e(e=>({open:!e.open})),close:()=>e({open:!1})}));function sd(e){return e instanceof Error?e.message:String(e)}var cd=25,ld=2e3,ud=3e4,dd=e=>new Promise(t=>setTimeout(t,e)),fd=e=>{try{return n.kill(e,0),!0}catch(e){return e.code!==`ESRCH`}},pd=async e=>{let t;try{t=await x(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return!0;throw e}let n=!1;try{let e=JSON.parse(t);if(!md(e)||typeof e.token!=`string`||typeof e.pid!=`number`||!Number.isInteger(e.pid)||e.pid<=0||typeof e.createdAt!=`number`||!Number.isFinite(e.createdAt))throw Error(`lock metadata 无效`);n=!fd(e.pid)||Date.now()-e.createdAt>=ud}catch{try{let t=await w(e);n=Date.now()-t.mtimeMs>=ld}catch(e){if(e.code===`ENOENT`)return!0;throw e}}if(!n)return!1;try{return await x(e,`utf8`)===t&&(await C(e),!0)}catch(e){if(e.code===`ENOENT`)return!0;throw e}},md=e=>typeof e==`object`&&!!e&&!Array.isArray(e),hd=async(e,t)=>{let r=`${e}.${n.pid}.${v()}.tmp`;try{await T(r,t,{encoding:`utf8`,flag:`wx`}),await y(r,e)}finally{await C(r,{force:!0})}};async function gd(e,t){let r=`${e}.lock`,i=v(),a=JSON.stringify({token:i,pid:n.pid,createdAt:Date.now()});await b(D(e),{recursive:!0});let o=Date.now(),s=!1;for(;!s;)try{await hd(r,a),s=!0}catch(e){if(e.code!==`EEXIST`)throw e;if(await pd(r))continue;if(Date.now()-o>=ld)throw Error(`文件正被其他进程占用, 请稍后重试`);await dd(cd)}let c;try{c={ok:!0,value:await t()}}catch(e){c={ok:!1,error:e}}let l;try{await x(r,`utf8`)===a&&await C(r)}catch(e){e.code!==`ENOENT`&&(l=e)}if(!c.ok)throw c.error;if(l)throw l;return c.value}var _d=n.platform===`win32`,vd=()=>{let e=n.env.XDG_CONFIG_HOME;if(e)return O(e,`leek-box-cli`);if(_d){let e=n.env.APPDATA;if(e)return O(e,`leek-box-cli`)}return O(c(),`.config`,`leek-box-cli`)};function yd(){return O(vd(),`settings.json`)}var bd=e=>e.charCodeAt(0)===65279?e.slice(1):e,xd=async e=>{try{return JSON.parse(bd(await x(e,`utf8`)))}catch(e){if(e.code===`ENOENT`)return;throw e}},Sd=async()=>{let e=yd();try{let t=await xd(e);return t===void 0?void 0:Wu(t)}catch(t){throw Error(`设置文件损坏: ${e} (${sd(t)})`)}},Cd=async e=>{let t=Wu(e),r=yd();await b(D(r),{recursive:!0});let i=`${r}.${n.pid}.${v()}.tmp`;try{await T(i,`${JSON.stringify(t,null,2)}\n`,`utf8`),await S(i,r)}finally{await C(i,{force:!0})}},wd=[{code:`sz002156`,name:`富通微电`},{code:`sh600584`,name:`长电科技`},{code:`sh688825`,name:`长鑫科技`}],Td=()=>{let e=new Date().toISOString();return wd.map(t=>({...t,addedAt:e}))},Ed=async()=>{let e=await Sd();if(e)return e;let t=Ku(Iu,Td());return await Cd(t),t};async function Dd(){return await Sd()??gd(yd(),Ed)}async function Od(e){await gd(yd(),async()=>{let t=await Ed();await Cd(Ku({...Gu(t),...e},t.stocks))})}async function kd(){return(await Dd()).stocks}async function Ad(e){let t=zu(e);return gd(yd(),async()=>{let e=await Ed(),n=new Set(e.stocks.map(e=>e.code)),r=t.filter(e=>!n.has(e.code));return r.length>0&&await Cd({...e,stocks:[...e.stocks,...r]}),r.length})}async function jd(e){let t=new Set(e);return t.size===0?0:gd(yd(),async()=>{let e=await Ed(),n=e.stocks.filter(e=>!t.has(e.code)),r=e.stocks.length-n.length;return r>0&&await Cd({...e,stocks:n}),r})}var Md={loadStocks:kd};function Nd(e=Md){return Qu()(t=>({entries:[],errorMessage:void 0,resetToken:0,loadEntries:async()=>{t({errorMessage:void 0});try{t({entries:await e.loadStocks()})}catch(e){t({entries:[],errorMessage:sd(e)})}},removeByCodes:e=>{let n=new Set(e);t(e=>({entries:e.entries.filter(e=>!n.has(e.code)),resetToken:e.resetToken+1}))},resetSelection:()=>t(e=>({resetToken:e.resetToken+1}))}))}var Pd=Nd(),Fd=e=>e.type===`confirm`,Id=e=>e.type===`confirm`||e.type===`removing`||e.type===`done`||e.type===`error`,Ld={stocksRemove:jd,commitRemoval:e=>Pd.getState().removeByCodes(e),resetSelection:()=>Pd.getState().resetSelection()};function Rd(e=Ld){return Qu()((t,n)=>({step:{type:`idle`},targets:[],open:e=>{n().step.type===`idle`&&e.length!==0&&t({step:{type:`confirm`},targets:e})},confirmDelete:async()=>{if(n().step.type!==`confirm`)return;let r=n().targets.map(e=>e.code),i=r.length;t({step:{type:`removing`}});try{let n=await e.stocksRemove(r);if(n===0){t({step:{type:`error`,message:`所选 ${i} 个条目已不在自选股中.`}});return}e.commitRemoval(r);let a=i-n;if(a>0){t({step:{type:`done`,message:`已删除 ${n} 个股票, ${a} 个条目已不在自选股中.`},targets:[]});return}t({step:{type:`idle`},targets:[]})}catch(e){t({step:{type:`error`,message:`删除失败: ${sd(e)}`}})}},cancel:()=>{n().step.type===`confirm`&&(t({step:{type:`idle`},targets:[]}),e.resetSelection())},dismiss:()=>{(n().step.type===`done`||n().step.type===`error`)&&t({step:{type:`idle`},targets:[]})}}))}var zd=Rd(),Bd=e=>typeof e==`object`&&e?e:void 0,Vd=(e,t)=>{let n=Number.parseFloat(e[t]??``);return Number.isFinite(n)?n:0},Hd=e=>{let t=Number.parseFloat(typeof e==`string`||typeof e==`number`?String(e):``);return Number.isFinite(t)?t:0},Ud=e=>{if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let[e=``,r=``,i=``]=n.split(` `);if(!/^(?:[01]\d|2[0-3])[0-5]\d$/.test(e)||e>`1500`)continue;let a=Number.parseFloat(r);if(!Number.isFinite(a)||a<=0)continue;let o=Number.parseFloat(i);t.push({time:e,price:a,volume:Number.isFinite(o)?o:0})}return t};function Wd(e){let t=[];for(let n of e.split(`;`)){let e=/^v_([a-z]{2}\d{6})="([^"]*)"/.exec(n.trim());if(!e)continue;let r=e[2].split(`~`);if(r.length<50)continue;let i=r[1].trim();i&&t.push({code:e[1],name:i,current:Vd(r,3),prevClose:Vd(r,4),open:Vd(r,5),high:Vd(r,33),low:Vd(r,34),change:Vd(r,31),changePercent:Vd(r,32),timestamp:r[30],volume:Vd(r,36),turnover:Vd(r,37),turnoverRate:Vd(r,38),amplitude:Vd(r,43),marketCap:Vd(r,45),volumeRatio:Vd(r,49)})}if(t.length===0)throw Error(`未查询到任何行情数据, 请检查股票代码`);return t}function Gd(e,t){return Ud(Bd(Bd(Bd(Bd(e)?.data)?.[t])?.data)?.data)}function Kd(e,t){let n=Bd(Bd(Bd(e)?.data)?.[t])?.data;return Array.isArray(n)?n.flatMap(e=>{let t=Bd(e),n=t?.date;if(typeof n!=`string`||!/^\d{8}$/.test(n))return[];let r=`${n.slice(0,4)}-${n.slice(4,6)}-${n.slice(6,8)}`,i=Hd(t?.prec);return[{sessionDate:r,points:Ud(t?.data).map(e=>({...e,sessionDate:r,prevClose:i}))}]}).sort((e,t)=>e.sessionDate.localeCompare(t.sessionDate)).slice(-5).flatMap(e=>e.points):[]}function qd(e,t,n=`day`,r=`qfq`){let i=Bd(Bd(Bd(e)?.data)?.[t]),a=i?.[`${r}${n}`],o=Array.isArray(a)&&a.length>0?a:i?.[n];if(!Array.isArray(o))return[];let s=[];for(let e of o){if(!Array.isArray(e))continue;let[t,n,r,i,a,o]=e;if(typeof t!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(t))continue;let c=Hd(n),l=Hd(r),u=Hd(i),d=Hd(a),f=Hd(o);[c,l,u,d].some(e=>e<=0)||s.push({date:t,open:c,close:l,high:u,low:d,volume:Math.max(0,f)})}return s}var Jd=(e,t)=>e<=0?Promise.resolve():t?.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason)};t?.addEventListener(`abort`,a,{once:!0})}),Yd=async(e,t)=>{let{requestTimeoutMs:n,minimumRequestDurationMs:r}=id.getState(),i=AbortSignal.timeout(n),a=e?AbortSignal.any([e,i]):i,o=Date.now(),s=await t(a);return await Jd(r-(Date.now()-o),e),s};function Xd(e){let t=e.trim().toUpperCase();if(t=t.replace(/\.(SH|SZ|BJ)$/,``),t=t.replace(/^(SH|SZ|BJ)/,``),!/^\d{6}$/.test(t))return;let n;if(t.startsWith(`6`)||t.startsWith(`5`))n=`sh`;else if(t.startsWith(`0`)||t.startsWith(`1`)||t.startsWith(`3`))n=`sz`;else if(t.startsWith(`4`)||t.startsWith(`8`)||t.startsWith(`92`))n=`bj`;else return;return`${n}${t}`}async function Zd(e,t){return e.length===0?[]:Yd(t,async t=>{let n=await fetch(`https://qt.gtimg.cn/q=${e.join(`,`)}`,{signal:t});if(!n.ok)throw Error(`行情接口请求失败: HTTP ${n.status}`);let r=await n.arrayBuffer();return Wd(new TextDecoder(`gbk`).decode(r))})}async function Qd(e,t){return Yd(t,async t=>{let n=await fetch(`https://web.ifzq.gtimg.cn/appstock/app/minute/query?code=${e}`,{signal:t});if(!n.ok)throw Error(`分时接口请求失败: HTTP ${n.status}`);return Gd(await n.json(),e)})}async function $d(e,t){return Yd(t,async t=>{let n=await fetch(`https://web.ifzq.gtimg.cn/appstock/app/day/query?code=${e}`,{signal:t});if(!n.ok)throw Error(`五日行情接口请求失败: HTTP ${n.status}`);return Kd(await n.json(),e)})}var ef=e=>{let t=new Map;for(let n of[...e].sort((e,t)=>e.date.localeCompare(t.date))){let e=n.date.slice(0,4),r=t.get(e);if(!r){t.set(e,{...n});continue}r.date=n.date,r.close=n.close,r.high=Math.max(r.high,n.high),r.low=Math.min(r.low,n.low),r.volume+=n.volume}return[...t.values()]};async function tf(e,t){return Yd(t.signal,async n=>{let r=t.period===`year`?`month`:t.period,i=t.period===`year`?`hfq`:`qfq`,a=t.period===`year`?t.barCount*12:t.barCount,o=encodeURIComponent(`${e},${r},,,${a},${i}`),s=await fetch(`https://web.ifzq.gtimg.cn/appstock/app/fqkline/get?param=${o}`,{signal:n});if(!s.ok)throw Error(`K 线行情接口请求失败: HTTP ${s.status}`);let c=qd(await s.json(),e,r,i);return(t.period===`year`?ef(c):c).slice(-t.barCount)})}var nf={day:{barCount:60},week:{barCount:60},month:{barCount:60},year:{barCount:30}},rf=`intraday`,af=e=>e!==`intraday`&&e!==`five-day`,of={fetchIntraday:Qd,fetchFiveDay:$d,fetchHistorical:tf};function sf(e=of){return Qu()((t,n)=>({stock:void 0,period:rf,status:`loading`,points:[],open:(e,n)=>t({stock:{code:e,name:n},period:rf,status:`loading`,points:[],errorMessage:void 0}),close:()=>t({stock:void 0}),setPeriod:e=>{n().period!==e&&t({period:e,status:`loading`,points:[],errorMessage:void 0})},refreshChart:async(r,i,a)=>{try{let o;if(i===`intraday`)o=await e.fetchIntraday(r,a);else if(i===`five-day`)o=await e.fetchFiveDay?.(r,a);else if(af(i)){let t=nf[i];o=await e.fetchHistorical?.(r,{period:i,...t,signal:a})}if(!o)throw Error(`${i===`five-day`?`五日`:`K 线`}行情数据源不可用`);if(n().stock?.code!==r||n().period!==i||a?.aborted)return;t({status:`ready`,points:o,errorMessage:void 0})}catch(e){if(n().stock?.code!==r||n().period!==i||a?.aborted)return;t({status:`error`,errorMessage:sd(e)})}}}))}var cf=sf();function lf(){let e=od(e=>e.open),t=cf(e=>e.stock!==void 0),n=zd(e=>Id(e.step));return{overlayOpen:e||t||n,dialogMenuOpen:e,dialogStockDetailOpen:t,dialogRemoveConfirmOpen:n}}var uf=B((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Q=B(((e,t)=>{t.exports=uf()}))();function $({bright:e=!1,color:t,...n}){let{overlayOpen:r}=lf(),i=ad(),a=!e&&r;return(0,Q.jsx)(pl,{...n,color:t??i.foreground,dimColor:a})}function df({title:e,bright:t=!1,top:n,left:r,right:i}){return(0,Q.jsxs)(fl,{position:`absolute`,top:n,left:r,right:i,children:[(0,Q.jsx)($,{bright:t,children:`|`}),e,(0,Q.jsx)($,{bright:t,children:`|`})]})}function ff(e){let{bright:t=!1,fullScreen:n,title:r,extra:i,footer:a,children:o}=e,{width:s,height:c,backgroundColor:l}=e,{columns:u,rows:d}=gu(),f=id(e=>e.borderStyle),p=ad();return(0,Q.jsxs)(fl,{flexDirection:`column`,width:n?u:s,height:n?d:c,borderStyle:f,borderColor:p.primary,borderDimColor:t===!1,children:[r?(0,Q.jsx)(df,{title:r,bright:t,top:-1,left:1}):void 0,i?(0,Q.jsx)(df,{title:i,bright:t,top:-1,right:1}):void 0,(0,Q.jsx)(fl,{flexGrow:1,flexDirection:`column`,padding:1,backgroundColor:l,children:o}),a]})}var pf=new Intl.DateTimeFormat(`en-CA`,{timeZone:`Asia/Shanghai`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function mf(e,t){let n=pf.formatToParts(e),r=e=>n.find(t=>t.type===e)?.value??``,i=`${r(`year`)}-${r(`month`)}-${r(`day`)}`,a=`${r(`hour`)}:${r(`minute`)}`;switch(t){case`date-time`:return`${i} ${a}:${r(`second`)}`;case`date`:return i;case`time`:return`${a}:${r(`second`)}`;case`hour-minute`:return a}}var hf={"date-time":1e3,date:6e4,time:1e3,"hour-minute":6e4};function gf(e){let[t,n]=(0,W.useState)(()=>new Date);return(0,W.useEffect)(()=>{let t=setInterval(()=>n(new Date),hf[e]);return()=>clearInterval(t)},[e]),mf(t,e)}function _f(e){let{hint:t,bright:n=!1}=e,r=gf(`date-time`),i=ad();return(0,Q.jsxs)(fl,{justifyContent:`space-between`,paddingX:1,backgroundColor:n?i.accent:`gray`,children:[(0,Q.jsx)(fl,{flexShrink:0,children:t&&(0,Q.jsx)($,{bright:n,color:`white`,children:t})}),(0,Q.jsx)(fl,{flexShrink:0,children:(0,Q.jsx)($,{bright:n,color:`white`,children:r})})]})}var vf=[{type:`theme`,label:`主题色系`,description:`界面配色`},{type:`trendColor`,label:`涨跌颜色`,description:`选择涨绿或跌绿`},{type:`border`,label:`卡片边框`,description:`边框样式`},{type:`numeric`,label:`请求超时`,description:`单次请求最长等待`,setting:`requestTimeoutMs`},{type:`numeric`,label:`请求最短耗时`,description:`避免加载闪烁`,setting:`minimumRequestDurationMs`},{type:`numeric`,label:`看板刷新间隔`,description:`自选股票看板自动刷新频率`,setting:`quotePollIntervalMs`},{type:`numeric`,label:`分时图刷新间隔`,description:`分时与五日图自动刷新频率`,setting:`minuteChartPollIntervalMs`},{type:`numeric`,label:`K 线刷新间隔`,description:`日/周/月/年 K 线自动刷新频率`,setting:`klinePollIntervalMs`}],yf=(e,t,n)=>e[(e.indexOf(t)+n+e.length)%e.length]??t,bf=e=>e===0?`关闭`:e<1e3?`${e} ms`:e%6e4==0?`${e/6e4} 分钟`:e%1e3==0?`${e/1e3} 秒`:`${(e/1e3).toFixed(2)} 秒`;function xf(){let[e,t]=(0,W.useState)(0),{overlayOpen:n}=lf(),r=id(),i=t=>{let n=vf[e];n&&(n.type===`theme`?r.updateSettings({themePreset:yf(Pu,r.themePreset,t)}):n.type===`trendColor`?r.updateSettings({trendColorMode:yf(Cu,r.trendColorMode,t)}):n.type===`border`?r.updateSettings({borderStyle:yf(Mu,r.borderStyle,t)}):r.adjustNumericSetting(n.setting,t))};pu((e,n)=>{n.ctrl||(n.upArrow?t(e=>(e-1+vf.length)%vf.length):n.downArrow?t(e=>(e+1)%vf.length):n.leftArrow?i(-1):n.rightArrow||n.return?i(1):e===`d`&&r.resetSettings())},{isActive:!n});let a=vf.map((t,n)=>({label:t.label,description:t.description,selected:n===e,value:t.type===`theme`?Nu[r.themePreset].label:t.type===`trendColor`?wu[r.trendColorMode]:t.type===`border`?r.borderStyle:bf(r[t.setting])}));return{overlayOpen:n,appearanceRows:a.slice(0,3),requestRows:a.slice(3)}}function Sf({rows:e,highlight:t}){return e.map(e=>(0,Q.jsxs)(fl,{justifyContent:`space-between`,children:[(0,Q.jsxs)($,{color:e.selected?`black`:void 0,backgroundColor:e.selected?t:void 0,children:[e.selected?`› `:` `,e.label,(0,Q.jsxs)($,{color:`gray`,backgroundColor:e.selected?t:void 0,children:[`(`,e.description,`)`]})]}),(0,Q.jsx)($,{color:e.selected?t:`gray`,children:e.value})]},e.label))}function Cf({title:e,hint:t}){let n=ad(),{overlayOpen:r,appearanceRows:i,requestRows:a}=xf();return(0,Q.jsxs)(ff,{fullScreen:!0,bright:!r,title:(0,Q.jsx)($,{color:n.primary,children:e}),footer:(0,Q.jsx)(_f,{hint:t,bright:!r}),children:[(0,Q.jsx)($,{color:n.primary,children:`外观`}),(0,Q.jsx)(Sf,{rows:i,highlight:n.highlight}),(0,Q.jsxs)(fl,{marginTop:1,flexDirection:`column`,children:[(0,Q.jsx)($,{color:n.primary,children:`请求与刷新`}),(0,Q.jsx)(Sf,{rows:a,highlight:n.highlight})]}),(0,Q.jsx)(fl,{marginTop:1,flexDirection:`column`,children:(0,Q.jsx)($,{color:`gray`,children:`请求最短耗时用于避免加载状态闪烁, 且不会超过请求超时.`})})]})}var wf=Qu()(e=>({screen:`stock-list`,goTo:t=>e({screen:t})})),Tf={error:`red`,warning:`yellow`,success:`green`};function Ef({tone:e,msg:t}){return(0,Q.jsx)($,{bold:!0,color:Tf[e],children:t})}function Df({prompt:e,onSubmit:t,placeholder:n}){let{overlayOpen:r}=lf(),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(!1);return pu((e,n)=>{o||(n.return?(s(!0),t(i)):n.backspace||n.delete?a(e=>e.slice(0,-1)):!n.ctrl&&!n.meta&&e&&a(t=>t+e))},{isActive:!r&&!o}),(0,Q.jsx)(fl,{children:(0,Q.jsxs)($,{children:[e,o?(0,Q.jsx)($,{color:`green`,children:i}):(0,Q.jsxs)($,{children:[i,(0,Q.jsx)($,{color:`gray`,children:`█`}),!i&&n?n:void 0]})]})})}function Of({tone:e,msg:t,to:n,onReturn:r}){let i=wf(e=>e.goTo);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ef,{tone:e,msg:t}),(0,Q.jsx)(Kl,{}),(0,Q.jsx)(Df,{prompt:`按 Enter 返回操作页...`,onSubmit:()=>{r?.(),i(n)}})]})}function kf(e){let t=e.trim();if(t===`y`||t===`Y`)return`y`;if(t===`n`||t===`N`)return`n`}var Af=`错误: 必须选择 y (是) 或 n (否).`,jf=e=>e.type===`input-code`,Mf=e=>e.type===`confirm`,Nf=e=>e.type===`already-exists`||e.type===`done`||e.type===`error`,Pf={stocksAdd:Ad,fetchQuotes:Zd,normalizeCode:Xd,now:()=>new Date().toISOString()},Ff={error:void 0,resetToken:0},If=`无法识别股票代码, 请用英文逗号分隔 6 位股票代码.`;function Lf(e=Pf){let t=0,n=e=>e!==t;return Qu()((r,i)=>{let a=()=>r(e=>({codeInput:{error:If,resetToken:e.codeInput.resetToken+1}}));return{step:{type:`input-code`},codeInput:Ff,confirmInput:Ff,reset:()=>{t+=1,r({step:{type:`input-code`},codeInput:Ff,confirmInput:Ff})},handleCodeInput:async o=>{if(!jf(i().step))return;let s=t,c=o.split(`,`).map(e=>e.trim());if(c.length===0||c.some(e=>e===``)){a();return}let l=c.map(t=>e.normalizeCode(t));if(l.some(e=>e===void 0)){a();return}let u=[...new Set(l)];r(e=>({codeInput:{error:void 0,resetToken:e.codeInput.resetToken+1}})),r({step:{type:`checking`,codes:u}});try{let t=await e.fetchQuotes(u);if(n(s))return;let i=new Map(t.map(e=>[e.code,e])),a=u.filter(e=>!i.has(e));if(a.length>0){r({step:{type:`error`,message:`未找到股票代码: ${a.join(`, `)}.`}});return}r({step:{type:`confirm`,entries:u.map(e=>{let t=i.get(e);return{code:e,name:t.name,current:t.current}})}})}catch(e){n(s)||r({step:{type:`error`,message:sd(e)}})}},handleConfirm:async a=>{let o=kf(a);if(!o){r(e=>({confirmInput:{error:Af,resetToken:e.confirmInput.resetToken+1}}));return}if(r(e=>({confirmInput:{error:void 0,resetToken:e.confirmInput.resetToken+1}})),o===`n`){r({step:{type:`done`,message:`已取消.`}});return}let s=t,c=i().step;if(Mf(c)){r({step:{type:`saving`,entries:c.entries}});try{let t=e.now(),i=await e.stocksAdd(c.entries.map(e=>({code:e.code,name:e.name,addedAt:t})));if(n(s))return;if(i===0){r({step:{type:`already-exists`,entries:c.entries}});return}r({step:{type:`done`,message:`已添加 ${i} 个股票, ${c.entries.length-i} 个已在自选股中.`}})}catch(e){n(s)||r({step:{type:`error`,message:`写入自选股失败: ${sd(e)}`}})}}}}})}var Rf=Lf();function zf(){let e=Rf(e=>e.step),t=Rf(e=>e.codeInput),n=Rf(e=>e.confirmInput),r=Rf(e=>e.handleCodeInput),i=Rf(e=>e.handleConfirm),a=Rf(e=>e.reset);return(0,W.useEffect)(()=>{a()},[a]),{step:e,codeInput:t,confirmInput:n,handleCodeInput:r,handleConfirm:i,reset:a}}function Bf({title:e,hint:t}){let{overlayOpen:n}=lf(),r=ad(),{step:i,codeInput:a,confirmInput:o,handleCodeInput:s,handleConfirm:c,reset:l}=zf(),u;if(Nf(i))u=(0,Q.jsx)(Of,{tone:i.type===`already-exists`?`warning`:i.type===`done`?`success`:`error`,msg:i.type===`already-exists`?`${i.entries.map(e=>`${e.name} (${e.code})`).join(`, `)} 已在自选股中.`:i.message,to:`stock-add`,onReturn:l});else switch(i.type){case`input-code`:u=(0,Q.jsxs)(Q.Fragment,{children:[a.error&&(0,Q.jsx)($,{color:`red`,children:a.error}),(0,Q.jsx)(Df,{prompt:`请输入股票代码, 用英文逗号分隔: `,placeholder:(0,Q.jsx)($,{color:`gray`,children:`支持 600000, sh600000, 600000.SH 等写法`}),onSubmit:s},`code-${a.resetToken}`)]});break;case`checking`:u=(0,Q.jsxs)($,{color:`cyan`,children:[`正在验证股票代码: `,i.codes.join(`, `),`...`]});break;case`confirm`:u=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{color:`cyan`,children:`找到以下股票:`}),i.entries.map(e=>(0,Q.jsxs)($,{children:[e.name,` (`,e.code,`), 现价 `,bu(e.current)]},e.code)),o.error&&(0,Q.jsx)($,{color:`red`,children:o.error}),(0,Q.jsx)(Df,{prompt:`确认添加到自选股? (y/n): `,onSubmit:c},`confirm-${o.resetToken}`)]});break;case`saving`:u=(0,Q.jsxs)($,{color:`cyan`,children:[`正在添加 `,i.entries.length,` 个股票...`]})}return(0,Q.jsx)(ff,{fullScreen:!0,bright:!n,title:(0,Q.jsx)($,{color:r.primary,children:e}),footer:(0,Q.jsx)(_f,{hint:t,bright:!n}),children:u})}function Vf(e){let{segments:t,selected:n,bright:r=!1}=e;return(0,Q.jsx)($,{bright:r,inverse:n,children:t.map((e,t)=>(0,Q.jsx)($,{bright:r,color:e.color,children:e.text},t))})}var Hf=(e,t)=>e+` `.repeat(Math.max(0,t.width-Mt(e))),Uf=e=>e.map((t,n)=>({...t,text:n<e.length-1?`${t.text} `:t.text})),Wf=new Map([{key:`code`,kind:`code`,title:`代码`,width:9,render:e=>e.code},{key:`name`,kind:`name`,title:`名称`,width:9,render:e=>e.name},{key:`current`,kind:`value`,title:`现价`,width:8,render:e=>bu(e.current),color:(e,t)=>Eu(e.change,t)},{key:`changePercent`,kind:`changePercent`,title:`涨跌幅`,width:9,render:e=>Su(e.changePercent),color:(e,t)=>Eu(e.changePercent,t),suspendedText:`停牌`},{key:`change`,kind:`value`,title:`涨跌额`,width:8,render:e=>xu(e.change),color:(e,t)=>Eu(e.change,t)},{key:`open`,kind:`value`,title:`今开`,width:7,render:e=>bu(e.open)},{key:`prevClose`,kind:`value`,title:`昨收`,width:7,render:e=>bu(e.prevClose)},{key:`high`,kind:`value`,title:`最高`,width:7,render:e=>bu(e.high)},{key:`low`,kind:`value`,title:`最低`,width:7,render:e=>bu(e.low)},{key:`volume`,kind:`value`,title:`成交量`,width:11,render:e=>Du(e.volume)},{key:`turnover`,kind:`value`,title:`成交额`,width:9,render:e=>Ou(e.turnover)},{key:`turnoverRate`,kind:`value`,title:`换手率`,width:7,render:e=>ku(e.turnoverRate)},{key:`amplitude`,kind:`value`,title:`振幅`,width:7,render:e=>ku(e.amplitude)},{key:`volumeRatio`,kind:`value`,title:`量比`,width:7,render:e=>Au(e.volumeRatio)},{key:`marketCap`,kind:`value`,title:`总市值`,width:10,render:e=>ju(e.marketCap)}].map(e=>[e.key,e])),Gf=e=>e.map(e=>{let t=Wf.get(e);if(t===void 0)throw Error(`未知行情列: ${e}`);return t}),Kf=[`name`,`code`,`current`,`changePercent`,`change`,`open`,`high`,`low`,`volume`,`turnover`,`turnoverRate`,`marketCap`],qf=[`open`,`prevClose`,`high`,`low`,`volume`,`turnover`,`turnoverRate`,`amplitude`,`volumeRatio`,`marketCap`],Jf=Gf(Kf),Yf=Gf(qf),Xf=e=>e.reduce((e,t)=>e+t.width,0)+(e.length-1),Zf=e=>Uf(e.map(e=>({text:Hf(e.title,e),color:`gray`}))),Qf=(e,t,n=Tu)=>{let r=t.current<=0;return Uf(e.map(e=>({text:Hf(r?e.suspendedText??`--`:e.render(t),e),color:r||!e.color?`gray`:e.color(t,n)})))},$f=(e,t,n)=>Uf(e.map(e=>({text:Hf(e.kind===`code`?t:e.kind===`name`?n:e.kind===`changePercent`?`无数据`:`--`,e),color:`gray`})));function ep(e,{enabled:t=!0,intervalMs:n,restartKey:r,onError:i}){let a=(0,W.useRef)(e),o=(0,W.useRef)(n),s=(0,W.useRef)(i),c=(0,W.useRef)({});(0,W.useEffect)(()=>{a.current=e,o.current=n,s.current=i},[e,n,i]);let l=(0,W.useCallback)(()=>c.current.refresh?.(),[]);return(0,W.useEffect)(()=>{if(!t){c.current={};return}let e=!0,n=!1,r,i,l=()=>{r&&=(clearTimeout(r),void 0)},u=(t=o.current)=>{!e||n||r||(r=setTimeout(()=>{r=void 0,f()},t))},d=async()=>{if(!e||n)return;let t=Date.now();n=!0,i=new AbortController;let r=i;try{await a.current(r.signal)}catch(e){r.signal.aborted||s.current?.(e)}finally{i===r&&(i=void 0),n=!1,u(Math.max(0,o.current-(Date.now()-t)))}},f=()=>void d();return c.current={refresh:()=>{n||(l(),f())},reschedule:()=>{n||(l(),u())}},f(),()=>{e=!1,c.current={},l(),i?.abort()}},[t,r]),(0,W.useEffect)(()=>{c.current.reschedule?.()},[n]),{refresh:l}}var tp={fetchQuotes:Zd,loadStocks:kd},np=(e,t)=>Math.min(Math.max(e,0),t-1),rp=(e,t,n,r,i)=>{let a=np(t+e,n),o=Math.max(0,n-i);return e===1&&a>=r+i?Math.min(a-i+1,o):e===-1&&a<r?a:Math.min(r,o)},ip=(e,t)=>{if(!t)return 0;let n=e.findIndex(e=>e.code===t);return n<0?0:n},ap=(e,t)=>e.code===t.code&&e.name===t.name&&e.current===t.current&&e.prevClose===t.prevClose&&e.open===t.open&&e.high===t.high&&e.low===t.low&&e.change===t.change&&e.changePercent===t.changePercent&&e.timestamp===t.timestamp&&e.volume===t.volume&&e.turnover===t.turnover&&e.turnoverRate===t.turnoverRate&&e.amplitude===t.amplitude&&e.marketCap===t.marketCap&&e.volumeRatio===t.volumeRatio;function op(e=tp){return Qu()((t,n)=>({step:{type:`loading`},selectedCode:void 0,scrollOffset:0,refreshQuotes:async n=>{try{let r=await e.loadStocks();if(n?.aborted)return;if(r.length===0){t({step:{type:`empty`},selectedCode:void 0,scrollOffset:0});return}let i=await e.fetchQuotes(r.map(e=>e.code),n);if(n?.aborted)return;t(e=>{let t=e.step.type===`table`?e.step.rows:[],n=new Map(t.filter(e=>e.kind===`quote`).map(e=>[e.code,e.quote])),a=new Map(i.map(e=>{let t=n.get(e.code);return[e.code,t&&ap(t,e)?t:e]})),o=r.map(e=>{let t=a.get(e.code);return t?{kind:`quote`,code:e.code,name:t.name,quote:t}:{kind:`missing`,code:e.code,name:e.name}}),s=ip(t,e.selectedCode),c=e.selectedCode?o.findIndex(t=>t.code===e.selectedCode):-1,l=c>=0?c:np(s,o.length),u=Math.max(0,s-e.scrollOffset);return{step:{type:`table`,rows:o},selectedCode:o[l]?.code,scrollOffset:Math.max(0,l-u)}})}catch(e){if(n?.aborted)return;let r=sd(e);t(e=>e.step.type===`table`?{step:{...e.step,errorLine:r}}:{step:{type:`error`,message:r}})}},moveSelection:(e,r)=>{let{step:i,selectedCode:a,scrollOffset:o}=n();if(i.type!==`table`||i.rows.length===0)return;let s=ip(i.rows,a),c=np(s+e,i.rows.length);t({selectedCode:i.rows[c]?.code,scrollOffset:rp(e,s,i.rows.length,o,r)})}}))}var sp=op(),cp=(e,t,n)=>{if(e<=n)return{start:0,end:e};let r=e-n,i=Math.min(Math.max(t,0),r);return{start:i,end:i+n}};function lp(){let e=(0,W.useRef)(null),t=yu(e),n=sp(e=>e.step),r=sp(e=>e.selectedCode),i=sp(e=>e.scrollOffset),a=id(e=>e.quotePollIntervalMs),o=sp(e=>e.moveSelection),{overlayOpen:s}=lf(),c=t.hasMeasured?Math.max(1,Math.floor(t.height)):1,l=n.type===`table`?cp(n.rows.length,i,c):{start:0,end:0};(0,W.useEffect)(()=>{sp.setState({step:{type:`loading`}})},[]);let{refresh:u}=ep(e=>sp.getState().refreshQuotes(e),{intervalMs:a});return pu((e,t)=>{if(!t.ctrl){if(t.upArrow)o(-1,c);else if(t.downArrow)o(1,c);else if(t.return){let e=sp.getState();if(e.step.type!==`table`||!e.selectedCode)return;let t=e.step.rows.find(t=>t.code===e.selectedCode);t&&cf.getState().open(t.code,t.name)}else e===`r`&&u()}},{isActive:!s}),{rowsRef:e,step:n,selectedCode:r,window:l}}function up({title:e,hint:t}){let{overlayOpen:n}=lf(),r=ad(),i=id(e=>e.trendColorMode),{rowsRef:a,step:o,selectedCode:s,window:c}=lp(),l;switch(o.type){case`loading`:l=(0,Q.jsx)($,{color:`cyan`,children:`正在获取行情数据...`});break;case`empty`:l=(0,Q.jsx)($,{color:`yellow`,children:`自选股为空, 按 esc 打开菜单添加自选股.`});break;case`error`:l=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{color:`red`,children:o.message}),(0,Q.jsx)($,{color:`gray`,children:`行情接口异常, 稍后自动重试`})]});break;case`table`:l=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Vf,{segments:Zf(Jf)}),(0,Q.jsx)(fl,{ref:a,flexDirection:`column`,flexGrow:1,overflow:`hidden`,children:o.rows.slice(c.start,c.end).map(e=>(0,Q.jsx)(Vf,{segments:e.kind===`quote`?Qf(Jf,e.quote,i):$f(Jf,e.code,e.name),selected:e.code===s},e.code))}),o.errorLine?(0,Q.jsxs)($,{color:`yellow`,children:[`刷新失败: `,o.errorLine,`, 稍后自动重试`]}):void 0]})}return(0,Q.jsx)(ff,{fullScreen:!0,bright:!n,title:(0,Q.jsx)($,{color:r.primary,children:e}),footer:(0,Q.jsx)(_f,{hint:t,bright:!n}),children:l})}function dp(e){return(0,Q.jsx)(fl,{flexGrow:1,flexBasis:0,minWidth:0,...e})}function fp({label:e,hint:t,selected:n,cursor:r}){let i=ad();return(0,Q.jsx)(dp,{children:(0,Q.jsxs)($,{inverse:r,wrap:`truncate-end`,children:[(0,Q.jsxs)($,{color:n?i.primary:void 0,children:[n?`[x] `:`[ ] `,e]}),t?(0,Q.jsxs)($,{color:`gray`,children:[` (`,t,`)`]}):void 0]})})}function pp(e,t=3){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function mp(e,t,n){if(t<=0)return 0;let r=Math.min(Math.max(e,0),t-1),i=r%3;return n===`left`?i>0?r-1:r:n===`right`?i<2&&r+1<t?r+1:r:n===`up`?r-3>=0?r-3:r:r+3<t?r+3:r}function hp(e,t,n,r){let i=Math.max(0,t-r),a=Math.floor(Math.max(e,0)/3),o=Math.min(Math.max(n,0),i);return a<o?o=a:a>=o+r&&(o=a-r+1),Math.min(Math.max(o,0),i)}function gp(e,t,n){if(e<=n)return{start:0,end:e};let r=e-n,i=Math.min(Math.max(t,0),r);return{start:i,end:i+n}}function _p({items:e,getKey:t,isActive:n,onSubmit:r}){let i=(0,W.useRef)(null),a=yu(i),[o,s]=(0,W.useState)(0),[c,l]=(0,W.useState)(0),[u,d]=(0,W.useState)(()=>new Set),f=e.length,p=a.hasMeasured?Math.max(1,Math.floor(a.height)):1,m=Math.ceil(f/3),h=gp(m,c,p);return pu((n,i)=>{if(!i.ctrl){if(i.leftArrow||i.rightArrow||i.upArrow||i.downArrow){let e=i.leftArrow?`left`:i.rightArrow?`right`:i.upArrow?`up`:`down`,t=mp(o,f,e);s(t),l(hp(t,m,c,Math.max(1,p)))}else if(n===` `){let n=e[o];if(!n)return;let r=t(n);d(e=>{let t=new Set(e);return t.has(r)?t.delete(r):t.add(r),t})}else if(i.return){let n=e.filter(e=>u.has(t(e)));n.length>0&&r(n)}}},{isActive:n}),{gridRef:i,cursor:o,selectedKeys:u,visibleRange:h}}function vp(e){let{items:t,getKey:n,getLabel:r,getHint:i,isActive:a,onSubmit:o}=e,{gridRef:s,cursor:c,selectedKeys:l,visibleRange:u}=_p({items:t,getKey:n,isActive:a,onSubmit:o}),d=pp(t);return(0,Q.jsx)(fl,{ref:s,flexDirection:`column`,flexGrow:1,overflow:`hidden`,children:d.slice(u.start,u.end).map((e,t)=>{let o=u.start+t;return(0,Q.jsx)(fl,{columnGap:2,children:Array.from({length:3},(t,s)=>{let u=e[s];if(!u)return(0,Q.jsx)(dp,{},`empty-${s}`);let d=o*3+s,f=n(u);return(0,Q.jsx)(fp,{label:r(u),hint:i?.(u),selected:l.has(f),cursor:a&&d===c},f)})},o)})})}function yp(){let e=Pd(e=>e.entries),t=Pd(e=>e.errorMessage),n=Pd(e=>e.resetToken),r=Pd(e=>e.loadEntries),i=zd(e=>e.open);return(0,W.useEffect)(()=>{r()},[r]),{entries:e,errorMessage:t,resetToken:n,open:i}}function bp({title:e,hint:t}){let{overlayOpen:n}=lf(),r=ad(),{entries:i,errorMessage:a,resetToken:o,open:s}=yp(),c;return c=i.length===0?a?(0,Q.jsx)($,{color:`red`,children:a}):(0,Q.jsx)($,{color:`yellow`,children:`自选股为空, 按 esc 打开菜单添加自选股.`}):(0,Q.jsx)(vp,{items:i,getKey:e=>e.code,getLabel:e=>e.name,getHint:e=>e.code,isActive:!n,onSubmit:s},o),(0,Q.jsx)(ff,{fullScreen:!0,bright:!n,title:(0,Q.jsx)($,{color:r.primary,children:e}),footer:(0,Q.jsx)(_f,{hint:t,bright:!n}),children:c})}var xp={"stock-list":{Component:up,title:`自选股票看板`,description:`自选股票看板`,hint:`菜单(esc) 刷新(r) 选择(↑/↓) 详情(enter) 退出(q)`,menuLabel:`自选股票看板`},"stock-add":{Component:Bf,title:`添加自选股`,description:`添加自选股`,hint:`菜单(esc) 退出(q)`,menuLabel:`添加自选股`},"stock-remove":{Component:bp,title:`删除自选股`,description:`删除自选股`,hint:`菜单(esc) 移动(↑/↓/←/→) 选择(空格) 删除(enter) 退出(q)`,menuLabel:`删除自选股`},settings:{Component:Cf,title:`设置`,description:`配置主题, 涨跌颜色与请求参数`,hint:`菜单(esc) 选择(↑/↓) 调整(←/→/enter) 默认值(d) 退出(q)`,menuLabel:`设置`}},Sp=Object.keys(xp),Cp=e=>e!==void 0&&Object.hasOwn(xp,e),wp=e=>Cp(e)?e:`stock-list`;function Tp(e){let{title:t,extra:n,hint:r,width:i,children:a}=e,{rows:o,columns:s}=gu();return(0,Q.jsx)(fl,{position:`absolute`,top:0,left:0,width:s,height:o,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,children:(0,Q.jsx)(ff,{bright:!0,title:t,extra:n,width:i,backgroundColor:`black`,footer:(0,Q.jsx)(_f,{hint:r,bright:!0}),children:a})})}var Ep=[...Object.entries(xp).map(([e,t],n)=>({label:`${n+1}) ${t.menuLabel}`,screen:e})),{label:`${Object.keys(xp).length+1}) 退出程序`,screen:void 0}],Dp=45;function Op(){let e=wf(e=>e.goTo),t=od(e=>e.close),{exit:n}=mu(),[r,i]=(0,W.useState)(0),a=r=>{r.screen?(t(),e(r.screen)):n()};return pu((e,t)=>{if(t.upArrow)i(e=>(e+Ep.length-1)%Ep.length);else if(t.downArrow)i(e=>(e+1)%Ep.length);else if(t.return)a(Ep[r]);else if(/^[1-9]$/.test(e)){let t=Number(e)-1,n=Ep[t];if(!n)return;i(t),a(n)}}),{width:Dp,menuItems:Ep,highlight:r}}function kp(){let{highlight:e,width:t,menuItems:n}=Op(),r=ad();return(0,Q.jsx)(Tp,{title:(0,Q.jsx)($,{bright:!0,color:r.primary,children:`菜单`}),width:t,children:n.map((t,n)=>(0,Q.jsxs)($,{bright:!0,color:n===e?`black`:void 0,backgroundColor:n===e?r.highlight:void 0,children:[n===e?`> `:` `,t.label]},t.label))})}function Ap(){let e=zd(e=>e.step),t=zd(e=>e.targets);if(pu((e,t)=>{if(t.ctrl)return;let n=zd.getState();e===`y`||e===`Y`?n.confirmDelete():(e===`n`||e===`N`)&&n.cancel()},{isActive:Fd(e)}),Id(e))return{stage:e.type,entries:t,message:e.type===`done`||e.type===`error`?e.message:void 0}}var jp=`取消(esc/n) 确定(y)`,Mp=`关闭(esc)`,Np=60,Pp=22;function Fp(){let e=ad(),{columns:t}=gu(),n=Ap();if(!n)return;let{stage:r,entries:i,message:a}=n,o=i.length,s=r===`error`,c=r===`done`,l=s?`删除失败`:c?`删除完成`:r===`removing`?`正在删除 ${o} 个股票...`:`确定删除选中的 ${o} 个股票?`,u=s||c?a:i.map(e=>`${e.name} (${e.code})`).join(`, `),d=r===`confirm`?jp:s||c?Mp:void 0,f=Math.max(Mt(l),Math.min(Mt(u??``),Np),Mt(d??``)+Pp,24),p=Math.min(Math.max(t-2,1),f+4+6);return(0,Q.jsx)(Tp,{title:(0,Q.jsx)($,{bright:!0,color:s?`red`:e.primary,children:l}),hint:d,width:p,children:(0,Q.jsx)($,{bright:!0,color:s?`red`:c?e.primary:`gray`,children:u})})}var Ip=e=>{if(!/^\d{4}$/.test(e))return;let t=Number(e.slice(0,2))*60+Number(e.slice(2))-570;return t<0?0:t>120?t-90:t},Lp=(e,t)=>{if(t<=0)return[];let n=Array.from({length:t},()=>({sum:0,count:0,minPrice:0,maxPrice:0,lastPrice:0,volume:0})),r=-1,i=0;for(let a of e){let e=Ip(a.time);if(e===void 0)continue;let o=Math.min(t-1,Math.floor(e/240*t)),s=n[o];s.sum+=a.price,s.count+=1,s.minPrice=s.count===1?a.price:Math.min(s.minPrice,a.price),s.maxPrice=s.count===1?a.price:Math.max(s.maxPrice,a.price),s.lastPrice=a.price,s.volume+=Math.max(0,a.volume-i),i=a.volume,r=Math.max(r,o)}let a=[],o=0;for(let e=0;e<t;e++){let t=n[e];t.count>0?(o=t.lastPrice,a.push({avgPrice:t.sum/t.count,maxPrice:t.maxPrice,minPrice:t.minPrice,lastPrice:t.lastPrice,volume:t.volume})):e<r?a.push({avgPrice:o,maxPrice:o,minPrice:o,lastPrice:o,volume:0}):a.push({avgPrice:0,maxPrice:0,minPrice:0,lastPrice:0,volume:0})}return a},Rp=e=>`date`in e,zp=e=>`sessionDate`in e,Bp=e=>!Rp(e)&&!zp(e),Vp=(e,t)=>{let n=new Map;for(let t of e){let e=n.get(t.sessionDate)??[];e.push(t),n.set(t.sessionDate,e)}let r=[...n.entries()].sort(([e],[t])=>e.localeCompare(t));if(r.length===0)return Array.from({length:t},()=>({avgPrice:0,maxPrice:0,minPrice:0,lastPrice:0,volume:0}));let i=[];for(let e=0;e<r.length;e++){let n=Math.floor(e/r.length*t),a=Math.floor((e+1)/r.length*t)-n;if(a<=0)continue;let o=r[e][1].sort((e,t)=>e.time.localeCompare(t.time));i.push(...Lp(o,a))}return i},Hp=(e,t)=>e.length===0?Array.from({length:t},()=>({avgPrice:0,maxPrice:0,minPrice:0,lastPrice:0,volume:0})):Array.from({length:t},(n,r)=>{let i=t<=1?0:r/(t-1)*(e.length-1),a=e[Math.floor(i)],o=e[Math.min(Math.ceil(i),e.length-1)],s=i-Math.floor(i),c=a.close+(o.close-a.close)*s,l=e[Math.round(i)];return{avgPrice:c,maxPrice:Math.max(a.high,o.high),minPrice:Math.min(a.low,o.low),lastPrice:c,volume:l.volume}}),Up=(e,t)=>t<3?1<<t+e*3:1<<6+e,Wp=e=>String.fromCharCode(10240+e),Gp=e=>{let{points:t,period:n,prevClose:r,width:i,priceHeight:a,volumeHeight:o,trendColorMode:s=Tu}=e,c=t.filter(Bp),l=t.filter(zp),u=t.filter(Rp),d=n===`intraday`,f=n===`five-day`,p=d?Lp(c,i):f?Vp(l,i):Hp(u,i),m=d?r:f?l[0]?.prevClose:u[0]?.close,h=d?r:void 0,g=1/0,_=-1/0;for(let e of p)e.avgPrice<=0||(g=Math.min(g,e.minPrice),_=Math.max(_,e.maxPrice));h!==void 0&&(g=Math.min(g,h),_=Math.max(_,h)),Number.isFinite(g)||(g=0,_=1),_===g&&(_+=1);let v=a*4,y=i*2,b=e=>Math.round((_-e)/(_-g)*(v-1)),x=(e,t)=>t===void 0?`gray`:Eu(e-t,s),S=x(p.map(e=>e.lastPrice).filter(e=>e>0).at(-1)??0,m),C=p.map((e,t)=>{if(d)return S;if(e.lastPrice<=0)return`gray`;let n=p[t+1]?.lastPrice;if(n!==void 0&&n>0)return x(n,e.lastPrice);let r=p[t-1]?.lastPrice;return x(e.lastPrice,r!==void 0&&r>0?r:void 0)}),w=Array.from({length:a+o+1},()=>Array.from({length:i},()=>({ch:` `,color:void 0}))),T=Array.from({length:a},()=>new Uint16Array(i)),E=-1;for(let e=0;e<i;e++)p[e].avgPrice>0&&(E=e);let D;for(let e=0;e<y;e++){let t=e/2;if(t>E){D=void 0;continue}let n=p[Math.floor(t)];if(n.avgPrice<=0){D=void 0;continue}let r=p[Math.min(Math.floor(t)+1,i-1)],a=b(r.avgPrice>0?n.lastPrice+(r.lastPrice-n.lastPrice)*(t-Math.floor(t)):n.lastPrice),o=Math.floor(e/2),s=T[Math.floor(a/4)];if(s[o]=s[o]|Up(e%2,a%4),D!==void 0){let t=Math.min(D,a),n=Math.max(D,a);for(let r=t+1;r<n;r++){let t=T[Math.floor(r/4)];t[o]=t[o]|Up(e%2,r%4)}}D=a}let O=Array.from({length:a},()=>new Uint16Array(i));if(h!==void 0){let e=b(h),t=Math.floor(e/4);for(let n=0;n<y;n++){if(n%3==2)continue;let r=Math.floor(n/2);if(T[t][r]!==0)continue;let i=O[t];i[r]=i[r]|Up(n%2,e%4)}}for(let e=0;e<a;e++)for(let t=0;t<i;t++){let n=T[e][t]|O[e][t];n!==0&&(w[e][t]={ch:Wp(n),color:T[e][t]===0?`gray`:C[t]})}let k=Array.from({length:o},()=>new Uint16Array(i)),A=Math.max(...p.map(e=>e.volume),0);for(let e=0;e<i;e++){let t=p[e];if(t.volume<=0||A<=0)continue;let n=o*4,r=Math.max(1,Math.round(t.volume/A*n));for(let t=n-r;t<n;t++){let n=k[Math.floor(t/4)];n[e]=n[e]|Up(0,t%4)|Up(1,t%4)}}let j=Array.from({length:i},()=>void 0),M=m;for(let e=0;e<i;e++){let t=p[e];t.lastPrice<=0||(j[e]=M===void 0?`gray`:Eu(t.lastPrice-M,s),M=t.lastPrice)}for(let e=0;e<o;e++)for(let t=0;t<i;t++){let n=k[e][t];n!==0&&(w[a+e][t]={ch:Wp(n),color:j[t]})}let N=[],P=(e,t)=>Math.max(0,Math.min(i-t.length,e-Math.floor(t.length/2)));if(d)N.push({col:0,labelCol:0,label:`09:30`},{col:Math.floor(i/2),labelCol:Math.max(0,Math.floor((i-11)/2)),label:`11:30/13:00`},{col:i-1,labelCol:Math.max(0,i-5),label:`15:00`});else if(f&&l.length>0){let e=[...new Set(l.map(e=>e.sessionDate))].sort();for(let t=0;t<e.length;t++){let n=Math.min(i-1,Math.floor((t+.5)/e.length*i)),r=e[t].slice(5);N.push({col:n,labelCol:P(n,r),label:r})}}else if(u.length>0){let e=e=>n===`year`?e.date.slice(0,4):n===`month`?e.date.slice(0,7):n===`week`?e.date.slice(2):e.date.slice(5),t=e(u[0]),r=e(u[Math.floor((u.length-1)/2)]),a=e(u.at(-1));N.push({col:0,labelCol:0,label:t},{col:Math.floor(i/2),labelCol:Math.max(0,Math.floor((i-r.length)/2)),label:r},{col:i-1,labelCol:Math.max(0,i-a.length),label:a})}for(let{col:e}of N)for(let t=0;t<a+o;t++)w[t][e].ch===` `&&(w[t][e]={ch:`┊`,color:`gray`});let F=w[a+o],I=(e,t)=>{for(let n=0;n<t.length&&e+n<i;n++)F[e+n]={ch:t[n],color:`gray`}};for(let e of N)I(e.labelCol,e.label);return w},Kp=9,qp=4;function Jp({points:e,period:t,prevClose:n,width:r,priceHeight:i=Kp,volumeHeight:a=qp,bright:o=!1,trendColorMode:s}){let c=Gp({points:e,period:t,prevClose:n,width:r,priceHeight:i,volumeHeight:a,trendColorMode:s});return(0,Q.jsx)(fl,{flexDirection:`column`,children:c.map((e,t)=>{let n=[];for(let t of e){let e=n.at(-1);e&&e.color===t.color?e.text+=t.ch:n.push({text:t.ch,color:t.color})}return(0,Q.jsx)($,{bright:o,children:n.map((e,t)=>(0,Q.jsx)($,{bright:o,color:e.color,children:e.text},t))},t)})})}var Yp=new Map([[`sh`,`沪`],[`sz`,`深`],[`bj`,`北`]]);function Xp({code:e,bright:t=!1}){let n=e.slice(0,2).toLowerCase(),r=Yp.get(n);if(r)return(0,Q.jsx)($,{bright:t,color:`white`,backgroundColor:`red`,children:r})}var Zp=[{key:`1`,value:`intraday`,label:`分时`},{key:`2`,value:`five-day`,label:`五日`},{key:`3`,value:`day`,label:`日K`},{key:`4`,value:`week`,label:`周K`},{key:`5`,value:`month`,label:`月K`},{key:`6`,value:`year`,label:`年K`}];function Qp(){let e=cf(e=>e.stock),t=cf(e=>e.period),n=cf(e=>e.status),r=cf(e=>e.points),i=cf(e=>e.errorMessage),a=id(e=>e.minuteChartPollIntervalMs),o=id(e=>e.klinePollIntervalMs),s=od(e=>e.open),c=sp(t=>{if(t.step.type!==`table`)return;let n=t.step.rows.find(t=>t.code===e?.code);return n?.kind===`quote`?n.quote:void 0});if(pu((e,t)=>{if(t.ctrl)return;let n=Zp.find(t=>t.key===e);n&&cf.getState().setPeriod(n.value)},{isActive:e!==void 0&&!s}),ep(async n=>{e&&await cf.getState().refreshChart(e.code,t,n)},{enabled:e!==void 0,intervalMs:t===`intraday`||t===`five-day`?a:o,restartKey:e?`${e.code}:${t}`:void 0}),e)return{stock:e,quote:c,suspended:c?c.current<=0:!1,period:t,status:n,points:r,errorMessage:i}}var $p=Xf(Yf)+4+6,em=$p-4;function tm(){let e=id(e=>e.trendColorMode),t=Qp();if(!t)return;let{stock:n,quote:r,suspended:i,period:a,status:o,points:s,errorMessage:c}=t,l=Zp.find(e=>e.value===a)?.label??``;return(0,Q.jsxs)(Tp,{title:(0,Q.jsxs)($,{bright:!0,children:[(0,Q.jsx)(Xp,{code:n.code,bright:!0}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{bright:!0,children:n.name}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{bright:!0,color:`gray`,children:n.code}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{bright:!0,color:!r||i?`gray`:Eu(r.change,e),children:r?bu(r.current):`--`}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{bright:!0,color:!r||i?`gray`:Eu(r.changePercent,e),children:r?i?`停牌`:Su(r.changePercent):`--`}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{bright:!0,color:!r||i?`gray`:Eu(r.change,e),children:r?xu(r.change):`--`})]}),extra:(0,Q.jsx)($,{bright:!0,children:Zp.map((e,t)=>(0,Q.jsxs)($,{bright:!0,color:e.value===a?`cyan`:`gray`,children:[t>0?` `:``,`[`,e.key,`]`,e.label]},e.value))}),width:$p,children:[(0,Q.jsxs)(fl,{flexDirection:`column`,children:[(0,Q.jsx)(Vf,{bright:!0,segments:Zf(Yf)}),(0,Q.jsx)(Vf,{bright:!0,segments:r?Qf(Yf,r,e):$f(Yf,n.code,n.name)})]}),(0,Q.jsx)(fl,{marginTop:1,height:14,children:o===`loading`?(0,Q.jsxs)($,{bright:!0,color:`gray`,children:[`正在获取`,l,`行情...`]}):o===`error`?(0,Q.jsx)($,{bright:!0,color:`red`,children:c}):s.length===0?(0,Q.jsxs)($,{bright:!0,color:`gray`,children:[`暂无`,l,`行情数据`]}):(0,Q.jsx)(Jp,{bright:!0,points:s,period:a,prevClose:r?.prevClose,trendColorMode:e,width:em})})]})}var nm=Xf(Jf)+4;function rm({children:e}){let{columns:t,rows:n}=gu(),r=t>=nm,i=n>=26;return r&&i?e:(0,Q.jsxs)(fl,{width:t,height:n,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,children:[(0,Q.jsx)($,{color:`yellow`,children:`终端尺寸过小:`}),(0,Q.jsxs)(fl,{children:[(0,Q.jsx)($,{color:r?`green`:`red`,children:`宽度 = ${t}`}),(0,Q.jsx)($,{children:` `}),(0,Q.jsx)($,{color:i?`green`:`red`,children:`高度 = ${n}`})]}),(0,Q.jsx)(fl,{height:1}),(0,Q.jsx)($,{color:`gray`,children:`所需最小尺寸:`}),(0,Q.jsx)($,{color:`gray`,children:`宽度 = ${nm} 高度 = 26`})]})}function im(){let{exit:e}=mu(),{overlayOpen:t,dialogMenuOpen:n,dialogStockDetailOpen:r,dialogRemoveConfirmOpen:i}=lf(),a=xp[wf(e=>e.screen)];return pu((n,i)=>{if(i.escape){if(r){cf.getState().close();return}let e=zd.getState().step;if(e.type===`confirm`){zd.getState().cancel();return}if(e.type===`done`||e.type===`error`){zd.getState().dismiss();return}if(Id(e))return;od.getState().toggle();return}n===`q`&&!t&&e()}),(0,Q.jsxs)(rm,{children:[(0,Q.jsx)(a.Component,{title:a.title,hint:a.hint}),n&&(0,Q.jsx)(kp,{}),r&&(0,Q.jsx)(tm,{}),i&&(0,Q.jsx)(Fp,{})]})}function am(e){if((e===e.toLowerCase()||e===e.toUpperCase())&&(e=e.toLowerCase()),e.indexOf(`-`)===-1&&e.indexOf(`_`)===-1)return e;{let t=``,n=!1,r=e.match(/^-+/);for(let i=r?r[0].length:0;i<e.length;i++){let r=e.charAt(i);n&&(n=!1,r=r.toUpperCase()),i!==0&&(r===`-`||r===`_`)?n=!0:r!==`-`&&r!==`_`&&(t+=r)}return t}}function om(e,t){let n=e.toLowerCase();t||=`-`;let r=``;for(let i=0;i<e.length;i++){let a=n.charAt(i),o=e.charAt(i);r+=a!==o&&i>0?`${t}${n.charAt(i)}`:o}return r}function sm(e){return e==null?!1:typeof e==`number`||/^0x[0-9a-f]+$/i.test(e)?!0:!/^0[^.]/.test(e)&&/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function cm(e){if(Array.isArray(e))return e.map(e=>typeof e==`string`?e:e+``);e=e.trim();let t=0,n=null,r=null,i=null,a=[];for(let o=0;o<e.length;o++){if(n=r,r=e.charAt(o),r===` `&&!i){n!==` `&&t++;continue}r===i?i=null:(r===`'`||r===`"`)&&!i&&(i=r),a[t]||(a[t]=``),a[t]+=r}return a}var lm;(function(e){e.BOOLEAN=`boolean`,e.STRING=`string`,e.NUMBER=`number`,e.ARRAY=`array`})(lm||={});var um,dm=class{constructor(e){um=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),r=cm(e),i=typeof e==`string`,a=fm(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":`no-`,"parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),s=Object.assign(Object.create(null),n.default),c=n.configObjects||[],l=n.envPrefix,u=o[`populate--`],d=u?`--`:`_`,f=Object.create(null),p=Object.create(null),m=n.__||um.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},g=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,_=RegExp(`^--`+o[`negation-prefix`]+`(.+)`);[].concat(n.array||[]).filter(Boolean).forEach(function(e){let t=typeof e==`object`?e.key:e,n=Object.keys(e).map(function(e){return{boolean:`bools`,string:`strings`,number:`numbers`}[e]}).filter(Boolean).pop();n&&(h[n][t]=!0),h.arrays[t]=!0,h.keys.push(t)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(e){h.bools[e]=!0,h.keys.push(e)}),[].concat(n.string||[]).filter(Boolean).forEach(function(e){h.strings[e]=!0,h.keys.push(e)}),[].concat(n.number||[]).filter(Boolean).forEach(function(e){h.numbers[e]=!0,h.keys.push(e)}),[].concat(n.count||[]).filter(Boolean).forEach(function(e){h.counts[e]=!0,h.keys.push(e)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(e){h.normalize[e]=!0,h.keys.push(e)}),typeof n.narg==`object`&&Object.entries(n.narg).forEach(([e,t])=>{typeof t==`number`&&(h.nargs[e]=t,h.keys.push(e))}),typeof n.coerce==`object`&&Object.entries(n.coerce).forEach(([e,t])=>{typeof t==`function`&&(h.coercions[e]=t,h.keys.push(e))}),n.config!==void 0&&(Array.isArray(n.config)||typeof n.config==`string`?[].concat(n.config).filter(Boolean).forEach(function(e){h.configs[e]=!0}):typeof n.config==`object`&&Object.entries(n.config).forEach(([e,t])=>{(typeof t==`boolean`||typeof t==`function`)&&(h.configs[e]=t)})),L(n.key,a,n.default,h.arrays),Object.keys(s).forEach(function(e){(h.aliases[e]||[]).forEach(function(t){s[t]=s[e]})});let v=null;oe();let y=[],b=Object.assign(Object.create(null),{_:[]}),x={};for(let e=0;e<r.length;e++){let t=r[e],n=t.replace(/^-{3,}/,`---`),i,a,s,c,l,u;if(t!==`--`&&/^-/.test(t)&&ne(t))S(t);else if(n.match(/^---+(=|$)/)){S(t);continue}else if(t.match(/^--.+=/)||!o[`short-option-groups`]&&t.match(/^-.+=/))c=t.match(/^--?([^=]+)=([\s\S]*)$/),c!==null&&Array.isArray(c)&&c.length>=3&&(R(c[1],h.arrays)?e=w(e,c[1],r,c[2]):R(c[1],h.nargs)===!1?T(c[1],c[2],!0):e=C(e,c[1],r,c[2]));else if(t.match(_)&&o[`boolean-negation`])c=t.match(_),c!==null&&Array.isArray(c)&&c.length>=2&&(a=c[1],T(a,R(a,h.arrays)?[!1]:!1));else if(t.match(/^--.+/)||!o[`short-option-groups`]&&t.match(/^-[^-]+/))c=t.match(/^--?(.+)/),c!==null&&Array.isArray(c)&&c.length>=2&&(a=c[1],R(a,h.arrays)?e=w(e,a,r):R(a,h.nargs)===!1?(l=r[e+1],l!==void 0&&(!l.match(/^-/)||l.match(g))&&!R(a,h.bools)&&!R(a,h.counts)||/^(true|false)$/.test(l)?(T(a,l),e++):T(a,re(a))):e=C(e,a,r));else if(t.match(/^-.\..+=/))c=t.match(/^-([^=]+)=([\s\S]*)$/),c!==null&&Array.isArray(c)&&c.length>=3&&T(c[1],c[2]);else if(t.match(/^-.\..+/)&&!t.match(g))l=r[e+1],c=t.match(/^-(.\..+)/),c!==null&&Array.isArray(c)&&c.length>=2&&(a=c[1],l!==void 0&&!l.match(/^-/)&&!R(a,h.bools)&&!R(a,h.counts)?(T(a,l),e++):T(a,re(a)));else if(t.match(/^-[^-]+/)&&!t.match(g)){s=t.slice(1,-1).split(``),i=!1;for(let n=0;n<s.length;n++){if(l=t.slice(n+2),s[n+1]&&s[n+1]===`=`){u=t.slice(n+3),a=s[n],R(a,h.arrays)?e=w(e,a,r,u):R(a,h.nargs)===!1?T(a,u):e=C(e,a,r,u),i=!0;break}if(l===`-`){T(s[n],l);continue}if(/[A-Za-z]/.test(s[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&R(l,h.bools)===!1){T(s[n],l),i=!0;break}if(s[n+1]&&s[n+1].match(/\W/)){T(s[n],l),i=!0;break}T(s[n],re(s[n]))}a=t.slice(-1)[0],!i&&a!==`-`&&(R(a,h.arrays)?e=w(e,a,r):R(a,h.nargs)===!1?(l=r[e+1],l!==void 0&&(!/^(-|--)[^-]/.test(l)||l.match(g))&&!R(a,h.bools)&&!R(a,h.counts)||/^(true|false)$/.test(l)?(T(a,l),e++):T(a,re(a))):e=C(e,a,r))}else if(t.match(/^-[0-9]$/)&&t.match(g)&&R(t.slice(1),h.bools))a=t.slice(1),T(a,re(a));else if(t===`--`){y=r.slice(e+1);break}else if(o[`halt-at-non-option`]){y=r.slice(e);break}else S(t)}M(b,!0),M(b,!1),k(b),j(),F(b,h.aliases,s,!0),N(b),o[`set-placeholder-key`]&&P(b),Object.keys(h.counts).forEach(function(e){I(b,e.split(`.`))||T(e,0)}),u&&y.length&&(b[d]=[]),y.forEach(function(e){b[d].push(e)}),o[`camel-case-expansion`]&&o[`strip-dashed`]&&Object.keys(b).filter(e=>e!==`--`&&e.includes(`-`)).forEach(e=>{delete b[e]}),o[`strip-aliased`]&&[].concat(...Object.keys(a).map(e=>a[e])).forEach(e=>{o[`camel-case-expansion`]&&e.includes(`-`)&&delete b[e.split(`.`).map(e=>am(e)).join(`.`)],delete b[e]});function S(e){let t=O(`_`,e);(typeof t==`string`||typeof t==`number`)&&b._.push(t)}function C(e,t,n,r){let i,a=R(t,h.nargs);if(a=typeof a!=`number`||isNaN(a)?1:a,a===0)return ae(r)||(v=Error(m(`Argument unexpected for: %s`,t))),T(t,re(t)),e;let s=+!ae(r);if(o[`nargs-eats-options`])n.length-(e+1)+s<a&&(v=Error(m(`Not enough arguments following: %s`,t))),s=a;else{for(i=e+1;i<n.length&&(!n[i].match(/^-[^0-9]/)||n[i].match(g)||ne(n[i]));i++)s++;s<a&&(v=Error(m(`Not enough arguments following: %s`,t)))}let c=Math.min(s,a);for(!ae(r)&&c>0&&(T(t,r),c--),i=e+1;i<c+e+1;i++)T(t,n[i]);return e+c}function w(e,t,n,r){let a=[],c=r||n[e+1],l=R(t,h.nargs);if(R(t,h.bools)&&!/^(true|false)$/.test(c))a.push(!0);else if(ae(c)||ae(r)&&/^-/.test(c)&&!g.test(c)&&!ne(c)){if(s[t]!==void 0){let e=s[t];a=Array.isArray(e)?e:[e]}}else{ae(r)||a.push(D(t,r,!0));for(let r=e+1;r<n.length&&!(!o[`greedy-arrays`]&&a.length>0||l&&typeof l==`number`&&a.length>=l||(c=n[r],/^-/.test(c)&&!g.test(c)&&!ne(c)));r++)e=r,a.push(D(t,c,i))}return typeof l==`number`&&(l&&a.length<l||isNaN(l)&&a.length===0)&&(v=Error(m(`Not enough arguments following: %s`,t))),T(t,a),e}function T(e,t,n=i){/-/.test(e)&&o[`camel-case-expansion`]&&E(e,e.split(`.`).map(function(e){return am(e)}).join(`.`));let r=D(e,t,n),a=e.split(`.`);ee(b,a,r),h.aliases[e]&&h.aliases[e].forEach(function(e){let t=e.split(`.`);ee(b,t,r)}),a.length>1&&o[`dot-notation`]&&(h.aliases[a[0]]||[]).forEach(function(t){let n=t.split(`.`),i=[].concat(a);i.shift(),n=n.concat(i),(h.aliases[e]||[]).includes(n.join(`.`))||ee(b,n,r)}),R(e,h.normalize)&&!R(e,h.arrays)&&[e].concat(h.aliases[e]||[]).forEach(function(e){Object.defineProperty(x,e,{enumerable:!0,get(){return t},set(e){t=typeof e==`string`?um.normalize(e):e}})})}function E(e,t){h.aliases[e]&&h.aliases[e].length||(h.aliases[e]=[t],f[t]=!0),h.aliases[t]&&h.aliases[t].length||E(t,e)}function D(e,t,n){n&&(t=hm(t)),(R(e,h.bools)||R(e,h.counts))&&typeof t==`string`&&(t=t===`true`);let r=Array.isArray(t)?t.map(function(t){return O(e,t)}):O(e,t);return R(e,h.counts)&&(ae(r)||typeof r==`boolean`)&&(r=pm()),R(e,h.normalize)&&R(e,h.arrays)&&(r=Array.isArray(t)?t.map(e=>um.normalize(e)):um.normalize(t)),r}function O(e,t){return!o[`parse-positional-numbers`]&&e===`_`||!R(e,h.strings)&&!R(e,h.bools)&&!Array.isArray(t)&&(sm(t)&&o[`parse-numbers`]&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))||!ae(t)&&R(e,h.numbers))&&(t=Number(t)),t}function k(e){let t=Object.create(null);F(t,h.aliases,s),Object.keys(h.configs).forEach(function(n){let r=e[n]||t[n];if(r)try{let e=null,t=um.resolve(um.cwd(),r),i=h.configs[n];if(typeof i==`function`){try{e=i(t)}catch(t){e=t}if(e instanceof Error){v=e;return}}else e=um.require(t);A(e)}catch(t){t.name===`PermissionDenied`?v=t:e[n]&&(v=Error(m(`Invalid JSON config file: %s`,r)))}})}function A(e,t){Object.keys(e).forEach(function(n){let r=e[n],i=t?t+`.`+n:n;typeof r==`object`&&r&&!Array.isArray(r)&&o[`dot-notation`]?A(r,i):(!I(b,i.split(`.`))||R(i,h.arrays)&&o[`combine-arrays`])&&T(i,r)})}function j(){c!==void 0&&c.forEach(function(e){A(e)})}function M(e,t){if(l===void 0)return;let n=typeof l==`string`?l:``,r=um.env();Object.keys(r).forEach(function(i){if(n===``||i.lastIndexOf(n,0)===0){let a=i.split(`__`).map(function(e,t){return t===0&&(e=e.substring(n.length)),am(e)});(t&&h.configs[a.join(`.`)]||!t)&&!I(e,a)&&T(a.join(`.`),r[i])}})}function N(e){let t,n=new Set;Object.keys(e).forEach(function(r){if(!n.has(r)&&(t=R(r,h.coercions),typeof t==`function`))try{let i=O(r,t(e[r]));[].concat(h.aliases[r]||[],r).forEach(t=>{n.add(t),e[t]=i})}catch(e){v=e}})}function P(e){return h.keys.forEach(t=>{~t.indexOf(`.`)||e[t]===void 0&&(e[t]=void 0)}),e}function F(e,t,n,r=!1){Object.keys(n).forEach(function(i){I(e,i.split(`.`))||(ee(e,i.split(`.`),n[i]),r&&(p[i]=!0),(t[i]||[]).forEach(function(t){I(e,t.split(`.`))||ee(e,t.split(`.`),n[i])}))})}function I(e,t){let n=e;o[`dot-notation`]||(t=[t.join(`.`)]),t.slice(0,-1).forEach(function(e){n=n[e]||{}});let r=t[t.length-1];return typeof n==`object`&&r in n}function ee(e,t,n){let r=e;o[`dot-notation`]||(t=[t.join(`.`)]),t.slice(0,-1).forEach(function(e){e=mm(e),typeof r==`object`&&r[e]===void 0&&(r[e]={}),typeof r[e]!=`object`||Array.isArray(r[e])?(Array.isArray(r[e])?r[e].push({}):r[e]=[r[e],{}],r=r[e][r[e].length-1]):r=r[e]});let i=mm(t[t.length-1]),a=R(t.join(`.`),h.arrays),s=Array.isArray(n),c=o[`duplicate-arguments-array`];!c&&R(i,h.nargs)&&(c=!0,(!ae(r[i])&&h.nargs[i]===1||Array.isArray(r[i])&&r[i].length===h.nargs[i])&&(r[i]=void 0)),n===pm()?r[i]=pm(r[i]):Array.isArray(r[i])?c&&a&&s?r[i]=o[`flatten-duplicate-arrays`]?r[i].concat(n):(Array.isArray(r[i][0])?r[i]:[r[i]]).concat([n]):!c&&!!a==!!s?r[i]=n:r[i]=r[i].concat([n]):r[i]===void 0&&a?r[i]=s?n:[n]:c&&!(r[i]===void 0||R(i,h.counts)||R(i,h.bools))?r[i]=[r[i],n]:r[i]=n}function L(...e){e.forEach(function(e){Object.keys(e||{}).forEach(function(e){h.aliases[e]||(h.aliases[e]=[].concat(a[e]||[]),h.aliases[e].concat(e).forEach(function(t){if(/-/.test(t)&&o[`camel-case-expansion`]){let n=am(t);n!==e&&h.aliases[e].indexOf(n)===-1&&(h.aliases[e].push(n),f[n]=!0)}}),h.aliases[e].concat(e).forEach(function(t){if(t.length>1&&/[A-Z]/.test(t)&&o[`camel-case-expansion`]){let n=om(t,`-`);n!==e&&h.aliases[e].indexOf(n)===-1&&(h.aliases[e].push(n),f[n]=!0)}}),h.aliases[e].forEach(function(t){h.aliases[t]=[e].concat(h.aliases[e].filter(function(e){return t!==e}))}))})})}function R(e,t){let n=[].concat(h.aliases[e]||[],e),r=Object.keys(t),i=n.find(e=>r.includes(e));return i?t[i]:!1}function z(e){let t=Object.keys(h);return[].concat(t.map(e=>h[e])).some(function(t){return Array.isArray(t)?t.includes(e):t[e]})}function te(e,...t){return[].concat(...t).some(function(t){let n=e.match(t);return n&&z(n[1])})}function B(e){if(e.match(g)||!e.match(/^-[^-]+/))return!1;let t=!0,n,r=e.slice(1).split(``);for(let i=0;i<r.length;i++){if(n=e.slice(i+2),!z(r[i])){t=!1;break}if(r[i+1]&&r[i+1]===`=`||n===`-`||/[A-Za-z]/.test(r[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(n)||r[i+1]&&r[i+1].match(/\W/))break}return t}function ne(e){return o[`unknown-options-as-args`]&&V(e)}function V(e){return e=e.replace(/^-{3,}/,`--`),e.match(g)||B(e)?!1:!te(e,/^-+([^=]+?)=[\s\S]*$/,_,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function re(e){return!R(e,h.bools)&&!R(e,h.counts)&&`${e}`in s?s[e]:ie(H(e))}function ie(e){return{[lm.BOOLEAN]:!0,[lm.STRING]:``,[lm.NUMBER]:void 0,[lm.ARRAY]:[]}[e]}function H(e){let t=lm.BOOLEAN;return R(e,h.strings)?t=lm.STRING:R(e,h.numbers)?t=lm.NUMBER:R(e,h.bools)?t=lm.BOOLEAN:R(e,h.arrays)&&(t=lm.ARRAY),t}function ae(e){return e===void 0}function oe(){Object.keys(h.counts).find(e=>R(e,h.arrays)?(v=Error(m(`Invalid configuration: %s, opts.count excludes opts.array.`,e)),!0):R(e,h.nargs)?(v=Error(m(`Invalid configuration: %s, opts.count excludes opts.narg.`,e)),!0):!1)}return{aliases:Object.assign({},h.aliases),argv:Object.assign(x,b),configuration:o,defaulted:Object.assign({},p),error:v,newAliases:Object.assign({},f)}}};function fm(e){let t=[],n=Object.create(null),r=!0;for(Object.keys(e).forEach(function(n){t.push([].concat(e[n],n))});r;){r=!1;for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++)if(t[e].filter(function(e){return t[n].indexOf(e)!==-1}).length){t[e]=t[e].concat(t[n]),t.splice(n,1),r=!0;break}}return t.forEach(function(e){e=e.filter(function(e,t,n){return n.indexOf(e)===t});let t=e.pop();t!==void 0&&typeof t==`string`&&(n[t]=e)}),n}function pm(e){return e===void 0?1:e+1}function mm(e){return e===`__proto__`?`___proto___`:e}function hm(e){return typeof e==`string`&&(e[0]===`'`||e[0]===`"`)&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}var gm=process&&{}.YARGS_MIN_NODE_VERSION?Number({}.YARGS_MIN_NODE_VERSION):20,_m=(process==null?void 0:process.versions)?.node??(process==null?void 0:process.version)?.slice(1);if(_m&&Number(_m.match(/^([^.]+)/)[1])<gm)throw Error(`yargs parser supports a minimum Node.js version of ${gm}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var vm=(process,{}),ym=t?t(import.meta.url):void 0,bm=new dm({cwd:process.cwd,env:()=>vm,format:g,normalize:k,resolve:A,require:e=>{if(ym!==void 0)return ym(e);if(e.match(/\.json$/))return JSON.parse(j(e,`utf8`));throw Error(`only .json config files are supported in ESM`)}}),xm=function(e,t){return bm.parse(e.slice(),t).argv};xm.detailed=function(e,t){return bm.parse(e.slice(),t)},xm.camelCase=am,xm.decamelize=om,xm.looksLikeNumber=sm;var Sm=e=>typeof e==`object`&&!!e,Cm=e=>!(!Sm(e)||e instanceof RegExp||e instanceof Error||e instanceof Date||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof Promise||e instanceof ArrayBuffer||e instanceof DataView||ArrayBuffer.isView(e)||globalThis.Blob&&e instanceof globalThis.Blob||typeof e.$$typeof==`symbol`||typeof e.asymmetricMatch==`function`),wm=Symbol(`mapObjectSkip`),Tm=(e,t)=>{if(t){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t)?.enumerable);return[...t,...n]}return Object.keys(e)},Em=(e,t,n,r=new WeakMap)=>{let{target:i={},...a}={deep:!1,includeSymbols:!1,...n};if(r.has(e))return r.get(e);r.set(e,i);let o=e=>e.map(e=>Cm(e)?Em(e,t,a,r):e);if(Array.isArray(e))return o(e);for(let n of Tm(e,a.includeSymbols)){let s=e[n],c=t(n,s);if(c===wm)continue;if(!Array.isArray(c))throw TypeError(`Mapper must return an array or mapObjectSkip, got ${c===null?`null`:typeof c}`);if(c.length<2)throw TypeError(`Mapper must return an array with at least 2 elements [key, value], got ${c.length} elements`);let[l,u,{shouldRecurse:d=!0}={}]=c;if(l!==`__proto__`){a.deep&&d&&Cm(u)&&(u=Array.isArray(u)?o(u):Em(u,t,a,r));try{i[l]=u}catch(e){if(e.name===`TypeError`&&e.message.includes(`read only`))continue;throw e}}}return i};function Dm(e,t,n){if(!Sm(e))throw TypeError(`Expected an object, got \`${e}\` (${typeof e})`);if(Array.isArray(e))throw TypeError(`Expected an object, got an array`);return Em(e,(n,r)=>t(n,r,e),n)}var Om=/[\p{Lu}]/u,km=/[\p{Ll}]/u,Am=/^[\p{Lu}](?![\p{Lu}])/u,jm=/[_.\- ]+/,Mm=/([\p{Alpha}\p{N}_]|$)/u,Nm=RegExp(`^`+jm.source),Pm=new RegExp(jm.source+Mm.source,`gu`),Fm=new RegExp(String.raw`\d+`+Mm.source,`gu`),Im=(e,t,n,r)=>{let i=!1,a=!1,o=!1,s=!1;for(let c=0;c<e.length;c++){let l=e[c];s=c>2?e[c-3]===`-`:!0,i&&Om.test(l)?(e=e.slice(0,c)+`-`+e.slice(c),i=!1,o=a,a=!0,c++):a&&o&&km.test(l)&&(!s||r)?(e=e.slice(0,c-1)+`-`+e.slice(c-1),o=a,a=!1,i=!0):(i=t(l)===l&&n(l)!==l,o=a,a=n(l)===l&&t(l)!==l)}return e},Lm=(e,t)=>e.replace(Am,e=>t(e)),Rm=(e,t,n)=>{let r=``,i=!1,a=!1,o=[...e];for(let e=0;e<o.length;e++){let s=o[e],c=Om.test(s),l=e+1<o.length&&Om.test(o[e+1]);i&&/[\p{Alpha}]/u.test(s)?(r+=s,i=!1,a=c):n&&c&&(a||l)?(r+=s,a=!0):/\d/.test(s)?(r+=s,i=!0,a=!1):jm.test(s)?(r+=s,a=!1):(r+=t(s),i=!1,a=!1)}return r},zm=(e,t,{capitalizeAfterNumber:n})=>{let r=n?(e,n,r,i)=>{let a=i.charAt(r+e.length);return jm.test(a)?e:n?e.slice(0,-n.length)+t(n):e}:e=>e;return e.replaceAll(Fm,r).replaceAll(Pm,(e,n)=>t(n))};function Bm(e,t){if(!(typeof e==`string`||Array.isArray(e)))throw TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,capitalizeAfterNumber:!0,...t},e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length>0).join(`-`):e.trim(),e.length===0)return``;let n=e.match(/^[_$]*/)[0];if(e=e.slice(n.length),e.length===0)return n;let r=t.locale===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t.locale),i=t.locale===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t.locale);return e.length===1?jm.test(e)?n:n+(t.pascalCase?i(e):r(e)):(e!==r(e)&&(e=Im(e,r,i,t.preserveConsecutiveUppercase)),e=e.replace(Nm,``),e=t.capitalizeAfterNumber?t.preserveConsecutiveUppercase?Lm(e,r):r(e):Rm(e,r,t.preserveConsecutiveUppercase),t.pascalCase&&e.length>0&&(e=i(e[0])+e.slice(1)),n+zm(e,i,t))}var Vm=class extends Map{#e=0;#t=new Map;#n=new Map;#r;#i;#a;constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge==`number`&&e.maxAge===0)throw TypeError("`maxAge` must be a number greater than 0");this.#r=e.maxSize,this.#i=e.maxAge||1/0,this.#a=e.onEviction}get __oldCache(){return this.#n}#o(e){if(typeof this.#a==`function`)for(let[t,n]of e)this.#a(t,n.value)}#s(e,t){return typeof t.expiry==`number`&&t.expiry<=Date.now()&&(typeof this.#a==`function`&&this.#a(e,t.value),this.delete(e))}#c(e,t){if(this.#s(e,t)===!1)return t.value}#l(e,t){return t.expiry?this.#c(e,t):t.value}#u(e,t){let n=t.get(e);return this.#l(e,n)}#d(e,t){this.#t.set(e,t),this.#e++,this.#e>=this.#r&&(this.#e=0,this.#o(this.#n),this.#n=this.#t,this.#t=new Map)}#f(e,t){this.#n.delete(e),this.#d(e,t)}*#p(){for(let e of this.#n){let[t,n]=e;this.#t.has(t)||this.#s(t,n)===!1&&(yield e)}for(let e of this.#t){let[t,n]=e;this.#s(t,n)===!1&&(yield e)}}get(e){if(this.#t.has(e)){let t=this.#t.get(e);return this.#l(e,t)}if(this.#n.has(e)){let t=this.#n.get(e);if(this.#s(e,t)===!1)return this.#f(e,t),t.value}}set(e,t,{maxAge:n=this.#i}={}){let r=typeof n==`number`&&n!==1/0?Date.now()+n:void 0;return this.#t.has(e)?this.#t.set(e,{value:t,expiry:r}):this.#d(e,{value:t,expiry:r}),this}has(e){return this.#t.has(e)?!this.#s(e,this.#t.get(e)):this.#n.has(e)?!this.#s(e,this.#n.get(e)):!1}peek(e){if(this.#t.has(e))return this.#u(e,this.#t);if(this.#n.has(e))return this.#u(e,this.#n)}expiresIn(e){let t=this.#t.get(e)??this.#n.get(e);if(t)return t.expiry?t.expiry-Date.now():1/0}delete(e){let t=this.#t.delete(e);return t&&this.#e--,this.#n.delete(e)||t}clear(){this.#t.clear(),this.#n.clear(),this.#e=0}resize(e){if(!(e&&e>0))throw TypeError("`maxSize` must be a number greater than 0");let t=[...this.#p()],n=t.length-e;n<0?(this.#t=new Map(t),this.#n=new Map,this.#e=t.length):(n>0&&this.#o(t.slice(0,n)),this.#n=new Map(t.slice(n)),this.#t=new Map,this.#e=0),this.#r=e}evict(e=1){let t=Number(e);if(!t||t<=0)return;let n=[...this.#p()],r=Math.trunc(Math.min(t,Math.max(n.length-1,0)));r<=0||(this.#o(n.slice(0,r)),this.#n=new Map(n.slice(r)),this.#t=new Map,this.#e=0)}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.#t){let[t,n]=e;this.#s(t,n)===!1&&(yield[t,n.value])}for(let e of this.#n){let[t,n]=e;this.#t.has(t)||this.#s(t,n)===!1&&(yield[t,n.value])}}*entriesDescending(){let e=[...this.#t];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.#s(n,r)===!1&&(yield[n,r.value])}e=[...this.#n];for(let t=e.length-1;t>=0;--t){let[n,r]=e[t];this.#t.has(n)||this.#s(n,r)===!1&&(yield[n,r.value])}}*entriesAscending(){for(let[e,t]of this.#p())yield[e,t.value]}get size(){if(!this.#e)return this.#n.size;let e=0;for(let t of this.#n.keys())this.#t.has(t)||e++;return Math.min(this.#e+e,this.#r)}get maxSize(){return this.#r}get maxAge(){return this.#i}entries(){return this.entriesAscending()}forEach(e,t=this){for(let[n,r]of this.entriesAscending())e.call(t,r,n,this)}get[Symbol.toStringTag](){return`QuickLRU`}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},Hm=(e,t)=>e.some(e=>typeof e==`string`?e===t:(e.lastIndex=0,e.test(t))),Um=e=>e.trim()!==``&&!Number.isNaN(Number(e)),Wm=new Vm({maxSize:1e5}),Gm=e=>ArrayBuffer.isView(e)||e instanceof Date||e instanceof RegExp||e instanceof Error||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof Promise,Km=e=>typeof e==`object`&&!!e&&!Gm(e),qm=(e,t={},n=new WeakMap,r)=>{if(!Km(e))return e;if(n.has(e))return n.get(e);let{exclude:i,pascalCase:a=!1,stopPaths:o,deep:s=!1,preserveConsecutiveUppercase:c=!1}=t,l=new Set(o);if(Array.isArray(e)){let i=[];n.set(e,i);for(let a of e)i.push(Km(a)?qm(a,t,n,r):a);return i}let u={};n.set(e,u);let d=Dm(e,(e=>(r,o)=>{if(s&&Km(o)){let i=e===void 0?r:`${e}.${r}`;l.has(i)||(o=Array.isArray(o)?o.map(e=>Km(e)?qm(e,t,n,i):e):qm(o,t,n,i))}if(typeof r==`string`&&!Um(r)&&!(i&&Hm(i,r))){let e=a?`${r}_`:r;Wm.has(e)?r=Wm.get(e):(r=Bm(r,{pascalCase:a,locale:!1,preserveConsecutiveUppercase:c}),r.length<100&&Wm.set(e,r))}return[r,o]})(r),{deep:!1});Object.assign(u,d);let f=Object.getOwnPropertySymbols(e);for(let i of f)u[i]=s&&Km(e[i])?qm(e[i],t,n,r):e[i];return u};function Jm(e,t){let n=new WeakMap;return Array.isArray(e)?e.map(e=>Km(e)?qm(e,t,n,void 0):e):qm(e,t,n)}function Ym(e){let t=0,n=e.length;for(;t<n&&(e[t]===`\r`||e[t]===`
|
|
139
139
|
`);)t++;for(;n>t&&(e[n-1]===`\r`||e[n-1]===`
|
|
140
140
|
`);)n--;return t>0||n<e.length?e.slice(t,n):e}function Xm(e){let t=e.match(/^[ \t]*(?=\S)/gm);if(!t)return e;let n=1/0;for(let e of t)n=Math.min(n,e.length);return n===0||n===1/0?e:e.replace(RegExp(`^[ \\t]{${n}}`,`gm`),``)}function Zm(e,t=1,n={}){let{indent:r=` `,includeEmptyLines:i=!1}=n;if(typeof e!=`string`)throw TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``);if(typeof t!=`number`)throw TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof t}\``);if(t<0)throw RangeError(`Expected \`count\` to be at least 0, got \`${t}\``);if(typeof r!=`string`)throw TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r}\``);if(t===0)return e;let a=i?/^/gm:/^(?!\s*$)/gm;return e.replace(a,r.repeat(t))}function Qm(e,t=0,n={}){return Zm(Xm(e),t,n)}var $m=e=>e instanceof URL?N(e):e;function eh(e,{cwd:t=n.cwd(),type:r=`file`,stopAt:i}={}){let a=E.resolve($m(t)??``),{root:o}=E.parse(a);i=E.resolve(a,$m(i)??o);let s=E.isAbsolute(e);for(;a;){let t=s?e:E.join(a,e);try{let e=f.statSync(t,{throwIfNoEntry:!1});if(r===`file`&&e?.isFile()||r===`directory`&&e?.isDirectory())return t}catch{}if(a===i||a===o)break;a=E.dirname(a)}}function th(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var nh={},rh={exports:{}},ih;function ah(){if(ih)return rh.exports;ih=1;let e=process||{},t=e.argv||[],n=e.env||{},r=!(n.NO_COLOR||t.includes(`--no-color`))&&(!!n.FORCE_COLOR||t.includes(`--color`)||e.platform===`win32`||(e.stdout||{}).isTTY&&n.TERM!==`dumb`||!!n.CI),i=(e,t,n=e)=>r=>{let i=``+r,o=i.indexOf(t,e.length);return~o?e+a(i,t,n,o)+t:e+i+t},a=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},o=(e=r)=>{let t=e?i:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};return rh.exports=o(),rh.exports.createColors=o,rh.exports}var oh={},sh;function ch(){return sh?oh:(sh=1,Object.defineProperty(oh,"__esModule",{value:!0}),oh.default=/((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g,oh.matchToToken=function(e){var t={type:`invalid`,value:e[0],closed:void 0};return e[1]?(t.type=`string`,t.closed=!!(e[3]||e[4])):e[5]?t.type=`comment`:e[6]?(t.type=`comment`,t.closed=!!e[7]):e[8]?t.type=`regex`:e[9]?t.type=`number`:e[10]?t.type=`name`:e[11]?t.type=`punctuator`:e[12]&&(t.type=`whitespace`),t},oh)}var lh={},uh={},dh;function fh(){if(dh)return uh;dh=1,Object.defineProperty(uh,"__esModule",{value:!0}),uh.isIdentifierChar=c,uh.isIdentifierName=l,uh.isIdentifierStart=s;let e=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,t=`·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,n=RegExp(`[`+e+`]`),r=RegExp(`[`+e+t+`]`);e=t=null;let i=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],a=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239];function o(e,t){let n=65536;for(let r=0,i=t.length;r<i;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function s(e){return e<65?e===36:e<=90?!0:e<97?e===95:e<=122?!0:e<=65535?e>=170&&n.test(String.fromCharCode(e)):o(e,i)}function c(e){return e<48?e===36:e<58?!0:e<65?!1:e<=90?!0:e<97?e===95:e<=122?!0:e<=65535?e>=170&&r.test(String.fromCharCode(e)):o(e,i)||o(e,a)}function l(e){let t=!0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if((r&64512)==55296&&n+1<e.length){let t=e.charCodeAt(++n);(t&64512)==56320&&(r=65536+((r&1023)<<10)+(t&1023))}if(t){if(t=!1,!s(r))return!1}else if(!c(r))return!1}return!t}return uh}var ph={},mh;function hh(){if(mh)return ph;mh=1,Object.defineProperty(ph,"__esModule",{value:!0}),ph.isKeyword=c,ph.isReservedWord=i,ph.isStrictBindOnlyReservedWord=o,ph.isStrictBindReservedWord=s,ph.isStrictReservedWord=a;let e={keyword:`break.case.catch.continue.debugger.default.do.else.finally.for.function.if.return.switch.throw.try.var.const.while.with.new.this.super.class.extends.export.import.null.true.false.in.instanceof.typeof.void.delete`.split(`.`),strict:[`implements`,`interface`,`let`,`package`,`private`,`protected`,`public`,`static`,`yield`],strictBind:[`eval`,`arguments`]},t=new Set(e.keyword),n=new Set(e.strict),r=new Set(e.strictBind);function i(e,t){return t&&e===`await`||e===`enum`}function a(e,t){return i(e,t)||n.has(e)}function o(e){return r.has(e)}function s(e,t){return a(e,t)||o(e)}function c(e){return t.has(e)}return ph}var gh;function _h(){return gh?lh:(gh=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"isIdentifierChar",{enumerable:!0,get:function(){return t.isIdentifierChar}}),Object.defineProperty(e,"isIdentifierName",{enumerable:!0,get:function(){return t.isIdentifierName}}),Object.defineProperty(e,"isIdentifierStart",{enumerable:!0,get:function(){return t.isIdentifierStart}}),Object.defineProperty(e,"isKeyword",{enumerable:!0,get:function(){return n.isKeyword}}),Object.defineProperty(e,"isReservedWord",{enumerable:!0,get:function(){return n.isReservedWord}}),Object.defineProperty(e,"isStrictBindOnlyReservedWord",{enumerable:!0,get:function(){return n.isStrictBindOnlyReservedWord}}),Object.defineProperty(e,"isStrictBindReservedWord",{enumerable:!0,get:function(){return n.isStrictBindReservedWord}}),Object.defineProperty(e,"isStrictReservedWord",{enumerable:!0,get:function(){return n.isStrictReservedWord}});var t=fh(),n=hh()})(lh),lh)}var vh;function yh(){if(vh)return nh;vh=1,Object.defineProperty(nh,"__esModule",{value:!0});var e=ah(),t=ch(),n=_h();function r(){return typeof process==`object`&&({}.FORCE_COLOR===`0`||{}.FORCE_COLOR===`false`)?!1:e.isColorSupported}let i=(e,t)=>n=>e(t(n));function a(e){return{keyword:e.cyan,capitalized:e.yellow,jsxIdentifier:e.yellow,punctuator:e.yellow,number:e.magenta,string:e.green,regex:e.magenta,comment:e.gray,invalid:i(i(e.white,e.bgRed),e.bold),gutter:e.gray,marker:i(e.red,e.bold),message:i(e.red,e.bold),reset:e.reset}}let o=a(e.createColors(!0)),s=a(e.createColors(!1));function c(e){return e?o:s}let l=new Set([`as`,`async`,`from`,`get`,`of`,`set`]),u=/\r\n|[\n\r\u2028\u2029]/,d=/^[()[\]{}]$/,f;{let e=/^[a-z][\w-]*$/i,r=function(t,r,i){if(t.type===`name`){if(n.isKeyword(t.value)||n.isStrictReservedWord(t.value,!0)||l.has(t.value))return`keyword`;if(e.test(t.value)&&(i[r-1]===`<`||i.slice(r-2,r)===`</`))return`jsxIdentifier`;if(t.value[0]!==t.value[0].toLowerCase())return`capitalized`}return t.type===`punctuator`&&d.test(t.value)?`bracket`:t.type===`invalid`&&(t.value===`@`||t.value===`#`)?`punctuator`:t.type};f=function*(e){let n;for(;n=t.default.exec(e);){let i=t.matchToToken(n);yield{type:r(i,n.index,e),value:i.value}}}}function p(e){if(e===``)return``;let t=c(!0),n=``;for(let{type:r,value:i}of f(e))r in t?n+=i.split(u).map(e=>t[r](e)).join(`
|
|
141
141
|
`):n+=i;return n}let m=!1,h=/\r\n|[\n\r\u2028\u2029]/;function g(e,t,n){let r=Object.assign({column:0,line:-1},e.start),i=Object.assign({},r,e.end),{linesAbove:a=2,linesBelow:o=3}=n||{},s=r.line,c=r.column,l=i.line,u=i.column,d=Math.max(s-(a+1),0),f=Math.min(t.length,l+o);s===-1&&(d=0),l===-1&&(f=t.length);let p=l-s,m={};if(p)for(let e=0;e<=p;e++){let n=e+s;m[n]=c?e===0?[c,t[n-1].length-c+1]:e===p?[0,u]:[0,t[n-e].length]:!0}else m[s]=c===u?!c||[c,0]:[c,u-c];return{start:d,end:f,markerLines:m}}function _(e,t,n={}){let i=n.forceColor||r()&&n.highlightCode,a=c(i),{start:o,end:s,markerLines:l}=g(t,e.split(h),n),u=t.start&&typeof t.start.column==`number`,d=String(s).length,f=(i?p(e):e).split(h,s).slice(o,s).map((e,t)=>{let r=o+1+t,i=` ${` ${r}`.slice(-d)} |`,s=l[r],c=!l[r+1];if(s){let t=``;if(Array.isArray(s)){let r=e.slice(0,Math.max(s[0]-1,0)).replace(/[^\t]/g,` `),o=s[1]||1;t=[`
|
|
@@ -151,9 +151,9 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
|
|
|
151
151
|
$ leek-box-cli [command]
|
|
152
152
|
|
|
153
153
|
命令
|
|
154
|
-
${Object.entries(
|
|
154
|
+
${Object.entries(xp).map(([e,t])=>` ${e.padEnd(13)}${t.description}`).join(`
|
|
155
155
|
`)}
|
|
156
156
|
|
|
157
157
|
选项
|
|
158
158
|
-v, --version 查看版本
|
|
159
|
-
-h, --help
|
|
159
|
+
-h, --help 查看帮助`;function Q_(){let e=X_(Z_,{importMeta:import.meta,commands:[...Sp],description:!1,autoHelp:!1,helpIndent:0,flags:{help:{type:`boolean`,shortFlag:`h`},version:{type:`boolean`,shortFlag:`v`}}}),t=e.input.some(e=>e===`--help`||e===`-h`),n=e.flags.help===!0||t;return{command:e.command,showHelp:n}}var $_=100,ev=e=>Object.keys(e).length>0;async function tv(e){let t=await Dd();id.getState().hydrateSettings(Gu(t));let n={},r,i,a=Promise.resolve(),o=async()=>{if(!ev(n))return;let t=n;n={};try{await Od(t),r=void 0}catch(i){n={...t,...n},r=i;try{e(i)}catch{}}},s=()=>(i&&=(clearTimeout(i),void 0),a=a.then(o),a),c=()=>{i&&clearTimeout(i),i=setTimeout(()=>{i=void 0,s()},$_)},l=id.subscribe((e,t)=>{nd(e,t)||(n={...n,...rd(e,t)},c())}),u,d=async()=>(l(),await s(),r&&ev(n)&&await o(),r===void 0);return{stop:()=>u??=d()}}var nv=async e=>{let t=await tv(e=>{console.error(`设置保存失败: ${sd(e)}`)});try{wf.setState({screen:wp(e)}),await Ul((0,Q.jsx)(im,{}),{alternateScreen:!0,concurrent:!0,incrementalRendering:!0,maxFps:45}).waitUntilExit()}finally{await t.stop()||(n.exitCode=1)}},{command:rv,showHelp:iv}=Q_();if(iv)console.log(Z_);else try{await nv(rv)}catch(e){console.error(`运行失败: ${sd(e)}`),n.exitCode=1}export{};
|