local-operator-ui 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/renderer/assets/{_basePickBy-FfClaKQg.js → _basePickBy-C7yOlBwG.js} +1 -1
- package/out/renderer/assets/{_baseUniq-C9SvGZui.js → _baseUniq-BxWDXUxR.js} +1 -1
- package/out/renderer/assets/{agent-details-page-AoSG_fVH.js → agent-details-page-DGusXpiv.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-CaZjaTZe.js → agent-hub-page-BEy-xjst.js} +1 -1
- package/out/renderer/assets/{agents-page-RS6PE_fF.js → agents-page-VfOUQ-yP.js} +2 -2
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-Be7LQKHg.js → architectureDiagram-IEHRJDOE-358ZDLa0.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-iWnvArS2.js → blockDiagram-JOT3LUYC-tzEHVS4j.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-BBuir5yQ.js → c4Diagram-VJAJSXHY-D3tP-CCo.js} +1 -1
- package/out/renderer/assets/channel-D37fF6my.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-DzRvFZnz.js → chunk-4BMEZGHF-BKUSTR_S.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-4uP9DbW7.js → chunk-A2AXSNBT-DvXPJSTp.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-BL3rbHq4.js → chunk-AEK57VVT-iJyV8fDW.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-D6wbdfUw.js → chunk-D6G4REZN-B3DDJ3MU.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-D2Fl_NaB.js → chunk-RZ5BOZE2-Dbn_07ZJ.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-DN5jo0Xq.js → chunk-XZIHB7SX-ChdMxZnm.js} +1 -1
- package/out/renderer/assets/{classDiagram-GIVACNV2-yxaMQW5a.js → classDiagram-GIVACNV2-CcnNtrPC.js} +1 -1
- package/out/renderer/assets/{classDiagram-v2-COTLJTTW-yxaMQW5a.js → classDiagram-v2-COTLJTTW-CcnNtrPC.js} +1 -1
- package/out/renderer/assets/clone-DPqLvbSr.js +1 -0
- package/out/renderer/assets/{compact-pagination-20O8NjDK.js → compact-pagination-duvMYksr.js} +1 -1
- package/out/renderer/assets/{dagre-OKDRZEBW-BYIesx33.js → dagre-OKDRZEBW-BuSM1V0w.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DP6lL-Te.js → diagram-SSKATNLV-39xt9Mcn.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-bmsCnWFr.js → diagram-VNBRO52H-Bgyt_DWD.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-EsgbzeoI.js → erDiagram-Q7BY3M3F-DNfsSD46.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-DOiNzXZN.js → flowDiagram-4HSFHLVR-DbS8UHwN.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-DJmMxmWH.js → ganttDiagram-APWFNJXF-Dxdp2V-6.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-CsW8qQBE.js → gitGraphDiagram-7IBYFJ6S-BLrXJPe3.js} +1 -1
- package/out/renderer/assets/{graph-DPdUvm6W.js → graph-Cgkq5xQ7.js} +1 -1
- package/out/renderer/assets/{index-C2JWjezT.js → index-C4RcIL0i.js} +1 -1
- package/out/renderer/assets/{index-DTxYU-h1.js → index-CLwRuOtJ.js} +5 -5
- package/out/renderer/assets/{index-BHWYYomf.js → index-lEoaSpWQ.js} +1 -1
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-DlGp0OAs.js → infoDiagram-PH2N3AL5-DR6So_J8.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-BMKeuZdQ.js → journeyDiagram-U35MCT3I-DubpieGX.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-CBMkFWiV.js → kanban-definition-NDS4AKOZ-BtwsU2Rg.js} +1 -1
- package/out/renderer/assets/{layout-CQLCCDdm.js → layout-BDeRPl4h.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-DaL-s8eO.js → legacy-agents-page-ZyBMetf1.js} +1 -1
- package/out/renderer/assets/{mermaid.core-zhMaqo9l.js → mermaid.core-d-O-_a6F.js} +5 -5
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-ChxcwGV6.js → mindmap-definition-ALO5MXBD-BCZdiKEB.js} +1 -1
- package/out/renderer/assets/{parseISO-Bgv71POy.js → parseISO-PdZfrqAM.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-BMEW9BJi.js → pieDiagram-IB7DONF6-Bd2e7gHe.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-D-ErPCKs.js → quadrantDiagram-7GDLP6J5-oypZsih9.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-2tp4r77h.js → radar-MK3ICKWK-c4YagPOX.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-klNSjDud.js → radient-auth-buttons-BUlY7XDi.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-nNjxV4M0.js → requirementDiagram-KVF5MWMF-7UoAwEus.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-HK65A8n7.js → sankeyDiagram-QLVOVGJD-JStPMuRd.js} +1 -1
- package/out/renderer/assets/{schedules-page-CLrcFhCL.js → schedules-page-IjBtVuIo.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-D3VDaA9I.js → sequenceDiagram-X6HHIX6F-Lene9gQ-.js} +1 -1
- package/out/renderer/assets/{settings-page-CKVWBbsu.js → settings-page-BqJRfztd.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-BJMfya--.js → stateDiagram-DGXRK772-umC2tGUK.js} +1 -1
- package/out/renderer/assets/{stateDiagram-v2-YXO3MK2T-CmCw0Yzl.js → stateDiagram-v2-YXO3MK2T-Cp1tcztr.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-wvXoFLOl.js → timeline-definition-BDJGKUSR-h2KfXqek.js} +1 -1
- package/out/renderer/assets/{use-agent-like-mutation-DAmS19om.js → use-agent-like-mutation-BanZ02f7.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-DnyQ060j.js → xychartDiagram-VJFVF3MP-BOH5ZQcH.js} +1 -1
- package/out/renderer/index.html +1 -1
- package/package.json +2 -2
- package/out/renderer/assets/channel-D4JK8GjQ.js +0 -1
- package/out/renderer/assets/clone-B7rlppnW.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-d-O-_a6F.js","./icon-RIkwUxL5.js","./icon-HSrrv8O-.css","./step-DMJAOHzS.js","./katex-BCx1q_2Y.css","./index-lEoaSpWQ.js","./index-C4RcIL0i.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./agent-details-page-DGusXpiv.js","./square-pen-CQEKS3JT.js","./use-agent-like-mutation-BanZ02f7.js","./agent-hub-page-BEy-xjst.js","./compact-pagination-duvMYksr.js","./page-header-D-uc8qqA.js","./agents-page-VfOUQ-yP.js","./schedules-page-IjBtVuIo.js","./parseISO-PdZfrqAM.js","./settings-page-BqJRfztd.js","./radient-auth-buttons-BUlY7XDi.js","./band-CquvqAHh.js","./init-Dmth1JHB.js","./ordinal-DILIJJjt.js","./linear-BfLTrHPc.js","./time-BOTM2Tp0.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as b,j as p,m as Oe,a3 as YA,a as Fe,a6 as aie,B as Te,c as G,ac as cC,ad as uC,ae as BTe,af as sy,ag as ZTe,ah as BA,ai as BF,a4 as HTe,aj as KTe,a2 as JTe,D as e2e,A as qc,X as Rs,z as dC,L as Xs,I as yi,T as QO,S as Pr,Y as uc,ak as oie,h as zn,al as Uz,g as vt,y as t2e,f as Ru,_ as Wz,x as lie,t as eS,s as o1,C as og,am as ZF,an as tS,W as n2e,n as nS,o as l1,p as rS,q as ts,ao as cie,a9 as uie,b as ZA,P as HF,v as die,w as KF,M as ay,N as oy,O as ly,Q as cy,U as uy,ap as P0,i as JF,V as r2e,H as T2,aq as y5,ar as i2e,as as s2e,at as a2e,d as hie,e as fie,au as o2e,av as l2e,aw as c2e,ax as u2e,E as Oie,ay as pie,az as d2e,u as dy,l as h2e,k as f2e,R as O2e}from"./icon-RIkwUxL5.js";var rv=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(){}},lg=typeof window>"u"||"Deno"in globalThis;function Ml(){}function p2e(e,t){return typeof e=="function"?e(t):e}function HA(e){return typeof e=="number"&&e>=0&&e!==1/0}function gie(e,t){return Math.max(e+(t||0)-Date.now(),0)}function _0(e,t){return typeof e=="function"?e(t):e}function Xc(e,t){return typeof e=="function"?e(t):e}function Gz(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:a,stale:o}=e;if(a){if(r){if(t.queryHash!==e8(a,t.options))return!1}else if(!hy(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 jz(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(cg(t.options.mutationKey)!==cg(s))return!1}else if(!hy(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function e8(e,t){return(t?.queryKeyHashFn||cg)(e)}function cg(e){return JSON.stringify(e,(t,n)=>KA(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function hy(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>hy(e[n],t[n])):!1}function mie(e,t){if(e===t)return e;const n=Vz(e)&&Vz(t);if(n||KA(e)&&KA(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]=mie(e[u],t[u]),o[u]===e[u]&&e[u]!==void 0&&l++)}return i===a&&l===i?e:o}return t}function P2(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 Vz(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function KA(e){if(!Yz(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Yz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Yz(e){return Object.prototype.toString.call(e)==="[object Object]"}function g2e(e){return new Promise(t=>{setTimeout(t,e)})}function JA(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?mie(e,t):t}function vie(e){return e}function m2e(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function v2e(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var t8=Symbol();function wie(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===t8?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var w2e=class extends rv{#t;#e;#n;constructor(){super(),this.#n=e=>{if(!lg&&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"}},n8=new w2e,b2e=class extends rv{#t=!0;#e;#n;constructor(){super(),this.#n=e=>{if(!lg&&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}},_2=new b2e;function eX(){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 y2e(e){return Math.min(1e3*2**e,3e4)}function bie(e){return(e??"online")==="online"?_2.isOnline():!0}var yie=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function x5(e){return e instanceof yie}function xie(e){let t=!1,n=0,r=!1,i;const s=eX(),a=g=>{r||(h(new yie(g)),e.abort?.())},o=()=>{t=!0},l=()=>{t=!1},c=()=>n8.isFocused()&&(e.networkMode==="always"||_2.isOnline())&&e.canRun(),u=()=>bie(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 w=e.retry??(lg?0:3),y=e.retryDelay??y2e,T=typeof y=="function"?y(n,v):y,x=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,v);if(t||!x){h(v);return}n++,e.onFail?.(n,v),g2e(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 x2e=e=>setTimeout(e,0);function S2e(){let e=[],t=0,n=o=>{o()},r=o=>{o()},i=x2e;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 Qs=S2e(),Sie=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),HA(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(lg?1/0:5*60*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},$2e=class extends Sie{#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=k2e(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=JA(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(Ml).catch(Ml):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>Xc(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===t8||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||!gie(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=wie(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=>{x5(o)&&o.silent||this.#s({type:"error",error:o}),x5(o)||(this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this)),this.scheduleGc()};return this.#i=xie({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,...$ie(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 x5(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),Qs.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function $ie(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:bie(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function k2e(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 T2e=class extends rv{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,n){const r=t.queryKey,i=t.queryHash??e8(r,t);let s=this.get(i);return s||(s=new $2e({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(){Qs.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=>Gz(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>Gz(e,n)):t}notify(e){Qs.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Qs.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Qs.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},P2e=class extends Sie{#t;#e;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||kie(),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=xie({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),Qs.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function kie(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var _2e=class extends rv{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 P2e({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#t.add(e);const t=r$(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=r$(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=r$(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=r$(e);return typeof t=="string"?this.#e.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Qs.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=>jz(t,n))}findAll(e={}){return this.getAll().filter(t=>jz(e,t))}notify(e){Qs.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return Qs.batch(()=>Promise.all(e.map(t=>t.continue().catch(Ml))))}};function r$(e){return e.options.scope?.id}function Bz(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=wie(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 w=await h(v),{maxPages:y}=t.options,T=m?v2e:m2e;return{pages:T(O.pages,w,y),pageParams:T(O.pageParams,g,y)}};if(i&&s.length){const O=i==="backward",g=O?C2e:Zz,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:Zz(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 Zz(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 C2e(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Q2e=class{#t;#e;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#t=e.queryCache||new T2e,this.#e=e.mutationCache||new _2e,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=n8.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=_2.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(_0(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=p2e(t,s);if(a!==void 0)return this.#t.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Qs.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;Qs.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#t;return Qs.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Qs.batch(()=>this.#t.findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Ml).catch(Ml)}invalidateQueries(e,t={}){return Qs.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=Qs.batch(()=>this.#t.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(Ml)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Ml)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#t.build(this,t);return n.isStaleByTime(_0(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ml).catch(Ml)}fetchInfiniteQuery(e){return e.behavior=Bz(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ml).catch(Ml)}ensureInfiniteQueryData(e){return e.behavior=Bz(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return _2.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(cg(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(r=>{hy(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(cg(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#i.values()],n={};return t.forEach(r=>{hy(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=e8(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===t8&&(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()}},E2e=class extends rv{constructor(e,t){super(),this.options=t,this.#t=e,this.#s=null,this.#o=eX(),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),Hz(this.#e,this.options)?this.#d():this.updateResult(),this.#w())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return tX(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return tX(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#y(),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 Xc(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&&!P2(this.options,t)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Kz(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),r&&(this.#e!==n||Xc(this.options.enabled,this.#e)!==Xc(t.enabled,this.#e)||_0(this.options.staleTime,this.#e)!==_0(t.staleTime,this.#e))&&this.#g();const i=this.#m();r&&(this.#e!==n||Xc(this.options.enabled,this.#e)!==Xc(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 A2e(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(Ml)),t}#g(){this.#b();const e=_0(this.options.staleTime,this.#e);if(lg||this.#r.isStale||!HA(e))return;const n=gie(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.#y(),this.#l=e,!(lg||Xc(this.options.enabled,this.#e)===!1||!HA(this.#l)||this.#l===0)&&(this.#u=setInterval(()=>{(this.options.refetchIntervalInBackground||n8.isFocused())&&this.#d()},this.#l))}#w(){this.#g(),this.#v(this.#m())}#b(){this.#c&&(clearTimeout(this.#c),this.#c=void 0)}#y(){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 Q=this.hasListeners(),R=!Q&&Hz(e,t),_=Q&&Kz(e,n,t,r);(R||_)&&(u={...u,...$ie(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 Q;i?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(Q=i.data,m=!0):Q=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,Q!==void 0&&(g="success",h=JA(i?.data,Q,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=JA(i?.data,h,t),this.#h=h,this.#s=null}catch(Q){this.#s=Q}this.#s&&(f=this.#s,h=this.#h,O=Date.now(),g="error");const v=u.fetchStatus==="fetching",w=g==="pending",y=g==="error",T=w&&v,x=h!==void 0,S={status:g,fetchStatus:u.fetchStatus,isPending:w,isSuccess:g==="success",isError:y,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&&!w,isLoadingError:y&&!x,isPaused:u.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:y&&x,isStale:r8(e,t),refetch:this.refetch,promise:this.#o};if(this.options.experimental_prefetchInRender){const Q=A=>{S.status==="error"?A.reject(S.error):S.data!==void 0&&A.resolve(S.data)},R=()=>{const A=this.#o=S.promise=eX();Q(A)},_=this.#o;switch(_.status){case"pending":e.queryHash===n.queryHash&&Q(_);break;case"fulfilled":(S.status==="error"||S.data!==_.value)&&R();break;case"rejected":(S.status!=="error"||S.error!==_.reason)&&R();break}}return S}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),P2(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.#w()}#S(e){Qs.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function R2e(e,t){return Xc(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Hz(e,t){return R2e(e,t)||e.state.data!==void 0&&tX(e,t,t.refetchOnMount)}function tX(e,t,n){if(Xc(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&r8(e,t)}return!1}function Kz(e,t,n,r){return(e!==t||Xc(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&r8(e,n)}function r8(e,t){return Xc(t.enabled,e)!==!1&&e.isStaleByTime(_0(t.staleTime,e))}function A2e(e,t){return!P2(e.getCurrentResult(),t)}var X2e=class extends rv{#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),P2(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&cg(n.mutationKey)!==cg(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??kie();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){Qs.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)})})}},Tie=b.createContext(void 0),ks=e=>{const t=b.useContext(Tie);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Pie=({client:e,children:t})=>(b.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),p.jsx(Tie.Provider,{value:e,children:t})),_ie=b.createContext(!1),D2e=()=>b.useContext(_ie);_ie.Provider;function I2e(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var F2e=b.createContext(I2e()),N2e=()=>b.useContext(F2e);function Cie(e,t){return typeof e=="function"?e(...t):!!e}function nX(){}var M2e=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},z2e=e=>{b.useEffect(()=>{e.clearReset()},[e])},L2e=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Cie(n,[e.error,r])),q2e=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)))},U2e=(e,t)=>e.isLoading&&e.isFetching&&!t,W2e=(e,t)=>e?.suspense&&t.isPending,Jz=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function G2e(e,t,n){const r=ks(),i=D2e(),s=N2e(),a=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=i?"isRestoring":"optimistic",q2e(a),M2e(a,s),z2e(s);const o=!r.getQueryCache().get(a.queryHash),[l]=b.useState(()=>new t(r,a)),c=l.getOptimisticResult(a),u=!i&&e.subscribed!==!1;if(b.useSyncExternalStore(b.useCallback(d=>{const h=u?l.subscribe(Qs.batchCalls(d)):nX;return l.updateResult(),h},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),b.useEffect(()=>{l.setOptions(a)},[a,l]),W2e(a,c))throw Jz(a,l,s);if(L2e({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&&!lg&&U2e(c,i)&&(o?Jz(a,l,s):r.getQueryCache().get(a.queryHash)?.promise)?.catch(nX).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?c:l.trackResult(c)}function _r(e,t){return G2e(e,E2e)}function mo(e,t){const n=ks(),[r]=b.useState(()=>new X2e(n,e));b.useEffect(()=>{r.setOptions(e)},[r,e]);const i=b.useSyncExternalStore(b.useCallback(a=>r.subscribe(Qs.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=b.useCallback((a,o)=>{r.mutate(a,o).catch(nX)},[r]);if(i.error&&Cie(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const j2e=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),V2e=function(e,t){return new URL(e,t).href},eL={},Ae=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=V2e(c,r),c in eL)return;eL[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":j2e,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 Dc,Ne=typeof window<"u"?window:void 0,Do=typeof globalThis<"u"?globalThis:Ne,Qie=Array.prototype,tL=Qie.forEach,nL=Qie.indexOf,fl=Do?.navigator,jt=Do?.document,Qo=Do?.location,rX=Do?.fetch,iX=Do!=null&&Do.XMLHttpRequest&&"withCredentials"in new Do.XMLHttpRequest?Do.XMLHttpRequest:void 0,rL=Do?.AbortController,vs=fl?.userAgent,Xn=Ne??{},Hd={DEBUG:!1,LIB_VERSION:"1.235.6"},S5="$copy_autocapture",Y2e=["$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"})(Dc||(Dc={}));var B2e=["fatal","error","warning","log","info","debug"];function or(e,t){return e.indexOf(t)!==-1}var hC=function(e){return e.trim()},i8=function(e){return e.replace(/^\$/,"")},Z2e=Array.isArray,Eie=Object.prototype,Rie=Eie.hasOwnProperty,fC=Eie.toString,ji=Z2e||function(e){return fC.call(e)==="[object Array]"},Uc=e=>typeof e=="function",Vi=e=>e===Object(e)&&!ji(e),f0=e=>{if(Vi(e)){for(var t in e)if(Rie.call(e,t))return!1;return!0}return!1},Mt=e=>e===void 0,xs=e=>fC.call(e)=="[object String]",sX=e=>xs(e)&&e.trim().length===0,EO=e=>e===null,Wr=e=>Mt(e)||EO(e),lo=e=>fC.call(e)=="[object Number]",ih=e=>fC.call(e)==="[object Boolean]",H2e=e=>e instanceof FormData,K2e=e=>or(Y2e,e),Aie=e=>{var t={_log:function(n){if(Ne&&(Hd.DEBUG||Xn.POSTHOG_DEBUG)&&!Mt(Ne.console)&&Ne.console){for(var r=("__rrweb_original__"in Ne.console[n])?Ne.console[n].__rrweb_original__:Ne.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=>Aie("".concat(e," ").concat(n))};return t},sn=Aie("[PostHog.js]"),ja=sn.createLogger,J2e=ja("[ExternalScriptsLoader]"),iL=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return J2e.warn("".concat(t," was requested but loading of external scripts is disabled.")),n("Loading of external scripts is disabled");var r=jt?.querySelectorAll("script");if(r){for(var i=0;i<r.length;i++)if(r[i].src===t)return n()}var s=()=>{if(!jt)return n("document not found");var a=jt.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=jt.querySelectorAll("body > script");l.length>0?(o=l[0].parentNode)===null||o===void 0||o.insertBefore(a,l[0]):jt.body.appendChild(a)};jt!=null&&jt.body?s():jt?.addEventListener("DOMContentLoaded",s)};function sL(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 Ge(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?sL(Object(n),!0).forEach(function(r){xt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sL(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function xt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Xie(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}Xn.__PosthogExtensions__=Xn.__PosthogExtensions__||{},Xn.__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);iL(e,a,n)},Xn.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var r=e.requestRouter.endpointFor("api",t);iL(e,r,n)};var C2={};function Jf(e,t,n){if(ji(e)){if(tL&&e.forEach===tL)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)===C2)return}}}function ti(e,t,n){if(!Wr(e)){if(ji(e))return Jf(e,t,n);if(H2e(e)){for(var r of e.entries())if(t.call(n,r[1],r[0])===C2)return}else for(var i in e)if(Rie.call(e,i)&&t.call(n,e[i],i)===C2)return}}var ns=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 Jf(n,function(i){for(var s in i)i[s]!==void 0&&(e[s]=i[s])}),e},gT=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 Jf(n,function(i){Jf(i,function(s){e.push(s)})}),e};function mT(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 aL=function(e){try{return e()}catch{return}},ePe=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){sn.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),sn.critical(i)}}},fy=function(e){var t={};return ti(e,function(n,r){xs(n)&&n.length>0&&(t[r]=n)}),t};function tPe(e,t){return n=e,r=s=>xs(s)&&!EO(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),ji(a)?(l=[],Jf(a,c=>{l.push(s(c))})):(l={},ti(a,(c,u)=>{i.has(c)||(l[u]=s(c,u))})),l);var l}(n);var n,r,i}var nPe=["herokuapp.com","vercel.app","netlify.app"];function rPe(e){var t=e?.hostname;if(!xs(t))return!1;var n=t.split(".").slice(-2).join(".");for(var r of nPe)if(n===r)return!1;return!0}function Die(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n]}function is(e,t,n,r){var{capture:i=!1,passive:s=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:s})}var Iie="$people_distinct_id",Xw="__alias",Dw="__timers",oL="$autocapture_disabled_server_side",aX="$heatmaps_enabled_server_side",lL="$exception_capture_enabled_server_side",cL="$web_vitals_enabled_server_side",Fie="$dead_clicks_enabled_server_side",uL="$web_vitals_allowed_metrics",oX="$session_recording_enabled_server_side",dL="$console_log_recording_enabled_server_side",hL="$session_recording_network_payload_capture",fL="$session_recording_masking",OL="$session_recording_canvas_recording",pL="$replay_sample_rate",gL="$replay_minimum_duration",mL="$replay_script_config",Q2="$sesid",Iw="$session_is_sampled",$5="$session_recording_url_trigger_activated_session",k5="$session_recording_event_trigger_activated_session",O0="$enabled_feature_flags",vT="$early_access_features",lX="$feature_flag_details",Fw="$stored_person_properties",vp="$stored_group_properties",cX="$surveys",i$="$surveys_activated",E2="$flag_call_reported",Ud="$user_state",uX="$client_session_props",dX="$capture_rate_limit",hX="$initial_campaign_params",fX="$initial_referrer_info",OX="$initial_person_info",R2="$epp",Nie="__POSTHOG_TOOLBAR__",vL="$posthog_cookieless",iPe=[Iie,Xw,"__cmpns",Dw,oX,aX,Q2,O0,Ud,vT,lX,vp,Fw,cX,E2,uX,dX,hX,fX,R2];function wL(e){var t;return e instanceof Element&&(e.id===Nie||!((t=e.closest)===null||t===void 0||!t.call(e,".toolbar-global-fade-container")))}function OC(e){return!!e&&e.nodeType===1}function eO(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Mie(e){return!!e&&e.nodeType===3}function zie(e){return!!e&&e.nodeType===11}function s8(e){return e?hC(e).split(/\s+/):[]}function bL(e){var t=Ne?.location.href;return!!(t&&e&&e.some(n=>t.match(n)))}function A2(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 s8(t)}function Lie(e){return Wr(e)?null:hC(e).split(/(\s+)/).filter(t=>c1(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function pC(e){var t="";return gX(e)&&!Wie(e)&&e.childNodes&&e.childNodes.length&&ti(e.childNodes,function(n){var r;Mie(n)&&n.textContent&&(t+=(r=Lie(n.textContent))!==null&&r!==void 0?r:"")}),hC(t)}function qie(e){return Mt(e.target)?e.srcElement||null:(t=e.target)!==null&&t!==void 0&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var pX=["a","button","form","input","select","textarea","label"];function Uie(e){var t=e.parentNode;return!(!t||!OC(t))&&t}function sPe(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(!Ne||!e||eO(e,"html")||!OC(e)||n!=null&&n.url_allowlist&&!bL(n.url_allowlist)||n!=null&&n.url_ignorelist&&bL(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&&!eO(c,"body");)if(zie(c.parentNode))o.push(c.parentNode.host),c=c.parentNode.host;else{if(!(l=Uie(c)))break;if(r||pX.indexOf(l.tagName.toLowerCase())>-1)a=!0;else{var u=Ne.getComputedStyle(l);u&&u.getPropertyValue("cursor")==="pointer"&&(a=!0)}o.push(l),c=l}if(!function(f,O){var g=O?.element_allowlist;if(Mt(g))return!0;var m=function(y){if(g.some(T=>y.tagName.toLowerCase()===T))return{v:!0}};for(var v of f){var w=m(v);if(typeof w=="object")return w.v}return!1}(o,n)||!function(f,O){var g=O?.css_selector_allowlist;if(Mt(g))return!0;var m=function(y){if(g.some(T=>y.matches(T)))return{v:!0}};for(var v of f){var w=m(v);if(typeof w=="object")return w.v}return!1}(o,n))return!1;var d=Ne.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&&(pX.indexOf(h)>-1||e.getAttribute("contenteditable")==="true")}}function gX(e){for(var t=e;t.parentNode&&!eO(t,"body");t=t.parentNode){var n=A2(t);if(or(n,"ph-sensitive")||or(n,"ph-no-capture"))return!1}if(or(A2(e),"ph-include"))return!0;var r=e.type||"";if(xs(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=e.name||e.id||"";return!(xs(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 Wie(e){return!!(eO(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||eO(e,"select")||eO(e,"textarea")||e.getAttribute("contenteditable")==="true")}var Gie="(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})",aPe=new RegExp("^(?:".concat(Gie,")$")),oPe=new RegExp(Gie),jie="\\d{3}-?\\d{2}-?\\d{4}",lPe=new RegExp("^(".concat(jie,")$")),cPe=new RegExp("(".concat(jie,")"));function c1(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(Wr(e)||xs(e)&&(e=hC(e),(t?aPe:oPe).test((e||"").replace(/[- ]/g,""))||(t?lPe:cPe).test(e)))}function Vie(e){var t=pC(e);return c1(t="".concat(t," ").concat(Yie(e)).trim())?t:""}function Yie(e){var t="";return e&&e.childNodes&&e.childNodes.length&&ti(e.childNodes,function(n){var r;if(n&&((r=n.tagName)===null||r===void 0?void 0:r.toLowerCase())==="span")try{var i=pC(n);t="".concat(t," ").concat(i).trim(),n.childNodes&&n.childNodes.length&&(t="".concat(t," ").concat(Yie(n)).trim())}catch(s){sn.error("[AutoCapture]",s)}}),t}function uPe(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=Ge(Ge(Ge(Ge({},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 mT(l).sort((u,d)=>{var[h]=u,[f]=d;return h.localeCompare(f)}).forEach(u=>{var[d,h]=u;return c[yL(d.toString())]=yL(h.toString())}),a+=":",a+=mT(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:dPe(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return mT(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 yL(e){return e.replace(/"|\\"/g,'\\"')}function dPe(e){var t=e.attr__class;return t?ji(t)?t:s8(t):void 0}class Bie{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 hPe=["localhost","127.0.0.1"],C0=e=>{var t=jt?.createElement("a");return Mt(t)?null:(t.href=e,t)},fPe=function(e){var t,n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",i=[];return ti(e,function(s,a){Mt(s)||Mt(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)},X2=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(!ji(n)||n.length<2)return"";var a=n[1];try{a=decodeURIComponent(a)}catch{sn.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},T5=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("=");ji(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},D2=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},xL=ja("[AutoCapture]");function P5(e,t){return t.length>e?t.slice(0,e)+"...":t}function OPe(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!OC(t));return t}function pPe(e,t,n,r){var i=e.tagName.toLowerCase(),s={tag_name:i};pX.indexOf(i)>-1&&!n&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=P5(1024,Vie(e)):s.$el_text=P5(1024,pC(e)));var a=A2(e);a.length>0&&(s.classes=a.filter(function(u){return u!==""})),ti(e.attributes,function(u){var d;if((!Wie(e)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!t&&c1(u.value)&&(d=u.name,!xs(d)||d.substring(0,10)!=="_ngcontent"&&d.substring(0,7)!=="_nghost")){var h=u.value;u.name==="class"&&(h=s8(h).join(" ")),s["attr__"+u.name]=P5(1024,h)}});for(var o=1,l=1,c=e;c=OPe(c);)o++,c.tagName===e.tagName&&l++;return s.nth_child=o,s.nth_of_type=l,s}function gPe(e,t){for(var n,r,{e:i,maskAllElementAttributes:s,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:l}=t,c=[e],u=e;u.parentNode&&!eO(u,"body");)zie(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(ti(c,T=>{var x=gX(T);T.tagName.toLowerCase()==="a"&&(O=T.getAttribute("href"),O=x&&O&&c1(O)&&O),or(A2(T),"ph-no-capture")&&(g=!0),h.push(pPe(T,s,a,o));var k=function(S){if(!gX(S))return{};var Q={};return ti(S.attributes,function(R){if(R.name&&R.name.indexOf("data-ph-capture-attribute")===0){var _=R.name.replace("data-ph-capture-attribute-",""),A=R.value;_&&A&&c1(A)&&(Q[_]=A)}}),Q}(T);ns(f,k)}),g)return{props:{},explicitNoCapture:g};if(a||(e.tagName.toLowerCase()==="a"||e.tagName.toLowerCase()==="button"?h[0].$el_text=Vie(e):h[0].$el_text=pC(e)),O){var m,v;h[0].attr__href=O;var w=(m=C0(O))===null||m===void 0?void 0:m.host,y=Ne==null||(v=Ne.location)===null||v===void 0?void 0:v.host;w&&y&&w!==y&&(d=O)}return{props:ns({$event_type:i.type,$ce_version:1},l?{}:{$elements:h},{$elements_chain:uPe(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 mPe=class{constructor(t){xt(this,"_initialized",!1),xt(this,"_isDisabledServerSide",null),xt(this,"rageclicks",new Bie),xt(this,"_elementsChainAsString",!1),this.instance=t,this._elementSelectors=null}get config(){var t,n,r=Vi(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(Ne&&jt){var t=r=>{r=r||Ne?.event;try{this._captureEvent(r)}catch(i){xL.error("Failed to capture event",i)}};if(is(jt,"submit",t,{capture:!0}),is(jt,"change",t,{capture:!0}),is(jt,"click",t,{capture:!0}),this.config.capture_copied_text){var n=r=>{r=r||Ne?.event,this._captureEvent(r,S5)};is(jt,"copy",n,{capture:!0}),is(jt,"cut",n,{capture:!0})}}}else xL.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({[oL]:!!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=jt?.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[oL],i=this._isDisabledServerSide;if(EO(i)&&!ih(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=qie(t);Mie(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===S5;if(i&&sPe(i,t,this.config,s,s?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:o}=gPe(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===S5){var c,u=Lie(Ne==null||(c=Ne.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 Uc(jt?.querySelectorAll)}};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return lo(e)&&isFinite(e)&&Math.floor(e)===e});var SL="0123456789abcdef";let vPe=class mX{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 mX(s)}toString(){for(var t="",n=0;n<this.bytes.length;n++)t=t+SL.charAt(this.bytes[n]>>>4)+SL.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 mX(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}},wPe=class{constructor(){xt(this,"timestamp",0),xt(this,"counter",0),xt(this,"random",new bPe)}generate(){var t=this.generateOrAbort();if(Mt(t)){this.timestamp=0;var n=this.generateOrAbort();if(Mt(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 vPe.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 $L,Zie=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};Ne&&!Mt(Ne.crypto)&&crypto.getRandomValues&&(Zie=e=>crypto.getRandomValues(e));let bPe=class{constructor(){xt(this,"buffer",new Uint32Array(8)),xt(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(Zie(this.buffer),this.cursor=0),this.buffer[this.cursor++]}};var Ff=()=>yPe().toString(),yPe=()=>($L||($L=new wPe)).generate(),xPe="Thu, 01 Jan 1970 00:00:00 GMT",Nv="",SPe=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function $Pe(e,t){if(t){var n=function(i){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:jt;if(Nv)return Nv;if(!s||["localhost","127.0.0.1"].includes(i))return"";for(var a=i.split("."),o=Math.min(a.length,8),l="dmn_chk_"+Ff(),c=new RegExp("(^|;)\\s*"+l+"=1");!Nv&&o--;){var u=a.slice(o).join("."),d=l+"=1;domain=."+u;s.cookie=d,c.test(s.cookie)&&(s.cookie=d+";expires="+xPe,Nv=u)}return Nv}(e);if(!n){var r=(i=>{var s=i.match(SPe);return s?s[0]:""})(e);r!==n&&sn.info("Warning: cookie subdomain discovery mismatch",r,n),n=r}return n?"; domain=."+n:""}return""}var Pf,ph={is_supported:()=>!!jt,error:function(e){sn.error("cookieStore error: "+e)},get:function(e){if(jt){try{for(var t=e+"=",n=jt.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(ph.get(e))||{}}catch{}return t},set:function(e,t,n,r,i){if(jt)try{var s="",a="",o=$Pe(jt.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&&sn.warn("cookieStore warning: large cookie, len="+c.length),jt.cookie=c,c}catch{return}},remove:function(e,t){try{ph.set(e,"",-1,t)}catch{return}}},_5=null,_s={is_supported:function(){if(!EO(_5))return _5;var e=!0;if(Mt(Ne))e=!1;else try{var t="__mplssupport__";_s.set(t,"xyz"),_s.get(t)!=='"xyz"'&&(e=!1),_s.remove(t)}catch{e=!1}return e||sn.error("localStorage unsupported; falling back to cookie store"),_5=e,e},error:function(e){sn.error("localStorage error: "+e)},get:function(e){try{return Ne?.localStorage.getItem(e)}catch(t){_s.error(t)}return null},parse:function(e){try{return JSON.parse(_s.get(e))||{}}catch{}return null},set:function(e,t){try{Ne?.localStorage.setItem(e,JSON.stringify(t))}catch(n){_s.error(n)}},remove:function(e){try{Ne?.localStorage.removeItem(e)}catch(t){_s.error(t)}}},kPe=["distinct_id",Q2,Iw,R2,OX],s$=Ge(Ge({},_s),{},{parse:function(e){try{var t={};try{t=ph.parse(e)||{}}catch{}var n=ns(t,JSON.parse(_s.get(e)||"{}"));return _s.set(e,n),n}catch{}return null},set:function(e,t,n,r,i,s){try{_s.set(e,t,void 0,void 0,s);var a={};kPe.forEach(o=>{t[o]&&(a[o]=t[o])}),Object.keys(a).length&&ph.set(e,a,n,r,i,s)}catch(o){_s.error(o)}},remove:function(e,t){try{Ne?.localStorage.removeItem(e),ph.remove(e,t)}catch(n){_s.error(n)}}}),a$={},TPe={is_supported:function(){return!0},error:function(e){sn.error("memoryStorage error: "+e)},get:function(e){return a$[e]||null},parse:function(e){return a$[e]||null},set:function(e,t){a$[e]=t},remove:function(e){delete a$[e]}},HO=null,ca={is_supported:function(){if(!EO(HO))return HO;if(HO=!0,Mt(Ne))HO=!1;else try{var e="__support__";ca.set(e,"xyz"),ca.get(e)!=='"xyz"'&&(HO=!1),ca.remove(e)}catch{HO=!1}return HO},error:function(e){sn.error("sessionStorage error: ",e)},get:function(e){try{return Ne?.sessionStorage.getItem(e)}catch(t){ca.error(t)}return null},parse:function(e){try{return JSON.parse(ca.get(e))||null}catch{}return null},set:function(e,t){try{Ne?.sessionStorage.setItem(e,JSON.stringify(t))}catch(n){ca.error(n)}},remove:function(e){try{Ne?.sessionStorage.removeItem(e)}catch(t){ca.error(t)}}};(function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"})(Pf||(Pf={}));let PPe=class{constructor(t){this.instance=t}get config(){return this.instance.config}get consent(){return this.getDnt()?Pf.DENIED:this.storedConsent}isOptedOut(){return this.consent===Pf.DENIED||this.consent===Pf.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"?Pf.GRANTED:t==="0"?Pf.DENIED:Pf.PENDING}get storage(){if(!this._storage){var t=this.config.opt_out_capturing_persistence_type;this._storage=t==="localStorage"?_s:ph;var n=t==="localStorage"?ph:_s;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&&!!Die([fl?.doNotTrack,fl?.msDoNotTrack,Xn.doNotTrack],t=>or([!0,1,"1","yes"],t))}};var o$=ja("[Dead Clicks]"),_Pe=()=>!0,CPe=e=>{var t,n=!((t=e.instance.persistence)===null||t===void 0||!t.get_property(Fie)),r=e.instance.config.capture_dead_clicks;return ih(r)?r:n};let Hie=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({[Fie]:t?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(t){var n,r,i;(n=Xn.__PosthogExtensions__)!==null&&n!==void 0&&n.initDeadClicksAutocapture&&t(),(r=Xn.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"dead-clicks-autocapture",s=>{s?o$.error("failed to load script",s):t()})}start(){var t;if(jt){if(!this._lazyLoadedDeadClicksAutocapture&&(t=Xn.__PosthogExtensions__)!==null&&t!==void 0&&t.initDeadClicksAutocapture){var n=Vi(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Xn.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this._lazyLoadedDeadClicksAutocapture.start(jt),o$.info("starting...")}}else o$.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,o$.info("stopping..."))}};var C5=ja("[ExceptionAutocapture]");let QPe=class{constructor(t){var n;xt(this,"startCapturing",()=>{var r;if(Ne&&this.isEnabled&&(r=Xn.__PosthogExtensions__)!==null&&r!==void 0&&r.errorWrappingFunctions){var i=Xn.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=Xn.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=Xn.__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){C5.error("failed to start",o),this.stopCapturing()}}}),this.instance=t,this.remoteEnabled=!((n=this.instance.persistence)===null||n===void 0||!n.props[lL]),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 Vi(t)?n=Ge(Ge({},n),t):(Mt(t)?this.remoteEnabled:t)&&(n=Ge(Ge({},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&&(C5.info("enabled"),this.loadScript(this.startCapturing))}loadScript(t){var n,r,i;(n=Xn.__PosthogExtensions__)!==null&&n!==void 0&&n.errorWrappingFunctions&&t(),(r=Xn.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"exception-autocapture",s=>{if(s)return C5.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({[lL]: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 Kie(e){return!Mt(Event)&&Jie(e,Event)}function Jie(e,t){try{return e instanceof t}catch{return!1}}function wT(e,t){return Object.prototype.toString.call(e)==="[object ".concat(t,"]")}function Q5(e){return wT(e,"DOMError")}var kL=/\(error: (.*)\)/,TL=50,p0="?";function E5(e,t,n,r){var i={platform:"web:javascript",filename:e,function:t==="<anonymous>"?p0:t,in_app:!0};return Mt(n)||(i.lineno=n),Mt(r)||(i.colno=r),i}var EPe=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,RPe=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,APe=/\((\S*)(?::(\d+))(?::(\d+))\)/,XPe=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,DPe=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,IPe=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=kL.test(c)?c.replace(kL,"$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>=TL)break}}}return function(f){if(!f.length)return[];var O=Array.from(f);return O.reverse(),O.slice(0,TL).map(g=>Ge(Ge({},g),{},{filename:g.filename||FPe(O).filename,function:g.function||p0}))}(a)}}([30,e=>{var t=EPe.exec(e);if(t){var[,n,r,i]=t;return E5(n,p0,+r,+i)}var s=RPe.exec(e);if(s){if(s[2]&&s[2].indexOf("eval")===0){var a=APe.exec(s[2]);a&&(s[2]=a[1],s[3]=a[2],s[4]=a[3])}var[o,l]=_L(s[1]||p0,s[2]);return E5(l,o,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}}],[50,e=>{var t=XPe.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var n=DPe.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]||p0;return[i,r]=_L(i,r),E5(r,i,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]);function FPe(e){return e[e.length-1]||{}}var l$,PL,R5,_L=(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]:p0,n?"safari-extension:".concat(t):"safari-web-extension:".concat(t)]:[e,t]},NPe=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function a8(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=e.stacktrace||e.stack||"",r=function(a){return a&&MPe.test(a.message)?1:0}(e);try{var i=IPe,s=function(a,o){var l=function(c){var u=globalThis._posthogChunkIds;if(!u)return{};var d=Object.keys(u);return R5&&d.length===PL||(PL=d.length,R5=d.reduce((h,f)=>{l$||(l$={});var O=l$[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],w=v?.filename,y=u[f];if(w&&y){h[w]=y,l$[f]=[w,y];break}}return h},{})),R5}(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 MPe=/Minified React error #\d+;/i;function A5(e,t){var n,r,i=a8(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 X5(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=a8(t.syntheticException,1);l.length&&(o.stacktrace={frames:l,type:"raw"})}return{$exception_list:[o],$exception_level:"error"}}function zPe(e){return xs(e)&&!sX(e)&&B2e.indexOf(e)>=0}function LPe(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:Kie(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=a8(t?.syntheticException,1);c.length&&(l.stacktrace={frames:c,type:"raw"})}return{$exception_list:[l],$exception_level:zPe(e.level)?e.level:"error"}}function qPe(e,t){var{error:n,event:r}=e,i={$exception_list:[]},s=n||r;if(Q5(s)||function(f){return wT(f,"DOMException")}(s)){var a=s;if(function(f){return"stack"in f}(s))i=A5(s,t);else{var o=a.name||(Q5(a)?"DOMError":"DOMException"),l=a.message?"".concat(o,": ").concat(a.message):o,c=Q5(a)?"DOMError":"DOMException";i=X5(l,Ge(Ge({},t),{},{overrideExceptionType:c,defaultExceptionMessage:l}))}return"code"in a&&(i.$exception_DOMException_code="".concat(a.code)),i}if(function(f){return wT(f,"ErrorEvent")}(s)&&s.error)return A5(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 Jie(f,Error)}}(s))return A5(s,t);if(function(f){return wT(f,"Object")}(s)||Kie(s))return LPe(s,t);if(Mt(n)&&xs(r)){var u="Error",d=r,h=r.match(NPe);return h&&(u=h[1],d=h[2]),X5(d,Ge(Ge({},t),{},{overrideExceptionType:u,defaultExceptionMessage:d}))}return X5(s,t)}function I2(e){var t,n;return((t=JSON.stringify(e,(n=[],function(r,i){if(Vi(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 vX(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[vX({size:I2(r),data:r,sessionId:e.sessionId,windowId:e.windowId}),vX({size:I2(i),data:i,sessionId:e.sessionId,windowId:e.windowId})].flatMap(s=>s)}return[e]}var Wd=(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))(Wd||{}),Qc=(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))(Qc||{}),wX="[SessionRecording]",bX="redacted",c$={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"]},UPe=["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"],WPe=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],GPe=["/s/","/e/","/i/"];function CL(e,t,n,r){if(Wr(e))return e;var i=t?.["content-length"]||function(s){return new Blob([s]).size}(e);return xs(i)&&(i=parseInt(i)),i>n?wX+" ".concat(r," body too large to record (").concat(i," bytes)"):e}function QL(e,t){if(Wr(e))return e;var n=e;return c1(n,!1)||(n=wX+" "+t+" body "+bX),ti(WPe,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=wX+" "+t+" body "+bX+" as might contain: "+r)}),n}var jPe=(e,t)=>{var n,r,i,s={payloadSizeLimitBytes:c$.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...c$.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...c$.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=CL(h.requestBody,h.requestHeaders,i,"Request")),h!=null&&h.responseBody&&(h.responseBody=CL(h.responseBody,h.responseHeaders,i,"Response")),h)),u=h=>{return c(((g,m)=>{var v,w=C0(g.name),y=m.indexOf("http")===0?(v=C0(m))===null||v===void 0?void 0:v.pathname:m;y==="/"&&(y="");var T=w?.pathname.replace(y||"","");if(!(w&&T&&GPe.some(x=>T.indexOf(x)===0)))return g})((O=(f=h).requestHeaders,Wr(O)||ti(Object.keys(O??{}),g=>{UPe.includes(g.toLowerCase())&&(O[g]=bX)}),f),e.api_host));var f,O},d=Uc(e.session_recording.maskNetworkRequestFn);return d&&Uc(e.session_recording.maskCapturedNetworkRequestFn)&&sn.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 Ge(Ge({},h),{},{name:f?.url})}),s.maskRequestFn=Uc(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(!Mt(f))return f.requestBody=QL(f.requestBody,"Request"),f.responseBody=QL(f.responseBody,"Response"),f}(u(h)),Ge(Ge(Ge({},c$),s),{},{recordHeaders:a,recordBody:o,recordPerformance:l,recordInitialRequests:l})};function Bl(e,t,n,r,i){return t>n&&(sn.warn("min cannot be greater than max."),t=n),lo(e)?e>n?(r&&sn.warn(r+" cannot be greater than max: "+n+". Using max value instead."),n):e<t?(r&&sn.warn(r+" cannot be less than min: "+t+". Using min value instead."),t):e:(r&&sn.warn(r+" must be a number. using max or fallback. max: "+n+", fallback: "+i),Bl(i||n,t,n,r))}let VPe=class{constructor(t){var n,r,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};xt(this,"bucketSize",100),xt(this,"refillRate",10),xt(this,"mutationBuckets",{}),xt(this,"loggedTracker",{}),xt(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]})}),xt(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]}),xt(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)}),xt(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=Bl((n=this.options.refillRate)!==null&&n!==void 0?n:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=Bl((r=this.options.bucketSize)!==null&&r!==void 0?r:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval(()=>{this.refillBuckets()},1e3)}};var rc=Uint8Array,Io=Uint16Array,u1=Uint32Array,o8=new rc([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]),l8=new rc([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]),EL=new rc([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ese=function(e,t){for(var n=new Io(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new u1(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]},tse=ese(o8,2),YPe=tse[0],yX=tse[1];YPe[28]=258,yX[258]=28;for(var RL=ese(l8,0)[1],nse=new Io(32768),pi=0;pi<32768;++pi){var KO=(43690&pi)>>>1|(21845&pi)<<1;KO=(61680&(KO=(52428&KO)>>>2|(13107&KO)<<2))>>>4|(3855&KO)<<4,nse[pi]=((65280&KO)>>>8|(255&KO)<<8)>>>1}var ob=function(e,t,n){for(var r=e.length,i=0,s=new Io(t);i<r;++i)++s[e[i]-1];var a,o=new Io(t);for(i=0;i<t;++i)o[i]=o[i-1]+s[i-1]<<1;for(a=new Io(r),i=0;i<r;++i)a[i]=nse[o[e[i]-1]++]>>>15-e[i];return a},ug=new rc(288);for(pi=0;pi<144;++pi)ug[pi]=8;for(pi=144;pi<256;++pi)ug[pi]=9;for(pi=256;pi<280;++pi)ug[pi]=7;for(pi=280;pi<288;++pi)ug[pi]=8;var F2=new rc(32);for(pi=0;pi<32;++pi)F2[pi]=5;var BPe=ob(ug,9),ZPe=ob(F2,5),rse=function(e){return(e/8>>0)+(7&e&&1)},ise=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Io?Io:e instanceof u1?u1:rc)(n-t);return r.set(e.subarray(t,n)),r},Ed=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},Mv=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},D5=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 rc(0),0];if(i==1){var a=new rc(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort(function(x,k){return x.f-k.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 Io(h+1),O=xX(n[u-1],f,0);if(O>t){r=0;var g=0,m=O-t,v=1<<m;for(s.sort(function(x,k){return f[k.s]-f[x.s]||x.f-k.f});r<i;++r){var w=s[r].s;if(!(f[w]>t))break;g+=v-(1<<O-f[w]),f[w]=t}for(g>>>=m;g>0;){var y=s[r].s;f[y]<t?g-=1<<t-f[y]++-1:++r}for(;r>=0&&g;--r){var T=s[r].s;f[T]==t&&(--f[T],++g)}O=t}return[new rc(f),O]},xX=function(e,t,n){return e.s==-1?Math.max(xX(e.l,t,n+1),xX(e.r,t,n+1)):t[e.s]=n},AL=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Io(++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]},zv=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},SX=function(e,t,n){var r=n.length,i=rse(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)},XL=function(e,t,n,r,i,s,a,o,l,c,u){Ed(t,u++,n),++i[256];for(var d=D5(i,15),h=d[0],f=d[1],O=D5(s,15),g=O[0],m=O[1],v=AL(h),w=v[0],y=v[1],T=AL(g),x=T[0],k=T[1],S=new Io(19),Q=0;Q<w.length;++Q)S[31&w[Q]]++;for(Q=0;Q<x.length;++Q)S[31&x[Q]]++;for(var R=D5(S,7),_=R[0],A=R[1],E=19;E>4&&!_[EL[E-1]];--E);var I,L,z,V,q=c+5<<3,Z=zv(i,ug)+zv(s,F2)+a,j=zv(i,h)+zv(s,g)+a+14+3*E+zv(S,_)+(2*S[16]+3*S[17]+7*S[18]);if(q<=Z&&q<=j)return SX(t,u,e.subarray(l,l+c));if(Ed(t,u,1+(j<Z)),u+=2,j<Z){I=ob(h,f),L=h,z=ob(g,m),V=g;var M=ob(_,A);for(Ed(t,u,y-257),Ed(t,u+5,k-1),Ed(t,u+10,E-4),u+=14,Q=0;Q<E;++Q)Ed(t,u+3*Q,_[EL[Q]]);u+=3*E;for(var Y=[w,x],F=0;F<2;++F){var X=Y[F];for(Q=0;Q<X.length;++Q){var W=31&X[Q];Ed(t,u,M[W]),u+=_[W],W>15&&(Ed(t,u,X[Q]>>>5&127),u+=X[Q]>>>12)}}}else I=BPe,L=ug,z=ZPe,V=F2;for(Q=0;Q<o;++Q)if(r[Q]>255){W=r[Q]>>>18&31,Mv(t,u,I[W+257]),u+=L[W+257],W>7&&(Ed(t,u,r[Q]>>>23&31),u+=o8[W]);var U=31&r[Q];Mv(t,u,z[U]),u+=V[U],U>3&&(Mv(t,u,r[Q]>>>5&8191),u+=l8[U])}else Mv(t,u,I[r[Q]]),u+=L[r[Q]];return Mv(t,u,I[256]),u+L[256]},HPe=new u1([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),KPe=function(){for(var e=new u1(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),JPe=function(){var e=4294967295;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=KPe[255&n^t[r]]^n>>>8;e=n},d:function(){return 4294967295^e}}},e_e=function(e,t,n,r,i){return function(s,a,o,l,c,u){var d=s.length,h=new rc(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=SX(f,O,s.subarray(g,m)):(f[g]=u,O=SX(f,O,s.subarray(g,d)))}else{for(var v=HPe[a-1],w=v>>>13,y=8191&v,T=(1<<o)-1,x=new Io(32768),k=new Io(T+1),S=Math.ceil(o/3),Q=2*S,R=function(ge){return(s[ge]^s[ge+1]<<S^s[ge+2]<<Q)&T},_=new u1(25e3),A=new Io(288),E=new Io(32),I=0,L=0,z=(g=0,0),V=0,q=0;g<d;++g){var Z=R(g),j=32767&g,M=k[Z];if(x[j]=M,k[Z]=j,V<=g){var Y=d-g;if((I>7e3||z>24576)&&Y>423){O=XL(s,f,0,_,A,E,L,z,q,g-q,O),z=I=L=0,q=g;for(var F=0;F<286;++F)A[F]=0;for(F=0;F<30;++F)E[F]=0}var X=2,W=0,U=y,J=j-M&32767;if(Y>2&&Z==R(g-J))for(var he=Math.min(w,Y)-1,ue=Math.min(32767,g),we=Math.min(258,Y);J<=ue&&--U&&j!=M;){if(s[g+X]==s[g+X-J]){for(var xe=0;xe<we&&s[g+xe]==s[g+xe-J];++xe);if(xe>X){if(X=xe,W=J,xe>he)break;var dt=Math.min(J,xe-2),re=0;for(F=0;F<dt;++F){var it=g-J+F+32768&32767,Ue=it-x[it]+32768&32767;Ue>re&&(re=Ue,M=it)}}}J+=(j=M)-(M=x[j])+32768&32767}if(W){_[z++]=268435456|yX[X]<<18|RL[W];var pt=31&yX[X],We=31&RL[W];L+=o8[pt]+l8[We],++A[257+pt],++E[We],V=g+X,++I}else _[z++]=s[g],++A[s[g]]}}O=XL(s,f,u,_,A,E,L,z,q,g-q,O)}return ise(h,0,l+rse(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)},$X=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},t_e=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&&$X(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)}},n_e=function(e){return 10+(e.filename&&e.filename.length+1||0)};function sse(e,t){t===void 0&&(t={});var n=JPe(),r=e.length;n.p(e);var i=e_e(e,t,n_e(t),8),s=i.length;return t_e(i,t),$X(i,s-8,n.d()),$X(i,s-4,r),i}function ase(e,t){var n=e.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(e);for(var r=new rc(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 rc(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 ise(r,0,i)}function r_e(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<Bl(100*t,0,100)}var Nw="[SessionRecording]",ya=ja(Nw);function u$(){var e,t;return Xn==null||(e=Xn.__PosthogExtensions__)===null||e===void 0||(t=e.rrweb)===null||t===void 0?void 0:t.record}var i_e=3e5,s_e=[Qc.MouseMove,Qc.MouseInteraction,Qc.Scroll,Qc.ViewportResize,Qc.Input,Qc.TouchMove,Qc.MediaInteraction,Qc.Drag],DL=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function JO(e){return function(t,n){for(var r="",i=0;i<t.length;){var s=t[i++];r+=String.fromCharCode(s)}return r}(sse(ase(JSON.stringify(e))))}function IL(e){return e.type===Wd.Custom&&e.data.tag==="sessionIdle"}function FL(e,t){return t.some(n=>n.matching==="regex"&&new RegExp(n.url).test(e))}let a_e=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(Nw+" 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:i_e}get isSampled(){var t=this.instance.get_property(Iw);return ih(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(oX),n=!this.instance.config.disable_session_recording;return Ne&&t&&n}get isConsoleLogCaptureEnabled(){var t=!!this.instance.get_property(dL),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(OL),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:Bl(u,0,12,"canvas recording fps",4),quality:Bl(d,0,1,"canvas recording quality",.4)}}get networkPayloadCapture(){var t,n,r=this.instance.get_property(hL),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=Vi(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,l=!!(ih(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(fL),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 Mt(c)&&Mt(u)&&Mt(d)?void 0:{maskAllInputs:c==null||c,maskTextSelector:u,blockSelector:d}}get sampleRate(){var t=this.instance.get_property(pL);return lo(t)?t:null}get minimumDuration(){var t=this.instance.get_property(gL);return lo(t)?t:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this.isSampled===!1?"disabled":this._urlBlocked?"paused":Wr(this._linkedFlag)||this._linkedFlagSeen?this.triggerStatus==="trigger_pending"?"buffering":ih(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($5))===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(k5))===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(xt(this,"queuedRRWebEvents",[]),xt(this,"isIdle","unknown"),xt(this,"_linkedFlagSeen",!1),xt(this,"_lastActivityTimestamp",Date.now()),xt(this,"_linkedFlag",null),xt(this,"_removePageViewCaptureHook",void 0),xt(this,"_onSessionIdListener",void 0),xt(this,"_persistDecideOnSessionListener",void 0),xt(this,"_samplingSessionListener",void 0),xt(this,"_urlTriggers",[]),xt(this,"_urlBlocklist",[]),xt(this,"_urlBlocked",!1),xt(this,"_eventTriggers",[]),xt(this,"_removeEventTriggerCaptureHook",void 0),xt(this,"_forceAllowLocalhostNetworkCapture",!1),xt(this,"_onBeforeUnload",()=>{this._flushBuffer()}),xt(this,"_onOffline",()=>{this._tryAddCustomEvent("browser offline",{})}),xt(this,"_onOnline",()=>{this._tryAddCustomEvent("browser online",{})}),xt(this,"_onVisibilityChange",()=>{if(jt!=null&&jt.visibilityState){var i="window "+jt.visibilityState;this._tryAddCustomEvent(i,{})}}),this.instance=t,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw ya.error("started without valid sessionManager"),new Error(Nw+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(Nw+" 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&&ya.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),is(Ne,"beforeunload",this._onBeforeUnload),is(Ne,"offline",this._onOffline),is(Ne,"online",this._onOnline),is(Ne,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),Wr(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){ya.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(k5),(o=this.instance)===null||o===void 0||(l=o.persistence)===null||l===void 0||l.unregister($5))}))):this.stopRecording()}stopRecording(){var t,n,r,i;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,Ne?.removeEventListener("beforeunload",this._onBeforeUnload),Ne?.removeEventListener("offline",this._onOffline),Ne?.removeEventListener("online",this._onOnline),Ne?.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,ya.info("stopped"))}_resetSampling(){var t;(t=this.instance.persistence)===null||t===void 0||t.unregister(Iw)}makeSamplingDecision(t){var n,r=this.sessionId!==t,i=this.sampleRate;if(lo(i)){var s=this.isSampled,a=r||!ih(s),o=a?r_e(t,i):s;a&&(o?this._reportStarted("sampled"):ya.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({[Iw]: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(),!Wr(this._linkedFlag)&&!this._linkedFlagSeen){var l=xs(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,c=xs(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags((u,d)=>{var h=Vi(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(){lo(this.sampleRate)&&Wr(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=Wr(O)?null:parseFloat(O);Wr(g)&&this._resetSampling();var m=(a=t.sessionRecording)===null||a===void 0?void 0:a.minimumDurationMilliseconds;r.register({[oX]:!!t.sessionRecording,[dL]:(o=t.sessionRecording)===null||o===void 0?void 0:o.consoleLogRecordingEnabled,[hL]:Ge({capturePerformance:t.capturePerformance},(l=t.sessionRecording)===null||l===void 0?void 0:l.networkPayloadCapture),[fL]:(c=t.sessionRecording)===null||c===void 0?void 0:c.masking,[OL]:{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},[pL]:g,[gL]:Mt(m)?null:m,[mL]:(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(!Mt(Object.assign)&&!Mt(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var n,r;this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),u$()?this._onScriptLoaded():(n=Xn.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this.instance,this.scriptName,i=>{if(i)return ya.error("could not load recorder",i);this._onScriptLoaded()}),ya.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(mL))===null||r===void 0?void 0:r.script)||"recorder"}isInteractiveEvent(t){var n;return t.type===3&&s_e.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}):ya.warn("could not emit queued rrweb event.",n,t),!1}}_tryAddCustomEvent(t,n){return this._tryRRWebMethod(DL(()=>u$().addCustomEvent(t,n)))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(DL(()=>u$().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=Ge({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=u$();if(c){this.mutationRateLimiter=(t=this.mutationRateLimiter)!==null&&t!==void 0?t:new VPe(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");ya.info(f,{node:h}),this.log(Nw+" "+f,"warn")}});var u=this._gatherRRWebPlugins();this.stopRrweb=c(Ge({emit:d=>{this.onRRwebEmit(d)},plugins:u},s)),this._lastActivityTimestamp=Date.now(),this.isIdle=ih(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 ya.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=Xn.__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=Xn.__PosthogExtensions__)===null||r===void 0||(i=r.rrwebPlugins)===null||i===void 0?void 0:i.getRecordNetworkPlugin;return this.networkPayloadCapture&&Uc(o)&&(!hPe.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?s.push(o(jPe(this.instance.config,this.networkPayloadCapture))):ya.info("NetworkCapture not started because we are on localhost.")),s}onRRwebEmit(t){var n;if(this._processQueuedEvents(),t&&Vi(t)){if(t.type===Wd.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===Wd.Custom&&d.data.tag==="recording paused"}(t)){t.type===Wd.FullSnapshot&&this._scheduleFullSnapshot(),t.type===Wd.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&&Vi(h)&&h.type===6&&Vi(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||IL(s)){if(IL(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(I2(d)<1024)return d;try{if(d.type===Wd.FullSnapshot)return Ge(Ge({},d),{},{data:JO(d.data),cv:"2024-10"});if(d.type===Wd.IncrementalSnapshot&&d.data.source===Qc.Mutation)return Ge(Ge({},d),{},{cv:"2024-10",data:Ge(Ge({},d.data),{},{texts:JO(d.data.texts),attributes:JO(d.data.attributes),removes:JO(d.data.removes),adds:JO(d.data.adds)})});if(d.type===Wd.IncrementalSnapshot&&d.data.source===Qc.StyleSheetRule)return Ge(Ge({},d),{},{cv:"2024-10",data:Ge(Ge({},d.data),{},{adds:d.data.adds?JO(d.data.adds):void 0,removes:d.data.removes?JO(d.data.removes):void 0})})}catch(h){ya.error("could not compress event - will use uncompressed event",h)}return d}(s):s,u={$snapshot_bytes:I2(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&&Ne){var t=this._maskUrl(Ne.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=lo(n)&&n>=0,i=lo(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&&vX(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:Hd.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(Ne!==void 0&&Ne.location.href){var t=Ne.location.href,n=this._urlBlocked,r=FL(t,this._urlBlocklist);r&&!n?this._pauseRecording():!r&&n&&this._resumeRecording(),FL(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"?$5:k5]:this.sessionId}),this._flushBuffer(),this._reportStarted(t+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),ya.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"}),ya.info("recording resumed"))}_addEventTriggerListener(){this._eventTriggers.length!==0&&Wr(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",t=>{try{this._eventTriggers.includes(t.event)&&this._activateTrigger("event")}catch(n){ya.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({[Iw]:!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}),ya.info(t.replace("_"," "),n),or(["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 I5=ja("[SegmentIntegration]");function o_e(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()||Ff();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(Ud,"identified")),i()},o=s.user();"then"in o&&Uc(o.then)?o.then(l=>a(l)):a(o)})(e,()=>{n.register((r=>{Promise&&Promise.resolve||I5.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()||(I5.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(I5.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 ose="posthog-js";function lse(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=>Ge(Ge({},g),{},{stacktrace:g.stacktrace?Ge(Ge({},g.stacktrace),{},{type:"raw",frames:(g.stacktrace.frames||[]).map(m=>Ge(Ge({},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 l_e=class{constructor(t,n,r,i,s){this.name=ose,this.setupOnce=function(a){a(lse(t,{organization:n,projectId:r,prefix:i,severityAllowList:s}))}}};var Gd,c_e=Ne!=null&&Ne.location?D2(Ne.location.hash,"__posthog")||D2(location.hash,"state"):null,NL="_postHogToolbarParams",ML=ja("[Toolbar]");(function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"})(Gd||(Gd={}));class u_e{constructor(t){this.instance=t}setToolbarState(t){Xn.ph_toolbar_state=t}getToolbarState(){var t;return(t=Xn.ph_toolbar_state)!==null&&t!==void 0?t:Gd.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(!Ne||!jt)return!1;r=(t=r)!==null&&t!==void 0?t:Ne.location,s=(n=s)!==null&&n!==void 0?n:Ne.history;try{if(!i){try{Ne.localStorage.setItem("test","test"),Ne.localStorage.removeItem("test")}catch{return!1}i=Ne?.localStorage}var a,o=c_e||D2(r.hash,"__posthog")||D2(r.hash,"state"),l=o?aL(()=>JSON.parse(atob(decodeURIComponent(o))))||aL(()=>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(NL)||"{}")).source="localstorage",delete a.userIntent),!(!a.token||this.instance.config.token!==a.token)&&(this.loadToolbar(a),!0)}catch{return!1}}_callLoadToolbar(t){var n=Xn.ph_load_toolbar||Xn.ph_load_editor;!Wr(n)&&Uc(n)?n(t,this.instance):ML.warn("No toolbar load function found")}loadToolbar(t){var n=!(jt==null||!jt.getElementById(Nie));if(!Ne||n)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=Ge(Ge({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(Ne.localStorage.setItem(NL,JSON.stringify(Ge(Ge({},i),{},{source:void 0}))),this.getToolbarState()===Gd.LOADED)this._callLoadToolbar(i);else if(this.getToolbarState()===Gd.UNINITIALIZED){var s,a;this.setToolbarState(Gd.LOADING),(s=Xn.__PosthogExtensions__)===null||s===void 0||(a=s.loadExternalDependency)===null||a===void 0||a.call(s,this.instance,"toolbar",o=>{if(o)return ML.error("[Toolbar] Failed to load",o),void this.setToolbarState(Gd.UNINITIALIZED);this.setToolbarState(Gd.LOADED),this._callLoadToolbar(i)}),is(Ne,"turbolinks:load",()=>{this.setToolbarState(Gd.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 d_e=ja("[TracingHeaders]");class h_e{constructor(t){xt(this,"_restoreXHRPatch",void 0),xt(this,"_restoreFetchPatch",void 0),xt(this,"_startCapturing",()=>{var n,r,i,s;Mt(this._restoreXHRPatch)&&((n=Xn.__PosthogExtensions__)===null||n===void 0||(r=n.tracingHeadersPatchFns)===null||r===void 0||r._patchXHR(this.instance.sessionManager)),Mt(this._restoreFetchPatch)&&((i=Xn.__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=Xn.__PosthogExtensions__)!==null&&n!==void 0&&n.tracingHeadersPatchFns&&t(),(r=Xn.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"tracing-headers",s=>{if(s)return d_e.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 af=ja("[Web Vitals]"),zL=9e5;class f_e{constructor(t){var n;xt(this,"_enabledServerSide",!1),xt(this,"_initialized",!1),xt(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),xt(this,"_flushToCapture",()=>{clearTimeout(this._delayedFlushTimer),this.buffer.metrics.length!==0&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce((r,i)=>Ge(Ge({},r),{},{["$web_vitals_".concat(i.name,"_event")]:Ge({},i),["$web_vitals_".concat(i.name,"_value")]:i.value}),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),xt(this,"_addToBuffer",r=>{var i,s=(i=this.instance.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0);if(Mt(s))af.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var a=this._currentURL();Mt(a)||(Wr(r?.name)||Wr(r?.value)?af.error("Invalid metric received",r):this._maxAllowedValue&&r.value>=this._maxAllowedValue?af.error("Ignoring metric with value >= "+this._maxAllowedValue,r):(this.buffer.url!==a&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),Mt(this.buffer.url)&&(this.buffer.url=a),this.buffer.firstMetricTimestamp=Mt(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(Ge(Ge({},r),{},{$current_url:a,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()))}}),xt(this,"_startCapturing",()=>{var r,i,s,a,o=Xn.__PosthogExtensions__;Mt(o)||Mt(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):af.error("web vitals callbacks not loaded - not starting")}),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[cL]),this.startIfEnabled()}get allowedMetrics(){var t,n,r=Vi(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 Mt(r)?((n=this.instance.persistence)===null||n===void 0?void 0:n.props[uL])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(Vi(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var t=Vi(this.instance.config.capture_performance)&&lo(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:zL;return 0<t&&t<=6e4?zL:t}get isEnabled(){var t=Qo?.protocol;if(t!=="http:"&&t!=="https:")return af.info("Web Vitals are disabled on non-http/https protocols"),!1;var n=Vi(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:ih(this.instance.config.capture_performance)?this.instance.config.capture_performance:void 0;return ih(n)?n:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(af.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(t){var n=Vi(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=Vi(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[cL]:n}),this.instance.persistence.register({[uL]:r})),this._enabledServerSide=n,this.startIfEnabled()}loadScript(t){var n,r,i;(n=Xn.__PosthogExtensions__)!==null&&n!==void 0&&n.postHogWebVitalsCallbacks&&t(),(r=Xn.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"web-vitals",s=>{s?af.error("failed to load script",s):t()})}_currentURL(){var t=Ne?Ne.location.href:void 0;return t||af.error("Could not determine current URL"),t}}var O_e=ja("[Heatmaps]");function LL(e){return Vi(e)&&"clientX"in e&&"clientY"in e&&lo(e.clientX)&&lo(e.clientY)}class p_e{constructor(t){var n;xt(this,"rageclicks",new Bie),xt(this,"_enabledServerSide",!1),xt(this,"_initialized",!1),xt(this,"_flushInterval",null),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[aX])}get flushIntervalMilliseconds(){var t=5e3;return Vi(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 Mt(this.instance.config.capture_heatmaps)?Mt(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;O_e.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({[aX]: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(){Ne&&jt&&(is(Ne,"beforeunload",this.flush.bind(this)),is(jt,"click",t=>this._onClick(t||Ne?.event),{capture:!0}),is(jt,"mousemove",t=>this._onMouseMove(t||Ne?.event),{capture:!0}),this.deadClicksCapture=new Hie(this.instance,_Pe,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&&OC(u)&&!eO(u,"body");){if(u===c)return!1;if(or(l,Ne?.getComputedStyle(u).position))return!0;u=Uie(u)}return!1}(qie(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(!wL(t.target)&&LL(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(Ge(Ge({},i),{},{type:"rageclick"})),this._capture(i)}}_onMouseMove(t){!wL(t.target)&&LL(t)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(t,"mousemove"))},500))}_capture(t){if(Ne){var n=Ne.location.href;this.buffer=this.buffer||{},this.buffer[n]||(this.buffer[n]=[]),this.buffer[n].push(t)}}flush(){this.buffer&&!f0(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}let g_e=class{constructor(t){this._instance=t}doPageView(t,n){var r,i=this._previousPageViewProperties(t,n);return this._currentPageview={pathname:(r=Ne?.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(!(Mt(a)||Mt(o)||Mt(l)||Mt(c)||Mt(u)||Mt(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:Bl(o/a,0,1),f=a<=1?1:Bl(l/a,0,1),O=c<=1?1:Bl(u/c,0,1),g=c<=1?1:Bl(d/c,0,1);i=ns(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}},m_e=class{constructor(t){this.instance=t}sendExceptionEvent(t){this.instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent"})}};var ic="Mobile",N2="iOS",Uu="Android",Oy="Tablet",cse=Uu+" "+Oy,use="iPad",dse="Apple",hse=dse+" Watch",py="Safari",d1="BlackBerry",fse="Samsung",Ose=fse+"Browser",pse=fse+" Internet",dg="Chrome",v_e=dg+" OS",gse=dg+" "+N2,c8="Internet Explorer",mse=c8+" "+ic,u8="Opera",w_e=u8+" Mini",d8="Edge",vse="Microsoft "+d8,Q0="Firefox",wse=Q0+" "+N2,gy="Nintendo",my="PlayStation",E0="Xbox",bse=Uu+" "+ic,yse=ic+" "+py,Mw="Windows",kX=Mw+" Phone",qL="Nokia",TX="Ouya",xse="Generic",b_e=xse+" "+ic.toLowerCase(),Sse=xse+" "+Oy.toLowerCase(),PX="Konqueror",to="(\\d+(\\.\\d+)?)",F5=new RegExp("Version/"+to),y_e=new RegExp(E0,"i"),x_e=new RegExp(my+" \\w+","i"),S_e=new RegExp(gy+" \\w+","i"),h8=new RegExp(d1+"|PlayBook|BB10","i"),$_e={"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"},_X,k_e=(e,t)=>t&&or(t,dse)||function(n){return or(n,py)&&!or(n,dg)&&!or(n,Uu)}(e),UL=function(e,t){return t=t||"",or(e," OPR/")&&or(e,"Mini")?w_e:or(e," OPR/")?u8:h8.test(e)?d1:or(e,"IE"+ic)||or(e,"WPDesktop")?mse:or(e,Ose)?pse:or(e,d8)||or(e,"Edg/")?vse:or(e,"FBIOS")?"Facebook "+ic:or(e,"UCWEB")||or(e,"UCBrowser")?"UC Browser":or(e,"CriOS")?gse:or(e,"CrMo")||or(e,dg)?dg:or(e,Uu)&&or(e,py)?bse:or(e,"FxiOS")?wse:or(e.toLowerCase(),PX.toLowerCase())?PX:k_e(e,t)?or(e,ic)?yse:py:or(e,Q0)?Q0:or(e,"MSIE")||or(e,"Trident/")?c8:or(e,"Gecko")?Q0:""},T_e={[mse]:[new RegExp("rv:"+to)],[vse]:[new RegExp(d8+"?\\/"+to)],[dg]:[new RegExp("("+dg+"|CrMo)\\/"+to)],[gse]:[new RegExp("CriOS\\/"+to)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+to)],[py]:[F5],[yse]:[F5],[u8]:[new RegExp("(Opera|OPR)\\/"+to)],[Q0]:[new RegExp(Q0+"\\/"+to)],[wse]:[new RegExp("FxiOS\\/"+to)],[PX]:[new RegExp("Konqueror[:/]?"+to,"i")],[d1]:[new RegExp(d1+" "+to),F5],[bse]:[new RegExp("android\\s"+to,"i")],[pse]:[new RegExp(Ose+"\\/"+to)],[c8]:[new RegExp("(rv:|MSIE )"+to)],Mozilla:[new RegExp("rv:"+to)]},WL=[[new RegExp(E0+"; "+E0+" (.*?)[);]","i"),e=>[E0,e&&e[1]||""]],[new RegExp(gy,"i"),[gy,""]],[new RegExp(my,"i"),[my,""]],[h8,[d1,""]],[new RegExp(Mw,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[kX,""];if(new RegExp(ic).test(t)&&!/IEMobile\b/.test(t))return[Mw+" "+ic,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=n[1],i=$_e[r]||"";return/arm/i.test(t)&&(i="RT"),[Mw,i]}return[Mw,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[N2,t.join(".")]}return[N2,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=Mt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Uu+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Uu+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[Uu,t.join(".")]}return[Uu,""]}],[/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/,[v_e,""]],[/Linux|debian/i,["Linux",""]]],GL=function(e){return S_e.test(e)?gy:x_e.test(e)?my:y_e.test(e)?E0:new RegExp(TX,"i").test(e)?TX:new RegExp("("+kX+"|WPDesktop)","i").test(e)?kX:/iPad/.test(e)?use:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?hse:h8.test(e)?d1:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(qL,"i").test(e)?qL:/(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(ic).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)?Uu:cse:Uu:new RegExp("(pda|"+ic+")","i").test(e)?b_e:new RegExp(Oy,"i").test(e)&&!new RegExp(Oy+" pc","i").test(e)?Sse:""},d$="https?://(.*)",bT=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],P_e=gT(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],bT),N5="<masked>",Ti={campaignParams:function(){var{customTrackedParams:e,maskPersonalDataProperties:t,customPersonalDataProperties:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!jt)return{};var r=t?gT([],bT,n||[]):[];return this._campaignParamsFromUrl(T5(jt.URL,r,N5),e)},_campaignParamsFromUrl:function(e,t){var n=P_e.concat(t||[]),r={};return ti(n,function(i){var s=X2(e,i);r[i]=s||null}),r},_searchEngine:function(e){return e?e.search(d$+"google.([^/?]*)")===0?"google":e.search(d$+"bing.com")===0?"bing":e.search(d$+"yahoo.com")===0?"yahoo":e.search(d$+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var t=Ti._searchEngine(e),n=t!="yahoo"?"q":"p",r={};if(!EO(t)){r.$search_engine=t;var i=jt?X2(jt.referrer,n):"";i.length&&(r.ph_keyword=i)}return r},searchInfo:function(){var e=jt?.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:UL,browserVersion:function(e,t){var n=UL(e,t),r=T_e[n];if(Mt(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<WL.length;t++){var[n,r]=WL[t],i=n.exec(e),s=i&&(Uc(r)?r(i,e):r);if(s)return s}return["",""]},device:GL,deviceType:function(e){var t=GL(e);return t===use||t===cse||t==="Kobo"||t==="Kindle Fire"||t===Sse?Oy:t===gy||t===E0||t===my||t===TX?"Console":t===hse?"Wearable":t?ic:"Desktop"},referrer:function(){return jt?.referrer||"$direct"},referringDomain:function(){var e;return jt!=null&&jt.referrer&&((e=C0(jt.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?gT([],bT,t||[]):[],r=Qo?.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:r?T5(r,n,N5):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=C0(n))===null||t===void 0?void 0:t.host};if(r){i.$current_url=r;var s=C0(r);i.$host=s?.host,i.$pathname=s?.pathname;var a=this._campaignParamsFromUrl(r);ns(i,a)}if(n){var o=this._searchInfoFromReferrer(n);ns(i,o)}return i},initialPersonPropsFromInfo:function(e){var t=this.personPropsFromInfo(e),n={};return ti(t,function(r,i){n["$initial_".concat(i8(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(!vs)return{};var n=e?gT([],bT,t||[]):[],[r,i]=Ti.os(vs);return ns(fy({$os:r,$os_version:i,$browser:Ti.browser(vs,navigator.vendor),$device:Ti.device(vs),$device_type:Ti.deviceType(vs),$timezone:Ti.timezone(),$timezone_offset:Ti.timezoneOffset()}),{$current_url:T5(Qo?.href,n,N5),$host:Qo?.host,$pathname:Qo?.pathname,$raw_user_agent:vs.length>1e3?vs.substring(0,997)+"...":vs,$browser_version:Ti.browserVersion(vs,navigator.vendor),$browser_language:Ti.browserLanguage(),$browser_language_prefix:Ti.browserLanguagePrefix(),$screen_height:Ne?.screen.height,$screen_width:Ne?.screen.width,$viewport_height:Ne?.innerHeight,$viewport_width:Ne?.innerWidth,$lib:"web",$lib_version:Hd.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(!vs)return{};var[e,t]=Ti.os(vs);return ns(fy({$os:e,$os_version:t,$browser:Ti.browser(vs,navigator.vendor)}),{$browser_version:Ti.browserVersion(vs,navigator.vendor)})}},Tu=ja("[FeatureFlags]"),M5="$active_feature_flags",Sm="$override_feature_flags",jL="$feature_flag_payloads",Lv="$override_feature_flag_payloads",VL="$feature_flag_request_id",YL=e=>{var t={};for(var[n,r]of mT(e||{}))r&&(t[n]=r);return t},__e=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]}))):Tu.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"})(_X||(_X={}));class C_e{constructor(t){xt(this,"_override_warning",!1),xt(this,"_hasLoadedFlags",!1),xt(this,"_requestInFlight",!1),xt(this,"_reloadingDisabled",!1),xt(this,"_additionalReloadRequested",!1),xt(this,"_decideCalled",!1),xt(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(lX),n=this.instance.get_property(Sm),r=this.instance.get_property(Lv);if(!r&&!n)return t||{};var i=ns({},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=Mt(u)?(o=c?.enabled)!==null&&o!==void 0&&o:!!u,h=Mt(u)?c.variant:typeof u=="string"?u:void 0,f=r?.[a],O=Ge(Ge({},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=Ge(Ge({},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||(Tu.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:i}),this._override_warning=!0),i}getFlagVariants(){var t=this.instance.get_property(O0),n=this.instance.get_property(Sm);if(!n)return t||{};for(var r=ns({},t),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this._override_warning||(Tu.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:n,finalFlags:r}),this._override_warning=!0),r}getFlagPayloads(){var t=this.instance.get_property(jL),n=this.instance.get_property(Lv);if(!n)return t||{};for(var r=ns({},t||{}),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this._override_warning||(Tu.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:Ge(Ge({},((n=this.instance.persistence)===null||n===void 0?void 0:n.get_initial_props())||{}),this.instance.get_property(Fw)||{}),group_properties:this.instance.get_property(vp)};(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=Ti.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:Dc.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(_X.FeatureFlags)?Tu.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(VL)||void 0,a=this.instance.get_property(E2)||{};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;ji(a[t])?a[t].push(i):a[t]=[i],(o=this.instance.persistence)===null||o===void 0||o.register({[E2]:a});var w=this.getFeatureFlagDetails(t),y={$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};Mt(w==null||(h=w.metadata)===null||h===void 0?void 0:h.version)||(y.$feature_flag_version=w.metadata.version);var T,x=(f=w==null||(O=w.reason)===null||O===void 0?void 0:O.description)!==null&&f!==void 0?f:w==null||(g=w.reason)===null||g===void 0?void 0:g.code;x&&(y.$feature_flag_reason=x),w!=null&&(m=w.metadata)!==null&&m!==void 0&&m.id&&(y.$feature_flag_id=w.metadata.id),Mt(w?.original_variant)&&Mt(w?.original_enabled)||(y.$feature_flag_original_response=Mt(w.original_variant)?w.original_enabled:w.original_variant),w!=null&&(v=w.metadata)!==null&&v!==void 0&&v.original_payload&&(y.$feature_flag_original_payload=w==null||(T=w.metadata)===null||T===void 0?void 0:T.original_payload),this.instance.capture("$feature_flag_called",y)}return r}Tu.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:Dc.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);Tu.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=__e(a),h=d.flags,f=d.featureFlags,O=d.featureFlagPayloads;if(f){var g=a.requestId;if(ji(f)){Tu.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({[M5]:f,[O0]:m})}else{var w=f,y=O,T=h;a.errorsWhileComputingFlags&&(w=Ge(Ge({},l),w),y=Ge(Ge({},c),y),T=Ge(Ge({},u),T)),o&&o.register(Ge({[M5]:Object.keys(YL(w)),[O0]:w||{},[jL]:y||{},[lX]:T||{}},g?{[VL]:g}:{}))}}})(t,this.instance.persistence,r,i,s),this._fireFeatureFlagsCallbacks(n)}}override(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];Tu.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:n})}overrideFeatureFlags(t){if(!this.instance.__loaded||!this.instance.persistence)return Tu.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.instance.persistence.unregister(Sm),this.instance.persistence.unregister(Lv),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(Sm);else if(r.flags)if(ji(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this.instance.persistence.register({[Sm]:i})}else this.instance.persistence.register({[Sm]:r.flags})}return"payloads"in r&&(r.payloads===!1?this.instance.persistence.unregister(Lv):r.payloads&&this.instance.persistence.register({[Lv]: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(vT)||[]).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=Ge(Ge({},this.getFlagVariants()),{},{[t]:n});(r=this.instance.persistence)===null||r===void 0||r.register({[M5]:Object.keys(YL(o)),[O0]: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(vT),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({[vT]: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(Fw)||{};this.instance.register({[Fw]:Ge(Ge({},r),t)}),n&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(Fw)}setGroupPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],r=this.instance.get_property(vp)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(i=>{r[i]=Ge(Ge({},r[i]),t[i]),delete t[i]}),this.instance.register({[vp]:Ge(Ge({},r),t)}),n&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var n=this.instance.get_property(vp)||{};this.instance.register({[vp]:Ge(Ge({},n),{},{[t]:{}})})}else this.instance.unregister(vp)}}var Q_e=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class z5{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&&sn.info("Persistence loaded",t.persistence,Ge({},this.props)),this.update_config(t,t),this.save()}buildStorage(t){Q_e.indexOf(t.persistence.toLowerCase())===-1&&(sn.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n=t.persistence.toLowerCase();return n==="localstorage"&&_s.is_supported()?_s:n==="localstorage+cookie"&&s$.is_supported()?s$:n==="sessionstorage"&&ca.is_supported()?ca:n==="memory"?TPe:n==="cookie"?ph:s$.is_supported()?s$:ph}properties(){var t={};return ti(this.props,function(n,r){if(r===O0&&Vi(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,(EO(a=iPe)?l:nL&&a.indexOf===nL?a.indexOf(o)!=-1:(ti(a,function(c){if(l||(l=c===o))return C2}),l))||(t[r]=n);var a,o,l}),t}load(){if(!this.disabled){var t=this.storage.parse(this.name);t&&(this.props=ns({},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(Vi(t)){Mt(n)&&(n="None"),this.expire_days=Mt(r)?this.default_expiry:r;var i=!1;if(ti(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(Vi(t)){this.expire_days=Mt(n)?this.default_expiry:n;var r=!1;if(ti(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=Ti.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});f0(fy(t))||this.register(t),this.campaign_params_saved=!0}}update_search_keyword(){this.register(Ti.searchInfo())}update_referrer_info(){this.register_once(Ti.referrerInfo(),void 0)}set_initial_person_info(){this.props[hX]||this.props[fX]||this.register_once({[OX]:Ti.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return fy({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var t={};ti([fX,hX],i=>{var s=this.props[i];s&&ti(s,function(a,o){t["$initial_"+i8(o)]=a})});var n=this.props[OX];if(n){var r=Ti.initialPersonPropsFromInfo(n);ns(t,r)}return t}safe_merge(t){return ti(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[Dw]||{};r[t]=n,this.props[Dw]=r,this.save()}remove_event_timer(t){var n=(this.props[Dw]||{})[t];return Mt(n)||(delete this.props[Dw][t],this.save()),n}get_property(t){return this.props[t]}set_property(t,n){this.props[t]=n,this.save()}}var $se,Yi,kse,$p,BL,Tse,CX,Pse,ZL,QX,HL,KL,JL,eq,EX={},_se=[],E_e=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,f8=Array.isArray;function Nf(e,t){for(var n in t)e[n]=t[n];return e}function Cse(e){var t=e.parentNode;t&&t.removeChild(e)}function L5(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??++kse,__i:-1,__u:0};return i==null&&Yi.vnode!=null&&Yi.vnode(s),s}function O8(e){return e.children}function yT(e,t){this.props=e,this.context=t}function h1(e,t){if(t==null)return e.__?h1(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"?h1(e):null}function Qse(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 Qse(e)}}function RX(e){(!e.__d&&(e.__d=!0)&&$p.push(e)&&!M2.__r++||BL!==Yi.debounceRendering)&&((BL=Yi.debounceRendering)||Tse)(M2)}function M2(){var e,t,n,r,i,s,a,o,l;for($p.sort(CX);e=$p.shift();)e.__d&&(t=$p.length,r=void 0,s=(i=(n=e).__v).__e,o=[],l=[],(a=n.__P)&&((r=Nf({},i)).__v=i.__v+1,Yi.vnode&&Yi.vnode(r),Ase(a,r,i,n.__n,a.ownerSVGElement!==void 0,32&i.__u?[s]:null,o,s??h1(i),!!(32&i.__u),l),r.__.__k[r.__i]=r,X_e(o,r,l),r.__e!=s&&Qse(r)),$p.length>t&&$p.sort(CX));M2.__r=0}function Ese(e,t,n,r,i,s,a,o,l,c,u){var d,h,f,O,g,m=r&&r.__k||_se,v=t.length;for(n.__d=l,R_e(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?EX:m[f.__i]||EX,f.__i=d,Ase(e,f,h,i,s,a,o,l,c,u),O=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&p8(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=Rse(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 R_e(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?L5(null,i,null,null,i):f8(i)?L5(O8,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?L5(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)!=null?(i.__=e,i.__b=e.__b+1,o=A_e(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=h1(s)),AX(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=h1(s)),AX(s,s))}function Rse(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=Rse(r[i],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function A_e(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 tq(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||E_e.test(t)?n:n+"px"}function h$(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||tq(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||tq(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?rq:nq,s)):e.removeEventListener(t,s?rq:nq,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 nq(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Yi.event?Yi.event(e):e)}function rq(e){return this.l[e.type+!0](Yi.event?Yi.event(e):e)}function Ase(e,t,n,r,i,s,a,o,l,c){var u,d,h,f,O,g,m,v,w,y,T,x,k,S,Q,R=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),s=[o=t.__e=n.__e]),(u=Yi.__b)&&u(t);e:if(typeof R=="function")try{if(v=t.props,w=(u=R.contextType)&&r[u.__c],y=u?w?w.props.value:u.__:r,n.__c?m=(d=t.__c=n.__c).__=d.__E:("prototype"in R&&R.prototype.render?t.__c=d=new R(v,y):(t.__c=d=new yT(v,y),d.constructor=R,d.render=I_e),w&&w.sub(d),d.props=v,d.state||(d.state={}),d.context=y,d.__n=r,h=d.__d=!0,d.__h=[],d._sb=[]),d.__s==null&&(d.__s=d.state),R.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Nf({},d.__s)),Nf(d.__s,R.getDerivedStateFromProps(v,d.__s))),f=d.props,O=d.state,d.__v=t,h)R.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(R.getDerivedStateFromProps==null&&v!==f&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(v,y),!d.__e&&(d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(v,d.__s,y)===!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(_){_&&(_.__=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,y),d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(f,O,g)})}if(d.context=y,d.props=v,d.__P=e,d.__e=!1,x=Yi.__r,k=0,"prototype"in R&&R.prototype.render){for(d.state=d.__s,d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),S=0;S<d._sb.length;S++)d.__h.push(d._sb[S]);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&&++k<25);d.state=d.__s,d.getChildContext!=null&&(r=Nf(Nf({},r),d.getChildContext())),h||d.getSnapshotBeforeUpdate==null||(g=d.getSnapshotBeforeUpdate(f,O)),Ese(e,f8(Q=u!=null&&u.type===O8&&u.key==null?u.props.children:u)?Q:[Q],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(_){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),Yi.__e(_,t,n)}else s==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=D_e(n.__e,t,n,r,i,s,a,l,c);(u=Yi.diffed)&&u(t)}function X_e(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)p8(n[r],n[++r],n[++r]);Yi.__c&&Yi.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(s){s.call(i)})}catch(s){Yi.__e(s,i.__v)}})}function D_e(e,t,n,r,i,s,a,o,l){var c,u,d,h,f,O,g,m=n.props,v=t.props,w=t.type;if(w==="svg"&&(i=!0),s!=null){for(c=0;c<s.length;c++)if((f=s[c])&&"setAttribute"in f==!!w&&(w?f.localName===w:f.nodeType===3)){e=f,s[c]=null;break}}if(e==null){if(w===null)return document.createTextNode(v);e=i?document.createElementNS("http://www.w3.org/2000/svg",w):document.createElement(w,v.is&&v),s=null,o=!1}if(w===null)m===v||o&&e.data===v||(e.data=v);else{if(s=s&&$se.call(e.childNodes),m=n.props||EX,!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||h$(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||h$(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=""),Ese(e,f8(h)?h:[h],t,n,r,i&&w!=="foreignObject",s,a,s?s[0]:n.__k&&h1(n,0),o,l),s!=null)for(c=s.length;c--;)s[c]!=null&&Cse(s[c]);o||(c="value",O!==void 0&&(O!==e[c]||w==="progress"&&!O||w==="option"&&O!==m[c])&&h$(e,c,O,m[c],!1),c="checked",g!==void 0&&g!==e[c]&&h$(e,c,g,m[c],!1))}return e}function p8(e,t,n){try{typeof e=="function"?e(t):e.current=t}catch(r){Yi.__e(r,n)}}function AX(e,t,n){var r,i;if(Yi.unmount&&Yi.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||p8(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){Yi.__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]&&AX(r[i],t,n||typeof e.type!="function");n||e.__e==null||Cse(e.__e),e.__=e.__e=e.__d=void 0}function I_e(e,t,n){return this.constructor(e,n)}$se=_se.slice,Yi={__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}},kse=0,yT.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Nf({},this.state),typeof e=="function"&&(e=e(Nf({},n),this.props)),e&&Nf(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),RX(this))},yT.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),RX(this))},yT.prototype.render=O8,$p=[],Tse=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,CX=function(e,t){return e.__v.__b-t.__v.__b},M2.__r=0,Pse=0,function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}(ZL||(ZL={})),function(e){e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger"}(QX||(QX={})),function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(HL||(HL={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(KL||(KL={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(JL||(JL={})),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}(eq||(eq={}));var f1=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}},na=ja("[Surveys]"),iq={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=>f1(t,n)),not_regex:(e,t)=>e.every(n=>!f1(t,n)),exact:(e,t)=>e.some(n=>t===n),is_not:(e,t)=>e.every(n=>t!==n)};function sq(e){return e??"icontains"}QX.Right;(function(e,t){var n={__c:t="__cC"+Pse++,__: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,RX(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 Xse=class{constructor(){xt(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)}},F_e=class e0{constructor(t){xt(this,"_debugEventEmitter",new Xse),xt(this,"checkStep",(n,r)=>this.checkStepEvent(n,r)&&this.checkStepUrl(n,r)&&this.checkStepElement(n,r)),xt(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(!Mt((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(!Mt((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"||!e0.matchString(i,n?.url,n?.url_matching||"contains"))return!1}return!0}static matchString(t,n,r){switch(r){case"regex":return!!Ne&&f1(t,n);case"exact":return n===t;case"contains":var i=e0.escapeStringRegexp(n).replace(/_/g,".").replace(/%/g,".*");return f1(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&&!e0.matchString(s.href||"",n?.href,n?.href_matching||"exact"))&&(n==null||!n.tag_name||s.tag_name===n?.tag_name)&&!(n!=null&&n.text&&!e0.matchString(s.text||"",n?.text,n?.text_matching||"exact")&&!e0.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}},XX=class Dse{constructor(t){this.instance=t,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(t){var n;Mt((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 F_e(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[i$])||[];if(Dse.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[i$])||[];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({[i$]:[...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[i$];return r||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}};xt(XX,"SURVEY_SHOWN_EVENT_NAME","survey shown");let N_e=class{constructor(t){xt(this,"_isFetchingSurveys",!1),xt(this,"_isInitializingSurveys",!1),xt(this,"_surveyCallbacks",[]),this.instance=t,this._surveyEventReceiver=null}onRemoteConfig(t){var n=t.surveys;if(Wr(n))return na.warn("Decide not loaded yet. Not loading surveys.");var r=ji(n);this._hasSurveys=r?n.length>0:n,na.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)na.info("Already initializing surveys, skipping...");else if(this.instance.config.disable_surveys)na.info("Disabled. Not loading surveys.");else{var t=Xn?.__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 XX(this.instance),na.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 na.error("Could not load surveys script",s),void(this._isInitializingSurveys=!1);this._surveyManager=t.generateSurveys(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new XX(this.instance),na.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})});else{var i="PostHog loadExternalDependency extension not found. Cannot load remote config.";na.error(i),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:i})}}}catch(s){throw na.error("Error initializing surveys",s),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:"Error initializing surveys"}),s}}else na.info("No surveys to load.");else na.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 na.info("Disabled. Not loading surveys."),t([]);var r=this.instance.get_property(cX);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 na.error(o),t([],{isLoaded:!1,error:o})}var l,c=i.json.surveys||[],u=c.filter(d=>{var h,f,O,g,m,v,w,y,T,x,k,S;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||((w=d.conditions)===null||w===void 0?void 0:w.actions)&&((y=d.conditions)===null||y===void 0||(T=y.actions)===null||T===void 0?void 0:T.values)&&((x=d.conditions)===null||x===void 0||(k=x.actions)===null||k===void 0||(S=k.values)===null||S===void 0?void 0:S.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({[cX]: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){na.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=Ne==null||(g=Ne.location)===null||g===void 0?void 0:g.href;if(!v)return!1;var w=[f.conditions.url];return iq[sq((m=f.conditions)===null||m===void 0?void 0:m.urlMatchType)](w,v)}(l),d=(c=l.conditions)===null||c===void 0||!c.selector||jt?.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(!vs)return!1;var v=Ti.deviceType(vs);return iq[sq((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 w=this.isSurveyFeatureFlagEnabled(l.linked_flag_key),y=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,k=!T&&!x||a?.includes(l.id),S=this._canActivateRepeatedly(l)||this.isSurveyFeatureFlagEnabled(l.internal_targeting_flag_key),Q=this.checkFlags(l);return w&&y&&S&&k&&Q});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 Wr((n=Xn.__PosthogExtensions__)===null||n===void 0?void 0:n.canActivateRepeatedly)?(na.warn("init was not called"),!1):Xn.__PosthogExtensions__.canActivateRepeatedly(t)}canRenderSurvey(t){if(Wr(this._surveyManager))return na.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?Ge({},this._surveyManager.canRenderSurvey(i)):{visible:!1,disabledReason:"Survey not found"}}),n}renderSurvey(t,n){Wr(this._surveyManager)?na.warn("init was not called"):this.getSurveys(r=>{var i=r.filter(s=>s.id===t)[0];this._surveyManager.renderSurvey(i,jt?.querySelector(n))})}};var aq=ja("[RateLimiter]");let M_e=class{constructor(t){var n,r;xt(this,"serverLimits",{}),xt(this,"lastEventRateLimited",!1),xt(this,"checkForLimiting",i=>{var s=i.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(a=>{aq.info("".concat(a||"events"," is quota limited.")),this.serverLimits[a]=new Date().getTime()+6e4})}catch(a){return void aq.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(dX))!==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(dX,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()<n}};var ep=ja("[RemoteConfig]");let z_e=class{constructor(t){this.instance=t}get remoteConfig(){var t,n;return(t=Xn._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=Xn.__PosthogExtensions__)!==null&&n!==void 0&&n.loadExternalDependency?(r=Xn.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"remote-config",()=>t(this.remoteConfig)):(ep.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 ep.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void ep.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(t=>{if(!t)return ep.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){ep.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()):ep.info("__preview_remote_config is disabled. Logging config instead",t):ep.error("Failed to fetch remote config from PostHog.")}};var L_e=function(e){var t,n,r,i,s="";for(t=n=0,r=(e=(e+"").replace(/\r\n/g,`
|
|
4
4
|
`).replace(/\r/g,`
|
|
@@ -1063,7 +1063,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
1063
1063
|
`,before:f,encode:["$"],...u.current()})),O()}return f+=u.move(`
|
|
1064
1064
|
`),c&&(f+=u.move(c+`
|
|
1065
1065
|
`)),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 GUe={tokenize:jUe,concrete:!0,name:"mathFlow"},DG={tokenize:VUe,partial:!0};function jUe(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(w){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(w)}function l(w){return w===36?(e.consume(w),a++,l):a<2?n(w):(e.exit("mathFlowFenceSequence"),nr(e,c,"whitespace")(w))}function c(w){return w===null||an(w)?d(w):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(w))}function u(w){return w===null||an(w)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),d(w)):w===36?n(w):(e.consume(w),u)}function d(w){return e.exit("mathFlowFence"),r.interrupt?t(w):e.attempt(DG,h,m)(w)}function h(w){return e.attempt({tokenize:v,partial:!0},m,f)(w)}function f(w){return(s?nr(e,O,"linePrefix",s+1):O)(w)}function O(w){return w===null?m(w):an(w)?e.attempt(DG,h,m)(w):(e.enter("mathFlowValue"),g(w))}function g(w){return w===null||an(w)?(e.exit("mathFlowValue"),O(w)):(e.consume(w),g)}function m(w){return e.exit("mathFlow"),t(w)}function v(w,y,T){let x=0;return nr(w,k,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function k(R){return w.enter("mathFlowFence"),w.enter("mathFlowFenceSequence"),S(R)}function S(R){return R===36?(x++,w.consume(R),S):x<a?T(R):(w.exit("mathFlowFenceSequence"),nr(w,Q,"whitespace")(R))}function Q(R){return R===null||an(R)?(w.exit("mathFlowFence"),y(R)):T(R)}}}function VUe(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 YUe(e){let n=(e||{}).singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:BUe,previous:ZUe,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):an(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||an(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 BUe(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 ZUe(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function HUe(e){return{flow:{36:GUe},text:{36:YUe(e)}}}const KUe={};function JUe(e){const t=this,n=e||KUe,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(HUe(n)),s.push(UUe()),a.push(WUe(n))}const eWe=e=>e.charCodeAt(e.length-1)===13?e.slice(0,-1):e,xue=/^[ \t]*$/,tWe=/^ {0,3}(`{3,}|~{3,})/,Sue=/^ {0,3}(?:[-*+]|\d{1,9}[.)])(?:[ \t]|$)/,$ue=/^(?: {4}|\t)/,nWe=/^(?: {2,}|\t)/,rWe=()=>({source:"",cursor:0,blockStart:0,blankRunStart:-1,kind:"none",fence:null,blocks:[],revision:0}),iWe=e=>{e.source="",e.cursor=0,e.blockStart=0,e.blankRunStart=-1,e.kind="none",e.fence=null,e.blocks=[],e.revision+=1},IG=e=>$ue.test(e)?"indented-code":Sue.test(e)?"list":"other",sWe=(e,t)=>e==="list"?Sue.test(t)||nWe.test(t):e==="indented-code"?$ue.test(t):!1,aWe=(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:xue.test(e.slice(n+r))},oWe=(e,t)=>{(t.length<e.source.length||!t.startsWith(e.source))&&iWe(e),e.source=t;let n=e.cursor;for(;;){const r=t.indexOf(`
|
|
1066
|
-
`,n);if(r===-1)break;const i=eWe(t.slice(n,r));if(e.fence){aWe(i,e.fence)&&(e.fence=null),n=r+1;continue}if(xue.test(i)){e.blankRunStart<0&&(e.blankRunStart=n),n=r+1;continue}if(e.blankRunStart>=0){if(e.kind==="none"||!sWe(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=IG(i)}e.blankRunStart=-1}else e.kind==="none"&&(e.kind=IG(i));if(e.kind!=="indented-code"){const s=tWe.exec(i);s&&(e.fence={char:s[1][0],length:s[1].length})}n=r+1}e.cursor=n},lWe=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},Un="var(--color-ink)",Ad="var(--color-ink-muted)",mu="var(--color-surface)",df="var(--color-elevated)",Xd="var(--color-sunken)",xa="var(--color-hairline)",hf="var(--color-control)",Rm="var(--color-accent)",Ww="var(--color-accent-wash)",cWe="var(--color-on-accent)",uWe="var(--color-info)",kue="var(--color-info-wash)",dWe="var(--color-success)",Tue="var(--color-success-wash)",hWe="var(--color-warning)",I6="var(--color-warning-wash)",fWe="var(--color-warning-border)",WE="var(--color-danger)",F6="var(--color-danger-wash)",FG=[Ww,kue,Tue,I6,F6],ff=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),OWe=()=>{const e={primaryColor:ff("--color-accent"),secondaryColor:ff("--color-success"),tertiaryColor:ff("--color-info"),mainBkg:ff("--color-elevated"),clusterBkg:ff("--color-sunken"),clusterBorder:ff("--color-hairline"),edgeLabelBackground:ff("--color-surface"),quadrant1Fill:ff("--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:mu,primaryTextColor:Un,primaryBorderColor:hf,secondaryTextColor:Un,secondaryBorderColor:xa,tertiaryTextColor:Un,tertiaryBorderColor:xa,lineColor:Ad,arrowheadColor:Ad,textColor:Un,secondBkg:Xd,border1:hf,border2:xa,labelColor:Un,nodeBkg:df,nodeBorder:hf,nodeTextColor:Un,defaultLinkColor:Ad,titleColor:Un,noteBkgColor:I6,noteBorderColor:fWe,noteTextColor:Un,actorBkg:df,actorBorder:hf,actorTextColor:Un,actorLineColor:xa,signalColor:Ad,signalTextColor:Un,labelBoxBkgColor:df,labelBoxBorderColor:xa,labelTextColor:Un,loopTextColor:Un,activationBkgColor:Ww,activationBorderColor:Rm,sequenceNumberColor:mu,sectionBkgColor:Xd,sectionBkgColor2:mu,altSectionBkgColor:Xd,excludeBkgColor:Xd,taskBkgColor:Ww,taskBorderColor:hf,taskTextColor:Un,taskTextLightColor:Un,taskTextDarkColor:Un,taskTextOutsideColor:Un,taskTextClickableColor:Rm,activeTaskBkgColor:Ww,activeTaskBorderColor:Rm,gridColor:xa,doneTaskBkgColor:Xd,doneTaskBorderColor:xa,critBkgColor:F6,critBorderColor:WE,todayLineColor:Rm,transitionColor:Ad,transitionLabelColor:Un,stateLabelColor:Un,stateBkg:df,labelBackgroundColor:mu,compositeBackground:Xd,altBackground:Xd,compositeTitleBackground:df,compositeBorder:xa,innerEndBackground:Un,specialStateColor:Un,classText:Un,attributeBackgroundColorOdd:mu,attributeBackgroundColorEven:Xd,rowOdd:mu,rowEven:Xd,errorBkgColor:F6,errorTextColor:WE,pieTitleTextColor:Un,pieSectionTextColor:Un,pieLegendTextColor:Un,pieStrokeColor:mu,pieOuterStrokeColor:xa,requirementBackground:df,requirementBorderColor:hf,requirementTextColor:Un,relationColor:Ad,relationLabelBackground:mu,relationLabelColor:Un,branchLabelColor:cWe,commitLabelColor:Un,commitLabelBackground:mu,tagLabelColor:Un,tagLabelBackground:Ww,tagLabelBorder:hf,quadrant2Fill:kue,quadrant3Fill:Tue,quadrant4Fill:I6,quadrant2TextFill:Un,quadrant3TextFill:Un,quadrant4TextFill:Un,quadrantPointFill:Rm,archEdgeColor:Ad,archEdgeArrowColor:Ad,archGroupBorderColor:xa,scaleLabelColor:Un,packet:{startByteColor:Un,endByteColor:Un,labelColor:Un,titleColor:Un,blockStrokeColor:hf,blockFillColor:df},radar:{axisColor:Ad,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:xa,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:mu,titleColor:Un,xAxisTitleColor:Un,xAxisLabelColor:Un,xAxisTickColor:xa,xAxisLineColor:xa,yAxisTitleColor:Un,yAxisLabelColor:Un,yAxisTickColor:xa,yAxisLineColor:xa,plotColorPalette:[Rm,uWe,dWe,hWe,WE].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=df,t[`surfacePeer${n}`]=xa;for(let n=0;n<8;n++)t[`fillType${n}`]=FG[n%FG.length];return{...t,...e}};let GE=null,NG=null;const pWe=async e=>{GE||(GE=Ae(async()=>{const{default:n}=await import("./mermaid.core-zhMaqo9l.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([0,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await GE;return NG!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:OWe()}),NG=e),t},MG=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:s,onCopy:a,children:o})=>p.jsxs("div",{className:G("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[p.jsx(vt,{content:"Zoom in",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:p.jsx(BRe,{})})}),p.jsx(vt,{content:"Zoom out",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:p.jsx(HRe,{})})}),p.jsx(vt,{content:"Drag the diagram to pan",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:p.jsx(vEe,{})})}),p.jsx(vt,{content:"Reset view",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:p.jsx(E8,{})})}),p.jsx(vt,{content:"Save as SVG",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:s,children:p.jsx(iO,{})})}),p.jsx(vt,{content:t?"Copied":"Copy mermaid text",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:a,children:p.jsx(Vg,{className:G(t&&"text-success")})})}),o]}),N6=({title:e,children:t})=>p.jsxs(qc,{variant:"danger",role:"alert",className:"my-4",children:[p.jsx(lie,{children:e}),p.jsx(dC,{children:t})]});class gWe extends b.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(N6,{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 mWe=b.memo(({chart:e,id:t})=>{const n=b.useRef(null),r=b.useRef(null),[i,s]=b.useState(null),[a,o]=b.useState(!0),[l,c]=b.useState(""),[u,d]=b.useState(!1),[h,f]=b.useState({scale:1,x:0,y:0}),[O,g]=b.useState({scale:1,x:0,y:0}),[m,v]=b.useState(!1),[w,y]=b.useState({x:0,y:0}),[T,x]=b.useState("idle"),[k,S]=b.useState("idle"),Q=Gr(X=>X.themeName),R=b.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 X=await pWe(Q),W=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:U}=await X.render(W,e);if(!U||typeof U!="string"||U.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(U)}catch(X){console.error("Mermaid rendering error:",X);const W=X instanceof Error?X.message:"Failed to render mermaid diagram";s(W),c("")}finally{o(!1)}},[e,t,Q]);b.useEffect(()=>{R().catch(X=>{console.error("Error in renderDiagram effect:",X),s("Failed to initialize diagram rendering"),o(!1)})},[R]);const _=b.useCallback(()=>{try{if(!l||!r.current)return 1;const W=r.current.getBoundingClientRect(),U=document.createElement("div");U.innerHTML=l;const J=U.querySelector("svg");if(!J)return 1;const he=J.getBoundingClientRect?.()?.width||Number.parseFloat(J.getAttribute("width")||"0")||J.viewBox?.baseVal?.width||800,ue=J.getBoundingClientRect?.()?.height||Number.parseFloat(J.getAttribute("height")||"0")||J.viewBox?.baseVal?.height||600,we=W.width*.9/he,xe=W.height*.9/ue;return Math.min(we,xe,1)}catch(X){return console.error("Error calculating fullscreen scale:",X),1}},[l]);b.useEffect(()=>{u&&l&&setTimeout(()=>{try{const X=_();g({scale:X,x:0,y:0})}catch(X){console.error("Error setting fullscreen transform:",X)}},100)},[u,l,_]);const A=b.useCallback((X=!1)=>{try{(X?g:f)(U=>({...U,scale:Math.min(U.scale*1.2,10)}))}catch(W){console.error("Error in zoom in:",W)}},[]),E=b.useCallback((X=!1)=>{try{(X?g:f)(U=>({...U,scale:Math.max(U.scale/1.2,.1)}))}catch(W){console.error("Error in zoom out:",W)}},[]),I=b.useCallback((X=!1)=>{try{const W=X?g:f;if(X){const U=_();W({scale:U,x:0,y:0})}else W({scale:1,x:0,y:0})}catch(W){console.error("Error in reset:",W)}},[_]),L=b.useCallback(()=>{if(l)try{const X=new Blob([l],{type:"image/svg+xml"}),W=URL.createObjectURL(X),U=document.createElement("a");U.href=W,U.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(U),U.click(),document.body.removeChild(U),URL.revokeObjectURL(W)}catch(X){console.error("Failed to save SVG:",X)}},[l]),z=b.useCallback(async()=>{try{await navigator.clipboard.writeText(e),x("copied"),setTimeout(()=>x("idle"),1200)}catch(X){console.error("Failed to copy Mermaid chart text:",X)}},[e]),V=b.useCallback(async()=>{try{await navigator.clipboard.writeText(e),S("copied"),setTimeout(()=>S("idle"),1200)}catch(X){console.error("Failed to copy Mermaid chart text:",X)}},[e]),q=b.useCallback(X=>{try{v(!0),y({x:X.clientX,y:X.clientY}),X.preventDefault()}catch(W){console.error("Error in mouse down:",W)}},[]),Z=b.useCallback((X,W=!1)=>{try{if(!m)return;const U=X.clientX-w.x,J=X.clientY-w.y;(W?g:f)(ue=>({...ue,x:ue.x+U,y:ue.y+J})),y({x:X.clientX,y:X.clientY})}catch(U){console.error("Error in mouse move:",U)}},[m,w]),j=b.useCallback(()=>{try{v(!1)}catch(X){console.error("Error in mouse up:",X)}},[]),M=b.useCallback((X,W=!1)=>{try{X.preventDefault();const U=X.deltaY>0?.9:1.1;(W?g:f)(he=>({...he,scale:Math.min(Math.max(he.scale*U,.1),5)}))}catch(U){console.error("Error in wheel:",U)}},[]),Y=b.useCallback(X=>{try{d(X)}catch(W){console.error("Error toggling fullscreen:",W)}},[]);if(i)return p.jsxs(N6,{title:"Mermaid diagram error",children:[i,p.jsx("span",{className:G("mt-2 block text-ink-muted"),children:"Chart"}),p.jsx("span",{className:G("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const F=(X=!1)=>{try{const W=X?r:n,U=X?O:h;return p.jsx("div",{ref:W,className:G("mermaid flex w-full items-center justify-center",X?"h-full min-h-full":"h-auto min-h-50",m?"cursor-grabbing":"cursor-grab"),onMouseDown:q,onMouseMove:J=>Z(J,X),onMouseUp:j,onMouseLeave:j,onWheel:J=>M(J,X),children:a?p.jsx("div",{className:G("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?p.jsx("div",{className:G("flex h-full w-full items-center justify-center"),style:{transform:`translate(${U.x}px, ${U.y}px) scale(${U.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(W){return console.error("Error rendering diagram content:",W),p.jsx(N6,{title:"Rendering error",children:"Failed to render diagram content."})}};return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:G("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:[F(!1),p.jsx(MG,{className:"top-2 right-2",copied:T==="copied",onZoomIn:()=>A(!1),onZoomOut:()=>E(!1),onReset:()=>I(!1),onSave:L,onCopy:z,children:p.jsx(vt,{content:"Fullscreen",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>Y(!0),children:p.jsx(sEe,{})})})})]}),p.jsx(AO,{open:u,onClose:()=>Y(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:p.jsxs("div",{className:G("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:[F(!0),p.jsx(MG,{className:"top-4 right-4",copied:k==="copied",onZoomIn:()=>A(!0),onZoomOut:()=>E(!0),onReset:()=>I(!0),onSave:L,onCopy:V,children:p.jsx(vt,{content:"Close fullscreen",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>Y(!1),children:p.jsx(Rs,{})})})})]})})]})}),vWe=b.memo(e=>p.jsx(gWe,{children:p.jsx(mWe,{...e})}));let Pue=!1,jE=null;const wWe=()=>(jE||(jE=Ae(()=>Promise.resolve({}),__vite__mapDeps([4]),import.meta.url).then(e=>(Pue=!0,e))),jE),bWe=/language-(\w+)/,yWe=/\n$/,xWe=/\$(?!\d)(.+?)\$/,SWe=/\$\$([\s\S]+?)\$\$/,$We=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,kWe=/\\[a-zA-Z]+(\{[^}]*\})?/,_ue={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})=>bWe.exec(t??"")?.[1]==="mermaid"?p.jsx(vWe,{chart:String(n).replace(yWe,"")}):p.jsx("code",{className:t,...r,children:n})},TWe=[VC],PWe=[VC,JUe],_We=[],CWe=[mLe],QWe=e=>xWe.test(e)||SWe.test(e)||$We.test(e)?!0:kWe.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),Cue=e=>b.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),Que=e=>{const t=b.useMemo(()=>QWe(e),[e]),[n,r]=b.useState(()=>t&&Pue);return b.useEffect(()=>{if(!t||n)return;let i=!1;return wWe().then(()=>{i||r(!0)}),()=>{i=!0}},[t,n]),{remarkPlugins:n?PWe:TWe,rehypePlugins:n?CWe:_We}},Zg=b.memo(({content:e,styleProps:t,className:n})=>{const r=b.useMemo(()=>e.trim(),[e]),{remarkPlugins:i,rehypePlugins:s}=Que(r),a=Cue(t);return p.jsx("div",{className:G("lo-markdown",n),style:a,children:p.jsx(x7,{remarkPlugins:i,rehypePlugins:s,components:_ue,children:r})})});Zg.displayName="MarkdownRenderer";const Eue=b.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=Que(e);return p.jsx(x7,{remarkPlugins:t,rehypePlugins:n,components:_ue,children:e})});Eue.displayName="StableBlock";const Rue=b.memo(({text:e,animate:t})=>p.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));Rue.displayName="ArrivedText";const Aue=({content:e,styleProps:t,className:n})=>{const r=b.useRef(null);r.current===null&&(r.current=rWe());const i=r.current,s=b.useRef([]),a=b.useRef(0);oWe(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+lWe(e.slice(l)),h=[{offset:l,animate:!1}];for(const O of c){if(O.offset>=d)break;h.push(O)}const f=Cue(t);return p.jsxs("div",{className:G("lo-markdown",n),style:f,children:[i.blocks.map((O,g)=>p.jsx(Eue,{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(Rue,{text:e.slice(O.offset,m),animate:O.animate},O.offset)})})]})};Aue.displayName="StreamingMarkdown";const Of=(e="settings page")=>p.jsx(cQe,{to:"/settings",className:"text-accent underline underline-offset-2",children:e}),zG={"Hosting platform is not configured":p.jsxs("p",{children:["You haven't selected an AI provider yet. Go to the ",Of()," to configure it for all your agents. If you don't have an AI provider, you can sign in to Radient to get access for free to start."]}),"Model name is not configured":p.jsxs("p",{children:["You haven't selected an AI model yet. Go to the ",Of()," to select a model for all your agents. If you don't have an AI provider, you can sign in to Radient to get access for free to start."]}),"Rate limit":p.jsxs("p",{children:["You've hit the rate limit for your AI provider. Please try again later or get Radient Pass in the ",Of()," to access AI models with no rate limits at low prices."]}),"Rate-limit":p.jsxs("p",{children:["You've hit the rate limit for your AI provider. Please try again later or get Radient Pass in the ",Of()," to access all AI models with no rate limits at low prices."]}),"Invalid API key":p.jsxs("p",{children:["Your API key is invalid. Go to the ",Of()," to update your API key."]}),"404 models":p.jsxs("p",{children:["The model you're trying to use is not available. Go to the"," ",Of()," to select a different model, or use Radient to get access to hundreds of models with no rate limits"]}),"Call ListModels":p.jsxs("p",{children:["The model you're trying to use is not available. Go to the"," ",Of()," to select a different model, or use Radient to get access to hundreds of models with no rate limits"]}),"Failed to interpret action":p.jsxs("p",{children:["The model tried to perform an action but was unable to express its intent in the required schema. Typically this happens because the model can't follow the complex instructions required for agentic AI.",p.jsx("br",{}),p.jsx("br",{}),"Change your model in the ",Of()," to fix this. We recommend using Radient Automatic to have the best combo of cheap and smart picked for you based on your requests (typically cheaper than bringing your own key), or use one of the recommended models with a star icon."]})},mb=({error:e})=>{if(!e||e==="[No error output]")return null;const t=e.trim().toLowerCase();let n;for(const r in zG)if(t.includes(r.toLowerCase())){n=zG[r];break}return p.jsxs("div",{className:"mb-4 w-full",children:[p.jsx("span",{className:"mb-1 block text-danger text-meta",children:"Error"}),p.jsx("pre",{className:"flex max-h-[200px] w-full flex-col-reverse overflow-auto whitespace-pre-wrap rounded-sm border border-danger-border bg-danger-wash p-3 font-mono text-danger text-mono-sm",children:e}),n&&p.jsxs("div",{className:"mt-3 flex w-full items-center gap-2 rounded-sm border border-hairline bg-surface p-3",children:[p.jsx(eS,{className:"size-4 shrink-0 text-ink-muted","aria-hidden":!0}),p.jsx("div",{className:"text-body-sm text-ink",children:n})]})]})},Xue=({className:e})=>p.jsx("div",{className:G("flex size-7 shrink-0 items-center justify-center rounded-full bg-sunken text-ink-muted",e),children:p.jsx(sv,{size:16,"aria-label":"Assistant"})}),gP="pl-10",ah=({isUser:e,children:t,isSmallView:n,showAvatar:r,className:i})=>e?p.jsx("div",{className:G("flex w-full justify-end",i),children:t}):p.jsxs("div",{className:G("relative w-full",!n&&gP,i),children:[r&&!n&&p.jsx(Xue,{className:"absolute top-0 left-0"}),t]}),Due=6048e5,EWe=864e5,LG=6e4,Lan=36e5,qan=1e3,qG=525600,UG=43200,WG=1440,GG=Symbol.for("constructDateFrom");function Rh(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&GG in e?e[GG](t):e instanceof Date?new e.constructor(t):new Date(t)}function yl(e,t){return Rh(t||e,e)}let RWe={};function gS(){return RWe}function jy(e,t){const n=gS(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=yl(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 mP(e,t){return jy(e,{...t,weekStartsOn:1})}function Iue(e,t){const n=yl(e,t?.in),r=n.getFullYear(),i=Rh(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=mP(i),a=Rh(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);const o=mP(a);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function vP(e){const t=yl(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 Fue(e,...t){const n=Rh.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function jG(e,t){const n=yl(e,t?.in);return n.setHours(0,0,0,0),n}function AWe(e,t,n){const[r,i]=Fue(n?.in,e,t),s=jG(r),a=jG(i),o=+s-vP(s),l=+a-vP(a);return Math.round((o-l)/EWe)}function XWe(e,t){const n=Iue(e,t),r=Rh(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),mP(r)}function DWe(e,t){const n=+yl(e)-+yl(t);return n<0?-1:n>0?1:n}function IWe(e){return Rh(e,Date.now())}function FWe(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function NWe(e){return!(!FWe(e)&&typeof e!="number"||isNaN(+yl(e)))}function MWe(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function zWe(e,t){const n=yl(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const LWe={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"}},qWe=(e,t,n)=>{let r;const i=LWe[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 VE(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const UWe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},WWe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},GWe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},jWe={date:VE({formats:UWe,defaultWidth:"full"}),time:VE({formats:WWe,defaultWidth:"full"}),dateTime:VE({formats:GWe,defaultWidth:"full"})},VWe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},YWe=(e,t,n,r)=>VWe[e];function Jv(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 BWe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ZWe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},HWe={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"]},KWe={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"]},JWe={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"}},eGe={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"}},tGe=(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"},nGe={ordinalNumber:tGe,era:Jv({values:BWe,defaultWidth:"wide"}),quarter:Jv({values:ZWe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Jv({values:HWe,defaultWidth:"wide"}),day:Jv({values:KWe,defaultWidth:"wide"}),dayPeriod:Jv({values:JWe,defaultWidth:"wide",formattingValues:eGe,defaultFormattingWidth:"wide"})};function ew(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)?iGe(o,d=>d.test(a)):rGe(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 rGe(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function iGe(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function sGe(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 aGe=/^(\d+)(th|st|nd|rd)?/i,oGe=/\d+/i,lGe={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},cGe={any:[/^b/i,/^(a|c)/i]},uGe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},dGe={any:[/1/i,/2/i,/3/i,/4/i]},hGe={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},fGe={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]},OGe={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},pGe={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]},gGe={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},mGe={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}},vGe={ordinalNumber:sGe({matchPattern:aGe,parsePattern:oGe,valueCallback:e=>parseInt(e,10)}),era:ew({matchPatterns:lGe,defaultMatchWidth:"wide",parsePatterns:cGe,defaultParseWidth:"any"}),quarter:ew({matchPatterns:uGe,defaultMatchWidth:"wide",parsePatterns:dGe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ew({matchPatterns:hGe,defaultMatchWidth:"wide",parsePatterns:fGe,defaultParseWidth:"any"}),day:ew({matchPatterns:OGe,defaultMatchWidth:"wide",parsePatterns:pGe,defaultParseWidth:"any"}),dayPeriod:ew({matchPatterns:gGe,defaultMatchWidth:"any",parsePatterns:mGe,defaultParseWidth:"any"})},Nue={code:"en-US",formatDistance:qWe,formatLong:jWe,formatRelative:YWe,localize:nGe,match:vGe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function wGe(e,t){const n=yl(e,t?.in);return AWe(n,zWe(n))+1}function bGe(e,t){const n=yl(e,t?.in),r=+mP(n)-+XWe(n);return Math.round(r/Due)+1}function Mue(e,t){const n=yl(e,t?.in),r=n.getFullYear(),i=gS(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=Rh(t?.in||e,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const o=jy(a,t),l=Rh(t?.in||e,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const c=jy(l,t);return+n>=+o?r+1:+n>=+c?r:r-1}function yGe(e,t){const n=gS(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=Mue(e,t),s=Rh(t?.in||e,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),jy(s,t)}function xGe(e,t){const n=yl(e,t?.in),r=+jy(n,t)-+yGe(n,t);return Math.round(r/Due)+1}function Lr(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const pf={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return Lr(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):Lr(n+1,2)},d(e,t){return Lr(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 Lr(e.getHours()%12||12,t.length)},H(e,t){return Lr(e.getHours(),t.length)},m(e,t){return Lr(e.getMinutes(),t.length)},s(e,t){return Lr(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return Lr(i,t.length)}},Am={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},VG={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 pf.y(e,t)},Y:function(e,t,n,r){const i=Mue(e,r),s=i>0?i:1-i;if(t==="YY"){const a=s%100;return Lr(a,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):Lr(s,t.length)},R:function(e,t){const n=Iue(e);return Lr(n,t.length)},u:function(e,t){const n=e.getFullYear();return Lr(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 Lr(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 Lr(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 pf.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 Lr(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=xGe(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):Lr(i,t.length)},I:function(e,t,n){const r=bGe(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):Lr(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):pf.d(e,t)},D:function(e,t,n){const r=wGe(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Lr(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 Lr(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 Lr(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 Lr(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=Am.noon:r===0?i=Am.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=Am.evening:r>=12?i=Am.afternoon:r>=4?i=Am.morning:i=Am.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 pf.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):pf.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Lr(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):Lr(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):pf.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):pf.s(e,t)},S:function(e,t){return pf.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return BG(r);case"XXXX":case"XX":return wp(r);case"XXXXX":case"XXX":default:return wp(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return BG(r);case"xxxx":case"xx":return wp(r);case"xxxxx":case"xxx":default:return wp(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+YG(r,":");case"OOOO":default:return"GMT"+wp(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+YG(r,":");case"zzzz":default:return"GMT"+wp(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return Lr(r,t.length)},T:function(e,t,n){return Lr(+e,t.length)}};function YG(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+Lr(s,2)}function BG(e,t){return e%60===0?(e>0?"-":"+")+Lr(Math.abs(e)/60,2):wp(e,t)}function wp(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Lr(Math.trunc(r/60),2),s=Lr(r%60,2);return n+i+t+s}const ZG=(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"})}},zue=(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"})}},SGe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return ZG(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}}",ZG(r,t)).replace("{{time}}",zue(i,t))},$Ge={p:zue,P:SGe},kGe=/^D+$/,TGe=/^Y+$/,PGe=["D","DD","YY","YYYY"];function _Ge(e){return kGe.test(e)}function CGe(e){return TGe.test(e)}function QGe(e,t,n){const r=EGe(e,t,n);if(console.warn(r),PGe.includes(e))throw new RangeError(r)}function EGe(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 RGe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,AGe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,XGe=/^'([^]*?)'?$/,DGe=/''/g,IGe=/[a-zA-Z]/;function YE(e,t,n){const r=gS(),i=n?.locale??r.locale??Nue,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=yl(e,n?.in);if(!NWe(o))throw new RangeError("Invalid time value");let l=t.match(AGe).map(u=>{const d=u[0];if(d==="p"||d==="P"){const h=$Ge[d];return h(u,i.formatLong)}return u}).join("").match(RGe).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const d=u[0];if(d==="'")return{isToken:!1,value:FGe(u)};if(VG[d])return{isToken:!0,value:u};if(d.match(IGe))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&&CGe(d)||!n?.useAdditionalDayOfYearTokens&&_Ge(d))&&QGe(d,t,String(e));const h=VG[d[0]];return h(o,d,i.localize,c)}).join("")}function FGe(e){const t=e.match(XGe);return t?t[1].replace(DGe,"'"):e}function NGe(e,t,n){const r=gS(),i=n?.locale??r.locale??Nue,s=DWe(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:s}),[o,l]=Fue(n?.in,...s>0?[t,e]:[e,t]),c=MWe("round"),u=l.getTime()-o.getTime(),d=u/LG,h=vP(l)-vP(o),f=(u-h)/LG,O=n?.unit;let g;if(d<1?g="second":d<60?g="minute":d<WG?g="hour":f<UG?g="day":f<qG?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/WG);return i.formatDistance("xDays",m,a)}else if(g==="month"){const m=c(f/UG);return m===12&&O!=="month"?i.formatDistance("xYears",1,a):i.formatDistance("xMonths",m,a)}else{const m=c(f/qG);return i.formatDistance("xYears",m,a)}}function MGe(e,t){return NGe(e,IWe(e),t)}const zGe=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 YE(t,"h:mm a");if(t.toDateString()===r.toDateString())return"Yesterday";const i=new Date(n);return i.setDate(n.getDate()-7),t>i?YE(t,"EEEE"):YE(t,"yyyy-MM-dd")}catch(t){return console.error("Error formatting date:",t),""}},Uan=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),""}},LGe=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),""}},B7=({timestamp:e,className:t})=>p.jsx(vt,{content:LGe(e),side:"bottom",delayDuration:1200,children:p.jsx("span",{className:G("shrink-0 cursor-help whitespace-nowrap text-ink-dim text-meta",t),children:zGe(e)})}),vb=({output:e})=>e?p.jsxs("div",{className:"mb-4 w-full",children:[p.jsx("span",{className:"mb-1 block text-ink-dim text-meta",children:"Output"}),p.jsx("pre",{className:"flex max-h-[300px] w-full flex-col-reverse overflow-auto rounded-sm border border-hairline bg-sunken p-3 font-mono text-ink text-mono-sm",children:e})]}):null,Lue=({content:e,className:t})=>e?p.jsxs("section",{"aria-label":"Question from the agent",className:G("flex gap-3 rounded-md border border-accent bg-accent-wash px-4 py-3",t),children:[p.jsx(cEe,{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:"Waiting for your answer"}),p.jsx("div",{className:"lo-on-wash text-ink",children:p.jsx(Zg,{content:e})})]})]}):null,qGe="ml-5",HG="flex min-h-6 w-full items-center gap-1.5 py-0.5 text-left",mg=({summary:e,children:t,defaultOpen:n=!1,chevron:r="leading",className:i,triggerClassName:s,rowClassName:a,disabled:o=!1})=>{const[l,c]=b.useState(n),u=b.useId();if(o)return p.jsx("div",{className:i,children:p.jsxs("div",{className:G(HG,"text-ink-dim",a),children:[r==="leading"&&p.jsx("span",{className:"size-3.5 shrink-0","aria-hidden":!0}),p.jsx("span",{className:"min-w-0 flex-1",children:e})]})});const d=l?p.jsx(o1,{className:"size-3.5","aria-hidden":!0}):p.jsx(og,{className:"size-3.5","aria-hidden":!0});return p.jsxs("div",{className:i,children:[p.jsxs("button",{type:"button","aria-expanded":l,"aria-controls":u,onClick:()=>c(h=>!h),className:G(HG,"cursor-pointer select-none","text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink-muted",a,s),children:[r==="leading"&&p.jsx("span",{className:"flex shrink-0 text-ink-disabled",children:d}),p.jsx("span",{className:"min-w-0 flex-1",children:e}),r==="trailing"&&p.jsx("span",{className:"flex shrink-0 text-ink-disabled",children:d})]}),l&&p.jsx("div",{id:u,className:G("mt-1 flex flex-col gap-2 pb-1",r==="leading"&&qGe),children:t})]})},que=({children:e,className:t})=>p.jsx("span",{"aria-hidden":!0,className:G("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),Z7=({label:e="Reasoning",content:t})=>!Gr(r=>r.showAgentReasoning)||!t?null:p.jsx(mg,{summary:p.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p.jsx(que,{}),p.jsx("span",{className:"truncate",children:p.jsx("span",{className:"text-ink-dim text-meta",children:e})})]}),children:p.jsx(Zg,{content:t,className:"[--md-ink:var(--lo-ink-muted)]",styleProps:{fontSize:"var(--text-body-sm)",lineHeight:"var(--text-body-sm--line-height)"}})}),UGe={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},WGe=({line:e})=>p.jsx("span",{className:G(UGe[e.kind],"block"),children:e.text}),GGe=({diff:e,className:t})=>{const n=CDe(e);return p.jsxs("div",{className:G("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(WGe,{line:r},i)),n.hidden>0&&p.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:QDe(n.hidden)})]})},jGe=({content:e,details:t,className:n})=>p.jsxs("section",{"aria-label":"Security notice",className:G("flex gap-3 border-warning border-l-2 py-0.5 pl-3",n),children:[p.jsx(dRe,{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(mg,{summary:p.jsx("span",{className:"text-meta",children:"Show the reviewed code"}),children:t}):null]})]}),VGe=(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()},KG=e=>e.startsWith("file://")?e.slice(7):e,YGe={READ:{verb:"Read",runningVerb:"Reading",icon:S8},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:Q8},EDIT:{verb:"Edited",runningVerb:"Editing",icon:REe},CODE:{verb:"Ran code",runningVerb:"Running code",icon:k8},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:cRe},DONE:{verb:"Finished",runningVerb:"Finishing",icon:ZF},ASK:{verb:"Asked",runningVerb:"Asking",icon:$8},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:HQe}},BGe={verb:"Worked on the request",runningVerb:"Working on the request",icon:k8},ZGe=(e,t,n,r)=>{const i=e?YGe[e]:BGe;let s;if(t)s=KG(t);else if(n&&n.length>0){const o=n.filter(l=>!l.startsWith("data:"));o.length===1?s=KG(o[0]):o.length>1&&(s=`${o.length} files`)}const a=!s&&r?VGe(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:s,narration:a||void 0,icon:i.icon}},JG="min-h-5 py-0",HGe=({icon:e,verb:t,object:n,narration:r,running:i,failed:s,wrap:a})=>p.jsxs("span",{className:"flex min-w-0 items-center gap-2","aria-busy":i||void 0,children:[p.jsx(que,{className:s?"text-danger":"text-ink-dim",children:e}),p.jsxs("span",{className:G(a?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[p.jsxs("span",{className:G("font-mono text-mono-sm",i?"text-ink-muted":"text-ink-dim",s&&"text-danger"),children:[t,r?":":null]}),n?p.jsxs("span",{className:"font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?p.jsxs("span",{className:"text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),H7=({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=ZGe(e,t,n,r),g=c??(i?O.runningVerb:O.verb),m=s?tS:O.icon,v=s||!c||!d?p.jsx(m,{}):d,w=p.jsx(HGe,{icon:v,verb:g,object:c?u:O.object,narration:c?r:O.narration,running:i,failed:s,wrap:h});return o?p.jsx(mg,{summary:w,chevron:"leading",defaultOpen:a,className:l,rowClassName:f?JG:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:o}):p.jsx(mg,{disabled:!0,summary:w,className:l,rowClassName:f?JG:void 0})},KGe="mcp__",JGe={bash:IRe,read:sO,write:Tq,edit:Tq,glob:by,grep:yC,todo:Z5e,wake:vC,list_variables:W2,read_variable:W2,browser:Cq,web_search:Cq,web_fetch:iO,task:gh,agent:gh,send:R8,peer:M5e};function eje(e){const t=e.trim().toLowerCase(),n=JGe[t];return n||(t.startsWith(KGe)?cae:n2e)}const tje=uc,nje=Rs,rje=Hse,ej="min-h-5 py-0",ije={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent",plain:"text-ink-muted"},sje=({added:e,removed:t})=>e<=0&&t<=0?null:p.jsxs("span",{className:G("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&p.jsxs("span",{className:G("text-success"),children:["+",e]}),t>0&&p.jsxs("span",{className:G("text-danger"),children:["-",t]})]}),tj={running:"",success:"succeeded",error:"failed",interrupted:"interrupted"},aje=1e3;function oje(e){const[t,n]=b.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return b.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,aje);return()=>window.clearInterval(i)},[e]),t}const lje=({outcome:e,durationS:t,startedAt:n})=>{const r=e==="running",i=oje(r?n??null:null),s=e==="success"?tje:e==="error"?nje:e==="interrupted"?rje:null,a=e==="success"?"text-success":e==="error"?"text-danger":"text-ink-dim",o=r?n==null?"":n7(i??0):pDe(t);return p.jsxs("span",{className:G("flex shrink-0 items-center gap-1.5"),children:[p.jsxs("span",{className:G("flex size-3.5 shrink-0 [&_svg]:size-3.5",a),children:[s?p.jsx(s,{"aria-hidden":!0}):null,tj[e]?p.jsx("span",{className:G("sr-only"),children:tj[e]}):null]}),p.jsx("span",{className:G("w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums"),children:o})]})},cje=({toolName:e,summary:t,summaryFallback:n=null,outcome:r,durationS:i,startedAt:s=null,added:a=0,removed:o=0,nameColumn:l=woe,details:c,defaultOpen:u=!1,className:d,media:h})=>{const f=r==="running",O=r==="error",g=eje(e),m=tP(e),v=p.jsxs("span",{className:G("flex min-w-0 flex-1 items-center gap-2"),children:[p.jsx("span",{"aria-hidden":!0,className:G("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:G("shrink-0 truncate font-mono text-mono-sm","pr-1",f?"text-ink":O?"text-danger":ije[vDe(e)]),style:{width:`calc(${l}ch + 0.25rem)`},title:m,children:m}),p.jsx("span",{className:G("min-w-0 flex-1 truncate font-mono text-mono-sm",f?"text-ink-muted":"text-ink-dim"),children:voe(t,e)?n??"":t}),p.jsx(sje,{added:a,removed:o}),p.jsx(lje,{outcome:r,durationS:i,startedAt:s})]}),w=f?"bg-elevated":O?"bg-danger-wash":"hover:bg-elevated",y=c?p.jsx(mg,{summary:v,chevron:"leading",defaultOpen:u,className:G("@container/toolrow",d),rowClassName:ej,triggerClassName:G("-mx-2 rounded-sm px-2",w),children:c}):p.jsx(mg,{disabled:!0,summary:v,rowClassName:ej,className:G("@container/toolrow",(f||O)&&G("-mx-2 rounded-sm px-2",w),d)});return h?p.jsxs("div",{className:G("flex flex-col"),children:[y,h]}):y},Uue=e=>{const t=b.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=b.useCallback(()=>window.matchMedia(e).matches,[e]);return b.useSyncExternalStore(t,n,()=>!1)},nj=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],uje=80,dje=1e3,hje=({activity:e,phase:t,className:n})=>{const[r,i]=b.useState(0),[s,a]=b.useState(0),o=Uue("(prefers-reduced-motion: reduce)"),l=b.useRef(Date.now()),c=b.useRef(t);return c.current!==t&&(c.current=t,l.current=Date.now(),a(0)),b.useEffect(()=>{const u=window.setInterval(()=>a(Math.floor((Date.now()-l.current)/1e3)),dje);if(o)return i(0),()=>window.clearInterval(u);const d=window.setInterval(()=>i(h=>(h+1)%nj.length),uje);return()=>{window.clearInterval(d),window.clearInterval(u)}},[o]),p.jsxs("div",{className:G("flex items-center gap-2",n),"data-lo-working-line":!0,"aria-live":"polite",children:[p.jsx("span",{"aria-hidden":!0,className:G("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:nj[r]}),p.jsx("span",{className:G("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),p.jsx("span",{"aria-hidden":!0,className:G("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:n7(s)})]})},Wue=({children:e,className:t})=>p.jsx("div",{className:G("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}),K7=({name:e,className:t})=>p.jsxs("div",{className:G("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",t),children:[p.jsx(I5e,{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})," could not be displayed. It may have been moved, renamed, or deleted."]})]}),YC=({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),os("File path copied to clipboard")}catch(o){console.error("Failed to copy file path: ",o),tr("Failed to copy file path")}},a=()=>{e&&window.api.openFile(e)};return p.jsxs(nS,{children:[p.jsx(vt,{content:t,children:p.jsx(l1,{asChild:!0,children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":r,onClick:o=>o.stopPropagation(),children:n??p.jsx(T8,{"aria-hidden":"true"})})})}),p.jsxs(rS,{align:"end",className:"min-w-45",onClick:o=>o.stopPropagation(),children:[i&&p.jsxs(ts,{onSelect:i,children:[p.jsx(j5e,{"aria-hidden":"true"}),p.jsx("span",{children:"Show in canvas"})]}),p.jsxs(ts,{onSelect:a,children:[p.jsx(av,{"aria-hidden":"true"}),p.jsx("span",{children:"Open file"})]}),p.jsxs(ts,{onSelect:()=>window.api.showItemInFolder(e),children:[p.jsx(by,{"aria-hidden":"true"}),p.jsx("span",{children:"Open folder"})]}),p.jsxs(ts,{onSelect:s,children:[p.jsx(Kse,{"aria-hidden":"true"}),p.jsx("span",{children:"Copy file path"})]})]})]})},uo=e=>{if(e.startsWith("data:image/"))return"image";if(e.startsWith("data:video/"))return"video";if(e.startsWith("data:application/pdf"))return"pdf";const t=e.split(".").pop()?.toLowerCase();return t?["png","jpg","jpeg","gif","bmp","webp","svg"].includes(t)?"image":["mp4","webm","ogg","mov","avi","mkv"].includes(t)?"video":["pdf"].includes(t)?"pdf":["md","markdown"].includes(t)?"markdown":["html","htm"].includes(t)?"html":["zip","tar","gz","rar","7z"].includes(t)?"archive":["txt","log"].includes(t)?"text":["js","ts","jsx","tsx","py","java","c","cpp","cs","go","rb","php","sh","css","scss","less","json","xml","yaml","yml"].includes(t)?"code":["doc","docx","odt"].includes(t)?"document":["xls","xlsx","ods","csv","tsv"].includes(t)?"spreadsheet":["ppt","pptx","odp"].includes(t)?"presentation":["mp3","wav","aac","flac"].includes(t)?"audio":"other":"other"},Gue=1024;let fje=0,Hl=class{constructor(t,n){this.from=t,this.to=n}};class Pn{constructor(t={}){this.id=fje++,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=$s.match(t)),n=>{let r=t(n);return r===void 0?null:[this,r]}}}Pn.closedBy=new Pn({deserialize:e=>e.split(" ")});Pn.openedBy=new Pn({deserialize:e=>e.split(" ")});Pn.group=new Pn({deserialize:e=>e.split(" ")});Pn.isolate=new Pn({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});Pn.contextHash=new Pn({perNode:!0});Pn.lookAhead=new Pn({perNode:!0});Pn.mounted=new Pn({perNode:!0});class Vy{constructor(t,n,r){this.tree=t,this.overlay=n,this.parser=r}static get(t){return t&&t.props&&t.props[Pn.mounted.id]}}const Oje=Object.create(null);class $s{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):Oje,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new $s(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(Pn.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(Pn.group),s=-1;s<(i?i.length:0);s++){let a=n[s<0?r.name:i[s]];if(a)return a}}}}$s.none=new $s("",Object.create(null),0,8);class mv{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 $s(r.name,i,r.id,r.flags):r)}return new mv(n)}}const F$=new WeakMap,rj=new WeakMap;var ni;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"})(ni||(ni={}));class cr{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=Vy.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 wP(this.topNode,t)}cursorAt(t,n=0,r=0){let i=F$.get(this)||this.topNode,s=new wP(i);return s.moveTo(t,n),F$.set(this,s._tree),s}get topNode(){return new za(this,0,0,null)}resolve(t,n=0){let r=Yy(F$.get(this)||this.topNode,t,n,!1);return F$.set(this,r),r}resolveInner(t,n=0){let r=Yy(rj.get(this)||this.topNode,t,n,!0);return rj.set(this,r),r}resolveStack(t,n=0){return mje(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:s=this.length}=t,a=t.mode||0,o=(a&ni.IncludeAnonymous)>0;for(let l=this.cursor(a|ni.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:tN($s.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new cr(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new cr($s.none,n,r,i)))}static build(t){return vje(t)}}cr.empty=new cr($s.none,[],[],0);class J7{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 J7(this.buffer,this.index)}}class gO{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return $s.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&&!(jue(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 gO(s,a,this.set)}}function jue(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 Yy(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 za&&e.index<0?null:e.parent;if(!a)return e;e=a}let s=r?0:ni.IgnoreOverlays;if(r)for(let a=e,o=a.parent;o;a=o,o=a.parent)a instanceof za&&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 Vue{cursor(t=0){return new wP(this,t)}getChild(t,n=null,r=null){let i=ij(this,t,n,r);return i.length?i[0]:null}getChildren(t,n=null,r=null){return ij(this,t,n,r)}resolve(t,n=0){return Yy(this,t,n,!1)}resolveInner(t,n=0){return Yy(this,t,n,!0)}matchContext(t){return M6(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 za extends Vue{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(jue(i,r,d,d+u.length)){if(u instanceof gO){if(s&ni.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,n,r-d,i);if(h>-1)return new ju(new pje(a,u,t,d),null,h)}else if(s&ni.IncludeAnonymous||!u.type.isAnonymous||eN(u)){let h;if(!(s&ni.IgnoreMounts)&&(h=Vy.get(u))&&!h.overlay)return new za(h.tree,d,t,a);let f=new za(u,d,t,a);return s&ni.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(n<0?u.children.length-1:0,n,r,i)}}}if(s&ni.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&ni.IgnoreOverlays)&&(i=Vy.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 za(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 ij(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 M6(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 pje{constructor(t,n,r,i){this.parent=t,this.buffer=n,this.index=r,this.start=i}}class ju extends Vue{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 ju(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&ni.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 ju(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 ju(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 ju(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 cr(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Yue(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 za&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new gje(i,n)}class gje{constructor(t,n){this.heads=t,this.node=n}get next(){return Yue(this.heads)}}function mje(e,t,n){let r=e.resolveInner(t,n),i=null;for(let s=r instanceof za?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=Vy.get(s.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new za(a.tree,a.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Yy(o,t,n,!1))}}return i?Yue(i):r}class wP{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 za)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 za?(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&ni.ExcludeBuffers?!1:this.enterChild(1,t,n):this.yield(this._tree.enter(t,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ni.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&ni.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&ni.IncludeAnonymous||o instanceof gO||!o.type.isAnonymous||eN(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 ju(this.buffer,n,this.stack[i]);return this.bufferNode=new ju(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 M6(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 M6(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 eN(e){return e.children.some(t=>t instanceof gO||!t.type.isAnonymous||eN(t))}function vje(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=Gue,reused:s=[],minRepeatType:a=r.types.length}=e,o=Array.isArray(n)?new J7(n,n.length):n,l=r.types,c=0,u=0;function d(x,k,S,Q,R,_){let{id:A,start:E,end:I,size:L}=o,z=u,V=c;for(;L<0;)if(o.next(),L==-1){let Y=s[A];S.push(Y),Q.push(E-x);return}else if(L==-3){c=A;return}else if(L==-4){u=A;return}else throw new RangeError(`Unrecognized record size: ${L}`);let q=l[A],Z,j,M=E-x;if(I-E<=i&&(j=m(o.pos-k,R))){let Y=new Uint16Array(j.size-j.skip),F=o.pos-j.size,X=Y.length;for(;o.pos>F;)X=v(j.start,Y,X);Z=new gO(Y,I-j.start,r),M=j.start-x}else{let Y=o.pos-L;o.next();let F=[],X=[],W=A>=a?A:-1,U=0,J=I;for(;o.pos>Y;)W>=0&&o.id==W&&o.size>=0?(o.end<=J-i&&(O(F,X,E,U,o.end,J,W,z,V),U=F.length,J=o.end),o.next()):_>2500?h(E,Y,F,X):d(E,Y,F,X,W,_+1);if(W>=0&&U>0&&U<F.length&&O(F,X,E,U,E,J,W,z,V),F.reverse(),X.reverse(),W>-1&&U>0){let he=f(q,V);Z=tN(q,F,X,0,F.length,0,I-E,he,he)}else Z=g(q,F,X,I-E,z-I,V)}S.push(Z),Q.push(M)}function h(x,k,S,Q){let R=[],_=0,A=-1;for(;o.pos>k;){let{id:E,start:I,end:L,size:z}=o;if(z>4)o.next();else{if(A>-1&&I<A)break;A<0&&(A=L-i),R.push(E,I,L),_++,o.next()}}if(_){let E=new Uint16Array(_*4),I=R[R.length-2];for(let L=R.length-3,z=0;L>=0;L-=3)E[z++]=R[L],E[z++]=R[L+1]-I,E[z++]=R[L+2]-I,E[z++]=z;S.push(new gO(E,R[2]-I,r)),Q.push(I-x)}}function f(x,k){return(S,Q,R)=>{let _=0,A=S.length-1,E,I;if(A>=0&&(E=S[A])instanceof cr){if(!A&&E.type==x&&E.length==R)return E;(I=E.prop(Pn.lookAhead))&&(_=Q[A]+E.length+I)}return g(x,S,Q,R,_,k)}}function O(x,k,S,Q,R,_,A,E,I){let L=[],z=[];for(;x.length>Q;)L.push(x.pop()),z.push(k.pop()+S-R);x.push(g(r.types[A],L,z,_-R,E-_,I)),k.push(R-S)}function g(x,k,S,Q,R,_,A){if(_){let E=[Pn.contextHash,_];A=A?[E].concat(A):[E]}if(R>25){let E=[Pn.lookAhead,R];A=A?[E].concat(A):[E]}return new cr(x,k,S,Q,A)}function m(x,k){let S=o.fork(),Q=0,R=0,_=0,A=S.end-i,E={size:0,start:0,skip:0};e:for(let I=S.pos-x;S.pos>I;){let L=S.size;if(S.id==k&&L>=0){E.size=Q,E.start=R,E.skip=_,_+=4,Q+=4,S.next();continue}let z=S.pos-L;if(L<0||z<I||S.start<A)break;let V=S.id>=a?4:0,q=S.start;for(S.next();S.pos>z;){if(S.size<0)if(S.size==-3)V+=4;else break e;else S.id>=a&&(V+=4);S.next()}R=q,Q+=L,_+=V}return(k<0||Q==x)&&(E.size=Q,E.start=R,E.skip=_),E.size>4?E:void 0}function v(x,k,S){let{id:Q,start:R,end:_,size:A}=o;if(o.next(),A>=0&&Q<a){let E=S;if(A>4){let I=o.pos-(A-4);for(;o.pos>I;)S=v(x,k,S)}k[--S]=E,k[--S]=_-x,k[--S]=R-x,k[--S]=Q}else A==-3?c=Q:A==-4&&(u=Q);return S}let w=[],y=[];for(;o.pos>0;)d(e.start||0,e.bufferStart||0,w,y,-1,0);let T=(t=e.length)!==null&&t!==void 0?t:w.length?y[0]+w[0].length:0;return new cr(l[e.topID],w.reverse(),y.reverse(),T)}const sj=new WeakMap;function MT(e,t){if(!e.isAnonymous||t instanceof gO||t.type!=e)return 1;let n=sj.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof cr)){n=1;break}n+=MT(e,r)}sj.set(t,n)}return n}function tN(e,t,n,r,i,s,a,o,l){let c=0;for(let O=r;O<i;O++)c+=MT(e,t[O]);let u=Math.ceil(c*1.5/8),d=[],h=[];function f(O,g,m,v,w){for(let y=m;y<v;){let T=y,x=g[y],k=MT(e,O[y]);for(y++;y<v;y++){let S=MT(e,O[y]);if(k+S>=u)break;k+=S}if(y==T+1){if(k>u){let S=O[T];f(S.children,S.positions,0,S.children.length,g[T]+w);continue}d.push(O[T])}else{let S=g[y-1]+O[y-1].length-x;d.push(tN(e,O,g,T,y,x,S,null,l))}h.push(x+w-s)}}return f(t,n,r,i,0),(o||l)(d,h,a)}class nN{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 ju?this.setBuffer(t.context.buffer,t.index,n):t instanceof za&&this.map.set(t.tree,n)}get(t){return t instanceof ju?this.getBuffer(t.context.buffer,t.index):t instanceof za?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 wh{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 wh(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 wh(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 BC=class{startParse(t,n,r){return typeof t=="string"&&(t=new wje(t)),r=r?r.length?r.map(i=>new Hl(i.from,i.to)):[new Hl(0,0)]:[new Hl(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 wje{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 gc(e){return(t,n,r,i)=>new yje(t,e,n,r,i)}class aj{constructor(t,n,r,i,s){this.parser=t,this.parse=n,this.overlay=r,this.target=i,this.from=s}}function oj(e){if(!e.length||e.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class bje{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 z6=new Pn({perNode:!0});class yje{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 cr(r.type,r.children,r.positions,r.length,r.propValues.concat([[z6,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[Pn.mounted.id]=new Vy(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 $je(this.fragments),n=null,r=null,i=new wP(new za(this.baseTree,this.ranges[0].from,0,null),ni.IncludeAnonymous|ni.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=xje(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||Sje(i);let c=t.findMounts(i.from,s.parser);if(typeof s.overlay=="function")n=new bje(s.parser,s.overlay,c,this.inner.length,i.from,i.tree,n);else{let u=uj(this.ranges,s.overlay||(i.from<i.to?[new Hl(i.from,i.to)]:[]));u.length&&oj(u),(u.length||!s.overlay)&&this.inner.push(new aj(s.parser,u.length?s.parser.startParse(this.input,dj(c,u),u):s.parser.startParse(""),s.overlay?s.overlay.map(d=>new Hl(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 Hl(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=uj(this.ranges,n.ranges);c.length&&(oj(c),this.inner.splice(n.index,0,new aj(n.parser,n.parser.startParse(this.input,dj(n.mounts,c),c),n.ranges.map(u=>new Hl(u.from-n.start,u.to-n.start)),n.target,c[0].from))),n=n.prev}r&&!--r.depth&&(r=r.prev)}}}}function xje(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 lj(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 Sje(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=[],w=[];lj(a,u,m,v,w,f);let y=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]],y,T-y,g-1):t.toTree();return v.push(x),w.push(y-f),lj(a,o[m+3],d,v,w,f),new cr(h,v,w,O)}i.children[s]=c(0,o.length,$s.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 za(d,h+e.from,u,e._tree))}}class cj{constructor(t,n){this.offset=n,this.done=!1,this.cursor=t.cursor(ni.IncludeAnonymous|ni.IgnoreMounts)}moveTo(t){let{cursor:n}=this,r=t-this.offset;for(;!this.done&&n.from<r;)n.to>=t&&n.enter(r,1,ni.IgnoreOverlays|ni.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 cr)n=n.children[0];else break}return!1}}let $je=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(z6))!==null&&n!==void 0?n:r.to,this.inner=new cj(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(z6))!==null&&t!==void 0?t:n.to,this.inner=new cj(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(Pn.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 uj(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 Hl(l.from,a),l.to>o&&n.splice(s+1,0,new Hl(o,l.to))):l.to>o?n[s--]=new Hl(o,l.to):n.splice(s--,1))}}return r}function kje(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 Hl(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 dj(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 Hl(h.from+r,h.to+r)),d=kje(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 wh(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 wh(l,c,i.tree,-a,s.from>=a||s.openStart,s.to<=o||s.openEnd))}return n}let L6=[],Bue=[];(()=>{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?Bue:L6).push(n=n+e[t])})();function Tje(e){if(e<768)return!1;for(let t=0,n=L6.length;;){let r=t+n>>1;if(e<L6[r])n=r;else if(e>=Bue[r])t=r+1;else return!0;if(t==n)return!1}}function hj(e){return e>=127462&&e<=127487}const fj=8205;function Pje(e,t,n=!0,r=!0){return(n?Zue:_je)(e,t,r)}function Zue(e,t,n){if(t==e.length)return t;t&&Hue(e.charCodeAt(t))&&Kue(e.charCodeAt(t-1))&&t--;let r=BE(e,t);for(t+=Oj(r);t<e.length;){let i=BE(e,t);if(r==fj||i==fj||n&&Tje(i))t+=Oj(i),r=i;else if(hj(i)){let s=0,a=t-2;for(;a>=0&&hj(BE(e,a));)s++,a-=2;if(s%2==0)break;t+=2}else break}return t}function _je(e,t,n){for(;t>0;){let r=Zue(e,t-2,n);if(r<t)return r;t--}return 0}function BE(e,t){let n=e.charCodeAt(t);if(!Kue(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Hue(r)?(n-55296<<10)+(r-56320)+65536:n}function Hue(e){return e>=56320&&e<57344}function Kue(e){return e>=55296&&e<56320}function Oj(e){return e<65536?1:2}let Tr=class Jue{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]=$1(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),Nu.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]=$1(this,t,n);let r=[];return this.decompose(t,n,r,0),Nu.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 wb(this),s=new wb(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 wb(this,t)}iterRange(t,n=this.length){return new ede(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 tde(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]?Jue.empty:t.length<=32?new es(t):Nu.from(es.split(t,[]))}};class es extends Tr{constructor(t,n=Cje(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 Qje(i,o,r,a);i=o+1,r++}}decompose(t,n,r,i){let s=t<=0&&n>=this.length?this:new es(pj(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let a=r.pop(),o=zT(s.text,a.text.slice(),0,s.length);if(o.length<=32)r.push(new es(o,a.length+s.length));else{let l=o.length>>1;r.push(new es(o.slice(0,l)),new es(o.slice(l)))}}else r.push(s)}replace(t,n,r){if(!(r instanceof es))return super.replace(t,n,r);[t,n]=$1(this,t,n);let i=zT(this.text,zT(r.text,pj(this.text,0,t)),n),s=this.length+r.length-(n-t);return i.length<=32?new es(i,s):Nu.from(es.split(i,[]),s)}sliceString(t,n=this.length,r=`
|
|
1066
|
+
`,n);if(r===-1)break;const i=eWe(t.slice(n,r));if(e.fence){aWe(i,e.fence)&&(e.fence=null),n=r+1;continue}if(xue.test(i)){e.blankRunStart<0&&(e.blankRunStart=n),n=r+1;continue}if(e.blankRunStart>=0){if(e.kind==="none"||!sWe(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=IG(i)}e.blankRunStart=-1}else e.kind==="none"&&(e.kind=IG(i));if(e.kind!=="indented-code"){const s=tWe.exec(i);s&&(e.fence={char:s[1][0],length:s[1].length})}n=r+1}e.cursor=n},lWe=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},Un="var(--color-ink)",Ad="var(--color-ink-muted)",mu="var(--color-surface)",df="var(--color-elevated)",Xd="var(--color-sunken)",xa="var(--color-hairline)",hf="var(--color-control)",Rm="var(--color-accent)",Ww="var(--color-accent-wash)",cWe="var(--color-on-accent)",uWe="var(--color-info)",kue="var(--color-info-wash)",dWe="var(--color-success)",Tue="var(--color-success-wash)",hWe="var(--color-warning)",I6="var(--color-warning-wash)",fWe="var(--color-warning-border)",WE="var(--color-danger)",F6="var(--color-danger-wash)",FG=[Ww,kue,Tue,I6,F6],ff=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),OWe=()=>{const e={primaryColor:ff("--color-accent"),secondaryColor:ff("--color-success"),tertiaryColor:ff("--color-info"),mainBkg:ff("--color-elevated"),clusterBkg:ff("--color-sunken"),clusterBorder:ff("--color-hairline"),edgeLabelBackground:ff("--color-surface"),quadrant1Fill:ff("--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:mu,primaryTextColor:Un,primaryBorderColor:hf,secondaryTextColor:Un,secondaryBorderColor:xa,tertiaryTextColor:Un,tertiaryBorderColor:xa,lineColor:Ad,arrowheadColor:Ad,textColor:Un,secondBkg:Xd,border1:hf,border2:xa,labelColor:Un,nodeBkg:df,nodeBorder:hf,nodeTextColor:Un,defaultLinkColor:Ad,titleColor:Un,noteBkgColor:I6,noteBorderColor:fWe,noteTextColor:Un,actorBkg:df,actorBorder:hf,actorTextColor:Un,actorLineColor:xa,signalColor:Ad,signalTextColor:Un,labelBoxBkgColor:df,labelBoxBorderColor:xa,labelTextColor:Un,loopTextColor:Un,activationBkgColor:Ww,activationBorderColor:Rm,sequenceNumberColor:mu,sectionBkgColor:Xd,sectionBkgColor2:mu,altSectionBkgColor:Xd,excludeBkgColor:Xd,taskBkgColor:Ww,taskBorderColor:hf,taskTextColor:Un,taskTextLightColor:Un,taskTextDarkColor:Un,taskTextOutsideColor:Un,taskTextClickableColor:Rm,activeTaskBkgColor:Ww,activeTaskBorderColor:Rm,gridColor:xa,doneTaskBkgColor:Xd,doneTaskBorderColor:xa,critBkgColor:F6,critBorderColor:WE,todayLineColor:Rm,transitionColor:Ad,transitionLabelColor:Un,stateLabelColor:Un,stateBkg:df,labelBackgroundColor:mu,compositeBackground:Xd,altBackground:Xd,compositeTitleBackground:df,compositeBorder:xa,innerEndBackground:Un,specialStateColor:Un,classText:Un,attributeBackgroundColorOdd:mu,attributeBackgroundColorEven:Xd,rowOdd:mu,rowEven:Xd,errorBkgColor:F6,errorTextColor:WE,pieTitleTextColor:Un,pieSectionTextColor:Un,pieLegendTextColor:Un,pieStrokeColor:mu,pieOuterStrokeColor:xa,requirementBackground:df,requirementBorderColor:hf,requirementTextColor:Un,relationColor:Ad,relationLabelBackground:mu,relationLabelColor:Un,branchLabelColor:cWe,commitLabelColor:Un,commitLabelBackground:mu,tagLabelColor:Un,tagLabelBackground:Ww,tagLabelBorder:hf,quadrant2Fill:kue,quadrant3Fill:Tue,quadrant4Fill:I6,quadrant2TextFill:Un,quadrant3TextFill:Un,quadrant4TextFill:Un,quadrantPointFill:Rm,archEdgeColor:Ad,archEdgeArrowColor:Ad,archGroupBorderColor:xa,scaleLabelColor:Un,packet:{startByteColor:Un,endByteColor:Un,labelColor:Un,titleColor:Un,blockStrokeColor:hf,blockFillColor:df},radar:{axisColor:Ad,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:xa,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:mu,titleColor:Un,xAxisTitleColor:Un,xAxisLabelColor:Un,xAxisTickColor:xa,xAxisLineColor:xa,yAxisTitleColor:Un,yAxisLabelColor:Un,yAxisTickColor:xa,yAxisLineColor:xa,plotColorPalette:[Rm,uWe,dWe,hWe,WE].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=df,t[`surfacePeer${n}`]=xa;for(let n=0;n<8;n++)t[`fillType${n}`]=FG[n%FG.length];return{...t,...e}};let GE=null,NG=null;const pWe=async e=>{GE||(GE=Ae(async()=>{const{default:n}=await import("./mermaid.core-d-O-_a6F.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([0,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await GE;return NG!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:OWe()}),NG=e),t},MG=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:s,onCopy:a,children:o})=>p.jsxs("div",{className:G("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[p.jsx(vt,{content:"Zoom in",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:p.jsx(BRe,{})})}),p.jsx(vt,{content:"Zoom out",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:p.jsx(HRe,{})})}),p.jsx(vt,{content:"Drag the diagram to pan",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:p.jsx(vEe,{})})}),p.jsx(vt,{content:"Reset view",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:p.jsx(E8,{})})}),p.jsx(vt,{content:"Save as SVG",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:s,children:p.jsx(iO,{})})}),p.jsx(vt,{content:t?"Copied":"Copy mermaid text",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:a,children:p.jsx(Vg,{className:G(t&&"text-success")})})}),o]}),N6=({title:e,children:t})=>p.jsxs(qc,{variant:"danger",role:"alert",className:"my-4",children:[p.jsx(lie,{children:e}),p.jsx(dC,{children:t})]});class gWe extends b.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(N6,{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 mWe=b.memo(({chart:e,id:t})=>{const n=b.useRef(null),r=b.useRef(null),[i,s]=b.useState(null),[a,o]=b.useState(!0),[l,c]=b.useState(""),[u,d]=b.useState(!1),[h,f]=b.useState({scale:1,x:0,y:0}),[O,g]=b.useState({scale:1,x:0,y:0}),[m,v]=b.useState(!1),[w,y]=b.useState({x:0,y:0}),[T,x]=b.useState("idle"),[k,S]=b.useState("idle"),Q=Gr(X=>X.themeName),R=b.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 X=await pWe(Q),W=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:U}=await X.render(W,e);if(!U||typeof U!="string"||U.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(U)}catch(X){console.error("Mermaid rendering error:",X);const W=X instanceof Error?X.message:"Failed to render mermaid diagram";s(W),c("")}finally{o(!1)}},[e,t,Q]);b.useEffect(()=>{R().catch(X=>{console.error("Error in renderDiagram effect:",X),s("Failed to initialize diagram rendering"),o(!1)})},[R]);const _=b.useCallback(()=>{try{if(!l||!r.current)return 1;const W=r.current.getBoundingClientRect(),U=document.createElement("div");U.innerHTML=l;const J=U.querySelector("svg");if(!J)return 1;const he=J.getBoundingClientRect?.()?.width||Number.parseFloat(J.getAttribute("width")||"0")||J.viewBox?.baseVal?.width||800,ue=J.getBoundingClientRect?.()?.height||Number.parseFloat(J.getAttribute("height")||"0")||J.viewBox?.baseVal?.height||600,we=W.width*.9/he,xe=W.height*.9/ue;return Math.min(we,xe,1)}catch(X){return console.error("Error calculating fullscreen scale:",X),1}},[l]);b.useEffect(()=>{u&&l&&setTimeout(()=>{try{const X=_();g({scale:X,x:0,y:0})}catch(X){console.error("Error setting fullscreen transform:",X)}},100)},[u,l,_]);const A=b.useCallback((X=!1)=>{try{(X?g:f)(U=>({...U,scale:Math.min(U.scale*1.2,10)}))}catch(W){console.error("Error in zoom in:",W)}},[]),E=b.useCallback((X=!1)=>{try{(X?g:f)(U=>({...U,scale:Math.max(U.scale/1.2,.1)}))}catch(W){console.error("Error in zoom out:",W)}},[]),I=b.useCallback((X=!1)=>{try{const W=X?g:f;if(X){const U=_();W({scale:U,x:0,y:0})}else W({scale:1,x:0,y:0})}catch(W){console.error("Error in reset:",W)}},[_]),L=b.useCallback(()=>{if(l)try{const X=new Blob([l],{type:"image/svg+xml"}),W=URL.createObjectURL(X),U=document.createElement("a");U.href=W,U.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(U),U.click(),document.body.removeChild(U),URL.revokeObjectURL(W)}catch(X){console.error("Failed to save SVG:",X)}},[l]),z=b.useCallback(async()=>{try{await navigator.clipboard.writeText(e),x("copied"),setTimeout(()=>x("idle"),1200)}catch(X){console.error("Failed to copy Mermaid chart text:",X)}},[e]),V=b.useCallback(async()=>{try{await navigator.clipboard.writeText(e),S("copied"),setTimeout(()=>S("idle"),1200)}catch(X){console.error("Failed to copy Mermaid chart text:",X)}},[e]),q=b.useCallback(X=>{try{v(!0),y({x:X.clientX,y:X.clientY}),X.preventDefault()}catch(W){console.error("Error in mouse down:",W)}},[]),Z=b.useCallback((X,W=!1)=>{try{if(!m)return;const U=X.clientX-w.x,J=X.clientY-w.y;(W?g:f)(ue=>({...ue,x:ue.x+U,y:ue.y+J})),y({x:X.clientX,y:X.clientY})}catch(U){console.error("Error in mouse move:",U)}},[m,w]),j=b.useCallback(()=>{try{v(!1)}catch(X){console.error("Error in mouse up:",X)}},[]),M=b.useCallback((X,W=!1)=>{try{X.preventDefault();const U=X.deltaY>0?.9:1.1;(W?g:f)(he=>({...he,scale:Math.min(Math.max(he.scale*U,.1),5)}))}catch(U){console.error("Error in wheel:",U)}},[]),Y=b.useCallback(X=>{try{d(X)}catch(W){console.error("Error toggling fullscreen:",W)}},[]);if(i)return p.jsxs(N6,{title:"Mermaid diagram error",children:[i,p.jsx("span",{className:G("mt-2 block text-ink-muted"),children:"Chart"}),p.jsx("span",{className:G("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const F=(X=!1)=>{try{const W=X?r:n,U=X?O:h;return p.jsx("div",{ref:W,className:G("mermaid flex w-full items-center justify-center",X?"h-full min-h-full":"h-auto min-h-50",m?"cursor-grabbing":"cursor-grab"),onMouseDown:q,onMouseMove:J=>Z(J,X),onMouseUp:j,onMouseLeave:j,onWheel:J=>M(J,X),children:a?p.jsx("div",{className:G("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?p.jsx("div",{className:G("flex h-full w-full items-center justify-center"),style:{transform:`translate(${U.x}px, ${U.y}px) scale(${U.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(W){return console.error("Error rendering diagram content:",W),p.jsx(N6,{title:"Rendering error",children:"Failed to render diagram content."})}};return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:G("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:[F(!1),p.jsx(MG,{className:"top-2 right-2",copied:T==="copied",onZoomIn:()=>A(!1),onZoomOut:()=>E(!1),onReset:()=>I(!1),onSave:L,onCopy:z,children:p.jsx(vt,{content:"Fullscreen",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>Y(!0),children:p.jsx(sEe,{})})})})]}),p.jsx(AO,{open:u,onClose:()=>Y(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:p.jsxs("div",{className:G("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:[F(!0),p.jsx(MG,{className:"top-4 right-4",copied:k==="copied",onZoomIn:()=>A(!0),onZoomOut:()=>E(!0),onReset:()=>I(!0),onSave:L,onCopy:V,children:p.jsx(vt,{content:"Close fullscreen",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>Y(!1),children:p.jsx(Rs,{})})})})]})})]})}),vWe=b.memo(e=>p.jsx(gWe,{children:p.jsx(mWe,{...e})}));let Pue=!1,jE=null;const wWe=()=>(jE||(jE=Ae(()=>Promise.resolve({}),__vite__mapDeps([4]),import.meta.url).then(e=>(Pue=!0,e))),jE),bWe=/language-(\w+)/,yWe=/\n$/,xWe=/\$(?!\d)(.+?)\$/,SWe=/\$\$([\s\S]+?)\$\$/,$We=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,kWe=/\\[a-zA-Z]+(\{[^}]*\})?/,_ue={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})=>bWe.exec(t??"")?.[1]==="mermaid"?p.jsx(vWe,{chart:String(n).replace(yWe,"")}):p.jsx("code",{className:t,...r,children:n})},TWe=[VC],PWe=[VC,JUe],_We=[],CWe=[mLe],QWe=e=>xWe.test(e)||SWe.test(e)||$We.test(e)?!0:kWe.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),Cue=e=>b.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),Que=e=>{const t=b.useMemo(()=>QWe(e),[e]),[n,r]=b.useState(()=>t&&Pue);return b.useEffect(()=>{if(!t||n)return;let i=!1;return wWe().then(()=>{i||r(!0)}),()=>{i=!0}},[t,n]),{remarkPlugins:n?PWe:TWe,rehypePlugins:n?CWe:_We}},Zg=b.memo(({content:e,styleProps:t,className:n})=>{const r=b.useMemo(()=>e.trim(),[e]),{remarkPlugins:i,rehypePlugins:s}=Que(r),a=Cue(t);return p.jsx("div",{className:G("lo-markdown",n),style:a,children:p.jsx(x7,{remarkPlugins:i,rehypePlugins:s,components:_ue,children:r})})});Zg.displayName="MarkdownRenderer";const Eue=b.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=Que(e);return p.jsx(x7,{remarkPlugins:t,rehypePlugins:n,components:_ue,children:e})});Eue.displayName="StableBlock";const Rue=b.memo(({text:e,animate:t})=>p.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));Rue.displayName="ArrivedText";const Aue=({content:e,styleProps:t,className:n})=>{const r=b.useRef(null);r.current===null&&(r.current=rWe());const i=r.current,s=b.useRef([]),a=b.useRef(0);oWe(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+lWe(e.slice(l)),h=[{offset:l,animate:!1}];for(const O of c){if(O.offset>=d)break;h.push(O)}const f=Cue(t);return p.jsxs("div",{className:G("lo-markdown",n),style:f,children:[i.blocks.map((O,g)=>p.jsx(Eue,{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(Rue,{text:e.slice(O.offset,m),animate:O.animate},O.offset)})})]})};Aue.displayName="StreamingMarkdown";const Of=(e="settings page")=>p.jsx(cQe,{to:"/settings",className:"text-accent underline underline-offset-2",children:e}),zG={"Hosting platform is not configured":p.jsxs("p",{children:["You haven't selected an AI provider yet. Go to the ",Of()," to configure it for all your agents. If you don't have an AI provider, you can sign in to Radient to get access for free to start."]}),"Model name is not configured":p.jsxs("p",{children:["You haven't selected an AI model yet. Go to the ",Of()," to select a model for all your agents. If you don't have an AI provider, you can sign in to Radient to get access for free to start."]}),"Rate limit":p.jsxs("p",{children:["You've hit the rate limit for your AI provider. Please try again later or get Radient Pass in the ",Of()," to access AI models with no rate limits at low prices."]}),"Rate-limit":p.jsxs("p",{children:["You've hit the rate limit for your AI provider. Please try again later or get Radient Pass in the ",Of()," to access all AI models with no rate limits at low prices."]}),"Invalid API key":p.jsxs("p",{children:["Your API key is invalid. Go to the ",Of()," to update your API key."]}),"404 models":p.jsxs("p",{children:["The model you're trying to use is not available. Go to the"," ",Of()," to select a different model, or use Radient to get access to hundreds of models with no rate limits"]}),"Call ListModels":p.jsxs("p",{children:["The model you're trying to use is not available. Go to the"," ",Of()," to select a different model, or use Radient to get access to hundreds of models with no rate limits"]}),"Failed to interpret action":p.jsxs("p",{children:["The model tried to perform an action but was unable to express its intent in the required schema. Typically this happens because the model can't follow the complex instructions required for agentic AI.",p.jsx("br",{}),p.jsx("br",{}),"Change your model in the ",Of()," to fix this. We recommend using Radient Automatic to have the best combo of cheap and smart picked for you based on your requests (typically cheaper than bringing your own key), or use one of the recommended models with a star icon."]})},mb=({error:e})=>{if(!e||e==="[No error output]")return null;const t=e.trim().toLowerCase();let n;for(const r in zG)if(t.includes(r.toLowerCase())){n=zG[r];break}return p.jsxs("div",{className:"mb-4 w-full",children:[p.jsx("span",{className:"mb-1 block text-danger text-meta",children:"Error"}),p.jsx("pre",{className:"flex max-h-[200px] w-full flex-col-reverse overflow-auto whitespace-pre-wrap rounded-sm border border-danger-border bg-danger-wash p-3 font-mono text-danger text-mono-sm",children:e}),n&&p.jsxs("div",{className:"mt-3 flex w-full items-center gap-2 rounded-sm border border-hairline bg-surface p-3",children:[p.jsx(eS,{className:"size-4 shrink-0 text-ink-muted","aria-hidden":!0}),p.jsx("div",{className:"text-body-sm text-ink",children:n})]})]})},Xue=({className:e})=>p.jsx("div",{className:G("flex size-7 shrink-0 items-center justify-center rounded-full bg-sunken text-ink-muted",e),children:p.jsx(sv,{size:16,"aria-label":"Assistant"})}),gP="pl-10",ah=({isUser:e,children:t,isSmallView:n,showAvatar:r,className:i})=>e?p.jsx("div",{className:G("flex w-full justify-end",i),children:t}):p.jsxs("div",{className:G("relative w-full",!n&&gP,i),children:[r&&!n&&p.jsx(Xue,{className:"absolute top-0 left-0"}),t]}),Due=6048e5,EWe=864e5,LG=6e4,Lan=36e5,qan=1e3,qG=525600,UG=43200,WG=1440,GG=Symbol.for("constructDateFrom");function Rh(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&GG in e?e[GG](t):e instanceof Date?new e.constructor(t):new Date(t)}function yl(e,t){return Rh(t||e,e)}let RWe={};function gS(){return RWe}function jy(e,t){const n=gS(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=yl(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 mP(e,t){return jy(e,{...t,weekStartsOn:1})}function Iue(e,t){const n=yl(e,t?.in),r=n.getFullYear(),i=Rh(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=mP(i),a=Rh(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);const o=mP(a);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function vP(e){const t=yl(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 Fue(e,...t){const n=Rh.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function jG(e,t){const n=yl(e,t?.in);return n.setHours(0,0,0,0),n}function AWe(e,t,n){const[r,i]=Fue(n?.in,e,t),s=jG(r),a=jG(i),o=+s-vP(s),l=+a-vP(a);return Math.round((o-l)/EWe)}function XWe(e,t){const n=Iue(e,t),r=Rh(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),mP(r)}function DWe(e,t){const n=+yl(e)-+yl(t);return n<0?-1:n>0?1:n}function IWe(e){return Rh(e,Date.now())}function FWe(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function NWe(e){return!(!FWe(e)&&typeof e!="number"||isNaN(+yl(e)))}function MWe(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function zWe(e,t){const n=yl(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const LWe={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"}},qWe=(e,t,n)=>{let r;const i=LWe[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 VE(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const UWe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},WWe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},GWe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},jWe={date:VE({formats:UWe,defaultWidth:"full"}),time:VE({formats:WWe,defaultWidth:"full"}),dateTime:VE({formats:GWe,defaultWidth:"full"})},VWe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},YWe=(e,t,n,r)=>VWe[e];function Jv(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 BWe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ZWe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},HWe={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"]},KWe={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"]},JWe={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"}},eGe={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"}},tGe=(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"},nGe={ordinalNumber:tGe,era:Jv({values:BWe,defaultWidth:"wide"}),quarter:Jv({values:ZWe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Jv({values:HWe,defaultWidth:"wide"}),day:Jv({values:KWe,defaultWidth:"wide"}),dayPeriod:Jv({values:JWe,defaultWidth:"wide",formattingValues:eGe,defaultFormattingWidth:"wide"})};function ew(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)?iGe(o,d=>d.test(a)):rGe(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 rGe(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function iGe(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function sGe(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 aGe=/^(\d+)(th|st|nd|rd)?/i,oGe=/\d+/i,lGe={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},cGe={any:[/^b/i,/^(a|c)/i]},uGe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},dGe={any:[/1/i,/2/i,/3/i,/4/i]},hGe={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},fGe={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]},OGe={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},pGe={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]},gGe={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},mGe={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}},vGe={ordinalNumber:sGe({matchPattern:aGe,parsePattern:oGe,valueCallback:e=>parseInt(e,10)}),era:ew({matchPatterns:lGe,defaultMatchWidth:"wide",parsePatterns:cGe,defaultParseWidth:"any"}),quarter:ew({matchPatterns:uGe,defaultMatchWidth:"wide",parsePatterns:dGe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ew({matchPatterns:hGe,defaultMatchWidth:"wide",parsePatterns:fGe,defaultParseWidth:"any"}),day:ew({matchPatterns:OGe,defaultMatchWidth:"wide",parsePatterns:pGe,defaultParseWidth:"any"}),dayPeriod:ew({matchPatterns:gGe,defaultMatchWidth:"any",parsePatterns:mGe,defaultParseWidth:"any"})},Nue={code:"en-US",formatDistance:qWe,formatLong:jWe,formatRelative:YWe,localize:nGe,match:vGe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function wGe(e,t){const n=yl(e,t?.in);return AWe(n,zWe(n))+1}function bGe(e,t){const n=yl(e,t?.in),r=+mP(n)-+XWe(n);return Math.round(r/Due)+1}function Mue(e,t){const n=yl(e,t?.in),r=n.getFullYear(),i=gS(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=Rh(t?.in||e,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const o=jy(a,t),l=Rh(t?.in||e,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const c=jy(l,t);return+n>=+o?r+1:+n>=+c?r:r-1}function yGe(e,t){const n=gS(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=Mue(e,t),s=Rh(t?.in||e,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),jy(s,t)}function xGe(e,t){const n=yl(e,t?.in),r=+jy(n,t)-+yGe(n,t);return Math.round(r/Due)+1}function Lr(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const pf={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return Lr(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):Lr(n+1,2)},d(e,t){return Lr(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 Lr(e.getHours()%12||12,t.length)},H(e,t){return Lr(e.getHours(),t.length)},m(e,t){return Lr(e.getMinutes(),t.length)},s(e,t){return Lr(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return Lr(i,t.length)}},Am={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},VG={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 pf.y(e,t)},Y:function(e,t,n,r){const i=Mue(e,r),s=i>0?i:1-i;if(t==="YY"){const a=s%100;return Lr(a,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):Lr(s,t.length)},R:function(e,t){const n=Iue(e);return Lr(n,t.length)},u:function(e,t){const n=e.getFullYear();return Lr(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 Lr(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 Lr(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 pf.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 Lr(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=xGe(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):Lr(i,t.length)},I:function(e,t,n){const r=bGe(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):Lr(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):pf.d(e,t)},D:function(e,t,n){const r=wGe(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Lr(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 Lr(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 Lr(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 Lr(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=Am.noon:r===0?i=Am.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=Am.evening:r>=12?i=Am.afternoon:r>=4?i=Am.morning:i=Am.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 pf.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):pf.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Lr(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):Lr(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):pf.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):pf.s(e,t)},S:function(e,t){return pf.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return BG(r);case"XXXX":case"XX":return wp(r);case"XXXXX":case"XXX":default:return wp(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return BG(r);case"xxxx":case"xx":return wp(r);case"xxxxx":case"xxx":default:return wp(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+YG(r,":");case"OOOO":default:return"GMT"+wp(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+YG(r,":");case"zzzz":default:return"GMT"+wp(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return Lr(r,t.length)},T:function(e,t,n){return Lr(+e,t.length)}};function YG(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+Lr(s,2)}function BG(e,t){return e%60===0?(e>0?"-":"+")+Lr(Math.abs(e)/60,2):wp(e,t)}function wp(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Lr(Math.trunc(r/60),2),s=Lr(r%60,2);return n+i+t+s}const ZG=(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"})}},zue=(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"})}},SGe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return ZG(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}}",ZG(r,t)).replace("{{time}}",zue(i,t))},$Ge={p:zue,P:SGe},kGe=/^D+$/,TGe=/^Y+$/,PGe=["D","DD","YY","YYYY"];function _Ge(e){return kGe.test(e)}function CGe(e){return TGe.test(e)}function QGe(e,t,n){const r=EGe(e,t,n);if(console.warn(r),PGe.includes(e))throw new RangeError(r)}function EGe(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 RGe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,AGe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,XGe=/^'([^]*?)'?$/,DGe=/''/g,IGe=/[a-zA-Z]/;function YE(e,t,n){const r=gS(),i=n?.locale??r.locale??Nue,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=yl(e,n?.in);if(!NWe(o))throw new RangeError("Invalid time value");let l=t.match(AGe).map(u=>{const d=u[0];if(d==="p"||d==="P"){const h=$Ge[d];return h(u,i.formatLong)}return u}).join("").match(RGe).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const d=u[0];if(d==="'")return{isToken:!1,value:FGe(u)};if(VG[d])return{isToken:!0,value:u};if(d.match(IGe))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&&CGe(d)||!n?.useAdditionalDayOfYearTokens&&_Ge(d))&&QGe(d,t,String(e));const h=VG[d[0]];return h(o,d,i.localize,c)}).join("")}function FGe(e){const t=e.match(XGe);return t?t[1].replace(DGe,"'"):e}function NGe(e,t,n){const r=gS(),i=n?.locale??r.locale??Nue,s=DWe(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:s}),[o,l]=Fue(n?.in,...s>0?[t,e]:[e,t]),c=MWe("round"),u=l.getTime()-o.getTime(),d=u/LG,h=vP(l)-vP(o),f=(u-h)/LG,O=n?.unit;let g;if(d<1?g="second":d<60?g="minute":d<WG?g="hour":f<UG?g="day":f<qG?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/WG);return i.formatDistance("xDays",m,a)}else if(g==="month"){const m=c(f/UG);return m===12&&O!=="month"?i.formatDistance("xYears",1,a):i.formatDistance("xMonths",m,a)}else{const m=c(f/qG);return i.formatDistance("xYears",m,a)}}function MGe(e,t){return NGe(e,IWe(e),t)}const zGe=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 YE(t,"h:mm a");if(t.toDateString()===r.toDateString())return"Yesterday";const i=new Date(n);return i.setDate(n.getDate()-7),t>i?YE(t,"EEEE"):YE(t,"yyyy-MM-dd")}catch(t){return console.error("Error formatting date:",t),""}},Uan=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),""}},LGe=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),""}},B7=({timestamp:e,className:t})=>p.jsx(vt,{content:LGe(e),side:"bottom",delayDuration:1200,children:p.jsx("span",{className:G("shrink-0 cursor-help whitespace-nowrap text-ink-dim text-meta",t),children:zGe(e)})}),vb=({output:e})=>e?p.jsxs("div",{className:"mb-4 w-full",children:[p.jsx("span",{className:"mb-1 block text-ink-dim text-meta",children:"Output"}),p.jsx("pre",{className:"flex max-h-[300px] w-full flex-col-reverse overflow-auto rounded-sm border border-hairline bg-sunken p-3 font-mono text-ink text-mono-sm",children:e})]}):null,Lue=({content:e,className:t})=>e?p.jsxs("section",{"aria-label":"Question from the agent",className:G("flex gap-3 rounded-md border border-accent bg-accent-wash px-4 py-3",t),children:[p.jsx(cEe,{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:"Waiting for your answer"}),p.jsx("div",{className:"lo-on-wash text-ink",children:p.jsx(Zg,{content:e})})]})]}):null,qGe="ml-5",HG="flex min-h-6 w-full items-center gap-1.5 py-0.5 text-left",mg=({summary:e,children:t,defaultOpen:n=!1,chevron:r="leading",className:i,triggerClassName:s,rowClassName:a,disabled:o=!1})=>{const[l,c]=b.useState(n),u=b.useId();if(o)return p.jsx("div",{className:i,children:p.jsxs("div",{className:G(HG,"text-ink-dim",a),children:[r==="leading"&&p.jsx("span",{className:"size-3.5 shrink-0","aria-hidden":!0}),p.jsx("span",{className:"min-w-0 flex-1",children:e})]})});const d=l?p.jsx(o1,{className:"size-3.5","aria-hidden":!0}):p.jsx(og,{className:"size-3.5","aria-hidden":!0});return p.jsxs("div",{className:i,children:[p.jsxs("button",{type:"button","aria-expanded":l,"aria-controls":u,onClick:()=>c(h=>!h),className:G(HG,"cursor-pointer select-none","text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink-muted",a,s),children:[r==="leading"&&p.jsx("span",{className:"flex shrink-0 text-ink-disabled",children:d}),p.jsx("span",{className:"min-w-0 flex-1",children:e}),r==="trailing"&&p.jsx("span",{className:"flex shrink-0 text-ink-disabled",children:d})]}),l&&p.jsx("div",{id:u,className:G("mt-1 flex flex-col gap-2 pb-1",r==="leading"&&qGe),children:t})]})},que=({children:e,className:t})=>p.jsx("span",{"aria-hidden":!0,className:G("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),Z7=({label:e="Reasoning",content:t})=>!Gr(r=>r.showAgentReasoning)||!t?null:p.jsx(mg,{summary:p.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p.jsx(que,{}),p.jsx("span",{className:"truncate",children:p.jsx("span",{className:"text-ink-dim text-meta",children:e})})]}),children:p.jsx(Zg,{content:t,className:"[--md-ink:var(--lo-ink-muted)]",styleProps:{fontSize:"var(--text-body-sm)",lineHeight:"var(--text-body-sm--line-height)"}})}),UGe={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},WGe=({line:e})=>p.jsx("span",{className:G(UGe[e.kind],"block"),children:e.text}),GGe=({diff:e,className:t})=>{const n=CDe(e);return p.jsxs("div",{className:G("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(WGe,{line:r},i)),n.hidden>0&&p.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:QDe(n.hidden)})]})},jGe=({content:e,details:t,className:n})=>p.jsxs("section",{"aria-label":"Security notice",className:G("flex gap-3 border-warning border-l-2 py-0.5 pl-3",n),children:[p.jsx(dRe,{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(mg,{summary:p.jsx("span",{className:"text-meta",children:"Show the reviewed code"}),children:t}):null]})]}),VGe=(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()},KG=e=>e.startsWith("file://")?e.slice(7):e,YGe={READ:{verb:"Read",runningVerb:"Reading",icon:S8},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:Q8},EDIT:{verb:"Edited",runningVerb:"Editing",icon:REe},CODE:{verb:"Ran code",runningVerb:"Running code",icon:k8},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:cRe},DONE:{verb:"Finished",runningVerb:"Finishing",icon:ZF},ASK:{verb:"Asked",runningVerb:"Asking",icon:$8},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:HQe}},BGe={verb:"Worked on the request",runningVerb:"Working on the request",icon:k8},ZGe=(e,t,n,r)=>{const i=e?YGe[e]:BGe;let s;if(t)s=KG(t);else if(n&&n.length>0){const o=n.filter(l=>!l.startsWith("data:"));o.length===1?s=KG(o[0]):o.length>1&&(s=`${o.length} files`)}const a=!s&&r?VGe(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:s,narration:a||void 0,icon:i.icon}},JG="min-h-5 py-0",HGe=({icon:e,verb:t,object:n,narration:r,running:i,failed:s,wrap:a})=>p.jsxs("span",{className:"flex min-w-0 items-center gap-2","aria-busy":i||void 0,children:[p.jsx(que,{className:s?"text-danger":"text-ink-dim",children:e}),p.jsxs("span",{className:G(a?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[p.jsxs("span",{className:G("font-mono text-mono-sm",i?"text-ink-muted":"text-ink-dim",s&&"text-danger"),children:[t,r?":":null]}),n?p.jsxs("span",{className:"font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?p.jsxs("span",{className:"text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),H7=({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=ZGe(e,t,n,r),g=c??(i?O.runningVerb:O.verb),m=s?tS:O.icon,v=s||!c||!d?p.jsx(m,{}):d,w=p.jsx(HGe,{icon:v,verb:g,object:c?u:O.object,narration:c?r:O.narration,running:i,failed:s,wrap:h});return o?p.jsx(mg,{summary:w,chevron:"leading",defaultOpen:a,className:l,rowClassName:f?JG:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:o}):p.jsx(mg,{disabled:!0,summary:w,className:l,rowClassName:f?JG:void 0})},KGe="mcp__",JGe={bash:IRe,read:sO,write:Tq,edit:Tq,glob:by,grep:yC,todo:Z5e,wake:vC,list_variables:W2,read_variable:W2,browser:Cq,web_search:Cq,web_fetch:iO,task:gh,agent:gh,send:R8,peer:M5e};function eje(e){const t=e.trim().toLowerCase(),n=JGe[t];return n||(t.startsWith(KGe)?cae:n2e)}const tje=uc,nje=Rs,rje=Hse,ej="min-h-5 py-0",ije={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent",plain:"text-ink-muted"},sje=({added:e,removed:t})=>e<=0&&t<=0?null:p.jsxs("span",{className:G("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&p.jsxs("span",{className:G("text-success"),children:["+",e]}),t>0&&p.jsxs("span",{className:G("text-danger"),children:["-",t]})]}),tj={running:"",success:"succeeded",error:"failed",interrupted:"interrupted"},aje=1e3;function oje(e){const[t,n]=b.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return b.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,aje);return()=>window.clearInterval(i)},[e]),t}const lje=({outcome:e,durationS:t,startedAt:n})=>{const r=e==="running",i=oje(r?n??null:null),s=e==="success"?tje:e==="error"?nje:e==="interrupted"?rje:null,a=e==="success"?"text-success":e==="error"?"text-danger":"text-ink-dim",o=r?n==null?"":n7(i??0):pDe(t);return p.jsxs("span",{className:G("flex shrink-0 items-center gap-1.5"),children:[p.jsxs("span",{className:G("flex size-3.5 shrink-0 [&_svg]:size-3.5",a),children:[s?p.jsx(s,{"aria-hidden":!0}):null,tj[e]?p.jsx("span",{className:G("sr-only"),children:tj[e]}):null]}),p.jsx("span",{className:G("w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums"),children:o})]})},cje=({toolName:e,summary:t,summaryFallback:n=null,outcome:r,durationS:i,startedAt:s=null,added:a=0,removed:o=0,nameColumn:l=woe,details:c,defaultOpen:u=!1,className:d,media:h})=>{const f=r==="running",O=r==="error",g=eje(e),m=tP(e),v=p.jsxs("span",{className:G("flex min-w-0 flex-1 items-center gap-2"),children:[p.jsx("span",{"aria-hidden":!0,className:G("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:G("shrink-0 truncate font-mono text-mono-sm","pr-1",f?"text-ink":O?"text-danger":ije[vDe(e)]),style:{width:`calc(${l}ch + 0.25rem)`},title:m,children:m}),p.jsx("span",{className:G("min-w-0 flex-1 truncate font-mono text-mono-sm",f?"text-ink-muted":"text-ink-dim"),children:voe(t,e)?n??"":t}),p.jsx(sje,{added:a,removed:o}),p.jsx(lje,{outcome:r,durationS:i,startedAt:s})]}),w=f?"bg-elevated":O?"bg-danger-wash":"hover:bg-elevated",y=c?p.jsx(mg,{summary:v,chevron:"leading",defaultOpen:u,className:G("@container/toolrow",d),rowClassName:ej,triggerClassName:G("-mx-2 rounded-sm px-2",w),children:c}):p.jsx(mg,{disabled:!0,summary:v,rowClassName:ej,className:G("@container/toolrow",(f||O)&&G("-mx-2 rounded-sm px-2",w),d)});return h?p.jsxs("div",{className:G("flex flex-col"),children:[y,h]}):y},Uue=e=>{const t=b.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=b.useCallback(()=>window.matchMedia(e).matches,[e]);return b.useSyncExternalStore(t,n,()=>!1)},nj=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],uje=80,dje=1e3,hje=({activity:e,phase:t,className:n})=>{const[r,i]=b.useState(0),[s,a]=b.useState(0),o=Uue("(prefers-reduced-motion: reduce)"),l=b.useRef(Date.now()),c=b.useRef(t);return c.current!==t&&(c.current=t,l.current=Date.now(),a(0)),b.useEffect(()=>{const u=window.setInterval(()=>a(Math.floor((Date.now()-l.current)/1e3)),dje);if(o)return i(0),()=>window.clearInterval(u);const d=window.setInterval(()=>i(h=>(h+1)%nj.length),uje);return()=>{window.clearInterval(d),window.clearInterval(u)}},[o]),p.jsxs("div",{className:G("flex items-center gap-2",n),"data-lo-working-line":!0,"aria-live":"polite",children:[p.jsx("span",{"aria-hidden":!0,className:G("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:nj[r]}),p.jsx("span",{className:G("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),p.jsx("span",{"aria-hidden":!0,className:G("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:n7(s)})]})},Wue=({children:e,className:t})=>p.jsx("div",{className:G("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}),K7=({name:e,className:t})=>p.jsxs("div",{className:G("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",t),children:[p.jsx(I5e,{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})," could not be displayed. It may have been moved, renamed, or deleted."]})]}),YC=({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),os("File path copied to clipboard")}catch(o){console.error("Failed to copy file path: ",o),tr("Failed to copy file path")}},a=()=>{e&&window.api.openFile(e)};return p.jsxs(nS,{children:[p.jsx(vt,{content:t,children:p.jsx(l1,{asChild:!0,children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":r,onClick:o=>o.stopPropagation(),children:n??p.jsx(T8,{"aria-hidden":"true"})})})}),p.jsxs(rS,{align:"end",className:"min-w-45",onClick:o=>o.stopPropagation(),children:[i&&p.jsxs(ts,{onSelect:i,children:[p.jsx(j5e,{"aria-hidden":"true"}),p.jsx("span",{children:"Show in canvas"})]}),p.jsxs(ts,{onSelect:a,children:[p.jsx(av,{"aria-hidden":"true"}),p.jsx("span",{children:"Open file"})]}),p.jsxs(ts,{onSelect:()=>window.api.showItemInFolder(e),children:[p.jsx(by,{"aria-hidden":"true"}),p.jsx("span",{children:"Open folder"})]}),p.jsxs(ts,{onSelect:s,children:[p.jsx(Kse,{"aria-hidden":"true"}),p.jsx("span",{children:"Copy file path"})]})]})]})},uo=e=>{if(e.startsWith("data:image/"))return"image";if(e.startsWith("data:video/"))return"video";if(e.startsWith("data:application/pdf"))return"pdf";const t=e.split(".").pop()?.toLowerCase();return t?["png","jpg","jpeg","gif","bmp","webp","svg"].includes(t)?"image":["mp4","webm","ogg","mov","avi","mkv"].includes(t)?"video":["pdf"].includes(t)?"pdf":["md","markdown"].includes(t)?"markdown":["html","htm"].includes(t)?"html":["zip","tar","gz","rar","7z"].includes(t)?"archive":["txt","log"].includes(t)?"text":["js","ts","jsx","tsx","py","java","c","cpp","cs","go","rb","php","sh","css","scss","less","json","xml","yaml","yml"].includes(t)?"code":["doc","docx","odt"].includes(t)?"document":["xls","xlsx","ods","csv","tsv"].includes(t)?"spreadsheet":["ppt","pptx","odp"].includes(t)?"presentation":["mp3","wav","aac","flac"].includes(t)?"audio":"other":"other"},Gue=1024;let fje=0,Hl=class{constructor(t,n){this.from=t,this.to=n}};class Pn{constructor(t={}){this.id=fje++,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=$s.match(t)),n=>{let r=t(n);return r===void 0?null:[this,r]}}}Pn.closedBy=new Pn({deserialize:e=>e.split(" ")});Pn.openedBy=new Pn({deserialize:e=>e.split(" ")});Pn.group=new Pn({deserialize:e=>e.split(" ")});Pn.isolate=new Pn({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});Pn.contextHash=new Pn({perNode:!0});Pn.lookAhead=new Pn({perNode:!0});Pn.mounted=new Pn({perNode:!0});class Vy{constructor(t,n,r){this.tree=t,this.overlay=n,this.parser=r}static get(t){return t&&t.props&&t.props[Pn.mounted.id]}}const Oje=Object.create(null);class $s{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):Oje,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new $s(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(Pn.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(Pn.group),s=-1;s<(i?i.length:0);s++){let a=n[s<0?r.name:i[s]];if(a)return a}}}}$s.none=new $s("",Object.create(null),0,8);class mv{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 $s(r.name,i,r.id,r.flags):r)}return new mv(n)}}const F$=new WeakMap,rj=new WeakMap;var ni;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"})(ni||(ni={}));class cr{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=Vy.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 wP(this.topNode,t)}cursorAt(t,n=0,r=0){let i=F$.get(this)||this.topNode,s=new wP(i);return s.moveTo(t,n),F$.set(this,s._tree),s}get topNode(){return new za(this,0,0,null)}resolve(t,n=0){let r=Yy(F$.get(this)||this.topNode,t,n,!1);return F$.set(this,r),r}resolveInner(t,n=0){let r=Yy(rj.get(this)||this.topNode,t,n,!0);return rj.set(this,r),r}resolveStack(t,n=0){return mje(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:s=this.length}=t,a=t.mode||0,o=(a&ni.IncludeAnonymous)>0;for(let l=this.cursor(a|ni.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:tN($s.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new cr(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new cr($s.none,n,r,i)))}static build(t){return vje(t)}}cr.empty=new cr($s.none,[],[],0);class J7{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 J7(this.buffer,this.index)}}class gO{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return $s.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&&!(jue(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 gO(s,a,this.set)}}function jue(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 Yy(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 za&&e.index<0?null:e.parent;if(!a)return e;e=a}let s=r?0:ni.IgnoreOverlays;if(r)for(let a=e,o=a.parent;o;a=o,o=a.parent)a instanceof za&&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 Vue{cursor(t=0){return new wP(this,t)}getChild(t,n=null,r=null){let i=ij(this,t,n,r);return i.length?i[0]:null}getChildren(t,n=null,r=null){return ij(this,t,n,r)}resolve(t,n=0){return Yy(this,t,n,!1)}resolveInner(t,n=0){return Yy(this,t,n,!0)}matchContext(t){return M6(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 za extends Vue{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(jue(i,r,d,d+u.length)){if(u instanceof gO){if(s&ni.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,n,r-d,i);if(h>-1)return new ju(new pje(a,u,t,d),null,h)}else if(s&ni.IncludeAnonymous||!u.type.isAnonymous||eN(u)){let h;if(!(s&ni.IgnoreMounts)&&(h=Vy.get(u))&&!h.overlay)return new za(h.tree,d,t,a);let f=new za(u,d,t,a);return s&ni.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(n<0?u.children.length-1:0,n,r,i)}}}if(s&ni.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&ni.IgnoreOverlays)&&(i=Vy.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 za(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 ij(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 M6(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 pje{constructor(t,n,r,i){this.parent=t,this.buffer=n,this.index=r,this.start=i}}class ju extends Vue{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 ju(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&ni.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 ju(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 ju(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 ju(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 cr(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Yue(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 za&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new gje(i,n)}class gje{constructor(t,n){this.heads=t,this.node=n}get next(){return Yue(this.heads)}}function mje(e,t,n){let r=e.resolveInner(t,n),i=null;for(let s=r instanceof za?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=Vy.get(s.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new za(a.tree,a.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Yy(o,t,n,!1))}}return i?Yue(i):r}class wP{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 za)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 za?(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&ni.ExcludeBuffers?!1:this.enterChild(1,t,n):this.yield(this._tree.enter(t,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ni.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&ni.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&ni.IncludeAnonymous||o instanceof gO||!o.type.isAnonymous||eN(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 ju(this.buffer,n,this.stack[i]);return this.bufferNode=new ju(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 M6(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 M6(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 eN(e){return e.children.some(t=>t instanceof gO||!t.type.isAnonymous||eN(t))}function vje(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=Gue,reused:s=[],minRepeatType:a=r.types.length}=e,o=Array.isArray(n)?new J7(n,n.length):n,l=r.types,c=0,u=0;function d(x,k,S,Q,R,_){let{id:A,start:E,end:I,size:L}=o,z=u,V=c;for(;L<0;)if(o.next(),L==-1){let Y=s[A];S.push(Y),Q.push(E-x);return}else if(L==-3){c=A;return}else if(L==-4){u=A;return}else throw new RangeError(`Unrecognized record size: ${L}`);let q=l[A],Z,j,M=E-x;if(I-E<=i&&(j=m(o.pos-k,R))){let Y=new Uint16Array(j.size-j.skip),F=o.pos-j.size,X=Y.length;for(;o.pos>F;)X=v(j.start,Y,X);Z=new gO(Y,I-j.start,r),M=j.start-x}else{let Y=o.pos-L;o.next();let F=[],X=[],W=A>=a?A:-1,U=0,J=I;for(;o.pos>Y;)W>=0&&o.id==W&&o.size>=0?(o.end<=J-i&&(O(F,X,E,U,o.end,J,W,z,V),U=F.length,J=o.end),o.next()):_>2500?h(E,Y,F,X):d(E,Y,F,X,W,_+1);if(W>=0&&U>0&&U<F.length&&O(F,X,E,U,E,J,W,z,V),F.reverse(),X.reverse(),W>-1&&U>0){let he=f(q,V);Z=tN(q,F,X,0,F.length,0,I-E,he,he)}else Z=g(q,F,X,I-E,z-I,V)}S.push(Z),Q.push(M)}function h(x,k,S,Q){let R=[],_=0,A=-1;for(;o.pos>k;){let{id:E,start:I,end:L,size:z}=o;if(z>4)o.next();else{if(A>-1&&I<A)break;A<0&&(A=L-i),R.push(E,I,L),_++,o.next()}}if(_){let E=new Uint16Array(_*4),I=R[R.length-2];for(let L=R.length-3,z=0;L>=0;L-=3)E[z++]=R[L],E[z++]=R[L+1]-I,E[z++]=R[L+2]-I,E[z++]=z;S.push(new gO(E,R[2]-I,r)),Q.push(I-x)}}function f(x,k){return(S,Q,R)=>{let _=0,A=S.length-1,E,I;if(A>=0&&(E=S[A])instanceof cr){if(!A&&E.type==x&&E.length==R)return E;(I=E.prop(Pn.lookAhead))&&(_=Q[A]+E.length+I)}return g(x,S,Q,R,_,k)}}function O(x,k,S,Q,R,_,A,E,I){let L=[],z=[];for(;x.length>Q;)L.push(x.pop()),z.push(k.pop()+S-R);x.push(g(r.types[A],L,z,_-R,E-_,I)),k.push(R-S)}function g(x,k,S,Q,R,_,A){if(_){let E=[Pn.contextHash,_];A=A?[E].concat(A):[E]}if(R>25){let E=[Pn.lookAhead,R];A=A?[E].concat(A):[E]}return new cr(x,k,S,Q,A)}function m(x,k){let S=o.fork(),Q=0,R=0,_=0,A=S.end-i,E={size:0,start:0,skip:0};e:for(let I=S.pos-x;S.pos>I;){let L=S.size;if(S.id==k&&L>=0){E.size=Q,E.start=R,E.skip=_,_+=4,Q+=4,S.next();continue}let z=S.pos-L;if(L<0||z<I||S.start<A)break;let V=S.id>=a?4:0,q=S.start;for(S.next();S.pos>z;){if(S.size<0)if(S.size==-3)V+=4;else break e;else S.id>=a&&(V+=4);S.next()}R=q,Q+=L,_+=V}return(k<0||Q==x)&&(E.size=Q,E.start=R,E.skip=_),E.size>4?E:void 0}function v(x,k,S){let{id:Q,start:R,end:_,size:A}=o;if(o.next(),A>=0&&Q<a){let E=S;if(A>4){let I=o.pos-(A-4);for(;o.pos>I;)S=v(x,k,S)}k[--S]=E,k[--S]=_-x,k[--S]=R-x,k[--S]=Q}else A==-3?c=Q:A==-4&&(u=Q);return S}let w=[],y=[];for(;o.pos>0;)d(e.start||0,e.bufferStart||0,w,y,-1,0);let T=(t=e.length)!==null&&t!==void 0?t:w.length?y[0]+w[0].length:0;return new cr(l[e.topID],w.reverse(),y.reverse(),T)}const sj=new WeakMap;function MT(e,t){if(!e.isAnonymous||t instanceof gO||t.type!=e)return 1;let n=sj.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof cr)){n=1;break}n+=MT(e,r)}sj.set(t,n)}return n}function tN(e,t,n,r,i,s,a,o,l){let c=0;for(let O=r;O<i;O++)c+=MT(e,t[O]);let u=Math.ceil(c*1.5/8),d=[],h=[];function f(O,g,m,v,w){for(let y=m;y<v;){let T=y,x=g[y],k=MT(e,O[y]);for(y++;y<v;y++){let S=MT(e,O[y]);if(k+S>=u)break;k+=S}if(y==T+1){if(k>u){let S=O[T];f(S.children,S.positions,0,S.children.length,g[T]+w);continue}d.push(O[T])}else{let S=g[y-1]+O[y-1].length-x;d.push(tN(e,O,g,T,y,x,S,null,l))}h.push(x+w-s)}}return f(t,n,r,i,0),(o||l)(d,h,a)}class nN{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 ju?this.setBuffer(t.context.buffer,t.index,n):t instanceof za&&this.map.set(t.tree,n)}get(t){return t instanceof ju?this.getBuffer(t.context.buffer,t.index):t instanceof za?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 wh{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 wh(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 wh(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 BC=class{startParse(t,n,r){return typeof t=="string"&&(t=new wje(t)),r=r?r.length?r.map(i=>new Hl(i.from,i.to)):[new Hl(0,0)]:[new Hl(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 wje{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 gc(e){return(t,n,r,i)=>new yje(t,e,n,r,i)}class aj{constructor(t,n,r,i,s){this.parser=t,this.parse=n,this.overlay=r,this.target=i,this.from=s}}function oj(e){if(!e.length||e.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class bje{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 z6=new Pn({perNode:!0});class yje{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 cr(r.type,r.children,r.positions,r.length,r.propValues.concat([[z6,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[Pn.mounted.id]=new Vy(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 $je(this.fragments),n=null,r=null,i=new wP(new za(this.baseTree,this.ranges[0].from,0,null),ni.IncludeAnonymous|ni.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=xje(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||Sje(i);let c=t.findMounts(i.from,s.parser);if(typeof s.overlay=="function")n=new bje(s.parser,s.overlay,c,this.inner.length,i.from,i.tree,n);else{let u=uj(this.ranges,s.overlay||(i.from<i.to?[new Hl(i.from,i.to)]:[]));u.length&&oj(u),(u.length||!s.overlay)&&this.inner.push(new aj(s.parser,u.length?s.parser.startParse(this.input,dj(c,u),u):s.parser.startParse(""),s.overlay?s.overlay.map(d=>new Hl(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 Hl(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=uj(this.ranges,n.ranges);c.length&&(oj(c),this.inner.splice(n.index,0,new aj(n.parser,n.parser.startParse(this.input,dj(n.mounts,c),c),n.ranges.map(u=>new Hl(u.from-n.start,u.to-n.start)),n.target,c[0].from))),n=n.prev}r&&!--r.depth&&(r=r.prev)}}}}function xje(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 lj(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 Sje(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=[],w=[];lj(a,u,m,v,w,f);let y=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]],y,T-y,g-1):t.toTree();return v.push(x),w.push(y-f),lj(a,o[m+3],d,v,w,f),new cr(h,v,w,O)}i.children[s]=c(0,o.length,$s.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 za(d,h+e.from,u,e._tree))}}class cj{constructor(t,n){this.offset=n,this.done=!1,this.cursor=t.cursor(ni.IncludeAnonymous|ni.IgnoreMounts)}moveTo(t){let{cursor:n}=this,r=t-this.offset;for(;!this.done&&n.from<r;)n.to>=t&&n.enter(r,1,ni.IgnoreOverlays|ni.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 cr)n=n.children[0];else break}return!1}}let $je=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(z6))!==null&&n!==void 0?n:r.to,this.inner=new cj(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(z6))!==null&&t!==void 0?t:n.to,this.inner=new cj(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(Pn.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 uj(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 Hl(l.from,a),l.to>o&&n.splice(s+1,0,new Hl(o,l.to))):l.to>o?n[s--]=new Hl(o,l.to):n.splice(s--,1))}}return r}function kje(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 Hl(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 dj(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 Hl(h.from+r,h.to+r)),d=kje(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 wh(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 wh(l,c,i.tree,-a,s.from>=a||s.openStart,s.to<=o||s.openEnd))}return n}let L6=[],Bue=[];(()=>{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?Bue:L6).push(n=n+e[t])})();function Tje(e){if(e<768)return!1;for(let t=0,n=L6.length;;){let r=t+n>>1;if(e<L6[r])n=r;else if(e>=Bue[r])t=r+1;else return!0;if(t==n)return!1}}function hj(e){return e>=127462&&e<=127487}const fj=8205;function Pje(e,t,n=!0,r=!0){return(n?Zue:_je)(e,t,r)}function Zue(e,t,n){if(t==e.length)return t;t&&Hue(e.charCodeAt(t))&&Kue(e.charCodeAt(t-1))&&t--;let r=BE(e,t);for(t+=Oj(r);t<e.length;){let i=BE(e,t);if(r==fj||i==fj||n&&Tje(i))t+=Oj(i),r=i;else if(hj(i)){let s=0,a=t-2;for(;a>=0&&hj(BE(e,a));)s++,a-=2;if(s%2==0)break;t+=2}else break}return t}function _je(e,t,n){for(;t>0;){let r=Zue(e,t-2,n);if(r<t)return r;t--}return 0}function BE(e,t){let n=e.charCodeAt(t);if(!Kue(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Hue(r)?(n-55296<<10)+(r-56320)+65536:n}function Hue(e){return e>=56320&&e<57344}function Kue(e){return e>=55296&&e<56320}function Oj(e){return e<65536?1:2}let Tr=class Jue{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]=$1(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),Nu.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]=$1(this,t,n);let r=[];return this.decompose(t,n,r,0),Nu.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 wb(this),s=new wb(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 wb(this,t)}iterRange(t,n=this.length){return new ede(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 tde(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]?Jue.empty:t.length<=32?new es(t):Nu.from(es.split(t,[]))}};class es extends Tr{constructor(t,n=Cje(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 Qje(i,o,r,a);i=o+1,r++}}decompose(t,n,r,i){let s=t<=0&&n>=this.length?this:new es(pj(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let a=r.pop(),o=zT(s.text,a.text.slice(),0,s.length);if(o.length<=32)r.push(new es(o,a.length+s.length));else{let l=o.length>>1;r.push(new es(o.slice(0,l)),new es(o.slice(l)))}}else r.push(s)}replace(t,n,r){if(!(r instanceof es))return super.replace(t,n,r);[t,n]=$1(this,t,n);let i=zT(this.text,zT(r.text,pj(this.text,0,t)),n),s=this.length+r.length-(n-t);return i.length<=32?new es(i,s):Nu.from(es.split(i,[]),s)}sliceString(t,n=this.length,r=`
|
|
1067
1067
|
`){[t,n]=$1(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 es(r,i)),r=[],i=-1);return i>-1&&n.push(new es(r,i)),n}}class Nu extends Tr{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]=$1(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 Nu(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=`
|
|
1068
1068
|
`){[t,n]=$1(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 Nu))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 es(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 Nu)for(let g of f.children)d(g);else f.lines>a&&(l>a||!l)?(h(),o.push(f)):f instanceof es&&l&&(O=u[u.length-1])instanceof es&&f.lines+O.lines<=32?(l+=f.lines,c+=f.length+1,u[u.length-1]=new es(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]:Nu.from(u,c)),c=-1,l=u.length=0)}for(let f of t)d(f);return h(),o.length==1?o[0]:new Nu(o,n)}}Tr.empty=new es([""],0);function Cje(e){let t=-1;for(let n of e)t+=n.length+1;return t}function zT(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 pj(e,t,n){return zT(e,[""],t,n)}class wb{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 es?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 es?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=`
|
|
1069
1069
|
`,this;t--}else if(i instanceof es){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 es?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 ede{constructor(t,n,r){this.value="",this.done=!1,this.cursor=new wb(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 tde{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"&&(Tr.prototype[Symbol.iterator]=function(){return this.iter()},wb.prototype[Symbol.iterator]=ede.prototype[Symbol.iterator]=tde.prototype[Symbol.iterator]=function(){return this});let Qje=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 $1(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function pa(e,t,n=!0,r=!0){return Pje(e,t,n,r)}function Eje(e){return e>=56320&&e<57344}function Rje(e){return e>=55296&&e<56320}function Eo(e,t){let n=e.charCodeAt(t);if(!Rje(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Eje(r)?(n-55296<<10)+(r-56320)+65536:n}function rN(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function Mu(e){return e<65536?1:2}const q6=/\r\n?|\n/;var fa=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(fa||(fa={}));class id{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){U6(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 id(t)}composeDesc(t){return this.empty?t:t.empty?this:nde(this,t)}mapDesc(t,n=!1){return t.empty?this:W6(this,t,n)}mapPos(t,n=-1,r=fa.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!=fa.Simple&&c>=t&&(r==fa.TrackDel&&i<t&&c>t||r==fa.TrackBefore&&i<t||r==fa.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 id(t)}static create(t){return new id(t)}}class Cs extends id{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 U6(this,(n,r,i,s,a)=>t=t.replace(i,i+(r-n),a),!1),t}mapDesc(t,n=!1){return W6(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(Tr.empty);r.push(a?t.slice(s,s+a):Tr.empty)}s+=a}return new Cs(n,r)}compose(t){return this.empty?t:t.empty?this:nde(this,t,!0)}map(t,n=!1){return t.empty?this:W6(this,t,n,!0)}iterChanges(t,n=!1){U6(this,t,n)}get desc(){return id.create(this.sections)}filter(t){let n=[],r=[],i=[],s=new By(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);Ea(i,u,-1);let d=s.ins==-1?-1:s.off==0?s.ins:0;Ea(n,u,d),d>0&&qf(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);Ea(n,u,-1),Ea(i,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),o+=u}}return{changes:new Cs(n,r),filtered:id.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&&Ea(i,n-a,-1);let d=new Cs(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 Cs){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"?Tr.of(f.split(r||q6)):f:Tr.empty,g=O.length;if(d==h&&g==0)return;d<a&&l(),d>a&&Ea(i,d-a,-1),Ea(i,h-d,g),qf(s,i,O),a=h}}return c(t),l(!o),o}static empty(t){return new Cs(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(Tr.empty);r[i]=Tr.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new Cs(n,r)}static createSet(t,n){return new Cs(t,n)}}function Ea(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 qf(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(Tr.empty);e.push(n)}}function U6(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=Tr.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 W6(e,t,n,r=!1){let i=[],s=r?[]:null,a=new By(e),o=new By(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);Ea(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(Ea(i,o.ins,-1);c;){let u=Math.min(a.len,c);a.ins>=0&&l<a.i&&a.len<=u&&(Ea(i,0,a.ins),s&&qf(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;Ea(i,c,l<a.i?a.ins:0),s&&l<a.i&&qf(s,i,a.text),l=a.i,a.forward(a.len-u)}else{if(a.done&&o.done)return s?Cs.createSet(i,s):id.create(i);throw new Error("Mismatched change set lengths")}}}function nde(e,t,n=!1){let r=[],i=n?[]:null,s=new By(e),a=new By(t);for(let o=!1;;){if(s.done&&a.done)return i?Cs.createSet(r,i):id.create(r);if(s.ins==0)Ea(r,s.len,0,o),s.next();else if(a.len==0&&!a.done)Ea(r,0,a.ins,o),i&&qf(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;Ea(r,l,u,o),i&&u&&qf(i,r,a.text)}else a.ins==-1?(Ea(r,s.off?0:s.len,l,o),i&&qf(i,r,s.textBit(l))):(Ea(r,s.off?0:s.len,a.off?0:a.ins,o),i&&!a.off&&qf(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 By{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?Tr.empty:t[n]}textBit(t){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!t?Tr.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 Xp{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 Xp(r,i,this.flags)}extend(t,n=t){if(t<=this.anchor&&n>=this.anchor)return qe.range(t,n);let r=Math.abs(t-this.anchor)>Math.abs(n-this.anchor)?t:n;return qe.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 qe.range(t.anchor,t.head)}static create(t,n,r){return new Xp(t,n,r)}}class qe{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:qe.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 qe([this.main],0)}addRange(t,n=!0){return qe.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,qe.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 qe(t.ranges.map(n=>Xp.fromJSON(n)),t.main)}static single(t,n=t){return new qe([qe.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 qe.normalized(t.slice(),n);r=s.to}return new qe(t,n)}static cursor(t,n=0,r,i){return Xp.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?Xp.create(n,t,48|s):Xp.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?qe.range(l,o):qe.range(o,l))}}return new qe(t,n)}}function rde(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let iN=0;class Lt{constructor(t,n,r,i,s){this.combine=t,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=iN++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new Lt(t.combine||(n=>n),t.compareInput||((n,r)=>n===r),t.compare||(t.combine?(n,r)=>n===r:sN),!!t.static,t.enables)}of(t){return new LT([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new LT(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new LT(t,this,2,n)}from(t,n){return n||(n=r=>r),this.compute([t],r=>n(r.field(t)))}}function sN(e,t){return e==t||e.length==t.length&&e.every((n,r)=>n===t[r])}class LT{constructor(t,n,r,i){this.dependencies=t,this.facet=n,this.type=r,this.value=i,this.id=iN++}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)||G6(d,u)){let f=r(d);if(o?!gj(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=yP(h,O);if(this.dependencies.every(m=>m instanceof Lt?h.facet(m)===d.facet(m):m instanceof ea?h.field(m,!1)==d.field(m,!1):!0)||(o?gj(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 gj(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 G6(e,t){let n=!1;for(let r of t)bb(e,r)&1&&(n=!0);return n}function Aje(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=yP(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)bb(l,c);return l.values[a]=o(l),1},update(l,c){if(!G6(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=G6(l,r),d=c.config.facets[t.id],h=c.facet(t);if(d&&!u&&sN(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 N$=Lt.define({static:!0});class ea{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 ea(iN++,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(N$).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(N$),a=i.facet(N$),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,N$.of({field:this,create:t})]}get extension(){return this}}const Pp={lowest:4,low:3,default:2,high:1,highest:0};function tw(e){return t=>new ide(t,e)}const Yh={highest:tw(Pp.highest),high:tw(Pp.high),default:tw(Pp.default),low:tw(Pp.low),lowest:tw(Pp.lowest)};class ide{constructor(t,n){this.inner=t,this.prec=n}}class ZC{of(t){return new j6(this,t)}reconfigure(t){return ZC.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class j6{constructor(t,n){this.compartment=t,this.inner=n}}class bP{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 Xje(t,n,a))h instanceof ea?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,sN(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=>Aje(m,O,f))}}let d=c.map(h=>h(o));return new bP(t,a,d,o,l,s)}}function Xje(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 j6&&n.delete(a.compartment)}if(i.set(a,o),Array.isArray(a))for(let c of a)s(c,o);else if(a instanceof j6){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 ide)s(a.inner,a.prec);else if(a instanceof ea)r[o].push(a),a.provides&&s(a.provides,o);else if(a instanceof LT)r[o].push(a),a.facet.extensions&&s(a.facet.extensions,Pp.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,Pp.default),r.reduce((a,o)=>a.concat(o))}function bb(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 yP(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}const sde=Lt.define(),V6=Lt.define({combine:e=>e.some(t=>t),static:!0}),ade=Lt.define({combine:e=>e.length?e[0]:void 0,static:!0}),ode=Lt.define(),lde=Lt.define(),cde=Lt.define(),ude=Lt.define({combine:e=>e.length?e[0]:!1});class $d{constructor(t,n){this.type=t,this.value=n}static define(){return new Dje}}class Dje{of(t){return new $d(this,t)}}class Ije{constructor(t){this.map=t}of(t){return new En(this,t)}}class En{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 En(this.type,n)}is(t){return this.type==t}static define(t={}){return new Ije(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}}En.reconfigure=En.define();En.appendConfig=En.define();class Ss{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&&rde(r,n.newLength),s.some(o=>o.type==Ss.time)||(this.annotations=s.concat(Ss.time.of(Date.now())))}static create(t,n,r,i,s,a){return new Ss(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(Ss.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}}Ss.time=$d.define();Ss.userEvent=$d.define();Ss.addToHistory=$d.define();Ss.remote=$d.define();function Fje(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 dde(e,t,n){var r;let i,s,a;return n?(i=t.changes,s=Cs.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:En.mapEffects(e.effects,i).concat(En.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function Y6(e,t,n){let r=t.selection,i=F0(t.annotations);return t.userEvent&&(i=i.concat(Ss.userEvent.of(t.userEvent))),{changes:t.changes instanceof Cs?t.changes:Cs.of(t.changes||[],n,e.facet(ade)),selection:r&&(r instanceof qe?r:qe.single(r.anchor,r.head)),effects:F0(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function hde(e,t,n){let r=Y6(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=dde(r,Y6(e,t[s],a?r.changes.newLength:e.doc.length),a)}let i=Ss.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return Mje(n?Nje(i):i)}function Nje(e){let t=e.startState,n=!0;for(let i of t.facet(ode)){let s=i(e);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:Fje(n,s))}if(n!==!0){let i,s;if(n===!1)s=e.changes.invertedDesc,i=Cs.empty(t.doc.length);else{let a=e.changes.filter(n);i=a.changes,s=a.filtered.mapDesc(a.changes).invertedDesc}e=Ss.create(t,i,e.selection&&e.selection.map(s),En.mapEffects(e.effects,s),e.annotations,e.scrollIntoView)}let r=t.facet(lde);for(let i=r.length-1;i>=0;i--){let s=r[i](e);s instanceof Ss?e=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Ss?e=s[0]:e=hde(t,F0(s),!1)}return e}function Mje(e){let t=e.startState,n=t.facet(cde),r=e;for(let i=n.length-1;i>=0;i--){let s=n[i](e);s&&Object.keys(s).length&&(r=dde(r,Y6(t,s,e.changes.newLength),!0))}return r==e?e:Ss.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}const zje=[];function F0(e){return e==null?zje:Array.isArray(e)?e:[e]}var _i=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(_i||(_i={}));const Lje=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let B6;try{B6=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function qje(e){if(B6)return B6.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||Lje.test(n)))return!0}return!1}function Uje(e){return t=>{if(!/\S/.test(t))return _i.Space;if(qje(t))return _i.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return _i.Word;return _i.Other}}class ur{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++)bb(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 bb(this,r),yP(this,r)}update(...t){return hde(this,t,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let o of t.effects)o.is(ZC.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(En.reconfigure)?(n=null,r=o.value):o.is(En.appendConfig)&&(n=null,r=F0(r).concat(o.value));let s;n?s=t.startState.values.slice():(n=bP.resolve(r,i,this),s=new ur(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let a=t.startState.facet(V6)?t.newSelection:t.newSelection.asSingle();new ur(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:qe.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=F0(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=En.mapEffects(a,u).concat(En.mapEffects(F0(l.effects),d))}return{changes:i,selection:qe.create(s,n.mainIndex),effects:a}}changes(t=[]){return t instanceof Cs?t:Cs.of(t,this.doc.length,this.facet(ur.lineSeparator))}toText(t){return Tr.of(t.split(this.facet(ur.lineSeparator)||q6))}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:(bb(this,n),yP(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 ea&&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 ur.create({doc:t.doc,selection:qe.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=bP.resolve(t.extensions||[],new Map),r=t.doc instanceof Tr?t.doc:Tr.of((t.doc||"").split(n.staticFacet(ur.lineSeparator)||q6)),i=t.selection?t.selection instanceof qe?t.selection:qe.single(t.selection.anchor,t.selection.head):qe.single(0);return rde(i,r.length),n.staticFacet(V6)||(i=i.asSingle()),new ur(n,r,i,n.dynamicSlots.map(()=>null),(s,a)=>a.create(s),null)}get tabSize(){return this.facet(ur.tabSize)}get lineBreak(){return this.facet(ur.lineSeparator)||`
|
|
@@ -1075,7 +1075,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
1075
1075
|
`))};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=qe.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((Gt.mac||Gt.android)&&c.from==a-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:o,to:l,insert:Tr.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);ON(t,c,qe.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(zt.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:Gde.of(zt.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=Ky(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 bt{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||Jje(t.parent)||document,this.viewState=new Bj(t.state||ur.create(t)),t.scrollTo&&t.scrollTo.is(q$)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(m0).map(i=>new JE(i));for(let i of this.plugins)i.update(this);this.observer=new mYe(this),this.inputState=new zVe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Qj(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 Ss?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(ihe))?(this.inputState.notifiedFocused=a,o=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,l=she(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(ur.phrases)!=this.state.facet(ur.phrases))return this.setState(s);i=$P.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 M0(f.empty?f:qe.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of h.effects)f.is(q$)&&(d=f.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=TP.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Gw)!=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(Y$)!=i.state.facet(Y$)&&(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(hD))try{h(i)}catch(f){No(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!Kde(this,u)&&c.force&&N0(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 Bj(t),this.plugins=t.facet(m0).map(r=>new JE(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Qj(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(m0),r=t.state.facet(m0);if(n!=r){let i=[];for(let s of r){let a=n.indexOf(s);if(a<0)i.push(new JE(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){No(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(wde(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 No(this.state,O),Jj}}),d=$P.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]!=Jj)try{let O=c[f];O.write&&O.write(u[f],this)}catch(O){No(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(hD))o(n)}get themeClasses(){return mD+" "+(this.state.facet(gD)?che:lhe)+" "+this.state.facet(Y$)}updateAttrs(){let t=eV(this,jde,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(oh)?"true":"false",class:"cm-content",style:`${Gt.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),eV(this,dN,n);let r=this.observer.ignore(()=>{let i=oD(this.contentDOM,this.contentAttrs,n),s=oD(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(bt.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(Gw);let t=this.state.facet(bt.cspNonce);mO.mount(this.root,this.styleModules.concat(pYe).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 tR(this,t,Dj(this,t,n,r))}moveByGroup(t,n){return tR(this,t,Dj(this,t,n,r=>EVe(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 qe.cursor(s.side(n,i)+t.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return QVe(this,t,n,r)}moveVertically(t,n,r){return tR(this,t,RVe(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(),Hde(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[Wf.find(s,t-i.from,-1,n)];return mS(r,a.dir==mi.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(qde)||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>bYe)return Xde(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||Ade(s.isolates,r=Cj(this,t))))return s.order;r||(r=Cj(this,t));let i=OVe(t.text,n,r);return this.bidiCache.push(new TP(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Gt.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{mde(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 q$.of(new M0(typeof t=="number"?qe.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 q$.of(new M0(qe.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 zi.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return zi.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=mO.newName(),i=[Y$.of(r),Gw.of(vD(`.${r}`,t))];return n&&n.dark&&i.push(gD.of(!0)),i}static baseTheme(t){return Yh.lowest(Gw.of(vD("."+mD,t,uhe)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&ii.get(r)||ii.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}bt.styleModule=Gw;bt.inputHandler=zde;bt.clipboardInputFilter=cN;bt.clipboardOutputFilter=uN;bt.scrollHandler=Wde;bt.focusChangeEffect=Lde;bt.perLineTextDirection=qde;bt.exceptionSink=Mde;bt.updateListener=hD;bt.editable=oh;bt.mouseSelectionStyle=Nde;bt.dragMovesSelection=Fde;bt.clickAddsSelectionRange=Ide;bt.decorations=Jy;bt.outerDecorations=Vde;bt.atomicRanges=hN;bt.bidiIsolatedRanges=Yde;bt.scrollMargins=Bde;bt.darkTheme=gD;bt.cspNonce=Lt.define({combine:e=>e.length?e[0]:""});bt.contentAttributes=dN;bt.editorAttributes=jde;bt.lineWrapping=bt.contentAttributes.of({class:"cm-lineWrapping"});bt.announce=En.define();const bYe=4096,Jj={};class TP{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:mi.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 TP(n.mapPos(a.from,1),n.mapPos(a.to,-1),a.dir,a.isolates,!1,a.order))}return r}}function eV(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&&aD(a,n)}return n}const yYe=Gt.mac?"mac":Gt.windows?"win":Gt.linux?"linux":"key";function xYe(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 B$(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 SYe=Yh.default(bt.domEventHandlers({keydown(e,t){return hhe(dhe(t.state),e,t,"editor")}})),Hg=Lt.define({enables:SYe}),tV=new WeakMap;function dhe(e){let t=e.facet(Hg),n=tV.get(t);return n||tV.set(t,n=TYe(t.reduce((r,i)=>r.concat(i),[]))),n}function $Ye(e,t,n){return hhe(dhe(e.state),t,e,n)}let Xf=null;const kYe=4e3;function TYe(e,t=yYe){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=>xYe(v,t));for(let v=1;v<O.length;v++){let w=O.slice(0,v).join(" ");i(w,!0),f[w]||(f[w]={preventDefault:!0,stopPropagation:!1,run:[y=>{let T=Xf={view:y,prefix:w,scope:a};return setTimeout(()=>{Xf==T&&(Xf=null)},kYe),!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,wD))}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 wD=null;function hhe(e,t,n,r){wD=t;let i=Yje(t),s=Eo(i,0),a=Mu(s)==i.length&&i!=" ",o="",l=!1,c=!1,u=!1;Xf&&Xf.view==n&&Xf.scope==r&&(o=Xf.prefix+" ",ehe.indexOf(t.keyCode)<0&&(c=!0,Xf=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+B$(i,t,!a)])?l=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Gt.windows&&t.ctrlKey&&t.altKey)&&(O=vO[t.keyCode])&&O!=i?(h(f[o+B$(O,t,!0)])||t.shiftKey&&(g=Hy[t.keyCode])!=i&&g!=O&&h(f[o+B$(g,t,!1)]))&&(l=!0):a&&t.shiftKey&&h(f[o+B$(i,t,!0)])&&(l=!0),!l&&h(f._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),wD=null,l}class bS{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=fhe(t);return[new bS(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return PYe(t,n,r)}}function fhe(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==mi.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function nV(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 PYe(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==mi.LTR,a=e.contentDOM,o=a.getBoundingClientRect(),l=fhe(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=OD(e,r,1),O=OD(e,i,-1),g=f.type==fo.Text?f:null,m=O.type==fo.Text?O:null;if(g&&(e.lineWrapping||f.widgetLineBreaks)&&(g=nV(e,r,1,g)),m&&(e.lineWrapping||O.widgetLineBreaks)&&(m=nV(e,i,-1,m)),g&&m&&g.from==m.from&&g.to==m.to)return w(y(n.from,n.to,g));{let x=g?y(n.from,null,g):T(f,!1),k=m?y(null,n.to,m):T(O,!0),S=[];return(g||f).to<(m||O).from-(g&&m?1:0)||f.widgetLineBreaks>1&&x.bottom+e.defaultLineHeight/2<k.top?S.push(v(d,x.bottom,h,k.top)):x.bottom<k.top&&e.elementAtHeight((x.bottom+k.top)/2).type==fo.Text&&(x.bottom=k.top=(x.bottom+k.top)/2),w(x).concat(S).concat(w(k))}function v(x,k,S,Q){return new bS(t,x-l.left,k-l.top,S-x,Q-k)}function w({top:x,bottom:k,horizontal:S}){let Q=[];for(let R=0;R<S.length;R+=2)Q.push(v(S[R],x,S[R+1],k));return Q}function y(x,k,S){let Q=1e9,R=-1e9,_=[];function A(L,z,V,q,Z){let j=e.coordsAtPos(L,L==S.to?-2:2),M=e.coordsAtPos(V,V==S.from?2:-2);!j||!M||(Q=Math.min(j.top,M.top,Q),R=Math.max(j.bottom,M.bottom,R),Z==mi.LTR?_.push(s&&z?d:j.left,s&&q?h:M.right):_.push(!s&&q?d:M.left,!s&&z?h:j.right))}let E=x??S.from,I=k??S.to;for(let L of e.visibleRanges)if(L.to>E&&L.from<I)for(let z=Math.max(L.from,E),V=Math.min(L.to,I);;){let q=e.state.doc.lineAt(z);for(let Z of e.bidiSpans(q)){let j=Z.from+q.from,M=Z.to+q.from;if(j>=V)break;M>z&&A(Math.max(j,z),x==null&&j<=E,Math.min(M,V),k==null&&M>=I,Z.dir)}if(z=q.to+1,z>=V)break}return _.length==0&&A(E,x==null,I,k==null,e.textDirection),{top:Q,bottom:R,horizontal:_}}function T(x,k){let S=o.top+(k?x.top:x.bottom);return{top:S,bottom:S,horizontal:[]}}}function _Ye(e,t){return e.constructor==t.constructor&&e.eq(t)}class CYe{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(jT)!=t.state.facet(jT)&&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(jT);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)=>!_Ye(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 jT=Lt.define();function Ohe(e){return[zi.define(t=>new CYe(t,e)),jT.of(e)]}const ex=Lt.define({combine(e){return kd(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function QYe(e={}){return[ex.of(e),EYe,RYe,AYe,Ude.of(!0)]}function phe(e){return e.startState.facet(ex)!=e.state.facet(ex)}const EYe=Ohe({above:!0,markers(e){let{state:t}=e,n=t.facet(ex),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:qe.cursor(i.head,i.head>i.anchor?-1:1);for(let l of bS.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=phe(e);return n&&rV(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){rV(t.state,e)},class:"cm-cursorLayer"});function rV(e,t){t.style.animationDuration=e.facet(ex).cursorBlinkRate+"ms"}const RYe=Ohe({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:bS.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||phe(e)},class:"cm-selectionLayer"}),AYe=Yh.highest(bt.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"}}}})),ghe=En.define({map(e,t){return e==null?null:t.mapPos(e)}}),Yw=ea.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(ghe)?r.value:n,e)}}),XYe=zi.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(Yw);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(Yw)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Yw),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(Yw)!=e&&this.view.dispatch({effects:ghe.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 DYe(){return[Yw,XYe]}function iV(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 IYe(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 FYe{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 Ah,r=n.add.bind(n);for(let{from:i,to:s}of IYe(t,this.maxLength))iV(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 iV(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 bD=/x/.unicode!=null?"gu":"g",NYe=new RegExp(`[\0-\b
|
|
1076
1076
|
--\u2028\u2029\uFEFF-]`,bD),MYe={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 iR=null;function zYe(){var e;if(iR==null&&typeof document<"u"&&document.body){let t=document.body.style;iR=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return iR||!1}const VT=Lt.define({combine(e){let t=kd(e,{render:null,specialChars:NYe,addSpecialChars:null});return(t.replaceTabs=!zYe())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,bD)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,bD)),t}});function LYe(e={}){return[VT.of(e),qYe()]}let sV=null;function qYe(){return sV||(sV=zi.fromClass(class{constructor(e){this.view=e,this.decorations=zt.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(VT)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new FYe({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,s=Eo(t[0],0);if(s==9){let a=i.lineAt(r),o=n.state.tabSize,l=Kc(a.text,o,r-a.from);return zt.replace({widget:new jYe((o-l%o)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=zt.replace({widget:new GYe(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(VT);e.startState.facet(VT)!=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 UYe="•";function WYe(e){return e>=32?UYe:e==10?"":String.fromCharCode(9216+e)}class GYe extends su{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=WYe(this.code),r=t.state.phrase("Control character")+" "+(MYe[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 jYe extends su{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 VYe(){return BYe}const YYe=zt.line({class:"cm-activeLine"}),BYe=zi.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(YYe.range(i.from)),t=i.from)}return zt.set(n)}},{decorations:e=>e.decorations});class ZYe extends su{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?k1(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=mS(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 HYe(e){let t=zi.fromClass(class{constructor(n){this.view=n,this.placeholder=e?zt.set([zt.widget({widget:new ZYe(e),side:1}).range(0)]):zt.none}get decorations(){return this.view.state.doc.length?zt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,bt.contentAttributes.of({"aria-placeholder":e})]:t}const yD=2e3;function KYe(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),s=[];if(t.off>yD||n.off>yD||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(qe.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=J6(c.text,a,e.tabSize,!0);if(u<0)s.push(qe.cursor(c.to));else{let d=J6(c.text,o,e.tabSize);s.push(qe.range(c.from+u,c.from+d))}}}return s}function JYe(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function aV(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>yD?-1:i==r.length?JYe(e,t.clientX):Kc(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:s,off:i}}function eBe(e,t){let n=aV(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=aV(e,i);if(!o)return r;let l=KYe(e.state,n,o);return l.length?a?qe.create(l.concat(r.ranges)):qe.create(l):r}}:null}function tBe(e){let t=n=>n.altKey&&n.button==0;return bt.mouseSelectionStyle.of((n,r)=>t(r)?eBe(n,r):null)}const nBe={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},rBe={style:"cursor: crosshair"};function iBe(e={}){let[t,n]=nBe[e.key||"Alt"],r=zi.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,bt.contentAttributes.of(i=>{var s;return!((s=i.plugin(r))===null||s===void 0)&&s.isDown?rBe:null})]}const rw="-10000px";class mhe{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 sBe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const sR=Lt.define({combine:e=>{var t,n,r;return{position:Gt.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)||sBe}}}),oV=new WeakMap,mN=zi.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(sR);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 mhe(e,vN,(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(sR);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=rw,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(Gt.gecko)n=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==rw&&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=fN(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(sR).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=rw;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,O=f?7:0,g=h.right-h.left,m=(t=oV.get(c))!==null&&t!==void 0?t:h.bottom-h.top,v=c.offset||oBe,w=this.view.textDirection==mi.LTR,y=h.width>r.right-r.left?w?r.left:r.right-h.width:w?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=rw;continue}oV.set(c,m),u.style.height=(m=x)/s+"px"}else u.style.height&&(u.style.height="");let k=T?d.top-m-O-v.y:d.bottom+O+v.y,S=y+g;if(c.overlap!==!0)for(let Q of a)Q.left<S&&Q.right>y&&Q.top<k+m&&Q.bottom>k&&(k=T?Q.top-m-2-O:Q.bottom+O+2);if(this.position=="absolute"?(u.style.top=(k-e.parent.top)/s+"px",lV(u,(y-e.parent.left)/i)):(u.style.top=k/s+"px",lV(u,y/i)),f){let Q=d.left+(w?v.x:-v.x)-(y+14-7);f.style.left=Q/i+"px"}c.overlap!==!0&&a.push({left:y,top:k,right:S,bottom:k+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=rw}},{eventObservers:{scroll(){this.maybeMeasure()}}});function lV(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const aBe=bt.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"}}}),oBe={x:0,y:0},vN=Lt.define({enables:[mN,aBe]}),PP=Lt.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class JC{static create(t){return new JC(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new mhe(t,PP,(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 lBe=vN.compute([PP],e=>{let t=e.facet(PP);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:JC.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class cBe{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 Uf)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==mi.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=>No(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(mN),n=t?t.manager.tooltips.findIndex(r=>r.create==JC.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&&!uBe(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:!dBe(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 Z$=4;function uBe(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-Z$&&t.clientX<=r+Z$&&t.clientY>=i-Z$&&t.clientY<=s+Z$}function dBe(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 hBe(e,t={}){let n=En.define(),r=ea.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,fa.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(fBe)&&(i=[]);return i},provide:i=>PP.from(i)});return{active:r,extension:[r,zi.define(i=>new cBe(i,e,r,n,t.hoverTime||300)),lBe]}}function vhe(e,t){let n=e.plugin(mN);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const fBe=En.define(),cV=Lt.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 tx(e,t){let n=e.plugin(whe),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const whe=zi.fromClass(class{constructor(e){this.input=e.state.facet(nx),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(cV);this.top=new H$(e,!0,t.topContainer),this.bottom=new H$(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(cV);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new H$(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new H$(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(nx);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=>bt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class H${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=uV(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=uV(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 uV(e){let t=e.nextSibling;return e.remove(),t}const nx=Lt.define({enables:whe});class Dh extends vg{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Dh.prototype.elementClass="";Dh.prototype.toDOM=void 0;Dh.prototype.mapMode=fa.TrackBefore;Dh.prototype.startSide=Dh.prototype.endSide=-1;Dh.prototype.point=!0;const YT=Lt.define(),OBe=Lt.define(),pBe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>vr.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Sb=Lt.define();function gBe(e){return[bhe(),Sb.of({...pBe,...e})]}const dV=Lt.define({combine:e=>e.some(t=>t)});function bhe(e){return[mBe]}const mBe=zi.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(Sb).map(t=>new fV(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(dV),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(dV)!=!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=vr.iter(this.view.state.facet(YT),this.view.viewport.from),r=[],i=this.gutters.map(s=>new vBe(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==fo.Text&&a){xD(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==fo.Text){xD(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(Sb),n=e.state.facet(Sb),r=e.docChanged||e.heightChanged||e.viewportChanged||!vr.eq(e.startState.facet(YT),e.state.facet(YT),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 fV(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=>bt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==mi.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function hV(e){return Array.isArray(e)?e:[e]}function xD(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class vBe{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=vr.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 yhe(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=[];xD(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(OBe)){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 fV{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=hV(n.markers(t)),n.initialSpacer&&(this.spacer=new yhe(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=hV(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!vr.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 yhe{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":""),wBe(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 wBe(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 bBe=Lt.define(),yBe=Lt.define(),v0=Lt.define({combine(e){return kd(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 aR extends Dh{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function oR(e,t){return e.state.facet(v0).formatNumber(t,e.state)}const xBe=Sb.compute([v0],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(bBe)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new aR(oR(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(yBe)){let s=i(t,n,r);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(v0)!=t.state.facet(v0),initialSpacer(t){return new aR(oR(t,OV(t.state.doc.lines)))},updateSpacer(t,n){let r=oR(n.view,OV(n.view.state.doc.lines));return r==t.number?t:new aR(r)},domEventHandlers:e.facet(v0).domEventHandlers}));function SBe(e={}){return[v0.of(e),bhe(),xBe]}function OV(e){let t=9;for(;t<e;)t=t*10+9;return t}const $Be=new class extends Dh{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},kBe=YT.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($Be.range(i)))}return vr.of(t)});function TBe(){return kBe}let PBe=0;class Ft{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=PBe++}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 Ft&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new Ft(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 _P(t);return r=>r.modified.indexOf(n)>-1?r:_P.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let _Be=0;class _P{constructor(t){this.name=t,this.instances=[],this.id=_Be++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(o=>o.base==t&&CBe(n,o.modified));if(r)return r;let i=[],s=new Ft(t.name,i,t,n);for(let o of n)o.instances.push(s);let a=QBe(n);for(let o of t.set)if(!o.modified.length)for(let l of a)i.push(_P.get(o,l));return s}}function CBe(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function QBe(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 Qr(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 CP(r,a,l>0?s.slice(0,l):null);t[c]=u.sort(t[c])}}return xhe.add(t)}const xhe=new Pn;let CP=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}};CP.empty=new CP([],2,null);function She(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 EBe(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function RBe(e,t,n,r=0,i=e.length){let s=new ABe(r,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),r,i,"",s.highlighters),s.flush(i)}class ABe{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=XBe(t)||CP.empty,d=EBe(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(Pn.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 w=m<h.overlay.length?h.overlay[m]:null,y=w?w.from+o:l,T=Math.max(n,v),x=Math.min(r,y);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>=y||!t.nextSibling())););if(!w||y>r)break;v=w.to+o,v>n&&(this.highlightRange(f.cursor(),Math.max(n,w.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 XBe(e){let t=e.type.prop(xhe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const Rt=Ft.define,K$=Rt(),_f=Rt(),pV=Rt(_f),gV=Rt(_f),Cf=Rt(),J$=Rt(Cf),lR=Rt(Cf),Pu=Rt(),cp=Rt(Pu),wu=Rt(),bu=Rt(),SD=Rt(),iw=Rt(SD),ek=Rt(),P={comment:K$,lineComment:Rt(K$),blockComment:Rt(K$),docComment:Rt(K$),name:_f,variableName:Rt(_f),typeName:pV,tagName:Rt(pV),propertyName:gV,attributeName:Rt(gV),className:Rt(_f),labelName:Rt(_f),namespace:Rt(_f),macroName:Rt(_f),literal:Cf,string:J$,docString:Rt(J$),character:Rt(J$),attributeValue:Rt(J$),number:lR,integer:Rt(lR),float:Rt(lR),bool:Rt(Cf),regexp:Rt(Cf),escape:Rt(Cf),color:Rt(Cf),url:Rt(Cf),keyword:wu,self:Rt(wu),null:Rt(wu),atom:Rt(wu),unit:Rt(wu),modifier:Rt(wu),operatorKeyword:Rt(wu),controlKeyword:Rt(wu),definitionKeyword:Rt(wu),moduleKeyword:Rt(wu),operator:bu,derefOperator:Rt(bu),arithmeticOperator:Rt(bu),logicOperator:Rt(bu),bitwiseOperator:Rt(bu),compareOperator:Rt(bu),updateOperator:Rt(bu),definitionOperator:Rt(bu),typeOperator:Rt(bu),controlOperator:Rt(bu),punctuation:SD,separator:Rt(SD),bracket:iw,angleBracket:Rt(iw),squareBracket:Rt(iw),paren:Rt(iw),brace:Rt(iw),content:Pu,heading:cp,heading1:Rt(cp),heading2:Rt(cp),heading3:Rt(cp),heading4:Rt(cp),heading5:Rt(cp),heading6:Rt(cp),contentSeparator:Rt(Pu),list:Rt(Pu),quote:Rt(Pu),emphasis:Rt(Pu),strong:Rt(Pu),link:Rt(Pu),monospace:Rt(Pu),strikethrough:Rt(Pu),inserted:Rt(),deleted:Rt(),changed:Rt(),invalid:Rt(),meta:ek,documentMeta:Rt(ek),annotation:Rt(ek),processingInstruction:Rt(ek),definition:Ft.defineModifier("definition"),constant:Ft.defineModifier("constant"),function:Ft.defineModifier("function"),standard:Ft.defineModifier("standard"),local:Ft.defineModifier("local"),special:Ft.defineModifier("special")};for(let e in P){let t=P[e];t instanceof Ft&&(t.name=e)}She([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var cR;const Gf=new Pn;function eQ(e){return Lt.define({combine:e?t=>t.concat(e):void 0})}const wN=new Pn;class pl{constructor(t,n,r=[],i=""){this.data=t,this.name=i,ur.prototype.hasOwnProperty("tree")||Object.defineProperty(ur.prototype,"tree",{get(){return xr(this)}}),this.parser=n,this.extension=[bO.of(this),ur.languageData.of((s,a,o)=>{let l=mV(s,a,o),c=l.type.prop(Gf);if(!c)return[];let u=s.facet(c),d=l.type.prop(wN);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 mV(t,n,r).type.prop(Gf)==this.data}findRegions(t){let n=t.facet(bO);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(Gf)==this.data){r.push({from:a,to:a+s.length});return}let o=s.prop(Pn.mounted);if(o){if(o.tree.prop(Gf)==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 cr&&i(c,s.positions[l]+a)}};return i(xr(t),0),r}get allowsNesting(){return!0}}pl.setState=En.define();function mV(e,t,n){let r=e.facet(bO),i=xr(e).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(t,n,ni.ExcludeBuffers))s.type.isTop&&(i=s);return i}class yr extends pl{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=eQ(t.languageData);return new yr(n,t.parser.configure({props:[Gf.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new yr(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function xr(e){let t=e.field(pl.state,!1);return t?t.tree:cr.empty}class DBe{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 sw=null;class xg{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 xg(t,n,[],cr.empty,0,r,[],null)}startParse(){return this.parser.startParse(new DBe(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=cr.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(wh.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(wh.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=sw;sw=this;try{return t()}finally{sw=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=vV(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=wh.applyChanges(r,l),i=cr.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 xg(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=vV(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 BC{createParse(n,r,i){let s=i[0].from,a=i[i.length-1].to;return{parsedPos:s,advance(){let l=sw;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 cr($s.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 sw}}function vV(e,t,n){return wh.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class C1{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 C1(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=xg.create(t.facet(bO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new C1(r)}}pl.state=ea.define({create:C1.init,update(e,t){for(let n of t.effects)if(n.is(pl.setState))return n.value;return t.startState.facet(bO)!=t.state.facet(bO)?C1.init(t.state):e.apply(t)}});let $he=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&($he=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const uR=typeof navigator<"u"&&(!((cR=navigator.scheduling)===null||cR===void 0)&&cR.isInputPending)?()=>navigator.scheduling.isInputPending():null,IBe=zi.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(pl.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(pl.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=$he(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(pl.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,t&&!uR?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<i&&r.doc.length>i+1e3,l=s.context.work(()=>uR&&uR()||Date.now()>a,i+(o?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:pl.setState.of(new C1(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=>No(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()}}}),bO=Lt.define({combine(e){return e.length?e[0]:null},enables:e=>[pl.state,IBe,bt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class Or{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class Pe{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 Pe(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 FBe=Lt.define(),vv=Lt.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 Sg(e){let t=e.facet(vv);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function rx(e,t){let n="",r=e.tabSize,i=e.facet(vv)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let s=0;s<t;s++)n+=i;return n}function bN(e,t){e instanceof ur&&(e=new tQ(e));for(let r of e.state.facet(FBe)){let i=r(e,t);if(i!==void 0)return i}let n=xr(e.state);return n.length>=t?NBe(e,n,t):null}class tQ{constructor(t,n={}){this.state=t,this.options=n,this.unit=Sg(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 Kc(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 Li=new Pn;function NBe(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 khe(r,e,n)}function khe(e,t,n){for(let r=e;r;r=r.next){let i=zBe(r.node);if(i)return i(yN.create(t,n,r))}return 0}function MBe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function zBe(e){let t=e.type.prop(Li);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Pn.closedBy))){let i=e.lastChild,s=i&&r.indexOf(i.name)>-1;return a=>The(a,!0,1,void 0,s&&!MBe(a)?i.from:void 0)}return e.parent==null?LBe:null}function LBe(){return 0}class yN extends tQ{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 yN(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(qBe(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return khe(this.context.next,this.base,this.pos)}}function qBe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function UBe(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 ac({closing:e,align:t=!0,units:n=1}){return r=>The(r,t,n,e)}function The(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?UBe(e):null;return l?o?e.column(l.from):e.column(l.to):e.baseIndent+(o?0:e.unit*n)}const xN=e=>e.baseIndent;function Bi({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const WBe=200;function GBe(){return ur.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+WBe)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=bN(a,u.from);if(d==null)continue;let h=/^\s*/.exec(u.text)[0],f=rx(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 Phe=Lt.define(),Ei=new Pn;function Wa(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 jBe(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(Ei);if(l&&(o.to<r.length-50||r.length==e.doc.length||!VBe(o))){let c=l(o,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(s=c)}}return s}function VBe(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function QP(e,t,n){for(let r of e.facet(Phe)){let i=r(e,t,n);if(i)return i}return jBe(e,t,n)}function _he(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 nQ=En.define({map:_he}),yS=En.define({map:_he});function Che(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 $g=ea.define({create(){return zt.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(nQ)&&!YBe(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(Rhe),i=r?zt.replace({widget:new tZe(r(t.state,n.value))}):wV;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(yS)&&(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=>bt.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(wV.range(r,i))}return zt.set(t,!0)}});function EP(e,t,n){var r;let i=null;return(r=e.field($g,!1))===null||r===void 0||r.between(t,n,(s,a)=>{(!i||i.from>s)&&(i={from:s,to:a})}),i}function YBe(e,t,n){let r=!1;return e.between(t,t,(i,s)=>{i==t&&s==n&&(r=!0)}),r}function Qhe(e,t){return e.field($g,!1)?t:t.concat(En.appendConfig.of(Ahe()))}const BBe=e=>{for(let t of Che(e)){let n=QP(e.state,t.from,t.to);if(n)return e.dispatch({effects:Qhe(e.state,[nQ.of(n),Ehe(e,n)])}),!0}return!1},ZBe=e=>{if(!e.state.field($g,!1))return!1;let t=[];for(let n of Che(e)){let r=EP(e.state,n.from,n.to);r&&t.push(yS.of(r),Ehe(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function Ehe(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return bt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const HBe=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),s=QP(t,i.from,i.to);s&&n.push(nQ.of(s)),r=(s?e.lineBlockAt(s.to):i).to+1}return n.length&&e.dispatch({effects:Qhe(e.state,n)}),!!n.length},KBe=e=>{let t=e.state.field($g,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(yS.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},JBe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:BBe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:ZBe},{key:"Ctrl-Alt-[",run:HBe},{key:"Ctrl-Alt-]",run:KBe}],eZe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Rhe=Lt.define({combine(e){return kd(e,eZe)}});function Ahe(e){return[$g,iZe]}function Xhe(e,t){let{state:n}=e,r=n.facet(Rhe),i=a=>{let o=e.lineBlockAt(e.posAtDOM(a.target)),l=EP(e.state,o.from,o.to);l&&e.dispatch({effects:yS.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 wV=zt.replace({widget:new class extends su{toDOM(e){return Xhe(e,null)}}});class tZe extends su{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Xhe(t,this.value)}}const nZe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class dR extends Dh{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 rZe(e={}){let t={...nZe,...e},n=new dR(t,!0),r=new dR(t,!1),i=zi.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(bO)!=a.state.facet(bO)||a.startState.field($g,!1)!=a.state.field($g,!1)||xr(a.startState)!=xr(a.state)||t.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let o=new Ah;for(let l of a.viewportLineBlocks){let c=EP(a.state,l.from,l.to)?r:QP(a.state,l.from,l.to)?n:null;c&&o.add(l.from,l.from,c)}return o.finish()}}),{domEventHandlers:s}=t;return[i,gBe({class:"cm-foldGutter",markers(a){var o;return((o=a.plugin(i))===null||o===void 0?void 0:o.markers)||vr.empty},initialSpacer(){return new dR(t,!1)},domEventHandlers:{...s,click:(a,o,l)=>{if(s.click&&s.click(a,o,l))return!0;let c=EP(a.state,o.from,o.to);if(c)return a.dispatch({effects:yS.of(c)}),!0;let u=QP(a.state,o.from,o.to);return u?(a.dispatch({effects:nQ.of(u)}),!0):!1}}}),Ahe()]}const iZe=bt.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 wv{constructor(t,n){this.specs=t;let r;function i(o){let l=mO.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 pl?o=>o.prop(Gf)==a.data:a?o=>o==a:void 0,this.style=She(t.map(o=>({tag:o.tag,class:o.class||i(Object.assign({},o,{tag:null}))})),{all:s}).style,this.module=r?new mO(r):null,this.themeType=n.themeType}static define(t,n){return new wv(t,n||{})}}const $D=Lt.define(),Dhe=Lt.define({combine(e){return e.length?[e[0]]:null}});function hR(e){let t=e.facet($D);return t.length?t:e.facet(Dhe)}function RP(e,t){let n=[aZe],r;return e instanceof wv&&(e.module&&n.push(bt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Dhe.of(e)):r?n.push($D.computeN([bt.darkTheme],i=>i.facet(bt.darkTheme)==(r=="dark")?[e]:[])):n.push($D.of(e)),n}class sZe{constructor(t){this.markCache=Object.create(null),this.tree=xr(t.state),this.decorations=this.buildDeco(t,hR(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=xr(t.state),r=hR(t.state),i=r!=hR(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 zt.none;let r=new Ah;for(let{from:i,to:s}of t.visibleRanges)RBe(this.tree,n,(a,o,l)=>{r.add(a,o,this.markCache[l]||(this.markCache[l]=zt.mark({class:l})))},i,s);return r.finish()}}const aZe=Yh.high(zi.fromClass(sZe,{decorations:e=>e.decorations})),oZe=wv.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),lZe=bt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Ihe=1e4,Fhe="()[]{}",Nhe=Lt.define({combine(e){return kd(e,{afterCursor:!0,brackets:Fhe,maxScanDistance:Ihe,renderMatch:dZe})}}),cZe=zt.mark({class:"cm-matchingBracket"}),uZe=zt.mark({class:"cm-nonmatchingBracket"});function dZe(e){let t=[],n=e.matched?cZe:uZe;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 hZe=ea.define({create(){return zt.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Nhe);for(let i of t.state.selection.ranges){if(!i.empty)continue;let s=Vu(t.state,i.head,-1,r)||i.head>0&&Vu(t.state,i.head-1,1,r)||r.afterCursor&&(Vu(t.state,i.head,1,r)||i.head<t.state.doc.length&&Vu(t.state,i.head+1,-1,r));s&&(n=n.concat(r.renderMatch(s,t.state)))}return zt.set(n,!0)},provide:e=>bt.decorations.from(e)}),fZe=[hZe,lZe];function OZe(e={}){return[Nhe.of(e),fZe]}const SN=new Pn;function kD(e,t,n){let r=e.prop(t<0?Pn.openedBy:Pn.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 TD(e){let t=e.type.prop(SN);return t?t(e.node):e}function Vu(e,t,n,r={}){let i=r.maxScanDistance||Ihe,s=r.brackets||Fhe,a=xr(e),o=a.resolveInner(t,n);for(let l=o;l;l=l.parent){let c=kD(l.type,n,s);if(c&&l.from<l.to){let u=TD(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return pZe(e,t,n,l,u,c,s)}}return gZe(e,t,n,a,o.type,i,s)}function pZe(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=TD(u);return{start:l,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(kD(u.type,n,a))c++;else if(kD(u.type,-n,a)){if(c==0){let d=TD(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 gZe(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 bV(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 Mhe{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=bV(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:bV(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 mZe(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||vZe,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||kN,mergeTokens:e.mergeTokens!==!1}}function vZe(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 yV=new WeakMap;class nt extends pl{constructor(t){let n=eQ(t.languageData),r=mZe(t),i,s=new class extends BC{createParse(a,o,l){return new bZe(i,a,o,l)}};super(n,s,[],t.name),this.topNode=SZe(n,this),i=this,this.streamParser=r,this.stateAfter=new Pn({perNode:!0}),this.tokenTable=t.tokenTable?new Uhe(r.tokenTable):xZe}static define(t){return new nt(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=yV.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=$N(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 Mhe(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;d.pos<c-l.from;)Lhe(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&&yV.set(t.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],t)}get allowsNesting(){return!1}}function $N(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 cr&&l<i&&$N(e,o,l,r,i);if(c)return c}return null}function zhe(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 cr){if(!(l=zhe(e,o,n-a,r-a,i)))break;return i?new cr(t.type,t.children.slice(0,s).concat(l),t.positions.slice(0,s+1),a+l.length):l}}return null}function wZe(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&&$N(e,s.tree,0-s.offset,n,o),c;if(l&&l.pos<=r&&(c=zhe(e,s.tree,n+s.offset,l.pos+s.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?Sg(i):4),tree:cr.empty}}let bZe=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=xg.get(),a=i[0].from,{state:o,tree:l}=wZe(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(Sg(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=xg.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==`
|
|
1077
1077
|
`&&(n="");else{let r=n.indexOf(`
|
|
1078
|
-
`);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 Mhe(n,t?t.state.tabSize:4,t?Sg(t.state):2);if(a.eol())s.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let o=Lhe(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=cr.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:yZe,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new cr(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 cr(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Lhe(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 kN=Object.create(null),ix=[$s.none],yZe=new mv(ix),xV=[],SV=Object.create(null),qhe=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"]])qhe[e]=Whe(kN,t);class Uhe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),qhe)}resolve(t){return t?this.table[t]||(this.table[t]=Whe(this.extra,t)):0}}const xZe=new Uhe(kN);function fR(e,t){xV.indexOf(e)>-1||(xV.push(e),console.warn(t))}function Whe(e,t){let n=[];for(let o of t.split(" ")){let l=[];for(let c of o.split(".")){let u=e[c]||P[c];u?typeof u=="function"?l.length?l=l.map(u):fR(c,`Modifier ${c} used at start of tag`):l.length?fR(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:fR(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=SV[i];if(s)return s.id;let a=SV[i]=$s.define({id:ix.length,name:r,props:[Qr({[r]:n})]});return ix.push(a),a.id}function SZe(e,t){let n=$s.define({id:ix.length,name:"Document",props:[Gf.add(()=>e),Li.add(()=>r=>t.getIndent(r))],top:!0});return ix.push(n),n}mi.RTL,mi.LTR;function Ze(e){return new Or(nt.define(e))}function gf(e){return Ae(()=>Promise.resolve().then(()=>Hst),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const $Ze=[Pe.of({name:"C",extensions:["c","h","ino"],load(){return Ae(()=>Promise.resolve().then(()=>OB),void 0,import.meta.url).then(e=>e.cpp())}}),Pe.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return Ae(()=>Promise.resolve().then(()=>OB),void 0,import.meta.url).then(e=>e.cpp())}}),Pe.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return gf("Cassandra")}}),Pe.of({name:"CSS",extensions:["css"],load(){return Ae(()=>Promise.resolve().then(()=>uJe),void 0,import.meta.url).then(e=>e.css())}}),Pe.of({name:"Go",extensions:["go"],load(){return Ae(()=>import("./index-BHWYYomf.js"),__vite__mapDeps([5,1,2]),import.meta.url).then(e=>e.go())}}),Pe.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return Ae(()=>Promise.resolve().then(()=>tet),void 0,import.meta.url).then(e=>e.html())}}),Pe.of({name:"Java",extensions:["java"],load(){return Ae(()=>Promise.resolve().then(()=>tat),void 0,import.meta.url).then(e=>e.java())}}),Pe.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Ae(()=>Promise.resolve().then(()=>ik),void 0,import.meta.url).then(e=>e.javascript())}}),Pe.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Ae(()=>Promise.resolve().then(()=>ltt),void 0,import.meta.url).then(e=>e.json())}}),Pe.of({name:"JSX",extensions:["jsx"],load(){return Ae(()=>Promise.resolve().then(()=>ik),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Pe.of({name:"LESS",extensions:["less"],load(){return Ae(()=>Promise.resolve().then(()=>$et),void 0,import.meta.url).then(e=>e.less())}}),Pe.of({name:"Liquid",extensions:["liquid"],load(){return Ae(()=>Promise.resolve().then(()=>zlt),void 0,import.meta.url).then(e=>e.liquid())}}),Pe.of({name:"MariaDB SQL",load(){return gf("MariaSQL")}}),Pe.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Ae(()=>Promise.resolve().then(()=>het),void 0,import.meta.url).then(e=>e.markdown())}}),Pe.of({name:"MS SQL",load(){return gf("MSSQL")}}),Pe.of({name:"MySQL",load(){return gf("MySQL")}}),Pe.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return Ae(()=>Promise.resolve().then(()=>mlt),void 0,import.meta.url).then(e=>e.php())}}),Pe.of({name:"PLSQL",extensions:["pls"],load(){return gf("PLSQL")}}),Pe.of({name:"PostgreSQL",load(){return gf("PostgreSQL")}}),Pe.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return Ae(()=>Promise.resolve().then(()=>zit),void 0,import.meta.url).then(e=>e.python())}}),Pe.of({name:"Rust",extensions:["rs"],load(){return Ae(()=>Promise.resolve().then(()=>yat),void 0,import.meta.url).then(e=>e.rust())}}),Pe.of({name:"Sass",extensions:["sass"],load(){return Ae(()=>Promise.resolve().then(()=>CY),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),Pe.of({name:"SCSS",extensions:["scss"],load(){return Ae(()=>Promise.resolve().then(()=>CY),void 0,import.meta.url).then(e=>e.sass())}}),Pe.of({name:"SQL",extensions:["sql"],load(){return gf("StandardSQL")}}),Pe.of({name:"SQLite",load(){return gf("SQLite")}}),Pe.of({name:"TSX",extensions:["tsx"],load(){return Ae(()=>Promise.resolve().then(()=>ik),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Pe.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Ae(()=>Promise.resolve().then(()=>ik),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Pe.of({name:"WebAssembly",extensions:["wat","wast"],load(){return Ae(()=>Promise.resolve().then(()=>Ult),void 0,import.meta.url).then(e=>e.wast())}}),Pe.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return Ae(()=>Promise.resolve().then(()=>lst),void 0,import.meta.url).then(e=>e.xml())}}),Pe.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return Ae(()=>import("./index-C2JWjezT.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>e.yaml())}}),Pe.of({name:"APL",extensions:["dyalog","apl"],load(){return Ae(()=>Promise.resolve().then(()=>vdt),void 0,import.meta.url).then(e=>Ze(e.apl))}}),Pe.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return Ae(()=>Promise.resolve().then(()=>wdt),void 0,import.meta.url).then(e=>Ze(e.asciiArmor))}}),Pe.of({name:"ASN.1",extensions:["asn","asn1"],load(){return Ae(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Ze(e.asn1({})))}}),Pe.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return Ae(()=>Promise.resolve().then(()=>$dt),void 0,import.meta.url).then(e=>Ze(e.asterisk))}}),Pe.of({name:"Brainfuck",extensions:["b","bf"],load(){return Ae(()=>Promise.resolve().then(()=>Tdt),void 0,import.meta.url).then(e=>Ze(e.brainfuck))}}),Pe.of({name:"Cobol",extensions:["cob","cpy"],load(){return Ae(()=>Promise.resolve().then(()=>eht),void 0,import.meta.url).then(e=>Ze(e.cobol))}}),Pe.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.csharp))}}),Pe.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return Ae(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ze(e.clojure))}}),Pe.of({name:"ClojureScript",extensions:["cljs"],load(){return Ae(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ze(e.clojure))}}),Pe.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return Ae(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Ze(e.gss))}}),Pe.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return Ae(()=>Promise.resolve().then(()=>Gdt),void 0,import.meta.url).then(e=>Ze(e.cmake))}}),Pe.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return Ae(()=>Promise.resolve().then(()=>fht),void 0,import.meta.url).then(e=>Ze(e.coffeeScript))}}),Pe.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return Ae(()=>Promise.resolve().then(()=>wht),void 0,import.meta.url).then(e=>Ze(e.commonLisp))}}),Pe.of({name:"Cypher",extensions:["cyp","cypher"],load(){return Ae(()=>Promise.resolve().then(()=>Fht),void 0,import.meta.url).then(e=>Ze(e.cypher))}}),Pe.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return Ae(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Ze(e.cython))}}),Pe.of({name:"Crystal",extensions:["cr"],load(){return Ae(()=>Promise.resolve().then(()=>Eht),void 0,import.meta.url).then(e=>Ze(e.crystal))}}),Pe.of({name:"D",extensions:["d"],load(){return Ae(()=>Promise.resolve().then(()=>Wht),void 0,import.meta.url).then(e=>Ze(e.d))}}),Pe.of({name:"Dart",extensions:["dart"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.dart))}}),Pe.of({name:"diff",extensions:["diff","patch"],load(){return Ae(()=>Promise.resolve().then(()=>Ght),void 0,import.meta.url).then(e=>Ze(e.diff))}}),Pe.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return Ae(()=>Promise.resolve().then(()=>ift),void 0,import.meta.url).then(e=>Ze(e.dockerFile))}}),Pe.of({name:"DTD",extensions:["dtd"],load(){return Ae(()=>Promise.resolve().then(()=>oft),void 0,import.meta.url).then(e=>Ze(e.dtd))}}),Pe.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return Ae(()=>Promise.resolve().then(()=>hft),void 0,import.meta.url).then(e=>Ze(e.dylan))}}),Pe.of({name:"EBNF",load(){return Ae(()=>Promise.resolve().then(()=>fft),void 0,import.meta.url).then(e=>Ze(e.ebnf))}}),Pe.of({name:"ECL",extensions:["ecl"],load(){return Ae(()=>Promise.resolve().then(()=>yft),void 0,import.meta.url).then(e=>Ze(e.ecl))}}),Pe.of({name:"edn",extensions:["edn"],load(){return Ae(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ze(e.clojure))}}),Pe.of({name:"Eiffel",extensions:["e"],load(){return Ae(()=>Promise.resolve().then(()=>Pft),void 0,import.meta.url).then(e=>Ze(e.eiffel))}}),Pe.of({name:"Elm",extensions:["elm"],load(){return Ae(()=>Promise.resolve().then(()=>Nft),void 0,import.meta.url).then(e=>Ze(e.elm))}}),Pe.of({name:"Erlang",extensions:["erl"],load(){return Ae(()=>Promise.resolve().then(()=>lOt),void 0,import.meta.url).then(e=>Ze(e.erlang))}}),Pe.of({name:"Esper",load(){return Ae(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Ze(e.esper))}}),Pe.of({name:"Factor",extensions:["factor"],load(){return Ae(()=>Promise.resolve().then(()=>cOt),void 0,import.meta.url).then(e=>Ze(e.factor))}}),Pe.of({name:"FCL",load(){return Ae(()=>Promise.resolve().then(()=>OOt),void 0,import.meta.url).then(e=>Ze(e.fcl))}}),Pe.of({name:"Forth",extensions:["forth","fth","4th"],load(){return Ae(()=>Promise.resolve().then(()=>mOt),void 0,import.meta.url).then(e=>Ze(e.forth))}}),Pe.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return Ae(()=>Promise.resolve().then(()=>$Ot),void 0,import.meta.url).then(e=>Ze(e.fortran))}}),Pe.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return Ae(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ze(e.fSharp))}}),Pe.of({name:"Gas",extensions:["s"],load(){return Ae(()=>Promise.resolve().then(()=>TOt),void 0,import.meta.url).then(e=>Ze(e.gas))}}),Pe.of({name:"Gherkin",extensions:["feature"],load(){return Ae(()=>Promise.resolve().then(()=>POt),void 0,import.meta.url).then(e=>Ze(e.gherkin))}}),Pe.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return Ae(()=>Promise.resolve().then(()=>NOt),void 0,import.meta.url).then(e=>Ze(e.groovy))}}),Pe.of({name:"Haskell",extensions:["hs"],load(){return Ae(()=>Promise.resolve().then(()=>GOt),void 0,import.meta.url).then(e=>Ze(e.haskell))}}),Pe.of({name:"Haxe",extensions:["hx"],load(){return Ae(()=>Promise.resolve().then(()=>FZ),void 0,import.meta.url).then(e=>Ze(e.haxe))}}),Pe.of({name:"HXML",extensions:["hxml"],load(){return Ae(()=>Promise.resolve().then(()=>FZ),void 0,import.meta.url).then(e=>Ze(e.hxml))}}),Pe.of({name:"HTTP",load(){return Ae(()=>Promise.resolve().then(()=>Opt),void 0,import.meta.url).then(e=>Ze(e.http))}}),Pe.of({name:"IDL",extensions:["pro"],load(){return Ae(()=>Promise.resolve().then(()=>ypt),void 0,import.meta.url).then(e=>Ze(e.idl))}}),Pe.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return Ae(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Ze(e.jsonld))}}),Pe.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return Ae(()=>Promise.resolve().then(()=>kpt),void 0,import.meta.url).then(e=>Ze(e.jinja2))}}),Pe.of({name:"Julia",extensions:["jl"],load(){return Ae(()=>Promise.resolve().then(()=>Zpt),void 0,import.meta.url).then(e=>Ze(e.julia))}}),Pe.of({name:"Kotlin",extensions:["kt","kts"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.kotlin))}}),Pe.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return Ae(()=>Promise.resolve().then(()=>egt),void 0,import.meta.url).then(e=>Ze(e.liveScript))}}),Pe.of({name:"Lua",extensions:["lua"],load(){return Ae(()=>Promise.resolve().then(()=>lgt),void 0,import.meta.url).then(e=>Ze(e.lua))}}),Pe.of({name:"mIRC",extensions:["mrc"],load(){return Ae(()=>Promise.resolve().then(()=>Egt),void 0,import.meta.url).then(e=>Ze(e.mirc))}}),Pe.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return Ae(()=>Promise.resolve().then(()=>ggt),void 0,import.meta.url).then(e=>Ze(e.mathematica))}}),Pe.of({name:"Modelica",extensions:["mo"],load(){return Ae(()=>Promise.resolve().then(()=>Lgt),void 0,import.meta.url).then(e=>Ze(e.modelica))}}),Pe.of({name:"MUMPS",extensions:["mps"],load(){return Ae(()=>Promise.resolve().then(()=>rmt),void 0,import.meta.url).then(e=>Ze(e.mumps))}}),Pe.of({name:"Mbox",extensions:["mbox"],load(){return Ae(()=>Promise.resolve().then(()=>_gt),void 0,import.meta.url).then(e=>Ze(e.mbox))}}),Pe.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return Ae(()=>Promise.resolve().then(()=>lmt),void 0,import.meta.url).then(e=>Ze(e.nginx))}}),Pe.of({name:"NSIS",extensions:["nsh","nsi"],load(){return Ae(()=>Promise.resolve().then(()=>cmt),void 0,import.meta.url).then(e=>Ze(e.nsis))}}),Pe.of({name:"NTriples",extensions:["nt","nq"],load(){return Ae(()=>Promise.resolve().then(()=>umt),void 0,import.meta.url).then(e=>Ze(e.ntriples))}}),Pe.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.objectiveC))}}),Pe.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.objectiveCpp))}}),Pe.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return Ae(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ze(e.oCaml))}}),Pe.of({name:"Octave",extensions:["m"],load(){return Ae(()=>Promise.resolve().then(()=>ymt),void 0,import.meta.url).then(e=>Ze(e.octave))}}),Pe.of({name:"Oz",extensions:["oz"],load(){return Ae(()=>Promise.resolve().then(()=>Amt),void 0,import.meta.url).then(e=>Ze(e.oz))}}),Pe.of({name:"Pascal",extensions:["p","pas"],load(){return Ae(()=>Promise.resolve().then(()=>Mmt),void 0,import.meta.url).then(e=>Ze(e.pascal))}}),Pe.of({name:"Perl",extensions:["pl","pm"],load(){return Ae(()=>Promise.resolve().then(()=>zmt),void 0,import.meta.url).then(e=>Ze(e.perl))}}),Pe.of({name:"Pig",extensions:["pig"],load(){return Ae(()=>Promise.resolve().then(()=>Umt),void 0,import.meta.url).then(e=>Ze(e.pig))}}),Pe.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return Ae(()=>Promise.resolve().then(()=>s0t),void 0,import.meta.url).then(e=>Ze(e.powerShell))}}),Pe.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return Ae(()=>Promise.resolve().then(()=>a0t),void 0,import.meta.url).then(e=>Ze(e.properties))}}),Pe.of({name:"ProtoBuf",extensions:["proto"],load(){return Ae(()=>Promise.resolve().then(()=>d0t),void 0,import.meta.url).then(e=>Ze(e.protobuf))}}),Pe.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return Ae(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([7,8]),import.meta.url).then(e=>Ze(e.pug))}}),Pe.of({name:"Puppet",extensions:["pp"],load(){return Ae(()=>Promise.resolve().then(()=>O0t),void 0,import.meta.url).then(e=>Ze(e.puppet))}}),Pe.of({name:"Q",extensions:["q"],load(){return Ae(()=>Promise.resolve().then(()=>x0t),void 0,import.meta.url).then(e=>Ze(e.q))}}),Pe.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return Ae(()=>Promise.resolve().then(()=>C0t),void 0,import.meta.url).then(e=>Ze(e.r))}}),Pe.of({name:"RPM Changes",load(){return Ae(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Ze(e.rpmChanges))}}),Pe.of({name:"RPM Spec",extensions:["spec"],load(){return Ae(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Ze(e.rpmSpec))}}),Pe.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return Ae(()=>Promise.resolve().then(()=>N0t),void 0,import.meta.url).then(e=>Ze(e.ruby))}}),Pe.of({name:"SAS",extensions:["sas"],load(){return Ae(()=>Promise.resolve().then(()=>q0t),void 0,import.meta.url).then(e=>Ze(e.sas))}}),Pe.of({name:"Scala",extensions:["scala"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.scala))}}),Pe.of({name:"Scheme",extensions:["scm","ss"],load(){return Ae(()=>Promise.resolve().then(()=>t1t),void 0,import.meta.url).then(e=>Ze(e.scheme))}}),Pe.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Ae(()=>Promise.resolve().then(()=>s1t),void 0,import.meta.url).then(e=>Ze(e.shell))}}),Pe.of({name:"Sieve",extensions:["siv","sieve"],load(){return Ae(()=>Promise.resolve().then(()=>u1t),void 0,import.meta.url).then(e=>Ze(e.sieve))}}),Pe.of({name:"Smalltalk",extensions:["st"],load(){return Ae(()=>Promise.resolve().then(()=>f1t),void 0,import.meta.url).then(e=>Ze(e.smalltalk))}}),Pe.of({name:"Solr",load(){return Ae(()=>Promise.resolve().then(()=>b1t),void 0,import.meta.url).then(e=>Ze(e.solr))}}),Pe.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return Ae(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ze(e.sml))}}),Pe.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return Ae(()=>Promise.resolve().then(()=>P1t),void 0,import.meta.url).then(e=>Ze(e.sparql))}}),Pe.of({name:"Spreadsheet",alias:["excel","formula"],load(){return Ae(()=>Promise.resolve().then(()=>_1t),void 0,import.meta.url).then(e=>Ze(e.spreadsheet))}}),Pe.of({name:"Squirrel",extensions:["nut"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.squirrel))}}),Pe.of({name:"Stylus",extensions:["styl"],load(){return Ae(()=>Promise.resolve().then(()=>Z1t),void 0,import.meta.url).then(e=>Ze(e.stylus))}}),Pe.of({name:"Swift",extensions:["swift"],load(){return Ae(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>Ze(e.swift))}}),Pe.of({name:"sTeX",load(){return Ae(()=>Promise.resolve().then(()=>_H),void 0,import.meta.url).then(e=>Ze(e.stex))}}),Pe.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return Ae(()=>Promise.resolve().then(()=>_H),void 0,import.meta.url).then(e=>Ze(e.stex))}}),Pe.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return Ae(()=>Promise.resolve().then(()=>YH),void 0,import.meta.url).then(e=>Ze(e.verilog))}}),Pe.of({name:"Tcl",extensions:["tcl"],load(){return Ae(()=>Promise.resolve().then(()=>bvt),void 0,import.meta.url).then(e=>Ze(e.tcl))}}),Pe.of({name:"Textile",extensions:["textile"],load(){return Ae(()=>Promise.resolve().then(()=>$vt),void 0,import.meta.url).then(e=>Ze(e.textile))}}),Pe.of({name:"TiddlyWiki",load(){return Ae(()=>Promise.resolve().then(()=>Gvt),void 0,import.meta.url).then(e=>Ze(e.tiddlyWiki))}}),Pe.of({name:"Tiki wiki",load(){return Ae(()=>Promise.resolve().then(()=>Kvt),void 0,import.meta.url).then(e=>Ze(e.tiki))}}),Pe.of({name:"TOML",extensions:["toml"],load(){return Ae(()=>Promise.resolve().then(()=>Jvt),void 0,import.meta.url).then(e=>Ze(e.toml))}}),Pe.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return Ae(()=>Promise.resolve().then(()=>nwt),void 0,import.meta.url).then(e=>Ze(e.troff))}}),Pe.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return Ae(()=>Promise.resolve().then(()=>bwt),void 0,import.meta.url).then(e=>Ze(e.ttcn))}}),Pe.of({name:"TTCN_CFG",extensions:["cfg"],load(){return Ae(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Ze(e.ttcnCfg))}}),Pe.of({name:"Turtle",extensions:["ttl"],load(){return Ae(()=>Promise.resolve().then(()=>Swt),void 0,import.meta.url).then(e=>Ze(e.turtle))}}),Pe.of({name:"Web IDL",extensions:["webidl"],load(){return Ae(()=>Promise.resolve().then(()=>gbt),void 0,import.meta.url).then(e=>Ze(e.webIDL))}}),Pe.of({name:"VB.NET",extensions:["vb"],load(){return Ae(()=>Promise.resolve().then(()=>Nwt),void 0,import.meta.url).then(e=>Ze(e.vb))}}),Pe.of({name:"VBScript",extensions:["vbs"],load(){return Ae(()=>Promise.resolve().then(()=>zwt),void 0,import.meta.url).then(e=>Ze(e.vbScript))}}),Pe.of({name:"Velocity",extensions:["vtl"],load(){return Ae(()=>Promise.resolve().then(()=>Uwt),void 0,import.meta.url).then(e=>Ze(e.velocity))}}),Pe.of({name:"Verilog",extensions:["v"],load(){return Ae(()=>Promise.resolve().then(()=>YH),void 0,import.meta.url).then(e=>Ze(e.verilog))}}),Pe.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return Ae(()=>Promise.resolve().then(()=>Kwt),void 0,import.meta.url).then(e=>Ze(e.vhdl))}}),Pe.of({name:"XQuery",extensions:["xy","xquery"],load(){return Ae(()=>Promise.resolve().then(()=>Tbt),void 0,import.meta.url).then(e=>Ze(e.xQuery))}}),Pe.of({name:"Yacas",extensions:["ys"],load(){return Ae(()=>Promise.resolve().then(()=>Ibt),void 0,import.meta.url).then(e=>Ze(e.yacas))}}),Pe.of({name:"Z80",extensions:["z80"],load(){return Ae(()=>Promise.resolve().then(()=>Lbt),void 0,import.meta.url).then(e=>Ze(e.z80))}}),Pe.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return Ae(()=>Promise.resolve().then(()=>w4),void 0,import.meta.url).then(e=>Ze(e.mscgen))}}),Pe.of({name:"Xù",extensions:["xu"],load(){return Ae(()=>Promise.resolve().then(()=>w4),void 0,import.meta.url).then(e=>Ze(e.xu))}}),Pe.of({name:"MsGenny",extensions:["msgenny"],load(){return Ae(()=>Promise.resolve().then(()=>w4),void 0,import.meta.url).then(e=>Ze(e.msgenny))}}),Pe.of({name:"Vue",extensions:["vue"],load(){return Ae(()=>Promise.resolve().then(()=>Hlt),void 0,import.meta.url).then(e=>e.vue())}}),Pe.of({name:"Angular Template",load(){return Ae(()=>Promise.resolve().then(()=>gct),void 0,import.meta.url).then(e=>e.angular())}})];class TN{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(Ghe(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 $V(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 kZe(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=$V(t)+$V(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function xS(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:kZe(t);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:t,validFor:n}:null}}function rQ(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 kV{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function qp(e){return e.selection.main.from}function Ghe(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 PN=$d.define();function TZe(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:qe.cursor(o.from+s+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const TV=new WeakMap;function PZe(e){if(!Array.isArray(e))return e;let t=TV.get(e);return t||TV.set(e,t=xS(e)),t}const AP=En.define(),sx=En.define();class _Ze{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=Eo(t,n),i=Mu(r);this.chars.push(r);let s=t.slice(n,n+i),a=s.toUpperCase();this.folded.push(Eo(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 w=Eo(t,0),y=Mu(w),T=y==t.length?0:-100;if(w!=n[0])if(w==r[0])T+=-200;else return null;return this.ret(T,[0,y])}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 w=0,y=Math.min(t.length,200);w<y&&c<l;){let T=Eo(t,w);(T==n[c]||T==r[c])&&(i[c++]=w),w+=Mu(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 w=0,y=Math.min(t.length,200),T=0;w<y&&d<l;){let x=Eo(t,w);o<0&&(u<l&&x==n[u]&&(s[u++]=w),f<l&&(x==n[f]||x==r[f]?(f==0&&(O=w),g=w+1,f++):f=0));let k,S=x<255?x>=48&&x<=57||x>=97&&x<=122?2:x>=65&&x<=90?1:0:(k=rN(x))!=k.toLowerCase()?1:k!=k.toUpperCase()?2:0;(!w||S==1&&m||T==0&&S!=0)&&(n[d]==x||r[d]==x&&(h=!0)?a[d++]=w:a.length&&(v=!1)),T=S,w+=Mu(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?Mu(Eo(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 CZe{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 Ys=Lt.define({combine(e){return kd(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:QZe,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=>PV(t(r),n(r)),optionClass:(t,n)=>r=>PV(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function PV(e,t){return e?t?e+" "+t:e:t}function QZe(e,t,n,r,i,s){let a=e.textDirection==mi.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 w=i.bottom-t.bottom;w>=g||w>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 EZe(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 OR(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 RZe{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(Ys);this.optionContent=EZe(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=OR(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(Ys).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:sx.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=OR(s.length,a,t.state.facet(Ys).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=OR(n.options.length,n.selected,this.view.state.facet(Ys).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=>No(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&&XZe(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(Ys).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 AZe(e,t){return n=>new RZe(n,e,t)}function XZe(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 _V(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function DZe(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(Ys);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 kV(d,c.source,u?u(d):[],1e9-n.length));else{let d=t.sliceDoc(c.from,c.to),h,f=s.filterStrict?new CZe(d):new _Ze(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 kV(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):_V(c.completion)>_V(o)&&(a[a.length-1]=c),o=c.completion}return a}class w0{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 w0(this.options,CV(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=DZe(t,n);if(!o.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ys).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 w0(o,CV(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:LZe,above:s.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new w0(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 w0(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class XP{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new XP(MZe,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ys),s=(r.override||n.languageDataAt("autocomplete",qp(n)).map(PZe)).map(l=>(this.active.find(u=>u.source==l)||new Kl(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(_N));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||s.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!IZe(s,this.active)||o?a=w0.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 Kl(l.source,0):l));for(let l of t.effects)l.is(Vhe)&&(a=a&&a.setSelected(l.value,this.id));return s==this.active&&a==this.open?this:new XP(s,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?FZe:NZe}}function IZe(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 FZe={"aria-autocomplete":"list"},NZe={};function CV(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const MZe=[];function jhe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(PN);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 Kl{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=jhe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Kl(i.source,0)),r&4&&i.state==0&&(i=new Kl(this.source,1)),i=i.updateFor(t,r);for(let s of t.effects)if(s.is(AP))i=new Kl(i.source,1,s.value);else if(s.is(sx))i=new Kl(i.source,0);else if(s.is(_N))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(qp(t.state))}}class z0 extends Kl{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=qp(t.state);if(o>a||!i||n&2&&(qp(t.startState)==this.from||o<this.limit))return new Kl(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return zZe(i.validFor,t.state,s,a)?new z0(this.source,this.explicit,l,i,s,a):i.update&&(i=i.update(i,s,a,new TN(t.state,o,!1)))?new z0(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:qp(t.state)):new Kl(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new z0(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Kl(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function zZe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Ghe(e,!0).test(i)}const _N=En.define({map(e,t){return e.map(n=>n.map(t))}}),Vhe=En.define(),Ao=ea.define({create(){return XP.start()},update(e,t){return e.update(t)},provide:e=>[vN.from(e,t=>t.tooltip),bt.contentAttributes.from(e,t=>t.attrs)]});function CN(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ao).active.find(i=>i.source==t.source);return r instanceof z0?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},TZe(e.state,n,r.from,r.to)),{annotations:PN.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const LZe=AZe(Ao,CN);function tk(e,t="option"){return n=>{let r=n.state.field(Ao,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ys).interactionDelay)return!1;let i=1,s;t=="page"&&(s=vhe(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:Vhe.of(o)}),!0}}const qZe=e=>{let t=e.state.field(Ao,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ys).interactionDelay?!1:CN(e,t.open.options[t.open.selected])},QV=e=>e.state.field(Ao,!1)?(e.dispatch({effects:AP.of(!0)}),!0):!1,UZe=e=>{let t=e.state.field(Ao,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:sx.of(null)}),!0)};class WZe{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const GZe=50,jZe=1e3,VZe=zi.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(Ao).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ao),n=e.state.facet(Ys);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ao)==t)return;let r=e.transactions.some(s=>{let a=jhe(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>GZe&&Date.now()-a.time>jZe){for(let o of a.context.abortListeners)try{o()}catch(l){No(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(AP)))&&(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(Ao);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(Ys).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=qp(t),r=new TN(t,n,e.explicit,this.view),i=new WZe(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:sx.of(null)}),No(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(Ys).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ys),r=this.view.state.field(Ao);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=qp(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(o,s.done.from+(s.active.explicit?0:1)),c=new z0(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 Kl(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:_N.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ao,!1);if(t&&t.tooltip&&this.view.state.facet(Ys).closeOnBlur){let n=t.open&&vhe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:sx.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:AP.of(!1)}),20),this.composing=0}}}),YZe=typeof navigator=="object"&&/Win/.test(navigator.platform),BZe=Yh.highest(bt.domEventHandlers({keydown(e,t){let n=t.state.field(Ao,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(YZe&&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&&CN(t,r),!1}})),Yhe=bt.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 ZZe{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class QN{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,fa.TrackDel),r=t.mapPos(this.to,1,fa.TrackDel);return n==null||r==null?null:new QN(this.field,n,r)}}class EN{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(vv);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 QN(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 ZZe(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 EN(r,i)}}let HZe=zt.widget({widget:new class extends su{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),KZe=zt.mark({class:"cm-snippetField"});class bv{constructor(t,n){this.ranges=t,this.active=n,this.deco=zt.set(t.map(r=>(r.from==r.to?HZe:KZe).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 bv(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 SS=En.define({map(e,t){return e&&e.map(t)}}),JZe=En.define(),ax=ea.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(SS))return n.value;if(n.is(JZe)&&e)return new bv(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=>bt.decorations.from(e,t=>t?t.deco:zt.none)});function RN(e,t){return qe.create(e.filter(n=>n.field==t).map(n=>qe.range(n.from,n.to)))}function eHe(e){let t=EN.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:Tr.of(a)},scrollIntoView:!0,annotations:r?[PN.of(r),Ss.userEvent.of("input.complete")]:void 0};if(o.length&&(c.selection=RN(o,0)),o.some(u=>u.field>0)){let u=new bv(o,0),d=c.effects=[SS.of(u)];n.state.field(ax,!1)===void 0&&d.push(En.appendConfig.of([ax,sHe,aHe,Yhe]))}n.dispatch(n.state.update(c))}}function Bhe(e){return({state:t,dispatch:n})=>{let r=t.field(ax,!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:RN(r.ranges,i),effects:SS.of(s?null:new bv(r.ranges,i)),scrollIntoView:!0})),!0}}const tHe=({state:e,dispatch:t})=>e.field(ax,!1)?(t(e.update({effects:SS.of(null)})),!0):!1,nHe=Bhe(1),rHe=Bhe(-1),iHe=[{key:"Tab",run:nHe,shift:rHe},{key:"Escape",run:tHe}],EV=Lt.define({combine(e){return e.length?e[0]:iHe}}),sHe=Yh.highest(Hg.compute([EV],e=>e.facet(EV)));function fi(e,t){return Object.assign(Object.assign({},t),{apply:eHe(e)})}const aHe=bt.domEventHandlers({mousedown(e,t){let n=t.state.field(ax,!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:RN(n.ranges,i.field),effects:SS.of(n.ranges.some(s=>s.field>i.field)?new bv(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),ox={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Dp=En.define({map(e,t){let n=t.mapPos(e,-1,fa.TrackAfter);return n??void 0}}),AN=new class extends vg{};AN.startSide=1;AN.endSide=-1;const Zhe=ea.define({create(){return vr.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(Dp)&&(e=e.update({add:[AN.range(n.value,n.value+1)]}));return e}});function oHe(){return[cHe,Zhe]}const pR="()[]{}<>«»»«[]{}";function Hhe(e){for(let t=0;t<pR.length;t+=2)if(pR.charCodeAt(t)==e)return pR.charAt(t+1);return rN(e<128?e:e+1)}function Khe(e,t){return e.languageDataAt("closeBrackets",t)[0]||ox}const lHe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),cHe=bt.inputHandler.of((e,t,n,r)=>{if((lHe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Mu(Eo(r,0))==1||t!=i.from||n!=i.to)return!1;let s=hHe(e.state,r);return s?(e.dispatch(s),!0):!1}),uHe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Khe(e,e.selection.main.head).brackets||ox.brackets,i=null,s=e.changeByRange(a=>{if(a.empty){let o=fHe(e.doc,a.head);for(let l of r)if(l==o&&iQ(e.doc,a.head)==Hhe(Eo(l,0)))return{changes:{from:a.head-l.length,to:a.head+l.length},range:qe.cursor(a.head-l.length)}}return{range:i=a}});return i||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},dHe=[{key:"Backspace",run:uHe}];function hHe(e,t){let n=Khe(e,e.selection.main.head),r=n.brackets||ox.brackets;for(let i of r){let s=Hhe(Eo(i,0));if(t==i)return s==i?gHe(e,i,r.indexOf(i+i+i)>-1,n):OHe(e,i,s,n.before||ox.before);if(t==s&&Jhe(e,e.selection.main.from))return pHe(e,i,s)}return null}function Jhe(e,t){let n=!1;return e.field(Zhe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function iQ(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Mu(Eo(n,0)))}function fHe(e,t){let n=e.sliceString(t-2,t);return Mu(Eo(n,0))==n.length?n:n.slice(1)}function OHe(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:Dp.of(a.to+t.length),range:qe.range(a.anchor+t.length,a.head+t.length)};let o=iQ(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:Dp.of(a.head+t.length),range:qe.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function pHe(e,t,n){let r=null,i=e.changeByRange(s=>s.empty&&iQ(e.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:qe.cursor(s.head+n.length)}:r={range:s});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function gHe(e,t,n,r){let i=r.stringPrefixes||ox.stringPrefixes,s=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:Dp.of(o.to+t.length),range:qe.range(o.anchor+t.length,o.head+t.length)};let l=o.head,c=iQ(e.doc,l),u;if(c==t){if(RV(e,l))return{changes:{insert:t+t,from:l},effects:Dp.of(l+t.length),range:qe.cursor(l+t.length)};if(Jhe(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:qe.cursor(l+h.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=AV(e,l-2*t.length,i))>-1&&RV(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Dp.of(l+t.length),range:qe.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=_i.Word&&AV(e,l,i)>-1&&!mHe(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Dp.of(l+t.length),range:qe.cursor(l+t.length)}}return{range:s=o}});return s?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function RV(e,t){let n=xr(e).resolveInner(t+1);return n.parent&&n.from==t}function mHe(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 AV(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=_i.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))!=_i.Word)return s}return-1}function vHe(e={}){return[BZe,Ao,Ys.of(e),VZe,wHe,Yhe]}const efe=[{key:"Ctrl-Space",run:QV},{mac:"Alt-`",run:QV},{key:"Escape",run:UZe},{key:"ArrowDown",run:tk(!0)},{key:"ArrowUp",run:tk(!1)},{key:"PageDown",run:tk(!0,"page")},{key:"PageUp",run:tk(!1,"page")},{key:"Enter",run:qZe}],wHe=Yh.highest(Hg.computeN([Ys],e=>e.facet(Ys).defaultKeymap?[efe]:[]));class DP{static create(t,n,r,i,s){let a=i+(i<<8)+t+(n<<4)|0;return new DP(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=[[Pn.contextHash,i]]}addChild(t,n){t.prop(Pn.contextHash)!=this.hash&&(t=new cr(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 cr(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,s,a)=>new cr($s.none,i,s,a,this.hashProp)})}}var mt;(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"})(mt||(mt={}));class bHe{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}class yHe{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 $b(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 XV(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==mt.OrderedList?IN:DN)(n,t,!1);return r>0&&(e.type!=mt.BulletList||XN(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const tfe={[mt.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(hr(mt.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(mc(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[mt.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[mt.OrderedList]:XV,[mt.BulletList]:XV,[mt.Document](){return!0}};function mc(e){return e==32||e==9||e==10||e==13}function $b(e,t=0){for(;t<e.length&&mc(e.charCodeAt(t));)t++;return t}function DV(e,t,n){for(;t>n&&mc(e.charCodeAt(t-1));)t--;return t}function nfe(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 rfe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function XN(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(!mc(s))return-1}return n&&e.next==45&&afe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(ufe.SetextHeading)>-1||r<3?-1:1}function ife(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function DN(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||mc(e.text.charCodeAt(e.pos+1)))&&(!n||ife(t,mt.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function IN(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&&!mc(e.text.charCodeAt(r+1))||n&&!ife(t,mt.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function sfe(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 afe(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&&mc(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const PD=/^[ \t]*$/,ofe=/-->/,lfe=/\?>/,_D=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,ofe],[/^\s*<\?/,lfe],[/^\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,PD],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,PD]];function cfe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,s=_D.length-(n?1:0);i<s;i++)if(_D[i][0].test(r))return i;return-1}function IV(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 up(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==mt.CodeText?e[r].to=n:e.push(hr(mt.CodeText,t,n))}const nk={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(up(a,i,s);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){up(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==mt.CodeText?up(a,c.from,c.to):a.push(c);o=[]}up(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&&up(a,l,s)}}return o.length&&(o=o.filter(l=>l.type!=mt.CodeText),o.length&&(t.markers=o.concat(t.markers))),e.addNode(e.buffer.writeElements(a,-i).finish(mt.CodeBlock,s-i),i),!0},FencedCode(e,t){let n=nfe(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,s=n-t.pos,a=t.skipSpace(n),o=DV(t.text,t.text.length,a),l=[hr(mt.CodeMark,r,r+s)];a<o&&l.push(hr(mt.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(hr(mt.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||up(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&&up(l,d,h)}}return e.addNode(e.buffer.writeElements(l,-r).finish(mt.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=rfe(t);return n<0?!1:(e.startContext(mt.Blockquote,t.pos),e.addNode(mt.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(XN(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(mt.HorizontalRule,n),!0},BulletList(e,t){let n=DN(t,e,!1);if(n<0)return!1;e.block.type!=mt.BulletList&&e.startContext(mt.BulletList,t.basePos,t.next);let r=IV(t,t.pos+1);return e.startContext(mt.ListItem,t.basePos,r-t.baseIndent),e.addNode(mt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=IN(t,e,!1);if(n<0)return!1;e.block.type!=mt.OrderedList&&e.startContext(mt.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=IV(t,t.pos+n);return e.startContext(mt.ListItem,t.basePos,r-t.baseIndent),e.addNode(mt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=sfe(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,s=DV(t.text,t.text.length,r),a=s;for(;a>r&&t.text.charCodeAt(a-1)==t.next;)a--;(a==s||a==r||!mc(t.text.charCodeAt(a-1)))&&(a=t.text.length);let o=e.buffer.write(mt.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,a),i+n+1),-i);a<t.text.length&&o.write(mt.HeaderMark,a-r,s-r);let l=o.finish(mt.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=cfe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=_D[n][1],s=[],a=i!=PD;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==ofe?mt.CommentBlock:i==lfe?mt.ProcessingInstructionBlock:mt.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(s,-r).finish(o,l-r),r),!0},SetextHeading:void 0};class xHe{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+`
|
|
1078
|
+
`);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 Mhe(n,t?t.state.tabSize:4,t?Sg(t.state):2);if(a.eol())s.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let o=Lhe(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=cr.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:yZe,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new cr(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 cr(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Lhe(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 kN=Object.create(null),ix=[$s.none],yZe=new mv(ix),xV=[],SV=Object.create(null),qhe=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"]])qhe[e]=Whe(kN,t);class Uhe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),qhe)}resolve(t){return t?this.table[t]||(this.table[t]=Whe(this.extra,t)):0}}const xZe=new Uhe(kN);function fR(e,t){xV.indexOf(e)>-1||(xV.push(e),console.warn(t))}function Whe(e,t){let n=[];for(let o of t.split(" ")){let l=[];for(let c of o.split(".")){let u=e[c]||P[c];u?typeof u=="function"?l.length?l=l.map(u):fR(c,`Modifier ${c} used at start of tag`):l.length?fR(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:fR(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=SV[i];if(s)return s.id;let a=SV[i]=$s.define({id:ix.length,name:r,props:[Qr({[r]:n})]});return ix.push(a),a.id}function SZe(e,t){let n=$s.define({id:ix.length,name:"Document",props:[Gf.add(()=>e),Li.add(()=>r=>t.getIndent(r))],top:!0});return ix.push(n),n}mi.RTL,mi.LTR;function Ze(e){return new Or(nt.define(e))}function gf(e){return Ae(()=>Promise.resolve().then(()=>Hst),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const $Ze=[Pe.of({name:"C",extensions:["c","h","ino"],load(){return Ae(()=>Promise.resolve().then(()=>OB),void 0,import.meta.url).then(e=>e.cpp())}}),Pe.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return Ae(()=>Promise.resolve().then(()=>OB),void 0,import.meta.url).then(e=>e.cpp())}}),Pe.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return gf("Cassandra")}}),Pe.of({name:"CSS",extensions:["css"],load(){return Ae(()=>Promise.resolve().then(()=>uJe),void 0,import.meta.url).then(e=>e.css())}}),Pe.of({name:"Go",extensions:["go"],load(){return Ae(()=>import("./index-lEoaSpWQ.js"),__vite__mapDeps([5,1,2]),import.meta.url).then(e=>e.go())}}),Pe.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return Ae(()=>Promise.resolve().then(()=>tet),void 0,import.meta.url).then(e=>e.html())}}),Pe.of({name:"Java",extensions:["java"],load(){return Ae(()=>Promise.resolve().then(()=>tat),void 0,import.meta.url).then(e=>e.java())}}),Pe.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Ae(()=>Promise.resolve().then(()=>ik),void 0,import.meta.url).then(e=>e.javascript())}}),Pe.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Ae(()=>Promise.resolve().then(()=>ltt),void 0,import.meta.url).then(e=>e.json())}}),Pe.of({name:"JSX",extensions:["jsx"],load(){return Ae(()=>Promise.resolve().then(()=>ik),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Pe.of({name:"LESS",extensions:["less"],load(){return Ae(()=>Promise.resolve().then(()=>$et),void 0,import.meta.url).then(e=>e.less())}}),Pe.of({name:"Liquid",extensions:["liquid"],load(){return Ae(()=>Promise.resolve().then(()=>zlt),void 0,import.meta.url).then(e=>e.liquid())}}),Pe.of({name:"MariaDB SQL",load(){return gf("MariaSQL")}}),Pe.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Ae(()=>Promise.resolve().then(()=>het),void 0,import.meta.url).then(e=>e.markdown())}}),Pe.of({name:"MS SQL",load(){return gf("MSSQL")}}),Pe.of({name:"MySQL",load(){return gf("MySQL")}}),Pe.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return Ae(()=>Promise.resolve().then(()=>mlt),void 0,import.meta.url).then(e=>e.php())}}),Pe.of({name:"PLSQL",extensions:["pls"],load(){return gf("PLSQL")}}),Pe.of({name:"PostgreSQL",load(){return gf("PostgreSQL")}}),Pe.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return Ae(()=>Promise.resolve().then(()=>zit),void 0,import.meta.url).then(e=>e.python())}}),Pe.of({name:"Rust",extensions:["rs"],load(){return Ae(()=>Promise.resolve().then(()=>yat),void 0,import.meta.url).then(e=>e.rust())}}),Pe.of({name:"Sass",extensions:["sass"],load(){return Ae(()=>Promise.resolve().then(()=>CY),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),Pe.of({name:"SCSS",extensions:["scss"],load(){return Ae(()=>Promise.resolve().then(()=>CY),void 0,import.meta.url).then(e=>e.sass())}}),Pe.of({name:"SQL",extensions:["sql"],load(){return gf("StandardSQL")}}),Pe.of({name:"SQLite",load(){return gf("SQLite")}}),Pe.of({name:"TSX",extensions:["tsx"],load(){return Ae(()=>Promise.resolve().then(()=>ik),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Pe.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Ae(()=>Promise.resolve().then(()=>ik),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Pe.of({name:"WebAssembly",extensions:["wat","wast"],load(){return Ae(()=>Promise.resolve().then(()=>Ult),void 0,import.meta.url).then(e=>e.wast())}}),Pe.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return Ae(()=>Promise.resolve().then(()=>lst),void 0,import.meta.url).then(e=>e.xml())}}),Pe.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return Ae(()=>import("./index-C4RcIL0i.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>e.yaml())}}),Pe.of({name:"APL",extensions:["dyalog","apl"],load(){return Ae(()=>Promise.resolve().then(()=>vdt),void 0,import.meta.url).then(e=>Ze(e.apl))}}),Pe.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return Ae(()=>Promise.resolve().then(()=>wdt),void 0,import.meta.url).then(e=>Ze(e.asciiArmor))}}),Pe.of({name:"ASN.1",extensions:["asn","asn1"],load(){return Ae(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Ze(e.asn1({})))}}),Pe.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return Ae(()=>Promise.resolve().then(()=>$dt),void 0,import.meta.url).then(e=>Ze(e.asterisk))}}),Pe.of({name:"Brainfuck",extensions:["b","bf"],load(){return Ae(()=>Promise.resolve().then(()=>Tdt),void 0,import.meta.url).then(e=>Ze(e.brainfuck))}}),Pe.of({name:"Cobol",extensions:["cob","cpy"],load(){return Ae(()=>Promise.resolve().then(()=>eht),void 0,import.meta.url).then(e=>Ze(e.cobol))}}),Pe.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.csharp))}}),Pe.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return Ae(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ze(e.clojure))}}),Pe.of({name:"ClojureScript",extensions:["cljs"],load(){return Ae(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ze(e.clojure))}}),Pe.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return Ae(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Ze(e.gss))}}),Pe.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return Ae(()=>Promise.resolve().then(()=>Gdt),void 0,import.meta.url).then(e=>Ze(e.cmake))}}),Pe.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return Ae(()=>Promise.resolve().then(()=>fht),void 0,import.meta.url).then(e=>Ze(e.coffeeScript))}}),Pe.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return Ae(()=>Promise.resolve().then(()=>wht),void 0,import.meta.url).then(e=>Ze(e.commonLisp))}}),Pe.of({name:"Cypher",extensions:["cyp","cypher"],load(){return Ae(()=>Promise.resolve().then(()=>Fht),void 0,import.meta.url).then(e=>Ze(e.cypher))}}),Pe.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return Ae(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Ze(e.cython))}}),Pe.of({name:"Crystal",extensions:["cr"],load(){return Ae(()=>Promise.resolve().then(()=>Eht),void 0,import.meta.url).then(e=>Ze(e.crystal))}}),Pe.of({name:"D",extensions:["d"],load(){return Ae(()=>Promise.resolve().then(()=>Wht),void 0,import.meta.url).then(e=>Ze(e.d))}}),Pe.of({name:"Dart",extensions:["dart"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.dart))}}),Pe.of({name:"diff",extensions:["diff","patch"],load(){return Ae(()=>Promise.resolve().then(()=>Ght),void 0,import.meta.url).then(e=>Ze(e.diff))}}),Pe.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return Ae(()=>Promise.resolve().then(()=>ift),void 0,import.meta.url).then(e=>Ze(e.dockerFile))}}),Pe.of({name:"DTD",extensions:["dtd"],load(){return Ae(()=>Promise.resolve().then(()=>oft),void 0,import.meta.url).then(e=>Ze(e.dtd))}}),Pe.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return Ae(()=>Promise.resolve().then(()=>hft),void 0,import.meta.url).then(e=>Ze(e.dylan))}}),Pe.of({name:"EBNF",load(){return Ae(()=>Promise.resolve().then(()=>fft),void 0,import.meta.url).then(e=>Ze(e.ebnf))}}),Pe.of({name:"ECL",extensions:["ecl"],load(){return Ae(()=>Promise.resolve().then(()=>yft),void 0,import.meta.url).then(e=>Ze(e.ecl))}}),Pe.of({name:"edn",extensions:["edn"],load(){return Ae(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ze(e.clojure))}}),Pe.of({name:"Eiffel",extensions:["e"],load(){return Ae(()=>Promise.resolve().then(()=>Pft),void 0,import.meta.url).then(e=>Ze(e.eiffel))}}),Pe.of({name:"Elm",extensions:["elm"],load(){return Ae(()=>Promise.resolve().then(()=>Nft),void 0,import.meta.url).then(e=>Ze(e.elm))}}),Pe.of({name:"Erlang",extensions:["erl"],load(){return Ae(()=>Promise.resolve().then(()=>lOt),void 0,import.meta.url).then(e=>Ze(e.erlang))}}),Pe.of({name:"Esper",load(){return Ae(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Ze(e.esper))}}),Pe.of({name:"Factor",extensions:["factor"],load(){return Ae(()=>Promise.resolve().then(()=>cOt),void 0,import.meta.url).then(e=>Ze(e.factor))}}),Pe.of({name:"FCL",load(){return Ae(()=>Promise.resolve().then(()=>OOt),void 0,import.meta.url).then(e=>Ze(e.fcl))}}),Pe.of({name:"Forth",extensions:["forth","fth","4th"],load(){return Ae(()=>Promise.resolve().then(()=>mOt),void 0,import.meta.url).then(e=>Ze(e.forth))}}),Pe.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return Ae(()=>Promise.resolve().then(()=>$Ot),void 0,import.meta.url).then(e=>Ze(e.fortran))}}),Pe.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return Ae(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ze(e.fSharp))}}),Pe.of({name:"Gas",extensions:["s"],load(){return Ae(()=>Promise.resolve().then(()=>TOt),void 0,import.meta.url).then(e=>Ze(e.gas))}}),Pe.of({name:"Gherkin",extensions:["feature"],load(){return Ae(()=>Promise.resolve().then(()=>POt),void 0,import.meta.url).then(e=>Ze(e.gherkin))}}),Pe.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return Ae(()=>Promise.resolve().then(()=>NOt),void 0,import.meta.url).then(e=>Ze(e.groovy))}}),Pe.of({name:"Haskell",extensions:["hs"],load(){return Ae(()=>Promise.resolve().then(()=>GOt),void 0,import.meta.url).then(e=>Ze(e.haskell))}}),Pe.of({name:"Haxe",extensions:["hx"],load(){return Ae(()=>Promise.resolve().then(()=>FZ),void 0,import.meta.url).then(e=>Ze(e.haxe))}}),Pe.of({name:"HXML",extensions:["hxml"],load(){return Ae(()=>Promise.resolve().then(()=>FZ),void 0,import.meta.url).then(e=>Ze(e.hxml))}}),Pe.of({name:"HTTP",load(){return Ae(()=>Promise.resolve().then(()=>Opt),void 0,import.meta.url).then(e=>Ze(e.http))}}),Pe.of({name:"IDL",extensions:["pro"],load(){return Ae(()=>Promise.resolve().then(()=>ypt),void 0,import.meta.url).then(e=>Ze(e.idl))}}),Pe.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return Ae(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Ze(e.jsonld))}}),Pe.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return Ae(()=>Promise.resolve().then(()=>kpt),void 0,import.meta.url).then(e=>Ze(e.jinja2))}}),Pe.of({name:"Julia",extensions:["jl"],load(){return Ae(()=>Promise.resolve().then(()=>Zpt),void 0,import.meta.url).then(e=>Ze(e.julia))}}),Pe.of({name:"Kotlin",extensions:["kt","kts"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.kotlin))}}),Pe.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return Ae(()=>Promise.resolve().then(()=>egt),void 0,import.meta.url).then(e=>Ze(e.liveScript))}}),Pe.of({name:"Lua",extensions:["lua"],load(){return Ae(()=>Promise.resolve().then(()=>lgt),void 0,import.meta.url).then(e=>Ze(e.lua))}}),Pe.of({name:"mIRC",extensions:["mrc"],load(){return Ae(()=>Promise.resolve().then(()=>Egt),void 0,import.meta.url).then(e=>Ze(e.mirc))}}),Pe.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return Ae(()=>Promise.resolve().then(()=>ggt),void 0,import.meta.url).then(e=>Ze(e.mathematica))}}),Pe.of({name:"Modelica",extensions:["mo"],load(){return Ae(()=>Promise.resolve().then(()=>Lgt),void 0,import.meta.url).then(e=>Ze(e.modelica))}}),Pe.of({name:"MUMPS",extensions:["mps"],load(){return Ae(()=>Promise.resolve().then(()=>rmt),void 0,import.meta.url).then(e=>Ze(e.mumps))}}),Pe.of({name:"Mbox",extensions:["mbox"],load(){return Ae(()=>Promise.resolve().then(()=>_gt),void 0,import.meta.url).then(e=>Ze(e.mbox))}}),Pe.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return Ae(()=>Promise.resolve().then(()=>lmt),void 0,import.meta.url).then(e=>Ze(e.nginx))}}),Pe.of({name:"NSIS",extensions:["nsh","nsi"],load(){return Ae(()=>Promise.resolve().then(()=>cmt),void 0,import.meta.url).then(e=>Ze(e.nsis))}}),Pe.of({name:"NTriples",extensions:["nt","nq"],load(){return Ae(()=>Promise.resolve().then(()=>umt),void 0,import.meta.url).then(e=>Ze(e.ntriples))}}),Pe.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.objectiveC))}}),Pe.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.objectiveCpp))}}),Pe.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return Ae(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ze(e.oCaml))}}),Pe.of({name:"Octave",extensions:["m"],load(){return Ae(()=>Promise.resolve().then(()=>ymt),void 0,import.meta.url).then(e=>Ze(e.octave))}}),Pe.of({name:"Oz",extensions:["oz"],load(){return Ae(()=>Promise.resolve().then(()=>Amt),void 0,import.meta.url).then(e=>Ze(e.oz))}}),Pe.of({name:"Pascal",extensions:["p","pas"],load(){return Ae(()=>Promise.resolve().then(()=>Mmt),void 0,import.meta.url).then(e=>Ze(e.pascal))}}),Pe.of({name:"Perl",extensions:["pl","pm"],load(){return Ae(()=>Promise.resolve().then(()=>zmt),void 0,import.meta.url).then(e=>Ze(e.perl))}}),Pe.of({name:"Pig",extensions:["pig"],load(){return Ae(()=>Promise.resolve().then(()=>Umt),void 0,import.meta.url).then(e=>Ze(e.pig))}}),Pe.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return Ae(()=>Promise.resolve().then(()=>s0t),void 0,import.meta.url).then(e=>Ze(e.powerShell))}}),Pe.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return Ae(()=>Promise.resolve().then(()=>a0t),void 0,import.meta.url).then(e=>Ze(e.properties))}}),Pe.of({name:"ProtoBuf",extensions:["proto"],load(){return Ae(()=>Promise.resolve().then(()=>d0t),void 0,import.meta.url).then(e=>Ze(e.protobuf))}}),Pe.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return Ae(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([7,8]),import.meta.url).then(e=>Ze(e.pug))}}),Pe.of({name:"Puppet",extensions:["pp"],load(){return Ae(()=>Promise.resolve().then(()=>O0t),void 0,import.meta.url).then(e=>Ze(e.puppet))}}),Pe.of({name:"Q",extensions:["q"],load(){return Ae(()=>Promise.resolve().then(()=>x0t),void 0,import.meta.url).then(e=>Ze(e.q))}}),Pe.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return Ae(()=>Promise.resolve().then(()=>C0t),void 0,import.meta.url).then(e=>Ze(e.r))}}),Pe.of({name:"RPM Changes",load(){return Ae(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Ze(e.rpmChanges))}}),Pe.of({name:"RPM Spec",extensions:["spec"],load(){return Ae(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Ze(e.rpmSpec))}}),Pe.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return Ae(()=>Promise.resolve().then(()=>N0t),void 0,import.meta.url).then(e=>Ze(e.ruby))}}),Pe.of({name:"SAS",extensions:["sas"],load(){return Ae(()=>Promise.resolve().then(()=>q0t),void 0,import.meta.url).then(e=>Ze(e.sas))}}),Pe.of({name:"Scala",extensions:["scala"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.scala))}}),Pe.of({name:"Scheme",extensions:["scm","ss"],load(){return Ae(()=>Promise.resolve().then(()=>t1t),void 0,import.meta.url).then(e=>Ze(e.scheme))}}),Pe.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Ae(()=>Promise.resolve().then(()=>s1t),void 0,import.meta.url).then(e=>Ze(e.shell))}}),Pe.of({name:"Sieve",extensions:["siv","sieve"],load(){return Ae(()=>Promise.resolve().then(()=>u1t),void 0,import.meta.url).then(e=>Ze(e.sieve))}}),Pe.of({name:"Smalltalk",extensions:["st"],load(){return Ae(()=>Promise.resolve().then(()=>f1t),void 0,import.meta.url).then(e=>Ze(e.smalltalk))}}),Pe.of({name:"Solr",load(){return Ae(()=>Promise.resolve().then(()=>b1t),void 0,import.meta.url).then(e=>Ze(e.solr))}}),Pe.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return Ae(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ze(e.sml))}}),Pe.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return Ae(()=>Promise.resolve().then(()=>P1t),void 0,import.meta.url).then(e=>Ze(e.sparql))}}),Pe.of({name:"Spreadsheet",alias:["excel","formula"],load(){return Ae(()=>Promise.resolve().then(()=>_1t),void 0,import.meta.url).then(e=>Ze(e.spreadsheet))}}),Pe.of({name:"Squirrel",extensions:["nut"],load(){return Ae(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(e=>Ze(e.squirrel))}}),Pe.of({name:"Stylus",extensions:["styl"],load(){return Ae(()=>Promise.resolve().then(()=>Z1t),void 0,import.meta.url).then(e=>Ze(e.stylus))}}),Pe.of({name:"Swift",extensions:["swift"],load(){return Ae(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>Ze(e.swift))}}),Pe.of({name:"sTeX",load(){return Ae(()=>Promise.resolve().then(()=>_H),void 0,import.meta.url).then(e=>Ze(e.stex))}}),Pe.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return Ae(()=>Promise.resolve().then(()=>_H),void 0,import.meta.url).then(e=>Ze(e.stex))}}),Pe.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return Ae(()=>Promise.resolve().then(()=>YH),void 0,import.meta.url).then(e=>Ze(e.verilog))}}),Pe.of({name:"Tcl",extensions:["tcl"],load(){return Ae(()=>Promise.resolve().then(()=>bvt),void 0,import.meta.url).then(e=>Ze(e.tcl))}}),Pe.of({name:"Textile",extensions:["textile"],load(){return Ae(()=>Promise.resolve().then(()=>$vt),void 0,import.meta.url).then(e=>Ze(e.textile))}}),Pe.of({name:"TiddlyWiki",load(){return Ae(()=>Promise.resolve().then(()=>Gvt),void 0,import.meta.url).then(e=>Ze(e.tiddlyWiki))}}),Pe.of({name:"Tiki wiki",load(){return Ae(()=>Promise.resolve().then(()=>Kvt),void 0,import.meta.url).then(e=>Ze(e.tiki))}}),Pe.of({name:"TOML",extensions:["toml"],load(){return Ae(()=>Promise.resolve().then(()=>Jvt),void 0,import.meta.url).then(e=>Ze(e.toml))}}),Pe.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return Ae(()=>Promise.resolve().then(()=>nwt),void 0,import.meta.url).then(e=>Ze(e.troff))}}),Pe.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return Ae(()=>Promise.resolve().then(()=>bwt),void 0,import.meta.url).then(e=>Ze(e.ttcn))}}),Pe.of({name:"TTCN_CFG",extensions:["cfg"],load(){return Ae(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Ze(e.ttcnCfg))}}),Pe.of({name:"Turtle",extensions:["ttl"],load(){return Ae(()=>Promise.resolve().then(()=>Swt),void 0,import.meta.url).then(e=>Ze(e.turtle))}}),Pe.of({name:"Web IDL",extensions:["webidl"],load(){return Ae(()=>Promise.resolve().then(()=>gbt),void 0,import.meta.url).then(e=>Ze(e.webIDL))}}),Pe.of({name:"VB.NET",extensions:["vb"],load(){return Ae(()=>Promise.resolve().then(()=>Nwt),void 0,import.meta.url).then(e=>Ze(e.vb))}}),Pe.of({name:"VBScript",extensions:["vbs"],load(){return Ae(()=>Promise.resolve().then(()=>zwt),void 0,import.meta.url).then(e=>Ze(e.vbScript))}}),Pe.of({name:"Velocity",extensions:["vtl"],load(){return Ae(()=>Promise.resolve().then(()=>Uwt),void 0,import.meta.url).then(e=>Ze(e.velocity))}}),Pe.of({name:"Verilog",extensions:["v"],load(){return Ae(()=>Promise.resolve().then(()=>YH),void 0,import.meta.url).then(e=>Ze(e.verilog))}}),Pe.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return Ae(()=>Promise.resolve().then(()=>Kwt),void 0,import.meta.url).then(e=>Ze(e.vhdl))}}),Pe.of({name:"XQuery",extensions:["xy","xquery"],load(){return Ae(()=>Promise.resolve().then(()=>Tbt),void 0,import.meta.url).then(e=>Ze(e.xQuery))}}),Pe.of({name:"Yacas",extensions:["ys"],load(){return Ae(()=>Promise.resolve().then(()=>Ibt),void 0,import.meta.url).then(e=>Ze(e.yacas))}}),Pe.of({name:"Z80",extensions:["z80"],load(){return Ae(()=>Promise.resolve().then(()=>Lbt),void 0,import.meta.url).then(e=>Ze(e.z80))}}),Pe.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return Ae(()=>Promise.resolve().then(()=>w4),void 0,import.meta.url).then(e=>Ze(e.mscgen))}}),Pe.of({name:"Xù",extensions:["xu"],load(){return Ae(()=>Promise.resolve().then(()=>w4),void 0,import.meta.url).then(e=>Ze(e.xu))}}),Pe.of({name:"MsGenny",extensions:["msgenny"],load(){return Ae(()=>Promise.resolve().then(()=>w4),void 0,import.meta.url).then(e=>Ze(e.msgenny))}}),Pe.of({name:"Vue",extensions:["vue"],load(){return Ae(()=>Promise.resolve().then(()=>Hlt),void 0,import.meta.url).then(e=>e.vue())}}),Pe.of({name:"Angular Template",load(){return Ae(()=>Promise.resolve().then(()=>gct),void 0,import.meta.url).then(e=>e.angular())}})];class TN{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(Ghe(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 $V(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 kZe(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=$V(t)+$V(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function xS(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:kZe(t);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:t,validFor:n}:null}}function rQ(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 kV{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function qp(e){return e.selection.main.from}function Ghe(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 PN=$d.define();function TZe(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:qe.cursor(o.from+s+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const TV=new WeakMap;function PZe(e){if(!Array.isArray(e))return e;let t=TV.get(e);return t||TV.set(e,t=xS(e)),t}const AP=En.define(),sx=En.define();class _Ze{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=Eo(t,n),i=Mu(r);this.chars.push(r);let s=t.slice(n,n+i),a=s.toUpperCase();this.folded.push(Eo(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 w=Eo(t,0),y=Mu(w),T=y==t.length?0:-100;if(w!=n[0])if(w==r[0])T+=-200;else return null;return this.ret(T,[0,y])}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 w=0,y=Math.min(t.length,200);w<y&&c<l;){let T=Eo(t,w);(T==n[c]||T==r[c])&&(i[c++]=w),w+=Mu(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 w=0,y=Math.min(t.length,200),T=0;w<y&&d<l;){let x=Eo(t,w);o<0&&(u<l&&x==n[u]&&(s[u++]=w),f<l&&(x==n[f]||x==r[f]?(f==0&&(O=w),g=w+1,f++):f=0));let k,S=x<255?x>=48&&x<=57||x>=97&&x<=122?2:x>=65&&x<=90?1:0:(k=rN(x))!=k.toLowerCase()?1:k!=k.toUpperCase()?2:0;(!w||S==1&&m||T==0&&S!=0)&&(n[d]==x||r[d]==x&&(h=!0)?a[d++]=w:a.length&&(v=!1)),T=S,w+=Mu(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?Mu(Eo(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 CZe{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 Ys=Lt.define({combine(e){return kd(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:QZe,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=>PV(t(r),n(r)),optionClass:(t,n)=>r=>PV(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function PV(e,t){return e?t?e+" "+t:e:t}function QZe(e,t,n,r,i,s){let a=e.textDirection==mi.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 w=i.bottom-t.bottom;w>=g||w>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 EZe(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 OR(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 RZe{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(Ys);this.optionContent=EZe(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=OR(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(Ys).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:sx.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=OR(s.length,a,t.state.facet(Ys).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=OR(n.options.length,n.selected,this.view.state.facet(Ys).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=>No(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&&XZe(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(Ys).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 AZe(e,t){return n=>new RZe(n,e,t)}function XZe(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 _V(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function DZe(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(Ys);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 kV(d,c.source,u?u(d):[],1e9-n.length));else{let d=t.sliceDoc(c.from,c.to),h,f=s.filterStrict?new CZe(d):new _Ze(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 kV(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):_V(c.completion)>_V(o)&&(a[a.length-1]=c),o=c.completion}return a}class w0{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 w0(this.options,CV(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=DZe(t,n);if(!o.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ys).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 w0(o,CV(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:LZe,above:s.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new w0(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 w0(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class XP{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new XP(MZe,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ys),s=(r.override||n.languageDataAt("autocomplete",qp(n)).map(PZe)).map(l=>(this.active.find(u=>u.source==l)||new Kl(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(_N));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||s.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!IZe(s,this.active)||o?a=w0.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 Kl(l.source,0):l));for(let l of t.effects)l.is(Vhe)&&(a=a&&a.setSelected(l.value,this.id));return s==this.active&&a==this.open?this:new XP(s,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?FZe:NZe}}function IZe(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 FZe={"aria-autocomplete":"list"},NZe={};function CV(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const MZe=[];function jhe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(PN);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 Kl{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=jhe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Kl(i.source,0)),r&4&&i.state==0&&(i=new Kl(this.source,1)),i=i.updateFor(t,r);for(let s of t.effects)if(s.is(AP))i=new Kl(i.source,1,s.value);else if(s.is(sx))i=new Kl(i.source,0);else if(s.is(_N))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(qp(t.state))}}class z0 extends Kl{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=qp(t.state);if(o>a||!i||n&2&&(qp(t.startState)==this.from||o<this.limit))return new Kl(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return zZe(i.validFor,t.state,s,a)?new z0(this.source,this.explicit,l,i,s,a):i.update&&(i=i.update(i,s,a,new TN(t.state,o,!1)))?new z0(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:qp(t.state)):new Kl(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new z0(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Kl(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function zZe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Ghe(e,!0).test(i)}const _N=En.define({map(e,t){return e.map(n=>n.map(t))}}),Vhe=En.define(),Ao=ea.define({create(){return XP.start()},update(e,t){return e.update(t)},provide:e=>[vN.from(e,t=>t.tooltip),bt.contentAttributes.from(e,t=>t.attrs)]});function CN(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ao).active.find(i=>i.source==t.source);return r instanceof z0?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},TZe(e.state,n,r.from,r.to)),{annotations:PN.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const LZe=AZe(Ao,CN);function tk(e,t="option"){return n=>{let r=n.state.field(Ao,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ys).interactionDelay)return!1;let i=1,s;t=="page"&&(s=vhe(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:Vhe.of(o)}),!0}}const qZe=e=>{let t=e.state.field(Ao,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ys).interactionDelay?!1:CN(e,t.open.options[t.open.selected])},QV=e=>e.state.field(Ao,!1)?(e.dispatch({effects:AP.of(!0)}),!0):!1,UZe=e=>{let t=e.state.field(Ao,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:sx.of(null)}),!0)};class WZe{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const GZe=50,jZe=1e3,VZe=zi.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(Ao).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ao),n=e.state.facet(Ys);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ao)==t)return;let r=e.transactions.some(s=>{let a=jhe(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>GZe&&Date.now()-a.time>jZe){for(let o of a.context.abortListeners)try{o()}catch(l){No(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(AP)))&&(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(Ao);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(Ys).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=qp(t),r=new TN(t,n,e.explicit,this.view),i=new WZe(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:sx.of(null)}),No(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(Ys).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ys),r=this.view.state.field(Ao);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=qp(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(o,s.done.from+(s.active.explicit?0:1)),c=new z0(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 Kl(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:_N.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ao,!1);if(t&&t.tooltip&&this.view.state.facet(Ys).closeOnBlur){let n=t.open&&vhe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:sx.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:AP.of(!1)}),20),this.composing=0}}}),YZe=typeof navigator=="object"&&/Win/.test(navigator.platform),BZe=Yh.highest(bt.domEventHandlers({keydown(e,t){let n=t.state.field(Ao,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(YZe&&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&&CN(t,r),!1}})),Yhe=bt.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 ZZe{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class QN{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,fa.TrackDel),r=t.mapPos(this.to,1,fa.TrackDel);return n==null||r==null?null:new QN(this.field,n,r)}}class EN{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(vv);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 QN(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 ZZe(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 EN(r,i)}}let HZe=zt.widget({widget:new class extends su{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),KZe=zt.mark({class:"cm-snippetField"});class bv{constructor(t,n){this.ranges=t,this.active=n,this.deco=zt.set(t.map(r=>(r.from==r.to?HZe:KZe).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 bv(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 SS=En.define({map(e,t){return e&&e.map(t)}}),JZe=En.define(),ax=ea.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(SS))return n.value;if(n.is(JZe)&&e)return new bv(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=>bt.decorations.from(e,t=>t?t.deco:zt.none)});function RN(e,t){return qe.create(e.filter(n=>n.field==t).map(n=>qe.range(n.from,n.to)))}function eHe(e){let t=EN.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:Tr.of(a)},scrollIntoView:!0,annotations:r?[PN.of(r),Ss.userEvent.of("input.complete")]:void 0};if(o.length&&(c.selection=RN(o,0)),o.some(u=>u.field>0)){let u=new bv(o,0),d=c.effects=[SS.of(u)];n.state.field(ax,!1)===void 0&&d.push(En.appendConfig.of([ax,sHe,aHe,Yhe]))}n.dispatch(n.state.update(c))}}function Bhe(e){return({state:t,dispatch:n})=>{let r=t.field(ax,!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:RN(r.ranges,i),effects:SS.of(s?null:new bv(r.ranges,i)),scrollIntoView:!0})),!0}}const tHe=({state:e,dispatch:t})=>e.field(ax,!1)?(t(e.update({effects:SS.of(null)})),!0):!1,nHe=Bhe(1),rHe=Bhe(-1),iHe=[{key:"Tab",run:nHe,shift:rHe},{key:"Escape",run:tHe}],EV=Lt.define({combine(e){return e.length?e[0]:iHe}}),sHe=Yh.highest(Hg.compute([EV],e=>e.facet(EV)));function fi(e,t){return Object.assign(Object.assign({},t),{apply:eHe(e)})}const aHe=bt.domEventHandlers({mousedown(e,t){let n=t.state.field(ax,!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:RN(n.ranges,i.field),effects:SS.of(n.ranges.some(s=>s.field>i.field)?new bv(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),ox={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Dp=En.define({map(e,t){let n=t.mapPos(e,-1,fa.TrackAfter);return n??void 0}}),AN=new class extends vg{};AN.startSide=1;AN.endSide=-1;const Zhe=ea.define({create(){return vr.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(Dp)&&(e=e.update({add:[AN.range(n.value,n.value+1)]}));return e}});function oHe(){return[cHe,Zhe]}const pR="()[]{}<>«»»«[]{}";function Hhe(e){for(let t=0;t<pR.length;t+=2)if(pR.charCodeAt(t)==e)return pR.charAt(t+1);return rN(e<128?e:e+1)}function Khe(e,t){return e.languageDataAt("closeBrackets",t)[0]||ox}const lHe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),cHe=bt.inputHandler.of((e,t,n,r)=>{if((lHe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Mu(Eo(r,0))==1||t!=i.from||n!=i.to)return!1;let s=hHe(e.state,r);return s?(e.dispatch(s),!0):!1}),uHe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Khe(e,e.selection.main.head).brackets||ox.brackets,i=null,s=e.changeByRange(a=>{if(a.empty){let o=fHe(e.doc,a.head);for(let l of r)if(l==o&&iQ(e.doc,a.head)==Hhe(Eo(l,0)))return{changes:{from:a.head-l.length,to:a.head+l.length},range:qe.cursor(a.head-l.length)}}return{range:i=a}});return i||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},dHe=[{key:"Backspace",run:uHe}];function hHe(e,t){let n=Khe(e,e.selection.main.head),r=n.brackets||ox.brackets;for(let i of r){let s=Hhe(Eo(i,0));if(t==i)return s==i?gHe(e,i,r.indexOf(i+i+i)>-1,n):OHe(e,i,s,n.before||ox.before);if(t==s&&Jhe(e,e.selection.main.from))return pHe(e,i,s)}return null}function Jhe(e,t){let n=!1;return e.field(Zhe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function iQ(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Mu(Eo(n,0)))}function fHe(e,t){let n=e.sliceString(t-2,t);return Mu(Eo(n,0))==n.length?n:n.slice(1)}function OHe(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:Dp.of(a.to+t.length),range:qe.range(a.anchor+t.length,a.head+t.length)};let o=iQ(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:Dp.of(a.head+t.length),range:qe.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function pHe(e,t,n){let r=null,i=e.changeByRange(s=>s.empty&&iQ(e.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:qe.cursor(s.head+n.length)}:r={range:s});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function gHe(e,t,n,r){let i=r.stringPrefixes||ox.stringPrefixes,s=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:Dp.of(o.to+t.length),range:qe.range(o.anchor+t.length,o.head+t.length)};let l=o.head,c=iQ(e.doc,l),u;if(c==t){if(RV(e,l))return{changes:{insert:t+t,from:l},effects:Dp.of(l+t.length),range:qe.cursor(l+t.length)};if(Jhe(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:qe.cursor(l+h.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=AV(e,l-2*t.length,i))>-1&&RV(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Dp.of(l+t.length),range:qe.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=_i.Word&&AV(e,l,i)>-1&&!mHe(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Dp.of(l+t.length),range:qe.cursor(l+t.length)}}return{range:s=o}});return s?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function RV(e,t){let n=xr(e).resolveInner(t+1);return n.parent&&n.from==t}function mHe(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 AV(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=_i.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))!=_i.Word)return s}return-1}function vHe(e={}){return[BZe,Ao,Ys.of(e),VZe,wHe,Yhe]}const efe=[{key:"Ctrl-Space",run:QV},{mac:"Alt-`",run:QV},{key:"Escape",run:UZe},{key:"ArrowDown",run:tk(!0)},{key:"ArrowUp",run:tk(!1)},{key:"PageDown",run:tk(!0,"page")},{key:"PageUp",run:tk(!1,"page")},{key:"Enter",run:qZe}],wHe=Yh.highest(Hg.computeN([Ys],e=>e.facet(Ys).defaultKeymap?[efe]:[]));class DP{static create(t,n,r,i,s){let a=i+(i<<8)+t+(n<<4)|0;return new DP(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=[[Pn.contextHash,i]]}addChild(t,n){t.prop(Pn.contextHash)!=this.hash&&(t=new cr(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 cr(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,s,a)=>new cr($s.none,i,s,a,this.hashProp)})}}var mt;(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"})(mt||(mt={}));class bHe{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}class yHe{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 $b(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 XV(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==mt.OrderedList?IN:DN)(n,t,!1);return r>0&&(e.type!=mt.BulletList||XN(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const tfe={[mt.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(hr(mt.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(mc(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[mt.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[mt.OrderedList]:XV,[mt.BulletList]:XV,[mt.Document](){return!0}};function mc(e){return e==32||e==9||e==10||e==13}function $b(e,t=0){for(;t<e.length&&mc(e.charCodeAt(t));)t++;return t}function DV(e,t,n){for(;t>n&&mc(e.charCodeAt(t-1));)t--;return t}function nfe(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 rfe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function XN(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(!mc(s))return-1}return n&&e.next==45&&afe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(ufe.SetextHeading)>-1||r<3?-1:1}function ife(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function DN(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||mc(e.text.charCodeAt(e.pos+1)))&&(!n||ife(t,mt.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function IN(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&&!mc(e.text.charCodeAt(r+1))||n&&!ife(t,mt.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function sfe(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 afe(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&&mc(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const PD=/^[ \t]*$/,ofe=/-->/,lfe=/\?>/,_D=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,ofe],[/^\s*<\?/,lfe],[/^\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,PD],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,PD]];function cfe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,s=_D.length-(n?1:0);i<s;i++)if(_D[i][0].test(r))return i;return-1}function IV(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 up(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==mt.CodeText?e[r].to=n:e.push(hr(mt.CodeText,t,n))}const nk={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(up(a,i,s);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){up(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==mt.CodeText?up(a,c.from,c.to):a.push(c);o=[]}up(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&&up(a,l,s)}}return o.length&&(o=o.filter(l=>l.type!=mt.CodeText),o.length&&(t.markers=o.concat(t.markers))),e.addNode(e.buffer.writeElements(a,-i).finish(mt.CodeBlock,s-i),i),!0},FencedCode(e,t){let n=nfe(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,s=n-t.pos,a=t.skipSpace(n),o=DV(t.text,t.text.length,a),l=[hr(mt.CodeMark,r,r+s)];a<o&&l.push(hr(mt.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(hr(mt.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||up(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&&up(l,d,h)}}return e.addNode(e.buffer.writeElements(l,-r).finish(mt.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=rfe(t);return n<0?!1:(e.startContext(mt.Blockquote,t.pos),e.addNode(mt.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(XN(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(mt.HorizontalRule,n),!0},BulletList(e,t){let n=DN(t,e,!1);if(n<0)return!1;e.block.type!=mt.BulletList&&e.startContext(mt.BulletList,t.basePos,t.next);let r=IV(t,t.pos+1);return e.startContext(mt.ListItem,t.basePos,r-t.baseIndent),e.addNode(mt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=IN(t,e,!1);if(n<0)return!1;e.block.type!=mt.OrderedList&&e.startContext(mt.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=IV(t,t.pos+n);return e.startContext(mt.ListItem,t.basePos,r-t.baseIndent),e.addNode(mt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=sfe(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,s=DV(t.text,t.text.length,r),a=s;for(;a>r&&t.text.charCodeAt(a-1)==t.next;)a--;(a==s||a==r||!mc(t.text.charCodeAt(a-1)))&&(a=t.text.length);let o=e.buffer.write(mt.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,a),i+n+1),-i);a<t.text.length&&o.write(mt.HeaderMark,a-r,s-r);let l=o.finish(mt.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=cfe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=_D[n][1],s=[],a=i!=PD;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==ofe?mt.CommentBlock:i==lfe?mt.ProcessingInstructionBlock:mt.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(s,-r).finish(o,l-r),r),!0},SetextHeading:void 0};class xHe{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+`
|
|
1079
1079
|
`+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)&&$b(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,hr(mt.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(wfe(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(hr(mt.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(mfe(t,$b(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=$b(t,this.pos),r=0;if(n>this.pos){let i=vfe(t,n,this.start);if(i){let s=gR(t,i.to-this.start);s>0&&(this.nextStage(i),r=s)}}return r||(r=gR(t,this.pos)),r>0&&r<t.length?r:-1}else return gR(t,this.pos)}}}function gR(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!mc(n))return-1}return t}class SHe{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:afe(n),s=n.next;if(i<0)return!1;let a=hr(mt.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,hr(s==61?mt.SetextHeading1:mt.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),a])),!0}finish(){return!1}}const ufe={LinkReference(e,t){return t.content.charCodeAt(0)==91?new xHe(t):null},SetextHeading(){return new SHe}},$He=[(e,t)=>sfe(t)>=0,(e,t)=>nfe(t)>=0,(e,t)=>rfe(t)>=0,(e,t)=>DN(t,e,!0)>=0,(e,t)=>IN(t,e,!0)>=0,(e,t)=>XN(t,e,!0)>=0,(e,t)=>cfe(t,e,!0)>=0],kHe={text:"",end:0};class THe{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new yHe,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=DP.create(mt.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new QHe(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 bHe(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+=`
|
|
1080
1080
|
`+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=bfe(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=kHe;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 "+mt[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==`
|
|
1081
1081
|
`?"":n;else{let i=n.indexOf(`
|
|
@@ -1310,7 +1310,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),ZO=tt,Br=Bt);const fu=
|
|
|
1310
1310
|
`?kt.useBR?"<br>":Bt:kt.tabReplace?Bt.replace(/\t/g,kt.tabReplace):Bt):tt}function Cn(tt,Bt,In){const Fr=Bt?ht[Bt]:In;tt.classList.add("hljs"),Fr&&tt.classList.add(Fr)}const Dn={"before:highlightElement":({el:tt})=>{kt.useBR&&(tt.innerHTML=tt.innerHTML.replace(/\n/g,"").replace(/<br[ /]*>/g,`
|
|
1311
1311
|
`))},"after:highlightElement":({result:tt})=>{kt.useBR&&(tt.value=tt.value.replace(/\n/g,"<br>"))}},B=/^(<[^>]+>|\t)+/gm,ae={"after:highlightElement":({result:tt})=>{kt.tabReplace&&(tt.value=tt.value.replace(B,Bt=>Bt.replace(/\t/g,kt.tabReplace)))}};function ee(tt){let Bt=null;const In=xn(tt);if(Kt(In))return;Yr("before:highlightElement",{el:tt,language:In}),Bt=tt;const Fr=Bt.textContent,Br=In?Rn(Fr,{language:In,ignoreIllegals:!0}):Ve(Fr);Yr("after:highlightElement",{el:tt,result:Br,text:Fr}),tt.innerHTML=Br.value,Cn(tt,In,Br.language),tt.result={language:Br.language,re:Br.relevance,relavance:Br.relevance},Br.second_best&&(tt.second_best={language:Br.second_best.language,re:Br.second_best.relevance,relavance:Br.second_best.relevance})}function te(tt){tt.useBR&&(gn("10.3.0","'useBR' will be removed entirely in v11.0"),gn("10.3.0","Please see https://github.com/highlightjs/highlight.js/issues/2559")),kt=ui(kt,tt)}const ie=()=>{if(ie.called)return;ie.called=!0,gn("10.6.0","initHighlighting() is deprecated. Use highlightAll() instead."),document.querySelectorAll("pre code").forEach(ee)};function oe(){gn("10.6.0","initHighlightingOnLoad() is deprecated. Use highlightAll() instead."),be=!0}let be=!1;function Xe(){if(document.readyState==="loading"){be=!0;return}document.querySelectorAll("pre code").forEach(ee)}function $e(){be&&Xe()}typeof window<"u"&&window.addEventListener&&window.addEventListener("DOMContentLoaded",$e,!1);function Qe(tt,Bt){let In=null;try{In=Bt(pe)}catch(Fr){if(gt("Language definition for '{}' could not be registered.".replace("{}",tt)),jn)gt(Fr);else throw Fr;In=ut}In.name||(In.name=tt),_e[tt]=In,In.rawDefinition=Bt.bind(null,pe),In.aliases&&Ot(In.aliases,{languageName:tt})}function Re(tt){delete _e[tt];for(const Bt of Object.keys(ht))ht[Bt]===tt&&delete ht[Bt]}function ot(){return Object.keys(_e)}function Qt(tt){gn("10.4.0","requireLanguage will be removed entirely in v11."),gn("10.4.0","Please see https://github.com/highlightjs/highlight.js/pull/2844");const Bt=At(tt);if(Bt)return Bt;throw new Error("The '{}' language is required, but not loaded.".replace("{}",tt))}function At(tt){return tt=(tt||"").toLowerCase(),_e[tt]||_e[ht[tt]]}function Ot(tt,{languageName:Bt}){typeof tt=="string"&&(tt=[tt]),tt.forEach(In=>{ht[In.toLowerCase()]=Bt})}function It(tt){const Bt=At(tt);return Bt&&!Bt.disableAutodetect}function Qn(tt){tt["before:highlightBlock"]&&!tt["before:highlightElement"]&&(tt["before:highlightElement"]=Bt=>{tt["before:highlightBlock"](Object.assign({block:Bt.el},Bt))}),tt["after:highlightBlock"]&&!tt["after:highlightElement"]&&(tt["after:highlightElement"]=Bt=>{tt["after:highlightBlock"](Object.assign({block:Bt.el},Bt))})}function di(tt){Qn(tt),tn.push(tt)}function Yr(tt,Bt){const In=tt;tn.forEach(function(Fr){Fr[In]&&Fr[In](Bt)})}function Ms(tt){return gn("10.2.0","fixMarkup will be removed entirely in v11.0"),gn("10.2.0","Please see https://github.com/highlightjs/highlight.js/issues/2534"),Pt(tt)}function BO(tt){return gn("10.7.0","highlightBlock will be removed entirely in v12.0"),gn("10.7.0","Please use highlightElement now."),ee(tt)}Object.assign(pe,{highlight:Rn,highlightAuto:Ve,highlightAll:Xe,fixMarkup:Ms,highlightElement:ee,highlightBlock:BO,configure:te,initHighlighting:ie,initHighlightingOnLoad:oe,registerLanguage:Qe,unregisterLanguage:Re,listLanguages:ot,getLanguage:At,registerAliases:Ot,requireLanguage:Qt,autoDetection:It,inherit:ui,addPlugin:di,vuePlugin:Xt(pe).VuePlugin}),pe.debugMode=function(){jn=!1},pe.safeMode=function(){jn=!0},pe.versionString=Ht;for(const tt in ue)typeof ue[tt]=="object"&&t(ue[tt]);return Object.assign(pe,ue),pe.addPlugin(Dn),pe.addPlugin(Tt),pe.addPlugin(ae),pe}({});return MA=He,MA}var zA={exports:{}},Jne;function Ntn(){return Jne||(Jne=1,function(e){(function(){var t;t=e.exports=i,t.format=i,t.vsprintf=r,typeof console<"u"&&typeof console.log=="function"&&(t.printf=n);function n(){console.log(i.apply(null,arguments))}function r(s,a){return i.apply(null,[s].concat(a))}function i(s){for(var a=1,o=[].slice.call(arguments),l=0,c=s.length,u="",d,h=!1,f,O,g=!1,m,v=function(){return o[a++]},w=function(){for(var y="";/\d/.test(s[l]);)y+=s[l++],d=s[l];return y.length>0?parseInt(y):null};l<c;++l)if(d=s[l],h)switch(h=!1,d=="."?(g=!1,d=s[++l]):d=="0"&&s[l+1]=="."?(g=!0,l+=2,d=s[l]):g=!0,m=w(),d){case"b":u+=parseInt(v(),10).toString(2);break;case"c":f=v(),typeof f=="string"||f instanceof String?u+=f:u+=String.fromCharCode(parseInt(f,10));break;case"d":u+=parseInt(v(),10);break;case"f":O=String(parseFloat(v()).toFixed(m||6)),u+=g?O:O.replace(/^0/,"");break;case"j":u+=JSON.stringify(v());break;case"o":u+="0"+parseInt(v(),10).toString(8);break;case"s":u+=v();break;case"x":u+="0x"+parseInt(v(),10).toString(16);break;case"X":u+="0x"+parseInt(v(),10).toString(16).toUpperCase();break;default:u+=d;break}else d==="%"?h=!0:u+=d;return u}})()}(zA)),zA.exports}var LA,ere;function Mtn(){if(ere)return LA;ere=1;var e=Ntn(),t=n(Error);LA=t,t.eval=n(EvalError),t.range=n(RangeError),t.reference=n(ReferenceError),t.syntax=n(SyntaxError),t.type=n(TypeError),t.uri=n(URIError),t.create=n;function n(r){return i.displayName=r.displayName||r.name,i;function i(s){return s&&(s=e.apply(null,arguments)),new r(s)}}return LA}var tre;function ztn(){if(tre)return mp;tre=1;var e=Ftn(),t=Mtn();mp.highlight=r,mp.highlightAuto=i,mp.registerLanguage=s,mp.listLanguages=a,mp.registerAlias=o,l.prototype.addText=d,l.prototype.addKeyword=c,l.prototype.addSublanguage=u,l.prototype.openNode=h,l.prototype.closeNode=f,l.prototype.closeAllNodes=g,l.prototype.finalize=g,l.prototype.toHTML=O;var n="hljs-";function r(m,v,w){var y=e.configure({}),T=w||{},x=T.prefix,k;if(typeof m!="string")throw t("Expected `string` for name, got `%s`",m);if(!e.getLanguage(m))throw t("Unknown language: `%s` is not registered",m);if(typeof v!="string")throw t("Expected `string` for value, got `%s`",v);if(x==null&&(x=n),e.configure({__emitter:l,classPrefix:x}),k=e.highlight(v,{language:m,ignoreIllegals:!0}),e.configure(y||{}),k.errorRaised)throw k.errorRaised;return{relevance:k.relevance,language:k.language,value:k.emitter.rootNode.children}}function i(m,v){var w=v||{},y=w.subset||e.listLanguages();w.prefix;var T=y.length,x=-1,k,S,Q,R;if(typeof m!="string")throw t("Expected `string` for value, got `%s`",m);for(S={relevance:0,language:null,value:[]},k={relevance:0,language:null,value:[]};++x<T;)R=y[x],e.getLanguage(R)&&(Q=r(R,m,v),Q.language=R,Q.relevance>S.relevance&&(S=Q),Q.relevance>k.relevance&&(S=k,k=Q));return S.language&&(k.secondBest=S),k}function s(m,v){e.registerLanguage(m,v)}function a(){return e.listLanguages()}function o(m,v){var w=m,y;v&&(w={},w[m]=v);for(y in w)e.registerAliases(w[y],{languageName:y})}function l(m){this.options=m,this.rootNode={children:[]},this.stack=[this.rootNode]}function c(m,v){this.openNode(v),this.addText(m),this.closeNode()}function u(m,v){var w=this.stack,y=w[w.length-1],T=m.rootNode.children,x=v?{type:"element",tagName:"span",properties:{className:[v]},children:T}:T;y.children=y.children.concat(x)}function d(m){var v=this.stack,w,y;m!==""&&(w=v[v.length-1],y=w.children[w.children.length-1],y&&y.type==="text"?y.value+=m:w.children.push({type:"text",value:m}))}function h(m){var v=this.stack,w=this.options.classPrefix+m,y=v[v.length-1],T={type:"element",tagName:"span",properties:{className:[w]},children:[]};y.children.push(T),v.push(T)}function f(){this.stack.pop()}function O(){return""}function g(){}return mp}var Ltn=ztn();const dTe=zn(Ltn);var $z=Itn(dTe,{});$z.registerLanguage=dTe.registerLanguage;const qtn={hljs:{display:"block",overflowX:"auto",padding:"0.5em",color:"#abb2bf",background:"#282c34"},"hljs-comment":{color:"#5c6370",fontStyle:"italic"},"hljs-quote":{color:"#5c6370",fontStyle:"italic"},"hljs-doctag":{color:"#c678dd"},"hljs-keyword":{color:"#c678dd"},"hljs-formula":{color:"#c678dd"},"hljs-section":{color:"#e06c75"},"hljs-name":{color:"#e06c75"},"hljs-selector-tag":{color:"#e06c75"},"hljs-deletion":{color:"#e06c75"},"hljs-subst":{color:"#e06c75"},"hljs-literal":{color:"#56b6c2"},"hljs-string":{color:"#98c379"},"hljs-regexp":{color:"#98c379"},"hljs-addition":{color:"#98c379"},"hljs-attribute":{color:"#98c379"},"hljs-meta-string":{color:"#98c379"},"hljs-built_in":{color:"#e6c07b"},"hljs-class .hljs-title":{color:"#e6c07b"},"hljs-attr":{color:"#d19a66"},"hljs-variable":{color:"#d19a66"},"hljs-template-variable":{color:"#d19a66"},"hljs-type":{color:"#d19a66"},"hljs-selector-class":{color:"#d19a66"},"hljs-selector-attr":{color:"#d19a66"},"hljs-selector-pseudo":{color:"#d19a66"},"hljs-number":{color:"#d19a66"},"hljs-symbol":{color:"#61aeee"},"hljs-bullet":{color:"#61aeee"},"hljs-link":{color:"#61aeee",textDecoration:"underline"},"hljs-meta":{color:"#61aeee"},"hljs-selector-id":{color:"#61aeee"},"hljs-title":{color:"#61aeee"},"hljs-emphasis":{fontStyle:"italic"},"hljs-strong":{fontWeight:"bold"}},Utn={armasm:dJt,bash:OJt,c:mJt,coffeescript:bJt,cpp:SJt,csharp:TJt,css:CJt,dart:RJt,dockerfile:DJt,dos:NJt,go:LJt,groovy:WJt,ini:VJt,java:ZJt,javascript:JJt,json:nen,kotlin:sen,latex:len,less:den,lua:Oen,makefile:men,markdown:ben,perl:Sen,php:Ten,plaintext:Cen,powershell:Ren,python:Den,r:Nen,ruby:Len,rust:Wen,scala:Ven,scss:Zen,sql:Jen,swift:ntn,typescript:stn,vbnet:ltn,xml:dtn,yaml:Otn};for(const[e,t]of Object.entries(Utn))$z.registerLanguage(e,t);const If=({code:e,language:t,header:n,flexDirection:r="column"})=>e?p.jsxs("div",{className:"mb-4 w-full",children:[p.jsx("span",{className:"mb-1 block text-ink-dim text-meta",children:n||"Code"}),p.jsx("div",{className:G("flex w-full whitespace-pre rounded-sm","max-h-80 w-full overflow-y-auto","[&_.react-syntax-highlighter-code-block_*]:font-mono!",r==="column-reverse"?"flex-col-reverse":"flex-col"),children:p.jsx($z,{language:t||"python",style:qtn,customStyle:{borderRadius:"6px",fontSize:"0.8125rem",width:"100%",padding:"0.75rem",margin:0},className:"react-syntax-highlighter-code-block",wrapLines:!0,wrapLongLines:!0,children:e})})]}):null,nre=/name=([^;,]+)/,Wtn=/[/\\]/,Sf=e=>{if(e.startsWith("data:image/")){const n=e.match(nre);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return"Pasted image"}return"Pasted image"}if(e.startsWith("data:")){const n=e.match(nre);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return"Pasted file"}return"Pasted file"}const t=e.split(Wtn);return t[t.length-1]},kz=b.memo(({file:e,onClick:t,conversationId:n})=>{const[r,i]=b.useState(!1),[s,a]=b.useState(!1),o=Gr(O=>O.setCanvasOpen),{setViewMode:l}=dr(),c=b.useCallback(async O=>{const g=Sf(O);if(Yf(g)){const{setFiles:m,setOpenTabs:v,setSelectedTab:w}=dr.getState(),y=O.startsWith("file://")?O.substring(7):O;try{const T=await window.api.readFile(y,"base64");if(T.success){const x=y,k={id:x,title:g,path:y,content:T.data,type:uo(O)},Q=dr.getState().conversations?.[n],R=Q?.files??[],_=Q?.openTabs??[],A=(()=>{const L=R.findIndex(z=>z.id===x);return L!==-1?[...R.slice(0,L),k,...R.slice(L+1)]:[...R,k]})();m(n,A);const I=_.some(L=>L.id===x)?_:[..._,{id:x,title:g}];v(n,I),w(n,x),o(!0),l(n,"documents")}}catch(T){console.error("Error processing spreadsheet file:",T)}}},[n,o,l]);b.useEffect(()=>{(async()=>{const g=dr.getState(),m=g.conversations?.[n];if(!m)return;const v=m.openTabs??[],w=m.files??[],y=Sf(e),T=e.startsWith("file://")?e.substring(7):e,x=e.startsWith("data:")?e:T;if(v.some(S=>S.id===x))if(e.startsWith("data:")){const S={id:x,title:y,path:x,content:e,type:uo(e),lastAgentModified:Date.now()},Q=w.findIndex(R=>R.id===x);if(Q!==-1){const R=[...w];R[Q]=S,g.setFiles(n,R)}}else try{const S=Yf(y)?"base64":"utf-8",Q=await window.api.readFile(T,S);if(Q.success){const R={id:x,title:y,path:T,content:Q.data,type:uo(e),lastAgentModified:Date.now()},_=w.findIndex(A=>A.id===x);if(_!==-1){const A=[...w];A[_]=R,g.setFiles(n,A)}}}catch(S){console.error(`Failed to auto-refresh file in canvas: ${T}`,S)}})()},[e,n]);const u=b.useCallback(async()=>{if(Yf(e)){await c(e);return}const O=Sf(e),g=y=>{y&&console.error("Error processing file:",y),t(e)},{setFiles:m,setOpenTabs:v,setSelectedTab:w}=dr.getState();if(e.startsWith("data:"))if(yO(O)){const y=e,T={id:y,title:O,path:y,content:e,type:uo(e)},k=dr.getState().conversations?.[n],S=k?.files??[],Q=k?.openTabs??[],R=(()=>{const E=S.findIndex(I=>I.id===y);return E!==-1?[...S.slice(0,E),T,...S.slice(E+1)]:[...S,T]})();m(n,R);const A=Q.some(E=>E.id===y)?Q:[...Q,{id:y,title:O}];v(n,A),w(n,y),o(!0),l(n,"documents")}else t(e);else{const y=e.startsWith("file://")?e.substring(7):e;try{const T=Yf(O)?"base64":"utf-8",x=await window.api.readFile(y,T);if(x.success&&yO(O)){const S=y,Q={id:S,title:O,path:y,content:x.data,type:uo(e)},_=dr.getState().conversations?.[n],A=_?.files??[],E=_?.openTabs??[],I=(()=>{const V=A.findIndex(q=>q.id===S);return V!==-1?[...A.slice(0,V),Q,...A.slice(V+1)]:[...A,Q]})();m(n,I);const z=E.some(V=>V.id===S)?E:[...E,{id:S,title:O}];v(n,z),w(n,S),o(!0),l(n,"documents");return}const k=!x.success&&x.error?x.error instanceof Error?x.error.message:String(x.error):"Unknown error reading file";return g(k)}catch(T){const x=T instanceof Error?T.message:String(T??"Unknown error reading file");return g(x)}}},[e,t,o,l,n,c]),d=e.startsWith("data:image/"),h=!e.startsWith("data:")&&!e.startsWith("http"),f=e.startsWith("file://")?e.substring(7):e;return d?p.jsx("div",{className:"group relative inline-block max-w-full",children:r?p.jsx(K7,{name:Sf(e)}):p.jsx("button",{type:"button",className:"block max-w-full cursor-pointer",onClick:u,title:`Click to open ${Sf(e)}`,children:p.jsx(Wue,{children:p.jsx("img",{src:e,alt:Sf(e),className:G("max-h-[240px] max-w-full object-contain",s?"opacity-100":"opacity-0"),onLoad:()=>a(!0),onError:()=>i(!0)})})})}):p.jsxs("div",{className:G("group relative flex w-fit max-w-full items-center gap-2.5 rounded-sm","border border-hairline bg-surface px-3 py-2","transition-colors duration-fast ease-out-quart hover:bg-elevated"),children:[p.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2.5 text-left",onClick:u,title:`Click to open ${Sf(e)}`,children:[p.jsx(av,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),p.jsx("span",{className:"truncate text-body-sm text-ink",children:Sf(e)})]}),h&&p.jsx("div",{className:"file-actions-menu invisible opacity-0 transition-[opacity,visibility] duration-fast ease-out-quart group-hover:visible group-hover:opacity-100",children:p.jsx(YC,{filePath:f,tooltip:"File actions","aria-label":"File actions",onShowInCanvas:u})})]})});kz.displayName="FileAttachment";const $2=({log:e})=>!e||e==="[No logger output]"?null:p.jsxs("div",{className:"mb-4 w-full",children:[p.jsx("span",{className:"mb-1 block text-ink-dim text-meta",children:"Logs"}),p.jsx("pre",{className:"flex max-h-[200px] w-full flex-col-reverse overflow-auto whitespace-pre-wrap rounded-sm border border-hairline bg-sunken p-3 font-mono text-ink-muted text-mono-sm",children:e})]}),Gtn=Oe.memo(({content:e,styleProps:t})=>e?p.jsx("div",{className:"mb-0",children:p.jsx(Zg,{content:e,styleProps:t})}):null),IF=({isUser:e,content:t,className:n,messageId:r,agentId:i,inline:s=!1,timestamp:a})=>{const[o,l]=b.useState(!1),{hasRadientApiKey:c,isUnavailable:u}=H8(),{playSpeech:d,stopSpeech:h,replaySpeech:f,loadingMessageId:O,playingMessageId:g,audioCache:m}=Vve(),v=g===r,w=O===r,y=m.has(r),T=c&&!u,x=u?"Text to speech is unavailable while Local Operator is offline":"Sign in to Radient in the settings page to enable text to speech",k=t,S=async()=>{try{t&&(await navigator.clipboard.writeText(t),l(!0),setTimeout(()=>l(!1),2e3))}catch(E){console.error("Failed to copy text:",E)}},Q=()=>{i&&t&&d(r,i,t)},R=()=>{f(r)},_=()=>{h()},A="text-ink-dim hover:bg-accent-wash hover:text-accent";return p.jsxs("div",{className:G("flex items-center gap-0.5",s?"w-auto":G("message-controls absolute -top-2 right-0 z-10 h-8 rounded-md border border-hairline bg-elevated px-1","pointer-events-none opacity-0 transition-opacity duration-fast ease-out-quart","group-hover:pointer-events-auto group-hover:opacity-100"),n),children:[a&&p.jsx(B7,{timestamp:a,className:"px-1"}),k&&p.jsxs("div",{className:"flex items-center",children:[p.jsx(vt,{content:o?"Copied":"Copy message",side:"top",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":o?"Copied":"Copy message",className:A,onClick:S,children:p.jsx(Vg,{})})}),!e&&(v?p.jsx(vt,{content:"Stop",side:"top",children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Stop speech",className:A,onClick:_,children:p.jsx(O1,{})})}):p.jsx(vt,{content:T?w?"Loading":y?"Replay speech":"Speak aloud":x,side:"top",children:p.jsx("span",{children:p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":y?"Replay speech":"Speak aloud",className:A,onClick:y?R:Q,disabled:w||!T,children:w?p.jsx(Pr,{size:"sm"}):p.jsx(X8,{})})})}))]})]})},jtn=e=>{const t=/<reply-to>(.*?)<\/reply-to>/g,n=[];let r;for(;r=t.exec(e),r!==null;)n.push({id:Fo(),text:r[1]});const i=e.replace(t,"").trim();return{replies:n,remainingContent:i}},Vtn=/\.([a-zA-Z0-9]+)$/,Ytn=/[\\/]/,Btn=e=>{if(typeof e!="string"||e.trim()==="")return"plaintext";const t=e.match(Vtn);if(!t)return"plaintext";const n=t[1].toLowerCase(),r={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",pyw:"python",rb:"ruby",java:"java",c:"c",h:"c",cpp:"cpp",cxx:"cpp",cc:"cpp",hpp:"cpp",cs:"csharp",go:"go",php:"php",html:"xml",htm:"xml",xml:"xml",json:"json",yaml:"yaml",yml:"yaml",md:"markdown",markdown:"markdown",sh:"bash",bash:"bash",zsh:"bash",bat:"dos",ps1:"powershell",swift:"swift",kt:"kotlin",kts:"kotlin",rs:"rust",scala:"scala",sql:"sql",css:"css",scss:"scss",less:"less",dockerfile:"dockerfile",makefile:"makefile",ini:"ini",toml:"toml",conf:"ini",env:"ini",dart:"dart",lua:"lua",perl:"perl",pl:"perl",r:"r",tex:"latex",latex:"latex",vue:"vue",svelte:"svelte",groovy:"groovy",gradle:"groovy",coffee:"coffeescript",sc:"scala",vb:"vbnet",asm:"armasm",sol:"solidity"},i=e.split(Ytn).pop();if(i){if(i.toLowerCase()==="dockerfile")return"dockerfile";if(i.toLowerCase()==="makefile")return"makefile"}return r[n]||"plaintext"},Tz=b.memo(({file:e,src:t,onClick:n,conversationId:r})=>{const[i,s]=b.useState(!1),a=Gr(f=>f.setCanvasOpen),{setViewMode:o}=dr(),l=b.useCallback(async()=>{const f=Z1(e),O=w=>{w&&console.error("Error processing file:",w),n(e)},{setFiles:g,setOpenTabs:m,setSelectedTab:v}=dr.getState();if(e.startsWith("data:"))if(yO(f)){const w=e,y={id:w,title:f,path:w,content:e,type:uo(e)},x=dr.getState().conversations?.[r],k=x?.files??[],S=x?.openTabs??[],Q=(()=>{const A=k.findIndex(E=>E.id===w);return A!==-1?[...k.slice(0,A),y,...k.slice(A+1)]:[...k,y]})();g(r,Q);const _=S.some(A=>A.id===w)?S:[...S,{id:w,title:f}];m(r,_),v(r,w),a(!0),o(r,"documents")}else n(e);else{const w=e.startsWith("file://")?e.substring(7):e;try{const y=await window.api.readFile(w);if(y.success&&yO(f)){const T=w,x={id:T,title:f,path:w,content:y.data,type:uo(e)},S=dr.getState().conversations?.[r],Q=S?.files??[],R=S?.openTabs??[],_=(()=>{const I=Q.findIndex(L=>L.id===T);return I!==-1?[...Q.slice(0,I),x,...Q.slice(I+1)]:[...Q,x]})();g(r,_);const E=R.some(I=>I.id===T)?R:[...R,{id:T,title:f}];m(r,E),v(r,T),a(!0),o(r,"documents");return}a(!0),o(r,"files")}catch(y){const T=y instanceof Error?y.message:String(y??"Unknown error reading file");return O(T)}}},[e,n,a,o,r]),c=()=>{n(e)},u=()=>{s(!0)},d=!e.startsWith("data:")&&!e.startsWith("http"),h=e.startsWith("file://")?e.substring(7):e;return i?p.jsx(iTe,{file:e}):p.jsxs("div",{className:"group relative inline-block",children:[p.jsx("video",{className:"mb-2 max-h-[300px] max-w-full cursor-pointer rounded-sm",src:t,controls:!0,preload:"metadata",tabIndex:0,onClick:c,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),c())},onError:u,title:`Click to open ${Z1(e)}`}),d&&p.jsx("div",{className:"file-actions-menu invisible absolute right-1 top-1 z-[2] opacity-0 transition-[opacity,visibility] duration-fast ease-out-quart group-hover:visible group-hover:opacity-100",onClick:f=>{f.stopPropagation()},onKeyDown:f=>f.stopPropagation(),children:p.jsx(YC,{filePath:h,tooltip:"File actions","aria-label":"File actions",onShowInCanvas:l})})]})});Tz.displayName="VideoAttachment";const Ztn=e=>e.startsWith("http://")||e.startsWith("https://"),FF=[".jpg",".jpeg",".png",".gif",".webp",".bmp",".svg",".tiff",".tif",".ico",".heic",".heif",".avif",".jfif",".pjpeg",".pjp"],NF=[".mp4",".webm",".ogg",".mov",".avi",".wmv",".flv",".mkv",".m4v",".3gp",".3g2"],MF=[".mp3",".wav",".ogg",".aac",".flac",".m4a",".aiff"],rh=(e,t)=>{const n=e.toLowerCase();return t.some(r=>n.endsWith(r))},Htn=(e,t)=>{if(t.startsWith("http"))return t;const n=t.startsWith("file://")?t:`file://${t}`;return rh(t,FF)?e.static.getImageUrl(n):rh(t,NF)?e.static.getVideoUrl(n):rh(t,MF)?e.static.getAudioUrl(n):t},hTe=({messageId:e,autoConnect:t=!0,onComplete:n,onUpdate:r,children:i,className:s,conversationId:a,refetchOnComplete:o=!0,styleProps:l})=>{const c=zf(I=>I.streamingMessages[e]??null),u=c?.isComplete??!1,{message:d,status:h,isLoading:f,isRefetching:O,error:g}=R6e({messageId:e,autoConnect:t,onComplete:n,onUpdate:r,conversationId:a,refetchOnComplete:o}),m=b.useMemo(()=>h==="connected"&&!u,[h,u]),v=b.useRef(null),w=b.useMemo(()=>d?(v.current=d,d):c?.content?(v.current=c.content,c.content):v.current||null,[d,c]),y=Btn(w?.file_path||""),T=!!(w?.code||w?.content||w?.replacements||w?.stdout||w?.stderr||w?.logging),x=b.useMemo(()=>Si(Cr.baseUrl),[]),k=b.useCallback(I=>Htn(x,I),[x]),S=b.useCallback(async I=>{try{if(Ztn(I))await window.api.openExternal(I);else{const L=I.startsWith("file://")?I.substring(7):I;await window.api.openFile(L)}}catch(L){console.error("Error opening file:",L),tr(`Could not open ${I.split("/").pop()}. The file may have been moved, renamed, or deleted.`)}},[]),Q=w?.files??[],R=b.useMemo(()=>Q.filter(I=>rh(I,FF)),[Q]),_=b.useMemo(()=>Q.filter(I=>rh(I,NF)),[Q]),A=b.useMemo(()=>Q.filter(I=>rh(I,MF)),[Q]),E=b.useMemo(()=>Q.filter(I=>!rh(I,FF)&&!rh(I,NF)&&!rh(I,MF)),[Q]);return p.jsxs("div",{className:G("relative break-words",s),children:[i,O&&p.jsxs("p",{className:"mt-1 flex items-center gap-2 text-meta text-ink-muted",children:[p.jsx(Pr,{size:"sm"}),"Refreshing message data..."]}),w?.thinking&&p.jsx(Z7,{label:"Reasoning",content:w.thinking}),w?.message&&(u?p.jsx(Zg,{content:w.message,styleProps:l}):p.jsx(Aue,{content:w.message,styleProps:l})),h==="connected"&&!w?.message&&p.jsx("div",{className:"flex justify-start",children:p.jsx(Pr,{size:"lg",label:"Waiting for the agent"})}),T&&p.jsx(H7,{className:"mt-2",action:w?.action,filePath:w?.file_path,files:w?.files,running:m,failed:!!w?.stderr,details:p.jsxs(p.Fragment,{children:[w?.code&&p.jsx(If,{code:w.code,isUser:!1,flexDirection:"column-reverse"}),w?.content&&p.jsx(If,{header:"Content",code:w.content,isUser:!1,language:y,flexDirection:"column-reverse"}),w?.replacements&&p.jsx(If,{header:"Replacements",code:w.replacements,isUser:!1,language:"diff",flexDirection:"column-reverse"}),w?.stdout&&p.jsx(vb,{output:w.stdout,isUser:!1}),w?.stderr&&p.jsx(mb,{error:w.stderr,isUser:!1}),w?.logging&&p.jsx($2,{log:w.logging,isUser:!1})]})}),R.length>0&&p.jsx("div",{className:"my-4",children:R.map(I=>p.jsx(XQ,{file:I,src:k(I),onClick:S,conversationId:a??""},`${e}-${I}`))}),_.length>0&&p.jsx("div",{className:"mb-4",children:_.map(I=>p.jsx(Tz,{file:I,src:k(I),onClick:S,conversationId:a??""},`${e}-${I}`))}),A.length>0&&p.jsx("div",{className:"mb-4",children:A.map(I=>p.jsx(Sz,{content:k(I),isUser:!1},`${e}-${I}`))}),E.length>0&&p.jsx("div",{className:"mt-4",children:E.map(I=>p.jsx(kz,{file:I,onClick:S,conversationId:a??""},`${e}-${I}`))}),g&&p.jsxs("div",{className:"mt-2 rounded-sm bg-danger-wash border border-danger-border p-3 text-body-sm text-ink",children:[p.jsx("p",{className:"font-medium",children:"Connection error"}),p.jsx("p",{children:g.message})]}),f&&!m&&p.jsxs("p",{className:"mt-2 flex items-center gap-2 text-body-sm text-ink-muted",children:[p.jsx(Pr,{size:"sm"}),"Loading message data..."]})]})};hTe.displayName="StreamingMessage";const Ktn="lo-measured",rre=(e,t,n)=>Oe.Children.map(e,r=>Oe.isValidElement(r)&&r.props.content?Oe.cloneElement(r,{content:t,styleProps:n}):r),ire=Oe.memo(({isUser:e,children:t,content:n,message:r,onMessageComplete:i,agentId:s,isSmallView:a,metadataMode:o="default"})=>{const l=b.useRef(null),c=o==="default",{replies:u,remainingContent:d}=b.useMemo(()=>jtn(n||""),[n]),h=b.useMemo(()=>({fontSize:a?"var(--text-body-sm)":"var(--text-body)",lineHeight:1.6}),[a]),f=r?.conversation_id??s;if(e)return p.jsxs("div",{className:"group relative flex w-full justify-end",children:[p.jsx("div",{className:G("relative rounded-frame border border-hairline bg-surface text-ink break-words",a?"max-w-[92%] px-3 py-2":"max-w-[75%] px-4 py-3"),children:p.jsxs("div",{ref:l,className:G("relative",Ktn),children:[u.length>0&&p.jsx(EF,{replies:u}),rre(t,d,h)]})}),r&&c&&p.jsx(IF,{isUser:e,content:n,messageId:r.id,agentId:s,timestamp:r.timestamp})]});const O=r?.is_streamable===!0&&r?.is_complete===!1&&!e,g=zf(T=>r?.id?T.streamingMessages[r.id]?.isComplete??!1:!0),m=O&&!g,v=b.useRef(null);b.useEffect(()=>{if(r?.id){if(m){v.current=null;return}i&&v.current!==r.id&&(v.current=r.id,i())}},[r?.id,i,m]);const w=m&&r&&p.jsx(hTe,{messageId:r.id,autoConnect:!0,conversationId:f,refetchOnComplete:!0,onComplete:()=>{i&&i()},styleProps:h,className:G("relative w-full break-words text-ink")}),y=!m&&r?p.jsxs("div",{className:G("relative w-full break-words text-ink"),ref:l,children:[u.length>0&&p.jsx(EF,{replies:u}),r.thinking&&!e&&p.jsx(Z7,{label:"Thinking",content:r.thinking}),rre(t,d,h),f&&p.jsx(F9,{agentId:s,targetRef:l,isUser:e,conversationId:f,showSpeech:!0,showCopy:!0,showReply:!0})]}):null;return p.jsxs("div",{className:"group relative w-full",children:[w,y,r&&c&&p.jsx(IF,{isUser:e,content:n,messageId:r.id,agentId:s,timestamp:r.timestamp,className:O?"invisible":void 0})]})}),Jtn=Si(Cr.baseUrl),enn=e=>e.startsWith("http://")||e.startsWith("https://"),zF=e=>{const t=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg"],n=e.toLowerCase();return t.some(r=>n.endsWith(r))},LF=e=>{const t=[".mp4",".webm",".ogg",".mov",".avi",".mkv"],n=e.toLowerCase();return t.some(r=>n.endsWith(r))},qF=e=>{const t=[".mp3",".wav",".ogg",".m4a",".flac",".aac",".wma"],n=e.toLowerCase();return t.some(r=>n.endsWith(r))},tnn=(e,t)=>{if(t.startsWith("http"))return t;const n=t.startsWith("file://")?t:`file://${t}`;return zF(t)?e.static.getImageUrl(n):LF(t)?e.static.getVideoUrl(n):qF(t)?e.static.getAudioUrl(n):t},nnn=b.memo(({message:e,onMessageComplete:t,isLastMessage:n,conversationId:r,currentExecution:i,isSmallView:s,isTurnStart:a=!1})=>{const o=dr(_=>_.addMentionedFilesBatch),l=Gr(_=>_.showAgentReasoning);b.useEffect(()=>{if(e.files&&e.files.length>0&&r){const _=e.files.map(A=>{if(A.startsWith("data:"))return null;const E=Z1(A),I=uo(A),L=A.startsWith("file://")?A.substring(7):A;return{id:L,title:E,path:L,content:L,type:I}}).filter(Boolean);_.length>0&&o(r,_)}},[e.files,r,o]);const c=b.useCallback(_=>tnn(Jtn,_),[]),u=b.useCallback(async _=>{try{if(enn(_))await window.api.openExternal(_);else{const A=_.startsWith("file://")?_.substring(7):_;await window.api.openFile(A)}}catch(A){console.error("Error opening file:",A),tr(`Could not open ${Z1(_)}. The file may have been moved, renamed, or deleted.`)}},[]),d=e.role==="user",h=e.execution_type,f=e.action==="ASK",O=h==="action",g=h==="security_check",m=h==="plan"||h==="reflection";if(nTe(e,l))return null;const v=n&&!!i,w=e.files??[],y=w.filter(_=>zF(_)),T=w.filter(_=>LF(_)),x=w.filter(_=>qF(_)),k=w.filter(_=>!zF(_)&&!LF(_)&&!qF(_)),S=p.jsxs(p.Fragment,{children:[y.length>0&&p.jsx("div",{className:"mb-2 flex flex-col gap-2",children:y.map(_=>p.jsx(XQ,{file:_,src:c(_),onClick:u,conversationId:r},`${e.id}-${_}`))}),T.length>0&&p.jsx("div",{className:"mb-2 flex flex-col gap-2",children:T.map(_=>p.jsx(Tz,{file:_,src:c(_),onClick:u,conversationId:r},`${e.id}-${_}`))}),x.length>0&&p.jsx("div",{className:"mb-2 flex flex-col gap-2",children:x.map(_=>p.jsx(Sz,{content:c(_),isUser:d},`${e.id}-${_}`))}),k.length>0&&p.jsx("div",{className:"flex flex-col gap-2",children:k.map(_=>p.jsx(kz,{file:_,onClick:u,conversationId:r},`${e.id}-${_}`))})]});if(f)return p.jsx(ah,{isUser:!1,isSmallView:s,showAvatar:a,children:p.jsxs(ire,{isUser:!1,content:e.message,message:e,onMessageComplete:t,isLastMessage:n??!1,isJobRunning:!!i,agentId:r,isSmallView:s,children:[p.jsx(Lue,{content:e.message}),S]})});if(O){const _=i?.stdout??e.stdout,A=i?.stderr??e.stderr,E=i?.logging??e.logging,I=e.message?e.message.replace(/(```\w+\s*)+$/g,"").trim():void 0,L=p.jsxs(p.Fragment,{children:[I&&p.jsx("p",{className:"text-body-sm text-ink-muted",children:I}),e.code&&p.jsx(If,{code:e.code,isUser:d}),e.content&&p.jsx(If,{code:e.content,isUser:d,header:"Content"}),e.replacements&&p.jsx(If,{code:e.replacements,isUser:d,header:"Replacements"}),_&&p.jsx(vb,{output:_,isUser:d}),A&&p.jsx(mb,{error:A,isUser:d}),E&&p.jsx($2,{log:E,isUser:d}),e.id&&e.timestamp&&p.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[p.jsx(IF,{inline:!0,isUser:d,content:I,messageId:e.id,agentId:r}),p.jsx(B7,{timestamp:e.timestamp})]})]}),z=!!(e.code||e.content||e.replacements||_||A||E||e.id&&e.timestamp);return p.jsxs(ah,{isUser:!1,isSmallView:s,showAvatar:a,children:[p.jsx(H7,{action:e.action,filePath:e.file_path,files:e.files,narration:I,running:v,failed:!!A,details:z?L:void 0}),S]})}if(m){const _=[e.message,e.thinking].filter(Boolean).join(`
|
|
1312
1312
|
|
|
1313
|
-
`);return p.jsxs(ah,{isUser:!1,isSmallView:s,showAvatar:a,children:[p.jsx(Z7,{content:_||void 0}),w.length>0&&p.jsx("div",{className:"mt-2",children:S})]})}if(g){const _=e.code||e.stdout||e.stderr||e.logging?p.jsxs(p.Fragment,{children:[e.code&&p.jsx(If,{code:e.code,isUser:d}),e.stdout&&p.jsx(vb,{output:e.stdout,isUser:d}),e.stderr&&p.jsx(mb,{error:e.stderr,isUser:d}),e.logging&&p.jsx($2,{log:e.logging,isUser:d})]}):void 0;return p.jsxs(ah,{isUser:!1,isSmallView:s,showAvatar:a,children:[p.jsx(jGe,{content:e.message,details:_}),w.length>0&&p.jsx("div",{className:"mt-2",children:S})]})}const Q=p.jsxs(p.Fragment,{children:[e.code&&p.jsx(If,{code:e.code,isUser:d}),e.stdout&&p.jsx(vb,{output:e.stdout,isUser:d}),e.stderr&&p.jsx(mb,{error:e.stderr,isUser:d}),e.logging&&p.jsx($2,{log:e.logging,isUser:d})]}),R=!!(e.code||e.stdout||e.stderr||e.logging);return p.jsx(ah,{isUser:d,isSmallView:s,showAvatar:a,children:p.jsxs(ire,{isUser:d,content:e.message,message:e,onMessageComplete:t,isLastMessage:n??!1,isJobRunning:!!i,agentId:r,isSmallView:s,children:[S,e.message&&!(e.is_streamable&&!e.is_complete)&&p.jsx(Gtn,{content:e.message,isUser:d}),!d&&R&&p.jsx(mg,{className:"mt-2",summary:p.jsx("span",{className:"text-meta",children:"Technical details"}),children:Q}),d&&Q]})})}),sre=40,rnn=25,inn=40,snn=120,are=e=>e>sre?sre:e,fTe=Oe.memo(({messages:e,isLoading:t,isLoadingMessages:n,isFetchingMore:r,jobStatus:i,agentName:s,currentExecution:a,messagesContainerRef:o,messagesEndRef:l,refetch:c,conversationId:u,isSmallView:d})=>{const[h,f]=b.useState(()=>are(e.length)),O=b.useRef(u),g=b.useRef(e.length),m=e.length===0&&!n&&!r;b.useEffect(()=>{const _=g.current;if(O.current!==u){O.current=u,f(are(e.length)),g.current=e.length;return}if(e.length<_)f(E=>Math.min(E,e.length));else if(e.length>_){const E=e.length-_;f(I=>I>=_?e.length:Math.min(e.length,I+Math.min(E,1)))}g.current=e.length},[u,e.length]),b.useEffect(()=>{if(h>=e.length)return;const _=window.setTimeout(()=>{f(A=>Math.min(e.length,A+rnn))},inn);return()=>{window.clearTimeout(_)}},[e.length,h]),b.useEffect(()=>{const _=o.current;if(!_||h>=e.length)return;const A=()=>{const{scrollTop:E,scrollHeight:I,clientHeight:L}=_,z=Math.abs(I-L),V=Math.abs(E);(E<0?z-V:z-E)<260&&f(Z=>Math.min(e.length,Z+snn))};return _.addEventListener("scroll",A,{passive:!0}),()=>{_.removeEventListener("scroll",A)}},[e.length,h,o]);const v=b.useMemo(()=>h>=e.length?e:e.slice(e.length-h),[e,h]),w=Gr(_=>_.showAgentReasoning),y=b.useMemo(()=>rJt(v,w),[v,w]),T=e.length-v.length,x=e[e.length-1],k=x?.id??"",S=zf(_=>_.streamingMessages[k]?.isComplete??!1),Q=!!(x?.is_streamable&&!(x?.is_complete||S)),R=b.useCallback(()=>{c?.()},[c]);return p.jsxs("div",{className:G("relative flex items-center justify-center",m?"h-0 grow-0 overflow-hidden":"min-h-0 grow overflow-auto"),children:[r&&p.jsxs("div",{className:G("absolute z-10 flex w-fit items-center text-ink-muted",d?"top-2 left-2 px-2 py-1 text-meta":"top-4 left-4 px-3 py-2 text-body-sm"),children:[p.jsx(Pr,{size:"sm",className:"mr-2"}),"Loading older messages..."]}),!r&&T>0&&p.jsxs("div",{className:G("absolute z-10 flex w-fit items-center text-ink-muted",d?"top-2 left-2 px-2 py-1 text-meta":"top-4 left-4 px-3 py-2 text-body-sm"),children:["Rendering ",T," earlier messages..."]}),p.jsx("div",{ref:o,className:G("relative flex w-full flex-col-reverse will-change-[scroll-position] [overflow-anchor:auto] [transform:translateZ(0)]",m?"h-0 grow-0 overflow-hidden p-0":"min-h-0 grow overflow-auto p-4"),children:n&&!e.length?p.jsx("div",{className:"flex h-full grow items-center justify-center p-8",children:p.jsx(Pr,{size:"lg",label:"Loading messages"})}):p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:l,style:{height:1,width:"100%",opacity:0,position:"relative",pointerEvents:"none"},id:"messages-end-anchor"}),y.length>0?p.jsxs("div",{className:G("mx-auto flex w-full max-w-[900px] flex-col sm:max-w-[90%] md:max-w-[900px]"),children:[y.map((_,A)=>p.jsxs("div",{className:G(iJt(_.boundary,d)),children:[_.divider&&p.jsx(one,{isSmallView:d,className:d?"mb-4":"mb-6",children:_.divider}),_.kind==="divider"?p.jsx(one,{isSmallView:d,children:_.message.message}):p.jsx(nnn,{message:_.message,conversationId:u,currentExecution:A===y.length-1&&a?a:void 0,isLastMessage:A===y.length-1,isTurnStart:_.isTurnStart,onMessageComplete:R,isSmallView:d})]},_.message.id)),t&&!Q&&p.jsx(AF,{status:i,agentName:s,currentExecution:a,conversationId:u,isSmallView:d,className:d?"mt-4":"mt-6"})]}):p.jsx(p.Fragment,{children:n&&p.jsx("div",{className:"flex h-full w-full grow items-center justify-center",children:p.jsx(AF,{status:i,agentName:s,currentExecution:a,conversationId:u,isSmallView:d})})})]})})]})});fTe.displayName="MessagesView";const ann=["Go to my documents folder","What's the latest news?","Make me a research report on the latest trends in AI","Make me a space invaders game","Organize my desktop","Create a presentation outline on climate change","Train a classifier on the MPG dataset","Search for quantum computing papers and download interesting ones to read later","Download some recent papers on fusion energy","Download some recent papers on cancer research","Make me a brick breaker game","Remove downloads that are more than a year old","Put together a competitive analysis report on the agentic AI space","Find me a royalty free gif of a cute cat","Go to my downloads folder","Organize my documents folder","Make me a GDPR compliant privacy policy","Look up trending stocks and put together an investment report","Fetch the MNIST dataset and train a good classifier","Look up interest rate trends and make a projection for the next 5 years","Make a presentation with a dependency graph of genetic factors for Alzheimer's disease","Is Apple buy/hold/sell? Do a fundamentals analysis","Do a technical analysis on NVDA over the last year","What are the trending stocks on WallStreetBets?","What stocks are trending right now?"],onn=[],lnn=[{id:"canonical",role:"system",timestamp:new Date(0)}],qA={openTabs:[],selectedTabId:null,files:[]},cnn=Oe.memo(({activeTab:e,onTabChange:t,agentName:n,description:r,onOpenOptions:i,isOptionsSidebarOpen:s,onCloseOptions:a,agentId:o,messages:l,isLoading:c,isLoadingMessages:u,isFetchingMore:d,isFarFromBottom:h,hasNewActivity:f=!1,jobStatus:O,currentExecution:g,messagesContainerRef:m,messagesEndRef:v,scrollToBottom:w,rawInfoContent:y,onSendMessage:T,currentJobId:x,onCancelJob:k,onComposerInput:S,agentData:Q,refetch:R,messageInputRef:_,cwd:A,onChangeCwd:E,sendError:I,sessionStatus:L,canonical:z,runDetails:V})=>{const[q,Z]=b.useState(!1),j=b.useRef(null),M=b.useRef(null);b.useEffect(()=>{if(!j.current)return;const Ce=new ResizeObserver(Be=>{for(const Yt of Be)Yt.contentRect.width<550?Z(!0):Z(!1)});return Ce.observe(j.current),()=>{Ce.disconnect()}},[]);const Y=Gr(Ce=>Ce.canvasWidth),F=Gr(Ce=>Ce.setCanvasWidth),X=Gr(Ce=>Ce.restoreDefaultCanvasWidth),W=o,U=dr(Ce=>Ce.conversations[W]),J=dr(Ce=>Ce.setOpenTabs),he=dr(Ce=>Ce.setSelectedTab),ue=dr(Ce=>Ce.setFiles),we=Gr(Ce=>Ce.isCanvasOpen),xe=(U??qA).openTabs,dt=(U??qA).selectedTabId,re=(U??qA).files,it=Y===0?450:Y,Ue=b.useCallback(Ce=>he(W,Ce),[W,he]),pt=b.useCallback(()=>{Gr.getState().setCanvasOpen(!1)},[]),We=b.useCallback(Ce=>{const Be=xe.filter(Ht=>Ht.id!==Ce),Yt=re.filter(Ht=>Ht.id!==Ce);J(W,Be),ue(W,Yt),dt===Ce&&he(W,Be.length>0?Be[0].id:null)},[W,re,xe,dt,ue,J,he]),ge=pie(),ve=(Ce,Be)=>Be;return p.jsxs("div",{className:"relative flex h-full w-full flex-row overflow-hidden",children:[p.jsx("div",{className:"relative h-full w-0 min-w-[220px] flex-1",children:p.jsxs("div",{ref:j,className:"flex h-full min-h-0 grow flex-col overflow-hidden rounded-none bg-canvas",children:[p.jsx(BHt,{agentName:n,description:r,onOpenOptions:i,runDetails:V}),!z&&p.jsx(gKt,{open:s,onClose:a,agentId:o}),ge,ve("chat",z?p.jsx(Syt,{frontend:z.view.frontend,transcript:z.view.transcript,gate:z.view.frontend?.pending_gate??null,waiting:z.busy,loadingOlder:z.view.loadingOlder,onLoadOlder:z.view.loadOlder,containerRef:m,isSmallView:q,status:z.view.status,error:z.view.error}):p.jsx(fTe,{messages:l,isLoading:c,isLoadingMessages:u,isFetchingMore:d,jobStatus:O,agentName:n,currentExecution:g,messagesContainerRef:m,messagesEndRef:v,scrollToBottom:w,refetch:R,conversationId:o,isSmallView:q})),(z||!(u&&l.length===0))&&p.jsx(tTe,{ref:_,onSendMessage:T,onComposerInput:S,initialSuggestions:ann,isLoading:z?!!z.admitting:c,conversationId:o,messages:z?z.view.transcript.records.length>0?lnn:l.length>0?l:onn:l,isHydrating:z?z.view.status==="connecting":!1,currentJobId:z?null:x,onCancelJob:k,canonicalStop:z?{active:z.busy,onStop:z.onStop}:void 0,isFarFromBottom:h,hasNewActivity:f,scrollToBottom:w,agentData:Q,cwd:A,onChangeCwd:E,sendError:I,sessionStatus:L,isSmallView:q})]})}),we&&p.jsxs(p.Fragment,{children:[p.jsx(noe,{sidebarWidth:it,onSidebarWidthChange:F,minWidth:400,maxWidth:1200,side:"left",onDoubleClick:X}),p.jsx("div",{ref:M,style:{minWidth:it,width:it},className:"relative h-full overflow-hidden border-l border-hairline transition-[width] duration-base ease-out-quart",children:p.jsx(YZt,{activeDocumentId:dt,initialDocuments:re,conversationId:W,agentId:o,currentWorkingDirectory:A,onChangeActiveDocument:Ue,onClose:pt,onCloseDocument:We})})]})]})});function unn(e){return _r({queryKey:["desktop","profiles"],enabled:e,queryFn:()=>un({op:"profiles.list"}).then(t=>t.profiles),retry:$C,staleTime:1e4})}function dnn(e){return _r({queryKey:["desktop","teams"],enabled:e,queryFn:()=>un({op:"teams.list"}).then(t=>t.teams),retry:$C,staleTime:1e4})}const hnn=(e,t)=>{t(""),e?.focus()},Hm="flex h-8 min-w-0 items-center gap-1 rounded-md px-1 text-body-sm leading-5 hover:bg-elevated focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",fnn=new Set(["idle","recent"]);function Onn({row:e}){const t=e.status?.code,n=t==="busy"?C8:t==="approval"||t==="answer"||t==="wedged"||t==="error"?tS:t==="interrupted"||t==="dormant"?QEe:t==="complete"?uc:t==="scheduled"?vC:t==="attached"?bC:fnn.has(t??"recent")?d2e:$8,r=t==="busy"?"text-info motion-safe:animate-spin":t==="error"||t==="wedged"?"text-danger":t==="approval"||t==="answer"||t==="interrupted"?"text-warning":t==="complete"?"text-success":"text-ink-dim";return p.jsxs("span",{className:"flex size-4 shrink-0",title:e.status?.label??"Recent",children:[p.jsx(n,{className:G("size-4",r),"aria-hidden":"true"}),p.jsx("span",{className:"sr-only",children:e.status?.label??"Recent"})]})}function pnn({selectedConversation:e,onSelectConversation:t,onStageDraft:n}){const r=Js(),i=Gh(),s=nd(i.data,"session_catalogue",2),a=b.useRef(null),o=b.useRef(!1);s&&(o.current=!0);const l=!!i.error&&o.current,c=s||l,u=unn(s&&nd(i.data,"profile_catalogue")),d=dnn(s&&nd(i.data,"team_catalogue")),h=Bn(Y=>Y.sessions),f=Bn(Y=>Y.fetchSessions),O=Bn(Y=>Y.loading),g=Bn(Y=>Y.error),m=Bn(Y=>Y.truncated),v=Bn(Y=>Y.activeDraftKey),w=Bn(Y=>Y.drafts),y=Bn(Y=>Y.pendingSessionId),[T,x]=b.useState(""),[k,S]=b.useState(!1),[Q,R]=b.useState(()=>{try{return JSON.parse(localStorage.getItem("chat-sidebar-disclosures")??"{}")}catch{return{}}}),_=(Y,F=!1)=>Q[Y]??F,A=(Y,F=!1)=>R(X=>({...X,[Y]:!(X[Y]??F)}));b.useEffect(()=>{localStorage.setItem("chat-sidebar-disclosures",JSON.stringify(Q))},[Q]),b.useEffect(()=>{if(!s)return;f();const Y=window.setInterval(()=>{document.visibilityState==="visible"&&f()},5e3);return()=>window.clearInterval(Y)},[s,f]);const E=b.useMemo(()=>h.filter(Y=>`${Y.title??""} ${Y.binding?.agent??""} ${Y.binding?.team??""}`.toLocaleLowerCase().includes(T.toLocaleLowerCase())),[h,T]),I=(Y,F)=>E.filter(X=>Y==="team"?X.binding?.team===F:!X.binding?.team&&X.binding?.agent===F),L=v?w[v]:void 0,z=Y=>Y.binding?.team||Y.binding?.agent||"",V=b.useMemo(()=>new Set(Object.values(w).filter(Y=>Y.sessionId).map(Y=>Y.sessionId)),[w]),q=(Y,F=!1)=>p.jsxs("button",{type:"button","data-chat-row":!0,"data-child":F||void 0,className:G(Hm,"w-full text-left",F&&"pl-7",e===Y.session_id&&!v&&"bg-accent-wash text-ink",Y.attention?.unseen&&"font-semibold"),"aria-current":e===Y.session_id&&!v?"page":void 0,title:`${Y.title||"Untitled chat"}${z(Y)?` (${z(Y)})`:""}: ${Y.status?.label??"Recent"}${Y.attention?.unseen?", unread":""}`,onClick:()=>t(Y.session_id),children:[p.jsx(Onn,{row:Y}),p.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[Y.title||"Untitled chat",!F&&z(Y)&&p.jsxs("span",{className:"ml-1 text-meta text-ink-muted",children:["· ",z(Y)]}),V.has(Y.session_id)&&p.jsx("span",{className:"ml-1 text-meta text-ink-muted",children:"· Not sent yet"})]}),y===Y.session_id&&p.jsx(C8,{className:"size-4 shrink-0 motion-safe:animate-spin","aria-label":"Opening chat"})]},Y.session_id),Z=(Y,F)=>{const X=I(Y,F),W=`${Y}:${F}`,U=!!T||_(W);if(T&&!F.toLocaleLowerCase().includes(T.toLocaleLowerCase())&&!X.length)return null;const J=Y==="team"?gh:sv;return p.jsxs("div",{"data-entity":!0,children:[p.jsxs("div",{className:G("group flex h-8 items-center gap-1 rounded-md",L?.target?.kind===Y&&L.target.name===F&&"bg-accent-wash"),children:[p.jsx("button",{type:"button","data-disclosure":!0,"aria-label":`${U?"Collapse":"Expand"} ${F} chats`,"aria-expanded":U,className:"flex size-6 shrink-0 items-center justify-center rounded-md hover:bg-elevated",onClick:()=>A(W),children:U?p.jsx(o1,{className:"size-3.5"}):p.jsx(og,{className:"size-3.5"})}),p.jsxs("button",{type:"button","data-chat-row":!0,"data-entity-name":!0,className:G(Hm,"flex-1 text-left"),onClick:()=>n({kind:Y,name:F}),"aria-label":`New chat with ${F}`,title:`New chat with ${F}`,children:[p.jsx(J,{className:"size-4 shrink-0"}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:F}),p.jsx(Eq,{className:G("size-4 shrink-0 text-ink opacity-0","transition-opacity duration-base ease-out-quart","group-hover:opacity-100 group-hover:duration-fast","group-focus-within:opacity-100 group-focus-within:duration-fast"),"aria-hidden":"true"}),p.jsx("span",{className:"min-w-4 shrink-0 text-right text-meta tabular-nums text-ink-dim",children:X.length||""})]}),p.jsx("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center rounded-md text-ink-dim hover:bg-elevated hover:text-ink-muted","aria-label":`Manage ${F}`,onClick:()=>r(`/agents?kind=${Y}&name=${encodeURIComponent(F)}`),children:p.jsx(T8,{className:"size-4"})})]}),U&&p.jsxs("div",{children:[X.map(he=>q(he,!0)),!X.length&&p.jsx("p",{className:"py-1 pl-7 text-meta text-ink-dim",children:"No chats yet"})]})]},W)},j=(Y,F,X,W)=>p.jsxs("button",{type:"button","data-chat-row":!0,className:"flex h-7 w-full items-center gap-1 rounded-md px-1 text-body-sm font-medium text-ink-muted hover:bg-elevated","aria-expanded":T?!0:_(Y,X),onClick:()=>A(Y,X),children:[T||_(Y,X)?p.jsx(o1,{className:"size-3.5"}):p.jsx(og,{className:"size-3.5"}),p.jsx("span",{className:"flex-1 text-left",children:F}),!!W&&p.jsx("span",{className:"text-meta tabular-nums",children:W})]}),M=Y=>{const F=Y.target;if(F.tagName==="INPUT"){Y.key==="Escape"&&(x(""),F.blur());return}if(Y.key==="Escape"){Y.preventDefault(),a.current?.focus();return}const X=[...Y.currentTarget.querySelectorAll("[data-chat-row]")],W=X.indexOf(F),U=Y.key==="ArrowDown"?Math.min(X.length-1,W+1):Y.key==="ArrowUp"?Math.max(0,W-1):Y.key==="Home"?0:Y.key==="End"?X.length-1:-1;if(U>=0){Y.preventDefault(),X[U]?.focus();return}const J=F.closest("[data-entity]"),he=J?.querySelector("[data-disclosure]");Y.key==="ArrowRight"&&he&&(Y.preventDefault(),he.getAttribute("aria-expanded")==="false"?he.click():J?.querySelector("[data-child]")?.focus()),Y.key==="ArrowLeft"&&he&&(Y.preventDefault(),F.hasAttribute("data-child")?J?.querySelector("[data-entity-name]")?.focus():he.getAttribute("aria-expanded")==="true"&&he.click())};return p.jsxs("nav",{"aria-label":"Chats",className:"flex h-full min-h-0 flex-col bg-surface p-2 text-ink",onKeyDown:M,children:[p.jsx("div",{className:"flex h-8 items-center px-1",children:p.jsx("h2",{className:"text-body-sm font-medium",children:"Chats"})}),p.jsxs("div",{className:"relative my-2",children:[p.jsx("input",{ref:a,"aria-label":"Search chats and agents",placeholder:"Search chats and agents",className:"h-8 w-full rounded-md border border-control bg-surface pr-9 pl-2 text-body-sm",value:T,onChange:Y=>x(Y.target.value)}),T&&p.jsx(Te,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2 focus-visible:outline-offset-[-2px]!",onClick:()=>hnn(a.current,x),"aria-label":"Clear search",children:p.jsx(Rs,{"aria-hidden":"true"})})]}),p.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto p-1",children:[i.isLoading&&p.jsx("p",{"aria-live":"polite",className:"text-meta text-ink-muted",children:"Connecting to chats…"}),i.error&&p.jsxs("div",{role:"alert",className:"space-y-1 text-body-sm text-danger",children:[p.jsxs("p",{children:[i.error.message,l?" Showing the last chats loaded.":""]}),p.jsx("button",{type:"button",className:"underline",onClick:()=>void i.refetch(),children:"Retry"})]}),i.data&&!s&&!i.error&&p.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:"Update the backend to use canonical chats. Existing histories are unchanged."}),c&&p.jsxs("div",{className:G("space-y-4 pb-2",l&&"opacity-60"),children:[p.jsxs("section",{children:[j("agents","Agents",!0),(T||_("agents",!0))&&p.jsxs(p.Fragment,{children:[u.isLoading&&p.jsx("p",{"aria-live":"polite",className:"text-meta text-ink-muted",children:"Loading agents…"}),u.data?.map(Y=>Z("agent",Y.name)),p.jsxs("button",{type:"button",className:G(Hm,"w-full text-ink-muted"),onClick:()=>r("/agents?create=agent"),children:[p.jsx(yy,{className:"size-4"}),"Create agent"]})]})]}),p.jsxs("section",{children:[j("teams","Teams",!0),(T||_("teams",!0))&&p.jsxs(p.Fragment,{children:[d.data?.map(Y=>Z("team",Y.name)),p.jsxs("button",{type:"button",className:G(Hm,"w-full text-ink-muted"),onClick:()=>r("/agents?create=team"),children:[p.jsx(yy,{className:"size-4"}),"Create team"]})]})]})]})]}),c&&p.jsxs("div",{className:G("mt-2 max-h-[45%] shrink-0 space-y-4 overflow-y-auto border-t border-hairline pt-2",l&&"opacity-60"),children:[p.jsxs("section",{children:[p.jsxs("button",{type:"button","data-chat-row":!0,className:G(Hm,"w-full",k&&"bg-accent-wash"),"aria-pressed":k,onClick:()=>S(Y=>!Y),children:[p.jsx(UX,{className:"size-4"}),p.jsx("span",{className:"flex-1 text-left",children:"All chats"}),E.length>0&&p.jsx("span",{className:"text-meta tabular-nums",children:E.length})]}),p.jsxs("button",{type:"button","data-chat-row":s||void 0,className:G(Hm,"mb-1 w-full border border-control disabled:text-ink-disabled disabled:hover:bg-transparent",!!v&&!L?.target&&"bg-accent-wash"),"aria-current":v&&!L?.target?"page":void 0,disabled:!s,onClick:()=>n(void 0,!0),children:[p.jsx(Eq,{className:"size-4"}),p.jsx("span",{className:"flex-1 text-left",children:"New chat"})]})]}),k?p.jsx("section",{children:E.map(Y=>q(Y))}):p.jsxs(p.Fragment,{children:[p.jsxs("section",{children:[j("active","Active chats",!0,E.filter(Y=>Y.active).length),(T||_("active",!0))&&(E.some(Y=>Y.active)?E.filter(Y=>Y.active).map(Y=>q(Y)):p.jsx("p",{className:"px-2 text-meta text-ink-muted",children:"Nothing running right now."}))]}),p.jsxs("section",{children:[j("previous","Previous chats",!1,E.filter(Y=>!Y.active).length),(T||_("previous"))&&E.filter(Y=>!Y.active).map(Y=>q(Y))]})]}),!h.length&&!O&&p.jsx("p",{className:"text-meta text-ink-muted",children:"No chats yet. Choose an agent, team or New chat."}),m&&p.jsx("p",{className:"text-meta text-ink-muted",children:"Showing up to 500 chats. Older chats remain available in the terminal."})]}),(g||u.error||d.error)&&p.jsxs("div",{role:"alert",className:"pt-2 text-meta text-danger",children:[p.jsx("p",{children:g||u.error?.message||d.error?.message}),p.jsx("button",{type:"button",className:"mt-1 underline",onClick:()=>{f(),u.refetch(),d.refetch()},children:"Retry refresh"})]})]})}const gnn=/^\/([A-Za-z]+)(?:\s([\s\S]*))?$/;function mnn(e,t){return{id:Fo(),role:"system",message:e,timestamp:new Date,status:t}}function vnn(e,t){const n=(r,i)=>{const s=Array.from({length:i.length+1},(a,o)=>o);for(let a=1;a<=r.length;a++){let o=s[0];s[0]=a;for(let l=1;l<=i.length;l++){const c=s[l];s[l]=Math.min(s[l]+1,s[l-1]+1,o+(r[a-1]===i[l-1]?0:1)),o=c}}return s[i.length]};return t.map(r=>({name:r.name,score:n(e,r.name)})).sort((r,i)=>r.score-i.score).slice(0,3).map(r=>`/${r.name}`)}const wnn=new Set(["session.goal","session.context","session.compact"]);function bnn({sessionId:e,addMessage:t,canonical:n,rebind:r,focusComposer:i}){const s=Js(),a=Gh(),o=nd(a.data,"commands"),l=_r({queryKey:td.commands,queryFn:()=>un({op:"commands.list"}).then(m=>m.commands),enabled:o,staleTime:3e5}),[c,u]=b.useState(null),d=b.useRef(null),h=b.useCallback(()=>{u(null);const m=d.current;d.current=null,m&&requestAnimationFrame(()=>{m.isConnected?m.focus():i?.()})},[i]),f=b.useCallback((m,v=!1)=>{if(e&&n.status!=="unavailable"){n.addNote(m,v?"error":"info");return}t(mnn(m,v?"error":void 0))},[t,n.addNote,n.status,e]),O=b.useCallback(async m=>{const v=gnn.exec(m.trim());if(!v||!o)return"not-a-command";const[,w,y]=v,T=y?.trim()??"",x=l.data??[],k=x.find(_=>_.name===w)??x.find(_=>_.aliases.includes(w));if(!k){const _=vnn(w,x);return f(_.length>0?`Unknown command /${w}. Did you mean ${_.join(", ")}? Type / for the full list.`:`Unknown command /${w}. Type / for the full list.`,!0),"consumed"}const S=f6[k.destination];if(S?.kind==="direct")return S.action==="clear"?(n.clearView(),"consumed"):(window.api?.desktop?.closeWindow?await window.api.desktop.closeWindow():f("Close this window to quit. Conversations keep running in the background."),"consumed");if(S?.kind==="navigate")return s(S.route(T,e??"")),"consumed";if(!e)return f(`/${k.name} needs an open conversation. Start one first.`,!0),"consumed";if(!T&&wnn.has(k.destination))return u({action:{kind:"native_action",destination:k.destination,session_id:e,args:"",fields:[],data:{}},spec:k,sessionId:e,canonical:n,commands:x,onClose:h,note:f,dispatch:_=>void O(_),rebind:r}),"consumed";const Q=k.name==="credential"?"":T,R=e6e(k.name,Q);if(R)return f(R,!0),"retained";try{const A=(await un({op:"sessions.command",sessionId:e,requestId:Fo(),command:k.name,args:Q})).result;if(b1(A)){const E=A,I=f6[E.destination];return I?.kind==="navigate"?(s(I.route(E.args,e)),"consumed"):I?(d.current=document.activeElement instanceof HTMLElement?document.activeElement:null,u({action:E,spec:k,sessionId:e,canonical:n,commands:x,onClose:h,note:f,dispatch:L=>void O(L),rebind:r}),"consumed"):(f(`/${k.name} is not available in the desktop app yet. Run it in the terminal with local-operator.`,!0),"consumed")}if(A.text)f(A.text,A.kind==="error"||A.style==="error");else if(A.kind==="block"){const E=A.data;Array.isArray(E.items)&&f([E.title,...E.items.map(([I,L])=>`${I}: ${L}`)].filter(Boolean).join(`
|
|
1313
|
+
`);return p.jsxs(ah,{isUser:!1,isSmallView:s,showAvatar:a,children:[p.jsx(Z7,{content:_||void 0}),w.length>0&&p.jsx("div",{className:"mt-2",children:S})]})}if(g){const _=e.code||e.stdout||e.stderr||e.logging?p.jsxs(p.Fragment,{children:[e.code&&p.jsx(If,{code:e.code,isUser:d}),e.stdout&&p.jsx(vb,{output:e.stdout,isUser:d}),e.stderr&&p.jsx(mb,{error:e.stderr,isUser:d}),e.logging&&p.jsx($2,{log:e.logging,isUser:d})]}):void 0;return p.jsxs(ah,{isUser:!1,isSmallView:s,showAvatar:a,children:[p.jsx(jGe,{content:e.message,details:_}),w.length>0&&p.jsx("div",{className:"mt-2",children:S})]})}const Q=p.jsxs(p.Fragment,{children:[e.code&&p.jsx(If,{code:e.code,isUser:d}),e.stdout&&p.jsx(vb,{output:e.stdout,isUser:d}),e.stderr&&p.jsx(mb,{error:e.stderr,isUser:d}),e.logging&&p.jsx($2,{log:e.logging,isUser:d})]}),R=!!(e.code||e.stdout||e.stderr||e.logging);return p.jsx(ah,{isUser:d,isSmallView:s,showAvatar:a,children:p.jsxs(ire,{isUser:d,content:e.message,message:e,onMessageComplete:t,isLastMessage:n??!1,isJobRunning:!!i,agentId:r,isSmallView:s,children:[S,e.message&&!(e.is_streamable&&!e.is_complete)&&p.jsx(Gtn,{content:e.message,isUser:d}),!d&&R&&p.jsx(mg,{className:"mt-2",summary:p.jsx("span",{className:"text-meta",children:"Technical details"}),children:Q}),d&&Q]})})}),sre=40,rnn=25,inn=40,snn=120,are=e=>e>sre?sre:e,fTe=Oe.memo(({messages:e,isLoading:t,isLoadingMessages:n,isFetchingMore:r,jobStatus:i,agentName:s,currentExecution:a,messagesContainerRef:o,messagesEndRef:l,refetch:c,conversationId:u,isSmallView:d})=>{const[h,f]=b.useState(()=>are(e.length)),O=b.useRef(u),g=b.useRef(e.length),m=e.length===0&&!n&&!r;b.useEffect(()=>{const _=g.current;if(O.current!==u){O.current=u,f(are(e.length)),g.current=e.length;return}if(e.length<_)f(E=>Math.min(E,e.length));else if(e.length>_){const E=e.length-_;f(I=>I>=_?e.length:Math.min(e.length,I+Math.min(E,1)))}g.current=e.length},[u,e.length]),b.useEffect(()=>{if(h>=e.length)return;const _=window.setTimeout(()=>{f(A=>Math.min(e.length,A+rnn))},inn);return()=>{window.clearTimeout(_)}},[e.length,h]),b.useEffect(()=>{const _=o.current;if(!_||h>=e.length)return;const A=()=>{const{scrollTop:E,scrollHeight:I,clientHeight:L}=_,z=Math.abs(I-L),V=Math.abs(E);(E<0?z-V:z-E)<260&&f(Z=>Math.min(e.length,Z+snn))};return _.addEventListener("scroll",A,{passive:!0}),()=>{_.removeEventListener("scroll",A)}},[e.length,h,o]);const v=b.useMemo(()=>h>=e.length?e:e.slice(e.length-h),[e,h]),w=Gr(_=>_.showAgentReasoning),y=b.useMemo(()=>rJt(v,w),[v,w]),T=e.length-v.length,x=e[e.length-1],k=x?.id??"",S=zf(_=>_.streamingMessages[k]?.isComplete??!1),Q=!!(x?.is_streamable&&!(x?.is_complete||S)),R=b.useCallback(()=>{c?.()},[c]);return p.jsxs("div",{className:G("relative flex items-center justify-center",m?"h-0 grow-0 overflow-hidden":"min-h-0 grow overflow-auto"),children:[r&&p.jsxs("div",{className:G("absolute z-10 flex w-fit items-center text-ink-muted",d?"top-2 left-2 px-2 py-1 text-meta":"top-4 left-4 px-3 py-2 text-body-sm"),children:[p.jsx(Pr,{size:"sm",className:"mr-2"}),"Loading older messages..."]}),!r&&T>0&&p.jsxs("div",{className:G("absolute z-10 flex w-fit items-center text-ink-muted",d?"top-2 left-2 px-2 py-1 text-meta":"top-4 left-4 px-3 py-2 text-body-sm"),children:["Rendering ",T," earlier messages..."]}),p.jsx("div",{ref:o,className:G("relative flex w-full flex-col-reverse will-change-[scroll-position] [overflow-anchor:auto] [transform:translateZ(0)]",m?"h-0 grow-0 overflow-hidden p-0":"min-h-0 grow overflow-auto p-4"),children:n&&!e.length?p.jsx("div",{className:"flex h-full grow items-center justify-center p-8",children:p.jsx(Pr,{size:"lg",label:"Loading messages"})}):p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:l,style:{height:1,width:"100%",opacity:0,position:"relative",pointerEvents:"none"},id:"messages-end-anchor"}),y.length>0?p.jsxs("div",{className:G("mx-auto flex w-full max-w-[900px] flex-col sm:max-w-[90%] md:max-w-[900px]"),children:[y.map((_,A)=>p.jsxs("div",{className:G(iJt(_.boundary,d)),children:[_.divider&&p.jsx(one,{isSmallView:d,className:d?"mb-4":"mb-6",children:_.divider}),_.kind==="divider"?p.jsx(one,{isSmallView:d,children:_.message.message}):p.jsx(nnn,{message:_.message,conversationId:u,currentExecution:A===y.length-1&&a?a:void 0,isLastMessage:A===y.length-1,isTurnStart:_.isTurnStart,onMessageComplete:R,isSmallView:d})]},_.message.id)),t&&!Q&&p.jsx(AF,{status:i,agentName:s,currentExecution:a,conversationId:u,isSmallView:d,className:d?"mt-4":"mt-6"})]}):p.jsx(p.Fragment,{children:n&&p.jsx("div",{className:"flex h-full w-full grow items-center justify-center",children:p.jsx(AF,{status:i,agentName:s,currentExecution:a,conversationId:u,isSmallView:d})})})]})})]})});fTe.displayName="MessagesView";const ann=["Go to my documents folder","What's the latest news?","Make me a research report on the latest trends in AI","Make me a space invaders game","Organize my desktop","Create a presentation outline on climate change","Train a classifier on the MPG dataset","Search for quantum computing papers and download interesting ones to read later","Download some recent papers on fusion energy","Download some recent papers on cancer research","Make me a brick breaker game","Remove downloads that are more than a year old","Put together a competitive analysis report on the agentic AI space","Find me a royalty free gif of a cute cat","Go to my downloads folder","Organize my documents folder","Make me a GDPR compliant privacy policy","Look up trending stocks and put together an investment report","Fetch the MNIST dataset and train a good classifier","Look up interest rate trends and make a projection for the next 5 years","Make a presentation with a dependency graph of genetic factors for Alzheimer's disease","Is Apple buy/hold/sell? Do a fundamentals analysis","Do a technical analysis on NVDA over the last year","What are the trending stocks on WallStreetBets?","What stocks are trending right now?"],onn=[],lnn=[{id:"canonical",role:"system",timestamp:new Date(0)}],qA={openTabs:[],selectedTabId:null,files:[]},cnn=Oe.memo(({activeTab:e,onTabChange:t,agentName:n,description:r,onOpenOptions:i,isOptionsSidebarOpen:s,onCloseOptions:a,agentId:o,messages:l,isLoading:c,isLoadingMessages:u,isFetchingMore:d,isFarFromBottom:h,hasNewActivity:f=!1,jobStatus:O,currentExecution:g,messagesContainerRef:m,messagesEndRef:v,scrollToBottom:w,rawInfoContent:y,onSendMessage:T,currentJobId:x,onCancelJob:k,onComposerInput:S,agentData:Q,refetch:R,messageInputRef:_,cwd:A,onChangeCwd:E,sendError:I,sessionStatus:L,canonical:z,runDetails:V})=>{const[q,Z]=b.useState(!1),j=b.useRef(null),M=b.useRef(null);b.useEffect(()=>{if(!j.current)return;const Ce=new ResizeObserver(Be=>{for(const Yt of Be)Yt.contentRect.width<550?Z(!0):Z(!1)});return Ce.observe(j.current),()=>{Ce.disconnect()}},[]);const Y=Gr(Ce=>Ce.canvasWidth),F=Gr(Ce=>Ce.setCanvasWidth),X=Gr(Ce=>Ce.restoreDefaultCanvasWidth),W=o,U=dr(Ce=>Ce.conversations[W]),J=dr(Ce=>Ce.setOpenTabs),he=dr(Ce=>Ce.setSelectedTab),ue=dr(Ce=>Ce.setFiles),we=Gr(Ce=>Ce.isCanvasOpen),xe=(U??qA).openTabs,dt=(U??qA).selectedTabId,re=(U??qA).files,it=Y===0?450:Y,Ue=b.useCallback(Ce=>he(W,Ce),[W,he]),pt=b.useCallback(()=>{Gr.getState().setCanvasOpen(!1)},[]),We=b.useCallback(Ce=>{const Be=xe.filter(Ht=>Ht.id!==Ce),Yt=re.filter(Ht=>Ht.id!==Ce);J(W,Be),ue(W,Yt),dt===Ce&&he(W,Be.length>0?Be[0].id:null)},[W,re,xe,dt,ue,J,he]),ge=pie(),ve=(Ce,Be)=>Be;return p.jsxs("div",{className:"relative flex h-full w-full flex-row overflow-hidden",children:[p.jsx("div",{className:"relative h-full w-0 min-w-[220px] flex-1",children:p.jsxs("div",{ref:j,className:"flex h-full min-h-0 grow flex-col overflow-hidden rounded-none bg-canvas",children:[p.jsx(BHt,{agentName:n,description:r,onOpenOptions:i,runDetails:V}),!z&&p.jsx(gKt,{open:s,onClose:a,agentId:o}),ge,ve("chat",z?p.jsx(Syt,{frontend:z.view.frontend,transcript:z.view.transcript,gate:z.view.frontend?.pending_gate??null,waiting:z.busy,loadingOlder:z.view.loadingOlder,onLoadOlder:z.view.loadOlder,containerRef:m,isSmallView:q,status:z.view.status,error:z.view.error}):p.jsx(fTe,{messages:l,isLoading:c,isLoadingMessages:u,isFetchingMore:d,jobStatus:O,agentName:n,currentExecution:g,messagesContainerRef:m,messagesEndRef:v,scrollToBottom:w,refetch:R,conversationId:o,isSmallView:q})),(z||!(u&&l.length===0))&&p.jsx(tTe,{ref:_,onSendMessage:T,onComposerInput:S,initialSuggestions:ann,isLoading:z?!!z.admitting:c,conversationId:o,messages:z?z.view.transcript.records.length>0?lnn:l.length>0?l:onn:l,isHydrating:z?z.view.status==="connecting":!1,currentJobId:z?null:x,onCancelJob:k,canonicalStop:z?{active:z.busy,onStop:z.onStop}:void 0,isFarFromBottom:h,hasNewActivity:f,scrollToBottom:w,agentData:Q,cwd:A,onChangeCwd:E,sendError:I,sessionStatus:L,isSmallView:q})]})}),we&&p.jsxs(p.Fragment,{children:[p.jsx(noe,{sidebarWidth:it,onSidebarWidthChange:F,minWidth:400,maxWidth:1200,side:"left",onDoubleClick:X}),p.jsx("div",{ref:M,style:{minWidth:it,width:it},className:"relative h-full overflow-hidden border-l border-hairline transition-[width] duration-base ease-out-quart",children:p.jsx(YZt,{activeDocumentId:dt,initialDocuments:re,conversationId:W,agentId:o,currentWorkingDirectory:A,onChangeActiveDocument:Ue,onClose:pt,onCloseDocument:We})})]})]})});function unn(e){return _r({queryKey:["desktop","profiles"],enabled:e,queryFn:()=>un({op:"profiles.list"}).then(t=>t.profiles),retry:$C,staleTime:1e4})}function dnn(e){return _r({queryKey:["desktop","teams"],enabled:e,queryFn:()=>un({op:"teams.list"}).then(t=>t.teams),retry:$C,staleTime:1e4})}const hnn=(e,t)=>{t(""),e?.focus()},Hm="flex h-8 min-w-0 items-center gap-1 rounded-md px-1 text-body-sm leading-5 hover:bg-elevated focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",fnn=new Set(["idle","recent"]);function Onn({row:e}){const t=e.status?.code,n=t==="busy"?C8:t==="approval"||t==="answer"||t==="wedged"||t==="error"?tS:t==="interrupted"||t==="dormant"?QEe:t==="complete"?uc:t==="scheduled"?vC:t==="attached"?bC:fnn.has(t??"recent")?d2e:$8,r=t==="busy"?"text-info motion-safe:animate-spin":t==="error"||t==="wedged"?"text-danger":t==="approval"||t==="answer"||t==="interrupted"?"text-warning":t==="complete"?"text-success":"text-ink-dim";return p.jsxs("span",{className:"flex size-4 shrink-0",title:e.status?.label??"Recent",children:[p.jsx(n,{className:G("size-4",r),"aria-hidden":"true"}),p.jsx("span",{className:"sr-only",children:e.status?.label??"Recent"})]})}function pnn({selectedConversation:e,onSelectConversation:t,onStageDraft:n}){const r=Js(),i=Gh(),s=nd(i.data,"session_catalogue",2),a=b.useRef(null),o=b.useRef(!1);s&&(o.current=!0);const l=!!i.error&&o.current,c=s||l,u=unn(s&&nd(i.data,"profile_catalogue")),d=dnn(s&&nd(i.data,"team_catalogue")),h=Bn(Y=>Y.sessions),f=Bn(Y=>Y.fetchSessions),O=Bn(Y=>Y.loading),g=Bn(Y=>Y.error),m=Bn(Y=>Y.truncated),v=Bn(Y=>Y.activeDraftKey),w=Bn(Y=>Y.drafts),y=Bn(Y=>Y.pendingSessionId),[T,x]=b.useState(""),[k,S]=b.useState(!1),[Q,R]=b.useState(()=>{try{return JSON.parse(localStorage.getItem("chat-sidebar-disclosures")??"{}")}catch{return{}}}),_=(Y,F=!1)=>Q[Y]??F,A=(Y,F=!1)=>R(X=>({...X,[Y]:!(X[Y]??F)}));b.useEffect(()=>{localStorage.setItem("chat-sidebar-disclosures",JSON.stringify(Q))},[Q]),b.useEffect(()=>{if(!s)return;f();const Y=window.setInterval(()=>{document.visibilityState==="visible"&&f()},5e3);return()=>window.clearInterval(Y)},[s,f]);const E=b.useMemo(()=>h.filter(Y=>`${Y.title??""} ${Y.binding?.agent??""} ${Y.binding?.team??""}`.toLocaleLowerCase().includes(T.toLocaleLowerCase())),[h,T]),I=(Y,F)=>E.filter(X=>Y==="team"?X.binding?.team===F:!X.binding?.team&&X.binding?.agent===F),L=v?w[v]:void 0,z=Y=>Y.binding?.team||Y.binding?.agent||"",V=b.useMemo(()=>new Set(Object.values(w).filter(Y=>Y.sessionId).map(Y=>Y.sessionId)),[w]),q=(Y,F=!1)=>p.jsxs("button",{type:"button","data-chat-row":!0,"data-child":F||void 0,className:G(Hm,"w-full text-left",F&&"pl-7",e===Y.session_id&&!v&&"bg-accent-wash text-ink",Y.attention?.unseen&&"font-semibold"),"aria-current":e===Y.session_id&&!v?"page":void 0,title:`${Y.title||"Untitled chat"}${z(Y)?` (${z(Y)})`:""}: ${Y.status?.label??"Recent"}${Y.attention?.unseen?", unread":""}`,onClick:()=>t(Y.session_id),children:[p.jsx(Onn,{row:Y}),p.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[Y.title||"Untitled chat",!F&&z(Y)&&p.jsxs("span",{className:"ml-1 text-meta text-ink-muted",children:["· ",z(Y)]}),V.has(Y.session_id)&&p.jsx("span",{className:"ml-1 text-meta text-ink-muted",children:"· Not sent yet"})]}),y===Y.session_id&&p.jsx(C8,{className:"size-4 shrink-0 motion-safe:animate-spin","aria-label":"Opening chat"})]},Y.session_id),Z=(Y,F)=>{const X=I(Y,F),W=`${Y}:${F}`,U=!!T||_(W);if(T&&!F.toLocaleLowerCase().includes(T.toLocaleLowerCase())&&!X.length)return null;const J=Y==="team"?gh:sv;return p.jsxs("div",{"data-entity":!0,children:[p.jsxs("div",{className:G("group flex h-8 items-center gap-1 rounded-md",L?.target?.kind===Y&&L.target.name===F&&"bg-accent-wash"),children:[p.jsx("button",{type:"button","data-disclosure":!0,"aria-label":`${U?"Collapse":"Expand"} ${F} chats`,"aria-expanded":U,className:"flex size-6 shrink-0 items-center justify-center rounded-md hover:bg-elevated",onClick:()=>A(W),children:U?p.jsx(o1,{className:"size-3.5"}):p.jsx(og,{className:"size-3.5"})}),p.jsxs("button",{type:"button","data-chat-row":!0,"data-entity-name":!0,className:G(Hm,"flex-1 text-left"),onClick:()=>n({kind:Y,name:F}),"aria-label":`New chat with ${F}`,title:`New chat with ${F}`,children:[p.jsx(J,{className:"size-4 shrink-0"}),p.jsx("span",{className:"min-w-0 flex-1 truncate",children:F}),p.jsx(Eq,{className:G("size-4 shrink-0 text-ink opacity-0","transition-opacity duration-base ease-out-quart","group-hover:opacity-100 group-hover:duration-fast","group-focus-within:opacity-100 group-focus-within:duration-fast"),"aria-hidden":"true"}),p.jsx("span",{className:"min-w-4 shrink-0 text-right text-meta tabular-nums text-ink-dim",children:X.length||""})]}),p.jsx("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center rounded-md text-ink-dim hover:bg-elevated hover:text-ink-muted","aria-label":`Manage ${F}`,onClick:()=>r(`/agents?kind=${Y}&name=${encodeURIComponent(F)}`),children:p.jsx(T8,{className:"size-4"})})]}),U&&p.jsxs("div",{children:[X.map(he=>q(he,!0)),!X.length&&p.jsx("p",{className:"py-1 pl-7 text-meta text-ink-dim",children:"No chats yet"})]})]},W)},j=(Y,F,X,W)=>p.jsxs("button",{type:"button","data-chat-row":!0,className:"flex h-7 w-full items-center gap-1 rounded-md px-1 text-body-sm font-medium text-ink-muted hover:bg-elevated","aria-expanded":T?!0:_(Y,X),onClick:()=>A(Y,X),children:[T||_(Y,X)?p.jsx(o1,{className:"size-3.5"}):p.jsx(og,{className:"size-3.5"}),p.jsx("span",{className:"flex-1 text-left",children:F}),!!W&&p.jsx("span",{className:"text-meta tabular-nums",children:W})]}),M=Y=>{const F=Y.target;if(F.tagName==="INPUT"){Y.key==="Escape"&&(x(""),F.blur());return}if(Y.key==="Escape"){Y.preventDefault(),a.current?.focus();return}const X=[...Y.currentTarget.querySelectorAll("[data-chat-row]")],W=X.indexOf(F),U=Y.key==="ArrowDown"?Math.min(X.length-1,W+1):Y.key==="ArrowUp"?Math.max(0,W-1):Y.key==="Home"?0:Y.key==="End"?X.length-1:-1;if(U>=0){Y.preventDefault(),X[U]?.focus();return}const J=F.closest("[data-entity]"),he=J?.querySelector("[data-disclosure]");Y.key==="ArrowRight"&&he&&(Y.preventDefault(),he.getAttribute("aria-expanded")==="false"?he.click():J?.querySelector("[data-child]")?.focus()),Y.key==="ArrowLeft"&&he&&(Y.preventDefault(),F.hasAttribute("data-child")?J?.querySelector("[data-entity-name]")?.focus():he.getAttribute("aria-expanded")==="true"&&he.click())};return p.jsxs("nav",{"aria-label":"Chats",className:"flex h-full min-h-0 flex-col bg-surface p-2 text-ink",onKeyDown:M,children:[p.jsx("div",{className:"flex h-8 items-center px-1",children:p.jsx("h2",{className:"text-body-sm font-medium",children:"Chats"})}),p.jsxs("div",{className:"relative my-2",children:[p.jsx("input",{ref:a,"aria-label":"Search chats and agents",placeholder:"Search chats and agents",className:"h-8 w-full rounded-md border border-control bg-surface pr-9 pl-2 text-body-sm",value:T,onChange:Y=>x(Y.target.value)}),T&&p.jsx(Te,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2 focus-visible:outline-offset-[-2px]!",onClick:()=>hnn(a.current,x),"aria-label":"Clear search",children:p.jsx(Rs,{"aria-hidden":"true"})})]}),p.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto p-1",children:[i.isLoading&&p.jsx("p",{"aria-live":"polite",className:"text-meta text-ink-muted",children:"Connecting to chats…"}),i.error&&p.jsxs("div",{role:"alert",className:"space-y-1 text-body-sm text-danger",children:[p.jsxs("p",{children:[i.error.message,l?" Showing the last chats loaded.":""]}),p.jsx("button",{type:"button",className:"underline",onClick:()=>void i.refetch(),children:"Retry"})]}),i.data&&!s&&!i.error&&p.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:"Update the backend to use canonical chats. Existing histories are unchanged."}),c&&p.jsxs("div",{className:G("space-y-4 pb-2",l&&"opacity-60"),children:[p.jsxs("section",{children:[j("agents","Agents",!0),(T||_("agents",!0))&&p.jsxs(p.Fragment,{children:[u.isLoading&&p.jsx("p",{"aria-live":"polite",className:"text-meta text-ink-muted",children:"Loading agents…"}),u.data?.map(Y=>Z("agent",Y.name)),p.jsxs("button",{type:"button",className:G(Hm,"w-full text-ink-muted"),onClick:()=>r("/agents?create=agent"),children:[p.jsx(yy,{className:"size-4"}),"Create agent"]})]})]}),p.jsxs("section",{children:[j("teams","Teams",!0),(T||_("teams",!0))&&p.jsxs(p.Fragment,{children:[d.data?.map(Y=>Z("team",Y.name)),p.jsxs("button",{type:"button",className:G(Hm,"w-full text-ink-muted"),onClick:()=>r("/agents?create=team"),children:[p.jsx(yy,{className:"size-4"}),"Create team"]})]})]})]})]}),c&&p.jsxs("div",{className:G("mt-2 max-h-[45%] shrink-0 space-y-4 overflow-y-auto border-t border-hairline pt-2",l&&"opacity-60"),children:[p.jsxs("section",{children:[p.jsxs("button",{type:"button","data-chat-row":!0,className:G(Hm,"w-full",k&&"bg-accent-wash"),"aria-pressed":k,onClick:()=>S(Y=>!Y),children:[p.jsx(UX,{className:"size-4"}),p.jsx("span",{className:"flex-1 text-left",children:"All chats"}),E.length>0&&p.jsx("span",{className:"text-meta tabular-nums",children:E.length})]}),p.jsxs("button",{type:"button","data-chat-row":s||void 0,className:G(Hm,"mb-1 w-full disabled:text-ink-disabled disabled:hover:bg-transparent",!!v&&!L?.target&&"bg-accent-wash"),"aria-current":v&&!L?.target?"page":void 0,disabled:!s,onClick:()=>n(void 0,!0),children:[p.jsx(Eq,{className:"size-4"}),p.jsx("span",{className:"flex-1 text-left",children:"New chat"})]})]}),k?p.jsx("section",{children:E.map(Y=>q(Y))}):p.jsxs(p.Fragment,{children:[p.jsxs("section",{children:[j("active","Active chats",!0,E.filter(Y=>Y.active).length),(T||_("active",!0))&&(E.some(Y=>Y.active)?E.filter(Y=>Y.active).map(Y=>q(Y)):p.jsx("p",{className:"px-2 text-meta text-ink-muted",children:"Nothing running right now."}))]}),p.jsxs("section",{children:[j("previous","Previous chats",!1,E.filter(Y=>!Y.active).length),(T||_("previous"))&&E.filter(Y=>!Y.active).map(Y=>q(Y))]})]}),!h.length&&!O&&p.jsx("p",{className:"text-meta text-ink-muted",children:"No chats yet. Choose an agent, team or New chat."}),m&&p.jsx("p",{className:"text-meta text-ink-muted",children:"Showing up to 500 chats. Older chats remain available in the terminal."})]}),(g||u.error||d.error)&&p.jsxs("div",{role:"alert",className:"pt-2 text-meta text-danger",children:[p.jsx("p",{children:g||u.error?.message||d.error?.message}),p.jsx("button",{type:"button",className:"mt-1 underline",onClick:()=>{f(),u.refetch(),d.refetch()},children:"Retry refresh"})]})]})}const gnn=/^\/([A-Za-z]+)(?:\s([\s\S]*))?$/;function mnn(e,t){return{id:Fo(),role:"system",message:e,timestamp:new Date,status:t}}function vnn(e,t){const n=(r,i)=>{const s=Array.from({length:i.length+1},(a,o)=>o);for(let a=1;a<=r.length;a++){let o=s[0];s[0]=a;for(let l=1;l<=i.length;l++){const c=s[l];s[l]=Math.min(s[l]+1,s[l-1]+1,o+(r[a-1]===i[l-1]?0:1)),o=c}}return s[i.length]};return t.map(r=>({name:r.name,score:n(e,r.name)})).sort((r,i)=>r.score-i.score).slice(0,3).map(r=>`/${r.name}`)}const wnn=new Set(["session.goal","session.context","session.compact"]);function bnn({sessionId:e,addMessage:t,canonical:n,rebind:r,focusComposer:i}){const s=Js(),a=Gh(),o=nd(a.data,"commands"),l=_r({queryKey:td.commands,queryFn:()=>un({op:"commands.list"}).then(m=>m.commands),enabled:o,staleTime:3e5}),[c,u]=b.useState(null),d=b.useRef(null),h=b.useCallback(()=>{u(null);const m=d.current;d.current=null,m&&requestAnimationFrame(()=>{m.isConnected?m.focus():i?.()})},[i]),f=b.useCallback((m,v=!1)=>{if(e&&n.status!=="unavailable"){n.addNote(m,v?"error":"info");return}t(mnn(m,v?"error":void 0))},[t,n.addNote,n.status,e]),O=b.useCallback(async m=>{const v=gnn.exec(m.trim());if(!v||!o)return"not-a-command";const[,w,y]=v,T=y?.trim()??"",x=l.data??[],k=x.find(_=>_.name===w)??x.find(_=>_.aliases.includes(w));if(!k){const _=vnn(w,x);return f(_.length>0?`Unknown command /${w}. Did you mean ${_.join(", ")}? Type / for the full list.`:`Unknown command /${w}. Type / for the full list.`,!0),"consumed"}const S=f6[k.destination];if(S?.kind==="direct")return S.action==="clear"?(n.clearView(),"consumed"):(window.api?.desktop?.closeWindow?await window.api.desktop.closeWindow():f("Close this window to quit. Conversations keep running in the background."),"consumed");if(S?.kind==="navigate")return s(S.route(T,e??"")),"consumed";if(!e)return f(`/${k.name} needs an open conversation. Start one first.`,!0),"consumed";if(!T&&wnn.has(k.destination))return u({action:{kind:"native_action",destination:k.destination,session_id:e,args:"",fields:[],data:{}},spec:k,sessionId:e,canonical:n,commands:x,onClose:h,note:f,dispatch:_=>void O(_),rebind:r}),"consumed";const Q=k.name==="credential"?"":T,R=e6e(k.name,Q);if(R)return f(R,!0),"retained";try{const A=(await un({op:"sessions.command",sessionId:e,requestId:Fo(),command:k.name,args:Q})).result;if(b1(A)){const E=A,I=f6[E.destination];return I?.kind==="navigate"?(s(I.route(E.args,e)),"consumed"):I?(d.current=document.activeElement instanceof HTMLElement?document.activeElement:null,u({action:E,spec:k,sessionId:e,canonical:n,commands:x,onClose:h,note:f,dispatch:L=>void O(L),rebind:r}),"consumed"):(f(`/${k.name} is not available in the desktop app yet. Run it in the terminal with local-operator.`,!0),"consumed")}if(A.text)f(A.text,A.kind==="error"||A.style==="error");else if(A.kind==="block"){const E=A.data;Array.isArray(E.items)&&f([E.title,...E.items.map(([I,L])=>`${I}: ${L}`)].filter(Boolean).join(`
|
|
1314
1314
|
`))}return"consumed"}catch(_){return f(`/${k.name} could not run: ${_ instanceof Error?_.message:"the backend refused it"}`,!0),"retained"}},[o,l.data,e,f,s,n,r,h]),g=b.useCallback(async m=>{await O(m)==="not-a-command"&&f("The backend could not complete this request. Check its connection and try again.",!0)},[O,f]);return{dispatch:O,dispatchFromControl:g,picker:c,closePicker:h}}const ynn=/^[a-f0-9]{12}$/,xnn={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"},Snn=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,$nn=/^file:\/\//;async function knn(e,t){const n=[];for(const r of e){const i=Snn.exec(r);if(i){n.push({data_b64:i[3],mime_type:i[1]});continue}const s=r.split(".").pop()?.toLowerCase()??"",a=xnn[s];if(!a||!window.api?.readFile)continue;const o=await window.api.readFile(r.replace($nn,""),"base64");o.success&&n.push({data_b64:o.data,mime_type:a})}return jFe(n.slice(0,8),EC,r=>r6(t,r))}function Tnn({identity:e,draftKey:t,sessionId:n,pendingNavigation:r}){const i=lIe(n,!!n);uIe(n,i.subscriptionId);const s=Gh(),a=hIe(n,s.data),o=b.useRef(null),l=b.useRef(null),c=b.useRef(null),u=BU(t,n),d=Bn(ve=>u?ve.drafts[u]:void 0),h=Bn(ve=>ve.cwd),f=Bn(ve=>ve.setCwd),[O,g]=b.useState(!1),m=b.useRef(!1),v=b.useRef(""),[w,y]=b.useState(null),[T,x]=b.useState(),[k,S]=b.useState(!1),[Q,R]=b.useState("chat"),{isFarFromBottom:_,scrollToBottom:A}=v6e(50,l,i.transcript.records.length),E=i.frontend?.streaming===!0,I=b.useMemo(()=>i.frontend?uHt({jobs:i.frontend.jobs,todos:i.frontend.todos}):null,[i.frontend]),L=Js(),z=ve=>{Bn.getState().openSession(ve).then(Ce=>{Ce&&L(`/chat/${ve}`)})},V=_r({queryKey:["desktop","entities",n,"effort",""],queryFn:()=>un({op:"commands.entities",sessionId:n,command:"effort"}),enabled:!!n,staleTime:15e3}),q=ks(),Z=r7(i.frontend?.effective_model)?null:i.frontend?.effective_model?.model_id??null,j=b.useRef(void 0);b.useEffect(()=>{const ve=j.current;j.current={session:n??null,model:Z},!(!n||!Z||!(ve?.session===n)||ve?.model===Z)&&q.invalidateQueries({queryKey:["desktop","entities",n,"effort",""]})},[n,Z,q]);const{dispatch:M,dispatchFromControl:Y,picker:F}=bnn({sessionId:n,canonical:i,rebind:z,addMessage:ve=>i.addNote(ve.message??""),focusComposer:()=>o.current?.focusInput()});b.useEffect(()=>{t&&o.current?.focusInput()},[t]),b.useEffect(()=>{if(!n||!i.frontend)return;const ve=Bn.getState();ve.sessions.some(Ce=>Ce.session_id===n)&&ve.upsertSession({session_id:n,...vIe({liveTitle:i.frontend.conversation_title}),attention:i.frontend.attention})},[n,i.frontend]),b.useEffect(()=>{const ve=JSON.stringify([n,i.frontend?.streaming,i.frontend?.attention?.unseen,i.frontend?.active_agent,i.frontend?.active_team]);!n||ve===v.current||(v.current=ve,Bn.getState().fetchSessions())},[n,i.frontend?.streaming,i.frontend?.attention?.unseen,i.frontend?.active_agent,i.frontend?.active_team]);const X=async(ve,Ce,Be)=>{const Yt=Bn.getState(),Ht=BU(t,n);if(!Ht)return!1;const pn=Yt.drafts[Ht];if(r||m.current||pn?.pending)return!1;m.current=!0,g(!0),y(null),x(void 0);try{const Xt=await M(ve);if(Xt==="consumed")return!0;if(Xt==="retained"||!t&&!n)return!1;const Tt=i.frontend?.pending_gate;if(Tt&&i.ownerEpoch&&n){if(Tt.kind==="approval"){const Et=ve.trim().toLowerCase(),gt=["y","yes","approve","ok","allow"].includes(Et);if(!gt&&!["n","no","deny","reject","cancel"].includes(Et))throw new Error("Reply yes or no to answer the approval request.");await un({op:"sessions.answer",sessionId:n,epoch:i.ownerEpoch,requestId:Tt.request_id,approved:gt})}else await un({op:"sessions.answer",sessionId:n,epoch:i.ownerEpoch,requestId:Tt.request_id,value:ve,questionIndex:Tt.question_index});return!0}const ye=await knn(Ce,ve),je=n6e(ve,ye);if(je)return y(je),!1;const Ye=await OIe(Ht,{text:ve,attachments:Ce,images:ye,mode:E?"steer":"prompt",cwd:h},n,Be);return Ye?(t&&Bn.getState().activeSessionId===Ye&&L(`/chat/${Ye}`,{replace:!0}),Yt.fetchSessions(),!0):!1}catch(Xt){return y(GX(Xt,Qoe)),x(Xt instanceof Error&&"code"in Xt&&typeof Xt.code=="string"?Xt.code:void 0),Eoe(Xt)?!1:K8}finally{m.current=!1,g(!1)}},W=()=>{n&&un({op:"sessions.command",sessionId:n,requestId:crypto.randomUUID(),command:"stop"}).catch(ve=>y(GX(ve,"Stop could not be confirmed.")))},U=i.frontend?.active_team||i.frontend?.active_agent||d?.target?.name,J=Bn(ve=>n?ve.sessions.find(Ce=>Ce.session_id===n):void 0),he=[i.frontend?.active_agent,i.frontend?.active_team].filter(Boolean).join(" · ")||[J?.binding?.agent,J?.binding?.team].filter(Boolean).join(" · "),ue=mIe({draftKey:t,draftTarget:U,liveTitle:i.frontend?.conversation_title,catalogueTitle:J?.title}),we=n?i:{...i,status:"live",error:null},xe=w||d?.error,dt=T??d?.errorCode,re=()=>{y(null),x(void 0)},it=i.frontend?.active_team||i.frontend?.active_agent,Ue=dt==="unresolved_attachment"&&!!it;b.useEffect(()=>{Ue&&(y(null),x(void 0),u&&Bn.getState().updateDraft(u,{error:void 0,errorCode:void 0}))},[Ue,u]);const pt=d?.admissionAttempted&&!d.pending?d.submittedText:void 0,We=()=>{u&&Bn.getState().releaseClaim(u),re()},ge=xe||pt!==void 0?{message:xe??void 0,actions:dt===Coe?void 0:dt==="unresolved_attachment"?[{label:"Choose agent",onClick:()=>void M("/agent")},{label:"Choose team",onClick:()=>void M("/team")}]:dt==="profile_registry_unavailable"?[{label:"Manage agents",onClick:()=>L("/agents")}]:void 0,heldText:pt,onRestoreHeld:pt!==void 0?()=>re():void 0,onDiscard:d?.submittedText&&!d.pending?()=>{u&&Bn.getState().discardDraft(u),re()}:void 0,onReleaseHeld:pt!==void 0?We:void 0,onDismiss:()=>{re(),u&&d&&Bn.getState().updateDraft(u,{error:void 0,errorCode:void 0})}}:void 0;return p.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[k&&p.jsx("div",{className:G("flex flex-wrap gap-2 border-b border-hairline px-4 py-2 text-body-sm"),children:["model","agent","team","rename","resume","fork","new","settings"].map(ve=>p.jsx("button",{type:"button",className:G("rounded-md px-2 py-1 hover:bg-elevated"),onClick:()=>{S(!1),M(`/${ve}`)},children:ve==="agent"?"Choose agent":ve==="team"?"Choose team":ve.charAt(0).toUpperCase()+ve.slice(1)},ve))}),p.jsx("div",{className:G("min-h-0 flex-1"),children:p.jsx(cnn,{activeTab:Q,onTabChange:R,agentName:ue,description:he||(t?"The session starts when you send your first message.":i.frontend?.cwd||"Canonical chat"),onOpenOptions:()=>S(ve=>!ve),isOptionsSidebarOpen:!1,onCloseOptions:()=>S(!1),agentId:e,cwd:t?h:i.frontend?.cwd,onChangeCwd:t&&!d?.sessionId&&!O?f:void 0,messages:[],isLoading:!1,isLoadingMessages:!1,isFetchingMore:i.loadingOlder,isFarFromBottom:_,messagesContainerRef:l,messagesEndRef:c,scrollToBottom:A,rawInfoContent:JSON.stringify(i.frontend,null,2),onSendMessage:X,sendError:ge,sessionStatus:n?{frontend:i.frontend,pendingModel:i.pendingModel,onCommand:ve=>void Y(ve),effortEntities:V.data?.entities}:void 0,currentJobId:null,onCancelJob:W,messageInputRef:o,runDetails:I,onComposerInput:a,canonical:{view:we,busy:E,admitting:O||r,onStop:W}})}),p.jsx(FFe,{context:F})]})}function ore(){const{agentId:e}=Wse(),t=Js(),n=Gh(),r=nd(n.data,"session_catalogue",2),i=Bn(g=>g.activeSessionId),s=Bn(g=>g.activeDraftKey),a=Bn(g=>s?g.drafts[s]:void 0),o=Bn(g=>g.pendingSessionId),l=Bn(g=>g.error),[c,u]=b.useState(null);b.useEffect(()=>{if(!r||!e)return;const g=Bn.getState(),m=ynn.test(e)?e:g.sessionByAgent[e];if(!m){u("This legacy link has no canonical chat. Its saved history is unchanged.");return}u(null),(g.activeSessionId!==m||g.activeDraftKey)&&g.openSession(m)},[r,e]),b.useEffect(()=>{const g=m=>{m.key==="Escape"&&Bn.getState().pendingSessionId&&(m.preventDefault(),Bn.getState().cancelOpen())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]);const d=(g,m)=>{Bn.getState().stageDraft(g,m),u(null),t("/chat")},h=g=>{Bn.getState().openSession(g).then(m=>{m&&(u(null),t(`/chat/${g}`))})},f=s?a?.sessionId:i??void 0,O=fIe(s,f);return p.jsx(WXe,{sidebar:p.jsx(pnn,{selectedConversation:i??void 0,onSelectConversation:h,onStageDraft:d}),content:p.jsxs("div",{className:G("flex h-full min-h-0 flex-col"),children:[o&&p.jsxs("p",{"aria-live":"polite",className:G("px-4 py-2 text-body-sm text-info"),children:["Opening chat…"," ",p.jsx("button",{type:"button",onClick:()=>Bn.getState().cancelOpen(),children:"Cancel"})]}),(c||l)&&p.jsx("p",{role:"alert",className:G("px-4 py-2 text-body-sm text-danger"),children:c||l}),r?O?p.jsx("div",{className:G("min-h-0 flex-1"),children:p.jsx(Tnn,{identity:O,draftKey:s,sessionId:f,pendingNavigation:!!o},O)}):p.jsxs("div",{className:G("p-6"),children:[p.jsx("h1",{className:G("text-title"),children:"Start a chat"}),p.jsx("p",{className:G("mt-2 text-body text-ink-muted"),children:"Choose an agent or team, or start a new chat. Nothing starts until you send."}),p.jsx("button",{type:"button",className:G("mt-4 rounded-md border border-control px-3 py-2"),onClick:()=>d(void 0,!0),children:"New chat"})]}):p.jsxs("div",{className:G("p-6 text-body text-ink-muted"),children:[n.isLoading?"Connecting to the backend…":n.error?n.error.message:"Update the backend to use canonical chats. Your existing histories are unchanged.",p.jsx("button",{type:"button",className:G("ml-2 underline"),onClick:()=>void n.refetch(),children:"Retry"})]})]})})}const Pnn=e=>p.jsx(e.icon,{size:16}),_nn={general:"settings-sidebar-general",radient:"settings-sidebar-radient-account",integrations:"settings-sidebar-integrations",appearance:"settings-sidebar-appearance",credentials:"settings-sidebar-api-credentials",updates:"settings-sidebar-application-updates"},Cnn=[{label:"General",ids:["general","appearance"]},{label:"Account",ids:["radient","providers","integrations","credentials"]},{label:"Backend",ids:["backend"]},{label:"System",ids:["updates"]}],son=({activeSection:e,onSelectSection:t,sections:n})=>{const r=Uue("(min-width: 1040px)"),i=s=>{const a=e===s.id,o=p.jsxs("button",{type:"button",onClick:()=>t(s.id),"aria-current":a?"page":void 0,"aria-label":r?void 0:s.label,"data-tour-tag":_nn[s.id],className:G("flex h-8 w-full items-center rounded-sm text-left text-body-sm","transition-colors duration-fast ease-out-quart",r?"justify-start gap-2 px-3":"justify-center",a?"bg-accent-wash font-medium text-ink":"text-ink-muted hover:bg-elevated hover:text-ink"),children:[p.jsx("span",{"aria-hidden":"true",className:G("flex size-4 shrink-0 items-center justify-center",a?"text-accent":"text-ink-dim"),children:p.jsx(s.icon,{size:16})}),r&&p.jsx("span",{className:"truncate",children:s.label})]});return r?p.jsx("li",{children:o},s.id):p.jsx("li",{children:p.jsx(vt,{content:s.label,side:"right",children:o})},s.id)};return p.jsx("nav",{"aria-label":"Settings sections",className:"flex h-full w-full flex-col overflow-hidden bg-surface",children:p.jsx("div",{className:"flex flex-1 flex-col gap-6 overflow-y-auto px-2 py-4",children:Cnn.map(s=>{const a=n.filter(o=>s.ids.includes(o.id));return a.length===0?null:p.jsxs("div",{children:[r&&p.jsx("div",{className:"px-3 pb-1 text-meta text-ink-dim",children:s.label}),p.jsx("ul",{className:"flex flex-col gap-0.5",children:a.map(i)})]},s.label)})})})},Qnn=[{id:"general",label:"General settings",icon:dh},{id:"radient",label:"Radient account",icon:I6e},{id:"integrations",label:"Integrations",icon:zEe},{id:"appearance",label:"Appearance",icon:$Ee},{id:"providers",label:"Providers",icon:cae},{id:"backend",label:"Backend settings",icon:dae},{id:"credentials",label:"API credentials",icon:U5e},{id:"updates",label:"Application updates",icon:iO}],Enn=[{name:"Chat",path:"/chat",category:"Navigation",icon:p.jsx(bC,{size:16})},{name:"My agents",path:"/agents",category:"Navigation",icon:p.jsx(sv,{size:16})},{name:"Agent hub",path:"/agent-hub",category:"Navigation",icon:p.jsx(fae,{size:16})},{name:"Schedules",path:"/schedules",category:"Navigation",icon:p.jsx(Bse,{size:16})},{name:"Settings",path:"/settings",category:"Navigation",icon:p.jsx(dh,{size:16})}],lre=15,cre="command-palette-results",ure="command-palette-input",Rnn={page:"Go","agent-chat":"Open","agent-settings":"Open","settings-section":"Open","create-agent":"Create","clear-conversation":"Clear","toggle-canvas":"Toggle"},Rw=({children:e})=>p.jsx("kbd",{className:"rounded-xs bg-sunken px-1 py-0.5 font-mono text-ink-dim text-mono-sm",children:e}),Ann=()=>{const e=Js(),t=jg(),{isCommandPaletteOpen:n,closeCommandPalette:r,commandPaletteQuery:i,setCommandPaletteQuery:s,isCanvasOpen:a,setCanvasOpen:o,isCreateAgentDialogOpen:l,closeCreateAgentDialog:c}=Gr(),{agentId:u}=g6e(),{getLastAgentId:d}=Iae(),[h,f]=b.useState(i),O=IS(h,200),{data:g}=M8(1,10,0,O),m=ioe(),[v,w]=b.useState(0),[y,T]=b.useState(!1),x=u||d("chat"),k=t.pathname.startsWith("/chat");b.useEffect(()=>{s(O)},[O,s]),b.useEffect(()=>{n&&f(i)},[n,i]);const S=b.useMemo(()=>Enn.map((Y,F)=>({...Y,id:`page-${F}`,type:"page"})),[]),Q=b.useMemo(()=>Qnn.map(Y=>({id:`settings-section-${Y.id}`,type:"settings-section",name:Y.label,category:"Settings",path:`/settings?section=${Y.id}`,icon:Pnn(Y)})),[]),R=b.useCallback(()=>{r(),e("/agents?create=agent")},[r,e]),_=b.useCallback(()=>{x&&T(!0)},[x]),A=b.useCallback(()=>{x&&m.mutate({agentId:x}),T(!1),r()},[x,m,r]),E=b.useCallback(()=>{T(!1)},[]),I=b.useCallback(()=>{o(!a),r()},[a,o,r]),L=b.useCallback(Y=>{e(`/chat/${Y}`),c()},[e,c]),z=b.useMemo(()=>{const Y=[];return Y.push({id:"create-agent",type:"create-agent",name:"Create agent",category:"Actions",icon:p.jsx(yy,{size:16}),action:R}),k&&x&&Y.push({id:"clear-conversation",type:"clear-conversation",name:"Clear conversation",category:"Actions",icon:p.jsx(A8,{size:16}),action:_}),k&&Y.push({id:"toggle-canvas",type:"toggle-canvas",name:a?"Close canvas":"Open canvas",category:"Actions",icon:a?p.jsx(oae,{size:16}):p.jsx(PEe,{size:16}),action:I}),Y},[k,x,a,R,_,I]),V=b.useCallback(Y=>{Y.action?Y.action():Y.path&&(e(Y.path),r())},[e,r]),q=b.useMemo(()=>{const Y=[];if(g?.agents)for(const F of g.agents)Y.push({id:`agent-chat-${F.id}`,type:"agent-chat",name:F.name,hint:"Open chat",category:"Agents",path:`/chat/${F.id}`,icon:p.jsx(bC,{size:16})}),Y.push({id:`agent-settings-${F.id}`,type:"agent-settings",name:F.name,hint:"Agent settings",category:"Agents",path:`/agents/${F.id}`,icon:p.jsx(dh,{size:16})});return[...z,...S,...Q,...Y]},[g,S,Q,z]),Z=b.useMemo(()=>{if(!O)return q.slice(0,lre);const Y=O.toLowerCase();return q.filter(X=>X.name.toLowerCase().includes(Y)||X.category.toLowerCase().includes(Y)||X.hint?.toLowerCase().includes(Y)).slice(0,lre)},[q,O]);if(b.useEffect(()=>{w(0)},[O,n]),b.useEffect(()=>{w(Y=>Y>=Z.length?Math.max(Z.length-1,0):Y)},[Z.length]),b.useEffect(()=>{const Y=F=>{if(!n||y||l)return;const X=Z.length;F.key==="ArrowDown"?(F.preventDefault(),X>0&&w(W=>(W+1)%X)):F.key==="ArrowUp"?(F.preventDefault(),X>0&&w(W=>(W-1+X)%X)):F.key==="Home"?(F.preventDefault(),w(0)):F.key==="End"?(F.preventDefault(),X>0&&w(X-1)):F.key==="Enter"?(F.preventDefault(),Z[v]&&V(Z[v])):F.key==="Escape"&&(F.preventDefault(),r())};return window.addEventListener("keydown",Y),()=>{window.removeEventListener("keydown",Y)}},[n,y,l,Z,v,r,V]),b.useEffect(()=>{if(!n)return;const Y=Z[v]?.id;Y&&document.getElementById(Y)?.scrollIntoView({block:"nearest",behavior:"auto"})},[n,Z,v]),!n)return null;const j=Z[v],M=Z.length>0;return p.jsxs(p.Fragment,{children:[p.jsx(cC,{open:n,onOpenChange:Y=>{Y||r()},children:p.jsxs(uC,{"data-tour-tag":"command-palette-dialog",showClose:!1,className:"w-160 max-w-[90vw] gap-0 overflow-hidden p-0",onOpenAutoFocus:Y=>{Y.preventDefault(),document.getElementById(ure)?.focus()},children:[p.jsx(sy,{className:"sr-only",children:"Command palette"}),p.jsxs("div",{className:"flex h-13 shrink-0 items-center gap-3 border-hairline border-b px-4",children:[p.jsx(yC,{size:16,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),p.jsx("input",{id:ure,type:"text",role:"combobox","aria-expanded":M,"aria-controls":M?cre:void 0,"aria-activedescendant":j?.id,"aria-autocomplete":"list",autoComplete:"off",placeholder:"Search actions, agents and pages",value:h,onChange:Y=>f(Y.target.value),className:"min-w-0 flex-1 bg-transparent text-body text-ink outline-none! placeholder:text-ink-dim"}),h&&p.jsx(Te,{variant:"ghost",size:"icon-sm","aria-label":"Clear search",onClick:()=>f(""),children:p.jsx(Rs,{"aria-hidden":"true"})})]}),M?p.jsx("div",{role:"listbox",id:cre,"aria-label":"Results",tabIndex:-1,className:"max-h-96 overflow-y-auto p-2",children:Z.map((Y,F)=>{const X=v===F,W=Y.type==="clear-conversation",U=F===0||Z[F-1].category!==Y.category;return p.jsxs(b.Fragment,{children:[U&&p.jsx("div",{role:"presentation",className:G("px-2 pb-1 text-ink-dim text-meta",F===0?"pt-1":"pt-3"),children:Y.category}),p.jsxs("button",{id:Y.id,type:"button",role:"option","aria-selected":X,tabIndex:-1,onClick:()=>V(Y),onMouseMove:()=>w(F),className:G("flex h-9 w-full items-center gap-3 rounded-sm px-2 text-left","transition-colors duration-fast ease-out-quart",X?"bg-accent-wash":"bg-transparent"),children:[p.jsx("span",{className:G("flex size-4 shrink-0 items-center justify-center",W?"text-danger":"text-ink-dim"),children:Y.icon||p.jsx(sO,{size:16,"aria-hidden":"true"})}),p.jsx("span",{className:G("shrink-0 truncate text-body-sm",W?"text-danger":"text-ink"),children:Y.name}),Y.hint&&p.jsx("span",{className:"min-w-0 flex-1 truncate text-ink-dim text-meta",children:Y.hint}),!Y.hint&&p.jsx("span",{className:"flex-1"}),X&&p.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-ink-dim text-meta",children:[Rnn[Y.type],p.jsx(Rw,{children:"↵"})]})]})]},Y.id)})}):p.jsxs("div",{className:"flex flex-col items-center gap-1 px-6 py-10 text-center",children:[p.jsx("p",{className:"text-body-sm text-ink",children:O?`No matches for "${O}"`:"Nothing to show yet"}),p.jsx("p",{className:"text-ink-dim text-meta",children:'Search for an agent by name, a page such as Schedules, or an action such as "create agent".'})]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-4 border-hairline border-t px-4 py-2 text-ink-dim text-meta",children:[M&&p.jsxs(p.Fragment,{children:[p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx(Rw,{children:"↑"}),p.jsx(Rw,{children:"↓"}),"to move"]}),p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx(Rw,{children:"↵"}),"to run"]})]}),p.jsxs("span",{className:"flex items-center gap-1.5",children:[p.jsx(Rw,{children:"esc"}),"to close"]})]})]})}),p.jsx(loe,{open:l,onClose:c,onAgentCreated:L}),p.jsx(TC,{open:y,title:"Clear this conversation?",message:"Every message in it is deleted from this computer, and there is no undo. The agent itself is not affected.",confirmText:"Clear",cancelText:"Cancel",isDangerous:!0,onConfirm:A,onCancel:E})]})},Xnn=({open:e,title:t,stepIndicators:n,children:r,actions:i,className:s})=>{const a=b.useRef(null);return p.jsx(cC,{open:e,children:p.jsxs(uC,{showClose:!1,onEscapeKeyDown:o=>o.preventDefault(),onPointerDownOutside:o=>o.preventDefault(),onInteractOutside:o=>o.preventDefault(),onOpenAutoFocus:o=>{o.preventDefault(),a.current?.focus()},className:G("max-h-[calc(100vh-4rem)] max-w-140 gap-0 overflow-hidden p-0",s),children:[(t||n)&&p.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-4 border-hairline border-b px-6 py-4",children:[t?p.jsx(sy,{className:"text-title",children:t}):p.jsx(sy,{className:"sr-only",children:"Setup"}),n]}),p.jsx("div",{ref:a,tabIndex:-1,className:"min-h-0 flex-1 overflow-y-auto px-6 py-6 outline-none!",children:r}),i&&p.jsx("div",{className:"shrink-0 border-hairline border-t px-6 py-4",children:i})]})})},Dnn=({provider:e})=>{const[t,n]=b.useState(!1),[r,i]=b.useState(null);b.useEffect(()=>{i(null)},[e.id]);const s=b.useCallback(async()=>{n(!0);try{i(await un({op:"auth.probe",provider:e.id}))}catch(a){i({reachable:!1,detail:a instanceof Error?a.message:"The connection could not be tested."})}finally{n(!1)}},[e.id]);return p.jsxs("div",{className:"flex flex-col items-start gap-2",children:[p.jsx(dy,{variant:r?.reachable?"success":"neutral",children:r===null?"Not tested yet":r.reachable?"Server responded":"No server responded"}),r&&p.jsx("p",{className:"text-ink-muted text-meta",children:r.detail}),p.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>void s(),disabled:t,children:t?"Testing":"Test connection"})]})},dre=1500;function Inn(e,t){let n=!1,r=null;const i=async()=>{if(!n)try{const s=await un({op:"auth.status",id:e});t(s),Bke(s.state)||(r=setTimeout(i,dre))}catch{r=setTimeout(i,dre*2)}};return i(),()=>{n=!0,r&&clearTimeout(r)}}const hre=({id:e,value:t,onChange:n,label:r})=>{const[i,s]=b.useState(!1);return p.jsxs("div",{className:"relative",children:[p.jsx(yi,{id:e,type:i?"text":"password",value:t,onChange:a=>n(a.target.value),autoComplete:"off",spellCheck:!1,"aria-label":r,className:"pr-10 font-mono"}),p.jsx(Te,{type:"button",variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>s(a=>!a),"aria-label":i?"Hide key":"Show key",children:i?p.jsx(s5e,{"aria-hidden":"true"}):p.jsx(o5e,{"aria-hidden":"true"})})]})},Fnn=({provider:e,onConnected:t})=>{const n=ks(),[r,i]=b.useState(null),[s,a]=b.useState(null),[o,l]=b.useState(!1),[c,u]=b.useState(""),[d,h]=b.useState(!1),[f,O]=b.useState(null),[g,m]=b.useState(""),[v,w]=b.useState(!1),y=b.useRef(null),T=e.auth_methods.find(L=>L.method_id===r)??rKt(e.auth_methods);b.useEffect(()=>()=>{y.current?.()},[]);const x=b.useCallback(()=>{n.invalidateQueries({queryKey:td.providers}),t?.()},[n,t]),k=b.useCallback(async L=>{l(!0),O(null),w(!1);try{const z=await un({op:"auth.start",provider:L.id});a(z),y.current?.(),y.current=Inn(z.id,V=>{a(V),V.state==="succeeded"&&x()}),z.auth_url&&await Xq(z.id)}catch(z){O(z instanceof Error?z.message:"Sign-in could not start.")}finally{l(!1)}},[x]),S=b.useCallback(async()=>{if(s){y.current?.(),y.current=null;try{await un({op:"auth.cancel",id:s.id})}catch{}a(null)}},[s]),Q=b.useCallback(()=>{T&&(y.current?.(),y.current=null,a(null),k(T))},[T,k]),R=b.useCallback(async()=>{if(!(!s?.prompt_id||!g))try{await un({op:"auth.input",id:s.id,promptId:s.prompt_id,value:g}),m("")}catch(L){O(L instanceof Error?L.message:"The code was not accepted.")}},[s,g]),_=b.useCallback(async()=>{if(!(!T||!c.trim())){h(!0),O(null);try{await un({op:"auth.key",provider:T.id,value:c.trim()}),u(""),x()}catch(L){O(L instanceof Error?L.message:"The key could not be saved.")}finally{h(!1)}}},[T,c,x]),A=b.useCallback(async()=>{if(s?.instructions)try{await navigator.clipboard.writeText(s.instructions),w(!0)}catch{tr("Could not copy the code. Select and copy it manually.")}},[s?.instructions]);if(e.local)return p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsxs("p",{className:"text-body-sm text-ink-muted",children:[e.name," runs on this computer and needs no account or key. It has to be running before this app can use it."]}),p.jsx(Dnn,{provider:e})]});if(!T)return p.jsx(qc,{variant:"warning",children:"This provider has no supported sign-in method on this backend."});const E=s&&!Bke(s.state),I=s&&(s.state==="failed"||s.state==="expired"||s.state==="cancelled");return p.jsxs("div",{className:"flex flex-col gap-4",children:[e.auth_methods.length>1&&p.jsxs("fieldset",{className:"flex flex-wrap gap-2",children:[p.jsx("legend",{className:"sr-only",children:"Sign-in method"}),e.auth_methods.map(L=>p.jsx(Te,{variant:L.method_id===T.method_id?"secondary":"ghost",size:"sm",onClick:()=>{i(L.method_id),a(null),O(null),y.current?.()},children:L.kind==="api_key"?"API key":L.label},L.method_id))]}),f&&p.jsx(qc,{variant:"danger",children:f}),T.kind==="api_key"?p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Xs,{htmlFor:`key-${e.id}`,children:"API key"}),p.jsx(hre,{id:`key-${e.id}`,value:c,onChange:u,label:`${e.name} API key`}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs(Te,{variant:"primary",size:"sm",disabled:!c.trim()||d,onClick:()=>void _(),children:[d?p.jsx(Pr,{size:"sm"}):null,"Save key"]}),e.configured&&p.jsx(dy,{variant:"success",children:"A credential is saved"})]})]}):p.jsxs("div",{className:"flex flex-col gap-3",children:[!s&&p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs(Te,{variant:"primary",size:"sm",disabled:o,onClick:()=>void k(T),children:[o?p.jsx(Pr,{size:"sm"}):null,T.label]}),e.configured&&p.jsx(dy,{variant:"success",children:"Signed in"})]}),E&&p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx("p",{className:"text-body-sm text-ink-muted",children:s.message||"Finish signing in to continue."}),s.instructions&&p.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-control bg-sunken p-3",children:[p.jsx("code",{className:"flex-1 font-mono text-body-sm text-ink",children:s.instructions}),p.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>void A(),children:[v?p.jsx(uc,{"aria-hidden":"true"}):p.jsx(Vg,{"aria-hidden":"true"}),v?"Copied":"Copy code"]})]}),s.auth_url&&p.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>void Xq(s.id,!0).catch(L=>tr(L instanceof Error?L.message:"The sign-in page could not be opened.")),children:"Reopen sign-in page"}),s.input_required&&p.jsxs("div",{className:"flex items-end gap-2",children:[p.jsxs("div",{className:"flex-1",children:[p.jsx(Xs,{htmlFor:`prompt-${s.id}`,children:"Paste the code from the provider"}),p.jsx(hre,{id:`prompt-${s.id}`,value:g,onChange:m,label:"Provider code"})]}),p.jsx(Te,{variant:"primary",size:"sm",disabled:!g,onClick:()=>void R(),children:"Submit code"})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Pr,{size:"sm"}),p.jsx("span",{className:"text-meta text-ink-dim",children:s.state==="input_required"?"Waiting for the code":`Waiting${s.expires_in>0?` (${Math.ceil(s.expires_in/60)} min left)`:""}`}),p.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>void S(),children:"Cancel"})]})]}),I&&p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(qc,{variant:s.state==="cancelled"?"neutral":"warning",children:s.state==="expired"?"This sign-in expired before it finished.":s.state==="cancelled"?"This sign-in was cancelled.":s.message||"Sign-in did not complete."}),p.jsx("div",{children:p.jsxs(Te,{variant:"secondary",size:"sm",onClick:Q,children:[p.jsx(E8,{"aria-hidden":"true"}),"Try again"]})})]})]})]})},Nnn=6,Mnn=({onConnected:e,initialProviderId:t=null})=>{const n=oS(!0),[r,i]=b.useState(t);b.useEffect(()=>{t&&i(t)},[t]);const[s,a]=b.useState(""),o=b.useMemo(()=>n.data??[],[n.data]),l=b.useMemo(()=>{const u=s.trim().toLowerCase();return u?o.filter(d=>[d.name,d.id,...d.search_aliases].join(" ").toLowerCase().includes(u)):o},[o,s]);if(n.isLoading)return p.jsx("div",{className:"flex h-40 items-center justify-center",children:p.jsx(Pr,{size:"lg",label:"Loading providers"})});if(n.isError)return p.jsx(qc,{variant:"warning",children:p.jsxs("div",{className:"flex items-center justify-between gap-3",children:[p.jsx("span",{children:Yke(n.error)}),p.jsx(Te,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void n.refetch(),disabled:n.isFetching,children:n.isFetching?"Retrying":"Retry"})]})});const c=o.find(u=>u.id===r)??null;return c?p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>i(null),children:"Back to providers"}),p.jsx("h3",{className:"text-heading text-ink",children:c.name})]}),p.jsx(Fnn,{provider:c,onConnected:e})]}):p.jsxs("div",{className:"flex flex-col gap-4",children:[o.length>Nnn&&p.jsxs("div",{className:"relative",children:[p.jsx(yC,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),p.jsx(yi,{value:s,onChange:u=>a(u.target.value),placeholder:"Search providers","aria-label":"Search providers",className:"pl-9"})]}),l.length===0?p.jsxs("div",{className:"flex flex-col items-center gap-2 py-6 text-center",children:[p.jsx("p",{className:"text-body-sm text-ink-muted",children:"No providers match this search."}),p.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>a(""),children:[p.jsx(Rs,{"aria-hidden":"true"}),"Clear search"]})]}):p.jsx("ul",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:l.map(u=>{const d=Vke(u);return p.jsx("li",{children:p.jsxs("button",{type:"button",onClick:()=>i(u.id),className:G("flex w-full flex-col gap-2 rounded-md border border-control bg-surface p-4 text-left","transition-colors duration-base ease-out-quart hover:bg-elevated"),children:[p.jsxs("span",{className:"flex flex-col items-start gap-1",children:[p.jsx("span",{className:"min-w-0 text-body text-ink",children:u.name}),p.jsx(dy,{variant:d.tone,title:d.detail,children:d.label})]}),p.jsx("span",{className:"text-meta text-ink-dim",children:nKt(u.auth_methods,u.local)})]})},u.id)})})]})},znn=()=>{const e=oS(!0),t=b.useMemo(()=>(e.data??[]).filter(n=>roe([n])).map(n=>n.name),[e.data]);return p.jsxs("div",{className:"flex flex-col gap-5",children:[t.length>0?p.jsxs(p.Fragment,{children:[p.jsx("p",{className:"text-body text-ink-muted",children:"You can add another provider, or choose Next."}),p.jsxs(qc,{variant:"success",children:[p.jsxs(lie,{children:["Signed in to ",Lnn(t)]}),p.jsx(dC,{children:"Nothing more is needed here: choose Next to continue, or connect another provider below."})]})]}):p.jsx("p",{className:"text-body text-ink-muted",children:"Pick the service your agents will think with. You can add or change providers later in Settings."}),p.jsx(Mnn,{})]})};function Lnn(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function GO(){return crypto.randomUUID()}async function qnn(e=1,t=20,n){const r={page:e,per_page:t};if(n)for(const[i,s]of Object.entries(n))s&&(r[i]=s);return wa({operation:"agents.list",query:r})}async function aon(e){return wa({operation:"agents.get",agentId:e})}async function oon(e){return wa({operation:"agents.delete",agentId:e,requestId:GO(),confirmed:!0})}async function lon(e){return wa({operation:"agents.like",agentId:e,requestId:GO()})}async function con(e){return wa({operation:"agents.unlike",agentId:e,requestId:GO(),confirmed:!0})}async function Unn(e){return wa({operation:"agents.like_count",agentId:e})}async function uon(e){return wa({operation:"agents.favourite",agentId:e,requestId:GO()})}async function don(e){return wa({operation:"agents.unfavourite",agentId:e,requestId:GO(),confirmed:!0})}async function Wnn(e){return wa({operation:"agents.favourite_count",agentId:e})}async function Gnn(e){return wa({operation:"agents.download_count",agentId:e})}async function hon(e,t){return wa({operation:"comments.create",agentId:e,payload:t,requestId:GO()})}async function fon(e,t=1,n=20){return wa({operation:"comments.list",agentId:e,query:{page:t,per_page:n}})}async function Oon(e,t,n){return wa({operation:"comments.update",agentId:e,commentId:t,payload:n,requestId:GO()})}async function pon(e,t){return wa({operation:"comments.delete",agentId:e,commentId:t,requestId:GO(),confirmed:!0})}async function gon(e){return wa({operation:"agents.liked",agentId:e})}async function mon(e){return wa({operation:"agents.favourited",agentId:e})}const OTe={all:["agent-download-count"],count:e=>[...OTe.all,e]},jnn=({agentId:e,enabled:t=!0})=>_r({queryKey:OTe.count(e||"invalid"),queryFn:async()=>{if(!e)throw new Error("Agent ID is required to fetch download count.");return(await Gnn(e)).result},select:r=>r.count,enabled:!!e&&t,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1}),pTe={all:["agent-favourite-count"],count:e=>[...pTe.all,e]},Vnn=({agentId:e,enabled:t=!0})=>_r({queryKey:pTe.count(e||"invalid"),queryFn:async()=>{if(!e)throw new Error("Agent ID is required to fetch favourite count.");return(await Wnn(e)).result},select:r=>r.count,enabled:!!e&&t,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1}),gTe={all:["agent-like-count"],count:e=>[...gTe.all,e]},Ynn=({agentId:e,enabled:t=!0})=>_r({queryKey:gTe.count(e||"invalid"),queryFn:async()=>{if(!e)throw new Error("Agent ID is required to fetch like count.");return(await Unn(e)).result},select:r=>r.count,enabled:!!e&&t,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1}),mTe=()=>{const e=ks(),t=Js();return mo({mutationFn:async({agentId:r})=>{if(!Cr.baseUrl)throw new Error("Local Operator API URL is not configured.");return mae.downloadAgentFromRadient(Cr.baseUrl,r)},onSuccess:(r,i)=>{const s=r.result?.name??i.agentName??"Agent";os(`Agent "${s}" downloaded.`),e.invalidateQueries({queryKey:["agents"]}),e.invalidateQueries({queryKey:["agent-download-count",i.agentId]});const a=r.result;a?.id?t(`/chat/${a.id}`):console.warn("Downloaded agent ID not found in response, cannot navigate to chat.")},onError:r=>{tr(`Failed to download agent: ${r.message}`),console.error("Download agent error:",r)}})},fre={investment:{icon:p.jsx(kQe,{size:14,"aria-hidden":"true"}),label:"Investment"},accounting:{icon:p.jsx(yQe,{size:14,"aria-hidden":"true"}),label:"Accounting"},healthcare:{icon:p.jsx(E5e,{size:14,"aria-hidden":"true"}),label:"Healthcare"},legal:{icon:p.jsx(tRe,{size:14,"aria-hidden":"true"}),label:"Legal"},software:{icon:p.jsx(k8,{size:14,"aria-hidden":"true"}),label:"Software"},security:{icon:p.jsx(uae,{size:14,"aria-hidden":"true"}),label:"Security"},role_play:{icon:p.jsx(gh,{size:14,"aria-hidden":"true"}),label:"Role play"},personal_assistance:{icon:p.jsx(Oae,{size:14,"aria-hidden":"true"}),label:"Personal assistance"},education:{icon:p.jsx(C5e,{size:14,"aria-hidden":"true"}),label:"Education"},marketing:{icon:p.jsx(oEe,{size:14,"aria-hidden":"true"}),label:"Marketing"},sales:{icon:p.jsx(ORe,{size:14,"aria-hidden":"true"}),label:"Sales"},research:{icon:p.jsx(x5e,{size:14,"aria-hidden":"true"}),label:"Research"},analysis:{icon:p.jsx(_Qe,{size:14,"aria-hidden":"true"}),label:"Analysis"},management:{icon:p.jsx(MQe,{size:14,"aria-hidden":"true"}),label:"Management"},social_media:{icon:p.jsx(e5e,{size:14,"aria-hidden":"true"}),label:"Social media"},other:{icon:p.jsx(f5e,{size:14,"aria-hidden":"true"}),label:"Other"}};function fT(e){const t=e.split("_").join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}const Ore="inline-flex min-h-5.5 items-center rounded-full border border-hairline bg-sunken px-2 text-meta leading-none",Bnn=({tags:e,categories:t,className:n})=>{if((!e||e.length===0)&&(!t||t.length===0))return null;const r=new Set((t??[]).map(s=>(fre[s]?.label??fT(s)).toLowerCase())),i=(e??[]).filter(s=>!r.has(fT(s).toLowerCase()));return p.jsxs("div",{className:G("relative flex flex-wrap items-center gap-1.5 overflow-hidden",n),"data-testid":"agent-tags-and-categories",children:[t?.map(s=>{const a=fre[s]||{icon:p.jsx(W2,{size:14,"aria-hidden":"true"}),label:fT(s)};return p.jsxs("span",{className:G(Ore,"gap-1 font-medium text-ink-muted"),children:[a.icon,a.label]},s)}),i.map(s=>p.jsxs("span",{className:G(Ore,"gap-1 font-normal text-ink-dim"),children:[p.jsx(W2,{size:12,"aria-hidden":"true"}),fT(s)]},s))]})},Znn=({agent:e,isLiked:t,isFavourited:n,onLikeToggle:r,onFavouriteToggle:i,isLikeActionLoading:s=!1,isFavouriteActionLoading:a=!1})=>{const o=Js(),l=mTe(),{isAuthenticated:c}=t7(),{data:u,isLoading:d}=Ynn({agentId:e.id}),{data:h,isLoading:f}=Vnn({agentId:e.id}),{data:O,isLoading:g}=jnn({agentId:e.id}),m=e.description??"",[v,w]=b.useState(!1),y=b.useRef(null),T=b.useCallback(S=>{if(y.current?.disconnect(),y.current=null,!S)return;const Q=()=>w(S.scrollHeight-S.clientHeight>1);Q();const R=new ResizeObserver(Q);R.observe(S),y.current=R},[]),x=c?t?"Unlike agent":"Like agent":"Log in to Radient to like agents",k=c?n?"Unfavourite agent":"Favourite agent":"Log in to Radient to favourite agents";return p.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border border-hairline bg-surface transition-colors duration-fast ease-out-quart hover:border-control",children:[p.jsxs("button",{type:"button",onClick:()=>o(`/agent-hub/${e.id}`),className:"flex min-h-0 flex-1 cursor-pointer flex-col gap-2 p-4 text-left","aria-label":`View details for ${e.name}`,children:[p.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:e.name}),p.jsx(vt,{content:v?m:"",children:p.jsx("span",{ref:T,className:"line-clamp-3 min-h-0 text-body-sm text-ink-muted",children:m})}),p.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[p.jsx(Bnn,{tags:e.tags,categories:e.categories}),p.jsxs("p",{className:"truncate text-ink-dim text-meta",children:[e.account_metadata?.name??"Unknown author",p.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"updated ",MGe(new Date(e.updated_at))," ago"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2",children:[p.jsxs("div",{className:"flex min-w-0 items-center gap-0.5",children:[p.jsx(vt,{content:x,children:p.jsx("span",{children:p.jsxs(Te,{variant:"ghost",size:"sm",onClick:c?()=>r(e.id):void 0,disabled:s||!c,"aria-label":t?"Unlike agent":"Like agent",className:G(t&&"text-danger"),children:[p.jsx(A5e,{fill:t?"currentColor":"none","data-testid":"agent-like-heart"}),p.jsx("span",{className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:d?p.jsx(Ru,{className:"h-3 w-4"}):u??0})]})})}),p.jsx(vt,{content:k,children:p.jsx("span",{children:p.jsxs(Te,{variant:"ghost",size:"sm",onClick:c?()=>i(e.id):void 0,disabled:a||!c,"aria-label":n?"Unfavourite agent":"Favourite agent",className:G(n&&"text-warning"),children:[p.jsx(hae,{fill:n?"currentColor":"none","data-testid":"agent-favourite-star"}),p.jsx("span",{className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:f?p.jsx(Ru,{className:"h-3 w-4"}):h??0})]})})}),p.jsx(vt,{content:"Downloads",children:p.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 pr-1 text-ink-dim",children:[p.jsx(iO,{"aria-hidden":"true",className:"size-3.5"}),p.jsx("span",{className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm",children:g||l.isPending?p.jsx(Ru,{className:"h-3 w-6"}):(O??0).toLocaleString()})]})})]}),p.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:p.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>{l.isPending||l.mutate({agentId:e.id,agentName:e.name})},disabled:l.isPending,"aria-label":`Download ${e.name}`,"data-tour-tag":"agent-hub-download-button",children:[p.jsx(iO,{"data-testid":"agent-download"}),"Get"]})})]})]})},Hnn={all:["public-agents"],list:(e,t)=>[...Hnn.all,"list",{page:e,perPage:t}]},Knn=({page:e=1,perPage:t=20,enabled:n=!0,categories:r,sort:i,order:s}={})=>{const a=["name","created_at","updated_at","like_count","favourite_count","download_count"],o=["asc","desc"],l=i&&a.includes(i)?i:"download_count",c=s&&o.includes(s)?s:"desc",u=_r({queryKey:["public-agents","list",{page:e,perPage:t,categories:r?.join(",")??void 0,sort:l,order:c}],queryFn:async()=>{const d={};return r&&r.length>0&&(d.categories=r.join(",")),d.sort=l,d.order=c,await qnn(e,t,d)},select:d=>d.result,enabled:n,staleTime:5*60*1e3,gcTime:10*60*1e3,refetchOnWindowFocus:!1});return{...u,agents:u.data?.records,pagination:u.data?{page:u.data.page,perPage:u.data.per_page,totalPages:u.data.total_pages,totalRecords:u.data.total_records}:void 0}},Jnn=4,ern=({onValidityChange:e})=>{const{data:t}=M8(),n=mTe(),[r,i]=b.useState(new Set),[s,a]=b.useState(!1),{data:o,isLoading:l,error:c}=Knn({page:1,perPage:Jnn,sort:"download_count",order:"desc"}),u=b.useMemo(()=>o?.records??[],[o]);b.useEffect(()=>{if(t?.agents){const O=new Set(t.agents.map(m=>m.id)),g=u.filter(m=>O.has(m.id)).map(m=>m.id);i(m=>new Set([...m,...g]))}n.isSuccess&&n.variables?.agentId&&i(O=>new Set(O).add(n.variables.agentId))},[t,u,n.isSuccess,n.variables?.agentId]);const d=async()=>{if(s||n.isPending)return;a(!0);const O=u.filter(g=>!r.has(g.id));try{for(const g of O)if(!r.has(g.id)&&n.variables?.agentId!==g.id)try{await n.mutateAsync({agentId:g.id,agentName:g.name}),i(m=>new Set(m).add(g.id))}catch(m){console.error(`Failed to download agent ${g.name}:`,m)}}catch(g){console.error("Failed to add all recommended agents:",g)}finally{a(!1)}},h=r.size>0;b.useEffect(()=>{e(h)},[h,e]);const f=u.length>0&&u.every(O=>r.has(O.id));return p.jsxs("div",{className:"flex flex-col gap-5",children:[p.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[p.jsx("p",{className:"min-w-60 flex-1 text-body text-ink-muted",children:"Pick an agent to start with, or add the popular ones as a set. More are in the Agent hub whenever you want them."}),p.jsxs(Te,{variant:"secondary",onClick:d,disabled:l||s||f,children:[s?p.jsx(Pr,{size:"sm"}):p.jsx(iO,{"aria-hidden":"true"}),s?"Adding":f?"All added":"Add all four"]})]}),l&&p.jsx("div",{className:"flex h-60 items-center justify-center",children:p.jsx(Pr,{size:"lg",label:"Loading recommended agents"})}),c&&p.jsxs("div",{className:"flex h-60 flex-col items-center justify-center gap-1 text-center",children:[p.jsx("p",{className:"text-body-sm text-ink",children:"The recommended agents could not be loaded."}),p.jsx("p",{className:"text-ink-dim text-meta",children:"Continue without one and add agents later from the Agent hub."})]}),!l&&!c&&p.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:u.length===0?p.jsx("p",{className:"text-center text-body-sm text-ink-muted sm:col-span-2",children:"No recommended agents right now. Continue, and add agents later from the Agent hub."}):u.map(O=>{const g=r.has(O.id),m=n.isPending&&n.variables?.agentId===O.id;return p.jsxs("div",{className:G("relative transition-colors duration-base ease-out-quart",g&&"pointer-events-none"),children:[p.jsx(Znn,{agent:O,isLiked:!1,isFavourited:!1,onLikeToggle:()=>{},onFavouriteToggle:()=>{},showActions:!1}),m&&p.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:p.jsx(Pr,{size:"md",label:`Adding ${O.name}`})}),g&&p.jsxs(dy,{variant:"success",className:"absolute top-3 right-3",children:[p.jsx(ZF,{"aria-hidden":"true"}),"Added"]})]},O.id)})})]})},pre="onboarding-default-provider",gre="onboarding-default-provider-help",mre="onboarding-default-model",vre="onboarding-default-model-help",trn=()=>{const{providers:e,models:t,isLoading:n,refreshModels:r}=RC({autoFetch:!1}),{data:i,isLoading:s}=lS(),{isLoading:a}=N8(),o=X6e(),[l,c]=b.useState(""),[u,d]=b.useState(""),[h,f]=b.useState(!1),[O,g]=b.useState(!1),m=b.useRef(void 0),v=b.useRef(!1),w=b.useMemo(()=>!e||!i?[]:e.filter(Q=>{const R=`${Q.id.toUpperCase()}_API_KEY`;return i.keys.includes(R)}),[e,i]),y=b.useMemo(()=>!t||!l?[]:t.filter(Q=>Q.provider===l),[t,l]),T=b.useCallback(async(Q,R)=>{if(Q&&R&&!h)try{f(!0),g(!1),await o.mutateAsync({hosting:Q,model_name:R}),g(!0),clearTimeout(m.current),m.current=setTimeout(()=>{g(!1)},3e3)}catch(_){console.error("Failed to update default model:",_),g(!1)}finally{f(!1)}},[h,o]);b.useEffect(()=>()=>clearTimeout(m.current),[]),b.useEffect(()=>{i&&!s&&!v.current&&(r(),v.current=!0)},[i,s,r]),b.useEffect(()=>{if(n||s||a||!i||!e||w.length===0||l)return;let Q=w[0].id;for(const R of w){const _=`${R.id.toUpperCase()}_API_KEY`;if(i.keys.includes(_)){Q=R.id;break}}c(Q)},[w,e,n,s,a,i,l]),b.useEffect(()=>{y.length>0&&!u&&(d(y[0].id),l&&y[0].id&&T(l,y[0].id))},[y,u,l,T]);const x=n||s||a,k=y.find(Q=>Q.id===u)?.name,S=w.find(Q=>Q.id===l)?.name;return p.jsxs("div",{className:"flex flex-col gap-6",children:[p.jsx("p",{className:"text-body text-ink-muted",children:"Pick the model your agents use by default. Models differ in speed, cost and capability, and every agent can override this later."}),x?p.jsxs("div",{className:"flex items-center justify-center gap-3 py-8",children:[p.jsx(Pr,{size:"sm"}),p.jsx("p",{className:"text-body-sm text-ink-muted",children:"Loading your models"})]}):p.jsxs("div",{className:"flex flex-col gap-5",children:[p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Xs,{htmlFor:pre,children:"Model provider"}),p.jsxs(ay,{value:l,disabled:w.length===0,onValueChange:Q=>{c(Q),d(""),g(!1)},children:[p.jsx(oy,{id:pre,selectSize:"lg","aria-describedby":gre,children:p.jsx(ly,{placeholder:w.length===0?"No providers with credentials yet":"Select a provider"})}),p.jsx(cy,{children:w.map(Q=>p.jsx(uy,{value:Q.id,children:Q.name},Q.id))})]}),p.jsx("p",{id:gre,className:"text-ink-dim text-meta",children:w.length===0?"Add a model key on the previous step to choose a provider here.":"Providers you have added credentials for"})]}),l&&p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Xs,{htmlFor:mre,children:"Model"}),p.jsxs(ay,{value:u,onValueChange:Q=>{d(Q),g(!1),l&&Q&&T(l,Q)},disabled:y.length===0,children:[p.jsx(oy,{id:mre,selectSize:"lg","aria-describedby":vre,children:p.jsx(ly,{placeholder:y.length===0?"No models available for this provider":"Select a model"})}),p.jsx(cy,{children:y.map(Q=>p.jsx(uy,{value:Q.id,children:Q.name},Q.id))})]}),p.jsx("p",{id:vre,className:"text-ink-dim text-meta",children:k&&S&&!h?`Agents will use ${k} from ${S}`:"The model your agents start with"})]}),O&&p.jsx(qc,{variant:"success",children:"Default model saved"})]})]})};var vTe=(e=>(e.Hosting="hosting",e.Search="search",e.Oauth="oauth",e))(vTe||{});const UF=[{key:"RADIENT_API_KEY",name:"Radient Pass",description:"API key for your Radient Pass. Radient Pass provides you unified access to models, tools, agents, automatic optimization, and many more features with a single key. Get one by signing in above with Gmail or Microsoft.",url:"https://radienthq.com",type:"hosting"},{key:"OPENAI_API_KEY",name:"OpenAI API key",description:"API key for accessing OpenAI models like GPT-4o, o3-mini, and GPT-4.5.",url:"https://platform.openai.com/api-keys",type:"hosting"},{key:"OPENROUTER_API_KEY",name:"OpenRouter API key",description:"API key for OpenRouter, which provides access to various AI models from different providers. Getting an openrouter key allows you to simultaneously access many models from different providers.",url:"https://openrouter.ai/keys",type:"hosting"},{key:"DEEPSEEK_API_KEY",name:"DeepSeek API key",description:"API key for DeepSeek AI models, specialized in code generation and understanding.",url:"https://platform.deepseek.com/",type:"hosting"},{key:"MISTRAL_API_KEY",name:"Mistral API key",description:"API key for Mistral AI models, known for efficient and powerful language processing.",url:"https://console.mistral.ai/api-keys/",type:"hosting"},{key:"KIMI_API_KEY",name:"Kimi API key",description:"API key for Kimi AI, providing advanced language models with strong reasoning capabilities.",url:"https://kimi.moonshot.cn/",type:"hosting"},{key:"ALIBABA_CLOUD_API_KEY",name:"Alibaba Cloud API key",description:"API key for Alibaba Cloud AI models, offering a range of language and vision capabilities such as Qwen.",url:"https://www.alibabacloud.com/product/ai",type:"hosting"},{key:"GOOGLE_AI_STUDIO_API_KEY",name:"Google AI Studio API key",description:"API key for Google AI Studio, providing access to Gemini and other Google AI models.",url:"https://aistudio.google.com/",type:"hosting"},{key:"GOOGLE_ACCESS_TOKEN",name:"Google access token",description:"OAuth 2.0 access token for Google APIs. Used by Local Operator for authenticated requests to Google services such as Gmail, Calendar, and Drive. This token is short-lived and automatically refreshed.",url:"https://console.cloud.google.com/apis/credentials",internal:!0,type:"oauth"},{key:"GOOGLE_TOKEN_EXPIRY_TIMESTAMP",name:"Google token expiry timestamp",description:"Timestamp (in milliseconds since epoch) indicating when the current Google access token will expire. Used internally to manage token refresh.",url:"",internal:!0,type:"oauth"},{key:"GOOGLE_REFRESH_TOKEN",name:"Google refresh token",description:"OAuth 2.0 refresh token for Google APIs. Used to obtain new access tokens when the current one expires. This is managed securely and automatically.",url:"https://console.cloud.google.com/apis/credentials",internal:!0,type:"oauth"},{key:"ANTHROPIC_API_KEY",name:"Anthropic API key",description:"API key for Anthropic's Claude models, known for agentic code generation capabilities.",url:"https://console.anthropic.com/settings/keys",type:"hosting"},{key:"SERP_API_KEY",name:"SERP API key",description:"API key for Search Engine Results Page API, allowing access to search engine data. Allows your agents to search the web for information.",url:"https://serpapi.com/dashboard",type:"search"},{key:"TAVILY_API_KEY",name:"Tavily API key",description:"API key for Tavily, a search API designed specifically for AI applications. Allows your agents to search the web for information.",url:"https://tavily.com/#api",type:"search"},{key:"FAL_API_KEY",name:"FAL API key",description:"API key for FAL, used by agents for generating, interpreting, and understanding images.",url:"https://docs.fal.ai/quick-start",type:"hosting"},{key:"XAI_API_KEY",name:"xAI API key",description:"API key for xAI, providing access to Grok and other advanced xAI models for language and reasoning tasks.",url:"https://docs.x.ai/docs/overview",type:"hosting"}],von=e=>UF.find(t=>t.key===e)||{key:e,name:e,description:"Custom credential",url:""},UA="TAVILY_API_KEY",wre="onboarding-search-provider",bre="onboarding-search-provider-help",yre="onboarding-search-key",xre="onboarding-search-key-help",nrn=()=>{const e=UF.filter(O=>O.type===vTe.Search).sort((O,g)=>O.key===UA?-1:g.key===UA?1:0),[t,n]=b.useState(e[0]?.key||""),[r,i]=b.useState(""),[s,a]=b.useState(!1),[o,l]=b.useState(!1),c=b.useRef(void 0),{data:u}=lS(),d=D6e(),h=async()=>{if(t&&r.trim()&&!u?.keys.includes(t)&&!s)try{a(!0),l(!1),await d.mutateAsync({key:t,value:r.trim()}),l(!0),clearTimeout(c.current),c.current=setTimeout(()=>{l(!1)},3e3)}catch(O){console.error("Failed to save credential:",O),l(!1)}finally{a(!1)}};b.useEffect(()=>()=>clearTimeout(c.current),[]);const f=UF.find(O=>O.key===t);return p.jsxs("div",{className:"flex flex-col gap-6",children:[p.jsx("p",{className:"text-body text-ink-muted",children:"With a search key, agents can look things up while they work — today's prices, this week's news — instead of relying on what the model already knows. Skip it and add one later if you prefer."}),p.jsxs("div",{className:"flex flex-col gap-5",children:[p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Xs,{htmlFor:wre,children:"Search provider"}),p.jsxs(ay,{value:t,onValueChange:O=>{n(O),i(""),l(!1)},children:[p.jsx(oy,{id:wre,selectSize:"lg","aria-describedby":f?bre:void 0,children:p.jsx(ly,{placeholder:"Select a provider"})}),p.jsx(cy,{children:e.map(O=>p.jsx(uy,{value:O.key,children:O.key===UA?`${O.name} (recommended)`:O.name},O.key))})]}),f&&p.jsxs("div",{id:bre,className:"flex flex-col items-start gap-1",children:[p.jsx("p",{className:"text-ink-dim text-meta",children:f.description}),p.jsxs("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-accent text-meta underline-offset-4 hover:text-accent-hover hover:underline",children:["Get your ",f.name,p.jsx(wC,{size:12,"aria-hidden":"true"})]})]})]}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Xs,{htmlFor:yre,children:"API key (optional)"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(yi,{id:yre,inputSize:"lg",type:"password",value:r,onChange:O=>{i(O.target.value),l(!1)},onBlur:h,onKeyDown:O=>{O.key==="Enter"&&t&&r.trim()&&!s&&h()},placeholder:"Paste your API key",disabled:s,"aria-describedby":xre}),s&&p.jsx(Pr,{size:"sm",label:"Saving credential"})]}),p.jsx("p",{id:xre,className:"text-ink-dim text-meta",children:"Saved on your device as soon as you leave the field"})]}),o&&p.jsx(qc,{variant:"success",children:"Search key saved"})]})]})},Sre="onboarding-profile-name",$re="onboarding-profile-name-help",kre="onboarding-profile-email",Tre="onboarding-profile-email-help",rrn=()=>{const{profile:e,updateProfile:t}=J8(),[n,r]=b.useState(e.name==="User"?"":e.name),[i,s]=b.useState(e.email==="user@example.com"?"":e.email),[a,o]=b.useState("");b.useEffect(()=>{n.trim()&&t({name:n.trim()}),i.trim()&&t({email:i.trim()})},[n,i,t]);const l=c=>{const u=c.target.value;r(u),u.trim()?o(""):o("Name is required")};return p.jsxs("div",{className:"flex flex-col gap-6",children:[p.jsx("p",{className:"text-body text-ink-muted",children:"So your agents know what to call you. Both fields stay on this computer and are never sent anywhere."}),p.jsxs("div",{className:"flex flex-col gap-5",children:[p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Xs,{htmlFor:Sre,children:"Your name"}),p.jsx(yi,{id:Sre,inputSize:"lg",value:n,onChange:l,required:!0,"aria-invalid":a?!0:void 0,"aria-describedby":$re}),p.jsx("p",{id:$re,className:G("text-meta",a?"text-danger":"text-ink-dim"),children:a||"Used when an agent addresses you"})]}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Xs,{htmlFor:kre,children:"Email address (optional)"}),p.jsx(yi,{id:kre,inputSize:"lg",type:"email",value:i,onChange:c=>s(c.target.value),autoComplete:"email","aria-describedby":Tre}),p.jsx("p",{id:Tre,className:"text-ink-dim text-meta",children:"Kept for convenience, never shared"})]})]})]})},WA={[Kr.CONNECT_PROVIDER]:"Connect a provider",[Kr.USER_PROFILE]:"Introduce yourself",[Kr.SEARCH_API]:"Turn on web search",[Kr.DEFAULT_MODEL]:"Pick a default model",[Kr.CREATE_AGENT]:"Create your first agent",[Kr.CONGRATULATIONS]:"You're all set"},ku=[Kr.CONNECT_PROVIDER,Kr.USER_PROFILE,Kr.SEARCH_API,Kr.DEFAULT_MODEL,Kr.CREATE_AGENT,Kr.CONGRATULATIONS],irn=new Set([Kr.SEARCH_API,Kr.CREATE_AGENT]),srn=({open:e})=>{const{currentStep:t,setCurrentStep:n,completeModalOnboarding:r}=zy(),i=Js(),[s,a]=b.useState(!1);b.useEffect(()=>{ku.includes(t)||n(Kr.CONNECT_PROVIDER)},[t,n]);const[o,l]=b.useState(new Set);b.useEffect(()=>{l(T=>{if(T.has(t))return T;const x=new Set(T);return x.add(t),x})},[t]);const c=b.useMemo(()=>t?WA[t]||"First-time setup":"Loading...",[t]),u=b.useMemo(()=>{if(!t)return null;switch(t){case Kr.CONNECT_PROVIDER:return p.jsx(znn,{});case Kr.USER_PROFILE:return p.jsx(rrn,{});case Kr.SEARCH_API:return p.jsx(nrn,{});case Kr.DEFAULT_MODEL:return p.jsx(trn,{});case Kr.CREATE_AGENT:return p.jsx(ern,{onValidityChange:a});case Kr.CONGRATULATIONS:return p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsx(ZF,{size:28,className:"text-accent","aria-hidden":"true"}),p.jsx("p",{className:"text-body text-ink-muted",children:"Local Operator is ready. Start a conversation with your new agent, or change anything you picked here later in Settings."})]});default:return null}},[t]),d=b.useCallback(()=>{if(t===Kr.CONGRATULATIONS){r();const x=sessionStorage.getItem("onboarding_created_agent_id");x?(i(`/chat/${x}`),sessionStorage.removeItem("onboarding_created_agent_id")):i("/chat");return}const T=ku.indexOf(t);T>=0&&T<ku.length-1&&n(ku[T+1])},[t,n,r,i]),h=b.useCallback(()=>{const T=ku.indexOf(t);T>0&&n(ku[T-1])},[t,n]),f=b.useCallback(()=>{d()},[d]),O=irn.has(t),g=t!==Kr.CONNECT_PROVIDER&&t!==Kr.CONGRATULATIONS,m=t===Kr.CONGRATULATIONS?"Get started":"Next",v=t===Kr.CREATE_AGENT&&!s,w=p.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[p.jsx("div",{children:g&&p.jsx(Te,{variant:"secondary",size:"lg",onClick:h,children:"Back"})}),p.jsxs("div",{className:"flex items-center gap-3",children:[O&&p.jsx(Te,{variant:"ghost",size:"lg",onClick:f,children:"Skip"}),p.jsx(Te,{variant:"primary",size:"lg",onClick:d,disabled:v,children:m})]})]}),y=b.useMemo(()=>{if(!t)return null;const T=ku.indexOf(t);return p.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[p.jsx("span",{className:"whitespace-nowrap text-ink-dim text-meta",children:T>=0?`Step ${T+1} of ${ku.length}`:`${ku.length} steps`}),p.jsx("ol",{className:"flex items-center gap-1",children:ku.map((x,k)=>{const S=t===x,R=o.has(x)&&!S,_=k<=T;return p.jsx("li",{className:"flex",children:p.jsx(vt,{content:WA[x],children:p.jsx("button",{type:"button","aria-label":WA[x],"aria-current":S?"step":void 0,"aria-disabled":!R,onClick:()=>{R&&n(x)},className:"flex h-4 w-4 items-center",children:p.jsx("span",{className:G("h-1 w-full rounded-xs transition-colors duration-base ease-out-quart",_?"bg-accent":"bg-control")})})})},x)})})]})},[t,o,n]);return p.jsx(Xnn,{open:e,title:c,stepIndicators:y,actions:w,children:u})};var Pre={exports:{}},Aw={};/**
|
|
1315
1315
|
* @license React
|
|
1316
1316
|
* react-jsx-runtime.production.min.js
|
|
@@ -1321,7 +1321,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),ZO=tt,Br=Bt);const fu=
|
|
|
1321
1321
|
* LICENSE file in the root directory of this source tree.
|
|
1322
1322
|
*/var _re;function arn(){if(_re)return Aw;_re=1;var e=Oe,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 Aw.Fragment=n,Aw.jsx=a,Aw.jsxs=a,Aw}var Cre;function orn(){return Cre||(Cre=1,Pre.exports=arn()),Pre.exports}var lrn=orn();/*! shepherd.js 14.5.0 */function crn(e){return e instanceof Element}function H1(e){return e instanceof HTMLElement}function _O(e){return typeof e=="function"}function Hx(e){return typeof e=="string"}function Da(e){return e===void 0}class Pz{on(t,n,r,i=!1){var s;return Da(this.bindings)&&(this.bindings={}),Da(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(Da(this.bindings)||Da(this.bindings[t]))return this;if(Da(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(!Da(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 Uo(){return Uo=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},Uo.apply(null,arguments)}function _z(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 jO={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")};jO.defaultMerge;function urn(e,t){return t}function drn(e,t){return e.filter(n=>n!==void 0)}var Qre;(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"})(Qre||(Qre={}));function Ere(e){return typeof e!="object"||e===null?0:Array.isArray(e)?2:Orn(e)?1:e instanceof Set?3:e instanceof Map?4:5}function hrn(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 frn(e,t){return typeof e=="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function wTe(e){return{*[Symbol.iterator](){for(const t of e)for(const n of t)yield n}}}const Rre=new Set(["[object Object]","[object Module]"]);function Orn(e){if(!Rre.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"||!Rre.has(Object.prototype.toString.call(n))||!n.hasOwnProperty("isPrototypeOf"))}function prn(e,t,n){const r={};for(const i of hrn(e)){const s=[];for(const l of e)frn(l,i)&&s.push(l[i]);if(s.length===0)continue;const a=t.metaDataUpdater(n,{key:i,parents:e}),o=bTe(s,t,a);o!==jO.skip&&(i==="__proto__"?Object.defineProperty(r,i,{value:o,configurable:!0,enumerable:!0,writable:!0}):r[i]=o)}return r}function grn(e){return e.flat()}function mrn(e){return new Set(wTe(e))}function vrn(e){return new Map(wTe(e))}function wrn(e){return e.at(-1)}const OT={mergeRecords:prn,mergeArrays:grn,mergeSets:mrn,mergeMaps:vrn,mergeOthers:wrn};function Cz(...e){return brn({})(...e)}function brn(e,t){const n=yrn(e,r);function r(...i){return bTe(i,n,t)}return r}function yrn(e,t){var n,r,i;return{defaultMergeFunctions:OT,mergeFunctions:Uo({},OT,Object.fromEntries(Object.entries(e).filter(([s,a])=>Object.hasOwn(OT,s)).map(([s,a])=>a===!1?[s,OT.mergeOthers]:[s,a]))),metaDataUpdater:(n=e.metaDataUpdater)!=null?n:urn,deepmerge:t,useImplicitDefaultMerging:(r=e.enableImplicitDefaultMerging)!=null?r:!1,filterValues:e.filterValues===!1?void 0:(i=e.filterValues)!=null?i:drn,actions:jO}}function bTe(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 GA(i,t,n);const s=Ere(i[0]);if(s!==0&&s!==5){for(let a=1;a<i.length;a++)if(Ere(i[a])!==s)return GA(i,t,n)}switch(s){case 1:return xrn(i,t,n);case 2:return Srn(i,t,n);case 3:return $rn(i,t,n);case 4:return krn(i,t,n);default:return GA(i,t,n)}}function xrn(e,t,n){const r=t.mergeFunctions.mergeRecords(e,t,n);return r===jO.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(e,t,n):r}function Srn(e,t,n){const r=t.mergeFunctions.mergeArrays(e,t,n);return r===jO.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(e):r}function $rn(e,t,n){const r=t.mergeFunctions.mergeSets(e,t,n);return r===jO.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(e):r}function krn(e,t,n){const r=t.mergeFunctions.mergeMaps(e,t,n);return r===jO.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(e):r}function GA(e,t,n){const r=t.mergeFunctions.mergeOthers(e,t,n);return r===jO.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(e):r}function Qz(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 Trn(e,t){return n=>{if(e.isOpen()){const r=e.el&&n.currentTarget===e.el;(!Da(t)&&n.currentTarget.matches(t)||r)&&e.tour.next()}}}function Prn(e){const{event:t,selector:n}=e.options.advanceOn||{};if(t){const r=Trn(e,n);let i=null;if(!Da(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 _rn{constructor(t){}}class Crn{constructor(t,n){}}function yTe(e){return!Hx(e)||e===""?"":e.charAt(e.length-1)!=="-"?`${e}-`:e}function Qrn(e){const t=e.options.attachTo||{},n=Object.assign({},t);if(_O(n.element)&&(n.element=n.element.call(e)),Hx(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 Ern(e){return e.options.extraHighlights?e.options.extraHighlights.flatMap(t=>Array.from(document.querySelectorAll(t))):[]}function xTe(e){return e==null?!0:!e.element||!e.on}function STe(){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 Rrn=["top","right","bottom","left"],Are=["start","end"],Xre=Rrn.reduce((e,t)=>e.concat(t,t+"-"+Are[0],t+"-"+Are[1]),[]),K1=Math.min,ig=Math.max,iC=Math.round,pT=Math.floor,od=e=>({x:e,y:e}),Arn={left:"right",right:"left",bottom:"top",top:"bottom"},Xrn={start:"end",end:"start"};function WF(e,t,n){return ig(e,K1(t,n))}function Ug(e,t){return typeof e=="function"?e(t):e}function Uh(e){return e.split("-")[0]}function Ph(e){return e.split("-")[1]}function Ez(e){return e==="x"?"y":"x"}function Rz(e){return e==="y"?"height":"width"}function J1(e){return["top","bottom"].includes(Uh(e))?"y":"x"}function Az(e){return Ez(J1(e))}function $Te(e,t,n){n===void 0&&(n=!1);const r=Ph(e),i=Az(e),s=Rz(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=aC(a)),[a,aC(a)]}function Drn(e){const t=aC(e);return[sC(e),t,sC(t)]}function sC(e){return e.replace(/start|end/g,t=>Xrn[t])}function Irn(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 Frn(e,t,n,r){const i=Ph(e);let s=Irn(Uh(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(sC)))),s}function aC(e){return e.replace(/left|right|bottom|top/g,t=>Arn[t])}function Nrn(e){return Uo({top:0,right:0,bottom:0,left:0},e)}function kTe(e){return typeof e!="number"?Nrn(e):{top:e,right:e,bottom:e,left:e}}function oC(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 Mrn=["crossAxis","alignment","allowedPlacements","autoAlignment"],zrn=["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"],Lrn=["mainAxis","crossAxis","limiter"];function Dre(e,t,n){let{reference:r,floating:i}=e;const s=J1(t),a=Az(t),o=Rz(a),l=Uh(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(Ph(t)){case"start":f[a]-=h*(n&&c?-1:1);break;case"end":f[a]+=h*(n&&c?-1:1);break}return f}const qrn=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}=Dre(c,r,l),h=r,f={},O=0;for(let g=0;g<o.length;g++){const{name:m,fn:v}=o[g],{x:w,y,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=w??u,d=y??d,f=Uo({},f,{[m]:Uo({},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}=Dre(c,h,l)),g=-1)}return{x:u,y:d,placement:h,strategy:i,middlewareData:f}};async function Xz(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}=Ug(t,e),O=kTe(f),g=o[h?d==="floating"?"reference":"floating":d],m=oC(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,w=await(s.getOffsetParent==null?void 0:s.getOffsetParent(o.floating)),y=await(s.isElement==null?void 0:s.isElement(w))?await(s.getScale==null?void 0:s.getScale(w))||{x:1,y:1}:{x:1,y:1},T=oC(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:v,offsetParent:w,strategy:l}):v);return{top:(m.top-T.top+O.top)/y.y,bottom:(T.bottom-m.bottom+O.bottom)/y.y,left:(m.left-T.left+O.left)/y.x,right:(T.right-m.right+O.right)/y.x}}const Urn=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}=Ug(e,t)||{};if(c==null)return{};const d=kTe(u),h={x:n,y:r},f=Az(i),O=Rz(f),g=await a.getDimensions(c),m=f==="y",v=m?"top":"left",w=m?"bottom":"right",y=m?"clientHeight":"clientWidth",T=s.reference[O]+s.reference[f]-h[f]-s.floating[O],x=h[f]-s.reference[f],k=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c));let S=k?k[y]:0;(!S||!await(a.isElement==null?void 0:a.isElement(k)))&&(S=o.floating[y]||s.floating[O]);const Q=T/2-x/2,R=S/2-g[O]/2-1,_=K1(d[v],R),A=K1(d[w],R),E=_,I=S-g[O]-A,L=S/2-g[O]/2+Q,z=WF(E,L,I),V=!l.arrow&&Ph(i)!=null&&L!==z&&s.reference[O]/2-(L<E?_:A)-g[O]/2<0,q=V?L<E?L-E:L-I:0;return{[f]:h[f]+q,data:Uo({[f]:z,centerOffset:L-z-q},V&&{alignmentOffset:q}),reset:V}}});function Wrn(e,t,n){return(e?[...n.filter(r=>Ph(r)===e),...n.filter(r=>Ph(r)!==e)]:n.filter(r=>Uh(r)===r)).filter(r=>e?Ph(r)===e||(t?sC(r)!==r:!1):!0)}const Grn=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=Ug(e,t),{crossAxis:d=!1,alignment:h,allowedPlacements:f=Xre,autoAlignment:O=!0}=u,g=_z(u,Mrn),m=h!==void 0||f===Xre?Wrn(h||null,O,f):f,v=await Xz(t,g),w=((n=a.autoPlacement)==null?void 0:n.index)||0,y=m[w];if(y==null)return{};const T=$Te(y,s,await(l.isRTL==null?void 0:l.isRTL(c.floating)));if(o!==y)return{reset:{placement:m[0]}};const x=[v[Uh(y)],v[T[0]],v[T[1]]],k=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:y,overflows:x}],S=m[w+1];if(S)return{data:{index:w+1,overflows:k},reset:{placement:S}};const Q=k.map(_=>{const A=Ph(_.placement);return[_.placement,A&&d?_.overflows.slice(0,2).reduce((E,I)=>E+I,0):_.overflows[0],_.overflows]}).sort((_,A)=>_[1]-A[1]),R=((i=Q.filter(_=>_[2].slice(0,Ph(_[0])?2:3).every(A=>A<=0))[0])==null?void 0:i[0])||Q[0][0];return R!==o?{data:{index:w+1,overflows:k},reset:{placement:R}}:{}}}},jrn=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=Ug(e,t),{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:O="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0}=u,v=_z(u,zrn);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=Uh(i),y=J1(o),T=Uh(o)===o,x=await(l.isRTL==null?void 0:l.isRTL(c.floating)),k=f||(T||!m?[aC(o)]:Drn(o)),S=g!=="none";!f&&S&&k.push(...Frn(o,m,g,x));const Q=[o,...k],R=await Xz(t,v),_=[];let A=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(R[w]),h){const z=$Te(i,a,x);_.push(R[z[0]],R[z[1]])}if(A=[...A,{placement:i,overflows:_}],!_.every(z=>z<=0)){var E,I;const z=(((E=s.flip)==null?void 0:E.index)||0)+1,V=Q[z];if(V)return{data:{index:z,overflows:A},reset:{placement:V}};let q=(I=A.filter(Z=>Z.overflows[0]<=0).sort((Z,j)=>Z.overflows[1]-j.overflows[1])[0])==null?void 0:I.placement;if(!q)switch(O){case"bestFit":{var L;const Z=(L=A.filter(j=>{if(S){const M=J1(j.placement);return M===y||M==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(M=>M>0).reduce((M,Y)=>M+Y,0)]).sort((j,M)=>j[1]-M[1])[0])==null?void 0:L[0];Z&&(q=Z);break}case"initialPlacement":q=o;break}if(i!==q)return{reset:{placement:q}}}return{}}}},Vrn=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,s=Ug(e,t),{mainAxis:a=!0,crossAxis:o=!1,limiter:l={fn:v=>{let{x:w,y}=v;return{x:w,y}}}}=s,c=_z(s,Lrn),u={x:n,y:r},d=await Xz(t,c),h=J1(Uh(i)),f=Ez(h);let O=u[f],g=u[h];if(a){const v=f==="y"?"top":"left",w=f==="y"?"bottom":"right",y=O+d[v],T=O-d[w];O=WF(y,O,T)}if(o){const v=h==="y"?"top":"left",w=h==="y"?"bottom":"right",y=g+d[v],T=g-d[w];g=WF(y,g,T)}const m=l.fn(Uo({},t,{[f]:O,[h]:g}));return Uo({},m,{data:{x:m.x-n,y:m.y-r}})}}},Yrn=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}=Ug(e,t),u={x:n,y:r},d=J1(i),h=Ez(d);let f=u[h],O=u[d];const g=Ug(o,t),m=typeof g=="number"?{mainAxis:g,crossAxis:0}:Uo({mainAxis:0,crossAxis:0},g);if(l){const y=h==="y"?"height":"width",T=s.reference[h]-s.floating[y]+m.mainAxis,x=s.reference[h]+s.reference[y]-m.mainAxis;f<T?f=T:f>x&&(f=x)}if(c){var v,w;const y=h==="y"?"width":"height",T=["top","left"].includes(Uh(i)),x=s.reference[d]-s.floating[y]+(T&&((v=a.offset)==null?void 0:v[d])||0)+(T?0:m.crossAxis),k=s.reference[d]+s.reference[y]+(T?0:((w=a.offset)==null?void 0:w[d])||0)-(T?m.crossAxis:0);O<x?O=x:O>k&&(O=k)}return{[h]:f,[d]:O}}}};function f5(){return typeof window<"u"}function Fv(e){return TTe(e)?(e.nodeName||"").toLowerCase():"#document"}function bl(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Qd(e){var t;return(t=(TTe(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function TTe(e){return f5()?e instanceof Node||e instanceof bl(e).Node:!1}function tu(e){return f5()?e instanceof Element||e instanceof bl(e).Element:!1}function vd(e){return f5()?e instanceof HTMLElement||e instanceof bl(e).HTMLElement:!1}function Ire(e){return!f5()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof bl(e).ShadowRoot}function KS(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=nu(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(i)}function Brn(e){return["table","td","th"].includes(Fv(e))}function O5(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Dz(e){const t=Iz(),n=tu(e)?nu(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 Zrn(e){let t=CO(e);for(;vd(t)&&!ev(t);){if(Dz(t))return t;if(O5(t))return null;t=CO(t)}return null}function Iz(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ev(e){return["html","body","#document"].includes(Fv(e))}function nu(e){return bl(e).getComputedStyle(e)}function p5(e){return tu(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function CO(e){if(Fv(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ire(e)&&e.host||Qd(e);return Ire(t)?t.host:t}function PTe(e){const t=CO(e);return ev(t)?e.ownerDocument?e.ownerDocument.body:e.body:vd(t)&&KS(t)?t:PTe(t)}function Kx(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=PTe(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=bl(i);if(s){const o=GF(a);return t.concat(a,a.visualViewport||[],KS(i)?i:[],o&&n?Kx(o):[])}return t.concat(i,Kx(i,[],n))}function GF(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function _Te(e){const t=nu(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=vd(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,o=iC(n)!==s||iC(r)!==a;return o&&(n=s,r=a),{width:n,height:r,$:o}}function Fz(e){return tu(e)?e:e.contextElement}function s1(e){const t=Fz(e);if(!vd(t))return od(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=_Te(t);let a=(s?iC(n.width):n.width)/r,o=(s?iC(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const Hrn=od(0);function CTe(e){const t=bl(e);return!Iz()||!t.visualViewport?Hrn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Krn(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==bl(e)?!1:t}function Wg(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=Fz(e);let a=od(1);t&&(r?tu(r)&&(a=s1(r)):a=s1(e));const o=Krn(s,n,r)?CTe(s):od(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=bl(s),f=r&&tu(r)?bl(r):r;let O=h,g=GF(O);for(;g&&r&&f!==O;){const m=s1(g),v=g.getBoundingClientRect(),w=nu(g),y=v.left+(g.clientLeft+parseFloat(w.paddingLeft))*m.x,T=v.top+(g.clientTop+parseFloat(w.paddingTop))*m.y;l*=m.x,c*=m.y,u*=m.x,d*=m.y,l+=y,c+=T,O=bl(g),g=GF(O)}}return oC({width:u,height:d,x:l,y:c})}function Nz(e,t){const n=p5(e).scrollLeft;return t?t.left+n:Wg(Qd(e)).left+n}function QTe(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),i=r.left+t.scrollLeft-(n?0:Nz(e,r)),s=r.top+t.scrollTop;return{x:i,y:s}}function Jrn(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=Qd(r),o=t?O5(t.floating):!1;if(r===a||o&&s)return n;let l={scrollLeft:0,scrollTop:0},c=od(1);const u=od(0),d=vd(r);if((d||!d&&!s)&&((Fv(r)!=="body"||KS(a))&&(l=p5(r)),vd(r))){const f=Wg(r);c=s1(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}const h=a&&!d&&!s?QTe(a,l,!0):od(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 ein(e){return Array.from(e.getClientRects())}function tin(e){const t=Qd(e),n=p5(e),r=e.ownerDocument.body,i=ig(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=ig(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Nz(e);const o=-n.scrollTop;return nu(r).direction==="rtl"&&(a+=ig(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:o}}function nin(e,t){const n=bl(e),r=Qd(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=Iz();(!c||c&&t==="fixed")&&(o=i.offsetLeft,l=i.offsetTop)}return{width:s,height:a,x:o,y:l}}function rin(e,t){const n=Wg(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=vd(e)?s1(e):od(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 Fre(e,t,n){let r;if(t==="viewport")r=nin(e,n);else if(t==="document")r=tin(Qd(e));else if(tu(t))r=rin(t,n);else{const i=CTe(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return oC(r)}function ETe(e,t){const n=CO(e);return n===t||!tu(n)||ev(n)?!1:nu(n).position==="fixed"||ETe(n,t)}function iin(e,t){const n=t.get(e);if(n)return n;let r=Kx(e,[],!1).filter(o=>tu(o)&&Fv(o)!=="body"),i=null;const s=nu(e).position==="fixed";let a=s?CO(e):e;for(;tu(a)&&!ev(a);){const o=nu(a),l=Dz(a);!l&&o.position==="fixed"&&(i=null),(s?!l&&!i:!l&&o.position==="static"&&i&&["absolute","fixed"].includes(i.position)||KS(a)&&!l&&ETe(e,a))?r=r.filter(c=>c!==a):i=o,a=CO(a)}return t.set(e,r),r}function sin(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[...n==="clippingAncestors"?O5(t)?[]:iin(t,this._c):[].concat(n),r],a=s[0],o=s.reduce((l,c)=>{const u=Fre(t,c,i);return l.top=ig(u.top,l.top),l.right=K1(u.right,l.right),l.bottom=K1(u.bottom,l.bottom),l.left=ig(u.left,l.left),l},Fre(t,a,i));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}}function ain(e){const{width:t,height:n}=_Te(e);return{width:t,height:n}}function oin(e,t,n){const r=vd(t),i=Qd(t),s=n==="fixed",a=Wg(e,!0,s,t);let o={scrollLeft:0,scrollTop:0};const l=od(0);if(r||!r&&!s)if((Fv(t)!=="body"||KS(i))&&(o=p5(t)),r){const h=Wg(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else i&&(l.x=Nz(i));const c=i&&!r&&!s?QTe(i,o):od(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 jA(e){return nu(e).position==="static"}function Nre(e,t){if(!vd(e)||nu(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Qd(e)===n&&(n=n.ownerDocument.body),n}function RTe(e,t){const n=bl(e);if(O5(e))return n;if(!vd(e)){let i=CO(e);for(;i&&!ev(i);){if(tu(i)&&!jA(i))return i;i=CO(i)}return n}let r=Nre(e,t);for(;r&&Brn(r)&&jA(r);)r=Nre(r,t);return r&&ev(r)&&jA(r)&&!Dz(r)?n:r||Zrn(e)||n}const lin=async function(e){const t=this.getOffsetParent||RTe,n=this.getDimensions,r=await n(e.floating);return{reference:oin(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function cin(e){return nu(e).direction==="rtl"}const uin={convertOffsetParentRelativeRectToViewportRelativeRect:Jrn,getDocumentElement:Qd,getClippingRect:sin,getOffsetParent:RTe,getElementRects:lin,getClientRects:ein,getDimensions:ain,getScale:s1,isElement:tu,isRTL:cin};function din(e,t){let n=null,r;const i=Qd(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=pT(u),O=pT(i.clientWidth-(c+d)),g=pT(i.clientHeight-(u+h)),m=pT(c),v={rootMargin:-f+"px "+-O+"px "+-g+"px "+-m+"px",threshold:ig(0,K1(1,l))||1};let w=!0;function y(T){const x=T[0].intersectionRatio;if(x!==l){if(!w)return a();x?a(!1,x):r=setTimeout(()=>{a(!1,1e-7)},1e3)}w=!1}try{n=new IntersectionObserver(y,Uo({},v,{root:i.ownerDocument}))}catch{n=new IntersectionObserver(y,v)}n.observe(e)}return a(!0),s}function hin(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=Fz(e),u=i||s?[...c?Kx(c):[],...Kx(t)]:[];u.forEach(v=>{i&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const d=c&&o?din(c,n):null;let h=-1,f=null;a&&(f=new ResizeObserver(v=>{let[w]=v;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=f)==null||y.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let O,g=l?Wg(e):null;l&&m();function m(){const v=Wg(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(w=>{i&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),d?.(),(v=f)==null||v.disconnect(),f=null,l&&cancelAnimationFrame(O)}}const fin=Grn,Oin=Vrn,pin=jrn,gin=Urn,min=Yrn,vin=(e,t,n)=>{const r=new Map,i=Uo({platform:uin},n),s=Uo({},i.platform,{_c:r});return qrn(e,t,Uo({},i,{platform:s}))};function win(e){e.cleanup&&e.cleanup();const t=e._getResolvedAttachToOptions();let n=t.element;const r=kin(t,e),i=xTe(t);return i&&(n=document.body,e.shepherdElementComponent.getElement().classList.add("shepherd-centered")),e.cleanup=hin(n,e.el,()=>{if(!e.el){e.cleanup==null||e.cleanup();return}xin(n,e,r,i)}),e.target=t.element,r}function bin(e,t){return{floatingUIOptions:Cz(e.floatingUIOptions||{},t.floatingUIOptions||{})}}function yin(e){e.cleanup&&e.cleanup(),e.cleanup=null}function xin(e,t,n,r){return vin(e,t.el,n).then(Sin(t,r)).then(i=>new Promise(s=>{setTimeout(()=>s(i),300)})).then(i=>{i!=null&&i.el&&i.el.focus({preventScroll:!0})})}function Sin(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,$in(e.el,s)),e)}function $in(e,t){const n=e.querySelector(".shepherd-arrow");if(H1(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 kin(e,t){var n,r,i;const s={strategy:"absolute"};s.middleware=[];const a=Tin(t),o=xTe(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(fin({crossAxis:!0,alignment:c?e==null||(u=e.on)==null?void 0:u.split("-").pop():null}))}else s.middleware.push(pin());if(s.middleware.push(Oin({limiter:min(),crossAxis:!0})),a){const d=typeof t.options.arrow=="object"?t.options.arrow:{padding:4};s.middleware.push(gin({element:a,padding:c?d.padding:0}))}l||(s.placement=e.on)}return Cz(s,t.options.floatingUIOptions||{})}function Tin(e){return e.options.arrow&&e.el?e.el.querySelector(".shepherd-arrow"):!1}function kl(){}function Pin(e,t){for(const n in t)e[n]=t[n];return e}function ATe(e){return e()}function Mre(){return Object.create(null)}function JS(e){e.forEach(ATe)}function Mz(e){return typeof e=="function"}function tf(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function _in(e){return Object.keys(e).length===0}function tv(e,t){e.appendChild(t)}function hu(e,t,n){e.insertBefore(t,n||null)}function bc(e){e.parentNode&&e.parentNode.removeChild(e)}function Cin(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function wd(e){return document.createElement(e)}function zre(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function XTe(e){return document.createTextNode(e)}function lC(){return XTe(" ")}function Qin(){return XTe("")}function g5(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function ri(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}const Ein=["width","height"];function Lre(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&&Ein.indexOf(r)===-1?e[r]=t[r]:ri(e,r,t[r])}function Rin(e){return Array.from(e.childNodes)}function Km(e,t,n){e.classList.toggle(t,!!n)}let Jx;function iy(e){Jx=e}function DTe(){if(!Jx)throw new Error("Function called outside component initialization");return Jx}function Ain(e){DTe().$$.on_mount.push(e)}function zz(e){DTe().$$.after_update.push(e)}const h0=[],nv=[];let a1=[];const qre=[],Xin=Promise.resolve();let jF=!1;function Din(){jF||(jF=!0,Xin.then(ITe))}function VF(e){a1.push(e)}const VA=new Set;let Jm=0;function ITe(){if(Jm!==0)return;const e=Jx;do{try{for(;Jm<h0.length;){const t=h0[Jm];Jm++,iy(t),Iin(t.$$)}}catch(t){throw h0.length=0,Jm=0,t}for(iy(null),h0.length=0,Jm=0;nv.length;)nv.pop()();for(let t=0;t<a1.length;t+=1){const n=a1[t];VA.has(n)||(VA.add(n),n())}a1.length=0}while(h0.length);for(;qre.length;)qre.pop()();jF=!1,VA.clear(),iy(e)}function Iin(e){if(e.fragment!==null){e.update(),JS(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(VF)}}function Fin(e){const t=[],n=[];a1.forEach(r=>e.indexOf(r)===-1?t.push(r):n.push(r)),n.forEach(r=>r()),a1=t}const k2=new Set;let Mp;function sg(){Mp={r:0,c:[],p:Mp}}function ag(){Mp.r||JS(Mp.c),Mp=Mp.p}function Ur(e,t){e&&e.i&&(k2.delete(e),e.i(t))}function rs(e,t,n,r){if(e&&e.o){if(k2.has(e))return;k2.add(e),Mp.c.push(()=>{k2.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Ure(e){return e?.length!==void 0?e:Array.from(e)}function Nin(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 bm(e){e&&e.c()}function VO(e,t,n){const{fragment:r,after_update:i}=e.$$;r&&r.m(t,n),VF(()=>{const s=e.$$.on_mount.map(ATe).filter(Mz);e.$$.on_destroy?e.$$.on_destroy.push(...s):JS(s),e.$$.on_mount=[]}),i.forEach(VF)}function YO(e,t){const n=e.$$;n.fragment!==null&&(Fin(n.after_update),JS(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Min(e,t){e.$$.dirty[0]===-1&&(h0.push(e),Din(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function nf(e,t,n,r,i,s,a=null,o=[-1]){const l=Jx;iy(e);const c=e.$$={fragment:null,ctx:[],props:s,update:kl,not_equal:i,bound:Mre(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Mre(),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&&Min(e,d)),h}):[],c.update(),u=!0,JS(c.before_update),c.fragment=r?r(c.ctx):!1,t.target){if(t.hydrate){const d=Rin(t.target);c.fragment&&c.fragment.l(d),d.forEach(bc)}else c.fragment&&c.fragment.c();t.intro&&Ur(e.$$.fragment),VO(e,t.target,t.anchor),ITe()}iy(l)}class rf{constructor(){this.$$=void 0,this.$$set=void 0}$destroy(){YO(this,1),this.$destroy=kl}$on(t,n){if(!Mz(n))return kl;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&&!_in(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const zin="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(zin);function Lin(e){let t,n,r,i,s;return{c(){t=wd("button"),ri(t,"aria-label",n=e[3]?e[3]:null),ri(t,"class",r=`${e[1]||""} shepherd-button ${e[4]?"shepherd-button-secondary":""}`),t.disabled=e[2],ri(t,"tabindex","0"),ri(t,"type","button")},m(a,o){hu(a,t,o),t.innerHTML=e[5],i||(s=g5(t,"click",function(){Mz(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)&&ri(t,"aria-label",n),o&18&&r!==(r=`${e[1]||""} shepherd-button ${e[4]?"shepherd-button-secondary":""}`)&&ri(t,"class",r),o&4&&(t.disabled=e[2])},i:kl,o:kl,d(a){a&&bc(t),i=!1,s()}}}function qin(e,t,n){let{config:r,step:i}=t,s,a,o,l,c,u;function d(h){return _O(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 Uin extends rf{constructor(t){super(),nf(this,t,qin,Lin,tf,{config:6,step:7})}}function Wre(e,t,n){const r=e.slice();return r[2]=t[n],r}function Gre(e){let t,n,r=Ure(e[1]),i=[];for(let a=0;a<r.length;a+=1)i[a]=jre(Wre(e,r,a));const s=a=>rs(i[a],1,1,()=>{i[a]=null});return{c(){for(let a=0;a<i.length;a+=1)i[a].c();t=Qin()},m(a,o){for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(a,o);hu(a,t,o),n=!0},p(a,o){if(o&3){r=Ure(a[1]);let l;for(l=0;l<r.length;l+=1){const c=Wre(a,r,l);i[l]?(i[l].p(c,o),Ur(i[l],1)):(i[l]=jre(c),i[l].c(),Ur(i[l],1),i[l].m(t.parentNode,t))}for(sg(),l=r.length;l<i.length;l+=1)s(l);ag()}},i(a){if(!n){for(let o=0;o<r.length;o+=1)Ur(i[o]);n=!0}},o(a){i=i.filter(Boolean);for(let o=0;o<i.length;o+=1)rs(i[o]);n=!1},d(a){a&&bc(t),Cin(i,a)}}}function jre(e){let t,n;return t=new Uin({props:{config:e[2],step:e[0]}}),{c(){bm(t.$$.fragment)},m(r,i){VO(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||(Ur(t.$$.fragment,r),n=!0)},o(r){rs(t.$$.fragment,r),n=!1},d(r){YO(t,r)}}}function Win(e){let t,n,r=e[1]&&Gre(e);return{c(){t=wd("footer"),r&&r.c(),ri(t,"class","shepherd-footer")},m(i,s){hu(i,t,s),r&&r.m(t,null),n=!0},p(i,[s]){i[1]?r?(r.p(i,s),s&2&&Ur(r,1)):(r=Gre(i),r.c(),Ur(r,1),r.m(t,null)):r&&(sg(),rs(r,1,1,()=>{r=null}),ag())},i(i){n||(Ur(r),n=!0)},o(i){rs(r),n=!1},d(i){i&&bc(t),r&&r.d()}}}function Gin(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 jin extends rf{constructor(t){super(),nf(this,t,Gin,Win,tf,{step:0})}}function Vin(e){let t,n,r,i,s;return{c(){t=wd("button"),n=wd("span"),n.textContent="×",ri(n,"aria-hidden","true"),ri(t,"aria-label",r=e[0].label?e[0].label:"Close Tour"),ri(t,"class","shepherd-cancel-icon"),ri(t,"type","button")},m(a,o){hu(a,t,o),tv(t,n),i||(s=g5(t,"click",e[1]),i=!0)},p(a,[o]){o&1&&r!==(r=a[0].label?a[0].label:"Close Tour")&&ri(t,"aria-label",r)},i:kl,o:kl,d(a){a&&bc(t),i=!1,s()}}}function Yin(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 Bin extends rf{constructor(t){super(),nf(this,t,Yin,Vin,tf,{cancelIcon:0,step:2})}}function Zin(e){let t;return{c(){t=wd("h3"),ri(t,"id",e[1]),ri(t,"class","shepherd-title")},m(n,r){hu(n,t,r),e[3](t)},p(n,[r]){r&2&&ri(t,"id",n[1])},i:kl,o:kl,d(n){n&&bc(t),e[3](null)}}}function Hin(e,t,n){let{labelId:r,element:i,title:s}=t;zz(()=>{_O(s)&&n(2,s=s()),n(0,i.innerHTML=s,i)});function a(o){nv[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 Kin extends rf{constructor(t){super(),nf(this,t,Hin,Zin,tf,{labelId:1,element:0,title:2})}}function Vre(e){let t,n;return t=new Kin({props:{labelId:e[0],title:e[2]}}),{c(){bm(t.$$.fragment)},m(r,i){VO(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||(Ur(t.$$.fragment,r),n=!0)},o(r){rs(t.$$.fragment,r),n=!1},d(r){YO(t,r)}}}function Yre(e){let t,n;return t=new Bin({props:{cancelIcon:e[3],step:e[1]}}),{c(){bm(t.$$.fragment)},m(r,i){VO(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||(Ur(t.$$.fragment,r),n=!0)},o(r){rs(t.$$.fragment,r),n=!1},d(r){YO(t,r)}}}function Jin(e){let t,n,r,i=e[2]&&Vre(e),s=e[3]&&e[3].enabled&&Yre(e);return{c(){t=wd("header"),i&&i.c(),n=lC(),s&&s.c(),ri(t,"class","shepherd-header")},m(a,o){hu(a,t,o),i&&i.m(t,null),tv(t,n),s&&s.m(t,null),r=!0},p(a,[o]){a[2]?i?(i.p(a,o),o&4&&Ur(i,1)):(i=Vre(a),i.c(),Ur(i,1),i.m(t,n)):i&&(sg(),rs(i,1,1,()=>{i=null}),ag()),a[3]&&a[3].enabled?s?(s.p(a,o),o&8&&Ur(s,1)):(s=Yre(a),s.c(),Ur(s,1),s.m(t,null)):s&&(sg(),rs(s,1,1,()=>{s=null}),ag())},i(a){r||(Ur(i),Ur(s),r=!0)},o(a){rs(i),rs(s),r=!1},d(a){a&&bc(t),i&&i.d(),s&&s.d()}}}function esn(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 tsn extends rf{constructor(t){super(),nf(this,t,esn,Jin,tf,{labelId:0,step:1})}}function nsn(e){let t;return{c(){t=wd("div"),ri(t,"class","shepherd-text"),ri(t,"id",e[1])},m(n,r){hu(n,t,r),e[3](t)},p(n,[r]){r&2&&ri(t,"id",n[1])},i:kl,o:kl,d(n){n&&bc(t),e[3](null)}}}function rsn(e,t,n){let{descriptionId:r,element:i,step:s}=t;zz(()=>{let{text:o}=s.options;_O(o)&&(o=o.call(s)),H1(o)?i.appendChild(o):n(0,i.innerHTML=o,i)});function a(o){nv[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 isn extends rf{constructor(t){super(),nf(this,t,rsn,nsn,tf,{descriptionId:1,element:0,step:2})}}function Bre(e){let t,n;return t=new tsn({props:{labelId:e[1],step:e[2]}}),{c(){bm(t.$$.fragment)},m(r,i){VO(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||(Ur(t.$$.fragment,r),n=!0)},o(r){rs(t.$$.fragment,r),n=!1},d(r){YO(t,r)}}}function Zre(e){let t,n;return t=new isn({props:{descriptionId:e[0],step:e[2]}}),{c(){bm(t.$$.fragment)},m(r,i){VO(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||(Ur(t.$$.fragment,r),n=!0)},o(r){rs(t.$$.fragment,r),n=!1},d(r){YO(t,r)}}}function Hre(e){let t,n;return t=new jin({props:{step:e[2]}}),{c(){bm(t.$$.fragment)},m(r,i){VO(t,r,i),n=!0},p(r,i){const s={};i&4&&(s.step=r[2]),t.$set(s)},i(r){n||(Ur(t.$$.fragment,r),n=!0)},o(r){rs(t.$$.fragment,r),n=!1},d(r){YO(t,r)}}}function ssn(e){let t,n=!Da(e[2].options.title)||e[2].options.cancelIcon&&e[2].options.cancelIcon.enabled,r,i=!Da(e[2].options.text),s,a=Array.isArray(e[2].options.buttons)&&e[2].options.buttons.length,o,l=n&&Bre(e),c=i&&Zre(e),u=a&&Hre(e);return{c(){t=wd("div"),l&&l.c(),r=lC(),c&&c.c(),s=lC(),u&&u.c(),ri(t,"class","shepherd-content")},m(d,h){hu(d,t,h),l&&l.m(t,null),tv(t,r),c&&c.m(t,null),tv(t,s),u&&u.m(t,null),o=!0},p(d,[h]){h&4&&(n=!Da(d[2].options.title)||d[2].options.cancelIcon&&d[2].options.cancelIcon.enabled),n?l?(l.p(d,h),h&4&&Ur(l,1)):(l=Bre(d),l.c(),Ur(l,1),l.m(t,r)):l&&(sg(),rs(l,1,1,()=>{l=null}),ag()),h&4&&(i=!Da(d[2].options.text)),i?c?(c.p(d,h),h&4&&Ur(c,1)):(c=Zre(d),c.c(),Ur(c,1),c.m(t,s)):c&&(sg(),rs(c,1,1,()=>{c=null}),ag()),h&4&&(a=Array.isArray(d[2].options.buttons)&&d[2].options.buttons.length),a?u?(u.p(d,h),h&4&&Ur(u,1)):(u=Hre(d),u.c(),Ur(u,1),u.m(t,null)):u&&(sg(),rs(u,1,1,()=>{u=null}),ag())},i(d){o||(Ur(l),Ur(c),Ur(u),o=!0)},o(d){rs(l),rs(c),rs(u),o=!1},d(d){d&&bc(t),l&&l.d(),c&&c.d(),u&&u.d()}}}function asn(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 osn extends rf{constructor(t){super(),nf(this,t,asn,ssn,tf,{descriptionId:0,labelId:1,step:2})}}function Kre(e){let t;return{c(){t=wd("div"),ri(t,"class","shepherd-arrow"),ri(t,"data-popper-arrow","")},m(n,r){hu(n,t,r)},d(n){n&&bc(t)}}}function lsn(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&&Kre();r=new osn({props:{descriptionId:e[2],labelId:e[3],step:e[4]}});let u=[{"aria-describedby":i=Da(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=Pin(d,u[h]);return{c(){t=wd("dialog"),c&&c.c(),n=lC(),bm(r.$$.fragment),Lre(t,d),Km(t,"shepherd-has-cancel-icon",e[5]),Km(t,"shepherd-has-title",e[6]),Km(t,"shepherd-element",!0)},m(h,f){hu(h,t,f),c&&c.m(t,null),tv(t,n),VO(r,t,null),e[13](t),a=!0,o||(l=g5(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=Kre(),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),Lre(t,d=Nin(u,[(!a||f&20&&i!==(i=Da(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"}])),Km(t,"shepherd-has-cancel-icon",h[5]),Km(t,"shepherd-has-title",h[6]),Km(t,"shepherd-element",!0)},i(h){a||(Ur(r.$$.fragment,h),a=!0)},o(h){rs(r.$$.fragment,h),a=!1},d(h){h&&bc(t),c&&c.d(),YO(r),e[13](null),o=!1,l()}}}const csn=9,usn=27,dsn=37,hsn=39;function Jre(e){return e.split(" ").filter(t=>!!t.length)}function fsn(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;Ain(()=>{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])}),zz(()=>{O!==u.options.classes&&m()});function m(){v(O),O=u.options.classes,w(O)}function v(x){if(Hx(x)){const k=Jre(x);k.length&&i.classList.remove(...k)}}function w(x){if(Hx(x)){const k=Jre(x);k.length&&i.classList.add(...k)}}const y=x=>{const{tour:k}=u;switch(x.keyCode){case csn: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 usn:k.options.exitOnEsc&&(x.preventDefault(),x.stopPropagation(),u.cancel());break;case dsn:k.options.keyboardNavigation&&(x.preventDefault(),x.stopPropagation(),k.back());break;case hsn:k.options.keyboardNavigation&&(x.preventDefault(),x.stopPropagation(),k.next());break}};function T(x){nv[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,y,a,o,c,r,g,T]}class Osn extends rf{constructor(t){super(),nf(this,t,fsn,lsn,tf,{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 YF extends Pz{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?yTe(this.tour.options.classPrefix):"",this.styles=t.styles,this._resolvedAttachTo=null,Qz(this),this._setOptions(n),this}cancel(){this.tour.cancel(),this.trigger("cancel")}complete(){this.tour.complete(),this.trigger("complete")}destroy(){yin(this),H1(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=Ern(this),this._resolvedExtraHighlightElements}_resolveAttachToOptions(){return this._resolvedAttachTo=Qrn(this),this._resolvedAttachTo}_getResolvedAttachToOptions(){return this._resolvedAttachTo===null?this._resolveAttachToOptions():this._resolvedAttachTo}isOpen(){return!!(this.el&&!this.el.hidden)}show(){return _O(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 Osn({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();_O(this.options.scrollToHandler)?this.options.scrollToHandler(n):crn(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=Cz({},n||{}),this.options=Object.assign({arrow:!0},n,t,bin(n,t));const{when:r}=this.options;this.options.classes=this._getClassOptions(t),this.destroy(),this.id=this.options.id||`step-${STe()}`,r&&Object.keys(r).forEach(i=>{this.on(i,r[i],this)})}_setupElements(){Da(this.el)||this.destroy(),this.el=this._createTooltipContent(),this.options.advanceOn&&Prn(this),win(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 psn(e){if(e){const{steps:t}=e;t.forEach(n=>{n.options&&n.options.canClickTarget===!1&&n.options.attachTo&&(H1(n.target)&&n.target.classList.remove("shepherd-target-click-disabled"),n._resolvedExtraHighlightElements&&n._resolvedExtraHighlightElements.forEach(r=>{H1(r)&&r.classList.remove("shepherd-target-click-disabled")}))})}}function gsn(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 msn(e){let t,n,r,i,s;return{c(){t=zre("svg"),n=zre("path"),ri(n,"d",e[2]),ri(t,"class",r=`${e[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)},m(a,o){hu(a,t,o),tv(t,n),e[11](t),i||(s=g5(t,"touchmove",e[3]),i=!0)},p(a,[o]){o&4&&ri(n,"d",a[2]),o&2&&r!==(r=`${a[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)&&ri(t,"class",r)},i:kl,o:kl,d(a){a&&bc(t),e[11](null),i=!1,s()}}}function FTe(e){if(!e)return null;const t=e instanceof HTMLElement&&window.getComputedStyle(e).overflowY;return t!=="hidden"&&t!=="visible"&&e.scrollHeight>=e.clientHeight?e:FTe(e.parentElement)}function vsn(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 wsn(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 bsn(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,k=0,S=0,Q,R,_){if(R){const A=[R,..._||[]];n(4,i=[]);for(const E of A){if(!E||A.indexOf(E)!==A.lastIndexOf(E))continue;const{y:I,height:L}=wsn(E,Q),{x:z,width:V,left:q}=E.getBoundingClientRect();A.some(Z=>{if(Z===E)return!1;const j=Z.getBoundingClientRect();return z>=j.left&&z+V<=j.right&&I>=j.top&&I+L<=j.bottom})||i.push({width:V+T*2,height:L+T*2,x:(z||q)+k-T,y:I+S-T,r:x})}}else c()}function h(T){v(),T.tour.options.useModalOverlay?(w(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 w(T){const{modalOverlayOpeningPadding:x,modalOverlayOpeningRadius:k,modalOverlayOpeningXOffset:S=0,modalOverlayOpeningYOffset:Q=0}=T.options,R=vsn(T.target),_=FTe(T.target),A=()=>{a=void 0,d(x,k,S+R.left,Q+R.top,_,T.target,T._resolvedExtraHighlightElements),a=requestAnimationFrame(A)};A(),m()}function y(T){nv[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=gsn(i))},[r,s,o,g,i,l,c,u,d,h,f,y]}class ysn extends rf{constructor(t){super(),nf(this,t,bsn,msn,tf,{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 xsn extends Pz{constructor(){super(),this.activeTour=void 0,Qz(this)}}class Ssn extends Pz{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,Qz(this);const n={exitOnEsc:!0,keyboardNavigation:!0};return this.options=Object.assign({},n,t),this.classPrefix=yTe(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,zp.trigger(i,s)})})(r)}),this._setTourID(t.id),this}addStep(t,n){let r=t;return r instanceof YF?r.tour=this:r=new YF(this,r),Da(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;_O(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 zp.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=Hx(t)?this.getById(t):this.steps[t];r&&(this._updateStateBeforeShow(),_O(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()),psn(this),this.trigger(t,{index:n}),zp.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)}H1(this.focusedElBeforeOpen)&&this.focusedElBeforeOpen.focus()}_setupActiveTour(){this.trigger("active",{tour:this}),zp.activeTour=this}setupModal(){this.modal=new ysn({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||STe();this.id=`${n}--${r}`}}const zp=new xsn,NTe=typeof window>"u";zp.Step=NTe?_rn:YF;zp.Tour=NTe?Crn:Ssn;const m5=b.createContext(void 0);m5.Consumer;const $sn=({children:e})=>lrn.jsx(m5.Provider,{value:{Shepherd:zp},children:e}),ksn=""+new URL("agentic-sequence-CExfswgi.png",import.meta.url).href,Tsn=""+new URL("canvas-code-inline-edit-DLji9b0m.png",import.meta.url).href,Psn=""+new URL("canvas-overview-CruGEIRC.png",import.meta.url).href,_sn=""+new URL("canvas-variables-view-DrA20zqs.png",import.meta.url).href,Csn=""+new URL("chat-attachments-_3cRrONU.png",import.meta.url).href,Qsn=""+new URL("chat-full-view-e-eJPzrw.png",import.meta.url).href,Esn=""+new URL("chat-input-CU-CA7Se.png",import.meta.url).href,Rsn=""+new URL("inline-edit-canvas-O9conTkE.png",import.meta.url).href,Asn=e=>{const t=Array.from(document.querySelectorAll(`[data-tour-tag="${e}"]`));return t.find(n=>n.offsetParent!==null)??t[0]??null},eie=e=>{document.querySelector(`[data-tour-action="${e}"]`)?.click()},tie=[{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="${Qsn}" 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="${Esn}" 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="${Csn}" 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="${ksn}" 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}=Gr.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}=Gr.getState();e(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const{closeCommandPalette:e}=Gr.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}=Gr.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="${Psn}" 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="${Rsn}" 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.
|
|
1323
1323
|
<br /><img src="${Tsn}" 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="${_sn}" 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").
|
|
1324
|
-
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:()=>Asn("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(){eie("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(()=>{eie("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()}}]}],Xsn=()=>{const e=Js(),{completeTourOnboarding:t}=zy(),n=b.useContext(m5),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=zy.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(tie)}else l.steps.length===0&&l.addSteps(tie);typeof l.start=="function"?(e("/"),l.start()):console.warn("Shepherd tour instance does not have a start method.",l)}}},Dsn=()=>{const{isModalComplete:e,isTourComplete:t}=zy(),{startTour:n}=Xsn(),r=Oe.useContext(m5),{data:i}=M8(1,1);return b.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},Isn=({children:e})=>p.jsxs($sn,{children:[e,p.jsx(Dsn,{})]}),nie=["auth","settings","commands","catalogues","lifecycle","mcp","radient"],Fsn=()=>{const e=Gh(),t=ks(),[n,r]=b.useState(!1),[i,s]=b.useState(null),a=b.useCallback(()=>{t.invalidateQueries({queryKey:td.capabilities})},[t]),o=b.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?nie.filter(m=>(l.features?.[m]??0)<1):[...nie],u=!!l&&!l?.desktop_available;if(l?.desktop_available&&c.length===0)return null;const d=Aae(e.error),h=!!l,f=!!window.api?.updater?.updateBackend,O=cAe({kind:d,unpaired:u,missing:c,answered:h}),g=f&&lAe({kind:d,unpaired:u,answered:h});return p.jsx("div",{className:"fixed inset-x-0 top-0 z-2100 w-full",children:p.jsx(qc,{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(dC,{children:[O,i?` ${i}`:null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[g&&p.jsx(Te,{variant:"primary",size:"sm",onClick:()=>void o(),disabled:n,children:n?"Updating":"Update backend"}),p.jsx(Te,{variant:"secondary",size:"sm",onClick:a,children:"Retry"})]})]})})})},Nsn=""+new URL("radient-icon-1024x1024-D_JJedvo.png",import.meta.url).href,MTe={all:["radient-prices"],prices:()=>[...MTe.all,"prices"]},Msn=()=>{const e=_r({queryKey:MTe.prices(),queryFn:()=>e7({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}},zTe=Va()(ru(e=>({hasBeenNotified:!1,setHasBeenNotified:t=>{e({hasBeenNotified:t})}}),{name:"low-credits-storage"})),zsn=({open:e,onClose:t,onGoToConsole:n})=>{const{setHasBeenNotified:r}=zTe(),{prices:i,isLoading:s,error:a}=Msn(),o=u=>typeof u!="number"?"$...":`$${u.toFixed(2)} USD`,l=()=>{r(!0),t()},c=()=>{r(!0),n()};return p.jsx(AO,{open:e,onClose:l,title:p.jsxs(p.Fragment,{children:[p.jsx("img",{src:Nsn,alt:"Radient icon",className:"size-7"}),"Running low on Radient credits?"]}),maxWidth:"sm",fullWidth:!1,actions:p.jsxs(p.Fragment,{children:[p.jsx(lv,{onClick:l,children:"Maybe later"}),p.jsx(ov,{onClick:c,startIcon:p.jsx(wC,{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(Pr,{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."})]})})},rie=({expanded:e})=>p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[p.jsx("img",{src:h2e,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"})]}),LTe=Oe.memo(({expanded:e,useAuth:t=!1})=>{const n=Js(),{user:r,isAuthenticated:i,signOut:s}=t7(),a=r?.name??"User",o=r?.email??"",l=b.useCallback(async()=>{i&&(await s(),window.location.reload())},[i,s]),c=b.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:G("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(hie,{className:"size-7 shrink-0",children:p.jsx(fie,{className:"bg-elevated text-ink",children:c??p.jsx(Oae,{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(vt,{content:"Account settings",side:"right",children:u});return t?p.jsxs(nS,{children:[e?p.jsx(l1,{asChild:!0,children:u}):p.jsx(vt,{content:"Account settings",side:"right",children:p.jsx(l1,{asChild:!0,children:u})}),p.jsxs(rS,{align:"end",side:"top",className:"min-w-50",children:[p.jsxs(ts,{onSelect:()=>n("/settings"),children:[p.jsx(dh,{size:16,"aria-hidden":"true"}),"Settings"]}),p.jsxs(ts,{children:[p.jsx(uae,{size:16,"aria-hidden":"true"}),"Privacy and security"]}),p.jsx(P0,{}),p.jsxs(ts,{onSelect:l,className:"text-danger focus:bg-danger-wash focus:text-danger",children:[p.jsx(rEe,{size:16,"aria-hidden":"true"}),"Sign out"]})]})]}):d});LTe.displayName="UserProfileSidebar";const iie={expanded:"w-55",collapsed:"w-12"},Lsn=()=>{const e=Js(),t=m6e(),{isSidebarCollapsed:n,toggleSidebar:r}=Gr(),i=!n,s=[{icon:bC,label:"Chat",path:"/chat",isActive:t==="chat",tourTag:"nav-item-chat"},{icon:sv,label:"My agents",path:"/agents",isActive:t==="agents",tourTag:"nav-item-agents"},{icon:fae,label:"Agent hub",path:"/agent-hub",isActive:t==="agent-hub",tourTag:"nav-item-agent-hub"},{icon:Bse,label:"Schedules",path:"/schedules",isActive:t==="schedules",tourTag:"nav-item-schedules"},{icon:dh,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:G("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:G("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(vt,{content:c.label,side:"right",children:u})},c.path)},o=i?"Collapse sidebar":"Expand sidebar",l=p.jsx("div",{className:G("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(vt,{content:o,side:"right",children:p.jsx(Te,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":o,"aria-expanded":i,children:i?p.jsx(q2,{"aria-hidden":"true"}):p.jsx(og,{"aria-hidden":"true"})})})});return p.jsxs("nav",{className:G("group flex shrink-0 flex-col overflow-x-hidden bg-sunken transition-[width] duration-base ease-out-quart",i?iie.expanded:iie.collapsed),children:[p.jsx("div",{className:G("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(rie,{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(rie,{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(LTe,{expanded:i})})]})},qsn=1,Usn=()=>{const{isAuthenticated:e,user:t}=t7(),{hasBeenNotified:n,setHasBeenNotified:r}=zTe(),[i,s]=b.useState(!1),[a,o]=b.useState(null),l=b.useCallback(async()=>{if(!(!e||!t?.radientUser?.account?.tenant_id))try{const h=await e7({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 b.useEffect(()=>{e&&l()},[e,l]),b.useEffect(()=>{e&&a!==null?a<qsn?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}},Wsn=b.lazy(()=>Ae(()=>import("./agent-details-page-AoSG_fVH.js"),__vite__mapDeps([9,1,2,10,11]),import.meta.url).then(e=>({default:e.AgentDetailsPage}))),Gsn=b.lazy(()=>Ae(()=>import("./agent-hub-page-CaZjaTZe.js"),__vite__mapDeps([12,1,2,13,14,11]),import.meta.url).then(e=>({default:e.AgentHubPage}))),sie=b.lazy(()=>Ae(()=>import("./agents-page-RS6PE_fF.js"),__vite__mapDeps([15,1,2]),import.meta.url).then(e=>({default:e.AgentsPage}))),jsn=b.lazy(()=>Ae(()=>import("./schedules-page-CLrcFhCL.js"),__vite__mapDeps([16,1,2,14,17,10]),import.meta.url).then(e=>({default:e.SchedulesPage}))),Vsn=b.lazy(()=>Ae(()=>import("./settings-page-CKVWBbsu.js"),__vite__mapDeps([18,1,2,14,19,10,17,3,20,21,22,23,24]),import.meta.url).then(e=>({default:e.SettingsPage}))),Ysn=()=>{const{isOnboardingActive:e}=i6e(),{isLowCreditsDialogOpen:t,openRadientConsole:n,onLowCreditsDialogClose:r}=Usn(),{toggleCommandPalette:i,isCommandPaletteOpen:s,isCreateAgentDialogOpen:a,closeCreateAgentDialog:o}=Gr(),l=Js(),c=d=>{l(`/chat/${d}`),o()};b.useEffect(()=>{const d=()=>{i()},h=window.electron.ipcRenderer.on("toggle-command-palette",d);return()=>{h&&h()}},[i]);const u=Bn(d=>d.setActiveSession);return b.useEffect(()=>{const d=window.api?.desktop?.onOpenConversation?.(h=>{u(h),l("/chat")});return()=>d?.()},[l,u]),p.jsx(Isn,{children:p.jsxs("div",{className:"relative flex h-screen overflow-hidden",children:[s&&p.jsx(Ann,{}),p.jsx(coe,{}),p.jsx(srn,{open:e}),p.jsx(VXe,{}),p.jsx(Fsn,{}),p.jsx(nDe,{}),p.jsx(zsn,{open:t,onClose:r,onGoToConsole:n}),p.jsx(loe,{open:a,onClose:o,onAgentCreated:c}),p.jsx(Lsn,{}),p.jsx("main",{className:"flex grow flex-col overflow-hidden",children:p.jsx(b.Suspense,{fallback:p.jsx("div",{className:"flex grow items-center justify-center",children:p.jsx(Pr,{size:"lg",label:"Loading page"})}),children:p.jsxs(KCe,{children:[p.jsx(kc,{path:"/",element:p.jsx(bq,{to:"/chat",replace:!0})}),p.jsx(kc,{path:"/chat",element:p.jsx(ore,{})}),p.jsx(kc,{path:"/chat/:agentId",element:p.jsx(ore,{})}),p.jsx(kc,{path:"/agents",element:p.jsx(sie,{})}),p.jsx(kc,{path:"/agents/:agentId",element:p.jsx(sie,{})}),p.jsx(kc,{path:"/settings",element:p.jsx(Vsn,{})}),p.jsx(kc,{path:"/agent-hub",element:p.jsx(Gsn,{})}),p.jsx(kc,{path:"/agent-hub/:agentId",element:p.jsx(Wsn,{})}),p.jsx(kc,{path:"/schedules",element:p.jsx(jsn,{})}),p.jsx(kc,{path:"*",element:p.jsx(bq,{to:"/chat",replace:!0})})]})})})]})})},Bsn={queries:{staleTime:5*60*1e3,gcTime:10*60*1e3,retry:1,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!1,networkMode:"always"},mutations:{retry:1,networkMode:"always"}},qTe=new Q2e({defaultOptions:Bsn}),Zsn=`
|
|
1324
|
+
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:()=>Asn("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(){eie("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(()=>{eie("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()}}]}],Xsn=()=>{const e=Js(),{completeTourOnboarding:t}=zy(),n=b.useContext(m5),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=zy.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(tie)}else l.steps.length===0&&l.addSteps(tie);typeof l.start=="function"?(e("/"),l.start()):console.warn("Shepherd tour instance does not have a start method.",l)}}},Dsn=()=>{const{isModalComplete:e,isTourComplete:t}=zy(),{startTour:n}=Xsn(),r=Oe.useContext(m5),{data:i}=M8(1,1);return b.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},Isn=({children:e})=>p.jsxs($sn,{children:[e,p.jsx(Dsn,{})]}),nie=["auth","settings","commands","catalogues","lifecycle","mcp","radient"],Fsn=()=>{const e=Gh(),t=ks(),[n,r]=b.useState(!1),[i,s]=b.useState(null),a=b.useCallback(()=>{t.invalidateQueries({queryKey:td.capabilities})},[t]),o=b.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?nie.filter(m=>(l.features?.[m]??0)<1):[...nie],u=!!l&&!l?.desktop_available;if(l?.desktop_available&&c.length===0)return null;const d=Aae(e.error),h=!!l,f=!!window.api?.updater?.updateBackend,O=cAe({kind:d,unpaired:u,missing:c,answered:h}),g=f&&lAe({kind:d,unpaired:u,answered:h});return p.jsx("div",{className:"fixed inset-x-0 top-0 z-2100 w-full",children:p.jsx(qc,{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(dC,{children:[O,i?` ${i}`:null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[g&&p.jsx(Te,{variant:"primary",size:"sm",onClick:()=>void o(),disabled:n,children:n?"Updating":"Update backend"}),p.jsx(Te,{variant:"secondary",size:"sm",onClick:a,children:"Retry"})]})]})})})},Nsn=""+new URL("radient-icon-1024x1024-D_JJedvo.png",import.meta.url).href,MTe={all:["radient-prices"],prices:()=>[...MTe.all,"prices"]},Msn=()=>{const e=_r({queryKey:MTe.prices(),queryFn:()=>e7({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}},zTe=Va()(ru(e=>({hasBeenNotified:!1,setHasBeenNotified:t=>{e({hasBeenNotified:t})}}),{name:"low-credits-storage"})),zsn=({open:e,onClose:t,onGoToConsole:n})=>{const{setHasBeenNotified:r}=zTe(),{prices:i,isLoading:s,error:a}=Msn(),o=u=>typeof u!="number"?"$...":`$${u.toFixed(2)} USD`,l=()=>{r(!0),t()},c=()=>{r(!0),n()};return p.jsx(AO,{open:e,onClose:l,title:p.jsxs(p.Fragment,{children:[p.jsx("img",{src:Nsn,alt:"Radient icon",className:"size-7"}),"Running low on Radient credits?"]}),maxWidth:"sm",fullWidth:!1,actions:p.jsxs(p.Fragment,{children:[p.jsx(lv,{onClick:l,children:"Maybe later"}),p.jsx(ov,{onClick:c,startIcon:p.jsx(wC,{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(Pr,{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."})]})})},rie=({expanded:e})=>p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[p.jsx("img",{src:h2e,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"})]}),LTe=Oe.memo(({expanded:e,useAuth:t=!1})=>{const n=Js(),{user:r,isAuthenticated:i,signOut:s}=t7(),a=r?.name??"User",o=r?.email??"",l=b.useCallback(async()=>{i&&(await s(),window.location.reload())},[i,s]),c=b.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:G("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(hie,{className:"size-7 shrink-0",children:p.jsx(fie,{className:"bg-elevated text-ink",children:c??p.jsx(Oae,{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(vt,{content:"Account settings",side:"right",children:u});return t?p.jsxs(nS,{children:[e?p.jsx(l1,{asChild:!0,children:u}):p.jsx(vt,{content:"Account settings",side:"right",children:p.jsx(l1,{asChild:!0,children:u})}),p.jsxs(rS,{align:"end",side:"top",className:"min-w-50",children:[p.jsxs(ts,{onSelect:()=>n("/settings"),children:[p.jsx(dh,{size:16,"aria-hidden":"true"}),"Settings"]}),p.jsxs(ts,{children:[p.jsx(uae,{size:16,"aria-hidden":"true"}),"Privacy and security"]}),p.jsx(P0,{}),p.jsxs(ts,{onSelect:l,className:"text-danger focus:bg-danger-wash focus:text-danger",children:[p.jsx(rEe,{size:16,"aria-hidden":"true"}),"Sign out"]})]})]}):d});LTe.displayName="UserProfileSidebar";const iie={expanded:"w-55",collapsed:"w-12"},Lsn=()=>{const e=Js(),t=m6e(),{isSidebarCollapsed:n,toggleSidebar:r}=Gr(),i=!n,s=[{icon:bC,label:"Chat",path:"/chat",isActive:t==="chat",tourTag:"nav-item-chat"},{icon:sv,label:"My agents",path:"/agents",isActive:t==="agents",tourTag:"nav-item-agents"},{icon:fae,label:"Agent hub",path:"/agent-hub",isActive:t==="agent-hub",tourTag:"nav-item-agent-hub"},{icon:Bse,label:"Schedules",path:"/schedules",isActive:t==="schedules",tourTag:"nav-item-schedules"},{icon:dh,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:G("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:G("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(vt,{content:c.label,side:"right",children:u})},c.path)},o=i?"Collapse sidebar":"Expand sidebar",l=p.jsx("div",{className:G("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(vt,{content:o,side:"right",children:p.jsx(Te,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":o,"aria-expanded":i,children:i?p.jsx(q2,{"aria-hidden":"true"}):p.jsx(og,{"aria-hidden":"true"})})})});return p.jsxs("nav",{className:G("group flex shrink-0 flex-col overflow-x-hidden bg-sunken transition-[width] duration-base ease-out-quart",i?iie.expanded:iie.collapsed),children:[p.jsx("div",{className:G("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(rie,{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(rie,{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(LTe,{expanded:i})})]})},qsn=1,Usn=()=>{const{isAuthenticated:e,user:t}=t7(),{hasBeenNotified:n,setHasBeenNotified:r}=zTe(),[i,s]=b.useState(!1),[a,o]=b.useState(null),l=b.useCallback(async()=>{if(!(!e||!t?.radientUser?.account?.tenant_id))try{const h=await e7({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 b.useEffect(()=>{e&&l()},[e,l]),b.useEffect(()=>{e&&a!==null?a<qsn?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}},Wsn=b.lazy(()=>Ae(()=>import("./agent-details-page-DGusXpiv.js"),__vite__mapDeps([9,1,2,10,11]),import.meta.url).then(e=>({default:e.AgentDetailsPage}))),Gsn=b.lazy(()=>Ae(()=>import("./agent-hub-page-BEy-xjst.js"),__vite__mapDeps([12,1,2,13,14,11]),import.meta.url).then(e=>({default:e.AgentHubPage}))),sie=b.lazy(()=>Ae(()=>import("./agents-page-VfOUQ-yP.js"),__vite__mapDeps([15,1,2]),import.meta.url).then(e=>({default:e.AgentsPage}))),jsn=b.lazy(()=>Ae(()=>import("./schedules-page-IjBtVuIo.js"),__vite__mapDeps([16,1,2,14,17,10]),import.meta.url).then(e=>({default:e.SchedulesPage}))),Vsn=b.lazy(()=>Ae(()=>import("./settings-page-BqJRfztd.js"),__vite__mapDeps([18,1,2,14,19,10,17,3,20,21,22,23,24]),import.meta.url).then(e=>({default:e.SettingsPage}))),Ysn=()=>{const{isOnboardingActive:e}=i6e(),{isLowCreditsDialogOpen:t,openRadientConsole:n,onLowCreditsDialogClose:r}=Usn(),{toggleCommandPalette:i,isCommandPaletteOpen:s,isCreateAgentDialogOpen:a,closeCreateAgentDialog:o}=Gr(),l=Js(),c=d=>{l(`/chat/${d}`),o()};b.useEffect(()=>{const d=()=>{i()},h=window.electron.ipcRenderer.on("toggle-command-palette",d);return()=>{h&&h()}},[i]);const u=Bn(d=>d.setActiveSession);return b.useEffect(()=>{const d=window.api?.desktop?.onOpenConversation?.(h=>{u(h),l("/chat")});return()=>d?.()},[l,u]),p.jsx(Isn,{children:p.jsxs("div",{className:"relative flex h-screen overflow-hidden",children:[s&&p.jsx(Ann,{}),p.jsx(coe,{}),p.jsx(srn,{open:e}),p.jsx(VXe,{}),p.jsx(Fsn,{}),p.jsx(nDe,{}),p.jsx(zsn,{open:t,onClose:r,onGoToConsole:n}),p.jsx(loe,{open:a,onClose:o,onAgentCreated:c}),p.jsx(Lsn,{}),p.jsx("main",{className:"flex grow flex-col overflow-hidden",children:p.jsx(b.Suspense,{fallback:p.jsx("div",{className:"flex grow items-center justify-center",children:p.jsx(Pr,{size:"lg",label:"Loading page"})}),children:p.jsxs(KCe,{children:[p.jsx(kc,{path:"/",element:p.jsx(bq,{to:"/chat",replace:!0})}),p.jsx(kc,{path:"/chat",element:p.jsx(ore,{})}),p.jsx(kc,{path:"/chat/:agentId",element:p.jsx(ore,{})}),p.jsx(kc,{path:"/agents",element:p.jsx(sie,{})}),p.jsx(kc,{path:"/agents/:agentId",element:p.jsx(sie,{})}),p.jsx(kc,{path:"/settings",element:p.jsx(Vsn,{})}),p.jsx(kc,{path:"/agent-hub",element:p.jsx(Gsn,{})}),p.jsx(kc,{path:"/agent-hub/:agentId",element:p.jsx(Wsn,{})}),p.jsx(kc,{path:"/schedules",element:p.jsx(jsn,{})}),p.jsx(kc,{path:"*",element:p.jsx(bq,{to:"/chat",replace:!0})})]})})})]})})},Bsn={queries:{staleTime:5*60*1e3,gcTime:10*60*1e3,retry:1,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!1,networkMode:"always"},mutations:{retry:1,networkMode:"always"}},qTe=new Q2e({defaultOptions:Bsn}),Zsn=`
|
|
1325
1325
|
*::-webkit-scrollbar {
|
|
1326
1326
|
width: 8px;
|
|
1327
1327
|
height: 8px;
|