local-operator-ui 0.23.1 → 0.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/out/main/index.js +1241 -492
  2. package/out/renderer/assets/{_basePickBy-mmFlh3ho.js → _basePickBy-BVR8NHkD.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-DAWnt4WG.js → _baseUniq-onZkstHq.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-CO72YkSX.js → agent-details-page-DC13Jibh.js} +1 -1
  5. package/out/renderer/assets/{agent-hub-page-DhYc5_gP.js → agent-hub-page-iulwy94G.js} +1 -1
  6. package/out/renderer/assets/{agents-page-BopOzax_.js → agents-page-BSegINKc.js} +2 -2
  7. package/out/renderer/assets/{arc-BgHsUFIt.js → arc-DAb06JtB.js} +1 -1
  8. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-BWxIiACo.js → architectureDiagram-IEHRJDOE-sSe348HD.js} +1 -1
  9. package/out/renderer/assets/{blockDiagram-JOT3LUYC-CoJDUfWc.js → blockDiagram-JOT3LUYC-DB0hhoP8.js} +1 -1
  10. package/out/renderer/assets/{c4Diagram-VJAJSXHY-B8vXmmLx.js → c4Diagram-VJAJSXHY-CcMWb5_5.js} +1 -1
  11. package/out/renderer/assets/channel-Dl22yt_O.js +1 -0
  12. package/out/renderer/assets/{chunk-4BMEZGHF-rO5ve7XY.js → chunk-4BMEZGHF-SRkv1Dzw.js} +1 -1
  13. package/out/renderer/assets/{chunk-A2AXSNBT-CTPb1xgY.js → chunk-A2AXSNBT-BBdcJhkk.js} +1 -1
  14. package/out/renderer/assets/{chunk-AEK57VVT-5VpTdLBm.js → chunk-AEK57VVT-BFLmAuIk.js} +1 -1
  15. package/out/renderer/assets/{chunk-D6G4REZN-C3CEf0kC.js → chunk-D6G4REZN--QHGDmI-.js} +1 -1
  16. package/out/renderer/assets/{chunk-RZ5BOZE2-B7nn7Euk.js → chunk-RZ5BOZE2-Cy8U6l3Q.js} +1 -1
  17. package/out/renderer/assets/{chunk-XZIHB7SX-CnPH3vBT.js → chunk-XZIHB7SX-DFfpTr7O.js} +1 -1
  18. package/out/renderer/assets/classDiagram-GIVACNV2-BguqLYlr.js +1 -0
  19. package/out/renderer/assets/classDiagram-v2-COTLJTTW-BguqLYlr.js +1 -0
  20. package/out/renderer/assets/clone-C0R1R8sa.js +1 -0
  21. package/out/renderer/assets/{compact-pagination-Bu8vshU-.js → compact-pagination-DERWPPOM.js} +1 -1
  22. package/out/renderer/assets/{dagre-OKDRZEBW-DUX1RPbJ.js → dagre-OKDRZEBW-DfjKcX6M.js} +1 -1
  23. package/out/renderer/assets/{diagram-SSKATNLV-Cpv42kzr.js → diagram-SSKATNLV-Bm1j7Y3r.js} +1 -1
  24. package/out/renderer/assets/{diagram-VNBRO52H-CGkUnKEL.js → diagram-VNBRO52H-BRx5TiDX.js} +1 -1
  25. package/out/renderer/assets/{erDiagram-Q7BY3M3F-iBbJbyJZ.js → erDiagram-Q7BY3M3F-BSxbIo11.js} +1 -1
  26. package/out/renderer/assets/{flowDiagram-4HSFHLVR-B569Tv1u.js → flowDiagram-4HSFHLVR-R2ILhUKR.js} +1 -1
  27. package/out/renderer/assets/{ganttDiagram-APWFNJXF-nGbcgsgD.js → ganttDiagram-APWFNJXF-Gd7TZJFy.js} +1 -1
  28. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-vv_MhteL.js → gitGraphDiagram-7IBYFJ6S-BAs2K2WV.js} +1 -1
  29. package/out/renderer/assets/{graph-krOMwYSa.js → graph-zm35SWuR.js} +1 -1
  30. package/out/renderer/assets/{index-CT6w0yXj.js → index-CqIP2mt3.js} +1 -1
  31. package/out/renderer/assets/{index-BqWgqUKZ.js → index-DF2zdD6_.js} +5 -5
  32. package/out/renderer/assets/{index-BgGl2-0g.js → index-DXx2j7ov.js} +1 -1
  33. package/out/renderer/assets/{infoDiagram-PH2N3AL5-DHDA5253.js → infoDiagram-PH2N3AL5-BcAWGJ1_.js} +1 -1
  34. package/out/renderer/assets/{journeyDiagram-U35MCT3I-CIrQ218m.js → journeyDiagram-U35MCT3I-VfDkAwaY.js} +1 -1
  35. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-DG_YsZbL.js → kanban-definition-NDS4AKOZ-BVgW6OQK.js} +1 -1
  36. package/out/renderer/assets/{layout-CB5zJSjt.js → layout-jfvNOQNg.js} +1 -1
  37. package/out/renderer/assets/{legacy-agents-page-B8pvrWy_.js → legacy-agents-page-yObswBd2.js} +1 -1
  38. package/out/renderer/assets/{mermaid.core-CYc-R2hQ.js → mermaid.core-w7CiwIS9.js} +5 -5
  39. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-C22fFThl.js → mindmap-definition-ALO5MXBD-Ck5fBAvP.js} +1 -1
  40. package/out/renderer/assets/{parseISO-vr2fT-wq.js → parseISO-BfcDJeSX.js} +1 -1
  41. package/out/renderer/assets/{pieDiagram-IB7DONF6-DKRytw7K.js → pieDiagram-IB7DONF6-xuxf3Is5.js} +1 -1
  42. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-CWdnqGKr.js → quadrantDiagram-7GDLP6J5-B4UU5d5n.js} +1 -1
  43. package/out/renderer/assets/{radar-MK3ICKWK-B0XgopGa.js → radar-MK3ICKWK-BUD9nsvK.js} +1 -1
  44. package/out/renderer/assets/{radient-auth-buttons-RrBw8fkd.js → radient-auth-buttons-BtcEZuSY.js} +1 -1
  45. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CXL8GuIo.js → requirementDiagram-KVF5MWMF-0fsS7ohi.js} +1 -1
  46. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-BQKCHfmN.js → sankeyDiagram-QLVOVGJD-CUjpA8gC.js} +1 -1
  47. package/out/renderer/assets/{schedules-page-DtNhlycC.js → schedules-page-xXMGrdrg.js} +1 -1
  48. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-awR0fjHu.js → sequenceDiagram-X6HHIX6F-CX6mfjEg.js} +1 -1
  49. package/out/renderer/assets/{settings-page-DCLaspsn.js → settings-page-PLBi7GEM.js} +1 -1
  50. package/out/renderer/assets/{stateDiagram-DGXRK772-BjhA_mJe.js → stateDiagram-DGXRK772-DlOrLmRF.js} +1 -1
  51. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CsUzDnIT.js +1 -0
  52. package/out/renderer/assets/{timeline-definition-BDJGKUSR-BFEDYBl8.js → timeline-definition-BDJGKUSR-B6_9nD67.js} +1 -1
  53. package/out/renderer/assets/{use-agent-like-mutation-Bxx_WHvo.js → use-agent-like-mutation-Ckg2HQQI.js} +1 -1
  54. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-CwLeRa1a.js → xychartDiagram-VJFVF3MP-B2JoquLl.js} +1 -1
  55. package/out/renderer/index.html +1 -1
  56. package/package.json +2 -2
  57. package/out/renderer/assets/channel-DAvIgUhZ.js +0 -1
  58. package/out/renderer/assets/classDiagram-GIVACNV2-CP5aSNYY.js +0 -1
  59. package/out/renderer/assets/classDiagram-v2-COTLJTTW-CP5aSNYY.js +0 -1
  60. package/out/renderer/assets/clone-CeahOD_w.js +0 -1
  61. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-nAxLNCrm.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-CYc-R2hQ.js","./icon-mKHwnRNs.js","./icon-DC3rStnR.css","./katex-BCx1q_2Y.css","./index-CT6w0yXj.js","./index-BgGl2-0g.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./agent-details-page-CO72YkSX.js","./square-pen-717nTWtU.js","./use-agent-like-mutation-Bxx_WHvo.js","./agent-hub-page-DhYc5_gP.js","./compact-pagination-Bu8vshU-.js","./page-header-DmGvvMe3.js","./agents-page-BopOzax_.js","./schedules-page-DtNhlycC.js","./parseISO-vr2fT-wq.js","./settings-page-DCLaspsn.js","./radient-auth-buttons-RrBw8fkd.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-w7CiwIS9.js","./icon-mKHwnRNs.js","./icon-DC3rStnR.css","./katex-BCx1q_2Y.css","./index-CqIP2mt3.js","./index-DXx2j7ov.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./agent-details-page-DC13Jibh.js","./square-pen-717nTWtU.js","./use-agent-like-mutation-Ckg2HQQI.js","./agent-hub-page-iulwy94G.js","./compact-pagination-DERWPPOM.js","./page-header-DmGvvMe3.js","./agents-page-BSegINKc.js","./schedules-page-xXMGrdrg.js","./parseISO-BfcDJeSX.js","./settings-page-PLBi7GEM.js","./radient-auth-buttons-BtcEZuSY.js"])))=>i.map(i=>d[i]);
2
2
  import{r as w,j as p,m as Z,a0 as ej,a as je,a3 as jSe,B as we,c as I,aa as gA,ab as mA,ac as hWe,ad as K$,ae as fWe,af as tj,ag as EV,h as en,a2 as OWe,ah as pWe,$ as gWe,D as mWe,A as el,X as Js,z as vA,L as os,I as fi,T as wg,S as br,U as bc,ai as qSe,aj as Wee,g as Ot,y as vWe,ak as jP,a1 as wr,f as Bs,al as yWe,am as bWe,an as Gee,ao as Vee,ap as wWe,aq as Bee,Q as zSe,b as J$,u as lu,s as v0,C as rO,V as Yee,x as USe,ar as RV,as as y0,W as xWe,n as X_,o as Ub,p as D_,q as ks,t as cv,at as WSe,a7 as GSe,P as VSe,v as BSe,w as YSe,J as ek,K as tk,M as nk,N as rk,O as ik,au as ib,i as AV,H as QE,av as b6,aw as SWe,ax as $We,d as ZSe,e as HSe,ay as kWe,az as TWe,aA as _We,aB as PWe,E as nj,aC as KSe,aD as Zee,l as CWe,k as QWe,R as EWe}from"./icon-mKHwnRNs.js";var pw=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(){}},b0=typeof window>"u"||"Deno"in globalThis;function qc(){}function RWe(e,t){return typeof e=="function"?e(t):e}function rj(e){return typeof e=="number"&&e>=0&&e!==1/0}function JSe(e,t){return Math.max(e+(t||0)-Date.now(),0)}function sb(e,t){return typeof e=="function"?e(t):e}function Vu(e,t){return typeof e=="function"?e(t):e}function Hee(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:a,stale:o}=e;if(a){if(r){if(t.queryHash!==XV(a,t.options))return!1}else if(!sk(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||i&&i!==t.state.fetchStatus||s&&!s(t))}function Kee(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(w0(t.options.mutationKey)!==w0(s))return!1}else if(!sk(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function XV(e,t){return(t?.queryKeyHashFn||w0)(e)}function w0(e){return JSON.stringify(e,(t,n)=>ij(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function sk(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>sk(e[n],t[n])):!1}function e$e(e,t){if(e===t)return e;const n=Jee(e)&&Jee(t);if(n||ij(e)&&ij(t)){const r=n?e:Object.keys(e),i=r.length,s=n?t:Object.keys(t),a=s.length,o=n?[]:{};let l=0;for(let c=0;c<a;c++){const u=n?c:s[c];(!n&&r.includes(u)||n)&&e[u]===void 0&&t[u]===void 0?(o[u]=void 0,l++):(o[u]=e$e(e[u],t[u]),o[u]===e[u]&&e[u]!==void 0&&l++)}return i===a&&l===i?e:o}return t}function EE(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Jee(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ij(e){if(!ete(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!ete(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function ete(e){return Object.prototype.toString.call(e)==="[object Object]"}function AWe(e){return new Promise(t=>{setTimeout(t,e)})}function sj(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?e$e(e,t):t}function I_(e){return e}function XWe(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function DWe(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var DV=Symbol();function t$e(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===DV?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var IWe=class extends pw{#t;#e;#n;constructor(){super(),this.#n=e=>{if(!b0&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},IV=new IWe,NWe=class extends pw{#t=!0;#e;#n;constructor(){super(),this.#n=e=>{if(!b0&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#t}},RE=new NWe;function aj(){let e,t;const n=new Promise((i,s)=>{e=i,t=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}function FWe(e){return Math.min(1e3*2**e,3e4)}function n$e(e){return(e??"online")==="online"?RE.isOnline():!0}var r$e=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function w6(e){return e instanceof r$e}function i$e(e){let t=!1,n=0,r=!1,i;const s=aj(),a=g=>{r||(h(new r$e(g)),e.abort?.())},o=()=>{t=!0},l=()=>{t=!1},c=()=>IV.isFocused()&&(e.networkMode==="always"||RE.isOnline())&&e.canRun(),u=()=>n$e(e.networkMode)&&e.canRun(),d=g=>{r||(r=!0,e.onSuccess?.(g),i?.(),s.resolve(g))},h=g=>{r||(r=!0,e.onError?.(g),i?.(),s.reject(g))},f=()=>new Promise(g=>{i=m=>{(r||c())&&g(m)},e.onPause?.()}).then(()=>{i=void 0,r||e.onContinue?.()}),O=()=>{if(r)return;let g;const m=n===0?e.initialPromise:void 0;try{g=m??e.fn()}catch(v){g=Promise.reject(v)}Promise.resolve(g).then(d).catch(v=>{if(r)return;const y=e.retry??(b0?0:3),b=e.retryDelay??FWe,T=typeof b=="function"?b(n,v):b,x=y===!0||typeof y=="number"&&n<y||typeof y=="function"&&y(n,v);if(t||!x){h(v);return}n++,e.onFail?.(n,v),AWe(T).then(()=>c()?void 0:f()).then(()=>{t?h(v):O()})})};return{promise:s,cancel:a,continue:()=>(i?.(),s),cancelRetry:o,continueRetry:l,canStart:u,start:()=>(u()?O():f().then(O),s)}}var MWe=e=>setTimeout(e,0);function LWe(){let e=[],t=0,n=o=>{o()},r=o=>{o()},i=MWe;const s=o=>{t?e.push(o):i(()=>{n(o)})},a=()=>{const o=e;e=[],o.length&&i(()=>{r(()=>{o.forEach(l=>{n(l)})})})};return{batch:o=>{let l;t++;try{l=o()}finally{t--,t||a()}return l},batchCalls:o=>(...l)=>{s(()=>{o(...l)})},schedule:s,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var la=LWe(),s$e=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rj(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(b0?1/0:5*60*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},jWe=class extends s$e{#t;#e;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=qWe(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){const n=sj(this.state.data,e,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#s({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(qc).catch(qc):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>Vu(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===DV||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!JSe(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){const o=this.observers.find(l=>l.options.queryFn);o&&this.setOptions(o.options)}const n=new AbortController,r=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const o=t$e(this.options,t),l={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(l),this.#o=!1,this.options.persister?this.options.persister(o,l,this):o(l)},s={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};r(s),this.options.behavior?.onFetch(s,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#s({type:"fetch",meta:s.fetchOptions?.meta});const a=o=>{w6(o)&&o.silent||this.#s({type:"error",error:o}),w6(o)||(this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this)),this.scheduleGc()};return this.#i=i$e({initialPromise:t?.initialPromise,fn:s.fetchFn,abort:n.abort.bind(n),onSuccess:o=>{if(o===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(o)}catch(l){a(l);return}this.#n.config.onSuccess?.(o,this),this.#n.config.onSettled?.(o,this.state.error,this),this.scheduleGc()},onError:a,onFail:(o,l)=>{this.#s({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0}),this.#i.start()}#s(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...a$e(n.data,this.options),fetchMeta:e.meta??null};case"success":return{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=e.error;return w6(r)&&r.revert&&this.#e?{...this.#e,fetchStatus:"idle"}:{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),la.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function a$e(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:n$e(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function qWe(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var zWe=class extends pw{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,n){const r=t.queryKey,i=t.queryHash??XV(r,t);let s=this.get(i);return s||(s=new jWe({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(s)),s}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){la.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Hee(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Hee(e,n)):t}notify(e){la.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){la.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){la.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},UWe=class extends s$e{#t;#e;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||o$e(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#e.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){this.#n=i$e({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(r,i)=>{this.#r({type:"failed",failureCount:r,error:i})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const t=this.state.status==="pending",n=!this.#n.canStart();try{if(!t){this.#r({type:"pending",variables:e,isPaused:n}),await this.#e.config.onMutate?.(e,this);const i=await this.options.onMutate?.(e);i!==this.state.context&&this.#r({type:"pending",context:i,variables:e,isPaused:n})}const r=await this.#n.start();return await this.#e.config.onSuccess?.(r,e,this.state.context,this),await this.options.onSuccess?.(r,e,this.state.context),await this.#e.config.onSettled?.(r,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(r,null,e,this.state.context),this.#r({type:"success",data:r}),r}catch(r){try{throw await this.#e.config.onError?.(r,e,this.state.context,this),await this.options.onError?.(r,e,this.state.context),await this.#e.config.onSettled?.(void 0,r,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,r,e,this.state.context),r}finally{this.#r({type:"error",error:r})}}finally{this.#e.runNext(this)}}#r(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),la.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function o$e(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var WWe=class extends pw{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(e,t,n){const r=new UWe({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#t.add(e);const t=qP(e);if(typeof t=="string"){const n=this.#e.get(t);n?n.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=qP(e);if(typeof t=="string"){const n=this.#e.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=qP(e);if(typeof t=="string"){const r=this.#e.get(t)?.find(i=>i.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=qP(e);return typeof t=="string"?this.#e.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){la.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>Kee(t,n))}findAll(e={}){return this.getAll().filter(t=>Kee(e,t))}notify(e){la.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return la.batch(()=>Promise.all(e.map(t=>t.continue().catch(qc))))}};function qP(e){return e.options.scope?.id}function tte(e){return{onFetch:(t,n)=>{const r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const c=async()=>{let u=!1;const d=O=>{Object.defineProperty(O,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},h=t$e(t.options,t.fetchOptions),f=async(O,g,m)=>{if(u)return Promise.reject();if(g==null&&O.pages.length)return Promise.resolve(O);const v={client:t.client,queryKey:t.queryKey,pageParam:g,direction:m?"backward":"forward",meta:t.options.meta};d(v);const y=await h(v),{maxPages:b}=t.options,T=m?DWe:XWe;return{pages:T(O.pages,y,b),pageParams:T(O.pageParams,g,b)}};if(i&&s.length){const O=i==="backward",g=O?GWe:nte,m={pages:s,pageParams:a},v=g(r,m);o=await f(m,v,O)}else{const O=e??s.length;do{const g=l===0?a[0]??r.initialPageParam:nte(r,o);if(l>0&&g==null)break;o=await f(o,g),l++}while(l<O)}return o};t.options.persister?t.fetchFn=()=>t.options.persister?.(c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=c}}}function nte(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function GWe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var VWe=class{#t;#e;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#t=e.queryCache||new zWe,this.#e=e.mutationCache||new WWe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=IV.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=RE.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#t.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(sb(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=this.#t.get(r.queryHash)?.state.data,a=RWe(t,s);if(a!==void 0)return this.#t.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return la.batch(()=>this.#t.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;la.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#t;return la.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=la.batch(()=>this.#t.findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(qc).catch(qc)}invalidateQueries(e,t={}){return la.batch(()=>(this.#t.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=la.batch(()=>this.#t.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(qc)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(qc)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#t.build(this,t);return n.isStaleByTime(sb(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(qc).catch(qc)}fetchInfiniteQuery(e){return e.behavior=tte(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(qc).catch(qc)}ensureInfiniteQueryData(e){return e.behavior=tte(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return RE.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(w0(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(r=>{sk(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(w0(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#i.values()],n={};return t.forEach(r=>{sk(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=XV(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===DV&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},BWe=class extends pw{constructor(e,t){super(),this.options=t,this.#t=e,this.#s=null,this.#o=aj(),this.options.experimental_prefetchInRender||this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#p;#h;#f;#c;#u;#l;#O=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),rte(this.#e,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return oj(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return oj(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Vu(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#e.setOptions(this.options),t._defaulted&&!EE(this.options,t)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&ite(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),r&&(this.#e!==n||Vu(this.options.enabled,this.#e)!==Vu(t.enabled,this.#e)||sb(this.options.staleTime,this.#e)!==sb(t.staleTime,this.#e))&&this.#g();const i=this.#m();r&&(this.#e!==n||Vu(this.options.enabled,this.#e)!==Vu(t.enabled,this.#e)||i!==this.#l)&&this.#v(i)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),n=this.createResult(t,e);return ZWe(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#e.state),n}getCurrentResult(){return this.#r}trackResult(e,t){const n={};return Object.keys(e).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(r),t?.(r),e[r])})}),n}trackProp(e){this.#O.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),n=this.#t.getQueryCache().build(this.#t,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#d(e){this.#x();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(qc)),t}#g(){this.#b();const e=sb(this.options.staleTime,this.#e);if(b0||this.#r.isStale||!rj(e))return;const n=JSe(this.#r.dataUpdatedAt,e)+1;this.#c=setTimeout(()=>{this.#r.isStale||this.updateResult()},n)}#m(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#v(e){this.#w(),this.#l=e,!(b0||Vu(this.options.enabled,this.#e)===!1||!rj(this.#l)||this.#l===0)&&(this.#u=setInterval(()=>{(this.options.refetchIntervalInBackground||IV.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#v(this.#m())}#b(){this.#c&&(clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,r=this.options,i=this.#r,s=this.#i,a=this.#a,l=e!==n?e.state:this.#n,{state:c}=e;let u={...c},d=!1,h;if(t._optimisticResults){const _=this.hasListeners(),P=!_&&rte(e,t),C=_&&ite(e,n,t,r);(P||C)&&(u={...u,...a$e(c.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:f,errorUpdatedAt:O,status:g}=u;h=u.data;let m=!1;if(t.placeholderData!==void 0&&h===void 0&&g==="pending"){let _;i?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(_=i.data,m=!0):_=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,_!==void 0&&(g="success",h=sj(i?.data,_,t),d=!0)}if(t.select&&h!==void 0&&!m)if(i&&h===s?.data&&t.select===this.#p)h=this.#h;else try{this.#p=t.select,h=t.select(h),h=sj(i?.data,h,t),this.#h=h,this.#s=null}catch(_){this.#s=_}this.#s&&(f=this.#s,h=this.#h,O=Date.now(),g="error");const v=u.fetchStatus==="fetching",y=g==="pending",b=g==="error",T=y&&v,x=h!==void 0,k={status:g,fetchStatus:u.fetchStatus,isPending:y,isSuccess:g==="success",isError:b,isInitialLoading:T,isLoading:T,data:h,dataUpdatedAt:u.dataUpdatedAt,error:f,errorUpdatedAt:O,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:v,isRefetching:v&&!y,isLoadingError:b&&!x,isPaused:u.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:b&&x,isStale:NV(e,t),refetch:this.refetch,promise:this.#o};if(this.options.experimental_prefetchInRender){const _=Q=>{k.status==="error"?Q.reject(k.error):k.data!==void 0&&Q.resolve(k.data)},P=()=>{const Q=this.#o=k.promise=aj();_(Q)},C=this.#o;switch(C.status){case"pending":e.queryHash===n.queryHash&&_(C);break;case"fulfilled":(k.status==="error"||k.data!==C.value)&&P();break;case"rejected":(k.status!=="error"||k.error!==C.reason)&&P();break}}return k}updateResult(){const e=this.#r,t=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#a=this.options,this.#i.data!==void 0&&(this.#f=this.#e),EE(t,e))return;this.#r=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#O.size)return!0;const s=new Set(i??this.#O);return this.options.throwOnError&&s.add("error"),Object.keys(this.#r).some(a=>{const o=a;return this.#r[o]!==e[o]&&s.has(o)})};this.#S({listeners:n()})}#x(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(e){la.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function YWe(e,t){return Vu(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function rte(e,t){return YWe(e,t)||e.state.data!==void 0&&oj(e,t,t.refetchOnMount)}function oj(e,t,n){if(Vu(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&NV(e,t)}return!1}function ite(e,t,n,r){return(e!==t||Vu(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&NV(e,n)}function NV(e,t){return Vu(t.enabled,e)!==!1&&e.isStaleByTime(sb(t.staleTime,e))}function ZWe(e,t){return!EE(e.getCurrentResult(),t)}var HWe=class extends pw{#t;#e=void 0;#n;#r;constructor(t,n){super(),this.#t=t,this.setOptions(n),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#t.defaultMutationOptions(t),EE(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&w0(n.mutationKey)!==w0(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(t){this.#i(),this.#a(t)}getCurrentResult(){return this.#e}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(t,n){return this.#r=n,this.#n?.removeObserver(this),this.#n=this.#t.getMutationCache().build(this.#t,this.options),this.#n.addObserver(this),this.#n.execute(t)}#i(){const t=this.#n?.state??o$e();this.#e={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){la.batch(()=>{if(this.#r&&this.hasListeners()){const n=this.#e.variables,r=this.#e.context;t?.type==="success"?(this.#r.onSuccess?.(t.data,n,r),this.#r.onSettled?.(t.data,null,n,r)):t?.type==="error"&&(this.#r.onError?.(t.error,n,r),this.#r.onSettled?.(void 0,t.error,n,r))}this.listeners.forEach(n=>{n(this.#e)})})}},l$e=w.createContext(void 0),Ki=e=>{const t=w.useContext(l$e);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},c$e=({client:e,children:t})=>(w.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),p.jsx(l$e.Provider,{value:e,children:t})),u$e=w.createContext(!1),KWe=()=>w.useContext(u$e);u$e.Provider;function JWe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var eGe=w.createContext(JWe()),tGe=()=>w.useContext(eGe);function d$e(e,t){return typeof e=="function"?e(...t):!!e}function lj(){}var nGe=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},rGe=e=>{w.useEffect(()=>{e.clearReset()},[e])},iGe=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||d$e(n,[e.error,r])),sGe=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},aGe=(e,t)=>e.isLoading&&e.isFetching&&!t,oGe=(e,t)=>e?.suspense&&t.isPending,ste=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function lGe(e,t,n){const r=Ki(),i=KWe(),s=tGe(),a=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=i?"isRestoring":"optimistic",sGe(a),nGe(a,s),rGe(s);const o=!r.getQueryCache().get(a.queryHash),[l]=w.useState(()=>new t(r,a)),c=l.getOptimisticResult(a),u=!i&&e.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(d=>{const h=u?l.subscribe(la.batchCalls(d)):lj;return l.updateResult(),h},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setOptions(a)},[a,l]),oGe(a,c))throw ste(a,l,s);if(iGe({result:c,errorResetBoundary:s,throwOnError:a.throwOnError,query:r.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw c.error;return r.getDefaultOptions().queries?._experimental_afterQuery?.(a,c),a.experimental_prefetchInRender&&!b0&&aGe(c,i)&&(o?ste(a,l,s):r.getQueryCache().get(a.queryHash)?.promise)?.catch(lj).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?c:l.trackResult(c)}function rr(e,t){return lGe(e,BWe)}function sl(e,t){const n=Ki(),[r]=w.useState(()=>new HWe(n,e));w.useEffect(()=>{r.setOptions(e)},[r,e]);const i=w.useSyncExternalStore(w.useCallback(a=>r.subscribe(la.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=w.useCallback((a,o)=>{r.mutate(a,o).catch(lj)},[r]);if(i.error&&d$e(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const cGe=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),uGe=function(e,t){return new URL(e,t).href},ate={},Ie=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const a=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");i=Promise.allSettled(n.map(c=>{if(c=uGe(c,r),c in ate)return;ate[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!r)for(let O=a.length-1;O>=0;O--){const g=a[O];if(g.href===c&&(!u||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":cGe,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((O,g)=>{f.addEventListener("load",O),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return t().catch(s)})};var Bu,Ue=typeof window<"u"?window:void 0,Sl=typeof globalThis<"u"?globalThis:Ue,h$e=Array.prototype,ote=h$e.forEach,lte=h$e.indexOf,uc=Sl?.navigator,tn=Sl?.document,vl=Sl?.location,cj=Sl?.fetch,uj=Sl!=null&&Sl.XMLHttpRequest&&"withCredentials"in new Sl.XMLHttpRequest?Sl.XMLHttpRequest:void 0,cte=Sl?.AbortController,Ws=uc?.userAgent,Un=Ue??{},wf={DEBUG:!1,LIB_VERSION:"1.235.6"},x6="$copy_autocapture",dGe=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];(function(e){e.GZipJS="gzip-js",e.Base64="base64"})(Bu||(Bu={}));var hGe=["fatal","error","warning","log","info","debug"];function pr(e,t){return e.indexOf(t)!==-1}var yA=function(e){return e.trim()},FV=function(e){return e.replace(/^\$/,"")},fGe=Array.isArray,f$e=Object.prototype,O$e=f$e.hasOwnProperty,bA=f$e.toString,gs=fGe||function(e){return bA.call(e)==="[object Array]"},nd=e=>typeof e=="function",ms=e=>e===Object(e)&&!gs(e),qy=e=>{if(ms(e)){for(var t in e)if(O$e.call(e,t))return!1;return!0}return!1},Gt=e=>e===void 0,Hs=e=>bA.call(e)=="[object String]",dj=e=>Hs(e)&&e.trim().length===0,xg=e=>e===null,ii=e=>Gt(e)||xg(e),Yo=e=>bA.call(e)=="[object Number]",Pf=e=>bA.call(e)==="[object Boolean]",OGe=e=>e instanceof FormData,pGe=e=>pr(dGe,e),p$e=e=>{var t={_log:function(n){if(Ue&&(wf.DEBUG||Un.POSTHOG_DEBUG)&&!Gt(Ue.console)&&Ue.console){for(var r=("__rrweb_original__"in Ue.console[n])?Ue.console[n].__rrweb_original__:Ue.console[n],i=arguments.length,s=new Array(i>1?i-1:0),a=1;a<i;a++)s[a-1]=arguments[a];r(e,...s)}},info:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];t._log("log",...r)},warn:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];t._log("warn",...r)},error:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];t._log("error",...r)},critical:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];console.error(e,...r)},uninitializedWarning:n=>{t.error("You must initialize PostHog before calling ".concat(n))},createLogger:n=>p$e("".concat(e," ").concat(n))};return t},fn=p$e("[PostHog.js]"),Ro=fn.createLogger,gGe=Ro("[ExternalScriptsLoader]"),ute=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return gGe.warn("".concat(t," was requested but loading of external scripts is disabled.")),n("Loading of external scripts is disabled");var r=tn?.querySelectorAll("script");if(r){for(var i=0;i<r.length;i++)if(r[i].src===t)return n()}var s=()=>{if(!tn)return n("document not found");var a=tn.createElement("script");if(a.type="text/javascript",a.crossOrigin="anonymous",a.src=t,a.onload=c=>n(void 0,c),a.onerror=c=>n(c),e.config.prepare_external_dependency_script&&(a=e.config.prepare_external_dependency_script(a)),!a)return n("prepare_external_dependency_script returned null");var o,l=tn.querySelectorAll("body > script");l.length>0?(o=l[0].parentNode)===null||o===void 0||o.insertBefore(a,l[0]):tn.body.appendChild(a)};tn!=null&&tn.body?s():tn?.addEventListener("DOMContentLoaded",s)};function dte(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Ke(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?dte(Object(n),!0).forEach(function(r){Et(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dte(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Et(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g$e(e,t){if(e==null)return{};var n,r,i=function(a,o){if(a==null)return{};var l,c,u={},d=Object.keys(a);for(c=0;c<d.length;c++)l=d[c],o.indexOf(l)>=0||(u[l]=a[l]);return u}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}Un.__PosthogExtensions__=Un.__PosthogExtensions__||{},Un.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{var r="/static/".concat(t,".js")+"?v=".concat(e.version);if(t==="remote-config"&&(r="/array/".concat(e.config.token,"/config.js")),t==="toolbar"){var i=3e5,s=Math.floor(Date.now()/i)*i;r="".concat(r,"&t=").concat(s)}var a=e.requestRouter.endpointFor("assets",r);ute(e,a,n)},Un.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var r=e.requestRouter.endpointFor("api",t);ute(e,r,n)};var AE={};function Lp(e,t,n){if(gs(e)){if(ote&&e.forEach===ote)e.forEach(t,n);else if("length"in e&&e.length===+e.length){for(var r=0,i=e.length;r<i;r++)if(r in e&&t.call(n,e[r],r)===AE)return}}}function vi(e,t,n){if(!ii(e)){if(gs(e))return Lp(e,t,n);if(OGe(e)){for(var r of e.entries())if(t.call(n,r[1],r[0])===AE)return}else for(var i in e)if(O$e.call(e,i)&&t.call(n,e[i],i)===AE)return}}var Ts=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Lp(n,function(i){for(var s in i)i[s]!==void 0&&(e[s]=i[s])}),e},vQ=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Lp(n,function(i){Lp(i,function(s){e.push(s)})}),e};function yQ(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var hte=function(e){try{return e()}catch{return}},mGe=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.apply(this,n)}catch(i){fn.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),fn.critical(i)}}},ak=function(e){var t={};return vi(e,function(n,r){Hs(n)&&n.length>0&&(t[r]=n)}),t};function vGe(e,t){return n=e,r=s=>Hs(s)&&!xg(t)?s.slice(0,t):s,i=new Set,function s(a,o){return a!==Object(a)?r?r(a,o):a:i.has(a)?void 0:(i.add(a),gs(a)?(l=[],Lp(a,c=>{l.push(s(c))})):(l={},vi(a,(c,u)=>{i.has(c)||(l[u]=s(c,u))})),l);var l}(n);var n,r,i}var yGe=["herokuapp.com","vercel.app","netlify.app"];function bGe(e){var t=e?.hostname;if(!Hs(t))return!1;var n=t.split(".").slice(-2).join(".");for(var r of yGe)if(n===r)return!1;return!0}function m$e(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n]}function Cs(e,t,n,r){var{capture:i=!1,passive:s=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:s})}var v$e="$people_distinct_id",fS="__alias",OS="__timers",fte="$autocapture_disabled_server_side",hj="$heatmaps_enabled_server_side",Ote="$exception_capture_enabled_server_side",pte="$web_vitals_enabled_server_side",y$e="$dead_clicks_enabled_server_side",gte="$web_vitals_allowed_metrics",fj="$session_recording_enabled_server_side",mte="$console_log_recording_enabled_server_side",vte="$session_recording_network_payload_capture",yte="$session_recording_masking",bte="$session_recording_canvas_recording",wte="$replay_sample_rate",xte="$replay_minimum_duration",Ste="$replay_script_config",XE="$sesid",pS="$session_is_sampled",S6="$session_recording_url_trigger_activated_session",$6="$session_recording_event_trigger_activated_session",zy="$enabled_feature_flags",bQ="$early_access_features",Oj="$feature_flag_details",gS="$stored_person_properties",vm="$stored_group_properties",pj="$surveys",zP="$surveys_activated",DE="$flag_call_reported",ff="$user_state",gj="$client_session_props",mj="$capture_rate_limit",vj="$initial_campaign_params",yj="$initial_referrer_info",bj="$initial_person_info",IE="$epp",b$e="__POSTHOG_TOOLBAR__",$te="$posthog_cookieless",wGe=[v$e,fS,"__cmpns",OS,fj,hj,XE,zy,ff,bQ,Oj,vm,gS,pj,DE,gj,mj,vj,yj,IE];function kte(e){var t;return e instanceof Element&&(e.id===b$e||!((t=e.closest)===null||t===void 0||!t.call(e,".toolbar-global-fade-container")))}function wA(e){return!!e&&e.nodeType===1}function jp(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function w$e(e){return!!e&&e.nodeType===3}function x$e(e){return!!e&&e.nodeType===11}function MV(e){return e?yA(e).split(/\s+/):[]}function Tte(e){var t=Ue?.location.href;return!!(t&&e&&e.some(n=>t.match(n)))}function NE(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return MV(t)}function S$e(e){return ii(e)?null:yA(e).split(/(\s+)/).filter(t=>Wb(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function xA(e){var t="";return xj(e)&&!T$e(e)&&e.childNodes&&e.childNodes.length&&vi(e.childNodes,function(n){var r;w$e(n)&&n.textContent&&(t+=(r=S$e(n.textContent))!==null&&r!==void 0?r:"")}),yA(t)}function $$e(e){return Gt(e.target)?e.srcElement||null:(t=e.target)!==null&&t!==void 0&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var wj=["a","button","form","input","select","textarea","label"];function k$e(e){var t=e.parentNode;return!(!t||!wA(t))&&t}function xGe(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;if(!Ue||!e||jp(e,"html")||!wA(e)||n!=null&&n.url_allowlist&&!Tte(n.url_allowlist)||n!=null&&n.url_ignorelist&&Tte(n.url_ignorelist))return!1;if(n!=null&&n.dom_event_allowlist){var s=n.dom_event_allowlist;if(s&&!s.some(f=>t.type===f))return!1}for(var a=!1,o=[e],l=!0,c=e;c.parentNode&&!jp(c,"body");)if(x$e(c.parentNode))o.push(c.parentNode.host),c=c.parentNode.host;else{if(!(l=k$e(c)))break;if(r||wj.indexOf(l.tagName.toLowerCase())>-1)a=!0;else{var u=Ue.getComputedStyle(l);u&&u.getPropertyValue("cursor")==="pointer"&&(a=!0)}o.push(l),c=l}if(!function(f,O){var g=O?.element_allowlist;if(Gt(g))return!0;var m=function(b){if(g.some(T=>b.tagName.toLowerCase()===T))return{v:!0}};for(var v of f){var y=m(v);if(typeof y=="object")return y.v}return!1}(o,n)||!function(f,O){var g=O?.css_selector_allowlist;if(Gt(g))return!0;var m=function(b){if(g.some(T=>b.matches(T)))return{v:!0}};for(var v of f){var y=m(v);if(typeof y=="object")return y.v}return!1}(o,n))return!1;var d=Ue.getComputedStyle(e);if(d&&d.getPropertyValue("cursor")==="pointer"&&t.type==="click")return!0;var h=e.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(i||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(i||["change","click"]).indexOf(t.type)>=0;default:return a?(i||["click"]).indexOf(t.type)>=0:(i||["click"]).indexOf(t.type)>=0&&(wj.indexOf(h)>-1||e.getAttribute("contenteditable")==="true")}}function xj(e){for(var t=e;t.parentNode&&!jp(t,"body");t=t.parentNode){var n=NE(t);if(pr(n,"ph-sensitive")||pr(n,"ph-no-capture"))return!1}if(pr(NE(e),"ph-include"))return!0;var r=e.type||"";if(Hs(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=e.name||e.id||"";return!(Hs(i)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))}function T$e(e){return!!(jp(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||jp(e,"select")||jp(e,"textarea")||e.getAttribute("contenteditable")==="true")}var _$e="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",SGe=new RegExp("^(?:".concat(_$e,")$")),$Ge=new RegExp(_$e),P$e="\\d{3}-?\\d{2}-?\\d{4}",kGe=new RegExp("^(".concat(P$e,")$")),TGe=new RegExp("(".concat(P$e,")"));function Wb(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(ii(e)||Hs(e)&&(e=yA(e),(t?SGe:$Ge).test((e||"").replace(/[- ]/g,""))||(t?kGe:TGe).test(e)))}function C$e(e){var t=xA(e);return Wb(t="".concat(t," ").concat(Q$e(e)).trim())?t:""}function Q$e(e){var t="";return e&&e.childNodes&&e.childNodes.length&&vi(e.childNodes,function(n){var r;if(n&&((r=n.tagName)===null||r===void 0?void 0:r.toLowerCase())==="span")try{var i=xA(n);t="".concat(t," ").concat(i).trim(),n.childNodes&&n.childNodes.length&&(t="".concat(t," ").concat(Q$e(n)).trim())}catch(s){fn.error("[AutoCapture]",s)}}),t}function _Ge(e){return function(t){var n=t.map(r=>{var i,s,a="";if(r.tag_name&&(a+=r.tag_name),r.attr_class)for(var o of(r.attr_class.sort(),r.attr_class))a+=".".concat(o.replace(/"/g,""));var l=Ke(Ke(Ke(Ke({},r.text?{text:r.text}:{}),{},{"nth-child":(i=r.nth_child)!==null&&i!==void 0?i:0,"nth-of-type":(s=r.nth_of_type)!==null&&s!==void 0?s:0},r.href?{href:r.href}:{}),r.attr_id?{attr_id:r.attr_id}:{}),r.attributes),c={};return yQ(l).sort((u,d)=>{var[h]=u,[f]=d;return h.localeCompare(f)}).forEach(u=>{var[d,h]=u;return c[_te(d.toString())]=_te(h.toString())}),a+=":",a+=yQ(l).map(u=>{var[d,h]=u;return"".concat(d,'="').concat(h,'"')}).join("")});return n.join(";")}(function(t){return t.map(n=>{var r,i,s={text:(r=n.$el_text)===null||r===void 0?void 0:r.slice(0,400),tag_name:n.tag_name,href:(i=n.attr__href)===null||i===void 0?void 0:i.slice(0,2048),attr_class:PGe(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return yQ(n).filter(a=>{var[o]=a;return o.indexOf("attr__")===0}).forEach(a=>{var[o,l]=a;return s.attributes[o]=l}),s})}(e))}function _te(e){return e.replace(/"|\\"/g,'\\"')}function PGe(e){var t=e.attr__class;return t?gs(t)?t:MV(t):void 0}class E$e{constructor(){this.clicks=[]}isRageClick(t,n,r){var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(t-i.x)+Math.abs(n-i.y)<30&&r-i.timestamp<1e3){if(this.clicks.push({x:t,y:n,timestamp:r}),this.clicks.length===3)return!0}else this.clicks=[{x:t,y:n,timestamp:r}];return!1}}var CGe=["localhost","127.0.0.1"],ab=e=>{var t=tn?.createElement("a");return Gt(t)?null:(t.href=e,t)},QGe=function(e){var t,n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",i=[];return vi(e,function(s,a){Gt(s)||Gt(a)||a==="undefined"||(t=encodeURIComponent((o=>o instanceof File)(s)?s.name:s.toString()),n=encodeURIComponent(a),i[i.length]=n+"="+t)}),i.join(r)},FE=function(e,t){for(var n,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<r.length;i++){var s=r[i].split("=");if(s[0]===t){n=s;break}}if(!gs(n)||n.length<2)return"";var a=n[1];try{a=decodeURIComponent(a)}catch{fn.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},k6=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split("#"),i=r[0]||"",s=r[1],a=i.split("?"),o=a[1],l=a[0],c=(o||"").split("&"),u=[],d=0;d<c.length;d++){var h=c[d].split("=");gs(h)&&(t.includes(h[0])?u.push(h[0]+"="+n):u.push(c[d]))}var f=l;return o!=null&&(f+="?"+u.join("&")),s!=null&&(f+="#"+s),f},ME=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},Pte=Ro("[AutoCapture]");function T6(e,t){return t.length>e?t.slice(0,e)+"...":t}function EGe(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!wA(t));return t}function RGe(e,t,n,r){var i=e.tagName.toLowerCase(),s={tag_name:i};wj.indexOf(i)>-1&&!n&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=T6(1024,C$e(e)):s.$el_text=T6(1024,xA(e)));var a=NE(e);a.length>0&&(s.classes=a.filter(function(u){return u!==""})),vi(e.attributes,function(u){var d;if((!T$e(e)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!t&&Wb(u.value)&&(d=u.name,!Hs(d)||d.substring(0,10)!=="_ngcontent"&&d.substring(0,7)!=="_nghost")){var h=u.value;u.name==="class"&&(h=MV(h).join(" ")),s["attr__"+u.name]=T6(1024,h)}});for(var o=1,l=1,c=e;c=EGe(c);)o++,c.tagName===e.tagName&&l++;return s.nth_child=o,s.nth_of_type=l,s}function AGe(e,t){for(var n,r,{e:i,maskAllElementAttributes:s,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:l}=t,c=[e],u=e;u.parentNode&&!jp(u,"body");)x$e(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var d,h=[],f={},O=!1,g=!1;if(vi(c,T=>{var x=xj(T);T.tagName.toLowerCase()==="a"&&(O=T.getAttribute("href"),O=x&&O&&Wb(O)&&O),pr(NE(T),"ph-no-capture")&&(g=!0),h.push(RGe(T,s,a,o));var S=function(k){if(!xj(k))return{};var _={};return vi(k.attributes,function(P){if(P.name&&P.name.indexOf("data-ph-capture-attribute")===0){var C=P.name.replace("data-ph-capture-attribute-",""),Q=P.value;C&&Q&&Wb(Q)&&(_[C]=Q)}}),_}(T);Ts(f,S)}),g)return{props:{},explicitNoCapture:g};if(a||(e.tagName.toLowerCase()==="a"||e.tagName.toLowerCase()==="button"?h[0].$el_text=C$e(e):h[0].$el_text=xA(e)),O){var m,v;h[0].attr__href=O;var y=(m=ab(O))===null||m===void 0?void 0:m.host,b=Ue==null||(v=Ue.location)===null||v===void 0?void 0:v.host;y&&b&&y!==b&&(d=O)}return{props:Ts({$event_type:i.type,$ce_version:1},l?{}:{$elements:h},{$elements_chain:_Ge(h)},(n=h[0])!==null&&n!==void 0&&n.$el_text?{$el_text:(r=h[0])===null||r===void 0?void 0:r.$el_text}:{},d&&i.type==="click"?{$external_click_url:d}:{},f)}}let XGe=class{constructor(t){Et(this,"_initialized",!1),Et(this,"_isDisabledServerSide",null),Et(this,"rageclicks",new E$e),Et(this,"_elementsChainAsString",!1),this.instance=t,this._elementSelectors=null}get config(){var t,n,r=ms(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=(t=r.url_allowlist)===null||t===void 0?void 0:t.map(i=>new RegExp(i)),r.url_ignorelist=(n=r.url_ignorelist)===null||n===void 0?void 0:n.map(i=>new RegExp(i)),r}_addDomEventHandlers(){if(this.isBrowserSupported()){if(Ue&&tn){var t=r=>{r=r||Ue?.event;try{this._captureEvent(r)}catch(i){Pte.error("Failed to capture event",i)}};if(Cs(tn,"submit",t,{capture:!0}),Cs(tn,"change",t,{capture:!0}),Cs(tn,"click",t,{capture:!0}),this.config.capture_copied_text){var n=r=>{r=r||Ue?.event,this._captureEvent(r,x6)};Cs(tn,"copy",n,{capture:!0}),Cs(tn,"cut",n,{capture:!0})}}}else Pte.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[fte]:!!t.autocapture_opt_out}),this._isDisabledServerSide=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this._elementSelectors=t}getElementSelectors(t){var n,r=[];return(n=this._elementSelectors)===null||n===void 0||n.forEach(i=>{var s=tn?.querySelectorAll(i);s?.forEach(a=>{t===a&&r.push(i)})}),r}get isEnabled(){var t,n,r=(t=this.instance.persistence)===null||t===void 0?void 0:t.props[fte],i=this._isDisabledServerSide;if(xg(i)&&!Pf(r)&&!this.instance.config.advanced_disable_decide)return!1;var s=(n=this._isDisabledServerSide)!==null&&n!==void 0?n:!!r;return!!this.instance.config.autocapture&&!s}_captureEvent(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"$autocapture";if(this.isEnabled){var r,i=$$e(t);w$e(i)&&(i=i.parentNode||null),n==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!==null&&r!==void 0&&r.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._captureEvent(t,"$rageclick");var s=n===x6;if(i&&xGe(i,t,this.config,s,s?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:o}=AGe(i,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(o)return!1;var l=this.getElementSelectors(i);if(l&&l.length>0&&(a.$element_selectors=l),n===x6){var c,u=S$e(Ue==null||(c=Ue.getSelection())===null||c===void 0?void 0:c.toString()),d=t.type||"clipboard";if(!u)return!1;a.$selected_content=u,a.$copy_type=d}return this.instance.capture(n,a),!0}}}isBrowserSupported(){return nd(tn?.querySelectorAll)}};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Yo(e)&&isFinite(e)&&Math.floor(e)===e});var Cte="0123456789abcdef";let DGe=class Sj{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||t<0||n<0||r<0||i<0||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/Math.pow(2,8),s[5]=t,s[6]=112|n>>>8,s[7]=n,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=i>>>24,s[13]=i>>>16,s[14]=i>>>8,s[15]=i,new Sj(s)}toString(){for(var t="",n=0;n<this.bytes.length;n++)t=t+Cte.charAt(this.bytes[n]>>>4)+Cte.charAt(15&this.bytes[n]),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Sj(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;n<16;n++){var r=this.bytes[n]-t.bytes[n];if(r!==0)return Math.sign(r)}return 0}},IGe=class{constructor(){Et(this,"timestamp",0),Et(this,"counter",0),Et(this,"random",new NGe)}generate(){var t=this.generateOrAbort();if(Gt(t)){this.timestamp=0;var n=this.generateOrAbort();if(Gt(n))throw new Error("Could not generate UUID after timestamp reset");return n}return t}generateOrAbort(){var t=Date.now();if(t>this.timestamp)this.timestamp=t,this.resetCounter();else{if(!(t+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return DGe.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}};var Qte,R$e=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};Ue&&!Gt(Ue.crypto)&&crypto.getRandomValues&&(R$e=e=>crypto.getRandomValues(e));let NGe=class{constructor(){Et(this,"buffer",new Uint32Array(8)),Et(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(R$e(this.buffer),this.cursor=0),this.buffer[this.cursor++]}};var xp=()=>FGe().toString(),FGe=()=>(Qte||(Qte=new IGe)).generate(),MGe="Thu, 01 Jan 1970 00:00:00 GMT",sx="",LGe=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function jGe(e,t){if(t){var n=function(i){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:tn;if(sx)return sx;if(!s||["localhost","127.0.0.1"].includes(i))return"";for(var a=i.split("."),o=Math.min(a.length,8),l="dmn_chk_"+xp(),c=new RegExp("(^|;)\\s*"+l+"=1");!sx&&o--;){var u=a.slice(o).join("."),d=l+"=1;domain=."+u;s.cookie=d,c.test(s.cookie)&&(s.cookie=d+";expires="+MGe,sx=u)}return sx}(e);if(!n){var r=(i=>{var s=i.match(LGe);return s?s[0]:""})(e);r!==n&&fn.info("Warning: cookie subdomain discovery mismatch",r,n),n=r}return n?"; domain=."+n:""}return""}var up,jf={is_supported:()=>!!tn,error:function(e){fn.error("cookieStore error: "+e)},get:function(e){if(tn){try{for(var t=e+"=",n=tn.cookie.split(";").filter(s=>s.length),r=0;r<n.length;r++){for(var i=n[r];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}}catch{}return null}},parse:function(e){var t;try{t=JSON.parse(jf.get(e))||{}}catch{}return t},set:function(e,t,n,r,i){if(tn)try{var s="",a="",o=jGe(tn.location.hostname,r);if(n){var l=new Date;l.setTime(l.getTime()+24*n*60*60*1e3),s="; expires="+l.toUTCString()}i&&(a="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; SameSite=Lax; path=/"+o+a;return c.length>3686.4&&fn.warn("cookieStore warning: large cookie, len="+c.length),tn.cookie=c,c}catch{return}},remove:function(e,t){try{jf.set(e,"",-1,t)}catch{return}}},_6=null,aa={is_supported:function(){if(!xg(_6))return _6;var e=!0;if(Gt(Ue))e=!1;else try{var t="__mplssupport__";aa.set(t,"xyz"),aa.get(t)!=='"xyz"'&&(e=!1),aa.remove(t)}catch{e=!1}return e||fn.error("localStorage unsupported; falling back to cookie store"),_6=e,e},error:function(e){fn.error("localStorage error: "+e)},get:function(e){try{return Ue?.localStorage.getItem(e)}catch(t){aa.error(t)}return null},parse:function(e){try{return JSON.parse(aa.get(e))||{}}catch{}return null},set:function(e,t){try{Ue?.localStorage.setItem(e,JSON.stringify(t))}catch(n){aa.error(n)}},remove:function(e){try{Ue?.localStorage.removeItem(e)}catch(t){aa.error(t)}}},qGe=["distinct_id",XE,pS,IE,bj],UP=Ke(Ke({},aa),{},{parse:function(e){try{var t={};try{t=jf.parse(e)||{}}catch{}var n=Ts(t,JSON.parse(aa.get(e)||"{}"));return aa.set(e,n),n}catch{}return null},set:function(e,t,n,r,i,s){try{aa.set(e,t,void 0,void 0,s);var a={};qGe.forEach(o=>{t[o]&&(a[o]=t[o])}),Object.keys(a).length&&jf.set(e,a,n,r,i,s)}catch(o){aa.error(o)}},remove:function(e,t){try{Ue?.localStorage.removeItem(e),jf.remove(e,t)}catch(n){aa.error(n)}}}),WP={},zGe={is_supported:function(){return!0},error:function(e){fn.error("memoryStorage error: "+e)},get:function(e){return WP[e]||null},parse:function(e){return WP[e]||null},set:function(e,t){WP[e]=t},remove:function(e){delete WP[e]}},Zg=null,Wa={is_supported:function(){if(!xg(Zg))return Zg;if(Zg=!0,Gt(Ue))Zg=!1;else try{var e="__support__";Wa.set(e,"xyz"),Wa.get(e)!=='"xyz"'&&(Zg=!1),Wa.remove(e)}catch{Zg=!1}return Zg},error:function(e){fn.error("sessionStorage error: ",e)},get:function(e){try{return Ue?.sessionStorage.getItem(e)}catch(t){Wa.error(t)}return null},parse:function(e){try{return JSON.parse(Wa.get(e))||null}catch{}return null},set:function(e,t){try{Ue?.sessionStorage.setItem(e,JSON.stringify(t))}catch(n){Wa.error(n)}},remove:function(e){try{Ue?.sessionStorage.removeItem(e)}catch(t){Wa.error(t)}}};(function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"})(up||(up={}));let UGe=class{constructor(t){this.instance=t}get config(){return this.instance.config}get consent(){return this.getDnt()?up.DENIED:this.storedConsent}isOptedOut(){return this.consent===up.DENIED||this.consent===up.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}optInOut(t){this.storage.set(this.storageKey,t?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}reset(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}get storageKey(){var{token:t,opt_out_capturing_cookie_prefix:n}=this.instance.config;return(n||"__ph_opt_in_out_")+t}get storedConsent(){var t=this.storage.get(this.storageKey);return t==="1"?up.GRANTED:t==="0"?up.DENIED:up.PENDING}get storage(){if(!this._storage){var t=this.config.opt_out_capturing_persistence_type;this._storage=t==="localStorage"?aa:jf;var n=t==="localStorage"?jf:aa;n.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut(n.get(this.storageKey)==="1"),n.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!m$e([uc?.doNotTrack,uc?.msDoNotTrack,Un.doNotTrack],t=>pr([!0,1,"1","yes"],t))}};var GP=Ro("[Dead Clicks]"),WGe=()=>!0,GGe=e=>{var t,n=!((t=e.instance.persistence)===null||t===void 0||!t.get_property(y$e)),r=e.instance.config.capture_dead_clicks;return Pf(r)?r:n};let A$e=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(t,n,r){this.instance=t,this.isEnabled=n,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(t){this.instance.persistence&&this.instance.persistence.register({[y$e]:t?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(t){var n,r,i;(n=Un.__PosthogExtensions__)!==null&&n!==void 0&&n.initDeadClicksAutocapture&&t(),(r=Un.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"dead-clicks-autocapture",s=>{s?GP.error("failed to load script",s):t()})}start(){var t;if(tn){if(!this._lazyLoadedDeadClicksAutocapture&&(t=Un.__PosthogExtensions__)!==null&&t!==void 0&&t.initDeadClicksAutocapture){var n=ms(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Un.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this._lazyLoadedDeadClicksAutocapture.start(tn),GP.info("starting...")}}else GP.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,GP.info("stopping..."))}};var P6=Ro("[ExceptionAutocapture]");let VGe=class{constructor(t){var n;Et(this,"startCapturing",()=>{var r;if(Ue&&this.isEnabled&&(r=Un.__PosthogExtensions__)!==null&&r!==void 0&&r.errorWrappingFunctions){var i=Un.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=Un.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=Un.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.unwrapOnError&&this.config.capture_unhandled_errors&&(this.unwrapOnError=i(this.captureException.bind(this))),!this.unwrapUnhandledRejection&&this.config.capture_unhandled_rejections&&(this.unwrapUnhandledRejection=s(this.captureException.bind(this))),!this.unwrapConsoleError&&this.config.capture_console_errors&&(this.unwrapConsoleError=a(this.captureException.bind(this)))}catch(o){P6.error("failed to start",o),this.stopCapturing()}}}),this.instance=t,this.remoteEnabled=!((n=this.instance.persistence)===null||n===void 0||!n.props[Ote]),this.config=this.requiredConfig(),this.startIfEnabled()}requiredConfig(){var t=this.instance.config.capture_exceptions,n={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return ms(t)?n=Ke(Ke({},n),t):(Gt(t)?this.remoteEnabled:t)&&(n=Ke(Ke({},n),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),n}get isEnabled(){return this.config.capture_console_errors||this.config.capture_unhandled_errors||this.config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(P6.info("enabled"),this.loadScript(this.startCapturing))}loadScript(t){var n,r,i;(n=Un.__PosthogExtensions__)!==null&&n!==void 0&&n.errorWrappingFunctions&&t(),(r=Un.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"exception-autocapture",s=>{if(s)return P6.error("failed to load script",s);t()})}stopCapturing(){var t,n,r;(t=this.unwrapOnError)===null||t===void 0||t.call(this),this.unwrapOnError=void 0,(n=this.unwrapUnhandledRejection)===null||n===void 0||n.call(this),this.unwrapUnhandledRejection=void 0,(r=this.unwrapConsoleError)===null||r===void 0||r.call(this),this.unwrapConsoleError=void 0}onRemoteConfig(t){var n=t.autocaptureExceptions;this.remoteEnabled=!!n||!1,this.config=this.requiredConfig(),this.instance.persistence&&this.instance.persistence.register({[Ote]:this.remoteEnabled}),this.startIfEnabled()}captureException(t){var n=this.instance.requestRouter.endpointFor("ui");t.$exception_personURL="".concat(n,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(t)}};function X$e(e){return!Gt(Event)&&D$e(e,Event)}function D$e(e,t){try{return e instanceof t}catch{return!1}}function wQ(e,t){return Object.prototype.toString.call(e)==="[object ".concat(t,"]")}function C6(e){return wQ(e,"DOMError")}var Ete=/\(error: (.*)\)/,Rte=50,Uy="?";function Q6(e,t,n,r){var i={platform:"web:javascript",filename:e,function:t==="<anonymous>"?Uy:t,in_app:!0};return Gt(n)||(i.lineno=n),Gt(r)||(i.colno=r),i}var BGe=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,YGe=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ZGe=/\((\S*)(?::(\d+))(?::(\d+))\)/,HGe=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,KGe=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,JGe=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=t.sort((i,s)=>i[0]-s[0]).map(i=>i[1]);return function(i){for(var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=[],o=i.split(`
3
3
  `),l=s;l<o.length;l++){var c=o[l];if(!(c.length>1024)){var u=Ete.test(c)?c.replace(Ete,"$1"):c;if(!u.match(/\S*Error: /)){for(var d of r){var h=d(u);if(h){a.push(h);break}}if(a.length>=Rte)break}}}return function(f){if(!f.length)return[];var O=Array.from(f);return O.reverse(),O.slice(0,Rte).map(g=>Ke(Ke({},g),{},{filename:g.filename||eVe(O).filename,function:g.function||Uy}))}(a)}}([30,e=>{var t=BGe.exec(e);if(t){var[,n,r,i]=t;return Q6(n,Uy,+r,+i)}var s=YGe.exec(e);if(s){if(s[2]&&s[2].indexOf("eval")===0){var a=ZGe.exec(s[2]);a&&(s[2]=a[1],s[3]=a[2],s[4]=a[3])}var[o,l]=Xte(s[1]||Uy,s[2]);return Q6(l,o,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}}],[50,e=>{var t=HGe.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var n=KGe.exec(t[3]);n&&(t[1]=t[1]||"eval",t[3]=n[1],t[4]=n[2],t[5]="")}var r=t[3],i=t[1]||Uy;return[i,r]=Xte(i,r),Q6(r,i,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]);function eVe(e){return e[e.length-1]||{}}var VP,Ate,E6,Xte=(e,t)=>{var n=e.indexOf("safari-extension")!==-1,r=e.indexOf("safari-web-extension")!==-1;return n||r?[e.indexOf("@")!==-1?e.split("@")[0]:Uy,n?"safari-extension:".concat(t):"safari-web-extension:".concat(t)]:[e,t]},tVe=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function LV(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=e.stacktrace||e.stack||"",r=function(a){return a&&nVe.test(a.message)?1:0}(e);try{var i=JGe,s=function(a,o){var l=function(c){var u=globalThis._posthogChunkIds;if(!u)return{};var d=Object.keys(u);return E6&&d.length===Ate||(Ate=d.length,E6=d.reduce((h,f)=>{VP||(VP={});var O=VP[f];if(O)h[O[0]]=O[1];else for(var g=c(f),m=g.length-1;m>=0;m--){var v=g[m],y=v?.filename,b=u[f];if(y&&b){h[y]=b,VP[f]=[y,b];break}}return h},{})),E6}(o);return a.forEach(c=>{c.filename&&(c.chunk_id=l[c.filename])}),a}(i(n,r),i);return s.slice(0,s.length-t)}catch{}return[]}var nVe=/Minified React error #\d+;/i;function R6(e,t){var n,r,i=LV(e),s=(n=t?.handled)===null||n===void 0||n,a=(r=t?.synthetic)!==null&&r!==void 0&&r;return{$exception_list:[{type:t!=null&&t.overrideExceptionType?t.overrideExceptionType:e.name,value:function(o){var l=o.message;return l.error&&typeof l.error.message=="string"?String(l.error.message):String(l)}(e),stacktrace:{frames:i,type:"raw"},mechanism:{handled:s,synthetic:a}}],$exception_level:"error"}}function A6(e,t){var n,r,i,s=(n=t?.handled)===null||n===void 0||n,a=(r=t?.synthetic)===null||r===void 0||r,o={type:t!=null&&t.overrideExceptionType?t.overrideExceptionType:(i=t?.defaultExceptionType)!==null&&i!==void 0?i:"Error",value:e||t?.defaultExceptionMessage,mechanism:{handled:s,synthetic:a}};if(t!=null&&t.syntheticException){var l=LV(t.syntheticException,1);l.length&&(o.stacktrace={frames:l,type:"raw"})}return{$exception_list:[o],$exception_level:"error"}}function rVe(e){return Hs(e)&&!dj(e)&&hGe.indexOf(e)>=0}function iVe(e,t){var n,r,i=(n=t?.handled)===null||n===void 0||n,s=(r=t?.synthetic)===null||r===void 0||r,a=t!=null&&t.overrideExceptionType?t.overrideExceptionType:X$e(e)?e.constructor.name:"Error",o="Non-Error 'exception' captured with keys: ".concat(function(u){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:40,h=Object.keys(u);if(h.sort(),!h.length)return"[object has no keys]";for(var f=h.length;f>0;f--){var O=h.slice(0,f).join(", ");if(!(O.length>d))return f===h.length||O.length<=d?O:"".concat(O.slice(0,d),"...")}return""}(e)),l={type:a,value:o,mechanism:{handled:i,synthetic:s}};if(t!=null&&t.syntheticException){var c=LV(t?.syntheticException,1);c.length&&(l.stacktrace={frames:c,type:"raw"})}return{$exception_list:[l],$exception_level:rVe(e.level)?e.level:"error"}}function sVe(e,t){var{error:n,event:r}=e,i={$exception_list:[]},s=n||r;if(C6(s)||function(f){return wQ(f,"DOMException")}(s)){var a=s;if(function(f){return"stack"in f}(s))i=R6(s,t);else{var o=a.name||(C6(a)?"DOMError":"DOMException"),l=a.message?"".concat(o,": ").concat(a.message):o,c=C6(a)?"DOMError":"DOMException";i=A6(l,Ke(Ke({},t),{},{overrideExceptionType:c,defaultExceptionMessage:l}))}return"code"in a&&(i.$exception_DOMException_code="".concat(a.code)),i}if(function(f){return wQ(f,"ErrorEvent")}(s)&&s.error)return R6(s.error,t);if(function(f){switch(Object.prototype.toString.call(f)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return D$e(f,Error)}}(s))return R6(s,t);if(function(f){return wQ(f,"Object")}(s)||X$e(s))return iVe(s,t);if(Gt(n)&&Hs(r)){var u="Error",d=r,h=r.match(tVe);return h&&(u=h[1],d=h[2]),A6(d,Ke(Ke({},t),{},{overrideExceptionType:u,defaultExceptionMessage:d}))}return A6(s,t)}function LE(e){var t,n;return((t=JSON.stringify(e,(n=[],function(r,i){if(ms(i)){for(;n.length>0&&n[n.length-1]!==this;)n.pop();return n.includes(i)?"[Circular]":(n.push(i),i)}return i})))===null||t===void 0?void 0:t.length)||0}function $j(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:66060288e-1;if(e.size>=t&&e.data.length>1){var n=Math.floor(e.data.length/2),r=e.data.slice(0,n),i=e.data.slice(n);return[$j({size:LE(r),data:r,sessionId:e.sessionId,windowId:e.windowId}),$j({size:LE(i),data:i,sessionId:e.sessionId,windowId:e.windowId})].flatMap(s=>s)}return[e]}var Of=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(Of||{}),ju=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(ju||{}),kj="[SessionRecording]",Tj="redacted",BP={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com"]},aVe=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],oVe=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],lVe=["/s/","/e/","/i/"];function Dte(e,t,n,r){if(ii(e))return e;var i=t?.["content-length"]||function(s){return new Blob([s]).size}(e);return Hs(i)&&(i=parseInt(i)),i>n?kj+" ".concat(r," body too large to record (").concat(i," bytes)"):e}function Ite(e,t){if(ii(e))return e;var n=e;return Wb(n,!1)||(n=kj+" "+t+" body "+Tj),vi(oVe,r=>{var i,s;(i=n)!==null&&i!==void 0&&i.length&&((s=n)===null||s===void 0?void 0:s.indexOf(r))!==-1&&(n=kj+" "+t+" body "+Tj+" as might contain: "+r)}),n}var cVe=(e,t)=>{var n,r,i,s={payloadSizeLimitBytes:BP.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...BP.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...BP.payloadHostDenyList]},a=e.session_recording.recordHeaders!==!1&&t.recordHeaders,o=e.session_recording.recordBody!==!1&&t.recordBody,l=e.capture_performance!==!1&&t.recordPerformance,c=(n=s,i=Math.min(1e6,(r=n.payloadSizeLimitBytes)!==null&&r!==void 0?r:1e6),h=>(h!=null&&h.requestBody&&(h.requestBody=Dte(h.requestBody,h.requestHeaders,i,"Request")),h!=null&&h.responseBody&&(h.responseBody=Dte(h.responseBody,h.responseHeaders,i,"Response")),h)),u=h=>{return c(((g,m)=>{var v,y=ab(g.name),b=m.indexOf("http")===0?(v=ab(m))===null||v===void 0?void 0:v.pathname:m;b==="/"&&(b="");var T=y?.pathname.replace(b||"","");if(!(y&&T&&lVe.some(x=>T.indexOf(x)===0)))return g})((O=(f=h).requestHeaders,ii(O)||vi(Object.keys(O??{}),g=>{aVe.includes(g.toLowerCase())&&(O[g]=Tj)}),f),e.api_host));var f,O},d=nd(e.session_recording.maskNetworkRequestFn);return d&&nd(e.session_recording.maskCapturedNetworkRequestFn)&&fn.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),d&&(e.session_recording.maskCapturedNetworkRequestFn=h=>{var f=e.session_recording.maskNetworkRequestFn({url:h.name});return Ke(Ke({},h),{},{name:f?.url})}),s.maskRequestFn=nd(e.session_recording.maskCapturedNetworkRequestFn)?h=>{var f,O,g,m=u(h);return m&&(f=(O=(g=e.session_recording).maskCapturedNetworkRequestFn)===null||O===void 0?void 0:O.call(g,m))!==null&&f!==void 0?f:void 0}:h=>function(f){if(!Gt(f))return f.requestBody=Ite(f.requestBody,"Request"),f.responseBody=Ite(f.responseBody,"Response"),f}(u(h)),Ke(Ke(Ke({},BP),s),{},{recordHeaders:a,recordBody:o,recordPerformance:l,recordInitialRequests:l})};function Jc(e,t,n,r,i){return t>n&&(fn.warn("min cannot be greater than max."),t=n),Yo(e)?e>n?(r&&fn.warn(r+" cannot be greater than max: "+n+". Using max value instead."),n):e<t?(r&&fn.warn(r+" cannot be less than min: "+t+". Using min value instead."),t):e:(r&&fn.warn(r+" must be a number. using max or fallback. max: "+n+", fallback: "+i),Jc(i||n,t,n,r))}let uVe=class{constructor(t){var n,r,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Et(this,"bucketSize",100),Et(this,"refillRate",10),Et(this,"mutationBuckets",{}),Et(this,"loggedTracker",{}),Et(this,"refillBuckets",()=>{Object.keys(this.mutationBuckets).forEach(s=>{this.mutationBuckets[s]=this.mutationBuckets[s]+this.refillRate,this.mutationBuckets[s]>=this.bucketSize&&delete this.mutationBuckets[s]})}),Et(this,"getNodeOrRelevantParent",s=>{var a=this.rrweb.mirror.getNode(s);if(a?.nodeName!=="svg"&&a instanceof Element){var o=a.closest("svg");if(o)return[this.rrweb.mirror.getId(o),o]}return[s,a]}),Et(this,"numberOfChanges",s=>{var a,o,l,c,u,d,h,f;return((a=(o=s.removes)===null||o===void 0?void 0:o.length)!==null&&a!==void 0?a:0)+((l=(c=s.attributes)===null||c===void 0?void 0:c.length)!==null&&l!==void 0?l:0)+((u=(d=s.texts)===null||d===void 0?void 0:d.length)!==null&&u!==void 0?u:0)+((h=(f=s.adds)===null||f===void 0?void 0:f.length)!==null&&h!==void 0?h:0)}),Et(this,"throttleMutations",s=>{if(s.type!==3||s.data.source!==0)return s;var a=s.data,o=this.numberOfChanges(a);a.attributes&&(a.attributes=a.attributes.filter(c=>{var u,d,h,[f,O]=this.getNodeOrRelevantParent(c.id);return this.mutationBuckets[f]===0?!1:(this.mutationBuckets[f]=(u=this.mutationBuckets[f])!==null&&u!==void 0?u:this.bucketSize,this.mutationBuckets[f]=Math.max(this.mutationBuckets[f]-1,0),this.mutationBuckets[f]===0&&(this.loggedTracker[f]||(this.loggedTracker[f]=!0,(d=(h=this.options).onBlockedNode)===null||d===void 0||d.call(h,f,O))),c)}));var l=this.numberOfChanges(a);return l!==0||o===l?s:void 0}),this.rrweb=t,this.options=i,this.refillRate=Jc((n=this.options.refillRate)!==null&&n!==void 0?n:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=Jc((r=this.options.bucketSize)!==null&&r!==void 0?r:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval(()=>{this.refillBuckets()},1e3)}};var cu=Uint8Array,$l=Uint16Array,Gb=Uint32Array,jV=new cu([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qV=new cu([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Nte=new cu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),I$e=function(e,t){for(var n=new $l(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new Gb(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return[n,i]},N$e=I$e(jV,2),dVe=N$e[0],_j=N$e[1];dVe[28]=258,_j[258]=28;for(var Fte=I$e(qV,0)[1],F$e=new $l(32768),Fi=0;Fi<32768;++Fi){var Hg=(43690&Fi)>>>1|(21845&Fi)<<1;Hg=(61680&(Hg=(52428&Hg)>>>2|(13107&Hg)<<2))>>>4|(3855&Hg)<<4,F$e[Fi]=((65280&Hg)>>>8|(255&Hg)<<8)>>>1}var US=function(e,t,n){for(var r=e.length,i=0,s=new $l(t);i<r;++i)++s[e[i]-1];var a,o=new $l(t);for(i=0;i<t;++i)o[i]=o[i-1]+s[i-1]<<1;for(a=new $l(r),i=0;i<r;++i)a[i]=F$e[o[e[i]-1]++]>>>15-e[i];return a},x0=new cu(288);for(Fi=0;Fi<144;++Fi)x0[Fi]=8;for(Fi=144;Fi<256;++Fi)x0[Fi]=9;for(Fi=256;Fi<280;++Fi)x0[Fi]=7;for(Fi=280;Fi<288;++Fi)x0[Fi]=8;var jE=new cu(32);for(Fi=0;Fi<32;++Fi)jE[Fi]=5;var hVe=US(x0,9),fVe=US(jE,5),M$e=function(e){return(e/8>>0)+(7&e&&1)},L$e=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof $l?$l:e instanceof Gb?Gb:cu)(n-t);return r.set(e.subarray(t,n)),r},Jh=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},ax=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},X6=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,s=n.slice();if(!i)return[new cu(0),0];if(i==1){var a=new cu(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort(function(x,S){return x.f-S.f}),n.push({s:-1,f:25001});var o=n[0],l=n[1],c=0,u=1,d=2;for(n[0]={s:-1,f:o.f+l.f,l:o,r:l};u!=i-1;)o=n[n[c].f<n[d].f?c++:d++],l=n[c!=u&&n[c].f<n[d].f?c++:d++],n[u++]={s:-1,f:o.f+l.f,l:o,r:l};var h=s[0].s;for(r=1;r<i;++r)s[r].s>h&&(h=s[r].s);var f=new $l(h+1),O=Pj(n[u-1],f,0);if(O>t){r=0;var g=0,m=O-t,v=1<<m;for(s.sort(function(x,S){return f[S.s]-f[x.s]||x.f-S.f});r<i;++r){var y=s[r].s;if(!(f[y]>t))break;g+=v-(1<<O-f[y]),f[y]=t}for(g>>>=m;g>0;){var b=s[r].s;f[b]<t?g-=1<<t-f[b]++-1:++r}for(;r>=0&&g;--r){var T=s[r].s;f[T]==t&&(--f[T],++g)}O=t}return[new cu(f),O]},Pj=function(e,t,n){return e.s==-1?Math.max(Pj(e.l,t,n+1),Pj(e.r,t,n+1)):t[e.s]=n},Mte=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new $l(++t),r=0,i=e[0],s=1,a=function(l){n[r++]=l},o=1;o<=t;++o)if(e[o]==i&&o!=t)++s;else{if(!i&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(i),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(i);s=1,i=e[o]}return[n.subarray(0,r),t]},ox=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Cj=function(e,t,n){var r=n.length,i=M$e(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var s=0;s<r;++s)e[i+s+4]=n[s];return 8*(i+4+r)},Lte=function(e,t,n,r,i,s,a,o,l,c,u){Jh(t,u++,n),++i[256];for(var d=X6(i,15),h=d[0],f=d[1],O=X6(s,15),g=O[0],m=O[1],v=Mte(h),y=v[0],b=v[1],T=Mte(g),x=T[0],S=T[1],k=new $l(19),_=0;_<y.length;++_)k[31&y[_]]++;for(_=0;_<x.length;++_)k[31&x[_]]++;for(var P=X6(k,7),C=P[0],Q=P[1],E=19;E>4&&!C[Nte[E-1]];--E);var A,L,j,q,z=c+5<<3,V=ox(i,x0)+ox(s,jE)+a,W=ox(i,h)+ox(s,g)+a+14+3*E+ox(k,C)+(2*k[16]+3*k[17]+7*k[18]);if(z<=V&&z<=W)return Cj(t,u,e.subarray(l,l+c));if(Jh(t,u,1+(W<V)),u+=2,W<V){A=US(h,f),L=h,j=US(g,m),q=g;var M=US(C,Q);for(Jh(t,u,b-257),Jh(t,u+5,S-1),Jh(t,u+10,E-4),u+=14,_=0;_<E;++_)Jh(t,u+3*_,C[Nte[_]]);u+=3*E;for(var K=[y,x],N=0;N<2;++N){var D=K[N];for(_=0;_<D.length;++_){var B=31&D[_];Jh(t,u,M[B]),u+=C[B],B>15&&(Jh(t,u,D[_]>>>5&127),u+=D[_]>>>12)}}}else A=hVe,L=x0,j=fVe,q=jE;for(_=0;_<o;++_)if(r[_]>255){B=r[_]>>>18&31,ax(t,u,A[B+257]),u+=L[B+257],B>7&&(Jh(t,u,r[_]>>>23&31),u+=jV[B]);var G=31&r[_];ax(t,u,j[G]),u+=q[G],G>3&&(ax(t,u,r[_]>>>5&8191),u+=qV[G])}else ax(t,u,A[r[_]]),u+=L[r[_]];return ax(t,u,A[256]),u+L[256]},OVe=new Gb([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),pVe=function(){for(var e=new Gb(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),gVe=function(){var e=4294967295;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=pVe[255&n^t[r]]^n>>>8;e=n},d:function(){return 4294967295^e}}},mVe=function(e,t,n,r,i){return function(s,a,o,l,c,u){var d=s.length,h=new cu(l+d+5*(1+Math.floor(d/7e3))+c),f=h.subarray(l,h.length-c),O=0;if(!a||d<8)for(var g=0;g<=d;g+=65535){var m=g+65535;m<d?O=Cj(f,O,s.subarray(g,m)):(f[g]=u,O=Cj(f,O,s.subarray(g,d)))}else{for(var v=OVe[a-1],y=v>>>13,b=8191&v,T=(1<<o)-1,x=new $l(32768),S=new $l(T+1),k=Math.ceil(o/3),_=2*k,P=function(ve){return(s[ve]^s[ve+1]<<k^s[ve+2]<<_)&T},C=new Gb(25e3),Q=new $l(288),E=new $l(32),A=0,L=0,j=(g=0,0),q=0,z=0;g<d;++g){var V=P(g),W=32767&g,M=S[V];if(x[W]=M,S[V]=W,q<=g){var K=d-g;if((A>7e3||j>24576)&&K>423){O=Lte(s,f,0,C,Q,E,L,j,z,g-z,O),j=A=L=0,z=g;for(var N=0;N<286;++N)Q[N]=0;for(N=0;N<30;++N)E[N]=0}var D=2,B=0,G=b,ee=W-M&32767;if(K>2&&V==P(g-ee))for(var he=Math.min(y,K)-1,ae=Math.min(32767,g),se=Math.min(258,K);ee<=ae&&--G&&W!=M;){if(s[g+D]==s[g+D-ee]){for(var me=0;me<se&&s[g+me]==s[g+me-ee];++me);if(me>D){if(D=me,B=ee,me>he)break;var fe=Math.min(ee,me-2),Y=0;for(N=0;N<fe;++N){var Te=g-ee+N+32768&32767,ke=Te-x[Te]+32768&32767;ke>Y&&(Y=ke,M=Te)}}}ee+=(W=M)-(M=x[W])+32768&32767}if(B){C[j++]=268435456|_j[D]<<18|Fte[B];var Ve=31&_j[D],De=31&Fte[B];L+=jV[Ve]+qV[De],++Q[257+Ve],++E[De],q=g+D,++A}else C[j++]=s[g],++Q[s[g]]}}O=Lte(s,f,u,C,Q,E,L,j,z,g-z,O)}return L$e(h,0,l+M$e(O)+c)}(e,t.level==null?6:t.level,t.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)},Qj=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},vVe=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&Qj(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;r<=n.length;++r)e[r+10]=n.charCodeAt(r)}},yVe=function(e){return 10+(e.filename&&e.filename.length+1||0)};function j$e(e,t){t===void 0&&(t={});var n=gVe(),r=e.length;n.p(e);var i=mVe(e,t,yVe(t),8),s=i.length;return vVe(i,t),Qj(i,s-8,n.d()),Qj(i,s-4,r),i}function q$e(e,t){var n=e.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(e);for(var r=new cu(e.length+(e.length>>>1)),i=0,s=function(c){r[i++]=c},a=0;a<n;++a){if(i+5>r.length){var o=new cu(i+8+(n-a<<1));o.set(r),r=o}var l=e.charCodeAt(a);l<128||t?s(l):l<2048?(s(192|l>>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++a))>>>18),s(128|l>>>12&63),s(128|l>>>6&63),s(128|63&l)):(s(224|l>>>12),s(128|l>>>6&63),s(128|63&l))}return L$e(r,0,i)}function bVe(e,t){return function(n){for(var r=0,i=0;i<n.length;i++)r=(r<<5)-r+n.charCodeAt(i),r|=0;return Math.abs(r)}(e)%100<Jc(100*t,0,100)}var mS="[SessionRecording]",ro=Ro(mS);function YP(){var e,t;return Un==null||(e=Un.__PosthogExtensions__)===null||e===void 0||(t=e.rrweb)===null||t===void 0?void 0:t.record}var wVe=3e5,xVe=[ju.MouseMove,ju.MouseInteraction,ju.Scroll,ju.ViewportResize,ju.Input,ju.TouchMove,ju.MediaInteraction,ju.Drag],jte=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function Kg(e){return function(t,n){for(var r="",i=0;i<t.length;){var s=t[i++];r+=String.fromCharCode(s)}return r}(j$e(q$e(JSON.stringify(e))))}function qte(e){return e.type===Of.Custom&&e.data.tag==="sessionIdle"}function zte(e,t){return t.some(n=>n.matching==="regex"&&new RegExp(n.url).test(e))}let SVe=class{get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this._captureStarted}get sessionManager(){if(!this.instance.sessionManager)throw new Error(mS+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var t,n;return this.triggerStatus==="trigger_pending"?6e4:(t=(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.full_snapshot_interval_millis)!==null&&t!==void 0?t:wVe}get isSampled(){var t=this.instance.get_property(pS);return Pf(t)?t:null}get sessionDuration(){var t,n,r=(t=this.buffer)===null||t===void 0?void 0:t.data[((n=this.buffer)===null||n===void 0?void 0:n.data.length)-1],{sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return r?r.timestamp-i:null}get isRecordingEnabled(){var t=!!this.instance.get_property(fj),n=!this.instance.config.disable_session_recording;return Ue&&t&&n}get isConsoleLogCaptureEnabled(){var t=!!this.instance.get_property(mte),n=this.instance.config.enable_recording_console_log;return n??t}get canvasRecording(){var t,n,r,i,s,a,o=this.instance.config.session_recording.captureCanvas,l=this.instance.get_property(bte),c=(t=(n=o?.recordCanvas)!==null&&n!==void 0?n:l?.enabled)!==null&&t!==void 0&&t,u=(r=(i=o?.canvasFps)!==null&&i!==void 0?i:l?.fps)!==null&&r!==void 0?r:4,d=(s=(a=o?.canvasQuality)!==null&&a!==void 0?a:l?.quality)!==null&&s!==void 0?s:.4;if(typeof d=="string"){var h=parseFloat(d);d=isNaN(h)?.4:h}return{enabled:c,fps:Jc(u,0,12,"canvas recording fps",4),quality:Jc(d,0,1,"canvas recording quality",.4)}}get networkPayloadCapture(){var t,n,r=this.instance.get_property(vte),i={recordHeaders:(t=this.instance.config.session_recording)===null||t===void 0?void 0:t.recordHeaders,recordBody:(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.recordBody},s=i?.recordHeaders||r?.recordHeaders,a=i?.recordBody||r?.recordBody,o=ms(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,l=!!(Pf(o)?o:r?.capturePerformance);return s||a||l?{recordHeaders:s,recordBody:a,recordPerformance:l}:void 0}get masking(){var t,n,r,i,s,a,o=this.instance.get_property(yte),l={maskAllInputs:(t=this.instance.config.session_recording)===null||t===void 0?void 0:t.maskAllInputs,maskTextSelector:(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.maskTextSelector,blockSelector:(r=this.instance.config.session_recording)===null||r===void 0?void 0:r.blockSelector},c=(i=l?.maskAllInputs)!==null&&i!==void 0?i:o?.maskAllInputs,u=(s=l?.maskTextSelector)!==null&&s!==void 0?s:o?.maskTextSelector,d=(a=l?.blockSelector)!==null&&a!==void 0?a:o?.blockSelector;return Gt(c)&&Gt(u)&&Gt(d)?void 0:{maskAllInputs:c==null||c,maskTextSelector:u,blockSelector:d}}get sampleRate(){var t=this.instance.get_property(wte);return Yo(t)?t:null}get minimumDuration(){var t=this.instance.get_property(xte);return Yo(t)?t:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this.isSampled===!1?"disabled":this._urlBlocked?"paused":ii(this._linkedFlag)||this._linkedFlagSeen?this.triggerStatus==="trigger_pending"?"buffering":Pf(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var t;return this._urlTriggers.length===0?"trigger_disabled":((t=this.instance)===null||t===void 0?void 0:t.get_property(S6))===this.sessionId?"trigger_activated":"trigger_pending"}get eventTriggerStatus(){var t;return this._eventTriggers.length===0?"trigger_disabled":((t=this.instance)===null||t===void 0?void 0:t.get_property($6))===this.sessionId?"trigger_activated":"trigger_pending"}get triggerStatus(){var t=this.eventTriggerStatus==="trigger_activated"||this.urlTriggerStatus==="trigger_activated",n=this.eventTriggerStatus==="trigger_pending"||this.urlTriggerStatus==="trigger_pending";return t?"trigger_activated":n?"trigger_pending":"trigger_disabled"}constructor(t){if(Et(this,"queuedRRWebEvents",[]),Et(this,"isIdle","unknown"),Et(this,"_linkedFlagSeen",!1),Et(this,"_lastActivityTimestamp",Date.now()),Et(this,"_linkedFlag",null),Et(this,"_removePageViewCaptureHook",void 0),Et(this,"_onSessionIdListener",void 0),Et(this,"_persistDecideOnSessionListener",void 0),Et(this,"_samplingSessionListener",void 0),Et(this,"_urlTriggers",[]),Et(this,"_urlBlocklist",[]),Et(this,"_urlBlocked",!1),Et(this,"_eventTriggers",[]),Et(this,"_removeEventTriggerCaptureHook",void 0),Et(this,"_forceAllowLocalhostNetworkCapture",!1),Et(this,"_onBeforeUnload",()=>{this._flushBuffer()}),Et(this,"_onOffline",()=>{this._tryAddCustomEvent("browser offline",{})}),Et(this,"_onOnline",()=>{this._tryAddCustomEvent("browser online",{})}),Et(this,"_onVisibilityChange",()=>{if(tn!=null&&tn.visibilityState){var i="window "+tn.visibilityState;this._tryAddCustomEvent(i,{})}}),this.instance=t,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw ro.error("started without valid sessionManager"),new Error(mS+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(mS+" cannot be used with __preview_experimental_cookieless_mode.");var{sessionId:n,windowId:r}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=n,this.windowId=r,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&ro.warn("session_idle_threshold_ms (".concat(this.sessionIdleThresholdMilliseconds,") is greater than the session timeout (").concat(this.sessionManager.sessionTimeoutMs,"). Session will never be detected as idle"))}startIfEnabledOrStop(t){this.isRecordingEnabled?(this._startCapture(t),Cs(Ue,"beforeunload",this._onBeforeUnload),Cs(Ue,"offline",this._onOffline),Cs(Ue,"online",this._onOnline),Cs(Ue,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),ii(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance.on("eventCaptured",n=>{try{if(n.event==="$pageview"){var r=n!=null&&n.properties.$current_url?this._maskUrl(n?.properties.$current_url):"";if(!r)return;this._tryAddCustomEvent("$pageview",{href:r})}}catch(i){ro.error("Could not add $pageview to rrweb session",i)}})),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId((n,r,i)=>{var s,a,o,l;i&&(this._tryAddCustomEvent("$session_id_change",{sessionId:n,windowId:r,changeReason:i}),(s=this.instance)===null||s===void 0||(a=s.persistence)===null||a===void 0||a.unregister($6),(o=this.instance)===null||o===void 0||(l=o.persistence)===null||l===void 0||l.unregister(S6))}))):this.stopRecording()}stopRecording(){var t,n,r,i;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,Ue?.removeEventListener("beforeunload",this._onBeforeUnload),Ue?.removeEventListener("offline",this._onOffline),Ue?.removeEventListener("online",this._onOnline),Ue?.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),(t=this._removePageViewCaptureHook)===null||t===void 0||t.call(this),this._removePageViewCaptureHook=void 0,(n=this._removeEventTriggerCaptureHook)===null||n===void 0||n.call(this),this._removeEventTriggerCaptureHook=void 0,(r=this._onSessionIdListener)===null||r===void 0||r.call(this),this._onSessionIdListener=void 0,(i=this._samplingSessionListener)===null||i===void 0||i.call(this),this._samplingSessionListener=void 0,ro.info("stopped"))}_resetSampling(){var t;(t=this.instance.persistence)===null||t===void 0||t.unregister(pS)}makeSamplingDecision(t){var n,r=this.sessionId!==t,i=this.sampleRate;if(Yo(i)){var s=this.isSampled,a=r||!Pf(s),o=a?bVe(t,i):s;a&&(o?this._reportStarted("sampled"):ro.warn("Sample rate (".concat(i,") has determined that this sessionId (").concat(t,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:i,isSampled:o})),(n=this.instance.persistence)===null||n===void 0||n.register({[pS]:o})}else this._resetSampling()}onRemoteConfig(t){var n,r,i,s,a,o;if(this._tryAddCustomEvent("$remote_config_received",t),this._persistRemoteConfig(t),this._linkedFlag=((n=t.sessionRecording)===null||n===void 0?void 0:n.linkedFlag)||null,(r=t.sessionRecording)!==null&&r!==void 0&&r.endpoint&&(this._endpoint=(o=t.sessionRecording)===null||o===void 0?void 0:o.endpoint),this._setupSampling(),!ii(this._linkedFlag)&&!this._linkedFlagSeen){var l=Hs(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,c=Hs(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags((u,d)=>{var h=ms(d)&&l in d,f=c?d[l]===c:h;f&&this._reportStarted("linked_flag_matched",{linkedFlag:l,linkedVariant:c}),this._linkedFlagSeen=f})}(i=t.sessionRecording)!==null&&i!==void 0&&i.urlTriggers&&(this._urlTriggers=t.sessionRecording.urlTriggers),(s=t.sessionRecording)!==null&&s!==void 0&&s.urlBlocklist&&(this._urlBlocklist=t.sessionRecording.urlBlocklist),(a=t.sessionRecording)!==null&&a!==void 0&&a.eventTriggers&&(this._eventTriggers=t.sessionRecording.eventTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){Yo(this.sampleRate)&&ii(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId(t=>{this.makeSamplingDecision(t)}))}_persistRemoteConfig(t){if(this.instance.persistence){var n,r=this.instance.persistence,i=()=>{var s,a,o,l,c,u,d,h,f,O=(s=t.sessionRecording)===null||s===void 0?void 0:s.sampleRate,g=ii(O)?null:parseFloat(O);ii(g)&&this._resetSampling();var m=(a=t.sessionRecording)===null||a===void 0?void 0:a.minimumDurationMilliseconds;r.register({[fj]:!!t.sessionRecording,[mte]:(o=t.sessionRecording)===null||o===void 0?void 0:o.consoleLogRecordingEnabled,[vte]:Ke({capturePerformance:t.capturePerformance},(l=t.sessionRecording)===null||l===void 0?void 0:l.networkPayloadCapture),[yte]:(c=t.sessionRecording)===null||c===void 0?void 0:c.masking,[bte]:{enabled:(u=t.sessionRecording)===null||u===void 0?void 0:u.recordCanvas,fps:(d=t.sessionRecording)===null||d===void 0?void 0:d.canvasFps,quality:(h=t.sessionRecording)===null||h===void 0?void 0:h.canvasQuality},[wte]:g,[xte]:Gt(m)?null:m,[Ste]:(f=t.sessionRecording)===null||f===void 0?void 0:f.scriptConfig})};i(),(n=this._persistDecideOnSessionListener)===null||n===void 0||n.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(i)}}log(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"log";(n=this.instance.sessionRecording)===null||n===void 0||n.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:r,trace:[],payload:[JSON.stringify(t)]}},timestamp:Date.now()})}_startCapture(t){if(!Gt(Object.assign)&&!Gt(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var n,r;this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),YP()?this._onScriptLoaded():(n=Un.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this.instance,this.scriptName,i=>{if(i)return ro.error("could not load recorder",i);this._onScriptLoaded()}),ro.info("starting"),this.status==="active"&&this._reportStarted(t||"recording_initialized")}}get scriptName(){var t,n,r;return((t=this.instance)===null||t===void 0||(n=t.persistence)===null||n===void 0||(r=n.get_property(Ste))===null||r===void 0?void 0:r.script)||"recorder"}isInteractiveEvent(t){var n;return t.type===3&&xVe.indexOf((n=t.data)===null||n===void 0?void 0:n.source)!==-1}_updateWindowAndSessionIds(t){var n=this.isInteractiveEvent(t);n||this.isIdle||t.timestamp-this._lastActivityTimestamp>this.sessionIdleThresholdMilliseconds&&(this.isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:t.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this.sessionIdleThresholdMilliseconds,bufferLength:this.buffer.data.length,bufferSize:this.buffer.size}),this._flushBuffer());var r=!1;if(n&&(this._lastActivityTimestamp=t.timestamp,this.isIdle)){var i=this.isIdle==="unknown";this.isIdle=!1,i||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:t.type}),r=!0)}if(!this.isIdle){var{windowId:s,sessionId:a}=this.sessionManager.checkAndGetSessionAndWindowId(!n,t.timestamp),o=this.sessionId!==a,l=this.windowId!==s;this.windowId=s,this.sessionId=a,o||l?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):r&&this._scheduleFullSnapshot()}}_tryRRWebMethod(t){try{return t.rrwebMethod(),!0}catch(n){return this.queuedRRWebEvents.length<10?this.queuedRRWebEvents.push({enqueuedAt:t.enqueuedAt||Date.now(),attempt:t.attempt++,rrwebMethod:t.rrwebMethod}):ro.warn("could not emit queued rrweb event.",n,t),!1}}_tryAddCustomEvent(t,n){return this._tryRRWebMethod(jte(()=>YP().addCustomEvent(t,n)))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(jte(()=>YP().takeFullSnapshot()))}_onScriptLoaded(){var t,n,r,i,s={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},a=this.instance.config.session_recording;for(var[o,l]of Object.entries(a||{}))o in s&&(o==="maskInputOptions"?s.maskInputOptions=Ke({password:!0},l):s[o]=l);this.canvasRecording&&this.canvasRecording.enabled&&(s.recordCanvas=!0,s.sampling={canvas:this.canvasRecording.fps},s.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),this.masking&&(s.maskAllInputs=(n=this.masking.maskAllInputs)===null||n===void 0||n,s.maskTextSelector=(r=this.masking.maskTextSelector)!==null&&r!==void 0?r:void 0,s.blockSelector=(i=this.masking.blockSelector)!==null&&i!==void 0?i:void 0);var c=YP();if(c){this.mutationRateLimiter=(t=this.mutationRateLimiter)!==null&&t!==void 0?t:new uVe(c,{refillRate:this.instance.config.session_recording.__mutationRateLimiterRefillRate,bucketSize:this.instance.config.session_recording.__mutationRateLimiterBucketSize,onBlockedNode:(d,h)=>{var f="Too many mutations on node '".concat(d,"'. Rate limiting. This could be due to SVG animations or something similar");ro.info(f,{node:h}),this.log(mS+" "+f,"warn")}});var u=this._gatherRRWebPlugins();this.stopRrweb=c(Ke({emit:d=>{this.onRRwebEmit(d)},plugins:u},s)),this._lastActivityTimestamp=Date.now(),this.isIdle=Pf(this.isIdle)?this.isIdle:"unknown",this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:s,activePlugins:u.map(d=>d?.name)}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}else ro.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),this.isIdle!==!0){var t=this.fullSnapshotIntervalMillis;t&&(this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},t))}}_gatherRRWebPlugins(){var t,n,r,i,s=[],a=(t=Un.__PosthogExtensions__)===null||t===void 0||(n=t.rrwebPlugins)===null||n===void 0?void 0:n.getRecordConsolePlugin;a&&this.isConsoleLogCaptureEnabled&&s.push(a());var o=(r=Un.__PosthogExtensions__)===null||r===void 0||(i=r.rrwebPlugins)===null||i===void 0?void 0:i.getRecordNetworkPlugin;return this.networkPayloadCapture&&nd(o)&&(!CGe.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?s.push(o(cVe(this.instance.config,this.networkPayloadCapture))):ro.info("NetworkCapture not started because we are on localhost.")),s}onRRwebEmit(t){var n;if(this._processQueuedEvents(),t&&ms(t)){if(t.type===Of.Meta){var r=this._maskUrl(t.data.href);if(this._lastHref=r,!r)return;t.data.href=r}else this._pageViewFallBack();if(this._checkUrlTriggerConditions(),!this._urlBlocked||function(d){return d.type===Of.Custom&&d.data.tag==="recording paused"}(t)){t.type===Of.FullSnapshot&&this._scheduleFullSnapshot(),t.type===Of.FullSnapshot&&this.triggerStatus==="trigger_pending"&&this.clearBuffer();var i=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(t):t;if(i){var s=function(d){var h=d;if(h&&ms(h)&&h.type===6&&ms(h.data)&&h.data.plugin==="rrweb/console@1"){h.data.payload.payload.length>10&&(h.data.payload.payload=h.data.payload.payload.slice(0,10),h.data.payload.payload.push("...[truncated]"));for(var f=[],O=0;O<h.data.payload.payload.length;O++)h.data.payload.payload[O]&&h.data.payload.payload[O].length>2e3?f.push(h.data.payload.payload[O].slice(0,2e3)+"...[truncated]"):f.push(h.data.payload.payload[O]);return h.data.payload.payload=f,d}return d}(i);if(this._updateWindowAndSessionIds(s),this.isIdle!==!0||qte(s)){if(qte(s)){var a=s.data.payload;if(a){var o=a.lastActivityTimestamp,l=a.threshold;s.timestamp=o+l}}var c=(n=this.instance.config.session_recording.compress_events)===null||n===void 0||n?function(d){if(LE(d)<1024)return d;try{if(d.type===Of.FullSnapshot)return Ke(Ke({},d),{},{data:Kg(d.data),cv:"2024-10"});if(d.type===Of.IncrementalSnapshot&&d.data.source===ju.Mutation)return Ke(Ke({},d),{},{cv:"2024-10",data:Ke(Ke({},d.data),{},{texts:Kg(d.data.texts),attributes:Kg(d.data.attributes),removes:Kg(d.data.removes),adds:Kg(d.data.adds)})});if(d.type===Of.IncrementalSnapshot&&d.data.source===ju.StyleSheetRule)return Ke(Ke({},d),{},{cv:"2024-10",data:Ke(Ke({},d.data),{},{adds:d.data.adds?Kg(d.data.adds):void 0,removes:d.data.removes?Kg(d.data.removes):void 0})})}catch(h){ro.error("could not compress event - will use uncompressed event",h)}return d}(s):s,u={$snapshot_bytes:LE(c),$snapshot_data:c,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(u):this.clearBuffer()}}}}}_pageViewFallBack(){if(!this.instance.config.capture_pageview&&Ue){var t=this._maskUrl(Ue.location.href);this._lastHref!==t&&(this._tryAddCustomEvent("$url_changed",{href:t}),this._lastHref=t)}}_processQueuedEvents(){if(this.queuedRRWebEvents.length){var t=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],t.forEach(n=>{Date.now()-n.enqueuedAt<=2e3&&this._tryRRWebMethod(n)})}}_maskUrl(t){var n=this.instance.config.session_recording;if(n.maskNetworkRequestFn){var r,i={url:t};return(r=i=n.maskNetworkRequestFn(i))===null||r===void 0?void 0:r.url}return t}clearBuffer(){return this.buffer={size:0,data:[],sessionId:this.sessionId,windowId:this.windowId},this.buffer}_flushBuffer(){this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var t=this.minimumDuration,n=this.sessionDuration,r=Yo(n)&&n>=0,i=Yo(t)&&r&&n<t;return this.status==="buffering"||this.status==="paused"||this.status==="disabled"||i?(this.flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3),this.buffer):(this.buffer.data.length>0&&$j(this.buffer).forEach(s=>{this._captureSnapshot({$snapshot_bytes:s.size,$snapshot_data:s.data,$session_id:s.sessionId,$window_id:s.windowId,$lib:"web",$lib_version:wf.LIB_VERSION})}),this.clearBuffer())}_captureSnapshotBuffered(t){var n,r=2+(((n=this.buffer)===null||n===void 0?void 0:n.data.length)||0);!this.isIdle&&(this.buffer.size+t.$snapshot_bytes+r>943718.4||this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),this.buffer.size+=t.$snapshot_bytes,this.buffer.data.push(t.$snapshot_data),this.flushBufferTimer||this.isIdle||(this.flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3))}_captureSnapshot(t){this.instance.capture("$snapshot",t,{_url:this.instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}_checkUrlTriggerConditions(){if(Ue!==void 0&&Ue.location.href){var t=Ue.location.href,n=this._urlBlocked,r=zte(t,this._urlBlocklist);r&&!n?this._pauseRecording():!r&&n&&this._resumeRecording(),zte(t,this._urlTriggers)&&this._activateTrigger("url")}}_activateTrigger(t){var n,r;this.triggerStatus==="trigger_pending"&&((n=this.instance)===null||n===void 0||(r=n.persistence)===null||r===void 0||r.register({[t==="url"?S6:$6]:this.sessionId}),this._flushBuffer(),this._reportStarted(t+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),ro.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){this._urlBlocked&&(this._urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),ro.info("recording resumed"))}_addEventTriggerListener(){this._eventTriggers.length!==0&&ii(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",t=>{try{this._eventTriggers.includes(t.event)&&this._activateTrigger("event")}catch(n){ro.error("Could not activate event trigger",n)}}))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var t;(t=this.instance.persistence)===null||t===void 0||t.register({[pS]:!0}),this._tryTakeFullSnapshot(),this._reportStarted("sampling_overridden")}overrideTrigger(t){this._activateTrigger(t)}_reportStarted(t,n){this.instance.register_for_session({$session_recording_start_reason:t}),ro.info(t.replace("_"," "),n),pr(["recording_initialized","session_id_changed"],t)||this._tryAddCustomEvent(t,n)}get sdkDebugProperties(){var{sessionStartTimestamp:t}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return{$recording_status:this.status,$sdk_debug_replay_internal_buffer_length:this.buffer.data.length,$sdk_debug_replay_internal_buffer_size:this.buffer.size,$sdk_debug_current_session_duration:this.sessionDuration,$sdk_debug_session_start:t}}};var D6=Ro("[SegmentIntegration]");function $Ve(e,t){var n=e.config.segment;if(!n)return t();(function(r,i){var s=r.config.segment;if(!s)return i();var a=l=>{var c=()=>l.anonymousId()||xp();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(ff,"identified")),i()},o=s.user();"then"in o&&nd(o.then)?o.then(l=>a(l)):a(o)})(e,()=>{n.register((r=>{Promise&&Promise.resolve||D6.warn("This browser does not have Promise support, and can not use the segment integration");var i=(s,a)=>{var o;if(!a)return s;s.event.userId||s.event.anonymousId===r.get_distinct_id()||(D6.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(D6.info("UserId set, identifying with PostHog"),r.identify(s.event.userId));var l=r._calculate_event_properties(a,(o=s.event.properties)!==null&&o!==void 0?o:{},new Date);return s.event.properties=Object.assign({},l,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:s=>i(s,s.event.event),page:s=>i(s,"$pageview"),identify:s=>i(s,"$identify"),screen:s=>i(s,"$screen")}})(e)).then(()=>{t()})})}var z$e="posthog-js";function U$e(e){var{organization:t,projectId:n,prefix:r,severityAllowList:i=["error"]}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return s=>{var a,o,l,c,u;if(!(i==="*"||i.includes(s.level))||!e.__loaded)return s;s.tags||(s.tags={});var d=e.requestRouter.endpointFor("ui","/project/".concat(e.config.token,"/person/").concat(e.get_distinct_id()));s.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(s.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var h=((a=s.exception)===null||a===void 0?void 0:a.values)||[],f=h.map(g=>Ke(Ke({},g),{},{stacktrace:g.stacktrace?Ke(Ke({},g.stacktrace),{},{type:"raw",frames:(g.stacktrace.frames||[]).map(m=>Ke(Ke({},m),{},{platform:"web:javascript"}))}):void 0})),O={$exception_message:((o=h[0])===null||o===void 0?void 0:o.value)||s.message,$exception_type:(l=h[0])===null||l===void 0?void 0:l.type,$exception_personURL:d,$exception_level:s.level,$exception_list:f,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:((c=h[0])===null||c===void 0?void 0:c.value)||s.message,$sentry_exception_type:(u=h[0])===null||u===void 0?void 0:u.type,$sentry_tags:s.tags};return t&&n&&(O.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+n+"&query="+s.event_id),e.exceptions.sendExceptionEvent(O),s}}let kVe=class{constructor(t,n,r,i,s){this.name=z$e,this.setupOnce=function(a){a(U$e(t,{organization:n,projectId:r,prefix:i,severityAllowList:s}))}}};var pf,TVe=Ue!=null&&Ue.location?ME(Ue.location.hash,"__posthog")||ME(location.hash,"state"):null,Ute="_postHogToolbarParams",Wte=Ro("[Toolbar]");(function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"})(pf||(pf={}));class _Ve{constructor(t){this.instance=t}setToolbarState(t){Un.ph_toolbar_state=t}getToolbarState(){var t;return(t=Un.ph_toolbar_state)!==null&&t!==void 0?t:pf.UNINITIALIZED}maybeLoadToolbar(){var t,n,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!Ue||!tn)return!1;r=(t=r)!==null&&t!==void 0?t:Ue.location,s=(n=s)!==null&&n!==void 0?n:Ue.history;try{if(!i){try{Ue.localStorage.setItem("test","test"),Ue.localStorage.removeItem("test")}catch{return!1}i=Ue?.localStorage}var a,o=TVe||ME(r.hash,"__posthog")||ME(r.hash,"state"),l=o?hte(()=>JSON.parse(atob(decodeURIComponent(o))))||hte(()=>JSON.parse(decodeURIComponent(o))):null;return l&&l.action==="ph_authorize"?((a=l).source="url",a&&Object.keys(a).length>0&&(l.desiredHash?r.hash=l.desiredHash:s?s.replaceState(s.state,"",r.pathname+r.search):r.hash="")):((a=JSON.parse(i.getItem(Ute)||"{}")).source="localstorage",delete a.userIntent),!(!a.token||this.instance.config.token!==a.token)&&(this.loadToolbar(a),!0)}catch{return!1}}_callLoadToolbar(t){var n=Un.ph_load_toolbar||Un.ph_load_editor;!ii(n)&&nd(n)?n(t,this.instance):Wte.warn("No toolbar load function found")}loadToolbar(t){var n=!(tn==null||!tn.getElementById(b$e));if(!Ue||n)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=Ke(Ke({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(Ue.localStorage.setItem(Ute,JSON.stringify(Ke(Ke({},i),{},{source:void 0}))),this.getToolbarState()===pf.LOADED)this._callLoadToolbar(i);else if(this.getToolbarState()===pf.UNINITIALIZED){var s,a;this.setToolbarState(pf.LOADING),(s=Un.__PosthogExtensions__)===null||s===void 0||(a=s.loadExternalDependency)===null||a===void 0||a.call(s,this.instance,"toolbar",o=>{if(o)return Wte.error("[Toolbar] Failed to load",o),void this.setToolbarState(pf.UNINITIALIZED);this.setToolbarState(pf.LOADED),this._callLoadToolbar(i)}),Cs(Ue,"turbolinks:load",()=>{this.setToolbarState(pf.UNINITIALIZED),this.loadToolbar(i)})}return!0}_loadEditor(t){return this.loadToolbar(t)}maybeLoadEditor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(t,n,r)}}var PVe=Ro("[TracingHeaders]");class CVe{constructor(t){Et(this,"_restoreXHRPatch",void 0),Et(this,"_restoreFetchPatch",void 0),Et(this,"_startCapturing",()=>{var n,r,i,s;Gt(this._restoreXHRPatch)&&((n=Un.__PosthogExtensions__)===null||n===void 0||(r=n.tracingHeadersPatchFns)===null||r===void 0||r._patchXHR(this.instance.sessionManager)),Gt(this._restoreFetchPatch)&&((i=Un.__PosthogExtensions__)===null||i===void 0||(s=i.tracingHeadersPatchFns)===null||s===void 0||s._patchFetch(this.instance.sessionManager))}),this.instance=t}_loadScript(t){var n,r,i;(n=Un.__PosthogExtensions__)!==null&&n!==void 0&&n.tracingHeadersPatchFns&&t(),(r=Un.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"tracing-headers",s=>{if(s)return PVe.error("failed to load script",s);t()})}startIfEnabledOrStop(){var t,n;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):((t=this._restoreXHRPatch)===null||t===void 0||t.call(this),(n=this._restoreFetchPatch)===null||n===void 0||n.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var LO=Ro("[Web Vitals]"),Gte=9e5;class QVe{constructor(t){var n;Et(this,"_enabledServerSide",!1),Et(this,"_initialized",!1),Et(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),Et(this,"_flushToCapture",()=>{clearTimeout(this._delayedFlushTimer),this.buffer.metrics.length!==0&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce((r,i)=>Ke(Ke({},r),{},{["$web_vitals_".concat(i.name,"_event")]:Ke({},i),["$web_vitals_".concat(i.name,"_value")]:i.value}),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),Et(this,"_addToBuffer",r=>{var i,s=(i=this.instance.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0);if(Gt(s))LO.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var a=this._currentURL();Gt(a)||(ii(r?.name)||ii(r?.value)?LO.error("Invalid metric received",r):this._maxAllowedValue&&r.value>=this._maxAllowedValue?LO.error("Ignoring metric with value >= "+this._maxAllowedValue,r):(this.buffer.url!==a&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),Gt(this.buffer.url)&&(this.buffer.url=a),this.buffer.firstMetricTimestamp=Gt(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(Ke(Ke({},r),{},{$current_url:a,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()))}}),Et(this,"_startCapturing",()=>{var r,i,s,a,o=Un.__PosthogExtensions__;Gt(o)||Gt(o.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:i,onFCP:s,onINP:a}=o.postHogWebVitalsCallbacks),r&&i&&s&&a?(this.allowedMetrics.indexOf("LCP")>-1&&r(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&a(this._addToBuffer.bind(this)),this._initialized=!0):LO.error("web vitals callbacks not loaded - not starting")}),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[pte]),this.startIfEnabled()}get allowedMetrics(){var t,n,r=ms(this.instance.config.capture_performance)?(t=this.instance.config.capture_performance)===null||t===void 0?void 0:t.web_vitals_allowed_metrics:void 0;return Gt(r)?((n=this.instance.persistence)===null||n===void 0?void 0:n.props[gte])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(ms(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var t=ms(this.instance.config.capture_performance)&&Yo(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:Gte;return 0<t&&t<=6e4?Gte:t}get isEnabled(){var t=vl?.protocol;if(t!=="http:"&&t!=="https:")return LO.info("Web Vitals are disabled on non-http/https protocols"),!1;var n=ms(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:Pf(this.instance.config.capture_performance)?this.instance.config.capture_performance:void 0;return Pf(n)?n:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(LO.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(t){var n=ms(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=ms(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[pte]:n}),this.instance.persistence.register({[gte]:r})),this._enabledServerSide=n,this.startIfEnabled()}loadScript(t){var n,r,i;(n=Un.__PosthogExtensions__)!==null&&n!==void 0&&n.postHogWebVitalsCallbacks&&t(),(r=Un.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"web-vitals",s=>{s?LO.error("failed to load script",s):t()})}_currentURL(){var t=Ue?Ue.location.href:void 0;return t||LO.error("Could not determine current URL"),t}}var EVe=Ro("[Heatmaps]");function Vte(e){return ms(e)&&"clientX"in e&&"clientY"in e&&Yo(e.clientX)&&Yo(e.clientY)}class RVe{constructor(t){var n;Et(this,"rageclicks",new E$e),Et(this,"_enabledServerSide",!1),Et(this,"_initialized",!1),Et(this,"_flushInterval",null),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[hj])}get flushIntervalMilliseconds(){var t=5e3;return ms(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(t=this.instance.config.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return Gt(this.instance.config.capture_heatmaps)?Gt(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;EVe.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var t,n;clearInterval((t=this._flushInterval)!==null&&t!==void 0?t:void 0),(n=this.deadClicksCapture)===null||n===void 0||n.stop(),this.getAndClearBuffer()}}onRemoteConfig(t){var n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[hj]:n}),this._enabledServerSide=n,this.startIfEnabled()}getAndClearBuffer(){var t=this.buffer;return this.buffer=void 0,t}_onDeadClick(t){this._onClick(t.originalEvent,"deadclick")}_setupListeners(){Ue&&tn&&(Cs(Ue,"beforeunload",this.flush.bind(this)),Cs(tn,"click",t=>this._onClick(t||Ue?.event),{capture:!0}),Cs(tn,"mousemove",t=>this._onMouseMove(t||Ue?.event),{capture:!0}),this.deadClicksCapture=new A$e(this.instance,WGe,this._onDeadClick.bind(this)),this.deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(t,n){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),a=function(o,l,c){for(var u=o;u&&wA(u)&&!jp(u,"body");){if(u===c)return!1;if(pr(l,Ue?.getComputedStyle(u).position))return!0;u=k$e(u)}return!1}($$e(t),["fixed","sticky"],s);return{x:t.clientX+(a?0:i),y:t.clientY+(a?0:r),target_fixed:a,type:n}}_onClick(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"click";if(!kte(t.target)&&Vte(t)){var i=this._getProperties(t,r);(n=this.rageclicks)!==null&&n!==void 0&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._capture(Ke(Ke({},i),{},{type:"rageclick"})),this._capture(i)}}_onMouseMove(t){!kte(t.target)&&Vte(t)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(t,"mousemove"))},500))}_capture(t){if(Ue){var n=Ue.location.href;this.buffer=this.buffer||{},this.buffer[n]||(this.buffer[n]=[]),this.buffer[n].push(t)}}flush(){this.buffer&&!qy(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}let AVe=class{constructor(t){this._instance=t}doPageView(t,n){var r,i=this._previousPageViewProperties(t,n);return this._currentPageview={pathname:(r=Ue?.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),i}doPageLeave(t){var n;return this._previousPageViewProperties(t,(n=this._currentPageview)===null||n===void 0?void 0:n.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this._currentPageview)===null||t===void 0?void 0:t.pageViewId}}_previousPageViewProperties(t,n){var r=this._currentPageview;if(!r)return{$pageview_id:n};var i={$pageview_id:n,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:o,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:d}=s;if(!(Gt(a)||Gt(o)||Gt(l)||Gt(c)||Gt(u)||Gt(d))){a=Math.ceil(a),o=Math.ceil(o),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),d=Math.ceil(d);var h=a<=1?1:Jc(o/a,0,1),f=a<=1?1:Jc(l/a,0,1),O=c<=1?1:Jc(u/c,0,1),g=c<=1?1:Jc(d/c,0,1);i=Ts(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:O,$prev_pageview_max_content:d,$prev_pageview_max_content_percentage:g})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(t.getTime()-r.timestamp.getTime())/1e3),i}},XVe=class{constructor(t){this.instance=t}sendExceptionEvent(t){this.instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent"})}};var uu="Mobile",qE="iOS",ah="Android",ok="Tablet",W$e=ah+" "+ok,G$e="iPad",V$e="Apple",B$e=V$e+" Watch",lk="Safari",Vb="BlackBerry",Y$e="Samsung",Z$e=Y$e+"Browser",H$e=Y$e+" Internet",S0="Chrome",DVe=S0+" OS",K$e=S0+" "+qE,zV="Internet Explorer",J$e=zV+" "+uu,UV="Opera",IVe=UV+" Mini",WV="Edge",eke="Microsoft "+WV,ob="Firefox",tke=ob+" "+qE,ck="Nintendo",uk="PlayStation",lb="Xbox",nke=ah+" "+uu,rke=uu+" "+lk,vS="Windows",Ej=vS+" Phone",Bte="Nokia",Rj="Ouya",ike="Generic",NVe=ike+" "+uu.toLowerCase(),ske=ike+" "+ok.toLowerCase(),Aj="Konqueror",qo="(\\d+(\\.\\d+)?)",I6=new RegExp("Version/"+qo),FVe=new RegExp(lb,"i"),MVe=new RegExp(uk+" \\w+","i"),LVe=new RegExp(ck+" \\w+","i"),GV=new RegExp(Vb+"|PlayBook|BB10","i"),jVe={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Xj,qVe=(e,t)=>t&&pr(t,V$e)||function(n){return pr(n,lk)&&!pr(n,S0)&&!pr(n,ah)}(e),Yte=function(e,t){return t=t||"",pr(e," OPR/")&&pr(e,"Mini")?IVe:pr(e," OPR/")?UV:GV.test(e)?Vb:pr(e,"IE"+uu)||pr(e,"WPDesktop")?J$e:pr(e,Z$e)?H$e:pr(e,WV)||pr(e,"Edg/")?eke:pr(e,"FBIOS")?"Facebook "+uu:pr(e,"UCWEB")||pr(e,"UCBrowser")?"UC Browser":pr(e,"CriOS")?K$e:pr(e,"CrMo")||pr(e,S0)?S0:pr(e,ah)&&pr(e,lk)?nke:pr(e,"FxiOS")?tke:pr(e.toLowerCase(),Aj.toLowerCase())?Aj:qVe(e,t)?pr(e,uu)?rke:lk:pr(e,ob)?ob:pr(e,"MSIE")||pr(e,"Trident/")?zV:pr(e,"Gecko")?ob:""},zVe={[J$e]:[new RegExp("rv:"+qo)],[eke]:[new RegExp(WV+"?\\/"+qo)],[S0]:[new RegExp("("+S0+"|CrMo)\\/"+qo)],[K$e]:[new RegExp("CriOS\\/"+qo)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+qo)],[lk]:[I6],[rke]:[I6],[UV]:[new RegExp("(Opera|OPR)\\/"+qo)],[ob]:[new RegExp(ob+"\\/"+qo)],[tke]:[new RegExp("FxiOS\\/"+qo)],[Aj]:[new RegExp("Konqueror[:/]?"+qo,"i")],[Vb]:[new RegExp(Vb+" "+qo),I6],[nke]:[new RegExp("android\\s"+qo,"i")],[H$e]:[new RegExp(Z$e+"\\/"+qo)],[zV]:[new RegExp("(rv:|MSIE )"+qo)],Mozilla:[new RegExp("rv:"+qo)]},Zte=[[new RegExp(lb+"; "+lb+" (.*?)[);]","i"),e=>[lb,e&&e[1]||""]],[new RegExp(ck,"i"),[ck,""]],[new RegExp(uk,"i"),[uk,""]],[GV,[Vb,""]],[new RegExp(vS,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Ej,""];if(new RegExp(uu).test(t)&&!/IEMobile\b/.test(t))return[vS+" "+uu,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=n[1],i=jVe[r]||"";return/arm/i.test(t)&&(i="RT"),[vS,i]}return[vS,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[qE,t.join(".")]}return[qE,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=Gt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ah+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ah+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[ah,t.join(".")]}return[ah,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[DVe,""]],[/Linux|debian/i,["Linux",""]]],Hte=function(e){return LVe.test(e)?ck:MVe.test(e)?uk:FVe.test(e)?lb:new RegExp(Rj,"i").test(e)?Rj:new RegExp("("+Ej+"|WPDesktop)","i").test(e)?Ej:/iPad/.test(e)?G$e:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?B$e:GV.test(e)?Vb:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Bte,"i").test(e)?Bte:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(uu).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?ah:W$e:ah:new RegExp("(pda|"+uu+")","i").test(e)?NVe:new RegExp(ok,"i").test(e)&&!new RegExp(ok+" pc","i").test(e)?ske:""},ZP="https?://(.*)",xQ=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],UVe=vQ(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],xQ),N6="<masked>",Vi={campaignParams:function(){var{customTrackedParams:e,maskPersonalDataProperties:t,customPersonalDataProperties:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!tn)return{};var r=t?vQ([],xQ,n||[]):[];return this._campaignParamsFromUrl(k6(tn.URL,r,N6),e)},_campaignParamsFromUrl:function(e,t){var n=UVe.concat(t||[]),r={};return vi(n,function(i){var s=FE(e,i);r[i]=s||null}),r},_searchEngine:function(e){return e?e.search(ZP+"google.([^/?]*)")===0?"google":e.search(ZP+"bing.com")===0?"bing":e.search(ZP+"yahoo.com")===0?"yahoo":e.search(ZP+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var t=Vi._searchEngine(e),n=t!="yahoo"?"q":"p",r={};if(!xg(t)){r.$search_engine=t;var i=tn?FE(tn.referrer,n):"";i.length&&(r.ph_keyword=i)}return r},searchInfo:function(){var e=tn?.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:Yte,browserVersion:function(e,t){var n=Yte(e,t),r=zVe[n];if(Gt(r))return null;for(var i=0;i<r.length;i++){var s=r[i],a=e.match(s);if(a)return parseFloat(a[a.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var e=this.browserLanguage();return typeof e=="string"?e.split("-")[0]:void 0},os:function(e){for(var t=0;t<Zte.length;t++){var[n,r]=Zte[t],i=n.exec(e),s=i&&(nd(r)?r(i,e):r);if(s)return s}return["",""]},device:Hte,deviceType:function(e){var t=Hte(e);return t===G$e||t===W$e||t==="Kobo"||t==="Kindle Fire"||t===ske?ok:t===ck||t===lb||t===uk||t===Rj?"Console":t===B$e?"Wearable":t?uu:"Desktop"},referrer:function(){return tn?.referrer||"$direct"},referringDomain:function(){var e;return tn!=null&&tn.referrer&&((e=ab(tn.referrer))===null||e===void 0?void 0:e.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},personInfo:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e?vQ([],xQ,t||[]):[],r=vl?.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:r?k6(r,n,N6):void 0}},personPropsFromInfo:function(e){var t,{r:n,u:r}=e,i={$referrer:n,$referring_domain:n==null?void 0:n=="$direct"?"$direct":(t=ab(n))===null||t===void 0?void 0:t.host};if(r){i.$current_url=r;var s=ab(r);i.$host=s?.host,i.$pathname=s?.pathname;var a=this._campaignParamsFromUrl(r);Ts(i,a)}if(n){var o=this._searchInfoFromReferrer(n);Ts(i,o)}return i},initialPersonPropsFromInfo:function(e){var t=this.personPropsFromInfo(e),n={};return vi(t,function(r,i){n["$initial_".concat(FV(i))]=r}),n},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}},timezoneOffset:function(){try{return new Date().getTimezoneOffset()}catch{return}},properties:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!Ws)return{};var n=e?vQ([],xQ,t||[]):[],[r,i]=Vi.os(Ws);return Ts(ak({$os:r,$os_version:i,$browser:Vi.browser(Ws,navigator.vendor),$device:Vi.device(Ws),$device_type:Vi.deviceType(Ws),$timezone:Vi.timezone(),$timezone_offset:Vi.timezoneOffset()}),{$current_url:k6(vl?.href,n,N6),$host:vl?.host,$pathname:vl?.pathname,$raw_user_agent:Ws.length>1e3?Ws.substring(0,997)+"...":Ws,$browser_version:Vi.browserVersion(Ws,navigator.vendor),$browser_language:Vi.browserLanguage(),$browser_language_prefix:Vi.browserLanguagePrefix(),$screen_height:Ue?.screen.height,$screen_width:Ue?.screen.width,$viewport_height:Ue?.innerHeight,$viewport_width:Ue?.innerWidth,$lib:"web",$lib_version:wf.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!Ws)return{};var[e,t]=Vi.os(Ws);return Ts(ak({$os:e,$os_version:t,$browser:Vi.browser(Ws,navigator.vendor)}),{$browser_version:Vi.browserVersion(Ws,navigator.vendor)})}},zd=Ro("[FeatureFlags]"),F6="$active_feature_flags",Yv="$override_feature_flags",Kte="$feature_flag_payloads",lx="$override_feature_flag_payloads",Jte="$feature_flag_request_id",ene=e=>{var t={};for(var[n,r]of yQ(e||{}))r&&(t[n]=r);return t},WVe=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map(n=>{var r;return[n,(r=t[n].variant)!==null&&r!==void 0?r:t[n].enabled]})),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter(n=>t[n].enabled).filter(n=>{var r;return(r=t[n].metadata)===null||r===void 0?void 0:r.payload}).map(n=>{var r;return[n,(r=t[n].metadata)===null||r===void 0?void 0:r.payload]}))):zd.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e};(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(Xj||(Xj={}));class GVe{constructor(t){Et(this,"_override_warning",!1),Et(this,"_hasLoadedFlags",!1),Et(this,"_requestInFlight",!1),Et(this,"_reloadingDisabled",!1),Et(this,"_additionalReloadRequested",!1),Et(this,"_decideCalled",!1),Et(this,"_flagsLoadedFromRemote",!1),this.instance=t,this.featureFlagEventHandlers=[]}decide(){if(this.instance.config.__preview_remote_config)this._decideCalled=!0;else{var t=!this._reloadDebouncer&&(this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load);this._callDecideEndpoint({disableFlags:t})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.instance.get_property(Oj),n=this.instance.get_property(Yv),r=this.instance.get_property(lx);if(!r&&!n)return t||{};var i=Ts({},t||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var a of s){var o,l,c=i[a],u=n?.[a],d=Gt(u)?(o=c?.enabled)!==null&&o!==void 0&&o:!!u,h=Gt(u)?c.variant:typeof u=="string"?u:void 0,f=r?.[a],O=Ke(Ke({},c),{},{enabled:d,variant:d?h??c?.variant:void 0});d!==c?.enabled&&(O.original_enabled=c?.enabled),h!==c?.variant&&(O.original_variant=c?.variant),f&&(O.metadata=Ke(Ke({},c?.metadata),{},{payload:f,original_payload:c==null||(l=c.metadata)===null||l===void 0?void 0:l.payload})),i[a]=O}return this._override_warning||(zd.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:i}),this._override_warning=!0),i}getFlagVariants(){var t=this.instance.get_property(zy),n=this.instance.get_property(Yv);if(!n)return t||{};for(var r=Ts({},t),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this._override_warning||(zd.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:n,finalFlags:r}),this._override_warning=!0),r}getFlagPayloads(){var t=this.instance.get_property(Kte),n=this.instance.get_property(lx);if(!n)return t||{};for(var r=Ts({},t||{}),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this._override_warning||(zd.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:n,finalPayloads:r}),this._override_warning=!0),r}reloadFeatureFlags(){this._reloadingDisabled||this.instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout(()=>{this._callDecideEndpoint()},5))}clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this._reloadingDisabled=t}_callDecideEndpoint(t){var n;if(this.clearDebouncer(),!this.instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var r={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:Ke(Ke({},((n=this.instance.persistence)===null||n===void 0?void 0:n.get_initial_props())||{}),this.instance.get_property(gS)||{}),group_properties:this.instance.get_property(vm)};(t!=null&&t.disableFlags||this.instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0);var i=this.instance.config.__preview_flags_v2&&this.instance.config.__preview_remote_config;i&&(r.timezone=Vi.timezone()),this._requestInFlight=!0,this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api",i?"/flags/?v=2":"/decide/?v=4"),data:r,compression:this.instance.config.disable_compression?void 0:Bu.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:s=>{var a,o,l,c=!0;s.statusCode===200&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),c=!1),this._requestInFlight=!1,this._decideCalled||(this._decideCalled=!0,this.instance._onRemoteConfig((l=s.json)!==null&&l!==void 0?l:{})),r.disable_flags&&!this._additionalReloadRequested||(this._flagsLoadedFromRemote=!c,s.json&&(a=s.json.quotaLimited)!==null&&a!==void 0&&a.includes(Xj.FeatureFlags)?zd.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(this.receivedFeatureFlags((o=s.json)!==null&&o!==void 0?o:{},c),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callDecideEndpoint())))}})}}getFeatureFlag(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[t],i="".concat(r),s=this.instance.get_property(Jte)||void 0,a=this.instance.get_property(DE)||{};if((n.send_event||!("send_event"in n))&&(!(t in a)||!a[t].includes(i))){var o,l,c,u,d,h,f,O,g,m,v;gs(a[t])?a[t].push(i):a[t]=[i],(o=this.instance.persistence)===null||o===void 0||o.register({[DE]:a});var y=this.getFeatureFlagDetails(t),b={$feature_flag:t,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(t)||null,$feature_flag_request_id:s,$feature_flag_bootstrapped_response:((l=this.instance.config.bootstrap)===null||l===void 0||(c=l.featureFlags)===null||c===void 0?void 0:c[t])||null,$feature_flag_bootstrapped_payload:((u=this.instance.config.bootstrap)===null||u===void 0||(d=u.featureFlagPayloads)===null||d===void 0?void 0:d[t])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};Gt(y==null||(h=y.metadata)===null||h===void 0?void 0:h.version)||(b.$feature_flag_version=y.metadata.version);var T,x=(f=y==null||(O=y.reason)===null||O===void 0?void 0:O.description)!==null&&f!==void 0?f:y==null||(g=y.reason)===null||g===void 0?void 0:g.code;x&&(b.$feature_flag_reason=x),y!=null&&(m=y.metadata)!==null&&m!==void 0&&m.id&&(b.$feature_flag_id=y.metadata.id),Gt(y?.original_variant)&&Gt(y?.original_enabled)||(b.$feature_flag_original_response=Gt(y.original_variant)?y.original_enabled:y.original_variant),y!=null&&(v=y.metadata)!==null&&v!==void 0&&v.original_payload&&(b.$feature_flag_original_payload=y==null||(T=y.metadata)===null||T===void 0?void 0:T.original_payload),this.instance.capture("$feature_flag_called",b)}return r}zd.warn('getFeatureFlag for key "'+t+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){return this.getFlagPayloads()[t]}getRemoteConfigPayload(t,n){var r=this.instance.config.token;this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=4"),data:{distinct_id:this.instance.get_distinct_id(),token:r},compression:this.instance.config.disable_compression?void 0:Bu.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:i=>{var s,a=(s=i.json)===null||s===void 0?void 0:s.featureFlagPayloads;n(a?.[t]||void 0)}})}isFeatureEnabled(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(t,n);zd.warn('isFeatureEnabled for key "'+t+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(n=>n!==t)}receivedFeatureFlags(t,n){if(this.instance.persistence){this._hasLoadedFlags=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(a,o){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},c=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},u=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},d=WVe(a),h=d.flags,f=d.featureFlags,O=d.featureFlagPayloads;if(f){var g=a.requestId;if(gs(f)){zd.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var m={};if(f)for(var v=0;v<f.length;v++)m[f[v]]=!0;o&&o.register({[F6]:f,[zy]:m})}else{var y=f,b=O,T=h;a.errorsWhileComputingFlags&&(y=Ke(Ke({},l),y),b=Ke(Ke({},c),b),T=Ke(Ke({},u),T)),o&&o.register(Ke({[F6]:Object.keys(ene(y)),[zy]:y||{},[Kte]:b||{},[Oj]:T||{}},g?{[Jte]:g}:{}))}}})(t,this.instance.persistence,r,i,s),this._fireFeatureFlagsCallbacks(n)}}override(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];zd.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:n})}overrideFeatureFlags(t){if(!this.instance.__loaded||!this.instance.persistence)return zd.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.instance.persistence.unregister(Yv),this.instance.persistence.unregister(lx),void this._fireFeatureFlagsCallbacks();if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var n,r=t;if(this._override_warning=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this.instance.persistence.unregister(Yv);else if(r.flags)if(gs(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this.instance.persistence.register({[Yv]:i})}else this.instance.persistence.register({[Yv]:r.flags})}return"payloads"in r&&(r.payloads===!1?this.instance.persistence.unregister(lx):r.payloads&&this.instance.persistence.register({[lx]:r.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this._hasLoadedFlags){var{flags:n,flagVariants:r}=this._prepareFeatureFlagsForCallbacks();t(n,r)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,n){var r,i=(this.instance.get_property(bQ)||[]).find(l=>l.flagKey===t),s={["$feature_enrollment/".concat(t)]:n},a={$feature_flag:t,$feature_enrollment:n,$set:s};i&&(a.$early_access_feature_name=i.name),this.instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(s,!1);var o=Ke(Ke({},this.getFlagVariants()),{},{[t]:n});(r=this.instance.persistence)===null||r===void 0||r.register({[F6]:Object.keys(ene(o)),[zy]:o}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1],r=arguments.length>2?arguments[2]:void 0,i=this.instance.get_property(bQ),s=r?"&".concat(r.map(a=>"stage=".concat(a)).join("&")):"";if(i&&!n)return t(i);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token).concat(s)),method:"GET",callback:a=>{var o;if(a.json){var l=a.json.earlyAccessFeatures;return(o=this.instance.persistence)===null||o===void 0||o.register({[bQ]:l}),t(l)}}})}_prepareFeatureFlagsForCallbacks(){var t=this.getFlags(),n=this.getFlagVariants();return{flags:t.filter(r=>n[r]),flagVariants:Object.keys(n).filter(r=>n[r]).reduce((r,i)=>(r[i]=n[i],r),{})}}_fireFeatureFlagsCallbacks(t){var{flags:n,flagVariants:r}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach(i=>i(n,r,{errorsLoading:t}))}setPersonPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],r=this.instance.get_property(gS)||{};this.instance.register({[gS]:Ke(Ke({},r),t)}),n&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(gS)}setGroupPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],r=this.instance.get_property(vm)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(i=>{r[i]=Ke(Ke({},r[i]),t[i]),delete t[i]}),this.instance.register({[vm]:Ke(Ke({},r),t)}),n&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var n=this.instance.get_property(vm)||{};this.instance.register({[vm]:Ke(Ke({},n),{},{[t]:{}})})}else this.instance.unregister(vm)}}var VVe=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class M6{constructor(t){this.config=t,this.props={},this.campaign_params_saved=!1,this.name=(n=>{var r="";return n.token&&(r=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+r+"_posthog"})(t),this.storage=this.buildStorage(t),this.load(),t.debug&&fn.info("Persistence loaded",t.persistence,Ke({},this.props)),this.update_config(t,t),this.save()}buildStorage(t){VVe.indexOf(t.persistence.toLowerCase())===-1&&(fn.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n=t.persistence.toLowerCase();return n==="localstorage"&&aa.is_supported()?aa:n==="localstorage+cookie"&&UP.is_supported()?UP:n==="sessionstorage"&&Wa.is_supported()?Wa:n==="memory"?zGe:n==="cookie"?jf:UP.is_supported()?UP:jf}properties(){var t={};return vi(this.props,function(n,r){if(r===zy&&ms(n))for(var i=Object.keys(n),s=0;s<i.length;s++)t["$feature/".concat(i[s])]=n[i[s]];else o=r,l=!1,(xg(a=wGe)?l:lte&&a.indexOf===lte?a.indexOf(o)!=-1:(vi(a,function(c){if(l||(l=c===o))return AE}),l))||(t[r]=n);var a,o,l}),t}load(){if(!this.disabled){var t=this.storage.parse(this.name);t&&(this.props=Ts({},t))}}save(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure,this.config.debug)}remove(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}clear(){this.remove(),this.props={}}register_once(t,n,r){if(ms(t)){Gt(n)&&(n="None"),this.expire_days=Gt(r)?this.default_expiry:r;var i=!1;if(vi(t,(s,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==n||(this.props[a]=s,i=!0)}),i)return this.save(),!0}return!1}register(t,n){if(ms(t)){this.expire_days=Gt(n)?this.default_expiry:n;var r=!1;if(vi(t,(i,s)=>{t.hasOwnProperty(s)&&this.props[s]!==i&&(this.props[s]=i,r=!0)}),r)return this.save(),!0}return!1}unregister(t){t in this.props&&(delete this.props[t],this.save())}update_campaign_params(){if(!this.campaign_params_saved){var t=Vi.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});qy(ak(t))||this.register(t),this.campaign_params_saved=!0}}update_search_keyword(){this.register(Vi.searchInfo())}update_referrer_info(){this.register_once(Vi.referrerInfo(),void 0)}set_initial_person_info(){this.props[vj]||this.props[yj]||this.register_once({[bj]:Vi.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return ak({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var t={};vi([yj,vj],i=>{var s=this.props[i];s&&vi(s,function(a,o){t["$initial_"+FV(o)]=a})});var n=this.props[bj];if(n){var r=Vi.initialPersonPropsFromInfo(n);Ts(t,r)}return t}safe_merge(t){return vi(this.props,function(n,r){r in t||(t[r]=n)}),t}update_config(t,n){if(this.default_expiry=this.expire_days=t.cookie_expiration,this.set_disabled(t.disable_persistence),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),t.persistence!==n.persistence){var r=this.buildStorage(t),i=this.props;this.clear(),this.storage=r,this.props=i,this.save()}}set_disabled(t){this.disabled=t,this.disabled?this.remove():this.save()}set_cross_subdomain(t){t!==this.cross_subdomain&&(this.cross_subdomain=t,this.remove(),this.save())}get_cross_subdomain(){return!!this.cross_subdomain}set_secure(t){t!==this.secure&&(this.secure=t,this.remove(),this.save())}set_event_timer(t,n){var r=this.props[OS]||{};r[t]=n,this.props[OS]=r,this.save()}remove_event_timer(t){var n=(this.props[OS]||{})[t];return Gt(n)||(delete this.props[OS][t],this.save()),n}get_property(t){return this.props[t]}set_property(t,n){this.props[t]=n,this.save()}}var ake,vs,oke,Tm,tne,lke,Dj,cke,nne,Ij,rne,ine,sne,ane,Nj={},uke=[],BVe=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,VV=Array.isArray;function Sp(e,t){for(var n in t)e[n]=t[n];return e}function dke(e){var t=e.parentNode;t&&t.removeChild(e)}function L6(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:i??++oke,__i:-1,__u:0};return i==null&&vs.vnode!=null&&vs.vnode(s),s}function BV(e){return e.children}function SQ(e,t){this.props=e,this.context=t}function Bb(e,t){if(t==null)return e.__?Bb(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Bb(e):null}function hke(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return hke(e)}}function Fj(e){(!e.__d&&(e.__d=!0)&&Tm.push(e)&&!zE.__r++||tne!==vs.debounceRendering)&&((tne=vs.debounceRendering)||lke)(zE)}function zE(){var e,t,n,r,i,s,a,o,l;for(Tm.sort(Dj);e=Tm.shift();)e.__d&&(t=Tm.length,r=void 0,s=(i=(n=e).__v).__e,o=[],l=[],(a=n.__P)&&((r=Sp({},i)).__v=i.__v+1,vs.vnode&&vs.vnode(r),pke(a,r,i,n.__n,a.ownerSVGElement!==void 0,32&i.__u?[s]:null,o,s??Bb(i),!!(32&i.__u),l),r.__.__k[r.__i]=r,HVe(o,r,l),r.__e!=s&&hke(r)),Tm.length>t&&Tm.sort(Dj));zE.__r=0}function fke(e,t,n,r,i,s,a,o,l,c,u){var d,h,f,O,g,m=r&&r.__k||uke,v=t.length;for(n.__d=l,YVe(n,t,m),l=n.__d,d=0;d<v;d++)(f=n.__k[d])!=null&&typeof f!="boolean"&&typeof f!="function"&&(h=f.__i===-1?Nj:m[f.__i]||Nj,f.__i=d,pke(e,f,h,i,s,a,o,l,c,u),O=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&YV(h.ref,null,f),u.push(f.ref,f.__c||O,f)),g==null&&O!=null&&(g=O),65536&f.__u||h.__k===f.__k?l=Oke(f,l,e):typeof f.type=="function"&&f.__d!==void 0?l=f.__d:O&&(l=O.nextSibling),f.__d=void 0,f.__u&=-196609);n.__d=l,n.__e=g}function YVe(e,t,n){var r,i,s,a,o,l=t.length,c=n.length,u=c,d=0;for(e.__k=[],r=0;r<l;r++)(i=e.__k[r]=(i=t[r])==null||typeof i=="boolean"||typeof i=="function"?null:typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?L6(null,i,null,null,i):VV(i)?L6(BV,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?L6(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)!=null?(i.__=e,i.__b=e.__b+1,o=ZVe(i,n,a=r+d,u),i.__i=o,s=null,o!==-1&&(u--,(s=n[o])&&(s.__u|=131072)),s==null||s.__v===null?(o==-1&&d--,typeof i.type!="function"&&(i.__u|=65536)):o!==a&&(o===a+1?d++:o>a?u>l-a?d+=o-a:d--:d=o<a&&o==a-1?o-a:0,o!==r+d&&(i.__u|=65536))):(s=n[r])&&s.key==null&&s.__e&&(s.__e==e.__d&&(e.__d=Bb(s)),Mj(s,s,!1),n[r]=null,u--);if(u)for(r=0;r<c;r++)(s=n[r])!=null&&(131072&s.__u)==0&&(s.__e==e.__d&&(e.__d=Bb(s)),Mj(s,s))}function Oke(e,t,n){var r,i;if(typeof e.type=="function"){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=Oke(r[i],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function ZVe(e,t,n,r){var i=e.key,s=e.type,a=n-1,o=n+1,l=t[n];if(l===null||l&&i==l.key&&s===l.type)return n;if(r>(l!=null&&(131072&l.__u)==0?1:0))for(;a>=0||o<t.length;){if(a>=0){if((l=t[a])&&(131072&l.__u)==0&&i==l.key&&s===l.type)return a;a--}if(o<t.length){if((l=t[o])&&(131072&l.__u)==0&&i==l.key&&s===l.type)return o;o++}}return-1}function one(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||BVe.test(t)?n:n+"px"}function HP(e,t,n,r,i){var s;e:if(t==="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||one(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||one(e.style,t,n[t])}else if(t[0]==="o"&&t[1]==="n")s=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?r?n.u=r.u:(n.u=Date.now(),e.addEventListener(t,s?cne:lne,s)):e.removeEventListener(t,s?cne:lne,s);else{if(i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!=="width"&&t!=="height"&&t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t!=="rowSpan"&&t!=="colSpan"&&t!=="role"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,n))}}function lne(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(vs.event?vs.event(e):e)}function cne(e){return this.l[e.type+!0](vs.event?vs.event(e):e)}function pke(e,t,n,r,i,s,a,o,l,c){var u,d,h,f,O,g,m,v,y,b,T,x,S,k,_,P=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),s=[o=t.__e=n.__e]),(u=vs.__b)&&u(t);e:if(typeof P=="function")try{if(v=t.props,y=(u=P.contextType)&&r[u.__c],b=u?y?y.props.value:u.__:r,n.__c?m=(d=t.__c=n.__c).__=d.__E:("prototype"in P&&P.prototype.render?t.__c=d=new P(v,b):(t.__c=d=new SQ(v,b),d.constructor=P,d.render=JVe),y&&y.sub(d),d.props=v,d.state||(d.state={}),d.context=b,d.__n=r,h=d.__d=!0,d.__h=[],d._sb=[]),d.__s==null&&(d.__s=d.state),P.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Sp({},d.__s)),Sp(d.__s,P.getDerivedStateFromProps(v,d.__s))),f=d.props,O=d.state,d.__v=t,h)P.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(P.getDerivedStateFromProps==null&&v!==f&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(v,b),!d.__e&&(d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(v,d.__s,b)===!1||t.__v===n.__v)){for(t.__v!==n.__v&&(d.props=v,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach(function(C){C&&(C.__=t)}),T=0;T<d._sb.length;T++)d.__h.push(d._sb[T]);d._sb=[],d.__h.length&&a.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(v,d.__s,b),d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(f,O,g)})}if(d.context=b,d.props=v,d.__P=e,d.__e=!1,x=vs.__r,S=0,"prototype"in P&&P.prototype.render){for(d.state=d.__s,d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),k=0;k<d._sb.length;k++)d.__h.push(d._sb[k]);d._sb=[]}else do d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++S<25);d.state=d.__s,d.getChildContext!=null&&(r=Sp(Sp({},r),d.getChildContext())),h||d.getSnapshotBeforeUpdate==null||(g=d.getSnapshotBeforeUpdate(f,O)),fke(e,VV(_=u!=null&&u.type===BV&&u.key==null?u.props.children:u)?_:[_],t,n,r,i,s,a,o,l,c),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),m&&(d.__E=d.__=null)}catch(C){t.__v=null,l||s!=null?(t.__e=o,t.__u|=l?160:32,s[s.indexOf(o)]=null):(t.__e=n.__e,t.__k=n.__k),vs.__e(C,t,n)}else s==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=KVe(n.__e,t,n,r,i,s,a,l,c);(u=vs.diffed)&&u(t)}function HVe(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)YV(n[r],n[++r],n[++r]);vs.__c&&vs.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(s){s.call(i)})}catch(s){vs.__e(s,i.__v)}})}function KVe(e,t,n,r,i,s,a,o,l){var c,u,d,h,f,O,g,m=n.props,v=t.props,y=t.type;if(y==="svg"&&(i=!0),s!=null){for(c=0;c<s.length;c++)if((f=s[c])&&"setAttribute"in f==!!y&&(y?f.localName===y:f.nodeType===3)){e=f,s[c]=null;break}}if(e==null){if(y===null)return document.createTextNode(v);e=i?document.createElementNS("http://www.w3.org/2000/svg",y):document.createElement(y,v.is&&v),s=null,o=!1}if(y===null)m===v||o&&e.data===v||(e.data=v);else{if(s=s&&ake.call(e.childNodes),m=n.props||Nj,!o&&s!=null)for(m={},c=0;c<e.attributes.length;c++)m[(f=e.attributes[c]).name]=f.value;for(c in m)f=m[c],c=="children"||(c=="dangerouslySetInnerHTML"?d=f:c==="key"||c in v||HP(e,c,null,f,i));for(c in v)f=v[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?u=f:c=="value"?O=f:c=="checked"?g=f:c==="key"||o&&typeof f!="function"||m[c]===f||HP(e,c,f,m[c],i);if(u)o||d&&(u.__html===d.__html||u.__html===e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),fke(e,VV(h)?h:[h],t,n,r,i&&y!=="foreignObject",s,a,s?s[0]:n.__k&&Bb(n,0),o,l),s!=null)for(c=s.length;c--;)s[c]!=null&&dke(s[c]);o||(c="value",O!==void 0&&(O!==e[c]||y==="progress"&&!O||y==="option"&&O!==m[c])&&HP(e,c,O,m[c],!1),c="checked",g!==void 0&&g!==e[c]&&HP(e,c,g,m[c],!1))}return e}function YV(e,t,n){try{typeof e=="function"?e(t):e.current=t}catch(r){vs.__e(r,n)}}function Mj(e,t,n){var r,i;if(vs.unmount&&vs.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||YV(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){vs.__e(s,t)}r.base=r.__P=null,e.__c=void 0}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Mj(r[i],t,n||typeof e.type!="function");n||e.__e==null||dke(e.__e),e.__=e.__e=e.__d=void 0}function JVe(e,t,n){return this.constructor(e,n)}ake=uke.slice,vs={__e:function(e,t,n,r){for(var i,s,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(o){e=o}throw e}},oke=0,SQ.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Sp({},this.state),typeof e=="function"&&(e=e(Sp({},n),this.props)),e&&Sp(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Fj(this))},SQ.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Fj(this))},SQ.prototype.render=BV,Tm=[],lke=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Dj=function(e,t){return e.__v.__b-t.__v.__b},zE.__r=0,cke=0,function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}(nne||(nne={})),function(e){e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger"}(Ij||(Ij={})),function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(rne||(rne={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(ine||(ine={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(sne||(sne={})),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}(ane||(ane={}));var Yb=function(e,t){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},Fa=Ro("[Surveys]"),une={icontains:(e,t)=>e.some(n=>t.toLowerCase().includes(n.toLowerCase())),not_icontains:(e,t)=>e.every(n=>!t.toLowerCase().includes(n.toLowerCase())),regex:(e,t)=>e.some(n=>Yb(t,n)),not_regex:(e,t)=>e.every(n=>!Yb(t,n)),exact:(e,t)=>e.some(n=>t===n),is_not:(e,t)=>e.every(n=>t!==n)};function dne(e){return e??"icontains"}Ij.Right;(function(e,t){var n={__c:t="__cC"+cke++,__:e,Consumer:function(r,i){return r.children(i)},Provider:function(r){var i,s;return this.getChildContext||(i=[],(s={})[t]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(a){this.props.value!==a.value&&i.some(function(o){o.__e=!0,Fj(o)})},this.sub=function(a){i.push(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){i.splice(i.indexOf(a),1),o&&o.call(a)}}),r.children}};n.Provider.__=n.Consumer.contextType=n})({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed:()=>{},isPopup:!0,onPreviewSubmit:()=>{}});let gke=class{constructor(){Et(this,"events",{}),this.events={}}on(t,n){return this.events[t]||(this.events[t]=[]),this.events[t].push(n),()=>{this.events[t]=this.events[t].filter(r=>r!==n)}}emit(t,n){for(var r of this.events[t]||[])r(n);for(var i of this.events["*"]||[])i(t,n)}},eBe=class Cy{constructor(t){Et(this,"_debugEventEmitter",new gke),Et(this,"checkStep",(n,r)=>this.checkStepEvent(n,r)&&this.checkStepUrl(n,r)&&this.checkStepElement(n,r)),Et(this,"checkStepEvent",(n,r)=>r==null||!r.event||n?.event===r?.event),this.instance=t,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var t;if(!Gt((t=this.instance)===null||t===void 0?void 0:t._addCaptureHook)){var n;(n=this.instance)===null||n===void 0||n._addCaptureHook((r,i)=>{this.on(r,i)})}}register(t){var n,r;if(!Gt((n=this.instance)===null||n===void 0?void 0:n._addCaptureHook)&&(t.forEach(a=>{var o,l;(o=this.actionRegistry)===null||o===void 0||o.add(a),(l=a.steps)===null||l===void 0||l.forEach(c=>{var u;(u=this.actionEvents)===null||u===void 0||u.add(c?.event||"")})}),(r=this.instance)!==null&&r!==void 0&&r.autocapture)){var i,s=new Set;t.forEach(a=>{var o;(o=a.steps)===null||o===void 0||o.forEach(l=>{l!=null&&l.selector&&s.add(l?.selector)})}),(i=this.instance)===null||i===void 0||i.autocapture.setElementSelectors(s)}}on(t,n){var r;n!=null&&t.length!=0&&(this.actionEvents.has(t)||this.actionEvents.has(n?.event))&&this.actionRegistry&&((r=this.actionRegistry)===null||r===void 0?void 0:r.size)>0&&this.actionRegistry.forEach(i=>{this.checkAction(n,i)&&this._debugEventEmitter.emit("actionCaptured",i.name)})}_addActionHook(t){this.onAction("actionCaptured",n=>t(n))}checkAction(t,n){if(n?.steps==null)return!1;for(var r of n.steps)if(this.checkStep(t,r))return!0;return!1}onAction(t,n){return this._debugEventEmitter.on(t,n)}checkStepUrl(t,n){if(n!=null&&n.url){var r,i=t==null||(r=t.properties)===null||r===void 0?void 0:r.$current_url;if(!i||typeof i!="string"||!Cy.matchString(i,n?.url,n?.url_matching||"contains"))return!1}return!0}static matchString(t,n,r){switch(r){case"regex":return!!Ue&&Yb(t,n);case"exact":return n===t;case"contains":var i=Cy.escapeStringRegexp(n).replace(/_/g,".").replace(/%/g,".*");return Yb(t,i);default:return!1}}static escapeStringRegexp(t){return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}checkStepElement(t,n){if((n!=null&&n.href||n!=null&&n.tag_name||n!=null&&n.text)&&!this.getElementsList(t).some(s=>!(n!=null&&n.href&&!Cy.matchString(s.href||"",n?.href,n?.href_matching||"exact"))&&(n==null||!n.tag_name||s.tag_name===n?.tag_name)&&!(n!=null&&n.text&&!Cy.matchString(s.text||"",n?.text,n?.text_matching||"exact")&&!Cy.matchString(s.$el_text||"",n?.text,n?.text_matching||"exact"))))return!1;if(n!=null&&n.selector){var r,i=t==null||(r=t.properties)===null||r===void 0?void 0:r.$element_selectors;if(!i||!i.includes(n?.selector))return!1}return!0}getElementsList(t){return t?.properties.$elements==null?[]:t?.properties.$elements}},Lj=class mke{constructor(t){this.instance=t,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(t){var n;Gt((n=this.instance)===null||n===void 0?void 0:n._addCaptureHook)||(this.setupEventBasedSurveys(t),this.setupActionBasedSurveys(t))}setupActionBasedSurveys(t){var n=t.filter(r=>{var i,s,a,o;return((i=r.conditions)===null||i===void 0?void 0:i.actions)&&((s=r.conditions)===null||s===void 0||(a=s.actions)===null||a===void 0||(o=a.values)===null||o===void 0?void 0:o.length)>0});n.length!==0&&(this.actionMatcher==null&&(this.actionMatcher=new eBe(this.instance),this.actionMatcher.init(),this.actionMatcher._addActionHook(r=>{this.onAction(r)})),n.forEach(r=>{var i,s,a,o,l,c,u,d,h,f;r.conditions&&(i=r.conditions)!==null&&i!==void 0&&i.actions&&(s=r.conditions)!==null&&s!==void 0&&(a=s.actions)!==null&&a!==void 0&&a.values&&((o=r.conditions)===null||o===void 0||(l=o.actions)===null||l===void 0||(c=l.values)===null||c===void 0?void 0:c.length)>0&&((u=this.actionMatcher)===null||u===void 0||u.register(r.conditions.actions.values),(d=r.conditions)===null||d===void 0||(h=d.actions)===null||h===void 0||(f=h.values)===null||f===void 0||f.forEach(O=>{if(O&&O.name){var g=this.actionToSurveys.get(O.name);g&&g.push(r.id),this.actionToSurveys.set(O.name,g||[r.id])}}))}))}setupEventBasedSurveys(t){var n;t.filter(r=>{var i,s,a,o;return((i=r.conditions)===null||i===void 0?void 0:i.events)&&((s=r.conditions)===null||s===void 0||(a=s.events)===null||a===void 0||(o=a.values)===null||o===void 0?void 0:o.length)>0}).length!==0&&((n=this.instance)===null||n===void 0||n._addCaptureHook((r,i)=>{this.onEvent(r,i)}),t.forEach(r=>{var i,s,a;(i=r.conditions)===null||i===void 0||(s=i.events)===null||s===void 0||(a=s.values)===null||a===void 0||a.forEach(o=>{if(o&&o.name){var l=this.eventToSurveys.get(o.name);l&&l.push(r.id),this.eventToSurveys.set(o.name,l||[r.id])}})}))}onEvent(t,n){var r,i,s=((r=this.instance)===null||r===void 0||(i=r.persistence)===null||i===void 0?void 0:i.props[zP])||[];if(mke.SURVEY_SHOWN_EVENT_NAME==t&&n&&s.length>0){var a,o=n==null||(a=n.properties)===null||a===void 0?void 0:a.$survey_id;if(o){var l=s.indexOf(o);l>=0&&(s.splice(l,1),this._updateActivatedSurveys(s))}}else this.eventToSurveys.has(t)&&this._updateActivatedSurveys(s.concat(this.eventToSurveys.get(t)||[]))}onAction(t){var n,r,i=((n=this.instance)===null||n===void 0||(r=n.persistence)===null||r===void 0?void 0:r.props[zP])||[];this.actionToSurveys.has(t)&&this._updateActivatedSurveys(i.concat(this.actionToSurveys.get(t)||[]))}_updateActivatedSurveys(t){var n,r;(n=this.instance)===null||n===void 0||(r=n.persistence)===null||r===void 0||r.register({[zP]:[...new Set(t)]})}getSurveys(){var t,n,r=(t=this.instance)===null||t===void 0||(n=t.persistence)===null||n===void 0?void 0:n.props[zP];return r||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}};Et(Lj,"SURVEY_SHOWN_EVENT_NAME","survey shown");let tBe=class{constructor(t){Et(this,"_isFetchingSurveys",!1),Et(this,"_isInitializingSurveys",!1),Et(this,"_surveyCallbacks",[]),this.instance=t,this._surveyEventReceiver=null}onRemoteConfig(t){var n=t.surveys;if(ii(n))return Fa.warn("Decide not loaded yet. Not loading surveys.");var r=gs(n);this._hasSurveys=r?n.length>0:n,Fa.info("decide response received, hasSurveys: ".concat(this._hasSurveys)),this._hasSurveys&&this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");var t=(()=>{for(var n=[],r=0;r<localStorage.length;r++){var i=localStorage.key(r);i!=null&&i.startsWith("seenSurvey_")&&n.push(i)}return n})();t.forEach(n=>localStorage.removeItem(n))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Fa.info("Already initializing surveys, skipping...");else if(this.instance.config.disable_surveys)Fa.info("Disabled. Not loading surveys.");else{var t=Un?.__PosthogExtensions__;if(t)if(this._hasSurveys){this._isInitializingSurveys=!0;try{var n=t.generateSurveys;if(n)this._surveyManager=n(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new Lj(this.instance),Fa.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0});else{var r=t.loadExternalDependency;if(r)r(this.instance,"surveys",s=>{if(s||!t.generateSurveys)return Fa.error("Could not load surveys script",s),void(this._isInitializingSurveys=!1);this._surveyManager=t.generateSurveys(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new Lj(this.instance),Fa.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})});else{var i="PostHog loadExternalDependency extension not found. Cannot load remote config.";Fa.error(i),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:i})}}}catch(s){throw Fa.error("Error initializing surveys",s),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:"Error initializing surveys"}),s}}else Fa.info("No surveys to load.");else Fa.error("PostHog Extensions not found.")}}onSurveysLoaded(t){return this._surveyCallbacks.push(t),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter(n=>n!==t)}}getSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(this.instance.config.disable_surveys)return Fa.info("Disabled. Not loading surveys."),t([]);var r=this.instance.get_property(pj);if(r&&!n)return t(r,{isLoaded:!0});if(this._isFetchingSurveys)return t([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this._isFetchingSurveys=!0,this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",timeout:this.instance.config.surveys_request_timeout_ms,callback:i=>{var s;this._isFetchingSurveys=!1;var a=i.statusCode;if(a!==200||!i.json){var o="Surveys API could not be loaded, status: ".concat(a);return Fa.error(o),t([],{isLoaded:!1,error:o})}var l,c=i.json.surveys||[],u=c.filter(d=>{var h,f,O,g,m,v,y,b,T,x,S,k;return((h=d.conditions)===null||h===void 0?void 0:h.events)&&((f=d.conditions)===null||f===void 0||(O=f.events)===null||O===void 0?void 0:O.values)&&((g=d.conditions)===null||g===void 0||(m=g.events)===null||m===void 0||(v=m.values)===null||v===void 0?void 0:v.length)>0||((y=d.conditions)===null||y===void 0?void 0:y.actions)&&((b=d.conditions)===null||b===void 0||(T=b.actions)===null||T===void 0?void 0:T.values)&&((x=d.conditions)===null||x===void 0||(S=x.actions)===null||S===void 0||(k=S.values)===null||k===void 0?void 0:k.length)>0});return u.length>0&&((l=this._surveyEventReceiver)===null||l===void 0||l.register(u)),(s=this.instance.persistence)===null||s===void 0||s.register({[pj]:c}),t(c,{isLoaded:!0})}})}catch(i){throw this._isFetchingSurveys=!1,i}}_notifySurveyCallbacks(t){for(var n of this._surveyCallbacks)try{t.isLoaded?this.getSurveys(n):n([],t)}catch(r){Fa.error("Error in survey callback",r)}}isSurveyFeatureFlagEnabled(t){return!t||this.instance.featureFlags.isFeatureEnabled(t)}getActiveMatchingSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(r=>{var i,s=r.filter(l=>!(!l.start_date||l.end_date)).filter(l=>{var c;if(!l.conditions)return!0;var u=function(f){var O,g,m;if((O=f.conditions)===null||O===void 0||!O.url)return!0;var v=Ue==null||(g=Ue.location)===null||g===void 0?void 0:g.href;if(!v)return!1;var y=[f.conditions.url];return une[dne((m=f.conditions)===null||m===void 0?void 0:m.urlMatchType)](y,v)}(l),d=(c=l.conditions)===null||c===void 0||!c.selector||tn?.querySelector(l.conditions.selector),h=function(f){var O,g,m;if((O=f.conditions)===null||O===void 0||!O.deviceTypes||((g=f.conditions)===null||g===void 0?void 0:g.deviceTypes.length)===0)return!0;if(!Ws)return!1;var v=Vi.deviceType(Ws);return une[dne((m=f.conditions)===null||m===void 0?void 0:m.deviceTypesMatchType)](f.conditions.deviceTypes,v)}(l);return u&&d&&h}),a=(i=this._surveyEventReceiver)===null||i===void 0?void 0:i.getSurveys(),o=s.filter(l=>{var c,u,d,h,f,O,g,m,v;if(!(l.linked_flag_key||l.targeting_flag_key||l.internal_targeting_flag_key||(c=l.feature_flag_keys)!==null&&c!==void 0&&c.length))return!0;var y=this.isSurveyFeatureFlagEnabled(l.linked_flag_key),b=this.isSurveyFeatureFlagEnabled(l.targeting_flag_key),T=((u=(d=l.conditions)===null||d===void 0||(h=d.events)===null||h===void 0||(f=h.values)===null||f===void 0?void 0:f.length)!==null&&u!==void 0?u:0)>0,x=((O=(g=l.conditions)===null||g===void 0||(m=g.actions)===null||m===void 0||(v=m.values)===null||v===void 0?void 0:v.length)!==null&&O!==void 0?O:0)>0,S=!T&&!x||a?.includes(l.id),k=this._canActivateRepeatedly(l)||this.isSurveyFeatureFlagEnabled(l.internal_targeting_flag_key),_=this.checkFlags(l);return y&&b&&k&&S&&_});return t(o)},n)}checkFlags(t){var n;return(n=t.feature_flag_keys)===null||n===void 0||!n.length||t.feature_flag_keys.every(r=>{var{key:i,value:s}=r;return!i||!s||this.instance.featureFlags.isFeatureEnabled(s)})}_canActivateRepeatedly(t){var n;return ii((n=Un.__PosthogExtensions__)===null||n===void 0?void 0:n.canActivateRepeatedly)?(Fa.warn("init was not called"),!1):Un.__PosthogExtensions__.canActivateRepeatedly(t)}canRenderSurvey(t){if(ii(this._surveyManager))return Fa.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=null;return this.getSurveys(r=>{var i=r.filter(s=>s.id===t)[0];n=i?Ke({},this._surveyManager.canRenderSurvey(i)):{visible:!1,disabledReason:"Survey not found"}}),n}renderSurvey(t,n){ii(this._surveyManager)?Fa.warn("init was not called"):this.getSurveys(r=>{var i=r.filter(s=>s.id===t)[0];this._surveyManager.renderSurvey(i,tn?.querySelector(n))})}};var hne=Ro("[RateLimiter]");let nBe=class{constructor(t){var n,r;Et(this,"serverLimits",{}),Et(this,"lastEventRateLimited",!1),Et(this,"checkForLimiting",i=>{var s=i.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(a=>{hne.info("".concat(a||"events"," is quota limited.")),this.serverLimits[a]=new Date().getTime()+6e4})}catch(a){return void hne.warn('could not rate limit - continuing. Error: "'.concat(a?.message,'"'),{text:s})}}),this.instance=t,this.captureEventsPerSecond=((n=t.config.rate_limiting)===null||n===void 0?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=t.config.rate_limiting)===null||r===void 0?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(){var t,n,r,i=arguments.length>0&&arguments[0]!==void 0&&arguments[0],s=new Date().getTime(),a=(t=(n=this.instance.persistence)===null||n===void 0?void 0:n.get_property(mj))!==null&&t!==void 0?t:{tokens:this.captureEventsBurstLimit,last:s};a.tokens+=(s-a.last)/1e3*this.captureEventsPerSecond,a.last=s,a.tokens>this.captureEventsBurstLimit&&(a.tokens=this.captureEventsBurstLimit);var o=a.tokens<1;return o||i||(a.tokens=Math.max(0,a.tokens-1)),!o||this.lastEventRateLimited||i||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,(r=this.instance.persistence)===null||r===void 0||r.set_property(mj,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()<n}};var Jg=Ro("[RemoteConfig]");let rBe=class{constructor(t){this.instance=t}get remoteConfig(){var t,n;return(t=Un._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(n=t[this.instance.config.token])===null||n===void 0?void 0:n.config}_loadRemoteConfigJs(t){var n,r,i;(n=Un.__PosthogExtensions__)!==null&&n!==void 0&&n.loadExternalDependency?(r=Un.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"remote-config",()=>t(this.remoteConfig)):(Jg.error("PostHog Extensions not found. Cannot load remote config."),t())}_loadRemoteConfigJSON(t){this.instance._send_request({method:"GET",url:this.instance.requestRouter.endpointFor("assets","/array/".concat(this.instance.config.token,"/config")),callback:n=>{t(n.json)}})}load(){try{if(this.remoteConfig)return Jg.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void Jg.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(t=>{if(!t)return Jg.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(n=>{this.onRemoteConfig(n)});this.onRemoteConfig(t)})}catch(t){Jg.error("Error loading remote config",t)}}onRemoteConfig(t){t?this.instance.config.__preview_remote_config?(this.instance._onRemoteConfig(t),t.hasFeatureFlags!==!1&&this.instance.featureFlags.ensureFlagsLoaded()):Jg.info("__preview_remote_config is disabled. Logging config instead",t):Jg.error("Failed to fetch remote config from PostHog.")}};var iBe=function(e){var t,n,r,i,s="";for(t=n=0,r=(e=(e+"").replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
@@ -741,7 +741,7 @@ try {
741
741
  ${c}
742
742
  }
743
743
  } catch(e){}})();`}},"mui-color-scheme-init")}function srt(){}const art=({key:e,storageWindow:t})=>(!t&&typeof window<"u"&&(t=window),{get(n){if(typeof window>"u")return;if(!t)return n;let r;try{r=t.localStorage.getItem(e)}catch{}return r||n},set:n=>{if(t)try{t.localStorage.setItem(e,n)}catch{}},subscribe:n=>{if(!t)return srt;const r=i=>{const s=i.newValue;i.key===e&&n(s)};return t.addEventListener("storage",r),()=>{t.removeEventListener("storage",r)}}});function tD(){}function dre(e){if(typeof window<"u"&&typeof window.matchMedia=="function"&&e==="system")return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ITe(e,t){if(e.mode==="light"||e.mode==="system"&&e.systemMode==="light")return t("light");if(e.mode==="dark"||e.mode==="system"&&e.systemMode==="dark")return t("dark")}function ort(e){return ITe(e,t=>{if(t==="light")return e.lightColorScheme;if(t==="dark")return e.darkColorScheme})}function lrt(e){const{defaultMode:t="light",defaultLightColorScheme:n,defaultDarkColorScheme:r,supportedColorSchemes:i=[],modeStorageKey:s=TB,colorSchemeStorageKey:a=_B,storageWindow:o=typeof window>"u"?void 0:window,storageManager:l=art,noSsr:c=!1}=e,u=i.join(","),d=i.length>1,h=w.useMemo(()=>l?.({key:s,storageWindow:o}),[l,s,o]),f=w.useMemo(()=>l?.({key:`${a}-light`,storageWindow:o}),[l,a,o]),O=w.useMemo(()=>l?.({key:`${a}-dark`,storageWindow:o}),[l,a,o]),[g,m]=w.useState(()=>{const _=h?.get(t)||t,P=f?.get(n)||n,C=O?.get(r)||r;return{mode:_,systemMode:dre(_),lightColorScheme:P,darkColorScheme:C}}),[v,y]=w.useState(c||!d);w.useEffect(()=>{y(!0)},[]);const b=ort(g),T=w.useCallback(_=>{m(P=>{if(_===P.mode)return P;const C=_??t;return h?.set(C),{...P,mode:C,systemMode:dre(C)}})},[h,t]),x=w.useCallback(_=>{_?typeof _=="string"?_&&!u.includes(_)?console.error(`\`${_}\` does not exist in \`theme.colorSchemes\`.`):m(P=>{const C={...P};return ITe(P,Q=>{Q==="light"&&(f?.set(_),C.lightColorScheme=_),Q==="dark"&&(O?.set(_),C.darkColorScheme=_)}),C}):m(P=>{const C={...P},Q=_.light===null?n:_.light,E=_.dark===null?r:_.dark;return Q&&(u.includes(Q)?(C.lightColorScheme=Q,f?.set(Q)):console.error(`\`${Q}\` does not exist in \`theme.colorSchemes\`.`)),E&&(u.includes(E)?(C.darkColorScheme=E,O?.set(E)):console.error(`\`${E}\` does not exist in \`theme.colorSchemes\`.`)),C}):m(P=>(f?.set(n),O?.set(r),{...P,lightColorScheme:n,darkColorScheme:r}))},[u,f,O,n,r]),S=w.useCallback(_=>{g.mode==="system"&&m(P=>{const C=_?.matches?"dark":"light";return P.systemMode===C?P:{...P,systemMode:C}})},[g.mode]),k=w.useRef(S);return k.current=S,w.useEffect(()=>{if(typeof window.matchMedia!="function"||!d)return;const _=(...C)=>k.current(...C),P=window.matchMedia("(prefers-color-scheme: dark)");return P.addListener(_),_(P),()=>{P.removeListener(_)}},[d]),w.useEffect(()=>{if(d){const _=h?.subscribe(Q=>{(!Q||["light","dark","system"].includes(Q))&&T(Q||t)})||tD,P=f?.subscribe(Q=>{(!Q||u.match(Q))&&x({light:Q})})||tD,C=O?.subscribe(Q=>{(!Q||u.match(Q))&&x({dark:Q})})||tD;return()=>{_(),P(),C()}}},[x,T,u,t,o,d,h,f,O]),{...g,mode:v?g.mode:void 0,systemMode:v?g.systemMode:void 0,colorScheme:v?b:void 0,setMode:T,setColorScheme:x}}const crt="*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";function urt(e){const{themeId:t,theme:n={},modeStorageKey:r=TB,colorSchemeStorageKey:i=_B,disableTransitionOnChange:s=!1,defaultColorScheme:a,resolveTheme:o}=e,l={allColorSchemes:[],colorScheme:void 0,darkColorScheme:void 0,lightColorScheme:void 0,mode:void 0,setColorScheme:()=>{},setMode:()=>{},systemMode:void 0},c=w.createContext(void 0),u=()=>w.useContext(c)||l,d={},h={};function f(v){const{children:y,theme:b,modeStorageKey:T=r,colorSchemeStorageKey:x=i,disableTransitionOnChange:S=s,storageManager:k,storageWindow:_=typeof window>"u"?void 0:window,documentNode:P=typeof document>"u"?void 0:document,colorSchemeNode:C=typeof document>"u"?void 0:document.documentElement,disableNestedContext:Q=!1,disableStyleSheetGeneration:E=!1,defaultMode:A="system",noSsr:L}=v,j=w.useRef(!1),q=kB(),z=w.useContext(c),V=!!z&&!Q,W=w.useMemo(()=>b||(typeof n=="function"?n():n),[b]),M=W[t],K=M||W,{colorSchemes:N=d,components:D=h,cssVarPrefix:B}=K,G=Object.keys(N).filter(Be=>!!N[Be]).join(","),ee=w.useMemo(()=>G.split(","),[G]),he=typeof a=="string"?a:a.light,ae=typeof a=="string"?a:a.dark,se=N[he]&&N[ae]?A:N[K.defaultColorScheme]?.palette?.mode||K.palette?.mode,{mode:me,setMode:fe,systemMode:Y,lightColorScheme:Te,darkColorScheme:ke,colorScheme:Ve,setColorScheme:De}=lrt({supportedColorSchemes:ee,defaultLightColorScheme:he,defaultDarkColorScheme:ae,modeStorageKey:T,colorSchemeStorageKey:x,defaultMode:se,storageManager:k,storageWindow:_,noSsr:L});let ve=me,Re=Ve;V&&(ve=z.mode,Re=z.colorScheme);const tt=w.useMemo(()=>{const Be=Re||K.defaultColorScheme,bt=K.generateThemeVars?.()||K.vars,xe={...K,components:D,colorSchemes:N,cssVarPrefix:B,vars:bt};if(typeof xe.generateSpacing=="function"&&(xe.spacing=xe.generateSpacing()),Be){const qe=N[Be];qe&&typeof qe=="object"&&Object.keys(qe).forEach(rt=>{qe[rt]&&typeof qe[rt]=="object"?xe[rt]={...xe[rt],...qe[rt]}:xe[rt]=qe[rt]})}return o?o(xe):xe},[K,Re,D,N,B]),ot=K.colorSchemeSelector;Ynt(()=>{if(Re&&C&&ot&&ot!=="media"){const Be=ot;let bt=ot;if(Be==="class"&&(bt=".%s"),Be==="data"&&(bt="[data-%s]"),Be?.startsWith("data-")&&!Be.includes("%s")&&(bt=`[${Be}="%s"]`),bt.startsWith("."))C.classList.remove(...ee.map(xe=>bt.substring(1).replace("%s",xe))),C.classList.add(bt.substring(1).replace("%s",Re));else{const xe=bt.replace("%s",Re).match(/\[([^\]]+)\]/);if(xe){const[qe,rt]=xe[1].split("=");rt||ee.forEach(et=>{C.removeAttribute(qe.replace(Re,et))}),C.setAttribute(qe,rt?rt.replace(/"|'/g,""):"")}else C.setAttribute(bt,Re)}}},[Re,ot,C,ee]),w.useEffect(()=>{let Be;if(S&&j.current&&P){const bt=P.createElement("style");bt.appendChild(P.createTextNode(crt)),P.head.appendChild(bt),window.getComputedStyle(P.body),Be=setTimeout(()=>{P.head.removeChild(bt)},1)}return()=>{clearTimeout(Be)}},[Re,S,P]),w.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]);const Vt=w.useMemo(()=>({allColorSchemes:ee,colorScheme:Re,darkColorScheme:ke,lightColorScheme:Te,mode:ve,setColorScheme:De,setMode:fe,systemMode:Y}),[ee,Re,ke,Te,ve,De,fe,Y,tt.colorSchemeSelector]);let Dt=!0;(E||K.cssVariables===!1||V&&q?.cssVarPrefix===B)&&(Dt=!1);const vn=p.jsxs(w.Fragment,{children:[p.jsx(DTe,{themeId:M?t:void 0,theme:tt,children:y}),Dt&&p.jsx(Gnt,{styles:tt.generateStyleSheets?.()||[]})]});return V?vn:p.jsx(c.Provider,{value:Vt,children:vn})}const O=typeof a=="string"?a:a.light,g=typeof a=="string"?a:a.dark;return{CssVarsProvider:f,useColorScheme:u,getInitColorSchemeScript:v=>irt({colorSchemeStorageKey:i,defaultLightColorScheme:O,defaultDarkColorScheme:g,modeStorageKey:r,...v})}}function nD({theme:e,...t}){const n=ub in e?e[ub]:void 0;return p.jsx(DTe,{...t,themeId:n?ub:void 0,theme:n||e})}const t2={colorSchemeStorageKey:"mui-color-scheme",defaultLightColorScheme:"light",defaultDarkColorScheme:"dark",modeStorageKey:"mui-mode"},{CssVarsProvider:drt}=urt({themeId:ub,theme:()=>OWe({cssVariables:!0}),colorSchemeStorageKey:t2.colorSchemeStorageKey,modeStorageKey:t2.modeStorageKey,defaultColorScheme:{light:t2.defaultLightColorScheme,dark:t2.defaultDarkColorScheme},resolveTheme:e=>{const t={...e,typography:pWe(e.palette,e.typography)};return t.unstable_sx=function(r){return gWe({sx:r,theme:this})},t}}),hrt=drt;function frt({theme:e,...t}){if(typeof e=="function")return p.jsx(nD,{theme:e,...t});const n=ub in e?e[ub]:e;return"colorSchemes"in n?p.jsx(hrt,{theme:e,...t}):"vars"in n?p.jsx(nD,{theme:e,...t}):p.jsx(nD,{theme:{...e,vars:null},...t})}const rD=e=>({isRunPanelOpen:e==="isRunPanelOpen",isCanvasOpen:e==="isCanvasOpen"}),hre=800,fre=280,Ore=420,sr=Ao()(yd(e=>({isCommandPaletteOpen:!1,commandPaletteQuery:"",isSidebarCollapsed:!1,showAgentReasoning:!1,themeName:mWe,canvasWidth:hre,chatSidebarWidth:fre,isCanvasOpen:!1,isRunPanelOpen:!1,runPanelReveal:null,runPanelWidth:Ore,isCreateAgentDialogOpen:!1,openCreateAgentDialog:()=>{e({isCreateAgentDialogOpen:!0})},closeCreateAgentDialog:()=>{e({isCreateAgentDialogOpen:!1})},openCommandPalette:()=>{e({isCommandPaletteOpen:!0})},closeCommandPalette:()=>{e({isCommandPaletteOpen:!1,commandPaletteQuery:""})},toggleCommandPalette:()=>{e(t=>({isCommandPaletteOpen:!t.isCommandPaletteOpen,commandPaletteQuery:t.isCommandPaletteOpen?t.commandPaletteQuery:""}))},setCommandPaletteQuery:t=>{e({commandPaletteQuery:t})},toggleSidebar:()=>{e(t=>({isSidebarCollapsed:!t.isSidebarCollapsed}))},setSidebarCollapsed:t=>{e({isSidebarCollapsed:t})},setShowAgentReasoning:t=>{e({showAgentReasoning:t})},setTheme:t=>{e({themeName:t})},setCanvasOpen:t=>{e(t?rD("isCanvasOpen"):{isCanvasOpen:!1})},setRunPanelOpen:t=>{e(t?rD("isRunPanelOpen"):{isRunPanelOpen:!1})},revealRunPanelSection:t=>{e(n=>({...rD("isRunPanelOpen"),runPanelReveal:{section:t,nonce:(n.runPanelReveal?.nonce??0)+1}}))},clearRunPanelReveal:t=>{e(n=>n.runPanelReveal?.nonce===t?{runPanelReveal:null}:{})},setRunPanelWidth:t=>{e({runPanelWidth:t})},restoreDefaultRunPanelWidth:()=>{e({runPanelWidth:Ore})},setCanvasWidth:t=>{e({canvasWidth:t})},setChatSidebarWidth:t=>{e({chatSidebarWidth:Math.min(360,Math.max(240,t))})},restoreDefaultCanvasWidth:()=>{e({canvasWidth:hre})},restoreDefaultChatSidebarWidth:()=>{e({chatSidebarWidth:fre})}}),{name:"ui-preferences-storage",partialize:e=>{const{runPanelReveal:t,...n}=e;return n}})),Ort=16,prt=64,grt=200;let Xm=null;const mrt=()=>{Xm||(Xm=document.createElement("div"),Object.assign(Xm.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",cursor:"col-resize",zIndex:"9999"}),document.body.appendChild(Xm))},vrt=()=>{Xm&&(document.body.removeChild(Xm),Xm=null)},oq=({sidebarWidth:e,onSidebarWidthChange:t,minWidth:n=180,maxWidth:r=600,side:i="right",onDoubleClick:s,label:a})=>{const[o,l]=w.useState(!1),[c,u]=w.useState(!1),d=w.useRef(!1),h=w.useRef(null);w.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const f=y=>Math.max(n,Math.min(r,y)),O=y=>{t(f(e+(i==="right"?y:-y)))},g=y=>{const b=y.shiftKey?prt:Ort;switch(y.key){case"ArrowLeft":y.preventDefault(),O(-b);return;case"ArrowRight":y.preventDefault(),O(b);return;case"Home":y.preventDefault(),t(i==="right"?n:r);return;case"End":y.preventDefault(),t(i==="right"?r:n);return;case"Enter":s&&(y.preventDefault(),s());return}},m=y=>{y.preventDefault(),d.current=!0,u(!0);const b=y.clientX,T=e;document.body.style.userSelect="none",mrt();const x=k=>{if(!d.current)return;const _=k.clientX-b,P=i==="right"?T+_:T-_;t(f(P))},S=()=>{d.current&&(d.current=!1,u(!1),l(!1),document.body.style.userSelect="",vrt(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",S),window.removeEventListener("blur",S),document.documentElement.removeEventListener("mouseleave",S))};window.addEventListener("mousemove",x),window.addEventListener("mouseup",S),window.addEventListener("blur",S),document.documentElement.addEventListener("mouseleave",S)},v=o||c;return p.jsxs("div",{className:"relative z-10 h-full w-0 shrink-0",children:[p.jsx("div",{"aria-hidden":"true",className:I("pointer-events-none absolute top-0 z-12 h-full w-0.5","transition-[opacity,background-color] duration-fast ease-out-quart",i==="left"?"left-0":"right-0",c?"bg-accent":"bg-control",v?"opacity-100":"opacity-0")}),p.jsx("div",{role:"separator","aria-label":a,"aria-orientation":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":n,"aria-valuemax":r,tabIndex:0,className:I("absolute top-0 z-11 h-full w-3 cursor-col-resize touch-none",i==="left"?"-left-1.5":"-right-1.5"),onMouseEnter:()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>l(!0),grt)},onMouseLeave:()=>{h.current&&clearTimeout(h.current),d.current||l(!1)},onFocus:()=>l(!0),onBlur:()=>{d.current||l(!1)},onKeyDown:g,onMouseDown:m,onDoubleClick:s})]})},yrt=({sidebar:e,content:t})=>{const n=sr(a=>a.chatSidebarWidth),r=Number.isFinite(n)?Math.min(360,Math.max(240,n)):280,i=sr(a=>a.setChatSidebarWidth),s=sr(a=>a.restoreDefaultChatSidebarWidth);return p.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[p.jsx("div",{className:"h-full shrink-0",style:{width:r},children:e}),p.jsx(oq,{sidebarWidth:r,onSidebarWidthChange:i,minWidth:240,maxWidth:360,onDoubleClick:s,label:"Resize chat sidebar"}),p.jsx("div",{className:"h-full grow overflow-hidden",children:t})]})},Ry=({open:e,onClose:t,autoHideDuration:n,variant:r="info",role:i,action:s,children:a})=>{if(w.useEffect(()=>{if(!e||n===void 0)return;const l=window.setTimeout(t,n);return()=>window.clearTimeout(l)},[e,n,t]),!e)return null;const o=i??(r==="danger"||r==="warning"?"alert":"status");return p.jsxs("div",{className:"fixed right-4 bottom-4 z-50 w-100 max-w-[calc(100vw-2rem)]",children:[p.jsxs(el,{variant:r,role:o,className:"relative pr-10 shadow-overlay",children:[a,s?p.jsx("div",{className:"flex justify-end gap-2 pt-1",children:s}):null]}),p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:t,"aria-label":"Dismiss",className:"absolute top-1.5 right-1.5",children:p.jsx(Js,{})})]})};Ry.displayName="FloatingAlert";const brt=48*60*60*1e3;var Ay=(e=>(e.UI="ui",e.BACKEND="backend",e))(Ay||{});const wrt=Ao()(yd((e,t)=>({uiDeferredVersion:null,uiDeferredAt:null,backendDeferredVersion:null,backendDeferredAt:null,hydrated:!1,deferUpdate:(n,r)=>{e(n==="ui"?{uiDeferredVersion:r,uiDeferredAt:Date.now()}:{backendDeferredVersion:r,backendDeferredAt:Date.now()})},shouldShowUpdate:(n,r)=>{const{uiDeferredVersion:i,uiDeferredAt:s,backendDeferredVersion:a,backendDeferredAt:o}=t();let l,c;return n==="ui"?(l=i,c=s):(l=a,c=o),!l||!c||l!==r?!0:Date.now()-c>brt},clearDeferredUpdate:n=>{if(n==="ui")e({uiDeferredVersion:null,uiDeferredAt:null});else if(n==="backend")e({backendDeferredVersion:null,backendDeferredAt:null});else throw new Error(`Invalid update type: ${n}`)}}),{name:"deferred-updates-storage",onRehydrateStorage:()=>e=>{e&&typeof e=="object"&&"setState"in e&&typeof e.setState=="function"&&e.setState({hydrated:!0})}})),xrt=({autoCheck:e=!0})=>{const{hostingProvider:t,shouldCheckInternet:n,hasConnectivityIssue:r,connectivityIssue:i,refetchServerStatus:s,refetchInternetStatus:a}=gTe(),[o,l]=w.useState(!1),[c,u]=w.useState(!1);w.useEffect(()=>{l(i==="internet_offline"?r&&!c:r)},[r,i,c]),w.useEffect(()=>{(!r||i!=="internet_offline")&&u(!1)},[r,i]),w.useEffect(()=>{const O=()=>{n&&(l(!0),u(!1))},g=()=>{l(!1),u(!1)};return window.addEventListener("offline",O),window.addEventListener("online",g),()=>{window.removeEventListener("offline",O),window.removeEventListener("online",g)}},[n]),w.useEffect(()=>{if(e){s();const O=setInterval(()=>{s()},3e3);return()=>clearInterval(O)}},[e,s]);const d=()=>{s(),n&&a()},h=()=>{u(!0),l(!1)};if(!o)return null;const f=i==="internet_offline";return p.jsx("div",{className:"fixed inset-x-0 top-0 z-2200 w-full",children:p.jsx(el,{variant:f?"warning":"danger",role:"alert",className:"items-center rounded-none border-x-0 border-t-0",children:p.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[p.jsx(vA,{children:i==="server_offline"?"The server is offline. The interface will not function properly until the server is back online.":f?`You are offline. Your configured hosting provider (${t}) requires an internet connection.`:"A connectivity issue has been detected."}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[p.jsx(we,{variant:"ghost",size:"sm",onClick:d,children:"Retry"}),f&&p.jsx(we,{variant:"ghost",size:"sm","aria-label":"dismiss",onClick:h,children:"Dismiss"})]})]})})})},Zn=re.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),n2=re.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),r2=re.string().min(1).max(32768),Ai=re.string().regex(/^[a-f0-9]{12}$/),NTe=/^[a-f0-9]{32}$/,ya=re.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),pre=re.object({data_b64:re.string().min(1).max(1e6),mime_type:re.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),eg=2e5,LA=256,FTe=100,lq=1e6,Sf=re.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),gre=re.object({kind:re.enum(["agent","team"]),name:Sf}).strict(),mre=re.object({provider:re.string().min(1).max(128),model_id:re.string().min(1).max(512),reasoning_effort:re.string().min(1).max(64).nullable()}).strict(),vre=re.object({kind:re.enum(["role","specialist"]).optional(),description:re.string().max(8e3).optional(),instructions:re.string().max(8e3).optional(),tools:re.array(re.string().min(1).max(128)).max(256).optional(),effort:re.string().max(64).optional(),delegate:re.boolean().optional()}).strict(),yre=re.object({name:re.string().min(1).max(64).optional(),description:re.string().max(8e3).optional(),manager:Sf.optional(),members:re.array(re.object({role:Sf,count:re.number().int().min(1).max(16),kind:re.enum(["agent","team"])}).strict()).max(128).optional(),instructions:re.string().max(8e3).optional(),project:re.string().max(8e3).optional()}).strict(),Srt=re.record(re.array(re.string().max(1024)).max(100)),bre=re.enum(["minutes","hours","days"]),iD=re.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),wre=re.object({is_active:re.boolean().nullish(),one_time:re.boolean().nullish(),start_time_utc:re.string().max(64).nullish(),end_time_utc:re.string().max(64).nullish()}).strict(),$rt=re.object({conversation_length:re.number().int().optional(),detail_length:re.number().int().optional(),max_learnings_history:re.number().int().optional(),hosting:re.string().max(256).optional(),model_name:re.string().max(1024).optional(),auto_save_conversation:re.boolean().optional()}).strict();re.discriminatedUnion("op",[re.object({op:re.literal("capabilities")}).strict(),re.object({op:re.literal("profiles.list")}).strict(),re.object({op:re.literal("profiles.get"),name:Sf}).strict(),re.object({op:re.literal("profiles.install"),name:Sf,requestId:ya}).strict(),re.object({op:re.literal("profiles.create"),name:Sf,requestId:ya,fields:vre.extend({description:re.string().max(8e3),instructions:re.string().min(1).max(8e3)})}).strict(),re.object({op:re.literal("profiles.update"),name:Sf,requestId:ya,fields:vre}).strict(),re.object({op:re.literal("teams.list")}).strict(),re.object({op:re.literal("teams.get"),name:Sf}).strict(),re.object({op:re.literal("teams.create"),requestId:ya,fields:yre.extend({name:re.string().min(1).max(64)})}).strict(),re.object({op:re.literal("teams.update"),name:Sf,requestId:ya,fields:yre}).strict(),re.object({op:re.literal("sessions.list"),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("sessions.search"),q:re.string().min(1).max(LA),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("sessions.create"),requestId:ya,cwd:re.string().min(1).max(4096),target:gre.optional(),model:mre.optional()}).strict(),re.object({op:re.literal("sessions.preview"),requestId:ya,cwd:re.string().min(1).max(4096),target:gre.optional(),model:mre.optional()}).strict(),re.object({op:re.literal("sessions.get"),sessionId:Ai}).strict(),re.object({op:re.literal("sessions.history"),sessionId:Ai,beforeId:Zn.optional(),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("subagents.transcript"),sessionId:Ai,childId:Ai,beforeId:Zn.optional(),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("sessions.message"),sessionId:Ai,requestId:ya,text:re.string().max(eg),images:re.array(pre).max(8).optional(),mode:re.enum(["prompt","steer"]).optional()}).strict(),re.object({op:re.literal("sessions.command"),sessionId:Ai,requestId:ya,command:re.string().regex(/^\/?[A-Za-z]+$/).max(64),args:re.string().max(eg).optional(),images:re.array(pre).max(8).optional()}).strict(),re.object({op:re.literal("sessions.answer"),sessionId:Ai,epoch:Zn,requestId:Zn,value:re.string().max(32768).optional(),approved:re.boolean().optional(),questionIndex:re.number().int().min(0).optional()}).strict(),re.object({op:re.literal("sessions.seen"),sessionId:Ai,completionToken:re.string().uuid()}).strict(),re.object({op:re.literal("sessions.notified"),sessionId:Ai,completionToken:re.string().uuid()}).strict(),re.object({op:re.literal("sessions.watch"),sessionId:Ai,subscriptionId:re.string().regex(NTe),visible:re.boolean(),canNotify:re.boolean()}).strict(),re.object({op:re.literal("sessions.warm"),sessionId:Ai}).strict(),re.object({op:re.literal("legacy.models"),provider:re.string().max(128).optional(),sort:re.enum(["id","name","provider","recommended"]).optional(),direction:re.enum(["ascending","descending"]).optional()}).strict(),re.object({op:re.literal("legacy.models.providers")}).strict(),re.object({op:re.literal("auth.probe"),provider:Zn}).strict(),re.object({op:re.literal("legacy.agent.upload"),agentId:Zn}).strict(),re.object({op:re.literal("legacy.agents.list"),page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(500).optional(),name:re.string().max(256).optional(),sort:re.string().max(64).optional(),direction:re.enum(["asc","desc"]).optional()}).strict(),re.object({op:re.literal("legacy.agent.get"),agentId:Zn}).strict(),re.object({op:re.literal("legacy.agent.history"),agentId:Zn,page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("legacy.jobs.list"),agentId:Zn.optional(),status:re.string().max(64).optional()}).strict(),re.object({op:re.literal("legacy.job.get"),jobId:Zn}).strict(),re.object({op:re.literal("legacy.schedules.list"),page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(100).optional()}).strict(),re.object({op:re.literal("legacy.agent.schedules.list"),agentId:Zn,page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(100).optional()}).strict(),re.object({op:re.literal("legacy.agent.schedule.create"),agentId:Zn,schedule:wre.extend({prompt:re.string().max(64e3),interval:re.number().int().min(1),unit:bre})}).strict(),re.object({op:re.literal("legacy.schedule.get"),scheduleId:Zn}).strict(),re.object({op:re.literal("legacy.schedule.edit"),scheduleId:Zn,schedule:wre.extend({prompt:re.string().max(64e3).nullish(),interval:re.number().int().min(1).nullish(),unit:bre.nullish()})}).strict(),re.object({op:re.literal("legacy.schedule.remove"),scheduleId:Zn}).strict(),re.object({op:re.literal("legacy.agent.create"),agent:re.record(re.unknown())}).strict(),re.object({op:re.literal("legacy.agent.update"),agentId:Zn,update:re.record(re.unknown())}).strict(),re.object({op:re.literal("legacy.agent.delete"),agentId:Zn}).strict(),re.object({op:re.literal("legacy.agent.conversation.clear"),agentId:Zn}).strict(),re.object({op:re.literal("legacy.agent.systemPrompt.get"),agentId:Zn}).strict(),re.object({op:re.literal("legacy.agent.systemPrompt.update"),agentId:Zn,systemPrompt:re.string().max(lq)}).strict(),re.object({op:re.literal("legacy.agent.download"),agentId:Zn}).strict(),re.object({op:re.literal("legacy.agent.variables.list"),agentId:Zn}).strict(),re.object({op:re.literal("legacy.agent.variables.create"),agentId:Zn,variable:re.record(re.unknown())}).strict(),re.object({op:re.literal("legacy.agent.variables.get"),agentId:Zn,key:iD}).strict(),re.object({op:re.literal("legacy.agent.variables.update"),agentId:Zn,key:iD,variable:re.record(re.unknown())}).strict(),re.object({op:re.literal("legacy.agent.variables.delete"),agentId:Zn,key:iD}).strict(),re.object({op:re.literal("legacy.job.cancel"),jobId:Zn}).strict(),re.object({op:re.literal("commands.list")}).strict(),re.object({op:re.literal("commands.entities"),sessionId:Ai,command:Zn,name:re.string().max(128).optional()}).strict(),re.object({op:re.literal("models.catalogue"),live:re.boolean().optional()}).strict(),re.object({op:re.literal("usage.get"),provider:Zn.optional(),live:re.boolean().optional(),refresh:re.boolean().optional()}).strict(),re.object({op:re.literal("analytics.get"),sessionId:Ai.optional(),sinceMs:re.number().int().nonnegative().optional(),untilMs:re.number().int().nonnegative().optional(),days:re.number().int().min(1).max(366).optional()}).strict(),re.object({op:re.literal("info.get")}).strict(),re.object({op:re.literal("sessions.report"),sessionId:Ai,recentLimit:re.number().int().min(0).max(50).optional()}).strict(),re.object({op:re.literal("skills.list"),sessionId:Ai,name:Zn.optional()}).strict(),re.object({op:re.literal("sessions.failovers"),sessionId:Ai}).strict(),re.object({op:re.literal("sessions.credential"),sessionId:Ai,action:re.enum(["list","store","forget"]),key:n2.optional(),value:r2.optional(),confirmed:re.boolean().optional()}).strict(),re.object({op:re.literal("sessions.fork"),sessionId:Ai,requestId:ya,message:re.string().max(2e5).optional(),boundary:re.literal("next_safe").optional()}).strict(),re.object({op:re.literal("sessions.stop"),requestId:ya,targets:re.array(Ai).min(1).max(100),confirmed:re.literal(!0)}).strict(),re.object({op:re.literal("sessions.aside"),sessionId:Ai,requestId:ya,text:re.string().min(1).max(32768),asideId:ya.optional()}).strict(),re.object({op:re.literal("sessions.adopt"),sessionId:Ai,requestId:ya,asideId:ya,confirmed:re.literal(!0)}).strict(),re.object({op:re.literal("sessions.aside.get"),sessionId:Ai,asideId:ya}).strict(),re.object({op:re.literal("sessions.aside.close"),sessionId:Ai,asideId:ya}).strict(),re.object({op:re.literal("mcp.list"),sessionId:Ai}).strict(),re.object({op:re.literal("mcp.control"),sessionId:Ai,control:re.object({action:re.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:re.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/).optional(),scope:re.enum(["global","project"]).optional(),command:re.string().min(1).max(4096).optional(),args:re.array(re.string().max(8192)).max(128).optional(),env:re.record(re.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/)).optional(),url:re.string().max(4096).optional(),headers:re.record(re.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/)).optional(),oauth:re.boolean().optional(),confirmed:re.boolean().optional(),operation_id:re.string().regex(/^[a-f0-9]{32}$/).optional()}).strict()}).strict(),re.object({op:re.literal("radient.request"),control:re.object({operation:re.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","comments.list","comments.create","comments.update","comments.delete","account.agents"]),request_id:ya.optional(),tenant_id:Zn.optional(),account_id:Zn.optional(),agent_id:Zn.optional(),comment_id:Zn.optional(),query:re.record(re.union([re.string().max(1024),re.number().int()])).optional(),payload:re.record(re.unknown()).optional(),confirmed:re.boolean().optional()}).strict()}).strict(),re.object({op:re.literal("providers.list")}).strict(),re.object({op:re.literal("accounts.list")}).strict(),re.object({op:re.literal("accounts.remove"),accountId:re.number().int().positive(),confirmed:re.literal(!0)}).strict(),re.object({op:re.literal("auth.start"),provider:Zn}).strict(),re.object({op:re.literal("auth.status"),id:Zn}).strict(),re.object({op:re.literal("auth.input"),id:Zn,promptId:Zn,value:r2}).strict(),re.object({op:re.literal("auth.cancel"),id:Zn}).strict(),re.object({op:re.literal("auth.key"),provider:Zn,value:r2}).strict(),re.object({op:re.literal("auth.logout"),provider:Zn}).strict(),re.object({op:re.literal("settings.list")}).strict(),re.object({op:re.literal("settings.edit"),key:n2,value:re.unknown().refine(e=>e!==void 0,"A setting value is required."),base:Srt.optional()}).strict(),re.object({op:re.literal("settings.reset"),key:n2}).strict(),re.object({op:re.literal("config.get")}).strict(),re.object({op:re.literal("config.update"),value:$rt}).strict(),re.object({op:re.literal("instructions.get")}).strict(),re.object({op:re.literal("instructions.update"),content:re.string().max(64e3)}).strict(),re.object({op:re.literal("credentials.list")}).strict(),re.object({op:re.literal("credentials.update"),key:n2,value:r2}).strict()]);const krt=88e4,Trt=11e5,jA=krt,_rt=Trt;function PB(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields}};case"sessions.list":return{path:`/v1/desktop/sessions?limit=${e.limit??100}`,method:"GET"};case"sessions.search":return{path:`/v1/desktop/sessions/search?${new URLSearchParams({q:e.q,limit:String(e.limit??FTe)})}`,method:"GET"};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"GET"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],mode:e.mode??"prompt"}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.answer":return{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.agent.variables.list":return{path:`/v1/agents/${e.agentId}/execution-variables`,method:"GET"};case"legacy.agent.variables.create":return{path:`/v1/agents/${e.agentId}/execution-variables`,method:"POST",body:e.variable};case"legacy.agent.variables.get":return{path:`/v1/agents/${e.agentId}/execution-variables/${e.key}`,method:"GET"};case"legacy.agent.variables.update":return{path:`/v1/agents/${e.agentId}/execution-variables/${e.key}`,method:"PATCH",body:e.variable};case"legacy.agent.variables.delete":return{path:`/v1/agents/${e.agentId}/execution-variables/${e.key}`,method:"DELETE"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":return{path:`/v1/desktop/models?live=${e.live??!1}`,method:"GET"};case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":return{path:`/v1/desktop/skills?session_id=${e.sessionId}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}}}}const xre=64,Sre=64*1024*1024,CB="000000000000",QB="00000000-0000-0000-0000-000000000000";function cq(e,t){const n=PB({op:"sessions.message",sessionId:CB,requestId:QB,text:e,images:t,mode:"prompt"});return new TextEncoder().encode(JSON.stringify(n.body)).length}function sD(e){return e>=999500?`${(e/1e6).toFixed(1)} MB`:`${Math.round(e/1e3)} KB`}function Rk(e,t){const n=sD(e);if(n!==sD(t))return[n,sD(t)];const r=n.endsWith("MB"),i=r?1e6:1e3,s=r?"MB":"KB";for(const a of[2,3]){const o=(e/i).toFixed(a),l=(t/i).toFixed(a);if(o!==l)return[`${o} ${s}`,`${l} ${s}`]}return[`${e.toLocaleString()} bytes`,`${t.toLocaleString()} bytes`]}function Prt(e,t,n=jA){if(t.length>eg)return`This command is ${t.length.toLocaleString()} characters, more than the ${eg.toLocaleString()} one command can carry. Shorten it, or put the text in a message instead.`;const r=PB({op:"sessions.command",sessionId:CB,requestId:QB,command:e,args:t}),i=new TextEncoder().encode(JSON.stringify(r.body)).length;if(i<=n)return null;const[s,a]=Rk(i,n);return`This command is ${s}, more than the ${a} one command can carry. Shorten it, or put the text in a message instead.`}function DWn(e,t=_rt){if(e.length>lq)return`This system prompt is ${e.length.toLocaleString()} characters, more than the ${lq.toLocaleString()} one agent can carry. Shorten it.`;const n=new TextEncoder().encode(JSON.stringify({system_prompt:e})).length;if(n<=t)return null;const[r,i]=Rk(n,t);return`This system prompt is ${r}, more than the ${i} one agent can carry. Shorten it.`}function Crt(e,t=jA){if(e.length>eg)return`This first message is ${e.length.toLocaleString()} characters, more than the ${eg.toLocaleString()} one message can carry. Shorten it, or send it in the new conversation instead.`;const n=PB({op:"sessions.fork",sessionId:CB,requestId:QB,message:e,boundary:"next_safe"}),r=new TextEncoder().encode(JSON.stringify(n.body)).length;if(r<=t)return null;const[i,s]=Rk(r,t);return`This first message is ${i}, more than the ${s} one message can carry. Shorten it, or send it in the new conversation instead.`}function Qrt(e,t,n=jA){if(e.length>eg)return`This message is ${e.length.toLocaleString()} characters, more than the ${eg.toLocaleString()} one message can carry. Split it across two messages.`;const r=cq(e,t);if(r<=n)return null;const i=cq(e,[]),s=r-i;if(t.length&&s>=i){const[l,c]=Rk(s,n);return`These images total ${l}, more than the ${c} one message can carry. Remove an image, or send them in a second message.`}const[a,o]=Rk(i,n);return`This message is ${a} of text, more than the ${o} one message can carry. Split it across two messages.`}const id={capabilities:["desktop","capabilities"],providers:["desktop","auth","providers"],commands:["desktop","commands"],accounts:["desktop","auth","accounts"]};function Dl(){return rr({queryKey:id.capabilities,queryFn:async()=>{try{return await an({op:"capabilities"})}catch(e){throw e instanceof Error?e:new Error(String(e))}},staleTime:6e4,retry:!1})}function Ks(e,t,n=1){return!e||!e.desktop_available?!1:(e.features?.[t]??0)>=n}function L_(e){return rr({queryKey:id.providers,queryFn:()=>an({op:"providers.list"}).then(t=>t.providers),enabled:e,staleTime:3e4,retry:AA})}var pi=(e=>(e.CONNECT_PROVIDER="connect_provider",e.USER_PROFILE="user_profile",e.SEARCH_API="search_api",e.DEFAULT_MODEL="default_model",e.CREATE_AGENT="create_agent",e.CONGRATULATIONS="congratulations",e))(pi||{});const Ak=Ao()(yd((e,t)=>({isModalComplete:!1,isTourComplete:!1,currentStep:"connect_provider",isModalActive:!1,completeModalOnboarding:()=>{e({isModalComplete:!0,isModalActive:!1})},completeTourOnboarding:()=>{e({isTourComplete:!0})},setCurrentStep:n=>{e({currentStep:n})},activateModalOnboarding:()=>{e({isModalActive:!0})},deactivateModalOnboarding:()=>{e({isModalActive:!1})},resetOnboarding:()=>{e({isModalComplete:!1,isTourComplete:!1,currentStep:"connect_provider",isModalActive:!1})}}),{name:"onboarding-storage",partialize:e=>({isModalComplete:e.isModalComplete,isTourComplete:e.isTourComplete,currentStep:e.currentStep}),merge:(e,t)=>{const{isModalActive:n,...r}=e??{};return{...t,...r}},onRehydrateStorage:()=>(e,t)=>{t?console.error("Failed to rehydrate onboarding store:",t):e&&JSON.parse(localStorage.getItem("onboarding-storage")||"{}")?.state?.isComplete===!0&&!e.isModalComplete&&(console.log("Migrating old 'isComplete:true' state to 'isModalComplete:true'"),e.isModalComplete=!0)}}));function MTe(e){return e.some(t=>!t.local&&!t.credential_optional&&(t.configured||t.has_credential))}function Ert(e){return e.onboardingComplete?"returning":e.census.status==="loading"||e.census.status==="failed"?"pending":e.census.status==="ready"?MTe(e.census.providers)?"returning":"first_time":e.legacy.status!=="ready"?"pending":e.legacy.keys.length===0?"first_time":"returning"}const Rrt=()=>{const e=Dl(),t=Ks(e.data,"auth"),n=L_(t),{shouldEnableQuery:r}=F_(),i=rr({queryKey:["open-credentials"],enabled:!t&&!e.isPending&&r({bypassInternetCheck:!0}),queryFn:()=>Jke.listOpenCredentials(Rr.baseUrl),staleTime:5e3,retry:!1}),{isModalComplete:s,isModalActive:a,activateModalOnboarding:o,deactivateModalOnboarding:l,resetOnboarding:c}=Ak();let u;e.isPending?u={status:"loading"}:t?n.isSuccess?u={status:"ready",providers:n.data}:n.isError?u={status:"failed"}:u={status:"loading"}:u={status:"unavailable"};let d;t||e.isPending?d={status:"loading"}:i.isSuccess&&i.data?d={status:"ready",keys:i.data.keys}:i.isError?d={status:"error"}:d={status:"loading"};const f=Ert({onboardingComplete:s,census:u,legacy:d})==="first_time";return w.useEffect(()=>{f&&!a&&o()},[f,a,o]),{isFirstTimeUser:f,isOnboardingActive:a,activateOnboarding:o,deactivateOnboarding:l,resetOnboarding:c}},Art=(e,t)=>e===t?!0:!e||!t?!e&&!t:e.length!==t.length?!1:e.every((n,r)=>n===t[r]),$re=(e,t)=>{const n=e.timestamp instanceof Date?e.timestamp.getTime():new Date(e.timestamp).getTime(),r=t.timestamp instanceof Date?t.timestamp.getTime():new Date(t.timestamp).getTime();return e.id===t.id&&e.role===t.role&&n===r&&e.message===t.message&&e.code===t.code&&e.stdout===t.stdout&&e.stderr===t.stderr&&e.logging===t.logging&&e.formatted_print===t.formatted_print&&e.status===t.status&&e.task_classification===t.task_classification&&e.action===t.action&&e.execution_type===t.execution_type&&e.is_streamable===t.is_streamable&&e.is_complete===t.is_complete&&e.conversation_id===t.conversation_id&&e.content===t.content&&e.file_path===t.file_path&&e.replacements===t.replacements&&e.agent===t.agent&&e.learnings===t.learnings&&e.thinking===t.thinking&&Art(e.files,t.files)},Dc=e=>e.timestamp instanceof Date?e.timestamp.getTime():new Date(e.timestamp).getTime(),kre=e=>{for(let t=1;t<e.length;t+=1)if(Dc(e[t-1])>Dc(e[t]))return!1;return!0},uq=Ao((e,t)=>({messagesByConversation:{},paginationByConversation:{},lastUpdated:Date.now(),addMessages:(n,r,i=!1)=>{e(s=>{const a=s.messagesByConversation[n]||[],o=new Set(a.map(h=>h.id)),l=r.filter(h=>!o.has(h.id));if(l.length===0)return s;const c=kre(l)?l:[...l].sort((h,f)=>Dc(h)-Dc(f));let u=i?[...c,...a]:[...a,...c];return a.length===0||(i?Dc(c[c.length-1])<=Dc(a[0]):Dc(c[0])>=Dc(a[a.length-1]))||(u=[...u].sort((h,f)=>Dc(h)-Dc(f))),{messagesByConversation:{...s.messagesByConversation,[n]:u},lastUpdated:Date.now()}})},setMessages:(n,r)=>{e(i=>{const s=kre(r)?r:[...r].sort((o,l)=>Dc(o)-Dc(l)),a=i.messagesByConversation[n]||[];if(a.length===s.length){let o=!1;for(let l=0;l<a.length;l+=1)if(!$re(a[l],s[l])){o=!0;break}if(!o)return i}return{messagesByConversation:{...i.messagesByConversation,[n]:s},lastUpdated:Date.now()}})},addMessage:(n,r)=>{e(i=>{const s=i.messagesByConversation[n]||[];return s.some(a=>a.id===r.id)?i:{messagesByConversation:{...i.messagesByConversation,[n]:[...s,r]},lastUpdated:Date.now()}})},updateMessage:(n,r)=>{let i=!1;return e(s=>{const o=(s.messagesByConversation[n]||[]).map(l=>l.id===r.id?$re(l,r)?l:(i=!0,r):l);return i?{messagesByConversation:{...s.messagesByConversation,[n]:o},lastUpdated:Date.now()}:s}),i},clearConversation:n=>{e(r=>{const{[n]:i,...s}=r.messagesByConversation,{[n]:a,...o}=r.paginationByConversation;return{messagesByConversation:s,paginationByConversation:o,lastUpdated:Date.now()}})},getMessages:n=>t().messagesByConversation[n]||[],updatePagination:(n,r,i,s)=>{e(a=>{const o=a.paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1};return o.currentPage===r&&o.totalPages===i&&o.hasMore===s?a:{paginationByConversation:{...a.paginationByConversation,[n]:{...o,currentPage:r,totalPages:i,hasMore:s}},lastUpdated:Date.now()}})},getPagination:n=>t().paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1},updateScrollPosition:(n,r)=>{e(i=>{const s=i.paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1};return s.scrollPosition===r?i:{paginationByConversation:{...i.paginationByConversation,[n]:{...s,scrollPosition:r}}}})},getScrollPosition:n=>t().paginationByConversation[n]?.scrollPosition})),Xrt=Ao((e,t)=>({historyByConversation:{},setCurrentMessage:(n,r)=>{e(i=>{const s=i.historyByConversation[n]||{currentMessage:"",currentSequenceId:null};return{historyByConversation:{...i.historyByConversation,[n]:{...s,currentMessage:r}}}})},getCurrentMessage:n=>t().historyByConversation[n]?.currentMessage||"",setCurrentSequenceId:(n,r)=>{e(i=>{const s=i.historyByConversation[n]||{currentMessage:"",currentSequenceId:null};return{historyByConversation:{...i.historyByConversation,[n]:{...s,currentSequenceId:r}}}})},getCurrentSequenceId:n=>t().historyByConversation[n]?.currentSequenceId||null,resetHistory:n=>{e(r=>{const i=r.historyByConversation[n];return i?{historyByConversation:{...r.historyByConversation,[n]:{...i,currentSequenceId:null}}}:r})},clearConversationHistory:n=>{e(r=>{const{[n]:i,...s}=r.historyByConversation;return{historyByConversation:s}})}})),LTe=()=>{const e=Ki(),t=uq(r=>r.clearConversation),n=Xrt(r=>r.clearConversationHistory);return sl({mutationFn:async({agentId:r})=>Ei(Rr.baseUrl).agents.clearAgentConversation(r),onSuccess:(r,i)=>{e.invalidateQueries({queryKey:["agent",i.agentId,"conversation"]}),e.invalidateQueries({queryKey:["conversation-messages",i.agentId]}),t(i.agentId),n(i.agentId),Rs("Conversation cleared")},onError:r=>{console.error("Error clearing agent conversation:",r),or(`Failed to clear conversation: ${r instanceof Error?r.message:"Unknown error"}`)}})},Drt=(e,t)=>{const n=e.role==="user"||e.role==="human"?"user":"assistant";return{id:e.id,role:n,message:e.message,code:e.code,stdout:e.stdout,stderr:e.stderr,logging:e.logging,timestamp:e.timestamp?new Date(e.timestamp):new Date,files:e.files,action:e.action,execution_type:e.execution_type,task_classification:e.task_classification,is_complete:e.is_complete,is_streamable:e.is_streamable,conversation_id:t,content:e.content,file_path:e.file_path,replacements:e.replacements,agent:e.agent,learnings:e.learnings,thinking:e.thinking}},EQ=["credentials"],j_=()=>{const{shouldEnableQuery:e,getConnectivityError:t}=F_(),n=t();return w.useEffect(()=>{n&&console.error("Credentials connectivity error:",n.message)},[n]),rr({enabled:e({bypassInternetCheck:!0}),queryKey:EQ,queryFn:async()=>{const i=await Ei(Rr.baseUrl).credentials.listCredentials();if(i.status>=400)throw new Error(i.message||"Failed to fetch credentials");return i.result},refetchOnWindowFocus:!1,staleTime:5e3})},EB=()=>{const{data:e,isError:t,isPending:n,fetchStatus:r}=j_();return{hasRadientApiKey:!!e?.keys?.includes("RADIENT_API_KEY"),isUnavailable:t||n&&r==="idle"}},Irt=15*60*1e3,jTe=Ao()(yd((e,t)=>({providers:[],models:[],isLoading:!1,error:null,lastFetched:null,isInitialized:!1,fetchModels:async(n,r=!1)=>{const{lastFetched:i,isInitialized:s}=t(),a=Date.now();if(!(!r&&s&&i&&a-i<Irt)){e({isLoading:!0,error:null});try{const o=Ei(n),c=(await o.models.listProviders()).result?.providers||[],d=(await o.models.listModels("","recommended","descending")).result?.models||[];e({providers:c,models:d,isLoading:!1,lastFetched:a,isInitialized:!0})}catch(o){console.error("Failed to fetch models:",o),e({isLoading:!1,error:o instanceof Error?o.message:String(o)})}}},getModelsForProvider:n=>t().models.filter(r=>r.provider===n),reset:()=>{e({providers:[],models:[],isLoading:!1,error:null,lastFetched:null,isInitialized:!1})}}),{name:"local-operator-models",partialize:e=>({providers:e.providers,models:e.models,lastFetched:e.lastFetched,isInitialized:e.isInitialized})})),qA=({autoFetch:e=!0}={})=>{const t=Rr.baseUrl,n=w.useRef(null),{shouldEnableQuery:r,getConnectivityError:i,hasConnectivityIssue:s}=F_(),{providers:a,models:o,isLoading:l,error:c,lastFetched:u,isInitialized:d,fetchModels:h,getModelsForProvider:f}=jTe(),O=w.useRef(!0),g=w.useRef(!1),m=w.useRef(null);w.useEffect(()=>(n.current&&(clearInterval(n.current),n.current=null),m.current&&(clearTimeout(m.current),m.current=null),e&&r({bypassInternetCheck:!0})?(O.current?(O.current=!1,m.current=window.setTimeout(()=>{!g.current&&r({bypassInternetCheck:!0})&&(h(t),g.current=!0),m.current=null},1e3)):g.current||(h(t),g.current=!0),n.current=window.setInterval(()=>{r({bypassInternetCheck:!0})&&h(t)},15*60*1e3),()=>{n.current&&(clearInterval(n.current),n.current=null),m.current&&(clearTimeout(m.current),m.current=null)}):()=>{m.current&&(clearTimeout(m.current),m.current=null)}),[e,t,h,r]),w.useEffect(()=>{!s&&e&&d&&h(t)},[s,e,d,t,h]);const v=w.useCallback(async()=>{if(r({bypassInternetCheck:!0}))await h(t,!0);else{const b=i();if(b)throw b}},[t,h,r,i]);return{providers:a,models:o,isLoading:l,error:c,lastFetched:u,isInitialized:d,getModelsForProvider:f,getModelById:b=>o.find(T=>T.id===b),refreshModels:v}},Nrt=()=>{const{isLoading:e,error:t,refreshModels:n}=qA({autoFetch:!1}),r=w.useRef(!1);return w.useEffect(()=>{r.current||(r.current=!0)},[]),{isLoading:e,error:t,refreshModels:n}},$a=Ao()(yd((e,t)=>({inputByConversation:{},addReply:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=Array.isArray(i.replies)?i.replies:[];e({inputByConversation:{...t().inputByConversation,[n]:{...i,replies:[...s,r]}}})},removeReply:(n,r)=>{const i=t().inputByConversation[n];i&&e({inputByConversation:{...t().inputByConversation,[n]:{...i,replies:i.replies.filter(s=>s.id!==r)}}})},clearReplies:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,replies:[]}}})},addAttachment:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=Array.isArray(i.attachments)?i.attachments:[];e({inputByConversation:{...t().inputByConversation,[n]:{...i,attachments:[...s,r]}}})},removeAttachment:(n,r)=>{const i=t().inputByConversation[n];i&&e({inputByConversation:{...t().inputByConversation,[n]:{...i,attachments:i.attachments.filter(s=>s.id!==r)}}})},clearAttachments:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,attachments:[]}}})},setCurrentInput:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]};e({inputByConversation:{...t().inputByConversation,[n]:{...i,currentInput:r}}})},getCurrentInput:n=>t().inputByConversation[n]?.currentInput||"",addSubmittedMessage:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=i.submittedMessages[i.submittedMessages.length-1],a=r&&r!==s?[...i.submittedMessages.slice(-19),r]:i.submittedMessages;e({inputByConversation:{...t().inputByConversation,[n]:{...i,submittedMessages:a}}})},getSubmittedMessages:n=>t().inputByConversation[n]?.submittedMessages||[],clearSubmittedMessages:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,submittedMessages:[]}}})},getCurrentHistoryIndex:n=>t().inputByConversation[n]?.currentHistoryIndex??null,setCurrentHistoryIndex:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=i.submittedMessages;let a=null;typeof r=="number"&&s.length>0&&(a=Math.max(0,Math.min(r,s.length-1))),e({inputByConversation:{...t().inputByConversation,[n]:{...i,currentHistoryIndex:a}}})},resetCurrentHistoryIndex:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,currentHistoryIndex:null}}})},clearAll:n=>{const{[n]:r,...i}=t().inputByConversation;e({inputByConversation:i})}}),{name:"conversation-input-store",partialize:e=>({inputByConversation:e.inputByConversation})})),RB="held",Frt=(e,t)=>e===t?"":e,Mrt=(e,t)=>e===""?t:e,Lrt=({conversationId:e,onSubmit:t,scrollToBottom:n})=>{const r=$a(E=>E.getCurrentInput),i=$a(E=>E.setCurrentInput),s=$a(E=>E.addSubmittedMessage),a=$a(E=>E.getSubmittedMessages),o=$a(E=>E.getCurrentHistoryIndex),l=$a(E=>E.setCurrentHistoryIndex),c=$a(E=>E.resetCurrentHistoryIndex),[u,d]=w.useState($a.persist.hasHydrated?.()??!1),h=w.useRef(void 0),[f,O]=w.useState("");w.useEffect(()=>{const E=$a.persist;let A,L;return E&&typeof E.onHydrate=="function"&&typeof E.onFinishHydration=="function"?(A=E.onHydrate(()=>d(!1)),L=E.onFinishHydration(()=>d(!0)),d(E.hasHydrated())):d(!0),()=>{A?.(),L?.()}},[]);const g=w.useRef(null),m=w.useRef(""),v=$a(E=>e?E.inputByConversation[e]?.currentInput??"":""),y=w.useRef(""),b=e?a(e):[],T=e?o(e):null;w.useEffect(()=>{if(u)if(e){const E=r(e);T!==null&&b.length>0?O(b[T]||""):O(E),h.current=e,m.current=""}else O(""),h.current=void 0,m.current=""},[e,u,r,T,b]),w.useEffect(()=>{u&&e&&h.current!==e&&i(e,f)},[e,f,i,u]),w.useEffect(()=>{!u||!e||v!==y.current&&(y.current=v,v&&!f&&O(v))},[v,u,e,f]);const x=w.useCallback(E=>{O(E),e&&(y.current=E,i(e,E),c(e))},[e,i,c]),S=w.useRef(!1),k=w.useCallback(async()=>{if(!f.trim()||!e||S.current)return;S.current=!0;const E=f;let A=!1;const L=()=>{A||(A=!0,h.current===e&&O(q=>Frt(q,E)))},j=()=>{y.current="",i(e,""),c(e),m.current=""};try{const q=await t?.(E,L);if(q===!1){h.current===e&&O(z=>Mrt(z,E));return}if(q===RB){j();return}}finally{S.current=!1}L(),s(e,E),j(),n&&requestAnimationFrame(()=>{n()})},[f,e,t,s,i,c,n]),_=w.useCallback(()=>{const E=g.current;if(!E)return{line:0,totalLines:1};const A=E.value,L=E.selectionStart,q=(A.substring(0,L).match(/\n/g)||[]).length+1,z=(A.match(/\n/g)||[]).length+1;return{line:q,totalLines:z}},[]),P=w.useCallback(()=>_().line===1,[_]),C=w.useCallback(()=>{const{line:E,totalLines:A}=_();return E===A},[_]),Q=w.useCallback(E=>{if(e){if(E.key==="Enter"&&!E.shiftKey){E.preventDefault(),k();return}if(b.length){if(E.key==="ArrowUp"&&P()){if(E.preventDefault(),T===null)m.current=f,l(e,b.length-1),O(b[b.length-1]||"");else if(T>0){const A=T-1;l(e,A),O(b[A]||"")}setTimeout(()=>{if(g.current){const A=g.current.value.length;g.current.selectionStart=A,g.current.selectionEnd=A}},0)}if(E.key==="ArrowDown"&&C()&&(E.preventDefault(),T!==null)){if(T<b.length-1){const A=T+1;l(e,A),O(b[A]||"")}else c(e),O(m.current),m.current="";setTimeout(()=>{if(g.current){const A=g.current.value.length;g.current.selectionStart=A,g.current.selectionEnd=A}},0)}}}},[k,P,C,T,f,b,e,l,c]);return{inputValue:f,setInputValue:x,handleKeyDown:Q,handleSubmit:k,textareaRef:g}},jrt={name:"User",email:"user@example.com"},AB=Ao()(yd(e=>({profile:jrt,isSigningOut:!1,updateName:t=>{e(n=>({profile:{...n.profile,name:t}}))},updateEmail:t=>{e(n=>({profile:{...n.profile,email:t}}))},updateProfile:t=>{e(n=>({profile:{...n.profile,...t}}))},setIsSigningOut:t=>{e({isSigningOut:t})},clearProfile:()=>{e({profile:{name:"",email:""}})}}),{name:"user-profile-storage"}));function qrt(e){return{operation:e.operation,...e.tenantId?{tenant_id:e.tenantId}:{},...e.accountId?{account_id:e.accountId}:{},...e.agentId?{agent_id:e.agentId}:{},...e.commentId?{comment_id:e.commentId}:{},...e.query?{query:e.query}:{},...e.payload?{payload:e.payload}:{},...e.requestId?{request_id:e.requestId}:{},...e.confirmed?{confirmed:!0}:{}}}async function to(e){return(await an({op:"radient.request",control:qrt(e)})).data}async function XB(e){const t=await to(e);return t&&typeof t=="object"&&"result"in t?t.result:t}const RQ={all:["radient-user"],user:()=>[...RQ.all,"user"]};function Tre(e){return e instanceof Error&&/sign in to radient/i.test(e.message)}const zrt=()=>{const e=Ki(),{setIsSigningOut:t}=AB(),n=Dl(),r=Ks(n.data,"radient"),i=rr({queryKey:RQ.user(),queryFn:async()=>{try{return await XB({operation:"account"})}catch(c){if(Tre(c))return null;throw c}},enabled:r,staleTime:30*1e3,refetchOnWindowFocus:!0,retry:(c,u)=>!Tre(u)&&c<2}),s=!!i.data&&!i.isLoading,a=s,o=sl({onMutate:()=>{t(!0)},mutationFn:async()=>{const u=(await an({op:"accounts.list"})).accounts.filter(d=>d.provider==="radient");for(const d of u)await an({op:"accounts.remove",accountId:d.id,confirmed:!0});return!0},onSuccess:()=>{e.removeQueries({queryKey:RQ.all}),e.invalidateQueries({queryKey:id.accounts}),Rs("Successfully signed out"),t(!1)},onError:c=>{const u=c instanceof Error?c.message:String(c);or(`Failed to sign out: ${u}`),t(!1)}}),l=sl({mutationFn:async()=>(e.invalidateQueries({queryKey:RQ.all}),!0)});return{user:i.data??void 0,isLoading:i.isLoading,isRefetching:i.isRefetching,error:i.error,hasLocalSession:a,isAuthenticated:s,unavailable:n.isSuccess&&!r,signOut:o.mutate,refreshUser:l.mutate,userQuery:i}},DB=()=>{const e=AB(),{user:t,isLoading:n,error:r,isAuthenticated:i,hasLocalSession:s,unavailable:a,signOut:o,refreshUser:l}=zrt();let c;return n?c=s?"restoring":"loading":i?c="authenticated":c="unauthenticated",w.useEffect(()=>{if(!i||!t?.account)return;const{account:u}=t;if(!u.name&&!u.email)return;const{name:d,email:h}=e.profile;(u.name&&u.name!==d||u.email&&u.email!==h)&&e.updateProfile({name:u.name||d,email:u.email||h})},[i,t,e]),{authStatus:c,isAuthenticated:i,hasLocalSession:s,isLoading:n,error:r,user:i&&t?.account?{name:t.account.name,email:t.account.email,radientUser:t}:null,unavailable:a,refreshUser:l,signOut:o,updateProfile:e.updateProfile,updateName:e.updateName,updateEmail:e.updateEmail}},Xk=e=>e.replace(/\\/g,"/"),qTe=()=>window.location.hash?Xk(window.location.hash.substring(1)):Xk(window.location.pathname),Xy=(e,t)=>Xk(e).includes(t),Urt=()=>{const{agentId:e}=Tke(),t=Xa(),n=()=>{const s=qTe();return Xy(s,"/chat")?"chat":"agents"};return{agentId:e,navigateToAgent:(s,a)=>{if(!s)return;const o=a||n();t(`/${o}/${s}`)},clearAgentId:s=>{const a=s||n();t(`/${a}`)}}},Wrt=()=>{const e=qTe();return Xy(e,"/chat")?"chat":Xy(e,"/agents")?"agents":Xy(e,"/settings")?"settings":Xy(e,"/agent-hub")?"agent-hub":Xy(e,"/schedules")?"schedules":"chat"},Grt=(e=50,t,n)=>{const r=w.useRef(null),i=t||r,[s,a]=w.useState(!1),o=w.useRef(!1),l=w.useRef(0),c=w.useRef(n),u=w.useCallback(()=>{const f=i.current;if(!f)return;const{scrollTop:O,scrollHeight:g,clientHeight:m}=f,v=Math.abs(O),b=g>m&&v>e;a(b)},[e,i]),d=w.useCallback(()=>{const f=i.current;f&&requestAnimationFrame(()=>{f.scrollTo({top:0,behavior:"smooth"}),requestAnimationFrame(u)})},[i,u]),h=w.useCallback(()=>{!i.current||o.current||(o.current=!0,requestAnimationFrame(()=>{u(),o.current=!1}))},[i,u]);return w.useEffect(()=>{const f=i.current;if(!f)return;c.current!==n&&(a(!1),l.current=0,c.current=n),f.addEventListener("scroll",h,{passive:!0});const O=requestAnimationFrame(u),g=window.setTimeout(u,100),m=window.setTimeout(u,500);return()=>{f.removeEventListener("scroll",h),cancelAnimationFrame(O),clearTimeout(g),clearTimeout(m)}},[i,n,h,u]),w.useEffect(()=>{const f=()=>{u()};return window.addEventListener("resize",f,{passive:!0}),()=>{window.removeEventListener("resize",f)}},[u]),w.useEffect(()=>{const f=i.current;if(!f)return;const O=new ResizeObserver(()=>{u()});return O.observe(f),()=>{O.disconnect()}},[i,u]),{containerRef:i,isFarFromBottom:s,scrollToBottom:d}},Vrt=15*60*1e3,_re=250,Pre=(e,t)=>e?e.is_complete!==t.is_complete||e.is_streamable!==t.is_streamable||e.message!==t.message||e.code!==t.code||e.stdout!==t.stdout||e.stderr!==t.stderr||e.logging!==t.logging||e.content!==t.content||e.replacements!==t.replacements||e.action!==t.action||e.execution_type!==t.execution_type:!0,aD=(e,t)=>{const r=Object.entries(e).filter(([s,a])=>!a.isComplete||t-a.lastUpdated<Vrt);if(r.length<=_re)return Object.fromEntries(r);const i=[...r].sort((s,a)=>a[1].lastUpdated-s[1].lastUpdated);return Object.fromEntries(i.slice(0,_re))},kp=Ao(e=>({streamingMessages:{},updateStreamingMessage:(t,n)=>{e(r=>{const i=Date.now(),s=r.streamingMessages[t]||{content:null,isComplete:!1,lastUpdated:i};if(!s.isComplete&&!Pre(s.content,n))return r;const a={...r.streamingMessages,[t]:{...s,content:n,lastUpdated:i}};return{streamingMessages:aD(a,i)}})},completeStreamingMessage:(t,n)=>{e(r=>{const i=Date.now(),s=r.streamingMessages[t];if(s?.isComplete&&!Pre(s.content,n))return r;const a={...r.streamingMessages,[t]:{content:n,isComplete:!0,lastUpdated:i}};return{streamingMessages:aD(a,i)}})},pruneStreamingMessages:()=>{e(t=>{const n=Date.now(),r=aD(t.streamingMessages,n);return Object.keys(r).length===Object.keys(t.streamingMessages).length?t:{streamingMessages:r}})}})),Brt=/\/+$/,Ma={Open:"stream.open",Gap:"stream.gap",Terminal:"stream.terminal",Error:"error",RecordUpdate:"record.update",RecordComplete:"record.complete",MessageDelta:"message.delta",ToolStart:"tool.start",ToolDelta:"tool.delta",ToolEnd:"tool.end",TurnStart:"turn.start",TurnEnd:"turn.end",AgentStart:"agent.start",AgentEnd:"agent.end",Notice:"notice",JobStatus:"job.status",Keepalive:"keepalive"},Yrt={autoReconnect:!0,maxReconnectAttempts:5,stallTimeout:45e3,openTimeout:8e3};class Zrt extends gB{source=null;baseUrl;channelId;channelKind;options;status="disconnected";failedOpens=0;lastSeq=null;stallTimerId=null;closedByServer=!1;opened=!1;openTimerId=null;constructor(t,n,r={},i="message"){super(),this.baseUrl=t.replace(Brt,""),this.channelId=n,this.channelKind=i,this.options={...Yrt,...r}}getStatus(){return this.status}getLastSequence(){return this.lastSeq}url(){const t=this.channelKind==="job"?`/v1/sse/jobs/${encodeURIComponent(this.channelId)}`:`/v1/sse/messages/${encodeURIComponent(this.channelId)}`,n=this.lastSeq!==null?`?after_seq=${this.lastSeq}`:"";return`${this.baseUrl}${t}${n}`}setStatus(t){this.status!==t&&(this.status=t,this.emit("status",t))}armStallTimer(){this.clearStallTimer(),this.stallTimerId=window.setTimeout(()=>{this.emit("error",new Error(`SSE stream stalled: no traffic for ${this.options.stallTimeout}ms`)),this.setStatus("error"),this.emit("stalled")},this.options.stallTimeout)}clearStallTimer(){this.stallTimerId!==null&&(window.clearTimeout(this.stallTimerId),this.stallTimerId=null)}clearOpenTimer(){this.openTimerId!==null&&(window.clearTimeout(this.openTimerId),this.openTimerId=null)}async connect(){if(!this.source)return this.closedByServer=!1,this.opened=!1,this.setStatus("connecting"),new Promise(t=>{let n=!1;const r=()=>{n||(n=!0,t())},i=new EventSource(this.url());this.source=i,this.openTimerId=window.setTimeout(()=>{this.opened||(this.teardown(),this.setStatus("error"),this.emit("error",new Error(`SSE open timed out after ${this.options.openTimeout}ms`)),r())},this.options.openTimeout),i.onopen=()=>{this.opened=!0,this.clearOpenTimer(),this.failedOpens=0,this.setStatus("connected"),this.armStallTimer(),r()},i.onerror=()=>{if(this.clearStallTimer(),this.closedByServer){this.teardown(),this.setStatus("disconnected"),r();return}if(i.readyState===EventSource.CONNECTING){if(this.failedOpens+=1,!this.options.autoReconnect||this.failedOpens>this.options.maxReconnectAttempts){this.teardown(),this.setStatus("failed"),this.emit("error",new Error(`SSE reconnect gave up after ${this.failedOpens} attempts`)),r();return}this.setStatus("reconnecting"),r();return}this.teardown(),this.setStatus("error"),this.emit("error",new Error("SSE connection closed unexpectedly")),r()},i.addEventListener(Ma.Open,a=>{this.armStallTimer();const o=this.parse(a);if(o){this.lastSeq=o.last_seq>0?o.last_seq:this.lastSeq,this.emit("open",o);for(const l of o.snapshot??[])this.emitRecord(l);r()}});const s=a=>{this.armStallTimer();const o=this.parse(a);o?.record&&(this.noteSeq(a),this.emitRecord(o.record))};i.addEventListener(Ma.RecordUpdate,s),i.addEventListener(Ma.RecordComplete,s),i.addEventListener(Ma.Terminal,a=>{this.noteSeq(a),this.closedByServer=!0,this.clearStallTimer(),this.emit("terminal",this.parse(a)),this.teardown(),this.setStatus("disconnected"),r()}),i.addEventListener(Ma.Gap,a=>{const o=this.parse(a);this.emit("gap",o)}),i.addEventListener(Ma.Error,a=>{const o=this.parse(a);this.emit("error",new Error(o?.error??"SSE stream reported an error"))});for(const a of[Ma.MessageDelta,Ma.ToolStart,Ma.ToolDelta,Ma.ToolEnd,Ma.TurnStart,Ma.TurnEnd,Ma.AgentStart,Ma.AgentEnd,Ma.Notice,Ma.JobStatus])i.addEventListener(a,o=>{this.armStallTimer(),this.noteSeq(o),this.emit(a,this.parse(o))});i.addEventListener(Ma.Keepalive,()=>{this.armStallTimer()})})}emitRecord(t){const n=t.message_id??t.id;this.emit(`update:${n}`,t),n!==this.channelId&&this.emit(`update:${this.channelId}`,t)}noteSeq(t){const n=t.lastEventId;if(!n)return;const r=Number.parseInt(n,10);Number.isFinite(r)&&(this.lastSeq=r)}parse(t){const n=t.data;if(typeof n!="string")return null;try{return JSON.parse(n)}catch{return console.error("[sse] frame was not valid JSON"),null}}teardown(){this.clearStallTimer(),this.clearOpenTimer(),this.source&&(this.source.close(),this.source=null)}disconnect(){this.teardown(),this.setStatus("disconnected")}}const zTe=/\/+$/,dq=new Map,hq=new Map,Hrt=2500,Krt=e=>{const t=e.replace(zTe,""),n=dq.get(t);if(n)return n;const r=(async()=>{const i=new AbortController,s=window.setTimeout(()=>i.abort(),Hrt);try{const a=await fetch(`${t}/v1/sse/capabilities`,{signal:i.signal});if(!a.ok)return{capabilities:null,sseProvenBroken:!1};const o=await a.json();return{capabilities:o?.transports?.includes("sse")??!1?o:null,sseProvenBroken:!1}}catch{return{capabilities:null,sseProvenBroken:!1}}finally{window.clearTimeout(s)}})();return dq.set(t,r),r.then(i=>hq.set(t,i)).catch(()=>{}),r};class Jrt extends gB{baseUrl;channelId;options;active=null;kind=null;disposed=!1;delivered=!1;connecting=!1;constructor(t,n,r={}){super(),this.baseUrl=t.replace(zTe,""),this.channelId=n,this.options=r}getTransport(){return this.kind}getStatus(){return this.active?.getStatus()??"disconnected"}async connect(){if(!(this.disposed||this.active||this.connecting)){this.connecting=!0;try{const t=this.options.force;let n=t==="sse";if(!t){const r=await Krt(this.baseUrl);if(this.disposed)return;n=r.capabilities!==null&&!r.sseProvenBroken}if(this.disposed)return;if(n){await this.startSse();return}await this.startWebSocket()}finally{this.connecting=!1}}}async startSse(){const t=new Zrt(this.baseUrl,this.channelId,this.options.sse,this.options.channelKind??"message");this.active=t,this.kind="sse",this.bind(t),t.on("stalled",()=>{this.delivered||this.fallback("stream stalled before any frame")}),t.on("status",n=>{(n==="failed"||n==="error")&&!this.delivered&&this.fallback(`sse status became ${String(n)}`)}),await t.connect()}async startWebSocket(){const t=new MJe(this.baseUrl,this.channelId,this.options.websocket,nTe.MESSAGE);this.active=t,this.kind="websocket",this.bind(t),await t.connect()}bind(t){const n=["status","error",`update:${this.channelId}`,"open","terminal","gap","message.delta","tool.start","tool.delta","tool.end","turn.start","turn.end","agent.start","agent.end","notice","job.status"];for(const r of n)t.on(r,(...i)=>{r===`update:${this.channelId}`&&(this.delivered=!0),this.emit(r,...i)})}async fallback(t){if(this.disposed||this.kind!=="sse")return;const n=this.baseUrl,r=hq.get(n);r?r.sseProvenBroken=!0:(hq.set(n,{capabilities:null,sseProvenBroken:!0}),dq.set(n,Promise.resolve({capabilities:null,sseProvenBroken:!0}))),console.warn(`[streaming] falling back to websocket: ${t}`),this.active&&(this.active.removeAllListeners(),this.active.disconnect(),this.active=null),this.kind=null;try{await this.startWebSocket()}catch(i){console.error("[streaming] websocket fallback failed:",i)}}disconnect(){this.disposed=!0,this.active&&(this.active.removeAllListeners(),this.active.disconnect(),this.active=null)}}const eit=["id","message","code","stdout","stderr","logging","content","replacements","thinking","learnings","formatted_print","file_path","agent","action","execution_type","task_classification","role","status","is_complete","is_streamable"],tit=(e,t)=>{if(!e)return!0;for(const i of eit)if(e[i]!==t[i])return!0;const n=e.files,r=t.files;return n===r?!1:!n||!r||n.length!==r.length?!0:n.some((i,s)=>i!==r[s])},nit=e=>{const{baseUrl:t,messageId:n,autoReconnect:r=!0,reconnectInterval:i=2e3,maxReconnectAttempts:s=5,pingInterval:a=3e4,onUpdate:o,onStatusChange:l,onError:c}=e,[u,d]=w.useState(null),[h,f]=w.useState(!1),[O,g]=w.useState(!1),[m,v]=w.useState("disconnected"),[y,b]=w.useState(null),[T,x]=w.useState(!1),S=w.useRef(null),k=w.useRef(null),_=w.useRef(null),P=w.useRef(null),C=w.useRef({onUpdate:o,onStatusChange:l,onError:c});w.useEffect(()=>{C.current={onUpdate:o,onStatusChange:l,onError:c}},[o,l,c]);const Q=w.useCallback(()=>{P.current=null;const q=k.current;q&&(k.current=null,!(!q.is_complete&&!tit(_.current,q))&&(_.current=q,d(q),C.current.onUpdate?.(q)))},[]),E=w.useCallback(()=>{P.current!==null&&(cancelAnimationFrame(P.current),P.current=null),k.current=null,S.current&&(S.current.removeAllListeners(),S.current.disconnect(),S.current=null)},[]),A=w.useCallback(()=>{if(S.current)return S.current;const q=new Jrt(t,n,{websocket:{autoReconnect:r,reconnectInterval:i,maxReconnectAttempts:s,pingInterval:a,messageDelay:250},sse:{autoReconnect:r,maxReconnectAttempts:s}});return q.on("status",z=>{const V=z;v(V),V==="connected"&&b(null),C.current.onStatusChange?.(V)}),q.on(`update:${n}`,z=>{const V=z;if(k.current={...k.current??_.current,...V},typeof V.is_complete=="boolean"&&f(V.is_complete),typeof V.is_streamable=="boolean"&&g(V.is_streamable),V.is_complete){P.current!==null&&cancelAnimationFrame(P.current),Q();return}P.current===null&&(P.current=requestAnimationFrame(Q))}),q.on("error",z=>{const V=z instanceof Error?z:new Error(typeof z=="string"?z:`WebSocket error for ${n}`);b(V),C.current.onError?.(V)}),S.current=q,q},[t,n,r,i,s,a,Q]),L=w.useCallback(async()=>{if(!n||!t)throw new Error("Missing messageId or baseUrl");b(null),x(!0);const q=A(),z=q.getStatus();if(z==="connected"||z==="connecting"||z==="reconnecting"){x(!1);return}try{await q.connect()}catch(V){const W=V instanceof Error?V:new Error(String(V));throw b(W),C.current.onError?.(W),W}finally{x(!1)}},[n,t,A]),j=w.useCallback(()=>{E(),v("disconnected"),x(!1)},[E]);return w.useEffect(()=>()=>{j()},[n,j]),w.useEffect(()=>{x(m==="connecting"||m==="reconnecting")},[m]),{message:u,isComplete:h,isStreamable:O,status:m,connect:L,disconnect:j,isLoading:T,error:y}},rit=1500,iit=80,sit=180,Fu=new Map,dx=(e,t)=>{const n=Fu.get(e);if(n)return t&&(n.conversationId=t),n;const r={connected:!1,connecting:!1,connectionPromise:null,instanceCount:0,messageData:null,isComplete:!1,isStreamable:!1,conversationId:t,disconnect:null};return Fu.set(e,r),r},ait=({messageId:e,autoConnect:t=!0,onComplete:n,onUpdate:r,baseUrl:i=Rr.baseUrl,conversationId:s,refetchOnComplete:a=!0})=>{const o=w.useRef(!1),l=w.useRef(!1),c=w.useRef(0),u=w.useRef(null),d=w.useRef(!1),h=w.useRef(null),f=w.useRef(null),O=w.useRef(null),[g,m]=w.useState(!1),v=kp(N=>N.updateStreamingMessage),y=kp(N=>N.completeStreamingMessage),b=kp(N=>N.pruneStreamingMessages),T=kp(N=>N.streamingMessages[e]?.isComplete??!1),x=uq(N=>N.addMessage),S=uq(N=>N.updateMessage),k=w.useCallback(N=>{if(!s||!N.id)return;const D=Drt(N,s);S(s,D)||x(s,D)},[s,S,x]),_=w.useCallback(()=>{O.current&&(k(O.current),O.current=null)},[k]),P=w.useCallback(N=>{!n||!o.current||u.current!==e&&(u.current=e,n(N))},[n,e]),C=w.useCallback(async()=>{if(e)try{m(!0);const N=Ei(i),D=Fu.get(e),B=D?.conversationId||s;if(!B)return;const G=await N.agents.getAgentExecutionHistory(B,1,30);if(G.status>=400||!G.result)throw new Error(G.message||"Failed to fetch message data");const ee=G.result.history.find(he=>he.id===e);if(ee){y(e,ee);const he=dx(e,s);he.messageData=ee,he.isComplete=!0,he.isStreamable=!!ee.is_streamable,k(ee),P(ee);return}D?.messageData&&D.isComplete&&(y(e,D.messageData),k(D.messageData),P(D.messageData))}catch(N){const D=N instanceof Error?N.message:String(N);console.error(`Error refetching message: ${D}`)}finally{m(!1)}},[e,i,s,y,k,P]),Q=w.useCallback(()=>{!a||h.current||(h.current=setTimeout(()=>{h.current=null,o.current&&C()},sit))},[a,C]),{message:E,isComplete:A,isStreamable:L,status:j,isLoading:q,error:z,connect:V,disconnect:W}=nit({baseUrl:i,messageId:e,onUpdate:N=>{r&&o.current&&r(N);const D=dx(e,s),B={...D.messageData,...N};if(D.messageData=B,D.isStreamable=!!(N.is_streamable||D.isStreamable),N.is_complete){D.isComplete=!0,y(e,B),O.current=B,_(),P(B),Q();return}v(e,B),s&&B.id&&(O.current=B,f.current||(f.current=setTimeout(()=>{f.current=null,_()},iit)))}}),M=w.useCallback(async()=>{if(A||T)return;const N=Date.now();if(N-c.current<rit)return;c.current=N;const D=dx(e,s);if(!D.connected){if(D.connectionPromise){try{await D.connectionPromise}catch{}return}D.connecting=!0,D.connectionPromise=V().then(()=>{const B=Fu.get(e);B&&(B.connected=!0,B.connecting=!1)}).catch(B=>{const G=Fu.get(e);throw G&&(G.connected=!1,G.connecting=!1),B}).finally(()=>{const B=Fu.get(e);B&&(B.connectionPromise=null)});try{await D.connectionPromise}catch(B){console.error("WebSocket connection failed:",B)}}},[A,T,e,s,V]),K=w.useCallback(()=>{const N=Fu.get(e);N&&(N.connected=!1,N.connecting=!1,N.connectionPromise=null,N.disconnect=null,N.instanceCount<=1&&Fu.delete(e)),W()},[e,W]);return w.useEffect(()=>{if(o.current=!0,d.current=!1,u.current=null,!T){const D=dx(e,s);D.disconnect=W,l.current||(D.instanceCount+=1,l.current=!0)}let N=null;return t&&!A&&!T&&(N=setTimeout(()=>{o.current&&M()},120)),()=>{if(o.current=!1,N&&clearTimeout(N),h.current&&(clearTimeout(h.current),h.current=null),f.current&&(clearTimeout(f.current),f.current=null),_(),b(),l.current){const D=Fu.get(e);D&&(D.instanceCount=Math.max(0,D.instanceCount-1),D.instanceCount===0&&(D.connected=!1,D.connecting=!1,D.connectionPromise=null,D.disconnect=null,Fu.delete(e),W())),l.current=!1}}},[t,A,T,M,e,s,_,b,W]),w.useEffect(()=>{const N=Fu.get(e);N&&(N.connected=j==="connected",N.connecting=j==="connecting"||j==="reconnecting",N.connecting||(N.connectionPromise=null))},[e,j]),w.useEffect(()=>{if(j!=="disconnected"||A||T||!o.current)return;const N=setTimeout(()=>{o.current&&M()},1600);return()=>clearTimeout(N)},[j,A,T,M]),w.useEffect(()=>{if(!A||!E){d.current=!1;return}if(d.current)return;d.current=!0;const N=dx(e,s);N.isComplete=!0,N.messageData=E,N.isStreamable=!!E.is_streamable,y(e,E),O.current=E,_(),P(E),Q(),K()},[A,E,e,s,y,_,P,Q,K]),{message:E,isComplete:A,isStreamable:L,status:j,isLoading:q,isRefetching:g,error:z,connect:M,disconnect:K,refetch:C}},oit=()=>{const e=Ki(),t=Ei(Rr.baseUrl);return sl({mutationFn:async({agentId:n,update:r})=>{try{const i=await t.agents.updateAgent(n,r);if(i.status>=400)throw new Error(i.message||`Failed to update agent ${n}`);return i.result}catch(i){const s=i instanceof Error?i.message:`An unknown error occurred while updating agent ${n}`;throw or(s),i}},onSuccess:async(n,{agentId:r})=>{await e.invalidateQueries({queryKey:vh,refetchType:"none"}),e.setQueryData([...vh,r],i=>i&&{...i,...n}),await e.refetchQueries({queryKey:vh,type:"all"}),Rs("Agent updated")},onError:n=>{console.error("Error updating agent:",n)}})},lit=()=>{const e=Ki(),t=Ei(Rr.baseUrl);return sl({mutationFn:async n=>{try{const r=await t.config.updateConfig(n);if(r.status>=400)throw new Error(r.message||"Failed to update configuration");return r.result}catch(r){const i=r instanceof Error?r.message:"An unknown error occurred while updating configuration";throw or(i),r}},onSuccess:async n=>{await e.invalidateQueries({queryKey:_Q,refetchType:"none"}),e.setQueryData(_Q,r=>r&&{...r,...n}),await e.refetchQueries({queryKey:_Q,type:"all"}),Rs("Configuration updated")},onError:n=>{console.error("Error updating configuration:",n)}})},cit=()=>{const e=Ki(),t=Ei(Rr.baseUrl);return sl({mutationFn:async n=>{try{const r=await t.credentials.updateCredential(n);if(r.status>=400)throw new Error(r.message||"Failed to update credential");return r}catch(r){const i=r instanceof Error?r.message:"An unknown error occurred while updating credential";throw or(i),r}},onSuccess:async(n,r)=>{await e.invalidateQueries({queryKey:EQ,refetchType:"none"}),e.setQueryData(EQ,i=>i&&(i.keys.includes(r.key)?i:{...i,keys:[...i.keys,r.key]})),await e.refetchQueries({queryKey:EQ,type:"all"}),Rs(`Credential "${r.key}" updated successfully`)},onError:n=>{console.error("Error updating credential:",n)}})},UTe=({open:e,onClose:t,onAgentCreated:n})=>{const r=Xa(),[i,s]=w.useState(""),[a,o]=w.useState(""),l=w.useRef(null),c=()=>{t(),setTimeout(()=>{r("/agent-hub")},200)},u=Ltt(),d=async m=>{if(m.preventDefault(),!i.trim())return;const v={name:i.trim(),description:a.trim()||void 0};try{const y=await u.mutateAsync(v);s(""),o(""),n&&y?.id&&n(y.id),t()}catch(y){console.error("Failed to create agent:",y)}},h=u.isPending,f=h||!i.trim(),O=p.jsxs(p.Fragment,{children:[p.jsx(mw,{size:19,className:"text-accent","aria-hidden":"true"}),"Create new agent"]}),g=p.jsxs(p.Fragment,{children:[p.jsx(bw,{onClick:t,disabled:h,"data-tour-tag":"create-agent-dialog-cancel-button",children:"Cancel"}),p.jsx(yw,{type:"submit",form:"create-agent-form",disabled:f,startIcon:h?p.jsx(br,{}):null,children:"Create agent"})]});return p.jsxs($g,{open:e,onClose:t,title:O,actions:g,maxWidth:"sm",dataTourTag:"create-agent-dialog",dialogProps:{onOpenAutoFocus:m=>{m.preventDefault(),l.current?.focus()}},children:[p.jsx("p",{className:"text-body-sm text-ink-muted",children:"Configure your new AI assistant with a name and optional description"}),p.jsxs(we,{variant:"link",onClick:c,className:"mt-1 mb-4 text-body-sm",children:["Browse Agent hub to fetch ready-made agents",p.jsx(_A,{"aria-hidden":"true"})]}),p.jsx("form",{id:"create-agent-form",onSubmit:d,children:p.jsxs("div",{className:"flex flex-col gap-5",children:[p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(os,{htmlFor:"create-agent-name",children:"Agent name"}),p.jsx(fi,{ref:l,id:"create-agent-name",inputSize:"lg",value:i,onChange:m=>s(m.target.value),required:!0,disabled:h,placeholder:"Enter a name for your agent"})]}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(os,{htmlFor:"create-agent-description",children:"Description (optional)"}),p.jsx(wg,{id:"create-agent-description",rows:2,value:a,onChange:m=>o(m.target.value),disabled:h,placeholder:"Describe what this agent does"})]})]})})]})},Cre=({value:e,label:t,onSave:n,multiline:r=!1,rows:i=4,placeholder:s="Enter value...",icon:a,isSaving:o=!1,readOnly:l=!1})=>{const[c,u]=w.useState(!1),[d,h]=w.useState(e),[f,O]=w.useState(e),[g,m]=w.useState(e),[v,y]=w.useState(!1),[b,T]=w.useState(!1),x=w.useRef(null),S=w.useRef(null),k=w.useId(),_=o||v;w.useEffect(()=>{c||(h(e),O(e)),m(e)},[e,c]),w.useEffect(()=>{if(c){const N=setTimeout(()=>{x.current&&(x.current.focus(),x.current.select())},0);return()=>clearTimeout(N)}},[c]);const P=()=>{l||u(!0)},C=N=>{h(N.target.value)},Q=()=>{h(g),u(!1)},E=async()=>{if(!(_||d===g)){y(!0);try{await n(d),m(d),O(d),u(!1)}catch(N){console.error("Failed to save editable field:",N)}finally{y(!1)}}},A=N=>{setTimeout(()=>{const D=N.relatedTarget;!(S.current?.contains(D)??!1)&&d===g&&u(!1)},0)},L=N=>{N.key==="Escape"?Q():N.key==="Enter"&&(!r||r&&(N.ctrlKey||N.metaKey))&&(N.preventDefault(),d!==g?E():u(!1))},j=N=>{N.preventDefault(),N.stopPropagation(),!(l||_||b)&&(T(!0),y(!0),h(""),O(""),n("").then(()=>{m(""),u(!1)}).catch(D=>{console.error("Failed to clear field:",D),h(g),O(g)}).finally(()=>{T(!1),y(!1)}))},q=N=>{l||(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),P())},z=d!==g,V=!l&&!_&&g!=="",W=V&&!z,M=_?"pr-20":W?"pr-28":z?"pr-18":"pr-10",K="opacity-0 transition-opacity duration-fast ease-out-quart group-hover:opacity-100 group-focus-within:opacity-100";return p.jsxs("div",{children:[(t||a)&&p.jsxs(os,{htmlFor:k,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[a,t]}),c?p.jsxs("div",{className:"relative",children:[r?p.jsx(wg,{id:k,ref:x,value:d,onChange:C,onBlur:A,onKeyDown:L,rows:i,placeholder:s,autoComplete:"off",className:I("min-h-9",M)}):p.jsx(fi,{id:k,ref:x,value:d,onChange:C,onBlur:A,onKeyDown:L,placeholder:s,autoComplete:"off",className:I("text-ellipsis",M)}),p.jsx("div",{ref:S,className:I("absolute right-1.5 z-10 flex items-center gap-1",r?"top-1.5":"top-1/2 -translate-y-1/2"),children:_?p.jsx("span",{className:"px-2 text-ink-dim text-meta",children:b?"Clearing...":"Saving..."}):p.jsxs(p.Fragment,{children:[z&&p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:E,title:"Save changes (Enter)","aria-label":`Save ${t}`,className:"text-success hover:bg-success-wash hover:text-success",children:p.jsx(bc,{})}),p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:Q,title:"Cancel (Escape)","aria-label":`Cancel editing ${t}`,className:"text-danger hover:bg-danger-wash hover:text-danger",children:p.jsx(Js,{})}),W&&p.jsxs(we,{variant:"danger",size:"sm",onClick:j,title:"Clear field","aria-label":`Clear ${t}`,children:[p.jsx(Ene,{}),"Clear"]})]})})]}):p.jsxs("div",{className:"group relative w-full",children:[p.jsx("button",{type:"button",onClick:P,"aria-label":`Current value: ${f||s}.${l?"":" Click to edit."}`,onKeyDown:q,disabled:l,className:I("flex w-full rounded-sm border border-control bg-surface px-3 text-left text-body-sm text-ink","transition-colors duration-fast ease-out-quart","disabled:cursor-default disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled",r?"min-h-8 items-start py-2":"h-8 items-center",!l&&"cursor-pointer hover:bg-elevated"),children:f?p.jsx("span",{className:I("min-w-0 flex-1 pr-8",r?"whitespace-pre-wrap break-words":"truncate"),children:f}):p.jsx("span",{className:"min-w-0 flex-1 truncate pr-8 text-ink-dim",children:s})}),!l&&p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:P,title:"Edit","aria-label":`Edit ${t}`,tabIndex:-1,className:I("absolute top-1/2 right-1.5 -translate-y-1/2",K),children:p.jsx(uB,{})}),V&&p.jsxs(we,{variant:"danger",size:"sm",onClick:j,title:"Clear field","aria-label":`Clear ${t}`,tabIndex:-1,className:I("absolute top-1/2 right-9 -translate-y-1/2",K),children:[p.jsx(Ene,{}),"Clear"]})]})]})},WTe=w.memo(()=>(Nrt(),null));WTe.displayName="ModelsInitializer";const uit=({size:e=24,className:t})=>p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,"aria-hidden":"true",children:[p.jsx("path",{d:"M12 2 20.7 7 20.7 17 12 22 3.3 17 3.3 7Z"}),p.jsx("path",{d:"M12 12V6.2"}),p.jsx("path",{d:"m12 12 5-2.9"}),p.jsx("path",{d:"m12 12 5 2.9"}),p.jsx("path",{d:"M12 12v5.8"}),p.jsx("path",{d:"m12 12-5 2.9"}),p.jsx("path",{d:"m12 12-5-2.9"})]}),Zv=({value:e,label:t,description:n,min:r,max:i,step:s=1,unit:a,onChange:o,icon:l,isSaving:c=!1})=>{const[u,d]=w.useState(e),[h,f]=w.useState(e.toString()),[O,g]=w.useState(!1),m=w.useId(),v=`${m}-label`,y=`${m}-description`,b=w.useRef(u);b.current=u,w.useEffect(()=>{O||(d(e),f(e.toString()))},[e,O]);const T=w.useCallback(async()=>{if(c)return;const A=Math.max(r,Math.min(i,b.current));if(d(A),f(A.toString()),A!==e)try{await o(A)}catch(L){console.error("Error updating setting via slider:",L),d(e),f(e.toString())}},[c,r,i,e,o]),x=A=>{const L=Number(A.target.value);d(L),f(L.toString())},S=()=>{const A=()=>{window.removeEventListener("pointerup",A),T()};window.addEventListener("pointerup",A)},k=A=>{(A.key.startsWith("Arrow")||A.key==="Home"||A.key==="End")&&T()},_=A=>{f(A.target.value)},P=async()=>{if(g(!1),c)return;let A=Number.parseFloat(h);if(Number.isNaN(A))A=e;else if(A=Math.max(r,Math.min(i,A)),s){A=Math.round(A/s)*s;const L=s.toString().split(".")[1]?.length||0;A=Number.parseFloat(A.toFixed(L))}if(A!==e){d(A),f(A.toString());try{await o(A)}catch(L){console.error("Error updating setting via input:",L),d(e),f(e.toString())}}else d(e),f(e.toString())},C=()=>{g(!0)},Q=A=>{A.key==="Enter"&&A.target.blur()},E=i>r?`${((u-r)/(i-r)*100).toFixed(2)}%`:"0%";return p.jsxs("div",{children:[p.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-4",children:[p.jsxs("label",{id:v,htmlFor:`${m}-range`,className:"flex min-w-0 items-center gap-2 text-body text-ink",children:[l&&p.jsx(l,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),p.jsx("span",{className:"truncate",children:t})]}),p.jsx("div",{className:"flex shrink-0 items-center gap-2",children:c?p.jsx(br,{size:"md",label:`Saving ${t}`}):p.jsxs(p.Fragment,{children:[p.jsx(fi,{inputSize:"sm",type:"number",value:h,onChange:_,onBlur:P,onFocus:C,onKeyDown:Q,min:r,max:i,step:s,disabled:c,"aria-labelledby":v,"aria-describedby":n?y:void 0,className:"w-18 text-right [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),a&&p.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a})]})})]}),n&&p.jsx("p",{id:y,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n}),p.jsx("input",{id:`${m}-range`,type:"range",value:u,min:r,max:i,step:s,disabled:c,onChange:x,onPointerDown:S,onKeyUp:k,onBlur:()=>void T(),"aria-labelledby":v,"aria-describedby":n?y:void 0,style:{"--fill":E},className:"mt-3 h-4 w-full cursor-pointer appearance-none bg-transparent bg-center bg-no-repeat bg-[length:100%_6px] bg-[linear-gradient(to_right,var(--color-accent)_0_var(--fill),var(--color-sunken)_var(--fill)_100%)] disabled:cursor-not-allowed disabled:bg-none disabled:bg-sunken [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-accent [&::-webkit-slider-thumb]:transition-colors [&::-webkit-slider-thumb]:duration-fast [&::-webkit-slider-thumb]:ease-out-quart [&::-webkit-slider-thumb]:hover:bg-accent-hover disabled:[&::-webkit-slider-thumb]:bg-ink-disabled"}),p.jsxs("div",{className:"flex justify-between font-mono text-mono-sm text-ink-dim",children:[p.jsx("span",{children:r}),p.jsx("span",{children:i})]})]})},dit={"--normal-bg":"var(--color-elevated)","--normal-text":"var(--color-ink)","--normal-border":"var(--color-control)","--border-radius":"var(--radius-md)","--gray12":"var(--color-ink)","--gray4":"var(--color-control)","--gray2":"var(--color-accent-wash)","--gray5":"var(--color-control)",background:"var(--color-elevated)",color:"var(--color-ink)",border:"1px solid var(--color-control)",boxShadow:"var(--shadow-overlay)",fontSize:"var(--text-meta)",padding:"12px 16px","--toast-close-button-start":"unset","--toast-close-button-end":"0px","--toast-close-button-transform":"translate(35%, -35%)"},hit=()=>p.jsx(Ttt,{position:"bottom-right",toastOptions:{style:dit,closeButton:!0}}),fit=/\/(?![\/\d])/g,Oit=e=>e.replace(fit,"/​");var hx={},Hv={},i2={},em={},tm={},oD={},Qre;function GTe(){return Qre||(Qre=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Doctype=e.CDATA=e.Tag=e.Style=e.Script=e.Comment=e.Directive=e.Text=e.Root=e.isTag=e.ElementType=void 0;var t;(function(r){r.Root="root",r.Text="text",r.Directive="directive",r.Comment="comment",r.Script="script",r.Style="style",r.Tag="tag",r.CDATA="cdata",r.Doctype="doctype"})(t=e.ElementType||(e.ElementType={}));function n(r){return r.type===t.Tag||r.type===t.Script||r.type===t.Style}e.isTag=n,e.Root=t.Root,e.Text=t.Text,e.Directive=t.Directive,e.Comment=t.Comment,e.Script=t.Script,e.Style=t.Style,e.Tag=t.Tag,e.CDATA=t.CDATA,e.Doctype=t.Doctype}(oD)),oD}var Hn={},Ere;function Rre(){if(Ere)return Hn;Ere=1;var e=Hn&&Hn.__extends||function(){var x=function(S,k){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,P){_.__proto__=P}||function(_,P){for(var C in P)Object.prototype.hasOwnProperty.call(P,C)&&(_[C]=P[C])},x(S,k)};return function(S,k){if(typeof k!="function"&&k!==null)throw new TypeError("Class extends value "+String(k)+" is not a constructor or null");x(S,k);function _(){this.constructor=S}S.prototype=k===null?Object.create(k):(_.prototype=k.prototype,new _)}}(),t=Hn&&Hn.__assign||function(){return t=Object.assign||function(x){for(var S,k=1,_=arguments.length;k<_;k++){S=arguments[k];for(var P in S)Object.prototype.hasOwnProperty.call(S,P)&&(x[P]=S[P])}return x},t.apply(this,arguments)};Object.defineProperty(Hn,"__esModule",{value:!0}),Hn.cloneNode=Hn.hasChildren=Hn.isDocument=Hn.isDirective=Hn.isComment=Hn.isText=Hn.isCDATA=Hn.isTag=Hn.Element=Hn.Document=Hn.CDATA=Hn.NodeWithChildren=Hn.ProcessingInstruction=Hn.Comment=Hn.Text=Hn.DataNode=Hn.Node=void 0;var n=GTe(),r=function(){function x(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(x.prototype,"parentNode",{get:function(){return this.parent},set:function(S){this.parent=S},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"previousSibling",{get:function(){return this.prev},set:function(S){this.prev=S},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"nextSibling",{get:function(){return this.next},set:function(S){this.next=S},enumerable:!1,configurable:!0}),x.prototype.cloneNode=function(S){return S===void 0&&(S=!1),b(this,S)},x}();Hn.Node=r;var i=function(x){e(S,x);function S(k){var _=x.call(this)||this;return _.data=k,_}return Object.defineProperty(S.prototype,"nodeValue",{get:function(){return this.data},set:function(k){this.data=k},enumerable:!1,configurable:!0}),S}(r);Hn.DataNode=i;var s=function(x){e(S,x);function S(){var k=x!==null&&x.apply(this,arguments)||this;return k.type=n.ElementType.Text,k}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 3},enumerable:!1,configurable:!0}),S}(i);Hn.Text=s;var a=function(x){e(S,x);function S(){var k=x!==null&&x.apply(this,arguments)||this;return k.type=n.ElementType.Comment,k}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 8},enumerable:!1,configurable:!0}),S}(i);Hn.Comment=a;var o=function(x){e(S,x);function S(k,_){var P=x.call(this,_)||this;return P.name=k,P.type=n.ElementType.Directive,P}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),S}(i);Hn.ProcessingInstruction=o;var l=function(x){e(S,x);function S(k){var _=x.call(this)||this;return _.children=k,_}return Object.defineProperty(S.prototype,"firstChild",{get:function(){var k;return(k=this.children[0])!==null&&k!==void 0?k:null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"childNodes",{get:function(){return this.children},set:function(k){this.children=k},enumerable:!1,configurable:!0}),S}(r);Hn.NodeWithChildren=l;var c=function(x){e(S,x);function S(){var k=x!==null&&x.apply(this,arguments)||this;return k.type=n.ElementType.CDATA,k}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),S}(l);Hn.CDATA=c;var u=function(x){e(S,x);function S(){var k=x!==null&&x.apply(this,arguments)||this;return k.type=n.ElementType.Root,k}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),S}(l);Hn.Document=u;var d=function(x){e(S,x);function S(k,_,P,C){P===void 0&&(P=[]),C===void 0&&(C=k==="script"?n.ElementType.Script:k==="style"?n.ElementType.Style:n.ElementType.Tag);var Q=x.call(this,P)||this;return Q.name=k,Q.attribs=_,Q.type=C,Q}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"tagName",{get:function(){return this.name},set:function(k){this.name=k},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"attributes",{get:function(){var k=this;return Object.keys(this.attribs).map(function(_){var P,C;return{name:_,value:k.attribs[_],namespace:(P=k["x-attribsNamespace"])===null||P===void 0?void 0:P[_],prefix:(C=k["x-attribsPrefix"])===null||C===void 0?void 0:C[_]}})},enumerable:!1,configurable:!0}),S}(l);Hn.Element=d;function h(x){return(0,n.isTag)(x)}Hn.isTag=h;function f(x){return x.type===n.ElementType.CDATA}Hn.isCDATA=f;function O(x){return x.type===n.ElementType.Text}Hn.isText=O;function g(x){return x.type===n.ElementType.Comment}Hn.isComment=g;function m(x){return x.type===n.ElementType.Directive}Hn.isDirective=m;function v(x){return x.type===n.ElementType.Root}Hn.isDocument=v;function y(x){return Object.prototype.hasOwnProperty.call(x,"children")}Hn.hasChildren=y;function b(x,S){S===void 0&&(S=!1);var k;if(O(x))k=new s(x.data);else if(g(x))k=new a(x.data);else if(h(x)){var _=S?T(x.children):[],P=new d(x.name,t({},x.attribs),_);_.forEach(function(A){return A.parent=P}),x.namespace!=null&&(P.namespace=x.namespace),x["x-attribsNamespace"]&&(P["x-attribsNamespace"]=t({},x["x-attribsNamespace"])),x["x-attribsPrefix"]&&(P["x-attribsPrefix"]=t({},x["x-attribsPrefix"])),k=P}else if(f(x)){var _=S?T(x.children):[],C=new c(_);_.forEach(function(L){return L.parent=C}),k=C}else if(v(x)){var _=S?T(x.children):[],Q=new u(_);_.forEach(function(L){return L.parent=Q}),x["x-mode"]&&(Q["x-mode"]=x["x-mode"]),k=Q}else if(m(x)){var E=new o(x.name,x.data);x["x-name"]!=null&&(E["x-name"]=x["x-name"],E["x-publicId"]=x["x-publicId"],E["x-systemId"]=x["x-systemId"]),k=E}else throw new Error("Not implemented yet: ".concat(x.type));return k.startIndex=x.startIndex,k.endIndex=x.endIndex,x.sourceCodeLocation!=null&&(k.sourceCodeLocation=x.sourceCodeLocation),k}Hn.cloneNode=b;function T(x){for(var S=x.map(function(_){return b(_,!0)}),k=1;k<S.length;k++)S[k].prev=S[k-1],S[k-1].next=S[k];return S}return Hn}var Are;function VTe(){return Are||(Are=1,function(e){var t=tm&&tm.__createBinding||(Object.create?function(o,l,c,u){u===void 0&&(u=c);var d=Object.getOwnPropertyDescriptor(l,c);(!d||("get"in d?!l.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return l[c]}}),Object.defineProperty(o,u,d)}:function(o,l,c,u){u===void 0&&(u=c),o[u]=l[c]}),n=tm&&tm.__exportStar||function(o,l){for(var c in o)c!=="default"&&!Object.prototype.hasOwnProperty.call(l,c)&&t(l,o,c)};Object.defineProperty(e,"__esModule",{value:!0}),e.DomHandler=void 0;var r=GTe(),i=Rre();n(Rre(),e);var s={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},a=function(){function o(l,c,u){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof c=="function"&&(u=c,c=s),typeof l=="object"&&(c=l,l=void 0),this.callback=l??null,this.options=c??s,this.elementCB=u??null}return o.prototype.onparserinit=function(l){this.parser=l},o.prototype.onreset=function(){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},o.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},o.prototype.onerror=function(l){this.handleCallback(l)},o.prototype.onclosetag=function(){this.lastNode=null;var l=this.tagStack.pop();this.options.withEndIndices&&(l.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(l)},o.prototype.onopentag=function(l,c){var u=this.options.xmlMode?r.ElementType.Tag:void 0,d=new i.Element(l,c,void 0,u);this.addNode(d),this.tagStack.push(d)},o.prototype.ontext=function(l){var c=this.lastNode;if(c&&c.type===r.ElementType.Text)c.data+=l,this.options.withEndIndices&&(c.endIndex=this.parser.endIndex);else{var u=new i.Text(l);this.addNode(u),this.lastNode=u}},o.prototype.oncomment=function(l){if(this.lastNode&&this.lastNode.type===r.ElementType.Comment){this.lastNode.data+=l;return}var c=new i.Comment(l);this.addNode(c),this.lastNode=c},o.prototype.oncommentend=function(){this.lastNode=null},o.prototype.oncdatastart=function(){var l=new i.Text(""),c=new i.CDATA([l]);this.addNode(c),l.parent=c,this.lastNode=l},o.prototype.oncdataend=function(){this.lastNode=null},o.prototype.onprocessinginstruction=function(l,c){var u=new i.ProcessingInstruction(l,c);this.addNode(u)},o.prototype.handleCallback=function(l){if(typeof this.callback=="function")this.callback(l,this.dom);else if(l)throw l},o.prototype.addNode=function(l){var c=this.tagStack[this.tagStack.length-1],u=c.children[c.children.length-1];this.options.withStartIndices&&(l.startIndex=this.parser.startIndex),this.options.withEndIndices&&(l.endIndex=this.parser.endIndex),c.children.push(l),u&&(l.prev=u,u.next=l),l.parent=c,this.lastNode=null},o}();e.DomHandler=a,e.default=a}(tm)),tm}var lD={},Xre;function pit(){return Xre||(Xre=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CARRIAGE_RETURN_PLACEHOLDER_REGEX=e.CARRIAGE_RETURN_PLACEHOLDER=e.CARRIAGE_RETURN_REGEX=e.CARRIAGE_RETURN=e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES=void 0,e.CASE_SENSITIVE_TAG_NAMES=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES.reduce(function(t,n){return t[n.toLowerCase()]=n,t},{}),e.CARRIAGE_RETURN="\r",e.CARRIAGE_RETURN_REGEX=new RegExp(e.CARRIAGE_RETURN,"g"),e.CARRIAGE_RETURN_PLACEHOLDER="__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now(),"__"),e.CARRIAGE_RETURN_PLACEHOLDER_REGEX=new RegExp(e.CARRIAGE_RETURN_PLACEHOLDER,"g")}(lD)),lD}var Dre;function BTe(){if(Dre)return em;Dre=1,Object.defineProperty(em,"__esModule",{value:!0}),em.formatAttributes=r,em.escapeSpecialCharacters=s,em.revertEscapedCharacters=a,em.formatDOM=o;var e=VTe(),t=pit();function n(l){return t.CASE_SENSITIVE_TAG_NAMES_MAP[l]}function r(l){for(var c={},u=0,d=l.length;u<d;u++){var h=l[u];c[h.name]=h.value}return c}function i(l){l=l.toLowerCase();var c=n(l);return c||l}function s(l){return l.replace(t.CARRIAGE_RETURN_REGEX,t.CARRIAGE_RETURN_PLACEHOLDER)}function a(l){return l.replace(t.CARRIAGE_RETURN_PLACEHOLDER_REGEX,t.CARRIAGE_RETURN)}function o(l,c,u){c===void 0&&(c=null);for(var d=[],h,f=0,O=l.length;f<O;f++){var g=l[f];switch(g.nodeType){case 1:{var m=i(g.nodeName);h=new e.Element(m,r(g.attributes)),h.children=o(m==="template"?g.content.childNodes:g.childNodes,h);break}case 3:h=new e.Text(a(g.nodeValue));break;case 8:h=new e.Comment(g.nodeValue);break;default:continue}var v=d[f-1]||null;v&&(v.next=h),h.parent=c,h.prev=v,h.next=null,d.push(h)}return u&&(h=new e.ProcessingInstruction(u.substring(0,u.indexOf(" ")).toLowerCase(),u),h.next=d[0]||null,h.parent=c,d.unshift(h),d[1]&&(d[1].prev=d[0])),d}return em}var Ire;function git(){if(Ire)return i2;Ire=1,Object.defineProperty(i2,"__esModule",{value:!0}),i2.default=g;var e=BTe(),t="html",n="head",r="body",i=/<([a-zA-Z]+[0-9]?)/,s=/<head[^]*>/i,a=/<body[^]*>/i,o=function(m,v){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},l=function(m,v){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")},c=typeof window=="object"&&window.DOMParser;if(typeof c=="function"){var u=new c,d="text/html";l=function(m,v){return v&&(m="<".concat(v,">").concat(m,"</").concat(v,">")),u.parseFromString(m,d)},o=l}if(typeof document=="object"&&document.implementation){var h=document.implementation.createHTMLDocument();o=function(m,v){if(v){var y=h.documentElement.querySelector(v);return y&&(y.innerHTML=m),h}return h.documentElement.innerHTML=m,h}}var f=typeof document=="object"&&document.createElement("template"),O;f&&f.content&&(O=function(m){return f.innerHTML=m,f.content.childNodes});function g(m){var v,y;m=(0,e.escapeSpecialCharacters)(m);var b=m.match(i),T=b&&b[1]?b[1].toLowerCase():"";switch(T){case t:{var x=l(m);if(!s.test(m)){var S=x.querySelector(n);(v=S?.parentNode)===null||v===void 0||v.removeChild(S)}if(!a.test(m)){var S=x.querySelector(r);(y=S?.parentNode)===null||y===void 0||y.removeChild(S)}return x.querySelectorAll(t)}case n:case r:{var k=o(m).querySelectorAll(T);return a.test(m)&&s.test(m)?k[0].parentNode.childNodes:k}default:{if(O)return O(m);var S=o(m,r).querySelector(r);return S.childNodes}}}return i2}var Nre;function mit(){if(Nre)return Hv;Nre=1;var e=Hv&&Hv.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Hv,"__esModule",{value:!0}),Hv.default=i;var t=e(git()),n=BTe(),r=/<(![a-zA-Z\s]+)>/;function i(s){if(typeof s!="string")throw new TypeError("First argument must be a string");if(!s)return[];var a=s.match(r),o=a?a[1]:void 0;return(0,n.formatDOM)((0,t.default)(s),null,o)}return Hv}var s2={},_c={},fx={},Fre;function vit(){if(Fre)return fx;Fre=1;var e=0;fx.SAME=e;var t=1;return fx.CAMELCASE=t,fx.possibleStandardNames={accept:0,acceptCharset:1,"accept-charset":"acceptCharset",accessKey:1,action:0,allowFullScreen:1,alt:0,as:0,async:0,autoCapitalize:1,autoComplete:1,autoCorrect:1,autoFocus:1,autoPlay:1,autoSave:1,capture:0,cellPadding:1,cellSpacing:1,challenge:0,charSet:1,checked:0,children:0,cite:0,class:"className",classID:1,className:1,cols:0,colSpan:1,content:0,contentEditable:1,contextMenu:1,controls:0,controlsList:1,coords:0,crossOrigin:1,dangerouslySetInnerHTML:1,data:0,dateTime:1,default:0,defaultChecked:1,defaultValue:1,defer:0,dir:0,disabled:0,disablePictureInPicture:1,disableRemotePlayback:1,download:0,draggable:0,encType:1,enterKeyHint:1,for:"htmlFor",form:0,formMethod:1,formAction:1,formEncType:1,formNoValidate:1,formTarget:1,frameBorder:1,headers:0,height:0,hidden:0,high:0,href:0,hrefLang:1,htmlFor:1,httpEquiv:1,"http-equiv":"httpEquiv",icon:0,id:0,innerHTML:1,inputMode:1,integrity:0,is:0,itemID:1,itemProp:1,itemRef:1,itemScope:1,itemType:1,keyParams:1,keyType:1,kind:0,label:0,lang:0,list:0,loop:0,low:0,manifest:0,marginWidth:1,marginHeight:1,max:0,maxLength:1,media:0,mediaGroup:1,method:0,min:0,minLength:1,multiple:0,muted:0,name:0,noModule:1,nonce:0,noValidate:1,open:0,optimum:0,pattern:0,placeholder:0,playsInline:1,poster:0,preload:0,profile:0,radioGroup:1,readOnly:1,referrerPolicy:1,rel:0,required:0,reversed:0,role:0,rows:0,rowSpan:1,sandbox:0,scope:0,scoped:0,scrolling:0,seamless:0,selected:0,shape:0,size:0,sizes:0,span:0,spellCheck:1,src:0,srcDoc:1,srcLang:1,srcSet:1,start:0,step:0,style:0,summary:0,tabIndex:1,target:0,title:0,type:0,useMap:1,value:0,width:0,wmode:0,wrap:0,about:0,accentHeight:1,"accent-height":"accentHeight",accumulate:0,additive:0,alignmentBaseline:1,"alignment-baseline":"alignmentBaseline",allowReorder:1,alphabetic:0,amplitude:0,arabicForm:1,"arabic-form":"arabicForm",ascent:0,attributeName:1,attributeType:1,autoReverse:1,azimuth:0,baseFrequency:1,baselineShift:1,"baseline-shift":"baselineShift",baseProfile:1,bbox:0,begin:0,bias:0,by:0,calcMode:1,capHeight:1,"cap-height":"capHeight",clip:0,clipPath:1,"clip-path":"clipPath",clipPathUnits:1,clipRule:1,"clip-rule":"clipRule",color:0,colorInterpolation:1,"color-interpolation":"colorInterpolation",colorInterpolationFilters:1,"color-interpolation-filters":"colorInterpolationFilters",colorProfile:1,"color-profile":"colorProfile",colorRendering:1,"color-rendering":"colorRendering",contentScriptType:1,contentStyleType:1,cursor:0,cx:0,cy:0,d:0,datatype:0,decelerate:0,descent:0,diffuseConstant:1,direction:0,display:0,divisor:0,dominantBaseline:1,"dominant-baseline":"dominantBaseline",dur:0,dx:0,dy:0,edgeMode:1,elevation:0,enableBackground:1,"enable-background":"enableBackground",end:0,exponent:0,externalResourcesRequired:1,fill:0,fillOpacity:1,"fill-opacity":"fillOpacity",fillRule:1,"fill-rule":"fillRule",filter:0,filterRes:1,filterUnits:1,floodOpacity:1,"flood-opacity":"floodOpacity",floodColor:1,"flood-color":"floodColor",focusable:0,fontFamily:1,"font-family":"fontFamily",fontSize:1,"font-size":"fontSize",fontSizeAdjust:1,"font-size-adjust":"fontSizeAdjust",fontStretch:1,"font-stretch":"fontStretch",fontStyle:1,"font-style":"fontStyle",fontVariant:1,"font-variant":"fontVariant",fontWeight:1,"font-weight":"fontWeight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:1,"glyph-name":"glyphName",glyphOrientationHorizontal:1,"glyph-orientation-horizontal":"glyphOrientationHorizontal",glyphOrientationVertical:1,"glyph-orientation-vertical":"glyphOrientationVertical",glyphRef:1,gradientTransform:1,gradientUnits:1,hanging:0,horizAdvX:1,"horiz-adv-x":"horizAdvX",horizOriginX:1,"horiz-origin-x":"horizOriginX",ideographic:0,imageRendering:1,"image-rendering":"imageRendering",in2:0,in:0,inlist:0,intercept:0,k1:0,k2:0,k3:0,k4:0,k:0,kernelMatrix:1,kernelUnitLength:1,kerning:0,keyPoints:1,keySplines:1,keyTimes:1,lengthAdjust:1,letterSpacing:1,"letter-spacing":"letterSpacing",lightingColor:1,"lighting-color":"lightingColor",limitingConeAngle:1,local:0,markerEnd:1,"marker-end":"markerEnd",markerHeight:1,markerMid:1,"marker-mid":"markerMid",markerStart:1,"marker-start":"markerStart",markerUnits:1,markerWidth:1,mask:0,maskContentUnits:1,maskUnits:1,mathematical:0,mode:0,numOctaves:1,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:1,"overline-position":"overlinePosition",overlineThickness:1,"overline-thickness":"overlineThickness",paintOrder:1,"paint-order":"paintOrder",panose1:0,"panose-1":"panose1",pathLength:1,patternContentUnits:1,patternTransform:1,patternUnits:1,pointerEvents:1,"pointer-events":"pointerEvents",points:0,pointsAtX:1,pointsAtY:1,pointsAtZ:1,prefix:0,preserveAlpha:1,preserveAspectRatio:1,primitiveUnits:1,property:0,r:0,radius:0,refX:1,refY:1,renderingIntent:1,"rendering-intent":"renderingIntent",repeatCount:1,repeatDur:1,requiredExtensions:1,requiredFeatures:1,resource:0,restart:0,result:0,results:0,rotate:0,rx:0,ry:0,scale:0,security:0,seed:0,shapeRendering:1,"shape-rendering":"shapeRendering",slope:0,spacing:0,specularConstant:1,specularExponent:1,speed:0,spreadMethod:1,startOffset:1,stdDeviation:1,stemh:0,stemv:0,stitchTiles:1,stopColor:1,"stop-color":"stopColor",stopOpacity:1,"stop-opacity":"stopOpacity",strikethroughPosition:1,"strikethrough-position":"strikethroughPosition",strikethroughThickness:1,"strikethrough-thickness":"strikethroughThickness",string:0,stroke:0,strokeDasharray:1,"stroke-dasharray":"strokeDasharray",strokeDashoffset:1,"stroke-dashoffset":"strokeDashoffset",strokeLinecap:1,"stroke-linecap":"strokeLinecap",strokeLinejoin:1,"stroke-linejoin":"strokeLinejoin",strokeMiterlimit:1,"stroke-miterlimit":"strokeMiterlimit",strokeWidth:1,"stroke-width":"strokeWidth",strokeOpacity:1,"stroke-opacity":"strokeOpacity",suppressContentEditableWarning:1,suppressHydrationWarning:1,surfaceScale:1,systemLanguage:1,tableValues:1,targetX:1,targetY:1,textAnchor:1,"text-anchor":"textAnchor",textDecoration:1,"text-decoration":"textDecoration",textLength:1,textRendering:1,"text-rendering":"textRendering",to:0,transform:0,typeof:0,u1:0,u2:0,underlinePosition:1,"underline-position":"underlinePosition",underlineThickness:1,"underline-thickness":"underlineThickness",unicode:0,unicodeBidi:1,"unicode-bidi":"unicodeBidi",unicodeRange:1,"unicode-range":"unicodeRange",unitsPerEm:1,"units-per-em":"unitsPerEm",unselectable:0,vAlphabetic:1,"v-alphabetic":"vAlphabetic",values:0,vectorEffect:1,"vector-effect":"vectorEffect",version:0,vertAdvY:1,"vert-adv-y":"vertAdvY",vertOriginX:1,"vert-origin-x":"vertOriginX",vertOriginY:1,"vert-origin-y":"vertOriginY",vHanging:1,"v-hanging":"vHanging",vIdeographic:1,"v-ideographic":"vIdeographic",viewBox:1,viewTarget:1,visibility:0,vMathematical:1,"v-mathematical":"vMathematical",vocab:0,widths:0,wordSpacing:1,"word-spacing":"wordSpacing",writingMode:1,"writing-mode":"writingMode",x1:0,x2:0,x:0,xChannelSelector:1,xHeight:1,"x-height":"xHeight",xlinkActuate:1,"xlink:actuate":"xlinkActuate",xlinkArcrole:1,"xlink:arcrole":"xlinkArcrole",xlinkHref:1,"xlink:href":"xlinkHref",xlinkRole:1,"xlink:role":"xlinkRole",xlinkShow:1,"xlink:show":"xlinkShow",xlinkTitle:1,"xlink:title":"xlinkTitle",xlinkType:1,"xlink:type":"xlinkType",xmlBase:1,"xml:base":"xmlBase",xmlLang:1,"xml:lang":"xmlLang",xmlns:0,"xml:space":"xmlSpace",xmlnsXlink:1,"xmlns:xlink":"xmlnsXlink",xmlSpace:1,y1:0,y2:0,y:0,yChannelSelector:1,z:0,zoomAndPan:1},fx}var Mre;function yit(){if(Mre)return _c;Mre=1;const e=0,t=1,n=2,r=3,i=4,s=5,a=6;function o(x){return c.hasOwnProperty(x)?c[x]:null}function l(x,S,k,_,P,C,Q){this.acceptsBooleans=S===n||S===r||S===i,this.attributeName=_,this.attributeNamespace=P,this.mustUseProperty=k,this.propertyName=x,this.type=S,this.sanitizeURL=C,this.removeEmptyString=Q}const c={};["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"].forEach(x=>{c[x]=new l(x,e,!1,x,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(([x,S])=>{c[x]=new l(x,t,!1,S,null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(x=>{c[x]=new l(x,n,!1,x.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(x=>{c[x]=new l(x,n,!1,x,null,!1,!1)}),["allowFullScreen","async","autoFocus","autoPlay","controls","default","defer","disabled","disablePictureInPicture","disableRemotePlayback","formNoValidate","hidden","loop","noModule","noValidate","open","playsInline","readOnly","required","reversed","scoped","seamless","itemScope"].forEach(x=>{c[x]=new l(x,r,!1,x.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(x=>{c[x]=new l(x,r,!0,x,null,!1,!1)}),["capture","download"].forEach(x=>{c[x]=new l(x,i,!1,x,null,!1,!1)}),["cols","rows","size","span"].forEach(x=>{c[x]=new l(x,a,!1,x,null,!1,!1)}),["rowSpan","start"].forEach(x=>{c[x]=new l(x,s,!1,x.toLowerCase(),null,!1,!1)});const d=/[\-\:]([a-z])/g,h=x=>x[1].toUpperCase();["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","xmlns:xlink","x-height"].forEach(x=>{const S=x.replace(d,h);c[S]=new l(S,t,!1,x,null,!1,!1)}),["xlink:actuate","xlink:arcrole","xlink:role","xlink:show","xlink:title","xlink:type"].forEach(x=>{const S=x.replace(d,h);c[S]=new l(S,t,!1,x,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(x=>{const S=x.replace(d,h);c[S]=new l(S,t,!1,x,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(x=>{c[x]=new l(x,t,!1,x.toLowerCase(),null,!1,!1)});const f="xlinkHref";c[f]=new l("xlinkHref",t,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(x=>{c[x]=new l(x,t,!1,x.toLowerCase(),null,!0,!0)});const{CAMELCASE:O,SAME:g,possibleStandardNames:m}=vit(),y=":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",b=RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+y+"]*$")),T=Object.keys(m).reduce((x,S)=>{const k=m[S];return k===g?x[S]=S:k===O?x[S.toLowerCase()]=S:x[S]=k,x},{});return _c.BOOLEAN=r,_c.BOOLEANISH_STRING=n,_c.NUMERIC=s,_c.OVERLOADED_BOOLEAN=i,_c.POSITIVE_NUMERIC=a,_c.RESERVED=e,_c.STRING=t,_c.getPropertyInfo=o,_c.isCustomAttribute=b,_c.possibleStandardNames=T,_c}var Ox={},Kv={},cD,Lre;function bit(){if(Lre)return cD;Lre=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
744
- `,c="/",u="*",d="",h="comment",f="declaration";cD=function(g,m){if(typeof g!="string")throw new TypeError("First argument must be a string");if(!g)return[];m=m||{};var v=1,y=1;function b(A){var L=A.match(t);L&&(v+=L.length);var j=A.lastIndexOf(l);y=~j?A.length-j:y+A.length}function T(){var A={line:v,column:y};return function(L){return L.position=new x(A),_(),L}}function x(A){this.start=A,this.end={line:v,column:y},this.source=m.source}x.prototype.content=g;function S(A){var L=new Error(m.source+":"+v+":"+y+": "+A);if(L.reason=A,L.filename=m.source,L.line=v,L.column=y,L.source=g,!m.silent)throw L}function k(A){var L=A.exec(g);if(L){var j=L[0];return b(j),g=g.slice(j.length),L}}function _(){k(n)}function P(A){var L;for(A=A||[];L=C();)L!==!1&&A.push(L);return A}function C(){var A=T();if(!(c!=g.charAt(0)||u!=g.charAt(1))){for(var L=2;d!=g.charAt(L)&&(u!=g.charAt(L)||c!=g.charAt(L+1));)++L;if(L+=2,d===g.charAt(L-1))return S("End of comment missing");var j=g.slice(2,L-2);return y+=2,b(j),g=g.slice(L),y+=2,A({type:h,comment:j})}}function Q(){var A=T(),L=k(r);if(L){if(C(),!k(i))return S("property missing ':'");var j=k(s),q=A({type:f,property:O(L[0].replace(e,d)),value:j?O(j[0].replace(e,d)):d});return k(a),q}}function E(){var A=[];P(A);for(var L;L=Q();)L!==!1&&(A.push(L),P(A));return A}return _(),E()};function O(g){return g?g.replace(o,d):d}return cD}var jre;function wit(){if(jre)return Kv;jre=1;var e=Kv&&Kv.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Kv,"__esModule",{value:!0}),Kv.default=n;var t=e(bit());function n(r,i){var s=null;if(!r||typeof r!="string")return s;var a=(0,t.default)(r),o=typeof i=="function";return a.forEach(function(l){if(l.type==="declaration"){var c=l.property,u=l.value;o?i(c,u,l):u&&(s=s||{},s[c]=u)}}),s}return Kv}var px={},qre;function xit(){if(qre)return px;qre=1,Object.defineProperty(px,"__esModule",{value:!0}),px.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||e.test(c)},a=function(c,u){return u.toUpperCase()},o=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),s(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(i,o):c=c.replace(r,o),c.replace(t,a))};return px.camelCase=l,px}var gx,zre;function YTe(){if(zre)return gx;zre=1;var e=gx&&gx.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(wit()),n=xit();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,n.camelCase)(o,s)]=l)}),a}return r.default=r,gx=r,gx}var Ure;function ZTe(){return Ure||(Ure=1,function(e){var t=Ox&&Ox.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(e,"__esModule",{value:!0}),e.returnFirstArg=e.canTextBeChildOfNode=e.ELEMENTS_WITH_NO_TEXT_CHILDREN=e.PRESERVE_CUSTOM_ATTRIBUTES=void 0,e.isCustomComponent=s,e.setStyleProp=o;var n=qSe(),r=t(YTe()),i=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function s(u,d){return u.includes("-")?!i.has(u):!!(d&&typeof d.is=="string")}var a={reactCompat:!0};function o(u,d){if(typeof u=="string"){if(!u.trim()){d.style={};return}try{d.style=(0,r.default)(u,a)}catch{d.style={}}}}e.PRESERVE_CUSTOM_ATTRIBUTES=Number(n.version.split(".")[0])>=16,e.ELEMENTS_WITH_NO_TEXT_CHILDREN=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);var l=function(u){return!e.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(u.name)};e.canTextBeChildOfNode=l;var c=function(u){return u};e.returnFirstArg=c}(Ox)),Ox}var Wre;function HTe(){if(Wre)return s2;Wre=1,Object.defineProperty(s2,"__esModule",{value:!0}),s2.default=s;var e=yit(),t=ZTe(),n=["checked","value"],r=["input","select","textarea"],i={reset:!0,submit:!0};function s(o,l){o===void 0&&(o={});var c={},u=!!(o.type&&i[o.type]);for(var d in o){var h=o[d];if((0,e.isCustomAttribute)(d)){c[d]=h;continue}var f=d.toLowerCase(),O=a(f);if(O){var g=(0,e.getPropertyInfo)(O);switch(n.includes(O)&&r.includes(l)&&!u&&(O=a("default"+f)),c[O]=h,g&&g.type){case e.BOOLEAN:c[O]=!0;break;case e.OVERLOADED_BOOLEAN:h===""&&(c[O]=!0);break}continue}t.PRESERVE_CUSTOM_ATTRIBUTES&&(c[d]=h)}return(0,t.setStyleProp)(o.style,c),c}function a(o){return e.possibleStandardNames[o]}return s2}var Jv={},Gre;function Sit(){if(Gre)return Jv;Gre=1;var e=Jv&&Jv.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(Jv,"__esModule",{value:!0}),Jv.default=s;var t=qSe(),n=e(HTe()),r=ZTe(),i={cloneElement:t.cloneElement,createElement:t.createElement,isValidElement:t.isValidElement};function s(o,l){l===void 0&&(l={});for(var c=[],u=typeof l.replace=="function",d=l.transform||r.returnFirstArg,h=l.library||i,f=h.cloneElement,O=h.createElement,g=h.isValidElement,m=o.length,v=0;v<m;v++){var y=o[v];if(u){var b=l.replace(y,v);if(g(b)){m>1&&(b=f(b,{key:b.key||v})),c.push(d(b,y,v));continue}}if(y.type==="text"){var T=!y.data.trim().length;if(T&&y.parent&&!(0,r.canTextBeChildOfNode)(y.parent)||l.trim&&T)continue;c.push(d(y.data,y,v));continue}var x=y,S={};a(x)?((0,r.setStyleProp)(x.attribs.style,x.attribs),S=x.attribs):x.attribs&&(S=(0,n.default)(x.attribs,x.name));var k=void 0;switch(y.type){case"script":case"style":y.children[0]&&(S.dangerouslySetInnerHTML={__html:y.children[0].data});break;case"tag":y.name==="textarea"&&y.children[0]?S.defaultValue=y.children[0].data:y.children&&y.children.length&&(k=s(y.children,l));break;default:continue}m>1&&(S.key=v),c.push(d(O(y.name,S,k),y,v))}return c.length===1?c[0]:c}function a(o){return r.PRESERVE_CUSTOM_ATTRIBUTES&&o.type==="tag"&&(0,r.isCustomComponent)(o.name,o.attribs)}return Jv}var Vre;function $it(){return Vre||(Vre=1,function(e){var t=hx&&hx.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(e,"__esModule",{value:!0}),e.htmlToDOM=e.domToReact=e.attributesToProps=e.Text=e.ProcessingInstruction=e.Element=e.Comment=void 0,e.default=o;var n=t(mit());e.htmlToDOM=n.default;var r=t(HTe());e.attributesToProps=r.default;var i=t(Sit());e.domToReact=i.default;var s=VTe();Object.defineProperty(e,"Comment",{enumerable:!0,get:function(){return s.Comment}}),Object.defineProperty(e,"Element",{enumerable:!0,get:function(){return s.Element}}),Object.defineProperty(e,"ProcessingInstruction",{enumerable:!0,get:function(){return s.ProcessingInstruction}}),Object.defineProperty(e,"Text",{enumerable:!0,get:function(){return s.Text}});var a={lowerCaseAttributeNames:!1};function o(l,c){if(typeof l!="string")throw new TypeError("First argument must be a string");return l?(0,i.default)((0,n.default)(l,c?.htmlparser2||a),c):[]}}(hx)),hx}var kit=$it();const Bre=en(kit),Tit=Bre.default||Bre,_it=/^v/i,KTe=(e,t)=>{const n=o=>o.trim().replace(_it,""),r=n(e),i=n(t);if(r===i)return!0;if(r.includes("-")||i.includes("-"))return!1;const s=r.split(".").map(Number),a=i.split(".").map(Number);for(let o=0;o<Math.max(s.length,a.length);o++){const l=s[o]??0,c=a[o]??0;if(!Number.isFinite(l)||!Number.isFinite(c))return!1;if(l>c)return!0;if(l<c)return!1}return!0},JTe=e=>{const{target:t,sourceBuild:n}=e.expectation;return n?!0:t==null?!1:e.reported!=null&&KTe(e.reported,t)},Pit=e=>e.manual===!0&&JTe({reported:e.currentVersion,expectation:e.expectation}),Cit=/cannot find .* in the latest release artifacts/i,Qit={"installed-bundle-not-sealed":"This app can't update itself","download-verification-failed":"The update couldn't be verified","artifact-metadata-missing":"The update couldn't be verified","insufficient-disk-space":"Not enough disk space to update"},qO=({className:e,tone:t="notice",role:n,...r})=>p.jsx("div",{role:n??(t==="failed"?"alert":"status"),className:I("fixed top-4 right-4 z-50 w-100 max-w-[calc(100vw-2rem)]","rounded-lg bg-elevated p-4 shadow-overlay","[&_a]:text-accent [&_a]:underline-offset-4 [&_a]:hover:underline",e),...r}),a2=({children:e,tone:t="notice"})=>p.jsxs("h2",{className:I("mb-3 flex items-center gap-2 text-heading text-ink"),children:[t==="failed"&&p.jsx(EV,{className:"size-4 shrink-0 text-danger","aria-hidden":!0}),e]}),mx=({detail:e})=>{const[t,n]=w.useState(!1);return p.jsxs("div",{className:"mt-4 flex items-start gap-2",children:[p.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:"Details:"}),p.jsx("span",{className:"min-w-0 flex-1 break-words font-mono text-mono-sm text-ink-dim",children:Oit(e)}),p.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard.writeText(e).then(()=>n(!0)).catch(()=>{})},children:[t?p.jsx(bc,{}):p.jsx(hv,{}),t?"Copied":"Copy details"]})]})},o2=({command:e})=>{const[t,n]=w.useState(!1);return p.jsxs("div",{className:"mt-2 flex items-start gap-2",children:[p.jsx("code",{className:"min-w-0 flex-1 rounded-sm bg-sunken p-2 text-mono-sm break-all text-ink",children:e}),p.jsxs(we,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(e).then(()=>n(!0)).catch(()=>{})},children:[t?p.jsx(bc,{}):p.jsx(hv,{}),t?"Copied":"Copy command"]})]})},Eit=["[&_:is(h1,h2,h3,h4,h5,h6)]:mt-3 [&_:is(h1,h2,h3,h4,h5,h6)]:mb-1 [&_:is(h1,h2,h3,h4,h5,h6)]:font-semibold [&_:is(h1,h2,h3,h4,h5,h6)]:text-ink","[&_h1]:text-heading [&_h2]:text-heading [&_h3]:text-body [&_h4]:text-body [&_h5]:text-body-sm [&_h6]:text-body-sm","[&_p]:my-1.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0","[&_:is(ul,ol)]:my-1.5 [&_:is(ul,ol)]:pl-5 [&_ul_li]:list-disc [&_ol_li]:list-decimal [&_li]:my-0.5","[&_code]:rounded-xs [&_code]:bg-sunken [&_code]:px-1 [&_code]:font-mono [&_code]:text-mono-sm"].join(" "),uD=({command:e,sourceBuild:t})=>t&&!e?p.jsx("p",{className:"mt-2 text-body text-ink",children:"This server follows this machine's checkout, so there is no command to run here."}):p.jsx("p",{className:"mt-2 text-body text-ink",children:t?"Run this in a terminal. It rebuilds the server from this machine's checkout, so the version it reports afterwards is your checkout's rather than the published release.":e?"Run this in a terminal, then check for updates again to pick up the new server version.":"Then check for updates again to pick up the new server version."}),Yre=({latestVersion:e,currentVersion:t,className:n})=>e?p.jsxs("p",{className:I("mb-2 text-body text-ink-muted",n),children:[`Server version ${e} is available.`,t?` You are currently using version ${t}.`:""]}):null,zO=({className:e,...t})=>p.jsx("div",{className:I("mt-6 flex flex-wrap justify-end gap-3",e),...t}),Zre=({className:e,...t})=>p.jsx("div",{className:I("mt-4 mb-2",e),...t}),Rit=({autoCheck:e=!0})=>{const[t,n]=w.useState(!1),[r,i]=w.useState(!1),[s,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(!1),[d,h]=w.useState(null),[f,O]=w.useState(!1),[g,m]=w.useState(null),[v,y]=w.useState(!1),[b,T]=w.useState("unknown"),[x,S]=w.useState(!1),[k,_]=w.useState(null),[P,C]=w.useState(!1),[Q,E]=w.useState(!1),[A,L]=w.useState(null),j=w.useRef({target:null,sourceBuild:!1}),[q,z]=w.useState(!1),[V,W]=w.useState(null),[M,K]=w.useState(null),[N,D]=w.useState(null),{shouldShowUpdate:B,deferUpdate:G}=wrt(),ee=w.useRef(null);w.useEffect(()=>{ee.current=k},[k]),w.useEffect(()=>{window.api.systemInfo.getAppVersion().then(ve=>T(ve)).catch(()=>T("unknown"))},[]);const he=w.useCallback(async ve=>{try{n(!0),m(null),await window.api.updater.checkForUpdates(ve)}catch(Re){const tt=Re instanceof Error?Re.message:String(Re);if(Cit.test(tt)){a(!1),l(null),console.warn(`Error checking for updates: ${tt}`);return}m(`Error checking for updates: ${tt}`),y(!0)}finally{n(!1)}},[]),ae=w.useCallback(async()=>{try{n(!0),m(null),await window.api.updater.checkForAllUpdates({manual:!0})}catch(ve){m(`Error checking for updates: ${ve instanceof Error?ve.message:String(ve)}`),y(!0)}finally{n(!1)}},[]),se=w.useCallback(async()=>{try{u(!0),m(null),await window.api.updater.downloadUpdate()}catch(ve){m(`Error downloading update: ${ve instanceof Error?ve.message:String(ve)}`),u(!1),y(!0)}},[]),me=w.useCallback(async()=>{z(!0),m(null);try{await window.api.updater.quitAndInstall()||z(!1)}catch(ve){z(!1),m(`Error starting the update: ${ve instanceof Error?ve.message:String(ve)}`),y(!0)}},[]),fe=w.useCallback(async()=>{try{await window.api.updater.quitForUpdateInstall()}catch(ve){m(`Error quitting for the update: ${ve instanceof Error?ve.message:String(ve)}`),y(!0)}},[]),Y=w.useCallback(ve=>{ve&&window.api.openExternal(ve)},[]),Te=w.useCallback(async()=>{try{n(!0),i(!0),m(null),await window.api.updater.updateBackend(ee.current?.latestVersion)}catch(ve){m(`Error updating server: ${ve instanceof Error?ve.message:String(ve)}`),y(!0),n(!1),i(!1)}},[]),ke=w.useCallback(()=>{k&&(G(Ay.BACKEND,k.latestVersion),y(!1),S(!1),_(null))},[G,k]),Ve=w.useCallback(()=>{o&&(G(Ay.UI,o.version),y(!1),a(!1),O(!1))},[G,o]);w.useEffect(()=>{const ve=window.api.updater.onUpdateAvailable(et=>{B(Ay.UI,et.version)&&(K(null),a(!0),l(et),y(!0))}),Re=window.api.updater.onUpdateNotAvailable(()=>{a(!1),l(null)}),tt=window.api.updater.onUpdateDownloaded(et=>{u(!1),B(Ay.UI,et.version)&&(K(null),O(!0),l(et),y(!0))}),ot=window.api.updater.onUpdateError(et=>{et.includes("manually")?(E(!0),L({message:"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip.",command:""}),y(!0)):(m(et),n(!1),u(!1),y(!0))}),Vt=window.api.updater.onBackendUpdateManualRequired(et=>{j.current={target:et.latestVersion??ee.current?.latestVersion??null,sourceBuild:et.sourceBuild===!0},E(!0),L(et),n(!1),i(!1),S(!1),_(null)}),Dt=window.api.updater.onUpdateInstallBlocked(et=>{W(et),n(!1),i(!1),u(!1)}),vn=window.api.updater.onUpdateInstallFailed(et=>{K(et),D(null),n(!1)}),Be=window.api.updater.onUpdateInstallInFlight(et=>{D(et),K(null),n(!1)}),bt=window.api.updater.onUpdateProgress(et=>{h(et)}),xe=window.api.updater.onBackendUpdateAvailable(et=>{if(Pit({manual:et.manual,currentVersion:et.currentVersion,expectation:j.current})&&(E(!1),L(null),j.current={target:null,sourceBuild:!1}),B(Ay.BACKEND,et.latestVersion)){const dt={...et,canManageUpdate:et.canManageUpdate??!et.updateCommand.includes("manually")};S(!0),_(dt),y(!0)}}),qe=window.api.updater.onBackendUpdateNotAvailable(et=>{const dt=ee.current;S(cn=>dt&&KTe(et.version,dt.latestVersion)?(_(null),!1):cn);const gn=j.current;(gn.target==null||JTe({reported:et.version,expectation:gn}))&&(E(!1),L(null),j.current={target:null,sourceBuild:!1})}),rt=window.api.updater.onBackendUpdateCompleted(()=>{S(!1),_(null),n(!1),i(!1),C(!0),y(!0),setTimeout(()=>{C(!1)},6e3)});return e&&he(),()=>{ve(),Re(),tt(),ot(),bt(),xe(),qe(),rt(),Vt(),Dt(),vn(),Be()}},[e,he,B]);const De=()=>{y(!1)};return M?p.jsxs(qO,{tone:"failed",children:[p.jsx(a2,{tone:"failed",children:M.cancelledByRelaunch?"The update was cancelled":"The last update didn't finish"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:M.message}),p.jsx("p",{className:"mt-2 text-body text-ink",children:M.remedy.text}),(M.attempts??1)>1&&p.jsxs("p",{className:"mt-1 text-body-sm text-ink-muted",children:["Version ",M.targetVersion," has failed to install"," ",M.attempts," times on this machine."]}),p.jsx("p",{className:"mt-1 text-body-sm text-ink-muted",children:"This is also recorded in Settings, under Application updates."}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>K(null),children:"Update later"}),p.jsx(we,{variant:"outline",size:"sm",onClick:()=>void he({manual:!0}),disabled:t,children:t?"Checking...":"Check for updates"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>Y(M.remedy.url),children:"Open download page"})]}),M.detail&&p.jsx(mx,{detail:M.detail})]}):N?p.jsxs(qO,{role:"alert",children:[p.jsx(a2,{children:"The update is still installing"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:N.message}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>D(null),children:"Keep using Local Operator (cancels the install)"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void fe(),children:"Quit and let the update finish"})]}),N.detail&&p.jsx(mx,{detail:N.detail})]}):t?p.jsxs(qO,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:r?"Updating server":"Checking for updates"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:r?"Please wait while the server is being updated. The server will temporarily go offline while it restarts to apply the update.":"Please wait while we check for available updates..."}),p.jsx(Zre,{children:p.jsx(Wee,{})})]}):g?p.jsx(Ry,{open:v,autoHideDuration:6e3,onClose:De,variant:"danger",children:g}):V?p.jsxs(qO,{tone:"failed",children:[p.jsx(a2,{tone:"failed",children:Qit[V.code]??"The update wasn't installed"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:V.message}),p.jsx("p",{className:"mt-2 text-body text-ink",children:V.remedy.text}),V.remedy.command&&p.jsx(o2,{command:V.remedy.command}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>W(null),children:"Update later"}),V.remedy.url?p.jsx(we,{variant:"primary",size:"sm",onClick:()=>Y(V.remedy.url),children:"Open download page"}):p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void he({manual:!0}),disabled:t,children:t?"Checking...":"Check for updates"})]}),V.detail&&p.jsx(mx,{detail:V.detail})]}):Q&&A?p.jsxs(qO,{children:[p.jsx(a2,{children:"The server needs updating by hand"}),p.jsx("p",{className:"mb-2 text-body text-ink",children:A.message}),A.sourceBuild===!0?p.jsxs(p.Fragment,{children:[A.command?p.jsx(o2,{command:A.command}):null,p.jsx(uD,{command:!!A.command,sourceBuild:!0}),p.jsx(Yre,{className:"mt-2",latestVersion:A.latestVersion,currentVersion:A.currentVersion})]}):p.jsxs(p.Fragment,{children:[p.jsx(Yre,{latestVersion:A.latestVersion,currentVersion:A.currentVersion}),A.command?p.jsx(o2,{command:A.command}):null,p.jsx(uD,{command:!!A.command,sourceBuild:!1})]}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>{E(!1),L(null)},children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void ae(),disabled:t,children:t?"Checking...":"Check for updates"})]}),A.detail&&p.jsx(mx,{detail:A.detail})]}):s&&!f&&o?p.jsxs(p.Fragment,{children:[p.jsxs(qO,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Update available"}),p.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Version ",o.version," is available. You are currently using version ",b,"."]}),o.releaseNotes&&p.jsxs("div",{className:I("mt-2 text-body text-ink-muted",Eit),children:["Release notes:"," ",typeof o.releaseNotes=="string"?p.jsxs(p.Fragment,{children:[Tit(Ait(o.releaseNotes,400)),o.releaseNotes.length>400&&p.jsx("a",{href:Hre(o),target:"_blank",rel:"noopener noreferrer",className:"ml-2",children:"View full release notes"})]}):p.jsx("a",{href:Hre(o),target:"_blank",rel:"noopener noreferrer",children:"See release notes on GitHub"})]}),c&&d&&p.jsxs(Zre,{children:[p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Downloading: ",Math.round(d.percent),"%"]}),p.jsx(Wee,{value:d.percent,className:"mt-2"}),p.jsxs("p",{className:"mt-1 text-mono-sm text-ink-dim",children:[Math.round(d.transferred/1024)," KB of"," ",Math.round(d.total/1024)," KB"]})]}),p.jsx(zO,{children:!c&&p.jsxs(p.Fragment,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:Ve,disabled:c,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:se,disabled:c,children:"Download update"})]})})]}),p.jsxs(Ry,{open:v,autoHideDuration:6e3,onClose:De,variant:"info",children:["A new update is available: v",o.version]})]}):f&&o?p.jsxs(p.Fragment,{children:[p.jsxs(qO,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Update ready to install"}),p.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Version ",o.version," has been downloaded. You are currently using version ",b,"."]}),p.jsx("p",{className:"mt-2 text-body text-ink-muted",children:"Installing closes the app for a few minutes while the update is verified and put in place. Don't reopen it until it starts by itself. Opening it while the update is installing cancels the install."}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:Ve,disabled:q,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void me(),disabled:q,children:q?"Preparing to install...":"Install now"})]})]}),p.jsx(Ry,{open:v,autoHideDuration:6e3,onClose:De,variant:"success",children:"Update downloaded and ready to install"})]}):x&&k?p.jsxs(p.Fragment,{children:[p.jsxs(qO,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Server update available"}),p.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Server version ",k.latestVersion," is available. You are currently using version ",k.currentVersion,"."]}),p.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"Updating the server will improve AI functionality, improve security, and fix bugs."}),k.canManageUpdate?p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:ke,disabled:t,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:Te,disabled:t,children:t?"Updating...":"Update server"})]}):p.jsxs(p.Fragment,{children:[p.jsx("p",{className:"mt-4 text-body text-ink",children:k.remedy??"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip:"}),k.updateCommand&&p.jsx(o2,{command:k.updateCommand}),p.jsx(uD,{command:!!k.updateCommand,sourceBuild:k.sourceBuild===!0}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:ke,disabled:t,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void ae(),disabled:t,children:t?"Checking...":"Check for updates"})]}),k.detail&&p.jsx(mx,{detail:k.detail})]})]}),k.canManageUpdate&&p.jsxs(Ry,{open:v,autoHideDuration:6e3,onClose:De,variant:"info",children:["A new server update is available: v",k.latestVersion]})]}):P?p.jsx(Ry,{open:!0,autoHideDuration:6e3,onClose:()=>C(!1),variant:"success",children:"Server update completed successfully"}):null},Ait=(e,t)=>e.length<=t?e:`${e.substring(0,t)}...`,Hre=e=>{if(e.releaseNotes&&typeof e.releaseNotes!="string"){const t=e.releaseNotes,n=`https://github.com/damianvtran/local-operator-ui/releases/tag/v${e.version}`;return t.path||n}return`https://github.com/damianvtran/local-operator-ui/releases/tag/v${e.version}`},e_e=/\s+/,Xit=/[\\/]+$/,Dit=/[\\/]/,t_e=`
744
+ `,c="/",u="*",d="",h="comment",f="declaration";cD=function(g,m){if(typeof g!="string")throw new TypeError("First argument must be a string");if(!g)return[];m=m||{};var v=1,y=1;function b(A){var L=A.match(t);L&&(v+=L.length);var j=A.lastIndexOf(l);y=~j?A.length-j:y+A.length}function T(){var A={line:v,column:y};return function(L){return L.position=new x(A),_(),L}}function x(A){this.start=A,this.end={line:v,column:y},this.source=m.source}x.prototype.content=g;function S(A){var L=new Error(m.source+":"+v+":"+y+": "+A);if(L.reason=A,L.filename=m.source,L.line=v,L.column=y,L.source=g,!m.silent)throw L}function k(A){var L=A.exec(g);if(L){var j=L[0];return b(j),g=g.slice(j.length),L}}function _(){k(n)}function P(A){var L;for(A=A||[];L=C();)L!==!1&&A.push(L);return A}function C(){var A=T();if(!(c!=g.charAt(0)||u!=g.charAt(1))){for(var L=2;d!=g.charAt(L)&&(u!=g.charAt(L)||c!=g.charAt(L+1));)++L;if(L+=2,d===g.charAt(L-1))return S("End of comment missing");var j=g.slice(2,L-2);return y+=2,b(j),g=g.slice(L),y+=2,A({type:h,comment:j})}}function Q(){var A=T(),L=k(r);if(L){if(C(),!k(i))return S("property missing ':'");var j=k(s),q=A({type:f,property:O(L[0].replace(e,d)),value:j?O(j[0].replace(e,d)):d});return k(a),q}}function E(){var A=[];P(A);for(var L;L=Q();)L!==!1&&(A.push(L),P(A));return A}return _(),E()};function O(g){return g?g.replace(o,d):d}return cD}var jre;function wit(){if(jre)return Kv;jre=1;var e=Kv&&Kv.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Kv,"__esModule",{value:!0}),Kv.default=n;var t=e(bit());function n(r,i){var s=null;if(!r||typeof r!="string")return s;var a=(0,t.default)(r),o=typeof i=="function";return a.forEach(function(l){if(l.type==="declaration"){var c=l.property,u=l.value;o?i(c,u,l):u&&(s=s||{},s[c]=u)}}),s}return Kv}var px={},qre;function xit(){if(qre)return px;qre=1,Object.defineProperty(px,"__esModule",{value:!0}),px.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||e.test(c)},a=function(c,u){return u.toUpperCase()},o=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),s(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(i,o):c=c.replace(r,o),c.replace(t,a))};return px.camelCase=l,px}var gx,zre;function YTe(){if(zre)return gx;zre=1;var e=gx&&gx.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(wit()),n=xit();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,n.camelCase)(o,s)]=l)}),a}return r.default=r,gx=r,gx}var Ure;function ZTe(){return Ure||(Ure=1,function(e){var t=Ox&&Ox.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(e,"__esModule",{value:!0}),e.returnFirstArg=e.canTextBeChildOfNode=e.ELEMENTS_WITH_NO_TEXT_CHILDREN=e.PRESERVE_CUSTOM_ATTRIBUTES=void 0,e.isCustomComponent=s,e.setStyleProp=o;var n=qSe(),r=t(YTe()),i=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function s(u,d){return u.includes("-")?!i.has(u):!!(d&&typeof d.is=="string")}var a={reactCompat:!0};function o(u,d){if(typeof u=="string"){if(!u.trim()){d.style={};return}try{d.style=(0,r.default)(u,a)}catch{d.style={}}}}e.PRESERVE_CUSTOM_ATTRIBUTES=Number(n.version.split(".")[0])>=16,e.ELEMENTS_WITH_NO_TEXT_CHILDREN=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);var l=function(u){return!e.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(u.name)};e.canTextBeChildOfNode=l;var c=function(u){return u};e.returnFirstArg=c}(Ox)),Ox}var Wre;function HTe(){if(Wre)return s2;Wre=1,Object.defineProperty(s2,"__esModule",{value:!0}),s2.default=s;var e=yit(),t=ZTe(),n=["checked","value"],r=["input","select","textarea"],i={reset:!0,submit:!0};function s(o,l){o===void 0&&(o={});var c={},u=!!(o.type&&i[o.type]);for(var d in o){var h=o[d];if((0,e.isCustomAttribute)(d)){c[d]=h;continue}var f=d.toLowerCase(),O=a(f);if(O){var g=(0,e.getPropertyInfo)(O);switch(n.includes(O)&&r.includes(l)&&!u&&(O=a("default"+f)),c[O]=h,g&&g.type){case e.BOOLEAN:c[O]=!0;break;case e.OVERLOADED_BOOLEAN:h===""&&(c[O]=!0);break}continue}t.PRESERVE_CUSTOM_ATTRIBUTES&&(c[d]=h)}return(0,t.setStyleProp)(o.style,c),c}function a(o){return e.possibleStandardNames[o]}return s2}var Jv={},Gre;function Sit(){if(Gre)return Jv;Gre=1;var e=Jv&&Jv.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(Jv,"__esModule",{value:!0}),Jv.default=s;var t=qSe(),n=e(HTe()),r=ZTe(),i={cloneElement:t.cloneElement,createElement:t.createElement,isValidElement:t.isValidElement};function s(o,l){l===void 0&&(l={});for(var c=[],u=typeof l.replace=="function",d=l.transform||r.returnFirstArg,h=l.library||i,f=h.cloneElement,O=h.createElement,g=h.isValidElement,m=o.length,v=0;v<m;v++){var y=o[v];if(u){var b=l.replace(y,v);if(g(b)){m>1&&(b=f(b,{key:b.key||v})),c.push(d(b,y,v));continue}}if(y.type==="text"){var T=!y.data.trim().length;if(T&&y.parent&&!(0,r.canTextBeChildOfNode)(y.parent)||l.trim&&T)continue;c.push(d(y.data,y,v));continue}var x=y,S={};a(x)?((0,r.setStyleProp)(x.attribs.style,x.attribs),S=x.attribs):x.attribs&&(S=(0,n.default)(x.attribs,x.name));var k=void 0;switch(y.type){case"script":case"style":y.children[0]&&(S.dangerouslySetInnerHTML={__html:y.children[0].data});break;case"tag":y.name==="textarea"&&y.children[0]?S.defaultValue=y.children[0].data:y.children&&y.children.length&&(k=s(y.children,l));break;default:continue}m>1&&(S.key=v),c.push(d(O(y.name,S,k),y,v))}return c.length===1?c[0]:c}function a(o){return r.PRESERVE_CUSTOM_ATTRIBUTES&&o.type==="tag"&&(0,r.isCustomComponent)(o.name,o.attribs)}return Jv}var Vre;function $it(){return Vre||(Vre=1,function(e){var t=hx&&hx.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(e,"__esModule",{value:!0}),e.htmlToDOM=e.domToReact=e.attributesToProps=e.Text=e.ProcessingInstruction=e.Element=e.Comment=void 0,e.default=o;var n=t(mit());e.htmlToDOM=n.default;var r=t(HTe());e.attributesToProps=r.default;var i=t(Sit());e.domToReact=i.default;var s=VTe();Object.defineProperty(e,"Comment",{enumerable:!0,get:function(){return s.Comment}}),Object.defineProperty(e,"Element",{enumerable:!0,get:function(){return s.Element}}),Object.defineProperty(e,"ProcessingInstruction",{enumerable:!0,get:function(){return s.ProcessingInstruction}}),Object.defineProperty(e,"Text",{enumerable:!0,get:function(){return s.Text}});var a={lowerCaseAttributeNames:!1};function o(l,c){if(typeof l!="string")throw new TypeError("First argument must be a string");return l?(0,i.default)((0,n.default)(l,c?.htmlparser2||a),c):[]}}(hx)),hx}var kit=$it();const Bre=en(kit),Tit=Bre.default||Bre,_it=/^v/i,KTe=(e,t)=>{const n=o=>o.trim().replace(_it,""),r=n(e),i=n(t);if(r===i)return!0;if(r.includes("-")||i.includes("-"))return!1;const s=r.split(".").map(Number),a=i.split(".").map(Number);for(let o=0;o<Math.max(s.length,a.length);o++){const l=s[o]??0,c=a[o]??0;if(!Number.isFinite(l)||!Number.isFinite(c))return!1;if(l>c)return!0;if(l<c)return!1}return!0},JTe=e=>{const{target:t,sourceBuild:n}=e.expectation;return n?!0:t==null?!1:e.reported!=null&&KTe(e.reported,t)},Pit=e=>e.manual===!0&&JTe({reported:e.currentVersion,expectation:e.expectation}),Cit=/cannot find .* in the latest release artifacts/i,Qit={"installed-bundle-not-sealed":"This app can't update itself","download-verification-failed":"The update couldn't be verified","artifact-metadata-missing":"The update couldn't be verified","insufficient-disk-space":"Not enough disk space to update"},qO=({className:e,tone:t="notice",role:n,...r})=>p.jsx("div",{role:n??(t==="failed"?"alert":"status"),className:I("fixed top-4 right-4 z-50 w-100 max-w-[calc(100vw-2rem)]","rounded-lg bg-elevated p-4 shadow-overlay","[&_a]:text-accent [&_a]:underline-offset-4 [&_a]:hover:underline",e),...r}),a2=({children:e,tone:t="notice"})=>p.jsxs("h2",{className:I("mb-3 flex items-center gap-2 text-heading text-ink"),children:[t==="failed"&&p.jsx(EV,{className:"size-4 shrink-0 text-danger","aria-hidden":!0}),e]}),mx=({detail:e})=>{const[t,n]=w.useState(!1);return p.jsxs("div",{className:"mt-4 flex items-start gap-2",children:[p.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:"Details:"}),p.jsx("span",{className:"min-w-0 flex-1 break-words font-mono text-mono-sm text-ink-dim",children:Oit(e)}),p.jsxs(we,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard.writeText(e).then(()=>n(!0)).catch(()=>{})},children:[t?p.jsx(bc,{}):p.jsx(hv,{}),t?"Copied":"Copy details"]})]})},o2=({command:e})=>{const[t,n]=w.useState(!1);return p.jsxs("div",{className:"mt-2 flex items-start gap-2",children:[p.jsx("code",{className:"min-w-0 flex-1 rounded-sm bg-sunken p-2 text-mono-sm break-all text-ink",children:e}),p.jsxs(we,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(e).then(()=>n(!0)).catch(()=>{})},children:[t?p.jsx(bc,{}):p.jsx(hv,{}),t?"Copied":"Copy command"]})]})},Eit=["[&_:is(h1,h2,h3,h4,h5,h6)]:mt-3 [&_:is(h1,h2,h3,h4,h5,h6)]:mb-1 [&_:is(h1,h2,h3,h4,h5,h6)]:font-semibold [&_:is(h1,h2,h3,h4,h5,h6)]:text-ink","[&_h1]:text-heading [&_h2]:text-heading [&_h3]:text-body [&_h4]:text-body [&_h5]:text-body-sm [&_h6]:text-body-sm","[&_p]:my-1.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0","[&_:is(ul,ol)]:my-1.5 [&_:is(ul,ol)]:pl-5 [&_ul_li]:list-disc [&_ol_li]:list-decimal [&_li]:my-0.5","[&_code]:rounded-xs [&_code]:bg-sunken [&_code]:px-1 [&_code]:font-mono [&_code]:text-mono-sm"].join(" "),uD=({command:e,sourceBuild:t})=>t&&!e?p.jsx("p",{className:"mt-2 text-body text-ink",children:"This server follows this machine's checkout, so there is no command to run here."}):p.jsx("p",{className:"mt-2 text-body text-ink",children:t?"Run this in a terminal. It rebuilds the server from this machine's checkout, so the version it reports afterwards is your checkout's rather than the published release.":e?"Run this in a terminal, then check for updates again to pick up the new server version.":"Then check for updates again to pick up the new server version."}),Yre=({latestVersion:e,currentVersion:t,className:n})=>e?p.jsxs("p",{className:I("mb-2 text-body text-ink-muted",n),children:[`Server version ${e} is available.`,t?` You are currently using version ${t}.`:""]}):null,zO=({className:e,...t})=>p.jsx("div",{className:I("mt-6 flex flex-wrap justify-end gap-3",e),...t}),Zre=({className:e,...t})=>p.jsx("div",{className:I("mt-4 mb-2",e),...t}),Rit=({autoCheck:e=!0})=>{const[t,n]=w.useState(!1),[r,i]=w.useState(!1),[s,a]=w.useState(!1),[o,l]=w.useState(null),[c,u]=w.useState(!1),[d,h]=w.useState(null),[f,O]=w.useState(!1),[g,m]=w.useState(null),[v,y]=w.useState(!1),[b,T]=w.useState("unknown"),[x,S]=w.useState(!1),[k,_]=w.useState(null),[P,C]=w.useState(!1),[Q,E]=w.useState(!1),[A,L]=w.useState(null),j=w.useRef({target:null,sourceBuild:!1}),[q,z]=w.useState(!1),[V,W]=w.useState(null),[M,K]=w.useState(null),[N,D]=w.useState(null),{shouldShowUpdate:B,deferUpdate:G}=wrt(),ee=w.useRef(null);w.useEffect(()=>{ee.current=k},[k]),w.useEffect(()=>{window.api.systemInfo.getAppVersion().then(ve=>T(ve)).catch(()=>T("unknown"))},[]);const he=w.useCallback(async ve=>{try{n(!0),m(null),await window.api.updater.checkForUpdates(ve)}catch(Re){const tt=Re instanceof Error?Re.message:String(Re);if(Cit.test(tt)){a(!1),l(null),console.warn(`Error checking for updates: ${tt}`);return}m(`Error checking for updates: ${tt}`),y(!0)}finally{n(!1)}},[]),ae=w.useCallback(async()=>{try{n(!0),m(null),await window.api.updater.checkForAllUpdates({manual:!0})}catch(ve){m(`Error checking for updates: ${ve instanceof Error?ve.message:String(ve)}`),y(!0)}finally{n(!1)}},[]),se=w.useCallback(async()=>{try{u(!0),m(null),await window.api.updater.downloadUpdate()}catch(ve){m(`Error downloading update: ${ve instanceof Error?ve.message:String(ve)}`),u(!1),y(!0)}},[]),me=w.useCallback(async()=>{z(!0),m(null);try{await window.api.updater.quitAndInstall()||z(!1)}catch(ve){z(!1),m(`Error starting the update: ${ve instanceof Error?ve.message:String(ve)}`),y(!0)}},[]),fe=w.useCallback(async()=>{try{await window.api.updater.quitForUpdateInstall()}catch(ve){m(`Error quitting for the update: ${ve instanceof Error?ve.message:String(ve)}`),y(!0)}},[]),Y=w.useCallback(ve=>{ve&&window.api.openExternal(ve)},[]),Te=w.useCallback(async()=>{try{n(!0),i(!0),m(null),await window.api.updater.updateBackend(ee.current?.latestVersion)}catch(ve){m(`Error updating server: ${ve instanceof Error?ve.message:String(ve)}`),y(!0),n(!1),i(!1)}},[]),ke=w.useCallback(()=>{k&&(G(Ay.BACKEND,k.latestVersion),y(!1),S(!1),_(null))},[G,k]),Ve=w.useCallback(()=>{o&&(G(Ay.UI,o.version),y(!1),a(!1),O(!1))},[G,o]);w.useEffect(()=>{const ve=window.api.updater.onUpdateAvailable(et=>{B(Ay.UI,et.version)&&(K(null),a(!0),l(et),y(!0))}),Re=window.api.updater.onUpdateNotAvailable(()=>{a(!1),l(null)}),tt=window.api.updater.onUpdateDownloaded(et=>{u(!1),B(Ay.UI,et.version)&&(K(null),O(!0),l(et),y(!0))}),ot=window.api.updater.onUpdateError(et=>{et.includes("manually")?(E(!0),L({message:"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip.",command:""}),y(!0)):(m(et),n(!1),u(!1),y(!0))}),Vt=window.api.updater.onBackendUpdateManualRequired(et=>{j.current={target:et.latestVersion??ee.current?.latestVersion??null,sourceBuild:et.sourceBuild===!0},E(!0),L(et),n(!1),i(!1),S(!1),_(null)}),Dt=window.api.updater.onUpdateInstallBlocked(et=>{W(et),n(!1),i(!1),u(!1)}),vn=window.api.updater.onUpdateInstallFailed(et=>{K(et),D(null),n(!1)}),Be=window.api.updater.onUpdateInstallInFlight(et=>{D(et),K(null),n(!1)}),bt=window.api.updater.onUpdateProgress(et=>{h(et)}),xe=window.api.updater.onBackendUpdateAvailable(et=>{if(Pit({manual:et.manual,currentVersion:et.currentVersion,expectation:j.current})&&(E(!1),L(null),j.current={target:null,sourceBuild:!1}),B(Ay.BACKEND,et.latestVersion)){const dt={...et,canManageUpdate:et.canManageUpdate??!et.updateCommand.includes("manually")};S(!0),_(dt),y(!0)}}),qe=window.api.updater.onBackendUpdateNotAvailable(et=>{const dt=ee.current;S(cn=>dt&&KTe(et.version,dt.latestVersion)?(_(null),!1):cn);const gn=j.current;(gn.target==null||JTe({reported:et.version,expectation:gn}))&&(E(!1),L(null),j.current={target:null,sourceBuild:!1})}),rt=window.api.updater.onBackendUpdateCompleted(()=>{S(!1),_(null),n(!1),i(!1),C(!0),y(!0),setTimeout(()=>{C(!1)},6e3)});return e&&he(),()=>{ve(),Re(),tt(),ot(),bt(),xe(),qe(),rt(),Vt(),Dt(),vn(),Be()}},[e,he,B]);const De=()=>{y(!1)};return M?p.jsxs(qO,{tone:"failed",children:[p.jsx(a2,{tone:"failed",children:M.cancelledByRelaunch?"The update was cancelled":"The last update didn't finish"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:M.message}),p.jsx("p",{className:"mt-2 text-body text-ink",children:M.remedy.text}),(M.attempts??1)>1&&p.jsxs("p",{className:"mt-1 text-body-sm text-ink-muted",children:["Version ",M.targetVersion," has failed to install"," ",M.attempts," times on this machine."]}),p.jsx("p",{className:"mt-1 text-body-sm text-ink-muted",children:"This is also recorded in Settings, under Application updates."}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>K(null),children:"Update later"}),p.jsx(we,{variant:"outline",size:"sm",onClick:()=>void he({manual:!0}),disabled:t,children:t?"Checking...":"Check for updates"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>Y(M.remedy.url),children:"Open download page"})]}),M.detail&&p.jsx(mx,{detail:M.detail})]}):N?p.jsxs(qO,{role:"alert",children:[p.jsx(a2,{children:"The update is still installing"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:N.message}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>D(null),children:"Keep using Local Operator (cancels the install)"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void fe(),children:"Quit and let the update finish"})]}),N.detail&&p.jsx(mx,{detail:N.detail})]}):t?p.jsxs(qO,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:r?"Updating server":"Checking for updates"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:r?"Please wait while the server is being updated. The server will temporarily go offline while it restarts to apply the update.":"Please wait while we check for available updates..."}),p.jsx(Zre,{children:p.jsx(Wee,{})})]}):g?p.jsx(Ry,{open:v,autoHideDuration:6e3,onClose:De,variant:"danger",children:g}):V?p.jsxs(qO,{tone:"failed",children:[p.jsx(a2,{tone:"failed",children:V.heading??Qit[V.code]??"The update wasn't installed"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:V.message}),p.jsx("p",{className:"mt-2 text-body text-ink",children:V.remedy.text}),V.remedy.command&&p.jsx(o2,{command:V.remedy.command}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>W(null),children:V.dismissLabel??"Update later"}),V.remedy.url?p.jsx(we,{variant:"primary",size:"sm",onClick:()=>Y(V.remedy.url),children:"Open download page"}):p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void he({manual:!0}),disabled:t,children:t?"Checking...":"Check for updates"})]}),V.detail&&p.jsx(mx,{detail:V.detail})]}):Q&&A?p.jsxs(qO,{children:[p.jsx(a2,{children:"The server needs updating by hand"}),p.jsx("p",{className:"mb-2 text-body text-ink",children:A.message}),A.sourceBuild===!0?p.jsxs(p.Fragment,{children:[A.command?p.jsx(o2,{command:A.command}):null,p.jsx(uD,{command:!!A.command,sourceBuild:!0}),p.jsx(Yre,{className:"mt-2",latestVersion:A.latestVersion,currentVersion:A.currentVersion})]}):p.jsxs(p.Fragment,{children:[p.jsx(Yre,{latestVersion:A.latestVersion,currentVersion:A.currentVersion}),A.command?p.jsx(o2,{command:A.command}):null,p.jsx(uD,{command:!!A.command,sourceBuild:!1})]}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>{E(!1),L(null)},children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void ae(),disabled:t,children:t?"Checking...":"Check for updates"})]}),A.detail&&p.jsx(mx,{detail:A.detail})]}):s&&!f&&o?p.jsxs(p.Fragment,{children:[p.jsxs(qO,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Update available"}),p.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Version ",o.version," is available. You are currently using version ",b,"."]}),o.releaseNotes&&p.jsxs("div",{className:I("mt-2 text-body text-ink-muted",Eit),children:["Release notes:"," ",typeof o.releaseNotes=="string"?p.jsxs(p.Fragment,{children:[Tit(Ait(o.releaseNotes,400)),o.releaseNotes.length>400&&p.jsx("a",{href:Hre(o),target:"_blank",rel:"noopener noreferrer",className:"ml-2",children:"View full release notes"})]}):p.jsx("a",{href:Hre(o),target:"_blank",rel:"noopener noreferrer",children:"See release notes on GitHub"})]}),c&&d&&p.jsxs(Zre,{children:[p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Downloading: ",Math.round(d.percent),"%"]}),p.jsx(Wee,{value:d.percent,className:"mt-2"}),p.jsxs("p",{className:"mt-1 text-mono-sm text-ink-dim",children:[Math.round(d.transferred/1024)," KB of"," ",Math.round(d.total/1024)," KB"]})]}),p.jsx(zO,{children:!c&&p.jsxs(p.Fragment,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:Ve,disabled:c,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:se,disabled:c,children:"Download update"})]})})]}),p.jsxs(Ry,{open:v,autoHideDuration:6e3,onClose:De,variant:"info",children:["A new update is available: v",o.version]})]}):f&&o?p.jsxs(p.Fragment,{children:[p.jsxs(qO,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Update ready to install"}),p.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Version ",o.version," has been downloaded. You are currently using version ",b,"."]}),p.jsx("p",{className:"mt-2 text-body text-ink-muted",children:"Installing closes the app for a few minutes while the update is verified and put in place. Don't reopen it until it starts by itself. Opening it while the update is installing cancels the install."}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:Ve,disabled:q,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void me(),disabled:q,children:q?"Preparing to install...":"Install now"})]})]}),p.jsx(Ry,{open:v,autoHideDuration:6e3,onClose:De,variant:"success",children:"Update downloaded and ready to install"})]}):x&&k?p.jsxs(p.Fragment,{children:[p.jsxs(qO,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Server update available"}),p.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Server version ",k.latestVersion," is available. You are currently using version ",k.currentVersion,"."]}),p.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"Updating the server will improve AI functionality, improve security, and fix bugs."}),k.canManageUpdate?p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:ke,disabled:t,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:Te,disabled:t,children:t?"Updating...":"Update server"})]}):p.jsxs(p.Fragment,{children:[p.jsx("p",{className:"mt-4 text-body text-ink",children:k.remedy??"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip:"}),k.updateCommand&&p.jsx(o2,{command:k.updateCommand}),p.jsx(uD,{command:!!k.updateCommand,sourceBuild:k.sourceBuild===!0}),p.jsxs(zO,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:ke,disabled:t,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void ae(),disabled:t,children:t?"Checking...":"Check for updates"})]}),k.detail&&p.jsx(mx,{detail:k.detail})]})]}),k.canManageUpdate&&p.jsxs(Ry,{open:v,autoHideDuration:6e3,onClose:De,variant:"info",children:["A new server update is available: v",k.latestVersion]})]}):P?p.jsx(Ry,{open:!0,autoHideDuration:6e3,onClose:()=>C(!1),variant:"success",children:"Server update completed successfully"}):null},Ait=(e,t)=>e.length<=t?e:`${e.substring(0,t)}...`,Hre=e=>{if(e.releaseNotes&&typeof e.releaseNotes!="string"){const t=e.releaseNotes,n=`https://github.com/damianvtran/local-operator-ui/releases/tag/v${e.version}`;return t.path||n}return`https://github.com/damianvtran/local-operator-ui/releases/tag/v${e.version}`},e_e=/\s+/,Xit=/[\\/]+$/,Dit=/[\\/]/,t_e=`
745
745
 
746
746
  `,Iit=" — cancel with wake(",Nit=120,Fit=/(?:\u001b[\]PX^_]|[\u009d\u0090\u0098\u009e\u009f])(?:(?!\u0007|\u001b\\|\u009c)[\s\S])*(?:\u0007|\u001b\\|\u009c|$)|(?:\u001b\[|\u009b)[0-?]*[ -/]*[@-~]|(?:\u001b\[|\u009b)[0-?]*[ -/]*$|\u001b[ -/]+[0-~]|\u001b[@-Z\\-_]|\u001b$|[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g,Mit=new RegExp("\\p{Cf}","gu"),Lit=4096;function fq(e){return e==null?"":(typeof e=="string"?e:String(e)).replace(Fit,"").replace(Mit,"").split(e_e).filter(Boolean).join(" ").slice(0,Nit)}function n_e(e){if(e.conversationName)return{name:e.conversationName,quoted:!0};const t=e.cwd.replace(Xit,"");if(t){const n=t.split(Dit).pop()??"";if(n)return{name:`${n}/`,quoted:!1}}return e.sessionId?{name:e.sessionId.slice(0,8),quoted:!1}:{name:"",quoted:!1}}function r_e(e){const{name:t,quoted:n}=n_e(e);return t?n?`"${t}"`:t:e.pid?`pid ${e.pid}`:"another session"}function i_e(e){const{name:t,quoted:n}=n_e(e),r=[];return e.pid&&r.push(`pid ${e.pid}`),e.modelLabel&&r.push(e.modelLabel),t?[n?`"${t}"`:t,...r].join(" · "):r.length>0?r.join(" · "):"another session"}function jit(e,t){return t.trim()?!0:i_e(e)!==r_e(e)}function qit(e){for(const t of e.slice(0,Lit).split(`
747
747
  `)){const n=fq(t);if(n)return n}return""}function Kre(e,t){const n=r_e(e),r=qit(t);return r?`${n} · ${r}`:n}function zit(e,t){return e.pid===t.pid&&e.conversationName===t.conversationName&&e.cwd===t.cwd&&e.sessionId===t.sessionId&&e.modelLabel===t.modelLabel}const Uit=/^<peer-session-message\s+((?:[^>"']|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/peer-session-message>\s*$/,Wit=/<\/?peer-session-message(?:[^>"']|"[^"]*"|'[^']*')*>/g,Git=/^<peer-session-message[^>]*>/,Vit=/([a-zA-Z_]+)\s*=\s*(?:'([^']*)'|"([^"]*)"|([^\s>]+))/g;function Bit(e){const t=String(e.text??e.detail??""),n=Uit.exec(t.trim()),r={};if(n)for(const c of n[1].matchAll(Vit))r[c[1]]=c[2]??c[3]??c[4]??"";const i=n?n[2]:"",a=(String(e.body??"").trim()||i||(n?"":t.trim().replace(Git,""))).replace(Wit,"").trim(),o=e.sender??{},l=(c,u)=>fq(c)||fq(u);return{body:a,sender:{pid:l(o.pid,r.from_pid),conversationName:l(o.conversation_name,r.conversation),cwd:l(o.cwd,void 0),sessionId:l(o.session_id,void 0),modelLabel:l(o.model_label,r.model)}}}function Yit(e){return!!e.wake_catchup}function Zit(e){let t=e.split(t_e)[0]??"";t=t.split(e_e).filter(Boolean).join(" "),t=t.split(Iit)[0];const n="(alarm) ";for(;t.startsWith(n);)t=t.slice(n.length);const r="Scheduled wake ";return t.startsWith(r)&&(t=t.slice(r.length)),t.trim()}function Hit(e){const t=e.indexOf(t_e);return t===-1?"":e.slice(t+2).trim()}const Kit=new Set(["command","path","file_path","url","pattern","query","name","target","message"]),Jre="mcp__",Jit=/^\/(?:Users|home)\/[^/]+\//,est=/\s+/;function s_e(e){return!e.startsWith("/")||e.includes(" ")?e:e.replace(Jit,"~/")}function rR(e){return typeof e=="string"?s_e(e.trim()).replace(/\n/g," ").trim():typeof e=="number"||typeof e=="boolean"?String(e):""}function tst(e){return e.now?"now":e.wake===!1?"quiet":"wake"}function nst(e){const t=e.pid;if(typeof t=="number"&&Number.isFinite(t))return`pid ${t}`;const n=String(e.session??"").trim();return n?`session ${n}`:String(e.target??"").split(est).filter(Boolean).join(" ")||"?"}function rst(e){return[tst(e),rR(nst(e))||"?",rR(e.message)].filter(Boolean).join(" · ")}function ist(e,t){const n=e.trim();if(!t)return n;if(n==="send")return rst(t)||n;let r=Object.entries(t).filter(([i])=>Kit.has(i)).map(([,i])=>rR(i)).filter(Boolean);return r.length===0&&(r=Object.values(t).map(rR).filter(Boolean)),r.slice(0,2).join(" ")||n}function Dk(e){const t=e.trim();if(!t.toLowerCase().startsWith(Jre))return t;const n=t.slice(Jre.length),r=n.indexOf("_");return r<=0?n||t:n.slice(r+1)||n}function a_e(e,t){return e===t||e===Dk(t)}const sst=/^(?:exit code:?\s*-?\d*|\(empty\)|--- (?:stdout|stderr) ---)$/,ast="… ";function ost(e){if(!e)return null;for(const t of e.split(`
@@ -1145,7 +1145,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
1145
1145
  `,before:f,encode:["$"],...u.current()})),O()}return f+=u.move(`
1146
1146
  `),c&&(f+=u.move(c+`
1147
1147
  `)),f+=u.move(d),h(),f}function r(s,a,o){let l=s.value||"",c=1;for(t||c++;new RegExp("(^|[^$])"+"\\$".repeat(c)+"([^$]|$)").test(l);)c++;const u="$".repeat(c);/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^\$|\$$/.test(l))&&(l=" "+l+" ");let d=-1;for(;++d<o.unsafe.length;){const h=o.unsafe[d];if(!h.atBreak)continue;const f=o.compilePattern(h);let O;for(;O=f.exec(l);){let g=O.index;l.codePointAt(g)===10&&l.codePointAt(g-1)===13&&g--,l=l.slice(0,g)+" "+l.slice(O.index+1)}}return u+l+u}function i(){return"$"}}const E5t={tokenize:R5t,concrete:!0,name:"mathFlow"},Jhe={tokenize:A5t,partial:!0};function R5t(e,t,n){const r=this,i=r.events[r.events.length-1],s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let a=0;return o;function o(y){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(y)}function l(y){return y===36?(e.consume(y),a++,l):a<2?n(y):(e.exit("mathFlowFenceSequence"),dr(e,c,"whitespace")(y))}function c(y){return y===null||On(y)?d(y):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(y))}function u(y){return y===null||On(y)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),d(y)):y===36?n(y):(e.consume(y),u)}function d(y){return e.exit("mathFlowFence"),r.interrupt?t(y):e.attempt(Jhe,h,m)(y)}function h(y){return e.attempt({tokenize:v,partial:!0},m,f)(y)}function f(y){return(s?dr(e,O,"linePrefix",s+1):O)(y)}function O(y){return y===null?m(y):On(y)?e.attempt(Jhe,h,m)(y):(e.enter("mathFlowValue"),g(y))}function g(y){return y===null||On(y)?(e.exit("mathFlowValue"),O(y)):(e.consume(y),g)}function m(y){return e.exit("mathFlow"),t(y)}function v(y,b,T){let x=0;return dr(y,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(P){return y.enter("mathFlowFence"),y.enter("mathFlowFenceSequence"),k(P)}function k(P){return P===36?(x++,y.consume(P),k):x<a?T(P):(y.exit("mathFlowFenceSequence"),dr(y,_,"whitespace")(P))}function _(P){return P===null||On(P)?(y.exit("mathFlowFence"),b(P)):T(P)}}}function A5t(e,t,n){const r=this;return i;function i(a){return a===null?t(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function X5t(e){let n=(e||{}).singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:D5t,previous:I5t,name:"mathText"};function r(i,s,a){let o=0,l,c;return u;function u(g){return i.enter("mathText"),i.enter("mathTextSequence"),d(g)}function d(g){return g===36?(i.consume(g),o++,d):o<2&&!n?a(g):(i.exit("mathTextSequence"),h(g))}function h(g){return g===null?a(g):g===36?(c=i.enter("mathTextSequence"),l=0,O(g)):g===32?(i.enter("space"),i.consume(g),i.exit("space"),h):On(g)?(i.enter("lineEnding"),i.consume(g),i.exit("lineEnding"),h):(i.enter("mathTextData"),f(g))}function f(g){return g===null||g===32||g===36||On(g)?(i.exit("mathTextData"),h(g)):(i.consume(g),f)}function O(g){return g===36?(i.consume(g),l++,O):l===o?(i.exit("mathTextSequence"),i.exit("mathText"),s(g)):(c.type="mathTextData",f(g))}}}function D5t(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function I5t(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function N5t(e){return{flow:{36:E5t},text:{36:X5t(e)}}}const F5t={};function M5t(e){const t=this,n=e||F5t,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(N5t(n)),s.push(C5t()),a.push(Q5t(n))}const L5t=e=>e.charCodeAt(e.length-1)===13?e.slice(0,-1):e,v5e=/^[ \t]*$/,j5t=/^ {0,3}(`{3,}|~{3,})/,y5e=/^ {0,3}(?:[-*+]|\d{1,9}[.)])(?:[ \t]|$)/,b5e=/^(?: {4}|\t)/,q5t=/^(?: {2,}|\t)/,z5t=()=>({source:"",cursor:0,blockStart:0,blankRunStart:-1,kind:"none",fence:null,blocks:[],revision:0}),U5t=e=>{e.source="",e.cursor=0,e.blockStart=0,e.blankRunStart=-1,e.kind="none",e.fence=null,e.blocks=[],e.revision+=1},efe=e=>b5e.test(e)?"indented-code":y5e.test(e)?"list":"other",W5t=(e,t)=>e==="list"?y5e.test(t)||q5t.test(t):e==="indented-code"?b5e.test(t):!1,G5t=(e,t)=>{let n=0;for(;n<3&&e.charCodeAt(n)===32;)n+=1;let r=0;for(;e[n+r]===t.char;)r+=1;return r<t.length?!1:v5e.test(e.slice(n+r))},V5t=(e,t)=>{(t.length<e.source.length||!t.startsWith(e.source))&&U5t(e),e.source=t;let n=e.cursor;for(;;){const r=t.indexOf(`
1148
- `,n);if(r===-1)break;const i=L5t(t.slice(n,r));if(e.fence){G5t(i,e.fence)&&(e.fence=null),n=r+1;continue}if(v5e.test(i)){e.blankRunStart<0&&(e.blankRunStart=n),n=r+1;continue}if(e.blankRunStart>=0){if(e.kind==="none"||!W5t(e.kind,i)){const s=t.slice(e.blockStart,e.blankRunStart);s.trim().length>0&&(e.blocks.push(s),e.revision+=1),e.blockStart=n,e.kind=efe(i)}e.blankRunStart=-1}else e.kind==="none"&&(e.kind=efe(i));if(e.kind!=="indented-code"){const s=j5t.exec(i);s&&(e.fence={char:s[1][0],length:s[1].length})}n=r+1}e.cursor=n},B5t=e=>{let t=e.length;for(;t>0;){const n=e.charCodeAt(t-1);if(n!==32&&n!==9&&n!==10&&n!==13)break;t-=1}return t},Kn="var(--color-ink)",nf="var(--color-ink-muted)",Xd="var(--color-surface)",VO="var(--color-elevated)",rf="var(--color-sunken)",io="var(--color-hairline)",BO="var(--color-control)",oy="var(--color-accent)",TS="var(--color-accent-wash)",Y5t="var(--color-on-accent)",Z5t="var(--color-info)",w5e="var(--color-info-wash)",H5t="var(--color-success)",x5e="var(--color-success-wash)",K5t="var(--color-warning)",OU="var(--color-warning-wash)",J5t="var(--color-warning-border)",zM="var(--color-danger)",pU="var(--color-danger-wash)",tfe=[TS,w5e,x5e,OU,pU],YO=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),e4t=()=>{const e={primaryColor:YO("--color-accent"),secondaryColor:YO("--color-success"),tertiaryColor:YO("--color-info"),mainBkg:YO("--color-elevated"),clusterBkg:YO("--color-sunken"),clusterBorder:YO("--color-hairline"),edgeLabelBackground:YO("--color-surface"),quadrant1Fill:YO("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:Xd,primaryTextColor:Kn,primaryBorderColor:BO,secondaryTextColor:Kn,secondaryBorderColor:io,tertiaryTextColor:Kn,tertiaryBorderColor:io,lineColor:nf,arrowheadColor:nf,textColor:Kn,secondBkg:rf,border1:BO,border2:io,labelColor:Kn,nodeBkg:VO,nodeBorder:BO,nodeTextColor:Kn,defaultLinkColor:nf,titleColor:Kn,noteBkgColor:OU,noteBorderColor:J5t,noteTextColor:Kn,actorBkg:VO,actorBorder:BO,actorTextColor:Kn,actorLineColor:io,signalColor:nf,signalTextColor:Kn,labelBoxBkgColor:VO,labelBoxBorderColor:io,labelTextColor:Kn,loopTextColor:Kn,activationBkgColor:TS,activationBorderColor:oy,sequenceNumberColor:Xd,sectionBkgColor:rf,sectionBkgColor2:Xd,altSectionBkgColor:rf,excludeBkgColor:rf,taskBkgColor:TS,taskBorderColor:BO,taskTextColor:Kn,taskTextLightColor:Kn,taskTextDarkColor:Kn,taskTextOutsideColor:Kn,taskTextClickableColor:oy,activeTaskBkgColor:TS,activeTaskBorderColor:oy,gridColor:io,doneTaskBkgColor:rf,doneTaskBorderColor:io,critBkgColor:pU,critBorderColor:zM,todayLineColor:oy,transitionColor:nf,transitionLabelColor:Kn,stateLabelColor:Kn,stateBkg:VO,labelBackgroundColor:Xd,compositeBackground:rf,altBackground:rf,compositeTitleBackground:VO,compositeBorder:io,innerEndBackground:Kn,specialStateColor:Kn,classText:Kn,attributeBackgroundColorOdd:Xd,attributeBackgroundColorEven:rf,rowOdd:Xd,rowEven:rf,errorBkgColor:pU,errorTextColor:zM,pieTitleTextColor:Kn,pieSectionTextColor:Kn,pieLegendTextColor:Kn,pieStrokeColor:Xd,pieOuterStrokeColor:io,requirementBackground:VO,requirementBorderColor:BO,requirementTextColor:Kn,relationColor:nf,relationLabelBackground:Xd,relationLabelColor:Kn,branchLabelColor:Y5t,commitLabelColor:Kn,commitLabelBackground:Xd,tagLabelColor:Kn,tagLabelBackground:TS,tagLabelBorder:BO,quadrant2Fill:w5e,quadrant3Fill:x5e,quadrant4Fill:OU,quadrant2TextFill:Kn,quadrant3TextFill:Kn,quadrant4TextFill:Kn,quadrantPointFill:oy,archEdgeColor:nf,archEdgeArrowColor:nf,archGroupBorderColor:io,scaleLabelColor:Kn,packet:{startByteColor:Kn,endByteColor:Kn,labelColor:Kn,titleColor:Kn,blockStrokeColor:BO,blockFillColor:VO},radar:{axisColor:nf,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:io,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Xd,titleColor:Kn,xAxisTitleColor:Kn,xAxisLabelColor:Kn,xAxisTickColor:io,xAxisLineColor:io,yAxisTitleColor:Kn,yAxisLabelColor:Kn,yAxisTickColor:io,yAxisLineColor:io,plotColorPalette:[oy,Z5t,H5t,K5t,zM].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=VO,t[`surfacePeer${n}`]=io;for(let n=0;n<8;n++)t[`fillType${n}`]=tfe[n%tfe.length];return{...t,...e}};let UM=null,nfe=null;const t4t=async e=>{UM||(UM=Ie(async()=>{const{default:n}=await import("./mermaid.core-CYc-R2hQ.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([0,1,2]),import.meta.url).then(({default:n})=>n));const t=await UM;return nfe!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:e4t()}),nfe=e),t},rfe=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:s,onCopy:a,children:o})=>p.jsxs("div",{className:I("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[p.jsx(Ot,{content:"Zoom in",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:p.jsx(fJe,{})})}),p.jsx(Ot,{content:"Zoom out",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:p.jsx(pJe,{})})}),p.jsx(Ot,{content:"Drag the diagram to pan",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:p.jsx(XHe,{})})}),p.jsx(Ot,{content:"Reset view",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:p.jsx(hB,{})})}),p.jsx(Ot,{content:"Save as SVG",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:s,children:p.jsx(Bp,{})})}),p.jsx(Ot,{content:t?"Copied":"Copy mermaid text",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:a,children:p.jsx(hv,{className:I(t&&"text-success")})})}),o]}),gU=({title:e,children:t})=>p.jsxs(el,{variant:"danger",role:"alert",className:"my-4",children:[p.jsx(USe,{children:e}),p.jsx(vA,{children:t})]});class n4t extends w.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Mermaid Error Boundary caught an error:",t,n)}render(){return this.state.hasError?this.props.fallback||p.jsxs(gU,{title:"Mermaid diagram error",children:[this.state.error?.message||"An unexpected error occurred while rendering the diagram"," ","The error was contained within the diagram component."]}):this.props.children}}const r4t=w.memo(({chart:e,id:t})=>{const n=w.useRef(null),r=w.useRef(null),[i,s]=w.useState(null),[a,o]=w.useState(!0),[l,c]=w.useState(""),[u,d]=w.useState(!1),[h,f]=w.useState({scale:1,x:0,y:0}),[O,g]=w.useState({scale:1,x:0,y:0}),[m,v]=w.useState(!1),[y,b]=w.useState({x:0,y:0}),[T,x]=w.useState("idle"),[S,k]=w.useState("idle"),_=sr(D=>D.themeName),P=w.useCallback(async()=>{try{if(o(!0),s(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const D=await t4t(_),B=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:G}=await D.render(B,e);if(!G||typeof G!="string"||G.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(G)}catch(D){console.error("Mermaid rendering error:",D);const B=D instanceof Error?D.message:"Failed to render mermaid diagram";s(B),c("")}finally{o(!1)}},[e,t,_]);w.useEffect(()=>{P().catch(D=>{console.error("Error in renderDiagram effect:",D),s("Failed to initialize diagram rendering"),o(!1)})},[P]);const C=w.useCallback(()=>{try{if(!l||!r.current)return 1;const B=r.current.getBoundingClientRect(),G=document.createElement("div");G.innerHTML=l;const ee=G.querySelector("svg");if(!ee)return 1;const he=ee.getBoundingClientRect?.()?.width||Number.parseFloat(ee.getAttribute("width")||"0")||ee.viewBox?.baseVal?.width||800,ae=ee.getBoundingClientRect?.()?.height||Number.parseFloat(ee.getAttribute("height")||"0")||ee.viewBox?.baseVal?.height||600,se=B.width*.9/he,me=B.height*.9/ae;return Math.min(se,me,1)}catch(D){return console.error("Error calculating fullscreen scale:",D),1}},[l]);w.useEffect(()=>{u&&l&&setTimeout(()=>{try{const D=C();g({scale:D,x:0,y:0})}catch(D){console.error("Error setting fullscreen transform:",D)}},100)},[u,l,C]);const Q=w.useCallback((D=!1)=>{try{(D?g:f)(G=>({...G,scale:Math.min(G.scale*1.2,10)}))}catch(B){console.error("Error in zoom in:",B)}},[]),E=w.useCallback((D=!1)=>{try{(D?g:f)(G=>({...G,scale:Math.max(G.scale/1.2,.1)}))}catch(B){console.error("Error in zoom out:",B)}},[]),A=w.useCallback((D=!1)=>{try{const B=D?g:f;if(D){const G=C();B({scale:G,x:0,y:0})}else B({scale:1,x:0,y:0})}catch(B){console.error("Error in reset:",B)}},[C]),L=w.useCallback(()=>{if(l)try{const D=new Blob([l],{type:"image/svg+xml"}),B=URL.createObjectURL(D),G=document.createElement("a");G.href=B,G.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(B)}catch(D){console.error("Failed to save SVG:",D)}},[l]),j=w.useCallback(async()=>{try{await navigator.clipboard.writeText(e),x("copied"),setTimeout(()=>x("idle"),1200)}catch(D){console.error("Failed to copy Mermaid chart text:",D)}},[e]),q=w.useCallback(async()=>{try{await navigator.clipboard.writeText(e),k("copied"),setTimeout(()=>k("idle"),1200)}catch(D){console.error("Failed to copy Mermaid chart text:",D)}},[e]),z=w.useCallback(D=>{try{v(!0),b({x:D.clientX,y:D.clientY}),D.preventDefault()}catch(B){console.error("Error in mouse down:",B)}},[]),V=w.useCallback((D,B=!1)=>{try{if(!m)return;const G=D.clientX-y.x,ee=D.clientY-y.y;(B?g:f)(ae=>({...ae,x:ae.x+G,y:ae.y+ee})),b({x:D.clientX,y:D.clientY})}catch(G){console.error("Error in mouse move:",G)}},[m,y]),W=w.useCallback(()=>{try{v(!1)}catch(D){console.error("Error in mouse up:",D)}},[]),M=w.useCallback((D,B=!1)=>{try{D.preventDefault();const G=D.deltaY>0?.9:1.1;(B?g:f)(he=>({...he,scale:Math.min(Math.max(he.scale*G,.1),5)}))}catch(G){console.error("Error in wheel:",G)}},[]),K=w.useCallback(D=>{try{d(D)}catch(B){console.error("Error toggling fullscreen:",B)}},[]);if(i)return p.jsxs(gU,{title:"Mermaid diagram error",children:[i,p.jsx("span",{className:I("mt-2 block text-ink-muted"),children:"Chart"}),p.jsx("span",{className:I("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const N=(D=!1)=>{try{const B=D?r:n,G=D?O:h;return p.jsx("div",{ref:B,className:I("mermaid flex w-full items-center justify-center",D?"h-full min-h-full":"h-auto min-h-50",m?"cursor-grabbing":"cursor-grab"),onMouseDown:z,onMouseMove:ee=>V(ee,D),onMouseUp:W,onMouseLeave:W,onWheel:ee=>M(ee,D),children:a?p.jsx("div",{className:I("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?p.jsx("div",{className:I("flex h-full w-full items-center justify-center"),style:{transform:`translate(${G.x}px, ${G.y}px) scale(${G.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(B){return console.error("Error rendering diagram content:",B),p.jsx(gU,{title:"Rendering error",children:"Failed to render diagram content."})}};return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:I("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[N(!1),p.jsx(rfe,{className:"top-2 right-2",copied:T==="copied",onZoomIn:()=>Q(!1),onZoomOut:()=>E(!1),onReset:()=>A(!1),onSave:L,onCopy:j,children:p.jsx(Ot,{content:"Fullscreen",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>K(!0),children:p.jsx(wHe,{})})})})]}),p.jsx($g,{open:u,onClose:()=>K(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:p.jsxs("div",{className:I("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[N(!0),p.jsx(rfe,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>Q(!0),onZoomOut:()=>E(!0),onReset:()=>A(!0),onSave:L,onCopy:q,children:p.jsx(Ot,{content:"Close fullscreen",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>K(!1),children:p.jsx(Js,{})})})})]})})]})}),i4t=w.memo(e=>p.jsx(n4t,{children:p.jsx(r4t,{...e})}));let S5e=!1,WM=null;const s4t=()=>(WM||(WM=Ie(()=>Promise.resolve({}),__vite__mapDeps([3]),import.meta.url).then(e=>(S5e=!0,e))),WM),a4t=/language-(\w+)/,o4t=/\n$/,l4t=/\$(?!\d)(.+?)\$/,c4t=/\$\$([\s\S]+?)\$\$/,u4t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,d4t=/\\[a-zA-Z]+(\{[^}]*\})?/,$5e={a:({href:e,children:t})=>p.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}),code:({node:e,className:t,children:n,...r})=>a4t.exec(t??"")?.[1]==="mermaid"?p.jsx(i4t,{chart:String(n).replace(o4t,"")}):p.jsx("code",{className:t,...r,children:n})},h4t=[W3],f4t=[W3,M5t],O4t=[],p4t=[rEt],g4t=e=>l4t.test(e)||c4t.test(e)||u4t.test(e)?!0:d4t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),k5e=e=>w.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),T5e=e=>{const t=w.useMemo(()=>g4t(e),[e]),[n,r]=w.useState(()=>t&&S5e);return w.useEffect(()=>{if(!t||n)return;let i=!1;return s4t().then(()=>{i||r(!0)}),()=>{i=!0}},[t,n]),{remarkPlugins:n?f4t:h4t,rehypePlugins:n?p4t:O4t}},wv=w.memo(({content:e,styleProps:t,className:n})=>{const r=w.useMemo(()=>e.trim(),[e]),{remarkPlugins:i,rehypePlugins:s}=T5e(r),a=k5e(t);return p.jsx("div",{className:I("lo-markdown",n),style:a,children:p.jsx(OZ,{remarkPlugins:i,rehypePlugins:s,components:$5e,children:r})})});wv.displayName="MarkdownRenderer";const _5e=w.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=T5e(e);return p.jsx(OZ,{remarkPlugins:t,rehypePlugins:n,components:$5e,children:e})});_5e.displayName="StableBlock";const P5e=w.memo(({text:e,animate:t})=>p.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));P5e.displayName="ArrivedText";const C5e=({content:e,styleProps:t,className:n})=>{const r=w.useRef(null);r.current===null&&(r.current=z5t());const i=r.current,s=w.useRef([]),a=w.useRef(0);V5t(i,e);const o=a.current;e.length>o?(o>0&&s.current.push({offset:o,animate:!0}),a.current=e.length):e.length<o&&(s.current=[],a.current=e.length);const{blockStart:l}=i,c=s.current;let u=0;for(;u<c.length&&c[u].offset<=l;)u+=1;u>0&&c.splice(0,u);const d=l+B5t(e.slice(l)),h=[{offset:l,animate:!1}];for(const O of c){if(O.offset>=d)break;h.push(O)}const f=k5e(t);return p.jsxs("div",{className:I("lo-markdown",n),style:f,children:[i.blocks.map((O,g)=>p.jsx(_5e,{source:O},g)),d>l&&p.jsx("p",{className:"lo-stream-tail",children:h.map((O,g)=>{const m=h[g+1]?.offset??d;return p.jsx(P5e,{text:e.slice(O.offset,m),animate:O.animate},O.offset)})})]})};C5e.displayName="StreamingMarkdown";const Q5e=({className:e})=>p.jsx("div",{className:I("flex size-7 shrink-0 items-center justify-center rounded-full bg-sunken text-ink-muted",e),children:p.jsx(mw,{size:16,"aria-label":"Assistant"})}),v5="pl-10",ic=({isUser:e,children:t,isSmallView:n,showAvatar:r,className:i})=>e?p.jsx("div",{className:I("flex w-full justify-end",i),children:t}):p.jsxs("div",{className:I("relative w-full",!n&&v5,i),children:[r&&!n&&p.jsx(Q5e,{className:"absolute top-0 left-0"}),t]}),E5e=6048e5,m4t=864e5,ife=6e4,BWn=36e5,YWn=1e3,sfe=525600,afe=43200,ofe=1440,lfe=Symbol.for("constructDateFrom");function dO(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&lfe in e?e[lfe](t):e instanceof Date?new e.constructor(t):new Date(t)}function wc(e,t){return dO(t||e,e)}let v4t={};function tP(){return v4t}function TT(e,t){const n=tP(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=wc(e,t?.in),s=i.getDay(),a=(s<r?7:0)+s-r;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function y5(e,t){return TT(e,{...t,weekStartsOn:1})}function R5e(e,t){const n=wc(e,t?.in),r=n.getFullYear(),i=dO(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=y5(i),a=dO(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);const o=y5(a);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function b5(e){const t=wc(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function A5e(e,...t){const n=dO.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function cfe(e,t){const n=wc(e,t?.in);return n.setHours(0,0,0,0),n}function y4t(e,t,n){const[r,i]=A5e(n?.in,e,t),s=cfe(r),a=cfe(i),o=+s-b5(s),l=+a-b5(a);return Math.round((o-l)/m4t)}function b4t(e,t){const n=R5e(e,t),r=dO(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),y5(r)}function w4t(e,t){const n=+wc(e)-+wc(t);return n<0?-1:n>0?1:n}function x4t(e){return dO(e,Date.now())}function S4t(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function $4t(e){return!(!S4t(e)&&typeof e!="number"||isNaN(+wc(e)))}function k4t(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function T4t(e,t){const n=wc(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const _4t={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},P4t=(e,t,n)=>{let r;const i=_4t[e];return typeof i=="string"?r=i:t===1?r=i.one:r=i.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function GM(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const C4t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Q4t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},E4t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},R4t={date:GM({formats:C4t,defaultWidth:"full"}),time:GM({formats:Q4t,defaultWidth:"full"}),dateTime:GM({formats:E4t,defaultWidth:"full"})},A4t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},X4t=(e,t,n,r)=>A4t[e];function Ex(e){return(t,n)=>{const r=n?.context?String(n.context):"standalone";let i;if(r==="formatting"&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,o=n?.width?String(n.width):a;i=e.formattingValues[o]||e.formattingValues[a]}else{const a=e.defaultWidth,o=n?.width?String(n.width):e.defaultWidth;i=e.values[o]||e.values[a]}const s=e.argumentCallback?e.argumentCallback(t):t;return i[s]}}const D4t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},I4t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},N4t={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},F4t={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},M4t={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},L4t={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},j4t=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},q4t={ordinalNumber:j4t,era:Ex({values:D4t,defaultWidth:"wide"}),quarter:Ex({values:I4t,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ex({values:N4t,defaultWidth:"wide"}),day:Ex({values:F4t,defaultWidth:"wide"}),dayPeriod:Ex({values:M4t,defaultWidth:"wide",formattingValues:L4t,defaultFormattingWidth:"wide"})};function Rx(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(i);if(!s)return null;const a=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?U4t(o,d=>d.test(a)):z4t(o,d=>d.test(a));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;const u=t.slice(a.length);return{value:c,rest:u}}}function z4t(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function U4t(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function W4t(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const i=r[0],s=t.match(e.parsePattern);if(!s)return null;let a=e.valueCallback?e.valueCallback(s[0]):s[0];a=n.valueCallback?n.valueCallback(a):a;const o=t.slice(i.length);return{value:a,rest:o}}}const G4t=/^(\d+)(th|st|nd|rd)?/i,V4t=/\d+/i,B4t={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Y4t={any:[/^b/i,/^(a|c)/i]},Z4t={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},H4t={any:[/1/i,/2/i,/3/i,/4/i]},K4t={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},J4t={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},eAt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},tAt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},nAt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},rAt={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},iAt={ordinalNumber:W4t({matchPattern:G4t,parsePattern:V4t,valueCallback:e=>parseInt(e,10)}),era:Rx({matchPatterns:B4t,defaultMatchWidth:"wide",parsePatterns:Y4t,defaultParseWidth:"any"}),quarter:Rx({matchPatterns:Z4t,defaultMatchWidth:"wide",parsePatterns:H4t,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Rx({matchPatterns:K4t,defaultMatchWidth:"wide",parsePatterns:J4t,defaultParseWidth:"any"}),day:Rx({matchPatterns:eAt,defaultMatchWidth:"wide",parsePatterns:tAt,defaultParseWidth:"any"}),dayPeriod:Rx({matchPatterns:nAt,defaultMatchWidth:"any",parsePatterns:rAt,defaultParseWidth:"any"})},X5e={code:"en-US",formatDistance:P4t,formatLong:R4t,formatRelative:X4t,localize:q4t,match:iAt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function sAt(e,t){const n=wc(e,t?.in);return y4t(n,T4t(n))+1}function aAt(e,t){const n=wc(e,t?.in),r=+y5(n)-+b4t(n);return Math.round(r/E5e)+1}function D5e(e,t){const n=wc(e,t?.in),r=n.getFullYear(),i=tP(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=dO(t?.in||e,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const o=TT(a,t),l=dO(t?.in||e,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const c=TT(l,t);return+n>=+o?r+1:+n>=+c?r:r-1}function oAt(e,t){const n=tP(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=D5e(e,t),s=dO(t?.in||e,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),TT(s,t)}function lAt(e,t){const n=wc(e,t?.in),r=+TT(n,t)-+oAt(n,t);return Math.round(r/E5e)+1}function ti(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const ZO={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ti(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ti(n+1,2)},d(e,t){return ti(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ti(e.getHours()%12||12,t.length)},H(e,t){return ti(e.getHours(),t.length)},m(e,t){return ti(e.getMinutes(),t.length)},s(e,t){return ti(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return ti(i,t.length)}},ly={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},ufe={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return ZO.y(e,t)},Y:function(e,t,n,r){const i=D5e(e,r),s=i>0?i:1-i;if(t==="YY"){const a=s%100;return ti(a,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):ti(s,t.length)},R:function(e,t){const n=R5e(e);return ti(n,t.length)},u:function(e,t){const n=e.getFullYear();return ti(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ti(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ti(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return ZO.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ti(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const i=lAt(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):ti(i,t.length)},I:function(e,t,n){const r=aAt(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ti(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):ZO.d(e,t)},D:function(e,t,n){const r=sAt(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ti(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ti(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ti(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),i=r===0?7:r;switch(t){case"i":return String(i);case"ii":return ti(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let i;switch(r===12?i=ly.noon:r===0?i=ly.midnight:i=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let i;switch(r>=17?i=ly.evening:r>=12?i=ly.afternoon:r>=4?i=ly.morning:i=ly.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return ZO.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):ZO.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ti(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ti(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):ZO.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):ZO.s(e,t)},S:function(e,t){return ZO.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return hfe(r);case"XXXX":case"XX":return wm(r);case"XXXXX":case"XXX":default:return wm(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return hfe(r);case"xxxx":case"xx":return wm(r);case"xxxxx":case"xxx":default:return wm(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+dfe(r,":");case"OOOO":default:return"GMT"+wm(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+dfe(r,":");case"zzzz":default:return"GMT"+wm(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return ti(r,t.length)},T:function(e,t,n){return ti(+e,t.length)}};function dfe(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+t+ti(s,2)}function hfe(e,t){return e%60===0?(e>0?"-":"+")+ti(Math.abs(e)/60,2):wm(e,t)}function wm(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=ti(Math.trunc(r/60),2),s=ti(r%60,2);return n+i+t+s}const ffe=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},I5e=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},cAt=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return ffe(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",ffe(r,t)).replace("{{time}}",I5e(i,t))},uAt={p:I5e,P:cAt},dAt=/^D+$/,hAt=/^Y+$/,fAt=["D","DD","YY","YYYY"];function OAt(e){return dAt.test(e)}function pAt(e){return hAt.test(e)}function gAt(e,t,n){const r=mAt(e,t,n);if(console.warn(r),fAt.includes(e))throw new RangeError(r)}function mAt(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const vAt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,yAt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,bAt=/^'([^]*?)'?$/,wAt=/''/g,xAt=/[a-zA-Z]/;function VM(e,t,n){const r=tP(),i=n?.locale??r.locale??X5e,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=wc(e,n?.in);if(!$4t(o))throw new RangeError("Invalid time value");let l=t.match(yAt).map(u=>{const d=u[0];if(d==="p"||d==="P"){const h=uAt[d];return h(u,i.formatLong)}return u}).join("").match(vAt).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const d=u[0];if(d==="'")return{isToken:!1,value:SAt(u)};if(ufe[d])return{isToken:!0,value:u};if(d.match(xAt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:u}});i.localize.preprocessor&&(l=i.localize.preprocessor(o,l));const c={firstWeekContainsDate:s,weekStartsOn:a,locale:i};return l.map(u=>{if(!u.isToken)return u.value;const d=u.value;(!n?.useAdditionalWeekYearTokens&&pAt(d)||!n?.useAdditionalDayOfYearTokens&&OAt(d))&&gAt(d,t,String(e));const h=ufe[d[0]];return h(o,d,i.localize,c)}).join("")}function SAt(e){const t=e.match(bAt);return t?t[1].replace(wAt,"'"):e}function $At(e,t,n){const r=tP(),i=n?.locale??r.locale??X5e,s=w4t(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:s}),[o,l]=A5e(n?.in,...s>0?[t,e]:[e,t]),c=k4t("round"),u=l.getTime()-o.getTime(),d=u/ife,h=b5(l)-b5(o),f=(u-h)/ife,O=n?.unit;let g;if(d<1?g="second":d<60?g="minute":d<ofe?g="hour":f<afe?g="day":f<sfe?g="month":g="year",g==="second"){const m=c(u/1e3);return i.formatDistance("xSeconds",m,a)}else if(g==="minute"){const m=c(d);return i.formatDistance("xMinutes",m,a)}else if(g==="hour"){const m=c(d/60);return i.formatDistance("xHours",m,a)}else if(g==="day"){const m=c(f/ofe);return i.formatDistance("xDays",m,a)}else if(g==="month"){const m=c(f/afe);return m===12&&O!=="month"?i.formatDistance("xYears",1,a):i.formatDistance("xMonths",m,a)}else{const m=c(f/sfe);return i.formatDistance("xYears",m,a)}}function kAt(e,t){return $At(e,x4t(e),t)}const TAt=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e),n=new Date,r=new Date(n);if(r.setDate(n.getDate()-1),t.toDateString()===n.toDateString())return VM(t,"h:mm a");if(t.toDateString()===r.toDateString())return"Yesterday";const i=new Date(n);return i.setDate(n.getDate()-7),t>i?VM(t,"EEEE"):VM(t,"yyyy-MM-dd")}catch(t){return console.error("Error formatting date:",t),""}},ZWn=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(navigator.language,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},_At=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString(navigator.language,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}catch(t){return console.error("Error formatting calendar date-time:",t),""}},jZ=({timestamp:e,className:t})=>p.jsx(Ot,{content:_At(e),side:"bottom",delayDuration:1200,children:p.jsx("span",{className:I("shrink-0 cursor-help whitespace-nowrap text-ink-dim text-meta",t),children:TAt(e)})}),N5e=({content:e,busy:t=!1,className:n})=>e?p.jsxs("section",{"aria-label":"Question from the agent",className:I("flex gap-3 rounded-md border border-accent bg-accent-wash px-4 py-3",n),children:[p.jsx(kHe,{className:"mt-0.5 size-4 shrink-0 text-accent","aria-hidden":!0}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[p.jsx("p",{className:"font-medium text-accent text-meta",children:t?"Sending your answer…":"Waiting for your answer"}),p.jsx("div",{className:"lo-on-wash text-ink",children:p.jsx(wv,{content:e})})]})]}):null,PAt=({options:e,recommended:t,busy:n=!1,onAnswer:r,requestId:i})=>{if(e.length===0)return null;const s=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<e.length?t:null;return p.jsx("fieldset",{"aria-label":"Answer options",className:"mt-1 flex min-w-0 max-h-[380px] flex-col gap-2 overflow-y-auto border-0 px-0 py-1",children:e.map((a,o)=>p.jsxs("button",{type:"button",disabled:n,onClick:()=>r(a.label),className:I("flex w-full items-baseline gap-2 rounded-sm border px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","border-control bg-surface hover:bg-elevated active:bg-sunken","disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled"),children:[o<9&&p.jsxs("span",{"aria-hidden":!0,className:I("shrink-0 font-mono text-mono-sm",n?"text-ink-disabled":"text-ink-dim"),children:[o+1,"."]}),p.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[p.jsxs("span",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[p.jsx("span",{className:I("min-w-0 text-body-sm",n?"text-ink-disabled":"text-ink"),children:a.label}),s===o&&p.jsx("span",{className:I("shrink-0 font-medium text-meta",n?"text-ink-disabled":"text-ink"),children:"Recommended"})]}),a.description&&p.jsx("span",{className:I("text-body-sm",n?"text-ink-disabled":"text-ink-muted"),children:a.description})]})]},`${i}-${String(o)}`))})},F5e=({children:e,className:t})=>p.jsx("span",{"aria-hidden":!0,className:I("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),qZ=({label:e="Reasoning",content:t})=>!sr(r=>r.showAgentReasoning)||!t?null:p.jsx(fd,{summary:p.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p.jsx(F5e,{}),p.jsx("span",{className:"truncate",children:p.jsx("span",{className:"text-ink-dim text-meta",children:e})})]}),children:p.jsx(wv,{content:t,className:"[--md-ink:var(--lo-ink-muted)]",styleProps:{fontSize:"var(--text-body-sm)",lineHeight:"var(--text-body-sm--line-height)"}})}),CAt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},QAt=({line:e})=>p.jsx("span",{className:I(CAt[e.kind],"block"),children:e.text}),EAt=({diff:e,className:t})=>{const n=xst(e);return p.jsxs("div",{className:I("max-h-[740px] overflow-y-auto overflow-x-hidden rounded-sm border border-hairline bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",t),children:[n.lines.map((r,i)=>p.jsx(QAt,{line:r},i)),n.hidden>0&&p.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:Sst(n.hidden)})]})},RAt=({content:e,details:t,className:n})=>p.jsxs("section",{"aria-label":"Security notice",className:I("flex gap-3 border-warning border-l-2 py-0.5 pl-3",n),children:[p.jsx(CKe,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":!0}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[p.jsx("p",{className:"font-medium text-body-sm text-warning",children:"Blocked a risky action"}),e?p.jsx("p",{className:"text-body-sm text-ink-muted",children:e}):null,t?p.jsx(fd,{summary:p.jsx("span",{className:"text-meta",children:"Show the reviewed code"}),children:t}):null]})]}),AAt=(e,t=72)=>{let i=e.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\s+/g," ").trim();if(i.length>t){const s=i.slice(0,t),a=s.lastIndexOf(" ");i=`${s.slice(0,a>32?a:t).trimEnd()}…`}return i.replace(/[.!?…]+$/g,"").trimEnd()},Ofe=e=>e.startsWith("file://")?e.slice(7):e,XAt={READ:{verb:"Read",runningVerb:"Reading",icon:rB},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:uB},EDIT:{verb:"Edited",runningVerb:"Editing",icon:BHe},CODE:{verb:"Ran code",runningVerb:"Running code",icon:iB},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:_Ke},DONE:{verb:"Finished",runningVerb:"Finishing",icon:RV},ASK:{verb:"Asked",runningVerb:"Asking",icon:kA},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:fZe}},DAt={verb:"Worked on the request",runningVerb:"Working on the request",icon:iB},IAt=(e,t,n,r)=>{const i=e?XAt[e]:DAt;let s;if(t)s=Ofe(t);else if(n&&n.length>0){const o=n.filter(l=>!l.startsWith("data:"));o.length===1?s=Ofe(o[0]):o.length>1&&(s=`${o.length} files`)}const a=!s&&r?AAt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:s,narration:a||void 0,icon:i.icon}},pfe="min-h-5 py-0",NAt=({icon:e,verb:t,object:n,narration:r,running:i,failed:s,wrap:a})=>p.jsxs("span",{className:I("flex min-w-0 gap-2",a?"items-start":"items-center"),"aria-busy":i||void 0,children:[p.jsx(F5e,{className:I(s?"text-danger":"text-ink-dim",a&&oQe),children:e}),p.jsxs("span",{className:I(a?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[p.jsxs("span",{...cM,className:I("select-text font-mono text-mono-sm",i?"text-ink-muted":"text-ink-dim",s&&"text-danger"),children:[t,r?":":null]}),n?p.jsxs("span",{...cM,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?p.jsxs("span",{...cM,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),w5=({action:e,filePath:t,files:n,narration:r,running:i=!1,failed:s=!1,defaultOpen:a=!1,details:o,className:l,verbOverride:c,object:u,glyph:d,wrap:h,dense:f=!1})=>{const O=IAt(e,t,n,r),g=c??(i?O.runningVerb:O.verb),m=s?y0:O.icon,v=s||!c||!d?p.jsx(m,{}):d,y=p.jsx(NAt,{icon:v,verb:g,object:c?u:O.object,narration:c?r:O.narration,running:i,failed:s,wrap:h}),b=h?"firstLine":"center";return o?p.jsx(fd,{summary:y,chevron:"leading",summaryAlign:b,defaultOpen:a,className:l,rowClassName:f?pfe:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:o}):p.jsx(fd,{disabled:!0,summary:y,summaryAlign:b,className:l,rowClassName:f?pfe:void 0})},M5e=8,FAt="… deeper values not shown",MAt="(empty)";function LAt(e){return`… ${e} more line${e===1?"":"s"}`}const gfe=.5;function jAt(e,t,n,r){if(!Number.isFinite(t)||t<=0)return 0;let i=0;for(const s of e){if(s.height<=0)continue;const a=Math.max(1,Math.round(s.height/t));for(let o=1;o<=a;o++)s.top+o*t>n+r&&i++}return i}function L5e(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function zZ(e){return typeof e=="object"&&e!==null}function j5e(e,t,n,r){if(n>M5e){r.push({key:t,value:FAt,depth:n});return}if(zZ(e)){for(const[s,a]of Object.entries(e))j5e(a,t?`${t}.${s}`:s,n+1,r);return}const i=L5e(e);i!==null&&r.push({key:t,value:i,depth:n})}function q5e(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))j5e(r,n,1,t);return t}const qAt=512;function zAt(e,t){if(t)return!0;if(!e)return!1;let n=qAt;const r=(i,s)=>{if(n--<=0||s>M5e)return!0;if(!zZ(i))return L5e(i)!==null;for(const a of Object.values(i))if(r(a,s+1))return!0;return!1};for(const i of Object.values(e))if(r(i,1))return!0;return!1}function UAt(e){if(!e)return null;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!zZ(n))return null;const r=q5e(n);return r.length>0?r:[{key:"",value:MAt,depth:1}]}const WAt=8,mfe="max-h-[240px]",GAt=({line:e})=>p.jsxs("div",{className:I("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*WAt},children:[e.key?p.jsxs("span",{className:I("text-ink-dim"),children:[e.key,": "]}):null,p.jsx("span",{className:I("text-ink-muted"),children:e.value})]}),vfe=({lines:e,label:t})=>p.jsx("div",{className:I("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>p.jsx(GAt,{line:n},r))});function yfe(e){const[t,n]=w.useState(0),[r,i]=w.useState(!1);return w.useLayoutEffect(()=>{const s=e.current;if(!s)return;const a=s.firstElementChild,o=()=>{const c=a??s,u=Number.parseFloat(getComputedStyle(c).lineHeight);if(!Number.isFinite(u)||u<=0){n(0),i(!1);return}const d=s.getBoundingClientRect(),h=c.getBoundingClientRect();i(h.height>d.height+gfe);const f=c.children.length>0?Array.from(c.children):[c];n(jAt(f.map(O=>{const g=O.getBoundingClientRect();return{top:g.top,height:g.height}}),u,d.bottom,gfe))};o(),s.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(o);return l.observe(a??s),()=>{s.removeEventListener("scroll",o),l.disconnect()}}),{lines:t,overflowing:r}}const bfe=({lines:e,overflowing:t})=>t?p.jsx("span",{className:I("mt-1 block text-ink-dim"),children:e>0?LAt(e):" "}):null,VAt=({args:e,output:t,isError:n})=>{const r=q5e(e),i=UAt(t),s=w.useRef(null),a=w.useRef(null),o=yfe(s),l=yfe(a);return r.length===0&&!t?null:p.jsxs("div",{className:I("w-full rounded-sm border border-hairline bg-sunken p-3 font-mono text-mono-sm"),children:[r.length>0&&p.jsxs("div",{"data-detail-section":"input",children:[p.jsx("div",{ref:s,className:I(mfe,"overflow-auto"),children:p.jsx(vfe,{lines:r,label:"input"})}),p.jsx(bfe,{lines:o.lines,overflowing:o.overflowing})]}),t&&p.jsxs("div",{className:I(r.length>0&&"mt-3"),"data-detail-section":"output",children:[p.jsx("span",{className:I("mb-1 block text-meta",n?"text-danger":"text-ink-dim"),children:n?"Error":"Output"}),p.jsx("div",{ref:a,className:I(mfe,"overflow-auto"),children:i?p.jsx(vfe,{lines:i,label:"result-json"}):p.jsx("pre",{className:I("whitespace-pre font-mono",n?"text-danger":"text-ink"),children:t})}),p.jsx(bfe,{lines:l.lines,overflowing:l.overflowing})]})]})},BAt="mcp__",YAt={bash:eJe,read:Yp,write:Rne,edit:Rne,glob:fk,grep:CA,todo:hHe,wake:TA,list_variables:VE,read_variable:VE,browser:Xne,web_search:Xne,web_fetch:Bp,task:qf,agent:qf,send:fB,peer:tHe};function ZAt(e){const t=e.trim().toLowerCase(),n=YAt[t];return n||(t.startsWith(BAt)?dB:xWe)}const HAt=bc,KAt=Js,JAt=Xke,wfe="min-h-5 py-0",e3t={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent",plain:"text-ink-muted"},t3t=(e,t)=>e==="running"?"text-ink":e==="error"?"text-danger":e==="receipt"?"text-ink-muted":e3t[dst(t)],n3t=({added:e,removed:t})=>e<=0&&t<=0?null:p.jsxs("span",{className:I("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&p.jsxs("span",{className:I("text-success"),children:["+",e]}),t>0&&p.jsxs("span",{className:I("text-danger"),children:["-",t]})]}),xfe={running:"",success:"succeeded",error:"failed",interrupted:"interrupted",receipt:""},r3t=1e3;function i3t(e){const[t,n]=w.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return w.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,r3t);return()=>window.clearInterval(i)},[e]),t}const s3t=({outcome:e,durationS:t,startedAt:n})=>{const r=e==="running",i=i3t(r?n??null:null),s=e==="success"?HAt:e==="error"?KAt:e==="interrupted"?JAt:null,a=e==="success"?"text-success":e==="error"?"text-danger":"text-ink-dim",o=r?n==null?"":IB(i??0):lst(t);return p.jsxs("span",{className:I("flex shrink-0 items-center gap-1.5"),children:[p.jsxs("span",{className:I("flex size-3.5 shrink-0 [&_svg]:size-3.5",a),children:[s?p.jsx(s,{"aria-hidden":!0}):null,xfe[e]?p.jsx("span",{className:I("sr-only"),children:xfe[e]}):null]}),p.jsx("span",{className:I("w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums"),children:o})]})},x5=({toolName:e,summary:t,summaryFallback:n=null,outcome:r,durationS:i,startedAt:s=null,added:a=0,removed:o=0,nameColumn:l=o_e,details:c,defaultOpen:u=!1,className:d,media:h})=>{const f=r==="running",O=r==="error",g=ZAt(e),m=Dk(e),v=a_e(t,e)?n??"":t,y=p.jsxs("span",{className:I("flex min-w-0 flex-1 items-center gap-2"),children:[p.jsx("span",{"aria-hidden":!0,className:I("flex size-3.5 shrink-0 [&_svg]:size-3.5",f?"text-accent":O?"text-danger":"text-ink-dim"),children:p.jsx(g,{})}),p.jsx("span",{className:I("shrink-0 truncate font-mono text-mono-sm","pr-1",t3t(r,e)),style:{width:`calc(${l}ch + 0.25rem)`},title:m,children:m}),p.jsx("span",{className:I("min-w-0 flex-1 truncate font-mono text-mono-sm",f?"text-ink-muted":"text-ink-dim"),title:v,children:v}),p.jsx(n3t,{added:a,removed:o}),p.jsx(s3t,{outcome:r,durationS:i,startedAt:s})]}),b=f?"bg-elevated":O?"bg-danger-wash":"hover:bg-elevated",T=c?p.jsx(fd,{summary:y,chevron:"leading",defaultOpen:u,className:I("@container/toolrow",d),rowClassName:wfe,triggerClassName:I("-mx-2 rounded-sm px-2",b),children:c}):p.jsx(fd,{disabled:!0,summary:y,rowClassName:wfe,className:I("@container/toolrow",(f||O)&&I("-mx-2 rounded-sm px-2",b),d)});return h?p.jsxs("div",{className:I("flex flex-col"),children:[T,h]}):T},z5e=e=>{const t=w.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=w.useCallback(()=>window.matchMedia(e).matches,[e]);return w.useSyncExternalStore(t,n,()=>!1)},Sfe=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],a3t=80,o3t=1e3,l3t=({activity:e,phase:t,className:n})=>{const[r,i]=w.useState(0),[s,a]=w.useState(0),o=z5e("(prefers-reduced-motion: reduce)"),l=w.useRef(Date.now()),c=w.useRef(t);return c.current!==t&&(c.current=t,l.current=Date.now(),a(0)),w.useEffect(()=>{const u=window.setInterval(()=>a(Math.floor((Date.now()-l.current)/1e3)),o3t);if(o)return i(0),()=>window.clearInterval(u);const d=window.setInterval(()=>i(h=>(h+1)%Sfe.length),a3t);return()=>{window.clearInterval(d),window.clearInterval(u)}},[o]),p.jsxs("div",{className:I("flex items-center gap-2",n),"data-lo-working-line":!0,"aria-live":"polite",children:[p.jsx("span",{"aria-hidden":!0,className:I("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:Sfe[r]}),p.jsx("span",{className:I("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),p.jsx("span",{"aria-hidden":!0,className:I("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:IB(s)})]})},U5e=({children:e,className:t})=>p.jsx("div",{className:I("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm border border-hairline bg-sunken",t),children:e}),c3t="could not be displayed. It may have been moved, renamed, or deleted.",u3t="could not be displayed. Its stored copy is not available to this reader.",UZ=({name:e,detail:t=c3t,className:n})=>p.jsxs("div",{className:I("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[p.jsx(KZe,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),p.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[p.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),G3=({filePath:e,tooltip:t="File actions",icon:n,"aria-label":r="File actions",onShowInCanvas:i})=>{const s=async()=>{if(e)try{await navigator.clipboard.writeText(e),Rs("File path copied to clipboard")}catch(o){console.error("Failed to copy file path: ",o),or("Failed to copy file path")}},a=()=>{e&&window.api.openFile(e)};return p.jsxs(X_,{children:[p.jsx(Ot,{content:t,children:p.jsx(Ub,{asChild:!0,children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":r,onClick:o=>o.stopPropagation(),children:n??p.jsx(sB,{"aria-hidden":"true"})})})}),p.jsxs(D_,{align:"end",className:"min-w-45",onClick:o=>o.stopPropagation(),children:[i&&p.jsxs(ks,{onSelect:i,children:[p.jsx(lHe,{"aria-hidden":"true"}),p.jsx("span",{children:"Show in canvas"})]}),p.jsxs(ks,{onSelect:a,children:[p.jsx(vw,{"aria-hidden":"true"}),p.jsx("span",{children:"Open file"})]}),p.jsxs(ks,{onSelect:()=>window.api.showItemInFolder(e),children:[p.jsx(fk,{"aria-hidden":"true"}),p.jsx("span",{children:"Open folder"})]}),p.jsxs(ks,{onSelect:s,children:[p.jsx(Dke,{"aria-hidden":"true"}),p.jsx("span",{children:"Copy file path"})]})]})]})},W5e=1024;let d3t=0,nu=class{constructor(t,n){this.from=t,this.to=n}};class In{constructor(t={}){this.id=d3t++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=na.match(t)),n=>{let r=t(n);return r===void 0?null:[this,r]}}}In.closedBy=new In({deserialize:e=>e.split(" ")});In.openedBy=new In({deserialize:e=>e.split(" ")});In.group=new In({deserialize:e=>e.split(" ")});In.isolate=new In({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});In.contextHash=new In({perNode:!0});In.lookAhead=new In({perNode:!0});In.mounted=new In({perNode:!0});class _T{constructor(t,n,r){this.tree=t,this.overlay=n,this.parser=r}static get(t){return t&&t.props&&t.props[In.mounted.id]}}const h3t=Object.create(null);class na{constructor(t,n,r,i=0){this.name=t,this.props=n,this.id=r,this.flags=i}static define(t){let n=t.props&&t.props.length?Object.create(null):h3t,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new na(t.name||"",n,t.id,r);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let n=this.prop(In.group);return n?n.indexOf(t)>-1:!1}return this.id==t}static match(t){let n=Object.create(null);for(let r in t)for(let i of r.split(" "))n[i]=t[r];return r=>{for(let i=r.prop(In.group),s=-1;s<(i?i.length:0);s++){let a=n[s<0?r.name:i[s]];if(a)return a}}}}na.none=new na("",Object.create(null),0,8);class Mw{constructor(t){this.types=t;for(let n=0;n<t.length;n++)if(t[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let n=[];for(let r of this.types){let i=null;for(let s of t){let a=s(r);a&&(i||(i=Object.assign({},r.props)),i[a[0].id]=a[1])}n.push(i?new na(r.name,i,r.id,r.flags):r)}return new Mw(n)}}const N2=new WeakMap,$fe=new WeakMap;var bi;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"})(bi||(bi={}));class vr{constructor(t,n,r,i,s){if(this.type=t,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[a,o]of s)this.props[typeof a=="number"?a:a.id]=o}}toString(){let t=_T.get(this);if(t&&!t.overlay)return t.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(t=0){return new S5(this.topNode,t)}cursorAt(t,n=0,r=0){let i=N2.get(this)||this.topNode,s=new S5(i);return s.moveTo(t,n),N2.set(this,s._tree),s}get topNode(){return new To(this,0,0,null)}resolve(t,n=0){let r=PT(N2.get(this)||this.topNode,t,n,!1);return N2.set(this,r),r}resolveInner(t,n=0){let r=PT($fe.get(this)||this.topNode,t,n,!0);return $fe.set(this,r),r}resolveStack(t,n=0){return p3t(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:s=this.length}=t,a=t.mode||0,o=(a&bi.IncludeAnonymous)>0;for(let l=this.cursor(a|bi.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=i&&(!o&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(o||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let n in this.props)t.push([+n,this.props[n]]);return t}balance(t={}){return this.children.length<=8?this:VZ(na.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new vr(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new vr(na.none,n,r,i)))}static build(t){return g3t(t)}}vr.empty=new vr(na.none,[],[],0);class WZ{constructor(t,n){this.buffer=t,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new WZ(this.buffer,this.index)}}class lg{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return na.none}toString(){let t=[];for(let n=0;n<this.buffer.length;)t.push(this.childString(n)),n=this.buffer[n+3];return t.join(",")}childString(t){let n=this.buffer[t],r=this.buffer[t+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),t+=4,r==t)return s;let a=[];for(;t<r;)a.push(this.childString(t)),t=this.buffer[t+3];return s+"("+a.join(",")+")"}findChild(t,n,r,i,s){let{buffer:a}=this,o=-1;for(let l=t;l!=n&&!(G5e(s,i,a[l+1],a[l+2])&&(o=l,r>0));l=a[l+3]);return o}slice(t,n,r){let i=this.buffer,s=new Uint16Array(n-t),a=0;for(let o=t,l=0;o<n;){s[l++]=i[o++],s[l++]=i[o++]-r;let c=s[l++]=i[o++]-r;s[l++]=i[o++]-t,a=Math.max(a,c)}return new lg(s,a,this.set)}}function G5e(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function PT(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let a=!r&&e instanceof To&&e.index<0?null:e.parent;if(!a)return e;e=a}let s=r?0:bi.IgnoreOverlays;if(r)for(let a=e,o=a.parent;o;a=o,o=a.parent)a instanceof To&&a.index<0&&((i=o.enter(t,n,s))===null||i===void 0?void 0:i.from)!=a.from&&(e=o);for(;;){let a=e.enter(t,n,s);if(!a)return e;e=a}}class V5e{cursor(t=0){return new S5(this,t)}getChild(t,n=null,r=null){let i=kfe(this,t,n,r);return i.length?i[0]:null}getChildren(t,n=null,r=null){return kfe(this,t,n,r)}resolve(t,n=0){return PT(this,t,n,!1)}resolveInner(t,n=0){return PT(this,t,n,!0)}matchContext(t){return mU(this.parent,t)}enterUnfinishedNodesBefore(t){let n=this.childBefore(t),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class To extends V5e{constructor(t,n,r,i){super(),this._tree=t,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,s=0){for(let a=this;;){for(let{children:o,positions:l}=a._tree,c=n>0?o.length:-1;t!=c;t+=n){let u=o[t],d=l[t]+a.from;if(G5e(i,r,d,d+u.length)){if(u instanceof lg){if(s&bi.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,n,r-d,i);if(h>-1)return new dh(new f3t(a,u,t,d),null,h)}else if(s&bi.IncludeAnonymous||!u.type.isAnonymous||GZ(u)){let h;if(!(s&bi.IgnoreMounts)&&(h=_T.get(u))&&!h.overlay)return new To(h.tree,d,t,a);let f=new To(u,d,t,a);return s&bi.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(n<0?u.children.length-1:0,n,r,i)}}}if(s&bi.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?t=a.index+n:t=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,n,r=0){let i;if(!(r&bi.IgnoreOverlays)&&(i=_T.get(this._tree))&&i.overlay){let s=t-this.from;for(let{from:a,to:o}of i.overlay)if((n>0?a<=s:a<s)&&(n<0?o>=s:o>s))return new To(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function kfe(e,t,n,r){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let a=!1;!a;)if(a=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(t)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function mU(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class f3t{constructor(t,n,r,i){this.parent=t,this.buffer=n,this.index=r,this.start=i}}class dh extends V5e{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,n,r){super(),this.context=t,this._parent=n,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return s<0?null:new dh(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,n,r=0){if(r&bi.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return s<0?null:new dh(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new dh(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new dh(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let a=r.buffer[this.index+1];t.push(r.slice(i,s,a)),n.push(0)}return new vr(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function B5e(e){if(!e.length)return null;let t=0,n=e[0];for(let s=1;s<e.length;s++){let a=e[s];(a.from>n.from||a.to<n.to)&&(n=a,t=s)}let r=n instanceof To&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new O3t(i,n)}class O3t{constructor(t,n){this.heads=t,this.node=n}get next(){return B5e(this.heads)}}function p3t(e,t,n){let r=e.resolveInner(t,n),i=null;for(let s=r instanceof To?r:r.context.parent;s;s=s.parent)if(s.index<0){let a=s.parent;(i||(i=[r])).push(a.resolve(t,n)),s=a}else{let a=_T.get(s.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new To(a.tree,a.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(PT(o,t,n,!1))}}return i?B5e(i):r}class S5{get name(){return this.type.name}constructor(t,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof To)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let r=t._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,n){this.index=t;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[t]],this.from=r+i.buffer[t+1],this.to=r+i.buffer[t+2],!0}yield(t){return t?t instanceof To?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,n,r=this.mode){return this.buffer?r&bi.ExcludeBuffers?!1:this.enterChild(1,t,n):this.yield(this._tree.enter(t,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&bi.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&bi.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(t<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let n,r,{buffer:i}=this;if(i){if(t>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+t,a=t<0?-1:r._tree.children.length;s!=a;s+=t){let o=r._tree.children[s];if(this.mode&bi.IncludeAnonymous||o instanceof lg||!o.type.isAnonymous||GZ(o))return!1}return!0}move(t,n){if(n&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,n=0){for(;(this.from==this.to||(n<1?this.from>=t:this.from>t)||(n>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,n););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,n=null,r=0;if(t&&t.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let a=t;a;a=a._parent)if(a.index==i){if(i==this.index)return a;n=a,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new dh(this.buffer,n,this.stack[i]);return this.bufferNode=new dh(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(t){if(!this.buffer)return mU(this.node.parent,t);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=t.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return mU(this._tree,t,i);let a=r[n.buffer[this.stack[s]]];if(!a.isAnonymous){if(t[i]&&t[i]!=a.name)return!1;i--}}return!0}}function GZ(e){return e.children.some(t=>t instanceof lg||!t.type.isAnonymous||GZ(t))}function g3t(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=W5e,reused:s=[],minRepeatType:a=r.types.length}=e,o=Array.isArray(n)?new WZ(n,n.length):n,l=r.types,c=0,u=0;function d(x,S,k,_,P,C){let{id:Q,start:E,end:A,size:L}=o,j=u,q=c;for(;L<0;)if(o.next(),L==-1){let K=s[Q];k.push(K),_.push(E-x);return}else if(L==-3){c=Q;return}else if(L==-4){u=Q;return}else throw new RangeError(`Unrecognized record size: ${L}`);let z=l[Q],V,W,M=E-x;if(A-E<=i&&(W=m(o.pos-S,P))){let K=new Uint16Array(W.size-W.skip),N=o.pos-W.size,D=K.length;for(;o.pos>N;)D=v(W.start,K,D);V=new lg(K,A-W.start,r),M=W.start-x}else{let K=o.pos-L;o.next();let N=[],D=[],B=Q>=a?Q:-1,G=0,ee=A;for(;o.pos>K;)B>=0&&o.id==B&&o.size>=0?(o.end<=ee-i&&(O(N,D,E,G,o.end,ee,B,j,q),G=N.length,ee=o.end),o.next()):C>2500?h(E,K,N,D):d(E,K,N,D,B,C+1);if(B>=0&&G>0&&G<N.length&&O(N,D,E,G,E,ee,B,j,q),N.reverse(),D.reverse(),B>-1&&G>0){let he=f(z,q);V=VZ(z,N,D,0,N.length,0,A-E,he,he)}else V=g(z,N,D,A-E,j-A,q)}k.push(V),_.push(M)}function h(x,S,k,_){let P=[],C=0,Q=-1;for(;o.pos>S;){let{id:E,start:A,end:L,size:j}=o;if(j>4)o.next();else{if(Q>-1&&A<Q)break;Q<0&&(Q=L-i),P.push(E,A,L),C++,o.next()}}if(C){let E=new Uint16Array(C*4),A=P[P.length-2];for(let L=P.length-3,j=0;L>=0;L-=3)E[j++]=P[L],E[j++]=P[L+1]-A,E[j++]=P[L+2]-A,E[j++]=j;k.push(new lg(E,P[2]-A,r)),_.push(A-x)}}function f(x,S){return(k,_,P)=>{let C=0,Q=k.length-1,E,A;if(Q>=0&&(E=k[Q])instanceof vr){if(!Q&&E.type==x&&E.length==P)return E;(A=E.prop(In.lookAhead))&&(C=_[Q]+E.length+A)}return g(x,k,_,P,C,S)}}function O(x,S,k,_,P,C,Q,E,A){let L=[],j=[];for(;x.length>_;)L.push(x.pop()),j.push(S.pop()+k-P);x.push(g(r.types[Q],L,j,C-P,E-C,A)),S.push(P-k)}function g(x,S,k,_,P,C,Q){if(C){let E=[In.contextHash,C];Q=Q?[E].concat(Q):[E]}if(P>25){let E=[In.lookAhead,P];Q=Q?[E].concat(Q):[E]}return new vr(x,S,k,_,Q)}function m(x,S){let k=o.fork(),_=0,P=0,C=0,Q=k.end-i,E={size:0,start:0,skip:0};e:for(let A=k.pos-x;k.pos>A;){let L=k.size;if(k.id==S&&L>=0){E.size=_,E.start=P,E.skip=C,C+=4,_+=4,k.next();continue}let j=k.pos-L;if(L<0||j<A||k.start<Q)break;let q=k.id>=a?4:0,z=k.start;for(k.next();k.pos>j;){if(k.size<0)if(k.size==-3)q+=4;else break e;else k.id>=a&&(q+=4);k.next()}P=z,_+=L,C+=q}return(S<0||_==x)&&(E.size=_,E.start=P,E.skip=C),E.size>4?E:void 0}function v(x,S,k){let{id:_,start:P,end:C,size:Q}=o;if(o.next(),Q>=0&&_<a){let E=k;if(Q>4){let A=o.pos-(Q-4);for(;o.pos>A;)k=v(x,S,k)}S[--k]=E,S[--k]=C-x,S[--k]=P-x,S[--k]=_}else Q==-3?c=_:Q==-4&&(u=_);return k}let y=[],b=[];for(;o.pos>0;)d(e.start||0,e.bufferStart||0,y,b,-1,0);let T=(t=e.length)!==null&&t!==void 0?t:y.length?b[0]+y[0].length:0;return new vr(l[e.topID],y.reverse(),b.reverse(),T)}const Tfe=new WeakMap;function jQ(e,t){if(!e.isAnonymous||t instanceof lg||t.type!=e)return 1;let n=Tfe.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof vr)){n=1;break}n+=jQ(e,r)}Tfe.set(t,n)}return n}function VZ(e,t,n,r,i,s,a,o,l){let c=0;for(let O=r;O<i;O++)c+=jQ(e,t[O]);let u=Math.ceil(c*1.5/8),d=[],h=[];function f(O,g,m,v,y){for(let b=m;b<v;){let T=b,x=g[b],S=jQ(e,O[b]);for(b++;b<v;b++){let k=jQ(e,O[b]);if(S+k>=u)break;S+=k}if(b==T+1){if(S>u){let k=O[T];f(k.children,k.positions,0,k.children.length,g[T]+y);continue}d.push(O[T])}else{let k=g[b-1]+O[b-1].length-x;d.push(VZ(e,O,g,T,b,x,k,null,l))}h.push(x+y-s)}}return f(t,n,r,i,0),(o||l)(d,h,a)}class BZ{constructor(){this.map=new WeakMap}setBuffer(t,n,r){let i=this.map.get(t);i||this.map.set(t,i=new Map),i.set(n,r)}getBuffer(t,n){let r=this.map.get(t);return r&&r.get(n)}set(t,n){t instanceof dh?this.setBuffer(t.context.buffer,t.index,n):t instanceof To&&this.map.set(t.tree,n)}get(t){return t instanceof dh?this.getBuffer(t.context.buffer,t.index):t instanceof To?this.map.get(t.tree):void 0}cursorSet(t,n){t.buffer?this.setBuffer(t.buffer.buffer,t.index,n):this.map.set(t.tree,n)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class Bf{constructor(t,n,r,i,s=!1,a=!1){this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new Bf(0,t.length,t,0,!1,r)];for(let s of n)s.to>t.length&&i.push(s);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],s=1,a=t.length?t[0]:null;for(let o=0,l=0,c=0;;o++){let u=o<n.length?n[o]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;a&&a.from<d;){let h=a;if(l>=h.from||d<=h.to||c){let f=Math.max(h.from,l)-c,O=Math.min(h.to,d)-c;h=f>=O?null:new Bf(f,O,h.tree,h.offset+c,o>0,!!u)}if(h&&i.push(h),a.to>d)break;a=s<t.length?t[s++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}let V3=class{startParse(t,n,r){return typeof t=="string"&&(t=new m3t(t)),r=r?r.length?r.map(i=>new nu(i.from,i.to)):[new nu(0,0)]:[new nu(0,t.length)],this.createParse(t,n||[],r)}parse(t,n,r){let i=this.startParse(t,n,r);for(;;){let s=i.advance();if(s)return s}}};class m3t{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,n){return this.string.slice(t,n)}}function ku(e){return(t,n,r,i)=>new y3t(t,e,n,r,i)}class _fe{constructor(t,n,r,i,s){this.parser=t,this.parse=n,this.overlay=r,this.target=i,this.from=s}}function Pfe(e){if(!e.length||e.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class v3t{constructor(t,n,r,i,s,a,o){this.parser=t,this.predicate=n,this.mounts=r,this.index=i,this.start=s,this.target=a,this.prev=o,this.depth=0,this.ranges=[]}}const vU=new In({perNode:!0});class y3t{constructor(t,n,r,i,s){this.nest=n,this.input=r,this.fragments=i,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new vr(r.type,r.children,r.positions,r.length,r.propValues.concat([[vU,this.stoppedAt]]))),r}let t=this.inner[this.innerDone],n=t.parse.advance();if(n){this.innerDone++;let r=Object.assign(Object.create(null),t.target.props);r[In.mounted.id]=new _T(n,t.overlay,t.parser),t.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].from<t&&(t=Math.min(t,this.inner[n].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].parse.stopAt(t)}startInner(){let t=new x3t(this.fragments),n=null,r=null,i=new S5(new To(this.baseTree,this.ranges[0].from,0,null),bi.IncludeAnonymous|bi.IgnoreMounts);e:for(let s,a;;){let o=!0,l;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)o=!1;else if(t.hasNode(i)){if(n){let c=n.mounts.find(u=>u.frag.from<=i.from&&u.frag.to>=i.to&&u.mount.overlay);if(c)for(let u of c.mount.overlay){let d=u.from+c.pos,h=u.to+c.pos;d>=i.from&&h<=i.to&&!n.ranges.some(f=>f.from<h&&f.to>d)&&n.ranges.push({from:d,to:h})}}o=!1}else if(r&&(a=b3t(r.ranges,i.from,i.to)))o=a!=2;else if(!i.type.isAnonymous&&(s=this.nest(i,this.input))&&(i.from<i.to||!s.overlay)){i.tree||w3t(i);let c=t.findMounts(i.from,s.parser);if(typeof s.overlay=="function")n=new v3t(s.parser,s.overlay,c,this.inner.length,i.from,i.tree,n);else{let u=Efe(this.ranges,s.overlay||(i.from<i.to?[new nu(i.from,i.to)]:[]));u.length&&Pfe(u),(u.length||!s.overlay)&&this.inner.push(new _fe(s.parser,u.length?s.parser.startParse(this.input,Rfe(c,u),u):s.parser.startParse(""),s.overlay?s.overlay.map(d=>new nu(d.from-i.from,d.to-i.from)):null,i.tree,u.length?u[0].from:i.from)),s.overlay?u.length&&(r={ranges:u,depth:0,prev:r}):o=!1}}else if(n&&(l=n.predicate(i))&&(l===!0&&(l=new nu(i.from,i.to)),l.from<l.to)){let c=n.ranges.length-1;c>=0&&n.ranges[c].to==l.from?n.ranges[c]={from:n.ranges[c].from,to:l.to}:n.ranges.push(l)}if(o&&i.firstChild())n&&n.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(n&&!--n.depth){let c=Efe(this.ranges,n.ranges);c.length&&(Pfe(c),this.inner.splice(n.index,0,new _fe(n.parser,n.parser.startParse(this.input,Rfe(n.mounts,c),c),n.ranges.map(u=>new nu(u.from-n.start,u.to-n.start)),n.target,c[0].from))),n=n.prev}r&&!--r.depth&&(r=r.prev)}}}}function b3t(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function Cfe(e,t,n,r,i,s){if(t<n){let a=e.buffer[t+1];r.push(e.slice(t,n,a)),i.push(a-s)}}function w3t(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,s=i.children.indexOf(r),a=i.children[s],o=a.buffer,l=[s];function c(u,d,h,f,O,g){let m=n[g],v=[],y=[];Cfe(a,u,m,v,y,f);let b=o[m+1],T=o[m+2];l.push(v.length);let x=g?c(m+4,o[m+3],a.set.types[o[m]],b,T-b,g-1):t.toTree();return v.push(x),y.push(b-f),Cfe(a,o[m+3],d,v,y,f),new vr(h,v,y,O)}i.children[s]=c(0,o.length,na.none,0,a.length,n.length-1);for(let u of l){let d=e.tree.children[u],h=e.tree.positions[u];e.yield(new To(d,h+e.from,u,e._tree))}}class Qfe{constructor(t,n){this.offset=n,this.done=!1,this.cursor=t.cursor(bi.IncludeAnonymous|bi.IgnoreMounts)}moveTo(t){let{cursor:n}=this,r=t-this.offset;for(;!this.done&&n.from<r;)n.to>=t&&n.enter(r,1,bi.IgnoreOverlays|bi.ExcludeBuffers)||n.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==t.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof vr)n=n.children[0];else break}return!1}}let x3t=class{constructor(t){var n;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let r=this.curFrag=t[0];this.curTo=(n=r.tree.prop(vU))!==null&&n!==void 0?n:r.to,this.inner=new Qfe(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(t=n.tree.prop(vU))!==null&&t!==void 0?t:n.to,this.inner=new Qfe(n.tree,-n.offset)}}findMounts(t,n){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let a=(r=s.tree)===null||r===void 0?void 0:r.prop(In.mounted);if(a&&a.parser==n)for(let o=this.fragI;o<this.fragments.length;o++){let l=this.fragments[o];if(l.from>=s.to)break;l.tree==this.curFrag.tree&&i.push({frag:l,pos:s.from-l.offset,mount:a})}}}return i}};function Efe(e,t){let n=null,r=t;for(let i=1,s=0;i<e.length;i++){let a=e[i-1].to,o=e[i].from;for(;s<r.length;s++){let l=r[s];if(l.from>=o)break;l.to<=a||(n||(r=n=t.slice()),l.from<a?(n[s]=new nu(l.from,a),l.to>o&&n.splice(s+1,0,new nu(o,l.to))):l.to>o?n[s--]=new nu(o,l.to):n.splice(s--,1))}}return r}function S3t(e,t,n,r){let i=0,s=0,a=!1,o=!1,l=-1e9,c=[];for(;;){let u=i==e.length?1e9:a?e[i].to:e[i].from,d=s==t.length?1e9:o?t[s].to:t[s].from;if(a!=o){let h=Math.max(l,n),f=Math.min(u,d,r);h<f&&c.push(new nu(h,f))}if(l=Math.min(u,d),l==1e9)break;u==l&&(a?(a=!1,i++):a=!0),d==l&&(o?(o=!1,s++):o=!0)}return c}function Rfe(e,t){let n=[];for(let{pos:r,mount:i,frag:s}of e){let a=r+(i.overlay?i.overlay[0].from:0),o=a+i.tree.length,l=Math.max(s.from,a),c=Math.min(s.to,o);if(i.overlay){let u=i.overlay.map(h=>new nu(h.from+r,h.to+r)),d=S3t(t,u,l,c);for(let h=0,f=l;;h++){let O=h==d.length,g=O?c:d[h].from;if(g>f&&n.push(new Bf(f,g,i.tree,-a,s.from>=f||s.openStart,s.to<=g||s.openEnd)),O)break;f=d[h].to}}else n.push(new Bf(l,c,i.tree,-a,s.from>=a||s.openStart,s.to<=o||s.openEnd))}return n}let yU=[],Y5e=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Y5e:yU).push(n=n+e[t])})();function $3t(e){if(e<768)return!1;for(let t=0,n=yU.length;;){let r=t+n>>1;if(e<yU[r])n=r;else if(e>=Y5e[r])t=r+1;else return!0;if(t==n)return!1}}function Afe(e){return e>=127462&&e<=127487}const Xfe=8205;function k3t(e,t,n=!0,r=!0){return(n?Z5e:T3t)(e,t,r)}function Z5e(e,t,n){if(t==e.length)return t;t&&H5e(e.charCodeAt(t))&&K5e(e.charCodeAt(t-1))&&t--;let r=BM(e,t);for(t+=Dfe(r);t<e.length;){let i=BM(e,t);if(r==Xfe||i==Xfe||n&&$3t(i))t+=Dfe(i),r=i;else if(Afe(i)){let s=0,a=t-2;for(;a>=0&&Afe(BM(e,a));)s++,a-=2;if(s%2==0)break;t+=2}else break}return t}function T3t(e,t,n){for(;t>0;){let r=Z5e(e,t-2,n);if(r<t)return r;t--}return 0}function BM(e,t){let n=e.charCodeAt(t);if(!K5e(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return H5e(r)?(n-55296<<10)+(r-56320)+65536:n}function H5e(e){return e>=56320&&e<57344}function K5e(e){return e>=55296&&e<56320}function Dfe(e){return e<65536?1:2}let Fr=class J5e{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,r){[t,n]=I1(this,t,n);let i=[];return this.decompose(0,t,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),th.from(i,this.length-(n-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=I1(this,t,n);let r=[];return this.decompose(t,n,r,0),th.from(r,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),i=new d$(this),s=new d$(t);for(let a=n,o=n;;){if(i.next(a),s.next(a),a=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(o+=i.value.length,i.done||o>=r)return!0}}iter(t=1){return new d$(this,t)}iterRange(t,n=this.length){return new e4e(this,t,n)}iterLines(t,n){let r;if(t==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(t).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new t4e(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?J5e.empty:t.length<=32?new $s(t):th.from($s.split(t,[]))}};class $s extends Fr{constructor(t,n=_3t(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,r,i){for(let s=0;;s++){let a=this.text[s],o=i+a.length;if((n?r:o)>=t)return new P3t(i,o,r,a);i=o+1,r++}}decompose(t,n,r,i){let s=t<=0&&n>=this.length?this:new $s(Ife(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let a=r.pop(),o=qQ(s.text,a.text.slice(),0,s.length);if(o.length<=32)r.push(new $s(o,a.length+s.length));else{let l=o.length>>1;r.push(new $s(o.slice(0,l)),new $s(o.slice(l)))}}else r.push(s)}replace(t,n,r){if(!(r instanceof $s))return super.replace(t,n,r);[t,n]=I1(this,t,n);let i=qQ(this.text,qQ(r.text,Ife(this.text,0,t)),n),s=this.length+r.length-(n-t);return i.length<=32?new $s(i,s):th.from($s.split(i,[]),s)}sliceString(t,n=this.length,r=`
1148
+ `,n);if(r===-1)break;const i=L5t(t.slice(n,r));if(e.fence){G5t(i,e.fence)&&(e.fence=null),n=r+1;continue}if(v5e.test(i)){e.blankRunStart<0&&(e.blankRunStart=n),n=r+1;continue}if(e.blankRunStart>=0){if(e.kind==="none"||!W5t(e.kind,i)){const s=t.slice(e.blockStart,e.blankRunStart);s.trim().length>0&&(e.blocks.push(s),e.revision+=1),e.blockStart=n,e.kind=efe(i)}e.blankRunStart=-1}else e.kind==="none"&&(e.kind=efe(i));if(e.kind!=="indented-code"){const s=j5t.exec(i);s&&(e.fence={char:s[1][0],length:s[1].length})}n=r+1}e.cursor=n},B5t=e=>{let t=e.length;for(;t>0;){const n=e.charCodeAt(t-1);if(n!==32&&n!==9&&n!==10&&n!==13)break;t-=1}return t},Kn="var(--color-ink)",nf="var(--color-ink-muted)",Xd="var(--color-surface)",VO="var(--color-elevated)",rf="var(--color-sunken)",io="var(--color-hairline)",BO="var(--color-control)",oy="var(--color-accent)",TS="var(--color-accent-wash)",Y5t="var(--color-on-accent)",Z5t="var(--color-info)",w5e="var(--color-info-wash)",H5t="var(--color-success)",x5e="var(--color-success-wash)",K5t="var(--color-warning)",OU="var(--color-warning-wash)",J5t="var(--color-warning-border)",zM="var(--color-danger)",pU="var(--color-danger-wash)",tfe=[TS,w5e,x5e,OU,pU],YO=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),e4t=()=>{const e={primaryColor:YO("--color-accent"),secondaryColor:YO("--color-success"),tertiaryColor:YO("--color-info"),mainBkg:YO("--color-elevated"),clusterBkg:YO("--color-sunken"),clusterBorder:YO("--color-hairline"),edgeLabelBackground:YO("--color-surface"),quadrant1Fill:YO("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:Xd,primaryTextColor:Kn,primaryBorderColor:BO,secondaryTextColor:Kn,secondaryBorderColor:io,tertiaryTextColor:Kn,tertiaryBorderColor:io,lineColor:nf,arrowheadColor:nf,textColor:Kn,secondBkg:rf,border1:BO,border2:io,labelColor:Kn,nodeBkg:VO,nodeBorder:BO,nodeTextColor:Kn,defaultLinkColor:nf,titleColor:Kn,noteBkgColor:OU,noteBorderColor:J5t,noteTextColor:Kn,actorBkg:VO,actorBorder:BO,actorTextColor:Kn,actorLineColor:io,signalColor:nf,signalTextColor:Kn,labelBoxBkgColor:VO,labelBoxBorderColor:io,labelTextColor:Kn,loopTextColor:Kn,activationBkgColor:TS,activationBorderColor:oy,sequenceNumberColor:Xd,sectionBkgColor:rf,sectionBkgColor2:Xd,altSectionBkgColor:rf,excludeBkgColor:rf,taskBkgColor:TS,taskBorderColor:BO,taskTextColor:Kn,taskTextLightColor:Kn,taskTextDarkColor:Kn,taskTextOutsideColor:Kn,taskTextClickableColor:oy,activeTaskBkgColor:TS,activeTaskBorderColor:oy,gridColor:io,doneTaskBkgColor:rf,doneTaskBorderColor:io,critBkgColor:pU,critBorderColor:zM,todayLineColor:oy,transitionColor:nf,transitionLabelColor:Kn,stateLabelColor:Kn,stateBkg:VO,labelBackgroundColor:Xd,compositeBackground:rf,altBackground:rf,compositeTitleBackground:VO,compositeBorder:io,innerEndBackground:Kn,specialStateColor:Kn,classText:Kn,attributeBackgroundColorOdd:Xd,attributeBackgroundColorEven:rf,rowOdd:Xd,rowEven:rf,errorBkgColor:pU,errorTextColor:zM,pieTitleTextColor:Kn,pieSectionTextColor:Kn,pieLegendTextColor:Kn,pieStrokeColor:Xd,pieOuterStrokeColor:io,requirementBackground:VO,requirementBorderColor:BO,requirementTextColor:Kn,relationColor:nf,relationLabelBackground:Xd,relationLabelColor:Kn,branchLabelColor:Y5t,commitLabelColor:Kn,commitLabelBackground:Xd,tagLabelColor:Kn,tagLabelBackground:TS,tagLabelBorder:BO,quadrant2Fill:w5e,quadrant3Fill:x5e,quadrant4Fill:OU,quadrant2TextFill:Kn,quadrant3TextFill:Kn,quadrant4TextFill:Kn,quadrantPointFill:oy,archEdgeColor:nf,archEdgeArrowColor:nf,archGroupBorderColor:io,scaleLabelColor:Kn,packet:{startByteColor:Kn,endByteColor:Kn,labelColor:Kn,titleColor:Kn,blockStrokeColor:BO,blockFillColor:VO},radar:{axisColor:nf,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:io,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Xd,titleColor:Kn,xAxisTitleColor:Kn,xAxisLabelColor:Kn,xAxisTickColor:io,xAxisLineColor:io,yAxisTitleColor:Kn,yAxisLabelColor:Kn,yAxisTickColor:io,yAxisLineColor:io,plotColorPalette:[oy,Z5t,H5t,K5t,zM].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=VO,t[`surfacePeer${n}`]=io;for(let n=0;n<8;n++)t[`fillType${n}`]=tfe[n%tfe.length];return{...t,...e}};let UM=null,nfe=null;const t4t=async e=>{UM||(UM=Ie(async()=>{const{default:n}=await import("./mermaid.core-w7CiwIS9.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([0,1,2]),import.meta.url).then(({default:n})=>n));const t=await UM;return nfe!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:e4t()}),nfe=e),t},rfe=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:s,onCopy:a,children:o})=>p.jsxs("div",{className:I("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[p.jsx(Ot,{content:"Zoom in",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:p.jsx(fJe,{})})}),p.jsx(Ot,{content:"Zoom out",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:p.jsx(pJe,{})})}),p.jsx(Ot,{content:"Drag the diagram to pan",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:p.jsx(XHe,{})})}),p.jsx(Ot,{content:"Reset view",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:p.jsx(hB,{})})}),p.jsx(Ot,{content:"Save as SVG",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:s,children:p.jsx(Bp,{})})}),p.jsx(Ot,{content:t?"Copied":"Copy mermaid text",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:a,children:p.jsx(hv,{className:I(t&&"text-success")})})}),o]}),gU=({title:e,children:t})=>p.jsxs(el,{variant:"danger",role:"alert",className:"my-4",children:[p.jsx(USe,{children:e}),p.jsx(vA,{children:t})]});class n4t extends w.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Mermaid Error Boundary caught an error:",t,n)}render(){return this.state.hasError?this.props.fallback||p.jsxs(gU,{title:"Mermaid diagram error",children:[this.state.error?.message||"An unexpected error occurred while rendering the diagram"," ","The error was contained within the diagram component."]}):this.props.children}}const r4t=w.memo(({chart:e,id:t})=>{const n=w.useRef(null),r=w.useRef(null),[i,s]=w.useState(null),[a,o]=w.useState(!0),[l,c]=w.useState(""),[u,d]=w.useState(!1),[h,f]=w.useState({scale:1,x:0,y:0}),[O,g]=w.useState({scale:1,x:0,y:0}),[m,v]=w.useState(!1),[y,b]=w.useState({x:0,y:0}),[T,x]=w.useState("idle"),[S,k]=w.useState("idle"),_=sr(D=>D.themeName),P=w.useCallback(async()=>{try{if(o(!0),s(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const D=await t4t(_),B=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:G}=await D.render(B,e);if(!G||typeof G!="string"||G.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(G)}catch(D){console.error("Mermaid rendering error:",D);const B=D instanceof Error?D.message:"Failed to render mermaid diagram";s(B),c("")}finally{o(!1)}},[e,t,_]);w.useEffect(()=>{P().catch(D=>{console.error("Error in renderDiagram effect:",D),s("Failed to initialize diagram rendering"),o(!1)})},[P]);const C=w.useCallback(()=>{try{if(!l||!r.current)return 1;const B=r.current.getBoundingClientRect(),G=document.createElement("div");G.innerHTML=l;const ee=G.querySelector("svg");if(!ee)return 1;const he=ee.getBoundingClientRect?.()?.width||Number.parseFloat(ee.getAttribute("width")||"0")||ee.viewBox?.baseVal?.width||800,ae=ee.getBoundingClientRect?.()?.height||Number.parseFloat(ee.getAttribute("height")||"0")||ee.viewBox?.baseVal?.height||600,se=B.width*.9/he,me=B.height*.9/ae;return Math.min(se,me,1)}catch(D){return console.error("Error calculating fullscreen scale:",D),1}},[l]);w.useEffect(()=>{u&&l&&setTimeout(()=>{try{const D=C();g({scale:D,x:0,y:0})}catch(D){console.error("Error setting fullscreen transform:",D)}},100)},[u,l,C]);const Q=w.useCallback((D=!1)=>{try{(D?g:f)(G=>({...G,scale:Math.min(G.scale*1.2,10)}))}catch(B){console.error("Error in zoom in:",B)}},[]),E=w.useCallback((D=!1)=>{try{(D?g:f)(G=>({...G,scale:Math.max(G.scale/1.2,.1)}))}catch(B){console.error("Error in zoom out:",B)}},[]),A=w.useCallback((D=!1)=>{try{const B=D?g:f;if(D){const G=C();B({scale:G,x:0,y:0})}else B({scale:1,x:0,y:0})}catch(B){console.error("Error in reset:",B)}},[C]),L=w.useCallback(()=>{if(l)try{const D=new Blob([l],{type:"image/svg+xml"}),B=URL.createObjectURL(D),G=document.createElement("a");G.href=B,G.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(B)}catch(D){console.error("Failed to save SVG:",D)}},[l]),j=w.useCallback(async()=>{try{await navigator.clipboard.writeText(e),x("copied"),setTimeout(()=>x("idle"),1200)}catch(D){console.error("Failed to copy Mermaid chart text:",D)}},[e]),q=w.useCallback(async()=>{try{await navigator.clipboard.writeText(e),k("copied"),setTimeout(()=>k("idle"),1200)}catch(D){console.error("Failed to copy Mermaid chart text:",D)}},[e]),z=w.useCallback(D=>{try{v(!0),b({x:D.clientX,y:D.clientY}),D.preventDefault()}catch(B){console.error("Error in mouse down:",B)}},[]),V=w.useCallback((D,B=!1)=>{try{if(!m)return;const G=D.clientX-y.x,ee=D.clientY-y.y;(B?g:f)(ae=>({...ae,x:ae.x+G,y:ae.y+ee})),b({x:D.clientX,y:D.clientY})}catch(G){console.error("Error in mouse move:",G)}},[m,y]),W=w.useCallback(()=>{try{v(!1)}catch(D){console.error("Error in mouse up:",D)}},[]),M=w.useCallback((D,B=!1)=>{try{D.preventDefault();const G=D.deltaY>0?.9:1.1;(B?g:f)(he=>({...he,scale:Math.min(Math.max(he.scale*G,.1),5)}))}catch(G){console.error("Error in wheel:",G)}},[]),K=w.useCallback(D=>{try{d(D)}catch(B){console.error("Error toggling fullscreen:",B)}},[]);if(i)return p.jsxs(gU,{title:"Mermaid diagram error",children:[i,p.jsx("span",{className:I("mt-2 block text-ink-muted"),children:"Chart"}),p.jsx("span",{className:I("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const N=(D=!1)=>{try{const B=D?r:n,G=D?O:h;return p.jsx("div",{ref:B,className:I("mermaid flex w-full items-center justify-center",D?"h-full min-h-full":"h-auto min-h-50",m?"cursor-grabbing":"cursor-grab"),onMouseDown:z,onMouseMove:ee=>V(ee,D),onMouseUp:W,onMouseLeave:W,onWheel:ee=>M(ee,D),children:a?p.jsx("div",{className:I("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?p.jsx("div",{className:I("flex h-full w-full items-center justify-center"),style:{transform:`translate(${G.x}px, ${G.y}px) scale(${G.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(B){return console.error("Error rendering diagram content:",B),p.jsx(gU,{title:"Rendering error",children:"Failed to render diagram content."})}};return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:I("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[N(!1),p.jsx(rfe,{className:"top-2 right-2",copied:T==="copied",onZoomIn:()=>Q(!1),onZoomOut:()=>E(!1),onReset:()=>A(!1),onSave:L,onCopy:j,children:p.jsx(Ot,{content:"Fullscreen",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>K(!0),children:p.jsx(wHe,{})})})})]}),p.jsx($g,{open:u,onClose:()=>K(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:p.jsxs("div",{className:I("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[N(!0),p.jsx(rfe,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>Q(!0),onZoomOut:()=>E(!0),onReset:()=>A(!0),onSave:L,onCopy:q,children:p.jsx(Ot,{content:"Close fullscreen",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>K(!1),children:p.jsx(Js,{})})})})]})})]})}),i4t=w.memo(e=>p.jsx(n4t,{children:p.jsx(r4t,{...e})}));let S5e=!1,WM=null;const s4t=()=>(WM||(WM=Ie(()=>Promise.resolve({}),__vite__mapDeps([3]),import.meta.url).then(e=>(S5e=!0,e))),WM),a4t=/language-(\w+)/,o4t=/\n$/,l4t=/\$(?!\d)(.+?)\$/,c4t=/\$\$([\s\S]+?)\$\$/,u4t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,d4t=/\\[a-zA-Z]+(\{[^}]*\})?/,$5e={a:({href:e,children:t})=>p.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}),code:({node:e,className:t,children:n,...r})=>a4t.exec(t??"")?.[1]==="mermaid"?p.jsx(i4t,{chart:String(n).replace(o4t,"")}):p.jsx("code",{className:t,...r,children:n})},h4t=[W3],f4t=[W3,M5t],O4t=[],p4t=[rEt],g4t=e=>l4t.test(e)||c4t.test(e)||u4t.test(e)?!0:d4t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),k5e=e=>w.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),T5e=e=>{const t=w.useMemo(()=>g4t(e),[e]),[n,r]=w.useState(()=>t&&S5e);return w.useEffect(()=>{if(!t||n)return;let i=!1;return s4t().then(()=>{i||r(!0)}),()=>{i=!0}},[t,n]),{remarkPlugins:n?f4t:h4t,rehypePlugins:n?p4t:O4t}},wv=w.memo(({content:e,styleProps:t,className:n})=>{const r=w.useMemo(()=>e.trim(),[e]),{remarkPlugins:i,rehypePlugins:s}=T5e(r),a=k5e(t);return p.jsx("div",{className:I("lo-markdown",n),style:a,children:p.jsx(OZ,{remarkPlugins:i,rehypePlugins:s,components:$5e,children:r})})});wv.displayName="MarkdownRenderer";const _5e=w.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=T5e(e);return p.jsx(OZ,{remarkPlugins:t,rehypePlugins:n,components:$5e,children:e})});_5e.displayName="StableBlock";const P5e=w.memo(({text:e,animate:t})=>p.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));P5e.displayName="ArrivedText";const C5e=({content:e,styleProps:t,className:n})=>{const r=w.useRef(null);r.current===null&&(r.current=z5t());const i=r.current,s=w.useRef([]),a=w.useRef(0);V5t(i,e);const o=a.current;e.length>o?(o>0&&s.current.push({offset:o,animate:!0}),a.current=e.length):e.length<o&&(s.current=[],a.current=e.length);const{blockStart:l}=i,c=s.current;let u=0;for(;u<c.length&&c[u].offset<=l;)u+=1;u>0&&c.splice(0,u);const d=l+B5t(e.slice(l)),h=[{offset:l,animate:!1}];for(const O of c){if(O.offset>=d)break;h.push(O)}const f=k5e(t);return p.jsxs("div",{className:I("lo-markdown",n),style:f,children:[i.blocks.map((O,g)=>p.jsx(_5e,{source:O},g)),d>l&&p.jsx("p",{className:"lo-stream-tail",children:h.map((O,g)=>{const m=h[g+1]?.offset??d;return p.jsx(P5e,{text:e.slice(O.offset,m),animate:O.animate},O.offset)})})]})};C5e.displayName="StreamingMarkdown";const Q5e=({className:e})=>p.jsx("div",{className:I("flex size-7 shrink-0 items-center justify-center rounded-full bg-sunken text-ink-muted",e),children:p.jsx(mw,{size:16,"aria-label":"Assistant"})}),v5="pl-10",ic=({isUser:e,children:t,isSmallView:n,showAvatar:r,className:i})=>e?p.jsx("div",{className:I("flex w-full justify-end",i),children:t}):p.jsxs("div",{className:I("relative w-full",!n&&v5,i),children:[r&&!n&&p.jsx(Q5e,{className:"absolute top-0 left-0"}),t]}),E5e=6048e5,m4t=864e5,ife=6e4,BWn=36e5,YWn=1e3,sfe=525600,afe=43200,ofe=1440,lfe=Symbol.for("constructDateFrom");function dO(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&lfe in e?e[lfe](t):e instanceof Date?new e.constructor(t):new Date(t)}function wc(e,t){return dO(t||e,e)}let v4t={};function tP(){return v4t}function TT(e,t){const n=tP(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=wc(e,t?.in),s=i.getDay(),a=(s<r?7:0)+s-r;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function y5(e,t){return TT(e,{...t,weekStartsOn:1})}function R5e(e,t){const n=wc(e,t?.in),r=n.getFullYear(),i=dO(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=y5(i),a=dO(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);const o=y5(a);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function b5(e){const t=wc(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function A5e(e,...t){const n=dO.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function cfe(e,t){const n=wc(e,t?.in);return n.setHours(0,0,0,0),n}function y4t(e,t,n){const[r,i]=A5e(n?.in,e,t),s=cfe(r),a=cfe(i),o=+s-b5(s),l=+a-b5(a);return Math.round((o-l)/m4t)}function b4t(e,t){const n=R5e(e,t),r=dO(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),y5(r)}function w4t(e,t){const n=+wc(e)-+wc(t);return n<0?-1:n>0?1:n}function x4t(e){return dO(e,Date.now())}function S4t(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function $4t(e){return!(!S4t(e)&&typeof e!="number"||isNaN(+wc(e)))}function k4t(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function T4t(e,t){const n=wc(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const _4t={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},P4t=(e,t,n)=>{let r;const i=_4t[e];return typeof i=="string"?r=i:t===1?r=i.one:r=i.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function GM(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const C4t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Q4t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},E4t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},R4t={date:GM({formats:C4t,defaultWidth:"full"}),time:GM({formats:Q4t,defaultWidth:"full"}),dateTime:GM({formats:E4t,defaultWidth:"full"})},A4t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},X4t=(e,t,n,r)=>A4t[e];function Ex(e){return(t,n)=>{const r=n?.context?String(n.context):"standalone";let i;if(r==="formatting"&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,o=n?.width?String(n.width):a;i=e.formattingValues[o]||e.formattingValues[a]}else{const a=e.defaultWidth,o=n?.width?String(n.width):e.defaultWidth;i=e.values[o]||e.values[a]}const s=e.argumentCallback?e.argumentCallback(t):t;return i[s]}}const D4t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},I4t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},N4t={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},F4t={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},M4t={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},L4t={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},j4t=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},q4t={ordinalNumber:j4t,era:Ex({values:D4t,defaultWidth:"wide"}),quarter:Ex({values:I4t,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ex({values:N4t,defaultWidth:"wide"}),day:Ex({values:F4t,defaultWidth:"wide"}),dayPeriod:Ex({values:M4t,defaultWidth:"wide",formattingValues:L4t,defaultFormattingWidth:"wide"})};function Rx(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(i);if(!s)return null;const a=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?U4t(o,d=>d.test(a)):z4t(o,d=>d.test(a));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;const u=t.slice(a.length);return{value:c,rest:u}}}function z4t(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function U4t(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function W4t(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const i=r[0],s=t.match(e.parsePattern);if(!s)return null;let a=e.valueCallback?e.valueCallback(s[0]):s[0];a=n.valueCallback?n.valueCallback(a):a;const o=t.slice(i.length);return{value:a,rest:o}}}const G4t=/^(\d+)(th|st|nd|rd)?/i,V4t=/\d+/i,B4t={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Y4t={any:[/^b/i,/^(a|c)/i]},Z4t={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},H4t={any:[/1/i,/2/i,/3/i,/4/i]},K4t={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},J4t={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},eAt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},tAt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},nAt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},rAt={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},iAt={ordinalNumber:W4t({matchPattern:G4t,parsePattern:V4t,valueCallback:e=>parseInt(e,10)}),era:Rx({matchPatterns:B4t,defaultMatchWidth:"wide",parsePatterns:Y4t,defaultParseWidth:"any"}),quarter:Rx({matchPatterns:Z4t,defaultMatchWidth:"wide",parsePatterns:H4t,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Rx({matchPatterns:K4t,defaultMatchWidth:"wide",parsePatterns:J4t,defaultParseWidth:"any"}),day:Rx({matchPatterns:eAt,defaultMatchWidth:"wide",parsePatterns:tAt,defaultParseWidth:"any"}),dayPeriod:Rx({matchPatterns:nAt,defaultMatchWidth:"any",parsePatterns:rAt,defaultParseWidth:"any"})},X5e={code:"en-US",formatDistance:P4t,formatLong:R4t,formatRelative:X4t,localize:q4t,match:iAt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function sAt(e,t){const n=wc(e,t?.in);return y4t(n,T4t(n))+1}function aAt(e,t){const n=wc(e,t?.in),r=+y5(n)-+b4t(n);return Math.round(r/E5e)+1}function D5e(e,t){const n=wc(e,t?.in),r=n.getFullYear(),i=tP(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=dO(t?.in||e,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const o=TT(a,t),l=dO(t?.in||e,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const c=TT(l,t);return+n>=+o?r+1:+n>=+c?r:r-1}function oAt(e,t){const n=tP(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=D5e(e,t),s=dO(t?.in||e,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),TT(s,t)}function lAt(e,t){const n=wc(e,t?.in),r=+TT(n,t)-+oAt(n,t);return Math.round(r/E5e)+1}function ti(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const ZO={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ti(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ti(n+1,2)},d(e,t){return ti(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ti(e.getHours()%12||12,t.length)},H(e,t){return ti(e.getHours(),t.length)},m(e,t){return ti(e.getMinutes(),t.length)},s(e,t){return ti(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return ti(i,t.length)}},ly={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},ufe={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return ZO.y(e,t)},Y:function(e,t,n,r){const i=D5e(e,r),s=i>0?i:1-i;if(t==="YY"){const a=s%100;return ti(a,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):ti(s,t.length)},R:function(e,t){const n=R5e(e);return ti(n,t.length)},u:function(e,t){const n=e.getFullYear();return ti(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ti(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ti(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return ZO.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ti(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const i=lAt(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):ti(i,t.length)},I:function(e,t,n){const r=aAt(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ti(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):ZO.d(e,t)},D:function(e,t,n){const r=sAt(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ti(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ti(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ti(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),i=r===0?7:r;switch(t){case"i":return String(i);case"ii":return ti(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let i;switch(r===12?i=ly.noon:r===0?i=ly.midnight:i=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let i;switch(r>=17?i=ly.evening:r>=12?i=ly.afternoon:r>=4?i=ly.morning:i=ly.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return ZO.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):ZO.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ti(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ti(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):ZO.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):ZO.s(e,t)},S:function(e,t){return ZO.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return hfe(r);case"XXXX":case"XX":return wm(r);case"XXXXX":case"XXX":default:return wm(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return hfe(r);case"xxxx":case"xx":return wm(r);case"xxxxx":case"xxx":default:return wm(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+dfe(r,":");case"OOOO":default:return"GMT"+wm(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+dfe(r,":");case"zzzz":default:return"GMT"+wm(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return ti(r,t.length)},T:function(e,t,n){return ti(+e,t.length)}};function dfe(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+t+ti(s,2)}function hfe(e,t){return e%60===0?(e>0?"-":"+")+ti(Math.abs(e)/60,2):wm(e,t)}function wm(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=ti(Math.trunc(r/60),2),s=ti(r%60,2);return n+i+t+s}const ffe=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},I5e=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},cAt=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return ffe(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",ffe(r,t)).replace("{{time}}",I5e(i,t))},uAt={p:I5e,P:cAt},dAt=/^D+$/,hAt=/^Y+$/,fAt=["D","DD","YY","YYYY"];function OAt(e){return dAt.test(e)}function pAt(e){return hAt.test(e)}function gAt(e,t,n){const r=mAt(e,t,n);if(console.warn(r),fAt.includes(e))throw new RangeError(r)}function mAt(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const vAt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,yAt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,bAt=/^'([^]*?)'?$/,wAt=/''/g,xAt=/[a-zA-Z]/;function VM(e,t,n){const r=tP(),i=n?.locale??r.locale??X5e,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=wc(e,n?.in);if(!$4t(o))throw new RangeError("Invalid time value");let l=t.match(yAt).map(u=>{const d=u[0];if(d==="p"||d==="P"){const h=uAt[d];return h(u,i.formatLong)}return u}).join("").match(vAt).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const d=u[0];if(d==="'")return{isToken:!1,value:SAt(u)};if(ufe[d])return{isToken:!0,value:u};if(d.match(xAt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:u}});i.localize.preprocessor&&(l=i.localize.preprocessor(o,l));const c={firstWeekContainsDate:s,weekStartsOn:a,locale:i};return l.map(u=>{if(!u.isToken)return u.value;const d=u.value;(!n?.useAdditionalWeekYearTokens&&pAt(d)||!n?.useAdditionalDayOfYearTokens&&OAt(d))&&gAt(d,t,String(e));const h=ufe[d[0]];return h(o,d,i.localize,c)}).join("")}function SAt(e){const t=e.match(bAt);return t?t[1].replace(wAt,"'"):e}function $At(e,t,n){const r=tP(),i=n?.locale??r.locale??X5e,s=w4t(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:s}),[o,l]=A5e(n?.in,...s>0?[t,e]:[e,t]),c=k4t("round"),u=l.getTime()-o.getTime(),d=u/ife,h=b5(l)-b5(o),f=(u-h)/ife,O=n?.unit;let g;if(d<1?g="second":d<60?g="minute":d<ofe?g="hour":f<afe?g="day":f<sfe?g="month":g="year",g==="second"){const m=c(u/1e3);return i.formatDistance("xSeconds",m,a)}else if(g==="minute"){const m=c(d);return i.formatDistance("xMinutes",m,a)}else if(g==="hour"){const m=c(d/60);return i.formatDistance("xHours",m,a)}else if(g==="day"){const m=c(f/ofe);return i.formatDistance("xDays",m,a)}else if(g==="month"){const m=c(f/afe);return m===12&&O!=="month"?i.formatDistance("xYears",1,a):i.formatDistance("xMonths",m,a)}else{const m=c(f/sfe);return i.formatDistance("xYears",m,a)}}function kAt(e,t){return $At(e,x4t(e),t)}const TAt=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e),n=new Date,r=new Date(n);if(r.setDate(n.getDate()-1),t.toDateString()===n.toDateString())return VM(t,"h:mm a");if(t.toDateString()===r.toDateString())return"Yesterday";const i=new Date(n);return i.setDate(n.getDate()-7),t>i?VM(t,"EEEE"):VM(t,"yyyy-MM-dd")}catch(t){return console.error("Error formatting date:",t),""}},ZWn=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(navigator.language,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},_At=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString(navigator.language,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}catch(t){return console.error("Error formatting calendar date-time:",t),""}},jZ=({timestamp:e,className:t})=>p.jsx(Ot,{content:_At(e),side:"bottom",delayDuration:1200,children:p.jsx("span",{className:I("shrink-0 cursor-help whitespace-nowrap text-ink-dim text-meta",t),children:TAt(e)})}),N5e=({content:e,busy:t=!1,className:n})=>e?p.jsxs("section",{"aria-label":"Question from the agent",className:I("flex gap-3 rounded-md border border-accent bg-accent-wash px-4 py-3",n),children:[p.jsx(kHe,{className:"mt-0.5 size-4 shrink-0 text-accent","aria-hidden":!0}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[p.jsx("p",{className:"font-medium text-accent text-meta",children:t?"Sending your answer…":"Waiting for your answer"}),p.jsx("div",{className:"lo-on-wash text-ink",children:p.jsx(wv,{content:e})})]})]}):null,PAt=({options:e,recommended:t,busy:n=!1,onAnswer:r,requestId:i})=>{if(e.length===0)return null;const s=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<e.length?t:null;return p.jsx("fieldset",{"aria-label":"Answer options",className:"mt-1 flex min-w-0 max-h-[380px] flex-col gap-2 overflow-y-auto border-0 px-0 py-1",children:e.map((a,o)=>p.jsxs("button",{type:"button",disabled:n,onClick:()=>r(a.label),className:I("flex w-full items-baseline gap-2 rounded-sm border px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","border-control bg-surface hover:bg-elevated active:bg-sunken","disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled"),children:[o<9&&p.jsxs("span",{"aria-hidden":!0,className:I("shrink-0 font-mono text-mono-sm",n?"text-ink-disabled":"text-ink-dim"),children:[o+1,"."]}),p.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[p.jsxs("span",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[p.jsx("span",{className:I("min-w-0 text-body-sm",n?"text-ink-disabled":"text-ink"),children:a.label}),s===o&&p.jsx("span",{className:I("shrink-0 font-medium text-meta",n?"text-ink-disabled":"text-ink"),children:"Recommended"})]}),a.description&&p.jsx("span",{className:I("text-body-sm",n?"text-ink-disabled":"text-ink-muted"),children:a.description})]})]},`${i}-${String(o)}`))})},F5e=({children:e,className:t})=>p.jsx("span",{"aria-hidden":!0,className:I("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),qZ=({label:e="Reasoning",content:t})=>!sr(r=>r.showAgentReasoning)||!t?null:p.jsx(fd,{summary:p.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p.jsx(F5e,{}),p.jsx("span",{className:"truncate",children:p.jsx("span",{className:"text-ink-dim text-meta",children:e})})]}),children:p.jsx(wv,{content:t,className:"[--md-ink:var(--lo-ink-muted)]",styleProps:{fontSize:"var(--text-body-sm)",lineHeight:"var(--text-body-sm--line-height)"}})}),CAt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},QAt=({line:e})=>p.jsx("span",{className:I(CAt[e.kind],"block"),children:e.text}),EAt=({diff:e,className:t})=>{const n=xst(e);return p.jsxs("div",{className:I("max-h-[740px] overflow-y-auto overflow-x-hidden rounded-sm border border-hairline bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",t),children:[n.lines.map((r,i)=>p.jsx(QAt,{line:r},i)),n.hidden>0&&p.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:Sst(n.hidden)})]})},RAt=({content:e,details:t,className:n})=>p.jsxs("section",{"aria-label":"Security notice",className:I("flex gap-3 border-warning border-l-2 py-0.5 pl-3",n),children:[p.jsx(CKe,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":!0}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[p.jsx("p",{className:"font-medium text-body-sm text-warning",children:"Blocked a risky action"}),e?p.jsx("p",{className:"text-body-sm text-ink-muted",children:e}):null,t?p.jsx(fd,{summary:p.jsx("span",{className:"text-meta",children:"Show the reviewed code"}),children:t}):null]})]}),AAt=(e,t=72)=>{let i=e.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\s+/g," ").trim();if(i.length>t){const s=i.slice(0,t),a=s.lastIndexOf(" ");i=`${s.slice(0,a>32?a:t).trimEnd()}…`}return i.replace(/[.!?…]+$/g,"").trimEnd()},Ofe=e=>e.startsWith("file://")?e.slice(7):e,XAt={READ:{verb:"Read",runningVerb:"Reading",icon:rB},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:uB},EDIT:{verb:"Edited",runningVerb:"Editing",icon:BHe},CODE:{verb:"Ran code",runningVerb:"Running code",icon:iB},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:_Ke},DONE:{verb:"Finished",runningVerb:"Finishing",icon:RV},ASK:{verb:"Asked",runningVerb:"Asking",icon:kA},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:fZe}},DAt={verb:"Worked on the request",runningVerb:"Working on the request",icon:iB},IAt=(e,t,n,r)=>{const i=e?XAt[e]:DAt;let s;if(t)s=Ofe(t);else if(n&&n.length>0){const o=n.filter(l=>!l.startsWith("data:"));o.length===1?s=Ofe(o[0]):o.length>1&&(s=`${o.length} files`)}const a=!s&&r?AAt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:s,narration:a||void 0,icon:i.icon}},pfe="min-h-5 py-0",NAt=({icon:e,verb:t,object:n,narration:r,running:i,failed:s,wrap:a})=>p.jsxs("span",{className:I("flex min-w-0 gap-2",a?"items-start":"items-center"),"aria-busy":i||void 0,children:[p.jsx(F5e,{className:I(s?"text-danger":"text-ink-dim",a&&oQe),children:e}),p.jsxs("span",{className:I(a?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[p.jsxs("span",{...cM,className:I("select-text font-mono text-mono-sm",i?"text-ink-muted":"text-ink-dim",s&&"text-danger"),children:[t,r?":":null]}),n?p.jsxs("span",{...cM,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?p.jsxs("span",{...cM,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),w5=({action:e,filePath:t,files:n,narration:r,running:i=!1,failed:s=!1,defaultOpen:a=!1,details:o,className:l,verbOverride:c,object:u,glyph:d,wrap:h,dense:f=!1})=>{const O=IAt(e,t,n,r),g=c??(i?O.runningVerb:O.verb),m=s?y0:O.icon,v=s||!c||!d?p.jsx(m,{}):d,y=p.jsx(NAt,{icon:v,verb:g,object:c?u:O.object,narration:c?r:O.narration,running:i,failed:s,wrap:h}),b=h?"firstLine":"center";return o?p.jsx(fd,{summary:y,chevron:"leading",summaryAlign:b,defaultOpen:a,className:l,rowClassName:f?pfe:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:o}):p.jsx(fd,{disabled:!0,summary:y,summaryAlign:b,className:l,rowClassName:f?pfe:void 0})},M5e=8,FAt="… deeper values not shown",MAt="(empty)";function LAt(e){return`… ${e} more line${e===1?"":"s"}`}const gfe=.5;function jAt(e,t,n,r){if(!Number.isFinite(t)||t<=0)return 0;let i=0;for(const s of e){if(s.height<=0)continue;const a=Math.max(1,Math.round(s.height/t));for(let o=1;o<=a;o++)s.top+o*t>n+r&&i++}return i}function L5e(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function zZ(e){return typeof e=="object"&&e!==null}function j5e(e,t,n,r){if(n>M5e){r.push({key:t,value:FAt,depth:n});return}if(zZ(e)){for(const[s,a]of Object.entries(e))j5e(a,t?`${t}.${s}`:s,n+1,r);return}const i=L5e(e);i!==null&&r.push({key:t,value:i,depth:n})}function q5e(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))j5e(r,n,1,t);return t}const qAt=512;function zAt(e,t){if(t)return!0;if(!e)return!1;let n=qAt;const r=(i,s)=>{if(n--<=0||s>M5e)return!0;if(!zZ(i))return L5e(i)!==null;for(const a of Object.values(i))if(r(a,s+1))return!0;return!1};for(const i of Object.values(e))if(r(i,1))return!0;return!1}function UAt(e){if(!e)return null;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!zZ(n))return null;const r=q5e(n);return r.length>0?r:[{key:"",value:MAt,depth:1}]}const WAt=8,mfe="max-h-[240px]",GAt=({line:e})=>p.jsxs("div",{className:I("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*WAt},children:[e.key?p.jsxs("span",{className:I("text-ink-dim"),children:[e.key,": "]}):null,p.jsx("span",{className:I("text-ink-muted"),children:e.value})]}),vfe=({lines:e,label:t})=>p.jsx("div",{className:I("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>p.jsx(GAt,{line:n},r))});function yfe(e){const[t,n]=w.useState(0),[r,i]=w.useState(!1);return w.useLayoutEffect(()=>{const s=e.current;if(!s)return;const a=s.firstElementChild,o=()=>{const c=a??s,u=Number.parseFloat(getComputedStyle(c).lineHeight);if(!Number.isFinite(u)||u<=0){n(0),i(!1);return}const d=s.getBoundingClientRect(),h=c.getBoundingClientRect();i(h.height>d.height+gfe);const f=c.children.length>0?Array.from(c.children):[c];n(jAt(f.map(O=>{const g=O.getBoundingClientRect();return{top:g.top,height:g.height}}),u,d.bottom,gfe))};o(),s.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(o);return l.observe(a??s),()=>{s.removeEventListener("scroll",o),l.disconnect()}}),{lines:t,overflowing:r}}const bfe=({lines:e,overflowing:t})=>t?p.jsx("span",{className:I("mt-1 block text-ink-dim"),children:e>0?LAt(e):" "}):null,VAt=({args:e,output:t,isError:n})=>{const r=q5e(e),i=UAt(t),s=w.useRef(null),a=w.useRef(null),o=yfe(s),l=yfe(a);return r.length===0&&!t?null:p.jsxs("div",{className:I("w-full rounded-sm border border-hairline bg-sunken p-3 font-mono text-mono-sm"),children:[r.length>0&&p.jsxs("div",{"data-detail-section":"input",children:[p.jsx("div",{ref:s,className:I(mfe,"overflow-auto"),children:p.jsx(vfe,{lines:r,label:"input"})}),p.jsx(bfe,{lines:o.lines,overflowing:o.overflowing})]}),t&&p.jsxs("div",{className:I(r.length>0&&"mt-3"),"data-detail-section":"output",children:[p.jsx("span",{className:I("mb-1 block text-meta",n?"text-danger":"text-ink-dim"),children:n?"Error":"Output"}),p.jsx("div",{ref:a,className:I(mfe,"overflow-auto"),children:i?p.jsx(vfe,{lines:i,label:"result-json"}):p.jsx("pre",{className:I("whitespace-pre font-mono",n?"text-danger":"text-ink"),children:t})}),p.jsx(bfe,{lines:l.lines,overflowing:l.overflowing})]})]})},BAt="mcp__",YAt={bash:eJe,read:Yp,write:Rne,edit:Rne,glob:fk,grep:CA,todo:hHe,wake:TA,list_variables:VE,read_variable:VE,browser:Xne,web_search:Xne,web_fetch:Bp,task:qf,agent:qf,send:fB,peer:tHe};function ZAt(e){const t=e.trim().toLowerCase(),n=YAt[t];return n||(t.startsWith(BAt)?dB:xWe)}const HAt=bc,KAt=Js,JAt=Xke,wfe="min-h-5 py-0",e3t={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent",plain:"text-ink-muted"},t3t=(e,t)=>e==="running"?"text-ink":e==="error"?"text-danger":e==="receipt"?"text-ink-muted":e3t[dst(t)],n3t=({added:e,removed:t})=>e<=0&&t<=0?null:p.jsxs("span",{className:I("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&p.jsxs("span",{className:I("text-success"),children:["+",e]}),t>0&&p.jsxs("span",{className:I("text-danger"),children:["-",t]})]}),xfe={running:"",success:"succeeded",error:"failed",interrupted:"interrupted",receipt:""},r3t=1e3;function i3t(e){const[t,n]=w.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return w.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,r3t);return()=>window.clearInterval(i)},[e]),t}const s3t=({outcome:e,durationS:t,startedAt:n})=>{const r=e==="running",i=i3t(r?n??null:null),s=e==="success"?HAt:e==="error"?KAt:e==="interrupted"?JAt:null,a=e==="success"?"text-success":e==="error"?"text-danger":"text-ink-dim",o=r?n==null?"":IB(i??0):lst(t);return p.jsxs("span",{className:I("flex shrink-0 items-center gap-1.5"),children:[p.jsxs("span",{className:I("flex size-3.5 shrink-0 [&_svg]:size-3.5",a),children:[s?p.jsx(s,{"aria-hidden":!0}):null,xfe[e]?p.jsx("span",{className:I("sr-only"),children:xfe[e]}):null]}),p.jsx("span",{className:I("w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums"),children:o})]})},x5=({toolName:e,summary:t,summaryFallback:n=null,outcome:r,durationS:i,startedAt:s=null,added:a=0,removed:o=0,nameColumn:l=o_e,details:c,defaultOpen:u=!1,className:d,media:h})=>{const f=r==="running",O=r==="error",g=ZAt(e),m=Dk(e),v=a_e(t,e)?n??"":t,y=p.jsxs("span",{className:I("flex min-w-0 flex-1 items-center gap-2"),children:[p.jsx("span",{"aria-hidden":!0,className:I("flex size-3.5 shrink-0 [&_svg]:size-3.5",f?"text-accent":O?"text-danger":"text-ink-dim"),children:p.jsx(g,{})}),p.jsx("span",{className:I("shrink-0 truncate font-mono text-mono-sm","pr-1",t3t(r,e)),style:{width:`calc(${l}ch + 0.25rem)`},title:m,children:m}),p.jsx("span",{className:I("min-w-0 flex-1 truncate font-mono text-mono-sm",f?"text-ink-muted":"text-ink-dim"),title:v,children:v}),p.jsx(n3t,{added:a,removed:o}),p.jsx(s3t,{outcome:r,durationS:i,startedAt:s})]}),b=f?"bg-elevated":O?"bg-danger-wash":"hover:bg-elevated",T=c?p.jsx(fd,{summary:y,chevron:"leading",defaultOpen:u,className:I("@container/toolrow",d),rowClassName:wfe,triggerClassName:I("-mx-2 rounded-sm px-2",b),children:c}):p.jsx(fd,{disabled:!0,summary:y,rowClassName:wfe,className:I("@container/toolrow",(f||O)&&I("-mx-2 rounded-sm px-2",b),d)});return h?p.jsxs("div",{className:I("flex flex-col"),children:[T,h]}):T},z5e=e=>{const t=w.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=w.useCallback(()=>window.matchMedia(e).matches,[e]);return w.useSyncExternalStore(t,n,()=>!1)},Sfe=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],a3t=80,o3t=1e3,l3t=({activity:e,phase:t,className:n})=>{const[r,i]=w.useState(0),[s,a]=w.useState(0),o=z5e("(prefers-reduced-motion: reduce)"),l=w.useRef(Date.now()),c=w.useRef(t);return c.current!==t&&(c.current=t,l.current=Date.now(),a(0)),w.useEffect(()=>{const u=window.setInterval(()=>a(Math.floor((Date.now()-l.current)/1e3)),o3t);if(o)return i(0),()=>window.clearInterval(u);const d=window.setInterval(()=>i(h=>(h+1)%Sfe.length),a3t);return()=>{window.clearInterval(d),window.clearInterval(u)}},[o]),p.jsxs("div",{className:I("flex items-center gap-2",n),"data-lo-working-line":!0,"aria-live":"polite",children:[p.jsx("span",{"aria-hidden":!0,className:I("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:Sfe[r]}),p.jsx("span",{className:I("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),p.jsx("span",{"aria-hidden":!0,className:I("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:IB(s)})]})},U5e=({children:e,className:t})=>p.jsx("div",{className:I("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm border border-hairline bg-sunken",t),children:e}),c3t="could not be displayed. It may have been moved, renamed, or deleted.",u3t="could not be displayed. Its stored copy is not available to this reader.",UZ=({name:e,detail:t=c3t,className:n})=>p.jsxs("div",{className:I("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[p.jsx(KZe,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),p.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[p.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),G3=({filePath:e,tooltip:t="File actions",icon:n,"aria-label":r="File actions",onShowInCanvas:i})=>{const s=async()=>{if(e)try{await navigator.clipboard.writeText(e),Rs("File path copied to clipboard")}catch(o){console.error("Failed to copy file path: ",o),or("Failed to copy file path")}},a=()=>{e&&window.api.openFile(e)};return p.jsxs(X_,{children:[p.jsx(Ot,{content:t,children:p.jsx(Ub,{asChild:!0,children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":r,onClick:o=>o.stopPropagation(),children:n??p.jsx(sB,{"aria-hidden":"true"})})})}),p.jsxs(D_,{align:"end",className:"min-w-45",onClick:o=>o.stopPropagation(),children:[i&&p.jsxs(ks,{onSelect:i,children:[p.jsx(lHe,{"aria-hidden":"true"}),p.jsx("span",{children:"Show in canvas"})]}),p.jsxs(ks,{onSelect:a,children:[p.jsx(vw,{"aria-hidden":"true"}),p.jsx("span",{children:"Open file"})]}),p.jsxs(ks,{onSelect:()=>window.api.showItemInFolder(e),children:[p.jsx(fk,{"aria-hidden":"true"}),p.jsx("span",{children:"Open folder"})]}),p.jsxs(ks,{onSelect:s,children:[p.jsx(Dke,{"aria-hidden":"true"}),p.jsx("span",{children:"Copy file path"})]})]})]})},W5e=1024;let d3t=0,nu=class{constructor(t,n){this.from=t,this.to=n}};class In{constructor(t={}){this.id=d3t++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=na.match(t)),n=>{let r=t(n);return r===void 0?null:[this,r]}}}In.closedBy=new In({deserialize:e=>e.split(" ")});In.openedBy=new In({deserialize:e=>e.split(" ")});In.group=new In({deserialize:e=>e.split(" ")});In.isolate=new In({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});In.contextHash=new In({perNode:!0});In.lookAhead=new In({perNode:!0});In.mounted=new In({perNode:!0});class _T{constructor(t,n,r){this.tree=t,this.overlay=n,this.parser=r}static get(t){return t&&t.props&&t.props[In.mounted.id]}}const h3t=Object.create(null);class na{constructor(t,n,r,i=0){this.name=t,this.props=n,this.id=r,this.flags=i}static define(t){let n=t.props&&t.props.length?Object.create(null):h3t,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new na(t.name||"",n,t.id,r);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let n=this.prop(In.group);return n?n.indexOf(t)>-1:!1}return this.id==t}static match(t){let n=Object.create(null);for(let r in t)for(let i of r.split(" "))n[i]=t[r];return r=>{for(let i=r.prop(In.group),s=-1;s<(i?i.length:0);s++){let a=n[s<0?r.name:i[s]];if(a)return a}}}}na.none=new na("",Object.create(null),0,8);class Mw{constructor(t){this.types=t;for(let n=0;n<t.length;n++)if(t[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let n=[];for(let r of this.types){let i=null;for(let s of t){let a=s(r);a&&(i||(i=Object.assign({},r.props)),i[a[0].id]=a[1])}n.push(i?new na(r.name,i,r.id,r.flags):r)}return new Mw(n)}}const N2=new WeakMap,$fe=new WeakMap;var bi;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"})(bi||(bi={}));class vr{constructor(t,n,r,i,s){if(this.type=t,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[a,o]of s)this.props[typeof a=="number"?a:a.id]=o}}toString(){let t=_T.get(this);if(t&&!t.overlay)return t.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(t=0){return new S5(this.topNode,t)}cursorAt(t,n=0,r=0){let i=N2.get(this)||this.topNode,s=new S5(i);return s.moveTo(t,n),N2.set(this,s._tree),s}get topNode(){return new To(this,0,0,null)}resolve(t,n=0){let r=PT(N2.get(this)||this.topNode,t,n,!1);return N2.set(this,r),r}resolveInner(t,n=0){let r=PT($fe.get(this)||this.topNode,t,n,!0);return $fe.set(this,r),r}resolveStack(t,n=0){return p3t(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:s=this.length}=t,a=t.mode||0,o=(a&bi.IncludeAnonymous)>0;for(let l=this.cursor(a|bi.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=i&&(!o&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(o||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let n in this.props)t.push([+n,this.props[n]]);return t}balance(t={}){return this.children.length<=8?this:VZ(na.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new vr(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new vr(na.none,n,r,i)))}static build(t){return g3t(t)}}vr.empty=new vr(na.none,[],[],0);class WZ{constructor(t,n){this.buffer=t,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new WZ(this.buffer,this.index)}}class lg{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return na.none}toString(){let t=[];for(let n=0;n<this.buffer.length;)t.push(this.childString(n)),n=this.buffer[n+3];return t.join(",")}childString(t){let n=this.buffer[t],r=this.buffer[t+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),t+=4,r==t)return s;let a=[];for(;t<r;)a.push(this.childString(t)),t=this.buffer[t+3];return s+"("+a.join(",")+")"}findChild(t,n,r,i,s){let{buffer:a}=this,o=-1;for(let l=t;l!=n&&!(G5e(s,i,a[l+1],a[l+2])&&(o=l,r>0));l=a[l+3]);return o}slice(t,n,r){let i=this.buffer,s=new Uint16Array(n-t),a=0;for(let o=t,l=0;o<n;){s[l++]=i[o++],s[l++]=i[o++]-r;let c=s[l++]=i[o++]-r;s[l++]=i[o++]-t,a=Math.max(a,c)}return new lg(s,a,this.set)}}function G5e(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function PT(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let a=!r&&e instanceof To&&e.index<0?null:e.parent;if(!a)return e;e=a}let s=r?0:bi.IgnoreOverlays;if(r)for(let a=e,o=a.parent;o;a=o,o=a.parent)a instanceof To&&a.index<0&&((i=o.enter(t,n,s))===null||i===void 0?void 0:i.from)!=a.from&&(e=o);for(;;){let a=e.enter(t,n,s);if(!a)return e;e=a}}class V5e{cursor(t=0){return new S5(this,t)}getChild(t,n=null,r=null){let i=kfe(this,t,n,r);return i.length?i[0]:null}getChildren(t,n=null,r=null){return kfe(this,t,n,r)}resolve(t,n=0){return PT(this,t,n,!1)}resolveInner(t,n=0){return PT(this,t,n,!0)}matchContext(t){return mU(this.parent,t)}enterUnfinishedNodesBefore(t){let n=this.childBefore(t),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class To extends V5e{constructor(t,n,r,i){super(),this._tree=t,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,s=0){for(let a=this;;){for(let{children:o,positions:l}=a._tree,c=n>0?o.length:-1;t!=c;t+=n){let u=o[t],d=l[t]+a.from;if(G5e(i,r,d,d+u.length)){if(u instanceof lg){if(s&bi.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,n,r-d,i);if(h>-1)return new dh(new f3t(a,u,t,d),null,h)}else if(s&bi.IncludeAnonymous||!u.type.isAnonymous||GZ(u)){let h;if(!(s&bi.IgnoreMounts)&&(h=_T.get(u))&&!h.overlay)return new To(h.tree,d,t,a);let f=new To(u,d,t,a);return s&bi.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(n<0?u.children.length-1:0,n,r,i)}}}if(s&bi.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?t=a.index+n:t=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,n,r=0){let i;if(!(r&bi.IgnoreOverlays)&&(i=_T.get(this._tree))&&i.overlay){let s=t-this.from;for(let{from:a,to:o}of i.overlay)if((n>0?a<=s:a<s)&&(n<0?o>=s:o>s))return new To(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function kfe(e,t,n,r){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let a=!1;!a;)if(a=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(t)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function mU(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class f3t{constructor(t,n,r,i){this.parent=t,this.buffer=n,this.index=r,this.start=i}}class dh extends V5e{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,n,r){super(),this.context=t,this._parent=n,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return s<0?null:new dh(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,n,r=0){if(r&bi.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return s<0?null:new dh(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new dh(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new dh(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let a=r.buffer[this.index+1];t.push(r.slice(i,s,a)),n.push(0)}return new vr(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function B5e(e){if(!e.length)return null;let t=0,n=e[0];for(let s=1;s<e.length;s++){let a=e[s];(a.from>n.from||a.to<n.to)&&(n=a,t=s)}let r=n instanceof To&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new O3t(i,n)}class O3t{constructor(t,n){this.heads=t,this.node=n}get next(){return B5e(this.heads)}}function p3t(e,t,n){let r=e.resolveInner(t,n),i=null;for(let s=r instanceof To?r:r.context.parent;s;s=s.parent)if(s.index<0){let a=s.parent;(i||(i=[r])).push(a.resolve(t,n)),s=a}else{let a=_T.get(s.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new To(a.tree,a.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(PT(o,t,n,!1))}}return i?B5e(i):r}class S5{get name(){return this.type.name}constructor(t,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof To)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let r=t._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,n){this.index=t;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[t]],this.from=r+i.buffer[t+1],this.to=r+i.buffer[t+2],!0}yield(t){return t?t instanceof To?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,n,r=this.mode){return this.buffer?r&bi.ExcludeBuffers?!1:this.enterChild(1,t,n):this.yield(this._tree.enter(t,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&bi.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&bi.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(t<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let n,r,{buffer:i}=this;if(i){if(t>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+t,a=t<0?-1:r._tree.children.length;s!=a;s+=t){let o=r._tree.children[s];if(this.mode&bi.IncludeAnonymous||o instanceof lg||!o.type.isAnonymous||GZ(o))return!1}return!0}move(t,n){if(n&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,n=0){for(;(this.from==this.to||(n<1?this.from>=t:this.from>t)||(n>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,n););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,n=null,r=0;if(t&&t.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let a=t;a;a=a._parent)if(a.index==i){if(i==this.index)return a;n=a,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new dh(this.buffer,n,this.stack[i]);return this.bufferNode=new dh(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(t){if(!this.buffer)return mU(this.node.parent,t);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=t.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return mU(this._tree,t,i);let a=r[n.buffer[this.stack[s]]];if(!a.isAnonymous){if(t[i]&&t[i]!=a.name)return!1;i--}}return!0}}function GZ(e){return e.children.some(t=>t instanceof lg||!t.type.isAnonymous||GZ(t))}function g3t(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=W5e,reused:s=[],minRepeatType:a=r.types.length}=e,o=Array.isArray(n)?new WZ(n,n.length):n,l=r.types,c=0,u=0;function d(x,S,k,_,P,C){let{id:Q,start:E,end:A,size:L}=o,j=u,q=c;for(;L<0;)if(o.next(),L==-1){let K=s[Q];k.push(K),_.push(E-x);return}else if(L==-3){c=Q;return}else if(L==-4){u=Q;return}else throw new RangeError(`Unrecognized record size: ${L}`);let z=l[Q],V,W,M=E-x;if(A-E<=i&&(W=m(o.pos-S,P))){let K=new Uint16Array(W.size-W.skip),N=o.pos-W.size,D=K.length;for(;o.pos>N;)D=v(W.start,K,D);V=new lg(K,A-W.start,r),M=W.start-x}else{let K=o.pos-L;o.next();let N=[],D=[],B=Q>=a?Q:-1,G=0,ee=A;for(;o.pos>K;)B>=0&&o.id==B&&o.size>=0?(o.end<=ee-i&&(O(N,D,E,G,o.end,ee,B,j,q),G=N.length,ee=o.end),o.next()):C>2500?h(E,K,N,D):d(E,K,N,D,B,C+1);if(B>=0&&G>0&&G<N.length&&O(N,D,E,G,E,ee,B,j,q),N.reverse(),D.reverse(),B>-1&&G>0){let he=f(z,q);V=VZ(z,N,D,0,N.length,0,A-E,he,he)}else V=g(z,N,D,A-E,j-A,q)}k.push(V),_.push(M)}function h(x,S,k,_){let P=[],C=0,Q=-1;for(;o.pos>S;){let{id:E,start:A,end:L,size:j}=o;if(j>4)o.next();else{if(Q>-1&&A<Q)break;Q<0&&(Q=L-i),P.push(E,A,L),C++,o.next()}}if(C){let E=new Uint16Array(C*4),A=P[P.length-2];for(let L=P.length-3,j=0;L>=0;L-=3)E[j++]=P[L],E[j++]=P[L+1]-A,E[j++]=P[L+2]-A,E[j++]=j;k.push(new lg(E,P[2]-A,r)),_.push(A-x)}}function f(x,S){return(k,_,P)=>{let C=0,Q=k.length-1,E,A;if(Q>=0&&(E=k[Q])instanceof vr){if(!Q&&E.type==x&&E.length==P)return E;(A=E.prop(In.lookAhead))&&(C=_[Q]+E.length+A)}return g(x,k,_,P,C,S)}}function O(x,S,k,_,P,C,Q,E,A){let L=[],j=[];for(;x.length>_;)L.push(x.pop()),j.push(S.pop()+k-P);x.push(g(r.types[Q],L,j,C-P,E-C,A)),S.push(P-k)}function g(x,S,k,_,P,C,Q){if(C){let E=[In.contextHash,C];Q=Q?[E].concat(Q):[E]}if(P>25){let E=[In.lookAhead,P];Q=Q?[E].concat(Q):[E]}return new vr(x,S,k,_,Q)}function m(x,S){let k=o.fork(),_=0,P=0,C=0,Q=k.end-i,E={size:0,start:0,skip:0};e:for(let A=k.pos-x;k.pos>A;){let L=k.size;if(k.id==S&&L>=0){E.size=_,E.start=P,E.skip=C,C+=4,_+=4,k.next();continue}let j=k.pos-L;if(L<0||j<A||k.start<Q)break;let q=k.id>=a?4:0,z=k.start;for(k.next();k.pos>j;){if(k.size<0)if(k.size==-3)q+=4;else break e;else k.id>=a&&(q+=4);k.next()}P=z,_+=L,C+=q}return(S<0||_==x)&&(E.size=_,E.start=P,E.skip=C),E.size>4?E:void 0}function v(x,S,k){let{id:_,start:P,end:C,size:Q}=o;if(o.next(),Q>=0&&_<a){let E=k;if(Q>4){let A=o.pos-(Q-4);for(;o.pos>A;)k=v(x,S,k)}S[--k]=E,S[--k]=C-x,S[--k]=P-x,S[--k]=_}else Q==-3?c=_:Q==-4&&(u=_);return k}let y=[],b=[];for(;o.pos>0;)d(e.start||0,e.bufferStart||0,y,b,-1,0);let T=(t=e.length)!==null&&t!==void 0?t:y.length?b[0]+y[0].length:0;return new vr(l[e.topID],y.reverse(),b.reverse(),T)}const Tfe=new WeakMap;function jQ(e,t){if(!e.isAnonymous||t instanceof lg||t.type!=e)return 1;let n=Tfe.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof vr)){n=1;break}n+=jQ(e,r)}Tfe.set(t,n)}return n}function VZ(e,t,n,r,i,s,a,o,l){let c=0;for(let O=r;O<i;O++)c+=jQ(e,t[O]);let u=Math.ceil(c*1.5/8),d=[],h=[];function f(O,g,m,v,y){for(let b=m;b<v;){let T=b,x=g[b],S=jQ(e,O[b]);for(b++;b<v;b++){let k=jQ(e,O[b]);if(S+k>=u)break;S+=k}if(b==T+1){if(S>u){let k=O[T];f(k.children,k.positions,0,k.children.length,g[T]+y);continue}d.push(O[T])}else{let k=g[b-1]+O[b-1].length-x;d.push(VZ(e,O,g,T,b,x,k,null,l))}h.push(x+y-s)}}return f(t,n,r,i,0),(o||l)(d,h,a)}class BZ{constructor(){this.map=new WeakMap}setBuffer(t,n,r){let i=this.map.get(t);i||this.map.set(t,i=new Map),i.set(n,r)}getBuffer(t,n){let r=this.map.get(t);return r&&r.get(n)}set(t,n){t instanceof dh?this.setBuffer(t.context.buffer,t.index,n):t instanceof To&&this.map.set(t.tree,n)}get(t){return t instanceof dh?this.getBuffer(t.context.buffer,t.index):t instanceof To?this.map.get(t.tree):void 0}cursorSet(t,n){t.buffer?this.setBuffer(t.buffer.buffer,t.index,n):this.map.set(t.tree,n)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class Bf{constructor(t,n,r,i,s=!1,a=!1){this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new Bf(0,t.length,t,0,!1,r)];for(let s of n)s.to>t.length&&i.push(s);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],s=1,a=t.length?t[0]:null;for(let o=0,l=0,c=0;;o++){let u=o<n.length?n[o]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;a&&a.from<d;){let h=a;if(l>=h.from||d<=h.to||c){let f=Math.max(h.from,l)-c,O=Math.min(h.to,d)-c;h=f>=O?null:new Bf(f,O,h.tree,h.offset+c,o>0,!!u)}if(h&&i.push(h),a.to>d)break;a=s<t.length?t[s++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}let V3=class{startParse(t,n,r){return typeof t=="string"&&(t=new m3t(t)),r=r?r.length?r.map(i=>new nu(i.from,i.to)):[new nu(0,0)]:[new nu(0,t.length)],this.createParse(t,n||[],r)}parse(t,n,r){let i=this.startParse(t,n,r);for(;;){let s=i.advance();if(s)return s}}};class m3t{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,n){return this.string.slice(t,n)}}function ku(e){return(t,n,r,i)=>new y3t(t,e,n,r,i)}class _fe{constructor(t,n,r,i,s){this.parser=t,this.parse=n,this.overlay=r,this.target=i,this.from=s}}function Pfe(e){if(!e.length||e.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class v3t{constructor(t,n,r,i,s,a,o){this.parser=t,this.predicate=n,this.mounts=r,this.index=i,this.start=s,this.target=a,this.prev=o,this.depth=0,this.ranges=[]}}const vU=new In({perNode:!0});class y3t{constructor(t,n,r,i,s){this.nest=n,this.input=r,this.fragments=i,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new vr(r.type,r.children,r.positions,r.length,r.propValues.concat([[vU,this.stoppedAt]]))),r}let t=this.inner[this.innerDone],n=t.parse.advance();if(n){this.innerDone++;let r=Object.assign(Object.create(null),t.target.props);r[In.mounted.id]=new _T(n,t.overlay,t.parser),t.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].from<t&&(t=Math.min(t,this.inner[n].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].parse.stopAt(t)}startInner(){let t=new x3t(this.fragments),n=null,r=null,i=new S5(new To(this.baseTree,this.ranges[0].from,0,null),bi.IncludeAnonymous|bi.IgnoreMounts);e:for(let s,a;;){let o=!0,l;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)o=!1;else if(t.hasNode(i)){if(n){let c=n.mounts.find(u=>u.frag.from<=i.from&&u.frag.to>=i.to&&u.mount.overlay);if(c)for(let u of c.mount.overlay){let d=u.from+c.pos,h=u.to+c.pos;d>=i.from&&h<=i.to&&!n.ranges.some(f=>f.from<h&&f.to>d)&&n.ranges.push({from:d,to:h})}}o=!1}else if(r&&(a=b3t(r.ranges,i.from,i.to)))o=a!=2;else if(!i.type.isAnonymous&&(s=this.nest(i,this.input))&&(i.from<i.to||!s.overlay)){i.tree||w3t(i);let c=t.findMounts(i.from,s.parser);if(typeof s.overlay=="function")n=new v3t(s.parser,s.overlay,c,this.inner.length,i.from,i.tree,n);else{let u=Efe(this.ranges,s.overlay||(i.from<i.to?[new nu(i.from,i.to)]:[]));u.length&&Pfe(u),(u.length||!s.overlay)&&this.inner.push(new _fe(s.parser,u.length?s.parser.startParse(this.input,Rfe(c,u),u):s.parser.startParse(""),s.overlay?s.overlay.map(d=>new nu(d.from-i.from,d.to-i.from)):null,i.tree,u.length?u[0].from:i.from)),s.overlay?u.length&&(r={ranges:u,depth:0,prev:r}):o=!1}}else if(n&&(l=n.predicate(i))&&(l===!0&&(l=new nu(i.from,i.to)),l.from<l.to)){let c=n.ranges.length-1;c>=0&&n.ranges[c].to==l.from?n.ranges[c]={from:n.ranges[c].from,to:l.to}:n.ranges.push(l)}if(o&&i.firstChild())n&&n.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(n&&!--n.depth){let c=Efe(this.ranges,n.ranges);c.length&&(Pfe(c),this.inner.splice(n.index,0,new _fe(n.parser,n.parser.startParse(this.input,Rfe(n.mounts,c),c),n.ranges.map(u=>new nu(u.from-n.start,u.to-n.start)),n.target,c[0].from))),n=n.prev}r&&!--r.depth&&(r=r.prev)}}}}function b3t(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function Cfe(e,t,n,r,i,s){if(t<n){let a=e.buffer[t+1];r.push(e.slice(t,n,a)),i.push(a-s)}}function w3t(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,s=i.children.indexOf(r),a=i.children[s],o=a.buffer,l=[s];function c(u,d,h,f,O,g){let m=n[g],v=[],y=[];Cfe(a,u,m,v,y,f);let b=o[m+1],T=o[m+2];l.push(v.length);let x=g?c(m+4,o[m+3],a.set.types[o[m]],b,T-b,g-1):t.toTree();return v.push(x),y.push(b-f),Cfe(a,o[m+3],d,v,y,f),new vr(h,v,y,O)}i.children[s]=c(0,o.length,na.none,0,a.length,n.length-1);for(let u of l){let d=e.tree.children[u],h=e.tree.positions[u];e.yield(new To(d,h+e.from,u,e._tree))}}class Qfe{constructor(t,n){this.offset=n,this.done=!1,this.cursor=t.cursor(bi.IncludeAnonymous|bi.IgnoreMounts)}moveTo(t){let{cursor:n}=this,r=t-this.offset;for(;!this.done&&n.from<r;)n.to>=t&&n.enter(r,1,bi.IgnoreOverlays|bi.ExcludeBuffers)||n.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==t.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof vr)n=n.children[0];else break}return!1}}let x3t=class{constructor(t){var n;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let r=this.curFrag=t[0];this.curTo=(n=r.tree.prop(vU))!==null&&n!==void 0?n:r.to,this.inner=new Qfe(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(t=n.tree.prop(vU))!==null&&t!==void 0?t:n.to,this.inner=new Qfe(n.tree,-n.offset)}}findMounts(t,n){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let a=(r=s.tree)===null||r===void 0?void 0:r.prop(In.mounted);if(a&&a.parser==n)for(let o=this.fragI;o<this.fragments.length;o++){let l=this.fragments[o];if(l.from>=s.to)break;l.tree==this.curFrag.tree&&i.push({frag:l,pos:s.from-l.offset,mount:a})}}}return i}};function Efe(e,t){let n=null,r=t;for(let i=1,s=0;i<e.length;i++){let a=e[i-1].to,o=e[i].from;for(;s<r.length;s++){let l=r[s];if(l.from>=o)break;l.to<=a||(n||(r=n=t.slice()),l.from<a?(n[s]=new nu(l.from,a),l.to>o&&n.splice(s+1,0,new nu(o,l.to))):l.to>o?n[s--]=new nu(o,l.to):n.splice(s--,1))}}return r}function S3t(e,t,n,r){let i=0,s=0,a=!1,o=!1,l=-1e9,c=[];for(;;){let u=i==e.length?1e9:a?e[i].to:e[i].from,d=s==t.length?1e9:o?t[s].to:t[s].from;if(a!=o){let h=Math.max(l,n),f=Math.min(u,d,r);h<f&&c.push(new nu(h,f))}if(l=Math.min(u,d),l==1e9)break;u==l&&(a?(a=!1,i++):a=!0),d==l&&(o?(o=!1,s++):o=!0)}return c}function Rfe(e,t){let n=[];for(let{pos:r,mount:i,frag:s}of e){let a=r+(i.overlay?i.overlay[0].from:0),o=a+i.tree.length,l=Math.max(s.from,a),c=Math.min(s.to,o);if(i.overlay){let u=i.overlay.map(h=>new nu(h.from+r,h.to+r)),d=S3t(t,u,l,c);for(let h=0,f=l;;h++){let O=h==d.length,g=O?c:d[h].from;if(g>f&&n.push(new Bf(f,g,i.tree,-a,s.from>=f||s.openStart,s.to<=g||s.openEnd)),O)break;f=d[h].to}}else n.push(new Bf(l,c,i.tree,-a,s.from>=a||s.openStart,s.to<=o||s.openEnd))}return n}let yU=[],Y5e=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Y5e:yU).push(n=n+e[t])})();function $3t(e){if(e<768)return!1;for(let t=0,n=yU.length;;){let r=t+n>>1;if(e<yU[r])n=r;else if(e>=Y5e[r])t=r+1;else return!0;if(t==n)return!1}}function Afe(e){return e>=127462&&e<=127487}const Xfe=8205;function k3t(e,t,n=!0,r=!0){return(n?Z5e:T3t)(e,t,r)}function Z5e(e,t,n){if(t==e.length)return t;t&&H5e(e.charCodeAt(t))&&K5e(e.charCodeAt(t-1))&&t--;let r=BM(e,t);for(t+=Dfe(r);t<e.length;){let i=BM(e,t);if(r==Xfe||i==Xfe||n&&$3t(i))t+=Dfe(i),r=i;else if(Afe(i)){let s=0,a=t-2;for(;a>=0&&Afe(BM(e,a));)s++,a-=2;if(s%2==0)break;t+=2}else break}return t}function T3t(e,t,n){for(;t>0;){let r=Z5e(e,t-2,n);if(r<t)return r;t--}return 0}function BM(e,t){let n=e.charCodeAt(t);if(!K5e(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return H5e(r)?(n-55296<<10)+(r-56320)+65536:n}function H5e(e){return e>=56320&&e<57344}function K5e(e){return e>=55296&&e<56320}function Dfe(e){return e<65536?1:2}let Fr=class J5e{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,r){[t,n]=I1(this,t,n);let i=[];return this.decompose(0,t,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),th.from(i,this.length-(n-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=I1(this,t,n);let r=[];return this.decompose(t,n,r,0),th.from(r,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),i=new d$(this),s=new d$(t);for(let a=n,o=n;;){if(i.next(a),s.next(a),a=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(o+=i.value.length,i.done||o>=r)return!0}}iter(t=1){return new d$(this,t)}iterRange(t,n=this.length){return new e4e(this,t,n)}iterLines(t,n){let r;if(t==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(t).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new t4e(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?J5e.empty:t.length<=32?new $s(t):th.from($s.split(t,[]))}};class $s extends Fr{constructor(t,n=_3t(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,r,i){for(let s=0;;s++){let a=this.text[s],o=i+a.length;if((n?r:o)>=t)return new P3t(i,o,r,a);i=o+1,r++}}decompose(t,n,r,i){let s=t<=0&&n>=this.length?this:new $s(Ife(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let a=r.pop(),o=qQ(s.text,a.text.slice(),0,s.length);if(o.length<=32)r.push(new $s(o,a.length+s.length));else{let l=o.length>>1;r.push(new $s(o.slice(0,l)),new $s(o.slice(l)))}}else r.push(s)}replace(t,n,r){if(!(r instanceof $s))return super.replace(t,n,r);[t,n]=I1(this,t,n);let i=qQ(this.text,qQ(r.text,Ife(this.text,0,t)),n),s=this.length+r.length-(n-t);return i.length<=32?new $s(i,s):th.from($s.split(i,[]),s)}sliceString(t,n=this.length,r=`
1149
1149
  `){[t,n]=I1(this,t,n);let i="";for(let s=0,a=0;s<=n&&a<this.text.length;a++){let o=this.text[a],l=s+o.length;s>t&&a&&(i+=r),t<l&&n>s&&(i+=o.slice(Math.max(0,t-s),n-s)),s=l+1}return i}flatten(t){for(let n of this.text)t.push(n)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let s of t)r.push(s),i+=s.length+1,r.length==32&&(n.push(new $s(r,i)),r=[],i=-1);return i>-1&&n.push(new $s(r,i)),n}}class th extends Fr{constructor(t,n){super(),this.children=t,this.length=n,this.lines=0;for(let r of t)this.lines+=r.lines}lineInner(t,n,r,i){for(let s=0;;s++){let a=this.children[s],o=i+a.length,l=r+a.lines-1;if((n?l:o)>=t)return a.lineInner(t,n,r,i);i=o+1,r=l+1}}decompose(t,n,r,i){for(let s=0,a=0;a<=n&&s<this.children.length;s++){let o=this.children[s],l=a+o.length;if(t<=l&&n>=a){let c=i&((a<=t?1:0)|(l>=n?2:0));a>=t&&l<=n&&!c?r.push(o):o.decompose(t-a,n-a,r,c)}a=l+1}}replace(t,n,r){if([t,n]=I1(this,t,n),r.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let a=this.children[i],o=s+a.length;if(t>=s&&n<=o){let l=a.replace(t-s,n-s,r),c=this.lines-a.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[i]=l,new th(u,this.length-(n-t)+r.length)}return super.replace(s,o,l)}s=o+1}return super.replace(t,n,r)}sliceString(t,n=this.length,r=`
1150
1150
  `){[t,n]=I1(this,t,n);let i="";for(let s=0,a=0;s<this.children.length&&a<=n;s++){let o=this.children[s],l=a+o.length;a>t&&s&&(i+=r),t<l&&n>a&&(i+=o.sliceString(t-a,n-a,r)),a=l+1}return i}flatten(t){for(let n of this.children)n.flatten(t)}scanIdentical(t,n){if(!(t instanceof th))return 0;let r=0,[i,s,a,o]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==a||s==o)return r;let l=this.children[i],c=t.children[s];if(l!=c)return r+l.scanIdentical(c,n);r+=l.length+1}}static from(t,n=t.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let f of t)r+=f.lines;if(r<32){let f=[];for(let O of t)O.flatten(f);return new $s(f,n)}let i=Math.max(32,r>>5),s=i<<1,a=i>>1,o=[],l=0,c=-1,u=[];function d(f){let O;if(f.lines>s&&f instanceof th)for(let g of f.children)d(g);else f.lines>a&&(l>a||!l)?(h(),o.push(f)):f instanceof $s&&l&&(O=u[u.length-1])instanceof $s&&f.lines+O.lines<=32?(l+=f.lines,c+=f.length+1,u[u.length-1]=new $s(O.text.concat(f.text),O.length+1+f.length)):(l+f.lines>i&&h(),l+=f.lines,c+=f.length+1,u.push(f))}function h(){l!=0&&(o.push(u.length==1?u[0]:th.from(u,c)),c=-1,l=u.length=0)}for(let f of t)d(f);return h(),o.length==1?o[0]:new th(o,n)}}Fr.empty=new $s([""],0);function _3t(e){let t=-1;for(let n of e)t+=n.length+1;return t}function qQ(e,t,n=0,r=1e9){for(let i=0,s=0,a=!0;s<e.length&&i<=r;s++){let o=e[s],l=i+o.length;l>=n&&(l>r&&(o=o.slice(0,r-i)),i<n&&(o=o.slice(n-i)),a?(t[t.length-1]+=o,a=!1):t.push(o)),i=l+1}return t}function Ife(e,t,n){return qQ(e,[""],t,n)}class d${constructor(t,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[n>0?1:(t instanceof $s?t.text.length:t.children.length)<<1]}nextInner(t,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],a=s>>1,o=i instanceof $s?i.text.length:i.children.length;if(a==(n>0?o:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,t==0)return this.lineBreak=!0,this.value=`
1151
1151
  `,this;t--}else if(i instanceof $s){let l=i.text[a+(n<0?-1:0)];if(this.offsets[r]+=n,l.length>Math.max(0,t))return this.value=t==0?l:n>0?l.slice(t):l.slice(0,l.length-t),this;t-=l.length}else{let l=i.children[a+(n<0?-1:0)];t>l.length?(t-=l.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof $s?l.text.length:l.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class e4e{constructor(t,n,r){this.value="",this.done=!1,this.cursor=new d$(t,n>r?-1:1),this.pos=n>r?t.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(t,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;t>r&&(t=r),r-=t;let{value:i}=this.cursor.next(t);return this.pos+=(i.length+t)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class t4e{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:n,lineBreak:r,value:i}=this.inner.next(t);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Fr.prototype[Symbol.iterator]=function(){return this.iter()},d$.prototype[Symbol.iterator]=e4e.prototype[Symbol.iterator]=t4e.prototype[Symbol.iterator]=function(){return this});let P3t=class{constructor(t,n,r,i){this.from=t,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}};function I1(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function Ka(e,t,n=!0,r=!0){return k3t(e,t,n,r)}function C3t(e){return e>=56320&&e<57344}function Q3t(e){return e>=55296&&e<56320}function yl(e,t){let n=e.charCodeAt(t);if(!Q3t(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return C3t(r)?(n-55296<<10)+(r-56320)+65536:n}function YZ(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function nh(e){return e<65536?1:2}const bU=/\r\n?|\n/;var Ya=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(Ya||(Ya={}));class $h{constructor(t){this.sections=t}get length(){let t=0;for(let n=0;n<this.sections.length;n+=2)t+=this.sections[n];return t}get newLength(){let t=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];t+=r<0?this.sections[n]:r}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let n=0,r=0,i=0;n<this.sections.length;){let s=this.sections[n++],a=this.sections[n++];a<0?(t(r,i,s),i+=s):i+=a,r+=s}}iterChangedRanges(t,n=!1){wU(this,t,n)}get invertedDesc(){let t=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?t.push(r,i):t.push(i,r)}return new $h(t)}composeDesc(t){return this.empty?t:t.empty?this:n4e(this,t)}mapDesc(t,n=!1){return t.empty?this:xU(this,t,n)}mapPos(t,n=-1,r=Ya.Simple){let i=0,s=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],l=this.sections[a++],c=i+o;if(l<0){if(c>t)return s+(t-i);s+=o}else{if(r!=Ya.Simple&&c>=t&&(r==Ya.TrackDel&&i<t&&c>t||r==Ya.TrackBefore&&i<t||r==Ya.TrackAfter&&c>t))return null;if(c>t||c==t&&n<0&&!o)return t==i||n<0?s:s+l;s+=l}i=c}if(t>i)throw new RangeError(`Position ${t} is out of range for changeset of length ${i}`);return s}touchesRange(t,n=t){for(let r=0,i=0;r<this.sections.length&&i<=n;){let s=this.sections[r++],a=this.sections[r++],o=i+s;if(a>=0&&i<=n&&o>=t)return i<t&&o>n?"cover":!0;i=o}return!1}toString(){let t="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];t+=(t?" ":"")+r+(i>=0?":"+i:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new $h(t)}static create(t){return new $h(t)}}class oa extends $h{constructor(t,n){super(t),this.inserted=n}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return wU(this,(n,r,i,s,a)=>t=t.replace(i,i+(r-n),a),!1),t}mapDesc(t,n=!1){return xU(this,t,n,!0)}invert(t){let n=this.sections.slice(),r=[];for(let i=0,s=0;i<n.length;i+=2){let a=n[i],o=n[i+1];if(o>=0){n[i]=o,n[i+1]=a;let l=i>>1;for(;r.length<l;)r.push(Fr.empty);r.push(a?t.slice(s,s+a):Fr.empty)}s+=a}return new oa(n,r)}compose(t){return this.empty?t:t.empty?this:n4e(this,t,!0)}map(t,n=!1){return t.empty?this:xU(this,t,n,!0)}iterChanges(t,n=!1){wU(this,t,n)}get desc(){return $h.create(this.sections)}filter(t){let n=[],r=[],i=[],s=new CT(this);e:for(let a=0,o=0;;){let l=a==t.length?1e9:t[a++];for(;o<l||o==l&&s.len==0;){if(s.done)break e;let u=Math.min(s.len,l-o);po(i,u,-1);let d=s.ins==-1?-1:s.off==0?s.ins:0;po(n,u,d),d>0&&Qp(r,n,s.text),s.forward(u),o+=u}let c=t[a++];for(;o<c;){if(s.done)break e;let u=Math.min(s.len,c-o);po(n,u,-1),po(i,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),o+=u}}return{changes:new oa(n,r),filtered:$h.create(i)}}toJSON(){let t=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?t.push(r):i==0?t.push([r]):t.push([r].concat(this.inserted[n>>1].toJSON()))}return t}static of(t,n,r){let i=[],s=[],a=0,o=null;function l(u=!1){if(!u&&!i.length)return;a<n&&po(i,n-a,-1);let d=new oa(i,s);o=o?o.compose(d.map(o)):d,i=[],s=[],a=0}function c(u){if(Array.isArray(u))for(let d of u)c(d);else if(u instanceof oa){if(u.length!=n)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);l(),o=o?o.compose(u.map(o)):u}else{let{from:d,to:h=d,insert:f}=u;if(d>h||d<0||h>n)throw new RangeError(`Invalid change range ${d} to ${h} (in doc of length ${n})`);let O=f?typeof f=="string"?Fr.of(f.split(r||bU)):f:Fr.empty,g=O.length;if(d==h&&g==0)return;d<a&&l(),d>a&&po(i,d-a,-1),po(i,h-d,g),Qp(s,i,O),a=h}}return c(t),l(!o),o}static empty(t){return new oa(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<t.length;i++){let s=t[i];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((a,o)=>o&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length<i;)r.push(Fr.empty);r[i]=Fr.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new oa(n,r)}static createSet(t,n){return new oa(t,n)}}function po(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function Qp(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(Fr.empty);e.push(n)}}function wU(e,t,n){let r=e.inserted;for(let i=0,s=0,a=0;a<e.sections.length;){let o=e.sections[a++],l=e.sections[a++];if(l<0)i+=o,s+=o;else{let c=i,u=s,d=Fr.empty;for(;c+=o,u+=l,l&&r&&(d=d.append(r[a-2>>1])),!(n||a==e.sections.length||e.sections[a+1]<0);)o=e.sections[a++],l=e.sections[a++];t(i,c,s,u,d),i=c,s=u}}}function xU(e,t,n,r=!1){let i=[],s=r?[]:null,a=new CT(e),o=new CT(t);for(let l=-1;;){if(a.done&&o.len||o.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&o.ins==-1){let c=Math.min(a.len,o.len);po(i,c,-1),a.forward(c),o.forward(c)}else if(o.ins>=0&&(a.ins<0||l==a.i||a.off==0&&(o.len<a.len||o.len==a.len&&!n))){let c=o.len;for(po(i,o.ins,-1);c;){let u=Math.min(a.len,c);a.ins>=0&&l<a.i&&a.len<=u&&(po(i,0,a.ins),s&&Qp(s,i,a.text),l=a.i),a.forward(u),c-=u}o.next()}else if(a.ins>=0){let c=0,u=a.len;for(;u;)if(o.ins==-1){let d=Math.min(u,o.len);c+=d,u-=d,o.forward(d)}else if(o.ins==0&&o.len<u)u-=o.len,o.next();else break;po(i,c,l<a.i?a.ins:0),s&&l<a.i&&Qp(s,i,a.text),l=a.i,a.forward(a.len-u)}else{if(a.done&&o.done)return s?oa.createSet(i,s):$h.create(i);throw new Error("Mismatched change set lengths")}}}function n4e(e,t,n=!1){let r=[],i=n?[]:null,s=new CT(e),a=new CT(t);for(let o=!1;;){if(s.done&&a.done)return i?oa.createSet(r,i):$h.create(r);if(s.ins==0)po(r,s.len,0,o),s.next();else if(a.len==0&&!a.done)po(r,0,a.ins,o),i&&Qp(i,r,a.text),a.next();else{if(s.done||a.done)throw new Error("Mismatched change set lengths");{let l=Math.min(s.len2,a.len),c=r.length;if(s.ins==-1){let u=a.ins==-1?-1:a.off?0:a.ins;po(r,l,u,o),i&&u&&Qp(i,r,a.text)}else a.ins==-1?(po(r,s.off?0:s.len,l,o),i&&Qp(i,r,s.textBit(l))):(po(r,s.off?0:s.len,a.off?0:a.ins,o),i&&!a.off&&Qp(i,r,a.text));o=(s.ins>l||a.ins>=0&&a.len>l)&&(o||r.length>c),s.forward2(l),a.forward(l)}}}}class CT{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length?Fr.empty:t[n]}textBit(t){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!t?Fr.empty:n[r].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class Lm{constructor(t,n,r){this.from=t,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let t=this.flags&7;return t==7?null:t}get goalColumn(){let t=this.flags>>6;return t==16777215?void 0:t}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new Lm(r,i,this.flags)}extend(t,n=t){if(t<=this.anchor&&n>=this.anchor)return Ze.range(t,n);let r=Math.abs(t-this.anchor)>Math.abs(n-this.anchor)?t:n;return Ze.range(this.anchor,r)}eq(t,n=!1){return this.anchor==t.anchor&&this.head==t.head&&(!n||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Ze.range(t.anchor,t.head)}static create(t,n,r){return new Lm(t,n,r)}}class Ze{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:Ze.create(this.ranges.map(r=>r.map(t,n)),this.mainIndex)}eq(t,n=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(t.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new Ze([this.main],0)}addRange(t,n=!0){return Ze.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,Ze.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ze(t.ranges.map(n=>Lm.fromJSON(n)),t.main)}static single(t,n=t){return new Ze([Ze.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<t.length;i++){let s=t[i];if(s.empty?s.from<=r:s.from<r)return Ze.normalized(t.slice(),n);r=s.to}return new Ze(t,n)}static cursor(t,n=0,r,i){return Lm.create(t,t,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(i??16777215)<<6)}static range(t,n,r,i){let s=(r??16777215)<<6|(i==null?7:Math.min(6,i));return n<t?Lm.create(n,t,48|s):Lm.create(t,n,(n>t?8:0)|s)}static normalized(t,n=0){let r=t[n];t.sort((i,s)=>i.from-s.from),n=t.indexOf(r);for(let i=1;i<t.length;i++){let s=t[i],a=t[i-1];if(s.empty?s.from<=a.to:s.from<a.to){let o=a.from,l=Math.max(s.to,a.to);i<=n&&n--,t.splice(--i,2,s.anchor>s.head?Ze.range(l,o):Ze.range(o,l))}}return new Ze(t,n)}}function r4e(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let ZZ=0;class Yt{constructor(t,n,r,i,s){this.combine=t,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=ZZ++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new Yt(t.combine||(n=>n),t.compareInput||((n,r)=>n===r),t.compare||(t.combine?(n,r)=>n===r:HZ),!!t.static,t.enables)}of(t){return new zQ([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new zQ(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new zQ(t,this,2,n)}from(t,n){return n||(n=r=>r),this.compute([t],r=>n(r.field(t)))}}function HZ(e,t){return e==t||e.length==t.length&&e.every((n,r)=>n===t[r])}class zQ{constructor(t,n,r,i){this.dependencies=t,this.facet=n,this.type=r,this.value=i,this.id=ZZ++}dynamicSlot(t){var n;let r=this.value,i=this.facet.compareInput,s=this.id,a=t[s]>>1,o=this.type==2,l=!1,c=!1,u=[];for(let d of this.dependencies)d=="doc"?l=!0:d=="selection"?c=!0:(((n=t[d.id])!==null&&n!==void 0?n:1)&1)==0&&u.push(t[d.id]);return{create(d){return d.values[a]=r(d),1},update(d,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||SU(d,u)){let f=r(d);if(o?!Nfe(f,d.values[a],i):!i(f,d.values[a]))return d.values[a]=f,1}return 0},reconfigure:(d,h)=>{let f,O=h.config.address[s];if(O!=null){let g=k5(h,O);if(this.dependencies.every(m=>m instanceof Yt?h.facet(m)===d.facet(m):m instanceof Ia?h.field(m,!1)==d.field(m,!1):!0)||(o?Nfe(f=r(d),g,i):i(f=r(d),g)))return d.values[a]=g,0}else f=r(d);return d.values[a]=f,1}}}}function Nfe(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function SU(e,t){let n=!1;for(let r of t)h$(e,r)&1&&(n=!0);return n}function E3t(e,t,n){let r=n.map(l=>e[l.id]),i=n.map(l=>l.type),s=r.filter(l=>!(l&1)),a=e[t.id]>>1;function o(l){let c=[];for(let u=0;u<r.length;u++){let d=k5(l,r[u]);if(i[u]==2)for(let h of d)c.push(h);else c.push(d)}return t.combine(c)}return{create(l){for(let c of r)h$(l,c);return l.values[a]=o(l),1},update(l,c){if(!SU(l,s))return 0;let u=o(l);return t.compare(u,l.values[a])?0:(l.values[a]=u,1)},reconfigure(l,c){let u=SU(l,r),d=c.config.facets[t.id],h=c.facet(t);if(d&&!u&&HZ(n,d))return l.values[a]=h,0;let f=o(l);return t.compare(f,h)?(l.values[a]=h,0):(l.values[a]=f,1)}}}const F2=Yt.define({static:!0});class Ia{constructor(t,n,r,i,s){this.id=t,this.createF=n,this.updateF=r,this.compareF=i,this.spec=s,this.provides=void 0}static define(t){let n=new Ia(ZZ++,t.create,t.update,t.compare||((r,i)=>r===i),t);return t.provide&&(n.provides=t.provide(n)),n}create(t){let n=t.facet(F2).find(r=>r.field==this);return(n?.create||this.createF)(t)}slot(t){let n=t[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],a=this.updateF(s,i);return this.compareF(s,a)?0:(r.values[n]=a,1)},reconfigure:(r,i)=>{let s=r.facet(F2),a=i.facet(F2),o;return(o=s.find(l=>l.field==this))&&o!=a.find(l=>l.field==this)?(r.values[n]=o.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(t){return[this,F2.of({field:this,create:t})]}get extension(){return this}}const Pm={lowest:4,low:3,default:2,high:1,highest:0};function Ax(e){return t=>new i4e(t,e)}const CO={highest:Ax(Pm.highest),high:Ax(Pm.high),default:Ax(Pm.default),low:Ax(Pm.low),lowest:Ax(Pm.lowest)};class i4e{constructor(t,n){this.inner=t,this.prec=n}}class B3{of(t){return new $U(this,t)}reconfigure(t){return B3.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class $U{constructor(t,n){this.compartment=t,this.inner=n}}class $5{constructor(t,n,r,i,s,a){for(this.base=t,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(t){let n=this.address[t.id];return n==null?t.default:this.staticValues[n>>1]}static resolve(t,n,r){let i=[],s=Object.create(null),a=new Map;for(let h of R3t(t,n,a))h instanceof Ia?i.push(h):(s[h.facet.id]||(s[h.facet.id]=[])).push(h);let o=Object.create(null),l=[],c=[];for(let h of i)o[h.id]=c.length<<1,c.push(f=>h.slot(f));let u=r?.config.facets;for(let h in s){let f=s[h],O=f[0].facet,g=u&&u[h]||[];if(f.every(m=>m.type==0))if(o[O.id]=l.length<<1|1,HZ(g,f))l.push(r.facet(O));else{let m=O.combine(f.map(v=>v.value));l.push(r&&O.compare(m,r.facet(O))?r.facet(O):m)}else{for(let m of f)m.type==0?(o[m.id]=l.length<<1|1,l.push(m.value)):(o[m.id]=c.length<<1,c.push(v=>m.dynamicSlot(v)));o[O.id]=c.length<<1,c.push(m=>E3t(m,O,f))}}let d=c.map(h=>h(o));return new $5(t,a,d,o,l,s)}}function R3t(e,t,n){let r=[[],[],[],[],[]],i=new Map;function s(a,o){let l=i.get(a);if(l!=null){if(l<=o)return;let c=r[l].indexOf(a);c>-1&&r[l].splice(c,1),a instanceof $U&&n.delete(a.compartment)}if(i.set(a,o),Array.isArray(a))for(let c of a)s(c,o);else if(a instanceof $U){if(n.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=t.get(a.compartment)||a.inner;n.set(a.compartment,c),s(c,o)}else if(a instanceof i4e)s(a.inner,a.prec);else if(a instanceof Ia)r[o].push(a),a.provides&&s(a.provides,o);else if(a instanceof zQ)r[o].push(a),a.facet.extensions&&s(a.facet.extensions,Pm.default);else{let c=a.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,o)}}return s(e,Pm.default),r.reduce((a,o)=>a.concat(o))}function h$(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function k5(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}const s4e=Yt.define(),kU=Yt.define({combine:e=>e.some(t=>t),static:!0}),a4e=Yt.define({combine:e=>e.length?e[0]:void 0,static:!0}),o4e=Yt.define(),l4e=Yt.define(),c4e=Yt.define(),u4e=Yt.define({combine:e=>e.length?e[0]:!1});class Gh{constructor(t,n){this.type=t,this.value=n}static define(){return new A3t}}class A3t{of(t){return new Gh(this,t)}}class X3t{constructor(t){this.map=t}of(t){return new Mn(this,t)}}class Mn{constructor(t,n){this.type=t,this.value=n}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new Mn(this.type,n)}is(t){return this.type==t}static define(t={}){return new X3t(t.map||(n=>n))}static mapEffects(t,n){if(!t.length)return t;let r=[];for(let i of t){let s=i.map(n);s&&r.push(s)}return r}}Mn.reconfigure=Mn.define();Mn.appendConfig=Mn.define();class ea{constructor(t,n,r,i,s,a){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=a,this._doc=null,this._state=null,r&&r4e(r,n.newLength),s.some(o=>o.type==ea.time)||(this.annotations=s.concat(ea.time.of(Date.now())))}static create(t,n,r,i,s,a){return new ea(t,n,r,i,s,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let n of this.annotations)if(n.type==t)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(ea.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}}ea.time=Gh.define();ea.userEvent=Gh.define();ea.addToHistory=Gh.define();ea.remote=Gh.define();function D3t(e,t){let n=[];for(let r=0,i=0;;){let s,a;if(r<e.length&&(i==t.length||t[i]>=e[r]))s=e[r++],a=e[r++];else if(i<t.length)s=t[i++],a=t[i++];else return n;!n.length||n[n.length-1]<s?n.push(s,a):n[n.length-1]<a&&(n[n.length-1]=a)}}function d4e(e,t,n){var r;let i,s,a;return n?(i=t.changes,s=oa.empty(t.changes.length),a=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),s=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(i)),{changes:a,selection:t.selection?t.selection.map(s):(r=e.selection)===null||r===void 0?void 0:r.map(i),effects:Mn.mapEffects(e.effects,i).concat(Mn.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function TU(e,t,n){let r=t.selection,i=bb(t.annotations);return t.userEvent&&(i=i.concat(ea.userEvent.of(t.userEvent))),{changes:t.changes instanceof oa?t.changes:oa.of(t.changes||[],n,e.facet(a4e)),selection:r&&(r instanceof Ze?r:Ze.single(r.anchor,r.head)),effects:bb(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function h4e(e,t,n){let r=TU(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let s=1;s<t.length;s++){t[s].filter===!1&&(n=!1);let a=!!t[s].sequential;r=d4e(r,TU(e,t[s],a?r.changes.newLength:e.doc.length),a)}let i=ea.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return N3t(n?I3t(i):i)}function I3t(e){let t=e.startState,n=!0;for(let i of t.facet(o4e)){let s=i(e);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:D3t(n,s))}if(n!==!0){let i,s;if(n===!1)s=e.changes.invertedDesc,i=oa.empty(t.doc.length);else{let a=e.changes.filter(n);i=a.changes,s=a.filtered.mapDesc(a.changes).invertedDesc}e=ea.create(t,i,e.selection&&e.selection.map(s),Mn.mapEffects(e.effects,s),e.annotations,e.scrollIntoView)}let r=t.facet(l4e);for(let i=r.length-1;i>=0;i--){let s=r[i](e);s instanceof ea?e=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ea?e=s[0]:e=h4e(t,bb(s),!1)}return e}function N3t(e){let t=e.startState,n=t.facet(c4e),r=e;for(let i=n.length-1;i>=0;i--){let s=n[i](e);s&&Object.keys(s).length&&(r=d4e(r,TU(t,s,e.changes.newLength),!0))}return r==e?e:ea.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}const F3t=[];function bb(e){return e==null?F3t:Array.isArray(e)?e:[e]}var Zi=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(Zi||(Zi={}));const M3t=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let _U;try{_U=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function L3t(e){if(_U)return _U.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||M3t.test(n)))return!0}return!1}function j3t(e){return t=>{if(!/\S/.test(t))return Zi.Space;if(L3t(t))return Zi.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return Zi.Word;return Zi.Other}}class yr{constructor(t,n,r,i,s,a){this.config=t,this.doc=n,this.selection=r,this.values=i,this.status=t.statusTemplate.slice(),this.computeSlot=s,a&&(a._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)h$(this,o<<1);this.computeSlot=null}field(t,n=!0){let r=this.config.address[t.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return h$(this,r),k5(this,r)}update(...t){return h4e(this,t,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let o of t.effects)o.is(B3.reconfigure)?(n&&(i=new Map,n.compartments.forEach((l,c)=>i.set(c,l)),n=null),i.set(o.value.compartment,o.value.extension)):o.is(Mn.reconfigure)?(n=null,r=o.value):o.is(Mn.appendConfig)&&(n=null,r=bb(r).concat(o.value));let s;n?s=t.startState.values.slice():(n=$5.resolve(r,i,this),s=new yr(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let a=t.startState.facet(kU)?t.newSelection:t.newSelection.asSingle();new yr(n,t.newDoc,a,s,(o,l)=>l.update(o,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:t},range:Ze.cursor(n.from+t.length)}))}changeByRange(t){let n=this.selection,r=t(n.ranges[0]),i=this.changes(r.changes),s=[r.range],a=bb(r.effects);for(let o=1;o<n.ranges.length;o++){let l=t(n.ranges[o]),c=this.changes(l.changes),u=c.map(i);for(let h=0;h<o;h++)s[h]=s[h].map(u);let d=i.mapDesc(c,!0);s.push(l.range.map(d)),i=i.compose(u),a=Mn.mapEffects(a,u).concat(Mn.mapEffects(bb(l.effects),d))}return{changes:i,selection:Ze.create(s,n.mainIndex),effects:a}}changes(t=[]){return t instanceof oa?t:oa.of(t,this.doc.length,this.facet(yr.lineSeparator))}toText(t){return Fr.of(t.split(this.facet(yr.lineSeparator)||bU))}sliceDoc(t=0,n=this.doc.length){return this.doc.sliceString(t,n,this.lineBreak)}facet(t){let n=this.config.address[t.id];return n==null?t.default:(h$(this,n),k5(this,n))}toJSON(t){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let r in t){let i=t[r];i instanceof Ia&&this.config.address[i.id]!=null&&(n[r]=i.spec.toJSON(this.field(t[r]),this))}return n}static fromJSON(t,n={},r){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(t,s)){let a=r[s],o=t[s];i.push(a.init(l=>a.spec.fromJSON(o,l)))}}return yr.create({doc:t.doc,selection:Ze.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=$5.resolve(t.extensions||[],new Map),r=t.doc instanceof Fr?t.doc:Fr.of((t.doc||"").split(n.staticFacet(yr.lineSeparator)||bU)),i=t.selection?t.selection instanceof Ze?t.selection:Ze.single(t.selection.anchor,t.selection.head):Ze.single(0);return r4e(i,r.length),n.staticFacet(kU)||(i=i.asSingle()),new yr(n,r,i,n.dynamicSlots.map(()=>null),(s,a)=>a.create(s),null)}get tabSize(){return this.facet(yr.tabSize)}get lineBreak(){return this.facet(yr.lineSeparator)||`
@@ -1157,7 +1157,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
1157
1157
  `))};if(c.from==this.from&&s<this.from?c.from=s:c.to==this.to&&s>this.to&&(c.to=s),c.from==c.to&&!c.insert.length){let u=Ze.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((Jt.mac||Jt.android)&&c.from==a-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:o,to:l,insert:Fr.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);aH(t,c,Ze.single(this.toEditorPos(r.selectionStart,u),this.toEditorPos(r.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let a=this.toEditorPos(r.rangeStart),o=this.toEditorPos(r.rangeEnd);a<o;a++){let l=t.coordsForChar(a);s=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||s||new DOMRect,i.push(s)}n.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let s of r.getTextFormats()){let a=s.underlineStyle,o=s.underlineThickness;if(a!="None"&&o!="None"){let l=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(l<c){let u=`text-decoration: underline ${a=="Dashed"?"dashed ":a=="Squiggle"?"wavy ":""}${o=="Thin"?1:2}px`;i.push(Bt.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:W4e.of(Bt.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(t.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let i=RT(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let n=0,r=!1,i=this.pendingContextChange;return t.changes.iterChanges((s,a,o,l,c)=>{if(r)return;let u=c.length-(a-s);if(i&&a>=i.to)if(i.from==s&&i.to==a&&i.insert.eq(c)){i=this.pendingContextChange=null,n+=u,this.to+=u;return}else i=null,this.revertPending(t.state);if(s+=n,a+=n,a<=this.from)this.from+=u,this.to+=u;else if(s<this.to){if(s<this.from||a>this.to||this.to-this.from+c.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(a),c.toString()),this.to+=u}n+=u}),i&&!r&&this.revertPending(t.state),!r}update(t){let n=this.pendingContextChange,r=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(r.from,r.to)&&t.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||n)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:n}=t.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(t.doc.length,n+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),t.doc.sliceString(n.from,n.to))}setSelection(t){let{main:n}=t.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(t){let{head:n}=t.selection.main;return!(this.from>0&&n-this.from<500||this.to<t.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(t,n=this.to-this.from){t=Math.min(t,n);let r=this.composing;return r&&r.drifted?r.editorBase+(t-r.contextBase):t+this.from}toContextPos(t){let n=this.composing;return n&&n.drifted?n.contextBase+(t-n.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class Ct{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:r}=t;this.dispatchTransactions=t.dispatchTransactions||r&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||H3t(t.parent)||document,this.viewState=new gOe(t.state||yr.create(t)),t.scrollTo&&t.scrollTo.is(q2)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Yy).map(i=>new KM(i));for(let i of this.plugins)i.update(this);this.observer=new p6t(this),this.inputState=new FXt(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Hfe(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let n=t.length==1&&t[0]instanceof ea?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let h of t){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let a=this.hasFocus,o=0,l=null;t.some(h=>h.annotation(iAe))?(this.inputState.notifiedFocused=a,o=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,l=sAe(s,a),l||(o=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(yr.phrases)!=this.state.facet(yr.phrases))return this.setState(s);i=P5.create(this,s,t),i.flags|=o;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let h of t){if(d&&(d=d.map(h.changes)),h.scrollIntoView){let{main:f}=h.state.selection;d=new xb(f.empty?f:Ze.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of h.effects)f.is(q2)&&(d=f.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=Q5.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(_S)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(B2)!=i.state.facet(B2)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let h of this.state.facet(UU))try{h(i)}catch(f){_l(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!K4e(this,u)&&c.force&&wb(this.contentDOM,c.key,c.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new gOe(t),this.plugins=t.facet(Yy).map(r=>new KM(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Hfe(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(t){let n=t.startState.facet(Yy),r=t.state.facet(Yy);if(n!=r){let i=[];for(let s of r){let a=n.indexOf(s);if(a<0)i.push(new KM(s));else{let o=this.plugins[a];o.mustUpdate=t,i.push(o)}}for(let s of this.plugins)s.mustUpdate!=t&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=t;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);n!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let n=t.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(r){_l(this.state,r,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let n=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:a}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let o=0;;o++){if(a<0)if(y4e(r))s=-1,a=this.viewState.heightMap.height;else{let f=this.viewState.scrollAnchorAt(i);s=f.from,a=f.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(o>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(f=>{try{return f.read(this)}catch(O){return _l(this.state,O),bOe}}),d=P5.create(this,this.state,[]),h=!1;d.flags|=l,n?n.flags|=l:n=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),h=this.docView.update(d),h&&this.docViewUpdate());for(let f=0;f<c.length;f++)if(u[f]!=bOe)try{let O=c[f];O.write&&O.write(u[f],this)}catch(O){_l(this.state,O)}if(h&&this.docView.updateSelection(!0),!d.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let O=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-a;if(O>1||O<-1){i=i+O,r.scrollTop=i/this.scaleY,a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let o of this.state.facet(UU))o(n)}get themeClasses(){return YU+" "+(this.state.facet(BU)?cAe:lAe)+" "+this.state.facet(B2)}updateAttrs(){let t=wOe(this,G4e,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Qf)?"true":"false",class:"cm-content",style:`${Jt.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),wOe(this,rH,n);let r=this.observer.ignore(()=>{let i=MU(this.contentDOM,this.contentAttrs,n),s=MU(this.dom,this.editorAttrs,t);return i||s});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let i of r.effects)if(i.is(Ct.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(_S);let t=this.state.facet(Ct.cspNonce);cg.mount(this.root,this.styleModules.concat(f6t).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===t.key){this.measureRequests[n]=t;return}}this.measureRequests.push(t)}}plugin(t){let n=this.pluginMap.get(t);return(n===void 0||n&&n.plugin!=t)&&this.pluginMap.set(t,n=this.plugins.find(r=>r.plugin==t)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,n,r){return e8(this,t,nOe(this,t,n,r))}moveByGroup(t,n){return e8(this,t,nOe(this,t,n,r=>CXt(this,t.head,r)))}visualLineSide(t,n){let r=this.bidiSpans(t),i=this.textDirectionAt(t.from),s=r[n?r.length-1:0];return Ze.cursor(s.side(n,i)+t.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return PXt(this,t,n,r)}moveVertically(t,n,r){return e8(this,t,QXt(this,t,n,r))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,n=0){return this.docView.posFromDOM(t,n)}posAtCoords(t,n=!0){return this.readMeasured(),H4e(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.docView.coordsAt(t,n);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(t),s=this.bidiSpans(i),a=s[Rp.find(s,t-i.from,-1,n)];return nP(r,a.dir==Li.LTR==n>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(q4e)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>v6t)return X4e(t.length);let n=this.textDirectionAt(t.from),r;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==n&&(s.fresh||A4e(s.isolates,r=Zfe(this,t))))return s.order;r||(r=Zfe(this,t));let i=hXt(t.text,n,r);return this.bidiCache.push(new Q5(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Jt.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{m4e(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,n={}){return q2.of(new xb(typeof t=="number"?Ze.cursor(t):t,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return q2.of(new xb(Ze.cursor(r.from),"start","start",r.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return us.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return us.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=cg.newName(),i=[B2.of(r),_S.of(ZU(`.${r}`,t))];return n&&n.dark&&i.push(BU.of(!0)),i}static baseTheme(t){return CO.lowest(_S.of(ZU("."+YU,t,uAe)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&xi.get(r)||xi.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}Ct.styleModule=_S;Ct.inputHandler=L4e;Ct.clipboardInputFilter=tH;Ct.clipboardOutputFilter=nH;Ct.scrollHandler=U4e;Ct.focusChangeEffect=j4e;Ct.perLineTextDirection=q4e;Ct.exceptionSink=M4e;Ct.updateListener=UU;Ct.editable=Qf;Ct.mouseSelectionStyle=F4e;Ct.dragMovesSelection=N4e;Ct.clickAddsSelectionRange=I4e;Ct.decorations=AT;Ct.outerDecorations=V4e;Ct.atomicRanges=iH;Ct.bidiIsolatedRanges=B4e;Ct.scrollMargins=Y4e;Ct.darkTheme=BU;Ct.cspNonce=Yt.define({combine:e=>e.length?e[0]:""});Ct.contentAttributes=rH;Ct.editorAttributes=G4e;Ct.lineWrapping=Ct.contentAttributes.of({class:"cm-lineWrapping"});Ct.announce=Mn.define();const v6t=4096,bOe={};class Q5{constructor(t,n,r,i,s,a){this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=a}static update(t,n){if(n.empty&&!t.some(s=>s.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:Li.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let a=t[s];a.dir==i&&!n.touchesRange(a.from,a.to)&&r.push(new Q5(n.mapPos(a.from,1),n.mapPos(a.to,-1),a.dir,a.isolates,!1,a.order))}return r}}function wOe(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let s=r[i],a=typeof s=="function"?s(e):s;a&&FU(a,n)}return n}const y6t=Jt.mac?"mac":Jt.windows?"win":Jt.linux?"linux":"key";function b6t(e,t){const n=e.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,a,o;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))t=="mac"?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(r="Alt-"+r),s&&(r="Ctrl-"+r),o&&(r="Meta-"+r),a&&(r="Shift-"+r),r}function Y2(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n!==!1&&t.shiftKey&&(e="Shift-"+e),e}const w6t=CO.default(Ct.domEventHandlers({keydown(e,t){return hAe(dAe(t.state),e,t,"editor")}})),xv=Yt.define({enables:w6t}),xOe=new WeakMap;function dAe(e){let t=e.facet(xv),n=xOe.get(t);return n||xOe.set(t,n=$6t(t.reduce((r,i)=>r.concat(i),[]))),n}function x6t(e,t,n){return hAe(dAe(e.state),t,e,n)}let yp=null;const S6t=4e3;function $6t(e,t=y6t){let n=Object.create(null),r=Object.create(null),i=(a,o)=>{let l=r[a];if(l==null)r[a]=o;else if(l!=o)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},s=(a,o,l,c,u)=>{var d,h;let f=n[a]||(n[a]=Object.create(null)),O=o.split(/ (?!$)/).map(v=>b6t(v,t));for(let v=1;v<O.length;v++){let y=O.slice(0,v).join(" ");i(y,!0),f[y]||(f[y]={preventDefault:!0,stopPropagation:!1,run:[b=>{let T=yp={view:b,prefix:y,scope:a};return setTimeout(()=>{yp==T&&(yp=null)},S6t),!0}]})}let g=O.join(" ");i(g,!1);let m=f[g]||(f[g]={preventDefault:!1,stopPropagation:!1,run:((h=(d=f._any)===null||d===void 0?void 0:d.run)===null||h===void 0?void 0:h.slice())||[]});l&&m.run.push(l),c&&(m.preventDefault=!0),u&&(m.stopPropagation=!0)};for(let a of e){let o=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let c of o){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=a;for(let h in u)u[h].run.push(f=>d(f,HU))}let l=a[t]||a.key;if(l)for(let c of o)s(c,l,a.run,a.preventDefault,a.stopPropagation),a.shift&&s(c,"Shift-"+l,a.shift,a.preventDefault,a.stopPropagation)}return n}let HU=null;function hAe(e,t,n,r){HU=t;let i=G3t(t),s=yl(i,0),a=nh(s)==i.length&&i!=" ",o="",l=!1,c=!1,u=!1;yp&&yp.view==n&&yp.scope==r&&(o=yp.prefix+" ",eAe.indexOf(t.keyCode)<0&&(c=!0,yp=null));let d=new Set,h=m=>{if(m){for(let v of m.run)if(!d.has(v)&&(d.add(v),v(n)))return m.stopPropagation&&(u=!0),!0;m.preventDefault&&(m.stopPropagation&&(u=!0),c=!0)}return!1},f=e[r],O,g;return f&&(h(f[o+Y2(i,t,!a)])?l=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Jt.windows&&t.ctrlKey&&t.altKey)&&(O=ug[t.keyCode])&&O!=i?(h(f[o+Y2(O,t,!0)])||t.shiftKey&&(g=ET[t.keyCode])!=i&&g!=O&&h(f[o+Y2(g,t,!1)]))&&(l=!0):a&&t.shiftKey&&h(f[o+Y2(i,t,!0)])&&(l=!0),!l&&h(f._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),HU=null,l}class sP{constructor(t,n,r,i,s){this.className=t,this.left=n,this.top=r,this.width=i,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,n){return n.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let s=fAe(t);return[new sP(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return k6t(t,n,r)}}function fAe(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Li.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function SOe(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let s=e.dom.getBoundingClientRect(),a=(i.top+i.bottom)/2,o=e.posAtCoords({x:s.left+1,y:a}),l=e.posAtCoords({x:s.right-1,y:a});return o==null||l==null?r:{from:Math.max(r.from,Math.min(o,l)),to:Math.min(r.to,Math.max(o,l))}}function k6t(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),s=e.textDirection==Li.LTR,a=e.contentDOM,o=a.getBoundingClientRect(),l=fAe(e),c=a.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),d=o.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),h=o.right-(u?parseInt(u.paddingRight):0),f=GU(e,r,1),O=GU(e,i,-1),g=f.type==tl.Text?f:null,m=O.type==tl.Text?O:null;if(g&&(e.lineWrapping||f.widgetLineBreaks)&&(g=SOe(e,r,1,g)),m&&(e.lineWrapping||O.widgetLineBreaks)&&(m=SOe(e,i,-1,m)),g&&m&&g.from==m.from&&g.to==m.to)return y(b(n.from,n.to,g));{let x=g?b(n.from,null,g):T(f,!1),S=m?b(null,n.to,m):T(O,!0),k=[];return(g||f).to<(m||O).from-(g&&m?1:0)||f.widgetLineBreaks>1&&x.bottom+e.defaultLineHeight/2<S.top?k.push(v(d,x.bottom,h,S.top)):x.bottom<S.top&&e.elementAtHeight((x.bottom+S.top)/2).type==tl.Text&&(x.bottom=S.top=(x.bottom+S.top)/2),y(x).concat(k).concat(y(S))}function v(x,S,k,_){return new sP(t,x-l.left,S-l.top,k-x,_-S)}function y({top:x,bottom:S,horizontal:k}){let _=[];for(let P=0;P<k.length;P+=2)_.push(v(k[P],x,k[P+1],S));return _}function b(x,S,k){let _=1e9,P=-1e9,C=[];function Q(L,j,q,z,V){let W=e.coordsAtPos(L,L==k.to?-2:2),M=e.coordsAtPos(q,q==k.from?2:-2);!W||!M||(_=Math.min(W.top,M.top,_),P=Math.max(W.bottom,M.bottom,P),V==Li.LTR?C.push(s&&j?d:W.left,s&&z?h:M.right):C.push(!s&&z?d:M.left,!s&&j?h:W.right))}let E=x??k.from,A=S??k.to;for(let L of e.visibleRanges)if(L.to>E&&L.from<A)for(let j=Math.max(L.from,E),q=Math.min(L.to,A);;){let z=e.state.doc.lineAt(j);for(let V of e.bidiSpans(z)){let W=V.from+z.from,M=V.to+z.from;if(W>=q)break;M>j&&Q(Math.max(W,j),x==null&&W<=E,Math.min(M,q),S==null&&M>=A,V.dir)}if(j=z.to+1,j>=q)break}return C.length==0&&Q(E,x==null,A,S==null,e.textDirection),{top:_,bottom:P,horizontal:C}}function T(x,S){let k=o.top+(S?x.top:x.bottom);return{top:k,bottom:k,horizontal:[]}}}function T6t(e,t){return e.constructor==t.constructor&&e.eq(t)}class _6t{constructor(t,n){this.view=t,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,t)}update(t){t.startState.facet(BQ)!=t.state.facet(BQ)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let n=0,r=t.facet(BQ);for(;n<r.length&&r[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:n}=this.view;(t!=this.scaleX||n!=this.scaleY)&&(this.scaleX=t,this.scaleY=n,this.dom.style.transform=`scale(${1/t}, ${1/n})`)}draw(t){if(t.length!=this.drawn.length||t.some((n,r)=>!T6t(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let i of t)i.update&&n&&i.constructor&&this.drawn[r].constructor&&i.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(i.draw(),n);for(;n;){let i=n.nextSibling;n.remove(),n=i}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const BQ=Yt.define();function OAe(e){return[us.define(t=>new _6t(t,e)),BQ.of(e)]}const XT=Yt.define({combine(e){return Vh(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function P6t(e={}){return[XT.of(e),C6t,Q6t,E6t,z4e.of(!0)]}function pAe(e){return e.startState.facet(XT)!=e.state.facet(XT)}const C6t=OAe({above:!0,markers(e){let{state:t}=e,n=t.facet(XT),r=[];for(let i of t.selection.ranges){let s=i==t.selection.main;if(i.empty||n.drawRangeCursor){let a=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",o=i.empty?i:Ze.cursor(i.head,i.head>i.anchor?-1:1);for(let l of sP.forRange(e,a,o))r.push(l)}}return r},update(e,t){e.transactions.some(r=>r.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=pAe(e);return n&&$Oe(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){$Oe(t.state,e)},class:"cm-cursorLayer"});function $Oe(e,t){t.style.animationDuration=e.facet(XT).cursorBlinkRate+"ms"}const Q6t=OAe({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:sP.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||pAe(e)},class:"cm-selectionLayer"}),E6t=CO.highest(Ct.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),gAe=Mn.define({map(e,t){return e==null?null:t.mapPos(e)}}),QS=Ia.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(gAe)?r.value:n,e)}}),R6t=us.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(QS);n==null?this.cursor!=null&&((t=this.cursor)===null||t===void 0||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(QS)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(QS),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(QS)!=e&&this.view.dispatch({effects:gAe.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function A6t(){return[QS,R6t]}function kOe(e,t,n,r,i){t.lastIndex=0;for(let s=e.iterRange(n,r),a=n,o;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)i(a+o.index,o)}function X6t(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:s}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=s:r.push({from:i,to:s});return r}class D6t{constructor(t){const{regexp:n,decoration:r,decorate:i,boundary:s,maxLength:a=1e3}=t;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,i)this.addMatch=(o,l,c,u)=>i(u,c,c+o[0].length,o,l);else if(typeof r=="function")this.addMatch=(o,l,c,u)=>{let d=r(o,l,c);d&&u(c,c+o[0].length,d)};else if(r)this.addMatch=(o,l,c,u)=>u(c,c+o[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=a}createDeco(t){let n=new hO,r=n.add.bind(n);for(let{from:i,to:s}of X6t(t,this.maxLength))kOe(t.state.doc,this.regexp,i,s,(a,o)=>this.addMatch(o,t,a,r));return n.finish()}updateDeco(t,n){let r=1e9,i=-1;return t.docChanged&&t.changes.iterChanges((s,a,o,l)=>{l>=t.view.viewport.from&&o<=t.view.viewport.to&&(r=Math.min(o,r),i=Math.max(l,i))}),t.viewportMoved||i-r>1e3?this.createDeco(t.view):i>-1?this.updateRange(t.view,n.map(t.changes),r,i):n}updateRange(t,n,r,i){for(let s of t.visibleRanges){let a=Math.max(s.from,r),o=Math.min(s.to,i);if(o>=a){let l=t.state.doc.lineAt(a),c=l.to<o?t.state.doc.lineAt(o):l,u=Math.max(s.from,l.from),d=Math.min(s.to,c.to);if(this.boundary){for(;a>l.from;a--)if(this.boundary.test(l.text[a-1-l.from])){u=a;break}for(;o<c.to;o++)if(this.boundary.test(c.text[o-c.from])){d=o;break}}let h=[],f,O=(g,m,v)=>h.push(v.range(g,m));if(l==c)for(this.regexp.lastIndex=u-l.from;(f=this.regexp.exec(l.text))&&f.index<d-l.from;)this.addMatch(f,t,f.index+l.from,O);else kOe(t.state.doc,this.regexp,u,d,(g,m)=>this.addMatch(m,t,g,O));n=n.update({filterFrom:u,filterTo:d,filter:(g,m)=>g<u||m>d,add:h})}}return n}}const KU=/x/.unicode!=null?"gu":"g",I6t=new RegExp(`[\0-\b
1158
1158
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,KU),N6t={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let r8=null;function F6t(){var e;if(r8==null&&typeof document<"u"&&document.body){let t=document.body.style;r8=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return r8||!1}const YQ=Yt.define({combine(e){let t=Vh(e,{render:null,specialChars:I6t,addSpecialChars:null});return(t.replaceTabs=!F6t())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,KU)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,KU)),t}});function M6t(e={}){return[YQ.of(e),L6t()]}let TOe=null;function L6t(){return TOe||(TOe=us.fromClass(class{constructor(e){this.view=e,this.decorations=Bt.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(YQ)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new D6t({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,s=yl(t[0],0);if(s==9){let a=i.lineAt(r),o=n.state.tabSize,l=Od(a.text,o,r-a.from);return Bt.replace({widget:new U6t((o-l%o)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Bt.replace({widget:new z6t(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(YQ);e.startState.facet(YQ)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}const j6t="•";function q6t(e){return e>=32?j6t:e==10?"␤":String.fromCharCode(9216+e)}class z6t extends xd{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=q6t(this.code),r=t.state.phrase("Control character")+" "+(N6t[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let s=document.createElement("span");return s.textContent=n,s.title=r,s.setAttribute("aria-label",r),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class U6t extends xd{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function W6t(){return V6t}const G6t=Bt.line({class:"cm-activeLine"}),V6t=us.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(G6t.range(i.from)),t=i.from)}return Bt.set(n)}},{decorations:e=>e.decorations});class B6t extends xd{constructor(t){super(),this.content=t}toDOM(t){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(t){let n=t.firstChild?N1(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=nP(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function Y6t(e){let t=us.fromClass(class{constructor(n){this.view=n,this.placeholder=e?Bt.set([Bt.widget({widget:new B6t(e),side:1}).range(0)]):Bt.none}get decorations(){return this.view.state.doc.length?Bt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,Ct.contentAttributes.of({"aria-placeholder":e})]:t}const JU=2e3;function Z6t(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),s=[];if(t.off>JU||n.off>JU||t.col<0||n.col<0){let a=Math.min(t.off,n.off),o=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let c=e.doc.line(l);c.length<=o&&s.push(Ze.range(c.from+a,c.to+o))}}else{let a=Math.min(t.col,n.col),o=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let c=e.doc.line(l),u=EU(c.text,a,e.tabSize,!0);if(u<0)s.push(Ze.cursor(c.to));else{let d=EU(c.text,o,e.tabSize);s.push(Ze.range(c.from+u,c.from+d))}}}return s}function H6t(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function _Oe(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,s=i>JU?-1:i==r.length?H6t(e,t.clientX):Od(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:s,off:i}}function K6t(e,t){let n=_Oe(e,t),r=e.state.selection;return n?{update(i){if(i.docChanged){let s=i.changes.mapPos(i.startState.doc.line(n.line).from),a=i.state.doc.lineAt(s);n={line:a.number,col:n.col,off:Math.min(n.off,a.length)},r=r.map(i.changes)}},get(i,s,a){let o=_Oe(e,i);if(!o)return r;let l=Z6t(e.state,n,o);return l.length?a?Ze.create(l.concat(r.ranges)):Ze.create(l):r}}:null}function J6t(e){let t=n=>n.altKey&&n.button==0;return Ct.mouseSelectionStyle.of((n,r)=>t(r)?K6t(n,r):null)}const eDt={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},tDt={style:"cursor: crosshair"};function nDt(e={}){let[t,n]=eDt[e.key||"Alt"],r=us.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==t||n(i))},keyup(i){(i.keyCode==t||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,Ct.contentAttributes.of(i=>{var s;return!((s=i.plugin(r))===null||s===void 0)&&s.isDown?tDt:null})]}const Dx="-10000px";class mAe{constructor(t,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=t.state.facet(n),this.tooltips=this.input.filter(a=>a);let s=null;this.tooltipViews=this.tooltips.map(a=>s=r(a,s))}update(t,n){var r;let i=t.state.facet(this.facet),s=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(t);return!1}let a=[],o=n?[]:null;for(let l=0;l<s.length;l++){let c=s[l],u=-1;if(c){for(let d=0;d<this.tooltips.length;d++){let h=this.tooltips[d];h&&h.create==c.create&&(u=d)}if(u<0)a[l]=this.createTooltipView(c,l?a[l-1]:null),o&&(o[l]=!!c.above);else{let d=a[l]=this.tooltipViews[u];o&&(o[l]=n[u]),d.update&&d.update(t)}}}for(let l of this.tooltipViews)a.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(o.forEach((l,c)=>n[c]=l),n.length=o.length),this.input=i,this.tooltips=s,this.tooltipViews=a,!0}}function rDt(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const i8=Yt.define({combine:e=>{var t,n,r;return{position:Jt.ios?"absolute":((t=e.find(i=>i.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=e.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||rDt}}}),POe=new WeakMap,cH=us.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(i8);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new mAe(e,uH,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(i8);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=Dx,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(e=r.destroy)===null||e===void 0||e.call(r);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Jt.gecko)n=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==Dx&&s.style.left=="0px"){let a=s.getBoundingClientRect();n=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(e=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=sH(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,a)=>{let o=this.manager.tooltipViews[a];return o.getCoords?o.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(i8).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let o of this.manager.tooltipViews)o.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let l=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:u}=c,d=e.pos[o],h=e.size[o];if(!d||l.clip!==!1&&(d.bottom<=Math.max(n.top,r.top)||d.top>=Math.min(n.bottom,r.bottom)||d.right<Math.max(n.left,r.left)-.1||d.left>Math.min(n.right,r.right)+.1)){u.style.top=Dx;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,O=f?7:0,g=h.right-h.left,m=(t=POe.get(c))!==null&&t!==void 0?t:h.bottom-h.top,v=c.offset||sDt,y=this.view.textDirection==Li.LTR,b=h.width>r.right-r.left?y?r.left:r.right-h.width:y?Math.max(r.left,Math.min(d.left-(f?14:0)+v.x,r.right-g)):Math.min(Math.max(r.left,d.left-g+(f?14:0)-v.x),r.right-g),T=this.above[o];!l.strictSide&&(T?d.top-m-O-v.y<r.top:d.bottom+m+O+v.y>r.bottom)&&T==r.bottom-d.bottom>d.top-r.top&&(T=this.above[o]=!T);let x=(T?d.top-r.top:r.bottom-d.bottom)-O;if(x<m&&c.resize!==!1){if(x<this.view.defaultLineHeight){u.style.top=Dx;continue}POe.set(c,m),u.style.height=(m=x)/s+"px"}else u.style.height&&(u.style.height="");let S=T?d.top-m-O-v.y:d.bottom+O+v.y,k=b+g;if(c.overlap!==!0)for(let _ of a)_.left<k&&_.right>b&&_.top<S+m&&_.bottom>S&&(S=T?_.top-m-2-O:_.bottom+O+2);if(this.position=="absolute"?(u.style.top=(S-e.parent.top)/s+"px",COe(u,(b-e.parent.left)/i)):(u.style.top=S/s+"px",COe(u,b/i)),f){let _=d.left+(y?v.x:-v.x)-(b+14-7);f.style.left=_/i+"px"}c.overlap!==!0&&a.push({left:b,top:S,right:k,bottom:S+m}),u.classList.toggle("cm-tooltip-above",T),u.classList.toggle("cm-tooltip-below",!T),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=Dx}},{eventObservers:{scroll(){this.maybeMeasure()}}});function COe(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const iDt=Ct.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),sDt={x:0,y:0},uH=Yt.define({enables:[cH,iDt]}),E5=Yt.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class H3{static create(t){return new H3(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new mAe(t,E5,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(t,n){let r=t.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let r of this.manager.tooltipViews){let i=r[t];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const aDt=uH.compute([E5],e=>{let t=e.facet(E5);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:H3.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class oDt{constructor(t,n,r,i,s){this.view=t,this.source=n,this.field=r,this.setHover=i,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:n}=this,r=t.docView.nearest(n.target);if(!r)return;let i,s=1;if(r instanceof Ep)i=r.posAtStart;else{if(i=t.posAtCoords(n),i==null)return;let o=t.coordsAtPos(i);if(!o||n.y<o.top||n.y>o.bottom||n.x<o.left-t.defaultCharacterWidth||n.x>o.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==Li.RTL?-1:1;s=n.x<o.left?-c:c}let a=this.source(t,i,s);if(a?.then){let o=this.pending={pos:i};a.then(l=>{this.pending==o&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>_l(t.state,l,"hover tooltip"))}else a&&!(Array.isArray(a)&&!a.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])})}get tooltip(){let t=this.view.plugin(cH),n=t?t.manager.tooltips.findIndex(r=>r.create==H3.create):-1;return n>-1?t.manager.tooltipViews[n]:null}mousemove(t){var n,r;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&s&&!lDt(s.dom,t)||this.pending){let{pos:a}=i[0]||this.pending,o=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:a;(a==o?this.view.posAtCoords(this.lastMove)!=a:!cDt(this.view,a,o,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:r}=this;r&&r.dom.contains(t.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let n=r=>{t.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Z2=4;function lDt(e,t){let{left:n,right:r,top:i,bottom:s}=e.getBoundingClientRect(),a;if(a=e.querySelector(".cm-tooltip-arrow")){let o=a.getBoundingClientRect();i=Math.min(o.top,i),s=Math.max(o.bottom,s)}return t.clientX>=n-Z2&&t.clientX<=r+Z2&&t.clientY>=i-Z2&&t.clientY<=s+Z2}function cDt(e,t,n,r,i,s){let a=e.scrollDOM.getBoundingClientRect(),o=e.documentTop+e.documentPadding.top+e.contentHeight;if(a.left>r||a.right<r||a.top>i||Math.min(a.bottom,o)<i)return!1;let l=e.posAtCoords({x:r,y:i},!1);return l>=t&&l<=n}function uDt(e,t={}){let n=Mn.define(),r=Ia.define({create(){return[]},update(i,s){if(i.length&&(t.hideOnChange&&(s.docChanged||s.selection)?i=[]:t.hideOn&&(i=i.filter(a=>!t.hideOn(s,a))),s.docChanged)){let a=[];for(let o of i){let l=s.changes.mapPos(o.pos,-1,Ya.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),o);c.pos=l,c.end!=null&&(c.end=s.changes.mapPos(c.end)),a.push(c)}}i=a}for(let a of s.effects)a.is(n)&&(i=a.value),a.is(dDt)&&(i=[]);return i},provide:i=>E5.from(i)});return{active:r,extension:[r,us.define(i=>new oDt(i,e,r,n,t.hoverTime||300)),aDt]}}function vAe(e,t){let n=e.plugin(cH);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const dDt=Mn.define(),QOe=Yt.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function DT(e,t){let n=e.plugin(yAe),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const yAe=us.fromClass(class{constructor(e){this.input=e.state.facet(IT),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(QOe);this.top=new H2(e,!0,t.topContainer),this.bottom=new H2(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(QOe);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new H2(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new H2(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(IT);if(n!=this.input){let r=n.filter(l=>l),i=[],s=[],a=[],o=[];for(let l of r){let c=this.specs.indexOf(l),u;c<0?(u=l(e.view),o.push(u)):(u=this.panels[c],u.update&&u.update(e)),i.push(u),(u.top?s:a).push(u)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(a);for(let l of o)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Ct.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class H2{constructor(t,n,r){this.view=t,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let n of this.panels)n.destroy&&t.indexOf(n)<0&&n.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let t=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;t!=n.dom;)t=EOe(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=EOe(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function EOe(e){let t=e.nextSibling;return e.remove(),t}const IT=Yt.define({enables:yAe});class OO extends D0{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}OO.prototype.elementClass="";OO.prototype.toDOM=void 0;OO.prototype.mapMode=Ya.TrackBefore;OO.prototype.startSide=OO.prototype.endSide=-1;OO.prototype.point=!0;const ZQ=Yt.define(),hDt=Yt.define(),fDt={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Cr.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},p$=Yt.define();function ODt(e){return[bAe(),p$.of({...fDt,...e})]}const ROe=Yt.define({combine:e=>e.some(t=>t)});function bAe(e){return[pDt]}const pDt=us.fromClass(class{constructor(e){this.view=e,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(p$).map(t=>new XOe(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(ROe),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}e.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(ROe)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&this.dom.remove();let n=Cr.iter(this.view.state.facet(ZQ),this.view.viewport.from),r=[],i=this.gutters.map(s=>new gDt(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(s.type)){let a=!0;for(let o of s.type)if(o.type==tl.Text&&a){eW(n,r,o.from);for(let l of i)l.line(this.view,o,r);a=!1}else if(o.widget)for(let l of i)l.widget(this.view,o)}else if(s.type==tl.Text){eW(n,r,s.from);for(let a of i)a.line(this.view,s,r)}else if(s.widget)for(let a of i)a.widget(this.view,s);for(let s of i)s.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(p$),n=e.state.facet(p$),r=e.docChanged||e.heightChanged||e.viewportChanged||!Cr.eq(e.startState.facet(ZQ),e.state.facet(ZQ),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let i of this.gutters)i.update(e)&&(r=!0);else{r=!0;let i=[];for(let s of n){let a=t.indexOf(s);a<0?i.push(new XOe(this.view,s)):(this.gutters[a].update(e),i.push(this.gutters[a]))}for(let s of this.gutters)s.dom.remove(),i.indexOf(s)<0&&s.destroy();for(let s of i)this.dom.appendChild(s.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>Ct.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==Li.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function AOe(e){return Array.isArray(e)?e:[e]}function eW(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class gDt{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=Cr.iter(t.markers,n.from)}addElement(t,n,r){let{gutter:i}=this,s=(n.top-this.height)/t.scaleY,a=n.height/t.scaleY;if(this.i==i.elements.length){let o=new wAe(t,a,s,r);i.elements.push(o),i.dom.appendChild(o.dom)}else i.elements[this.i].update(t,a,s,r);this.height=n.bottom,this.i++}line(t,n,r){let i=[];eW(this.cursor,i,n.from),r.length&&(i=i.concat(r));let s=this.gutter.config.lineMarker(t,n,i);s&&i.unshift(s);let a=this.gutter;i.length==0&&!a.config.renderEmptyElements||this.addElement(t,n,i)}widget(t,n){let r=this.gutter.config.widgetMarker(t,n.widget,n),i=r?[r]:null;for(let s of t.state.facet(hDt)){let a=s(t,n.widget,n);a&&(i||(i=[])).push(a)}i&&this.addElement(t,n,i)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let n=t.elements.pop();t.dom.removeChild(n.dom),n.destroy()}}}class XOe{constructor(t,n){this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let s=i.target,a;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();a=(l.top+l.bottom)/2}else a=i.clientY;let o=t.lineBlockAtHeight(a-t.documentTop);n.domEventHandlers[r](t,o,i)&&i.preventDefault()});this.markers=AOe(n.markers(t)),n.initialSpacer&&(this.spacer=new wAe(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let n=this.markers;if(this.markers=AOe(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],t);i!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[i])}let r=t.view.viewport;return!Cr.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class wAe{constructor(t,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,r,i)}update(t,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),mDt(this.markers,i)||this.setMarkers(t,i)}setMarkers(t,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let s=0,a=0;;){let o=a,l=s<n.length?n[s++]:null,c=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let d=a;d<this.markers.length;d++)if(this.markers[d].compare(l)){o=d,c=!0;break}}else o=this.markers.length;for(;a<o;){let u=this.markers[a++];if(u.toDOM){u.destroy(i);let d=i.nextSibling;i.remove(),i=d}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(t),i)),c&&a++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function mDt(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}const vDt=Yt.define(),yDt=Yt.define(),Zy=Yt.define({combine(e){return Vh(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let i in n){let s=r[i],a=n[i];r[i]=s?(o,l,c)=>s(o,l,c)||a(o,l,c):a}return r}})}});class s8 extends OO{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function a8(e,t){return e.state.facet(Zy).formatNumber(t,e.state)}const bDt=p$.compute([Zy],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(vDt)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new s8(a8(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(yDt)){let s=i(t,n,r);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(Zy)!=t.state.facet(Zy),initialSpacer(t){return new s8(a8(t,DOe(t.state.doc.lines)))},updateSpacer(t,n){let r=a8(n.view,DOe(n.view.state.doc.lines));return r==t.number?t:new s8(r)},domEventHandlers:e.facet(Zy).domEventHandlers}));function wDt(e={}){return[Zy.of(e),bAe(),bDt]}function DOe(e){let t=9;for(;t<e;)t=t*10+9;return t}const xDt=new class extends OO{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},SDt=ZQ.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(xDt.range(i)))}return Cr.of(t)});function $Dt(){return SDt}let kDt=0;class zt{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=kDt++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let r=typeof t=="string"?t:"?";if(t instanceof zt&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new zt(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(t){let n=new R5(t);return r=>r.modified.indexOf(n)>-1?r:R5.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let TDt=0;class R5{constructor(t){this.name=t,this.instances=[],this.id=TDt++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(o=>o.base==t&&_Dt(n,o.modified));if(r)return r;let i=[],s=new zt(t.name,i,t,n);for(let o of n)o.instances.push(s);let a=PDt(n);for(let o of t.set)if(!o.modified.length)for(let l of a)i.push(R5.get(o,l));return s}}function _Dt(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function PDt(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((n,r)=>r.length-n.length)}function Lr(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],a=2,o=i;for(let d=0;;){if(o=="..."&&d>0&&d+3==i.length){a=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!h)throw new RangeError("Invalid path: "+i);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),d+=h[0].length,d==i.length)break;let f=i[d++];if(d==i.length&&f=="!"){a=0;break}if(f!="/")throw new RangeError("Invalid path: "+i);o=i.slice(d)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new A5(r,a,l>0?s.slice(0,l):null);t[c]=u.sort(t[c])}}return xAe.add(t)}const xAe=new In;let A5=class{constructor(t,n,r,i){this.tags=t,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}};A5.empty=new A5([],2,null);function SAe(e,t){let n=Object.create(null);for(let s of e)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let a of s.tag)n[a.id]=s.class;let{scope:r,all:i=null}=t||{};return{style:s=>{let a=i;for(let o of s)for(let l of o.set){let c=n[l.id];if(c){a=a?a+" "+c:c;break}}return a},scope:r}}function CDt(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function QDt(e,t,n,r=0,i=e.length){let s=new EDt(r,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),r,i,"",s.highlighters),s.flush(i)}class EDt{constructor(t,n,r){this.at=t,this.highlighters=n,this.span=r,this.class=""}startSpan(t,n){n!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=n)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,n,r,i,s){let{type:a,from:o,to:l}=t;if(o>=r||l<=n)return;a.isTop&&(s=this.highlighters.filter(f=>!f.scope||f.scope(a)));let c=i,u=RDt(t)||A5.empty,d=CDt(s,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(n,o),c),u.opaque)return;let h=t.tree&&t.tree.prop(In.mounted);if(h&&h.overlay){let f=t.node.enter(h.overlay[0].from+o,1),O=this.highlighters.filter(m=>!m.scope||m.scope(h.tree.type)),g=t.firstChild();for(let m=0,v=o;;m++){let y=m<h.overlay.length?h.overlay[m]:null,b=y?y.from+o:l,T=Math.max(n,v),x=Math.min(r,b);if(T<x&&g)for(;t.from<x&&(this.highlightRange(t,T,x,i,s),this.startSpan(Math.min(x,t.to),c),!(t.to>=b||!t.nextSibling())););if(!y||b>r)break;v=y.to+o,v>n&&(this.highlightRange(f.cursor(),Math.max(n,y.from+o),Math.min(r,v),"",O),this.startSpan(Math.min(r,v),c))}g&&t.parent()}else if(t.firstChild()){h&&(i="");do if(!(t.to<=n)){if(t.from>=r)break;this.highlightRange(t,n,r,i,s),this.startSpan(Math.min(r,t.to),c)}while(t.nextSibling());t.parent()}}}function RDt(e){let t=e.type.prop(xAe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const Ft=zt.define,K2=Ft(),hp=Ft(),IOe=Ft(hp),NOe=Ft(hp),fp=Ft(),J2=Ft(fp),o8=Ft(fp),Ud=Ft(),om=Ft(Ud),Id=Ft(),Nd=Ft(),tW=Ft(),Ix=Ft(tW),eC=Ft(),R={comment:K2,lineComment:Ft(K2),blockComment:Ft(K2),docComment:Ft(K2),name:hp,variableName:Ft(hp),typeName:IOe,tagName:Ft(IOe),propertyName:NOe,attributeName:Ft(NOe),className:Ft(hp),labelName:Ft(hp),namespace:Ft(hp),macroName:Ft(hp),literal:fp,string:J2,docString:Ft(J2),character:Ft(J2),attributeValue:Ft(J2),number:o8,integer:Ft(o8),float:Ft(o8),bool:Ft(fp),regexp:Ft(fp),escape:Ft(fp),color:Ft(fp),url:Ft(fp),keyword:Id,self:Ft(Id),null:Ft(Id),atom:Ft(Id),unit:Ft(Id),modifier:Ft(Id),operatorKeyword:Ft(Id),controlKeyword:Ft(Id),definitionKeyword:Ft(Id),moduleKeyword:Ft(Id),operator:Nd,derefOperator:Ft(Nd),arithmeticOperator:Ft(Nd),logicOperator:Ft(Nd),bitwiseOperator:Ft(Nd),compareOperator:Ft(Nd),updateOperator:Ft(Nd),definitionOperator:Ft(Nd),typeOperator:Ft(Nd),controlOperator:Ft(Nd),punctuation:tW,separator:Ft(tW),bracket:Ix,angleBracket:Ft(Ix),squareBracket:Ft(Ix),paren:Ft(Ix),brace:Ft(Ix),content:Ud,heading:om,heading1:Ft(om),heading2:Ft(om),heading3:Ft(om),heading4:Ft(om),heading5:Ft(om),heading6:Ft(om),contentSeparator:Ft(Ud),list:Ft(Ud),quote:Ft(Ud),emphasis:Ft(Ud),strong:Ft(Ud),link:Ft(Ud),monospace:Ft(Ud),strikethrough:Ft(Ud),inserted:Ft(),deleted:Ft(),changed:Ft(),invalid:Ft(),meta:eC,documentMeta:Ft(eC),annotation:Ft(eC),processingInstruction:Ft(eC),definition:zt.defineModifier("definition"),constant:zt.defineModifier("constant"),function:zt.defineModifier("function"),standard:zt.defineModifier("standard"),local:zt.defineModifier("local"),special:zt.defineModifier("special")};for(let e in R){let t=R[e];t instanceof zt&&(t.name=e)}SAe([{tag:R.link,class:"tok-link"},{tag:R.heading,class:"tok-heading"},{tag:R.emphasis,class:"tok-emphasis"},{tag:R.strong,class:"tok-strong"},{tag:R.keyword,class:"tok-keyword"},{tag:R.atom,class:"tok-atom"},{tag:R.bool,class:"tok-bool"},{tag:R.url,class:"tok-url"},{tag:R.labelName,class:"tok-labelName"},{tag:R.inserted,class:"tok-inserted"},{tag:R.deleted,class:"tok-deleted"},{tag:R.literal,class:"tok-literal"},{tag:R.string,class:"tok-string"},{tag:R.number,class:"tok-number"},{tag:[R.regexp,R.escape,R.special(R.string)],class:"tok-string2"},{tag:R.variableName,class:"tok-variableName"},{tag:R.local(R.variableName),class:"tok-variableName tok-local"},{tag:R.definition(R.variableName),class:"tok-variableName tok-definition"},{tag:R.special(R.variableName),class:"tok-variableName2"},{tag:R.definition(R.propertyName),class:"tok-propertyName tok-definition"},{tag:R.typeName,class:"tok-typeName"},{tag:R.namespace,class:"tok-namespace"},{tag:R.className,class:"tok-className"},{tag:R.macroName,class:"tok-macroName"},{tag:R.propertyName,class:"tok-propertyName"},{tag:R.operator,class:"tok-operator"},{tag:R.comment,class:"tok-comment"},{tag:R.meta,class:"tok-meta"},{tag:R.invalid,class:"tok-invalid"},{tag:R.punctuation,class:"tok-punctuation"}]);var l8;const Ap=new In;function K3(e){return Yt.define({combine:e?t=>t.concat(e):void 0})}const dH=new In;class fc{constructor(t,n,r=[],i=""){this.data=t,this.name=i,yr.prototype.hasOwnProperty("tree")||Object.defineProperty(yr.prototype,"tree",{get(){return Xr(this)}}),this.parser=n,this.extension=[hg.of(this),yr.languageData.of((s,a,o)=>{let l=FOe(s,a,o),c=l.type.prop(Ap);if(!c)return[];let u=s.facet(c),d=l.type.prop(dH);if(d){let h=l.resolve(a-l.from,o);for(let f of d)if(f.test(h,s)){let O=s.facet(f.facet);return f.type=="replace"?O:O.concat(u)}}return u})].concat(r)}isActiveAt(t,n,r=-1){return FOe(t,n,r).type.prop(Ap)==this.data}findRegions(t){let n=t.facet(hg);if(n?.data==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,a)=>{if(s.prop(Ap)==this.data){r.push({from:a,to:a+s.length});return}let o=s.prop(In.mounted);if(o){if(o.tree.prop(Ap)==this.data){if(o.overlay)for(let l of o.overlay)r.push({from:l.from+a,to:l.to+a});else r.push({from:a,to:a+s.length});return}else if(o.overlay){let l=r.length;if(i(o.tree,o.overlay[0].from+a),r.length>l)return}}for(let l=0;l<s.children.length;l++){let c=s.children[l];c instanceof vr&&i(c,s.positions[l]+a)}};return i(Xr(t),0),r}get allowsNesting(){return!0}}fc.setState=Mn.define();function FOe(e,t,n){let r=e.facet(hg),i=Xr(e).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(t,n,bi.ExcludeBuffers))s.type.isTop&&(i=s);return i}class Ar extends fc{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=K3(t.languageData);return new Ar(n,t.parser.configure({props:[Ap.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Ar(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Xr(e){let t=e.field(fc.state,!1);return t?t.tree:vr.empty}class ADt{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,n){let r=this.cursorPos-this.string.length;return t<r||n>=this.cursorPos?this.doc.sliceString(t,n):this.string.slice(t-r,n-r)}}let Nx=null;class M0{constructor(t,n,r=[],i,s,a,o,l){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=a,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new M0(t,n,[],vr.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ADt(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=vr.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(Bf.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,n;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped(Bf.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Nx;Nx=this;try{return t()}finally{Nx=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=MOe(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:s,viewport:a,skipped:o}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((c,u,d,h)=>l.push({fromA:c,toA:u,fromB:d,toB:h})),r=Bf.applyChanges(r,l),i=vr.empty,s=0,a={from:t.mapPos(a.from,-1),to:t.mapPos(a.to,1)},this.skipped.length){o=[];for(let c of this.skipped){let u=t.mapPos(c.from,1),d=t.mapPos(c.to,-1);u<d&&o.push({from:u,to:d})}}}return new M0(this.parser,n,r,i,s,a,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:s}=this.skipped[r];i<t.to&&s>t.from&&(this.fragments=MOe(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends V3{createParse(n,r,i){let s=i[0].from,a=i[i.length-1].to;return{parsedPos:s,advance(){let l=Nx;if(l){for(let c of i)l.tempSkipped.push(c);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=a,new vr(na.none,[],[],a-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return Nx}}function MOe(e,t,n){return Bf.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class j1{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new j1(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=M0.create(t.facet(hg).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new j1(r)}}fc.state=Ia.define({create:j1.init,update(e,t){for(let n of t.effects)if(n.is(fc.setState))return n.value;return t.startState.facet(hg)!=t.state.facet(hg)?j1.init(t.state):e.apply(t)}});let $Ae=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&($Ae=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const c8=typeof navigator<"u"&&(!((l8=navigator.scheduling)===null||l8===void 0)&&l8.isInputPending)?()=>navigator.scheduling.isInputPending():null,XDt=us.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(fc.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(fc.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=$Ae(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,s=r.field(fc.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,t&&!c8?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<i&&r.doc.length>i+1e3,l=s.context.work(()=>c8&&c8()||Date.now()>a,i+(o?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:fc.setState.of(new j1(s.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>_l(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),hg=Yt.define({combine(e){return e.length?e[0]:null},enables:e=>[fc.state,XDt,Ct.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class kr{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class Ee{constructor(t,n,r,i,s,a=void 0){this.name=t,this.alias=n,this.extensions=r,this.filename=i,this.loadFunc=s,this.support=a,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(r)}return new Ee(t.name,(t.alias||[]).concat(t.name).map(i=>i.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(t,n){for(let i of t)if(i.filename&&i.filename.test(n))return i;let r=/\.([^.]+)$/.exec(n);if(r){for(let i of t)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(t,n,r=!0){n=n.toLowerCase();for(let i of t)if(i.alias.some(s=>s==n))return i;if(r)for(let i of t)for(let s of i.alias){let a=n.indexOf(s);if(a>-1&&(s.length>2||!/\w/.test(n[a-1])&&!/\w/.test(n[a+s.length])))return i}return null}}const DDt=Yt.define(),Lw=Yt.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function L0(e){let t=e.facet(Lw);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function NT(e,t){let n="",r=e.tabSize,i=e.facet(Lw)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let s=0;s<t;s++)n+=i;return n}function hH(e,t){e instanceof yr&&(e=new J3(e));for(let r of e.state.facet(DDt)){let i=r(e,t);if(i!==void 0)return i}let n=Xr(e.state);return n.length>=t?IDt(e,n,t):null}class J3{constructor(t,n={}){this.state=t,this.options=n,this.unit=L0(t)}lineAt(t,n=1){let r=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==t?{text:"",from:t}:(n<0?i<t:i<=t)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(t,n=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(t,n);return r.slice(t-i,Math.min(r.length,t+100-i))}column(t,n=1){let{text:r,from:i}=this.lineAt(t,n),s=this.countColumn(r,t-i),a=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return a>-1&&(s+=a-this.countColumn(r,r.search(/\S|$/))),s}countColumn(t,n=t.length){return Od(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:r,from:i}=this.lineAt(t,n),s=this.options.overrideIndentation;if(s){let a=s(i);if(a>-1)return a}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ds=new In;function IDt(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let a=i;a&&!(a.from<r.node.from||a.to>r.node.to||a.from==r.node.from&&a.type==r.node.type);a=a.parent)s.push(a);for(let a=s.length-1;a>=0;a--)r={node:s[a],next:r}}return kAe(r,e,n)}function kAe(e,t,n){for(let r=e;r;r=r.next){let i=FDt(r.node);if(i)return i(fH.create(t,n,r))}return 0}function NDt(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function FDt(e){let t=e.type.prop(ds);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(In.closedBy))){let i=e.lastChild,s=i&&r.indexOf(i.name)>-1;return a=>TAe(a,!0,1,void 0,s&&!NDt(a)?i.from:void 0)}return e.parent==null?MDt:null}function MDt(){return 0}class fH extends J3{constructor(t,n,r){super(t.state,t.options),this.base=t,this.pos=n,this.context=r}get node(){return this.context.node}static create(t,n,r){return new fH(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(LDt(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return kAe(this.context.next,this.base,this.pos)}}function LDt(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function jDt(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,s=e.state.doc.lineAt(n.from),a=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let o=n.to;;){let l=t.childAfter(o);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=a)return null;let c=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+c}}o=l.to}}function fu({closing:e,align:t=!0,units:n=1}){return r=>TAe(r,t,n,e)}function TAe(e,t,n,r,i){let s=e.textAfter,a=s.match(/^\s*/)[0].length,o=r&&s.slice(a,a+r.length)==r||i==e.pos+a,l=t?jDt(e):null;return l?o?e.column(l.from):e.column(l.to):e.baseIndent+(o?0:e.unit*n)}const OH=e=>e.baseIndent;function ys({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const qDt=200;function zDt(){return yr.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+qDt)return e;let s=n.sliceString(i.from,r);if(!t.some(c=>c.test(s)))return e;let{state:a}=e,o=-1,l=[];for(let{head:c}of a.selection.ranges){let u=a.doc.lineAt(c);if(u.from==o)continue;o=u.from;let d=hH(a,u.from);if(d==null)continue;let h=/^\s*/.exec(u.text)[0],f=NT(a,d);h!=f&&l.push({from:u.from,to:u.from+h.length,insert:f})}return l.length?[e,{changes:l,sequential:!0}]:e})}const _Ae=Yt.define(),es=new In;function Qo(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function UDt(e,t,n){let r=Xr(e);if(r.length<n)return null;let i=r.resolveStack(n,1),s=null;for(let a=i;a;a=a.next){let o=a.node;if(o.to<=n||o.from>n)continue;if(s&&o.from<t)break;let l=o.type.prop(es);if(l&&(o.to<r.length-50||r.length==e.doc.length||!WDt(o))){let c=l(o,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(s=c)}}return s}function WDt(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function X5(e,t,n){for(let r of e.facet(_Ae)){let i=r(e,t,n);if(i)return i}return UDt(e,t,n)}function PAe(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const eX=Mn.define({map:PAe}),aP=Mn.define({map:PAe});function CAe(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(r=>r.from<=n&&r.to>=n)||t.push(e.lineBlockAt(n));return t}const j0=Ia.define({create(){return Bt.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(eX)&&!GDt(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(RAe),i=r?Bt.replace({widget:new JDt(r(t.state,n.value))}):LOe;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(aP)&&(e=e.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:r}=t.selection.main;e.between(r,r,(i,s)=>{i<r&&s>r&&(n=!0)}),n&&(e=e.update({filterFrom:r,filterTo:r,filter:(i,s)=>s<=r||i>=r}))}return e},provide:e=>Ct.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");t.push(LOe.range(r,i))}return Bt.set(t,!0)}});function D5(e,t,n){var r;let i=null;return(r=e.field(j0,!1))===null||r===void 0||r.between(t,n,(s,a)=>{(!i||i.from>s)&&(i={from:s,to:a})}),i}function GDt(e,t,n){let r=!1;return e.between(t,t,(i,s)=>{i==t&&s==n&&(r=!0)}),r}function QAe(e,t){return e.field(j0,!1)?t:t.concat(Mn.appendConfig.of(AAe()))}const VDt=e=>{for(let t of CAe(e)){let n=X5(e.state,t.from,t.to);if(n)return e.dispatch({effects:QAe(e.state,[eX.of(n),EAe(e,n)])}),!0}return!1},BDt=e=>{if(!e.state.field(j0,!1))return!1;let t=[];for(let n of CAe(e)){let r=D5(e.state,n.from,n.to);r&&t.push(aP.of(r),EAe(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function EAe(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return Ct.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const YDt=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),s=X5(t,i.from,i.to);s&&n.push(eX.of(s)),r=(s?e.lineBlockAt(s.to):i).to+1}return n.length&&e.dispatch({effects:QAe(e.state,n)}),!!n.length},ZDt=e=>{let t=e.state.field(j0,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(aP.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},HDt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:VDt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:BDt},{key:"Ctrl-Alt-[",run:YDt},{key:"Ctrl-Alt-]",run:ZDt}],KDt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},RAe=Yt.define({combine(e){return Vh(e,KDt)}});function AAe(e){return[j0,nIt]}function XAe(e,t){let{state:n}=e,r=n.facet(RAe),i=a=>{let o=e.lineBlockAt(e.posAtDOM(a.target)),l=D5(e.state,o.from,o.to);l&&e.dispatch({effects:aP.of(l)}),a.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const LOe=Bt.replace({widget:new class extends xd{toDOM(e){return XAe(e,null)}}});class JDt extends xd{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return XAe(t,this.value)}}const eIt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class u8 extends OO{constructor(t,n){super(),this.config=t,this.open=n}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=t.state.phrase(this.open?"Fold line":"Unfold line"),n}}function tIt(e={}){let t={...eIt,...e},n=new u8(t,!0),r=new u8(t,!1),i=us.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(hg)!=a.state.facet(hg)||a.startState.field(j0,!1)!=a.state.field(j0,!1)||Xr(a.startState)!=Xr(a.state)||t.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let o=new hO;for(let l of a.viewportLineBlocks){let c=D5(a.state,l.from,l.to)?r:X5(a.state,l.from,l.to)?n:null;c&&o.add(l.from,l.from,c)}return o.finish()}}),{domEventHandlers:s}=t;return[i,ODt({class:"cm-foldGutter",markers(a){var o;return((o=a.plugin(i))===null||o===void 0?void 0:o.markers)||Cr.empty},initialSpacer(){return new u8(t,!1)},domEventHandlers:{...s,click:(a,o,l)=>{if(s.click&&s.click(a,o,l))return!0;let c=D5(a.state,o.from,o.to);if(c)return a.dispatch({effects:aP.of(c)}),!0;let u=X5(a.state,o.from,o.to);return u?(a.dispatch({effects:eX.of(u)}),!0):!1}}}),AAe()]}const nIt=Ct.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class jw{constructor(t,n){this.specs=t;let r;function i(o){let l=cg.newName();return(r||(r=Object.create(null)))["."+l]=o,l}const s=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,a=n.scope;this.scope=a instanceof fc?o=>o.prop(Ap)==a.data:a?o=>o==a:void 0,this.style=SAe(t.map(o=>({tag:o.tag,class:o.class||i(Object.assign({},o,{tag:null}))})),{all:s}).style,this.module=r?new cg(r):null,this.themeType=n.themeType}static define(t,n){return new jw(t,n||{})}}const nW=Yt.define(),DAe=Yt.define({combine(e){return e.length?[e[0]]:null}});function d8(e){let t=e.facet(nW);return t.length?t:e.facet(DAe)}function I5(e,t){let n=[iIt],r;return e instanceof jw&&(e.module&&n.push(Ct.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(DAe.of(e)):r?n.push(nW.computeN([Ct.darkTheme],i=>i.facet(Ct.darkTheme)==(r=="dark")?[e]:[])):n.push(nW.of(e)),n}class rIt{constructor(t){this.markCache=Object.create(null),this.tree=Xr(t.state),this.decorations=this.buildDeco(t,d8(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=Xr(t.state),r=d8(t.state),i=r!=d8(t.startState),{viewport:s}=t.view,a=t.changes.mapPos(this.decoratedTo,1);n.length<s.to&&!i&&n.type==this.tree.type&&a>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=a):(n!=this.tree||t.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=s.to)}buildDeco(t,n){if(!n||!this.tree.length)return Bt.none;let r=new hO;for(let{from:i,to:s}of t.visibleRanges)QDt(this.tree,n,(a,o,l)=>{r.add(a,o,this.markCache[l]||(this.markCache[l]=Bt.mark({class:l})))},i,s);return r.finish()}}const iIt=CO.high(us.fromClass(rIt,{decorations:e=>e.decorations})),sIt=jw.define([{tag:R.meta,color:"#404740"},{tag:R.link,textDecoration:"underline"},{tag:R.heading,textDecoration:"underline",fontWeight:"bold"},{tag:R.emphasis,fontStyle:"italic"},{tag:R.strong,fontWeight:"bold"},{tag:R.strikethrough,textDecoration:"line-through"},{tag:R.keyword,color:"#708"},{tag:[R.atom,R.bool,R.url,R.contentSeparator,R.labelName],color:"#219"},{tag:[R.literal,R.inserted],color:"#164"},{tag:[R.string,R.deleted],color:"#a11"},{tag:[R.regexp,R.escape,R.special(R.string)],color:"#e40"},{tag:R.definition(R.variableName),color:"#00f"},{tag:R.local(R.variableName),color:"#30a"},{tag:[R.typeName,R.namespace],color:"#085"},{tag:R.className,color:"#167"},{tag:[R.special(R.variableName),R.macroName],color:"#256"},{tag:R.definition(R.propertyName),color:"#00c"},{tag:R.comment,color:"#940"},{tag:R.invalid,color:"#f00"}]),aIt=Ct.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),IAe=1e4,NAe="()[]{}",FAe=Yt.define({combine(e){return Vh(e,{afterCursor:!0,brackets:NAe,maxScanDistance:IAe,renderMatch:cIt})}}),oIt=Bt.mark({class:"cm-matchingBracket"}),lIt=Bt.mark({class:"cm-nonmatchingBracket"});function cIt(e){let t=[],n=e.matched?oIt:lIt;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const uIt=Ia.define({create(){return Bt.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(FAe);for(let i of t.state.selection.ranges){if(!i.empty)continue;let s=hh(t.state,i.head,-1,r)||i.head>0&&hh(t.state,i.head-1,1,r)||r.afterCursor&&(hh(t.state,i.head,1,r)||i.head<t.state.doc.length&&hh(t.state,i.head+1,-1,r));s&&(n=n.concat(r.renderMatch(s,t.state)))}return Bt.set(n,!0)},provide:e=>Ct.decorations.from(e)}),dIt=[uIt,aIt];function hIt(e={}){return[FAe.of(e),dIt]}const pH=new In;function rW(e,t,n){let r=e.prop(t<0?In.openedBy:In.closedBy);if(r)return r;if(e.name.length==1){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function iW(e){let t=e.type.prop(pH);return t?t(e.node):e}function hh(e,t,n,r={}){let i=r.maxScanDistance||IAe,s=r.brackets||NAe,a=Xr(e),o=a.resolveInner(t,n);for(let l=o;l;l=l.parent){let c=rW(l.type,n,s);if(c&&l.from<l.to){let u=iW(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return fIt(e,t,n,l,u,c,s)}}return OIt(e,t,n,a,o.type,i,s)}function fIt(e,t,n,r,i,s,a){let o=r.parent,l={from:i.from,to:i.to},c=0,u=o?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(c==0&&s.indexOf(u.type.name)>-1&&u.from<u.to){let d=iW(u);return{start:l,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(rW(u.type,n,a))c++;else if(rW(u.type,-n,a)){if(c==0){let d=iW(u);return{start:l,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function OIt(e,t,n,r,i,s,a){let o=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=a.indexOf(o);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let h=0;!u.next().done&&h<=s;){let f=u.value;n<0&&(h+=f.length);let O=t+h*n;for(let g=n>0?0:f.length-1,m=n>0?f.length:-1;g!=m;g+=n){let v=a.indexOf(f[g]);if(!(v<0||r.resolveInner(O+g,1).type!=i))if(v%2==0==n>0)d++;else{if(d==1)return{start:c,end:{from:O+g,to:O+g+1},matched:v>>1==l>>1};d--}}n>0&&(h+=f.length)}return u.done?{start:c,matched:!1}:null}function jOe(e,t,n,r=0,i=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let s=i;for(let a=r;a<t;a++)e.charCodeAt(a)==9?s+=n-s%n:s++;return s}class MAe{constructor(t,n,r,i){this.string=t,this.tabSize=n,this.indentUnit=r,this.overrideIndent=i,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let n=this.string.charAt(this.pos),r;if(typeof t=="string"?r=n==t:r=n&&(t instanceof RegExp?t.test(n):t(n)),r)return++this.pos,n}eatWhile(t){let n=this.pos;for(;this.eat(t););return this.pos>n}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let n=this.string.indexOf(t,this.pos);if(n>-1)return this.pos=n,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=jOe(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:jOe(this.string,null,this.tabSize)}match(t,n,r){if(typeof t=="string"){let i=a=>r?a.toLowerCase():a,s=this.string.substr(this.pos,t.length);return i(s)==i(t)?(n!==!1&&(this.pos+=t.length),!0):null}else{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&n!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function pIt(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||gIt,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||mH,mergeTokens:e.mergeTokens!==!1}}function gIt(e){if(typeof e!="object")return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}const qOe=new WeakMap;class ut extends fc{constructor(t){let n=K3(t.languageData),r=pIt(t),i,s=new class extends V3{createParse(a,o,l){return new vIt(i,a,o,l)}};super(n,s,[],t.name),this.topNode=wIt(n,this),i=this,this.streamParser=r,this.stateAfter=new In({perNode:!0}),this.tokenTable=t.tokenTable?new zAe(r.tokenTable):bIt}static define(t){return new ut(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=qOe.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=gH(this,t.node.tree,t.node.from,t.node.from,n??t.pos),s,a;if(i?(a=i.state,s=i.pos+1):(a=this.streamParser.startState(t.unit),s=t.node.from),t.pos-s>1e4)return null;for(;s<t.pos;){let l=t.state.doc.lineAt(s),c=Math.min(t.pos,l.to);if(l.length){let u=r?r(l.from):-1,d=new MAe(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;d.pos<c-l.from;)jAe(this.streamParser.token,d,a)}else this.streamParser.blankLine(a,t.unit);if(c==t.pos)break;s=l.to+1}let o=t.lineAt(t.pos);return r&&n==null&&qOe.set(t.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],t)}get allowsNesting(){return!1}}function gH(e,t,n,r,i){let s=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(s)return{state:e.streamParser.copyState(s),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],l=n+t.positions[a],c=o instanceof vr&&l<i&&gH(e,o,l,r,i);if(c)return c}return null}function LAe(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let s=t.children.length-1;s>=0;s--){let a=t.positions[s],o=t.children[s],l;if(a<r&&o instanceof vr){if(!(l=LAe(e,o,n-a,r-a,i)))break;return i?new vr(t.type,t.children.slice(0,s).concat(l),t.positions.slice(0,s+1),a+l.length):l}}return null}function mIt(e,t,n,r,i){for(let s of t){let a=s.from+(s.openStart?25:0),o=s.to-(s.openEnd?25:0),l=a<=n&&o>n&&gH(e,s.tree,0-s.offset,n,o),c;if(l&&l.pos<=r&&(c=LAe(e,s.tree,n+s.offset,l.pos+s.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?L0(i):4),tree:vr.empty}}let vIt=class{constructor(t,n,r,i){this.lang=t,this.input=n,this.fragments=r,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let s=M0.get(),a=i[0].from,{state:o,tree:l}=mIt(t,r,a,this.to,s?.state);this.state=o,this.parsedPos=this.chunkStart=a+l.length;for(let c=0;c<l.children.length;c++)this.chunks.push(l.children[c]),this.chunkPos.push(l.positions[c]);s&&this.parsedPos<s.viewport.from-1e5&&i.some(c=>c.from<=s.viewport.from&&c.to>=s.viewport.from)&&(this.state=this.lang.streamParser.startState(L0(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=M0.get(),n=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(n,this.chunkStart+2048);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=n?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,n),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let n=this.input.chunk(t);if(this.input.lineChunks)n==`
1159
1159
  `&&(n="");else{let r=n.indexOf(`
1160
- `);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let s=this.ranges[i].to;if(s>=r||(n=n.slice(0,s-(r-n.length)),i++,i==this.ranges.length))break;let a=this.ranges[i].from,o=this.lineAfter(a);n+=o,r=a+o.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,s=t+n;if(r>0?i>s:i>=s)break;let a=this.ranges[++this.rangeIndex].from;n+=a-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let s=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let o=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,s+=this.chunk.length-o}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&s==4&&a>=0&&this.chunk[a]==t&&this.chunk[a+2]==n?this.chunk[a+2]=r:this.chunk.push(t,n,r,s),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:s}=this.lang,a=new MAe(n,t?t.state.tabSize:4,t?L0(t.state):2);if(a.eol())s.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let o=jAe(s.token,a,this.state);if(o&&(i=this.emitToken(this.lang.tokenTable.resolve(o),this.parsedPos+a.start,this.parsedPos+a.pos,i)),a.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=vr.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:yIt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new vr(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new vr(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function jAe(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let i=e(t,n);if(t.pos>t.start)return i}throw new Error("Stream parser failed to advance stream.")}const mH=Object.create(null),FT=[na.none],yIt=new Mw(FT),zOe=[],UOe=Object.create(null),qAe=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])qAe[e]=UAe(mH,t);class zAe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),qAe)}resolve(t){return t?this.table[t]||(this.table[t]=UAe(this.extra,t)):0}}const bIt=new zAe(mH);function h8(e,t){zOe.indexOf(e)>-1||(zOe.push(e),console.warn(t))}function UAe(e,t){let n=[];for(let o of t.split(" ")){let l=[];for(let c of o.split(".")){let u=e[c]||R[c];u?typeof u=="function"?l.length?l=l.map(u):h8(c,`Modifier ${c} used at start of tag`):l.length?h8(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:h8(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(o=>o.id),s=UOe[i];if(s)return s.id;let a=UOe[i]=na.define({id:FT.length,name:r,props:[Lr({[r]:n})]});return FT.push(a),a.id}function wIt(e,t){let n=na.define({id:FT.length,name:"Document",props:[Ap.add(()=>e),ds.add(()=>r=>t.getIndent(r))],top:!0});return FT.push(n),n}Li.RTL,Li.LTR;function it(e){return new kr(ut.define(e))}function HO(e){return Ie(()=>Promise.resolve().then(()=>Vqt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const xIt=[Ee.of({name:"C",extensions:["c","h","ino"],load(){return Ie(()=>Promise.resolve().then(()=>Dge),void 0,import.meta.url).then(e=>e.cpp())}}),Ee.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return Ie(()=>Promise.resolve().then(()=>Dge),void 0,import.meta.url).then(e=>e.cpp())}}),Ee.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return HO("Cassandra")}}),Ee.of({name:"CSS",extensions:["css"],load(){return Ie(()=>Promise.resolve().then(()=>lMt),void 0,import.meta.url).then(e=>e.css())}}),Ee.of({name:"Go",extensions:["go"],load(){return Ie(()=>import("./index-CT6w0yXj.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>e.go())}}),Ee.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return Ie(()=>Promise.resolve().then(()=>JMt),void 0,import.meta.url).then(e=>e.html())}}),Ee.of({name:"Java",extensions:["java"],load(){return Ie(()=>Promise.resolve().then(()=>Hqt),void 0,import.meta.url).then(e=>e.java())}}),Ee.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Ie(()=>Promise.resolve().then(()=>iC),void 0,import.meta.url).then(e=>e.javascript())}}),Ee.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Ie(()=>Promise.resolve().then(()=>i7t),void 0,import.meta.url).then(e=>e.json())}}),Ee.of({name:"JSX",extensions:["jsx"],load(){return Ie(()=>Promise.resolve().then(()=>iC),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Ee.of({name:"LESS",extensions:["less"],load(){return Ie(()=>Promise.resolve().then(()=>b8t),void 0,import.meta.url).then(e=>e.less())}}),Ee.of({name:"Liquid",extensions:["liquid"],load(){return Ie(()=>Promise.resolve().then(()=>IWt),void 0,import.meta.url).then(e=>e.liquid())}}),Ee.of({name:"MariaDB SQL",load(){return HO("MariaSQL")}}),Ee.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Ie(()=>Promise.resolve().then(()=>c8t),void 0,import.meta.url).then(e=>e.markdown())}}),Ee.of({name:"MS SQL",load(){return HO("MSSQL")}}),Ee.of({name:"MySQL",load(){return HO("MySQL")}}),Ee.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return Ie(()=>Promise.resolve().then(()=>fWt),void 0,import.meta.url).then(e=>e.php())}}),Ee.of({name:"PLSQL",extensions:["pls"],load(){return HO("PLSQL")}}),Ee.of({name:"PostgreSQL",load(){return HO("PostgreSQL")}}),Ee.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return Ie(()=>Promise.resolve().then(()=>Ijt),void 0,import.meta.url).then(e=>e.python())}}),Ee.of({name:"Rust",extensions:["rs"],load(){return Ie(()=>Promise.resolve().then(()=>mzt),void 0,import.meta.url).then(e=>e.rust())}}),Ee.of({name:"Sass",extensions:["sass"],load(){return Ie(()=>Promise.resolve().then(()=>Zpe),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),Ee.of({name:"SCSS",extensions:["scss"],load(){return Ie(()=>Promise.resolve().then(()=>Zpe),void 0,import.meta.url).then(e=>e.sass())}}),Ee.of({name:"SQL",extensions:["sql"],load(){return HO("StandardSQL")}}),Ee.of({name:"SQLite",load(){return HO("SQLite")}}),Ee.of({name:"TSX",extensions:["tsx"],load(){return Ie(()=>Promise.resolve().then(()=>iC),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Ee.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Ie(()=>Promise.resolve().then(()=>iC),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Ee.of({name:"WebAssembly",extensions:["wat","wast"],load(){return Ie(()=>Promise.resolve().then(()=>MWt),void 0,import.meta.url).then(e=>e.wast())}}),Ee.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return Ie(()=>Promise.resolve().then(()=>iqt),void 0,import.meta.url).then(e=>e.xml())}}),Ee.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return Ie(()=>import("./index-BgGl2-0g.js"),__vite__mapDeps([5,1,2]),import.meta.url).then(e=>e.yaml())}}),Ee.of({name:"APL",extensions:["dyalog","apl"],load(){return Ie(()=>Promise.resolve().then(()=>OBt),void 0,import.meta.url).then(e=>it(e.apl))}}),Ee.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return Ie(()=>Promise.resolve().then(()=>pBt),void 0,import.meta.url).then(e=>it(e.asciiArmor))}}),Ee.of({name:"ASN.1",extensions:["asn","asn1"],load(){return Ie(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>it(e.asn1({})))}}),Ee.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return Ie(()=>Promise.resolve().then(()=>bBt),void 0,import.meta.url).then(e=>it(e.asterisk))}}),Ee.of({name:"Brainfuck",extensions:["b","bf"],load(){return Ie(()=>Promise.resolve().then(()=>xBt),void 0,import.meta.url).then(e=>it(e.brainfuck))}}),Ee.of({name:"Cobol",extensions:["cob","cpy"],load(){return Ie(()=>Promise.resolve().then(()=>ZBt),void 0,import.meta.url).then(e=>it(e.cobol))}}),Ee.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.csharp))}}),Ee.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return Ie(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ee.of({name:"ClojureScript",extensions:["cljs"],load(){return Ie(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ee.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return Ie(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>it(e.gss))}}),Ee.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return Ie(()=>Promise.resolve().then(()=>jBt),void 0,import.meta.url).then(e=>it(e.cmake))}}),Ee.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return Ie(()=>Promise.resolve().then(()=>cYt),void 0,import.meta.url).then(e=>it(e.coffeeScript))}}),Ee.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return Ie(()=>Promise.resolve().then(()=>pYt),void 0,import.meta.url).then(e=>it(e.commonLisp))}}),Ee.of({name:"Cypher",extensions:["cyp","cypher"],load(){return Ie(()=>Promise.resolve().then(()=>AYt),void 0,import.meta.url).then(e=>it(e.cypher))}}),Ee.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return Ie(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>it(e.cython))}}),Ee.of({name:"Crystal",extensions:["cr"],load(){return Ie(()=>Promise.resolve().then(()=>_Yt),void 0,import.meta.url).then(e=>it(e.crystal))}}),Ee.of({name:"D",extensions:["d"],load(){return Ie(()=>Promise.resolve().then(()=>LYt),void 0,import.meta.url).then(e=>it(e.d))}}),Ee.of({name:"Dart",extensions:["dart"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.dart))}}),Ee.of({name:"diff",extensions:["diff","patch"],load(){return Ie(()=>Promise.resolve().then(()=>jYt),void 0,import.meta.url).then(e=>it(e.diff))}}),Ee.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return Ie(()=>Promise.resolve().then(()=>eZt),void 0,import.meta.url).then(e=>it(e.dockerFile))}}),Ee.of({name:"DTD",extensions:["dtd"],load(){return Ie(()=>Promise.resolve().then(()=>rZt),void 0,import.meta.url).then(e=>it(e.dtd))}}),Ee.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return Ie(()=>Promise.resolve().then(()=>lZt),void 0,import.meta.url).then(e=>it(e.dylan))}}),Ee.of({name:"EBNF",load(){return Ie(()=>Promise.resolve().then(()=>cZt),void 0,import.meta.url).then(e=>it(e.ebnf))}}),Ee.of({name:"ECL",extensions:["ecl"],load(){return Ie(()=>Promise.resolve().then(()=>mZt),void 0,import.meta.url).then(e=>it(e.ecl))}}),Ee.of({name:"edn",extensions:["edn"],load(){return Ie(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ee.of({name:"Eiffel",extensions:["e"],load(){return Ie(()=>Promise.resolve().then(()=>SZt),void 0,import.meta.url).then(e=>it(e.eiffel))}}),Ee.of({name:"Elm",extensions:["elm"],load(){return Ie(()=>Promise.resolve().then(()=>XZt),void 0,import.meta.url).then(e=>it(e.elm))}}),Ee.of({name:"Erlang",extensions:["erl"],load(){return Ie(()=>Promise.resolve().then(()=>iHt),void 0,import.meta.url).then(e=>it(e.erlang))}}),Ee.of({name:"Esper",load(){return Ie(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>it(e.esper))}}),Ee.of({name:"Factor",extensions:["factor"],load(){return Ie(()=>Promise.resolve().then(()=>sHt),void 0,import.meta.url).then(e=>it(e.factor))}}),Ee.of({name:"FCL",load(){return Ie(()=>Promise.resolve().then(()=>uHt),void 0,import.meta.url).then(e=>it(e.fcl))}}),Ee.of({name:"Forth",extensions:["forth","fth","4th"],load(){return Ie(()=>Promise.resolve().then(()=>fHt),void 0,import.meta.url).then(e=>it(e.forth))}}),Ee.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return Ie(()=>Promise.resolve().then(()=>bHt),void 0,import.meta.url).then(e=>it(e.fortran))}}),Ee.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return Ie(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.fSharp))}}),Ee.of({name:"Gas",extensions:["s"],load(){return Ie(()=>Promise.resolve().then(()=>xHt),void 0,import.meta.url).then(e=>it(e.gas))}}),Ee.of({name:"Gherkin",extensions:["feature"],load(){return Ie(()=>Promise.resolve().then(()=>SHt),void 0,import.meta.url).then(e=>it(e.gherkin))}}),Ee.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return Ie(()=>Promise.resolve().then(()=>XHt),void 0,import.meta.url).then(e=>it(e.groovy))}}),Ee.of({name:"Haskell",extensions:["hs"],load(){return Ie(()=>Promise.resolve().then(()=>jHt),void 0,import.meta.url).then(e=>it(e.haskell))}}),Ee.of({name:"Haxe",extensions:["hx"],load(){return Ie(()=>Promise.resolve().then(()=>i0e),void 0,import.meta.url).then(e=>it(e.haxe))}}),Ee.of({name:"HXML",extensions:["hxml"],load(){return Ie(()=>Promise.resolve().then(()=>i0e),void 0,import.meta.url).then(e=>it(e.hxml))}}),Ee.of({name:"HTTP",load(){return Ie(()=>Promise.resolve().then(()=>uKt),void 0,import.meta.url).then(e=>it(e.http))}}),Ee.of({name:"IDL",extensions:["pro"],load(){return Ie(()=>Promise.resolve().then(()=>mKt),void 0,import.meta.url).then(e=>it(e.idl))}}),Ee.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return Ie(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>it(e.jsonld))}}),Ee.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return Ie(()=>Promise.resolve().then(()=>wKt),void 0,import.meta.url).then(e=>it(e.jinja2))}}),Ee.of({name:"Julia",extensions:["jl"],load(){return Ie(()=>Promise.resolve().then(()=>GKt),void 0,import.meta.url).then(e=>it(e.julia))}}),Ee.of({name:"Kotlin",extensions:["kt","kts"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.kotlin))}}),Ee.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return Ie(()=>Promise.resolve().then(()=>ZKt),void 0,import.meta.url).then(e=>it(e.liveScript))}}),Ee.of({name:"Lua",extensions:["lua"],load(){return Ie(()=>Promise.resolve().then(()=>iJt),void 0,import.meta.url).then(e=>it(e.lua))}}),Ee.of({name:"mIRC",extensions:["mrc"],load(){return Ie(()=>Promise.resolve().then(()=>_Jt),void 0,import.meta.url).then(e=>it(e.mirc))}}),Ee.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return Ie(()=>Promise.resolve().then(()=>hJt),void 0,import.meta.url).then(e=>it(e.mathematica))}}),Ee.of({name:"Modelica",extensions:["mo"],load(){return Ie(()=>Promise.resolve().then(()=>NJt),void 0,import.meta.url).then(e=>it(e.modelica))}}),Ee.of({name:"MUMPS",extensions:["mps"],load(){return Ie(()=>Promise.resolve().then(()=>JJt),void 0,import.meta.url).then(e=>it(e.mumps))}}),Ee.of({name:"Mbox",extensions:["mbox"],load(){return Ie(()=>Promise.resolve().then(()=>$Jt),void 0,import.meta.url).then(e=>it(e.mbox))}}),Ee.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return Ie(()=>Promise.resolve().then(()=>ien),void 0,import.meta.url).then(e=>it(e.nginx))}}),Ee.of({name:"NSIS",extensions:["nsh","nsi"],load(){return Ie(()=>Promise.resolve().then(()=>sen),void 0,import.meta.url).then(e=>it(e.nsis))}}),Ee.of({name:"NTriples",extensions:["nt","nq"],load(){return Ie(()=>Promise.resolve().then(()=>aen),void 0,import.meta.url).then(e=>it(e.ntriples))}}),Ee.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.objectiveC))}}),Ee.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.objectiveCpp))}}),Ee.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return Ie(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.oCaml))}}),Ee.of({name:"Octave",extensions:["m"],load(){return Ie(()=>Promise.resolve().then(()=>men),void 0,import.meta.url).then(e=>it(e.octave))}}),Ee.of({name:"Oz",extensions:["oz"],load(){return Ie(()=>Promise.resolve().then(()=>Cen),void 0,import.meta.url).then(e=>it(e.oz))}}),Ee.of({name:"Pascal",extensions:["p","pas"],load(){return Ie(()=>Promise.resolve().then(()=>Den),void 0,import.meta.url).then(e=>it(e.pascal))}}),Ee.of({name:"Perl",extensions:["pl","pm"],load(){return Ie(()=>Promise.resolve().then(()=>Ien),void 0,import.meta.url).then(e=>it(e.perl))}}),Ee.of({name:"Pig",extensions:["pig"],load(){return Ie(()=>Promise.resolve().then(()=>Men),void 0,import.meta.url).then(e=>it(e.pig))}}),Ee.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return Ie(()=>Promise.resolve().then(()=>ttn),void 0,import.meta.url).then(e=>it(e.powerShell))}}),Ee.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return Ie(()=>Promise.resolve().then(()=>ntn),void 0,import.meta.url).then(e=>it(e.properties))}}),Ee.of({name:"ProtoBuf",extensions:["proto"],load(){return Ie(()=>Promise.resolve().then(()=>otn),void 0,import.meta.url).then(e=>it(e.protobuf))}}),Ee.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return Ie(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>it(e.pug))}}),Ee.of({name:"Puppet",extensions:["pp"],load(){return Ie(()=>Promise.resolve().then(()=>utn),void 0,import.meta.url).then(e=>it(e.puppet))}}),Ee.of({name:"Q",extensions:["q"],load(){return Ie(()=>Promise.resolve().then(()=>vtn),void 0,import.meta.url).then(e=>it(e.q))}}),Ee.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return Ie(()=>Promise.resolve().then(()=>ktn),void 0,import.meta.url).then(e=>it(e.r))}}),Ee.of({name:"RPM Changes",load(){return Ie(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>it(e.rpmChanges))}}),Ee.of({name:"RPM Spec",extensions:["spec"],load(){return Ie(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>it(e.rpmSpec))}}),Ee.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return Ie(()=>Promise.resolve().then(()=>Xtn),void 0,import.meta.url).then(e=>it(e.ruby))}}),Ee.of({name:"SAS",extensions:["sas"],load(){return Ie(()=>Promise.resolve().then(()=>Ftn),void 0,import.meta.url).then(e=>it(e.sas))}}),Ee.of({name:"Scala",extensions:["scala"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.scala))}}),Ee.of({name:"Scheme",extensions:["scm","ss"],load(){return Ie(()=>Promise.resolve().then(()=>Htn),void 0,import.meta.url).then(e=>it(e.scheme))}}),Ee.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Ie(()=>Promise.resolve().then(()=>tnn),void 0,import.meta.url).then(e=>it(e.shell))}}),Ee.of({name:"Sieve",extensions:["siv","sieve"],load(){return Ie(()=>Promise.resolve().then(()=>ann),void 0,import.meta.url).then(e=>it(e.sieve))}}),Ee.of({name:"Smalltalk",extensions:["st"],load(){return Ie(()=>Promise.resolve().then(()=>cnn),void 0,import.meta.url).then(e=>it(e.smalltalk))}}),Ee.of({name:"Solr",load(){return Ie(()=>Promise.resolve().then(()=>gnn),void 0,import.meta.url).then(e=>it(e.solr))}}),Ee.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return Ie(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.sml))}}),Ee.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return Ie(()=>Promise.resolve().then(()=>Snn),void 0,import.meta.url).then(e=>it(e.sparql))}}),Ee.of({name:"Spreadsheet",alias:["excel","formula"],load(){return Ie(()=>Promise.resolve().then(()=>$nn),void 0,import.meta.url).then(e=>it(e.spreadsheet))}}),Ee.of({name:"Squirrel",extensions:["nut"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.squirrel))}}),Ee.of({name:"Stylus",extensions:["styl"],load(){return Ie(()=>Promise.resolve().then(()=>Gnn),void 0,import.meta.url).then(e=>it(e.stylus))}}),Ee.of({name:"Swift",extensions:["swift"],load(){return Ie(()=>Promise.resolve().then(()=>hrn),void 0,import.meta.url).then(e=>it(e.swift))}}),Ee.of({name:"sTeX",load(){return Ie(()=>Promise.resolve().then(()=>Y0e),void 0,import.meta.url).then(e=>it(e.stex))}}),Ee.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return Ie(()=>Promise.resolve().then(()=>Y0e),void 0,import.meta.url).then(e=>it(e.stex))}}),Ee.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return Ie(()=>Promise.resolve().then(()=>pve),void 0,import.meta.url).then(e=>it(e.verilog))}}),Ee.of({name:"Tcl",extensions:["tcl"],load(){return Ie(()=>Promise.resolve().then(()=>grn),void 0,import.meta.url).then(e=>it(e.tcl))}}),Ee.of({name:"Textile",extensions:["textile"],load(){return Ie(()=>Promise.resolve().then(()=>brn),void 0,import.meta.url).then(e=>it(e.textile))}}),Ee.of({name:"TiddlyWiki",load(){return Ie(()=>Promise.resolve().then(()=>jrn),void 0,import.meta.url).then(e=>it(e.tiddlyWiki))}}),Ee.of({name:"Tiki wiki",load(){return Ie(()=>Promise.resolve().then(()=>Brn),void 0,import.meta.url).then(e=>it(e.tiki))}}),Ee.of({name:"TOML",extensions:["toml"],load(){return Ie(()=>Promise.resolve().then(()=>Yrn),void 0,import.meta.url).then(e=>it(e.toml))}}),Ee.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return Ie(()=>Promise.resolve().then(()=>Krn),void 0,import.meta.url).then(e=>it(e.troff))}}),Ee.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return Ie(()=>Promise.resolve().then(()=>gin),void 0,import.meta.url).then(e=>it(e.ttcn))}}),Ee.of({name:"TTCN_CFG",extensions:["cfg"],load(){return Ie(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>it(e.ttcnCfg))}}),Ee.of({name:"Turtle",extensions:["ttl"],load(){return Ie(()=>Promise.resolve().then(()=>yin),void 0,import.meta.url).then(e=>it(e.turtle))}}),Ee.of({name:"Web IDL",extensions:["webidl"],load(){return Ie(()=>Promise.resolve().then(()=>hsn),void 0,import.meta.url).then(e=>it(e.webIDL))}}),Ee.of({name:"VB.NET",extensions:["vb"],load(){return Ie(()=>Promise.resolve().then(()=>Xin),void 0,import.meta.url).then(e=>it(e.vb))}}),Ee.of({name:"VBScript",extensions:["vbs"],load(){return Ie(()=>Promise.resolve().then(()=>Iin),void 0,import.meta.url).then(e=>it(e.vbScript))}}),Ee.of({name:"Velocity",extensions:["vtl"],load(){return Ie(()=>Promise.resolve().then(()=>Min),void 0,import.meta.url).then(e=>it(e.velocity))}}),Ee.of({name:"Verilog",extensions:["v"],load(){return Ie(()=>Promise.resolve().then(()=>pve),void 0,import.meta.url).then(e=>it(e.verilog))}}),Ee.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return Ie(()=>Promise.resolve().then(()=>Bin),void 0,import.meta.url).then(e=>it(e.vhdl))}}),Ee.of({name:"XQuery",extensions:["xy","xquery"],load(){return Ie(()=>Promise.resolve().then(()=>xsn),void 0,import.meta.url).then(e=>it(e.xQuery))}}),Ee.of({name:"Yacas",extensions:["ys"],load(){return Ie(()=>Promise.resolve().then(()=>Rsn),void 0,import.meta.url).then(e=>it(e.yacas))}}),Ee.of({name:"Z80",extensions:["z80"],load(){return Ie(()=>Promise.resolve().then(()=>Nsn),void 0,import.meta.url).then(e=>it(e.z80))}}),Ee.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return Ie(()=>Promise.resolve().then(()=>v7),void 0,import.meta.url).then(e=>it(e.mscgen))}}),Ee.of({name:"Xù",extensions:["xu"],load(){return Ie(()=>Promise.resolve().then(()=>v7),void 0,import.meta.url).then(e=>it(e.xu))}}),Ee.of({name:"MsGenny",extensions:["msgenny"],load(){return Ie(()=>Promise.resolve().then(()=>v7),void 0,import.meta.url).then(e=>it(e.msgenny))}}),Ee.of({name:"Vue",extensions:["vue"],load(){return Ie(()=>Promise.resolve().then(()=>VWt),void 0,import.meta.url).then(e=>e.vue())}}),Ee.of({name:"Angular Template",load(){return Ie(()=>Promise.resolve().then(()=>hGt),void 0,import.meta.url).then(e=>e.angular())}})];class vH{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=Xr(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),s=i.search(WAe(t,!1));return s<0?null:{from:r+s,to:this.pos,text:i.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function WOe(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function SIt(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let s=1;s<i.length;s++)n[i[s]]=!0}let r=WOe(t)+WOe(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function oP(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:SIt(t);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:t,validFor:n}:null}}function tX(e,t){return n=>{for(let r=Xr(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class GOe{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Jm(e){return e.selection.main.from}function WAe(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",s=r[r.length-1]!="$";return!i&&!s?e:new RegExp(`${i?"^":""}(?:${r})${s?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const yH=Gh.define();function $It(e,t,n,r){let{main:i}=e.selection,s=n-i.from,a=r-i.from;return Object.assign(Object.assign({},e.changeByRange(o=>{if(o!=i&&n!=r&&e.sliceDoc(o.from+s,o.from+a)!=e.sliceDoc(n,r))return{range:o};let l=e.toText(t);return{changes:{from:o.from+s,to:r==i.from?o.to:o.from+a,insert:l},range:Ze.cursor(o.from+s+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const VOe=new WeakMap;function kIt(e){if(!Array.isArray(e))return e;let t=VOe.get(e);return t||VOe.set(e,t=oP(e)),t}const N5=Mn.define(),MT=Mn.define();class TIt{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=yl(t,n),i=nh(r);this.chars.push(r);let s=t.slice(n,n+i),a=s.toUpperCase();this.folded.push(yl(a==s?s.toLowerCase():a,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:s,byWord:a}=this;if(n.length==1){let y=yl(t,0),b=nh(y),T=b==t.length?0:-100;if(y!=n[0])if(y==r[0])T+=-200;else return null;return this.ret(T,[0,b])}let o=t.indexOf(this.pattern);if(o==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(o<0){for(let y=0,b=Math.min(t.length,200);y<b&&c<l;){let T=yl(t,y);(T==n[c]||T==r[c])&&(i[c++]=y),y+=nh(T)}if(c<l)return null}let u=0,d=0,h=!1,f=0,O=-1,g=-1,m=/[a-z]/.test(t),v=!0;for(let y=0,b=Math.min(t.length,200),T=0;y<b&&d<l;){let x=yl(t,y);o<0&&(u<l&&x==n[u]&&(s[u++]=y),f<l&&(x==n[f]||x==r[f]?(f==0&&(O=y),g=y+1,f++):f=0));let S,k=x<255?x>=48&&x<=57||x>=97&&x<=122?2:x>=65&&x<=90?1:0:(S=YZ(x))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!y||k==1&&m||T==0&&k!=0)&&(n[d]==x||r[d]==x&&(h=!0)?a[d++]=y:a.length&&(v=!1)),T=k,y+=nh(x)}return d==l&&a[0]==0&&v?this.result(-100+(h?-200:0),a,t):f==l&&O==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):f==l?this.ret(-900-t.length,[O,g]):d==l?this.result(-100+(h?-200:0)+-700+(v?0:-1100),a,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],s=0;for(let a of n){let o=a+(this.astral?nh(yl(r,a)):1);s&&i[s-1]==a?i[s-1]=o:(i[s++]=a,i[s++]=o)}return this.ret(t-r.length,i)}}class _It{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const Ca=Yt.define({combine(e){return Vh(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:PIt,filterStrict:!1,compareCompletions:(t,n)=>t.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>BOe(t(r),n(r)),optionClass:(t,n)=>r=>BOe(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function BOe(e,t){return e?t?e+" "+t:e:t}function PIt(e,t,n,r,i,s){let a=e.textDirection==Li.RTL,o=a,l=!1,c="top",u,d,h=t.left-i.left,f=i.right-t.right,O=r.right-r.left,g=r.bottom-r.top;if(o&&h<Math.min(O,f)?o=!1:!o&&f<Math.min(O,h)&&(o=!0),O<=(o?h:f))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,d=Math.min(400,o?h:f);else{l=!0,d=Math.min(400,(a?t.right:i.right-t.left)-30);let y=i.bottom-t.bottom;y>=g||y>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let m=(t.bottom-t.top)/s.offsetHeight,v=(t.right-t.left)/s.offsetWidth;return{style:`${c}: ${u/m}px; max-width: ${d/v}px`,class:"cm-completionInfo-"+(l?a?"left-narrow":"right-narrow":o?"left":"right")}}function CIt(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,s){let a=document.createElement("span");a.className="cm-completionLabel";let o=n.displayLabel||n.label,l=0;for(let c=0;c<s.length;){let u=s[c++],d=s[c++];u>l&&a.appendChild(document.createTextNode(o.slice(l,u)));let h=a.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(o.slice(u,d))),h.className="cm-completionMatchedText",l=d}return l<o.length&&a.appendChild(document.createTextNode(o.slice(l))),a},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function f8(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class QIt{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:s,selected:a}=i.open,o=t.state.facet(Ca);this.optionContent=CIt(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=f8(s.length,a,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=t.state.field(n).open;for(let u=l.target,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]<c.length){this.applyCompletion(t,c[+d[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(Ca).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:MT.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:s,selected:a,disabled:o}=r.open;(!i.open||i.open.options!=s)&&(this.range=f8(s.length,a,t.state.facet(Ca).maxRenderedOptions),this.showOptions(s,r.id)),this.updateSel(),o!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=f8(n.options.length,n.selected,this.view.state.facet(Ca).maxRenderedOptions),this.showOptions(n.options,t.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let s=typeof i=="string"?document.createTextNode(i):i(r);if(!s)return;"then"in s?s.then(a=>{a&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(a,r)}).catch(a=>_l(this.view.state,a,"completion info")):this.addInfoPane(s,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:s}=t;r.appendChild(i),this.infoDestroy=s||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&RIt(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),s=this.space;if(!s){let a=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return i.top>Math.min(s.bottom,n.bottom)-10||i.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(Ca).positionInfo(this.view,n,i,r,s,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",a=>{a.target==i&&a.preventDefault()});let s=null;for(let a=r.from;a<r.to;a++){let{completion:o,match:l}=t[a],{section:c}=o;if(c){let h=typeof c=="string"?c:c.name;if(h!=s&&(a>r.from||r.from==0))if(s=h,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let f=i.appendChild(document.createElement("completion-section"));f.textContent=h}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+a,u.setAttribute("role","option");let d=this.optionClass(o);d&&(u.className=d);for(let h of this.optionContent){let f=h(o,this.view.state,this.view,l);f&&u.appendChild(f)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function EIt(e,t){return n=>new QIt(n,e,t)}function RIt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function YOe(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function AIt(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let d=typeof u=="string"?u:u.name;r.some(h=>h.name==d)||r.push(typeof u=="string"?{name:d}:u)}},s=t.facet(Ca);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let d of c.result.options)i(new GOe(d,c.source,u?u(d):[],1e9-n.length));else{let d=t.sliceDoc(c.from,c.to),h,f=s.filterStrict?new _It(d):new TIt(d);for(let O of c.result.options)if(h=f.match(O.label)){let g=O.displayLabel?u?u(O,h.matched):[]:h.matched;i(new GOe(O,c.source,g,h.score+(O.boost||0)))}}}if(r){let c=Object.create(null),u=0,d=(h,f)=>{var O,g;return((O=h.rank)!==null&&O!==void 0?O:1e9)-((g=f.rank)!==null&&g!==void 0?g:1e9)||(h.name<f.name?-1:1)};for(let h of r.sort(d))u-=1e5,c[h.name]=u;for(let h of n){let{section:f}=h.completion;f&&(h.score+=c[typeof f=="string"?f:f.name])}}let a=[],o=null,l=s.compareCompletions;for(let c of n.sort((u,d)=>d.score-u.score||l(u.completion,d.completion))){let u=c.completion;!o||o.label!=u.label||o.detail!=u.detail||o.type!=null&&u.type!=null&&o.type!=u.type||o.apply!=u.apply||o.boost!=u.boost?a.push(c):YOe(c.completion)>YOe(o)&&(a[a.length-1]=c),o=c.completion}return a}class Hy{constructor(t,n,r,i,s,a){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=s,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new Hy(this.options,ZOe(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,s,a){if(i&&!a&&t.some(c=>c.isPending))return i.setDisabled();let o=AIt(t,n);if(!o.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ca).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<o.length;u++)if(o[u].completion==c){l=u;break}}return new Hy(o,ZOe(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:MIt,above:s.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Hy(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new Hy(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class F5{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new F5(NIt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ca),s=(r.override||n.languageDataAt("autocomplete",Jm(n)).map(kIt)).map(l=>(this.active.find(u=>u.source==l)||new ru(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));s.length==this.active.length&&s.every((l,c)=>l==this.active[c])&&(s=this.active);let a=this.open,o=t.effects.some(l=>l.is(bH));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||s.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!XIt(s,this.active)||o?a=Hy.build(s,n,this.id,a,r,o):a&&a.disabled&&!s.some(l=>l.isPending)&&(a=null),!a&&s.every(l=>!l.isPending)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new ru(l.source,0):l));for(let l of t.effects)l.is(VAe)&&(a=a&&a.setSelected(l.value,this.id));return s==this.active&&a==this.open?this:new F5(s,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?DIt:IIt}}function XIt(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,s=r==t.length;if(i||s)return i==s;if(e[n++].result!=t[r++].result)return!1}}const DIt={"aria-autocomplete":"list"},IIt={};function ZOe(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const NIt=[];function GAe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(yH);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class ru{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=GAe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ru(i.source,0)),r&4&&i.state==0&&(i=new ru(this.source,1)),i=i.updateFor(t,r);for(let s of t.effects)if(s.is(N5))i=new ru(i.source,1,s.value);else if(s.is(MT))i=new ru(i.source,0);else if(s.is(bH))for(let a of s.value)a.source==i.source&&(i=a);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Jm(t.state))}}class Sb extends ru{constructor(t,n,r,i,s,a){super(t,3,n),this.limit=r,this.result=i,this.from=s,this.to=a}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let s=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Jm(t.state);if(o>a||!i||n&2&&(Jm(t.startState)==this.from||o<this.limit))return new ru(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return FIt(i.validFor,t.state,s,a)?new Sb(this.source,this.explicit,l,i,s,a):i.update&&(i=i.update(i,s,a,new vH(t.state,o,!1)))?new Sb(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Jm(t.state)):new ru(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Sb(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ru(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function FIt(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):WAe(e,!0).test(i)}const bH=Mn.define({map(e,t){return e.map(n=>n.map(t))}}),VAe=Mn.define(),wl=Ia.define({create(){return F5.start()},update(e,t){return e.update(t)},provide:e=>[uH.from(e,t=>t.tooltip),Ct.contentAttributes.from(e,t=>t.attrs)]});function wH(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(wl).active.find(i=>i.source==t.source);return r instanceof Sb?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},$It(e.state,n,r.from,r.to)),{annotations:yH.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const MIt=EIt(wl,wH);function tC(e,t="option"){return n=>{let r=n.state.field(wl,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ca).interactionDelay)return!1;let i=1,s;t=="page"&&(s=vAe(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:a}=r.open.options,o=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:a-1;return o<0?o=t=="page"?0:a-1:o>=a&&(o=t=="page"?a-1:0),n.dispatch({effects:VAe.of(o)}),!0}}const LIt=e=>{let t=e.state.field(wl,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ca).interactionDelay?!1:wH(e,t.open.options[t.open.selected])},HOe=e=>e.state.field(wl,!1)?(e.dispatch({effects:N5.of(!0)}),!0):!1,jIt=e=>{let t=e.state.field(wl,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:MT.of(null)}),!0)};class qIt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const zIt=50,UIt=1e3,WIt=us.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(wl).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(wl),n=e.state.facet(Ca);if(!e.selectionSet&&!e.docChanged&&e.startState.field(wl)==t)return;let r=e.transactions.some(s=>{let a=GAe(s,n);return a&8||(s.selection||s.docChanged)&&!(a&3)});for(let s=0;s<this.running.length;s++){let a=this.running[s];if(r||a.context.abortOnDocChange&&e.docChanged||a.updates.length+e.transactions.length>zIt&&Date.now()-a.time>UIt){for(let o of a.context.abortListeners)try{o()}catch(l){_l(this.view.state,l)}a.context.abortListeners=null,this.running.splice(s--,1)}else a.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(s=>s.effects.some(a=>a.is(N5)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(s=>s.isPending&&!this.running.some(a=>a.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of e.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(wl);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ca).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Jm(t),r=new vH(t,n,e.explicit,this.view),i=new qIt(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:MT.of(null)}),_l(this.view.state,s)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ca).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ca),r=this.view.state.field(wl);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let o=Jm(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(o,s.done.from+(s.active.explicit?0:1)),c=new Sb(s.active.source,s.active.explicit,l,s.done,s.done.from,(e=s.done.to)!==null&&e!==void 0?e:o);for(let u of s.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let a=r.active.find(o=>o.source==s.active.source);if(a&&a.isPending)if(s.done==null){let o=new ru(s.active.source,0);for(let l of s.updates)o=o.update(l,n);o.isPending||t.push(o)}else this.startQuery(a)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:bH.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(wl,!1);if(t&&t.tooltip&&this.view.state.facet(Ca).closeOnBlur){let n=t.open&&vAe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:MT.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:N5.of(!1)}),20),this.composing=0}}}),GIt=typeof navigator=="object"&&/Win/.test(navigator.platform),VIt=CO.highest(Ct.domEventHandlers({keydown(e,t){let n=t.state.field(wl,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(GIt&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(a=>a.source==r.source),s=r.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&wH(t,r),!1}})),BAe=Ct.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class BIt{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class xH{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ya.TrackDel),r=t.mapPos(this.to,1,Ya.TrackDel);return n==null||r==null?null:new xH(this.field,n,r)}}class SH{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],s=t.doc.lineAt(n),a=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(r.length){let c=a,u=/^\t*/.exec(l)[0].length;for(let d=0;d<u;d++)c+=t.facet(Lw);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let o=this.fieldPositions.map(l=>new xH(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:o}}static parse(t){let n=[],r=[],i=[],s;for(let a of t.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(a);){let o=s[1]?+s[1]:null,l=s[2]||s[3]||"",c=-1,u=l.replace(/\\[{}]/g,d=>d[1]);for(let d=0;d<n.length;d++)(o!=null?n[d].seq==o:u&&n[d].name==u)&&(c=d);if(c<0){let d=0;for(;d<n.length&&(o==null||n[d].seq!=null&&n[d].seq<o);)d++;n.splice(d,0,{seq:o,name:u}),c=d;for(let h of i)h.field>=c&&h.field++}i.push(new BIt(c,r.length,s.index,s.index+u.length)),a=a.slice(0,s.index)+l+a.slice(s.index+s[0].length)}a=a.replace(/\\([{}])/g,(o,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(a)}return new SH(r,i)}}let YIt=Bt.widget({widget:new class extends xd{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),ZIt=Bt.mark({class:"cm-snippetField"});class qw{constructor(t,n){this.ranges=t,this.active=n,this.deco=Bt.set(t.map(r=>(r.from==r.to?YIt:ZIt).range(r.from,r.to)))}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new qw(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const lP=Mn.define({map(e,t){return e&&e.map(t)}}),HIt=Mn.define(),LT=Ia.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(lP))return n.value;if(n.is(HIt)&&e)return new qw(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>Ct.decorations.from(e,t=>t?t.deco:Bt.none)});function $H(e,t){return Ze.create(e.filter(n=>n.field==t).map(n=>Ze.range(n.from,n.to)))}function KIt(e){let t=SH.parse(e);return(n,r,i,s)=>{let{text:a,ranges:o}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:s==l.from?l.to:s,insert:Fr.of(a)},scrollIntoView:!0,annotations:r?[yH.of(r),ea.userEvent.of("input.complete")]:void 0};if(o.length&&(c.selection=$H(o,0)),o.some(u=>u.field>0)){let u=new qw(o,0),d=c.effects=[lP.of(u)];n.state.field(LT,!1)===void 0&&d.push(Mn.appendConfig.of([LT,rNt,iNt,BAe]))}n.dispatch(n.state.update(c))}}function YAe(e){return({state:t,dispatch:n})=>{let r=t.field(LT,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,s=e>0&&!r.ranges.some(a=>a.field==i+e);return n(t.update({selection:$H(r.ranges,i),effects:lP.of(s?null:new qw(r.ranges,i)),scrollIntoView:!0})),!0}}const JIt=({state:e,dispatch:t})=>e.field(LT,!1)?(t(e.update({effects:lP.of(null)})),!0):!1,eNt=YAe(1),tNt=YAe(-1),nNt=[{key:"Tab",run:eNt,shift:tNt},{key:"Escape",run:JIt}],KOe=Yt.define({combine(e){return e.length?e[0]:nNt}}),rNt=CO.highest(xv.compute([KOe],e=>e.facet(KOe)));function Di(e,t){return Object.assign(Object.assign({},t),{apply:KIt(e)})}const iNt=Ct.domEventHandlers({mousedown(e,t){let n=t.state.field(LT,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(s=>s.from<=r&&s.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:$H(n.ranges,i.field),effects:lP.of(n.ranges.some(s=>s.field>i.field)?new qw(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),jT={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},jm=Mn.define({map(e,t){let n=t.mapPos(e,-1,Ya.TrackAfter);return n??void 0}}),kH=new class extends D0{};kH.startSide=1;kH.endSide=-1;const ZAe=Ia.define({create(){return Cr.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(jm)&&(e=e.update({add:[kH.range(n.value,n.value+1)]}));return e}});function sNt(){return[oNt,ZAe]}const O8="()[]{}<>«»»«[]{}";function HAe(e){for(let t=0;t<O8.length;t+=2)if(O8.charCodeAt(t)==e)return O8.charAt(t+1);return YZ(e<128?e:e+1)}function KAe(e,t){return e.languageDataAt("closeBrackets",t)[0]||jT}const aNt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),oNt=Ct.inputHandler.of((e,t,n,r)=>{if((aNt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&nh(yl(r,0))==1||t!=i.from||n!=i.to)return!1;let s=uNt(e.state,r);return s?(e.dispatch(s),!0):!1}),lNt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=KAe(e,e.selection.main.head).brackets||jT.brackets,i=null,s=e.changeByRange(a=>{if(a.empty){let o=dNt(e.doc,a.head);for(let l of r)if(l==o&&nX(e.doc,a.head)==HAe(yl(l,0)))return{changes:{from:a.head-l.length,to:a.head+l.length},range:Ze.cursor(a.head-l.length)}}return{range:i=a}});return i||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},cNt=[{key:"Backspace",run:lNt}];function uNt(e,t){let n=KAe(e,e.selection.main.head),r=n.brackets||jT.brackets;for(let i of r){let s=HAe(yl(i,0));if(t==i)return s==i?ONt(e,i,r.indexOf(i+i+i)>-1,n):hNt(e,i,s,n.before||jT.before);if(t==s&&JAe(e,e.selection.main.from))return fNt(e,i,s)}return null}function JAe(e,t){let n=!1;return e.field(ZAe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function nX(e,t){let n=e.sliceString(t,t+2);return n.slice(0,nh(yl(n,0)))}function dNt(e,t){let n=e.sliceString(t-2,t);return nh(yl(n,0))==n.length?n:n.slice(1)}function hNt(e,t,n,r){let i=null,s=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:jm.of(a.to+t.length),range:Ze.range(a.anchor+t.length,a.head+t.length)};let o=nX(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:jm.of(a.head+t.length),range:Ze.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function fNt(e,t,n){let r=null,i=e.changeByRange(s=>s.empty&&nX(e.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:Ze.cursor(s.head+n.length)}:r={range:s});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function ONt(e,t,n,r){let i=r.stringPrefixes||jT.stringPrefixes,s=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:jm.of(o.to+t.length),range:Ze.range(o.anchor+t.length,o.head+t.length)};let l=o.head,c=nX(e.doc,l),u;if(c==t){if(JOe(e,l))return{changes:{insert:t+t,from:l},effects:jm.of(l+t.length),range:Ze.cursor(l+t.length)};if(JAe(e,l)){let h=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+h.length,insert:h},range:Ze.cursor(l+h.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=epe(e,l-2*t.length,i))>-1&&JOe(e,u))return{changes:{insert:t+t+t+t,from:l},effects:jm.of(l+t.length),range:Ze.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Zi.Word&&epe(e,l,i)>-1&&!pNt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:jm.of(l+t.length),range:Ze.cursor(l+t.length)}}return{range:s=o}});return s?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function JOe(e,t){let n=Xr(e).resolveInner(t+1);return n.parent&&n.from==t}function pNt(e,t,n,r){let i=Xr(e).resolveInner(t,-1),s=r.reduce((a,o)=>Math.max(a,o.length),0);for(let a=0;a<5;a++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),l=o.indexOf(n);if(!l||l>-1&&r.indexOf(o.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(e.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function epe(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Zi.Word)return t;for(let i of n){let s=t-i.length;if(e.sliceDoc(s,t)==i&&r(e.sliceDoc(s-1,s))!=Zi.Word)return s}return-1}function gNt(e={}){return[VIt,wl,Ca.of(e),WIt,mNt,BAe]}const e3e=[{key:"Ctrl-Space",run:HOe},{mac:"Alt-`",run:HOe},{key:"Escape",run:jIt},{key:"ArrowDown",run:tC(!0)},{key:"ArrowUp",run:tC(!1)},{key:"PageDown",run:tC(!0,"page")},{key:"PageUp",run:tC(!1,"page")},{key:"Enter",run:LIt}],mNt=CO.highest(xv.computeN([Ca],e=>e.facet(Ca).defaultKeymap?[e3e]:[]));class M5{static create(t,n,r,i,s){let a=i+(i<<8)+t+(n<<4)|0;return new M5(t,n,r,a,s,[],[])}constructor(t,n,r,i,s,a,o){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=s,this.children=a,this.positions=o,this.hashProp=[[In.contextHash,i]]}addChild(t,n){t.prop(In.contextHash)!=this.hash&&(t=new vr(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new vr(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,s,a)=>new vr(na.none,i,s,a,this.hashProp)})}}var $t;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})($t||($t={}));class vNt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}class yNt{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return g$(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,r=0){for(let i=n;i<t;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(t){let n=0;for(let r=0;n<this.text.length&&r<t;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let t="";for(let n=0;n<this.basePos;n++)t+=" ";return t+this.text.slice(this.basePos)}}function tpe(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==$t.OrderedList?PH:_H)(n,t,!1);return r>0&&(e.type!=$t.BulletList||TH(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const t3e={[$t.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(xr($t.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Tu(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[$t.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[$t.OrderedList]:tpe,[$t.BulletList]:tpe,[$t.Document](){return!0}};function Tu(e){return e==32||e==9||e==10||e==13}function g$(e,t=0){for(;t<e.length&&Tu(e.charCodeAt(t));)t++;return t}function npe(e,t,n){for(;t>n&&Tu(e.charCodeAt(t-1));)t--;return t}function n3e(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function r3e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function TH(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let s=e.text.charCodeAt(i);if(s==e.next)r++;else if(!Tu(s))return-1}return n&&e.next==45&&a3e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(u3e.SetextHeading)>-1||r<3?-1:1}function i3e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function _H(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Tu(e.text.charCodeAt(e.pos+1)))&&(!n||i3e(t,$t.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function PH(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!Tu(e.text.charCodeAt(r+1))||n&&!i3e(t,$t.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function s3e(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function a3e(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&Tu(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const sW=/^[ \t]*$/,o3e=/-->/,l3e=/\?>/,aW=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,o3e],[/^\s*<\?/,l3e],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,sW],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,sW]];function c3e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,s=aW.length-(n?1:0);i<s;i++)if(aW[i][0].test(r))return i;return-1}function rpe(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function lm(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==$t.CodeText?e[r].to=n:e.push(xr($t.CodeText,t,n))}const nC={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,s=e.lineStart+t.text.length,a=[],o=[];for(lm(a,i,s);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){lm(o,e.lineStart-1,e.lineStart);for(let l of t.markers)o.push(l)}else{if(t.indent<n)break;{if(o.length){for(let c of o)c.type==$t.CodeText?lm(a,c.from,c.to):a.push(c);o=[]}lm(a,e.lineStart-1,e.lineStart);for(let c of t.markers)a.push(c);s=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<s&&lm(a,l,s)}}return o.length&&(o=o.filter(l=>l.type!=$t.CodeText),o.length&&(t.markers=o.concat(t.markers))),e.addNode(e.buffer.writeElements(a,-i).finish($t.CodeBlock,s-i),i),!0},FencedCode(e,t){let n=n3e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,s=n-t.pos,a=t.skipSpace(n),o=npe(t.text,t.text.length,a),l=[xr($t.CodeMark,r,r+s)];a<o&&l.push(xr($t.CodeInfo,e.lineStart+a,e.lineStart+o));for(let c=!0;e.nextLine()&&t.depth>=e.stack.length;c=!1){let u=t.pos;if(t.indent-t.baseIndent<4)for(;u<t.text.length&&t.text.charCodeAt(u)==i;)u++;if(u-t.pos>=s&&t.skipSpace(u)==t.text.length){for(let d of t.markers)l.push(d);l.push(xr($t.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||lm(l,e.lineStart-1,e.lineStart);for(let f of t.markers)l.push(f);let d=e.lineStart+t.basePos,h=e.lineStart+t.text.length;d<h&&lm(l,d,h)}}return e.addNode(e.buffer.writeElements(l,-r).finish($t.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=r3e(t);return n<0?!1:(e.startContext($t.Blockquote,t.pos),e.addNode($t.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(TH(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode($t.HorizontalRule,n),!0},BulletList(e,t){let n=_H(t,e,!1);if(n<0)return!1;e.block.type!=$t.BulletList&&e.startContext($t.BulletList,t.basePos,t.next);let r=rpe(t,t.pos+1);return e.startContext($t.ListItem,t.basePos,r-t.baseIndent),e.addNode($t.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=PH(t,e,!1);if(n<0)return!1;e.block.type!=$t.OrderedList&&e.startContext($t.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=rpe(t,t.pos+n);return e.startContext($t.ListItem,t.basePos,r-t.baseIndent),e.addNode($t.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=s3e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,s=npe(t.text,t.text.length,r),a=s;for(;a>r&&t.text.charCodeAt(a-1)==t.next;)a--;(a==s||a==r||!Tu(t.text.charCodeAt(a-1)))&&(a=t.text.length);let o=e.buffer.write($t.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,a),i+n+1),-i);a<t.text.length&&o.write($t.HeaderMark,a-r,s-r);let l=o.finish($t.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=c3e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=aW[n][1],s=[],a=i!=sW;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){a=!1;break}for(let c of t.markers)s.push(c)}a&&e.nextLine();let o=i==o3e?$t.CommentBlock:i==l3e?$t.ProcessingInstructionBlock:$t.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(s,-r).finish(o,l-r),r),!0},SetextHeading:void 0};class bNt{constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,n,r){if(this.stage==-1)return!1;let i=r.content+`
1160
+ `);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let s=this.ranges[i].to;if(s>=r||(n=n.slice(0,s-(r-n.length)),i++,i==this.ranges.length))break;let a=this.ranges[i].from,o=this.lineAfter(a);n+=o,r=a+o.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,s=t+n;if(r>0?i>s:i>=s)break;let a=this.ranges[++this.rangeIndex].from;n+=a-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let s=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let o=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,s+=this.chunk.length-o}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&s==4&&a>=0&&this.chunk[a]==t&&this.chunk[a+2]==n?this.chunk[a+2]=r:this.chunk.push(t,n,r,s),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:s}=this.lang,a=new MAe(n,t?t.state.tabSize:4,t?L0(t.state):2);if(a.eol())s.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let o=jAe(s.token,a,this.state);if(o&&(i=this.emitToken(this.lang.tokenTable.resolve(o),this.parsedPos+a.start,this.parsedPos+a.pos,i)),a.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=vr.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:yIt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new vr(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new vr(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function jAe(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let i=e(t,n);if(t.pos>t.start)return i}throw new Error("Stream parser failed to advance stream.")}const mH=Object.create(null),FT=[na.none],yIt=new Mw(FT),zOe=[],UOe=Object.create(null),qAe=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])qAe[e]=UAe(mH,t);class zAe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),qAe)}resolve(t){return t?this.table[t]||(this.table[t]=UAe(this.extra,t)):0}}const bIt=new zAe(mH);function h8(e,t){zOe.indexOf(e)>-1||(zOe.push(e),console.warn(t))}function UAe(e,t){let n=[];for(let o of t.split(" ")){let l=[];for(let c of o.split(".")){let u=e[c]||R[c];u?typeof u=="function"?l.length?l=l.map(u):h8(c,`Modifier ${c} used at start of tag`):l.length?h8(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:h8(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(o=>o.id),s=UOe[i];if(s)return s.id;let a=UOe[i]=na.define({id:FT.length,name:r,props:[Lr({[r]:n})]});return FT.push(a),a.id}function wIt(e,t){let n=na.define({id:FT.length,name:"Document",props:[Ap.add(()=>e),ds.add(()=>r=>t.getIndent(r))],top:!0});return FT.push(n),n}Li.RTL,Li.LTR;function it(e){return new kr(ut.define(e))}function HO(e){return Ie(()=>Promise.resolve().then(()=>Vqt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const xIt=[Ee.of({name:"C",extensions:["c","h","ino"],load(){return Ie(()=>Promise.resolve().then(()=>Dge),void 0,import.meta.url).then(e=>e.cpp())}}),Ee.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return Ie(()=>Promise.resolve().then(()=>Dge),void 0,import.meta.url).then(e=>e.cpp())}}),Ee.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return HO("Cassandra")}}),Ee.of({name:"CSS",extensions:["css"],load(){return Ie(()=>Promise.resolve().then(()=>lMt),void 0,import.meta.url).then(e=>e.css())}}),Ee.of({name:"Go",extensions:["go"],load(){return Ie(()=>import("./index-CqIP2mt3.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>e.go())}}),Ee.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return Ie(()=>Promise.resolve().then(()=>JMt),void 0,import.meta.url).then(e=>e.html())}}),Ee.of({name:"Java",extensions:["java"],load(){return Ie(()=>Promise.resolve().then(()=>Hqt),void 0,import.meta.url).then(e=>e.java())}}),Ee.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Ie(()=>Promise.resolve().then(()=>iC),void 0,import.meta.url).then(e=>e.javascript())}}),Ee.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Ie(()=>Promise.resolve().then(()=>i7t),void 0,import.meta.url).then(e=>e.json())}}),Ee.of({name:"JSX",extensions:["jsx"],load(){return Ie(()=>Promise.resolve().then(()=>iC),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Ee.of({name:"LESS",extensions:["less"],load(){return Ie(()=>Promise.resolve().then(()=>b8t),void 0,import.meta.url).then(e=>e.less())}}),Ee.of({name:"Liquid",extensions:["liquid"],load(){return Ie(()=>Promise.resolve().then(()=>IWt),void 0,import.meta.url).then(e=>e.liquid())}}),Ee.of({name:"MariaDB SQL",load(){return HO("MariaSQL")}}),Ee.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Ie(()=>Promise.resolve().then(()=>c8t),void 0,import.meta.url).then(e=>e.markdown())}}),Ee.of({name:"MS SQL",load(){return HO("MSSQL")}}),Ee.of({name:"MySQL",load(){return HO("MySQL")}}),Ee.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return Ie(()=>Promise.resolve().then(()=>fWt),void 0,import.meta.url).then(e=>e.php())}}),Ee.of({name:"PLSQL",extensions:["pls"],load(){return HO("PLSQL")}}),Ee.of({name:"PostgreSQL",load(){return HO("PostgreSQL")}}),Ee.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return Ie(()=>Promise.resolve().then(()=>Ijt),void 0,import.meta.url).then(e=>e.python())}}),Ee.of({name:"Rust",extensions:["rs"],load(){return Ie(()=>Promise.resolve().then(()=>mzt),void 0,import.meta.url).then(e=>e.rust())}}),Ee.of({name:"Sass",extensions:["sass"],load(){return Ie(()=>Promise.resolve().then(()=>Zpe),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),Ee.of({name:"SCSS",extensions:["scss"],load(){return Ie(()=>Promise.resolve().then(()=>Zpe),void 0,import.meta.url).then(e=>e.sass())}}),Ee.of({name:"SQL",extensions:["sql"],load(){return HO("StandardSQL")}}),Ee.of({name:"SQLite",load(){return HO("SQLite")}}),Ee.of({name:"TSX",extensions:["tsx"],load(){return Ie(()=>Promise.resolve().then(()=>iC),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Ee.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Ie(()=>Promise.resolve().then(()=>iC),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Ee.of({name:"WebAssembly",extensions:["wat","wast"],load(){return Ie(()=>Promise.resolve().then(()=>MWt),void 0,import.meta.url).then(e=>e.wast())}}),Ee.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return Ie(()=>Promise.resolve().then(()=>iqt),void 0,import.meta.url).then(e=>e.xml())}}),Ee.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return Ie(()=>import("./index-DXx2j7ov.js"),__vite__mapDeps([5,1,2]),import.meta.url).then(e=>e.yaml())}}),Ee.of({name:"APL",extensions:["dyalog","apl"],load(){return Ie(()=>Promise.resolve().then(()=>OBt),void 0,import.meta.url).then(e=>it(e.apl))}}),Ee.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return Ie(()=>Promise.resolve().then(()=>pBt),void 0,import.meta.url).then(e=>it(e.asciiArmor))}}),Ee.of({name:"ASN.1",extensions:["asn","asn1"],load(){return Ie(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>it(e.asn1({})))}}),Ee.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return Ie(()=>Promise.resolve().then(()=>bBt),void 0,import.meta.url).then(e=>it(e.asterisk))}}),Ee.of({name:"Brainfuck",extensions:["b","bf"],load(){return Ie(()=>Promise.resolve().then(()=>xBt),void 0,import.meta.url).then(e=>it(e.brainfuck))}}),Ee.of({name:"Cobol",extensions:["cob","cpy"],load(){return Ie(()=>Promise.resolve().then(()=>ZBt),void 0,import.meta.url).then(e=>it(e.cobol))}}),Ee.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.csharp))}}),Ee.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return Ie(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ee.of({name:"ClojureScript",extensions:["cljs"],load(){return Ie(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ee.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return Ie(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>it(e.gss))}}),Ee.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return Ie(()=>Promise.resolve().then(()=>jBt),void 0,import.meta.url).then(e=>it(e.cmake))}}),Ee.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return Ie(()=>Promise.resolve().then(()=>cYt),void 0,import.meta.url).then(e=>it(e.coffeeScript))}}),Ee.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return Ie(()=>Promise.resolve().then(()=>pYt),void 0,import.meta.url).then(e=>it(e.commonLisp))}}),Ee.of({name:"Cypher",extensions:["cyp","cypher"],load(){return Ie(()=>Promise.resolve().then(()=>AYt),void 0,import.meta.url).then(e=>it(e.cypher))}}),Ee.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return Ie(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>it(e.cython))}}),Ee.of({name:"Crystal",extensions:["cr"],load(){return Ie(()=>Promise.resolve().then(()=>_Yt),void 0,import.meta.url).then(e=>it(e.crystal))}}),Ee.of({name:"D",extensions:["d"],load(){return Ie(()=>Promise.resolve().then(()=>LYt),void 0,import.meta.url).then(e=>it(e.d))}}),Ee.of({name:"Dart",extensions:["dart"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.dart))}}),Ee.of({name:"diff",extensions:["diff","patch"],load(){return Ie(()=>Promise.resolve().then(()=>jYt),void 0,import.meta.url).then(e=>it(e.diff))}}),Ee.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return Ie(()=>Promise.resolve().then(()=>eZt),void 0,import.meta.url).then(e=>it(e.dockerFile))}}),Ee.of({name:"DTD",extensions:["dtd"],load(){return Ie(()=>Promise.resolve().then(()=>rZt),void 0,import.meta.url).then(e=>it(e.dtd))}}),Ee.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return Ie(()=>Promise.resolve().then(()=>lZt),void 0,import.meta.url).then(e=>it(e.dylan))}}),Ee.of({name:"EBNF",load(){return Ie(()=>Promise.resolve().then(()=>cZt),void 0,import.meta.url).then(e=>it(e.ebnf))}}),Ee.of({name:"ECL",extensions:["ecl"],load(){return Ie(()=>Promise.resolve().then(()=>mZt),void 0,import.meta.url).then(e=>it(e.ecl))}}),Ee.of({name:"edn",extensions:["edn"],load(){return Ie(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ee.of({name:"Eiffel",extensions:["e"],load(){return Ie(()=>Promise.resolve().then(()=>SZt),void 0,import.meta.url).then(e=>it(e.eiffel))}}),Ee.of({name:"Elm",extensions:["elm"],load(){return Ie(()=>Promise.resolve().then(()=>XZt),void 0,import.meta.url).then(e=>it(e.elm))}}),Ee.of({name:"Erlang",extensions:["erl"],load(){return Ie(()=>Promise.resolve().then(()=>iHt),void 0,import.meta.url).then(e=>it(e.erlang))}}),Ee.of({name:"Esper",load(){return Ie(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>it(e.esper))}}),Ee.of({name:"Factor",extensions:["factor"],load(){return Ie(()=>Promise.resolve().then(()=>sHt),void 0,import.meta.url).then(e=>it(e.factor))}}),Ee.of({name:"FCL",load(){return Ie(()=>Promise.resolve().then(()=>uHt),void 0,import.meta.url).then(e=>it(e.fcl))}}),Ee.of({name:"Forth",extensions:["forth","fth","4th"],load(){return Ie(()=>Promise.resolve().then(()=>fHt),void 0,import.meta.url).then(e=>it(e.forth))}}),Ee.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return Ie(()=>Promise.resolve().then(()=>bHt),void 0,import.meta.url).then(e=>it(e.fortran))}}),Ee.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return Ie(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.fSharp))}}),Ee.of({name:"Gas",extensions:["s"],load(){return Ie(()=>Promise.resolve().then(()=>xHt),void 0,import.meta.url).then(e=>it(e.gas))}}),Ee.of({name:"Gherkin",extensions:["feature"],load(){return Ie(()=>Promise.resolve().then(()=>SHt),void 0,import.meta.url).then(e=>it(e.gherkin))}}),Ee.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return Ie(()=>Promise.resolve().then(()=>XHt),void 0,import.meta.url).then(e=>it(e.groovy))}}),Ee.of({name:"Haskell",extensions:["hs"],load(){return Ie(()=>Promise.resolve().then(()=>jHt),void 0,import.meta.url).then(e=>it(e.haskell))}}),Ee.of({name:"Haxe",extensions:["hx"],load(){return Ie(()=>Promise.resolve().then(()=>i0e),void 0,import.meta.url).then(e=>it(e.haxe))}}),Ee.of({name:"HXML",extensions:["hxml"],load(){return Ie(()=>Promise.resolve().then(()=>i0e),void 0,import.meta.url).then(e=>it(e.hxml))}}),Ee.of({name:"HTTP",load(){return Ie(()=>Promise.resolve().then(()=>uKt),void 0,import.meta.url).then(e=>it(e.http))}}),Ee.of({name:"IDL",extensions:["pro"],load(){return Ie(()=>Promise.resolve().then(()=>mKt),void 0,import.meta.url).then(e=>it(e.idl))}}),Ee.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return Ie(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>it(e.jsonld))}}),Ee.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return Ie(()=>Promise.resolve().then(()=>wKt),void 0,import.meta.url).then(e=>it(e.jinja2))}}),Ee.of({name:"Julia",extensions:["jl"],load(){return Ie(()=>Promise.resolve().then(()=>GKt),void 0,import.meta.url).then(e=>it(e.julia))}}),Ee.of({name:"Kotlin",extensions:["kt","kts"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.kotlin))}}),Ee.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return Ie(()=>Promise.resolve().then(()=>ZKt),void 0,import.meta.url).then(e=>it(e.liveScript))}}),Ee.of({name:"Lua",extensions:["lua"],load(){return Ie(()=>Promise.resolve().then(()=>iJt),void 0,import.meta.url).then(e=>it(e.lua))}}),Ee.of({name:"mIRC",extensions:["mrc"],load(){return Ie(()=>Promise.resolve().then(()=>_Jt),void 0,import.meta.url).then(e=>it(e.mirc))}}),Ee.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return Ie(()=>Promise.resolve().then(()=>hJt),void 0,import.meta.url).then(e=>it(e.mathematica))}}),Ee.of({name:"Modelica",extensions:["mo"],load(){return Ie(()=>Promise.resolve().then(()=>NJt),void 0,import.meta.url).then(e=>it(e.modelica))}}),Ee.of({name:"MUMPS",extensions:["mps"],load(){return Ie(()=>Promise.resolve().then(()=>JJt),void 0,import.meta.url).then(e=>it(e.mumps))}}),Ee.of({name:"Mbox",extensions:["mbox"],load(){return Ie(()=>Promise.resolve().then(()=>$Jt),void 0,import.meta.url).then(e=>it(e.mbox))}}),Ee.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return Ie(()=>Promise.resolve().then(()=>ien),void 0,import.meta.url).then(e=>it(e.nginx))}}),Ee.of({name:"NSIS",extensions:["nsh","nsi"],load(){return Ie(()=>Promise.resolve().then(()=>sen),void 0,import.meta.url).then(e=>it(e.nsis))}}),Ee.of({name:"NTriples",extensions:["nt","nq"],load(){return Ie(()=>Promise.resolve().then(()=>aen),void 0,import.meta.url).then(e=>it(e.ntriples))}}),Ee.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.objectiveC))}}),Ee.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.objectiveCpp))}}),Ee.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return Ie(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.oCaml))}}),Ee.of({name:"Octave",extensions:["m"],load(){return Ie(()=>Promise.resolve().then(()=>men),void 0,import.meta.url).then(e=>it(e.octave))}}),Ee.of({name:"Oz",extensions:["oz"],load(){return Ie(()=>Promise.resolve().then(()=>Cen),void 0,import.meta.url).then(e=>it(e.oz))}}),Ee.of({name:"Pascal",extensions:["p","pas"],load(){return Ie(()=>Promise.resolve().then(()=>Den),void 0,import.meta.url).then(e=>it(e.pascal))}}),Ee.of({name:"Perl",extensions:["pl","pm"],load(){return Ie(()=>Promise.resolve().then(()=>Ien),void 0,import.meta.url).then(e=>it(e.perl))}}),Ee.of({name:"Pig",extensions:["pig"],load(){return Ie(()=>Promise.resolve().then(()=>Men),void 0,import.meta.url).then(e=>it(e.pig))}}),Ee.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return Ie(()=>Promise.resolve().then(()=>ttn),void 0,import.meta.url).then(e=>it(e.powerShell))}}),Ee.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return Ie(()=>Promise.resolve().then(()=>ntn),void 0,import.meta.url).then(e=>it(e.properties))}}),Ee.of({name:"ProtoBuf",extensions:["proto"],load(){return Ie(()=>Promise.resolve().then(()=>otn),void 0,import.meta.url).then(e=>it(e.protobuf))}}),Ee.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return Ie(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>it(e.pug))}}),Ee.of({name:"Puppet",extensions:["pp"],load(){return Ie(()=>Promise.resolve().then(()=>utn),void 0,import.meta.url).then(e=>it(e.puppet))}}),Ee.of({name:"Q",extensions:["q"],load(){return Ie(()=>Promise.resolve().then(()=>vtn),void 0,import.meta.url).then(e=>it(e.q))}}),Ee.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return Ie(()=>Promise.resolve().then(()=>ktn),void 0,import.meta.url).then(e=>it(e.r))}}),Ee.of({name:"RPM Changes",load(){return Ie(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>it(e.rpmChanges))}}),Ee.of({name:"RPM Spec",extensions:["spec"],load(){return Ie(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>it(e.rpmSpec))}}),Ee.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return Ie(()=>Promise.resolve().then(()=>Xtn),void 0,import.meta.url).then(e=>it(e.ruby))}}),Ee.of({name:"SAS",extensions:["sas"],load(){return Ie(()=>Promise.resolve().then(()=>Ftn),void 0,import.meta.url).then(e=>it(e.sas))}}),Ee.of({name:"Scala",extensions:["scala"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.scala))}}),Ee.of({name:"Scheme",extensions:["scm","ss"],load(){return Ie(()=>Promise.resolve().then(()=>Htn),void 0,import.meta.url).then(e=>it(e.scheme))}}),Ee.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Ie(()=>Promise.resolve().then(()=>tnn),void 0,import.meta.url).then(e=>it(e.shell))}}),Ee.of({name:"Sieve",extensions:["siv","sieve"],load(){return Ie(()=>Promise.resolve().then(()=>ann),void 0,import.meta.url).then(e=>it(e.sieve))}}),Ee.of({name:"Smalltalk",extensions:["st"],load(){return Ie(()=>Promise.resolve().then(()=>cnn),void 0,import.meta.url).then(e=>it(e.smalltalk))}}),Ee.of({name:"Solr",load(){return Ie(()=>Promise.resolve().then(()=>gnn),void 0,import.meta.url).then(e=>it(e.solr))}}),Ee.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return Ie(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.sml))}}),Ee.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return Ie(()=>Promise.resolve().then(()=>Snn),void 0,import.meta.url).then(e=>it(e.sparql))}}),Ee.of({name:"Spreadsheet",alias:["excel","formula"],load(){return Ie(()=>Promise.resolve().then(()=>$nn),void 0,import.meta.url).then(e=>it(e.spreadsheet))}}),Ee.of({name:"Squirrel",extensions:["nut"],load(){return Ie(()=>Promise.resolve().then(()=>dm),void 0,import.meta.url).then(e=>it(e.squirrel))}}),Ee.of({name:"Stylus",extensions:["styl"],load(){return Ie(()=>Promise.resolve().then(()=>Gnn),void 0,import.meta.url).then(e=>it(e.stylus))}}),Ee.of({name:"Swift",extensions:["swift"],load(){return Ie(()=>Promise.resolve().then(()=>hrn),void 0,import.meta.url).then(e=>it(e.swift))}}),Ee.of({name:"sTeX",load(){return Ie(()=>Promise.resolve().then(()=>Y0e),void 0,import.meta.url).then(e=>it(e.stex))}}),Ee.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return Ie(()=>Promise.resolve().then(()=>Y0e),void 0,import.meta.url).then(e=>it(e.stex))}}),Ee.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return Ie(()=>Promise.resolve().then(()=>pve),void 0,import.meta.url).then(e=>it(e.verilog))}}),Ee.of({name:"Tcl",extensions:["tcl"],load(){return Ie(()=>Promise.resolve().then(()=>grn),void 0,import.meta.url).then(e=>it(e.tcl))}}),Ee.of({name:"Textile",extensions:["textile"],load(){return Ie(()=>Promise.resolve().then(()=>brn),void 0,import.meta.url).then(e=>it(e.textile))}}),Ee.of({name:"TiddlyWiki",load(){return Ie(()=>Promise.resolve().then(()=>jrn),void 0,import.meta.url).then(e=>it(e.tiddlyWiki))}}),Ee.of({name:"Tiki wiki",load(){return Ie(()=>Promise.resolve().then(()=>Brn),void 0,import.meta.url).then(e=>it(e.tiki))}}),Ee.of({name:"TOML",extensions:["toml"],load(){return Ie(()=>Promise.resolve().then(()=>Yrn),void 0,import.meta.url).then(e=>it(e.toml))}}),Ee.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return Ie(()=>Promise.resolve().then(()=>Krn),void 0,import.meta.url).then(e=>it(e.troff))}}),Ee.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return Ie(()=>Promise.resolve().then(()=>gin),void 0,import.meta.url).then(e=>it(e.ttcn))}}),Ee.of({name:"TTCN_CFG",extensions:["cfg"],load(){return Ie(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>it(e.ttcnCfg))}}),Ee.of({name:"Turtle",extensions:["ttl"],load(){return Ie(()=>Promise.resolve().then(()=>yin),void 0,import.meta.url).then(e=>it(e.turtle))}}),Ee.of({name:"Web IDL",extensions:["webidl"],load(){return Ie(()=>Promise.resolve().then(()=>hsn),void 0,import.meta.url).then(e=>it(e.webIDL))}}),Ee.of({name:"VB.NET",extensions:["vb"],load(){return Ie(()=>Promise.resolve().then(()=>Xin),void 0,import.meta.url).then(e=>it(e.vb))}}),Ee.of({name:"VBScript",extensions:["vbs"],load(){return Ie(()=>Promise.resolve().then(()=>Iin),void 0,import.meta.url).then(e=>it(e.vbScript))}}),Ee.of({name:"Velocity",extensions:["vtl"],load(){return Ie(()=>Promise.resolve().then(()=>Min),void 0,import.meta.url).then(e=>it(e.velocity))}}),Ee.of({name:"Verilog",extensions:["v"],load(){return Ie(()=>Promise.resolve().then(()=>pve),void 0,import.meta.url).then(e=>it(e.verilog))}}),Ee.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return Ie(()=>Promise.resolve().then(()=>Bin),void 0,import.meta.url).then(e=>it(e.vhdl))}}),Ee.of({name:"XQuery",extensions:["xy","xquery"],load(){return Ie(()=>Promise.resolve().then(()=>xsn),void 0,import.meta.url).then(e=>it(e.xQuery))}}),Ee.of({name:"Yacas",extensions:["ys"],load(){return Ie(()=>Promise.resolve().then(()=>Rsn),void 0,import.meta.url).then(e=>it(e.yacas))}}),Ee.of({name:"Z80",extensions:["z80"],load(){return Ie(()=>Promise.resolve().then(()=>Nsn),void 0,import.meta.url).then(e=>it(e.z80))}}),Ee.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return Ie(()=>Promise.resolve().then(()=>v7),void 0,import.meta.url).then(e=>it(e.mscgen))}}),Ee.of({name:"Xù",extensions:["xu"],load(){return Ie(()=>Promise.resolve().then(()=>v7),void 0,import.meta.url).then(e=>it(e.xu))}}),Ee.of({name:"MsGenny",extensions:["msgenny"],load(){return Ie(()=>Promise.resolve().then(()=>v7),void 0,import.meta.url).then(e=>it(e.msgenny))}}),Ee.of({name:"Vue",extensions:["vue"],load(){return Ie(()=>Promise.resolve().then(()=>VWt),void 0,import.meta.url).then(e=>e.vue())}}),Ee.of({name:"Angular Template",load(){return Ie(()=>Promise.resolve().then(()=>hGt),void 0,import.meta.url).then(e=>e.angular())}})];class vH{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=Xr(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),s=i.search(WAe(t,!1));return s<0?null:{from:r+s,to:this.pos,text:i.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function WOe(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function SIt(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let s=1;s<i.length;s++)n[i[s]]=!0}let r=WOe(t)+WOe(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function oP(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:SIt(t);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:t,validFor:n}:null}}function tX(e,t){return n=>{for(let r=Xr(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class GOe{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Jm(e){return e.selection.main.from}function WAe(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",s=r[r.length-1]!="$";return!i&&!s?e:new RegExp(`${i?"^":""}(?:${r})${s?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const yH=Gh.define();function $It(e,t,n,r){let{main:i}=e.selection,s=n-i.from,a=r-i.from;return Object.assign(Object.assign({},e.changeByRange(o=>{if(o!=i&&n!=r&&e.sliceDoc(o.from+s,o.from+a)!=e.sliceDoc(n,r))return{range:o};let l=e.toText(t);return{changes:{from:o.from+s,to:r==i.from?o.to:o.from+a,insert:l},range:Ze.cursor(o.from+s+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const VOe=new WeakMap;function kIt(e){if(!Array.isArray(e))return e;let t=VOe.get(e);return t||VOe.set(e,t=oP(e)),t}const N5=Mn.define(),MT=Mn.define();class TIt{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=yl(t,n),i=nh(r);this.chars.push(r);let s=t.slice(n,n+i),a=s.toUpperCase();this.folded.push(yl(a==s?s.toLowerCase():a,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:s,byWord:a}=this;if(n.length==1){let y=yl(t,0),b=nh(y),T=b==t.length?0:-100;if(y!=n[0])if(y==r[0])T+=-200;else return null;return this.ret(T,[0,b])}let o=t.indexOf(this.pattern);if(o==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(o<0){for(let y=0,b=Math.min(t.length,200);y<b&&c<l;){let T=yl(t,y);(T==n[c]||T==r[c])&&(i[c++]=y),y+=nh(T)}if(c<l)return null}let u=0,d=0,h=!1,f=0,O=-1,g=-1,m=/[a-z]/.test(t),v=!0;for(let y=0,b=Math.min(t.length,200),T=0;y<b&&d<l;){let x=yl(t,y);o<0&&(u<l&&x==n[u]&&(s[u++]=y),f<l&&(x==n[f]||x==r[f]?(f==0&&(O=y),g=y+1,f++):f=0));let S,k=x<255?x>=48&&x<=57||x>=97&&x<=122?2:x>=65&&x<=90?1:0:(S=YZ(x))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!y||k==1&&m||T==0&&k!=0)&&(n[d]==x||r[d]==x&&(h=!0)?a[d++]=y:a.length&&(v=!1)),T=k,y+=nh(x)}return d==l&&a[0]==0&&v?this.result(-100+(h?-200:0),a,t):f==l&&O==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):f==l?this.ret(-900-t.length,[O,g]):d==l?this.result(-100+(h?-200:0)+-700+(v?0:-1100),a,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],s=0;for(let a of n){let o=a+(this.astral?nh(yl(r,a)):1);s&&i[s-1]==a?i[s-1]=o:(i[s++]=a,i[s++]=o)}return this.ret(t-r.length,i)}}class _It{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const Ca=Yt.define({combine(e){return Vh(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:PIt,filterStrict:!1,compareCompletions:(t,n)=>t.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>BOe(t(r),n(r)),optionClass:(t,n)=>r=>BOe(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function BOe(e,t){return e?t?e+" "+t:e:t}function PIt(e,t,n,r,i,s){let a=e.textDirection==Li.RTL,o=a,l=!1,c="top",u,d,h=t.left-i.left,f=i.right-t.right,O=r.right-r.left,g=r.bottom-r.top;if(o&&h<Math.min(O,f)?o=!1:!o&&f<Math.min(O,h)&&(o=!0),O<=(o?h:f))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,d=Math.min(400,o?h:f);else{l=!0,d=Math.min(400,(a?t.right:i.right-t.left)-30);let y=i.bottom-t.bottom;y>=g||y>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let m=(t.bottom-t.top)/s.offsetHeight,v=(t.right-t.left)/s.offsetWidth;return{style:`${c}: ${u/m}px; max-width: ${d/v}px`,class:"cm-completionInfo-"+(l?a?"left-narrow":"right-narrow":o?"left":"right")}}function CIt(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,s){let a=document.createElement("span");a.className="cm-completionLabel";let o=n.displayLabel||n.label,l=0;for(let c=0;c<s.length;){let u=s[c++],d=s[c++];u>l&&a.appendChild(document.createTextNode(o.slice(l,u)));let h=a.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(o.slice(u,d))),h.className="cm-completionMatchedText",l=d}return l<o.length&&a.appendChild(document.createTextNode(o.slice(l))),a},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function f8(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class QIt{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:s,selected:a}=i.open,o=t.state.facet(Ca);this.optionContent=CIt(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=f8(s.length,a,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=t.state.field(n).open;for(let u=l.target,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]<c.length){this.applyCompletion(t,c[+d[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(Ca).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:MT.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:s,selected:a,disabled:o}=r.open;(!i.open||i.open.options!=s)&&(this.range=f8(s.length,a,t.state.facet(Ca).maxRenderedOptions),this.showOptions(s,r.id)),this.updateSel(),o!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=f8(n.options.length,n.selected,this.view.state.facet(Ca).maxRenderedOptions),this.showOptions(n.options,t.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let s=typeof i=="string"?document.createTextNode(i):i(r);if(!s)return;"then"in s?s.then(a=>{a&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(a,r)}).catch(a=>_l(this.view.state,a,"completion info")):this.addInfoPane(s,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:s}=t;r.appendChild(i),this.infoDestroy=s||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&RIt(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),s=this.space;if(!s){let a=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return i.top>Math.min(s.bottom,n.bottom)-10||i.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(Ca).positionInfo(this.view,n,i,r,s,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",a=>{a.target==i&&a.preventDefault()});let s=null;for(let a=r.from;a<r.to;a++){let{completion:o,match:l}=t[a],{section:c}=o;if(c){let h=typeof c=="string"?c:c.name;if(h!=s&&(a>r.from||r.from==0))if(s=h,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let f=i.appendChild(document.createElement("completion-section"));f.textContent=h}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+a,u.setAttribute("role","option");let d=this.optionClass(o);d&&(u.className=d);for(let h of this.optionContent){let f=h(o,this.view.state,this.view,l);f&&u.appendChild(f)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function EIt(e,t){return n=>new QIt(n,e,t)}function RIt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function YOe(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function AIt(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let d=typeof u=="string"?u:u.name;r.some(h=>h.name==d)||r.push(typeof u=="string"?{name:d}:u)}},s=t.facet(Ca);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let d of c.result.options)i(new GOe(d,c.source,u?u(d):[],1e9-n.length));else{let d=t.sliceDoc(c.from,c.to),h,f=s.filterStrict?new _It(d):new TIt(d);for(let O of c.result.options)if(h=f.match(O.label)){let g=O.displayLabel?u?u(O,h.matched):[]:h.matched;i(new GOe(O,c.source,g,h.score+(O.boost||0)))}}}if(r){let c=Object.create(null),u=0,d=(h,f)=>{var O,g;return((O=h.rank)!==null&&O!==void 0?O:1e9)-((g=f.rank)!==null&&g!==void 0?g:1e9)||(h.name<f.name?-1:1)};for(let h of r.sort(d))u-=1e5,c[h.name]=u;for(let h of n){let{section:f}=h.completion;f&&(h.score+=c[typeof f=="string"?f:f.name])}}let a=[],o=null,l=s.compareCompletions;for(let c of n.sort((u,d)=>d.score-u.score||l(u.completion,d.completion))){let u=c.completion;!o||o.label!=u.label||o.detail!=u.detail||o.type!=null&&u.type!=null&&o.type!=u.type||o.apply!=u.apply||o.boost!=u.boost?a.push(c):YOe(c.completion)>YOe(o)&&(a[a.length-1]=c),o=c.completion}return a}class Hy{constructor(t,n,r,i,s,a){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=s,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new Hy(this.options,ZOe(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,s,a){if(i&&!a&&t.some(c=>c.isPending))return i.setDisabled();let o=AIt(t,n);if(!o.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ca).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<o.length;u++)if(o[u].completion==c){l=u;break}}return new Hy(o,ZOe(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:MIt,above:s.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Hy(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new Hy(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class F5{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new F5(NIt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ca),s=(r.override||n.languageDataAt("autocomplete",Jm(n)).map(kIt)).map(l=>(this.active.find(u=>u.source==l)||new ru(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));s.length==this.active.length&&s.every((l,c)=>l==this.active[c])&&(s=this.active);let a=this.open,o=t.effects.some(l=>l.is(bH));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||s.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!XIt(s,this.active)||o?a=Hy.build(s,n,this.id,a,r,o):a&&a.disabled&&!s.some(l=>l.isPending)&&(a=null),!a&&s.every(l=>!l.isPending)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new ru(l.source,0):l));for(let l of t.effects)l.is(VAe)&&(a=a&&a.setSelected(l.value,this.id));return s==this.active&&a==this.open?this:new F5(s,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?DIt:IIt}}function XIt(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,s=r==t.length;if(i||s)return i==s;if(e[n++].result!=t[r++].result)return!1}}const DIt={"aria-autocomplete":"list"},IIt={};function ZOe(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const NIt=[];function GAe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(yH);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class ru{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=GAe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ru(i.source,0)),r&4&&i.state==0&&(i=new ru(this.source,1)),i=i.updateFor(t,r);for(let s of t.effects)if(s.is(N5))i=new ru(i.source,1,s.value);else if(s.is(MT))i=new ru(i.source,0);else if(s.is(bH))for(let a of s.value)a.source==i.source&&(i=a);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Jm(t.state))}}class Sb extends ru{constructor(t,n,r,i,s,a){super(t,3,n),this.limit=r,this.result=i,this.from=s,this.to=a}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let s=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Jm(t.state);if(o>a||!i||n&2&&(Jm(t.startState)==this.from||o<this.limit))return new ru(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return FIt(i.validFor,t.state,s,a)?new Sb(this.source,this.explicit,l,i,s,a):i.update&&(i=i.update(i,s,a,new vH(t.state,o,!1)))?new Sb(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Jm(t.state)):new ru(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Sb(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ru(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function FIt(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):WAe(e,!0).test(i)}const bH=Mn.define({map(e,t){return e.map(n=>n.map(t))}}),VAe=Mn.define(),wl=Ia.define({create(){return F5.start()},update(e,t){return e.update(t)},provide:e=>[uH.from(e,t=>t.tooltip),Ct.contentAttributes.from(e,t=>t.attrs)]});function wH(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(wl).active.find(i=>i.source==t.source);return r instanceof Sb?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},$It(e.state,n,r.from,r.to)),{annotations:yH.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const MIt=EIt(wl,wH);function tC(e,t="option"){return n=>{let r=n.state.field(wl,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ca).interactionDelay)return!1;let i=1,s;t=="page"&&(s=vAe(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:a}=r.open.options,o=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:a-1;return o<0?o=t=="page"?0:a-1:o>=a&&(o=t=="page"?a-1:0),n.dispatch({effects:VAe.of(o)}),!0}}const LIt=e=>{let t=e.state.field(wl,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ca).interactionDelay?!1:wH(e,t.open.options[t.open.selected])},HOe=e=>e.state.field(wl,!1)?(e.dispatch({effects:N5.of(!0)}),!0):!1,jIt=e=>{let t=e.state.field(wl,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:MT.of(null)}),!0)};class qIt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const zIt=50,UIt=1e3,WIt=us.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(wl).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(wl),n=e.state.facet(Ca);if(!e.selectionSet&&!e.docChanged&&e.startState.field(wl)==t)return;let r=e.transactions.some(s=>{let a=GAe(s,n);return a&8||(s.selection||s.docChanged)&&!(a&3)});for(let s=0;s<this.running.length;s++){let a=this.running[s];if(r||a.context.abortOnDocChange&&e.docChanged||a.updates.length+e.transactions.length>zIt&&Date.now()-a.time>UIt){for(let o of a.context.abortListeners)try{o()}catch(l){_l(this.view.state,l)}a.context.abortListeners=null,this.running.splice(s--,1)}else a.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(s=>s.effects.some(a=>a.is(N5)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(s=>s.isPending&&!this.running.some(a=>a.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of e.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(wl);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ca).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Jm(t),r=new vH(t,n,e.explicit,this.view),i=new qIt(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:MT.of(null)}),_l(this.view.state,s)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ca).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ca),r=this.view.state.field(wl);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let o=Jm(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(o,s.done.from+(s.active.explicit?0:1)),c=new Sb(s.active.source,s.active.explicit,l,s.done,s.done.from,(e=s.done.to)!==null&&e!==void 0?e:o);for(let u of s.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let a=r.active.find(o=>o.source==s.active.source);if(a&&a.isPending)if(s.done==null){let o=new ru(s.active.source,0);for(let l of s.updates)o=o.update(l,n);o.isPending||t.push(o)}else this.startQuery(a)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:bH.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(wl,!1);if(t&&t.tooltip&&this.view.state.facet(Ca).closeOnBlur){let n=t.open&&vAe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:MT.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:N5.of(!1)}),20),this.composing=0}}}),GIt=typeof navigator=="object"&&/Win/.test(navigator.platform),VIt=CO.highest(Ct.domEventHandlers({keydown(e,t){let n=t.state.field(wl,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(GIt&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(a=>a.source==r.source),s=r.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&wH(t,r),!1}})),BAe=Ct.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class BIt{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class xH{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ya.TrackDel),r=t.mapPos(this.to,1,Ya.TrackDel);return n==null||r==null?null:new xH(this.field,n,r)}}class SH{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],s=t.doc.lineAt(n),a=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(r.length){let c=a,u=/^\t*/.exec(l)[0].length;for(let d=0;d<u;d++)c+=t.facet(Lw);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let o=this.fieldPositions.map(l=>new xH(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:o}}static parse(t){let n=[],r=[],i=[],s;for(let a of t.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(a);){let o=s[1]?+s[1]:null,l=s[2]||s[3]||"",c=-1,u=l.replace(/\\[{}]/g,d=>d[1]);for(let d=0;d<n.length;d++)(o!=null?n[d].seq==o:u&&n[d].name==u)&&(c=d);if(c<0){let d=0;for(;d<n.length&&(o==null||n[d].seq!=null&&n[d].seq<o);)d++;n.splice(d,0,{seq:o,name:u}),c=d;for(let h of i)h.field>=c&&h.field++}i.push(new BIt(c,r.length,s.index,s.index+u.length)),a=a.slice(0,s.index)+l+a.slice(s.index+s[0].length)}a=a.replace(/\\([{}])/g,(o,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(a)}return new SH(r,i)}}let YIt=Bt.widget({widget:new class extends xd{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),ZIt=Bt.mark({class:"cm-snippetField"});class qw{constructor(t,n){this.ranges=t,this.active=n,this.deco=Bt.set(t.map(r=>(r.from==r.to?YIt:ZIt).range(r.from,r.to)))}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new qw(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const lP=Mn.define({map(e,t){return e&&e.map(t)}}),HIt=Mn.define(),LT=Ia.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(lP))return n.value;if(n.is(HIt)&&e)return new qw(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>Ct.decorations.from(e,t=>t?t.deco:Bt.none)});function $H(e,t){return Ze.create(e.filter(n=>n.field==t).map(n=>Ze.range(n.from,n.to)))}function KIt(e){let t=SH.parse(e);return(n,r,i,s)=>{let{text:a,ranges:o}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:s==l.from?l.to:s,insert:Fr.of(a)},scrollIntoView:!0,annotations:r?[yH.of(r),ea.userEvent.of("input.complete")]:void 0};if(o.length&&(c.selection=$H(o,0)),o.some(u=>u.field>0)){let u=new qw(o,0),d=c.effects=[lP.of(u)];n.state.field(LT,!1)===void 0&&d.push(Mn.appendConfig.of([LT,rNt,iNt,BAe]))}n.dispatch(n.state.update(c))}}function YAe(e){return({state:t,dispatch:n})=>{let r=t.field(LT,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,s=e>0&&!r.ranges.some(a=>a.field==i+e);return n(t.update({selection:$H(r.ranges,i),effects:lP.of(s?null:new qw(r.ranges,i)),scrollIntoView:!0})),!0}}const JIt=({state:e,dispatch:t})=>e.field(LT,!1)?(t(e.update({effects:lP.of(null)})),!0):!1,eNt=YAe(1),tNt=YAe(-1),nNt=[{key:"Tab",run:eNt,shift:tNt},{key:"Escape",run:JIt}],KOe=Yt.define({combine(e){return e.length?e[0]:nNt}}),rNt=CO.highest(xv.compute([KOe],e=>e.facet(KOe)));function Di(e,t){return Object.assign(Object.assign({},t),{apply:KIt(e)})}const iNt=Ct.domEventHandlers({mousedown(e,t){let n=t.state.field(LT,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(s=>s.from<=r&&s.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:$H(n.ranges,i.field),effects:lP.of(n.ranges.some(s=>s.field>i.field)?new qw(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),jT={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},jm=Mn.define({map(e,t){let n=t.mapPos(e,-1,Ya.TrackAfter);return n??void 0}}),kH=new class extends D0{};kH.startSide=1;kH.endSide=-1;const ZAe=Ia.define({create(){return Cr.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(jm)&&(e=e.update({add:[kH.range(n.value,n.value+1)]}));return e}});function sNt(){return[oNt,ZAe]}const O8="()[]{}<>«»»«[]{}";function HAe(e){for(let t=0;t<O8.length;t+=2)if(O8.charCodeAt(t)==e)return O8.charAt(t+1);return YZ(e<128?e:e+1)}function KAe(e,t){return e.languageDataAt("closeBrackets",t)[0]||jT}const aNt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),oNt=Ct.inputHandler.of((e,t,n,r)=>{if((aNt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&nh(yl(r,0))==1||t!=i.from||n!=i.to)return!1;let s=uNt(e.state,r);return s?(e.dispatch(s),!0):!1}),lNt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=KAe(e,e.selection.main.head).brackets||jT.brackets,i=null,s=e.changeByRange(a=>{if(a.empty){let o=dNt(e.doc,a.head);for(let l of r)if(l==o&&nX(e.doc,a.head)==HAe(yl(l,0)))return{changes:{from:a.head-l.length,to:a.head+l.length},range:Ze.cursor(a.head-l.length)}}return{range:i=a}});return i||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},cNt=[{key:"Backspace",run:lNt}];function uNt(e,t){let n=KAe(e,e.selection.main.head),r=n.brackets||jT.brackets;for(let i of r){let s=HAe(yl(i,0));if(t==i)return s==i?ONt(e,i,r.indexOf(i+i+i)>-1,n):hNt(e,i,s,n.before||jT.before);if(t==s&&JAe(e,e.selection.main.from))return fNt(e,i,s)}return null}function JAe(e,t){let n=!1;return e.field(ZAe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function nX(e,t){let n=e.sliceString(t,t+2);return n.slice(0,nh(yl(n,0)))}function dNt(e,t){let n=e.sliceString(t-2,t);return nh(yl(n,0))==n.length?n:n.slice(1)}function hNt(e,t,n,r){let i=null,s=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:jm.of(a.to+t.length),range:Ze.range(a.anchor+t.length,a.head+t.length)};let o=nX(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:jm.of(a.head+t.length),range:Ze.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function fNt(e,t,n){let r=null,i=e.changeByRange(s=>s.empty&&nX(e.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:Ze.cursor(s.head+n.length)}:r={range:s});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function ONt(e,t,n,r){let i=r.stringPrefixes||jT.stringPrefixes,s=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:jm.of(o.to+t.length),range:Ze.range(o.anchor+t.length,o.head+t.length)};let l=o.head,c=nX(e.doc,l),u;if(c==t){if(JOe(e,l))return{changes:{insert:t+t,from:l},effects:jm.of(l+t.length),range:Ze.cursor(l+t.length)};if(JAe(e,l)){let h=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+h.length,insert:h},range:Ze.cursor(l+h.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=epe(e,l-2*t.length,i))>-1&&JOe(e,u))return{changes:{insert:t+t+t+t,from:l},effects:jm.of(l+t.length),range:Ze.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Zi.Word&&epe(e,l,i)>-1&&!pNt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:jm.of(l+t.length),range:Ze.cursor(l+t.length)}}return{range:s=o}});return s?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function JOe(e,t){let n=Xr(e).resolveInner(t+1);return n.parent&&n.from==t}function pNt(e,t,n,r){let i=Xr(e).resolveInner(t,-1),s=r.reduce((a,o)=>Math.max(a,o.length),0);for(let a=0;a<5;a++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),l=o.indexOf(n);if(!l||l>-1&&r.indexOf(o.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(e.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function epe(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Zi.Word)return t;for(let i of n){let s=t-i.length;if(e.sliceDoc(s,t)==i&&r(e.sliceDoc(s-1,s))!=Zi.Word)return s}return-1}function gNt(e={}){return[VIt,wl,Ca.of(e),WIt,mNt,BAe]}const e3e=[{key:"Ctrl-Space",run:HOe},{mac:"Alt-`",run:HOe},{key:"Escape",run:jIt},{key:"ArrowDown",run:tC(!0)},{key:"ArrowUp",run:tC(!1)},{key:"PageDown",run:tC(!0,"page")},{key:"PageUp",run:tC(!1,"page")},{key:"Enter",run:LIt}],mNt=CO.highest(xv.computeN([Ca],e=>e.facet(Ca).defaultKeymap?[e3e]:[]));class M5{static create(t,n,r,i,s){let a=i+(i<<8)+t+(n<<4)|0;return new M5(t,n,r,a,s,[],[])}constructor(t,n,r,i,s,a,o){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=s,this.children=a,this.positions=o,this.hashProp=[[In.contextHash,i]]}addChild(t,n){t.prop(In.contextHash)!=this.hash&&(t=new vr(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new vr(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,s,a)=>new vr(na.none,i,s,a,this.hashProp)})}}var $t;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})($t||($t={}));class vNt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}class yNt{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return g$(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,r=0){for(let i=n;i<t;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(t){let n=0;for(let r=0;n<this.text.length&&r<t;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let t="";for(let n=0;n<this.basePos;n++)t+=" ";return t+this.text.slice(this.basePos)}}function tpe(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==$t.OrderedList?PH:_H)(n,t,!1);return r>0&&(e.type!=$t.BulletList||TH(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const t3e={[$t.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(xr($t.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Tu(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[$t.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[$t.OrderedList]:tpe,[$t.BulletList]:tpe,[$t.Document](){return!0}};function Tu(e){return e==32||e==9||e==10||e==13}function g$(e,t=0){for(;t<e.length&&Tu(e.charCodeAt(t));)t++;return t}function npe(e,t,n){for(;t>n&&Tu(e.charCodeAt(t-1));)t--;return t}function n3e(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function r3e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function TH(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let s=e.text.charCodeAt(i);if(s==e.next)r++;else if(!Tu(s))return-1}return n&&e.next==45&&a3e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(u3e.SetextHeading)>-1||r<3?-1:1}function i3e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function _H(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Tu(e.text.charCodeAt(e.pos+1)))&&(!n||i3e(t,$t.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function PH(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!Tu(e.text.charCodeAt(r+1))||n&&!i3e(t,$t.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function s3e(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function a3e(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&Tu(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const sW=/^[ \t]*$/,o3e=/-->/,l3e=/\?>/,aW=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,o3e],[/^\s*<\?/,l3e],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,sW],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,sW]];function c3e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,s=aW.length-(n?1:0);i<s;i++)if(aW[i][0].test(r))return i;return-1}function rpe(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function lm(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==$t.CodeText?e[r].to=n:e.push(xr($t.CodeText,t,n))}const nC={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,s=e.lineStart+t.text.length,a=[],o=[];for(lm(a,i,s);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){lm(o,e.lineStart-1,e.lineStart);for(let l of t.markers)o.push(l)}else{if(t.indent<n)break;{if(o.length){for(let c of o)c.type==$t.CodeText?lm(a,c.from,c.to):a.push(c);o=[]}lm(a,e.lineStart-1,e.lineStart);for(let c of t.markers)a.push(c);s=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<s&&lm(a,l,s)}}return o.length&&(o=o.filter(l=>l.type!=$t.CodeText),o.length&&(t.markers=o.concat(t.markers))),e.addNode(e.buffer.writeElements(a,-i).finish($t.CodeBlock,s-i),i),!0},FencedCode(e,t){let n=n3e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,s=n-t.pos,a=t.skipSpace(n),o=npe(t.text,t.text.length,a),l=[xr($t.CodeMark,r,r+s)];a<o&&l.push(xr($t.CodeInfo,e.lineStart+a,e.lineStart+o));for(let c=!0;e.nextLine()&&t.depth>=e.stack.length;c=!1){let u=t.pos;if(t.indent-t.baseIndent<4)for(;u<t.text.length&&t.text.charCodeAt(u)==i;)u++;if(u-t.pos>=s&&t.skipSpace(u)==t.text.length){for(let d of t.markers)l.push(d);l.push(xr($t.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||lm(l,e.lineStart-1,e.lineStart);for(let f of t.markers)l.push(f);let d=e.lineStart+t.basePos,h=e.lineStart+t.text.length;d<h&&lm(l,d,h)}}return e.addNode(e.buffer.writeElements(l,-r).finish($t.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=r3e(t);return n<0?!1:(e.startContext($t.Blockquote,t.pos),e.addNode($t.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(TH(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode($t.HorizontalRule,n),!0},BulletList(e,t){let n=_H(t,e,!1);if(n<0)return!1;e.block.type!=$t.BulletList&&e.startContext($t.BulletList,t.basePos,t.next);let r=rpe(t,t.pos+1);return e.startContext($t.ListItem,t.basePos,r-t.baseIndent),e.addNode($t.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=PH(t,e,!1);if(n<0)return!1;e.block.type!=$t.OrderedList&&e.startContext($t.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=rpe(t,t.pos+n);return e.startContext($t.ListItem,t.basePos,r-t.baseIndent),e.addNode($t.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=s3e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,s=npe(t.text,t.text.length,r),a=s;for(;a>r&&t.text.charCodeAt(a-1)==t.next;)a--;(a==s||a==r||!Tu(t.text.charCodeAt(a-1)))&&(a=t.text.length);let o=e.buffer.write($t.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,a),i+n+1),-i);a<t.text.length&&o.write($t.HeaderMark,a-r,s-r);let l=o.finish($t.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=c3e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=aW[n][1],s=[],a=i!=sW;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){a=!1;break}for(let c of t.markers)s.push(c)}a&&e.nextLine();let o=i==o3e?$t.CommentBlock:i==l3e?$t.ProcessingInstructionBlock:$t.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(s,-r).finish(o,l-r),r),!0},SetextHeading:void 0};class bNt{constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,n,r){if(this.stage==-1)return!1;let i=r.content+`
1161
1161
  `+n.scrub(),s=this.advance(i);return s>-1&&s<i.length?this.complete(t,r,s):!1}finish(t,n){return(this.stage==2||this.stage==3)&&g$(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,xr($t.LinkReference,this.start,this.start+r,this.elts)),!0}nextStage(t){return t?(this.pos=t.to-this.start,this.elts.push(t),this.stage++,!0):(t===!1&&(this.stage=-1),!1)}advance(t){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(y3e(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(xr($t.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(m3e(t,g$(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=g$(t,this.pos),r=0;if(n>this.pos){let i=v3e(t,n,this.start);if(i){let s=p8(t,i.to-this.start);s>0&&(this.nextStage(i),r=s)}}return r||(r=p8(t,this.pos)),r>0&&r<t.length?r:-1}else return p8(t,this.pos)}}}function p8(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!Tu(n))return-1}return t}class wNt{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:a3e(n),s=n.next;if(i<0)return!1;let a=xr($t.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,xr(s==61?$t.SetextHeading1:$t.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),a])),!0}finish(){return!1}}const u3e={LinkReference(e,t){return t.content.charCodeAt(0)==91?new bNt(t):null},SetextHeading(){return new wNt}},xNt=[(e,t)=>s3e(t)>=0,(e,t)=>n3e(t)>=0,(e,t)=>r3e(t)>=0,(e,t)=>_H(t,e,!0)>=0,(e,t)=>PH(t,e,!0)>=0,(e,t)=>TH(t,e,!0)>=0,(e,t)=>c3e(t,e,!0)>=0],SNt={text:"",end:0};class $Nt{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new yNt,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=i[i.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=i[0].from,this.block=M5.create($t.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new PNt(r,n):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:t}=this;for(;;){for(let r=0;;){let i=t.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;r<t.markers.length&&(!i||t.markers[r].from<i.end);){let s=t.markers[r++];this.addNode(s.type,s.from,s.to)}if(!i)break;this.finishContext()}if(t.pos<t.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(t.basePos))return null;e:for(;;){for(let r of this.parser.blockParsers)if(r){let i=r(this,t);if(i!=!1){if(i==!0)return null;t.forward();continue e}}break}let n=new vNt(this.lineStart+t.pos,t.text.slice(t.pos));for(let r of this.parser.leafBlockParsers)if(r){let i=r(this,n);i&&n.parsers.push(i)}e:for(;this.nextLine()&&t.pos!=t.text.length;){if(t.indent<t.baseIndent+4){for(let r of this.parser.endLeafBlock)if(r(this,t,n))break e}for(let r of n.parsers)if(r.nextLine(this,t,n))return null;n.content+=`
1162
1162
  `+t.scrub();for(let r of t.markers)n.marks.push(r)}return this.finishLeaf(n),null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}reuseFragment(t){if(!this.fragments.moveTo(this.absoluteLineStart+t,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let n=this.fragments.takeNodes(this);return n?(this.absoluteLineStart+=n,this.lineStart=b3e(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(t=this.depth-1){return this.parser.nodeSet.types[this.stack[t].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(t){let n=SNt;if(n.end=t,t>=this.to)n.text="";else if(n.text=this.lineChunkAt(t),n.end+=n.text.length,this.ranges.length>1){let r=this.absoluteLineStart,i=this.rangeI;for(;this.ranges[i].to<n.end;){i++;let s=this.ranges[i].from,a=this.lineChunkAt(s);n.end=s+a.length,n.text=n.text.slice(0,this.ranges[i-1].to-r)+a,r=n.end-n.text.length}}return n}readLine(){let{line:t}=this,{text:n,end:r}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=r,t.reset(n);t.depth<this.stack.length;t.depth++){let i=this.stack[t.depth],s=this.parser.skipContextMarkup[i.type];if(!s)throw new Error("Unhandled block context "+$t[i.type]);if(!s(i,this,t))break;t.forward()}}lineChunkAt(t){let n=this.input.chunk(t),r;if(this.input.lineChunks)r=n==`
1163
1163
  `?"":n;else{let i=n.indexOf(`
@@ -1408,7 +1408,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Yg=ct,li=sn);const Qd=
1408
1408
  * LICENSE file in the root directory of this source tree.
1409
1409
  */var cSe;function iqn(){if(cSe)return hS;cSe=1;var e=Z,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(o,l,c){var u,d={},h=null,f=null;c!==void 0&&(h=""+c),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(f=l.ref);for(u in l)r.call(l,u)&&!s.hasOwnProperty(u)&&(d[u]=l[u]);if(o&&o.defaultProps)for(u in l=o.defaultProps,l)d[u]===void 0&&(d[u]=l[u]);return{$$typeof:t,type:o,key:h,ref:f,props:d,_owner:i.current}}return hS.Fragment=n,hS.jsx=a,hS.jsxs=a,hS}var uSe;function sqn(){return uSe||(uSe=1,lSe.exports=iqn()),lSe.exports}var aqn=sqn();/*! shepherd.js 14.5.0 */function oqn(e){return e instanceof Element}function cw(e){return e instanceof HTMLElement}function yg(e){return typeof e=="function"}function E_(e){return typeof e=="string"}function wo(e){return e===void 0}class Cee{on(t,n,r,i=!1){var s;return wo(this.bindings)&&(this.bindings={}),wo(this.bindings[t])&&(this.bindings[t]=[]),(s=this.bindings[t])==null||s.push({handler:n,ctx:r,once:i}),this}once(t,n,r){return this.on(t,n,r,!0)}off(t,n){if(wo(this.bindings)||wo(this.bindings[t]))return this;if(wo(n))delete this.bindings[t];else{var r;(r=this.bindings[t])==null||r.forEach((i,s)=>{if(i.handler===n){var a;(a=this.bindings[t])==null||a.splice(s,1)}})}return this}trigger(t,...n){if(!wo(this.bindings)&&this.bindings[t]){var r;(r=this.bindings[t])==null||r.forEach((i,s)=>{const{ctx:a,handler:o,once:l}=i,c=a||this;if(o.apply(c,n),l){var u;(u=this.bindings[t])==null||u.splice(s,1)}})}return this}}function Al(){return Al=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Al.apply(null,arguments)}function Qee(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}const Wg={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")};Wg.defaultMerge;function lqn(e,t){return t}function cqn(e,t){return e.filter(n=>n!==void 0)}var dSe;(function(e){e[e.NOT=0]="NOT",e[e.RECORD=1]="RECORD",e[e.ARRAY=2]="ARRAY",e[e.SET=3]="SET",e[e.MAP=4]="MAP",e[e.OTHER=5]="OTHER"})(dSe||(dSe={}));function hSe(e){return typeof e!="object"||e===null?0:Array.isArray(e)?2:hqn(e)?1:e instanceof Set?3:e instanceof Map?4:5}function uqn(e){const t=new Set;for(const n of e)for(const r of[...Object.keys(n),...Object.getOwnPropertySymbols(n)])t.add(r);return t}function dqn(e,t){return typeof e=="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function IUe(e){return{*[Symbol.iterator](){for(const t of e)for(const n of t)yield n}}}const fSe=new Set(["[object Object]","[object Module]"]);function hqn(e){if(!fSe.has(Object.prototype.toString.call(e)))return!1;const{constructor:t}=e;if(t===void 0)return!0;const n=t.prototype;return!(n===null||typeof n!="object"||!fSe.has(Object.prototype.toString.call(n))||!n.hasOwnProperty("isPrototypeOf"))}function fqn(e,t,n){const r={};for(const i of uqn(e)){const s=[];for(const l of e)dqn(l,i)&&s.push(l[i]);if(s.length===0)continue;const a=t.metaDataUpdater(n,{key:i,parents:e}),o=NUe(s,t,a);o!==Wg.skip&&(i==="__proto__"?Object.defineProperty(r,i,{value:o,configurable:!0,enumerable:!0,writable:!0}):r[i]=o)}return r}function Oqn(e){return e.flat()}function pqn(e){return new Set(IUe(e))}function gqn(e){return new Map(IUe(e))}function mqn(e){return e.at(-1)}const gQ={mergeRecords:fqn,mergeArrays:Oqn,mergeSets:pqn,mergeMaps:gqn,mergeOthers:mqn};function Eee(...e){return vqn({})(...e)}function vqn(e,t){const n=yqn(e,r);function r(...i){return NUe(i,n,t)}return r}function yqn(e,t){var n,r,i;return{defaultMergeFunctions:gQ,mergeFunctions:Al({},gQ,Object.fromEntries(Object.entries(e).filter(([s,a])=>Object.hasOwn(gQ,s)).map(([s,a])=>a===!1?[s,gQ.mergeOthers]:[s,a]))),metaDataUpdater:(n=e.metaDataUpdater)!=null?n:lqn,deepmerge:t,useImplicitDefaultMerging:(r=e.enableImplicitDefaultMerging)!=null?r:!1,filterValues:e.filterValues===!1?void 0:(i=e.filterValues)!=null?i:cqn,actions:Wg}}function NUe(e,t,n){var r;const i=(r=t.filterValues==null?void 0:t.filterValues(e,n))!=null?r:e;if(i.length===0)return;if(i.length===1)return HL(i,t,n);const s=hSe(i[0]);if(s!==0&&s!==5){for(let a=1;a<i.length;a++)if(hSe(i[a])!==s)return HL(i,t,n)}switch(s){case 1:return bqn(i,t,n);case 2:return wqn(i,t,n);case 3:return xqn(i,t,n);case 4:return Sqn(i,t,n);default:return HL(i,t,n)}}function bqn(e,t,n){const r=t.mergeFunctions.mergeRecords(e,t,n);return r===Wg.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(e,t,n):r}function wqn(e,t,n){const r=t.mergeFunctions.mergeArrays(e,t,n);return r===Wg.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(e):r}function xqn(e,t,n){const r=t.mergeFunctions.mergeSets(e,t,n);return r===Wg.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(e):r}function Sqn(e,t,n){const r=t.mergeFunctions.mergeMaps(e,t,n);return r===Wg.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(e):r}function HL(e,t,n){const r=t.mergeFunctions.mergeOthers(e,t,n);return r===Wg.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(e):r}function Ree(e){const t=Object.getOwnPropertyNames(e.constructor.prototype);for(let n=0;n<t.length;n++){const r=t[n],i=e[r];r!=="constructor"&&typeof i=="function"&&(e[r]=i.bind(e))}return e}function $qn(e,t){return n=>{if(e.isOpen()){const r=e.el&&n.currentTarget===e.el;(!wo(t)&&n.currentTarget.matches(t)||r)&&e.tour.next()}}}function kqn(e){const{event:t,selector:n}=e.options.advanceOn||{};if(t){const r=$qn(e,n);let i=null;if(!wo(n)&&(i=document.querySelector(n),!i))return console.error(`No element was found for the selector supplied to advanceOn: ${n}`);i?(i.addEventListener(t,r),e.on("destroy",()=>i.removeEventListener(t,r))):(document.body.addEventListener(t,r,!0),e.on("destroy",()=>document.body.removeEventListener(t,r,!0)))}else return console.error("advanceOn was defined, but no event name was passed.")}class Tqn{constructor(t){}}class _qn{constructor(t,n){}}function FUe(e){return!E_(e)||e===""?"":e.charAt(e.length-1)!=="-"?`${e}-`:e}function Pqn(e){const t=e.options.attachTo||{},n=Object.assign({},t);if(yg(n.element)&&(n.element=n.element.call(e)),E_(n.element)){try{n.element=document.querySelector(n.element)}catch{}n.element||console.error(`The element for this Shepherd step was not found ${t.element}`)}return n}function Cqn(e){return e.options.extraHighlights?e.options.extraHighlights.flatMap(t=>Array.from(document.querySelectorAll(t))):[]}function MUe(e){return e==null?!0:!e.element||!e.on}function LUe(){let e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t=="x"?n:n&3|8).toString(16)})}const Qqn=["top","right","bottom","left"],OSe=["start","end"],pSe=Qqn.reduce((e,t)=>e.concat(t,t+"-"+OSe[0],t+"-"+OSe[1]),[]),uw=Math.min,p0=Math.max,dA=Math.round,mQ=Math.floor,_h=e=>({x:e,y:e}),Eqn={left:"right",right:"left",bottom:"top",top:"bottom"},Rqn={start:"end",end:"start"};function TV(e,t,n){return p0(e,uw(t,n))}function ov(e,t){return typeof e=="function"?e(t):e}function xO(e){return e.split("-")[0]}function nO(e){return e.split("-")[1]}function Aee(e){return e==="x"?"y":"x"}function Xee(e){return e==="y"?"height":"width"}function dw(e){return["top","bottom"].includes(xO(e))?"y":"x"}function Dee(e){return Aee(dw(e))}function jUe(e,t,n){n===void 0&&(n=!1);const r=nO(e),i=Dee(e),s=Xee(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=fA(a)),[a,fA(a)]}function Aqn(e){const t=fA(e);return[hA(e),t,hA(t)]}function hA(e){return e.replace(/start|end/g,t=>Rqn[t])}function Xqn(e,t,n){const r=["left","right"],i=["right","left"],s=["top","bottom"],a=["bottom","top"];switch(e){case"top":case"bottom":return n?t?i:r:t?r:i;case"left":case"right":return t?s:a;default:return[]}}function Dqn(e,t,n,r){const i=nO(e);let s=Xqn(xO(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(hA)))),s}function fA(e){return e.replace(/left|right|bottom|top/g,t=>Eqn[t])}function Iqn(e){return Al({top:0,right:0,bottom:0,left:0},e)}function qUe(e){return typeof e!="number"?Iqn(e):{top:e,right:e,bottom:e,left:e}}function OA(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}const Nqn=["crossAxis","alignment","allowedPlacements","autoAlignment"],Fqn=["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"],Mqn=["mainAxis","crossAxis","limiter"];function gSe(e,t,n){let{reference:r,floating:i}=e;const s=dw(t),a=Dee(t),o=Xee(a),l=xO(t),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,h=r[o]/2-i[o]/2;let f;switch(l){case"top":f={x:u,y:r.y-i.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-i.width,y:d};break;default:f={x:r.x,y:r.y}}switch(nO(t)){case"start":f[a]-=h*(n&&c?-1:1);break;case"end":f[a]+=h*(n&&c?-1:1);break}return f}const Lqn=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,o=s.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=gSe(c,r,l),h=r,f={},O=0;for(let g=0;g<o.length;g++){const{name:m,fn:v}=o[g],{x:y,y:b,data:T,reset:x}=await v({x:u,y:d,initialPlacement:r,placement:h,strategy:i,middlewareData:f,rects:c,platform:a,elements:{reference:e,floating:t}});u=y??u,d=b??d,f=Al({},f,{[m]:Al({},f[m],T)}),x&&O<=50&&(O++,typeof x=="object"&&(x.placement&&(h=x.placement),x.rects&&(c=x.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=gSe(c,h,l)),g=-1)}return{x:u,y:d,placement:h,strategy:i,middlewareData:f}};async function Iee(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:o,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:f=0}=ov(t,e),O=qUe(f),g=o[h?d==="floating"?"reference":"floating":d],m=OA(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(o.floating)),boundary:c,rootBoundary:u,strategy:l})),v=d==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(o.floating)),b=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},T=OA(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:v,offsetParent:y,strategy:l}):v);return{top:(m.top-T.top+O.top)/b.y,bottom:(T.bottom-m.bottom+O.bottom)/b.y,left:(m.left-T.left+O.left)/b.x,right:(T.right-m.right+O.right)/b.x}}const jqn=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:o,middlewareData:l}=t,{element:c,padding:u=0}=ov(e,t)||{};if(c==null)return{};const d=qUe(u),h={x:n,y:r},f=Dee(i),O=Xee(f),g=await a.getDimensions(c),m=f==="y",v=m?"top":"left",y=m?"bottom":"right",b=m?"clientHeight":"clientWidth",T=s.reference[O]+s.reference[f]-h[f]-s.floating[O],x=h[f]-s.reference[f],S=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c));let k=S?S[b]:0;(!k||!await(a.isElement==null?void 0:a.isElement(S)))&&(k=o.floating[b]||s.floating[O]);const _=T/2-x/2,P=k/2-g[O]/2-1,C=uw(d[v],P),Q=uw(d[y],P),E=C,A=k-g[O]-Q,L=k/2-g[O]/2+_,j=TV(E,L,A),q=!l.arrow&&nO(i)!=null&&L!==j&&s.reference[O]/2-(L<E?C:Q)-g[O]/2<0,z=q?L<E?L-E:L-A:0;return{[f]:h[f]+z,data:Al({[f]:j,centerOffset:L-j-z},q&&{alignmentOffset:z}),reset:q}}});function qqn(e,t,n){return(e?[...n.filter(r=>nO(r)===e),...n.filter(r=>nO(r)!==e)]:n.filter(r=>xO(r)===r)).filter(r=>e?nO(r)===e||(t?hA(r)!==r:!1):!0)}const zqn=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,i;const{rects:s,middlewareData:a,placement:o,platform:l,elements:c}=t,u=ov(e,t),{crossAxis:d=!1,alignment:h,allowedPlacements:f=pSe,autoAlignment:O=!0}=u,g=Qee(u,Nqn),m=h!==void 0||f===pSe?qqn(h||null,O,f):f,v=await Iee(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,b=m[y];if(b==null)return{};const T=jUe(b,s,await(l.isRTL==null?void 0:l.isRTL(c.floating)));if(o!==b)return{reset:{placement:m[0]}};const x=[v[xO(b)],v[T[0]],v[T[1]]],S=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:b,overflows:x}],k=m[y+1];if(k)return{data:{index:y+1,overflows:S},reset:{placement:k}};const _=S.map(C=>{const Q=nO(C.placement);return[C.placement,Q&&d?C.overflows.slice(0,2).reduce((E,A)=>E+A,0):C.overflows[0],C.overflows]}).sort((C,Q)=>C[1]-Q[1]),P=((i=_.filter(C=>C[2].slice(0,nO(C[0])?2:3).every(Q=>Q<=0))[0])==null?void 0:i[0])||_[0][0];return P!==o?{data:{index:y+1,overflows:S},reset:{placement:P}}:{}}}},Uqn=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:o,platform:l,elements:c}=t,u=ov(e,t),{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:O="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0}=u,v=Qee(u,Fqn);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=xO(i),b=dw(o),T=xO(o)===o,x=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=f||(T||!m?[fA(o)]:Aqn(o)),k=g!=="none";!f&&k&&S.push(...Dqn(o,m,g,x));const _=[o,...S],P=await Iee(t,v),C=[];let Q=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&C.push(P[y]),h){const j=jUe(i,a,x);C.push(P[j[0]],P[j[1]])}if(Q=[...Q,{placement:i,overflows:C}],!C.every(j=>j<=0)){var E,A;const j=(((E=s.flip)==null?void 0:E.index)||0)+1,q=_[j];if(q)return{data:{index:j,overflows:Q},reset:{placement:q}};let z=(A=Q.filter(V=>V.overflows[0]<=0).sort((V,W)=>V.overflows[1]-W.overflows[1])[0])==null?void 0:A.placement;if(!z)switch(O){case"bestFit":{var L;const V=(L=Q.filter(W=>{if(k){const M=dw(W.placement);return M===b||M==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(M=>M>0).reduce((M,K)=>M+K,0)]).sort((W,M)=>W[1]-M[1])[0])==null?void 0:L[0];V&&(z=V);break}case"initialPlacement":z=o;break}if(i!==z)return{reset:{placement:z}}}return{}}}},Wqn=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,s=ov(e,t),{mainAxis:a=!0,crossAxis:o=!1,limiter:l={fn:v=>{let{x:y,y:b}=v;return{x:y,y:b}}}}=s,c=Qee(s,Mqn),u={x:n,y:r},d=await Iee(t,c),h=dw(xO(i)),f=Aee(h);let O=u[f],g=u[h];if(a){const v=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=O+d[v],T=O-d[y];O=TV(b,O,T)}if(o){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=g+d[v],T=g-d[y];g=TV(b,g,T)}const m=l.fn(Al({},t,{[f]:O,[h]:g}));return Al({},m,{data:{x:m.x-n,y:m.y-r}})}}},Gqn=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=t,{offset:o=0,mainAxis:l=!0,crossAxis:c=!0}=ov(e,t),u={x:n,y:r},d=dw(i),h=Aee(d);let f=u[h],O=u[d];const g=ov(o,t),m=typeof g=="number"?{mainAxis:g,crossAxis:0}:Al({mainAxis:0,crossAxis:0},g);if(l){const b=h==="y"?"height":"width",T=s.reference[h]-s.floating[b]+m.mainAxis,x=s.reference[h]+s.reference[b]-m.mainAxis;f<T?f=T:f>x&&(f=x)}if(c){var v,y;const b=h==="y"?"width":"height",T=["top","left"].includes(xO(i)),x=s.reference[d]-s.floating[b]+(T&&((v=a.offset)==null?void 0:v[d])||0)+(T?0:m.crossAxis),S=s.reference[d]+s.reference[b]+(T?0:((y=a.offset)==null?void 0:y[d])||0)-(T?m.crossAxis:0);O<x?O=x:O>S&&(O=S)}return{[h]:f,[d]:O}}}};function h6(){return typeof window<"u"}function ix(e){return zUe(e)?(e.nodeName||"").toLowerCase():"#document"}function yc(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Kh(e){var t;return(t=(zUe(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function zUe(e){return h6()?e instanceof Node||e instanceof yc(e).Node:!1}function md(e){return h6()?e instanceof Element||e instanceof yc(e).Element:!1}function Mh(e){return h6()?e instanceof HTMLElement||e instanceof yc(e).HTMLElement:!1}function mSe(e){return!h6()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yc(e).ShadowRoot}function IP(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=vd(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(i)}function Vqn(e){return["table","td","th"].includes(ix(e))}function f6(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Nee(e){const t=Fee(),n=md(e)?vd(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Bqn(e){let t=bg(e);for(;Mh(t)&&!hw(t);){if(Nee(t))return t;if(f6(t))return null;t=bg(t)}return null}function Fee(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function hw(e){return["html","body","#document"].includes(ix(e))}function vd(e){return yc(e).getComputedStyle(e)}function O6(e){return md(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function bg(e){if(ix(e)==="html")return e;const t=e.assignedSlot||e.parentNode||mSe(e)&&e.host||Kh(e);return mSe(t)?t.host:t}function UUe(e){const t=bg(e);return hw(t)?e.ownerDocument?e.ownerDocument.body:e.body:Mh(t)&&IP(t)?t:UUe(t)}function R_(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=UUe(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=yc(i);if(s){const o=_V(a);return t.concat(a,a.visualViewport||[],IP(i)?i:[],o&&n?R_(o):[])}return t.concat(i,R_(i,[],n))}function _V(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function WUe(e){const t=vd(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Mh(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,o=dA(n)!==s||dA(r)!==a;return o&&(n=s,r=a),{width:n,height:r,$:o}}function Mee(e){return md(e)?e:e.contextElement}function qb(e){const t=Mee(e);if(!Mh(t))return _h(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=WUe(t);let a=(s?dA(n.width):n.width)/r,o=(s?dA(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const Yqn=_h(0);function GUe(e){const t=yc(e);return!Fee()||!t.visualViewport?Yqn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Zqn(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yc(e)?!1:t}function lv(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=Mee(e);let a=_h(1);t&&(r?md(r)&&(a=qb(r)):a=qb(e));const o=Zqn(s,n,r)?GUe(s):_h(0);let l=(i.left+o.x)/a.x,c=(i.top+o.y)/a.y,u=i.width/a.x,d=i.height/a.y;if(s){const h=yc(s),f=r&&md(r)?yc(r):r;let O=h,g=_V(O);for(;g&&r&&f!==O;){const m=qb(g),v=g.getBoundingClientRect(),y=vd(g),b=v.left+(g.clientLeft+parseFloat(y.paddingLeft))*m.x,T=v.top+(g.clientTop+parseFloat(y.paddingTop))*m.y;l*=m.x,c*=m.y,u*=m.x,d*=m.y,l+=b,c+=T,O=yc(g),g=_V(O)}}return OA({width:u,height:d,x:l,y:c})}function Lee(e,t){const n=O6(e).scrollLeft;return t?t.left+n:lv(Kh(e)).left+n}function VUe(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),i=r.left+t.scrollLeft-(n?0:Lee(e,r)),s=r.top+t.scrollTop;return{x:i,y:s}}function Hqn(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=Kh(r),o=t?f6(t.floating):!1;if(r===a||o&&s)return n;let l={scrollLeft:0,scrollTop:0},c=_h(1);const u=_h(0),d=Mh(r);if((d||!d&&!s)&&((ix(r)!=="body"||IP(a))&&(l=O6(r)),Mh(r))){const f=lv(r);c=qb(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}const h=a&&!d&&!s?VUe(a,l,!0):_h(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function Kqn(e){return Array.from(e.getClientRects())}function Jqn(e){const t=Kh(e),n=O6(e),r=e.ownerDocument.body,i=p0(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=p0(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Lee(e);const o=-n.scrollTop;return vd(r).direction==="rtl"&&(a+=p0(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:o}}function ezn(e,t){const n=yc(e),r=Kh(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,o=0,l=0;if(i){s=i.width,a=i.height;const c=Fee();(!c||c&&t==="fixed")&&(o=i.offsetLeft,l=i.offsetTop)}return{width:s,height:a,x:o,y:l}}function tzn(e,t){const n=lv(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Mh(e)?qb(e):_h(1),a=e.clientWidth*s.x,o=e.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:a,height:o,x:l,y:c}}function vSe(e,t,n){let r;if(t==="viewport")r=ezn(e,n);else if(t==="document")r=Jqn(Kh(e));else if(md(t))r=tzn(t,n);else{const i=GUe(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return OA(r)}function BUe(e,t){const n=bg(e);return n===t||!md(n)||hw(n)?!1:vd(n).position==="fixed"||BUe(n,t)}function nzn(e,t){const n=t.get(e);if(n)return n;let r=R_(e,[],!1).filter(o=>md(o)&&ix(o)!=="body"),i=null;const s=vd(e).position==="fixed";let a=s?bg(e):e;for(;md(a)&&!hw(a);){const o=vd(a),l=Nee(a);!l&&o.position==="fixed"&&(i=null),(s?!l&&!i:!l&&o.position==="static"&&i&&["absolute","fixed"].includes(i.position)||IP(a)&&!l&&BUe(e,a))?r=r.filter(c=>c!==a):i=o,a=bg(a)}return t.set(e,r),r}function rzn(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[...n==="clippingAncestors"?f6(t)?[]:nzn(t,this._c):[].concat(n),r],a=s[0],o=s.reduce((l,c)=>{const u=vSe(t,c,i);return l.top=p0(u.top,l.top),l.right=uw(u.right,l.right),l.bottom=uw(u.bottom,l.bottom),l.left=p0(u.left,l.left),l},vSe(t,a,i));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}}function izn(e){const{width:t,height:n}=WUe(e);return{width:t,height:n}}function szn(e,t,n){const r=Mh(t),i=Kh(t),s=n==="fixed",a=lv(e,!0,s,t);let o={scrollLeft:0,scrollTop:0};const l=_h(0);if(r||!r&&!s)if((ix(t)!=="body"||IP(i))&&(o=O6(t)),r){const h=lv(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else i&&(l.x=Lee(i));const c=i&&!r&&!s?VUe(i,o):_h(0),u=a.left+o.scrollLeft-l.x-c.x,d=a.top+o.scrollTop-l.y-c.y;return{x:u,y:d,width:a.width,height:a.height}}function KL(e){return vd(e).position==="static"}function ySe(e,t){if(!Mh(e)||vd(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Kh(e)===n&&(n=n.ownerDocument.body),n}function YUe(e,t){const n=yc(e);if(f6(e))return n;if(!Mh(e)){let i=bg(e);for(;i&&!hw(i);){if(md(i)&&!KL(i))return i;i=bg(i)}return n}let r=ySe(e,t);for(;r&&Vqn(r)&&KL(r);)r=ySe(r,t);return r&&hw(r)&&KL(r)&&!Nee(r)?n:r||Bqn(e)||n}const azn=async function(e){const t=this.getOffsetParent||YUe,n=this.getDimensions,r=await n(e.floating);return{reference:szn(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ozn(e){return vd(e).direction==="rtl"}const lzn={convertOffsetParentRelativeRectToViewportRelativeRect:Hqn,getDocumentElement:Kh,getClippingRect:rzn,getOffsetParent:YUe,getElementRects:azn,getClientRects:Kqn,getDimensions:izn,getScale:qb,isElement:md,isRTL:ozn};function czn(e,t){let n=null,r;const i=Kh(e);function s(){var o;clearTimeout(r),(o=n)==null||o.disconnect(),n=null}function a(o,l){o===void 0&&(o=!1),l===void 0&&(l=1),s();const{left:c,top:u,width:d,height:h}=e.getBoundingClientRect();if(o||t(),!d||!h)return;const f=mQ(u),O=mQ(i.clientWidth-(c+d)),g=mQ(i.clientHeight-(u+h)),m=mQ(c),v={rootMargin:-f+"px "+-O+"px "+-g+"px "+-m+"px",threshold:p0(0,uw(1,l))||1};let y=!0;function b(T){const x=T[0].intersectionRatio;if(x!==l){if(!y)return a();x?a(!1,x):r=setTimeout(()=>{a(!1,1e-7)},1e3)}y=!1}try{n=new IntersectionObserver(b,Al({},v,{root:i.ownerDocument}))}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return a(!0),s}function uzn(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Mee(e),u=i||s?[...c?R_(c):[],...R_(t)]:[];u.forEach(v=>{i&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const d=c&&o?czn(c,n):null;let h=-1,f=null;a&&(f=new ResizeObserver(v=>{let[y]=v;y&&y.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var b;(b=f)==null||b.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let O,g=l?lv(e):null;l&&m();function m(){const v=lv(e);g&&(v.x!==g.x||v.y!==g.y||v.width!==g.width||v.height!==g.height)&&n(),g=v,O=requestAnimationFrame(m)}return n(),()=>{var v;u.forEach(y=>{i&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),d?.(),(v=f)==null||v.disconnect(),f=null,l&&cancelAnimationFrame(O)}}const dzn=zqn,hzn=Wqn,fzn=Uqn,Ozn=jqn,pzn=Gqn,gzn=(e,t,n)=>{const r=new Map,i=Al({platform:lzn},n),s=Al({},i.platform,{_c:r});return Lqn(e,t,Al({},i,{platform:s}))};function mzn(e){e.cleanup&&e.cleanup();const t=e._getResolvedAttachToOptions();let n=t.element;const r=Szn(t,e),i=MUe(t);return i&&(n=document.body,e.shepherdElementComponent.getElement().classList.add("shepherd-centered")),e.cleanup=uzn(n,e.el,()=>{if(!e.el){e.cleanup==null||e.cleanup();return}bzn(n,e,r,i)}),e.target=t.element,r}function vzn(e,t){return{floatingUIOptions:Eee(e.floatingUIOptions||{},t.floatingUIOptions||{})}}function yzn(e){e.cleanup&&e.cleanup(),e.cleanup=null}function bzn(e,t,n,r){return gzn(e,t.el,n).then(wzn(t,r)).then(i=>new Promise(s=>{setTimeout(()=>s(i),300)})).then(i=>{i!=null&&i.el&&i.el.focus({preventScroll:!0})})}function wzn(e,t){return({x:n,y:r,placement:i,middlewareData:s})=>(e.el&&(t?Object.assign(e.el.style,{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)"}):Object.assign(e.el.style,{position:"absolute",left:`${n}px`,top:`${r}px`}),e.el.dataset.popperPlacement=i,xzn(e.el,s)),e)}function xzn(e,t){const n=e.querySelector(".shepherd-arrow");if(cw(n)&&t.arrow){const{x:r,y:i}=t.arrow;Object.assign(n.style,{left:r!=null?`${r}px`:"",top:i!=null?`${i}px`:""})}}function Szn(e,t){var n,r,i;const s={strategy:"absolute"};s.middleware=[];const a=$zn(t),o=MUe(e),l=(n=e.on)==null?void 0:n.includes("auto"),c=(e==null||(r=e.on)==null?void 0:r.includes("-start"))||(e==null||(i=e.on)==null?void 0:i.includes("-end"));if(!o){if(l){var u;s.middleware.push(dzn({crossAxis:!0,alignment:c?e==null||(u=e.on)==null?void 0:u.split("-").pop():null}))}else s.middleware.push(fzn());if(s.middleware.push(hzn({limiter:pzn(),crossAxis:!0})),a){const d=typeof t.options.arrow=="object"?t.options.arrow:{padding:4};s.middleware.push(Ozn({element:a,padding:c?d.padding:0}))}l||(s.placement=e.on)}return Eee(s,t.options.floatingUIOptions||{})}function $zn(e){return e.options.arrow&&e.el?e.el.querySelector(".shepherd-arrow"):!1}function kc(){}function kzn(e,t){for(const n in t)e[n]=t[n];return e}function ZUe(e){return e()}function bSe(){return Object.create(null)}function NP(e){e.forEach(ZUe)}function jee(e){return typeof e=="function"}function IO(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Tzn(e){return Object.keys(e).length===0}function fw(e,t){e.appendChild(t)}function Cd(e,t,n){e.insertBefore(t,n||null)}function Cu(e){e.parentNode&&e.parentNode.removeChild(e)}function _zn(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function Lh(e){return document.createElement(e)}function wSe(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function HUe(e){return document.createTextNode(e)}function pA(){return HUe(" ")}function Pzn(){return HUe("")}function p6(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function wi(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}const Czn=["width","height"];function xSe(e,t){const n=Object.getOwnPropertyDescriptors(e.__proto__);for(const r in t)t[r]==null?e.removeAttribute(r):r==="style"?e.style.cssText=t[r]:r==="__value"?e.value=e[r]=t[r]:n[r]&&n[r].set&&Czn.indexOf(r)===-1?e[r]=t[r]:wi(e,r,t[r])}function Qzn(e){return Array.from(e.childNodes)}function _y(e,t,n){e.classList.toggle(t,!!n)}let A_;function H$(e){A_=e}function KUe(){if(!A_)throw new Error("Function called outside component initialization");return A_}function Ezn(e){KUe().$$.on_mount.push(e)}function qee(e){KUe().$$.after_update.push(e)}const jy=[],Ow=[];let zb=[];const SSe=[],Rzn=Promise.resolve();let PV=!1;function Azn(){PV||(PV=!0,Rzn.then(JUe))}function CV(e){zb.push(e)}const JL=new Set;let Py=0;function JUe(){if(Py!==0)return;const e=A_;do{try{for(;Py<jy.length;){const t=jy[Py];Py++,H$(t),Xzn(t.$$)}}catch(t){throw jy.length=0,Py=0,t}for(H$(null),jy.length=0,Py=0;Ow.length;)Ow.pop()();for(let t=0;t<zb.length;t+=1){const n=zb[t];JL.has(n)||(JL.add(n),n())}zb.length=0}while(jy.length);for(;SSe.length;)SSe.pop()();PV=!1,JL.clear(),H$(e)}function Xzn(e){if(e.fragment!==null){e.update(),NP(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(CV)}}function Dzn(e){const t=[],n=[];zb.forEach(r=>e.indexOf(r)===-1?t.push(r):n.push(r)),n.forEach(r=>r()),zb=t}const CE=new Set;let Gm;function g0(){Gm={r:0,c:[],p:Gm}}function m0(){Gm.r||NP(Gm.c),Gm=Gm.p}function ri(e,t){e&&e.i&&(CE.delete(e),e.i(t))}function Ps(e,t,n,r){if(e&&e.o){if(CE.has(e))return;CE.add(e),Gm.c.push(()=>{CE.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function $Se(e){return e?.length!==void 0?e:Array.from(e)}function Izn(e,t){const n={},r={},i={$$scope:1};let s=e.length;for(;s--;){const a=e[s],o=t[s];if(o){for(const l in a)l in o||(r[l]=1);for(const l in o)i[l]||(n[l]=o[l],i[l]=1);e[s]=o}else for(const l in a)i[l]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Gv(e){e&&e.c()}function Gg(e,t,n){const{fragment:r,after_update:i}=e.$$;r&&r.m(t,n),CV(()=>{const s=e.$$.on_mount.map(ZUe).filter(jee);e.$$.on_destroy?e.$$.on_destroy.push(...s):NP(s),e.$$.on_mount=[]}),i.forEach(CV)}function Vg(e,t){const n=e.$$;n.fragment!==null&&(Dzn(n.after_update),NP(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Nzn(e,t){e.$$.dirty[0]===-1&&(jy.push(e),Azn(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function NO(e,t,n,r,i,s,a=null,o=[-1]){const l=A_;H$(e);const c=e.$$={fragment:null,ctx:[],props:s,update:kc,not_equal:i,bound:bSe(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:bSe(),dirty:o,skip_bound:!1,root:t.target||l.$$.root};a&&a(c.root);let u=!1;if(c.ctx=n?n(e,t.props||{},(d,h,...f)=>{const O=f.length?f[0]:h;return c.ctx&&i(c.ctx[d],c.ctx[d]=O)&&(!c.skip_bound&&c.bound[d]&&c.bound[d](O),u&&Nzn(e,d)),h}):[],c.update(),u=!0,NP(c.before_update),c.fragment=r?r(c.ctx):!1,t.target){if(t.hydrate){const d=Qzn(t.target);c.fragment&&c.fragment.l(d),d.forEach(Cu)}else c.fragment&&c.fragment.c();t.intro&&ri(e.$$.fragment),Gg(e,t.target,t.anchor),JUe()}H$(l)}class FO{constructor(){this.$$=void 0,this.$$set=void 0}$destroy(){Vg(this,1),this.$destroy=kc}$on(t,n){if(!jee(n))return kc;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const i=r.indexOf(n);i!==-1&&r.splice(i,1)}}$set(t){this.$$set&&!Tzn(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Fzn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Fzn);function Mzn(e){let t,n,r,i,s;return{c(){t=Lh("button"),wi(t,"aria-label",n=e[3]?e[3]:null),wi(t,"class",r=`${e[1]||""} shepherd-button ${e[4]?"shepherd-button-secondary":""}`),t.disabled=e[2],wi(t,"tabindex","0"),wi(t,"type","button")},m(a,o){Cd(a,t,o),t.innerHTML=e[5],i||(s=p6(t,"click",function(){jee(e[0])&&e[0].apply(this,arguments)}),i=!0)},p(a,[o]){e=a,o&32&&(t.innerHTML=e[5]),o&8&&n!==(n=e[3]?e[3]:null)&&wi(t,"aria-label",n),o&18&&r!==(r=`${e[1]||""} shepherd-button ${e[4]?"shepherd-button-secondary":""}`)&&wi(t,"class",r),o&4&&(t.disabled=e[2])},i:kc,o:kc,d(a){a&&Cu(t),i=!1,s()}}}function Lzn(e,t,n){let{config:r,step:i}=t,s,a,o,l,c,u;function d(h){return yg(h)?h=h.call(i):h}return e.$$set=h=>{"config"in h&&n(6,r=h.config),"step"in h&&n(7,i=h.step)},e.$$.update=()=>{e.$$.dirty&192&&(n(0,s=r.action?r.action.bind(i.tour):null),n(1,a=r.classes),n(2,o=r.disabled?d(r.disabled):!1),n(3,l=r.label?d(r.label):null),n(4,c=r.secondary),n(5,u=r.text?d(r.text):null))},[s,a,o,l,c,u,r,i]}class jzn extends FO{constructor(t){super(),NO(this,t,Lzn,Mzn,IO,{config:6,step:7})}}function kSe(e,t,n){const r=e.slice();return r[2]=t[n],r}function TSe(e){let t,n,r=$Se(e[1]),i=[];for(let a=0;a<r.length;a+=1)i[a]=_Se(kSe(e,r,a));const s=a=>Ps(i[a],1,1,()=>{i[a]=null});return{c(){for(let a=0;a<i.length;a+=1)i[a].c();t=Pzn()},m(a,o){for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(a,o);Cd(a,t,o),n=!0},p(a,o){if(o&3){r=$Se(a[1]);let l;for(l=0;l<r.length;l+=1){const c=kSe(a,r,l);i[l]?(i[l].p(c,o),ri(i[l],1)):(i[l]=_Se(c),i[l].c(),ri(i[l],1),i[l].m(t.parentNode,t))}for(g0(),l=r.length;l<i.length;l+=1)s(l);m0()}},i(a){if(!n){for(let o=0;o<r.length;o+=1)ri(i[o]);n=!0}},o(a){i=i.filter(Boolean);for(let o=0;o<i.length;o+=1)Ps(i[o]);n=!1},d(a){a&&Cu(t),_zn(i,a)}}}function _Se(e){let t,n;return t=new jzn({props:{config:e[2],step:e[0]}}),{c(){Gv(t.$$.fragment)},m(r,i){Gg(t,r,i),n=!0},p(r,i){const s={};i&2&&(s.config=r[2]),i&1&&(s.step=r[0]),t.$set(s)},i(r){n||(ri(t.$$.fragment,r),n=!0)},o(r){Ps(t.$$.fragment,r),n=!1},d(r){Vg(t,r)}}}function qzn(e){let t,n,r=e[1]&&TSe(e);return{c(){t=Lh("footer"),r&&r.c(),wi(t,"class","shepherd-footer")},m(i,s){Cd(i,t,s),r&&r.m(t,null),n=!0},p(i,[s]){i[1]?r?(r.p(i,s),s&2&&ri(r,1)):(r=TSe(i),r.c(),ri(r,1),r.m(t,null)):r&&(g0(),Ps(r,1,1,()=>{r=null}),m0())},i(i){n||(ri(r),n=!0)},o(i){Ps(r),n=!1},d(i){i&&Cu(t),r&&r.d()}}}function zzn(e,t,n){let r,{step:i}=t;return e.$$set=s=>{"step"in s&&n(0,i=s.step)},e.$$.update=()=>{e.$$.dirty&1&&n(1,r=i.options.buttons)},[i,r]}class Uzn extends FO{constructor(t){super(),NO(this,t,zzn,qzn,IO,{step:0})}}function Wzn(e){let t,n,r,i,s;return{c(){t=Lh("button"),n=Lh("span"),n.textContent="×",wi(n,"aria-hidden","true"),wi(t,"aria-label",r=e[0].label?e[0].label:"Close Tour"),wi(t,"class","shepherd-cancel-icon"),wi(t,"type","button")},m(a,o){Cd(a,t,o),fw(t,n),i||(s=p6(t,"click",e[1]),i=!0)},p(a,[o]){o&1&&r!==(r=a[0].label?a[0].label:"Close Tour")&&wi(t,"aria-label",r)},i:kc,o:kc,d(a){a&&Cu(t),i=!1,s()}}}function Gzn(e,t,n){let{cancelIcon:r,step:i}=t;const s=a=>{a.preventDefault(),i.cancel()};return e.$$set=a=>{"cancelIcon"in a&&n(0,r=a.cancelIcon),"step"in a&&n(2,i=a.step)},[r,s,i]}class Vzn extends FO{constructor(t){super(),NO(this,t,Gzn,Wzn,IO,{cancelIcon:0,step:2})}}function Bzn(e){let t;return{c(){t=Lh("h3"),wi(t,"id",e[1]),wi(t,"class","shepherd-title")},m(n,r){Cd(n,t,r),e[3](t)},p(n,[r]){r&2&&wi(t,"id",n[1])},i:kc,o:kc,d(n){n&&Cu(t),e[3](null)}}}function Yzn(e,t,n){let{labelId:r,element:i,title:s}=t;qee(()=>{yg(s)&&n(2,s=s()),n(0,i.innerHTML=s,i)});function a(o){Ow[o?"unshift":"push"](()=>{i=o,n(0,i)})}return e.$$set=o=>{"labelId"in o&&n(1,r=o.labelId),"element"in o&&n(0,i=o.element),"title"in o&&n(2,s=o.title)},[i,r,s,a]}class Zzn extends FO{constructor(t){super(),NO(this,t,Yzn,Bzn,IO,{labelId:1,element:0,title:2})}}function PSe(e){let t,n;return t=new Zzn({props:{labelId:e[0],title:e[2]}}),{c(){Gv(t.$$.fragment)},m(r,i){Gg(t,r,i),n=!0},p(r,i){const s={};i&1&&(s.labelId=r[0]),i&4&&(s.title=r[2]),t.$set(s)},i(r){n||(ri(t.$$.fragment,r),n=!0)},o(r){Ps(t.$$.fragment,r),n=!1},d(r){Vg(t,r)}}}function CSe(e){let t,n;return t=new Vzn({props:{cancelIcon:e[3],step:e[1]}}),{c(){Gv(t.$$.fragment)},m(r,i){Gg(t,r,i),n=!0},p(r,i){const s={};i&8&&(s.cancelIcon=r[3]),i&2&&(s.step=r[1]),t.$set(s)},i(r){n||(ri(t.$$.fragment,r),n=!0)},o(r){Ps(t.$$.fragment,r),n=!1},d(r){Vg(t,r)}}}function Hzn(e){let t,n,r,i=e[2]&&PSe(e),s=e[3]&&e[3].enabled&&CSe(e);return{c(){t=Lh("header"),i&&i.c(),n=pA(),s&&s.c(),wi(t,"class","shepherd-header")},m(a,o){Cd(a,t,o),i&&i.m(t,null),fw(t,n),s&&s.m(t,null),r=!0},p(a,[o]){a[2]?i?(i.p(a,o),o&4&&ri(i,1)):(i=PSe(a),i.c(),ri(i,1),i.m(t,n)):i&&(g0(),Ps(i,1,1,()=>{i=null}),m0()),a[3]&&a[3].enabled?s?(s.p(a,o),o&8&&ri(s,1)):(s=CSe(a),s.c(),ri(s,1),s.m(t,null)):s&&(g0(),Ps(s,1,1,()=>{s=null}),m0())},i(a){r||(ri(i),ri(s),r=!0)},o(a){Ps(i),Ps(s),r=!1},d(a){a&&Cu(t),i&&i.d(),s&&s.d()}}}function Kzn(e,t,n){let{labelId:r,step:i}=t,s,a;return e.$$set=o=>{"labelId"in o&&n(0,r=o.labelId),"step"in o&&n(1,i=o.step)},e.$$.update=()=>{e.$$.dirty&2&&(n(2,s=i.options.title),n(3,a=i.options.cancelIcon))},[r,i,s,a]}class Jzn extends FO{constructor(t){super(),NO(this,t,Kzn,Hzn,IO,{labelId:0,step:1})}}function eUn(e){let t;return{c(){t=Lh("div"),wi(t,"class","shepherd-text"),wi(t,"id",e[1])},m(n,r){Cd(n,t,r),e[3](t)},p(n,[r]){r&2&&wi(t,"id",n[1])},i:kc,o:kc,d(n){n&&Cu(t),e[3](null)}}}function tUn(e,t,n){let{descriptionId:r,element:i,step:s}=t;qee(()=>{let{text:o}=s.options;yg(o)&&(o=o.call(s)),cw(o)?i.appendChild(o):n(0,i.innerHTML=o,i)});function a(o){Ow[o?"unshift":"push"](()=>{i=o,n(0,i)})}return e.$$set=o=>{"descriptionId"in o&&n(1,r=o.descriptionId),"element"in o&&n(0,i=o.element),"step"in o&&n(2,s=o.step)},[i,r,s,a]}class nUn extends FO{constructor(t){super(),NO(this,t,tUn,eUn,IO,{descriptionId:1,element:0,step:2})}}function QSe(e){let t,n;return t=new Jzn({props:{labelId:e[1],step:e[2]}}),{c(){Gv(t.$$.fragment)},m(r,i){Gg(t,r,i),n=!0},p(r,i){const s={};i&2&&(s.labelId=r[1]),i&4&&(s.step=r[2]),t.$set(s)},i(r){n||(ri(t.$$.fragment,r),n=!0)},o(r){Ps(t.$$.fragment,r),n=!1},d(r){Vg(t,r)}}}function ESe(e){let t,n;return t=new nUn({props:{descriptionId:e[0],step:e[2]}}),{c(){Gv(t.$$.fragment)},m(r,i){Gg(t,r,i),n=!0},p(r,i){const s={};i&1&&(s.descriptionId=r[0]),i&4&&(s.step=r[2]),t.$set(s)},i(r){n||(ri(t.$$.fragment,r),n=!0)},o(r){Ps(t.$$.fragment,r),n=!1},d(r){Vg(t,r)}}}function RSe(e){let t,n;return t=new Uzn({props:{step:e[2]}}),{c(){Gv(t.$$.fragment)},m(r,i){Gg(t,r,i),n=!0},p(r,i){const s={};i&4&&(s.step=r[2]),t.$set(s)},i(r){n||(ri(t.$$.fragment,r),n=!0)},o(r){Ps(t.$$.fragment,r),n=!1},d(r){Vg(t,r)}}}function rUn(e){let t,n=!wo(e[2].options.title)||e[2].options.cancelIcon&&e[2].options.cancelIcon.enabled,r,i=!wo(e[2].options.text),s,a=Array.isArray(e[2].options.buttons)&&e[2].options.buttons.length,o,l=n&&QSe(e),c=i&&ESe(e),u=a&&RSe(e);return{c(){t=Lh("div"),l&&l.c(),r=pA(),c&&c.c(),s=pA(),u&&u.c(),wi(t,"class","shepherd-content")},m(d,h){Cd(d,t,h),l&&l.m(t,null),fw(t,r),c&&c.m(t,null),fw(t,s),u&&u.m(t,null),o=!0},p(d,[h]){h&4&&(n=!wo(d[2].options.title)||d[2].options.cancelIcon&&d[2].options.cancelIcon.enabled),n?l?(l.p(d,h),h&4&&ri(l,1)):(l=QSe(d),l.c(),ri(l,1),l.m(t,r)):l&&(g0(),Ps(l,1,1,()=>{l=null}),m0()),h&4&&(i=!wo(d[2].options.text)),i?c?(c.p(d,h),h&4&&ri(c,1)):(c=ESe(d),c.c(),ri(c,1),c.m(t,s)):c&&(g0(),Ps(c,1,1,()=>{c=null}),m0()),h&4&&(a=Array.isArray(d[2].options.buttons)&&d[2].options.buttons.length),a?u?(u.p(d,h),h&4&&ri(u,1)):(u=RSe(d),u.c(),ri(u,1),u.m(t,null)):u&&(g0(),Ps(u,1,1,()=>{u=null}),m0())},i(d){o||(ri(l),ri(c),ri(u),o=!0)},o(d){Ps(l),Ps(c),Ps(u),o=!1},d(d){d&&Cu(t),l&&l.d(),c&&c.d(),u&&u.d()}}}function iUn(e,t,n){let{descriptionId:r,labelId:i,step:s}=t;return e.$$set=a=>{"descriptionId"in a&&n(0,r=a.descriptionId),"labelId"in a&&n(1,i=a.labelId),"step"in a&&n(2,s=a.step)},[r,i,s]}class sUn extends FO{constructor(t){super(),NO(this,t,iUn,rUn,IO,{descriptionId:0,labelId:1,step:2})}}function ASe(e){let t;return{c(){t=Lh("div"),wi(t,"class","shepherd-arrow"),wi(t,"data-popper-arrow","")},m(n,r){Cd(n,t,r)},d(n){n&&Cu(t)}}}function aUn(e){let t,n,r,i,s,a,o,l,c=e[4].options.arrow&&e[4].options.attachTo&&e[4].options.attachTo.element&&e[4].options.attachTo.on&&ASe();r=new sUn({props:{descriptionId:e[2],labelId:e[3],step:e[4]}});let u=[{"aria-describedby":i=wo(e[4].options.text)?null:e[2]},{"aria-labelledby":s=e[4].options.title?e[3]:null},e[1],{open:"true"}],d={};for(let h=0;h<u.length;h+=1)d=kzn(d,u[h]);return{c(){t=Lh("dialog"),c&&c.c(),n=pA(),Gv(r.$$.fragment),xSe(t,d),_y(t,"shepherd-has-cancel-icon",e[5]),_y(t,"shepherd-has-title",e[6]),_y(t,"shepherd-element",!0)},m(h,f){Cd(h,t,f),c&&c.m(t,null),fw(t,n),Gg(r,t,null),e[13](t),a=!0,o||(l=p6(t,"keydown",e[7]),o=!0)},p(h,[f]){h[4].options.arrow&&h[4].options.attachTo&&h[4].options.attachTo.element&&h[4].options.attachTo.on?c||(c=ASe(),c.c(),c.m(t,n)):c&&(c.d(1),c=null);const O={};f&4&&(O.descriptionId=h[2]),f&8&&(O.labelId=h[3]),f&16&&(O.step=h[4]),r.$set(O),xSe(t,d=Izn(u,[(!a||f&20&&i!==(i=wo(h[4].options.text)?null:h[2]))&&{"aria-describedby":i},(!a||f&24&&s!==(s=h[4].options.title?h[3]:null))&&{"aria-labelledby":s},f&2&&h[1],{open:"true"}])),_y(t,"shepherd-has-cancel-icon",h[5]),_y(t,"shepherd-has-title",h[6]),_y(t,"shepherd-element",!0)},i(h){a||(ri(r.$$.fragment,h),a=!0)},o(h){Ps(r.$$.fragment,h),a=!1},d(h){h&&Cu(t),c&&c.d(),Vg(r),e[13](null),o=!1,l()}}}const oUn=9,lUn=27,cUn=37,uUn=39;function XSe(e){return e.split(" ").filter(t=>!!t.length)}function dUn(e,t,n){let{classPrefix:r,element:i,descriptionId:s,firstFocusableElement:a,focusableElements:o,labelId:l,lastFocusableElement:c,step:u,dataStepId:d}=t,h,f,O;const g=()=>i;Ezn(()=>{n(1,d={[`data-${r}shepherd-step-id`]:u.id}),n(9,o=i.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]')),n(8,a=o[0]),n(10,c=o[o.length-1])}),qee(()=>{O!==u.options.classes&&m()});function m(){v(O),O=u.options.classes,y(O)}function v(x){if(E_(x)){const S=XSe(x);S.length&&i.classList.remove(...S)}}function y(x){if(E_(x)){const S=XSe(x);S.length&&i.classList.add(...S)}}const b=x=>{const{tour:S}=u;switch(x.keyCode){case oUn:if(o.length===0){x.preventDefault();break}x.shiftKey?(document.activeElement===a||document.activeElement.classList.contains("shepherd-element"))&&(x.preventDefault(),c.focus()):document.activeElement===c&&(x.preventDefault(),a.focus());break;case lUn:S.options.exitOnEsc&&(x.preventDefault(),x.stopPropagation(),u.cancel());break;case cUn:S.options.keyboardNavigation&&(x.preventDefault(),x.stopPropagation(),S.back());break;case uUn:S.options.keyboardNavigation&&(x.preventDefault(),x.stopPropagation(),S.next());break}};function T(x){Ow[x?"unshift":"push"](()=>{i=x,n(0,i)})}return e.$$set=x=>{"classPrefix"in x&&n(11,r=x.classPrefix),"element"in x&&n(0,i=x.element),"descriptionId"in x&&n(2,s=x.descriptionId),"firstFocusableElement"in x&&n(8,a=x.firstFocusableElement),"focusableElements"in x&&n(9,o=x.focusableElements),"labelId"in x&&n(3,l=x.labelId),"lastFocusableElement"in x&&n(10,c=x.lastFocusableElement),"step"in x&&n(4,u=x.step),"dataStepId"in x&&n(1,d=x.dataStepId)},e.$$.update=()=>{e.$$.dirty&16&&(n(5,h=u.options&&u.options.cancelIcon&&u.options.cancelIcon.enabled),n(6,f=u.options&&u.options.title))},[i,d,s,l,u,h,f,b,a,o,c,r,g,T]}class hUn extends FO{constructor(t){super(),NO(this,t,dUn,aUn,IO,{classPrefix:11,element:0,descriptionId:2,firstFocusableElement:8,focusableElements:9,labelId:3,lastFocusableElement:10,step:4,dataStepId:1,getElement:12})}get getElement(){return this.$$.ctx[12]}}class QV extends Cee{constructor(t,n={}){return super(),this._resolvedAttachTo=void 0,this._resolvedExtraHighlightElements=void 0,this.classPrefix=void 0,this.el=void 0,this.target=void 0,this.tour=void 0,this.tour=t,this.classPrefix=this.tour.options?FUe(this.tour.options.classPrefix):"",this.styles=t.styles,this._resolvedAttachTo=null,Ree(this),this._setOptions(n),this}cancel(){this.tour.cancel(),this.trigger("cancel")}complete(){this.tour.complete(),this.trigger("complete")}destroy(){yzn(this),cw(this.el)&&(this.el.remove(),this.el=null),this._updateStepTargetOnHide(),this.trigger("destroy")}getTour(){return this.tour}hide(){var t;(t=this.tour.modal)==null||t.hide(),this.trigger("before-hide"),this.el&&(this.el.hidden=!0),this._updateStepTargetOnHide(),this.trigger("hide")}_resolveExtraHiglightElements(){return this._resolvedExtraHighlightElements=Cqn(this),this._resolvedExtraHighlightElements}_resolveAttachToOptions(){return this._resolvedAttachTo=Pqn(this),this._resolvedAttachTo}_getResolvedAttachToOptions(){return this._resolvedAttachTo===null?this._resolveAttachToOptions():this._resolvedAttachTo}isOpen(){return!!(this.el&&!this.el.hidden)}show(){return yg(this.options.beforeShowPromise)?Promise.resolve(this.options.beforeShowPromise()).then(()=>this._show()):Promise.resolve(this._show())}updateStepOptions(t){Object.assign(this.options,t),this.shepherdElementComponent&&this.shepherdElementComponent.$set({step:this})}getElement(){return this.el}getTarget(){return this.target}_createTooltipContent(){const t=`${this.id}-description`,n=`${this.id}-label`;return this.shepherdElementComponent=new hUn({target:this.tour.options.stepsContainer||document.body,props:{classPrefix:this.classPrefix,descriptionId:t,labelId:n,step:this,styles:this.styles}}),this.shepherdElementComponent.getElement()}_scrollTo(t){const{element:n}=this._getResolvedAttachToOptions();yg(this.options.scrollToHandler)?this.options.scrollToHandler(n):oqn(n)&&typeof n.scrollIntoView=="function"&&n.scrollIntoView(t)}_getClassOptions(t){const n=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions,r=t.classes?t.classes:"",i=n&&n.classes?n.classes:"",s=[...r.split(" "),...i.split(" ")],a=new Set(s);return Array.from(a).join(" ").trim()}_setOptions(t={}){let n=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions;n=Eee({},n||{}),this.options=Object.assign({arrow:!0},n,t,vzn(n,t));const{when:r}=this.options;this.options.classes=this._getClassOptions(t),this.destroy(),this.id=this.options.id||`step-${LUe()}`,r&&Object.keys(r).forEach(i=>{this.on(i,r[i],this)})}_setupElements(){wo(this.el)||this.destroy(),this.el=this._createTooltipContent(),this.options.advanceOn&&kqn(this),mzn(this)}_show(){var t;this.trigger("before-show"),this._resolveAttachToOptions(),this._resolveExtraHiglightElements(),this._setupElements(),this.tour.modal||this.tour.setupModal(),(t=this.tour.modal)==null||t.setupForStep(this),this._styleTargetElementForStep(this),this.el&&(this.el.hidden=!1),this.options.scrollTo&&setTimeout(()=>{this._scrollTo(this.options.scrollTo)}),this.el&&(this.el.hidden=!1);const n=this.shepherdElementComponent.getElement(),r=this.target||document.body,i=this._resolvedExtraHighlightElements;r.classList.add(`${this.classPrefix}shepherd-enabled`),r.classList.add(`${this.classPrefix}shepherd-target`),n.classList.add("shepherd-enabled"),i?.forEach(s=>{s.classList.add(`${this.classPrefix}shepherd-enabled`),s.classList.add(`${this.classPrefix}shepherd-target`)}),this.trigger("show")}_styleTargetElementForStep(t){const n=t.target,r=t._resolvedExtraHighlightElements;if(!n)return;const i=t.options.highlightClass;i&&(n.classList.add(i),r?.forEach(s=>s.classList.add(i))),n.classList.remove("shepherd-target-click-disabled"),r?.forEach(s=>s.classList.remove("shepherd-target-click-disabled")),t.options.canClickTarget===!1&&(n.classList.add("shepherd-target-click-disabled"),r?.forEach(s=>s.classList.add("shepherd-target-click-disabled")))}_updateStepTargetOnHide(){const t=this.target||document.body,n=this._resolvedExtraHighlightElements,r=this.options.highlightClass;r&&(t.classList.remove(r),n?.forEach(i=>i.classList.remove(r))),t.classList.remove("shepherd-target-click-disabled",`${this.classPrefix}shepherd-enabled`,`${this.classPrefix}shepherd-target`),n?.forEach(i=>{i.classList.remove("shepherd-target-click-disabled",`${this.classPrefix}shepherd-enabled`,`${this.classPrefix}shepherd-target`)})}}function fUn(e){if(e){const{steps:t}=e;t.forEach(n=>{n.options&&n.options.canClickTarget===!1&&n.options.attachTo&&(cw(n.target)&&n.target.classList.remove("shepherd-target-click-disabled"),n._resolvedExtraHighlightElements&&n._resolvedExtraHighlightElements.forEach(r=>{cw(r)&&r.classList.remove("shepherd-target-click-disabled")}))})}}function OUn(e){let t="";const{innerWidth:n,innerHeight:r}=window;return e.forEach(i=>{const{width:s,height:a,x:o=0,y:l=0,r:c=0}=i,{topLeft:u=0,topRight:d=0,bottomRight:h=0,bottomLeft:f=0}=typeof c=="number"?{topLeft:c,topRight:c,bottomRight:c,bottomLeft:c}:c;t+=`M${o+u},${l} a${u},${u},0,0,0-${u},${u} V${a+l-f} a${f},${f},0,0,0,${f},${f} H${s+o-h} a${h},${h},0,0,0,${h}-${h} V${l+d} a${d},${d},0,0,0-${d}-${d} Z`}),`M${n},${r} H0 V0 H${n} V${r} Z ${t}`.replace(/\s/g,"")}function pUn(e){let t,n,r,i,s;return{c(){t=wSe("svg"),n=wSe("path"),wi(n,"d",e[2]),wi(t,"class",r=`${e[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)},m(a,o){Cd(a,t,o),fw(t,n),e[11](t),i||(s=p6(t,"touchmove",e[3]),i=!0)},p(a,[o]){o&4&&wi(n,"d",a[2]),o&2&&r!==(r=`${a[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)&&wi(t,"class",r)},i:kc,o:kc,d(a){a&&Cu(t),e[11](null),i=!1,s()}}}function eWe(e){if(!e)return null;const t=e instanceof HTMLElement&&window.getComputedStyle(e).overflowY;return t!=="hidden"&&t!=="visible"&&e.scrollHeight>=e.clientHeight?e:eWe(e.parentElement)}function gUn(e){let t={top:0,left:0};if(!e)return t;let n=e.ownerDocument.defaultView;for(;n!==window.top;){var r;const a=(r=n)==null?void 0:r.frameElement;if(a){var i,s;const o=a.getBoundingClientRect();t.top+=o.top+((i=o.scrollTop)!=null?i:0),t.left+=o.left+((s=o.scrollLeft)!=null?s:0)}n=n.parent}return t}function mUn(e,t){const n=e.getBoundingClientRect();let r=n.y||n.top,i=n.bottom||r+n.height;if(t){const a=t.getBoundingClientRect(),o=a.y||a.top,l=a.bottom||o+a.height;r=Math.max(r,o),i=Math.min(i,l)}const s=Math.max(i-r,0);return{y:r,height:s}}function vUn(e,t,n){let{element:r,openingProperties:i}=t,s=!1,a,o;c();const l=()=>r;function c(){n(4,i=[{width:0,height:0,x:0,y:0,r:0}])}function u(){n(1,s=!1),v()}function d(T=0,x=0,S=0,k=0,_,P,C){if(P){const Q=[P,...C||[]];n(4,i=[]);for(const E of Q){if(!E||Q.indexOf(E)!==Q.lastIndexOf(E))continue;const{y:A,height:L}=mUn(E,_),{x:j,width:q,left:z}=E.getBoundingClientRect();Q.some(V=>{if(V===E)return!1;const W=V.getBoundingClientRect();return j>=W.left&&j+q<=W.right&&A>=W.top&&A+L<=W.bottom})||i.push({width:q+T*2,height:L+T*2,x:(j||z)+S-T,y:A+k-T,r:x})}}else c()}function h(T){v(),T.tour.options.useModalOverlay?(y(T),f()):u()}function f(){n(1,s=!0)}const O=T=>{T.preventDefault()},g=T=>{T.stopPropagation()};function m(){window.addEventListener("touchmove",O,{passive:!1})}function v(){a&&(cancelAnimationFrame(a),a=void 0),window.removeEventListener("touchmove",O,{passive:!1})}function y(T){const{modalOverlayOpeningPadding:x,modalOverlayOpeningRadius:S,modalOverlayOpeningXOffset:k=0,modalOverlayOpeningYOffset:_=0}=T.options,P=gUn(T.target),C=eWe(T.target),Q=()=>{a=void 0,d(x,S,k+P.left,_+P.top,C,T.target,T._resolvedExtraHighlightElements),a=requestAnimationFrame(Q)};Q(),m()}function b(T){Ow[T?"unshift":"push"](()=>{r=T,n(0,r)})}return e.$$set=T=>{"element"in T&&n(0,r=T.element),"openingProperties"in T&&n(4,i=T.openingProperties)},e.$$.update=()=>{e.$$.dirty&16&&n(2,o=OUn(i))},[r,s,o,g,i,l,c,u,d,h,f,b]}class yUn extends FO{constructor(t){super(),NO(this,t,vUn,pUn,IO,{element:0,openingProperties:4,getElement:5,closeModalOpening:6,hide:7,positionModal:8,setupForStep:9,show:10})}get getElement(){return this.$$.ctx[5]}get closeModalOpening(){return this.$$.ctx[6]}get hide(){return this.$$.ctx[7]}get positionModal(){return this.$$.ctx[8]}get setupForStep(){return this.$$.ctx[9]}get show(){return this.$$.ctx[10]}}class bUn extends Cee{constructor(){super(),this.activeTour=void 0,Ree(this)}}class wUn extends Cee{constructor(t={}){super(),this.trackedEvents=["active","cancel","complete","show"],this.classPrefix=void 0,this.currentStep=void 0,this.focusedElBeforeOpen=void 0,this.id=void 0,this.modal=void 0,this.options=void 0,this.steps=void 0,Ree(this);const n={exitOnEsc:!0,keyboardNavigation:!0};return this.options=Object.assign({},n,t),this.classPrefix=FUe(this.options.classPrefix),this.steps=[],this.addSteps(this.options.steps),["active","cancel","complete","inactive","show","start"].map(r=>{(i=>{this.on(i,s=>{s=s||{},s.tour=this,Vm.trigger(i,s)})})(r)}),this._setTourID(t.id),this}addStep(t,n){let r=t;return r instanceof QV?r.tour=this:r=new QV(this,r),wo(n)?this.steps.push(r):this.steps.splice(n,0,r),r}addSteps(t){return Array.isArray(t)&&t.forEach(n=>{this.addStep(n)}),this}back(){const t=this.steps.indexOf(this.currentStep);this.show(t-1,!1)}async cancel(){if(this.options.confirmCancel){const t=this.options.confirmCancelMessage||"Are you sure you want to stop the tour?";let n;yg(this.options.confirmCancel)?n=await this.options.confirmCancel():n=window.confirm(t),n&&this._done("cancel")}else this._done("cancel")}complete(){this._done("complete")}getById(t){return this.steps.find(n=>n.id===t)}getCurrentStep(){return this.currentStep}hide(){const t=this.getCurrentStep();if(t)return t.hide()}isActive(){return Vm.activeTour===this}next(){const t=this.steps.indexOf(this.currentStep);t===this.steps.length-1?this.complete():this.show(t+1,!0)}removeStep(t){const n=this.getCurrentStep();this.steps.some((r,i)=>{if(r.id===t)return r.isOpen()&&r.hide(),r.destroy(),this.steps.splice(i,1),!0}),n&&n.id===t&&(this.currentStep=void 0,this.steps.length?this.show(0):this.cancel())}show(t=0,n=!0){const r=E_(t)?this.getById(t):this.steps[t];r&&(this._updateStateBeforeShow(),yg(r.options.showOn)&&!r.options.showOn()?this._skipStep(r,n):(this.currentStep=r,this.trigger("show",{step:r,previous:this.currentStep}),r.show()))}async start(){this.trigger("start"),this.focusedElBeforeOpen=document.activeElement,this.currentStep=null,this.setupModal(),this._setupActiveTour(),this.next()}_done(t){const n=this.steps.indexOf(this.currentStep);if(Array.isArray(this.steps)&&this.steps.forEach(r=>r.destroy()),fUn(this),this.trigger(t,{index:n}),Vm.activeTour=null,this.trigger("inactive",{tour:this}),this.modal&&this.modal.hide(),(t==="cancel"||t==="complete")&&this.modal){const r=document.querySelector(".shepherd-modal-overlay-container");r&&(r.remove(),this.modal=null)}cw(this.focusedElBeforeOpen)&&this.focusedElBeforeOpen.focus()}_setupActiveTour(){this.trigger("active",{tour:this}),Vm.activeTour=this}setupModal(){this.modal=new yUn({target:this.options.modalContainer||document.body,props:{styles:this.styles}})}_skipStep(t,n){const r=this.steps.indexOf(t);if(r===this.steps.length-1)this.complete();else{const i=n?r+1:r-1;this.show(i,n)}}_updateStateBeforeShow(){this.currentStep&&this.currentStep.hide(),this.isActive()||this._setupActiveTour()}_setTourID(t){const n=this.options.tourName||"tour",r=t||LUe();this.id=`${n}--${r}`}}const Vm=new bUn,tWe=typeof window>"u";Vm.Step=tWe?Tqn:QV;Vm.Tour=tWe?_qn:wUn;const g6=w.createContext(void 0);g6.Consumer;const xUn=({children:e})=>aqn.jsx(g6.Provider,{value:{Shepherd:Vm},children:e}),SUn=""+new URL("agentic-sequence-CExfswgi.png",import.meta.url).href,$Un=""+new URL("canvas-code-inline-edit-DLji9b0m.png",import.meta.url).href,kUn=""+new URL("canvas-overview-CruGEIRC.png",import.meta.url).href,TUn=""+new URL("canvas-variables-view-DrA20zqs.png",import.meta.url).href,_Un=""+new URL("chat-attachments-_3cRrONU.png",import.meta.url).href,PUn=""+new URL("chat-full-view-e-eJPzrw.png",import.meta.url).href,CUn=""+new URL("chat-input-CU-CA7Se.png",import.meta.url).href,QUn=""+new URL("inline-edit-canvas-O9conTkE.png",import.meta.url).href,EUn=e=>{const t=Array.from(document.querySelectorAll(`[data-tour-tag="${e}"]`));return t.find(n=>n.offsetParent!==null)??t[0]??null},DSe=e=>{document.querySelector(`[data-tour-action="${e}"]`)?.click()},ISe=[{id:"welcome",title:"Welcome to Local Operator",text:`Local Operator is an AI agents platform that allows you to create a team of proactive AI agents that support you and help to reduce your daily workload.<br/><img src="${PUn}" alt="Chat full view" style="width: 100%; height: 350px; object-fit: contain; border-radius: 8px;"/><br />These agents are different from simple chatbots because they can actually do things for you on your computer like create files, run code and analytics, edit images, videos, and PDFs, organize your system, and much more.<br/><br/>In this walkthrough we'll cover:<ul><li>Creating agents</li><li>Making agents do things</li><li>The canvas workspace</li><li>Customizing agents</li><li>Agent hub for sharing and collaborating</li><li>Schedules for proactive agents</li><li>Settings for customization</li></ul>Let's explore how it works.`,buttons:[{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"agent-list",attachTo:{element:'[data-tour-tag="agent-list-panel"]',on:"right"},title:"Your agents",text:"On the left, you'll see a list of your available AI agents. You can select an agent to start a conversation or manage its settings. Think of this as your messenger contacts list, but for AI agents. There are no limits to how many agents you can have, so create as many as you need to handle all your daily tasks.<br/><br/>Use the create agents button at the top of the toolbar to create a new agent at any time. You can also import agents from the Agent hub, which we will cover later in this tour.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"select-agent",attachTo:{element:'[data-tour-tag="agent-list-item-button-0"]',on:"right"},title:"Select an agent",text:"Click on an agent to open the chat window to pull up your conversation with it. This will show the messages that you have sent them and the responses and actions that they have taken.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="agent-list-item-button-0"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"chat-input",attachTo:{element:'[data-tour-tag="chat-input-textarea"]',on:"top"},title:"Ask your agent anything",text:`Type your request here. Agents can answer questions, perform tasks, search the web, and much more. When you create a new agent, you'll see suggested prompts for ideas.<br /><br />Some powerful requests that you can try:<br /><br /><ul><li>"Create a spreadsheet in my Documents folder with all the major cities in Canada."</li><li>"Search the web for the latest news on AI and make a thorough report."</li><li>Select an attachment and then "translate this document to French."</li></ul><br /><img src="${CUn}" alt="Chat input" style="width: 100%; height: 200px; object-fit: contain; border-radius: 8px;"/><br />You can also attach files to your message by clicking the paperclip button, which we will cover in the next step.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"attachments",attachTo:{element:'button[data-tour-tag="chat-input-attach-file-button"]',on:"top"},title:"Attach files to your message",text:`You can attach any files, images, or documents to your message by clicking this paperclip button, there are no limitations on the file types. Your agent can process, analyze, or translate these attachments as part of your request.<br /><br />Try attaching a PDF, image, or text file and then ask your agent to summarize, translate, or extract information from it.<br /><img src="${_Un}" alt="Chat attachments" style="width: 100%; height: 200px; object-fit: contain; border-radius: 8px;"/><br />Images like PNGs, JPGs, and PDFs are natively streamed into the model context window, so they can understand them directly without needing to run any code. Other files like Excel, Word, and CSV files are included as file paths on your device to direct the model's attention to work with them using code. You can attach massive files like million line CSVs and have the agent work with them using code.<br /><br />You can also paste images into the chat input, and attach multiple files at once to achieve more complex tasks. Try taking a screenshot of a website and then asking your agent to try to code it.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"agent-capabilities",attachTo:{element:'[data-tour-tag="chat-header"]',on:"top"},title:"More than just chat",text:`Local Operator agents are different from simple chatbots. They can perform actions on your computer, like creating files, running code, or browsing the web, based on your instructions. You'll see them use "tools" like reading, writing, and executing code to get things done. Agents have memory of the conversation, previous steps, learnings, and even store the execution variables of previous steps in code to be able to use them later in the conversation.<br /><img src="${SUn}" alt="Agentic sequence" style="width: 100%; height: 350px; object-fit: contain; border-radius: 8px;"/><br />Local Operator agents are extremely flexible, so they can bounce back and forth with you for simple chatting, and know when they need to embark on a work journey to get things done in multiple steps with tool use.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const{openCommandPalette:e}=sr.getState();e(),setTimeout(()=>{this.next()},500)}}]},{id:"pre-command-palette-open-canvas",title:"Command palette",attachTo:{element:'[data-tour-tag="command-palette-dialog"]',on:"right"},text:"Let's quickly look at another powerful feature: the Command Palette. You can open it anywhere in the app by pressing <code>Cmd+P</code> on Mac and <code>Ctrl+P</code> on Windows or Linux. This is a helpful window that you can open from anywhere in the app to be able to access agents, settings, pages, and much more using your keyboard. It can often be faster to access sections in the app this way instead of clicking through menus. You can type an agent's name to find the chat for that agent, and then hit Enter to open it.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const{closeCommandPalette:e}=sr.getState();e(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const{closeCommandPalette:e}=sr.getState();e(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-open-button",attachTo:{element:'button[data-tour-tag="open-canvas-button"]',on:"left"},title:"Open the canvas",text:"Click here to open the Canvas, a workspace for files and dynamic visualizations where you can organize, plan, and interact with your agents in a more flexible way.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const{openCommandPalette:e}=sr.getState();e(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="open-canvas-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-feature",attachTo:{element:'[data-tour-tag="canvas-container"]',on:"left"},title:"The canvas: your visual workspace",text:`This is the Canvas, your workspace for files and dynamic visualizations where you can organize, plan, and interact with your agents in a more flexible way. Any files that your agents create on your device can be opened here by clicking on the file icons that you see as they work.<br/><br/>Agents can make dynamic visualizations like games, charts, maps, and more in HTML files. Any HTML files you open will be rendered dynamically in an iframe. Any markdown files that you open will be rendered in full markdown viewer with support for code blocks, tables, mermaid diagrams, and more.<br/><img src="${kUn}" alt="Canvas overview" style="width: 100%; height: 300px; object-fit: contain; border-radius: 8px;"/>`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="close-canvas-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-documents-view-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-documents-view",attachTo:{element:'button[data-tour-tag="canvas-documents-view-button"]',on:"top"},title:"Documents view",text:`The Documents view shows all your open notes, blog articles, code, and visualizations as tabs. You can switch between documents to edit them and see dynamic visualizations in HTML created by your agents. Use this view to work with your notes, reports, and agent-generated content.<br /><br />This is where you can get more precise around your agents' work.<br/><img src="${QUn}" alt="Inline edit canvas" style="width: 100%; height: 200px; object-fit: contain; border-radius: 8px;"/><br />In your documents, highlight any text that you want your agent to improve and press Cmd/Ctrl+K to bring up the inline AI editor.
1410
1410
  <br /><img src="${$Un}" alt="Canvas code inline edit" style="width: 100%; height: 200px; object-fit: cover; object-position: top; border-radius: 8px;"/><br />You can be as precise as you want and the agent will edit the document for you in place, using its memories and context so you don't have to re-explain things.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-files-view-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-files-view",attachTo:{element:'button[data-tour-tag="canvas-files-view-button"]',on:"top"},title:"Files view",text:"The Files view lets you browse and open files that your agents have created or that are relevant to your current conversation. Use this to quickly access, preview, and open files in the Canvas workspace.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-documents-view-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-variables-view-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-variables-view",attachTo:{element:'button[data-tour-tag="canvas-variables-view-button"]',on:"top"},title:"Variables view",text:`The Variables view displays the "code memory" that agents have stored during their work. These are technical variables that include results, intermediate values, and other data that agents use to perform tasks. You can inspect and manage these variables here.<br /><br />This section will be most helpful for more technical users who want to understand how agents are working and what they are doing.<br/><img src="${TUn}" alt="Canvas variables" style="width: 100%; height: 350px; object-fit: contain; border-radius: 8px;"/>`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-files-view-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="close-canvas-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"agent-options",attachTo:{element:'button[data-tour-tag="agent-options-button"]',on:"right"},title:"Agent options",text:"Click here to see options for the currently selected agent, like viewing its settings, exporting it, or deleting it.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="open-canvas-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="agent-options-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"click-view-settings-from-chat",attachTo:{element:'[role="menuitem"][data-tour-tag="view-agent-settings-menu-item"]',on:"right"},title:"View configuration",text:'Click "View agent settings" to see and change how this agent works and change things like its name, description, hosting provider, and AI model.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[role="menuitem"][data-tour-tag="view-agent-settings-menu-item"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"view-agent-settings",attachTo:{element:'div[data-tour-tag="agent-settings-details-paper"]',on:"left"},title:"Agent configuration",text:"This is where you can customize and configure your agent. You can change its name, description, the AI model it uses, its temperature for creativity, and other chat settings.<br /><br />The agents will already have default settings that work well for most use cases, but if you want to roll up your sleeves and customize, you can do so here.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-chat"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="agent-options-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"select-provider",attachTo:{element:'[data-tour-tag="agent-settings-hosting-select"]',on:"left"},title:"Select hosting provider",text:`Choose an AI provider for your agent. If you don't pick one here, then the default provider from the settings page will be used. Providers offer different AI models and pricing. Radient is recommended for Local Operator as its "Automatic" mode is optimized for the lowest cost and best performance.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"select-model",attachTo:{element:'[data-tour-tag="agent-settings-model-select"]',on:"left"},title:"Select AI model",text:"After selecting a provider, choose an AI model. Models marked as 'Recommended' are known to work well with Local Operator. Other models might have inconsistent performance. If a model you expect to be recommended isn't listed, please let us know if it works well for you in Local Operator via GitHub Issues or email.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"modify-security-prompt",attachTo:{element:'[data-tour-tag="agent-settings-security"]',on:"left"},title:"Customize security behaviors",text:"This prompt provides separate instructions to the security agent that reviews this agent's work. You can explicitly allow certain actions that would normally be blocked. If you encounter frequent security interventions, consider adding a note here for the security agent.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"modify-agent-prompt",attachTo:{element:'[data-tour-tag="agent-settings-system-prompt"]',on:"left"},title:"Customize the agent's behavior",text:"This prompt allows you to customize the baseline behavior of the agent. While most customization can happen by talking to the agent (it records learnings in its notebook), you can provide specific workflow instructions here that will be followed separately.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"create-new-agent",attachTo:{element:'button[data-tour-tag="create-new-agent-button"]',on:"bottom"},title:"Create a new agent",text:'Click the "+" button to create a brand new agent from scratch. You can then customize its behavior and capabilities.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="agent-list-item-button-0"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="agent-options-button"]');t&&t.click()},500),setTimeout(()=>{const t=document.querySelector('[role="menuitem"][data-tour-tag="view-agent-settings-menu-item"]');t&&t.click()},1e3),setTimeout(()=>{this.back()},1500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-new-agent-button"]');e&&e.click(),setTimeout(()=>{this.next()},1e3)}}]},{id:"agent-naming-guidelines",attachTo:{element:'[data-tour-tag="create-agent-dialog"]',on:"right"},title:"Naming and describing your agent",text:`Give your agent a clear, descriptive name that reflects its purpose (e.g., "File Organizer" or "Web Researcher").
1411
- A good description helps you and others understand what the agent does and any special instructions. The descriptions are also used by other agents to help them understand how to tag each other in for certain tasks.<br /><br />If you want this agent to be part of the agent-to-agent communication network, it will need to have a description that captures its purpose and capabilities. Be concise and specific.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-agent-hub",attachTo:{element:'[data-tour-tag="nav-item-agent-hub"]',on:"right"},title:"Discover more agents",text:`Let's visit the Agent hub to find community-created agents. Click on the "Agent hub" icon in the navigation bar.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('[data-tour-tag="create-new-agent-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"agent-hub-view",attachTo:{element:'[data-tour-tag="agent-hub-sidebar-container"]',on:"right"},title:"The Agent hub",text:"Here you can browse agents by category or search for specific ones. These agents are shared by the community and can perform various specialized tasks.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"download-agent",attachTo:{element:'button[data-tour-tag="agent-hub-download-button"]',on:"bottom"},title:"Download an agent",text:'Find an agent that interests you and click the "Get" button to add it to your local agent list.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{this.next()},1e3)}}]},{id:"upload-agent-hub",attachTo:{element:()=>EUn("upload-to-hub-header-button"),on:"bottom"},title:"Share your agents",text:"If you create a useful agent, you can also share it with the community by uploading it to the Agent hub from the agent options menu.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){DSe("open-upload-dialog"),setTimeout(()=>{this.next()},500)}}]},{id:"upload-agent-hub-dialog",attachTo:{element:'[data-tour-tag="upload-agent-dialog"]',on:"right"},title:"Upload agent to hub",text:"This dialog allows you to share your agent with the community. You need to have a Radient account to upload an agent, which is free to create and doesn't cost anything per upload. You can review the agent details and confirm the upload. Make sure your agent meets the required criteria before submitting. Also be aware that any conversation history and learnings for this agent will be part of its training and will be visible to the public. So don't share agents publicly that know sensitive information.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-schedules",attachTo:{element:'[data-tour-tag="nav-item-schedules"]',on:"right"},title:"Automate tasks with schedules",text:"Local Operator can run tasks for you on a regular basis. Let's check out the Schedules section.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{DSe("open-upload-dialog")},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"schedules-overview",title:"Proactive agents with schedules",text:"A powerful feature of Local Operator is the ability to ask agents to perform tasks on their own on a recurring basis. This turns them from reactive agent bots to proactive agents that work on their own in the background to support you without you needing to continually ask them to do things.<br /><br />You can simply ask any agent to do something at some point in the future, or to handle some daily task at a certain time, and it will create a prompt for itself that will be executed at the specified times.<br /><br />Here, you can view, create, and manage all your scheduled tasks in one place to streamline your workflow and ensure important actions happen automatically.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"create-schedule",attachTo:{element:'button[data-tour-tag="create-schedule-button"]',on:"bottom"},title:"Set up a recurring task",text:'Click "Create schedule" to ask an agent to perform a task for you regularly, like sending a daily report or checking for news updates.<br /><br />You can also create one-off tasks that only run once at some point in the future.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="create-schedule-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"create-schedule-dialog",attachTo:{element:'[data-tour-tag="create-schedule-dialog"]',on:"right"},title:"Configure your schedule",text:"While it is often much easier to simply ask the agent to do a task on a recurring basis for you, you can also manually set up a schedule for a task here or update existing tasks.<br /><br />The prompt is the message that will be sent to the agent at the predefined schedule. You can update the time of day in your local timezone, the frequency of the task, and even specify a specific date or time that the task should stop running at.<br /><br />You can also schedule one-off tasks that only run once at some point in the future.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-settings",attachTo:{element:'[data-tour-tag="nav-item-settings"]',on:"right"},title:"Personalize your experience",text:"Now, let's explore the Settings menu to customize Local Operator to your liking.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="create-schedule-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-settings"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"general-settings",attachTo:{element:'div[data-tour-tag="settings-general-section"]',on:"right"},title:"General settings",text:"Here you can update your user profile, configure model settings (like default hosting provider and model), and adjust history settings for conversations and learnings.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"appearance-settings",attachTo:{element:'[data-tour-tag="settings-appearance-section"]',on:"right"},title:"Customize appearance",text:"Choose from various themes to change the look and feel of Local Operator. Find one that suits your style.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"radient-account-settings",attachTo:{element:'[data-tour-tag="settings-radient-account-section"]',on:"right"},title:"Radient account",text:"Connect your Radient account to access your Radient Pass details, credits, and unlock unified access to models and tools. Radient is the best way to use Local Operator since it powers the AI models, web search, image generation, and much more with a single integration. You get free credits when you sign up to try it out and bonus credits when you top up.<br /><br />When you sign in for the first time, it will automatically create a Radient Pass for you and save it securely to your computer. This will power your Local Operator agents with Radient Automatic, which mixes and matches AI models to get you the best balance of speed, accuracy, and cost in every step of your agents' workflows.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"integrations-settings",attachTo:{element:'[data-tour-tag="settings-integrations-section"]',on:"right"},title:"Connect your services",text:"Enhance your agents' capabilities by connecting your Google services like Gmail, Calendar, and Drive. This allows agents to access and manage your information with your permission.<br /><br />You need to be logged in to a Radient account to use this feature, however it is free to use and doesn't cost any additional Radient credits per action.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"api-credentials-settings",attachTo:{element:'[data-tour-tag="settings-api-credentials-section"]',on:"right"},title:"Manage API keys",text:"Configure API keys for various services and AI models here. This allows your agents to access external tools and capabilities.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"application-updates-settings",attachTo:{element:'[data-tour-tag="settings-app-updates-section"]',on:"right"},title:"Stay up to date",text:"Check for updates to Local Operator here to ensure you have the latest features and improvements. You can see your current version information below.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"tour-complete",title:"Tour complete",text:"You've now seen the main features of Local Operator. Feel free to explore further and discover all the ways your AI agents can assist you. Happy automating.",buttons:[{text:"Finish",classes:"shepherd-button-primary",action:function(){this.complete()}}]}],RUn=()=>{const e=Xa(),{completeTourOnboarding:t}=Ak(),n=w.useContext(g6),r={cancelIcon:{enabled:!0},scrollTo:{behavior:"smooth",block:"center"}},i=!0;return{startTour:a=>{if(n?.tour?.isActive()&&!a?.forceModalCompleted){console.log("Onboarding tour is already active (from context.tour). Not starting another.");return}const o=Ak.getState();if(!a?.forceModalCompleted&&!o.isModalComplete){console.log("Onboarding modal not completed (checked via store). Tour will not start.");return}if(o.isTourComplete&&!a?.forceModalCompleted){console.log("Onboarding tour already completed in store and not forced. Not starting again.");return}let l=n?.tour;const c=n?.Shepherd;if(!l&&c&&(l=c.activeTour,!l&&c.Tour&&(console.log("No active Shepherd tour found from context or global. Creating a new one."),l=new c.Tour({useModalOverlay:i,defaultStepOptions:r}))),!l){console.warn("Failed to get or create a Shepherd tour instance.",n);return}if(l.isActive()){console.log("Tour is already active. Not starting again.");return}if(l.options.defaultStepOptions={...l.options.defaultStepOptions||{},...r},l.options.useModalOverlay=i,a?.firstAgentId&&(l.options.firstAgentId=a.firstAgentId),l.off("complete",t),l.on("complete",t),l.off("cancel",t),l.on("cancel",t),a?.forceModalCompleted||!l.isActive()){const u=[...l.steps];for(const d of u)d.id&&l.removeStep(d.id);l.addSteps(ISe)}else l.steps.length===0&&l.addSteps(ISe);typeof l.start=="function"?(e("/"),l.start()):console.warn("Shepherd tour instance does not have a start method.",l)}}},AUn=()=>{const{isModalComplete:e,isTourComplete:t}=Ak(),{startTour:n}=RUn(),r=Z.useContext(g6),{data:i}=yB(1,1);return w.useEffect(()=>{if(e&&!t&&r){const s=setTimeout(()=>{const a=i?.agents?.[0]?.id;n({firstAgentId:a})},500);return()=>clearTimeout(s)}},[e,t,r,n,i]),null},XUn=({children:e})=>p.jsxs(xUn,{children:[e,p.jsx(AUn,{})]}),NSe=["auth","settings","commands","catalogues","lifecycle","mcp","radient"],DUn=()=>{const e=Dl(),t=Ki(),[n,r]=w.useState(!1),[i,s]=w.useState(null),a=w.useCallback(()=>{t.invalidateQueries({queryKey:id.capabilities})},[t]),o=w.useCallback(async()=>{r(!0),s(null);try{await window.api.updater.updateBackend(),a()}catch(m){s(m instanceof Error?m.message:"The backend update could not start.")}finally{r(!1)}},[a]);if(e.isLoading)return null;const l=e.data,c=l?NSe.filter(m=>(l.features?.[m]??0)<1):[...NSe],u=!!l&&!l?.desktop_available;if(l?.desktop_available&&c.length===0)return null;const d=OTe(e.error),h=!!l,f=!!window.api?.updater?.updateBackend,O=Xtt({kind:d,unpaired:u,missing:c,answered:h}),g=f&&Att({kind:d,unpaired:u,answered:h});return p.jsx("div",{className:"fixed inset-x-0 top-0 z-2100 w-full",children:p.jsx(el,{variant:"warning",className:"items-center rounded-none border-x-0 border-t-0",children:p.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[p.jsxs(vA,{children:[O,i?` ${i}`:null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[g&&p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void o(),disabled:n,children:n?"Updating":"Update backend"}),p.jsx(we,{variant:"secondary",size:"sm",onClick:a,children:"Retry"})]})]})})})},IUn=""+new URL("radient-icon-1024x1024-D_JJedvo.png",import.meta.url).href,nWe={all:["radient-prices"],prices:()=>[...nWe.all,"prices"]},NUn=()=>{const e=rr({queryKey:nWe.prices(),queryFn:()=>XB({operation:"prices"}),staleTime:36e5,refetchOnWindowFocus:!1,refetchOnMount:!0,refetchInterval:!1,retry:3});return{prices:e.data,isLoading:e.isLoading,isFetching:e.isFetching,error:e.error,pricesQuery:e}},rWe=Ao()(yd(e=>({hasBeenNotified:!1,setHasBeenNotified:t=>{e({hasBeenNotified:t})}}),{name:"low-credits-storage"})),FUn=({open:e,onClose:t,onGoToConsole:n})=>{const{setHasBeenNotified:r}=rWe(),{prices:i,isLoading:s,error:a}=NUn(),o=u=>typeof u!="number"?"$...":`$${u.toFixed(2)} USD`,l=()=>{r(!0),t()},c=()=>{r(!0),n()};return p.jsx($g,{open:e,onClose:l,title:p.jsxs(p.Fragment,{children:[p.jsx("img",{src:IUn,alt:"Radient icon",className:"size-7"}),"Running low on Radient credits?"]}),maxWidth:"sm",fullWidth:!1,actions:p.jsxs(p.Fragment,{children:[p.jsx(bw,{onClick:l,children:"Maybe later"}),p.jsx(yw,{onClick:c,startIcon:p.jsx(_A,{size:18}),className:"min-w-55",children:"Get more credits"})]}),children:p.jsxs("div",{className:"flex flex-col items-center gap-4 py-2 text-center",children:[p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Unlock the full power of Local Operator with"," ",p.jsx("span",{className:"font-bold text-accent",children:"Radient Pass"}),"."]}),p.jsx("p",{className:"text-body-sm text-ink-muted",children:"Radient Automatic is often cheaper than bringing your own key: its smart model routing picks the most cost-effective model for each step of your agentic workflows."}),p.jsx("p",{className:"text-body-sm text-ink-muted",children:"It's pay-as-you-go with no commitments. Load up what you need, starting small for maximum flexibility."}),p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Plus, get"," ",p.jsx("span",{className:"font-medium text-ink",children:s?p.jsx(br,{size:"sm",className:"mr-0.5 align-middle"}):o(i?.default_registration_credits)})," ","in bonus credits with your first purchase.",a&&p.jsx("span",{className:"mt-1 block text-meta text-danger",children:"Could not load bonus credit information."})]}),p.jsx("p",{className:"text-meta text-ink-dim",children:"You can also reach the Radient Console from Settings at any time."})]})})},FSe=({expanded:e})=>p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[p.jsx("img",{src:CWe,alt:e?"":"Local Operator",loading:"eager",className:"size-6 shrink-0"}),e&&p.jsx("span",{className:"truncate font-semibold text-body text-ink",children:"Local Operator"})]}),iWe=Z.memo(({expanded:e,useAuth:t=!1})=>{const n=Xa(),{user:r,isAuthenticated:i,signOut:s}=DB(),a=r?.name??"User",o=r?.email??"",l=w.useCallback(async()=>{i&&(await s(),window.location.reload())},[i,s]),c=w.useMemo(()=>a?a.split(" ").map(h=>h.charAt(0)).join("").toUpperCase().substring(0,2):null,[a]),u=p.jsxs("button",{type:"button",onClick:t?void 0:()=>n("/settings"),"aria-label":e?void 0:"Account settings",className:I("flex w-full items-center gap-2 rounded-sm transition-colors duration-fast ease-out-quart hover:bg-elevated",e?"px-3 py-1.5":"justify-center py-1.5"),children:[p.jsx(ZSe,{className:"size-7 shrink-0",children:p.jsx(HSe,{className:"bg-elevated text-ink",children:c??p.jsx(Yke,{size:14,"aria-hidden":"true"})})}),e&&a&&p.jsxs("span",{className:"min-w-0 text-left",children:[p.jsx("span",{className:"block truncate text-body-sm text-ink",children:a}),o&&p.jsx("span",{className:"block truncate text-meta text-ink-dim",children:o})]})]}),d=e?u:p.jsx(Ot,{content:"Account settings",side:"right",children:u});return t?p.jsxs(X_,{children:[e?p.jsx(Ub,{asChild:!0,children:u}):p.jsx(Ot,{content:"Account settings",side:"right",children:p.jsx(Ub,{asChild:!0,children:u})}),p.jsxs(D_,{align:"end",side:"top",className:"min-w-50",children:[p.jsxs(ks,{onSelect:()=>n("/settings"),children:[p.jsx(Xf,{size:16,"aria-hidden":"true"}),"Settings"]}),p.jsxs(ks,{children:[p.jsx(Wke,{size:16,"aria-hidden":"true"}),"Privacy and security"]}),p.jsx(ib,{}),p.jsxs(ks,{onSelect:l,className:"text-danger focus:bg-danger-wash focus:text-danger",children:[p.jsx(yHe,{size:16,"aria-hidden":"true"}),"Sign out"]})]})]}):d});iWe.displayName="UserProfileSidebar";const MSe={expanded:"w-55",collapsed:"w-12"},MUn=()=>{const e=Xa(),t=Wrt(),{isSidebarCollapsed:n,toggleSidebar:r}=sr(),i=!n,s=[{icon:PA,label:"Chat",path:"/chat",isActive:t==="chat",tourTag:"nav-item-chat"},{icon:mw,label:"My agents",path:"/agents",isActive:t==="agents",tourTag:"nav-item-agents"},{icon:Bke,label:"Agent hub",path:"/agent-hub",isActive:t==="agent-hub",tourTag:"nav-item-agent-hub"},{icon:Eke,label:"Schedules",path:"/schedules",isActive:t==="schedules",tourTag:"nav-item-schedules"},{icon:Xf,label:"Settings",path:"/settings",isActive:t==="settings",tourTag:"nav-item-settings"}],a=c=>{const u=p.jsxs("button",{type:"button",onClick:()=>e(c.path),"data-tour-tag":c.tourTag,"aria-current":c.isActive?"page":void 0,"aria-label":i?void 0:c.label,className:I("flex h-8 w-full items-center rounded-sm text-body-sm transition-colors duration-fast ease-out-quart",i?"justify-start gap-2 px-3":"justify-center",c.isActive?"bg-accent-wash font-medium text-ink":"text-ink-muted hover:bg-elevated hover:text-ink"),children:[p.jsx(c.icon,{size:16,"aria-hidden":"true",className:I("shrink-0",c.isActive&&"text-accent")}),i&&p.jsx("span",{className:"truncate",children:c.label})]});return i?p.jsx("li",{children:u},c.path):p.jsx("li",{children:p.jsx(Ot,{content:c.label,side:"right",children:u})},c.path)},o=i?"Collapse sidebar":"Expand sidebar",l=p.jsx("div",{className:I("pointer-events-none opacity-0 transition-opacity duration-fast ease-out-quart","group-hover:pointer-events-auto group-hover:opacity-100","group-focus-within:pointer-events-auto group-focus-within:opacity-100"),children:p.jsx(Ot,{content:o,side:"right",children:p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":o,"aria-expanded":i,children:i?p.jsx(Zb,{"aria-hidden":"true"}):p.jsx(rO,{"aria-hidden":"true"})})})});return p.jsxs("nav",{className:I("group flex shrink-0 flex-col overflow-x-hidden bg-sunken transition-[width] duration-base ease-out-quart",i?MSe.expanded:MSe.collapsed),children:[p.jsx("div",{className:I("flex h-12 shrink-0 items-center",i?"justify-between pr-2 pl-5":"justify-center"),children:i?p.jsxs(p.Fragment,{children:[p.jsx(FSe,{expanded:!0}),l]}):p.jsxs("div",{className:"relative flex size-8 items-center justify-center",children:[p.jsx("div",{className:"transition-opacity duration-fast ease-out-quart group-hover:opacity-0 group-focus-within:opacity-0",children:p.jsx(FSe,{expanded:!1})}),p.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l})]})}),p.jsx("ul",{className:"flex flex-col gap-1 p-2",children:s.map(a)}),p.jsx("div",{className:"mt-auto p-2",children:p.jsx(iWe,{expanded:i})})]})},LUn=1,jUn=()=>{const{isAuthenticated:e,user:t}=DB(),{hasBeenNotified:n,setHasBeenNotified:r}=rWe(),[i,s]=w.useState(!1),[a,o]=w.useState(null),l=w.useCallback(async()=>{if(!(!e||!t?.radientUser?.account?.tenant_id))try{const h=await XB({operation:"credits",tenantId:t.radientUser.account.tenant_id});if(!h||typeof h.balance!="number")throw new Error("Invalid credit balance response format");o(h.balance)}catch(h){console.error("Failed to fetch Radient credits:",h),o(null)}},[e,t?.radientUser?.account?.tenant_id]);return w.useEffect(()=>{e&&l()},[e,l]),w.useEffect(()=>{e&&a!==null?a<LUn?n||s(!0):(s(!1),n&&r(!1)):s(!1)},[e,n,a,r]),{isLowCreditsDialogOpen:i,openRadientConsole:()=>{window.api?.openExternal?window.api.openExternal("https://console.radienthq.com"):window.open("https://console.radienthq.com","_blank"),r(!0),s(!1)},closeLowCreditsDialog:()=>{s(!1)},onLowCreditsDialogClose:()=>{r(!0),s(!1)},currentCredits:a}},qUn=w.lazy(()=>Ie(()=>import("./agent-details-page-CO72YkSX.js"),__vite__mapDeps([8,1,2,9,10]),import.meta.url).then(e=>({default:e.AgentDetailsPage}))),zUn=w.lazy(()=>Ie(()=>import("./agent-hub-page-DhYc5_gP.js"),__vite__mapDeps([11,1,2,12,13,10]),import.meta.url).then(e=>({default:e.AgentHubPage}))),LSe=w.lazy(()=>Ie(()=>import("./agents-page-BopOzax_.js"),__vite__mapDeps([14,1,2]),import.meta.url).then(e=>({default:e.AgentsPage}))),UUn=w.lazy(()=>Ie(()=>import("./schedules-page-DtNhlycC.js"),__vite__mapDeps([15,1,2,13,16,9]),import.meta.url).then(e=>({default:e.SchedulesPage}))),WUn=w.lazy(()=>Ie(()=>import("./settings-page-DCLaspsn.js"),__vite__mapDeps([17,1,2,13,9,18,16]),import.meta.url).then(e=>({default:e.SettingsPage}))),GUn=()=>{const{isOnboardingActive:e}=Rrt(),{isLowCreditsDialogOpen:t,openRadientConsole:n,onLowCreditsDialogClose:r}=jUn(),{toggleCommandPalette:i,isCommandPaletteOpen:s,isCreateAgentDialogOpen:a,closeCreateAgentDialog:o}=sr(),l=Xa(),c=d=>{l(`/chat/${d}`),o()};w.useEffect(()=>{const d=()=>{i()},h=window.electron.ipcRenderer.on("toggle-command-palette",d);return()=>{h&&h()}},[i]);const u=ir(d=>d.setActiveSession);return w.useEffect(()=>{const d=window.api?.desktop?.onOpenConversation?.(h=>{u(h),l("/chat")});return()=>d?.()},[l,u]),p.jsx(XUn,{children:p.jsxs("div",{className:"relative flex h-screen overflow-hidden",children:[s&&p.jsx(Ejn,{}),p.jsx(WTe,{}),p.jsx(rqn,{open:e}),p.jsx(xrt,{}),p.jsx(DUn,{}),p.jsx(Rit,{}),p.jsx(FUn,{open:t,onClose:r,onGoToConsole:n}),p.jsx(UTe,{open:a,onClose:o,onAgentCreated:c}),p.jsx(MUn,{}),p.jsx("main",{className:"flex grow flex-col overflow-hidden",children:p.jsx(w.Suspense,{fallback:p.jsx("div",{className:"flex grow items-center justify-center",children:p.jsx(br,{size:"lg",label:"Loading page"})}),children:p.jsxs(pYe,{children:[p.jsx(Iu,{path:"/",element:p.jsx(Tne,{to:"/chat",replace:!0})}),p.jsx(Iu,{path:"/chat",element:p.jsx(qxe,{})}),p.jsx(Iu,{path:"/chat/:agentId",element:p.jsx(qxe,{})}),p.jsx(Iu,{path:"/agents",element:p.jsx(LSe,{})}),p.jsx(Iu,{path:"/agents/:agentId",element:p.jsx(LSe,{})}),p.jsx(Iu,{path:"/settings",element:p.jsx(WUn,{})}),p.jsx(Iu,{path:"/agent-hub",element:p.jsx(zUn,{})}),p.jsx(Iu,{path:"/agent-hub/:agentId",element:p.jsx(qUn,{})}),p.jsx(Iu,{path:"/schedules",element:p.jsx(UUn,{})}),p.jsx(Iu,{path:"*",element:p.jsx(Tne,{to:"/chat",replace:!0})})]})})})]})})},VUn={queries:{staleTime:5*60*1e3,gcTime:10*60*1e3,retry:1,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!1,networkMode:"always"},mutations:{retry:1,networkMode:"always"}},sWe=new VWe({defaultOptions:VUn}),BUn=`
1411
+ A good description helps you and others understand what the agent does and any special instructions. The descriptions are also used by other agents to help them understand how to tag each other in for certain tasks.<br /><br />If you want this agent to be part of the agent-to-agent communication network, it will need to have a description that captures its purpose and capabilities. Be concise and specific.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-agent-hub",attachTo:{element:'[data-tour-tag="nav-item-agent-hub"]',on:"right"},title:"Discover more agents",text:`Let's visit the Agent hub to find community-created agents. Click on the "Agent hub" icon in the navigation bar.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('[data-tour-tag="create-new-agent-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"agent-hub-view",attachTo:{element:'[data-tour-tag="agent-hub-sidebar-container"]',on:"right"},title:"The Agent hub",text:"Here you can browse agents by category or search for specific ones. These agents are shared by the community and can perform various specialized tasks.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"download-agent",attachTo:{element:'button[data-tour-tag="agent-hub-download-button"]',on:"bottom"},title:"Download an agent",text:'Find an agent that interests you and click the "Get" button to add it to your local agent list.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{this.next()},1e3)}}]},{id:"upload-agent-hub",attachTo:{element:()=>EUn("upload-to-hub-header-button"),on:"bottom"},title:"Share your agents",text:"If you create a useful agent, you can also share it with the community by uploading it to the Agent hub from the agent options menu.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){DSe("open-upload-dialog"),setTimeout(()=>{this.next()},500)}}]},{id:"upload-agent-hub-dialog",attachTo:{element:'[data-tour-tag="upload-agent-dialog"]',on:"right"},title:"Upload agent to hub",text:"This dialog allows you to share your agent with the community. You need to have a Radient account to upload an agent, which is free to create and doesn't cost anything per upload. You can review the agent details and confirm the upload. Make sure your agent meets the required criteria before submitting. Also be aware that any conversation history and learnings for this agent will be part of its training and will be visible to the public. So don't share agents publicly that know sensitive information.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-schedules",attachTo:{element:'[data-tour-tag="nav-item-schedules"]',on:"right"},title:"Automate tasks with schedules",text:"Local Operator can run tasks for you on a regular basis. Let's check out the Schedules section.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{DSe("open-upload-dialog")},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"schedules-overview",title:"Proactive agents with schedules",text:"A powerful feature of Local Operator is the ability to ask agents to perform tasks on their own on a recurring basis. This turns them from reactive agent bots to proactive agents that work on their own in the background to support you without you needing to continually ask them to do things.<br /><br />You can simply ask any agent to do something at some point in the future, or to handle some daily task at a certain time, and it will create a prompt for itself that will be executed at the specified times.<br /><br />Here, you can view, create, and manage all your scheduled tasks in one place to streamline your workflow and ensure important actions happen automatically.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"create-schedule",attachTo:{element:'button[data-tour-tag="create-schedule-button"]',on:"bottom"},title:"Set up a recurring task",text:'Click "Create schedule" to ask an agent to perform a task for you regularly, like sending a daily report or checking for news updates.<br /><br />You can also create one-off tasks that only run once at some point in the future.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="create-schedule-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"create-schedule-dialog",attachTo:{element:'[data-tour-tag="create-schedule-dialog"]',on:"right"},title:"Configure your schedule",text:"While it is often much easier to simply ask the agent to do a task on a recurring basis for you, you can also manually set up a schedule for a task here or update existing tasks.<br /><br />The prompt is the message that will be sent to the agent at the predefined schedule. You can update the time of day in your local timezone, the frequency of the task, and even specify a specific date or time that the task should stop running at.<br /><br />You can also schedule one-off tasks that only run once at some point in the future.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-settings",attachTo:{element:'[data-tour-tag="nav-item-settings"]',on:"right"},title:"Personalize your experience",text:"Now, let's explore the Settings menu to customize Local Operator to your liking.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="create-schedule-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-settings"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"general-settings",attachTo:{element:'div[data-tour-tag="settings-general-section"]',on:"right"},title:"General settings",text:"Here you can update your user profile, configure model settings (like default hosting provider and model), and adjust history settings for conversations and learnings.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"appearance-settings",attachTo:{element:'[data-tour-tag="settings-appearance-section"]',on:"right"},title:"Customize appearance",text:"Choose from various themes to change the look and feel of Local Operator. Find one that suits your style.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"radient-account-settings",attachTo:{element:'[data-tour-tag="settings-radient-account-section"]',on:"right"},title:"Radient account",text:"Connect your Radient account to access your Radient Pass details, credits, and unlock unified access to models and tools. Radient is the best way to use Local Operator since it powers the AI models, web search, image generation, and much more with a single integration. You get free credits when you sign up to try it out and bonus credits when you top up.<br /><br />When you sign in for the first time, it will automatically create a Radient Pass for you and save it securely to your computer. This will power your Local Operator agents with Radient Automatic, which mixes and matches AI models to get you the best balance of speed, accuracy, and cost in every step of your agents' workflows.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"integrations-settings",attachTo:{element:'[data-tour-tag="settings-integrations-section"]',on:"right"},title:"Connect your services",text:"Enhance your agents' capabilities by connecting your Google services like Gmail, Calendar, and Drive. This allows agents to access and manage your information with your permission.<br /><br />You need to be logged in to a Radient account to use this feature, however it is free to use and doesn't cost any additional Radient credits per action.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"api-credentials-settings",attachTo:{element:'[data-tour-tag="settings-api-credentials-section"]',on:"right"},title:"Manage API keys",text:"Configure API keys for various services and AI models here. This allows your agents to access external tools and capabilities.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"application-updates-settings",attachTo:{element:'[data-tour-tag="settings-app-updates-section"]',on:"right"},title:"Stay up to date",text:"Check for updates to Local Operator here to ensure you have the latest features and improvements. You can see your current version information below.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"tour-complete",title:"Tour complete",text:"You've now seen the main features of Local Operator. Feel free to explore further and discover all the ways your AI agents can assist you. Happy automating.",buttons:[{text:"Finish",classes:"shepherd-button-primary",action:function(){this.complete()}}]}],RUn=()=>{const e=Xa(),{completeTourOnboarding:t}=Ak(),n=w.useContext(g6),r={cancelIcon:{enabled:!0},scrollTo:{behavior:"smooth",block:"center"}},i=!0;return{startTour:a=>{if(n?.tour?.isActive()&&!a?.forceModalCompleted){console.log("Onboarding tour is already active (from context.tour). Not starting another.");return}const o=Ak.getState();if(!a?.forceModalCompleted&&!o.isModalComplete){console.log("Onboarding modal not completed (checked via store). Tour will not start.");return}if(o.isTourComplete&&!a?.forceModalCompleted){console.log("Onboarding tour already completed in store and not forced. Not starting again.");return}let l=n?.tour;const c=n?.Shepherd;if(!l&&c&&(l=c.activeTour,!l&&c.Tour&&(console.log("No active Shepherd tour found from context or global. Creating a new one."),l=new c.Tour({useModalOverlay:i,defaultStepOptions:r}))),!l){console.warn("Failed to get or create a Shepherd tour instance.",n);return}if(l.isActive()){console.log("Tour is already active. Not starting again.");return}if(l.options.defaultStepOptions={...l.options.defaultStepOptions||{},...r},l.options.useModalOverlay=i,a?.firstAgentId&&(l.options.firstAgentId=a.firstAgentId),l.off("complete",t),l.on("complete",t),l.off("cancel",t),l.on("cancel",t),a?.forceModalCompleted||!l.isActive()){const u=[...l.steps];for(const d of u)d.id&&l.removeStep(d.id);l.addSteps(ISe)}else l.steps.length===0&&l.addSteps(ISe);typeof l.start=="function"?(e("/"),l.start()):console.warn("Shepherd tour instance does not have a start method.",l)}}},AUn=()=>{const{isModalComplete:e,isTourComplete:t}=Ak(),{startTour:n}=RUn(),r=Z.useContext(g6),{data:i}=yB(1,1);return w.useEffect(()=>{if(e&&!t&&r){const s=setTimeout(()=>{const a=i?.agents?.[0]?.id;n({firstAgentId:a})},500);return()=>clearTimeout(s)}},[e,t,r,n,i]),null},XUn=({children:e})=>p.jsxs(xUn,{children:[e,p.jsx(AUn,{})]}),NSe=["auth","settings","commands","catalogues","lifecycle","mcp","radient"],DUn=()=>{const e=Dl(),t=Ki(),[n,r]=w.useState(!1),[i,s]=w.useState(null),a=w.useCallback(()=>{t.invalidateQueries({queryKey:id.capabilities})},[t]),o=w.useCallback(async()=>{r(!0),s(null);try{await window.api.updater.updateBackend(),a()}catch(m){s(m instanceof Error?m.message:"The backend update could not start.")}finally{r(!1)}},[a]);if(e.isLoading)return null;const l=e.data,c=l?NSe.filter(m=>(l.features?.[m]??0)<1):[...NSe],u=!!l&&!l?.desktop_available;if(l?.desktop_available&&c.length===0)return null;const d=OTe(e.error),h=!!l,f=!!window.api?.updater?.updateBackend,O=Xtt({kind:d,unpaired:u,missing:c,answered:h}),g=f&&Att({kind:d,unpaired:u,answered:h});return p.jsx("div",{className:"fixed inset-x-0 top-0 z-2100 w-full",children:p.jsx(el,{variant:"warning",className:"items-center rounded-none border-x-0 border-t-0",children:p.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[p.jsxs(vA,{children:[O,i?` ${i}`:null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[g&&p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void o(),disabled:n,children:n?"Updating":"Update backend"}),p.jsx(we,{variant:"secondary",size:"sm",onClick:a,children:"Retry"})]})]})})})},IUn=""+new URL("radient-icon-1024x1024-D_JJedvo.png",import.meta.url).href,nWe={all:["radient-prices"],prices:()=>[...nWe.all,"prices"]},NUn=()=>{const e=rr({queryKey:nWe.prices(),queryFn:()=>XB({operation:"prices"}),staleTime:36e5,refetchOnWindowFocus:!1,refetchOnMount:!0,refetchInterval:!1,retry:3});return{prices:e.data,isLoading:e.isLoading,isFetching:e.isFetching,error:e.error,pricesQuery:e}},rWe=Ao()(yd(e=>({hasBeenNotified:!1,setHasBeenNotified:t=>{e({hasBeenNotified:t})}}),{name:"low-credits-storage"})),FUn=({open:e,onClose:t,onGoToConsole:n})=>{const{setHasBeenNotified:r}=rWe(),{prices:i,isLoading:s,error:a}=NUn(),o=u=>typeof u!="number"?"$...":`$${u.toFixed(2)} USD`,l=()=>{r(!0),t()},c=()=>{r(!0),n()};return p.jsx($g,{open:e,onClose:l,title:p.jsxs(p.Fragment,{children:[p.jsx("img",{src:IUn,alt:"Radient icon",className:"size-7"}),"Running low on Radient credits?"]}),maxWidth:"sm",fullWidth:!1,actions:p.jsxs(p.Fragment,{children:[p.jsx(bw,{onClick:l,children:"Maybe later"}),p.jsx(yw,{onClick:c,startIcon:p.jsx(_A,{size:18}),className:"min-w-55",children:"Get more credits"})]}),children:p.jsxs("div",{className:"flex flex-col items-center gap-4 py-2 text-center",children:[p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Unlock the full power of Local Operator with"," ",p.jsx("span",{className:"font-bold text-accent",children:"Radient Pass"}),"."]}),p.jsx("p",{className:"text-body-sm text-ink-muted",children:"Radient Automatic is often cheaper than bringing your own key: its smart model routing picks the most cost-effective model for each step of your agentic workflows."}),p.jsx("p",{className:"text-body-sm text-ink-muted",children:"It's pay-as-you-go with no commitments. Load up what you need, starting small for maximum flexibility."}),p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Plus, get"," ",p.jsx("span",{className:"font-medium text-ink",children:s?p.jsx(br,{size:"sm",className:"mr-0.5 align-middle"}):o(i?.default_registration_credits)})," ","in bonus credits with your first purchase.",a&&p.jsx("span",{className:"mt-1 block text-meta text-danger",children:"Could not load bonus credit information."})]}),p.jsx("p",{className:"text-meta text-ink-dim",children:"You can also reach the Radient Console from Settings at any time."})]})})},FSe=({expanded:e})=>p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[p.jsx("img",{src:CWe,alt:e?"":"Local Operator",loading:"eager",className:"size-6 shrink-0"}),e&&p.jsx("span",{className:"truncate font-semibold text-body text-ink",children:"Local Operator"})]}),iWe=Z.memo(({expanded:e,useAuth:t=!1})=>{const n=Xa(),{user:r,isAuthenticated:i,signOut:s}=DB(),a=r?.name??"User",o=r?.email??"",l=w.useCallback(async()=>{i&&(await s(),window.location.reload())},[i,s]),c=w.useMemo(()=>a?a.split(" ").map(h=>h.charAt(0)).join("").toUpperCase().substring(0,2):null,[a]),u=p.jsxs("button",{type:"button",onClick:t?void 0:()=>n("/settings"),"aria-label":e?void 0:"Account settings",className:I("flex w-full items-center gap-2 rounded-sm transition-colors duration-fast ease-out-quart hover:bg-elevated",e?"px-3 py-1.5":"justify-center py-1.5"),children:[p.jsx(ZSe,{className:"size-7 shrink-0",children:p.jsx(HSe,{className:"bg-elevated text-ink",children:c??p.jsx(Yke,{size:14,"aria-hidden":"true"})})}),e&&a&&p.jsxs("span",{className:"min-w-0 text-left",children:[p.jsx("span",{className:"block truncate text-body-sm text-ink",children:a}),o&&p.jsx("span",{className:"block truncate text-meta text-ink-dim",children:o})]})]}),d=e?u:p.jsx(Ot,{content:"Account settings",side:"right",children:u});return t?p.jsxs(X_,{children:[e?p.jsx(Ub,{asChild:!0,children:u}):p.jsx(Ot,{content:"Account settings",side:"right",children:p.jsx(Ub,{asChild:!0,children:u})}),p.jsxs(D_,{align:"end",side:"top",className:"min-w-50",children:[p.jsxs(ks,{onSelect:()=>n("/settings"),children:[p.jsx(Xf,{size:16,"aria-hidden":"true"}),"Settings"]}),p.jsxs(ks,{children:[p.jsx(Wke,{size:16,"aria-hidden":"true"}),"Privacy and security"]}),p.jsx(ib,{}),p.jsxs(ks,{onSelect:l,className:"text-danger focus:bg-danger-wash focus:text-danger",children:[p.jsx(yHe,{size:16,"aria-hidden":"true"}),"Sign out"]})]})]}):d});iWe.displayName="UserProfileSidebar";const MSe={expanded:"w-55",collapsed:"w-12"},MUn=()=>{const e=Xa(),t=Wrt(),{isSidebarCollapsed:n,toggleSidebar:r}=sr(),i=!n,s=[{icon:PA,label:"Chat",path:"/chat",isActive:t==="chat",tourTag:"nav-item-chat"},{icon:mw,label:"My agents",path:"/agents",isActive:t==="agents",tourTag:"nav-item-agents"},{icon:Bke,label:"Agent hub",path:"/agent-hub",isActive:t==="agent-hub",tourTag:"nav-item-agent-hub"},{icon:Eke,label:"Schedules",path:"/schedules",isActive:t==="schedules",tourTag:"nav-item-schedules"},{icon:Xf,label:"Settings",path:"/settings",isActive:t==="settings",tourTag:"nav-item-settings"}],a=c=>{const u=p.jsxs("button",{type:"button",onClick:()=>e(c.path),"data-tour-tag":c.tourTag,"aria-current":c.isActive?"page":void 0,"aria-label":i?void 0:c.label,className:I("flex h-8 w-full items-center rounded-sm text-body-sm transition-colors duration-fast ease-out-quart",i?"justify-start gap-2 px-3":"justify-center",c.isActive?"bg-accent-wash font-medium text-ink":"text-ink-muted hover:bg-elevated hover:text-ink"),children:[p.jsx(c.icon,{size:16,"aria-hidden":"true",className:I("shrink-0",c.isActive&&"text-accent")}),i&&p.jsx("span",{className:"truncate",children:c.label})]});return i?p.jsx("li",{children:u},c.path):p.jsx("li",{children:p.jsx(Ot,{content:c.label,side:"right",children:u})},c.path)},o=i?"Collapse sidebar":"Expand sidebar",l=p.jsx("div",{className:I("pointer-events-none opacity-0 transition-opacity duration-fast ease-out-quart","group-hover:pointer-events-auto group-hover:opacity-100","group-focus-within:pointer-events-auto group-focus-within:opacity-100"),children:p.jsx(Ot,{content:o,side:"right",children:p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":o,"aria-expanded":i,children:i?p.jsx(Zb,{"aria-hidden":"true"}):p.jsx(rO,{"aria-hidden":"true"})})})});return p.jsxs("nav",{className:I("group flex shrink-0 flex-col overflow-x-hidden bg-sunken transition-[width] duration-base ease-out-quart",i?MSe.expanded:MSe.collapsed),children:[p.jsx("div",{className:I("flex h-12 shrink-0 items-center",i?"justify-between pr-2 pl-5":"justify-center"),children:i?p.jsxs(p.Fragment,{children:[p.jsx(FSe,{expanded:!0}),l]}):p.jsxs("div",{className:"relative flex size-8 items-center justify-center",children:[p.jsx("div",{className:"transition-opacity duration-fast ease-out-quart group-hover:opacity-0 group-focus-within:opacity-0",children:p.jsx(FSe,{expanded:!1})}),p.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l})]})}),p.jsx("ul",{className:"flex flex-col gap-1 p-2",children:s.map(a)}),p.jsx("div",{className:"mt-auto p-2",children:p.jsx(iWe,{expanded:i})})]})},LUn=1,jUn=()=>{const{isAuthenticated:e,user:t}=DB(),{hasBeenNotified:n,setHasBeenNotified:r}=rWe(),[i,s]=w.useState(!1),[a,o]=w.useState(null),l=w.useCallback(async()=>{if(!(!e||!t?.radientUser?.account?.tenant_id))try{const h=await XB({operation:"credits",tenantId:t.radientUser.account.tenant_id});if(!h||typeof h.balance!="number")throw new Error("Invalid credit balance response format");o(h.balance)}catch(h){console.error("Failed to fetch Radient credits:",h),o(null)}},[e,t?.radientUser?.account?.tenant_id]);return w.useEffect(()=>{e&&l()},[e,l]),w.useEffect(()=>{e&&a!==null?a<LUn?n||s(!0):(s(!1),n&&r(!1)):s(!1)},[e,n,a,r]),{isLowCreditsDialogOpen:i,openRadientConsole:()=>{window.api?.openExternal?window.api.openExternal("https://console.radienthq.com"):window.open("https://console.radienthq.com","_blank"),r(!0),s(!1)},closeLowCreditsDialog:()=>{s(!1)},onLowCreditsDialogClose:()=>{r(!0),s(!1)},currentCredits:a}},qUn=w.lazy(()=>Ie(()=>import("./agent-details-page-DC13Jibh.js"),__vite__mapDeps([8,1,2,9,10]),import.meta.url).then(e=>({default:e.AgentDetailsPage}))),zUn=w.lazy(()=>Ie(()=>import("./agent-hub-page-iulwy94G.js"),__vite__mapDeps([11,1,2,12,13,10]),import.meta.url).then(e=>({default:e.AgentHubPage}))),LSe=w.lazy(()=>Ie(()=>import("./agents-page-BSegINKc.js"),__vite__mapDeps([14,1,2]),import.meta.url).then(e=>({default:e.AgentsPage}))),UUn=w.lazy(()=>Ie(()=>import("./schedules-page-xXMGrdrg.js"),__vite__mapDeps([15,1,2,13,16,9]),import.meta.url).then(e=>({default:e.SchedulesPage}))),WUn=w.lazy(()=>Ie(()=>import("./settings-page-PLBi7GEM.js"),__vite__mapDeps([17,1,2,13,9,18,16]),import.meta.url).then(e=>({default:e.SettingsPage}))),GUn=()=>{const{isOnboardingActive:e}=Rrt(),{isLowCreditsDialogOpen:t,openRadientConsole:n,onLowCreditsDialogClose:r}=jUn(),{toggleCommandPalette:i,isCommandPaletteOpen:s,isCreateAgentDialogOpen:a,closeCreateAgentDialog:o}=sr(),l=Xa(),c=d=>{l(`/chat/${d}`),o()};w.useEffect(()=>{const d=()=>{i()},h=window.electron.ipcRenderer.on("toggle-command-palette",d);return()=>{h&&h()}},[i]);const u=ir(d=>d.setActiveSession);return w.useEffect(()=>{const d=window.api?.desktop?.onOpenConversation?.(h=>{u(h),l("/chat")});return()=>d?.()},[l,u]),p.jsx(XUn,{children:p.jsxs("div",{className:"relative flex h-screen overflow-hidden",children:[s&&p.jsx(Ejn,{}),p.jsx(WTe,{}),p.jsx(rqn,{open:e}),p.jsx(xrt,{}),p.jsx(DUn,{}),p.jsx(Rit,{}),p.jsx(FUn,{open:t,onClose:r,onGoToConsole:n}),p.jsx(UTe,{open:a,onClose:o,onAgentCreated:c}),p.jsx(MUn,{}),p.jsx("main",{className:"flex grow flex-col overflow-hidden",children:p.jsx(w.Suspense,{fallback:p.jsx("div",{className:"flex grow items-center justify-center",children:p.jsx(br,{size:"lg",label:"Loading page"})}),children:p.jsxs(pYe,{children:[p.jsx(Iu,{path:"/",element:p.jsx(Tne,{to:"/chat",replace:!0})}),p.jsx(Iu,{path:"/chat",element:p.jsx(qxe,{})}),p.jsx(Iu,{path:"/chat/:agentId",element:p.jsx(qxe,{})}),p.jsx(Iu,{path:"/agents",element:p.jsx(LSe,{})}),p.jsx(Iu,{path:"/agents/:agentId",element:p.jsx(LSe,{})}),p.jsx(Iu,{path:"/settings",element:p.jsx(WUn,{})}),p.jsx(Iu,{path:"/agent-hub",element:p.jsx(zUn,{})}),p.jsx(Iu,{path:"/agent-hub/:agentId",element:p.jsx(qUn,{})}),p.jsx(Iu,{path:"/schedules",element:p.jsx(UUn,{})}),p.jsx(Iu,{path:"*",element:p.jsx(Tne,{to:"/chat",replace:!0})})]})})})]})})},VUn={queries:{staleTime:5*60*1e3,gcTime:10*60*1e3,retry:1,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!1,networkMode:"always"},mutations:{retry:1,networkMode:"always"}},sWe=new VWe({defaultOptions:VUn}),BUn=`
1412
1412
  *::-webkit-scrollbar {
1413
1413
  width: 8px;
1414
1414
  height: 8px;