var e=Object.defineProperty,t=(t,n,r)=>((t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r)(t,"symbol"!=typeof n?n+"":n,r);import{c8 as n,as as r,aD as i,dS as o,R as s,G as a,eQ as c,P as l,aM as u,a9 as d,aY as h,df as f,ax as p,eR as g,J as m,cn as y,ad as v,eS as b,dI as x,eD as w,eT as k,aF as T,eU as S,d5 as R,eV as D,eW as C,eX as j,eY as O,eZ as P,e_ as N,at as E,e$ as I,f0 as _,a5 as M,aS as q,aQ as A,be as L,$ as F,dc as H,e6 as $,a6 as z,a4 as B,f1 as U,f2 as W,f3 as V,f4 as K,f5 as G,f6 as J,f7 as Y,f8 as Z,dp as X,es as Q,f9 as ee,fa as te,fb as ne,fc as re,ar as ie,M as oe,fd as se,aE as ae,fe as ce,az as le,dx as ue,ff as de,fg as he,bc as fe,fh as pe,fi as ge,fj as me,Z as ye,fk as ve,fl as be,a0 as xe,a1 as we,a2 as ke,fm as Te,fn as Se,fo as Re,fp as De,fq as Ce,fr as je,fs as Oe,ft as Pe,fu as Ne,fv as Ee,fw as Ie,fx as _e,fy as Me,fz as qe,fA as Ae,fB as Le,bd as Fe,fC as He,fD as $e,d9 as ze,fE as Be,cb as Ue,fF as We,fG as Ve,ei as Ke,fH as Ge,fI as Je,fJ as Ye,fK as Ze,_ as Xe,fL as Qe,fM as et,fN as tt,fO as nt,fP as rt}from"./index-BiV-b1K2.js";import{r as it,a as ot,b as st,c as at,m as ct}from"./main-CEaoNRsh.js";import{r as lt}from"./createWsUrl-Bazdvp-G.js";import{e as ut}from"./index-DbEIEgDe.js"; /** * @license lucide-react v0.474.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */ const dt=i("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]),ht=i("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]),ft=i("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]),pt=i("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]),gt=i("FlaskConical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]),mt=i("FolderCog",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v3.3",key:"1k8050"}],["path",{d:"m21.7 19.4-.9-.3",key:"1qgwi9"}],["path",{d:"m15.2 16.9-.9-.3",key:"1t7mvx"}],["path",{d:"m16.6 21.7.3-.9",key:"1j67ps"}],["path",{d:"m19.1 15.2.3-.9",key:"18r7jp"}],["path",{d:"m19.6 21.7-.4-1",key:"z2vh2"}],["path",{d:"m16.8 15.3-.4-1",key:"1ei7r6"}],["path",{d:"m14.3 19.6 1-.4",key:"11sv9r"}],["path",{d:"m20.7 16.8 1-.4",key:"19m87a"}]]),yt=i("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),vt=i("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]),bt=i("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),xt=i("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function wt(e,t){return(wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function kt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}const Tt=o("flex items-center justify-center m-0 leading-none font-medium border border-foreground/10 shadow-xsSolid hover:cursor-pointer active:shadow-none dark:border-border text-sm",{variants:{color:{gray:"mo-button gray",white:"mo-button white",green:"mo-button green",red:"mo-button red",yellow:"mo-button yellow","hint-green":"mo-button hint-green",disabled:"mo-button disabled"},shape:{rectangle:"rounded",circle:"rounded-full"},size:{small:"",medium:""}},compoundVariants:[{size:"small",shape:"circle",class:"h-[24px] w-[24px] px-[5.5px] py-[5.5px]"},{size:"medium",shape:"circle",class:"px-2 py-2"},{size:"small",shape:"rectangle",class:"px-1 py-1 h-[24px] w-[24px]"},{size:"medium",shape:"rectangle",class:"px-3 py-2"}],defaultVariants:{color:"gray",size:"medium",shape:"rectangle"}}),St=o("font-mono w-full flex-1 inline-flex items-center justify-center rounded px-2.5 text-foreground/60 h-[36px] hover:shadow-md hover:cursor-pointer focus:shadow-md focus:outline-none text-[hsl(0, 0%, 43.5%)] bg-transparent hover:bg-background focus:bg-background"),Rt=s.forwardRef(((e,t)=>{const n=a.c(15);let r,i,o,s,u,d,h;return n[0]!==e?(({color:i,shape:s,size:u,className:r,...o}=e),n[0]=e,n[1]=r,n[2]=i,n[3]=o,n[4]=s,n[5]=u):(r=n[1],i=n[2],o=n[3],s=n[4],u=n[5]),n[6]!==r||n[7]!==i||n[8]!==s||n[9]!==u?(d=c(Tt({color:i,shape:s,size:u}),r),n[6]=r,n[7]=i,n[8]=s,n[9]=u,n[10]=d):d=n[10],n[11]!==o||n[12]!==t||n[13]!==d?(h=l.jsx("button",{ref:t,className:d,...o,children:o.children}),n[11]=o,n[12]=t,n[13]=d,n[14]=h):h=n[14],h}));Rt.displayName="Button";s.forwardRef(((e,t)=>{const n=a.c(9);let r,i,o,s;return n[0]!==e?(({className:r,...i}=e),n[0]=e,n[1]=r,n[2]=i):(r=n[1],i=n[2]),n[3]!==r?(o=c(St(),r),n[3]=r,n[4]=o):o=n[4],n[5]!==i||n[6]!==t||n[7]!==o?(s=l.jsx("input",{ref:t,className:o,...i}),n[5]=i,n[6]=t,n[7]=o,n[8]=s):s=n[8],s})).displayName="Input";const Dt=e=>{const t=a.c(7),{openConfirm:n,closeModal:r}=u(),i=jt;if(d())return null;let o,s,c;return t[0]!==r||t[1]!==n||t[2]!==e.description?(o=t=>{t.stopPropagation(),n({title:"Shutdown",description:e.description,variant:"destructive",confirmAction:l.jsx(h,{onClick:e=>{i(),r()},"aria-label":"Confirm Shutdown",children:"Shutdown"})})},t[0]=r,t[1]=n,t[2]=e.description,t[3]=o):o=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(s=l.jsx(f,{strokeWidth:1}),t[4]=s):s=t[4],t[5]!==o?(c=l.jsx(p,{content:"Shutdown",children:l.jsx(Rt,{"aria-label":"Shutdown","data-testid":"shutdown-button",shape:"circle",size:"small",color:"red",className:"h-[27px] w-[27px]",onClick:o,children:s})}),t[5]=o,t[6]=c):c=t[6],c};function Ct(){window.close()}function jt(){g(),setTimeout(Ct,200)}function Ot(e,t){const n=a.c(11),{delayMs:r,whenVisible:i,disabled:o}=t,s=void 0!==o&&o,c=m.useRef();let l,u,d,h,f;return n[0]!==e?(l=()=>{c.current=e},u=[e],n[0]=e,n[1]=l,n[2]=u):(l=n[1],u=n[2]),m.useEffect(l,u),n[3]!==r||n[4]!==s||n[5]!==i?(d=()=>{if(null===r||s)return;const e=setInterval((()=>{var e;i&&"visible"!==document.visibilityState||null==(e=c.current)||e.call(c)}),r);return()=>clearInterval(e)},h=[r,i,s],n[3]=r,n[4]=s,n[5]=i,n[6]=d,n[7]=h):(d=n[6],h=n[7]),m.useEffect(d,h),n[8]!==s||n[9]!==i?(f=()=>{var e;"visible"===document.visibilityState&&i&&!s&&(null==(e=c.current)||e.call(c))},n[8]=s,n[9]=i,n[10]=f):f=n[10],y(document,"visibilitychange",f),null}const Pt=e=>{const t=a.c(2),{children:n}=e;let r;return t[0]!==n?(r=l.jsx("div",{className:"text-md font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:n}),t[0]=n,t[1]=r):r=t[1],r},Nt=e=>{const t=a.c(10);let n,r,i,o,s;return t[0]!==e?(({children:n,className:r,...i}=e),t[0]=e,t[1]=n,t[2]=r,t[3]=i):(n=t[1],r=t[2],i=t[3]),t[4]!==r?(o=v("text-sm font-semibold underline-offset-2 text-accent-foreground uppercase tracking-wide",r),t[4]=r,t[5]=o):o=t[5],t[6]!==n||t[7]!==i||t[8]!==o?(s=l.jsx("div",{...i,className:o,children:n}),t[6]=n,t[7]=i,t[8]=o,t[9]=s):s=t[9],s},Et=e=>{const t=a.c(2),{children:n}=e;let r;return t[0]!==n?(r=l.jsx("p",{className:"text-sm text-muted-foreground",children:n}),t[0]=n,t[1]=r):r=t[1],r},It="marimo:copilot:signedIn",_t=T(It,null,void 0,{getOnInit:!0}),Mt=w(null),qt=w(null);function At(){const e="true"===localStorage.getItem(It),t=b();return e&&"github"===t.completion.copilot}var Lt,Ft,Ht={},$t={},zt={exports:{}};function Bt(){if(Lt)return zt.exports;Lt=1;var e,t="object"==typeof Reflect?Reflect:null,n=t&&"function"==typeof t.apply?t.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};e=t&&"function"==typeof t.ownKeys?t.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}zt.exports=i,zt.exports.once=function(e,t){return new Promise((function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}p(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&p(e,"error",t,n)}(e,i,{once:!0})}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function s(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function a(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function c(e,t,n,r){var i,o,c,l;if(s(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),c=o[t]),void 0===c)c=o[t]=n,++e._eventsCount;else if("function"==typeof c?c=o[t]=r?[n,c]:[c,n]:r?c.unshift(n):c.push(n),(i=a(e))>0&&c.length>i&&!c.warned){c.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=c.length,l=u,console&&console.warn&&console.warn(l)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=l.bind(r);return i.listener=n,r.wrapFn=i,i}function d(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var l=c.length,u=f(c,l);for(r=0;r=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},i.prototype.listeners=function(e){return d(this,e,!0)},i.prototype.rawListeners=function(e){return d(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},i.prototype.listenerCount=h,i.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]},zt.exports}function Ut(){return Ft||(Ft=1,function(e){var t=$t&&$t.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(t){o(t)}}function a(e){try{c(r.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},n=$t&&$t.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0)return r[0]},n.prototype.resolveRes=function(e,n){var r,i=e.id,o=e.error,s=this.pendingRequest[i];return s?(delete this.pendingRequest[i],this.processResult(e,s),void this.transportEventChannel.emit("response",e)):void 0!==i||void 0!==o?(o&&(r=t.convertJSONToRPCError(e)),n&&o&&r&&this.transportEventChannel.emit("error",r),r):void this.transportEventChannel.emit("notification",e)},n.prototype.setRequestTimeout=function(e,n,r){var i=this;setTimeout((function(){delete i.pendingRequest[e],r(new t.JSONRPCError("Request timeout request took longer than "+n+" ms to resolve",t.ERR_TIMEOUT))}),n)},n}();return Yt.TransportRequestManager=n,Yt}(),t=function(){function t(){this.transportRequestManager=new e.TransportRequestManager,this.transportRequestManager.transportEventChannel.on("error",(function(){}))}return t.prototype.subscribe=function(e,t){this.transportRequestManager.transportEventChannel.addListener(e,t)},t.prototype.unsubscribe=function(e,t){if(!e)return this.transportRequestManager.transportEventChannel.removeAllListeners();e&&t&&this.transportRequestManager.transportEventChannel.removeListener(e,t)},t.prototype.parseData=function(e){return e instanceof Array?e.map((function(e){return e.request.request})):e.request},t}();return Jt.Transport=t,Jt}var en,tn,nn={};function rn(){return en||(en=1,e=nn,Object.defineProperty(e,"__esModule",{value:!0}),e.getNotifications=e.getBatchRequests=e.isNotification=void 0,e.isNotification=function(e){return void 0===e.request.id||null===e.request.id},e.getBatchRequests=function(e){return e instanceof Array?e.filter((function(e){var t=e.request.request.id;return null!=t})).map((function(e){return e.request})):[]},e.getNotifications=function(t){return t instanceof Array?t.filter((function(t){return e.isNotification(t.request)})).map((function(e){return e.request})):e.isNotification(t)?[t]:[]}),nn;var e}var on={},sn="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{},an="URLSearchParams"in sn,cn="Symbol"in sn&&"iterator"in Symbol,ln="FileReader"in sn&&"Blob"in sn&&function(){try{return new Blob,!0}catch(e){return!1}}(),un="FormData"in sn,dn="ArrayBuffer"in sn;if(dn)var hn=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],fn=ArrayBuffer.isView||function(e){return e&&hn.indexOf(Object.prototype.toString.call(e))>-1};function pn(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function gn(e){return"string"!=typeof e&&(e=String(e)),e}function mn(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return cn&&(t[Symbol.iterator]=function(){return t}),t}function yn(e){this.map={},e instanceof yn?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function vn(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function bn(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function xn(e){var t=new FileReader,n=bn(t);return t.readAsArrayBuffer(e),n}function wn(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function kn(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:ln&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:un&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:an&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():dn&&ln&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=wn(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):dn&&(ArrayBuffer.prototype.isPrototypeOf(e)||fn(e))?this._bodyArrayBuffer=wn(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):an&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},ln&&(this.blob=function(){var e=vn(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=vn(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(ln)return this.blob().then(xn);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,i,o=vn(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=bn(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),i=r?r[1]:"utf-8",t.readAsText(e,i),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in sn)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function Rn(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function Dn(e,t){if(!(this instanceof Dn))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new yn(t.headers),this.url=t.url||"",this._initBody(e)}Sn.prototype.clone=function(){return new Sn(this,{body:this._bodyInit})},kn.call(Sn.prototype),kn.call(Dn.prototype),Dn.prototype.clone=function(){return new Dn(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new yn(this.headers),url:this.url})},Dn.error=function(){var e=new Dn(null,{status:200,statusText:""});return e.status=0,e.type="error",e};var Cn=[301,302,303,307,308];Dn.redirect=function(e,t){if(-1===Cn.indexOf(t))throw new RangeError("Invalid status code");return new Dn(null,{status:t,headers:{location:e}})};var jn,On,Pn,Nn=sn.DOMException;try{new Nn}catch(Ch){(Nn=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),Nn.prototype.constructor=Nn}function En(e,t){return new Promise((function(n,r){var i=new Sn(e,t);if(i.signal&&i.signal.aborted)return r(new Nn("Aborted","AbortError"));var o=new XMLHttpRequest;function s(){o.abort()}if(o.onload=function(){var e,t,r={status:o.status,statusText:o.statusText,headers:(e=o.getAllResponseHeaders()||"",t=new yn,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();try{t.append(r,i)}catch(o){console.warn("Response "+o.message)}}})),t)};r.url="responseURL"in o?o.responseURL:r.headers.get("X-Request-URL");var i="response"in o?o.response:o.responseText;setTimeout((function(){n(new Dn(i,r))}),0)},o.onerror=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},o.ontimeout=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},o.onabort=function(){setTimeout((function(){r(new Nn("Aborted","AbortError"))}),0)},o.open(i.method,function(e){try{return""===e&&sn.location.href?sn.location.href:e}catch(t){return e}}(i.url),!0),"include"===i.credentials?o.withCredentials=!0:"omit"===i.credentials&&(o.withCredentials=!1),"responseType"in o&&(ln?o.responseType="blob":dn&&(o.responseType="arraybuffer")),t&&"object"==typeof t.headers&&!(t.headers instanceof yn||sn.Headers&&t.headers instanceof sn.Headers)){var a=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){a.push(pn(e)),o.setRequestHeader(e,gn(t.headers[e]))})),i.headers.forEach((function(e,t){-1===a.indexOf(t)&&o.setRequestHeader(t,e)}))}else i.headers.forEach((function(e,t){o.setRequestHeader(t,e)}));i.signal&&(i.signal.addEventListener("abort",s),o.onreadystatechange=function(){4===o.readyState&&i.signal.removeEventListener("abort",s)}),o.send(void 0===i._bodyInit?null:i._bodyInit)}))}function In(){if(Pn)return on;Pn=1;var e=on&&on.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),t=on&&on.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(t){o(t)}}function a(e){try{c(r.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},n=on&&on.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]n,next:()=>{if(this._state!==e)throw new Error("LinkedMap got modified during iteration.");if(t){const e={value:t.key,done:!1};return t=t.next,e}return{value:void 0,done:!0}}};return n}values(){const e=this._state;let t=this._head;const n={[Symbol.iterator]:()=>n,next:()=>{if(this._state!==e)throw new Error("LinkedMap got modified during iteration.");if(t){const e={value:t.value,done:!1};return t=t.next,e}return{value:void 0,done:!0}}};return n}entries(){const e=this._state;let t=this._head;const n={[Symbol.iterator]:()=>n,next:()=>{if(this._state!==e)throw new Error("LinkedMap got modified during iteration.");if(t){const e={value:[t.key,t.value],done:!1};return t=t.next,e}return{value:void 0,done:!0}}};return n}[(e=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}trimOld(e){if(e>=this.size)return;if(0===e)return void this.clear();let t=this._head,n=this.size;for(;t&&n>e;)this._map.delete(t.key),t=t.next,n--;this._head=t,this._size=n,t&&(t.previous=void 0),this._state++}addItemFirst(e){if(this._head||this._tail){if(!this._head)throw new Error("Invalid list");e.next=this._head,this._head.previous=e}else this._tail=e;this._head=e,this._state++}addItemLast(e){if(this._head||this._tail){if(!this._tail)throw new Error("Invalid list");e.previous=this._tail,this._tail.next=e}else this._head=e;this._tail=e,this._state++}removeItem(e){if(e===this._head&&e===this._tail)this._head=void 0,this._tail=void 0;else if(e===this._head){if(!e.next)throw new Error("Invalid list");e.next.previous=void 0,this._head=e.next}else if(e===this._tail){if(!e.previous)throw new Error("Invalid list");e.previous.next=void 0,this._tail=e.previous}else{const t=e.next,n=e.previous;if(!t||!n)throw new Error("Invalid list");t.previous=n,n.next=t}e.next=void 0,e.previous=void 0,this._state++}touch(e,n){if(!this._head||!this._tail)throw new Error("Invalid list");if(n===t.First||n===t.Last)if(n===t.First){if(e===this._head)return;const t=e.next,n=e.previous;e===this._tail?(n.next=void 0,this._tail=n):(t.previous=n,n.next=t),e.previous=void 0,e.next=this._head,this._head.previous=e,this._head=e,this._state++}else if(n===t.Last){if(e===this._tail)return;const t=e.next,n=e.previous;e===this._head?(t.previous=void 0,this._head=t):(t.previous=n,n.next=t),e.next=void 0,e.previous=this._tail,this._tail.next=e,this._tail=e,this._state++}}toJSON(){const e=[];return this.forEach(((t,n)=>{e.push([n,t])})),e}fromJSON(e){this.clear();for(const[t,n]of e)this.set(t,n)}}or.LinkedMap=r;return or.LRUCache=class extends r{constructor(e,t=1){super(),this._limit=e,this._ratio=Math.min(Math.max(0,t),1)}get limit(){return this._limit}set limit(e){this._limit=e,this.checkTrim()}get ratio(){return this._ratio}set ratio(e){this._ratio=Math.min(Math.max(0,e),1),this.checkTrim()}get(e,n=t.AsNew){return super.get(e,n)}peek(e){return super.get(e,t.None)}set(e,n){return super.set(e,n,t.Last),this.checkTrim(),this}checkTrim(){this.size>this._limit&&this.trimOld(Math.round(this._limit*this._ratio))}},or}var ar,cr={};var lr,ur={};var dr,hr,fr={},pr={};function gr(){if(dr)return pr;dr=1,Object.defineProperty(pr,"__esModule",{value:!0}),pr.Semaphore=void 0;const e=st();return pr.Semaphore=class{constructor(e=1){if(e<=0)throw new Error("Capacity must be greater than 0");this._capacity=e,this._active=0,this._waiting=[]}lock(e){return new Promise(((t,n)=>{this._waiting.push({thunk:e,resolve:t,reject:n}),this.runNext()}))}get active(){return this._active}runNext(){0!==this._waiting.length&&this._active!==this._capacity&&(0,e.default)().timer.setImmediate((()=>this.doRunNext()))}doRunNext(){if(0===this._waiting.length||this._active===this._capacity)return;const e=this._waiting.shift();if(this._active++,this._active>this._capacity)throw new Error("To many thunks active");try{const t=e.thunk();t instanceof Promise?t.then((t=>{this._active--,e.resolve(t),this.runNext()}),(t=>{this._active--,e.reject(t),this.runNext()})):(this._active--,e.resolve(t),this.runNext())}catch(Ch){this._active--,e.reject(Ch),this.runNext()}}},pr}var mr,yr={};var vr,br={};var xr,wr,kr,Tr,Sr,Rr,Dr={};function Cr(){return xr||(xr=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createMessageConnection=e.ConnectionOptions=e.MessageStrategy=e.CancellationStrategy=e.CancellationSenderStrategy=e.CancellationReceiverStrategy=e.RequestCancellationReceiverStrategy=e.IdCancellationReceiverStrategy=e.ConnectionStrategy=e.ConnectionError=e.ConnectionErrors=e.LogTraceNotification=e.SetTraceNotification=e.TraceFormat=e.TraceValues=e.Trace=e.NullLogger=e.ProgressType=e.ProgressToken=void 0;const t=st(),n=it(),r=rr(),i=sr(),o=at(),s=ot();var a,c,l,u,d,h,f,p,g,m,y,v,b,x,w,k,T,S,R,D,C,j,O,P,N,E,I;(a||(a={})).type=new r.NotificationType("$/cancelRequest"),(c||(e.ProgressToken=c={})).is=function(e){return"string"==typeof e||"number"==typeof e},(l||(l={})).type=new r.NotificationType("$/progress");e.ProgressType=class{constructor(){}},(u||(u={})).is=function(e){return n.func(e)},e.NullLogger=Object.freeze({error:()=>{},warn:()=>{},info:()=>{},log:()=>{}}),(h=d||(e.Trace=d={}))[h.Off=0]="Off",h[h.Messages=1]="Messages",h[h.Compact=2]="Compact",h[h.Verbose=3]="Verbose",(p=f||(e.TraceValues=f={})).Off="off",p.Messages="messages",p.Compact="compact",p.Verbose="verbose",function(e){e.fromString=function(t){if(!n.string(t))return e.Off;switch(t=t.toLowerCase()){case"off":default:return e.Off;case"messages":return e.Messages;case"compact":return e.Compact;case"verbose":return e.Verbose}},e.toString=function(t){switch(t){case e.Off:return"off";case e.Messages:return"messages";case e.Compact:return"compact";case e.Verbose:return"verbose";default:return"off"}}}(d||(e.Trace=d={})),(m=g||(e.TraceFormat=g={})).Text="text",m.JSON="json",function(e){e.fromString=function(t){return n.string(t)&&"json"===(t=t.toLowerCase())?e.JSON:e.Text}}(g||(e.TraceFormat=g={})),(y||(e.SetTraceNotification=y={})).type=new r.NotificationType("$/setTrace"),(v||(e.LogTraceNotification=v={})).type=new r.NotificationType("$/logTrace"),(x=b||(e.ConnectionErrors=b={}))[x.Closed=1]="Closed",x[x.Disposed=2]="Disposed",x[x.AlreadyListening=3]="AlreadyListening";class _ extends Error{constructor(e,t){super(t),this.code=e,Object.setPrototypeOf(this,_.prototype)}}e.ConnectionError=_,(w||(e.ConnectionStrategy=w={})).is=function(e){const t=e;return t&&n.func(t.cancelUndispatched)},(k||(e.IdCancellationReceiverStrategy=k={})).is=function(e){const t=e;return t&&(void 0===t.kind||"id"===t.kind)&&n.func(t.createCancellationTokenSource)&&(void 0===t.dispose||n.func(t.dispose))},(T||(e.RequestCancellationReceiverStrategy=T={})).is=function(e){const t=e;return t&&"request"===t.kind&&n.func(t.createCancellationTokenSource)&&(void 0===t.dispose||n.func(t.dispose))},(R=S||(e.CancellationReceiverStrategy=S={})).Message=Object.freeze({createCancellationTokenSource:e=>new s.CancellationTokenSource}),R.is=function(e){return k.is(e)||T.is(e)},(C=D||(e.CancellationSenderStrategy=D={})).Message=Object.freeze({sendCancellation:(e,t)=>e.sendNotification(a.type,{id:t}),cleanup(e){}}),C.is=function(e){const t=e;return t&&n.func(t.sendCancellation)&&n.func(t.cleanup)},(O=j||(e.CancellationStrategy=j={})).Message=Object.freeze({receiver:S.Message,sender:D.Message}),O.is=function(e){const t=e;return t&&S.is(t.receiver)&&D.is(t.sender)},(P||(e.MessageStrategy=P={})).is=function(e){const t=e;return t&&n.func(t.handleMessage)},(N||(e.ConnectionOptions=N={})).is=function(e){const t=e;return t&&(j.is(t.cancellationStrategy)||w.is(t.connectionStrategy)||P.is(t.messageStrategy))},(I=E||(E={}))[I.New=1]="New",I[I.Listening=2]="Listening",I[I.Closed=3]="Closed",I[I.Disposed=4]="Disposed",e.createMessageConnection=function(h,f,p,m){const x=void 0!==p?p:e.NullLogger;let w=0,T=0,S=0;const R="2.0";let D;const C=new Map;let O;const N=new Map,I=new Map;let M,q,A=new i.LinkedMap,L=new Map,F=new Set,H=new Map,$=d.Off,z=g.Text,B=E.New;const U=new o.Emitter,W=new o.Emitter,V=new o.Emitter,K=new o.Emitter,G=new o.Emitter,J=m&&m.cancellationStrategy?m.cancellationStrategy:j.Message;function Y(e){if(null===e)throw new Error("Can't send requests with id null since the response can't be correlated.");return"req-"+e.toString()}function Z(e,t){var n;r.Message.isRequest(t)?e.set(Y(t.id),t):r.Message.isResponse(t)?e.set(null===(n=t.id)?"res-unknown-"+(++S).toString():"res-"+n.toString(),t):e.set("not-"+(++T).toString(),t)}function X(e){}function Q(){return B===E.Listening}function ee(){return B===E.Closed}function te(){return B===E.Disposed}function ne(){B!==E.New&&B!==E.Listening||(B=E.Closed,W.fire(void 0))}function re(){M||0===A.size||(M=(0,t.default)().timer.setImmediate((()=>{M=void 0,function(){if(0===A.size)return;const e=A.shift();try{const t=null==m?void 0:m.messageStrategy;P.is(t)?t.handleMessage(e,ie):ie(e)}finally{re()}}()})))}function ie(e){r.Message.isRequest(e)?function(e){if(te())return;function t(t,n,i){const o={jsonrpc:R,id:e.id};t instanceof r.ResponseError?o.error=t.toJson():o.result=void 0===t?null:t,ae(o,n,i),f.write(o).catch((()=>x.error("Sending response failed.")))}function i(t,n,r){const i={jsonrpc:R,id:e.id,error:t.toJson()};ae(i,n,r),f.write(i).catch((()=>x.error("Sending response failed.")))}function o(t,n,r){void 0===t&&(t=null);const i={jsonrpc:R,id:e.id,result:t};ae(i,n,r),f.write(i).catch((()=>x.error("Sending response failed.")))}!function(e){if($===d.Off||!q)return;if(z===g.Text){let t;$!==d.Verbose&&$!==d.Compact||!e.params||(t=`Params: ${se(e.params)}\n\n`),q.log(`Received request '${e.method} - (${e.id})'.`,t)}else le("receive-request",e)}(e);const s=C.get(e.method);let a,c;s&&(a=s.type,c=s.handler);const l=Date.now();if(c||D){const s=e.id??String(Date.now()),d=k.is(J.receiver)?J.receiver.createCancellationTokenSource(s):J.receiver.createCancellationTokenSource(e);null!==e.id&&F.has(e.id)&&d.cancel(),null!==e.id&&H.set(s,d);try{let u;if(c)if(void 0===e.params){if(void 0!==a&&0!==a.numberOfParams)return void i(new r.ResponseError(r.ErrorCodes.InvalidParams,`Request ${e.method} defines ${a.numberOfParams} params but received none.`),e.method,l);u=c(d.token)}else if(Array.isArray(e.params)){if(void 0!==a&&a.parameterStructures===r.ParameterStructures.byName)return void i(new r.ResponseError(r.ErrorCodes.InvalidParams,`Request ${e.method} defines parameters by name but received parameters by position`),e.method,l);u=c(...e.params,d.token)}else{if(void 0!==a&&a.parameterStructures===r.ParameterStructures.byPosition)return void i(new r.ResponseError(r.ErrorCodes.InvalidParams,`Request ${e.method} defines parameters by position but received parameters by name`),e.method,l);u=c(e.params,d.token)}else D&&(u=D(e.method,e.params,d.token));const h=u;u?h.then?h.then((n=>{H.delete(s),t(n,e.method,l)}),(t=>{H.delete(s),t instanceof r.ResponseError?i(t,e.method,l):t&&n.string(t.message)?i(new r.ResponseError(r.ErrorCodes.InternalError,`Request ${e.method} failed with message: ${t.message}`),e.method,l):i(new r.ResponseError(r.ErrorCodes.InternalError,`Request ${e.method} failed unexpectedly without providing any details.`),e.method,l)})):(H.delete(s),t(u,e.method,l)):(H.delete(s),o(u,e.method,l))}catch(u){H.delete(s),u instanceof r.ResponseError?t(u,e.method,l):u&&n.string(u.message)?i(new r.ResponseError(r.ErrorCodes.InternalError,`Request ${e.method} failed with message: ${u.message}`),e.method,l):i(new r.ResponseError(r.ErrorCodes.InternalError,`Request ${e.method} failed unexpectedly without providing any details.`),e.method,l)}}else i(new r.ResponseError(r.ErrorCodes.MethodNotFound,`Unhandled method ${e.method}`),e.method,l)}(e):r.Message.isNotification(e)?function(e){if(te())return;let t,n;if(e.method===a.type.method){const t=e.params.id;return F.delete(t),void ce(e)}{const r=N.get(e.method);r&&(n=r.handler,t=r.type)}if(n||O)try{if(ce(e),n)if(void 0===e.params)void 0!==t&&0!==t.numberOfParams&&t.parameterStructures!==r.ParameterStructures.byName&&x.error(`Notification ${e.method} defines ${t.numberOfParams} params but received none.`),n();else if(Array.isArray(e.params)){const i=e.params;e.method===l.type.method&&2===i.length&&c.is(i[0])?n({token:i[0],value:i[1]}):(void 0!==t&&(t.parameterStructures===r.ParameterStructures.byName&&x.error(`Notification ${e.method} defines parameters by name but received parameters by position`),t.numberOfParams!==e.params.length&&x.error(`Notification ${e.method} defines ${t.numberOfParams} params but received ${i.length} arguments`)),n(...i))}else void 0!==t&&t.parameterStructures===r.ParameterStructures.byPosition&&x.error(`Notification ${e.method} defines parameters by position but received parameters by name`),n(e.params);else O&&O(e.method,e.params)}catch(i){i.message?x.error(`Notification handler '${e.method}' failed with message: ${i.message}`):x.error(`Notification handler '${e.method}' failed unexpectedly.`)}else V.fire(e)}(e):r.Message.isResponse(e)?function(e){if(te())return;if(null===e.id)e.error?x.error(`Received response message without id: Error is: \n${JSON.stringify(e.error,void 0,4)}`):x.error("Received response message without id. No further error information provided.");else{const n=e.id,i=L.get(n);if(function(e,t){if($===d.Off||!q)return;if(z===g.Text){let n;if($!==d.Verbose&&$!==d.Compact||(e.error&&e.error.data?n=`Error data: ${se(e.error.data)}\n\n`:e.result?n=`Result: ${se(e.result)}\n\n`:void 0===e.error&&(n="No result returned.\n\n")),t){const r=e.error?` Request failed: ${e.error.message} (${e.error.code}).`:"";q.log(`Received response '${t.method} - (${e.id})' in ${Date.now()-t.timerStart}ms.${r}`,n)}else q.log(`Received response ${e.id} without active response promise.`,n)}else le("receive-response",e)}(e,i),void 0!==i){L.delete(n);try{if(e.error){const t=e.error;i.reject(new r.ResponseError(t.code,t.message,t.data))}else{if(void 0===e.result)throw new Error("Should never happen.");i.resolve(e.result)}}catch(t){t.message?x.error(`Response handler '${i.method}' failed with message: ${t.message}`):x.error(`Response handler '${i.method}' failed unexpectedly.`)}}}}(e):function(e){if(!e)return void x.error("Received empty message.");x.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(e,null,4)}`);const t=e;if(n.string(t.id)||n.number(t.id)){const e=t.id,n=L.get(e);n&&n.reject(new Error("The received response has neither a result nor an error property."))}}(e)}h.onClose(ne),h.onError((function(e){U.fire([e,void 0,void 0])})),f.onClose(ne),f.onError((function(e){U.fire(e)}));const oe=e=>{try{if(r.Message.isNotification(e)&&e.method===a.type.method){const t=e.params.id,n=Y(t),i=A.get(n);if(r.Message.isRequest(i)){const r=null==m?void 0:m.connectionStrategy,o=r&&r.cancelUndispatched?r.cancelUndispatched(i,X):void 0;if(o&&(void 0!==o.error||void 0!==o.result))return A.delete(n),H.delete(t),o.id=i.id,ae(o,e.method,Date.now()),void f.write(o).catch((()=>x.error("Sending response for canceled message failed.")))}const o=H.get(t);if(void 0!==o)return o.cancel(),void ce(e);F.add(t)}Z(A,e)}finally{re()}};function se(e){if(null!=e)switch($){case d.Verbose:return JSON.stringify(e,null,4);case d.Compact:return JSON.stringify(e);default:return}}function ae(e,t,n){if($!==d.Off&&q)if(z===g.Text){let r;$!==d.Verbose&&$!==d.Compact||(e.error&&e.error.data?r=`Error data: ${se(e.error.data)}\n\n`:e.result?r=`Result: ${se(e.result)}\n\n`:void 0===e.error&&(r="No result returned.\n\n")),q.log(`Sending response '${t} - (${e.id})'. Processing request took ${Date.now()-n}ms`,r)}else le("send-response",e)}function ce(e){if($!==d.Off&&q&&e.method!==v.type.method)if(z===g.Text){let t;$!==d.Verbose&&$!==d.Compact||(t=e.params?`Params: ${se(e.params)}\n\n`:"No parameters provided.\n\n"),q.log(`Received notification '${e.method}'.`,t)}else le("receive-notification",e)}function le(e,t){if(!q||$===d.Off)return;const n={isLSPMessage:!0,type:e,message:t,timestamp:Date.now()};q.log(n)}function ue(){if(ee())throw new _(b.Closed,"Connection is closed.");if(te())throw new _(b.Disposed,"Connection is disposed.")}function de(e){return void 0===e?null:e}function he(e){return null===e?void 0:e}function fe(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}function pe(e,t){switch(e){case r.ParameterStructures.auto:return fe(t)?he(t):[de(t)];case r.ParameterStructures.byName:if(!fe(t))throw new Error("Received parameters by name but param is not an object literal.");return he(t);case r.ParameterStructures.byPosition:return[de(t)];default:throw new Error(`Unknown parameter structure ${e.toString()}`)}}function ge(e,t){let n;const r=e.numberOfParams;switch(r){case 0:n=void 0;break;case 1:n=pe(e.parameterStructures,t[0]);break;default:n=[];for(let e=0;e{let i,o;if(ue(),n.string(e)){i=e;const n=t[0];let s=0,a=r.ParameterStructures.auto;r.ParameterStructures.is(n)&&(s=1,a=n);let c=t.length;const l=c-s;switch(l){case 0:o=void 0;break;case 1:o=pe(a,t[s]);break;default:if(a===r.ParameterStructures.byName)throw new Error(`Received ${l} parameters for 'by Name' notification parameter structure.`);o=t.slice(s,c).map((e=>de(e)))}}else{const n=t;i=e.method,o=ge(e,n)}const s={jsonrpc:R,method:i,params:o};return function(e){if($!==d.Off&&q)if(z===g.Text){let t;$!==d.Verbose&&$!==d.Compact||(t=e.params?`Params: ${se(e.params)}\n\n`:"No parameters provided.\n\n"),q.log(`Sending notification '${e.method}'.`,t)}else le("send-notification",e)}(s),f.write(s).catch((e=>{throw x.error("Sending notification failed."),e}))},onNotification:(e,t)=>{let r;return ue(),n.func(e)?O=e:t&&(n.string(e)?(r=e,N.set(e,{type:void 0,handler:t})):(r=e.method,N.set(e.method,{type:e,handler:t}))),{dispose:()=>{void 0!==r?N.delete(r):O=void 0}}},onProgress:(e,t,n)=>{if(I.has(t))throw new Error(`Progress handler for token ${t} already registered`);return I.set(t,n),{dispose:()=>{I.delete(t)}}},sendProgress:(e,t,n)=>me.sendNotification(l.type,{token:t,value:n}),onUnhandledProgress:K.event,sendRequest:(e,...t)=>{let i,o,a;if(ue(),function(){if(!Q())throw new Error("Call listen() first.")}(),n.string(e)){i=e;const n=t[0],c=t[t.length-1];let l=0,u=r.ParameterStructures.auto;r.ParameterStructures.is(n)&&(l=1,u=n);let d=t.length;s.CancellationToken.is(c)&&(d-=1,a=c);const h=d-l;switch(h){case 0:o=void 0;break;case 1:o=pe(u,t[l]);break;default:if(u===r.ParameterStructures.byName)throw new Error(`Received ${h} parameters for 'by Name' request parameter structure.`);o=t.slice(l,d).map((e=>de(e)))}}else{const n=t;i=e.method,o=ge(e,n);const r=e.numberOfParams;a=s.CancellationToken.is(n[r])?n[r]:void 0}const c=w++;let l;a&&(l=a.onCancellationRequested((()=>{const e=J.sender.sendCancellation(me,c);return void 0===e?(x.log(`Received no promise from cancellation strategy when cancelling id ${c}`),Promise.resolve()):e.catch((()=>{x.log(`Sending cancellation messages for id ${c} failed`)}))})));const u={jsonrpc:R,id:c,method:i,params:o};return function(e){if($!==d.Off&&q)if(z===g.Text){let t;$!==d.Verbose&&$!==d.Compact||!e.params||(t=`Params: ${se(e.params)}\n\n`),q.log(`Sending request '${e.method} - (${e.id})'.`,t)}else le("send-request",e)}(u),"function"==typeof J.sender.enableCancellation&&J.sender.enableCancellation(u),new Promise((async(e,t)=>{const n={method:i,timerStart:Date.now(),resolve:t=>{e(t),J.sender.cleanup(c),null==l||l.dispose()},reject:e=>{t(e),J.sender.cleanup(c),null==l||l.dispose()}};try{await f.write(u),L.set(c,n)}catch(o){throw x.error("Sending request failed."),n.reject(new r.ResponseError(r.ErrorCodes.MessageWriteError,o.message?o.message:"Unknown reason")),o}}))},onRequest:(e,t)=>{ue();let r=null;return u.is(e)?(r=void 0,D=e):n.string(e)?(r=null,void 0!==t&&(r=e,C.set(e,{handler:t,type:void 0}))):void 0!==t&&(r=e.method,C.set(e.method,{type:e,handler:t})),{dispose:()=>{null!==r&&(void 0!==r?C.delete(r):D=void 0)}}},hasPendingResponse:()=>L.size>0,trace:async(e,t,r)=>{let i=!1,o=g.Text;void 0!==r&&(n.boolean(r)?i=r:(i=r.sendNotification||!1,o=r.traceFormat||g.Text)),$=e,z=o,q=$===d.Off?void 0:t,!i||ee()||te()||await me.sendNotification(y.type,{value:d.toString(e)})},onError:U.event,onClose:W.event,onUnhandledNotification:V.event,onDispose:G.event,end:()=>{f.end()},dispose:()=>{if(te())return;B=E.Disposed,G.fire(void 0);const e=new r.ResponseError(r.ErrorCodes.PendingResponseRejected,"Pending response rejected since connection got disposed");for(const t of L.values())t.reject(e);L=new Map,H=new Map,F=new Set,A=new i.LinkedMap,n.func(f.dispose)&&f.dispose(),n.func(h.dispose)&&h.dispose()},listen:()=>{ue(),function(){if(Q())throw new _(b.AlreadyListening,"Connection is already listening")}(),B=E.Listening,h.listen(oe)},inspect:()=>{(0,t.default)().console.log("inspect")}};return me.onNotification(v.type,(e=>{if($===d.Off||!q)return;const t=$===d.Verbose||$===d.Compact;q.log(e.message,t?e.verbose:void 0)})),me.onNotification(l.type,(e=>{const t=I.get(e.token);t?t(e.value):K.fire(e)})),me}}(Dr)),Dr}function jr(){return wr||(wr=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ProgressType=e.ProgressToken=e.createMessageConnection=e.NullLogger=e.ConnectionOptions=e.ConnectionStrategy=e.AbstractMessageBuffer=e.WriteableStreamMessageWriter=e.AbstractMessageWriter=e.MessageWriter=e.ReadableStreamMessageReader=e.AbstractMessageReader=e.MessageReader=e.SharedArrayReceiverStrategy=e.SharedArraySenderStrategy=e.CancellationToken=e.CancellationTokenSource=e.Emitter=e.Event=e.Disposable=e.LRUCache=e.Touch=e.LinkedMap=e.ParameterStructures=e.NotificationType9=e.NotificationType8=e.NotificationType7=e.NotificationType6=e.NotificationType5=e.NotificationType4=e.NotificationType3=e.NotificationType2=e.NotificationType1=e.NotificationType0=e.NotificationType=e.ErrorCodes=e.ResponseError=e.RequestType9=e.RequestType8=e.RequestType7=e.RequestType6=e.RequestType5=e.RequestType4=e.RequestType3=e.RequestType2=e.RequestType1=e.RequestType0=e.RequestType=e.Message=e.RAL=void 0,e.MessageStrategy=e.CancellationStrategy=e.CancellationSenderStrategy=e.CancellationReceiverStrategy=e.ConnectionError=e.ConnectionErrors=e.LogTraceNotification=e.SetTraceNotification=e.TraceFormat=e.TraceValues=e.Trace=void 0;const t=rr();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return t.Message}}),Object.defineProperty(e,"RequestType",{enumerable:!0,get:function(){return t.RequestType}}),Object.defineProperty(e,"RequestType0",{enumerable:!0,get:function(){return t.RequestType0}}),Object.defineProperty(e,"RequestType1",{enumerable:!0,get:function(){return t.RequestType1}}),Object.defineProperty(e,"RequestType2",{enumerable:!0,get:function(){return t.RequestType2}}),Object.defineProperty(e,"RequestType3",{enumerable:!0,get:function(){return t.RequestType3}}),Object.defineProperty(e,"RequestType4",{enumerable:!0,get:function(){return t.RequestType4}}),Object.defineProperty(e,"RequestType5",{enumerable:!0,get:function(){return t.RequestType5}}),Object.defineProperty(e,"RequestType6",{enumerable:!0,get:function(){return t.RequestType6}}),Object.defineProperty(e,"RequestType7",{enumerable:!0,get:function(){return t.RequestType7}}),Object.defineProperty(e,"RequestType8",{enumerable:!0,get:function(){return t.RequestType8}}),Object.defineProperty(e,"RequestType9",{enumerable:!0,get:function(){return t.RequestType9}}),Object.defineProperty(e,"ResponseError",{enumerable:!0,get:function(){return t.ResponseError}}),Object.defineProperty(e,"ErrorCodes",{enumerable:!0,get:function(){return t.ErrorCodes}}),Object.defineProperty(e,"NotificationType",{enumerable:!0,get:function(){return t.NotificationType}}),Object.defineProperty(e,"NotificationType0",{enumerable:!0,get:function(){return t.NotificationType0}}),Object.defineProperty(e,"NotificationType1",{enumerable:!0,get:function(){return t.NotificationType1}}),Object.defineProperty(e,"NotificationType2",{enumerable:!0,get:function(){return t.NotificationType2}}),Object.defineProperty(e,"NotificationType3",{enumerable:!0,get:function(){return t.NotificationType3}}),Object.defineProperty(e,"NotificationType4",{enumerable:!0,get:function(){return t.NotificationType4}}),Object.defineProperty(e,"NotificationType5",{enumerable:!0,get:function(){return t.NotificationType5}}),Object.defineProperty(e,"NotificationType6",{enumerable:!0,get:function(){return t.NotificationType6}}),Object.defineProperty(e,"NotificationType7",{enumerable:!0,get:function(){return t.NotificationType7}}),Object.defineProperty(e,"NotificationType8",{enumerable:!0,get:function(){return t.NotificationType8}}),Object.defineProperty(e,"NotificationType9",{enumerable:!0,get:function(){return t.NotificationType9}}),Object.defineProperty(e,"ParameterStructures",{enumerable:!0,get:function(){return t.ParameterStructures}});const n=sr();Object.defineProperty(e,"LinkedMap",{enumerable:!0,get:function(){return n.LinkedMap}}),Object.defineProperty(e,"LRUCache",{enumerable:!0,get:function(){return n.LRUCache}}),Object.defineProperty(e,"Touch",{enumerable:!0,get:function(){return n.Touch}});const r=(ar||(ar=1,Object.defineProperty(cr,"__esModule",{value:!0}),cr.Disposable=void 0,(i||(cr.Disposable=i={})).create=function(e){return{dispose:e}}),cr);var i;Object.defineProperty(e,"Disposable",{enumerable:!0,get:function(){return r.Disposable}});const o=at();Object.defineProperty(e,"Event",{enumerable:!0,get:function(){return o.Event}}),Object.defineProperty(e,"Emitter",{enumerable:!0,get:function(){return o.Emitter}});const s=ot();Object.defineProperty(e,"CancellationTokenSource",{enumerable:!0,get:function(){return s.CancellationTokenSource}}),Object.defineProperty(e,"CancellationToken",{enumerable:!0,get:function(){return s.CancellationToken}});const a=function(){if(lr)return ur;lr=1,Object.defineProperty(ur,"__esModule",{value:!0}),ur.SharedArrayReceiverStrategy=ur.SharedArraySenderStrategy=void 0;const e=ot();var t,n;(n=t||(t={})).Continue=0,n.Cancelled=1,ur.SharedArraySenderStrategy=class{constructor(){this.buffers=new Map}enableCancellation(e){if(null===e.id)return;const n=new SharedArrayBuffer(4);new Int32Array(n,0,1)[0]=t.Continue,this.buffers.set(e.id,n),e.$cancellationData=n}async sendCancellation(e,n){const r=this.buffers.get(n);if(void 0===r)return;const i=new Int32Array(r,0,1);Atomics.store(i,0,t.Cancelled)}cleanup(e){this.buffers.delete(e)}dispose(){this.buffers.clear()}};class r{constructor(e){this.data=new Int32Array(e,0,1)}get isCancellationRequested(){return Atomics.load(this.data,0)===t.Cancelled}get onCancellationRequested(){throw new Error("Cancellation over SharedArrayBuffer doesn't support cancellation events")}}class i{constructor(e){this.token=new r(e)}cancel(){}dispose(){}}return ur.SharedArrayReceiverStrategy=class{constructor(){this.kind="request"}createCancellationTokenSource(t){const n=t.$cancellationData;return void 0===n?new e.CancellationTokenSource:new i(n)}},ur}();Object.defineProperty(e,"SharedArraySenderStrategy",{enumerable:!0,get:function(){return a.SharedArraySenderStrategy}}),Object.defineProperty(e,"SharedArrayReceiverStrategy",{enumerable:!0,get:function(){return a.SharedArrayReceiverStrategy}});const c=function(){if(hr)return fr;hr=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.ReadableStreamMessageReader=fr.AbstractMessageReader=fr.MessageReader=void 0;const e=st(),t=it(),n=at(),r=gr();var i,o;(i||(fr.MessageReader=i={})).is=function(e){let n=e;return n&&t.func(n.listen)&&t.func(n.dispose)&&t.func(n.onError)&&t.func(n.onClose)&&t.func(n.onPartialMessage)};class s{constructor(){this.errorEmitter=new n.Emitter,this.closeEmitter=new n.Emitter,this.partialMessageEmitter=new n.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError(e){this.errorEmitter.fire(this.asError(e))}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}get onPartialMessage(){return this.partialMessageEmitter.event}firePartialMessage(e){this.partialMessageEmitter.fire(e)}asError(e){return e instanceof Error?e:new Error(`Reader received error. Reason: ${t.string(e.message)?e.message:"unknown"}`)}}return fr.AbstractMessageReader=s,(o||(o={})).fromOptions=function(t){let n,r;const i=new Map;let o;const s=new Map;if(void 0===t||"string"==typeof t)n=t??"utf-8";else{if(n=t.charset??"utf-8",void 0!==t.contentDecoder&&(r=t.contentDecoder,i.set(r.name,r)),void 0!==t.contentDecoders)for(const e of t.contentDecoders)i.set(e.name,e);if(void 0!==t.contentTypeDecoder&&(o=t.contentTypeDecoder,s.set(o.name,o)),void 0!==t.contentTypeDecoders)for(const e of t.contentTypeDecoders)s.set(e.name,e)}return void 0===o&&(o=(0,e.default)().applicationJson.decoder,s.set(o.name,o)),{charset:n,contentDecoder:r,contentDecoders:i,contentTypeDecoder:o,contentTypeDecoders:s}},fr.ReadableStreamMessageReader=class extends s{constructor(t,n){super(),this.readable=t,this.options=o.fromOptions(n),this.buffer=(0,e.default)().messageBuffer.create(this.options.charset),this._partialMessageTimeout=1e4,this.nextMessageLength=-1,this.messageToken=0,this.readSemaphore=new r.Semaphore(1)}set partialMessageTimeout(e){this._partialMessageTimeout=e}get partialMessageTimeout(){return this._partialMessageTimeout}listen(e){this.nextMessageLength=-1,this.messageToken=0,this.partialMessageTimer=void 0,this.callback=e;const t=this.readable.onData((e=>{this.onData(e)}));return this.readable.onError((e=>this.fireError(e))),this.readable.onClose((()=>this.fireClose())),t}onData(e){try{for(this.buffer.append(e);;){if(-1===this.nextMessageLength){const e=this.buffer.tryReadHeaders(!0);if(!e)return;const t=e.get("content-length");if(!t)return void this.fireError(new Error(`Header must provide a Content-Length property.\n${JSON.stringify(Object.fromEntries(e))}`));const n=parseInt(t);if(isNaN(n))return void this.fireError(new Error(`Content-Length value must be a number. Got ${t}`));this.nextMessageLength=n}const e=this.buffer.tryReadBody(this.nextMessageLength);if(void 0===e)return void this.setPartialMessageTimer();this.clearPartialMessageTimer(),this.nextMessageLength=-1,this.readSemaphore.lock((async()=>{const t=void 0!==this.options.contentDecoder?await this.options.contentDecoder.decode(e):e,n=await this.options.contentTypeDecoder.decode(t,this.options);this.callback(n)})).catch((e=>{this.fireError(e)}))}}catch(t){this.fireError(t)}}clearPartialMessageTimer(){this.partialMessageTimer&&(this.partialMessageTimer.dispose(),this.partialMessageTimer=void 0)}setPartialMessageTimer(){this.clearPartialMessageTimer(),this._partialMessageTimeout<=0||(this.partialMessageTimer=(0,e.default)().timer.setTimeout(((e,t)=>{this.partialMessageTimer=void 0,e===this.messageToken&&(this.firePartialMessage({messageToken:e,waitingTime:t}),this.setPartialMessageTimer())}),this._partialMessageTimeout,this.messageToken,this._partialMessageTimeout))}},fr}();Object.defineProperty(e,"MessageReader",{enumerable:!0,get:function(){return c.MessageReader}}),Object.defineProperty(e,"AbstractMessageReader",{enumerable:!0,get:function(){return c.AbstractMessageReader}}),Object.defineProperty(e,"ReadableStreamMessageReader",{enumerable:!0,get:function(){return c.ReadableStreamMessageReader}});const l=function(){if(mr)return yr;mr=1,Object.defineProperty(yr,"__esModule",{value:!0}),yr.WriteableStreamMessageWriter=yr.AbstractMessageWriter=yr.MessageWriter=void 0;const e=st(),t=it(),n=gr(),r=at();var i,o;(i||(yr.MessageWriter=i={})).is=function(e){let n=e;return n&&t.func(n.dispose)&&t.func(n.onClose)&&t.func(n.onError)&&t.func(n.write)};class s{constructor(){this.errorEmitter=new r.Emitter,this.closeEmitter=new r.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError(e,t,n){this.errorEmitter.fire([this.asError(e),t,n])}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}asError(e){return e instanceof Error?e:new Error(`Writer received error. Reason: ${t.string(e.message)?e.message:"unknown"}`)}}return yr.AbstractMessageWriter=s,(o||(o={})).fromOptions=function(t){return void 0===t||"string"==typeof t?{charset:t??"utf-8",contentTypeEncoder:(0,e.default)().applicationJson.encoder}:{charset:t.charset??"utf-8",contentEncoder:t.contentEncoder,contentTypeEncoder:t.contentTypeEncoder??(0,e.default)().applicationJson.encoder}},yr.WriteableStreamMessageWriter=class extends s{constructor(e,t){super(),this.writable=e,this.options=o.fromOptions(t),this.errorCount=0,this.writeSemaphore=new n.Semaphore(1),this.writable.onError((e=>this.fireError(e))),this.writable.onClose((()=>this.fireClose()))}async write(e){return this.writeSemaphore.lock((async()=>this.options.contentTypeEncoder.encode(e,this.options).then((e=>void 0!==this.options.contentEncoder?this.options.contentEncoder.encode(e):e)).then((t=>{const n=[];return n.push("Content-Length: ",t.byteLength.toString(),"\r\n"),n.push("\r\n"),this.doWrite(e,n,t)}),(e=>{throw this.fireError(e),e}))))}async doWrite(e,t,n){try{return await this.writable.write(t.join(""),"ascii"),this.writable.write(n)}catch(r){return this.handleError(r,e),Promise.reject(r)}}handleError(e,t){this.errorCount++,this.fireError(e,t,this.errorCount)}end(){this.writable.end()}},yr}();Object.defineProperty(e,"MessageWriter",{enumerable:!0,get:function(){return l.MessageWriter}}),Object.defineProperty(e,"AbstractMessageWriter",{enumerable:!0,get:function(){return l.AbstractMessageWriter}}),Object.defineProperty(e,"WriteableStreamMessageWriter",{enumerable:!0,get:function(){return l.WriteableStreamMessageWriter}});const u=(vr||(vr=1,Object.defineProperty(br,"__esModule",{value:!0}),br.AbstractMessageBuffer=void 0,br.AbstractMessageBuffer=class{constructor(e="utf-8"){this._encoding=e,this._chunks=[],this._totalLength=0}get encoding(){return this._encoding}append(e){const t="string"==typeof e?this.fromString(e,this._encoding):e;this._chunks.push(t),this._totalLength+=t.byteLength}tryReadHeaders(e=!1){if(0===this._chunks.length)return;let t=0,n=0,r=0,i=0;e:for(;nthis._totalLength)throw new Error("Cannot read so many bytes!");if(this._chunks[0].byteLength===e){const t=this._chunks[0];return this._chunks.shift(),this._totalLength-=e,this.asNative(t)}if(this._chunks[0].byteLength>e){const t=this._chunks[0],n=this.asNative(t,e);return this._chunks[0]=t.slice(e),this._totalLength-=e,n}const t=this.allocNative(e);let n=0;for(;e>0;){const r=this._chunks[0];if(r.byteLength>e){const i=r.slice(0,e);t.set(i,n),n+=e,this._chunks[0]=r.slice(e),this._totalLength-=e,e-=e}else t.set(r,n),n+=r.byteLength,this._chunks.shift(),this._totalLength-=r.byteLength,e-=r.byteLength}return t}}),br);Object.defineProperty(e,"AbstractMessageBuffer",{enumerable:!0,get:function(){return u.AbstractMessageBuffer}});const d=Cr();Object.defineProperty(e,"ConnectionStrategy",{enumerable:!0,get:function(){return d.ConnectionStrategy}}),Object.defineProperty(e,"ConnectionOptions",{enumerable:!0,get:function(){return d.ConnectionOptions}}),Object.defineProperty(e,"NullLogger",{enumerable:!0,get:function(){return d.NullLogger}}),Object.defineProperty(e,"createMessageConnection",{enumerable:!0,get:function(){return d.createMessageConnection}}),Object.defineProperty(e,"ProgressToken",{enumerable:!0,get:function(){return d.ProgressToken}}),Object.defineProperty(e,"ProgressType",{enumerable:!0,get:function(){return d.ProgressType}}),Object.defineProperty(e,"Trace",{enumerable:!0,get:function(){return d.Trace}}),Object.defineProperty(e,"TraceValues",{enumerable:!0,get:function(){return d.TraceValues}}),Object.defineProperty(e,"TraceFormat",{enumerable:!0,get:function(){return d.TraceFormat}}),Object.defineProperty(e,"SetTraceNotification",{enumerable:!0,get:function(){return d.SetTraceNotification}}),Object.defineProperty(e,"LogTraceNotification",{enumerable:!0,get:function(){return d.LogTraceNotification}}),Object.defineProperty(e,"ConnectionErrors",{enumerable:!0,get:function(){return d.ConnectionErrors}}),Object.defineProperty(e,"ConnectionError",{enumerable:!0,get:function(){return d.ConnectionError}}),Object.defineProperty(e,"CancellationReceiverStrategy",{enumerable:!0,get:function(){return d.CancellationReceiverStrategy}}),Object.defineProperty(e,"CancellationSenderStrategy",{enumerable:!0,get:function(){return d.CancellationSenderStrategy}}),Object.defineProperty(e,"CancellationStrategy",{enumerable:!0,get:function(){return d.CancellationStrategy}}),Object.defineProperty(e,"MessageStrategy",{enumerable:!0,get:function(){return d.MessageStrategy}});const h=st();e.RAL=h.default}(tr)),tr}function Or(){return Tr||(Tr=1,function(e){var t=Qn&&Qn.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=Qn&&Qn.__exportStar||function(e,n){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.createMessageConnection=e.BrowserMessageWriter=e.BrowserMessageReader=void 0;const r=function(){if(kr)return er;kr=1,Object.defineProperty(er,"__esModule",{value:!0});const e=jr();class t extends e.AbstractMessageBuffer{constructor(e="utf-8"){super(e),this.asciiDecoder=new TextDecoder("ascii")}emptyBuffer(){return t.emptyBuffer}fromString(e,t){return(new TextEncoder).encode(e)}toString(e,t){return"ascii"===t?this.asciiDecoder.decode(e):new TextDecoder(t).decode(e)}asNative(e,t){return void 0===t?e:e.slice(0,t)}allocNative(e){return new Uint8Array(e)}}t.emptyBuffer=new Uint8Array(0);class n{constructor(t){this.socket=t,this._onData=new e.Emitter,this._messageListener=t=>{t.data.arrayBuffer().then((e=>{this._onData.fire(new Uint8Array(e))}),(()=>{(0,e.RAL)().console.error("Converting blob to array buffer failed.")}))},this.socket.addEventListener("message",this._messageListener)}onClose(t){return this.socket.addEventListener("close",t),e.Disposable.create((()=>this.socket.removeEventListener("close",t)))}onError(t){return this.socket.addEventListener("error",t),e.Disposable.create((()=>this.socket.removeEventListener("error",t)))}onEnd(t){return this.socket.addEventListener("end",t),e.Disposable.create((()=>this.socket.removeEventListener("end",t)))}onData(e){return this._onData.event(e)}}class r{constructor(e){this.socket=e}onClose(t){return this.socket.addEventListener("close",t),e.Disposable.create((()=>this.socket.removeEventListener("close",t)))}onError(t){return this.socket.addEventListener("error",t),e.Disposable.create((()=>this.socket.removeEventListener("error",t)))}onEnd(t){return this.socket.addEventListener("end",t),e.Disposable.create((()=>this.socket.removeEventListener("end",t)))}write(e,t){if("string"==typeof e){if(void 0!==t&&"utf-8"!==t)throw new Error(`In a Browser environments only utf-8 text encoding is supported. But got encoding: ${t}`);this.socket.send(e)}else this.socket.send(e);return Promise.resolve()}end(){this.socket.close()}}const i=new TextEncoder,o=Object.freeze({messageBuffer:Object.freeze({create:e=>new t(e)}),applicationJson:Object.freeze({encoder:Object.freeze({name:"application/json",encode:(e,t)=>{if("utf-8"!==t.charset)throw new Error(`In a Browser environments only utf-8 text encoding is supported. But got encoding: ${t.charset}`);return Promise.resolve(i.encode(JSON.stringify(e,void 0,0)))}}),decoder:Object.freeze({name:"application/json",decode:(e,t)=>{if(!(e instanceof Uint8Array))throw new Error("In a Browser environments only Uint8Arrays are supported.");return Promise.resolve(JSON.parse(new TextDecoder(t.charset).decode(e)))}})}),stream:Object.freeze({asReadableStream:e=>new n(e),asWritableStream:e=>new r(e)}),console:console,timer:Object.freeze({setTimeout(e,t,...n){const r=setTimeout(e,t,...n);return{dispose:()=>clearTimeout(r)}},setImmediate(e,...t){const n=setTimeout(e,0,...t);return{dispose:()=>clearTimeout(n)}},setInterval(e,t,...n){const r=setInterval(e,t,...n);return{dispose:()=>clearInterval(r)}}})});function s(){return o}return(s||(s={})).install=function(){e.RAL.install(o)},er.default=s,er}();r.default.install();const i=jr();n(jr(),e);class o extends i.AbstractMessageReader{constructor(e){super(),this._onData=new i.Emitter,this._messageListener=e=>{this._onData.fire(e.data)},e.addEventListener("error",(e=>this.fireError(e))),e.onmessage=this._messageListener}listen(e){return this._onData.event(e)}}e.BrowserMessageReader=o;class s extends i.AbstractMessageWriter{constructor(e){super(),this.port=e,this.errorCount=0,e.addEventListener("error",(e=>this.fireError(e)))}write(e){try{return this.port.postMessage(e),Promise.resolve()}catch(t){return this.handleError(t,e),Promise.reject(t)}}handleError(e,t){this.errorCount++,this.fireError(e,t,this.errorCount)}end(){}}e.BrowserMessageWriter=s,e.createMessageConnection=function(e,t,n,r){return void 0===n&&(n=i.NullLogger),i.ConnectionStrategy.is(r)&&(r={connectionStrategy:r}),(0,i.createMessageConnection)(e,t,n,r)}}(Qn)),Qn}function Pr(){return Rr?Sr:(Rr=1,Sr=Or())}var Nr={};const Er=R(ct);var Ir,_r={};function Mr(){if(Ir)return _r;Ir=1,Object.defineProperty(_r,"__esModule",{value:!0}),_r.ProtocolNotificationType=_r.ProtocolNotificationType0=_r.ProtocolRequestType=_r.ProtocolRequestType0=_r.RegistrationType=_r.MessageDirection=void 0;const e=Or();var t,n;(n=t||(_r.MessageDirection=t={})).clientToServer="clientToServer",n.serverToClient="serverToClient",n.both="both";_r.RegistrationType=class{constructor(e){this.method=e}};class r extends e.RequestType0{constructor(e){super(e)}}_r.ProtocolRequestType0=r;class i extends e.RequestType{constructor(t){super(t,e.ParameterStructures.byName)}}_r.ProtocolRequestType=i;class o extends e.NotificationType0{constructor(e){super(e)}}_r.ProtocolNotificationType0=o;class s extends e.NotificationType{constructor(t){super(t,e.ParameterStructures.byName)}}return _r.ProtocolNotificationType=s,_r}var qr,Ar={},Lr={};function Fr(){if(qr)return Lr;function e(e){return"string"==typeof e||e instanceof String}function t(e){return Array.isArray(e)}return qr=1,Object.defineProperty(Lr,"__esModule",{value:!0}),Lr.objectLiteral=Lr.typedArray=Lr.stringArray=Lr.array=Lr.func=Lr.error=Lr.number=Lr.string=Lr.boolean=void 0,Lr.boolean=function(e){return!0===e||!1===e},Lr.string=e,Lr.number=function(e){return"number"==typeof e||e instanceof Number},Lr.error=function(e){return e instanceof Error},Lr.func=function(e){return"function"==typeof e},Lr.array=t,Lr.stringArray=function(n){return t(n)&&n.every((t=>e(t)))},Lr.typedArray=function(e,t){return Array.isArray(e)&&e.every(t)},Lr.objectLiteral=function(e){return null!==e&&"object"==typeof e},Lr}var Hr,$r={};var zr,Br={};var Ur,Wr={};var Vr,Kr={};var Gr,Jr={};var Yr,Zr={};var Xr,Qr={};var ei,ti={};var ni,ri={};var ii,oi={};var si,ai={};var ci,li={};var ui,di={};var hi,fi={};var pi,gi={};var mi,yi={};var vi,bi={};var xi,wi={};var ki,Ti={};var Si,Ri={};function Di(){if(Si)return Ri;Si=1,Object.defineProperty(Ri,"__esModule",{value:!0}),Ri.DidCloseNotebookDocumentNotification=Ri.DidSaveNotebookDocumentNotification=Ri.DidChangeNotebookDocumentNotification=Ri.NotebookCellArrayChange=Ri.DidOpenNotebookDocumentNotification=Ri.NotebookDocumentSyncRegistrationType=Ri.NotebookDocument=Ri.NotebookCell=Ri.ExecutionSummary=Ri.NotebookCellKind=void 0;const e=Er,t=Fr(),n=Mr();var r,i,o,s,a,c,l,u,d,h,f,p,g,m,y,v,b,x,w;return(i=r||(Ri.NotebookCellKind=r={})).Markup=1,i.Code=2,i.is=function(e){return 1===e||2===e},(s=o||(Ri.ExecutionSummary=o={})).create=function(e,t){const n={executionOrder:e};return!0!==t&&!1!==t||(n.success=t),n},s.is=function(n){const r=n;return t.objectLiteral(r)&&e.uinteger.is(r.executionOrder)&&(void 0===r.success||t.boolean(r.success))},s.equals=function(e,t){return e===t||null!=e&&null!=t&&e.executionOrder===t.executionOrder&&e.success===t.success},function(n){function i(e,n){if(e===n)return!0;if(null==e||null==n)return!1;if(typeof e!=typeof n)return!1;if("object"!=typeof e)return!1;const r=Array.isArray(e),o=Array.isArray(n);if(r!==o)return!1;if(r&&o){if(e.length!==n.length)return!1;for(let t=0;t0},(H||(e.TextDocumentRegistrationOptions=H={})).is=function(e){const t=e;return t&&(null===t.documentSelector||j.is(t.documentSelector))},(z=$||(e.WorkDoneProgressOptions=$={})).is=function(e){const t=e;return r.objectLiteral(t)&&(void 0===t.workDoneProgress||r.boolean(t.workDoneProgress))},z.hasWorkDoneProgress=function(e){const t=e;return t&&r.boolean(t.workDoneProgress)},(U=B||(e.InitializeRequest=B={})).method="initialize",U.messageDirection=t.MessageDirection.clientToServer,U.type=new t.ProtocolRequestType(U.method),(W||(e.InitializeErrorCodes=W={})).unknownProtocolVersion=1,(K=V||(e.InitializedNotification=V={})).method="initialized",K.messageDirection=t.MessageDirection.clientToServer,K.type=new t.ProtocolNotificationType(K.method),(J=G||(e.ShutdownRequest=G={})).method="shutdown",J.messageDirection=t.MessageDirection.clientToServer,J.type=new t.ProtocolRequestType0(J.method),(Z=Y||(e.ExitNotification=Y={})).method="exit",Z.messageDirection=t.MessageDirection.clientToServer,Z.type=new t.ProtocolNotificationType0(Z.method),(Q=X||(e.DidChangeConfigurationNotification=X={})).method="workspace/didChangeConfiguration",Q.messageDirection=t.MessageDirection.clientToServer,Q.type=new t.ProtocolNotificationType(Q.method),(te=ee||(e.MessageType=ee={})).Error=1,te.Warning=2,te.Info=3,te.Log=4,te.Debug=5,(re=ne||(e.ShowMessageNotification=ne={})).method="window/showMessage",re.messageDirection=t.MessageDirection.serverToClient,re.type=new t.ProtocolNotificationType(re.method),(oe=ie||(e.ShowMessageRequest=ie={})).method="window/showMessageRequest",oe.messageDirection=t.MessageDirection.serverToClient,oe.type=new t.ProtocolRequestType(oe.method),(ae=se||(e.LogMessageNotification=se={})).method="window/logMessage",ae.messageDirection=t.MessageDirection.serverToClient,ae.type=new t.ProtocolNotificationType(ae.method),(le=ce||(e.TelemetryEventNotification=ce={})).method="telemetry/event",le.messageDirection=t.MessageDirection.serverToClient,le.type=new t.ProtocolNotificationType(le.method),(de=ue||(e.TextDocumentSyncKind=ue={})).None=0,de.Full=1,de.Incremental=2,(fe=he||(e.DidOpenTextDocumentNotification=he={})).method="textDocument/didOpen",fe.messageDirection=t.MessageDirection.clientToServer,fe.type=new t.ProtocolNotificationType(fe.method),(ge=pe||(e.TextDocumentContentChangeEvent=pe={})).isIncremental=function(e){let t=e;return null!=t&&"string"==typeof t.text&&void 0!==t.range&&(void 0===t.rangeLength||"number"==typeof t.rangeLength)},ge.isFull=function(e){let t=e;return null!=t&&"string"==typeof t.text&&void 0===t.range&&void 0===t.rangeLength},(ye=me||(e.DidChangeTextDocumentNotification=me={})).method="textDocument/didChange",ye.messageDirection=t.MessageDirection.clientToServer,ye.type=new t.ProtocolNotificationType(ye.method),(be=ve||(e.DidCloseTextDocumentNotification=ve={})).method="textDocument/didClose",be.messageDirection=t.MessageDirection.clientToServer,be.type=new t.ProtocolNotificationType(be.method),(we=xe||(e.DidSaveTextDocumentNotification=xe={})).method="textDocument/didSave",we.messageDirection=t.MessageDirection.clientToServer,we.type=new t.ProtocolNotificationType(we.method),(Te=ke||(e.TextDocumentSaveReason=ke={})).Manual=1,Te.AfterDelay=2,Te.FocusOut=3,(Re=Se||(e.WillSaveTextDocumentNotification=Se={})).method="textDocument/willSave",Re.messageDirection=t.MessageDirection.clientToServer,Re.type=new t.ProtocolNotificationType(Re.method),(Ce=De||(e.WillSaveTextDocumentWaitUntilRequest=De={})).method="textDocument/willSaveWaitUntil",Ce.messageDirection=t.MessageDirection.clientToServer,Ce.type=new t.ProtocolRequestType(Ce.method),(Oe=je||(e.DidChangeWatchedFilesNotification=je={})).method="workspace/didChangeWatchedFiles",Oe.messageDirection=t.MessageDirection.clientToServer,Oe.type=new t.ProtocolNotificationType(Oe.method),(Ne=Pe||(e.FileChangeType=Pe={})).Created=1,Ne.Changed=2,Ne.Deleted=3,(Ee||(e.RelativePattern=Ee={})).is=function(e){const t=e;return r.objectLiteral(t)&&(n.URI.is(t.baseUri)||n.WorkspaceFolder.is(t.baseUri))&&r.string(t.pattern)},(_e=Ie||(e.WatchKind=Ie={})).Create=1,_e.Change=2,_e.Delete=4,(qe=Me||(e.PublishDiagnosticsNotification=Me={})).method="textDocument/publishDiagnostics",qe.messageDirection=t.MessageDirection.serverToClient,qe.type=new t.ProtocolNotificationType(qe.method),(Le=Ae||(e.CompletionTriggerKind=Ae={})).Invoked=1,Le.TriggerCharacter=2,Le.TriggerForIncompleteCompletions=3,(He=Fe||(e.CompletionRequest=Fe={})).method="textDocument/completion",He.messageDirection=t.MessageDirection.clientToServer,He.type=new t.ProtocolRequestType(He.method),(ze=$e||(e.CompletionResolveRequest=$e={})).method="completionItem/resolve",ze.messageDirection=t.MessageDirection.clientToServer,ze.type=new t.ProtocolRequestType(ze.method),(Ue=Be||(e.HoverRequest=Be={})).method="textDocument/hover",Ue.messageDirection=t.MessageDirection.clientToServer,Ue.type=new t.ProtocolRequestType(Ue.method),(Ve=We||(e.SignatureHelpTriggerKind=We={})).Invoked=1,Ve.TriggerCharacter=2,Ve.ContentChange=3,(Ge=Ke||(e.SignatureHelpRequest=Ke={})).method="textDocument/signatureHelp",Ge.messageDirection=t.MessageDirection.clientToServer,Ge.type=new t.ProtocolRequestType(Ge.method),(Ye=Je||(e.DefinitionRequest=Je={})).method="textDocument/definition",Ye.messageDirection=t.MessageDirection.clientToServer,Ye.type=new t.ProtocolRequestType(Ye.method),(Xe=Ze||(e.ReferencesRequest=Ze={})).method="textDocument/references",Xe.messageDirection=t.MessageDirection.clientToServer,Xe.type=new t.ProtocolRequestType(Xe.method),(et=Qe||(e.DocumentHighlightRequest=Qe={})).method="textDocument/documentHighlight",et.messageDirection=t.MessageDirection.clientToServer,et.type=new t.ProtocolRequestType(et.method),(nt=tt||(e.DocumentSymbolRequest=tt={})).method="textDocument/documentSymbol",nt.messageDirection=t.MessageDirection.clientToServer,nt.type=new t.ProtocolRequestType(nt.method),(it=rt||(e.CodeActionRequest=rt={})).method="textDocument/codeAction",it.messageDirection=t.MessageDirection.clientToServer,it.type=new t.ProtocolRequestType(it.method),(st=ot||(e.CodeActionResolveRequest=ot={})).method="codeAction/resolve",st.messageDirection=t.MessageDirection.clientToServer,st.type=new t.ProtocolRequestType(st.method),(ct=at||(e.WorkspaceSymbolRequest=at={})).method="workspace/symbol",ct.messageDirection=t.MessageDirection.clientToServer,ct.type=new t.ProtocolRequestType(ct.method),(ut=lt||(e.WorkspaceSymbolResolveRequest=lt={})).method="workspaceSymbol/resolve",ut.messageDirection=t.MessageDirection.clientToServer,ut.type=new t.ProtocolRequestType(ut.method),(ht=dt||(e.CodeLensRequest=dt={})).method="textDocument/codeLens",ht.messageDirection=t.MessageDirection.clientToServer,ht.type=new t.ProtocolRequestType(ht.method),(pt=ft||(e.CodeLensResolveRequest=ft={})).method="codeLens/resolve",pt.messageDirection=t.MessageDirection.clientToServer,pt.type=new t.ProtocolRequestType(pt.method),(mt=gt||(e.CodeLensRefreshRequest=gt={})).method="workspace/codeLens/refresh",mt.messageDirection=t.MessageDirection.serverToClient,mt.type=new t.ProtocolRequestType0(mt.method),(vt=yt||(e.DocumentLinkRequest=yt={})).method="textDocument/documentLink",vt.messageDirection=t.MessageDirection.clientToServer,vt.type=new t.ProtocolRequestType(vt.method),(xt=bt||(e.DocumentLinkResolveRequest=bt={})).method="documentLink/resolve",xt.messageDirection=t.MessageDirection.clientToServer,xt.type=new t.ProtocolRequestType(xt.method),(kt=wt||(e.DocumentFormattingRequest=wt={})).method="textDocument/formatting",kt.messageDirection=t.MessageDirection.clientToServer,kt.type=new t.ProtocolRequestType(kt.method),(St=Tt||(e.DocumentRangeFormattingRequest=Tt={})).method="textDocument/rangeFormatting",St.messageDirection=t.MessageDirection.clientToServer,St.type=new t.ProtocolRequestType(St.method),(Dt=Rt||(e.DocumentRangesFormattingRequest=Rt={})).method="textDocument/rangesFormatting",Dt.messageDirection=t.MessageDirection.clientToServer,Dt.type=new t.ProtocolRequestType(Dt.method),(jt=Ct||(e.DocumentOnTypeFormattingRequest=Ct={})).method="textDocument/onTypeFormatting",jt.messageDirection=t.MessageDirection.clientToServer,jt.type=new t.ProtocolRequestType(jt.method),(Ot||(e.PrepareSupportDefaultBehavior=Ot={})).Identifier=1,(Nt=Pt||(e.RenameRequest=Pt={})).method="textDocument/rename",Nt.messageDirection=t.MessageDirection.clientToServer,Nt.type=new t.ProtocolRequestType(Nt.method),(It=Et||(e.PrepareRenameRequest=Et={})).method="textDocument/prepareRename",It.messageDirection=t.MessageDirection.clientToServer,It.type=new t.ProtocolRequestType(It.method),(Mt=_t||(e.ExecuteCommandRequest=_t={})).method="workspace/executeCommand",Mt.messageDirection=t.MessageDirection.clientToServer,Mt.type=new t.ProtocolRequestType(Mt.method),(At=qt||(e.ApplyWorkspaceEditRequest=qt={})).method="workspace/applyEdit",At.messageDirection=t.MessageDirection.serverToClient,At.type=new t.ProtocolRequestType("workspace/applyEdit")}(Ar)),Ar}var Ni,Ei,Ii,_i={};function Mi(){return Ei||(Ei=1,function(e){var t=Nr&&Nr.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=Nr&&Nr.__exportStar||function(e,n){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.LSPErrorCodes=e.createProtocolConnection=void 0,n(Or(),e),n(Er,e),n(Mr(),e),n(Pi(),e);var r,i,o=function(){if(Ni)return _i;Ni=1,Object.defineProperty(_i,"__esModule",{value:!0}),_i.createProtocolConnection=void 0;const e=Or();return _i.createProtocolConnection=function(t,n,r,i){return e.ConnectionStrategy.is(i)&&(i={connectionStrategy:i}),(0,e.createMessageConnection)(t,n,r,i)},_i}();Object.defineProperty(e,"createProtocolConnection",{enumerable:!0,get:function(){return o.createProtocolConnection}}),(i=r||(e.LSPErrorCodes=r={})).lspReservedErrorRangeStart=-32899,i.RequestFailed=-32803,i.ServerCancelled=-32802,i.ContentModified=-32801,i.RequestCancelled=-32800,i.lspReservedErrorRangeEnd=-32800}(Nr)),Nr}var qi=(Ii||(Ii=1,function(e){var t=Xn&&Xn.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),n=Xn&&Xn.__exportStar||function(e,n){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(n,r)||t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.createProtocolConnection=void 0;const r=Pr();n(Pr(),e),n(Mi(),e),e.createProtocolConnection=function(e,t,n,i){return(0,r.createMessageConnection)(e,t,n,i)}}(Xn)),Xn);function Ai(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Li={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Fi(e){Li=e}const Hi={exec:()=>null};function $i(e,t=""){let n="string"==typeof e?e:e.source;const r={replace:(e,t)=>{let i="string"==typeof t?t:t.source;return i=i.replace(zi.caret,"$1"),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}const zi={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},Bi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ui=/(?:[*+-]|\d{1,9}[.)])/,Wi=$i(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,Ui).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Vi=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ki=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Gi=$i(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ki).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ji=$i(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ui).getRegex(),Yi="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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Zi=/|$))/,Xi=$i("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Zi).replace("tag",Yi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Qi=$i(Vi).replace("hr",Bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Yi).getRegex(),eo={blockquote:$i(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Qi).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:Gi,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:Bi,html:Xi,lheading:Wi,list:Ji,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Qi,table:Hi,text:/^[^\n]+/},to=$i("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Yi).getRegex(),no={...eo,table:to,paragraph:$i(Vi).replace("hr",Bi).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",to).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Yi).getRegex()},ro={...eo,html:$i("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Zi).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Hi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:$i(Vi).replace("hr",Bi).replace("heading"," *#{1,6} *[^\n]").replace("lheading",Wi).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},io=/^( {2,}|\\)\n(?!\s*$)/,oo=/[\p{P}\p{S}]/u,so=/[\s\p{P}\p{S}]/u,ao=/[^\s\p{P}\p{S}]/u,co=$i(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,so).getRegex(),lo=/(?!~)[\p{P}\p{S}]/u,uo=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ho=$i(uo,"u").replace(/punct/g,oo).getRegex(),fo=$i(uo,"u").replace(/punct/g,lo).getRegex(),po="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",go=$i(po,"gu").replace(/notPunctSpace/g,ao).replace(/punctSpace/g,so).replace(/punct/g,oo).getRegex(),mo=$i(po,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,lo).getRegex(),yo=$i("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ao).replace(/punctSpace/g,so).replace(/punct/g,oo).getRegex(),vo=$i(/\\(punct)/,"gu").replace(/punct/g,oo).getRegex(),bo=$i(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),xo=$i(Zi).replace("(?:--\x3e|$)","--\x3e").getRegex(),wo=$i("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment",xo).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ko=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,To=$i(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",ko).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),So=$i(/^!?\[(label)\]\[(ref)\]/).replace("label",ko).replace("ref",Ki).getRegex(),Ro=$i(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ki).getRegex(),Do={_backpedal:Hi,anyPunctuation:vo,autolink:bo,blockSkip:/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,br:io,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:Hi,emStrongLDelim:ho,emStrongRDelimAst:go,emStrongRDelimUnd:yo,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:To,nolink:Ro,punctuation:co,reflink:So,reflinkSearch:$i("reflink|nolink(?!\\()","g").replace("reflink",So).replace("nolink",Ro).getRegex(),tag:wo,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\":">",'"':""","'":"'"},Io=e=>Eo[e];function _o(e,t){if(t){if(zi.escapeTest.test(e))return e.replace(zi.escapeReplace,Io)}else if(zi.escapeTestNoEncode.test(e))return e.replace(zi.escapeReplaceNoEncode,Io);return e}function Mo(e){try{e=encodeURI(e).replace(zi.percentDecode,"%")}catch{return null}return e}function qo(e,t){var n;const r=e.replace(zi.findPipe,((e,t,n)=>{let r=!1,i=t;for(;--i>=0&&"\\"===n[i];)r=!r;return r?"|":" |"})).split(zi.splitPipe);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!(null==(n=r.at(-1))?void 0:n.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Ao(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t,n){const r=e.match(n.other.indentCodeCompensation);if(null===r)return t;const i=r[1];return t.split("\n").map((e=>{const t=e.match(n.other.beginningSpace);if(null===t)return e;const[r]=t;return r.length>=i.length?e.slice(i.length):e})).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){const t=Ao(e,"#");this.options.pedantic?e=t.trim():t&&!this.rules.other.endingSpaceChar.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Ao(t[0],"\n")}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let e=Ao(t[0],"\n").split("\n"),n="",r="";const i=[];for(;e.length>0;){let t=!1;const o=[];let s;for(s=0;s1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const o=this.rules.other.listItemRegex(n);let s=!1;for(;e;){let n=!1,r="",a="";if(!(t=o.exec(e)))break;if(this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,(e=>" ".repeat(3*e.length))),l=e.split("\n",1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,a=c.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,a=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+"\n",e=e.substring(l.length+1),n=!0),!n){const t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),o=this.rules.other.headingBeginRegex(d),s=this.rules.other.htmlBeginRegex(d);for(;e;){const h=e.split("\n",1)[0];let f;if(l=h,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting," "),f=l):f=l.replace(this.rules.other.tabCharGlobal," "),i.test(l))break;if(o.test(l))break;if(s.test(l))break;if(t.test(l))break;if(n.test(l))break;if(f.search(this.rules.other.nonSpaceChar)>=d||!l.trim())a+="\n"+f.slice(d);else{if(u)break;if(c.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4)break;if(i.test(c))break;if(o.test(c))break;if(n.test(c))break;a+="\n"+l}u||l.trim()||(u=!0),r+=h+"\n",e=e.substring(h.length+1),c=f.slice(d)}}i.loose||(s?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(s=!0));let h,f=null;this.options.gfm&&(f=this.rules.other.listIsTask.exec(a),f&&(h="[ ] "!==f[0],a=a.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:r,task:!!f,checked:h,loose:!1,text:a,tokens:[]}),i.raw+=r}const a=i.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),i.raw=i.raw.trimEnd();for(let e=0;e"space"===e.type)),n=t.length>0&&t.some((e=>this.rules.other.anyLine.test(e.raw)));i.loose=n}if(i.loose)for(let e=0;e({text:e,tokens:this.lexer.inline(e),header:!1,align:s.align[t]}))));return s}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;const t=Ao(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){const e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Lo(t,{href:n?n.replace(this.rules.inline.anyPunctuation,"$1"):n,title:r?r.replace(this.rules.inline.anyPunctuation,"$1"):r},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return Lo(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r)return;if(r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const n=[...r[0]].length-1;let i,o,s=n,a=0;const c="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);null!=(r=c.exec(t));){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(o=[...i].length,r[3]||r[4]){s+=o;continue}if((r[5]||r[6])&&n%3&&!((n+o)%3)){a+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s+a);const t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+o);if(Math.min(n,o)%2){const e=c.slice(1,-1);return{type:"em",raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}const l=c.slice(2,-2);return{type:"strong",raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," ");const n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){var t;let n;if(n=this.rules.inline.url.exec(e)){let e,r;if("@"===n[2])e=n[0],r="mailto:"+e;else{let i;do{i=n[0],n[0]=(null==(t=this.rules.inline._backpedal.exec(n[0]))?void 0:t[0])??""}while(i!==n[0]);e=n[0],r="www."===n[1]?"http://"+n[0]:n[0]}return{type:"link",raw:n[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){const e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}}class Ho{constructor(e){t(this,"tokens"),t(this,"options"),t(this,"state"),t(this,"tokenizer"),t(this,"inlineQueue"),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Li,this.options.tokenizer=this.options.tokenizer||new Fo,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={other:zi,block:Po.normal,inline:No.normal};this.options.pedantic?(n.block=Po.pedantic,n.inline=No.pedantic):this.options.gfm&&(n.block=Po.gfm,this.options.breaks?n.inline=No.breaks:n.inline=No.gfm),this.tokenizer.rules=n}static get rules(){return{block:Po,inline:No}}static lex(e,t){return new Ho(t).lex(e)}static lexInline(e,t){return new Ho(t).inlineTokens(e)}lex(e){e=e.replace(zi.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let t=0;t!!(s=n.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0))))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);const n=t.at(-1);1===s.raw.length&&void 0!==n?n.raw+="\n":t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);const n=t.at(-1);"paragraph"===(null==n?void 0:n.type)||"text"===(null==n?void 0:n.type)?(n.raw+="\n"+s.raw,n.text+="\n"+s.text,this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);const n=t.at(-1);"paragraph"===(null==n?void 0:n.type)||"text"===(null==n?void 0:n.type)?(n.raw+="\n"+s.raw,n.text+="\n"+s.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let a=e;if(null==(o=this.options.extensions)?void 0:o.startBlock){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startBlock.forEach((e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))})),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(s=this.tokenizer.paragraph(a))){const r=t.at(-1);n&&"paragraph"===(null==r?void 0:r.type)?(r.raw+="\n"+s.raw,r.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s),n=a.length!==e.length,e=e.substring(s.raw.length)}else if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);const n=t.at(-1);"text"===(null==n?void 0:n.type)?(n.raw+="\n"+s.raw,n.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(s)}else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var n,r,i;let o=e,s=null;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(o));)e.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(o));)o=o.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(s=this.tokenizer.rules.inline.anyPunctuation.exec(o));)o=o.slice(0,s.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a=!1,c="";for(;e;){let s;if(a||(c=""),a=!1,null==(r=null==(n=this.options.extensions)?void 0:n.inline)?void 0:r.some((n=>!!(s=n.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0))))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);const n=t.at(-1);"text"===s.type&&"text"===(null==n?void 0:n.type)?(n.raw+=s.raw,n.text+=s.text):t.push(s);continue}if(s=this.tokenizer.emStrong(e,o,c)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.del(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),t.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),t.push(s);continue}let l=e;if(null==(i=this.options.extensions)?void 0:i.startInline){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startInline.forEach((e=>{r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))})),t<1/0&&t>=0&&(l=e.substring(0,t+1))}if(s=this.tokenizer.inlineText(l)){e=e.substring(s.raw.length),"_"!==s.raw.slice(-1)&&(c=s.raw.slice(-1)),a=!0;const n=t.at(-1);"text"===(null==n?void 0:n.type)?(n.raw+=s.raw,n.text+=s.text):t.push(s)}else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}}class $o{constructor(e){t(this,"options"),t(this,"parser"),this.options=e||Li}space(e){return""}code({text:e,lang:t,escaped:n}){var r;const i=null==(r=(t||"").match(zi.notSpaceStart))?void 0:r[0],o=e.replace(zi.endingNewline,"")+"\n";return i?'
'+(n?o:_o(o,!0))+"
\n":"
"+(n?o:_o(o,!0))+"
\n"}blockquote({tokens:e}){return`
\n${this.parser.parse(e)}
\n`}html({text:e}){return e}heading({tokens:e,depth:t}){return`${this.parser.parseInline(e)}\n`}hr(e){return"
\n"}list(e){const t=e.ordered,n=e.start;let r="";for(let o=0;o\n"+r+"\n"}listitem(e){var t;let n="";if(e.task){const r=this.checkbox({checked:!!e.checked});e.loose?"paragraph"===(null==(t=e.tokens[0])?void 0:t.type)?(e.tokens[0].text=r+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&"text"===e.tokens[0].tokens[0].type&&(e.tokens[0].tokens[0].text=r+" "+_o(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):n+=r+" "}return n+=this.parser.parse(e.tokens,!!e.loose),`
  • ${n}
  • \n`}checkbox({checked:e}){return"'}paragraph({tokens:e}){return`

    ${this.parser.parseInline(e)}

    \n`}table(e){let t="",n="";for(let i=0;i${r}`),"\n\n"+t+"\n"+r+"
    \n"}tablerow({text:e}){return`\n${e}\n`}tablecell(e){const t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`\n`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${_o(e,!0)}`}br(e){return"
    "}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){const r=this.parser.parseInline(n),i=Mo(e);if(null===i)return r;let o='
    ",o}image({href:e,title:t,text:n}){const r=Mo(e);if(null===r)return _o(n);let i=`${n}{const r=e[n].flat(1/0);i=i.concat(this.walkTokens(r,t))})):e.tokens&&(i=i.concat(this.walkTokens(e.tokens,t)))}}return i}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{const n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");const n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){const t=this.defaults.renderer||new $o(this.defaults);for(const n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;const r=n,i=e.renderer[r],o=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){const t=this.defaults.tokenizer||new Fo(this.defaults);for(const n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;const r=n,i=e.tokenizer[r],o=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){const t=this.defaults.hooks||new Uo;for(const n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;const r=n,i=e.hooks[r],o=t[r];Uo.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then((e=>o.call(t,e)));const n=i.call(t,e);return o.call(t,n)}:t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){const t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ho.lex(e,t??this.defaults)}parser(e,t){return Bo.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{const r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(!0===this.defaults.async&&!1===r.async)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(null==t)return o(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=e);const s=i.hooks?i.hooks.provideLexer():e?Ho.lex:Ho.lexInline,a=i.hooks?i.hooks.provideParser():e?Bo.parse:Bo.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then((e=>s(e,i))).then((e=>i.hooks?i.hooks.processAllTokens(e):e)).then((e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then((()=>e)):e)).then((e=>a(e,i))).then((e=>i.hooks?i.hooks.postprocess(e):e)).catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let e=s(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=a(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(c){return o(c)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){const e="

    An error occurred:

    "+_o(n.message+"",!0)+"
    ";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Vo(e,t){return Wo.parse(e,t)}Vo.options=Vo.setOptions=function(e){return Wo.setOptions(e),Vo.defaults=Wo.defaults,Fi(Vo.defaults),Vo},Vo.getDefaults=Ai,Vo.defaults=Li,Vo.use=function(...e){return Wo.use(...e),Vo.defaults=Wo.defaults,Fi(Vo.defaults),Vo},Vo.walkTokens=function(e,t){return Wo.walkTokens(e,t)},Vo.parseInline=Wo.parseInline,Vo.Parser=Bo,Vo.parser=Bo.parse,Vo.Renderer=$o,Vo.TextRenderer=zo,Vo.Lexer=Ho,Vo.lexer=Ho.lex,Vo.Tokenizer=Fo,Vo.Hooks=Uo,Vo.parse=Vo,Vo.options,Vo.setOptions,Vo.use,Vo.walkTokens,Vo.parseInline,Bo.parse,Ho.lex;const Ko=1e4,Go=Object.fromEntries(Object.entries(qi.CompletionItemKind).map((([e,t])=>[t,e]))),Jo=e=>e.reduce(((e,t)=>t),""),Yo=D.define({combine:Jo}),Zo=D.define({combine:Jo}),Xo=D.define({combine:Jo});class Qo{constructor(e){this.rootUri=e.rootUri,this.workspaceFolders=e.workspaceFolders,this.autoClose=e.autoClose,this.plugins=[],this.transport=e.transport,this.requestManager=new Zn.RequestManager([this.transport]),this.client=new Zn.Client(this.requestManager),this.client.onNotification((e=>{this.processNotification(e)}));const t=this.transport;t&&t.connection&&t.connection.addEventListener("message",(e=>{const n=JSON.parse(e.data);n.method&&n.id&&t.connection.send(JSON.stringify({jsonrpc:"2.0",id:n.id,result:null}))})),this.initializePromise=this.initialize()}async initialize(){const{capabilities:e}=await this.request("initialize",{capabilities:{textDocument:{hover:{dynamicRegistration:!0,contentFormat:["plaintext","markdown"]},moniker:{},synchronization:{dynamicRegistration:!0,willSave:!1,didSave:!1,willSaveWaitUntil:!1},completion:{dynamicRegistration:!0,completionItem:{snippetSupport:!1,commitCharactersSupport:!0,documentationFormat:["plaintext","markdown"],deprecatedSupport:!1,preselectSupport:!1},contextSupport:!1},signatureHelp:{dynamicRegistration:!0,signatureInformation:{documentationFormat:["plaintext","markdown"]}},declaration:{dynamicRegistration:!0,linkSupport:!0},definition:{dynamicRegistration:!0,linkSupport:!0},typeDefinition:{dynamicRegistration:!0,linkSupport:!0},implementation:{dynamicRegistration:!0,linkSupport:!0}},workspace:{didChangeConfiguration:{dynamicRegistration:!0}}},initializationOptions:null,processId:null,rootUri:this.rootUri,workspaceFolders:this.workspaceFolders},3e4);this.capabilities=e,this.notify("initialized",{}),this.ready=!0}close(){this.client.close()}textDocumentDidOpen(e){return this.notify("textDocument/didOpen",e)}textDocumentDidChange(e){return this.notify("textDocument/didChange",e)}async textDocumentHover(e){return await this.request("textDocument/hover",e,Ko)}async textDocumentCompletion(e){return await this.request("textDocument/completion",e,Ko)}attachPlugin(e){this.plugins.push(e)}detachPlugin(e){const t=this.plugins.indexOf(e);-1!==t&&(this.plugins.splice(t,1),this.autoClose&&this.close())}request(e,t,n){return this.client.request({method:e,params:t},n)}notify(e,t){return this.client.notify({method:e,params:t})}processNotification(e){for(const t of this.plugins)t.processNotification(e)}}class es{constructor(e,t){this.view=e,this.allowHTMLContent=t,this.client=this.view.state.facet(Yo),this.documentUri=this.view.state.facet(Zo),this.languageId=this.view.state.facet(Xo),this.documentVersion=0,this.changesTimeout=0,this.client.attachPlugin(this),this.initialize({documentText:this.view.state.doc.toString()})}update({docChanged:e}){e&&(this.changesTimeout&&clearTimeout(this.changesTimeout),this.changesTimeout=self.setTimeout((()=>{this.sendChange({documentText:this.view.state.doc.toString()})}),500))}destroy(){this.client.detachPlugin(this)}async initialize({documentText:e}){this.client.initializePromise&&await this.client.initializePromise,this.client.textDocumentDidOpen({textDocument:{uri:this.documentUri,languageId:this.languageId,text:e,version:this.documentVersion}})}async sendChange({documentText:e}){if(this.client.ready)try{await this.client.textDocumentDidChange({textDocument:{uri:this.documentUri,version:this.documentVersion++},contentChanges:[{text:e}]})}catch(t){console.error(t)}}requestDiagnostics(e){this.sendChange({documentText:e.state.doc.toString()})}async requestHoverTooltip(e,{line:t,character:n}){if(!this.client.ready||!this.client.capabilities.hoverProvider)return null;this.sendChange({documentText:e.state.doc.toString()});const r=await this.client.textDocumentHover({textDocument:{uri:this.documentUri},position:{line:t,character:n}});if(!r)return null;const{contents:i,range:o}=r;let s,a=ts(e.state.doc,{line:t,character:n});if(o&&(a=ts(e.state.doc,o.start),s=ts(e.state.doc,o.end)),null===a)return null;const c=document.createElement("div");return c.classList.add("documentation"),this.allowHTMLContent?c.innerHTML=rs(i):c.textContent=rs(i),{pos:a,end:s,create:e=>({dom:c}),above:!0}}async requestCompletion(e,{line:t,character:n},{triggerKind:r,triggerCharacter:i}){if(!this.client.ready||!this.client.capabilities.completionProvider)return null;this.sendChange({documentText:e.state.doc.toString()});const o=await this.client.textDocumentCompletion({textDocument:{uri:this.documentUri},position:{line:t,character:n},context:{triggerKind:r,triggerCharacter:i}});if(!o)return null;let s="items"in o?o.items:o;const[a,c]=function(e){var t;const n=new Set,r=new Set;for(const o of e){const[e,...i]=(null===(t=o.textEdit)||void 0===t?void 0:t.newText)||o.label;n.add(e);for(const t of i)r.add(t)}const i=is(n)+is(r)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(s),l=e.matchBefore(c);let{pos:u}=e;if(l){u=l.from;const e=l.text.toLowerCase();/^\w+$/.test(e)&&(s=s.filter((({label:t,filterText:n})=>(null!=n?n:t).toLowerCase().startsWith(e))).sort(((e,t)=>{var n,r;const i=null!==(n=e.sortText)&&void 0!==n?n:e.label,o=null!==(r=t.sortText)&&void 0!==r?r:t.label;switch(!0){case i.startsWith(l.text)&&!o.startsWith(l.text):return-1;case!i.startsWith(l.text)&&o.startsWith(l.text):return 1}return 0})))}return{from:u,options:s.map((({detail:e,label:t,kind:n,textEdit:r,documentation:i,additionalTextEdits:o})=>{const s={label:t,detail:e,apply(e,n,i,s){!function(e){return void 0!==(null==e?void 0:e.range)}(r)?e.dispatch(N(e.state,t,i,s)):e.dispatch(N(e.state,r.newText,ts(e.state.doc,r.range.start),ts(e.state.doc,r.range.end))),o&&o.sort((({range:{end:t}},{range:{end:n}})=>ts(e.state.doc,t)ts(e.state.doc,n)?-1:0)).forEach((t=>{e.dispatch(e.state.update({changes:{from:ts(e.state.doc,t.range.start),to:ts(e.state.doc,t.range.end),insert:t.newText}}))}))},type:n&&Go[n].toLowerCase()};return i&&(s.info=rs(i)),s})),filter:!1}}processNotification(e){try{if("textDocument/publishDiagnostics"===e.method)this.processDiagnostics(e.params)}catch(t){console.log(t)}}processDiagnostics(e){if(e.uri!==this.documentUri)return;const t=e.diagnostics.map((({range:e,message:t,severity:n})=>({from:ts(this.view.state.doc,e.start),to:ts(this.view.state.doc,e.end),severity:{[qi.DiagnosticSeverity.Error]:"error",[qi.DiagnosticSeverity.Warning]:"warning",[qi.DiagnosticSeverity.Information]:"info",[qi.DiagnosticSeverity.Hint]:"info"}[n],message:t}))).filter((({from:e,to:t})=>null!==e&&null!==t&&void 0!==e&&void 0!==t)).sort(((e,t)=>{switch(!0){case e.fromt.from:return 1}return 0}));this.view.dispatch(P(this.view.state,t))}}function ts(e,t){if(t.line>=e.lines)return;const n=e.line(t.line+1).from+t.character;return n>e.length?void 0:n}function ns(e,t){const n=e.lineAt(t);return{character:t-n.from,line:n.number-1}}function rs(e){if(function(e){return void 0!==e.kind}(e)){let t=e.value;return"markdown"===e.kind&&(t=Vo.parse(t)),t}return Array.isArray(e)?e.map((e=>rs(e)+"\n\n")).join(""):"string"==typeof e?e:void 0}function is(e){let t="",n=Array.from(e).join("");return/\w/.test(n)&&(t+="\\w",n=n.replace(/\w/g,"")),`[${t}${n.replace(/[^\w\s]/g,"\\$&")}]`}class os extends Qo{constructor(...e){super(...e),this.documentVersion=0,this.getCompletionInternal=async(e,t)=>await this._request("getCompletions",{doc:{...e.doc,version:t}}),this.throttledGetCompletionInternal=function(e,t,i){var o=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return n(i)&&(o="leading"in i?!!i.leading:o,s="trailing"in i?!!i.trailing:s),r(e,t,{leading:o,maxWait:t,trailing:s})}(this.getCompletionInternal,200)}async _request(e,t){try{return await this.request(e,t)}catch(n){throw E.error("CopilotLanguageServerClient#request: Error",n),n}}isDisabled(){return!At()}async textDocumentDidOpen(e){return this.isDisabled()?e:super.textDocumentDidOpen(e)}async textDocumentCompletion(e){return this.isDisabled()?[]:super.textDocumentCompletion(e)}async textDocumentDidChange(e){return this.isDisabled()?e:super.textDocumentDidChange({...e,contentChanges:[{text:I(e.contentChanges[0].text)}],textDocument:qi.VersionedTextDocumentIdentifier.create(e.textDocument.uri,++this.documentVersion)})}textDocumentHover(e){return this.isDisabled()?Promise.resolve({contents:[]}):super.textDocumentHover(e)}signOut(){return this._request("signOut",{})}async signInInitiate(){E.log("Copilot#signInInitiate: Starting sign-in flow");try{const e=await this._request("signInInitiate",{});return E.log("Copilot#signInInitiate: Sign-in flow started successfully"),e}catch(e){throw E.warn("Copilot#signInInitiate: Failed to start sign-in flow",e),e}}async signInConfirm(e){E.log("Copilot#signInConfirm: Confirming sign-in");try{const t=await this._request("signInConfirm",e);return E.log("Copilot#signInConfirm: Sign-in confirmed successfully"),t}catch(t){throw E.warn("Copilot#signInConfirm: Failed to confirm sign-in",t),t}}async signedIn(){try{const{status:e}=await this._request("checkStatus",{});return E.log("Copilot#signedIn: Status check completed",{status:e}),"SignedIn"===e||"AlreadySignedIn"===e||"OK"===e}catch(e){throw E.warn("Copilot#signedIn: Failed to check sign-in status",e),e}}acceptCompletion(e){return this._request("notifyAccepted",e)}rejectCompletions(e){return this._request("notifyRejected",e)}async getCompletion(e){if(this.isDisabled())return{completions:[]};const t=this.documentVersion;if(e.doc.version=t,0===t)return{completions:[]};var n;n=t,x.set(qt,n);const r=await this.throttledGetCompletionInternal(e,t);var i;return i=t,x.get(qt)===i&&x.set(qt,null),t!==this.documentVersion?{completions:[]}:r||{completions:[]}}}var ss=Qt();async function as(e){return new Promise(((t,n)=>{const r=new WebSocket(e);r.onopen=()=>{r.close(),t(e)},r.onerror=t=>{r.close(),n(new Error(`Failed to connect to ${e}: ${t.type}`))}}))}const cs="/marimo.py",ls="copilot",us=`file://${cs}`,ds=_((()=>new hs));class hs extends ss.Transport{constructor(){super(),this.delegate=void 0,this.WS_URL=lt("lsp/copilot"),this.delegate=void 0}async tryConnect(e=3,t=1e3){for(let r=1;r<=e;r++)try{return this.delegate||(this.delegate=new Zn.WebSocketTransport(this.WS_URL)),await this.delegate.connect(),void E.log("Copilot#connect: Connected successfully")}catch(n){if(E.warn(`Copilot#connect: Connection attempt ${r}/${e} failed`,n),r===e)throw this.delegate=void 0,M({variant:"danger",title:"GitHub Copilot Connection Error",description:"Failed to connect to GitHub Copilot. Please check settings and try again."}),n;await new Promise((e=>setTimeout(e,t)))}}async connect(){return await k(S,(e=>"github"===e.completion.copilot)),await async function(e,t=5){for(let n=0;nsetTimeout(e,1e3*(n+1))))}throw new Error(`Failed to connect to ${e}`)}(this.WS_URL,3),this.tryConnect()}close(){var e;null==(e=this.delegate)||e.close(),this.delegate=void 0}async sendData(e,t){var n;return t=Math.min(t??5e3,5e3),null==(n=this.delegate)?void 0:n.sendData(e,t)}}const fs=_((()=>new os({rootUri:us,documentUri:us,languageId:ls,workspaceFolders:null,transport:ds()})));function ps(){return function(e){let t=null;return[Yo.of(e.client||new Qo({...e,autoClose:!0})),Zo.of(e.documentUri),Xo.of(e.languageId),C.define((n=>t=new es(n,e.allowHTMLContent))),j(((e,n)=>{var r;return null!==(r=null==t?void 0:t.requestHoverTooltip(e,ns(e.state.doc,n)))&&void 0!==r?r:null})),O({override:[async e=>{var n,r,i;if(null==t)return null;const{state:o,pos:s,explicit:a}=e,c=o.doc.lineAt(s);let l,u=qi.CompletionTriggerKind.Invoked;return!a&&(null===(i=null===(r=null===(n=t.client.capabilities)||void 0===n?void 0:n.completionProvider)||void 0===r?void 0:r.triggerCharacters)||void 0===i?void 0:i.includes(c.text[s-c.from-1]))&&(u=qi.CompletionTriggerKind.TriggerCharacter,l=c.text[s-c.from-1]),u!==qi.CompletionTriggerKind.Invoked||e.matchBefore(/\w+$/)?await t.requestCompletion(e,ns(o.doc,s),{triggerCharacter:l,triggerKind:u}):null}]})]}({rootUri:us,documentUri:us,workspaceFolders:[],transport:ds(),client:fs(),languageId:ls})}const gs=w(!1);function ms(){const e=a.c(5),t=q(Ls),n=q(gs);let r;e[0]!==t||e[1]!==n?(r=e=>{t(e),n(!0)},e[0]=t,e[1]=n,e[2]=r):r=e[2];const i=r;let o;return e[3]!==i?(o={handleClick:i},e[3]=i,e[4]=o):o=e[4],o}const ys=m.memo((()=>{const[e,t]=A(_t),[n,r]=A(Mt),{handleClick:i}=ms(),[o,s]=m.useState(),[a,c]=m.useState(!1),u=async e=>{e.preventDefault(),c(!0);try{const e=fs(),{verificationUri:n,status:i,userCode:o}=await e.signInInitiate();"OK"===i||"AlreadySignedIn"===i?t(!0):(r("signingIn"),s({url:n,code:o}))}finally{c(!1)}},d=async e=>{if(e.preventDefault(),!o)return;const n=fs();try{c(!0),E.log("Copilot#tryFinishSignIn: Attempting to confirm sign-in");const{status:e}=await n.signInConfirm({userCode:o.code});"OK"===e||"AlreadySignedIn"===e?(E.log("Copilot#tryFinishSignIn: Sign-in confirmed successfully"),t(!0),r("signedIn")):(E.warn("Copilot#tryFinishSignIn: Sign-in confirmation returned unexpected status",{status:e}),r("signInFailed"))}catch(s){if(E.warn("Copilot#tryFinishSignIn: Initial sign-in confirmation failed, attempting retries"),s instanceof Error&&(s.message.includes("ECONNREFUSED")||s.message.includes("WebSocket")||s.message.includes("network")))return E.error("Copilot#tryFinishSignIn: Connection error during sign-in",s),r("connectionError"),void M({title:"GitHub Copilot Connection Error",description:"Lost connection during sign-in. Please try again.",variant:"danger",action:l.jsx(F,{onClick:u,children:"Retry"})});for(let e=0;e<3;e++)try{await new Promise((e=>setTimeout(e,1e3)));if(await n.signedIn())return E.log("Copilot#tryFinishSignIn: Successfully signed in after retry"),t(!0),void r("signedIn")}catch(a){if(E.warn("Copilot#tryFinishSignIn: Retry attempt failed",{attempt:e+1,maxRetries:3}),a instanceof Error&&(a.message.includes("ECONNREFUSED")||a.message.includes("WebSocket")||a.message.includes("network")))return r("connectionError"),void M({title:"GitHub Copilot Connection Error",description:"Lost connection during sign-in. Please check settings and try again.",variant:"danger",action:l.jsx(F,{variant:"link",onClick:()=>i("ai"),children:"Settings"})})}E.error("Copilot#tryFinishSignIn: All sign-in attempts failed"),r("signInFailed")}finally{c(!1)}},h=async e=>{e.preventDefault();const n=fs();t(!1),r("signedOut"),await n.signOut()};return(()=>{switch(n??(e?"signedIn":"connecting")){case"connecting":return l.jsx(L,{className:"font-normal flex",children:"Connecting..."});case"signedOut":return l.jsx(F,{onClick:u,size:"xs",variant:"link",children:"Sign in to GitHub Copilot"});case"signingIn":return l.jsxs("ol",{className:"ml-4 text-sm list-decimal [&>li]:mt-2",children:[l.jsx("li",{children:l.jsxs("div",{className:"flex items-center",children:["Copy this code:",l.jsx("strong",{className:"ml-2",children:null==o?void 0:o.code}),l.jsx(z,{className:"ml-2 cursor-pointer opacity-60 hover:opacity-100 h-3 w-3",onClick:async()=>{o&&(await B(o.code),M({description:"Copied to clipboard"}))}})]})}),l.jsxs("li",{children:["Enter the code at this link:",l.jsx("a",{href:null==o?void 0:o.url,target:"_blank",rel:"noreferrer",className:U({variant:"link",size:"xs"}),children:null==o?void 0:o.url})]}),l.jsxs("li",{children:["Click here when done:",l.jsxs(F,{size:"xs",onClick:d,className:"ml-1",children:[a&&l.jsx($,{className:"h-3 w-3 mr-1 animate-spin"}),"Done"]})]})]});case"signInFailed":return l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsx("div",{className:"text-destructive text-sm",children:"Sign in failed. Please try again."}),a?l.jsx($,{className:"h-3 w-3 mr-1 animate-spin"}):l.jsx(F,{onClick:u,size:"xs",variant:"link",children:"Connect to GitHub Copilot"})]});case"signedIn":return l.jsxs("div",{className:"flex items-center gap-5",children:[l.jsxs(L,{className:"font-normal flex items-center",children:[l.jsx("div",{className:"inline-flex items-center justify-center bg-[var(--grass-7)] rounded-full p-1 mr-2",children:l.jsx(H,{className:"h-3 w-3 text-white"})}),"Connected"]}),l.jsx(F,{onClick:h,size:"xs",variant:"text",children:"Disconnect"})]});case"connectionError":return l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsxs(L,{className:"font-normal flex",children:[l.jsx(f,{className:"h-4 w-4 mr-1"}),"Connection Error"]}),l.jsx("div",{className:"text-sm",children:"Unable to connect to GitHub Copilot."}),l.jsx(F,{onClick:u,size:"xs",variant:"link",children:"Retry Connection"})]});case"notConnected":return l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsxs(L,{className:"font-normal flex",children:[l.jsx(f,{className:"h-4 w-4 mr-1"}),"Unable to connect"]}),l.jsxs("div",{className:"text-sm",children:["For troubleshooting, see the"," ",l.jsx("a",{className:"hyperlink",href:"https://docs.marimo.io/getting_started/index.html#github-copilot",target:"_blank",rel:"noreferrer",children:"docs"}),"."]})]})}})()}));var vs;function bs(e){return xs(),[W.of([{key:"j",run:t=>!(!V(t,!0)||!K(t))&&(e.focusDown(),!0)}]),W.of([{key:"k",run:t=>!(!G(t)||!K(t))&&(e.focusUp(),!0)}]),C.define((e=>(ws.INSTANCES.addInstance(e),{destroy(){ws.INSTANCES.removeInstance(e)}})))]}ys.displayName="CopilotConfig";const xs=_((()=>{J.defineAction("goToDefinition",(e=>{const t=e.cm6;return Y(t)})),J.mapCommand("gd","action","goToDefinition",{},{context:"normal"})}));class ws{constructor(){this.instances=new Set,this.isBroadcasting=!1}addInstance(e){this.instances.add(e);const t=Z(e);t?t.on("vim-mode-change",(t=>{this.isBroadcasting||(X("mode"in t,'Expected event to have a "mode" property'),this.isBroadcasting=!0,this.broadcastModeChange(e,t.mode,t.subMode),this.isBroadcasting=!1)})):E.warn("Expected CodeMirror instance to have CodeMirror instance state")}removeInstance(e){this.instances.delete(e)}broadcastModeChange(e,t,n){X("exitInsertMode"in J,"Vim does not have an exitInsertMode method"),X("exitVisualMode"in J,"Vim does not have an exitVisualMode method");for(const r of this.instances)if(r!==e){const e=Z(r);if(!e){E.warn("Expected CodeMirror instance to have CodeMirror instance state");continue}const n=e.setSelections.bind(e);e.setSelections=()=>[];const i=e.state.vim;if(!i){E.warn("Expected CodeMirror instance to have Vim state");continue}switch(t){case"normal":i.insertMode&&J.exitInsertMode(e,!0),i.visualMode&&J.exitVisualMode(e,!0);break;case"insert":i.insertMode||J.handleKey(e,"i","")}e.setSelections=n}}}vs=ws,ws.INSTANCES=new vs;const ks=["default","vim"];function Ts(e,t){switch(e.preset){case"default":return[W.of(re),W.of([{key:"Escape",preventDefault:!0,run:e=>(e.contentDOM.blur(),!0)}])];case"vim":return[W.of(Ss()),W.of([{key:"Enter",run:e=>{var t;const n=Z(e);return!!(null==(t=null==n?void 0:n.state.vim)?void 0:t.insertMode)&&ne(e)}}]),ee.high(Rs("d",(e=>""===e.state.doc.toString()),(e=>""===e.state.doc.toString()&&(t.deleteCell(),!0)))),te({status:!1}),ee.high(bs(t))];default:return Q(e.preset),[]}}const Ss=_((()=>{const e=new Set(["Enter","Ctrl-v"]);return re.filter((t=>!e.has(t.key||t.mac||t.linux||t.win||"")))}));function Rs(e,t,n){let r="",i=0;return W.of([{any:(o,s)=>{const a=s.key,c=s.timeStamp;if(a!==e||!t(o))return r="",i=0,!1;if(r===e&&c-i<500){if(n(o))return r="",i=0,!0}return r=a,i=c,!1}}])}function Ds(){return["compact","medium","full","columns"]}const Cs=w({});function js(){return oe(Cs)}function Os(e,t){const n=a.c(13),{registerAction:r,unregisterAction:i}=function(){const e=q(Cs);return{registerAction:ie(((t,n)=>{e((e=>({...e,[t]:n})))})),unregisterAction:ie((t=>{e((e=>{const{[t]:n,...r}=e;return r}))}))}}(),o=oe(se),s=t===ae.NOOP;let c;n[0]!==t?(c=e=>t(e),n[0]=t,n[1]=c):c=n[1];const l=ie(c);let u;n[2]!==t||n[3]!==o||n[4]!==e?(u=n=>{const r=o.getHotkey(e).key;if(ce(r)(n)){!1!==t(n)&&(n.preventDefault(),n.stopPropagation())}},n[2]=t,n[3]=o,n[4]=e,n[5]=u):u=n[5];const d=ie(u);let h,f;y(document,"keydown",d),n[6]!==s||n[7]!==l||n[8]!==r||n[9]!==e||n[10]!==i?(h=()=>{if(!s)return r(e,l),()=>i(e)},f=[l,e,s,r,i],n[6]=s,n[7]=l,n[8]=r,n[9]=e,n[10]=i,n[11]=h,n[12]=f):(h=n[11],f=n[12]),m.useEffect(h,f)}function Ps(e,t){const n=a.c(3),r=oe(se);let i;n[0]!==t||n[1]!==r?(i=e=>{for(const[n,i]of le.entries(t)){if(void 0===i)continue;const t=r.getHotkey(n).key;if(ce(t)(e)){E.debug("Satisfied",t,e);!1!==i(e)&&(e.preventDefault(),e.stopPropagation())}}},n[0]=t,n[1]=r,n[2]=i):i=n[2],y(e,"keydown",i)}function Ns(e,t){const n=a.c(2);let r;n[0]!==t?(r=e=>{for(const[n,r]of le.entries(t))if(ce(n)(e)){E.debug("Satisfied",n,e);!1!==r(e)&&(e.preventDefault(),e.stopPropagation())}},n[0]=t,n[1]=r):r=n[1],y(e,"keydown",r)}const Es=w(!1),Is=()=>{const e=a.c(78),[t,n]=A(Es),[r,i]=m.useState(null);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const[s,c]=m.useState(o),[u,d]=ue(),h=oe(se);let p,g;e[1]!==n?(p=()=>n(_s),e[1]=n,e[2]=p):p=e[2],Os("global.showHelp",p),e[3]!==u||e[4]!==d?(g=async e=>{const t={...u};d(e),await de({config:e}).catch((e=>{throw d(t),e}))},e[3]=u,e[4]=d,e[5]=g):g=e[5];const y=g;let v;e[6]!==u||e[7]!==r||e[8]!==y?(v=async e=>{if(!r)return;const t=e.join("-"),n={...u,keymap:{...u.keymap,overrides:{...u.keymap.overrides,[r]:t}}};i(null),c([]),await y(n)},e[6]=u,e[7]=r,e[8]=y,e[9]=v):v=e[9];const b=v;let x;e[10]!==u||e[11]!==r||e[12]!==y?(x=async()=>{if(!r)return;const e={...u,keymap:{...u.keymap,overrides:{...u.keymap.overrides}}};delete e.keymap.overrides[r],i(null),c([]),await y(e)},e[10]=u,e[11]=r,e[12]=y,e[13]=x):x=e[13];const w=x;let k;e[14]!==u||e[15]!==y?(k=async()=>{if(!window.confirm("Are you sure you want to reset all shortcuts to their default values?"))return;const e={...u,keymap:{...u.keymap,overrides:{}}};i(null),c([]),await y(e)},e[14]=u,e[15]=y,e[16]=k):k=e[16];const T=k;if(!t)return null;let S;e[17]!==r||e[18]!==b||e[19]!==w||e[20]!==h||e[21]!==s?(S=e=>{const t=h.getHotkey(e);if(r===e){const n=he(e);return l.jsxs("div",{children:[l.jsx(fe,{defaultValue:s.join("+"),placeholder:t.name,onKeyDown:e=>{e.preventDefault();const t=[];if("Meta"===e.key||"Control"===e.key||"Alt"===e.key||"Shift"===e.key)return;if(e.metaKey&&t.push(pe()?"Cmd":"Meta"),e.ctrlKey&&t.push("Ctrl"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),"-"===e.key)return;if("Escape"===e.key&&0===t.length)return i(null),void c([]);let n=e.key.toLowerCase();" "===e.key&&(n="Space"),t.push(n),b(t)},autoFocus:!0,endAdornment:l.jsx(F,{variant:"text",size:"xs",className:"mb-0",onClick:()=>{i(null),c([])},children:l.jsx(f,{className:"w-4 h-4"})})}),l.jsxs("div",{className:"flex items-center justify-between w-full",children:[l.jsx("span",{className:"text-muted-foreground text-xs",children:"Press a key combination"}),n.key!==t.key&&l.jsxs("span",{className:"text-xs cursor-pointer text-primary",onClick:w,children:["Reset to default:"," ",l.jsx("span",{className:"font-mono",children:n.key})]})]})]},e)}return l.jsxs("div",{className:"grid grid-cols-[auto,2fr,3fr] gap-2 items-center",children:[h.isEditable(e)?l.jsx(ge,{className:"cursor-pointer opacity-60 hover:opacity-100 text-muted-foreground w-3 h-3",onClick:()=>{c([]),i(e)}}):l.jsx("div",{className:"w-3 h-3"}),l.jsx(me,{className:"justify-end",shortcut:t.key}),l.jsx("span",{children:t.name.toLowerCase()})]},e)},e[17]=r,e[18]=b,e[19]=w,e[20]=h,e[21]=s,e[22]=S):S=e[22];const R=S;let D,C,j,O,P,N,E,I,_,M,q,L,H,$,z,B,U,W,V,K,G,J,Y,Z;if(e[23]!==h||e[24]!==t||e[25]!==R||e[26]!==n){const r=h.getHotkeyGroups(),i=e=>{const t=r[e];return l.jsxs("div",{className:"mb-[40px] gap-2 flex flex-col",children:[l.jsx("h3",{className:"text-lg font-medium",children:e}),t.map((e=>R(e)))]})};j=ye,H=t,e[44]!==n?($=e=>n(e),e[44]=n,e[45]=$):$=e[45],C=ve,q="sm:items-center sm:top-0",e[46]===Symbol.for("react.memo_cache_sentinel")?(L=l.jsx(be,{}),e[46]=L):L=e[46],D=xe,I=!1,_="max-h-screen sm:max-h-[90vh] overflow-y-auto sm:max-w-[850px]",e[47]===Symbol.for("react.memo_cache_sentinel")?(M=l.jsx(we,{children:l.jsx(ke,{children:"Shortcuts"})}),e[47]=M):M=e[47],N="flex flex-row gap-3",E=l.jsxs("div",{className:"w-1/2",children:[i("Editing"),i("Markdown")]}),z="w-1/2",B=i("Navigation"),U=i("Running Cells"),O=i("Creation and Ordering"),P=i("Other"),e[23]=h,e[24]=t,e[25]=R,e[26]=n,e[27]=D,e[28]=C,e[29]=j,e[30]=O,e[31]=P,e[32]=N,e[33]=E,e[34]=I,e[35]=_,e[36]=M,e[37]=q,e[38]=L,e[39]=H,e[40]=$,e[41]=z,e[42]=B,e[43]=U}else D=e[27],C=e[28],j=e[29],O=e[30],P=e[31],N=e[32],E=e[33],I=e[34],_=e[35],M=e[36],q=e[37],L=e[38],H=e[39],$=e[40],z=e[41],B=e[42],U=e[43];return e[48]===Symbol.for("react.memo_cache_sentinel")?(W=l.jsx("span",{className:"text-destructive",children:"Reset all to default"}),e[48]=W):W=e[48],e[49]!==T?(V=l.jsx(F,{className:"mt-4 hover:bg-destructive/10 hover:border-destructive",variant:"outline",size:"xs",onClick:T,tabIndex:-1,children:W}),e[49]=T,e[50]=V):V=e[50],e[51]!==O||e[52]!==P||e[53]!==V||e[54]!==z||e[55]!==B||e[56]!==U?(K=l.jsxs("div",{className:z,children:[B,U,O,P,V]}),e[51]=O,e[52]=P,e[53]=V,e[54]=z,e[55]=B,e[56]=U,e[57]=K):K=e[57],e[58]!==N||e[59]!==E||e[60]!==K?(G=l.jsxs("div",{className:N,children:[E,K]}),e[58]=N,e[59]=E,e[60]=K,e[61]=G):G=e[61],e[62]!==D||e[63]!==I||e[64]!==_||e[65]!==M||e[66]!==G?(J=l.jsxs(D,{usePortal:I,className:_,children:[M,G]}),e[62]=D,e[63]=I,e[64]=_,e[65]=M,e[66]=G,e[67]=J):J=e[67],e[68]!==C||e[69]!==q||e[70]!==L||e[71]!==J?(Y=l.jsxs(C,{className:q,children:[L,J]}),e[68]=C,e[69]=q,e[70]=L,e[71]=J,e[72]=Y):Y=e[72],e[73]!==j||e[74]!==H||e[75]!==$||e[76]!==Y?(Z=l.jsx(j,{open:H,onOpenChange:$,children:Y}),e[73]=j,e[74]=H,e[75]=$,e[76]=Y,e[77]=Z):Z=e[77],Z};function _s(e){return!e}const Ms=["claude-3-5-sonnet-20241022","claude-3-opus","claude-3.5-haiku","claude-3.5-sonnet","deepseek-v3","gemini-2.0-flash-exp","gemini-2.0-flash-thinking-exp","gemini-exp-1206","gpt-3.5-turbo","gpt-4","gpt-4-turbo-2024-04-09","gpt-4o","gpt-4o-mini","o1","o1-mini","o1-preview"],qs="flex flex-row items-center space-x-1 space-y-0",As=[{id:"editor",label:"Editor",Icon:ge,className:"bg-[var(--blue-4)]"},{id:"display",label:"Display",Icon:vt,className:"bg-[var(--grass-4)]"},{id:"packageManagement",label:"Package Management",Icon:bt,className:"bg-[var(--red-4)]"},{id:"runtime",label:"Runtime",Icon:pt,className:"bg-[var(--amber-4)]"},{id:"ai",label:"AI",Icon:ht,className:"bg-[linear-gradient(45deg,var(--purple-5),var(--cyan-5))]"},{id:"labs",label:"Labs",Icon:gt,className:"bg-[var(--slate-4)]"}],Ls=w(As[0].id),Fs=()=>{const e=a.c(40),[t,n]=Te(),r=m.useRef(null),i=q(Es),[o,s]=A(Ls);let c,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=Se(Re),e[0]=c):c=e[0],e[1]!==t?(u={resolver:c,defaultValues:t},e[1]=t,e[2]=u):u=e[2];const h=De(u);let f;e[3]!==n?(f=async e=>{await de({config:e}).then((()=>{n(e)}))},e[3]=n,e[4]=f):f=e[4];const p=f;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=d(),e[5]=g):g=e[5];const y=g;let v;e[6]!==t||e[7]!==h?(v=()=>{const e=h.getValues("completion.copilot");return!1===e?null:"codeium"===e?l.jsxs(l.Fragment,{children:[l.jsxs("p",{className:"text-sm text-muted-secondary",children:["To get a Codeium API key, follow"," ",l.jsx("a",{className:"text-link hover:underline",href:"https://docs.marimo.io/guides/editor_features/ai_completion.html#codeium-copilot",target:"_blank",rel:"noreferrer",children:"these instructions"}),"."]}),l.jsx(Pe,{control:h.control,name:"completion.codeium_api_key",render:e=>{const{field:n}=e;return l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"API Key"}),l.jsx(Ie,{children:l.jsx(fe,{"data-testid":"codeium-api-key-input",className:"m-0 inline-flex",placeholder:"key",...n,value:n.value||""})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"completion.codeium_api_key"})]})}})]}):"github"===e?l.jsx(ys,{}):void 0},e[6]=t,e[7]=h,e[8]=v):v=e[8];const b=v;let x;e[9]!==o||e[10]!==t||e[11]!==h||e[12]!==p||e[13]!==b||e[14]!==s||e[15]!==i?(x=()=>{switch(o){case"editor":return l.jsxs(l.Fragment,{children:[l.jsxs(Hs,{title:"Autosave",children:[l.jsx(Pe,{control:h.control,name:"save.autosave",render:e=>{const{field:n}=e;return l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{className:"font-normal",children:"Autosave enabled"}),l.jsx(Ie,{children:l.jsx(Fe,{"data-testid":"autosave-checkbox",checked:"after_delay"===n.value,disabled:n.disabled,onCheckedChange:e=>{n.onChange(e?"after_delay":"off")}})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"save.autosave"})]})}}),l.jsx(Pe,{control:h.control,name:"save.autosave_delay",render:e=>{const{field:n}=e;return l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Autosave delay (seconds)"}),l.jsx(Ie,{children:l.jsx(ze,{"data-testid":"autosave-delay-input",className:"m-0 w-24",isDisabled:"after_delay"!==h.getValues("save.autosave"),...n,value:n.value/1e3,minValue:1,onChange:e=>{n.onChange(1e3*e),Number.isNaN(e)||p(h.getValues())}})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"save.autosave_delay"})]})}})]}),l.jsxs(Hs,{title:"Formatting",children:[l.jsx(Pe,{control:h.control,name:"save.format_on_save",render:e=>{const{field:n}=e;return l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{className:"font-normal",children:"Format on save"}),l.jsx(Ie,{children:l.jsx(Fe,{"data-testid":"format-on-save-checkbox",checked:n.value,disabled:n.disabled,onCheckedChange:e=>{n.onChange(e)}})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"save.format_on_save"})]})}}),l.jsx(Pe,{control:h.control,name:"formatting.line_length",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Line length"}),l.jsx(Ie,{children:l.jsx(ze,{"data-testid":"line-length-input",className:"m-0 w-24",...n,value:n.value,minValue:1,maxValue:1e3,onChange:e=>{n.onChange(e),Number.isNaN(e)||p(h.getValues())}})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"formatting.line_length"})]}),l.jsx(qe,{children:"Maximum line length when formatting code."})]})}})]}),l.jsx(Hs,{title:"Autocomplete",children:l.jsx(Pe,{control:h.control,name:"completion.activate_on_typing",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{className:"font-normal",children:"Autocomplete"}),l.jsx(Ie,{children:l.jsx(Fe,{"data-testid":"autocomplete-checkbox",checked:n.value,disabled:n.disabled,onCheckedChange:e=>{n.onChange(Boolean(e))}})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"completion.activate_on_typing"})]}),l.jsx(qe,{children:"When unchecked, code completion is still available through a hotkey."}),l.jsx("div",{children:l.jsx(F,{variant:"link",className:"mb-0 px-0",type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),s("ai")},children:"Edit AI autocomplete"})})]})}})}),l.jsx(Hs,{title:"Keymap",children:l.jsx(Pe,{control:h.control,name:"keymap.preset",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Keymap"}),l.jsx(Ie,{children:l.jsx(Me,{"data-testid":"keymap-select",onChange:e=>n.onChange(e.target.value),value:n.value,disabled:n.disabled,className:"inline-flex mr-2",children:ks.map(zs)})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"keymap.preset"})]}),l.jsx("div",{children:l.jsx(F,{variant:"link",className:"mb-0 px-0",type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),i(!0)},children:"Edit Keyboard Shortcuts"})})]})}})})]});case"display":return l.jsxs(l.Fragment,{children:[l.jsxs(Hs,{title:"Display",children:[l.jsx(Pe,{control:h.control,name:"display.default_width",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Default width"}),l.jsx(Ie,{children:l.jsx(Me,{"data-testid":"user-config-width-select",onChange:e=>n.onChange(e.target.value),value:n.value,disabled:n.disabled,className:"inline-flex mr-2",children:["compact","medium","full","columns"].map(Bs)})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"display.default_width"})]}),l.jsx(qe,{children:'The default app width for new notebooks; overridden by "width" in the application config.'})]})}}),l.jsx(Pe,{control:h.control,name:"display.theme",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Theme"}),l.jsx(Ie,{children:l.jsx(Me,{"data-testid":"theme-select",onChange:e=>n.onChange(e.target.value),value:n.value,disabled:n.disabled,className:"inline-flex mr-2",children:$e.map(Us)})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"display.theme"})]}),l.jsx(qe,{children:"This theme will be applied to the user's configuration; it does not affect theme when sharing the notebook."})]})}}),l.jsx(Pe,{control:h.control,name:"display.code_editor_font_size",render:e=>{const{field:n}=e;return l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Code editor font size (px)"}),l.jsx(Ie,{children:l.jsx("span",{className:"inline-flex mr-2",children:l.jsx(ze,{"data-testid":"code-editor-font-size-input",className:"m-0 w-24",...n,value:n.value,minValue:8,maxValue:32,onChange:e=>{n.onChange(e),p(h.getValues())}})})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"display.code_editor_font_size"})]})}})]}),l.jsxs(Hs,{title:"Outputs",children:[l.jsx(Pe,{control:h.control,name:"display.cell_output",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Cell output area"}),l.jsx(Ie,{children:l.jsx(Me,{"data-testid":"cell-output-select",onChange:e=>n.onChange(e.target.value),value:n.value,disabled:n.disabled,className:"inline-flex mr-2",children:["above","below"].map(Ws)})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"display.cell_output"})]}),l.jsx(qe,{children:"Where to display cell's output."})]})}}),l.jsx(Pe,{control:h.control,name:"display.dataframes",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Dataframe viewer"}),l.jsx(Ie,{children:l.jsx(Me,{"data-testid":"display-dataframes-select",onChange:e=>n.onChange(e.target.value),value:n.value,disabled:n.disabled,className:"inline-flex mr-2",children:["rich","plain"].map(Vs)})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"display.dataframes"})]}),l.jsx(qe,{children:"Whether to use marimo's rich dataframe viewer or a plain HTML table. This requires restarting your notebook to take effect."})]})}})]})]});case"packageManagement":return l.jsx(Hs,{title:"Package Management",children:l.jsx(Pe,{control:h.control,disabled:y,name:"package_management.manager",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Manager"}),l.jsx(Ie,{children:l.jsx(Me,{"data-testid":"package-manager-select",onChange:e=>n.onChange(e.target.value),value:n.value,disabled:n.disabled,className:"inline-flex mr-2",children:He.map(Ks)})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"package_management.manager"})]}),l.jsxs(qe,{children:["When marimo comes across a module that is not installed, you will be prompted to install it using your preferred package manager. Learn more in the"," ",l.jsx("a",{className:"text-link hover:underline",href:"https://docs.marimo.io/guides/editor_features/package_management.html",target:"_blank",rel:"noreferrer",children:"docs"}),".",l.jsx("br",{}),l.jsx("br",{}),"Running marimo in a"," ",l.jsx("a",{className:"text-link hover:underline",href:"https://docs.marimo.io/guides/editor_features/package_management.html#running-marimo-in-a-sandbox-environment-uv-only",target:"_blank",rel:"noreferrer",children:"sandboxed environment"})," ","is only supported by ",l.jsx(Ae,{className:"inline",children:"uv"})]})]})}})});case"runtime":return l.jsxs(Hs,{title:"Runtime configuration",children:[l.jsx(Pe,{control:h.control,name:"runtime.auto_instantiate",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col gap-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{className:"font-normal",children:"Autorun on startup"}),l.jsx(Ie,{children:l.jsx(Fe,{"data-testid":"auto-instantiate-checkbox",disabled:n.disabled,checked:n.value,onCheckedChange:n.onChange})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"runtime.auto_instantiate"})]}),l.jsx(qe,{children:"Whether to automatically run all cells on startup."})]})}}),l.jsx(Pe,{control:h.control,name:"runtime.on_cell_change",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col gap-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{className:"font-normal",children:"On cell change"}),l.jsx(Ie,{children:l.jsx(Me,{"data-testid":"on-cell-change-select",onChange:e=>n.onChange(e.target.value),value:n.value,className:"inline-flex mr-2",children:["lazy","autorun"].map(Gs)})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"runtime.on_cell_change"})]}),l.jsx(qe,{children:'Whether marimo should automatically run cells or just mark them as stale. If "autorun", marimo will automatically run affected cells when a cell is run or a UI element is interacted with; if "lazy", marimo will mark affected cells as stale but won\'t re-run them.'})]})}}),l.jsx(Pe,{control:h.control,name:"runtime.auto_reload",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col gap-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{className:"font-normal",children:"On module change"}),l.jsx(Ie,{children:l.jsx(Me,{"data-testid":"auto-reload-select",onChange:e=>n.onChange(e.target.value),value:n.value,disabled:y,className:"inline-flex mr-2",children:["off","lazy","autorun"].map(Js)})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"runtime.auto_reload"})]}),l.jsx(qe,{children:'Whether marimo should automatically reload modules before executing cells. If "lazy", marimo will mark cells affected by module modifications as stale; if "autorun", affected cells will be automatically re-run.'})]})}}),l.jsxs(qe,{children:["Learn more in the"," ",l.jsx("a",{className:"text-link hover:underline",href:"https://docs.marimo.io/guides/reactivity/#configuring-how-marimo-runs-cells",target:"_blank",rel:"noreferrer",children:"docs"}),"."]})]});case"ai":return l.jsxs(l.Fragment,{children:[l.jsxs(Hs,{title:"AI Code Completion",children:[l.jsx("p",{className:"text-sm text-muted-secondary",children:"You may use GitHub Copilot or Codeium for AI code completion."}),l.jsx(Pe,{control:h.control,name:"completion.copilot",render:e=>{const{field:n}=e;return l.jsx("div",{className:"flex flex-col space-y-1",children:l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Provider"}),l.jsx(Ie,{children:l.jsx(Me,{"data-testid":"copilot-select",onChange:e=>{"none"===e.target.value?n.onChange(!1):n.onChange(e.target.value)},value:!0===n.value?"github":!1===n.value?"none":n.value,disabled:n.disabled,className:"inline-flex mr-2",children:["none","github","codeium"].map(Ys)})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"completion.copilot"})]})})}}),b()]}),l.jsxs(Hs,{title:"AI Keys",children:[l.jsx(Pe,{control:h.control,name:"ai.open_ai.api_key",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"OpenAI API Key"}),l.jsx(Ie,{children:l.jsx(fe,{"data-testid":"ai-openai-api-key-input",className:"m-0 inline-flex",placeholder:"sk-proj...",...n,onChange:e=>{const t=e.target.value;t.includes("*")||n.onChange(t)}})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"ai.open_ai.api_key"})]}),l.jsxs(qe,{children:["Your OpenAI API key from"," ",l.jsx("a",{className:"text-link hover:underline",href:"https://platform.openai.com/account/api-keys",target:"_blank",rel:"noreferrer",children:"platform.openai.com"}),"."]})]})}}),l.jsx(Pe,{control:h.control,name:"ai.anthropic.api_key",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Anthropic API Key"}),l.jsx(Ie,{children:l.jsx(fe,{"data-testid":"ai-anthropic-api-key-input",className:"m-0 inline-flex",placeholder:"sk-ant...",...n,onChange:e=>{const t=e.target.value;t.includes("*")||n.onChange(t)}})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"ai.anthropic.api_key"})]}),l.jsxs(qe,{children:["Your Anthropic API key from"," ",l.jsx("a",{className:"text-link hover:underline",href:"https://console.anthropic.com/settings/keys",target:"_blank",rel:"noreferrer",children:"console.anthropic.com"}),"."]})]})}}),l.jsx(Pe,{control:h.control,name:"ai.google.api_key",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Google AI API Key"}),l.jsx(Ie,{children:l.jsx(fe,{"data-testid":"ai-google-api-key-input",className:"m-0 inline-flex",placeholder:"AI...",...n,onChange:e=>{const t=e.target.value;t.includes("*")||n.onChange(t)}})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"ai.google.api_key"})]}),l.jsxs(qe,{children:["Your Google AI API key from"," ",l.jsx("a",{className:"text-link hover:underline",href:"https://aistudio.google.com/app/apikey",target:"_blank",rel:"noreferrer",children:"aistudio.google.com"}),"."]})]})}})]}),l.jsxs(Hs,{title:"AI Assist",children:[l.jsxs("p",{className:"text-sm text-muted-secondary",children:["Add an API key to ",l.jsx(Ae,{className:"inline",children:"marimo.toml"})," to activate marimo's AI assistant; see"," ",l.jsx("a",{className:"text-link hover:underline",href:"https://docs.marimo.io/guides/editor_features/ai_completion.html",target:"_blank",rel:"noreferrer",children:"docs"})," ","for more info."]}),l.jsx(Pe,{control:h.control,disabled:y,name:"ai.open_ai.base_url",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Base URL"}),l.jsx(Ie,{children:l.jsx(fe,{"data-testid":"ai-base-url-input",className:"m-0 inline-flex",placeholder:"https://api.openai.com/v1",...n})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"ai.open_ai.base_url"})]}),l.jsx(qe,{children:"This URL can be any OpenAI-compatible API endpoint."})]})}}),l.jsx(Pe,{control:h.control,disabled:y,name:"ai.open_ai.model",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col space-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{children:"Model"}),l.jsx(Ie,{children:l.jsx(fe,{list:"ai-model-datalist","data-testid":"ai-model-input",className:"m-0 inline-flex",placeholder:"gpt-4-turbo",...n})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"ai.open_ai.model"})]}),l.jsx("datalist",{id:"ai-model-datalist",children:Ms.map(Zs)}),l.jsx(qe,{children:'If the model starts with "claude-", we will use your Anthropic API key. If the model starts with "gemini-", we will use your Google AI API key. Otherwise, we will use your OpenAI API key.'})]})}}),l.jsx(Pe,{control:h.control,name:"ai.rules",render:e=>{const{field:n}=e;return l.jsxs("div",{className:"flex flex-col",children:[l.jsxs(Ne,{children:[l.jsx(Ee,{children:"Custom Rules"}),l.jsx(Ie,{children:l.jsx(Le,{"data-testid":"ai-rules-input",className:"m-0 inline-flex w-full h-32 p-2 text-sm",placeholder:"e.g. Always use type hints; prefer polars over pandas",...n,value:n.value})}),l.jsx(_e,{}),l.jsx($s,{userConfig:t,name:"ai.rules"})]}),l.jsx(qe,{children:"Custom rules to include in all AI completion prompts."})]})}})]})]});case"labs":return l.jsxs(Hs,{title:"Experimental Features",children:[l.jsx("p",{className:"text-sm text-muted-secondary mb-4",children:"⚠️ These features are experimental and may require restarting your notebook to take effect."}),l.jsx(Pe,{control:h.control,name:"experimental.chat_sidebar",render:Xs}),l.jsx(Pe,{control:h.control,name:"experimental.inline_ai_tooltip",render:Qs}),!d()&&l.jsx(Pe,{control:h.control,name:"experimental.rtc",render:ea})]})}},e[9]=o,e[10]=t,e[11]=h,e[12]=p,e[13]=b,e[14]=s,e[15]=i,e[16]=x):x=e[16];const w=x;let k,T,S;e[17]===Symbol.for("react.memo_cache_sentinel")?(k=l.jsx(Ae,{className:"inline",children:"marimo.toml"}),T=l.jsx("br",{}),e[17]=k,e[18]=T):(k=e[17],T=e[18]),e[19]===Symbol.for("react.memo_cache_sentinel")?(S=l.jsxs("p",{className:"text-muted-secondary",children:["User configuration is stored in ",k,T,"Run ",l.jsx(Ae,{className:"inline",children:"marimo config show"})," in your terminal to show your current configuration and file location."]}),e[19]=S):S=e[19];const R=S;let D,C,j,O,P,N,E,I;return e[20]!==h||e[21]!==p?(D=h.handleSubmit(p),e[20]=h,e[21]=p,e[22]=D):D=e[22],e[23]!==s?(C=e=>s(e),e[23]=s,e[24]=C):C=e[24],e[25]===Symbol.for("react.memo_cache_sentinel")?(j=l.jsxs(Ce,{className:"self-start max-h-none flex flex-col gap-2 shrink-0 bg-background flex-1 min-h-full",children:[As.map(ta),l.jsx("div",{className:"flex-1"}),!d()&&R]}),e[25]=j):j=e[25],e[26]!==o||e[27]!==C?(O=l.jsx(Be,{value:o,onValueChange:C,orientation:"vertical",className:"w-1/3 pr-4 border-r h-full overflow-auto p-6",children:j}),e[26]=o,e[27]=C,e[28]=O):O=e[28],e[29]!==w?(P=w(),e[29]=w,e[30]=P):P=e[30],e[31]!==P?(N=l.jsx("div",{className:"w-2/3 pl-6 gap-2 flex flex-col overflow-auto p-6",children:P}),e[31]=P,e[32]=N):N=e[32],e[33]!==O||e[34]!==N||e[35]!==D?(E=l.jsxs("form",{ref:r,onChange:D,className:"flex text-pretty overflow-hidden",children:[O,N]}),e[33]=O,e[34]=N,e[35]=D,e[36]=E):E=e[36],e[37]!==h||e[38]!==E?(I=l.jsx(je,{...h,children:E}),e[37]=h,e[38]=E,e[39]=I):I=e[39],I},Hs=e=>{const t=a.c(5),{title:n,children:r}=e;let i,o;return t[0]!==n?(i=l.jsx(Nt,{className:"text-base",children:n}),t[0]=n,t[1]=i):i=t[1],t[2]!==r||t[3]!==i?(o=l.jsxs("div",{className:"flex flex-col gap-4 pb-4",children:[i,r]}),t[2]=r,t[3]=i,t[4]=o):o=t[4],o},$s=e=>{const t=a.c(24),{userConfig:n,name:r}=e;let i;t[0]!==r||t[1]!==n?(i=Ue(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];const o=i,s=oe(We);let c;t[3]!==r||t[4]!==s?(c=Ue(s,r),t[3]=r,t[4]=s,t[5]=c):c=t[5];const u=c;if(null==u)return null;if(o===u)return null;let d,h,f,g;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=l.jsxs("span",{children:["This setting is overridden by"," ",l.jsx(Ae,{className:"inline",children:"pyproject.toml"}),"."]}),h=l.jsx("br",{}),t[6]=d,t[7]=h):(d=t[6],h=t[7]),t[8]===Symbol.for("react.memo_cache_sentinel")?(f=l.jsxs("span",{children:["Edit the ",l.jsx(Ae,{className:"inline",children:"pyproject.toml"})," file directly to change this setting."]}),g=l.jsx("br",{}),t[8]=f,t[9]=g):(f=t[8],g=t[9]);const m=String(o);let y,v;t[10]!==m?(y=l.jsxs("span",{children:["User value: ",l.jsx("strong",{children:m})]}),t[10]=m,t[11]=y):y=t[11],t[12]===Symbol.for("react.memo_cache_sentinel")?(v=l.jsx("br",{}),t[12]=v):v=t[12];const b=String(u);let x,w,k;t[13]!==b?(x=l.jsxs("span",{children:["Project value: ",l.jsx("strong",{children:b})]}),t[13]=b,t[14]=x):x=t[14],t[15]!==x||t[16]!==y?(w=l.jsxs(l.Fragment,{children:[d,h,f,g,y,v,x]}),t[15]=x,t[16]=y,t[17]=w):w=t[17],t[18]===Symbol.for("react.memo_cache_sentinel")?(k=l.jsx(mt,{className:"w-3 h-3"}),t[18]=k):k=t[18];const T=String(u);let S,R;return t[19]!==T?(S=l.jsxs("span",{className:"text-[var(--amber-12)] text-xs flex items-center gap-1 border rounded px-2 py-1 bg-[var(--amber-2)] border-[var(--amber-6)] ml-1",children:[k,"Overridden by pyproject.toml [",T,"]"]}),t[19]=T,t[20]=S):S=t[20],t[21]!==w||t[22]!==S?(R=l.jsx(p,{content:w,children:S}),t[21]=w,t[22]=S,t[23]=R):R=t[23],R};function zs(e){return l.jsx("option",{value:e,children:e},e)}function Bs(e){return l.jsx("option",{value:e,children:e},e)}function Us(e){return l.jsx("option",{value:e,children:e},e)}function Ws(e){return l.jsx("option",{value:e,children:e},e)}function Vs(e){return l.jsx("option",{value:e,children:e},e)}function Ks(e){return l.jsx("option",{value:e,children:e},e)}function Gs(e){return l.jsx("option",{value:e,children:e},e)}function Js(e){return l.jsx("option",{value:e,children:e},e)}function Ys(e){return l.jsx("option",{value:e,children:e},e)}function Zs(e){return l.jsx("option",{value:e,children:e},e)}function Xs(e){const{field:t}=e;return l.jsxs("div",{className:"flex flex-col gap-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{className:"font-normal",children:"Chat sidebar"}),l.jsx(Ie,{children:l.jsx(Fe,{"data-testid":"chat-sidebar-checkbox",checked:!0===t.value,onCheckedChange:t.onChange})})]}),l.jsx(qe,{children:"Enable experimental chat sidebar to ask questions with an AI assistant."})]})}function Qs(e){const{field:t}=e;return l.jsxs("div",{className:"flex flex-col gap-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{className:"font-normal",children:"AI Edit Tooltip"}),l.jsx(Ie,{children:l.jsx(Fe,{"data-testid":"inline-ai-checkbox",checked:!0===t.value,onCheckedChange:t.onChange})})]}),l.jsx(qe,{children:'Enable experimental "Edit with AI" tooltip when selecting code.'})]})}function ea(e){const{field:t}=e;return l.jsxs("div",{className:"flex flex-col gap-y-1",children:[l.jsxs(Ne,{className:qs,children:[l.jsx(Ee,{className:"font-normal",children:"Real-time Collaboration"}),l.jsx(Ie,{children:l.jsx(Fe,{"data-testid":"rtc-checkbox",checked:!0===t.value,onCheckedChange:t.onChange})})]}),l.jsx(qe,{children:"Enable experimental real-time collaboration to allow editing cell inputs by multiple users. This experimental feature has known issues, including duplication of code. Requires refreshing the page to take effect."})," "]})}function ta(e){return l.jsx(Oe,{value:e.id,className:"w-full text-left p-2 data-[state=active]:bg-primary data-[state=active]:text-primary-foreground justify-start",children:l.jsxs("div",{className:"flex gap-4 items-center text-lg",children:[l.jsx("span",{className:v(e.className,"w-8 h-8 rounded flex items-center justify-center text-muted-foreground"),children:l.jsx(e.Icon,{className:"w-4 h-4"})}),e.label]})},e.id)}const na=()=>{const e=a.c(27),[t,n]=Ve();let r,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=Se(Ke),e[0]=r):r=e[0],e[1]!==t?(i={resolver:r,defaultValues:t},e[1]=t,e[2]=i):i=e[2];const o=De(i);let s;e[3]!==n?(s=async e=>{await Ye({config:e}).then((()=>{n(e)})).catch((()=>{n(e)}))},e[3]=n,e[4]=s):s=e[4];const c=s;let u,d,h,f,p,g,y,v,b,x;return e[5]!==t.width?(u=[t.width],e[5]=t.width,e[6]=u):u=e[6],m.useEffect(ra,u),e[7]!==o||e[8]!==c?(d=o.handleSubmit(c),e[7]=o,e[8]=c,e[9]=d):d=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(h=l.jsxs("div",{children:[l.jsx(Pt,{children:"Application Config"}),l.jsx(Et,{children:"Settings applied to this notebook"})]}),e[10]=h):h=e[10],e[11]!==o.control?(p=l.jsx(Pe,{control:o.control,name:"width",render:oa}),g=l.jsx(Pe,{control:o.control,name:"app_title",render:sa}),y=l.jsx(Pe,{control:o.control,name:"css_file",render:aa}),v=l.jsx(Pe,{control:o.control,name:"html_head_file",render:ca}),f=l.jsx(Pe,{control:o.control,name:"auto_download",render:la}),e[11]=o.control,e[12]=f,e[13]=p,e[14]=g,e[15]=y,e[16]=v):(f=e[12],p=e[13],g=e[14],y=e[15],v=e[16]),e[17]!==f||e[18]!==d||e[19]!==p||e[20]!==g||e[21]!==y||e[22]!==v?(b=l.jsxs("form",{onChange:d,className:"flex flex-col gap-4",children:[h,p,g,y,v,f]}),e[17]=f,e[18]=d,e[19]=p,e[20]=g,e[21]=y,e[22]=v,e[23]=b):b=e[23],e[24]!==o||e[25]!==b?(x=l.jsx(je,{...o,children:b}),e[24]=o,e[25]=b,e[26]=x):x=e[26],x};function ra(){window.dispatchEvent(new Event("resize"))}function ia(e){return l.jsx("option",{value:e,children:e},e)}function oa(e){const{field:t}=e;return l.jsxs(Ne,{className:"flex flex-row items-center space-x-1 space-y-0",children:[l.jsx(Ee,{children:"Width"}),l.jsx(Ie,{children:l.jsx(Me,{"data-testid":"app-width-select",onChange:e=>t.onChange(e.target.value),value:t.value,disabled:t.disabled,className:"inline-flex mr-2",children:["compact","medium","full","columns"].map(ia)})}),l.jsx(_e,{})]})}function sa(e){const{field:t}=e;return l.jsxs("div",{className:"flex flex-col gap-y-1",children:[l.jsxs(Ne,{className:"flex flex-row items-center space-x-1 space-y-0",children:[l.jsx(Ee,{children:"App title"}),l.jsx(Ie,{children:l.jsx(fe,{...t,value:t.value??"",onChange:e=>{t.onChange(e.target.value),Ge.safeParse(e.target.value).success&&(document.title=e.target.value)}})}),l.jsx(_e,{})]}),l.jsx(qe,{children:"The application title is put in the title tag in the HTML code and typically displayed in the title bar of the browser window."})]})}function aa(e){const{field:t}=e;return l.jsxs("div",{className:"flex flex-col gap-y-1",children:[l.jsxs(Ne,{className:"flex flex-row items-center space-x-1 space-y-0",children:[l.jsx(Ee,{className:"flex-shrink-0",children:"Custom CSS"}),l.jsx(Ie,{children:l.jsx(fe,{...t,value:t.value??"",placeholder:"custom.css",onChange:e=>{t.onChange(e.target.value),Ge.safeParse(e.target.value).success&&(document.title=e.target.value)}})}),l.jsx(_e,{})]}),l.jsx(qe,{children:"A filepath to a custom css file to be injected into the notebook."})]})}function ca(e){const{field:t}=e;return l.jsxs("div",{className:"flex flex-col gap-y-1",children:[l.jsxs(Ne,{className:"flex flex-row items-center space-x-1 space-y-0",children:[l.jsx(Ee,{className:"flex-shrink-0",children:"HTML Head"}),l.jsx(Ie,{children:l.jsx(fe,{...t,value:t.value??"",placeholder:"head.html",onChange:e=>{t.onChange(e.target.value)}})}),l.jsx(_e,{})]}),l.jsxs(qe,{children:["A filepath to an HTML file to be injected into the"," ",l.jsx(Ae,{className:"inline",children:""})," section of the notebook. Use this to add analytics, custom fonts, meta tags, or external scripts."]})]})}function la(e){const{field:t}=e;return l.jsxs("div",{className:"flex flex-col gap-y-1",children:[l.jsx("div",{className:"text-base font-bold text-muted-foreground",children:"Auto-download"}),l.jsxs(Ne,{className:"flex flex-col gap-2",children:[l.jsx(Ie,{children:l.jsxs("div",{className:"flex gap-4",children:[l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx(Fe,{id:"html-checkbox",checked:t.value.includes("html"),onCheckedChange:()=>{t.onChange(Je(t.value,"html"))}}),l.jsx(Ee,{htmlFor:"html-checkbox",children:"HTML"})]}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx(Fe,{id:"ipynb-checkbox",checked:t.value.includes("ipynb"),onCheckedChange:()=>{t.onChange(Je(t.value,"ipynb"))}}),l.jsx(Ee,{htmlFor:"ipynb-checkbox",children:"IPYNB"})]})]})}),l.jsx(_e,{})]}),l.jsxs(qe,{children:["When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named"," ",l.jsx(Ae,{className:"inline",children:"__marimo__"})," next to your notebook file."]})]})}const ua=e=>{const t=a.c(20),{showAppConfig:n}=e,r=void 0===n||n,[i,o]=A(gs);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=l.jsx(Rt,{"aria-label":"Config","data-testid":"app-config-button",shape:"circle",size:"small",className:"h-[27px] w-[27px]",color:"hint-green",children:l.jsx(p,{content:"Settings",children:l.jsx(Ze,{strokeWidth:1.8})})}),t[0]=s):s=t[0];const c=s;let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u=l.jsx(xe,{className:"w-[80vw] h-[70vh] overflow-hidden sm:max-w-5xl top-[15vh] p-0",children:l.jsx(Fs,{})}),t[1]=u):u=t[1];const d=u;if(!r){let e,n;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=l.jsx(Xe,{children:c}),t[2]=e):e=t[2],t[3]!==o||t[4]!==i?(n=l.jsxs(ye,{open:i,onOpenChange:o,children:[e,d]}),t[3]=o,t[4]=i,t[5]=n):n=t[5],n}let h,f,g,m,y,v,b,x;return t[6]===Symbol.for("react.memo_cache_sentinel")?(h=l.jsx(Qe,{asChild:!0,children:c}),t[6]=h):h=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(f=l.jsx(na,{}),g=l.jsx("div",{className:"h-px bg-border my-2"}),t[7]=f,t[8]=g):(f=t[7],g=t[8]),t[9]!==o?(m=()=>o(!0),t[9]=o,t[10]=m):m=t[10],t[11]===Symbol.for("react.memo_cache_sentinel")?(y=l.jsx(Ze,{strokeWidth:1.8,className:"w-4 h-4 mr-2"}),t[11]=y):y=t[11],t[12]!==m?(v=l.jsxs(et,{children:[h,l.jsxs(tt,{className:"w-80 overflow-auto",align:"end",side:"bottom",onFocusOutside:da,children:[f,g,l.jsxs(F,{onClick:m,variant:"link",className:"px-0",children:[y,"User settings"]})]})]}),t[12]=m,t[13]=v):v=t[13],t[14]!==o||t[15]!==i?(b=l.jsx(ye,{open:i,onOpenChange:o,children:d}),t[14]=o,t[15]=i,t[16]=b):b=t[16],t[17]!==b||t[18]!==v?(x=l.jsxs(l.Fragment,{children:[v,b]}),t[17]=b,t[18]=v,t[19]=x):x=t[19],x};function da(e){return e.preventDefault()}const ha=e=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 448 512",...e,children:l.jsx("path",{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"})}),fa=e=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 640 512",fill:"currentColor",...e,children:l.jsx("path",{d:"M593.8 59.1H46.2C20.7 59.1 0 79.8 0 105.2v301.5c0 25.5 20.7 46.2 46.2 46.2h547.7c25.5 0 46.2-20.7 46.1-46.1V105.2c0-25.4-20.7-46.1-46.2-46.1zM338.5 360.6H277v-120l-61.5 76.9-61.5-76.9v120H92.3V151.4h61.5l61.5 76.9 61.5-76.9h61.5v209.2zm135.3 3.1L381.5 256H443V151.4h61.5V256H566z"})}),pa=m.createContext(null);function ga(){const e=m.useContext(pa);if(null===e)throw new Error("No Tree Api Provided");return e}const ma=m.createContext(null);const ya=m.createContext(null);const va=m.createContext(0);function ba(){m.useContext(va)}function xa(e,t,n){return Math.max(Math.min(e,n),t)}function wa(e){return e&&e.isLeaf}function ka(e){return e&&e.isInternal&&!e.isOpen}function Ta(e){var t;return e&&e.isOpen&&!(null===(t=e.children)||void 0===t?void 0:t.length)}const Sa=(e,t)=>{let n=e;for(;n;){if(n.id===t.id)return!0;n=n.parent}return!1},Ra=e=>{if(!e.parent)throw Error("Node does not have a parent");return e.parent.children.findIndex((t=>t.id===e.id))};function Da(e,t){if(!e)return null;if(e.id===t)return e;if(e.children)for(let n of e.children){const e=Da(n,t);if(e)return e}return null}function Ca(e,t){if(t(e),e.children)for(let n of e.children)Ca(n,t)}function ja(e){const t=Ea(e);let n;for(let r=0;r=0?e[t-1]:e[e.length-1]}function Ea(e){return Array.from(document.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)')).filter((t=>t===e||!e.contains(t)))}function Ia(e,t){return"boolean"==typeof t?t:"string"==typeof t?e[t]:t(e)}function _a(e){return null===e?null:Ma(e)}function Ma(e){return"string"==typeof e?e:e.id}function qa(e,...t){if(e)return e(...t)}function Aa(e){return new Promise(((t,n)=>{let r=0;!function i(){r+=1,100===r&&n(),e()?t():setTimeout(i,10)}()}))}function La(e){var t,n;const r=e.focusedNode;return r?r.isOpen?0:r.parent?r.childIndex+1:0:null!==(n=null===(t=e.root.children)||void 0===t?void 0:t.length)&&void 0!==n?n:0}function Fa(e){const t=e.focusedNode;return t?t.isOpen?t.id:t.parent&&!t.parent.isRoot?t.parent.id:null:null}const Ha=Object.freeze(Object.defineProperty({__proto__:null,access:Ia,bound:xa,dfs:Da,focusNextElement:ja,focusPrevElement:Oa,getInsertIndex:La,getInsertParentId:Fa,identify:Ma,identifyNull:_a,indexOf:Ra,isClosed:ka,isDescendant:Sa,isItem:wa,isOpenWithEmptyChildren:Ta,mergeRefs:function(...e){return t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}},noop:function(){},safeRun:qa,waitFor:Aa,walk:Ca},Symbol.toStringTag,{value:"Module"})),$a={display:"flex",alignItems:"center",zIndex:1},za={flex:1,height:"2px",background:"#4B91E2",borderRadius:"1px"},Ba={width:"4px",height:"4px",boxShadow:"0 0 0 3px #4B91E2",borderRadius:"50%"},Ua=s.memo((function({top:e,left:t,indent:n}){const r={position:"absolute",pointerEvents:"none",top:e-2+"px",left:t+"px",right:n+"px"};return l.jsxs("div",{style:Object.assign(Object.assign({},$a),r),children:[l.jsx("div",{style:Object.assign({},Ba)}),l.jsx("div",{style:Object.assign({},za)})]})}));function Wa({node:e,attrs:t,innerRef:n,children:r}){return l.jsx("div",Object.assign({},t,{ref:n,onFocus:e=>e.stopPropagation(),onClick:e.handleClick,children:r}))}function Va(e){return l.jsxs("div",{ref:e.dragHandle,style:e.style,children:[l.jsx("span",{onClick:t=>{t.stopPropagation(),e.node.toggle()},children:e.node.isLeaf?"🌳":e.node.isOpen?"🗁":"🗀"})," ",e.node.isEditing?l.jsx(Ga,Object.assign({},e)):l.jsx(Ka,Object.assign({},e))]})}function Ka(e){return l.jsx(l.Fragment,{children:l.jsx("span",{children:e.node.data.name})})}function Ga({node:e}){const t=m.useRef();return m.useEffect((()=>{var e,n;null===(e=t.current)||void 0===e||e.focus(),null===(n=t.current)||void 0===n||n.select()}),[]),l.jsx("input",{ref:t,defaultValue:e.data.name,onBlur:()=>e.reset(),onKeyDown:n=>{var r;"Escape"===n.key&&e.reset(),"Enter"===n.key&&e.submit((null===(r=t.current)||void 0===r?void 0:r.value)||"")}})}function Ja(e){return{type:"EDIT",id:e}}function Ya(e){return{type:"FOCUS",id:e}}class Za{constructor(e){this.handleClick=e=>{e.metaKey&&!this.tree.props.disableMultiSelection?this.isSelected?this.deselect():this.selectMulti():e.shiftKey&&!this.tree.props.disableMultiSelection?this.selectContiguous():(this.select(),this.activate())},this.tree=e.tree,this.id=e.id,this.data=e.data,this.level=e.level,this.children=e.children,this.parent=e.parent,this.isDraggable=e.isDraggable,this.rowIndex=e.rowIndex}get isRoot(){return this.id===Xa}get isLeaf(){return!Array.isArray(this.children)}get isInternal(){return!this.isLeaf}get isOpen(){return!this.isLeaf&&this.tree.isOpen(this.id)}get isClosed(){return!this.isLeaf&&!this.tree.isOpen(this.id)}get isEditable(){return this.tree.isEditable(this.data)}get isEditing(){return this.tree.editingId===this.id}get isSelected(){return this.tree.isSelected(this.id)}get isOnlySelection(){return this.isSelected&&this.tree.hasOneSelection}get isSelectedStart(){var e;return this.isSelected&&!(null===(e=this.prev)||void 0===e?void 0:e.isSelected)}get isSelectedEnd(){var e;return this.isSelected&&!(null===(e=this.next)||void 0===e?void 0:e.isSelected)}get isFocused(){return this.tree.isFocused(this.id)}get isDragging(){return this.tree.isDragging(this.id)}get willReceiveDrop(){return this.tree.willReceiveDrop(this.id)}get state(){return{isClosed:this.isClosed,isDragging:this.isDragging,isEditing:this.isEditing,isFocused:this.isFocused,isInternal:this.isInternal,isLeaf:this.isLeaf,isOpen:this.isOpen,isSelected:this.isSelected,isSelectedEnd:this.isSelectedEnd,isSelectedStart:this.isSelectedStart,willReceiveDrop:this.willReceiveDrop}}get childIndex(){return this.parent&&this.parent.children?this.parent.children.findIndex((e=>e.id===this.id)):-1}get next(){return null===this.rowIndex?null:this.tree.at(this.rowIndex+1)}get prev(){return null===this.rowIndex?null:this.tree.at(this.rowIndex-1)}get nextSibling(){var e,t;const n=this.childIndex;return null!==(t=null===(e=this.parent)||void 0===e?void 0:e.children[n+1])&&void 0!==t?t:null}isAncestorOf(e){if(!e)return!1;let t=e;for(;t;){if(t.id===this.id)return!0;t=t.parent}return!1}select(){this.tree.select(this)}deselect(){this.tree.deselect(this)}selectMulti(){this.tree.selectMulti(this)}selectContiguous(){this.tree.selectContiguous(this)}activate(){this.tree.activate(this)}focus(){this.tree.focus(this)}toggle(){this.tree.toggle(this)}open(){this.tree.open(this)}openParents(){this.tree.openParents(this)}close(){this.tree.close(this)}submit(e){this.tree.submit(this,e)}reset(){this.tree.reset()}clone(){return new Za(Object.assign({},this))}edit(){return this.tree.edit(this)}}const Xa="__REACT_ARBORIST_INTERNAL_ROOT__";function Qa(e){var t;function n(t,r,i){const o=e.accessId(t),s=new Za({tree:e,data:t,level:r,parent:i,id:o,children:null,isDraggable:e.isDraggable(t),rowIndex:null}),a=e.accessChildren(t);return a&&(s.children=a.map((e=>n(e,r+1,s)))),s}const r=new Za({tree:e,id:Xa,data:{id:Xa},level:-1,parent:null,children:null,isDraggable:!0,rowIndex:null}),i=null!==(t=e.props.data)&&void 0!==t?t:[];return r.children=i.map((e=>n(e,0,r))),r}const ec={open:(e,t)=>({type:"VISIBILITY_OPEN",id:e,filtered:t}),close:(e,t)=>({type:"VISIBILITY_CLOSE",id:e,filtered:t}),toggle:(e,t)=>({type:"VISIBILITY_TOGGLE",id:e,filtered:t}),clear:e=>({type:"VISIBILITY_CLEAR",filtered:e})};function tc(e={},t){if("VISIBILITY_OPEN"===t.type)return Object.assign(Object.assign({},e),{[t.id]:!0});if("VISIBILITY_CLOSE"===t.type)return Object.assign(Object.assign({},e),{[t.id]:!1});if("VISIBILITY_TOGGLE"===t.type){const n=e[t.id];return Object.assign(Object.assign({},e),{[t.id]:!n})}return"VISIBILITY_CLEAR"===t.type?{}:e}const nc=e=>{var t;return{nodes:{open:{filtered:{},unfiltered:null!==(t=null==e?void 0:e.initialOpenState)&&void 0!==t?t:{}},focus:{id:null,treeFocused:!1},edit:{id:null},drag:{id:null,selectedIds:[],destinationParentId:null,destinationIndex:null},selection:{ids:new Set,anchor:null,mostRecent:null}},dnd:{cursor:{type:"none"},dragId:null,dragIds:[],parentId:null,index:-1}}},rc=e=>({type:"SELECTION_ONLY",id:Ma(e)}),ic=e=>({type:"SELECTION_ADD",ids:(Array.isArray(e)?e:[e]).map(Ma)}),oc=e=>({type:"SELECTION_REMOVE",ids:(Array.isArray(e)?e:[e]).map(Ma)}),sc=e=>Object.assign({type:"SELECTION_SET"},e),ac=e=>({type:"SELECTION_MOST_RECENT",id:null===e?null:Ma(e)}),cc=e=>({type:"SELECTION_ANCHOR",id:null===e?null:Ma(e)});const lc={cursor:e=>({type:"DND_CURSOR",cursor:e}),dragStart:(e,t)=>({type:"DND_DRAG_START",id:e,dragIds:t}),dragEnd:()=>({type:"DND_DRAG_END"}),hovering:(e,t)=>({type:"DND_HOVERING",parentId:e,index:t})};const uc={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},dc=e=>{if(!e)return{display:"none"};const{x:t,y:n}=e;return{transform:`translate(${t}px, ${n}px)`}},hc=e=>{if(!e)return{display:"none"};const{x:t,y:n}=e;return{transform:`translate(${t+10}px, ${n+10}px)`}};function fc({offset:e,mouse:t,id:n,dragIds:r,isDragging:i}){return l.jsxs(pc,{isDragging:i,children:[l.jsx(gc,{offset:e,children:l.jsx(yc,{id:n,dragIds:r})}),l.jsx(mc,{mouse:t,count:r.length})]})}const pc=m.memo((function(e){return e.isDragging?l.jsx("div",{style:uc,children:e.children}):null}));function gc(e){return l.jsx("div",{className:"row preview",style:dc(e.offset),children:e.children})}function mc(e){const{count:t,mouse:n}=e;return t>1?l.jsx("div",{className:"selected-count",style:hc(n),children:t}):null}const yc=m.memo((function(e){const t=ga(),n=t.get(e.id);return n?l.jsx(t.renderNode,{preview:!0,node:n,style:{paddingLeft:n.level*t.indent,opacity:.2,background:"transparent"},tree:t}):null}));var vc=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function bc(e,t){if(e.length!==t.length)return!1;for(var n=0;n0?Rc="positive-descending":(t.scrollLeft=1,Rc=0===t.scrollLeft?"negative":"positive-ascending"),document.body.removeChild(t),Rc}return Rc}var Cc=function(e,t){return e};function jc(e){var t,n=e.getItemOffset,r=e.getEstimatedTotalSize,i=e.getItemSize,o=e.getOffsetForIndexAndAlignment,s=e.getStartIndexForOffset,a=e.getStopIndexForStartIndex,c=e.initInstanceProps,l=e.shouldResetStyleCacheOnItemSizeChange,u=e.validateProps;return(t=function(e){var t,d;function h(t){var r;return(r=e.call(this,t)||this)._instanceProps=c(r.props,kt(r)),r._outerRef=void 0,r._resetIsScrollingTimeoutId=null,r.state={instance:kt(r),isScrolling:!1,scrollDirection:"forward",scrollOffset:"number"==typeof r.props.initialScrollOffset?r.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},r._callOnItemsRendered=void 0,r._callOnItemsRendered=xc((function(e,t,n,i){return r.props.onItemsRendered({overscanStartIndex:e,overscanStopIndex:t,visibleStartIndex:n,visibleStopIndex:i})})),r._callOnScroll=void 0,r._callOnScroll=xc((function(e,t,n){return r.props.onScroll({scrollDirection:e,scrollOffset:t,scrollUpdateWasRequested:n})})),r._getItemStyle=void 0,r._getItemStyle=function(e){var t,o=r.props,s=o.direction,a=o.itemSize,c=o.layout,u=r._getItemStyleCache(l&&a,l&&c,l&&s);if(u.hasOwnProperty(e))t=u[e];else{var d=n(r.props,e,r._instanceProps),h=i(r.props,e,r._instanceProps),f="horizontal"===s||"horizontal"===c,p="rtl"===s,g=f?d:0;u[e]=t={position:"absolute",left:p?void 0:g,right:p?g:void 0,top:f?0:d,height:f?"100%":h,width:f?h:"100%"}}return t},r._getItemStyleCache=void 0,r._getItemStyleCache=xc((function(e,t,n){return{}})),r._onScrollHorizontal=function(e){var t=e.currentTarget,n=t.clientWidth,i=t.scrollLeft,o=t.scrollWidth;r.setState((function(e){if(e.scrollOffset===i)return null;var t=r.props.direction,s=i;if("rtl"===t)switch(Dc()){case"negative":s=-i;break;case"positive-descending":s=o-n-i}return s=Math.max(0,Math.min(s,o-n)),{isScrolling:!0,scrollDirection:e.scrollOffset=t?e.call(null):i.id=requestAnimationFrame(r)}))})},r._resetIsScrolling=function(){r._resetIsScrollingTimeoutId=null,r.setState({isScrolling:!1},(function(){r._getItemStyleCache(-1,null)}))},r}d=e,(t=h).prototype=Object.create(d.prototype),t.prototype.constructor=t,wt(t,d),h.getDerivedStateFromProps=function(e,t){return Oc(e,t),u(e),null};var f=h.prototype;return f.scrollTo=function(e){e=Math.max(0,e),this.setState((function(t){return t.scrollOffset===e?null:{scrollDirection:t.scrollOffsetc.clientWidth?Sc():0:c.scrollHeight>c.clientHeight?Sc():0}this.scrollTo(o(this.props,e,t,s,this._instanceProps,a))},f.componentDidMount=function(){var e=this.props,t=e.direction,n=e.initialScrollOffset,r=e.layout;if("number"==typeof n&&null!=this._outerRef){var i=this._outerRef;"horizontal"===t||"horizontal"===r?i.scrollLeft=n:i.scrollTop=n}this._callPropsCallbacks()},f.componentDidUpdate=function(){var e=this.props,t=e.direction,n=e.layout,r=this.state,i=r.scrollOffset;if(r.scrollUpdateWasRequested&&null!=this._outerRef){var o=this._outerRef;if("horizontal"===t||"horizontal"===n)if("rtl"===t)switch(Dc()){case"negative":o.scrollLeft=-i;break;case"positive-ascending":o.scrollLeft=i;break;default:var s=o.clientWidth,a=o.scrollWidth;o.scrollLeft=a-s-i}else o.scrollLeft=i;else o.scrollTop=i}this._callPropsCallbacks()},f.componentWillUnmount=function(){null!==this._resetIsScrollingTimeoutId&&kc(this._resetIsScrollingTimeoutId)},f.render=function(){var e=this.props,t=e.children,n=e.className,i=e.direction,o=e.height,s=e.innerRef,a=e.innerElementType,c=e.innerTagName,l=e.itemCount,u=e.itemData,d=e.itemKey,h=void 0===d?Cc:d,f=e.layout,p=e.outerElementType,g=e.outerTagName,y=e.style,v=e.useIsScrolling,b=e.width,x=this.state.isScrolling,w="horizontal"===i||"horizontal"===f,k=w?this._onScrollHorizontal:this._onScrollVertical,T=this._getRangeToRender(),S=T[0],R=T[1],D=[];if(l>0)for(var C=S;C<=R;C++)D.push(m.createElement(t,{data:u,key:h(C,u),index:C,isScrolling:v?x:void 0,style:this._getItemStyle(C)}));var j=r(this.props,this._instanceProps);return m.createElement(p||g||"div",{className:n,onScroll:k,ref:this._outerRefSetter,style:nt({position:"relative",height:o,width:b,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:i},y)},m.createElement(a||c||"div",{children:D,ref:s,style:{height:w?"100%":j,pointerEvents:x?"none":void 0,width:w?j:"100%"}}))},f._callPropsCallbacks=function(){if("function"==typeof this.props.onItemsRendered&&this.props.itemCount>0){var e=this._getRangeToRender(),t=e[0],n=e[1],r=e[2],i=e[3];this._callOnItemsRendered(t,n,r,i)}if("function"==typeof this.props.onScroll){var o=this.state,s=o.scrollDirection,a=o.scrollOffset,c=o.scrollUpdateWasRequested;this._callOnScroll(s,a,c)}},f._getRangeToRender=function(){var e=this.props,t=e.itemCount,n=e.overscanCount,r=this.state,i=r.isScrolling,o=r.scrollDirection,c=r.scrollOffset;if(0===t)return[0,0,0,0];var l=s(this.props,c,this._instanceProps),u=a(this.props,l,c,this._instanceProps),d=i&&"backward"!==o?1:Math.max(1,n),h=i&&"forward"!==o?1:Math.max(1,n);return[Math.max(0,l-d),Math.max(0,Math.min(t-1,u+h)),l,u]},h}(m.PureComponent)).defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},t}var Oc=function(e,t){e.children,e.direction,e.height,e.layout,e.innerTagName,e.outerTagName,e.width,t.instance},Pc=jc({getItemOffset:function(e,t){return t*e.itemSize},getItemSize:function(e,t){return e.itemSize},getEstimatedTotalSize:function(e){var t=e.itemCount;return e.itemSize*t},getOffsetForIndexAndAlignment:function(e,t,n,r,i,o){var s=e.direction,a=e.height,c=e.itemCount,l=e.itemSize,u=e.layout,d=e.width,h="horizontal"===s||"horizontal"===u?d:a,f=Math.max(0,c*l-h),p=Math.min(f,t*l),g=Math.max(0,t*l-h+l+o);switch("smart"===n&&(n=r>=g-h&&r<=p+h?"auto":"center"),n){case"start":return p;case"end":return g;case"center":var m=Math.round(g+(p-g)/2);return mf+Math.floor(h/2)?f:m;default:return r>=g&&r<=p?r:r{e.currentTarget===e.target&&i.deselectAll()},children:[l.jsx(Ic,{}),n]}))})),Ic=()=>{const e=ga();return l.jsx("div",{style:{height:e.visibleNodes.length*e.rowHeight,width:"100%",position:"absolute",left:"0",right:"0"},children:l.jsx(Nc,{})})};const _c=m.forwardRef((function(e,t){var n,r,i,o,{style:s}=e,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i2?n-2:0),i=2;i0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{publishSource:!0},r=n.publishSource,i=void 0===r||r,o=n.clientOffset,s=n.getSourceClientOffset,a=e.getMonitor(),c=e.getRegistry();e.dispatch(Wc(o)),function(e,t,n){Lc(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach((function(e){Lc(n.getSource(e),"Expected sourceIds to be registered.")}))}(t,a,c);var l=function(e,t){for(var n=null,r=e.length-1;r>=0;r--)if(t.canDragSource(e[r])){n=e[r];break}return n}(t,a);if(null!==l){var u=null;if(o){if(!s)throw new Error("getSourceClientOffset must be defined");!function(e){Lc("function"==typeof e,"When clientOffset is provided, getSourceClientOffset must be a function.")}(s),u=s(l)}e.dispatch(Wc(o,u));var d=c.getSource(l).beginDrag(a,l);if(null!=d){!function(e){Lc(Kc(e),"Item must be an object.")}(d),c.pinSource(l);var h=c.getSourceType(l);return{type:Hc,payload:{itemType:h,item:d,sourceId:l,clientOffset:o||null,sourceClientOffset:u||null,isSourcePublic:!!i}}}}else e.dispatch(Gc)}}function Yc(e){return function(){if(e.getMonitor().isDragging())return{type:$c}}}function Zc(e,t){return null===t?null===e:Array.isArray(e)?e.some((function(e){return e===t})):e===t}function Xc(e){return function(t){var n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).clientOffset;!function(e){Lc(Array.isArray(e),"Expected targetIds to be an array.")}(t);var r=t.slice(0),i=e.getMonitor(),o=e.getRegistry();return function(e,t,n){Lc(t.isDragging(),"Cannot call hover while not dragging."),Lc(!t.didDrop(),"Cannot call hover after drop.");for(var r=0;r=0;r--){var i=e[r];Zc(t.getTargetType(i),n)||e.splice(r,1)}}(r,o,i.getItemType()),function(e,t,n){e.forEach((function(e){n.getTarget(e).hover(t,e)}))}(r,i,o),{type:zc,payload:{targetIds:r,clientOffset:n||null}}}}function Qc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function el(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},n=e.getMonitor(),r=e.getRegistry();!function(e){Lc(e.isDragging(),"Cannot call drop while not dragging."),Lc(!e.didDrop(),"Cannot call drop twice during one drag operation.")}(n);var i=function(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}(n);i.forEach((function(i,o){var s=function(e,t,n,r){var i=n.getTarget(e),o=i?i.drop(r,e):void 0;(function(e){Lc(void 0===e||Kc(e),"Drop result must either be an object or undefined.")})(o),void 0===o&&(o=0===t?{}:r.getDropResult());return o}(i,o,r,n),a={type:Bc,payload:{dropResult:el(el({},t),s)}};e.dispatch(a)}))}}function rl(e){return function(){var t=e.getMonitor(),n=e.getRegistry();!function(e){Lc(e.isDragging(),"Cannot call endDrag while not dragging.")}(t);var r=t.getSourceId();null!=r&&(n.getSource(r,!0).endDrag(t,r),n.unpinSource());return{type:Uc}}}function il(e,t,n){return t&&function(e,t){for(var n=0;n0;r.backend&&(e&&!r.isSetUp?(r.backend.setup(),r.isSetUp=!0):!e&&r.isSetUp&&(r.backend.teardown(),r.isSetUp=!1))})),this.store=t,this.monitor=n,t.subscribe(this.handleRefCountChange)}return il(e,[{key:"receiveBackend",value:function(e){this.backend=e}},{key:"getMonitor",value:function(){return this.monitor}},{key:"getBackend",value:function(){return this.backend}},{key:"getRegistry",value:function(){return this.monitor.registry}},{key:"getActions",value:function(){var e=this,t=this.store.dispatch;var n=function(e){return{beginDrag:Jc(e),publishDragSource:Yc(e),hover:Xc(e),drop:nl(e),endDrag:rl(e)}}(this);return Object.keys(n).reduce((function(r,i){var o,s=n[i];return r[i]=(o=s,function(){for(var n=arguments.length,r=new Array(n),i=0;i0&&void 0!==arguments[0]?arguments[0]:ml,r=arguments.length>1?arguments[1]:void 0,i=r.payload;switch(r.type){case Fc:case Hc:return{initialSourceClientOffset:i.sourceClientOffset,initialClientOffset:i.clientOffset,clientOffset:i.clientOffset};case zc:return e=n.clientOffset,t=i.clientOffset,!e&&!t||e&&t&&e.x===t.x&&e.y===t.y?n:pl(pl({},n),{},{clientOffset:i.clientOffset});case Uc:case Bc:return ml;default:return n}}var vl="dnd-core/ADD_SOURCE",bl="dnd-core/ADD_TARGET",xl="dnd-core/REMOVE_SOURCE",wl="dnd-core/REMOVE_TARGET";function kl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Tl(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:Rl,r=arguments.length>1?arguments[1]:void 0,i=r.payload;switch(r.type){case Hc:return Tl(Tl({},n),{},{itemType:i.itemType,item:i.item,sourceId:i.sourceId,isSourcePublic:i.isSourcePublic,dropResult:null,didDrop:!1});case $c:return Tl(Tl({},n),{},{isSourcePublic:!0});case zc:return Tl(Tl({},n),{},{targetIds:i.targetIds});case wl:return-1===n.targetIds.indexOf(i.targetId)?n:Tl(Tl({},n),{},{targetIds:(e=n.targetIds,t=i.targetId,e.filter((function(e){return e!==t})))});case Bc:return Tl(Tl({},n),{},{dropResult:i.dropResult,didDrop:!0,targetIds:[]});case Uc:return Tl(Tl({},n),{},{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return n}}function Cl(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;switch((arguments.length>1?arguments[1]:void 0).type){case vl:case bl:return e+1;case xl:case wl:return e-1;default:return e}}var jl=[],Ol=[];function Pl(){var e=arguments.length>1?arguments[1]:void 0;switch(e.type){case zc:break;case vl:case bl:case wl:case xl:return jl;default:return Ol}var t=e.payload,n=t.targetIds,r=void 0===n?[]:n,i=t.prevTargetIds,o=void 0===i?[]:i,s=function(e,t){var n=new Map,r=function(e){n.set(e,n.has(e)?n.get(e)+1:1)};e.forEach(r),t.forEach(r);var i=[];return n.forEach((function(e,t){1===e&&i.push(t)})),i}(r,o),a=s.length>0||!function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:hl;if(e.length!==t.length)return!1;for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:0)+1}function El(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Il(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:Pl(r.dirtyHandlerIds,{type:i.type,payload:Il(Il({},i.payload),{},{prevTargetIds:(e=r,t="dragOperation.targetIds",n=[],t.split(".").reduce((function(e,t){return e&&e[t]?e[t]:n||null}),e))})}),dragOffset:yl(r.dragOffset,i),refCount:Cl(r.refCount,i),dragOperation:Dl(r.dragOperation,i),stateId:Nl(r.stateId)}}function ql(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Al(e,t,n){return t&&function(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{handlerIds:void 0}).handlerIds;Lc("function"==typeof e,"listener must be a function."),Lc(void 0===n||Array.isArray(n),"handlerIds, when specified, must be an array of strings.");var r=this.store.getState().stateId;return this.store.subscribe((function(){var i=t.store.getState(),o=i.stateId;try{var s=o===r||o===r+1&&!function(e,t){return e!==jl&&(e===Ol||void 0===t||(n=e,t.filter((function(e){return n.indexOf(e)>-1}))).length>0);var n}(i.dirtyHandlerIds,n);s||e()}finally{r=o}}))}},{key:"subscribeToOffsetChange",value:function(e){var t=this;Lc("function"==typeof e,"listener must be a function.");var n=this.store.getState().dragOffset;return this.store.subscribe((function(){var r=t.store.getState().dragOffset;r!==n&&(n=r,e())}))}},{key:"canDragSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e);return Lc(t,"Expected to find a valid source. sourceId=".concat(e)),!this.isDragging()&&t.canDrag(this,e)}},{key:"canDropOnTarget",value:function(e){if(!e)return!1;var t=this.registry.getTarget(e);return Lc(t,"Expected to find a valid target. targetId=".concat(e)),!(!this.isDragging()||this.didDrop())&&(Zc(this.registry.getTargetType(e),this.getItemType())&&t.canDrop(this,e))}},{key:"isDragging",value:function(){return Boolean(this.getItemType())}},{key:"isDraggingSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e,!0);return Lc(t,"Expected to find a valid source. sourceId=".concat(e)),!(!this.isDragging()||!this.isSourcePublic())&&(this.registry.getSourceType(e)===this.getItemType()&&t.isDragging(this,e))}},{key:"isOverTarget",value:function(e){if(!e)return!1;var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shallow:!1}).shallow;if(!this.isDragging())return!1;var n=this.registry.getTargetType(e),r=this.getItemType();if(r&&!Zc(n,r))return!1;var i=this.getTargetIds();if(!i.length)return!1;var o=i.indexOf(e);return t?o===i.length-1:o>-1}},{key:"getItemType",value:function(){return this.store.getState().dragOperation.itemType}},{key:"getItem",value:function(){return this.store.getState().dragOperation.item}},{key:"getSourceId",value:function(){return this.store.getState().dragOperation.sourceId}},{key:"getTargetIds",value:function(){return this.store.getState().dragOperation.targetIds}},{key:"getDropResult",value:function(){return this.store.getState().dragOperation.dropResult}},{key:"didDrop",value:function(){return this.store.getState().dragOperation.didDrop}},{key:"isSourcePublic",value:function(){return Boolean(this.store.getState().dragOperation.isSourcePublic)}},{key:"getInitialClientOffset",value:function(){return this.store.getState().dragOffset.initialClientOffset}},{key:"getInitialSourceClientOffset",value:function(){return this.store.getState().dragOffset.initialSourceClientOffset}},{key:"getClientOffset",value:function(){return this.store.getState().dragOffset.clientOffset}},{key:"getSourceClientOffset",value:function(){return e=this.store.getState().dragOffset,r=e.clientOffset,i=e.initialClientOffset,o=e.initialSourceClientOffset,r&&i&&o?ql((n=o,{x:(t=r).x+n.x,y:t.y+n.y}),i):null;var e,t,n,r,i,o}},{key:"getDifferenceFromInitialOffset",value:function(){return e=this.store.getState().dragOffset,t=e.clientOffset,n=e.initialClientOffset,t&&n?ql(t,n):null;var e,t,n}}]),e}(),Hl=0;function $l(e){return($l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function zl(e,t){t&&Array.isArray(e)?e.forEach((function(e){return zl(e,!1)})):Lc("string"==typeof e||"symbol"===$l(e),t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}const Bl="undefined"!=typeof global?global:self,Ul=Bl.MutationObserver||Bl.WebKitMutationObserver;function Wl(e){return function(){const t=setTimeout(r,0),n=setInterval(r,50);function r(){clearTimeout(t),clearInterval(n),e()}}}const Vl="function"==typeof Ul?function(e){let t=1;const n=new Ul(e),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(){t=-t,r.data=t}}:Wl;class Kl{call(){try{this.task&&this.task()}catch(e){this.onError(e)}finally{this.task=null,this.release(this)}}constructor(e,t){this.onError=e,this.release=t,this.task=null}}const Gl=new class{enqueueTask(e){const{queue:t,requestFlush:n}=this;t.length||(n(),this.flushing=!0),t[t.length]=e}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{const{queue:e}=this;for(;this.indexthis.capacity){for(let t=0,n=e.length-this.index;t{this.pendingErrors.push(e),this.requestErrorThrow()},this.requestFlush=Vl(this.flush),this.requestErrorThrow=Wl((()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()}))}},Jl=new class{create(e){const t=this.freeTasks,n=t.length?t.pop():new Kl(this.onError,(e=>t[t.length]=e));return n.task=e,n}constructor(e){this.onError=e,this.freeTasks=[]}}(Gl.registerPendingError);function Yl(e,t,n){return t&&function(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n1&&void 0!==arguments[1]&&arguments[1];return Lc(this.isSourceId(e),"Expected a valid source ID."),t&&e===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(e)}},{key:"getTarget",value:function(e){return Lc(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}},{key:"getSourceType",value:function(e){return Lc(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}},{key:"getTargetType",value:function(e){return Lc(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}},{key:"isSourceId",value:function(e){return tu(e)===Mc.SOURCE}},{key:"isTargetId",value:function(e){return tu(e)===Mc.TARGET}},{key:"removeSource",value:function(e){var t,n=this;Lc(this.getSource(e),"Expected an existing source."),this.store.dispatch(function(e){return{type:xl,payload:{sourceId:e}}}(e)),t=function(){n.dragSources.delete(e),n.types.delete(e)},Gl.enqueueTask(Jl.create(t))}},{key:"removeTarget",value:function(e){Lc(this.getTarget(e),"Expected an existing target."),this.store.dispatch(function(e){return{type:wl,payload:{targetId:e}}}(e)),this.dropTargets.delete(e),this.types.delete(e)}},{key:"pinSource",value:function(e){var t=this.getSource(e);Lc(t,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=t}},{key:"unpinSource",value:function(){Lc(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}},{key:"addHandler",value:function(e,t,n){var r=eu(e);return this.types.set(r,t),e===Mc.SOURCE?this.dragSources.set(r,n):e===Mc.TARGET&&this.dropTargets.set(r,n),r}}]),e}();function iu(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=function(e){var t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__;return dl(Ml,e&&t&&t({name:"dnd-core",instanceId:"dnd-core"}))}(arguments.length>3&&void 0!==arguments[3]&&arguments[3]),i=new Fl(r,new ru(r)),o=new sl(r,i),s=e(o,t,n);return o.receiveBackend(s),o}var ou=["children"];function su(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,i,o=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);s=!0);}catch(Ch){a=!0,i=Ch}finally{try{s||null==n.return||n.return()}finally{if(a)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return au(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return au(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function au(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var lu=0,uu=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__"),du=m.memo((function(e){var t=e.children,n=function(e){if("manager"in e){return[{dragDropManager:e.manager},!1]}var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:hu(),n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=t;i[uu]||(i[uu]={dragDropManager:iu(e,t,n,r)});return i[uu]}(e.backend,e.context,e.options,e.debugMode),n=!e.context;return[t,n]}(cu(e,ou)),r=su(n,2),i=r[0],o=r[1];return m.useEffect((function(){if(o){var e=hu();return++lu,function(){0==--lu&&(e[uu]=null)}}}),[]),l.jsx(Ac.Provider,Object.assign({value:i},{children:t}),void 0)}));function hu(){return"undefined"!=typeof global?global:window}function fu(e,t,n){return t&&function(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!m.isValidElement(t)){var r=t;return e(r,n),r}var i=t;return function(e){if("string"!=typeof e.type){var t=e.type.displayName||e.type.name||"the component";throw new Error("Only native element nodes can now be passed to React DnD connectors."+"You can either wrap ".concat(t," into a
    , or turn it into a ")+"drag source or a drop target itself.")}}(i),function(e,t){var n=e.ref;return Lc("string"!=typeof n,"Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a or
    . Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"),n?m.cloneElement(e,{ref:function(e){Su(n,e),Su(t,e)}}):m.cloneElement(e,{ref:t})}(i,n?function(t){return e(t,n)}:e)}}function Tu(e){var t={};return Object.keys(e).forEach((function(n){var r=e[n];if(n.endsWith("Ref"))t[n]=e[n];else{var i=ku(r);t[n]=function(){return i}}})),t}function Su(e,t){"function"==typeof e?e(t):e.current=t}function Ru(e){return(Ru="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Du(e){return null!==e&&"object"===Ru(e)&&Object.prototype.hasOwnProperty.call(e,"current")}function Cu(e,t,n,r){var i=void 0;if(void 0!==i)return!!i;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var o=Object.keys(e),s=Object.keys(t);if(o.length!==s.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(t),c=0;ce.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0}},{key:"leave",value:function(e){var t,n,r=this.entered.length;return this.entered=(t=this.entered.filter(this.isNodeInDocument),n=e,t.filter((function(e){return e!==n}))),r>0&&0===this.entered.length}},{key:"reset",value:function(){this.entered=[]}}]),e}(),gd=dd((function(){return/firefox/i.test(navigator.userAgent)})),md=dd((function(){return Boolean(window.safari)}));function yd(e,t,n){return t&&function(e,t){for(var n=0;ne))return n[a];l=a-1}}var d=e-t[s=Math.max(0,l)],h=d*d;return n[s]+r[s]*d+i[s]*h+o[s]*d*h}}]),e}();function xd(e){var t=1===e.nodeType?e:e.parentElement;if(!t)return null;var n=t.getBoundingClientRect(),r=n.top;return{x:n.left,y:r}}function wd(e){return{x:e.clientX,y:e.clientY}}function kd(e,t,n,r,i){var o,s,a,c="IMG"===(o=t).nodeName&&(gd()||!(null!==(s=document.documentElement)&&void 0!==s&&s.contains(o))),l=xd(c?e:t),u={x:n.x-l.x,y:n.y-l.y},d=e.offsetWidth,h=e.offsetHeight,f=r.anchorX,p=r.anchorY,g=function(e,t,n,r){var i=e?t.width:n,o=e?t.height:r;return md()&&e&&(o/=window.devicePixelRatio,i/=window.devicePixelRatio),{dragPreviewWidth:i,dragPreviewHeight:o}}(c,t,d,h),m=g.dragPreviewWidth,y=g.dragPreviewHeight,v=i.offsetX,b=i.offsetY,x=0===b||b;return{x:0===v||v?v:new bd([0,.5,1],[u.x,u.x/d*m,u.x+m-d]).interpolate(f),y:x?b:(a=new bd([0,.5,1],[u.y,u.y/h*y,u.y+y-h]).interpolate(p),md()&&c&&(a+=(window.devicePixelRatio-1)*y),a)}}var Td="__NATIVE_FILE__",Sd="__NATIVE_URL__",Rd="__NATIVE_TEXT__",Dd="__NATIVE_HTML__";const Cd=Object.freeze(Object.defineProperty({__proto__:null,FILE:Td,HTML:Dd,TEXT:Rd,URL:Sd},Symbol.toStringTag,{value:"Module"}));function jd(e,t,n){var r=t.reduce((function(t,n){return t||e.getData(n)}),"");return null!=r?r:n}var Od;function Pd(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Nd=(Pd(Od={},Td,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items},dataTransfer:function(e){return e}},matchesTypes:["Files"]}),Pd(Od,Dd,{exposeProperties:{html:function(e,t){return jd(e,t,"")},dataTransfer:function(e){return e}},matchesTypes:["Html","text/html"]}),Pd(Od,Sd,{exposeProperties:{urls:function(e,t){return jd(e,t,"").split("\n")},dataTransfer:function(e){return e}},matchesTypes:["Url","text/uri-list"]}),Pd(Od,Rd,{exposeProperties:{text:function(e,t){return jd(e,t,"")},dataTransfer:function(e){return e}},matchesTypes:["Text","text/plain"]}),Od);function Ed(e,t,n){return t&&function(e,t){for(var n=0;n-1}))}))[0]||null}function qd(e,t,n){return t&&function(e,t){for(var n=0;n0&&i.actions.hover(t,{clientOffset:wd(e)}),t.some((function(e){return i.monitor.canDropOnTarget(e)}))&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=i.getCurrentDropEffect())))})),zd(this,"handleTopDragOverCapture",(function(){i.dragOverTargetIds=[]})),zd(this,"handleTopDragOver",(function(e){var t=i.dragOverTargetIds;if(i.dragOverTargetIds=[],!i.monitor.isDragging())return e.preventDefault(),void(e.dataTransfer&&(e.dataTransfer.dropEffect="none"));i.altKeyPressed=e.altKey,i.lastClientOffset=wd(e),null===i.hoverRafId&&"undefined"!=typeof requestAnimationFrame&&(i.hoverRafId=requestAnimationFrame((function(){i.monitor.isDragging()&&i.actions.hover(t||[],{clientOffset:i.lastClientOffset}),i.hoverRafId=null}))),(t||[]).some((function(e){return i.monitor.canDropOnTarget(e)}))?(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=i.getCurrentDropEffect())):i.isDraggingNativeItem()?e.preventDefault():(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none"))})),zd(this,"handleTopDragLeaveCapture",(function(e){i.isDraggingNativeItem()&&e.preventDefault(),i.enterLeaveCounter.leave(e.target)&&i.isDraggingNativeItem()&&setTimeout((function(){return i.endDragNativeItem()}),0)})),zd(this,"handleTopDropCapture",(function(e){var t;(i.dropTargetIds=[],i.isDraggingNativeItem())?(e.preventDefault(),null===(t=i.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer)):Md(e.dataTransfer)&&e.preventDefault();i.enterLeaveCounter.reset()})),zd(this,"handleTopDrop",(function(e){var t=i.dropTargetIds;i.dropTargetIds=[],i.actions.hover(t,{clientOffset:wd(e)}),i.actions.drop({dropEffect:i.getCurrentDropEffect()}),i.isDraggingNativeItem()?i.endDragNativeItem():i.monitor.isDragging()&&i.actions.endDrag()})),zd(this,"handleSelectStart",(function(e){var t=e.target;"function"==typeof t.dragDrop&&("INPUT"===t.tagName||"SELECT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable||(e.preventDefault(),t.dragDrop()))})),this.options=new Ld(n,r),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.registry=t.getRegistry(),this.enterLeaveCounter=new pd(this.isNodeInDocument)}return $d(e,[{key:"profile",value:function(){var e,t;return{sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,sourceNodeOptions:this.sourceNodeOptions.size,sourceNodes:this.sourceNodes.size,dragStartSourceIds:(null===(e=this.dragStartSourceIds)||void 0===e?void 0:e.length)||0,dropTargetIds:this.dropTargetIds.length,dragEnterTargetIds:this.dragEnterTargetIds.length,dragOverTargetIds:(null===(t=this.dragOverTargetIds)||void 0===t?void 0:t.length)||0}}},{key:"window",get:function(){return this.options.window}},{key:"document",get:function(){return this.options.document}},{key:"rootElement",get:function(){return this.options.rootElement}},{key:"setup",value:function(){var e=this.rootElement;if(void 0!==e){if(e.__isReactDndBackendSetUp)throw new Error("Cannot have two HTML5 backends at the same time.");e.__isReactDndBackendSetUp=!0,this.addEventListeners(e)}}},{key:"teardown",value:function(){var e,t=this.rootElement;void 0!==t&&(t.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.rootElement),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId&&(null===(e=this.window)||void 0===e||e.cancelAnimationFrame(this.asyncEndDragFrameId)))}},{key:"connectDragPreview",value:function(e,t,n){var r=this;return this.sourcePreviewNodeOptions.set(e,n),this.sourcePreviewNodes.set(e,t),function(){r.sourcePreviewNodes.delete(e),r.sourcePreviewNodeOptions.delete(e)}}},{key:"connectDragSource",value:function(e,t,n){var r=this;this.sourceNodes.set(e,t),this.sourceNodeOptions.set(e,n);var i=function(t){return r.handleDragStart(t,e)},o=function(e){return r.handleSelectStart(e)};return t.setAttribute("draggable","true"),t.addEventListener("dragstart",i),t.addEventListener("selectstart",o),function(){r.sourceNodes.delete(e),r.sourceNodeOptions.delete(e),t.removeEventListener("dragstart",i),t.removeEventListener("selectstart",o),t.setAttribute("draggable","false")}}},{key:"connectDropTarget",value:function(e,t){var n=this,r=function(t){return n.handleDragEnter(t,e)},i=function(t){return n.handleDragOver(t,e)},o=function(t){return n.handleDrop(t,e)};return t.addEventListener("dragenter",r),t.addEventListener("dragover",i),t.addEventListener("drop",o),function(){t.removeEventListener("dragenter",r),t.removeEventListener("dragover",i),t.removeEventListener("drop",o)}}},{key:"addEventListeners",value:function(e){e.addEventListener&&(e.addEventListener("dragstart",this.handleTopDragStart),e.addEventListener("dragstart",this.handleTopDragStartCapture,!0),e.addEventListener("dragend",this.handleTopDragEndCapture,!0),e.addEventListener("dragenter",this.handleTopDragEnter),e.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.addEventListener("dragover",this.handleTopDragOver),e.addEventListener("dragover",this.handleTopDragOverCapture,!0),e.addEventListener("drop",this.handleTopDrop),e.addEventListener("drop",this.handleTopDropCapture,!0))}},{key:"removeEventListeners",value:function(e){e.removeEventListener&&(e.removeEventListener("dragstart",this.handleTopDragStart),e.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),e.removeEventListener("dragend",this.handleTopDragEndCapture,!0),e.removeEventListener("dragenter",this.handleTopDragEnter),e.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.removeEventListener("dragover",this.handleTopDragOver),e.removeEventListener("dragover",this.handleTopDragOverCapture,!0),e.removeEventListener("drop",this.handleTopDrop),e.removeEventListener("drop",this.handleTopDropCapture,!0))}},{key:"getCurrentSourceNodeOptions",value:function(){var e=this.monitor.getSourceId(),t=this.sourceNodeOptions.get(e);return Hd({dropEffect:this.altKeyPressed?"copy":"move"},t||{})}},{key:"getCurrentDropEffect",value:function(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}},{key:"getCurrentSourcePreviewNodeOptions",value:function(){var e=this.monitor.getSourceId();return Hd({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}},{key:"isDraggingNativeItem",value:function(){var e=this.monitor.getItemType();return Object.keys(Cd).some((function(t){return Cd[t]===e}))}},{key:"beginDragNativeItem",value:function(e,t){this.clearCurrentDragSourceNode(),this.currentNativeSource=function(e,t){var n=new _d(Nd[e]);return n.loadDataTransfer(t),n}(e,t),this.currentNativeHandle=this.registry.addSource(e,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}},{key:"setCurrentDragSourceNode",value:function(e){var t=this;this.clearCurrentDragSourceNode(),this.currentDragSourceNode=e;this.mouseMoveTimeoutTimer=setTimeout((function(){var e;return null===(e=t.rootElement)||void 0===e?void 0:e.addEventListener("mousemove",t.endDragIfSourceWasRemovedFromDOM,!0)}),1e3)}},{key:"clearCurrentDragSourceNode",value:function(){if(this.currentDragSourceNode){var e;if(this.currentDragSourceNode=null,this.rootElement)null===(e=this.window)||void 0===e||e.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0);return this.mouseMoveTimeoutTimer=null,!0}return!1}},{key:"handleDragStart",value:function(e,t){e.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(t))}},{key:"handleDragEnter",value:function(e,t){this.dragEnterTargetIds.unshift(t)}},{key:"handleDragOver",value:function(e,t){null===this.dragOverTargetIds&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(t)}},{key:"handleDrop",value:function(e,t){this.dropTargetIds.unshift(t)}}]),e}();var Wd=function(e,t,n){return new Ud(e,t,n)};function Vd(e){const t=ga(),n=t.selectedIds,[r,i,o]=ed((()=>({canDrag:()=>e.isDraggable,type:"NODE",item:()=>{const r=t.isSelected(e.id)?Array.from(n):[e.id];return t.dispatch(lc.dragStart(e.id,r)),{id:e.id}},end:()=>{t.hideCursor();let{parentId:e,index:n,dragIds:r}=t.state.dnd;t.canDrop()&&(qa(t.props.onMove,{dragIds:r,parentId:e===Xa?null:e,index:null===n?0:n,dragNodes:t.dragNodes,parentNode:t.get(e)}),t.open(e)),t.dispatch(lc.dragEnd())}})),[n,e]);return m.useEffect((()=>{o((Bd||((Bd=new Image).src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),Bd))}),[o]),i}function Kd(e,t){return{parentId:e||null,index:t}}function Gd(e,t){return{type:"line",index:e,level:t}}function Jd(e,t){var n;let r=e;for(;r.parent&&r.level>t;)r=r.parent;return{parentId:(null===(n=r.parent)||void 0===n?void 0:n.id)||null,index:Ra(r)+1}}function Yd(e){var t;const n=function(e,t){const n=e.getBoundingClientRect(),r=t.x-Math.round(n.x),i=t.y-Math.round(n.y),o=n.height,s=ic&&ic.level?{drop:Kd(c.id,0),cursor:Gd(c.rowIndex+1,e)}:{drop:Jd(c,e),cursor:Gd(c.rowIndex+1,e)}}return{drop:Kd(null==c?void 0:c.id,0),cursor:Gd(c.rowIndex+1,c.level+1)}}const Zd=s.memo((function({index:e,style:t}){ba(),function(){const e=m.useContext(ma);if(null===e)throw new Error("Provide a NodesContext")}();const n=ga(),r=function(e){const t=ga(),n=t.at(e);if(!n)throw new Error(`Could not find node for index: ${e}`);return m.useMemo((()=>{const r=n.clone();return t.visibleNodes[e]=r,r}),[...Object.values(n.state),n])}(e),i=m.useRef(null),o=Vd(r),s=function(e,t){const n=ga(),[r,i]=cd((()=>({accept:"NODE",canDrop:()=>n.canDrop(),hover:(r,i)=>{const o=i.getClientOffset();if(!e.current||!o)return;const{cursor:s,drop:a}=Yd({element:e.current,offset:o,indent:n.indent,node:t,prevNode:t.prev,nextNode:t.next});a&&n.dispatch(lc.hovering(a.parentId,a.index)),i.canDrop()?s&&n.showCursor(s):n.hideCursor()},drop:(e,t)=>{if(!t.canDrop())return null}})),[t,e.current,n.props]);return i}(i,r),a=m.useCallback((e=>{i.current=e,s(e)}),[s]),c=n.indent*r.level,u=m.useMemo((()=>({paddingLeft:c})),[c]),d=m.useMemo((()=>{var e,r;return Object.assign(Object.assign({},t),{top:parseFloat(t.top)+(null!==(r=null!==(e=n.props.padding)&&void 0!==e?e:n.props.paddingTop)&&void 0!==r?r:0)})}),[t,n.props.padding,n.props.paddingTop]),h={role:"treeitem","aria-level":r.level+1,"aria-selected":r.isSelected,style:d,tabIndex:-1,className:n.props.rowClassName};m.useEffect((()=>{var e;!r.isEditing&&r.isFocused&&(null===(e=i.current)||void 0===e||e.focus({preventScroll:!0}))}),[r.isEditing,r.isFocused,i.current]);const f=n.renderNode,p=n.renderRow;return l.jsx(p,{node:r,innerRef:a,attrs:h,children:l.jsx(f,{node:r,tree:n,style:u,dragHandle:o})})}));let Xd="",Qd=null;function eh(){ba();const e=ga();return l.jsx("div",{role:"tree",style:{height:e.height,width:e.width,minHeight:0,minWidth:0},onContextMenu:e.props.onContextMenu,onClick:e.props.onClick,tabIndex:0,onFocus:t=>{t.currentTarget.contains(t.relatedTarget)||e.onFocus()},onBlur:t=>{t.currentTarget.contains(t.relatedTarget)||e.onBlur()},onKeyDown:t=>{var n;if(e.isEditing)return;if("Backspace"===t.key){if(!e.props.onDelete)return;const t=Array.from(e.selectedIds);if(t.length>1){let n=e.mostRecentNode;for(;n&&n.isSelected;)n=n.nextSibling;n||(n=e.lastNode),e.focus(n,{scroll:!1}),e.delete(Array.from(t))}else{const t=e.focusedNode;if(t){const n=t.nextSibling,r=t.parent;e.focus(n||r,{scroll:!1}),e.delete(t)}}return}if("Tab"===t.key&&!t.shiftKey)return t.preventDefault(),void ja(t.currentTarget);if("Tab"===t.key&&t.shiftKey)return t.preventDefault(),void Oa(t.currentTarget);if("ArrowDown"===t.key){t.preventDefault();const n=e.nextNode;if(t.metaKey)return e.select(e.focusedNode),void e.activate(e.focusedNode);if(!t.shiftKey||e.props.disableMultiSelection)return void e.focus(n);{if(!n)return;const t=e.focusedNode;return void(t?t.isSelected?e.selectContiguous(n):e.selectMulti(n):e.focus(e.firstNode))}}if("ArrowUp"===t.key){t.preventDefault();const n=e.prevNode;if(!t.shiftKey||e.props.disableMultiSelection)return void e.focus(n);{if(!n)return;const t=e.focusedNode;return void(t?t.isSelected?e.selectContiguous(n):e.selectMulti(n):e.focus(e.lastNode))}}if("ArrowRight"===t.key){const t=e.focusedNode;if(!t)return;return void(t.isInternal&&t.isOpen?e.focus(e.nextNode):t.isInternal&&e.open(t.id))}if("ArrowLeft"===t.key){const t=e.focusedNode;if(!t||t.isRoot)return;return void(t.isInternal&&t.isOpen?e.close(t.id):(null===(n=t.parent)||void 0===n?void 0:n.isRoot)||e.focus(t.parent))}if("a"===t.key&&t.metaKey&&!e.props.disableMultiSelection)return t.preventDefault(),void e.selectAll();if("a"===t.key&&!t.metaKey&&e.props.onCreate)return void e.createLeaf();if("A"===t.key&&!t.metaKey){if(!e.props.onCreate)return;return void e.createInternal()}if("Home"===t.key)return t.preventDefault(),void e.focus(e.firstNode);if("End"===t.key)return t.preventDefault(),void e.focus(e.lastNode);if("Enter"===t.key){const t=e.focusedNode;if(!t)return;if(!t.isEditable||!e.props.onRename)return;return void setTimeout((()=>{t&&e.edit(t)}))}if(" "===t.key){t.preventDefault();const n=e.focusedNode;if(!n)return;return void(n.isLeaf?(n.select(),n.activate()):n.toggle())}if("*"===t.key){const t=e.focusedNode;if(!t)return;return void e.openSiblings(t)}if("PageUp"===t.key)return t.preventDefault(),void e.pageUp();"PageDown"===t.key&&(t.preventDefault(),e.pageDown()),clearTimeout(Qd),Xd+=t.key,Qd=setTimeout((()=>{Xd=""}),600);const r=e.visibleNodes.find((e=>{const t=e.data.name;return"string"==typeof t&&t.toLowerCase().startsWith(Xd)}));r&&e.focus(r.id)},children:l.jsx(Pc,{className:e.props.className,outerRef:e.listEl,itemCount:e.visibleNodes.length,height:e.height,width:e.width,itemSize:e.rowHeight,overscanCount:e.overscanCount,itemKey:t=>{var n;return(null===(n=e.visibleNodes[t])||void 0===n?void 0:n.id)||t},outerElementType:Ec,innerElementType:_c,onScroll:e.props.onScroll,onItemsRendered:e.onItemsRendered.bind(e),ref:e.list,children:Zd})})}function th(e){return e.isFiltered?function(e,t){const n={},r=[];function i(e){if(!e.isRoot&&t(e)){n[e.id]=!0;let t=e.parent;for(;t;)n[t.id]=!0,t=t.parent}if(e.children)for(let t of e.children)i(t)}function o(e){var t;e.level>=0&&n[e.id]&&r.push(e),e.isOpen&&(null===(t=e.children)||void 0===t||t.forEach(o))}return i(e),o(e),r.forEach(nh),r}(e.root,e.isMatch.bind(e)):function(e){const t=[];function n(e){var r;e.level>=0&&t.push(e),e.isOpen&&(null===(r=e.children)||void 0===r||r.forEach(n))}return n(e),t.forEach(nh),t}(e.root)}function nh(e,t){e.rowIndex=t}const rh=e=>e.reduce(((e,t,n)=>(e[t.id]=n,e)),{});var ih=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(t){o(t)}}function a(e){try{c(r.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};const{safeRun:oh,identify:sh,identifyNull:ah}=Ha;class ch{constructor(e,t,n,r){this.store=e,this.props=t,this.list=n,this.listEl=r,this.visibleStartIndex=0,this.visibleStopIndex=0,this.root=Qa(this),this.visibleNodes=th(this),this.idToIndex=rh(this.visibleNodes)}update(e){this.props=e,this.root=Qa(this),this.visibleNodes=th(this),this.idToIndex=rh(this.visibleNodes)}dispatch(e){return this.store.dispatch(e)}get state(){return this.store.getState()}get openState(){return this.state.nodes.open.unfiltered}get width(){var e;return null!==(e=this.props.width)&&void 0!==e?e:300}get height(){var e;return null!==(e=this.props.height)&&void 0!==e?e:500}get indent(){var e;return null!==(e=this.props.indent)&&void 0!==e?e:24}get rowHeight(){var e;return null!==(e=this.props.rowHeight)&&void 0!==e?e:24}get overscanCount(){var e;return null!==(e=this.props.overscanCount)&&void 0!==e?e:1}get searchTerm(){return(this.props.searchTerm||"").trim()}get matchFn(){var e;const t=null!==(e=this.props.searchMatch)&&void 0!==e?e:(e,t)=>JSON.stringify(Object.values(e.data)).toLocaleLowerCase().includes(t.toLocaleLowerCase());return e=>t(e,this.searchTerm)}accessChildren(e){var t;return null!==(t=Ia(e,this.props.childrenAccessor||"children"))&&void 0!==t?t:null}accessId(e){const t=Ia(e,this.props.idAccessor||"id");if(!t)throw new Error("Data must contain an 'id' property or props.idAccessor must return a string");return t}get firstNode(){var e;return null!==(e=this.visibleNodes[0])&&void 0!==e?e:null}get lastNode(){var e;return null!==(e=this.visibleNodes[this.visibleNodes.length-1])&&void 0!==e?e:null}get focusedNode(){var e;return null!==(e=this.get(this.state.nodes.focus.id))&&void 0!==e?e:null}get mostRecentNode(){var e;return null!==(e=this.get(this.state.nodes.selection.mostRecent))&&void 0!==e?e:null}get nextNode(){const e=this.indexOf(this.focusedNode);return null===e?null:this.at(e+1)}get prevNode(){const e=this.indexOf(this.focusedNode);return null===e?null:this.at(e-1)}get(e){return e&&e in this.idToIndex&&this.visibleNodes[this.idToIndex[e]]||null}at(e){return this.visibleNodes[e]||null}nodesBetween(e,t){var n;if(null===e||null===t)return[];const r=null!==(n=this.indexOf(e))&&void 0!==n?n:0,i=this.indexOf(t);if(null===i)return[];const o=Math.min(r,i),s=Math.max(r,i);return this.visibleNodes.slice(o,s+1)}indexOf(e){const t=_a(e);return t?this.idToIndex[t]:null}get editingId(){return this.state.nodes.edit.id}createInternal(){return this.create({type:"internal"})}createLeaf(){return this.create({type:"leaf"})}create(e={}){var t,n;return ih(this,void 0,void 0,(function*(){const r=void 0===e.parentId?Fa(this):e.parentId,i=null!==(t=e.index)&&void 0!==t?t:La(this),o=null!==(n=e.type)&&void 0!==n?n:"leaf",s=yield oh(this.props.onCreate,{type:o,parentId:r,index:i,parentNode:this.get(r)});s&&(this.focus(s),setTimeout((()=>{this.edit(s).then((()=>{this.select(s),this.activate(s)}))})))}))}delete(e){return ih(this,void 0,void 0,(function*(){if(!e)return;const t=(Array.isArray(e)?e:[e]).map(sh),n=t.map((e=>this.get(e))).filter((e=>!!e));yield oh(this.props.onDelete,{nodes:n,ids:t})}))}edit(e){const t=sh(e);return this.resolveEdit({cancelled:!0}),this.scrollTo(t),this.dispatch(Ja(t)),new Promise((e=>{ch.editPromise=e}))}submit(e,t){return ih(this,void 0,void 0,(function*(){if(!e)return;const n=sh(e);yield oh(this.props.onRename,{id:n,name:t,node:this.get(n)}),this.dispatch(Ja(null)),this.resolveEdit({cancelled:!1,value:t}),setTimeout((()=>this.onFocus()))}))}reset(){this.dispatch(Ja(null)),this.resolveEdit({cancelled:!0}),setTimeout((()=>this.onFocus()))}activate(e){const t=this.get(ah(e));t&&oh(this.props.onActivate,t)}resolveEdit(e){const t=ch.editPromise;t&&t(e),ch.editPromise=null}get selectedIds(){return this.state.nodes.selection.ids}get selectedNodes(){let e=[];for(let t of Array.from(this.selectedIds)){const n=this.get(t);n&&e.push(n)}return e}focus(e,t={}){e&&(this.props.selectionFollowsFocus?this.select(e):(this.dispatch(Ya(sh(e))),!1!==t.scroll&&this.scrollTo(e),this.focusedNode&&oh(this.props.onFocus,this.focusedNode)))}pageUp(){var e,t;const n=this.visibleStartIndex,r=this.visibleStopIndex-n;let i=null!==(t=null===(e=this.focusedNode)||void 0===e?void 0:e.rowIndex)&&void 0!==t?t:0;i=i>n?n:Math.max(n-r,0),this.focus(this.at(i))}pageDown(){var e,t;const n=this.visibleStartIndex,r=this.visibleStopIndex,i=r-n;let o=null!==(t=null===(e=this.focusedNode)||void 0===e?void 0:e.rowIndex)&&void 0!==t?t:0;o=othis.get(e))).filter((e=>!!e))}get dragNode(){return this.get(this.state.nodes.drag.id)}get dragDestinationParent(){return this.get(this.state.nodes.drag.destinationParentId)}get dragDestinationIndex(){return this.state.nodes.drag.destinationIndex}canDrop(){var e;if(this.isFiltered)return!1;const t=null!==(e=this.get(this.state.dnd.parentId))&&void 0!==e?e:this.root,n=this.dragNodes,r=this.props.disableDrop;for(const i of n){if(!i)return!1;if(!t)return!1;if(i.isInternal&&Sa(t,i))return!1}return"function"==typeof r?!r({parentNode:t,dragNodes:this.dragNodes,index:this.state.dnd.index||0}):"string"==typeof r?!t.data[r]:"boolean"!=typeof r||!r}hideCursor(){this.dispatch(lc.cursor({type:"none"}))}showCursor(e){this.dispatch(lc.cursor(e))}open(e){const t=ah(e);t&&(this.isOpen(t)||(this.dispatch(ec.open(t,this.isFiltered)),oh(this.props.onToggle,t)))}close(e){const t=ah(e);t&&this.isOpen(t)&&(this.dispatch(ec.close(t,this.isFiltered)),oh(this.props.onToggle,t))}toggle(e){const t=ah(e);if(t)return this.isOpen(t)?this.close(t):this.open(t)}openParents(e){const t=ah(e);if(!t)return;const n=Da(this.root,t);let r=null==n?void 0:n.parent;for(;r;)this.open(r.id),r=r.parent}openSiblings(e){const t=e.parent;if(t){if(t.children){const n=e.isOpen;for(let e of t.children)e.isInternal&&(n?this.close(e.id):this.open(e.id));this.scrollTo(this.focusedNode)}}else this.toggle(e.id)}openAll(){Ca(this.root,(e=>{e.isInternal&&e.open()}))}closeAll(){Ca(this.root,(e=>{e.isInternal&&e.close()}))}scrollTo(e,t="smart"){if(!e)return;const n=sh(e);return this.openParents(n),Aa((()=>n in this.idToIndex)).then((()=>{var e;const r=this.idToIndex[n];void 0!==r&&(null===(e=this.list.current)||void 0===e||e.scrollToItem(r,t))})).catch((()=>{}))}get isEditing(){return null!==this.state.nodes.edit.id}get isFiltered(){var e;return!!(null===(e=this.props.searchTerm)||void 0===e?void 0:e.trim())}get hasFocus(){return this.state.nodes.focus.treeFocused}get hasNoSelection(){return 0===this.state.nodes.selection.ids.size}get hasOneSelection(){return 1===this.state.nodes.selection.ids.size}get hasMultipleSelections(){return this.state.nodes.selection.ids.size>1}isSelected(e){return!!e&&this.state.nodes.selection.ids.has(e)}isOpen(e){var t,n,r;if(!e)return!1;if(e===Xa)return!0;const i=null===(t=this.props.openByDefault)||void 0===t||t;return this.isFiltered?null===(n=this.state.nodes.open.filtered[e])||void 0===n||n:null!==(r=this.state.nodes.open.unfiltered[e])&&void 0!==r?r:i}isEditable(e){var t;return null===(t=!Ia(e,this.props.disableEdit||(()=>!1)))||void 0===t||t}isDraggable(e){var t;return null===(t=!Ia(e,this.props.disableDrag||(()=>!1)))||void 0===t||t}isDragging(e){const t=ah(e);return!!t&&this.state.nodes.drag.id===t}isFocused(e){return this.hasFocus&&this.state.nodes.focus.id===e}isMatch(e){return this.matchFn(e)}willReceiveDrop(e){const t=ah(e);if(!t)return!1;const{destinationParentId:n,destinationIndex:r}=this.state.nodes.drag;return t===n&&null===r}onFocus(){const e=this.focusedNode||this.firstNode;e&&this.dispatch(Ya(e.id))}onBlur(){this.dispatch({type:"TREE_BLUR"})}onItemsRendered(e){this.visibleStartIndex=e.visibleStartIndex,this.visibleStopIndex=e.visibleStopIndex}get renderContainer(){return this.props.renderContainer||eh}get renderRow(){return this.props.renderRow||Wa}get renderNode(){return this.props.children||Va}get renderDragPreview(){return this.props.renderDragPreview||fc}get renderCursor(){return this.props.renderCursor||Ua}}function lh(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var uh=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),dh=()=>Math.random().toString(36).substring(7).split("").join("."),hh={INIT:`@@redux/INIT${dh()}`,REPLACE:`@@redux/REPLACE${dh()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${dh()}`};function fh(e,t,n){if("function"!=typeof e)throw new Error(lh(2));if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(lh(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(lh(1));return n(fh)(e,t)}let r=e,i=t,o=new Map,s=o,a=0,c=!1;function l(){s===o&&(s=new Map,o.forEach(((e,t)=>{s.set(t,e)})))}function u(){if(c)throw new Error(lh(3));return i}function d(e){if("function"!=typeof e)throw new Error(lh(4));if(c)throw new Error(lh(5));let t=!0;l();const n=a++;return s.set(n,e),function(){if(t){if(c)throw new Error(lh(6));t=!1,l(),s.delete(n),o=null}}}function h(e){if(!function(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}(e))throw new Error(lh(7));if(void 0===e.type)throw new Error(lh(8));if("string"!=typeof e.type)throw new Error(lh(17));if(c)throw new Error(lh(9));try{c=!0,i=r(i,e)}finally{c=!1}return(o=s).forEach((e=>{e()})),e}h({type:hh.INIT});return{dispatch:h,subscribe:d,getState:u,replaceReducer:function(e){if("function"!=typeof e)throw new Error(lh(10));r=e,h({type:hh.REPLACE})},[uh]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(lh(11));function n(){const e=t;e.next&&e.next(u())}n();return{unsubscribe:e(n)}},[uh](){return this}}}}}function ph(e){const t=Object.keys(e),n={};for(let s=0;s{const n=e[t];if(void 0===n(void 0,{type:hh.INIT}))throw new Error(lh(12));if(void 0===n(void 0,{type:hh.PROBE_UNKNOWN_ACTION()}))throw new Error(lh(13))}))}(n)}catch(o){i=o}return function(e={},t){if(i)throw i;let o=!1;const s={};for(let i=0;in.add(e))),Object.assign(Object.assign({},e),{ids:new Set(n)}));case"SELECTION_REMOVE":return 0===t.ids.length?e:(t.ids.forEach((e=>n.delete(e))),Object.assign(Object.assign({},e),{ids:new Set(n)}));case"SELECTION_SET":return Object.assign(Object.assign({},e),{ids:t.ids,mostRecent:t.mostRecent,anchor:t.anchor});case"SELECTION_MOST_RECENT":return Object.assign(Object.assign({},e),{mostRecent:t.id});case"SELECTION_ANCHOR":return Object.assign(Object.assign({},e),{anchor:t.id});default:return e}},drag:function(e=nc().nodes.drag,t){switch(t.type){case"DND_DRAG_START":return Object.assign(Object.assign({},e),{id:t.id,selectedIds:t.dragIds});case"DND_DRAG_END":return Object.assign(Object.assign({},e),{id:null,destinationParentId:null,destinationIndex:null,selectedIds:[]});case"DND_HOVERING":return t.parentId!==e.destinationParentId||t.index!=e.destinationIndex?Object.assign(Object.assign({},e),{destinationParentId:t.parentId,destinationIndex:t.index}):e;default:return e}}}),dnd:function(e=nc().dnd,t){switch(t.type){case"DND_CURSOR":return Object.assign(Object.assign({},e),{cursor:t.cursor});case"DND_DRAG_START":return Object.assign(Object.assign({},e),{dragId:t.id,dragIds:t.dragIds});case"DND_DRAG_END":return nc().dnd;case"DND_HOVERING":return Object.assign(Object.assign({},e),{parentId:t.parentId,index:t.index});default:return e}}}),mh=nc();function yh({treeProps:e,imperativeHandle:t,children:n}){const r=m.useRef(null),i=m.useRef(null),o=m.useRef(fh(gh,nc(e))),s=rt.useSyncExternalStore(o.current.subscribe,o.current.getState,(()=>mh)),a=m.useMemo((()=>new ch(o.current,e,r,i)),[]),c=m.useRef(0);return m.useMemo((()=>{c.current+=1,a.update(e)}),[...Object.values(e),s.nodes.open]),m.useImperativeHandle(t,(()=>a)),m.useEffect((()=>{a.props.selection?a.select(a.props.selection,{focus:!1}):a.deselectAll()}),[a.props.selection]),m.useEffect((()=>{a.props.searchTerm||o.current.dispatch(ec.clear(!0))}),[a.props.searchTerm]),l.jsx(pa.Provider,{value:a,children:l.jsx(va.Provider,{value:c.current,children:l.jsx(ma.Provider,{value:s.nodes,children:l.jsx(ya.Provider,{value:s.dnd,children:l.jsx(du,Object.assign({backend:Wd,options:{rootElement:a.props.dndRootElement||void 0}},e.dndManager&&{manager:e.dndManager},{children:n}))})})})})}function vh(e){return function(){const e=ga(),[,t]=cd((()=>({accept:"NODE",canDrop:(t,n)=>!!n.isOver({shallow:!0})&&e.canDrop(),hover:(t,n)=>{if(!n.isOver({shallow:!0}))return;const r=n.getClientOffset();if(!e.listEl.current||!r)return;const{cursor:i,drop:o}=Yd({element:e.listEl.current,offset:r,indent:e.indent,node:null,prevNode:e.visibleNodes[e.visibleNodes.length-1],nextNode:null});o&&e.dispatch(lc.hovering(o.parentId,o.index)),n.canDrop()?i&&e.showCursor(i):e.hideCursor()}})),[e]);t(e.listEl)}(),e.children}function bh(){const e=ga().props.renderContainer||eh;return l.jsx(l.Fragment,{children:l.jsx(e,{})})}function xh(){const e=ga(),{offset:t,mouse:n,item:r,isDragging:i}=(o=e=>({offset:e.getSourceClientOffset(),mouse:e.getClientOffset(),item:e.getItem(),isDragging:e.isDragging()}),s=Fu().getMonitor(),a=ld(Gu(s,o),2),c=a[0],u=a[1],m.useEffect((function(){return s.subscribeToOffsetChange(u)})),m.useEffect((function(){return s.subscribeToStateChange(u)})),c);var o,s,a,c,u;const d=e.props.renderDragPreview||fc;return l.jsx(d,{offset:t,mouse:n,id:(null==r?void 0:r.id)||null,dragIds:(null==r?void 0:r.dragIds)||[],isDragging:i})}class wh{constructor(e){this.root=function(e){const t=new Th({id:"ROOT"},null);return t.children=e.map((e=>kh(e,t))),t}(e)}get data(){var e,t;return null!==(t=null===(e=this.root.children)||void 0===e?void 0:e.map((e=>e.data)))&&void 0!==t?t:[]}create(e){const t=e.parentId?this.find(e.parentId):this.root;if(!t)return null;t.addChild(e.data,e.index)}move(e){const t=this.find(e.id),n=e.parentId?this.find(e.parentId):this.root;t&&n&&(n.addChild(t.data,e.index),t.drop())}update(e){const t=this.find(e.id);t&&t.update(e.changes)}drop(e){const t=this.find(e.id);t&&t.drop()}find(e,t=this.root){if(!t)return null;if(t.id===e)return t;if(t.children){for(let n of t.children){const t=this.find(e,n);if(t)return t}return null}return null}}function kh(e,t){const n=new Th(e,t);return e.children&&(n.children=e.children.map((e=>kh(e,n)))),n}class Th{constructor(e,t){this.data=e,this.parent=t,this.id=e.id}hasParent(){return!!this.parent}get childIndex(){return this.hasParent()?this.parent.children.indexOf(this):-1}addChild(e,t){var n,r;const i=kh(e,this);this.children=null!==(n=this.children)&&void 0!==n?n:[],this.children.splice(t,0,i),this.data.children=null!==(r=this.data.children)&&void 0!==r?r:[],this.data.children.splice(t,0,e)}removeChild(e){var t,n;null===(t=this.children)||void 0===t||t.splice(e,1),null===(n=this.data.children)||void 0===n||n.splice(e,1)}update(e){if(this.hasParent()){const t=this.childIndex;this.parent.addChild(Object.assign(Object.assign({},this.data),e),t),this.drop()}}drop(){this.hasParent()&&this.parent.removeChild(this.childIndex)}}let Sh=0;function Rh(e){if(e.initialData&&e.data)throw new Error("React Arborist Tree => Provide either a data or initialData prop, but not both.");if(e.initialData&&(e.onCreate||e.onDelete||e.onMove||e.onRename))throw new Error("React Arborist Tree => You passed the initialData prop along with a data handler.\nUse the data prop if you want to provide your own handlers.");if(e.initialData){const[t,n]=function(e){const[t,n]=m.useState(e),r=m.useMemo((()=>new wh(t)),[t]);return[t,{onMove:e=>{for(const t of e.dragIds)r.move({id:t,parentId:e.parentId,index:e.index});n(r.data)},onRename:({name:e,id:t})=>{r.update({id:t,changes:{name:e}}),n(r.data)},onCreate:({parentId:e,index:t,type:i})=>{const o={id:"simple-tree-id-"+Sh++,name:""};return"internal"===i&&(o.children=[]),r.create({parentId:e,index:t,data:o}),n(r.data),o},onDelete:e=>{e.ids.forEach((e=>r.drop({id:e}))),n(r.data)}}]}(e.initialData);return Object.assign(Object.assign(Object.assign({},e),n),{data:t})}return e}const Dh=m.forwardRef((function(e,t){const n=Rh(e);return l.jsxs(yh,{treeProps:n,imperativeHandle:t,children:[l.jsx(vh,{children:l.jsx(bh,{})}),l.jsx(xh,{})]})}));export{dt as A,Rt as B,ua as C,yt as G,Is as K,ls as L,fa as M,xt as P,Dt as S,Dh as T,ft as a,ha as b,js as c,Os as d,ps as e,fs as f,Ds as g,cs as h,At as i,Ts as j,Es as k,Ps as l,Ns as m,ms as n,_t as o,qt as p,Mt as q,pt as r,gs as s,wh as t,Ot as u};