@vinihcrosa/lumem-os 0.4.0 → 0.5.0

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.
Files changed (48) hide show
  1. package/bin/lumem.mjs +46 -3
  2. package/dist/server/main.mjs +11637 -7544
  3. package/dist/web/assets/{codemirror-setup-u52h1pHp.js → codemirror-setup-DJO1HmWW.js} +1 -1
  4. package/dist/web/assets/index-BV0JIdw9.css +32 -0
  5. package/dist/web/assets/index-Dzie5jh_.js +101 -0
  6. package/dist/web/index.html +2 -2
  7. package/drizzle/0014_tarefa_como_entidade.sql +33 -0
  8. package/drizzle/0015_quadro_de_sete_colunas.sql +33 -0
  9. package/drizzle/0016_ordem_na_coluna.sql +13 -0
  10. package/drizzle/0017_relogio_do_encalhe.sql +10 -0
  11. package/drizzle/0018_tetos_do_workspace.sql +26 -0
  12. package/drizzle/0019_comentario_de_tarefa.sql +15 -0
  13. package/drizzle/0020_esteira_tentativa_e_autonomia.sql +51 -0
  14. package/drizzle/0021_catalogo_de_agentes.sql +27 -0
  15. package/drizzle/0022_interruptor_da_esteira.sql +30 -0
  16. package/drizzle/0023_prompt_preparado.sql +49 -0
  17. package/drizzle/0024_motivo_do_bloqueio.sql +1 -0
  18. package/drizzle/0025_aviso_uma_vez.sql +1 -0
  19. package/drizzle/0026_pr_mesclada_sempre_remove.sql +1 -0
  20. package/drizzle/0027_issue_como_identidade.sql +6 -0
  21. package/drizzle/0028_marcos_no_tracker.sql +1 -0
  22. package/drizzle/0029_parecer_do_revisor.sql +22 -0
  23. package/drizzle/0030_papel_da_sessao_e_vaivem.sql +56 -0
  24. package/drizzle/0031_recibo_do_parecer.sql +14 -0
  25. package/drizzle/0032_turno_do_consumo.sql +1 -0
  26. package/drizzle/meta/0014_snapshot.json +1895 -0
  27. package/drizzle/meta/0015_snapshot.json +1895 -0
  28. package/drizzle/meta/0016_snapshot.json +1912 -0
  29. package/drizzle/meta/0017_snapshot.json +1920 -0
  30. package/drizzle/meta/0018_snapshot.json +1945 -0
  31. package/drizzle/meta/0019_snapshot.json +2039 -0
  32. package/drizzle/meta/0020_snapshot.json +2063 -0
  33. package/drizzle/meta/0021_snapshot.json +2249 -0
  34. package/drizzle/meta/0022_snapshot.json +2273 -0
  35. package/drizzle/meta/0023_snapshot.json +2291 -0
  36. package/drizzle/meta/0024_snapshot.json +2298 -0
  37. package/drizzle/meta/0025_snapshot.json +2305 -0
  38. package/drizzle/meta/0026_snapshot.json +2313 -0
  39. package/drizzle/meta/0027_snapshot.json +2357 -0
  40. package/drizzle/meta/0028_snapshot.json +2365 -0
  41. package/drizzle/meta/0029_snapshot.json +2506 -0
  42. package/drizzle/meta/0030_snapshot.json +2525 -0
  43. package/drizzle/meta/0031_snapshot.json +2623 -0
  44. package/drizzle/meta/0032_snapshot.json +2631 -0
  45. package/drizzle/meta/_journal.json +133 -0
  46. package/package.json +1 -1
  47. package/dist/web/assets/index-CrtHjcbU.js +0 -101
  48. package/dist/web/assets/index-DliBP3a7.css +0 -32
@@ -0,0 +1,101 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js"])))=>i.map(i=>d[i]);
2
+ var $b=e=>{throw TypeError(e)};var tm=(e,t,s)=>t.has(e)||$b("Cannot "+s);var E=(e,t,s)=>(tm(e,t,"read from private field"),s?s.call(e):t.get(e)),ge=(e,t,s)=>t.has(e)?$b("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),he=(e,t,s,n)=>(tm(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s),Ne=(e,t,s)=>(tm(e,t,"access private method"),s);var Du=(e,t,s,n)=>({set _(a){he(e,t,a,s)},get _(){return E(e,t,n)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const c of a)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&n(h)}).observe(document,{childList:!0,subtree:!0});function s(a){const c={};return a.integrity&&(c.integrity=a.integrity),a.referrerPolicy&&(c.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?c.credentials="include":a.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function n(a){if(a.ep)return;a.ep=!0;const c=s(a);fetch(a.href,c)}})();const Kk="modulepreload",$k=function(e){return"/"+e},Wb={},Ut=function(t,s,n){let a=Promise.resolve();if(s&&s.length>0){let h=function(m){return Promise.all(m.map(g=>Promise.resolve(g).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),f=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));a=h(s.map(m=>{if(m=$k(m),m in Wb)return;Wb[m]=!0;const g=m.endsWith(".css"),v=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${v}`))return;const b=document.createElement("link");if(b.rel=g?"stylesheet":Kk,g||(b.as="script"),b.crossOrigin="",b.href=m,f&&b.setAttribute("nonce",f),document.head.appendChild(b),g)return new Promise((S,x)=>{b.addEventListener("load",S),b.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${m}`)))})}))}function c(h){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=h,window.dispatchEvent(d),!d.defaultPrevented)throw h}return a.then(h=>{for(const d of h||[])d.status==="rejected"&&c(d.reason);return t().catch(c)})};var sm={exports:{}},Co={};/**
3
+ * @license React
4
+ * react-jsx-runtime.production.js
5
+ *
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var Vb;function Wk(){if(Vb)return Co;Vb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function s(n,a,c){var h=null;if(c!==void 0&&(h=""+c),a.key!==void 0&&(h=""+a.key),"key"in a){c={};for(var d in a)d!=="key"&&(c[d]=a[d])}else c=a;return a=c.ref,{$$typeof:e,type:n,key:h,ref:a!==void 0?a:null,props:c}}return Co.Fragment=t,Co.jsx=s,Co.jsxs=s,Co}var Yb;function Vk(){return Yb||(Yb=1,sm.exports=Wk()),sm.exports}var l=Vk(),da=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Wn,en,al,yx,Yk=(yx=class extends da{constructor(){super();ge(this,Wn);ge(this,en);ge(this,al);he(this,al,t=>{if(typeof window<"u"&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){E(this,en)||this.setEventListener(E(this,al))}onUnsubscribe(){var t;this.hasListeners()||((t=E(this,en))==null||t.call(this),he(this,en,void 0))}setEventListener(t){var s;he(this,al,t),(s=E(this,en))==null||s.call(this),he(this,en,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){E(this,Wn)!==t&&(he(this,Wn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){var t;return typeof E(this,Wn)=="boolean"?E(this,Wn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Wn=new WeakMap,en=new WeakMap,al=new WeakMap,yx),a_=new Yk,Gk={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},tn,n_,bx,Qk=(bx=class{constructor(){ge(this,tn,Gk);ge(this,n_,!1)}setTimeoutProvider(e){he(this,tn,e)}setTimeout(e,t){return E(this,tn).setTimeout(e,t)}clearTimeout(e){E(this,tn).clearTimeout(e)}setInterval(e,t){return E(this,tn).setInterval(e,t)}clearInterval(e){E(this,tn).clearInterval(e)}},tn=new WeakMap,n_=new WeakMap,bx),Kn=new Qk;function Zk(e){setTimeout(e,0)}var Xk=typeof window>"u"||"Deno"in globalThis;function ps(){}function Jk(e,t){return typeof e=="function"?e(t):e}function Lm(e){return typeof e=="number"&&e>=0&&e!==1/0}function Mx(e,t){return Math.max(e+(t||0)-Date.now(),0)}function pn(e,t){return typeof e=="function"?e(t):e}function Ys(e,t){return typeof e=="function"?e(t):e}function Gb(e,t){const{type:s="all",exact:n,fetchStatus:a,predicate:c,queryKey:h,stale:d}=e;if(h){if(n){if(t.queryHash!==l_(h,t.options))return!1}else if(!Sl(t.queryKey,h))return!1}if(s!=="all"){const f=t.isActive();if(s==="active"&&!f||s==="inactive"&&f)return!1}return!(typeof d=="boolean"&&t.isStale()!==d||a&&a!==t.state.fetchStatus||c&&!c(t))}function Qb(e,t){const{exact:s,status:n,predicate:a,mutationKey:c}=e;if(c){if(!t.options.mutationKey)return!1;if(s){if(ra(t.options.mutationKey)!==ra(c))return!1}else if(!Sl(t.options.mutationKey,c))return!1}return!(n&&t.state.status!==n||a&&!a(t))}function l_(e,t){return((t==null?void 0:t.queryKeyHashFn)||ra)(e)}function ra(e){return JSON.stringify(e,(t,s)=>qm(s)?Object.keys(s).sort().reduce((n,a)=>(n[a]=s[a],n),{}):s)}function Sl(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!Sl(e[n],t[n]))return!1;return!0}const s=Object.keys(t);for(const n of s)if(!Sl(e[n],t[n]))return!1;return!0}return!1}var eN=Object.prototype.hasOwnProperty;function o_(e,t,s=0){if(e===t)return e;if(s>500)return t;const n=Zb(e)&&Zb(t);if(!n&&!(qm(e)&&qm(t)))return t;const c=(n?e:Object.keys(e)).length,h=n?t:Object.keys(t),d=h.length,f=n?new Array(d):{};let m=0;for(let g=0;g<d;g++){const v=n?g:h[g],b=e[v],S=t[v];if(b===S){f[v]=b,(n?g<c:eN.call(e,v))&&m++;continue}if(b===null||S===null||typeof b!="object"||typeof S!="object"){f[v]=S;continue}const x=o_(b,S,s+1);f[v]=x,x===b&&m++}return c===d&&m===c?e:f}function Uo(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Zb(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function qm(e){if(!Xb(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!Xb(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Xb(e){return Object.prototype.toString.call(e)==="[object Object]"}function tN(e){return new Promise(t=>{Kn.setTimeout(t,e)})}function zm(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?o_(e,t):t}function sN(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function iN(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var c_=Symbol();function Bx(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===c_?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function u_(e,t){return typeof e=="function"?e(...t):!!e}function rN(e,t,s){let n=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),n||(n=!0,a.aborted?s():a.addEventListener("abort",s,{once:!0})),a)}),e}var Ko=(()=>{let e=()=>Xk;return{isServer(){return e()},setIsServer(t){e=t}}})();function Pm(){let e,t;const s=new Promise((a,c)=>{e=a,t=c});s.status="pending",s.catch(()=>{});function n(a){Object.assign(s,a),delete s.resolve,delete s.reject}return s.resolve=a=>{n({status:"fulfilled",value:a}),e(a)},s.reject=a=>{n({status:"rejected",reason:a}),t(a)},s}var nN=Zk;function aN(){let e=[],t=0,s=d=>{d()},n=d=>{d()},a=nN;const c=d=>{t?e.push(d):a(()=>{s(d)})},h=()=>{const d=e;e=[],d.length&&a(()=>{n(()=>{d.forEach(f=>{s(f)})})})};return{batch:d=>{let f;t++;try{f=d()}finally{t--,t||h()}return f},batchCalls:d=>(...f)=>{c(()=>{d(...f)})},schedule:c,setNotifyFunction:d=>{s=d},setBatchNotifyFunction:d=>{n=d},setScheduler:d=>{a=d}}}var jt=aN(),ll,sn,ol,Sx,lN=(Sx=class extends da{constructor(){super();ge(this,ll,!0);ge(this,sn);ge(this,ol);he(this,ol,t=>{if(typeof window<"u"&&window.addEventListener){const s=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",n)}}})}onSubscribe(){E(this,sn)||this.setEventListener(E(this,ol))}onUnsubscribe(){var t;this.hasListeners()||((t=E(this,sn))==null||t.call(this),he(this,sn,void 0))}setEventListener(t){var s;he(this,ol,t),(s=E(this,sn))==null||s.call(this),he(this,sn,t(this.setOnline.bind(this)))}setOnline(t){E(this,ll)!==t&&(he(this,ll,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return E(this,ll)}},ll=new WeakMap,sn=new WeakMap,ol=new WeakMap,Sx),ch=new lN;function oN(e){return Math.min(1e3*2**e,3e4)}function Lx(e){return(e??"online")==="online"?ch.isOnline():!0}var Hm=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function qx(e){let t=!1,s=0,n;const a=Pm(),c=()=>a.status!=="pending",h=w=>{var k;if(!c()){const N=new Hm(w);b(N),(k=e.onCancel)==null||k.call(e,N)}},d=()=>{t=!0},f=()=>{t=!1},m=()=>a_.isFocused()&&(e.networkMode==="always"||ch.isOnline())&&e.canRun(),g=()=>Lx(e.networkMode)&&e.canRun(),v=w=>{c()||(n==null||n(),a.resolve(w))},b=w=>{c()||(n==null||n(),a.reject(w))},S=()=>new Promise(w=>{var k;n=N=>{(c()||m())&&w(N)},(k=e.onPause)==null||k.call(e)}).then(()=>{var w;n=void 0,c()||(w=e.onContinue)==null||w.call(e)}),x=()=>{if(c())return;let w;const k=s===0?e.initialPromise:void 0;try{w=k??e.fn()}catch(N){w=Promise.reject(N)}Promise.resolve(w).then(v).catch(N=>{var K;if(c())return;const L=e.retry??(Ko.isServer()?0:3),R=e.retryDelay??oN,D=typeof R=="function"?R(s,N):R,Y=L===!0||typeof L=="number"&&s<L||typeof L=="function"&&L(s,N);if(t||!Y){b(N);return}s++,(K=e.onFail)==null||K.call(e,s,N),tN(D).then(()=>m()?void 0:S()).then(()=>{t?b(N):x()})})};return{promise:a,status:()=>a.status,cancel:h,continue:()=>(n==null||n(),a),cancelRetry:d,continueRetry:f,canStart:g,start:()=>(g()?x():S().then(x),a)}}var Vn,xx,zx=(xx=class{constructor(){ge(this,Vn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Lm(this.gcTime)&&he(this,Vn,Kn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ko.isServer()?1/0:300*1e3))}clearGcTimeout(){E(this,Vn)!==void 0&&(Kn.clearTimeout(E(this,Vn)),he(this,Vn,void 0))}},Vn=new WeakMap,xx);function cN(e){return{onFetch:(t,s)=>{var g,v,b,S,x;const n=t.options,a=(b=(v=(g=t.fetchOptions)==null?void 0:g.meta)==null?void 0:v.fetchMore)==null?void 0:b.direction,c=((S=t.state.data)==null?void 0:S.pages)||[],h=((x=t.state.data)==null?void 0:x.pageParams)||[];let d={pages:[],pageParams:[]},f=0;const m=async()=>{let w=!1;const k=R=>{rN(R,()=>t.signal,()=>w=!0)},N=Bx(t.options,t.fetchOptions),L=async(R,D,Y)=>{if(w)return Promise.reject(t.signal.reason);if(D==null&&R.pages.length)return Promise.resolve(R);const Z=(()=>{const le={client:t.client,queryKey:t.queryKey,pageParam:D,direction:Y?"backward":"forward",meta:t.options.meta};return k(le),le})(),Q=await N(Z),{maxPages:z}=t.options,G=Y?iN:sN;return{pages:G(R.pages,Q,z),pageParams:G(R.pageParams,D,z)}};if(a&&c.length){const R=a==="backward",D=R?uN:Jb,Y={pages:c,pageParams:h},K=D(n,Y);d=await L(Y,K,R)}else{const R=e??c.length;do{const D=f===0?h[0]??n.initialPageParam:Jb(n,d);if(f>0&&D==null)break;d=await L(d,D),f++}while(f<R)}return d};t.options.persister?t.fetchFn=()=>{var w,k;return(k=(w=t.options).persister)==null?void 0:k.call(w,m,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=m}}}function Jb(e,{pages:t,pageParams:s}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,s[n],s):void 0}function uN(e,{pages:t,pageParams:s}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,s[0],s):void 0}var cl,Yn,ul,ui,Gn,Qt,ec,Qn,Vs,Px,lr,wx,hN=(wx=class extends zx{constructor(t){super();ge(this,Vs);ge(this,cl);ge(this,Yn);ge(this,ul);ge(this,ui);ge(this,Gn);ge(this,Qt);ge(this,ec);ge(this,Qn);he(this,Qn,!1),he(this,ec,t.defaultOptions),this.setOptions(t.options),this.observers=[],he(this,Gn,t.client),he(this,ui,E(this,Gn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,he(this,Yn,t0(this.options)),this.state=t.state??E(this,Yn),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return E(this,cl)}get promise(){var t;return(t=E(this,Qt))==null?void 0:t.promise}setOptions(t){if(this.options={...E(this,ec),...t},t!=null&&t._type&&he(this,cl,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const s=t0(this.options);s.data!==void 0&&(this.setState(e0(s.data,s.dataUpdatedAt)),he(this,Yn,s))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&E(this,ui).remove(this)}setData(t,s){const n=zm(this.state.data,t,this.options);return Ne(this,Vs,lr).call(this,{data:n,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),n}setState(t){Ne(this,Vs,lr).call(this,{type:"setState",state:t})}cancel(t){var n,a;const s=(n=E(this,Qt))==null?void 0:n.promise;return(a=E(this,Qt))==null||a.cancel(t),s?s.then(ps).catch(ps):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return E(this,Yn)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Ys(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===c_||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>pn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Mx(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=E(this,Qt))==null||s.continue()}onOnline(){var s;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=E(this,Qt))==null||s.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),E(this,ui).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(s=>s!==t),this.observers.length||(E(this,Qt)&&(E(this,Qn)||Ne(this,Vs,Px).call(this)?E(this,Qt).cancel({revert:!0}):E(this,Qt).cancelRetry()),this.scheduleGc()),E(this,ui).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ne(this,Vs,lr).call(this,{type:"invalidate"})}async fetch(t,s){var m,g,v,b,S,x,w,k,N,L,R;if(this.state.fetchStatus!=="idle"&&((m=E(this,Qt))==null?void 0:m.status())!=="rejected"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(E(this,Qt))return E(this,Qt).continueRetry(),E(this,Qt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const D=this.observers.find(Y=>Y.options.queryFn);D&&this.setOptions(D.options)}const n=new AbortController,a=D=>{Object.defineProperty(D,"signal",{enumerable:!0,get:()=>(he(this,Qn,!0),n.signal)})},c=()=>{const D=Bx(this.options,s),K=(()=>{const Z={client:E(this,Gn),queryKey:this.queryKey,meta:this.meta};return a(Z),Z})();return he(this,Qn,!1),this.options.persister?this.options.persister(D,K,this):D(K)},d=(()=>{const D={fetchOptions:s,options:this.options,queryKey:this.queryKey,client:E(this,Gn),state:this.state,fetchFn:c};return a(D),D})(),f=E(this,cl)==="infinite"?cN(this.options.pages):this.options.behavior;f==null||f.onFetch(d,this),he(this,ul,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((g=d.fetchOptions)==null?void 0:g.meta))&&Ne(this,Vs,lr).call(this,{type:"fetch",meta:(v=d.fetchOptions)==null?void 0:v.meta}),he(this,Qt,qx({initialPromise:s==null?void 0:s.initialPromise,fn:d.fetchFn,onCancel:D=>{D instanceof Hm&&D.revert&&this.setState({...E(this,ul),fetchStatus:"idle"}),n.abort()},onFail:(D,Y)=>{Ne(this,Vs,lr).call(this,{type:"failed",failureCount:D,error:Y})},onPause:()=>{Ne(this,Vs,lr).call(this,{type:"pause"})},onContinue:()=>{Ne(this,Vs,lr).call(this,{type:"continue"})},retry:d.options.retry,retryDelay:d.options.retryDelay,networkMode:d.options.networkMode,canRun:()=>!0}));try{const D=await E(this,Qt).start();if(D===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(D),(S=(b=E(this,ui).config).onSuccess)==null||S.call(b,D,this),(w=(x=E(this,ui).config).onSettled)==null||w.call(x,D,this.state.error,this),D}catch(D){if(D instanceof Hm){if(D.silent)return E(this,Qt).promise;if(D.revert){if(this.state.data===void 0)throw D;return this.state.data}}throw Ne(this,Vs,lr).call(this,{type:"error",error:D}),(N=(k=E(this,ui).config).onError)==null||N.call(k,D,this),(R=(L=E(this,ui).config).onSettled)==null||R.call(L,this.state.data,D,this),D}finally{this.scheduleGc()}}},cl=new WeakMap,Yn=new WeakMap,ul=new WeakMap,ui=new WeakMap,Gn=new WeakMap,Qt=new WeakMap,ec=new WeakMap,Qn=new WeakMap,Vs=new WeakSet,Px=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},lr=function(t){const s=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Hx(n.data,this.options),fetchMeta:t.meta??null};case"success":const a={...n,...e0(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return he(this,ul,t.manual?a:void 0),a;case"error":const c=t.error;return{...n,error:c,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:c,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=s(this.state),jt.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),E(this,ui).notify({query:this,type:"updated",action:t})})},wx);function Hx(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Lx(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function e0(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function t0(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,n=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var Os,Ge,tc,vs,Zn,hl,cr,rn,sc,dl,fl,Xn,Jn,nn,ml,rt,Ro,Fm,Im,Um,Km,$m,Wm,Vm,Fx,Cx,h_=(Cx=class extends da{constructor(t,s){super();ge(this,rt);ge(this,Os);ge(this,Ge);ge(this,tc);ge(this,vs);ge(this,Zn);ge(this,hl);ge(this,cr);ge(this,rn);ge(this,sc);ge(this,dl);ge(this,fl);ge(this,Xn);ge(this,Jn);ge(this,nn);ge(this,ml,new Set);this.options=s,he(this,Os,t),he(this,rn,null),he(this,cr,Pm()),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(E(this,Ge).addObserver(this),s0(E(this,Ge),this.options)?Ne(this,rt,Ro).call(this):this.updateResult(),Ne(this,rt,Km).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ym(E(this,Ge),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ym(E(this,Ge),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ne(this,rt,$m).call(this),Ne(this,rt,Wm).call(this),E(this,Ge).removeObserver(this)}setOptions(t){const s=this.options,n=E(this,Ge);if(this.options=E(this,Os).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ys(this.options.enabled,E(this,Ge))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ne(this,rt,Vm).call(this),E(this,Ge).setOptions(this.options),s._defaulted&&!Uo(this.options,s)&&E(this,Os).getQueryCache().notify({type:"observerOptionsUpdated",query:E(this,Ge),observer:this});const a=this.hasListeners();a&&i0(E(this,Ge),n,this.options,s)&&Ne(this,rt,Ro).call(this),this.updateResult(),a&&(E(this,Ge)!==n||Ys(this.options.enabled,E(this,Ge))!==Ys(s.enabled,E(this,Ge))||pn(this.options.staleTime,E(this,Ge))!==pn(s.staleTime,E(this,Ge)))&&Ne(this,rt,Fm).call(this);const c=Ne(this,rt,Im).call(this);a&&(E(this,Ge)!==n||Ys(this.options.enabled,E(this,Ge))!==Ys(s.enabled,E(this,Ge))||c!==E(this,nn))&&Ne(this,rt,Um).call(this,c)}getOptimisticResult(t){const s=E(this,Os).getQueryCache().build(E(this,Os),t),n=this.createResult(s,t);return fN(this,n)&&(he(this,vs,n),he(this,hl,this.options),he(this,Zn,E(this,Ge).state)),n}getCurrentResult(){return E(this,vs)}trackResult(t,s){return new Proxy(t,{get:(n,a)=>(this.trackProp(a),s==null||s(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&E(this,cr).status==="pending"&&E(this,cr).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,a))})}trackProp(t){E(this,ml).add(t)}getCurrentQuery(){return E(this,Ge)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=E(this,Os).defaultQueryOptions(t),n=E(this,Os).getQueryCache().build(E(this,Os),s);return n.fetch().then(()=>this.createResult(n,s))}fetch(t){return Ne(this,rt,Ro).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),E(this,vs)))}createResult(t,s){var z;const n=E(this,Ge),a=this.options,c=E(this,vs),h=E(this,Zn),d=E(this,hl),m=t!==n?t.state:E(this,tc),{state:g}=t;let v={...g},b=!1,S;if(s._optimisticResults){const G=this.hasListeners(),le=!G&&s0(t,s),H=G&&i0(t,n,s,a);(le||H)&&(v={...v,...Hx(g.data,t.options)}),s._optimisticResults==="isRestoring"&&(v.fetchStatus="idle")}let{error:x,errorUpdatedAt:w,status:k}=v;S=v.data;let N=!1;if(s.placeholderData!==void 0&&S===void 0&&k==="pending"){let G;c!=null&&c.isPlaceholderData&&s.placeholderData===(d==null?void 0:d.placeholderData)?(G=c.data,N=!0):G=typeof s.placeholderData=="function"?s.placeholderData((z=E(this,fl))==null?void 0:z.state.data,E(this,fl)):s.placeholderData,G!==void 0&&(k="success",S=zm(c==null?void 0:c.data,G,s),b=!0)}if(s.select&&S!==void 0&&!N)if(c&&S===(h==null?void 0:h.data)&&s.select===E(this,sc))S=E(this,dl);else try{he(this,sc,s.select),S=s.select(S),S=zm(c==null?void 0:c.data,S,s),he(this,dl,S),he(this,rn,null)}catch(G){he(this,rn,G)}E(this,rn)&&(x=E(this,rn),S=E(this,dl),w=Date.now(),k="error");const L=v.fetchStatus==="fetching",R=k==="pending",D=k==="error",Y=R&&L,K=S!==void 0,Q={status:k,fetchStatus:v.fetchStatus,isPending:R,isSuccess:k==="success",isError:D,isInitialLoading:Y,isLoading:Y,data:S,dataUpdatedAt:v.dataUpdatedAt,error:x,errorUpdatedAt:w,failureCount:v.fetchFailureCount,failureReason:v.fetchFailureReason,errorUpdateCount:v.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:v.dataUpdateCount>m.dataUpdateCount||v.errorUpdateCount>m.errorUpdateCount,isFetching:L,isRefetching:L&&!R,isLoadingError:D&&!K,isPaused:v.fetchStatus==="paused",isPlaceholderData:b,isRefetchError:D&&K,isStale:d_(t,s),refetch:this.refetch,promise:E(this,cr),isEnabled:Ys(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const G=Q.data!==void 0,le=Q.status==="error"&&!G,H=ee=>{le?ee.reject(Q.error):G&&ee.resolve(Q.data)},O=()=>{const ee=he(this,cr,Q.promise=Pm());H(ee)},W=E(this,cr);switch(W.status){case"pending":t.queryHash===n.queryHash&&H(W);break;case"fulfilled":(le||Q.data!==W.value)&&O();break;case"rejected":(!le||Q.error!==W.reason)&&O();break}}return Q}updateResult(){const t=E(this,vs),s=this.createResult(E(this,Ge),this.options);if(he(this,Zn,E(this,Ge).state),he(this,hl,this.options),E(this,Zn).data!==void 0&&he(this,fl,E(this,Ge)),Uo(s,t))return;he(this,vs,s);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,c=typeof a=="function"?a():a;if(c==="all"||!c&&!E(this,ml).size)return!0;const h=new Set(c??E(this,ml));return this.options.throwOnError&&h.add("error"),Object.keys(E(this,vs)).some(d=>{const f=d;return E(this,vs)[f]!==t[f]&&h.has(f)})};Ne(this,rt,Fx).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ne(this,rt,Km).call(this)}},Os=new WeakMap,Ge=new WeakMap,tc=new WeakMap,vs=new WeakMap,Zn=new WeakMap,hl=new WeakMap,cr=new WeakMap,rn=new WeakMap,sc=new WeakMap,dl=new WeakMap,fl=new WeakMap,Xn=new WeakMap,Jn=new WeakMap,nn=new WeakMap,ml=new WeakMap,rt=new WeakSet,Ro=function(t){Ne(this,rt,Vm).call(this);let s=E(this,Ge).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(ps)),s},Fm=function(){Ne(this,rt,$m).call(this);const t=pn(this.options.staleTime,E(this,Ge));if(Ko.isServer()||E(this,vs).isStale||!Lm(t))return;const n=Mx(E(this,vs).dataUpdatedAt,t)+1;he(this,Xn,Kn.setTimeout(()=>{E(this,vs).isStale||this.updateResult()},n))},Im=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(E(this,Ge)):this.options.refetchInterval)??!1},Um=function(t){Ne(this,rt,Wm).call(this),he(this,nn,t),!(Ko.isServer()||Ys(this.options.enabled,E(this,Ge))===!1||!Lm(E(this,nn))||E(this,nn)===0)&&he(this,Jn,Kn.setInterval(()=>{(this.options.refetchIntervalInBackground||a_.isFocused())&&Ne(this,rt,Ro).call(this)},E(this,nn)))},Km=function(){Ne(this,rt,Fm).call(this),Ne(this,rt,Um).call(this,Ne(this,rt,Im).call(this))},$m=function(){E(this,Xn)!==void 0&&(Kn.clearTimeout(E(this,Xn)),he(this,Xn,void 0))},Wm=function(){E(this,Jn)!==void 0&&(Kn.clearInterval(E(this,Jn)),he(this,Jn,void 0))},Vm=function(){const t=E(this,Os).getQueryCache().build(E(this,Os),this.options);if(t===E(this,Ge))return;const s=E(this,Ge);he(this,Ge,t),he(this,tc,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Fx=function(t){jt.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(E(this,vs))}),E(this,Os).getQueryCache().notify({query:E(this,Ge),type:"observerResultsUpdated"})})},Cx);function dN(e,t){return Ys(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Ys(t.retryOnMount,e)===!1)}function s0(e,t){return dN(e,t)||e.state.data!==void 0&&Ym(e,t,t.refetchOnMount)}function Ym(e,t,s){if(Ys(t.enabled,e)!==!1&&pn(t.staleTime,e)!=="static"){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&d_(e,t)}return!1}function i0(e,t,s,n){return(e!==t||Ys(n.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&d_(e,s)}function d_(e,t){return Ys(t.enabled,e)!==!1&&e.isStaleByTime(pn(t.staleTime,e))}function fN(e,t){return!Uo(e.getCurrentResult(),t)}var ic,Ai,ms,ea,Ri,Gr,jx,mN=(jx=class extends zx{constructor(t){super();ge(this,Ri);ge(this,ic);ge(this,Ai);ge(this,ms);ge(this,ea);he(this,ic,t.client),this.mutationId=t.mutationId,he(this,ms,t.mutationCache),he(this,Ai,[]),this.state=t.state||Ix(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){E(this,Ai).includes(t)||(E(this,Ai).push(t),this.clearGcTimeout(),E(this,ms).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){he(this,Ai,E(this,Ai).filter(s=>s!==t)),this.scheduleGc(),E(this,ms).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){E(this,Ai).length||(this.state.status==="pending"?this.scheduleGc():E(this,ms).remove(this))}continue(){var t;return((t=E(this,ea))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var h,d,f,m,g,v,b,S,x,w,k,N,L,R,D,Y,K,Z;const s=()=>{Ne(this,Ri,Gr).call(this,{type:"continue"})},n={client:E(this,ic),meta:this.options.meta,mutationKey:this.options.mutationKey};he(this,ea,qx({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(Q,z)=>{Ne(this,Ri,Gr).call(this,{type:"failed",failureCount:Q,error:z})},onPause:()=>{Ne(this,Ri,Gr).call(this,{type:"pause"})},onContinue:s,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>E(this,ms).canRun(this)}));const a=this.state.status==="pending",c=!E(this,ea).canStart();try{if(a)s();else{Ne(this,Ri,Gr).call(this,{type:"pending",variables:t,isPaused:c}),E(this,ms).config.onMutate&&await E(this,ms).config.onMutate(t,this,n);const z=await((d=(h=this.options).onMutate)==null?void 0:d.call(h,t,n));z!==this.state.context&&Ne(this,Ri,Gr).call(this,{type:"pending",context:z,variables:t,isPaused:c})}const Q=await E(this,ea).start();return await((m=(f=E(this,ms).config).onSuccess)==null?void 0:m.call(f,Q,t,this.state.context,this,n)),await((v=(g=this.options).onSuccess)==null?void 0:v.call(g,Q,t,this.state.context,n)),await((S=(b=E(this,ms).config).onSettled)==null?void 0:S.call(b,Q,null,this.state.variables,this.state.context,this,n)),await((w=(x=this.options).onSettled)==null?void 0:w.call(x,Q,null,t,this.state.context,n)),Ne(this,Ri,Gr).call(this,{type:"success",data:Q}),Q}catch(Q){try{await((N=(k=E(this,ms).config).onError)==null?void 0:N.call(k,Q,t,this.state.context,this,n))}catch(z){Promise.reject(z)}try{await((R=(L=this.options).onError)==null?void 0:R.call(L,Q,t,this.state.context,n))}catch(z){Promise.reject(z)}try{await((Y=(D=E(this,ms).config).onSettled)==null?void 0:Y.call(D,void 0,Q,this.state.variables,this.state.context,this,n))}catch(z){Promise.reject(z)}try{await((Z=(K=this.options).onSettled)==null?void 0:Z.call(K,void 0,Q,t,this.state.context,n))}catch(z){Promise.reject(z)}throw Ne(this,Ri,Gr).call(this,{type:"error",error:Q}),Q}finally{E(this,ms).runNext(this)}}},ic=new WeakMap,Ai=new WeakMap,ms=new WeakMap,ea=new WeakMap,Ri=new WeakSet,Gr=function(t){const s=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),jt.batch(()=>{E(this,Ai).forEach(n=>{n.onMutationUpdate(t)}),E(this,ms).notify({mutation:this,type:"updated",action:t})})},jx);function Ix(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ur,yi,rc,kx,pN=(kx=class extends da{constructor(t={}){super();ge(this,ur);ge(this,yi);ge(this,rc);this.config=t,he(this,ur,new Set),he(this,yi,new Map),he(this,rc,0)}build(t,s,n){const a=new mN({client:t,mutationCache:this,mutationId:++Du(this,rc)._,options:t.defaultMutationOptions(s),state:n});return this.add(a),a}add(t){E(this,ur).add(t);const s=Mu(t);if(typeof s=="string"){const n=E(this,yi).get(s);n?n.push(t):E(this,yi).set(s,[t])}this.notify({type:"added",mutation:t})}remove(t){if(E(this,ur).delete(t)){const s=Mu(t);if(typeof s=="string"){const n=E(this,yi).get(s);if(n)if(n.length>1){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}else n[0]===t&&E(this,yi).delete(s)}}this.notify({type:"removed",mutation:t})}canRun(t){const s=Mu(t);if(typeof s=="string"){const n=E(this,yi).get(s),a=n==null?void 0:n.find(c=>c.state.status==="pending");return!a||a===t}else return!0}runNext(t){var n;const s=Mu(t);if(typeof s=="string"){const a=(n=E(this,yi).get(s))==null?void 0:n.find(c=>c!==t&&c.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){jt.batch(()=>{E(this,ur).forEach(t=>{this.notify({type:"removed",mutation:t})}),E(this,ur).clear(),E(this,yi).clear()})}getAll(){return Array.from(E(this,ur))}find(t){const s={exact:!0,...t};return this.getAll().find(n=>Qb(s,n))}findAll(t={}){return this.getAll().filter(s=>Qb(t,s))}notify(t){jt.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){const t=this.getAll().filter(s=>s.state.isPaused);return jt.batch(()=>Promise.all(t.map(s=>s.continue().catch(ps))))}},ur=new WeakMap,yi=new WeakMap,rc=new WeakMap,kx);function Mu(e){var t;return(t=e.options.scope)==null?void 0:t.id}var hr,an,As,dr,_r,th,Gm,Nx,_N=(Nx=class extends da{constructor(s,n){super();ge(this,_r);ge(this,hr);ge(this,an);ge(this,As);ge(this,dr);he(this,hr,s),this.setOptions(n),this.bindMethods(),Ne(this,_r,th).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(s){var a;const n=this.options;this.options=E(this,hr).defaultMutationOptions(s),Uo(this.options,n)||E(this,hr).getMutationCache().notify({type:"observerOptionsUpdated",mutation:E(this,As),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&ra(n.mutationKey)!==ra(this.options.mutationKey)?this.reset():((a=E(this,As))==null?void 0:a.state.status)==="pending"&&E(this,As).setOptions(this.options)}onUnsubscribe(){var s;this.hasListeners()||(s=E(this,As))==null||s.removeObserver(this)}onMutationUpdate(s){Ne(this,_r,th).call(this),Ne(this,_r,Gm).call(this,s)}getCurrentResult(){return E(this,an)}reset(){var s;(s=E(this,As))==null||s.removeObserver(this),he(this,As,void 0),Ne(this,_r,th).call(this),Ne(this,_r,Gm).call(this)}mutate(s,n){var a;return he(this,dr,n),(a=E(this,As))==null||a.removeObserver(this),he(this,As,E(this,hr).getMutationCache().build(E(this,hr),this.options)),E(this,As).addObserver(this),E(this,As).execute(s)}},hr=new WeakMap,an=new WeakMap,As=new WeakMap,dr=new WeakMap,_r=new WeakSet,th=function(){var n;const s=((n=E(this,As))==null?void 0:n.state)??Ix();he(this,an,{...s,isPending:s.status==="pending",isSuccess:s.status==="success",isError:s.status==="error",isIdle:s.status==="idle",mutate:this.mutate,reset:this.reset})},Gm=function(s){jt.batch(()=>{var n,a,c,h,d,f,m,g;if(E(this,dr)&&this.hasListeners()){const v=E(this,an).variables,b=E(this,an).context,S={client:E(this,hr),meta:this.options.meta,mutationKey:this.options.mutationKey};if((s==null?void 0:s.type)==="success"){try{(a=(n=E(this,dr)).onSuccess)==null||a.call(n,s.data,v,b,S)}catch(x){Promise.reject(x)}try{(h=(c=E(this,dr)).onSettled)==null||h.call(c,s.data,null,v,b,S)}catch(x){Promise.reject(x)}}else if((s==null?void 0:s.type)==="error"){try{(f=(d=E(this,dr)).onError)==null||f.call(d,s.error,v,b,S)}catch(x){Promise.reject(x)}try{(g=(m=E(this,dr)).onSettled)==null||g.call(m,void 0,s.error,v,b,S)}catch(x){Promise.reject(x)}}}this.listeners.forEach(v=>{v(E(this,an))})})},Nx);function r0(e,t){const s=new Set(t);return e.filter(n=>!s.has(n))}function gN(e,t,s){const n=e.slice(0);return n[t]=s,n}var pl,Rs,_l,ta,Ws,ln,nc,ac,lc,oc,Vt,Qm,Zm,Ux,Xm,Jm,ep,Ex,vN=(Ex=class extends da{constructor(t,s,n){super();ge(this,Vt);ge(this,pl);ge(this,Rs);ge(this,_l);ge(this,ta);ge(this,Ws);ge(this,ln);ge(this,nc);ge(this,ac);ge(this,lc);ge(this,oc,[]);he(this,pl,t),he(this,ta,n),he(this,_l,[]),he(this,Ws,[]),he(this,Rs,[]),this.setQueries(s)}onSubscribe(){this.listeners.size===1&&E(this,Ws).forEach(t=>{t.subscribe(s=>{Ne(this,Vt,Jm).call(this,t,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,E(this,Ws).forEach(t=>{t.destroy()})}setQueries(t,s){he(this,_l,t),he(this,ta,s),jt.batch(()=>{const n=E(this,Ws),a=Ne(this,Vt,Xm).call(this,E(this,_l));a.forEach(v=>v.observer.setOptions(v.defaultedQueryOptions));const c=a.map(v=>v.observer),h=c.map(v=>v.getCurrentResult()),d=n.length!==c.length,f=c.some((v,b)=>v!==n[b]),m=d||f,g=m?!0:h.some((v,b)=>{const S=E(this,Rs)[b];return!S||!Uo(v,S)});!m&&!g||(m&&(he(this,oc,a),he(this,Ws,c)),he(this,Rs,h),this.hasListeners()&&(m&&(r0(n,c).forEach(v=>{v.destroy()}),r0(c,n).forEach(v=>{v.subscribe(b=>{Ne(this,Vt,Jm).call(this,v,b)})})),Ne(this,Vt,ep).call(this)))})}getCurrentResult(){return E(this,Rs)}getQueries(){return E(this,Ws).map(t=>t.getCurrentQuery())}getObservers(){return E(this,Ws)}getOptimisticResult(t,s){const n=Ne(this,Vt,Xm).call(this,t),a=n.map(h=>h.observer.getOptimisticResult(h.defaultedQueryOptions)),c=n.map(h=>h.defaultedQueryOptions.queryHash);return[a,h=>Ne(this,Vt,Zm).call(this,h??a,s,c),()=>Ne(this,Vt,Qm).call(this,a,n)]}},pl=new WeakMap,Rs=new WeakMap,_l=new WeakMap,ta=new WeakMap,Ws=new WeakMap,ln=new WeakMap,nc=new WeakMap,ac=new WeakMap,lc=new WeakMap,oc=new WeakMap,Vt=new WeakSet,Qm=function(t,s){return s.map((n,a)=>{const c=t[a];return n.defaultedQueryOptions.notifyOnChangeProps?c:n.observer.trackResult(c,h=>{s.forEach(d=>{d.observer.trackProp(h)})})})},Zm=function(t,s,n){if(s){const a=E(this,lc),c=n!==void 0&&a!==void 0&&(a.length!==n.length||n.some((h,d)=>h!==a[d]));return(!E(this,ln)||E(this,Rs)!==E(this,ac)||c||s!==E(this,nc))&&(he(this,nc,s),he(this,ac,E(this,Rs)),n!==void 0&&he(this,lc,n),he(this,ln,o_(E(this,ln),s(t)))),E(this,ln)}return t},Ux=function(){var t;return((t=E(this,ta))==null?void 0:t.combine)!==void 0&&E(this,Ws).some((s,n)=>{var a;return s.options.suspense&&((a=E(this,Rs)[n])==null?void 0:a.data)===void 0})},Xm=function(t){const s=new Map;E(this,Ws).forEach(a=>{const c=a.options.queryHash;if(!c)return;const h=s.get(c);h?h.push(a):s.set(c,[a])});const n=[];return t.forEach(a=>{var f;const c=E(this,pl).defaultQueryOptions(a),d=((f=s.get(c.queryHash))==null?void 0:f.shift())??new h_(E(this,pl),c);n.push({defaultedQueryOptions:c,observer:d})}),n},Jm=function(t,s){const n=E(this,Ws).indexOf(t);n!==-1&&(he(this,Rs,gN(E(this,Rs),n,s)),Ne(this,Vt,ep).call(this))},ep=function(){var t;if(this.hasListeners()){const s=Ne(this,Vt,Qm).call(this,E(this,Rs),E(this,oc)),n=Ne(this,Vt,Ux).call(this),a=E(this,ln),c=n?a:Ne(this,Vt,Zm).call(this,s,(t=E(this,ta))==null?void 0:t.combine);(n||a!==c)&&jt.batch(()=>{this.listeners.forEach(h=>{h(E(this,Rs))})})}},Ex),Di,Tx,yN=(Tx=class extends da{constructor(t={}){super();ge(this,Di);this.config=t,he(this,Di,new Map)}build(t,s,n){const a=s.queryKey,c=s.queryHash??l_(a,s);let h=this.get(c);return h||(h=new hN({client:t,queryKey:a,queryHash:c,options:t.defaultQueryOptions(s),state:n,defaultOptions:t.getQueryDefaults(a)}),this.add(h)),h}add(t){E(this,Di).has(t.queryHash)||(E(this,Di).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=E(this,Di).get(t.queryHash);s&&(t.destroy(),s===t&&E(this,Di).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){jt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return E(this,Di).get(t)}getAll(){return[...E(this,Di).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(n=>Gb(s,n))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(n=>Gb(t,n)):s}notify(t){jt.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){jt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){jt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Di=new WeakMap,Tx),wt,on,cn,gl,vl,un,yl,bl,Ox,bN=(Ox=class{constructor(e={}){ge(this,wt);ge(this,on);ge(this,cn);ge(this,gl);ge(this,vl);ge(this,un);ge(this,yl);ge(this,bl);he(this,wt,e.queryCache||new yN),he(this,on,e.mutationCache||new pN),he(this,cn,e.defaultOptions||{}),he(this,gl,new Map),he(this,vl,new Map),he(this,un,0)}mount(){Du(this,un)._++,E(this,un)===1&&(he(this,yl,a_.subscribe(async e=>{e&&(await this.resumePausedMutations(),E(this,wt).onFocus())})),he(this,bl,ch.subscribe(async e=>{e&&(await this.resumePausedMutations(),E(this,wt).onOnline())})))}unmount(){var e,t;Du(this,un)._--,E(this,un)===0&&((e=E(this,yl))==null||e.call(this),he(this,yl,void 0),(t=E(this,bl))==null||t.call(this),he(this,bl,void 0))}isFetching(e){return E(this,wt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return E(this,on).findAll({...e,status:"pending"}).length}getQueryData(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=E(this,wt).get(t.queryHash))==null?void 0:s.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=E(this,wt).build(this,t),n=s.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(pn(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return E(this,wt).findAll(e).map(({queryKey:t,state:s})=>{const n=s.data;return[t,n]})}setQueryData(e,t,s){const n=this.defaultQueryOptions({queryKey:e}),a=E(this,wt).get(n.queryHash),c=a==null?void 0:a.state.data,h=Jk(t,c);if(h!==void 0)return E(this,wt).build(this,n).setData(h,{...s,manual:!0})}setQueriesData(e,t,s){return jt.batch(()=>E(this,wt).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,s)]))}getQueryState(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=E(this,wt).get(t.queryHash))==null?void 0:s.state}removeQueries(e){const t=E(this,wt);jt.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=E(this,wt);return jt.batch(()=>(s.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},n=jt.batch(()=>E(this,wt).findAll(e).map(a=>a.cancel(s)));return Promise.all(n).then(ps).catch(ps)}invalidateQueries(e,t={}){return jt.batch(()=>(E(this,wt).findAll(e).forEach(s=>{s.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},n=jt.batch(()=>E(this,wt).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let c=a.fetch(void 0,s);return s.throwOnError||(c=c.catch(ps)),a.state.fetchStatus==="paused"?Promise.resolve():c}));return Promise.all(n).then(ps)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=E(this,wt).build(this,t);return s.isStaleByTime(pn(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ps).catch(ps)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ps).catch(ps)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return ch.isOnline()?E(this,on).resumePausedMutations():Promise.resolve()}getQueryCache(){return E(this,wt)}getMutationCache(){return E(this,on)}getDefaultOptions(){return E(this,cn)}setDefaultOptions(e){he(this,cn,e)}setQueryDefaults(e,t){E(this,gl).set(ra(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...E(this,gl).values()],s={};return t.forEach(n=>{Sl(e,n.queryKey)&&Object.assign(s,n.defaultOptions)}),s}setMutationDefaults(e,t){E(this,vl).set(ra(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...E(this,vl).values()],s={};return t.forEach(n=>{Sl(e,n.mutationKey)&&Object.assign(s,n.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...E(this,cn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=l_(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===c_&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...E(this,cn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){E(this,wt).clear(),E(this,on).clear()}},wt=new WeakMap,on=new WeakMap,cn=new WeakMap,gl=new WeakMap,vl=new WeakMap,un=new WeakMap,yl=new WeakMap,bl=new WeakMap,Ox),im={exports:{}},Me={};/**
11
+ * @license React
12
+ * react.production.js
13
+ *
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var n0;function SN(){if(n0)return Me;n0=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),h=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),b=Symbol.iterator;function S(M){return M===null||typeof M!="object"?null:(M=b&&M[b]||M["@@iterator"],typeof M=="function"?M:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,k={};function N(M,U,ae){this.props=M,this.context=U,this.refs=k,this.updater=ae||x}N.prototype.isReactComponent={},N.prototype.setState=function(M,U){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,U,"setState")},N.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function L(){}L.prototype=N.prototype;function R(M,U,ae){this.props=M,this.context=U,this.refs=k,this.updater=ae||x}var D=R.prototype=new L;D.constructor=R,w(D,N.prototype),D.isPureReactComponent=!0;var Y=Array.isArray;function K(){}var Z={H:null,A:null,T:null,S:null},Q=Object.prototype.hasOwnProperty;function z(M,U,ae){var V=ae.ref;return{$$typeof:e,type:M,key:U,ref:V!==void 0?V:null,props:ae}}function G(M,U){return z(M.type,U,M.props)}function le(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function H(M){var U={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(ae){return U[ae]})}var O=/\/+/g;function W(M,U){return typeof M=="object"&&M!==null&&M.key!=null?H(""+M.key):U.toString(36)}function ee(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(K,K):(M.status="pending",M.then(function(U){M.status==="pending"&&(M.status="fulfilled",M.value=U)},function(U){M.status==="pending"&&(M.status="rejected",M.reason=U)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function T(M,U,ae,V,de){var _e=typeof M;(_e==="undefined"||_e==="boolean")&&(M=null);var Ae=!1;if(M===null)Ae=!0;else switch(_e){case"bigint":case"string":case"number":Ae=!0;break;case"object":switch(M.$$typeof){case e:case t:Ae=!0;break;case g:return Ae=M._init,T(Ae(M._payload),U,ae,V,de)}}if(Ae)return de=de(M),Ae=V===""?"."+W(M,0):V,Y(de)?(ae="",Ae!=null&&(ae=Ae.replace(O,"$&/")+"/"),T(de,U,ae,"",function(Ds){return Ds})):de!=null&&(le(de)&&(de=G(de,ae+(de.key==null||M&&M.key===de.key?"":(""+de.key).replace(O,"$&/")+"/")+Ae)),U.push(de)),1;Ae=0;var nt=V===""?".":V+":";if(Y(M))for(var Xe=0;Xe<M.length;Xe++)V=M[Xe],_e=nt+W(V,Xe),Ae+=T(V,U,ae,_e,de);else if(Xe=S(M),typeof Xe=="function")for(M=Xe.call(M),Xe=0;!(V=M.next()).done;)V=V.value,_e=nt+W(V,Xe++),Ae+=T(V,U,ae,_e,de);else if(_e==="object"){if(typeof M.then=="function")return T(ee(M),U,ae,V,de);throw U=String(M),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.")}return Ae}function F(M,U,ae){if(M==null)return M;var V=[],de=0;return T(M,V,"","",function(_e){return U.call(ae,_e,de++)}),V}function J(M){if(M._status===-1){var U=M._result;U=U(),U.then(function(ae){(M._status===0||M._status===-1)&&(M._status=1,M._result=ae)},function(ae){(M._status===0||M._status===-1)&&(M._status=2,M._result=ae)}),M._status===-1&&(M._status=0,M._result=U)}if(M._status===1)return M._result.default;throw M._result}var ve=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var U=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(U))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},oe={map:F,forEach:function(M,U,ae){F(M,function(){U.apply(this,arguments)},ae)},count:function(M){var U=0;return F(M,function(){U++}),U},toArray:function(M){return F(M,function(U){return U})||[]},only:function(M){if(!le(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Me.Activity=v,Me.Children=oe,Me.Component=N,Me.Fragment=s,Me.Profiler=a,Me.PureComponent=R,Me.StrictMode=n,Me.Suspense=f,Me.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Z,Me.__COMPILER_RUNTIME={__proto__:null,c:function(M){return Z.H.useMemoCache(M)}},Me.cache=function(M){return function(){return M.apply(null,arguments)}},Me.cacheSignal=function(){return null},Me.cloneElement=function(M,U,ae){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var V=w({},M.props),de=M.key;if(U!=null)for(_e in U.key!==void 0&&(de=""+U.key),U)!Q.call(U,_e)||_e==="key"||_e==="__self"||_e==="__source"||_e==="ref"&&U.ref===void 0||(V[_e]=U[_e]);var _e=arguments.length-2;if(_e===1)V.children=ae;else if(1<_e){for(var Ae=Array(_e),nt=0;nt<_e;nt++)Ae[nt]=arguments[nt+2];V.children=Ae}return z(M.type,de,V)},Me.createContext=function(M){return M={$$typeof:h,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:c,_context:M},M},Me.createElement=function(M,U,ae){var V,de={},_e=null;if(U!=null)for(V in U.key!==void 0&&(_e=""+U.key),U)Q.call(U,V)&&V!=="key"&&V!=="__self"&&V!=="__source"&&(de[V]=U[V]);var Ae=arguments.length-2;if(Ae===1)de.children=ae;else if(1<Ae){for(var nt=Array(Ae),Xe=0;Xe<Ae;Xe++)nt[Xe]=arguments[Xe+2];de.children=nt}if(M&&M.defaultProps)for(V in Ae=M.defaultProps,Ae)de[V]===void 0&&(de[V]=Ae[V]);return z(M,_e,de)},Me.createRef=function(){return{current:null}},Me.forwardRef=function(M){return{$$typeof:d,render:M}},Me.isValidElement=le,Me.lazy=function(M){return{$$typeof:g,_payload:{_status:-1,_result:M},_init:J}},Me.memo=function(M,U){return{$$typeof:m,type:M,compare:U===void 0?null:U}},Me.startTransition=function(M){var U=Z.T,ae={};Z.T=ae;try{var V=M(),de=Z.S;de!==null&&de(ae,V),typeof V=="object"&&V!==null&&typeof V.then=="function"&&V.then(K,ve)}catch(_e){ve(_e)}finally{U!==null&&ae.types!==null&&(U.types=ae.types),Z.T=U}},Me.unstable_useCacheRefresh=function(){return Z.H.useCacheRefresh()},Me.use=function(M){return Z.H.use(M)},Me.useActionState=function(M,U,ae){return Z.H.useActionState(M,U,ae)},Me.useCallback=function(M,U){return Z.H.useCallback(M,U)},Me.useContext=function(M){return Z.H.useContext(M)},Me.useDebugValue=function(){},Me.useDeferredValue=function(M,U){return Z.H.useDeferredValue(M,U)},Me.useEffect=function(M,U){return Z.H.useEffect(M,U)},Me.useEffectEvent=function(M){return Z.H.useEffectEvent(M)},Me.useId=function(){return Z.H.useId()},Me.useImperativeHandle=function(M,U,ae){return Z.H.useImperativeHandle(M,U,ae)},Me.useInsertionEffect=function(M,U){return Z.H.useInsertionEffect(M,U)},Me.useLayoutEffect=function(M,U){return Z.H.useLayoutEffect(M,U)},Me.useMemo=function(M,U){return Z.H.useMemo(M,U)},Me.useOptimistic=function(M,U){return Z.H.useOptimistic(M,U)},Me.useReducer=function(M,U,ae){return Z.H.useReducer(M,U,ae)},Me.useRef=function(M){return Z.H.useRef(M)},Me.useState=function(M){return Z.H.useState(M)},Me.useSyncExternalStore=function(M,U,ae){return Z.H.useSyncExternalStore(M,U,ae)},Me.useTransition=function(){return Z.H.useTransition()},Me.version="19.2.8",Me}var a0;function f_(){return a0||(a0=1,im.exports=SN()),im.exports}var j=f_(),Kx=j.createContext(void 0),qe=e=>{const t=j.useContext(Kx);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},xN=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx(Kx.Provider,{value:e,children:t})),$x=j.createContext(!1),Wx=()=>j.useContext($x);$x.Provider;function wN(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var CN=j.createContext(wN()),Vx=()=>j.useContext(CN),Yx=(e,t,s)=>{const n=s!=null&&s.state.error&&typeof e.throwOnError=="function"?u_(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},Gx=e=>{j.useEffect(()=>{e.clearReset()},[e])},Qx=({result:e,errorResetBoundary:t,throwOnError:s,query:n,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(a&&e.data===void 0||u_(s,[e.error,n])),Zx=e=>{if(e.suspense){const s=a=>a==="static"?a:Math.max(a??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...a)=>s(n(...a)):s(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},jN=(e,t)=>e.isLoading&&e.isFetching&&!t,tp=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,sp=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Xx({queries:e,...t},s){const n=qe(),a=Wx(),c=Vx(),h=j.useMemo(()=>e.map(w=>{const k=n.defaultQueryOptions(w);return k._optimisticResults=a?"isRestoring":"optimistic",k}),[e,n,a]);h.forEach(w=>{Zx(w);const k=n.getQueryCache().get(w.queryHash);Yx(w,c,k)}),Gx(c);const[d]=j.useState(()=>new vN(n,h,t)),[f,m,g]=d.getOptimisticResult(h,t.combine),v=!a&&t.subscribed!==!1;j.useSyncExternalStore(j.useCallback(w=>v?d.subscribe(jt.batchCalls(w)):ps,[d,v]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),j.useEffect(()=>{d.setQueries(h,t)},[h,t,d]);const S=f.some((w,k)=>tp(h[k],w))?f.flatMap((w,k)=>{const N=h[k];if(N&&tp(N,w)){const L=new h_(n,N);return sp(N,L,c)}return[]}):[];if(S.length>0)throw Promise.all(S);const x=f.find((w,k)=>{const N=h[k];return N&&Qx({result:w,errorResetBoundary:c,throwOnError:N.throwOnError,query:n.getQueryCache().get(N.queryHash),suspense:N.suspense})});if(x!=null&&x.error)throw x.error;return m(g())}function kN(e,t,s){var S,x,w,k;const n=Wx(),a=Vx(),c=qe(),h=c.defaultQueryOptions(e);(x=(S=c.getDefaultOptions().queries)==null?void 0:S._experimental_beforeQuery)==null||x.call(S,h);const d=c.getQueryCache().get(h.queryHash),f=e.subscribed!==!1;h._optimisticResults=n?"isRestoring":f?"optimistic":void 0,Zx(h),Yx(h,a,d),Gx(a);const m=!c.getQueryCache().get(h.queryHash),[g]=j.useState(()=>new t(c,h)),v=g.getOptimisticResult(h),b=!n&&f;if(j.useSyncExternalStore(j.useCallback(N=>{const L=b?g.subscribe(jt.batchCalls(N)):ps;return g.updateResult(),L},[g,b]),()=>g.getCurrentResult(),()=>g.getCurrentResult()),j.useEffect(()=>{g.setOptions(h)},[h,g]),tp(h,v))throw sp(h,g,a);if(Qx({result:v,errorResetBoundary:a,throwOnError:h.throwOnError,query:d,suspense:h.suspense}))throw v.error;if((k=(w=c.getDefaultOptions().queries)==null?void 0:w._experimental_afterQuery)==null||k.call(w,h,v),h.experimental_prefetchInRender&&!Ko.isServer()&&jN(v,n)){const N=m?sp(h,g,a):d==null?void 0:d.promise;N==null||N.catch(ps).finally(()=>{g.updateResult()})}return h.notifyOnChangeProps?v:g.trackResult(v)}function ye(e,t){return kN(e,h_)}function Te(e,t){const s=qe(),[n]=j.useState(()=>new _N(s,e));j.useEffect(()=>{n.setOptions(e)},[n,e]);const a=j.useSyncExternalStore(j.useCallback(h=>n.subscribe(jt.batchCalls(h)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),c=j.useCallback((h,d)=>{n.mutate(h,d).catch(ps)},[n]);if(a.error&&u_(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:c,mutateAsync:a.mutate}}var rm={exports:{}},jo={},nm={exports:{}},am={};/**
19
+ * @license React
20
+ * scheduler.production.js
21
+ *
22
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
23
+ *
24
+ * This source code is licensed under the MIT license found in the
25
+ * LICENSE file in the root directory of this source tree.
26
+ */var l0;function NN(){return l0||(l0=1,(function(e){function t(T,F){var J=T.length;T.push(F);e:for(;0<J;){var ve=J-1>>>1,oe=T[ve];if(0<a(oe,F))T[ve]=F,T[J]=oe,J=ve;else break e}}function s(T){return T.length===0?null:T[0]}function n(T){if(T.length===0)return null;var F=T[0],J=T.pop();if(J!==F){T[0]=J;e:for(var ve=0,oe=T.length,M=oe>>>1;ve<M;){var U=2*(ve+1)-1,ae=T[U],V=U+1,de=T[V];if(0>a(ae,J))V<oe&&0>a(de,ae)?(T[ve]=de,T[V]=J,ve=V):(T[ve]=ae,T[U]=J,ve=U);else if(V<oe&&0>a(de,J))T[ve]=de,T[V]=J,ve=V;else break e}}return F}function a(T,F){var J=T.sortIndex-F.sortIndex;return J!==0?J:T.id-F.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var h=Date,d=h.now();e.unstable_now=function(){return h.now()-d}}var f=[],m=[],g=1,v=null,b=3,S=!1,x=!1,w=!1,k=!1,N=typeof setTimeout=="function"?setTimeout:null,L=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function D(T){for(var F=s(m);F!==null;){if(F.callback===null)n(m);else if(F.startTime<=T)n(m),F.sortIndex=F.expirationTime,t(f,F);else break;F=s(m)}}function Y(T){if(w=!1,D(T),!x)if(s(f)!==null)x=!0,K||(K=!0,H());else{var F=s(m);F!==null&&ee(Y,F.startTime-T)}}var K=!1,Z=-1,Q=5,z=-1;function G(){return k?!0:!(e.unstable_now()-z<Q)}function le(){if(k=!1,K){var T=e.unstable_now();z=T;var F=!0;try{e:{x=!1,w&&(w=!1,L(Z),Z=-1),S=!0;var J=b;try{t:{for(D(T),v=s(f);v!==null&&!(v.expirationTime>T&&G());){var ve=v.callback;if(typeof ve=="function"){v.callback=null,b=v.priorityLevel;var oe=ve(v.expirationTime<=T);if(T=e.unstable_now(),typeof oe=="function"){v.callback=oe,D(T),F=!0;break t}v===s(f)&&n(f),D(T)}else n(f);v=s(f)}if(v!==null)F=!0;else{var M=s(m);M!==null&&ee(Y,M.startTime-T),F=!1}}break e}finally{v=null,b=J,S=!1}F=void 0}}finally{F?H():K=!1}}}var H;if(typeof R=="function")H=function(){R(le)};else if(typeof MessageChannel<"u"){var O=new MessageChannel,W=O.port2;O.port1.onmessage=le,H=function(){W.postMessage(null)}}else H=function(){N(le,0)};function ee(T,F){Z=N(function(){T(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(T){T.callback=null},e.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<T?Math.floor(1e3/T):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(T){switch(b){case 1:case 2:case 3:var F=3;break;default:F=b}var J=b;b=F;try{return T()}finally{b=J}},e.unstable_requestPaint=function(){k=!0},e.unstable_runWithPriority=function(T,F){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var J=b;b=T;try{return F()}finally{b=J}},e.unstable_scheduleCallback=function(T,F,J){var ve=e.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?ve+J:ve):J=ve,T){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=J+oe,T={id:g++,callback:F,priorityLevel:T,startTime:J,expirationTime:oe,sortIndex:-1},J>ve?(T.sortIndex=J,t(m,T),s(f)===null&&T===s(m)&&(w?(L(Z),Z=-1):w=!0,ee(Y,J-ve))):(T.sortIndex=oe,t(f,T),x||S||(x=!0,K||(K=!0,H()))),T},e.unstable_shouldYield=G,e.unstable_wrapCallback=function(T){var F=b;return function(){var J=b;b=F;try{return T.apply(this,arguments)}finally{b=J}}}})(am)),am}var o0;function EN(){return o0||(o0=1,nm.exports=NN()),nm.exports}var lm={exports:{}},ds={};/**
27
+ * @license React
28
+ * react-dom.production.js
29
+ *
30
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */var c0;function TN(){if(c0)return ds;c0=1;var e=f_();function t(f){var m="https://react.dev/errors/"+f;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)m+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+f+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var n={d:{f:s,r:function(){throw Error(t(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},a=Symbol.for("react.portal");function c(f,m,g){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:v==null?null:""+v,children:f,containerInfo:m,implementation:g}}var h=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(f,m){if(f==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return ds.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,ds.createPortal=function(f,m){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(t(299));return c(f,m,null,g)},ds.flushSync=function(f){var m=h.T,g=n.p;try{if(h.T=null,n.p=2,f)return f()}finally{h.T=m,n.p=g,n.d.f()}},ds.preconnect=function(f,m){typeof f=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,n.d.C(f,m))},ds.prefetchDNS=function(f){typeof f=="string"&&n.d.D(f)},ds.preinit=function(f,m){if(typeof f=="string"&&m&&typeof m.as=="string"){var g=m.as,v=d(g,m.crossOrigin),b=typeof m.integrity=="string"?m.integrity:void 0,S=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;g==="style"?n.d.S(f,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:S}):g==="script"&&n.d.X(f,{crossOrigin:v,integrity:b,fetchPriority:S,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},ds.preinitModule=function(f,m){if(typeof f=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var g=d(m.as,m.crossOrigin);n.d.M(f,{crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&n.d.M(f)},ds.preload=function(f,m){if(typeof f=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var g=m.as,v=d(g,m.crossOrigin);n.d.L(f,g,{crossOrigin:v,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},ds.preloadModule=function(f,m){if(typeof f=="string")if(m){var g=d(m.as,m.crossOrigin);n.d.m(f,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else n.d.m(f)},ds.requestFormReset=function(f){n.d.r(f)},ds.unstable_batchedUpdates=function(f,m){return f(m)},ds.useFormState=function(f,m,g){return h.H.useFormState(f,m,g)},ds.useFormStatus=function(){return h.H.useHostTransitionStatus()},ds.version="19.2.8",ds}var u0;function ON(){if(u0)return lm.exports;u0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),lm.exports=TN(),lm.exports}/**
35
+ * @license React
36
+ * react-dom-client.production.js
37
+ *
38
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */var h0;function AN(){if(h0)return jo;h0=1;var e=EN(),t=f_(),s=ON();function n(i){var r="https://react.dev/errors/"+i;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)r+="&args[]="+encodeURIComponent(arguments[o])}return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var r=i,o=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(o=r.return),i=r.return;while(i)}return r.tag===3?o:null}function h(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function d(i){if(i.tag===31){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function f(i){if(c(i)!==i)throw Error(n(188))}function m(i){var r=i.alternate;if(!r){if(r=c(i),r===null)throw Error(n(188));return r!==i?null:i}for(var o=i,u=r;;){var p=o.return;if(p===null)break;var _=p.alternate;if(_===null){if(u=p.return,u!==null){o=u;continue}break}if(p.child===_.child){for(_=p.child;_;){if(_===o)return f(p),i;if(_===u)return f(p),r;_=_.sibling}throw Error(n(188))}if(o.return!==u.return)o=p,u=_;else{for(var y=!1,C=p.child;C;){if(C===o){y=!0,o=p,u=_;break}if(C===u){y=!0,u=p,o=_;break}C=C.sibling}if(!y){for(C=_.child;C;){if(C===o){y=!0,o=_,u=p;break}if(C===u){y=!0,u=_,o=p;break}C=C.sibling}if(!y)throw Error(n(189))}}if(o.alternate!==u)throw Error(n(190))}if(o.tag!==3)throw Error(n(188));return o.stateNode.current===o?i:r}function g(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i;for(i=i.child;i!==null;){if(r=g(i),r!==null)return r;i=i.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),R=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),Y=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),G=Symbol.for("react.memo_cache_sentinel"),le=Symbol.iterator;function H(i){return i===null||typeof i!="object"?null:(i=le&&i[le]||i["@@iterator"],typeof i=="function"?i:null)}var O=Symbol.for("react.client.reference");function W(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===O?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case w:return"Fragment";case N:return"Profiler";case k:return"StrictMode";case Y:return"Suspense";case K:return"SuspenseList";case z:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case x:return"Portal";case R:return i.displayName||"Context";case L:return(i._context.displayName||"Context")+".Consumer";case D:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case Z:return r=i.displayName||null,r!==null?r:W(i.type)||"Memo";case Q:r=i._payload,i=i._init;try{return W(i(r))}catch{}}return null}var ee=Array.isArray,T=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},ve=[],oe=-1;function M(i){return{current:i}}function U(i){0>oe||(i.current=ve[oe],ve[oe]=null,oe--)}function ae(i,r){oe++,ve[oe]=i.current,i.current=r}var V=M(null),de=M(null),_e=M(null),Ae=M(null);function nt(i,r){switch(ae(_e,r),ae(de,i),ae(V,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?mb(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=mb(r),i=pb(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}U(V),ae(V,i)}function Xe(){U(V),U(de),U(_e)}function Ds(i){i.memoizedState!==null&&ae(Ae,i);var r=V.current,o=pb(r,i.type);r!==o&&(ae(de,i),ae(V,o))}function xi(i){de.current===i&&(U(V),U(de)),Ae.current===i&&(U(Ae),bo._currentValue=J)}var Zs,et;function mi(i){if(Zs===void 0)try{throw Error()}catch(o){var r=o.stack.trim().match(/\n( *(at )?)/);Zs=r&&r[1]||"",et=-1<o.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<o.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+Zs+i+et}var qh=!1;function zh(i,r){if(!i||qh)return"";qh=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(r){var re=function(){throw Error()};if(Object.defineProperty(re.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(re,[])}catch(X){var $=X}Reflect.construct(i,[],re)}else{try{re.call()}catch(X){$=X}i.call(re.prototype)}}else{try{throw Error()}catch(X){$=X}(re=i())&&typeof re.catch=="function"&&re.catch(function(){})}}catch(X){if(X&&$&&typeof X.stack=="string")return[X.stack,$.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var _=u.DetermineComponentFrameRoot(),y=_[0],C=_[1];if(y&&C){var A=y.split(`
45
+ `),I=C.split(`
46
+ `);for(p=u=0;u<A.length&&!A[u].includes("DetermineComponentFrameRoot");)u++;for(;p<I.length&&!I[p].includes("DetermineComponentFrameRoot");)p++;if(u===A.length||p===I.length)for(u=A.length-1,p=I.length-1;1<=u&&0<=p&&A[u]!==I[p];)p--;for(;1<=u&&0<=p;u--,p--)if(A[u]!==I[p]){if(u!==1||p!==1)do if(u--,p--,0>p||A[u]!==I[p]){var se=`
47
+ `+A[u].replace(" at new "," at ");return i.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",i.displayName)),se}while(1<=u&&0<=p);break}}}finally{qh=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?mi(o):""}function SC(i,r){switch(i.tag){case 26:case 27:case 5:return mi(i.type);case 16:return mi("Lazy");case 13:return i.child!==r&&r!==null?mi("Suspense Fallback"):mi("Suspense");case 19:return mi("SuspenseList");case 0:case 15:return zh(i.type,!1);case 11:return zh(i.type.render,!1);case 1:return zh(i.type,!0);case 31:return mi("Activity");default:return""}}function $_(i){try{var r="",o=null;do r+=SC(i,o),o=i,i=i.return;while(i);return r}catch(u){return`
48
+ Error generating stack: `+u.message+`
49
+ `+u.stack}}var Ph=Object.prototype.hasOwnProperty,Hh=e.unstable_scheduleCallback,Fh=e.unstable_cancelCallback,xC=e.unstable_shouldYield,wC=e.unstable_requestPaint,Ms=e.unstable_now,CC=e.unstable_getCurrentPriorityLevel,W_=e.unstable_ImmediatePriority,V_=e.unstable_UserBlockingPriority,_c=e.unstable_NormalPriority,jC=e.unstable_LowPriority,Y_=e.unstable_IdlePriority,kC=e.log,NC=e.unstable_setDisableYieldValue,Al=null,Bs=null;function Sr(i){if(typeof kC=="function"&&NC(i),Bs&&typeof Bs.setStrictMode=="function")try{Bs.setStrictMode(Al,i)}catch{}}var Ls=Math.clz32?Math.clz32:OC,EC=Math.log,TC=Math.LN2;function OC(i){return i>>>=0,i===0?32:31-(EC(i)/TC|0)|0}var gc=256,vc=262144,yc=4194304;function xn(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function bc(i,r,o){var u=i.pendingLanes;if(u===0)return 0;var p=0,_=i.suspendedLanes,y=i.pingedLanes;i=i.warmLanes;var C=u&134217727;return C!==0?(u=C&~_,u!==0?p=xn(u):(y&=C,y!==0?p=xn(y):o||(o=C&~i,o!==0&&(p=xn(o))))):(C=u&~_,C!==0?p=xn(C):y!==0?p=xn(y):o||(o=u&~i,o!==0&&(p=xn(o)))),p===0?0:r!==0&&r!==p&&(r&_)===0&&(_=p&-p,o=r&-r,_>=o||_===32&&(o&4194048)!==0)?r:p}function Rl(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function AC(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function G_(){var i=yc;return yc<<=1,(yc&62914560)===0&&(yc=4194304),i}function Ih(i){for(var r=[],o=0;31>o;o++)r.push(i);return r}function Dl(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function RC(i,r,o,u,p,_){var y=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var C=i.entanglements,A=i.expirationTimes,I=i.hiddenUpdates;for(o=y&~o;0<o;){var se=31-Ls(o),re=1<<se;C[se]=0,A[se]=-1;var $=I[se];if($!==null)for(I[se]=null,se=0;se<$.length;se++){var X=$[se];X!==null&&(X.lane&=-536870913)}o&=~re}u!==0&&Q_(i,u,0),_!==0&&p===0&&i.tag!==0&&(i.suspendedLanes|=_&~(y&~r))}function Q_(i,r,o){i.pendingLanes|=r,i.suspendedLanes&=~r;var u=31-Ls(r);i.entangledLanes|=r,i.entanglements[u]=i.entanglements[u]|1073741824|o&261930}function Z_(i,r){var o=i.entangledLanes|=r;for(i=i.entanglements;o;){var u=31-Ls(o),p=1<<u;p&r|i[u]&r&&(i[u]|=r),o&=~p}}function X_(i,r){var o=r&-r;return o=(o&42)!==0?1:Uh(o),(o&(i.suspendedLanes|r))!==0?0:o}function Uh(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function Kh(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function J_(){var i=F.p;return i!==0?i:(i=window.event,i===void 0?32:zb(i.type))}function eg(i,r){var o=F.p;try{return F.p=i,r()}finally{F.p=o}}var xr=Math.random().toString(36).slice(2),is="__reactFiber$"+xr,xs="__reactProps$"+xr,_a="__reactContainer$"+xr,$h="__reactEvents$"+xr,DC="__reactListeners$"+xr,MC="__reactHandles$"+xr,tg="__reactResources$"+xr,Ml="__reactMarker$"+xr;function Wh(i){delete i[is],delete i[xs],delete i[$h],delete i[DC],delete i[MC]}function ga(i){var r=i[is];if(r)return r;for(var o=i.parentNode;o;){if(r=o[_a]||o[is]){if(o=r.alternate,r.child!==null||o!==null&&o.child!==null)for(i=xb(i);i!==null;){if(o=i[is])return o;i=xb(i)}return r}i=o,o=i.parentNode}return null}function va(i){if(i=i[is]||i[_a]){var r=i.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return i}return null}function Bl(i){var r=i.tag;if(r===5||r===26||r===27||r===6)return i.stateNode;throw Error(n(33))}function ya(i){var r=i[tg];return r||(r=i[tg]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function Yt(i){i[Ml]=!0}var sg=new Set,ig={};function wn(i,r){ba(i,r),ba(i+"Capture",r)}function ba(i,r){for(ig[i]=r,i=0;i<r.length;i++)sg.add(r[i])}var BC=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),rg={},ng={};function LC(i){return Ph.call(ng,i)?!0:Ph.call(rg,i)?!1:BC.test(i)?ng[i]=!0:(rg[i]=!0,!1)}function Sc(i,r,o){if(LC(r))if(o===null)i.removeAttribute(r);else{switch(typeof o){case"undefined":case"function":case"symbol":i.removeAttribute(r);return;case"boolean":var u=r.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){i.removeAttribute(r);return}}i.setAttribute(r,""+o)}}function xc(i,r,o){if(o===null)i.removeAttribute(r);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(r);return}i.setAttribute(r,""+o)}}function Ii(i,r,o,u){if(u===null)i.removeAttribute(o);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(o);return}i.setAttributeNS(r,o,""+u)}}function Xs(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ag(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function qC(i,r,o){var u=Object.getOwnPropertyDescriptor(i.constructor.prototype,r);if(!i.hasOwnProperty(r)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var p=u.get,_=u.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return p.call(this)},set:function(y){o=""+y,_.call(this,y)}}),Object.defineProperty(i,r,{enumerable:u.enumerable}),{getValue:function(){return o},setValue:function(y){o=""+y},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function Vh(i){if(!i._valueTracker){var r=ag(i)?"checked":"value";i._valueTracker=qC(i,r,""+i[r])}}function lg(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var o=r.getValue(),u="";return i&&(u=ag(i)?i.checked?"true":"false":i.value),i=u,i!==o?(r.setValue(i),!0):!1}function wc(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var zC=/[\n"\\]/g;function Js(i){return i.replace(zC,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Yh(i,r,o,u,p,_,y,C){i.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?i.type=y:i.removeAttribute("type"),r!=null?y==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Xs(r)):i.value!==""+Xs(r)&&(i.value=""+Xs(r)):y!=="submit"&&y!=="reset"||i.removeAttribute("value"),r!=null?Gh(i,y,Xs(r)):o!=null?Gh(i,y,Xs(o)):u!=null&&i.removeAttribute("value"),p==null&&_!=null&&(i.defaultChecked=!!_),p!=null&&(i.checked=p&&typeof p!="function"&&typeof p!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+Xs(C):i.removeAttribute("name")}function og(i,r,o,u,p,_,y,C){if(_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.type=_),r!=null||o!=null){if(!(_!=="submit"&&_!=="reset"||r!=null)){Vh(i);return}o=o!=null?""+Xs(o):"",r=r!=null?""+Xs(r):o,C||r===i.value||(i.value=r),i.defaultValue=r}u=u??p,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=C?i.checked:!!u,i.defaultChecked=!!u,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.name=y),Vh(i)}function Gh(i,r,o){r==="number"&&wc(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Sa(i,r,o,u){if(i=i.options,r){r={};for(var p=0;p<o.length;p++)r["$"+o[p]]=!0;for(o=0;o<i.length;o++)p=r.hasOwnProperty("$"+i[o].value),i[o].selected!==p&&(i[o].selected=p),p&&u&&(i[o].defaultSelected=!0)}else{for(o=""+Xs(o),r=null,p=0;p<i.length;p++){if(i[p].value===o){i[p].selected=!0,u&&(i[p].defaultSelected=!0);return}r!==null||i[p].disabled||(r=i[p])}r!==null&&(r.selected=!0)}}function cg(i,r,o){if(r!=null&&(r=""+Xs(r),r!==i.value&&(i.value=r),o==null)){i.defaultValue!==r&&(i.defaultValue=r);return}i.defaultValue=o!=null?""+Xs(o):""}function ug(i,r,o,u){if(r==null){if(u!=null){if(o!=null)throw Error(n(92));if(ee(u)){if(1<u.length)throw Error(n(93));u=u[0]}o=u}o==null&&(o=""),r=o}o=Xs(r),i.defaultValue=o,u=i.textContent,u===o&&u!==""&&u!==null&&(i.value=u),Vh(i)}function xa(i,r){if(r){var o=i.firstChild;if(o&&o===i.lastChild&&o.nodeType===3){o.nodeValue=r;return}}i.textContent=r}var PC=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function hg(i,r,o){var u=r.indexOf("--")===0;o==null||typeof o=="boolean"||o===""?u?i.setProperty(r,""):r==="float"?i.cssFloat="":i[r]="":u?i.setProperty(r,o):typeof o!="number"||o===0||PC.has(r)?r==="float"?i.cssFloat=o:i[r]=(""+o).trim():i[r]=o+"px"}function dg(i,r,o){if(r!=null&&typeof r!="object")throw Error(n(62));if(i=i.style,o!=null){for(var u in o)!o.hasOwnProperty(u)||r!=null&&r.hasOwnProperty(u)||(u.indexOf("--")===0?i.setProperty(u,""):u==="float"?i.cssFloat="":i[u]="");for(var p in r)u=r[p],r.hasOwnProperty(p)&&o[p]!==u&&hg(i,p,u)}else for(var _ in r)r.hasOwnProperty(_)&&hg(i,_,r[_])}function Qh(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var HC=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),FC=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Cc(i){return FC.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Ui(){}var Zh=null;function Xh(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var wa=null,Ca=null;function fg(i){var r=va(i);if(r&&(i=r.stateNode)){var o=i[xs]||null;e:switch(i=r.stateNode,r.type){case"input":if(Yh(i,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name),r=o.name,o.type==="radio"&&r!=null){for(o=i;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll('input[name="'+Js(""+r)+'"][type="radio"]'),r=0;r<o.length;r++){var u=o[r];if(u!==i&&u.form===i.form){var p=u[xs]||null;if(!p)throw Error(n(90));Yh(u,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name)}}for(r=0;r<o.length;r++)u=o[r],u.form===i.form&&lg(u)}break e;case"textarea":cg(i,o.value,o.defaultValue);break e;case"select":r=o.value,r!=null&&Sa(i,!!o.multiple,r,!1)}}}var Jh=!1;function mg(i,r,o){if(Jh)return i(r,o);Jh=!0;try{var u=i(r);return u}finally{if(Jh=!1,(wa!==null||Ca!==null)&&(hu(),wa&&(r=wa,i=Ca,Ca=wa=null,fg(r),i)))for(r=0;r<i.length;r++)fg(i[r])}}function Ll(i,r){var o=i.stateNode;if(o===null)return null;var u=o[xs]||null;if(u===null)return null;o=u[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(i=i.type,u=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!u;break e;default:i=!1}if(i)return null;if(o&&typeof o!="function")throw Error(n(231,r,typeof o));return o}var Ki=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ed=!1;if(Ki)try{var ql={};Object.defineProperty(ql,"passive",{get:function(){ed=!0}}),window.addEventListener("test",ql,ql),window.removeEventListener("test",ql,ql)}catch{ed=!1}var wr=null,td=null,jc=null;function pg(){if(jc)return jc;var i,r=td,o=r.length,u,p="value"in wr?wr.value:wr.textContent,_=p.length;for(i=0;i<o&&r[i]===p[i];i++);var y=o-i;for(u=1;u<=y&&r[o-u]===p[_-u];u++);return jc=p.slice(i,1<u?1-u:void 0)}function kc(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function Nc(){return!0}function _g(){return!1}function ws(i){function r(o,u,p,_,y){this._reactName=o,this._targetInst=p,this.type=u,this.nativeEvent=_,this.target=y,this.currentTarget=null;for(var C in i)i.hasOwnProperty(C)&&(o=i[C],this[C]=o?o(_):_[C]);return this.isDefaultPrevented=(_.defaultPrevented!=null?_.defaultPrevented:_.returnValue===!1)?Nc:_g,this.isPropagationStopped=_g,this}return v(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=Nc)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=Nc)},persist:function(){},isPersistent:Nc}),r}var Cn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ec=ws(Cn),zl=v({},Cn,{view:0,detail:0}),IC=ws(zl),sd,id,Pl,Tc=v({},zl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nd,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Pl&&(Pl&&i.type==="mousemove"?(sd=i.screenX-Pl.screenX,id=i.screenY-Pl.screenY):id=sd=0,Pl=i),sd)},movementY:function(i){return"movementY"in i?i.movementY:id}}),gg=ws(Tc),UC=v({},Tc,{dataTransfer:0}),KC=ws(UC),$C=v({},zl,{relatedTarget:0}),rd=ws($C),WC=v({},Cn,{animationName:0,elapsedTime:0,pseudoElement:0}),VC=ws(WC),YC=v({},Cn,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),GC=ws(YC),QC=v({},Cn,{data:0}),vg=ws(QC),ZC={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},XC={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},JC={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ej(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=JC[i])?!!r[i]:!1}function nd(){return ej}var tj=v({},zl,{key:function(i){if(i.key){var r=ZC[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=kc(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?XC[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nd,charCode:function(i){return i.type==="keypress"?kc(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?kc(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),sj=ws(tj),ij=v({},Tc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),yg=ws(ij),rj=v({},zl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nd}),nj=ws(rj),aj=v({},Cn,{propertyName:0,elapsedTime:0,pseudoElement:0}),lj=ws(aj),oj=v({},Tc,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),cj=ws(oj),uj=v({},Cn,{newState:0,oldState:0}),hj=ws(uj),dj=[9,13,27,32],ad=Ki&&"CompositionEvent"in window,Hl=null;Ki&&"documentMode"in document&&(Hl=document.documentMode);var fj=Ki&&"TextEvent"in window&&!Hl,bg=Ki&&(!ad||Hl&&8<Hl&&11>=Hl),Sg=" ",xg=!1;function wg(i,r){switch(i){case"keyup":return dj.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cg(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ja=!1;function mj(i,r){switch(i){case"compositionend":return Cg(r);case"keypress":return r.which!==32?null:(xg=!0,Sg);case"textInput":return i=r.data,i===Sg&&xg?null:i;default:return null}}function pj(i,r){if(ja)return i==="compositionend"||!ad&&wg(i,r)?(i=pg(),jc=td=wr=null,ja=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return bg&&r.locale!=="ko"?null:r.data;default:return null}}var _j={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function jg(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!_j[i.type]:r==="textarea"}function kg(i,r,o,u){wa?Ca?Ca.push(u):Ca=[u]:wa=u,r=vu(r,"onChange"),0<r.length&&(o=new Ec("onChange","change",null,o,u),i.push({event:o,listeners:r}))}var Fl=null,Il=null;function gj(i){ob(i,0)}function Oc(i){var r=Bl(i);if(lg(r))return i}function Ng(i,r){if(i==="change")return r}var Eg=!1;if(Ki){var ld;if(Ki){var od="oninput"in document;if(!od){var Tg=document.createElement("div");Tg.setAttribute("oninput","return;"),od=typeof Tg.oninput=="function"}ld=od}else ld=!1;Eg=ld&&(!document.documentMode||9<document.documentMode)}function Og(){Fl&&(Fl.detachEvent("onpropertychange",Ag),Il=Fl=null)}function Ag(i){if(i.propertyName==="value"&&Oc(Il)){var r=[];kg(r,Il,i,Xh(i)),mg(gj,r)}}function vj(i,r,o){i==="focusin"?(Og(),Fl=r,Il=o,Fl.attachEvent("onpropertychange",Ag)):i==="focusout"&&Og()}function yj(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Oc(Il)}function bj(i,r){if(i==="click")return Oc(r)}function Sj(i,r){if(i==="input"||i==="change")return Oc(r)}function xj(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var qs=typeof Object.is=="function"?Object.is:xj;function Ul(i,r){if(qs(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var o=Object.keys(i),u=Object.keys(r);if(o.length!==u.length)return!1;for(u=0;u<o.length;u++){var p=o[u];if(!Ph.call(r,p)||!qs(i[p],r[p]))return!1}return!0}function Rg(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Dg(i,r){var o=Rg(i);i=0;for(var u;o;){if(o.nodeType===3){if(u=i+o.textContent.length,i<=r&&u>=r)return{node:o,offset:r-i};i=u}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Rg(o)}}function Mg(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Mg(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Bg(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=wc(i.document);r instanceof i.HTMLIFrameElement;){try{var o=typeof r.contentWindow.location.href=="string"}catch{o=!1}if(o)i=r.contentWindow;else break;r=wc(i.document)}return r}function cd(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var wj=Ki&&"documentMode"in document&&11>=document.documentMode,ka=null,ud=null,Kl=null,hd=!1;function Lg(i,r,o){var u=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;hd||ka==null||ka!==wc(u)||(u=ka,"selectionStart"in u&&cd(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Kl&&Ul(Kl,u)||(Kl=u,u=vu(ud,"onSelect"),0<u.length&&(r=new Ec("onSelect","select",null,r,o),i.push({event:r,listeners:u}),r.target=ka)))}function jn(i,r){var o={};return o[i.toLowerCase()]=r.toLowerCase(),o["Webkit"+i]="webkit"+r,o["Moz"+i]="moz"+r,o}var Na={animationend:jn("Animation","AnimationEnd"),animationiteration:jn("Animation","AnimationIteration"),animationstart:jn("Animation","AnimationStart"),transitionrun:jn("Transition","TransitionRun"),transitionstart:jn("Transition","TransitionStart"),transitioncancel:jn("Transition","TransitionCancel"),transitionend:jn("Transition","TransitionEnd")},dd={},qg={};Ki&&(qg=document.createElement("div").style,"AnimationEvent"in window||(delete Na.animationend.animation,delete Na.animationiteration.animation,delete Na.animationstart.animation),"TransitionEvent"in window||delete Na.transitionend.transition);function kn(i){if(dd[i])return dd[i];if(!Na[i])return i;var r=Na[i],o;for(o in r)if(r.hasOwnProperty(o)&&o in qg)return dd[i]=r[o];return i}var zg=kn("animationend"),Pg=kn("animationiteration"),Hg=kn("animationstart"),Cj=kn("transitionrun"),jj=kn("transitionstart"),kj=kn("transitioncancel"),Fg=kn("transitionend"),Ig=new Map,fd="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");fd.push("scrollEnd");function pi(i,r){Ig.set(i,r),wn(r,[i])}var Ac=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},ei=[],Ea=0,md=0;function Rc(){for(var i=Ea,r=md=Ea=0;r<i;){var o=ei[r];ei[r++]=null;var u=ei[r];ei[r++]=null;var p=ei[r];ei[r++]=null;var _=ei[r];if(ei[r++]=null,u!==null&&p!==null){var y=u.pending;y===null?p.next=p:(p.next=y.next,y.next=p),u.pending=p}_!==0&&Ug(o,p,_)}}function Dc(i,r,o,u){ei[Ea++]=i,ei[Ea++]=r,ei[Ea++]=o,ei[Ea++]=u,md|=u,i.lanes|=u,i=i.alternate,i!==null&&(i.lanes|=u)}function pd(i,r,o,u){return Dc(i,r,o,u),Mc(i)}function Nn(i,r){return Dc(i,null,null,r),Mc(i)}function Ug(i,r,o){i.lanes|=o;var u=i.alternate;u!==null&&(u.lanes|=o);for(var p=!1,_=i.return;_!==null;)_.childLanes|=o,u=_.alternate,u!==null&&(u.childLanes|=o),_.tag===22&&(i=_.stateNode,i===null||i._visibility&1||(p=!0)),i=_,_=_.return;return i.tag===3?(_=i.stateNode,p&&r!==null&&(p=31-Ls(o),i=_.hiddenUpdates,u=i[p],u===null?i[p]=[r]:u.push(r),r.lane=o|536870912),_):null}function Mc(i){if(50<fo)throw fo=0,jf=null,Error(n(185));for(var r=i.return;r!==null;)i=r,r=i.return;return i.tag===3?i.stateNode:null}var Ta={};function Nj(i,r,o,u){this.tag=i,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zs(i,r,o,u){return new Nj(i,r,o,u)}function _d(i){return i=i.prototype,!(!i||!i.isReactComponent)}function $i(i,r){var o=i.alternate;return o===null?(o=zs(i.tag,r,i.key,i.mode),o.elementType=i.elementType,o.type=i.type,o.stateNode=i.stateNode,o.alternate=i,i.alternate=o):(o.pendingProps=r,o.type=i.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=i.flags&65011712,o.childLanes=i.childLanes,o.lanes=i.lanes,o.child=i.child,o.memoizedProps=i.memoizedProps,o.memoizedState=i.memoizedState,o.updateQueue=i.updateQueue,r=i.dependencies,o.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},o.sibling=i.sibling,o.index=i.index,o.ref=i.ref,o.refCleanup=i.refCleanup,o}function Kg(i,r){i.flags&=65011714;var o=i.alternate;return o===null?(i.childLanes=0,i.lanes=r,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,r=o.dependencies,i.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),i}function Bc(i,r,o,u,p,_){var y=0;if(u=i,typeof i=="function")_d(i)&&(y=1);else if(typeof i=="string")y=Rk(i,o,V.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case z:return i=zs(31,o,r,p),i.elementType=z,i.lanes=_,i;case w:return En(o.children,p,_,r);case k:y=8,p|=24;break;case N:return i=zs(12,o,r,p|2),i.elementType=N,i.lanes=_,i;case Y:return i=zs(13,o,r,p),i.elementType=Y,i.lanes=_,i;case K:return i=zs(19,o,r,p),i.elementType=K,i.lanes=_,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case R:y=10;break e;case L:y=9;break e;case D:y=11;break e;case Z:y=14;break e;case Q:y=16,u=null;break e}y=29,o=Error(n(130,i===null?"null":typeof i,"")),u=null}return r=zs(y,o,r,p),r.elementType=i,r.type=u,r.lanes=_,r}function En(i,r,o,u){return i=zs(7,i,u,r),i.lanes=o,i}function gd(i,r,o){return i=zs(6,i,null,r),i.lanes=o,i}function $g(i){var r=zs(18,null,null,0);return r.stateNode=i,r}function vd(i,r,o){return r=zs(4,i.children!==null?i.children:[],i.key,r),r.lanes=o,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}var Wg=new WeakMap;function ti(i,r){if(typeof i=="object"&&i!==null){var o=Wg.get(i);return o!==void 0?o:(r={value:i,source:r,stack:$_(r)},Wg.set(i,r),r)}return{value:i,source:r,stack:$_(r)}}var Oa=[],Aa=0,Lc=null,$l=0,si=[],ii=0,Cr=null,wi=1,Ci="";function Wi(i,r){Oa[Aa++]=$l,Oa[Aa++]=Lc,Lc=i,$l=r}function Vg(i,r,o){si[ii++]=wi,si[ii++]=Ci,si[ii++]=Cr,Cr=i;var u=wi;i=Ci;var p=32-Ls(u)-1;u&=~(1<<p),o+=1;var _=32-Ls(r)+p;if(30<_){var y=p-p%5;_=(u&(1<<y)-1).toString(32),u>>=y,p-=y,wi=1<<32-Ls(r)+p|o<<p|u,Ci=_+i}else wi=1<<_|o<<p|u,Ci=i}function yd(i){i.return!==null&&(Wi(i,1),Vg(i,1,0))}function bd(i){for(;i===Lc;)Lc=Oa[--Aa],Oa[Aa]=null,$l=Oa[--Aa],Oa[Aa]=null;for(;i===Cr;)Cr=si[--ii],si[ii]=null,Ci=si[--ii],si[ii]=null,wi=si[--ii],si[ii]=null}function Yg(i,r){si[ii++]=wi,si[ii++]=Ci,si[ii++]=Cr,wi=r.id,Ci=r.overflow,Cr=i}var rs=null,mt=null,Ye=!1,jr=null,ri=!1,Sd=Error(n(519));function kr(i){var r=Error(n(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Wl(ti(r,i)),Sd}function Gg(i){var r=i.stateNode,o=i.type,u=i.memoizedProps;switch(r[is]=i,r[xs]=u,o){case"dialog":Ke("cancel",r),Ke("close",r);break;case"iframe":case"object":case"embed":Ke("load",r);break;case"video":case"audio":for(o=0;o<po.length;o++)Ke(po[o],r);break;case"source":Ke("error",r);break;case"img":case"image":case"link":Ke("error",r),Ke("load",r);break;case"details":Ke("toggle",r);break;case"input":Ke("invalid",r),og(r,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":Ke("invalid",r);break;case"textarea":Ke("invalid",r),ug(r,u.value,u.defaultValue,u.children)}o=u.children,typeof o!="string"&&typeof o!="number"&&typeof o!="bigint"||r.textContent===""+o||u.suppressHydrationWarning===!0||db(r.textContent,o)?(u.popover!=null&&(Ke("beforetoggle",r),Ke("toggle",r)),u.onScroll!=null&&Ke("scroll",r),u.onScrollEnd!=null&&Ke("scrollend",r),u.onClick!=null&&(r.onclick=Ui),r=!0):r=!1,r||kr(i,!0)}function Qg(i){for(rs=i.return;rs;)switch(rs.tag){case 5:case 31:case 13:ri=!1;return;case 27:case 3:ri=!0;return;default:rs=rs.return}}function Ra(i){if(i!==rs)return!1;if(!Ye)return Qg(i),Ye=!0,!1;var r=i.tag,o;if((o=r!==3&&r!==27)&&((o=r===5)&&(o=i.type,o=!(o!=="form"&&o!=="button")||Hf(i.type,i.memoizedProps)),o=!o),o&&mt&&kr(i),Qg(i),r===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));mt=Sb(i)}else if(r===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));mt=Sb(i)}else r===27?(r=mt,Hr(i.type)?(i=$f,$f=null,mt=i):mt=r):mt=rs?ai(i.stateNode.nextSibling):null;return!0}function Tn(){mt=rs=null,Ye=!1}function xd(){var i=jr;return i!==null&&(Ns===null?Ns=i:Ns.push.apply(Ns,i),jr=null),i}function Wl(i){jr===null?jr=[i]:jr.push(i)}var wd=M(null),On=null,Vi=null;function Nr(i,r,o){ae(wd,r._currentValue),r._currentValue=o}function Yi(i){i._currentValue=wd.current,U(wd)}function Cd(i,r,o){for(;i!==null;){var u=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),i===o)break;i=i.return}}function jd(i,r,o,u){var p=i.child;for(p!==null&&(p.return=i);p!==null;){var _=p.dependencies;if(_!==null){var y=p.child;_=_.firstContext;e:for(;_!==null;){var C=_;_=p;for(var A=0;A<r.length;A++)if(C.context===r[A]){_.lanes|=o,C=_.alternate,C!==null&&(C.lanes|=o),Cd(_.return,o,i),u||(y=null);break e}_=C.next}}else if(p.tag===18){if(y=p.return,y===null)throw Error(n(341));y.lanes|=o,_=y.alternate,_!==null&&(_.lanes|=o),Cd(y,o,i),y=null}else y=p.child;if(y!==null)y.return=p;else for(y=p;y!==null;){if(y===i){y=null;break}if(p=y.sibling,p!==null){p.return=y.return,y=p;break}y=y.return}p=y}}function Da(i,r,o,u){i=null;for(var p=r,_=!1;p!==null;){if(!_){if((p.flags&524288)!==0)_=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var y=p.alternate;if(y===null)throw Error(n(387));if(y=y.memoizedProps,y!==null){var C=p.type;qs(p.pendingProps.value,y.value)||(i!==null?i.push(C):i=[C])}}else if(p===Ae.current){if(y=p.alternate,y===null)throw Error(n(387));y.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(i!==null?i.push(bo):i=[bo])}p=p.return}i!==null&&jd(r,i,o,u),r.flags|=262144}function qc(i){for(i=i.firstContext;i!==null;){if(!qs(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function An(i){On=i,Vi=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function ns(i){return Zg(On,i)}function zc(i,r){return On===null&&An(i),Zg(i,r)}function Zg(i,r){var o=r._currentValue;if(r={context:r,memoizedValue:o,next:null},Vi===null){if(i===null)throw Error(n(308));Vi=r,i.dependencies={lanes:0,firstContext:r},i.flags|=524288}else Vi=Vi.next=r;return o}var Ej=typeof AbortController<"u"?AbortController:function(){var i=[],r=this.signal={aborted:!1,addEventListener:function(o,u){i.push(u)}};this.abort=function(){r.aborted=!0,i.forEach(function(o){return o()})}},Tj=e.unstable_scheduleCallback,Oj=e.unstable_NormalPriority,Rt={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function kd(){return{controller:new Ej,data:new Map,refCount:0}}function Vl(i){i.refCount--,i.refCount===0&&Tj(Oj,function(){i.controller.abort()})}var Yl=null,Nd=0,Ma=0,Ba=null;function Aj(i,r){if(Yl===null){var o=Yl=[];Nd=0,Ma=Af(),Ba={status:"pending",value:void 0,then:function(u){o.push(u)}}}return Nd++,r.then(Xg,Xg),r}function Xg(){if(--Nd===0&&Yl!==null){Ba!==null&&(Ba.status="fulfilled");var i=Yl;Yl=null,Ma=0,Ba=null;for(var r=0;r<i.length;r++)(0,i[r])()}}function Rj(i,r){var o=[],u={status:"pending",value:null,reason:null,then:function(p){o.push(p)}};return i.then(function(){u.status="fulfilled",u.value=r;for(var p=0;p<o.length;p++)(0,o[p])(r)},function(p){for(u.status="rejected",u.reason=p,p=0;p<o.length;p++)(0,o[p])(void 0)}),u}var Jg=T.S;T.S=function(i,r){Ly=Ms(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&Aj(i,r),Jg!==null&&Jg(i,r)};var Rn=M(null);function Ed(){var i=Rn.current;return i!==null?i:dt.pooledCache}function Pc(i,r){r===null?ae(Rn,Rn.current):ae(Rn,r.pool)}function ev(){var i=Ed();return i===null?null:{parent:Rt._currentValue,pool:i}}var La=Error(n(460)),Td=Error(n(474)),Hc=Error(n(542)),Fc={then:function(){}};function tv(i){return i=i.status,i==="fulfilled"||i==="rejected"}function sv(i,r,o){switch(o=i[o],o===void 0?i.push(r):o!==r&&(r.then(Ui,Ui),r=o),r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,rv(i),i;default:if(typeof r.status=="string")r.then(Ui,Ui);else{if(i=dt,i!==null&&100<i.shellSuspendCounter)throw Error(n(482));i=r,i.status="pending",i.then(function(u){if(r.status==="pending"){var p=r;p.status="fulfilled",p.value=u}},function(u){if(r.status==="pending"){var p=r;p.status="rejected",p.reason=u}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw i=r.reason,rv(i),i}throw Mn=r,La}}function Dn(i){try{var r=i._init;return r(i._payload)}catch(o){throw o!==null&&typeof o=="object"&&typeof o.then=="function"?(Mn=o,La):o}}var Mn=null;function iv(){if(Mn===null)throw Error(n(459));var i=Mn;return Mn=null,i}function rv(i){if(i===La||i===Hc)throw Error(n(483))}var qa=null,Gl=0;function Ic(i){var r=Gl;return Gl+=1,qa===null&&(qa=[]),sv(qa,i,r)}function Ql(i,r){r=r.props.ref,i.ref=r!==void 0?r:null}function Uc(i,r){throw r.$$typeof===b?Error(n(525)):(i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i)))}function nv(i){function r(q,B){if(i){var P=q.deletions;P===null?(q.deletions=[B],q.flags|=16):P.push(B)}}function o(q,B){if(!i)return null;for(;B!==null;)r(q,B),B=B.sibling;return null}function u(q){for(var B=new Map;q!==null;)q.key!==null?B.set(q.key,q):B.set(q.index,q),q=q.sibling;return B}function p(q,B){return q=$i(q,B),q.index=0,q.sibling=null,q}function _(q,B,P){return q.index=P,i?(P=q.alternate,P!==null?(P=P.index,P<B?(q.flags|=67108866,B):P):(q.flags|=67108866,B)):(q.flags|=1048576,B)}function y(q){return i&&q.alternate===null&&(q.flags|=67108866),q}function C(q,B,P,ie){return B===null||B.tag!==6?(B=gd(P,q.mode,ie),B.return=q,B):(B=p(B,P),B.return=q,B)}function A(q,B,P,ie){var je=P.type;return je===w?se(q,B,P.props.children,ie,P.key):B!==null&&(B.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===Q&&Dn(je)===B.type)?(B=p(B,P.props),Ql(B,P),B.return=q,B):(B=Bc(P.type,P.key,P.props,null,q.mode,ie),Ql(B,P),B.return=q,B)}function I(q,B,P,ie){return B===null||B.tag!==4||B.stateNode.containerInfo!==P.containerInfo||B.stateNode.implementation!==P.implementation?(B=vd(P,q.mode,ie),B.return=q,B):(B=p(B,P.children||[]),B.return=q,B)}function se(q,B,P,ie,je){return B===null||B.tag!==7?(B=En(P,q.mode,ie,je),B.return=q,B):(B=p(B,P),B.return=q,B)}function re(q,B,P){if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return B=gd(""+B,q.mode,P),B.return=q,B;if(typeof B=="object"&&B!==null){switch(B.$$typeof){case S:return P=Bc(B.type,B.key,B.props,null,q.mode,P),Ql(P,B),P.return=q,P;case x:return B=vd(B,q.mode,P),B.return=q,B;case Q:return B=Dn(B),re(q,B,P)}if(ee(B)||H(B))return B=En(B,q.mode,P,null),B.return=q,B;if(typeof B.then=="function")return re(q,Ic(B),P);if(B.$$typeof===R)return re(q,zc(q,B),P);Uc(q,B)}return null}function $(q,B,P,ie){var je=B!==null?B.key:null;if(typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint")return je!==null?null:C(q,B,""+P,ie);if(typeof P=="object"&&P!==null){switch(P.$$typeof){case S:return P.key===je?A(q,B,P,ie):null;case x:return P.key===je?I(q,B,P,ie):null;case Q:return P=Dn(P),$(q,B,P,ie)}if(ee(P)||H(P))return je!==null?null:se(q,B,P,ie,null);if(typeof P.then=="function")return $(q,B,Ic(P),ie);if(P.$$typeof===R)return $(q,B,zc(q,P),ie);Uc(q,P)}return null}function X(q,B,P,ie,je){if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return q=q.get(P)||null,C(B,q,""+ie,je);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case S:return q=q.get(ie.key===null?P:ie.key)||null,A(B,q,ie,je);case x:return q=q.get(ie.key===null?P:ie.key)||null,I(B,q,ie,je);case Q:return ie=Dn(ie),X(q,B,P,ie,je)}if(ee(ie)||H(ie))return q=q.get(P)||null,se(B,q,ie,je,null);if(typeof ie.then=="function")return X(q,B,P,Ic(ie),je);if(ie.$$typeof===R)return X(q,B,P,zc(B,ie),je);Uc(B,ie)}return null}function be(q,B,P,ie){for(var je=null,tt=null,we=B,ze=B=0,Ve=null;we!==null&&ze<P.length;ze++){we.index>ze?(Ve=we,we=null):Ve=we.sibling;var st=$(q,we,P[ze],ie);if(st===null){we===null&&(we=Ve);break}i&&we&&st.alternate===null&&r(q,we),B=_(st,B,ze),tt===null?je=st:tt.sibling=st,tt=st,we=Ve}if(ze===P.length)return o(q,we),Ye&&Wi(q,ze),je;if(we===null){for(;ze<P.length;ze++)we=re(q,P[ze],ie),we!==null&&(B=_(we,B,ze),tt===null?je=we:tt.sibling=we,tt=we);return Ye&&Wi(q,ze),je}for(we=u(we);ze<P.length;ze++)Ve=X(we,q,ze,P[ze],ie),Ve!==null&&(i&&Ve.alternate!==null&&we.delete(Ve.key===null?ze:Ve.key),B=_(Ve,B,ze),tt===null?je=Ve:tt.sibling=Ve,tt=Ve);return i&&we.forEach(function($r){return r(q,$r)}),Ye&&Wi(q,ze),je}function Ee(q,B,P,ie){if(P==null)throw Error(n(151));for(var je=null,tt=null,we=B,ze=B=0,Ve=null,st=P.next();we!==null&&!st.done;ze++,st=P.next()){we.index>ze?(Ve=we,we=null):Ve=we.sibling;var $r=$(q,we,st.value,ie);if($r===null){we===null&&(we=Ve);break}i&&we&&$r.alternate===null&&r(q,we),B=_($r,B,ze),tt===null?je=$r:tt.sibling=$r,tt=$r,we=Ve}if(st.done)return o(q,we),Ye&&Wi(q,ze),je;if(we===null){for(;!st.done;ze++,st=P.next())st=re(q,st.value,ie),st!==null&&(B=_(st,B,ze),tt===null?je=st:tt.sibling=st,tt=st);return Ye&&Wi(q,ze),je}for(we=u(we);!st.done;ze++,st=P.next())st=X(we,q,ze,st.value,ie),st!==null&&(i&&st.alternate!==null&&we.delete(st.key===null?ze:st.key),B=_(st,B,ze),tt===null?je=st:tt.sibling=st,tt=st);return i&&we.forEach(function(Uk){return r(q,Uk)}),Ye&&Wi(q,ze),je}function ut(q,B,P,ie){if(typeof P=="object"&&P!==null&&P.type===w&&P.key===null&&(P=P.props.children),typeof P=="object"&&P!==null){switch(P.$$typeof){case S:e:{for(var je=P.key;B!==null;){if(B.key===je){if(je=P.type,je===w){if(B.tag===7){o(q,B.sibling),ie=p(B,P.props.children),ie.return=q,q=ie;break e}}else if(B.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===Q&&Dn(je)===B.type){o(q,B.sibling),ie=p(B,P.props),Ql(ie,P),ie.return=q,q=ie;break e}o(q,B);break}else r(q,B);B=B.sibling}P.type===w?(ie=En(P.props.children,q.mode,ie,P.key),ie.return=q,q=ie):(ie=Bc(P.type,P.key,P.props,null,q.mode,ie),Ql(ie,P),ie.return=q,q=ie)}return y(q);case x:e:{for(je=P.key;B!==null;){if(B.key===je)if(B.tag===4&&B.stateNode.containerInfo===P.containerInfo&&B.stateNode.implementation===P.implementation){o(q,B.sibling),ie=p(B,P.children||[]),ie.return=q,q=ie;break e}else{o(q,B);break}else r(q,B);B=B.sibling}ie=vd(P,q.mode,ie),ie.return=q,q=ie}return y(q);case Q:return P=Dn(P),ut(q,B,P,ie)}if(ee(P))return be(q,B,P,ie);if(H(P)){if(je=H(P),typeof je!="function")throw Error(n(150));return P=je.call(P),Ee(q,B,P,ie)}if(typeof P.then=="function")return ut(q,B,Ic(P),ie);if(P.$$typeof===R)return ut(q,B,zc(q,P),ie);Uc(q,P)}return typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint"?(P=""+P,B!==null&&B.tag===6?(o(q,B.sibling),ie=p(B,P),ie.return=q,q=ie):(o(q,B),ie=gd(P,q.mode,ie),ie.return=q,q=ie),y(q)):o(q,B)}return function(q,B,P,ie){try{Gl=0;var je=ut(q,B,P,ie);return qa=null,je}catch(we){if(we===La||we===Hc)throw we;var tt=zs(29,we,null,q.mode);return tt.lanes=ie,tt.return=q,tt}finally{}}}var Bn=nv(!0),av=nv(!1),Er=!1;function Od(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ad(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Tr(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Or(i,r,o){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(it&2)!==0){var p=u.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),u.pending=r,r=Mc(i),Ug(i,null,o),r}return Dc(i,u,r,o),Mc(i)}function Zl(i,r,o){if(r=r.updateQueue,r!==null&&(r=r.shared,(o&4194048)!==0)){var u=r.lanes;u&=i.pendingLanes,o|=u,r.lanes=o,Z_(i,o)}}function Rd(i,r){var o=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,o===u)){var p=null,_=null;if(o=o.firstBaseUpdate,o!==null){do{var y={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};_===null?p=_=y:_=_.next=y,o=o.next}while(o!==null);_===null?p=_=r:_=_.next=r}else p=_=r;o={baseState:u.baseState,firstBaseUpdate:p,lastBaseUpdate:_,shared:u.shared,callbacks:u.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=r:i.next=r,o.lastBaseUpdate=r}var Dd=!1;function Xl(){if(Dd){var i=Ba;if(i!==null)throw i}}function Jl(i,r,o,u){Dd=!1;var p=i.updateQueue;Er=!1;var _=p.firstBaseUpdate,y=p.lastBaseUpdate,C=p.shared.pending;if(C!==null){p.shared.pending=null;var A=C,I=A.next;A.next=null,y===null?_=I:y.next=I,y=A;var se=i.alternate;se!==null&&(se=se.updateQueue,C=se.lastBaseUpdate,C!==y&&(C===null?se.firstBaseUpdate=I:C.next=I,se.lastBaseUpdate=A))}if(_!==null){var re=p.baseState;y=0,se=I=A=null,C=_;do{var $=C.lane&-536870913,X=$!==C.lane;if(X?(We&$)===$:(u&$)===$){$!==0&&$===Ma&&(Dd=!0),se!==null&&(se=se.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var be=i,Ee=C;$=r;var ut=o;switch(Ee.tag){case 1:if(be=Ee.payload,typeof be=="function"){re=be.call(ut,re,$);break e}re=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=Ee.payload,$=typeof be=="function"?be.call(ut,re,$):be,$==null)break e;re=v({},re,$);break e;case 2:Er=!0}}$=C.callback,$!==null&&(i.flags|=64,X&&(i.flags|=8192),X=p.callbacks,X===null?p.callbacks=[$]:X.push($))}else X={lane:$,tag:C.tag,payload:C.payload,callback:C.callback,next:null},se===null?(I=se=X,A=re):se=se.next=X,y|=$;if(C=C.next,C===null){if(C=p.shared.pending,C===null)break;X=C,C=X.next,X.next=null,p.lastBaseUpdate=X,p.shared.pending=null}}while(!0);se===null&&(A=re),p.baseState=A,p.firstBaseUpdate=I,p.lastBaseUpdate=se,_===null&&(p.shared.lanes=0),Br|=y,i.lanes=y,i.memoizedState=re}}function lv(i,r){if(typeof i!="function")throw Error(n(191,i));i.call(r)}function ov(i,r){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;i<o.length;i++)lv(o[i],r)}var za=M(null),Kc=M(0);function cv(i,r){i=ir,ae(Kc,i),ae(za,r),ir=i|r.baseLanes}function Md(){ae(Kc,ir),ae(za,za.current)}function Bd(){ir=Kc.current,U(za),U(Kc)}var Ps=M(null),ni=null;function Ar(i){var r=i.alternate;ae(Et,Et.current&1),ae(Ps,i),ni===null&&(r===null||za.current!==null||r.memoizedState!==null)&&(ni=i)}function Ld(i){ae(Et,Et.current),ae(Ps,i),ni===null&&(ni=i)}function uv(i){i.tag===22?(ae(Et,Et.current),ae(Ps,i),ni===null&&(ni=i)):Rr()}function Rr(){ae(Et,Et.current),ae(Ps,Ps.current)}function Hs(i){U(Ps),ni===i&&(ni=null),U(Et)}var Et=M(0);function $c(i){for(var r=i;r!==null;){if(r.tag===13){var o=r.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||Uf(o)||Kf(o)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Gi=0,Le=null,ot=null,Dt=null,Wc=!1,Pa=!1,Ln=!1,Vc=0,eo=0,Ha=null,Dj=0;function St(){throw Error(n(321))}function qd(i,r){if(r===null)return!1;for(var o=0;o<r.length&&o<i.length;o++)if(!qs(i[o],r[o]))return!1;return!0}function zd(i,r,o,u,p,_){return Gi=_,Le=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,T.H=i===null||i.memoizedState===null?Vv:Jd,Ln=!1,_=o(u,p),Ln=!1,Pa&&(_=dv(r,o,u,p)),hv(i),_}function hv(i){T.H=io;var r=ot!==null&&ot.next!==null;if(Gi=0,Dt=ot=Le=null,Wc=!1,eo=0,Ha=null,r)throw Error(n(300));i===null||Mt||(i=i.dependencies,i!==null&&qc(i)&&(Mt=!0))}function dv(i,r,o,u){Le=i;var p=0;do{if(Pa&&(Ha=null),eo=0,Pa=!1,25<=p)throw Error(n(301));if(p+=1,Dt=ot=null,i.updateQueue!=null){var _=i.updateQueue;_.lastEffect=null,_.events=null,_.stores=null,_.memoCache!=null&&(_.memoCache.index=0)}T.H=Yv,_=r(o,u)}while(Pa);return _}function Mj(){var i=T.H,r=i.useState()[0];return r=typeof r.then=="function"?to(r):r,i=i.useState()[0],(ot!==null?ot.memoizedState:null)!==i&&(Le.flags|=1024),r}function Pd(){var i=Vc!==0;return Vc=0,i}function Hd(i,r,o){r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~o}function Fd(i){if(Wc){for(i=i.memoizedState;i!==null;){var r=i.queue;r!==null&&(r.pending=null),i=i.next}Wc=!1}Gi=0,Dt=ot=Le=null,Pa=!1,eo=Vc=0,Ha=null}function _s(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Dt===null?Le.memoizedState=Dt=i:Dt=Dt.next=i,Dt}function Tt(){if(ot===null){var i=Le.alternate;i=i!==null?i.memoizedState:null}else i=ot.next;var r=Dt===null?Le.memoizedState:Dt.next;if(r!==null)Dt=r,ot=i;else{if(i===null)throw Le.alternate===null?Error(n(467)):Error(n(310));ot=i,i={memoizedState:ot.memoizedState,baseState:ot.baseState,baseQueue:ot.baseQueue,queue:ot.queue,next:null},Dt===null?Le.memoizedState=Dt=i:Dt=Dt.next=i}return Dt}function Yc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function to(i){var r=eo;return eo+=1,Ha===null&&(Ha=[]),i=sv(Ha,i,r),r=Le,(Dt===null?r.memoizedState:Dt.next)===null&&(r=r.alternate,T.H=r===null||r.memoizedState===null?Vv:Jd),i}function Gc(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return to(i);if(i.$$typeof===R)return ns(i)}throw Error(n(438,String(i)))}function Id(i){var r=null,o=Le.updateQueue;if(o!==null&&(r=o.memoCache),r==null){var u=Le.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(r={data:u.data.map(function(p){return p.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),o===null&&(o=Yc(),Le.updateQueue=o),o.memoCache=r,o=r.data[r.index],o===void 0)for(o=r.data[r.index]=Array(i),u=0;u<i;u++)o[u]=G;return r.index++,o}function Qi(i,r){return typeof r=="function"?r(i):r}function Qc(i){var r=Tt();return Ud(r,ot,i)}function Ud(i,r,o){var u=i.queue;if(u===null)throw Error(n(311));u.lastRenderedReducer=o;var p=i.baseQueue,_=u.pending;if(_!==null){if(p!==null){var y=p.next;p.next=_.next,_.next=y}r.baseQueue=p=_,u.pending=null}if(_=i.baseState,p===null)i.memoizedState=_;else{r=p.next;var C=y=null,A=null,I=r,se=!1;do{var re=I.lane&-536870913;if(re!==I.lane?(We&re)===re:(Gi&re)===re){var $=I.revertLane;if($===0)A!==null&&(A=A.next={lane:0,revertLane:0,gesture:null,action:I.action,hasEagerState:I.hasEagerState,eagerState:I.eagerState,next:null}),re===Ma&&(se=!0);else if((Gi&$)===$){I=I.next,$===Ma&&(se=!0);continue}else re={lane:0,revertLane:I.revertLane,gesture:null,action:I.action,hasEagerState:I.hasEagerState,eagerState:I.eagerState,next:null},A===null?(C=A=re,y=_):A=A.next=re,Le.lanes|=$,Br|=$;re=I.action,Ln&&o(_,re),_=I.hasEagerState?I.eagerState:o(_,re)}else $={lane:re,revertLane:I.revertLane,gesture:I.gesture,action:I.action,hasEagerState:I.hasEagerState,eagerState:I.eagerState,next:null},A===null?(C=A=$,y=_):A=A.next=$,Le.lanes|=re,Br|=re;I=I.next}while(I!==null&&I!==r);if(A===null?y=_:A.next=C,!qs(_,i.memoizedState)&&(Mt=!0,se&&(o=Ba,o!==null)))throw o;i.memoizedState=_,i.baseState=y,i.baseQueue=A,u.lastRenderedState=_}return p===null&&(u.lanes=0),[i.memoizedState,u.dispatch]}function Kd(i){var r=Tt(),o=r.queue;if(o===null)throw Error(n(311));o.lastRenderedReducer=i;var u=o.dispatch,p=o.pending,_=r.memoizedState;if(p!==null){o.pending=null;var y=p=p.next;do _=i(_,y.action),y=y.next;while(y!==p);qs(_,r.memoizedState)||(Mt=!0),r.memoizedState=_,r.baseQueue===null&&(r.baseState=_),o.lastRenderedState=_}return[_,u]}function fv(i,r,o){var u=Le,p=Tt(),_=Ye;if(_){if(o===void 0)throw Error(n(407));o=o()}else o=r();var y=!qs((ot||p).memoizedState,o);if(y&&(p.memoizedState=o,Mt=!0),p=p.queue,Vd(_v.bind(null,u,p,i),[i]),p.getSnapshot!==r||y||Dt!==null&&Dt.memoizedState.tag&1){if(u.flags|=2048,Fa(9,{destroy:void 0},pv.bind(null,u,p,o,r),null),dt===null)throw Error(n(349));_||(Gi&127)!==0||mv(u,r,o)}return o}function mv(i,r,o){i.flags|=16384,i={getSnapshot:r,value:o},r=Le.updateQueue,r===null?(r=Yc(),Le.updateQueue=r,r.stores=[i]):(o=r.stores,o===null?r.stores=[i]:o.push(i))}function pv(i,r,o,u){r.value=o,r.getSnapshot=u,gv(r)&&vv(i)}function _v(i,r,o){return o(function(){gv(r)&&vv(i)})}function gv(i){var r=i.getSnapshot;i=i.value;try{var o=r();return!qs(i,o)}catch{return!0}}function vv(i){var r=Nn(i,2);r!==null&&Es(r,i,2)}function $d(i){var r=_s();if(typeof i=="function"){var o=i;if(i=o(),Ln){Sr(!0);try{o()}finally{Sr(!1)}}}return r.memoizedState=r.baseState=i,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qi,lastRenderedState:i},r}function yv(i,r,o,u){return i.baseState=o,Ud(i,ot,typeof u=="function"?u:Qi)}function Bj(i,r,o,u,p){if(Jc(i))throw Error(n(485));if(i=r.action,i!==null){var _={payload:p,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(y){_.listeners.push(y)}};T.T!==null?o(!0):_.isTransition=!1,u(_),o=r.pending,o===null?(_.next=r.pending=_,bv(r,_)):(_.next=o.next,r.pending=o.next=_)}}function bv(i,r){var o=r.action,u=r.payload,p=i.state;if(r.isTransition){var _=T.T,y={};T.T=y;try{var C=o(p,u),A=T.S;A!==null&&A(y,C),Sv(i,r,C)}catch(I){Wd(i,r,I)}finally{_!==null&&y.types!==null&&(_.types=y.types),T.T=_}}else try{_=o(p,u),Sv(i,r,_)}catch(I){Wd(i,r,I)}}function Sv(i,r,o){o!==null&&typeof o=="object"&&typeof o.then=="function"?o.then(function(u){xv(i,r,u)},function(u){return Wd(i,r,u)}):xv(i,r,o)}function xv(i,r,o){r.status="fulfilled",r.value=o,wv(r),i.state=o,r=i.pending,r!==null&&(o=r.next,o===r?i.pending=null:(o=o.next,r.next=o,bv(i,o)))}function Wd(i,r,o){var u=i.pending;if(i.pending=null,u!==null){u=u.next;do r.status="rejected",r.reason=o,wv(r),r=r.next;while(r!==u)}i.action=null}function wv(i){i=i.listeners;for(var r=0;r<i.length;r++)(0,i[r])()}function Cv(i,r){return r}function jv(i,r){if(Ye){var o=dt.formState;if(o!==null){e:{var u=Le;if(Ye){if(mt){t:{for(var p=mt,_=ri;p.nodeType!==8;){if(!_){p=null;break t}if(p=ai(p.nextSibling),p===null){p=null;break t}}_=p.data,p=_==="F!"||_==="F"?p:null}if(p){mt=ai(p.nextSibling),u=p.data==="F!";break e}}kr(u)}u=!1}u&&(r=o[0])}}return o=_s(),o.memoizedState=o.baseState=r,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cv,lastRenderedState:r},o.queue=u,o=Kv.bind(null,Le,u),u.dispatch=o,u=$d(!1),_=Xd.bind(null,Le,!1,u.queue),u=_s(),p={state:r,dispatch:null,action:i,pending:null},u.queue=p,o=Bj.bind(null,Le,p,_,o),p.dispatch=o,u.memoizedState=i,[r,o,!1]}function kv(i){var r=Tt();return Nv(r,ot,i)}function Nv(i,r,o){if(r=Ud(i,r,Cv)[0],i=Qc(Qi)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var u=to(r)}catch(y){throw y===La?Hc:y}else u=r;r=Tt();var p=r.queue,_=p.dispatch;return o!==r.memoizedState&&(Le.flags|=2048,Fa(9,{destroy:void 0},Lj.bind(null,p,o),null)),[u,_,i]}function Lj(i,r){i.action=r}function Ev(i){var r=Tt(),o=ot;if(o!==null)return Nv(r,o,i);Tt(),r=r.memoizedState,o=Tt();var u=o.queue.dispatch;return o.memoizedState=i,[r,u,!1]}function Fa(i,r,o,u){return i={tag:i,create:o,deps:u,inst:r,next:null},r=Le.updateQueue,r===null&&(r=Yc(),Le.updateQueue=r),o=r.lastEffect,o===null?r.lastEffect=i.next=i:(u=o.next,o.next=i,i.next=u,r.lastEffect=i),i}function Tv(){return Tt().memoizedState}function Zc(i,r,o,u){var p=_s();Le.flags|=i,p.memoizedState=Fa(1|r,{destroy:void 0},o,u===void 0?null:u)}function Xc(i,r,o,u){var p=Tt();u=u===void 0?null:u;var _=p.memoizedState.inst;ot!==null&&u!==null&&qd(u,ot.memoizedState.deps)?p.memoizedState=Fa(r,_,o,u):(Le.flags|=i,p.memoizedState=Fa(1|r,_,o,u))}function Ov(i,r){Zc(8390656,8,i,r)}function Vd(i,r){Xc(2048,8,i,r)}function qj(i){Le.flags|=4;var r=Le.updateQueue;if(r===null)r=Yc(),Le.updateQueue=r,r.events=[i];else{var o=r.events;o===null?r.events=[i]:o.push(i)}}function Av(i){var r=Tt().memoizedState;return qj({ref:r,nextImpl:i}),function(){if((it&2)!==0)throw Error(n(440));return r.impl.apply(void 0,arguments)}}function Rv(i,r){return Xc(4,2,i,r)}function Dv(i,r){return Xc(4,4,i,r)}function Mv(i,r){if(typeof r=="function"){i=i();var o=r(i);return function(){typeof o=="function"?o():r(null)}}if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function Bv(i,r,o){o=o!=null?o.concat([i]):null,Xc(4,4,Mv.bind(null,r,i),o)}function Yd(){}function Lv(i,r){var o=Tt();r=r===void 0?null:r;var u=o.memoizedState;return r!==null&&qd(r,u[1])?u[0]:(o.memoizedState=[i,r],i)}function qv(i,r){var o=Tt();r=r===void 0?null:r;var u=o.memoizedState;if(r!==null&&qd(r,u[1]))return u[0];if(u=i(),Ln){Sr(!0);try{i()}finally{Sr(!1)}}return o.memoizedState=[u,r],u}function Gd(i,r,o){return o===void 0||(Gi&1073741824)!==0&&(We&261930)===0?i.memoizedState=r:(i.memoizedState=o,i=zy(),Le.lanes|=i,Br|=i,o)}function zv(i,r,o,u){return qs(o,r)?o:za.current!==null?(i=Gd(i,o,u),qs(i,r)||(Mt=!0),i):(Gi&42)===0||(Gi&1073741824)!==0&&(We&261930)===0?(Mt=!0,i.memoizedState=o):(i=zy(),Le.lanes|=i,Br|=i,r)}function Pv(i,r,o,u,p){var _=F.p;F.p=_!==0&&8>_?_:8;var y=T.T,C={};T.T=C,Xd(i,!1,r,o);try{var A=p(),I=T.S;if(I!==null&&I(C,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var se=Rj(A,u);so(i,r,se,Us(i))}else so(i,r,u,Us(i))}catch(re){so(i,r,{then:function(){},status:"rejected",reason:re},Us())}finally{F.p=_,y!==null&&C.types!==null&&(y.types=C.types),T.T=y}}function zj(){}function Qd(i,r,o,u){if(i.tag!==5)throw Error(n(476));var p=Hv(i).queue;Pv(i,p,r,J,o===null?zj:function(){return Fv(i),o(u)})}function Hv(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qi,lastRenderedState:J},next:null};var o={};return r.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qi,lastRenderedState:o},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function Fv(i){var r=Hv(i);r.next===null&&(r=i.alternate.memoizedState),so(i,r.next.queue,{},Us())}function Zd(){return ns(bo)}function Iv(){return Tt().memoizedState}function Uv(){return Tt().memoizedState}function Pj(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var o=Us();i=Tr(o);var u=Or(r,i,o);u!==null&&(Es(u,r,o),Zl(u,r,o)),r={cache:kd()},i.payload=r;return}r=r.return}}function Hj(i,r,o){var u=Us();o={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Jc(i)?$v(r,o):(o=pd(i,r,o,u),o!==null&&(Es(o,i,u),Wv(o,r,u)))}function Kv(i,r,o){var u=Us();so(i,r,o,u)}function so(i,r,o,u){var p={lane:u,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Jc(i))$v(r,p);else{var _=i.alternate;if(i.lanes===0&&(_===null||_.lanes===0)&&(_=r.lastRenderedReducer,_!==null))try{var y=r.lastRenderedState,C=_(y,o);if(p.hasEagerState=!0,p.eagerState=C,qs(C,y))return Dc(i,r,p,0),dt===null&&Rc(),!1}catch{}finally{}if(o=pd(i,r,p,u),o!==null)return Es(o,i,u),Wv(o,r,u),!0}return!1}function Xd(i,r,o,u){if(u={lane:2,revertLane:Af(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Jc(i)){if(r)throw Error(n(479))}else r=pd(i,o,u,2),r!==null&&Es(r,i,2)}function Jc(i){var r=i.alternate;return i===Le||r!==null&&r===Le}function $v(i,r){Pa=Wc=!0;var o=i.pending;o===null?r.next=r:(r.next=o.next,o.next=r),i.pending=r}function Wv(i,r,o){if((o&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,o|=u,r.lanes=o,Z_(i,o)}}var io={readContext:ns,use:Gc,useCallback:St,useContext:St,useEffect:St,useImperativeHandle:St,useLayoutEffect:St,useInsertionEffect:St,useMemo:St,useReducer:St,useRef:St,useState:St,useDebugValue:St,useDeferredValue:St,useTransition:St,useSyncExternalStore:St,useId:St,useHostTransitionStatus:St,useFormState:St,useActionState:St,useOptimistic:St,useMemoCache:St,useCacheRefresh:St};io.useEffectEvent=St;var Vv={readContext:ns,use:Gc,useCallback:function(i,r){return _s().memoizedState=[i,r===void 0?null:r],i},useContext:ns,useEffect:Ov,useImperativeHandle:function(i,r,o){o=o!=null?o.concat([i]):null,Zc(4194308,4,Mv.bind(null,r,i),o)},useLayoutEffect:function(i,r){return Zc(4194308,4,i,r)},useInsertionEffect:function(i,r){Zc(4,2,i,r)},useMemo:function(i,r){var o=_s();r=r===void 0?null:r;var u=i();if(Ln){Sr(!0);try{i()}finally{Sr(!1)}}return o.memoizedState=[u,r],u},useReducer:function(i,r,o){var u=_s();if(o!==void 0){var p=o(r);if(Ln){Sr(!0);try{o(r)}finally{Sr(!1)}}}else p=r;return u.memoizedState=u.baseState=p,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:p},u.queue=i,i=i.dispatch=Hj.bind(null,Le,i),[u.memoizedState,i]},useRef:function(i){var r=_s();return i={current:i},r.memoizedState=i},useState:function(i){i=$d(i);var r=i.queue,o=Kv.bind(null,Le,r);return r.dispatch=o,[i.memoizedState,o]},useDebugValue:Yd,useDeferredValue:function(i,r){var o=_s();return Gd(o,i,r)},useTransition:function(){var i=$d(!1);return i=Pv.bind(null,Le,i.queue,!0,!1),_s().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,o){var u=Le,p=_s();if(Ye){if(o===void 0)throw Error(n(407));o=o()}else{if(o=r(),dt===null)throw Error(n(349));(We&127)!==0||mv(u,r,o)}p.memoizedState=o;var _={value:o,getSnapshot:r};return p.queue=_,Ov(_v.bind(null,u,_,i),[i]),u.flags|=2048,Fa(9,{destroy:void 0},pv.bind(null,u,_,o,r),null),o},useId:function(){var i=_s(),r=dt.identifierPrefix;if(Ye){var o=Ci,u=wi;o=(u&~(1<<32-Ls(u)-1)).toString(32)+o,r="_"+r+"R_"+o,o=Vc++,0<o&&(r+="H"+o.toString(32)),r+="_"}else o=Dj++,r="_"+r+"r_"+o.toString(32)+"_";return i.memoizedState=r},useHostTransitionStatus:Zd,useFormState:jv,useActionState:jv,useOptimistic:function(i){var r=_s();r.memoizedState=r.baseState=i;var o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=o,r=Xd.bind(null,Le,!0,o),o.dispatch=r,[i,r]},useMemoCache:Id,useCacheRefresh:function(){return _s().memoizedState=Pj.bind(null,Le)},useEffectEvent:function(i){var r=_s(),o={impl:i};return r.memoizedState=o,function(){if((it&2)!==0)throw Error(n(440));return o.impl.apply(void 0,arguments)}}},Jd={readContext:ns,use:Gc,useCallback:Lv,useContext:ns,useEffect:Vd,useImperativeHandle:Bv,useInsertionEffect:Rv,useLayoutEffect:Dv,useMemo:qv,useReducer:Qc,useRef:Tv,useState:function(){return Qc(Qi)},useDebugValue:Yd,useDeferredValue:function(i,r){var o=Tt();return zv(o,ot.memoizedState,i,r)},useTransition:function(){var i=Qc(Qi)[0],r=Tt().memoizedState;return[typeof i=="boolean"?i:to(i),r]},useSyncExternalStore:fv,useId:Iv,useHostTransitionStatus:Zd,useFormState:kv,useActionState:kv,useOptimistic:function(i,r){var o=Tt();return yv(o,ot,i,r)},useMemoCache:Id,useCacheRefresh:Uv};Jd.useEffectEvent=Av;var Yv={readContext:ns,use:Gc,useCallback:Lv,useContext:ns,useEffect:Vd,useImperativeHandle:Bv,useInsertionEffect:Rv,useLayoutEffect:Dv,useMemo:qv,useReducer:Kd,useRef:Tv,useState:function(){return Kd(Qi)},useDebugValue:Yd,useDeferredValue:function(i,r){var o=Tt();return ot===null?Gd(o,i,r):zv(o,ot.memoizedState,i,r)},useTransition:function(){var i=Kd(Qi)[0],r=Tt().memoizedState;return[typeof i=="boolean"?i:to(i),r]},useSyncExternalStore:fv,useId:Iv,useHostTransitionStatus:Zd,useFormState:Ev,useActionState:Ev,useOptimistic:function(i,r){var o=Tt();return ot!==null?yv(o,ot,i,r):(o.baseState=i,[i,o.queue.dispatch])},useMemoCache:Id,useCacheRefresh:Uv};Yv.useEffectEvent=Av;function ef(i,r,o,u){r=i.memoizedState,o=o(u,r),o=o==null?r:v({},r,o),i.memoizedState=o,i.lanes===0&&(i.updateQueue.baseState=o)}var tf={enqueueSetState:function(i,r,o){i=i._reactInternals;var u=Us(),p=Tr(u);p.payload=r,o!=null&&(p.callback=o),r=Or(i,p,u),r!==null&&(Es(r,i,u),Zl(r,i,u))},enqueueReplaceState:function(i,r,o){i=i._reactInternals;var u=Us(),p=Tr(u);p.tag=1,p.payload=r,o!=null&&(p.callback=o),r=Or(i,p,u),r!==null&&(Es(r,i,u),Zl(r,i,u))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var o=Us(),u=Tr(o);u.tag=2,r!=null&&(u.callback=r),r=Or(i,u,o),r!==null&&(Es(r,i,o),Zl(r,i,o))}};function Gv(i,r,o,u,p,_,y){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(u,_,y):r.prototype&&r.prototype.isPureReactComponent?!Ul(o,u)||!Ul(p,_):!0}function Qv(i,r,o,u){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(o,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(o,u),r.state!==i&&tf.enqueueReplaceState(r,r.state,null)}function qn(i,r){var o=r;if("ref"in r){o={};for(var u in r)u!=="ref"&&(o[u]=r[u])}if(i=i.defaultProps){o===r&&(o=v({},o));for(var p in i)o[p]===void 0&&(o[p]=i[p])}return o}function Zv(i){Ac(i)}function Xv(i){console.error(i)}function Jv(i){Ac(i)}function eu(i,r){try{var o=i.onUncaughtError;o(r.value,{componentStack:r.stack})}catch(u){setTimeout(function(){throw u})}}function ey(i,r,o){try{var u=i.onCaughtError;u(o.value,{componentStack:o.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function sf(i,r,o){return o=Tr(o),o.tag=3,o.payload={element:null},o.callback=function(){eu(i,r)},o}function ty(i){return i=Tr(i),i.tag=3,i}function sy(i,r,o,u){var p=o.type.getDerivedStateFromError;if(typeof p=="function"){var _=u.value;i.payload=function(){return p(_)},i.callback=function(){ey(r,o,u)}}var y=o.stateNode;y!==null&&typeof y.componentDidCatch=="function"&&(i.callback=function(){ey(r,o,u),typeof p!="function"&&(Lr===null?Lr=new Set([this]):Lr.add(this));var C=u.stack;this.componentDidCatch(u.value,{componentStack:C!==null?C:""})})}function Fj(i,r,o,u,p){if(o.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(r=o.alternate,r!==null&&Da(r,o,p,!0),o=Ps.current,o!==null){switch(o.tag){case 31:case 13:return ni===null?du():o.alternate===null&&xt===0&&(xt=3),o.flags&=-257,o.flags|=65536,o.lanes=p,u===Fc?o.flags|=16384:(r=o.updateQueue,r===null?o.updateQueue=new Set([u]):r.add(u),Ef(i,u,p)),!1;case 22:return o.flags|=65536,u===Fc?o.flags|=16384:(r=o.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([u])},o.updateQueue=r):(o=r.retryQueue,o===null?r.retryQueue=new Set([u]):o.add(u)),Ef(i,u,p)),!1}throw Error(n(435,o.tag))}return Ef(i,u,p),du(),!1}if(Ye)return r=Ps.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,u!==Sd&&(i=Error(n(422),{cause:u}),Wl(ti(i,o)))):(u!==Sd&&(r=Error(n(423),{cause:u}),Wl(ti(r,o))),i=i.current.alternate,i.flags|=65536,p&=-p,i.lanes|=p,u=ti(u,o),p=sf(i.stateNode,u,p),Rd(i,p),xt!==4&&(xt=2)),!1;var _=Error(n(520),{cause:u});if(_=ti(_,o),ho===null?ho=[_]:ho.push(_),xt!==4&&(xt=2),r===null)return!0;u=ti(u,o),o=r;do{switch(o.tag){case 3:return o.flags|=65536,i=p&-p,o.lanes|=i,i=sf(o.stateNode,u,i),Rd(o,i),!1;case 1:if(r=o.type,_=o.stateNode,(o.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||_!==null&&typeof _.componentDidCatch=="function"&&(Lr===null||!Lr.has(_))))return o.flags|=65536,p&=-p,o.lanes|=p,p=ty(p),sy(p,i,o,u),Rd(o,p),!1}o=o.return}while(o!==null);return!1}var rf=Error(n(461)),Mt=!1;function as(i,r,o,u){r.child=i===null?av(r,null,o,u):Bn(r,i.child,o,u)}function iy(i,r,o,u,p){o=o.render;var _=r.ref;if("ref"in u){var y={};for(var C in u)C!=="ref"&&(y[C]=u[C])}else y=u;return An(r),u=zd(i,r,o,y,_,p),C=Pd(),i!==null&&!Mt?(Hd(i,r,p),Zi(i,r,p)):(Ye&&C&&yd(r),r.flags|=1,as(i,r,u,p),r.child)}function ry(i,r,o,u,p){if(i===null){var _=o.type;return typeof _=="function"&&!_d(_)&&_.defaultProps===void 0&&o.compare===null?(r.tag=15,r.type=_,ny(i,r,_,u,p)):(i=Bc(o.type,null,u,r,r.mode,p),i.ref=r.ref,i.return=r,r.child=i)}if(_=i.child,!df(i,p)){var y=_.memoizedProps;if(o=o.compare,o=o!==null?o:Ul,o(y,u)&&i.ref===r.ref)return Zi(i,r,p)}return r.flags|=1,i=$i(_,u),i.ref=r.ref,i.return=r,r.child=i}function ny(i,r,o,u,p){if(i!==null){var _=i.memoizedProps;if(Ul(_,u)&&i.ref===r.ref)if(Mt=!1,r.pendingProps=u=_,df(i,p))(i.flags&131072)!==0&&(Mt=!0);else return r.lanes=i.lanes,Zi(i,r,p)}return nf(i,r,o,u,p)}function ay(i,r,o,u){var p=u.children,_=i!==null?i.memoizedState:null;if(i===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((r.flags&128)!==0){if(_=_!==null?_.baseLanes|o:o,i!==null){for(u=r.child=i.child,p=0;u!==null;)p=p|u.lanes|u.childLanes,u=u.sibling;u=p&~_}else u=0,r.child=null;return ly(i,r,_,o,u)}if((o&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},i!==null&&Pc(r,_!==null?_.cachePool:null),_!==null?cv(r,_):Md(),uv(r);else return u=r.lanes=536870912,ly(i,r,_!==null?_.baseLanes|o:o,o,u)}else _!==null?(Pc(r,_.cachePool),cv(r,_),Rr(),r.memoizedState=null):(i!==null&&Pc(r,null),Md(),Rr());return as(i,r,p,o),r.child}function ro(i,r){return i!==null&&i.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function ly(i,r,o,u,p){var _=Ed();return _=_===null?null:{parent:Rt._currentValue,pool:_},r.memoizedState={baseLanes:o,cachePool:_},i!==null&&Pc(r,null),Md(),uv(r),i!==null&&Da(i,r,u,!0),r.childLanes=p,null}function tu(i,r){return r=iu({mode:r.mode,children:r.children},i.mode),r.ref=i.ref,i.child=r,r.return=i,r}function oy(i,r,o){return Bn(r,i.child,null,o),i=tu(r,r.pendingProps),i.flags|=2,Hs(r),r.memoizedState=null,i}function Ij(i,r,o){var u=r.pendingProps,p=(r.flags&128)!==0;if(r.flags&=-129,i===null){if(Ye){if(u.mode==="hidden")return i=tu(r,u),r.lanes=536870912,ro(null,i);if(Ld(r),(i=mt)?(i=bb(i,ri),i=i!==null&&i.data==="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Cr!==null?{id:wi,overflow:Ci}:null,retryLane:536870912,hydrationErrors:null},o=$g(i),o.return=r,r.child=o,rs=r,mt=null)):i=null,i===null)throw kr(r);return r.lanes=536870912,null}return tu(r,u)}var _=i.memoizedState;if(_!==null){var y=_.dehydrated;if(Ld(r),p)if(r.flags&256)r.flags&=-257,r=oy(i,r,o);else if(r.memoizedState!==null)r.child=i.child,r.flags|=128,r=null;else throw Error(n(558));else if(Mt||Da(i,r,o,!1),p=(o&i.childLanes)!==0,Mt||p){if(u=dt,u!==null&&(y=X_(u,o),y!==0&&y!==_.retryLane))throw _.retryLane=y,Nn(i,y),Es(u,i,y),rf;du(),r=oy(i,r,o)}else i=_.treeContext,mt=ai(y.nextSibling),rs=r,Ye=!0,jr=null,ri=!1,i!==null&&Yg(r,i),r=tu(r,u),r.flags|=4096;return r}return i=$i(i.child,{mode:u.mode,children:u.children}),i.ref=r.ref,r.child=i,i.return=r,i}function su(i,r){var o=r.ref;if(o===null)i!==null&&i.ref!==null&&(r.flags|=4194816);else{if(typeof o!="function"&&typeof o!="object")throw Error(n(284));(i===null||i.ref!==o)&&(r.flags|=4194816)}}function nf(i,r,o,u,p){return An(r),o=zd(i,r,o,u,void 0,p),u=Pd(),i!==null&&!Mt?(Hd(i,r,p),Zi(i,r,p)):(Ye&&u&&yd(r),r.flags|=1,as(i,r,o,p),r.child)}function cy(i,r,o,u,p,_){return An(r),r.updateQueue=null,o=dv(r,u,o,p),hv(i),u=Pd(),i!==null&&!Mt?(Hd(i,r,_),Zi(i,r,_)):(Ye&&u&&yd(r),r.flags|=1,as(i,r,o,_),r.child)}function uy(i,r,o,u,p){if(An(r),r.stateNode===null){var _=Ta,y=o.contextType;typeof y=="object"&&y!==null&&(_=ns(y)),_=new o(u,_),r.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,_.updater=tf,r.stateNode=_,_._reactInternals=r,_=r.stateNode,_.props=u,_.state=r.memoizedState,_.refs={},Od(r),y=o.contextType,_.context=typeof y=="object"&&y!==null?ns(y):Ta,_.state=r.memoizedState,y=o.getDerivedStateFromProps,typeof y=="function"&&(ef(r,o,y,u),_.state=r.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof _.getSnapshotBeforeUpdate=="function"||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(y=_.state,typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount(),y!==_.state&&tf.enqueueReplaceState(_,_.state,null),Jl(r,u,_,p),Xl(),_.state=r.memoizedState),typeof _.componentDidMount=="function"&&(r.flags|=4194308),u=!0}else if(i===null){_=r.stateNode;var C=r.memoizedProps,A=qn(o,C);_.props=A;var I=_.context,se=o.contextType;y=Ta,typeof se=="object"&&se!==null&&(y=ns(se));var re=o.getDerivedStateFromProps;se=typeof re=="function"||typeof _.getSnapshotBeforeUpdate=="function",C=r.pendingProps!==C,se||typeof _.UNSAFE_componentWillReceiveProps!="function"&&typeof _.componentWillReceiveProps!="function"||(C||I!==y)&&Qv(r,_,u,y),Er=!1;var $=r.memoizedState;_.state=$,Jl(r,u,_,p),Xl(),I=r.memoizedState,C||$!==I||Er?(typeof re=="function"&&(ef(r,o,re,u),I=r.memoizedState),(A=Er||Gv(r,o,A,u,$,I,y))?(se||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount()),typeof _.componentDidMount=="function"&&(r.flags|=4194308)):(typeof _.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=I),_.props=u,_.state=I,_.context=y,u=A):(typeof _.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{_=r.stateNode,Ad(i,r),y=r.memoizedProps,se=qn(o,y),_.props=se,re=r.pendingProps,$=_.context,I=o.contextType,A=Ta,typeof I=="object"&&I!==null&&(A=ns(I)),C=o.getDerivedStateFromProps,(I=typeof C=="function"||typeof _.getSnapshotBeforeUpdate=="function")||typeof _.UNSAFE_componentWillReceiveProps!="function"&&typeof _.componentWillReceiveProps!="function"||(y!==re||$!==A)&&Qv(r,_,u,A),Er=!1,$=r.memoizedState,_.state=$,Jl(r,u,_,p),Xl();var X=r.memoizedState;y!==re||$!==X||Er||i!==null&&i.dependencies!==null&&qc(i.dependencies)?(typeof C=="function"&&(ef(r,o,C,u),X=r.memoizedState),(se=Er||Gv(r,o,se,u,$,X,A)||i!==null&&i.dependencies!==null&&qc(i.dependencies))?(I||typeof _.UNSAFE_componentWillUpdate!="function"&&typeof _.componentWillUpdate!="function"||(typeof _.componentWillUpdate=="function"&&_.componentWillUpdate(u,X,A),typeof _.UNSAFE_componentWillUpdate=="function"&&_.UNSAFE_componentWillUpdate(u,X,A)),typeof _.componentDidUpdate=="function"&&(r.flags|=4),typeof _.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof _.componentDidUpdate!="function"||y===i.memoizedProps&&$===i.memoizedState||(r.flags|=4),typeof _.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&$===i.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=X),_.props=u,_.state=X,_.context=A,u=se):(typeof _.componentDidUpdate!="function"||y===i.memoizedProps&&$===i.memoizedState||(r.flags|=4),typeof _.getSnapshotBeforeUpdate!="function"||y===i.memoizedProps&&$===i.memoizedState||(r.flags|=1024),u=!1)}return _=u,su(i,r),u=(r.flags&128)!==0,_||u?(_=r.stateNode,o=u&&typeof o.getDerivedStateFromError!="function"?null:_.render(),r.flags|=1,i!==null&&u?(r.child=Bn(r,i.child,null,p),r.child=Bn(r,null,o,p)):as(i,r,o,p),r.memoizedState=_.state,i=r.child):i=Zi(i,r,p),i}function hy(i,r,o,u){return Tn(),r.flags|=256,as(i,r,o,u),r.child}var af={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function lf(i){return{baseLanes:i,cachePool:ev()}}function of(i,r,o){return i=i!==null?i.childLanes&~o:0,r&&(i|=Is),i}function dy(i,r,o){var u=r.pendingProps,p=!1,_=(r.flags&128)!==0,y;if((y=_)||(y=i!==null&&i.memoizedState===null?!1:(Et.current&2)!==0),y&&(p=!0,r.flags&=-129),y=(r.flags&32)!==0,r.flags&=-33,i===null){if(Ye){if(p?Ar(r):Rr(),(i=mt)?(i=bb(i,ri),i=i!==null&&i.data!=="&"?i:null,i!==null&&(r.memoizedState={dehydrated:i,treeContext:Cr!==null?{id:wi,overflow:Ci}:null,retryLane:536870912,hydrationErrors:null},o=$g(i),o.return=r,r.child=o,rs=r,mt=null)):i=null,i===null)throw kr(r);return Kf(i)?r.lanes=32:r.lanes=536870912,null}var C=u.children;return u=u.fallback,p?(Rr(),p=r.mode,C=iu({mode:"hidden",children:C},p),u=En(u,p,o,null),C.return=r,u.return=r,C.sibling=u,r.child=C,u=r.child,u.memoizedState=lf(o),u.childLanes=of(i,y,o),r.memoizedState=af,ro(null,u)):(Ar(r),cf(r,C))}var A=i.memoizedState;if(A!==null&&(C=A.dehydrated,C!==null)){if(_)r.flags&256?(Ar(r),r.flags&=-257,r=uf(i,r,o)):r.memoizedState!==null?(Rr(),r.child=i.child,r.flags|=128,r=null):(Rr(),C=u.fallback,p=r.mode,u=iu({mode:"visible",children:u.children},p),C=En(C,p,o,null),C.flags|=2,u.return=r,C.return=r,u.sibling=C,r.child=u,Bn(r,i.child,null,o),u=r.child,u.memoizedState=lf(o),u.childLanes=of(i,y,o),r.memoizedState=af,r=ro(null,u));else if(Ar(r),Kf(C)){if(y=C.nextSibling&&C.nextSibling.dataset,y)var I=y.dgst;y=I,u=Error(n(419)),u.stack="",u.digest=y,Wl({value:u,source:null,stack:null}),r=uf(i,r,o)}else if(Mt||Da(i,r,o,!1),y=(o&i.childLanes)!==0,Mt||y){if(y=dt,y!==null&&(u=X_(y,o),u!==0&&u!==A.retryLane))throw A.retryLane=u,Nn(i,u),Es(y,i,u),rf;Uf(C)||du(),r=uf(i,r,o)}else Uf(C)?(r.flags|=192,r.child=i.child,r=null):(i=A.treeContext,mt=ai(C.nextSibling),rs=r,Ye=!0,jr=null,ri=!1,i!==null&&Yg(r,i),r=cf(r,u.children),r.flags|=4096);return r}return p?(Rr(),C=u.fallback,p=r.mode,A=i.child,I=A.sibling,u=$i(A,{mode:"hidden",children:u.children}),u.subtreeFlags=A.subtreeFlags&65011712,I!==null?C=$i(I,C):(C=En(C,p,o,null),C.flags|=2),C.return=r,u.return=r,u.sibling=C,r.child=u,ro(null,u),u=r.child,C=i.child.memoizedState,C===null?C=lf(o):(p=C.cachePool,p!==null?(A=Rt._currentValue,p=p.parent!==A?{parent:A,pool:A}:p):p=ev(),C={baseLanes:C.baseLanes|o,cachePool:p}),u.memoizedState=C,u.childLanes=of(i,y,o),r.memoizedState=af,ro(i.child,u)):(Ar(r),o=i.child,i=o.sibling,o=$i(o,{mode:"visible",children:u.children}),o.return=r,o.sibling=null,i!==null&&(y=r.deletions,y===null?(r.deletions=[i],r.flags|=16):y.push(i)),r.child=o,r.memoizedState=null,o)}function cf(i,r){return r=iu({mode:"visible",children:r},i.mode),r.return=i,i.child=r}function iu(i,r){return i=zs(22,i,null,r),i.lanes=0,i}function uf(i,r,o){return Bn(r,i.child,null,o),i=cf(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function fy(i,r,o){i.lanes|=r;var u=i.alternate;u!==null&&(u.lanes|=r),Cd(i.return,r,o)}function hf(i,r,o,u,p,_){var y=i.memoizedState;y===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:o,tailMode:p,treeForkCount:_}:(y.isBackwards=r,y.rendering=null,y.renderingStartTime=0,y.last=u,y.tail=o,y.tailMode=p,y.treeForkCount=_)}function my(i,r,o){var u=r.pendingProps,p=u.revealOrder,_=u.tail;u=u.children;var y=Et.current,C=(y&2)!==0;if(C?(y=y&1|2,r.flags|=128):y&=1,ae(Et,y),as(i,r,u,o),u=Ye?$l:0,!C&&i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&fy(i,o,r);else if(i.tag===19)fy(i,o,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(p){case"forwards":for(o=r.child,p=null;o!==null;)i=o.alternate,i!==null&&$c(i)===null&&(p=o),o=o.sibling;o=p,o===null?(p=r.child,r.child=null):(p=o.sibling,o.sibling=null),hf(r,!1,p,o,_,u);break;case"backwards":case"unstable_legacy-backwards":for(o=null,p=r.child,r.child=null;p!==null;){if(i=p.alternate,i!==null&&$c(i)===null){r.child=p;break}i=p.sibling,p.sibling=o,o=p,p=i}hf(r,!0,o,null,_,u);break;case"together":hf(r,!1,null,null,void 0,u);break;default:r.memoizedState=null}return r.child}function Zi(i,r,o){if(i!==null&&(r.dependencies=i.dependencies),Br|=r.lanes,(o&r.childLanes)===0)if(i!==null){if(Da(i,r,o,!1),(o&r.childLanes)===0)return null}else return null;if(i!==null&&r.child!==i.child)throw Error(n(153));if(r.child!==null){for(i=r.child,o=$i(i,i.pendingProps),r.child=o,o.return=r;i.sibling!==null;)i=i.sibling,o=o.sibling=$i(i,i.pendingProps),o.return=r;o.sibling=null}return r.child}function df(i,r){return(i.lanes&r)!==0?!0:(i=i.dependencies,!!(i!==null&&qc(i)))}function Uj(i,r,o){switch(r.tag){case 3:nt(r,r.stateNode.containerInfo),Nr(r,Rt,i.memoizedState.cache),Tn();break;case 27:case 5:Ds(r);break;case 4:nt(r,r.stateNode.containerInfo);break;case 10:Nr(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Ld(r),null;break;case 13:var u=r.memoizedState;if(u!==null)return u.dehydrated!==null?(Ar(r),r.flags|=128,null):(o&r.child.childLanes)!==0?dy(i,r,o):(Ar(r),i=Zi(i,r,o),i!==null?i.sibling:null);Ar(r);break;case 19:var p=(i.flags&128)!==0;if(u=(o&r.childLanes)!==0,u||(Da(i,r,o,!1),u=(o&r.childLanes)!==0),p){if(u)return my(i,r,o);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),ae(Et,Et.current),u)break;return null;case 22:return r.lanes=0,ay(i,r,o,r.pendingProps);case 24:Nr(r,Rt,i.memoizedState.cache)}return Zi(i,r,o)}function py(i,r,o){if(i!==null)if(i.memoizedProps!==r.pendingProps)Mt=!0;else{if(!df(i,o)&&(r.flags&128)===0)return Mt=!1,Uj(i,r,o);Mt=(i.flags&131072)!==0}else Mt=!1,Ye&&(r.flags&1048576)!==0&&Vg(r,$l,r.index);switch(r.lanes=0,r.tag){case 16:e:{var u=r.pendingProps;if(i=Dn(r.elementType),r.type=i,typeof i=="function")_d(i)?(u=qn(i,u),r.tag=1,r=uy(null,r,i,u,o)):(r.tag=0,r=nf(null,r,i,u,o));else{if(i!=null){var p=i.$$typeof;if(p===D){r.tag=11,r=iy(null,r,i,u,o);break e}else if(p===Z){r.tag=14,r=ry(null,r,i,u,o);break e}}throw r=W(i)||i,Error(n(306,r,""))}}return r;case 0:return nf(i,r,r.type,r.pendingProps,o);case 1:return u=r.type,p=qn(u,r.pendingProps),uy(i,r,u,p,o);case 3:e:{if(nt(r,r.stateNode.containerInfo),i===null)throw Error(n(387));u=r.pendingProps;var _=r.memoizedState;p=_.element,Ad(i,r),Jl(r,u,null,o);var y=r.memoizedState;if(u=y.cache,Nr(r,Rt,u),u!==_.cache&&jd(r,[Rt],o,!0),Xl(),u=y.element,_.isDehydrated)if(_={element:u,isDehydrated:!1,cache:y.cache},r.updateQueue.baseState=_,r.memoizedState=_,r.flags&256){r=hy(i,r,u,o);break e}else if(u!==p){p=ti(Error(n(424)),r),Wl(p),r=hy(i,r,u,o);break e}else{switch(i=r.stateNode.containerInfo,i.nodeType){case 9:i=i.body;break;default:i=i.nodeName==="HTML"?i.ownerDocument.body:i}for(mt=ai(i.firstChild),rs=r,Ye=!0,jr=null,ri=!0,o=av(r,null,u,o),r.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling}else{if(Tn(),u===p){r=Zi(i,r,o);break e}as(i,r,u,o)}r=r.child}return r;case 26:return su(i,r),i===null?(o=kb(r.type,null,r.pendingProps,null))?r.memoizedState=o:Ye||(o=r.type,i=r.pendingProps,u=yu(_e.current).createElement(o),u[is]=r,u[xs]=i,ls(u,o,i),Yt(u),r.stateNode=u):r.memoizedState=kb(r.type,i.memoizedProps,r.pendingProps,i.memoizedState),null;case 27:return Ds(r),i===null&&Ye&&(u=r.stateNode=wb(r.type,r.pendingProps,_e.current),rs=r,ri=!0,p=mt,Hr(r.type)?($f=p,mt=ai(u.firstChild)):mt=p),as(i,r,r.pendingProps.children,o),su(i,r),i===null&&(r.flags|=4194304),r.child;case 5:return i===null&&Ye&&((p=u=mt)&&(u=yk(u,r.type,r.pendingProps,ri),u!==null?(r.stateNode=u,rs=r,mt=ai(u.firstChild),ri=!1,p=!0):p=!1),p||kr(r)),Ds(r),p=r.type,_=r.pendingProps,y=i!==null?i.memoizedProps:null,u=_.children,Hf(p,_)?u=null:y!==null&&Hf(p,y)&&(r.flags|=32),r.memoizedState!==null&&(p=zd(i,r,Mj,null,null,o),bo._currentValue=p),su(i,r),as(i,r,u,o),r.child;case 6:return i===null&&Ye&&((i=o=mt)&&(o=bk(o,r.pendingProps,ri),o!==null?(r.stateNode=o,rs=r,mt=null,i=!0):i=!1),i||kr(r)),null;case 13:return dy(i,r,o);case 4:return nt(r,r.stateNode.containerInfo),u=r.pendingProps,i===null?r.child=Bn(r,null,u,o):as(i,r,u,o),r.child;case 11:return iy(i,r,r.type,r.pendingProps,o);case 7:return as(i,r,r.pendingProps,o),r.child;case 8:return as(i,r,r.pendingProps.children,o),r.child;case 12:return as(i,r,r.pendingProps.children,o),r.child;case 10:return u=r.pendingProps,Nr(r,r.type,u.value),as(i,r,u.children,o),r.child;case 9:return p=r.type._context,u=r.pendingProps.children,An(r),p=ns(p),u=u(p),r.flags|=1,as(i,r,u,o),r.child;case 14:return ry(i,r,r.type,r.pendingProps,o);case 15:return ny(i,r,r.type,r.pendingProps,o);case 19:return my(i,r,o);case 31:return Ij(i,r,o);case 22:return ay(i,r,o,r.pendingProps);case 24:return An(r),u=ns(Rt),i===null?(p=Ed(),p===null&&(p=dt,_=kd(),p.pooledCache=_,_.refCount++,_!==null&&(p.pooledCacheLanes|=o),p=_),r.memoizedState={parent:u,cache:p},Od(r),Nr(r,Rt,p)):((i.lanes&o)!==0&&(Ad(i,r),Jl(r,null,null,o),Xl()),p=i.memoizedState,_=r.memoizedState,p.parent!==u?(p={parent:u,cache:u},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),Nr(r,Rt,u)):(u=_.cache,Nr(r,Rt,u),u!==p.cache&&jd(r,[Rt],o,!0))),as(i,r,r.pendingProps.children,o),r.child;case 29:throw r.pendingProps}throw Error(n(156,r.tag))}function Xi(i){i.flags|=4}function ff(i,r,o,u,p){if((r=(i.mode&32)!==0)&&(r=!1),r){if(i.flags|=16777216,(p&335544128)===p)if(i.stateNode.complete)i.flags|=8192;else if(Iy())i.flags|=8192;else throw Mn=Fc,Td}else i.flags&=-16777217}function _y(i,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Ab(r))if(Iy())i.flags|=8192;else throw Mn=Fc,Td}function ru(i,r){r!==null&&(i.flags|=4),i.flags&16384&&(r=i.tag!==22?G_():536870912,i.lanes|=r,$a|=r)}function no(i,r){if(!Ye)switch(i.tailMode){case"hidden":r=i.tail;for(var o=null;r!==null;)r.alternate!==null&&(o=r),r=r.sibling;o===null?i.tail=null:o.sibling=null;break;case"collapsed":o=i.tail;for(var u=null;o!==null;)o.alternate!==null&&(u=o),o=o.sibling;u===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:u.sibling=null}}function pt(i){var r=i.alternate!==null&&i.alternate.child===i.child,o=0,u=0;if(r)for(var p=i.child;p!==null;)o|=p.lanes|p.childLanes,u|=p.subtreeFlags&65011712,u|=p.flags&65011712,p.return=i,p=p.sibling;else for(p=i.child;p!==null;)o|=p.lanes|p.childLanes,u|=p.subtreeFlags,u|=p.flags,p.return=i,p=p.sibling;return i.subtreeFlags|=u,i.childLanes=o,r}function Kj(i,r,o){var u=r.pendingProps;switch(bd(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return pt(r),null;case 1:return pt(r),null;case 3:return o=r.stateNode,u=null,i!==null&&(u=i.memoizedState.cache),r.memoizedState.cache!==u&&(r.flags|=2048),Yi(Rt),Xe(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(i===null||i.child===null)&&(Ra(r)?Xi(r):i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,xd())),pt(r),null;case 26:var p=r.type,_=r.memoizedState;return i===null?(Xi(r),_!==null?(pt(r),_y(r,_)):(pt(r),ff(r,p,null,u,o))):_?_!==i.memoizedState?(Xi(r),pt(r),_y(r,_)):(pt(r),r.flags&=-16777217):(i=i.memoizedProps,i!==u&&Xi(r),pt(r),ff(r,p,i,u,o)),null;case 27:if(xi(r),o=_e.current,p=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==u&&Xi(r);else{if(!u){if(r.stateNode===null)throw Error(n(166));return pt(r),null}i=V.current,Ra(r)?Gg(r):(i=wb(p,u,o),r.stateNode=i,Xi(r))}return pt(r),null;case 5:if(xi(r),p=r.type,i!==null&&r.stateNode!=null)i.memoizedProps!==u&&Xi(r);else{if(!u){if(r.stateNode===null)throw Error(n(166));return pt(r),null}if(_=V.current,Ra(r))Gg(r);else{var y=yu(_e.current);switch(_){case 1:_=y.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:_=y.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":_=y.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":_=y.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":_=y.createElement("div"),_.innerHTML="<script><\/script>",_=_.removeChild(_.firstChild);break;case"select":_=typeof u.is=="string"?y.createElement("select",{is:u.is}):y.createElement("select"),u.multiple?_.multiple=!0:u.size&&(_.size=u.size);break;default:_=typeof u.is=="string"?y.createElement(p,{is:u.is}):y.createElement(p)}}_[is]=r,_[xs]=u;e:for(y=r.child;y!==null;){if(y.tag===5||y.tag===6)_.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===r)break e;for(;y.sibling===null;){if(y.return===null||y.return===r)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}r.stateNode=_;e:switch(ls(_,p,u),p){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Xi(r)}}return pt(r),ff(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,o),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==u&&Xi(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(n(166));if(i=_e.current,Ra(r)){if(i=r.stateNode,o=r.memoizedProps,u=null,p=rs,p!==null)switch(p.tag){case 27:case 5:u=p.memoizedProps}i[is]=r,i=!!(i.nodeValue===o||u!==null&&u.suppressHydrationWarning===!0||db(i.nodeValue,o)),i||kr(r,!0)}else i=yu(i).createTextNode(u),i[is]=r,r.stateNode=i}return pt(r),null;case 31:if(o=r.memoizedState,i===null||i.memoizedState!==null){if(u=Ra(r),o!==null){if(i===null){if(!u)throw Error(n(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(557));i[is]=r}else Tn(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;pt(r),i=!1}else o=xd(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return r.flags&256?(Hs(r),r):(Hs(r),null);if((r.flags&128)!==0)throw Error(n(558))}return pt(r),null;case 13:if(u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(p=Ra(r),u!==null&&u.dehydrated!==null){if(i===null){if(!p)throw Error(n(318));if(p=r.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(n(317));p[is]=r}else Tn(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;pt(r),p=!1}else p=xd(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(Hs(r),r):(Hs(r),null)}return Hs(r),(r.flags&128)!==0?(r.lanes=o,r):(o=u!==null,i=i!==null&&i.memoizedState!==null,o&&(u=r.child,p=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(p=u.alternate.memoizedState.cachePool.pool),_=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(_=u.memoizedState.cachePool.pool),_!==p&&(u.flags|=2048)),o!==i&&o&&(r.child.flags|=8192),ru(r,r.updateQueue),pt(r),null);case 4:return Xe(),i===null&&Bf(r.stateNode.containerInfo),pt(r),null;case 10:return Yi(r.type),pt(r),null;case 19:if(U(Et),u=r.memoizedState,u===null)return pt(r),null;if(p=(r.flags&128)!==0,_=u.rendering,_===null)if(p)no(u,!1);else{if(xt!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(_=$c(i),_!==null){for(r.flags|=128,no(u,!1),i=_.updateQueue,r.updateQueue=i,ru(r,i),r.subtreeFlags=0,i=o,o=r.child;o!==null;)Kg(o,i),o=o.sibling;return ae(Et,Et.current&1|2),Ye&&Wi(r,u.treeForkCount),r.child}i=i.sibling}u.tail!==null&&Ms()>cu&&(r.flags|=128,p=!0,no(u,!1),r.lanes=4194304)}else{if(!p)if(i=$c(_),i!==null){if(r.flags|=128,p=!0,i=i.updateQueue,r.updateQueue=i,ru(r,i),no(u,!0),u.tail===null&&u.tailMode==="hidden"&&!_.alternate&&!Ye)return pt(r),null}else 2*Ms()-u.renderingStartTime>cu&&o!==536870912&&(r.flags|=128,p=!0,no(u,!1),r.lanes=4194304);u.isBackwards?(_.sibling=r.child,r.child=_):(i=u.last,i!==null?i.sibling=_:r.child=_,u.last=_)}return u.tail!==null?(i=u.tail,u.rendering=i,u.tail=i.sibling,u.renderingStartTime=Ms(),i.sibling=null,o=Et.current,ae(Et,p?o&1|2:o&1),Ye&&Wi(r,u.treeForkCount),i):(pt(r),null);case 22:case 23:return Hs(r),Bd(),u=r.memoizedState!==null,i!==null?i.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(o&536870912)!==0&&(r.flags&128)===0&&(pt(r),r.subtreeFlags&6&&(r.flags|=8192)):pt(r),o=r.updateQueue,o!==null&&ru(r,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==o&&(r.flags|=2048),i!==null&&U(Rn),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),r.memoizedState.cache!==o&&(r.flags|=2048),Yi(Rt),pt(r),null;case 25:return null;case 30:return null}throw Error(n(156,r.tag))}function $j(i,r){switch(bd(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return Yi(Rt),Xe(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return xi(r),null;case 31:if(r.memoizedState!==null){if(Hs(r),r.alternate===null)throw Error(n(340));Tn()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Hs(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));Tn()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return U(Et),null;case 4:return Xe(),null;case 10:return Yi(r.type),null;case 22:case 23:return Hs(r),Bd(),i!==null&&U(Rn),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return Yi(Rt),null;case 25:return null;default:return null}}function gy(i,r){switch(bd(r),r.tag){case 3:Yi(Rt),Xe();break;case 26:case 27:case 5:xi(r);break;case 4:Xe();break;case 31:r.memoizedState!==null&&Hs(r);break;case 13:Hs(r);break;case 19:U(Et);break;case 10:Yi(r.type);break;case 22:case 23:Hs(r),Bd(),i!==null&&U(Rn);break;case 24:Yi(Rt)}}function ao(i,r){try{var o=r.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var p=u.next;o=p;do{if((o.tag&i)===i){u=void 0;var _=o.create,y=o.inst;u=_(),y.destroy=u}o=o.next}while(o!==p)}}catch(C){lt(r,r.return,C)}}function Dr(i,r,o){try{var u=r.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var _=p.next;u=_;do{if((u.tag&i)===i){var y=u.inst,C=y.destroy;if(C!==void 0){y.destroy=void 0,p=r;var A=o,I=C;try{I()}catch(se){lt(p,A,se)}}}u=u.next}while(u!==_)}}catch(se){lt(r,r.return,se)}}function vy(i){var r=i.updateQueue;if(r!==null){var o=i.stateNode;try{ov(r,o)}catch(u){lt(i,i.return,u)}}}function yy(i,r,o){o.props=qn(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(u){lt(i,r,u)}}function lo(i,r){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var u=i.stateNode;break;case 30:u=i.stateNode;break;default:u=i.stateNode}typeof o=="function"?i.refCleanup=o(u):o.current=u}}catch(p){lt(i,r,p)}}function ji(i,r){var o=i.ref,u=i.refCleanup;if(o!==null)if(typeof u=="function")try{u()}catch(p){lt(i,r,p)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(p){lt(i,r,p)}else o.current=null}function by(i){var r=i.type,o=i.memoizedProps,u=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":o.autoFocus&&u.focus();break e;case"img":o.src?u.src=o.src:o.srcSet&&(u.srcset=o.srcSet)}}catch(p){lt(i,i.return,p)}}function mf(i,r,o){try{var u=i.stateNode;fk(u,i.type,o,r),u[xs]=r}catch(p){lt(i,i.return,p)}}function Sy(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Hr(i.type)||i.tag===4}function pf(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Sy(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&Hr(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function _f(i,r,o){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,r):(r=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,r.appendChild(i),o=o._reactRootContainer,o!=null||r.onclick!==null||(r.onclick=Ui));else if(u!==4&&(u===27&&Hr(i.type)&&(o=i.stateNode,r=null),i=i.child,i!==null))for(_f(i,r,o),i=i.sibling;i!==null;)_f(i,r,o),i=i.sibling}function nu(i,r,o){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?o.insertBefore(i,r):o.appendChild(i);else if(u!==4&&(u===27&&Hr(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(nu(i,r,o),i=i.sibling;i!==null;)nu(i,r,o),i=i.sibling}function xy(i){var r=i.stateNode,o=i.memoizedProps;try{for(var u=i.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);ls(r,u,o),r[is]=i,r[xs]=o}catch(_){lt(i,i.return,_)}}var Ji=!1,Bt=!1,gf=!1,wy=typeof WeakSet=="function"?WeakSet:Set,Gt=null;function Wj(i,r){if(i=i.containerInfo,zf=ku,i=Bg(i),cd(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var u=o.getSelection&&o.getSelection();if(u&&u.rangeCount!==0){o=u.anchorNode;var p=u.anchorOffset,_=u.focusNode;u=u.focusOffset;try{o.nodeType,_.nodeType}catch{o=null;break e}var y=0,C=-1,A=-1,I=0,se=0,re=i,$=null;t:for(;;){for(var X;re!==o||p!==0&&re.nodeType!==3||(C=y+p),re!==_||u!==0&&re.nodeType!==3||(A=y+u),re.nodeType===3&&(y+=re.nodeValue.length),(X=re.firstChild)!==null;)$=re,re=X;for(;;){if(re===i)break t;if($===o&&++I===p&&(C=y),$===_&&++se===u&&(A=y),(X=re.nextSibling)!==null)break;re=$,$=re.parentNode}re=X}o=C===-1||A===-1?null:{start:C,end:A}}else o=null}o=o||{start:0,end:0}}else o=null;for(Pf={focusedElem:i,selectionRange:o},ku=!1,Gt=r;Gt!==null;)if(r=Gt,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Gt=i;else for(;Gt!==null;){switch(r=Gt,_=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o<i.length;o++)p=i[o],p.ref.impl=p.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&_!==null){i=void 0,o=r,p=_.memoizedProps,_=_.memoizedState,u=o.stateNode;try{var be=qn(o.type,p);i=u.getSnapshotBeforeUpdate(be,_),u.__reactInternalSnapshotBeforeUpdate=i}catch(Ee){lt(o,o.return,Ee)}}break;case 3:if((i&1024)!==0){if(i=r.stateNode.containerInfo,o=i.nodeType,o===9)If(i);else if(o===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":If(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(n(163))}if(i=r.sibling,i!==null){i.return=r.return,Gt=i;break}Gt=r.return}}function Cy(i,r,o){var u=o.flags;switch(o.tag){case 0:case 11:case 15:tr(i,o),u&4&&ao(5,o);break;case 1:if(tr(i,o),u&4)if(i=o.stateNode,r===null)try{i.componentDidMount()}catch(y){lt(o,o.return,y)}else{var p=qn(o.type,r.memoizedProps);r=r.memoizedState;try{i.componentDidUpdate(p,r,i.__reactInternalSnapshotBeforeUpdate)}catch(y){lt(o,o.return,y)}}u&64&&vy(o),u&512&&lo(o,o.return);break;case 3:if(tr(i,o),u&64&&(i=o.updateQueue,i!==null)){if(r=null,o.child!==null)switch(o.child.tag){case 27:case 5:r=o.child.stateNode;break;case 1:r=o.child.stateNode}try{ov(i,r)}catch(y){lt(o,o.return,y)}}break;case 27:r===null&&u&4&&xy(o);case 26:case 5:tr(i,o),r===null&&u&4&&by(o),u&512&&lo(o,o.return);break;case 12:tr(i,o);break;case 31:tr(i,o),u&4&&Ny(i,o);break;case 13:tr(i,o),u&4&&Ey(i,o),u&64&&(i=o.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(o=tk.bind(null,o),Sk(i,o))));break;case 22:if(u=o.memoizedState!==null||Ji,!u){r=r!==null&&r.memoizedState!==null||Bt,p=Ji;var _=Bt;Ji=u,(Bt=r)&&!_?sr(i,o,(o.subtreeFlags&8772)!==0):tr(i,o),Ji=p,Bt=_}break;case 30:break;default:tr(i,o)}}function jy(i){var r=i.alternate;r!==null&&(i.alternate=null,jy(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&Wh(r)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var gt=null,Cs=!1;function er(i,r,o){for(o=o.child;o!==null;)ky(i,r,o),o=o.sibling}function ky(i,r,o){if(Bs&&typeof Bs.onCommitFiberUnmount=="function")try{Bs.onCommitFiberUnmount(Al,o)}catch{}switch(o.tag){case 26:Bt||ji(o,r),er(i,r,o),o.memoizedState?o.memoizedState.count--:o.stateNode&&(o=o.stateNode,o.parentNode.removeChild(o));break;case 27:Bt||ji(o,r);var u=gt,p=Cs;Hr(o.type)&&(gt=o.stateNode,Cs=!1),er(i,r,o),go(o.stateNode),gt=u,Cs=p;break;case 5:Bt||ji(o,r);case 6:if(u=gt,p=Cs,gt=null,er(i,r,o),gt=u,Cs=p,gt!==null)if(Cs)try{(gt.nodeType===9?gt.body:gt.nodeName==="HTML"?gt.ownerDocument.body:gt).removeChild(o.stateNode)}catch(_){lt(o,r,_)}else try{gt.removeChild(o.stateNode)}catch(_){lt(o,r,_)}break;case 18:gt!==null&&(Cs?(i=gt,vb(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,o.stateNode),Ja(i)):vb(gt,o.stateNode));break;case 4:u=gt,p=Cs,gt=o.stateNode.containerInfo,Cs=!0,er(i,r,o),gt=u,Cs=p;break;case 0:case 11:case 14:case 15:Dr(2,o,r),Bt||Dr(4,o,r),er(i,r,o);break;case 1:Bt||(ji(o,r),u=o.stateNode,typeof u.componentWillUnmount=="function"&&yy(o,r,u)),er(i,r,o);break;case 21:er(i,r,o);break;case 22:Bt=(u=Bt)||o.memoizedState!==null,er(i,r,o),Bt=u;break;default:er(i,r,o)}}function Ny(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Ja(i)}catch(o){lt(r,r.return,o)}}}function Ey(i,r){if(r.memoizedState===null&&(i=r.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Ja(i)}catch(o){lt(r,r.return,o)}}function Vj(i){switch(i.tag){case 31:case 13:case 19:var r=i.stateNode;return r===null&&(r=i.stateNode=new wy),r;case 22:return i=i.stateNode,r=i._retryCache,r===null&&(r=i._retryCache=new wy),r;default:throw Error(n(435,i.tag))}}function au(i,r){var o=Vj(i);r.forEach(function(u){if(!o.has(u)){o.add(u);var p=sk.bind(null,i,u);u.then(p,p)}})}function js(i,r){var o=r.deletions;if(o!==null)for(var u=0;u<o.length;u++){var p=o[u],_=i,y=r,C=y;e:for(;C!==null;){switch(C.tag){case 27:if(Hr(C.type)){gt=C.stateNode,Cs=!1;break e}break;case 5:gt=C.stateNode,Cs=!1;break e;case 3:case 4:gt=C.stateNode.containerInfo,Cs=!0;break e}C=C.return}if(gt===null)throw Error(n(160));ky(_,y,p),gt=null,Cs=!1,_=p.alternate,_!==null&&(_.return=null),p.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)Ty(r,i),r=r.sibling}var _i=null;function Ty(i,r){var o=i.alternate,u=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:js(r,i),ks(i),u&4&&(Dr(3,i,i.return),ao(3,i),Dr(5,i,i.return));break;case 1:js(r,i),ks(i),u&512&&(Bt||o===null||ji(o,o.return)),u&64&&Ji&&(i=i.updateQueue,i!==null&&(u=i.callbacks,u!==null&&(o=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=o===null?u:o.concat(u))));break;case 26:var p=_i;if(js(r,i),ks(i),u&512&&(Bt||o===null||ji(o,o.return)),u&4){var _=o!==null?o.memoizedState:null;if(u=i.memoizedState,o===null)if(u===null)if(i.stateNode===null){e:{u=i.type,o=i.memoizedProps,p=p.ownerDocument||p;t:switch(u){case"title":_=p.getElementsByTagName("title")[0],(!_||_[Ml]||_[is]||_.namespaceURI==="http://www.w3.org/2000/svg"||_.hasAttribute("itemprop"))&&(_=p.createElement(u),p.head.insertBefore(_,p.querySelector("head > title"))),ls(_,u,o),_[is]=i,Yt(_),u=_;break e;case"link":var y=Tb("link","href",p).get(u+(o.href||""));if(y){for(var C=0;C<y.length;C++)if(_=y[C],_.getAttribute("href")===(o.href==null||o.href===""?null:o.href)&&_.getAttribute("rel")===(o.rel==null?null:o.rel)&&_.getAttribute("title")===(o.title==null?null:o.title)&&_.getAttribute("crossorigin")===(o.crossOrigin==null?null:o.crossOrigin)){y.splice(C,1);break t}}_=p.createElement(u),ls(_,u,o),p.head.appendChild(_);break;case"meta":if(y=Tb("meta","content",p).get(u+(o.content||""))){for(C=0;C<y.length;C++)if(_=y[C],_.getAttribute("content")===(o.content==null?null:""+o.content)&&_.getAttribute("name")===(o.name==null?null:o.name)&&_.getAttribute("property")===(o.property==null?null:o.property)&&_.getAttribute("http-equiv")===(o.httpEquiv==null?null:o.httpEquiv)&&_.getAttribute("charset")===(o.charSet==null?null:o.charSet)){y.splice(C,1);break t}}_=p.createElement(u),ls(_,u,o),p.head.appendChild(_);break;default:throw Error(n(468,u))}_[is]=i,Yt(_),u=_}i.stateNode=u}else Ob(p,i.type,i.stateNode);else i.stateNode=Eb(p,u,i.memoizedProps);else _!==u?(_===null?o.stateNode!==null&&(o=o.stateNode,o.parentNode.removeChild(o)):_.count--,u===null?Ob(p,i.type,i.stateNode):Eb(p,u,i.memoizedProps)):u===null&&i.stateNode!==null&&mf(i,i.memoizedProps,o.memoizedProps)}break;case 27:js(r,i),ks(i),u&512&&(Bt||o===null||ji(o,o.return)),o!==null&&u&4&&mf(i,i.memoizedProps,o.memoizedProps);break;case 5:if(js(r,i),ks(i),u&512&&(Bt||o===null||ji(o,o.return)),i.flags&32){p=i.stateNode;try{xa(p,"")}catch(be){lt(i,i.return,be)}}u&4&&i.stateNode!=null&&(p=i.memoizedProps,mf(i,p,o!==null?o.memoizedProps:p)),u&1024&&(gf=!0);break;case 6:if(js(r,i),ks(i),u&4){if(i.stateNode===null)throw Error(n(162));u=i.memoizedProps,o=i.stateNode;try{o.nodeValue=u}catch(be){lt(i,i.return,be)}}break;case 3:if(xu=null,p=_i,_i=bu(r.containerInfo),js(r,i),_i=p,ks(i),u&4&&o!==null&&o.memoizedState.isDehydrated)try{Ja(r.containerInfo)}catch(be){lt(i,i.return,be)}gf&&(gf=!1,Oy(i));break;case 4:u=_i,_i=bu(i.stateNode.containerInfo),js(r,i),ks(i),_i=u;break;case 12:js(r,i),ks(i);break;case 31:js(r,i),ks(i),u&4&&(u=i.updateQueue,u!==null&&(i.updateQueue=null,au(i,u)));break;case 13:js(r,i),ks(i),i.child.flags&8192&&i.memoizedState!==null!=(o!==null&&o.memoizedState!==null)&&(ou=Ms()),u&4&&(u=i.updateQueue,u!==null&&(i.updateQueue=null,au(i,u)));break;case 22:p=i.memoizedState!==null;var A=o!==null&&o.memoizedState!==null,I=Ji,se=Bt;if(Ji=I||p,Bt=se||A,js(r,i),Bt=se,Ji=I,ks(i),u&8192)e:for(r=i.stateNode,r._visibility=p?r._visibility&-2:r._visibility|1,p&&(o===null||A||Ji||Bt||zn(i)),o=null,r=i;;){if(r.tag===5||r.tag===26){if(o===null){A=o=r;try{if(_=A.stateNode,p)y=_.style,typeof y.setProperty=="function"?y.setProperty("display","none","important"):y.display="none";else{C=A.stateNode;var re=A.memoizedProps.style,$=re!=null&&re.hasOwnProperty("display")?re.display:null;C.style.display=$==null||typeof $=="boolean"?"":(""+$).trim()}}catch(be){lt(A,A.return,be)}}}else if(r.tag===6){if(o===null){A=r;try{A.stateNode.nodeValue=p?"":A.memoizedProps}catch(be){lt(A,A.return,be)}}}else if(r.tag===18){if(o===null){A=r;try{var X=A.stateNode;p?yb(X,!0):yb(A.stateNode,!1)}catch(be){lt(A,A.return,be)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===i)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;o===r&&(o=null),r=r.return}o===r&&(o=null),r.sibling.return=r.return,r=r.sibling}u&4&&(u=i.updateQueue,u!==null&&(o=u.retryQueue,o!==null&&(u.retryQueue=null,au(i,o))));break;case 19:js(r,i),ks(i),u&4&&(u=i.updateQueue,u!==null&&(i.updateQueue=null,au(i,u)));break;case 30:break;case 21:break;default:js(r,i),ks(i)}}function ks(i){var r=i.flags;if(r&2){try{for(var o,u=i.return;u!==null;){if(Sy(u)){o=u;break}u=u.return}if(o==null)throw Error(n(160));switch(o.tag){case 27:var p=o.stateNode,_=pf(i);nu(i,_,p);break;case 5:var y=o.stateNode;o.flags&32&&(xa(y,""),o.flags&=-33);var C=pf(i);nu(i,C,y);break;case 3:case 4:var A=o.stateNode.containerInfo,I=pf(i);_f(i,I,A);break;default:throw Error(n(161))}}catch(se){lt(i,i.return,se)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function Oy(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var r=i;Oy(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),i=i.sibling}}function tr(i,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)Cy(i,r.alternate,r),r=r.sibling}function zn(i){for(i=i.child;i!==null;){var r=i;switch(r.tag){case 0:case 11:case 14:case 15:Dr(4,r,r.return),zn(r);break;case 1:ji(r,r.return);var o=r.stateNode;typeof o.componentWillUnmount=="function"&&yy(r,r.return,o),zn(r);break;case 27:go(r.stateNode);case 26:case 5:ji(r,r.return),zn(r);break;case 22:r.memoizedState===null&&zn(r);break;case 30:zn(r);break;default:zn(r)}i=i.sibling}}function sr(i,r,o){for(o=o&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var u=r.alternate,p=i,_=r,y=_.flags;switch(_.tag){case 0:case 11:case 15:sr(p,_,o),ao(4,_);break;case 1:if(sr(p,_,o),u=_,p=u.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(I){lt(u,u.return,I)}if(u=_,p=u.updateQueue,p!==null){var C=u.stateNode;try{var A=p.shared.hiddenCallbacks;if(A!==null)for(p.shared.hiddenCallbacks=null,p=0;p<A.length;p++)lv(A[p],C)}catch(I){lt(u,u.return,I)}}o&&y&64&&vy(_),lo(_,_.return);break;case 27:xy(_);case 26:case 5:sr(p,_,o),o&&u===null&&y&4&&by(_),lo(_,_.return);break;case 12:sr(p,_,o);break;case 31:sr(p,_,o),o&&y&4&&Ny(p,_);break;case 13:sr(p,_,o),o&&y&4&&Ey(p,_);break;case 22:_.memoizedState===null&&sr(p,_,o),lo(_,_.return);break;case 30:break;default:sr(p,_,o)}r=r.sibling}}function vf(i,r){var o=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),i=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(i=r.memoizedState.cachePool.pool),i!==o&&(i!=null&&i.refCount++,o!=null&&Vl(o))}function yf(i,r){i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Vl(i))}function gi(i,r,o,u){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)Ay(i,r,o,u),r=r.sibling}function Ay(i,r,o,u){var p=r.flags;switch(r.tag){case 0:case 11:case 15:gi(i,r,o,u),p&2048&&ao(9,r);break;case 1:gi(i,r,o,u);break;case 3:gi(i,r,o,u),p&2048&&(i=null,r.alternate!==null&&(i=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==i&&(r.refCount++,i!=null&&Vl(i)));break;case 12:if(p&2048){gi(i,r,o,u),i=r.stateNode;try{var _=r.memoizedProps,y=_.id,C=_.onPostCommit;typeof C=="function"&&C(y,r.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(A){lt(r,r.return,A)}}else gi(i,r,o,u);break;case 31:gi(i,r,o,u);break;case 13:gi(i,r,o,u);break;case 23:break;case 22:_=r.stateNode,y=r.alternate,r.memoizedState!==null?_._visibility&2?gi(i,r,o,u):oo(i,r):_._visibility&2?gi(i,r,o,u):(_._visibility|=2,Ia(i,r,o,u,(r.subtreeFlags&10256)!==0||!1)),p&2048&&vf(y,r);break;case 24:gi(i,r,o,u),p&2048&&yf(r.alternate,r);break;default:gi(i,r,o,u)}}function Ia(i,r,o,u,p){for(p=p&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var _=i,y=r,C=o,A=u,I=y.flags;switch(y.tag){case 0:case 11:case 15:Ia(_,y,C,A,p),ao(8,y);break;case 23:break;case 22:var se=y.stateNode;y.memoizedState!==null?se._visibility&2?Ia(_,y,C,A,p):oo(_,y):(se._visibility|=2,Ia(_,y,C,A,p)),p&&I&2048&&vf(y.alternate,y);break;case 24:Ia(_,y,C,A,p),p&&I&2048&&yf(y.alternate,y);break;default:Ia(_,y,C,A,p)}r=r.sibling}}function oo(i,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var o=i,u=r,p=u.flags;switch(u.tag){case 22:oo(o,u),p&2048&&vf(u.alternate,u);break;case 24:oo(o,u),p&2048&&yf(u.alternate,u);break;default:oo(o,u)}r=r.sibling}}var co=8192;function Ua(i,r,o){if(i.subtreeFlags&co)for(i=i.child;i!==null;)Ry(i,r,o),i=i.sibling}function Ry(i,r,o){switch(i.tag){case 26:Ua(i,r,o),i.flags&co&&i.memoizedState!==null&&Dk(o,_i,i.memoizedState,i.memoizedProps);break;case 5:Ua(i,r,o);break;case 3:case 4:var u=_i;_i=bu(i.stateNode.containerInfo),Ua(i,r,o),_i=u;break;case 22:i.memoizedState===null&&(u=i.alternate,u!==null&&u.memoizedState!==null?(u=co,co=16777216,Ua(i,r,o),co=u):Ua(i,r,o));break;default:Ua(i,r,o)}}function Dy(i){var r=i.alternate;if(r!==null&&(i=r.child,i!==null)){r.child=null;do r=i.sibling,i.sibling=null,i=r;while(i!==null)}}function uo(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var o=0;o<r.length;o++){var u=r[o];Gt=u,By(u,i)}Dy(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)My(i),i=i.sibling}function My(i){switch(i.tag){case 0:case 11:case 15:uo(i),i.flags&2048&&Dr(9,i,i.return);break;case 3:uo(i);break;case 12:uo(i);break;case 22:var r=i.stateNode;i.memoizedState!==null&&r._visibility&2&&(i.return===null||i.return.tag!==13)?(r._visibility&=-3,lu(i)):uo(i);break;default:uo(i)}}function lu(i){var r=i.deletions;if((i.flags&16)!==0){if(r!==null)for(var o=0;o<r.length;o++){var u=r[o];Gt=u,By(u,i)}Dy(i)}for(i=i.child;i!==null;){switch(r=i,r.tag){case 0:case 11:case 15:Dr(8,r,r.return),lu(r);break;case 22:o=r.stateNode,o._visibility&2&&(o._visibility&=-3,lu(r));break;default:lu(r)}i=i.sibling}}function By(i,r){for(;Gt!==null;){var o=Gt;switch(o.tag){case 0:case 11:case 15:Dr(8,o,r);break;case 23:case 22:if(o.memoizedState!==null&&o.memoizedState.cachePool!==null){var u=o.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:Vl(o.memoizedState.cache)}if(u=o.child,u!==null)u.return=o,Gt=u;else e:for(o=i;Gt!==null;){u=Gt;var p=u.sibling,_=u.return;if(jy(u),u===o){Gt=null;break e}if(p!==null){p.return=_,Gt=p;break e}Gt=_}}}var Yj={getCacheForType:function(i){var r=ns(Rt),o=r.data.get(i);return o===void 0&&(o=i(),r.data.set(i,o)),o},cacheSignal:function(){return ns(Rt).controller.signal}},Gj=typeof WeakMap=="function"?WeakMap:Map,it=0,dt=null,Ue=null,We=0,at=0,Fs=null,Mr=!1,Ka=!1,bf=!1,ir=0,xt=0,Br=0,Pn=0,Sf=0,Is=0,$a=0,ho=null,Ns=null,xf=!1,ou=0,Ly=0,cu=1/0,uu=null,Lr=null,Ht=0,qr=null,Wa=null,rr=0,wf=0,Cf=null,qy=null,fo=0,jf=null;function Us(){return(it&2)!==0&&We!==0?We&-We:T.T!==null?Af():J_()}function zy(){if(Is===0)if((We&536870912)===0||Ye){var i=vc;vc<<=1,(vc&3932160)===0&&(vc=262144),Is=i}else Is=536870912;return i=Ps.current,i!==null&&(i.flags|=32),Is}function Es(i,r,o){(i===dt&&(at===2||at===9)||i.cancelPendingCommit!==null)&&(Va(i,0),zr(i,We,Is,!1)),Dl(i,o),((it&2)===0||i!==dt)&&(i===dt&&((it&2)===0&&(Pn|=o),xt===4&&zr(i,We,Is,!1)),ki(i))}function Py(i,r,o){if((it&6)!==0)throw Error(n(327));var u=!o&&(r&127)===0&&(r&i.expiredLanes)===0||Rl(i,r),p=u?Xj(i,r):Nf(i,r,!0),_=u;do{if(p===0){Ka&&!u&&zr(i,r,0,!1);break}else{if(o=i.current.alternate,_&&!Qj(o)){p=Nf(i,r,!1),_=!1;continue}if(p===2){if(_=r,i.errorRecoveryDisabledLanes&_)var y=0;else y=i.pendingLanes&-536870913,y=y!==0?y:y&536870912?536870912:0;if(y!==0){r=y;e:{var C=i;p=ho;var A=C.current.memoizedState.isDehydrated;if(A&&(Va(C,y).flags|=256),y=Nf(C,y,!1),y!==2){if(bf&&!A){C.errorRecoveryDisabledLanes|=_,Pn|=_,p=4;break e}_=Ns,Ns=p,_!==null&&(Ns===null?Ns=_:Ns.push.apply(Ns,_))}p=y}if(_=!1,p!==2)continue}}if(p===1){Va(i,0),zr(i,r,0,!0);break}e:{switch(u=i,_=p,_){case 0:case 1:throw Error(n(345));case 4:if((r&4194048)!==r)break;case 6:zr(u,r,Is,!Mr);break e;case 2:Ns=null;break;case 3:case 5:break;default:throw Error(n(329))}if((r&62914560)===r&&(p=ou+300-Ms(),10<p)){if(zr(u,r,Is,!Mr),bc(u,0,!0)!==0)break e;rr=r,u.timeoutHandle=_b(Hy.bind(null,u,o,Ns,uu,xf,r,Is,Pn,$a,Mr,_,"Throttled",-0,0),p);break e}Hy(u,o,Ns,uu,xf,r,Is,Pn,$a,Mr,_,null,-0,0)}}break}while(!0);ki(i)}function Hy(i,r,o,u,p,_,y,C,A,I,se,re,$,X){if(i.timeoutHandle=-1,re=r.subtreeFlags,re&8192||(re&16785408)===16785408){re={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ui},Ry(r,_,re);var be=(_&62914560)===_?ou-Ms():(_&4194048)===_?Ly-Ms():0;if(be=Mk(re,be),be!==null){rr=_,i.cancelPendingCommit=be(Yy.bind(null,i,r,_,o,u,p,y,C,A,se,re,null,$,X)),zr(i,_,y,!I);return}}Yy(i,r,_,o,u,p,y,C,A)}function Qj(i){for(var r=i;;){var o=r.tag;if((o===0||o===11||o===15)&&r.flags&16384&&(o=r.updateQueue,o!==null&&(o=o.stores,o!==null)))for(var u=0;u<o.length;u++){var p=o[u],_=p.getSnapshot;p=p.value;try{if(!qs(_(),p))return!1}catch{return!1}}if(o=r.child,r.subtreeFlags&16384&&o!==null)o.return=r,r=o;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function zr(i,r,o,u){r&=~Sf,r&=~Pn,i.suspendedLanes|=r,i.pingedLanes&=~r,u&&(i.warmLanes|=r),u=i.expirationTimes;for(var p=r;0<p;){var _=31-Ls(p),y=1<<_;u[_]=-1,p&=~y}o!==0&&Q_(i,o,r)}function hu(){return(it&6)===0?(mo(0),!1):!0}function kf(){if(Ue!==null){if(at===0)var i=Ue.return;else i=Ue,Vi=On=null,Fd(i),qa=null,Gl=0,i=Ue;for(;i!==null;)gy(i.alternate,i),i=i.return;Ue=null}}function Va(i,r){var o=i.timeoutHandle;o!==-1&&(i.timeoutHandle=-1,_k(o)),o=i.cancelPendingCommit,o!==null&&(i.cancelPendingCommit=null,o()),rr=0,kf(),dt=i,Ue=o=$i(i.current,null),We=r,at=0,Fs=null,Mr=!1,Ka=Rl(i,r),bf=!1,$a=Is=Sf=Pn=Br=xt=0,Ns=ho=null,xf=!1,(r&8)!==0&&(r|=r&32);var u=i.entangledLanes;if(u!==0)for(i=i.entanglements,u&=r;0<u;){var p=31-Ls(u),_=1<<p;r|=i[p],u&=~_}return ir=r,Rc(),o}function Fy(i,r){Le=null,T.H=io,r===La||r===Hc?(r=iv(),at=3):r===Td?(r=iv(),at=4):at=r===rf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,Fs=r,Ue===null&&(xt=1,eu(i,ti(r,i.current)))}function Iy(){var i=Ps.current;return i===null?!0:(We&4194048)===We?ni===null:(We&62914560)===We||(We&536870912)!==0?i===ni:!1}function Uy(){var i=T.H;return T.H=io,i===null?io:i}function Ky(){var i=T.A;return T.A=Yj,i}function du(){xt=4,Mr||(We&4194048)!==We&&Ps.current!==null||(Ka=!0),(Br&134217727)===0&&(Pn&134217727)===0||dt===null||zr(dt,We,Is,!1)}function Nf(i,r,o){var u=it;it|=2;var p=Uy(),_=Ky();(dt!==i||We!==r)&&(uu=null,Va(i,r)),r=!1;var y=xt;e:do try{if(at!==0&&Ue!==null){var C=Ue,A=Fs;switch(at){case 8:kf(),y=6;break e;case 3:case 2:case 9:case 6:Ps.current===null&&(r=!0);var I=at;if(at=0,Fs=null,Ya(i,C,A,I),o&&Ka){y=0;break e}break;default:I=at,at=0,Fs=null,Ya(i,C,A,I)}}Zj(),y=xt;break}catch(se){Fy(i,se)}while(!0);return r&&i.shellSuspendCounter++,Vi=On=null,it=u,T.H=p,T.A=_,Ue===null&&(dt=null,We=0,Rc()),y}function Zj(){for(;Ue!==null;)$y(Ue)}function Xj(i,r){var o=it;it|=2;var u=Uy(),p=Ky();dt!==i||We!==r?(uu=null,cu=Ms()+500,Va(i,r)):Ka=Rl(i,r);e:do try{if(at!==0&&Ue!==null){r=Ue;var _=Fs;t:switch(at){case 1:at=0,Fs=null,Ya(i,r,_,1);break;case 2:case 9:if(tv(_)){at=0,Fs=null,Wy(r);break}r=function(){at!==2&&at!==9||dt!==i||(at=7),ki(i)},_.then(r,r);break e;case 3:at=7;break e;case 4:at=5;break e;case 7:tv(_)?(at=0,Fs=null,Wy(r)):(at=0,Fs=null,Ya(i,r,_,7));break;case 5:var y=null;switch(Ue.tag){case 26:y=Ue.memoizedState;case 5:case 27:var C=Ue;if(y?Ab(y):C.stateNode.complete){at=0,Fs=null;var A=C.sibling;if(A!==null)Ue=A;else{var I=C.return;I!==null?(Ue=I,fu(I)):Ue=null}break t}}at=0,Fs=null,Ya(i,r,_,5);break;case 6:at=0,Fs=null,Ya(i,r,_,6);break;case 8:kf(),xt=6;break e;default:throw Error(n(462))}}Jj();break}catch(se){Fy(i,se)}while(!0);return Vi=On=null,T.H=u,T.A=p,it=o,Ue!==null?0:(dt=null,We=0,Rc(),xt)}function Jj(){for(;Ue!==null&&!xC();)$y(Ue)}function $y(i){var r=py(i.alternate,i,ir);i.memoizedProps=i.pendingProps,r===null?fu(i):Ue=r}function Wy(i){var r=i,o=r.alternate;switch(r.tag){case 15:case 0:r=cy(o,r,r.pendingProps,r.type,void 0,We);break;case 11:r=cy(o,r,r.pendingProps,r.type.render,r.ref,We);break;case 5:Fd(r);default:gy(o,r),r=Ue=Kg(r,ir),r=py(o,r,ir)}i.memoizedProps=i.pendingProps,r===null?fu(i):Ue=r}function Ya(i,r,o,u){Vi=On=null,Fd(r),qa=null,Gl=0;var p=r.return;try{if(Fj(i,p,r,o,We)){xt=1,eu(i,ti(o,i.current)),Ue=null;return}}catch(_){if(p!==null)throw Ue=p,_;xt=1,eu(i,ti(o,i.current)),Ue=null;return}r.flags&32768?(Ye||u===1?i=!0:Ka||(We&536870912)!==0?i=!1:(Mr=i=!0,(u===2||u===9||u===3||u===6)&&(u=Ps.current,u!==null&&u.tag===13&&(u.flags|=16384))),Vy(r,i)):fu(r)}function fu(i){var r=i;do{if((r.flags&32768)!==0){Vy(r,Mr);return}i=r.return;var o=Kj(r.alternate,r,ir);if(o!==null){Ue=o;return}if(r=r.sibling,r!==null){Ue=r;return}Ue=r=i}while(r!==null);xt===0&&(xt=5)}function Vy(i,r){do{var o=$j(i.alternate,i);if(o!==null){o.flags&=32767,Ue=o;return}if(o=i.return,o!==null&&(o.flags|=32768,o.subtreeFlags=0,o.deletions=null),!r&&(i=i.sibling,i!==null)){Ue=i;return}Ue=i=o}while(i!==null);xt=6,Ue=null}function Yy(i,r,o,u,p,_,y,C,A){i.cancelPendingCommit=null;do mu();while(Ht!==0);if((it&6)!==0)throw Error(n(327));if(r!==null){if(r===i.current)throw Error(n(177));if(_=r.lanes|r.childLanes,_|=md,RC(i,o,_,y,C,A),i===dt&&(Ue=dt=null,We=0),Wa=r,qr=i,rr=o,wf=_,Cf=p,qy=u,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,ik(_c,function(){return Jy(),null})):(i.callbackNode=null,i.callbackPriority=0),u=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||u){u=T.T,T.T=null,p=F.p,F.p=2,y=it,it|=4;try{Wj(i,r,o)}finally{it=y,F.p=p,T.T=u}}Ht=1,Gy(),Qy(),Zy()}}function Gy(){if(Ht===1){Ht=0;var i=qr,r=Wa,o=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||o){o=T.T,T.T=null;var u=F.p;F.p=2;var p=it;it|=4;try{Ty(r,i);var _=Pf,y=Bg(i.containerInfo),C=_.focusedElem,A=_.selectionRange;if(y!==C&&C&&C.ownerDocument&&Mg(C.ownerDocument.documentElement,C)){if(A!==null&&cd(C)){var I=A.start,se=A.end;if(se===void 0&&(se=I),"selectionStart"in C)C.selectionStart=I,C.selectionEnd=Math.min(se,C.value.length);else{var re=C.ownerDocument||document,$=re&&re.defaultView||window;if($.getSelection){var X=$.getSelection(),be=C.textContent.length,Ee=Math.min(A.start,be),ut=A.end===void 0?Ee:Math.min(A.end,be);!X.extend&&Ee>ut&&(y=ut,ut=Ee,Ee=y);var q=Dg(C,Ee),B=Dg(C,ut);if(q&&B&&(X.rangeCount!==1||X.anchorNode!==q.node||X.anchorOffset!==q.offset||X.focusNode!==B.node||X.focusOffset!==B.offset)){var P=re.createRange();P.setStart(q.node,q.offset),X.removeAllRanges(),Ee>ut?(X.addRange(P),X.extend(B.node,B.offset)):(P.setEnd(B.node,B.offset),X.addRange(P))}}}}for(re=[],X=C;X=X.parentNode;)X.nodeType===1&&re.push({element:X,left:X.scrollLeft,top:X.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<re.length;C++){var ie=re[C];ie.element.scrollLeft=ie.left,ie.element.scrollTop=ie.top}}ku=!!zf,Pf=zf=null}finally{it=p,F.p=u,T.T=o}}i.current=r,Ht=2}}function Qy(){if(Ht===2){Ht=0;var i=qr,r=Wa,o=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||o){o=T.T,T.T=null;var u=F.p;F.p=2;var p=it;it|=4;try{Cy(i,r.alternate,r)}finally{it=p,F.p=u,T.T=o}}Ht=3}}function Zy(){if(Ht===4||Ht===3){Ht=0,wC();var i=qr,r=Wa,o=rr,u=qy;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Ht=5:(Ht=0,Wa=qr=null,Xy(i,i.pendingLanes));var p=i.pendingLanes;if(p===0&&(Lr=null),Kh(o),r=r.stateNode,Bs&&typeof Bs.onCommitFiberRoot=="function")try{Bs.onCommitFiberRoot(Al,r,void 0,(r.current.flags&128)===128)}catch{}if(u!==null){r=T.T,p=F.p,F.p=2,T.T=null;try{for(var _=i.onRecoverableError,y=0;y<u.length;y++){var C=u[y];_(C.value,{componentStack:C.stack})}}finally{T.T=r,F.p=p}}(rr&3)!==0&&mu(),ki(i),p=i.pendingLanes,(o&261930)!==0&&(p&42)!==0?i===jf?fo++:(fo=0,jf=i):fo=0,mo(0)}}function Xy(i,r){(i.pooledCacheLanes&=r)===0&&(r=i.pooledCache,r!=null&&(i.pooledCache=null,Vl(r)))}function mu(){return Gy(),Qy(),Zy(),Jy()}function Jy(){if(Ht!==5)return!1;var i=qr,r=wf;wf=0;var o=Kh(rr),u=T.T,p=F.p;try{F.p=32>o?32:o,T.T=null,o=Cf,Cf=null;var _=qr,y=rr;if(Ht=0,Wa=qr=null,rr=0,(it&6)!==0)throw Error(n(331));var C=it;if(it|=4,My(_.current),Ay(_,_.current,y,o),it=C,mo(0,!1),Bs&&typeof Bs.onPostCommitFiberRoot=="function")try{Bs.onPostCommitFiberRoot(Al,_)}catch{}return!0}finally{F.p=p,T.T=u,Xy(i,r)}}function eb(i,r,o){r=ti(o,r),r=sf(i.stateNode,r,2),i=Or(i,r,2),i!==null&&(Dl(i,2),ki(i))}function lt(i,r,o){if(i.tag===3)eb(i,i,o);else for(;r!==null;){if(r.tag===3){eb(r,i,o);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Lr===null||!Lr.has(u))){i=ti(o,i),o=ty(2),u=Or(r,o,2),u!==null&&(sy(o,u,r,i),Dl(u,2),ki(u));break}}r=r.return}}function Ef(i,r,o){var u=i.pingCache;if(u===null){u=i.pingCache=new Gj;var p=new Set;u.set(r,p)}else p=u.get(r),p===void 0&&(p=new Set,u.set(r,p));p.has(o)||(bf=!0,p.add(o),i=ek.bind(null,i,r,o),r.then(i,i))}function ek(i,r,o){var u=i.pingCache;u!==null&&u.delete(r),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,dt===i&&(We&o)===o&&(xt===4||xt===3&&(We&62914560)===We&&300>Ms()-ou?(it&2)===0&&Va(i,0):Sf|=o,$a===We&&($a=0)),ki(i)}function tb(i,r){r===0&&(r=G_()),i=Nn(i,r),i!==null&&(Dl(i,r),ki(i))}function tk(i){var r=i.memoizedState,o=0;r!==null&&(o=r.retryLane),tb(i,o)}function sk(i,r){var o=0;switch(i.tag){case 31:case 13:var u=i.stateNode,p=i.memoizedState;p!==null&&(o=p.retryLane);break;case 19:u=i.stateNode;break;case 22:u=i.stateNode._retryCache;break;default:throw Error(n(314))}u!==null&&u.delete(r),tb(i,o)}function ik(i,r){return Hh(i,r)}var pu=null,Ga=null,Tf=!1,_u=!1,Of=!1,Pr=0;function ki(i){i!==Ga&&i.next===null&&(Ga===null?pu=Ga=i:Ga=Ga.next=i),_u=!0,Tf||(Tf=!0,nk())}function mo(i,r){if(!Of&&_u){Of=!0;do for(var o=!1,u=pu;u!==null;){if(i!==0){var p=u.pendingLanes;if(p===0)var _=0;else{var y=u.suspendedLanes,C=u.pingedLanes;_=(1<<31-Ls(42|i)+1)-1,_&=p&~(y&~C),_=_&201326741?_&201326741|1:_?_|2:0}_!==0&&(o=!0,nb(u,_))}else _=We,_=bc(u,u===dt?_:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(_&3)===0||Rl(u,_)||(o=!0,nb(u,_));u=u.next}while(o);Of=!1}}function rk(){sb()}function sb(){_u=Tf=!1;var i=0;Pr!==0&&pk()&&(i=Pr);for(var r=Ms(),o=null,u=pu;u!==null;){var p=u.next,_=ib(u,r);_===0?(u.next=null,o===null?pu=p:o.next=p,p===null&&(Ga=o)):(o=u,(i!==0||(_&3)!==0)&&(_u=!0)),u=p}Ht!==0&&Ht!==5||mo(i),Pr!==0&&(Pr=0)}function ib(i,r){for(var o=i.suspendedLanes,u=i.pingedLanes,p=i.expirationTimes,_=i.pendingLanes&-62914561;0<_;){var y=31-Ls(_),C=1<<y,A=p[y];A===-1?((C&o)===0||(C&u)!==0)&&(p[y]=AC(C,r)):A<=r&&(i.expiredLanes|=C),_&=~C}if(r=dt,o=We,o=bc(i,i===r?o:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),u=i.callbackNode,o===0||i===r&&(at===2||at===9)||i.cancelPendingCommit!==null)return u!==null&&u!==null&&Fh(u),i.callbackNode=null,i.callbackPriority=0;if((o&3)===0||Rl(i,o)){if(r=o&-o,r===i.callbackPriority)return r;switch(u!==null&&Fh(u),Kh(o)){case 2:case 8:o=V_;break;case 32:o=_c;break;case 268435456:o=Y_;break;default:o=_c}return u=rb.bind(null,i),o=Hh(o,u),i.callbackPriority=r,i.callbackNode=o,r}return u!==null&&u!==null&&Fh(u),i.callbackPriority=2,i.callbackNode=null,2}function rb(i,r){if(Ht!==0&&Ht!==5)return i.callbackNode=null,i.callbackPriority=0,null;var o=i.callbackNode;if(mu()&&i.callbackNode!==o)return null;var u=We;return u=bc(i,i===dt?u:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),u===0?null:(Py(i,u,r),ib(i,Ms()),i.callbackNode!=null&&i.callbackNode===o?rb.bind(null,i):null)}function nb(i,r){if(mu())return null;Py(i,r,!0)}function nk(){gk(function(){(it&6)!==0?Hh(W_,rk):sb()})}function Af(){if(Pr===0){var i=Ma;i===0&&(i=gc,gc<<=1,(gc&261888)===0&&(gc=256)),Pr=i}return Pr}function ab(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Cc(""+i)}function lb(i,r){var o=r.ownerDocument.createElement("input");return o.name=r.name,o.value=r.value,i.id&&o.setAttribute("form",i.id),r.parentNode.insertBefore(o,r),i=new FormData(i),o.parentNode.removeChild(o),i}function ak(i,r,o,u,p){if(r==="submit"&&o&&o.stateNode===p){var _=ab((p[xs]||null).action),y=u.submitter;y&&(r=(r=y[xs]||null)?ab(r.formAction):y.getAttribute("formAction"),r!==null&&(_=r,y=null));var C=new Ec("action","action",null,u,p);i.push({event:C,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(Pr!==0){var A=y?lb(p,y):new FormData(p);Qd(o,{pending:!0,data:A,method:p.method,action:_},null,A)}}else typeof _=="function"&&(C.preventDefault(),A=y?lb(p,y):new FormData(p),Qd(o,{pending:!0,data:A,method:p.method,action:_},_,A))},currentTarget:p}]})}}for(var Rf=0;Rf<fd.length;Rf++){var Df=fd[Rf],lk=Df.toLowerCase(),ok=Df[0].toUpperCase()+Df.slice(1);pi(lk,"on"+ok)}pi(zg,"onAnimationEnd"),pi(Pg,"onAnimationIteration"),pi(Hg,"onAnimationStart"),pi("dblclick","onDoubleClick"),pi("focusin","onFocus"),pi("focusout","onBlur"),pi(Cj,"onTransitionRun"),pi(jj,"onTransitionStart"),pi(kj,"onTransitionCancel"),pi(Fg,"onTransitionEnd"),ba("onMouseEnter",["mouseout","mouseover"]),ba("onMouseLeave",["mouseout","mouseover"]),ba("onPointerEnter",["pointerout","pointerover"]),ba("onPointerLeave",["pointerout","pointerover"]),wn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),wn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),wn("onBeforeInput",["compositionend","keypress","textInput","paste"]),wn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),wn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),wn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var po="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),ck=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(po));function ob(i,r){r=(r&4)!==0;for(var o=0;o<i.length;o++){var u=i[o],p=u.event;u=u.listeners;e:{var _=void 0;if(r)for(var y=u.length-1;0<=y;y--){var C=u[y],A=C.instance,I=C.currentTarget;if(C=C.listener,A!==_&&p.isPropagationStopped())break e;_=C,p.currentTarget=I;try{_(p)}catch(se){Ac(se)}p.currentTarget=null,_=A}else for(y=0;y<u.length;y++){if(C=u[y],A=C.instance,I=C.currentTarget,C=C.listener,A!==_&&p.isPropagationStopped())break e;_=C,p.currentTarget=I;try{_(p)}catch(se){Ac(se)}p.currentTarget=null,_=A}}}}function Ke(i,r){var o=r[$h];o===void 0&&(o=r[$h]=new Set);var u=i+"__bubble";o.has(u)||(cb(r,i,2,!1),o.add(u))}function Mf(i,r,o){var u=0;r&&(u|=4),cb(o,i,u,r)}var gu="_reactListening"+Math.random().toString(36).slice(2);function Bf(i){if(!i[gu]){i[gu]=!0,sg.forEach(function(o){o!=="selectionchange"&&(ck.has(o)||Mf(o,!1,i),Mf(o,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[gu]||(r[gu]=!0,Mf("selectionchange",!1,r))}}function cb(i,r,o,u){switch(zb(r)){case 2:var p=qk;break;case 8:p=zk;break;default:p=Qf}o=p.bind(null,r,o,i),p=void 0,!ed||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),u?p!==void 0?i.addEventListener(r,o,{capture:!0,passive:p}):i.addEventListener(r,o,!0):p!==void 0?i.addEventListener(r,o,{passive:p}):i.addEventListener(r,o,!1)}function Lf(i,r,o,u,p){var _=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var y=u.tag;if(y===3||y===4){var C=u.stateNode.containerInfo;if(C===p)break;if(y===4)for(y=u.return;y!==null;){var A=y.tag;if((A===3||A===4)&&y.stateNode.containerInfo===p)return;y=y.return}for(;C!==null;){if(y=ga(C),y===null)return;if(A=y.tag,A===5||A===6||A===26||A===27){u=_=y;continue e}C=C.parentNode}}u=u.return}mg(function(){var I=_,se=Xh(o),re=[];e:{var $=Ig.get(i);if($!==void 0){var X=Ec,be=i;switch(i){case"keypress":if(kc(o)===0)break e;case"keydown":case"keyup":X=sj;break;case"focusin":be="focus",X=rd;break;case"focusout":be="blur",X=rd;break;case"beforeblur":case"afterblur":X=rd;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":X=gg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":X=KC;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":X=nj;break;case zg:case Pg:case Hg:X=VC;break;case Fg:X=lj;break;case"scroll":case"scrollend":X=IC;break;case"wheel":X=cj;break;case"copy":case"cut":case"paste":X=GC;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":X=yg;break;case"toggle":case"beforetoggle":X=hj}var Ee=(r&4)!==0,ut=!Ee&&(i==="scroll"||i==="scrollend"),q=Ee?$!==null?$+"Capture":null:$;Ee=[];for(var B=I,P;B!==null;){var ie=B;if(P=ie.stateNode,ie=ie.tag,ie!==5&&ie!==26&&ie!==27||P===null||q===null||(ie=Ll(B,q),ie!=null&&Ee.push(_o(B,ie,P))),ut)break;B=B.return}0<Ee.length&&($=new X($,be,null,o,se),re.push({event:$,listeners:Ee}))}}if((r&7)===0){e:{if($=i==="mouseover"||i==="pointerover",X=i==="mouseout"||i==="pointerout",$&&o!==Zh&&(be=o.relatedTarget||o.fromElement)&&(ga(be)||be[_a]))break e;if((X||$)&&($=se.window===se?se:($=se.ownerDocument)?$.defaultView||$.parentWindow:window,X?(be=o.relatedTarget||o.toElement,X=I,be=be?ga(be):null,be!==null&&(ut=c(be),Ee=be.tag,be!==ut||Ee!==5&&Ee!==27&&Ee!==6)&&(be=null)):(X=null,be=I),X!==be)){if(Ee=gg,ie="onMouseLeave",q="onMouseEnter",B="mouse",(i==="pointerout"||i==="pointerover")&&(Ee=yg,ie="onPointerLeave",q="onPointerEnter",B="pointer"),ut=X==null?$:Bl(X),P=be==null?$:Bl(be),$=new Ee(ie,B+"leave",X,o,se),$.target=ut,$.relatedTarget=P,ie=null,ga(se)===I&&(Ee=new Ee(q,B+"enter",be,o,se),Ee.target=P,Ee.relatedTarget=ut,ie=Ee),ut=ie,X&&be)t:{for(Ee=uk,q=X,B=be,P=0,ie=q;ie;ie=Ee(ie))P++;ie=0;for(var je=B;je;je=Ee(je))ie++;for(;0<P-ie;)q=Ee(q),P--;for(;0<ie-P;)B=Ee(B),ie--;for(;P--;){if(q===B||B!==null&&q===B.alternate){Ee=q;break t}q=Ee(q),B=Ee(B)}Ee=null}else Ee=null;X!==null&&ub(re,$,X,Ee,!1),be!==null&&ut!==null&&ub(re,ut,be,Ee,!0)}}e:{if($=I?Bl(I):window,X=$.nodeName&&$.nodeName.toLowerCase(),X==="select"||X==="input"&&$.type==="file")var tt=Ng;else if(jg($))if(Eg)tt=Sj;else{tt=yj;var we=vj}else X=$.nodeName,!X||X.toLowerCase()!=="input"||$.type!=="checkbox"&&$.type!=="radio"?I&&Qh(I.elementType)&&(tt=Ng):tt=bj;if(tt&&(tt=tt(i,I))){kg(re,tt,o,se);break e}we&&we(i,$,I),i==="focusout"&&I&&$.type==="number"&&I.memoizedProps.value!=null&&Gh($,"number",$.value)}switch(we=I?Bl(I):window,i){case"focusin":(jg(we)||we.contentEditable==="true")&&(ka=we,ud=I,Kl=null);break;case"focusout":Kl=ud=ka=null;break;case"mousedown":hd=!0;break;case"contextmenu":case"mouseup":case"dragend":hd=!1,Lg(re,o,se);break;case"selectionchange":if(wj)break;case"keydown":case"keyup":Lg(re,o,se)}var ze;if(ad)e:{switch(i){case"compositionstart":var Ve="onCompositionStart";break e;case"compositionend":Ve="onCompositionEnd";break e;case"compositionupdate":Ve="onCompositionUpdate";break e}Ve=void 0}else ja?wg(i,o)&&(Ve="onCompositionEnd"):i==="keydown"&&o.keyCode===229&&(Ve="onCompositionStart");Ve&&(bg&&o.locale!=="ko"&&(ja||Ve!=="onCompositionStart"?Ve==="onCompositionEnd"&&ja&&(ze=pg()):(wr=se,td="value"in wr?wr.value:wr.textContent,ja=!0)),we=vu(I,Ve),0<we.length&&(Ve=new vg(Ve,i,null,o,se),re.push({event:Ve,listeners:we}),ze?Ve.data=ze:(ze=Cg(o),ze!==null&&(Ve.data=ze)))),(ze=fj?mj(i,o):pj(i,o))&&(Ve=vu(I,"onBeforeInput"),0<Ve.length&&(we=new vg("onBeforeInput","beforeinput",null,o,se),re.push({event:we,listeners:Ve}),we.data=ze)),ak(re,i,I,o,se)}ob(re,r)})}function _o(i,r,o){return{instance:i,listener:r,currentTarget:o}}function vu(i,r){for(var o=r+"Capture",u=[];i!==null;){var p=i,_=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||_===null||(p=Ll(i,o),p!=null&&u.unshift(_o(i,p,_)),p=Ll(i,r),p!=null&&u.push(_o(i,p,_))),i.tag===3)return u;i=i.return}return[]}function uk(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function ub(i,r,o,u,p){for(var _=r._reactName,y=[];o!==null&&o!==u;){var C=o,A=C.alternate,I=C.stateNode;if(C=C.tag,A!==null&&A===u)break;C!==5&&C!==26&&C!==27||I===null||(A=I,p?(I=Ll(o,_),I!=null&&y.unshift(_o(o,I,A))):p||(I=Ll(o,_),I!=null&&y.push(_o(o,I,A)))),o=o.return}y.length!==0&&i.push({event:r,listeners:y})}var hk=/\r\n?/g,dk=/\u0000|\uFFFD/g;function hb(i){return(typeof i=="string"?i:""+i).replace(hk,`
50
+ `).replace(dk,"")}function db(i,r){return r=hb(r),hb(i)===r}function ct(i,r,o,u,p,_){switch(o){case"children":typeof u=="string"?r==="body"||r==="textarea"&&u===""||xa(i,u):(typeof u=="number"||typeof u=="bigint")&&r!=="body"&&xa(i,""+u);break;case"className":xc(i,"class",u);break;case"tabIndex":xc(i,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":xc(i,o,u);break;case"style":dg(i,u,_);break;case"data":if(r!=="object"){xc(i,"data",u);break}case"src":case"href":if(u===""&&(r!=="a"||o!=="href")){i.removeAttribute(o);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){i.removeAttribute(o);break}u=Cc(""+u),i.setAttribute(o,u);break;case"action":case"formAction":if(typeof u=="function"){i.setAttribute(o,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof _=="function"&&(o==="formAction"?(r!=="input"&&ct(i,r,"name",p.name,p,null),ct(i,r,"formEncType",p.formEncType,p,null),ct(i,r,"formMethod",p.formMethod,p,null),ct(i,r,"formTarget",p.formTarget,p,null)):(ct(i,r,"encType",p.encType,p,null),ct(i,r,"method",p.method,p,null),ct(i,r,"target",p.target,p,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){i.removeAttribute(o);break}u=Cc(""+u),i.setAttribute(o,u);break;case"onClick":u!=null&&(i.onclick=Ui);break;case"onScroll":u!=null&&Ke("scroll",i);break;case"onScrollEnd":u!=null&&Ke("scrollend",i);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(n(61));if(o=u.__html,o!=null){if(p.children!=null)throw Error(n(60));i.innerHTML=o}}break;case"multiple":i.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":i.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){i.removeAttribute("xlink:href");break}o=Cc(""+u),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?i.setAttribute(o,""+u):i.removeAttribute(o);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":u&&typeof u!="function"&&typeof u!="symbol"?i.setAttribute(o,""):i.removeAttribute(o);break;case"capture":case"download":u===!0?i.setAttribute(o,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?i.setAttribute(o,u):i.removeAttribute(o);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?i.setAttribute(o,u):i.removeAttribute(o);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?i.removeAttribute(o):i.setAttribute(o,u);break;case"popover":Ke("beforetoggle",i),Ke("toggle",i),Sc(i,"popover",u);break;case"xlinkActuate":Ii(i,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":Ii(i,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":Ii(i,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":Ii(i,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":Ii(i,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":Ii(i,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":Ii(i,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":Ii(i,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":Ii(i,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Sc(i,"is",u);break;case"innerText":case"textContent":break;default:(!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(o=HC.get(o)||o,Sc(i,o,u))}}function qf(i,r,o,u,p,_){switch(o){case"style":dg(i,u,_);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(n(61));if(o=u.__html,o!=null){if(p.children!=null)throw Error(n(60));i.innerHTML=o}}break;case"children":typeof u=="string"?xa(i,u):(typeof u=="number"||typeof u=="bigint")&&xa(i,""+u);break;case"onScroll":u!=null&&Ke("scroll",i);break;case"onScrollEnd":u!=null&&Ke("scrollend",i);break;case"onClick":u!=null&&(i.onclick=Ui);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ig.hasOwnProperty(o))e:{if(o[0]==="o"&&o[1]==="n"&&(p=o.endsWith("Capture"),r=o.slice(2,p?o.length-7:void 0),_=i[xs]||null,_=_!=null?_[o]:null,typeof _=="function"&&i.removeEventListener(r,_,p),typeof u=="function")){typeof _!="function"&&_!==null&&(o in i?i[o]=null:i.hasAttribute(o)&&i.removeAttribute(o)),i.addEventListener(r,u,p);break e}o in i?i[o]=u:u===!0?i.setAttribute(o,""):Sc(i,o,u)}}}function ls(i,r,o){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ke("error",i),Ke("load",i);var u=!1,p=!1,_;for(_ in o)if(o.hasOwnProperty(_)){var y=o[_];if(y!=null)switch(_){case"src":u=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(n(137,r));default:ct(i,r,_,y,o,null)}}p&&ct(i,r,"srcSet",o.srcSet,o,null),u&&ct(i,r,"src",o.src,o,null);return;case"input":Ke("invalid",i);var C=_=y=p=null,A=null,I=null;for(u in o)if(o.hasOwnProperty(u)){var se=o[u];if(se!=null)switch(u){case"name":p=se;break;case"type":y=se;break;case"checked":A=se;break;case"defaultChecked":I=se;break;case"value":_=se;break;case"defaultValue":C=se;break;case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(n(137,r));break;default:ct(i,r,u,se,o,null)}}og(i,_,C,A,I,y,p,!1);return;case"select":Ke("invalid",i),u=y=_=null;for(p in o)if(o.hasOwnProperty(p)&&(C=o[p],C!=null))switch(p){case"value":_=C;break;case"defaultValue":y=C;break;case"multiple":u=C;default:ct(i,r,p,C,o,null)}r=_,o=y,i.multiple=!!u,r!=null?Sa(i,!!u,r,!1):o!=null&&Sa(i,!!u,o,!0);return;case"textarea":Ke("invalid",i),_=p=u=null;for(y in o)if(o.hasOwnProperty(y)&&(C=o[y],C!=null))switch(y){case"value":u=C;break;case"defaultValue":p=C;break;case"children":_=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(n(91));break;default:ct(i,r,y,C,o,null)}ug(i,u,p,_);return;case"option":for(A in o)if(o.hasOwnProperty(A)&&(u=o[A],u!=null))switch(A){case"selected":i.selected=u&&typeof u!="function"&&typeof u!="symbol";break;default:ct(i,r,A,u,o,null)}return;case"dialog":Ke("beforetoggle",i),Ke("toggle",i),Ke("cancel",i),Ke("close",i);break;case"iframe":case"object":Ke("load",i);break;case"video":case"audio":for(u=0;u<po.length;u++)Ke(po[u],i);break;case"image":Ke("error",i),Ke("load",i);break;case"details":Ke("toggle",i);break;case"embed":case"source":case"link":Ke("error",i),Ke("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(I in o)if(o.hasOwnProperty(I)&&(u=o[I],u!=null))switch(I){case"children":case"dangerouslySetInnerHTML":throw Error(n(137,r));default:ct(i,r,I,u,o,null)}return;default:if(Qh(r)){for(se in o)o.hasOwnProperty(se)&&(u=o[se],u!==void 0&&qf(i,r,se,u,o,void 0));return}}for(C in o)o.hasOwnProperty(C)&&(u=o[C],u!=null&&ct(i,r,C,u,o,null))}function fk(i,r,o,u){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var p=null,_=null,y=null,C=null,A=null,I=null,se=null;for(X in o){var re=o[X];if(o.hasOwnProperty(X)&&re!=null)switch(X){case"checked":break;case"value":break;case"defaultValue":A=re;default:u.hasOwnProperty(X)||ct(i,r,X,null,u,re)}}for(var $ in u){var X=u[$];if(re=o[$],u.hasOwnProperty($)&&(X!=null||re!=null))switch($){case"type":_=X;break;case"name":p=X;break;case"checked":I=X;break;case"defaultChecked":se=X;break;case"value":y=X;break;case"defaultValue":C=X;break;case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(n(137,r));break;default:X!==re&&ct(i,r,$,X,u,re)}}Yh(i,y,C,A,I,se,_,p);return;case"select":X=y=C=$=null;for(_ in o)if(A=o[_],o.hasOwnProperty(_)&&A!=null)switch(_){case"value":break;case"multiple":X=A;default:u.hasOwnProperty(_)||ct(i,r,_,null,u,A)}for(p in u)if(_=u[p],A=o[p],u.hasOwnProperty(p)&&(_!=null||A!=null))switch(p){case"value":$=_;break;case"defaultValue":C=_;break;case"multiple":y=_;default:_!==A&&ct(i,r,p,_,u,A)}r=C,o=y,u=X,$!=null?Sa(i,!!o,$,!1):!!u!=!!o&&(r!=null?Sa(i,!!o,r,!0):Sa(i,!!o,o?[]:"",!1));return;case"textarea":X=$=null;for(C in o)if(p=o[C],o.hasOwnProperty(C)&&p!=null&&!u.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:ct(i,r,C,null,u,p)}for(y in u)if(p=u[y],_=o[y],u.hasOwnProperty(y)&&(p!=null||_!=null))switch(y){case"value":$=p;break;case"defaultValue":X=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(n(91));break;default:p!==_&&ct(i,r,y,p,u,_)}cg(i,$,X);return;case"option":for(var be in o)if($=o[be],o.hasOwnProperty(be)&&$!=null&&!u.hasOwnProperty(be))switch(be){case"selected":i.selected=!1;break;default:ct(i,r,be,null,u,$)}for(A in u)if($=u[A],X=o[A],u.hasOwnProperty(A)&&$!==X&&($!=null||X!=null))switch(A){case"selected":i.selected=$&&typeof $!="function"&&typeof $!="symbol";break;default:ct(i,r,A,$,u,X)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ee in o)$=o[Ee],o.hasOwnProperty(Ee)&&$!=null&&!u.hasOwnProperty(Ee)&&ct(i,r,Ee,null,u,$);for(I in u)if($=u[I],X=o[I],u.hasOwnProperty(I)&&$!==X&&($!=null||X!=null))switch(I){case"children":case"dangerouslySetInnerHTML":if($!=null)throw Error(n(137,r));break;default:ct(i,r,I,$,u,X)}return;default:if(Qh(r)){for(var ut in o)$=o[ut],o.hasOwnProperty(ut)&&$!==void 0&&!u.hasOwnProperty(ut)&&qf(i,r,ut,void 0,u,$);for(se in u)$=u[se],X=o[se],!u.hasOwnProperty(se)||$===X||$===void 0&&X===void 0||qf(i,r,se,$,u,X);return}}for(var q in o)$=o[q],o.hasOwnProperty(q)&&$!=null&&!u.hasOwnProperty(q)&&ct(i,r,q,null,u,$);for(re in u)$=u[re],X=o[re],!u.hasOwnProperty(re)||$===X||$==null&&X==null||ct(i,r,re,$,u,X)}function fb(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function mk(){if(typeof performance.getEntriesByType=="function"){for(var i=0,r=0,o=performance.getEntriesByType("resource"),u=0;u<o.length;u++){var p=o[u],_=p.transferSize,y=p.initiatorType,C=p.duration;if(_&&C&&fb(y)){for(y=0,C=p.responseEnd,u+=1;u<o.length;u++){var A=o[u],I=A.startTime;if(I>C)break;var se=A.transferSize,re=A.initiatorType;se&&fb(re)&&(A=A.responseEnd,y+=se*(A<C?1:(C-I)/(A-I)))}if(--u,r+=8*(_+y)/(p.duration/1e3),i++,10<i)break}}if(0<i)return r/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var zf=null,Pf=null;function yu(i){return i.nodeType===9?i:i.ownerDocument}function mb(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function pb(i,r){if(i===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&r==="foreignObject"?0:i}function Hf(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Ff=null;function pk(){var i=window.event;return i&&i.type==="popstate"?i===Ff?!1:(Ff=i,!0):(Ff=null,!1)}var _b=typeof setTimeout=="function"?setTimeout:void 0,_k=typeof clearTimeout=="function"?clearTimeout:void 0,gb=typeof Promise=="function"?Promise:void 0,gk=typeof queueMicrotask=="function"?queueMicrotask:typeof gb<"u"?function(i){return gb.resolve(null).then(i).catch(vk)}:_b;function vk(i){setTimeout(function(){throw i})}function Hr(i){return i==="head"}function vb(i,r){var o=r,u=0;do{var p=o.nextSibling;if(i.removeChild(o),p&&p.nodeType===8)if(o=p.data,o==="/$"||o==="/&"){if(u===0){i.removeChild(p),Ja(r);return}u--}else if(o==="$"||o==="$?"||o==="$~"||o==="$!"||o==="&")u++;else if(o==="html")go(i.ownerDocument.documentElement);else if(o==="head"){o=i.ownerDocument.head,go(o);for(var _=o.firstChild;_;){var y=_.nextSibling,C=_.nodeName;_[Ml]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&_.rel.toLowerCase()==="stylesheet"||o.removeChild(_),_=y}}else o==="body"&&go(i.ownerDocument.body);o=p}while(o);Ja(r)}function yb(i,r){var o=i;i=0;do{var u=o.nextSibling;if(o.nodeType===1?r?(o._stashedDisplay=o.style.display,o.style.display="none"):(o.style.display=o._stashedDisplay||"",o.getAttribute("style")===""&&o.removeAttribute("style")):o.nodeType===3&&(r?(o._stashedText=o.nodeValue,o.nodeValue=""):o.nodeValue=o._stashedText||""),u&&u.nodeType===8)if(o=u.data,o==="/$"){if(i===0)break;i--}else o!=="$"&&o!=="$?"&&o!=="$~"&&o!=="$!"||i++;o=u}while(o)}function If(i){var r=i.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var o=r;switch(r=r.nextSibling,o.nodeName){case"HTML":case"HEAD":case"BODY":If(o),Wh(o);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(o.rel.toLowerCase()==="stylesheet")continue}i.removeChild(o)}}function yk(i,r,o,u){for(;i.nodeType===1;){var p=o;if(i.nodeName.toLowerCase()!==r.toLowerCase()){if(!u&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(u){if(!i[Ml])switch(r){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(_=i.getAttribute("rel"),_==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(_!==p.rel||i.getAttribute("href")!==(p.href==null||p.href===""?null:p.href)||i.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin)||i.getAttribute("title")!==(p.title==null?null:p.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(_=i.getAttribute("src"),(_!==(p.src==null?null:p.src)||i.getAttribute("type")!==(p.type==null?null:p.type)||i.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&_&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(r==="input"&&i.type==="hidden"){var _=p.name==null?null:""+p.name;if(p.type==="hidden"&&i.getAttribute("name")===_)return i}else return i;if(i=ai(i.nextSibling),i===null)break}return null}function bk(i,r,o){if(r==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!o||(i=ai(i.nextSibling),i===null))return null;return i}function bb(i,r){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!r||(i=ai(i.nextSibling),i===null))return null;return i}function Uf(i){return i.data==="$?"||i.data==="$~"}function Kf(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function Sk(i,r){var o=i.ownerDocument;if(i.data==="$~")i._reactRetry=r;else if(i.data!=="$?"||o.readyState!=="loading")r();else{var u=function(){r(),o.removeEventListener("DOMContentLoaded",u)};o.addEventListener("DOMContentLoaded",u),i._reactRetry=u}}function ai(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return i}var $f=null;function Sb(i){i=i.nextSibling;for(var r=0;i;){if(i.nodeType===8){var o=i.data;if(o==="/$"||o==="/&"){if(r===0)return ai(i.nextSibling);r--}else o!=="$"&&o!=="$!"&&o!=="$?"&&o!=="$~"&&o!=="&"||r++}i=i.nextSibling}return null}function xb(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var o=i.data;if(o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"){if(r===0)return i;r--}else o!=="/$"&&o!=="/&"||r++}i=i.previousSibling}return null}function wb(i,r,o){switch(r=yu(o),i){case"html":if(i=r.documentElement,!i)throw Error(n(452));return i;case"head":if(i=r.head,!i)throw Error(n(453));return i;case"body":if(i=r.body,!i)throw Error(n(454));return i;default:throw Error(n(451))}}function go(i){for(var r=i.attributes;r.length;)i.removeAttributeNode(r[0]);Wh(i)}var li=new Map,Cb=new Set;function bu(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var nr=F.d;F.d={f:xk,r:wk,D:Ck,C:jk,L:kk,m:Nk,X:Tk,S:Ek,M:Ok};function xk(){var i=nr.f(),r=hu();return i||r}function wk(i){var r=va(i);r!==null&&r.tag===5&&r.type==="form"?Fv(r):nr.r(i)}var Qa=typeof document>"u"?null:document;function jb(i,r,o){var u=Qa;if(u&&typeof r=="string"&&r){var p=Js(r);p='link[rel="'+i+'"][href="'+p+'"]',typeof o=="string"&&(p+='[crossorigin="'+o+'"]'),Cb.has(p)||(Cb.add(p),i={rel:i,crossOrigin:o,href:r},u.querySelector(p)===null&&(r=u.createElement("link"),ls(r,"link",i),Yt(r),u.head.appendChild(r)))}}function Ck(i){nr.D(i),jb("dns-prefetch",i,null)}function jk(i,r){nr.C(i,r),jb("preconnect",i,r)}function kk(i,r,o){nr.L(i,r,o);var u=Qa;if(u&&i&&r){var p='link[rel="preload"][as="'+Js(r)+'"]';r==="image"&&o&&o.imageSrcSet?(p+='[imagesrcset="'+Js(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(p+='[imagesizes="'+Js(o.imageSizes)+'"]')):p+='[href="'+Js(i)+'"]';var _=p;switch(r){case"style":_=Za(i);break;case"script":_=Xa(i)}li.has(_)||(i=v({rel:"preload",href:r==="image"&&o&&o.imageSrcSet?void 0:i,as:r},o),li.set(_,i),u.querySelector(p)!==null||r==="style"&&u.querySelector(vo(_))||r==="script"&&u.querySelector(yo(_))||(r=u.createElement("link"),ls(r,"link",i),Yt(r),u.head.appendChild(r)))}}function Nk(i,r){nr.m(i,r);var o=Qa;if(o&&i){var u=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+Js(u)+'"][href="'+Js(i)+'"]',_=p;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":_=Xa(i)}if(!li.has(_)&&(i=v({rel:"modulepreload",href:i},r),li.set(_,i),o.querySelector(p)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(yo(_)))return}u=o.createElement("link"),ls(u,"link",i),Yt(u),o.head.appendChild(u)}}}function Ek(i,r,o){nr.S(i,r,o);var u=Qa;if(u&&i){var p=ya(u).hoistableStyles,_=Za(i);r=r||"default";var y=p.get(_);if(!y){var C={loading:0,preload:null};if(y=u.querySelector(vo(_)))C.loading=5;else{i=v({rel:"stylesheet",href:i,"data-precedence":r},o),(o=li.get(_))&&Wf(i,o);var A=y=u.createElement("link");Yt(A),ls(A,"link",i),A._p=new Promise(function(I,se){A.onload=I,A.onerror=se}),A.addEventListener("load",function(){C.loading|=1}),A.addEventListener("error",function(){C.loading|=2}),C.loading|=4,Su(y,r,u)}y={type:"stylesheet",instance:y,count:1,state:C},p.set(_,y)}}}function Tk(i,r){nr.X(i,r);var o=Qa;if(o&&i){var u=ya(o).hoistableScripts,p=Xa(i),_=u.get(p);_||(_=o.querySelector(yo(p)),_||(i=v({src:i,async:!0},r),(r=li.get(p))&&Vf(i,r),_=o.createElement("script"),Yt(_),ls(_,"link",i),o.head.appendChild(_)),_={type:"script",instance:_,count:1,state:null},u.set(p,_))}}function Ok(i,r){nr.M(i,r);var o=Qa;if(o&&i){var u=ya(o).hoistableScripts,p=Xa(i),_=u.get(p);_||(_=o.querySelector(yo(p)),_||(i=v({src:i,async:!0,type:"module"},r),(r=li.get(p))&&Vf(i,r),_=o.createElement("script"),Yt(_),ls(_,"link",i),o.head.appendChild(_)),_={type:"script",instance:_,count:1,state:null},u.set(p,_))}}function kb(i,r,o,u){var p=(p=_e.current)?bu(p):null;if(!p)throw Error(n(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(r=Za(o.href),o=ya(p).hoistableStyles,u=o.get(r),u||(u={type:"style",instance:null,count:0,state:null},o.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=Za(o.href);var _=ya(p).hoistableStyles,y=_.get(i);if(y||(p=p.ownerDocument||p,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},_.set(i,y),(_=p.querySelector(vo(i)))&&!_._p&&(y.instance=_,y.state.loading=5),li.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},li.set(i,o),_||Ak(p,i,o,y.state))),r&&u===null)throw Error(n(528,""));return y}if(r&&u!==null)throw Error(n(529,""));return null;case"script":return r=o.async,o=o.src,typeof o=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Xa(o),o=ya(p).hoistableScripts,u=o.get(r),u||(u={type:"script",instance:null,count:0,state:null},o.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,i))}}function Za(i){return'href="'+Js(i)+'"'}function vo(i){return'link[rel="stylesheet"]['+i+"]"}function Nb(i){return v({},i,{"data-precedence":i.precedence,precedence:null})}function Ak(i,r,o,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),ls(r,"link",o),Yt(r),i.head.appendChild(r))}function Xa(i){return'[src="'+Js(i)+'"]'}function yo(i){return"script[async]"+i}function Eb(i,r,o){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+Js(o.href)+'"]');if(u)return r.instance=u,Yt(u),u;var p=v({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Yt(u),ls(u,"style",p),Su(u,o.precedence,i),r.instance=u;case"stylesheet":p=Za(o.href);var _=i.querySelector(vo(p));if(_)return r.state.loading|=4,r.instance=_,Yt(_),_;u=Nb(o),(p=li.get(p))&&Wf(u,p),_=(i.ownerDocument||i).createElement("link"),Yt(_);var y=_;return y._p=new Promise(function(C,A){y.onload=C,y.onerror=A}),ls(_,"link",u),r.state.loading|=4,Su(_,o.precedence,i),r.instance=_;case"script":return _=Xa(o.src),(p=i.querySelector(yo(_)))?(r.instance=p,Yt(p),p):(u=o,(p=li.get(_))&&(u=v({},o),Vf(u,p)),i=i.ownerDocument||i,p=i.createElement("script"),Yt(p),ls(p,"link",u),i.head.appendChild(p),r.instance=p);case"void":return null;default:throw Error(n(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,Su(u,o.precedence,i));return r.instance}function Su(i,r,o){for(var u=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=u.length?u[u.length-1]:null,_=p,y=0;y<u.length;y++){var C=u[y];if(C.dataset.precedence===r)_=C;else if(_!==p)break}_?_.parentNode.insertBefore(i,_.nextSibling):(r=o.nodeType===9?o.head:o,r.insertBefore(i,r.firstChild))}function Wf(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.title==null&&(i.title=r.title)}function Vf(i,r){i.crossOrigin==null&&(i.crossOrigin=r.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=r.referrerPolicy),i.integrity==null&&(i.integrity=r.integrity)}var xu=null;function Tb(i,r,o){if(xu===null){var u=new Map,p=xu=new Map;p.set(o,u)}else p=xu,u=p.get(o),u||(u=new Map,p.set(o,u));if(u.has(i))return u;for(u.set(i,null),o=o.getElementsByTagName(i),p=0;p<o.length;p++){var _=o[p];if(!(_[Ml]||_[is]||i==="link"&&_.getAttribute("rel")==="stylesheet")&&_.namespaceURI!=="http://www.w3.org/2000/svg"){var y=_.getAttribute(r)||"";y=i+y;var C=u.get(y);C?C.push(_):u.set(y,[_])}}return u}function Ob(i,r,o){i=i.ownerDocument||i,i.head.insertBefore(o,r==="title"?i.querySelector("head > title"):null)}function Rk(i,r,o){if(o===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return i=r.disabled,typeof r.precedence=="string"&&i==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function Ab(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function Dk(i,r,o,u){if(o.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var p=Za(u.href),_=r.querySelector(vo(p));if(_){r=_._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=wu.bind(i),r.then(i,i)),o.state.loading|=4,o.instance=_,Yt(_);return}_=r.ownerDocument||r,u=Nb(u),(p=li.get(p))&&Wf(u,p),_=_.createElement("link"),Yt(_);var y=_;y._p=new Promise(function(C,A){y.onload=C,y.onerror=A}),ls(_,"link",u),o.instance=_}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,r),(r=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=wu.bind(i),r.addEventListener("load",o),r.addEventListener("error",o))}}var Yf=0;function Mk(i,r){return i.stylesheets&&i.count===0&&ju(i,i.stylesheets),0<i.count||0<i.imgCount?function(o){var u=setTimeout(function(){if(i.stylesheets&&ju(i,i.stylesheets),i.unsuspend){var _=i.unsuspend;i.unsuspend=null,_()}},6e4+r);0<i.imgBytes&&Yf===0&&(Yf=62500*mk());var p=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&ju(i,i.stylesheets),i.unsuspend)){var _=i.unsuspend;i.unsuspend=null,_()}},(i.imgBytes>Yf?50:800)+r);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(p)}}:null}function wu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ju(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Cu=null;function ju(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Cu=new Map,r.forEach(Bk,i),Cu=null,wu.call(i))}function Bk(i,r){if(!(r.state.loading&4)){var o=Cu.get(i);if(o)var u=o.get(null);else{o=new Map,Cu.set(i,o);for(var p=i.querySelectorAll("link[data-precedence],style[data-precedence]"),_=0;_<p.length;_++){var y=p[_];(y.nodeName==="LINK"||y.getAttribute("media")!=="not all")&&(o.set(y.dataset.precedence,y),u=y)}u&&o.set(null,u)}p=r.instance,y=p.getAttribute("data-precedence"),_=o.get(y)||u,_===u&&o.set(null,p),o.set(y,p),this.count++,u=wu.bind(this),p.addEventListener("load",u),p.addEventListener("error",u),_?_.parentNode.insertBefore(p,_.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(p,i.firstChild)),r.state.loading|=4}}var bo={$$typeof:R,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function Lk(i,r,o,u,p,_,y,C,A){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ih(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ih(0),this.hiddenUpdates=Ih(null),this.identifierPrefix=u,this.onUncaughtError=p,this.onCaughtError=_,this.onRecoverableError=y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=A,this.incompleteTransitions=new Map}function Rb(i,r,o,u,p,_,y,C,A,I,se,re){return i=new Lk(i,r,o,y,A,I,se,re,C),r=1,_===!0&&(r|=24),_=zs(3,null,null,r),i.current=_,_.stateNode=i,r=kd(),r.refCount++,i.pooledCache=r,r.refCount++,_.memoizedState={element:u,isDehydrated:o,cache:r},Od(_),i}function Db(i){return i?(i=Ta,i):Ta}function Mb(i,r,o,u,p,_){p=Db(p),u.context===null?u.context=p:u.pendingContext=p,u=Tr(r),u.payload={element:o},_=_===void 0?null:_,_!==null&&(u.callback=_),o=Or(i,u,r),o!==null&&(Es(o,i,r),Zl(o,i,r))}function Bb(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var o=i.retryLane;i.retryLane=o!==0&&o<r?o:r}}function Gf(i,r){Bb(i,r),(i=i.alternate)&&Bb(i,r)}function Lb(i){if(i.tag===13||i.tag===31){var r=Nn(i,67108864);r!==null&&Es(r,i,67108864),Gf(i,67108864)}}function qb(i){if(i.tag===13||i.tag===31){var r=Us();r=Uh(r);var o=Nn(i,r);o!==null&&Es(o,i,r),Gf(i,r)}}var ku=!0;function qk(i,r,o,u){var p=T.T;T.T=null;var _=F.p;try{F.p=2,Qf(i,r,o,u)}finally{F.p=_,T.T=p}}function zk(i,r,o,u){var p=T.T;T.T=null;var _=F.p;try{F.p=8,Qf(i,r,o,u)}finally{F.p=_,T.T=p}}function Qf(i,r,o,u){if(ku){var p=Zf(u);if(p===null)Lf(i,r,u,Nu,o),Pb(i,u);else if(Hk(p,i,r,o,u))u.stopPropagation();else if(Pb(i,u),r&4&&-1<Pk.indexOf(i)){for(;p!==null;){var _=va(p);if(_!==null)switch(_.tag){case 3:if(_=_.stateNode,_.current.memoizedState.isDehydrated){var y=xn(_.pendingLanes);if(y!==0){var C=_;for(C.pendingLanes|=2,C.entangledLanes|=2;y;){var A=1<<31-Ls(y);C.entanglements[1]|=A,y&=~A}ki(_),(it&6)===0&&(cu=Ms()+500,mo(0))}}break;case 31:case 13:C=Nn(_,2),C!==null&&Es(C,_,2),hu(),Gf(_,2)}if(_=Zf(u),_===null&&Lf(i,r,u,Nu,o),_===p)break;p=_}p!==null&&u.stopPropagation()}else Lf(i,r,u,null,o)}}function Zf(i){return i=Xh(i),Xf(i)}var Nu=null;function Xf(i){if(Nu=null,i=ga(i),i!==null){var r=c(i);if(r===null)i=null;else{var o=r.tag;if(o===13){if(i=h(r),i!==null)return i;i=null}else if(o===31){if(i=d(r),i!==null)return i;i=null}else if(o===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null)}}return Nu=i,null}function zb(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(CC()){case W_:return 2;case V_:return 8;case _c:case jC:return 32;case Y_:return 268435456;default:return 32}default:return 32}}var Jf=!1,Fr=null,Ir=null,Ur=null,So=new Map,xo=new Map,Kr=[],Pk="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Pb(i,r){switch(i){case"focusin":case"focusout":Fr=null;break;case"dragenter":case"dragleave":Ir=null;break;case"mouseover":case"mouseout":Ur=null;break;case"pointerover":case"pointerout":So.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":xo.delete(r.pointerId)}}function wo(i,r,o,u,p,_){return i===null||i.nativeEvent!==_?(i={blockedOn:r,domEventName:o,eventSystemFlags:u,nativeEvent:_,targetContainers:[p]},r!==null&&(r=va(r),r!==null&&Lb(r)),i):(i.eventSystemFlags|=u,r=i.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),i)}function Hk(i,r,o,u,p){switch(r){case"focusin":return Fr=wo(Fr,i,r,o,u,p),!0;case"dragenter":return Ir=wo(Ir,i,r,o,u,p),!0;case"mouseover":return Ur=wo(Ur,i,r,o,u,p),!0;case"pointerover":var _=p.pointerId;return So.set(_,wo(So.get(_)||null,i,r,o,u,p)),!0;case"gotpointercapture":return _=p.pointerId,xo.set(_,wo(xo.get(_)||null,i,r,o,u,p)),!0}return!1}function Hb(i){var r=ga(i.target);if(r!==null){var o=c(r);if(o!==null){if(r=o.tag,r===13){if(r=h(o),r!==null){i.blockedOn=r,eg(i.priority,function(){qb(o)});return}}else if(r===31){if(r=d(o),r!==null){i.blockedOn=r,eg(i.priority,function(){qb(o)});return}}else if(r===3&&o.stateNode.current.memoizedState.isDehydrated){i.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Eu(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var o=Zf(i.nativeEvent);if(o===null){o=i.nativeEvent;var u=new o.constructor(o.type,o);Zh=u,o.target.dispatchEvent(u),Zh=null}else return r=va(o),r!==null&&Lb(r),i.blockedOn=o,!1;r.shift()}return!0}function Fb(i,r,o){Eu(i)&&o.delete(r)}function Fk(){Jf=!1,Fr!==null&&Eu(Fr)&&(Fr=null),Ir!==null&&Eu(Ir)&&(Ir=null),Ur!==null&&Eu(Ur)&&(Ur=null),So.forEach(Fb),xo.forEach(Fb)}function Tu(i,r){i.blockedOn===r&&(i.blockedOn=null,Jf||(Jf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Fk)))}var Ou=null;function Ib(i){Ou!==i&&(Ou=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Ou===i&&(Ou=null);for(var r=0;r<i.length;r+=3){var o=i[r],u=i[r+1],p=i[r+2];if(typeof u!="function"){if(Xf(u||o)===null)continue;break}var _=va(o);_!==null&&(i.splice(r,3),r-=3,Qd(_,{pending:!0,data:p,method:o.method,action:u},u,p))}}))}function Ja(i){function r(A){return Tu(A,i)}Fr!==null&&Tu(Fr,i),Ir!==null&&Tu(Ir,i),Ur!==null&&Tu(Ur,i),So.forEach(r),xo.forEach(r);for(var o=0;o<Kr.length;o++){var u=Kr[o];u.blockedOn===i&&(u.blockedOn=null)}for(;0<Kr.length&&(o=Kr[0],o.blockedOn===null);)Hb(o),o.blockedOn===null&&Kr.shift();if(o=(i.ownerDocument||i).$$reactFormReplay,o!=null)for(u=0;u<o.length;u+=3){var p=o[u],_=o[u+1],y=p[xs]||null;if(typeof _=="function")y||Ib(o);else if(y){var C=null;if(_&&_.hasAttribute("formAction")){if(p=_,y=_[xs]||null)C=y.formAction;else if(Xf(p)!==null)continue}else C=y.action;typeof C=="function"?o[u+1]=C:(o.splice(u,3),u-=3),Ib(o)}}}function Ub(){function i(_){_.canIntercept&&_.info==="react-transition"&&_.intercept({handler:function(){return new Promise(function(y){return p=y})},focusReset:"manual",scroll:"manual"})}function r(){p!==null&&(p(),p=null),u||setTimeout(o,20)}function o(){if(!u&&!navigation.transition){var _=navigation.currentEntry;_&&_.url!=null&&navigation.navigate(_.url,{state:_.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,p=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(o,100),function(){u=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),p!==null&&(p(),p=null)}}}function em(i){this._internalRoot=i}Au.prototype.render=em.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));var o=r.current,u=Us();Mb(o,u,i,r,null,null)},Au.prototype.unmount=em.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;Mb(i.current,2,null,i,null,null),hu(),r[_a]=null}};function Au(i){this._internalRoot=i}Au.prototype.unstable_scheduleHydration=function(i){if(i){var r=J_();i={blockedOn:null,target:i,priority:r};for(var o=0;o<Kr.length&&r!==0&&r<Kr[o].priority;o++);Kr.splice(o,0,i),o===0&&Hb(i)}};var Kb=t.version;if(Kb!=="19.2.8")throw Error(n(527,Kb,"19.2.8"));F.findDOMNode=function(i){var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=m(r),i=i!==null?g(i):null,i=i===null?null:i.stateNode,i};var Ik={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:T,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ru=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ru.isDisabled&&Ru.supportsFiber)try{Al=Ru.inject(Ik),Bs=Ru}catch{}}return jo.createRoot=function(i,r){if(!a(i))throw Error(n(299));var o=!1,u="",p=Zv,_=Xv,y=Jv;return r!=null&&(r.unstable_strictMode===!0&&(o=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onUncaughtError!==void 0&&(p=r.onUncaughtError),r.onCaughtError!==void 0&&(_=r.onCaughtError),r.onRecoverableError!==void 0&&(y=r.onRecoverableError)),r=Rb(i,1,!1,null,null,o,u,null,p,_,y,Ub),i[_a]=r.current,Bf(i),new em(r)},jo.hydrateRoot=function(i,r,o){if(!a(i))throw Error(n(299));var u=!1,p="",_=Zv,y=Xv,C=Jv,A=null;return o!=null&&(o.unstable_strictMode===!0&&(u=!0),o.identifierPrefix!==void 0&&(p=o.identifierPrefix),o.onUncaughtError!==void 0&&(_=o.onUncaughtError),o.onCaughtError!==void 0&&(y=o.onCaughtError),o.onRecoverableError!==void 0&&(C=o.onRecoverableError),o.formState!==void 0&&(A=o.formState)),r=Rb(i,1,!0,r,o??null,u,p,A,_,y,C,Ub),r.context=Db(null),o=r.current,u=Us(),u=Uh(u),p=Tr(u),p.callback=null,Or(o,p,u),o=u,r.current.lanes=o,Dl(r,o),ki(r),i[_a]=r.current,Bf(i),new Au(r)},jo.version="19.2.8",jo}var d0;function RN(){if(d0)return rm.exports;d0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),rm.exports=AN(),rm.exports}var DN=RN();const mr=["workspace","list"];function gn(e){return["project","listByWorkspace",e]}function gr(e){return["worktree","listByProject",e]}function sa(e,t){const s=["task","listByWorkspace",e];return t===void 0?s:[...s,t]}function ip(e){return["task","get",e]}function Jx(e,t){return["task","board",e,t]}function MN(e){return["task","settings",e]}function BN(e){return["worktree","branches",e]}function LN(e){return["worktree","hostOrigins",e]}function qN(e){return["project","detail",e]}function m_(e){return["worktree","detail",e]}function Hi(e,t){return["session","listByScope",e,t]}function ew(e,t){return["scripts","status",e,t]}function p_(e,t,s){return["files","listDir",e,t,s]}function Bu(e,t,s){return["files","read",e,t,s]}function zN(e,t,s){return["files","deletePreview",e,t,s]}function PN(e,t,s){return["changes","list",e,t,s]}function HN(e,t,s,n){return["changes","patch",e,t,s,n]}function FN(e,t){return["memory","list",e??"-",t??"-"]}function IN(e){return["memory","proposals",e]}function UN(e,t){return["memory","core",e??"-",t??"-"]}function KN(e,t,s){return["memory","search",e??"-",t??"-",s]}const $N=["memory","decisions"],WN=["memory","usage"],VN=["memory","settings"];function YN(e,t){return["usage","byProject",e,t]}function GN(e,t){return["usage","byWorktree",e,t]}function QN(e,t){return["usage","byProjectAndAgent",e,t]}function ZN(e,t){return["memory","playbooks",e??"-",t?"arquivados":"ativos"]}function uh(e){return["project","cloneJobs",e]}function XN(e){return["pr","getByWorktree",e]}function JN(e){return["pr","listByProject",e]}function eE(e){return["pr","draft",e]}var tE=Object.create,tw=Object.defineProperty,sE=Object.getOwnPropertyDescriptor,sw=Object.getOwnPropertyNames,iE=Object.getPrototypeOf,rE=Object.prototype.hasOwnProperty,Fi=(e,t)=>function(){return t||(0,e[sw(e)[0]])((t={exports:{}}).exports,t),t.exports},nE=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=sw(t),c=0,h=a.length,d;c<h;c++)d=a[c],!rE.call(e,d)&&d!==s&&tw(e,d,{get:(f=>t[f]).bind(null,d),enumerable:!(n=sE(t,d))||n.enumerable});return e},At=(e,t,s)=>(s=e!=null?tE(iE(e)):{},nE(t||!e||!e.__esModule?tw(s,"default",{value:e,enumerable:!0}):s,e)),iw=Fi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function s(n){"@babel/helpers - typeof";return t.exports=s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},t.exports.__esModule=!0,t.exports.default=t.exports,s(n)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),aE=Fi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var s=iw().default;function n(a,c){if(s(a)!="object"||!a)return a;var h=a[Symbol.toPrimitive];if(h!==void 0){var d=h.call(a,c||"default");if(s(d)!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(a)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),lE=Fi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var s=iw().default,n=aE();function a(c){var h=n(c,"string");return s(h)=="symbol"?h:h+""}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),fa=Fi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var s=lE();function n(a,c,h){return(c=s(c))in a?Object.defineProperty(a,c,{value:h,enumerable:!0,configurable:!0,writable:!0}):a[c]=h,a}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),bi=Fi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var s=fa();function n(c,h){var d=Object.keys(c);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(c);h&&(f=f.filter(function(m){return Object.getOwnPropertyDescriptor(c,m).enumerable})),d.push.apply(d,f)}return d}function a(c){for(var h=1;h<arguments.length;h++){var d=arguments[h]!=null?arguments[h]:{};h%2?n(Object(d),!0).forEach(function(f){s(c,f,d[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(d)):n(Object(d)).forEach(function(f){Object.defineProperty(c,f,Object.getOwnPropertyDescriptor(d,f))})}return c}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}});function jl(e){const t={subscribe(s){let n=null,a=!1,c=!1,h=!1;function d(){if(n===null){h=!0;return}c||(c=!0,typeof n=="function"?n():n&&n.unsubscribe())}return n=e({next(f){var m;a||(m=s.next)===null||m===void 0||m.call(s,f)},error(f){var m;a||(a=!0,(m=s.error)===null||m===void 0||m.call(s,f),d())},complete(){var f;a||(a=!0,(f=s.complete)===null||f===void 0||f.call(s),d())}}),h&&d(),{unsubscribe:d}},pipe(...s){return s.reduce(oE,t)}};return t}function oE(e,t){return t(e)}function cE(e){const t=new AbortController;return new Promise((n,a)=>{let c=!1;function h(){c||(c=!0,d.unsubscribe())}t.signal.addEventListener("abort",()=>{a(t.signal.reason)});const d=e.subscribe({next(f){c=!0,n(f),h()},error(f){a(f)},complete(){t.abort(),h()}})})}function uE(e){return t=>{let s=0,n=null;const a=[];function c(){n||(n=t.subscribe({next(d){for(const m of a){var f;(f=m.next)===null||f===void 0||f.call(m,d)}},error(d){for(const m of a){var f;(f=m.error)===null||f===void 0||f.call(m,d)}},complete(){for(const f of a){var d;(d=f.complete)===null||d===void 0||d.call(f)}}}))}function h(){if(s===0&&n){const d=n;n=null,d.unsubscribe()}}return jl(d=>(s++,a.push(d),c(),{unsubscribe(){s--,h();const f=a.findIndex(m=>m===d);f>-1&&a.splice(f,1)}}))}}function rw(e){let t=e;const s=[],n=h=>{t!==void 0&&h.next(t),s.push(h)},a=h=>{s.splice(s.indexOf(h),1)},c=jl(h=>(n(h),()=>{a(h)}));return c.next=h=>{if(t!==h){t=h;for(const d of s)d.next(h)}},c.get=()=>t,c}function nw(e){return jl(t=>{function s(a=0,c=e.op){const h=e.links[a];if(!h)throw new Error("No more links to execute - did you forget to add an ending link?");return h({op:c,next(f){return s(a+1,f)}})}return s().subscribe(t)})}function f0(e){return Array.isArray(e)?e:[e]}function hE(e){return t=>{const s=f0(e.true).map(a=>a(t)),n=f0(e.false).map(a=>a(t));return a=>jl(c=>{const h=e.condition(a.op)?s:n;return nw({op:a.op,links:h}).subscribe(c)})}}function $o(e){return!!e&&!Array.isArray(e)&&typeof e=="object"}function aw(){return Object.create(null)}const lw=e=>e(),Lu={INTERNAL_SERVER_ERROR:-32603,BAD_GATEWAY:-32603,SERVICE_UNAVAILABLE:-32603,GATEWAY_TIMEOUT:-32603},dE=[Lu.BAD_GATEWAY,Lu.SERVICE_UNAVAILABLE,Lu.GATEWAY_TIMEOUT,Lu.INTERNAL_SERVER_ERROR];var fE=Object.create,ow=Object.defineProperty,mE=Object.getOwnPropertyDescriptor,cw=Object.getOwnPropertyNames,pE=Object.getPrototypeOf,_E=Object.prototype.hasOwnProperty,Si=(e,t)=>function(){return t||(0,e[cw(e)[0]])((t={exports:{}}).exports,t),t.exports},gE=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=cw(t),c=0,h=a.length,d;c<h;c++)d=a[c],!_E.call(e,d)&&d!==s&&ow(e,d,{get:(f=>t[f]).bind(null,d),enumerable:!(n=mE(t,d))||n.enumerable});return e},ft=(e,t,s)=>(s=e!=null?fE(pE(e)):{},gE(ow(s,"default",{value:e,enumerable:!0}),e));const uw=()=>{},m0=e=>{Object.freeze&&Object.freeze(e)};function hw(e,t,s){var n;const a=t.join(".");return(n=s[a])!==null&&n!==void 0||(s[a]=new Proxy(uw,{get(c,h){if(!(typeof h!="string"||h==="then"))return hw(e,[...t,h],s)},apply(c,h,d){const f=t[t.length-1];if(f==="valueOf"||f==="toString"||f==="toJSON")return`tRPC.proxy(${t.slice(0,-1).join(".")})`;let m={args:d,path:t};return f==="call"?m={args:d.length>=2?[d[1]]:[],path:t.slice(0,-1)}:f==="apply"&&(m={args:d.length>=2?d[1]:[],path:t.slice(0,-1)}),m0(m.args),m0(m.path),e(m)}})),s[a]}const vE=e=>hw(e,[],aw()),yE=e=>new Proxy(uw,{get(t,s){if(s!=="then")return e(s)}});var dw=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function s(n){"@babel/helpers - typeof";return t.exports=s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},t.exports.__esModule=!0,t.exports.default=t.exports,s(n)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),bE=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var s=dw().default;function n(a,c){if(s(a)!="object"||!a)return a;var h=a[Symbol.toPrimitive];if(h!==void 0){var d=h.call(a,c||"default");if(s(d)!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(a)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),SE=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var s=dw().default,n=bE();function a(c){var h=n(c,"string");return s(h)=="symbol"?h:h+""}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),__=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var s=SE();function n(a,c,h){return(c=s(c))in a?Object.defineProperty(a,c,{value:h,enumerable:!0,configurable:!0,writable:!0}):a[c]=h,a}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),cc=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var s=__();function n(c,h){var d=Object.keys(c);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(c);h&&(f=f.filter(function(m){return Object.getOwnPropertyDescriptor(c,m).enumerable})),d.push.apply(d,f)}return d}function a(c){for(var h=1;h<arguments.length;h++){var d=arguments[h]!=null?arguments[h]:{};h%2?n(Object(d),!0).forEach(function(f){s(c,f,d[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(d)):n(Object(d)).forEach(function(f){Object.defineProperty(c,f,Object.getOwnPropertyDescriptor(d,f))})}return c}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}});ft(cc());ft(__());var qu=ft(cc());function xE(e,t){if("error"in e){const n=t.deserialize(e.error);return{ok:!1,error:(0,qu.default)((0,qu.default)({},e),{},{error:n})}}return{ok:!0,result:(0,qu.default)((0,qu.default)({},e.result),(!e.result.type||e.result.type==="data")&&{type:"data",data:t.deserialize(e.result.data)})}}var om=class extends Error{constructor(){super("Unable to transform response from server")}};function wE(e,t){let s;try{s=xE(e,t)}catch{throw new om}if(!s.ok&&(!$o(s.error.error)||typeof s.error.error.code!="number"))throw new om;if(s.ok&&!$o(s.result))throw new om;return s}ft(cc());ft(cc());var zu=ft(__());let fw;const cm=new WeakMap,CE=()=>{};fw=Symbol.toStringTag;var mw=class Fn{constructor(t){(0,zu.default)(this,"promise",void 0),(0,zu.default)(this,"subscribers",[]),(0,zu.default)(this,"settlement",null),(0,zu.default)(this,fw,"Unpromise"),typeof t=="function"?this.promise=new Promise(t):this.promise=t;const s=this.promise.then(n=>{const{subscribers:a}=this;this.subscribers=null,this.settlement={status:"fulfilled",value:n},a==null||a.forEach(({resolve:c})=>{c(n)})});"catch"in s&&s.catch(n=>{const{subscribers:a}=this;this.subscribers=null,this.settlement={status:"rejected",reason:n},a==null||a.forEach(({reject:c})=>{c(n)})})}subscribe(){let t,s;const{settlement:n}=this;if(n===null){if(this.subscribers===null)throw new Error("Unpromise settled but still has subscribers");const a=kE();this.subscribers=NE(this.subscribers,a),t=a.promise,s=()=>{this.subscribers!==null&&(this.subscribers=TE(this.subscribers,a))}}else{const{status:a}=n;a==="fulfilled"?t=Promise.resolve(n.value):t=Promise.reject(n.reason),s=CE}return Object.assign(t,{unsubscribe:s})}then(t,s){const n=this.subscribe(),{unsubscribe:a}=n;return Object.assign(n.then(t,s),{unsubscribe:a})}catch(t){const s=this.subscribe(),{unsubscribe:n}=s;return Object.assign(s.catch(t),{unsubscribe:n})}finally(t){const s=this.subscribe(),{unsubscribe:n}=s;return Object.assign(s.finally(t),{unsubscribe:n})}static proxy(t){const s=Fn.getSubscribablePromise(t);return typeof s<"u"?s:Fn.createSubscribablePromise(t)}static createSubscribablePromise(t){const s=new Fn(t);return cm.set(t,s),cm.set(s,s),s}static getSubscribablePromise(t){return cm.get(t)}static resolve(t){const s=typeof t=="object"&&t!==null&&"then"in t&&typeof t.then=="function"?t:Promise.resolve(t);return Fn.proxy(s).subscribe()}static async any(t){const n=(Array.isArray(t)?t:[...t]).map(Fn.resolve);try{return await Promise.any(n)}finally{n.forEach(({unsubscribe:a})=>{a()})}}static async race(t){const n=(Array.isArray(t)?t:[...t]).map(Fn.resolve);try{return await Promise.race(n)}finally{n.forEach(({unsubscribe:a})=>{a()})}}static async raceReferences(t){const s=t.map(jE);try{return await Promise.race(s)}finally{for(const n of s)n.unsubscribe()}}};function jE(e){return mw.proxy(e).then(()=>[e])}function kE(){let e,t;return{promise:new Promise((n,a)=>{e=n,t=a}),resolve:e,reject:t}}function NE(e,t){return[...e,t]}function EE(e,t){return[...e.slice(0,t),...e.slice(t+1)]}function TE(e,t){const s=e.indexOf(t);return s!==-1?EE(e,s):e}var p0,_0,g0,v0;(_0=(p0=Symbol).dispose)!==null&&_0!==void 0||(p0.dispose=Symbol());(v0=(g0=Symbol).asyncDispose)!==null&&v0!==void 0||(g0.asyncDispose=Symbol());function OE(e,t){const s=e,n=s[Symbol.dispose];return s[Symbol.dispose]=()=>{t(),n==null||n()},s}function AE(e,t){const s=e,n=s[Symbol.asyncDispose];return s[Symbol.asyncDispose]=async()=>{await t(),await(n==null?void 0:n())},s}const pw=Symbol();function RE(e){let t=null;return OE({start(){if(t)throw new Error("Timer already started");return new Promise(n=>{t=setTimeout(()=>n(pw),e)})}},()=>{t&&clearTimeout(t)})}var uc=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function s(){var n=typeof SuppressedError=="function"?SuppressedError:function(d,f){var m=Error();return m.name="SuppressedError",m.error=d,m.suppressed=f,m},a={},c=[];function h(d,f){if(f!=null){if(Object(f)!==f)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(d)var m=f[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(m===void 0&&(m=f[Symbol.dispose||Symbol.for("Symbol.dispose")],d))var g=m;if(typeof m!="function")throw new TypeError("Object is not disposable.");g&&(m=function(){try{g.call(f)}catch(b){return Promise.reject(b)}}),c.push({v:f,d:m,a:d})}else d&&c.push({d:f,a:d});return f}return{e:a,u:h.bind(null,!1),a:h.bind(null,!0),d:function(){var f,m=this.e,g=0;function v(){for(;f=c.pop();)try{if(!f.a&&g===1)return g=0,c.push(f),Promise.resolve().then(v);if(f.d){var S=f.d.call(f.v);if(f.a)return g|=2,Promise.resolve(S).then(v,b)}else g|=1}catch(x){return b(x)}if(g===1)return m!==a?Promise.reject(m):Promise.resolve();if(m!==a)throw m}function b(S){return m=m!==a?new n(S,m):S,v()}return v()}}}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),g_=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function s(n,a){this.v=n,this.k=a}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),hc=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var s=g_();function n(a){return new s(a,0)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),kl=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var s=g_();function n(c){return function(){return new a(c.apply(this,arguments))}}function a(c){var h,d;function f(g,v){try{var b=c[g](v),S=b.value,x=S instanceof s;Promise.resolve(x?S.v:S).then(function(w){if(x){var k=g==="return"?"return":"next";if(!S.k||w.done)return f(k,w);w=c[k](w).value}m(b.done?"return":"normal",w)},function(w){f("throw",w)})}catch(w){m("throw",w)}}function m(g,v){switch(g){case"return":h.resolve({value:v,done:!0});break;case"throw":h.reject(v);break;default:h.resolve({value:v,done:!1})}(h=h.next)?f(h.key,h.arg):d=null}this._invoke=function(g,v){return new Promise(function(b,S){var x={key:g,arg:v,resolve:b,reject:S,next:null};d?d=d.next=x:(h=d=x,f(g,v))})},typeof c.return!="function"&&(this.return=void 0)}a.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},a.prototype.next=function(c){return this._invoke("next",c)},a.prototype.throw=function(c){return this._invoke("throw",c)},a.prototype.return=function(c){return this._invoke("return",c)},t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}});ft(uc());ft(hc());ft(kl());ft(uc());ft(hc());ft(kl());ft(uc());ft(hc());ft(kl());var _w=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function s(a){var c,h,d,f=2;for(typeof Symbol<"u"&&(h=Symbol.asyncIterator,d=Symbol.iterator);f--;){if(h&&(c=a[h])!=null)return c.call(a);if(d&&(c=a[d])!=null)return new n(c.call(a));h="@@asyncIterator",d="@@iterator"}throw new TypeError("Object is not async iterable")}function n(a){function c(h){if(Object(h)!==h)return Promise.reject(new TypeError(h+" is not an object."));var d=h.done;return Promise.resolve(h.value).then(function(f){return{value:f,done:d}})}return n=function(d){this.s=d,this.n=d.next},n.prototype={s:null,n:null,next:function(){return c(this.n.apply(this.s,arguments))},return:function(d){var f=this.s.return;return f===void 0?Promise.resolve({value:d,done:!0}):c(f.apply(this.s,arguments))},throw:function(d){var f=this.s.return;return f===void 0?Promise.reject(d):c(f.apply(this.s,arguments))}},new n(a)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}});ft(hc());ft(kl());ft(uc());ft(_w());var DE=Si({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncGeneratorDelegate.js"(e,t){var s=g_();function n(a){var c={},h=!1;function d(f,m){return h=!0,m=new Promise(function(g){g(a[f](m))}),{done:!1,value:new s(m,1)}}return c[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},c.next=function(f){return h?(h=!1,f):d("next",f)},typeof a.throw=="function"&&(c.throw=function(f){if(h)throw h=!1,f;return d("throw",f)}),typeof a.return=="function"&&(c.return=function(f){return h?(h=!1,f):d("return",f)}),c}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}});ft(_w());var y0=ft(hc()),ME=ft(kl());ft(DE());var gw=ft(uc());const BE="ping",LE="serialized-error",qE="connected",zE="return";async function PE(e){try{var t=(0,gw.default)();const s=t.u(RE(e.timeoutMs)),n=await mw.race([e.promise,s.start()]);return n===pw?await e.onTimeout():n}catch(s){t.e=s}finally{t.d()}}function HE(e){const{deserialize:t=d=>d}=e;let s=aw();const n=e.signal;let a=null;const c=()=>new ReadableStream({async start(d){const[f,m]=await Promise.all([e.url(),e.init()]),g=a=new e.EventSource(f,m);d.enqueue({type:"connecting",eventSource:a,event:null}),g.addEventListener(qE,b=>{const x=JSON.parse(b.data);s=x,d.enqueue({type:"connected",options:x,eventSource:g})}),g.addEventListener(LE,b=>{const S=b;d.enqueue({type:"serialized-error",error:t(JSON.parse(S.data)),eventSource:g})}),g.addEventListener(BE,()=>{d.enqueue({type:"ping",eventSource:g})}),g.addEventListener(zE,()=>{g.close(),d.close(),a=null}),g.addEventListener("error",b=>{g.readyState===g.CLOSED?d.error(b):d.enqueue({type:"connecting",eventSource:g,event:b})}),g.addEventListener("message",b=>{const S=b,w={data:t(JSON.parse(S.data))};S.lastEventId&&(w.id=S.lastEventId),d.enqueue({type:"data",data:w,eventSource:g})});const v=()=>{try{g.close(),d.close()}catch{}};n.aborted?v():n.addEventListener("abort",v)},cancel(){a==null||a.close()}}),h=()=>{let d=c(),f=d.getReader();async function m(){await f.cancel(),a=null}return AE({read(){return f.read()},async recreate(){await m(),d=c(),f=d.getReader()}},m)};return lw((0,ME.default)(function*(){try{var d=(0,gw.default)();const f=d.a(h());for(;;){let m=f.read();const g=s.reconnectAfterInactivityMs;g&&(m=PE({promise:m,timeoutMs:g,onTimeout:async()=>{const b={value:{type:"timeout",ms:g,eventSource:a},done:!1};return await f.recreate(),b}}));const v=yield(0,y0.default)(m);if(v.done)return v.value;yield v.value}}catch(f){d.e=f}finally{yield(0,y0.default)(d.d())}}))}ft(kl());ft(cc());var Pu=At(fa(),1),el=At(bi(),1);function FE(e){return e instanceof hn}function IE(e){return $o(e)&&$o(e.error)&&typeof e.error.code=="number"&&typeof e.error.message=="string"}function UE(e,t){return typeof e=="string"?e:$o(e)&&typeof e.message=="string"?e.message:t}var hn=class sh extends Error{constructor(t,s){var n,a;const c=s==null?void 0:s.cause;super(t,{cause:c}),(0,Pu.default)(this,"cause",void 0),(0,Pu.default)(this,"shape",void 0),(0,Pu.default)(this,"data",void 0),(0,Pu.default)(this,"meta",void 0),this.meta=s==null?void 0:s.meta,this.cause=c,this.shape=s==null||(n=s.result)===null||n===void 0?void 0:n.error,this.data=s==null||(a=s.result)===null||a===void 0?void 0:a.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,sh.prototype)}static from(t,s={}){const n=t;return FE(n)?(s.meta&&(n.meta=(0,el.default)((0,el.default)({},n.meta),s.meta)),n):IE(n)?new sh(n.error.message,(0,el.default)((0,el.default)({},s),{},{result:n,cause:s.cause})):new sh(UE(n,"Unknown error"),(0,el.default)((0,el.default)({},s),{},{cause:n}))}};function vw(e){const t=e;return t?"input"in t?t:{input:t,output:t}:{input:{serialize:s=>s,deserialize:s=>s},output:{serialize:s=>s,deserialize:s=>s}}}const b0=e=>typeof e=="function";function KE(e){if(e)return e;if(typeof window<"u"&&b0(window.fetch))return window.fetch;if(typeof globalThis<"u"&&b0(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}var Ho=At(bi());function $E(e){return{url:e.url.toString(),fetch:e.fetch,transformer:vw(e.transformer),methodOverride:e.methodOverride}}function WE(e){const t={};for(let s=0;s<e.length;s++){const n=e[s];t[s]=n}return t}const VE={query:"GET",mutation:"POST",subscription:"PATCH"};function yw(e){return"input"in e?e.transformer.input.serialize(e.input):WE(e.inputs.map(t=>e.transformer.input.serialize(t)))}const v_=e=>{const t=e.url.split("?");let n=t[0].replace(/\/$/,"")+"/"+e.path;const a=[];if(t[1]&&a.push(t[1]),"inputs"in e&&a.push("batch=1"),e.type==="query"||e.type==="subscription"){const c=yw(e);c!==void 0&&e.methodOverride!=="POST"&&a.push(`input=${encodeURIComponent(JSON.stringify(c))}`)}return a.length&&(n+="?"+a.join("&")),n},YE=e=>{if(e.type==="query"&&e.methodOverride!=="POST")return;const t=yw(e);return t!==void 0?JSON.stringify(t):void 0},GE=e=>JE((0,Ho.default)((0,Ho.default)({},e),{},{contentTypeHeader:"application/json",getUrl:v_,getBody:YE}));var QE=class extends Error{constructor(){const e="AbortError";super(e),this.name=e,this.message=e}};const ZE=e=>{var t;if(e!=null&&e.aborted)throw(t=e.throwIfAborted)===null||t===void 0||t.call(e),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new QE};async function XE(e){var t,s;ZE(e.signal);const n=e.getUrl(e),a=e.getBody(e),c=(t=e.methodOverride)!==null&&t!==void 0?t:VE[e.type],h=await(async()=>{const f=await e.headers();return Symbol.iterator in f?Object.fromEntries(f):f})(),d=(0,Ho.default)((0,Ho.default)((0,Ho.default)({},e.contentTypeHeader&&c!=="GET"?{"content-type":e.contentTypeHeader}:{}),e.trpcAcceptHeader?{[(s=e.trpcAcceptHeaderKey)!==null&&s!==void 0?s:"trpc-accept"]:e.trpcAcceptHeader}:void 0),h);return KE(e.fetch)(n,{method:c,signal:e.signal,body:a,headers:d})}async function JE(e){const t={},s=await XE(e);t.response=s;const n=await s.json();return t.responseJSON=n,{json:n,meta:t}}At(bi(),1);const S0=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function x0(e){let t=null,s=null;const n=()=>{clearTimeout(s),s=null,t=null};function a(d){const f=[[]];let m=0;for(;;){const b=d[m];if(!b)break;const S=f[f.length-1];if(b.aborted){var g;(g=b.reject)===null||g===void 0||g.call(b,new Error("Aborted")),m++;continue}if(e.validate(S.concat(b).map(w=>w.key))){S.push(b),m++;continue}if(S.length===0){var v;(v=b.reject)===null||v===void 0||v.call(b,new Error("Input is too big for a single dispatch")),m++;continue}f.push([])}return f}function c(){const d=a(t);n();for(const f of d){if(!f.length)continue;const m={items:f};for(const v of f)v.batch=m;e.fetch(m.items.map(v=>v.key)).then(async v=>{await Promise.all(v.map(async(S,x)=>{const w=m.items[x];try{var k;const L=await Promise.resolve(S);(k=w.resolve)===null||k===void 0||k.call(w,L)}catch(L){var N;(N=w.reject)===null||N===void 0||N.call(w,L)}w.batch=null,w.reject=null,w.resolve=null}));for(const S of m.items){var b;(b=S.reject)===null||b===void 0||b.call(S,new Error("Missing result")),S.batch=null}}).catch(v=>{for(const S of m.items){var b;(b=S.reject)===null||b===void 0||b.call(S,v),S.batch=null}})}}function h(d){var f;const m={aborted:!1,key:d,batch:null,resolve:S0,reject:S0},g=new Promise((v,b)=>{var S;m.reject=b,m.resolve=v,(S=t)!==null&&S!==void 0||(t=[]),t.push(m)});return(f=s)!==null&&f!==void 0||(s=setTimeout(c)),g}return{load:h}}function e2(...e){const t=new AbortController,s=e.length;let n=0;const a=()=>{++n===s&&t.abort()};for(const c of e)c!=null&&c.aborted?a():c==null||c.addEventListener("abort",a,{once:!0});return t.signal}function t2(...e){const t=new AbortController;for(const s of e)s!=null&&s.aborted?t.abort():s==null||s.addEventListener("abort",()=>t.abort(),{once:!0});return t.signal}var Hu=At(bi(),1);function s2(e){var t,s;const n=$E(e),a=(t=e.maxURLLength)!==null&&t!==void 0?t:1/0,c=(s=e.maxItems)!==null&&s!==void 0?s:1/0;return()=>{const h=g=>({validate(v){if(a===1/0&&c===1/0)return!0;if(v.length>c)return!1;const b=v.map(w=>w.path).join(","),S=v.map(w=>w.input);return v_((0,Hu.default)((0,Hu.default)({},n),{},{type:g,path:b,inputs:S,signal:null})).length<=a},async fetch(v){const b=v.map(L=>L.path).join(","),S=v.map(L=>L.input),x=e2(...v.map(L=>L.signal)),w=await GE((0,Hu.default)((0,Hu.default)({},n),{},{path:b,inputs:S,type:g,headers(){return e.headers?typeof e.headers=="function"?e.headers({opList:v}):e.headers:{}},signal:x}));return(Array.isArray(w.json)?w.json:v.map(()=>w.json)).map(L=>({meta:w.meta,json:L}))}}),d=x0(h("query")),f=x0(h("mutation")),m={query:d,mutation:f};return({op:g})=>jl(v=>{/* istanbul ignore if -- @preserve */if(g.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const S=m[g.type].load(g);let x;return S.then(w=>{x=w;const k=wE(w.json,n.transformer.output);if(!k.ok){v.error(hn.from(k.error,{meta:w.meta}));return}v.next({context:w.meta,result:k.result}),v.complete()}).catch(w=>{v.error(hn.from(w,{meta:x==null?void 0:x.meta}))}),()=>{}})}}At(bi(),1);const Wo=(e,...t)=>typeof e=="function"?e(...t):e;At(fa(),1);function i2(){let e,t;return{promise:new Promise((n,a)=>{e=n,t=a}),resolve:e,reject:t}}async function r2(e){const t=await Wo(e.url);if(!e.connectionParams)return t;const n=`${t.includes("?")?"&":"?"}connectionParams=1`;return t+n}async function n2(e,t){const s={method:"connectionParams",data:await Wo(e)};return t.encode(s)}At(fa(),1);var Qr=At(fa(),1);function a2(e){const{promise:t,resolve:s,reject:n}=i2();return e.addEventListener("open",()=>{e.removeEventListener("error",n),s()}),e.addEventListener("error",n),t}function l2(e,{intervalMs:t,pongTimeoutMs:s}){let n,a;function c(){n=setTimeout(()=>{e.send("PING"),a=setTimeout(()=>{e.close()},s)},t)}function h(){clearTimeout(n),c()}function d(){clearTimeout(a),h()}e.addEventListener("open",c),e.addEventListener("message",({data:f})=>{clearTimeout(n),c(),f==="PONG"&&d()}),e.addEventListener("close",()=>{clearTimeout(n),clearTimeout(a)})}var o2=class rp{constructor(t){var s;if((0,Qr.default)(this,"id",++rp.connectCount),(0,Qr.default)(this,"WebSocketPonyfill",void 0),(0,Qr.default)(this,"urlOptions",void 0),(0,Qr.default)(this,"keepAliveOpts",void 0),(0,Qr.default)(this,"encoder",void 0),(0,Qr.default)(this,"wsObservable",rw(null)),(0,Qr.default)(this,"openPromise",null),this.WebSocketPonyfill=(s=t.WebSocketPonyfill)!==null&&s!==void 0?s:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=t.urlOptions,this.keepAliveOpts=t.keepAlive,this.encoder=t.encoder}get ws(){return this.wsObservable.get()}set ws(t){this.wsObservable.next(t)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var t=this;if(t.openPromise)return t.openPromise;t.id=++rp.connectCount;const s=r2(t.urlOptions).then(n=>new t.WebSocketPonyfill(n));t.openPromise=s.then(async n=>{t.ws=n,n.binaryType="arraybuffer",n.addEventListener("message",function({data:a}){a==="PING"&&this.send("PONG")}),t.keepAliveOpts.enabled&&l2(n,t.keepAliveOpts),n.addEventListener("close",()=>{t.ws===n&&(t.ws=null)}),await a2(n),t.urlOptions.connectionParams&&n.send(await n2(t.urlOptions.connectionParams,t.encoder))});try{await t.openPromise}finally{t.openPromise=null}}async close(){var t=this;try{await t.openPromise}finally{var s;(s=t.ws)===null||s===void 0||s.close()}}};(0,Qr.default)(o2,"connectCount",0);At(fa(),1);At(bi(),1);var um=At(fa(),1),w0=At(bi(),1),c2=class{constructor(e){(0,um.default)(this,"links",void 0),(0,um.default)(this,"runtime",void 0),(0,um.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(t=>t(this.runtime))}$request(e){var t;return nw({links:this.links,op:(0,w0.default)((0,w0.default)({},e),{},{context:(t=e.context)!==null&&t!==void 0?t:{},id:++this.requestId})}).pipe(uE())}async requestAsPromise(e){var t=this;try{const s=t.$request(e);return(await cE(s)).result.data}catch(s){throw hn.from(s)}}query(e,t,s){return this.requestAsPromise({type:"query",path:e,input:t,context:s==null?void 0:s.context,signal:s==null?void 0:s.signal})}mutation(e,t,s){return this.requestAsPromise({type:"mutation",path:e,input:t,context:s==null?void 0:s.context,signal:s==null?void 0:s.signal})}subscription(e,t,s){return this.$request({type:"subscription",path:e,input:t,context:s.context,signal:s.signal}).subscribe({next(a){switch(a.result.type){case"state":{var c;(c=s.onConnectionStateChange)===null||c===void 0||c.call(s,a.result);break}case"started":{var h;(h=s.onStarted)===null||h===void 0||h.call(s,{context:a.context});break}case"stopped":{var d;(d=s.onStopped)===null||d===void 0||d.call(s);break}case"data":case void 0:{var f;(f=s.onData)===null||f===void 0||f.call(s,a.result.data);break}}},error(a){var c;(c=s.onError)===null||c===void 0||c.call(s,a)},complete(){var a;(a=s.onComplete)===null||a===void 0||a.call(s)}})}};const u2=Symbol.for("trpc_untypedClient"),h2={query:"query",mutate:"mutation",subscribe:"subscription"},d2=e=>h2[e];function f2(e){const t=vE(({path:s,args:n})=>{const a=[...s],c=d2(a.pop()),h=a.join(".");return e[c](h,...n)});return yE(s=>s===u2?e:t[s])}function m2(e){const t=new c2(e);return f2(t)}At(bi(),1);var C0=At(bi(),1);function p2(e,t){return!t||e!=null&&typeof e!="object"?e:(0,C0.default)((0,C0.default)({},e??{}),{},{lastEventId:t})}var _2=Fi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function s(a){var c,h,d,f=2;for(typeof Symbol<"u"&&(h=Symbol.asyncIterator,d=Symbol.iterator);f--;){if(h&&(c=a[h])!=null)return c.call(a);if(d&&(c=a[d])!=null)return new n(c.call(a));h="@@asyncIterator",d="@@iterator"}throw new TypeError("Object is not async iterable")}function n(a){function c(h){if(Object(h)!==h)return Promise.reject(new TypeError(h+" is not an object."));var d=h.done;return Promise.resolve(h.value).then(function(f){return{value:f,done:d}})}return n=function(d){this.s=d,this.n=d.next},n.prototype={s:null,n:null,next:function(){return c(this.n.apply(this.s,arguments))},return:function(d){var f=this.s.return;return f===void 0?Promise.resolve({value:d,done:!0}):c(f.apply(this.s,arguments))},throw:function(d){var f=this.s.return;return f===void 0?Promise.reject(d):c(f.apply(this.s,arguments))}},new n(a)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),g2=At(_2(),1);async function v2(e){let t=await Wo(e.url);if(e.connectionParams){const s=await Wo(e.connectionParams),n=t.includes("?")?"&":"?";t+=n+"connectionParams="+encodeURIComponent(JSON.stringify(s))}return t}function y2(e){const t=vw(e.transformer);return()=>({op:s})=>jl(n=>{var a;const{type:c,path:h,input:d}=s;/* istanbul ignore if -- @preserve */if(c!=="subscription")throw new Error("httpSubscriptionLink only supports subscriptions");let f;const m=new AbortController,g=t2(s.signal,m.signal),v=HE({url:async()=>v_({transformer:t,url:await v2(e),input:p2(d,f),path:h,type:c,signal:null}),init:()=>Wo(e.eventSourceOptions,{op:s}),signal:g,deserialize:x=>t.output.deserialize(x),EventSource:(a=e.EventSource)!==null&&a!==void 0?a:globalThis.EventSource}),b=rw({type:"state",state:"connecting",error:null}),S=b.subscribe({next(x){n.next({result:x})}});return lw(async()=>{var x=!1,w=!1,k;try{for(var N=(0,g2.default)(v),L;x=!(L=await N.next()).done;x=!1){const R=L.value;switch(R.type){case"ping":break;case"data":const D=R.data;let Y;D.id?(f=D.id,Y={id:D.id,data:D}):Y={data:D.data},n.next({result:Y,context:{eventSource:R.eventSource}});break;case"connected":{n.next({result:{type:"started"},context:{eventSource:R.eventSource}}),b.next({type:"state",state:"pending",error:null});break}case"serialized-error":{const K=hn.from({error:R.error});if(dE.includes(R.error.code)){b.next({type:"state",state:"connecting",error:K});break}throw K}case"connecting":{const K=b.get(),Z=R.event&&hn.from(R.event);if(!Z&&K.state==="connecting")break;b.next({type:"state",state:"connecting",error:Z});break}case"timeout":b.next({type:"state",state:"connecting",error:new hn(`Timeout of ${R.ms}ms reached while waiting for a response`)})}}}catch(R){w=!0,k=R}finally{try{x&&N.return!=null&&await N.return()}finally{if(w)throw k}}n.next({result:{type:"stopped"}}),b.next({type:"state",state:"idle",error:null}),n.complete()}).catch(x=>{n.error(hn.from(x))}),()=>{n.complete(),m.abort(),S.unsubscribe()}})}At(bi(),1);var b2=Fi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function s(){var n=typeof SuppressedError=="function"?SuppressedError:function(d,f){var m=Error();return m.name="SuppressedError",m.error=d,m.suppressed=f,m},a={},c=[];function h(d,f){if(f!=null){if(Object(f)!==f)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(d)var m=f[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(m===void 0&&(m=f[Symbol.dispose||Symbol.for("Symbol.dispose")],d))var g=m;if(typeof m!="function")throw new TypeError("Object is not disposable.");g&&(m=function(){try{g.call(f)}catch(b){return Promise.reject(b)}}),c.push({v:f,d:m,a:d})}else d&&c.push({d:f,a:d});return f}return{e:a,u:h.bind(null,!1),a:h.bind(null,!0),d:function(){var f,m=this.e,g=0;function v(){for(;f=c.pop();)try{if(!f.a&&g===1)return g=0,c.push(f),Promise.resolve().then(v);if(f.d){var S=f.d.call(f.v);if(f.a)return g|=2,Promise.resolve(S).then(v,b)}else g|=1}catch(x){return b(x)}if(g===1)return m!==a?Promise.reject(m):Promise.resolve();if(m!==a)throw m}function b(S){return m=m!==a?new n(S,m):S,v()}return v()}}}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),bw=Fi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function s(n,a){this.v=n,this.k=a}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),S2=Fi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var s=bw();function n(a){return new s(a,0)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),x2=Fi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var s=bw();function n(c){return function(){return new a(c.apply(this,arguments))}}function a(c){var h,d;function f(g,v){try{var b=c[g](v),S=b.value,x=S instanceof s;Promise.resolve(x?S.v:S).then(function(w){if(x){var k=g==="return"?"return":"next";if(!S.k||w.done)return f(k,w);w=c[k](w).value}m(b.done?"return":"normal",w)},function(w){f("throw",w)})}catch(w){m("throw",w)}}function m(g,v){switch(g){case"return":h.resolve({value:v,done:!0});break;case"throw":h.reject(v);break;default:h.resolve({value:v,done:!1})}(h=h.next)?f(h.key,h.arg):d=null}this._invoke=function(g,v){return new Promise(function(b,S){var x={key:g,arg:v,resolve:b,reject:S,next:null};d?d=d.next=x:(h=d=x,f(g,v))})},typeof c.return!="function"&&(this.return=void 0)}a.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},a.prototype.next=function(c){return this._invoke("next",c)},a.prototype.throw=function(c){return this._invoke("throw",c)},a.prototype.return=function(c){return this._invoke("return",c)},t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}});At(b2(),1);At(S2(),1);At(x2(),1);At(bi(),1);const te=m2({links:[hE({condition:e=>e.type==="subscription",true:y2({url:"/trpc"}),false:s2({url:"/trpc"})})]}),w2={connecting:"conectando",counting:"contando objetos",compressing:"comprimindo",receiving:"recebendo objetos",resolving:"resolvendo deltas",checkout:"preparando arquivos"},C2=new Set(["done","failed","cancelled"]);function hh(e){return C2.has(e)}function j2(e){const t=ye({queryKey:uh(e),queryFn:()=>te.project.cloneJobs.query({workspaceId:e})});return k2(t.data??[])}function k2(e){const t=e.find(s=>!hh(s.state));return t!==void 0?t:e.reduce((s,n)=>s===null||n.updatedAt>s.updatedAt?n:s,null)}function N2(e){const t=qe(),s=j2(e),n=s!==null&&!hh(s.state)?s.id:null;return j.useEffect(()=>{if(n===null)return;const a=te.project.cloneProgress.subscribe({jobId:n},{onData:c=>{const h=c;t.setQueryData(uh(e),d=>[...(d??[]).filter(m=>m.id!==h.id),h])}});return()=>a.unsubscribe()},[n,e,t]),s}const E2={info:"◆",warning:"⚠",danger:"⚠"};function ke({tone:e,children:t,actions:s}){return l.jsxs("div",{className:`banner banner--${e}`,role:e==="danger"?"alert":"status",children:[l.jsx("span",{className:"banner__glyph","aria-hidden":"true",children:E2[e]}),l.jsx("span",{children:t}),s!==void 0&&l.jsx("span",{className:"banner__actions",children:s})]})}function ce({variant:e="default",size:t="md",glyph:s,className:n,children:a,type:c="button",...h}){const d=["btn",e==="default"?"":`btn--${e}`,t==="sm"?"btn--sm":"",n??""].filter(Boolean).join(" ");return l.jsxs("button",{type:c,className:d,...h,children:[s,a]})}function Sw({title:e,lede:t,children:s}){return l.jsxs("div",{className:"card",children:[e!==void 0&&l.jsx("h2",{className:"card__title",children:e}),t!==void 0&&l.jsx("p",{className:"card__lede",children:t}),s]})}const T2={ok:"✓",warn:"⚠",fail:"✕",running:"◐"};function Gs({state:e,what:t,value:s,status:n,action:a}){return l.jsxs("div",{className:`ck ck--${e}`,children:[l.jsx("span",{className:"ck__glyph","aria-hidden":"true",children:T2[e]}),l.jsx("span",{className:"ck__what",children:t}),l.jsx("span",{className:"ck__val",children:s}),l.jsx("span",{className:"ck__st",children:n}),a!==void 0&&l.jsx("span",{className:"ck__act",children:a})]})}function Vo({label:e,children:t}){return l.jsx("div",{className:"check",role:"group","aria-label":e,children:t})}function kt({tone:e="neutral",dot:t=!1,children:s}){const n=e==="neutral"?"":` chip--${e}`;return l.jsxs("span",{className:`chip${n}`,children:[t&&l.jsx("span",{className:"chip__dot","aria-hidden":"true"}),s]})}function j0({title:e,description:t,meta:s,glyph:n,selected:a,onSelect:c,disabled:h=!1}){return l.jsxs("button",{type:"button",role:"radio","aria-checked":a,className:`choice${a?" is-on":""}`,disabled:h,onClick:c,children:[l.jsxs("span",{className:"choice__top",children:[n,l.jsx("span",{className:"choice__t",children:e}),l.jsx("span",{className:"choice__mark","aria-hidden":"true",children:a?"◉":"○"})]}),t!==void 0&&l.jsx("span",{className:"choice__d",children:t}),s!==void 0&&l.jsx("span",{className:"choice__meta",children:s})]})}function O2({label:e,columns:t=2,children:s}){return l.jsx("div",{className:`choices${t===2?" choices--2":""}`,role:"radiogroup","aria-label":e,children:s})}function A2({title:e,children:t,onUnderstood:s,onNever:n}){return l.jsxs("div",{className:"coach",role:"note",children:[l.jsxs("span",{className:"coach__t",children:[l.jsx("span",{"aria-hidden":"true",children:"◆"}),e]}),l.jsx("span",{className:"coach__b",children:t}),l.jsxs("span",{className:"coach__acts",children:[l.jsx(ce,{size:"sm",variant:"primary",onClick:s,children:"entendi"}),n!==void 0&&l.jsx(ce,{size:"sm",variant:"ghost",onClick:n,children:"não mostrar de novo"})]})]})}function y_({command:e}){const[t,s]=j.useState(!1);j.useEffect(()=>s(!1),[e]),j.useEffect(()=>{if(!t)return;const a=setTimeout(()=>s(!1),1500);return()=>clearTimeout(a)},[t]);const n=navigator.clipboard;return l.jsxs("div",{className:"copy",children:[l.jsx("code",{className:"copy__cmd",children:e}),n!==void 0&&l.jsx(ce,{size:"sm",variant:"ghost",onClick:()=>{n.writeText(e).then(()=>s(!0),()=>s(!1))},children:t?"copiado":"copiar"})]})}function xw({path:e}){const[t,s]=j.useState(!1);j.useEffect(()=>s(!1),[e]),j.useEffect(()=>{if(!t)return;const a=setTimeout(()=>s(!1),1500);return()=>clearTimeout(a)},[t]);const n=navigator.clipboard;return l.jsxs("span",{className:"path",children:[l.jsx("span",{className:"path__value",children:e}),n!==void 0&&l.jsx("button",{type:"button",className:"path__copy","aria-label":t?"caminho copiado":"copiar caminho",onClick:()=>{n.writeText(e).then(()=>s(!0),()=>s(!1))},children:l.jsx("span",{"aria-hidden":"true",children:t?"✓":"⧉"})})]})}function hs({title:e,children:t,action:s}){return l.jsxs("div",{className:"empty",children:[l.jsx("span",{className:"empty__title",children:e}),t!==void 0&&l.jsx("span",{children:t}),s]})}function ys({widths:e=["70%","40%","100%","70%"],label:t="carregando"}){return l.jsx("div",{role:"status","aria-label":t,children:e.map((s,n)=>l.jsx("div",{className:"skeleton",style:{width:s}},n))})}function $t({id:e,label:t,error:s,hint:n,children:a}){return l.jsxs("div",{className:"field",children:[l.jsx("label",{className:"field__label",htmlFor:e,children:t}),a,n!==void 0&&l.jsx("span",{className:"field__hint",id:`${e}-hint`,children:n}),s!==void 0&&l.jsx("span",{className:"field__error",id:`${e}-error`,role:"alert",children:s})]})}function ts({invalid:e=!1,className:t,id:s,...n}){const a=["input",e?"input--error":"",t??""].filter(Boolean).join(" ");return l.jsx("input",{id:s,className:a,"aria-invalid":e||void 0,"aria-describedby":e&&s!==void 0?`${s}-error`:void 0,...n})}function $e({tone:e="none",children:t}){const s=e==="none"?"":` glyph--${e}`;return l.jsx("span",{className:`glyph${s}`,"aria-hidden":"true",children:t})}function ww({name:e,glyph:t,detail:s,state:n,age:a,onSelect:c,action:h}){const d=l.jsxs(l.Fragment,{children:[t,l.jsx("span",{className:"item__name",children:e}),s!==void 0&&l.jsx("span",{className:"item__detail",title:s,children:s}),n!==void 0&&l.jsx("span",{className:`item__state state--${n.tone}`,children:n.label}),a!==void 0&&l.jsx("span",{className:"item__age",children:a})]});return l.jsxs("div",{className:"item",children:[c===void 0?l.jsx("span",{className:"item__main",children:d}):l.jsx("button",{type:"button",className:"item__main",onClick:c,children:d}),h!==void 0&&l.jsx("span",{className:"item__act",children:h})]})}function b_({label:e,children:t}){return l.jsx("div",{className:"menu",role:"menu","aria-label":e,children:t})}function dn({children:e,onSelect:t,glyph:s,hint:n,disabled:a=!1}){return l.jsxs("button",{type:"button",role:"menuitem",className:"menu__item",disabled:a,onClick:t,children:[s,e,n!==void 0&&l.jsx("span",{className:"menu__hint",title:typeof n=="string"?n:void 0,children:n})]})}const k0='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Ah({open:e,title:t,where:s,onClose:n,dismissible:a=!0,reason:c,footer:h,children:d}){const f=j.useRef(null),m=j.useRef(null);if(j.useEffect(()=>{var S;if(!e)return;m.current=document.activeElement;const v=f.current;return(S=(v==null?void 0:v.querySelector("[data-modal-focus]"))??(v==null?void 0:v.querySelector(k0)))==null||S.focus(),()=>{var x;(x=m.current)==null||x.focus(),m.current=null}},[e]),j.useEffect(()=>{if(!e)return;const v=b=>{var N,L;if(b.key==="Escape"){if(!a)return;b.preventDefault(),n();return}if(b.key!=="Tab")return;const S=[...((N=f.current)==null?void 0:N.querySelectorAll(k0))??[]];if(S.length===0)return;const x=S[0],w=S[S.length-1],k=document.activeElement;b.shiftKey&&(k===x||!((L=f.current)!=null&&L.contains(k)))?(b.preventDefault(),w.focus()):!b.shiftKey&&k===w&&(b.preventDefault(),x.focus())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[e,a,n]),!e)return null;const g=`modal-title-${t.replace(/\s+/g,"-").toLowerCase()}`;return l.jsxs("div",{className:"modal",children:[l.jsx("div",{className:"modal__scrim","aria-hidden":"true",onClick:a?n:void 0}),l.jsxs("div",{className:"modal__card",ref:f,role:"dialog","aria-modal":"true","aria-labelledby":g,children:[l.jsx("div",{className:"modal__head",children:l.jsxs("div",{className:"modal__head-b",children:[l.jsx("h3",{className:"modal__t",id:g,children:t}),s!==void 0&&l.jsx("p",{className:"modal__where",children:s})]})}),l.jsx("div",{className:"modal__body",children:d}),l.jsxs("div",{className:"modal__foot",children:[h,l.jsx("span",{className:a?"modal__esc":"modal__esc modal__esc--held",children:a?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"kbd",children:"Esc"})," fecha"]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"kbd",children:"Esc"})," ",c??"não fecha agora"]})})]}),l.jsx("button",{type:"button",className:"modal__close","aria-label":"fechar",disabled:!a,onClick:n,children:"✕"})]})]})}function ma({entries:e,variant:t="meta"}){return t==="recap"?l.jsx("dl",{className:"recap",children:e.map(s=>l.jsxs("div",{className:"recap__r",children:[l.jsx("dt",{className:"recap__k",children:s.label}),l.jsx("dd",{className:"recap__v",title:s.title,children:s.value})]},s.label))}):l.jsx("dl",{className:"meta",children:e.map(s=>l.jsxs(j.Fragment,{children:[l.jsx("dt",{children:s.label}),l.jsx("dd",{title:s.title,children:s.value})]},s.label))})}function Yo({depth:e,label:t,onSelect:s,selected:n=!1,muted:a=!1,emphasis:c=!1,expanded:h,onToggle:d,glyph:f,meta:m,count:g,countTone:v="running",action:b,reserveAction:S=!1}){const x=["row",n?"row--selected":"",a?"row--muted":"",c?"row--emphasis":""].filter(Boolean).join(" "),w=h!==void 0&&d!==void 0;return l.jsxs("div",{className:x,style:{"--depth":e},children:[w?l.jsx("button",{type:"button",className:"row__twist","aria-expanded":h,"aria-label":`${h?"recolher":"expandir"} ${t}`,onClick:d,children:l.jsx("span",{"aria-hidden":"true",children:h?"▾":"▸"})}):l.jsx("span",{className:"row__twist row__twist--empty","aria-hidden":"true"}),l.jsxs("button",{type:"button",className:"row__main","aria-current":n,onClick:s,children:[f,l.jsx("span",{className:"row__label",children:t}),m!==void 0&&l.jsx("span",{className:"row__meta",children:m}),g!==void 0&&g>0&&l.jsxs("span",{className:`row__count row__count--${v}`,children:[l.jsx("span",{className:"row__count__dot","aria-hidden":"true"}),g,l.jsx("span",{className:"sr-only",children:v==="asking"?g===1?" sessão esperando permissão":" sessões esperando permissão":g===1?" sessão rodando":" sessões rodando"})]})]}),b??(S?l.jsx("span",{className:"row__slot","aria-hidden":"true"}):null)]})}function bn({title:e,count:t,aside:s}){return l.jsxs("div",{className:"section-head",children:[l.jsx("span",{className:"section-head__title",children:e}),t!==void 0&&l.jsx("span",{className:"section-head__count",children:t}),s!==void 0&&l.jsx("span",{className:"section-head__aside",children:s})]})}function R2({steps:e,current:t}){return l.jsx("div",{className:"steps","aria-hidden":"true",children:e.map((s,n)=>{const a=n<t?" steps__i--done":n===t?" steps__i--now":"";return l.jsxs(j.Fragment,{children:[l.jsxs("span",{className:`steps__i${a}`,children:[l.jsx("span",{className:"steps__n",children:n<t?"✓":n+1}),l.jsx("span",{className:"steps__l",children:s})]}),n<e.length-1&&l.jsx("span",{className:"steps__bar"})]},s)})})}function N0({label:e,onSelect:t,glyph:s,ordinal:n,active:a=!1,state:c,stateLabel:h,note:d,onClose:f}){return l.jsxs("div",{className:`tab-item${a?" tab-item--active":""}`,children:[l.jsxs("button",{type:"button",role:"tab","aria-selected":a,className:"tab-item__main",onClick:t,children:[s,l.jsx("span",{className:"tab-item__label",children:e}),n!==void 0&&l.jsx("span",{className:"tab-item__ord",children:n}),d!==void 0&&l.jsx("span",{className:"tab-item__note",children:d}),c!==void 0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:`tab-item__dot tab-item__dot--${c}`}),h!==void 0&&l.jsx("span",{className:"sr-only",children:h})]})]}),f!==void 0&&l.jsx("button",{type:"button",className:"tab-item__close","aria-label":`fechar ${e}`,onClick:f,children:l.jsx("span",{"aria-hidden":"true",children:"✕"})})]})}function D2({label:e,lead:t,children:s,action:n,end:a}){return l.jsxs("div",{className:"tabs-bar",role:"tablist","aria-label":e,children:[t!==void 0&&l.jsxs(l.Fragment,{children:[t,l.jsx("span",{className:"tabs-bar__sep","aria-hidden":"true"})]}),l.jsx("div",{className:"tabs-bar__scroll",children:s}),n!==void 0&&l.jsx("span",{className:"tabs-bar__action",children:n}),a!==void 0&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tabs-bar__sep","aria-hidden":"true"}),l.jsx("span",{className:"tabs-bar__end",children:a})]})]})}function M2({label:e,pressed:t,onToggle:s,children:n}){return l.jsx("button",{type:"button",className:"tab-toggle","aria-pressed":t,"aria-label":`${t?"fechar":"abrir"} ${e}`,onClick:s,children:l.jsx("span",{"aria-hidden":"true",children:n})})}function B2({eyebrow:e,title:t,lede:s,narrow:n=!1,children:a,footer:c}){return l.jsxs("div",{className:`wizard__card${n?" wizard__card--narrow":""}`,children:[l.jsxs("div",{className:"wizard__head",children:[e!==void 0&&l.jsx("span",{className:"wizard__eyebrow",children:e}),l.jsx("h2",{className:"wizard__title",children:t}),s!==void 0&&l.jsx("p",{className:"wizard__lede",children:s})]}),a,c!==void 0&&l.jsx("div",{className:"wizard__foot",children:c})]})}function na({title:e,children:t}){return l.jsxs("section",{className:"wizard__sec",children:[l.jsx("span",{className:"wizard__sec-t",children:e}),t]})}function L2({job:e}){const t=e.percent,s=e.phase===null?null:w2[e.phase]??e.phase;return l.jsxs("div",{className:"modal__work","data-state":e.state,"aria-label":`clonando ${e.name}`,children:[l.jsxs("div",{className:"modal__work-top",children:[l.jsx($e,{tone:"project",children:"■"}),l.jsx("span",{className:"modal__work-name",children:e.name}),t!==null&&l.jsxs("span",{className:"modal__work-pct",children:[t,"%"]})]}),l.jsx("div",{className:t===null?"bar bar--unknown":"bar",children:l.jsx("div",{className:"bar__fill",style:t===null?void 0:{width:`${t}%`}})}),l.jsx("p",{className:"modal__work-phase",children:e.state==="registering"?"registrando":s??"conectando"})]})}function E0(e){return e.state==="cancelled"?!1:e.state!=="done"?!0:e.message!==null&&e.message.includes("registrado como")}function q2({job:e,onDismiss:t,onRetry:s}){if(e.state==="done")return e.message===null||!e.message.includes("registrado como")?null:l.jsxs("div",{className:"clone-outcome clone-outcome--done",role:"status",children:[l.jsx("p",{className:"clone-outcome__body",children:e.message}),l.jsx(ce,{variant:"ghost",size:"sm",onClick:t,children:"entendi"})]});const n=e.failure==="auth"?P2(e.url):null;return l.jsxs("div",{className:"clone-outcome clone-outcome--failed",role:"alert",children:[l.jsx("p",{className:"clone-outcome__title",children:e.failure==="auth"?`não consegui autenticar em ${z2(e.url)}`:`não deu para clonar ${e.name}`}),e.failure==="auth"&&l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"clone-outcome__body",children:"O Lumem usa as credenciais que já estão na sua máquina — ele não guarda token nenhum. Duas saídas:"}),l.jsxs("ul",{className:"clone-outcome__ways",children:[l.jsx("li",{children:"usar a URL ssh do mesmo repositório, com a chave no ssh-agent;"}),l.jsx("li",{children:"configurar um credential.helper para https."})]})]}),e.message!==null&&l.jsx("code",{className:"clone-outcome__git",children:e.message}),l.jsxs("div",{className:"clone-outcome__actions",children:[n!==null&&s!==void 0&&l.jsx(ce,{variant:"primary",size:"sm",onClick:()=>s(n),children:"tentar por ssh"}),l.jsx(ce,{variant:"ghost",size:"sm",onClick:t,children:"dispensar"})]}),n!==null&&l.jsx("p",{className:"clone-outcome__path",children:n})]})}function z2(e){try{return new URL(e).host}catch{return e}}function P2(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const s=t.pathname.replace(/^\/+/,"");return s===""?null:t.port!==""?`ssh://git@${t.hostname}:${t.port}/${s}`:`git@${t.hostname}:${s}`}const H2=250;function F2({workspaceId:e,workspaceName:t,open:s,onClose:n,onRequestOpen:a,onAdded:c,prefill:h=null,onPrefillConsumed:d}){const f=qe(),[m,g]=j.useState(""),[v,b]=j.useState(""),[S,x]=j.useState(null),[w,k]=j.useState(null),N=N2(e),L=N!==null&&!hh(N.state)?N:null,R=N!==null&&N.id!==S&&hh(N.state)&&E0(N)?N:null,D=U2(e,m,v);j.useEffect(()=>{h!==null&&(g(h),b(""),d==null||d())},[h,d]),j.useEffect(()=>{s||(L!==null||R!==null)&&a()},[L,R,s,a]),j.useEffect(()=>{L!==null&&k(L.id)},[L==null?void 0:L.id]);const Y=Te({mutationFn:()=>te.project.add.mutate({workspaceId:e,path:(D==null?void 0:D.kind)==="path"?D.path:m.trim(),...v.trim()===""?{}:{name:v.trim()}}),onSuccess:async F=>{await f.invalidateQueries({queryKey:gn(e)}),c(F.id),Q()}}),K=Te({mutationFn:()=>te.project.clone.mutate({workspaceId:e,source:m.trim(),...v.trim()===""?{}:{name:v.trim()}}),onSuccess:async()=>{x(null),await f.invalidateQueries({queryKey:uh(e)})}}),Z=Te({mutationFn:F=>te.project.cloneCancel.mutate({jobId:F}),onSuccess:()=>f.invalidateQueries({queryKey:uh(e)})});j.useEffect(()=>{!s||N===null||N.id!==w||N.state!=="done"||E0(N)&&N.id!==S||(f.invalidateQueries({queryKey:gn(e)}),k(null),Q())},[s,w,N==null?void 0:N.id,N==null?void 0:N.state,S]);function Q(){R!==null&&x(R.id),g(""),b(""),Y.reset(),K.reset(),n()}const z=(D==null?void 0:D.kind)==="url",G=(D==null?void 0:D.kind)==="refused",le=m.trim().startsWith("/")||m.trim().startsWith("~"),H=D===null&&!le&&m.trim()!=="",O=Y.isPending||K.isPending,W=Y.isError?Y.error.message:K.isError?K.error.message:void 0,ee=L!==null,T=F=>{F.preventDefault(),!(m.trim()===""||G||H)&&(z?K.mutate():Y.mutate())};return l.jsxs(Ah,{open:s,title:"Adicionar projeto",where:l.jsxs(l.Fragment,{children:["no workspace",l.jsx($e,{tone:"workspace",children:"◈"}),l.jsx("b",{children:t})]}),onClose:Q,dismissible:!ee,reason:"não fecha enquanto clona",footer:ee?L.state==="cloning"?l.jsx(ce,{variant:"ghost",onClick:()=>Z.mutate(L.id),children:"cancelar o clone"}):null:l.jsxs(l.Fragment,{children:[l.jsx(ce,{type:"submit",form:T0,variant:"primary",disabled:O||m.trim()===""||G||H,children:Y.isPending?"validando…":z?"clonar":"adicionar"}),l.jsx(ce,{variant:"ghost",onClick:Q,children:"cancelar"})]}),children:[R!==null&&l.jsx(q2,{job:R,onDismiss:()=>x(R.id),onRetry:F=>{x(R.id),g(F)}}),ee?l.jsx(L2,{job:L}):l.jsxs("form",{id:T0,className:"add-project",onSubmit:T,children:[l.jsx($t,{id:"project-source",label:"Caminho ou URL",error:W,children:l.jsx(ts,{id:"project-source",value:m,onChange:F=>g(F.target.value),placeholder:"git@gitlab.interno:time/api.git",invalid:G||Y.isError||K.isError})}),D!==null&&l.jsx(I2,{plan:D}),l.jsx($t,{id:"project-name",label:"Nome",children:l.jsx(ts,{id:"project-name",value:v,onChange:F=>b(F.target.value),placeholder:z?D.name??"o nome do repositório":"o nome da pasta"})}),z&&l.jsxs("p",{className:"add-project__answer",children:[l.jsx("span",{className:"add-project__answer-label",children:"Vai em"}),l.jsx("span",{className:"add-project__answer-path",children:D.targetPath})]})]})]})}const T0="add-project";function I2({plan:e}){return e.kind==="refused"?l.jsxs("p",{className:"echo echo--refused",role:"status",children:[l.jsx("span",{className:"echo__arrow","aria-hidden":"true",children:"↳"}),e.message]}):e.kind==="path"?l.jsxs("p",{className:"echo",children:[l.jsx("span",{className:"echo__arrow","aria-hidden":"true",children:"↳"}),"registrar o repositório em ",l.jsx("strong",{children:e.path})]}):l.jsxs("p",{className:"echo",children:[l.jsx("span",{className:"echo__arrow","aria-hidden":"true",children:"↳"}),"clonar via ",e.scheme,e.insecure===!0&&l.jsx(kt,{tone:"insecure",children:"sem TLS"})]})}function U2(e,t,s){const[n,a]=j.useState("");return j.useEffect(()=>{const h=setTimeout(()=>a(t.trim()),H2);return()=>clearTimeout(h)},[t]),ye({queryKey:["project","parseSource",e,n,s.trim()],queryFn:()=>te.project.parseSource.query({workspaceId:e,source:n,...s.trim()===""?{}:{name:s.trim()}}),enabled:n!==""}).data??null}var Je;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function s(a){throw new Error}e.assertNever=s,e.arrayToEnum=a=>{const c={};for(const h of a)c[h]=h;return c},e.getValidEnumValues=a=>{const c=e.objectKeys(a).filter(d=>typeof a[a[d]]!="number"),h={};for(const d of c)h[d]=a[d];return e.objectValues(h)},e.objectValues=a=>e.objectKeys(a).map(function(c){return a[c]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const c=[];for(const h in a)Object.prototype.hasOwnProperty.call(a,h)&&c.push(h);return c},e.find=(a,c)=>{for(const h of a)if(c(h))return h},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,c=" | "){return a.map(h=>typeof h=="string"?`'${h}'`:h).join(c)}e.joinValues=n,e.jsonStringifyReplacer=(a,c)=>typeof c=="bigint"?c.toString():c})(Je||(Je={}));var O0;(function(e){e.mergeShapes=(t,s)=>({...t,...s})})(O0||(O0={}));const Se=Je.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Zr=e=>{switch(typeof e){case"undefined":return Se.undefined;case"string":return Se.string;case"number":return Number.isNaN(e)?Se.nan:Se.number;case"boolean":return Se.boolean;case"function":return Se.function;case"bigint":return Se.bigint;case"symbol":return Se.symbol;case"object":return Array.isArray(e)?Se.array:e===null?Se.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Se.promise:typeof Map<"u"&&e instanceof Map?Se.map:typeof Set<"u"&&e instanceof Set?Se.set:typeof Date<"u"&&e instanceof Date?Se.date:Se.object;default:return Se.unknown}},ue=Je.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class vr extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=t}format(t){const s=t||function(c){return c.message},n={_errors:[]},a=c=>{for(const h of c.issues)if(h.code==="invalid_union")h.unionErrors.map(a);else if(h.code==="invalid_return_type")a(h.returnTypeError);else if(h.code==="invalid_arguments")a(h.argumentsError);else if(h.path.length===0)n._errors.push(s(h));else{let d=n,f=0;for(;f<h.path.length;){const m=h.path[f];f===h.path.length-1?(d[m]=d[m]||{_errors:[]},d[m]._errors.push(s(h))):d[m]=d[m]||{_errors:[]},d=d[m],f++}}};return a(this),n}static assert(t){if(!(t instanceof vr))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Je.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=s=>s.message){const s={},n=[];for(const a of this.issues)if(a.path.length>0){const c=a.path[0];s[c]=s[c]||[],s[c].push(t(a))}else n.push(t(a));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}vr.create=e=>new vr(e);const np=(e,t)=>{let s;switch(e.code){case ue.invalid_type:e.received===Se.undefined?s="Required":s=`Expected ${e.expected}, received ${e.received}`;break;case ue.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,Je.jsonStringifyReplacer)}`;break;case ue.unrecognized_keys:s=`Unrecognized key(s) in object: ${Je.joinValues(e.keys,", ")}`;break;case ue.invalid_union:s="Invalid input";break;case ue.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${Je.joinValues(e.options)}`;break;case ue.invalid_enum_value:s=`Invalid enum value. Expected ${Je.joinValues(e.options)}, received '${e.received}'`;break;case ue.invalid_arguments:s="Invalid function arguments";break;case ue.invalid_return_type:s="Invalid function return type";break;case ue.invalid_date:s="Invalid date";break;case ue.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(s=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?s=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?s=`Invalid input: must end with "${e.validation.endsWith}"`:Je.assertNever(e.validation):e.validation!=="regex"?s=`Invalid ${e.validation}`:s="Invalid";break;case ue.too_small:e.type==="array"?s=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?s=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?s=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?s=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?s=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:s="Invalid input";break;case ue.too_big:e.type==="array"?s=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?s=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?s=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?s=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?s=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:s="Invalid input";break;case ue.custom:s="Invalid input";break;case ue.invalid_intersection_types:s="Intersection results could not be merged";break;case ue.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case ue.not_finite:s="Number must be finite";break;default:s=t.defaultError,Je.assertNever(e)}return{message:s}};let K2=np;function $2(){return K2}const W2=e=>{const{data:t,path:s,errorMaps:n,issueData:a}=e,c=[...s,...a.path||[]],h={...a,path:c};if(a.message!==void 0)return{...a,path:c,message:a.message};let d="";const f=n.filter(m=>!!m).slice().reverse();for(const m of f)d=m(h,{data:t,defaultError:d}).message;return{...a,path:c,message:d}};function me(e,t){const s=$2(),n=W2({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===np?void 0:np].filter(a=>!!a)});e.common.issues.push(n)}class Qs{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,s){const n=[];for(const a of s){if(a.status==="aborted")return Re;a.status==="dirty"&&t.dirty(),n.push(a.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,s){const n=[];for(const a of s){const c=await a.key,h=await a.value;n.push({key:c,value:h})}return Qs.mergeObjectSync(t,n)}static mergeObjectSync(t,s){const n={};for(const a of s){const{key:c,value:h}=a;if(c.status==="aborted"||h.status==="aborted")return Re;c.status==="dirty"&&t.dirty(),h.status==="dirty"&&t.dirty(),c.value!=="__proto__"&&(typeof h.value<"u"||a.alwaysSet)&&(n[c.value]=h.value)}return{status:t.value,value:n}}}const Re=Object.freeze({status:"aborted"}),Do=e=>({status:"dirty",value:e}),fi=e=>({status:"valid",value:e}),A0=e=>e.status==="aborted",R0=e=>e.status==="dirty",xl=e=>e.status==="valid",dh=e=>typeof Promise<"u"&&e instanceof Promise;var Ce;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Ce||(Ce={}));class vn{constructor(t,s,n,a){this._cachedPath=[],this.parent=t,this.data=s,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const D0=(e,t)=>{if(xl(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const s=new vr(e.common.issues);return this._error=s,this._error}}};function Fe(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:n,description:a}=e;if(t&&(s||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(h,d)=>{const{message:f}=e;return h.code==="invalid_enum_value"?{message:f??d.defaultError}:typeof d.data>"u"?{message:f??n??d.defaultError}:h.code!=="invalid_type"?{message:d.defaultError}:{message:f??s??d.defaultError}},description:a}}class Ze{get description(){return this._def.description}_getType(t){return Zr(t.data)}_getOrReturnCtx(t,s){return s||{common:t.parent.common,data:t.data,parsedType:Zr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Qs,ctx:{common:t.parent.common,data:t.data,parsedType:Zr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const s=this._parse(t);if(dh(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(t){const s=this._parse(t);return Promise.resolve(s)}parse(t,s){const n=this.safeParse(t,s);if(n.success)return n.data;throw n.error}safeParse(t,s){const n={common:{issues:[],async:(s==null?void 0:s.async)??!1,contextualErrorMap:s==null?void 0:s.errorMap},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Zr(t)},a=this._parseSync({data:t,path:n.path,parent:n});return D0(n,a)}"~validate"(t){var n,a;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Zr(t)};if(!this["~standard"].async)try{const c=this._parseSync({data:t,path:[],parent:s});return xl(c)?{value:c.value}:{issues:s.common.issues}}catch(c){(a=(n=c==null?void 0:c.message)==null?void 0:n.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:s}).then(c=>xl(c)?{value:c.value}:{issues:s.common.issues})}async parseAsync(t,s){const n=await this.safeParseAsync(t,s);if(n.success)return n.data;throw n.error}async safeParseAsync(t,s){const n={common:{issues:[],contextualErrorMap:s==null?void 0:s.errorMap,async:!0},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Zr(t)},a=this._parse({data:t,path:n.path,parent:n}),c=await(dh(a)?a:Promise.resolve(a));return D0(n,c)}refine(t,s){const n=a=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(a):s;return this._refinement((a,c)=>{const h=t(a),d=()=>c.addIssue({code:ue.custom,...n(a)});return typeof Promise<"u"&&h instanceof Promise?h.then(f=>f?!0:(d(),!1)):h?!0:(d(),!1)})}refinement(t,s){return this._refinement((n,a)=>t(n)?!0:(a.addIssue(typeof s=="function"?s(n,a):s),!1))}_refinement(t){return new oa({schema:this,typeName:De.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:s=>this["~validate"](s)}}optional(){return pr.create(this,this._def)}nullable(){return ca.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qi.create(this)}promise(){return gh.create(this,this._def)}or(t){return mh.create([this,t],this._def)}and(t){return ph.create(this,t,this._def)}transform(t){return new oa({...Fe(this._def),schema:this,typeName:De.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const s=typeof t=="function"?t:()=>t;return new vh({...Fe(this._def),innerType:this,defaultValue:s,typeName:De.ZodDefault})}brand(){return new Nw({typeName:De.ZodBranded,type:this,...Fe(this._def)})}catch(t){const s=typeof t=="function"?t:()=>t;return new yh({...Fe(this._def),innerType:this,catchValue:s,typeName:De.ZodCatch})}describe(t){const s=this.constructor;return new s({...this._def,description:t})}pipe(t){return x_.create(this,t)}readonly(){return bh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const V2=/^c[^\s-]{8,}$/i,Y2=/^[0-9a-z]+$/,G2=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Q2=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Z2=/^[a-z0-9_-]{21}$/i,X2=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,J2=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,eT=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,tT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let hm;const sT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,iT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,rT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,nT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,aT=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lT=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Cw="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",oT=new RegExp(`^${Cw}$`);function jw(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const s=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${s}`}function cT(e){return new RegExp(`^${jw(e)}$`)}function uT(e){let t=`${Cw}T${jw(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function hT(e,t){return!!((t==="v4"||!t)&&sT.test(e)||(t==="v6"||!t)&&rT.test(e))}function dT(e,t){if(!X2.test(e))return!1;try{const[s]=e.split(".");if(!s)return!1;const n=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function fT(e,t){return!!((t==="v4"||!t)&&iT.test(e)||(t==="v6"||!t)&&nT.test(e))}class fn extends Ze{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Se.string){const c=this._getOrReturnCtx(t);return me(c,{code:ue.invalid_type,expected:Se.string,received:c.parsedType}),Re}const n=new Qs;let a;for(const c of this._def.checks)if(c.kind==="min")t.data.length<c.value&&(a=this._getOrReturnCtx(t,a),me(a,{code:ue.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),n.dirty());else if(c.kind==="max")t.data.length>c.value&&(a=this._getOrReturnCtx(t,a),me(a,{code:ue.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),n.dirty());else if(c.kind==="length"){const h=t.data.length>c.value,d=t.data.length<c.value;(h||d)&&(a=this._getOrReturnCtx(t,a),h?me(a,{code:ue.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}):d&&me(a,{code:ue.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}),n.dirty())}else if(c.kind==="email")eT.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"email",code:ue.invalid_string,message:c.message}),n.dirty());else if(c.kind==="emoji")hm||(hm=new RegExp(tT,"u")),hm.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"emoji",code:ue.invalid_string,message:c.message}),n.dirty());else if(c.kind==="uuid")Q2.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"uuid",code:ue.invalid_string,message:c.message}),n.dirty());else if(c.kind==="nanoid")Z2.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"nanoid",code:ue.invalid_string,message:c.message}),n.dirty());else if(c.kind==="cuid")V2.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"cuid",code:ue.invalid_string,message:c.message}),n.dirty());else if(c.kind==="cuid2")Y2.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"cuid2",code:ue.invalid_string,message:c.message}),n.dirty());else if(c.kind==="ulid")G2.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"ulid",code:ue.invalid_string,message:c.message}),n.dirty());else if(c.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),me(a,{validation:"url",code:ue.invalid_string,message:c.message}),n.dirty()}else c.kind==="regex"?(c.regex.lastIndex=0,c.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"regex",code:ue.invalid_string,message:c.message}),n.dirty())):c.kind==="trim"?t.data=t.data.trim():c.kind==="includes"?t.data.includes(c.value,c.position)||(a=this._getOrReturnCtx(t,a),me(a,{code:ue.invalid_string,validation:{includes:c.value,position:c.position},message:c.message}),n.dirty()):c.kind==="toLowerCase"?t.data=t.data.toLowerCase():c.kind==="toUpperCase"?t.data=t.data.toUpperCase():c.kind==="startsWith"?t.data.startsWith(c.value)||(a=this._getOrReturnCtx(t,a),me(a,{code:ue.invalid_string,validation:{startsWith:c.value},message:c.message}),n.dirty()):c.kind==="endsWith"?t.data.endsWith(c.value)||(a=this._getOrReturnCtx(t,a),me(a,{code:ue.invalid_string,validation:{endsWith:c.value},message:c.message}),n.dirty()):c.kind==="datetime"?uT(c).test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{code:ue.invalid_string,validation:"datetime",message:c.message}),n.dirty()):c.kind==="date"?oT.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{code:ue.invalid_string,validation:"date",message:c.message}),n.dirty()):c.kind==="time"?cT(c).test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{code:ue.invalid_string,validation:"time",message:c.message}),n.dirty()):c.kind==="duration"?J2.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"duration",code:ue.invalid_string,message:c.message}),n.dirty()):c.kind==="ip"?hT(t.data,c.version)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"ip",code:ue.invalid_string,message:c.message}),n.dirty()):c.kind==="jwt"?dT(t.data,c.alg)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"jwt",code:ue.invalid_string,message:c.message}),n.dirty()):c.kind==="cidr"?fT(t.data,c.version)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"cidr",code:ue.invalid_string,message:c.message}),n.dirty()):c.kind==="base64"?aT.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"base64",code:ue.invalid_string,message:c.message}),n.dirty()):c.kind==="base64url"?lT.test(t.data)||(a=this._getOrReturnCtx(t,a),me(a,{validation:"base64url",code:ue.invalid_string,message:c.message}),n.dirty()):Je.assertNever(c);return{status:n.value,value:t.data}}_regex(t,s,n){return this.refinement(a=>t.test(a),{validation:s,code:ue.invalid_string,...Ce.errToObj(n)})}_addCheck(t){return new fn({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ce.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ce.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ce.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ce.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ce.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ce.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ce.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ce.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ce.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ce.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ce.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ce.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ce.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Ce.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Ce.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Ce.errToObj(t)})}regex(t,s){return this._addCheck({kind:"regex",regex:t,...Ce.errToObj(s)})}includes(t,s){return this._addCheck({kind:"includes",value:t,position:s==null?void 0:s.position,...Ce.errToObj(s==null?void 0:s.message)})}startsWith(t,s){return this._addCheck({kind:"startsWith",value:t,...Ce.errToObj(s)})}endsWith(t,s){return this._addCheck({kind:"endsWith",value:t,...Ce.errToObj(s)})}min(t,s){return this._addCheck({kind:"min",value:t,...Ce.errToObj(s)})}max(t,s){return this._addCheck({kind:"max",value:t,...Ce.errToObj(s)})}length(t,s){return this._addCheck({kind:"length",value:t,...Ce.errToObj(s)})}nonempty(t){return this.min(1,Ce.errToObj(t))}trim(){return new fn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new fn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new fn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const s of this._def.checks)s.kind==="min"&&(t===null||s.value>t)&&(t=s.value);return t}get maxLength(){let t=null;for(const s of this._def.checks)s.kind==="max"&&(t===null||s.value<t)&&(t=s.value);return t}}fn.create=e=>new fn({checks:[],typeName:De.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Fe(e)});function mT(e,t){const s=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,a=s>n?s:n,c=Number.parseInt(e.toFixed(a).replace(".","")),h=Number.parseInt(t.toFixed(a).replace(".",""));return c%h/10**a}class wl extends Ze{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Se.number){const c=this._getOrReturnCtx(t);return me(c,{code:ue.invalid_type,expected:Se.number,received:c.parsedType}),Re}let n;const a=new Qs;for(const c of this._def.checks)c.kind==="int"?Je.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),me(n,{code:ue.invalid_type,expected:"integer",received:"float",message:c.message}),a.dirty()):c.kind==="min"?(c.inclusive?t.data<c.value:t.data<=c.value)&&(n=this._getOrReturnCtx(t,n),me(n,{code:ue.too_small,minimum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),a.dirty()):c.kind==="max"?(c.inclusive?t.data>c.value:t.data>=c.value)&&(n=this._getOrReturnCtx(t,n),me(n,{code:ue.too_big,maximum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),a.dirty()):c.kind==="multipleOf"?mT(t.data,c.value)!==0&&(n=this._getOrReturnCtx(t,n),me(n,{code:ue.not_multiple_of,multipleOf:c.value,message:c.message}),a.dirty()):c.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),me(n,{code:ue.not_finite,message:c.message}),a.dirty()):Je.assertNever(c);return{status:a.value,value:t.data}}gte(t,s){return this.setLimit("min",t,!0,Ce.toString(s))}gt(t,s){return this.setLimit("min",t,!1,Ce.toString(s))}lte(t,s){return this.setLimit("max",t,!0,Ce.toString(s))}lt(t,s){return this.setLimit("max",t,!1,Ce.toString(s))}setLimit(t,s,n,a){return new wl({...this._def,checks:[...this._def.checks,{kind:t,value:s,inclusive:n,message:Ce.toString(a)}]})}_addCheck(t){return new wl({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ce.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ce.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ce.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ce.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ce.toString(t)})}multipleOf(t,s){return this._addCheck({kind:"multipleOf",value:t,message:Ce.toString(s)})}finite(t){return this._addCheck({kind:"finite",message:Ce.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ce.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ce.toString(t)})}get minValue(){let t=null;for(const s of this._def.checks)s.kind==="min"&&(t===null||s.value>t)&&(t=s.value);return t}get maxValue(){let t=null;for(const s of this._def.checks)s.kind==="max"&&(t===null||s.value<t)&&(t=s.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Je.isInteger(t.value))}get isFinite(){let t=null,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(s)&&Number.isFinite(t)}}wl.create=e=>new wl({checks:[],typeName:De.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Fe(e)});class Go extends Ze{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Se.bigint)return this._getInvalidInput(t);let n;const a=new Qs;for(const c of this._def.checks)c.kind==="min"?(c.inclusive?t.data<c.value:t.data<=c.value)&&(n=this._getOrReturnCtx(t,n),me(n,{code:ue.too_small,type:"bigint",minimum:c.value,inclusive:c.inclusive,message:c.message}),a.dirty()):c.kind==="max"?(c.inclusive?t.data>c.value:t.data>=c.value)&&(n=this._getOrReturnCtx(t,n),me(n,{code:ue.too_big,type:"bigint",maximum:c.value,inclusive:c.inclusive,message:c.message}),a.dirty()):c.kind==="multipleOf"?t.data%c.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),me(n,{code:ue.not_multiple_of,multipleOf:c.value,message:c.message}),a.dirty()):Je.assertNever(c);return{status:a.value,value:t.data}}_getInvalidInput(t){const s=this._getOrReturnCtx(t);return me(s,{code:ue.invalid_type,expected:Se.bigint,received:s.parsedType}),Re}gte(t,s){return this.setLimit("min",t,!0,Ce.toString(s))}gt(t,s){return this.setLimit("min",t,!1,Ce.toString(s))}lte(t,s){return this.setLimit("max",t,!0,Ce.toString(s))}lt(t,s){return this.setLimit("max",t,!1,Ce.toString(s))}setLimit(t,s,n,a){return new Go({...this._def,checks:[...this._def.checks,{kind:t,value:s,inclusive:n,message:Ce.toString(a)}]})}_addCheck(t){return new Go({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ce.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ce.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ce.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ce.toString(t)})}multipleOf(t,s){return this._addCheck({kind:"multipleOf",value:t,message:Ce.toString(s)})}get minValue(){let t=null;for(const s of this._def.checks)s.kind==="min"&&(t===null||s.value>t)&&(t=s.value);return t}get maxValue(){let t=null;for(const s of this._def.checks)s.kind==="max"&&(t===null||s.value<t)&&(t=s.value);return t}}Go.create=e=>new Go({checks:[],typeName:De.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Fe(e)});class ap extends Ze{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Se.boolean){const n=this._getOrReturnCtx(t);return me(n,{code:ue.invalid_type,expected:Se.boolean,received:n.parsedType}),Re}return fi(t.data)}}ap.create=e=>new ap({typeName:De.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Fe(e)});class fh extends Ze{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Se.date){const c=this._getOrReturnCtx(t);return me(c,{code:ue.invalid_type,expected:Se.date,received:c.parsedType}),Re}if(Number.isNaN(t.data.getTime())){const c=this._getOrReturnCtx(t);return me(c,{code:ue.invalid_date}),Re}const n=new Qs;let a;for(const c of this._def.checks)c.kind==="min"?t.data.getTime()<c.value&&(a=this._getOrReturnCtx(t,a),me(a,{code:ue.too_small,message:c.message,inclusive:!0,exact:!1,minimum:c.value,type:"date"}),n.dirty()):c.kind==="max"?t.data.getTime()>c.value&&(a=this._getOrReturnCtx(t,a),me(a,{code:ue.too_big,message:c.message,inclusive:!0,exact:!1,maximum:c.value,type:"date"}),n.dirty()):Je.assertNever(c);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new fh({...this._def,checks:[...this._def.checks,t]})}min(t,s){return this._addCheck({kind:"min",value:t.getTime(),message:Ce.toString(s)})}max(t,s){return this._addCheck({kind:"max",value:t.getTime(),message:Ce.toString(s)})}get minDate(){let t=null;for(const s of this._def.checks)s.kind==="min"&&(t===null||s.value>t)&&(t=s.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const s of this._def.checks)s.kind==="max"&&(t===null||s.value<t)&&(t=s.value);return t!=null?new Date(t):null}}fh.create=e=>new fh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:De.ZodDate,...Fe(e)});class M0 extends Ze{_parse(t){if(this._getType(t)!==Se.symbol){const n=this._getOrReturnCtx(t);return me(n,{code:ue.invalid_type,expected:Se.symbol,received:n.parsedType}),Re}return fi(t.data)}}M0.create=e=>new M0({typeName:De.ZodSymbol,...Fe(e)});class lp extends Ze{_parse(t){if(this._getType(t)!==Se.undefined){const n=this._getOrReturnCtx(t);return me(n,{code:ue.invalid_type,expected:Se.undefined,received:n.parsedType}),Re}return fi(t.data)}}lp.create=e=>new lp({typeName:De.ZodUndefined,...Fe(e)});class op extends Ze{_parse(t){if(this._getType(t)!==Se.null){const n=this._getOrReturnCtx(t);return me(n,{code:ue.invalid_type,expected:Se.null,received:n.parsedType}),Re}return fi(t.data)}}op.create=e=>new op({typeName:De.ZodNull,...Fe(e)});class B0 extends Ze{constructor(){super(...arguments),this._any=!0}_parse(t){return fi(t.data)}}B0.create=e=>new B0({typeName:De.ZodAny,...Fe(e)});class L0 extends Ze{constructor(){super(...arguments),this._unknown=!0}_parse(t){return fi(t.data)}}L0.create=e=>new L0({typeName:De.ZodUnknown,...Fe(e)});class yn extends Ze{_parse(t){const s=this._getOrReturnCtx(t);return me(s,{code:ue.invalid_type,expected:Se.never,received:s.parsedType}),Re}}yn.create=e=>new yn({typeName:De.ZodNever,...Fe(e)});class q0 extends Ze{_parse(t){if(this._getType(t)!==Se.undefined){const n=this._getOrReturnCtx(t);return me(n,{code:ue.invalid_type,expected:Se.void,received:n.parsedType}),Re}return fi(t.data)}}q0.create=e=>new q0({typeName:De.ZodVoid,...Fe(e)});class qi extends Ze{_parse(t){const{ctx:s,status:n}=this._processInputParams(t),a=this._def;if(s.parsedType!==Se.array)return me(s,{code:ue.invalid_type,expected:Se.array,received:s.parsedType}),Re;if(a.exactLength!==null){const h=s.data.length>a.exactLength.value,d=s.data.length<a.exactLength.value;(h||d)&&(me(s,{code:h?ue.too_big:ue.too_small,minimum:d?a.exactLength.value:void 0,maximum:h?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&s.data.length<a.minLength.value&&(me(s,{code:ue.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&s.data.length>a.maxLength.value&&(me(s,{code:ue.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((h,d)=>a.type._parseAsync(new vn(s,h,s.path,d)))).then(h=>Qs.mergeArray(n,h));const c=[...s.data].map((h,d)=>a.type._parseSync(new vn(s,h,s.path,d)));return Qs.mergeArray(n,c)}get element(){return this._def.type}min(t,s){return new qi({...this._def,minLength:{value:t,message:Ce.toString(s)}})}max(t,s){return new qi({...this._def,maxLength:{value:t,message:Ce.toString(s)}})}length(t,s){return new qi({...this._def,exactLength:{value:t,message:Ce.toString(s)}})}nonempty(t){return this.min(1,t)}}qi.create=(e,t)=>new qi({type:e,minLength:null,maxLength:null,exactLength:null,typeName:De.ZodArray,...Fe(t)});function il(e){if(e instanceof zt){const t={};for(const s in e.shape){const n=e.shape[s];t[s]=pr.create(il(n))}return new zt({...e._def,shape:()=>t})}else return e instanceof qi?new qi({...e._def,type:il(e.element)}):e instanceof pr?pr.create(il(e.unwrap())):e instanceof ca?ca.create(il(e.unwrap())):e instanceof aa?aa.create(e.items.map(t=>il(t))):e}class zt extends Ze{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),s=Je.objectKeys(t);return this._cached={shape:t,keys:s},this._cached}_parse(t){if(this._getType(t)!==Se.object){const m=this._getOrReturnCtx(t);return me(m,{code:ue.invalid_type,expected:Se.object,received:m.parsedType}),Re}const{status:n,ctx:a}=this._processInputParams(t),{shape:c,keys:h}=this._getCached(),d=[];if(!(this._def.catchall instanceof yn&&this._def.unknownKeys==="strip"))for(const m in a.data)h.includes(m)||d.push(m);const f=[];for(const m of h){const g=c[m],v=a.data[m];f.push({key:{status:"valid",value:m},value:g._parse(new vn(a,v,a.path,m)),alwaysSet:m in a.data})}if(this._def.catchall instanceof yn){const m=this._def.unknownKeys;if(m==="passthrough")for(const g of d)f.push({key:{status:"valid",value:g},value:{status:"valid",value:a.data[g]}});else if(m==="strict")d.length>0&&(me(a,{code:ue.unrecognized_keys,keys:d}),n.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const m=this._def.catchall;for(const g of d){const v=a.data[g];f.push({key:{status:"valid",value:g},value:m._parse(new vn(a,v,a.path,g)),alwaysSet:g in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const m=[];for(const g of f){const v=await g.key,b=await g.value;m.push({key:v,value:b,alwaysSet:g.alwaysSet})}return m}).then(m=>Qs.mergeObjectSync(n,m)):Qs.mergeObjectSync(n,f)}get shape(){return this._def.shape()}strict(t){return Ce.errToObj,new zt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(s,n)=>{var c,h;const a=((h=(c=this._def).errorMap)==null?void 0:h.call(c,s,n).message)??n.defaultError;return s.code==="unrecognized_keys"?{message:Ce.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new zt({...this._def,unknownKeys:"strip"})}passthrough(){return new zt({...this._def,unknownKeys:"passthrough"})}extend(t){return new zt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new zt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:De.ZodObject})}setKey(t,s){return this.augment({[t]:s})}catchall(t){return new zt({...this._def,catchall:t})}pick(t){const s={};for(const n of Je.objectKeys(t))t[n]&&this.shape[n]&&(s[n]=this.shape[n]);return new zt({...this._def,shape:()=>s})}omit(t){const s={};for(const n of Je.objectKeys(this.shape))t[n]||(s[n]=this.shape[n]);return new zt({...this._def,shape:()=>s})}deepPartial(){return il(this)}partial(t){const s={};for(const n of Je.objectKeys(this.shape)){const a=this.shape[n];t&&!t[n]?s[n]=a:s[n]=a.optional()}return new zt({...this._def,shape:()=>s})}required(t){const s={};for(const n of Je.objectKeys(this.shape))if(t&&!t[n])s[n]=this.shape[n];else{let c=this.shape[n];for(;c instanceof pr;)c=c._def.innerType;s[n]=c}return new zt({...this._def,shape:()=>s})}keyof(){return kw(Je.objectKeys(this.shape))}}zt.create=(e,t)=>new zt({shape:()=>e,unknownKeys:"strip",catchall:yn.create(),typeName:De.ZodObject,...Fe(t)});zt.strictCreate=(e,t)=>new zt({shape:()=>e,unknownKeys:"strict",catchall:yn.create(),typeName:De.ZodObject,...Fe(t)});zt.lazycreate=(e,t)=>new zt({shape:e,unknownKeys:"strip",catchall:yn.create(),typeName:De.ZodObject,...Fe(t)});class mh extends Ze{_parse(t){const{ctx:s}=this._processInputParams(t),n=this._def.options;function a(c){for(const d of c)if(d.result.status==="valid")return d.result;for(const d of c)if(d.result.status==="dirty")return s.common.issues.push(...d.ctx.common.issues),d.result;const h=c.map(d=>new vr(d.ctx.common.issues));return me(s,{code:ue.invalid_union,unionErrors:h}),Re}if(s.common.async)return Promise.all(n.map(async c=>{const h={...s,common:{...s.common,issues:[]},parent:null};return{result:await c._parseAsync({data:s.data,path:s.path,parent:h}),ctx:h}})).then(a);{let c;const h=[];for(const f of n){const m={...s,common:{...s.common,issues:[]},parent:null},g=f._parseSync({data:s.data,path:s.path,parent:m});if(g.status==="valid")return g;g.status==="dirty"&&!c&&(c={result:g,ctx:m}),m.common.issues.length&&h.push(m.common.issues)}if(c)return s.common.issues.push(...c.ctx.common.issues),c.result;const d=h.map(f=>new vr(f));return me(s,{code:ue.invalid_union,unionErrors:d}),Re}}get options(){return this._def.options}}mh.create=(e,t)=>new mh({options:e,typeName:De.ZodUnion,...Fe(t)});const or=e=>e instanceof up?or(e.schema):e instanceof oa?or(e.innerType()):e instanceof _h?[e.value]:e instanceof la?e.options:e instanceof hp?Je.objectValues(e.enum):e instanceof vh?or(e._def.innerType):e instanceof lp?[void 0]:e instanceof op?[null]:e instanceof pr?[void 0,...or(e.unwrap())]:e instanceof ca?[null,...or(e.unwrap())]:e instanceof Nw||e instanceof bh?or(e.unwrap()):e instanceof yh?or(e._def.innerType):[];class S_ extends Ze{_parse(t){const{ctx:s}=this._processInputParams(t);if(s.parsedType!==Se.object)return me(s,{code:ue.invalid_type,expected:Se.object,received:s.parsedType}),Re;const n=this.discriminator,a=s.data[n],c=this.optionsMap.get(a);return c?s.common.async?c._parseAsync({data:s.data,path:s.path,parent:s}):c._parseSync({data:s.data,path:s.path,parent:s}):(me(s,{code:ue.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Re)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,s,n){const a=new Map;for(const c of s){const h=or(c.shape[t]);if(!h.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const d of h){if(a.has(d))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(d)}`);a.set(d,c)}}return new S_({typeName:De.ZodDiscriminatedUnion,discriminator:t,options:s,optionsMap:a,...Fe(n)})}}function cp(e,t){const s=Zr(e),n=Zr(t);if(e===t)return{valid:!0,data:e};if(s===Se.object&&n===Se.object){const a=Je.objectKeys(t),c=Je.objectKeys(e).filter(d=>a.indexOf(d)!==-1),h={...e,...t};for(const d of c){const f=cp(e[d],t[d]);if(!f.valid)return{valid:!1};h[d]=f.data}return{valid:!0,data:h}}else if(s===Se.array&&n===Se.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let c=0;c<e.length;c++){const h=e[c],d=t[c],f=cp(h,d);if(!f.valid)return{valid:!1};a.push(f.data)}return{valid:!0,data:a}}else return s===Se.date&&n===Se.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class ph extends Ze{_parse(t){const{status:s,ctx:n}=this._processInputParams(t),a=(c,h)=>{if(A0(c)||A0(h))return Re;const d=cp(c.value,h.value);return d.valid?((R0(c)||R0(h))&&s.dirty(),{status:s.value,value:d.data}):(me(n,{code:ue.invalid_intersection_types}),Re)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([c,h])=>a(c,h)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ph.create=(e,t,s)=>new ph({left:e,right:t,typeName:De.ZodIntersection,...Fe(s)});class aa extends Ze{_parse(t){const{status:s,ctx:n}=this._processInputParams(t);if(n.parsedType!==Se.array)return me(n,{code:ue.invalid_type,expected:Se.array,received:n.parsedType}),Re;if(n.data.length<this._def.items.length)return me(n,{code:ue.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Re;!this._def.rest&&n.data.length>this._def.items.length&&(me(n,{code:ue.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const c=[...n.data].map((h,d)=>{const f=this._def.items[d]||this._def.rest;return f?f._parse(new vn(n,h,n.path,d)):null}).filter(h=>!!h);return n.common.async?Promise.all(c).then(h=>Qs.mergeArray(s,h)):Qs.mergeArray(s,c)}get items(){return this._def.items}rest(t){return new aa({...this._def,rest:t})}}aa.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new aa({items:e,typeName:De.ZodTuple,rest:null,...Fe(t)})};class z0 extends Ze{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:s,ctx:n}=this._processInputParams(t);if(n.parsedType!==Se.map)return me(n,{code:ue.invalid_type,expected:Se.map,received:n.parsedType}),Re;const a=this._def.keyType,c=this._def.valueType,h=[...n.data.entries()].map(([d,f],m)=>({key:a._parse(new vn(n,d,n.path,[m,"key"])),value:c._parse(new vn(n,f,n.path,[m,"value"]))}));if(n.common.async){const d=new Map;return Promise.resolve().then(async()=>{for(const f of h){const m=await f.key,g=await f.value;if(m.status==="aborted"||g.status==="aborted")return Re;(m.status==="dirty"||g.status==="dirty")&&s.dirty(),d.set(m.value,g.value)}return{status:s.value,value:d}})}else{const d=new Map;for(const f of h){const m=f.key,g=f.value;if(m.status==="aborted"||g.status==="aborted")return Re;(m.status==="dirty"||g.status==="dirty")&&s.dirty(),d.set(m.value,g.value)}return{status:s.value,value:d}}}}z0.create=(e,t,s)=>new z0({valueType:t,keyType:e,typeName:De.ZodMap,...Fe(s)});class Qo extends Ze{_parse(t){const{status:s,ctx:n}=this._processInputParams(t);if(n.parsedType!==Se.set)return me(n,{code:ue.invalid_type,expected:Se.set,received:n.parsedType}),Re;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(me(n,{code:ue.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),s.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(me(n,{code:ue.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),s.dirty());const c=this._def.valueType;function h(f){const m=new Set;for(const g of f){if(g.status==="aborted")return Re;g.status==="dirty"&&s.dirty(),m.add(g.value)}return{status:s.value,value:m}}const d=[...n.data.values()].map((f,m)=>c._parse(new vn(n,f,n.path,m)));return n.common.async?Promise.all(d).then(f=>h(f)):h(d)}min(t,s){return new Qo({...this._def,minSize:{value:t,message:Ce.toString(s)}})}max(t,s){return new Qo({...this._def,maxSize:{value:t,message:Ce.toString(s)}})}size(t,s){return this.min(t,s).max(t,s)}nonempty(t){return this.min(1,t)}}Qo.create=(e,t)=>new Qo({valueType:e,minSize:null,maxSize:null,typeName:De.ZodSet,...Fe(t)});class up extends Ze{get schema(){return this._def.getter()}_parse(t){const{ctx:s}=this._processInputParams(t);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}up.create=(e,t)=>new up({getter:e,typeName:De.ZodLazy,...Fe(t)});class _h extends Ze{_parse(t){if(t.data!==this._def.value){const s=this._getOrReturnCtx(t);return me(s,{received:s.data,code:ue.invalid_literal,expected:this._def.value}),Re}return{status:"valid",value:t.data}}get value(){return this._def.value}}_h.create=(e,t)=>new _h({value:e,typeName:De.ZodLiteral,...Fe(t)});function kw(e,t){return new la({values:e,typeName:De.ZodEnum,...Fe(t)})}class la extends Ze{_parse(t){if(typeof t.data!="string"){const s=this._getOrReturnCtx(t),n=this._def.values;return me(s,{expected:Je.joinValues(n),received:s.parsedType,code:ue.invalid_type}),Re}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const s=this._getOrReturnCtx(t),n=this._def.values;return me(s,{received:s.data,code:ue.invalid_enum_value,options:n}),Re}return fi(t.data)}get options(){return this._def.values}get enum(){const t={};for(const s of this._def.values)t[s]=s;return t}get Values(){const t={};for(const s of this._def.values)t[s]=s;return t}get Enum(){const t={};for(const s of this._def.values)t[s]=s;return t}extract(t,s=this._def){return la.create(t,{...this._def,...s})}exclude(t,s=this._def){return la.create(this.options.filter(n=>!t.includes(n)),{...this._def,...s})}}la.create=kw;class hp extends Ze{_parse(t){const s=Je.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==Se.string&&n.parsedType!==Se.number){const a=Je.objectValues(s);return me(n,{expected:Je.joinValues(a),received:n.parsedType,code:ue.invalid_type}),Re}if(this._cache||(this._cache=new Set(Je.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const a=Je.objectValues(s);return me(n,{received:n.data,code:ue.invalid_enum_value,options:a}),Re}return fi(t.data)}get enum(){return this._def.values}}hp.create=(e,t)=>new hp({values:e,typeName:De.ZodNativeEnum,...Fe(t)});class gh extends Ze{unwrap(){return this._def.type}_parse(t){const{ctx:s}=this._processInputParams(t);if(s.parsedType!==Se.promise&&s.common.async===!1)return me(s,{code:ue.invalid_type,expected:Se.promise,received:s.parsedType}),Re;const n=s.parsedType===Se.promise?s.data:Promise.resolve(s.data);return fi(n.then(a=>this._def.type.parseAsync(a,{path:s.path,errorMap:s.common.contextualErrorMap})))}}gh.create=(e,t)=>new gh({type:e,typeName:De.ZodPromise,...Fe(t)});class oa extends Ze{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===De.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:s,ctx:n}=this._processInputParams(t),a=this._def.effect||null,c={addIssue:h=>{me(n,h),h.fatal?s.abort():s.dirty()},get path(){return n.path}};if(c.addIssue=c.addIssue.bind(c),a.type==="preprocess"){const h=a.transform(n.data,c);if(n.common.async)return Promise.resolve(h).then(async d=>{if(s.value==="aborted")return Re;const f=await this._def.schema._parseAsync({data:d,path:n.path,parent:n});return f.status==="aborted"?Re:f.status==="dirty"||s.value==="dirty"?Do(f.value):f});{if(s.value==="aborted")return Re;const d=this._def.schema._parseSync({data:h,path:n.path,parent:n});return d.status==="aborted"?Re:d.status==="dirty"||s.value==="dirty"?Do(d.value):d}}if(a.type==="refinement"){const h=d=>{const f=a.refinement(d,c);if(n.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return d};if(n.common.async===!1){const d=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return d.status==="aborted"?Re:(d.status==="dirty"&&s.dirty(),h(d.value),{status:s.value,value:d.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(d=>d.status==="aborted"?Re:(d.status==="dirty"&&s.dirty(),h(d.value).then(()=>({status:s.value,value:d.value}))))}if(a.type==="transform")if(n.common.async===!1){const h=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!xl(h))return Re;const d=a.transform(h.value,c);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:s.value,value:d}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(h=>xl(h)?Promise.resolve(a.transform(h.value,c)).then(d=>({status:s.value,value:d})):Re);Je.assertNever(a)}}oa.create=(e,t,s)=>new oa({schema:e,typeName:De.ZodEffects,effect:t,...Fe(s)});oa.createWithPreprocess=(e,t,s)=>new oa({schema:t,effect:{type:"preprocess",transform:e},typeName:De.ZodEffects,...Fe(s)});class pr extends Ze{_parse(t){return this._getType(t)===Se.undefined?fi(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}pr.create=(e,t)=>new pr({innerType:e,typeName:De.ZodOptional,...Fe(t)});class ca extends Ze{_parse(t){return this._getType(t)===Se.null?fi(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}ca.create=(e,t)=>new ca({innerType:e,typeName:De.ZodNullable,...Fe(t)});class vh extends Ze{_parse(t){const{ctx:s}=this._processInputParams(t);let n=s.data;return s.parsedType===Se.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}vh.create=(e,t)=>new vh({innerType:e,typeName:De.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Fe(t)});class yh extends Ze{_parse(t){const{ctx:s}=this._processInputParams(t),n={...s,common:{...s.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return dh(a)?a.then(c=>({status:"valid",value:c.status==="valid"?c.value:this._def.catchValue({get error(){return new vr(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new vr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}yh.create=(e,t)=>new yh({innerType:e,typeName:De.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Fe(t)});class P0 extends Ze{_parse(t){if(this._getType(t)!==Se.nan){const n=this._getOrReturnCtx(t);return me(n,{code:ue.invalid_type,expected:Se.nan,received:n.parsedType}),Re}return{status:"valid",value:t.data}}}P0.create=e=>new P0({typeName:De.ZodNaN,...Fe(e)});class Nw extends Ze{_parse(t){const{ctx:s}=this._processInputParams(t),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class x_ extends Ze{_parse(t){const{status:s,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{const c=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?Re:c.status==="dirty"?(s.dirty(),Do(c.value)):this._def.out._parseAsync({data:c.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Re:a.status==="dirty"?(s.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(t,s){return new x_({in:t,out:s,typeName:De.ZodPipeline})}}class bh extends Ze{_parse(t){const s=this._def.innerType._parse(t),n=a=>(xl(a)&&(a.value=Object.freeze(a.value)),a);return dh(s)?s.then(a=>n(a)):n(s)}unwrap(){return this._def.innerType}}bh.create=(e,t)=>new bh({innerType:e,typeName:De.ZodReadonly,...Fe(t)});var De;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(De||(De={}));const xe=fn.create,Kt=wl.create,Ew=ap.create;yn.create;const Oi=qi.create,Be=zt.create,pT=mh.create,Nl=S_.create;ph.create;aa.create;const Qe=_h.create,us=la.create;gh.create;pr.create;ca.create;const _T="/acp",gT="session",vT=4404,yT=us(["running","exited"]),H0=us(["pending","running","ok","failed","cancelled"]),bT=us(["read","edit","delete","move","search","execute","think","fetch","switch_mode","other"]),F0=Be({path:xe(),line:Kt().int().nullish()}),ST=Nl("type",[Be({type:Qe("content"),text:xe()}),Be({type:Qe("diff"),path:xe(),oldText:xe().nullish(),newText:xe()}),Be({type:Qe("terminal"),terminalId:xe()})]),xT=us(["allow_once","allow_always","reject_once","reject_always"]),w_=us(["ask","auto","free"]),Tw=us(["ask","auto"]),Ow=us(["agent","lumem"]),wT=Be({optionId:xe(),name:xe(),kind:xT}),CT=us(["end_turn","max_tokens","max_turn_requests","refusal","cancelled"]),jT=us(["pending","in_progress","completed"]),kT=Be({content:xe(),status:jT,priority:us(["high","medium","low"]).nullish()}),NT=Be({utilization:Kt(),surpassedThreshold:Kt().nullish(),isUsingOverage:Ew(),resetsAt:Kt().int().nullish(),kind:xe().nullish()}),ET=Be({value:xe(),name:xe(),description:xe().nullish()}),Aw=Be({id:xe(),name:xe(),category:xe().nullish(),currentValue:xe(),choices:Oi(ET)}),TT=Be({name:xe(),description:xe(),takesInput:Ew()}),Rw=Nl("type",[Be({type:Qe("message"),messageId:xe(),role:us(["user","agent"]),text:xe()}),Be({type:Qe("thought"),messageId:xe(),text:xe()}),Be({type:Qe("tool_call"),toolCallId:xe(),title:xe(),name:xe().nullish(),kind:bT,status:H0,locations:Oi(F0).default([])}),Be({type:Qe("tool_call_update"),toolCallId:xe(),status:H0.optional(),title:xe().optional(),content:Oi(ST).optional(),locations:Oi(F0).optional()}),Be({type:Qe("permission_request"),requestId:xe(),toolCallId:xe(),title:xe(),command:xe().nullish(),cwd:xe(),options:Oi(wT).min(1),policyReason:xe().nullable().default(null)}),Be({type:Qe("permission_resolved"),requestId:xe(),outcome:pT([Qe("cancelled"),Be({optionId:xe()})]),by:us(["user","lumem"]).default("user"),reason:xe().nullable().default(null)}),Be({type:Qe("plan"),entries:Oi(kT)}),Be({type:Qe("plan_removed")}),Be({type:Qe("usage"),used:Kt().int().nonnegative(),size:Kt().int().positive(),cost:Be({amount:Kt(),currency:xe()}).nullish(),rateLimit:NT.nullish()}),Be({type:Qe("config"),mode:xe(),options:Oi(Aw),modeOwner:Ow.default("agent"),lumemMode:w_.default("ask"),lumemModeDefault:Tw.default("ask")}),Be({type:Qe("commands"),commands:Oi(TT)}),Be({type:Qe("terminal"),terminalId:xe(),ptySessionId:xe(),command:xe()}),Be({type:Qe("turn_end"),stopReason:CT}),Be({type:Qe("resumed"),fromSessionId:xe()}),Be({type:Qe("memory_core"),entries:Kt().int().nonnegative(),chars:Kt().int().nonnegative()}),Be({type:Qe("budget"),outcome:us(["warn","block"]),cap:us(["cost-per-task","cost-per-day","turns-per-session"]),limit:Kt().nonnegative(),spent:Kt().nonnegative(),message:xe()}),Be({type:Qe("unknown"),sessionUpdate:xe()})]),OT=Be({at:Kt().int().nonnegative(),event:Rw}),AT=us(["SESSION_NOT_FOUND","SESSION_EXITED","INVALID_MESSAGE","ADAPTER_UNAVAILABLE","INTERNAL"]),RT=Nl("type",[Be({type:Qe("prompt"),text:xe().min(1)}),Be({type:Qe("cancel")}),Be({type:Qe("permission_response"),requestId:xe(),optionId:xe()}),Be({type:Qe("set_config"),optionId:xe().min(1),value:xe().min(1)}),Be({type:Qe("set_lumem_mode"),mode:w_})]),DT=Nl("type",[Be({type:Qe("attached"),sessionId:xe(),state:yT,acpSessionId:xe(),model:xe(),mode:xe(),configOptions:Oi(Aw).default([]),modeOwner:Ow.default("agent"),lumemMode:w_.default("ask"),lumemModeDefault:Tw.default("ask"),cwd:xe().default(""),transcript:Oi(OT)}),Be({type:Qe("event"),at:Kt().int().nonnegative(),event:Rw}),Be({type:Qe("error"),code:AT,message:xe(),remedy:xe().optional()})]);function MT(e,t){let s;try{s=JSON.parse(t)}catch(a){return{ok:!1,error:`not valid JSON: ${a.message}`}}const n=e.safeParse(s);return n.success?{ok:!0,message:n.data}:{ok:!1,error:n.error.issues.map(c=>`${c.path.join(".")||"<root>"}: ${c.message}`).join("; ")}}function BT(e){return MT(DT,e)}function LT(e){return JSON.stringify(e)}const nl={id:"claude",label:"Claude Code",package:"@agentclientprotocol/claude-agent-acp",command:"claude-agent-acp",pinnedVersion:"0.75.1",cli:null,runtime:"@anthropic-ai/claude-agent-sdk",apiKeyEnv:["ANTHROPIC_API_KEY"],autonomousMode:"bypassPermissions"},qT={id:"codex",label:"Codex",package:"@agentclientprotocol/codex-acp",command:"codex-acp",pinnedVersion:"1.10.0",cli:null,runtime:"@openai/codex",apiKeyEnv:["CODEX_API_KEY","OPENAI_API_KEY"],autonomousMode:null},zT=[nl,qT],PT=nl.id,HT="/pty",FT="session",IT=us(["running","exited"]),UT=us(["SESSION_NOT_FOUND","SESSION_EXITED","INVALID_MESSAGE","INTERNAL"]),I0=5e3;Nl("type",[Be({type:Qe("input"),data:xe()}),Be({type:Qe("resize"),cols:Kt().int().min(1).max(I0),rows:Kt().int().min(1).max(I0)})]);const KT=Nl("type",[Be({type:Qe("attached"),sessionId:xe(),state:IT,cols:Kt().int(),rows:Kt().int(),snapshot:xe()}),Be({type:Qe("output"),data:xe()}),Be({type:Qe("exit"),exitCode:Kt().int(),signal:Kt().int().nullable()}),Be({type:Qe("error"),code:UT,message:xe()})]);function $T(e,t){let s;try{s=JSON.parse(t)}catch(a){return{ok:!1,error:`not valid JSON: ${a.message}`}}const n=e.safeParse(s);return n.success?{ok:!0,message:n.data}:{ok:!1,error:n.error.issues.map(c=>`${c.path.join(".")||"<root>"}: ${c.message}`).join("; ")}}function WT(e){return $T(KT,e)}function U0(e){return JSON.stringify(e)}const VT=1;function YT(e,t){return`${t.protocol==="https:"?"wss:":"ws:"}//${t.host}${HT}?${FT}=${encodeURIComponent(e)}`}function Dw(e,t,s={}){const{createWebSocket:n=d=>new WebSocket(d),origin:a=window.location}=s,c=n(YT(e,a));let h=[];return c.onopen=()=>{const d=h;h=[];for(const f of d)c.send(U0(f))},c.onmessage=d=>{var m;const f=WT(String(d.data));f.ok?t.onMessage(f.message):(m=t.onDecodeError)==null||m.call(t,f.error)},c.onclose=d=>{var f;h=[],(f=t.onClose)==null||f.call(t,{code:d.code,clean:d.wasClean})},c.onerror=()=>{},{send(d){c.readyState===VT?c.send(U0(d)):h.push(d)},close(){c.onmessage=null,c.onclose=null,c.onopen=null,h=[],c.close()}}}const K0=12;function GT({ptySessionId:e,onFinished:t,connect:s=Dw}){const[n,a]=j.useState([]),[c,h]=j.useState(null),[d,f]=j.useState(!1),m=j.useRef(t);return m.current=t,j.useEffect(()=>{if(e===null)return;a([]),h(null),f(!0);const g=s(e,{onMessage:v=>{if(v.type==="attached"||v.type==="output"){const b=v.type==="attached"?v.snapshot:v.data;a(S=>$0([...S,...QT(b)]));return}if(v.type==="exit"){f(!1),h(v.exitCode),m.current(v.exitCode);return}v.type==="error"&&a(b=>$0([...b,v.message]))},onClose:()=>f(!1)});return()=>g.close()},[e,s]),{output:n,exitCode:c,running:d}}function QT(e){return e.replace(/\u001B\[[0-9;?]*[A-Za-z]/g,"").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,"").split(/\r?\n/).map(t=>t.trim()).filter(t=>t!=="")}function $0(e){return e.length<=K0?e:e.slice(e.length-K0)}function ZT({slot:e,onClose:t}){const[s,n]=j.useState(""),a=qe(),c=Te({mutationFn:h=>te.secrets.set.mutate({id:e.id,value:h}),onSuccess:()=>{a.invalidateQueries({queryKey:["secrets"]}),t()}});return l.jsx(Ah,{open:!0,title:e.label,onClose:t,footer:l.jsxs(l.Fragment,{children:[e.present?l.jsx(ce,{variant:"danger",className:"modal__destructive",onClick:()=>c.mutate(""),disabled:c.isPending,children:"remover"}):null,l.jsx(ce,{onClick:t,children:"cancelar"}),l.jsx(ce,{variant:"primary",disabled:s.trim()===""||c.isPending,onClick:()=>c.mutate(s),children:"guardar"})]}),children:l.jsx($t,{id:`secret-${e.id}`,label:"chave de API",error:c.isError?"não deu para guardar":void 0,hint:l.jsxs(l.Fragment,{children:[e.hint,". O Lumem guarda ",l.jsx("b",{children:"cifrada"})," e ",l.jsx("b",{children:"nunca a mostra de volta"}),"."]}),children:l.jsx(ts,{id:`secret-${e.id}`,type:"password",autoComplete:"off",placeholder:e.present?"há uma chave guardada — cole outra para trocar":"",value:s,onChange:h=>n(h.target.value)})})})}function XT(){const[e,t]=j.useState(null),n=ye({queryKey:["secrets"],queryFn:()=>te.secrets.list.query()}).data??[];return n.length===0?null:l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"foot-head",children:l.jsx("span",{className:"foot-head__label",children:"Credenciais"})}),n.map(a=>l.jsxs("button",{type:"button",className:`foot-row foot-row--${a.present?"on":"off"} focus-ring`,onClick:()=>t(a),children:[l.jsx("span",{className:"glyph glyph--key",children:"⚿"}),l.jsx("span",{className:"foot-row__label",children:a.label}),l.jsx("span",{className:"pip"}),l.jsx("span",{className:"foot-row__st",children:a.present?"guardada":"sem chave"})]},a.id)),e===null?null:l.jsx(ZT,{slot:e,onClose:()=>t(null)})]})}const dm=["agentConfig","list"];function JT({embedded:e=!1,onClose:t}={}){const s=qe(),[n,a]=j.useState(e),c=ye({queryKey:dm,queryFn:()=>te.agentConfig.list.query(),enabled:n}),[h,d]=j.useState(""),[f,m]=j.useState(""),[g,v]=j.useState(""),[b,S]=j.useState("acp"),[x,w]=j.useState(""),[k,N]=j.useState(null),L=Te({mutationFn:()=>te.agentConfig.create.mutate({name:h.trim(),command:f.trim(),args:g.trim()===""?[]:g.trim().split(/\s+/),transport:b,...b==="acp"?{adapterVersion:x.trim()}:{}}),onSuccess:async()=>{await s.invalidateQueries({queryKey:dm}),d(""),m(""),v(""),w("")}}),R=Te({mutationFn:Z=>te.agentConfig.remove.mutate({id:Z}),onSuccess:async()=>{N(null),await s.invalidateQueries({queryKey:dm})}}),D=h.trim()!==""&&f.trim()!==""&&(b==="pty"||x.trim()!==""),Y=Z=>{Z.preventDefault(),D&&L.mutate()};if(!n)return l.jsxs("button",{type:"button",className:"sidebar__add",onClick:()=>a(!0),children:[l.jsx($e,{tone:"agent",children:"◆"}),"agentes"]});const K=c.data??[];return l.jsx("div",{className:"agents",children:l.jsxs(Sw,{children:[K.length===0&&!c.isPending&&l.jsx("p",{className:"agents__empty",children:"nenhum agente configurado"}),K.map(Z=>{const Q=Z.transport==="acp";return l.jsxs("div",{className:"agents__row",children:[l.jsxs("div",{className:"agents__head",children:[l.jsx($e,{tone:Q?"agent":"shell",children:Q?"◆":"●"}),l.jsx("span",{className:"agents__name",children:Z.name}),l.jsx(kt,{children:Q?"conversa":"terminal"}),!Z.available&&l.jsx(kt,{tone:"missing",children:"fora do PATH"})]}),l.jsxs("div",{className:"agents__foot",children:[l.jsxs("span",{className:"agents__cmd",title:Z.command,children:[Z.command,Q&&Z.adapterVersion?` @${Z.adapterVersion}`:""]}),k===Z.id?l.jsx(ce,{size:"sm",variant:"danger",disabled:R.isPending,onClick:()=>R.mutate(Z.id),children:"confirmar"}):l.jsxs(ce,{size:"sm",variant:"ghost",onClick:()=>N(Z.id),children:["remover ",l.jsx("span",{className:"sr-only",children:Z.name})]})]})]},Z.id)}),R.isError&&l.jsx(ke,{tone:"danger",children:R.error.message}),l.jsxs("form",{className:"agents__form",onSubmit:Y,children:[l.jsx($t,{id:"agent-name",label:"Nome",error:L.isError?L.error.message:void 0,children:l.jsx(ts,{id:"agent-name",value:h,onChange:Z=>d(Z.target.value),placeholder:"claude-acp",invalid:L.isError,autoFocus:!0})}),l.jsx($t,{id:"agent-transport",label:"Transporte",children:l.jsxs("select",{id:"agent-transport",className:"input",value:b,onChange:Z=>S(Z.target.value),children:[l.jsx("option",{value:"acp",children:"conversa (ACP)"}),l.jsx("option",{value:"pty",children:"terminal (PTY)"})]})}),l.jsx($t,{id:"agent-command",label:"Comando",children:l.jsx(ts,{id:"agent-command",value:f,onChange:Z=>m(Z.target.value),placeholder:b==="acp"?"claude-agent-acp":"claude"})}),l.jsx($t,{id:"agent-args",label:"Argumentos (opcional)",children:l.jsx(ts,{id:"agent-args",value:g,onChange:Z=>v(Z.target.value),placeholder:"--flag valor"})}),b==="acp"&&l.jsx($t,{id:"agent-version",label:"Versão do adaptador",children:l.jsx(ts,{id:"agent-version",value:x,onChange:Z=>w(Z.target.value),placeholder:nl.pinnedVersion})}),l.jsxs("div",{className:"agents__actions",children:[l.jsx(ce,{type:"submit",variant:"primary",disabled:L.isPending||!D,children:L.isPending?"criando…":"adicionar"}),l.jsx(ce,{variant:"ghost",onClick:()=>{e?t==null||t():a(!1)},children:"fechar"})]})]})]})})}const Mw=["agentConfig","list"],W0=["setup","agents"],Bw=["setup","probe"];function eO(){const[e,t]=j.useState(null),[s,n]=j.useState(!1),c=(ye({queryKey:Mw,queryFn:()=>te.agentConfig.list.query()}).data??[]).filter(f=>f.transport==="acp"),h=(e==null?void 0:e.kind)==="agent"?c.find(f=>f.id===e.id):void 0,d=j.useCallback(()=>t(null),[]);return l.jsxs(l.Fragment,{children:[s&&l.jsxs("div",{className:"setup",role:"group","aria-label":"outro agente ACP",children:[l.jsxs("div",{className:"setup__head",children:[l.jsx("span",{className:"setup__t",children:"Outro agente ACP"}),l.jsx("button",{type:"button",className:"setup__x","aria-label":"fechar",onClick:()=>n(!1),children:"✕"})]}),l.jsx(JT,{embedded:!0,onClose:()=>n(!1)})]}),!s&&(e==null?void 0:e.kind)==="connect"&&l.jsx(iO,{configured:c.map(f=>f.command),onClose:d,onCustom:()=>{n(!0),t(null)},onConnected:f=>t({kind:"agent",id:f})}),!s&&h!==void 0&&l.jsx(aO,{config:h,onClose:d,onCustom:()=>n(!0)}),l.jsxs("div",{className:"foot-head",children:[l.jsx("span",{className:"foot-head__label",children:"Agentes"}),l.jsx("button",{type:"button",className:"act",title:"conectar um agente","aria-label":"conectar um agente",onClick:()=>t({kind:"connect"}),children:"+"})]}),c.length===0?l.jsx("span",{className:"foot-empty",children:"nenhum agente conectado"}):c.map(f=>l.jsx(sO,{config:f,open:(e==null?void 0:e.kind)==="agent"&&e.id===f.id,onOpen:()=>t({kind:"agent",id:f.id})},f.id)),l.jsx(XT,{})]})}function Lw(e){return ye({queryKey:[...Bw,e.command,e.args.join(" ")],queryFn:()=>te.setup.probe.query({command:e.command,args:[...e.args]}),retry:!1,refetchOnWindowFocus:!1,staleTime:5*6e4})}function tO(e){var t;return e.isPending?{tone:"off",word:"verificando"}:e.isError?{tone:"err",word:"falhou"}:((t=e.data)==null?void 0:t.authRequired)===!0?{tone:"warn",word:"entrar"}:{tone:"on",word:"conectado"}}function sO({config:e,open:t,onOpen:s}){const n=Lw(e),{tone:a,word:c}=tO(n);return l.jsxs("button",{type:"button",className:`foot-row foot-row--${a}${t?" is-open":""}`,"aria-label":`${e.name}: ${c}`,onClick:s,children:[l.jsx($e,{tone:"agent",children:"◆"}),l.jsx("span",{className:"foot-row__label",children:e.name}),l.jsx("span",{className:"pip"}),l.jsx("span",{className:"foot-row__st",children:c})]})}function iO({configured:e,onClose:t,onCustom:s,onConnected:n}){const a=qe(),[c,h]=j.useState("idle"),[d,f]=j.useState(null),m=ye({queryKey:W0,queryFn:()=>te.setup.agents.query(),refetchOnWindowFocus:!1}),g=Te({mutationFn:async v=>{var N;f(v);const b=fm(m.data,v.id);let S=(b==null?void 0:b.adapter.path)??null;const x=(b==null?void 0:b.adapter.version)!=null&&b.adapter.version!==v.pinnedVersion;(S===null||x)&&(h("installing"),S=(await te.setup.installAdapter.mutate({adapterId:v.id})).path),h("handshaking");const w=await te.setup.probe.query({command:S});return(await te.agentConfig.create.mutate({name:v.id,command:S,args:[],transport:"acp",adapterVersion:((N=w.agentInfo)==null?void 0:N.version)??v.pinnedVersion})).id},onSettled:async()=>{h("idle"),await a.invalidateQueries({queryKey:Mw}),await a.invalidateQueries({queryKey:W0})},onSuccess:v=>n(v)});return l.jsxs("div",{className:"setup",role:"group","aria-label":"conectar agente",children:[l.jsxs("div",{className:"setup__head",children:[l.jsx("span",{className:"setup__t",children:g.isPending?`Preparando o ${(d==null?void 0:d.label)??"agente"}`:"Conectar agente"}),!g.isPending&&l.jsx("button",{type:"button",className:"setup__x","aria-label":"fechar",onClick:t,children:"✕"})]}),g.isPending?l.jsx(nO,{spec:d,stage:c,entry:fm(m.data,d==null?void 0:d.id)}):l.jsxs(l.Fragment,{children:[zT.map((v,b)=>{const S=fm(m.data,v.id),x=(S==null?void 0:S.adapter.path)!=null&&e.includes(S.adapter.path);return l.jsxs("button",{type:"button",className:b===0&&!x?"opt opt--primary":"opt",disabled:x||g.isPending||m.isPending,onClick:()=>g.mutate(v),children:[l.jsxs("span",{className:"opt__t",children:[l.jsx("span",{className:"opt__g","aria-hidden":"true",children:"◆"}),v.label]}),l.jsx("span",{className:"opt__d",children:rO(v,S,x===!0,m.isPending)})]},v.id)}),l.jsx("button",{type:"button",className:"linkbtn",onClick:s,children:"outro agente ACP…"}),l.jsxs("span",{className:"setup__note",children:["A lista é o ",l.jsx("b",{children:"catálogo do daemon"}),". O adaptador é instalado"," ",l.jsx("b",{children:"dentro da pasta do app"})," e fixado numa versão — nunca ",l.jsx("code",{children:"@latest"}),", para uma atualização de madrugada não mudar o comportamento do agente."]}),g.isError&&l.jsx(ke,{tone:"danger",children:g.error.message})]})]})}function fm(e,t){if(t!==void 0)return e==null?void 0:e.adapters.find(s=>s.id===t)}function rO(e,t,s,n){var a;return s?"já conectado":n?"procurando na sua máquina…":e.cli!==null?((a=t==null?void 0:t.cli)==null?void 0:a.path)==null?`o CLI ${e.cli.command} não está no PATH — o adaptador precisa dele`:`${e.cli.command} encontrado · ${t.cli.version??"versão não lida"}`:(t==null?void 0:t.adapter.path)==null?"o adaptador traz o próprio agente dentro":`instalado · ${t.adapter.version??"versão não lida"}`}function nO({spec:e,stage:t,entry:s}){var a;const n=[];return(e==null?void 0:e.cli)!=null&&n.push([`${e.cli.command} encontrado`,((a=s==null?void 0:s.cli)==null?void 0:a.path)==null?"wait":"done"]),n.push(["instalando o adaptador",t==="installing"?"now":t==="handshaking"?"done":"wait"]),n.push(["handshake",t==="handshaking"?"now":"wait"]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"prep",children:n.map(([c,h])=>l.jsxs("div",{className:`prep__r prep__r--${h}`,children:[l.jsx("span",{className:"prep__m","aria-hidden":"true",children:h==="done"?"✓":h==="now"?"◐":"○"}),c]},c))}),l.jsx("span",{className:"setup__note",children:e!==null&&e.cli===null?l.jsxs(l.Fragment,{children:["Duas linhas, e não três: este adaptador ",l.jsx("b",{children:"não precisa de CLI no PATH"})," — ele traz o próprio. Não há o que procurar na sua máquina."]}):l.jsxs(l.Fragment,{children:["Nada para rodar no terminal: o adaptador é instalado ",l.jsx("b",{children:"dentro da pasta do app"})," e fixado numa versão."]})})]})}function aO({config:e,onClose:t,onCustom:s}){var x,w;const n=qe(),[a,c]=j.useState(!1),h=Lw(e),d=j.useCallback(async()=>{await n.invalidateQueries({queryKey:Bw})},[n]),f=((w=(x=h.data)==null?void 0:x.agentInfo)==null?void 0:w.title)??e.name;return l.jsxs("div",{className:"setup",role:"group","aria-label":`agente ${e.name}`,children:[l.jsxs("div",{className:"setup__head",children:[l.jsx("span",{className:"setup__t",children:m()}),l.jsx("button",{type:"button",className:"setup__x","aria-label":"fechar",onClick:t,children:"✕"})]}),g()]});function m(){var k;return a?"Adaptador":h.isError?"Não deu para conectar":((k=h.data)==null?void 0:k.authRequired)===!0?`Entrar no ${f}`:f}function g(){var k;return a?b():h.isError?S(h.error.message):((k=h.data)==null?void 0:k.authRequired)===!0?l.jsx(lO,{config:e,methods:h.data.authMethods,onDone:()=>void d()}):v()}function v(){const k=h.data;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"acct",children:[l.jsxs("div",{className:"acct__r",children:[l.jsx("span",{className:"acct__k",children:"agente"}),l.jsxs("span",{className:"acct__v",children:[l.jsx("b",{children:f}),(k==null?void 0:k.agentInfo)!=null&&l.jsxs(l.Fragment,{children:[" · ",k.agentInfo.version]})]})]}),l.jsxs("div",{className:"acct__r",children:[l.jsx("span",{className:"acct__k",children:"entrada"}),l.jsx("span",{className:"acct__v",children:(k==null?void 0:k.authMethods.length)===0?"credencial local, já válida":"credencial local"})]}),l.jsxs("div",{className:"acct__r",children:[l.jsx("span",{className:"acct__k",children:"padrão"}),l.jsx("span",{className:"acct__v",children:(k==null?void 0:k.currentMode)??"o padrão do agente"})]})]}),l.jsxs("div",{className:"setup__acts",children:[l.jsx(ce,{size:"sm",variant:"ghost",onClick:()=>void d(),children:"verificar de novo"}),l.jsx("button",{type:"button",className:"linkbtn",onClick:()=>c(!0),children:"avançado"})]}),l.jsxs("span",{className:"setup__note",children:["Trocar de conta é ",l.jsx("code",{children:"/logout"})," no seu agente: o Lumem ainda não chama a capacidade"," ",l.jsx("code",{children:"auth.logout"}),", então um botão aqui não faria nada."]})]})}function b(){return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"acct",children:[l.jsxs("div",{className:"acct__r",children:[l.jsx("span",{className:"acct__k",children:"comando"}),l.jsx("span",{className:"acct__v",children:e.command})]}),l.jsxs("div",{className:"acct__r",children:[l.jsx("span",{className:"acct__k",children:"args"}),l.jsx("span",{className:"acct__v",children:e.args.length?e.args.join(" "):"nenhum"})]}),l.jsxs("div",{className:"acct__r",children:[l.jsx("span",{className:"acct__k",children:"versão"}),l.jsx("span",{className:"acct__v",children:e.adapterVersion??"não fixada"})]})]}),l.jsxs("span",{className:"setup__note",children:["Só para quem mantém o próprio adaptador. O Lumem usa o que instalou e a versão que fixou — para trocar, remova esta configuração em ",l.jsx("b",{children:"outro agente ACP…"})," e crie a sua."]}),l.jsx("button",{type:"button",className:"linkbtn",onClick:()=>c(!1),children:"voltar"})]})}function S(k){return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"fail",children:[l.jsxs("span",{className:"fail__title",children:[l.jsx("span",{"aria-hidden":"true",children:"✕"}),"não deu para conectar"]}),l.jsx("span",{className:"fail__body",children:"O adaptador não respondeu ao handshake. O que ele disse está abaixo."}),l.jsx("div",{className:"fail__cmd",children:k})]}),l.jsxs("div",{className:"setup__acts",children:[l.jsx(ce,{size:"sm",variant:"primary",onClick:()=>void d(),children:"tentar de novo"}),l.jsx("button",{type:"button",className:"linkbtn",onClick:s,children:"outro agente ACP…"})]})]})}}function lO({config:e,methods:t,onDone:s}){var Z,Q;const[n,a]=j.useState(null),[c,h]=j.useState(null),[d,f]=j.useState(""),[m,g]=j.useState(null),v=GT({ptySessionId:n,onFinished:()=>{a(null),s()}}),b={command:e.command,args:[...e.args]},S=Te({mutationFn:z=>te.setup.login.mutate({methodId:z,...b}),onSuccess:z=>a(z.ptySessionId)}),x=Te({mutationFn:z=>te.setup.authenticate.mutate({...z,...b}),onSuccess:z=>g(z.id)}),w=ye({queryKey:["setup","authState",m],queryFn:()=>te.setup.authState.query({loginId:m??""}),enabled:m!==null,refetchInterval:z=>z.state.data===void 0||z.state.data.state==="running"?700:!1}),k=Te({mutationFn:()=>te.setup.cancelAuth.mutate({loginId:m??""}),onSuccess:()=>g(null)}),N=(Z=w.data)==null?void 0:Z.state;if(n!==null||v.running)return R();if(m!==null&&N==="ok")return Y();if(m!==null&&(N==="running"||N===void 0))return D();if(c!==null)return K(c);const L=t.filter(z=>z.type!=="terminal"||z.command!==null);if(L.length===0)return l.jsxs(l.Fragment,{children:[l.jsxs(ke,{tone:"warning",children:["O adaptador não ofereceu nenhuma forma de entrar que o Lumem saiba executar",t.length>0&&l.jsxs(l.Fragment,{children:[" — ele listou ",t.length,", e nenhuma delas dá para rodar"]}),"."]}),l.jsx(ce,{size:"sm",variant:"ghost",onClick:s,children:"verificar de novo"})]});return l.jsxs(l.Fragment,{children:[L.map((z,G)=>l.jsxs("button",{type:"button",className:G===0?"opt opt--primary":"opt",disabled:S.isPending||x.isPending,onClick:()=>{if(z.type==="terminal"){S.mutate(z.id);return}if(oO(z)){h(z);return}x.mutate({methodId:z.id})},children:[l.jsxs("span",{className:"opt__t",children:[l.jsx("span",{className:"opt__g","aria-hidden":"true",children:G===0?"◆":"◇"}),z.name]}),l.jsx("span",{className:"opt__d",children:cO(z)})]},z.id)),l.jsxs("span",{className:"setup__note",children:["Estas opções vieram ",l.jsx("b",{children:"do próprio adaptador"}),", no handshake. O Lumem não inventa método de login."]}),S.isError&&l.jsx(ke,{tone:"danger",children:S.error.message}),x.isError&&l.jsx(ke,{tone:"danger",children:x.error.message}),N==="failed"&&((Q=w.data)==null?void 0:Q.message)!=null&&l.jsx(ke,{tone:"danger",children:w.data.message})]});function R(){return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"prep",children:[l.jsxs("div",{className:"prep__r prep__r--done",children:[l.jsx("span",{className:"prep__m","aria-hidden":"true",children:"✓"}),"adaptador de pé"]}),l.jsxs("div",{className:"prep__r prep__r--now",children:[l.jsx("span",{className:"prep__m","aria-hidden":"true",children:"◐"}),"autorize no navegador e volte"]})]}),v.output.length>0&&l.jsx("div",{className:"out out--short",children:v.output.map((z,G)=>l.jsx("span",{className:"l",children:z},G))}),l.jsx("div",{className:"setup__acts",children:l.jsx(ce,{size:"sm",variant:"ghost",onClick:()=>a(null),children:"cancelar"})}),l.jsx("span",{className:"setup__note",children:"Terminou lá? Este painel muda sozinho — quem confirma é o adaptador respondendo, não você dizendo que entrou."})]})}function D(){var G;const z=((G=w.data)==null?void 0:G.elicitation)??null;return l.jsxs(l.Fragment,{children:[z!==null&&l.jsxs("div",{className:"dcode",children:[l.jsx("span",{className:"dcode__k",children:"abra em qualquer aparelho"}),l.jsx(y_,{command:z.url}),z.code!==null&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"dcode__k",children:"e digite este código"}),l.jsx("span",{className:"dcode__v",children:z.code})]}),l.jsx("span",{className:"setup__note",children:z.message})]}),l.jsx("div",{className:"prep",children:l.jsxs("div",{className:"prep__r prep__r--now",children:[l.jsx("span",{className:"prep__m","aria-hidden":"true",children:"◐"}),z===null?"entrando…":"esperando você autorizar"]})}),l.jsx("div",{className:"setup__acts",children:l.jsx(ce,{size:"sm",variant:"ghost",disabled:k.isPending,onClick:()=>k.mutate(),children:"cancelar"})}),l.jsx("span",{className:"setup__note",children:z===null?"Terminou lá? Este painel muda sozinho — quem confirma é o adaptador respondendo.":"Nada abre aqui, e é de propósito: o daemon pode estar noutra máquina."})]})}function Y(){return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"prep",children:l.jsxs("div",{className:"prep__r prep__r--done",children:[l.jsx("span",{className:"prep__m","aria-hidden":"true",children:"✓"}),"credencial aceita pelo adaptador"]})}),l.jsx("div",{className:"setup__acts",children:l.jsx(ce,{size:"sm",variant:"primary",onClick:()=>{g(null),s()},children:"continuar"})})]})}function K(z){return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"key-in",children:[l.jsx(ts,{type:"password","aria-label":"chave de API",placeholder:"sk-…",value:d,onChange:G=>f(G.target.value)}),l.jsx(ce,{size:"sm",variant:"primary",disabled:d.trim()===""||x.isPending,onClick:()=>{x.mutate({methodId:z.id,apiKey:d.trim()}),f(""),h(null)},children:"usar"})]}),l.jsxs("span",{className:"setup__note",children:["Ela ",l.jsx("b",{children:"atravessa"})," o daemon e vai para o adaptador. O Lumem não grava chave: não vai para o ",l.jsx("code",{children:"~/.lumem"}),", não vai para log, e não volta para esta tela."]}),l.jsx("button",{type:"button",className:"linkbtn",onClick:()=>h(null),children:"voltar aos jeitos de entrar"})]})}}function oO(e){return e.type==="env_var"||/api[- ]?key/i.test(e.id)}function cO(e){return e.description!==null&&e.description!==""?e.description:e.type==="terminal"?"roda um comando num terminal do daemon":"abre o navegador nesta máquina"}const Fo={backlog:"Backlog",open:"To-Do",in_progress:"In Progress",review:"In Review",testing:"Testing",ready_to_merge:"Ready to Merge",done:"Done"},qw=["backlog","done"],zw=["open","ready_to_merge","done"],uO={in_progress:{warn:30,over:120},review:{warn:30,over:120},testing:{warn:30,over:120},ready_to_merge:{warn:240,over:1440}};function C_(e,t,s){const n=s??e.status;if(n===void 0||e.seal.kind==="paused"||e.queuedBeyondSlots===!0&&n!=="ready_to_merge")return null;const a=uO[n];if(a===void 0)return null;const c=(t-new Date(e.statusChangedAt).getTime())/6e4;return c>=a.over?"over":c>=a.warn?"warn":null}function hO(e,t){let s=0,n=0;for(const a of e.cards){const c=C_(a,t,e.status);c==="over"?n+=1:c==="warn"&&(s+=1)}return{warn:s,over:n}}function dp(e,t,s){return e.seal.kind==="blocked"||zw.includes(t)&&t!=="done"?!0:C_(e,s,t)!==null}function dO({workspaceId:e,place:t,onHome:s,onBoard:n}){const a=ye({queryKey:Jx(e,null),queryFn:()=>te.task.board.query({workspaceId:e})}),c=Date.now(),h=(a.data??[]).reduce((d,f)=>d+f.cards.filter(m=>dp(m,f.status,c)).length,0);return l.jsxs("nav",{className:"nav","aria-label":"Telas do workspace",children:[l.jsx(Yo,{depth:0,label:"Home",glyph:l.jsx($e,{children:"◎"}),selected:t==="home",onSelect:s}),l.jsx(Yo,{depth:0,label:"Tarefas",glyph:l.jsx($e,{children:"▥"}),selected:t==="board",onSelect:n,meta:h===0?void 0:l.jsxs("span",{className:"row__n",children:[h,l.jsx("span",{className:"sr-only",children:h===1?" tarefa esperando você":" tarefas esperando você"})]})})]})}const Pw=[{id:"1d",label:"1d"},{id:"7d",label:"7d"},{id:"1m",label:"1m"},{id:"6m",label:"6m"},{id:"1y",label:"1a"}];function fO(e,t){return ye({queryKey:YN(e,t),queryFn:()=>te.usage.byProject.query({workspaceId:e,period:t})})}function mO(e,t){return ye({queryKey:GN(e,t),queryFn:()=>te.usage.byWorktree.query({projectId:e,period:t})})}function pO(e,t,s){return ye({queryKey:QN(e,t),queryFn:()=>te.usage.byProjectAndAgent.query({workspaceId:e,period:t}),enabled:s})}function _O(e){return ye({queryKey:FN(e.workspaceId,e.projectId),queryFn:()=>te.memory.list.query({...e.workspaceId?{workspaceId:e.workspaceId}:{},...e.projectId?{projectId:e.projectId}:{}})})}function j_(e="pending"){return ye({queryKey:IN(e),queryFn:()=>te.memory.proposals.query({status:e})})}function gO(e,t){const s=t.trim();return ye({queryKey:KN(e.workspaceId,e.projectId,s),queryFn:()=>te.memory.search.query({query:s,...e.workspaceId?{workspaceId:e.workspaceId}:{},...e.projectId?{projectId:e.projectId}:{}}),enabled:s!==""})}function vO(){return ye({queryKey:$N,queryFn:()=>te.memory.decisions.query()})}function yO(e){return ye({queryKey:UN(e.workspaceId,e.projectId),queryFn:()=>te.memory.core.query({...e.workspaceId?{workspaceId:e.workspaceId}:{},...e.projectId?{projectId:e.projectId}:{}})})}function bO(){const e=qe();return Te({mutationFn:t=>te.memory.pin.mutate(t),onSuccess:()=>e.invalidateQueries({queryKey:["memory"]})})}function SO(){return ye({queryKey:VN,queryFn:()=>te.memory.settings.query()})}function xO(e){const t=e.archived??!1;return ye({queryKey:ZN(e.workspaceId,t),queryFn:()=>te.memory.playbooks.query({...e.workspaceId?{workspaceId:e.workspaceId}:{},archived:t})})}function wO(){const e=qe();return Te({mutationFn:t=>te.memory.archivePlaybook.mutate(t),onSuccess:()=>e.invalidateQueries({queryKey:["memory"]})})}function CO(){return ye({queryKey:WN,queryFn:()=>te.memory.usage.query()})}function jO(){const e=qe(),t=()=>e.invalidateQueries({queryKey:["memory"]}),s=Te({mutationFn:a=>te.memory.approveProposal.mutate(a),onSuccess:t}),n=Te({mutationFn:a=>te.memory.rejectProposal.mutate(a),onSuccess:t});return{approve:s,reject:n}}const kO=[{id:"entries",label:"Memória"},{id:"playbooks",label:"Playbooks"},{id:"timeline",label:"Histórico"},{id:"numbers",label:"Números"}];function Hw({workspaceId:e,projectId:t,tab:s,onTabChange:n}){const[a,c]=j.useState("entries"),h=s??a,d=g=>{c(g),n==null||n(g)},f=_O({workspaceId:e,projectId:t}),m=yO({workspaceId:e,projectId:t});return j_("pending"),l.jsxs("section",{className:"mem-panel","aria-label":"Memória do workspace",children:[l.jsx("header",{className:"mem-head",children:l.jsx("div",{role:"tablist","aria-label":"Vistas da memória",className:"mem-tabs",children:kO.map(g=>l.jsx("button",{type:"button",role:"tab",id:`mem-tab-${g.id}`,"aria-selected":h===g.id,"aria-controls":"mem-panel-body",className:`mem-tab${h===g.id?" mem-tab--active":""}`,onClick:()=>{d(g.id)},children:g.label},g.id))})}),l.jsxs("div",{className:"mem-body",id:"mem-panel-body",role:"tabpanel","aria-labelledby":`mem-tab-${h}`,children:[h==="entries"?l.jsx(NO,{query:f,core:m,scope:{workspaceId:e,projectId:t}}):null,h==="playbooks"?l.jsx(KO,{workspaceId:e,projectId:t}):null,h==="timeline"?l.jsx(FO,{}):null,h==="numbers"?l.jsx(WO,{core:m}):null]})]})}const V0=4e3,Fw={low:"baixa",medium:"média",high:"alta"},fp={human:"você",agent:"agente",distiller:"destilação",auto_research:"auto-learn",import:"importação"},k_={global:"você · atravessa workspace",workspace:"workspace",project:"projeto"};function NO({query:e,core:t,scope:s}){var S;const[n,a]=j.useState(""),c=gO(s,n),h=l.jsx("div",{className:"mem-find",children:l.jsx("input",{type:"search",className:"focus-ring",placeholder:"buscar na memória…","aria-label":"Buscar na memória",value:n,onChange:x=>a(x.target.value)})});if(n.trim()!=="")return l.jsxs(l.Fragment,{children:[h,l.jsx(TO,{found:c})]});if(e.isPending)return l.jsx("p",{className:"mem-meta",children:"carregando…"});if(e.isError)return l.jsx(hs,{title:"Não deu para ler a memória",children:e.error.message});const{entries:d,shadowed:f}=e.data;if(d.length===0)return l.jsx(hs,{title:"Nada aprendido ainda",children:"A memória aparece aqui quando algo durável for salvo."});const m=new Map;for(const x of f)m.set(x.winner,[...m.get(x.winner)??[],x.identity]);const g=new Map((((S=t.data)==null?void 0:S.entries)??[]).map(x=>[x.path,x.chars])),b=["project","workspace","global"].map(x=>({scope:x,rows:d.filter(w=>w.scope===x)})).filter(x=>x.rows.length>0);return l.jsxs(l.Fragment,{children:[h,b.map(x=>l.jsxs("section",{children:[l.jsxs("h3",{className:"mem-group__t",children:[l.jsx("span",{className:"mem-scope","data-scope":x.scope,children:k_[x.scope]??x.scope}),l.jsx("span",{className:"mem-group__n",children:x.rows.length})]}),l.jsx("ul",{className:"mem-list",children:x.rows.map(w=>{var k;return l.jsxs("li",{className:"mem-item",children:[l.jsx(OO,{entry:w}),l.jsx("p",{className:"mem-desc",children:w.description}),l.jsxs("p",{className:"mem-meta",children:[l.jsx("span",{children:fp[w.sourceActor]??w.sourceActor}),l.jsxs("span",{children:["confiança ",Fw[w.confidence]??w.confidence]}),l.jsx(EO,{entry:w}),w.pinned&&g.get(w.path)!==void 0?l.jsxs("span",{className:"mem-pin-cost",children:[(g.get(w.path)??0).toLocaleString("pt-BR")," car."]}):null]}),(k=m.get(w.path))==null?void 0:k.map(N=>l.jsxs("p",{className:"mem-shadow-note",children:["sombreia ",l.jsx("strong",{children:N})," — continua no disco"]},N))]},w.path)})})]},x.scope))]})}function EO({entry:e}){const t=bO();return l.jsx("button",{type:"button",className:"mem-pin focus-ring","aria-pressed":e.pinned,disabled:t.isPending,onClick:()=>t.mutate({path:e.path,pinned:!e.pinned}),children:e.pinned?"no núcleo":"fixar no núcleo"})}function TO({found:e}){return e.isPending?l.jsx("p",{className:"mem-meta",children:"buscando…"}):e.isError?l.jsx(hs,{title:"Não deu para buscar",children:e.error.message}):e.data.skipped==="trivial_query"?l.jsx(hs,{title:"Busca não realizada",children:"Menos de dois termos significativos — dizer que não buscou é diferente de dizer que não achou."}):l.jsxs(l.Fragment,{children:[e.data.staleIndex?l.jsx("p",{className:"mem-stale",children:"índice desatualizado — o resultado pode estar curto"}):null,e.data.hits.length===0?l.jsx(hs,{title:"Nada encontrado",children:"Nenhuma memória casa com esses termos no escopo ativo."}):l.jsx("ul",{className:"mem-list",children:e.data.hits.map(t=>l.jsxs("li",{className:"mem-item",children:[l.jsxs("p",{className:"mem-row",children:[l.jsx("span",{className:"mem-scope","data-scope":t.entry.scope,children:k_[t.entry.scope]??t.entry.scope}),l.jsx("span",{className:"mem-kind",children:t.entry.type}),l.jsx("span",{className:"mem-name",children:t.entry.name})]}),l.jsx("p",{className:"mem-desc",children:t.entry.description}),l.jsx("p",{className:"mem-why",children:t.why.map(s=>l.jsx("span",{children:s},s))})]},t.entry.path))})]})}function OO({entry:e}){return l.jsxs("p",{className:"mem-row",children:[l.jsx("span",{className:"mem-kind",children:e.type}),l.jsx("span",{className:"mem-name",children:e.name})]})}const AO=[{id:"pending",label:"Pendentes"},{id:"resolved",label:"Resolvidas"}];function RO({status:e}={}){const[t,s]=j.useState("pending"),n=e??t,a=j_(n);return l.jsxs(l.Fragment,{children:[e===void 0&&l.jsx("div",{className:"mem-seg",role:"group","aria-label":"Propostas por estado",children:AO.map(c=>l.jsx("button",{type:"button",className:`mem-seg__item${n===c.id?" mem-seg__item--active":""}`,"aria-pressed":n===c.id,onClick:()=>{s(c.id)},children:c.label},c.id))}),l.jsx(DO,{query:a,status:n})]})}function DO({query:e,status:t}){return e.isPending?l.jsx("p",{className:"mem-meta",children:"carregando…"}):e.isError?l.jsx(hs,{title:"Não deu para ler as propostas",children:e.error.message}):e.data.length===0?t==="pending"?l.jsx(hs,{title:"Nenhuma proposta pendente",children:"Escrita de workspace feita por agente cai aqui antes de valer."}):l.jsx(hs,{title:"Nada decidido ainda",children:"Aprovar ou rejeitar move a proposta para cá — recusar é histórico, não apagamento."}):l.jsx("ul",{className:"mem-list",children:e.data.map(s=>l.jsx("li",{className:"mem-item",children:s.status==="pending"?l.jsx(BO,{proposal:s}):l.jsx(zO,{proposal:s})},s.id))})}function MO({current:e,proposal:t}){return l.jsxs("div",{className:"mem-conflict",children:[l.jsxs("p",{className:"mem-conflict__t",children:[l.jsx("span",{className:"mem-warn",children:"conflito no mesmo escopo"}),"já existe memória aqui — aprovar substitui"]}),l.jsxs("div",{className:"mem-split",children:[l.jsxs("div",{children:[l.jsx("strong",{children:"A que está valendo"}),l.jsx("p",{className:"mem-desc",children:e.description}),l.jsxs("p",{className:"mem-meta",children:[l.jsx("span",{children:fp[e.sourceActor]??e.sourceActor}),l.jsxs("span",{children:["confiança ",Fw[e.confidence]??e.confidence]})]})]}),l.jsxs("div",{children:[l.jsx("strong",{children:"A que chegou"}),l.jsx("p",{className:"mem-desc",children:t.description}),l.jsxs("p",{className:"mem-meta",children:[l.jsx("span",{children:fp[t.actor]??t.actor}),l.jsx("span",{children:t.evidence===null?"sem evidência":"com evidência"})]})]})]})]})}function BO({proposal:e}){const{approve:t,reject:s}=jO(),[n,a]=j.useState("none");return l.jsxs(l.Fragment,{children:[l.jsx(Iw,{proposal:e}),l.jsx("p",{className:"mem-desc",children:e.description}),l.jsx("pre",{className:"mem-body-text",children:e.body===""?"(sem corpo — só nome e descrição)":e.body}),l.jsx(PO,{proposal:e}),e.current===null?null:l.jsx(MO,{current:e.current,proposal:e}),n==="edit"?l.jsx(LO,{proposal:e,approve:t,onCancel:()=>{a("none")}}):n==="reject"?l.jsx(qO,{proposal:e,reject:s,onCancel:()=>{a("none")}}):l.jsxs("div",{className:"mem-actions",children:[l.jsx(ce,{variant:"primary",disabled:t.isPending,onClick:()=>{t.mutate({id:e.id})},children:"Aprovar"}),l.jsx(ce,{onClick:()=>{a("edit")},children:"Editar e aprovar"}),l.jsx(ce,{variant:"ghost",onClick:()=>{a("reject")},children:"Rejeitar"})]}),t.isError?l.jsxs(ke,{tone:"danger",children:["não deu para aprovar: ",t.error.message]}):null,s.isError?l.jsxs(ke,{tone:"danger",children:["não deu para rejeitar: ",s.error.message]}):null]})}function LO({proposal:e,approve:t,onCancel:s}){const[n,a]=j.useState(e.name),[c,h]=j.useState(e.description),[d,f]=j.useState(e.body),m=n.trim()===""||c.trim()==="";return l.jsxs("div",{className:"mem-form",children:[l.jsx($t,{id:`prop-${e.id}-name`,label:"Nome",children:l.jsx(ts,{id:`prop-${e.id}-name`,value:n,onChange:g=>{a(g.target.value)}})}),l.jsx($t,{id:`prop-${e.id}-description`,label:"Descrição",children:l.jsx(ts,{id:`prop-${e.id}-description`,value:c,onChange:g=>{h(g.target.value)}})}),l.jsx($t,{id:`prop-${e.id}-body`,label:"Corpo",children:l.jsx("textarea",{id:`prop-${e.id}-body`,className:"mem-textarea",rows:6,value:d,onChange:g=>{f(g.target.value)}})}),l.jsxs("div",{className:"mem-actions",children:[l.jsx(ce,{variant:"primary",disabled:t.isPending||m,onClick:()=>{t.mutate({id:e.id,...n===e.name?{}:{name:n},...c===e.description?{}:{description:c},...d===e.body?{}:{body:d}})},children:"Aprovar com edição"}),l.jsx(ce,{variant:"ghost",onClick:s,children:"Cancelar"})]})]})}function qO({proposal:e,reject:t,onCancel:s}){const[n,a]=j.useState("");return l.jsxs("div",{className:"mem-form",children:[l.jsx(ke,{tone:"warning",children:"Rejeitar não tem volta: a proposta fica no histórico como recusada, e não há como reabri-la."}),l.jsx($t,{id:`prop-${e.id}-note`,label:"Por que não? (fica registrado)",children:l.jsx(ts,{id:`prop-${e.id}-note`,value:n,maxLength:500,placeholder:"isso é regra do api, não do produto",onChange:c=>{a(c.target.value)}})}),l.jsxs("div",{className:"mem-actions",children:[l.jsx(ce,{variant:"danger",disabled:t.isPending,onClick:()=>{t.mutate({id:e.id,...n.trim()===""?{}:{note:n.trim()}})},children:"Rejeitar"}),l.jsx(ce,{variant:"ghost",onClick:s,children:"Cancelar"})]})]})}function zO({proposal:e}){return l.jsxs(l.Fragment,{children:[l.jsx(Iw,{proposal:e}),l.jsx("p",{className:"mem-desc",children:e.description}),l.jsxs("p",{className:"mem-meta",children:[l.jsx("span",{className:"mem-verdict","data-status":e.status,children:e.status==="approved"?"aprovada":"rejeitada"}),l.jsxs("span",{children:["proposta por ",e.actor]}),e.resolvedAt===null?null:l.jsx("span",{children:Uw(e.resolvedAt)})]}),e.resolutionNote===null?null:l.jsx("p",{className:"mem-shadow-note",children:e.resolutionNote})]})}function PO({proposal:e}){return l.jsxs("div",{className:"mem-evidence",children:[e.evidence===null?l.jsxs(l.Fragment,{children:[l.jsx("strong",{children:"Sem evidência verificável"})," — o agente concluiu. Conclusão vira proposta; fato vira memória."]}):l.jsxs(l.Fragment,{children:[l.jsx("strong",{children:"Evidência"})," — ",l.jsx("code",{children:e.evidence})]}),l.jsx("br",{}),"proposta por ",l.jsx("strong",{children:e.actor}),e.fromProjectId===null?null:l.jsxs(l.Fragment,{children:[" · projeto ",e.fromProjectId]})]})}function Iw({proposal:e}){return l.jsxs("p",{className:"mem-row",children:[l.jsx("span",{className:"mem-scope","data-scope":e.scope,children:e.scope==="global"?"você":e.scope}),l.jsx("span",{className:"mem-kind",children:e.type}),l.jsx("span",{className:"mem-name",children:e.name})]})}const HO={applied:"aprendeu",rejected:"recusou",noop:"nada a fazer"};function FO(){const e=vO();return e.isPending?l.jsx("p",{className:"mem-meta",children:"carregando…"}):e.isError?l.jsx(hs,{title:"Não deu para ler o histórico",children:e.error.message}):e.data.length===0?l.jsx(hs,{title:"Nada decidido ainda",children:"Cada escrita — e cada recusa — aparece aqui."}):l.jsx("ol",{className:"mem-tl",children:e.data.map(t=>l.jsxs("li",{className:"mem-tl-item","data-outcome":t.outcome,children:[l.jsx("span",{className:"mem-tl-when",children:IO(t)}),l.jsx("span",{className:"mem-tl-dot",children:t.outcome==="rejected"?"▲":"●"}),l.jsxs("span",{children:[l.jsx("span",{className:"mem-tl-verb",children:HO[t.outcome]??t.outcome})," ",l.jsx("span",{children:t.path}),t.reason===null?null:l.jsxs(l.Fragment,{children:[" — ",l.jsx("em",{children:t.reason})]}),(t.taskTitles??[]).length>0&&l.jsxs("span",{className:"mem-tl-task",children:[" · ",(t.taskTitles??[]).join(", ")]})]})]},t.id))})}function IO(e){return Uw(e.createdAt)}function Uw(e){return new Date(e).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}const UO={active:"ativo",stale:"parado",archived:"arquivado"};function KO({workspaceId:e,projectId:t}){var h,d;const[s,n]=j.useState(!1),a=xO({workspaceId:e,archived:s}),c=wO();return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"mem-seg",role:"group","aria-label":"Vista dos playbooks",children:[{label:"ativos",value:!1},{label:"arquivados",value:!0}].map(f=>l.jsx("button",{type:"button",className:`mem-seg__item${s===f.value?" mem-seg__item--active":""}`,"aria-pressed":s===f.value,onClick:()=>n(f.value),children:f.label},f.label))}),a.isPending?l.jsx("p",{className:"mem-meta",children:"carregando…"}):null,a.isError?l.jsx(hs,{title:"Não deu para ler os playbooks",children:a.error.message}):null,((h=a.data)==null?void 0:h.length)===0?l.jsx(hs,{title:s?"Nenhum playbook arquivado":"Nenhum playbook ainda",children:s?"Arquivar não apaga: o que for arquivado aparece aqui.":"Playbook é procedimento — o caminho que já funcionou, para a próxima vez."}):null,(d=a.data)==null?void 0:d.map(f=>l.jsxs("div",{className:"pb",children:[l.jsxs("p",{className:"pb__row",children:[l.jsx("span",{className:"life","data-life":f.lifecycle,children:UO[f.lifecycle]??f.lifecycle}),l.jsx("span",{className:"pb__class",children:f.taskClass})]}),l.jsx("p",{className:"pb__desc",children:f.description}),l.jsxs("p",{className:"pb__use",children:[l.jsxs("span",{className:"pb__loads",children:[f.loads,"×"]}),l.jsx("span",{children:f.lastLoadedAt===null?"nunca carregado":$O(f.lastLoadedAt)}),l.jsx("span",{className:"mem-scope","data-scope":f.scope,children:k_[f.scope]??f.scope}),l.jsx("button",{type:"button",className:"pb__act focus-ring",disabled:c.isPending,onClick:()=>c.mutate({path:f.path,archived:!f.archived}),children:f.archived?"desarquivar":"arquivar"})]}),f.lifecycle==="stale"?l.jsx("p",{className:"pb__suggest",children:"parado há muito tempo — talvez o procedimento tenha mudado. Arquivar não apaga: carregar de novo reativa."}):null]},f.path))]})}function $O(e){const t=Math.floor((Date.now()-new Date(e).getTime())/864e5);return t<=0?"último uso hoje":t===1?"último uso ontem":`último uso há ${String(t)} dias`}function WO({core:e}){const t=CO(),s=SO();if(t.isPending)return l.jsx("p",{className:"mem-meta",children:"carregando…"});if(t.isError)return l.jsx(hs,{title:"Não deu para ler os números",children:t.error.message});const n=e.data;return l.jsxs("div",{className:"mem-stats",children:[n!==void 0&&n.entries.length>0?l.jsxs("div",{className:`mem-stat${n.chars>V0?" mem-stat--warn":""}`,children:[l.jsx("div",{className:"n",children:n.chars.toLocaleString("pt-BR")}),l.jsx("div",{className:"l",children:"caracteres no núcleo"}),l.jsxs("div",{className:"hint",children:[n.entries.length," ",n.entries.length===1?"diretriz fixada":"diretrizes fixadas",n.recentChars>0?` · ${n.recentChars.toLocaleString("pt-BR")} entraram em 30 dias`:"",n.chars>V0?" · hora de consolidar":""]})]}):null,s.data!==void 0?l.jsxs("div",{className:"mem-stat",children:[l.jsx("div",{className:"n",children:s.data.distill?"on":"off"}),l.jsx("div",{className:"l",children:"destilação de fim de sessão"}),l.jsx("div",{className:"hint",children:s.data.distill?"cada sessão de agente que termina custa uma sessão de destilação":"ligue com LUMEM_MEMORY_DISTILL=1"})]}):null,s.data!==void 0?l.jsxs("div",{className:"mem-stat",children:[l.jsx("div",{className:"n",children:s.data.autoLearn?"on":"off"}),l.jsx("div",{className:"l",children:"pesquisa automática"}),l.jsx("div",{className:"hint",children:s.data.autoLearn?`pergunta sem resposta sobe um agente · até ${String(s.data.autoLearnBudget)} por sessão`:"ligue com LUMEM_MEMORY_AUTO_LEARN=1"})]}):null,t.data.map(a=>l.jsxs("div",{className:"mem-stat",children:[l.jsx("div",{className:"n",children:a.events}),l.jsxs("div",{className:"l",children:[a.kind," · ",a.totalAmount," no total · ",a.averageDurationMs," ms"]})]},a.kind)),t.data.length===0?l.jsxs("div",{className:"mem-stat",children:[l.jsx("div",{className:"n",children:"0"}),l.jsx("div",{className:"l",children:"uso registrado"}),l.jsx("div",{className:"hint",children:"os números aparecem depois da primeira busca"})]}):null]})}function VO({workspaceId:e,projectName:t}){var g;const[s,n]=j.useState("pending"),a=s==="pending"?"proposed":"dropped",c=ye({queryKey:sa(e,{status:a}),queryFn:()=>te.task.listByWorkspace.query({workspaceId:e,status:a})}),h=ye({queryKey:["memory","proposals",s],queryFn:()=>te.memory.proposals.query({status:s})}),d=c.data??[],f=((g=h.data)==null?void 0:g.length)??0,m=d.length+f;return m===0&&s==="pending"?null:l.jsxs("section",{className:"section",children:[l.jsx(bn,{title:"Propostas",count:m,aside:l.jsxs("div",{className:"mem-seg",role:"group","aria-label":"Propostas por estado",children:[l.jsx("button",{type:"button",className:`mem-seg__item${s==="pending"?" mem-seg__item--active":""}`,"aria-pressed":s==="pending",onClick:()=>n("pending"),children:"Pendentes"}),l.jsx("button",{type:"button",className:`mem-seg__item${s!=="pending"?" mem-seg__item--active":""}`,"aria-pressed":s!=="pending",onClick:()=>n("rejected"),children:"Resolvidas"})]})}),l.jsx("div",{className:"tlist",children:d.map(v=>l.jsx(YO,{row:v,workspaceId:e,projectName:t(v.projectId),decided:s!=="pending"},v.id))}),f>0&&l.jsx(RO,{status:s})]})}function YO({row:e,workspaceId:t,projectName:s,decided:n}){const a=qe(),[c,h]=j.useState(!1),[d,f]=j.useState(""),m=Te({mutationFn:g=>te.task.setStatus.mutate({id:e.id,...g}),onSuccess:async()=>{await a.invalidateQueries({queryKey:sa(t)})}});return l.jsxs("div",{className:"pq-item",children:[l.jsxs("div",{className:"pq-item__head",children:[l.jsx("span",{className:"tprov__g","aria-hidden":"true",children:"◆"}),l.jsx("span",{className:"pq-item__who",children:"agente"}),l.jsxs("span",{className:"pq-item__kind",children:["tarefa · ",s]})]}),l.jsx("div",{className:"pq-item__title",children:e.title}),e.body!==""&&l.jsx("div",{className:"pq-item__why",children:e.body}),m.isError&&l.jsx(ke,{tone:"danger",children:m.error.message}),n?l.jsxs("div",{className:"pq-item__acts",children:[l.jsx("span",{className:"pq-item__verdict",children:"✕ rejeitada"}),e.reason!==null&&e.reason!==""&&l.jsxs("span",{className:"pq-item__note",children:['"',e.reason,'"']})]}):c?l.jsxs("div",{className:"pq-item__acts",children:[l.jsx("input",{className:"input","aria-label":"por que rejeitar",placeholder:"por que rejeitar?",value:d,onChange:g=>f(g.target.value)}),l.jsx(ce,{variant:"danger",disabled:d.trim()===""||m.isPending,onClick:()=>m.mutate({status:"dropped",reason:d.trim()}),children:"rejeitar"}),l.jsx(ce,{variant:"ghost",onClick:()=>h(!1),children:"cancelar"})]}):l.jsxs("div",{className:"pq-item__acts",children:[l.jsx(ce,{variant:"primary",disabled:m.isPending,onClick:()=>m.mutate({status:"open"}),children:"aprovar"}),l.jsx(ce,{variant:"ghost",onClick:()=>h(!0),children:"rejeitar"}),l.jsx("span",{className:"pq-item__note",children:"rejeitar pede um motivo — é o que ensina o agente a não propor de novo"})]})]})}function Kw(){return typeof window<"u"&&"Notification"in window}async function GO(){Kw()&&Notification.permission==="default"&&await Notification.requestPermission().catch(()=>{})}function QO(e){const t=j.useRef(new Set);j.useEffect(()=>{if(e!==void 0)for(const s of e)for(const n of s.cards){if(n.notice===null){t.current.delete(n.id);continue}if(t.current.has(n.id))continue;t.current.add(n.id);const a=n.notice;te.task.markNotified.mutate({id:n.id}).then(c=>{c.first&&(!Kw()||Notification.permission!=="granted"||new Notification("Lumem",{body:a,tag:`lumem-task-${n.id}`}))}).catch(()=>{t.current.delete(n.id)})}},[e])}const ZO={implementador:"implementando",revisor:"revisando",testador:"testando"};function $w(e,t=Date.now()){const s=Math.floor((t-new Date(e).getTime())/6e4);if(s<1)return"agora";if(s<60)return`${String(s)} min`;const n=Math.floor(s/60);return n<24?`${String(n)} h`:`${String(Math.floor(n/24))} d`}function XO(e){return e.kind==="working"?"work":e.kind==="waiting"?"wait":e.kind}function JO(e,t=Date.now()){switch(e.kind){case"manual":return"manual — ninguém pega";case"waiting":return`aguardando ${e.role}`;case"working":return`${e.role===null?"trabalhando":ZO[e.role]} há ${$w(e.since,t)}`;case"blocked":return`bloqueada: ${e.reason}`;case"paused":return`pausada até ~${new Date(e.until).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}}function eA({seal:e,now:t}){return l.jsxs("div",{className:"seal",children:[l.jsx("span",{className:"seal__dot"}),l.jsx("span",{className:"seal__t",children:JO(e,t)})]})}function tA(e){return e.cost===null?"—":new Intl.NumberFormat("pt-BR",{style:"currency",currency:e.currency??"USD"}).format(e.cost)}function sA(e){return e.seal.kind==="blocked"?e.seal.reason:e.preparedPrompt}function iA({card:e,status:t,now:s=Date.now(),onOpen:n,ghost:a=!1,onDragStart:c,onDragEnd:h,onSend:d,onStop:f}){const m=C_(e,s,t),g=e.links[0],v=sA(e),b=e.preparedPrompt!==null&&d!==void 0,S=e.seal.kind==="working"&&f!==void 0;return l.jsxs("button",{type:"button",className:`tcard tcard--${XO(e.seal)}${a?" tcard--ghost":""} focus-ring`,onClick:()=>n(e.id),draggable:c!==void 0,onDragStart:x=>{x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",e.id),c==null||c()},onDragEnd:()=>h==null?void 0:h(),children:[l.jsxs("div",{className:"tcard__top",children:[l.jsx("span",{className:"glyph glyph--project",children:"■"}),l.jsx("span",{className:"tcard__proj",children:e.projectName}),l.jsx("span",{className:`tcard__cost${e.cost===null?" tcard__cost--none":""}`,children:tA(e)})]}),l.jsx("div",{className:"tcard__t",children:e.title}),l.jsx(eA,{seal:e.seal,now:s}),v===null?null:l.jsx("div",{className:"tcard__ask",children:l.jsx("span",{className:"tcard__ask-t",children:v})}),b||S?l.jsxs("div",{className:"tcard__act",children:[b?l.jsx(Y0,{label:"enviar",onRun:()=>d(e.id)}):null,S?l.jsx(Y0,{label:"parar",onRun:()=>f(e.id)}):null]}):null,l.jsxs("div",{className:"tcard__foot",children:[e.createdBy==="agent"?l.jsx("span",{className:"tcard__from tcard__from--agent",children:"◆ proposta"}):g===void 0?null:l.jsxs("span",{className:"tcard__from tcard__from--track",children:["↗ ",rA(g)]}),e.attempts>1?l.jsxs("span",{className:"tcard__from",children:["tentativa ",e.attempts]}):null,l.jsx("span",{className:`stale${m===null?"":` stale--${m}`}`,children:$w(e.statusChangedAt,s)})]})]})}function Y0({label:e,onRun:t}){return l.jsx("span",{role:"button",tabIndex:0,className:"btn btn--sm focus-ring",onClick:s=>{s.stopPropagation(),t()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),s.stopPropagation(),t())},children:e})}function rA(e){const t=e.split("/").filter(s=>s!=="");return t[t.length-1]??e}const nA=1418,aA=200;function lA(e,t){const s=e-t;return s<=0?0:Math.max(1,Math.ceil(s/aA))}function oA({workspaceId:e,projectId:t,onOpen:s,now:n=Date.now()}){const[a,c]=j.useState(qw),[h,d]=j.useState(!1),[f,m]=j.useState(null),[g,v]=j.useState(null),{ref:b,clipped:S}=uA(),x=qe(),w=Jx(e,t??null),k=ye({queryKey:w,queryFn:()=>te.task.board.query({workspaceId:e,...t===void 0?{}:{projectId:t}})});QO(k.data);const N=(k.data??[]).map(O=>({...O,cards:h?O.cards.filter(W=>dp(W,O.status,n)):O.cards})),L=O=>{var W;return((W=(k.data??[]).find(ee=>ee.status===O))==null?void 0:W.cards)??[]},R=(O,W)=>{const ee=L(O).findIndex(T=>T.id===W);return ee===-1?L(O).length:ee},D=(k.data??[]).reduce((O,W)=>O+W.cards.filter(ee=>ee.notice!==null).length,0),Y=(k.data??[]).reduce((O,W)=>O+W.cards.filter(ee=>dp(ee,W.status,n)).length,0),K=Te({mutationFn:O=>te.task.move.mutate(O),onSettled:()=>x.invalidateQueries({queryKey:w})}),Z=Te({mutationFn:O=>te.task.stop.mutate({id:O}),onSettled:()=>x.invalidateQueries({queryKey:w})}),Q=Te({mutationFn:O=>te.task.sendPrepared.mutate({id:O}),onSettled:()=>x.invalidateQueries({queryKey:w})}),z=Te({mutationFn:O=>te.task.setAutonomy.mutate({id:O,autonomy:"off"}),onSettled:()=>x.invalidateQueries({queryKey:w})});function G(O){const W=(k.data??[]).flatMap(ee=>ee.cards).find(ee=>ee.id===O);(W==null?void 0:W.seal.kind)==="working"&&W.autonomy!=="off"&&z.mutate(O),s(O)}const le=Te({mutationFn:O=>te.task.finish.mutate({id:O}),onSuccess:O=>{v(O.cleanup.kind==="keep"?O.cleanup.reason??null:null)},onSettled:()=>x.invalidateQueries({queryKey:w})});function H(O,W){if(f!==null){if(O==="done"){le.mutate(f),m(null);return}K.mutate({id:f,status:O,index:W}),m(null)}}return l.jsxs("main",{className:"bd",children:[l.jsx("div",{className:"bd__head",children:l.jsxs("div",{className:"bd__title",children:[l.jsx("h2",{className:"bd__t",children:"Quadro de tarefas"}),l.jsx("span",{className:"bd__sub",children:"todas as tarefas deste workspace, em uma tela"})]})}),l.jsxs("div",{className:"bd__bar",children:[l.jsxs("button",{type:"button",className:"needme focus-ring","aria-pressed":h,onClick:()=>d(O=>!O),children:["precisa de mim",Y===0?null:l.jsx("span",{className:"needme__n",children:Y})]}),g===null?null:l.jsxs("span",{className:"bd__unseen",children:["a worktree ficou: ",g]}),D===0?null:l.jsx("span",{className:"bd__unseen",children:D===1?"1 parou enquanto você não estava":`${String(D)} pararam enquanto você não estava`})]}),S===0?null:l.jsxs("div",{className:"bd__clip",children:[l.jsx("span",{className:"bd__clip-g",children:"⟷"}),l.jsxs("span",{children:[l.jsx("b",{children:S===1?"1 coluna fora da tela.":`${String(S)} colunas fora da tela.`})," ","O quadro pede ",String(nA),"px de janela com as duas pontas recolhidas — role para o lado, ou alargue."]}),l.jsx("span",{className:"bd__clip__which",children:Fo.ready_to_merge})]}),l.jsx("div",{className:"bd__cols",ref:b,children:N.map(O=>a.includes(O.status)?l.jsx("button",{type:"button",className:"col col--rail focus-ring","aria-expanded":!1,onClick:()=>c(W=>W.filter(ee=>ee!==O.status)),children:l.jsxs("div",{className:"col__h",children:[l.jsx("span",{className:"col__t",children:Fo[O.status]}),l.jsx("span",{className:"col__n",children:O.cards.length})]})},O.status):l.jsxs("section",{className:"col","aria-label":Fo[O.status],children:[l.jsx(cA,{column:O,now:n,onCollapse:()=>c(W=>[...W,O.status])}),l.jsx("div",{className:"col__body",onDragOver:W=>{f!==null&&W.preventDefault()},onDrop:()=>H(O.status,L(O.status).length),children:O.cards.length===0?l.jsx("div",{className:"col__empty",children:"vazia"}):O.cards.map(W=>l.jsx("div",{onDragOver:ee=>{f!==null&&ee.preventDefault()},onDrop:ee=>{ee.stopPropagation(),H(O.status,R(O.status,W.id))},children:l.jsx(iA,{card:W,status:O.status,now:n,onOpen:G,ghost:f===W.id,onDragStart:()=>m(W.id),onDragEnd:()=>m(null),onSend:ee=>Q.mutate(ee),onStop:ee=>Z.mutate(ee)})},W.id))})]},O.status))})]})}function cA({column:e,now:t,onCollapse:s}){const n=hO(e,t),a=n.over>0?"over":n.warn>0?"warn":null,c=n.over+n.warn;return l.jsxs("div",{className:"col__h",children:[l.jsx("span",{className:"col__t",children:Fo[e.status]}),l.jsx("span",{className:"col__n",children:e.cards.length}),zw.includes(e.status)&&e.status!=="done"?l.jsx("span",{className:"col__you",children:"sua vez"}):null,a===null?qw.includes(e.status)?l.jsx("button",{type:"button",className:"col__add focus-ring",onClick:s,"aria-label":`Recolher ${Fo[e.status]}`,children:"‹"}):null:l.jsx("span",{className:`col__stale col__stale--${a}`,title:c===1?"1 tarefa encalhada":`${String(c)} tarefas encalhadas`})]})}function uA(){const[e,t]=j.useState(0),s=j.useRef(null),n=j.useCallback(()=>{const c=s.current;c!==null&&t(lA(c.scrollWidth,c.clientWidth))},[]);return j.useLayoutEffect(n),j.useEffect(()=>{const c=()=>n();return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[n]),{ref:j.useCallback(c=>{s.current=c},[]),clipped:e}}function hA({taskId:e,workspaceId:t,onBack:s,onWork:n}){const a=qe(),[c,h]=j.useState(!1),d=ye({queryKey:ip(e),queryFn:()=>te.task.get.query({id:e})}),f=Te({mutationFn:v=>te.task.setStatus.mutate({id:e,...v}),onSuccess:async()=>{await a.invalidateQueries({queryKey:sa(t)}),await a.invalidateQueries({queryKey:ip(e)})}});if(d.isError)return l.jsx(ke,{tone:"danger",children:d.error.message});if(d.isPending)return l.jsx(ys,{label:"buscando a tarefa"});if(d.data===null)return l.jsx(ke,{tone:"warning",children:"esta tarefa não existe mais"});const m=d.data,g=m.status==="done"||m.status==="dropped";return l.jsxs("div",{className:"tdet",children:[l.jsxs("div",{className:"crumb",children:[l.jsx("button",{type:"button",className:"crumb__up focus-ring",onClick:s,children:"Tarefas"}),l.jsx("span",{className:"crumb__sep",children:"/"}),l.jsx("span",{className:"crumb__here",children:m.title})]}),l.jsxs("div",{className:"tdet__head",children:[l.jsx("h2",{className:"tdet__title",children:m.title}),l.jsxs("span",{className:"tdet__acts",children:[!g&&l.jsx(ce,{variant:"primary",onClick:()=>h(!0),children:"trabalhar nesta tarefa"}),!g&&l.jsx(ce,{onClick:()=>f.mutate({status:"done"}),children:"marcar done"}),!g&&l.jsx(ce,{variant:"ghost",onClick:()=>{const v=window.prompt("por que descartar esta tarefa?");v!==null&&v.trim()!==""&&f.mutate({status:"dropped",reason:v.trim()})},children:"descartar"}),g&&l.jsx(ce,{onClick:()=>f.mutate({status:"open"}),children:"reabrir"})]})]}),f.isError&&l.jsx(ke,{tone:"danger",children:f.error.message}),l.jsxs("div",{className:"chips",children:[l.jsx(kt,{children:m.status}),m.createdBy==="agent"&&l.jsx(kt,{children:"◆ proposta por agente"}),m.worktreeId===null?l.jsx(kt,{children:"sem checkout"}):l.jsx(kt,{tone:"branch",children:"◇ checkout"}),m.reason!==null&&m.reason!==""&&l.jsx(kt,{children:m.reason})]}),m.body!==""&&l.jsxs("section",{className:"section",children:[l.jsx(bn,{title:"O corpo"}),l.jsx("div",{className:"tdet__body",children:m.body})]}),l.jsx(dA,{taskId:e}),c&&l.jsx(fA,{taskId:e,projectId:m.projectId,title:m.title,body:m.body,worktreeId:m.worktreeId,onClose:()=>h(!1),onOpened:v=>{h(!1),n(v)}})]})}function dA({taskId:e}){const t=ye({queryKey:["session","byTask",e],queryFn:()=>te.session.listByTask.query({taskId:e})}),s=t.data??[];return l.jsxs("section",{className:"section",children:[l.jsx(bn,{title:"As sessões",count:s.length}),t.isError?l.jsx(ke,{tone:"danger",children:t.error.message}):t.isPending?l.jsx(ys,{label:"buscando as sessões",widths:["80%"]}):s.length===0?l.jsx("p",{className:"detail__hint",children:"ninguém trabalhou nesta tarefa ainda"}):l.jsx("div",{className:"tlist",children:s.map(n=>l.jsxs("div",{className:"tsess",children:[l.jsxs("span",{className:"tsess__kind",children:[l.jsx("span",{className:`glyph glyph--${n.kind==="agent"?"agent":"shell"}`,"aria-hidden":"true",children:n.kind==="agent"?"◆":"●"}),n.agentName??n.kind]}),l.jsx("span",{className:"tsess__when",children:n.command}),l.jsxs("span",{className:`tsess__st tsess__st--${n.state}`,children:[l.jsx("span",{className:"tsess__dot","aria-hidden":"true"}),n.state==="running"?"viva":"encerrada"]})]},n.id))})]})}function fA({taskId:e,projectId:t,title:s,body:n,worktreeId:a,onClose:c,onOpened:h}){var D,Y,K,Z;const d=qe(),[f,m]=j.useState(a===null?"new":"existing"),[g,v]=j.useState(()=>mA(s)),[b,S]=j.useState(a),x=ye({queryKey:gr(t),queryFn:()=>te.worktree.listByProject.query({projectId:t})}),w=ye({queryKey:["agentConfig","list"],queryFn:()=>te.agentConfig.list.query()}),[k,N]=j.useState(null),L=k??((Y=(D=w.data)==null?void 0:D[0])==null?void 0:Y.id)??null,R=Te({mutationFn:async()=>{const Q=f==="new"?(await te.worktree.create.mutate({projectId:t,name:g,taskId:e})).id:b;if(Q===null)throw new Error("escolha um checkout");if(L===null)throw new Error("nenhum agente configurado");f==="existing"&&await te.task.attachWorktree.mutate({id:e,worktreeId:Q});const z=await te.session.createAgent.mutate({scopeType:"worktree",scopeId:Q,agentConfigId:L,taskId:e});return{worktreeId:Q,sessionId:z.id}},onSuccess:async Q=>{await d.invalidateQueries({queryKey:gr(t)}),await d.invalidateQueries({queryKey:ip(e)}),h({projectId:t,worktreeId:Q.worktreeId,sessionId:Q.sessionId,draft:n})}});return l.jsx(Ah,{open:!0,title:"Trabalhar nesta tarefa",onClose:c,children:l.jsxs("div",{className:"work",children:[l.jsxs("div",{className:"seg",role:"group","aria-label":"onde trabalhar",children:[l.jsx("button",{type:"button",className:"seg__btn","aria-pressed":f==="new",onClick:()=>m("new"),children:"worktree nova"}),l.jsx("button",{type:"button",className:"seg__btn","aria-pressed":f==="existing",onClick:()=>m("existing"),children:"checkout existente"})]}),f==="new"?l.jsxs("label",{className:"field",children:[l.jsx("span",{className:"field__label",children:"Nome da worktree"}),l.jsx("input",{className:"input",value:g,onChange:Q=>v(Q.target.value)}),l.jsx("span",{className:"field__help",children:"derivado do título — a sugestão é do Lumem, e o nome continua seu"})]}):l.jsx("div",{className:"work__list",role:"listbox","aria-label":"checkouts",children:(x.data??[]).map(Q=>l.jsxs("button",{type:"button",role:"option","aria-selected":b===Q.id,className:`wopt${b===Q.id?" is-selected":""}`,onClick:()=>S(Q.id),children:[l.jsx("span",{className:"glyph glyph--worktree","aria-hidden":"true",children:"◇"}),l.jsx("span",{className:"wopt__name",children:Q.name})]},Q.id))}),(((K=w.data)==null?void 0:K.length)??0)>1&&l.jsx("div",{className:"work__list",role:"listbox","aria-label":"agentes",children:(Z=w.data)==null?void 0:Z.map(Q=>l.jsxs("button",{type:"button",role:"option","aria-selected":L===Q.id,className:`wopt${L===Q.id?" is-selected":""}`,onClick:()=>N(Q.id),children:[l.jsx("span",{className:"glyph glyph--agent","aria-hidden":"true",children:"◆"}),l.jsx("span",{className:"wopt__name",children:Q.name})]},Q.id))}),R.isError&&l.jsx(ke,{tone:"danger",children:R.error.message}),l.jsxs("div",{className:"modal__foot",children:[l.jsx(ce,{variant:"primary",disabled:R.isPending,onClick:()=>R.mutate(),children:R.isPending?"abrindo…":"abrir"}),l.jsx(ce,{variant:"ghost",onClick:c,children:"cancelar"})]})]})})}function mA(e){const t=e.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").split("-").slice(0,5).join("-");return t===""?"tarefa":t}const pA={proposed:"proposta",open:"open",in_progress:"in progress",review:"review",done:"done",dropped:"dropped"},_A={done:"✓",dropped:"–"};function mm(e,t=""){return e===null?"sem teto":`${t}${t===""?"":" "}${t===""?String(e):e.toFixed(2)}`}const gA=[{value:"manual",label:"manual"},{value:"assistido",label:"assistido"},{value:"autonomo",label:"autônomo"}];function vA({workspaceId:e,projectId:t,onOpen:s,onCreate:n,onOpenBoard:a}){var Z,Q;const[c,h]=j.useState(t??null),[d,f]=j.useState(!1),g=ye({queryKey:sa(e,c===null?void 0:{projectId:c}),queryFn:()=>te.task.listByWorkspace.query({workspaceId:e,...c===null?{}:{projectId:c}})}),v=qe(),b=MN(e),S=ye({queryKey:b,queryFn:()=>te.task.settings.query({workspaceId:e})}),x=Te({mutationFn:z=>{var G;return te.workspace.setAutonomy.mutate({id:e,autonomy:z,maxParallel:((G=S.data)==null?void 0:G.maxParallel)??2})},onSettled:()=>{v.invalidateQueries({queryKey:sa(e)}),v.invalidateQueries({queryKey:b})}}),w=Te({mutationFn:z=>te.workspace.setCleanup.mutate({id:e,mergedAlwaysRemoves:z}),onSettled:()=>{v.invalidateQueries({queryKey:sa(e)}),v.invalidateQueries({queryKey:b})}}),k=ye({queryKey:["usage","byTask",e],queryFn:()=>te.usage.byTask.query({workspaceId:e,period:"7d"})}),N=ye({queryKey:gn(e),queryFn:()=>te.project.listByWorkspace.query({workspaceId:e}),enabled:t===void 0}),L=z=>{var G,le;return((le=(G=N.data)==null?void 0:G.find(H=>H.id===z))==null?void 0:le.name)??""},R=z=>{var G,le;return((le=(G=k.data)==null?void 0:G.find(H=>H.taskId===z))==null?void 0:le.cost)??null},D=g.data??[],Y=D.filter(z=>z.status!=="done"&&z.status!=="dropped"),K=D.filter(z=>z.status==="done");return l.jsxs("section",{className:"section",children:[l.jsx(bn,{title:"Tarefas",count:D.length,aside:l.jsxs(l.Fragment,{children:[t===void 0&&(((Z=N.data)==null?void 0:Z.length)??0)>1&&l.jsxs("select",{className:"input tlist__filter","aria-label":"Filtrar tarefas por projeto",value:c??"",onChange:z=>h(z.target.value===""?null:z.target.value),children:[l.jsx("option",{value:"",children:"todos os projetos"}),(Q=N.data)==null?void 0:Q.map(z=>l.jsx("option",{value:z.id,children:z.name},z.id))]}),a&&t===void 0&&l.jsx(ce,{size:"sm",variant:"ghost",onClick:a,children:"quadro"}),n&&l.jsx(ce,{size:"sm",onClick:n,children:"+ tarefa"})]})}),g.isError?l.jsx(ke,{tone:"danger",children:g.error.message}):g.isPending?l.jsx(ys,{label:"buscando as tarefas",widths:["90%","70%"]}):D.length===0?l.jsx(hs,{title:"Nenhuma tarefa ainda",action:n&&l.jsx(ce,{variant:"primary",onClick:n,children:"criar a primeira"}),children:"Tarefa é para o trabalho que você quer acompanhar — ela guarda o corpo, o checkout, as sessões e o custo. Conversa rápida continua a um clique, sem tarefa nenhuma."}):l.jsxs("div",{className:"tlist",children:[S.data!==void 0&&l.jsxs("p",{className:"tlist__budget",children:["gasto: ",l.jsx("b",{children:mm(S.data.caps.costPerTask,"US$")})," por tarefa ·"," ",l.jsx("b",{children:mm(S.data.caps.costPerDay,"US$")})," por dia ·"," ",l.jsx("b",{children:mm(S.data.caps.turnsPerSession)})," turnos por sessão",l.jsx("br",{}),"um agente pode criar até ",l.jsx("b",{children:S.data.budget})," tarefas por tarefa · mude em"," ",l.jsx("code",{children:S.data.budgetEnv}),l.jsx("br",{}),"esteira:"," ",gA.map(z=>{var G;return l.jsx("button",{type:"button",className:`btn btn--sm focus-ring${((G=S.data)==null?void 0:G.autonomy)===z.value?" btn--brand":""}`,onClick:()=>{z.value!=="manual"&&GO(),x.mutate(z.value)},children:z.label},z.value)})," ","· ",l.jsx("b",{children:S.data.maxParallel})," em paralelo",l.jsx("br",{}),l.jsxs("label",{className:"tlist__switch",children:[l.jsx("input",{type:"checkbox",checked:S.data.mergedAlwaysRemoves,onChange:z=>{w.mutate(z.target.checked)}})," ","PR mesclada sempre remove a worktree — ",l.jsx("b",{children:"inclusive com arquivo não commitado"})]}),S.data.sessions>0&&l.jsxs(l.Fragment,{children:[" · ",l.jsxs("b",{children:[S.data.sessionsWithTask," de ",S.data.sessions]})," ","sessões têm tarefa"]})]}),Y.map(z=>l.jsx(G0,{row:z,projectName:L(z.projectId),cost:R(z.id),onOpen:s},z.id)),K.length>0&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:"tfold focus-ring","aria-expanded":d,onClick:()=>f(z=>!z),children:[l.jsx("span",{className:"tfold__caret","aria-hidden":"true",children:d?"▾":"▸"}),"done",l.jsx("span",{className:"tfold__n",children:K.length})]}),d&&K.map(z=>l.jsx(G0,{row:z,projectName:L(z.projectId),cost:R(z.id),onOpen:s},z.id))]})]})]})}function G0({row:e,projectName:t,cost:s,onOpen:n}){const a=_A[e.status];return l.jsxs("button",{type:"button",className:`trow trow--${e.status} focus-ring`,onClick:()=>n(e.id),children:[l.jsxs("span",{className:"tstat",children:[a===void 0?l.jsx("span",{className:"tstat__dot","aria-hidden":"true"}):l.jsx("span",{className:"tstat__g","aria-hidden":"true",children:a}),pA[e.status]??e.status]}),l.jsxs("span",{className:"trow__t",children:[e.title,e.reason!==null&&e.reason!==""&&l.jsxs("span",{className:"trow__why",children:[" — ",e.reason]})]}),l.jsx("span",{className:"trow__proj",children:t!==""&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"glyph glyph--project","aria-hidden":"true",children:"■"}),t]})}),l.jsx("span",{className:"tprov",children:e.createdBy==="agent"&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tprov__g","aria-hidden":"true",children:"◆"}),"proposta"]})}),l.jsx("span",{className:"trow__wt",children:e.worktreeId!==null&&l.jsx("span",{className:"glyph glyph--worktree","aria-hidden":"true",children:"◇"})}),l.jsx("span",{className:`trow__cost${s===null?" trow__cost--none":""}`,children:s===null?"—":`US$ ${s.toFixed(2)}`})]})}function Q0(e,t){return t<=0?"0%":`${(Math.min(1,Math.max(0,e/t))*100).toFixed(2)}%`}function Sh(e){if(e<1e3)return String(e);if(e<1e6){const s=e/1e3;return`${s>=100?Math.round(s):s.toFixed(1).replace(".",",")}k`}const t=e/1e6;return`${t>=10?Math.round(t):t.toFixed(1).replace(".",",").replace(",0","")}M`}function Z0(e,t){return`${t==="USD"?"US$":`${t} `} ${e.toFixed(4).replace(".",",")}`}function yA(e,t){const s=e-Math.round(t/1e3);if(s<=0)return"resetou";const n=s/3600;if(n>=24)return`reseta em ${Math.round(n/24)} d`;if(n>=6)return`reseta em ${Math.round(n)} h`;const a=new Date(e*1e3);return`reseta ${String(a.getHours()).padStart(2,"0")}:${String(a.getMinutes()).padStart(2,"0")}`}function bA(e){if(!e)return"quiet";if(e.isUsingOverage)return"over";const t=e.surpassedThreshold;return t!=null&&e.utilization>=t?"warn":"quiet"}function SA({usage:e,now:t=Date.now()}){var a;const{rateLimit:s}=e,n=bA(s);return l.jsxs(l.Fragment,{children:[n==="over"&&l.jsxs("div",{className:"overage",role:"status",children:[l.jsx("span",{"aria-hidden":"true",children:"⚠"}),l.jsxs("span",{children:["Você entrou no ",l.jsx("b",{children:"overage"})," do ciclo. A partir daqui a sessão cobra fora da assinatura."]})]}),l.jsxs("div",{className:"usage",children:[l.jsxs("span",{className:"u",children:[l.jsx("span",{className:"u__k",children:"janela"}),Sh(e.used)," / ",Sh(e.size),l.jsx(X0,{fraction:Q0(e.used,e.size)})]}),l.jsxs("span",{className:`u${e.cost?" u--cost":""}`,children:[l.jsx("span",{className:"u__k",children:"turno"}),e.cost?Z0(e.cost.amount,e.cost.currency):"—",e.currency&&e.totalCost>(((a=e.cost)==null?void 0:a.amount)??0)&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"u__k",children:"sessão"}),Z0(e.totalCost,e.currency)]})]}),l.jsx("span",{className:"usage__spacer"}),s&&l.jsxs("span",{className:`u${n==="quiet"?"":` u--${n}`}`,children:[l.jsx("span",{className:"u__k",children:"assinatura"}),Math.round(s.utilization*100),"%",l.jsx(X0,{fraction:Q0(s.utilization,1)}),s.isUsingOverage?"em overage":s.resetsAt!==null&&s.resetsAt!==void 0?yA(s.resetsAt,t):null]})]})]})}function X0({fraction:e}){return l.jsx("span",{className:"meter","data-fill":e,children:l.jsx("span",{className:"meter__f",style:{"--w":e}})})}function Ww({rows:e}){const t=Math.max(...e.map(c=>c.tokens),0),s=e.some(c=>{var h;return(((h=c.agents)==null?void 0:h.length)??0)>0}),[n,a]=j.useState(new Set);return l.jsx("div",{className:`spend${s?" spend--split":""}`,children:e.map(c=>{const h=c.agents??[],d=h.length>0,f=n.has(c.id),m=d?"div":j.Fragment,g=d?{className:"spend__group"}:{};return l.jsxs(m,{...g,children:[l.jsxs("div",{className:`spend__row${c.tokens===0?" spend__row--idle":""}${c.outside===!0?" spend__row--outside":""}`,children:[s&&l.jsx(l.Fragment,{children:d?l.jsx("button",{type:"button",className:"spend__twist","aria-expanded":f,"aria-label":`${f?"fechar":"abrir"} a divisão por agente de ${c.name}`,onClick:()=>a(v=>{const b=new Set(v);return b.delete(c.id)||b.add(c.id),b}),children:f?"▾":"▸"}):l.jsx("span",{className:"spend__twist"})}),l.jsx($e,{tone:c.tokens===0?"off":c.kind,children:c.kind==="worktree"?"◫":"▣"}),l.jsx("span",{className:"spend__name",children:c.name}),l.jsx("span",{className:"spend__bar",children:t>0&&c.tokens>0&&l.jsx("span",{className:"spend__fill",style:{"--w":`${String(Math.round(c.tokens/t*100))}%`}})}),l.jsx("span",{className:"spend__tok",children:Sh(c.tokens)}),c.cost===null?l.jsx("span",{className:"spend__cost spend__cost--none",children:"sem custo reportado"}):l.jsx("span",{className:"spend__cost",children:J0(c.cost,c.currency)}),l.jsx("span",{className:"spend__turns",children:c.turns===0?"nenhum turno":`${String(c.turns)} turnos`})]}),f&&h.map(v=>l.jsxs("div",{className:`spend__row spend__row--agent${v.name===null?" spend__row--idle":""}`,children:[l.jsx("span",{className:"spend__twist"}),l.jsx($e,{tone:v.name===null?"off":"agent",children:"◆"}),l.jsx("span",{className:"spend__name",children:v.name??"antes desta versão"}),l.jsx("span",{className:"spend__bar",children:c.tokens>0&&v.tokens>0&&l.jsx("span",{className:"spend__fill",style:{"--w":`${String(Math.round(v.tokens/c.tokens*100))}%`}})}),l.jsx("span",{className:"spend__tok",children:Sh(v.tokens)}),v.cost===null?l.jsx("span",{className:"spend__cost spend__cost--none",children:"sem custo reportado"}):l.jsx("span",{className:"spend__cost",children:J0(v.cost,v.currency)}),l.jsx("span",{className:"spend__turns",children:v.turns===0?"nenhum turno":`${String(v.turns)} turnos`})]},v.id))]},c.id)})})}function J0(e,t){const s=e.toFixed(4).replace(".",",");return t==="USD"||t===null?`US$ ${s}`:`${t} ${s}`}function xA({workspaceId:e,workspaceName:t,onRemoved:s,onWorkOnTask:n,view:a,onView:c}){const[h,d]=j.useState("7d"),[f,m]=j.useState(null),g=a==="board",v=R=>{c(R?"board":"home")},b=ye({queryKey:gn(e),queryFn:()=>te.project.listByWorkspace.query({workspaceId:e})}),S=fO(e,h),w=(ye({queryKey:jA,queryFn:()=>te.agentConfig.list.query()}).data??[]).filter(R=>R.transport==="acp").length>1,k=pO(e,h,w),N=b.data??[],L=(S.data??[]).map(R=>({id:R.projectId,name:R.name,tokens:R.tokens,cost:R.cost,currency:R.currency,turns:R.turns,kind:"project",...kA(k.data,R.projectId)}));return g?l.jsxs("div",{className:"pane wsp wsp--board",children:[l.jsxs("div",{className:"crumb",children:[l.jsx("button",{type:"button",className:"crumb__up focus-ring",onClick:()=>v(!1),children:t}),l.jsx("span",{className:"crumb__sep",children:"/"}),l.jsx("span",{className:"crumb__here",children:"Quadro de tarefas"})]}),l.jsx(oA,{workspaceId:e,onOpen:R=>{v(!1),m(R)}})]}):f!==null?l.jsx("div",{className:"pane wsp",children:l.jsx(hA,{taskId:f,workspaceId:e,onBack:()=>m(null),onWork:R=>{m(null),n==null||n(R)}})}):l.jsxs("div",{className:"pane wsp",children:[l.jsxs("div",{className:"detail__title",children:[l.jsx("h2",{children:t}),l.jsx("span",{className:"wsp__kind",children:"workspace"}),l.jsx("span",{className:"actions__spacer"}),l.jsx(wA,{id:e,name:t}),l.jsx(CA,{id:e,projects:b.isPending?"unknown":N.length,onRemoved:s})]}),l.jsx("div",{className:"chips",children:l.jsxs(kt,{children:[N.length," ",N.length===1?"projeto":"projetos"]})}),b.isError&&l.jsx("div",{className:"detail__banner",children:l.jsx(ke,{tone:"danger",children:b.error.message})}),b.isPending?l.jsx(ys,{label:"carregando os projetos",widths:["70%","50%"]}):N.length===0?l.jsx(hs,{title:"Nenhum projeto ainda",children:"Um workspace é um conjunto de projetos que se conhecem. Adicione o primeiro pela barra da esquerda — e o que você ensinar aqui já vale para todos eles."}):l.jsx(ma,{entries:[{label:"projetos",value:String(N.length)},{label:"sem diretório",value:N.filter(R=>!R.available).length===0?l.jsx("span",{className:"dim",children:"nenhum"}):`${String(N.filter(R=>!R.available).length)} de ${String(N.length)}`}]}),l.jsx(VO,{workspaceId:e,projectName:R=>{var D;return((D=N.find(Y=>Y.id===R))==null?void 0:D.name)??""}}),l.jsx(vA,{workspaceId:e,onOpen:R=>m(R),onOpenBoard:()=>v(!0)}),l.jsxs("section",{className:"section",children:[l.jsx(bn,{title:"Consumo",aside:l.jsx("div",{className:"seg",role:"group","aria-label":"Janela de tempo do consumo",children:Pw.map(R=>l.jsx("button",{type:"button",className:"seg__btn","aria-pressed":h===R.id,onClick:()=>d(R.id),children:R.label},R.id))})}),S.isError?l.jsx(ke,{tone:"danger",children:S.error.message}):S.isPending?l.jsx(ys,{label:"somando o consumo",widths:["90%","70%"]}):L.length===0?l.jsx("p",{className:"detail__hint",children:"nada gasto ainda neste workspace"}):l.jsx(Ww,{rows:L})]}),l.jsx("section",{className:"section",children:l.jsx(Hw,{workspaceId:e,projectId:null})})]})}function wA({id:e,name:t}){const[s,n]=j.useState(!1),[a,c]=j.useState(t),h=qe(),d=Te({mutationFn:f=>te.workspace.rename.mutate({id:e,name:f}),onSuccess:async()=>{await h.invalidateQueries({queryKey:mr}),n(!1)}});return s?l.jsxs("form",{className:"wsp__rename",onSubmit:f=>{f.preventDefault();const m=a.trim();if(m===""||m===t){n(!1);return}d.mutate(m)},children:[l.jsx("input",{className:"wsp__input focus-ring","aria-label":"Nome do workspace",value:a,autoFocus:!0,onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Escape"&&n(!1)}}),l.jsx(ce,{variant:"primary",size:"sm",type:"submit",disabled:d.isPending,children:"salvar"}),d.isError&&l.jsx(ke,{tone:"danger",children:d.error.message})]}):l.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{c(t),n(!0)},children:"renomear"})}function CA({id:e,projects:t,onRemoved:s}){const n=qe(),a=Te({mutationFn:()=>te.workspace.remove.mutate({id:e}),onSuccess:async()=>{await n.invalidateQueries({queryKey:mr}),s()}});return l.jsxs(l.Fragment,{children:[l.jsx(ce,{variant:"ghost",size:"sm",disabled:t==="unknown"||t>0||a.isPending,onClick:()=>a.mutate(),children:a.isPending?"removendo…":"remover workspace"}),typeof t=="number"&&t>0&&l.jsxs("span",{className:"wsp__why",children:[t," ",t===1?"projeto dentro":"projetos dentro"]}),a.isError&&l.jsx(ke,{tone:"danger",children:a.error.message})]})}const jA=["agentConfig","list"];function kA(e,t){const s=(e??[]).filter(n=>n.projectId===t).map(n=>({id:n.agentConfigId??"sem-agente",name:n.name,tokens:n.tokens,cost:n.cost,currency:n.currency,turns:n.turns}));return s.length>0?{agents:s}:{}}function Vw(e,t="worktree"){return ye({queryKey:PN(e.scopeType,e.scopeId,t),queryFn:()=>te.changes.list.query({scopeType:e.scopeType,scopeId:e.scopeId,ref:t}),refetchOnWindowFocus:!0})}function Yw(e){switch(e){case"added":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}}function Gw(e){switch(e){case"added":return"a";case"deleted":return"d";case"untracked":return"u";default:return"m"}}const NA=15e3,mp=6e4;function EA(e){var t;return e.visible?e.status&&(((t=e.status.pull)==null?void 0:t.counts.running)??0)>0?NA:mp:!1}function Qw(){const[e,t]=j.useState(()=>typeof document>"u"||!document.hidden);return j.useEffect(()=>{if(typeof document>"u")return;const s=()=>t(!document.hidden);return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),e}function TA(e,{panelOpen:t}){const s=Qw();return ye({queryKey:XN(e??"-"),queryFn:()=>te.pr.getByWorktree.query({worktreeId:e}),enabled:e!==null,refetchInterval:n=>EA({visible:s,status:n.state.data}),placeholderData:n=>n})}function OA(e){const t=Qw();return ye({queryKey:JN(e??"-"),queryFn:()=>te.pr.listByProject.query({projectId:e}),enabled:e!==null,refetchInterval:()=>t?mp:!1,placeholderData:s=>s})}function AA(e){return ye({queryKey:eE(e??"-"),queryFn:()=>te.pr.draft.query({worktreeId:e}),enabled:e!==null,staleTime:Number.POSITIVE_INFINITY})}function RA(e){const t=qe();return Te({mutationFn:async()=>{await te.pr.refresh.mutate(e)},onSettled:async()=>{await t.cancelQueries({queryKey:["pr"]}),await t.refetchQueries({queryKey:["pr"]})}})}const Zw="lumem.pr.dismissed";function DA(e){const[t,s]=j.useState(()=>MA());return{isDismissed:e!==null&&t.includes(e),dismiss:()=>{if(e===null)return;const n=[...new Set([...t,e])];s(n);try{localStorage.setItem(Zw,JSON.stringify(n))}catch{}}}}function MA(){try{const e=localStorage.getItem(Zw);if(e===null)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}catch{return[]}}const pp=new Set;function BA(e){pp.add(e);const t=()=>pp.delete(e);e.then(t,t)}async function LA(){await Promise.allSettled([...pp])}function eS(e,t,s){return`${e}:${t}:${s??"context"}`}const Xw=j.createContext(null);function qA({children:e}){const[t,s]=j.useState(null),[n,a]=j.useState({}),c=j.useCallback(f=>{a(m=>t===null?m:{...m,[t]:f})},[t]),h=j.useCallback(f=>{a(m=>{if(!(f in m))return m;const g={...m};return delete g[f],g})},[]),d=j.useMemo(()=>({activeTab:t,setActiveTab:s,fileFor:f=>n[f]??null,open:c,close:h}),[t,n,c,h]);return l.jsx(Xw.Provider,{value:d,children:e})}function N_(){const e=j.useContext(Xw);if(e===null)throw new Error("useOpenFiles precisa de um OpenFilesProvider acima");return e}function Fu(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function tS(e,t){return t===e||t.startsWith(`${e}/`)}function zA(e){var z,G,le;const t=qe(),s=N_(),[n,a]=j.useState({kind:"idle"}),c=s.activeTab,h=c===null?null:s.fileFor(c),d=h!==null&&h.view==="file"?h.path:null,f=j.useRef(null),[m,g]=j.useState(0);j.useEffect(()=>{const H=f.current;H!==null&&(f.current=null,LA().then(H))},[m]);const v=j.useCallback(H=>{if(c===null){H();return}f.current=H,s.close(c),g(O=>O+1)},[s,c]),b=j.useCallback((...H)=>{t.invalidateQueries({queryKey:["changes"]});for(const O of new Set(H))t.invalidateQueries({queryKey:p_(e.scopeType,e.scopeId,O)})},[t,e.scopeType,e.scopeId]),S=Te({mutationFn:H=>te.files.create.mutate({scopeType:e.scopeType,scopeId:e.scopeId,path:H.path,kind:H.kind}),onSuccess:H=>{b(Fu(H.path)),a({kind:"idle"})}}),x=Te({mutationFn:H=>te.files.rename.mutate({scopeType:e.scopeType,scopeId:e.scopeId,from:H.from,to:H.to}),onSuccess:(H,O)=>{if(b(Fu(O.from),Fu(H.path)),O.reopen!==null){const W=O.reopen.slice(O.from.length);s.open({path:`${H.path}${W}`,view:"file"})}a({kind:"idle"})},onError:(H,O)=>{O.reopen!==null&&s.open({path:O.reopen,view:"file"})}}),w=Te({mutationFn:H=>te.files.remove.mutate({scopeType:e.scopeType,scopeId:e.scopeId,path:H.path,recursive:H.recursive}),onSuccess:(H,O)=>{b(Fu(O.path)),a({kind:"idle"})},onError:(H,O)=>{O.reopen!==null&&s.open({path:O.reopen,view:"file"})}}),k=n.kind==="delete"?n.path:null,N=ye({queryKey:zN(e.scopeType,e.scopeId,k??""),queryFn:()=>te.files.deletePreview.query({scopeType:e.scopeType,scopeId:e.scopeId,path:k??""}),enabled:k!==null,gcTime:0}),L=S.reset,R=x.reset,D=w.reset,Y=j.useCallback(H=>{L(),R(),D(),a(H)},[L,R,D]),K=j.useCallback(()=>Y({kind:"idle"}),[Y]),Z=j.useCallback(H=>{const O=H.trim();if(O==="")return;if(n.kind==="create"){const F=n.parent;S.mutate({path:F===""?O:`${F}/${O}`,kind:n.makes});return}if(n.kind!=="rename")return;const W=n.path,ee=d!==null&&tS(W,d)?d:null,T=()=>x.mutate({from:W,to:O,reopen:ee});ee===null?T():v(T)},[S,n,v,x,d]),Q=j.useCallback(()=>{if(n.kind!=="delete")return;const H=n.path,O=d!==null&&tS(H,d)?d:null,W=()=>w.mutate({path:H,recursive:n.directory,reopen:O});O===null?W():v(W)},[n,v,w,d]);return{gesture:n,ask:Y,cancel:K,refusal:((z=S.error)==null?void 0:z.message)??((G=x.error)==null?void 0:G.message)??((le=w.error)==null?void 0:le.message)??null,busy:S.isPending||x.isPending||w.isPending,submit:Z,confirm:Q,preview:N}}function PA(e){var a,c;const t=ye({queryKey:m_(e.scopeId),queryFn:()=>te.worktree.getDetail.query({id:e.scopeId}),enabled:e.scopeType==="worktree"}),s=e.scopeType==="project"?e.scopeId:((a=t.data)==null?void 0:a.projectId)??null;return{workspaceId:((c=ye({queryKey:qN(s??"-"),queryFn:()=>te.project.get.query({id:s}),enabled:s!==null}).data)==null?void 0:c.workspaceId)??null,projectId:s}}function HA({scope:e,openPath:t,onOpenPatch:s,onRefChange:n}){var x,w;const[a,c]=j.useState("worktree"),h=Vw(e,a),d=a==="base"&&h.isError?h.error.message:null,f=j.useRef("base");j.useEffect(()=>{h.data!==void 0&&(f.current=h.data.baseBranch)},[h.data]);const m=((x=h.data)==null?void 0:x.baseBranch)??f.current,g=((w=h.data)==null?void 0:w.files)??[],v=g.reduce((k,N)=>k+N.additions,0),b=g.reduce((k,N)=>k+N.deletions,0);function S(k){c(k),n==null||n(k)}return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"seg-wrap",children:l.jsxs("div",{className:"seg",role:"group","aria-label":"o que comparar",children:[l.jsx("button",{type:"button",className:`seg__btn${a==="worktree"?" seg__btn--on":""}`,"aria-pressed":a==="worktree",onClick:()=>S("worktree"),children:"não commitado"}),l.jsxs("button",{type:"button",className:`seg__btn${a==="base"?" seg__btn--on":""}${d===null?"":" seg__btn--off"}`,"aria-pressed":a==="base",onClick:()=>S("base"),children:["vs ",m]})]})}),d!==null&&l.jsxs("p",{className:"fnote",role:"alert",children:[l.jsx("span",{className:"fnote__glyph","aria-hidden":"true",children:"⚠"}),l.jsx("span",{children:d})]}),h.isPending?l.jsx("div",{className:"rp__scroll",children:l.jsx("p",{className:"fnote",children:"carregando…"})}):g.length===0&&d===null?IA(a,m):l.jsxs(l.Fragment,{children:[l.jsxs("p",{className:"sum",children:[l.jsxs("span",{children:[g.length," ",g.length===1?"arquivo":"arquivos"]}),v>0&&l.jsxs("span",{className:"plus",children:["+",v]}),b>0&&l.jsxs("span",{className:"minus",children:["−",b]})]}),l.jsx("div",{className:"rp__scroll",children:g.map(k=>l.jsx(FA,{file:k,open:t===k.path,onOpen:()=>s(k.path,a)},k.path))})]})]})}function FA({file:e,open:t,onOpen:s}){const n=e.path.lastIndexOf("/"),a=n===-1?"":e.path.slice(0,n+1),c=e.path.slice(n+1);return l.jsxs("button",{type:"button",className:`drow${t?" drow--open":""}`,onClick:s,children:[l.jsx("span",{className:`mark mark--${Gw(e.status)}`,title:e.status,children:Yw(e.status)}),l.jsxs("span",{className:"dpath",title:e.path,children:[l.jsx("span",{className:"dpath__dir",children:a}),l.jsx("span",{className:"dpath__name",children:c})]}),e.binary?l.jsx("span",{className:"dstat",children:"binário"}):l.jsxs(l.Fragment,{children:[e.additions>0&&l.jsxs("span",{className:"dstat plus",children:["+",e.additions]}),e.deletions>0&&l.jsxs("span",{className:"dstat minus",children:["−",e.deletions]})]}),e.oldPath!==null&&l.jsxs("span",{className:"drow__was",children:["era ",e.oldPath]}),l.jsx("span",{className:"drow__gap"})]})}function IA(e,t){return l.jsxs("div",{className:"empty",children:[l.jsx("span",{className:"empty__glyph","aria-hidden":"true",children:"✓"}),l.jsx("span",{className:"empty__title",children:e==="worktree"?"nada por commitar":`idêntica a ${t}`}),l.jsx("span",{className:"empty__why",children:e==="worktree"?"a árvore de trabalho está igual ao HEAD. O que já foi commitado aparece na outra vista.":"nada nesta worktree diverge da base — nem commitado, nem por commitar."})]})}function UA(e){switch(e){case"ready":return"ready";case"blocked":return"blocked";case"pending":return"pending";case"merged":return"merged";default:return"none"}}const Iu=(e,t,s)=>`${String(e)} ${e===1?t:s}`;function Uu(e,t=2){return e.slice(0,t)}function KA(e){const t=e.reason;switch(t.kind){case"conflict":return{state:"conflito com a base",why:[{text:"não mescla sozinha em "},{text:t.base,strong:!0}]};case"checks-failed":{const s=Uu(t.names),n=t.names.length-s.length;return{state:Iu(t.names.length,"verificação falhou","verificações falharam"),why:[...s.flatMap((a,c)=>[...c>0?[{text:", "}]:[],{text:a,strong:!0}]),...n>0?[{text:` e mais ${String(n)}`}]:[]]}}case"changes-requested":{const s=Uu(t.by,1);return{state:"mudanças pedidas",why:s.length===0?[{text:"alguém pediu mudanças nesta pull request"}]:[{text:"por "},{text:s[0],strong:!0}]}}case"review-required":return{state:"falta revisão",why:[{text:"a regra da base exige aprovação"}]};case"behind":return{state:"atrás da base",why:[{text:"atualize a partir de "},{text:t.base,strong:!0}]};case"blocked-by-host":return{state:"bloqueada pelo GitHub",why:[{text:"uma regra da base impede o merge — o motivo está na pull request"}]};case"checks-running":{const s=Uu(t.names,1),n=t.running+t.queued;return{state:Iu(n,"verificação rodando","verificações rodando"),why:[...s.length>0?[{text:s[0],strong:!0}]:[],...t.queued>0?[{text:`${s.length>0?" · ":""}${String(t.queued)} na fila`}]:[]]}}case"mergeability-unknown":return{state:"verificando",why:[{text:"o GitHub ainda não disse se ela mescla"}]};case"ready":{const s=Uu(t.approvedBy,1);return{state:"pronta para merge",why:[{text:t.passed===0?"nada impede":Iu(t.passed,"verificação passou","verificações passaram")},...s.length>0?[{text:" · aprovada por "},{text:s[0],strong:!0}]:[]]}}case"draft":return{state:"rascunho",why:[{text:t.passed===0?"marque como pronta no GitHub":`${Iu(t.passed,"verificação passou","verificações passaram")} · marque como pronta no GitHub`}]};case"merged":return{state:"mesclada",why:[{text:"em "},{text:t.base,strong:!0},{text:" · esta worktree pode ser removida"}]};case"closed":return{state:"fechada sem merge",why:[{text:"ninguém mesclou esta pull request"}]}}}function $A(e){return e.published?{state:"sem pull request",why:[{text:"publicada · ninguém abriu pull request para "},{text:e.base,strong:!0}]}:{state:"branch não publicada",why:[{text:"nenhum remoto conhece "},{text:e.branch,strong:!0}]}}function pm(e,t){switch(e.kind){case"no-binary":return{state:"sem integração com o GitHub",why:[{text:"instale o "},{text:"gh",strong:!0},{text:" para ver PR e verificações aqui"}],dismissible:!0};case"no-auth":return{state:"gh não autenticado",why:[{text:"rode "},{text:"gh auth login",strong:!0},{text:" num shell desta worktree"}],dismissible:!1};case"unsupported-host":return{state:t===null?"sem integração":`sem integração com ${t}`,why:[{text:"o v1 fala só GitHub · o adaptador de host é a porta para os outros"}],dismissible:!0};case"rate-limit":return{state:"limite do GitHub atingido",why:e.retryAt===null?[{text:"o dado acima é de antes · tente de novo mais tarde"}]:[{text:"volta a consultar às "},{text:WA(e.retryAt),strong:!0},{text:" · o dado acima é de antes"}],dismissible:!1};case"not-a-repo":return{state:"sem integração",why:[{text:"este checkout não é um repositório git"}],dismissible:!0};case"offline":case"timeout":return{state:"sem conexão com o GitHub",why:[{text:"o dado acima é o último que deu para ler"}],dismissible:!1};default:return{state:"não deu para ler a pull request",why:[{text:e.message}],dismissible:!1}}}function WA(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}const VA=12e4;function Jw(e,t=Date.now()){if(e===null)return null;const s=Date.parse(e);if(Number.isNaN(s))return null;const n=Math.max(0,t-s);return{label:`há ${YA(n)}`,stale:n>VA}}function YA(e){const t=Math.floor(e/1e3);if(t<60)return`${String(t)} s`;const s=Math.floor(t/60);if(s<60)return`${String(s)} min`;const n=Math.floor(s/60);return n<24?`${String(n)} h`:`${String(Math.floor(n/24))} d`}function GA(e){if(e===null)return"—";const t=Math.round(e/1e3);if(t<60)return`${String(t)}s`;const s=Math.floor(t/60),n=t%60;return`${String(s)}m${String(n).padStart(2,"0")}s`}const QA=[{group:"failed",title:"precisa de você"},{group:"running",title:"em andamento"},{group:"passed",title:"passaram"},{group:"skipped",title:"ignoradas"}],ZA={failed:{char:"✕",word:"falhou",suffix:"bad"},running:{char:"●",word:"rodando",suffix:"run"},passed:{char:"✓",word:"passou",suffix:"ok"},skipped:{char:"–",word:"pulada",suffix:"skip"}};function XA({pull:e,readAt:t,now:s}){const n=Jw(t,s);return e.checks.length===0?l.jsx("div",{className:"checks",children:l.jsx(hs,{title:"Nenhuma verificação",children:"Esta pull request não tem verificação configurada, ou o host ainda não relatou nenhuma."})}):l.jsxs("div",{className:"checks",children:[QA.map(({group:a,title:c})=>{const h=e.checks.filter(d=>d.group===a);return h.length===0?null:l.jsxs("div",{children:[l.jsx("div",{className:"checks__group",children:c}),h.map(d=>l.jsx(JA,{check:d},`${a}:${d.name}`))]},a)}),l.jsxs("div",{className:"checks__foot",children:[n===null?"lido do gh":`lido do gh ${n.label}`," · reexecutar se faz no navegador"]})]})}function JA({check:e}){const t=ZA[e.group],s=l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"checks__glyph","aria-hidden":"true",children:t.char}),l.jsx("span",{className:"sr-only",children:t.word}),l.jsxs("span",{className:"checks__body",children:[l.jsx("span",{className:"checks__name",children:e.name}),e.app!==""&&l.jsx("span",{className:"checks__app",children:e.app})]}),l.jsx("span",{className:"checks__time",children:GA(e.durationMs)})]});return e.url===null?l.jsxs("div",{className:"checks__row",title:"o endereço desta execução não é do host do projeto",children:[s,l.jsx("span",{className:"checks__go","aria-hidden":"true"})]}):l.jsxs("a",{className:`checks__row checks__row--${t.suffix} focus-ring`,href:e.url,target:"_blank",rel:"noopener noreferrer",children:[s,l.jsx("span",{className:"checks__go","aria-hidden":"true",children:"↗"}),l.jsxs("span",{className:"sr-only",children:["abrir a execução de ",e.name]})]})}function eR(e){const{failed:t,running:s,passed:n}=e.counts;return t>0?{text:`✕${String(t)}`,tone:"bad"}:s>0?{text:`●${String(s)}`,tone:"run"}:{text:`✓${String(n)}`,tone:"ok"}}function E_(){const[e,t]=j.useState(!1),s=j.useRef(null),n=j.useRef(null),a=j.useCallback(()=>{t(h=>{var d;return h&&((d=s.current)==null||d.focus()),!1})},[]),c=j.useCallback(()=>t(h=>!h),[]);return j.useEffect(()=>{if(!e)return;const h=f=>{f.key==="Escape"&&a()},d=f=>{var g,v;const m=f.target;((g=n.current)==null?void 0:g.contains(m))!==!0&&((v=s.current)==null?void 0:v.contains(m))!==!0&&t(!1)};return document.addEventListener("keydown",h),document.addEventListener("pointerdown",d),()=>{document.removeEventListener("keydown",h),document.removeEventListener("pointerdown",d)}},[e,a]),{open:e,toggle:c,close:a,triggerRef:s,panelRef:n}}function tR({scope:e,openPath:t,onOpen:s,statusOf:n,edits:a}){const[c,h]=j.useState(new Set),d=j.useCallback(m=>{h(g=>{const v=new Set(g);return v.delete(m)||v.add(m),v})},[]),f=j.useCallback(m=>{h(g=>g.has(m)?g:new Set(g).add(m))},[]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"rp__scroll",role:"tree","aria-label":"arquivos",children:l.jsx(e1,{scope:e,path:"",depth:0,expanded:c,onToggle:d,onExpand:f,edits:a,openPath:t,onOpen:s,statusOf:n})}),l.jsx(rR,{edits:a})]})}function e1({scope:e,path:t,depth:s,expanded:n,onToggle:a,onExpand:c,edits:h,openPath:d,onOpen:f,statusOf:m}){const[g,v]=j.useState(void 0),b=ye({queryKey:[...p_(e.scopeType,e.scopeId,t),g??"default"],queryFn:()=>te.files.listDir.query({scopeType:e.scopeType,scopeId:e.scopeId,path:t,...g===void 0?{}:{limit:g}}),refetchOnWindowFocus:!0}),S=h.gesture,x=S.kind==="create"&&S.parent===t?l.jsx(sS,{depth:s,label:S.makes==="dir"?"nova pasta":"novo arquivo",initial:"",hint:l.jsxs(l.Fragment,{children:["enter cria em ",l.jsx("code",{children:t===""?"./":`${t}/`})," · esc cancela"]}),edits:h},`${t}:${S.makes}`):null;if(b.isPending)return l.jsxs(l.Fragment,{children:[x,l.jsx("p",{className:"fnote",style:{"--depth":s},children:"carregando…"})]});if(b.isError)return l.jsxs(l.Fragment,{children:[x,l.jsxs("p",{className:"fnote",style:{"--depth":s},role:"alert",children:[l.jsx("span",{className:"fnote__glyph","aria-hidden":"true",children:"⚠"}),l.jsx("span",{children:b.error.message})]})]});const{entries:w,total:k,truncated:N}=b.data;return w.length===0?l.jsxs(l.Fragment,{children:[x,l.jsx("p",{className:"fnote",style:{"--depth":s},children:"vazio"})]}):l.jsxs(l.Fragment,{children:[x,w.map(L=>{const R=t===""?L.name:`${t}/${L.name}`,D=L.kind==="dir",Y=n.has(R),K=m(R);return S.kind==="rename"&&S.path===R?l.jsx(sS,{depth:s,label:"renomear",initial:R,hint:l.jsx(l.Fragment,{children:"com barra, move · esc cancela"}),edits:h},R):l.jsxs("div",{role:"group",children:[l.jsxs("div",{className:"frow-wrap",children:[l.jsxs("button",{type:"button",className:["frow",D?"frow--dir":"",K==="deleted"?"frow--dim":"",d===R?"frow--open":""].filter(Boolean).join(" "),"aria-expanded":D?Y:void 0,onClick:()=>D?a(R):f(R),children:[l.jsx("span",{className:"frow__twist",style:{"--depth":s},"aria-hidden":"true",children:D?Y?"▾":"▸":""}),l.jsx("span",{className:"frow__name",children:L.name}),K!==void 0&&l.jsx("span",{className:`mark mark--${Gw(K)}`,title:K,children:Yw(K)}),l.jsx("span",{className:"frow__gap"}),L.size!==null&&L.size>0&&l.jsx("span",{className:"frow__size",children:Mo(L.size)})]}),l.jsx(iR,{path:R,isDir:D,edits:h,onExpand:c})]}),D&&Y&&l.jsx(e1,{scope:e,path:R,depth:s+1,expanded:n,onToggle:a,onExpand:c,edits:h,openPath:d,onOpen:f,statusOf:m})]},R)}),N&&l.jsxs("p",{className:"fnote",style:{"--depth":s},children:[l.jsx("span",{className:"fnote__glyph","aria-hidden":"true",children:"⚠"}),l.jsxs("span",{children:[w.length," de ",k," entradas."," ",l.jsx("button",{type:"button",onClick:()=>v(k),children:"listar assim mesmo"})]})]})]})}function sR({edits:e}){const t=E_(),s=n=>()=>{t.close(),e.ask({kind:"create",parent:"",makes:n})};return l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",ref:t.triggerRef,className:"rp__icon","aria-haspopup":"menu","aria-expanded":t.open,"aria-label":"criar na raiz",title:"criar na raiz do checkout",onClick:t.toggle,children:"+"}),t.open&&l.jsx("div",{className:"rp__menu",ref:t.panelRef,children:l.jsxs(b_,{label:"criar na raiz",children:[l.jsx(dn,{glyph:l.jsx($e,{children:"+"}),onSelect:s("file"),children:"novo arquivo"}),l.jsx(dn,{glyph:l.jsx($e,{children:"▤"}),onSelect:s("dir"),children:"nova pasta"})]})})]})}function iR({path:e,isDir:t,edits:s,onExpand:n}){const a=E_(),c=h=>()=>{a.close(),n(e),s.ask({kind:"create",parent:e,makes:h})};return l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",ref:a.triggerRef,className:"fact","aria-haspopup":"menu","aria-expanded":a.open,"aria-label":`ações de ${e}`,onClick:a.toggle,children:"⋯"}),a.open&&l.jsx("div",{className:"frow-menu",ref:a.panelRef,children:l.jsxs(b_,{label:`ações de ${e}`,children:[t&&l.jsxs(l.Fragment,{children:[l.jsx(dn,{glyph:l.jsx($e,{children:"+"}),onSelect:c("file"),children:"novo arquivo"}),l.jsx(dn,{glyph:l.jsx($e,{children:"▤"}),onSelect:c("dir"),children:"nova pasta"}),l.jsx("div",{className:"frow-menu__sep",role:"separator"})]}),l.jsx(dn,{glyph:l.jsx($e,{children:"✎"}),onSelect:()=>{a.close(),s.ask({kind:"rename",path:e})},children:"renomear"}),l.jsx(dn,{glyph:l.jsx($e,{tone:"warn",children:"✕"}),onSelect:()=>{a.close(),s.ask({kind:"delete",path:e,directory:t})},children:"apagar"})]})})]})}function sS({depth:e,label:t,initial:s,hint:n,edits:a}){const[c,h]=j.useState(s),d=a.refusal!==null;return l.jsxs(l.Fragment,{children:[l.jsxs("form",{className:"fedit",onSubmit:f=>{f.preventDefault(),a.submit(c)},children:[l.jsx("span",{className:"frow__twist",style:{"--depth":e},"aria-hidden":"true"}),l.jsx("input",{className:`finput${d?" finput--error":""}`,"aria-label":t,"aria-invalid":d,value:c,autoFocus:!0,disabled:a.busy,onChange:f=>h(f.target.value),onKeyDown:f=>{f.key==="Escape"&&a.cancel()}})]}),l.jsx("p",{className:`fhint${d?" fhint--error":""}`,style:{"--depth":e},role:d?"alert":void 0,children:a.refusal??n})]})}function rR({edits:e}){const{gesture:t,cancel:s}=e;if(j.useEffect(()=>{if(t.kind!=="delete")return;const f=m=>{m.key==="Escape"&&s()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[t.kind,s]),t.kind!=="delete")return null;const n=e.preview,a=n.data??null,c=a!==null&&a.kind==="dir"?a.files+a.dirs:null,h=a!==null&&a.kind==="dir"&&a.truncated,d=a===null?t.directory:a.kind==="dir";return l.jsx("div",{className:"fdim",role:"dialog","aria-modal":"true","aria-label":`apagar ${t.path}`,children:l.jsxs(Sw,{title:d?"apagar esta pasta e o que tem dentro?":"apagar este arquivo?",children:[l.jsx("code",{className:"fdim__target",children:t.path}),n.isPending&&l.jsx("p",{className:"fdim__note",children:"consultando o git…"}),n.isError&&l.jsxs(ke,{tone:"danger",children:["não deu para consultar o git: ",n.error.message,". Nada foi verificado sobre o que volta."]}),a!==null&&a.kind==="file"&&l.jsx(nR,{path:t.path,tracked:a.tracked}),a!==null&&a.kind==="dir"&&l.jsxs(l.Fragment,{children:[l.jsxs("p",{className:"fdim__note",children:[h?"pelo menos ":"",Jr(a.files)," ",a.files===1?"arquivo":"arquivos"," e"," ",Jr(a.dirs)," ",a.dirs===1?"pasta":"pastas",", contando os subdiretórios.",h?" A contagem parou no teto do daemon.":""]}),l.jsx(aR,{path:t.path,files:a.files,untracked:a.untracked,truncated:a.truncated})]}),l.jsxs("div",{className:"fdim__actions",children:[l.jsx(ce,{variant:"ghost",onClick:s,children:"cancelar"}),l.jsx(ce,{variant:"danger",disabled:e.busy,onClick:e.confirm,children:c===null?"apagar":`apagar ${h?"pelo menos ":"as "}${Jr(c)} ${c===1?"entrada":"entradas"}`})]}),e.refusal!==null&&l.jsx(ke,{tone:"danger",children:e.refusal})]})})}function nR({path:e,tracked:t}){return t?l.jsxs(ke,{tone:"info",children:["o git tem uma cópia: ",l.jsxs("code",{children:["git checkout -- ",e]})," traz de volta o que está no índice."]}):l.jsxs(ke,{tone:"danger",children:[l.jsx("strong",{children:"o git não confirmou ter uma cópia disto."})," Pode não haver nada que traga de volta — nem o histórico, nem esta janela."]})}function aR({path:e,files:t,untracked:s,truncated:n}){if(n)return l.jsxs(ke,{tone:"danger",children:[l.jsx("strong",{children:s>0?`de pelo menos ${Jr(t)}, ${Jr(s)} o git não confirmou ter.`:"o git não foi consultado sobre tudo que está aqui dentro."})," ","O que a caminhada não alcançou também não foi verificado, e nada aqui promete que volte."]});if(s===0)return l.jsxs(ke,{tone:"info",children:["o git tem cópia do que está aqui dentro: ",l.jsxs("code",{children:["git checkout -- ",e]})," traz de volta o que está no índice."]});const a=t-s;return l.jsxs(ke,{tone:"danger",children:[l.jsxs("strong",{children:["de ",Jr(t),", ",Jr(s)," o git não confirmou ter."]})," ",a>0?`Nada garante que voltem; ${Jr(a)} o git desfaz.`:"Nada garante que voltem."]})}function Jr(e){return e.toLocaleString("pt-BR")}function Mo(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1).replace(".",",")} MB`}const iS={squash:"squash",merge:"merge commit",rebase:"rebase"};function lR(e){const t=j.useRef(null);return j.useEffect(()=>{var s;return(s=t.current)==null?void 0:s.focus()},[]),l.jsx("div",{className:"prgate",role:"dialog","aria-modal":"true","aria-label":e.verb==="merge"?"mesclar a pull request":"abrir uma pull request",onKeyDown:s=>{s.key==="Escape"&&(s.stopPropagation(),e.onClose())},children:e.verb==="merge"?l.jsx(oR,{...e,cancelRef:t}):l.jsx(cR,{...e,cancelRef:t})})}function t1(e){const t=qe();return()=>(t.invalidateQueries({queryKey:["pr"]}),t.invalidateQueries({queryKey:["worktree"]}),t.invalidateQueries({queryKey:["changes"]}),e)}function oR({status:e,worktreeId:t,onClose:s,cancelRef:n}){const a=t1(t),c=uR(e),[h,d]=j.useState(c[0]??"merge"),[f,m]=j.useState(e.merge.deleteBranchOnMerge),g=Te({mutationFn:()=>te.pr.merge.mutate({worktreeId:t,strategy:h,deleteBranch:f}),onSuccess:()=>{a(),s()}}),v=e.pull;return v===null?null:l.jsxs("form",{className:"prform",onSubmit:b=>{b.preventDefault(),g.mutate()},children:[l.jsxs("div",{className:"prgate__t",children:[l.jsx("span",{className:"prgate__g","aria-hidden":"true",children:"⚠"}),"Mesclar a #",v.number,"?"]}),l.jsxs("div",{className:"prform__what",children:[l.jsxs("span",{children:[l.jsx("b",{children:v.head})," entra em ",l.jsx("b",{children:v.base}),", por ",l.jsx("b",{children:iS[h]}),"."]}),l.jsx("span",{children:f?"A branch remota é apagada. A worktree local fica onde está.":"A branch remota fica. A worktree local também."})]}),l.jsxs("div",{className:"prform__field",children:[l.jsx("span",{className:"prform__label",children:"estratégia"}),l.jsx("div",{className:"prform__strategies",role:"radiogroup","aria-label":"estratégia de merge",children:c.map(b=>l.jsx(ce,{size:"sm",variant:b===h?"primary":"default",role:"radio","aria-checked":b===h,onClick:()=>d(b),children:iS[b]},b))})]}),l.jsx("label",{className:"prform__field",children:l.jsxs("span",{children:[l.jsx("input",{type:"checkbox",checked:f,onChange:b=>m(b.target.checked)})," ","apagar a branch remota depois"]})}),g.isError&&l.jsx("p",{className:"prform__error",role:"alert",children:g.error.message}),l.jsxs("div",{className:"prform__acts",children:[l.jsx(ce,{size:"sm",variant:"ghost",ref:n,onClick:s,children:"cancelar"}),l.jsx(ce,{size:"sm",variant:"danger",type:"submit",disabled:g.isPending,children:g.isPending?"mesclando…":"mesclar"})]})]})}function cR({status:e,worktreeId:t,onClose:s,cancelRef:n}){var k;const a=t1(t),c=AA(t),[h,d]=j.useState(null),f=h??((k=c.data)==null?void 0:k.title)??"",m=d,[g,v]=j.useState(""),[b,S]=j.useState(!1),x=Te({mutationFn:()=>te.pr.create.mutate({worktreeId:t,title:f.trim(),body:g,draft:b}),onSuccess:()=>{a(),s()}}),w=`pr-title-${t}`;return l.jsxs("form",{className:"prform",onSubmit:N=>{N.preventDefault(),f.trim()!==""&&x.mutate()},children:[l.jsx("div",{className:"prgate__t",children:"Abrir pull request"}),l.jsx("div",{className:"prform__what",children:l.jsxs("span",{children:[l.jsx("b",{children:e.branch})," para ",l.jsx("b",{children:e.base}),", em ",l.jsx("b",{children:e.host??"GitHub"}),"."]})}),l.jsx($t,{id:w,label:"Título",error:x.isError?x.error.message:void 0,children:l.jsx(ts,{id:w,value:f,onChange:N=>m(N.target.value),placeholder:"feat: o que esta branch faz",invalid:x.isError,autoFocus:!0})}),l.jsxs("div",{className:"prform__field",children:[l.jsx("label",{className:"prform__label",htmlFor:`${w}-body`,children:"descrição"}),l.jsx("textarea",{id:`${w}-body`,className:"prform__body",rows:5,value:g,onChange:N=>v(N.target.value)})]}),l.jsx("label",{className:"prform__field",children:l.jsxs("span",{children:[l.jsx("input",{type:"checkbox",checked:b,onChange:N=>S(N.target.checked)})," ","abrir como rascunho"]})}),l.jsxs("div",{className:"prform__acts",children:[l.jsx(ce,{size:"sm",variant:"ghost",ref:n,onClick:s,children:"cancelar"}),l.jsx(ce,{size:"sm",variant:"primary",type:"submit",disabled:x.isPending||f.trim()==="",children:x.isPending?"abrindo…":"abrir"}),e.compareUrl!==null&&l.jsxs("a",{className:"btn btn--ghost btn--sm focus-ring",href:e.compareUrl,target:"_blank",rel:"noopener noreferrer",children:["abrir no GitHub ",l.jsx("span",{"aria-hidden":"true",children:"↗"})]})]})]})}function uR(e){return["squash","merge","rebase"].filter(t=>e.merge[t])}function hR({words:e}){return l.jsx("span",{className:"prbar__why",children:e.map((t,s)=>t.strong===!0?l.jsx("b",{children:t.text},s):l.jsx("span",{children:t.text},s))})}function dR({status:e,worktreeId:t,now:s,onRetry:n,onDismiss:a}){const[c,h]=j.useState(null),d=e.pull,f=e.failure,m=d===null?"none":UA(d.verdict),g=d!==null?KA(d):f!==null?pm(f,e.host):$A(e),v=d!==null&&f!==null?pm(f,e.host):null,b=Jw(e.readAt,s),S=d===null&&f!==null&&pm(f,e.host).dismissible,x=d!==null&&d.verdict==="ready"&&(e.merge.merge||e.merge.squash||e.merge.rebase),w=d===null&&e.published&&f===null&&e.host!==null;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:`prbar prbar--${m}`,role:"status","aria-label":"estado da pull request",children:[l.jsxs("div",{className:"prbar__top",children:[d!==null&&l.jsx(fR,{pull:d}),l.jsxs("span",{className:"prbar__state",children:[l.jsx("span",{className:"prbar__dot","aria-hidden":"true"}),l.jsx("span",{className:"prbar__word",children:g.state})]})]}),l.jsxs("div",{className:"prbar__reason",children:[l.jsx(hR,{words:v===null?g.why:[...g.why,{text:" · "},...v.why]}),b!==null&&l.jsx("span",{className:`prbar__fresh${b.stale?" prbar__fresh--stale":""}`,children:b.label})]}),(x||w||e.compareUrl!==null||f!==null)&&l.jsxs("div",{className:"prbar__acts",children:[x&&l.jsx(ce,{size:"sm",variant:"primary",onClick:()=>h("merge"),children:"mesclar"}),w&&l.jsx(ce,{size:"sm",onClick:()=>h("create"),children:"abrir pull request"}),d===null&&e.compareUrl!==null&&l.jsxs("a",{className:"btn btn--sm focus-ring",href:e.compareUrl,target:"_blank",rel:"noopener noreferrer",children:["comparar no GitHub ",l.jsx("span",{"aria-hidden":"true",children:"↗"})]}),f!==null&&l.jsx(ce,{size:"sm",variant:"ghost",onClick:n,children:"tentar de novo"}),S&&l.jsx(ce,{size:"sm",variant:"ghost",onClick:a,children:"não mostrar mais"})]})]}),c!==null&&l.jsx(lR,{verb:c,status:e,worktreeId:t,onClose:()=>h(null)})]})}function fR({pull:e}){const t=`abrir a pull request ${String(e.number)} no navegador`;return l.jsxs(l.Fragment,{children:[e.url===null?l.jsx("span",{className:"prbar__pr",title:"o endereço desta pull request não é do host do projeto",children:l.jsxs("span",{className:"prbar__num",children:["#",e.number]})}):l.jsxs("a",{className:"prbar__pr focus-ring",href:e.url,target:"_blank",rel:"noopener noreferrer",children:[l.jsxs("span",{className:"prbar__num",children:["#",e.number]}),l.jsx("span",{className:"prbar__go","aria-hidden":"true",children:"↗"}),l.jsx("span",{className:"sr-only",children:t})]}),e.alsoOpen>0&&l.jsxs("span",{className:"prbar__more",title:"esta branch tem mais de uma pull request aberta",children:["+",e.alsoOpen]})]})}const s1="lumem.rightPanel",mR=360,pR=260,_R=720;function gR(){const e={open:!1,width:mR};try{const t=window.localStorage.getItem(s1);if(t===null)return e;const s=JSON.parse(t);if(typeof s!="object"||s===null)return e;const{open:n,width:a}=s;return{open:typeof n=="boolean"?n:e.open,width:typeof a=="number"?T_(a):e.width}}catch{return e}}function rS(e){try{window.localStorage.setItem(s1,JSON.stringify(e))}catch{}}function T_(e){return Math.min(_R,Math.max(pR,Math.round(e)))}function vR(){const[e,t]=j.useState(gR),s=j.useCallback(()=>{t(a=>{const c={...a,open:!a.open};return rS(c),c})},[]),n=j.useCallback(a=>{t(c=>{const h={...c,width:T_(a)};return rS(h),h})},[]);return{open:e.open,width:e.width,toggle:s,setWidth:n}}function yR({proposalCount:e=null,prBar:t,prBadge:s=null,tab:n,onSelectTab:a,changeCount:c,actions:h,onReload:d,onClose:f,onResize:m,dock:g,footLeft:v,footRight:b,children:S}){const x=j.useRef(!1),w=j.useRef(null),[k,N]=j.useState(!1),L=j.useCallback(R=>{var Y;const D=(Y=w.current)==null?void 0:Y.getBoundingClientRect().right;D===void 0||!Number.isFinite(R)||m(T_(D-R))},[m]);return j.useEffect(()=>{if(!k)return;const R=Y=>{x.current&&(Y.preventDefault(),L(Y.clientX))},D=()=>{x.current=!1,N(!1)};return window.addEventListener("pointermove",R),window.addEventListener("pointerup",D),()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",D)}},[k,L]),l.jsxs("aside",{className:"rp","aria-label":"arquivos do checkout",ref:w,children:[l.jsx("span",{className:"rp__grip",role:"separator","aria-orientation":"vertical","aria-label":"largura da coluna",onPointerDown:R=>{R.preventDefault(),x.current=!0,N(!0)}}),t,l.jsxs("div",{className:"rp__bar",role:"tablist","aria-label":"conteúdo da coluna",children:[l.jsx("button",{type:"button",role:"tab","aria-selected":n==="files",className:`rtab${n==="files"?" rtab--active":""}`,onClick:()=>a("files"),children:"Arquivos"}),l.jsxs("button",{type:"button",role:"tab","aria-selected":n==="changes",className:`rtab${n==="changes"?" rtab--active":""}`,onClick:()=>a("changes"),children:["Mudanças",c!==null&&c>0&&l.jsx("span",{className:"rtab__count",children:c})]}),l.jsxs("button",{type:"button",role:"tab","aria-selected":n==="memory",className:`rtab${n==="memory"?" rtab--active":""}`,onClick:()=>a("memory"),children:["Memória",e!==null&&e>0&&l.jsx("span",{className:"rtab__count",children:e})]}),s!==null&&l.jsxs("button",{type:"button",role:"tab","aria-selected":n==="pr",className:`rtab${n==="pr"?" rtab--active":""}`,onClick:()=>a("pr"),children:["PR",l.jsx("span",{className:`rtab__count rtab__count--${s.tone}`,children:s.text})]}),l.jsx("span",{className:"rp__spacer"}),h,l.jsxs("button",{type:"button",className:"rp__icon",onClick:d,title:"recarregar",children:["⟳",l.jsx("span",{className:"sr-only",children:"recarregar"})]}),l.jsxs("button",{type:"button",className:"rp__icon",onClick:f,title:"fechar a coluna",children:["›",l.jsx("span",{className:"sr-only",children:"fechar a coluna"})]})]}),l.jsxs("div",{className:"rp__body",children:[S,l.jsxs("div",{className:"rp__foot",children:[l.jsx("span",{children:v}),l.jsx("span",{className:"rp__spacer"}),l.jsx("span",{children:b})]}),g]})]})}const bR=2e3;function i1(e){return ye({queryKey:ew(e.scopeType,e.scopeId),queryFn:()=>te.scripts.status.query(e),refetchInterval:t=>{const s=t.state.data;return s&&[s.setup,s.run,s.test,s.teardown].some(a=>{var c;return(c=a.last)==null?void 0:c.running})?bR:!1}})}function SR(e){const t=qe(),s=()=>{t.invalidateQueries({queryKey:ew(e.scopeType,e.scopeId)}),t.invalidateQueries({queryKey:["session"]})},n=Te({mutationFn:h=>te.scripts.start.mutate({...e,phase:h}),onSettled:s}),a=Te({mutationFn:h=>te.scripts.stop.mutate({...e,phase:h}),onSettled:s}),c=Te({mutationFn:()=>te.scripts.trust.mutate(e),onSettled:s});return{start:n,stop:a,trust:c}}const xR=3e3;function r1(e){return{queryKey:Hi(e.scopeType,e.scopeId),queryFn:()=>te.session.listByScope.query(e),refetchInterval:xR}}function O_(e){return ye(r1(e))}function A_(e){return Xx({queries:e.map(r1),combine:t=>t.reduce((s,n)=>s+(n.data??[]).filter(a=>a.state==="running").length,0)})}function xh(e,t=Date.now()){const s=Date.parse(e);if(Number.isNaN(s))return"";const n=Math.max(0,Math.round((t-s)/1e3));if(n<60)return"agora";const a=Math.floor(n/60);if(a<60)return`${a} min`;const c=Math.floor(a/60);return c<24?`${c} h`:`${Math.floor(c/24)} d`}/**
51
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
52
+ * @license MIT
53
+ *
54
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
55
+ * @license MIT
56
+ *
57
+ * Originally forked from (with the author's permission):
58
+ * Fabrice Bellard's javascript vt100 for jslinux:
59
+ * http://bellard.org/jslinux/
60
+ * Copyright (c) 2011 Fabrice Bellard
61
+ */var wR=2,CR=1,jR=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var v;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((v=this._terminal.options.overviewRuler)==null?void 0:v.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(s.getPropertyValue("height")),a=Math.max(0,parseInt(s.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),h={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},d=h.top+h.bottom,f=h.right+h.left,m=n-d,g=a-f-t;return{cols:Math.max(wR,Math.floor(g/e.css.cell.width)),rows:Math.max(CR,Math.floor(m/e.css.cell.height))}}};/**
62
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
63
+ * @license MIT
64
+ *
65
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
66
+ * @license MIT
67
+ *
68
+ * Originally forked from (with the author's permission):
69
+ * Fabrice Bellard's javascript vt100 for jslinux:
70
+ * http://bellard.org/jslinux/
71
+ * Copyright (c) 2011 Fabrice Bellard
72
+ */var n1=Object.defineProperty,kR=Object.getOwnPropertyDescriptor,NR=(e,t)=>{for(var s in t)n1(e,s,{get:t[s],enumerable:!0})},Nt=(e,t,s,n)=>{for(var a=n>1?void 0:n?kR(t,s):t,c=e.length-1,h;c>=0;c--)(h=e[c])&&(a=(n?h(t,s,a):h(a))||a);return n&&a&&n1(t,s,a),a},pe=(e,t)=>(s,n)=>t(s,n,e),nS="Terminal input",_p={get:()=>nS,set:e=>nS=e},aS="Too much output to announce, navigate to rows manually to read",gp={get:()=>aS,set:e=>aS=e};function ER(e){return e.replace(/\r?\n/g,"\r")}function TR(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function OR(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function AR(e,t,s,n){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");a1(a,t,s,n)}}function a1(e,t,s,n){e=ER(e),e=TR(e,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function l1(e,t,s){let n=s.getBoundingClientRect(),a=e.clientX-n.left-10,c=e.clientY-n.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function lS(e,t,s,n,a){l1(e,t,s),a&&n.rightClickSelect(e),t.value=n.selectionText,t.select()}function Xr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Rh(e,t=0,s=e.length){let n="";for(let a=t;a<s;++a){let c=e[a];c>65535?(c-=65536,n+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):n+=String.fromCharCode(c)}return n}var RR=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let n=0,a=0;if(this._interim){let c=e.charCodeAt(a++);56320<=c&&c<=57343?t[n++]=(this._interim-55296)*1024+c-56320+65536:(t[n++]=this._interim,t[n++]=c),this._interim=0}for(let c=a;c<s;++c){let h=e.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=s)return this._interim=h,n;let d=e.charCodeAt(c);56320<=d&&d<=57343?t[n++]=(h-55296)*1024+d-56320+65536:(t[n++]=h,t[n++]=d);continue}h!==65279&&(t[n++]=h)}return n}},DR=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let n=0,a,c,h,d,f=0,m=0;if(this.interim[0]){let b=!1,S=this.interim[0];S&=(S&224)===192?31:(S&240)===224?15:7;let x=0,w;for(;(w=this.interim[++x]&63)&&x<4;)S<<=6,S|=w;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,N=k-x;for(;m<N;){if(m>=s)return 0;if(w=e[m++],(w&192)!==128){m--,b=!0;break}else this.interim[x++]=w,S<<=6,S|=w&63}b||(k===2?S<128?m--:t[n++]=S:k===3?S<2048||S>=55296&&S<=57343||S===65279||(t[n++]=S):S<65536||S>1114111||(t[n++]=S)),this.interim.fill(0)}let g=s-4,v=m;for(;v<s;){for(;v<g&&!((a=e[v])&128)&&!((c=e[v+1])&128)&&!((h=e[v+2])&128)&&!((d=e[v+3])&128);)t[n++]=a,t[n++]=c,t[n++]=h,t[n++]=d,v+=4;if(a=e[v++],a<128)t[n++]=a;else if((a&224)===192){if(v>=s)return this.interim[0]=a,n;if(c=e[v++],(c&192)!==128){v--;continue}if(f=(a&31)<<6|c&63,f<128){v--;continue}t[n++]=f}else if((a&240)===224){if(v>=s)return this.interim[0]=a,n;if(c=e[v++],(c&192)!==128){v--;continue}if(v>=s)return this.interim[0]=a,this.interim[1]=c,n;if(h=e[v++],(h&192)!==128){v--;continue}if(f=(a&15)<<12|(c&63)<<6|h&63,f<2048||f>=55296&&f<=57343||f===65279)continue;t[n++]=f}else if((a&248)===240){if(v>=s)return this.interim[0]=a,n;if(c=e[v++],(c&192)!==128){v--;continue}if(v>=s)return this.interim[0]=a,this.interim[1]=c,n;if(h=e[v++],(h&192)!==128){v--;continue}if(v>=s)return this.interim[0]=a,this.interim[1]=c,this.interim[2]=h,n;if(d=e[v++],(d&192)!==128){v--;continue}if(f=(a&7)<<18|(c&63)<<12|(h&63)<<6|d&63,f<65536||f>1114111)continue;t[n++]=f}}return n}},o1="",mn=" ",dc=class c1{constructor(){this.fg=0,this.bg=0,this.extended=new wh}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new c1;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},wh=class u1{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new u1(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},di=class h1 extends dc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new wh,this.combinedData=""}static fromCharData(t){let s=new h1;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Xr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let n=t[1].charCodeAt(0);if(55296<=n&&n<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(n-55296)*1024+a-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},oS="di$target",vp="di$dependencies",_m=new Map;function MR(e){return e[vp]||[]}function ss(e){if(_m.has(e))return _m.get(e);let t=function(s,n,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");BR(t,s,a)};return t._id=e,_m.set(e,t),t}function BR(e,t,s){t[oS]===t?t[vp].push({id:e,index:s}):(t[vp]=[{id:e,index:s}],t[oS]=t)}var bs=ss("BufferService"),d1=ss("CoreMouseService"),pa=ss("CoreService"),LR=ss("CharsetService"),R_=ss("InstantiationService"),f1=ss("LogService"),Ss=ss("OptionsService"),m1=ss("OscLinkService"),qR=ss("UnicodeService"),fc=ss("DecorationService"),yp=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var g;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let n=[],a=this._optionsService.rawOptions.linkHandler,c=new di,h=s.getTrimmedLength(),d=-1,f=-1,m=!1;for(let v=0;v<h;v++)if(!(f===-1&&!s.hasContent(v))){if(s.loadCell(v,c),c.hasExtendedAttrs()&&c.extended.urlId)if(f===-1){f=v,d=c.extended.urlId;continue}else m=c.extended.urlId!==d;else f!==-1&&(m=!0);if(m||f!==-1&&v===h-1){let b=(g=this._oscLinkService.getLinkData(d))==null?void 0:g.uri;if(b){let S={start:{x:f+1,y:e},end:{x:v+(!m&&v===h-1?1:0),y:e}},x=!1;if(!(a!=null&&a.allowNonHttpProtocols))try{let w=new URL(b);["http:","https:"].includes(w.protocol)||(x=!0)}catch{x=!0}x||n.push({text:b,range:S,activate:(w,k)=>a?a.activate(w,k,S):zR(w,k),hover:(w,k)=>{var N;return(N=a==null?void 0:a.hover)==null?void 0:N.call(a,w,k,S)},leave:(w,k)=>{var N;return(N=a==null?void 0:a.leave)==null?void 0:N.call(a,w,k,S)}})}m=!1,c.hasExtendedAttrs()&&c.extended.urlId?(f=v,d=c.extended.urlId):(f=-1,d=-1)}}t(n)}};yp=Nt([pe(0,bs),pe(1,Ss),pe(2,m1)],yp);function zR(e,t){if(confirm(`Do you want to navigate to ${t}?
73
+
74
+ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Dh=ss("CharSizeService"),yr=ss("CoreBrowserService"),D_=ss("MouseService"),br=ss("RenderService"),PR=ss("SelectionService"),p1=ss("CharacterJoinerService"),El=ss("ThemeService"),_1=ss("LinkProviderService"),HR=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cS.isErrorNoTelemetry(e)?new cS(e.message+`
75
+
76
+ `+e.stack):new Error(e.message+`
77
+
78
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},FR=new HR;function ih(e){IR(e)||FR.onUnexpectedError(e)}var bp="Canceled";function IR(e){return e instanceof UR?!0:e instanceof Error&&e.name===bp&&e.message===bp}var UR=class extends Error{constructor(){super(bp),this.name=this.message}};function KR(e){return new Error(`Illegal argument: ${e}`)}var cS=class Sp extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Sp)return t;let s=new Sp;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},xp=class g1 extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,g1.prototype)}};function Ks(e,t=0){return e[e.length-(1+t)]}var $R;(e=>{function t(c){return c<0}e.isLessThan=t;function s(c){return c<=0}e.isLessThanOrEqual=s;function n(c){return c>0}e.isGreaterThan=n;function a(c){return c===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})($R||($R={}));function WR(e,t){let s=this,n=!1,a;return function(){return n||(n=!0,t||(a=e.apply(s,arguments))),a}}var v1;(e=>{function t(D){return D&&typeof D=="object"&&typeof D[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function n(){return s}e.empty=n;function*a(D){yield D}e.single=a;function c(D){return t(D)?D:a(D)}e.wrap=c;function h(D){return D||s}e.from=h;function*d(D){for(let Y=D.length-1;Y>=0;Y--)yield D[Y]}e.reverse=d;function f(D){return!D||D[Symbol.iterator]().next().done===!0}e.isEmpty=f;function m(D){return D[Symbol.iterator]().next().value}e.first=m;function g(D,Y){let K=0;for(let Z of D)if(Y(Z,K++))return!0;return!1}e.some=g;function v(D,Y){for(let K of D)if(Y(K))return K}e.find=v;function*b(D,Y){for(let K of D)Y(K)&&(yield K)}e.filter=b;function*S(D,Y){let K=0;for(let Z of D)yield Y(Z,K++)}e.map=S;function*x(D,Y){let K=0;for(let Z of D)yield*Y(Z,K++)}e.flatMap=x;function*w(...D){for(let Y of D)yield*Y}e.concat=w;function k(D,Y,K){let Z=K;for(let Q of D)Z=Y(Z,Q);return Z}e.reduce=k;function*N(D,Y,K=D.length){for(Y<0&&(Y+=D.length),K<0?K+=D.length:K>D.length&&(K=D.length);Y<K;Y++)yield D[Y]}e.slice=N;function L(D,Y=Number.POSITIVE_INFINITY){let K=[];if(Y===0)return[K,D];let Z=D[Symbol.iterator]();for(let Q=0;Q<Y;Q++){let z=Z.next();if(z.done)return[K,e.empty()];K.push(z.value)}return[K,{[Symbol.iterator](){return Z}}]}e.consume=L;async function R(D){let Y=[];for await(let K of D)Y.push(K);return Promise.resolve(Y)}e.asyncToArray=R})(v1||(v1={}));function ua(e){if(v1.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(n){t.push(n)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function VR(...e){return vt(()=>ua(e))}function vt(e){return{dispose:WR(()=>{e()})}}var y1=class b1{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{ua(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?b1.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};y1.DISABLE_DISPOSED_WARNING=!1;var _n=y1,Ie=class{constructor(){this._store=new _n,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Ie.None=Object.freeze({dispose(){}});var Cl=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},fr=typeof window=="object"?window:globalThis,wp=class Cp{constructor(t){this.element=t,this.next=Cp.Undefined,this.prev=Cp.Undefined}};wp.Undefined=new wp(void 0);var yt=wp,uS=class{constructor(){this._first=yt.Undefined,this._last=yt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===yt.Undefined}clear(){let e=this._first;for(;e!==yt.Undefined;){let t=e.next;e.prev=yt.Undefined,e.next=yt.Undefined,e=t}this._first=yt.Undefined,this._last=yt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new yt(e);if(this._first===yt.Undefined)this._first=s,this._last=s;else if(t){let a=this._last;this._last=s,s.prev=a,a.next=s}else{let a=this._first;this._first=s,s.next=a,a.prev=s}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(s))}}shift(){if(this._first!==yt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==yt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==yt.Undefined&&e.next!==yt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===yt.Undefined&&e.next===yt.Undefined?(this._first=yt.Undefined,this._last=yt.Undefined):e.next===yt.Undefined?(this._last=this._last.prev,this._last.next=yt.Undefined):e.prev===yt.Undefined&&(this._first=this._first.next,this._first.prev=yt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==yt.Undefined;)yield e.element,e=e.next}},YR=globalThis.performance&&typeof globalThis.performance.now=="function",GR=class S1{static create(t){return new S1(t)}constructor(t){this._now=YR&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},cs;(e=>{e.None=()=>Ie.None;function t(H,O){return v(H,()=>{},0,void 0,!0,void 0,O)}e.defer=t;function s(H){return(O,W=null,ee)=>{let T=!1,F;return F=H(J=>{if(!T)return F?F.dispose():T=!0,O.call(W,J)},null,ee),T&&F.dispose(),F}}e.once=s;function n(H,O,W){return m((ee,T=null,F)=>H(J=>ee.call(T,O(J)),null,F),W)}e.map=n;function a(H,O,W){return m((ee,T=null,F)=>H(J=>{O(J),ee.call(T,J)},null,F),W)}e.forEach=a;function c(H,O,W){return m((ee,T=null,F)=>H(J=>O(J)&&ee.call(T,J),null,F),W)}e.filter=c;function h(H){return H}e.signal=h;function d(...H){return(O,W=null,ee)=>{let T=VR(...H.map(F=>F(J=>O.call(W,J))));return g(T,ee)}}e.any=d;function f(H,O,W,ee){let T=W;return n(H,F=>(T=O(T,F),T),ee)}e.reduce=f;function m(H,O){let W,ee={onWillAddFirstListener(){W=H(T.fire,T)},onDidRemoveLastListener(){W==null||W.dispose()}},T=new fe(ee);return O==null||O.add(T),T.event}function g(H,O){return O instanceof Array?O.push(H):O&&O.add(H),H}function v(H,O,W=100,ee=!1,T=!1,F,J){let ve,oe,M,U=0,ae,V={leakWarningThreshold:F,onWillAddFirstListener(){ve=H(_e=>{U++,oe=O(oe,_e),ee&&!M&&(de.fire(oe),oe=void 0),ae=()=>{let Ae=oe;oe=void 0,M=void 0,(!ee||U>1)&&de.fire(Ae),U=0},typeof W=="number"?(clearTimeout(M),M=setTimeout(ae,W)):M===void 0&&(M=0,queueMicrotask(ae))})},onWillRemoveListener(){T&&U>0&&(ae==null||ae())},onDidRemoveLastListener(){ae=void 0,ve.dispose()}},de=new fe(V);return J==null||J.add(de),de.event}e.debounce=v;function b(H,O=0,W){return e.debounce(H,(ee,T)=>ee?(ee.push(T),ee):[T],O,void 0,!0,void 0,W)}e.accumulate=b;function S(H,O=(ee,T)=>ee===T,W){let ee=!0,T;return c(H,F=>{let J=ee||!O(F,T);return ee=!1,T=F,J},W)}e.latch=S;function x(H,O,W){return[e.filter(H,O,W),e.filter(H,ee=>!O(ee),W)]}e.split=x;function w(H,O=!1,W=[],ee){let T=W.slice(),F=H(oe=>{T?T.push(oe):ve.fire(oe)});ee&&ee.add(F);let J=()=>{T==null||T.forEach(oe=>ve.fire(oe)),T=null},ve=new fe({onWillAddFirstListener(){F||(F=H(oe=>ve.fire(oe)),ee&&ee.add(F))},onDidAddFirstListener(){T&&(O?setTimeout(J):J())},onDidRemoveLastListener(){F&&F.dispose(),F=null}});return ee&&ee.add(ve),ve.event}e.buffer=w;function k(H,O){return(W,ee,T)=>{let F=O(new L);return H(function(J){let ve=F.evaluate(J);ve!==N&&W.call(ee,ve)},void 0,T)}}e.chain=k;let N=Symbol("HaltChainable");class L{constructor(){this.steps=[]}map(O){return this.steps.push(O),this}forEach(O){return this.steps.push(W=>(O(W),W)),this}filter(O){return this.steps.push(W=>O(W)?W:N),this}reduce(O,W){let ee=W;return this.steps.push(T=>(ee=O(ee,T),ee)),this}latch(O=(W,ee)=>W===ee){let W=!0,ee;return this.steps.push(T=>{let F=W||!O(T,ee);return W=!1,ee=T,F?T:N}),this}evaluate(O){for(let W of this.steps)if(O=W(O),O===N)break;return O}}function R(H,O,W=ee=>ee){let ee=(...ve)=>J.fire(W(...ve)),T=()=>H.on(O,ee),F=()=>H.removeListener(O,ee),J=new fe({onWillAddFirstListener:T,onDidRemoveLastListener:F});return J.event}e.fromNodeEventEmitter=R;function D(H,O,W=ee=>ee){let ee=(...ve)=>J.fire(W(...ve)),T=()=>H.addEventListener(O,ee),F=()=>H.removeEventListener(O,ee),J=new fe({onWillAddFirstListener:T,onDidRemoveLastListener:F});return J.event}e.fromDOMEventEmitter=D;function Y(H){return new Promise(O=>s(H)(O))}e.toPromise=Y;function K(H){let O=new fe;return H.then(W=>{O.fire(W)},()=>{O.fire(void 0)}).finally(()=>{O.dispose()}),O.event}e.fromPromise=K;function Z(H,O){return H(W=>O.fire(W))}e.forward=Z;function Q(H,O,W){return O(W),H(ee=>O(ee))}e.runAndSubscribe=Q;class z{constructor(O,W){this._observable=O,this._counter=0,this._hasChanged=!1;let ee={onWillAddFirstListener:()=>{O.addObserver(this)},onDidRemoveLastListener:()=>{O.removeObserver(this)}};this.emitter=new fe(ee),W&&W.add(this.emitter)}beginUpdate(O){this._counter++}handlePossibleChange(O){}handleChange(O,W){this._hasChanged=!0}endUpdate(O){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function G(H,O){return new z(H,O).emitter.event}e.fromObservable=G;function le(H){return(O,W,ee)=>{let T=0,F=!1,J={beginUpdate(){T++},endUpdate(){T--,T===0&&(H.reportChanges(),F&&(F=!1,O.call(W)))},handlePossibleChange(){},handleChange(){F=!0}};H.addObserver(J),H.reportChanges();let ve={dispose(){H.removeObserver(J)}};return ee instanceof _n?ee.add(ve):Array.isArray(ee)&&ee.push(ve),ve}}e.fromObservableLight=le})(cs||(cs={}));var jp=class kp{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${kp._idPool++}`,kp.all.add(this)}start(t){this._stopWatch=new GR,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};jp.all=new Set,jp._idPool=0;var QR=jp,ZR=-1,x1=class w1{constructor(t,s,n=(w1._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=n,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let n=this.threshold;if(n<=0||s<n)return;this._stacks||(this._stacks=new Map);let a=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,a+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[c,h]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${h}):`;console.warn(d),console.warn(c);let f=new eD(d,c);this._errorHandler(f)}return()=>{let c=this._stacks.get(t.value)||0;this._stacks.set(t.value,c-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[n,a]of this._stacks)(!t||s<a)&&(t=[n,a],s=a);return t}};x1._idPool=1;var XR=x1,JR=class C1{constructor(t){this.value=t}static create(){let t=new Error;return new C1(t.stack??"")}print(){console.warn(this.value.split(`
79
+ `).slice(2).join(`
80
+ `))}},eD=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},tD=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},sD=0,gm=class{constructor(e){this.value=e,this.id=sD++}},iD=2,rD,fe=class{constructor(e){var t,s,n,a;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new XR((e==null?void 0:e.onListenerError)??ih,((s=this._options)==null?void 0:s.leakWarningThreshold)??ZR):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new QR(this._options._profName):void 0,this._deliveryQueue=(a=this._options)==null?void 0:a.deliveryQueue}dispose(){var e,t,s,n;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||s.call(t),(n=this._leakageMon)==null||n.dispose())}get event(){return this._event??(this._event=(e,t,s)=>{var h,d,f,m,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let v=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(v);let b=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],S=new tD(`${v}. HINT: Stack shows most frequent listener (${b[1]}-times)`,b[0]);return(((h=this._options)==null?void 0:h.onListenerError)||ih)(S),Ie.None}if(this._disposed)return Ie.None;t&&(e=e.bind(t));let n=new gm(e),a;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=JR.create(),a=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof gm?(this._deliveryQueue??(this._deliveryQueue=new nD),this._listeners=[this._listeners,n]):this._listeners.push(n):((f=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||f.call(d,this),this._listeners=n,(g=(m=this._options)==null?void 0:m.onDidAddFirstListener)==null||g.call(m,this)),this._size++;let c=vt(()=>{a==null||a(),this._removeListener(n)});return s instanceof _n?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(e){var a,c,h,d;if((c=(a=this._options)==null?void 0:a.onWillRemoveListener)==null||c.call(a,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(h=this._options)==null?void 0:h.onDidRemoveLastListener)==null||d.call(h,this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[s]=void 0;let n=this._deliveryQueue.current===this;if(this._size*iD<=t.length){let f=0;for(let m=0;m<t.length;m++)t[m]?t[f++]=t[m]:n&&(this._deliveryQueue.end--,f<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=f}}_deliver(e,t){var n;if(!e)return;let s=((n=this._options)==null?void 0:n.onListenerError)||ih;if(!s){e.value(t);return}try{e.value(t)}catch(a){s(a)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,s,n,a;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(s=this._perfMon)==null||s.stop()),(n=this._perfMon)==null||n.start(this._size),this._listeners)if(this._listeners instanceof gm)this._deliver(this._listeners,e);else{let c=this._deliveryQueue;c.enqueue(this,e,this._listeners.length),this._deliverQueue(c)}(a=this._perfMon)==null||a.stop()}hasListeners(){return this._size>0}},nD=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Np=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new fe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new fe,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let n=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(n,t),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let n=this.getWindowId(s);this.mapWindowIdToFullScreen.set(n,t),this._onDidChangeFullscreen.fire(n)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Np.INSTANCE=new Np;var M_=Np;function aD(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}M_.INSTANCE.onDidChangeZoomLevel;function lD(e){return M_.INSTANCE.getZoomFactor(e)}M_.INSTANCE.onDidChangeFullscreen;var Tl=typeof navigator=="object"?navigator.userAgent:"",Ep=Tl.indexOf("Firefox")>=0,oD=Tl.indexOf("AppleWebKit")>=0,B_=Tl.indexOf("Chrome")>=0,cD=!B_&&Tl.indexOf("Safari")>=0;Tl.indexOf("Electron/")>=0;Tl.indexOf("Android")>=0;var vm=!1;if(typeof fr.matchMedia=="function"){let e=fr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=fr.matchMedia("(display-mode: fullscreen)");vm=e.matches,aD(fr,e,({matches:s})=>{vm&&t.matches||(vm=s)})}var rl="en",Tp=!1,Op=!1,rh=!1,j1=!1,Ku,nh=rl,hS=rl,uD,vi,ia=globalThis,os,Ax;typeof ia.vscode<"u"&&typeof ia.vscode.process<"u"?os=ia.vscode.process:typeof process<"u"&&typeof((Ax=process==null?void 0:process.versions)==null?void 0:Ax.node)=="string"&&(os=process);var Rx,hD=typeof((Rx=os==null?void 0:os.versions)==null?void 0:Rx.electron)=="string",dD=hD&&(os==null?void 0:os.type)==="renderer",Dx;if(typeof os=="object"){Tp=os.platform==="win32",Op=os.platform==="darwin",rh=os.platform==="linux",rh&&os.env.SNAP&&os.env.SNAP_REVISION,os.env.CI||os.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ku=rl,nh=rl;let e=os.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ku=t.userLocale,hS=t.osLocale,nh=t.resolvedLanguage||rl,uD=(Dx=t.languagePack)==null?void 0:Dx.translationsConfigFile}catch{}j1=!0}else typeof navigator=="object"&&!dD?(vi=navigator.userAgent,Tp=vi.indexOf("Windows")>=0,Op=vi.indexOf("Macintosh")>=0,(vi.indexOf("Macintosh")>=0||vi.indexOf("iPad")>=0||vi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,rh=vi.indexOf("Linux")>=0,(vi==null?void 0:vi.indexOf("Mobi"))>=0,nh=globalThis._VSCODE_NLS_LANGUAGE||rl,Ku=navigator.language.toLowerCase(),hS=Ku):console.error("Unable to resolve platform.");var k1=Tp,zi=Op,fD=rh,dS=j1,Pi=vi,Wr=nh,mD;(e=>{function t(){return Wr}e.value=t;function s(){return Wr.length===2?Wr==="en":Wr.length>=3?Wr[0]==="e"&&Wr[1]==="n"&&Wr[2]==="-":!1}e.isDefaultVariant=s;function n(){return Wr==="en"}e.isDefault=n})(mD||(mD={}));var pD=typeof ia.postMessage=="function"&&!ia.importScripts;(()=>{if(pD){let e=[];ia.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let n=0,a=e.length;n<a;n++){let c=e[n];if(c.id===s.data.vscodeScheduleAsyncWork){e.splice(n,1),c.callback();return}}});let t=0;return s=>{let n=++t;e.push({id:n,callback:s}),ia.postMessage({vscodeScheduleAsyncWork:n},"*")}}return e=>setTimeout(e)})();var _D=!!(Pi&&Pi.indexOf("Chrome")>=0);Pi&&Pi.indexOf("Firefox")>=0;!_D&&Pi&&Pi.indexOf("Safari")>=0;Pi&&Pi.indexOf("Edg/")>=0;Pi&&Pi.indexOf("Android")>=0;var tl=typeof navigator=="object"?navigator:{};dS||document.queryCommandSupported&&document.queryCommandSupported("copy")||tl&&tl.clipboard&&tl.clipboard.writeText,dS||tl&&tl.clipboard&&tl.clipboard.readText;var L_=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},ym=new L_,fS=new L_,mS=new L_,gD=new Array(230),N1;(e=>{function t(d){return ym.keyCodeToStr(d)}e.toString=t;function s(d){return ym.strToKeyCode(d)}e.fromString=s;function n(d){return fS.keyCodeToStr(d)}e.toUserSettingsUS=n;function a(d){return mS.keyCodeToStr(d)}e.toUserSettingsGeneral=a;function c(d){return fS.strToKeyCode(d)||mS.strToKeyCode(d)}e.fromUserSettings=c;function h(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ym.keyCodeToStr(d)}e.toElectronAccelerator=h})(N1||(N1={}));var vD=class E1{constructor(t,s,n,a,c){this.ctrlKey=t,this.shiftKey=s,this.altKey=n,this.metaKey=a,this.keyCode=c}equals(t){return t instanceof E1&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",n=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${s}${n}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new yD([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},yD=class{constructor(e){if(e.length===0)throw KR("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function bD(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return N1.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Ep)switch(t){case 59:return 85;case 60:if(fD)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(zi)return 57;break}else if(oD&&(zi&&t===93||!zi&&t===92))return 57;return gD[t]||0}var SD=zi?256:2048,xD=512,wD=1024,CD=zi?2048:256,pS=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=bD(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=SD),this.altKey&&(t|=xD),this.shiftKey&&(t|=wD),this.metaKey&&(t|=CD),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new vD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},_S=new WeakMap;function jD(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var kD=class{static getSameOriginWindowChain(e){let t=_S.get(e);if(!t){t=[],_S.set(e,t);let s=e,n;do n=jD(s),n?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=n;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,n=0,a=this.getSameOriginWindowChain(e);for(let c of a){let h=c.window.deref();if(s+=(h==null?void 0:h.scrollY)??0,n+=(h==null?void 0:h.scrollX)??0,h===t||!c.iframeElement)break;let d=c.iframeElement.getBoundingClientRect();s+=d.top,n+=d.left}return{top:s,left:n}}},$u=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=kD.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},gS=class{constructor(e,t=0,s=0){var a;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let n=!1;if(B_){let c=navigator.userAgent.match(/Chrome\/(\d+)/);n=(c?parseInt(c[1]):123)<=122}if(e){let c=e,h=e,d=((a=e.view)==null?void 0:a.devicePixelRatio)||1;if(typeof c.wheelDeltaY<"u")n?this.deltaY=c.wheelDeltaY/(120*d):this.deltaY=c.wheelDeltaY/120;else if(typeof h.VERTICAL_AXIS<"u"&&h.axis===h.VERTICAL_AXIS)this.deltaY=-h.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Ep&&!zi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof c.wheelDeltaX<"u")cD&&k1?this.deltaX=-(c.wheelDeltaX/120):n?this.deltaX=c.wheelDeltaX/(120*d):this.deltaX=c.wheelDeltaX/120;else if(typeof h.HORIZONTAL_AXIS<"u"&&h.axis===h.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Ep&&!zi?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(n?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},T1=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),ND;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof ED?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:cs.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:T1})})(ND||(ND={}));var ED=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?T1:(this._emitter||(this._emitter=new fe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},q_=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new xp("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new xp("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},TD=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new xp("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=s.setInterval(()=>{e()},t);this.disposable=vt(()=>{s.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},OD;(e=>{async function t(n){let a,c=await Promise.all(n.map(h=>h.then(d=>d,d=>{a||(a=d)})));if(typeof a<"u")throw a;return c}e.settled=t;function s(n){return new Promise(async(a,c)=>{try{await n(a,c)}catch(h){c(h)}})}e.withAsyncBody=s})(OD||(OD={}));var vS=class ci{static fromArray(t){return new ci(s=>{s.emitMany(t)})}static fromPromise(t){return new ci(async s=>{s.emitMany(await t)})}static fromPromises(t){return new ci(async s=>{await Promise.all(t.map(async n=>s.emitOne(await n)))})}static merge(t){return new ci(async s=>{await Promise.all(t.map(async n=>{for await(let a of n)s.emitOne(a)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new fe,queueMicrotask(async()=>{let n={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(n)),this.resolve()}catch(a){this.reject(a)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await cs.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new ci(async n=>{for await(let a of t)n.emitOne(s(a))})}map(t){return ci.map(this,t)}static filter(t,s){return new ci(async n=>{for await(let a of t)s(a)&&n.emitOne(a)})}filter(t){return ci.filter(this,t)}static coalesce(t){return ci.filter(t,s=>!!s)}coalesce(){return ci.coalesce(this)}static async toPromise(t){let s=[];for await(let n of t)s.push(n);return s}toPromise(){return ci.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};vS.EMPTY=vS.fromArray([]);var{getWindow:Bi,getWindowId:AD,onDidRegisterWindow:RD}=(function(){let e=new Map,t={window:fr,disposables:new _n};e.set(fr.vscodeWindowId,t);let s=new fe,n=new fe,a=new fe;function c(h,d){return(typeof h=="number"?e.get(h):void 0)??(d?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:n.event,registerWindow(h){if(e.has(h.vscodeWindowId))return Ie.None;let d=new _n,f={window:h,disposables:d.add(new _n)};return e.set(h.vscodeWindowId,f),d.add(vt(()=>{e.delete(h.vscodeWindowId),n.fire(h)})),d.add(Oe(h,Zt.BEFORE_UNLOAD,()=>{a.fire(h)})),s.fire(f),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(h){return h.vscodeWindowId},hasWindow(h){return e.has(h)},getWindowById:c,getWindow(h){var m;let d=h;if((m=d==null?void 0:d.ownerDocument)!=null&&m.defaultView)return d.ownerDocument.defaultView.window;let f=h;return f!=null&&f.view?f.view.window:fr},getDocument(h){return Bi(h).document}}})(),DD=class{constructor(e,t,s,n){this._node=e,this._type=t,this._handler=s,this._options=n||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Oe(e,t,s,n){return new DD(e,t,s,n)}var yS=function(e,t,s,n){return Oe(e,t,s,n)},z_,MD=class extends TD{constructor(e){super(),this.defaultTarget=e&&Bi(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},bS=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){ih(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,n=new Map,a=c=>{s.set(c,!1);let h=e.get(c)??[];for(t.set(c,h),e.set(c,[]),n.set(c,!0);h.length>0;)h.sort(bS.sort),h.shift().execute();n.set(c,!1)};z_=(c,h,d=0)=>{let f=AD(c),m=new bS(h,d),g=e.get(f);return g||(g=[],e.set(f,g)),g.push(m),s.get(f)||(s.set(f,!0),c.requestAnimationFrame(()=>a(f))),m}})();function BD(e){let t=e.getBoundingClientRect(),s=Bi(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Zt={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},LD=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Ts(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Ts(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Ts(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Ts(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Ts(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Ts(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Ts(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Ts(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Ts(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Ts(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Ts(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Ts(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Ts(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Ts(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Ts(e){return typeof e=="number"?`${e}px`:e}function Io(e){return new LD(e)}var O1=class{constructor(){this._hooks=new _n,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,n,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=a;let c=e;try{e.setPointerCapture(t),this._hooks.add(vt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=Bi(e)}this._hooks.add(Oe(c,Zt.POINTER_MOVE,h=>{if(h.buttons!==s){this.stopMonitoring(!0);return}h.preventDefault(),this._pointerMoveCallback(h)})),this._hooks.add(Oe(c,Zt.POINTER_UP,h=>this.stopMonitoring(!0)))}};function qD(e,t,s){let n=null,a=null;if(typeof s.value=="function"?(n="value",a=s.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(n="get",a=s.get),!a)throw new Error("not supported");let c=`$memoize$${t}`;s[n]=function(...h){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,h)}),this[c]}}var Ti;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Ti||(Ti={}));var Bo=class fs extends Ie{constructor(){super(),this.dispatched=!1,this.targets=new uS,this.ignoreTargets=new uS,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(cs.runAndSubscribe(RD,({window:t,disposables:s})=>{s.add(Oe(t.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),s.add(Oe(t.document,"touchend",n=>this.onTouchEnd(t,n))),s.add(Oe(t.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:fr,disposables:this._store}))}static addTarget(t){if(!fs.isTouchDevice())return Ie.None;fs.INSTANCE||(fs.INSTANCE=new fs);let s=fs.INSTANCE.targets.push(t);return vt(s)}static ignoreTarget(t){if(!fs.isTouchDevice())return Ie.None;fs.INSTANCE||(fs.INSTANCE=new fs);let s=fs.INSTANCE.ignoreTargets.push(t);return vt(s)}static isTouchDevice(){return"ontouchstart"in fr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,a=t.targetTouches.length;n<a;n++){let c=t.targetTouches.item(n);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:s,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[s],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let h=this.newGestureEvent(Ti.Start,c.target);h.pageX=c.pageX,h.pageY=c.pageY,this.dispatchEvent(h)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let n=Date.now(),a=Object.keys(this.activeTouches).length;for(let c=0,h=s.changedTouches.length;c<h;c++){let d=s.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let f=this.activeTouches[d.identifier],m=Date.now()-f.initialTimeStamp;if(m<fs.HOLD_DELAY&&Math.abs(f.initialPageX-Ks(f.rollingPageX))<30&&Math.abs(f.initialPageY-Ks(f.rollingPageY))<30){let g=this.newGestureEvent(Ti.Tap,f.initialTarget);g.pageX=Ks(f.rollingPageX),g.pageY=Ks(f.rollingPageY),this.dispatchEvent(g)}else if(m>=fs.HOLD_DELAY&&Math.abs(f.initialPageX-Ks(f.rollingPageX))<30&&Math.abs(f.initialPageY-Ks(f.rollingPageY))<30){let g=this.newGestureEvent(Ti.Contextmenu,f.initialTarget);g.pageX=Ks(f.rollingPageX),g.pageY=Ks(f.rollingPageY),this.dispatchEvent(g)}else if(a===1){let g=Ks(f.rollingPageX),v=Ks(f.rollingPageY),b=Ks(f.rollingTimestamps)-f.rollingTimestamps[0],S=g-f.rollingPageX[0],x=v-f.rollingPageY[0],w=[...this.targets].filter(k=>f.initialTarget instanceof Node&&k.contains(f.initialTarget));this.inertia(t,w,n,Math.abs(S)/b,S>0?1:-1,g,Math.abs(x)/b,x>0?1:-1,v)}this.dispatchEvent(this.newGestureEvent(Ti.End,f.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let n=document.createEvent("CustomEvent");return n.initEvent(t,!1,!0),n.initialTarget=s,n.tapCount=0,n}dispatchEvent(t){if(t.type===Ti.Tap){let s=new Date().getTime(),n=0;s-this._lastSetTapCountTime>fs.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=s,t.tapCount=n}else(t.type===Ti.Change||t.type===Ti.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(t.initialTarget))return;let s=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let a=0,c=t.initialTarget;for(;c&&c!==n;)a++,c=c.parentElement;s.push([a,n])}s.sort((n,a)=>n[0]-a[0]);for(let[n,a]of s)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,n,a,c,h,d,f,m){this.handle=z_(t,()=>{let g=Date.now(),v=g-n,b=0,S=0,x=!0;a+=fs.SCROLL_FRICTION*v,d+=fs.SCROLL_FRICTION*v,a>0&&(x=!1,b=c*a*v),d>0&&(x=!1,S=f*d*v);let w=this.newGestureEvent(Ti.Change);w.translationX=b,w.translationY=S,s.forEach(k=>k.dispatchEvent(w)),x||this.inertia(t,s,g,a,c,h+b,d,f,m+S)})}onTouchMove(t){let s=Date.now();for(let n=0,a=t.changedTouches.length;n<a;n++){let c=t.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let h=this.activeTouches[c.identifier],d=this.newGestureEvent(Ti.Change,h.initialTarget);d.translationX=c.pageX-Ks(h.rollingPageX),d.translationY=c.pageY-Ks(h.rollingPageY),d.pageX=c.pageX,d.pageY=c.pageY,this.dispatchEvent(d),h.rollingPageX.length>3&&(h.rollingPageX.shift(),h.rollingPageY.shift(),h.rollingTimestamps.shift()),h.rollingPageX.push(c.pageX),h.rollingPageY.push(c.pageY),h.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Bo.SCROLL_FRICTION=-.005,Bo.HOLD_DELAY=700,Bo.CLEAR_TAP_COUNT_TIME=400,Nt([qD],Bo,"isTouchDevice",1);var zD=Bo,P_=class extends Ie{onclick(e,t){this._register(Oe(e,Zt.CLICK,s=>t(new $u(Bi(e),s))))}onmousedown(e,t){this._register(Oe(e,Zt.MOUSE_DOWN,s=>t(new $u(Bi(e),s))))}onmouseover(e,t){this._register(Oe(e,Zt.MOUSE_OVER,s=>t(new $u(Bi(e),s))))}onmouseleave(e,t){this._register(Oe(e,Zt.MOUSE_LEAVE,s=>t(new $u(Bi(e),s))))}onkeydown(e,t){this._register(Oe(e,Zt.KEY_DOWN,s=>t(new pS(s))))}onkeyup(e,t){this._register(Oe(e,Zt.KEY_UP,s=>t(new pS(s))))}oninput(e,t){this._register(Oe(e,Zt.INPUT,t))}onblur(e,t){this._register(Oe(e,Zt.BLUR,t))}onfocus(e,t){this._register(Oe(e,Zt.FOCUS,t))}onchange(e,t){this._register(Oe(e,Zt.CHANGE,t))}ignoreGesture(e){return zD.ignoreTarget(e)}},SS=11,PD=class extends P_{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=SS+"px",this.domNode.style.height=SS+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new O1),this._register(yS(this.bgDomNode,Zt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(yS(this.domNode,Zt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new MD),this._pointerdownScheduleRepeatTimer=this._register(new q_)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Bi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},HD=class Ap{constructor(t,s,n,a,c,h,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,n=n|0,a=a|0,c=c|0,h=h|0,d=d|0),this.rawScrollLeft=a,this.rawScrollTop=d,s<0&&(s=0),a+s>n&&(a=n-s),a<0&&(a=0),c<0&&(c=0),d+c>h&&(d=h-c),d<0&&(d=0),this.width=s,this.scrollWidth=n,this.scrollLeft=a,this.height=c,this.scrollHeight=h,this.scrollTop=d}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new Ap(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Ap(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let n=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,h=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,f=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:a,scrollLeftChanged:c,heightChanged:h,scrollHeightChanged:d,scrollTopChanged:f}}},FD=class extends Ie{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new HD(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var n;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(n=this._smoothScrolling)==null||n.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let n;t?n=new wS(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=wS.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},xS=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function bm(e,t){let s=t-e;return function(n){return e+s*KD(n)}}function ID(e,t,s){return function(n){return n<s?e(n/s):t((n-s)/(1-s))}}var wS=class Rp{constructor(t,s,n,a){this.from=t,this.to=s,this.duration=a,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,n){if(Math.abs(t-s)>2.5*n){let a,c;return t<s?(a=t+.75*n,c=s-.75*n):(a=t-.75*n,c=s+.75*n),ID(bm(t,a),bm(c,s),.33)}return bm(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let n=this.scrollLeft(s),a=this.scrollTop(s);return new xS(n,a,!1)}return new xS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,n){return Rp.start(t,s,n)}static start(t,s,n){n=n+10;let a=Date.now()-10;return new Rp(t,s,a,n)}};function UD(e){return Math.pow(e,3)}function KD(e){return 1-UD(1-e)}var $D=class extends Ie{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new q_)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},WD=140,A1=class extends P_{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new $D(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new O1),this._shouldRender=!0,this.domNode=Io(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Oe(this.domNode.domNode,Zt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new PD(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,n){this.slider=Io(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Oe(this.slider.domNode,Zt.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),n=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);s<=a&&a<=n?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let a=BD(this.domNode.domNode);t=e.pageX-a.left,s=e.pageY-a.top}let n=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let c=this._sliderOrthogonalPointerPosition(a),h=Math.abs(c-s);if(k1&&h>WD){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let d=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(d))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},R1=class Dp{constructor(t,s,n,a,c,h){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=c,this._scrollPosition=h,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Dp(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,n,a,c){let h=Math.max(0,n-t),d=Math.max(0,h-2*s),f=a>0&&a>n;if(!f)return{computedAvailableSize:Math.round(h),computedIsNeeded:f,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let m=Math.round(Math.max(20,Math.floor(n*d/a))),g=(d-m)/(a-n),v=c*g;return{computedAvailableSize:Math.round(h),computedIsNeeded:f,computedSliderSize:Math.round(m),computedSliderRatio:g,computedSliderPosition:Math.round(v)}}_refreshComputedValues(){let t=Dp._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,n=this._scrollPosition;return s<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},VD=class extends A1{constructor(e,t,s){let n=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new R1(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,n.width,n.scrollWidth,a.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},YD=class extends A1{constructor(e,t,s){let n=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new R1(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,n.height,n.scrollHeight,a.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},GD=500,CS=50,QD=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Mp=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,n=1,a=this._rear;do{let c=a===this._front?t:Math.pow(2,-n);if(t-=c,s+=this._memory[a].score*c,a===this._front)break;a=(this._capacity+a-1)%this._capacity,n++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(B_){let s=Bi(t.browserEvent),n=lD(s);this.accept(Date.now(),t.deltaX*n,t.deltaY*n)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,n){let a=null,c=new QD(t,s,n);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(a=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,a)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(n+=.25),s){let a=Math.abs(t.deltaX),c=Math.abs(t.deltaY),h=Math.abs(s.deltaX),d=Math.abs(s.deltaY),f=Math.max(Math.min(a,h),1),m=Math.max(Math.min(c,d),1),g=Math.max(a,h),v=Math.max(c,d);g%f===0&&v%m===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Mp.INSTANCE=new Mp;var ZD=Mp,XD=class extends P_{constructor(e,t,s){super(),this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new fe),this.onWillScroll=this._onWillScroll.event,this._options=eM(t),this._scrollable=s,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let n={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new YD(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new VD(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Io(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Io(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Io(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new q_),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ua(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,zi&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new gS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ua(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new gS(s))};this._mouseWheelToDispose.push(Oe(this._listenOnDomNode,Zt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=ZD.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let c=e.deltaY*this._options.mouseWheelScrollSensitivity,h=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&h+c===0?h=c=0:Math.abs(c)>=Math.abs(h)?h=0:c=0),this._options.flipAxes&&([c,h]=[h,c]);let d=!zi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!h&&(h=c,c=0),e.browserEvent&&e.browserEvent.altKey&&(h=h*this._options.fastScrollSensitivity,c=c*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),m={};if(c){let g=CS*c,v=f.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(m,v)}if(h){let g=CS*h,v=f.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(m,v)}m=this._scrollable.validateScrollPosition(m),(f.scrollLeft!==m.scrollLeft||f.scrollTop!==m.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(m):this._scrollable.setScrollPositionNow(m),s=!0)}let n=s;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,n=s?" left":"",a=t?" top":"",c=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${a}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),GD)}},JD=class extends XD{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function eM(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,zi&&(t.className+=" mac"),t}var Bp=class extends Ie{constructor(e,t,s,n,a,c,h,d){super(),this._bufferService=s,this._optionsService=h,this._renderService=d,this._onRequestScrollLines=this._register(new fe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new FD({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:m=>z_(n.window,m)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new JD(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(m=>{this._scrollableElement.updateOptions({handleMouseWheel:!(m&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(cs.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(vt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(vt(()=>this._styleElement.remove())),this._register(cs.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
81
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(m=>this._handleScroll(m)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Bp=Nt([pe(2,bs),pe(3,yr),pe(4,d1),pe(5,El),pe(6,Ss),pe(7,br)],Bp);var Lp=class extends Ie{constructor(e,t,s,n,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=n,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(vt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var n;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((n=e==null?void 0:e.options)==null?void 0:n.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Lp=Nt([pe(1,bs),pe(2,yr),pe(3,fc),pe(4,br)],Lp);var tM=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ni={full:0,left:0,center:0,right:0},Vr={full:0,left:0,center:0,right:0},ko={full:0,left:0,center:0,right:0},Ch=class extends Ie{constructor(e,t,s,n,a,c,h,d){var m;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=n,this._renderService=a,this._optionsService=c,this._themeService=h,this._coreBrowserService=d,this._colorZoneStore=new tM,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(m=this._viewportElement.parentElement)==null||m.insertBefore(this._canvas,this._viewportElement),this._register(vt(()=>{var g;return(g=this._canvas)==null?void 0:g.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Vr.full=this._canvas.width,Vr.left=e,Vr.center=t,Vr.right=e,this._refreshDrawHeightConstants(),ko.full=1,ko.left=1,ko.center=1+Vr.left,ko.right=1+Vr.left+Vr.center}_refreshDrawHeightConstants(){Ni.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Ni.left=t,Ni.center=t,Ni.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ni.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ni.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ni.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ni.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(ko[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ni[e.position||"full"]/2),Vr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ni[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Ch=Nt([pe(2,bs),pe(3,fc),pe(4,br),pe(5,Ss),pe(6,El),pe(7,yr)],Ch);var ne;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
82
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(ne||(ne={}));var ah;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(ah||(ah={}));var D1;(e=>e.ST=`${ne.ESC}\\`)(D1||(D1={}));var qp=class{constructor(e,t,s,n,a,c){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=n,this._coreService=a,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${ne.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,a=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=a+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=a+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};qp=Nt([pe(2,bs),pe(3,Ss),pe(4,pa),pe(5,br)],qp);var Xt=0,Jt=0,es=0,Ct=0,jS={css:"#00000000",rgba:0},Pt;(e=>{function t(a,c,h,d){return d!==void 0?`#${Hn(a)}${Hn(c)}${Hn(h)}${Hn(d)}`:`#${Hn(a)}${Hn(c)}${Hn(h)}`}e.toCss=t;function s(a,c,h,d=255){return(a<<24|c<<16|h<<8|d)>>>0}e.toRgba=s;function n(a,c,h,d){return{css:e.toCss(a,c,h,d),rgba:e.toRgba(a,c,h,d)}}e.toColor=n})(Pt||(Pt={}));var _t;(e=>{function t(f,m){if(Ct=(m.rgba&255)/255,Ct===1)return{css:m.css,rgba:m.rgba};let g=m.rgba>>24&255,v=m.rgba>>16&255,b=m.rgba>>8&255,S=f.rgba>>24&255,x=f.rgba>>16&255,w=f.rgba>>8&255;Xt=S+Math.round((g-S)*Ct),Jt=x+Math.round((v-x)*Ct),es=w+Math.round((b-w)*Ct);let k=Pt.toCss(Xt,Jt,es),N=Pt.toRgba(Xt,Jt,es);return{css:k,rgba:N}}e.blend=t;function s(f){return(f.rgba&255)===255}e.isOpaque=s;function n(f,m,g){let v=lh.ensureContrastRatio(f.rgba,m.rgba,g);if(v)return Pt.toColor(v>>24&255,v>>16&255,v>>8&255)}e.ensureContrastRatio=n;function a(f){let m=(f.rgba|255)>>>0;return[Xt,Jt,es]=lh.toChannels(m),{css:Pt.toCss(Xt,Jt,es),rgba:m}}e.opaque=a;function c(f,m){return Ct=Math.round(m*255),[Xt,Jt,es]=lh.toChannels(f.rgba),{css:Pt.toCss(Xt,Jt,es,Ct),rgba:Pt.toRgba(Xt,Jt,es,Ct)}}e.opacity=c;function h(f,m){return Ct=f.rgba&255,c(f,Ct*m/255)}e.multiplyOpacity=h;function d(f){return[f.rgba>>24&255,f.rgba>>16&255,f.rgba>>8&255]}e.toColorRGB=d})(_t||(_t={}));var bt;(e=>{let t,s;try{let a=document.createElement("canvas");a.width=1,a.height=1;let c=a.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Xt=parseInt(a.slice(1,2).repeat(2),16),Jt=parseInt(a.slice(2,3).repeat(2),16),es=parseInt(a.slice(3,4).repeat(2),16),Pt.toColor(Xt,Jt,es);case 5:return Xt=parseInt(a.slice(1,2).repeat(2),16),Jt=parseInt(a.slice(2,3).repeat(2),16),es=parseInt(a.slice(3,4).repeat(2),16),Ct=parseInt(a.slice(4,5).repeat(2),16),Pt.toColor(Xt,Jt,es,Ct);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let c=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return Xt=parseInt(c[1]),Jt=parseInt(c[2]),es=parseInt(c[3]),Ct=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),Pt.toColor(Xt,Jt,es,Ct);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Xt,Jt,es,Ct]=t.getImageData(0,0,1,1).data,Ct!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Pt.toRgba(Xt,Jt,es,Ct),css:a}}e.toColor=n})(bt||(bt={}));var gs;(e=>{function t(n){return s(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function s(n,a,c){let h=n/255,d=a/255,f=c/255,m=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),g=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),v=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4);return m*.2126+g*.7152+v*.0722}e.relativeLuminance2=s})(gs||(gs={}));var lh;(e=>{function t(h,d){if(Ct=(d&255)/255,Ct===1)return d;let f=d>>24&255,m=d>>16&255,g=d>>8&255,v=h>>24&255,b=h>>16&255,S=h>>8&255;return Xt=v+Math.round((f-v)*Ct),Jt=b+Math.round((m-b)*Ct),es=S+Math.round((g-S)*Ct),Pt.toRgba(Xt,Jt,es)}e.blend=t;function s(h,d,f){let m=gs.relativeLuminance(h>>8),g=gs.relativeLuminance(d>>8);if(ar(m,g)<f){if(g<m){let S=n(h,d,f),x=ar(m,gs.relativeLuminance(S>>8));if(x<f){let w=a(h,d,f),k=ar(m,gs.relativeLuminance(w>>8));return x>k?S:w}return S}let v=a(h,d,f),b=ar(m,gs.relativeLuminance(v>>8));if(b<f){let S=n(h,d,f),x=ar(m,gs.relativeLuminance(S>>8));return b>x?v:S}return v}}e.ensureContrastRatio=s;function n(h,d,f){let m=h>>24&255,g=h>>16&255,v=h>>8&255,b=d>>24&255,S=d>>16&255,x=d>>8&255,w=ar(gs.relativeLuminance2(b,S,x),gs.relativeLuminance2(m,g,v));for(;w<f&&(b>0||S>0||x>0);)b-=Math.max(0,Math.ceil(b*.1)),S-=Math.max(0,Math.ceil(S*.1)),x-=Math.max(0,Math.ceil(x*.1)),w=ar(gs.relativeLuminance2(b,S,x),gs.relativeLuminance2(m,g,v));return(b<<24|S<<16|x<<8|255)>>>0}e.reduceLuminance=n;function a(h,d,f){let m=h>>24&255,g=h>>16&255,v=h>>8&255,b=d>>24&255,S=d>>16&255,x=d>>8&255,w=ar(gs.relativeLuminance2(b,S,x),gs.relativeLuminance2(m,g,v));for(;w<f&&(b<255||S<255||x<255);)b=Math.min(255,b+Math.ceil((255-b)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),w=ar(gs.relativeLuminance2(b,S,x),gs.relativeLuminance2(m,g,v));return(b<<24|S<<16|x<<8|255)>>>0}e.increaseLuminance=a;function c(h){return[h>>24&255,h>>16&255,h>>8&255,h&255]}e.toChannels=c})(lh||(lh={}));function Hn(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ar(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var sM=class extends dc{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},jh=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new di}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],n=t.translateToString(!0),a=0,c=0,h=0,d=t.getFg(0),f=t.getBg(0);for(let m=0;m<t.getTrimmedLength();m++)if(t.loadCell(m,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==f){if(m-a>1){let g=this._getJoinedRanges(n,h,c,t,a);for(let v=0;v<g.length;v++)s.push(g[v])}a=m,h=c,d=this._workCell.fg,f=this._workCell.bg}c+=this._workCell.getChars().length||mn.length}if(this._bufferService.cols-a>1){let m=this._getJoinedRanges(n,h,c,t,a);for(let g=0;g<m.length;g++)s.push(m[g])}return s}_getJoinedRanges(e,t,s,n,a){let c=e.substring(t,s),h=[];try{h=this._characterJoiners[0].handler(c)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let f=this._characterJoiners[d].handler(c);for(let m=0;m<f.length;m++)jh._mergeRanges(h,f[m])}catch(f){console.error(f)}return this._stringRangesToCellRanges(h,n,a),h}_stringRangesToCellRanges(e,t,s){let n=0,a=!1,c=0,h=e[n];if(h){for(let d=s;d<this._bufferService.cols;d++){let f=t.getWidth(d),m=t.getString(d).length||mn.length;if(f!==0){if(!a&&h[0]<=c&&(h[0]=d,a=!0),h[1]<=c){if(h[1]=d,h=e[++n],!h)break;h[0]<=c?(h[0]=d,a=!0):a=!1}c+=m}}h&&(h[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let n=0;n<e.length;n++){let a=e[n];if(s){if(t[1]<=a[0])return e[n-1][1]=t[1],e;if(t[1]<=a[1])return e[n-1][1]=Math.max(t[1],a[1]),e.splice(n,1),e;e.splice(n,1),n--}else{if(t[1]<=a[0])return e.splice(n,0,t),e;if(t[1]<=a[1])return a[0]=Math.min(t[0],a[0]),e;t[0]<a[1]&&(a[0]=Math.min(t[0],a[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};jh=Nt([pe(0,bs)],jh);function iM(e){return 57508<=e&&e<=57558}function rM(e){return 9472<=e&&e<=9631}function nM(e){return iM(e)||rM(e)}function aM(){return{css:{canvas:Wu(),cell:Wu()},device:{canvas:Wu(),cell:Wu(),char:{width:0,height:0,left:0,top:0}}}}function Wu(){return{width:0,height:0}}var zp=class{constructor(e,t,s,n,a,c,h){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=n,this._coreService=a,this._decorationService=c,this._themeService=h,this._workCell=new di,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,n,a,c,h,d,f,m,g){let v=[],b=this._characterJoinerService.getJoinedCharacters(t),S=this._themeService.colors,x=e.getNoBgTrimmedLength();s&&x<c+1&&(x=c+1);let w,k=0,N="",L=0,R=0,D=0,Y=0,K=!1,Z=0,Q=!1,z=0,G=0,le=[],H=m!==-1&&g!==-1;for(let O=0;O<x;O++){e.loadCell(O,this._workCell);let W=this._workCell.getWidth();if(W===0)continue;let ee=!1,T=O>=G,F=O,J=this._workCell;if(b.length>0&&O===b[0][0]&&T){let et=b.shift(),mi=this._isCellInSelection(et[0],t);for(L=et[0]+1;L<et[1];L++)T&&(T=mi===this._isCellInSelection(L,t));T&&(T=!s||c<et[0]||c>=et[1]),T?(ee=!0,J=new sM(this._workCell,e.translateToString(!0,et[0],et[1]),et[1]-et[0]),F=et[1]-1,W=J.getWidth()):G=et[1]}let ve=this._isCellInSelection(O,t),oe=s&&O===c,M=H&&O>=m&&O<=g,U=!1;this._decorationService.forEachDecorationAtCell(O,t,void 0,et=>{U=!0});let ae=J.getChars()||mn;if(ae===" "&&(J.isUnderline()||J.isOverline())&&(ae=" "),z=W*d-f.get(ae,J.isBold(),J.isItalic()),!w)w=this._document.createElement("span");else if(k&&(ve&&Q||!ve&&!Q&&J.bg===R)&&(ve&&Q&&S.selectionForeground||J.fg===D)&&J.extended.ext===Y&&M===K&&z===Z&&!oe&&!ee&&!U&&T){J.isInvisible()?N+=mn:N+=ae,k++;continue}else k&&(w.textContent=N),w=this._document.createElement("span"),k=0,N="";if(R=J.bg,D=J.fg,Y=J.extended.ext,K=M,Z=z,Q=ve,ee&&c>=O&&c<=F&&(c=O),!this._coreService.isCursorHidden&&oe&&this._coreService.isCursorInitialized){if(le.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&le.push("xterm-cursor-blink"),le.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":le.push("xterm-cursor-outline");break;case"block":le.push("xterm-cursor-block");break;case"bar":le.push("xterm-cursor-bar");break;case"underline":le.push("xterm-cursor-underline");break}}if(J.isBold()&&le.push("xterm-bold"),J.isItalic()&&le.push("xterm-italic"),J.isDim()&&le.push("xterm-dim"),J.isInvisible()?N=mn:N=J.getChars()||mn,J.isUnderline()&&(le.push(`xterm-underline-${J.extended.underlineStyle}`),N===" "&&(N=" "),!J.isUnderlineColorDefault()))if(J.isUnderlineColorRGB())w.style.textDecorationColor=`rgb(${dc.toColorRGB(J.getUnderlineColor()).join(",")})`;else{let et=J.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&J.isBold()&&et<8&&(et+=8),w.style.textDecorationColor=S.ansi[et].css}J.isOverline()&&(le.push("xterm-overline"),N===" "&&(N=" ")),J.isStrikethrough()&&le.push("xterm-strikethrough"),M&&(w.style.textDecoration="underline");let V=J.getFgColor(),de=J.getFgColorMode(),_e=J.getBgColor(),Ae=J.getBgColorMode(),nt=!!J.isInverse();if(nt){let et=V;V=_e,_e=et;let mi=de;de=Ae,Ae=mi}let Xe,Ds,xi=!1;this._decorationService.forEachDecorationAtCell(O,t,void 0,et=>{et.options.layer!=="top"&&xi||(et.backgroundColorRGB&&(Ae=50331648,_e=et.backgroundColorRGB.rgba>>8&16777215,Xe=et.backgroundColorRGB),et.foregroundColorRGB&&(de=50331648,V=et.foregroundColorRGB.rgba>>8&16777215,Ds=et.foregroundColorRGB),xi=et.options.layer==="top")}),!xi&&ve&&(Xe=this._coreBrowserService.isFocused?S.selectionBackgroundOpaque:S.selectionInactiveBackgroundOpaque,_e=Xe.rgba>>8&16777215,Ae=50331648,xi=!0,S.selectionForeground&&(de=50331648,V=S.selectionForeground.rgba>>8&16777215,Ds=S.selectionForeground)),xi&&le.push("xterm-decoration-top");let Zs;switch(Ae){case 16777216:case 33554432:Zs=S.ansi[_e],le.push(`xterm-bg-${_e}`);break;case 50331648:Zs=Pt.toColor(_e>>16,_e>>8&255,_e&255),this._addStyle(w,`background-color:#${kS((_e>>>0).toString(16),"0",6)}`);break;case 0:default:nt?(Zs=S.foreground,le.push("xterm-bg-257")):Zs=S.background}switch(Xe||J.isDim()&&(Xe=_t.multiplyOpacity(Zs,.5)),de){case 16777216:case 33554432:J.isBold()&&V<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(V+=8),this._applyMinimumContrast(w,Zs,S.ansi[V],J,Xe,void 0)||le.push(`xterm-fg-${V}`);break;case 50331648:let et=Pt.toColor(V>>16&255,V>>8&255,V&255);this._applyMinimumContrast(w,Zs,et,J,Xe,Ds)||this._addStyle(w,`color:#${kS(V.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(w,Zs,S.foreground,J,Xe,Ds)||nt&&le.push("xterm-fg-257")}le.length&&(w.className=le.join(" "),le.length=0),!oe&&!ee&&!U&&T?k++:w.textContent=N,z!==this.defaultSpacing&&(w.style.letterSpacing=`${z}px`),v.push(w),O=F}return w&&k&&(w.textContent=N),v}_applyMinimumContrast(e,t,s,n,a,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||nM(n.getCode()))return!1;let h=this._getContrastCache(n),d;if(!a&&!c&&(d=h.getColor(t.rgba,s.rgba)),d===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);d=_t.ensureContrastRatio(a||t,c||s,f),h.setColor((a||t).rgba,(c||s).rgba,d??null)}return d?(this._addStyle(e,`color:${d.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,n=this._selectionEnd;return!s||!n?!1:this._columnSelectMode?s[0]<=n[0]?e>=s[0]&&t>=s[1]&&e<n[0]&&t<=n[1]:e<s[0]&&t>=s[1]&&e>=n[0]&&t<=n[1]:t>s[1]&&t<n[1]||s[1]===n[1]&&t===s[1]&&e>=s[0]&&e<n[0]||s[1]<n[1]&&t===n[1]&&e<n[0]||s[1]<n[1]&&t===s[1]&&e>=s[0]}};zp=Nt([pe(1,p1),pe(2,Ss),pe(3,yr),pe(4,pa),pe(5,fc),pe(6,El)],zp);function kS(e,t,s){for(;e.length<s;)e=t+e;return e}var lM=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[s,n,a,c],this._container.appendChild(s),this._container.appendChild(n),this._container.appendChild(a),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,n){e===this._font&&t===this._fontSize&&s===this._weight&&n===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(e,t,s){let n=0;if(!t&&!s&&e.length===1&&(n=e.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let h=this._measure(e,0);return h>0&&(this._flat[n]=h),h}let a=e;t&&(a+="B"),s&&(a+="I");let c=this._holey.get(a);if(c===void 0){let h=0;t&&(h|=1),s&&(h|=2),c=this._measure(e,h),c>0&&this._holey.set(a,c)}return c}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},oM=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,n=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let a=e.buffers.active.ydisp,c=t[1]-a,h=s[1]-a,d=Math.max(c,0),f=Math.min(h,e.rows-1);if(d>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=d,this.viewportCappedEndRow=f,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function cM(){return new oM}var Sm="xterm-dom-renderer-owner-",oi="xterm-rows",Vu="xterm-fg-",NS="xterm-bg-",No="xterm-focus",Yu="xterm-selection",uM=1,Pp=class extends Ie{constructor(e,t,s,n,a,c,h,d,f,m,g,v,b,S){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=n,this._viewportElement=a,this._helperContainer=c,this._linkifier2=h,this._charSizeService=f,this._optionsService=m,this._bufferService=g,this._coreService=v,this._coreBrowserService=b,this._themeService=S,this._terminalClass=uM++,this._rowElements=[],this._selectionRenderModel=cM(),this.onRequestRedraw=this._register(new fe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(oi),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Yu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=aM(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(zp,document),this._element.classList.add(Sm+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(vt(()=>{this._element.classList.remove(Sm+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new lM(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${oi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${oi} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${oi} .xterm-dim { color: ${_t.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${n} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${oi}.${No} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${oi}.${No} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${oi}.${No} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${oi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${oi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${oi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${oi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${oi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Yu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Yu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Yu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,h]of e.ansi.entries())t+=`${this._terminalSelector} .${Vu}${c} { color: ${h.css}; }${this._terminalSelector} .${Vu}${c}.xterm-dim { color: ${_t.multiplyOpacity(h,.5).css}; }${this._terminalSelector} .${NS}${c} { background-color: ${h.css}; }`;t+=`${this._terminalSelector} .${Vu}257 { color: ${_t.opaque(e.background).css}; }${this._terminalSelector} .${Vu}257.xterm-dim { color: ${_t.multiplyOpacity(_t.opaque(e.background),.5).css}; }${this._terminalSelector} .${NS}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(No),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(No),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,h=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(s){let f=e[0]>t[0];d.appendChild(this._createSelectionElement(c,f?t[0]:e[0],f?e[0]:t[0],h-c+1))}else{let f=n===c?e[0]:0,m=c===a?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(c,f,m));let g=h-c-1;if(d.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,g)),c!==h){let v=a===h?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(h,0,v))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,s,n=1){let a=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,h=this.dimensions.css.cell.width*(s-t);return c+h>this.dimensions.css.canvas.width&&(h=this.dimensions.css.canvas.width-c),a.style.height=`${n*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${c}px`,a.style.width=`${h}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,n=s.ybase+s.y,a=Math.min(s.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,h=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=t;f++){let m=f+s.ydisp,g=this._rowElements[f],v=s.lines.get(m);if(!g||!v)break;g.replaceChildren(...this._rowFactory.createRow(v,m,m===n,h,d,a,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Sm}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,n,a,c){s<0&&(e=0),n<0&&(t=0);let h=this._bufferService.rows-1;s=Math.max(Math.min(s,h),0),n=Math.max(Math.min(n,h),0),a=Math.min(a,this._bufferService.cols);let d=this._bufferService.buffer,f=d.ybase+d.y,m=Math.min(d.x,a-1),g=this._optionsService.rawOptions.cursorBlink,v=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let S=s;S<=n;++S){let x=S+d.ydisp,w=this._rowElements[S],k=d.lines.get(x);if(!w||!k)break;w.replaceChildren(...this._rowFactory.createRow(k,x,x===f,v,b,m,g,this.dimensions.css.cell.width,this._widthCache,c?S===s?e:0:-1,c?(S===n?t:a)-1:-1))}}};Pp=Nt([pe(7,R_),pe(8,Dh),pe(9,Ss),pe(10,bs),pe(11,pa),pe(12,yr),pe(13,El)],Pp);var Hp=class extends Ie{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new fe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new dM(this._optionsService))}catch{this._measureStrategy=this._register(new hM(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Hp=Nt([pe(2,Ss)],Hp);var M1=class extends Ie{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},hM=class extends M1{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},dM=class extends M1{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},fM=class extends Ie{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new mM(this._window)),this._onDprChange=this._register(new fe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new fe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(cs.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Oe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Oe(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},mM=class extends Ie{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Cl),this._onDprChange=this._register(new fe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(vt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Oe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},pM=class extends Ie{constructor(){super(),this.linkProviders=[],this._register(vt(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function H_(e,t,s){let n=s.getBoundingClientRect(),a=e.getComputedStyle(s),c=parseInt(a.getPropertyValue("padding-left")),h=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-n.left-c,t.clientY-n.top-h]}function _M(e,t,s,n,a,c,h,d,f){if(!c)return;let m=H_(e,t,s);if(m)return m[0]=Math.ceil((m[0]+(f?h/2:0))/h),m[1]=Math.ceil(m[1]/d),m[0]=Math.min(Math.max(m[0],1),n+(f?1:0)),m[1]=Math.min(Math.max(m[1],1),a),m}var Fp=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,n,a){return _M(window,e,t,s,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let s=H_(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Fp=Nt([pe(0,br),pe(1,Dh)],Fp);var gM=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},B1={};NR(B1,{getSafariVersion:()=>yM,isChromeOS:()=>P1,isFirefox:()=>L1,isIpad:()=>bM,isIphone:()=>SM,isLegacyEdge:()=>vM,isLinux:()=>F_,isMac:()=>kh,isNode:()=>Mh,isSafari:()=>q1,isWindows:()=>z1});var Mh=typeof process<"u"&&"title"in process,mc=Mh?"node":navigator.userAgent,pc=Mh?"node":navigator.platform,L1=mc.includes("Firefox"),vM=mc.includes("Edge"),q1=/^((?!chrome|android).)*safari/i.test(mc);function yM(){if(!q1)return 0;let e=mc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var kh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(pc),bM=pc==="iPad",SM=pc==="iPhone",z1=["Windows","Win16","Win32","WinCE"].includes(pc),F_=pc.indexOf("Linux")>=0,P1=/\bCrOS\b/.test(mc),H1=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),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(e){this._idleCallback=void 0;let t=0,s=0,n=e.timeRemaining(),a=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),a=e.timeRemaining(),s*1.5>a){n-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-t))}ms`),this._start();return}n=a}this.clear()}},xM=class extends H1{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},wM=class extends H1{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Nh=!Mh&&"requestIdleCallback"in window?wM:xM,CM=class{constructor(){this._queue=new Nh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Ip=class extends Ie{constructor(e,t,s,n,a,c,h,d,f){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=n,this._coreService=a,this._coreBrowserService=d,this._renderer=this._register(new Cl),this._pausedResizeTask=new CM,this._observerDisposable=this._register(new Cl),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new fe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new fe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new fe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new fe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new gM((m,g)=>this._renderRows(m,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new jM(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(vt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(h.onResize(()=>this._fullRefresh())),this._register(h.buffers.onBufferActivate(()=>{var m;return(m=this._renderer.value)==null?void 0:m.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(h.cols,h.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(h.buffer.y,h.buffer.y,!0))),this._register(f.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(m=>this._registerIntersectionObserver(m,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=vt(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let n=this._syncOutputHandler.flush();n&&(e=Math.min(e,n.start),t=Math.max(t,n.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var n;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(n=this._renderer.value)==null||n.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Ip=Nt([pe(2,Ss),pe(3,Dh),pe(4,pa),pe(5,fc),pe(6,bs),pe(7,yr),pe(8,El)],Ip);var jM=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function kM(e,t,s,n){let a=s.buffer.x,c=s.buffer.y;if(!s.buffer.hasScrollback)return TM(a,c,e,t,s,n)+Bh(c,t,s,n)+OM(a,c,e,t,s,n);let h;if(c===t)return h=a>e?"D":"C",Xo(Math.abs(a-e),Zo(h,n));h=c>t?"D":"C";let d=Math.abs(c-t),f=EM(c>t?e:a,s)+(d-1)*s.cols+1+NM(c>t?a:e);return Xo(f,Zo(h,n))}function NM(e,t){return e-1}function EM(e,t){return t.cols-e}function TM(e,t,s,n,a,c){return Bh(t,n,a,c).length===0?"":Xo(I1(e,t,e,t-ha(t,a),!1,a).length,Zo("D",c))}function Bh(e,t,s,n){let a=e-ha(e,s),c=t-ha(t,s),h=Math.abs(a-c)-AM(e,t,s);return Xo(h,Zo(F1(e,t),n))}function OM(e,t,s,n,a,c){let h;Bh(t,n,a,c).length>0?h=n-ha(n,a):h=t;let d=n,f=RM(e,t,s,n,a,c);return Xo(I1(e,h,s,d,f==="C",a).length,Zo(f,c))}function AM(e,t,s){var h;let n=0,a=e-ha(e,s),c=t-ha(t,s);for(let d=0;d<Math.abs(a-c);d++){let f=F1(e,t)==="A"?-1:1;(h=s.buffer.lines.get(a+f*d))!=null&&h.isWrapped&&n++}return n}function ha(e,t){let s=0,n=t.buffer.lines.get(e),a=n==null?void 0:n.isWrapped;for(;a&&e>=0&&e<t.rows;)s++,n=t.buffer.lines.get(--e),a=n==null?void 0:n.isWrapped;return s}function RM(e,t,s,n,a,c){let h;return Bh(s,n,a,c).length>0?h=n-ha(n,a):h=t,e<s&&h<=n||e>=s&&h<n?"C":"D"}function F1(e,t){return e>t?"A":"B"}function I1(e,t,s,n,a,c){let h=e,d=t,f="";for(;(h!==s||d!==n)&&d>=0&&d<c.buffer.lines.length;)h+=a?1:-1,a&&h>c.cols-1?(f+=c.buffer.translateBufferLineToString(d,!1,e,h),h=0,e=0,d++):!a&&h<0&&(f+=c.buffer.translateBufferLineToString(d,!1,0,e+1),h=c.cols-1,e=h,d--);return f+c.buffer.translateBufferLineToString(d,!1,e,h)}function Zo(e,t){let s=t?"O":"[";return ne.ESC+s+e}function Xo(e,t){e=Math.floor(e);let s="";for(let n=0;n<e;n++)s+=t;return s}var DM=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function ES(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var xm=50,MM=15,BM=50,LM=500,qM=" ",zM=new RegExp(qM,"g"),Up=class extends Ie{constructor(e,t,s,n,a,c,h,d,f){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=n,this._coreService=a,this._mouseService=c,this._optionsService=h,this._renderService=d,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new di,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new fe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new fe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new fe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new fe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=m=>this._handleMouseMove(m),this._mouseUpListener=m=>this._handleMouseUp(m),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(m=>this._handleTrim(m)),this._register(this._bufferService.buffers.onBufferActivate(m=>this._handleBufferActivate(m))),this.enable(),this._model=new DM(this._bufferService),this._activeSelectionMode=0,this._register(vt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(m=>{m.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let h=e[1];h<=t[1];h++){let d=s.translateBufferLineToString(h,!0,a,c);n.push(d)}}else{let a=e[1]===t[1]?t[0]:void 0;n.push(s.translateBufferLineToString(e[1],!0,e[0],a));for(let c=e[1]+1;c<=t[1]-1;c++){let h=s.lines.get(c),d=s.translateBufferLineToString(c,!0);h!=null&&h.isWrapped?n[n.length-1]+=d:n.push(d)}if(e[1]!==t[1]){let c=s.lines.get(t[1]),h=s.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?n[n.length-1]+=h:n.push(h)}}return n.map(a=>a.replace(zM," ")).join(z1?`\r
83
+ `:`
84
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),F_&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n||!t?!1:this._areCoordsInSelection(t,s,n)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!s||!n?!1:this._areCoordsInSelection([e,t],s,n)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var a,c;let s=(c=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:c.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=ES(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return n?(this._selectWordAt(n,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=H_(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-xm),xm),t/=xm,t/Math.abs(t)+Math.round(t*(MM-1)))}shouldForceSelection(e){return kh?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),BM)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(kh&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let n=s.lines.get(this._model.selectionEnd[1]);n&&n.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<LM&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let n=kM(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let n=0;t>=n;n++){let a=e.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:a>1&&t!==n&&(s+=a-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,n=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,c=a.lines.get(e[1]);if(!c)return;let h=a.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(c,e[0]),f=d,m=e[0]-d,g=0,v=0,b=0,S=0;if(h.charAt(d)===" "){for(;d>0&&h.charAt(d-1)===" ";)d--;for(;f<h.length&&h.charAt(f+1)===" ";)f++}else{let k=e[0],N=e[0];c.getWidth(k)===0&&(g++,k--),c.getWidth(N)===2&&(v++,N++);let L=c.getString(N).length;for(L>1&&(S+=L-1,f+=L-1);k>0&&d>0&&!this._isCharWordSeparator(c.loadCell(k-1,this._workCell));){c.loadCell(k-1,this._workCell);let R=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,k--):R>1&&(b+=R-1,d-=R-1),d--,k--}for(;N<c.length&&f+1<h.length&&!this._isCharWordSeparator(c.loadCell(N+1,this._workCell));){c.loadCell(N+1,this._workCell);let R=this._workCell.getChars().length;this._workCell.getWidth()===2?(v++,N++):R>1&&(S+=R-1,f+=R-1),f++,N++}}f++;let x=d+m-g+b,w=Math.min(this._bufferService.cols,f-d+g+v-b-S);if(!(!t&&h.slice(d,f).trim()==="")){if(s&&x===0&&c.getCodePoint(0)!==32){let k=a.lines.get(e[1]-1);if(k&&c.isWrapped&&k.getCodePoint(this._bufferService.cols-1)!==32){let N=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(N){let L=this._bufferService.cols-N.start;x-=L,w+=L}}}if(n&&x+w===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let k=a.lines.get(e[1]+1);if(k!=null&&k.isWrapped&&k.getCodePoint(0)!==32){let N=this._getWordAt([0,e[1]+1],!1,!1,!0);N&&(w+=N.length)}}return{start:x,length:w}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=ES(s,this._bufferService.cols)}};Up=Nt([pe(3,bs),pe(4,pa),pe(5,D_),pe(6,Ss),pe(7,br),pe(8,yr)],Up);var TS=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},OS=class{constructor(){this._color=new TS,this._css=new TS}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ft=Object.freeze((()=>{let e=[bt.toColor("#2e3436"),bt.toColor("#cc0000"),bt.toColor("#4e9a06"),bt.toColor("#c4a000"),bt.toColor("#3465a4"),bt.toColor("#75507b"),bt.toColor("#06989a"),bt.toColor("#d3d7cf"),bt.toColor("#555753"),bt.toColor("#ef2929"),bt.toColor("#8ae234"),bt.toColor("#fce94f"),bt.toColor("#729fcf"),bt.toColor("#ad7fa8"),bt.toColor("#34e2e2"),bt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let n=t[s/36%6|0],a=t[s/6%6|0],c=t[s%6];e.push({css:Pt.toCss(n,a,c),rgba:Pt.toRgba(n,a,c)})}for(let s=0;s<24;s++){let n=8+s*10;e.push({css:Pt.toCss(n,n,n),rgba:Pt.toRgba(n,n,n)})}return e})()),In=bt.toColor("#ffffff"),Lo=bt.toColor("#000000"),AS=bt.toColor("#ffffff"),RS=Lo,Eo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},PM=In,Kp=class extends Ie{constructor(e){super(),this._optionsService=e,this._contrastCache=new OS,this._halfContrastCache=new OS,this._onChangeColors=this._register(new fe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:In,background:Lo,cursor:AS,cursorAccent:RS,selectionForeground:void 0,selectionBackgroundTransparent:Eo,selectionBackgroundOpaque:_t.blend(Lo,Eo),selectionInactiveBackgroundTransparent:Eo,selectionInactiveBackgroundOpaque:_t.blend(Lo,Eo),scrollbarSliderBackground:_t.opacity(In,.2),scrollbarSliderHoverBackground:_t.opacity(In,.4),scrollbarSliderActiveBackground:_t.opacity(In,.5),overviewRulerBorder:In,ansi:Ft.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=ht(e.foreground,In),t.background=ht(e.background,Lo),t.cursor=_t.blend(t.background,ht(e.cursor,AS)),t.cursorAccent=_t.blend(t.background,ht(e.cursorAccent,RS)),t.selectionBackgroundTransparent=ht(e.selectionBackground,Eo),t.selectionBackgroundOpaque=_t.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ht(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=_t.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ht(e.selectionForeground,jS):void 0,t.selectionForeground===jS&&(t.selectionForeground=void 0),_t.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=_t.opacity(t.selectionBackgroundTransparent,.3)),_t.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=_t.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ht(e.scrollbarSliderBackground,_t.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ht(e.scrollbarSliderHoverBackground,_t.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ht(e.scrollbarSliderActiveBackground,_t.opacity(t.foreground,.5)),t.overviewRulerBorder=ht(e.overviewRulerBorder,PM),t.ansi=Ft.slice(),t.ansi[0]=ht(e.black,Ft[0]),t.ansi[1]=ht(e.red,Ft[1]),t.ansi[2]=ht(e.green,Ft[2]),t.ansi[3]=ht(e.yellow,Ft[3]),t.ansi[4]=ht(e.blue,Ft[4]),t.ansi[5]=ht(e.magenta,Ft[5]),t.ansi[6]=ht(e.cyan,Ft[6]),t.ansi[7]=ht(e.white,Ft[7]),t.ansi[8]=ht(e.brightBlack,Ft[8]),t.ansi[9]=ht(e.brightRed,Ft[9]),t.ansi[10]=ht(e.brightGreen,Ft[10]),t.ansi[11]=ht(e.brightYellow,Ft[11]),t.ansi[12]=ht(e.brightBlue,Ft[12]),t.ansi[13]=ht(e.brightMagenta,Ft[13]),t.ansi[14]=ht(e.brightCyan,Ft[14]),t.ansi[15]=ht(e.brightWhite,Ft[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let n=0;n<s;n++)t.ansi[n+16]=ht(e.extendedAnsi[n],Ft[n+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Kp=Nt([pe(0,Ss)],Kp);function ht(e,t){if(e!==void 0)try{return bt.toColor(e)}catch{}return t}var HM=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},FM=class{constructor(){this._services=new HM,this._services.set(R_,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=MR(e).sort((c,h)=>c.index-h.index),n=[];for(let c of s){let h=this._services.get(c.id);if(!h)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);n.push(h)}let a=s.length>0?s[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...n)}},IM={trace:0,debug:1,info:2,warn:3,error:4,off:5},UM="xterm.js: ",$p=class extends Ie{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=IM[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":UM)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};$p=Nt([pe(0,Ss)],$p);var DS=class extends Ie{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new fe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new fe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new fe),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new 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(e,t,...s){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+s.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<s.length;n++)this._array[this._getCyclicIndex(e+n)]=s[n];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let n=this._length+s.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let a=t-1;a>=0;a--)this.set(e+a+s,this.get(e+a));let n=e+t+s-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<t;n++)this.set(e+n+s,this.get(e+n))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Pe=3,qt=Object.freeze(new dc),Gu=0,wm=2,qo=class U1{constructor(t,s,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Pe);let a=s||di.fromCharData([0,o1,1,0]);for(let c=0;c<t;++c)this.setCell(c,a);this.length=t}get(t){let s=this._data[t*Pe+0],n=s&2097151;return[this._data[t*Pe+1],s&2097152?this._combined[t]:n?Xr(n):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n]}set(t,s){this._data[t*Pe+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*Pe+0]=t|2097152|s[2]<<22):this._data[t*Pe+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*Pe+0]>>22}hasWidth(t){return this._data[t*Pe+0]&12582912}getFg(t){return this._data[t*Pe+1]}getBg(t){return this._data[t*Pe+2]}hasContent(t){return this._data[t*Pe+0]&4194303}getCodePoint(t){let s=this._data[t*Pe+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*Pe+0]&2097152}getString(t){let s=this._data[t*Pe+0];return s&2097152?this._combined[t]:s&2097151?Xr(s&2097151):""}isProtected(t){return this._data[t*Pe+2]&536870912}loadCell(t,s){return Gu=t*Pe,s.content=this._data[Gu+0],s.fg=this._data[Gu+1],s.bg=this._data[Gu+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*Pe+0]=s.content,this._data[t*Pe+1]=s.fg,this._data[t*Pe+2]=s.bg}setCellFromCodepoint(t,s,n,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*Pe+0]=s|n<<22,this._data[t*Pe+1]=a.fg,this._data[t*Pe+2]=a.bg}addCodepointToCell(t,s,n){let a=this._data[t*Pe+0];a&2097152?this._combined[t]+=Xr(s):a&2097151?(this._combined[t]=Xr(a&2097151)+Xr(s),a&=-2097152,a|=2097152):a=s|1<<22,n&&(a&=-12582913,a|=n<<22),this._data[t*Pe+0]=a}insertCells(t,s,n){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),s<this.length-t){let a=new di;for(let c=this.length-t-s-1;c>=0;--c)this.setCell(t+s+c,this.loadCell(t+c,a));for(let c=0;c<s;++c)this.setCell(t+c,n)}else for(let a=t;a<this.length;++a)this.setCell(a,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(t,s,n){if(t%=this.length,s<this.length-t){let a=new di;for(let c=0;c<this.length-t-s;++c)this.setCell(t+c,this.loadCell(t+s+c,a));for(let c=this.length-s;c<this.length;++c)this.setCell(c,n)}else for(let a=t;a<this.length;++a)this.setCell(a,n);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,n)}replaceCells(t,s,n,a=!1){if(a){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,n);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,n),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,n),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,n);t<s&&t<this.length;)this.setCell(t++,n)}resize(t,s){if(t===this.length)return this._data.length*4*wm<this._data.buffer.byteLength;let n=t*Pe;if(t>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let a=new Uint32Array(n);a.set(this._data),this._data=a}for(let a=this.length;a<t;++a)this.setCell(a,s)}else{this._data=this._data.subarray(0,n);let a=Object.keys(this._combined);for(let h=0;h<a.length;h++){let d=parseInt(a[h],10);d>=t&&delete this._combined[d]}let c=Object.keys(this._extendedAttrs);for(let h=0;h<c.length;h++){let d=parseInt(c[h],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,n*4*wm<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*wm<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,t);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new U1(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Pe+0]&4194303)return t+(this._data[t*Pe+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Pe+0]&4194303||this._data[t*Pe+2]&50331648)return t+(this._data[t*Pe+0]>>22);return 0}copyCellsFrom(t,s,n,a,c){let h=t._data;if(c)for(let f=a-1;f>=0;f--){for(let m=0;m<Pe;m++)this._data[(n+f)*Pe+m]=h[(s+f)*Pe+m];h[(s+f)*Pe+2]&268435456&&(this._extendedAttrs[n+f]=t._extendedAttrs[s+f])}else for(let f=0;f<a;f++){for(let m=0;m<Pe;m++)this._data[(n+f)*Pe+m]=h[(s+f)*Pe+m];h[(s+f)*Pe+2]&268435456&&(this._extendedAttrs[n+f]=t._extendedAttrs[s+f])}let d=Object.keys(t._combined);for(let f=0;f<d.length;f++){let m=parseInt(d[f],10);m>=s&&(this._combined[m-s+n]=t._combined[m])}}translateToString(t,s,n,a){s=s??0,n=n??this.length,t&&(n=Math.min(n,this.getTrimmedLength())),a&&(a.length=0);let c="";for(;s<n;){let h=this._data[s*Pe+0],d=h&2097151,f=h&2097152?this._combined[s]:d?Xr(d):mn;if(c+=f,a)for(let m=0;m<f.length;++m)a.push(s);s+=h>>22||1}return a&&a.push(s),c}};function KM(e,t,s,n,a,c){let h=[];for(let d=0;d<e.length-1;d++){let f=d,m=e.get(++f);if(!m.isWrapped)continue;let g=[e.get(d)];for(;f<e.length&&m.isWrapped;)g.push(m),m=e.get(++f);if(!c&&n>=d&&n<f){d+=g.length-1;continue}let v=0,b=Jo(g,v,t),S=1,x=0;for(;S<g.length;){let k=Jo(g,S,t),N=k-x,L=s-b,R=Math.min(N,L);g[v].copyCellsFrom(g[S],x,b,R,!1),b+=R,b===s&&(v++,b=0),x+=R,x===k&&(S++,x=0),b===0&&v!==0&&g[v-1].getWidth(s-1)===2&&(g[v].copyCellsFrom(g[v-1],s-1,b++,1,!1),g[v-1].setCell(s-1,a))}g[v].replaceCells(b,s,a);let w=0;for(let k=g.length-1;k>0&&(k>v||g[k].getTrimmedLength()===0);k--)w++;w>0&&(h.push(d+g.length-w),h.push(w)),d+=g.length-1}return h}function $M(e,t){let s=[],n=0,a=t[n],c=0;for(let h=0;h<e.length;h++)if(a===h){let d=t[++n];e.onDeleteEmitter.fire({index:h-c,amount:d}),h+=d-1,c+=d,a=t[++n]}else s.push(h);return{layout:s,countRemoved:c}}function WM(e,t){let s=[];for(let n=0;n<t.length;n++)s.push(e.get(t[n]));for(let n=0;n<s.length;n++)e.set(n,s[n]);e.length=t.length}function VM(e,t,s){let n=[],a=e.map((f,m)=>Jo(e,m,t)).reduce((f,m)=>f+m),c=0,h=0,d=0;for(;d<a;){if(a-d<s){n.push(a-d);break}c+=s;let f=Jo(e,h,t);c>f&&(c-=f,h++);let m=e[h].getWidth(c-1)===2;m&&c--;let g=m?s-1:s;n.push(g),d+=g}return n}function Jo(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let n=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,a=e[t+1].getWidth(0)===2;return n&&a?s-1:s}var K1=class $1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=$1._nextId++,this._onDispose=this.register(new fe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ua(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};K1._nextId=1;var YM=K1,Wt={},Un=Wt.B;Wt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Wt.A={"#":"£"};Wt.B=void 0;Wt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Wt.C=Wt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Wt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Wt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Wt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Wt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Wt.E=Wt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Wt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Wt.H=Wt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Wt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var MS=4294967295,BS=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=qt.clone(),this.savedCharset=Un,this.markers=[],this._nullCell=di.fromCharData([0,o1,1,0]),this._whitespaceCell=di.fromCharData([0,mn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Nh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new DS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new wh),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new wh),this._whitespaceCell}getBlankLine(e,t){return new qo(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>MS?MS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=qt);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new DS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(qt),n=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols<e)for(let h=0;h<this.lines.length;h++)n+=+this.lines.get(h).resize(e,s);let c=0;if(this._rows<t)for(let h=this._rows;h<t;h++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new qo(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new qo(e,s)));else for(let h=this._rows;h>t;h--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a<this.lines.maxLength){let h=this.lines.length-a;h>0&&(this.lines.trimStart(h),this.ybase=Math.max(this.ybase-h,0),this.ydisp=Math.max(this.ydisp-h,0),this.savedY=Math.max(this.savedY-h,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)n+=+this.lines.get(c).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,n=KM(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(qt),s);if(n.length>0){let a=$M(this.lines,n);WM(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let n=this.getNullCell(qt),a=s;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new qo(e,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(qt),a=[],c=0;for(let h=this.lines.length-1;h>=0;h--){let d=this.lines.get(h);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let f=[d];for(;d.isWrapped&&h>0;)d=this.lines.get(--h),f.unshift(d);if(!s){let R=this.ybase+this.y;if(R>=h&&R<h+f.length)continue}let m=f[f.length-1].getTrimmedLength(),g=VM(f,this._cols,e),v=g.length-f.length,b;this.ybase===0&&this.y!==this.lines.length-1?b=Math.max(0,this.y-this.lines.maxLength+v):b=Math.max(0,this.lines.length-this.lines.maxLength+v);let S=[];for(let R=0;R<v;R++){let D=this.getBlankLine(qt,!0);S.push(D)}S.length>0&&(a.push({start:h+f.length+c,newLines:S}),c+=S.length),f.push(...S);let x=g.length-1,w=g[x];w===0&&(x--,w=g[x]);let k=f.length-v-1,N=m;for(;k>=0;){let R=Math.min(N,w);if(f[x]===void 0)break;if(f[x].copyCellsFrom(f[k],N-R,w-R,R,!0),w-=R,w===0&&(x--,w=g[x]),N-=R,N===0){k--;let D=Math.max(k,0);N=Jo(f,D,this._cols)}}for(let R=0;R<f.length;R++)g[R]<e&&f[R].setCell(g[R],n);let L=v-b;for(;L-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+v,this.ybase+t-1)}if(a.length>0){let h=[],d=[];for(let w=0;w<this.lines.length;w++)d.push(this.lines.get(w));let f=this.lines.length,m=f-1,g=0,v=a[g];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let b=0;for(let w=Math.min(this.lines.maxLength-1,f+c-1);w>=0;w--)if(v&&v.start>m+b){for(let k=v.newLines.length-1;k>=0;k--)this.lines.set(w--,v.newLines[k]);w++,h.push({index:m+1,amount:v.newLines.length}),b+=v.newLines.length,v=a[++g]}else this.lines.set(w,d[m--]);let S=0;for(let w=h.length-1;w>=0;w--)h[w].index+=S,this.lines.onInsertEmitter.fire(h[w]),S+=h[w].amount;let x=Math.max(0,f+c-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,t,s=0,n){let a=this.lines.get(e);return a?a.translateToString(t,s,n):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new YM(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},GM=class extends Ie{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new fe),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 BS(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new BS(!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(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),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(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},W1=2,V1=1,Wp=class extends Ie{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new fe),this.onResize=this._onResize.event,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,W1),this.rows=Math.max(e.rawOptions.rows||0,V1),this.buffers=this._register(new GM(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,n=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==e.fg||n.getBg(0)!==e.bg)&&(n=s.getBlankLine(e,t),this._cachedBlankLine=n),n.isWrapped=t;let a=s.ybase+s.scrollTop,c=s.ybase+s.scrollBottom;if(s.scrollTop===0){let h=s.lines.isFull;c===s.lines.length-1?h?s.lines.recycle().copyFrom(n):s.lines.push(n.clone()):s.lines.splice(c+1,0,n.clone()),h?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let h=c-a+1;s.lines.shiftElements(a+1,h-1,-1),s.lines.set(c,n.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let n=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),n!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Wp=Nt([pe(0,Ss)],Wp);var sl={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:1e3,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:kh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},QM=["normal","bold","100","200","300","400","500","600","700","800","900"],ZM=class extends Ie{constructor(e){super(),this._onOptionChange=this._register(new fe),this.onOptionChange=this._onOptionChange.event;let t={...sl};for(let s in e)if(s in t)try{let n=e[s];t[s]=this._sanitizeAndValidateOption(s,n)}catch(n){console.error(n)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(vt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in sl))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,n)=>{if(!(s in sl))throw new Error(`No option with key "${s}"`);n=this._sanitizeAndValidateOption(s,n),this.rawOptions[s]!==n&&(this.rawOptions[s]=n,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let n={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,n)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=sl[e]),!XM(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=sl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=QM.includes(t)?t:sl[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function XM(e){return e==="block"||e==="underline"||e==="bar"}function zo(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let n in e)s[n]=t<=1?e[n]:e[n]&&zo(e[n],t-1);return s}var LS=Object.freeze({insertMode:!1}),qS=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Vp=class extends Ie{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new fe),this.onData=this._onData.event,this._onUserInput=this._register(new fe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new fe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new fe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=zo(LS),this.decPrivateModes=zo(qS)}reset(){this.modes=zo(LS),this.decPrivateModes=zo(qS)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(n=>n.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Vp=Nt([pe(0,bs),pe(1,f1),pe(2,Ss)],Vp);var zS={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Cm(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var jm=String.fromCharCode,PS={DEFAULT:e=>{let t=[Cm(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${jm(t[0])}${jm(t[1])}${jm(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Cm(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Cm(e,!0)};${e.x};${e.y}${t}`}},Yp=class extends Ie{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new fe),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(zS))this.addProtocol(n,zS[n]);for(let n of Object.keys(PS))this.addEncoding(n,PS[n]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let n=t/s,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=n+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Yp=Nt([pe(0,bs),pe(1,pa),pe(2,Ss)],Yp);var km=[[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]],JM=[[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]],It;function e3(e,t){let s=0,n=t.length-1,a;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=s;)if(a=s+n>>1,e>t[a][1])s=a+1;else if(e<t[a][0])n=a-1;else return!0;return!1}var t3=class{constructor(){if(this.version="6",!It){It=new Uint8Array(65536),It.fill(1),It[0]=0,It.fill(0,1,32),It.fill(0,127,160),It.fill(2,4352,4448),It[9001]=2,It[9002]=2,It.fill(2,11904,42192),It[12351]=1,It.fill(2,44032,55204),It.fill(2,63744,64256),It.fill(2,65040,65050),It.fill(2,65072,65136),It.fill(2,65280,65377),It.fill(2,65504,65511);for(let e=0;e<km.length;++e)It.fill(0,km[e][0],km[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?It[e]:e3(e,JM)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),n=s===0&&t!==0;if(n){let a=$n.extractWidth(t);a===0?n=!1:a>s&&(s=a)}return $n.createPropertyValue(0,s,n)}},$n=class oh{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new fe,this.onChange=this._onChange.event;let t=new t3;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,n=!1){return(t&16777215)<<3|(s&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,n=0,a=t.length;for(let c=0;c<a;++c){let h=t.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=a)return s+this.wcwidth(h);let m=t.charCodeAt(c);56320<=m&&m<=57343?h=(h-55296)*1024+m-56320+65536:s+=this.wcwidth(m)}let d=this.charProperties(h,n),f=oh.extractWidth(d);oh.extractShouldJoin(d)&&(f-=oh.extractWidth(n)),s+=f,n=d}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},s3=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function HS(e){var n;let t=(n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:n.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var To=2147483647,i3=256,Y1=class Gp{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>i3)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Gp;if(!t.length)return s;for(let n=Array.isArray(t[0])?1:0;n<t.length;++n){let a=t[n];if(Array.isArray(a))for(let c=0;c<a.length;++c)s.addSubParam(a[c]);else s.addParam(a)}return s}clone(){let t=new Gp(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let n=this._subParamsIdx[s]>>8,a=this._subParamsIdx[s]&255;a-n>0&&t.push(Array.prototype.slice.call(this._subParams,n,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>To?To:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>To?To:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,n=this._subParamsIdx[t]&255;return n-s>0?this._subParams.subarray(s,n):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let n=this._subParamsIdx[s]>>8,a=this._subParamsIdx[s]&255;a-n>0&&(t[s]=this._subParams.slice(n,a))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,a=n[s-1];n[s-1]=~a?Math.min(a*10+t,To):t}},Oo=[],r3=class{constructor(){this._state=0,this._active=Oo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let n=s.indexOf(t);n!==-1&&s.splice(n,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Oo}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Oo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Oo,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Rh(e,t,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,n=this._active.length-1,a=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&s===!1){for(;n>=0&&(s=this._active[n].end(e),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=Oo,this._id=-1,this._state=0}}},$s=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Rh(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Ao=[],n3=class{constructor(){this._handlers=Object.create(null),this._active=Ao,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ao}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let n=s.indexOf(t);n!==-1&&s.splice(n,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Ao,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ao,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Rh(e,t,s));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,n=this._active.length-1,a=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,s=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&s===!1){for(;n>=0&&(s=this._active[n].unhook(e),s!==!0);n--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,s;n--}for(;n>=0;n--)if(s=this._active[n].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,s}this._active=Ao,this._ident=0}},Po=new Y1;Po.addParam(0);var FS=class{constructor(e){this._handler=e,this._data="",this._params=Po,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Po,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Rh(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=Po,this._data="",this._hitLimit=!1,s));return this._params=Po,this._data="",this._hitLimit=!1,t}},a3=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,n){this.table[t<<8|e]=s<<4|n}addMany(e,t,s,n){for(let a=0;a<e.length;a++)this.table[t<<8|e[a]]=s<<4|n}},hi=160,l3=(function(){let e=new a3(4095),t=Array.apply(null,Array(256)).map((d,f)=>f),s=(d,f)=>t.slice(d,f),n=s(32,127),a=s(0,24);a.push(25),a.push.apply(a,s(28,32));let c=s(0,14),h;e.setDefault(1,0),e.addMany(n,0,2,0);for(h in c)e.addMany([24,26,153,154],h,3,0),e.addMany(s(128,144),h,3,0),e.addMany(s(144,152),h,3,0),e.add(156,h,0,0),e.add(27,h,11,1),e.add(157,h,4,8),e.addMany([152,158,159],h,0,7),e.add(155,h,11,3),e.add(144,h,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(n,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(n,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(n,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(hi,0,2,0),e.add(hi,8,5,8),e.add(hi,6,0,6),e.add(hi,11,0,11),e.add(hi,13,13,13),e})(),o3=class extends Ie{constructor(e=l3){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Y1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,n)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(vt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new r3),this._dcsParser=this._register(new n3),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;a<e.intermediates.length;++a){let c=e.intermediates.charCodeAt(a);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let n=e.final.charCodeAt(0);if(t[0]>n||n>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=n,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let n=this._escHandlers[s];return n.push(t),{dispose:()=>{let a=n.indexOf(t);a!==-1&&n.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let n=this._csiHandlers[s];return n.push(t),{dispose:()=>{let a=n.indexOf(t);a!==-1&&n.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}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(e,t,s,n,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=n,this._parseStack.chunkPos=a}parse(e,t,s){let n=0,a=0,c=0,h;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&f>-1){for(;f>=0&&(h=d[f](this._params),h!==!0);f--)if(h instanceof Promise)return this._parseStack.handlerPos=f,h}this._parseStack.handlers=[];break;case 4:if(s===!1&&f>-1){for(;f>=0&&(h=d[f](),h!==!0);f--)if(h instanceof Promise)return this._parseStack.handlerPos=f,h}this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],h=this._dcsParser.unhook(n!==24&&n!==26,s),h)return h;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],h=this._oscParser.end(n!==24&&n!==26,s),h)return h;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=c;d<t;++d){switch(n=e[d],a=this._transitions.table[this.currentState<<8|(n<160?n:hi)],a>>4){case 2:for(let b=d+1;;++b){if(b>=t||(n=e[b])<32||n>126&&n<hi){this._printHandler(e,d,b),d=b-1;break}if(++b>=t||(n=e[b])<32||n>126&&n<hi){this._printHandler(e,d,b),d=b-1;break}if(++b>=t||(n=e[b])<32||n>126&&n<hi){this._printHandler(e,d,b),d=b-1;break}if(++b>=t||(n=e[b])<32||n>126&&n<hi){this._printHandler(e,d,b),d=b-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:d,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|n],m=f?f.length-1:-1;for(;m>=0&&(h=f[m](this._params),h!==!0);m--)if(h instanceof Promise)return this._preserveStack(3,f,m,a,d),h;m<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(n-48)}while(++d<t&&(n=e[d])>47&&n<60);d--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let g=this._escHandlers[this._collect<<8|n],v=g?g.length-1:-1;for(;v>=0&&(h=g[v](),h!==!0);v--)if(h instanceof Promise)return this._preserveStack(4,g,v,a,d),h;v<0&&this._escHandlerFb(this._collect<<8|n),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|n,this._params);break;case 13:for(let b=d+1;;++b)if(b>=t||(n=e[b])===24||n===26||n===27||n>127&&n<hi){this._dcsParser.put(e,d,b),d=b-1;break}break;case 14:if(h=this._dcsParser.unhook(n!==24&&n!==26),h)return this._preserveStack(6,[],0,a,d),h;n===27&&(a|=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 b=d+1;;b++)if(b>=t||(n=e[b])<32||n>127&&n<hi){this._oscParser.put(e,d,b),d=b-1;break}break;case 6:if(h=this._oscParser.end(n!==24&&n!==26),h)return this._preserveStack(5,[],0,a,d),h;n===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=a&15}}},c3=/^([\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})$/,u3=/^[\da-f]+$/;function IS(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=c3.exec(t);if(s){let n=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/n*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/n*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/n*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),u3.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,n=[0,0,0];for(let a=0;a<3;++a){let c=parseInt(t.slice(s*a,s*a+s),16);n[a]=s===1?c<<4:s===2?c:s===3?c>>4:c>>8}return n}}function Nm(e,t){let s=e.toString(16),n=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function h3(e,t=16){let[s,n,a]=e;return`rgb:${Nm(s,t)}/${Nm(n,t)}/${Nm(a,t)}`}var d3={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Yr=131072,US=10;function KS(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var $S=5e3,WS=0,f3=class extends Ie{constructor(e,t,s,n,a,c,h,d,f=new o3){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=n,this._optionsService=a,this._oscLinkService=c,this._coreMouseService=h,this._unicodeService=d,this._parser=f,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new RR,this._utf8Decoder=new DR,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=qt.clone(),this._eraseAttrDataInternal=qt.clone(),this._onRequestBell=this._register(new fe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new fe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new fe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new fe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new fe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new fe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new fe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new fe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new fe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new fe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new fe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new fe),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 Qp(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:g.toArray()})}),this._parser.setEscHandlerFallback(m=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(m)})}),this._parser.setExecuteHandlerFallback(m=>{this._logService.debug("Unknown EXECUTE code: ",{code:m})}),this._parser.setOscHandlerFallback((m,g,v)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:g,data:v})}),this._parser.setDcsHandlerFallback((m,g,v)=>{g==="HOOK"&&(v=v.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:g,payload:v})}),this._parser.setPrintHandler((m,g,v)=>this.print(m,g,v)),this._parser.registerCsiHandler({final:"@"},m=>this.insertChars(m)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},m=>this.scrollLeft(m)),this._parser.registerCsiHandler({final:"A"},m=>this.cursorUp(m)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},m=>this.scrollRight(m)),this._parser.registerCsiHandler({final:"B"},m=>this.cursorDown(m)),this._parser.registerCsiHandler({final:"C"},m=>this.cursorForward(m)),this._parser.registerCsiHandler({final:"D"},m=>this.cursorBackward(m)),this._parser.registerCsiHandler({final:"E"},m=>this.cursorNextLine(m)),this._parser.registerCsiHandler({final:"F"},m=>this.cursorPrecedingLine(m)),this._parser.registerCsiHandler({final:"G"},m=>this.cursorCharAbsolute(m)),this._parser.registerCsiHandler({final:"H"},m=>this.cursorPosition(m)),this._parser.registerCsiHandler({final:"I"},m=>this.cursorForwardTab(m)),this._parser.registerCsiHandler({final:"J"},m=>this.eraseInDisplay(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},m=>this.eraseInDisplay(m,!0)),this._parser.registerCsiHandler({final:"K"},m=>this.eraseInLine(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},m=>this.eraseInLine(m,!0)),this._parser.registerCsiHandler({final:"L"},m=>this.insertLines(m)),this._parser.registerCsiHandler({final:"M"},m=>this.deleteLines(m)),this._parser.registerCsiHandler({final:"P"},m=>this.deleteChars(m)),this._parser.registerCsiHandler({final:"S"},m=>this.scrollUp(m)),this._parser.registerCsiHandler({final:"T"},m=>this.scrollDown(m)),this._parser.registerCsiHandler({final:"X"},m=>this.eraseChars(m)),this._parser.registerCsiHandler({final:"Z"},m=>this.cursorBackwardTab(m)),this._parser.registerCsiHandler({final:"`"},m=>this.charPosAbsolute(m)),this._parser.registerCsiHandler({final:"a"},m=>this.hPositionRelative(m)),this._parser.registerCsiHandler({final:"b"},m=>this.repeatPrecedingCharacter(m)),this._parser.registerCsiHandler({final:"c"},m=>this.sendDeviceAttributesPrimary(m)),this._parser.registerCsiHandler({prefix:">",final:"c"},m=>this.sendDeviceAttributesSecondary(m)),this._parser.registerCsiHandler({final:"d"},m=>this.linePosAbsolute(m)),this._parser.registerCsiHandler({final:"e"},m=>this.vPositionRelative(m)),this._parser.registerCsiHandler({final:"f"},m=>this.hVPosition(m)),this._parser.registerCsiHandler({final:"g"},m=>this.tabClear(m)),this._parser.registerCsiHandler({final:"h"},m=>this.setMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"h"},m=>this.setModePrivate(m)),this._parser.registerCsiHandler({final:"l"},m=>this.resetMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"l"},m=>this.resetModePrivate(m)),this._parser.registerCsiHandler({final:"m"},m=>this.charAttributes(m)),this._parser.registerCsiHandler({final:"n"},m=>this.deviceStatus(m)),this._parser.registerCsiHandler({prefix:"?",final:"n"},m=>this.deviceStatusPrivate(m)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},m=>this.softReset(m)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},m=>this.setCursorStyle(m)),this._parser.registerCsiHandler({final:"r"},m=>this.setScrollRegion(m)),this._parser.registerCsiHandler({final:"s"},m=>this.saveCursor(m)),this._parser.registerCsiHandler({final:"t"},m=>this.windowOptions(m)),this._parser.registerCsiHandler({final:"u"},m=>this.restoreCursor(m)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},m=>this.insertColumns(m)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},m=>this.deleteColumns(m)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},m=>this.selectProtected(m)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},m=>this.requestMode(m,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},m=>this.requestMode(m,!1)),this._parser.setExecuteHandler(ne.BEL,()=>this.bell()),this._parser.setExecuteHandler(ne.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ne.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ne.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ne.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ne.BS,()=>this.backspace()),this._parser.setExecuteHandler(ne.HT,()=>this.tab()),this._parser.setExecuteHandler(ne.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ne.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ah.IND,()=>this.index()),this._parser.setExecuteHandler(ah.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ah.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new $s(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new $s(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new $s(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new $s(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new $s(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new $s(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new $s(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new $s(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new $s(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new $s(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new $s(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new $s(m=>this.restoreCursorColor(m))),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 m in Wt)this._parser.registerEscHandler({intermediates:"(",final:m},()=>this.selectCharset("("+m)),this._parser.registerEscHandler({intermediates:")",final:m},()=>this.selectCharset(")"+m)),this._parser.registerEscHandler({intermediates:"*",final:m},()=>this.selectCharset("*"+m)),this._parser.registerEscHandler({intermediates:"+",final:m},()=>this.selectCharset("+"+m)),this._parser.registerEscHandler({intermediates:"-",final:m},()=>this.selectCharset("-"+m)),this._parser.registerEscHandler({intermediates:".",final:m},()=>this.selectCharset("."+m)),this._parser.registerEscHandler({intermediates:"/",final:m},()=>this.selectCharset("/"+m));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(m=>(this._logService.error("Parsing error: ",m),m)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new FS((m,g)=>this.requestStatusString(m,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=n}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),$S))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${$S} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,n=this._activeBuffer.x,a=this._activeBuffer.y,c=0,h=this._parseStack.paused;if(h){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;n=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Yr&&(c=this._parseStack.position+Yr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,m=>String.fromCharCode(m)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(m=>m.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Yr&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Yr))),h||this._dirtyRowTracker.clearRange(),e.length>Yr)for(let m=c;m<e.length;m+=Yr){let g=m+Yr<e.length?m+Yr:e.length,v=typeof e=="string"?this._stringDecoder.decode(e.substring(m,g),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,g),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,v))return this._preserveStack(n,a,v,m),this._logSlowResolvingAsync(s),s}else if(!h){let m=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,m))return this._preserveStack(n,a,m,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==n||this._activeBuffer.y!==a)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),f=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);f<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(f,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,s){let n,a,c=this._charsetService.charset,h=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,f=this._coreService.decPrivateModes.wraparound,m=this._coreService.modes.insertMode,g=this._curAttrData,v=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&v.getWidth(this._activeBuffer.x-1)===2&&v.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let b=this._parser.precedingJoinState;for(let S=t;S<s;++S){if(n=e[S],n<127&&c){let N=c[String.fromCharCode(n)];N&&(n=N.charCodeAt(0))}let x=this._unicodeService.charProperties(n,b);a=$n.extractWidth(x);let w=$n.extractShouldJoin(x),k=w?$n.extractWidth(b):0;if(b=x,h&&this._onA11yChar.fire(Xr(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+a-k>d){if(f){let N=v,L=this._activeBuffer.x-k;for(this._activeBuffer.x=k,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),k>0&&v instanceof qo&&v.copyCellsFrom(N,L,0,k,!1);L<d;)N.setCellFromCodepoint(L++,0,1,g)}else if(this._activeBuffer.x=d-1,a===2)continue}if(w&&this._activeBuffer.x){let N=v.getWidth(this._activeBuffer.x-1)?1:2;v.addCodepointToCell(this._activeBuffer.x-N,n,a);for(let L=a-k;--L>=0;)v.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(m&&(v.insertCells(this._activeBuffer.x,a-k,this._activeBuffer.getNullCell(g)),v.getWidth(d-1)===2&&v.setCellFromCodepoint(d-1,0,1,g)),v.setCellFromCodepoint(this._activeBuffer.x++,n,a,g),a>0)for(;--a;)v.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=b,this._activeBuffer.x<d&&s-t>0&&v.getWidth(this._activeBuffer.x)===0&&!v.hasContent(this._activeBuffer.x)&&v.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>KS(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new FS(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new $s(t))}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(){var e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,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(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,n=!1,a=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),a),n&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var n;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&n.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,a=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;t--;)this._activeBuffer.lines.splice(a-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)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(e){let t=e.params[0]||1;for(;t--;)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(qt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,n=$n.extractWidth(t),a=this._activeBuffer.x-n,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(a),h=new Uint32Array(c.length*s),d=0;for(let m=0;m<c.length;){let g=c.codePointAt(m)||0;h[d++]=g,m+=g>65535?2:1}let f=d;for(let m=1;m<s;++m)h.copyWithin(f,0,d),f+=d;return this.print(h,0,f),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ne.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ne.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ne.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ne.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ne.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Un),this._charsetService.setgCharset(1,Un),this._charsetService.setgCharset(2,Un),this._charsetService.setgCharset(3,Un);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 1e3: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;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){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 1e3: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:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===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);break}return!0}requestMode(e,t){(w=>(w[w.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",w[w.SET=1]="SET",w[w.RESET=2]="RESET",w[w.PERMANENTLY_SET=3]="PERMANENTLY_SET",w[w.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let n=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:c}=this._coreMouseService,h=this._coreService,{buffers:d,cols:f}=this._bufferService,{active:m,alt:g}=d,v=this._optionsService.rawOptions,b=(w,k)=>(h.triggerDataEvent(`${ne.ESC}[${t?"":"?"}${w};${k}$y`),!0),S=w=>w?1:2,x=e.params[0];return t?x===2?b(x,4):x===4?b(x,S(h.modes.insertMode)):x===12?b(x,3):x===20?b(x,S(v.convertEol)):b(x,0):x===1?b(x,S(n.applicationCursorKeys)):x===3?b(x,v.windowOptions.setWinLines?f===80?2:f===132?1:0:0):x===6?b(x,S(n.origin)):x===7?b(x,S(n.wraparound)):x===8?b(x,3):x===9?b(x,S(a==="X10")):x===12?b(x,S(v.cursorBlink)):x===25?b(x,S(!h.isCursorHidden)):x===45?b(x,S(n.reverseWraparound)):x===66?b(x,S(n.applicationKeypad)):x===67?b(x,4):x===1e3?b(x,S(a==="VT200")):x===1002?b(x,S(a==="DRAG")):x===1003?b(x,S(a==="ANY")):x===1004?b(x,S(n.sendFocus)):x===1005?b(x,4):x===1006?b(x,S(c==="SGR")):x===1015?b(x,4):x===1016?b(x,S(c==="SGR_PIXELS")):x===1048?b(x,1):x===47||x===1047||x===1049?b(x,S(m===g)):x===2004?b(x,S(n.bracketedPasteMode)):x===2026?b(x,S(n.synchronizedOutput)):b(x,0)}_updateAttrColor(e,t,s,n,a){return t===2?(e|=50331648,e&=-16777216,e|=dc.fromColorRGB([s,n,a])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let n=[0,0,-1,0,0,0],a=0,c=0;do{if(n[c+a]=e.params[t+c],e.hasSubParams(t+c)){let h=e.getSubParams(t+c),d=0;do n[1]===5&&(a=1),n[c+d+1+a]=h[d];while(++d<h.length&&d+c+1+a<n.length);break}if(n[1]===5&&c+a>=2||n[1]===2&&c+a>=5)break;n[1]&&(a=1)}while(++c+t<e.length&&c+a<n.length);for(let h=2;h<n.length;++h)n[h]===-1&&(n[h]=0);switch(n[0]){case 38:s.fg=this._updateAttrColor(s.fg,n[1],n[3],n[4],n[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,n[1],n[3],n[4],n[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,n[1],n[3],n[4],n[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=qt.fg,e.bg=qt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,n=this._curAttrData;for(let a=0;a<t;a++)s=e.params[a],s>=30&&s<=37?(n.fg&=-50331904,n.fg|=16777216|s-30):s>=40&&s<=47?(n.bg&=-50331904,n.bg|=16777216|s-40):s>=90&&s<=97?(n.fg&=-50331904,n.fg|=16777216|s-90|8):s>=100&&s<=107?(n.bg&=-50331904,n.bg|=16777216|s-100|8):s===0?this._processSGR0(n):s===1?n.fg|=134217728:s===3?n.bg|=67108864:s===4?(n.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,n)):s===5?n.fg|=536870912:s===7?n.fg|=67108864:s===8?n.fg|=1073741824:s===9?n.fg|=2147483648:s===2?n.bg|=134217728:s===21?this._processUnderline(2,n):s===22?(n.fg&=-134217729,n.bg&=-134217729):s===23?n.bg&=-67108865:s===24?(n.fg&=-268435457,this._processUnderline(0,n)):s===25?n.fg&=-536870913:s===27?n.fg&=-67108865:s===28?n.fg&=-1073741825:s===29?n.fg&=2147483647:s===39?(n.fg&=-67108864,n.fg|=qt.fg&16777215):s===49?(n.bg&=-67108864,n.bg|=qt.bg&16777215):s===38||s===48||s===58?a+=this._extractColor(e,a,n):s===53?n.bg|=1073741824:s===55?n.bg&=-1073741825:s===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):s===100?(n.fg&=-67108864,n.fg|=qt.fg&16777215,n.bg&=-67108864,n.bg|=qt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${ne.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ne.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ne.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=qt.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(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){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";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!KS(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${ne.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>US&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>US&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){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(e){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(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let n=s.shift(),a=s.shift();if(/^\d+$/.exec(n)){let c=parseInt(n);if(VS(c))if(a==="?")t.push({type:0,index:c});else{let h=IS(a);h&&t.push({type:1,index:c,color:h})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),n=e.slice(t+1);return n?this._createHyperlink(s,n):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),n,a=s.findIndex(c=>c.startsWith("id="));return a!==-1&&(n=s[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let n=0;n<s.length&&!(t>=this._specialColors.length);++n,++t)if(s[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=IS(s[n]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let n=0;n<s.length;++n)if(/^\d+$/.exec(s[n])){let a=parseInt(s[n]);VS(a)&&t.push({type:2,index:a})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){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,Un),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(d3[e[0]],Wt[e[1]]||Un),!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 e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,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=qt.clone(),this._eraseAttrDataInternal=qt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new di;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,n=this._activeBuffer.lines.get(s);n&&(n.fill(e),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=h=>(this._coreService.triggerDataEvent(`${ne.ESC}${h}${ne.ESC}\\`),!0),n=this._bufferService.buffer,a=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Qp=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(WS=e,e=t,t=WS),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Qp=Nt([pe(0,bs)],Qp);function VS(e){return 0<=e&&e<256}var m3=5e7,YS=12,p3=50,_3=class extends Ie{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new fe),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>m3)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],a=this._action(n,t);if(a){let h=d=>performance.now()-s>=YS?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(s,d);a.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(h);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-s>=YS)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>p3&&(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()}},Zp=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let d=t.addMarker(t.ybase+t.y),f={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(f,d)),this._dataByLinkId.set(f.id,f),f.id}let s=e,n=this._getEntryIdKey(s),a=this._entriesWithId.get(n);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let c=t.addMarker(t.ybase+t.y),h={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(h,c)),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(n=>n.line!==t)){let n=this._bufferService.buffer.addMarker(t);s.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(s,n))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Zp=Nt([pe(0,bs)],Zp);var GS=!1,g3=class extends Ie{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Cl),this._onBinary=this._register(new fe),this.onBinary=this._onBinary.event,this._onData=this._register(new fe),this.onData=this._onData.event,this._onLineFeed=this._register(new fe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new fe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new fe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new fe),this._instantiationService=new FM,this.optionsService=this._register(new ZM(e)),this._instantiationService.setService(Ss,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Wp)),this._instantiationService.setService(bs,this._bufferService),this._logService=this._register(this._instantiationService.createInstance($p)),this._instantiationService.setService(f1,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Vp)),this._instantiationService.setService(pa,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Yp)),this._instantiationService.setService(d1,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance($n)),this._instantiationService.setService(qR,this.unicodeService),this._charsetService=this._instantiationService.createInstance(s3),this._instantiationService.setService(LR,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Zp),this._instantiationService.setService(m1,this._oscLinkService),this._inputHandler=this._register(new f3(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(cs.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(cs.forward(this._bufferService.onResize,this._onResize)),this._register(cs.forward(this.coreService.onData,this._onData)),this._register(cs.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 _3((t,s)=>this._inputHandler.parse(t,s))),this._register(cs.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new fe),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.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(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!GS&&(this._logService.warn("writeSync is unreliable and will be removed soon."),GS=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,W1),t=Math.max(t,V1),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(HS.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(HS(this._bufferService),!1))),this._windowsWrappingHeuristics.value=vt(()=>{for(let t of e)t.dispose()})}}},v3={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function y3(e,t,s,n){var h;let a={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=ne.ESC+"OA":a.key=ne.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=ne.ESC+"OD":a.key=ne.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=ne.ESC+"OC":a.key=ne.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=ne.ESC+"OB":a.key=ne.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":ne.DEL,e.altKey&&(a.key=ne.ESC+a.key);break;case 9:if(e.shiftKey){a.key=ne.ESC+"[Z";break}a.key=ne.HT,a.cancel=!0;break;case 13:a.key=e.altKey?ne.ESC+ne.CR:ne.CR,a.cancel=!0;break;case 27:a.key=ne.ESC,e.altKey&&(a.key=ne.ESC+ne.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;c?a.key=ne.ESC+"[1;"+(c+1)+"D":t?a.key=ne.ESC+"OD":a.key=ne.ESC+"[D";break;case 39:if(e.metaKey)break;c?a.key=ne.ESC+"[1;"+(c+1)+"C":t?a.key=ne.ESC+"OC":a.key=ne.ESC+"[C";break;case 38:if(e.metaKey)break;c?a.key=ne.ESC+"[1;"+(c+1)+"A":t?a.key=ne.ESC+"OA":a.key=ne.ESC+"[A";break;case 40:if(e.metaKey)break;c?a.key=ne.ESC+"[1;"+(c+1)+"B":t?a.key=ne.ESC+"OB":a.key=ne.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=ne.ESC+"[2~");break;case 46:c?a.key=ne.ESC+"[3;"+(c+1)+"~":a.key=ne.ESC+"[3~";break;case 36:c?a.key=ne.ESC+"[1;"+(c+1)+"H":t?a.key=ne.ESC+"OH":a.key=ne.ESC+"[H";break;case 35:c?a.key=ne.ESC+"[1;"+(c+1)+"F":t?a.key=ne.ESC+"OF":a.key=ne.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=ne.ESC+"[5;"+(c+1)+"~":a.key=ne.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=ne.ESC+"[6;"+(c+1)+"~":a.key=ne.ESC+"[6~";break;case 112:c?a.key=ne.ESC+"[1;"+(c+1)+"P":a.key=ne.ESC+"OP";break;case 113:c?a.key=ne.ESC+"[1;"+(c+1)+"Q":a.key=ne.ESC+"OQ";break;case 114:c?a.key=ne.ESC+"[1;"+(c+1)+"R":a.key=ne.ESC+"OR";break;case 115:c?a.key=ne.ESC+"[1;"+(c+1)+"S":a.key=ne.ESC+"OS";break;case 116:c?a.key=ne.ESC+"[15;"+(c+1)+"~":a.key=ne.ESC+"[15~";break;case 117:c?a.key=ne.ESC+"[17;"+(c+1)+"~":a.key=ne.ESC+"[17~";break;case 118:c?a.key=ne.ESC+"[18;"+(c+1)+"~":a.key=ne.ESC+"[18~";break;case 119:c?a.key=ne.ESC+"[19;"+(c+1)+"~":a.key=ne.ESC+"[19~";break;case 120:c?a.key=ne.ESC+"[20;"+(c+1)+"~":a.key=ne.ESC+"[20~";break;case 121:c?a.key=ne.ESC+"[21;"+(c+1)+"~":a.key=ne.ESC+"[21~";break;case 122:c?a.key=ne.ESC+"[23;"+(c+1)+"~":a.key=ne.ESC+"[23~";break;case 123:c?a.key=ne.ESC+"[24;"+(c+1)+"~":a.key=ne.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=ne.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=ne.DEL:e.keyCode===219?a.key=ne.ESC:e.keyCode===220?a.key=ne.FS:e.keyCode===221&&(a.key=ne.GS);else if((!s||n)&&e.altKey&&!e.metaKey){let d=(h=v3[e.keyCode])==null?void 0:h[e.shiftKey?1:0];if(d)a.key=ne.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,m=String.fromCharCode(f);e.shiftKey&&(m=m.toUpperCase()),a.key=ne.ESC+m}else if(e.keyCode===32)a.key=ne.ESC+(e.ctrlKey?ne.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),a.key=ne.ESC+f,a.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=ne.US),e.key==="@"&&(a.key=ne.NUL));break}return a}var Ot=0,b3=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Nh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Nh,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,c)=>this._getKey(a)-this._getKey(c)),t=0,s=0,n=new Array(this._array.length+this._insertedValues.length);for(let a=0;a<n.length;a++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(n[a]=e[t],t++):n[a]=this._array[s++];this._array=n,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Ot=this._search(t),Ot===-1)||this._getKey(this._array[Ot])!==t)return!1;do if(this._array[Ot]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ot),!0;while(++Ot<this._array.length&&this._getKey(this._array[Ot])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((a,c)=>a-c),t=0,s=new Array(this._array.length-e.length),n=0;for(let a=0;a<this._array.length;a++)e[t]===a?t++:s[n++]=this._array[a];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ot=this._search(e),!(Ot<0||Ot>=this._array.length)&&this._getKey(this._array[Ot])===e))do yield this._array[Ot];while(++Ot<this._array.length&&this._getKey(this._array[Ot])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ot=this._search(e),!(Ot<0||Ot>=this._array.length)&&this._getKey(this._array[Ot])===e))do t(this._array[Ot]);while(++Ot<this._array.length&&this._getKey(this._array[Ot])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let n=t+s>>1,a=this._getKey(this._array[n]);if(a>e)s=n-1;else if(a<e)t=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===e;)n--;return n}}return t}},Em=0,QS=0,S3=class extends Ie{constructor(){super(),this._decorations=new b3(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new fe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new fe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(vt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new x3(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let n=0,a=0;for(let c of this._decorations.getKeyIterator(t))n=c.options.x??0,a=n+(c.options.width??1),e>=n&&e<a&&(!s||(c.options.layer??"bottom")===s)&&(yield c)}forEachDecorationAtCell(e,t,s,n){this._decorations.forEachByKey(t,a=>{Em=a.options.x??0,QS=Em+(a.options.width??1),e>=Em&&e<QS&&(!s||(a.options.layer??"bottom")===s)&&n(a)})}},x3=class extends _n{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new fe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new fe),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=bt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=bt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},w3=1e3,C3=class{constructor(e,t=w3){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=n-this._lastRefreshMs,c=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},ZS=20,Eh=class extends Ie{constructor(e,t,s,n){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new C3(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(c=>this._handleResize(c.rows))),this._register(this._terminal.onRender(c=>this._refreshRows(c.start,c.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(c=>this._handleChar(c))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
85
+ `))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Oe(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(vt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<ZS+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
86
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===ZS+1&&(this._liveRegion.textContent+=gp.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,n=s.lines.length.toString();for(let a=e;a<=t;a++){let c=s.lines.get(s.ydisp+a),h=[],d=(c==null?void 0:c.translateToString(!0,void 0,void 0,h))||"",f=(s.ydisp+a+1).toString(),m=this._rowElements[a];m&&(d.length===0?(m.textContent=" ",this._rowColumns.set(m,[0,1])):(m.textContent=d,this._rowColumns.set(m,h)),m.setAttribute("aria-posinset",f),m.setAttribute("aria-setsize",n),this._alignRowWidth(m))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,n=this._rowElements[t===0?1:this._rowElements.length-2],a=s.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===c||e.relatedTarget!==n)return;let h,d;if(t===0?(h=s,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(h=this._rowElements.shift(),d=s,this._rowContainer.removeChild(h)),h.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let f=this._createAccessibilityTreeNode();this._rowElements.unshift(f),this._rowContainer.insertAdjacentElement("afterbegin",f)}else{let f=this._createAccessibilityTreeNode();this._rowElements.push(f),this._rowContainer.appendChild(f)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var d;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let n=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:n,offset:((d=n.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(s.node))return;let a=({node:f,offset:m})=>{let g=f instanceof Text?f.parentNode:f,v=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(v))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(g);if(!b)return console.warn("columns is null. Race condition?"),null;let S=m<b.length?b[m]:b.slice(-1)[0]+1;return S>=this._terminal.cols&&(++v,S=0),{row:v,column:S}},c=a(t),h=a(s);if(!(!c||!h)){if(c.row>h.row||c.row===h.row&&c.column>=h.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(h.row-c.row)*this._terminal.cols-c.column+h.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var a,c;e.style.transform="";let t=e.getBoundingClientRect().width,s=(c=(a=this._rowColumns.get(e))==null?void 0:a.slice(-1))==null?void 0:c[0];if(!s)return;let n=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/t})`}};Eh=Nt([pe(1,R_),pe(2,yr),pe(3,br)],Eh);var Xp=class extends Ie{constructor(e,t,s,n,a){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=n,this._linkProviderService=a,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new fe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new fe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(vt(()=>{var c;ua(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(c=this._activeProviderReplies)==null||c.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Oe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Oe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Oe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Oe(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let n=0;n<s.length;n++){let a=s[n];if(a.classList.contains("xterm"))break;if(a.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var n,a;(!this._activeProviderReplies||!t)&&((n=this._activeProviderReplies)==null||n.forEach(c=>{c==null||c.forEach(h=>{h.link.dispose&&h.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[c,h]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(c)&&(s=this._checkLinkProviderResult(c,e,s)):h.provideLinks(e.y,d=>{var m,g;if(this._isMouseOut)return;let f=d==null?void 0:d.map(v=>({link:v}));(m=this._activeProviderReplies)==null||m.set(c,f),s=this._checkLinkProviderResult(c,e,s),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let n=0;n<t.size;n++){let a=t.get(n);if(a)for(let c=0;c<a.length;c++){let h=a[c],d=h.link.range.start.y<e?0:h.link.range.start.x,f=h.link.range.end.y>e?this._bufferService.cols:h.link.range.end.x;for(let m=d;m<=f;m++){if(s.has(m)){a.splice(c--,1);break}s.add(m)}}}}_checkLinkProviderResult(e,t,s){var c;if(!this._activeProviderReplies)return s;let n=this._activeProviderReplies.get(e),a=!1;for(let h=0;h<e;h++)(!this._activeProviderReplies.has(h)||this._activeProviderReplies.get(h))&&(a=!0);if(!a&&n){let h=n.find(d=>this._linkAtPosition(d.link,t));h&&(s=!0,this._handleNewLink(h))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let h=0;h<this._activeProviderReplies.size;h++){let d=(c=this._activeProviderReplies.get(h))==null?void 0:c.find(f=>this._linkAtPosition(f.link,t));if(d){s=!0,this._handleNewLink(d);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&j3(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ua(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,n;return(n=(s=this._currentLink)==null?void 0:s.state)==null?void 0:n.decorations.pointerCursor},set:s=>{var n;(n=this._currentLink)!=null&&n.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,n;return(n=(s=this._currentLink)==null?void 0:s.state)==null?void 0:n.decorations.underline},set:s=>{var n,a,c;(n=this._currentLink)!=null&&n.state&&((c=(a=this._currentLink)==null?void 0:a.state)==null?void 0:c.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let n=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(n,a),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,s){var n;(n=this._currentLink)!=null&&n.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,n=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-n-1,s.end.x,s.end.y-n-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,s){var n;(n=this._currentLink)!=null&&n.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,n=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return s<=a&&a<=n}_positionFromMouseEvent(e,t,s){let n=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,n,a){return{x1:e,y1:t,x2:s,y2:n,cols:this._bufferService.cols,fg:a}}};Xp=Nt([pe(1,D_),pe(2,br),pe(3,bs),pe(4,_1)],Xp);function j3(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var k3=class extends g3{constructor(e={}){super(e),this._linkifier=this._register(new Cl),this.browser=B1,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Cl),this._onCursorMove=this._register(new fe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new fe),this.onKey=this._onKey.event,this._onRender=this._register(new fe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new fe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new fe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new fe),this.onBell=this._onBell.event,this._onFocus=this._register(new fe),this._onBlur=this._register(new fe),this._onA11yCharEmitter=this._register(new fe),this._onA11yTabEmitter=this._register(new fe),this._onWillOpen=this._register(new fe),this._setup(),this._decorationService=this._instantiationService.createInstance(S3),this._instantiationService.setService(fc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(pM),this._instantiationService.setService(_1,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(yp)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(cs.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(cs.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(cs.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(cs.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(vt(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,n="";switch(t.index){case 256:s="foreground",n="10";break;case 257:s="background",n="11";break;case 258:s="cursor",n="12";break;default:s="ansi",n="4;"+t.index}switch(t.type){case 0:let a=_t.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${ne.ESC}]${n};${h3(a)}${D1.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=Pt.toColor(...t.color));else{let c=s;this._themeService.modifyColors(h=>h[c]=Pt.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Eh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ne.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ne.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,a=t.getWidth(s),c=this._renderService.dimensions.css.cell.width*a,h=this.buffer.y*this._renderService.dimensions.css.cell.height,d=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=h+"px",this.textarea.style.width=c+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Oe(this.element,"copy",t=>{this.hasSelection()&&OR(t,this._selectionService)}));let e=t=>AR(t,this.textarea,this.coreService,this.optionsService);this._register(Oe(this.textarea,"paste",e)),this._register(Oe(this.element,"paste",e)),L1?this._register(Oe(this.element,"mousedown",t=>{t.button===2&&lS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Oe(this.element,"contextmenu",t=>{lS(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),F_&&this._register(Oe(this.element,"auxclick",t=>{t.button===1&&l1(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Oe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Oe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Oe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Oe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Oe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Oe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Oe(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Oe(this.screenElement,"mousemove",c=>this.updateCursorStyle(c))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",_p.get()),P1||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(fM,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(yr,this._coreBrowserService),this._register(Oe(this.textarea,"focus",c=>this._handleTextAreaFocus(c))),this._register(Oe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Hp,this._document,this._helperContainer),this._instantiationService.setService(Dh,this._charSizeService),this._themeService=this._instantiationService.createInstance(Kp),this._instantiationService.setService(El,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(jh),this._instantiationService.setService(p1,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Ip,this.rows,this.screenElement)),this._instantiationService.setService(br,this._renderService),this._register(this._renderService.onRenderedViewportChange(c=>this._onRender.fire(c))),this.onResize(c=>this._renderService.resize(c.cols,c.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(qp,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Fp),this._instantiationService.setService(D_,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(Xp,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Bp,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(c=>{super.scrollLines(c,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Up,this.element,this.screenElement,n)),this._instantiationService.setService(PR,this._selectionService),this._register(this._selectionService.onRequestScrollLines(c=>this.scrollLines(c.amount,c.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(c=>this._renderService.handleSelectionChanged(c.start,c.end,c.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(c=>{this.textarea.value=c,this.textarea.focus(),this.textarea.select()})),this._register(cs.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var c;this._selectionService.refresh(),(c=this._viewport)==null||c.queueSync()})),this._register(this._instantiationService.createInstance(Lp,this.screenElement)),this._register(Oe(this.element,"mousedown",c=>this._selectionService.handleMouseDown(c))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Eh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",c=>this._handleScreenReaderModeOptionChange(c))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ch,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",c=>{!this._overviewRulerRenderer&&c&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ch,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Pp,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(c){var m,g,v,b,S;let h=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!h)return!1;let d,f;switch(c.overrideType||c.type){case"mousemove":f=32,c.buttons===void 0?(d=3,c.button!==void 0&&(d=c.button<3?c.button:3)):d=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":f=0,d=c.button<3?c.button:3;break;case"mousedown":f=1,d=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let x=c.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(c,(b=(v=(g=(m=e._renderService)==null?void 0:m.dimensions)==null?void 0:g.device)==null?void 0:v.cell)==null?void 0:b.height,(S=e._coreBrowserService)==null?void 0:S.dpr)===0)return!1;f=x<0?0:1,d=4;break;default:return!1}return f===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:d,action:f,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:c=>(s(c),c.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(c)),wheel:c=>(s(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&s(c)},mousemove:c=>{c.buttons||s(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?n.mousemove||(t.addEventListener("mousemove",a.mousemove),n.mousemove=a.mousemove):(t.removeEventListener("mousemove",n.mousemove),n.mousemove=null),c&16?n.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),n.wheel=a.wheel):(t.removeEventListener("wheel",n.wheel),n.wheel=null),c&2?n.mouseup||(n.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),c&4?n.mousedrag||(n.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Oe(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return s(c),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(c)})),this._register(Oe(t,"wheel",c=>{var h,d,f,m,g;if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,(m=(f=(d=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:d.device)==null?void 0:f.cell)==null?void 0:m.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(c,!0);let v=ne.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(v,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){a1(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=y3(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let n=this.rows-1;return this.scrollLines(s.type===2?-n:n),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===ne.ETX||s.key===ne.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(N3(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),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 e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(qt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(ne.ESC+"[I"):this.coreService.triggerDataEvent(ne.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ne.ESC}[4;${s};${t}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),a=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ne.ESC}[6;${a};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function N3(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var E3=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},T3=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new di)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},XS=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,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(e){let t=this._buffer.lines.get(e);if(t)return new T3(t)}getNullCell(){return new di}},O3=class extends Ie{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new fe),this.onBufferChange=this._onBufferChange.event,this._normal=new XS(this._core.buffers.normal,"normal"),this._alternate=new XS(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 new 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)}},A3=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,n)=>t(s,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},R3=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},D3=["cols","rows"],Ei=0,M3=class extends Ie{constructor(e){super(),this._core=this._register(new k3(e)),this._addonManager=this._register(new E3),this._publicOptions={...this._core.options};let t=n=>this._core.options[n],s=(n,a)=>{this._checkReadonlyOptions(n),this._core.options[n]=a};for(let n in this._core.options){let a={get:t.bind(this,n),set:s.bind(this,n)};Object.defineProperty(this._publicOptions,n,a)}}_checkReadonlyOptions(e){if(D3.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new A3(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new R3(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new O3(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
87
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return _p.get()},set promptLabel(e){_p.set(e)},get tooMuchOutput(){return gp.get()},set tooMuchOutput(e){gp.set(e)}}}_verifyIntegers(...e){for(Ei of e)if(Ei===1/0||isNaN(Ei)||Ei%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ei of e)if(Ei&&(Ei===1/0||isNaN(Ei)||Ei%1!==0||Ei<0))throw new Error("This API only accepts positive integers")}};const He={brand:{300:"#CCC2FF",400:"#B5A2FF",500:"#9774FD",900:"#321F5F",950:"#211441"},accent:{400:"#ABBE55"},neutral:{50:"#F8F7F9",300:"#CBCAD2",400:"#B2B1BB",500:"#91909B",600:"#73727C",900:"#2E2E33",925:"#26252C",960:"#19181F",980:"#100F15",1010:"#050408"},success:{300:"#91E0B3",400:"#60CC93",500:"#1AAC6E"},warning:{300:"#F4C273",500:"#BF8500"},danger:{300:"#FFB6AE",400:"#FF8D83",500:"#F0554F"},info:{200:"#BEE5FF",300:"#94D4FF",400:"#4FBEFF",500:"#009CE0"}},Lt={"bg/surface":He.neutral[980],"bg/inset":He.neutral[1010],"bg/active":He.neutral[925],"bg/brand":He.brand[500],"bg/brand-subtle":He.brand[950],"bg/brand-muted":He.brand[900],"text/primary":He.neutral[50],"text/code":He.neutral[300],"border/subtle":He.neutral[960],"git/added":He.success[400],"git/removed":He.danger[400],"syntax/keyword":He.brand[400],"syntax/string":He.accent[400],"syntax/number":He.warning[300],"syntax/comment":He.neutral[600],"syntax/function":He.info[400],"syntax/type":He.success[300],"syntax/punctuation":He.neutral[400],"editor/cursor":He.brand[400],"editor/selection":He.brand[900],"editor/active-line":He.neutral[980],"editor/line-number":He.neutral[500],"editor/line-number-active":He.neutral[300]},xL={2:2,8:8,10:10,12:12},wL={"gutter/line":44},B3={background:Lt["bg/inset"],foreground:Lt["text/primary"],cursor:Lt["text/primary"],cursorAccent:Lt["bg/inset"],selectionBackground:`${Lt["bg/brand"]}55`,selectionInactiveBackground:`${Lt["bg/active"]}88`,black:He.neutral[900],red:He.danger[500],green:He.success[500],yellow:He.warning[500],blue:He.info[500],magenta:He.brand[500],cyan:He.info[400],white:He.neutral[300],brightBlack:He.neutral[600],brightRed:He.danger[300],brightGreen:He.success[300],brightYellow:He.warning[300],brightBlue:He.info[300],brightMagenta:He.brand[300],brightCyan:He.info[200],brightWhite:He.neutral[50]},L3=['"JetBrainsMono Nerd Font"','"MesloLGS NF"','"FiraCode Nerd Font"','"Hack Nerd Font"','"JetBrains Mono"',"ui-monospace","SFMono-Regular","Menlo","monospace"].join(", "),q3=13,z3=20/13;function Lh({sessionId:e,connect:t=Dw,readOnly:s=!1,onReady:n,onMessage:a}){const c=j.useRef(null),h=j.useRef(null),d=j.useRef(s);d.current=s;const f=j.useRef(n),m=j.useRef(a);return f.current=n,m.current=a,j.useEffect(()=>{var L;const g=c.current;if(!g)return;const v=new M3({convertEol:!1,cursorBlink:!d.current,disableStdin:d.current,scrollback:1e4,theme:B3,fontFamily:L3,fontSize:q3,lineHeight:z3}),b=new jR;v.loadAddon(b),v.open(g),h.current=v,Tm(b),d.current||v.focus();const S=t(e,{onMessage(R){var D;R.type==="attached"?(Tm(b),v.reset(),v.write(R.snapshot)):R.type==="output"&&v.write(R.data),(D=m.current)==null||D.call(m,R)}}),x=v.onData(R=>{d.current||S.send({type:"input",data:R})}),w=v.onResize(({cols:R,rows:D})=>S.send({type:"resize",cols:R,rows:D})),k=()=>Tm(b);window.addEventListener("resize",k);const N=typeof ResizeObserver>"u"?null:new ResizeObserver(k);return N==null||N.observe(g),(L=f.current)==null||L.call(f,v),()=>{N==null||N.disconnect(),window.removeEventListener("resize",k),x.dispose(),w.dispose(),S.close(),v.dispose(),h.current=null}},[e,t]),j.useEffect(()=>{var v;const g=h.current;g!==null&&(g.options.disableStdin=s,g.options.cursorBlink=!s,s&&((v=c.current)!=null&&v.contains(document.activeElement))&&g.blur())},[s]),l.jsx("div",{className:"terminal","data-testid":"terminal","data-readonly":s?"true":void 0,ref:c})}function Tm(e){try{e.fit()}catch{}}function P3({scope:e,dock:t,onAskAgent:s}){var d,f,m;const[n,a]=j.useState("run"),c=i1(e),h=SR(e);return t.open?l.jsxs("div",{className:"dock",style:{height:`${String(t.height)}px`},"data-testid":"run-dock",children:[l.jsx("span",{className:"dock__grip",role:"separator","aria-orientation":"horizontal","aria-label":"altura do rodapé",onPointerDown:t.beginResize}),l.jsxs("div",{className:"dock__bar",role:"tablist","aria-label":"execução do checkout",children:[l.jsx("button",{type:"button",className:"dock__fold",title:"recolher o rodapé","aria-label":"recolher o rodapé",onClick:t.toggle,children:"⌄"}),l.jsx(Qu,{label:"Setup",active:n==="setup",dot:Om((d=c.data)==null?void 0:d.setup),onClick:()=>a("setup")}),l.jsx(Qu,{label:"Run",active:n==="run",dot:Om((f=c.data)==null?void 0:f.run),onClick:()=>a("run")}),l.jsx(Qu,{label:"Testes",active:n==="test",dot:Om((m=c.data)==null?void 0:m.test),onClick:()=>a("test")}),l.jsx(Qu,{label:"Terminal",active:n==="terminal",onClick:()=>a("terminal")}),l.jsx("span",{className:"dock__spacer"}),l.jsxs("div",{className:"dock__acts",children:[n==="run"&&l.jsx(H3,{status:c.data,actions:h}),(n==="setup"||n==="test")&&l.jsx(F3,{phase:n,status:c.data,actions:h})]})]}),n==="terminal"?l.jsx(W3,{scope:e}):c.isError?l.jsx("div",{className:"dock__idle",role:"alert",children:l.jsx("span",{children:c.error.message})}):l.jsx(I3,{scope:e,phase:n,status:c.data,actions:h,onAskAgent:s})]}):l.jsx(V3,{scope:e,status:c.data,onOpen:t.toggle})}function Om(e){return e!=null&&e.last?e.last.running?"run":e.last.exitCode===0?"ok":"fail":null}function Qu({label:e,active:t,dot:s=null,onClick:n}){return l.jsxs("button",{type:"button",role:"tab","aria-selected":t,className:`dtab${t?" dtab--active":""}`,onClick:n,children:[s!==null&&l.jsx("span",{className:`dtab__dot dtab__dot--${s}`,"data-testid":`dot-${e.toLowerCase()}`}),e]})}function H3({status:e,actions:t}){var a;const s=((a=e==null?void 0:e.run.last)==null?void 0:a.running)===!0,n=(e==null?void 0:e.port)??null;return s?l.jsxs(l.Fragment,{children:[n!==null&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"openbtn__from dock__note",children:n.source==="env"?"porta de LUMEM_RUN_PORT":"porta lida da saída"}),l.jsxs("a",{className:"openbtn",href:`http://127.0.0.1:${String(n.port)}`,target:"_blank",rel:"noreferrer",children:[l.jsx("span",{children:"Abrir"}),l.jsxs("span",{className:"openbtn__port",children:[":",n.port]})]})]}),l.jsx(ce,{size:"sm",glyph:l.jsx("span",{className:"stopglyph",children:"⏹"}),disabled:t.stop.isPending,onClick:()=>t.stop.mutate("run"),children:"parar"})]}):l.jsx(ce,{size:"sm",variant:"primary",disabled:(e==null?void 0:e.run.command)===null||t.start.isPending,onClick:()=>t.start.mutate("run"),children:"▶ rodar"})}function F3({phase:e,status:t,actions:s}){if(t===void 0||t[e].command===null)return null;const n=t[e].last;if((n==null?void 0:n.running)===!0)return l.jsx(ce,{size:"sm",glyph:l.jsx("span",{className:"stopglyph",children:"⏹"}),onClick:()=>s.stop.mutate(e),children:"parar"});const a=n!==null&&n.exitCode!==0;return l.jsxs(ce,{size:"sm",variant:a?"primary":"default",disabled:s.start.isPending,onClick:()=>s.start.mutate(e),children:["▶ ",n===null?"rodar":a?"tentar de novo":"rodar de novo"]})}function I3({scope:e,phase:t,status:s,actions:n,onAskAgent:a}){if(!s)return l.jsx("div",{className:"dock__idle",children:"lendo o checkout…"});const c=s[t].command;if(c===null)return l.jsx(K3,{scope:e,status:s,onAskAgent:a});if(!s.trusted)return l.jsx($3,{status:s,phase:t,actions:n});const h=s[t].last,d=h!==null&&!h.running&&h.exitCode!==0;return l.jsxs(l.Fragment,{children:[t==="setup"&&d&&l.jsxs("div",{className:"dock__banner",role:"status",children:[l.jsx($e,{tone:"warn",children:"⚠"}),l.jsxs("span",{children:[l.jsx("strong",{children:"A worktree foi criada; o setup dela falhou."})," Ela funciona — só não está preparada."]})]}),l.jsxs("div",{className:"dock__state",children:[h===null?l.jsx(kt,{children:"nunca rodou"}):h.running?l.jsxs(kt,{tone:"clean",dot:!0,children:["rodando · ",xh(h.startedAt)]}):l.jsxs(kt,{dot:!0,children:["saiu ",h.exitCode??"?"," · ",xh(h.finishedAt??h.startedAt)]}),l.jsx("span",{className:"dock__cmd",children:c}),l.jsx("span",{className:"dock__spacer"}),l.jsx("span",{className:"dock__note",children:s.reservedPort===null?"":`porta reservada :${String(s.reservedPort)}`})]}),h!==null&&!h.outputAvailable?l.jsx("div",{className:"dock__idle",children:l.jsx("span",{children:"A saída desta execução não existe mais — ela vivia na memória do daemon, e ele reiniciou desde então."})}):h===null?l.jsx("div",{className:"dock__idle",children:l.jsxs("span",{children:["Este checkout ainda não rodou ",t==="test"?"os testes":`o ${t}`,". O botão está ali em cima."]})}):l.jsx("div",{className:"dock__out",children:l.jsx(Lh,{sessionId:h.sessionId,readOnly:!h.running},h.sessionId)})]})}function U3(e){return["Este checkout ainda não diz ao Lumem como rodar.","",`Escreva a tabela \`[scripts]\` em \`${e}\`, com as quatro fases:`,"","- `setup`: deixa um checkout novo pronto para trabalhar — instalar dependências, preparar banco, o que for. Precisa ser idempetente: rodar de novo não pode estragar nada.","- `run`: sobe a aplicação em primeiro plano (nada de daemon em background). Se ela aceitar porta configurável, use `$LUMEM_RUN_PORT` — é a porta que o Lumem reserva para este checkout, e é o que faz duas worktrees rodarem ao mesmo tempo.","- `test`: roda a suíte de testes do projeto, uma vez e até o fim (nada de modo watch — o rodapé quer um código de saída, não um processo que fica).","- `teardown`: desfaz o que sobrevive ao diretório — container, volume, porta presa. Se não houver nada assim, omita a linha.","","Antes de escrever, **leia o repositório** para descobrir os comandos de verdade: `package.json`, `Makefile`, `docker-compose.yml`, `README`, e o que mais existir. Não invente comando que não está lá; se não achar o de alguma fase, diga isso em vez de chutar.","","Cada valor é uma string só, executada pelo shell de login no diretório do checkout. Preserve o resto do arquivo — ele pode já ter o `id` do projeto dentro, e ele é do time.","","Não commite: eu reviso a mudança."].join(`
88
+ `)}function K3({scope:e,status:t,onAskAgent:s}){const n=qe(),c=(ye({queryKey:["agentConfig","list"],queryFn:()=>te.agentConfig.list.query()}).data??[]).find(f=>f.transport==="acp")??null,h=Te({mutationFn:async()=>{if(c===null)throw new Error("nenhum agente conectado");const f=await te.session.createAgent.mutate({scopeType:e.scopeType,scopeId:e.scopeId,agentConfigId:c.id});return await n.invalidateQueries({queryKey:Hi(e.scopeType,e.scopeId)}),f.id},onSuccess:f=>s==null?void 0:s(f,U3(t.file))}),d=j.useMemo(()=>["# o id já está aqui; o que falta é o resto",'id = "prj_…"',"","[scripts]",'setup = "./scripts/setup.sh"','run = "pnpm dev"','test = "pnpm test"','teardown = "./scripts/teardown.sh"'].join(`
89
+ `),[]);return l.jsxs("div",{className:"noscripts",children:[l.jsx("span",{className:"noscripts__t",children:"Este projeto não diz como rodar."}),l.jsxs("p",{className:"noscripts__d",children:["O Lumem lê os comandos de um arquivo ",l.jsx("strong",{children:"do repositório"}),", versionado junto com o código: quem clonar depois herda o mesmo setup, com Lumem ou sem. Enquanto ele não existir, as abas ",l.jsx("code",{children:"Setup"})," e ",l.jsx("code",{children:"Run"})," ficam vazias — o ",l.jsx("code",{children:"Terminal"})," continua funcionando."]}),l.jsx("span",{className:"noscripts__where",children:t.file}),l.jsx("pre",{className:"toml",children:d}),l.jsxs("div",{className:"noscripts__acts",children:[l.jsx(ce,{size:"sm",variant:"primary",disabled:c===null||s===void 0||h.isPending,onClick:()=>h.mutate(),children:h.isPending?"abrindo a conversa…":"pedir para o agente criar"}),l.jsx(ce,{size:"sm",onClick:()=>{var f;return void((f=navigator.clipboard)==null?void 0:f.writeText(d))},children:"copiar o exemplo"}),c===null&&l.jsx("span",{className:"trust__note",children:"conecte um agente na barra da esquerda para pedir — ou escreva o arquivo à mão"}),h.isError&&l.jsx("span",{className:"trust__note",role:"alert",children:h.error.message})]})]})}function $3({status:e,phase:t,actions:s}){return l.jsxs("div",{className:"trust",children:[l.jsxs("div",{className:"trust__head",children:[l.jsx("span",{className:"trust__glyph",children:"⚠"}),"Este comando vem do repositório, não de você."]}),l.jsx("p",{className:"trust__why",children:"Este projeto foi clonado de uma URL. O que está abaixo estava dentro dele, e vai rodar na sua máquina com as suas permissões."}),l.jsx("div",{className:"trust__cmd",children:e[t].command}),l.jsxs("div",{className:"trust__acts",children:[l.jsx(ce,{size:"sm",variant:"primary",disabled:s.trust.isPending,onClick:()=>s.trust.mutate(),children:"confiar neste projeto"}),l.jsx("span",{className:"trust__note",children:"Vale para este projeto nesta máquina — e volta a perguntar se o comando mudar."})]})]})}function W3({scope:e}){const t=qe(),s=O_(e),[n,a]=j.useState(null),c=(s.data??[]).filter(f=>f.kind==="shell"&&f.state==="running"),h=c.find(f=>f.id===n)??c[0]??null;async function d(){const f=await te.session.createShell.mutate(e);a(f.id),await t.invalidateQueries({queryKey:Hi(e.scopeType,e.scopeId)})}return h==null?l.jsxs("div",{className:"dock__idle",children:[l.jsx("span",{children:"Nenhum terminal aberto neste checkout."}),l.jsx(ce,{size:"sm",onClick:()=>void d(),children:"+ abrir terminal"})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"dock__state",children:[l.jsxs(kt,{tone:"clean",dot:!0,children:[c.length," viva",c.length>1?"s":""]}),l.jsxs("span",{className:"dock__cmd dock__cmd--dim",children:["cwd ",h.cwd]}),l.jsx("span",{className:"dock__spacer"}),l.jsx("button",{type:"button",className:"dock__new",onClick:()=>void d(),children:"+ outro terminal"})]}),l.jsx("div",{className:"dock__out",children:l.jsx(Lh,{sessionId:h.id},h.id)})]})}function V3({scope:e,status:t,onOpen:s}){var c;const n=((c=t==null?void 0:t.run.last)==null?void 0:c.running)===!0,a=(t==null?void 0:t.port)??null;return l.jsx("div",{className:"dock dock--collapsed","data-testid":"run-dock-folded",children:l.jsxs("div",{className:"dock__folded",children:[l.jsx("button",{type:"button",className:"dock__fold","aria-label":"abrir o rodapé",onClick:s,children:"⌃"}),n?l.jsxs("span",{className:"runmark",children:[l.jsx("span",{className:"runmark__glyph",children:"▶"}),a===null?"run":`run · :${String(a.port)}`]}):l.jsx("span",{children:"setup, run e terminal"}),l.jsx("span",{className:"dock__spacer"}),l.jsx("span",{className:"dock__note",children:e.scopeType==="worktree"?"worktree":"projeto"})]})})}function Y3({scope:e,onClose:t,onResize:s,dock:n,onAskAgent:a}){var z,G,le,H;const c=qe(),[h,d]=j.useState("files"),[f,m]=j.useState("worktree"),g=N_(),v=zA(e),b=Vw(e,"worktree"),S=j_("pending"),x=PA(e),w=e.scopeType==="worktree"?e.scopeId:null,k=TA(w,{panelOpen:!0}),N=RA(e),L=DA(x.projectId),R=k.data??null,D=(R==null?void 0:R.pull)??null,Y=R!==null&&w!==null&&!L.isDismissed,K=h==="pr"&&D===null?"files":h,Z=new Map((((z=b.data)==null?void 0:z.files)??[]).map(O=>[O.path,O.status])),Q=g.activeTab===null?null:g.fileFor(g.activeTab);return l.jsxs(yR,{tab:K,onSelectTab:d,changeCount:((G=b.data)==null?void 0:G.files.length)??null,proposalCount:((le=S.data)==null?void 0:le.length)??null,prBar:Y&&w!==null?l.jsx(dR,{status:R,worktreeId:w,onRetry:()=>N.mutate(),onDismiss:L.dismiss}):void 0,prBadge:D===null?null:eR(D),actions:K==="files"?l.jsx(sR,{edits:v}):void 0,onReload:()=>{c.invalidateQueries({queryKey:["files"]}),c.invalidateQueries({queryKey:["changes"]}),N.mutate()},onClose:t,onResize:s,dock:l.jsx(P3,{scope:e,dock:n,onAskAgent:a}),footLeft:b.isError?"não deu para ler o checkout":void 0,footRight:K==="changes"?f==="worktree"?"árvore de trabalho vs HEAD":`vs ${((H=b.data)==null?void 0:H.baseBranch)??"base"}`:void 0,children:[K==="files"&&l.jsx(tR,{scope:e,openPath:(Q==null?void 0:Q.view)==="file"?Q.path:null,onOpen:O=>g.open({path:O,view:"file"}),statusOf:O=>Z.get(O),edits:v}),K==="changes"&&l.jsx(HA,{scope:e,openPath:(Q==null?void 0:Q.view)==="patch"?Q.path:null,onOpenPatch:(O,W)=>g.open({path:O,view:"patch",ref:W}),onRefChange:m}),K==="pr"&&D!==null&&l.jsx(XA,{pull:D,readAt:(R==null?void 0:R.readAt)??null}),K==="memory"&&l.jsx(Hw,{workspaceId:x.workspaceId,projectId:x.projectId})]})}const G3=new Set(["no-binary","no-auth","unsupported-host"]);function Q3(e,t){const s=t.toLowerCase().normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60).replace(/-+$/g,"");return s===""?String(e):`${e}-${s}`}function Z3({projectId:e,projectName:t,open:s,onClose:n,onCreated:a,onOpenExisting:c,hasCommits:h=null}){var H,O,W,ee,T,F,J,ve;const d=qe(),[f,m]=j.useState(""),[g,v]=j.useState("default"),[b,S]=j.useState(null),x=ye({queryKey:BN(e),queryFn:()=>te.worktree.branches.query({projectId:e}),enabled:s}),w=ye({queryKey:LN(e),queryFn:()=>te.worktree.hostOrigins.query({projectId:e}),enabled:s}),k=Te({mutationFn:()=>te.worktree.create.mutate({projectId:e,name:f.trim(),from:eB(Q,b)}),onSuccess:async oe=>{await d.invalidateQueries({queryKey:gr(e)}),a(oe.id),N()}});function N(){m(""),v("default"),S(null),k.reset(),n()}const L=oe=>{oe.preventDefault(),f.trim()!==""&&k.mutate()},R=h===!1,D=`worktree-name-${e}`,Y=((H=w.data)==null?void 0:H.issues.failure)??((O=w.data)==null?void 0:O.pulls.failure)??null,K=w.data!==void 0&&(w.data.host===null||G3.has((Y==null?void 0:Y.kind)??"")),Z=K?["default","branch"]:["default","branch","issue","pr"],Q=Z.includes(g)?g:"default",z=b!==null&&b.kind===Q?b:null,G=(z==null?void 0:z.kind)==="pr"&&((W=w.data)==null?void 0:W.pulls.items.some(oe=>oe.number===z.number&&!oe.onDisk))===!0?z.number:null;function le(oe,M){S(oe),m(M)}return l.jsx(Ah,{open:s,title:"Nova worktree",where:l.jsxs(l.Fragment,{children:["em",l.jsx($e,{tone:"project",children:"■"}),l.jsx("b",{children:t})]}),onClose:N,footer:l.jsxs(l.Fragment,{children:[l.jsx(ce,{type:"submit",form:ex,variant:"primary",disabled:k.isPending||f.trim()===""||R,children:k.isPending?"criando…":"criar"}),l.jsx(ce,{variant:"ghost",onClick:N,children:R?"fechar":"cancelar"})]}),children:l.jsxs("form",{id:ex,onSubmit:L,children:[!R&&l.jsxs("div",{className:"origin",children:[l.jsx("div",{className:"seg",role:"group","aria-label":"de onde cortar",children:Z.map(oe=>l.jsx("button",{type:"button",className:"seg__btn","aria-pressed":Q===oe,onClick:()=>{v(oe),S(null)},children:tB[oe]},oe))}),Q==="default"?l.jsx("div",{className:"origin__list",children:l.jsx("div",{className:"origin__empty",children:l.jsx("p",{children:"corta da branch default deste projeto — sem ir à rede"})})}):Q==="branch"?l.jsx(Am,{busy:x.isPending,label:"branches",empty:"nenhuma branch além da default",failure:x.isError?x.error.message:null,children:(x.data??[]).map(oe=>{const M=oe.worktreePath!==null;return l.jsxs("button",{type:"button",role:"option",className:`orow${M?" orow--held":""}`,"aria-selected":(b==null?void 0:b.kind)==="branch"&&b.ref===oe.name,onClick:()=>{if(M){oe.worktreeId!==null&&((c??a)(oe.worktreeId),N());return}le({kind:"branch",ref:oe.name,local:oe.local},oe.name)},children:[l.jsx("span",{className:"orow__ref",children:oe.name}),l.jsx("span",{className:"orow__t"}),l.jsx("span",{className:"orow__note",children:M?oe.worktreeName===null?"no checkout principal":`em ${oe.worktreeName}`:X3(oe)}),M&&oe.worktreeId!==null&&l.jsx("span",{className:"orow__go",children:"→"})]},oe.name)})}):Q==="issue"?l.jsx(Am,{busy:w.isPending,label:"issues abertas",empty:"nenhuma issue aberta neste repositório",failure:JS(w,((ee=w.data)==null?void 0:ee.issues.failure)??null),children:(((T=w.data)==null?void 0:T.issues.items)??[]).map(oe=>l.jsxs("button",{type:"button",role:"option",className:"orow","aria-selected":(b==null?void 0:b.kind)==="issue"&&b.number===oe.number,onClick:()=>le({kind:"issue",number:oe.number},Q3(oe.number,oe.title)),children:[l.jsxs("span",{className:"orow__n",children:["#",oe.number]}),l.jsx("span",{className:"orow__t",children:oe.title})]},oe.number))}):l.jsx(Am,{busy:w.isPending,label:"pull requests abertas",empty:"nenhuma PR aberta neste repositório",failure:JS(w,((F=w.data)==null?void 0:F.pulls.failure)??null),children:(((J=w.data)==null?void 0:J.pulls.items)??[]).map(oe=>l.jsxs("button",{type:"button",role:"option",className:"orow","aria-selected":(b==null?void 0:b.kind)==="pr"&&b.number===oe.number,onClick:()=>le({kind:"pr",number:oe.number},oe.headRefName),children:[l.jsxs("span",{className:"orow__n",children:["#",oe.number]}),l.jsx("span",{className:"orow__t",children:oe.title}),!oe.onDisk&&l.jsx("span",{className:"orow__note orow__note--wait",children:oe.crossRepository?"de um fork · busca ao criar":"busca ao criar"})]},oe.number))}),K&&l.jsxs("p",{className:"origin__off",children:[l.jsx($e,{tone:"off",children:"◌"}),Y===null||((ve=w.data)==null?void 0:ve.host)===null?"este projeto não tem remoto — issues e PRs vêm de um host":Y.kind==="no-auth"?"o gh não está autenticado — rode gh auth login no terminal":Y.message]})]}),l.jsx($t,{id:D,label:"Nome da worktree",error:k.isError?k.error.message:void 0,children:l.jsx(ts,{id:D,"data-modal-focus":"",value:f,onChange:oe=>m(oe.target.value),placeholder:"teste-prd",invalid:k.isError})}),R?l.jsx(ke,{tone:"warning",children:"este repositório ainda não tem nenhum commit — faça o primeiro para poder cortar worktrees"}):z===null?l.jsx("p",{className:"create-worktree__hint",children:"A branch tem o mesmo nome. Barra vira diretório aninhado."}):l.jsxs("p",{className:`create-worktree__hint fname${z.kind==="branch"&&z.local?" fname--branch":""}`,children:[l.jsx("span",{className:"fname__g",children:z.kind==="branch"&&z.local?"⑂":"◈"}),l.jsx("span",{children:J3(z)})]}),k.isPending&&l.jsx(ke,{tone:"info",children:G===null?"copiando o checkout — em repositório grande isto leva alguns segundos":`buscando a branch da PR #${String(G)} — isto vai à rede`})]})})}function Am({busy:e,label:t,empty:s,failure:n,children:a}){return l.jsx("div",{className:"origin__list",role:"listbox","aria-label":t,"aria-busy":e||void 0,children:e?l.jsxs("div",{className:"origin__skel","aria-hidden":"true",children:[l.jsx("span",{}),l.jsx("span",{}),l.jsx("span",{})]}):n!==null?l.jsx("div",{className:"origin__empty",children:l.jsx("p",{children:n})}):a.length===0?l.jsx("div",{className:"origin__empty",children:l.jsx("p",{children:s})}):a})}function X3(e){return[e.local?"local":null,...e.remotes].filter(t=>t!==null).join(" · ")}function J3(e){switch(e.kind){case"branch":return e.local?`na branch ${e.ref}, que já existe — o nome é só desta worktree`:`da branch publicada ${e.ref}, rastreando ela`;case"issue":return`da issue #${e.number} — corta da default, como sempre`;case"pr":return`da head da PR #${e.number}, que já está no disco`}}function eB(e,t){if(!(e==="default"||t===null)&&e===t.kind)return t}function JS(e,t){var s;return e.isError?((s=e.error)==null?void 0:s.message)??"não deu para ler as origens deste projeto":t===null?null:t.message}const tB={default:"default",branch:"branch",issue:"issue",pr:"PR"},ex="create-worktree",G1=j.createContext(null);function sB({children:e}){const[t,s]=j.useState(new Set),n=j.useCallback((c,h)=>{s(d=>{if(d.has(c)===h)return d;const f=new Set(d);return h?f.add(c):f.delete(c),f})},[]),a=j.useMemo(()=>({isWaiting:c=>t.has(c),countIn:c=>c.filter(h=>t.has(h)).length,setWaiting:n}),[t,n]);return l.jsx(G1.Provider,{value:a,children:e})}function I_(){return j.useContext(G1)??{isWaiting:()=>!1,countIn:()=>0,setWaiting:()=>{}}}function iB(e){const t=O_(e),s=qe(),[n,a]=j.useState(null),[c,h]=j.useState(new Set),[d,f]=j.useState(new Set),m=j.useMemo(()=>t.data??[],[t.data]),g=j.useMemo(()=>{const k=m.filter(L=>!d.has(L.id)&&(L.state==="running"||c.has(L.id))),N=new Map;return k.map(L=>{const R=L.agentName??"shell",D=(N.get(R)??0)+1;return N.set(R,D),{sessionId:L.id,label:R,kind:L.kind,state:L.state,exitCode:L.exitCode,command:L.command,transport:L.transport==="acp"?"acp":"pty",agentConfigId:L.agentConfigId,...D>1?{ordinal:D}:{}}})},[m,c,d]);j.useEffect(()=>{n!==null&&!g.some(k=>k.sessionId===n)&&a(null)},[g,n]);const v=j.useCallback(k=>a(k),[]),b=j.useCallback(k=>{const N=m.find(L=>L.id===k);N===void 0||N.state==="running"||(f(L=>new Set(L).add(k)),h(L=>{const R=new Set(L);return R.delete(k),R}))},[m]),S=j.useCallback(k=>{f(N=>{const L=new Set(N);return L.delete(k),L}),h(N=>new Set(N).add(k)),a(k)},[]),x=Te({mutationFn:k=>te.session.resume.mutate({id:k}),onSuccess:async k=>{await s.invalidateQueries({queryKey:Hi(e.scopeType,e.scopeId)}),a(k.id)}}),w=j.useCallback(k=>x.mutate(k),[x]);return{tabs:g,activeId:n,select:v,close:b,reopen:S,resume:w,resuming:x.isPending?x.variables??null:null,sessions:t}}const rB=800;function tx(e,t){if(e===t)return{added:0,removed:0};const s=e.split(`
90
+ `),n=t.split(`
91
+ `);let a=0;for(;a<s.length&&a<n.length&&s[a]===n[a];)a++;let c=0;for(;c<s.length-a&&c<n.length-a&&s[s.length-1-c]===n[n.length-1-c];)c++;return{added:n.length-a-c,removed:s.length-a-c}}function Zu(e,t){return e.scopeType===t.scopeType&&e.scopeId===t.scopeId&&e.path===t.path}function nB(e){const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function aB(e){return e instanceof Error?e.message:String(e)}function sx(e){return e===void 0||e.kind!=="text"?null:e}function lB({scope:e,path:t,active:s}){const n=qe(),a=j.useRef(null),c=j.useRef(null),h=j.useRef({scopeType:e.scopeType,scopeId:e.scopeId,path:t}),d=j.useRef(null),f=j.useRef(0),m=j.useRef(0),g=j.useRef(null),v=j.useRef(!1),b=j.useRef(!1),S=j.useRef(null),x=j.useRef(null),w=j.useRef(!1),k=j.useRef([]),[N,L]=j.useState({kind:"clean"}),[R,D]=j.useState(!0),Y=j.useRef(!0),K=Bu(e.scopeType,e.scopeId,t),Z=ye({queryKey:K,queryFn:()=>{const V=n.getQueryData(K);return!Y.current&&V!==void 0?(w.current=!0,V):te.files.read.query({scopeType:e.scopeType,scopeId:e.scopeId,path:t})},refetchOnWindowFocus:R}),Q=sx(Z.data),z=j.useRef(!1);z.current=Q===null||Q.readOnly!==null;const G=j.useCallback(V=>{Y.current=V,D(V)},[]),le=j.useCallback(()=>{x.current!==null&&(window.clearTimeout(x.current),x.current=null)},[]),H=j.useCallback(V=>{S.current=V,L({kind:"stale",...V})},[]),O=j.useCallback(()=>!v.current&&(g.current===null||b.current),[]),W=j.useCallback(()=>{if(!O())return;const V=k.current;if(V.length!==0){k.current=[];for(const de of V)de()}},[O]),ee=j.useCallback(V=>{n.invalidateQueries({queryKey:["changes"]}),n.invalidateQueries({queryKey:p_(V.scopeType,V.scopeId,nB(V.path))})},[n]),T=j.useCallback(()=>{if(v.current||b.current)return;const V=g.current;V!==null&&(g.current=null,v.current=!0,L({kind:"saving"}),n.cancelQueries({queryKey:Bu(V.target.scopeType,V.target.scopeId,V.target.path)}),te.files.write.mutate({scopeType:V.target.scopeType,scopeId:V.target.scopeId,path:V.target.path,text:V.text,baseRevision:V.baseRevision}).then(de=>{var _e,Ae;if(!de.ok){if(!Zu(V.target,h.current))return;b.current=!0,le(),H({revision:de.revision,changedAt:de.changedAt,base:((_e=c.current)==null?void 0:_e.text)??V.text,mine:((Ae=a.current)==null?void 0:Ae.getDoc())??V.text,disk:null}),te.files.read.query(V.target).then(nt=>{const Xe=sx(nt),Ds=S.current;Xe===null||Ds===null||H({...Ds,disk:Xe})}).catch(()=>{});return}Zu(V.target,h.current)&&(c.current={text:V.text,revision:de.revision},f.current===V.version&&(m.current=V.version,G(!0)),L({kind:"saved",at:Date.now()})),g.current!==null&&Zu(g.current.target,V.target)&&(g.current={...g.current,baseRevision:de.revision}),ee(V.target)}).catch(de=>{Zu(V.target,h.current)&&L({kind:"failed",why:aB(de)})}).finally(()=>{v.current=!1,T(),W()}))},[le,ee,n,W,G,H]),F=j.useCallback(()=>{le();const V=a.current,de=c.current,_e=d.current;V===null||de===null||_e===null||f.current!==m.current&&(g.current={target:_e,text:V.getDoc(),baseRevision:de.revision,version:f.current},T())},[le,T]),J=j.useCallback(()=>{if(b.current||(F(),O()))return Promise.resolve();const V=new Promise(de=>{k.current.push(de)});return BA(V),V},[O,F]),ve=j.useCallback(()=>{if(f.current+=1,d.current=h.current,G(!1),b.current){const V=S.current,de=a.current;V!==null&&de!==null&&H({...V,mine:de.getDoc()});return}le(),x.current=window.setTimeout(()=>{x.current=null,F()},rB)},[le,F,G,H]),oe=j.useCallback(V=>{var de;if(V===null){J(),(de=a.current)==null||de.onChange(null),a.current=null;return}a.current=V,!z.current&&V.onChange(ve)},[ve,J]),M=j.useCallback(()=>{F()},[F]),U=j.useCallback(()=>{const V=S.current,de=d.current;if(V===null||de===null)return;S.current=null,b.current=!1,m.current=f.current,G(!0),L({kind:"clean"});const _e=Bu(de.scopeType,de.scopeId,de.path);if(V.disk===null){n.invalidateQueries({queryKey:_e});return}n.setQueryData(_e,V.disk)},[n,G]),ae=j.useCallback(()=>{const V=S.current,de=a.current,_e=d.current;V===null||de===null||_e===null||(S.current=null,b.current=!1,g.current={target:_e,text:de.getDoc(),baseRevision:V.revision,version:f.current},T())},[T]);return j.useEffect(()=>{h.current={scopeType:e.scopeType,scopeId:e.scopeId,path:t},d.current=null,m.current=f.current,b.current=!1,S.current=null,c.current=null,G(!0),L({kind:"clean"})},[e.scopeType,e.scopeId,t,G]),j.useEffect(()=>{var V;Q!==null&&Y.current&&(c.current={text:Q.text,revision:Q.revision},(V=a.current)==null||V.setDoc(Q.text))},[Q]),j.useEffect(()=>{!R||!w.current||(w.current=!1,n.invalidateQueries({queryKey:Bu(e.scopeType,e.scopeId,t)}))},[R,n,e.scopeType,e.scopeId,t]),j.useEffect(()=>{s||J()},[s,J]),j.useEffect(()=>{const V=()=>void J();return window.addEventListener("blur",V),()=>window.removeEventListener("blur",V)},[J]),j.useEffect(()=>le,[le]),{content:Z,state:N,attach:oe,retry:M,reload:U,overwrite:ae}}const Q1="lumem",oB={name:Q1,type:"dark",colors:{"editor.background":Lt["bg/inset"],"editor.foreground":Lt["text/code"]},settings:[{settings:{background:Lt["bg/inset"],foreground:Lt["text/code"]}},{scope:["comment","punctuation.definition.comment","string.comment"],settings:{foreground:Lt["syntax/comment"]}},{scope:["string","string.quoted","constant.other.symbol","meta.embedded.line"],settings:{foreground:Lt["syntax/string"]}},{scope:["constant.numeric","constant.language","constant.character","keyword.other.unit"],settings:{foreground:Lt["syntax/number"]}},{scope:["keyword","storage","storage.type","keyword.operator.new","keyword.control"],settings:{foreground:Lt["syntax/keyword"]}},{scope:["entity.name.function","support.function","meta.function-call","variable.function"],settings:{foreground:Lt["syntax/function"]}},{scope:["entity.name.type","entity.name.class","support.type","support.class","entity.other.inherited-class"],settings:{foreground:Lt["syntax/type"]}},{scope:["punctuation","meta.brace","keyword.operator"],settings:{foreground:Lt["syntax/punctuation"]}},{scope:["markup.heading","entity.name.section"],settings:{foreground:Lt["syntax/keyword"]}},{scope:["markup.inserted"],settings:{foreground:Lt["git/added"]}},{scope:["markup.deleted"],settings:{foreground:Lt["git/removed"]}}]},cB={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",json:"json",md:"markdown",css:"css",html:"html",yml:"yaml",yaml:"yaml",sh:"shellscript",bash:"shellscript",zsh:"shellscript",py:"python",sql:"sql",toml:"toml",diff:"diff",patch:"diff"},uB={typescript:()=>Ut(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>Ut(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>Ut(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>Ut(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>Ut(()=>import("./json-Cp-IABpG.js"),[]),markdown:()=>Ut(()=>import("./markdown-Cvjx9yec.js"),[]),css:()=>Ut(()=>import("./css-CLj8gQPS.js"),[]),html:()=>Ut(()=>import("./html-pp8916En.js"),__vite__mapDeps([0,1,2])),yaml:()=>Ut(()=>import("./yaml-Buea-lGh.js"),[]),shellscript:()=>Ut(()=>import("./shellscript-Yzrsuije.js"),[]),python:()=>Ut(()=>import("./python-B6aJPvgy.js"),[]),sql:()=>Ut(()=>import("./sql-CRqJ_cUM.js"),[]),toml:()=>Ut(()=>import("./toml-vGWfd6FD.js"),[]),diff:()=>Ut(()=>import("./diff-D97Zzqfu.js"),[]),docker:()=>Ut(()=>import("./docker-BcOcwvcX.js"),[]),make:()=>Ut(()=>import("./make-CHLpvVh8.js"),[])},ix={dockerfile:"docker",makefile:"make"};function hB(e){const t=e.slice(e.lastIndexOf("/")+1).toLowerCase();if(t in ix)return ix[t];const s=t.lastIndexOf(".");return s<=0?null:cB[t.slice(s+1)]??null}let Xu=null,Rm=null;const rx=new Set;async function dB(){if(Xu!==null)return Xu;Rm??(Rm=fB());try{return Xu=await Rm,Xu}catch(e){throw Rm=null,e}}async function fB(){const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([Ut(()=>import("./core-rofTMs1b.js"),[]),Ut(()=>import("./engine-javascript-DBd1bXLz.js"),[])]);return e({themes:[oB],langs:[],engine:t()})}async function mB(e){try{const t=await dB();if(!rx.has(e)){const s=uB[e];if(s===void 0)return null;const n=await s();await t.loadLanguage(n.default),rx.add(e)}return t}catch{return null}}function Z1({path:e,headExtra:t,wrap:s,onToggleWrap:n,onClose:a,footLeft:c,footRight:h,children:d}){const f=e.lastIndexOf("/"),m=f===-1?"":e.slice(0,f+1),g=e.slice(f+1);return l.jsxs("div",{className:"viewer",children:[l.jsxs("div",{className:"viewer__head",children:[l.jsxs("span",{className:"fpath",title:e,children:[l.jsx("span",{className:"fpath__dir",children:m}),l.jsx("span",{className:"fpath__name",children:g})]}),t,l.jsx("span",{className:"viewer__spacer"}),l.jsxs("button",{type:"button",className:`rp__icon${s?" rp__icon--on":""}`,"aria-pressed":s,onClick:n,title:"quebrar linhas longas",children:["⇄",l.jsx("span",{className:"sr-only",children:"quebrar linhas longas"})]}),l.jsxs("button",{type:"button",className:"rp__icon",onClick:a,title:"fechar",children:["✕",l.jsx("span",{className:"sr-only",children:"fechar"})]})]}),d,l.jsxs("div",{className:"viewer__foot",children:[c,h===void 0?null:l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"viewer__spacer"}),h]})]})]})}const nx={"inside-git":{chip:"dentro de .git",why:l.jsxs(l.Fragment,{children:["está dentro de ",l.jsx("code",{children:".git"}),": reescrever aqui destrói a worktree e o que ainda não foi commitado."]})},"not-writable":{chip:"sem permissão de escrita",why:l.jsx(l.Fragment,{children:"o daemon não consegue gravar neste arquivo, e a gravação atômica não serve de atalho para o modo que alguém deixou aqui."})},"not-utf8":{chip:"não é UTF-8",why:l.jsx(l.Fragment,{children:"os bytes deste arquivo não voltam iguais depois de uma ida e volta em UTF-8, e gravar trocaria o que não for representável por outra coisa."})}};function pB({scope:e,path:t,active:s,onClose:n}){const[a,c]=j.useState(!0),h=lB({scope:e,path:t,active:s}),d=h.content,f=hB(t),m=d.data,g=m===void 0?null:m.kind==="binary"?"binário":m.kind==="too-large"?"acima do teto":m.readOnly===null?null:nx[m.readOnly].chip,v=g===null&&(h.state.kind==="failed"||h.state.kind==="stale");return l.jsx(Z1,{path:t,onClose:n,wrap:a,onToggleWrap:()=>c(S=>!S),footLeft:g===null?l.jsx(vB,{state:h.state,onRetry:h.retry}):l.jsxs("span",{className:"save save--readonly",children:[l.jsx("span",{className:"save__mark","aria-hidden":"true",children:"⊘"}),"somente leitura · ",g]}),footRight:v||m===void 0?void 0:m.kind==="text"?`${Mo(m.bytes)} · ${m.lines} linhas · ${f??"texto"}`:Mo(m.bytes),children:b()});function b(){if(d.isPending)return l.jsx("div",{className:"code",children:"carregando…"});if(d.isError)return l.jsxs("div",{className:"refuse",role:"alert",children:[l.jsx("span",{className:"refuse__glyph","aria-hidden":"true",children:"⚠"}),l.jsx("span",{className:"refuse__title",children:"não deu para abrir"}),l.jsx("span",{className:"refuse__why",children:d.error.message})]});if(d.data.kind==="binary")return l.jsxs("div",{className:"refuse",children:[l.jsx("span",{className:"refuse__glyph","aria-hidden":"true",children:"▦"}),l.jsx("span",{className:"refuse__title",children:"arquivo binário"}),l.jsx("span",{className:"refuse__why",children:"tem bytes nulos nos primeiros KiB — o split não tenta desenhá-lo como texto, e não há buffer para editar."}),l.jsx("span",{className:"refuse__why",children:l.jsx("code",{children:t})})]});if(d.data.kind==="too-large")return l.jsxs("div",{className:"refuse",children:[l.jsx("span",{className:"refuse__glyph","aria-hidden":"true",children:"▤"}),l.jsxs("span",{className:"refuse__title",children:[Mo(d.data.bytes)," passa do teto de ",Mo(d.data.limit)]}),l.jsx("span",{className:"refuse__why",children:"o daemon não leu o arquivo — sem leitura não há revisão, e sem revisão não haveria contra o que gravar."}),l.jsx("span",{className:"refuse__why",children:l.jsx("code",{children:t})})]});const S=d.data.readOnly;return l.jsxs(l.Fragment,{children:[S!==null&&l.jsxs("div",{className:"robar",children:[l.jsx("span",{className:"robar__glyph","aria-hidden":"true",children:"⊘"}),l.jsx("span",{children:nx[S].why})]}),h.state.kind==="stale"&&l.jsx(_B,{conflict:h.state,onReload:h.reload,onOverwrite:h.overwrite}),l.jsx(yB,{path:t,text:d.data.text,language:f,readOnly:S!==null,wrap:a,onReady:h.attach})]})}}function _B({conflict:e,onReload:t,onOverwrite:s}){const n=tx(e.base,e.mine),a=e.disk===null?null:tx(e.base,e.disk.text);return l.jsxs("div",{className:"conflict",role:"alert",children:[l.jsxs("div",{className:"conflict__head",children:[l.jsx("span",{className:"conflict__glyph","aria-hidden":"true",children:"⚠"}),"o agente escreveu este arquivo há ",l.jsx(X1,{at:e.changedAt})]}),l.jsx("p",{className:"conflict__why",children:"O disco não é mais o que você abriu, e o que você digitou ainda não foi para lá."}),l.jsxs("div",{className:"conflict__exits",children:[l.jsxs("button",{type:"button",className:"exit",onClick:t,children:[l.jsx("span",{className:"exit__what",children:"recarregar do disco"}),l.jsxs("span",{className:"exit__cost",children:["perde ",gB(n)]})]}),l.jsxs("button",{type:"button",className:"exit",onClick:s,children:[l.jsx("span",{className:"exit__what",children:"sobrescrever"}),l.jsxs("span",{className:"exit__cost",children:["perde a edição do agente",a===null?"":` (+${a.added} −${a.removed})`]})]})]})]})}function gB(e){const t=e.added>0?"digitou":"apagou",s=e.added>0?e.added:e.removed;return s===0?"nada: o seu texto é igual ao que você abriu":s===1?`a linha que você ${t}`:`as ${s} linhas que você ${t}`}function vB({state:e,onRetry:t}){return e.kind==="clean"?null:e.kind==="saving"?l.jsx(Ju,{tone:"saving",children:"salvando…"}):e.kind==="saved"?l.jsxs(Ju,{tone:"saved",children:["salvo há ",l.jsx(X1,{at:e.at})]}):e.kind==="failed"?l.jsxs(l.Fragment,{children:[l.jsx(Ju,{tone:"failed",children:"não deu para salvar"}),l.jsx("span",{className:"save__why",title:e.why,children:e.why}),l.jsx("button",{type:"button",className:"save__act",onClick:t,children:"tentar de novo"})]}):l.jsxs(l.Fragment,{children:[l.jsx(Ju,{tone:"stale",children:"mudou no disco"}),l.jsx("span",{className:"save__why",children:"o autosave parou até você escolher"})]})}function Ju({tone:e,children:t}){return l.jsxs("span",{className:`save save--${e}`,children:[l.jsx("span",{className:"save__dot","aria-hidden":"true"}),t]})}function X1({at:e}){const[t,s]=j.useState(e);j.useEffect(()=>{s(Date.now());const a=window.setInterval(()=>s(Date.now()),1e3);return()=>window.clearInterval(a)},[e]);const n=Math.max(0,Math.round((t-e)/1e3));return l.jsx(l.Fragment,{children:n<60?`${n} s`:`${Math.floor(n/60)} min`})}function yB({path:e,text:t,language:s,readOnly:n,wrap:a,onReady:c}){const h=j.useRef(null),d=j.useRef(null),f=j.useRef(null),m=j.useRef({text:t,wrap:a});return j.useEffect(()=>{m.current.text=t},[t]),j.useEffect(()=>{var g;m.current.wrap=a,(g=d.current)==null||g.setWrap(a)},[a]),j.useEffect(()=>{const g=h.current;if(g===null)return;let v=!0;return Ut(async()=>{const{mountEditor:b}=await import("./codemirror-setup-DJO1HmWW.js");return{mountEditor:b}},[]).then(({mountEditor:b})=>{v&&(d.current=b(g,{doc:m.current.text,wrap:m.current.wrap,readOnly:n}),d.current.setHighlight(f.current),c(d.current))}),()=>{var b;v=!1,c(null),(b=d.current)==null||b.destroy(),d.current=null}},[e,n,c]),j.useEffect(()=>{var v;if(f.current=null,(v=d.current)==null||v.setHighlight(null),s===null)return;let g=!0;return mB(s).then(b=>{var S;!g||b===null||(f.current={highlighter:b,language:s,theme:Q1},(S=d.current)==null||S.setHighlight(f.current))}),()=>{g=!1}},[s]),l.jsx("div",{className:"cmhost",ref:h,"data-testid":"editor"})}function bB({scopeType:e,scopeId:t,onCreated:s}){const n=qe(),a=E_(),c=ye({queryKey:["agentConfig","list"],queryFn:()=>te.agentConfig.list.query()}),h=()=>n.invalidateQueries({queryKey:Hi(e,t)}),d=Te({mutationFn:()=>te.session.createShell.mutate({scopeType:e,scopeId:t}),onSuccess:async v=>{await h(),s(v.id)}}),f=Te({mutationFn:v=>te.session.createAgent.mutate({scopeType:e,scopeId:t,agentConfigId:v}),onSuccess:async v=>{a.close(),await h(),s(v.id)}}),m=d.error??f.error,g=c.data??[];return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"new-session",children:[l.jsxs("button",{type:"button",ref:a.triggerRef,className:"tabs-new","aria-haspopup":"menu","aria-expanded":a.open,disabled:f.isPending||d.isPending,onClick:a.toggle,children:[l.jsx("span",{"aria-hidden":"true",children:"+"})," nova sessão"]}),a.open&&l.jsx("div",{className:"new-session__panel",ref:a.panelRef,children:l.jsxs(b_,{label:"nova sessão",children:[l.jsx(dn,{glyph:l.jsx($e,{tone:"shell",children:"●"}),hint:"shell de login",onSelect:()=>{a.close(),d.mutate()},children:"shell"}),g.map(v=>l.jsx(dn,{glyph:l.jsx($e,{tone:"agent",children:"◆"}),disabled:!v.available||f.isPending,hint:v.available?v.command:"fora do PATH",onSelect:()=>f.mutate(v.id),children:v.name},v.id))]})})]}),m&&l.jsx("div",{className:"new-session__error",children:l.jsx(ke,{tone:"danger",children:m.message})})]})}function J1({lines:e,wrap:t=!0}){return l.jsx("div",{className:`patch${t?"":" patch--nowrap"}`,children:e.map((s,n)=>s.kind==="hunk"?l.jsx("div",{className:"hunk",children:s.text},n):l.jsxs("div",{className:`dl${s.kind==="add"?" dl--add":s.kind==="del"?" dl--del":""}`,children:[l.jsx("span",{className:"dl__sig","aria-hidden":"true",children:s.kind==="add"?"+":s.kind==="del"?"−":" "}),l.jsx("span",{className:"dl__t",children:s.text})]},n))})}function SB(e,t){const s=ax(e??""),n=ax(t);let a=0;for(;a<s.length&&a<n.length&&s[a]===n[a];)a+=1;let c=0;for(;c<s.length-a&&c<n.length-a&&s[s.length-1-c]===n[n.length-1-c];)c+=1;const h=s.slice(a,s.length-c),d=n.slice(a,n.length-c),f=[];a>0&&f.push({kind:"context",text:`… ${a} linha(s) acima, sem mudança`});for(const m of h)f.push({kind:"del",text:m});for(const m of d)f.push({kind:"add",text:m});return c>0&&f.push({kind:"context",text:`… ${c} linha(s) abaixo, sem mudança`}),f}function ax(e){if(e==="")return[];const t=e.split(`
92
+ `);return t.at(-1)===""&&t.pop(),t}function xB({scope:e,path:t,changeRef:s,onClose:n}){const[a,c]=j.useState(!0),h=ye({queryKey:HN(e.scopeType,e.scopeId,s,t),queryFn:()=>te.changes.patch.query({scopeType:e.scopeType,scopeId:e.scopeId,ref:s,path:t}),refetchOnWindowFocus:!0}),d=h.data===void 0?[]:wB(h.data.patch),f=d.filter(g=>g.kind==="hunk").length;return l.jsx(Z1,{path:t,onClose:n,wrap:a,onToggleWrap:()=>c(g=>!g),footLeft:s==="worktree"?"não commitado · vs HEAD":"vs base",footRight:f===0?void 0:`${f} ${f===1?"hunk":"hunks"}`,children:m()});function m(){return h.isPending?l.jsx("div",{className:"patch",children:"carregando…"}):h.isError?l.jsxs("div",{className:"refuse",role:"alert",children:[l.jsx("span",{className:"refuse__glyph","aria-hidden":"true",children:"⚠"}),l.jsx("span",{className:"refuse__title",children:"não deu para ler o diff"}),l.jsx("span",{className:"refuse__why",children:h.error.message})]}):h.data.binary?l.jsxs("div",{className:"refuse",children:[l.jsx("span",{className:"refuse__glyph","aria-hidden":"true",children:"▦"}),l.jsx("span",{className:"refuse__title",children:"arquivo binário"}),l.jsx("span",{className:"refuse__why",children:"o git conta linhas, e aqui não há linhas para contar."})]}):d.length===0?l.jsxs("div",{className:"empty",children:[l.jsx("span",{className:"empty__glyph","aria-hidden":"true",children:"✓"}),l.jsx("span",{className:"empty__title",children:"sem diferenças neste arquivo"})]}):l.jsx(J1,{lines:d,wrap:a})}}function wB(e){var n,a;const t=[];let s=!1;for(const c of e.split(`
93
+ `)){if(c.startsWith("@@")){s=!0,t.push({kind:"hunk",text:c});continue}s&&(c.startsWith("\\")||(c.startsWith("+")?t.push({kind:"add",text:c.slice(1)}):c.startsWith("-")?t.push({kind:"del",text:c.slice(1)}):(c!==""||t.length>0)&&t.push({kind:"context",text:c.slice(1)})))}return((n=t.at(-1))==null?void 0:n.kind)==="context"&&((a=t.at(-1))==null?void 0:a.text)===""&&t.pop(),t}function eC(){return{turns:[],pendingPermission:null,streaming:!1,lastStopReason:null,orphanUpdates:0,plan:null,usage:null,mode:"",configOptions:[],modeOwner:"agent",lumemMode:"ask",lumemModeDefault:"ask",commands:[],terminals:[],turnTally:{auto:0,asked:0}}}function CB(e){return e.reduce(tC,eC())}function tC(e,{at:t,event:s}){var n,a,c,h,d;switch(s.type){case"message":return lx(s.role==="user"?jB(e):e,s.role,{kind:"message",messageId:s.messageId,text:s.text});case"thought":return lx(e,"agent",{kind:"thought",messageId:s.messageId,text:s.text});case"tool_call":return eh(e,"agent",{kind:"tool",call:{toolCallId:s.toolCallId,title:s.title,name:s.name??null,kind:s.kind,status:s.status,locations:s.locations,content:[],elapsedMs:null,added:null,removed:null,verdict:null,verdictBy:"user",verdictReason:null,startedAt:t}});case"tool_call_update":return ox(e,s.toolCallId,f=>({...f,...s.status?{status:s.status}:{},...s.title?{title:s.title}:{},...s.locations?{locations:s.locations}:{},...s.content?EB(f,s.content):{},elapsedMs:t-f.startedAt}));case"permission_request":{const f={requestId:s.requestId,toolCallId:s.toolCallId,title:s.title,command:s.command??null,cwd:s.cwd,options:s.options,policyReason:s.policyReason},m=Jp(e.turns,g=>g.kind==="permission"?null:g);return eh({...e,turns:m,pendingPermission:f,turnTally:{...e.turnTally,asked:e.turnTally.asked+1}},"agent",{kind:"permission",request:f})}case"permission_resolved":{const f=NB(e.turns,s.requestId);if(!f)return{...e,orphanUpdates:e.orphanUpdates+1};const m=s.outcome==="cancelled"?null:s.outcome.optionId,g=m===null?null:f.options.find(S=>S.optionId===m)??null,v=Jp(e.turns,S=>S.kind==="permission"&&S.request.requestId===s.requestId?null:S),b={...e,turns:v,pendingPermission:((n=e.pendingPermission)==null?void 0:n.requestId)===s.requestId?null:e.pendingPermission,turnTally:s.by==="lumem"?{auto:e.turnTally.auto+1,asked:Math.max(0,e.turnTally.asked-1)}:e.turnTally};return g?ox(b,f.toolCallId,S=>({...S,verdict:g,verdictBy:s.by,verdictReason:s.reason})):b}case"plan":return{...e,plan:s.entries};case"plan_removed":return{...e,plan:null};case"usage":{const f=((a=s.cost)==null?void 0:a.amount)??0;return{...e,usage:{used:s.used,size:s.size,cost:s.cost??null,rateLimit:s.rateLimit??null,totalCost:(((c=e.usage)==null?void 0:c.totalCost)??0)+f,currency:((h=s.cost)==null?void 0:h.currency)??((d=e.usage)==null?void 0:d.currency)??null}}}case"config":return{...e,mode:s.mode,configOptions:s.options,modeOwner:s.modeOwner,lumemMode:s.lumemMode,lumemModeDefault:s.lumemModeDefault};case"commands":return{...e,commands:s.commands};case"terminal":{const f=e.terminals.filter(m=>m.terminalId!==s.terminalId);return{...e,terminals:[...f,{terminalId:s.terminalId,ptySessionId:s.ptySessionId,command:s.command}]}}case"turn_end":{const f={...e,streaming:!1,lastStopReason:s.stopReason,turnTally:{auto:0,asked:0}};return e.turnTally.auto===0?f:eh(f,"agent",{kind:"meta",text:kB(e.turnTally)})}case"resumed":return{...e,turns:[...e.turns,{role:"resumed",blocks:[],at:t,fromSessionId:s.fromSessionId}]};case"memory_core":return{...e,turns:[...e.turns,{role:"agent",blocks:[{kind:"meta",text:`memória do workspace: ${String(s.entries)} ${s.entries===1?"diretriz fixada":"diretrizes fixadas"} · ${s.chars.toLocaleString("pt-BR")} caracteres neste turno`}],at:t}]};case"budget":return{...e,turns:[...e.turns,{role:"agent",blocks:[{kind:"meta",text:s.message}],at:t}]};case"unknown":return eh(e,"agent",{kind:"note",text:`evento não reconhecido: ${s.sessionUpdate}`})}}function lx(e,t,s){const n=t==="user"?!0:e.streaming,a=[...e.turns],c=a.at(-1);if((c==null?void 0:c.role)===t){const h=[...c.blocks],d=h.at(-1);return(d==null?void 0:d.kind)===s.kind&&d.messageId===s.messageId?h[h.length-1]={...d,text:d.text+s.text}:h.push(s),a[a.length-1]={...c,blocks:h},{...e,turns:a,streaming:n}}return a.push({role:t,blocks:[s]}),{...e,turns:a,streaming:n}}function jB(e){return{...e,turns:Jp(e.turns,t=>t.kind==="meta"&&t.text.startsWith(sC)?null:t)}}const sC="◈ ";function kB({auto:e,asked:t}){const s=e===1?"1 pedido aprovado":`${e} pedidos aprovados`,n=t===1?"1 subiu para você":`${t} subiram para você`;return`${sC}${s} pelo Lumem, ${n} neste turno`}function eh(e,t,s){const n=[...e.turns],a=n.at(-1);return(a==null?void 0:a.role)===t?n[n.length-1]={...a,blocks:[...a.blocks,s]}:n.push({role:t,blocks:[s]}),{...e,turns:n}}function ox(e,t,s){let n=!1;const a=e.turns.map(c=>({...c,blocks:c.blocks.map(h=>h.kind!=="tool"||h.call.toolCallId!==t?h:(n=!0,{...h,call:s(h.call)}))}));return n?{...e,turns:a}:{...e,orphanUpdates:e.orphanUpdates+1}}function Jp(e,t){return e.map(s=>({...s,blocks:s.blocks.flatMap(n=>{const a=t(n);return a?[a]:[]})}))}function NB(e,t){for(const s of e)for(const n of s.blocks)if(n.kind==="permission"&&n.request.requestId===t)return n.request;return null}function EB(e,t){let s=0,n=0,a=!1;for(const c of t){if(c.type!=="diff")continue;a=!0;const h=cx(c.oldText??""),d=cx(c.newText),f=TB(h,d);s+=d.length-f,n+=h.length-f}return{content:t,added:a?s:e.added,removed:a?n:e.removed}}function cx(e){if(e==="")return[];const t=e.split(`
94
+ `);return t.at(-1)===""&&t.pop(),t}function TB(e,t){const s=new Map;for(const a of e)s.set(a,(s.get(a)??0)+1);let n=0;for(const a of t){const c=s.get(a)??0;c>0&&(s.set(a,c-1),n+=1)}return n}const OB=1;function AB(e,t){return`${t.protocol==="https:"?"wss:":"ws:"}//${t.host}${_T}?${gT}=${encodeURIComponent(e)}`}function RB(e,t,s={}){const{createWebSocket:n=h=>new WebSocket(h),origin:a=window.location}=s,c=n(AB(e,a));return c.onmessage=h=>{var f;const d=BT(String(h.data));d.ok?t.onMessage(d.message):(f=t.onDecodeError)==null||f.call(t,d.error)},c.onclose=h=>{var d;(d=t.onClose)==null||d.call(t,{code:h.code,clean:h.wasClean,refused:h.code===vT})},c.onerror=()=>{},{send(h){var f,m;const d=RT.safeParse(h);if(!d.success){(f=t.onSendRejected)==null||f.call(t,d.error.issues.map(g=>`${g.path.join(".")||"<root>"}: ${g.message}`).join("; "));return}if(c.readyState!==OB){(m=t.onSendRejected)==null||m.call(t,"o socket não está aberto");return}c.send(LT(d.data))},close(){c.onmessage=null,c.onclose=null,c.onopen=null,c.close()}}}const DB={auto:"auto",plan:"plan",bypassPermissions:"bypass"};function MB({mode:e,options:t,disabled:s=!1,onSwitch:n}){const[a,c]=j.useState(null);return l.jsx(l.Fragment,{children:t.map(h=>{const d=h.id==="mode"?e:h.currentValue,f=BB(h,d);return l.jsxs("span",{className:"config",children:[l.jsxs("button",{type:"button",className:`pill${LB(h,d)} focus-ring`,"aria-haspopup":"menu","aria-expanded":a===h.id,"aria-label":`${h.name}: ${f}`,disabled:s,title:s?"não dá para trocar no meio de um turno":`${h.name}: ${f}`,onClick:()=>c(a===h.id?null:h.id),children:[f,l.jsx("span",{className:"pill__caret","aria-hidden":"true",children:"▾"})]}),a===h.id&&l.jsx("div",{className:"slash",role:"menu","aria-label":h.name,children:h.choices.map(m=>l.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":m.value===d,className:`slash__row focus-ring${m.value===d?" slash__row--on":""}${m.value==="bypassPermissions"?" slash__row--danger":""}`,onClick:()=>{c(null),n(h.id,m.value)},children:[l.jsx("span",{className:"slash__cmd",children:m.value}),l.jsx("span",{className:"slash__desc",children:m.description??""})]},m.value))})]},h.id)})})}function BB(e,t){var s;return((s=e.choices.find(n=>n.value===t))==null?void 0:s.name)||t||e.name}function LB(e,t){if(e.id==="mode"){const s=DB[t];return s?` pill--${s}`:""}return e.id==="model"?" pill--model":""}function qB({cwd:e,onCancel:t,onConfirm:s}){const n=j.useRef(null);return j.useEffect(()=>{var a;return(a=n.current)==null?void 0:a.focus()},[]),l.jsxs("div",{className:"gate",role:"dialog","aria-modal":"true","aria-label":"liberar esta sessão",onKeyDown:a=>{a.key==="Escape"&&(a.stopPropagation(),t())},children:[l.jsxs("div",{className:"gate__t",children:[l.jsx("span",{className:"gate__g","aria-hidden":"true",children:"⚠"}),"Liberar esta sessão?"]}),l.jsxs("div",{className:"gate__b",children:["O Lumem vai ",l.jsx("b",{children:"parar de perguntar"})," e responder ",l.jsx("b",{children:"sim"})," a tudo que este agente pedir, até o fim desta conversa."]}),l.jsxs("ul",{className:"gate__list",children:[l.jsx("li",{children:"escrever e apagar arquivos"}),l.jsx("li",{children:"rodar qualquer comando de shell"}),l.jsx("li",{children:l.jsxs("span",{children:["tudo isso dentro de ",l.jsx("span",{className:"gate__scope",children:e})]})})]}),l.jsxs("div",{className:"gate__acts",children:[l.jsxs("button",{type:"button",className:"btn btn--ghost btn--sm focus-ring",ref:n,onClick:t,children:["cancelar ",l.jsx("span",{className:"kbd",children:"esc"})]}),l.jsx("span",{className:"spacer"}),l.jsx("button",{type:"button",className:"btn btn--danger btn--sm focus-ring",onClick:s,children:"liberar esta sessão"})]}),l.jsx("div",{className:"gate__note",children:"Vale só para esta conversa. Uma sessão nova volta a perguntar tudo."})]})}const e_=[{value:"ask",label:"Perguntar tudo",description:"Todo pedido para e espera por você. É o padrão, e nenhuma sessão nasce em outro.",tone:"pill--ask"},{value:"auto",label:"Automático",description:"Leitura de arquivo com caminho dentro do checkout passa sozinha, e aparece na conversa. Escrita e comando ainda perguntam.",tone:"pill--auto"},{value:"free",label:"Liberado",description:"Nada é perguntado dentro da worktree. Pede confirmação antes de valer.",tone:"pill--bypass"}],iC=e=>e_.find(t=>t.value===e)??e_[0];function zB({mode:e,disabled:t=!1,readOnly:s=!1,open:n=!1,onToggle:a}){const c=iC(e);return s?l.jsxs("span",{className:`pill ${c.tone}`,title:"conversa encerrada — o modo em que ela esteve",children:[l.jsx("span",{className:"pill__own","aria-hidden":"true",children:"◈"}),l.jsx("span",{className:"sr-only",children:"regra do Lumem, e a conversa terminou: "}),c.label]}):l.jsxs("button",{type:"button",className:`pill ${c.tone} focus-ring`,"aria-haspopup":"menu","aria-expanded":n,"aria-label":`regra do Lumem: ${c.label}`,disabled:t,title:t?"não dá para trocar no meio de um turno":"regra do Lumem — este agente não oferece modos",onClick:a,children:[l.jsx("span",{className:"pill__own","aria-hidden":"true",children:"◈"}),c.label,l.jsx("span",{className:"pill__caret","aria-hidden":"true",children:"▾"})]})}function PB({mode:e,workspaceDefault:t,onSwitch:s,onFreeRequested:n}){return l.jsxs("div",{className:"mmenu",role:"menu","aria-label":"regra do Lumem",children:[l.jsxs("div",{className:"mmenu__head",children:[l.jsxs("div",{className:"mmenu__who",children:[l.jsx("span",{"aria-hidden":"true",children:"◈"}),"Regra do Lumem"]}),l.jsxs("div",{className:"mmenu__why",children:["este agente não relatou modos. O que muda aqui é ",l.jsx("b",{children:"o que o daemon responde"})," a um pedido de permissão — o agente não fica sabendo."]})]}),e_.map(a=>l.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":a.value===e,className:`mopt focus-ring${a.value===e?" mopt--on":""}${a.value==="auto"?" mopt--auto":""}${a.value==="free"?" mopt--free":""}`,onClick:()=>{if(a.value==="free"){n();return}s(a.value)},children:[l.jsxs("span",{className:"mopt__t",children:[a.label,a.value===e&&l.jsx("span",{className:"mopt__mark","aria-hidden":"true",children:"✓"})]}),l.jsx("span",{className:"mopt__d",children:a.description})]},a.value)),l.jsxs("div",{className:"mmenu__foot",children:["padrão do workspace: ",l.jsx("b",{children:iC(t).label.toLowerCase()})]})]})}const t_=/^\s{0,3}(?:```|~~~)\s*([\w+-]*)\s*$/,rC=/^\s{0,3}(#{1,6})\s+(.*)$/,nC=/^\s{0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/,s_=/^\s{0,3}>\s?(.*)$/,U_=/^(\s*)[-*+]\s+(.*)$/,Th=/^(\s*)\d{1,9}[.)]\s+(.*)$/,Oh=/^\s{0,3}\|(.+)\|\s*$/,HB=/^\s{0,3}\|[\s:|-]+\|\s*$/;function FB(e){const t=e.replace(/\r\n?/g,`
95
+ `).split(`
96
+ `),s=[];let n=0;for(;n<t.length;){const a=t[n];if(a.trim()===""){n+=1;continue}const c=t_.exec(a);if(c){const f=c[1]===""?null:c[1],m=[];for(n+=1;n<t.length&&!t_.test(t[n]);)m.push(t[n]),n+=1;n<t.length&&(n+=1),s.push({kind:"code",language:f,text:m.join(`
97
+ `)});continue}const h=rC.exec(a);if(h){s.push({kind:"heading",level:h[1].length,content:Li(h[2].trim())}),n+=1;continue}if(nC.test(a)){s.push({kind:"rule"}),n+=1;continue}if(s_.test(a)){const f=[];for(;n<t.length;){const m=s_.exec(t[n]);if(!m)break;f.push(m[1]),n+=1}s.push({kind:"quote",content:Li(f.join(`
98
+ `))});continue}if(Oh.test(a)&&n+1<t.length&&HB.test(t[n+1])){const f=ux(a);n+=2;const m=[];for(;n<t.length&&Oh.test(t[n]);)m.push(ux(t[n])),n+=1;s.push({kind:"table",header:f,rows:m});continue}if(U_.test(a)||Th.test(a)){const f=Th.test(a),{items:m,next:g}=UB(t,n,f);s.push({kind:"list",ordered:f,items:m}),n=g;continue}const d=[t[n].trim()];for(n+=1;n<t.length;){const f=t[n];if(f.trim()===""||IB(f))break;d.push(f.trim()),n+=1}s.push({kind:"paragraph",content:Li(d.join(`
99
+ `))})}return s}function IB(e){return t_.test(e)||rC.test(e)||nC.test(e)||s_.test(e)||U_.test(e)||Th.test(e)||Oh.test(e)}function ux(e){return Oh.exec(e)[1].split("|").map(s=>Li(s.trim()))}function UB(e,t,s){const n=[];let a=t,c=null;for(;a<e.length;){const h=e[a];if(h.trim()===""){if(a+1<e.length&&hx(e[a+1])!==null){a+=1;continue}break}const d=hx(h);if(d===null||d.ordered!==s&&d.indent===(c??d.indent))break;if(c??(c=d.indent),d.indent>c){const f=n[n.length-1];if(f===void 0)break;f.children.push({content:Li(d.text),children:[]})}else n.push({content:Li(d.text),children:[]});a+=1}return{items:n,next:a}}function hx(e){const t=U_.exec(e);if(t)return{indent:t[1].length,text:t[2],ordered:!1};const s=Th.exec(e);return s?{indent:s[1].length,text:s[2],ordered:!0}:null}function Li(e){const t=[];let s="";const n=()=>{if(s!==""){for(const[c,h]of s.split(`
100
+ `).entries())c>0&&t.push({kind:"break"}),h!==""&&t.push({kind:"text",text:h});s=""}};let a=0;for(;a<e.length;){const c=e.slice(a),h=/^(`+)([\s\S]*?)\1(?!`)/.exec(c);if(h){n(),t.push({kind:"code",text:h[2].trim()}),a+=h[0].length;continue}const d=/^\[([^\]]*)\]\(([^\s)]+)\)/.exec(c);if(d){n(),t.push({kind:"link",href:d[2],children:Li(d[1])}),a+=d[0].length;continue}const f=/^(\*\*|__)(?=\S)([\s\S]*?\S)\1/.exec(c);if(f){n(),t.push({kind:"strong",children:Li(f[2])}),a+=f[0].length;continue}const m=/^~~(?=\S)([\s\S]*?\S)~~/.exec(c);if(m){n(),t.push({kind:"strike",children:Li(m[1])}),a+=m[0].length;continue}const g=/^(\*)(?=\S)([\s\S]*?\S)\1|^(_)(?=\S)([\s\S]*?\S)\3(?![\w])/.exec(c);if(g&&(g[1]==="*"||a===0||/[^\w]/.test(e[a-1]))){n(),t.push({kind:"em",children:Li(g[2]??g[4])}),a+=g[0].length;continue}s+=e[a],a+=1}return n(),t}function aC({text:e,streaming:t=!1}){const s=FB(e),n=s.length-1,a=l.jsx("span",{className:"mcaret","aria-hidden":"true"});return s.length===0?t?l.jsx("p",{children:a}):null:l.jsx(l.Fragment,{children:s.map((c,h)=>l.jsx(j.Fragment,{children:KB(c,t&&h===n?a:null)},h))})}function KB(e,t){switch(e.kind){case"paragraph":return l.jsxs("p",{children:[l.jsx(Mi,{nodes:e.content}),t]});case"heading":{const s=`h${String(Math.min(e.level,6))}`;return l.jsxs(s,{children:[l.jsx(Mi,{nodes:e.content}),t]})}case"code":return l.jsxs(l.Fragment,{children:[l.jsx("pre",{children:l.jsx("code",{...e.language===null?{}:{"data-language":e.language},children:e.text})}),t]});case"quote":return l.jsxs("blockquote",{children:[l.jsx(Mi,{nodes:e.content}),t]});case"list":{const s=e.ordered?"ol":"ul";return l.jsxs(l.Fragment,{children:[l.jsx(s,{children:e.items.map((n,a)=>l.jsx(lC,{item:n,ordered:e.ordered},a))}),t]})}case"table":return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"table-scroll",children:l.jsxs("table",{children:[l.jsx("thead",{children:l.jsx("tr",{children:e.header.map((s,n)=>l.jsx("th",{children:l.jsx(Mi,{nodes:s})},n))})}),l.jsx("tbody",{children:e.rows.map((s,n)=>l.jsx("tr",{children:s.map((a,c)=>l.jsx("td",{children:l.jsx(Mi,{nodes:a})},c))},n))})]})}),t]});case"rule":return l.jsxs(l.Fragment,{children:[l.jsx("hr",{}),t]})}}function lC({item:e,ordered:t}){const s=t?"ol":"ul";return l.jsxs("li",{children:[l.jsx(Mi,{nodes:e.content}),e.children.length>0&&l.jsx(s,{children:e.children.map((n,a)=>l.jsx(lC,{item:n,ordered:t},a))})]})}function Mi({nodes:e}){return l.jsx(l.Fragment,{children:e.map((t,s)=>l.jsx(j.Fragment,{children:$B(t)},s))})}function $B(e){switch(e.kind){case"text":return e.text;case"code":return l.jsx("code",{children:e.text});case"strong":return l.jsx("strong",{children:l.jsx(Mi,{nodes:e.children})});case"em":return l.jsx("em",{children:l.jsx(Mi,{nodes:e.children})});case"strike":return l.jsx("del",{children:l.jsx(Mi,{nodes:e.children})});case"link":return l.jsx("a",{href:e.href,target:"_blank",rel:"noreferrer",children:l.jsx(Mi,{nodes:e.children})});case"break":return l.jsx("br",{})}}function WB({role:e,children:t}){return l.jsxs("div",{className:`turn turn--${e}`,children:[l.jsx("span",{className:"turn__g",children:l.jsx($e,{tone:e==="agent"?"agent":"none",children:e==="agent"?"◆":"❯"})}),l.jsx("div",{className:"turn__b",children:t})]})}function VB({text:e,streaming:t=!1}){return l.jsx("div",{className:"msg",children:l.jsx(aC,{text:e,streaming:t})})}function YB({text:e,open:t,onToggle:s,streaming:n=!1}){const a=n?"pensando…":"pensou";return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:"thought focus-ring","aria-expanded":t,onClick:s,children:[l.jsx("span",{className:"thought__twist","aria-hidden":"true",children:t?"▾":"▸"}),a,!t&&e!==""&&l.jsxs("span",{className:"thought__peek",children:["· ",e]})]}),t&&l.jsx("div",{className:"thought__text",children:l.jsx(aC,{text:e,streaming:n})})]})}function GB({request:e,onRespond:t}){const[s,n]=j.useState(!1),a=j.useRef(null),c=Dm(e.options,"allow_once")??e.options[0],h=Dm(e.options,"reject_once"),d=Dm(e.options,"reject_always"),f=e.options.filter(g=>g!==c&&g!==h&&g!==d),m=g=>{s||(n(!0),t(g))};return j.useEffect(()=>{var g;(g=a.current)==null||g.focus()},[e.requestId]),j.useEffect(()=>{const g=v=>{if(v.key==="Enter"&&!v.shiftKey){v.preventDefault(),m(c.optionId);return}v.key==="Escape"&&h&&(v.preventDefault(),m(h.optionId))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)}),l.jsxs("div",{className:"perm",role:"group","aria-label":"pedido de permissão",children:[l.jsxs("div",{className:"perm__head",children:[l.jsx("span",{className:"perm__glyph","aria-hidden":"true",children:"⚠"}),"Permissão",l.jsx("span",{className:"spacer"}),l.jsx("span",{className:"kbd",children:s?"enviado":"o turno está parado aqui"})]}),l.jsxs("div",{className:"perm__body",children:[l.jsxs("div",{className:"perm__what",children:[l.jsx("div",{className:"perm__cmd",children:e.command??e.title}),l.jsxs("div",{className:"perm__where",children:["cwd ",e.cwd]})]}),e.policyReason!==null&&l.jsx("div",{className:"perm__why",children:e.policyReason}),l.jsxs("div",{className:"perm__opts",children:[l.jsxs(ce,{ref:a,variant:"primary",size:"sm",disabled:s,onClick:()=>m(c.optionId),children:[c.name," ",l.jsx("span",{className:"kbd",children:"⏎"})]}),f.map(g=>l.jsx(ce,{variant:"ghost",size:"sm",disabled:s,onClick:()=>m(g.optionId),children:g.name},g.optionId)),h&&l.jsxs(ce,{variant:"ghost",size:"sm",disabled:s,onClick:()=>m(h.optionId),children:[h.name," ",l.jsx("span",{className:"kbd",children:"esc"})]}),d&&l.jsx(ce,{variant:"danger",size:"sm",disabled:s,onClick:()=>m(d.optionId),children:d.name})]})]})]})}function Dm(e,t){return e.find(s=>s.kind===t)}const oC="lumem.coach.permission";function QB(){try{return window.localStorage.getItem(oC)==="seen"}catch{return!1}}function ZB(){try{window.localStorage.setItem(oC,"seen")}catch{}}function XB(e){const[t,s]=j.useState(QB),[n,a]=j.useState(!1),c=j.useCallback(()=>a(!0),[]),h=j.useCallback(()=>{ZB(),s(!0)},[]);return{show:e&&!t&&!n,dismiss:c,never:h}}const JB={pending:"○",in_progress:"◐",completed:"✓"},e5={pending:"pending",in_progress:"active",completed:"done"};function t5({entries:e,defaultOpen:t=!1}){const s=e.filter(d=>d.status==="completed").length,n=e.length>0&&s===e.length,[a,c]=j.useState(t),h=!n||a;return l.jsxs("div",{className:"plan",children:[l.jsxs("div",{className:"plan__head",children:[l.jsx("span",{className:`plan__glyph${n?" plan__glyph--done":""}`,"aria-hidden":"true",children:n?"✓":"☰"}),"Plano",l.jsx("span",{className:"spacer"}),l.jsxs("span",{className:"plan__count",children:[s," de ",e.length]}),n&&l.jsx("button",{type:"button",className:"tc__twist focus-ring","aria-expanded":a,"aria-label":a?"esconder os passos":"mostrar os passos",onClick:()=>c(!a),children:a?"▾":"▸"})]}),h&&e.map((d,f)=>l.jsxs("div",{className:`plan__row plan__row--${e5[d.status]}`,children:[l.jsx("span",{className:"plan__mark","aria-hidden":"true",children:JB[d.status]}),l.jsx("span",{className:"plan__what",children:d.content}),d.status==="in_progress"&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"spacer"}),l.jsx("span",{className:"plan__now",children:"agora"})]})]},f))]})}function s5(e){const t=/^\/([^\s]*)$/.exec(e);return t?t[1]:null}function cC(e,t){if(t==="")return e;const s=t.toLowerCase();return e.filter(n=>n.name.toLowerCase().startsWith(s))}function i5({commands:e,query:t,onChoose:s,onDismiss:n}){const a=cC(e,t),[c,h]=j.useState(0);j.useEffect(()=>h(0),[t,e]),j.useEffect(()=>{const f=m=>{if(a.length!==0){if(m.key==="ArrowDown"){m.preventDefault(),h(g=>(g+1)%a.length);return}if(m.key==="ArrowUp"){m.preventDefault(),h(g=>(g-1+a.length)%a.length);return}if(m.key==="Enter"&&!m.metaKey&&!m.ctrlKey){m.preventDefault(),m.stopPropagation(),d(a[c]);return}m.key==="Escape"&&(m.preventDefault(),n())}};return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)});function d(f){s(`/${f.name}${f.takesInput?" ":""}`)}return a.length===0?null:l.jsx("div",{className:"slash",role:"listbox","aria-label":"comandos do agente",children:a.map((f,m)=>l.jsxs("button",{type:"button",role:"option","aria-selected":m===c,className:`slash__row focus-ring${m===c?" slash__row--on":""}`,onMouseDown:g=>{g.preventDefault(),d(f)},children:[l.jsxs("span",{className:"slash__cmd",children:["/",f.name]}),l.jsx("span",{className:"slash__desc",children:f.description})]},f.name))})}const r5={read:"▤",search:"▤",edit:"▣",delete:"▣",move:"▣",execute:"❯",fetch:"↓",think:"◈",switch_mode:"◈",other:"◈"},n5={pending:"na fila",running:"rodando",ok:"ok",failed:"falhou",cancelled:"interrompido"},a5=12;function l5({call:e,terminals:t=[],defaultOpen:s=!1}){const[n,a]=j.useState(s),c=o5(e),h=u5(e),d=c5(e,t);return l.jsxs("div",{className:`tc tc--${e.status}`,children:[l.jsxs("div",{className:"tc__head",children:[l.jsx("span",{className:"tc__glyph","aria-hidden":"true",children:r5[e.kind]}),l.jsx("span",{className:"tc__verb",children:e.name??d5(e.title)}),h?l.jsxs("span",{className:"tc__target",title:h.full,children:[l.jsx("span",{className:"tc__dir",children:h.dir}),l.jsx("span",{className:"tc__name",children:h.name})]}):l.jsx("span",{className:"tc__arg",title:e.title,children:h5(e)}),e.verdict&&l.jsx("span",{className:`verdict verdict--${e.verdictBy==="lumem"?"lumem":e.verdict.kind.startsWith("allow")?"allowed":"denied"}`,children:e.verdictBy==="lumem"?l.jsxs(l.Fragment,{children:[l.jsx("span",{"aria-hidden":"true",children:"◈"})," o Lumem aprovou"]}):l.jsxs(l.Fragment,{children:[e.verdict.kind.startsWith("allow")?"✓":"✕"," ",e.verdict.name]})}),(e.added!==null||e.removed!==null)&&l.jsxs("span",{className:"tc__delta",children:[e.added?l.jsxs("span",{className:"plus",children:["+",e.added]}):null,e.added&&e.removed?" ":null,e.removed?l.jsxs("span",{className:"minus",children:["−",e.removed]}):null]}),e.elapsedMs!==null&&l.jsx("span",{className:"tc__time",children:f5(e.elapsedMs)}),l.jsxs("span",{className:"tc__st",children:[l.jsx("span",{className:"tc__dot","aria-hidden":"true"}),n5[e.status]]}),(c||d)&&l.jsx("button",{type:"button",className:"tc__twist focus-ring","aria-expanded":n,"aria-label":n?"esconder o resultado":"mostrar o resultado",onClick:()=>a(!n),children:n?"▾":"▸"})]}),e.verdictBy==="lumem"&&e.verdictReason!==null&&l.jsx("div",{className:"tc__why",children:e.verdictReason}),n&&d&&l.jsx("div",{className:"tc__body",children:l.jsx("div",{className:"tc__term",children:l.jsx(Lh,{sessionId:d.ptySessionId})})}),n&&!d&&c&&l.jsxs("div",{className:"tc__body",children:[c.kind==="diff"?l.jsx(J1,{lines:c.lines,wrap:!1}):l.jsx("div",{className:"out",children:c.lines.map((f,m)=>l.jsx("span",{className:"l",children:f},m))}),c.hidden>0&&l.jsxs("div",{className:"tc__more",children:["▾ mostrar as ",c.hidden.toLocaleString("pt-BR")," linhas"]})]})]})}function o5(e){const t=e.content.find(c=>c.type==="diff");if((t==null?void 0:t.type)==="diff")return{kind:"diff",lines:SB(t.oldText,t.newText),hidden:0};const s=e.content.filter(c=>c.type==="content").map(c=>c.text).join("");if(s==="")return null;const n=s.split(`
101
+ `),a=n.slice(Math.max(0,n.length-a5));return{kind:"text",lines:a,hidden:n.length-a.length}}function c5(e,t){const s=e.content.find(n=>n.type==="terminal");return(s==null?void 0:s.type)!=="terminal"?null:t.find(n=>n.terminalId===s.terminalId)??null}function u5(e){const t=e.locations[0];if(!t)return null;const s=t.path.lastIndexOf("/");return s===-1?{dir:"",name:t.path,full:t.path}:{dir:t.path.slice(0,s+1),name:t.path.slice(s+1),full:t.path}}function h5(e){const t=e.name;return t&&e.title.startsWith(`${t} `)?e.title.slice(t.length+1):e.title}function d5(e){const t=e.indexOf(" ");return t===-1?e:e.slice(0,t)}function f5(e){if(e<1e3)return`${e} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1).replace(".",",")} s`;const s=Math.floor(t/60),n=Math.round(t-s*60);return n===0?`${s} min`:`${s} min ${n} s`}const uC={conversation:eC(),session:null,failure:null};function m5(e,t){if(t.kind==="reset")return uC;const s=t.message;switch(s.type){case"attached":return{conversation:{...CB(s.transcript),mode:s.mode,configOptions:s.configOptions,modeOwner:s.modeOwner,lumemMode:s.lumemMode,lumemModeDefault:s.lumemModeDefault},session:{acpSessionId:s.acpSessionId,model:s.model,mode:s.mode,state:s.state,cwd:s.cwd},failure:null};case"event":return{...e,conversation:tC(e.conversation,{at:s.at,event:s.event})};case"error":return{...e,failure:{message:s.message,remedy:s.remedy??null,fatal:s.code==="ADAPTER_UNAVAILABLE"||s.code==="SESSION_NOT_FOUND"}}}}const p5=e=>te.session.transcript.query({id:e});function _5({sessionId:e,agentName:t="agente",live:s=!0,connect:n=RB,load:a=p5,onResume:c,resuming:h=!1,active:d=!0,initialPrompt:f,initialDraft:m}){const[g,v]=j.useReducer(m5,uC),[b,S]=j.useState(m??""),[x,w]=j.useState(!1),[k,N]=j.useState(!1),[L,R]=j.useState(new Set),D=j.useRef(null),Y=I_(),{conversation:K,session:Z,failure:Q}=g,z=K.pendingPermission,G=XB(z!==null),le=!s||(Z==null?void 0:Z.state)==="exited";j.useEffect(()=>{if(v({kind:"reset"}),!s){let ae=!0;return a(e).then(V=>{ae&&v({kind:"message",message:V})}).catch(V=>{ae&&v({kind:"message",message:{type:"error",code:"INTERNAL",message:V instanceof Error?V.message:"não deu para ler a conversa"}})}),()=>{ae=!1}}const U=n(e,{onMessage:ae=>v({kind:"message",message:ae})});return D.current=U,()=>{D.current=null,U.close()}},[e,s,n,a]),j.useEffect(()=>{Y.setWaiting(e,z!==null)},[Y,e,z]);const H=j.useRef(Y.setWaiting);H.current=Y.setWaiting,j.useEffect(()=>()=>{H.current(e,!1)},[e]);const O=Z!==null,W=!K.streaming&&O;j.useEffect(()=>{W||(N(!1),w(!1))},[W]);const ee=j.useCallback(()=>{var ae;const U=b.trim();U===""||z!==null||le||!O||((ae=D.current)==null||ae.send({type:"prompt",text:U}),S(""))},[O,b,z,le]),T=j.useRef(!1);j.useEffect(()=>{var U;f===void 0||T.current||!O||le||(T.current=!0,(U=D.current)==null||U.send({type:"prompt",text:f}))},[O,f,le]);const F=s5(b),J=j.useCallback(()=>{var U;(U=D.current)==null||U.send({type:"cancel"})},[]),ve=K.streaming,oe=F!==null&&cC(K.commands,F).length>0;j.useEffect(()=>{if(!d||le||!ve||z!==null||oe)return;const U=ae=>{ae.key==="Escape"&&(ae.preventDefault(),J())};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[d,le,ve,z,oe,J]);const M=S5();return l.jsxs("div",{className:"conv",children:[l.jsxs("div",{className:"conv__head",children:[l.jsxs("span",{className:"conv__who",children:[l.jsx($e,{tone:"agent",children:"◆"}),t]}),Z&&l.jsxs("span",{className:"conv__adapter",children:["sessão ",Z.acpSessionId.slice(0,8)," · ",Z.model," · ",Z.mode]}),l.jsx("span",{className:"spacer"}),le&&c&&l.jsx(ce,{variant:"primary",size:"sm",disabled:h,onClick:c,children:h?"retomando…":"↻ retomar"}),K.streaming&&!le&&l.jsxs(ce,{variant:"ghost",size:"sm",onClick:J,children:["■ interromper ",l.jsx("span",{className:"kbd",children:"esc"})]})]}),l.jsxs("div",{className:"conv__scroll",ref:M,children:[(Q==null?void 0:Q.fatal)&&l.jsxs("div",{className:"fail",children:[l.jsxs("div",{className:"fail__title",children:[l.jsx("span",{"aria-hidden":"true",children:"⚠"}),Q.remedy?"o adaptador ACP não subiu":"a sessão não está disponível"]}),l.jsx("div",{className:"fail__body",children:Q.message}),Q.remedy&&l.jsx("div",{className:"fail__cmd",children:Q.remedy})]}),Q&&!Q.fatal&&l.jsx(ke,{tone:"danger",children:Q.message}),K.turns.length===0&&!Q&&l.jsx(b5,{ready:Z!==null}),K.plan&&l.jsx(t5,{entries:K.plan}),K.turns.map((U,ae)=>U.role==="resumed"?l.jsx(g5,{at:U.at??null},ae):l.jsx(WB,{role:U.role,children:U.blocks.map((V,de)=>l.jsx(y5,{block:V,terminals:K.terminals,streaming:K.streaming&&ae===K.turns.length-1&&de===U.blocks.length-1,openThoughts:L,onToggleThought:_e=>R(Ae=>{const nt=new Set(Ae);return nt.has(_e)?nt.delete(_e):nt.add(_e),nt}),onRespond:_e=>{var nt;const Ae=K.pendingPermission;Ae&&((nt=D.current)==null||nt.send({type:"permission_response",requestId:Ae.requestId,optionId:_e}))},coach:G},de))},ae)),le&&Z&&l.jsx("div",{className:"daysep",children:"conversa encerrada"})]}),K.usage&&l.jsx(SA,{usage:K.usage}),l.jsxs("div",{className:"composer",children:[x&&W&&l.jsx(qB,{cwd:(Z==null?void 0:Z.cwd)??"",onCancel:()=>w(!1),onConfirm:()=>{var U;w(!1),(U=D.current)==null||U.send({type:"set_lumem_mode",mode:"free"})}}),l.jsxs("div",{className:"composer__box",children:[F!==null&&l.jsx(i5,{commands:K.commands,query:F,onChoose:S,onDismiss:()=>S("")}),l.jsx("textarea",{className:`composer__in${b===""?" composer__in--empty":""}`,value:b,disabled:z!==null||le,placeholder:le?"esta conversa terminou — retome para continuar":z!==null?"responda o pedido de permissão para continuar":"escreva, ou / para comandos","aria-label":"mensagem para o agente",onChange:U=>S(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.shiftKey||U.nativeEvent.isComposing||(U.preventDefault(),ee()))}}),l.jsxs("div",{className:"composer__bar",children:[K.modeOwner==="lumem"&&l.jsxs("span",{className:"config",children:[l.jsx(zB,{mode:K.lumemMode,disabled:!W,readOnly:le,open:k,onToggle:()=>N(!k)}),k&&W&&l.jsx(PB,{mode:K.lumemMode,workspaceDefault:K.lumemModeDefault,onSwitch:U=>{var ae;N(!1),(ae=D.current)==null||ae.send({type:"set_lumem_mode",mode:U})},onFreeRequested:()=>{N(!1),w(!0)}})]}),l.jsx(MB,{mode:K.mode,options:K.configOptions,disabled:K.streaming||le,onSwitch:(U,ae)=>{var V;return(V=D.current)==null?void 0:V.send({type:"set_config",optionId:U,value:ae})}}),l.jsx("span",{className:"spacer"}),l.jsxs(ce,{variant:"primary",size:"sm",disabled:b.trim()===""||z!==null||le||!O,onClick:ee,children:["enviar ",l.jsx("span",{className:"kbd",children:"⏎"})]})]})]})]})]})}function g5({at:e}){return l.jsxs("div",{className:"daysep",children:["retomada",e===null?"":` · ${v5(e)}`]})}function v5(e){return new Date(e).toLocaleString("pt-BR",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"})}function y5({block:e,terminals:t,streaming:s,openThoughts:n,onToggleThought:a,onRespond:c,coach:h}){switch(e.kind){case"message":return l.jsx(VB,{text:e.text,streaming:s});case"thought":return l.jsx(YB,{text:e.text,open:n.has(e.messageId),onToggle:()=>a(e.messageId),streaming:s});case"tool":return l.jsx(l5,{call:e.call,terminals:t});case"permission":return l.jsxs(l.Fragment,{children:[l.jsx(GB,{request:e.request,onRespond:c}),h.show&&l.jsxs(A2,{title:"a primeira vez que isso aparece",onUnderstood:h.dismiss,onNever:h.never,children:["É assim que o Lumem te mantém no controle: o modo ",l.jsx("b",{children:"Auto"})," resolve sozinho o que é leitura e escrita dentro desta worktree, e para em tudo que sai disso — rede, comando global, arquivo fora dela. Para ver o plano antes de qualquer execução, troque para"," ",l.jsx("b",{children:"Plano"})," na barra acima."]})]});case"note":return l.jsx("div",{className:"unknown",children:e.text});case"meta":return l.jsx("div",{className:"meta",children:e.text})}}function b5({ready:e}){return l.jsxs("div",{className:"empty",children:[l.jsx("span",{className:"empty__glyph","aria-hidden":"true",children:"◆"}),l.jsx("span",{className:"empty__title",children:e?"sessão aberta, nada pedido ainda":"conectando…"}),e&&l.jsxs("span",{className:"empty__sub",children:["O adaptador subiu e o handshake passou sem consumir nada. O primeiro turno já entra com"," ",l.jsx("b",{children:"39,2k"})," de contexto — system prompt e ferramentas do próprio Claude Code, não do Lumem."]})]})}function S5(){const e=j.useRef(!0),t=j.useRef(null);return j.useCallback(s=>{var h;if((h=t.current)==null||h.call(t),t.current=null,!s)return;const n=()=>{e.current&&(s.scrollTop=s.scrollHeight)},a=()=>{e.current=s.scrollHeight-s.scrollTop-s.clientHeight<24};s.addEventListener("scroll",a,{passive:!0});const c=new MutationObserver(n);c.observe(s,{childList:!0,subtree:!0,characterData:!0}),n(),t.current=()=>{s.removeEventListener("scroll",a),c.disconnect()}},[])}const x5=.2,w5=.8;function hC({children:e,viewer:t}){const[s,n]=j.useState(.5),a=j.useRef(null),[c,h]=j.useState(!1),d=j.useCallback(f=>{var v;const m=(v=a.current)==null?void 0:v.getBoundingClientRect();if(m===void 0||m.width===0||!Number.isFinite(f))return;const g=(f-m.left)/m.width;n(Math.min(w5,Math.max(x5,g)))},[]);return j.useEffect(()=>{if(!c)return;const f=g=>{g.preventDefault(),d(g.clientX)},m=()=>h(!1);return window.addEventListener("pointermove",f),window.addEventListener("pointerup",m),()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",m)}},[c,d]),t===null?l.jsx(l.Fragment,{children:e}):l.jsxs("div",{className:"split",ref:a,children:[l.jsx("div",{className:"split__side split__side--term",style:{flexGrow:s},children:e}),l.jsx("span",{className:"split__grip",role:"separator","aria-orientation":"vertical","aria-label":"largura do arquivo aberto",onPointerDown:f=>{f.preventDefault(),h(!0)}}),l.jsx("div",{className:"split__side split__side--viewer",style:{flexGrow:1-s},children:t})]})}function C5({tab:e,scope:t,cwd:s,active:n,viewer:a=null,onResume:c,resuming:h=!1,onStarted:d,initialPrompt:f,initialDraft:m}){const g=e.kind==="agent",v=e.transport==="acp",b=!v&&e.state!=="running";return l.jsx("div",{className:`pane ${v?"pane--conv":"pane--term"}`,role:"tabpanel",hidden:!n,"aria-label":b?`registro de ${e.label}`:`sessão ${e.label}`,children:l.jsxs(hC,{viewer:a,children:[!v&&l.jsxs("div",{className:"term-head",children:[l.jsx($e,{tone:g?"agent":"shell",children:g?"◆":"●"}),l.jsxs("span",{className:"term-head__cmd",title:`${e.command} · cwd ${s}`,children:[e.command," ",l.jsxs("span",{className:"dim",children:["· cwd ",s]})]}),b?l.jsxs(l.Fragment,{children:[l.jsx(kt,{tone:"neutral",children:"registro"}),l.jsxs(kt,{tone:e.exitCode===0?"exited":"failed",dot:!0,children:["exited (",e.exitCode??"?",")"]})]}):l.jsx(kt,{tone:"running",dot:!0,children:"running"})]}),b&&l.jsx(j5,{tab:e,scope:t,onStarted:d}),v?l.jsx(_5,{sessionId:e.sessionId,agentName:e.label,live:e.state==="running",active:n,...c?{onResume:c}:{},resuming:h,initialDraft:m,initialPrompt:f},e.sessionId):l.jsx(Lh,{sessionId:e.sessionId,readOnly:b},e.sessionId)]})})}function j5({tab:e,scope:t,onStarted:s}){const n=qe(),a=Te({mutationFn:()=>e.agentConfigId===null?te.session.createShell.mutate(t):te.session.createAgent.mutate({...t,agentConfigId:e.agentConfigId}),onSuccess:async c=>{await n.invalidateQueries({queryKey:Hi(t.scopeType,t.scopeId)}),s(c.id)}});return l.jsxs("div",{className:"term-note",children:[l.jsx(ke,{tone:"info",actions:l.jsx(ce,{size:"sm",variant:"default",disabled:a.isPending,onClick:()=>a.mutate(),children:"nova sessão igual"}),children:"Esta sessão encerrou. O que está abaixo é o registro do que ela imprimiu, somente leitura — o processo não existe mais e não há o que digitar."}),a.isError&&l.jsx(ke,{tone:"danger",children:a.error.message})]})}function i_({scope:e,crumb:t,checkout:s,context:n,filesPanel:a,cwd:c,openSessionId:h,initialPrompt:d,initialDraft:f}){const m=qe(),{tabs:g,activeId:v,select:b,close:S,reopen:x,resume:w,resuming:k,sessions:N}=iB(e),L=I_(),R=N_(),D=j.useRef(!1);j.useEffect(()=>{h===void 0||D.current||g.some(G=>G.sessionId===h)&&(D.current=!0,b(h))},[h,g,b]);const Y=eS(e.scopeType,e.scopeId,v);j.useEffect(()=>{R.setActiveTab(Y)},[Y,R.setActiveTab]);function K(G){const le=eS(e.scopeType,e.scopeId,G),H=R.fileFor(le);return H===null?null:H.view==="patch"?l.jsx(xB,{scope:e,path:H.path,changeRef:H.ref??"worktree",onClose:()=>R.close(le)}):l.jsx(pB,{scope:e,path:H.path,active:G===v,onClose:()=>R.close(le)})}const Z=Te({mutationFn:G=>te.session.close.mutate({id:G}),onSuccess:()=>m.invalidateQueries({queryKey:Hi(e.scopeType,e.scopeId)})}),Q=N.data??[],z=new Set(g.map(G=>G.sessionId));return l.jsxs("section",{className:"scope",children:[l.jsx("div",{className:"scope__crumb",children:t}),l.jsx(D2,{label:`sessões de ${c}`,lead:l.jsx(N0,{label:s.name,glyph:s.glyph,active:v===null,onSelect:()=>b(null),...s.state!==void 0?{state:s.state}:{},...s.stateLabel!==void 0?{stateLabel:s.stateLabel}:{}}),action:l.jsx(bB,{scopeType:e.scopeType,scopeId:e.scopeId,onCreated:G=>b(G)}),end:l.jsx(M2,{label:"a coluna de arquivos",pressed:a.open,onToggle:a.toggle,children:"▤"}),children:g.map(G=>l.jsx(N0,{label:G.label,ordinal:G.ordinal,glyph:l.jsx($e,{tone:G.kind==="agent"?"agent":"shell",children:G.kind==="agent"?"◆":"●"}),state:L.isWaiting(G.sessionId)?"asking":G.state==="running"?"running":G.exitCode===0?"exited":"failed",note:G.state==="running"?void 0:"registro",active:v===G.sessionId,onSelect:()=>b(G.sessionId),onClose:()=>{G.state==="running"?Z.mutate(G.sessionId):S(G.sessionId)}},G.sessionId))}),l.jsx("div",{className:"pane",role:"tabpanel",hidden:v!==null,"aria-label":s.name,children:l.jsxs(hC,{viewer:K(null),children:[Z.isError&&l.jsx("div",{className:"detail__banner",children:l.jsx(ke,{tone:"danger",children:Z.error.message})}),n,l.jsxs("section",{className:"section",children:[l.jsx(bn,{title:"Sessões",count:Q.length===0?0:`${Q.length} · ${Q.filter(G=>G.state==="running").length} rodando`}),Q.length===0?l.jsx("p",{className:"detail__hint",children:"nenhuma sessão aberta aqui"}):Q.map(G=>{const le=G.state==="running",H=z.has(G.id);return l.jsx(ww,{name:G.agentName??G.scriptName??"shell",glyph:l.jsx($e,{tone:G.kind==="agent"?"agent":"shell",children:G.kind==="agent"?"◆":G.kind==="script"?"▶":"●"}),detail:G.command,state:le?{label:"running",tone:"running"}:{label:`exited (${G.exitCode??"?"})`,tone:G.exitCode===0?"exited":"failed"},age:xh(G.createdAt),onSelect:H?()=>b(G.id):void 0,action:H?void 0:l.jsx(ce,{size:"sm",variant:"ghost",onClick:()=>x(G.id),children:G.transport==="acp"?"reabrir":"ver registro"})},G.id)})]})]})}),g.map(G=>l.jsx(C5,{tab:G,scope:e,cwd:c,onStarted:b,active:v===G.sessionId,viewer:K(G.sessionId),...G.transport==="acp"?{onResume:()=>w(G.sessionId)}:{},resuming:k===G.sessionId,initialPrompt:(d==null?void 0:d.sessionId)===G.sessionId?d.text:void 0,initialDraft:(f==null?void 0:f.sessionId)===G.sessionId?f.text:void 0},G.sessionId))]})}function k5({projectId:e}){var h,d;const[t,s]=j.useState("7d"),n=mO(e,t),a=[...(((h=n.data)==null?void 0:h.worktrees)??[]).map(f=>({id:f.worktreeId,name:f.name,tokens:f.tokens,cost:f.cost,currency:f.currency,turns:f.turns,kind:"worktree"}))],c=(d=n.data)==null?void 0:d.outside;return c!==void 0&&(c.turns>0||a.length>0)&&a.push({id:"__outside__",name:"direto no projeto",tokens:c.tokens,cost:c.cost,currency:c.currency,turns:c.turns,kind:"project",outside:!0}),l.jsxs("section",{className:"section",children:[l.jsx(bn,{title:"Consumo por worktree",aside:l.jsx("div",{className:"seg",role:"group","aria-label":"Janela de tempo do consumo do projeto",children:Pw.map(f=>l.jsx("button",{type:"button",className:"seg__btn","aria-pressed":t===f.id,onClick:()=>s(f.id),children:f.label},f.id))})}),n.isError?l.jsx(ke,{tone:"danger",children:n.error.message}):n.isPending?l.jsx("p",{className:"detail__hint",children:"somando o consumo…"}):a.length===0?l.jsx("p",{className:"detail__hint",children:"nada gasto ainda neste projeto"}):l.jsx(Ww,{rows:a})]})}function N5(e,t){const s=[];return e===null?s.push("as worktrees dele"):e>0&&s.push(e===1?"1 worktree":`${e} worktrees`),t>0&&s.push(t===1?"1 tarefa":`${t} tarefas`),s.join(" e ")}function E5(e,t,s){const n=N5(t,s);return n===""?`remover ${e} da lista?`:`remover ${e} da lista, e o registro de ${n}?`}function T5({projectId:e,workspaceId:t,workspaceName:s,onRemoved:n,onOpenWorkspace:a,onSelectWorktree:c,openSessionId:h,initialPrompt:d,initialDraft:f,filesPanel:m}){var Z,Q,z;const g=qe(),v={scopeType:"project",scopeId:e},b=ye({queryKey:["project","get",e],queryFn:()=>te.project.get.query({id:e})}),S=ye({queryKey:gr(e),queryFn:()=>te.worktree.listByProject.query({projectId:e}),enabled:((Z=b.data)==null?void 0:Z.available)===!0}),x=ye({queryKey:["task","listByWorkspace",t,e],queryFn:()=>te.task.listByWorkspace.query({workspaceId:t,projectId:e})}),[w,k]=j.useState(!1),N=Te({mutationFn:()=>te.project.remove.mutate({id:e}),onSuccess:async()=>{await g.invalidateQueries({queryKey:gn(t)}),n()}});if(w&&b.data)return l.jsx(O5,{project:b.data,worktrees:((Q=S.data)==null?void 0:Q.length)??null,tasks:((z=x.data)==null?void 0:z.length)??0,pending:N.isPending,error:N.isError?N.error.message:null,onCancel:()=>{k(!1),N.reset()},onConfirm:()=>N.mutate()});if(b.isPending)return l.jsx("div",{className:"pane",children:l.jsx(ys,{label:"carregando o projeto"})});if(!b.data)return l.jsx("div",{className:"pane",children:l.jsx("p",{role:"alert",children:"projeto não encontrado"})});const{name:L,path:R,defaultBranch:D,available:Y}=b.data,K=S.data??[];return l.jsx(i_,{scope:v,cwd:R,openSessionId:h,initialPrompt:d,initialDraft:f,filesPanel:m,crumb:l.jsxs("nav",{className:"crumb","aria-label":"Caminho",children:[l.jsx("button",{type:"button",className:"crumb__up focus-ring",onClick:a,children:s}),l.jsx("span",{className:"crumb__sep","aria-hidden":"true",children:"/"}),L,l.jsx("span",{className:"crumb__sep","aria-hidden":"true",children:"/"}),l.jsx("span",{className:"crumb__here",children:"local"})]}),checkout:{name:"local",glyph:l.jsx($e,{tone:Y?"project":"off",children:"▭"})},context:l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"detail__title",children:[l.jsxs("h2",{children:[l.jsx($e,{tone:Y?"project":"off",children:"▭"})," local"]}),l.jsx("span",{className:"detail__kind",children:"checkout do projeto"}),l.jsx("span",{className:"actions__spacer"}),l.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>k(!0),disabled:N.isPending,children:N.isPending?"removendo…":"remover projeto"})]}),Y?l.jsx("div",{className:"detail__banner",children:l.jsxs(ke,{tone:"info",children:[l.jsx("strong",{children:"Este é o repositório em si, não uma worktree do Lumem."})," Remover o projeto tira o registro — o diretório e o que está dentro dele ficam no disco."]})}):l.jsx("div",{className:"detail__banner",children:l.jsxs(ke,{tone:"danger",children:[l.jsxs("strong",{children:["O repositório não está mais em ",R,"."]})," As ações sobre ele ficam bloqueadas até que ele volte; o registro continua aqui."]})}),N.isError&&l.jsx("div",{className:"detail__banner",children:l.jsx(ke,{tone:"danger",children:N.error.message})}),l.jsx(ma,{entries:[{label:"branch base",value:l.jsxs(l.Fragment,{children:[l.jsx(kt,{tone:"branch",dot:!0,children:D})," ",l.jsx("span",{className:"dim",children:"resolvida na adição"})]})},{label:"caminho",value:l.jsx(xw,{path:R})},...Y?[{label:"worktrees",value:l.jsxs("span",{className:"dim",children:[K.length," ",K.length===1?"worktree":"worktrees"]})}]:[]]}),Y&&l.jsxs(l.Fragment,{children:[l.jsx(k5,{projectId:e}),l.jsxs("section",{className:"section",children:[l.jsx(bn,{title:"Worktrees deste projeto",count:K.length}),K.length===0?l.jsx("p",{className:"detail__hint",children:"nenhuma worktree ainda"}):K.map(G=>l.jsx(ww,{name:G.name,glyph:l.jsx($e,{tone:G.state==="missing"?"warn":"worktree",children:G.state==="missing"?"⚠":"◇"}),detail:G.path,state:G.state==="missing"?{label:"ausente",tone:"missing"}:void 0,onSelect:()=>c(G.id)},G.id))]})]})]})})}function O5({project:e,worktrees:t,tasks:s,pending:n,error:a,onCancel:c,onConfirm:h}){return l.jsx("div",{className:"pane",children:l.jsxs("div",{className:"remove-confirm",role:"alertdialog","aria-label":"confirmar remoção",children:[e.managed?l.jsxs(l.Fragment,{children:[l.jsxs("h2",{className:"remove-confirm__title",children:["apagar ",e.name," do disco?"]}),l.jsxs("p",{className:"remove-confirm__body",children:["Este projeto foi clonado pelo Lumem. Remover tira do registro ",l.jsx("strong",{children:"e apaga o diretório"}),". Não dá para desfazer."]}),l.jsx("p",{className:"remove-confirm__path",children:e.path})]}):l.jsxs(l.Fragment,{children:[l.jsx("h2",{className:"remove-confirm__title",children:E5(e.name,t,s)}),l.jsxs("p",{className:"remove-confirm__body",children:["Este projeto aponta para um repositório ",l.jsx("strong",{children:"seu"}),". Sai da lista; o diretório fica exatamente onde está — o dele e o de cada worktree, com trabalho não commitado e tudo."]})]}),a!==null&&l.jsx(ke,{tone:"danger",children:a}),l.jsxs("div",{className:"remove-confirm__actions",children:[l.jsx(ce,{variant:e.managed?"danger":"primary",onClick:h,disabled:n,children:n?"removendo…":e.managed?"apagar":"remover"}),l.jsx(ce,{variant:"ghost",onClick:c,children:"cancelar"})]})]})})}function A5(e){const t=ye({queryKey:gn(e.workspaceId),queryFn:()=>te.project.listByWorkspace.query({workspaceId:e.workspaceId})});return l.jsxs("div",{className:"tree","aria-label":"árvore de projetos",children:[l.jsxs("div",{className:"tree__head",children:[l.jsx("p",{className:"tree__label",children:"Projetos"}),l.jsx("button",{type:"button",className:"act","aria-label":"adicionar projeto",onClick:e.onAddProject,children:"+"})]}),s()]});function s(){if(t.isError)return l.jsx("p",{className:"tree__message",role:"alert",children:t.error.message});if(t.isPending)return l.jsx(ys,{label:"carregando os projetos",widths:["80%","60%","70%"]});const n=t.data??[];return n.length===0?l.jsx(hs,{title:"Nenhum projeto aqui",children:"Aponte para a raiz de um repositório git no disco, ou cole uma URL para clonar."}):n.map(a=>l.jsx(R5,{project:a,...e},a.id))}}function R5({project:e,expansion:t,selection:s,onSelect:n,onCreateWorktree:a}){const c=t.isExpanded(e.id),h={scopeType:"project",scopeId:e.id},d=ye({queryKey:gr(e.id),queryFn:()=>te.worktree.listByProject.query({projectId:e.id}),enabled:e.available}),f=d.data??[],m=[h,...f.map(S=>({scopeType:"worktree",scopeId:S.id}))],g=A_(m),v=OA(e.available&&c?e.id:null),b=S=>(v.data??[]).find(x=>x.worktreeId===S);return l.jsxs(l.Fragment,{children:[l.jsx("div",{"data-kind":"project","data-state":e.available?"available":"missing",children:l.jsx(Yo,{depth:0,emphasis:!0,label:e.name,glyph:l.jsx($e,{tone:e.available?"project":"off",children:"■"}),muted:!e.available,meta:e.available?void 0:"sem disco",count:!c&&g>0?g:void 0,expanded:c,onToggle:()=>t.toggle(e.id),reserveAction:!0,...e.available?{action:l.jsx("button",{type:"button",className:"row__act","aria-label":`nova worktree em ${e.name}`,onClick:()=>a(e),children:"+"})}:{},selected:!1,onSelect:()=>n(e.id,h)})}),c&&e.available&&l.jsxs(l.Fragment,{children:[l.jsx(D5,{projectId:e.id,selected:s.scopeType==="project"&&s.scopeId===e.id,onSelect:()=>n(e.id,h)}),d.isError&&l.jsx("p",{className:"tree__message",role:"alert",children:d.error.message}),f.map(S=>l.jsx(q5,{projectId:e.id,worktree:S,mark:b(S.id),selected:s.scopeType==="worktree"&&s.scopeId===S.id,onSelect:n},S.id))]})]})}function D5({projectId:e,selected:t,onSelect:s}){const n={scopeType:"project",scopeId:e},a=A_([n]);return l.jsx("div",{"data-kind":"local","data-state":"active",children:l.jsx(Yo,{depth:1,label:"local",glyph:l.jsx($e,{tone:"project",children:"▭"}),meta:l.jsx(dC,{scope:n}),count:a>0?a:void 0,selected:t,onSelect:s})})}function dC({scope:e}){var a,c,h;const t=i1(e),s=(a=t.data)==null?void 0:a.run.last,n=(c=t.data)==null?void 0:c.setup.last;if((s==null?void 0:s.running)===!0){const d=((h=t.data)==null?void 0:h.port)??null;return l.jsxs("span",{className:"runmark",children:[l.jsx("span",{className:"runmark__glyph",children:"▶"}),d===null?"run":`:${String(d.port)}`]})}return n&&!n.running&&n.exitCode!==0?l.jsx(l.Fragment,{children:"setup falhou"}):null}function M5(e){const t=[e.branch===e.name?null:e.branch,e.state==="missing"?"ausente":null].filter(s=>s!==null);return t.length===0?void 0:t.join(" · ")}function B5({mark:e}){return l.jsxs("span",{className:`prmark prmark--${e.verdict}`,children:[l.jsx("span",{className:"prmark__dot","aria-hidden":"true"}),"#",e.number,l.jsxs("span",{className:"sr-only",children:[" pull request ",L5[e.verdict]]})]})}const L5={ready:"pronta para merge",blocked:"bloqueada",pending:"verificando",draft:"em rascunho",merged:"mesclada",closed:"fechada sem merge"};function q5({projectId:e,worktree:t,mark:s,selected:n,onSelect:a}){const c=t.state==="missing",h={scopeType:"worktree",scopeId:t.id},d=A_([h]),f=I_(),m=O_(h),g=f.countIn((m.data??[]).map(v=>v.id));return l.jsx("div",{"data-kind":"worktree","data-state":t.state,children:l.jsx(Yo,{depth:1,label:t.name,glyph:l.jsx($e,{tone:c?"warn":"worktree",children:c?"⚠":"◇"}),muted:c,meta:s!==void 0&&!c?l.jsx(B5,{mark:s}):M5(t)??(c?void 0:l.jsx(dC,{scope:h}))??void 0,count:g>0?g:d>0?d:void 0,countTone:g>0?"asking":"running",selected:n,onSelect:()=>a(e,h)})})}function z5({workspaces:e,activeId:t,onSelect:s}){const n=qe(),[a,c]=j.useState(!1),[h,d]=j.useState(""),f=Te({mutationFn:g=>te.workspace.create.mutate({name:g}),onSuccess:async g=>{await n.invalidateQueries({queryKey:mr}),s(g.id),c(!1),d("")}}),m=g=>{g.preventDefault(),h.trim()!==""&&f.mutate(h)};return l.jsxs("div",{className:"ws",children:[l.jsxs("div",{className:"ws__bar",children:[l.jsx("label",{className:"sr-only",htmlFor:"workspace-select",children:"Workspace"}),l.jsx("span",{className:"ws__glyph","aria-hidden":"true",children:"◈"}),l.jsx("select",{id:"workspace-select",className:"ws__select",value:t??"",onChange:g=>s(g.target.value),children:e.map(g=>l.jsx("option",{value:g.id,children:g.name},g.id))}),l.jsx("span",{className:"ws__caret","aria-hidden":"true",children:"▾"}),l.jsx(ce,{size:"sm",variant:"ghost","aria-label":"novo workspace",title:"novo workspace",onClick:()=>c(!0),children:"+"})]}),a&&l.jsxs("form",{className:"ws__form",onSubmit:m,children:[l.jsx($t,{id:"new-workspace-name",label:"Nome do novo workspace",children:l.jsx(ts,{id:"new-workspace-name",value:h,onChange:g=>d(g.target.value),placeholder:"trabalho",autoFocus:!0})}),l.jsxs("div",{className:"ws__actions",children:[l.jsx(ce,{type:"submit",variant:"primary",size:"sm",disabled:f.isPending||h.trim()==="",children:"criar"}),l.jsx(ce,{size:"sm",variant:"ghost",onClick:()=>c(!1),children:"cancelar"})]})]}),f.isError&&l.jsx("p",{className:"ws__error",role:"alert",children:f.error.message})]})}function P5({worktreeId:e,projectId:t,workspaceName:s,onRemoved:n,onOpenWorkspace:a,onOpenProject:c,openSessionId:h,initialPrompt:d,initialDraft:f,filesPanel:m}){var ee,T;const g=qe(),[v,b]=j.useState(!1),S=ye({queryKey:m_(e),queryFn:()=>te.worktree.getDetail.query({id:e})}),x=ye({queryKey:["task","getByWorktree",e],queryFn:()=>te.task.getByWorktree.query({worktreeId:e})}),w=(ee=g.getQueryData(gr(t)))==null?void 0:ee.find(F=>F.id===e),k=ye({queryKey:["project","get",t],queryFn:()=>te.project.get.query({id:t})}),N=Te({mutationFn:F=>te.worktree.remove.mutate({id:e,force:F}),onSuccess:async()=>{await g.invalidateQueries({queryKey:gr(t)}),n()}}),L={scopeType:"worktree",scopeId:e};function R(F,J){var ve;return l.jsxs("nav",{className:"crumb","aria-label":"Caminho",children:[l.jsx("button",{type:"button",className:"crumb__up focus-ring",onClick:a,children:s}),l.jsx("span",{className:"crumb__sep","aria-hidden":"true",children:"/"}),l.jsx("button",{type:"button",className:"crumb__up focus-ring",onClick:c,children:((ve=k.data)==null?void 0:ve.name)??"…"}),l.jsx("span",{className:"crumb__sep","aria-hidden":"true",children:"/"}),l.jsx("span",{className:"crumb__here",children:F}),J!==F&&l.jsx("span",{className:"crumb__branch",children:J})]})}if(S.isPending)return w===void 0?l.jsx("div",{className:"pane",children:l.jsx(ys,{label:"carregando a worktree"})}):l.jsx(i_,{scope:L,cwd:w.path,openSessionId:h,initialPrompt:d,initialDraft:f,filesPanel:m,crumb:R(w.name,w.branch),checkout:{name:w.name,glyph:l.jsx($e,{tone:"worktree",children:"◇"})},context:l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"detail__title",children:[l.jsxs("h2",{children:[l.jsx($e,{tone:"worktree",children:"◇"})," ",w.name]}),l.jsx("span",{className:"detail__kind",children:"worktree"})]}),l.jsx(ys,{label:"carregando a worktree"})]})});if(S.isError)return l.jsx("div",{className:"pane",children:l.jsx(ke,{tone:"danger",children:S.error.message})});const{name:D,branch:Y,path:K,state:Z,present:Q,status:z,aheadBehind:G,baseBranch:le,createdAt:H}=S.data,O=!Q||Z==="missing",W=O||z===null||z.clean?null:z.changedFiles;return l.jsx(i_,{scope:L,cwd:K,openSessionId:h,initialPrompt:d,filesPanel:m,crumb:R(D,Y),checkout:{name:D,glyph:l.jsx($e,{tone:O?"warn":"worktree",children:O?"⚠":"◇"}),...W===null?{}:{state:"dirty",stateLabel:`árvore suja · ${W} ${W===1?"arquivo":"arquivos"}`}},context:l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"detail__title",children:[l.jsxs("h2",{children:[l.jsx($e,{tone:O?"warn":"worktree",children:O?"⚠":"◇"})," ",D]}),l.jsx("span",{className:"detail__kind",children:O?"worktree ausente":"worktree"}),l.jsx("span",{className:"actions__spacer"}),l.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>N.mutate(!1,{onError:()=>b(!0)}),disabled:N.isPending,children:N.isPending?"removendo…":"remover worktree"})]}),v&&l.jsx("div",{className:"detail__banner",children:l.jsx(ke,{tone:"danger",actions:l.jsxs(l.Fragment,{children:[l.jsx(ce,{size:"sm",variant:"danger",onClick:()=>N.mutate(!0),disabled:N.isPending,children:"remover mesmo assim"}),l.jsx(ce,{size:"sm",variant:"ghost",onClick:()=>b(!1),children:"cancelar"})]}),children:((T=N.error)==null?void 0:T.message)??"isso descarta as alterações não salvas."})}),O&&l.jsx("div",{className:"detail__banner",children:l.jsxs(ke,{tone:"warning",children:["O diretório não está em ",l.jsx("code",{children:K}),". Remover aqui só apaga o registro; a branch ",l.jsx("code",{children:Y})," continua existindo."]})}),l.jsx(ma,{entries:[{label:"branch",value:l.jsxs(l.Fragment,{children:[l.jsx(kt,{tone:"branch",dot:!0,children:Y})," ",l.jsxs("span",{className:"dim",children:["nasceu de ",le]})]})},{label:"tarefa",value:x.data==null?l.jsx("span",{className:"ctx-task--none",children:"sem tarefa"}):l.jsxs("span",{className:`ctx-task trow--${x.data.status}`,children:[l.jsx("span",{className:"tstat__dot","aria-hidden":"true"}),l.jsx("span",{className:"ctx-task__t",children:x.data.title})]})},...O?[]:[{label:`em relação a ${le}`,value:G===null?"desconhecido":l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"ahead",children:["↑",G.ahead]})," ",l.jsxs("span",{className:"behind",children:["↓",G.behind]})," ",l.jsxs("span",{className:"dim",children:[G.ahead," à frente, ",G.behind," atrás"]})]})}],{label:"estado",value:O?l.jsx(kt,{tone:"missing",dot:!0,children:"ausente do disco"}):z===null?l.jsx(kt,{children:"estado desconhecido"}):z.clean?l.jsx(kt,{tone:"clean",dot:!0,children:"limpa"}):l.jsxs(kt,{tone:"dirty",dot:!0,children:["suja · ",z.changedFiles," ",z.changedFiles===1?"arquivo":"arquivos"]})},{label:"caminho",value:l.jsx(xw,{path:K})},...O?[]:[{label:"criada",value:l.jsx("span",{className:"dim",children:xh(H)})}]]}),l.jsx("p",{className:"detail__hint",children:"a branch não é apagada"})]})})}const r_="lumem.activeWorkspaceId";function H5(){try{return window.localStorage.getItem(r_)}catch{return null}}function dx(e){try{e===null?window.localStorage.removeItem(r_):window.localStorage.setItem(r_,e)}catch{}}function F5(e){var c,h;const[t,s]=j.useState(H5),n=((c=e.find(d=>d.id===t))==null?void 0:c.id)??((h=e[0])==null?void 0:h.id)??null;j.useEffect(()=>{n!==t&&dx(n)},[n,t]);const a=j.useCallback(d=>{dx(d),s(d)},[]);return{activeId:n,select:a}}function I5(e,t){switch(t.type){case"workspace.changed":e.invalidateQueries({queryKey:mr});return;case"project.changed":e.invalidateQueries({queryKey:gn(t.workspaceId)}),e.invalidateQueries({queryKey:["project","get"]});return;case"worktree.changed":e.invalidateQueries({queryKey:gr(t.projectId)}),e.invalidateQueries({queryKey:["worktree"]}),e.invalidateQueries({queryKey:["files"]}),e.invalidateQueries({queryKey:["changes"]});return;case"pr.changed":e.invalidateQueries({queryKey:["pr"]});return;case"session.changed":e.invalidateQueries({queryKey:Hi(t.scopeType,t.scopeId)}),e.invalidateQueries({queryKey:["session"]});return;case"task.changed":e.invalidateQueries({queryKey:sa(t.workspaceId)}),e.invalidateQueries({queryKey:["task","get"]}),e.invalidateQueries({queryKey:["task","board"]}),e.invalidateQueries({queryKey:["task","settings"]});return}}function U5(){const e=qe();j.useEffect(()=>{const t=te.events.onChange.subscribe(void 0,{onData:s=>I5(e,s),onConnectionStateChange:s=>{s.state==="idle"&&e.invalidateQueries()}});return()=>t.unsubscribe()},[e])}const fC="lumem.runDock",mC=96;function K5(e=window.innerHeight){return K_(Math.round(e/2),e)}function $5(e=window.innerHeight){return Math.max(mC,e-160)}const fx=640;function K_(e,t=window.innerHeight){return Math.min($5(t),Math.max(mC,Math.round(e)))}function W5(){const e={open:!0,height:K5()};try{const t=window.localStorage.getItem(fC);if(t===null)return e;const s=JSON.parse(t);if(typeof s!="object"||s===null)return e;const{open:n,height:a}=s;return{open:typeof n=="boolean"?n:e.open,height:typeof a=="number"?K_(a):e.height}}catch{return e}}function mx(e){try{window.localStorage.setItem(fC,JSON.stringify(e))}catch{}}function V5(e,t){return{...e,toggle:()=>{!e.open&&t.width<fx&&t.setWidth(fx),e.toggle()}}}function Y5(){const[e,t]=j.useState(W5),[s,n]=j.useState(!1),a=j.useCallback(d=>{t(f=>{const m={...f,height:K_(d)};return mx(m),m})},[]),c=j.useCallback(()=>{t(d=>{const f={...d,open:!d.open};return mx(f),f})},[]);j.useEffect(()=>{if(!s)return;const d=m=>{m.preventDefault(),a(window.innerHeight-m.clientY)},f=()=>n(!1);return window.addEventListener("pointermove",d),window.addEventListener("pointerup",f),()=>{window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",f)}},[s,a]);const h=j.useCallback(d=>{d.preventDefault(),n(!0)},[]);return{open:e.open,height:e.height,toggle:c,setHeight:a,beginResize:h}}const pC="lumem.collapsedNodes";function G5(){try{const e=window.localStorage.getItem(pC);if(e===null)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(s=>typeof s=="string")):new Set}catch{return new Set}}function px(e){try{window.localStorage.setItem(pC,JSON.stringify([...e]))}catch{}}function Q5(){const[e,t]=j.useState(G5),s=j.useCallback(c=>!e.has(c),[e]),n=j.useCallback(c=>{t(h=>{const d=new Set(h);return d.delete(c)||d.add(c),px(d),d})},[]),a=j.useCallback(c=>{t(h=>{if(!h.has(c))return h;const d=new Set(h);return d.delete(c),px(d),d})},[]);return{isExpanded:s,toggle:n,expand:a}}function Z5({sidebar:e,children:t,fill:s=!1,right:n,rightWidth:a}){const c=n!==void 0&&a!==void 0?{"--right-width":`${a}px`}:void 0;return l.jsxs("div",{className:`app-shell${n!==void 0?" app-shell--right":""}`,style:c,children:[l.jsx("aside",{className:"app-shell__sidebar","aria-label":"navegação",children:e}),l.jsx("main",{className:`app-shell__main${s?" app-shell__main--fill":""}`,children:t}),n]})}function X5({version:e,unreachable:t}){return l.jsxs("header",{className:"topbar",children:[l.jsxs("h1",{className:"wordmark",children:[l.jsx("span",{className:"wordmark__dot","aria-hidden":"true"}),"Lumem-OS"]}),l.jsx("span",{className:"topbar__spacer"}),t?l.jsxs("span",{className:"daemon daemon--off",role:"alert",children:[l.jsx("span",{className:"daemon__dot","aria-hidden":"true"}),"daemon inacessível"]}):e!==null&&l.jsxs("span",{className:"daemon",children:[l.jsx("span",{className:"daemon__dot","aria-hidden":"true"}),"daemon v",e]})]})}const _C=["máquina","agente","workspace","projeto","tarefa"],J5={welcome:null,machine:0,agent:1,handshake:1,workspace:2,project:3,task:4,done:null};function gC(e){return J5[e]}function Ol(e){const t=gC(e);return t===null?null:`passo ${t+1} de ${_C.length}`}function Sn({eyebrow:e,title:t,lede:s,narrow:n,children:a,primary:c,onSubmit:h,onBack:d,onSkip:f,extra:m,hint:g}){const v=b=>{b.preventDefault(),!((c==null?void 0:c.disabled)===!0||(c==null?void 0:c.isPending)===!0)&&(h==null||h())};return l.jsx("form",{className:"wizard__form",onSubmit:v,children:l.jsx(B2,{...e===void 0?{}:{eyebrow:e},title:t,...s===void 0?{}:{lede:s},...n===void 0?{}:{narrow:n},footer:l.jsxs(l.Fragment,{children:[c!==void 0&&l.jsxs(ce,{type:"submit",variant:"primary",disabled:c.disabled===!0||c.isPending===!0,children:[c.isPending===!0&&c.pending!==void 0?c.pending:c.label,c.isPending!==!0&&l.jsxs(l.Fragment,{children:[" ",l.jsx("span",{className:"kbd",children:"⏎"})]})]}),m,l.jsx("span",{className:"spacer"}),f!==void 0&&l.jsx(ce,{variant:"ghost",onClick:f,children:"pular este passo"}),d!==void 0&&l.jsx(ce,{variant:"ghost",onClick:d,children:"Voltar"}),g!==void 0&&l.jsx("span",{className:"hint",children:g})]}),children:a})})}const _x=["setup","agents"];function eL({onNext:e,onBack:t,onSkip:s}){var b;const n=qe(),a=ye({queryKey:_x,queryFn:()=>te.setup.agents.query(),refetchOnWindowFocus:!1}),c=Te({mutationFn:()=>te.setup.installAdapter.mutate(),onSuccess:async()=>{await n.invalidateQueries({queryKey:_x})}}),h=(b=a.data)==null?void 0:b.adapters.find(S=>S.id===PT),d=h==null?void 0:h.adapter,f=(h==null?void 0:h.cli)??void 0,m=(h==null?void 0:h.apiKeyEnv)!==null&&(h==null?void 0:h.apiKeyEnv)!==void 0,g=(d==null?void 0:d.path)!=null,v=(d==null?void 0:d.version)!=null&&d.version!==nl.pinnedVersion;return l.jsxs(Sn,{eyebrow:Ol("agent"),title:"Conecte o Claude Code",lede:l.jsxs(l.Fragment,{children:["O Lumem conversa com agentes por ",l.jsx("b",{children:"ACP"})," — o daemon sobe o adaptador como processo e troca mensagens por stdio. É o que faz ferramenta, plano e pedido de permissão chegarem como blocos, e não como texto rolando num terminal."]}),primary:{label:"Testar conexão",disabled:!g},onSubmit:e,onBack:t,onSkip:s,hint:g?void 0:l.jsx(l.Fragment,{children:"o botão libera quando o adaptador estiver no PATH"}),children:[a.isPending&&l.jsx(ys,{label:"procurando os binários"}),a.isError&&l.jsxs(ke,{tone:"danger",children:[l.jsx("strong",{children:"Não deu para procurar os binários."})," ",a.error.message]}),a.data!==void 0&&d!==void 0&&l.jsxs(l.Fragment,{children:[l.jsxs(na,{title:"o que foi encontrado na sua máquina",children:[l.jsxs(Vo,{label:"binários",children:[f!==void 0&&l.jsx(Gs,{state:f.path===null?"warn":"ok",what:f.command,value:f.path===null?"não está no PATH — o adaptador precisa dele para trabalhar":`${f.version??f.versionNote??"versão não lida"} · ${f.path}`,status:f.path===null?"falta":"ok"}),l.jsx(Gs,{state:d.path===null?"fail":"ok",what:d.command,value:d.path===null?"adaptador ACP não está no PATH":`${d.version??d.versionNote??"versão não lida"} · ${d.path}`,status:d.path===null?"falta":"ok"})]}),d.path===null&&l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"field__help",children:["Nada para rodar no terminal: o Lumem instala o adaptador ",l.jsx("b",{children:"dentro da pasta dele"}),", numa versão fixa — nunca ",l.jsx("code",{children:"@latest"}),", para uma atualização de madrugada não mudar o comportamento do agente."]}),l.jsxs("div",{className:"wizard__acts",children:[l.jsx(ce,{variant:"primary",size:"sm",disabled:c.isPending,onClick:()=>c.mutate(),children:c.isPending?"instalando…":"Instalar o adaptador"}),l.jsx(ce,{variant:"ghost",size:"sm",disabled:a.isFetching,onClick:()=>void a.refetch(),children:a.isFetching?"verificando…":"Já instalei — verificar"})]}),c.isError&&l.jsxs(l.Fragment,{children:[l.jsx(ke,{tone:"danger",children:c.error.message}),d.install!==null&&l.jsx(y_,{command:d.install})]})]}),v&&l.jsxs("span",{className:"field__help",children:["A cópia encontrada é a ",l.jsx("b",{children:d.version}),", e o Lumem fixa a"," ",l.jsx("b",{children:nl.pinnedVersion})," — a versão que foi medida contra este daemon. O adaptador ",l.jsx("b",{children:"embute o próprio runtime"}),", então uma cópia velha responde a conversa mesmo com o ",l.jsx("code",{children:"claude"})," da sua máquina atualizado. Conectar o agente instala a versão fixa na pasta do Lumem."]}),d.managed&&l.jsxs("span",{className:"field__help",children:["Instalado pelo Lumem, na pasta dele — é esta cópia que o daemon executa, e não uma que esteja no seu ",l.jsx("code",{children:"PATH"}),"."]})]}),l.jsxs(na,{title:"como o Claude vai se autenticar — o que foi encontrado",children:[l.jsx(Vo,{label:"credencial",children:l.jsx(Gs,{state:m?"ok":"warn",what:(h==null?void 0:h.apiKeyEnv)??nl.apiKeyEnv[0]??"",value:m?"presente no ambiente do daemon — cobrança por token":"ausente — o adaptador vai usar a credencial local do Claude",status:m?"chave":"assinatura"})}),l.jsxs("span",{className:"field__help",children:["Não é escolha sua nem do Lumem: o adaptador usa a credencial que ",l.jsx("b",{children:"encontrar"}),". É o passo seguinte que confirma se ela vale — e ele confirma sem gastar token."]})]}),l.jsxs("div",{className:"adv",children:[l.jsx("span",{className:"adv__k",children:"avançado"}),l.jsxs("span",{className:"adv__v",children:["comando: ",d.command," · args: nenhum · env herdado do daemon"]})]}),l.jsxs(ke,{tone:"info",children:["Qualquer agente que fale ACP entra depois em ",l.jsx("b",{children:"agentes"}),", no rodapé da sidebar — o Lumem não é preso ao Claude. Pular este passo também é legítimo: sem agente ACP, a sessão é um terminal."]})]})]})}const tL=["agentConfig","list"];function sL({result:e,skipped:t,onOpen:s,onReview:n}){var S,x,w;const[a,c,h,d,f]=Xx({queries:[{queryKey:mr,queryFn:()=>te.workspace.list.query()},{queryKey:tL,queryFn:()=>te.agentConfig.list.query(),enabled:e.agentConfigId!==void 0},{queryKey:["project","get",e.projectId??""],queryFn:()=>te.project.get.query({id:e.projectId??""}),enabled:e.projectId!==void 0},{queryKey:m_(e.worktreeId??""),queryFn:()=>te.worktree.getDetail.query({id:e.worktreeId??""}),enabled:e.worktreeId!==void 0},{queryKey:Hi("worktree",e.worktreeId??""),queryFn:()=>te.session.listByScope.query({scopeType:"worktree",scopeId:e.worktreeId??""}),enabled:e.worktreeId!==void 0}]}),m=(S=a.data)==null?void 0:S.find(k=>k.id===e.workspaceId),g=(x=c.data)==null?void 0:x.find(k=>k.id===e.agentConfigId),v=(w=f.data)==null?void 0:w.find(k=>k.kind==="agent"),b=[{label:"workspace",value:(m==null?void 0:m.name)??l.jsx(iL,{})},{label:"agente",value:g===void 0?l.jsx(Mm,{step:"agent",skipped:t,onReview:n}):l.jsxs(l.Fragment,{children:[g.command,g.adapterVersion!==null&&` @${g.adapterVersion}`," ",l.jsxs("span",{className:"dim",children:["— ",g.transport==="acp"?"conversa":"terminal",g.available?"":" · fora do PATH"]})]})},{label:"projeto",value:h.data==null?l.jsx(Mm,{step:"project",skipped:t,onReview:n}):l.jsxs(l.Fragment,{children:[h.data.path,!h.data.available&&l.jsx("span",{className:"dim",children:" — não está no disco"})]})},{label:"worktree",value:d.data==null?l.jsx(Mm,{step:"task",skipped:t,onReview:n}):l.jsxs(l.Fragment,{children:[d.data.path,!d.data.present&&l.jsx("span",{className:"dim",children:" — não está no disco"})]})},{label:"sessão",value:v===void 0?l.jsx("span",{className:"dim",children:"nenhuma — abra uma quando quiser"}):l.jsxs(l.Fragment,{children:[v.agentName??"agente"," ",l.jsxs("span",{className:"dim",children:["— ",v.state]})]})}];return l.jsxs(Sn,{narrow:!0,eyebrow:"tudo configurado",title:"Pronto. O resto acontece dentro do produto.",lede:"Foi isto que passou a existir na sua máquina:",primary:{label:"Abrir o workspace"},onSubmit:s,extra:l.jsx(ce,{variant:"ghost",onClick:n,children:"Revisar a configuração"}),children:[l.jsx(ma,{variant:"recap",entries:b}),l.jsxs("div",{className:"keys",children:[l.jsxs("div",{className:"key",children:[l.jsx("span",{className:"key__k",children:"⏎"}),l.jsxs("span",{className:"key__d",children:["enviar o turno — ",l.jsx("span",{className:"dim",children:"⇧⏎ faz linha nova"})]})]}),l.jsxs("div",{className:"key",children:[l.jsx("span",{className:"key__k",children:"esquerda"}),l.jsx("span",{className:"key__d",children:"projetos e worktrees; o rodapé adiciona projeto e configura agente"})]}),l.jsxs("div",{className:"key",children:[l.jsx("span",{className:"key__k",children:"abas"}),l.jsxs("span",{className:"key__d",children:["uma por sessão viva, mais ",l.jsx("b",{children:"contexto"})," — a worktree em si"]})]}),l.jsxs("div",{className:"key",children:[l.jsx("span",{className:"key__k",children:"direita"}),l.jsx("span",{className:"key__d",children:"arquivos do checkout e o que mudou neles, ao lado da conversa"})]})]})]})}function iL(){return l.jsx("span",{className:"dim",children:"lendo do daemon…"})}function Mm({step:e,skipped:t,onReview:s}){const n={agent:"no rodapé da sidebar, em agentes",project:"na sidebar, no + ao lado de Projetos",task:"na sidebar, no + da linha do projeto"};return t.includes(e)?l.jsxs("span",{className:"dim",children:["pulado — dá para fazer ",n[e],","," ",l.jsx("button",{type:"button",className:"key__link",onClick:s,children:"ou voltar ao fluxo"})]}):l.jsx("span",{className:"dim",children:"nada foi criado"})}const rL=["setup","probe"],gx=["agentConfig","list"],vx="claude";function nL({onNext:e,onBack:t,onSkip:s}){const n=qe(),a=ye({queryKey:rL,queryFn:()=>te.setup.probe.query(),refetchOnWindowFocus:!1,retry:!1}),c=ye({queryKey:gx,queryFn:()=>te.agentConfig.list.query()}),h=a.data,d=Te({mutationFn:async()=>{var g,v;if(h===void 0)throw new Error("sem handshake não há o que salvar");const m=(g=c.data)==null?void 0:g.find(b=>b.transport==="acp"&&b.command===h.command);return m!==void 0?m:te.agentConfig.create.mutate({name:vx,command:h.command,args:[...h.args],transport:"acp",adapterVersion:((v=h.agentInfo)==null?void 0:v.version)??null})},onSuccess:async m=>{await n.invalidateQueries({queryKey:gx}),e({agentConfigId:m.id,agentName:m.name,...m.adapterVersion===null?{}:{adapterVersion:m.adapterVersion}})}}),f=h===void 0?"":h.authMethods.length===0?"o adaptador não pediu autenticação: usou a credencial local":`o adaptador pede autenticação: ${h.authMethods.map(m=>m.name??m.id).join(", ")}`;return l.jsxs(Sn,{eyebrow:`${Ol("handshake")??""} · conexão`,title:a.isError?"O adaptador não conectou":"Claude Code conectado",lede:a.isError?l.jsx(l.Fragment,{children:"Isto é o que o daemon tentou, e o que voltou."}):l.jsxs(l.Fragment,{children:["O daemon subiu o adaptador, trocou o ",l.jsx("code",{children:"initialize"})," e abriu uma sessão de teste. Isto é o que ele respondeu."]}),primary:{label:"Continuar",disabled:h===void 0,isPending:d.isPending,pending:"salvando…"},onSubmit:()=>d.mutate(),onBack:t,onSkip:s,extra:l.jsx(ce,{variant:"ghost",disabled:a.isFetching,onClick:()=>void a.refetch(),children:a.isFetching?"testando…":"Testar de novo"}),hint:l.jsxs(l.Fragment,{children:["salvo como ",l.jsx("b",{children:vx})]}),children:[a.isPending&&l.jsx(ys,{label:"subindo o adaptador"}),a.isError&&l.jsxs(ke,{tone:"danger",children:[l.jsx("strong",{children:"O handshake falhou."})," ",a.error.message]}),h!==void 0&&l.jsxs(l.Fragment,{children:[l.jsxs(Vo,{label:"o que o adaptador respondeu",children:[l.jsx(Gs,{state:"ok",what:"processo",value:`${h.command} · subiu em ${h.timings.spawnMs} ms`,status:"ok"}),l.jsx(Gs,{state:"ok",what:"protocolo",value:`ACP v${h.protocolVersion}${h.agentInfo===null?" · o adaptador não declarou nome nem versão":` · ${h.agentInfo.name} ${h.agentInfo.version}`}`,status:"ok"}),l.jsx(Gs,{state:h.authMethods.length===0?"ok":"warn",what:"autenticação",value:f,status:h.authMethods.length===0?"ok":"pede"}),l.jsx(Gs,{state:"ok",what:"capacidades",value:h.capabilities.length===0?"nenhuma declarada":h.capabilities.join(" · "),status:"ok"}),l.jsx(Gs,{state:"ok",what:"sessão",value:`session/new devolveu ${h.acpSessionId} em ${h.timings.sessionMs} ms`,status:"ok"})]}),l.jsx(na,{title:"o que o daemon mandou e o que voltou",children:l.jsxs("div",{className:"wire",children:[l.jsxs("span",{className:"wire__l",children:[l.jsx("span",{className:"wire__d wire__d--out","aria-hidden":"true",children:"→"}),l.jsxs("span",{className:"wire__c",children:["initialize ","{"," protocolVersion: ",h.protocolVersion,", clientCapabilities:"," ","{"," fs: ","{"," readTextFile, writeTextFile ","}",", terminal ","}"," ","}"]})]}),l.jsxs("span",{className:"wire__l",children:[l.jsx("span",{className:"wire__d wire__d--in","aria-hidden":"true",children:"←"}),l.jsxs("span",{className:"wire__c",children:["{"," protocolVersion: ",h.protocolVersion,", agentInfo:"," ",h.agentInfo===null?"ausente":`${h.agentInfo.name}@${h.agentInfo.version}`,", authMethods: [",h.authMethods.map(m=>m.id).join(", "),"] ","}"]})]}),l.jsxs("span",{className:"wire__l",children:[l.jsx("span",{className:"wire__d wire__d--out","aria-hidden":"true",children:"→"}),l.jsxs("span",{className:"wire__c",children:["session/new ","{"," cwd: ~/.lumem/probe, mcpServers: [] ","}"]})]}),l.jsxs("span",{className:"wire__l",children:[l.jsx("span",{className:"wire__d wire__d--in","aria-hidden":"true",children:"←"}),l.jsxs("span",{className:"wire__c",children:["{"," sessionId: ",h.acpSessionId,", modes: [",h.modes.join(", "),"] ","}"]})]}),l.jsxs("span",{className:"wire__l",children:[l.jsx("span",{className:"wire__d","aria-hidden":"true",children:"·"}),l.jsx("span",{className:"wire__c",children:"sessão de teste encerrada. Nenhum token consumido — não houve session/prompt."})]})]})}),l.jsxs(na,{title:"como as próximas sessões nascem",children:[l.jsx(ma,{variant:"recap",entries:[{label:"modelo",value:l.jsxs(l.Fragment,{children:["o que o agente oferecer ",l.jsx("span",{className:"dim",children:"— trocável em cada conversa"})]})},{label:"modo",value:h.currentMode===null?l.jsx("span",{className:"dim",children:"o padrão do agente"}):l.jsxs(l.Fragment,{children:[h.currentMode," ",l.jsx("span",{className:"dim",children:"— trocável em cada conversa"})]})},{label:"versão",value:h.agentInfo===null?l.jsx("span",{className:"dim",children:"o adaptador não declarou — vai pedir para digitar"}):h.agentInfo.version}]}),l.jsx("span",{className:"field__help",children:"Leitura, não escolha: o Lumem não tem onde guardar um padrão seu, e a conversa já escolhe modelo e modo por sessão — com o agente como autoridade sobre a lista."})]}),d.isError&&l.jsx(ke,{tone:"danger",children:d.error.message})]})]})}const vC=["setup","preflight"];function aL({onNext:e,onBack:t,onSkip:s}){var h;const n=ye({queryKey:vC,queryFn:()=>te.setup.preflight.query(),refetchOnWindowFocus:!1}),a=((h=n.data)==null?void 0:h.checks)??[],c=a.some(d=>d.id==="git"&&d.state==="fail");return l.jsxs(Sn,{eyebrow:Ol("machine"),title:"O que o Lumem precisa da sua máquina",lede:"Cinco verificações, todas locais. Nenhuma delas instala nada.",primary:{label:"Continuar"},onSubmit:e,onBack:t,onSkip:s,extra:l.jsx(ce,{variant:"ghost",disabled:n.isFetching,onClick:()=>void n.refetch(),children:n.isFetching?"verificando…":"Verificar de novo"}),hint:l.jsxs(l.Fragment,{children:[l.jsx("b",{children:"esc"})," volta"]}),children:[n.isPending&&l.jsx(ys,{label:"lendo a máquina"}),n.isError&&l.jsxs(ke,{tone:"danger",children:[l.jsx("strong",{children:"O daemon não respondeu ao pré-voo."})," ",n.error.message]}),a.length>0&&l.jsx(Vo,{label:"o que o Lumem encontrou nesta máquina",children:a.map(d=>l.jsx(Gs,{state:n.isFetching?"running":d.state,what:d.label,value:d.value,status:n.isFetching?"lendo":lL(d.state),...d.fix===null?{}:{action:l.jsx(y_,{command:d.fix})}},d.id))}),c&&l.jsxs(ke,{tone:"warning",children:["Git abaixo de ",l.jsx("strong",{children:"2.30"})," não serve: o Lumem usa ",l.jsx("code",{children:"git worktree"})," com"," ",l.jsx("code",{children:"--orphan"}),", e o comportamento muda antes dessa versão. Dá para continuar — a falha aparece na primeira worktree, com esta mesma frase."]})]})}function lL(e){return e==="ok"?"ok":e==="warn"?"atenção":"falha"}function yC(e,t=400){const[s,n]=j.useState(e);return j.useEffect(()=>{const a=setTimeout(()=>n(e),t);return()=>clearTimeout(a)},[e,t]),s}function oL({workspaceId:e,onNext:t,onBack:s,onSkip:n}){const a=qe(),[c,h]=j.useState(""),d=yC(c.trim()),f=ye({queryKey:["project","inspect",d],queryFn:()=>te.project.inspect.query({path:d}),enabled:d.startsWith("/")||d.startsWith("~"),retry:!1}),m=Te({mutationFn:()=>{if(e===void 0)throw new Error("sem workspace não há onde adicionar");return te.project.add.mutate({workspaceId:e,path:d})},onSuccess:async b=>{e!==void 0&&await a.invalidateQueries({queryKey:gn(e)}),t({projectId:b.id,projectPath:b.path})}}),g=f.data,v=(g==null?void 0:g.alreadyRegistered)??null;return l.jsxs(Sn,{eyebrow:Ol("project"),title:"Adicione o primeiro projeto",lede:l.jsxs(l.Fragment,{children:["Projeto é um repositório git que ",l.jsx("b",{children:"já existe"})," na sua máquina. O Lumem não move nem reescreve nada dele — só passa a criar worktrees a partir dele. Clonar de uma URL é outra história: rede, credencial e progresso são feature, não um campo."]}),primary:{label:v===null?"Adicionar projeto":"Usar o que já está aqui",disabled:g===void 0,isPending:m.isPending,pending:"validando…"},onSubmit:()=>{if(v!==null){t({projectId:v.id,projectPath:d});return}m.mutate()},onBack:s,onSkip:n,children:[l.jsxs("div",{className:"wizard__body",children:[l.jsx($t,{id:"setup-project-path",label:"Pasta do projeto — caminho absoluto",error:m.isError?m.error.message:f.isError&&d!==""?f.error.message:void 0,children:l.jsx(ts,{id:"setup-project-path",value:c,onChange:b=>h(b.target.value),placeholder:"/Users/voce/Documents/GitHub/lorebase",invalid:m.isError||f.isError,autoFocus:!0})}),l.jsxs("span",{className:"field__help",children:["Digitado, não escolhido: o daemon pode estar em outra máquina, e o seletor de arquivo do navegador entrega arquivo, não caminho de servidor. Ele valida na hora e diz"," ",l.jsx("b",{children:"qual"})," verificação falhou."]})]}),f.isFetching&&l.jsx(ys,{label:"lendo o repositório"}),g!==void 0&&l.jsxs(l.Fragment,{children:[l.jsxs(na,{title:"o que o Lumem leu daí",children:[l.jsxs(Vo,{label:"o que o repositório é",children:[l.jsx(Gs,{state:"ok",what:"repositório",value:`git · ${g.commits} commit(s) · HEAD em ${g.head.branch??"HEAD destacado"}${g.head.shortSha===null?"":` · ${g.head.shortSha}`}`,status:"ok"}),l.jsx(Gs,{state:g.origin===null?"warn":"ok",what:"remoto",value:g.origin??"sem origin — worktree funciona igual, push é que não",status:g.origin===null?"sem":"ok"}),l.jsx(Gs,{state:g.clean?"ok":"warn",what:"árvore",value:g.clean?"limpa · nada por commitar":`${g.changedFiles} arquivo(s) por commitar — o Lumem não toca neles`,status:g.clean?"limpa":"suja"}),l.jsx(Gs,{state:g.worktrees.length===0?"ok":"warn",what:"worktrees",value:g.worktrees.length===0?"nenhuma além do checkout principal":`${g.worktrees.length} já registrada(s) neste repositório, criada(s) fora do Lumem`,status:g.worktrees.length===0?"ok":"atenção"})]}),g.worktrees.length>0&&l.jsx("span",{className:"field__help",children:"Elas continuam onde estão. O Lumem não mexe em nenhuma delas, e não passa a listá-las — ver e administrar worktree criada fora daqui é outra feature."})]}),v!==null&&l.jsxs(ke,{tone:"info",children:["Este caminho já é o projeto ",l.jsx("strong",{children:v.name})," aqui. Nada será criado de novo — o fluxo segue com ele."]}),l.jsxs(ke,{tone:"info",children:["Seu checkout em ",l.jsx("code",{children:g.root})," continua sendo seu. O agente trabalha nas worktrees irmãs, fora dele."]})]})]})}function cL({projectId:e,agentConfigId:t,onNext:s,onBack:n,onSkip:a}){const c=qe(),[h,d]=j.useState("primeira-tarefa"),[f,m]=j.useState(!0),g=yC(h.trim()),v=ye({queryKey:["worktree","plan",e??"",g],queryFn:()=>te.worktree.plan.query({projectId:e??"",name:g}),enabled:e!==void 0&&g!=="",retry:!1}),b=Te({mutationFn:async()=>{if(e===void 0)throw new Error("sem projeto não há de onde cortar worktree");const x=await te.worktree.create.mutate({projectId:e,name:g});let w;return f&&t!==void 0&&(w=(await te.session.createAgent.mutate({scopeType:"worktree",scopeId:x.id,agentConfigId:t})).id),{worktree:x,sessionId:w}},onSuccess:async({worktree:x,sessionId:w})=>{e!==void 0&&await c.invalidateQueries({queryKey:gr(e)}),await c.invalidateQueries({queryKey:Hi("worktree",x.id)}),s({worktreeId:x.id,worktreeName:x.name,sessionOpened:w!==void 0,...w===void 0?{}:{sessionId:w}})}}),S=v.data;return l.jsxs(Sn,{eyebrow:Ol("task"),title:"Toda tarefa vira uma worktree",lede:"É a ideia central: em vez de trocar de branch no seu checkout, cada tarefa ganha uma branch e uma pasta próprias. Você pode ter três agentes trabalhando ao mesmo tempo e nenhum encosta no que o outro está fazendo.",primary:{label:f&&t!==void 0?"Criar e abrir a conversa":"Criar a worktree",disabled:S===void 0||S.refusal!==null,isPending:b.isPending,pending:"criando…"},onSubmit:()=>b.mutate(),onBack:n,onSkip:a,children:[l.jsxs("div",{className:"wizard__body",children:[l.jsx($t,{id:"setup-task-name",label:"Nome da tarefa",error:b.isError?b.error.message:v.isError?v.error.message:(S==null?void 0:S.refusal)??void 0,children:l.jsx(ts,{id:"setup-task-name",value:h,onChange:x=>d(x.target.value),placeholder:"primeira-tarefa",invalid:b.isError||v.isError||(S==null?void 0:S.refusal)!=null,autoFocus:!0})}),l.jsx("span",{className:"field__help",children:"Vira o nome da branch e o nome da pasta."}),S!==void 0&&l.jsx(ma,{variant:"recap",entries:[{label:"branch",value:l.jsxs(l.Fragment,{children:[S.branch," ",l.jsxs("span",{className:"dim",children:["← ",S.baseBranch,S.baseSha===null?" · sem commit ainda":` · ${S.baseSha}`]})]})},{label:"pasta",value:S.path},{label:"comando",value:S.command}]})]}),l.jsx(na,{title:"o que abre junto",children:l.jsxs(O2,{label:"o que abre junto",children:[l.jsx(j0,{title:"Uma sessão do Claude",description:t===void 0?"Precisa de um agente ACP configurado — o passo 2 foi pulado.":"Abre a conversa já dentro da worktree.",glyph:l.jsx($e,{tone:"agent",children:"◆"}),selected:f&&t!==void 0,onSelect:()=>m(!0),disabled:t===void 0}),l.jsx(j0,{title:"Só a worktree",description:"Cria a pasta e a branch. Você abre sessão quando quiser.",glyph:l.jsx($e,{tone:"shell",children:"●"}),selected:!f||t===void 0,onSelect:()=>m(!1)})]})}),e===void 0&&l.jsxs(ke,{tone:"warning",children:["O passo do projeto foi pulado, então não há de onde cortar uma worktree. Pule este também — a linha do projeto na sidebar ganha um ",l.jsx("b",{children:"+"})," quando você adicionar um."]})]})}function uL({daemonVersion:e,daemonUnreachable:t,onStart:s}){return l.jsx(Sn,{title:t?"O daemon não está respondendo.":"O daemon já está rodando. Falta dizer com o que ele trabalha.",lede:t?l.jsxs(l.Fragment,{children:["O Lumem roda inteiro na sua máquina, e o daemon é a parte que tem os processos. Sem ele nada aqui responde — nem este fluxo. Suba ",l.jsx("code",{children:"pnpm dev"})," e volte."]}):l.jsxs(l.Fragment,{children:["O Lumem roda inteiro na sua máquina: um daemon local",e!==null&&l.jsxs(l.Fragment,{children:[" (v",e,")"]}),", seus repositórios onde já estão, e agentes que você mesmo instalou. Nada sai daqui — o que vai para a Anthropic é o que você escrever para o Claude, pela sua própria conta."]}),primary:{label:"Configurar em 5 passos",disabled:t},onSubmit:s,hint:l.jsx(l.Fragment,{children:"leva ~2 min"}),children:l.jsxs("div",{className:"tri",children:[l.jsxs("div",{className:"tri__i",children:[l.jsx("span",{className:"tri__g glyph glyph--worktree","aria-hidden":"true",children:"◇"}),l.jsx("span",{className:"tri__t",children:"Uma tarefa, uma worktree"}),l.jsx("span",{className:"tri__d",children:"Cada tarefa ganha branch e pasta próprias. O agente trabalha lá; seu checkout não é tocado."})]}),l.jsxs("div",{className:"tri__i",children:[l.jsx("span",{className:"tri__g glyph glyph--agent","aria-hidden":"true",children:"◆"}),l.jsx("span",{className:"tri__t",children:"Agente por ACP"}),l.jsx("span",{className:"tri__d",children:"Claude Code entra por protocolo, não por terminal simulado. Ferramenta, plano e permissão viram blocos."})]}),l.jsxs("div",{className:"tri__i",children:[l.jsx("span",{className:"tri__g glyph glyph--project","aria-hidden":"true",children:"■"}),l.jsx("span",{className:"tri__t",children:"Vários ao mesmo tempo"}),l.jsx("span",{className:"tri__d",children:"Sessões paralelas em worktrees diferentes, sem uma pisar na outra."})]})]})})}function hL({onNext:e,onBack:t}){var f;const s=qe(),[n,a]=j.useState("pessoal"),c=ye({queryKey:vC,queryFn:()=>te.setup.preflight.query(),refetchOnWindowFocus:!1}),h=Te({mutationFn:()=>te.workspace.create.mutate({name:n.trim()}),onSuccess:async m=>{await s.invalidateQueries({queryKey:mr}),e({workspaceId:m.id,workspaceName:m.name})}}),d=(f=c.data)==null?void 0:f.paths;return l.jsxs(Sn,{eyebrow:Ol("workspace"),title:"Crie seu primeiro workspace",lede:"Um workspace agrupa projetos e guarda as worktrees deles num lugar só. Quem trabalha em coisas separadas — pessoal e cliente, por exemplo — mantém dois, e eles nunca se veem.",primary:{label:"Criar workspace",disabled:n.trim()==="",isPending:h.isPending,pending:"criando…"},onSubmit:()=>h.mutate(),onBack:t,children:[l.jsxs("div",{className:"wizard__body",children:[l.jsx($t,{id:"setup-workspace-name",label:"Nome",error:h.isError?h.error.message:void 0,children:l.jsx(ts,{id:"setup-workspace-name",value:n,onChange:m=>a(m.target.value),placeholder:"pessoal",invalid:h.isError,autoFocus:!0})}),l.jsx("span",{className:"field__help",children:"Aparece no topo da coluna da esquerda. Dá para renomear depois."}),d!==void 0&&l.jsx($t,{id:"setup-workspaces-dir",label:"Onde o Lumem escreve — leitura",children:l.jsx(ts,{id:"setup-workspaces-dir",value:d.workspacesDir,readOnly:!0})}),l.jsxs("span",{className:"field__help",children:["Uma árvore por workspace, com o clone e as worktrees de cada projeto debaixo dele. Fora dos seus repositórios, de propósito: worktree dentro do checkout suja"," ",l.jsx("code",{children:"git status"})," e acaba commitada por acidente. Quem muda o lugar é a variável"," ",l.jsx("code",{children:"LUMEM_STATE_DIR"})," do daemon."]})]}),d!==void 0&&l.jsx(na,{title:"o que este passo escreve no disco",children:l.jsx(ma,{variant:"recap",entries:[{label:"registro",value:d.databasePath},{label:"workspaces",value:d.workspacesDir},{label:"conversas",value:l.jsxs(l.Fragment,{children:[d.transcriptsDir," ",l.jsx("span",{className:"dim",children:"— só local"})]})}]})})]})}const Bm=["welcome","machine","agent","handshake","workspace","project","task","done"];function dL({daemonVersion:e,daemonUnreachable:t,onFinish:s}){const[n,a]=j.useState("welcome"),[c,h]=j.useState({}),[d,f]=j.useState([]),m=Bm.indexOf(n),g=j.useCallback(N=>{a(N),window.scrollTo(0,0)},[]),v=j.useCallback(N=>{N!==void 0&&h(R=>({...R,...N}));const L=Bm[m+1];L!==void 0&&g(L)},[g,m]),b=j.useCallback(()=>{const N=Bm[m-1];N!==void 0&&g(N)},[g,m]),S=j.useCallback(()=>{if(f(N=>N.includes(n)?N:[...N,n]),n==="agent"){f(N=>N.includes("handshake")?N:[...N,"handshake"]),g("workspace");return}v()},[v,g,n]);j.useEffect(()=>{const N=L=>{L.key==="Escape"&&b()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[b]);const x=gC(n),w=j.useMemo(()=>x===null?null:l.jsx(R2,{steps:_C,current:x}),[x]);return l.jsx("div",{className:"flow",children:l.jsxs("div",{className:"wizard",children:[w,k()]})});function k(){switch(n){case"welcome":return l.jsx(uL,{daemonVersion:e,daemonUnreachable:t,onStart:()=>v()});case"machine":return l.jsx(aL,{onNext:()=>v(),onBack:b,onSkip:S});case"agent":return l.jsx(eL,{onNext:()=>v(),onBack:b,onSkip:S});case"handshake":return l.jsx(nL,{onNext:N=>v(N),onBack:b,onSkip:S});case"workspace":return l.jsx(hL,{onNext:N=>v(N),onBack:b});case"project":return l.jsx(oL,{workspaceId:c.workspaceId,onNext:N=>v(N),onBack:b,onSkip:S});case"task":return l.jsx(cL,{projectId:c.projectId,agentConfigId:c.agentConfigId,onNext:N=>v(N),onBack:b,onSkip:S});case"done":return l.jsx(sL,{result:c,skipped:d,onOpen:()=>s(c),onReview:()=>g("welcome")})}}}function fL(){var le;const e=qe(),[t,s]=j.useState(null),[n,a]=j.useState("home"),[c,h]=j.useState(null),[d,f]=j.useState(void 0),[m,g]=j.useState(null),[v,b]=j.useState(null),[S,x]=j.useState(!1),[w,k]=j.useState(null),N=Q5(),L=vR(),R=Y5(),D=ye({queryKey:["health"],queryFn:()=>te.health.query(),refetchInterval:5e3,retry:!1}),Y=ye({queryKey:mr,queryFn:()=>te.workspace.list.query()}),{activeId:K,select:Z}=F5(Y.data??[]);return j.useEffect(()=>{c!==null||!Y.isSuccess||h(Y.data.length===0)},[c,Y.isSuccess,Y.data]),U5(),l.jsx(sB,{children:l.jsx(qA,{children:l.jsxs("div",{className:"app",children:[l.jsx(X5,{version:((le=D.data)==null?void 0:le.version)??null,unreachable:D.isError}),D.isError&&l.jsx("div",{className:"app__banner",children:l.jsxs(ke,{tone:"danger",children:[l.jsx("strong",{children:"Daemon inacessível."})," Nada aqui responde até ele voltar. As sessões continuam rodando no servidor — o que caiu é a conexão com ele."]})}),Q()]})})});function Q(){var W,ee;if(Y.isPending)return l.jsx("div",{className:"pane",children:l.jsx(ys,{label:"conectando ao daemon"})});if(Y.isError)return l.jsx("div",{className:"pane",children:l.jsx("p",{role:"alert",children:Y.error.message})});if(c===null)return l.jsx("div",{className:"pane",children:l.jsx(ys,{label:"conectando ao daemon"})});if(c||Y.data.length===0||K===null)return l.jsx(dL,{daemonVersion:((W=D.data)==null?void 0:W.version)??null,daemonUnreachable:D.isError,onFinish:async T=>{await e.invalidateQueries({queryKey:mr}),T.workspaceId!==void 0&&Z(T.workspaceId),f(T.sessionId),T.projectId!==void 0&&s({projectId:T.projectId,scope:T.worktreeId===void 0?{scopeType:"project",scopeId:T.projectId}:{scopeType:"worktree",scopeId:T.worktreeId}}),h(!1)}});const H=Y.data,O=((ee=H.find(T=>T.id===K))==null?void 0:ee.name)??"";return l.jsxs(l.Fragment,{children:[l.jsx(Z5,{fill:!0,right:z(),rightWidth:L.width,sidebar:l.jsxs(l.Fragment,{children:[l.jsx(z5,{workspaces:H,activeId:K,onSelect:T=>{Z(T),s(null)}}),l.jsx(dO,{workspaceId:K,place:t!==null?"scope":n==="board"?"board":"home",onHome:()=>{a("home"),s(null)},onBoard:()=>{a("board"),s(null)}}),l.jsx(A5,{workspaceId:K,expansion:N,selection:{scopeType:(t==null?void 0:t.scope.scopeType)??null,scopeId:(t==null?void 0:t.scope.scopeId)??null},onSelect:(T,F)=>s({projectId:T,scope:F}),onAddProject:()=>x(!0),onCreateWorktree:k}),l.jsx("div",{className:"sidebar__foot",children:l.jsx(eO,{})})]}),children:G(K,O)}),l.jsx(F2,{workspaceId:K,workspaceName:O,open:S,onClose:()=>x(!1),onRequestOpen:()=>x(!0),onAdded:T=>s({projectId:T,scope:{scopeType:"project",scopeId:T}})}),w!==null&&l.jsx(Z3,{projectId:w.id,projectName:w.name,hasCommits:w.hasCommits,open:!0,onClose:()=>k(null),onOpenExisting:T=>{N.expand(w.id),s({projectId:w.id,scope:{scopeType:"worktree",scopeId:T}}),k(null)},onCreated:T=>{N.expand(w.id),s({projectId:w.id,scope:{scopeType:"worktree",scopeId:T}}),k(null)}},w.id)]})}function z(){if(!(t===null||!L.open))return l.jsx(Y3,{scope:t.scope,onClose:L.toggle,onResize:L.setWidth,onAskAgent:(H,O)=>{g({sessionId:H,text:O}),f(H)},dock:V5(R,L)},`${t.scope.scopeType}:${t.scope.scopeId}`)}function G(H,O){if(t===null)return l.jsx(xA,{workspaceId:H,workspaceName:O,view:n,onView:a,onRemoved:async()=>{await e.invalidateQueries({queryKey:mr})},onWorkOnTask:T=>{b({sessionId:T.sessionId,text:T.draft}),f(T.sessionId),s({projectId:T.projectId,scope:T.worktreeId===null?{scopeType:"project",scopeId:T.projectId}:{scopeType:"worktree",scopeId:T.worktreeId}})}},H);const{projectId:W,scope:ee}=t;return ee.scopeType==="worktree"?l.jsx(P5,{worktreeId:ee.scopeId,projectId:W,openSessionId:d,initialPrompt:m??void 0,initialDraft:v??void 0,workspaceName:O,filesPanel:L,onRemoved:()=>s({projectId:W,scope:{scopeType:"project",scopeId:W}}),onOpenWorkspace:()=>s(null),onOpenProject:()=>s({projectId:W,scope:{scopeType:"project",scopeId:W}})},ee.scopeId):l.jsx(T5,{projectId:W,workspaceId:H,workspaceName:O,openSessionId:d,initialPrompt:m??void 0,initialDraft:v??void 0,filesPanel:L,onRemoved:()=>s(null),onOpenWorkspace:()=>s(null),onSelectWorktree:T=>s({projectId:W,scope:{scopeType:"worktree",scopeId:T}})},W)}}const mL={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};async function pL(e=mL){}function _L(){return new bN({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}})}const bC=document.getElementById("root");if(!bC)throw new Error("#root not found in index.html");const gL=DN.createRoot(bC);gL.render(l.jsx(j.StrictMode,{children:l.jsx(xN,{client:_L(),children:l.jsx(fL,{})})}));pL();export{wL as a,Lt as c,xL as s};