@fungi.computer/spore 0.14.7 → 0.14.8
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/THIRD_PARTY_NOTICES +1 -1
- package/dist/cli.js +3 -3
- package/dist/whats-new.json +1 -1
- package/package.json +5 -5
package/THIRD_PARTY_NOTICES
CHANGED
|
@@ -561,7 +561,7 @@ SOFTWARE.
|
|
|
561
561
|
|
|
562
562
|
---
|
|
563
563
|
|
|
564
|
-
@fungi.computer/agar 0.18.0, @fungi.computer/almanac 0.2.1, @fungi.computer/approvals 0.2.3, @fungi.computer/bird-dog 0.3.6, @fungi.computer/cairn 0.1.0, @fungi.computer/carrier 0.2.4, @fungi.computer/cli-version 0.0.2, @fungi.computer/cordyceps 0.4.2, @fungi.computer/corral 0.1.31, @fungi.computer/gills 0.3.0, @fungi.computer/graft 0.2.25, @fungi.computer/knapsack 0.4.13, @fungi.computer/lantern 0.4.2, @fungi.computer/maosaico 0.1.2, @fungi.computer/mule 0.2.3, @fungi.computer/mycelium 0.4.0, @fungi.computer/nacre 0.6.6, @fungi.computer/parakeet 0.11.
|
|
564
|
+
@fungi.computer/agar 0.18.0, @fungi.computer/almanac 0.2.1, @fungi.computer/approvals 0.2.3, @fungi.computer/bird-dog 0.3.6, @fungi.computer/cairn 0.1.0, @fungi.computer/carrier 0.2.4, @fungi.computer/cli-version 0.0.2, @fungi.computer/cordyceps 0.4.2, @fungi.computer/corral 0.1.31, @fungi.computer/gills 0.3.0, @fungi.computer/graft 0.2.25, @fungi.computer/knapsack 0.4.13, @fungi.computer/lantern 0.4.2, @fungi.computer/maosaico 0.1.2, @fungi.computer/mule 0.2.3, @fungi.computer/mycelium 0.4.0, @fungi.computer/nacre 0.6.6, @fungi.computer/parakeet 0.11.37, @fungi.computer/puffball 0.9.0, @fungi.computer/seam 0.2.5, @fungi.computer/shiitake 0.18.2, @fungi.computer/shiitake-extensions 0.10.2, @fungi.computer/spore 0.14.8, @fungi.computer/sprite 0.2.2, @fungi.computer/stipe 0.1.1, @fungi.computer/truffle 0.12.9, @fungi.computer/veil 0.7.4, @fungi.computer/watchdog 0.1.3, @fungi.computer/whistle 0.3.0, @fungi.computer/zookeeper 0.0.32
|
|
565
565
|
|
|
566
566
|
MIT License
|
|
567
567
|
|
package/dist/cli.js
CHANGED
|
@@ -1337,7 +1337,7 @@ ${te}`).join("")),ps((j)=>({_tag:"MuleError",phase:"model",message:"Extension pr
|
|
|
1337
1337
|
`)}}parseParagraph(){let e=[];while(this.index<this.lines.length){let t=this.current();if(N7(t))break;if(e.length>0&&Rxt(t,this.next()))break;e.push(t.trim()),this.index++}return{type:"paragraph",children:SY(e.join(`
|
|
1338
1338
|
`),this.options)}}createHeadingId(e){if(this.options.headingIds===!1)return;let t=wxt(e);if(typeof this.options.headingIds==="function")return this.options.headingIds(t,this.index);return this.slugger(t)}current(){return this.lines[this.index]??""}next(){return this.lines[this.index+1]}}function LIi(e){if(!e)return{};let n=e.match(/^([A-Za-z0-9_+.#-]+)/)?.[1],r=n?e.slice(n.length).trim():e,i=r.match(/(?:^|\s)(?:title|file)=(?:"([^"]+)"|'([^']+)'|([^\s}]+))/),o=r.match(/(?:^|\s)framework=(?:"([^"]+)"|'([^']+)'|([^\s}]+))/),s=r.match(/\{([^}]+)\}|(?:^|\s)lines=([^\s]+)/),a=zIi(s?.[1]??s?.[2]??""),c=i?i[1]??i[2]??i[3]:void 0,u=o?o[1]??o[2]??o[3]:void 0;return{...n?{lang:n}:{},...r?{meta:r}:{},...c?{title:c,file:c}:{},...u?{framework:u.toLowerCase()}:{},...a.length?{highlightLines:a}:{}}}function FIi(e){let t=Object.create(null),n=Object.create(null),r=new Map,i=[],o,s=0,a=0;while(a<e.length){let c=e[a],u=c.match(/^ {0,3}(`{3,}|~{3,})/);if(u){let l=u[1][0];if(!o)o=l,s=u[1].length;else if(l===o&&u[1].length>=s)o=void 0,s=0;i.push(c),a++;continue}if(!o){let l=c.match(/^ {0,3}\[\^([^\]\n]+)\]:[ \t]*(.*)$/);if(l){let p=l[1],f=[l[2]??""];a++;while(a<e.length){let h=e[a];if(!/^(?: {4,}|\t)/.test(h))break;f.push(h.replace(/^(?: {4}|\t)/,"")),a++}let m=L7(p);if(!n[m]){let h=jme(p)||"footnote",g=(r.get(h)??0)+1;r.set(h,g),n[m]={label:p,content:f.join(`
|
|
1339
1339
|
`),id:g===1?h:`${h}-${g}`}}continue}let d=c.match(/^ {0,3}\[([^\]\n]+)\]:[ \t]*(\S+)(?:[ \t]+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?[ \t]*$/);if(d){let p=d[3]??d[4]??d[5];t[L7(d[1])]={href:d[2].replace(/^<|>$/g,""),...p!==void 0?{title:p}:{}},a++;continue}}i.push(c),a++}return{lines:i,references:t,footnotes:n}}function $Ii(e,t,n){let r=[];for(let i=0;i<t.length;i++){let o=t[i],s=e[o];if(!s)continue;r.push({id:s.id??(jme(s.label)||"footnote"),number:i+1,children:new EY(ZPe(s.content).split(`
|
|
1340
|
-
`),n,Ext()).parse()})}for(let i of r){let o=n.footnoteCounts?.[t[i.number-1]]??1;if(o>1)i.referenceCount=o}return{type:"footnotes",items:r}}function zIi(e){let t=new Set;for(let n of e.split(",")){let r=n.trim().match(/^(\d+)(?:-(\d+))?$/);if(!r)continue;let i=Number(r[1]),o=Number(r[2]??r[1]);for(let s=i;s<=o&&s<i+1000;s++)t.add(s)}return[...t].sort((n,r)=>n-r)}function Bme(e){let t=e.match(/^(\s{0,8})([-+*]|\d{1,9}[.)])(?:([ \t]+)(.*))?$/);if(!t)return;let n=t[2],r=/\d/.test(n[0]);return{ordered:r,...r?{number:Number.parseInt(n,10)}:{},indent:t[1].length,marker:r?n.at(-1):n,contentIndent:t[1].length+n.length+(t[3]?.length??1),content:t[4]??""}}function a9n(e,t){return e.ordered===t.ordered&&e.marker===t.marker}function c9n(e){return e.match(/^ */)?.[0].length??0}function Rxt(e,t){let n=Bme(e);return/^ {0,3}(`{3,}|~{3,})/.test(e)||/^ {0,3}#{1,6}(?:\s+|$)/.test(e)||/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/.test(e)||/^ {0,3}>\s?/.test(e)||n!==void 0&&(!n.ordered||n.number===1)||!!t&&d9n(e,t)}function d9n(e,t){if(!e.includes("|"))return!1;let n=qme(t);return n.length===qme(e).length&&n.every((r)=>/^:?-+:?$/.test(r.trim()))}function qme(e){let t=e.trim();if(t.startsWith("|"))t=t.slice(1);if(t.endsWith("|"))t=t.slice(0,-1);let n=[],r="";for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"&&t[i+1]==="|"){r+="|",i++;continue}if(o==="|"){n.push(r.trim()),r="";continue}r+=o}return n.push(r.trim()),n}function UIi(e){let t=e.trim();if(t.startsWith(":")&&t.endsWith(":"))return"center";if(t.endsWith(":"))return"right";if(t.startsWith(":"))return"left";return}function u9n(e,t){return{type:"tableCell",children:SY(e,t)}}var NIi=64;var p9n=A(()=>{s9n();Txt()});function Dxt(e){return Ns(()=>l9n(e,{allowHtml:!1,frontmatter:!1}),[e])}var f9n=A(()=>{p9n();Xi()});function m9n(e){return[...e.value.panel.flatMap((t)=>t.actions??[]),...e.value.timeline.cells.flatMap((t)=>t.rows.flatMap((n)=>n.actions??[])),...e.value.waiting===null?[]:[e.value.waiting.cancel]]}function h9n(e){let t=new AbortController,n=()=>t.signal.aborted,r=new Set,i=new Map,o=new Map,s=(u,l)=>JSON.stringify([u,l.id,l.input??{}]),a=()=>{if(n())return;let u=new Map,l=new Set;for(let d of e.contributions())for(let p of m9n(d)){let f=s(d.entryId,p);l.add(f);let m=o.get(f);if(m!==void 0)u.set(p,m)}for(let[d,p]of o)if(!l.has(d)&&!p.pending)o.delete(d);i=u;for(let d of r)d()},c=(u,l)=>{if(n())return;o.set(u,l),a()};return{snapshot:()=>i,refresh:a,subscribe:(u)=>(r.add(u),()=>{r.delete(u)}),execute:async(u,l,d=!1)=>{let p=e.contributions().find((g)=>g.entryId===u);if(n()||!e.online()||p===void 0||!m9n(p).includes(l)||d&&p.value.waiting?.cancel!==l)return;if(l.awaiting!==void 0){e.interactions.awaiting.focus();return}let f=s(u,l);if(o.get(f)?.pending)return;c(f,{pending:!0});let m;try{let g={origin:"menu",signal:t.signal};if(l.input!==void 0)g={...g,arguments:l.input};m=await e.commands.execute({namespace:u,id:l.id},g)}catch(g){if(M_("client row command",g),n())return;let _=g instanceof Error?g:Error("Client row command failed",{cause:g});c(f,{pending:!1,error:_.message}),e.interactions.report({tone:"error",message:_.message});return}if(n())return;let h=m.status==="handled"?void 0:m.status==="failed"?m.error.message:m.status==="unavailable"?m.reason:`Client row command ${m.status}`;if(c(f,h===void 0?{pending:!1}:{pending:!1,error:h}),h!==void 0)e.interactions.report({tone:"error",message:h})},dispose:()=>{t.abort(),i=new Map,o.clear(),r.clear()}}}var g9n=A(()=>{cY()});function Oxt(e){let t=LI(),{observation:n}=NI(),r=Ime(),i=Tme(),[o,s]=ii(),a=Pr({contributions:t,observation:n});return a.current={contributions:t,observation:n},Qn(()=>{let u=h9n({commands:e,contributions:()=>a.current.contributions,online:()=>a.current.observation.status==="live",interactions:r});return s(u),()=>{u.dispose()}},[e,r,i]),Qn(()=>{o?.refresh()},[o,t]),{state:Ka(o?.subscribe??BIi,o?.snapshot??_9n,o?.snapshot??_9n),enabled:o!==void 0&&n.status==="live",execute:(u,l,d=!1)=>o?.execute(u,l,d)??Promise.resolve()}}var jIi,_9n=()=>jIi,BIi=()=>()=>{return};var y9n=A(()=>{Xi();bPe();g9n();jIi=new Map});function x9n(e,t){if(t.prompt!==void 0)return e;return t.status==="failed"?{...e,phase:"refused",refusal:t.failure??"Something went wrong."}:{...e,phase:"sending"}}function Pxt(e,t){let{host:n}=e,r=Ka(n.subscribe,n.snapshot),i=Pr(),o=r.prompt;if(o?.request.type==="decision")i.current={sequence:o.sequence,prompt:o.request};let[,s]=ii(),a=Pr(),c=i.current,u=()=>c!==void 0&&a.current?.sequence===c.sequence?a.current.state:vxt(),l=(d)=>{if(c===void 0)return;a.current={sequence:c.sequence,state:d},s(a.current)};return{view:c===void 0?void 0:bxt(x9n(u(),r),c.prompt,{kind:e.kind,position:t.position,total:t.total}),later:t.later,dispatch:(d)=>{if(c===void 0)return;let p=n.snapshot();if(p.prompt===void 0&&p.status==="failed"){if(d.type==="enter")n.retry();else if(d.type==="escape")t.later();return}let f=XPe(x9n(u(),p),d,c.prompt);l(f.state);let m=f.effect;if(m?.type==="later")t.later();else if(m?.type==="answer"){let h={selected:m.selected};if(m.text!==void 0)h.text=m.text;if(!n.answer(c.sequence,h))l(XPe(f.state,{type:"refused",message:"That answer was not accepted. Choose again."},c.prompt).state)}}}}var v9n=A(()=>{Xi();YPe()});function S9n(e,t){let{record:n}=e,r=Math.max(0,n.expiresAt-t);return[["Agent",`${n.requester.displayName} \xB7 ${n.requester.agentId??"none"}`],["Session",n.requester.sessionId??"none"],["Requester",n.requester.principalId],["Request",`${n.module}.${n.operation} \xB7 ${n.access}`],["Input",`${n.description.inputBytes.toLocaleString()} bytes \xB7 SHA-256 ${n.description.inputSha256.slice(0,8)}\u2026${n.description.inputSha256.slice(-6)}`],["Expires",`in ${String(Math.floor(r/3600000))} h ${String(Math.floor(r%3600000/60000))} m`],["Record",`${n.recordId} \xB7 revision ${String(n.revision)}`]]}function w9n(e){return["Undo",e.record.reversibility==="irreversible-external"?"Can't be undone":"Can be undone"]}function qIi(e,t){let{record:n}=e;return{content:{title:`Allow ${n.module} \xB7 ${n.operation}?`,summary:`${n.requester.displayName} wants to use a connected tool.`,facts:[{label:"Effect",value:(n.access==="write"?"Changes data in Fungi":"Changes things outside Fungi")+(n.reversibility==="irreversible-external"?" \xB7 can't be undone":"")}],details:Nxt([w9n(e),...S9n(e,t)])}}}function WIi(e,t,n,r,i){let o=t.prefix?.join(" "),s=o!==void 0&&t.alwaysAllowUnavailableReason===void 0,a=t.command,c=`Allow \`${a}\`?`.length<=n?`Allow \`${a}\`?`:"Allow this command?",u=t.cwd===r?"~":t.cwd.startsWith(`${r}/`)?`~${t.cwd.slice(r.length)}`:t.cwd,l=Math.max(8,(n-8)*2-2),d=t.justification.length<=l?`\u201C${t.justification}\u201D`:`\u201C${t.justification.slice(0,l-1)}\u2026\u201D`,p=[["Folder",b9n(u,Math.max(8,n-10))],["Why",d]];if(t.kind==="extension-install")p.push(["Note","Extensions run inside Fungi with access to every Agent."]);if(s&&t.alwaysAllowCoverage!==void 0)p.push(["Scope",Mxt(t.alwaysAllowCoverage,Math.max(8,n-12))]);if(!s&&t.risk!==void 0)p.push(["Risk",t.risk.summary]);let f=!s?void 0:`Always allow \u201C${b9n(o,Math.max(8,n-5-32))}\u201D in this project\u2026`,m=[["Command",a]];if(t.argv!==void 0)m.push(["Arguments",JSON.stringify(t.argv)]);if(m.push(["Folder",t.cwd],["Runs","Outside the sandbox, as you"],w9n(e)),!s&&t.alwaysAllowUnavailableReason!==void 0)m.push(["Rule",t.alwaysAllowUnavailableReason]);else if(t.form==="shell")m.push(["Rule","Shell command: no Always-allow rule can match it."]);else if(s){if(m.push(["Rule",`\u201C${o}\u201D would match \`${o} \u2026\` in this project`]),t.alwaysAllowCoverage!==void 0)m.push(["Coverage",t.alwaysAllowCoverage])}if(t.risk!==void 0)m.push(["Risk",t.risk.detail]);return m.push(...S9n(e,i)),{content:{title:c,body:c==="Allow this command?"?a:void 0,bodyLabel:c==="Allow this command?"?"Command":void 0,summary:`${e.record.requester.displayName} wants to run this outside the sandbox, as you.`,facts:Nxt(p),details:Nxt(m)},always:f===void 0?void 0:Mxt(f,Math.max(12,n-5)),confirmation:!s?void 0:{title:`Always allow \u201C${o}\u201D in this project?`,body:Mxt(t.alwaysAllowCoverage??`Any Workspace Agent here can then run \`${o} \u2026\` without asking.`,Math.max(12,(n-8)*2-2))},confirmWarning:s?t.risk?.summary:void 0,confirmYes:!s?void 0:`Always allow \u201C${o}\u201D and run it now`}}function HIi(e,t,n){let r=Math.min(n.width,60);return t===void 0?qIi(e,n.now):WIi(e,t,r,n.home,n.now)}function GIi(e,t){switch(e){case"stale-revision":case"already-answered":return"This request changed. Look again before answering.";case"expired":return"This request expired. Nothing ran.";case"not-eligible":if(t==="always-allow")return"Always allow isn't available for this command. Approve once or deny.";break;default:break}return`Couldn't answer (${e}). Nothing ran.`}async function E9n(e,t){let{view:n,source:r}=t,i=HIi(n,r.review,{width:t.width,home:t.home,now:t.now}),o=n.record;try{let s,a,c=!1;while(s===void 0){let d=await e.prompt({type:"decision",message:i.content.title,summary:c?"Automatic approval is on for this family.":i.content.summary,facts:i.content.facts?.map((p)=>({...p})),body:i.content.body,bodyLabel:i.content.bodyLabel,details:i.content.details?.map((p)=>({...p})),options:[{value:"approve",label:"Approve once"},...i.always===void 0?[]:[{value:"always",label:i.always}],...r.family===void 0||c?[]:[{value:"family",label:r.family.label}],{value:"deny",label:"Deny"}],other:{label:"Deny and say why\u2026",placeholder:"A short reason for the Agent (optional)",maxLength:t.noteLimit,blank:"deny"}});if(!t.stillCurrent())return{kind:"abandoned"};if(d.text!==void 0)a=d.text.trim()||void 0,s="deny";else if(d.selected[0]==="always"){let p=i.confirmation,f=await e.prompt({type:"decision",message:p?.title??i.content.title,summary:i.confirmWarning,body:p?.body,options:[{value:"back",label:"Back"},{value:"always-allow",label:i.confirmYes??"Always allow"}],escape:"back"});if(!t.stillCurrent())return{kind:"abandoned"};if(f.selected[0]==="always-allow")s="always-allow"}else if(d.selected[0]==="family"&&r.family!==void 0){let p=await e.prompt({type:"decision",message:`${r.family.label}?`,summary:`Later ${o.module} requests that ${o.access==="write"?"change data in Fungi":"reach outside Fungi"} will run without asking.`,options:[{value:"back",label:"Back"},{value:"family",label:r.family.label}],escape:"back"});if(!t.stillCurrent())return{kind:"abandoned"};if(p.selected[0]==="family"){if(c=await r.family.enable(),!t.stillCurrent())return{kind:"abandoned"}}}else if(d.selected[0]==="approve")s="approve";else if(d.selected[0]==="deny")s="deny"}let u={recordId:o.recordId,decision:s,expectedRevision:o.revision},l=await r.answer(a===void 0?u:{...u,denialNote:a});if(!t.stillCurrent())return{kind:"abandoned"};return l.kind==="refused"?{kind:"refused",message:GIi(l.reason??"unknown",s)}:{kind:"answered"}}catch(s){if(e.signal.aborted)return{kind:"abandoned"};return t.onFailure(s),{kind:"refused",message:KIi}}}var b9n=(e,t)=>{if(e.length<=t)return e;let n=Math.max(1,Math.floor((t-1)/2));return`${e.slice(0,n)}\u2026${e.slice(-(t-n-1))}`},Mxt=(e,t)=>e.length<=t?e:`${e.slice(0,t-1)}\u2026`,Nxt=(e)=>e.map(([t,n])=>({label:t,value:n})),KIi="Couldn't send your answer. It may not have been recorded.";function nMe(e){let{source:t,store:n,enabled:r,home:i,width:o,noteLimit:s,onFailure:a}=e,c=Pr(a);c.current=a;let u=Pr({home:i,width:o,noteLimit:s});u.current={home:i,width:o,noteLimit:s};let l=Ka(t?.subscribe??JIi,t?.snapshot??VIi),d=Pr(l);d.current=l;let p=l===void 0?void 0:JSON.stringify(["approval",l.record.recordId,l.record.revision,l.canAnswer]);Qn(()=>{let f=d.current;if(!r||t===void 0||f===void 0)return;if(!f.canAnswer||p===void 0)return;let{home:m,width:h,noteLimit:g}=u.current,_=s7({title:"Approval"}),y=_.begin(),x=()=>{let S=t.snapshot();return!y.interaction.signal.aborted&&S?.record.recordId===f.record.recordId&&S.record.revision===f.record.revision&&S.canAnswer},b=n.awaiting.add({key:p,kind:"approval",arrivedAt:Date.now(),host:_});return E9n(y.interaction,{view:f,source:t,home:m,width:h,now:Date.now(),noteLimit:g,stillCurrent:x,onFailure:(S)=>{c.current(S)}}).then((S)=>{if(S.kind==="refused")y.settle({status:"failed",message:S.message});else b(),y.settle(S.kind==="answered"?{status:"handled"}:{status:"cancelled"})}),()=>{b(),_.cancel()}},[t,p,r,n])}var VIi=()=>{return},JIi=()=>()=>{return};var k9n=A(()=>{mX();Xi()});function Lxt(e){let t=new Map;for(let r of e){let i=t.get(r.entryId);if(i===void 0)t.set(r.entryId,[r]);else i.push(r)}for(let r of t.values())r.sort((i,o)=>i.cell.sequence-o.cell.sequence);let n=[];while(t.size>0){let r=[...t.values()].flatMap((s)=>s[0]===void 0?[]:[s[0]]);r.sort((s,a)=>s.cell.at-a.cell.at||(s.entryId<a.entryId?-1:s.entryId>a.entryId?1:0)||s.cell.sequence-a.cell.sequence);let i=r[0];if(i===void 0)break;n.push(i);let o=t.get(i.entryId);if(o?.shift(),o?.length===0)t.delete(i.entryId)}return n}function BB(e,t,n=new Map){let r=new Map,i=[],o=[];for(let{entryId:s,value:a}of e)for(let c of a.timeline.cells){let u={entryId:s,cell:c};if(c.afterSequence===void 0&&c.commandId===null){o.push(u);continue}let l=c.afterSequence!==void 0?n.get(c.afterSequence):c.commandId===null?void 0:t.get(c.commandId);if(l===void 0)continue;if(l===null){i.push(u);continue}let d=r.get(l);if(d===void 0)r.set(l,[u]);else d.push(u)}return{before:Lxt(i),after:new Map([...r].map(([s,a])=>[s,Lxt(a)])),unanchored:Lxt(o),omitted:e.flatMap(({entryId:s,value:a})=>a.timeline.omitted===0?[]:[{entryId:s,count:a.timeline.omitted}])}}var Tm=A(()=>{cUe();bPe();afe();lfe();m1t();C1t();iNn();W7n();Fgt();t9n();f9n();s1t();hPe();y9n();YPe();v9n();k9n()});function yr(e){return nne(e)}var k1=A(()=>{Tm()});function Ow(e){return Array.from(yr(e).replace(/[\n\t]/gu,"")).slice(0,512).join("")}var kY=A(()=>{k1()});function Gl(e){return{type:"done",notice:e}}function Wme(e){return{type:"done",notice:e,result:{cancelled:!0}}}function Z0(e,t,n){return{type:"prompt",prompt:e,next:{arguments:t,answer:n}}}function jb(e){return gLn(JSON.stringify({protocol:"whistle.catalog/v1",commands:e}))}var Xx,UI;var T1=A(()=>{HDe();Nd();Ar();cr();Yd();Xx=k0((e)=>Mgt.safeParse(e).success,{representation:{id:"@fungi.computer/whistle/catalog-step/v1",payload:null}});UI=Vt(()=>Kc())});var xk=(e)=>Ce.check(Yn(1),Wt(e),Jc(/\S/u)),T9n,TY,Hme,rMe,Fxt,qB,iMe,$xt,sMe,oMe,A9n,zxt,Uxt,I9n,QIi,XIi,aMe,Bb;var F7=A(()=>{Yd();cr();T1();T9n=oe({id:xk(32).check(Jc(/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/u)),header:xk(12),question:xk(1000),options:bn(oe({label:xk(60),description:xk(300)})).check(Yn(2),Wt(4),Sr((e)=>new Set(e.map((t)=>t.label)).size===e.length||"Option labels must be unique",{representation:{id:"botanical/ask/unique-option-labels",payload:null}})),multiple:wt(ai)}),TY=bn(T9n).check(Yn(1),Wt(4),Sr((e)=>new Set(e.map((t)=>t.id)).size===e.length||"Question ids must be unique",{representation:{id:"botanical/ask/unique-question-ids",payload:null}})),Hme=oe({askId:Ce,waitingOn:wt(YE),escalated:wt(QG),questions:TY,status:Yt(["live","parked"]),createdAt:gr,expiresAt:Dn(gr)}),rMe=oe({asks:bn(Hme).check(Wt(4))}),Fxt=xk(256),qB=gc(T9n.fields.id,oe({selected:bn(xk(60)).check(Wt(4)),text:wt(Ce.check(Wt(4000)))})),iMe=oe({askId:xk(256),requestId:Fxt,answers:qB}),$xt=oe({askId:xk(256),requestId:Fxt,note:wt(Ce.check(Wt(4000)))}),sMe=Yt(["answered","declined","withdrawn","expired","cancelled","undeliverable"]),oMe=Nn([oe({result:Je("accepted"),via:Yt(["in_turn","follow_up"]),commandId:wt(xk(256))}),oe({result:Je("closed"),status:sMe}),oe({result:Je("not_found")})]),A9n=oe({result:Je("refused"),reason:Je("not_sender")}),zxt=Nn([oMe,A9n]),Uxt=oe({kind:Je("agent"),agentId:xk(256)}),I9n=Nn([oe({result:Je("escalated"),to:Je("agent"),waitingOn:YE}),oe({result:Je("escalated"),to:Je("person")}),oe({result:Je("closed"),status:sMe}),oe({result:Je("not_found")}),A9n]),QIi=oe({askId:xk(256),note:Rn(Ce.check(Wt(1000)))}),XIi={askId:iMe.fields.askId,requestId:Fxt,index:gr.check(Cf(),lp({minimum:0,maximum:3})),answers:qB},aMe=Nn([oe({stage:Je("decision"),...XIi,answer:qB.value}),oe({askId:iMe.fields.askId}),oe({})]),Bb={id:Zu.make("botanical-session-question"),commands:{answerFlow:{scope:"session",input:aMe,output:Xx},answer:{scope:"session",input:iMe,output:oMe},answerAgent:{scope:"session",input:iMe,output:oe({result:zxt,answeredBy:Uxt})},escalateAgent:{scope:"session",input:QIi,output:I9n},decline:{scope:"session",input:$xt,output:oMe},list:{scope:"session",input:oe({}),output:rMe}},projection:{schema:rMe}}});var WB,HB,jxt,C9n,YIi,$7,Bxt,uMe=16,R9n,ZIi,A1;var AY=A(()=>{Yd();cr();T1();WB=Ce.pipe(lt(Yn(1)),lt(Wt(4000)),lt(Jc(/\S/u,{message:"Goal objective is blank"}))),HB=Ce.pipe(lt(Yn(1)),lt(Wt(1000)),lt(Jc(/\S/u))),jxt=Ce.pipe(lt(Yn(1)),lt(Wt(256))),C9n=kn.check(_r(0)),YIi=oe({kind:Yt(["person","delegator","blocked","stalled","cancelled","failed","no-terminal"]),detail:Dn(Ce)}),$7=oe({revision:Ce,objective:WB,state:Yt(["active","paused"]),startedAt:C9n,pauseCause:Dn(YIi)}),Bxt=oe({sequence:kn.check(ea(0)),objective:WB,outcome:Yt(["achieved","cleared"]),reason:Dn(HB),clearedBy:wt(Xy.check(Wt(256))),endedAt:C9n,afterSequence:kn.check(_r(0))}),R9n=Nn([oe({action:Je("set"),objective:WB,requestId:jxt,expectedRevision:Rn(Dn(Ce)),confirmed:Rn(ai)}),oe({action:Yt(["pause","resume","replace","clear","clear-ask"]),confirmed:Rn(ai)}),oe({})]),ZIi=oe({goal:Dn($7),ended:bn(Bxt).check(Wt(uMe)),omitted:kn.check(_r(0))}),A1={id:Zu.make("botanical-session-goal"),commands:{controlAgent:{scope:"session",input:oe({action:Yt(["pause","resume","clear"]),reason:HB}),output:Nn([oe({result:Je("paused"),goal:$7}),oe({result:Je("resumed"),goal:$7}),oe({result:Je("cleared")}),oe({result:Je("no_goal")}),oe({result:Je("refused"),reason:Yt(["not_delegator","not_paused_by_delegator"])})])},goal:{scope:"session",input:R9n,output:Xx},pause:{scope:"session",input:oe({}),output:$7},resume:{scope:"session",input:oe({}),output:$7},clear:{scope:"session",input:oe({}),output:oe({})},set:{scope:"session",input:oe({objective:WB,expectedRevision:Dn(Ce),requestId:jxt,adoptCommandId:wt(jxt)}),output:oe({goal:$7,accepted:oe({status:Je("accepted"),commandId:Ce})})}},projection:{schema:ZIi}}});var qb,jI;var IY=A(()=>{cr();qb=Ce.pipe(lt(Yn(1)),lt(Wt(256))),jI=Ce.pipe(lt(Yn(1)),lt(Wt(262144)))});var lMe,Mg,dMe;var pMe=A(()=>{cr();IY();lMe=oe({expression:Ce.pipe(lt(Yn(1)),lt(Wt(256))),timeZone:Ce.pipe(lt(Yn(1)),lt(Wt(128)))}),Mg=oe({loopId:Ce,origin:Yt(["human","model"]),expiresAt:Dn(kn),prompt:jI,mode:Yt(["self_paced","fixed_interval"]),cron:Dn(lMe),state:Yt(["active","paused","finished","failed","cancelled"]),commandId:Ce,reason:Dn(Ce),nextDueAt:Dn(kn),lastError:Dn(Ce),consecutiveFailures:kn.pipe(lt(_r(0)))}),dMe=oe({after:wt(qb),limit:wt(kn.pipe(lt(lp({minimum:1,maximum:64}))))})});var Wxt,O9n,P9n,rCi,qxt,BO;var Kme=A(()=>{Yd();cr();T1();IY();pMe();pMe();Wxt=Ce.pipe(lt(Yn(1)),lt(Wt(200))),O9n=oe({loop:Mg,accepted:oe({status:Je("accepted"),commandId:Ce})}),P9n=Nn([oe({action:Je("start"),text:jI,requestId:Wxt}),oe({action:Yt(["status","pause","resume","stop","stop-ask","new"]),confirmed:Rn(ai)}),oe({})]),rCi=oe({loop:Mg}),qxt=oe({sessionId:qb,loopId:Mg.fields.loopId}),BO={id:Zu.make("botanical-session-loop"),commands:{list:{scope:"agent",input:dMe,output:bn(oe({...Mg.fields,sessionId:qb})).pipe(lt(Wt(64)))},pauseLoop:{scope:"agent",input:qxt,output:Mg},resumeLoop:{scope:"agent",input:qxt,output:Mg},stopLoop:{scope:"agent",input:qxt,output:Mg},loop:{scope:"session",input:P9n,output:Xx},startSelfPaced:{scope:"session",input:oe({prompt:jI,requestId:Wxt}),output:O9n},startFixedInterval:{scope:"session",input:oe({prompt:jI,requestId:Wxt,...lMe.fields}),output:O9n},pause:{scope:"session",input:oe({}),output:Mg},resume:{scope:"session",input:oe({}),output:Mg},stop:{scope:"session",input:oe({}),output:Mg}},projection:{schema:rCi}}});function fMe(e){return oe({nextSequence:kn.check(ea(0)),omitted:kn.check(_r(0)),events:bn(oe({id:Ce,sequence:kn,at:kn,commandId:Dn(Ce),event:e}))})}function Hxt(){return{nextSequence:1,omitted:0,events:[]}}function F9n(e,t,n,r){let i=e.nextSequence,o=[...e.events,{id:String(i),sequence:i,at:r,commandId:n,event:t}],s={nextSequence:i+1,omitted:e.omitted,events:o};while(o.length>32||oCi.encode(JSON.stringify(s)).length>32768){if(o.length===0)break;o.shift(),s.omitted+=1}return s}var oCi;var Gxt=A(()=>{cr();oCi=new TextEncoder});function mMe(e){return e.steps.some((t)=>t.status!=="completed")}var CY,$9n,sCi,aCi,z7;var hMe=A(()=>{Gxt();Yd();cr();T1();CY=oe({explanation:wt(Ce.pipe(lt(Wt(2000)))),steps:bn(oe({step:Ce.pipe(lt(Yn(1)),lt(Wt(500))),status:Yt(["pending","in_progress","completed"])})).pipe(lt(Wt(50)))}),$9n=CY.pipe(lt(Sr((e)=>e.steps.filter((t)=>t.status==="in_progress").length<=1||"At most one plan step may be in progress")));sCi=oe({plan:CY,history:fMe(CY)}),aCi=Nn([oe({action:Je("clear")}),oe({})]),z7={id:Zu.make("botanical-session-plan"),commands:{plan:{scope:"session",input:aCi,output:Xx}},projection:{schema:sCi}}});var A4,U9n,gMe=16,j9n=256,lCi,dCi,pCi,fCi,mCi,hCi,GB;var Kxt=A(()=>{Yd();cr();T1();F7();A4=Ce.check(Yn(1),Wt(256)),U9n=Yt(["escalated","sender_archived","sender_absent"]),lCi=Yt(["working","waiting_on_agent","needs_you","idle","failed","unavailable"]),dCi=oe({agentId:A4,name:A4,sessionId:Dn(A4),state:lCi,attention:wt(Ce.check(Wt(200))),waitingOn:wt(A4),escalated:wt(oe({by:A4,reason:U9n})),ask:wt(oe({askId:A4,questions:TY}))}),pCi=oe({agents:bn(dCi).check(Wt(gMe)),more:kn.check(_r(0)),uncounted:kn.check(_r(0)),counts:oe({working:kn.check(_r(0)),waiting_on_agent:kn.check(_r(0)),needs_you:kn.check(_r(0)),idle:kn.check(_r(0)),failed:kn.check(_r(0)),unavailable:kn.check(_r(0))}),escalated:kn.check(_r(0)),waitingOn:bn(oe({name:A4,count:kn.check(ea(0))})),escalatedBy:bn(oe({name:A4,reason:U9n,count:kn.check(ea(0))})),expanded:ai}),fCi={agentId:A4,sessionId:A4},mCi=Nn(aMe.members.map((e)=>oe({...e.fields,...fCi}))),hCi={agents:{scope:"session",input:oe({}),output:Xx},answerChild:{scope:"session",input:mCi,output:Xx}},GB={id:Zu.make("botanical-session-subagents"),commands:hCi,projection:{schema:pCi}}});function Vme(e){if(e===void 0)return;return e.reason==="escalated"?`escalated by ${e.by}`:e.reason==="sender_archived"?`${e.by} archived`:`${e.by} is gone`}function xMe(e,t){if(e.unreadable!==void 0)return`${e.agentId} (unreadable: ${e.unreadable})`;let n=e.name??e.agentId;if(e.createdBy===void 0||e.createdBy===null)return n;let r=t.find((i)=>i.agentId===e.createdBy);return`${n}, made by ${r?.name??e.createdBy}`}var oFn,sFn,zCi,Zxt;var evt=A(()=>{Wn();oFn={requestId:D().min(1).max(256),computerId:D().min(1).max(256),computerName:D().min(1).max(256),rootPath:D().min(1).max(4096),hostLabel:D().min(1).max(256),folderLabel:D().min(1).max(256),publicKey:RR().length(44),privateKey:RR().min(1).max(512),backendId:D().regex(/^local-[a-z2-7]{16}$/).optional()},sFn=Xe({...oFn,teamId:D().min(1).max(256)}),zCi=Xe(oFn),Zxt=Xe({type:we("local_backends"),origin:ag().refine((e)=>new URL(e).origin===e),backends:Ge(zCi).min(1).max(16)})});var U7,UCi,jCi,aFn,BCi,tvt,qCi,nvt;var rvt=A(()=>{Wn();U7=D().min(1).max(256),UCi=Xe({localAgentId:U7,databasePath:D().min(1).max(4096),name:U7}),jCi=Xe({selection:tt().int().min(0).max(255),agentId:U7}),aFn=Xe({requestId:U7,target:us("kind",[Xe({kind:we("oauth"),teamId:U7}),Xe({kind:we("oyster")})]),invocationRoot:D().min(1).max(4096),machineLabel:U7,publicKey:RR().length(44),privateKey:RR().min(1).max(512),agents:Ge(UCi).max(256)}),BCi=us("state",[aFn.extend({state:we("pending")}),aFn.extend({state:we("enrolled"),scopeId:U7,deviceId:U7,bindings:Ge(jCi).max(256)})]),tvt=ag().refine((e)=>new URL(e).origin===e),qCi=us("kind",[Xe({kind:we("oauth"),origin:tvt}),Xe({kind:we("oyster"),origin:tvt})]),nvt=Xe({type:we("machine_enrollment"),origin:tvt,enrollments:Ge(BCi).max(256).refine((e)=>e.every((t)=>t.target.kind===e[0]?.target.kind))})});var uFn=gt(function(PHa,cFn){var j7=xi("constants"),WCi=process.cwd,bMe=null,HCi=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){if(!bMe)bMe=WCi.call(process);return bMe};try{process.cwd()}catch(e){}if(typeof process.chdir==="function"){if(SMe=process.chdir,process.chdir=function(e){bMe=null,SMe.call(process,e)},Object.setPrototypeOf)Object.setPrototypeOf(process.chdir,SMe)}var SMe;cFn.exports=GCi;function GCi(e){if(j7.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./))t(e);if(!e.lutimes)n(e);if(e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=r(e.chmod),e.fchmod=r(e.fchmod),e.lchmod=r(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=c(e.statSync),e.fstatSync=c(e.fstatSync),e.lstatSync=c(e.lstatSync),e.chmod&&!e.lchmod)e.lchmod=function(l,d,p){if(p)process.nextTick(p)},e.lchmodSync=function(){};if(e.chown&&!e.lchown)e.lchown=function(l,d,p,f){if(f)process.nextTick(f)},e.lchownSync=function(){};if(HCi==="win32")e.rename=typeof e.rename!=="function"?e.rename:function(l){function d(p,f,m){var h=Date.now(),g=0;l(p,f,function _(y){if(y&&(y.code==="EACCES"||y.code==="EPERM"||y.code==="EBUSY")&&Date.now()-h<60000){if(setTimeout(function(){e.stat(f,function(x,b){if(x&&x.code==="ENOENT")l(p,f,_);else m(y)})},g),g<100)g+=10;return}if(m)m(y)})}if(Object.setPrototypeOf)Object.setPrototypeOf(d,l);return d}(e.rename);e.read=typeof e.read!=="function"?e.read:function(l){function d(p,f,m,h,g,_){var y;if(_&&typeof _==="function"){var x=0;y=function(b,S,T){if(b&&b.code==="EAGAIN"&&x<10)return x++,l.call(e,p,f,m,h,g,y);_.apply(this,arguments)}}return l.call(e,p,f,m,h,g,y)}if(Object.setPrototypeOf)Object.setPrototypeOf(d,l);return d}(e.read),e.readSync=typeof e.readSync!=="function"?e.readSync:function(l){return function(d,p,f,m,h){var g=0;while(!0)try{return l.call(e,d,p,f,m,h)}catch(_){if(_.code==="EAGAIN"&&g<10){g++;continue}throw _}}}(e.readSync);function t(l){l.lchmod=function(d,p,f){l.open(d,j7.O_WRONLY|j7.O_SYMLINK,p,function(m,h){if(m){if(f)f(m);return}l.fchmod(h,p,function(g){l.close(h,function(_){if(f)f(g||_)})})})},l.lchmodSync=function(d,p){var f=l.openSync(d,j7.O_WRONLY|j7.O_SYMLINK,p),m=!0,h;try{h=l.fchmodSync(f,p),m=!1}finally{if(m)try{l.closeSync(f)}catch(g){}else l.closeSync(f)}return h}}function n(l){if(j7.hasOwnProperty("O_SYMLINK")&&l.futimes)l.lutimes=function(d,p,f,m){l.open(d,j7.O_SYMLINK,function(h,g){if(h){if(m)m(h);return}l.futimes(g,p,f,function(_){l.close(g,function(y){if(m)m(_||y)})})})},l.lutimesSync=function(d,p,f){var m=l.openSync(d,j7.O_SYMLINK),h,g=!0;try{h=l.futimesSync(m,p,f),g=!1}finally{if(g)try{l.closeSync(m)}catch(_){}else l.closeSync(m)}return h};else if(l.futimes)l.lutimes=function(d,p,f,m){if(m)process.nextTick(m)},l.lutimesSync=function(){}}function r(l){if(!l)return l;return function(d,p,f){return l.call(e,d,p,function(m){if(u(m))m=null;if(f)f.apply(this,arguments)})}}function i(l){if(!l)return l;return function(d,p){try{return l.call(e,d,p)}catch(f){if(!u(f))throw f}}}function o(l){if(!l)return l;return function(d,p,f,m){return l.call(e,d,p,f,function(h){if(u(h))h=null;if(m)m.apply(this,arguments)})}}function s(l){if(!l)return l;return function(d,p,f){try{return l.call(e,d,p,f)}catch(m){if(!u(m))throw m}}}function a(l){if(!l)return l;return function(d,p,f){if(typeof p==="function")f=p,p=null;function m(h,g){if(g){if(g.uid<0)g.uid+=4294967296;if(g.gid<0)g.gid+=4294967296}if(f)f.apply(this,arguments)}return p?l.call(e,d,p,m):l.call(e,d,m)}}function c(l){if(!l)return l;return function(d,p){var f=p?l.call(e,d,p):l.call(e,d);if(f){if(f.uid<0)f.uid+=4294967296;if(f.gid<0)f.gid+=4294967296}return f}}function u(l){if(!l)return!0;if(l.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;if(d){if(l.code==="EINVAL"||l.code==="EPERM")return!0}return!1}}});var pFn=gt(function(MHa,dFn){var lFn=xi("stream").Stream;dFn.exports=KCi;function KCi(e){return{ReadStream:t,WriteStream:n};function t(r,i){if(!(this instanceof t))return new t(r,i);lFn.call(this);var o=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,i=i||{};var s=Object.keys(i);for(var a=0,c=s.length;a<c;a++){var u=s[a];this[u]=i[u]}if(this.encoding)this.setEncoding(this.encoding);if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!=="number")throw TypeError("end must be a Number");if(this.start>this.end)throw Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(l,d){if(l){o.emit("error",l),o.readable=!1;return}o.fd=d,o.emit("open",d),o._read()})}function n(r,i){if(!(this instanceof n))return new n(r,i);lFn.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};var o=Object.keys(i);for(var s=0,a=o.length;s<a;s++){var c=o[s];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.start<0)throw Error("start must be >= zero");this.pos=this.start}if(this.busy=!1,this._queue=[],this.fd===null)this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush()}}});var mFn=gt(function(NHa,fFn){fFn.exports=JCi;var VCi=Object.getPrototypeOf||function(e){return e.__proto__};function JCi(e){if(e===null||typeof e!=="object")return e;if(e instanceof Object)var t={__proto__:VCi(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}});var cvt=gt(function(LHa,avt){var Wf=xi("fs"),QCi=uFn(),XCi=pFn(),YCi=mFn(),wMe=xi("util"),ey,kMe;if(typeof Symbol==="function"&&typeof Symbol.for==="function")ey=Symbol.for("graceful-fs.queue"),kMe=Symbol.for("graceful-fs.previous");else ey="___graceful-fs.queue",kMe="___graceful-fs.previous";function ZCi(){}function gFn(e,t){Object.defineProperty(e,ey,{get:function(){return t}})}var VB=ZCi;if(wMe.debuglog)VB=wMe.debuglog("gfs4");else if(/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))VB=function(){var e=wMe.format.apply(wMe,arguments);e="GFS4: "+e.split(/\n/).join(`
|
|
1340
|
+
`),n,Ext()).parse()})}for(let i of r){let o=n.footnoteCounts?.[t[i.number-1]]??1;if(o>1)i.referenceCount=o}return{type:"footnotes",items:r}}function zIi(e){let t=new Set;for(let n of e.split(",")){let r=n.trim().match(/^(\d+)(?:-(\d+))?$/);if(!r)continue;let i=Number(r[1]),o=Number(r[2]??r[1]);for(let s=i;s<=o&&s<i+1000;s++)t.add(s)}return[...t].sort((n,r)=>n-r)}function Bme(e){let t=e.match(/^(\s{0,8})([-+*]|\d{1,9}[.)])(?:([ \t]+)(.*))?$/);if(!t)return;let n=t[2],r=/\d/.test(n[0]);return{ordered:r,...r?{number:Number.parseInt(n,10)}:{},indent:t[1].length,marker:r?n.at(-1):n,contentIndent:t[1].length+n.length+(t[3]?.length??1),content:t[4]??""}}function a9n(e,t){return e.ordered===t.ordered&&e.marker===t.marker}function c9n(e){return e.match(/^ */)?.[0].length??0}function Rxt(e,t){let n=Bme(e);return/^ {0,3}(`{3,}|~{3,})/.test(e)||/^ {0,3}#{1,6}(?:\s+|$)/.test(e)||/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/.test(e)||/^ {0,3}>\s?/.test(e)||n!==void 0&&(!n.ordered||n.number===1)||!!t&&d9n(e,t)}function d9n(e,t){if(!e.includes("|"))return!1;let n=qme(t);return n.length===qme(e).length&&n.every((r)=>/^:?-+:?$/.test(r.trim()))}function qme(e){let t=e.trim();if(t.startsWith("|"))t=t.slice(1);if(t.endsWith("|"))t=t.slice(0,-1);let n=[],r="";for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"&&t[i+1]==="|"){r+="|",i++;continue}if(o==="|"){n.push(r.trim()),r="";continue}r+=o}return n.push(r.trim()),n}function UIi(e){let t=e.trim();if(t.startsWith(":")&&t.endsWith(":"))return"center";if(t.endsWith(":"))return"right";if(t.startsWith(":"))return"left";return}function u9n(e,t){return{type:"tableCell",children:SY(e,t)}}var NIi=64;var p9n=A(()=>{s9n();Txt()});function Dxt(e){return Ns(()=>l9n(e,{allowHtml:!1,frontmatter:!1}),[e])}var f9n=A(()=>{p9n();Xi()});function m9n(e){return[...e.value.panel.flatMap((t)=>t.actions??[]),...e.value.timeline.cells.flatMap((t)=>t.rows.flatMap((n)=>n.actions??[])),...e.value.waiting===null?[]:[e.value.waiting.cancel]]}function h9n(e){let t=new AbortController,n=()=>t.signal.aborted,r=new Set,i=new Map,o=new Map,s=(u,l)=>JSON.stringify([u,l.id,l.input??{}]),a=()=>{if(n())return;let u=new Map,l=new Set;for(let d of e.contributions())for(let p of m9n(d)){let f=s(d.entryId,p);l.add(f);let m=o.get(f);if(m!==void 0)u.set(p,m)}for(let[d,p]of o)if(!l.has(d)&&!p.pending)o.delete(d);i=u;for(let d of r)d()},c=(u,l)=>{if(n())return;o.set(u,l),a()};return{snapshot:()=>i,refresh:a,subscribe:(u)=>(r.add(u),()=>{r.delete(u)}),execute:async(u,l,d=!1)=>{let p=e.contributions().find((g)=>g.entryId===u);if(n()||!e.online()||p===void 0||!m9n(p).includes(l)||d&&p.value.waiting?.cancel!==l)return;if(l.awaiting!==void 0){e.interactions.awaiting.focus();return}let f=s(u,l);if(o.get(f)?.pending)return;c(f,{pending:!0});let m;try{let g={origin:"menu",signal:t.signal};if(l.input!==void 0)g={...g,arguments:l.input};m=await e.commands.execute({namespace:u,id:l.id},g)}catch(g){if(M_("client row command",g),n())return;let _=g instanceof Error?g:Error("Client row command failed",{cause:g});c(f,{pending:!1,error:_.message}),e.interactions.report({tone:"error",message:_.message});return}if(n())return;let h=m.status==="handled"?void 0:m.status==="failed"?m.error.message:m.status==="unavailable"?m.reason:`Client row command ${m.status}`;if(c(f,h===void 0?{pending:!1}:{pending:!1,error:h}),h!==void 0)e.interactions.report({tone:"error",message:h})},dispose:()=>{t.abort(),i=new Map,o.clear(),r.clear()}}}var g9n=A(()=>{cY()});function Oxt(e){let t=LI(),{observation:n}=NI(),r=Ime(),i=Tme(),[o,s]=ii(),a=Pr({contributions:t,observation:n});return a.current={contributions:t,observation:n},Qn(()=>{let u=h9n({commands:e,contributions:()=>a.current.contributions,online:()=>a.current.observation.status==="live",interactions:r});return s(u),()=>{u.dispose()}},[e,r,i]),Qn(()=>{o?.refresh()},[o,t]),{state:Ka(o?.subscribe??BIi,o?.snapshot??_9n,o?.snapshot??_9n),enabled:o!==void 0&&n.status==="live",execute:(u,l,d=!1)=>o?.execute(u,l,d)??Promise.resolve()}}var jIi,_9n=()=>jIi,BIi=()=>()=>{return};var y9n=A(()=>{Xi();bPe();g9n();jIi=new Map});function x9n(e,t){if(t.prompt!==void 0)return e;return t.status==="failed"?{...e,phase:"refused",refusal:t.failure??"Something went wrong."}:{...e,phase:"sending"}}function Pxt(e,t){let{host:n}=e,r=Ka(n.subscribe,n.snapshot),i=Pr(),o=r.prompt;if(o?.request.type==="decision")i.current={sequence:o.sequence,prompt:o.request};let[,s]=ii(),a=Pr(),c=i.current,u=()=>c!==void 0&&a.current?.sequence===c.sequence?a.current.state:vxt(),l=(d)=>{if(c===void 0)return;a.current={sequence:c.sequence,state:d},s(a.current)};return{view:c===void 0?void 0:bxt(x9n(u(),r),c.prompt,{kind:e.kind,position:t.position,total:t.total}),later:t.later,dispatch:(d)=>{if(c===void 0)return;let p=n.snapshot();if(p.prompt===void 0&&p.status==="failed"){if(d.type==="enter")n.retry();else if(d.type==="escape")t.later();return}let f=XPe(x9n(u(),p),d,c.prompt);l(f.state);let m=f.effect;if(m?.type==="later")t.later();else if(m?.type==="answer"){let h={selected:m.selected};if(m.text!==void 0)h.text=m.text;if(!n.answer(c.sequence,h))l(XPe(f.state,{type:"refused",message:"That answer was not accepted. Choose again."},c.prompt).state)}}}}var v9n=A(()=>{Xi();YPe()});function S9n(e,t){let{record:n}=e,r=Math.max(0,n.expiresAt-t);return[["Agent",`${n.requester.displayName} \xB7 ${n.requester.agentId??"none"}`],["Session",n.requester.sessionId??"none"],["Requester",n.requester.principalId],["Request",`${n.module}.${n.operation} \xB7 ${n.access}`],["Input",`${n.description.inputBytes.toLocaleString()} bytes \xB7 SHA-256 ${n.description.inputSha256.slice(0,8)}\u2026${n.description.inputSha256.slice(-6)}`],["Expires",`in ${String(Math.floor(r/3600000))} h ${String(Math.floor(r%3600000/60000))} m`],["Record",`${n.recordId} \xB7 revision ${String(n.revision)}`]]}function w9n(e){return["Undo",e.record.reversibility==="irreversible-external"?"Can't be undone":"Can be undone"]}function qIi(e,t){let{record:n}=e;return{content:{title:`Allow ${n.module} \xB7 ${n.operation}?`,summary:`${n.requester.displayName} wants to use a connected tool.`,facts:[{label:"Effect",value:(n.access==="write"?"Changes data in Fungi":"Changes things outside Fungi")+(n.reversibility==="irreversible-external"?" \xB7 can't be undone":"")}],details:Nxt([w9n(e),...S9n(e,t)])}}}function WIi(e,t,n,r,i){let o=t.prefix?.join(" "),s=o!==void 0&&t.alwaysAllowUnavailableReason===void 0,a=t.command,c=`Allow \`${a}\`?`.length<=n?`Allow \`${a}\`?`:"Allow this command?",u=t.cwd===r?"~":t.cwd.startsWith(`${r}/`)?`~${t.cwd.slice(r.length)}`:t.cwd,l=Math.max(8,(n-8)*2-2),d=t.justification.length<=l?`\u201C${t.justification}\u201D`:`\u201C${t.justification.slice(0,l-1)}\u2026\u201D`,p=[["Folder",b9n(u,Math.max(8,n-10))],["Why",d]];if(t.kind==="extension-install")p.push(["Note","Extensions run inside Fungi with access to every Agent."]);if(s&&t.alwaysAllowCoverage!==void 0)p.push(["Scope",Mxt(t.alwaysAllowCoverage,Math.max(8,n-12))]);if(!s&&t.risk!==void 0)p.push(["Risk",t.risk.summary]);let f=!s?void 0:`Always allow \u201C${b9n(o,Math.max(8,n-5-32))}\u201D in this project\u2026`,m=[["Command",a]];if(t.argv!==void 0)m.push(["Arguments",JSON.stringify(t.argv)]);if(m.push(["Folder",t.cwd],["Runs","Outside the sandbox, as you"],w9n(e)),!s&&t.alwaysAllowUnavailableReason!==void 0)m.push(["Rule",t.alwaysAllowUnavailableReason]);else if(t.form==="shell")m.push(["Rule","Shell command: no Always-allow rule can match it."]);else if(s){if(m.push(["Rule",`\u201C${o}\u201D would match \`${o} \u2026\` in this project`]),t.alwaysAllowCoverage!==void 0)m.push(["Coverage",t.alwaysAllowCoverage])}if(t.risk!==void 0)m.push(["Risk",t.risk.detail]);return m.push(...S9n(e,i)),{content:{title:c,body:c==="Allow this command?"?a:void 0,bodyLabel:c==="Allow this command?"?"Command":void 0,summary:`${e.record.requester.displayName} wants to run this outside the sandbox, as you.`,facts:Nxt(p),details:Nxt(m)},always:f===void 0?void 0:Mxt(f,Math.max(12,n-5)),confirmation:!s?void 0:{title:`Always allow \u201C${o}\u201D in this project?`,body:Mxt(t.alwaysAllowCoverage??`Any Workspace Agent here can then run \`${o} \u2026\` without asking.`,Math.max(12,(n-8)*2-2))},confirmWarning:s?t.risk?.summary:void 0,confirmYes:!s?void 0:`Always allow \u201C${o}\u201D and run it now`}}function HIi(e,t,n){let r=Math.min(n.width,60);return t===void 0?qIi(e,n.now):WIi(e,t,r,n.home,n.now)}function GIi(e,t){switch(e){case"stale-revision":case"already-answered":case"not-pending":return"This request changed. Look again before answering.";case"expired":return"This request expired. Nothing ran.";case"not-found":return"This request is gone. Nothing ran. Ask the Agent to try again.";case"declined":return"This request was already denied. Nothing ran.";case"not-eligible":return t==="always-allow"?"Always allow isn't available for this command. Approve once or deny.":"You can't answer this request. Nothing ran. Ask whoever owns it.";case"not-granted":case"read-only":return"You aren't allowed to answer this request. Nothing ran. Ask whoever owns it.";case"fenced":case"identity-conflict":return"This request no longer matches what you saw. Nothing ran. Refresh and look again.";case"pending":return"This request hasn't been answered yet. Answer it first.";case"in-flight":return"This is already running. Wait for it to finish.";case"outcome-unknown":return"We can't tell whether this ran. Check before trying again.";case"not-attached":return"This session isn't connected anymore. Reconnect and try again. Nothing ran.";default:return"Couldn't answer this request. Nothing ran. Try again."}}async function E9n(e,t){let{view:n,source:r}=t,i=HIi(n,r.review,{width:t.width,home:t.home,now:t.now}),o=n.record;try{let s,a,c=!1;while(s===void 0){let d=await e.prompt({type:"decision",message:i.content.title,summary:c?"Automatic approval is on for this family.":i.content.summary,facts:i.content.facts?.map((p)=>({...p})),body:i.content.body,bodyLabel:i.content.bodyLabel,details:i.content.details?.map((p)=>({...p})),options:[{value:"approve",label:"Approve once"},...i.always===void 0?[]:[{value:"always",label:i.always}],...r.family===void 0||c?[]:[{value:"family",label:r.family.label}],{value:"deny",label:"Deny"}],other:{label:"Deny and say why\u2026",placeholder:"A short reason for the Agent (optional)",maxLength:t.noteLimit,blank:"deny"}});if(!t.stillCurrent())return{kind:"abandoned"};if(d.text!==void 0)a=d.text.trim()||void 0,s="deny";else if(d.selected[0]==="always"){let p=i.confirmation,f=await e.prompt({type:"decision",message:p?.title??i.content.title,summary:i.confirmWarning,body:p?.body,options:[{value:"back",label:"Back"},{value:"always-allow",label:i.confirmYes??"Always allow"}],escape:"back"});if(!t.stillCurrent())return{kind:"abandoned"};if(f.selected[0]==="always-allow")s="always-allow"}else if(d.selected[0]==="family"&&r.family!==void 0){let p=await e.prompt({type:"decision",message:`${r.family.label}?`,summary:`Later ${o.module} requests that ${o.access==="write"?"change data in Fungi":"reach outside Fungi"} will run without asking.`,options:[{value:"back",label:"Back"},{value:"family",label:r.family.label}],escape:"back"});if(!t.stillCurrent())return{kind:"abandoned"};if(p.selected[0]==="family"){if(c=await r.family.enable(),!t.stillCurrent())return{kind:"abandoned"}}}else if(d.selected[0]==="approve")s="approve";else if(d.selected[0]==="deny")s="deny"}let u={recordId:o.recordId,decision:s,expectedRevision:o.revision},l=await r.answer(a===void 0?u:{...u,denialNote:a});if(!t.stillCurrent())return{kind:"abandoned"};return l.kind==="refused"?{kind:"refused",message:GIi(l.reason??"unknown",s)}:{kind:"answered"}}catch(s){if(e.signal.aborted)return{kind:"abandoned"};return t.onFailure(s),{kind:"refused",message:KIi}}}var b9n=(e,t)=>{if(e.length<=t)return e;let n=Math.max(1,Math.floor((t-1)/2));return`${e.slice(0,n)}\u2026${e.slice(-(t-n-1))}`},Mxt=(e,t)=>e.length<=t?e:`${e.slice(0,t-1)}\u2026`,Nxt=(e)=>e.map(([t,n])=>({label:t,value:n})),KIi="Couldn't send your answer. It may not have been recorded.";function nMe(e){let{source:t,store:n,enabled:r,home:i,width:o,noteLimit:s,onFailure:a}=e,c=Pr(a);c.current=a;let u=Pr({home:i,width:o,noteLimit:s});u.current={home:i,width:o,noteLimit:s};let l=Ka(t?.subscribe??JIi,t?.snapshot??VIi),d=Pr(l);d.current=l;let p=l===void 0?void 0:JSON.stringify(["approval",l.record.recordId,l.record.revision,l.canAnswer]);Qn(()=>{let f=d.current;if(!r||t===void 0||f===void 0)return;if(!f.canAnswer||p===void 0)return;let{home:m,width:h,noteLimit:g}=u.current,_=s7({title:"Approval"}),y=_.begin(),x=()=>{let S=t.snapshot();return!y.interaction.signal.aborted&&S?.record.recordId===f.record.recordId&&S.record.revision===f.record.revision&&S.canAnswer},b=n.awaiting.add({key:p,kind:"approval",arrivedAt:Date.now(),host:_});return E9n(y.interaction,{view:f,source:t,home:m,width:h,now:Date.now(),noteLimit:g,stillCurrent:x,onFailure:(S)=>{c.current(S)}}).then((S)=>{if(S.kind==="refused")y.settle({status:"failed",message:S.message});else b(),y.settle(S.kind==="answered"?{status:"handled"}:{status:"cancelled"})}),()=>{b(),_.cancel()}},[t,p,r,n])}var VIi=()=>{return},JIi=()=>()=>{return};var k9n=A(()=>{mX();Xi()});function Lxt(e){let t=new Map;for(let r of e){let i=t.get(r.entryId);if(i===void 0)t.set(r.entryId,[r]);else i.push(r)}for(let r of t.values())r.sort((i,o)=>i.cell.sequence-o.cell.sequence);let n=[];while(t.size>0){let r=[...t.values()].flatMap((s)=>s[0]===void 0?[]:[s[0]]);r.sort((s,a)=>s.cell.at-a.cell.at||(s.entryId<a.entryId?-1:s.entryId>a.entryId?1:0)||s.cell.sequence-a.cell.sequence);let i=r[0];if(i===void 0)break;n.push(i);let o=t.get(i.entryId);if(o?.shift(),o?.length===0)t.delete(i.entryId)}return n}function BB(e,t,n=new Map){let r=new Map,i=[],o=[];for(let{entryId:s,value:a}of e)for(let c of a.timeline.cells){let u={entryId:s,cell:c};if(c.afterSequence===void 0&&c.commandId===null){o.push(u);continue}let l=c.afterSequence!==void 0?n.get(c.afterSequence):c.commandId===null?void 0:t.get(c.commandId);if(l===void 0)continue;if(l===null){i.push(u);continue}let d=r.get(l);if(d===void 0)r.set(l,[u]);else d.push(u)}return{before:Lxt(i),after:new Map([...r].map(([s,a])=>[s,Lxt(a)])),unanchored:Lxt(o),omitted:e.flatMap(({entryId:s,value:a})=>a.timeline.omitted===0?[]:[{entryId:s,count:a.timeline.omitted}])}}var Tm=A(()=>{cUe();bPe();afe();lfe();m1t();C1t();iNn();W7n();Fgt();t9n();f9n();s1t();hPe();y9n();YPe();v9n();k9n()});function yr(e){return nne(e)}var k1=A(()=>{Tm()});function Ow(e){return Array.from(yr(e).replace(/[\n\t]/gu,"")).slice(0,512).join("")}var kY=A(()=>{k1()});function Gl(e){return{type:"done",notice:e}}function Wme(e){return{type:"done",notice:e,result:{cancelled:!0}}}function Z0(e,t,n){return{type:"prompt",prompt:e,next:{arguments:t,answer:n}}}function jb(e){return gLn(JSON.stringify({protocol:"whistle.catalog/v1",commands:e}))}var Xx,UI;var T1=A(()=>{HDe();Nd();Ar();cr();Yd();Xx=k0((e)=>Mgt.safeParse(e).success,{representation:{id:"@fungi.computer/whistle/catalog-step/v1",payload:null}});UI=Vt(()=>Kc())});var xk=(e)=>Ce.check(Yn(1),Wt(e),Jc(/\S/u)),T9n,TY,Hme,rMe,Fxt,qB,iMe,$xt,sMe,oMe,A9n,zxt,Uxt,I9n,QIi,XIi,aMe,Bb;var F7=A(()=>{Yd();cr();T1();T9n=oe({id:xk(32).check(Jc(/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/u)),header:xk(12),question:xk(1000),options:bn(oe({label:xk(60),description:xk(300)})).check(Yn(2),Wt(4),Sr((e)=>new Set(e.map((t)=>t.label)).size===e.length||"Option labels must be unique",{representation:{id:"botanical/ask/unique-option-labels",payload:null}})),multiple:wt(ai)}),TY=bn(T9n).check(Yn(1),Wt(4),Sr((e)=>new Set(e.map((t)=>t.id)).size===e.length||"Question ids must be unique",{representation:{id:"botanical/ask/unique-question-ids",payload:null}})),Hme=oe({askId:Ce,waitingOn:wt(YE),escalated:wt(QG),questions:TY,status:Yt(["live","parked"]),createdAt:gr,expiresAt:Dn(gr)}),rMe=oe({asks:bn(Hme).check(Wt(4))}),Fxt=xk(256),qB=gc(T9n.fields.id,oe({selected:bn(xk(60)).check(Wt(4)),text:wt(Ce.check(Wt(4000)))})),iMe=oe({askId:xk(256),requestId:Fxt,answers:qB}),$xt=oe({askId:xk(256),requestId:Fxt,note:wt(Ce.check(Wt(4000)))}),sMe=Yt(["answered","declined","withdrawn","expired","cancelled","undeliverable"]),oMe=Nn([oe({result:Je("accepted"),via:Yt(["in_turn","follow_up"]),commandId:wt(xk(256))}),oe({result:Je("closed"),status:sMe}),oe({result:Je("not_found")})]),A9n=oe({result:Je("refused"),reason:Je("not_sender")}),zxt=Nn([oMe,A9n]),Uxt=oe({kind:Je("agent"),agentId:xk(256)}),I9n=Nn([oe({result:Je("escalated"),to:Je("agent"),waitingOn:YE}),oe({result:Je("escalated"),to:Je("person")}),oe({result:Je("closed"),status:sMe}),oe({result:Je("not_found")}),A9n]),QIi=oe({askId:xk(256),note:Rn(Ce.check(Wt(1000)))}),XIi={askId:iMe.fields.askId,requestId:Fxt,index:gr.check(Cf(),lp({minimum:0,maximum:3})),answers:qB},aMe=Nn([oe({stage:Je("decision"),...XIi,answer:qB.value}),oe({askId:iMe.fields.askId}),oe({})]),Bb={id:Zu.make("botanical-session-question"),commands:{answerFlow:{scope:"session",input:aMe,output:Xx},answer:{scope:"session",input:iMe,output:oMe},answerAgent:{scope:"session",input:iMe,output:oe({result:zxt,answeredBy:Uxt})},escalateAgent:{scope:"session",input:QIi,output:I9n},decline:{scope:"session",input:$xt,output:oMe},list:{scope:"session",input:oe({}),output:rMe}},projection:{schema:rMe}}});var WB,HB,jxt,C9n,YIi,$7,Bxt,uMe=16,R9n,ZIi,A1;var AY=A(()=>{Yd();cr();T1();WB=Ce.pipe(lt(Yn(1)),lt(Wt(4000)),lt(Jc(/\S/u,{message:"Goal objective is blank"}))),HB=Ce.pipe(lt(Yn(1)),lt(Wt(1000)),lt(Jc(/\S/u))),jxt=Ce.pipe(lt(Yn(1)),lt(Wt(256))),C9n=kn.check(_r(0)),YIi=oe({kind:Yt(["person","delegator","blocked","stalled","cancelled","failed","no-terminal"]),detail:Dn(Ce)}),$7=oe({revision:Ce,objective:WB,state:Yt(["active","paused"]),startedAt:C9n,pauseCause:Dn(YIi)}),Bxt=oe({sequence:kn.check(ea(0)),objective:WB,outcome:Yt(["achieved","cleared"]),reason:Dn(HB),clearedBy:wt(Xy.check(Wt(256))),endedAt:C9n,afterSequence:kn.check(_r(0))}),R9n=Nn([oe({action:Je("set"),objective:WB,requestId:jxt,expectedRevision:Rn(Dn(Ce)),confirmed:Rn(ai)}),oe({action:Yt(["pause","resume","replace","clear","clear-ask"]),confirmed:Rn(ai)}),oe({})]),ZIi=oe({goal:Dn($7),ended:bn(Bxt).check(Wt(uMe)),omitted:kn.check(_r(0))}),A1={id:Zu.make("botanical-session-goal"),commands:{controlAgent:{scope:"session",input:oe({action:Yt(["pause","resume","clear"]),reason:HB}),output:Nn([oe({result:Je("paused"),goal:$7}),oe({result:Je("resumed"),goal:$7}),oe({result:Je("cleared")}),oe({result:Je("no_goal")}),oe({result:Je("refused"),reason:Yt(["not_delegator","not_paused_by_delegator"])})])},goal:{scope:"session",input:R9n,output:Xx},pause:{scope:"session",input:oe({}),output:$7},resume:{scope:"session",input:oe({}),output:$7},clear:{scope:"session",input:oe({}),output:oe({})},set:{scope:"session",input:oe({objective:WB,expectedRevision:Dn(Ce),requestId:jxt,adoptCommandId:wt(jxt)}),output:oe({goal:$7,accepted:oe({status:Je("accepted"),commandId:Ce})})}},projection:{schema:ZIi}}});var qb,jI;var IY=A(()=>{cr();qb=Ce.pipe(lt(Yn(1)),lt(Wt(256))),jI=Ce.pipe(lt(Yn(1)),lt(Wt(262144)))});var lMe,Mg,dMe;var pMe=A(()=>{cr();IY();lMe=oe({expression:Ce.pipe(lt(Yn(1)),lt(Wt(256))),timeZone:Ce.pipe(lt(Yn(1)),lt(Wt(128)))}),Mg=oe({loopId:Ce,origin:Yt(["human","model"]),expiresAt:Dn(kn),prompt:jI,mode:Yt(["self_paced","fixed_interval"]),cron:Dn(lMe),state:Yt(["active","paused","finished","failed","cancelled"]),commandId:Ce,reason:Dn(Ce),nextDueAt:Dn(kn),lastError:Dn(Ce),consecutiveFailures:kn.pipe(lt(_r(0)))}),dMe=oe({after:wt(qb),limit:wt(kn.pipe(lt(lp({minimum:1,maximum:64}))))})});var Wxt,O9n,P9n,rCi,qxt,BO;var Kme=A(()=>{Yd();cr();T1();IY();pMe();pMe();Wxt=Ce.pipe(lt(Yn(1)),lt(Wt(200))),O9n=oe({loop:Mg,accepted:oe({status:Je("accepted"),commandId:Ce})}),P9n=Nn([oe({action:Je("start"),text:jI,requestId:Wxt}),oe({action:Yt(["status","pause","resume","stop","stop-ask","new"]),confirmed:Rn(ai)}),oe({})]),rCi=oe({loop:Mg}),qxt=oe({sessionId:qb,loopId:Mg.fields.loopId}),BO={id:Zu.make("botanical-session-loop"),commands:{list:{scope:"agent",input:dMe,output:bn(oe({...Mg.fields,sessionId:qb})).pipe(lt(Wt(64)))},pauseLoop:{scope:"agent",input:qxt,output:Mg},resumeLoop:{scope:"agent",input:qxt,output:Mg},stopLoop:{scope:"agent",input:qxt,output:Mg},loop:{scope:"session",input:P9n,output:Xx},startSelfPaced:{scope:"session",input:oe({prompt:jI,requestId:Wxt}),output:O9n},startFixedInterval:{scope:"session",input:oe({prompt:jI,requestId:Wxt,...lMe.fields}),output:O9n},pause:{scope:"session",input:oe({}),output:Mg},resume:{scope:"session",input:oe({}),output:Mg},stop:{scope:"session",input:oe({}),output:Mg}},projection:{schema:rCi}}});function fMe(e){return oe({nextSequence:kn.check(ea(0)),omitted:kn.check(_r(0)),events:bn(oe({id:Ce,sequence:kn,at:kn,commandId:Dn(Ce),event:e}))})}function Hxt(){return{nextSequence:1,omitted:0,events:[]}}function F9n(e,t,n,r){let i=e.nextSequence,o=[...e.events,{id:String(i),sequence:i,at:r,commandId:n,event:t}],s={nextSequence:i+1,omitted:e.omitted,events:o};while(o.length>32||oCi.encode(JSON.stringify(s)).length>32768){if(o.length===0)break;o.shift(),s.omitted+=1}return s}var oCi;var Gxt=A(()=>{cr();oCi=new TextEncoder});function mMe(e){return e.steps.some((t)=>t.status!=="completed")}var CY,$9n,sCi,aCi,z7;var hMe=A(()=>{Gxt();Yd();cr();T1();CY=oe({explanation:wt(Ce.pipe(lt(Wt(2000)))),steps:bn(oe({step:Ce.pipe(lt(Yn(1)),lt(Wt(500))),status:Yt(["pending","in_progress","completed"])})).pipe(lt(Wt(50)))}),$9n=CY.pipe(lt(Sr((e)=>e.steps.filter((t)=>t.status==="in_progress").length<=1||"At most one plan step may be in progress")));sCi=oe({plan:CY,history:fMe(CY)}),aCi=Nn([oe({action:Je("clear")}),oe({})]),z7={id:Zu.make("botanical-session-plan"),commands:{plan:{scope:"session",input:aCi,output:Xx}},projection:{schema:sCi}}});var A4,U9n,gMe=16,j9n=256,lCi,dCi,pCi,fCi,mCi,hCi,GB;var Kxt=A(()=>{Yd();cr();T1();F7();A4=Ce.check(Yn(1),Wt(256)),U9n=Yt(["escalated","sender_archived","sender_absent"]),lCi=Yt(["working","waiting_on_agent","needs_you","idle","failed","unavailable"]),dCi=oe({agentId:A4,name:A4,sessionId:Dn(A4),state:lCi,attention:wt(Ce.check(Wt(200))),waitingOn:wt(A4),escalated:wt(oe({by:A4,reason:U9n})),ask:wt(oe({askId:A4,questions:TY}))}),pCi=oe({agents:bn(dCi).check(Wt(gMe)),more:kn.check(_r(0)),uncounted:kn.check(_r(0)),counts:oe({working:kn.check(_r(0)),waiting_on_agent:kn.check(_r(0)),needs_you:kn.check(_r(0)),idle:kn.check(_r(0)),failed:kn.check(_r(0)),unavailable:kn.check(_r(0))}),escalated:kn.check(_r(0)),waitingOn:bn(oe({name:A4,count:kn.check(ea(0))})),escalatedBy:bn(oe({name:A4,reason:U9n,count:kn.check(ea(0))})),expanded:ai}),fCi={agentId:A4,sessionId:A4},mCi=Nn(aMe.members.map((e)=>oe({...e.fields,...fCi}))),hCi={agents:{scope:"session",input:oe({}),output:Xx},answerChild:{scope:"session",input:mCi,output:Xx}},GB={id:Zu.make("botanical-session-subagents"),commands:hCi,projection:{schema:pCi}}});function Vme(e){if(e===void 0)return;return e.reason==="escalated"?`escalated by ${e.by}`:e.reason==="sender_archived"?`${e.by} archived`:`${e.by} is gone`}function xMe(e,t){if(e.unreadable!==void 0)return`${e.agentId} (unreadable: ${e.unreadable})`;let n=e.name??e.agentId;if(e.createdBy===void 0||e.createdBy===null)return n;let r=t.find((i)=>i.agentId===e.createdBy);return`${n}, made by ${r?.name??e.createdBy}`}var oFn,sFn,zCi,Zxt;var evt=A(()=>{Wn();oFn={requestId:D().min(1).max(256),computerId:D().min(1).max(256),computerName:D().min(1).max(256),rootPath:D().min(1).max(4096),hostLabel:D().min(1).max(256),folderLabel:D().min(1).max(256),publicKey:RR().length(44),privateKey:RR().min(1).max(512),backendId:D().regex(/^local-[a-z2-7]{16}$/).optional()},sFn=Xe({...oFn,teamId:D().min(1).max(256)}),zCi=Xe(oFn),Zxt=Xe({type:we("local_backends"),origin:ag().refine((e)=>new URL(e).origin===e),backends:Ge(zCi).min(1).max(16)})});var U7,UCi,jCi,aFn,BCi,tvt,qCi,nvt;var rvt=A(()=>{Wn();U7=D().min(1).max(256),UCi=Xe({localAgentId:U7,databasePath:D().min(1).max(4096),name:U7}),jCi=Xe({selection:tt().int().min(0).max(255),agentId:U7}),aFn=Xe({requestId:U7,target:us("kind",[Xe({kind:we("oauth"),teamId:U7}),Xe({kind:we("oyster")})]),invocationRoot:D().min(1).max(4096),machineLabel:U7,publicKey:RR().length(44),privateKey:RR().min(1).max(512),agents:Ge(UCi).max(256)}),BCi=us("state",[aFn.extend({state:we("pending")}),aFn.extend({state:we("enrolled"),scopeId:U7,deviceId:U7,bindings:Ge(jCi).max(256)})]),tvt=ag().refine((e)=>new URL(e).origin===e),qCi=us("kind",[Xe({kind:we("oauth"),origin:tvt}),Xe({kind:we("oyster"),origin:tvt})]),nvt=Xe({type:we("machine_enrollment"),origin:tvt,enrollments:Ge(BCi).max(256).refine((e)=>e.every((t)=>t.target.kind===e[0]?.target.kind))})});var uFn=gt(function(PHa,cFn){var j7=xi("constants"),WCi=process.cwd,bMe=null,HCi=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){if(!bMe)bMe=WCi.call(process);return bMe};try{process.cwd()}catch(e){}if(typeof process.chdir==="function"){if(SMe=process.chdir,process.chdir=function(e){bMe=null,SMe.call(process,e)},Object.setPrototypeOf)Object.setPrototypeOf(process.chdir,SMe)}var SMe;cFn.exports=GCi;function GCi(e){if(j7.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./))t(e);if(!e.lutimes)n(e);if(e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=r(e.chmod),e.fchmod=r(e.fchmod),e.lchmod=r(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=c(e.statSync),e.fstatSync=c(e.fstatSync),e.lstatSync=c(e.lstatSync),e.chmod&&!e.lchmod)e.lchmod=function(l,d,p){if(p)process.nextTick(p)},e.lchmodSync=function(){};if(e.chown&&!e.lchown)e.lchown=function(l,d,p,f){if(f)process.nextTick(f)},e.lchownSync=function(){};if(HCi==="win32")e.rename=typeof e.rename!=="function"?e.rename:function(l){function d(p,f,m){var h=Date.now(),g=0;l(p,f,function _(y){if(y&&(y.code==="EACCES"||y.code==="EPERM"||y.code==="EBUSY")&&Date.now()-h<60000){if(setTimeout(function(){e.stat(f,function(x,b){if(x&&x.code==="ENOENT")l(p,f,_);else m(y)})},g),g<100)g+=10;return}if(m)m(y)})}if(Object.setPrototypeOf)Object.setPrototypeOf(d,l);return d}(e.rename);e.read=typeof e.read!=="function"?e.read:function(l){function d(p,f,m,h,g,_){var y;if(_&&typeof _==="function"){var x=0;y=function(b,S,T){if(b&&b.code==="EAGAIN"&&x<10)return x++,l.call(e,p,f,m,h,g,y);_.apply(this,arguments)}}return l.call(e,p,f,m,h,g,y)}if(Object.setPrototypeOf)Object.setPrototypeOf(d,l);return d}(e.read),e.readSync=typeof e.readSync!=="function"?e.readSync:function(l){return function(d,p,f,m,h){var g=0;while(!0)try{return l.call(e,d,p,f,m,h)}catch(_){if(_.code==="EAGAIN"&&g<10){g++;continue}throw _}}}(e.readSync);function t(l){l.lchmod=function(d,p,f){l.open(d,j7.O_WRONLY|j7.O_SYMLINK,p,function(m,h){if(m){if(f)f(m);return}l.fchmod(h,p,function(g){l.close(h,function(_){if(f)f(g||_)})})})},l.lchmodSync=function(d,p){var f=l.openSync(d,j7.O_WRONLY|j7.O_SYMLINK,p),m=!0,h;try{h=l.fchmodSync(f,p),m=!1}finally{if(m)try{l.closeSync(f)}catch(g){}else l.closeSync(f)}return h}}function n(l){if(j7.hasOwnProperty("O_SYMLINK")&&l.futimes)l.lutimes=function(d,p,f,m){l.open(d,j7.O_SYMLINK,function(h,g){if(h){if(m)m(h);return}l.futimes(g,p,f,function(_){l.close(g,function(y){if(m)m(_||y)})})})},l.lutimesSync=function(d,p,f){var m=l.openSync(d,j7.O_SYMLINK),h,g=!0;try{h=l.futimesSync(m,p,f),g=!1}finally{if(g)try{l.closeSync(m)}catch(_){}else l.closeSync(m)}return h};else if(l.futimes)l.lutimes=function(d,p,f,m){if(m)process.nextTick(m)},l.lutimesSync=function(){}}function r(l){if(!l)return l;return function(d,p,f){return l.call(e,d,p,function(m){if(u(m))m=null;if(f)f.apply(this,arguments)})}}function i(l){if(!l)return l;return function(d,p){try{return l.call(e,d,p)}catch(f){if(!u(f))throw f}}}function o(l){if(!l)return l;return function(d,p,f,m){return l.call(e,d,p,f,function(h){if(u(h))h=null;if(m)m.apply(this,arguments)})}}function s(l){if(!l)return l;return function(d,p,f){try{return l.call(e,d,p,f)}catch(m){if(!u(m))throw m}}}function a(l){if(!l)return l;return function(d,p,f){if(typeof p==="function")f=p,p=null;function m(h,g){if(g){if(g.uid<0)g.uid+=4294967296;if(g.gid<0)g.gid+=4294967296}if(f)f.apply(this,arguments)}return p?l.call(e,d,p,m):l.call(e,d,m)}}function c(l){if(!l)return l;return function(d,p){var f=p?l.call(e,d,p):l.call(e,d);if(f){if(f.uid<0)f.uid+=4294967296;if(f.gid<0)f.gid+=4294967296}return f}}function u(l){if(!l)return!0;if(l.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;if(d){if(l.code==="EINVAL"||l.code==="EPERM")return!0}return!1}}});var pFn=gt(function(MHa,dFn){var lFn=xi("stream").Stream;dFn.exports=KCi;function KCi(e){return{ReadStream:t,WriteStream:n};function t(r,i){if(!(this instanceof t))return new t(r,i);lFn.call(this);var o=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,i=i||{};var s=Object.keys(i);for(var a=0,c=s.length;a<c;a++){var u=s[a];this[u]=i[u]}if(this.encoding)this.setEncoding(this.encoding);if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!=="number")throw TypeError("end must be a Number");if(this.start>this.end)throw Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(l,d){if(l){o.emit("error",l),o.readable=!1;return}o.fd=d,o.emit("open",d),o._read()})}function n(r,i){if(!(this instanceof n))return new n(r,i);lFn.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};var o=Object.keys(i);for(var s=0,a=o.length;s<a;s++){var c=o[s];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.start<0)throw Error("start must be >= zero");this.pos=this.start}if(this.busy=!1,this._queue=[],this.fd===null)this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush()}}});var mFn=gt(function(NHa,fFn){fFn.exports=JCi;var VCi=Object.getPrototypeOf||function(e){return e.__proto__};function JCi(e){if(e===null||typeof e!=="object")return e;if(e instanceof Object)var t={__proto__:VCi(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}});var cvt=gt(function(LHa,avt){var Wf=xi("fs"),QCi=uFn(),XCi=pFn(),YCi=mFn(),wMe=xi("util"),ey,kMe;if(typeof Symbol==="function"&&typeof Symbol.for==="function")ey=Symbol.for("graceful-fs.queue"),kMe=Symbol.for("graceful-fs.previous");else ey="___graceful-fs.queue",kMe="___graceful-fs.previous";function ZCi(){}function gFn(e,t){Object.defineProperty(e,ey,{get:function(){return t}})}var VB=ZCi;if(wMe.debuglog)VB=wMe.debuglog("gfs4");else if(/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))VB=function(){var e=wMe.format.apply(wMe,arguments);e="GFS4: "+e.split(/\n/).join(`
|
|
1341
1341
|
GFS4: `),console.error(e)};if(!Wf[ey]){if(ivt=global[ey]||[],gFn(Wf,ivt),Wf.close=function(e){function t(n,r){return e.call(Wf,n,function(i){if(!i)hFn();if(typeof r==="function")r.apply(this,arguments)})}return Object.defineProperty(t,kMe,{value:e}),t}(Wf.close),Wf.closeSync=function(e){function t(n){e.apply(Wf,arguments),hFn()}return Object.defineProperty(t,kMe,{value:e}),t}(Wf.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){VB(Wf[ey]),xi("assert").equal(Wf[ey].length,0)})}var ivt;if(!global[ey])gFn(global,Wf[ey]);avt.exports=ovt(YCi(Wf));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Wf.__patched)avt.exports=ovt(Wf),Wf.__patched=!0;function ovt(e){QCi(e),e.gracefulify=ovt,e.createReadStream=S,e.createWriteStream=T;var t=e.readFile;e.readFile=n;function n(F,z,j){if(typeof z==="function")j=z,z=null;return K(F,z,j);function K(te,ee,ge,he){return t(te,ee,function(Se){if(Se&&(Se.code==="EMFILE"||Se.code==="ENFILE"))OY([K,[te,ee,ge],Se,he||Date.now(),Date.now()]);else if(typeof ge==="function")ge.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=i;function i(F,z,j,K){if(typeof j==="function")K=j,j=null;return te(F,z,j,K);function te(ee,ge,he,Se,U){return r(ee,ge,he,function(Q){if(Q&&(Q.code==="EMFILE"||Q.code==="ENFILE"))OY([te,[ee,ge,he,Se],Q,U||Date.now(),Date.now()]);else if(typeof Se==="function")Se.apply(this,arguments)})}}var o=e.appendFile;if(o)e.appendFile=s;function s(F,z,j,K){if(typeof j==="function")K=j,j=null;return te(F,z,j,K);function te(ee,ge,he,Se,U){return o(ee,ge,he,function(Q){if(Q&&(Q.code==="EMFILE"||Q.code==="ENFILE"))OY([te,[ee,ge,he,Se],Q,U||Date.now(),Date.now()]);else if(typeof Se==="function")Se.apply(this,arguments)})}}var a=e.copyFile;if(a)e.copyFile=c;function c(F,z,j,K){if(typeof j==="function")K=j,j=0;return te(F,z,j,K);function te(ee,ge,he,Se,U){return a(ee,ge,he,function(Q){if(Q&&(Q.code==="EMFILE"||Q.code==="ENFILE"))OY([te,[ee,ge,he,Se],Q,U||Date.now(),Date.now()]);else if(typeof Se==="function")Se.apply(this,arguments)})}}var u=e.readdir;e.readdir=d;var l=/^v[0-5]\./;function d(F,z,j){if(typeof z==="function")j=z,z=null;var K=l.test(process.version)?function(ge,he,Se,U){return u(ge,te(ge,he,Se,U))}:function(ge,he,Se,U){return u(ge,he,te(ge,he,Se,U))};return K(F,z,j);function te(ee,ge,he,Se){return function(U,Q){if(U&&(U.code==="EMFILE"||U.code==="ENFILE"))OY([K,[ee,ge,he],U,Se||Date.now(),Date.now()]);else{if(Q&&Q.sort)Q.sort();if(typeof he==="function")he.call(this,U,Q)}}}}if(process.version.substr(0,4)==="v0.8"){var p=XCi(e);_=p.ReadStream,x=p.WriteStream}var f=e.ReadStream;if(f)_.prototype=Object.create(f.prototype),_.prototype.open=y;var m=e.WriteStream;if(m)x.prototype=Object.create(m.prototype),x.prototype.open=b;Object.defineProperty(e,"ReadStream",{get:function(){return _},set:function(F){_=F},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return x},set:function(F){x=F},enumerable:!0,configurable:!0});var h=_;Object.defineProperty(e,"FileReadStream",{get:function(){return h},set:function(F){h=F},enumerable:!0,configurable:!0});var g=x;Object.defineProperty(e,"FileWriteStream",{get:function(){return g},set:function(F){g=F},enumerable:!0,configurable:!0});function _(F,z){if(this instanceof _)return f.apply(this,arguments),this;else return _.apply(Object.create(_.prototype),arguments)}function y(){var F=this;R(F.path,F.flags,F.mode,function(z,j){if(z){if(F.autoClose)F.destroy();F.emit("error",z)}else F.fd=j,F.emit("open",j),F.read()})}function x(F,z){if(this instanceof x)return m.apply(this,arguments),this;else return x.apply(Object.create(x.prototype),arguments)}function b(){var F=this;R(F.path,F.flags,F.mode,function(z,j){if(z)F.destroy(),F.emit("error",z);else F.fd=j,F.emit("open",j)})}function S(F,z){return new e.ReadStream(F,z)}function T(F,z){return new e.WriteStream(F,z)}var I=e.open;e.open=R;function R(F,z,j,K){if(typeof j==="function")K=j,j=null;return te(F,z,j,K);function te(ee,ge,he,Se,U){return I(ee,ge,he,function(Q,Y){if(Q&&(Q.code==="EMFILE"||Q.code==="ENFILE"))OY([te,[ee,ge,he,Se],Q,U||Date.now(),Date.now()]);else if(typeof Se==="function")Se.apply(this,arguments)})}}return e}function OY(e){VB("ENQUEUE",e[0].name,e[1]),Wf[ey].push(e),svt()}var EMe;function hFn(){var e=Date.now();for(var t=0;t<Wf[ey].length;++t)if(Wf[ey][t].length>2)Wf[ey][t][3]=e,Wf[ey][t][4]=e;svt()}function svt(){if(clearTimeout(EMe),EMe=void 0,Wf[ey].length===0)return;var e=Wf[ey].shift(),t=e[0],n=e[1],r=e[2],i=e[3],o=e[4];if(i===void 0)VB("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-i>=60000){VB("TIMEOUT",t.name,n);var s=n.pop();if(typeof s==="function")s.call(null,r)}else{var a=Date.now()-o,c=Math.max(o-i,1),u=Math.min(c*1.2,100);if(a>=u)VB("RETRY",t.name,n),t.apply(null,n.concat([i]));else Wf[ey].push(e)}if(EMe===void 0)EMe=setTimeout(svt,0)}});var yFn=gt(function(FHa,_Fn){function vk(e,t){if(typeof t==="boolean")t={forever:t};if(this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}_Fn.exports=vk;vk.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};vk.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};vk.prototype.retry=function(e){if(this._timeout)clearTimeout(this._timeout);if(!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,i=setTimeout(function(){if(r._attempts++,r._operationTimeoutCb){if(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref)r._timeout.unref()}r._fn(r._attempts)},n);if(this._options.unref)i.unref();return!0};vk.prototype.attempt=function(e,t){if(this._fn=e,t){if(t.timeout)this._operationTimeout=t.timeout;if(t.cb)this._operationTimeoutCb=t.cb}var n=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};vk.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};vk.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};vk.prototype.start=vk.prototype.try;vk.prototype.errors=function(){return this._errors};vk.prototype.attempts=function(){return this._attempts};vk.prototype.mainError=function(){if(this._errors.length===0)return null;var e={},t=null,n=0;for(var r=0;r<this._errors.length;r++){var i=this._errors[r],o=i.message,s=(e[o]||0)+1;if(e[o]=s,s>=n)t=i,n=s}return t}});var vFn=gt(function(uvt){var eRi=yFn();uvt.operation=function(e){var t=uvt.timeouts(e);return new eRi(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};uvt.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var r=[];for(var i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));if(e&&e.forever&&!r.length)r.push(this.createTimeout(i,t));return r.sort(function(o,s){return o-s}),r};uvt.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return r=Math.min(r,t.maxTimeout),r};uvt.wrap=function(e,t,n){if(t instanceof Array)n=t,t=null;if(!n){n=[];for(var r in e)if(typeof e[r]==="function")n.push(r)}for(var i=0;i<n.length;i++){var o=n[i],s=e[o];e[o]=function(c){var u=uvt.operation(t),l=Array.prototype.slice.call(arguments,1),d=l.pop();l.push(function(p){if(u.retry(p))return;if(p)arguments[0]=u.mainError();d.apply(this,arguments)}),u.attempt(function(){c.apply(e,l)})}.bind(e,s),e[o].options=t}}});var bFn=gt(function(zHa,TMe){TMe.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")TMe.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")TMe.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var SFn=gt(function(UHa,MY){var ff=global.process,JB=function(e){return e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function"};if(!JB(ff))MY.exports=function(){return function(){}};else{if(lvt=xi("assert"),QB=bFn(),dvt=/^win/i.test(ff.platform),PY=xi("events"),typeof PY!=="function")PY=PY.EventEmitter;if(ff.__signal_exit_emitter__)Ng=ff.__signal_exit_emitter__;else Ng=ff.__signal_exit_emitter__=new PY,Ng.count=0,Ng.emitted={};if(!Ng.infinite)Ng.setMaxListeners(1/0),Ng.infinite=!0;MY.exports=function(e,t){if(!JB(global.process))return function(){};if(lvt.equal(typeof e,"function","a callback must be provided for exit handler"),XB===!1)AMe();var n="exit";if(t&&t.alwaysLast)n="afterexit";var r=function(){if(Ng.removeListener(n,e),Ng.listeners("exit").length===0&&Ng.listeners("afterexit").length===0)Xme()};return Ng.on(n,e),r},Xme=function(){if(!XB||!JB(global.process))return;XB=!1,QB.forEach(function(t){try{ff.removeListener(t,Yme[t])}catch(n){}}),ff.emit=Zme,ff.reallyExit=IMe,Ng.count-=1},MY.exports.unload=Xme,B7=function(t,n,r){if(Ng.emitted[t])return;Ng.emitted[t]=!0,Ng.emit(t,n,r)},Yme={},QB.forEach(function(e){Yme[e]=function(){if(!JB(global.process))return;var n=ff.listeners(e);if(n.length===Ng.count){if(Xme(),B7("exit",null,e),B7("afterexit",null,e),dvt&&e==="SIGHUP")e="SIGINT";ff.kill(ff.pid,e)}}}),MY.exports.signals=function(){return QB},XB=!1,AMe=function(){if(XB||!JB(global.process))return;XB=!0,Ng.count+=1,QB=QB.filter(function(t){try{return ff.on(t,Yme[t]),!0}catch(n){return!1}}),ff.emit=fvt,ff.reallyExit=pvt},MY.exports.load=AMe,IMe=ff.reallyExit,pvt=function(t){if(!JB(global.process))return;ff.exitCode=t||0,B7("exit",ff.exitCode,null),B7("afterexit",ff.exitCode,null),IMe.call(ff,ff.exitCode)},Zme=ff.emit,fvt=function(t,n){if(t==="exit"&&JB(global.process)){if(n!==void 0)ff.exitCode=n;var r=Zme.apply(this,arguments);return B7("exit",ff.exitCode,null),B7("afterexit",ff.exitCode,null),r}else return Zme.apply(this,arguments)}}var lvt,QB,dvt,PY,Ng,Xme,B7,Yme,XB,AMe,IMe,pvt,Zme,fvt});var EFn=gt(function(sRi,mvt){var wFn=Symbol();function iRi(e,t,n){let r=t[wFn];if(r)return t.stat(e,(o,s)=>{if(o)return n(o);n(null,s.mtime,r)});let i=new Date(Math.ceil(Date.now()/1000)*1000+5);t.utimes(e,i,i,(o)=>{if(o)return n(o);t.stat(e,(s,a)=>{if(s)return n(s);let c=a.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty(t,wFn,{value:c}),n(null,a.mtime,c)})})}function oRi(e){let t=Date.now();if(e==="s")t=Math.ceil(t/1000)*1000;return new Date(t)}sRi.probe=iRi;sRi.getMtime=oRi});var RFn=gt(function(fRi,the){var kFn=xi("path"),_vt=cvt(),TFn=vFn(),uRi=SFn(),RMe=EFn(),qO={};function ehe(e,t){return t.lockfilePath||`${e}.lock`}function yvt(e,t,n){if(!t.realpath)return n(null,kFn.resolve(e));t.fs.realpath(e,n)}function gvt(e,t,n){let r=ehe(e,t);t.fs.mkdir(r,(i)=>{if(!i)return RMe.probe(r,t.fs,(o,s,a)=>{if(o)return t.fs.rmdir(r,()=>{}),n(o);n(null,s,a)});if(i.code!=="EEXIST")return n(i);if(t.stale<=0)return n(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:e}));t.fs.stat(r,(o,s)=>{if(o){if(o.code==="ENOENT")return gvt(e,{...t,stale:0},n);return n(o)}if(!AFn(s,t))return n(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:e}));IFn(e,t,(a)=>{if(a)return n(a);gvt(e,{...t,stale:0},n)})})})}function AFn(e,t){return e.mtime.getTime()<Date.now()-t.stale}function IFn(e,t,n){t.fs.rmdir(ehe(e,t),(r)=>{if(r&&r.code!=="ENOENT")return n(r);n()})}function CMe(e,t){let n=qO[e];if(n.updateTimeout)return;if(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let o=n.lastUpdate+t.stale<Date.now();if(r){if(r.code==="ENOENT"||o)return hvt(e,n,Object.assign(r,{code:"ECOMPROMISED"}));return n.updateDelay=1000,CMe(e,t)}if(n.mtime.getTime()!==i.mtime.getTime())return hvt(e,n,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let a=RMe.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,a,a,(c)=>{let u=n.lastUpdate+t.stale<Date.now();if(n.released)return;if(c){if(c.code==="ENOENT"||u)return hvt(e,n,Object.assign(c,{code:"ECOMPROMISED"}));return n.updateDelay=1000,CMe(e,t)}n.mtime=a,n.lastUpdate=Date.now(),n.updateDelay=null,CMe(e,t)})})},n.updateDelay),n.updateTimeout.unref)n.updateTimeout.unref()}function hvt(e,t,n){if(t.released=!0,t.updateTimeout)clearTimeout(t.updateTimeout);if(qO[e]===t)delete qO[e];t.options.onCompromised(n)}function lRi(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:_vt,onCompromised:(r)=>{throw r},...t},t.retries=t.retries||0,t.retries=typeof t.retries==="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2000),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1000),yvt(e,t,(r,i)=>{if(r)return n(r);let o=TFn.operation(t.retries);o.attempt(()=>{gvt(i,t,(s,a,c)=>{if(o.retry(s))return;if(s)return n(o.mainError());let u=qO[i]={lockfilePath:ehe(i,t),mtime:a,mtimePrecision:c,options:t,lastUpdate:Date.now()};CMe(i,t),n(null,(l)=>{if(u.released)return l&&l(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));CFn(i,{...t,realpath:!1},l)})})})})}function CFn(e,t,n){t={fs:_vt,realpath:!0,...t},yvt(e,t,(r,i)=>{if(r)return n(r);let o=qO[i];if(!o)return n(Object.assign(Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete qO[i],IFn(i,t,n)})}function dRi(e,t,n){t={stale:1e4,realpath:!0,fs:_vt,...t},t.stale=Math.max(t.stale||0,2000),yvt(e,t,(r,i)=>{if(r)return n(r);t.fs.stat(ehe(i,t),(o,s)=>{if(o)return o.code==="ENOENT"?n(null,!1):n(o);return n(null,!AFn(s,t))})})}function pRi(){return qO}uRi(()=>{for(let e in qO){let t=qO[e].options;try{t.fs.rmdirSync(ehe(e,t))}catch(n){}}});fRi.lock=lRi;fRi.unlock=CFn;fRi.check=dRi;fRi.getLocks=pRi});var OFn=gt(function(jHa,DFn){var yRi=cvt();function xRi(e){let t=["mkdir","realpath","stat","rmdir","utimes"],n={...e};return t.forEach((r)=>{n[r]=(...i)=>{let o=i.pop(),s;try{s=e[`${r}Sync`](...i)}catch(a){return o(a)}o(null,s)}}),n}function vRi(e){return(...t)=>new Promise((n,r)=>{t.push((i,o)=>{if(i)r(i);else n(o)}),e(...t)})}function bRi(e){return(...t)=>{let n,r;if(t.push((i,o)=>{n=i,r=o}),e(...t),n)throw n;return r}}function SRi(e){if(e={...e},e.fs=xRi(e.fs||yRi),typeof e.retries==="number"&&e.retries>0||e.retries&&typeof e.retries.retries==="number"&&e.retries.retries>0)throw Object.assign(Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}DFn.exports={toPromise:vRi,toSync:bRi,toSyncOptions:SRi}});var NY=gt(function(BHa,q7){var bk=RFn(),{toPromise:DMe,toSync:OMe,toSyncOptions:xvt}=OFn();async function PFn(e,t){let n=await DMe(bk.lock)(e,t);return DMe(n)}function wRi(e,t){let n=OMe(bk.lock)(e,xvt(t));return OMe(n)}function ERi(e,t){return DMe(bk.unlock)(e,t)}function kRi(e,t){return OMe(bk.unlock)(e,xvt(t))}function TRi(e,t){return DMe(bk.check)(e,t)}function ARi(e,t){return OMe(bk.check)(e,xvt(t))}q7.exports=PFn;q7.exports.lock=PFn;q7.exports.unlock=ERi;q7.exports.lockSync=wRi;q7.exports.unlockSync=kRi;q7.exports.check=TRi;q7.exports.checkSync=ARi});var NFn=gt(function(MFn){Object.defineProperty(MFn,"__esModule",{value:!0});MFn.signals=void 0;MFn.signals=[];MFn.signals.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")MFn.signals.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")MFn.signals.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});var UFn=gt(function(Evt){var PMe;Object.defineProperty(Evt,"__esModule",{value:!0});Evt.unload=Evt.load=Evt.onExit=Evt.signals=void 0;var W7=NFn();Object.defineProperty(Evt,"signals",{enumerable:!0,get:function(){return W7.signals}});var MMe=(e)=>!!e&&typeof e==="object"&&typeof e.removeListener==="function"&&typeof e.emit==="function"&&typeof e.reallyExit==="function"&&typeof e.listeners==="function"&&typeof e.kill==="function"&&typeof e.pid==="number"&&typeof e.on==="function",vvt=Symbol.for("signal-exit emitter"),bvt=globalThis,IRi=Object.defineProperty.bind(Object);class LFn{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(bvt[vvt])return bvt[vvt];IRi(bvt,vvt,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let n=this.listeners[e],r=n.indexOf(t);if(r===-1)return;if(r===0&&n.length===1)n.length=0;else n.splice(r,1)}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let i of this.listeners[e])r=i(t,n)===!0||r;if(e==="exit")r=this.emit("afterExit",t,n)||r;return r}}class wvt{}var CRi=(e)=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});class FFn extends wvt{onExit(){return()=>{}}load(){}unload(){}}class $Fn extends wvt{#e=Svt.platform==="win32"?"SIGINT":"SIGHUP";#t=new LFn;#n;#r;#i;#o={};#s=!1;constructor(e){super();this.#n=e,this.#o={};for(let t of W7.signals)this.#o[t]=()=>{let n=this.#n.listeners(t),{count:r}=this.#t,i=e;if(typeof i.__signal_exit_emitter__==="object"&&typeof i.__signal_exit_emitter__.count==="number")r+=i.__signal_exit_emitter__.count;if(n.length===r){this.unload();let o=this.#t.emit("exit",null,t),s=t==="SIGHUP"?this.#e:t;if(!o)e.kill(e.pid,s)}};this.#i=e.reallyExit,this.#r=e.emit}onExit(e,t){if(!MMe(this.#n))return()=>{};if(this.#s===!1)this.load();let n=t?.alwaysLast?"afterExit":"exit";return this.#t.on(n,e),()=>{if(this.#t.removeListener(n,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0)this.unload()}}load(){if(this.#s)return;this.#s=!0,this.#t.count+=1;for(let e of W7.signals)try{let t=this.#o[e];if(t)this.#n.on(e,t)}catch(t){}this.#n.emit=(e,...t)=>this.#u(e,...t),this.#n.reallyExit=(e)=>this.#c(e)}unload(){if(!this.#s)return;this.#s=!1,W7.signals.forEach((e)=>{let t=this.#o[e];if(!t)throw Error("Listener not defined for signal: "+e);try{this.#n.removeListener(e,t)}catch(n){}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#i,this.#t.count-=1}#c(e){if(!MMe(this.#n))return 0;return this.#n.exitCode=e||0,this.#t.emit("exit",this.#n.exitCode,null),this.#i.call(this.#n,this.#n.exitCode)}#u(e,...t){let n=this.#r;if(e==="exit"&&MMe(this.#n)){if(typeof t[0]==="number")this.#n.exitCode=t[0];let r=n.call(this.#n,e,...t);return this.#t.emit("exit",this.#n.exitCode,null),r}else return n.call(this.#n,e,...t)}}var Svt=globalThis.process;PMe=CRi(MMe(Svt)?new $Fn(Svt):new FFn),Evt.onExit=PMe.onExit,Evt.load=PMe.load,Evt.unload=PMe.unload});var BI=gt(function(GHa,rhe){var __filename="/node_modules/.pnpm/write-file-atomic@8.0.0/node_modules/write-file-atomic/lib/index.js";rhe.exports=LRi;rhe.exports.sync=FRi;rhe.exports._getTmpname=kvt;rhe.exports._cleanupOnExit=Tvt;var qs=xi("fs"),jFn=xi("crypto"),{onExit:BFn}=UFn(),qFn=xi("path"),{promisify:Sk}=xi("util"),H7={},ORi=function(){try{let t=xi("worker_threads");return t.threadId}catch(t){return 0}}(),PRi=0;function kvt(e){return e+"."+jFn.createHash("sha1").update(__filename).update(String(process.pid)).update(String(ORi)).update(String(++PRi)).digest().readUInt32BE(0)}function Tvt(e){return()=>{try{qs.unlinkSync(typeof e==="function"?e():e)}catch{}}}function MRi(e){return new Promise((t)=>{if(!H7[e])H7[e]=[];if(H7[e].push(t),H7[e].length===1)t()})}function NMe(e){if(e.code==="ENOSYS")return!0;if(!process.getuid||process.getuid()!==0){if(e.code==="EINVAL"||e.code==="EPERM")return!0}return!1}async function NRi(e,t,n={}){if(typeof n==="string")n={encoding:n};let r,i,o=BFn(Tvt(()=>i)),s=qFn.resolve(e);try{await MRi(s);let a=await Sk(qs.realpath)(e).catch(()=>e);if(i=kvt(a),!n.mode||!n.chown){let c=await Sk(qs.stat)(a).catch(()=>{});if(c){if(n.mode==null)n.mode=c.mode;if(n.chown==null&&process.getuid)n.chown={uid:c.uid,gid:c.gid}}}if(r=await Sk(qs.open)(i,"w",n.mode),n.tmpfileCreated)await n.tmpfileCreated(i);if(ArrayBuffer.isView(t))await Sk(qs.write)(r,t,0,t.length,0);else if(t!=null)await Sk(qs.write)(r,String(t),0,String(n.encoding||"utf8"));if(n.fsync!==!1)await Sk(qs.fsync)(r);if(await Sk(qs.close)(r),r=null,n.chown)await Sk(qs.chown)(i,n.chown.uid,n.chown.gid).catch((c)=>{if(!NMe(c))throw c});if(n.mode)await Sk(qs.chmod)(i,n.mode).catch((c)=>{if(!NMe(c))throw c});await Sk(qs.rename)(i,a)}finally{if(r)await Sk(qs.close)(r).catch(()=>{});if(o(),await Sk(qs.unlink)(i).catch(()=>{}),H7[s].shift(),H7[s].length>0)H7[s][0]();else delete H7[s]}}async function LRi(e,t,n,r){if(n instanceof Function)r=n,n={};let i=NRi(e,t,n);if(r)try{let o=await i;return r(o)}catch(o){return r(o)}return i}function FRi(e,t,n){if(typeof n==="string")n={encoding:n};else if(!n)n={};try{e=qs.realpathSync(e)}catch(c){}let r=kvt(e);if(!n.mode||!n.chown)try{let c=qs.statSync(e);if(n=Object.assign({},n),!n.mode)n.mode=c.mode;if(!n.chown&&process.getuid)n.chown={uid:c.uid,gid:c.gid}}catch(c){}let i,o=Tvt(r),s=BFn(o),a=!0;try{if(i=qs.openSync(r,"w",n.mode||438),n.tmpfileCreated)n.tmpfileCreated(r);if(ArrayBuffer.isView(t))qs.writeSync(i,t,0,t.length,0);else if(t!=null)qs.writeSync(i,String(t),0,String(n.encoding||"utf8"));if(n.fsync!==!1)qs.fsyncSync(i);if(qs.closeSync(i),i=null,n.chown)try{qs.chownSync(r,n.chown.uid,n.chown.gid)}catch(c){if(!NMe(c))throw c}if(n.mode)try{qs.chmodSync(r,n.mode)}catch(c){if(!NMe(c))throw c}qs.renameSync(r,e),a=!1}finally{if(i)try{qs.closeSync(i)}catch(c){}if(s(),a)o()}}});import{createHash as JFn}from"crypto";import{chmod as $Ri,mkdir as zRi,open as WFn}from"fs/promises";import{dirname as URi,isAbsolute as QFn,resolve as jRi}from"path";function HO(e){if(!QFn(e))throw Error("Default credential home must be absolute");return jRi(e,".config","fungi","credentials.json")}function WO(e){return Error(e)}function Cvt(e){return e.type==="machine_enrollment"||e.type==="local_backends"}function ihe(e,t){if(e===void 0||!Object.hasOwn(e,t))return;let n=e[t];return n===void 0||Cvt(n)?void 0:n}function XRi(e){let t;try{t=JSON.parse(e)}catch{throw WO("Credential store contains malformed JSON")}let n=ZFn.safeParse(t);if(!n.success)throw WO("Credential store contains invalid credential data");return n.data}class e$n{#e;#t;constructor(e,t=YFn.default){if(!QFn(e))throw Error("Private credential path must be absolute");this.#e=e,this.#t=t}async getDeviceId(){return this.#o(async()=>{let e=`${this.#e}.device-id`,t;try{t=await WFn(e,"r")}catch(n){if(!VFn.safeParse(n).success)throw n;let r=rA();return await this.#t(e,r,{encoding:"utf8",fsync:!0,mode:KFn}),r}try{let n=Buffer.alloc(37),{bytesRead:r}=await t.read(n,0,n.length,0),i=O$().safeParse(n.subarray(0,r).toString("utf8"));if(!i.success)throw WO("Local model device ID is invalid");return i.data}finally{await t.close()}})}async read(e,t){return t?.signal?.throwIfAborted(),ihe(await this.#r(),e)}async list(e){e?.signal?.throwIfAborted();let t=await this.#r();if(t===void 0)return[];return Object.entries(t).flatMap(([n,r])=>Cvt(r)?[]:[{providerId:n,type:r.type}])}async modify(e,t,n){return n?.signal?.throwIfAborted(),await this.#o(async()=>{n?.signal?.throwIfAborted();let r=await this.#r()??{},i=r[e];if(i!==void 0&&Cvt(i))throw WO("A model credential cannot replace a private Local record");let o=ihe(r,e),s=await t(o);if(n?.signal?.throwIfAborted(),s===void 0)return o;let a=this.#n({...r,[e]:s});await this.#i(a);let c=ihe(a,e);if(c===void 0)throw WO("Credential store failed to retain its update");return c})}async delete(e,t){await this.remove(e,()=>Promise.resolve(),t)}async readMachineEnrollments(){return Object.values(await this.#r()??{}).filter((e)=>e.type==="machine_enrollment")}async modifyMachineEnrollments(e,t,n){await this.#o(async()=>{let r=await this.#r()??{};n?.admit(ihe(r,n.providerId));let i=Avt(e),o=r[i];if(o!==void 0&&o.type!=="machine_enrollment")throw WO("Machine enrollment record is occupied");let s=t(o?.enrollments??[]),a=Object.fromEntries(Object.entries(r).filter(([c])=>c!==i));await this.#i(this.#n(s.length===0?a:{...a,[i]:nvt.parse({type:"machine_enrollment",origin:e,enrollments:s})}))})}async readLocalBackends(e){let t=(await this.#r())?.[Ivt(e)];return t?.type==="local_backends"?t.backends:[]}async readAllLocalBackends(){return Object.values(await this.#r()??{}).filter((e)=>e.type==="local_backends")}async modifyLocalBackends(e,t){await this.#o(async()=>{let n=await this.#r()??{},r=Ivt(e),i=n[r];if(i!==void 0&&i.type!=="local_backends")throw WO("Local backend record is occupied");let o=t(i?.backends??[]),s=Object.fromEntries(Object.entries(n).filter(([a])=>a!==r));await this.#i(this.#n(o.length===0?s:{...s,[r]:Zxt.parse({type:"local_backends",origin:e,backends:o})}))})}async removeMachineEnrollments(e){return this.#o(async()=>{let t=await this.#r(),n=Avt(e);if(t?.[n]?.type!=="machine_enrollment")return!1;let r=Object.fromEntries(Object.entries(t).filter(([i])=>i!==n));return await this.#i(this.#n(r)),!0})}async remove(e,t,n){return n?.signal?.throwIfAborted(),this.#o(async()=>{n?.signal?.throwIfAborted();let r=await this.#r(),i=ihe(r,e);if(r===void 0||i===void 0)return;let o=await t(i),s=Object.fromEntries(Object.entries(r).filter(([a])=>a!==e));return n?.signal?.throwIfAborted(),await this.#i(this.#n(s)),o})}#n(e){let t=ZFn.safeParse(e);if(!t.success)throw WO("Credential update contains invalid credential data");return t.data}async#r(){let e;try{e=await WFn(this.#e,"r")}catch(t){if(VFn.safeParse(t).success)return;throw t}try{let t=Buffer.alloc(HFn+1),n=0;while(n<t.length){let{bytesRead:r}=await e.read(t,n,t.length-n,n);if(r===0)break;n+=r}if(n>HFn)throw WO("Credential store exceeds its private file bound");return XRi(t.subarray(0,n).toString("utf8"))}finally{await e.close()}}async#i(e){await this.#t(this.#e,JSON.stringify(e),{encoding:"utf8",fsync:!0,mode:KFn})}async#o(e){let t=URi(this.#e);await zRi(t,{recursive:!0,mode:GFn}),await $Ri(t,GFn);let n=await XFn.default.lock(this.#e,HRi);try{return await e()}finally{await n()}}}function I4(e){return new e$n(e)}var XFn,YFn,HFn=262144,BRi=128,Rvt=256,YB=65536,qRi=64,WRi=64,GFn=448,KFn=384,HRi,GRi,LMe,KRi,VRi,JRi,QRi,Avt=(e)=>`machine-enrollment:${JFn("sha256").update(e).digest("hex")}`,Ivt=(e)=>`local-backends:${JFn("sha256").update(e).digest("hex")}`,ZFn,VFn;var G7=A(()=>{Nd();evt();rvt();Wn();XFn=rl(NY(),1),YFn=rl(BI(),1),HRi={realpath:!1,stale:30000,update:1e4,retries:{retries:20,factor:1.2,minTimeout:25,maxTimeout:100}},GRi=D().min(1).max(Rvt),LMe=D().max(YB),KRi=We(D().min(1).max(Rvt),LMe).superRefine((e,t)=>{if(Object.keys(e).length>qRi)t.addIssue({code:"custom",message:"Credential environment contains too many entries"})}),VRi=Xe({type:we("api_key"),key:LMe.optional(),env:KRi.optional()}).transform((e)=>{let t={type:"api_key"};if(e.key!==void 0)t.key=e.key;if(e.env!==void 0)t.env=e.env;return t}),JRi=se({type:we("oauth"),refresh:LMe,access:LMe,expires:tt()}).catchall(_s()).superRefine((e,t)=>{if(Object.keys(e).length>WRi+4)t.addIssue({code:"custom",message:"OAuth credential contains too many entries"});for(let n of Object.keys(e))if(n.length>Rvt)t.addIssue({code:"custom",message:"OAuth credential contains an oversized key"})}),QRi=us("type",[VRi,JRi,nvt,Zxt]),ZFn=We(GRi,QRi).superRefine((e,t)=>{for(let[n,r]of Object.entries(e))if(r.type==="machine_enrollment"&&n!==Avt(r.origin))t.addIssue({code:"custom",message:"Machine enrollment origin does not match its record"});for(let[n,r]of Object.entries(e))if(r.type==="local_backends"&&n!==Ivt(r.origin))t.addIssue({code:"custom",message:"Local backend origin does not match its record"});if(Object.keys(e).length>BRi)t.addIssue({code:"custom",message:"Credential store contains too many providers"})}),VFn=se({code:we("ENOENT")})});var Yx,t$n,Dvt,n$n,YRi,ZRi,e6i,r$n,tGa,i$n,Ovt,FMe=512,LY,t6i=4,n6i=5242880,Pvt,GO,Mvt,o$n,s$n,$Me,Nvt;var Lvt=A(()=>{cr();Yx=Ce.check(Yn(1),Wt(256)),t$n=kn.check(_r(1),ol(Number.MAX_SAFE_INTEGER)),Dvt=kn.check(_r(0),ol(Number.MAX_SAFE_INTEGER)),n$n=Yt(["write","external"]),YRi=oe({module:Dn(Yx),access:n$n}),ZRi=oe({agentId:Dn(Yx)}),e6i=oe({principalId:Yx,agentId:Dn(Yx),sessionId:Dn(Yx),displayName:Yx}),r$n=oe({title:Ce.check(Yn(1),Wt(512)),inputBytes:kn.check(_r(0)),inputSha256:Ce.check(Jc(/^[a-f0-9]{64}$/))}),tGa=oe({kind:Je("pending_approval"),recordId:Yx,description:r$n}),i$n=Yt(["requested","pending","approved","claimed","applied","denied","expired","outcome_unknown"]),Ovt=Yt(["not-found","not-eligible","already-answered","stale-revision","expired","declined","fenced","not-granted","read-only","pending","in-flight","outcome-unknown","identity-conflict"]),LY=Ce.check(Yn(1),Wt(FMe),Jc(/^(?=.*\S)[^\p{Cc}\u2028\u2029]*$/u)),Pvt=bn(oe({kind:Je("artifact"),ref:Ce.check(Jc(/^sha256:[a-f0-9]{64}$/)),mediaType:Je("image/png"),bytes:kn.check(_r(1),ol(n6i))})).check(Wt(t6i)),GO=oe({recordId:Yx,requester:e6i,module:Yx,operation:Yx,access:n$n,description:r$n,evidence:wt(Pvt),authorityFence:Yx,reversibility:Yt(["reversible","irreversible-external"]),state:i$n,by:Dn(Nn([oe({kind:Je("human"),memberId:Yx}),oe({kind:Je("policy")})])),reason:Dn(Ovt),denialNote:wt(LY),requestedAt:Dvt,expiresAt:Dvt,updatedAt:Dvt,revision:t$n}),Mvt=oe({record:GO,canAnswer:ai,canSetAutoApprove:ai}),o$n=oe({state:wt(i$n),cursor:wt(Yx),limit:wt(kn.check(_r(1),ol(100)))}),s$n=oe({recordId:Yx}),$Me=oe({recordId:Yx,decision:Yt(["approve","deny"]),expectedRevision:t$n,denialNote:wt(LY)}),Nvt=oe({scope:ZRi,family:YRi,enabled:ai})});function Fvt(e,t){return e.state==="denied"&&e.by?.kind==="human"&&e.denialNote!==void 0?`Denied by ${JSON.stringify(t)}: ${JSON.stringify(e.denialNote)}`:null}function a$n(){return"approval-result:"+[...crypto.getRandomValues(new Uint8Array(32))].map((t)=>t.toString(16).padStart(2,"0")).join("")}async function u$n(e){let t=await crypto.subtle.digest("SHA-256",e);return[...new Uint8Array(t)].map((n)=>n.toString(16).padStart(2,"0")).join("")}class zMe{options;homeKey;constructor(e){this.options=e,this.homeKey=JSON.stringify([e.home.kind,e.home.id]),e.owner.sql.exec("CREATE TABLE IF NOT EXISTS approval_rules (home_key TEXT NOT NULL, rule_key TEXT NOT NULL, agent_id TEXT, module_id TEXT, access_class TEXT NOT NULL, enabled INTEGER NOT NULL, set_by TEXT NOT NULL, set_at INTEGER NOT NULL, PRIMARY KEY (home_key, rule_key))"),e.owner.sql.exec("CREATE TABLE IF NOT EXISTS approval_records (home_key TEXT NOT NULL, record_id TEXT NOT NULL, record_json TEXT NOT NULL, PRIMARY KEY (home_key, record_id))"),e.owner.sql.exec("CREATE INDEX IF NOT EXISTS approval_records_by_state ON approval_records (home_key, json_extract(record_json, '$.state'), record_id)"),e.owner.sql.exec("CREATE TABLE IF NOT EXISTS approval_payloads (home_key TEXT NOT NULL, record_id TEXT NOT NULL, input_json TEXT NOT NULL, output_json TEXT, PRIMARY KEY (home_key, record_id))"),e.owner.sql.exec("CREATE TABLE IF NOT EXISTS approval_handoffs (home_key TEXT NOT NULL, record_id TEXT NOT NULL, delivery_id TEXT NOT NULL, command_id TEXT, attempts INTEGER NOT NULL DEFAULT 0, next_attempt_at INTEGER, undeliverable_at INTEGER, PRIMARY KEY (home_key, record_id))"),e.owner.sql.exec("CREATE INDEX IF NOT EXISTS approval_handoffs_by_receipt ON approval_handoffs (home_key, command_id, record_id)")}capability(e){let t=(o)=>{if(o?.kind!=="human")throw Error("Approval read requires a current member")},n=async(o)=>{let{recordId:s}=tn(s$n,{onExcessProperty:"error"})(o),a=this.get(s),c=await e.actor(a);return t(c),a===null?null:i(a,c)},r=async(o)=>{if(this.options.home.kind==="team")return e.setter===void 0?null:e.setter(o);return e.actor(null)},i=async(o,s)=>{let a={scope:{agentId:o.requester.agentId},family:{module:o.module,access:o.access},enabled:!0};return{record:o,canAnswer:o.state==="pending"&&this.eligible(s),canSetAutoApprove:this.canManagePolicy(a,await r(a))}};return{get:n,list:async(o)=>{let s=tn(o$n,{onExcessProperty:"error"})(o);t(await e.actor(null));let a=s.limit??100,c=this.options.owner.sql.exec("SELECT record_json FROM approval_records WHERE home_key = ? AND record_id > ? AND (? IS NULL OR CASE WHEN json_extract(record_json, '$.state') = 'pending' AND json_extract(record_json, '$.expiresAt') <= ? THEN 'expired' ELSE json_extract(record_json, '$.state') END = ?) ORDER BY record_id LIMIT ?",this.homeKey,s.cursor??"",s.state??null,this.options.now(),s.state??null,a+1).toArray().map((f)=>$vt(zvt(f).record_json)),u=c.slice(0,a),l=u.flatMap((f)=>{let m=this.get(f.recordId);return m===null||s.state!==void 0&&m.state!==s.state?[]:[m]}),d=await Promise.all(l.map(async(f)=>{let m=await e.actor(f);return t(m),i(f,m)})),p=u.at(-1);return{items:d,nextCursor:c.length>a&&p!==void 0?p.recordId:null}},answer:async(o)=>{let s=tn($Me,{onExcessProperty:"error"})(o),a=this.answer(s,await e.actor(this.get(s.recordId)));if(a.kind==="refused")return a;await e.decision(a.record.recordId);let c=await n({recordId:a.record.recordId});if(c===null)throw Error("Answered approval disappeared");return{kind:"answered",view:c}},setAutoApprove:async(o)=>{let s=tn(Nvt,{onExcessProperty:"error"})(o);return this.setAutoApprove(s,await r(s))}}}eligible(e){return e?.kind==="human"&&!e.actingForAgent&&e.mayUseOperation&&(this.options.home.kind!=="oyster"||e.role==="owner")}async submit(e,t){let n=await this.request(e,t.evidence);if(n.kind==="refused")return n;let{record:r}=n;if(n.created&&r.state==="approved")return this.applyInline(r.recordId,t);return this.outcome(r)}outcome(e){switch(e.state){case"requested":case"pending":case"approved":case"claimed":return{kind:"pending_approval",recordId:e.recordId,description:e.description};case"applied":{if(e.by?.kind!=="policy")return{kind:"refused",reason:"already-answered"};let t=this.payload(e.recordId).output_json;if(t===null)throw Error("Applied approval has no recorded output");return{kind:"applied",record:e,output:FY(t)}}case"denied":return this.deniedResult(e);case"expired":return{kind:"refused",reason:"expired"};case"outcome_unknown":return{kind:"refused",reason:"outcome-unknown"}}}async request(e,t){let n=structuredClone(e);if(n.requireHumanApproval&&n.prefixPolicyApproved)throw Error("A human-required request cannot be policy-approved");let r=t===void 0?{}:{evidence:tn(Pvt,{onExcessProperty:"error"})(structuredClone(t))};FY(n.inputJson);let i=new TextEncoder().encode(n.inputJson),[o,s]=await Promise.all([u$n(new TextEncoder().encode(JSON.stringify([this.homeKey,n.requester.principalId,n.requester.sessionId,n.module,n.operation,n.idempotencyKey]))),u$n(i)]);return this.options.owner.transactionSync(()=>{let a=this.get(o);if(a!==null){if(a.description.inputSha256!==s||a.authorityFence!==n.authorityFence||n.requireHumanApproval&&a.by?.kind==="policy"||JSON.stringify(a.evidence??[])!==JSON.stringify(r.evidence??[]))return{kind:"refused",reason:"identity-conflict"};return{kind:"record",record:a,created:!1}}let c=this.options.now(),u=n.prefixPolicyApproved===!0||!n.requireHumanApproval&&this.selectAutoApprove({agentId:n.requester.agentId,module:n.module,access:n.access}),l=tn(GO,{onExcessProperty:"error"})({recordId:o,requester:n.requester,module:n.module,operation:n.operation,access:n.access,description:{title:(n.module+"."+n.operation).slice(0,512),inputBytes:i.length,inputSha256:s},...r,authorityFence:n.authorityFence,reversibility:n.reversibility,state:u?"approved":"pending",by:u?{kind:"policy"}:null,reason:null,requestedAt:c,expiresAt:c+l$n,updatedAt:c,revision:1});if(this.options.persistIntent?.(l),this.options.owner.sql.exec("INSERT INTO approval_records (home_key, record_id, record_json) VALUES (?, ?, ?)",this.homeKey,o,c$n(l)),this.options.owner.sql.exec("INSERT INTO approval_payloads (home_key, record_id, input_json) VALUES (?, ?, ?)",this.homeKey,o,n.inputJson),!u&&l.requester.agentId!==null&&l.requester.sessionId!==null)this.options.owner.sql.exec("INSERT INTO approval_handoffs (home_key, record_id, delivery_id) VALUES (?, ?, ?)",this.homeKey,o,a$n());return{kind:"record",record:l,created:!0}})}answer(e,t){if(!this.eligible(t))return{kind:"refused",reason:"not-eligible"};if(e.decision!=="deny"&&e.denialNote!==void 0)return{kind:"refused",reason:"not-eligible"};return this.options.owner.transactionSync(()=>{let n=this.get(e.recordId);if(n===null)return{kind:"refused",reason:"not-found"};if(n.state==="expired")return{kind:"refused",reason:"expired"};if(n.state!=="pending")return{kind:"refused",reason:"already-answered"};if(n.revision!==e.expectedRevision)return{kind:"refused",reason:"stale-revision"};let r={...n,state:e.decision==="approve"?"approved":"denied",reason:e.decision==="approve"?null:"declined",by:{kind:"human",memberId:t.memberId},revision:n.revision+1,updatedAt:this.options.now()},i=e.decision==="deny"&&e.denialNote!==void 0?{...r,denialNote:e.denialNote}:r;return this.save(i),{kind:"answered",record:i}})}setAutoApprove(e,t){let n=tn(Nvt,{onExcessProperty:"error"})(e);if(!this.canManagePolicy(n,t)||t?.kind!=="human")return{kind:"refused",reason:"not-eligible"};return this.options.owner.sql.exec("INSERT INTO approval_rules (home_key, rule_key, agent_id, module_id, access_class, enabled, set_by, set_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT (home_key, rule_key) DO UPDATE SET enabled = excluded.enabled, set_by = excluded.set_by, set_at = excluded.set_at",this.homeKey,JSON.stringify([n.scope.agentId,n.family.module,n.family.access]),n.scope.agentId,n.family.module,n.family.access,n.enabled?1:0,t.memberId,this.options.now()),{kind:"updated",rule:n}}canManagePolicy(e,t){if(t?.kind!=="human"||t.actingForAgent)return!1;if(this.options.home.kind!=="team")return t.role==="owner";return e.scope.agentId!==null&&e.family.module!==null?t.mayUseOperation&&"mayManageAgent"in t&&t.mayManageAgent:t.role==="owner"}selectAutoApprove(e){let t=this.options.owner.sql.exec("SELECT enabled FROM approval_rules WHERE home_key = ? AND access_class = ? AND (agent_id IS NULL OR agent_id = ?) AND (module_id IS NULL OR module_id = ?) ORDER BY (agent_id IS NOT NULL) DESC, (module_id IS NOT NULL) DESC LIMIT 1",this.homeKey,e.access,e.agentId,e.module).toArray()[0];if(t===void 0)return r6i[this.options.home.kind];return tn(oe({enabled:Yt([0,1])}))(t).enabled===1}expirePending(){let e=tn(oe({record_id:GO.fields.recordId})),t=this.options.owner.sql.exec("SELECT record_id FROM approval_records WHERE home_key = ? AND json_extract(record_json, '$.state') = 'pending' AND json_extract(record_json, '$.expiresAt') <= ? ORDER BY record_id LIMIT 100",this.homeKey,this.options.now()).toArray();for(let n of t)this.get(e(n).record_id)}nextWakeAt(){let e=this.options.owner.sql.exec("SELECT MIN(CASE WHEN json_extract(record_json, '$.state') = 'pending' THEN json_extract(record_json, '$.expiresAt') ELSE ? END) AS wake_at FROM approval_records WHERE home_key = ? AND json_extract(record_json, '$.state') IN ('pending', 'approved', 'claimed')",this.options.now()+250,this.homeKey).toArray()[0],t=tn(oe({wake_at:Dn(GO.fields.expiresAt)})),n=t(e).wake_at;if(this.options.resultDelivery===void 0)return n;let r=this.options.now(),i=t(this.options.owner.sql.exec("SELECT MIN(COALESCE(h.next_attempt_at, ?)) AS wake_at FROM approval_handoffs h JOIN approval_records r ON r.home_key = h.home_key AND r.record_id = h.record_id WHERE h.home_key = ? AND h.command_id IS NULL AND h.undeliverable_at IS NULL AND (json_extract(r.record_json, '$.state') IN ('applied', 'denied', 'expired', 'outcome_unknown') OR (json_extract(r.record_json, '$.state') = 'pending' AND json_extract(r.record_json, '$.expiresAt') <= ?))",r,this.homeKey,r).toArray()[0]).wake_at;return n===null?i:i===null?n:Math.min(n,i)}pendingApplications(){let e=tn(oe({record_id:GO.fields.recordId}));return this.options.owner.sql.exec("SELECT record_id FROM approval_records WHERE home_key = ? AND json_extract(record_json, '$.state') = 'approved' ORDER BY record_id LIMIT 100",this.homeKey).toArray().map((t)=>e(t).record_id)}readInput(e){if(this.get(e)===null)return null;return FY(this.payload(e).input_json)}pendingHandoffs(){let e=tn(oe({record_id:GO.fields.recordId}));return this.options.owner.sql.exec("SELECT h.record_id FROM approval_handoffs h JOIN approval_records r ON r.home_key = h.home_key AND r.record_id = h.record_id WHERE h.home_key = ? AND h.command_id IS NULL AND h.undeliverable_at IS NULL AND (h.next_attempt_at IS NULL OR h.next_attempt_at <= ?) AND (json_extract(r.record_json, '$.state') IN ('applied', 'denied', 'expired', 'outcome_unknown') OR (json_extract(r.record_json, '$.state') = 'pending' AND json_extract(r.record_json, '$.expiresAt') <= ?)) ORDER BY h.record_id LIMIT 100",this.homeKey,this.options.now(),this.options.now()).toArray().map((t)=>e(t).record_id)}async handoff(e,t){let n=this.get(e);if(n===null)return{kind:"refused",reason:"not-found"};let r=()=>{let a=this.options.owner.sql.exec("SELECT command_id, delivery_id, attempts, undeliverable_at FROM approval_handoffs WHERE home_key = ? AND record_id = ?",this.homeKey,e).toArray()[0];return a===void 0?null:tn(oe({command_id:Dn(Ce),delivery_id:Ce,attempts:kn,undeliverable_at:Dn(kn)}))(a)},i=r();if(i===null)return{kind:"not-required"};if(i.command_id!==null)return{kind:"delivered",commandId:i.command_id};if(i.undeliverable_at!==null)return{kind:"undeliverable"};let o;switch(n.state){case"applied":{let a=this.payload(e).output_json;if(a===null)throw Error("Applied approval has no recorded output");o={kind:"applied",record:n,output:FY(a)};break}case"denied":o=this.deniedResult(n);break;case"expired":o={kind:"refused",reason:"expired"};break;case"outcome_unknown":o={kind:"refused",reason:"outcome-unknown"};break;case"claimed":return{kind:"refused",reason:"in-flight"};case"requested":case"pending":case"approved":return{kind:"refused",reason:"pending"}}let s;try{s=await t({deliveryId:i.delivery_id,record:n,result:o})}catch(a){let c=this.options.resultDelivery;if(c!==void 0){let u=i.attempts+1;if(u>=c.attemptLimit)return this.options.owner.sql.exec("UPDATE approval_handoffs SET attempts = ?, next_attempt_at = NULL, undeliverable_at = ? WHERE home_key = ? AND record_id = ? AND command_id IS NULL",u,this.options.now(),this.homeKey,e),{kind:"undeliverable"};this.options.owner.sql.exec("UPDATE approval_handoffs SET attempts = ?, next_attempt_at = ? WHERE home_key = ? AND record_id = ? AND command_id IS NULL",u,this.options.now()+c.retryDelay(u),this.homeKey,e)}throw a}return this.options.owner.transactionSync(()=>{let a=r();if(a===null)throw Error("Approval result delivery intent is missing");if(a.command_id!==null&&a.command_id!==s.commandId)throw Error("Approval result delivery identity conflicted");return this.options.owner.sql.exec("UPDATE approval_handoffs SET command_id = ? WHERE home_key = ? AND record_id = ? AND command_id IS NULL",s.commandId,this.homeKey,e),{kind:"delivered",commandId:s.commandId}})}apply(e,t){return this.run(e,t,!0)}applyInline(e,t){return this.run(e,t,!1)}async run(e,t,n){let r=this.options.owner.transactionSync(()=>{let i=this.get(e);if(i===null)return{kind:"refused",reason:"not-found"};if(i.state==="applied"){let a=this.payload(e).output_json;if(a===null)throw Error("Applied approval has no recorded output");return{kind:"applied",record:i,output:FY(a)}}if(i.state==="expired")return{kind:"refused",reason:"expired"};if(i.state==="denied")return this.deniedResult(i);if(i.state==="claimed")return{kind:"refused",reason:"in-flight"};if(i.state==="outcome_unknown")return{kind:"refused",reason:"outcome-unknown"};if(i.state!=="approved")return{kind:"refused",reason:"pending"};let o=FY(this.payload(e).input_json),s={...i,state:"claimed",updatedAt:this.options.now(),revision:i.revision+1};if(this.save(s),n&&s.requester.agentId!==null&&s.requester.sessionId!==null)this.options.owner.sql.exec("INSERT OR IGNORE INTO approval_handoffs (home_key, record_id, delivery_id) VALUES (?, ?, ?)",this.homeKey,e,a$n());return{kind:"claimed",record:s,input:o}});if(r.kind!=="claimed")return r;try{let i=await t.recheck(r.record),o=i.kind==="refused"?i.reason:i.authorityFence!==r.record.authorityFence?"fenced":null;if(o!==null)return this.finishDenied(r.record,o);let s=await t.dispatch({record:r.record,input:r.input});if(s.kind==="refused")return this.finishDenied(r.record,s.reason);let a=s.output,c=i6i(a);return this.options.owner.transactionSync(()=>{let u=this.get(e);if(u?.state!=="claimed"||u.revision!==r.record.revision)return{kind:"refused",reason:"outcome-unknown"};this.options.owner.sql.exec("UPDATE approval_payloads SET output_json = ? WHERE home_key = ? AND record_id = ?",c,this.homeKey,e);let l={...u,state:"applied",updatedAt:this.options.now(),revision:u.revision+1};return this.save(l),{kind:"applied",record:l,output:a}})}catch{return this.options.owner.transactionSync(()=>{let i=this.get(e);if(i?.state==="claimed"&&i.revision===r.record.revision)this.save({...i,state:"outcome_unknown",reason:"outcome-unknown",updatedAt:this.options.now(),revision:i.revision+1});return{kind:"refused",reason:"outcome-unknown"}})}}finishDenied(e,t){return this.options.owner.transactionSync(()=>{let n=this.get(e.recordId);if(n?.state!=="claimed"||n.revision!==e.revision)return{kind:"refused",reason:"outcome-unknown"};return this.save({...n,state:"denied",reason:t,updatedAt:this.options.now(),revision:n.revision+1}),{kind:"refused",reason:t}})}recoverClaims(){return this.options.owner.transactionSync(()=>this.options.owner.sql.exec("SELECT record_json FROM approval_records WHERE home_key = ? AND json_extract(record_json, '$.state') = 'claimed' ORDER BY record_id LIMIT 100",this.homeKey).toArray().map((t)=>{let n=$vt(zvt(t).record_json),r={...n,state:"outcome_unknown",reason:"outcome-unknown",updatedAt:this.options.now(),revision:n.revision+1};return this.save(r),r}))}deniedResult(e){let t={kind:"refused",reason:e.reason??"declined"};return e.denialNote===void 0?t:{...t,denialNote:e.denialNote}}payload(e){let t=this.options.owner.sql.exec("SELECT input_json, output_json FROM approval_payloads WHERE home_key = ? AND record_id = ?",this.homeKey,e).toArray()[0];if(t===void 0)throw Error("Approval has no persisted operation payload");return o6i(t)}save(e){this.options.owner.sql.exec("UPDATE approval_records SET record_json = ? WHERE home_key = ? AND record_id = ?",c$n(e),this.homeKey,e.recordId)}get(e){return this.options.owner.transactionSync(()=>{let t=this.options.owner.sql.exec("SELECT record_json FROM approval_records WHERE home_key = ? AND record_id = ?",this.homeKey,e).toArray()[0];if(t===void 0)return null;let n=$vt(zvt(t).record_json),r=this.options.now();if(n.state!=="pending"||r<n.expiresAt)return n;let i={...n,state:"expired",reason:"expired",updatedAt:r,revision:n.revision+1};return this.save(i),i})}}var Uvt,r6i,l$n=86400000,$vt,c$n,zvt,FY,i6i,o6i;var d$n=A(()=>{cr();Lvt();Uvt=oe({kind:Je("refused"),reason:Ovt,denialNote:wt(LY)}),r6i={team:!1,oyster:!0,local:!0};$vt=tn(Hi(GO),{onExcessProperty:"error"}),c$n=up(Hi(GO)),zvt=tn(oe({record_json:Ce})),FY=tn(Hi(Km)),i6i=up(Hi(Km)),o6i=tn(oe({input_json:Ce,output_json:Dn(Ce)}))});var UMe=A(()=>{d$n();Lvt()});var jvt,s6i,a6i,qI;var jMe=A(()=>{Yd();cr();UMe();jvt=oe({message:Ce,requestedSchema:oe({type:Je("object"),properties:oe({approve:oe({type:Je("boolean"),title:wt(Ce)})}),required:f_([Je("approve")])})}),s6i=Nn([oe({kind:Je("answered"),view:Mvt}),Uvt,oe({kind:Je("submitted")}),oe({kind:Je("refused"),reason:Yt(["not-attached","not-pending"])})]),a6i=oe({id:Ce,approval:Mvt,review:wt(oe({command:Ce,cwd:Ce,justification:Ce,form:Yt(["direct","shell"]),kind:Yt(["exec","extension-install"]),argv:wt(bn(Ce)),prefix:wt(bn(Ce)),alwaysAllowCoverage:wt(Ce),alwaysAllowUnavailableReason:wt(Ce),risk:wt(oe({summary:Ce,detail:Ce}))}))}),qI={id:Zu.make("botanical-local-mcp-form"),commands:{answer:{scope:"session",input:oe({id:Ce,decision:Yt(["approve","deny","always-allow"]),expectedRevision:$Me.fields.expectedRevision,denialNote:wt(LY)}),output:s6i}},projection:{schema:oe({pending:bn(a6i)})}}});function BMe(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function p$n(e){let t=BMe(e.title),n=BMe(e.heading),r=BMe(e.message),i=e.details?BMe(e.details):void 0;return`<!doctype html>
|
|
1342
1342
|
<html lang="en">
|
|
1343
1343
|
<head>
|
|
@@ -2100,7 +2100,7 @@ $ bun add react-devtools-core@7 -d
|
|
|
2100
2100
|
`);else throw e}SW.injectIntoDevTools();agr=SW,Nko=agr.flushSyncFromReconciler??agr.flushSync,{createPortal:Lko}=SW});import{engine as Ybc,Timeline as Zbc}from"@opentui/core";import{createSlotRegistry as nSc}from"@opentui/core";import{TimeToFirstDrawRenderable as Uko}from"@opentui/core";function gDt(e){let t=Pr(e);return Og(()=>{t.current=e}),el((...n)=>{let r=t.current;return r(...n)},[])}function $ko(e,t,n,r,i){if(!t)return null;try{return t(n)}catch(o){return e.reportPluginError({pluginId:r,slot:i,phase:"error_placeholder",source:"react",error:o}),null}}var tE=()=>{let{renderer:e}=I$e();if(!e)throw Error("Renderer not found.");return e},ste=(e,t={release:!1})=>{let{keyHandler:n}=I$e(),r=gDt(e);Qn(()=>{if(n?.on("keypress",r),t?.release)n?.on("keyrelease",r);return()=>{if(n?.off("keypress",r),t?.release)n?.off("keyrelease",r)}},[n,t.release])},ggr=(e)=>{let{keyHandler:t}=I$e(),n=gDt(e);Qn(()=>(t?.on("paste",n),()=>{t?.off("paste",n)}),[t])},Fko=(e)=>{let t=tE(),n=gDt(e);return Qn(()=>(t.on("resize",n),()=>{t.off("resize",n)}),[t]),t},Kf=()=>{let e=tE(),[t,n]=ii({width:e.width,height:e.height});return Fko((i,o)=>{n({width:i,height:o})}),t},zko;var qg=A(async()=>{d$e();Xi();Xi();Xi();Xi();Xi();Xi();Xi();Xi();Xi();Xi();Xi();Xi();await hgr();zko=class zko extends zgt{constructor(e){super(e);this.state={failure:null}}componentDidCatch(e){let t=this.props.registry.reportPluginError({pluginId:this.props.pluginId,slot:this.props.slotName,phase:"render",source:"react",error:e});this.setState({failure:t})}componentDidUpdate(e){if(e.resetToken!==this.props.resetToken&&this.state.failure)this.setState({failure:null})}render(){if(this.state.failure){let e=$ko(this.props.registry,this.props.pluginFailurePlaceholder,this.state.failure,this.props.pluginId,this.props.slotName);if(e===null||e===void 0||e===!1)return this.props.fallbackOnFailure??null;return e}return this.props.children}};ite({"time-to-first-draw":Uko})});var{stringWidth:jko}=globalThis.Bun;function ygr(e,t=!1){return t?e.keys:`${e.keys} ${e.label}`}function Bko(e,t,n=!1){let r=[...e],i=()=>jko(r.map((o)=>ygr(o,n)).join(_gr))<=Math.max(0,t);while(r.length>0&&!i()){let o=0;for(let s=1;s<r.length;s+=1)if((r[s]?.priority??0)>=(r[o]?.priority??0))o=s;r.splice(o,1)}return r}function fC({hints:e,width:t,colors:n,marginTop:r,compact:i=!1}){let o=Bko(e,t,i);if(o.length===0)return null;return Be("text",{fg:n.foreground,attributes:2,wrapMode:"none",marginTop:r??0,children:o.map((s)=>ygr(s,i)).join(_gr)})}var _gr=" \xB7 ";var nye=A(()=>{bu()});function uye(e){if(e<192||e>8580)return e;let t=xDt[e];if(t!==void 0)return t.codePointAt(0);return e}function iye(e){return e}function qko(e){return e}function cF(e,t){return e>t?e:t}function ate(e,t,n){if(n)return e;return t-e-1}function yDt(e){if(e)return new Set;return null}function rye(e,t,n){if(t!==null&&t.i16.length>e+n){let r=t.i16.subarray(e,e+n);return[e+n,r]}return[e,new Int16Array(n)]}function xgr(e,t,n){if(t!==null&&t.i32.length>e+n){let r=t.i32.subarray(e,e+n);return[e+n,r]}return[e,new Int32Array(n)]}function Tgr(e){if(e>=Sgr&&e<=wgr)return 1;else if(e>=oye&&e<=sye)return 2;else if(e>=Hko&&e<=Gko)return 4;else return 0}function Agr(e){let t=String.fromCodePoint(e);if(t!==t.toUpperCase())return 1;else if(t!==t.toLowerCase())return 2;else if(t.match(/\p{Number}/gu)!==null)return 4;else if(t.match(/\p{Letter}/gu)!==null)return 3;return 0}function R$e(e){if(e<=cte)return Tgr(e);return Agr(e)}function vDt(e,t){if(e===0&&t!==0)return wW;else if(e===1&&t===2||e!==4&&t===4)return Vko;else if(t===0)return Kko;return 0}function Jko(e,t){if(t===0)return wW;return vDt(R$e(e[t-1]),R$e(e[t]))}function Qko(e,t,n,r){let i=e.slice(r),o=i.indexOf(n);if(o===0)return r;if(!t&&n>=Sgr&&n<=wgr){if(o>0)i=i.slice(0,o);let s=i.indexOf(n-32);if(s>=0)o=s}if(o<0)return-1;return r+o}function vgr(e){for(let t of e)if(t>=128)return!1;return!0}function bDt(e,t,n){if(!vgr(e))return 0;if(!vgr(t))return-1;let r=0,i=0;for(let o=0;o<t.length;o++){if(i=Qko(e,n,t[o],i),i<0)return-1;if(o===0&&i>0)r=i-1;i++}return r}function Igr(e,t,n,r,i,o,s){let a=0,c=0,u=!1,l=0,d=iye(0),p=yDt(s),f=0;if(i>0)f=R$e(n[i-1]);for(let m=i;m<o;m++){let h=n[m],g=R$e(h);if(!e){if(h>=oye&&h<=sye)h+=32;else if(h>cte)h=String.fromCodePoint(h).toLowerCase().codePointAt(0)}if(t)h=uye(h);if(h===r[a]){if(s&&p!==null)p.add(m);c+=aye;let _=vDt(f,g);if(l===0)d=_;else{if(_===wW)d=_;_=cF(cF(_,d),Egr)}if(a===0)c+=_*kgr;else c+=_;u=!1,l++,a++}else{if(u)c+=cye;else c+=C$e;u=!0,l=0,d=0}f=g}return[c,p]}function tTo(e,t){return{i16:new Int16Array(e),i32:new Int32Array(t)}}function Dgr(e,t){let n=Object.keys(e).map((i)=>parseInt(i,10)).sort((i,o)=>o-i),r=[];for(let i of n)if(r=r.concat(e[i]),r.length>=t)break;return r}function Ogr(e,t,n){return(r)=>{let i=this.runesList[r];if(t.length>i.length)return;let[o,s]=this.algoFn(n,this.opts.normalize,this.opts.forward,i,t,!0,nTo);if(o.start===-1)return;if(this.opts.fuzzy===!1){s=new Set;for(let c=o.start;c<o.end;++c)s.add(c)}let a=this.opts.sort?o.score:0;if(e[a]===void 0)e[a]=[];e[a].push({item:this.items[r],...o,positions:s!=null?s:new Set})}}function rTo(e){let{queryRunes:t,caseSensitive:n}=Rgr(e,this.opts.casing,this.opts.normalize),r={},i=Ogr.bind(this)(r,t,n);for(let o=0,s=this.runesList.length;o<s;++o)i(o);return Dgr(r,this.opts.limit)}function oTo(e,t,n,r){return new Promise((i,o)=>{let a=0,c=Math.min(1000,t),u=()=>{if(e.cancelled)return o("search cancelled");for(;a<c;++a)n(a);if(c<t)c=Math.min(c+1000,t),iTo?setImmediate(u):setTimeout(u);else i(r())};u()})}function sTo(e,t){let{queryRunes:n,caseSensitive:r}=Rgr(e,this.opts.casing,this.opts.normalize),i={};return oTo(t,this.runesList.length,Ogr.bind(this)(i,n,r),()=>Dgr(i,this.opts.limit))}class Pgr{constructor(e,...t){switch(this.opts={...SDt,...t[0]},this.items=e,this.runesList=e.map((n)=>bgr(this.opts.selector(n).normalize())),this.algoFn=Yko,this.opts.fuzzy){case"v2":this.algoFn=Xko;break;case"v1":this.algoFn=Cgr;break}}}function uTo(e,t){if(t.sort){let{selector:n}=t;e.sort((r,i)=>{if(r.score===i.score)for(let o of t.tiebreakers){let s=o(r,i,n);if(s!==0)return s}return 0})}if(Number.isFinite(t.limit))e.splice(t.limit);return e}class wDt{constructor(e,...t){this.finder=new Mgr(e,...t),this.find=this.finder.find.bind(this.finder)}}var xDt,_Dt,bgr=(e)=>e.split("").map((t)=>t.codePointAt(0)),Wko,cte,oye,sye,Sgr,wgr,Hko,Gko,aye=16,C$e=-3,cye=-1,wW,Kko,Vko,Egr,kgr=2,Xko=(e,t,n,r,i,o,s)=>{let a=i.length;if(a===0)return[{start:0,end:0,score:0},yDt(o)];let c=r.length;if(s!==null&&c*a>s.i16.length)return Cgr(e,t,n,r,i,o);let u=bDt(r,i,e);if(u<0)return[{start:-1,end:-1,score:0},null];let l=0,d=0,p=null,f=null,m=null,h=null;[l,p]=rye(l,s,c),[l,f]=rye(l,s,c),[l,m]=rye(l,s,c),[d,h]=xgr(d,s,a);let[,g]=xgr(d,s,c);for(let _e=0;_e<g.length;_e++)g[_e]=r[_e];let _=iye(0),y=0,x=0,b=0,S=i[0],T=i[0],I=iye(0),R=0,F=!1,z=g.subarray(u),j=p.subarray(u).subarray(0,z.length),K=f.subarray(u).subarray(0,z.length),te=m.subarray(u).subarray(0,z.length);for(let[_e,G]of z.entries()){let Z=null;if(G<=cte){if(Z=Tgr(G),!e&&Z===2)G+=32}else{if(Z=Agr(G),!e&&Z===2)G=String.fromCodePoint(G).toLowerCase().codePointAt(0);if(t)G=uye(G)}z[_e]=G;let le=vDt(R,Z);if(te[_e]=le,R=Z,G===T){if(x<a)h[x]=qko(u+_e),x++,T=i[Math.min(x,a-1)];b=u+_e}if(G===S){let Oe=aye+le*kgr;if(j[_e]=Oe,K[_e]=1,a===1&&(n&&Oe>_||!n&&Oe>=_)){if(_=Oe,y=u+_e,n&&le===wW)break}F=!1}else{if(F)j[_e]=cF(I+cye,0);else j[_e]=cF(I+C$e,0);K[_e]=0,F=!0}I=j[_e]}if(x!==a)return[{start:-1,end:-1,score:0},null];if(a===1){let _e={start:y,end:y+1,score:_};if(!o)return[_e,null];let G=new Set;return G.add(y),[_e,G]}let ee=h[0],ge=b-ee+1,he=null;[l,he]=rye(l,s,ge*a);{let _e=p.subarray(ee,b+1);for(let[G,Z]of _e.entries())he[G]=Z}let[,Se]=rye(l,s,ge*a);{let _e=f.subarray(ee,b+1);for(let[G,Z]of _e.entries())Se[G]=Z}let U=h.subarray(1),Q=i.slice(1).slice(0,U.length);for(let[_e,G]of U.entries()){let Z=!1,le=Q[_e],Oe=_e+1,ve=Oe*ge,Le=g.subarray(G,b+1),V=m.subarray(G).subarray(0,Le.length),re=Se.subarray(ve+G-ee).subarray(0,Le.length),be=Se.subarray(ve+G-ee-1-ge).subarray(0,Le.length),ue=he.subarray(ve+G-ee).subarray(0,Le.length),ae=he.subarray(ve+G-ee-1-ge).subarray(0,Le.length),Ee=he.subarray(ve+G-ee-1).subarray(0,Le.length);Ee[0]=0;for(let[Me,pe]of Le.entries()){let Re=Me+G,et=0,Fe=0,rt=0;if(Z)Fe=Ee[Me]+cye;else Fe=Ee[Me]+C$e;if(le===pe){et=ae[Me]+aye;let Mt=V[Me];if(rt=be[Me]+1,Mt===wW)rt=1;else if(rt>1)Mt=cF(Mt,cF(Egr,m[Re-rt+1]));if(et+Mt<Fe)et+=V[Me],rt=0;else et+=Mt}re[Me]=rt,Z=et<Fe;let xt=cF(cF(et,Fe),0);if(Oe===a-1&&(n&&xt>_||!n&&xt>=_))_=xt,y=Re;ue[Me]=xt}}let Y=yDt(o),X=ee;if(o&&Y!==null){let _e=a-1;X=y;let G=!0;while(!0){let Z=_e*ge,le=X-ee,Oe=he[Z+le],ve=0,Le=0;if(_e>0&&X>=h[_e])ve=he[Z-ge+le-1];if(X>h[_e])Le=he[Z+le-1];if(Oe>ve&&(Oe>Le||Oe===Le&&G)){if(Y.add(X),_e===0)break;_e--}G=Se[Z+le]>1||Z+ge+le+1<Se.length&&Se[Z+ge+le+1]>0,X--}}return[{start:X,end:y+1,score:_},Y]},Cgr=(e,t,n,r,i,o,s)=>{if(i.length===0)return[{start:0,end:0,score:0},null];if(bDt(r,i,e)<0)return[{start:-1,end:-1,score:0},null];let a=0,c=-1,u=-1,l=r.length,d=i.length;for(let p=0;p<l;p++){let f=r[ate(p,l,n)];if(!e){if(f>=oye&&f<=sye)f+=32;else if(f>cte)f=String.fromCodePoint(f).toLowerCase().codePointAt(0)}if(t)f=uye(f);let m=i[ate(a,d,n)];if(f===m){if(c<0)c=p;if(a++,a===d){u=p+1;break}}}if(c>=0&&u>=0){a--;for(let m=u-1;m>=c;m--){let h=ate(m,l,n),g=r[h];if(!e){if(g>=oye&&g<=sye)g+=32;else if(g>cte)g=String.fromCodePoint(g).toLowerCase().codePointAt(0)}let _=ate(a,d,n),y=i[_];if(g===y){if(a--,a<0){c=m;break}}}if(!n){let m=c;c=l-u,u=l-m}let[p,f]=Igr(e,t,r,i,c,u,o);return[{start:c,end:u,score:p},f]}return[{start:-1,end:-1,score:0},null]},Yko=(e,t,n,r,i,o,s)=>{if(i.length===0)return[{start:0,end:0,score:0},null];let a=r.length,c=i.length;if(a<c)return[{start:-1,end:-1,score:0},null];if(bDt(r,i,e)<0)return[{start:-1,end:-1,score:0},null];let u=0,l=-1,d=iye(0),p=iye(-1);for(let f=0;f<a;f++){let m=ate(f,a,n),h=r[m];if(!e){if(h>=oye&&h<=sye)h+=32;else if(h>cte)h=String.fromCodePoint(h).toLowerCase().codePointAt(0)}if(t)h=uye(h);let g=ate(u,c,n);if(i[g]===h){if(g===0)d=Jko(r,m);if(u++,u===c){if(d>p)l=f,p=d;if(d===wW)break;f-=u-1,u=0,d=0}}else f-=u,u=0,d=0}if(l>=0){let f=0,m=0;if(n)f=l-c+1,m=l+1;else f=a-(l+1),m=a-(l-c+1);let[h]=Igr(e,t,r,i,f,m,!1);return[{start:f,end:m,score:h},null]}return[{start:-1,end:-1,score:0},null]},Zko=102400,eTo=2048,nTo,Rgr=(e,t,n)=>{let r=!1;switch(t){case"smart-case":if(e.toLowerCase()!==e)r=!0;break;case"case-sensitive":r=!0;break;case"case-insensitive":e=e.toLowerCase(),r=!1;break}let i=bgr(e);if(n)i=i.map(uye);return{queryRunes:i,caseSensitive:r}},iTo,SDt,aTo,Mgr,dSc,cTo=(e)=>({item:e,start:-1,end:-1,score:0,positions:new Set});var Ngr=A(()=>{xDt={216:"O",223:"s",248:"o",273:"d",295:"h",305:"i",320:"l",322:"l",359:"t",383:"s",384:"b",385:"B",387:"b",390:"O",392:"c",393:"D",394:"D",396:"d",398:"E",400:"E",402:"f",403:"G",407:"I",409:"k",410:"l",412:"M",413:"N",414:"n",415:"O",421:"p",427:"t",429:"t",430:"T",434:"V",436:"y",438:"z",477:"e",485:"g",544:"N",545:"d",549:"z",564:"l",565:"n",566:"t",567:"j",570:"A",571:"C",572:"c",573:"L",574:"T",575:"s",576:"z",579:"B",580:"U",581:"V",582:"E",583:"e",584:"J",585:"j",586:"Q",587:"q",588:"R",589:"r",590:"Y",591:"y",592:"a",593:"a",595:"b",596:"o",597:"c",598:"d",599:"d",600:"e",603:"e",604:"e",605:"e",606:"e",607:"j",608:"g",609:"g",610:"G",613:"h",614:"h",616:"i",618:"I",619:"l",620:"l",621:"l",623:"m",624:"m",625:"m",626:"n",627:"n",628:"N",629:"o",633:"r",634:"r",635:"r",636:"r",637:"r",638:"r",639:"r",640:"R",641:"R",642:"s",647:"t",648:"t",649:"u",651:"v",652:"v",653:"w",654:"y",655:"Y",656:"z",657:"z",663:"c",665:"B",666:"e",667:"G",668:"H",669:"j",670:"k",671:"L",672:"q",686:"h",867:"a",868:"e",869:"i",870:"o",871:"u",872:"c",873:"d",874:"h",875:"m",876:"r",877:"t",878:"v",879:"x",7424:"A",7427:"B",7428:"C",7429:"D",7431:"E",7432:"e",7433:"i",7434:"J",7435:"K",7436:"L",7437:"M",7438:"N",7439:"O",7440:"O",7441:"o",7442:"o",7443:"o",7446:"o",7447:"o",7448:"P",7449:"R",7450:"R",7451:"T",7452:"U",7453:"u",7454:"u",7455:"m",7456:"V",7457:"W",7458:"Z",7522:"i",7523:"r",7524:"u",7525:"v",7834:"a",7835:"s",8305:"i",8341:"h",8342:"k",8343:"l",8344:"m",8345:"n",8346:"p",8347:"s",8348:"t",8580:"c"};for(let e="\u0300".codePointAt(0);e<="\u036F".codePointAt(0);++e){let t=String.fromCodePoint(e);for(let n of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"){let i=(n+t).normalize().codePointAt(0);if(i>126)xDt[i]=n}}_Dt={a:[7844,7863],e:[7870,7879],o:[7888,7907],u:[7912,7921]};for(let e of Object.keys(_Dt)){let t=e.toUpperCase();for(let n=_Dt[e][0];n<=_Dt[e][1];++n)xDt[n]=n%2===0?t:e}Wko=new Set(` \f
|
|
2101
2101
|
\r \v\xA0\u1680\u2028\u2029\u202F\u205F\u3000\uFEFF`.split("").map((e)=>e.codePointAt(0)));for(let e="\u2000".codePointAt(0);e<="\u200A".codePointAt(0);e++)Wko.add(e);cte="\x7F".codePointAt(0),oye="A".codePointAt(0),sye="Z".codePointAt(0),Sgr="a".codePointAt(0),wgr="z".codePointAt(0),Hko="0".codePointAt(0),Gko="9".codePointAt(0);wW=aye/2,Kko=aye/2,Vko=wW+cye,Egr=-(C$e+cye);nTo=tTo(Zko,eTo);iTo=typeof window>"u";SDt={limit:1/0,selector:(e)=>e,casing:"smart-case",normalize:!0,fuzzy:"v2",tiebreakers:[],sort:!0,forward:!0};aTo={...SDt,match:rTo};Mgr=class Mgr extends Pgr{constructor(e,...t){super(e,...t);this.opts={...aTo,...t[0]}}find(e){if(e.length===0||this.items.length===0)return this.items.slice(0,this.opts.limit).map(cTo);e=e.normalize();let t=this.opts.match.bind(this)(e);return uTo(t,this.opts)}};dSc={...SDt,match:sTo}});function Lgr(e,{query:t="",collapsedGroups:n=[],expanded:r=!1,collapsedLabel:i,visibleLimit:o=1/0,rowLimit:s=1/0}={}){let a=t.trim(),c=new wDt(e.map((m,h)=>({choice:m,index:h})),{selector:({choice:m})=>`${m.name} ${m.description??""}`,casing:"case-insensitive"}).find(a).map(({item:m,positions:h})=>({...m,positions:h})),u=new Map;for(let m of c){let h=u.get(m.choice.group)??[];h.push(m),u.set(m.choice.group,h)}let l=new Set,d=new Set;for(let m of c){if(!r&&!a){if(m.choice.group!==void 0&&n.includes(m.choice.group))continue;let h=new Set([...d,m.choice.group]),g=[...h].filter((x)=>x!==void 0).length,_=Math.max(0,h.size-1),y=l.size+1<c.length?2:0;if(l.size>=o||l.size+1+g+_+y>s)break}l.add(m.index),d.add(m.choice.group)}let p=[],f=c.length-l.size;for(let[m,h]of u){let g=h.filter(({index:_})=>l.has(_));if(g.length===0)continue;if(p.length>0)p.push({kind:"blank"});if(m!==void 0)p.push({kind:"heading",label:m.toLocaleUpperCase()});for(let{choice:_,index:y,positions:x}of g)p.push({kind:"choice",choice:_,index:y,positions:x})}if(f>0){if(p.length>0)p.push({kind:"blank"});let m=i??(n.length===1?n[0]:void 0)??"More choices";p.push({kind:"expand",label:`${m} (${String(f)})\u2026`})}return p}var Fgr=A(()=>{Ngr()});function $gr({text:e,positions:t,offset:n=0,clipped:r=!1}){if(t.size===0)return e;let i=[...t];return Array.from(dTo.segment(e),({segment:o,index:s})=>{let a=s+n;return(!r||s+o.length<e.length)&&i.some((u)=>u>=a&&u<a+o.length)?Be("b",{children:o},s):o})}function Cm({title:e,choices:t,onCancel:n,onSelect:r,currentIndex:i,initialIndex:o,collapsedGroups:s,collapsedLabel:a,visibleLimit:c,rowLimit:u,descriptionWrap:l=!0,descriptionWidth:d,searchable:p=!1,showDescription:f=!0,onHighlight:m,onKey:h,disabled:g=!1,hints:_=lTo,colors:y}){let x=Ns(()=>s?.map(yr)??[],[s]),b=a===void 0?void 0:yr(a),S=e===void 0?void 0:yr(e),T=Ns(()=>t.map((ae)=>{let Ee=yr(ae.name).normalize();return{...ae,name:d!==void 0||!l?Ee.replace(/\s+/gu," "):Ee,description:ae.description===void 0?void 0:yr(ae.description).normalize(),group:ae.group===void 0?void 0:yr(ae.group)}}),[t,d,l]),I=tE(),{width:R,height:F}=Kf(),z=F<14,j=Pr(null),K=Pr(!0),te=Pr(null),[ee,ge]=ii(""),[he,Se]=ii(!1),[U,Q]=ii(`choice-${String(o??i??0)}`),Y=Pr(U),X=(ae)=>{if(ae===Y.current)return;Y.current=ae,Q(ae);let Ee=/^choice-(\d+)$/u.exec(ae)?.[1];if(Ee!==void 0)m?.(Number(Ee))},_e=Ns(()=>Lgr(T,{query:ee,collapsedGroups:x,collapsedLabel:b,visibleLimit:c,rowLimit:u,expanded:he}),[T,ee,x,b,c,u,he]),G=_e.filter((ae)=>ae.kind==="choice"||ae.kind==="expand"),Z=Math.max(0,G.findIndex((ae)=>uF(ae)===U)),le=G[Z]===void 0?void 0:uF(G[Z]),[Oe,ve]=ii(Math.max(1,Math.min(68,R-2)-(z?4:6)-2));Og(()=>{if(d===void 0)return;let ae=()=>{if(te.current)ve(Math.max(1,te.current.width-2))};return I.addPostProcessFn(ae),()=>{I.removePostProcessFn(ae)}},[I,d]);let Le=(ae)=>{if(g)return;if(ae?.kind==="choice")r(ae.index);else if(ae?.kind==="expand"){Se(!0);let Ee=new Set(_e.flatMap((pe)=>pe.kind==="choice"?[pe.index]:[])),Me=T.findIndex((pe,Re)=>!Ee.has(Re));X(`choice-${String(Me)}`)}},V=(ae)=>{if(h?.(ae)===!0){ae.preventDefault();return}if(ae.name==="escape"||ae.ctrl&&ae.name==="c"){if(ae.preventDefault(),!g)n()}else if(g)ae.preventDefault();else if(!ae.ctrl&&!ae.meta&&!ae.option&&/^[1-9]$/.test(ae.name))ae.preventDefault(),Le(G[Number(ae.name)-1]);else if(ae.name==="up"||ae.name==="down"){ae.preventDefault();let Ee=G[Math.max(0,Math.min(G.length-1,Math.max(0,G.findIndex((Me)=>uF(Me)===Y.current))+(ae.name==="up"?-1:1)))];if(Ee)X(uF(Ee))}else if(!p&&(ae.name==="return"||ae.name==="enter"))ae.preventDefault(),Le(G[Math.max(0,G.findIndex((Ee)=>uF(Ee)===Y.current))])};Og(()=>{if(!p)te.current?.focus()},[p]),Og(()=>{K.current=!0;let ae=()=>{if(!K.current||le===void 0)return;K.current=!1,j.current?.scrollChildIntoView(le)};return I.addPostProcessFn(ae),()=>{I.removePostProcessFn(ae)}},[I,le,_e]);let re=(S===void 0?0:z?1:2)+(p?z?1:2:0)+(z?1:2),be=Math.max(1,F-(z?4:6)-re),ue=(ae)=>{if(!l)return 1;if(ae.kind!=="choice"&&ae.kind!=="expand")return 1;let Ee=ae.kind==="choice"?`${ae.index===i?"\u25CF ":""}${ae.choice.name}`:ae.label,Me=ae.kind==="choice"&&f&&(!z||d!==void 0)?ae.choice.description:void 0;if(Me&&Bun.stringWidth(Ee)+Bun.stringWidth(Me)+4<=Oe)return 1;return Math.max(1,Math.ceil(Bun.stringWidth(Ee)/Math.max(1,Oe-2)))+(Me?Math.ceil(Bun.stringWidth(Me)/Math.max(1,Oe-2)):0)};return Vn("box",{ref:te,width:"100%",minWidth:0,focusable:!p,focused:!p,onSizeChange:()=>{if(te.current)ve(Math.max(1,te.current.width-2))},onKeyDown:(ae)=>{if(!p)V(ae)},flexDirection:"column",backgroundColor:y.background,children:[S===void 0?null:Be("text",{fg:y.foreground,attributes:1,marginBottom:z?0:1,children:S}),p?Vn("box",{flexDirection:"row",marginBottom:z?0:1,children:[Be("text",{fg:y.accent,width:2,flexShrink:0,children:"/ "}),Be("input",{flexGrow:1,value:ee,placeholder:"type to filter",onInput:(ae)=>{ge(ae),X("")},onSubmit:()=>{Le(G[Math.max(0,G.findIndex((ae)=>uF(ae)===Y.current))])},onKeyDown:V,focused:!0,backgroundColor:y.background,focusedBackgroundColor:y.background,textColor:y.foreground,focusedTextColor:y.foreground,cursorColor:y.accent})]}):null,Vn("scrollbox",{ref:j,onSizeChange:()=>{K.current=!0},flexBasis:Math.min(be,Math.max(1,_e.reduce((ae,Ee)=>ae+ue(Ee),0))),scrollbarOptions:{visible:!1},minHeight:1,flexShrink:1,scrollX:!1,children:[_e.map((ae,Ee)=>{if(ae.kind==="blank")return Be("box",{height:1,flexShrink:0},`blank-${String(Ee)}`);if(ae.kind==="heading")return Be("text",{fg:y.foreground,attributes:2,children:ae.label},`heading-${String(Ee)}`);let Me=uF(ae),pe=G.findIndex((qt)=>uF(qt)===Me)+1,Re=Me===le,et=ae.kind==="choice"?`${ae.index===i?"\u25CF ":""}${ae.choice.name}`:ae.label,Fe=d!==void 0,rt=32,xt=Fe?Wc(et,Math.max(0,Oe-4-d)):l?et:Wc(et,Math.max(0,Math.min(rt,Oe-2))),Mt=ae.kind==="choice"&&f&&(!z||d!==void 0)?ae.choice.description:void 0,ht=Bun.stringWidth(xt),$t=Fe||l||Mt===void 0?Mt:Bun.stringWidth(Mt)<=Oe-rt-4?Mt:void 0,yn=$t!==void 0&&(!l||ht+Bun.stringWidth($t)+4<=Oe);return Vn("box",{id:Me,flexDirection:"row",flexShrink:0,backgroundColor:Re?y.selection:y.background,onMouseDown:(qt)=>{qt.preventDefault(),X(Me),Le(ae)},children:[Be("text",{width:2,flexShrink:0,fg:y.foreground,children:pe<=9?`${String(pe)} `:" "}),Be("text",{width:2,flexShrink:0,fg:y.selectionForeground,children:Re?"\u25B6 ":" "}),Vn("box",{flexDirection:yn?"row":"column",flexGrow:1,flexShrink:1,minWidth:0,children:[Be("text",{fg:ae.kind==="choice"&&ae.choice.tone==="destructive"?y.error:Re?y.selectionForeground:y.foreground,flexShrink:Fe?1:0,flexGrow:Fe?1:0,minWidth:0,width:Fe?"auto":yn?l?ht:rt+2:"100%",wrapMode:!l||ht<=Oe-2?"none":"char",children:ae.kind==="choice"?Be($gr,{text:xt,positions:ae.positions,offset:ae.index===i?-2:0,clipped:xt!==et}):xt}),$t===void 0?null:Be("box",{flexGrow:Fe?0:1,flexShrink:0,marginLeft:Fe?2:0,width:Fe?d:"auto",alignItems:Fe||l?"flex-end":"flex-start",children:Be("text",{fg:Re?y.selectionForeground:y.foreground,attributes:Re?0:2,wrapMode:l?"char":"none",children:ae.kind==="choice"?Be($gr,{text:$t,positions:ae.positions,offset:ae.choice.name.length+1}):$t})})]})]},Me)}),G.length===0?Be("text",{fg:y.foreground,attributes:2,children:"No matches"}):null]}),Be(fC,{hints:[..._,{keys:"1\u20139",label:"pick",priority:3}],compact:R<48||z,width:Oe,colors:y,marginTop:z?0:1})]})}function zgr({rows:e,selected:t,onChoose:n,header:r,maxRows:i,width:o,colors:s}){let a=Math.max(0,Math.min(t-i+1,e.length)),c=e.slice(a,a+i),u=Math.min(Math.max(0,...e.map((l)=>Bun.stringWidth(l.label)))+2,Math.max(8,Math.floor(o/3)));return Vn("box",{marginX:1,flexDirection:"column",flexShrink:0,children:[r===void 0?null:Be("text",{fg:s.foreground,attributes:2,paddingX:1,children:Wc(yr(r),o-2)}),c.map((l,d)=>{let p=a+d,f=p===t;return Vn("box",{flexDirection:"row",height:1,paddingX:1,backgroundColor:f?s.selection:s.background,onMouseDown:(m)=>{m.preventDefault(),n(p)},children:[Be("text",{fg:f?s.selectionForeground:s.accent,width:u,flexShrink:0,children:Wc(yr(l.label),u-1)}),Be("text",{fg:f?s.selectionForeground:s.foreground,attributes:f?0:2,wrapMode:"none",children:Wc(yr(l.detail),o-u-2)})]},l.key)})]})}var lTo,uF=(e)=>e.kind==="choice"?`choice-${String(e.index)}`:"expand",dTo;var jP=A(async()=>{bu();oF();k1();Xi();nye();Fgr();await qg();lTo=[{keys:"\u2191\u2193",label:"choose",priority:1},{keys:"Enter",label:"select",priority:0},{keys:"Esc",label:"close",priority:2}],dTo=new Intl.Segmenter(void 0,{granularity:"grapheme"})});import{mkdir as pTo,readFile as fTo}from"fs/promises";import{homedir as mTo}from"os";import{dirname as hTo,join as gTo}from"path";async function EW(e=jgr()){try{let t=JSON.parse(await fTo(e,"utf8")),n=_To.safeParse(t);if(!n.success)throw Error("expected theme terminal, mocha, or latte; sigils auto, on, or off; update off or notify");return n.data}catch(t){let n=yTo.safeParse(t);if(n.success&&n.data.code==="ENOENT")return{theme:"terminal"};return{theme:"terminal",error:`Unable to read ${e}: ${t instanceof Error?t.message:"invalid preferences"}`}}}async function lye(e,t=jgr()){let n=await EW(t);if(n.error)throw Error(n.error);let r={...n,theme:e};await pTo(hTo(t),{recursive:!0}),await Ugr.default(t,`${JSON.stringify(r)}
|
|
2102
2102
|
`,{mode:384})}var Ugr,ute,_To,yTo,jgr=()=>gTo(mTo(),".config","fungi","tui.json");var lte=A(()=>{Wn();Ugr=rl(BI(),1),ute=["terminal","mocha","latte"],_To=Xe({theme:ln(ute).default("terminal"),sigils:ln(["auto","on","off"]).optional(),update:ln(["off","notify"]).optional()}),yTo=se({code:D()})});import{CliRenderEvents as D$e,RGBA as O$e}from"@opentui/core";function mC(e){let t=Bun.color(e,"hex");if(t===null)throw Error(`Unsupported Stipe color: ${e}`);return O$e.fromHex(t)}function xTo(e,t,n){if(e==="terminal"){let i=O$e.defaultForeground(t?.defaultForeground??void 0),o=O$e.defaultBackground(t?.defaultBackground??void 0),s=(a)=>{let c=a+(n==="light"?0:8);return O$e.fromIndex(c,t?.palette[c]??void 0)};return{background:o,foreground:i,surface:i,selection:i,selectionForeground:o,primary:s(5),accent:s(5),success:s(2),info:s(4),warning:s(3),error:s(1)}}let r=P_e(e);if(r===void 0)throw Error(`Missing Stipe theme: ${e}`);return{background:mC(r.background),foreground:mC(r.foreground),surface:mC(r.surface),selection:mC(r.selectionBackground),selectionForeground:mC(r.selectionForeground),primary:mC(r.primary),accent:mC(r.accent),success:mC(r.success),info:mC(r.info),warning:mC(r.warning),error:mC(r.error)}}function vTo(e){let t={palette:void 0,mode:e.themeMode},n=!1,r=new Set,i=(l)=>{t=l;for(let d of r)d()},o=(l)=>{i({...t,palette:l})},s=(l)=>{i({...t,mode:l})},a=!1,c=()=>{a=!1,e.clearPaletteCache(),e.getPalette({size:16}).then(o,()=>{return})},u=()=>{if(n=!0,a)return;a=!0,queueMicrotask(c)};return{read:()=>t,ensure:()=>{if(!n)u()},refresh:u,subscribe:(l)=>{if(r.size===0)e.on(D$e.PALETTE,o),e.on(D$e.THEME_MODE,s);return r.add(l),()=>{if(r.delete(l),r.size===0)e.off(D$e.PALETTE,o),e.off(D$e.THEME_MODE,s)}}}}function hC(e,t={}){let n=tE(),r=Bgr.get(n);if(r===void 0)r=vTo(n),Bgr.set(n,r);let{palette:i,mode:o}=Ka(r.subscribe,r.read),s=r.refresh,a=r.ensure,c=Pr(e);Qn(()=>{if(e==="terminal")if(c.current!=="terminal"&&t.refreshOnReturnToTerminal!==!1)s();else a();c.current=e},[e,a,s,t.refreshOnReturnToTerminal]);let u=Ns(()=>{let l=xTo(e,i,o),d=e==="terminal"?{foreground:i?.defaultForeground===null||i?.defaultForeground===void 0?void 0:l.foreground,background:i?.defaultBackground===null||i?.defaultBackground===void 0?void 0:l.background}:{foreground:l.foreground,background:l.background};return Nhr(l,e==="terminal",d)},[e,i,o]);return Qn(()=>()=>{u.syntax.destroy()},[u]),{...u,refresh:s}}function STo({theme:e,colors:t,onPreview:n,onConfirm:r,onClose:i}){let[o,s]=ii(!1),[a,c]=ii(),u=Pr(!1);Qn(()=>(u.current=!0,()=>{u.current=!1,n(void 0)}),[n]);let l=async(d)=>{if(o)return;s(!0);try{await r(d),i()}catch(p){if(Oi("terminal-theme-save",p),u.current)c(p instanceof Error?p.message:"Unable to save theme")}finally{if(u.current)s(!1)}};return Vn("box",{children:[Be(Cm,{title:"Theme",choices:ute.map((d)=>({name:d.charAt(0).toUpperCase()+d.slice(1)})),currentIndex:ute.indexOf(e),showDescription:!1,disabled:o,hints:bTo,onHighlight:(d)=>{let p=ute[d];if(p!==void 0)n(p)},onSelect:(d)=>{let p=ute[d];if(p!==void 0)l(p)},onCancel:i,colors:t}),o?Be("text",{fg:t.foreground,attributes:2,children:"Saving theme\u2026"}):null,a?Vn("text",{fg:t.error,children:["\u25CF ",a]}):null]})}function EDt(e,t){let[n,r]=ii(t.initialTheme),[i,o]=ii(),[s,a]=ii(t.initialError),c=hC(i??n),u=Pr(c);u.current=c;let l=()=>{let f=t.confirm,m=!1;e.show((h)=>Be(STo,{theme:n,colors:u.current.colors,onPreview:o,onClose:h.dismiss,onConfirm:async(g)=>{m=!0;try{if(await f(g),!h.isCurrent())return;if(r(g),a(void 0),g==="terminal")u.current.refresh()}finally{m=!1}}}),{beforeDismiss:()=>!m})},d=Pr(l);d.current=l;let p=t.commands;return Qn(()=>{let f=p.contribute({sourceId:"tui-frame",namespace:"tui",commands:[{id:"theme",title:"Theme",category:"Settings",description:"Choose terminal colors",projections:{palette:{order:5},slash:{aliases:["theme"],order:5}},handler:()=>{d.current()}}]});return()=>{f.dispose()}},[p]),{presentation:c,error:s}}var Bgr,bTo;var dye=A(async()=>{bu();zAt();Xi();l$e();lte();P1();await du([qg(),jP()]);Bgr=new WeakMap;bTo=[{keys:"\u2191\u2193",label:"preview",priority:1},{keys:"Enter",label:"save",priority:0},{keys:"Esc",label:"cancel",priority:2}]});function kTo(e){let t=qgr.get(e);if(t!==void 0)return t;let n=++ETo;return qgr.set(e,n),n}function TTo(e){return b4({queryKey:["tui-model-catalog",e?.identity],queryFn:({signal:t})=>{if(e===void 0)throw Error("Model source unavailable");return e.models(t)},enabled:e!==void 0,staleTime:0})}function ATo(e){return b4({queryKey:["tui-session-model-preference",e===void 0?void 0:kTo(e.modelPreference)],queryFn:()=>{if(e===void 0)throw Error("Model source unavailable");return e.modelPreference.read()},enabled:e!==void 0,staleTime:0})}function kDt(e){return b4({queryKey:["tui-effective-model",e?.identity],queryFn:({signal:t})=>{if(e===void 0)throw Error("Model source unavailable");return e.effectiveModel(t)},enabled:e!==void 0,staleTime:0})}function Wgr(e,t){return b4({queryKey:["tui-model-access",e?.identity],queryFn:({signal:n})=>{if(e===void 0)throw Error("Model account unavailable");return e.account.owner.access(n)},enabled:e!==void 0&&t==="fungi",staleTime:0})}function Hgr(e){let t=xO(),n=kw(TTo(e),t),r=kw(ATo(e),t),i=kw(kDt(e),t);if(e===void 0)return;let o=n.error??r.error??i.error,s={models:n.data??wTo,current:r.data,effective:i.data,modelPreference:e.modelPreference,onOpen:async()=>{await Promise.all([n.refetch(),r.refetch(),i.refetch()])}};return o===null?s:{...s,error:o.message}}var wTo,qgr,ETo=0;var Ggr=A(()=>{wO();wTo=[],qgr=new WeakMap});function TDt({source:e,commands:t}){let n=Hgr(e),r=kw(Wgr(e,n?.effective?.providerId)),i=n?.effective?.providerId==="fungi"&&r.isSuccess&&!r.data.some((f)=>f.providerId==="fungi")?q9e:void 0,o=e?.modelPreference,s=Pr(void 0);Qn(()=>{if(o===void 0)return;let f=t.contribute({sourceId:"tui-session",namespace:"session",commands:[]});return s.current=f,()=>{f.dispose(),s.current=void 0}},[t,o]);let a=n?.onOpen;Qn(()=>{if(n===void 0||e===void 0)return;let f=n.modelPreference;s.current?.update(D1t({modelPreference:{read:f.read,set:async(m)=>{await f.set(m),await a?.()}}},{account:e.account,sourceId:"tui-session",namespace:"session",models:n.models,refreshModels:e.models}))},[t,o,n?.models,e?.account]);let c=n?.effective,u=c===void 0?void 0:{provider:c.providerId,model:c.modelId},l=kw(kDt(e)),d=u===void 0||l.data?.credential.kind==="missing"||i!==void 0,p=c?.reasoning;return{loginNotice:i,selectedModel:u,selectedReasoning:p,refresh:a,signInRequired:d}}var Kgr=A(()=>{Xi();wO();Tm();Ggr()});var{stringWidth:kW}=globalThis.Bun;function Jgr(e,t){let n="";for(let{segment:r}of ITo.segment(e)){if(kW(n+r)>t)break;n+=r}return n}function RTo(e,t){let n=[],r="";for(let i of e.split(/\s+/u).filter((o)=>o!=="")){let o=i;while(kW(o)>t){if(r!=="")n.push(r),r="";let s=Jgr(o,t);if(s==="")return n;n.push(s),o=o.slice(s.length)}if(r==="")r=o;else if(kW(`${r} ${o}`)<=t)r=`${r} ${o}`;else n.push(r),r=o}if(r!=="")n.push(r);return n}function pye(e,t){let n=Math.max(1,t);return yr(e).split(`
|
|
2103
|
-
`).flatMap((r)=>{let i=RTo(r,n);return i.length===0?[""]:i})}function ADt(e,t,n,r="\u2026"){if(e.length<=t)return e;let i=e.slice(0,t),o=i[t-1]??"";return i[t-1]=`${Jgr(o,Math.max(0,n-kW(r))).trimEnd()}${r}`,i}function Qgr(e,t){return e!==void 0&&pye(e,t).length>Vgr}function F1({content:e,width:t,compact:n,detailsKey:r="d",marker:i,full:o=!1,colors:s}){let a=yr(e.title).replace(/\s+/gu," ").trim(),c=[...(e.facts??[]).map((h)=>h.label),...e.body!==void 0&&e.bodyLabel!==void 0?[e.bodyLabel]:[]],u=c.length===0?0:Math.max(...c.map((h)=>kW(h)))+2,l=Math.max(1,t-u),d=e.summary===void 0?[]:ADt(pye(e.summary,t),o?1/0:n?1:2,t),p=e.bodyLabel===void 0?t:l,f=e.body===void 0?void 0:ADt(pye(e.body,p),o?1/0:Vgr,p,`\u2026 ${r} shows all`),m=(e.facts?.length??0)>0;return Vn("box",{flexDirection:"column",rowGap:n?0:1,flexShrink:0,children:[Vn("box",{flexDirection:"column",children:[i===void 0?Be("text",{fg:s.foreground,attributes:1,wrapMode:"none",children:Wc(a,t)}):Vn("box",{flexDirection:"row",justifyContent:"space-between",children:[Be("text",{fg:s.foreground,attributes:1,wrapMode:"none",children:Wc(a,Math.max(1,t-kW(i)-2))}),Be("text",{fg:s.foreground,attributes:2,wrapMode:"none",children:i})]}),d.map((h,g)=>Be("text",{fg:s.foreground,attributes:2,wrapMode:"none",children:h},`summary-${String(g)}`))]}),m||f!==void 0?Vn("box",{flexDirection:"column",children:[(e.facts??[]).map((h)=>Be(IDt,{label:h.label,lines:ADt(pye(h.value,l),CTo,l),labelWidth:u,colors:s},h.label)),f===void 0?null:Be(IDt,{label:e.bodyLabel??"",lines:f,labelWidth:e.bodyLabel===void 0?0:u,colors:s})]}):null]})}function CDt({content:e,colors:t,children:n}){let r=Kf(),i=r.height<14;return Vn("box",{flexDirection:"column",rowGap:i?0:1,children:[Be(F1,{content:e,width:aS(r.width),compact:i,colors:t}),n]})}function IDt({label:e,lines:t,labelWidth:n,colors:r}){return Vn("box",{flexDirection:"row",children:[n===0?null:Be("text",{width:n,flexShrink:0,fg:r.foreground,attributes:2,wrapMode:"none",children:yr(e)}),Be("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:t.map((i,o)=>Be("text",{fg:r.foreground,wrapMode:"none",children:i},o))})]})}function TW({content:e,width:t,maxRows:n,colors:r,onKeyDown:i}){let o=e.details??[],s=(l)=>o.some((d)=>d.label===l.label),a=[...(e.body===void 0?[]:[{label:e.bodyLabel??"Text",value:e.body}]).filter((l)=>!s(l)),...(e.facts??[]).filter((l)=>!s(l)),...o],c=Math.max(0,...a.map((l)=>kW(l.label)))+2,u=Math.max(1,t-c);return Vn("box",{flexDirection:"column",rowGap:1,children:[Be("text",{fg:r.foreground,attributes:1,children:"Details"}),Be("scrollbox",{focused:!0,...i===void 0?{}:{onKeyDown:i},scrollbarOptions:{visible:!1},scrollX:!1,maxHeight:Math.max(1,n),children:a.map((l,d)=>Be(IDt,{label:l.label,lines:pye(l.value,u),labelWidth:c,colors:r},`${l.label}-${String(d)}`))})]})}var ITo,aS=(e)=>Math.max(1,Math.min(68,e-2)-4),CTo=2,Vgr=3;var AW=A(async()=>{bu();oF();k1();await qg();ITo=new Intl.Segmenter(void 0,{granularity:"grapheme"})});function P$e({placeholder:e,secret:t=!1,maxLength:n,initialValue:r="",value:i,focused:o=!0,onInput:s,onSubmit:a,onKeyDown:c,colors:u}){let l=Pr(null),[d,p]=ii((i??r).length);return Qn(()=>{let f=l.current;if(i===void 0||f===null||f.value===i)return;f.value=i,p(i.length)},[i]),Vn("box",{flexDirection:"row",backgroundColor:u.selection,paddingX:1,children:[t?Be("text",{fg:u.selectionForeground,children:d===0?" ":`${"\u2022".repeat(Math.min(d,32))} ${String(d)} characters`}):null,Be("box",{flexGrow:1,visible:!t,children:Be("input",{ref:l,width:"100%",maxLength:n,value:i??r,placeholder:yr(e??""),showCursor:!t,selectable:!t,focused:o,onInput:(f)=>{p(f.length),s?.(f)},onSubmit:()=>{a(l.current?.value??"")},onKeyDown:(f)=>{c?.(f)},backgroundColor:u.selection,focusedBackgroundColor:u.selection,textColor:u.selectionForeground,focusedTextColor:u.selectionForeground,cursorColor:u.accent})})]})}var RDt=A(()=>{bu();Xi();k1()});import{createClipboard as DTo,createHostClipboard as OTo,createRendererClipboardAdapter as PTo}from"@opentui/core";function MTo(e){return`\x1BPtmux;\x1B${`\x1B]52;c;${Buffer.from(e).toString("base64")}\x07`}\x1B\\`}async function NTo(e,t,n,r){t=t.replace(/\u{10eeee}\u0305[\u0305\u030d]/gu,"");let i=await e.writeText(t,{destination:"all-available"}),o=n!==void 0&&n.length>0;if(o)r(MTo(t));if(i.host.status==="written")return"copied";return o||i.terminal.status==="attempted"?"sent":"failed"}function Xgr(e,t={}){let n=t.service??DTo({host:OTo(),terminal:PTo(e)}),r=t.tmux??process.env.TMUX,i=t.writeTerminal??((o)=>process.stdout.write(o));return{async copy(o){return NTo(n,o,r,i)},dispose:()=>n.dispose()}}var Ygr=()=>{};function IW(e){return Array.from(yr(e)).slice(0,FTo).join("")}function e_r(){let e,t=[],n={current:void 0,pending:0},r,i=0,o=0,s=!1,a=!1,c,u=new Set,l=()=>{n=c===void 0?{current:e,pending:t.length}:{current:e,pending:t.length+1,attentionOverflow:c.reports};for(let h of u)h()},d=()=>{clearTimeout(r),r=void 0},p=(h)=>{d(),o=h,i=Date.now(),r=setTimeout(m,h)},f=(h)=>{if(e=h,h.duration!=="until-dismissed")p(h.duration)};function m(){if(a||e?.actionPending)return;if(d(),e=void 0,s=!1,c!==void 0)f({id:Zgr.toast.generate(),title:"Attention capacity reached",variant:"warning",duration:"until-dismissed",message:IW(`At least ${String(c.reports)} additional attention reports could not be listed individually. Latest: ${c.latest}`)}),c=void 0;else{let[h,...g]=t;if(t=g,h!==void 0)f(h)}l()}return{snapshot:()=>n,subscribe:(h)=>{if(a)return()=>{return};return u.add(h),()=>{u.delete(h)}},show:(h)=>{if(a)return;let g={id:Zgr.toast.generate(),variant:h.variant,message:IW(h.message),title:h.title===void 0?void 0:IW(h.title),duration:h.duration??DDt,action:h.action===void 0?void 0:{...h.action,label:IW(h.action.label)},key:h.key===void 0?void 0:IW(h.key)};if(g.duration==="until-dismissed"&&g.key!==void 0){if(e?.key===g.key){if(!e.actionPending)e={...g,id:e.id},l();return}let _=t.findIndex((x)=>x.key===g.key),y=t[_];if(y!==void 0){t=t.map((x,b)=>b===_?{...g,id:y.id}:x),l();return}}if(e===void 0)f(g);else{if(t.length===LTo){let _=t.findIndex((y)=>y.duration!=="until-dismissed");if(_!==-1)t=t.filter((y,x)=>x!==_);else if(g.duration!=="until-dismissed")return;else{c={reports:Math.min(Number.MAX_SAFE_INTEGER,(c?.reports??0)+1),latest:g.message},l();return}}t=[...t,g]}l()},dismiss:m,activate:()=>{if(a||e?.actionPending)return;let h=e,g=h?.action;if(g===void 0){m();return}if(h===void 0)return;d(),e={...h,actionPending:!0},l();let _=()=>{if(a||e?.id!==h.id)return;e={...e,actionPending:!1},m()},y=(x)=>{if(a||e?.id!==h.id)return;e={...e,variant:"warning",title:IW(`${g.label} failed`),message:IW(x instanceof Error?x.message:"The action did not complete."),duration:"until-dismissed",action:void 0,actionPending:!1},l()};try{let x=g.run();if(x===void 0)_();else Promise.resolve(x).then(_,y)}catch(x){y(x)}},pause:()=>{if(a||e?.actionPending)return;if(e===void 0||s)return;if(s=!0,r===void 0)return;o=Math.max(0,o-(Date.now()-i)),d()},resume:()=>{if(a||e?.actionPending)return;if(e===void 0||!s)return;if(s=!1,e.duration!=="until-dismissed")p(o)},dispose:()=>{if(a)return;a=!0,d(),u.clear(),e=void 0,t=[],c=void 0,n={current:void 0,pending:0}}}}var Zgr,DDt=4000,LTo=20,FTo=512;var ODt=A(()=>{DR();k1();Zgr=mc({family:"tui-toast",version:1,kinds:{toast:{prefix:"toast"}}})});import{RGBA as fye,TextAttributes as M$e}from"@opentui/core";function gC(){let e=Xd(PDt);if(e===void 0)throw Error("Toasts need a ToastProvider above this view");return Ns(()=>({show:e.show,dismiss:e.dismiss}),[e])}function mye({children:e}){return Xd(PDt)===void 0?Be(UTo,{children:e}):e}function UTo({children:e}){let t=tE(),[n]=ii(e_r);return Qn(()=>()=>{n.dispose()},[n]),Qn(()=>{let r=(i)=>{if(i.name!=="escape"||n.snapshot().current===void 0)return;i.preventDefault(),i.stopPropagation(),n.dismiss()};return t.keyInput.prependListener("keypress",r),()=>{t.keyInput.off("keypress",r)}},[t,n]),Vn(PDt.Provider,{value:n,children:[e,Be(jTo,{store:n})]})}function jTo({store:e}){let{current:t,pending:n,attentionOverflow:r}=Ka(e.subscribe,e.snapshot);return t===void 0?null:Be(BTo,{toast:t,pending:n,attentionOverflow:r,store:e},t.id)}function BTo({toast:e,pending:t,attentionOverflow:n,store:r}){let i=tE(),{width:o}=Kf(),[s,a]=ii(!1),c=(l)=>{if(a(l),l)r.pause();else r.resume()},u=Vn("box",{flexDirection:"row",flexShrink:0,children:[e.action===void 0?null:Be("text",{marginLeft:2,wrapMode:"none",children:e.actionPending?"Working\u2026":`\u203A ${e.action.label}`}),e.actionPending?null:Be("text",{flexShrink:0,marginLeft:2,wrapMode:"none",attributes:s?M$e.BOLD:M$e.DIM,onMouseUp:(l)=>{l.stopPropagation(),r.dismiss()},children:"x"})]});return Vn("box",{position:"absolute",top:1,right:2,zIndex:300,maxWidth:Math.max(20,Math.min(zTo,o-6)),border:["left"],borderColor:t_r[e.variant],backgroundColor:$To,paddingLeft:1,paddingRight:1,onMouseOver:()=>{c(!0)},onMouseOut:()=>{c(!1)},onMouseUp:()=>{if(i.getSelection()?.getSelectedText())return;r.activate()},children:[e.title===void 0?Vn("box",{flexDirection:"row",width:"100%",children:[Be("text",{flexGrow:1,wrapMode:"word",children:e.message}),u]}):Vn(XT,{children:[Vn("box",{flexDirection:"row",width:"100%",children:[Be("text",{attributes:M$e.BOLD,children:e.title}),Be("box",{flexGrow:1}),u]}),Be("text",{width:"100%",flexShrink:0,wrapMode:"word",children:e.message})]}),t===0?null:Vn("text",{attributes:M$e.DIM,children:["+",t," more"]}),n===void 0?null:Vn("text",{fg:t_r.warning,children:[n," additional attention reports not listed individually"]})]})}var PDt,t_r,$To,zTo=60;var N$e=A(async()=>{bu();Xi();ODt();ODt();await qg();PDt=ud(void 0),t_r={info:fye.fromIndex(4),success:fye.fromIndex(2),warning:fye.fromIndex(3),error:fye.fromIndex(1)},$To=fye.defaultBackground()});function r_r(){return Xd(n_r)}function hye({children:e}){return Be("box",{position:"relative",flexDirection:"column",width:"100%",height:"100%",children:Be(mye,{children:Be(qTo,{children:e})})})}function qTo({children:e}){let t=tE(),n=gC(),r=Ns(()=>Xgr(t),[t]);Qn(()=>()=>{r.dispose()},[r]);let i=(s)=>{if(s.length===0)return;let a=()=>{n.show({variant:"warning",message:"Clipboard unavailable \xB7 enable OSC 52"})};r.copy(s).then((c)=>{if(c==="sent")n.show({variant:"info",message:"Copy request sent to terminal"});else if(c==="failed")a()},a)},o=()=>{let s=t.getSelection()?.getSelectedText();if(!s)return;queueMicrotask(()=>{if(!t.isDestroyed)t.clearSelection()}),i(s)};return ste((s)=>{if((s.meta||s.option)&&s.name==="c"){let a=t.getSelection()?.getSelectedText();if(a)s.preventDefault(),i(a)}}),ql(n_r.Provider,{value:i},Be("box",{flexDirection:"column",width:"100%",height:"100%",onMouseUp:o,children:e}))}var n_r;var L$e=A(async()=>{bu();Xi();Ygr();await du([qg(),N$e()]);n_r=ud(void 0)});function MDt(e){return{title:e.message,summary:e.summary,facts:e.facts,body:e.body,bodyLabel:e.bodyLabel,details:e.details}}function WTo({host:e,pending:t,colors:n,width:r,compact:i,detailsKey:o,hints:s,draft:a,onKey:c,textMaxLength:u}){if(t.request.type!=="text")return null;return Vn("box",{flexDirection:"column",rowGap:i?0:1,children:[Be(F1,{content:MDt(t.request),width:r,compact:i,detailsKey:o,colors:n}),Be(P$e,{placeholder:t.request.placeholder,secret:t.request.secret===!0,maxLength:u??GQ,initialValue:a.current,onInput:(l)=>{a.current=l},onSubmit:(l)=>{e.answer(t.sequence,l)},onKeyDown:c,colors:n}),Be(fC,{hints:s,width:r,colors:n})]})}function HTo({host:e,pending:t,colors:n,width:r,compact:i,rows:o,extraHints:s,onClose:a,onKey:c,customHints:u,hideChoiceTitle:l,initialIndex:d,onHighlight:p,textMaxLength:f}){let m=t.request,[h,g]=ii(!1),_=Pr(void 0),y=Pr(""),x=o<10?{...MDt(m),summary:void 0}:MDt(m),b=m.type==="choice"&&m.options.length>6,S=m.type==="text"||b,T=S?"Alt+D":"d",I=(m.details?.length??0)>0||Qgr(m.body,r),R=()=>{e.cancel(),a()},F=u??[{keys:"\u2191\u2193",label:"choose",priority:1},{keys:"Enter",label:"select",priority:0},...I?[{keys:T,label:"details",priority:2}]:[],...s,{keys:"Esc",label:"close",priority:2}],z=(ee)=>I&&ee.name==="d"&&!ee.ctrl&&(S?ee.meta||ee.option:!ee.meta&&!ee.option),j=(ee)=>{if(z(ee))return g(!0),!0;return c(ee)};if(h)return Vn("box",{flexDirection:"column",rowGap:i?0:1,focusable:!0,focused:!0,onKeyDown:(ee)=>{if(ee.name==="d"||ee.name==="escape")ee.preventDefault(),g(!1);else if(ee.ctrl&&ee.name==="c")ee.preventDefault(),R()},children:[Be(TW,{content:x,width:r,maxRows:o-8,colors:n}),Be(fC,{hints:[{keys:"d",label:"back",priority:0},{keys:"Esc",label:"back",priority:1}],width:r,colors:n})]});if(m.type==="text")return Be(WTo,{host:e,pending:t,colors:n,width:r,compact:i,detailsKey:T,draft:y,textMaxLength:f,hints:u??[{keys:"Enter",label:"submit",priority:0},...I?[{keys:T,label:"details",priority:2}]:[],...s,{keys:"Esc",label:"close",priority:1}],onKey:(ee)=>{if(j(ee)){ee.preventDefault();return}if(ee.name==="escape"||ee.ctrl&&ee.name==="c")ee.preventDefault(),R()}});if(m.type==="decision")return null;let K=m.type==="choice"?m.options.map((ee)=>({name:ee.label,description:ee.description,group:ee.group,tone:ee.destructive===!0?"destructive":void 0})):m.destructive===!0?[{name:m.cancelLabel??"Cancel"},{name:m.confirmLabel??"Confirm",tone:"destructive"}]:[{name:m.confirmLabel??"Confirm"},{name:m.cancelLabel??"Cancel"}],te=m.type==="choice"&&m.current!==void 0?m.options.findIndex((ee)=>ee.value===m.current):-1;return Vn("box",{flexDirection:"column",rowGap:i?0:1,children:[l?null:Be(F1,{content:x,width:r,compact:i,detailsKey:T,colors:n}),Be(Cm,{searchable:b,onKey:j,hints:F,collapsedGroups:m.type==="choice"&&m.collapsedGroup!==void 0?[m.collapsedGroup]:[],colors:n,choices:K,currentIndex:te>=0?te:void 0,initialIndex:_.current??d,onHighlight:(ee)=>{_.current=ee,p?.(ee)},onSelect:(ee)=>{if(m.type==="choice"){let ge=m.options[ee];if(ge!==void 0)e.answer(t.sequence,ge.value)}else e.answer(t.sequence,m.destructive===!0?ee===1:ee===0)},onCancel:R})]})}function NDt({host:e,colors:t,onClose:n,onKey:r,hints:i,hideChoiceTitle:o,hideProgressWhilePrompt:s,initialIndex:a,onHighlight:c,textMaxLength:u}){let l=Ka(e.subscribe,e.snapshot),d=r_r(),p=Kf(),f=p.height<14,m=aS(p.width),h=l.status==="done"||l.status==="cancelled",g=l.status==="failed",_=l.handoff?.url??l.links[0]?.url,y=(z)=>{let j=l.prompt?.request.type==="text";if(_!==void 0&&d!==void 0&&(z.name==="c"&&!j||(z.meta||z.option)&&z.name==="c"))return d(_),!0;if(l.handoff?.code!==void 0&&d!==void 0&&z.name==="x"&&!j)return d(l.handoff.code),!0;return!1},x=(z)=>{if(y(z))z.preventDefault();else if(z.name==="escape"||z.ctrl&&z.name==="c")z.preventDefault(),e.cancel(),n();else if(h&&(z.name==="return"||z.name==="enter"))z.preventDefault(),n()},b=l.prompt===void 0&&!g,S=l.handoff,T=g||s&&l.prompt!==void 0&&l.message?.type==="progress"?void 0:l.message,I=T?.type==="success"?t.success:T?.type==="progress"?t.warning:t.info,R=[..._===void 0?[]:[{keys:l.prompt?.request.type==="text"?"Alt+C":"c",label:"copy link",priority:2}],...l.handoff?.code===void 0?[]:[{keys:"x",label:"copy code",priority:2}]],F=g?[]:h?[{keys:"Enter",label:"close",priority:0}]:l.prompt===void 0?[...R,{keys:"Esc",label:"cancel",priority:0}]:[];return Vn("box",{flexDirection:"column",rowGap:f?0:1,focusable:b,focused:b,onKeyDown:(z)=>{if(b)x(z)},children:[l.prompt!==void 0?null:Be("text",{fg:t.foreground,attributes:1,children:yr(l.title)}),S===void 0?null:Vn("box",{flexDirection:"column",children:[Be("text",{fg:t.foreground,children:yr(S.message??(S.code===void 0?"Continue in your browser:":"Open this page and enter the code:"))}),Be("text",{fg:t.info,wrapMode:"char",onMouseDown:()=>d?.(S.url),children:yr(S.url)}),S.code===void 0?null:Be("box",{flexDirection:"column",children:Be("text",{fg:t.accent,attributes:1,children:yr(S.code)})})]}),T===void 0?null:Vn("box",{flexDirection:"column",children:[Vn("text",{fg:t.foreground,children:[Be("span",{fg:I,children:"\u25CF "}),yr(T.message)]}),l.links.map((z)=>Vn("box",{flexDirection:"column",children:[z.label===void 0?null:Vn("text",{fg:t.info,children:[yr(z.label),":"]}),Be("text",{fg:t.info,wrapMode:"char",onMouseDown:()=>d?.(z.url),children:yr(z.url)})]},z.url))]}),l.prompt===void 0?null:Be(HTo,{host:e,pending:l.prompt,colors:t,width:m,compact:f,rows:p.height,extraHints:R,onClose:n,onKey:(z)=>y(z)||(r?.(z)??!1),customHints:i,hideChoiceTitle:o,initialIndex:a,onHighlight:c,textMaxLength:u},l.prompt.sequence),g?Vn("box",{flexDirection:"column",rowGap:f?0:1,children:[Vn("text",{fg:t.error,children:["\u25CF ",yr(l.failure??"")]}),Be(Cm,{colors:t,choices:[...l.retryable?[{name:"Try again"}]:[],{name:"Close"}],onSelect:(z)=>{if(l.retryable&&z===0)e.retry();else e.cancel(),n()},onCancel:()=>{e.cancel(),n()}})]}):null,l.prompt!==void 0?null:Be(fC,{hints:i??F,width:m,colors:t})]})}function LDt(e){let t=Pr(e);t.current=e;let n=e.slash.interactions.open,{store:r}=e.slash;Qn(()=>{if(n===void 0||e.enabled===!1)return;let i=!0,o=t.current.dialog.show(()=>Be(NDt,{host:n.host,colors:t.current.colors,onClose:()=>{t.current.inputHandoff?.capture(),r.close(),o.dismiss()}}),{onDismiss:()=>{if(i)t.current.inputHandoff?.capture(),r.close()}});return()=>{i=!1,o.dismiss()}},[n,r,e.enabled])}var FDt=A(async()=>{bu();k1();Xi();mX();RDt();nye();await du([qg(),AW(),jP(),L$e()])});function GTo({status:e,rules:t,source:n,signal:r,refresh:i,colors:o,onClose:s}){let{width:a,height:c}=Kf(),u=dte.findIndex((h)=>h.mode===e.mode),l=c<20,[d,p]=ii(),f=Pr(void 0);Qn(()=>()=>f.current?.cancel(),[]);let m=async(h)=>{if(f.current!==void 0)return;let g=s7({title:"Permissions"});f.current=g;let _=g.begin(),y=AbortSignal.any([r,_.interaction.signal]),x=()=>{g.cancel()};if(r.addEventListener("abort",x,{once:!0}),r.aborted)x();p(g);try{let b=h.kind==="remove-rule"?{type:"confirmation",message:"Remove Always-allow rule?",summary:Wc(`\u201C${h.prefix.join(" ")}\u201D`,aS(a)),body:"Remove this saved approval for every Workspace Agent in this project. Another rule may still cover the command.",confirmLabel:"Remove rule",cancelLabel:"Keep rule",destructive:!0}:h.mode==="full-access"?{type:"confirmation",message:"Switch to Full access?",summary:"Outside the sandbox, as you",body:"Commands can use your files, network and credentials, without permission questions.",confirmLabel:"Use Full access",cancelLabel:`Keep ${dte[u]?.name??e.mode}`,destructive:!0}:void 0;if(b!==void 0){if(!await _.interaction.prompt(b)){_.settle({status:"cancelled"}),p(void 0);return}}_.interaction.notify({type:"progress",message:h.kind==="mode"?"Saving Agent mode\u2026":"Removing project rule\u2026"}),await _.interaction.run(async()=>{try{if(h.kind==="mode")await n.setMode(h.mode,y);else await n.rules.remove(h.prefix,y)}finally{await i()}}),_.settle({status:"handled"}),s()}catch(b){if(y.aborted)_.settle({status:"cancelled"});else Oi("local-permissions",b),_.settle({status:"failed",message:b instanceof Error?b.message:"Unable to save permissions"})}finally{r.removeEventListener("abort",x),f.current=void 0}};if(d!==void 0)return Be(NDt,{host:d,colors:o,onClose:s});return Vn("box",{flexDirection:"column",rowGap:l?0:1,children:[Be(F1,{content:{title:"Permissions",summary:`Current mode: ${dte[u]?.name??e.mode}`,facts:[{label:"Rules",value:"Shared by Workspace Agents in this project."}]},width:aS(a),compact:l,colors:o}),Be(Cm,{choices:[...dte.map((h)=>({name:h.name,description:h.description,group:"Agent mode",tone:h.mode==="full-access"?"destructive":void 0})),...t.map((h)=>({name:`Remove \u201C${h.join(" ")}\u201D\u2026`,group:"Always-allow rules",description:"Remove this project's saved approval.",tone:"destructive"}))],currentIndex:u,searchable:t.length>3,rowLimit:Math.max(1,c-(l?8:12)),colors:o,onCancel:s,onSelect:(h)=>{if(h===u)s();else{let g=dte[h]?.mode;if(g!==void 0)m({kind:"mode",mode:g});else{let _=t[h-dte.length];if(_!==void 0)m({kind:"remove-rule",prefix:_})}}}}),t.length===0?Be("text",{fg:o.foreground,attributes:2,children:"No Always-allow rules in this project."}):null]})}function $Dt({source:e,commands:t,dialog:n,colors:r}){let i=xO(),o=kw({queryKey:i_r(e?.identity),enabled:e!==void 0,staleTime:0,queryFn:({signal:c})=>{if(e===void 0)throw Error("Local permissions unavailable");return e.read(c)}});Qn(()=>{if(o.error!==null)Oi("local-sandbox-status",o.error)},[o.error]);let s=Pr(r);s.current=r;let a=n.show;return Qn(()=>{if(e===void 0)return;let c=new AbortController,u,l=t.contribute({sourceId:"tui-frame",namespace:"tui",commands:[{id:"permissions",title:"Permissions",category:"Settings",description:"Choose Agent mode and remove project Always-allow rules",projections:{palette:{},help:{},slash:{aliases:["permissions"],consumesDraft:!0}},handler:async({interaction:d})=>{if(d===void 0)throw Error("Managing permissions needs a person.");let[p,f]=await Promise.all([e.read(c.signal),e.rules.list(c.signal)]);c.signal.throwIfAborted(),u=a((m)=>Be(GTo,{status:p,rules:f,source:e,signal:c.signal,refresh:async()=>{let h={queryKey:i_r(e.identity),exact:!0};await i.cancelQueries(h),await i.invalidateQueries(h)},colors:s.current,onClose:m.dismiss}))}}]});return()=>{c.abort(),u?.dismiss(),l.dispose()}},[t,a,e,i]),{status:o.data,refresh:o.refetch}}var i_r=(e)=>["tui-sandbox-status",e],dte;var o_r=A(async()=>{bu();Xi();wO();mX();oF();P1();await du([qg(),AW(),jP(),FDt()]);dte=[{mode:"read-only",name:"Read-only",description:"Read files; no edits or command network."},{mode:"workspace",name:"Workspace",description:"Work in the Agent's folder, inside the sandbox."},{mode:"full-access",name:"Full access",description:"Outside the sandbox, as you."}]});import{RGBA as KTo}from"@opentui/core";function BP(){let e=Xd(lF);if(e===void 0)throw Error("Dialog content requires host colors");return e}function pte({children:e,colors:t,onClose:n}){let{height:r}=Kf();return Be(lF.Provider,{value:t,children:Be("box",{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:100,padding:1,alignItems:"center",justifyContent:"center",backgroundColor:KTo.fromInts(0,0,0,140),onMouseDown:(i)=>{i.preventDefault(),n()},children:Be("box",{width:"100%",maxWidth:68,maxHeight:"100%",backgroundColor:t.background,onMouseDown:(i)=>{i.stopPropagation()},children:Be("box",{backgroundColor:t.background,paddingX:r<14?1:2,paddingY:r<14?0:1,children:e})})})})}var lF;var dF=A(async()=>{bu();Xi();await qg();lF=ud(void 0)});function F$e(e){let[t,n]=ii(),r=Pr(void 0),i=Pr(0),o=Pr(!1);Qn(()=>(o.current=!0,n(r.current),()=>{o.current=!1;let u=r.current;r.current=void 0,u?.onDismiss?.()}),[e]);let s=el(()=>{let u=r.current;if(u===void 0)return!1;return r.current=void 0,n(void 0),u.onDismiss?.(),!0},[]),a=el(()=>{let u=r.current;if(u===void 0)return!1;if(u.beforeDismiss?.()!==!1)s();return!0},[s]);return{show:el((u,l)=>{let d={isCurrent:()=>o.current&&r.current?.handle===d,dismiss:()=>{if(d.isCurrent())s()}};if(!o.current)return d;let p=r.current;if(p?.beforeDismiss?.()===!1)throw Error("The current dialog is still saving or closing.");let f={key:++i.current,render:u,handle:d,onDismiss:l?.onDismiss,beforeDismiss:l?.beforeDismiss};return r.current=f,n(f),p?.onDismiss?.(),d},[s]),dismiss:a,isOpen:t!==void 0,entry:t}}function gye({dialog:e,colors:t}){let n=e.entry;if(n===void 0)return null;return Be(pte,{colors:t,onClose:e.dismiss,children:Be(VTo,{entry:n},n.key)})}function VTo({entry:e}){return Be(XT,{children:e.render(e.handle)})}var zDt=A(async()=>{bu();Xi();await dF()});var s_r=()=>{};function UDt({session:e,enabled:t}){let n=Ame(),{observation:r}=NI(),i=gC(),o=n[qI.id],s=Ns(()=>{if(o?.status!=="running")return{pending:void 0,invalid:!1};try{return{pending:JTo(o.value).pending[0],invalid:!1}}catch{return{pending:void 0,invalid:!0}}},[o]),a=t&&r.status==="live",c=s.pending,u=JSON.stringify([c?.id,c?.approval.record.recordId,c?.approval.record.revision,c?.approval.canAnswer,c?.approval.canSetAutoApprove]),l=Pr({session:e,pending:c,available:a,presentationKey:u});l.current={session:e,pending:c,available:a,presentationKey:u};let d=Ns(()=>{let p=l.current.pending;if(!a||p===void 0)return;let f=p.approval,m=()=>{let g=l.current;return g.available&&g.session===e&&g.presentationKey===u?f:void 0},h={snapshot:m,subscribe:XTo,answer:async(g)=>{if(!m()?.canAnswer||g.recordId!==f.record.recordId||g.expectedRevision!==f.record.revision)return{kind:"refused",reason:"not-pending"};let _={id:p.id,decision:g.decision,expectedRevision:g.expectedRevision},y=QTo(await e.extension(qI.id).call("answer",g.denialNote===void 0?_:{..._,denialNote:g.denialNote}));if(y.kind==="submitted")throw Error("The host has not confirmed the approval decision.");return y}};return p.review===void 0?h:{...h,review:p.review}},[e,a,u]);return Qn(()=>{if(a&&s.invalid)i.show({variant:"error",message:"Invalid MCP form approval projection."})},[a,s.invalid,i]),d}var JTo,QTo,XTo=()=>()=>{return};var a_r=A(async()=>{Xi();Tm();cr();await du([sC(),N$e()]);JTo=tn(qI.projection.schema),QTo=tn(qI.commands.answer.output)});function YTo(e){if(e.kind==="commands")return e.items.map((t)=>{let n=t.command.keys.join(", ");return{key:t.command.commandId+t.label,label:yr(t.label),detail:[t.command.description??t.command.title,n].filter((r)=>r.length>0).join(" \xB7 ")}});if(e.kind==="arguments")return e.items.map((t)=>({key:t.label,label:yr(t.label),detail:yr(t.word.description??"")}));return[]}function jDt({slash:e,colors:t,maxRows:n,width:r}){let{completion:i,selected:o}=e;return Be(zgr,{rows:YTo(i),selected:o,onChoose:(s)=>{e.choose(s)},header:i.kind==="arguments"?i.hint:i.kind==="commands"&&i.items.length>n?"More\u2026 \xB7 \u2191\u2193 to browse all commands":void 0,maxRows:n,width:r,colors:t})}var c_r=A(async()=>{bu();k1();await jP()});function BDt(e,t){return b4({queryKey:["tui-tool-code",e,t],queryFn:()=>Lhr(e,t),staleTime:Number.POSITIVE_INFINITY,gcTime:0})}var u_r=A(()=>{wO();l$e()});import{StyledText as ZTo,TextAttributes as CW,TextTableRenderable as eAo}from"@opentui/core";function _ye(e,t,n={}){let{colors:r,surface:i}=t;return e.flatMap((o)=>{let s=(a)=>[{...n,__isChunk:!0,text:yr(a)}];switch(o.type){case"text":case"inlineHtml":return s(o.value);case"inlineCode":return[{...n,__isChunk:!0,text:yr(o.value),fg:r.accent,bg:i}];case"break":return s(`
|
|
2103
|
+
`).flatMap((r)=>{let i=RTo(r,n);return i.length===0?[""]:i})}function ADt(e,t,n,r="\u2026"){if(e.length<=t)return e;let i=e.slice(0,t),o=i[t-1]??"";return i[t-1]=`${Jgr(o,Math.max(0,n-kW(r))).trimEnd()}${r}`,i}function Qgr(e,t){return e!==void 0&&pye(e,t).length>Vgr}function F1({content:e,width:t,compact:n,detailsKey:r="d",marker:i,full:o=!1,colors:s}){let a=yr(e.title).replace(/\s+/gu," ").trim(),c=[...(e.facts??[]).map((h)=>h.label),...e.body!==void 0&&e.bodyLabel!==void 0?[e.bodyLabel]:[]],u=c.length===0?0:Math.max(...c.map((h)=>kW(h)))+2,l=Math.max(1,t-u),d=e.summary===void 0?[]:ADt(pye(e.summary,t),o?1/0:n?1:2,t),p=e.bodyLabel===void 0?t:l,f=e.body===void 0?void 0:ADt(pye(e.body,p),o?1/0:Vgr,p,`\u2026 ${r} shows all`),m=(e.facts?.length??0)>0;return Vn("box",{flexDirection:"column",rowGap:n?0:1,flexShrink:0,children:[Vn("box",{flexDirection:"column",children:[i===void 0?Be("text",{fg:s.foreground,attributes:1,wrapMode:"none",children:Wc(a,t)}):Vn("box",{flexDirection:"row",justifyContent:"space-between",children:[Be("text",{fg:s.foreground,attributes:1,wrapMode:"none",children:Wc(a,Math.max(1,t-kW(i)-2))}),Be("text",{fg:s.foreground,attributes:2,wrapMode:"none",children:i})]}),d.map((h,g)=>Be("text",{fg:s.foreground,attributes:2,wrapMode:"none",children:h},`summary-${String(g)}`))]}),m||f!==void 0?Vn("box",{flexDirection:"column",children:[(e.facts??[]).map((h)=>Be(IDt,{label:h.label,lines:ADt(pye(h.value,l),CTo,l),labelWidth:u,colors:s},h.label)),f===void 0?null:Be(IDt,{label:e.bodyLabel??"",lines:f,labelWidth:e.bodyLabel===void 0?0:u,colors:s})]}):null]})}function CDt({content:e,colors:t,children:n}){let r=Kf(),i=r.height<14;return Vn("box",{flexDirection:"column",rowGap:i?0:1,children:[Be(F1,{content:e,width:aS(r.width),compact:i,colors:t}),n]})}function IDt({label:e,lines:t,labelWidth:n,colors:r}){return Vn("box",{flexDirection:"row",children:[n===0?null:Be("text",{width:n,flexShrink:0,fg:r.foreground,attributes:2,wrapMode:"none",children:yr(e)}),Be("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:t.map((i,o)=>Be("text",{fg:r.foreground,wrapMode:"none",children:i},o))})]})}function TW({content:e,width:t,maxRows:n,colors:r,onKeyDown:i}){let o=e.details??[],s=(l)=>o.some((d)=>d.label===l.label),a=[...(e.body===void 0?[]:[{label:e.bodyLabel??"Text",value:e.body}]).filter((l)=>!s(l)),...(e.facts??[]).filter((l)=>!s(l)),...o],c=Math.max(0,...a.map((l)=>kW(l.label)))+2,u=Math.max(1,t-c);return Vn("box",{flexDirection:"column",rowGap:1,children:[Be("text",{fg:r.foreground,attributes:1,children:"Details"}),Be("scrollbox",{focused:!0,...i===void 0?{}:{onKeyDown:i},scrollbarOptions:{visible:!1},scrollX:!1,maxHeight:Math.max(1,n),children:a.map((l,d)=>Be(IDt,{label:l.label,lines:pye(l.value,u),labelWidth:c,colors:r},`${l.label}-${String(d)}`))})]})}var ITo,aS=(e)=>Math.max(1,Math.min(68,e-2)-4),CTo=2,Vgr=3;var AW=A(async()=>{bu();oF();k1();await qg();ITo=new Intl.Segmenter(void 0,{granularity:"grapheme"})});function P$e({placeholder:e,secret:t=!1,maxLength:n,initialValue:r="",value:i,focused:o=!0,onInput:s,onSubmit:a,onKeyDown:c,colors:u}){let l=Pr(null),[d,p]=ii((i??r).length);return Qn(()=>{let f=l.current;if(i===void 0||f===null||f.value===i)return;f.value=i,p(i.length)},[i]),Vn("box",{flexDirection:"row",backgroundColor:u.selection,paddingX:1,children:[t?Be("text",{fg:u.selectionForeground,children:d===0?" ":`${"\u2022".repeat(Math.min(d,32))} ${String(d)} characters`}):null,Be("box",{flexGrow:1,visible:!t,children:Be("input",{ref:l,width:"100%",maxLength:n,value:i??r,placeholder:yr(e??""),showCursor:!t,selectable:!t,focused:o,onInput:(f)=>{p(f.length),s?.(f)},onSubmit:()=>{a(l.current?.value??"")},onKeyDown:(f)=>{c?.(f)},backgroundColor:u.selection,focusedBackgroundColor:u.selection,textColor:u.selectionForeground,focusedTextColor:u.selectionForeground,cursorColor:u.accent})})]})}var RDt=A(()=>{bu();Xi();k1()});import{createClipboard as DTo,createHostClipboard as OTo,createRendererClipboardAdapter as PTo}from"@opentui/core";function MTo(e){return`\x1BPtmux;\x1B${`\x1B]52;c;${Buffer.from(e).toString("base64")}\x07`}\x1B\\`}async function NTo(e,t,n,r){t=t.replace(/\u{10eeee}\u0305[\u0305\u030d]/gu,"");let i=await e.writeText(t,{destination:"all-available"}),o=n!==void 0&&n.length>0;if(o)r(MTo(t));if(i.host.status==="written")return"copied";return o||i.terminal.status==="attempted"?"sent":"failed"}function Xgr(e,t={}){let n=t.service??DTo({host:OTo(),terminal:PTo(e)}),r=t.tmux??process.env.TMUX,i=t.writeTerminal??((o)=>process.stdout.write(o));return{async copy(o){return NTo(n,o,r,i)},dispose:()=>n.dispose()}}var Ygr=()=>{};function IW(e){return Array.from(yr(e)).slice(0,FTo).join("")}function e_r(){let e,t=[],n={current:void 0,pending:0},r,i=0,o=0,s=!1,a=!1,c,u=new Set,l=()=>{n=c===void 0?{current:e,pending:t.length}:{current:e,pending:t.length+1,attentionOverflow:c.reports};for(let h of u)h()},d=()=>{clearTimeout(r),r=void 0},p=(h)=>{d(),o=h,i=Date.now(),r=setTimeout(m,h)},f=(h)=>{if(e=h,h.duration!=="until-dismissed")p(h.duration)};function m(){if(a||e?.actionPending)return;if(d(),e=void 0,s=!1,c!==void 0)f({id:Zgr.toast.generate(),title:"Attention capacity reached",variant:"warning",duration:"until-dismissed",message:IW(`At least ${String(c.reports)} additional attention reports could not be listed individually. Latest: ${c.latest}`)}),c=void 0;else{let[h,...g]=t;if(t=g,h!==void 0)f(h)}l()}return{snapshot:()=>n,subscribe:(h)=>{if(a)return()=>{return};return u.add(h),()=>{u.delete(h)}},show:(h)=>{if(a)return;let g={id:Zgr.toast.generate(),variant:h.variant,message:IW(h.message),title:h.title===void 0?void 0:IW(h.title),duration:h.duration??DDt,action:h.action===void 0?void 0:{...h.action,label:IW(h.action.label)},key:h.key===void 0?void 0:IW(h.key)};if(g.duration==="until-dismissed"&&g.key!==void 0){if(e?.key===g.key){if(!e.actionPending)e={...g,id:e.id},l();return}let _=t.findIndex((x)=>x.key===g.key),y=t[_];if(y!==void 0){t=t.map((x,b)=>b===_?{...g,id:y.id}:x),l();return}}if(e===void 0)f(g);else{if(t.length===LTo){let _=t.findIndex((y)=>y.duration!=="until-dismissed");if(_!==-1)t=t.filter((y,x)=>x!==_);else if(g.duration!=="until-dismissed")return;else{c={reports:Math.min(Number.MAX_SAFE_INTEGER,(c?.reports??0)+1),latest:g.message},l();return}}t=[...t,g]}l()},dismiss:m,activate:()=>{if(a||e?.actionPending)return;let h=e,g=h?.action;if(g===void 0){m();return}if(h===void 0)return;d(),e={...h,actionPending:!0},l();let _=()=>{if(a||e?.id!==h.id)return;e={...e,actionPending:!1},m()},y=(x)=>{if(a||e?.id!==h.id)return;e={...e,variant:"warning",title:IW(`${g.label} failed`),message:IW(x instanceof Error?x.message:"The action did not complete."),duration:"until-dismissed",action:void 0,actionPending:!1},l()};try{let x=g.run();if(x===void 0)_();else Promise.resolve(x).then(_,y)}catch(x){y(x)}},pause:()=>{if(a||e?.actionPending)return;if(e===void 0||s)return;if(s=!0,r===void 0)return;o=Math.max(0,o-(Date.now()-i)),d()},resume:()=>{if(a||e?.actionPending)return;if(e===void 0||!s)return;if(s=!1,e.duration!=="until-dismissed")p(o)},dispose:()=>{if(a)return;a=!0,d(),u.clear(),e=void 0,t=[],c=void 0,n={current:void 0,pending:0}}}}var Zgr,DDt=4000,LTo=20,FTo=512;var ODt=A(()=>{DR();k1();Zgr=mc({family:"tui-toast",version:1,kinds:{toast:{prefix:"toast"}}})});import{RGBA as fye,TextAttributes as M$e}from"@opentui/core";function gC(){let e=Xd(PDt);if(e===void 0)throw Error("Toasts need a ToastProvider above this view");return Ns(()=>({show:e.show,dismiss:e.dismiss}),[e])}function mye({children:e}){return Xd(PDt)===void 0?Be(UTo,{children:e}):e}function UTo({children:e}){let t=tE(),[n]=ii(e_r);return Qn(()=>()=>{n.dispose()},[n]),Qn(()=>{let r=(i)=>{if(i.name!=="escape"||n.snapshot().current===void 0)return;i.preventDefault(),i.stopPropagation(),n.dismiss()};return t.keyInput.prependListener("keypress",r),()=>{t.keyInput.off("keypress",r)}},[t,n]),Vn(PDt.Provider,{value:n,children:[e,Be(jTo,{store:n})]})}function jTo({store:e}){let{current:t,pending:n,attentionOverflow:r}=Ka(e.subscribe,e.snapshot);return t===void 0?null:Be(BTo,{toast:t,pending:n,attentionOverflow:r,store:e},t.id)}function BTo({toast:e,pending:t,attentionOverflow:n,store:r}){let i=tE(),{width:o}=Kf(),[s,a]=ii(!1),c=(l)=>{if(a(l),l)r.pause();else r.resume()},u=Vn("box",{flexDirection:"row",flexShrink:0,children:[e.action===void 0?null:Be("text",{marginLeft:2,wrapMode:"none",children:e.actionPending?"Working\u2026":`\u203A ${e.action.label}`}),e.actionPending?null:Be("text",{flexShrink:0,marginLeft:2,wrapMode:"none",attributes:s?M$e.BOLD:M$e.DIM,onMouseUp:(l)=>{l.stopPropagation(),r.dismiss()},children:"x"})]});return Vn("box",{position:"absolute",top:1,right:2,zIndex:300,maxWidth:Math.max(20,Math.min(zTo,o-6)),border:["left"],borderColor:t_r[e.variant],backgroundColor:$To,paddingLeft:1,paddingRight:1,onMouseOver:()=>{c(!0)},onMouseOut:()=>{c(!1)},onMouseUp:()=>{if(i.getSelection()?.getSelectedText())return;r.activate()},children:[e.title===void 0?Vn("box",{flexDirection:"row",width:"100%",children:[Be("text",{flexGrow:1,wrapMode:"word",children:e.message}),u]}):Vn(XT,{children:[Vn("box",{flexDirection:"row",width:"100%",children:[Be("text",{attributes:M$e.BOLD,children:e.title}),Be("box",{flexGrow:1}),u]}),Be("text",{width:"100%",flexShrink:0,wrapMode:"word",children:e.message})]}),t===0?null:Vn("text",{attributes:M$e.DIM,children:["+",t," more"]}),n===void 0?null:Vn("text",{fg:t_r.warning,children:[n," additional attention reports not listed individually"]})]})}var PDt,t_r,$To,zTo=60;var N$e=A(async()=>{bu();Xi();ODt();ODt();await qg();PDt=ud(void 0),t_r={info:fye.fromIndex(4),success:fye.fromIndex(2),warning:fye.fromIndex(3),error:fye.fromIndex(1)},$To=fye.defaultBackground()});function r_r(){return Xd(n_r)}function hye({children:e}){return Be("box",{position:"relative",flexDirection:"column",width:"100%",height:"100%",children:Be(mye,{children:Be(qTo,{children:e})})})}function qTo({children:e}){let t=tE(),n=gC(),r=Ns(()=>Xgr(t),[t]);Qn(()=>()=>{r.dispose()},[r]);let i=(s)=>{if(s.length===0)return;let a=()=>{n.show({variant:"warning",message:"Clipboard unavailable \xB7 enable OSC 52"})};r.copy(s).then((c)=>{if(c==="sent")n.show({variant:"info",message:"Copy request sent to terminal"});else if(c==="failed")a()},a)},o=()=>{let s=t.getSelection()?.getSelectedText();if(!s)return;queueMicrotask(()=>{if(!t.isDestroyed)t.clearSelection()}),i(s)};return ste((s)=>{if((s.meta||s.option)&&s.name==="c"){let a=t.getSelection()?.getSelectedText();if(a)s.preventDefault(),i(a)}}),ql(n_r.Provider,{value:i},Be("box",{flexDirection:"column",width:"100%",height:"100%",onMouseUp:o,children:e}))}var n_r;var L$e=A(async()=>{bu();Xi();Ygr();await du([qg(),N$e()]);n_r=ud(void 0)});function MDt(e){return{title:e.message,summary:e.summary,facts:e.facts,body:e.body,bodyLabel:e.bodyLabel,details:e.details}}function WTo({host:e,pending:t,colors:n,width:r,compact:i,detailsKey:o,hints:s,draft:a,onKey:c,textMaxLength:u}){if(t.request.type!=="text")return null;return Vn("box",{flexDirection:"column",rowGap:i?0:1,children:[Be(F1,{content:MDt(t.request),width:r,compact:i,detailsKey:o,colors:n}),Be(P$e,{placeholder:t.request.placeholder,secret:t.request.secret===!0,maxLength:u??GQ,initialValue:a.current,onInput:(l)=>{a.current=l},onSubmit:(l)=>{e.answer(t.sequence,l)},onKeyDown:c,colors:n}),Be(fC,{hints:s,width:r,colors:n})]})}function HTo({host:e,pending:t,colors:n,width:r,compact:i,rows:o,extraHints:s,onClose:a,onKey:c,customHints:u,hideChoiceTitle:l,initialIndex:d,onHighlight:p,textMaxLength:f}){let m=t.request,[h,g]=ii(!1),_=Pr(void 0),y=Pr(""),x=o<10?{...MDt(m),summary:void 0}:MDt(m),b=m.type==="choice"&&m.options.length>6,S=m.type==="text"||b,T=S?"Alt+D":"d",I=(m.details?.length??0)>0||Qgr(m.body,r),R=()=>{e.cancel(),a()},F=u??[{keys:"\u2191\u2193",label:"choose",priority:1},{keys:"Enter",label:"select",priority:0},...I?[{keys:T,label:"details",priority:2}]:[],...s,{keys:"Esc",label:"close",priority:2}],z=(ee)=>I&&ee.name==="d"&&!ee.ctrl&&(S?ee.meta||ee.option:!ee.meta&&!ee.option),j=(ee)=>{if(z(ee))return g(!0),!0;return c(ee)};if(h)return Vn("box",{flexDirection:"column",rowGap:i?0:1,focusable:!0,focused:!0,onKeyDown:(ee)=>{if(ee.name==="d"||ee.name==="escape")ee.preventDefault(),g(!1);else if(ee.ctrl&&ee.name==="c")ee.preventDefault(),R()},children:[Be(TW,{content:x,width:r,maxRows:o-8,colors:n}),Be(fC,{hints:[{keys:"d",label:"back",priority:0},{keys:"Esc",label:"back",priority:1}],width:r,colors:n})]});if(m.type==="text")return Be(WTo,{host:e,pending:t,colors:n,width:r,compact:i,detailsKey:T,draft:y,textMaxLength:f,hints:u??[{keys:"Enter",label:"submit",priority:0},...I?[{keys:T,label:"details",priority:2}]:[],...s,{keys:"Esc",label:"close",priority:1}],onKey:(ee)=>{if(j(ee)){ee.preventDefault();return}if(ee.name==="escape"||ee.ctrl&&ee.name==="c")ee.preventDefault(),R()}});if(m.type==="decision")return null;let K=m.type==="choice"?m.options.map((ee)=>({name:ee.label,description:ee.description,group:ee.group,tone:ee.destructive===!0?"destructive":void 0})):m.destructive===!0?[{name:m.cancelLabel??"Cancel"},{name:m.confirmLabel??"Confirm",tone:"destructive"}]:[{name:m.confirmLabel??"Confirm"},{name:m.cancelLabel??"Cancel"}],te=m.type==="choice"&&m.current!==void 0?m.options.findIndex((ee)=>ee.value===m.current):-1;return Vn("box",{flexDirection:"column",rowGap:i?0:1,children:[l?null:Be(F1,{content:x,width:r,compact:i,detailsKey:T,colors:n}),Be(Cm,{searchable:b,onKey:j,hints:F,collapsedGroups:m.type==="choice"&&m.collapsedGroup!==void 0?[m.collapsedGroup]:[],colors:n,choices:K,currentIndex:te>=0?te:void 0,initialIndex:_.current??d,onHighlight:(ee)=>{_.current=ee,p?.(ee)},onSelect:(ee)=>{if(m.type==="choice"){let ge=m.options[ee];if(ge!==void 0)e.answer(t.sequence,ge.value)}else e.answer(t.sequence,m.destructive===!0?ee===1:ee===0)},onCancel:R})]})}function NDt({host:e,colors:t,onClose:n,onKey:r,hints:i,hideChoiceTitle:o,hideProgressWhilePrompt:s,initialIndex:a,onHighlight:c,textMaxLength:u}){let l=Ka(e.subscribe,e.snapshot),d=r_r(),p=Kf(),f=p.height<14,m=aS(p.width),h=l.status==="done"||l.status==="cancelled",g=l.status==="failed",_=l.handoff?.url??l.links[0]?.url,y=(z)=>{let j=l.prompt?.request.type==="text";if(_!==void 0&&d!==void 0&&(z.name==="c"&&!j||(z.meta||z.option)&&z.name==="c"))return d(_),!0;if(l.handoff?.code!==void 0&&d!==void 0&&z.name==="x"&&!j)return d(l.handoff.code),!0;return!1},x=(z)=>{if(y(z))z.preventDefault();else if(z.name==="escape"||z.ctrl&&z.name==="c")z.preventDefault(),e.cancel(),n();else if(h&&(z.name==="return"||z.name==="enter"))z.preventDefault(),n()},b=l.prompt===void 0&&!g,S=l.handoff,T=g||s&&l.prompt!==void 0&&l.message?.type==="progress"?void 0:l.message,I=T?.type==="success"?t.success:T?.type==="progress"?t.warning:t.info,R=[..._===void 0?[]:[{keys:l.prompt?.request.type==="text"?"Alt+C":"c",label:"copy link",priority:2}],...l.handoff?.code===void 0?[]:[{keys:"x",label:"copy code",priority:2}]],F=g?[]:h?[{keys:"Enter",label:"close",priority:0}]:l.prompt===void 0?[...R,{keys:"Esc",label:"cancel",priority:0}]:[];return Vn("box",{flexDirection:"column",rowGap:f?0:1,focusable:b,focused:b,onKeyDown:(z)=>{if(b)x(z)},children:[l.prompt!==void 0?null:Be("text",{fg:t.foreground,attributes:1,children:yr(l.title)}),S===void 0?null:Vn("box",{flexDirection:"column",children:[Be("text",{fg:t.foreground,children:yr(S.message??(S.code===void 0?"Continue in your browser:":"Open this page and enter the code:"))}),Be("text",{fg:t.info,wrapMode:"char",onMouseDown:()=>d?.(S.url),children:yr(S.url)}),S.code===void 0?null:Be("box",{flexDirection:"column",children:Be("text",{fg:t.accent,attributes:1,children:yr(S.code)})})]}),T===void 0?null:Vn("box",{flexDirection:"column",children:[Vn("text",{fg:t.foreground,children:[Be("span",{fg:I,children:"\u25CF "}),yr(T.message)]}),l.links.map((z)=>Vn("box",{flexDirection:"column",children:[z.label===void 0?null:Vn("text",{fg:t.info,children:[yr(z.label),":"]}),Be("text",{fg:t.info,wrapMode:"char",onMouseDown:()=>d?.(z.url),children:yr(z.url)})]},z.url))]}),l.prompt===void 0?null:Be(HTo,{host:e,pending:l.prompt,colors:t,width:m,compact:f,rows:p.height,extraHints:R,onClose:n,onKey:(z)=>y(z)||(r?.(z)??!1),customHints:i,hideChoiceTitle:o,initialIndex:a,onHighlight:c,textMaxLength:u},l.prompt.sequence),g?Vn("box",{flexDirection:"column",rowGap:f?0:1,children:[Vn("text",{fg:t.error,children:["\u25CF ",yr(l.failure??"")]}),Be(Cm,{colors:t,choices:[...l.retryable?[{name:"Try again"}]:[],{name:"Close"}],onSelect:(z)=>{if(l.retryable&&z===0)e.retry();else e.cancel(),n()},onCancel:()=>{e.cancel(),n()}})]}):null,l.prompt!==void 0||g?null:Be(fC,{hints:i??F,width:m,colors:t})]})}function LDt(e){let t=Pr(e);t.current=e;let n=e.slash.interactions.open,{store:r}=e.slash;Qn(()=>{if(n===void 0||e.enabled===!1)return;let i=!0,o=t.current.dialog.show(()=>Be(NDt,{host:n.host,colors:t.current.colors,onClose:()=>{t.current.inputHandoff?.capture(),r.close(),o.dismiss()}}),{onDismiss:()=>{if(i)t.current.inputHandoff?.capture(),r.close()}});return()=>{i=!1,o.dismiss()}},[n,r,e.enabled])}var FDt=A(async()=>{bu();k1();Xi();mX();RDt();nye();await du([qg(),AW(),jP(),L$e()])});function GTo({status:e,rules:t,source:n,signal:r,refresh:i,colors:o,onClose:s}){let{width:a,height:c}=Kf(),u=dte.findIndex((h)=>h.mode===e.mode),l=c<20,[d,p]=ii(),f=Pr(void 0);Qn(()=>()=>f.current?.cancel(),[]);let m=async(h)=>{if(f.current!==void 0)return;let g=s7({title:"Permissions"});f.current=g;let _=g.begin(),y=AbortSignal.any([r,_.interaction.signal]),x=()=>{g.cancel()};if(r.addEventListener("abort",x,{once:!0}),r.aborted)x();p(g);try{let b=h.kind==="remove-rule"?{type:"confirmation",message:"Remove Always-allow rule?",summary:Wc(`\u201C${h.prefix.join(" ")}\u201D`,aS(a)),body:"Remove this saved approval for every Workspace Agent in this project. Another rule may still cover the command.",confirmLabel:"Remove rule",cancelLabel:"Keep rule",destructive:!0}:h.mode==="full-access"?{type:"confirmation",message:"Switch to Full access?",summary:"Outside the sandbox, as you",body:"Commands can use your files, network and credentials, without permission questions.",confirmLabel:"Use Full access",cancelLabel:`Keep ${dte[u]?.name??e.mode}`,destructive:!0}:void 0;if(b!==void 0){if(!await _.interaction.prompt(b)){_.settle({status:"cancelled"}),p(void 0);return}}_.interaction.notify({type:"progress",message:h.kind==="mode"?"Saving Agent mode\u2026":"Removing project rule\u2026"}),await _.interaction.run(async()=>{try{if(h.kind==="mode")await n.setMode(h.mode,y);else await n.rules.remove(h.prefix,y)}finally{await i()}}),_.settle({status:"handled"}),s()}catch(b){if(y.aborted)_.settle({status:"cancelled"});else Oi("local-permissions",b),_.settle({status:"failed",message:b instanceof Error?b.message:"Unable to save permissions"})}finally{r.removeEventListener("abort",x),f.current=void 0}};if(d!==void 0)return Be(NDt,{host:d,colors:o,onClose:s});return Vn("box",{flexDirection:"column",rowGap:l?0:1,children:[Be(F1,{content:{title:"Permissions",summary:`Current mode: ${dte[u]?.name??e.mode}`,facts:[{label:"Rules",value:"Shared by Workspace Agents in this project."}]},width:aS(a),compact:l,colors:o}),Be(Cm,{choices:[...dte.map((h)=>({name:h.name,description:h.description,group:"Agent mode",tone:h.mode==="full-access"?"destructive":void 0})),...t.map((h)=>({name:`Remove \u201C${h.join(" ")}\u201D\u2026`,group:"Always-allow rules",description:"Remove this project's saved approval.",tone:"destructive"}))],currentIndex:u,searchable:t.length>3,rowLimit:Math.max(1,c-(l?8:12)),colors:o,onCancel:s,onSelect:(h)=>{if(h===u)s();else{let g=dte[h]?.mode;if(g!==void 0)m({kind:"mode",mode:g});else{let _=t[h-dte.length];if(_!==void 0)m({kind:"remove-rule",prefix:_})}}}}),t.length===0?Be("text",{fg:o.foreground,attributes:2,children:"No Always-allow rules in this project."}):null]})}function $Dt({source:e,commands:t,dialog:n,colors:r}){let i=xO(),o=kw({queryKey:i_r(e?.identity),enabled:e!==void 0,staleTime:0,queryFn:({signal:c})=>{if(e===void 0)throw Error("Local permissions unavailable");return e.read(c)}});Qn(()=>{if(o.error!==null)Oi("local-sandbox-status",o.error)},[o.error]);let s=Pr(r);s.current=r;let a=n.show;return Qn(()=>{if(e===void 0)return;let c=new AbortController,u,l=t.contribute({sourceId:"tui-frame",namespace:"tui",commands:[{id:"permissions",title:"Permissions",category:"Settings",description:"Choose Agent mode and remove project Always-allow rules",projections:{palette:{},help:{},slash:{aliases:["permissions"],consumesDraft:!0}},handler:async({interaction:d})=>{if(d===void 0)throw Error("Managing permissions needs a person.");let[p,f]=await Promise.all([e.read(c.signal),e.rules.list(c.signal)]);c.signal.throwIfAborted(),u=a((m)=>Be(GTo,{status:p,rules:f,source:e,signal:c.signal,refresh:async()=>{let h={queryKey:i_r(e.identity),exact:!0};await i.cancelQueries(h),await i.invalidateQueries(h)},colors:s.current,onClose:m.dismiss}))}}]});return()=>{c.abort(),u?.dismiss(),l.dispose()}},[t,a,e,i]),{status:o.data,refresh:o.refetch}}var i_r=(e)=>["tui-sandbox-status",e],dte;var o_r=A(async()=>{bu();Xi();wO();mX();oF();P1();await du([qg(),AW(),jP(),FDt()]);dte=[{mode:"read-only",name:"Read-only",description:"Read files; no edits or command network."},{mode:"workspace",name:"Workspace",description:"Work in the Agent's folder, inside the sandbox."},{mode:"full-access",name:"Full access",description:"Outside the sandbox, as you."}]});import{RGBA as KTo}from"@opentui/core";function BP(){let e=Xd(lF);if(e===void 0)throw Error("Dialog content requires host colors");return e}function pte({children:e,colors:t,onClose:n}){let{height:r}=Kf();return Be(lF.Provider,{value:t,children:Be("box",{position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:100,padding:1,alignItems:"center",justifyContent:"center",backgroundColor:KTo.fromInts(0,0,0,140),onMouseDown:(i)=>{i.preventDefault(),n()},children:Be("box",{width:"100%",maxWidth:68,maxHeight:"100%",backgroundColor:t.background,onMouseDown:(i)=>{i.stopPropagation()},children:Be("box",{backgroundColor:t.background,paddingX:r<14?1:2,paddingY:r<14?0:1,children:e})})})})}var lF;var dF=A(async()=>{bu();Xi();await qg();lF=ud(void 0)});function F$e(e){let[t,n]=ii(),r=Pr(void 0),i=Pr(0),o=Pr(!1);Qn(()=>(o.current=!0,n(r.current),()=>{o.current=!1;let u=r.current;r.current=void 0,u?.onDismiss?.()}),[e]);let s=el(()=>{let u=r.current;if(u===void 0)return!1;return r.current=void 0,n(void 0),u.onDismiss?.(),!0},[]),a=el(()=>{let u=r.current;if(u===void 0)return!1;if(u.beforeDismiss?.()!==!1)s();return!0},[s]);return{show:el((u,l)=>{let d={isCurrent:()=>o.current&&r.current?.handle===d,dismiss:()=>{if(d.isCurrent())s()}};if(!o.current)return d;let p=r.current;if(p?.beforeDismiss?.()===!1)throw Error("The current dialog is still saving or closing.");let f={key:++i.current,render:u,handle:d,onDismiss:l?.onDismiss,beforeDismiss:l?.beforeDismiss};return r.current=f,n(f),p?.onDismiss?.(),d},[s]),dismiss:a,isOpen:t!==void 0,entry:t}}function gye({dialog:e,colors:t}){let n=e.entry;if(n===void 0)return null;return Be(pte,{colors:t,onClose:e.dismiss,children:Be(VTo,{entry:n},n.key)})}function VTo({entry:e}){return Be(XT,{children:e.render(e.handle)})}var zDt=A(async()=>{bu();Xi();await dF()});var s_r=()=>{};function UDt({session:e,enabled:t}){let n=Ame(),{observation:r}=NI(),i=gC(),o=n[qI.id],s=Ns(()=>{if(o?.status!=="running")return{pending:void 0,invalid:!1};try{return{pending:JTo(o.value).pending[0],invalid:!1}}catch{return{pending:void 0,invalid:!0}}},[o]),a=t&&r.status==="live",c=s.pending,u=JSON.stringify([c?.id,c?.approval.record.recordId,c?.approval.record.revision,c?.approval.canAnswer,c?.approval.canSetAutoApprove]),l=Pr({session:e,pending:c,available:a,presentationKey:u});l.current={session:e,pending:c,available:a,presentationKey:u};let d=Ns(()=>{let p=l.current.pending;if(!a||p===void 0)return;let f=p.approval,m=()=>{let g=l.current;return g.available&&g.session===e&&g.presentationKey===u?f:void 0},h={snapshot:m,subscribe:XTo,answer:async(g)=>{if(!m()?.canAnswer||g.recordId!==f.record.recordId||g.expectedRevision!==f.record.revision)return{kind:"refused",reason:"not-pending"};let _={id:p.id,decision:g.decision,expectedRevision:g.expectedRevision},y=QTo(await e.extension(qI.id).call("answer",g.denialNote===void 0?_:{..._,denialNote:g.denialNote}));if(y.kind==="submitted")throw Error("The host has not confirmed the approval decision.");return y}};return p.review===void 0?h:{...h,review:p.review}},[e,a,u]);return Qn(()=>{if(a&&s.invalid)i.show({variant:"error",message:"Invalid MCP form approval projection."})},[a,s.invalid,i]),d}var JTo,QTo,XTo=()=>()=>{return};var a_r=A(async()=>{Xi();Tm();cr();await du([sC(),N$e()]);JTo=tn(qI.projection.schema),QTo=tn(qI.commands.answer.output)});function YTo(e){if(e.kind==="commands")return e.items.map((t)=>{let n=t.command.keys.join(", ");return{key:t.command.commandId+t.label,label:yr(t.label),detail:[t.command.description??t.command.title,n].filter((r)=>r.length>0).join(" \xB7 ")}});if(e.kind==="arguments")return e.items.map((t)=>({key:t.label,label:yr(t.label),detail:yr(t.word.description??"")}));return[]}function jDt({slash:e,colors:t,maxRows:n,width:r}){let{completion:i,selected:o}=e;return Be(zgr,{rows:YTo(i),selected:o,onChoose:(s)=>{e.choose(s)},header:i.kind==="arguments"?i.hint:i.kind==="commands"&&i.items.length>n?"More\u2026 \xB7 \u2191\u2193 to browse all commands":void 0,maxRows:n,width:r,colors:t})}var c_r=A(async()=>{bu();k1();await jP()});function BDt(e,t){return b4({queryKey:["tui-tool-code",e,t],queryFn:()=>Lhr(e,t),staleTime:Number.POSITIVE_INFINITY,gcTime:0})}var u_r=A(()=>{wO();l$e()});import{StyledText as ZTo,TextAttributes as CW,TextTableRenderable as eAo}from"@opentui/core";function _ye(e,t,n={}){let{colors:r,surface:i}=t;return e.flatMap((o)=>{let s=(a)=>[{...n,__isChunk:!0,text:yr(a)}];switch(o.type){case"text":case"inlineHtml":return s(o.value);case"inlineCode":return[{...n,__isChunk:!0,text:yr(o.value),fg:r.accent,bg:i}];case"break":return s(`
|
|
2104
2104
|
`);case"strong":case"emphasis":case"strike":{let a=o.type==="strong"?CW.BOLD:o.type==="emphasis"?CW.ITALIC:CW.STRIKETHROUGH;return _ye(o.children,t,{...n,attributes:(n.attributes??0)|a})}case"link":{let a=yr(o.href),c={...n,fg:r.info,attributes:(n.attributes??0)|CW.UNDERLINE,link:{url:a}},u=_ye(o.children,t,c);if(u.map((l)=>l.text).join("")===a)return u;return[...u,{...n,__isChunk:!0,text:" \u2014 "},{...c,__isChunk:!0,text:a}]}case"image":{let a={...n,__isChunk:!0,text:yr(`[${o.alt||"Image"}]${o.src?` (${o.src})`:""}`)};if(o.src)a.link={url:yr(o.src)};return[a]}case"footnoteReference":return s(`[${String(o.number)}]`)}})}function fte({nodes:e,listItem:t=!1,...n}){return e.map((r,i)=>Be("box",{flexShrink:0,marginBottom:i===e.length-1||t&&e[i+1]?.type==="list"?0:1,children:Be(rAo,{node:r,...n})},i))}function tAo({node:e,presentation:t,foreground:n}){let{colors:r}=t;return ql("markdownTable",{content:[e.header.map((i)=>_ye(i.children,t,{attributes:CW.BOLD})),...e.rows.map((i)=>i.map((o)=>_ye(o.children,t)))],fg:n,borderColor:r.surface,columnWidthMode:"full",columnFitter:"balanced",wrapMode:"word",cellPaddingX:1,border:!0,selectable:!0,selectionBg:r.selection,selectionFg:r.selectionForeground,flexShrink:0})}function rAo({node:e,...t}){let{presentation:n,foreground:r,streaming:i}=t,{colors:o,syntax:s}=n,a={selectionBg:o.selection,selectionFg:o.selectionForeground};switch(e.type){case"paragraph":case"heading":return Be("text",{flexShrink:0,fg:r,...a,content:new ZTo(_ye(e.children,n,{attributes:e.type==="heading"?CW.BOLD:CW.NONE}))});case"code":return Vn("box",{flexShrink:0,children:[e.title?Be("text",{fg:o.info,children:yr(e.title)}):null,Be("code",{content:yr(e.value),...e.lang?{filetype:e.lang}:{},syntaxStyle:s,fg:r,bg:o.background,wrapMode:"word",streaming:i,flexShrink:0,...a})]});case"blockquote":return Be("box",{border:["left"],borderColor:o.primary,paddingLeft:1,flexShrink:0,children:Be(fte,{nodes:e.children,...t})});case"list":return Be("box",{flexShrink:0,children:e.items.map((c,u)=>Vn("box",{flexDirection:"row",flexShrink:0,marginBottom:e.loose&&u<e.items.length-1?1:0,children:[Be("text",{fg:o.primary,flexShrink:0,children:c.checked===void 0?e.ordered?`${String((e.start??1)+u)}. `:"\u2022 ":c.checked?"\u2611 ":"\u2610 "}),Be("box",{flexGrow:1,flexShrink:1,children:Be(fte,{nodes:c.children,listItem:!0,...t})})]},u))});case"table":return Be(nAo,{node:e,presentation:n,foreground:r});case"thematicBreak":return Be("box",{border:["bottom"],borderColor:o.surface,height:1,flexShrink:0});case"html":return Be("text",{fg:r,...a,children:yr(e.value)});case"footnotes":return Be("box",{flexShrink:0,children:e.items.map((c)=>Vn("box",{flexDirection:"row",flexShrink:0,children:[Be("text",{fg:o.info,flexShrink:0,children:`[${String(c.number)}] `}),Be("box",{flexGrow:1,flexShrink:1,children:Be(fte,{nodes:c.children,...t})})]},c.id))});case"callout":return Vn("box",{flexShrink:0,children:[Be("text",{fg:o.info,children:yr(e.title)}),Be(fte,{nodes:e.children,...t})]});case"component":return Be("box",{flexShrink:0,children:Be(fte,{nodes:e.children,...t})})}}function qDt({content:e,...t}){let n=Dxt(e);return Be("box",{flexGrow:1,flexShrink:1,children:Be(fte,{nodes:n.children,...t})})}var nAo;var l_r=A(async()=>{bu();k1();Tm();SO();Xi();await qg();ite({markdownTable:eAo});nAo=_X(tAo,(e,t)=>e.presentation.colors===t.presentation.colors&&e.presentation.surface===t.presentation.surface&&e.foreground===t.foreground&&rfe(e.node,t.node)===e.node)});function pF({kit:e,children:t}){return Be(d_r.Provider,{value:e,children:t})}function Rm(){let e=Xd(d_r);if(e===void 0)throw Error("A pane must be mounted by its shell");return e}function WDt(){let{viewport:e}=Rm();return Ka(e.subscribe,e.read)}function qP(){let{input:e}=Rm();return Ka(e.focused.subscribe,e.focused.read)}function mD(e){let{input:t}=Rm(),n=Pr(e);n.current=e,Qn(()=>t.onKey((r)=>n.current(r)),[t])}function HDt(e,t){let n=Rm(),r=qP(),i=Ka(n.dialogs.open.subscribe,n.dialogs.open.read),o=r&&!i&&t.enabled,s=t.deliver;return Qn(()=>{let a=e.current;if(a===null)return;if(!o)a.blur();else if(s===void 0)a.focus();else s(a)},[e,o,s]),mD(()=>{let a=e.current;if(o&&a!==null&&!n.rendering.isFocused(a))a.focus();return!1}),o}function GDt(e){let{input:t}=Rm(),n=Pr(e);n.current=e,Qn(()=>t.onPaste((r)=>{n.current(r)}),[t])}function KDt(e){let t=new Map,n=(r)=>[...t.get(r.namespace)?.values()??[]].some((i)=>i.has(r.id));return{...e.commands,contribute:(r)=>{let i=r.namespace,o={},s=t.get(i)??new Map;t.set(i,s);let a=(u)=>{s.set(o,new Set(u.map((l)=>l.id)))},c=e.commands.contribute(r.commands,i);return a(r.commands),{update:(u)=>{c.update(u),a(u)},dispose:()=>{if(s.delete(o),s.size===0)t.delete(i);c.dispose()}}},execute:(r,i)=>e.commands.execute(n(r)?e.commands.command(r.id,r.namespace):r,i)}}function VDt(e){let t=Rm();Og(()=>t.presentTheme(e).dispose,[t,e.colors,e.surface,e.syntax])}var d_r;var $$e=A(()=>{bu();Xi();d_r=ud(void 0)});var{stringWidth:iAo}=globalThis.Bun;function sAo(e){return!e.ctrl&&!e.meta&&!e.option&&!e.super&&!e.hyper&&e.sequence.length===1&&e.sequence>=" "&&e.sequence!=="\x7F"}function p_r({view:e,dispatch:t,colors:n,width:r,rows:i,surface:o,active:s,escapeRef:a}){let c=Pr(null),u=Math.max(1,r-2),l=r<=oAo,d=e.hints.some((K)=>K.label==="details"&&K.keys==="d"),p=e.other,f=p?.focused===!0;Qn(()=>{if(s&&!f&&!e.detailsOpen)c.current?.focus()},[s,f,e.detailsOpen,e.phase]),Qn(()=>{if(a===void 0)return;return a.current=()=>{t({type:"escape"})},()=>{a.current=void 0}});let m=(K)=>{if(!s||K.ctrl||K.super||K.hyper)return;let te=K.name;if(K.meta&&(te==="up"||te==="down"))return;if(te==="escape")K.preventDefault(),t({type:"escape"});else if(e.detailsOpen){if(te==="d")K.preventDefault(),t({type:"details"})}else if(te==="up"||te==="down")K.preventDefault(),t({type:"move",delta:te==="up"?-1:1});else if(te==="return"||te==="enter")K.preventDefault(),t({type:"enter"});else if((te==="space"||K.sequence===" ")&&e.multiple)K.preventDefault(),t({type:"toggle"});else if(!K.meta&&!K.option&&/^[1-9]$/u.test(te))K.preventDefault(),t({type:"pick",number:Number(te)});else if(te==="d"&&d&&!K.meta&&!K.option)K.preventDefault(),t({type:"details"});else if(sAo(K))K.preventDefault(),t({type:"append",text:K.sequence})},h=(K)=>{if(K.ctrl)return;let te=K.name;if(te==="d"&&(K.meta||K.option)&&d)K.preventDefault(),t({type:"details"});else if(K.meta&&(te==="up"||te==="down"))return;else if(te==="escape")K.preventDefault(),t({type:"escape"});else if(te==="up"||te==="down")K.preventDefault(),t({type:"move",delta:te==="up"?-1:1})},g=i<30,_={title:e.title,summary:i<14&&p!==void 0?void 0:e.summary,facts:e.facts,body:e.body,bodyLabel:e.bodyLabel,details:e.details};if(e.detailsOpen)return Vn("box",{ref:c,flexDirection:"column",backgroundColor:o,paddingX:1,paddingY:1,focusable:!0,focused:s,onKeyDown:m,children:[Be(TW,{content:_,width:u,maxRows:i-8,colors:n,onKeyDown:m}),Be(fC,{hints:e.hints,width:u,colors:n})]});let y=1+(_.summary===void 0?0:1)+e.facts.length+(e.body===void 0?0:3)+(g?0:1),x=Math.max(Math.min(e.rows.length,5),Math.floor(i/2)-y-3-(e.status===void 0?0:1)-(l?1:0)),b=e.rows.filter((K)=>K.kind==="other"),S=e.rows.filter((K)=>K.kind==="option"),T=Math.max(1,x-b.length),I=Math.max(0,S.findIndex((K)=>K.highlighted)),R=Math.max(0,Math.min(I-Math.floor(T/2),S.length-T)),F=[...S.slice(R,R+T),...b],z=Math.min(Math.max(1,u-2),Math.max(0,...S.map((K)=>iAo(K.text)))),j=(K)=>{let te=K.destructive?n.error:n.foreground,ee=K.highlighted,ge=Wc(K.text,Math.max(1,u-2)),he=K.kind==="option"&&K.description!==void 0&&!l;return Vn("box",{flexDirection:"column",children:[Vn("box",{flexDirection:"row",backgroundColor:ee?n.selection:"transparent",onMouseDown:()=>{t({type:"pick",number:K.index+1})},children:[Be("text",{width:2,flexShrink:0,fg:ee?n.selectionForeground:n.primary,children:ee?"\u203A ":" "}),Be("text",{flexShrink:K.kind==="other"?0:1,...he?{width:z}:{},wrapMode:"none",fg:ee?n.selectionForeground:te,attributes:ee?1:0,children:ge}),K.kind==="other"?Be("box",{flexGrow:1,marginLeft:1,visible:ee||(p?.text??"")!=="",children:Be(P$e,{placeholder:p?.placeholder,maxLength:p?.maxLength??1,value:p?.text??"",focused:s&&f,onInput:(Se)=>{t({type:"type",text:Se})},onSubmit:()=>{t({type:"enter"})},onKeyDown:h,colors:n})}):K.description===void 0||l?null:Be("text",{flexShrink:1,marginLeft:2,wrapMode:"none",fg:ee?n.selectionForeground:n.foreground,attributes:2,children:Wc(yr(K.description),u)})]}),ee&&l&&K.description!==void 0?Be("text",{marginLeft:4,wrapMode:"none",fg:n.foreground,attributes:2,children:Wc(yr(K.description),u-4)}):null]},K.index)};return Vn("box",{ref:c,flexDirection:"column",rowGap:g?0:1,backgroundColor:o,paddingX:1,paddingY:1,focusable:!0,focused:s&&!f,onKeyDown:m,children:[Be(F1,{content:_,width:u,compact:g,full:p===void 0,marker:e.counter,colors:n}),Be("box",{flexDirection:"column",children:F.map(j)}),e.status===void 0?null:Be("text",{wrapMode:"none",fg:e.status.tone==="error"?n.error:n.foreground,attributes:e.status.tone==="error"?0:2,children:Wc(`${e.status.tone==="error"?"\u25CF ":""}${yr(e.status.text)}`,u)}),Be(fC,{hints:e.hints,width:u,colors:n})]})}function JDt({item:e,position:t,total:n,onLater:r,...i}){let o=Pxt(e,{position:t,total:n,later:r});if(o.view===void 0)return null;return Be(p_r,{view:o.view,dispatch:o.dispatch,...i})}var oAo=72;var f_r=A(async()=>{bu();Tm();Xi();RDt();oF();nye();k1();await AW()});function QDt(e,t){switch(t){case"info":return e.info;case"success":return e.success;case"warning":return e.warning;case"error":return e.error;case"muted":return e.foreground}}var{stringWidth:aAo}=globalThis.Bun;function yye(e){let{status:t}=Rm();Og(()=>{let n=e.map((r)=>t.contribute(r));return()=>{for(let r of n)r.dispose()}},[t,e])}function xye({inset:e=1}){let t=Rm(),n=Ka(t.status.items.subscribe,t.status.items.read),{colors:r}=Ka(t.theme.subscribe,t.theme.read),i=[...n].sort((c,u)=>c.order-u.order),o=i.filter((c)=>c.slot==="state"||c.slot==="chips"),s=i.filter((c)=>c.slot==="model"),a=(c,u,l)=>c.text.length===0?null:Be("text",{fg:r[cAo[c.tone]],attributes:l?2:0,width:aAo(c.text),flexShrink:l?1:0,minWidth:0,truncate:l,wrapMode:"none",children:c.text},`${c.slot}:${String(u)}`);return Vn("box",{flexDirection:"row",justifyContent:"space-between",columnGap:1,height:1,paddingX:e,children:[Be("box",{flexDirection:"row",columnGap:1,flexShrink:0,children:o.map((c,u)=>a(c,u,!1))}),s.map((c,u)=>a(c,u,!0))]})}var cAo;var m_r=A(()=>{bu();Xi();$$e();cAo={info:"foreground",success:"success",warning:"warning",error:"error",muted:"foreground"}});function vye(e){return[{id:"ctrl-c",title:"Cancel or exit",category:"Advanced",projections:{bindings:{values:["ctrl+c"],order:3}},handler:e.ctrlC},...e.exit===void 0?[]:[{id:"exit",title:"Exit the terminal",category:"Advanced",projections:{slash:{aliases:["exit"],order:3}},handler:e.exit}]]}function bye(e,t){return e.contribute({sourceId:"tui-frame",namespace:"tui",commands:vye(t)})}var XDt=gt(function(h_r){(()=>{var e={5639:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.CircularList=void 0;let u=c(7150),l=c(802);class d extends u.Disposable{constructor(p){super(),this._maxLength=p,this.onDeleteEmitter=this._register(new l.Emitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new l.Emitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new l.Emitter),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(p){if(this._maxLength===p)return;let f=Array(p);for(let m=0;m<Math.min(p,this.length);m++)f[m]=this._array[this._getCyclicIndex(m)];this._array=f,this._maxLength=p,this._startIndex=0}get length(){return this._length}set length(p){if(p>this._length)for(let f=this._length;f<p;f++)this._array[f]=void 0;this._length=p}get(p){return this._array[this._getCyclicIndex(p)]}set(p,f){this._array[this._getCyclicIndex(p)]=f}push(p){this._array[this._getCyclicIndex(this._length)]=p,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(p,f,...m){if(f){for(let h=p;h<this._length-f;h++)this._array[this._getCyclicIndex(h)]=this._array[this._getCyclicIndex(h+f)];this._length-=f,this.onDeleteEmitter.fire({index:p,amount:f})}for(let h=this._length-1;h>=p;h--)this._array[this._getCyclicIndex(h+m.length)]=this._array[this._getCyclicIndex(h)];for(let h=0;h<m.length;h++)this._array[this._getCyclicIndex(p+h)]=m[h];if(m.length&&this.onInsertEmitter.fire({index:p,amount:m.length}),this._length+m.length>this._maxLength){let h=this._length+m.length-this._maxLength;this._startIndex+=h,this._length=this._maxLength,this.onTrimEmitter.fire(h)}else this._length+=m.length}trimStart(p){p>this._length&&(p=this._length),this._startIndex+=p,this._length-=p,this.onTrimEmitter.fire(p)}shiftElements(p,f,m){if(!(f<=0)){if(p<0||p>=this._length)throw Error("start argument out of range");if(p+m<0)throw Error("Cannot shift elements in list beyond index 0");if(m>0){for(let g=f-1;g>=0;g--)this.set(p+g+m,this.get(p+g));let h=p+f+m-this._length;if(h>0)for(this._length+=h;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let h=0;h<f;h++)this.set(p+h+m,this.get(p+h))}}_getCyclicIndex(p){return(this._startIndex+p)%this._maxLength}}a.CircularList=d},7453:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.clone=function c(u,l=5){if(typeof u!="object")return u;let d=Array.isArray(u)?[]:{};for(let p in u)d[p]=l<=1?u[p]:u[p]&&c(u[p],l-1);return d}},5777:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.CoreTerminal=void 0;let u=c(6501),l=c(6025),d=c(7276),p=c(9640),f=c(56),m=c(4071),h=c(7792),g=c(6415),_=c(5746),y=c(5882),x=c(2486),b=c(3562),S=c(8811),T=c(802),I=c(7150),R=!1;class F extends I.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new T.Emitter),this._onScroll.event((z)=>{this._onScrollApi?.fire(z.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(z){for(let j in z)this.optionsService.options[j]=z[j]}constructor(z){super(),this._windowsWrappingHeuristics=this._register(new I.MutableDisposable),this._onBinary=this._register(new T.Emitter),this.onBinary=this._onBinary.event,this._onData=this._register(new T.Emitter),this.onData=this._onData.event,this._onLineFeed=this._register(new T.Emitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new T.Emitter),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new T.Emitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new T.Emitter),this._instantiationService=new l.InstantiationService,this.optionsService=this._register(new f.OptionsService(z)),this._instantiationService.setService(u.IOptionsService,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(p.BufferService)),this._instantiationService.setService(u.IBufferService,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(d.LogService)),this._instantiationService.setService(u.ILogService,this._logService),this.coreService=this._register(this._instantiationService.createInstance(m.CoreService)),this._instantiationService.setService(u.ICoreService,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(u.ICoreMouseService,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(g.UnicodeService)),this._instantiationService.setService(u.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(_.CharsetService),this._instantiationService.setService(u.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(S.OscLinkService),this._instantiationService.setService(u.IOscLinkService,this._oscLinkService),this._inputHandler=this._register(new x.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(T.Event.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(T.Event.forward(this._bufferService.onResize,this._onResize)),this._register(T.Event.forward(this.coreService.onData,this._onData)),this._register(T.Event.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new b.WriteBuffer((j,K)=>this._inputHandler.parse(j,K))),this._register(T.Event.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(z,j){this._writeBuffer.write(z,j)}writeSync(z,j){this._logService.logLevel<=u.LogLevelEnum.WARN&&!R&&(this._logService.warn("writeSync is unreliable and will be removed soon."),R=!0),this._writeBuffer.writeSync(z,j)}input(z,j=!0){this.coreService.triggerDataEvent(z,j)}resize(z,j){isNaN(z)||isNaN(j)||(z=Math.max(z,p.MINIMUM_COLS),j=Math.max(j,p.MINIMUM_ROWS),this._bufferService.resize(z,j))}scroll(z,j=!1){this._bufferService.scroll(z,j)}scrollLines(z,j){this._bufferService.scrollLines(z,j)}scrollPages(z){this.scrollLines(z*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(z){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(z){let j=z-this._bufferService.buffer.ydisp;j!==0&&this.scrollLines(j)}registerEscHandler(z,j){return this._inputHandler.registerEscHandler(z,j)}registerDcsHandler(z,j){return this._inputHandler.registerDcsHandler(z,j)}registerCsiHandler(z,j){return this._inputHandler.registerCsiHandler(z,j)}registerOscHandler(z,j){return this._inputHandler.registerOscHandler(z,j)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let z=!1,j=this.optionsService.rawOptions.windowsPty;j&&j.buildNumber!==void 0&&j.buildNumber!==void 0?z=j.backend==="conpty"&&j.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(z=!0),z?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let z=[];z.push(this.onLineFeed(y.updateWindowsModeWrappedState.bind(null,this._bufferService))),z.push(this.registerCsiHandler({final:"H"},()=>((0,y.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,I.toDisposable)(()=>{for(let j of z)j.dispose()})}}}a.CoreTerminal=F},2486:function(s,a,c){var u=this&&this.__decorate||function(U,Q,Y,X){var _e,G=arguments.length,Z=G<3?Q:X===null?X=Object.getOwnPropertyDescriptor(Q,Y):X;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")Z=Reflect.decorate(U,Q,Y,X);else for(var le=U.length-1;le>=0;le--)(_e=U[le])&&(Z=(G<3?_e(Z):G>3?_e(Q,Y,Z):_e(Q,Y))||Z);return G>3&&Z&&Object.defineProperty(Q,Y,Z),Z},l=this&&this.__param||function(U,Q){return function(Y,X){Q(Y,X,U)}};Object.defineProperty(a,"__esModule",{value:!0}),a.InputHandler=a.WindowsOptionsReportType=void 0,a.isValidColorIndex=Se;let d=c(3534),p=c(6760),f=c(6717),m=c(7150),h=c(726),g=c(6107),_=c(8938),y=c(3055),x=c(5451),b=c(6501),S=c(6415),T=c(1346),I=c(9823),R=c(8693),F=c(802),z={"(":0,")":1,"*":2,"+":3,"-":1,".":2},j=131072;function K(U,Q){if(U>24)return Q.setWinLines||!1;switch(U){case 1:return!!Q.restoreWin;case 2:return!!Q.minimizeWin;case 3:return!!Q.setWinPosition;case 4:return!!Q.setWinSizePixels;case 5:return!!Q.raiseWin;case 6:return!!Q.lowerWin;case 7:return!!Q.refreshWin;case 8:return!!Q.setWinSizeChars;case 9:return!!Q.maximizeWin;case 10:return!!Q.fullscreenWin;case 11:return!!Q.getWinState;case 13:return!!Q.getWinPosition;case 14:return!!Q.getWinSizePixels;case 15:return!!Q.getScreenSizePixels;case 16:return!!Q.getCellSizePixels;case 18:return!!Q.getWinSizeChars;case 19:return!!Q.getScreenSizeChars;case 20:return!!Q.getIconTitle;case 21:return!!Q.getWinTitle;case 22:return!!Q.pushTitle;case 23:return!!Q.popTitle;case 24:return!!Q.setWinLines}return!1}var te;(function(U){U[U.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",U[U.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(te||(a.WindowsOptionsReportType=te={}));let ee=0;class ge extends m.Disposable{getAttrData(){return this._curAttrData}constructor(U,Q,Y,X,_e,G,Z,le,Oe=new f.EscapeSequenceParser){super(),this._bufferService=U,this._charsetService=Q,this._coreService=Y,this._logService=X,this._optionsService=_e,this._oscLinkService=G,this._coreMouseService=Z,this._unicodeService=le,this._parser=Oe,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new h.StringToUtf32,this._utf8Decoder=new h.Utf8ToUtf32,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=g.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=g.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this._register(new F.Emitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new F.Emitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new F.Emitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new F.Emitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new F.Emitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new F.Emitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new F.Emitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new F.Emitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new F.Emitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new F.Emitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new F.Emitter),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new F.Emitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new F.Emitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new he(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate((ve)=>this._activeBuffer=ve.activeBuffer)),this._parser.setCsiHandlerFallback((ve,Le)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(ve),params:Le.toArray()})}),this._parser.setEscHandlerFallback((ve)=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(ve)})}),this._parser.setExecuteHandlerFallback((ve)=>{this._logService.debug("Unknown EXECUTE code: ",{code:ve})}),this._parser.setOscHandlerFallback((ve,Le,V)=>{this._logService.debug("Unknown OSC code: ",{identifier:ve,action:Le,data:V})}),this._parser.setDcsHandlerFallback((ve,Le,V)=>{Le==="HOOK"&&(V=V.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(ve),action:Le,payload:V})}),this._parser.setPrintHandler((ve,Le,V)=>this.print(ve,Le,V)),this._parser.registerCsiHandler({final:"@"},(ve)=>this.insertChars(ve)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(ve)=>this.scrollLeft(ve)),this._parser.registerCsiHandler({final:"A"},(ve)=>this.cursorUp(ve)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(ve)=>this.scrollRight(ve)),this._parser.registerCsiHandler({final:"B"},(ve)=>this.cursorDown(ve)),this._parser.registerCsiHandler({final:"C"},(ve)=>this.cursorForward(ve)),this._parser.registerCsiHandler({final:"D"},(ve)=>this.cursorBackward(ve)),this._parser.registerCsiHandler({final:"E"},(ve)=>this.cursorNextLine(ve)),this._parser.registerCsiHandler({final:"F"},(ve)=>this.cursorPrecedingLine(ve)),this._parser.registerCsiHandler({final:"G"},(ve)=>this.cursorCharAbsolute(ve)),this._parser.registerCsiHandler({final:"H"},(ve)=>this.cursorPosition(ve)),this._parser.registerCsiHandler({final:"I"},(ve)=>this.cursorForwardTab(ve)),this._parser.registerCsiHandler({final:"J"},(ve)=>this.eraseInDisplay(ve,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},(ve)=>this.eraseInDisplay(ve,!0)),this._parser.registerCsiHandler({final:"K"},(ve)=>this.eraseInLine(ve,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},(ve)=>this.eraseInLine(ve,!0)),this._parser.registerCsiHandler({final:"L"},(ve)=>this.insertLines(ve)),this._parser.registerCsiHandler({final:"M"},(ve)=>this.deleteLines(ve)),this._parser.registerCsiHandler({final:"P"},(ve)=>this.deleteChars(ve)),this._parser.registerCsiHandler({final:"S"},(ve)=>this.scrollUp(ve)),this._parser.registerCsiHandler({final:"T"},(ve)=>this.scrollDown(ve)),this._parser.registerCsiHandler({final:"X"},(ve)=>this.eraseChars(ve)),this._parser.registerCsiHandler({final:"Z"},(ve)=>this.cursorBackwardTab(ve)),this._parser.registerCsiHandler({final:"`"},(ve)=>this.charPosAbsolute(ve)),this._parser.registerCsiHandler({final:"a"},(ve)=>this.hPositionRelative(ve)),this._parser.registerCsiHandler({final:"b"},(ve)=>this.repeatPrecedingCharacter(ve)),this._parser.registerCsiHandler({final:"c"},(ve)=>this.sendDeviceAttributesPrimary(ve)),this._parser.registerCsiHandler({prefix:">",final:"c"},(ve)=>this.sendDeviceAttributesSecondary(ve)),this._parser.registerCsiHandler({final:"d"},(ve)=>this.linePosAbsolute(ve)),this._parser.registerCsiHandler({final:"e"},(ve)=>this.vPositionRelative(ve)),this._parser.registerCsiHandler({final:"f"},(ve)=>this.hVPosition(ve)),this._parser.registerCsiHandler({final:"g"},(ve)=>this.tabClear(ve)),this._parser.registerCsiHandler({final:"h"},(ve)=>this.setMode(ve)),this._parser.registerCsiHandler({prefix:"?",final:"h"},(ve)=>this.setModePrivate(ve)),this._parser.registerCsiHandler({final:"l"},(ve)=>this.resetMode(ve)),this._parser.registerCsiHandler({prefix:"?",final:"l"},(ve)=>this.resetModePrivate(ve)),this._parser.registerCsiHandler({final:"m"},(ve)=>this.charAttributes(ve)),this._parser.registerCsiHandler({final:"n"},(ve)=>this.deviceStatus(ve)),this._parser.registerCsiHandler({prefix:"?",final:"n"},(ve)=>this.deviceStatusPrivate(ve)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(ve)=>this.softReset(ve)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(ve)=>this.setCursorStyle(ve)),this._parser.registerCsiHandler({final:"r"},(ve)=>this.setScrollRegion(ve)),this._parser.registerCsiHandler({final:"s"},(ve)=>this.saveCursor(ve)),this._parser.registerCsiHandler({final:"t"},(ve)=>this.windowOptions(ve)),this._parser.registerCsiHandler({final:"u"},(ve)=>this.restoreCursor(ve)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(ve)=>this.insertColumns(ve)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(ve)=>this.deleteColumns(ve)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(ve)=>this.selectProtected(ve)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(ve)=>this.requestMode(ve,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(ve)=>this.requestMode(ve,!1)),this._parser.setExecuteHandler(d.C0.BEL,()=>this.bell()),this._parser.setExecuteHandler(d.C0.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(d.C0.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(d.C0.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(d.C0.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(d.C0.BS,()=>this.backspace()),this._parser.setExecuteHandler(d.C0.HT,()=>this.tab()),this._parser.setExecuteHandler(d.C0.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(d.C0.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(d.C1.IND,()=>this.index()),this._parser.setExecuteHandler(d.C1.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(d.C1.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new T.OscHandler((ve)=>(this.setTitle(ve),this.setIconName(ve),!0))),this._parser.registerOscHandler(1,new T.OscHandler((ve)=>this.setIconName(ve))),this._parser.registerOscHandler(2,new T.OscHandler((ve)=>this.setTitle(ve))),this._parser.registerOscHandler(4,new T.OscHandler((ve)=>this.setOrReportIndexedColor(ve))),this._parser.registerOscHandler(8,new T.OscHandler((ve)=>this.setHyperlink(ve))),this._parser.registerOscHandler(10,new T.OscHandler((ve)=>this.setOrReportFgColor(ve))),this._parser.registerOscHandler(11,new T.OscHandler((ve)=>this.setOrReportBgColor(ve))),this._parser.registerOscHandler(12,new T.OscHandler((ve)=>this.setOrReportCursorColor(ve))),this._parser.registerOscHandler(104,new T.OscHandler((ve)=>this.restoreIndexedColor(ve))),this._parser.registerOscHandler(110,new T.OscHandler((ve)=>this.restoreFgColor(ve))),this._parser.registerOscHandler(111,new T.OscHandler((ve)=>this.restoreBgColor(ve))),this._parser.registerOscHandler(112,new T.OscHandler((ve)=>this.restoreCursorColor(ve))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let ve in p.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:ve},()=>this.selectCharset("("+ve)),this._parser.registerEscHandler({intermediates:")",final:ve},()=>this.selectCharset(")"+ve)),this._parser.registerEscHandler({intermediates:"*",final:ve},()=>this.selectCharset("*"+ve)),this._parser.registerEscHandler({intermediates:"+",final:ve},()=>this.selectCharset("+"+ve)),this._parser.registerEscHandler({intermediates:"-",final:ve},()=>this.selectCharset("-"+ve)),this._parser.registerEscHandler({intermediates:".",final:ve},()=>this.selectCharset("."+ve)),this._parser.registerEscHandler({intermediates:"/",final:ve},()=>this.selectCharset("/"+ve));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler((ve)=>(this._logService.error("Parsing error: ",ve),ve)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new I.DcsHandler((ve,Le)=>this.requestStatusString(ve,Le)))}_preserveStack(U,Q,Y,X){this._parseStack.paused=!0,this._parseStack.cursorStartX=U,this._parseStack.cursorStartY=Q,this._parseStack.decodedLength=Y,this._parseStack.position=X}_logSlowResolvingAsync(U){this._logService.logLevel<=b.LogLevelEnum.WARN&&Promise.race([U,new Promise((Q,Y)=>setTimeout(()=>Y("#SLOW_TIMEOUT"),5000))]).catch((Q)=>{if(Q!=="#SLOW_TIMEOUT")throw Q;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(U,Q){let Y,X=this._activeBuffer.x,_e=this._activeBuffer.y,G=0,Z=this._parseStack.paused;if(Z){if(Y=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,Q))return this._logSlowResolvingAsync(Y),Y;X=this._parseStack.cursorStartX,_e=this._parseStack.cursorStartY,this._parseStack.paused=!1,U.length>j&&(G=this._parseStack.position+j)}if(this._logService.logLevel<=b.LogLevelEnum.DEBUG&&this._logService.debug("parsing data "+(typeof U=="string"?` "${U}"`:` "${Array.prototype.map.call(U,(ve)=>String.fromCharCode(ve)).join("")}"`)),this._logService.logLevel===b.LogLevelEnum.TRACE&&this._logService.trace("parsing data (codes)",typeof U=="string"?U.split("").map((ve)=>ve.charCodeAt(0)):U),this._parseBuffer.length<U.length&&this._parseBuffer.length<j&&(this._parseBuffer=new Uint32Array(Math.min(U.length,j))),Z||this._dirtyRowTracker.clearRange(),U.length>j)for(let ve=G;ve<U.length;ve+=j){let Le=ve+j<U.length?ve+j:U.length,V=typeof U=="string"?this._stringDecoder.decode(U.substring(ve,Le),this._parseBuffer):this._utf8Decoder.decode(U.subarray(ve,Le),this._parseBuffer);if(Y=this._parser.parse(this._parseBuffer,V))return this._preserveStack(X,_e,V,ve),this._logSlowResolvingAsync(Y),Y}else if(!Z){let ve=typeof U=="string"?this._stringDecoder.decode(U,this._parseBuffer):this._utf8Decoder.decode(U,this._parseBuffer);if(Y=this._parser.parse(this._parseBuffer,ve))return this._preserveStack(X,_e,ve,0),this._logSlowResolvingAsync(Y),Y}this._activeBuffer.x===X&&this._activeBuffer.y===_e||this._onCursorMove.fire();let le=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),Oe=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);Oe<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(Oe,this._bufferService.rows-1),end:Math.min(le,this._bufferService.rows-1)})}print(U,Q,Y){let X,_e,G=this._charsetService.charset,Z=this._optionsService.rawOptions.screenReaderMode,le=this._bufferService.cols,Oe=this._coreService.decPrivateModes.wraparound,ve=this._coreService.modes.insertMode,Le=this._curAttrData,V=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&Y-Q>0&&V.getWidth(this._activeBuffer.x-1)===2&&V.setCellFromCodepoint(this._activeBuffer.x-1,0,1,Le);let re=this._parser.precedingJoinState;for(let be=Q;be<Y;++be){if(X=U[be],X<127&&G){let Me=G[String.fromCharCode(X)];Me&&(X=Me.charCodeAt(0))}let ue=this._unicodeService.charProperties(X,re);_e=S.UnicodeService.extractWidth(ue);let ae=S.UnicodeService.extractShouldJoin(ue),Ee=ae?S.UnicodeService.extractWidth(re):0;if(re=ue,Z&&this._onA11yChar.fire((0,h.stringFromCodePoint)(X)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+_e-Ee>le){if(Oe){let Me=V,pe=this._activeBuffer.x-Ee;for(this._activeBuffer.x=Ee,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),V=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),Ee>0&&V instanceof g.BufferLine&&V.copyCellsFrom(Me,pe,0,Ee,!1);pe<le;)Me.setCellFromCodepoint(pe++,0,1,Le)}else if(this._activeBuffer.x=le-1,_e===2)continue}if(ae&&this._activeBuffer.x){let Me=V.getWidth(this._activeBuffer.x-1)?1:2;V.addCodepointToCell(this._activeBuffer.x-Me,X,_e);for(let pe=_e-Ee;--pe>=0;)V.setCellFromCodepoint(this._activeBuffer.x++,0,0,Le)}else if(ve&&(V.insertCells(this._activeBuffer.x,_e-Ee,this._activeBuffer.getNullCell(Le)),V.getWidth(le-1)===2&&V.setCellFromCodepoint(le-1,_.NULL_CELL_CODE,_.NULL_CELL_WIDTH,Le)),V.setCellFromCodepoint(this._activeBuffer.x++,X,_e,Le),_e>0)for(;--_e;)V.setCellFromCodepoint(this._activeBuffer.x++,0,0,Le)}this._parser.precedingJoinState=re,this._activeBuffer.x<le&&Y-Q>0&&V.getWidth(this._activeBuffer.x)===0&&!V.hasContent(this._activeBuffer.x)&&V.setCellFromCodepoint(this._activeBuffer.x,0,1,Le),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(U,Q){return U.final!=="t"||U.prefix||U.intermediates?this._parser.registerCsiHandler(U,Q):this._parser.registerCsiHandler(U,(Y)=>!K(Y.params[0],this._optionsService.rawOptions.windowOptions)||Q(Y))}registerDcsHandler(U,Q){return this._parser.registerDcsHandler(U,new I.DcsHandler(Q))}registerEscHandler(U,Q){return this._parser.registerEscHandler(U,Q)}registerOscHandler(U,Q){return this._parser.registerOscHandler(U,new T.OscHandler(Q))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);U.hasWidth(this._activeBuffer.x)&&!U.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let U=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-U),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(U=this._bufferService.cols-1){this._activeBuffer.x=Math.min(U,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(U,Q){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=U,this._activeBuffer.y=this._activeBuffer.scrollTop+Q):(this._activeBuffer.x=U,this._activeBuffer.y=Q),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(U,Q){this._restrictCursor(),this._setCursor(this._activeBuffer.x+U,this._activeBuffer.y+Q)}cursorUp(U){let Q=this._activeBuffer.y-this._activeBuffer.scrollTop;return Q>=0?this._moveCursor(0,-Math.min(Q,U.params[0]||1)):this._moveCursor(0,-(U.params[0]||1)),!0}cursorDown(U){let Q=this._activeBuffer.scrollBottom-this._activeBuffer.y;return Q>=0?this._moveCursor(0,Math.min(Q,U.params[0]||1)):this._moveCursor(0,U.params[0]||1),!0}cursorForward(U){return this._moveCursor(U.params[0]||1,0),!0}cursorBackward(U){return this._moveCursor(-(U.params[0]||1),0),!0}cursorNextLine(U){return this.cursorDown(U),this._activeBuffer.x=0,!0}cursorPrecedingLine(U){return this.cursorUp(U),this._activeBuffer.x=0,!0}cursorCharAbsolute(U){return this._setCursor((U.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(U){return this._setCursor(U.length>=2?(U.params[1]||1)-1:0,(U.params[0]||1)-1),!0}charPosAbsolute(U){return this._setCursor((U.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(U){return this._moveCursor(U.params[0]||1,0),!0}linePosAbsolute(U){return this._setCursor(this._activeBuffer.x,(U.params[0]||1)-1),!0}vPositionRelative(U){return this._moveCursor(0,U.params[0]||1),!0}hVPosition(U){return this.cursorPosition(U),!0}tabClear(U){let Q=U.params[0];return Q===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:Q===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(U){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let Q=U.params[0]||1;for(;Q--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(U){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let Q=U.params[0]||1;for(;Q--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(U){let Q=U.params[0];return Q===1&&(this._curAttrData.bg|=536870912),Q!==2&&Q!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(U,Q,Y,X=!1,_e=!1){let G=this._activeBuffer.lines.get(this._activeBuffer.ybase+U);G.replaceCells(Q,Y,this._activeBuffer.getNullCell(this._eraseAttrData()),_e),X&&(G.isWrapped=!1)}_resetBufferLine(U,Q=!1){let Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+U);Y&&(Y.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),Q),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+U),Y.isWrapped=!1)}eraseInDisplay(U,Q=!1){let Y;switch(this._restrictCursor(this._bufferService.cols),U.params[0]){case 0:for(Y=this._activeBuffer.y,this._dirtyRowTracker.markDirty(Y),this._eraseInBufferLine(Y++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,Q);Y<this._bufferService.rows;Y++)this._resetBufferLine(Y,Q);this._dirtyRowTracker.markDirty(Y);break;case 1:for(Y=this._activeBuffer.y,this._dirtyRowTracker.markDirty(Y),this._eraseInBufferLine(Y,0,this._activeBuffer.x+1,!0,Q),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(Y+1).isWrapped=!1);Y--;)this._resetBufferLine(Y,Q);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(Y=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,Y-1);Y--;)if(this._activeBuffer.lines.get(this._activeBuffer.ybase+Y)?.getTrimmedLength())break;for(;Y>=0;Y--)this._bufferService.scroll(this._eraseAttrData())}else{for(Y=this._bufferService.rows,this._dirtyRowTracker.markDirty(Y-1);Y--;)this._resetBufferLine(Y,Q);this._dirtyRowTracker.markDirty(0)}break;case 3:let X=this._activeBuffer.lines.length-this._bufferService.rows;X>0&&(this._activeBuffer.lines.trimStart(X),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-X,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-X,0),this._onScroll.fire(0))}return!0}eraseInLine(U,Q=!1){switch(this._restrictCursor(this._bufferService.cols),U.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,Q);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,Q);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,Q)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(U){this._restrictCursor();let Q=U.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let Y=this._activeBuffer.ybase+this._activeBuffer.y,X=this._bufferService.rows-1-this._activeBuffer.scrollBottom,_e=this._bufferService.rows-1+this._activeBuffer.ybase-X+1;for(;Q--;)this._activeBuffer.lines.splice(_e-1,1),this._activeBuffer.lines.splice(Y,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(U){this._restrictCursor();let Q=U.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let Y=this._activeBuffer.ybase+this._activeBuffer.y,X;for(X=this._bufferService.rows-1-this._activeBuffer.scrollBottom,X=this._bufferService.rows-1+this._activeBuffer.ybase-X;Q--;)this._activeBuffer.lines.splice(Y,1),this._activeBuffer.lines.splice(X,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(U){this._restrictCursor();let Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return Q&&(Q.insertCells(this._activeBuffer.x,U.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(U){this._restrictCursor();let Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return Q&&(Q.deleteCells(this._activeBuffer.x,U.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(U){let Q=U.params[0]||1;for(;Q--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(U){let Q=U.params[0]||1;for(;Q--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(g.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let Q=U.params[0]||1;for(let Y=this._activeBuffer.scrollTop;Y<=this._activeBuffer.scrollBottom;++Y){let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+Y);X.deleteCells(0,Q,this._activeBuffer.getNullCell(this._eraseAttrData())),X.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let Q=U.params[0]||1;for(let Y=this._activeBuffer.scrollTop;Y<=this._activeBuffer.scrollBottom;++Y){let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+Y);X.insertCells(0,Q,this._activeBuffer.getNullCell(this._eraseAttrData())),X.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let Q=U.params[0]||1;for(let Y=this._activeBuffer.scrollTop;Y<=this._activeBuffer.scrollBottom;++Y){let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+Y);X.insertCells(this._activeBuffer.x,Q,this._activeBuffer.getNullCell(this._eraseAttrData())),X.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(U){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let Q=U.params[0]||1;for(let Y=this._activeBuffer.scrollTop;Y<=this._activeBuffer.scrollBottom;++Y){let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+Y);X.deleteCells(this._activeBuffer.x,Q,this._activeBuffer.getNullCell(this._eraseAttrData())),X.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(U){this._restrictCursor();let Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return Q&&(Q.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(U.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(U){let Q=this._parser.precedingJoinState;if(!Q)return!0;let Y=U.params[0]||1,X=S.UnicodeService.extractWidth(Q),_e=this._activeBuffer.x-X,G=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(_e),Z=new Uint32Array(G.length*Y),le=0;for(let ve=0;ve<G.length;){let Le=G.codePointAt(ve)||0;Z[le++]=Le,ve+=Le>65535?2:1}let Oe=le;for(let ve=1;ve<Y;++ve)Z.copyWithin(Oe,0,le),Oe+=le;return this.print(Z,0,Oe),!0}sendDeviceAttributesPrimary(U){return U.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(d.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(d.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(U){return U.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(d.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(d.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(U.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(d.C0.ESC+"[>83;40003;0c")),!0}_is(U){return(this._optionsService.rawOptions.termName+"").indexOf(U)===0}setMode(U){for(let Q=0;Q<U.length;Q++)switch(U.params[Q]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(U){for(let Q=0;Q<U.length;Q++)switch(U.params[Q]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),this._charsetService.setgCharset(1,p.DEFAULT_CHARSET),this._charsetService.setgCharset(2,p.DEFAULT_CHARSET),this._charsetService.setgCharset(3,p.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1000:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(U){for(let Q=0;Q<U.length;Q++)switch(U.params[Q]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(U){for(let Q=0;Q<U.length;Q++)switch(U.params[Q]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1000:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),U.params[Q]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(U,Q){let Y=this._coreService.decPrivateModes,{activeProtocol:X,activeEncoding:_e}=this._coreMouseService,G=this._coreService,{buffers:Z,cols:le}=this._bufferService,{active:Oe,alt:ve}=Z,Le=this._optionsService.rawOptions,V=(ae)=>ae?1:2,re=U.params[0];return be=re,ue=Q?re===2?4:re===4?V(G.modes.insertMode):re===12?3:re===20?V(Le.convertEol):0:re===1?V(Y.applicationCursorKeys):re===3?Le.windowOptions.setWinLines?le===80?2:le===132?1:0:0:re===6?V(Y.origin):re===7?V(Y.wraparound):re===8?3:re===9?V(X==="X10"):re===12?V(Le.cursorBlink):re===25?V(!G.isCursorHidden):re===45?V(Y.reverseWraparound):re===66?V(Y.applicationKeypad):re===67?4:re===1000?V(X==="VT200"):re===1002?V(X==="DRAG"):re===1003?V(X==="ANY"):re===1004?V(Y.sendFocus):re===1005?4:re===1006?V(_e==="SGR"):re===1015?4:re===1016?V(_e==="SGR_PIXELS"):re===1048?1:re===47||re===1047||re===1049?V(Oe===ve):re===2004?V(Y.bracketedPasteMode):re===2026?V(Y.synchronizedOutput):0,G.triggerDataEvent(`${d.C0.ESC}[${Q?"":"?"}${be};${ue}$y`),!0;var be,ue}_updateAttrColor(U,Q,Y,X,_e){return Q===2?(U|=50331648,U&=-16777216,U|=x.AttributeData.fromColorRGB([Y,X,_e])):Q===5&&(U&=-50331904,U|=33554432|255&Y),U}_extractColor(U,Q,Y){let X=[0,0,-1,0,0,0],_e=0,G=0;do{if(X[G+_e]=U.params[Q+G],U.hasSubParams(Q+G)){let Z=U.getSubParams(Q+G),le=0;do X[1]===5&&(_e=1),X[G+le+1+_e]=Z[le];while(++le<Z.length&&le+G+1+_e<X.length);break}if(X[1]===5&&G+_e>=2||X[1]===2&&G+_e>=5)break;X[1]&&(_e=1)}while(++G+Q<U.length&&G+_e<X.length);for(let Z=2;Z<X.length;++Z)X[Z]===-1&&(X[Z]=0);switch(X[0]){case 38:Y.fg=this._updateAttrColor(Y.fg,X[1],X[3],X[4],X[5]);break;case 48:Y.bg=this._updateAttrColor(Y.bg,X[1],X[3],X[4],X[5]);break;case 58:Y.extended=Y.extended.clone(),Y.extended.underlineColor=this._updateAttrColor(Y.extended.underlineColor,X[1],X[3],X[4],X[5])}return G}_processUnderline(U,Q){Q.extended=Q.extended.clone(),(!~U||U>5)&&(U=1),Q.extended.underlineStyle=U,Q.fg|=268435456,U===0&&(Q.fg&=-268435457),Q.updateExtended()}_processSGR0(U){U.fg=g.DEFAULT_ATTR_DATA.fg,U.bg=g.DEFAULT_ATTR_DATA.bg,U.extended=U.extended.clone(),U.extended.underlineStyle=0,U.extended.underlineColor&=-67108864,U.updateExtended()}charAttributes(U){if(U.length===1&&U.params[0]===0)return this._processSGR0(this._curAttrData),!0;let Q=U.length,Y,X=this._curAttrData;for(let _e=0;_e<Q;_e++)Y=U.params[_e],Y>=30&&Y<=37?(X.fg&=-50331904,X.fg|=16777216|Y-30):Y>=40&&Y<=47?(X.bg&=-50331904,X.bg|=16777216|Y-40):Y>=90&&Y<=97?(X.fg&=-50331904,X.fg|=16777224|Y-90):Y>=100&&Y<=107?(X.bg&=-50331904,X.bg|=16777224|Y-100):Y===0?this._processSGR0(X):Y===1?X.fg|=134217728:Y===3?X.bg|=67108864:Y===4?(X.fg|=268435456,this._processUnderline(U.hasSubParams(_e)?U.getSubParams(_e)[0]:1,X)):Y===5?X.fg|=536870912:Y===7?X.fg|=67108864:Y===8?X.fg|=1073741824:Y===9?X.fg|=2147483648:Y===2?X.bg|=134217728:Y===21?this._processUnderline(2,X):Y===22?(X.fg&=-134217729,X.bg&=-134217729):Y===23?X.bg&=-67108865:Y===24?(X.fg&=-268435457,this._processUnderline(0,X)):Y===25?X.fg&=-536870913:Y===27?X.fg&=-67108865:Y===28?X.fg&=-1073741825:Y===29?X.fg&=2147483647:Y===39?(X.fg&=-67108864,X.fg|=16777215&g.DEFAULT_ATTR_DATA.fg):Y===49?(X.bg&=-67108864,X.bg|=16777215&g.DEFAULT_ATTR_DATA.bg):Y===38||Y===48||Y===58?_e+=this._extractColor(U,_e,X):Y===53?X.bg|=1073741824:Y===55?X.bg&=-1073741825:Y===59?(X.extended=X.extended.clone(),X.extended.underlineColor=-1,X.updateExtended()):Y===100?(X.fg&=-67108864,X.fg|=16777215&g.DEFAULT_ATTR_DATA.fg,X.bg&=-67108864,X.bg|=16777215&g.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",Y);return!0}deviceStatus(U){switch(U.params[0]){case 5:this._coreService.triggerDataEvent(`${d.C0.ESC}[0n`);break;case 6:let Q=this._activeBuffer.y+1,Y=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${d.C0.ESC}[${Q};${Y}R`)}return!0}deviceStatusPrivate(U){if(U.params[0]===6){let Q=this._activeBuffer.y+1,Y=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${d.C0.ESC}[?${Q};${Y}R`)}return!0}softReset(U){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=g.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(U){let Q=U.length===0?1:U.params[0];if(Q===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(Q){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar"}let Y=Q%2==1;this._coreService.decPrivateModes.cursorBlink=Y}return!0}setScrollRegion(U){let Q=U.params[0]||1,Y;return(U.length<2||(Y=U.params[1])>this._bufferService.rows||Y===0)&&(Y=this._bufferService.rows),Y>Q&&(this._activeBuffer.scrollTop=Q-1,this._activeBuffer.scrollBottom=Y-1,this._setCursor(0,0)),!0}windowOptions(U){if(!K(U.params[0],this._optionsService.rawOptions.windowOptions))return!0;let Q=U.length>1?U.params[1]:0;switch(U.params[0]){case 14:Q!==2&&this._onRequestWindowsOptionsReport.fire(te.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(te.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${d.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:Q!==0&&Q!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),Q!==0&&Q!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:Q!==0&&Q!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),Q!==0&&Q!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(U){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(U){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(U){return this._windowTitle=U,this._onTitleChange.fire(U),!0}setIconName(U){return this._iconName=U,!0}setOrReportIndexedColor(U){let Q=[],Y=U.split(";");for(;Y.length>1;){let X=Y.shift(),_e=Y.shift();if(/^\d+$/.exec(X)){let G=parseInt(X);if(Se(G))if(_e==="?")Q.push({type:0,index:G});else{let Z=(0,R.parseColor)(_e);Z&&Q.push({type:1,index:G,color:Z})}}}return Q.length&&this._onColor.fire(Q),!0}setHyperlink(U){let Q=U.indexOf(";");if(Q===-1)return!0;let Y=U.slice(0,Q).trim(),X=U.slice(Q+1);return X?this._createHyperlink(Y,X):!Y.trim()&&this._finishHyperlink()}_createHyperlink(U,Q){this._getCurrentLinkId()&&this._finishHyperlink();let Y=U.split(":"),X,_e=Y.findIndex((G)=>G.startsWith("id="));return _e!==-1&&(X=Y[_e].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:X,uri:Q}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(U,Q){let Y=U.split(";");for(let X=0;X<Y.length&&!(Q>=this._specialColors.length);++X,++Q)if(Y[X]==="?")this._onColor.fire([{type:0,index:this._specialColors[Q]}]);else{let _e=(0,R.parseColor)(Y[X]);_e&&this._onColor.fire([{type:1,index:this._specialColors[Q],color:_e}])}return!0}setOrReportFgColor(U){return this._setOrReportSpecialColor(U,0)}setOrReportBgColor(U){return this._setOrReportSpecialColor(U,1)}setOrReportCursorColor(U){return this._setOrReportSpecialColor(U,2)}restoreIndexedColor(U){if(!U)return this._onColor.fire([{type:2}]),!0;let Q=[],Y=U.split(";");for(let X=0;X<Y.length;++X)if(/^\d+$/.exec(Y[X])){let _e=parseInt(Y[X]);Se(_e)&&Q.push({type:2,index:_e})}return Q.length&&this._onColor.fire(Q),!0}restoreFgColor(U){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(U){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(U){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),!0}selectCharset(U){return U.length!==2?(this.selectDefaultCharset(),!0):(U[0]==="/"||this._charsetService.setgCharset(z[U[0]],p.CHARSETS[U[1]]||p.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let U=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,U,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=g.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=g.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(U){return this._charsetService.setgLevel(U),!0}screenAlignmentPattern(){let U=new y.CellData;U.content=4194373,U.fg=this._curAttrData.fg,U.bg=this._curAttrData.bg,this._setCursor(0,0);for(let Q=0;Q<this._bufferService.rows;++Q){let Y=this._activeBuffer.ybase+this._activeBuffer.y+Q,X=this._activeBuffer.lines.get(Y);X&&(X.fill(U),X.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(U,Q){let Y=this._bufferService.buffer,X=this._optionsService.rawOptions;return((_e)=>(this._coreService.triggerDataEvent(`${d.C0.ESC}${_e}${d.C0.ESC}\\`),!0))(U==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:U==='"p'?'P1$r61;1"p':U==="r"?`P1$r${Y.scrollTop+1};${Y.scrollBottom+1}r`:U==="m"?"P1$r0m":U===" q"?`P1$r${{block:2,underline:4,bar:6}[X.cursorStyle]-(X.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(U,Q){this._dirtyRowTracker.markRangeDirty(U,Q)}}a.InputHandler=ge;let he=class{constructor(U){this._bufferService=U,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(U){U<this.start?this.start=U:U>this.end&&(this.end=U)}markRangeDirty(U,Q){U>Q&&(ee=U,U=Q,Q=ee),U<this.start&&(this.start=U),Q>this.end&&(this.end=Q)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Se(U){return 0<=U&&U<256}he=u([l(0,b.IBufferService)],he)},701:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.isChromeOS=a.isLinux=a.isWindows=a.isIphone=a.isIpad=a.isMac=a.isSafari=a.isLegacyEdge=a.isFirefox=a.isNode=void 0,a.getSafariVersion=function(){if(!a.isSafari)return 0;let l=c.match(/Version\/(\d+)/);return l===null||l.length<2?0:parseInt(l[1])},a.isNode=typeof process<"u"&&"title"in process;let c=a.isNode?"node":navigator.userAgent,u=a.isNode?"node":navigator.platform;a.isFirefox=c.includes("Firefox"),a.isLegacyEdge=c.includes("Edge"),a.isSafari=/^((?!chrome|android).)*safari/i.test(c),a.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(u),a.isIpad=u==="iPad",a.isIphone=u==="iPhone",a.isWindows=["Windows","Win16","Win32","WinCE"].includes(u),a.isLinux=u.indexOf("Linux")>=0,a.isChromeOS=/\bCrOS\b/.test(c)},6168:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.DebouncedIdleTask=a.IdleTaskQueue=a.PriorityTaskQueue=void 0;let u=c(701);class l{constructor(){this._tasks=[],this._i=0}enqueue(p){this._tasks.push(p),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(p){this._idleCallback=void 0;let f=0,m=0,h=p.timeRemaining(),g=0;for(;this._i<this._tasks.length;){if(f=performance.now(),this._tasks[this._i]()||this._i++,f=Math.max(1,performance.now()-f),m=Math.max(f,m),g=p.timeRemaining(),1.5*m>g)return h-f<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(h-f))}ms`),void this._start();h=g}this.clear()}}class d extends l{_requestCallback(p){return setTimeout(()=>p(this._createDeadline(16)))}_cancelCallback(p){clearTimeout(p)}_createDeadline(p){let f=performance.now()+p;return{timeRemaining:()=>Math.max(0,f-performance.now())}}}a.PriorityTaskQueue=d,a.IdleTaskQueue=!u.isNode&&"requestIdleCallback"in window?class extends l{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:d,a.DebouncedIdleTask=class{constructor(){this._queue=new a.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},5882:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.updateWindowsModeWrappedState=function(l){let d=l.buffer.lines.get(l.buffer.ybase+l.buffer.y-1),p=d?.get(l.cols-1),f=l.buffer.lines.get(l.buffer.ybase+l.buffer.y);f&&p&&(f.isWrapped=p[u.CHAR_DATA_CODE_INDEX]!==u.NULL_CELL_CODE&&p[u.CHAR_DATA_CODE_INDEX]!==u.WHITESPACE_CELL_CODE)};let u=c(8938)},5451:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ExtendedAttrs=a.AttributeData=void 0;class c{constructor(){this.fg=0,this.bg=0,this.extended=new u}static toColorRGB(l){return[l>>>16&255,l>>>8&255,255&l]}static fromColorRGB(l){return(255&l[0])<<16|(255&l[1])<<8|255&l[2]}clone(){let l=new c;return l.fg=this.fg,l.bg=this.bg,l.extended=this.extended.clone(),l}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}a.AttributeData=c;class u{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(l){this._ext=l}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(l){this._ext&=-469762049,this._ext|=l<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(l){this._ext&=-67108864,this._ext|=67108863&l}get urlId(){return this._urlId}set urlId(l){this._urlId=l}get underlineVariantOffset(){let l=(3758096384&this._ext)>>29;return l<0?4294967288^l:l}set underlineVariantOffset(l){this._ext&=536870911,this._ext|=l<<29&3758096384}constructor(l=0,d=0){this._ext=0,this._urlId=0,this._ext=l,this._urlId=d}clone(){return new u(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}a.ExtendedAttrs=u},1073:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.Buffer=a.MAX_BUFFER_SIZE=void 0;let u=c(5639),l=c(6168),d=c(5451),p=c(6107),f=c(732),m=c(3055),h=c(8938),g=c(8158),_=c(6760);a.MAX_BUFFER_SIZE=4294967295,a.Buffer=class{constructor(y,x,b){this._hasScrollback=y,this._optionsService=x,this._bufferService=b,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=p.DEFAULT_ATTR_DATA.clone(),this.savedCharset=_.DEFAULT_CHARSET,this.markers=[],this._nullCell=m.CellData.fromCharData([0,h.NULL_CELL_CHAR,h.NULL_CELL_WIDTH,h.NULL_CELL_CODE]),this._whitespaceCell=m.CellData.fromCharData([0,h.WHITESPACE_CELL_CHAR,h.WHITESPACE_CELL_WIDTH,h.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new l.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(y){return y?(this._nullCell.fg=y.fg,this._nullCell.bg=y.bg,this._nullCell.extended=y.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new d.ExtendedAttrs),this._nullCell}getWhitespaceCell(y){return y?(this._whitespaceCell.fg=y.fg,this._whitespaceCell.bg=y.bg,this._whitespaceCell.extended=y.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new d.ExtendedAttrs),this._whitespaceCell}getBlankLine(y,x){return new p.BufferLine(this._bufferService.cols,this.getNullCell(y),x)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let y=this.ybase+this.y-this.ydisp;return y>=0&&y<this._rows}_getCorrectBufferLength(y){if(!this._hasScrollback)return y;let x=y+this._optionsService.rawOptions.scrollback;return x>a.MAX_BUFFER_SIZE?a.MAX_BUFFER_SIZE:x}fillViewportRows(y){if(this.lines.length===0){y===void 0&&(y=p.DEFAULT_ATTR_DATA);let x=this._rows;for(;x--;)this.lines.push(this.getBlankLine(y))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(y,x){let b=this.getNullCell(p.DEFAULT_ATTR_DATA),S=0,T=this._getCorrectBufferLength(x);if(T>this.lines.maxLength&&(this.lines.maxLength=T),this.lines.length>0){if(this._cols<y)for(let R=0;R<this.lines.length;R++)S+=+this.lines.get(R).resize(y,b);let I=0;if(this._rows<x)for(let R=this._rows;R<x;R++)this.lines.length<x+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new p.BufferLine(y,b)):this.ybase>0&&this.lines.length<=this.ybase+this.y+I+1?(this.ybase--,I++,this.ydisp>0&&this.ydisp--):this.lines.push(new p.BufferLine(y,b)));else for(let R=this._rows;R>x;R--)this.lines.length>x+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(T<this.lines.maxLength){let R=this.lines.length-T;R>0&&(this.lines.trimStart(R),this.ybase=Math.max(this.ybase-R,0),this.ydisp=Math.max(this.ydisp-R,0),this.savedY=Math.max(this.savedY-R,0)),this.lines.maxLength=T}this.x=Math.min(this.x,y-1),this.y=Math.min(this.y,x-1),I&&(this.y+=I),this.savedX=Math.min(this.savedX,y-1),this.scrollTop=0}if(this.scrollBottom=x-1,this._isReflowEnabled&&(this._reflow(y,x),this._cols>y))for(let I=0;I<this.lines.length;I++)S+=+this.lines.get(I).resize(y,b);this._cols=y,this._rows=x,this._memoryCleanupQueue.clear(),S>0.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let y=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,y=!1);let x=0;for(;this._memoryCleanupPosition<this.lines.length;)if(x+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),x>100)return!0;return y}get _isReflowEnabled(){let y=this._optionsService.rawOptions.windowsPty;return y&&y.buildNumber?this._hasScrollback&&y.backend==="conpty"&&y.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(y,x){this._cols!==y&&(y>this._cols?this._reflowLarger(y,x):this._reflowSmaller(y,x))}_reflowLarger(y,x){let b=this._optionsService.rawOptions.reflowCursorLine,S=(0,f.reflowLargerGetLinesToRemove)(this.lines,this._cols,y,this.ybase+this.y,this.getNullCell(p.DEFAULT_ATTR_DATA),b);if(S.length>0){let T=(0,f.reflowLargerCreateNewLayout)(this.lines,S);(0,f.reflowLargerApplyNewLayout)(this.lines,T.layout),this._reflowLargerAdjustViewport(y,x,T.countRemoved)}}_reflowLargerAdjustViewport(y,x,b){let S=this.getNullCell(p.DEFAULT_ATTR_DATA),T=b;for(;T-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<x&&this.lines.push(new p.BufferLine(y,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-b,0)}_reflowSmaller(y,x){let b=this._optionsService.rawOptions.reflowCursorLine,S=this.getNullCell(p.DEFAULT_ATTR_DATA),T=[],I=0;for(let R=this.lines.length-1;R>=0;R--){let F=this.lines.get(R);if(!F||!F.isWrapped&&F.getTrimmedLength()<=y)continue;let z=[F];for(;F.isWrapped&&R>0;)F=this.lines.get(--R),z.unshift(F);if(!b){let X=this.ybase+this.y;if(X>=R&&X<R+z.length)continue}let j=z[z.length-1].getTrimmedLength(),K=(0,f.reflowSmallerGetNewLineLengths)(z,this._cols,y),te=K.length-z.length,ee;ee=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+te):Math.max(0,this.lines.length-this.lines.maxLength+te);let ge=[];for(let X=0;X<te;X++){let _e=this.getBlankLine(p.DEFAULT_ATTR_DATA,!0);ge.push(_e)}ge.length>0&&(T.push({start:R+z.length+I,newLines:ge}),I+=ge.length),z.push(...ge);let he=K.length-1,Se=K[he];Se===0&&(he--,Se=K[he]);let U=z.length-te-1,Q=j;for(;U>=0;){let X=Math.min(Q,Se);if(z[he]===void 0)break;if(z[he].copyCellsFrom(z[U],Q-X,Se-X,X,!0),Se-=X,Se===0&&(he--,Se=K[he]),Q-=X,Q===0){U--;let _e=Math.max(U,0);Q=(0,f.getWrappedLineTrimmedLength)(z,_e,this._cols)}}for(let X=0;X<z.length;X++)K[X]<y&&z[X].setCell(K[X],S);let Y=te-ee;for(;Y-- >0;)this.ybase===0?this.y<x-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+I)-x&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+te,this.ybase+x-1)}if(T.length>0){let R=[],F=[];for(let Se=0;Se<this.lines.length;Se++)F.push(this.lines.get(Se));let z=this.lines.length,j=z-1,K=0,te=T[K];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+I);let ee=0;for(let Se=Math.min(this.lines.maxLength-1,z+I-1);Se>=0;Se--)if(te&&te.start>j+ee){for(let U=te.newLines.length-1;U>=0;U--)this.lines.set(Se--,te.newLines[U]);Se++,R.push({index:j+1,amount:te.newLines.length}),ee+=te.newLines.length,te=T[++K]}else this.lines.set(Se,F[j--]);let ge=0;for(let Se=R.length-1;Se>=0;Se--)R[Se].index+=ge,this.lines.onInsertEmitter.fire(R[Se]),ge+=R[Se].amount;let he=Math.max(0,z+I-this.lines.maxLength);he>0&&this.lines.onTrimEmitter.fire(he)}}translateBufferLineToString(y,x,b=0,S){let T=this.lines.get(y);return T?T.translateToString(x,b,S):""}getWrappedRangeForLine(y){let x=y,b=y;for(;x>0&&this.lines.get(x).isWrapped;)x--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:x,last:b}}setupTabStops(y){for(y!=null?this.tabs[y]||(y=this.prevStop(y)):(this.tabs={},y=0);y<this._cols;y+=this._optionsService.rawOptions.tabStopWidth)this.tabs[y]=!0}prevStop(y){for(y==null&&(y=this.x);!this.tabs[--y]&&y>0;);return y>=this._cols?this._cols-1:y<0?0:y}nextStop(y){for(y==null&&(y=this.x);!this.tabs[++y]&&y<this._cols;);return y>=this._cols?this._cols-1:y<0?0:y}clearMarkers(y){this._isClearing=!0;for(let x=0;x<this.markers.length;x++)this.markers[x].line===y&&(this.markers[x].dispose(),this.markers.splice(x--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let y=0;y<this.markers.length;y++)this.markers[y].dispose();this.markers.length=0,this._isClearing=!1}addMarker(y){let x=new g.Marker(y);return this.markers.push(x),x.register(this.lines.onTrim((b)=>{x.line-=b,x.line<0&&x.dispose()})),x.register(this.lines.onInsert((b)=>{x.line>=b.index&&(x.line+=b.amount)})),x.register(this.lines.onDelete((b)=>{x.line>=b.index&&x.line<b.index+b.amount&&x.dispose(),x.line>b.index&&(x.line-=b.amount)})),x.register(x.onDispose(()=>this._removeMarker(x))),x}_removeMarker(y){this._isClearing||this.markers.splice(this.markers.indexOf(y),1)}}},6107:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BufferLine=a.DEFAULT_ATTR_DATA=void 0;let u=c(5451),l=c(3055),d=c(8938),p=c(726);a.DEFAULT_ATTR_DATA=Object.freeze(new u.AttributeData);let f=0;class m{constructor(h,g,_=!1){this.isWrapped=_,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*h);let y=g||l.CellData.fromCharData([0,d.NULL_CELL_CHAR,d.NULL_CELL_WIDTH,d.NULL_CELL_CODE]);for(let x=0;x<h;++x)this.setCell(x,y);this.length=h}get(h){let g=this._data[3*h+0],_=2097151&g;return[this._data[3*h+1],2097152&g?this._combined[h]:_?(0,p.stringFromCodePoint)(_):"",g>>22,2097152&g?this._combined[h].charCodeAt(this._combined[h].length-1):_]}set(h,g){this._data[3*h+1]=g[d.CHAR_DATA_ATTR_INDEX],g[d.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[h]=g[1],this._data[3*h+0]=2097152|h|g[d.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*h+0]=g[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|g[d.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(h){return this._data[3*h+0]>>22}hasWidth(h){return 12582912&this._data[3*h+0]}getFg(h){return this._data[3*h+1]}getBg(h){return this._data[3*h+2]}hasContent(h){return 4194303&this._data[3*h+0]}getCodePoint(h){let g=this._data[3*h+0];return 2097152&g?this._combined[h].charCodeAt(this._combined[h].length-1):2097151&g}isCombined(h){return 2097152&this._data[3*h+0]}getString(h){let g=this._data[3*h+0];return 2097152&g?this._combined[h]:2097151&g?(0,p.stringFromCodePoint)(2097151&g):""}isProtected(h){return 536870912&this._data[3*h+2]}loadCell(h,g){return f=3*h,g.content=this._data[f+0],g.fg=this._data[f+1],g.bg=this._data[f+2],2097152&g.content&&(g.combinedData=this._combined[h]),268435456&g.bg&&(g.extended=this._extendedAttrs[h]),g}setCell(h,g){2097152&g.content&&(this._combined[h]=g.combinedData),268435456&g.bg&&(this._extendedAttrs[h]=g.extended),this._data[3*h+0]=g.content,this._data[3*h+1]=g.fg,this._data[3*h+2]=g.bg}setCellFromCodepoint(h,g,_,y){268435456&y.bg&&(this._extendedAttrs[h]=y.extended),this._data[3*h+0]=g|_<<22,this._data[3*h+1]=y.fg,this._data[3*h+2]=y.bg}addCodepointToCell(h,g,_){let y=this._data[3*h+0];2097152&y?this._combined[h]+=(0,p.stringFromCodePoint)(g):2097151&y?(this._combined[h]=(0,p.stringFromCodePoint)(2097151&y)+(0,p.stringFromCodePoint)(g),y&=-2097152,y|=2097152):y=g|4194304,_&&(y&=-12582913,y|=_<<22),this._data[3*h+0]=y}insertCells(h,g,_){if((h%=this.length)&&this.getWidth(h-1)===2&&this.setCellFromCodepoint(h-1,0,1,_),g<this.length-h){let y=new l.CellData;for(let x=this.length-h-g-1;x>=0;--x)this.setCell(h+g+x,this.loadCell(h+x,y));for(let x=0;x<g;++x)this.setCell(h+x,_)}else for(let y=h;y<this.length;++y)this.setCell(y,_);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,_)}deleteCells(h,g,_){if(h%=this.length,g<this.length-h){let y=new l.CellData;for(let x=0;x<this.length-h-g;++x)this.setCell(h+x,this.loadCell(h+g+x,y));for(let x=this.length-g;x<this.length;++x)this.setCell(x,_)}else for(let y=h;y<this.length;++y)this.setCell(y,_);h&&this.getWidth(h-1)===2&&this.setCellFromCodepoint(h-1,0,1,_),this.getWidth(h)!==0||this.hasContent(h)||this.setCellFromCodepoint(h,0,1,_)}replaceCells(h,g,_,y=!1){if(y)for(h&&this.getWidth(h-1)===2&&!this.isProtected(h-1)&&this.setCellFromCodepoint(h-1,0,1,_),g<this.length&&this.getWidth(g-1)===2&&!this.isProtected(g)&&this.setCellFromCodepoint(g,0,1,_);h<g&&h<this.length;)this.isProtected(h)||this.setCell(h,_),h++;else for(h&&this.getWidth(h-1)===2&&this.setCellFromCodepoint(h-1,0,1,_),g<this.length&&this.getWidth(g-1)===2&&this.setCellFromCodepoint(g,0,1,_);h<g&&h<this.length;)this.setCell(h++,_)}resize(h,g){if(h===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let _=3*h;if(h>this.length){if(this._data.buffer.byteLength>=4*_)this._data=new Uint32Array(this._data.buffer,0,_);else{let y=new Uint32Array(_);y.set(this._data),this._data=y}for(let y=this.length;y<h;++y)this.setCell(y,g)}else{this._data=this._data.subarray(0,_);let y=Object.keys(this._combined);for(let b=0;b<y.length;b++){let S=parseInt(y[b],10);S>=h&&delete this._combined[S]}let x=Object.keys(this._extendedAttrs);for(let b=0;b<x.length;b++){let S=parseInt(x[b],10);S>=h&&delete this._extendedAttrs[S]}}return this.length=h,4*_*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let h=new Uint32Array(this._data.length);return h.set(this._data),this._data=h,1}return 0}fill(h,g=!1){if(g)for(let _=0;_<this.length;++_)this.isProtected(_)||this.setCell(_,h);else{this._combined={},this._extendedAttrs={};for(let _=0;_<this.length;++_)this.setCell(_,h)}}copyFrom(h){this.length!==h.length?this._data=new Uint32Array(h._data):this._data.set(h._data),this.length=h.length,this._combined={};for(let g in h._combined)this._combined[g]=h._combined[g];this._extendedAttrs={};for(let g in h._extendedAttrs)this._extendedAttrs[g]=h._extendedAttrs[g];this.isWrapped=h.isWrapped}clone(){let h=new m(0);h._data=new Uint32Array(this._data),h.length=this.length;for(let g in this._combined)h._combined[g]=this._combined[g];for(let g in this._extendedAttrs)h._extendedAttrs[g]=this._extendedAttrs[g];return h.isWrapped=this.isWrapped,h}getTrimmedLength(){for(let h=this.length-1;h>=0;--h)if(4194303&this._data[3*h+0])return h+(this._data[3*h+0]>>22);return 0}getNoBgTrimmedLength(){for(let h=this.length-1;h>=0;--h)if(4194303&this._data[3*h+0]||50331648&this._data[3*h+2])return h+(this._data[3*h+0]>>22);return 0}copyCellsFrom(h,g,_,y,x){let b=h._data;if(x)for(let T=y-1;T>=0;T--){for(let I=0;I<3;I++)this._data[3*(_+T)+I]=b[3*(g+T)+I];268435456&b[3*(g+T)+2]&&(this._extendedAttrs[_+T]=h._extendedAttrs[g+T])}else for(let T=0;T<y;T++){for(let I=0;I<3;I++)this._data[3*(_+T)+I]=b[3*(g+T)+I];268435456&b[3*(g+T)+2]&&(this._extendedAttrs[_+T]=h._extendedAttrs[g+T])}let S=Object.keys(h._combined);for(let T=0;T<S.length;T++){let I=parseInt(S[T],10);I>=g&&(this._combined[I-g+_]=h._combined[I])}}translateToString(h,g,_,y){g=g??0,_=_??this.length,h&&(_=Math.min(_,this.getTrimmedLength())),y&&(y.length=0);let x="";for(;g<_;){let b=this._data[3*g+0],S=2097151&b,T=2097152&b?this._combined[g]:S?(0,p.stringFromCodePoint)(S):d.WHITESPACE_CELL_CHAR;if(x+=T,y)for(let I=0;I<T.length;++I)y.push(g);g+=b>>22||1}return y&&y.push(g),x}}a.BufferLine=m},732:(s,a)=>{function c(u,l,d){if(l===u.length-1)return u[l].getTrimmedLength();let p=!u[l].hasContent(d-1)&&u[l].getWidth(d-1)===1,f=u[l+1].getWidth(0)===2;return p&&f?d-1:d}Object.defineProperty(a,"__esModule",{value:!0}),a.reflowLargerGetLinesToRemove=function(u,l,d,p,f,m){let h=[];for(let g=0;g<u.length-1;g++){let _=g,y=u.get(++_);if(!y.isWrapped)continue;let x=[u.get(g)];for(;_<u.length&&y.isWrapped;)x.push(y),y=u.get(++_);if(!m&&p>=g&&p<_){g+=x.length-1;continue}let b=0,S=c(x,b,l),T=1,I=0;for(;T<x.length;){let F=c(x,T,l),z=F-I,j=d-S,K=Math.min(z,j);x[b].copyCellsFrom(x[T],I,S,K,!1),S+=K,S===d&&(b++,S=0),I+=K,I===F&&(T++,I=0),S===0&&b!==0&&x[b-1].getWidth(d-1)===2&&(x[b].copyCellsFrom(x[b-1],d-1,S++,1,!1),x[b-1].setCell(d-1,f))}x[b].replaceCells(S,d,f);let R=0;for(let F=x.length-1;F>0&&(F>b||x[F].getTrimmedLength()===0);F--)R++;R>0&&(h.push(g+x.length-R),h.push(R)),g+=x.length-1}return h},a.reflowLargerCreateNewLayout=function(u,l){let d=[],p=0,f=l[p],m=0;for(let h=0;h<u.length;h++)if(f===h){let g=l[++p];u.onDeleteEmitter.fire({index:h-m,amount:g}),h+=g-1,m+=g,f=l[++p]}else d.push(h);return{layout:d,countRemoved:m}},a.reflowLargerApplyNewLayout=function(u,l){let d=[];for(let p=0;p<l.length;p++)d.push(u.get(l[p]));for(let p=0;p<d.length;p++)u.set(p,d[p]);u.length=l.length},a.reflowSmallerGetNewLineLengths=function(u,l,d){let p=[],f=u.map((_,y)=>c(u,y,l)).reduce((_,y)=>_+y),m=0,h=0,g=0;for(;g<f;){if(f-g<d){p.push(f-g);break}m+=d;let _=c(u,h,l);m>_&&(m-=_,h++);let y=u[h].getWidth(m-1)===2;y&&m--;let x=y?d-1:d;p.push(x),g+=x}return p},a.getWrappedLineTrimmedLength=c},4097:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BufferSet=void 0;let u=c(7150),l=c(1073),d=c(802);class p extends u.Disposable{constructor(f,m){super(),this._optionsService=f,this._bufferService=m,this._onBufferActivate=this._register(new d.Emitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new l.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new l.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(f){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(f),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(f,m){this._normal.resize(f,m),this._alt.resize(f,m),this.setupTabStops(f)}setupTabStops(f){this._normal.setupTabStops(f),this._alt.setupTabStops(f)}}a.BufferSet=p},3055:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.CellData=void 0;let u=c(726),l=c(8938),d=c(5451);class p extends d.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new d.ExtendedAttrs,this.combinedData=""}static fromCharData(f){let m=new p;return m.setFromCharData(f),m}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,u.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(f){this.fg=f[l.CHAR_DATA_ATTR_INDEX],this.bg=0;let m=!1;if(f[l.CHAR_DATA_CHAR_INDEX].length>2)m=!0;else if(f[l.CHAR_DATA_CHAR_INDEX].length===2){let h=f[l.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=h&&h<=56319){let g=f[l.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=g&&g<=57343?this.content=1024*(h-55296)+g-56320+65536|f[l.CHAR_DATA_WIDTH_INDEX]<<22:m=!0}else m=!0}else this.content=f[l.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|f[l.CHAR_DATA_WIDTH_INDEX]<<22;m&&(this.combinedData=f[l.CHAR_DATA_CHAR_INDEX],this.content=2097152|f[l.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}a.CellData=p},8938:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.WHITESPACE_CELL_CODE=a.WHITESPACE_CELL_WIDTH=a.WHITESPACE_CELL_CHAR=a.NULL_CELL_CODE=a.NULL_CELL_WIDTH=a.NULL_CELL_CHAR=a.CHAR_DATA_CODE_INDEX=a.CHAR_DATA_WIDTH_INDEX=a.CHAR_DATA_CHAR_INDEX=a.CHAR_DATA_ATTR_INDEX=a.DEFAULT_EXT=a.DEFAULT_ATTR=a.DEFAULT_COLOR=void 0,a.DEFAULT_COLOR=0,a.DEFAULT_ATTR=a.DEFAULT_COLOR<<9|256,a.DEFAULT_EXT=0,a.CHAR_DATA_ATTR_INDEX=0,a.CHAR_DATA_CHAR_INDEX=1,a.CHAR_DATA_WIDTH_INDEX=2,a.CHAR_DATA_CODE_INDEX=3,a.NULL_CELL_CHAR="",a.NULL_CELL_WIDTH=1,a.NULL_CELL_CODE=0,a.WHITESPACE_CELL_CHAR=" ",a.WHITESPACE_CELL_WIDTH=1,a.WHITESPACE_CELL_CODE=32},8158:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.Marker=void 0;let u=c(802),l=c(7150);class d{get id(){return this._id}constructor(p){this.line=p,this.isDisposed=!1,this._disposables=[],this._id=d._nextId++,this._onDispose=this.register(new u.Emitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,l.dispose)(this._disposables),this._disposables.length=0)}register(p){return this._disposables.push(p),p}}a.Marker=d,d._nextId=1},6760:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.DEFAULT_CHARSET=a.CHARSETS=void 0,a.CHARSETS={},a.DEFAULT_CHARSET=a.CHARSETS.B,a.CHARSETS[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"},a.CHARSETS.A={"#":"\xA3"},a.CHARSETS.B=void 0,a.CHARSETS[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"},a.CHARSETS.C=a.CHARSETS[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},a.CHARSETS.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"},a.CHARSETS.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"},a.CHARSETS.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"},a.CHARSETS.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"},a.CHARSETS.E=a.CHARSETS[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"},a.CHARSETS.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"},a.CHARSETS.H=a.CHARSETS[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},a.CHARSETS["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"}},3534:(s,a)=>{var c,u,l;Object.defineProperty(a,"__esModule",{value:!0}),a.C1_ESCAPED=a.C1=a.C0=void 0,function(d){d.NUL="\x00",d.SOH="\x01",d.STX="\x02",d.ETX="\x03",d.EOT="\x04",d.ENQ="\x05",d.ACK="\x06",d.BEL="\x07",d.BS="\b",d.HT="\t",d.LF=`
|
|
2105
2105
|
`,d.VT="\v",d.FF="\f",d.CR="\r",d.SO="\x0E",d.SI="\x0F",d.DLE="\x10",d.DC1="\x11",d.DC2="\x12",d.DC3="\x13",d.DC4="\x14",d.NAK="\x15",d.SYN="\x16",d.ETB="\x17",d.CAN="\x18",d.EM="\x19",d.SUB="\x1A",d.ESC="\x1B",d.FS="\x1C",d.GS="\x1D",d.RS="\x1E",d.US="\x1F",d.SP=" ",d.DEL="\x7F"}(c||(a.C0=c={})),function(d){d.PAD="\x80",d.HOP="\x81",d.BPH="\x82",d.NBH="\x83",d.IND="\x84",d.NEL="\x85",d.SSA="\x86",d.ESA="\x87",d.HTS="\x88",d.HTJ="\x89",d.VTS="\x8A",d.PLD="\x8B",d.PLU="\x8C",d.RI="\x8D",d.SS2="\x8E",d.SS3="\x8F",d.DCS="\x90",d.PU1="\x91",d.PU2="\x92",d.STS="\x93",d.CCH="\x94",d.MW="\x95",d.SPA="\x96",d.EPA="\x97",d.SOS="\x98",d.SGCI="\x99",d.SCI="\x9A",d.CSI="\x9B",d.ST="\x9C",d.OSC="\x9D",d.PM="\x9E",d.APC="\x9F"}(u||(a.C1=u={})),function(d){d.ST=`${c.ESC}\\`}(l||(a.C1_ESCAPED=l={}))},726:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.Utf8ToUtf32=a.StringToUtf32=void 0,a.stringFromCodePoint=function(c){return c>65535?(c-=65536,String.fromCharCode(55296+(c>>10))+String.fromCharCode(c%1024+56320)):String.fromCharCode(c)},a.utf32ToString=function(c,u=0,l=c.length){let d="";for(let p=u;p<l;++p){let f=c[p];f>65535?(f-=65536,d+=String.fromCharCode(55296+(f>>10))+String.fromCharCode(f%1024+56320)):d+=String.fromCharCode(f)}return d},a.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(c,u){let l=c.length;if(!l)return 0;let d=0,p=0;if(this._interim){let f=c.charCodeAt(p++);56320<=f&&f<=57343?u[d++]=1024*(this._interim-55296)+f-56320+65536:(u[d++]=this._interim,u[d++]=f),this._interim=0}for(let f=p;f<l;++f){let m=c.charCodeAt(f);if(55296<=m&&m<=56319){if(++f>=l)return this._interim=m,d;let h=c.charCodeAt(f);56320<=h&&h<=57343?u[d++]=1024*(m-55296)+h-56320+65536:(u[d++]=m,u[d++]=h)}else m!==65279&&(u[d++]=m)}return d}},a.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(c,u){let l=c.length;if(!l)return 0;let d,p,f,m,h=0,g=0,_=0;if(this.interim[0]){let b=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let T,I=0;for(;(T=63&this.interim[++I])&&I<4;)S<<=6,S|=T;let R=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,F=R-I;for(;_<F;){if(_>=l)return 0;if(T=c[_++],(192&T)!=128){_--,b=!0;break}this.interim[I++]=T,S<<=6,S|=63&T}b||(R===2?S<128?_--:u[h++]=S:R===3?S<2048||S>=55296&&S<=57343||S===65279||(u[h++]=S):S<65536||S>1114111||(u[h++]=S)),this.interim.fill(0)}let y=l-4,x=_;for(;x<l;){for(;!(!(x<y)||128&(d=c[x])||128&(p=c[x+1])||128&(f=c[x+2])||128&(m=c[x+3]));)u[h++]=d,u[h++]=p,u[h++]=f,u[h++]=m,x+=4;if(d=c[x++],d<128)u[h++]=d;else if((224&d)==192){if(x>=l)return this.interim[0]=d,h;if(p=c[x++],(192&p)!=128){x--;continue}if(g=(31&d)<<6|63&p,g<128){x--;continue}u[h++]=g}else if((240&d)==224){if(x>=l)return this.interim[0]=d,h;if(p=c[x++],(192&p)!=128){x--;continue}if(x>=l)return this.interim[0]=d,this.interim[1]=p,h;if(f=c[x++],(192&f)!=128){x--;continue}if(g=(15&d)<<12|(63&p)<<6|63&f,g<2048||g>=55296&&g<=57343||g===65279)continue;u[h++]=g}else if((248&d)==240){if(x>=l)return this.interim[0]=d,h;if(p=c[x++],(192&p)!=128){x--;continue}if(x>=l)return this.interim[0]=d,this.interim[1]=p,h;if(f=c[x++],(192&f)!=128){x--;continue}if(x>=l)return this.interim[0]=d,this.interim[1]=p,this.interim[2]=f,h;if(m=c[x++],(192&m)!=128){x--;continue}if(g=(7&d)<<18|(63&p)<<12|(63&f)<<6|63&m,g<65536||g>1114111)continue;u[h++]=g}}return h}}},7428:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.UnicodeV6=void 0;let u=c(6415),l=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],d=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],p;a.UnicodeV6=class{constructor(){if(this.version="6",!p){p=new Uint8Array(65536),p.fill(1),p[0]=0,p.fill(0,1,32),p.fill(0,127,160),p.fill(2,4352,4448),p[9001]=2,p[9002]=2,p.fill(2,11904,42192),p[12351]=1,p.fill(2,44032,55204),p.fill(2,63744,64256),p.fill(2,65040,65050),p.fill(2,65072,65136),p.fill(2,65280,65377),p.fill(2,65504,65511);for(let f=0;f<l.length;++f)p.fill(0,l[f][0],l[f][1]+1)}}wcwidth(f){return f<32?0:f<127?1:f<65536?p[f]:function(m,h){let g,_=0,y=h.length-1;if(m<h[0][0]||m>h[y][1])return!1;for(;y>=_;)if(g=_+y>>1,m>h[g][1])_=g+1;else{if(!(m<h[g][0]))return!0;y=g-1}return!1}(f,d)?0:f>=131072&&f<=196605||f>=196608&&f<=262141?2:1}charProperties(f,m){let h=this.wcwidth(f),g=h===0&&m!==0;if(g){let _=u.UnicodeService.extractWidth(m);_===0?g=!1:_>h&&(h=_)}return u.UnicodeService.createPropertyValue(0,h,g)}}},3562:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.WriteBuffer=void 0;let u=c(7150),l=c(802);class d extends u.Disposable{constructor(p){super(),this._action=p,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new l.Emitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(p,f){if(f!==void 0&&this._syncCalls>f)return void(this._syncCalls=0);if(this._pendingData+=p.length,this._writeBuffer.push(p),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let m;for(this._isSyncWriting=!0;m=this._writeBuffer.shift();){this._action(m);let h=this._callbacks.shift();h&&h()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(p,f){if(this._pendingData>50000000)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=p.length,this._writeBuffer.push(p),this._callbacks.push(f),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=p.length,this._writeBuffer.push(p),this._callbacks.push(f)}_innerWrite(p=0,f=!0){let m=p||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let h=this._writeBuffer[this._bufferOffset],g=this._action(h,f);if(g){let y=(x)=>performance.now()-m>=12?setTimeout(()=>this._innerWrite(0,x)):this._innerWrite(m,x);return void g.catch((x)=>(queueMicrotask(()=>{throw x}),Promise.resolve(!1))).then(y)}let _=this._callbacks[this._bufferOffset];if(_&&_(),this._bufferOffset++,this._pendingData-=h.length,performance.now()-m>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}a.WriteBuffer=d},8693:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.parseColor=function(d){if(!d)return;let p=d.toLowerCase();if(p.indexOf("rgb:")===0){p=p.slice(4);let f=c.exec(p);if(f){let m=f[1]?15:f[4]?255:f[7]?4095:65535;return[Math.round(parseInt(f[1]||f[4]||f[7]||f[10],16)/m*255),Math.round(parseInt(f[2]||f[5]||f[8]||f[11],16)/m*255),Math.round(parseInt(f[3]||f[6]||f[9]||f[12],16)/m*255)]}}else if(p.indexOf("#")===0&&(p=p.slice(1),u.exec(p)&&[3,6,9,12].includes(p.length))){let f=p.length/3,m=[0,0,0];for(let h=0;h<3;++h){let g=parseInt(p.slice(f*h,f*h+f),16);m[h]=f===1?g<<4:f===2?g:f===3?g>>4:g>>8}return m}},a.toRgbString=function(d,p=16){let[f,m,h]=d;return`rgb:${l(f,p)}/${l(m,p)}/${l(h,p)}`};let c=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,u=/^[\da-f]+$/;function l(d,p){let f=d.toString(16),m=f.length<2?"0"+f:f;switch(p){case 4:return f[0];case 8:return m;case 12:return(m+m).slice(0,3);default:return m+m}}},1263:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.PAYLOAD_LIMIT=void 0,a.PAYLOAD_LIMIT=1e7},9823:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.DcsHandler=a.DcsParser=void 0;let u=c(726),l=c(7262),d=c(1263),p=[];a.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=p,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}registerHandler(m,h){this._handlers[m]===void 0&&(this._handlers[m]=[]);let g=this._handlers[m];return g.push(h),{dispose:()=>{let _=g.indexOf(h);_!==-1&&g.splice(_,1)}}}clearHandler(m){this._handlers[m]&&delete this._handlers[m]}setHandlerFallback(m){this._handlerFb=m}reset(){if(this._active.length)for(let m=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;m>=0;--m)this._active[m].unhook(!1);this._stack.paused=!1,this._active=p,this._ident=0}hook(m,h){if(this.reset(),this._ident=m,this._active=this._handlers[m]||p,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].hook(h);else this._handlerFb(this._ident,"HOOK",h)}put(m,h,g){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(m,h,g);else this._handlerFb(this._ident,"PUT",(0,u.utf32ToString)(m,h,g))}unhook(m,h=!0){if(this._active.length){let g=!1,_=this._active.length-1,y=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,g=h,y=this._stack.fallThrough,this._stack.paused=!1),!y&&g===!1){for(;_>=0&&(g=this._active[_].unhook(m),g!==!0);_--)if(g instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,g;_--}for(;_>=0;_--)if(g=this._active[_].unhook(!1),g instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!0,g}else this._handlerFb(this._ident,"UNHOOK",m);this._active=p,this._ident=0}};let f=new l.Params;f.addParam(0),a.DcsHandler=class{constructor(m){this._handler=m,this._data="",this._params=f,this._hitLimit=!1}hook(m){this._params=m.length>1||m.params[0]?m.clone():f,this._data="",this._hitLimit=!1}put(m,h,g){this._hitLimit||(this._data+=(0,u.utf32ToString)(m,h,g),this._data.length>d.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(m){let h=!1;if(this._hitLimit)h=!1;else if(m&&(h=this._handler(this._data,this._params),h instanceof Promise))return h.then((g)=>(this._params=f,this._data="",this._hitLimit=!1,g));return this._params=f,this._data="",this._hitLimit=!1,h}}},6717:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.EscapeSequenceParser=a.VT500_TRANSITION_TABLE=a.TransitionTable=void 0;let u=c(7150),l=c(7262),d=c(1346),p=c(9823);class f{constructor(g){this.table=new Uint8Array(g)}setDefault(g,_){this.table.fill(g<<4|_)}add(g,_,y,x){this.table[_<<8|g]=y<<4|x}addMany(g,_,y,x){for(let b=0;b<g.length;b++)this.table[_<<8|g[b]]=y<<4|x}}a.TransitionTable=f;let m=160;a.VT500_TRANSITION_TABLE=function(){let g=new f(4095),_=Array.apply(null,Array(256)).map((I,R)=>R),y=(I,R)=>_.slice(I,R),x=y(32,127),b=y(0,24);b.push(25),b.push.apply(b,y(28,32));let S=y(0,14),T;for(T in g.setDefault(1,0),g.addMany(x,0,2,0),S)g.addMany([24,26,153,154],T,3,0),g.addMany(y(128,144),T,3,0),g.addMany(y(144,152),T,3,0),g.add(156,T,0,0),g.add(27,T,11,1),g.add(157,T,4,8),g.addMany([152,158,159],T,0,7),g.add(155,T,11,3),g.add(144,T,11,9);return g.addMany(b,0,3,0),g.addMany(b,1,3,1),g.add(127,1,0,1),g.addMany(b,8,0,8),g.addMany(b,3,3,3),g.add(127,3,0,3),g.addMany(b,4,3,4),g.add(127,4,0,4),g.addMany(b,6,3,6),g.addMany(b,5,3,5),g.add(127,5,0,5),g.addMany(b,2,3,2),g.add(127,2,0,2),g.add(93,1,4,8),g.addMany(x,8,5,8),g.add(127,8,5,8),g.addMany([156,27,24,26,7],8,6,0),g.addMany(y(28,32),8,0,8),g.addMany([88,94,95],1,0,7),g.addMany(x,7,0,7),g.addMany(b,7,0,7),g.add(156,7,0,0),g.add(127,7,0,7),g.add(91,1,11,3),g.addMany(y(64,127),3,7,0),g.addMany(y(48,60),3,8,4),g.addMany([60,61,62,63],3,9,4),g.addMany(y(48,60),4,8,4),g.addMany(y(64,127),4,7,0),g.addMany([60,61,62,63],4,0,6),g.addMany(y(32,64),6,0,6),g.add(127,6,0,6),g.addMany(y(64,127),6,0,0),g.addMany(y(32,48),3,9,5),g.addMany(y(32,48),5,9,5),g.addMany(y(48,64),5,0,6),g.addMany(y(64,127),5,7,0),g.addMany(y(32,48),4,9,5),g.addMany(y(32,48),1,9,2),g.addMany(y(32,48),2,9,2),g.addMany(y(48,127),2,10,0),g.addMany(y(48,80),1,10,0),g.addMany(y(81,88),1,10,0),g.addMany([89,90,92],1,10,0),g.addMany(y(96,127),1,10,0),g.add(80,1,11,9),g.addMany(b,9,0,9),g.add(127,9,0,9),g.addMany(y(28,32),9,0,9),g.addMany(y(32,48),9,9,12),g.addMany(y(48,60),9,8,10),g.addMany([60,61,62,63],9,9,10),g.addMany(b,11,0,11),g.addMany(y(32,128),11,0,11),g.addMany(y(28,32),11,0,11),g.addMany(b,10,0,10),g.add(127,10,0,10),g.addMany(y(28,32),10,0,10),g.addMany(y(48,60),10,8,10),g.addMany([60,61,62,63],10,0,11),g.addMany(y(32,48),10,9,12),g.addMany(b,12,0,12),g.add(127,12,0,12),g.addMany(y(28,32),12,0,12),g.addMany(y(32,48),12,9,12),g.addMany(y(48,64),12,0,11),g.addMany(y(64,127),12,12,13),g.addMany(y(64,127),10,12,13),g.addMany(y(64,127),9,12,13),g.addMany(b,13,13,13),g.addMany(x,13,13,13),g.add(127,13,0,13),g.addMany([27,156,24,26],13,14,0),g.add(m,0,2,0),g.add(m,8,5,8),g.add(m,6,0,6),g.add(m,11,0,11),g.add(m,13,13,13),g}();class h extends u.Disposable{constructor(g=a.VT500_TRANSITION_TABLE){super(),this._transitions=g,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new l.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(_,y,x)=>{},this._executeHandlerFb=(_)=>{},this._csiHandlerFb=(_,y)=>{},this._escHandlerFb=(_)=>{},this._errorHandlerFb=(_)=>_,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register((0,u.toDisposable)(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new d.OscParser),this._dcsParser=this._register(new p.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(g,_=[64,126]){let y=0;if(g.prefix){if(g.prefix.length>1)throw Error("only one byte as prefix supported");if(y=g.prefix.charCodeAt(0),y&&60>y||y>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(g.intermediates){if(g.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let b=0;b<g.intermediates.length;++b){let S=g.intermediates.charCodeAt(b);if(32>S||S>47)throw Error("intermediate must be in range 0x20 .. 0x2f");y<<=8,y|=S}}if(g.final.length!==1)throw Error("final must be a single byte");let x=g.final.charCodeAt(0);if(_[0]>x||x>_[1])throw Error(`final must be in range ${_[0]} .. ${_[1]}`);return y<<=8,y|=x,y}identToString(g){let _=[];for(;g;)_.push(String.fromCharCode(255&g)),g>>=8;return _.reverse().join("")}setPrintHandler(g){this._printHandler=g}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(g,_){let y=this._identifier(g,[48,126]);this._escHandlers[y]===void 0&&(this._escHandlers[y]=[]);let x=this._escHandlers[y];return x.push(_),{dispose:()=>{let b=x.indexOf(_);b!==-1&&x.splice(b,1)}}}clearEscHandler(g){this._escHandlers[this._identifier(g,[48,126])]&&delete this._escHandlers[this._identifier(g,[48,126])]}setEscHandlerFallback(g){this._escHandlerFb=g}setExecuteHandler(g,_){this._executeHandlers[g.charCodeAt(0)]=_}clearExecuteHandler(g){this._executeHandlers[g.charCodeAt(0)]&&delete this._executeHandlers[g.charCodeAt(0)]}setExecuteHandlerFallback(g){this._executeHandlerFb=g}registerCsiHandler(g,_){let y=this._identifier(g);this._csiHandlers[y]===void 0&&(this._csiHandlers[y]=[]);let x=this._csiHandlers[y];return x.push(_),{dispose:()=>{let b=x.indexOf(_);b!==-1&&x.splice(b,1)}}}clearCsiHandler(g){this._csiHandlers[this._identifier(g)]&&delete this._csiHandlers[this._identifier(g)]}setCsiHandlerFallback(g){this._csiHandlerFb=g}registerDcsHandler(g,_){return this._dcsParser.registerHandler(this._identifier(g),_)}clearDcsHandler(g){this._dcsParser.clearHandler(this._identifier(g))}setDcsHandlerFallback(g){this._dcsParser.setHandlerFallback(g)}registerOscHandler(g,_){return this._oscParser.registerHandler(g,_)}clearOscHandler(g){this._oscParser.clearHandler(g)}setOscHandlerFallback(g){this._oscParser.setHandlerFallback(g)}setErrorHandler(g){this._errorHandler=g}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(g,_,y,x,b){this._parseStack.state=g,this._parseStack.handlers=_,this._parseStack.handlerPos=y,this._parseStack.transition=x,this._parseStack.chunkPos=b}parse(g,_,y){let x,b=0,S=0,T=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,T=this._parseStack.chunkPos+1;else{if(y===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let I=this._parseStack.handlers,R=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(y===!1&&R>-1){for(;R>=0&&(x=I[R](this._params),x!==!0);R--)if(x instanceof Promise)return this._parseStack.handlerPos=R,x}this._parseStack.handlers=[];break;case 4:if(y===!1&&R>-1){for(;R>=0&&(x=I[R](),x!==!0);R--)if(x instanceof Promise)return this._parseStack.handlerPos=R,x}this._parseStack.handlers=[];break;case 6:if(b=g[this._parseStack.chunkPos],x=this._dcsParser.unhook(b!==24&&b!==26,y),x)return x;b===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(b=g[this._parseStack.chunkPos],x=this._oscParser.end(b!==24&&b!==26,y),x)return x;b===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,T=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let I=T;I<_;++I){switch(b=g[I],S=this._transitions.table[this.currentState<<8|(b<160?b:m)],S>>4){case 2:for(let K=I+1;;++K){if(K>=_||(b=g[K])<32||b>126&&b<m){this._printHandler(g,I,K),I=K-1;break}if(++K>=_||(b=g[K])<32||b>126&&b<m){this._printHandler(g,I,K),I=K-1;break}if(++K>=_||(b=g[K])<32||b>126&&b<m){this._printHandler(g,I,K),I=K-1;break}if(++K>=_||(b=g[K])<32||b>126&&b<m){this._printHandler(g,I,K),I=K-1;break}}break;case 3:this._executeHandlers[b]?this._executeHandlers[b]():this._executeHandlerFb(b),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:I,code:b,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let R=this._csiHandlers[this._collect<<8|b],F=R?R.length-1:-1;for(;F>=0&&(x=R[F](this._params),x!==!0);F--)if(x instanceof Promise)return this._preserveStack(3,R,F,S,I),x;F<0&&this._csiHandlerFb(this._collect<<8|b,this._params),this.precedingJoinState=0;break;case 8:do switch(b){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(b-48)}while(++I<_&&(b=g[I])>47&&b<60);I--;break;case 9:this._collect<<=8,this._collect|=b;break;case 10:let z=this._escHandlers[this._collect<<8|b],j=z?z.length-1:-1;for(;j>=0&&(x=z[j](),x!==!0);j--)if(x instanceof Promise)return this._preserveStack(4,z,j,S,I),x;j<0&&this._escHandlerFb(this._collect<<8|b),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|b,this._params);break;case 13:for(let K=I+1;;++K)if(K>=_||(b=g[K])===24||b===26||b===27||b>127&&b<m){this._dcsParser.put(g,I,K),I=K-1;break}break;case 14:if(x=this._dcsParser.unhook(b!==24&&b!==26),x)return this._preserveStack(6,[],0,S,I),x;b===27&&(S|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let K=I+1;;K++)if(K>=_||(b=g[K])<32||b>127&&b<m){this._oscParser.put(g,I,K),I=K-1;break}break;case 6:if(x=this._oscParser.end(b!==24&&b!==26),x)return this._preserveStack(5,[],0,S,I),x;b===27&&(S|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&S}}}a.EscapeSequenceParser=h},1346:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.OscHandler=a.OscParser=void 0;let u=c(1263),l=c(726),d=[];a.OscParser=class{constructor(){this._state=0,this._active=d,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(p,f){this._handlers[p]===void 0&&(this._handlers[p]=[]);let m=this._handlers[p];return m.push(f),{dispose:()=>{let h=m.indexOf(f);h!==-1&&m.splice(h,1)}}}clearHandler(p){this._handlers[p]&&delete this._handlers[p]}setHandlerFallback(p){this._handlerFb=p}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=d}reset(){if(this._state===2)for(let p=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;p>=0;--p)this._active[p].end(!1);this._stack.paused=!1,this._active=d,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||d,this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].start();else this._handlerFb(this._id,"START")}_put(p,f,m){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(p,f,m);else this._handlerFb(this._id,"PUT",(0,l.utf32ToString)(p,f,m))}start(){this.reset(),this._state=1}put(p,f,m){if(this._state!==3){if(this._state===1)for(;f<m;){let h=p[f++];if(h===59){this._state=2,this._start();break}if(h<48||57<h)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+h-48}this._state===2&&m-f>0&&this._put(p,f,m)}}end(p,f=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let m=!1,h=this._active.length-1,g=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,m=f,g=this._stack.fallThrough,this._stack.paused=!1),!g&&m===!1){for(;h>=0&&(m=this._active[h].end(p),m!==!0);h--)if(m instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,m;h--}for(;h>=0;h--)if(m=this._active[h].end(!1),m instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,m}else this._handlerFb(this._id,"END",p);this._active=d,this._id=-1,this._state=0}}},a.OscHandler=class{constructor(p){this._handler=p,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(p,f,m){this._hitLimit||(this._data+=(0,l.utf32ToString)(p,f,m),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(p){let f=!1;if(this._hitLimit)f=!1;else if(p&&(f=this._handler(this._data),f instanceof Promise))return f.then((m)=>(this._data="",this._hitLimit=!1,m));return this._data="",this._hitLimit=!1,f}}},7262:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.Params=void 0;let c=2147483647;class u{static fromArray(l){let d=new u;if(!l.length)return d;for(let p=Array.isArray(l[0])?1:0;p<l.length;++p){let f=l[p];if(Array.isArray(f))for(let m=0;m<f.length;++m)d.addSubParam(f[m]);else d.addParam(f)}return d}constructor(l=32,d=32){if(this.maxLength=l,this.maxSubParamsLength=d,d>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(l),this.length=0,this._subParams=new Int32Array(d),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(l),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){let l=new u(this.maxLength,this.maxSubParamsLength);return l.params.set(this.params),l.length=this.length,l._subParams.set(this._subParams),l._subParamsLength=this._subParamsLength,l._subParamsIdx.set(this._subParamsIdx),l._rejectDigits=this._rejectDigits,l._rejectSubDigits=this._rejectSubDigits,l._digitIsSub=this._digitIsSub,l}toArray(){let l=[];for(let d=0;d<this.length;++d){l.push(this.params[d]);let p=this._subParamsIdx[d]>>8,f=255&this._subParamsIdx[d];f-p>0&&l.push(Array.prototype.slice.call(this._subParams,p,f))}return l}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(l){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(l<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=l>c?c:l}}addSubParam(l){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(l<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=l>c?c:l,this._subParamsIdx[this.length-1]++}}hasSubParams(l){return(255&this._subParamsIdx[l])-(this._subParamsIdx[l]>>8)>0}getSubParams(l){let d=this._subParamsIdx[l]>>8,p=255&this._subParamsIdx[l];return p-d>0?this._subParams.subarray(d,p):null}getSubParamsAll(){let l={};for(let d=0;d<this.length;++d){let p=this._subParamsIdx[d]>>8,f=255&this._subParamsIdx[d];f-p>0&&(l[d]=this._subParams.slice(p,f))}return l}addDigit(l){let d;if(this._rejectDigits||!(d=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let p=this._digitIsSub?this._subParams:this.params,f=p[d-1];p[d-1]=~f?Math.min(10*f+l,c):l}}a.Params=u},3027:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.AddonManager=void 0,a.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let c=this._addons.length-1;c>=0;c--)this._addons[c].instance.dispose()}loadAddon(c,u){let l={instance:u,dispose:u.dispose,isDisposed:!1};this._addons.push(l),u.dispose=()=>this._wrappedAddonDispose(l),u.activate(c)}_wrappedAddonDispose(c){if(c.isDisposed)return;let u=-1;for(let l=0;l<this._addons.length;l++)if(this._addons[l]===c){u=l;break}if(u===-1)throw Error("Could not dispose an addon that has not been loaded");c.isDisposed=!0,c.dispose.apply(c.instance),this._addons.splice(u,1)}}},3235:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BufferApiView=void 0;let u=c(793),l=c(3055);a.BufferApiView=class{constructor(d,p){this._buffer=d,this.type=p}init(d){return this._buffer=d,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(d){let p=this._buffer.lines.get(d);if(p)return new u.BufferLineApiView(p)}getNullCell(){return new l.CellData}}},793:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BufferLineApiView=void 0;let u=c(3055);a.BufferLineApiView=class{constructor(l){this._line=l}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(l,d){if(!(l<0||l>=this._line.length))return d?(this._line.loadCell(l,d),d):this._line.loadCell(l,new u.CellData)}translateToString(l,d,p){return this._line.translateToString(l,d,p)}}},5101:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BufferNamespaceApi=void 0;let u=c(3235),l=c(7150),d=c(802);class p extends l.Disposable{constructor(f){super(),this._core=f,this._onBufferChange=this._register(new d.Emitter),this.onBufferChange=this._onBufferChange.event,this._normal=new u.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new u.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}a.BufferNamespaceApi=p},6097:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ParserApi=void 0,a.ParserApi=class{constructor(c){this._core=c}registerCsiHandler(c,u){return this._core.registerCsiHandler(c,(l)=>u(l.toArray()))}addCsiHandler(c,u){return this.registerCsiHandler(c,u)}registerDcsHandler(c,u){return this._core.registerDcsHandler(c,(l,d)=>u(l,d.toArray()))}addDcsHandler(c,u){return this.registerDcsHandler(c,u)}registerEscHandler(c,u){return this._core.registerEscHandler(c,u)}addEscHandler(c,u){return this.registerEscHandler(c,u)}registerOscHandler(c,u){return this._core.registerOscHandler(c,u)}addOscHandler(c,u){return this.registerOscHandler(c,u)}}},4335:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.UnicodeApi=void 0,a.UnicodeApi=class{constructor(c){this._core=c}register(c){this._core.unicodeService.register(c)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(c){this._core.unicodeService.activeVersion=c}}},9640:function(s,a,c){var u=this&&this.__decorate||function(g,_,y,x){var b,S=arguments.length,T=S<3?_:x===null?x=Object.getOwnPropertyDescriptor(_,y):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(g,_,y,x);else for(var I=g.length-1;I>=0;I--)(b=g[I])&&(T=(S<3?b(T):S>3?b(_,y,T):b(_,y))||T);return S>3&&T&&Object.defineProperty(_,y,T),T},l=this&&this.__param||function(g,_){return function(y,x){_(y,x,g)}};Object.defineProperty(a,"__esModule",{value:!0}),a.BufferService=a.MINIMUM_ROWS=a.MINIMUM_COLS=void 0;let d=c(7150),p=c(4097),f=c(6501),m=c(802);a.MINIMUM_COLS=2,a.MINIMUM_ROWS=1;let h=class extends d.Disposable{get buffer(){return this.buffers.active}constructor(g){super(),this.isUserScrolling=!1,this._onResize=this._register(new m.Emitter),this.onResize=this._onResize.event,this._onScroll=this._register(new m.Emitter),this.onScroll=this._onScroll.event,this.cols=Math.max(g.rawOptions.cols||0,a.MINIMUM_COLS),this.rows=Math.max(g.rawOptions.rows||0,a.MINIMUM_ROWS),this.buffers=this._register(new p.BufferSet(g,this)),this._register(this.buffers.onBufferActivate((_)=>{this._onScroll.fire(_.activeBuffer.ydisp)}))}resize(g,_){let y=this.cols!==g,x=this.rows!==_;this.cols=g,this.rows=_,this.buffers.resize(g,_),this._onResize.fire({cols:g,rows:_,colsChanged:y,rowsChanged:x})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(g,_=!1){let y=this.buffer,x;x=this._cachedBlankLine,x&&x.length===this.cols&&x.getFg(0)===g.fg&&x.getBg(0)===g.bg||(x=y.getBlankLine(g,_),this._cachedBlankLine=x),x.isWrapped=_;let b=y.ybase+y.scrollTop,S=y.ybase+y.scrollBottom;if(y.scrollTop===0){let T=y.lines.isFull;S===y.lines.length-1?T?y.lines.recycle().copyFrom(x):y.lines.push(x.clone()):y.lines.splice(S+1,0,x.clone()),T?this.isUserScrolling&&(y.ydisp=Math.max(y.ydisp-1,0)):(y.ybase++,this.isUserScrolling||y.ydisp++)}else{let T=S-b+1;y.lines.shiftElements(b+1,T-1,-1),y.lines.set(S,x.clone())}this.isUserScrolling||(y.ydisp=y.ybase),this._onScroll.fire(y.ydisp)}scrollLines(g,_){let y=this.buffer;if(g<0){if(y.ydisp===0)return;this.isUserScrolling=!0}else g+y.ydisp>=y.ybase&&(this.isUserScrolling=!1);let x=y.ydisp;y.ydisp=Math.max(Math.min(y.ydisp+g,y.ybase),0),x!==y.ydisp&&(_||this._onScroll.fire(y.ydisp))}};a.BufferService=h,a.BufferService=h=u([l(0,f.IOptionsService)],h)},5746:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.CharsetService=void 0,a.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(c){this.glevel=c,this.charset=this._charsets[c]}setgCharset(c,u){this._charsets[c]=u,this.glevel===c&&(this.charset=u)}}},7792:function(s,a,c){var u=this&&this.__decorate||function(x,b,S,T){var I,R=arguments.length,F=R<3?b:T===null?T=Object.getOwnPropertyDescriptor(b,S):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")F=Reflect.decorate(x,b,S,T);else for(var z=x.length-1;z>=0;z--)(I=x[z])&&(F=(R<3?I(F):R>3?I(b,S,F):I(b,S))||F);return R>3&&F&&Object.defineProperty(b,S,F),F},l=this&&this.__param||function(x,b){return function(S,T){b(S,T,x)}};Object.defineProperty(a,"__esModule",{value:!0}),a.CoreMouseService=void 0;let d=c(6501),p=c(7150),f=c(802),m={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:(x)=>x.button!==4&&x.action===1&&(x.ctrl=!1,x.alt=!1,x.shift=!1,!0)},VT200:{events:19,restrict:(x)=>x.action!==32},DRAG:{events:23,restrict:(x)=>x.action!==32||x.button!==3},ANY:{events:31,restrict:(x)=>!0}};function h(x,b){let S=(x.ctrl?16:0)|(x.shift?4:0)|(x.alt?8:0);return x.button===4?(S|=64,S|=x.action):(S|=3&x.button,4&x.button&&(S|=64),8&x.button&&(S|=128),x.action===32?S|=32:x.action!==0||b||(S|=3)),S}let g=String.fromCharCode,_={DEFAULT:(x)=>{let b=[h(x,!1)+32,x.col+32,x.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${g(b[0])}${g(b[1])}${g(b[2])}`},SGR:(x)=>{let b=x.action===0&&x.button!==4?"m":"M";return`\x1B[<${h(x,!0)};${x.col};${x.row}${b}`},SGR_PIXELS:(x)=>{let b=x.action===0&&x.button!==4?"m":"M";return`\x1B[<${h(x,!0)};${x.x};${x.y}${b}`}},y=class extends p.Disposable{constructor(x,b,S){super(),this._bufferService=x,this._coreService=b,this._optionsService=S,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new f.Emitter),this.onProtocolChange=this._onProtocolChange.event;for(let T of Object.keys(m))this.addProtocol(T,m[T]);for(let T of Object.keys(_))this.addEncoding(T,_[T]);this.reset()}addProtocol(x,b){this._protocols[x]=b}addEncoding(x,b){this._encodings[x]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(x){if(!this._protocols[x])throw Error(`unknown protocol "${x}"`);this._activeProtocol=x,this._onProtocolChange.fire(this._protocols[x].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(x){if(!this._encodings[x])throw Error(`unknown encoding "${x}"`);this._activeEncoding=x}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(x,b,S){if(x.deltaY===0||x.shiftKey)return 0;if(b===void 0||S===void 0)return 0;let T=b/S,I=this._applyScrollModifier(x.deltaY,x);return x.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(I/=T+0,Math.abs(x.deltaY)<50&&(I*=0.3),this._wheelPartialScroll+=I,I=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):x.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(I*=this._bufferService.rows),I}_applyScrollModifier(x,b){return b.altKey||b.ctrlKey||b.shiftKey?x*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:x*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(x){if(x.col<0||x.col>=this._bufferService.cols||x.row<0||x.row>=this._bufferService.rows)return!1;if(x.button===4&&x.action===32)return!1;if(x.button===3&&x.action!==32)return!1;if(x.button!==4&&(x.action===2||x.action===3))return!1;if(x.col++,x.row++,x.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,x,this._activeEncoding==="SGR_PIXELS"))return!1;if(!this._protocols[this._activeProtocol].restrict(x))return!1;let b=this._encodings[this._activeEncoding](x);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=x,!0}explainEvents(x){return{down:!!(1&x),up:!!(2&x),drag:!!(4&x),move:!!(8&x),wheel:!!(16&x)}}_equalEvents(x,b,S){if(S){if(x.x!==b.x)return!1;if(x.y!==b.y)return!1}else{if(x.col!==b.col)return!1;if(x.row!==b.row)return!1}return x.button===b.button&&x.action===b.action&&x.ctrl===b.ctrl&&x.alt===b.alt&&x.shift===b.shift}};a.CoreMouseService=y,a.CoreMouseService=y=u([l(0,d.IBufferService),l(1,d.ICoreService),l(2,d.IOptionsService)],y)},4071:function(s,a,c){var u=this&&this.__decorate||function(y,x,b,S){var T,I=arguments.length,R=I<3?x:S===null?S=Object.getOwnPropertyDescriptor(x,b):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(y,x,b,S);else for(var F=y.length-1;F>=0;F--)(T=y[F])&&(R=(I<3?T(R):I>3?T(x,b,R):T(x,b))||R);return I>3&&R&&Object.defineProperty(x,b,R),R},l=this&&this.__param||function(y,x){return function(b,S){x(b,S,y)}};Object.defineProperty(a,"__esModule",{value:!0}),a.CoreService=void 0;let d=c(7453),p=c(7150),f=c(6501),m=c(802),h=Object.freeze({insertMode:!1}),g=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),_=class extends p.Disposable{constructor(y,x,b){super(),this._bufferService=y,this._logService=x,this._optionsService=b,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new m.Emitter),this.onData=this._onData.event,this._onUserInput=this._register(new m.Emitter),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new m.Emitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new m.Emitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,d.clone)(h),this.decPrivateModes=(0,d.clone)(g)}reset(){this.modes=(0,d.clone)(h),this.decPrivateModes=(0,d.clone)(g)}triggerDataEvent(y,x=!1){if(this._optionsService.rawOptions.disableStdin)return;let b=this._bufferService.buffer;x&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),x&&this._onUserInput.fire(),this._logService.debug(`sending data "${y}"`),this._logService.trace("sending data (codes)",()=>y.split("").map((S)=>S.charCodeAt(0))),this._onData.fire(y)}triggerBinaryEvent(y){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${y}"`),this._logService.trace("sending binary (codes)",()=>y.split("").map((x)=>x.charCodeAt(0))),this._onBinary.fire(y))}};a.CoreService=_,a.CoreService=_=u([l(0,f.IBufferService),l(1,f.ILogService),l(2,f.IOptionsService)],_)},6025:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.InstantiationService=a.ServiceCollection=void 0;let u=c(6501),l=c(6201);class d{constructor(...p){this._entries=new Map;for(let[f,m]of p)this.set(f,m)}set(p,f){let m=this._entries.get(p);return this._entries.set(p,f),m}forEach(p){for(let[f,m]of this._entries.entries())p(f,m)}has(p){return this._entries.has(p)}get(p){return this._entries.get(p)}}a.ServiceCollection=d,a.InstantiationService=class{constructor(){this._services=new d,this._services.set(u.IInstantiationService,this)}setService(p,f){this._services.set(p,f)}getService(p){return this._services.get(p)}createInstance(p,...f){let m=(0,l.getServiceDependencies)(p).sort((_,y)=>_.index-y.index),h=[];for(let _ of m){let y=this._services.get(_.id);if(!y)throw Error(`[createInstance] ${p.name} depends on UNKNOWN service ${_.id._id}.`);h.push(y)}let g=m.length>0?m[0].index:f.length;if(f.length!==g)throw Error(`[createInstance] First service dependency of ${p.name} at position ${g+1} conflicts with ${f.length} static arguments`);return new p(...[...f,...h])}}},7276:function(s,a,c){var u=this&&this.__decorate||function(g,_,y,x){var b,S=arguments.length,T=S<3?_:x===null?x=Object.getOwnPropertyDescriptor(_,y):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(g,_,y,x);else for(var I=g.length-1;I>=0;I--)(b=g[I])&&(T=(S<3?b(T):S>3?b(_,y,T):b(_,y))||T);return S>3&&T&&Object.defineProperty(_,y,T),T},l=this&&this.__param||function(g,_){return function(y,x){_(y,x,g)}};Object.defineProperty(a,"__esModule",{value:!0}),a.LogService=void 0,a.setTraceLogger=function(g){m=g},a.traceCall=function(g,_,y){if(typeof y.value!="function")throw Error("not supported");let x=y.value;y.value=function(...b){if(m.logLevel!==p.LogLevelEnum.TRACE)return x.apply(this,b);m.trace(`GlyphRenderer#${x.name}(${b.map((T)=>JSON.stringify(T)).join(", ")})`);let S=x.apply(this,b);return m.trace(`GlyphRenderer#${x.name} return`,S),S}};let d=c(7150),p=c(6501),f={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF},m,h=class extends d.Disposable{get logLevel(){return this._logLevel}constructor(g){super(),this._optionsService=g,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),m=this}_updateLogLevel(){this._logLevel=f[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(g){for(let _=0;_<g.length;_++)typeof g[_]=="function"&&(g[_]=g[_]())}_log(g,_,y){this._evalLazyOptionalParams(y),g.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+_,...y)}trace(g,..._){this._logLevel<=p.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,g,_)}debug(g,..._){this._logLevel<=p.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,g,_)}info(g,..._){this._logLevel<=p.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,g,_)}warn(g,..._){this._logLevel<=p.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,g,_)}error(g,..._){this._logLevel<=p.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,g,_)}};a.LogService=h,a.LogService=h=u([l(0,p.IOptionsService)],h)},56:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.OptionsService=a.DEFAULT_OPTIONS=void 0;let u=c(7150),l=c(701),d=c(802);a.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1000,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:l.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}};let p=["normal","bold","100","200","300","400","500","600","700","800","900"];class f extends u.Disposable{constructor(m){super(),this._onOptionChange=this._register(new d.Emitter),this.onOptionChange=this._onOptionChange.event;let h={...a.DEFAULT_OPTIONS};for(let g in m)if(g in h)try{let _=m[g];h[g]=this._sanitizeAndValidateOption(g,_)}catch(_){console.error(_)}this.rawOptions=h,this.options={...h},this._setupOptions(),this._register((0,u.toDisposable)(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(m,h){return this.onOptionChange((g)=>{g===m&&h(this.rawOptions[m])})}onMultipleOptionChange(m,h){return this.onOptionChange((g)=>{m.indexOf(g)!==-1&&h()})}_setupOptions(){let m=(g)=>{if(!(g in a.DEFAULT_OPTIONS))throw Error(`No option with key "${g}"`);return this.rawOptions[g]},h=(g,_)=>{if(!(g in a.DEFAULT_OPTIONS))throw Error(`No option with key "${g}"`);_=this._sanitizeAndValidateOption(g,_),this.rawOptions[g]!==_&&(this.rawOptions[g]=_,this._onOptionChange.fire(g))};for(let g in this.rawOptions){let _={get:m.bind(this,g),set:h.bind(this,g)};Object.defineProperty(this.options,g,_)}}_sanitizeAndValidateOption(m,h){switch(m){case"cursorStyle":if(h||(h=a.DEFAULT_OPTIONS[m]),!function(g){return g==="block"||g==="underline"||g==="bar"}(h))throw Error(`"${h}" is not a valid value for ${m}`);break;case"wordSeparator":h||(h=a.DEFAULT_OPTIONS[m]);break;case"fontWeight":case"fontWeightBold":if(typeof h=="number"&&1<=h&&h<=1000)break;h=p.includes(h)?h:a.DEFAULT_OPTIONS[m];break;case"cursorWidth":h=Math.floor(h);case"lineHeight":case"tabStopWidth":if(h<1)throw Error(`${m} cannot be less than 1, value: ${h}`);break;case"minimumContrastRatio":h=Math.max(1,Math.min(21,Math.round(10*h)/10));break;case"scrollback":if((h=Math.min(h,4294967295))<0)throw Error(`${m} cannot be less than 0, value: ${h}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(h<=0)throw Error(`${m} cannot be less than or equal to 0, value: ${h}`);break;case"rows":case"cols":if(!h&&h!==0)throw Error(`${m} must be numeric, value: ${h}`);break;case"windowsPty":h=h??{}}return h}}a.OptionsService=f},8811:function(s,a,c){var u=this&&this.__decorate||function(f,m,h,g){var _,y=arguments.length,x=y<3?m:g===null?g=Object.getOwnPropertyDescriptor(m,h):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(f,m,h,g);else for(var b=f.length-1;b>=0;b--)(_=f[b])&&(x=(y<3?_(x):y>3?_(m,h,x):_(m,h))||x);return y>3&&x&&Object.defineProperty(m,h,x),x},l=this&&this.__param||function(f,m){return function(h,g){m(h,g,f)}};Object.defineProperty(a,"__esModule",{value:!0}),a.OscLinkService=void 0;let d=c(6501),p=class{constructor(f){this._bufferService=f,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(f){let m=this._bufferService.buffer;if(f.id===void 0){let b=m.addMarker(m.ybase+m.y),S={data:f,id:this._nextId++,lines:[b]};return b.onDispose(()=>this._removeMarkerFromLink(S,b)),this._dataByLinkId.set(S.id,S),S.id}let h=f,g=this._getEntryIdKey(h),_=this._entriesWithId.get(g);if(_)return this.addLineToLink(_.id,m.ybase+m.y),_.id;let y=m.addMarker(m.ybase+m.y),x={id:this._nextId++,key:this._getEntryIdKey(h),data:h,lines:[y]};return y.onDispose(()=>this._removeMarkerFromLink(x,y)),this._entriesWithId.set(x.key,x),this._dataByLinkId.set(x.id,x),x.id}addLineToLink(f,m){let h=this._dataByLinkId.get(f);if(h&&h.lines.every((g)=>g.line!==m)){let g=this._bufferService.buffer.addMarker(m);h.lines.push(g),g.onDispose(()=>this._removeMarkerFromLink(h,g))}}getLinkData(f){return this._dataByLinkId.get(f)?.data}_getEntryIdKey(f){return`${f.id};;${f.uri}`}_removeMarkerFromLink(f,m){let h=f.lines.indexOf(m);h!==-1&&(f.lines.splice(h,1),f.lines.length===0&&(f.data.id!==void 0&&this._entriesWithId.delete(f.key),this._dataByLinkId.delete(f.id)))}};a.OscLinkService=p,a.OscLinkService=p=u([l(0,d.IBufferService)],p)},6201:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.serviceRegistry=void 0,a.getServiceDependencies=function(l){return l[u]||[]},a.createDecorator=function(l){if(a.serviceRegistry.has(l))return a.serviceRegistry.get(l);let d=function(p,f,m){if(arguments.length!==3)throw Error("@IServiceName-decorator can only be used to decorate a parameter");(function(h,g,_){g[c]===g?g[u].push({id:h,index:_}):(g[u]=[{id:h,index:_}],g[c]=g)})(d,p,m)};return d._id=l,a.serviceRegistry.set(l,d),d};let c="di$target",u="di$dependencies";a.serviceRegistry=new Map},6501:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.IDecorationService=a.IUnicodeService=a.IOscLinkService=a.IOptionsService=a.ILogService=a.LogLevelEnum=a.IInstantiationService=a.ICharsetService=a.ICoreService=a.ICoreMouseService=a.IBufferService=void 0;let u=c(6201);var l;a.IBufferService=(0,u.createDecorator)("BufferService"),a.ICoreMouseService=(0,u.createDecorator)("CoreMouseService"),a.ICoreService=(0,u.createDecorator)("CoreService"),a.ICharsetService=(0,u.createDecorator)("CharsetService"),a.IInstantiationService=(0,u.createDecorator)("InstantiationService"),function(d){d[d.TRACE=0]="TRACE",d[d.DEBUG=1]="DEBUG",d[d.INFO=2]="INFO",d[d.WARN=3]="WARN",d[d.ERROR=4]="ERROR",d[d.OFF=5]="OFF"}(l||(a.LogLevelEnum=l={})),a.ILogService=(0,u.createDecorator)("LogService"),a.IOptionsService=(0,u.createDecorator)("OptionsService"),a.IOscLinkService=(0,u.createDecorator)("OscLinkService"),a.IUnicodeService=(0,u.createDecorator)("UnicodeService"),a.IDecorationService=(0,u.createDecorator)("DecorationService")},6415:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.UnicodeService=void 0;let u=c(7428),l=c(802);class d{static extractShouldJoin(p){return!!(1&p)}static extractWidth(p){return p>>1&3}static extractCharKind(p){return p>>3}static createPropertyValue(p,f,m=!1){return(16777215&p)<<3|(3&f)<<1|(m?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new l.Emitter,this.onChange=this._onChange.event;let p=new u.UnicodeV6;this.register(p),this._active=p.version,this._activeProvider=p}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(p){if(!this._providers[p])throw Error(`unknown Unicode version "${p}"`);this._active=p,this._activeProvider=this._providers[p],this._onChange.fire(p)}register(p){this._providers[p.version]=p}wcwidth(p){return this._activeProvider.wcwidth(p)}getStringCellWidth(p){let f=0,m=0,h=p.length;for(let g=0;g<h;++g){let _=p.charCodeAt(g);if(55296<=_&&_<=56319){if(++g>=h)return f+this.wcwidth(_);let b=p.charCodeAt(g);56320<=b&&b<=57343?_=1024*(_-55296)+b-56320+65536:f+=this.wcwidth(b)}let y=this.charProperties(_,m),x=d.extractWidth(y);d.extractShouldJoin(y)&&(x-=d.extractWidth(m)),f+=x,m=y}return f}charProperties(p,f){return this._activeProvider.charProperties(p,f)}}a.UnicodeService=d},5856:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.Terminal=void 0;let u=c(6107),l=c(5777),d=c(802);class p extends l.CoreTerminal{constructor(f={}){super(f),this._onBell=this._register(new d.Emitter),this.onBell=this._onBell.event,this._onCursorMove=this._register(new d.Emitter),this.onCursorMove=this._onCursorMove.event,this._onTitleChange=this._register(new d.Emitter),this.onTitleChange=this._onTitleChange.event,this._onA11yCharEmitter=this._register(new d.Emitter),this.onA11yChar=this._onA11yCharEmitter.event,this._onA11yTabEmitter=this._register(new d.Emitter),this.onA11yTab=this._onA11yTabEmitter.event,this._setup(),this._register(this._inputHandler.onRequestBell(()=>this.bell())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(d.Event.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(d.Event.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(d.Event.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(d.Event.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter))}get buffer(){return this.buffers.active}get markers(){return this.buffer.markers}addMarker(f){if(this.buffer===this.buffers.normal)return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+f)}bell(){this._onBell.fire()}input(f,m=!0){this.coreService.triggerDataEvent(f,m)}resize(f,m){f===this.cols&&m===this.rows||super.resize(f,m)}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let f=1;f<this.rows;f++)this.buffer.lines.push(this.buffer.getBlankLine(u.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp})}}reset(){this.options.rows=this.rows,this.options.cols=this.cols,this._setup(),super.reset()}}a.Terminal=p},3058:(s,a,c)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.Permutation=a.CallbackIterable=a.ArrayQueue=a.booleanComparator=a.numberComparator=a.CompareResult=void 0,a.tail=function(b,S=0){return b[b.length-(1+S)]},a.tail2=function(b){if(b.length===0)throw Error("Invalid tail call");return[b.slice(0,b.length-1),b[b.length-1]]},a.equals=function(b,S,T=(I,R)=>I===R){if(b===S)return!0;if(!b||!S)return!1;if(b.length!==S.length)return!1;for(let I=0,R=b.length;I<R;I++)if(!T(b[I],S[I]))return!1;return!0},a.removeFastWithoutKeepingOrder=function(b,S){let T=b.length-1;S<T&&(b[S]=b[T]),b.pop()},a.binarySearch=function(b,S,T){return d(b.length,(I)=>T(b[I],S))},a.binarySearch2=d,a.quickSelect=function b(S,T,I){if((S|=0)>=T.length)throw TypeError("invalid index");let R=T[Math.floor(T.length*Math.random())],F=[],z=[],j=[];for(let K of T){let te=I(K,R);te<0?F.push(K):te>0?z.push(K):j.push(K)}return S<F.length?b(S,F,I):S<F.length+j.length?j[0]:b(S-(F.length+j.length),z,I)},a.groupBy=function(b,S){let T=[],I;for(let R of b.slice(0).sort(S))I&&S(I[0],R)===0?I.push(R):(I=[R],T.push(I));return T},a.groupAdjacentBy=function*(b,S){let T,I;for(let R of b)I!==void 0&&S(I,R)?T.push(R):(T&&(yield T),T=[R]),I=R;T&&(yield T)},a.forEachAdjacent=function(b,S){for(let T=0;T<=b.length;T++)S(T===0?void 0:b[T-1],T===b.length?void 0:b[T])},a.forEachWithNeighbors=function(b,S){for(let T=0;T<b.length;T++)S(T===0?void 0:b[T-1],b[T],T+1===b.length?void 0:b[T+1])},a.sortedDiff=p,a.delta=function(b,S,T){let I=p(b,S,T),R=[],F=[];for(let z of I)R.push(...b.slice(z.start,z.start+z.deleteCount)),F.push(...z.toInsert);return{removed:R,added:F}},a.top=function(b,S,T){if(T===0)return[];let I=b.slice(0,T).sort(S);return f(b,S,I,T,b.length),I},a.topAsync=function(b,S,T,I,R){return T===0?Promise.resolve([]):new Promise((F,z)=>{(async()=>{let j=b.length,K=b.slice(0,T).sort(S);for(let te=T,ee=Math.min(T+I,j);te<j;te=ee,ee=Math.min(ee+I,j)){if(te>T&&await new Promise((ge)=>setTimeout(ge)),R&&R.isCancellationRequested)throw new u.CancellationError;f(b,S,K,te,ee)}return K})().then(F,z)})},a.coalesce=function(b){return b.filter((S)=>!!S)},a.coalesceInPlace=function(b){let S=0;for(let T=0;T<b.length;T++)b[T]&&(b[S]=b[T],S+=1);b.length=S},a.move=function(b,S,T){b.splice(T,0,b.splice(S,1)[0])},a.isFalsyOrEmpty=function(b){return!Array.isArray(b)||b.length===0},a.isNonEmptyArray=function(b){return Array.isArray(b)&&b.length>0},a.distinct=function(b,S=(T)=>T){let T=new Set;return b.filter((I)=>{let R=S(I);return!T.has(R)&&(T.add(R),!0)})},a.uniqueFilter=function(b){let S=new Set;return(T)=>{let I=b(T);return!S.has(I)&&(S.add(I),!0)}},a.firstOrDefault=function(b,S){return b.length>0?b[0]:S},a.lastOrDefault=function(b,S){return b.length>0?b[b.length-1]:S},a.commonPrefixLength=function(b,S,T=(I,R)=>I===R){let I=0;for(let R=0,F=Math.min(b.length,S.length);R<F&&T(b[R],S[R]);R++)I++;return I},a.range=function(b,S){let T=typeof S=="number"?b:0;typeof S=="number"?T=b:(T=0,S=b);let I=[];if(T<=S)for(let R=T;R<S;R++)I.push(R);else for(let R=T;R>S;R--)I.push(R);return I},a.index=function(b,S,T){return b.reduce((I,R)=>(I[S(R)]=T?T(R):R,I),Object.create(null))},a.insert=function(b,S){return b.push(S),()=>m(b,S)},a.remove=m,a.arrayInsert=function(b,S,T){let I=b.slice(0,S),R=b.slice(S);return I.concat(T,R)},a.shuffle=function(b,S){let T;if(typeof S=="number"){let I=S;T=()=>{let R=179426549*Math.sin(I++);return R-Math.floor(R)}}else T=Math.random;for(let I=b.length-1;I>0;I-=1){let R=Math.floor(T()*(I+1)),F=b[I];b[I]=b[R],b[R]=F}},a.pushToStart=function(b,S){let T=b.indexOf(S);T>-1&&(b.splice(T,1),b.unshift(S))},a.pushToEnd=function(b,S){let T=b.indexOf(S);T>-1&&(b.splice(T,1),b.push(S))},a.pushMany=function(b,S){for(let T of S)b.push(T)},a.mapArrayOrNot=function(b,S){return Array.isArray(b)?b.map(S):S(b)},a.asArray=function(b){return Array.isArray(b)?b:[b]},a.getRandomElement=function(b){return b[Math.floor(Math.random()*b.length)]},a.insertInto=h,a.splice=function(b,S,T,I){let R=g(b,S),F=b.splice(R,T);return F===void 0&&(F=[]),h(b,R,I),F},a.compareBy=function(b,S){return(T,I)=>S(b(T),b(I))},a.tieBreakComparators=function(...b){return(S,T)=>{for(let I of b){let R=I(S,T);if(!_.isNeitherLessOrGreaterThan(R))return R}return _.neitherLessOrGreaterThan}},a.reverseOrder=function(b){return(S,T)=>-b(S,T)};let u=c(9807),l=c(8297);function d(b,S){let T=0,I=b-1;for(;T<=I;){let R=(T+I)/2|0,F=S(R);if(F<0)T=R+1;else{if(!(F>0))return R;I=R-1}}return-(T+1)}function p(b,S,T){let I=[];function R(j,K,te){if(K===0&&te.length===0)return;let ee=I[I.length-1];ee&&ee.start+ee.deleteCount===j?(ee.deleteCount+=K,ee.toInsert.push(...te)):I.push({start:j,deleteCount:K,toInsert:te})}let F=0,z=0;for(;;){if(F===b.length){R(F,0,S.slice(z));break}if(z===S.length){R(F,b.length-F,[]);break}let j=b[F],K=S[z],te=T(j,K);te===0?(F+=1,z+=1):te<0?(R(F,1,[]),F+=1):te>0&&(R(F,0,[K]),z+=1)}return I}function f(b,S,T,I,R){for(let F=T.length;I<R;I++){let z=b[I];if(S(z,T[F-1])<0){T.pop();let j=(0,l.findFirstIdxMonotonousOrArrLen)(T,(K)=>S(z,K)<0);T.splice(j,0,z)}}}function m(b,S){let T=b.indexOf(S);if(T>-1)return b.splice(T,1),S}function h(b,S,T){let I=g(b,S),R=b.length,F=T.length;b.length=R+F;for(let z=R-1;z>=I;z--)b[z+F]=b[z];for(let z=0;z<F;z++)b[z+I]=T[z]}function g(b,S){return S<0?Math.max(S+b.length,0):Math.min(S,b.length)}var _;(function(b){b.isLessThan=function(S){return S<0},b.isLessThanOrEqual=function(S){return S<=0},b.isGreaterThan=function(S){return S>0},b.isNeitherLessOrGreaterThan=function(S){return S===0},b.greaterThan=1,b.lessThan=-1,b.neitherLessOrGreaterThan=0})(_||(a.CompareResult=_={})),a.numberComparator=(b,S)=>b-S,a.booleanComparator=(b,S)=>(0,a.numberComparator)(b?1:0,S?1:0),a.ArrayQueue=class{constructor(b){this.items=b,this.firstIdx=0,this.lastIdx=this.items.length-1}get length(){return this.lastIdx-this.firstIdx+1}takeWhile(b){let S=this.firstIdx;for(;S<this.items.length&&b(this.items[S]);)S++;let T=S===this.firstIdx?null:this.items.slice(this.firstIdx,S);return this.firstIdx=S,T}takeFromEndWhile(b){let S=this.lastIdx;for(;S>=0&&b(this.items[S]);)S--;let T=S===this.lastIdx?null:this.items.slice(S+1,this.lastIdx+1);return this.lastIdx=S,T}peek(){if(this.length!==0)return this.items[this.firstIdx]}peekLast(){if(this.length!==0)return this.items[this.lastIdx]}dequeue(){let b=this.items[this.firstIdx];return this.firstIdx++,b}removeLast(){let b=this.items[this.lastIdx];return this.lastIdx--,b}takeCount(b){let S=this.items.slice(this.firstIdx,this.firstIdx+b);return this.firstIdx+=b,S}};class y{static{this.empty=new y((b)=>{})}constructor(b){this.iterate=b}forEach(b){this.iterate((S)=>(b(S),!0))}toArray(){let b=[];return this.iterate((S)=>(b.push(S),!0)),b}filter(b){return new y((S)=>this.iterate((T)=>!b(T)||S(T)))}map(b){return new y((S)=>this.iterate((T)=>S(b(T))))}some(b){let S=!1;return this.iterate((T)=>(S=b(T),!S)),S}findFirst(b){let S;return this.iterate((T)=>!b(T)||(S=T,!1)),S}findLast(b){let S;return this.iterate((T)=>(b(T)&&(S=T),!0)),S}findLastMaxBy(b){let S,T=!0;return this.iterate((I)=>((T||_.isGreaterThan(b(I,S)))&&(T=!1,S=I),!0)),S}}a.CallbackIterable=y;class x{constructor(b){this._indexMap=b}static createSortPermutation(b,S){let T=Array.from(b.keys()).sort((I,R)=>S(b[I],b[R]));return new x(T)}apply(b){return b.map((S,T)=>b[this._indexMap[T]])}inverse(){let b=this._indexMap.slice();for(let S=0;S<this._indexMap.length;S++)b[this._indexMap[S]]=S;return new x(b)}}a.Permutation=x},8297:(s,a)=>{function c(f,m,h=f.length-1){for(let g=h;g>=0;g--)if(m(f[g]))return g;return-1}function u(f,m,h=0,g=f.length){let _=h,y=g;for(;_<y;){let x=Math.floor((_+y)/2);m(f[x])?_=x+1:y=x}return _-1}function l(f,m,h=0,g=f.length){let _=h,y=g;for(;_<y;){let x=Math.floor((_+y)/2);m(f[x])?y=x:_=x+1}return _}Object.defineProperty(a,"__esModule",{value:!0}),a.MonotonousArray=void 0,a.findLast=function(f,m){let h=c(f,m);if(h!==-1)return f[h]},a.findLastIdx=c,a.findLastMonotonous=function(f,m){let h=u(f,m);return h===-1?void 0:f[h]},a.findLastIdxMonotonous=u,a.findFirstMonotonous=function(f,m){let h=l(f,m);return h===f.length?void 0:f[h]},a.findFirstIdxMonotonousOrArrLen=l,a.findFirstIdxMonotonous=function(f,m,h=0,g=f.length){let _=l(f,m,h,g);return _===f.length?-1:_},a.findFirstMax=p,a.findLastMax=function(f,m){if(f.length===0)return;let h=f[0];for(let g=1;g<f.length;g++){let _=f[g];m(_,h)>=0&&(h=_)}return h},a.findFirstMin=function(f,m){return p(f,(h,g)=>-m(h,g))},a.findMaxIdx=function(f,m){if(f.length===0)return-1;let h=0;for(let g=1;g<f.length;g++)m(f[g],f[h])>0&&(h=g);return h},a.mapFindFirst=function(f,m){for(let h of f){let g=m(h);if(g!==void 0)return g}};class d{static{this.assertInvariants=!1}constructor(f){this._array=f,this._findLastMonotonousLastIdx=0}findLastMonotonous(f){if(d.assertInvariants){if(this._prevFindLastPredicate){for(let h of this._array)if(this._prevFindLastPredicate(h)&&!f(h))throw Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=f}let m=u(this._array,f,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=m+1,m===-1?void 0:this._array[m]}}function p(f,m){if(f.length===0)return;let h=f[0];for(let g=1;g<f.length;g++){let _=f[g];m(_,h)>0&&(h=_)}return h}a.MonotonousArray=d},9087:(s,a)=>{var c;Object.defineProperty(a,"__esModule",{value:!0}),a.SetWithKey=void 0,a.groupBy=function(l,d){let p=Object.create(null);for(let f of l){let m=d(f),h=p[m];h||(h=p[m]=[]),h.push(f)}return p},a.diffSets=function(l,d){let p=[],f=[];for(let m of l)d.has(m)||p.push(m);for(let m of d)l.has(m)||f.push(m);return{removed:p,added:f}},a.diffMaps=function(l,d){let p=[],f=[];for(let[m,h]of l)d.has(m)||p.push(h);for(let[m,h]of d)l.has(m)||f.push(h);return{removed:p,added:f}},a.intersection=function(l,d){let p=new Set;for(let f of d)l.has(f)&&p.add(f);return p};class u{static{c=Symbol.toStringTag}constructor(l,d){this.toKey=d,this._map=new Map,this[c]="SetWithKey";for(let p of l)this.add(p)}get size(){return this._map.size}add(l){let d=this.toKey(l);return this._map.set(d,l),this}delete(l){return this._map.delete(this.toKey(l))}has(l){return this._map.has(this.toKey(l))}*entries(){for(let l of this._map.values())yield[l,l]}keys(){return this.values()}*values(){for(let l of this._map.values())yield l}clear(){this._map.clear()}forEach(l,d){this._map.forEach((p)=>l.call(d,p,p,this))}[Symbol.iterator](){return this.values()}}a.SetWithKey=u},9807:(s,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.BugIndicatingError=a.ErrorNoTelemetry=a.ExpectedError=a.NotSupportedError=a.NotImplementedError=a.ReadonlyError=a.CancellationError=a.errorHandler=a.ErrorHandler=void 0,a.setUnexpectedErrorHandler=function(y){a.errorHandler.setUnexpectedErrorHandler(y)},a.isSigPipeError=function(y){if(!y||typeof y!="object")return!1;let x=y;return x.code==="EPIPE"&&x.syscall?.toUpperCase()==="WRITE"},a.onUnexpectedError=function(y){l(y)||a.errorHandler.onUnexpectedError(y)},a.onUnexpectedExternalError=function(y){l(y)||a.errorHandler.onUnexpectedExternalError(y)},a.transformErrorForSerialization=function(y){if(y instanceof Error){let{name:x,message:b}=y;return{$isError:!0,name:x,message:b,stack:y.stacktrace||y.stack,noTelemetry:g.isErrorNoTelemetry(y)}}return y},a.transformErrorFromSerialization=function(y){let x;return y.noTelemetry?x=new g:(x=Error(),x.name=y.name),x.message=y.message,x.stack=y.stack,x},a.isCancellationError=l,a.canceled=function(){let y=Error(u);return y.name=y.message,y},a.illegalArgument=function(y){return y?Error(`Illegal argument: ${y}`):Error("Illegal argument")},a.illegalState=function(y){return y?Error(`Illegal state: ${y}`):Error("Illegal state")},a.getErrorMessage=function(y){return y?y.message?y.message:y.stack?y.stack.split(`
|
|
2106
2106
|
`)[0]:String(y):"Error"};class c{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(y){setTimeout(()=>{if(y.stack){if(g.isErrorNoTelemetry(y))throw new g(y.message+`
|
|
@@ -2290,7 +2290,7 @@ that npm create fungi-app runs, at the version released with this fungi.
|
|
|
2290
2290
|
|
|
2291
2291
|
Add --help to create or install for its options.
|
|
2292
2292
|
See also: fungi oyster --help
|
|
2293
|
-
`,hxc=hr({version:D().min(1)});function cao(){return{oyster:"0.
|
|
2293
|
+
`,hxc=hr({version:D().min(1)});function cao(){return{oyster:"0.31.0",createFungiApp:"0.0.82"}}var uao=(e)=>new Promise((t,n)=>{let r=oao(e.command,[...e.args],{cwd:e.cwd,env:{...process.env,...e.env},stdio:"inherit"});r.once("error",n),r.once("close",(i,o)=>{t(i??(o===null?1:128))})}),lao=new Set(["try","install-apps","install"]),dao=new Set(["create","dev","build","install"]);function iar(e,t,n){return{command:"npm",args:["exec","--yes",`--package=${e}`,"--",t,...n]}}function pao(e){return e.length===0||e[0]==="help"||e[0]==="-h"||e[0]==="--help"}async function oar(e){let{group:t,args:n,cwd:r,stdout:i}=e,o=t==="oyster"?lao:dao,[s,...a]=n;if(pao(n)){i.write(t==="oyster"?CCt:RCt);return}if(s===void 0||!o.has(s))throw new K_e(`Unknown ${t} command: ${s??""}`,`Run fungi ${t} --help`);let c=cao(),u={FUNGI_HOST:`spore@${e.sporeVersion}`},l;if(t==="oyster"||s==="install")l=iar(`@fungi.computer/oyster@${c.oyster}`,"oyster",n);else if(s==="create")l=iar(`create-fungi-app@${c.createFungiApp}`,"create-fungi-app",a);else{let p=aao(r,"node_modules",".bin","fungi-app");if(!sao(p))throw new K_e("This folder is not a Fungi App","Run fungi app create <dir>, or npm install here");l={command:p,args:n}}let d=await(e.runner??uao)({...l,cwd:r,env:u});if(d!==0)process.exitCode=d}K9e();var hao=`Usage: fungi [command] [options]
|
|
2294
2294
|
|
|
2295
2295
|
Start here:
|
|
2296
2296
|
fungi Open your conversations in this folder
|
package/dist/whats-new.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"release":"0.
|
|
1
|
+
{"release":"0.45.0","lines":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/spore",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.8",
|
|
4
4
|
"description": "Spore by Fungi: open-source AI agents for your terminal and ACP editor, powered by Shiitake by Fungi.",
|
|
5
5
|
"homepage": "https://docs.fungi.computer/shiitake",
|
|
6
6
|
"keywords": [
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"@opencode-ai/pty": "0.3.0"
|
|
46
46
|
},
|
|
47
47
|
"optionalDependencies": {
|
|
48
|
-
"@fungi.computer/spore-native-linux-x64": "0.14.
|
|
49
|
-
"@fungi.computer/spore-native-linux-arm64": "0.14.
|
|
50
|
-
"@fungi.computer/spore-native-darwin-arm64": "0.14.
|
|
51
|
-
"@fungi.computer/spore-native-darwin-x64": "0.14.
|
|
48
|
+
"@fungi.computer/spore-native-linux-x64": "0.14.8",
|
|
49
|
+
"@fungi.computer/spore-native-linux-arm64": "0.14.8",
|
|
50
|
+
"@fungi.computer/spore-native-darwin-arm64": "0.14.8",
|
|
51
|
+
"@fungi.computer/spore-native-darwin-x64": "0.14.8",
|
|
52
52
|
"@oven/bun-darwin-x64": "1.4.4",
|
|
53
53
|
"@oven/bun-darwin-aarch64": "1.4.4",
|
|
54
54
|
"@oven/bun-linux-x64": "1.4.4",
|