@vuu-ui/vuu-layout 0.8.11 → 0.8.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Oh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var T=(r,e,t)=>(Oh(r,e,"read from private field"),t?t.call(r):e.get(r)),te=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},z=(r,e,t,n)=>(Oh(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Nh=(r,e,t,n)=>({set _(o){z(r,e,o,t)},get _(){return T(r,e,n)}});import{partition as $h}from"@vuu-ui/vuu-utils";import gx from"classnames";var Vh={},Fh={},Fn={};function ze(r){return Vh[r]===!0}function hx(r){return Fh[r]===!0}var Bh=r=>ze(r)||hx(r);function ge(r,e,t="component"){Fn[r]=e,t==="container"?Vh[r]=!0:t==="view"&&(Fh[r]=!0)}import{Button as Hh,useControlled as fx}from"@salt-ds/core";import _h from"classnames";import{useCallback as dx}from"react";import{jsx as bo,jsxs as mx}from"react/jsx-runtime";var fn="vuuDrawer",zh=r=>typeof r=="string"?r:r+"px",px=(r,e,t)=>{let n=e!==void 0,o=t!==void 0;if(!(!r&&!o&&!n))return!o&&!n?r:{...r,"--drawer-size":n?zh(e):void 0,"--drawer-peek-size":o?zh(t):void 0}},Wh=({children:r,className:e,clickToOpen:t,defaultOpen:n,sizeOpen:o,sizeClosed:i,style:s,open:l,position:a="left",inline:c,onClick:u,peekaboo:h=!1,toggleButton:f,...d})=>{let[p,m]=fx({controlled:l,default:n!=null?n:!1,name:"Drawer",state:"open"}),g=_h(fn,e,`${fn}-${a}`,{[`${fn}-open`]:p,[`${fn}-inline`]:c,[`${fn}-over`]:!c,[`${fn}-peekaboo`]:h}),y=dx(()=>{m(!p)},[p,m]),v=px(s,o,i),w=t?y:u,x=()=>bo("div",{className:_h("vuuToggleButton-container"),children:p?bo(Hh,{"aria-label":"close",onClick:y,"data-icon":"close",variant:"secondary"}):bo(Hh,{"aria-label":"open",onClick:y,"data-icon":"close",variant:"secondary"})});return mx("div",{...d,className:g,onClick:w,style:v,children:[f=="start"?x():null,bo("div",{className:`${fn}-liner`,children:bo("div",{className:`${fn}-content`,children:r})}),f=="end"?x():null]})};Wh.displayName="Drawer";var Li=Wh;import{jsx as xx,jsxs as vx}from"react/jsx-runtime";var yx=r=>r.type===Li,bx=({props:{position:r="left"}})=>r.match(/top|bottom/),Zl=r=>{let{children:e,className:t,id:n,style:o}=r,i="vuuDockLayout",[s,l]=$h(e,yx),[a,c]=$h(s,bx),u=a.length===0?"horizontal":c.length===0?"vertical":"both",h=gx(i,t,`${i}-${u}`);return vx("div",{className:h,id:n,style:o,children:[s,xx("div",{className:`${i}-content`,children:l})]})};Zl.displayName="DockLayout";var Uh=Zl;ge("DockLayout",Zl,"container");import{forwardRef as wx}from"react";import{jsx as Sx}from"react/jsx-runtime";var ea=wx(function({resizeable:e,...t},n){return Sx("div",{...t,className:"Component",ref:n})});ea.displayName="Component";var ta=ea;ge("Component",ea);import dn,{isValidElement as qh}from"react";var Cx={},q=(r,e)=>{var n;let t=_(r);return(n=t[e])!=null?n:t[`data-${e}`]},_=r=>(r==null?void 0:r.props)||r||Cx,Gh=r=>{let e=_(r);if(e.children){let{children:[t,...n]}=e;return n.length>0&&console.warn(`getChild expected a single child, found ${n.length+1}`),t}};function K(r){var e;if(r){let t=r.type;if(typeof t=="function"||typeof t=="object"){let n=t.displayName||t.name||((e=t.type)==null?void 0:e.name);if(typeof n=="string")return n}if(typeof r.type=="string")return r.type;if(r.constructor)return r.constructor.displayName;throw Error("typeOf unable to determine type of element")}}var DD=(r,e)=>K(r)===e;var Tx=r=>{let e=r.lastIndexOf(".");return e===-1?r:r.slice(0,e)},Kh=r=>dn.isValidElement(r.props.children)?[r.props.children]:r.props.children,na=(r,e="")=>{let[t,...n]=e.split(".");if(t!=null&&t.startsWith("#")){let o=ra(r,t.slice(1),!0);if(o&&n.length)return na(o,n.join("."))}else if(t==="ACTIVE_CHILD"){let{active:o}=_(r),i=Kh(r),{path:s}=_(i[o]);return s}return""},jh=(r,e="")=>{let[t,...n]=e.split(".");if(t!=null&&t.startsWith("#")){let o=Qh(r,t.slice(1),!0);if(o&&n.length)return jh(o,n.join("."))}else if(t==="ACTIVE_CHILD"){let{children:o,props:i}=r,{active:s}=i;if(typeof s=="number"&&(o!=null&&o[s]))return o[s]}};function Qt(r,e){let{"data-path":t,path:n=t}=_(r);return e==="0"||e===n?null:Te(r,Tx(e),!0)}function Yt(r,e){let{children:t,...n}=_(r);if(e(n))return r;if(dn.Children.count(t)>0){let o=dn.isValidElement(t)?[t]:t;for(let i of o){let s=Yt(i,e);if(s)return s}}}function kx(r,e){if(e===r)return null;let{path:t,children:n}=_(r),{idx:o,finalStep:i}=Mt(t,q(e,"path"));return i?r:n===void 0||n[o]===void 0?null:kx(n[o],e)}var Mx=(r,e)=>{if(dn.isValidElement(r)&&e==0)return r;if(Array.isArray(r))return r[e]};function Jh(r,e){let t=e.split("."),n=[r];for(let o=0;o<t.length;o++){let i=parseInt(t[o]),s=n[i];if(o===t.length-1)return s;n=Kh(s)}}var ra=(r,e,t=!0)=>{let{children:n,id:o}=r.props;if(o===e)return r;if(dn.Children.count(n)>0){let i=qh(n)?[n]:n;for(let s of i)if(qh(s)){let l=ra(s,e,!1);if(l)return l}}if(t===!0)throw Error(`pathUtils.findTargetById id #${e} not found in source`)},Qh=(r,e,t=!0)=>{let{children:n,id:o}=r;if(o===e)return r;if(Array.isArray(n)&&n.length>0){for(let i of n)if(i!==null&&typeof i=="object"){let s=Qh(i,e,!1);if(s)return s}}if(t===!0)throw Error(`pathUtils.findTargetJSONById id #${e} not found in source`)};function Te(r,e,t=!1){if(e.startsWith("#"))return ra(r,e.slice(1),t);let{"data-path":n,path:o=n}=_(r);if(e.indexOf(o)!==0)throw Error(`pathUtils.followPath path ${e} is not within source path ${o}`);let i=e.slice(o.length+1);if(i==="")return r;let s=r,l=i.split(".");for(let a=0;a<l.length;a++){if(dn.Children.count(s.props.children)===0){let c=`element at 0.${l.slice(0,a).join(".")} has no children, so cannot fulfill rest of path ${l.slice(a).join(".")}`;if(t)throw Error(c);console.warn(c);return}if(s=Mx(s.props.children,parseInt(l[a])),s===void 0){let c=`model at 0.${l.slice(0,a).join(".")} has no children that fulfill next step of path ${l.slice(a).join(".")}`;if(t)throw Error(c);console.warn(c)}}return s}function BD(r,e){let t=Qt(r,e),n=e.split(".").map(o=>parseInt(o,10));if(t){let o=n.pop(),{children:i}=t.props;if(i.length-1>o)return Ai(i[o+1]);{let s=n.pop(),l=Qt(r,q(t,"path"));if(l&&typeof s=="number"&&(n=l.props.path.split(".").map(a=>parseInt(a,10)),l.props.children.length-1>s)){let a=l.props.children[s+1];return ze(K(a))?Ai(a):a}}}return Ai(r)}function HD(r,e){let t=e.split(".").map(i=>parseInt(i,10)),n=t.pop(),o=Qt(r,e);if(o!=null&&typeof n=="number"){let{children:i}=o.props;if(n>0)return Oi(i[n-1]);for(;t.length>1;)if(n=t.pop(),o=Qt(r,q(o,"path")),n>0){let s=o.props.children[n-1];return ze(K(s))?Oi(s):s}}return Oi(r)}function Ai(r){if(ze(K(r))){let{children:e}=r.props||r;return Ai(e[0])}return r}function Oi(r){if(ze(K(r))){let{children:e}=r.props||r;return Oi(e[e.length-1])}return r}function Mt(r,e,t=!1){if(r===e)return{idx:-1,finalStep:!0};let n=`${r}.`;if(!e.startsWith(n))throw Error("pathUtils nextStep has strayed from the path");let o=t?0:1,i=e.replace(n,"").split(".").map(s=>parseInt(s,10));return{idx:i[0],finalStep:i.length===o}}function Ee(r,e,t){if(q(r,"path")===e)return r;let n=[];dn.Children.forEach(r.props.children,(i,s)=>{q(i,"path")?n.push(Ee(i,`${e}.${s}`)):n.push(i)});let o=r.props["data-path"]?"data-path":"path";return dn.cloneElement(r,{[o]:e,...t},n)}function zD(r,e){typeof r=="function"?r(e):r&&(r.current=e)}import{Children as Ex,isValidElement as Yh,useLayoutEffect as Rx,useMemo as Ix,useRef as Px}from"react";var Dx=[],Lx=0,wr=r=>{let e=Array.isArray(r),t=e?r.length:Ex.count(r);return e&&r.every(Yh)?r:t===1&&!e&&Yh(r)?[r]:t>1?r:Dx},Xh=(r,e)=>{let t=Px(!1);Rx(()=>{t.current?r():t.current=!0},e)},Sr=r=>Ix(()=>r!=null?r:`vuu-${++Lx}`,[r]);var oa=r=>{if(typeof r!="number")throw Error(`"no support yet for flex value ${r}`);return{flexBasis:0,flexGrow:1,flexShrink:1}};import{boxContainsPoint as Ni}from"@vuu-ui/vuu-utils";var Hn={north:1,east:2,south:4,west:8,header:16,centre:32,absolute:64},xo={AFTER:"after",BEFORE:"before"},Ze=Object.freeze({North:Bn("north"),East:Bn("east"),South:Bn("south"),West:Bn("west"),Header:Bn("header"),Centre:Bn("centre"),Absolute:Bn("absolute")});function Bn(r){return Object.freeze({offset:r==="north"||r==="west"?0:r==="south"||r==="east"?1:NaN,valueOf:function(){return Hn[r]},toString:function(){return r},North:r==="north",South:r==="south",East:r==="east",West:r==="west",Header:r==="header",Centre:r==="centre",NorthOrSouth:r==="north"||r==="south",EastOrWest:r==="east"||r==="west",NorthOrWest:r==="north"||r==="west",SouthOrEast:r==="east"||r==="south",Absolute:r==="absolute"})}var Zh=Ze.North,ef=Ze.South,ia=Ze.East,sa=Ze.West,Ax=Ze.Header,Ox=Ze.Centre,Cr=class{static measure(e,t=[]){let n={};return Fx(e,n,t),n}static allBoxesContainingPoint(e,t,n,o,i){return of(e,t,n,o,i).reverse()}};function la(r,e,t,n=30){let o=t.right-t.left,i=t.bottom-t.top,s=r-t.left,l=e-t.top,a=0;return s<n&&(a+=8),s>o-n&&(a+=2),l<n&&(a+=1),l>i-n&&(a+=4),{pctX:s/o,pctY:l/i,closeToTheEdge:a}}function aa(r,e,t,n){let{BEFORE:o,AFTER:i}=xo,{pctX:s,pctY:l,closeToTheEdge:a}=la(r,e,t),c,u;if(n==="row")c=s<.5?sa:ia;else if(t.header&&Ni(t.header,r,e))if(c=Ax,t.Stack){let h=t.Stack.length;if(h===0)u={index:-1,left:t.left,positionRelativeToTab:i,width:0};else{let f=t.Stack.find(({left:d,right:p})=>r>=d&&r<=p);if(f){let d=f.right-f.left;u={index:t.Stack.indexOf(f),left:f.left,positionRelativeToTab:(r-f.left)/d<.5?o:i,width:d}}else u={left:t.Stack[h-1].right,width:0,index:h,positionRelativeToTab:i}}}else if(t.header.titleWidth){let h=t.header.titleWidth;u={index:-1,left:t.left,positionRelativeToTab:(r-t.left)/h<.5?o:i,width:h}}else u={left:t.left,width:0,positionRelativeToTab:o,index:-1};else c=Nx(r,e,t,s,l);return{position:c,x:r,y:e,closeToTheEdge:a,tab:u}}function Nx(r,e,t,n,o){let i=Vx(t,.2);if(Ni(i,r,e))return Ox;switch(`${o<.5?"north":"south"}${n<.5?"west":"east"}`){case"northwest":return n>o?Zh:sa;case"northeast":return 1-n>o?Zh:ia;case"southeast":return n>o?ia:ef;case"southwest":return 1-n>o?sa:ef;default:}}function Vx({right:r,left:e,top:t,bottom:n},o){let i=(1-o)/2,s=(r-e)*i,l=(n-t)*i;return{left:e+s,top:t+l,right:r-s,bottom:n-l}}function Fx(r,e,t){let{id:n,"data-path":o,path:i=o}=_(r),s=K(r);if(n&&i){let[l,a]=rf(r);tf(r,l,a,e),ze(s)&&nf(r,e,t)}}function tf(r,e,t,n){let{"data-path":o,path:i=o,header:s}=_(r);n[i]=e;let l=K(r);if(s||l==="Stack"){let a=l==="Stack"?".vuuTabstrip":".vuuHeader",c=t.querySelector(a);if(c){let{top:u,left:h,right:f,bottom:d}=c.getBoundingClientRect();if(n[i].header={top:Math.round(u),left:Math.round(h),right:Math.round(f),bottom:Math.round(d)},l==="Stack")n[i].Stack=Array.from(c.querySelectorAll(".vuuTab")).map(p=>p.getBoundingClientRect()).map(({left:p,right:m})=>({left:p,right:m}));else{let p=c.querySelector('[class^="vuuHeader-title"]'),{header:m}=n[i];p&&m&&(m.titleWidth=p.clientWidth)}}}return n[i]}function nf(r,e,t,n=0,o=0,i=0,s=0){let{children:l,"data-path":a,path:c=a,style:u,active:h=0}=_(r),f=K(r),d=f==="Flexbox",p=f==="Stack",m=d&&u.flexDirection==="column",g=d&&u.flexDirection==="row",v=(p?l.filter((x,S)=>S===h):l.filter(Bx)).map(x=>{let[S,b]=rf(x);return[{...S,top:S.top-i,right:S.right+o,bottom:S.bottom+s,left:S.left-n},b,x]}),w=v.map(([x,S,b],C,k)=>{let E,R,N,O,M,D,F=k.length-1;g?(M=C===0?0:x.left-k[C-1][0].right,D=C===F?0:k[C+1][0].left-x.right,E=C===0||M===0?0:M,R=C===F||D===0?0:D-D/2,x.left-=E,x.right+=R,N=i,O=s):m&&(M=C===0?0:x.top-k[C-1][0].bottom,D=C===F?0:k[C+1][0].top-x.bottom,N=C===0||M===0?0:M,O=C===F||D===0?0:D-D/2,x.top-=N,x.bottom+=O,E=n,R=o);let G=tf(b,x,S,e),A=K(b);return ze(A)&&nf(b,e,t,E,R,N,O),G});v.length&&(e[c].children=w)}function Bx(r){let{id:e}=_(r),t=document.getElementById(e);return t?t.dataset.dragging!=="true":(console.warn(`BoxModel: no element found with id #${e}`),!1)}function rf(r){let{id:e}=_(r);if(e===void 0)throw Error("`BoxModel.measureComponentElement, component has no id");let t=document.getElementById(e);if(!t)throw Error("BoxModel.measureComponentElement, no DOM element found for component");let{top:n,left:o,right:i,bottom:s,height:l,width:a}=t.getBoundingClientRect(),c,u=K(r);if(ze(u)){let h=t.scrollHeight;h>l&&(c={id:e,scrollHeight:h,scrollTop:t.scrollTop})}return[{top:Math.round(n),left:Math.round(o),right:Math.round(i),bottom:Math.round(s),height:Math.round(l),width:Math.round(a),scrolling:c},t,r]}function of(r,e,t,n,o,i=[]){let{children:s,"data-path":l,path:a=l}=_(r),c=K(r),u=e[a];if(!Ni(u,t,n))return i;if(o&&o.length){if(o.includes(a))i.push(r);else if(!o.some(h=>h.startsWith(a)))return i}else i.push(r);if(!ze(c)||u.header&&Ni(u.header,t,n))return i;u.scrolling&&Hx(u,t,n);for(let h=0;h<s.length;h++){if(c==="Stack"&&r.props.active!==h)continue;let f=of(s[h],e,t,n,o);if(f.length)return i.concat(f)}return i}function Hx({top:r,bottom:e,scrolling:t},n,o){if(t){let{id:i,scrollTop:s,scrollHeight:l}=t,a=e-r;if(s===0&&e-o<50){let c=l-a;document.getElementById(i).scrollTo({left:0,top:c,behavior:"smooth"}),t.scrollTop=c}else if(s>0&&o-r<50)document.getElementById(i).scrollTo({left:0,top:0,behavior:"smooth"}),t.scrollTop=0;else return!1}else return!1}var _x=.4,Vi=class{constructor(e,t,n,o,i){this.init(e,t,n,o,i)}init(e,t,n,o,i){let{left:s,top:l}=o,{pctX:a,pctY:c}=la(t,n,o),u=_x,h=a*o.width,f=o.width-h,d=c*o.height,p=o.height-d,m=o.width*u,g=o.height*u,y=1-u,v=h*y,w=d*y,x=f*y,S=p*y;this.intrinsicSize=i,this.constraint={zone:{x:{lo:e.left,hi:e.right},y:{lo:e.top,hi:e.bottom}},pos:{x:{lo:e.left-v,hi:e.right-o.width+x},y:{lo:e.top-w,hi:e.bottom-o.height+S}},mouse:{x:{lo:e.left+m*a,hi:e.right-m*(1-a)},y:{lo:e.top+g*c,hi:e.bottom-g*(1-c)}}},this.x={pos:s,lo:!1,hi:!1,mousePos:t,mousePct:a},this.y={pos:l,lo:!1,hi:!1,mousePos:n,mousePct:c}}outOfBounds(){return this.x.lo||this.x.hi||this.y.lo||this.y.hi}inBounds(){return!this.outOfBounds()}dropX(){return this.dropXY("x")}dropY(){return this.dropXY("y")}hasIntrinsicSize(){var e,t;return((e=this==null?void 0:this.intrinsicSize)==null?void 0:e.height)&&((t=this==null?void 0:this.intrinsicSize)==null?void 0:t.width)}update(e,t){let n=this[e],o=this.constraint.mouse[e],i=this.constraint.pos[e],s=n.pos,l=t-n.mousePos;return l<0?n.lo||(t<o.lo?(n.lo=!0,n.pos=i.lo):n.hi?t<o.hi&&(n.hi=!1,n.pos+=l):n.pos+=l):l>0&&(n.hi||(t>o.hi?(n.hi=!0,n.pos=i.hi):n.lo?t>o.lo&&(n.lo=!1,n.pos+=l):n.pos+=l)),n.mousePos=t,s!==n.pos}dropXY(e){let t=this[e],n=this.constraint.zone[e];return t.lo?Math.max(n.lo,t.mousePos):t.hi?Math.min(t.mousePos,Math.round(n.hi)-1):t.mousePos}};var fL=r=>r.pos.tab&&K(r.component)==="Stack"&&r.pos.position.Header,{north:zx,south:Wx,east:$x,west:Ux}=Hn,Gx=$x+Ux,qx=zx+Wx,pn=class{constructor({component:e,pos:t,clientRect:n,nextDropTarget:o}){this.component=e,this.pos=t,this.clientRect=n,this.nextDropTarget=o,this.active=!1,this.dropRect=void 0}targetTabPos(e){let{left:t,width:n,positionRelativeToTab:o}=e;return o===xo.BEFORE?t:t+n}getTargetDropOutline(e,t){if(this.pos.tab)return this.getDropTabOutline(e,this.pos.tab);if(t&&t.hasIntrinsicSize())return this.getIntrinsicDropRect(t);{let[n,o,i,s]=this.getDropRectOutline(e,t);return{l:n,t:o,r:i,b:s}}}getDropTabOutline(e,t){var y,v;let{clientRect:{top:n,left:o,right:i,bottom:s,header:l}}=this,a=0,c=Math.round(e/2)+a,u=Math.round(n),h=Math.round(o+c),f=Math.round(i-c),d=Math.round(s-c),p=this.targetTabPos(t),m=60,g=((y=l==null?void 0:l.bottom)!=null?y:0)-((v=l==null?void 0:l.top)!=null?v:0);return{l:h,t:u,r:f,b:d,tabLeft:p,tabWidth:m,tabHeight:g}}getIntrinsicDropRect(e){var m,g,y,v;let{pos:t,clientRect:n}=this,{x:o,y:i}=e,s=(g=(m=e.intrinsicSize)==null?void 0:m.height)!=null?g:0,l=(v=(y=e.intrinsicSize)==null?void 0:y.height)!=null?v:0;s&&s>n.height?(console.log("DropTarget: we're going to blow the gaff"),s=n.height):l&&l>n.width&&(console.log("DropTarget: we're going to blow the gaff"),l=n.width);let a=Math.min(n.right-l,Math.max(n.left,Math.round(t.x-o.mousePct*l))),c=Math.min(n.bottom-s,Math.max(n.top,Math.round(t.y-i.mousePct*s))),[u,h,f,d]=this.dropRect=[a,c,a+l,c+s],p=t.position.EastOrWest?[u,n.top,u,n.bottom,f,n.top,f,n.bottom]:[n.left,h,n.right,h,n.left,d,n.right,d];return{l:u,r:f,t:h,b:d,guideLines:p}}getDropRectOutline(e,t){var v,w,x;let{pos:n,clientRect:o}=this,{width:i,height:s,position:l}=n,{width:a,height:c}=(v=t==null?void 0:t.intrinsicSize)!=null?v:{},u=(w=c!=null?c:s)!=null?w:0,h=(x=a!=null?a:i)!=null?x:0;this.dropRect=void 0;let{top:f,left:d,right:p,bottom:m}=o,g=0,y=Math.round(e/2)+g;switch(l){case Ze.North:case Ze.Header:{let S=Math.round((m-f)/2),b=u?Math.min(S,Math.round(u)):S;return h&&d+h<p?[d+y,f+y,d+h-y,f+y+b]:[d+y,f+y,p-y,f+y+b]}case Ze.West:{let S=Math.round((p-d)/2),b=h?Math.min(S,Math.round(h)):S;return u&&f+u<m?[d+y,f+y,d-y+b,f+u+y]:[d+y,f+y,d-y+b,m-y]}case Ze.East:{let S=Math.round((p-d)/2),b=h?Math.min(S,Math.round(h)):S;return u&&f+u<m?[p-y-b,f+y,p-y,f+u+y]:[p-y-b,f+y,p-y,m-y]}case Ze.South:{let S=Math.round((m-f)/2),b=u?Math.min(S,Math.round(u)):S;return h&&d+h<p?[d+y,m-y-b,d+h-y,m-y]:[d+y,m-y-b,p-y,m-y]}case Ze.Centre:return[d+y,f+y,p-y,m-y];default:return console.warn(`DropTarget does not recognize position ${l}`),null}}activate(){return this.active=!0,this}toArray(){let e=this,t=[e];for(;e=e.nextDropTarget;)t.push(e);return t}static getActiveDropTarget(e){return e===null?null:e!=null&&e.active?e:pn.getActiveDropTarget(e.nextDropTarget)}};function ca(r,e,t,n,o,i){var a;let s=null,l=Cr.allBoxesContainingPoint(t,n,r,e,i);if(l.length){let[c,...u]=l,{"data-path":h,path:f=h,"data-row-placeholder":d}=_(c),p=n[f],g=aa(r,e,p,o&&d?"row":void 0),y=n[f],v=([w,...x])=>{var S,b;if((S=g.position)!=null&&S.Header||g.closeToTheEdge){let C=Kx(w,g,y,n,r,e);if(C){let[k,E]=C;return new pn({component:w,pos:k,clientRect:E,nextDropTarget:(b=v(x))!=null?b:null})}else if(x.length)return v(x)}};s=new pn({component:c,pos:g,clientRect:p,nextDropTarget:(a=v(u))!=null?a:null}).activate()}return s}function Kx(r,{closeToTheEdge:e,position:t},n,o,i,s){if(!r||r.type==="DraggableLayout")return;let l=o[r.props.path],a=e&Hn.north,c=e&Hn.east,u=e&Hn.south,h=e&Hn.west,f=(a||t.Header)&&Math.round(n.top)===Math.round(l.top),d=c&&Math.round(n.right)===Math.round(l.right),p=u&&Math.round(n.bottom)===Math.round(l.bottom),m=h&&Math.round(n.left)===Math.round(l.left);if(f||d||p||m){let{"data-path":g,path:y=g}=r.props,v=o[y],w=aa(i,s,v);if((jx(r)||sf(r))&&e&Gx)return w.width=120,[w,v];if((Jx(r)||sf(r))&&(t.Header||e&qx))return w.height=120,[w,v]}}function sf(r){return K(r)==="Stack"}function jx(r){return K(r)==="Flexbox"&&r.props.style.flexDirection==="column"}function Jx(r){return K(r)==="Flexbox"&&r.props.style.flexDirection==="row"}import{PopupService as ha}from"@vuu-ui/vuu-popups";import Qx from"classnames";import{jsx as lf}from"react/jsx-runtime";function af(r,e=0,t=0){let{pos:n,clientRect:o}=r,i=20;return n.position.West?[o.left-t+i,n.y-e,"left"]:n.position.South?[n.x-t,o.bottom-e-i,"bottom"]:n.position.East?[o.right-t-i,n.y-e,"right"]:[n.x-t,o.top-e+i,"top"]}var ua="vuuDropMenu",cf=({className:r,dropTarget:e,onHover:t,orientation:n})=>{let o=e.toArray();return lf("div",{className:Qx(ua,r,`${ua}-${n}`),onMouseLeave:()=>t(null),children:o.map((i,s)=>lf("div",{className:`${ua}-item`,"data-icon":s===0?"column-2A":"column-2B",onMouseEnter:()=>t(i)},s))})};import{jsx as rv}from"react/jsx-runtime";var fa=!1,vo=null,Et=null,Yx=r=>vo=r,Xx=([r,e])=>`M${r},${e}`,Zx=([r,e])=>`L${r},${e}`,uf=([r,...e])=>`${Xx(r)} ${e.map(Zx)}Z`,ev=r=>{if(r){let[e,t,n,o,i,s,l,a]=r;return`M${e},${t} L${n},${o} M${i},${s} L${l},${a}`}else return""};function tv(){if(document.getElementById("hw-drag-canvas")===null){let r=document.getElementById("root"),e=document.createElement("div");e.id="hw-drag-canvas",e.innerHTML=`
1
+ var Lh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var T=(r,e,t)=>(Lh(r,e,"read from private field"),t?t.call(r):e.get(r)),ee=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},z=(r,e,t,n)=>(Lh(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Ah=(r,e,t,n)=>({set _(o){z(r,e,o,t)},get _(){return T(r,e,n)}});import{partition as zh}from"@vuu-ui/vuu-utils";import xx from"classnames";var Oh={},Nh={},Fn={};function ze(r){return Oh[r]===!0}function px(r){return Nh[r]===!0}var Vh=r=>ze(r)||px(r);function ge(r,e,t="component"){Fn[r]=e,t==="container"?Oh[r]=!0:t==="view"&&(Nh[r]=!0)}import{Button as Fh,useControlled as mx}from"@salt-ds/core";import Bh from"classnames";import{useCallback as gx}from"react";import{jsx as xo,jsxs as bx}from"react/jsx-runtime";var fn="vuuDrawer",Hh=r=>typeof r=="string"?r:r+"px",yx=(r,e,t)=>{let n=e!==void 0,o=t!==void 0;if(!(!r&&!o&&!n))return!o&&!n?r:{...r,"--drawer-size":n?Hh(e):void 0,"--drawer-peek-size":o?Hh(t):void 0}},_h=({children:r,className:e,clickToOpen:t,defaultOpen:n,sizeOpen:o,sizeClosed:i,style:s,open:l,position:a="left",inline:c,onClick:u,peekaboo:h=!1,toggleButton:f,...d})=>{let[p,m]=mx({controlled:l,default:n!=null?n:!1,name:"Drawer",state:"open"}),y=Bh(fn,e,`${fn}-${a}`,{[`${fn}-open`]:p,[`${fn}-inline`]:c,[`${fn}-over`]:!c,[`${fn}-peekaboo`]:h}),g=gx(()=>{m(!p)},[p,m]),v=yx(s,o,i),w=t?g:u,x=()=>xo("div",{className:Bh("vuuToggleButton-container"),children:p?xo(Fh,{"aria-label":"close",onClick:g,"data-icon":"close",variant:"secondary"}):xo(Fh,{"aria-label":"open",onClick:g,"data-icon":"close",variant:"secondary"})});return bx("div",{...d,className:y,onClick:w,style:v,children:[f=="start"?x():null,xo("div",{className:`${fn}-liner`,children:xo("div",{className:`${fn}-content`,children:r})}),f=="end"?x():null]})};_h.displayName="Drawer";var Ai=_h;import{jsx as Sx,jsxs as Cx}from"react/jsx-runtime";var vx=r=>r.type===Ai,wx=({props:{position:r="left"}})=>r.match(/top|bottom/),Zl=r=>{let{children:e,className:t,id:n,style:o}=r,i="vuuDockLayout",[s,l]=zh(e,vx),[a,c]=zh(s,wx),u=a.length===0?"horizontal":c.length===0?"vertical":"both",h=xx(i,t,`${i}-${u}`);return Cx("div",{className:h,id:n,style:o,children:[s,Sx("div",{className:`${i}-content`,children:l})]})};Zl.displayName="DockLayout";var Wh=Zl;ge("DockLayout",Zl,"container");import{forwardRef as Tx}from"react";import{jsx as kx}from"react/jsx-runtime";var ea=Tx(function({resizeable:e,...t},n){return kx("div",{...t,className:"Component",ref:n})});ea.displayName="Component";var ta=ea;ge("Component",ea);import dn,{isValidElement as Uh}from"react";var Mx={},q=(r,e)=>{var n;let t=_(r);return(n=t[e])!=null?n:t[`data-${e}`]},_=r=>(r==null?void 0:r.props)||r||Mx,$h=r=>{let e=_(r);if(e.children){let{children:[t,...n]}=e;return n.length>0&&console.warn(`getChild expected a single child, found ${n.length+1}`),t}};function K(r){var e;if(r){let t=r.type;if(typeof t=="function"||typeof t=="object"){let n=t.displayName||t.name||((e=t.type)==null?void 0:e.name);if(typeof n=="string")return n}if(typeof r.type=="string")return r.type;if(r.constructor)return r.constructor.displayName;throw Error("typeOf unable to determine type of element")}}var BD=(r,e)=>K(r)===e;var Ex=r=>{let e=r.lastIndexOf(".");return e===-1?r:r.slice(0,e)},Gh=r=>dn.isValidElement(r.props.children)?[r.props.children]:r.props.children,na=(r,e="")=>{let[t,...n]=e.split(".");if(t!=null&&t.startsWith("#")){let o=ra(r,t.slice(1),!0);if(o&&n.length)return na(o,n.join("."))}else if(t==="ACTIVE_CHILD"){let{active:o}=_(r),i=Gh(r),{path:s}=_(i[o]);return s}return""},qh=(r,e="")=>{let[t,...n]=e.split(".");if(t!=null&&t.startsWith("#")){let o=jh(r,t.slice(1),!0);if(o&&n.length)return qh(o,n.join("."))}else if(t==="ACTIVE_CHILD"){let{children:o,props:i}=r,{active:s}=i;if(typeof s=="number"&&(o!=null&&o[s]))return o[s]}};function Qt(r,e){let{"data-path":t,path:n=t}=_(r);return e==="0"||e===n?null:Te(r,Ex(e),!0)}function Yt(r,e){let{children:t,...n}=_(r);if(e(n))return r;if(dn.Children.count(t)>0){let o=dn.isValidElement(t)?[t]:t;for(let i of o){let s=Yt(i,e);if(s)return s}}}function Rx(r,e){if(e===r)return null;let{path:t,children:n}=_(r),{idx:o,finalStep:i}=Et(t,q(e,"path"));return i?r:n===void 0||n[o]===void 0?null:Rx(n[o],e)}var Ix=(r,e)=>{if(dn.isValidElement(r)&&e==0)return r;if(Array.isArray(r))return r[e]};function Kh(r,e){let t=e.split("."),n=[r];for(let o=0;o<t.length;o++){let i=parseInt(t[o]),s=n[i];if(o===t.length-1)return s;n=Gh(s)}}var ra=(r,e,t=!0)=>{let{children:n,id:o}=r.props;if(o===e)return r;if(dn.Children.count(n)>0){let i=Uh(n)?[n]:n;for(let s of i)if(Uh(s)){let l=ra(s,e,!1);if(l)return l}}if(t===!0)throw Error(`pathUtils.findTargetById id #${e} not found in source`)},jh=(r,e,t=!0)=>{let{children:n,id:o}=r;if(o===e)return r;if(Array.isArray(n)&&n.length>0){for(let i of n)if(i!==null&&typeof i=="object"){let s=jh(i,e,!1);if(s)return s}}if(t===!0)throw Error(`pathUtils.findTargetJSONById id #${e} not found in source`)};function Te(r,e,t=!1){if(e.startsWith("#"))return ra(r,e.slice(1),t);let{"data-path":n,path:o=n}=_(r);if(e.indexOf(o)!==0)throw Error(`pathUtils.followPath path ${e} is not within source path ${o}`);let i=e.slice(o.length+1);if(i==="")return r;let s=r,l=i.split(".");for(let a=0;a<l.length;a++){if(dn.Children.count(s.props.children)===0){let c=`element at 0.${l.slice(0,a).join(".")} has no children, so cannot fulfill rest of path ${l.slice(a).join(".")}`;if(t)throw Error(c);console.warn(c);return}if(s=Ix(s.props.children,parseInt(l[a])),s===void 0){let c=`model at 0.${l.slice(0,a).join(".")} has no children that fulfill next step of path ${l.slice(a).join(".")}`;if(t)throw Error(c);console.warn(c)}}return s}function GD(r,e){let t=Qt(r,e),n=e.split(".").map(o=>parseInt(o,10));if(t){let o=n.pop(),{children:i}=t.props;if(i.length-1>o)return Oi(i[o+1]);{let s=n.pop(),l=Qt(r,q(t,"path"));if(l&&typeof s=="number"&&(n=l.props.path.split(".").map(a=>parseInt(a,10)),l.props.children.length-1>s)){let a=l.props.children[s+1];return ze(K(a))?Oi(a):a}}}return Oi(r)}function qD(r,e){let t=e.split(".").map(i=>parseInt(i,10)),n=t.pop(),o=Qt(r,e);if(o!=null&&typeof n=="number"){let{children:i}=o.props;if(n>0)return Ni(i[n-1]);for(;t.length>1;)if(n=t.pop(),o=Qt(r,q(o,"path")),n>0){let s=o.props.children[n-1];return ze(K(s))?Ni(s):s}}return Ni(r)}function Oi(r){if(ze(K(r))){let{children:e}=r.props||r;return Oi(e[0])}return r}function Ni(r){if(ze(K(r))){let{children:e}=r.props||r;return Ni(e[e.length-1])}return r}function Et(r,e,t=!1){if(r===e)return{idx:-1,finalStep:!0};let n=`${r}.`;if(!e.startsWith(n))throw Error("pathUtils nextStep has strayed from the path");let o=t?0:1,i=e.replace(n,"").split(".").map(s=>parseInt(s,10));return{idx:i[0],finalStep:i.length===o}}function Ee(r,e,t){if(q(r,"path")===e)return r;let n=[];dn.Children.forEach(r.props.children,(i,s)=>{q(i,"path")?n.push(Ee(i,`${e}.${s}`)):n.push(i)});let o=r.props["data-path"]?"data-path":"path";return dn.cloneElement(r,{[o]:e,...t},n)}function jD(r,e){typeof r=="function"?r(e):r&&(r.current=e)}import{Children as Px,isValidElement as Jh,useLayoutEffect as Dx,useMemo as Lx,useRef as Ax}from"react";var Ox=[],Nx=0,wr=r=>{let e=Array.isArray(r),t=e?r.length:Px.count(r);return e&&r.every(Jh)?r:t===1&&!e&&Jh(r)?[r]:t>1?r:Ox},Qh=(r,e)=>{let t=Ax(!1);Dx(()=>{t.current?r():t.current=!0},e)},Sr=r=>Lx(()=>r!=null?r:`vuu-${++Nx}`,[r]);var oa=r=>{if(typeof r!="number")throw Error(`"no support yet for flex value ${r}`);return{flexBasis:0,flexGrow:1,flexShrink:1}};import{boxContainsPoint as Vi}from"@vuu-ui/vuu-utils";var Hn={north:1,east:2,south:4,west:8,header:16,centre:32,absolute:64},vo={AFTER:"after",BEFORE:"before"},Ze=Object.freeze({North:Bn("north"),East:Bn("east"),South:Bn("south"),West:Bn("west"),Header:Bn("header"),Centre:Bn("centre"),Absolute:Bn("absolute")});function Bn(r){return Object.freeze({offset:r==="north"||r==="west"?0:r==="south"||r==="east"?1:NaN,valueOf:function(){return Hn[r]},toString:function(){return r},North:r==="north",South:r==="south",East:r==="east",West:r==="west",Header:r==="header",Centre:r==="centre",NorthOrSouth:r==="north"||r==="south",EastOrWest:r==="east"||r==="west",NorthOrWest:r==="north"||r==="west",SouthOrEast:r==="east"||r==="south",Absolute:r==="absolute"})}var Yh=Ze.North,Xh=Ze.South,ia=Ze.East,sa=Ze.West,Vx=Ze.Header,Fx=Ze.Centre,Cr=class{static measure(e,t=[]){let n={};return _x(e,n,t),n}static allBoxesContainingPoint(e,t,n,o,i){return nf(e,t,n,o,i).reverse()}};function la(r,e,t,n=30){let o=t.right-t.left,i=t.bottom-t.top,s=r-t.left,l=e-t.top,a=0;return s<n&&(a+=8),s>o-n&&(a+=2),l<n&&(a+=1),l>i-n&&(a+=4),{pctX:s/o,pctY:l/i,closeToTheEdge:a}}function aa(r,e,t,n){let{BEFORE:o,AFTER:i}=vo,{pctX:s,pctY:l,closeToTheEdge:a}=la(r,e,t),c,u;if(n==="row")c=s<.5?sa:ia;else if(t.header&&Vi(t.header,r,e))if(c=Vx,t.Stack){let h=t.Stack.length;if(h===0)u={index:-1,left:t.left,positionRelativeToTab:i,width:0};else{let f=t.Stack.find(({left:d,right:p})=>r>=d&&r<=p);if(f){let d=f.right-f.left;u={index:t.Stack.indexOf(f),left:f.left,positionRelativeToTab:(r-f.left)/d<.5?o:i,width:d}}else u={left:t.Stack[h-1].right,width:0,index:h,positionRelativeToTab:i}}}else if(t.header.titleWidth){let h=t.header.titleWidth;u={index:-1,left:t.left,positionRelativeToTab:(r-t.left)/h<.5?o:i,width:h}}else u={left:t.left,width:0,positionRelativeToTab:o,index:-1};else c=Bx(r,e,t,s,l);return{position:c,x:r,y:e,closeToTheEdge:a,tab:u}}function Bx(r,e,t,n,o){let i=Hx(t,.2);if(Vi(i,r,e))return Fx;switch(`${o<.5?"north":"south"}${n<.5?"west":"east"}`){case"northwest":return n>o?Yh:sa;case"northeast":return 1-n>o?Yh:ia;case"southeast":return n>o?ia:Xh;case"southwest":return 1-n>o?sa:Xh;default:}}function Hx({right:r,left:e,top:t,bottom:n},o){let i=(1-o)/2,s=(r-e)*i,l=(n-t)*i;return{left:e+s,top:t+l,right:r-s,bottom:n-l}}function _x(r,e,t){let{id:n,"data-path":o,path:i=o}=_(r),s=K(r);if(n&&i){let[l,a]=tf(r);Zh(r,l,a,e),ze(s)&&ef(r,e,t)}}function Zh(r,e,t,n){let{"data-path":o,path:i=o,header:s}=_(r);n[i]=e;let l=K(r);if(s||l==="Stack"){let a=l==="Stack"?".vuuTabstrip":".vuuHeader",c=t.querySelector(a);if(c){let{top:u,left:h,right:f,bottom:d}=c.getBoundingClientRect();if(n[i].header={top:Math.round(u),left:Math.round(h),right:Math.round(f),bottom:Math.round(d)},l==="Stack")n[i].Stack=Array.from(c.querySelectorAll(".vuuTab")).map(p=>p.getBoundingClientRect()).map(({left:p,right:m})=>({left:p,right:m}));else{let p=c.querySelector('[class^="vuuHeader-title"]'),{header:m}=n[i];p&&m&&(m.titleWidth=p.clientWidth)}}}return n[i]}function ef(r,e,t,n=0,o=0,i=0,s=0){let{children:l,"data-path":a,path:c=a,style:u,active:h=0}=_(r),f=K(r),d=f==="Flexbox",p=f==="Stack",m=d&&u.flexDirection==="column",y=d&&u.flexDirection==="row",v=(p?l.filter((x,S)=>S===h):l.filter(zx)).map(x=>{let[S,b]=tf(x);return[{...S,top:S.top-i,right:S.right+o,bottom:S.bottom+s,left:S.left-n},b,x]}),w=v.map(([x,S,b],C,k)=>{let E,R,M,P,I,V,B=k.length-1;y?(I=C===0?0:x.left-k[C-1][0].right,V=C===B?0:k[C+1][0].left-x.right,E=C===0||I===0?0:I,R=C===B||V===0?0:V-V/2,x.left-=E,x.right+=R,M=i,P=s):m&&(I=C===0?0:x.top-k[C-1][0].bottom,V=C===B?0:k[C+1][0].top-x.bottom,M=C===0||I===0?0:I,P=C===B||V===0?0:V-V/2,x.top-=M,x.bottom+=P,E=n,R=o);let W=Zh(b,x,S,e),O=K(b);return ze(O)&&ef(b,e,t,E,R,M,P),W});v.length&&(e[c].children=w)}function zx(r){let{id:e}=_(r),t=document.getElementById(e);return t?t.dataset.dragging!=="true":(console.warn(`BoxModel: no element found with id #${e}`),!1)}function tf(r){let{id:e}=_(r);if(e===void 0)throw Error("`BoxModel.measureComponentElement, component has no id");let t=document.getElementById(e);if(!t)throw Error("BoxModel.measureComponentElement, no DOM element found for component");let{top:n,left:o,right:i,bottom:s,height:l,width:a}=t.getBoundingClientRect(),c,u=K(r);if(ze(u)){let h=t.scrollHeight;h>l&&(c={id:e,scrollHeight:h,scrollTop:t.scrollTop})}return[{top:Math.round(n),left:Math.round(o),right:Math.round(i),bottom:Math.round(s),height:Math.round(l),width:Math.round(a),scrolling:c},t,r]}function nf(r,e,t,n,o,i=[]){let{children:s,"data-path":l,path:a=l}=_(r),c=K(r),u=e[a];if(!Vi(u,t,n))return i;if(o&&o.length){if(o.includes(a))i.push(r);else if(!o.some(h=>h.startsWith(a)))return i}else i.push(r);if(!ze(c)||u.header&&Vi(u.header,t,n))return i;u.scrolling&&Wx(u,t,n);for(let h=0;h<s.length;h++){if(c==="Stack"&&r.props.active!==h)continue;let f=nf(s[h],e,t,n,o);if(f.length)return i.concat(f)}return i}function Wx({top:r,bottom:e,scrolling:t},n,o){if(t){let{id:i,scrollTop:s,scrollHeight:l}=t,a=e-r;if(s===0&&e-o<50){let c=l-a;document.getElementById(i).scrollTo({left:0,top:c,behavior:"smooth"}),t.scrollTop=c}else if(s>0&&o-r<50)document.getElementById(i).scrollTo({left:0,top:0,behavior:"smooth"}),t.scrollTop=0;else return!1}else return!1}var $x=.4,Fi=class{constructor(e,t,n,o,i){this.init(e,t,n,o,i)}init(e,t,n,o,i){let{left:s,top:l}=o,{pctX:a,pctY:c}=la(t,n,o),u=$x,h=a*o.width,f=o.width-h,d=c*o.height,p=o.height-d,m=o.width*u,y=o.height*u,g=1-u,v=h*g,w=d*g,x=f*g,S=p*g;this.intrinsicSize=i,this.constraint={zone:{x:{lo:e.left,hi:e.right},y:{lo:e.top,hi:e.bottom}},pos:{x:{lo:e.left-v,hi:e.right-o.width+x},y:{lo:e.top-w,hi:e.bottom-o.height+S}},mouse:{x:{lo:e.left+m*a,hi:e.right-m*(1-a)},y:{lo:e.top+y*c,hi:e.bottom-y*(1-c)}}},this.x={pos:s,lo:!1,hi:!1,mousePos:t,mousePct:a},this.y={pos:l,lo:!1,hi:!1,mousePos:n,mousePct:c}}outOfBounds(){return this.x.lo||this.x.hi||this.y.lo||this.y.hi}inBounds(){return!this.outOfBounds()}dropX(){return this.dropXY("x")}dropY(){return this.dropXY("y")}hasIntrinsicSize(){var e,t;return((e=this==null?void 0:this.intrinsicSize)==null?void 0:e.height)&&((t=this==null?void 0:this.intrinsicSize)==null?void 0:t.width)}update(e,t){let n=this[e],o=this.constraint.mouse[e],i=this.constraint.pos[e],s=n.pos,l=t-n.mousePos;return l<0?n.lo||(t<o.lo?(n.lo=!0,n.pos=i.lo):n.hi?t<o.hi&&(n.hi=!1,n.pos+=l):n.pos+=l):l>0&&(n.hi||(t>o.hi?(n.hi=!0,n.pos=i.hi):n.lo?t>o.lo&&(n.lo=!1,n.pos+=l):n.pos+=l)),n.mousePos=t,s!==n.pos}dropXY(e){let t=this[e],n=this.constraint.zone[e];return t.lo?Math.max(n.lo,t.mousePos):t.hi?Math.min(t.mousePos,Math.round(n.hi)-1):t.mousePos}};var xL=r=>r.pos.tab&&K(r.component)==="Stack"&&r.pos.position.Header,{north:Ux,south:Gx,east:qx,west:Kx}=Hn,jx=qx+Kx,Jx=Ux+Gx,pn=class{constructor({component:e,pos:t,clientRect:n,nextDropTarget:o}){this.component=e,this.pos=t,this.clientRect=n,this.nextDropTarget=o,this.active=!1,this.dropRect=void 0}targetTabPos(e){let{left:t,width:n,positionRelativeToTab:o}=e;return o===vo.BEFORE?t:t+n}getTargetDropOutline(e,t){if(this.pos.tab)return this.getDropTabOutline(e,this.pos.tab);if(t&&t.hasIntrinsicSize())return this.getIntrinsicDropRect(t);{let[n,o,i,s]=this.getDropRectOutline(e,t);return{l:n,t:o,r:i,b:s}}}getDropTabOutline(e,t){var g,v;let{clientRect:{top:n,left:o,right:i,bottom:s,header:l}}=this,a=0,c=Math.round(e/2)+a,u=Math.round(n),h=Math.round(o+c),f=Math.round(i-c),d=Math.round(s-c),p=this.targetTabPos(t),m=60,y=((g=l==null?void 0:l.bottom)!=null?g:0)-((v=l==null?void 0:l.top)!=null?v:0);return{l:h,t:u,r:f,b:d,tabLeft:p,tabWidth:m,tabHeight:y}}getIntrinsicDropRect(e){var m,y,g,v;let{pos:t,clientRect:n}=this,{x:o,y:i}=e,s=(y=(m=e.intrinsicSize)==null?void 0:m.height)!=null?y:0,l=(v=(g=e.intrinsicSize)==null?void 0:g.height)!=null?v:0;s&&s>n.height?(console.log("DropTarget: we're going to blow the gaff"),s=n.height):l&&l>n.width&&(console.log("DropTarget: we're going to blow the gaff"),l=n.width);let a=Math.min(n.right-l,Math.max(n.left,Math.round(t.x-o.mousePct*l))),c=Math.min(n.bottom-s,Math.max(n.top,Math.round(t.y-i.mousePct*s))),[u,h,f,d]=this.dropRect=[a,c,a+l,c+s],p=t.position.EastOrWest?[u,n.top,u,n.bottom,f,n.top,f,n.bottom]:[n.left,h,n.right,h,n.left,d,n.right,d];return{l:u,r:f,t:h,b:d,guideLines:p}}getDropRectOutline(e,t){var v,w,x;let{pos:n,clientRect:o}=this,{width:i,height:s,position:l}=n,{width:a,height:c}=(v=t==null?void 0:t.intrinsicSize)!=null?v:{},u=(w=c!=null?c:s)!=null?w:0,h=(x=a!=null?a:i)!=null?x:0;this.dropRect=void 0;let{top:f,left:d,right:p,bottom:m}=o,y=0,g=Math.round(e/2)+y;switch(l){case Ze.North:case Ze.Header:{let S=Math.round((m-f)/2),b=u?Math.min(S,Math.round(u)):S;return h&&d+h<p?[d+g,f+g,d+h-g,f+g+b]:[d+g,f+g,p-g,f+g+b]}case Ze.West:{let S=Math.round((p-d)/2),b=h?Math.min(S,Math.round(h)):S;return u&&f+u<m?[d+g,f+g,d-g+b,f+u+g]:[d+g,f+g,d-g+b,m-g]}case Ze.East:{let S=Math.round((p-d)/2),b=h?Math.min(S,Math.round(h)):S;return u&&f+u<m?[p-g-b,f+g,p-g,f+u+g]:[p-g-b,f+g,p-g,m-g]}case Ze.South:{let S=Math.round((m-f)/2),b=u?Math.min(S,Math.round(u)):S;return h&&d+h<p?[d+g,m-g-b,d+h-g,m-g]:[d+g,m-g-b,p-g,m-g]}case Ze.Centre:return[d+g,f+g,p-g,m-g];default:return console.warn(`DropTarget does not recognize position ${l}`),null}}activate(){return this.active=!0,this}toArray(){let e=this,t=[e];for(;e=e.nextDropTarget;)t.push(e);return t}static getActiveDropTarget(e){return e===null?null:e!=null&&e.active?e:pn.getActiveDropTarget(e.nextDropTarget)}};function ca(r,e,t,n,o,i){var a;let s=null,l=Cr.allBoxesContainingPoint(t,n,r,e,i);if(l.length){let[c,...u]=l,{"data-path":h,path:f=h,"data-row-placeholder":d}=_(c),p=n[f],y=aa(r,e,p,o&&d?"row":void 0),g=n[f],v=([w,...x])=>{var S,b;if((S=y.position)!=null&&S.Header||y.closeToTheEdge){let C=Qx(w,y,g,n,r,e);if(C){let[k,E]=C;return new pn({component:w,pos:k,clientRect:E,nextDropTarget:(b=v(x))!=null?b:null})}else if(x.length)return v(x)}};s=new pn({component:c,pos:y,clientRect:p,nextDropTarget:(a=v(u))!=null?a:null}).activate()}return s}function Qx(r,{closeToTheEdge:e,position:t},n,o,i,s){if(!r||r.type==="DraggableLayout")return;let l=o[r.props.path],a=e&Hn.north,c=e&Hn.east,u=e&Hn.south,h=e&Hn.west,f=(a||t.Header)&&Math.round(n.top)===Math.round(l.top),d=c&&Math.round(n.right)===Math.round(l.right),p=u&&Math.round(n.bottom)===Math.round(l.bottom),m=h&&Math.round(n.left)===Math.round(l.left);if(f||d||p||m){let{"data-path":y,path:g=y}=r.props,v=o[g],w=aa(i,s,v);if((Yx(r)||rf(r))&&e&jx)return w.width=120,[w,v];if((Xx(r)||rf(r))&&(t.Header||e&Jx))return w.height=120,[w,v]}}function rf(r){return K(r)==="Stack"}function Yx(r){return K(r)==="Flexbox"&&r.props.style.flexDirection==="column"}function Xx(r){return K(r)==="Flexbox"&&r.props.style.flexDirection==="row"}import{PopupService as ha}from"@vuu-ui/vuu-popups";import Zx from"classnames";import{jsx as of}from"react/jsx-runtime";function sf(r,e=0,t=0){let{pos:n,clientRect:o}=r,i=20;return n.position.West?[o.left-t+i,n.y-e,"left"]:n.position.South?[n.x-t,o.bottom-e-i,"bottom"]:n.position.East?[o.right-t-i,n.y-e,"right"]:[n.x-t,o.top-e+i,"top"]}var ua="vuuDropMenu",lf=({className:r,dropTarget:e,onHover:t,orientation:n})=>{let o=e.toArray();return of("div",{className:Zx(ua,r,`${ua}-${n}`),onMouseLeave:()=>t(null),children:o.map((i,s)=>of("div",{className:`${ua}-item`,"data-icon":s===0?"column-2A":"column-2B",onMouseEnter:()=>t(i)},s))})};import{jsx as sv}from"react/jsx-runtime";var fa=!1,wo=null,Rt=null,ev=r=>wo=r,tv=([r,e])=>`M${r},${e}`,nv=([r,e])=>`L${r},${e}`,af=([r,...e])=>`${tv(r)} ${e.map(nv)}Z`,rv=r=>{if(r){let[e,t,n,o,i,s,l,a]=r;return`M${e},${t} L${n},${o} M${i},${s} L${l},${a}`}else return""};function ov(){if(document.getElementById("hw-drag-canvas")===null){let r=document.getElementById("root"),e=document.createElement("div");e.id="hw-drag-canvas",e.innerHTML=`
2
2
  <svg width="100%" height="100%">
3
3
  <path id="hw-drop-guides" />
4
4
  <path
@@ -14,20 +14,20 @@ var Oh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var T=(r,e,t)=>(Oh(r
14
14
  />
15
15
  </path>
16
16
  </svg>
17
- `,document.body.insertBefore(e,r)}}var wo=class{constructor(){this.currentPath=null;this.tabMode=null;tv()}prepare(e,t="full-view"){document.body.classList.add("drawing"),this.currentPath=null,this.tabMode=t;let n=this.getPoints(0,0,0,0),o=uf(n),i=document.getElementById("vuu-drop-outline");i==null||i.setAttribute("d",o),this.currentPath=o}clear(){vo=null,Fi(),document.body.classList.remove("drawing"),ha.hidePopup()}get hoverDropTarget(){return vo}getPoints(e,t,n,o,i=0,s=0,l=0){let a=this.tabMode==="tab-only";if(s===0)return[[e,t+l],[e,t+l],[e,t],[e+s,t],[e+s,t],[e+n,t],[e+n,t+o],[e,t+o]];if(a){let c=i;return[[c,t],[c,t],[c+s,t],[c+s,t],[c+s,t+l],[c+s,t+l],[c,t+l],[c,t+l]]}else return i===0?[[e,t+l],[e,t+l],[e,t],[e+s,t],[e+s,t+l],[e+n,t+l],[e+n,t+o],[e,t+o]]:[[e,t+l],[e+i,t+l],[e+i,t],[e+i,t],[e+i,t+l],[e+n,t+l],[e+n,t+o],[e,t+o]]}draw(e,t){let o=fa;if(vo!==null)this.drawTarget(vo);else if(fa=e.nextDropTarget!=null,e.pos.tab?nv(e):Et&&Fi(),this.drawTarget(e,t),fa){let[i,s,l]=af(e);{let a=rv(cf,{dropTarget:e,onHover:Yx,orientation:l});ha.showPopup({left:i,top:s,component:a})}}else ha.hidePopup()}drawTarget(e,t){let o=e.getTargetDropOutline(6,t);if(o){let{l:i,t:s,r:l,b:a,tabLeft:c,tabWidth:u,tabHeight:h,guideLines:f}=o,d=l-i,p=a-s;if(this.currentPath){let w=document.getElementById("vuu-drop-outline");w==null||w.setAttribute("d",this.currentPath)}let m=this.getPoints(i,s,d,p,c,u,h),g=uf(m),y=document.getElementById("hw-drop-outline-animate");y==null||y.setAttribute("to",g),y==null||y.beginElement(),this.currentPath=g;let v=document.getElementById("hw-drop-guides");v==null||v.setAttribute("d",ev(f))}}},hf="transition:margin-left .4s ease-out;margin-left: 63px",ff="transition:margin-left .4s ease-out;margin-left: 0px";function nv(r){var l,a;let{AFTER:e,BEFORE:t}=xo,{clientRect:{Stack:n},pos:{tab:o}}=r,{id:i}=r.component.props,s=null;if(n&&o&&o.positionRelativeToTab!==e){let c=o.positionRelativeToTab===t?1:2,u=`:scope .hwTabstrip > .hwTabstrip-inner > .hwTab:nth-child(${o.index+c})`;s=(l=document.getElementById(i))==null?void 0:l.querySelector(u),s?(Et===null||Et!==s)&&(s.style.cssText=hf,Et&&(Et.style.cssText=ff),Et=s):Fi()}else if((o==null?void 0:o.positionRelativeToTab)===t){if(Et===null){let c=".vuuHeader-title";s=(a=document.getElementById(i))==null?void 0:a.querySelector(c),s.style.cssText=hf,Et=s}}else Fi()}function Fi(){Et&&(Et.style.cssText=ff,Et=null)}var Xt,So,mn,pf,mf,_n,Bi,zn=null,pa,gf,_i,yf,da,Hi=null,ov=3,zi=new wo,df=.4;function iv(r,e){return e?Te(r,e):Yt(r,t=>t.dropTarget)}var ma={handleMousedown(r,e,t={}){Xt=e,gf=t,pf=r.clientX,mf=r.clientY,da=t.dragThreshold===void 0?ov:t.dragThreshold,da===0?Xt(r,0,0):(window.addEventListener("mousemove",Wi,!1),window.addEventListener("mouseup",$i,!1),Hi=window.setTimeout(()=>{window.removeEventListener("mousemove",Wi,!1),window.removeEventListener("mouseup",$i,!1),Xt==null||Xt(r,0,0)},500)),r.preventDefault()},initDrag(r,e,{top:t,left:n,right:o,bottom:i},s,l,a,c){return{drag:So,drop:mn}=l,sv(r,e,{top:t,left:n,right:o,bottom:i},s,a,c)}};function Wi(r){let n=r.clientX-pf,o=r.clientY-mf;Math.max(Math.abs(n),Math.abs(o))>da&&(window.removeEventListener("mousemove",Wi,!1),window.removeEventListener("mouseup",$i,!1),Xt==null||Xt(r,n,o),Xt=null)}function $i(){Hi&&(window.clearTimeout(Hi),Hi=null),window.removeEventListener("mousemove",Wi,!1),window.removeEventListener("mouseup",$i,!1)}function sv(r,e,t,n,o,i){_n=iv(r,e);let{"data-path":s,path:l=s}=_(_n);i&&(pa=i.map(f=>Yt(r,d=>d.id===f)).map(f=>f.props.path)),_i=Cr.measure(_n,i);let a=_i[l];Bi=new Vi(a,n.x,n.y,t,o);let c=Math.round(Bi.x.mousePct*100),u=Math.round(Bi.y.mousePct*100);return window.addEventListener("mousemove",bf,!1),window.addEventListener("mouseup",vf,!1),window.addEventListener("keydown",xf,!1),yf=!1,zi.prepare(t,"tab-only"),gf.DoNotTransform?"transform:none":`transform:scale(${df},${df});transform-origin:${c}% ${u}%;`}function bf(r){let e=r.clientX,t=r.clientY,n=Bi,o=zn,i,s,l;n.update("x",e)&&(s=n.x.pos),n.update("y",t)&&(l=n.y.pos),s===void 0&&l===void 0||So==null||So(s,l),!(yf||_n===void 0)&&(n.inBounds()?i=ca(e,t,_n,_i,n.hasIntrinsicSize(),pa):i=ca(n.dropX(),n.dropY(),_n,_i),o&&(i==null||i.box!==o.box)&&(zn=null),i&&(zi.draw(i,n),zn=i))}function xf(r){r.key==="Escape"&&(zn=null,wf())}function vf(){wf()}function wf(){if(zn){let r=zi.hoverDropTarget||pn.getActiveDropTarget(zn);mn==null||mn(r),zn=null}else mn==null||mn();So=null,mn=null,_n=void 0,zi.clear(),pa=void 0,window.removeEventListener("mousemove",bf,!1),window.removeEventListener("mouseup",vf,!1),window.removeEventListener("keydown",xf,!1)}import lv from"classnames";import{forwardRef as av}from"react";import{jsx as cv}from"react/jsx-runtime";var Co=av(function({children:e,className:t,dropTarget:n,resizeable:o,...i},s){let l=lv("DraggableLayout",t);return cv("div",{className:l,ref:s,...i,children:e})}),Sf="DraggableLayout";Co.displayName=Sf;ge(Sf,Co,"container");import{useForkRef as Lv}from"@salt-ds/core";import Av from"classnames";import{forwardRef as Ov}from"react";import{getUniqueId as kv}from"@vuu-ui/vuu-utils";import Ro,{useCallback as Ji,useMemo as Of,useRef as Qi,useState as Mv}from"react";import uv from"classnames";import{jsx as hv}from"react/jsx-runtime";var Cf="vuuPlaceholder",Ui=({className:r,closeable:e,flexFill:t,resizeable:n,shim:o,...i})=>hv("div",{className:uv(Cf,r,{[`${Cf}-shim`]:o}),...i,"data-placeholder":!0,"data-resizeable":!0});Ui.displayName="Placeholder";ge("Placeholder",Ui);import fv from"classnames";import dv,{useCallback as To,useRef as Gi,useState as pv}from"react";import{jsx as Tf}from"react/jsx-runtime";var qi="vuuSplitter",kf=dv.memo(function({column:e,index:t,onDrag:n,onDragEnd:o,onDragStart:i,style:s}){let l=Gi(),a=Gi(null),c=Gi(0),[u,h]=pv(!1),f=To(({key:b,shiftKey:C})=>{let k=C?10:1;e&&b==="ArrowDown"?n(t,k):e&&b==="ArrowUp"||!e&&b==="ArrowLeft"?n(t,-k):!e&&b==="ArrowRight"&&n(t,k)},[e,t,n]),d=To(b=>{let{key:C}=b;(e&&(C==="ArrowUp"||C==="ArrowDown")||!e&&(C==="ArrowLeft"||C==="ArrowRight"))&&(i(t),f(b),p.current=f)},[e,f,t,i]),p=Gi(d),m=b=>p.current(b),g=To(b=>{l.current=!0;let C=b[e?"clientY":"clientX"],k=C-c.current;C&&C!==c.current&&n(t,k),c.current=C},[e,t,n]),y=To(()=>{var b;window.removeEventListener("mousemove",g,!1),window.removeEventListener("mouseup",y,!1),o(),h(!1),(b=a.current)==null||b.focus()},[g,o,h]),v=To(b=>{c.current=e?b.clientY:b.clientX,i(t),window.addEventListener("mousemove",g,!1),window.addEventListener("mouseup",y,!1),b.preventDefault(),h(!0)},[e,g,y,t,i,h]),w=()=>{var b;l.current?l.current=!1:(b=a.current)==null||b.focus()},x=()=>{p.current=d},S=fv(qi,{[`${qi}-active`]:u,[`${qi}-column`]:e});return Tf("div",{className:S,"data-splitter":!0,ref:a,role:"separator",style:s,onBlur:x,onClick:w,onKeyDown:m,onMouseDown:v,tabIndex:0,children:Tf("div",{className:`${qi}-grab-zone`})})});import{uuid as Mf}from"@vuu-ui/vuu-utils";import Ef from"react";var mv={"data-placeholder":!0,"data-resizeable":!0},Ki={},gn="auto",ga={flexBasis:0,flexGrow:1,flexShrink:1,height:gn,width:gn},Rf={height:"width",width:"height"},If=(r="row")=>r==="row"?["width","height","column"]:["height","width","row"],gv=r=>typeof r=="string"&&r.endsWith("%"),at=r=>{let{style:{width:e=gn,height:t=gn}=Ki}=r.props,n=typeof t=="number",o=typeof e=="number";return n&&o?{height:t,width:e}:n?{height:t}:o?{width:e}:void 0};function ya(r,e,t){let n=Rf[e],{style:{[n]:o=gn,...i}=Ki}=r.props;return t&&t[e]?{...i,...ga,flexBasis:t[e],flexGrow:0,flexShrink:0}:{...i,...ga,[n]:o}}function Pf(r){let{style:{flex:e,flexGrow:t,flexShrink:n,flexBasis:o}=Ki}=r.props;return typeof e=="number"||o===0&&t===1&&n===1?!0:typeof o!="number"}function ba(r,e,t){let n=Rf[e],{style:{[e]:o=gn,[n]:i=gn,...s}=Ki}=r.props;return o!==gn?gv(o)?{flexBasis:0,flexGrow:1,flexShrink:1,[e]:void 0,[n]:i}:{flexBasis:o,flexGrow:0,flexShrink:0,[e]:o,[n]:i}:t&&t[e]?{...s,...ga,flexBasis:t[e],flexGrow:0,flexShrink:0}:{...s,[n]:i}}function ko(r,e,t,n,o){let i=[],s=0,l;if(n&&o){let u,[h,f,d,p]=o;[u,l]=e==="column"?[f-n.top,n.bottom-p]:[h-n.left,n.right-d],u&&i.push(Ft(`${t}.${s++}`,u,{flexGrow:0,flexShrink:0}))}else l=!0;let{version:a=0,style:c}=_(r);return i.push(Ee(r,`${t}.${s++}`,{version:a+1,style:{...c,flexBasis:"auto",flexGrow:0,flexShrink:0}})),l&&i.push(Ft(`${t}.${s++}`,0,void 0,{[`data-${e}-placeholder`]:!0})),xa(e,{resizeable:!1,style:{flexBasis:"auto"}},i,t)}var yv=(r,e)=>{if(!e)return r===0?1:0};function xa(r,e,t,n){let o=Mf(),{flexFill:i,style:s,resizeable:l=!0}=e,{flexBasis:a=i?void 0:"auto"}=s,c=yv(a,i);return Ef.createElement(Fn.Flexbox,{id:o,key:o,path:n,flexFill:i,style:{...s,flexDirection:r,flexBasis:a,flexGrow:c,flexShrink:c},resizeable:l},t)}var bv={flexGrow:1,flexShrink:1};function Ft(r,e,t,n){let o=Mf();return Ef.createElement("div",{...mv,...n,"data-path":r,id:o,key:o,style:{...bv,...t,flexBasis:e}})}var xv={},Mo=1,Eo=2,vv=r=>typeof r.intrinsicSize=="number",wv=(r,e)=>{let t={};return r.forEach(n=>{t[n]=q(e,n)}),t},ji=(r,e,t)=>r.map((n,o)=>{var a;let i=q(n,"resizeable"),{[e]:s}=(a=at(n))!=null?a:xv,l=Pf(n);return t?{index:o,flexOpen:l,intrinsicSize:s,resizeable:i,...wv(t,n)}:{index:o,flexOpen:l,intrinsicSize:s,resizeable:i}}),Df=r=>{let e=r.length,t=r.every(vv),n=Array(e).fill(0);if(t&&e>0&&(n[0]=Eo,n[e-1]=Eo),e<2)return n;for(let o=0,i=0;o<e-1;o++)r[o].resizeable&&!i&&(i=Mo),n[o]+=i;for(let o=e-1;o>0&&(n[o]&Mo&&(n[o]-=Mo),!r[o].resizeable);o--);return n},Lf=(r,e)=>{let t=Cv(r,e),n=Tv(r,e),o=t!==-1&&n!==-1?[t,n]:void 0,i=Sv(r,o);return[o,i]};function Sv(r,e){if(e){let t=[];for(let n=0;n<r.length;n++)r[n].flexOpen&&!e.includes(n)&&t.push(n);return t}}function Cv(r,e){let t=e,n=!1;for(;t>=1&&!n;)t=t-1,n=Af(r,t);return t}function Tv(r,e){let t=e,n=!1,o=r.length;for(;t<o-1&&!n;)t=t+1,n=Af(r,t);return t===o?-1:t}function Af(r,e){let{placeholder:t,splitter:n,resizeable:o,intrinsicSize:i}=r[e];return!!(!n&&!i&&(t||o))}var Ev=r=>!r.splitter&&!r.placeholder,Vf=({children:r,onSplitterMoved:e,style:t})=>{let n=Qi(null),o=Qi(),i=Qi(),s=Qi([]),[,l]=Mv({}),a=g=>{i.current=g,l({})},c=(t==null?void 0:t.flexDirection)==="column",u=c?"height":"width",h=Of(()=>Array.isArray(r)?r:Ro.isValidElement(r)?[r]:[],[r]),f=Ji(g=>{let{current:y}=o;if(y){let[v,w]=Lf(y,g);v&&(v.forEach(x=>{var b;let S=(b=n.current)==null?void 0:b.childNodes[x];if(S){let{size:C,minSize:k}=Dv(S,u);y[x].currentSize=C,y[x].minSize=k}}),w&&w.forEach(x=>{var b;let S=(b=n.current)==null?void 0:b.childNodes[x];if(S){let{[u]:C}=S.getBoundingClientRect();y[x].flexBasis=C}}))}},[u]),d=Ji((g,y)=>{i.current&&o.current&&a(Iv(i.current,o.current,y,u))},[u]),p=Ji(()=>{let g=o.current;g&&(e==null||e(g.filter(Ev))),g==null||g.forEach(y=>{y.currentSize=void 0,y.flexBasis=void 0,y.flexOpen=!1})},[e]),m=Ji(g=>Ro.createElement(kf,{column:c,index:g,key:`splitter-${g}`,onDrag:d,onDragEnd:p,onDragStart:f}),[d,p,f,c]);return Of(()=>{let[g,y]=Rv(h,u,m,s.current);o.current=y,i.current=g},[h,m,u]),{content:i.current||[],rootRef:n}};function Rv(r,e,t,n){let o=ji(r,e),i=Df(o),s=[],l=[];for(let a=0;a<r.length;a++){let c=r[a];if(a===0&&i[a]&Eo&&(s.push(Nf(a)),l.push({placeholder:!0,shim:!0})),c.key==null){let u=n[a]||(n[a]=kv());s.push(Ro.cloneElement(c,{key:u}))}else s.push(c);l.push(o[a]),a>0&&i[a]&Eo?(s.push(Nf(a)),l.push({placeholder:!0})):i[a]&Mo&&(s.push(t(s.length)),l.push({splitter:!0}))}return[s,l]}function Iv(r,e,t,n){return Pv(e,t)?r.map((i,s)=>{let l=e[s],{currentSize:a,flexOpen:c,flexBasis:u}=l,h=a!==void 0;if(h||c){let{flexBasis:f}=i.props.style||{},d=h?l.currentSize:u;return d!==f?Ro.cloneElement(i,{style:{...i.props.style,flexBasis:d,[n]:"auto"}}):i}else return i}):r}function Pv(r,e){let t=[];r.forEach((u,h)=>{u.currentSize!==void 0&&t.push(h)});let n=e<0?t[0]:t[1],{currentSize:o=0,minSize:i=0}=r[n];if(o===i)return!1;if(Math.abs(e)>o-i){let u=e<0?-1:1;e=Math.max(0,o-i)*u}let s=r[t[0]],{currentSize:l=0}=s;s.currentSize=l+e;let a=r[t[1]],{currentSize:c=0}=a;return a.currentSize=c-e,!0}function Nf(r){return Ro.createElement(Ui,{shim:r===0,key:`placeholder-${r}`})}function Dv(r,e){let{[e]:t}=r.getBoundingClientRect(),o=getComputedStyle(r).getPropertyValue(`min-${e}`),i=o.endsWith("px")?parseInt(o,10):0;return{size:t,minSize:i}}import{jsx as Nv}from"react/jsx-runtime";var va="hwFlexbox",Ff=Ov(function(e,t){let{breakPoints:n,children:o,column:i,className:s,flexFill:l,gap:a,fullPage:c,id:u,onSplitterMoved:h,resizeable:f,row:d,spacing:p,splitterSize:m,style:g,...y}=e,{content:v,rootRef:w}=Vf({children:o,onSplitterMoved:h,style:g}),x=Av(va,s,{[`${va}-column`]:i,[`${va}-row`]:d,"flex-fill":l,"full-page":c});return Nv("div",{...y,className:x,"data-resizeable":f||void 0,id:u,ref:Lv(w,t),style:{...g,gap:a,"--spacing":p},children:v})});Ff.displayName="Flexbox";var Io=Ff;import{useCallback as kw}from"react";var Wn={ADD:"add",BLUR:"blur",BLUR_SPLITTER:"blur-splitter",DRAG_START:"drag-start",DRAG_STARTED:"drag-started",DRAG_DROP:"drag-drop",FOCUS:"focus",FOCUS_SPLITTER:"focus-splitter",INITIALIZE:"initialize",LAYOUT_RESIZE:"layout-resize",MAXIMIZE:"maximize",MINIMIZE:"minimize",REMOVE:"remove",REPLACE:"replace",RESTORE:"restore",SAVE:"save",SET_TITLE:"set-title",SPLITTER_RESIZE:"splitter-resize",SWITCH_TAB:"switch-tab",TEAR_OUT:"tear-out"};import{useCallback as Ra,useContext as Ia,useEffect as vw,useRef as dd,useState as ww}from"react";import Ma from"react";import{uuid as Gf}from"@vuu-ui/vuu-utils";import Lo from"react";import{uuid as zf}from"@vuu-ui/vuu-utils";import Po,{cloneElement as Vv}from"react";import{useCallback as Tr}from"react";var We=new Map,ct=new Map,Bf=r=>We.get(r),Hf=r=>We.has(r),_f=(r,e)=>We.set(r,e),kr=()=>{let r=Tr((s,l)=>{let a=ct.get(s);if(a)return l!==void 0&&a[l]!==void 0?a[l]:l!==void 0?void 0:a},[]),e=Tr((s,l,a)=>{if(l===void 0)ct.set(s,a);else if(ct.has(s)){let c=ct.get(s);ct.set(s,{...c,[l]:a})}else ct.set(s,{[l]:a})},[]),t=Tr((s,l)=>{if(ct.has(s)){if(l===void 0)ct.delete(s);else if(ct.get(s)[l]){let{[l]:c,...u}=ct.get(s);Object.keys(u).length>0?ct.set(s,u):ct.delete(s)}}},[]),n=Tr((s,l)=>{let a=We.get(s);if(a)return l!==void 0?a[l]:a},[]),o=Tr((s,l,a)=>{if(l===void 0)We.set(s,a);else if(We.has(s)){let c=We.get(s);We.set(s,{...c,[l]:a})}else We.set(s,{[l]:a})},[]),i=Tr((s,l)=>{if(We.has(s)){if(l===void 0)We.delete(s);else if(We.get(s)[l]){let{[l]:c,...u}=We.get(s);Object.keys(u).length>0?We.set(s,u):We.delete(s)}}},[]);return{loadSessionState:r,loadState:n,saveSessionState:e,saveState:o,purgeState:i,purgeSessionState:t}};var Wf=r=>r.flexDirection==="column"?["height","width"]:["width","height"],Fv={},Do=(r,e="0")=>{let[t,n]=Yi(K(r),r.props,e);return Po.cloneElement(r,t,n)},Sa=(r,e)=>{let t=K(r),[n,o]=Yi(t,r.props,"0",void 0,e);return Vv(r,n,o)},iO=(r,e,t)=>{let[n,o]=Yi(r,e,"0",void 0,t);return{...e,...n,type:r,children:o}};function Bv(r,e,t="0",n=null,o){var m,g;let{active:i=0,"data-path":s,path:l=s,id:a,style:c}=_(o),u=K(o)===r&&t===l,h=u?a:(m=e.id)!=null?m:zf(),f=r==="Stack"?(g=e.active)!=null?g:i:void 0,d=h,p=u?c:_v(r,e,n);return Bh(r)?{id:h,key:d,path:t,style:p,type:r,active:f}:{id:h,key:d,style:p,"data-path":t}}function Yi(r,e,t,n=null,o){var c,u;let i=Bv(r,e,t,n,o);if(e.layout&&!o)return[i,[Mr(e.layout,`${t}.0`)]];let s=(u=o==null?void 0:o.children)!=null?u:(c=o==null?void 0:o.props)==null?void 0:c.children,a=e.dropTarget&&s?s:Hv(r,e.children,t,s);return[i,a]}function Hv(r,e,t="0",n){let o=Array.isArray(e)?e:Po.isValidElement(e)?[e]:[];return ze(r)?o.map((i,s)=>{let l=K(i),a=K(n==null?void 0:n[s]);if(!a||l===a){let[c,u]=Yi(l,i.props,`${t}.${s}`,r,n==null?void 0:n[s]);return Po.cloneElement(i,c,u)}return n==null?void 0:n[s]}):e}var _v=(r,e,t)=>{let{style:n=Fv}=e;if(r==="Flexbox"&&(n={flexDirection:e.column?"column":"row",...n,display:"flex"}),n.flex){let{flex:o,...i}=n;n={...i,...oa(typeof o=="number"?o:0)}}else t==="Stack"?n={...n,...oa(1)}:t==="Flexbox"&&(n.width||n.height)&&n.flexBasis===void 0&&(n={...n,flexBasis:"auto",flexGrow:0,flexShrink:0});return n};function Mr({id:r=zf(),type:e,children:t,props:n,state:o},i){let s=e.match(/^[a-z]/)?e:Fn[e];if(s===void 0)throw Error(`layoutUtils unable to create component from JSON, unknown type ${e}`);return o&&_f(r,o),Po.createElement(s,{id:r,...n,key:r,path:i},t?t.map((l,a)=>Mr(l,`${i}.${a}`)):void 0)}function $f(r){return Uf(r)}function Uf(r){let e=K(r),{id:t,children:n,type:o,...i}=_(r),s=Hf(t)?Bf(t):void 0;return{id:t,type:e,props:zv(i),state:s,children:Po.Children.map(n,Uf)}}function zv(r){if(r){let{path:e,...t}=r,n={};for(let[o,i]of Object.entries(t))n[o]=wa(i);return n}}function wa(r){if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return r;if(Array.isArray(r))return r.map(wa);if(typeof r=="object"&&r!==null){let e={};for(let[t,n]of Object.entries(r))e[t]=wa(n);return e}}function qf(r,e){var s;let t=r.props.children,n=t.length,{index:o=-1,positionRelativeToTab:i="after"}=e.tab||{};return o===-1||o>=n?[t[n-1],"after"]:[(s=t[o])!=null?s:null,i]}function Xi(r,e,t){let{active:n,children:o=[],path:i}=_(r),s=q(e,"path"),{idx:l,finalStep:a}=Mt(i,s,!0),[c,u]=a?Wv(r,o,t):[n,o==null?void 0:o.map((f,d)=>d===l?Xi(f,e,t):f)],h=K(r)==="Stack"?Array.isArray(c)?c[0]:c:n;return Lo.cloneElement(r,{active:h},u)}function Wv(r,e,t){let n=q(r,"path"),o=e==null?void 0:e.length,{id:i=Gf()}=_(t);return o?[o,e.concat(Ee(t,`${n}.${o}`,{id:i,key:i}))]:[0,[Ee(t,`${n}.0`,{id:i})]]}function Zi(r,e,t,n,o,i,s){let{active:l,children:a,path:c}=_(r),u=q(e,"path"),{idx:h,finalStep:f}=Mt(c,u),[d,p]=f?$v(r,a,h,t,n,o,i,s):[l,a.map((g,y)=>y===h?Zi(g,e,t,n,o,i,s):g)],m=K(r)==="Stack"?d:l;return Lo.cloneElement(r,{active:m},p)}function $v(r,e,t,n,o,i,s,l){let a=at(n);return a!=null&&a.width&&(a!=null&&a.height)?Gv(r,e,t,n,o,s,l):Kf(r,e,t,n,o,(i==null?void 0:i.width)||(i==null?void 0:i.height),s)}var Uv=(r,e,{top:t,right:n,bottom:o,left:i},[s,l,a,c])=>{if(r==="column"&&e==="before")return l-t;if(r==="column")return o-c;if(r==="row"&&e==="before")return s-i;if(r==="row")return n-a};function Gv(r,e,t,n,o,i,s){let{style:{flexDirection:l}}=_(r),[a,c,u]=If(l),{[c]:h,[a]:f}=at(n),d=q(e[t],"path"),p=Uv(l,o,i,s),[m,g]=h<i[c]?[ko(n,u,d,i,s),f]:[n,void 0],y=p?Ft(d,p,{flexGrow:0,flexShrink:0}):void 0;return h>i[c]&&(e=e.map(v=>{if(q(v,"placeholder"))return v;{let{[c]:w}=at(v);return w&&w<h?ko(v,u,q(v,"path")):v}})),Kf(r,e,t,m,o,g,i,y)}function Kf(r,e,t,n,o,i,s,l){let a=q(r,"path"),c=0,u=!e||e.length===0?[n]:e.reduce((h,f,d)=>{if(t===d){let[p,m]=qv(r,f,n,s);o==="before"?l?h.push(l,m,p):h.push(m,p):l?h.push(p,m,l):h.push(p,m),c=h.indexOf(m)}else h.push(f);return h},[]).map((h,f)=>f<c?h:Ee(h,`${a}.${f}`));return[c,u]}function qv(r,e,t,n){let o=Gf(),{version:i=0}=_(t);if(i+=1,K(r)==="Flexbox"){let[s]=Wf(r.props.style),l=6,a={[s]:(n[s]-l)/2},c=ba(e,s,a),u=ba(t,s,a);return[Lo.cloneElement(e,{style:c}),Lo.cloneElement(t,{id:o,version:i,style:u})]}else{let{style:{left:s,top:l,flex:a,...c}={left:void 0,top:void 0,flex:void 0}}=_(t);return[e,Lo.cloneElement(t,{id:o,version:i,style:c})]}}import{cloneElement as Jv}from"react";import es from"react";function jf(r,{target:e,replacement:t}){return Ca(r,e,t)}function Ca(r,e,t){let n=q(e,"path"),o=q(e,"resizeable"),{style:i}=_(e),s=Do(es.cloneElement(t,{resizeable:o,style:{...i,...t.props.style}}),n);return $e(r,e,s)}function $e(r,e,t,n){if(r===e)return t;let{idx:o,finalStep:i}=Mt(q(r,"path"),q(e,"path")),s=r.props.children.slice();return i?n?n===Wn.MINIMIZE?s[o]=Kv(r,s[o]):n===Wn.RESTORE&&(s[o]=jv(s[o])):s[o]=t:s[o]=$e(s[o],e,t,n),es.cloneElement(r,void 0,s)}function Kv(r,e){let{style:t}=_(r),{style:n}=_(e),{width:o,height:i,flexBasis:s,flexShrink:l,flexGrow:a,...c}=n,u={width:o,height:i,flexBasis:s,flexShrink:l,flexGrow:a},h={...c,flexBasis:0,flexGrow:0,flexShrink:0},f=t.flexDirection==="row"?"vertical":t.flexDirection==="column"?"horizontal":!1;return f?es.cloneElement(e,{collapsed:f,restoreStyle:u,style:h}):e}function jv(r){let{style:e,restoreStyle:t}=_(r),{flexBasis:n,flexShrink:o,flexGrow:i,...s}=e,l={...s,...t};return es.cloneElement(r,{collapsed:!1,style:l,restoreStyle:void 0})}function Jf(r,{fromIndex:e,path:t,toIndex:n}){let o=Te(r,t,!0),{children:i}=_(o),s=Qv(i,e,n),l=Jv(o,void 0,s);return $e(r,o,l)}function Qv(r,e,t){let n=r.slice(),[o]=n.splice(e,1);return t===-1?n.concat(o):(n.splice(t,0,o),n)}var Re={ADD:"add",DRAG_START:"drag-start",DRAG_DROP:"drag-drop",LAYOUT_RESIZE:"layout-resize",MAXIMIZE:"maximize",MINIMIZE:"minimize",MOVE_CHILD:"move-child",REMOVE:"remove",REPLACE:"replace",RESTORE:"restore",SAVE:"save",SET_PROP:"set-prop",SET_PROPS:"set-props",SET_TITLE:"set-title",SPLITTER_RESIZE:"splitter-resize",SWITCH_TAB:"switch-tab",TEAROUT:"tearout"},IO=r=>["switch-active-layout","open-layout","close-layout","rename-layout"].includes(r),PO=r=>["switch-active-tab","edit-feature-title","save-feature-props","remove-component","resize-component","drag-drop-operation"].includes(r);import $n from"react";function Ta(r,{path:e}){let t=Te(r,e),n=Qt(r,e);if(n===null)return r;let{children:o}=_(n);if(o.length>1&&Yf(o,e)){let{style:{flexBasis:i,display:s,flexDirection:l,...a}}=_(n),c=q(n,"path"),u=$e(r,n,Ft(c,i,a));for(;(n=Qt(u,c))&&q(n,"path")!=="0";){let{children:h}=_(n);if(Yf(h)){c=q(n,"path");let{style:{flexBasis:f,display:d,flexDirection:p,...m}}=_(n);u=$e(r,n,Ft(c,f,m))}else if(ew(h))u=ed(r,n);else break}return u}return Xf(r,t)}function Xf(r,e){let t=_(r),{children:n,path:o,preserve:i}=t,{active:s}=t,{idx:l,finalStep:a}=Mt(o,q(e,"path")),c=K(r),u=n.slice();if(a){if(u.splice(l,1),s!==void 0&&s>=l&&(s=Math.max(0,s-1)),u.length===1&&!i&&o!=="0"&&c.match(/Flexbox|Stack/))return Yv(r,u[0]);!u.some(Xv)&&u.some(Zf)&&(u=Zv(u))}else u[l]=Xf(u[l],e);return u=u.map((h,f)=>Ee(h,`${o}.${f}`)),$n.cloneElement(r,{active:s},u)}function Yv(r,e){let t=K(r),{path:n,style:{flexBasis:o,flexGrow:i,flexShrink:s,width:l,height:a}}=_(r),c=Ee(e,n);if(n==="0")c=$n.cloneElement(c,{style:{...e.props.style,width:l,height:a}});else if(t==="Flexbox"){let u=r.props.style.flexDirection==="column"?"height":"width",{style:{[u]:h,...f}}=c.props;c=$n.cloneElement(c,{flexFill:void 0,style:{...f,flexGrow:i,flexShrink:s,flexBasis:o,width:l,height:a}})}return c}var Xv=r=>r.props.style.flexGrow>0,Zf=r=>{let{width:e,height:t,flexGrow:n}=r.props.style;return n===0&&typeof e!="number"&&typeof t!="number"},Zv=r=>r.map(e=>Zf(e)?$n.cloneElement(e,{style:{...e.props.style,flexGrow:1}}):e),ew=r=>{if(r&&r.length>0){let e=q(r[0],"placeholder"),t=!1;for(let n=1;n<r.length;n++){if(t=q(r[n],"placeholder"),e&&t)return!0;e=t}}},ed=(r,e)=>{let{children:t,path:n}=_(r),{idx:o,finalStep:i}=Mt(n,q(e,"path")),s=t.slice();return i?s[o]=tw(e):s[o]=ed(s[o],e),s=s.map((l,a)=>Ee(l,`${n}.${a}`)),$n.cloneElement(r,void 0,s)},tw=r=>{let{children:e}=_(r),t=[],n=[];for(let i=0;i<e.length;i++)q(e[i],"placeholder")?n.push(e[i]):(n.length===1?t.push(n.pop()):n.length>0&&(t.push(Qf(n)),n.length=0),t.push(e[i]));n.length===1?t.push(n.pop()):n.length>0&&t.push(Qf(n));let o=q(r,"path");return $n.cloneElement(r,void 0,t.map((i,s)=>Ee(i,`${o}.${s}`)))},Qf=([r,...e])=>{let t=q(r,"style"),{flexBasis:n,flexGrow:o,flexShrink:i}=t;for(let{props:{style:s}}of e)n+=s.flexBasis,o=Math.max(o,s.flexGrow),i=Math.max(i,s.flexShrink);return $n.cloneElement(r,{style:{...t,flexBasis:n,flexGrow:o,flexShrink:i}})},Yf=(r,e)=>r.every(t=>q(t,"placeholder")||e&&q(t,"path")===e);import ka from"react";function td(r,{path:e,size:t}){let n=Te(r,e,!0),{style:o}=_(n),i={...o,width:t},s=ka.cloneElement(n,{style:i});return $e(r,n,s)}function nd(r,{path:e,sizes:t}){let n=Te(r,e,!0),{children:o,style:i}=_(n),s=i.flexDirection==="column"?"height":"width",l=nw(o,t,s),a=ka.cloneElement(n,void 0,l);return $e(r,n,a)}function nw(r,e,t){return r.map((n,o)=>{let{style:{[t]:i,flexBasis:s}}=_(n),l=e[o],{currentSize:a,flexBasis:c}=l,h=a!==void 0?l.currentSize:c;return h===void 0||i===h||s===h?n:ka.cloneElement(n,{style:rw(n.props.style,t,h)})})}function rw(r,e,t){let n=typeof r[e]=="number",{flexShrink:o=1,flexGrow:i=1}=r;return{...r,[e]:n?t:"auto",flexBasis:n?"auto":t,flexShrink:o,flexGrow:i}}import{uuid as ow}from"@vuu-ui/vuu-utils";import ts from"react";var rd=r=>{let[e]=K(r);return e===e.toLowerCase()};function Ao(r,e,t,n,o,i){let{children:s,path:l}=_(r),a=q(e,"path"),{idx:c,finalStep:u}=Mt(l,a),h=u?iw(r,s,e,t,n,o,i):s.map((f,d)=>d===c?Ao(f,e,t,n,o,i):f);return ts.cloneElement(r,void 0,h)}function iw(r,e,t,n,o,i,s){let l=at(n);if(l!=null&&l.width&&(l!=null&&l.height)){if(i===void 0||s===void 0)throw Error("wrap-layout-element, updateChildren clientRect and dropRect must both be available");return lw(e,t,n,o,i,s)}return sw(r,e,t,n,o)}function sw(r,e,t,n,o){var b;let{version:i=0}=_(n),s=q(t,"path"),{type:l,flexDirection:a,showTabs:c}=id(o),[u,h,f]=aw(l,t,n,a,o),d=od(o),p=d?1:0,m={resizeable:!0,style:f,version:i+1},y={[rd(t)?"data-resizeable":"resizeable"]:!0,style:h},v=l==="Stack"?{showTabs:c}:void 0,w=l==="Flexbox"?{splitterSize:(b=K(r)==="Flexbox"&&r.props.splitterSize)!=null?b:void 0}:void 0,x=ow(),S=ts.createElement(Fn[l],{active:p,id:x,key:x,path:q(t,"path"),flexFill:q(t,"flexFill"),...w,...v,style:u,resizeable:q(t,"resizeable")},d?[Ee(t,`${s}.0`,y),Do(ts.cloneElement(n,m),`${s}.1`)]:[Do(ts.cloneElement(n,m),`${s}.0`),Ee(t,`${s}.1`,y)]);return e.map(C=>C===t?S:C)}function lw(r,e,t,n,o,i){let{flexDirection:s}=id(n),l=s==="column"?"row":"column",a=od(n),[c,u,h,f]=i,[d,p]=s==="column"?[u-o.top,o.bottom-f]:[c-o.left,o.right-h],m=q(e,"path"),g=0,y=rd(e)?"data-resizeable":"resizeable",v=[];d&&v.push(a?Ee(e,`${m}.${g++}`,{[y]:!0,style:{flexBasis:d,flexGrow:1,flexShrink:1}}):Ft(`${m}.${g++}`,d,{flexGrow:0,flexShrink:0})),v.push(ko(t,l,`${m}.${g++}`,o,i)),p&&v.push(a?Ft(`${m}.${g++}`,0):Ee(e,`${m}.${g++}`,{[y]:!0,style:{flexBasis:0,flexGrow:1,flexShrink:1}}));let w=xa(s,e.props,v,m);return r.map(x=>x===e?w:x)}function aw(r,e,t,n,o){let i={...e.props.style,flexDirection:n},s=r==="Flexbox"&&n==="column"?"height":"width",l=ya(t,s,o),a=ya(e,s);return[i,a,l]}var od=r=>{var e;return r.position.SouthOrEast?!0:((e=r==null?void 0:r.tab)==null?void 0:e.positionRelativeToTab)==="before"?!1:!!r.position.Header};function id(r){return r.position.Header?{type:"Stack",flexDirection:"column",showTabs:!0}:{type:"Flexbox",flexDirection:r.position.EastOrWest?"row":"column"}}var ud=(r,e)=>{switch(e.type){case Re.ADD:return dw(r,e);case Re.DRAG_DROP:return fw(r,e);case Re.MAXIMIZE:return hw(r,e);case Re.REMOVE:return Ta(r,e);case Re.REPLACE:return jf(r,e);case Re.SET_PROP:return sd(r,e);case Re.SET_PROPS:return uw(r,e);case Re.SET_TITLE:return sd(r,{type:"set-prop",path:e.path,propName:"title",propValue:e.title});case Re.SPLITTER_RESIZE:return nd(r,e);case Re.LAYOUT_RESIZE:return td(r,e);case Re.SWITCH_TAB:return cw(r,e);case Re.MOVE_CHILD:return Jf(r,e);default:return r}},cw=(r,{path:e,nextIdx:t})=>{let n=Te(r,e,!0),o=Ma.cloneElement(n,{active:t});return $e(r,n,o)},sd=(r,{path:e,propName:t,propValue:n})=>{let o=Te(r,e,!0),i=Ma.cloneElement(o,{[t]:n});return $e(r,o,i)},uw=(r,{path:e,props:t})=>{let n=Te(r,e,!0),o=Ma.cloneElement(n,t);return $e(r,n,o)},hw=(r,{path:e,type:t})=>{if(e){let n=Te(r,e,!0);return $e(r,n,n,t)}else return r},fw=(r,e)=>{var p,m;let{draggedReactElement:t,dragInstructions:n,dropTarget:o}=e,i=o.component,{pos:s}=o,l=((p=s==null?void 0:s.position)==null?void 0:p.Header)&&K(i)==="Stack",{id:a,version:c}=_(t),u=at(t),h;if(l){let[g,y]=qf(i,s);g===void 0?h=Xi(r,i,t):h=Zi(r,g,t,y)}else!u&&((m=s==null?void 0:s.position)!=null&&m.Centre)?h=Ca(r,i,t):h=pw(r,o,t);if(n.DoNotRemove)return h;let f=Yt(h,g=>g.id===a&&g.version===c),d=q(f,"path");return Ta(h,{path:d,type:"remove"})},dw=(r,{path:e,component:t})=>Xi(r,Te(r,e),t),pw=(r,e,t)=>{let{component:n,pos:o,clientRect:i,dropRect:s}=e,l=q(n,"path");if(l==="0.0")return Ao(r,n,t,o);let a=Qt(r,l);if(ld(o,a)){let c=o.position.SouthOrEast?"after":"before";return Zi(r,n,t,c,o,i,s)}if(!ld(o,a))return Ao(r,n,t,o,i,s);if(ze(K(a)))return Ao(r,n,t,o);throw Error(`no support right now for position = ${o.position}`)},ld=(r,e)=>r.position.Centre?cd(e)||ad(e):r.position.NorthOrSouth?ad(e):r.position.EastOrWest?cd(e):!1,ad=r=>K(r)==="Flexbox"&&r.props.style.flexDirection==="column",cd=r=>K(r)==="Flexbox"&&r.props.style.flexDirection!=="column";import{createContext as mw}from"react";var gw=r=>console.log(`dispatch ${r.type}, have you forgotten to provide a LayoutProvider ?`),Oo=mw({dispatchLayoutProvider:gw,version:-1});import{useCallback as ns,useRef as Ea}from"react";var yw={},hd=[0,0],bw=(r,e,t)=>{let n=document.createElement("div");n.className="vuuSimpleDraggableWrapper",n.classList.add("vuuSimpleDraggableWrapper","salt-theme","salt-density-medium"),n.dataset.dragging="true";let o=t!=null?t:document.createElement("div");o.id=e,n.appendChild(o),document.body.appendChild(n);let i=`top:${r.top}px;left:${r.left}px;width:${r.width}px;height:${r.height}px;`;return[n,i,r.left,r.top]},xw=r=>{let{offsetParent:e}=r;if(e===null)return hd;{let{left:t,top:n}=e.getBoundingClientRect();return[t,n]}},fd=(r,e,t)=>{let n=Ea(),o=Ea(),i=Ea(),s=ns((u,h)=>{if(o.current&&i.current){let{dragOffsets:[f,d],targetPosition:p}=o.current,m=typeof u=="number"?u-f:p.left,g=typeof h=="number"?h-d:p.top;(m!==p.left||g!==p.top)&&(o.current.targetPosition.left=m,o.current.targetPosition.top=g,i.current.style.top=g+"px",i.current.style.left=m+"px")}},[]),l=ns(u=>{if(o.current){let{dragInstructions:h,payload:f,originalCSS:d}=o.current;u&&e({type:"drag-drop",draggedReactElement:f,dragInstructions:h,dropTarget:u}),i.current&&(!u&&h.DriftHomeIfNoDropTarget?(console.log("drift back to start"),document.body.removeChild(i.current)):h.RemoveDraggableOnDragEnd?document.body.removeChild(i.current):(i.current.style.cssText=d,delete i.current.dataset.dragging)),n.current=void 0,o.current=void 0,i.current=void 0}},[e]),a=ns(u=>{if(n.current){let{payload:h,dragContainerPath:f,dragElement:d,dragRect:p,instructions:m=yw,path:g}=n.current,{current:y}=r,v={x:u.clientX,y:u.clientY},w=h!=null?h:Te(y,g,!0),{id:x}=w.props,S=at(w),b="",C="",k="",E=-1,R=-1,N=hd,O=document.getElementById(x);if(O===null)[O,C,E,R]=bw(p,x,d);else{N=xw(O);let[M,D]=N,{width:F,height:G,left:A,top:V}=O.getBoundingClientRect();E=A-M,R=V-D,C=`width:${F}px;height:${G}px;left:${E}px;top:${R}px;z-index: 100;background-color:#ccc;opacity: 0.6;`,O.dataset.dragging="true",b=O.style.cssText}k=ma.initDrag(r.current,f,p,v,{drag:s,drop:l},S),O.style.cssText=C+k,i.current=O,o.current={payload:w,originalCSS:b,dragRect:p,dragOffsets:N,dragInstructions:m,targetPosition:{left:E,top:R}}}},[s,l,r]);return ns(u=>{let{evt:h,...f}=u;n.current={...f,dragContainerPath:na(r.current,t)},ma.handleMousedown(h,a,f.instructions)},[a,t,r])};import{jsx as yd}from"react/jsx-runtime";var pd=r=>r.dropTarget,Sw=r=>["drag-drop","remove","set-title","splitter-resize","switch-tab"].includes(r.type),md=r=>{switch(r.type){case"switch-tab":return r.id==="main-tabs"?"switch-active-layout":"switch-active-tab";case"save":return"save-feature-props";case"drag-drop":return"drag-drop-operation";case"remove":return"remove-component";case"splitter-resize":return"resize-component";case"set-title":return"edit-feature-title";default:throw Error("unknown layout action")}},ZN=()=>{let r=Tw();return yd("div",{children:`Context: ${r} `})},Cw=r=>{let{children:e,createNewChild:t,pathToDropTarget:n,layout:o,onLayoutChange:i}=r,s=dd(void 0),l=dd(e),[,a]=ww(null),c=Ra((d,p)=>{if(console.log(`serialize state ${p}`),i){let m=Yt(d,pd)||s.current,y=K(m)==="DraggableLayout"?_(m).children[0]:m,v=$f(y);i(v,p)}},[i]),u=Ra((d,p=!1)=>{let m=ud(s.current,d);m!==s.current&&(s.current=m,a({}),!p&&Sw(d)&&c(m,md(d)))},[a,c]),h=Ra(d=>{switch(d.type){case"drag-start":{f(d);break}case"save":{c(s.current,md(d));break}default:{u(d);break}}},[u,c]),f=fd(s,h,n);return vw(()=>{if(o){let d=Yt(s.current,pd);if(d){let p=Gh(d),m=Mr(o,`${d.props.path}.0`),g=p?{type:Re.REPLACE,target:p,replacement:m}:{type:Re.ADD,path:d.props.path,component:m};u(g,!0)}else if(o.id===q(s.current,"id")){let p=Mr(o,"0"),m={type:Re.REPLACE,target:s.current,replacement:p};u(m,!0)}}},[u,o]),s.current===void 0?s.current=Sa(e):e!==l.current&&(s.current=Sa(e,s.current),l.current=e),yd(Oo.Provider,{value:{createNewChild:t,dispatchLayoutProvider:h,version:0},children:s.current})},ut=()=>{let{dispatchLayoutProvider:r}=Ia(Oo);return r},gd=()=>{let{createNewChild:r}=Ia(Oo);return r},Tw=()=>{let{version:r}=Ia(Oo);return r};import{jsx as Mw}from"react/jsx-runtime";var bd=function(e){let{path:t}=e,n=ut(),o=kw(i=>{n({type:Wn.SPLITTER_RESIZE,path:t,sizes:i})},[n,t]);return Mw(Io,{...e,onSplitterMoved:o})};bd.displayName="Flexbox";ge("Flexbox",bd,"container");import{useForkRef as qw}from"@salt-ds/core";import Kw from"classnames";import{forwardRef as jw,useMemo as Jw}from"react";import{useCallback as Td,useEffect as Lw,useRef as La,useState as Aw}from"react";import{useCallback as Ew,useLayoutEffect as xd,useRef as Rw}from"react";var wd=["height","width"],p2=["height"],m2=["width"],Un=new WeakMap,Sd=(r,e,t)=>{switch(t){case"height":return e.height;case"scrollHeight":return r.scrollHeight;case"scrollWidth":return r.scrollWidth;case"width":return e.width;default:return 0}},vd=new ResizeObserver(r=>{for(let e of r){let{target:t,contentRect:n}=e,o=Un.get(t);if(o){let{onResize:i,measurements:s}=o,l=!1;for(let[a,c]of Object.entries(s)){let u=Sd(t,n,a);u!==c&&(l=!0,s[a]=u)}l&&i&&i(s)}}});function rs(r,e,t,n=!1){let o=Rw(e),i=Ew(s=>{let l=s.getBoundingClientRect();return o.current.reduce((a,c)=>(a[c]=Sd(s,l,c),a),{})},[]);xd(()=>{let s=r.current,l=!1;async function a(){Un.set(s,{measurements:{}}),l=!1;let{fonts:c}=document;if(c&&await c.ready,!l){let u=Un.get(s);if(u){let h=i(s);u.measurements=h,vd.observe(s),n&&t(h)}}}if(s){if(Un.has(s))throw Error("useResizeObserver attemping to observe same element twice");a()}return()=>{s&&Un.has(s)&&(vd.unobserve(s),Un.delete(s),l=!0)}},[r,i,n,t]),xd(()=>{let s=r.current,l=Un.get(s);if(l){if(o.current!==e){o.current=e;let a=i(s);l.measurements=a}l.onResize=t}},[e,i,r,t])}function Iw(r,e){let t=document.body.querySelector(`.${r}`),n={get:function(o,i){let s=o.getPropertyValue(`--${r}-breakpoint-${i}`);return s?parseInt(s):void 0}};return t?new Proxy(getComputedStyle(t),n):e!=null?e:{}}var Pw=([,r],[,e])=>e-r,Da=r=>Object.entries(r).sort(Pw).map(([e,t],n,o)=>[e,t,n<o.length-1?o[n+1][1]:9999]),Pa=null,Dw=(r="salt")=>{let{xs:e,sm:t,md:n,lg:o,xl:i}=Iw(r);return Da({xs:e,sm:t,md:n,lg:o,xl:i})},Cd=r=>(Pa===null&&(Pa=Dw(r)),Pa);var Ow=[],kd=({breakPoints:r,smallerThan:e},t)=>{let[n,o]=Aw(e?!1:"lg"),i=La(document.body),s=La(r?Da(r):Cd()),l=La("lg"),a=Td(u=>{if(s.current){for(let[h,f]of s.current)if(u>=f)return h}},[s]),c=Td(u=>{if(e){let h=s.current.find(([f])=>f===e);if(h){let[,,f]=h;return u<f}}else return a(u);return u},[e,a]);return rs(t||i,s.current?["width"]:Ow,({width:u})=>{let h=c(u);h!==l.current&&(l.current=h,o(h))},!0),Lw(()=>{let u=t||i;if(u.current){let h=l.current;if(s.current){let{clientWidth:f}=u.current,d=c(f);l.current=d,d!==h&&o(d)}}},[o,c,t]),n};var Md="data-collapsible",Nw={[Md]:!0,"data-pad-start":!0,"data-pad-end":!0},Vw=r=>{var e;return(e=Nw[r])!=null?e:!1},Fw=r=>r===Md,Bw={dynamic:"dynamic",instant:"instant",true:"instant"},Hw=r=>{var e;return(e=Bw[r])!=null?e:"none"},T2=r=>Object.keys(r).reduce((e,t)=>{let[n,o]=e;if(Vw(t)){let i=Fw(t)?Hw(r[t]):r[t];n[t]=i,o[t]=void 0}return e},[{},{}]);import{getUniqueId as _w}from"@vuu-ui/vuu-utils";import{cloneElement as zw,isValidElement as Ww,useCallback as $w,useMemo as Ed,useRef as Aa}from"react";var Uw=["xs","sm","md","lg","xl"],Gw=12,Rd=({children:r,cols:e,style:t})=>{let n=Aa(null),o=Aa(null),i=Aa(),s=e!=null?e:Gw,a=(t==null?void 0:t.flexDirection)==="column"?"height":"width",c=Ed(()=>Array.isArray(r)?r:Ww(r)?[r]:[],[r]),u=$w((h,f)=>{let d=ji(h,f,Uw),p=[],m=[];for(let g=0;g<h.length;g++){let y=h[g],{style:{flex:v,...w}}=y.props;p.push(zw(y,{key:_w(),style:{...w,"--parent-col-count":s}})),m.push(d[g])}return[p,m]},[s]);return Ed(()=>{let[h,f]=u(c,a);o.current=f,i.current=h},[u,c,a]),{cols:s,content:i.current,rootRef:n}};import{jsx as Qw}from"react/jsx-runtime";var os="hwFluidGrid",Oa=jw(function(e,t){let{breakPoints:n,children:o,column:i,cols:s=12,className:l,flexFill:a,gap:c=3,fullPage:u,id:h,onSplitterMoved:f,resizeable:d,row:p,showGrid:m,spacing:g,splitterSize:y,style:v,...w}=e,x=Jw(()=>wr(o),[o]),{cols:S,content:b,rootRef:C}=Rd({children:x,cols:s,style:v}),k=kd({breakPoints:n},C),E=Kw(os,l,{[`${os}-column`]:i,[`${os}-row`]:p,[`${os}-show-grid`]:m,"flex-fill":a,"full-page":u}),R={...v,"--spacing":g,"--grid-col-count":S,"--grid-gap":c};return Qw("div",{...w,className:E,"data-breakpoint":k,"data-cols":S,"data-resizeable":d||void 0,id:h,ref:qw(C,t),style:R,children:b})});Oa.displayName="FluidGrid";import{jsx as Yw}from"react/jsx-runtime";var Id=function(e){return Yw(Oa,{...e})};Id.displayName="FluidGrid";ge("FluidGrid",Id,"container");import{EditableLabel as hS}from"@vuu-ui/vuu-ui-controls";import{Button as fS}from"@salt-ds/core";import{default as dS,default as pS}from"classnames";import{cloneElement as _d,useRef as mS,useState as zd}from"react";import{useCallback as No,useState as Xw}from"react";var is=(r,e,t,n)=>{var g;let{loadSessionState:o,purgeSessionState:i,purgeState:s,saveSessionState:l}=kr(),[a,c]=Xw((g=o(r,"contributions"))!=null?g:[]),u=ut(),h=No((y,v)=>{let w=a.concat([{location:y,content:v}]);l(r,"contributions",w),c(w)},[a,r,l]),f=No(()=>{i(r,"contributions"),c([])},[r,i]),d=No(()=>{let y=o(r,"data-source");y&&y.unsubscribe(),i(r),s(r),u({type:"remove",path:t})},[u,r,o,i,s,t]),p=No(async(y,v,w)=>{var S;y.stopPropagation();let x=(S=e.current)==null?void 0:S.getBoundingClientRect();return new Promise((b,C)=>{u({type:"drag-start",evt:y,path:v===void 0?t:`${t}.${v}`,dragRect:x,preDragActivity:w,dropTargets:n,resolveDragStart:b,rejectDragStart:C})})},[e,u,t,n]);return[No(async(y,v)=>{var x;let{type:w}=y;switch(w){case"maximize":case"minimize":case"restore":return u({type:w,path:(x=y.path)!=null?x:t});case"remove":return d();case"mousedown":return p(v,y.index,y.preDragActivity);case"add-toolbar-contribution":return h(y.location,y.content);case"remove-toolbar-contribution":return f();default:return}},[u,t,d,p,h,f]),a]};import{useForkRef as nS,useIdMemo as rS}from"@salt-ds/core";import oS from"classnames";import Va,{forwardRef as iS,useCallback as sS,useMemo as lS,useRef as Fd,useState as aS}from"react";import{useCallback as Gn,useMemo as Pd}from"react";var Dd=({id:r,rootRef:e,path:t,dropTargets:n,title:o})=>{let i=ut(),{loadState:s,loadSessionState:l,purgeState:a,saveState:c,saveSessionState:u}=kr(),[h,f]=is(r,e,t,n),d=Pd(()=>{var b;return(b=s("view-title"))!=null?b:o},[s,o]),p=Gn(b=>{t&&i({type:"set-title",path:t,title:b})},[i,t]),m=Pd(()=>s(r),[r,s]),g=Gn(b=>s(r,b),[r,s]),y=Gn(b=>{a(r,b),i({type:"save"})},[r,i,a]),v=Gn((b,C)=>{c(r,C,b),i({type:"save"})},[r,i,c]),w=Gn(b=>l(r,b),[r,l]),x=Gn((b,C)=>u(r,C,b),[r,u]),S=Gn(({type:b,...C})=>{let{[b]:k}=C;v(k,b)},[v]);return{contributions:f,dispatchViewAction:h,load:g,loadSession:w,onConfigChange:S,onEditTitle:p,purge:y,restoredState:m,save:v,saveSession:x,title:d}};import{useCallback as Ld,useRef as Ad}from"react";var Zw=[],Od=({mainRef:r,resize:e="responsive",rootRef:t})=>{let n=e==="defer",o=Ad({}),i=Ad(),s=Ld(()=>{r.current&&(r.current.style.height=o.current.height+"px",r.current.style.width=o.current.width+"px"),i.current=void 0},[r]),l=Ld(({height:a,width:c})=>{o.current.height=a,o.current.width=c,i.current!==null&&clearTimeout(i.current),i.current=window.setTimeout(s,40)},[s]);rs(t,n?wd:Zw,l,n)};import eS,{useContext as Nd}from"react";var tS={dispatch:null},ss=eS.createContext(tS),Vd=()=>{var e;let r=Nd(ss);return(e=r==null?void 0:r.dispatch)!=null?e:null},CV=()=>Nd(ss);import{jsx as Na,jsxs as uS}from"react/jsx-runtime";var Vo="vuuView",cS=(r,e)=>r&&e?{...r,...e}:r||e,Bd=iS(function(e,t){let{Header:n=Hd,children:o,className:i,collapsed:s,closeable:l,"data-path":a,"data-resizeable":c,dropTargets:u,expanded:h,flexFill:f,id:d,header:p,orientation:m="horizontal",path:g=a,resize:y="responsive",resizeable:v=c,tearOut:w,style:x={},title:S,...b}=e,C=rS(d),k=Fd(null),E=Fd(null),[R,N]=aS(),{contributions:O,dispatchViewAction:M,load:D,loadSession:F,onConfigChange:G,onEditTitle:A,purge:V,restoredState:B,save:U,saveSession:X,title:ee}=Dd({id:C,rootRef:k,path:g,dropTargets:u,title:S});Od({mainRef:E,resize:y,rootRef:k});let _e=sS(Vt=>{N(Vt)},[]),de=()=>Va.isValidElement(o)&&(B||R)?Va.cloneElement(o,cS(B,R)):o,it=lS(()=>({dispatch:M,id:C,path:g,title:ee,load:D,loadSession:F,onConfigChange:G,purge:V,save:U,saveSession:X,setComponentProps:_e}),[M,C,D,F,G,g,V,U,X,_e,ee]),On=typeof p=="object"?p:{};return Na("div",{...b,className:oS(Vo,i,{[`${Vo}-collapsed`]:s,[`${Vo}-expanded`]:h,[`${Vo}-resize-defer`]:y==="defer"}),"data-resizeable":v,id:C,ref:nS(t,k),style:x,tabIndex:-1,children:uS(ss.Provider,{value:it,children:[p?Na(n,{...On,collapsed:s,contributions:O,expanded:h,closeable:l,onEditTitle:A,orientation:m,tearOut:w,title:ee}):null,Na("div",{className:`${Vo}-main`,ref:E,children:de()})]})})});Bd.displayName="View";var qn=Va.memo(Bd);qn.displayName="View";ge("View",qn,"view");import{jsx as Fo}from"react/jsx-runtime";var Fa="vuuHeader",Hd=({className:r,contributions:e,collapsed:t,closeable:n,onEditTitle:o,orientation:i="horizontal",style:s,title:l="Untitled"})=>{let a=mS(null),[c,u]=zd(l),[h,f]=zd(!1),d=Vd(),p=R=>d==null?void 0:d({type:"remove"},R),m=()=>{var R;(R=a.current)==null||R.focus()},g=R=>{R.stopPropagation()},v=dS(Fa,r,`${Fa}-${t||i}`),w=()=>{f(!0)},x=R=>{R.key==="Enter"&&f(!0)},S=(R="",N="",O=!0,M=!1)=>{var D;f(!1),M?u(R):N!==R&&(u(N),o==null||o(N)),O===!1&&((D=a.current)==null||D.focus())},b=R=>{d==null||d({type:"mousedown"},R)},C=[],k=[],E=[];return e==null||e.forEach((R,N)=>{switch(R.location){case"pre-title":C.push(_d(R.content,{key:N}));break;default:k.push(_d(R.content,{key:N}))}}),l&&C.push(Fo(hS,{className:`${Fa}-title`,editing:h,value:c,onChange:u,onMouseDownCapture:m,onEnterEditMode:w,onExitEditMode:S,onKeyDown:x,ref:a,tabIndex:0},"title")),n&&E.push(Fo(fS,{"data-icon":"close",onClick:p,onMouseDown:g,variant:"secondary"},"close")),k.length>0&&C.push(Fo("div",{className:"vuuTooltrayProxy","data-align":"end",children:k},"contributions")),E.length>0&&C.push(Fo("div",{className:"vuuTooltrayProxy","data-align":"end",children:E},"actions")),Fo("div",{className:pS("vuuToolbarProxy",v),style:s,onMouseDown:b,children:C})};var cF={type:"View",props:{style:{height:"calc(100% - 6px)"}},children:[{props:{className:"vuuShell-warningPlaceholder"},type:"Placeholder"}]},Bo={type:"Stack",id:"main-tabs",props:{className:"vuuShell-mainTabs",TabstripProps:{allowAddTab:!0,allowRenameTab:!0,animateSelectionThumb:!1,location:"main-tab",allowCloseTab:!0},preserve:!0,active:0},children:[{props:{id:"tab1",className:"vuuShell-Placeholder"},type:"Placeholder"}]};import{Prompt as Dz}from"@vuu-ui/vuu-popups";import{Button as Az}from"@salt-ds/core";import Nz from"classnames";import{useRef as Hz}from"react";import{useCallback as mF,useRef as gF}from"react";import{PopupComponent as bF,Portal as xF}from"@vuu-ui/vuu-popups";import{List as wF,ListItem as SF}from"@vuu-ui/vuu-ui-controls";import{Fragment as EF,jsx as kF,jsxs as MF}from"react/jsx-runtime";import{itemToString as gS}from"@vuu-ui/vuu-utils";import{ComboBox as yS}from"@vuu-ui/vuu-ui-controls";import Wd from"classnames";import{forwardRef as bS,useCallback as ls,useMemo as xS,useRef as vS,useState as wS}from"react";import{jsx as Ud}from"react/jsx-runtime";var $d="vuuExpandoCombobox",SS={},Ho=bS(function({className:e,InputProps:t=SS,ListProps:n,onInputChange:o,onSelectionChange:i,selectionStrategy:s,style:l,value:a="",...c},u){let[h,f]=wS(a),{itemToString:d=gS}=c,p=vS(a),m=ls(b=>{let[C,...k]=b;return k.length?`${d(C)} + ${k.length}`:d(C)},[d]),g=ls(b=>{let{value:C}=b.target;console.log(`onInputChange ${C}`),f(C),o==null||o(b)},[o]),y=ls(b=>{console.log(`handleSetSelectedText ${b}`),f(b)},[]),[v,w]=xS(()=>{let{inputProps:b,...C}=t;return[{...C,className:`${$d}-Input`,endAdornment:null,inputProps:{...b,autoComplete:"off",onInput:g}},{...n,className:Wd("vuuMenuList",n==null?void 0:n.className),"data-mode":"light",displayedItemCount:10,itemHeight:22,maxWidth:300,minWidth:100,width:"auto"}]},[t,g,n]),x=ls((b,C)=>{Array.isArray(C)?i==null||i(null,C):C&&(f(d(C)),i==null||i(null,C))},[d,i]),S={minWidth:102};return Ud("div",{className:Wd($d,e),"data-text":h,ref:u,style:l,children:Ud(yS,{...c,PopupProps:S,defaultValue:p.current,fullWidth:!0,ListProps:w,InputProps:v,itemsToString:m,onSelectionChange:x,onSetSelectedText:y,selectionStrategy:s})})});import L_ from"classnames";import{useCallback as N_}from"react";import{Button as QF}from"@salt-ds/core";import{jsx as ZF}from"react/jsx-runtime";import{forwardRef as CS,useState as TS,useCallback as Gd}from"react";import{ExpandoInput as kS}from"@vuu-ui/vuu-ui-controls";import{isValidNumber as Ba}from"@vuu-ui/vuu-utils";import{jsx as ES}from"react/jsx-runtime";var MS=CS(function({InputProps:e,className:t,column:n,onInputComplete:o,value:i},s){let[l,a]=TS(Ba(i)?i.toString():""),c=Gd(h=>{let{value:f}=h.target,d=parseFloat(f);Ba(d)&&console.log("its valid"),a(f)},[]),u=Gd(h=>{if(h.key==="Enter"){let{value:f}=h.target,d=parseFloat(f);Ba(d)&&o(d)}},[o]);return ES(kS,{...e,className:t,value:l,ref:s,onChange:c,onKeyDown:u})});import{isNumericColumn as fB,isTextColumn as dB}from"@vuu-ui/vuu-utils";import{forwardRef as rT,useCallback as ks,useEffect as Hp,useMemo as oT,useState as _p}from"react";import{getFullRange as gB,metadataKeys as RS,WindowRange as yB}from"@vuu-ui/vuu-utils";import{useCallback as xB,useEffect as vB,useMemo as wB,useRef as SB,useState as CB}from"react";var{SELECTED:TB}=RS;import{useCallback as u4,useEffect as h4,useState as f4}from"react";import{EventEmitter as $S,getLoggingConfigForWorker as US,uuid as GS}from"@vuu-ui/vuu-utils";var _o=(r,e)=>r===e?!0:r===void 0&&e===void 0,IS=({filter:r},{filter:e})=>r===void 0&&(e==null?void 0:e.filter)===""||e===void 0&&(r==null?void 0:r.filter)==="",PS=(r,e)=>{var t,n;return IS(r,e)?!1:((t=r.filter)==null?void 0:t.filter)!==((n=e.filter)==null?void 0:n.filter)},DS=({sort:r},{sort:e})=>r===void 0&&(e==null?void 0:e.sortDefs.length)===0||e===void 0&&(r==null?void 0:r.sortDefs.length)===0,LS=(r,e)=>{let{sort:t}=r,{sort:n}=e;return _o(t,n)||DS(r,e)?!1:t===void 0||n===void 0||(t==null?void 0:t.sortDefs.length)!==(n==null?void 0:n.sortDefs.length)?!0:t.sortDefs.some(({column:o,sortType:i},s)=>o!==n.sortDefs[s].column||i!==n.sortDefs[s].sortType)},qd=r=>r!==void 0&&r.groupBy!==void 0&&r.groupBy.length>0,Kd=r=>(r==null?void 0:r.filter)!==void 0&&r.filter.filter.length>0,jd=r=>{var e;return(r==null?void 0:r.sort)!==void 0&&Array.isArray((e=r.sort)==null?void 0:e.sortDefs)&&r.sort.sortDefs.length>0},AS=({groupBy:r},{groupBy:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,Ha=(r,e)=>{let{groupBy:t}=r,{groupBy:n}=e;return _o(t,n)||AS(r,e)?!1:t===void 0||n===void 0||(t==null?void 0:t.length)!==(n==null?void 0:n.length)?!0:t.some((o,i)=>o!==(n==null?void 0:n[i]))},OS=({columns:r},{columns:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,NS=(r,e)=>{let{columns:t}=r,{columns:n}=e;return _o(t,n)||OS(r,e)?!1:t===void 0||n===void 0||(t==null?void 0:t.length)!==(n==null?void 0:n.length)?!0:t.some((o,i)=>o!==(n==null?void 0:n[i]))},VS=({aggregations:r},{aggregations:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,FS=(r,e)=>{let{aggregations:t}=r,{aggregations:n}=e;return _o(t,n)||VS(r,e)?!1:t===void 0||n===void 0||t.length!==n.length?!0:t.some(({column:o,aggType:i},s)=>o!==n[s].column||i!==n[s].aggType)},BS=()=>!1,as=(r,e)=>_o(r,e)?!1:r===void 0||e===void 0?!0:NS(r,e)||PS(r,e)||LS(r,e)||Ha(r,e)||FS(r,e)||BS(r,e),HS=["config","aggregate","viewport-update","columns","debounce-begin","disabled","enabled","filter","groupBy","vuu-link-created","vuu-link-removed","vuu-links","vuu-menu","sort","subscribed"],Jd=r=>{let e=r.type;return HS.includes(e)},Qd=r=>["config","aggregate","columns","filter","groupBy","sort"].includes(r.type),_S={filter:""},zS={sortDefs:[]},Er={aggregations:[],columns:[],filter:_S,groupBy:[],sort:zS},cs=r=>{if(r.aggregations&&r.columns&&r.filter&&r.groupBy&&r.sort)return r;{let{aggregations:e=[],columns:t=[],filter:n={filter:""},groupBy:o=[],sort:i={sortDefs:[]},visualLink:s}=r;return{aggregations:e,columns:t,filter:n,groupBy:o,sort:i,visualLink:s}}};var Yd="GET_TABLE_LIST",Xd="GET_TABLE_META";var _a=r=>r.type==="connection-status",Zd=r=>r.type==="connection-metrics",ep=r=>typeof r.result<"u",tp=r=>r.type==="TABLE_META_RESP";var np='\nvar fe=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var g=(s,e,t)=>(fe(s,e,"read from private field"),t?t.call(s):e.get(s)),U=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},me=(s,e,t,n)=>(fe(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);function he(s,e,t=[],n=[]){for(let r=0,o=s.length;r<o;r++)(e(s[r],r)?t:n).push(s[r]);return[t,n]}var x={IDX:0,RENDER_IDX:1,IS_LEAF:2,IS_EXPANDED:3,DEPTH:4,COUNT:5,KEY:6,SELECTED:7,count:8,PARENT_IDX:"parent_idx",IDX_POINTER:"idx_pointer",FILTER_COUNT:"filter_count",NEXT_FILTER_IDX:"next_filter_idx"};var{DEPTH:nn,IS_LEAF:rn}=x;var be=s=>{var e,t;if(((e=globalThis.document)==null?void 0:e.cookie)!==void 0)return(t=globalThis.document.cookie.split("; ").find(n=>n.startsWith(`${s}=`)))==null?void 0:t.split("=")[1]};function Y({from:s,to:e},t=0,n=Number.MAX_SAFE_INTEGER){if(t===0)return n<s?{from:0,to:0}:{from:s,to:Math.min(e,n)};if(s===0)return{from:s,to:Math.min(e+t,n)};{let r=e-s,o=Math.round(t/2),a=s-o<0,u=n-(e+o)<0;return a&&u?{from:0,to:n}:a?{from:0,to:r+t}:u?{from:Math.max(0,n-(r+t)),to:n}:{from:s-o,to:e+o}}}var lt=(s,{from:e,to:t})=>s>=e&&s<t;var v=class{constructor(e,t){this.from=e,this.to=t}isWithin(e){return lt(e,this)}overlap(e,t){return e>=this.to||t<this.from?[0,0]:[Math.max(e,this.from),Math.min(t,this.to)]}copy(){return new v(this.from,this.to)}};var{KEY:pn}=x;var ct=["error","warn","info","debug"],pt=s=>typeof s=="string"&&ct.includes(s),dt="error",F=()=>{},gt="error",{loggingLevel:N=gt}=ft(),w=s=>{let e=N==="debug",t=e||N==="info",n=t||N==="warn",r=n||N==="error",o=t?d=>console.info(`[${s}] ${d}`):F,a=n?d=>console.warn(`[${s}] ${d}`):F,u=e?d=>console.debug(`[${s}] ${d}`):F;return{errorEnabled:r,error:r?d=>console.error(`[${s}] ${d}`):F}};function ft(){return typeof loggingSettings<"u"?loggingSettings:{loggingLevel:mt()}}function mt(){let s=be("vuu-logging-level");return pt(s)?s:dt}var{debug:ht,debugEnabled:bt}=w("range-monitor"),W=class{constructor(e){this.source=e;this.range={from:0,to:0};this.timestamp=0}isSet(){return this.timestamp!==0}set({from:e,to:t}){let{timestamp:n}=this;if(this.range.from=e,this.range.to=t,this.timestamp=performance.now(),n)bt&&ht(`<${this.source}> [${e}-${t}], ${(this.timestamp-n).toFixed(0)} ms elapsed`);else return 0}};function Ce(s){return Array.isArray(s)}function Ct(s){return!Array.isArray(s)}var S,ye=class{constructor(){U(this,S,new Map)}addListener(e,t){let n=g(this,S).get(e);n?Ce(n)?n.push(t):Ct(n)&&g(this,S).set(e,[n,t]):g(this,S).set(e,t)}removeListener(e,t){if(!g(this,S).has(e))return;let n=g(this,S).get(e),r=-1;if(n===t)g(this,S).delete(e);else if(Array.isArray(n)){for(let o=length;o-- >0;)if(n[o]===t){r=o;break}if(r<0)return;n.length===1?(n.length=0,g(this,S).delete(e)):n.splice(r,1)}}removeAllListeners(e){e&&g(this,S).has(e)?g(this,S).delete(e):e===void 0&&g(this,S).clear()}emit(e,...t){if(g(this,S)){let n=g(this,S).get(e);n&&this.invokeHandler(n,t)}}once(e,t){let n=(...r)=>{this.removeListener(e,n),t(...r)};this.on(e,n)}on(e,t){this.addListener(e,t)}invokeHandler(e,t){if(Ce(e))e.slice().forEach(n=>this.invokeHandler(n,t));else switch(t.length){case 0:e();break;case 1:e(t[0]);break;case 2:e(t[0],t[1]);break;default:e.call(null,...t)}}};S=new WeakMap;var $=String.fromCharCode(8200),m=String.fromCharCode(8199);var wn={DIGIT:m,TWO_DIGITS:m+m,THREE_DIGITS:m+m+m,FULL_PADDING:[null,$+m,$+m+m,$+m+m+m,$+m+m+m+m]};var En=m+m+m+m+m+m+m+m+m;var{COUNT:Bn}=x;var q=class{constructor(e){this.keys=new Map,this.free=[],this.nextKeyValue=0,this.reset(e)}next(){return this.free.length>0?this.free.pop():this.nextKeyValue++}reset({from:e,to:t}){this.keys.forEach((r,o)=>{(o<e||o>=t)&&(this.free.push(r),this.keys.delete(o))});let n=t-e;this.keys.size+this.free.length>n&&(this.free.length=Math.max(0,n-this.keys.size));for(let r=e;r<t;r++)if(!this.keys.has(r)){let o=this.next();this.keys.set(r,o)}this.nextKeyValue>this.keys.size&&(this.nextKeyValue=this.keys.size)}keyFor(e){let t=this.keys.get(e);if(t===void 0)throw console.log(`key not found\n keys: ${this.toDebugString()}\n free : ${this.free.join(",")} \n `),Error(`KeySet, no key found for rowIndex ${e}`);return t}toDebugString(){return Array.from(this.keys.entries()).map((e,t)=>`${e}=>${t}`).join(",")}};var{IDX:Zn}=x;var{SELECTED:er}=x,I={False:0,True:1,First:2,Last:4};var yt=(s,e)=>e>=s[0]&&e<=s[1],St=I.True+I.First+I.Last,Tt=I.True+I.First,Rt=I.True+I.Last,Z=(s,e)=>{for(let t of s)if(typeof t=="number"){if(t===e)return St}else if(yt(t,e))return e===t[0]?Tt:e===t[1]?Rt:I.True;return I.False};var Se=s=>{if(s.every(t=>typeof t=="number"))return s;let e=[];for(let t of s)if(typeof t=="number")e.push(t);else for(let n=t[0];n<=t[1];n++)e.push(n);return e};var wt=(()=>{let s=0,e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(s+=1,`u${e()}${s}`)})();var{debug:ks,debugEnabled:As,error:we,info:V,infoEnabled:It,warn:_}=w("websocket-connection"),Ee="ws",vt=s=>s.startsWith(Ee+"://")||s.startsWith(Ee+"s://"),xe={},ee=Symbol("setWebsocket"),B=Symbol("connectionCallback");async function Ie(s,e,t,n=10,r=5){return xe[s]={status:"connecting",connect:{allowed:r,remaining:r},reconnect:{allowed:n,remaining:n}},ve(s,e,t)}async function Q(s){throw Error("connection broken")}async function ve(s,e,t,n){let{status:r,connect:o,reconnect:a}=xe[s],u=r==="connecting"?o:a;try{t({type:"connection-status",status:"connecting"});let c=typeof n<"u",d=await _t(s,e);console.info("%c\u26A1 %cconnected","font-size: 24px;color: green;font-weight: bold;","color:green; font-size: 14px;"),n!==void 0&&n[ee](d);let i=n!=null?n:new te(d,s,e,t),l=c?"reconnected":"connection-open-awaiting-session";return t({type:"connection-status",status:l}),i.status=l,u.remaining=u.allowed,i}catch{let d=--u.remaining>0;if(t({type:"connection-status",status:"disconnected",reason:"failed to connect",retry:d}),d)return Dt(s,e,t,n,2e3);throw Error("Failed to establish connection")}}var Dt=(s,e,t,n,r)=>new Promise(o=>{setTimeout(()=>{o(ve(s,e,t,n))},r)}),_t=(s,e)=>new Promise((t,n)=>{let r=vt(s)?s:`wss://${s}`;It&&e!==void 0&&V(`WebSocket Protocol ${e==null?void 0:e.toString()}`);let o=new WebSocket(r,e);o.onopen=()=>t(o),o.onerror=a=>n(a)}),Ve=()=>{_==null||_("Connection cannot be closed, socket not yet opened")},Me=s=>{_==null||_(`Message cannot be sent, socket closed ${s.body.type}`)},Pt=s=>{try{return JSON.parse(s)}catch{throw Error(`Error parsing JSON response from server ${s}`)}},te=class{constructor(e,t,n,r){this.close=Ve;this.requiresLogin=!0;this.send=Me;this.status="ready";this.messagesCount=0;this.connectionMetricsInterval=null;this.handleWebsocketMessage=e=>{let t=Pt(e.data);this.messagesCount+=1,this[B](t)};this.url=t,this.protocol=n,this[B]=r,this[ee](e)}reconnect(){Q(this)}[(B,ee)](e){let t=this[B];e.onmessage=o=>{this.status="connected",e.onmessage=this.handleWebsocketMessage,this.handleWebsocketMessage(o)},this.connectionMetricsInterval=setInterval(()=>{t({type:"connection-metrics",messagesLength:this.messagesCount}),this.messagesCount=0},2e3),e.onerror=()=>{we("\u26A1 connection error"),t({type:"connection-status",status:"disconnected",reason:"error"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status==="connection-open-awaiting-session"?we("Websocket connection lost before Vuu session established, check websocket configuration"):this.status!=="closed"&&(Q(this),this.send=r)},e.onclose=()=>{V==null||V("\u26A1 connection close"),t({type:"connection-status",status:"disconnected",reason:"close"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status!=="closed"&&(Q(this),this.send=r)};let n=o=>{e.send(JSON.stringify(o))},r=o=>{V==null||V(`TODO queue message until websocket reconnected ${o.body.type}`)};this.send=n,this.close=()=>{this.status="closed",e.close(),this.close=Ve,this.send=Me,V==null||V("close websocket")}}};var Lt=["VIEW_PORT_MENUS_SELECT_RPC","VIEW_PORT_MENU_TABLE_RPC","VIEW_PORT_MENU_ROW_RPC","VIEW_PORT_MENU_CELL_RPC","VP_EDIT_CELL_RPC","VP_EDIT_ROW_RPC","VP_EDIT_ADD_ROW_RPC","VP_EDIT_DELETE_CELL_RPC","VP_EDIT_DELETE_ROW_RPC","VP_EDIT_SUBMIT_FORM_RPC"],De=s=>Lt.includes(s.type),ne=({requestId:s,...e})=>[s,e],_e=s=>{let e=s.at(0);if(e.updateType==="SIZE"){if(s.length===1)return s;e=s.at(1)}let t=s.at(-1);return[e,t]},Pe=s=>{let e={};for(let t of s)(e[t.viewPortId]||(e[t.viewPortId]=[])).push(t);return e};var re=({columns:s,dataTypes:e,key:t,table:n})=>({table:n,columns:s.map((r,o)=>({name:r,serverDataType:e[o]})),key:t});var Le=s=>s.type==="connection-status",Oe=s=>s.type==="connection-metrics";var ke=s=>"viewport"in s,Ae=s=>s.type==="VIEW_PORT_MENU_RESP"&&s.action!==null&&G(s.action.table),G=s=>s!==null&&typeof s=="object"&&"table"in s&&"module"in s?s.table.startsWith("session"):!1;var Ue="CHANGE_VP_SUCCESS",Fe="CHANGE_VP_RANGE_SUCCESS",Ne="CLOSE_TREE_NODE",We="CLOSE_TREE_SUCCESS";var $e="CREATE_VP",qe="CREATE_VP_SUCCESS",Be="DISABLE_VP",Ge="DISABLE_VP_SUCCESS";var Ke="ENABLE_VP",He="ENABLE_VP_SUCCESS";var se="GET_VP_VISUAL_LINKS",je="GET_VIEW_PORT_MENUS";var ze="HB",Je="HB_RESP",Ye="LOGIN",Ze="LOGIN_SUCCESS",Xe="OPEN_TREE_NODE",Qe="OPEN_TREE_SUCCESS";var et="REMOVE_VP";var oe="RPC_RESP";var tt="SET_SELECTION_SUCCESS",ie="TABLE_META_RESP",ae="TABLE_LIST_RESP",nt="TABLE_ROW";var st=s=>{switch(s){case"TypeAheadRpcHandler":return"TYPEAHEAD";default:return"SIMUL"}};var ot=[],T=w("array-backed-moving-window");function Ot(s,e){if(!e||e.sel!==s.sel)return!1;for(let t=0;t<e.data.length;t++)if(e.data[t]!==s.data[t])return!1;return!0}var h,K=class{constructor({from:e,to:t},{from:n,to:r},o){U(this,h,void 0);this.setRowCount=e=>{var t;if((t=T.info)==null||t.call(T,`setRowCount ${e}`),e<this.internalData.length&&(this.internalData.length=e),e<this.rowCount){this.rowsWithinRange=0;let n=Math.min(e,this.clientRange.to);for(let r=this.clientRange.from;r<n;r++){let o=r-g(this,h).from;this.internalData[o]!==void 0&&(this.rowsWithinRange+=1)}}this.rowCount=e};this.bufferBreakout=(e,t)=>{let n=this.bufferSize*.25;return g(this,h).to-t<n?!0:g(this,h).from>0&&e-g(this,h).from<n};this.bufferSize=o,this.clientRange=new v(e,t),me(this,h,new v(n,r)),this.internalData=new Array(o),this.rowsWithinRange=0,this.rowCount=0}get range(){return g(this,h)}get hasAllRowsWithinRange(){return this.rowsWithinRange===this.clientRange.to-this.clientRange.from||this.rowCount>0&&this.clientRange.from+this.rowsWithinRange===this.rowCount}outOfRange(e,t){let{from:n,to:r}=this.range;if(t<n||e>=r)return!0}setAtIndex(e){let{rowIndex:t}=e,n=t-g(this,h).from;if(Ot(e,this.internalData[n]))return!1;let r=this.isWithinClientRange(t);return(r||this.isWithinRange(t))&&(!this.internalData[n]&&r&&(this.rowsWithinRange+=1),this.internalData[n]=e),r}getAtIndex(e){return g(this,h).isWithin(e)&&this.internalData[e-g(this,h).from]!=null?this.internalData[e-g(this,h).from]:void 0}isWithinRange(e){return g(this,h).isWithin(e)}isWithinClientRange(e){return this.clientRange.isWithin(e)}setClientRange(e,t){var d;(d=T.debug)==null||d.call(T,`setClientRange ${e} - ${t}`);let n=this.clientRange.from,r=Math.min(this.clientRange.to,this.rowCount);if(e===n&&t===r)return[!1,ot];let o=this.clientRange.copy();this.clientRange.from=e,this.clientRange.to=t,this.rowsWithinRange=0;for(let i=e;i<t;i++){let l=i-g(this,h).from;this.internalData[l]&&(this.rowsWithinRange+=1)}let a=ot,u=g(this,h).from;if(this.hasAllRowsWithinRange)if(t>o.to){let i=Math.max(e,o.to);a=this.internalData.slice(i-u,t-u)}else{let i=Math.min(o.from,t);a=this.internalData.slice(e-u,i-u)}return[this.bufferBreakout(e,t),a]}setRange(e,t){var n,r;if(e!==g(this,h).from||t!==g(this,h).to){(n=T.debug)==null||n.call(T,`setRange ${e} - ${t}`);let[o,a]=g(this,h).overlap(e,t),u=new Array(t-e);this.rowsWithinRange=0;for(let c=o;c<a;c++){let d=this.getAtIndex(c);if(d){let i=c-e;u[i]=d,this.isWithinClientRange(c)&&(this.rowsWithinRange+=1)}}this.internalData=u,g(this,h).from=e,g(this,h).to=t}else(r=T.debug)==null||r.call(T,`setRange ${e} - ${t} IGNORED because not changed`)}get data(){return this.internalData}getData(){var u;let{from:e,to:t}=g(this,h),{from:n,to:r}=this.clientRange,o=Math.max(0,n-e),a=Math.min(t-e,t,r-e,(u=this.rowCount)!=null?u:t);return this.internalData.slice(o,a)}clear(){var e;(e=T.debug)==null||e.call(T,"clear"),this.internalData.length=0,this.rowsWithinRange=0,this.setRowCount(0)}getCurrentDataRange(){let e=this.internalData,t=e.length,[n]=this.internalData,r=this.internalData[t-1];if(n&&r)return[n.rowIndex,r.rowIndex];for(let o=0;o<t;o++)if(e[o]!==void 0){n=e[o];break}for(let o=t-1;o>=0;o--)if(e[o]!==void 0){r=e[o];break}return n&&r?[n.rowIndex,r.rowIndex]:[-1,-1]}};h=new WeakMap;var kt=[],{debug:b,debugEnabled:H,error:At,info:p,infoEnabled:Ut,warn:P}=w("viewport"),Ft=({rowKey:s,updateType:e})=>e==="U"&&!s.startsWith("$root"),j=[void 0,void 0],Nt={count:0,mode:void 0,size:0,ts:0},z=class{constructor({aggregations:e,bufferSize:t=50,columns:n,filter:r,groupBy:o=[],table:a,range:u,sort:c,title:d,viewport:i,visualLink:l},f){this.batchMode=!0;this.hasUpdates=!1;this.pendingUpdates=[];this.pendingOperations=new Map;this.pendingRangeRequests=[];this.rowCountChanged=!1;this.selectedRows=[];this.tableSchema=null;this.useBatchMode=!0;this.lastUpdateStatus=Nt;this.updateThrottleTimer=void 0;this.rangeMonitor=new W("ViewPort");this.disabled=!1;this.isTree=!1;this.status="";this.suspended=!1;this.suspendTimer=null;this.setLastSizeOnlyUpdateSize=e=>{this.lastUpdateStatus.size=e};this.setLastUpdate=e=>{let{ts:t,mode:n}=this.lastUpdateStatus,r=0;if(n===e){let o=Date.now();this.lastUpdateStatus.count+=1,this.lastUpdateStatus.ts=o,r=t===0?0:o-t}else this.lastUpdateStatus.count=1,this.lastUpdateStatus.ts=0,r=0;return this.lastUpdateStatus.mode=e,r};this.rangeRequestAlreadyPending=e=>{let{bufferSize:t}=this,n=t*.25,{from:r}=e;for(let{from:o,to:a}of this.pendingRangeRequests)if(r>=o&&r<a){if(e.to+n<=a)return!0;r=a}return!1};this.sendThrottledSizeMessage=()=>{this.updateThrottleTimer=void 0,this.lastUpdateStatus.count=3,this.postMessageToClient({clientViewportId:this.clientViewportId,mode:"size-only",size:this.lastUpdateStatus.size,type:"viewport-update"})};this.shouldThrottleMessage=e=>{let t=this.setLastUpdate(e);return console.log(`elapsed time = ${t}`),e==="size-only"&&t>0&&t<500&&this.lastUpdateStatus.count>3};this.throttleMessage=e=>this.shouldThrottleMessage(e)?(p==null||p("throttling updates setTimeout to 2000"),this.updateThrottleTimer===void 0&&(this.updateThrottleTimer=setTimeout(this.sendThrottledSizeMessage,2e3)),!0):(this.updateThrottleTimer!==void 0&&(clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),!1);this.getNewRowCount=()=>{if(this.rowCountChanged&&this.dataWindow)return this.rowCountChanged=!1,this.dataWindow.rowCount};this.aggregations=e,this.bufferSize=t,this.clientRange=u,this.clientViewportId=i,this.columns=n,this.filter=r,this.groupBy=o,this.keys=new q(u),this.pendingLinkedParent=l,this.table=a,this.sort=c,this.title=d,Ut&&(p==null||p(`constructor #${i} ${a.table} bufferSize=${t}`)),this.dataWindow=new K(this.clientRange,u,this.bufferSize),this.postMessageToClient=f}get hasUpdatesToProcess(){return this.suspended?!1:this.rowCountChanged||this.hasUpdates}get size(){var e;return(e=this.dataWindow.rowCount)!=null?e:0}subscribe(){let{filter:e}=this.filter;return this.status=this.status==="subscribed"?"resubscribing":"subscribing",{type:$e,table:this.table,range:Y(this.clientRange,this.bufferSize),aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:e}}}handleSubscribed({viewPortId:e,aggregations:t,columns:n,filterSpec:r,range:o,sort:a,groupBy:u}){return this.serverViewportId=e,this.status="subscribed",this.aggregations=t,this.columns=n,this.groupBy=u,this.isTree=u&&u.length>0,this.dataWindow.setRange(o.from,o.to),{aggregations:t,type:"subscribed",clientViewportId:this.clientViewportId,columns:n,filter:r,groupBy:u,range:o,sort:a,tableSchema:this.tableSchema}}awaitOperation(e,t){this.pendingOperations.set(e,t)}completeOperation(e,...t){var u;let{clientViewportId:n,pendingOperations:r}=this,o=r.get(e);if(!o){At("no matching operation found to complete");return}let{type:a}=o;if(p==null||p(`completeOperation ${a}`),r.delete(e),a==="CHANGE_VP_RANGE"){let[c,d]=t;(u=this.dataWindow)==null||u.setRange(c,d);for(let i=this.pendingRangeRequests.length-1;i>=0;i--){let l=this.pendingRangeRequests[i];if(l.requestId===e){l.acked=!0;break}else P==null||P("range requests sent faster than they are being ACKed")}}else if(a==="config"){let{aggregations:c,columns:d,filter:i,groupBy:l,sort:f}=o.data;return this.aggregations=c,this.columns=d,this.filter=i,this.groupBy=l,this.sort=f,l.length>0?this.isTree=!0:this.isTree&&(this.isTree=!1),b==null||b(`config change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:a,config:o.data}}else{if(a==="groupBy")return this.isTree=o.data.length>0,this.groupBy=o.data,b==null||b(`groupBy change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:a,groupBy:o.data};if(a==="columns")return this.columns=o.data,{clientViewportId:n,type:a,columns:o.data};if(a==="filter")return this.filter=o.data,{clientViewportId:n,type:a,filter:o.data};if(a==="aggregate")return this.aggregations=o.data,{clientViewportId:n,type:"aggregate",aggregations:this.aggregations};if(a==="sort")return this.sort=o.data,{clientViewportId:n,type:a,sort:this.sort};if(a!=="selection"){if(a==="disable")return this.disabled=!0,{type:"disabled",clientViewportId:n};if(a==="enable")return this.disabled=!1,{type:"enabled",clientViewportId:n};if(a==="CREATE_VISUAL_LINK"){let[c,d,i]=t;return this.linkedParent={colName:c,parentViewportId:d,parentColName:i},this.pendingLinkedParent=void 0,{type:"vuu-link-created",clientViewportId:n,colName:c,parentViewportId:d,parentColName:i}}else if(a==="REMOVE_VISUAL_LINK")return this.linkedParent=void 0,{type:"vuu-link-removed",clientViewportId:n}}}}rangeRequest(e,t){H&&this.rangeMonitor.set(t);let n="CHANGE_VP_RANGE";if(this.dataWindow){let[r,o]=this.dataWindow.setClientRange(t.from,t.to),a,u=this.dataWindow.rowCount||void 0,c=r&&!this.rangeRequestAlreadyPending(t)?{type:n,viewPortId:this.serverViewportId,...Y(t,this.bufferSize,u)}:null;if(c){H&&(b==null||b(`create CHANGE_VP_RANGE: [${c.from} - ${c.to}]`)),this.awaitOperation(e,{type:n});let i=this.pendingRangeRequests.at(-1);if(i)if(i.acked)console.warn("Range Request before previous request is filled");else{let{from:l,to:f}=i;this.dataWindow.outOfRange(l,f)?a={clientViewportId:this.clientViewportId,type:"debounce-begin"}:P==null||P("Range Request before previous request is acked")}this.pendingRangeRequests.push({...c,requestId:e}),this.useBatchMode&&(this.batchMode=!0)}else o.length>0&&(this.batchMode=!1);this.keys.reset(this.dataWindow.clientRange);let d=this.isTree?le:ue;return o.length?[c,o.map(i=>d(i,this.keys,this.selectedRows))]:a?[c,void 0,a]:[c]}else return[null]}setLinks(e){return this.links=e,[{type:"vuu-links",links:e,clientViewportId:this.clientViewportId},this.pendingLinkedParent]}setMenu(e){return{type:"vuu-menu",menu:e,clientViewportId:this.clientViewportId}}setTableSchema(e){this.tableSchema=e}openTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Xe,vpId:this.serverViewportId,treeKey:t.key}}closeTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Ne,vpId:this.serverViewportId,treeKey:t.key}}createLink(e,t,n,r){let o={type:"CREATE_VISUAL_LINK",parentVpId:n,childVpId:this.serverViewportId,parentColumnName:r,childColumnName:t};return this.awaitOperation(e,o),this.useBatchMode&&(this.batchMode=!0),o}removeLink(e){let t={type:"REMOVE_VISUAL_LINK",childVpId:this.serverViewportId};return this.awaitOperation(e,t),t}suspend(){this.suspended=!0,p==null||p("suspend")}resume(){return this.suspended=!1,H&&(b==null||b(`resume: ${this.currentData()}`)),this.currentData()}currentData(){let e=[];if(this.dataWindow){let t=this.dataWindow.getData(),{keys:n}=this,r=this.isTree?le:ue;for(let o of t)o&&e.push(r(o,n,this.selectedRows))}return e}enable(e){return this.awaitOperation(e,{type:"enable"}),p==null||p(`enable: ${this.serverViewportId}`),{type:Ke,viewPortId:this.serverViewportId}}disable(e){return this.awaitOperation(e,{type:"disable"}),p==null||p(`disable: ${this.serverViewportId}`),this.suspended=!1,{type:Be,viewPortId:this.serverViewportId}}columnRequest(e,t){return this.awaitOperation(e,{type:"columns",data:t}),b==null||b(`columnRequest: ${t}`),this.createRequest({columns:t})}filterRequest(e,t){this.awaitOperation(e,{type:"filter",data:t}),this.useBatchMode&&(this.batchMode=!0);let{filter:n}=t;return p==null||p(`filterRequest: ${n}`),this.createRequest({filterSpec:{filter:n}})}setConfig(e,t){this.awaitOperation(e,{type:"config",data:t});let{filter:n,...r}=t;return this.useBatchMode&&(this.batchMode=!0),H?b==null||b(`setConfig ${JSON.stringify(t)}`):p==null||p("setConfig"),this.createRequest({...r,filterSpec:typeof(n==null?void 0:n.filter)=="string"?{filter:n.filter}:{filter:""}},!0)}aggregateRequest(e,t){return this.awaitOperation(e,{type:"aggregate",data:t}),p==null||p(`aggregateRequest: ${t}`),this.createRequest({aggregations:t})}sortRequest(e,t){return this.awaitOperation(e,{type:"sort",data:t}),p==null||p(`sortRequest: ${JSON.stringify(t.sortDefs)}`),this.createRequest({sort:t})}groupByRequest(e,t=kt){var n;return this.awaitOperation(e,{type:"groupBy",data:t}),this.useBatchMode&&(this.batchMode=!0),this.isTree||(n=this.dataWindow)==null||n.clear(),this.createRequest({groupBy:t})}selectRequest(e,t){return this.selectedRows=t,this.awaitOperation(e,{type:"selection",data:t}),p==null||p(`selectRequest: ${t}`),{type:"SET_SELECTION",vpId:this.serverViewportId,selection:Se(t)}}removePendingRangeRequest(e,t){for(let n=this.pendingRangeRequests.length-1;n>=0;n--){let{from:r,to:o}=this.pendingRangeRequests[n],a=!0;if(e>=r&&e<o||t>r&&t<o){a||console.warn("removePendingRangeRequest TABLE_ROWS are not for latest request"),this.pendingRangeRequests.splice(n,1);break}else a=!1}}updateRows(e){var r,o,a;let[t,n]=_e(e);if(t&&n&&this.removePendingRangeRequest(t.rowIndex,n.rowIndex),e.length===1)if(t.vpSize===0&&this.disabled){b==null||b(`ignore a SIZE=0 message on disabled viewport (${e.length} rows)`);return}else t.updateType==="SIZE"&&this.setLastSizeOnlyUpdateSize(t.vpSize);for(let u of e)this.isTree&&Ft(u)||((u.updateType==="SIZE"||((r=this.dataWindow)==null?void 0:r.rowCount)!==u.vpSize)&&((o=this.dataWindow)==null||o.setRowCount(u.vpSize),this.rowCountChanged=!0),u.updateType==="U"&&(a=this.dataWindow)!=null&&a.setAtIndex(u)&&(this.hasUpdates=!0,this.batchMode||this.pendingUpdates.push(u)))}getClientRows(){let e,t="size-only";if(!this.hasUpdates&&!this.rowCountChanged)return j;if(this.hasUpdates){let{keys:n,selectedRows:r}=this,o=this.isTree?le:ue;if(this.updateThrottleTimer&&(self.clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),this.pendingUpdates.length>0){e=[],t="update";for(let a of this.pendingUpdates)e.push(o(a,n,r));this.pendingUpdates.length=0}else{let a=this.dataWindow.getData();if(this.dataWindow.hasAllRowsWithinRange){e=[],t="batch";for(let u of a)e.push(o(u,n,r));this.batchMode=!1}}this.hasUpdates=!1}return this.throttleMessage(t)?j:[e,t]}createRequest(e,t=!1){return t?{type:"CHANGE_VP",viewPortId:this.serverViewportId,...e}:{type:"CHANGE_VP",viewPortId:this.serverViewportId,aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:this.filter.filter},...e}}},ue=({rowIndex:s,rowKey:e,sel:t,data:n},r,o)=>[s,r.keyFor(s),!0,!1,0,0,e,t?Z(o,s):0].concat(n),le=({rowIndex:s,rowKey:e,sel:t,data:n},r,o)=>{let[a,u,,c,,d,...i]=n;return[s,r.keyFor(s),c,u,a,d,e,t?Z(o,s):0].concat(i)};var it=1;var{debug:E,debugEnabled:L,error:O,info:y,infoEnabled:Wt,warn:k}=w("server-proxy"),C=()=>`${it++}`,$t={},qt=s=>s.disabled!==!0&&s.suspended!==!0,Bt={type:"NO_ACTION"},Gt=(s,e,t)=>s.map(n=>n.parentVpId===e?{...n,label:t}:n);function Kt(s,e){return s.map(t=>{let{parentVpId:n}=t,r=e.get(n);if(r)return{...t,parentClientVpId:r.clientViewportId,label:r.title};throw Error("addLabelsToLinks viewport not found")})}var J=class{constructor(e,t){this.authToken="";this.user="user";this.pendingTableMetaRequests=new Map;this.pendingRequests=new Map;this.queuedRequests=[];this.cachedTableSchemas=new Map;this.connection=e,this.postMessageToClient=t,this.viewports=new Map,this.mapClientToServerViewport=new Map}async reconnect(){await this.login(this.authToken);let[e,t]=he(Array.from(this.viewports.values()),qt);this.viewports.clear(),this.mapClientToServerViewport.clear();let n=r=>{r.forEach(o=>{let{clientViewportId:a}=o;this.viewports.set(a,o),this.sendMessageToServer(o.subscribe(),a)})};n(e),setTimeout(()=>{n(t)},2e3)}async login(e,t="user"){if(e)return this.authToken=e,this.user=t,new Promise((n,r)=>{this.sendMessageToServer({type:Ye,token:this.authToken,user:t},""),this.pendingLogin={resolve:n,reject:r}});this.authToken===""&&O("login, cannot login until auth token has been obtained")}subscribe(e){if(this.mapClientToServerViewport.has(e.viewport))O(`spurious subscribe call ${e.viewport}`);else{if(!this.hasSchemaForTable(e.table)&&!G(e.table)){y==null||y(`subscribe to ${e.table.table}, no metadata yet, request metadata`);let n=C();this.sendMessageToServer({type:"GET_TABLE_META",table:e.table},n),this.pendingTableMetaRequests.set(n,e.viewport)}let t=new z(e,this.postMessageToClient);this.viewports.set(e.viewport,t),this.sendIfReady(t.subscribe(),e.viewport,this.sessionId!=="")}}unsubscribe(e){let t=this.mapClientToServerViewport.get(e);t?(y==null||y(`Unsubscribe Message (Client to Server):\n ${t}`),this.sendMessageToServer({type:et,viewPortId:t})):O(`failed to unsubscribe client viewport ${e}, viewport not found`)}getViewportForClient(e,t=!0){let n=this.mapClientToServerViewport.get(e);if(n){let r=this.viewports.get(n);if(r)return r;if(t)throw Error(`Viewport not found for client viewport ${e}`);return null}else{if(this.viewports.has(e))return this.viewports.get(e);if(t)throw Error(`Viewport server id not found for client viewport ${e}`);return null}}setViewRange(e,t){let n=C(),[r,o,a]=e.rangeRequest(n,t.range);y==null||y(`setViewRange ${t.range.from} - ${t.range.to}`),r&&this.sendIfReady(r,n,e.status==="subscribed"),o?(y==null||y(`setViewRange ${o.length} rows returned from cache`),this.postMessageToClient({mode:"batch",type:"viewport-update",clientViewportId:e.clientViewportId,rows:o})):a&&this.postMessageToClient(a)}setConfig(e,t){let n=C(),r=e.setConfig(n,t.config);this.sendIfReady(r,n,e.status==="subscribed")}aggregate(e,t){let n=C(),r=e.aggregateRequest(n,t.aggregations);this.sendIfReady(r,n,e.status==="subscribed")}sort(e,t){let n=C(),r=e.sortRequest(n,t.sort);this.sendIfReady(r,n,e.status==="subscribed")}groupBy(e,t){let n=C(),r=e.groupByRequest(n,t.groupBy);this.sendIfReady(r,n,e.status==="subscribed")}filter(e,t){let n=C(),{filter:r}=t,o=e.filterRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}setColumns(e,t){let n=C(),{columns:r}=t,o=e.columnRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}setTitle(e,t){e&&(e.title=t.title,this.updateTitleOnVisualLinks(e))}select(e,t){let n=C(),{selected:r}=t,o=e.selectRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}disableViewport(e){let t=C(),n=e.disable(t);this.sendIfReady(n,t,e.status==="subscribed")}enableViewport(e){if(e.disabled){let t=C(),n=e.enable(t);this.sendIfReady(n,t,e.status==="subscribed")}}suspendViewport(e){e.suspend(),e.suspendTimer=setTimeout(()=>{y==null||y("suspendTimer expired, escalate suspend to disable"),this.disableViewport(e)},3e3)}resumeViewport(e){e.suspendTimer&&(E==null||E("clear suspend timer"),clearTimeout(e.suspendTimer),e.suspendTimer=null);let t=e.resume();this.postMessageToClient({clientViewportId:e.clientViewportId,mode:"batch",rows:t,type:"viewport-update"})}openTreeNode(e,t){if(e.serverViewportId){let n=C();this.sendIfReady(e.openTreeNode(n,t),n,e.status==="subscribed")}}closeTreeNode(e,t){if(e.serverViewportId){let n=C();this.sendIfReady(e.closeTreeNode(n,t),n,e.status==="subscribed")}}createLink(e,t){let{parentClientVpId:n,parentColumnName:r,childColumnName:o}=t,a=C(),u=this.mapClientToServerViewport.get(n);if(u){let c=e.createLink(a,o,u,r);this.sendMessageToServer(c,a)}else O("ServerProxy unable to create link, viewport not found")}removeLink(e){let t=C(),n=e.removeLink(t);this.sendMessageToServer(n,t)}updateTitleOnVisualLinks(e){var r;let{serverViewportId:t,title:n}=e;for(let o of this.viewports.values())if(o!==e&&o.links&&t&&n&&(r=o.links)!=null&&r.some(a=>a.parentVpId===t)){let[a]=o.setLinks(Gt(o.links,t,n));this.postMessageToClient(a)}}removeViewportFromVisualLinks(e){var t;for(let n of this.viewports.values())if((t=n.links)!=null&&t.some(({parentVpId:r})=>r===e)){let[r]=n.setLinks(n.links.filter(({parentVpId:o})=>o!==e));this.postMessageToClient(r)}}menuRpcCall(e){let t=this.getViewportForClient(e.vpId,!1);if(t!=null&&t.serverViewportId){let[n,r]=ne(e);this.sendMessageToServer({...r,vpId:t.serverViewportId},n)}}rpcCall(e){let[t,n]=ne(e),r=st(n.service);this.sendMessageToServer(n,t,{module:r})}handleMessageFromClient(e){if(E==null||E(`handleMessageFromClient: ${e.type}`),ke(e))if(e.type==="disable"){let t=this.getViewportForClient(e.viewport,!1);return t!==null?this.disableViewport(t):void 0}else{let t=this.getViewportForClient(e.viewport);switch(e.type){case"setViewRange":return this.setViewRange(t,e);case"config":return this.setConfig(t,e);case"aggregate":return this.aggregate(t,e);case"sort":return this.sort(t,e);case"groupBy":return this.groupBy(t,e);case"filter":return this.filter(t,e);case"select":return this.select(t,e);case"suspend":return this.suspendViewport(t);case"resume":return this.resumeViewport(t);case"enable":return this.enableViewport(t);case"openTreeNode":return this.openTreeNode(t,e);case"closeTreeNode":return this.closeTreeNode(t,e);case"createLink":return this.createLink(t,e);case"removeLink":return this.removeLink(t);case"setColumns":return this.setColumns(t,e);case"setTitle":return this.setTitle(t,e);default:}}else{if(De(e))return this.menuRpcCall(e);{let{type:t,requestId:n}=e;switch(t){case"GET_TABLE_LIST":return this.sendMessageToServer({type:t},n);case"GET_TABLE_META":return this.sendMessageToServer({type:t,table:e.table},n);case"RPC_CALL":return this.rpcCall(e);default:}}}O(`Vuu ServerProxy Unexpected message from client ${JSON.stringify(e)}`)}awaitResponseToMessage(e){return new Promise((t,n)=>{let r=C();this.sendMessageToServer(e,r),this.pendingRequests.set(r,{reject:n,resolve:t})})}sendIfReady(e,t,n=!0){return n?this.sendMessageToServer(e,t):this.queuedRequests.push(e),n}sendMessageToServer(e,t=`${it++}`,n=$t){let{module:r="CORE"}=n;this.authToken&&this.connection.send({requestId:t,sessionId:this.sessionId,token:this.authToken,user:this.user,module:r,body:e})}handleMessageFromServer(e){var u;let{body:t,requestId:n,sessionId:r}=e,o=this.pendingRequests.get(n);if(o){let{resolve:i}=o;this.pendingRequests.delete(n),i(t);return}let{viewports:a}=this;switch(t.type){case ze:this.sendMessageToServer({type:Je,ts:+new Date},"NA");break;case Ze:if(r)this.sessionId=r,(u=this.pendingLogin)==null||u.resolve(r),this.pendingLogin=void 0;else throw Error("LOGIN_SUCCESS did not provide sessionId");break;case qe:{let i=a.get(n);if(i){let{status:l}=i,{viewPortId:f}=t;n!==f&&(a.delete(n),a.set(f,i)),this.mapClientToServerViewport.set(n,f);let R=i.handleSubscribed(t);R&&(this.postMessageToClient(R),L&&E(`post DataSourceSubscribedMessage to client: ${JSON.stringify(R)}`)),i.disabled&&this.disableViewport(i),l==="subscribing"&&!G(i.table)&&(this.sendMessageToServer({type:se,vpId:f}),this.sendMessageToServer({type:je,vpId:f}),Array.from(a.entries()).filter(([M,{disabled:A}])=>M!==f&&!A).forEach(([M])=>{this.sendMessageToServer({type:se,vpId:M})}))}}break;case"REMOVE_VP_SUCCESS":{let i=this.viewports.get(t.viewPortId);i&&(this.mapClientToServerViewport.delete(i.clientViewportId),a.delete(t.viewPortId),this.removeViewportFromVisualLinks(t.viewPortId))}break;case tt:{let i=this.viewports.get(t.vpId);i&&i.completeOperation(n)}break;case Ue:case Ge:if(a.has(t.viewPortId)){let i=this.viewports.get(t.viewPortId);if(i){let l=i.completeOperation(n);l!==void 0&&(this.postMessageToClient(l),L&&E(`postMessageToClient ${JSON.stringify(l)}`))}}break;case He:{let i=this.viewports.get(t.viewPortId);if(i){let l=i.completeOperation(n);if(l){this.postMessageToClient(l);let f=i.currentData();L&&E(`Enable Response (ServerProxy to Client): ${JSON.stringify(l)}`),i.size===0?L&&E("Viewport Enabled but size 0, resend to server"):(this.postMessageToClient({clientViewportId:i.clientViewportId,mode:"batch",rows:f,size:i.size,type:"viewport-update"}),L&&E(`Enable Response (ServerProxy to Client): send size ${i.size} ${f.length} rows from cache`))}}}break;case nt:{let i=Pe(t.rows);for(let[l,f]of Object.entries(i)){let R=a.get(l);R?R.updateRows(f):k==null||k(`TABLE_ROW message received for non registered viewport ${l}`)}this.processUpdates()}break;case Fe:{let i=this.viewports.get(t.viewPortId);if(i){let{from:l,to:f}=t;i.completeOperation(n,l,f)}}break;case Qe:case We:break;case"CREATE_VISUAL_LINK_SUCCESS":{let i=this.viewports.get(t.childVpId),l=this.viewports.get(t.parentVpId);if(i&&l){let{childColumnName:f,parentColumnName:R}=t,M=i.completeOperation(n,f,l.clientViewportId,R);M&&this.postMessageToClient(M)}}break;case"REMOVE_VISUAL_LINK_SUCCESS":{let i=this.viewports.get(t.childVpId);if(i){let l=i.completeOperation(n);l&&this.postMessageToClient(l)}}break;case ae:this.postMessageToClient({type:ae,tables:t.tables,requestId:n});break;case ie:{let i=this.cacheTableMeta(t),l=this.pendingTableMetaRequests.get(n);if(l){this.pendingTableMetaRequests.delete(n);let f=this.viewports.get(l);f?f.setTableSchema(i):k==null||k("Message has come back AFTER CREATE_VP_SUCCESS, what do we do now")}else this.postMessageToClient({type:ie,tableSchema:i,requestId:n})}break;case"VP_VISUAL_LINKS_RESP":{let i=this.getActiveLinks(t.links),l=this.viewports.get(t.vpId);if(i.length&&l){let f=Kt(i,this.viewports),[R,M]=l.setLinks(f);if(this.postMessageToClient(R),M){let{link:A,parentClientVpId:at}=M,de=C(),ge=this.mapClientToServerViewport.get(at);if(ge){let ut=l.createLink(de,A.fromColumn,ge,A.toColumn);this.sendMessageToServer(ut,de)}}}}break;case"VIEW_PORT_MENUS_RESP":if(t.menu.name){let i=this.viewports.get(t.vpId);if(i){let l=i.setMenu(t.menu);this.postMessageToClient(l)}}break;case"VP_EDIT_RPC_RESPONSE":this.postMessageToClient({action:t.action,requestId:n,rpcName:t.rpcName,type:"VP_EDIT_RPC_RESPONSE"});break;case"VP_EDIT_RPC_REJECT":this.viewports.get(t.vpId)&&this.postMessageToClient({requestId:n,type:"VP_EDIT_RPC_REJECT",error:t.error});break;case"VIEW_PORT_MENU_RESP":if(Ae(t)){let{action:i,rpcName:l}=t;this.awaitResponseToMessage({type:"GET_TABLE_META",table:i.table}).then(f=>{let R=re(f);this.postMessageToClient({rpcName:l,type:"VIEW_PORT_MENU_RESP",action:{...i,tableSchema:R},tableAlreadyOpen:this.isTableOpen(i.table),requestId:n})})}else{let{action:i}=t;this.postMessageToClient({type:"VIEW_PORT_MENU_RESP",action:i||Bt,tableAlreadyOpen:i!==null&&this.isTableOpen(i.table),requestId:n})}break;case oe:{let{method:i,result:l}=t;this.postMessageToClient({type:oe,method:i,result:l,requestId:n})}break;case"ERROR":O(t.msg);break;default:Wt&&y(`handleMessageFromServer ${t.type}.`)}}hasSchemaForTable(e){return this.cachedTableSchemas.has(`${e.module}:${e.table}`)}cacheTableMeta(e){let{module:t,table:n}=e.table,r=`${t}:${n}`,o=this.cachedTableSchemas.get(r);return o||(o=re(e),this.cachedTableSchemas.set(r,o)),o}isTableOpen(e){if(e){let t=e.table;for(let n of this.viewports.values())if(!n.suspended&&n.table.table===t)return!0}}getActiveLinks(e){return e.filter(t=>{let n=this.viewports.get(t.parentVpId);return n&&!n.suspended})}processUpdates(){this.viewports.forEach(e=>{var t;if(e.hasUpdatesToProcess){let n=e.getClientRows();if(n!==j){let[r,o]=n,a=e.getNewRowCount();(a!==void 0||r&&r.length>0)&&(L&&E(`postMessageToClient #${e.clientViewportId} viewport-update ${o}, ${(t=r==null?void 0:r.length)!=null?t:"no"} rows, size ${a}`),o&&this.postMessageToClient({clientViewportId:e.clientViewportId,mode:o,rows:r,size:a,type:"viewport-update"}))}}})}};var D,{info:ce,infoEnabled:pe}=w("worker");async function Ht(s,e,t,n,r,o,a){let u=await Ie(s,e,c=>{Oe(c)?(console.log("post connection metrics"),postMessage({type:"connection-metrics",messages:c})):Le(c)?(r(c),c.status==="reconnected"&&D.reconnect()):D.handleMessageFromServer(c)},o,a);D=new J(u,c=>jt(c)),u.requiresLogin&&await D.login(t,n)}function jt(s){postMessage(s)}var zt=async({data:s})=>{switch(s.type){case"connect":await Ht(s.url,s.protocol,s.token,s.username,postMessage,s.retryLimitDisconnect,s.retryLimitStartup),postMessage({type:"connected"});break;case"subscribe":pe&&ce(`client subscribe: ${JSON.stringify(s)}`),D.subscribe(s);break;case"unsubscribe":pe&&ce(`client unsubscribe: ${JSON.stringify(s)}`),D.unsubscribe(s.viewport);break;default:pe&&ce(`client message: ${JSON.stringify(s)}`),D.handleMessageFromClient(s)}};self.addEventListener("message",zt);postMessage({type:"ready"});\n\n';var qS=new Blob([US()+np],{type:"text/javascript"}),KS=URL.createObjectURL(qS),Rr,za,Wa=[],jS,JS,rp=new Promise((r,e)=>{jS=r,JS=e}),Ga=()=>rp,us=new Map,hs=new Map,QS=async({handleConnectionStatusChange:r,protocol:e,retryLimitDisconnect:t,retryLimitStartup:n,token:o="",username:i,url:s})=>o===""&&za===void 0?new Promise(l=>{Wa.push({resolve:l})}):za||(za=new Promise(l=>{let a=new Worker(KS),c=window.setTimeout(()=>{console.error("timed out waiting for worker to load")},1e3);a.onmessage=u=>{let{data:h}=u;if(h.type==="ready")window.clearTimeout(c),a.postMessage({protocol:e,retryLimitDisconnect:t,retryLimitStartup:n,token:o,type:"connect",url:s,username:i});else if(h.type==="connected"){a.onmessage=op,l(a);for(let f of Wa)f.resolve(a);Wa.length=0}else _a(h)?r({data:h}):console.warn("ConnectionManager: Unexpected message from the worker")}}));function op({data:r}){if(Jd(r)){let e=us.get(r.clientViewportId);e?e.postMessageToClientDataSource(r):console.error(`[ConnectionManager] ${r.type} message received, viewport not found`)}else if(_a(r))fs.emit("connection-status",r);else if(Zd(r))console.log({message:r}),fs.emit("connection-metrics",r);else{let e=r.requestId;if(hs.has(e)){let{resolve:t}=hs.get(e);hs.delete(e);let{type:n,requestId:o,...i}=r;ep(r)?t(r.result):r.type==="VP_EDIT_RPC_RESPONSE"||r.type==="VP_EDIT_RPC_REJECT"?t(r):tp(r)?t(r.tableSchema):t(i)}else console.warn("%cConnectionManager Unexpected message from the worker","color:red;font-weight:bold;")}}var $a=r=>{let e=GS();return Rr.postMessage({requestId:e,...r}),new Promise((t,n)=>{hs.set(e,{resolve:t,reject:n})})},YS={subscribe:(r,e)=>{us.set(r.viewport,{status:"subscribing",request:r,postMessageToClientDataSource:e}),Rr.postMessage({type:"subscribe",...r})},unsubscribe:r=>{Rr.postMessage({type:"unsubscribe",viewport:r})},send:r=>{Rr.postMessage(r)},destroy:r=>{r&&us.has(r)&&us.delete(r)},rpcCall:async r=>$a(r),getTableList:async()=>$a({type:Yd}),getTableSchema:async r=>$a({type:Xd,table:r})},Ua=class extends $S{async connect({url:e,authToken:t,username:n,protocol:o,retryLimitDisconnect:i,retryLimitStartup:s}){return Rr=await QS({protocol:o,url:e,token:t,username:n,retryLimitDisconnect:i,retryLimitStartup:s,handleConnectionStatusChange:op}),YS}destroy(){Rr.terminate()}},fs=new Ua;var ip=async r=>{try{return(await rp).rpcCall(r)}catch{throw Error("Error accessing server api")}};var XS=0,zo=class{constructor(e,t){this.from=e,this.to=t}},J=class{constructor(e={}){this.id=XS++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=ke.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};J.closedBy=new J({deserialize:r=>r.split(" ")});J.openedBy=new J({deserialize:r=>r.split(" ")});J.group=new J({deserialize:r=>r.split(" ")});J.contextHash=new J({perNode:!0});J.lookAhead=new J({perNode:!0});J.mounted=new J({perNode:!0});var ZS=Object.create(null),ke=class{constructor(e,t,n,o=0){this.name=e,this.props=t,this.id=n,this.flags=o}static define(e){let t=e.props&&e.props.length?Object.create(null):ZS,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),o=new ke(e.name||"",t,e.id,n);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(o)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}}return o}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(J.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let o of n.split(" "))t[o]=e[n];return n=>{for(let o=n.prop(J.group),i=-1;i<(o?o.length:0);i++){let s=t[i<0?n.name:o[i]];if(s)return s}}}};ke.none=new ke("",Object.create(null),0,8);var Kn=class{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let o=null;for(let i of e){let s=i(n);s&&(o||(o=Object.assign({},n.props)),o[s[0].id]=s[1])}t.push(o?new ke(n.name,o,n.id,n.flags):n)}return new Kn(t)}},ds=new WeakMap,sp=new WeakMap,ye;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays"})(ye||(ye={}));var le=class{constructor(e,t,n,o,i){if(this.type=e,this.children=t,this.positions=n,this.length=o,this.props=null,i&&i.length){this.props=Object.create(null);for(let[s,l]of i)this.props[typeof s=="number"?s:s.id]=l}}toString(){let e=this.prop(J.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let o=n.toString();o&&(t&&(t+=","),t+=o)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Pr(this.topNode,e)}cursorAt(e,t=0,n=0){let o=ds.get(this)||this.topNode,i=new Pr(o);return i.moveTo(e,t),ds.set(this,i._tree),i}get topNode(){return new Rt(this,0,0,null)}resolve(e,t=0){let n=Ir(ds.get(this)||this.topNode,e,t,!1);return ds.set(this,n),n}resolveInner(e,t=0){let n=Ir(sp.get(this)||this.topNode,e,t,!0);return sp.set(this,n),n}iterate(e){let{enter:t,leave:n,from:o=0,to:i=this.length}=e,s=e.mode||0,l=(s&ye.IncludeAnonymous)>0;for(let a=this.cursor(s|ye.IncludeAnonymous);;){let c=!1;if(a.from<=i&&a.to>=o&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ja(ke.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,o)=>new le(this.type,t,n,o,this.propValues),e.makeTree||((t,n,o)=>new le(ke.none,t,n,o)))}static build(e){return eC(e)}};le.empty=new le(ke.none,[],[],0);var Wo=class{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Wo(this.buffer,this.index)}},Zt=class{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return ke.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],o=this.set.types[t],i=o.name;if(/\W/.test(i)&&!o.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let s=[];for(;e<n;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,t,n,o,i){let{buffer:s}=this,l=-1;for(let a=e;a!=t&&!(ap(i,o,s[a+1],s[a+2])&&(l=a,n>0));a=s[a+3]);return l}slice(e,t,n){let o=this.buffer,i=new Uint16Array(t-e),s=0;for(let l=e,a=0;l<t;){i[a++]=o[l++],i[a++]=o[l++]-n;let c=i[a++]=o[l++]-n;i[a++]=o[l++]-e,s=Math.max(s,c)}return new Zt(i,s,this.set)}};function ap(r,e,t,n){switch(r){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function cp(r,e){let t=r.childBefore(e);for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(r=t,t=n.prevSibling):t=n}return r}function Ir(r,e,t,n){for(var o;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to<e);){let s=!n&&r instanceof Rt&&r.index<0?null:r.parent;if(!s)return r;r=s}let i=n?0:ye.IgnoreOverlays;if(n)for(let s=r,l=s.parent;l;s=l,l=s.parent)s instanceof Rt&&s.index<0&&((o=l.enter(e,t,i))===null||o===void 0?void 0:o.from)!=s.from&&(r=l);for(;;){let s=r.enter(e,t,i);if(!s)return r;r=s}}var Rt=class{constructor(e,t,n,o){this._tree=e,this.from=t,this.index=n,this._parent=o}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,o,i=0){for(let s=this;;){for(let{children:l,positions:a}=s._tree,c=t>0?l.length:-1;e!=c;e+=t){let u=l[e],h=a[e]+s.from;if(ap(o,n,h,h+u.length)){if(u instanceof Zt){if(i&ye.ExcludeBuffers)continue;let f=u.findChild(0,u.buffer.length,t,n-h,o);if(f>-1)return new Bt(new qa(s,u,e,h),null,f)}else if(i&ye.IncludeAnonymous||!u.type.isAnonymous||ja(u)){let f;if(!(i&ye.IgnoreMounts)&&u.props&&(f=u.prop(J.mounted))&&!f.overlay)return new Rt(f.tree,h,e,s);let d=new Rt(u,h,e,s);return i&ye.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?u.children.length-1:0,t,n,o)}}}if(i&ye.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+t:e=t<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let o;if(!(n&ye.IgnoreOverlays)&&(o=this._tree.prop(J.mounted))&&o.overlay){let i=e-this.from;for(let{from:s,to:l}of o.overlay)if((t>0?s<=i:s<i)&&(t<0?l>=i:l>i))return new Rt(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new Pr(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return Ir(this,e,t,!1)}resolveInner(e,t=0){return Ir(this,e,t,!0)}enterUnfinishedNodesBefore(e){return cp(this,e)}getChild(e,t=null,n=null){let o=ms(this,e,t,n);return o.length?o[0]:null}getChildren(e,t=null,n=null){return ms(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return gs(this,e)}};function ms(r,e,t,n){let o=r.cursor(),i=[];if(!o.firstChild())return i;if(t!=null){for(;!o.type.is(t);)if(!o.nextSibling())return i}for(;;){if(n!=null&&o.type.is(n))return i;if(o.type.is(e)&&i.push(o.node),!o.nextSibling())return n==null?i:[]}}function gs(r,e,t=e.length-1){for(let n=r.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}var qa=class{constructor(e,t,n,o){this.parent=e,this.buffer=t,this.index=n,this.start=o}},Bt=class{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new Bt(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&ye.ExcludeBuffers)return null;let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new Bt(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Bt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Bt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new Pr(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,o=this.index+4,i=n.buffer[this.index+3];if(i>o){let s=n.buffer[this.index+1];e.push(n.slice(o,i,s)),t.push(0)}return new le(this.type,e,t,this.to-this.from)}resolve(e,t=0){return Ir(this,e,t,!1)}resolveInner(e,t=0){return Ir(this,e,t,!0)}enterUnfinishedNodesBefore(e){return cp(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let o=ms(this,e,t,n);return o.length?o[0]:null}getChildren(e,t=null,n=null){return ms(this,e,t,n)}get node(){return this}matchContext(e){return gs(this,e)}},Pr=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Rt)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:o}=this.buffer;return this.type=t||o.set.types[o.buffer[e]],this.from=n+o.buffer[e+1],this.to=n+o.buffer[e+2],!0}yield(e){return e?e instanceof Rt?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:o}=this.buffer,i=o.findChild(this.index+4,o.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&ye.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ye.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ye.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let o=n<0?0:this.stack[n]+4;if(this.index!=o)return this.yieldBuf(t.findChild(o,this.index,-1,0,4))}else{let o=t.buffer[this.index+3];if(o<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(o)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:o}=this;if(o){if(e>0){if(this.index<o.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(o.buffer.buffer[i+3]<this.index)return!1;({index:t,parent:n}=o)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let i=t+e,s=e<0?-1:n._tree.children.length;i!=s;i+=e){let l=n._tree.children[i];if(this.mode&ye.IncludeAnonymous||l instanceof Zt||!l.type.isAnonymous||ja(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let o=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==o){if(o==this.index)return s;t=s,n=i+1;break e}o=this.stack[--i]}for(let o=n;o<this.stack.length;o++)t=new Bt(this.buffer,t,this.stack[o]);return this.bufferNode=new Bt(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let o=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(o=!0)}for(;o&&t&&t(this),o=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,o=!0}}}matchContext(e){if(!this.buffer)return gs(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let o=e.length-1,i=this.stack.length-1;o>=0;i--){if(i<0)return gs(this.node,e,o);let s=n[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[o]&&e[o]!=s.name)return!1;o--}}return!0}};function ja(r){return r.children.some(e=>e instanceof Zt||!e.type.isAnonymous||ja(e))}function eC(r){var e;let{buffer:t,nodeSet:n,maxBufferLength:o=1024,reused:i=[],minRepeatType:s=n.types.length}=r,l=Array.isArray(t)?new Wo(t,t.length):t,a=n.types,c=0,u=0;function h(x,S,b,C,k){let{id:E,start:R,end:N,size:O}=l,M=u;for(;O<0;)if(l.next(),O==-1){let V=i[E];b.push(V),C.push(R-x);return}else if(O==-3){c=E;return}else if(O==-4){u=E;return}else throw new RangeError(`Unrecognized record size: ${O}`);let D=a[E],F,G,A=R-x;if(N-R<=o&&(G=m(l.pos-S,k))){let V=new Uint16Array(G.size-G.skip),B=l.pos-G.size,U=V.length;for(;l.pos>B;)U=g(G.start,V,U);F=new Zt(V,N-G.start,n),A=G.start-x}else{let V=l.pos-O;l.next();let B=[],U=[],X=E>=s?E:-1,ee=0,_e=N;for(;l.pos>V;)X>=0&&l.id==X&&l.size>=0?(l.end<=_e-o&&(d(B,U,R,ee,l.end,_e,X,M),ee=B.length,_e=l.end),l.next()):h(R,V,B,U,X);if(X>=0&&ee>0&&ee<B.length&&d(B,U,R,ee,R,_e,X,M),B.reverse(),U.reverse(),X>-1&&ee>0){let de=f(D);F=Ja(D,B,U,0,B.length,0,N-R,de,de)}else F=p(D,B,U,N-R,M-N)}b.push(F),C.push(A)}function f(x){return(S,b,C)=>{let k=0,E=S.length-1,R,N;if(E>=0&&(R=S[E])instanceof le){if(!E&&R.type==x&&R.length==C)return R;(N=R.prop(J.lookAhead))&&(k=b[E]+R.length+N)}return p(x,S,b,C,k)}}function d(x,S,b,C,k,E,R,N){let O=[],M=[];for(;x.length>C;)O.push(x.pop()),M.push(S.pop()+b-k);x.push(p(n.types[R],O,M,E-k,N-E)),S.push(k-b)}function p(x,S,b,C,k=0,E){if(c){let R=[J.contextHash,c];E=E?[R].concat(E):[R]}if(k>25){let R=[J.lookAhead,k];E=E?[R].concat(E):[R]}return new le(x,S,b,C,E)}function m(x,S){let b=l.fork(),C=0,k=0,E=0,R=b.end-o,N={size:0,start:0,skip:0};e:for(let O=b.pos-x;b.pos>O;){let M=b.size;if(b.id==S&&M>=0){N.size=C,N.start=k,N.skip=E,E+=4,C+=4,b.next();continue}let D=b.pos-M;if(M<0||D<O||b.start<R)break;let F=b.id>=s?4:0,G=b.start;for(b.next();b.pos>D;){if(b.size<0)if(b.size==-3)F+=4;else break e;else b.id>=s&&(F+=4);b.next()}k=G,C+=M,E+=F}return(S<0||C==x)&&(N.size=C,N.start=k,N.skip=E),N.size>4?N:void 0}function g(x,S,b){let{id:C,start:k,end:E,size:R}=l;if(l.next(),R>=0&&C<s){let N=b;if(R>4){let O=l.pos-(R-4);for(;l.pos>O;)b=g(x,S,b)}S[--b]=N,S[--b]=E-x,S[--b]=k-x,S[--b]=C}else R==-3?c=C:R==-4&&(u=C);return b}let y=[],v=[];for(;l.pos>0;)h(r.start||0,r.bufferStart||0,y,v,-1);let w=(e=r.length)!==null&&e!==void 0?e:y.length?v[0]+y[0].length:0;return new le(a[r.topID],y.reverse(),v.reverse(),w)}var lp=new WeakMap;function ps(r,e){if(!r.isAnonymous||e instanceof Zt||e.type!=r)return 1;let t=lp.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=r||!(n instanceof le)){t=1;break}t+=ps(r,n)}lp.set(e,t)}return t}function Ja(r,e,t,n,o,i,s,l,a){let c=0;for(let p=n;p<o;p++)c+=ps(r,e[p]);let u=Math.ceil(c*1.5/8),h=[],f=[];function d(p,m,g,y,v){for(let w=g;w<y;){let x=w,S=m[w],b=ps(r,p[w]);for(w++;w<y;w++){let C=ps(r,p[w]);if(b+C>=u)break;b+=C}if(w==x+1){if(b>u){let C=p[x];d(C.children,C.positions,0,C.children.length,m[x]+v);continue}h.push(p[x])}else{let C=m[w-1]+p[w-1].length-S;h.push(Ja(r,p,m,x,w,S,C,null,a))}f.push(S+v-i)}}return d(e,t,n,o,0),(l||a)(h,f,s)}var Ht=class{constructor(e,t,n,o,i=!1,s=!1){this.from=e,this.to=t,this.tree=n,this.offset=o,this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let o=[new Ht(0,e.length,e,0,!1,n)];for(let i of t)i.to>e.length&&o.push(i);return o}static applyChanges(e,t,n=128){if(!t.length)return e;let o=[],i=1,s=e.length?e[0]:null;for(let l=0,a=0,c=0;;l++){let u=l<t.length?t[l]:null,h=u?u.fromA:1e9;if(h-a>=n)for(;s&&s.from<h;){let f=s;if(a>=f.from||h<=f.to||c){let d=Math.max(f.from,a)-c,p=Math.min(f.to,h)-c;f=d>=p?null:new Ht(d,p,f.tree,f.offset+c,l>0,!!u)}if(f&&o.push(f),s.to>h)break;s=i<e.length?e[i++]:null}if(!u)break;a=u.toA,c=u.toA-u.toB}return o}},Dr=class{startParse(e,t,n){return typeof e=="string"&&(e=new Ka(e)),n=n?n.length?n.map(o=>new zo(o.from,o.to)):[new zo(0,0)]:[new zo(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let o=this.startParse(e,t,n);for(;;){let i=o.advance();if(i)return i}}},Ka=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var GB=new J({perNode:!0});var Ar=class{constructor(e,t,n,o,i,s,l,a,c,u=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=o,this.pos=i,this.score=s,this.buffer=l,this.bufferBase=a,this.curContext=c,this.lookAhead=u,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let o=e.parser.context;return new Ar(e,[],t,n,n,0,[],0,o?new ys(o,o.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,o=e&65535,{parser:i}=this.p,s=i.dynamicPrecedence(o);if(s&&(this.score+=s),n==0){this.pushState(i.getGoto(this.state,o,!0),this.reducePos),o<i.minRepeatTerm&&this.storeNode(o,this.reducePos,this.reducePos,4,!0),this.reduceContext(o,this.reducePos);return}let l=this.stack.length-(n-1)*3-(e&262144?6:0),a=l?this.stack[l-2]:this.p.ranges[0].from,c=this.reducePos-a;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[o])===null||t===void 0)&&t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=c));let u=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-u;if(o<i.minRepeatTerm||e&131072){let f=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(o,a,f,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=i.getGoto(f,o,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(o,a)}storeNode(e,t,n,o=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,l=this.buffer.length;if(l==0&&s.parent&&(l=s.bufferBase-s.parent.bufferBase,s=s.parent),l>0&&s.buffer[l-4]==0&&s.buffer[l-1]>-1){if(t==n)return;if(s.buffer[l-2]>=t){s.buffer[l-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,o);else{let s=this.buffer.length;if(s>0&&this.buffer[s-4]!=0)for(;s>0&&this.buffer[s-2]>n;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,o>4&&(o-=4);this.buffer[s]=e,this.buffer[s+1]=t,this.buffer[s+2]=n,this.buffer[s+3]=o}}shift(e,t,n){let o=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=n,this.shiftContext(t,o),t<=this.p.parser.maxNode&&this.buffer.push(t,o,n,4);else{let i=e,{parser:s}=this.p;(n>this.pos||t<=s.maxNode)&&(this.pos=n,s.stateFlag(i,1)||(this.reducePos=n)),this.pushState(i,o),this.shiftContext(t,o),t<=s.maxNode&&this.buffer.push(t,o,n,4)}}apply(e,t,n){e&65536?this.reduce(e):this.shift(e,t,n)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let o=this.pos;this.reducePos=this.pos=o+e.length,this.pushState(t,o),this.buffer.push(n,o,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),o=e.bufferBase+t;for(;e&&o==e.bufferBase;)e=e.parent;return new Ar(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,o,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Ya(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>4<<1||this.stack.length>=120){let o=[];for(let i=0,s;i<t.length;i+=2)(s=t[i+1])!=this.state&&this.p.parser.hasAction(s,e)&&o.push(t[i],s);if(this.stack.length<120)for(let i=0;o.length<4<<1&&i<t.length;i+=2){let s=t[i+1];o.some((l,a)=>a&1&&l==s)||o.push(t[i],s)}t=o}let n=[];for(let o=0;o<t.length&&n.length<4;o+=2){let i=t[o+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(t[o],this.pos),s.score-=200,n.push(s)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,o=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],o,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;t=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(o,i)=>{if(!t.includes(o))return t.push(o),e.allActions(o,s=>{if(!(s&393216))if(s&65536){let l=(s>>19)-i;if(l>1){let a=s&65535,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],a,!1)>=0)return l<<19|65536|a}}else{let l=n(s,i+1);if(l!=null)return l}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new ys(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},ys=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},up;(function(r){r[r.Insert=200]="Insert",r[r.Delete=190]="Delete",r[r.Reduce=100]="Reduce",r[r.MaxNext=4]="MaxNext",r[r.MaxInsertStackDepth=300]="MaxInsertStackDepth",r[r.DampenInsertStackDepth=120]="DampenInsertStackDepth",r[r.MinBigReduction=2e3]="MinBigReduction"})(up||(up={}));var Ya=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let o=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=o}},Or=class{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Or(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Or(this.stack,this.pos,this.index)}};function $o(r,e=Uint16Array){if(typeof r!="string")return r;let t=null;for(let n=0,o=0;n<r.length;){let i=0;for(;;){let s=r.charCodeAt(n++),l=!1;if(s==126){i=65535;break}s>=92&&s--,s>=34&&s--;let a=s-32;if(a>=46&&(a-=46,l=!0),i+=a,l)break;i*=46}t?t[o++]=i:t=new e(i)}return t}var Lr=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},hp=new Lr,Xa=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=hp,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,o=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!o)return null;let s=this.ranges[--o];i-=n.from-s.to,n=s}for(;t<0?i>n.to:i>=n.to;){if(o==this.ranges.length-1)return null;let s=this.ranges[++o];i+=s.from-n.to,n=s}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,o;if(t>=0&&t<this.chunk.length)n=this.pos+e,o=this.chunk.charCodeAt(t);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(n=i,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)o=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let s=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),o=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),o}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=hp,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let o of this.ranges){if(o.from>=t)break;o.to>e&&(n+=this.input.read(Math.max(o.from,e),Math.min(o.to,t)))}return n}},yn=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;bp(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};yn.prototype.contextual=yn.prototype.fallback=yn.prototype.extend=!1;var Za=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?$o(e):e}token(e,t){let n=e.pos,o=0;for(;;){let i=e.next<0,s=e.resolveOffset(1,1);if(bp(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(i||o++,s==null)break;e.reset(s,e.token)}o&&(e.reset(n,e.token),e.acceptToken(this.elseToken,o))}};Za.prototype.contextual=yn.prototype.fallback=yn.prototype.extend=!1;function bp(r,e,t,n,o,i){let s=0,l=1<<n,{dialect:a}=t.p.parser;e:for(;l&r[s];){let c=r[s+1];for(let d=s+3;d<c;d+=2)if((r[d+1]&l)>0){let p=r[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||nC(p,e.token.value,o,i))){e.acceptToken(p);break}}let u=e.next,h=0,f=r[s+2];if(e.next<0&&f>h&&r[c+f*3-3]==65535&&r[c+f*3-3]==65535){s=r[c+f*3-1];continue e}for(;h<f;){let d=h+f>>1,p=c+d+(d<<1),m=r[p],g=r[p+1]||65536;if(u<m)f=d;else if(u>=g)h=d+1;else{s=r[p+2],e.advance();continue e}}break}}function fp(r,e,t){for(let n=e,o;(o=r[n])!=65535;n++)if(o==t)return n-e;return-1}function nC(r,e,t,n){let o=fp(t,n,e);return o<0||fp(t,n,r)<o}var It=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),Qa=null,dp;(function(r){r[r.Margin=25]="Margin"})(dp||(dp={}));function pp(r,e,t){let n=r.cursor(ye.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(r.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:r.length}}var ec=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?pp(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?pp(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],o=this.index[t];if(o==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[o],s=this.start[t]+n.positions[o];if(s>e)return this.nextStart=s,null;if(i instanceof le){if(s==e){if(s<this.safeFrom)return null;let l=s+i.length;if(l<=this.safeTo){let a=i.prop(J.lookAhead);if(!a||l+a<this.fragment.to)return i}}this.index[t]++,s+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+i.length}}},tc=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Lr)}getActions(e){let t=0,n=null,{parser:o}=e.p,{tokenizers:i}=o,s=o.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let c=0;c<i.length;c++){if(!(1<<c&s))continue;let u=i[c],h=this.tokens[c];if(!(n&&!u.fallback)&&((u.contextual||h.start!=e.pos||h.mask!=s||h.context!=l)&&(this.updateCachedToken(h,u,e),h.mask=s,h.context=l),h.lookAhead>h.end+25&&(a=Math.max(h.lookAhead,a)),h.value!=0)){let f=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!u.extend&&(n=h,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Lr,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Lr,{pos:n,p:o}=e;return t.start=n,t.end=Math.min(n+1,o.stream.end),t.value=n==o.stream.end?o.parser.eofTerm:0,t}updateCachedToken(e,t,n){let o=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(o,e),n),e.value>-1){let{parser:i}=n.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==e.value){let l=i.specializers[s](this.stream.read(e.start,e.end),n);if(l>=0&&n.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(o+1)}putAction(e,t,n,o){for(let i=0;i<o;i+=3)if(this.actions[i]==e)return o;return this.actions[o++]=e,this.actions[o++]=t,this.actions[o++]=n,o}addActions(e,t,n,o){let{state:i}=e,{parser:s}=e.p,{data:l}=s;for(let a=0;a<2;a++)for(let c=s.stateSlot(i,a?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=en(l,c+2);else{o==0&&l[c+1]==2&&(o=this.putAction(en(l,c+2),t,n,o));break}l[c]==t&&(o=this.putAction(en(l,c+1),t,n,o))}return o}},mp;(function(r){r[r.Distance=5]="Distance",r[r.MaxRemainingPerStep=3]="MaxRemainingPerStep",r[r.MinBufferLengthPrune=500]="MinBufferLengthPrune",r[r.ForceReduceLimit=10]="ForceReduceLimit",r[r.CutDepth=15e3]="CutDepth",r[r.CutTo=9e3]="CutTo",r[r.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",r[r.MaxStackCount=12]="MaxStackCount"})(mp||(mp={}));var nc=class{constructor(e,t,n,o){this.parser=e,this.input=t,this.ranges=o,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Xa(t,o),this.tokens=new tc(e,this.stream),this.topTerm=e.top[1];let{from:i}=o[0];this.stacks=[Ar.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new ec(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],o,i;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let l=e[s];for(;;){if(this.tokens.mainToken=null,l.pos>t)n.push(l);else{if(this.advanceStack(l,n,e))continue;{o||(o=[],i=[]),o.push(l);let a=this.tokens.getMainToken(l);i.push(a.value,a.end)}}break}}if(!n.length){let s=o&&rC(o);if(s)return this.stackToTree(s);if(this.parser.strict)throw It&&o&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&o){let s=this.stoppedAt!=null&&o[0].pos>this.stoppedAt?o[0]:this.runRecovery(o,i,n);if(s)return this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(n.length>s)for(n.sort((l,a)=>a.score-l.score);n.length>s;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let s=0;s<n.length-1;s++){let l=n[s];for(let a=s+1;a<n.length;a++){let c=n[a];if(l.sameState(c)||l.buffer.length>500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.buffer.length)>0)n.splice(a--,1);else{n.splice(s--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let s=1;s<n.length;s++)n[s].pos<this.minStackPos&&(this.minStackPos=n[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let o=e.pos,{parser:i}=this,s=It?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&o>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let h=this.fragments.nodeAt(o);h;){let f=this.parser.nodeSet.types[h.type.id]==h.type?i.getGoto(e.state,h.type.id):-1;if(f>-1&&h.length&&(!c||(h.prop(J.contextHash)||0)==u))return e.useNode(h,f),It&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(h.type.id)})`),!0;if(!(h instanceof le)||h.children.length==0||h.positions[0]>0)break;let d=h.children[0];if(d instanceof le&&h.positions[0]==0)h=d;else break}}let l=i.stateSlot(e.state,4);if(l>0)return e.reduce(l),It&&console.log(s+this.stackID(e)+` (via always-reduce ${i.getName(l&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let c=0;c<a.length;){let u=a[c++],h=a[c++],f=a[c++],d=c==a.length||!n,p=d?e:e.split();if(p.apply(u,h,f),It&&console.log(s+this.stackID(p)+` (via ${u&65536?`reduce of ${i.getName(u&65535)}`:"shift"} for ${i.getName(h)} @ ${o}${p==e?"":", split"})`),d)return!0;p.pos>o?t.push(p):n.push(p)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return gp(e,t),!0}}runRecovery(e,t,n){let o=null,i=!1;for(let s=0;s<e.length;s++){let l=e[s],a=t[s<<1],c=t[(s<<1)+1],u=It?this.stackID(l)+" -> ":"";if(l.deadEnd&&(i||(i=!0,l.restart(),It&&console.log(u+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let h=l.split(),f=u;for(let d=0;h.forceReduce()&&d<10&&(It&&console.log(f+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,n));d++)It&&(f=this.stackID(h)+" -> ");for(let d of l.recoverByInsert(a))It&&console.log(u+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,n);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),It&&console.log(u+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),gp(l,n)):(!o||o.score<l.score)&&(o=l)}return o}stackToTree(e){return e.close(),le.build({buffer:Or.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(Qa||(Qa=new WeakMap)).get(e);return t||Qa.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function gp(r,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==r.pos&&n.sameState(r)){e[t].score<r.score&&(e[t]=r);return}}e.push(r)}var rc=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}};var jn=class extends Dr{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let n=Object.keys(e.topRules).map(l=>e.topRules[l][1]),o=[];for(let l=0;l<t.length;l++)o.push([]);function i(l,a,c){o[l].push([a,a.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=J[a]);for(let c=1;c<l.length;){let u=l[c++];if(u>=0)i(u,a,l[c++]);else{let h=l[c+-u];for(let f=-u;f>0;f--)i(l[c++],a,h);c++}}}this.nodeSet=new Kn(t.map((l,a)=>ke.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:o[a],top:n.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let s=$o(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(yp),this.states=$o(e.states,Uint32Array),this.data=$o(e.stateData),this.goto=$o(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new yn(s,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let o=new nc(this,e,t,n);for(let i of this.wrappers)o=i(o,e,t,n);return o}getGoto(e,t,n=!1){let o=this.goto;if(t>=o[0])return-1;for(let i=o[t+1];;){let s=o[i++],l=s&1,a=o[i++];if(l&&n)return a;for(let c=i+(s>>1);i<c;i++)if(o[i]==e)return a;if(l)return-1}}hasAction(e,t){let n=this.data;for(let o=0;o<2;o++)for(let i=this.stateSlot(e,o?2:1),s;;i+=3){if((s=n[i])==65535)if(n[i+1]==1)s=n[i=en(n,i+2)];else{if(n[i+1]==2)return en(n,i+2);break}if(s==t||s==0)return en(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),o=n?t(n):void 0;for(let i=this.stateSlot(e,1);o==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=en(this.data,i+2);else break;o=t(en(this.data,i+1))}return o}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=en(this.data,n+2);else break;if(!(this.data[n+2]&1)){let o=this.data[n+1];t.some((i,s)=>s&1&&i==o)||t.push(this.data[n],o)}}return t}configure(e){let t=Object.assign(Object.create(jn.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let o=e.tokenizers.find(i=>i.from==n);return o?o.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,o)=>{let i=e.specializers.find(l=>l.from==n.external);if(!i)return n;let s=Object.assign(Object.assign({},n),{external:i.to});return t.specializers[o]=yp(s),s})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let i of e.split(" ")){let s=t.indexOf(i);s>=0&&(n[s]=!0)}let o=null;for(let i=0;i<t.length;i++)if(!n[i])for(let s=this.dialects[t[i]],l;(l=this.data[s++])!=65535;)(o||(o=new Uint8Array(this.maxTerm+1)))[l]=1;return new rc(e,n,o)}static deserialize(e){return new jn(e)}};function en(r,e){return r[e]|r[e+1]<<16}function rC(r){let e=null;for(let t of r){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function yp(r){if(r.external){let e=r.extend?1:0;return(t,n)=>r.external(t,n)<<1|e}return r.get}var Uo=jn.deserialize({version:14,states:"%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",stateData:"#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",goto:"#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",nodeNames:"\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:"6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",tokenizers:[0,1],topRules:{Filter:[0,1]},tokenPrec:0});import{isMultiClauseFilter as Go,isMultiValueFilter as oC,isSingleValueFilter as iC}from"@vuu-ui/vuu-utils";var Qe,oc=class{constructor(){te(this,Qe,void 0)}setFilterCombinatorOp(e,t=T(this,Qe)){Go(t)&&t.op===e||z(this,Qe,{op:e,filters:[T(this,Qe)]})}add(e){if(T(this,Qe)===void 0)z(this,Qe,e);else if(Go(T(this,Qe)))T(this,Qe).filters.push(e);else throw Error("Invalid filter passed to FilterExpression")}setColumn(e,t=T(this,Qe)){if(Go(t)){let n=t.filters.at(-1);n&&this.setColumn(e,n)}else t&&(t.column=e)}setOp(e,t=T(this,Qe)){if(Go(t)){let n=t.filters.at(-1);n&&this.setOp(e,n)}else t&&(t.op=e)}setValue(e,t=T(this,Qe)){var n;if(Go(t)){let o=t.filters.at(-1);o&&this.setValue(e,o)}else oC(t)?((n=t.values)!=null||(t.values=[]),t.values.push(e)):iC(t)&&(t.value=e)}toJSON(e=T(this,Qe)){return this.name?{...e,name:this.name}:e}};Qe=new WeakMap;var bs=(r,e)=>{let t=new oc,n=r.cursor();do{let{name:o,from:i,to:s}=n;switch(o){case"ColumnValueExpression":t.add({});break;case"ColumnSetExpression":t.add({op:"in"});break;case"Or":case"And":t.setFilterCombinatorOp(e.substring(i,s));break;case"Column":t.setColumn(e.substring(i,s));break;case"Operator":t.setOp(e.substring(i,s));break;case"String":t.setValue(e.substring(i+1,s-1));break;case"Number":t.setValue(parseFloat(e.substring(i,s)));break;case"True":t.setValue(!0);break;case"False":t.setValue(!1);break;case"FilterName":t.name=e.substring(i,s);break;default:}}while(n.next());return t.toJSON()};var sC=Uo.configure({strict:!0}),Jn=r=>{let e=sC.parse(r);return bs(e,r)};function xs(r,e){switch(e.op){case"in":return lC(r,e);case"=":return aC(r,e);case">":return cC(r,e);case">=":return uC(r,e);case"<":return hC(r,e);case"<=":return fC(r,e);case"starts":return dC(r,e);case"and":return pC(r,e);case"or":return mC(r,e);default:return console.log(`unrecognized filter type ${e.op}`),()=>!0}}var lC=(r,e)=>t=>e.values.indexOf(t[r[e.column]])!==-1,aC=(r,e)=>t=>t[r[e.column]]===e.value,cC=(r,e)=>t=>t[r[e.column]]>e.value,uC=(r,e)=>t=>t[r[e.column]]>=e.value,hC=(r,e)=>t=>t[r[e.column]]<e.value,fC=(r,e)=>t=>t[r[e.column]]<=e.value,dC=(r,e)=>{let t=e.value;if(typeof t!="string")throw Error("string filter applied to value of wrong type");return n=>{let o=n[r[e.column]];if(typeof o!="string")throw Error("string filter applied to value of wrong type");return o.toLowerCase().startsWith(t.toLowerCase())}},pC=(r,e)=>{let t=e.filters.map(n=>xs(r,n));return n=>t.every(o=>o(n))};function mC(r,e){let t=e.filters.map(n=>xs(r,n));return n=>t.some(o=>o(n))}import{buildColumnMap as IC,EventEmitter as PC,getSelectionStatus as DC,KeySet as LC,logger as AC,metadataKeys as OC,NULL_RANGE as Ep,rangeNewItems as NC,resetRange as qo,uuid as Rp}from"@vuu-ui/vuu-utils";var xp=(r,e,t,n,o,i)=>{let s=Qn(o,r),l=r[r.length-1].aggType,a=t.map(c=>o[c]);switch(l){case 1:return wp(i,n,o,r,e,a);case 2:return gC(i,n,o,r,e,a);case 3:return vp(i,o,r,e,a);case 4:return bC(i,n,o,r,e,a);case 5:return xC(i,n,o,r,e,a);case 6:return yC(i,n,o,r,e,a)}};function vp(r,e,t,n,o){let i={},s=Qn(e,t);function l(a){if(Array.isArray(a))return a.length;{let c=0;for(let u in a)c+=1+l(a[u]);return c}}for(let a in r){let c=l(r[a]);i[a]=c}for(let a=0;a<n.length;a++)for(let c in i)n[a][o[0]]===c&&(n[a][s]=i[c]);return console.log("!!!! targetData",n),console.log("!!!! counts",i),i}function Qn(r,e){console.log("!!!! aggregation length",e.length);let t=e[e.length-1].column;return r[t]}function wp(r,e,t,n,o,i){let s={},l=Qn(t,n);function a(c,u,h){if(Array.isArray(c)){let f=0;for(let d of c)f+=Number(u[d][h]);return f}else{let f=0;for(let d in c)f+=a(c[d],u,h);return f}}for(let c in r){console.log(c);let u=Number(a(r[c],e,l));s[c]=u}for(let c=0;c<o.length;c++)for(let u in s)o[c][i[0]]===u&&(o[c][l]=s[u]);return console.log("!!!! targetData",o),console.log("!!!! sums",s),s}function gC(r,e,t,n,o,i){let s={},l=Qn(t,n),a=vp(r,t,n,o,i),c=wp(r,e,t,n,o,i);for(let u in a){let h=0;h=c[u]/a[u],s[u]=h}for(let u=0;u<o.length;u++)for(let h in s)o[u][i[0]]===h&&(o[u][l]=s[h]);return console.log("!!!! targetData",o),console.log("!!!! averages",s),s}function vs(r,e,t){let n=[];if(Array.isArray(r))for(let o of r)n.push(e[o][t]);else for(let o in r)n.push(...vs(r[o],e,t));return n}function yC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=vs(r[a],e,l),u=[...new Set(c)];s[a]=u}for(let a=0;a<o.length;a++)for(let c in s)o[a][i[0]]===c&&(o[a][l]=s[c]);return s}function bC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=vs(r[a],e,l),u=Math.max(...c);s[a]=u}for(let a=0;a<o.length;a++)for(let c in s)o[a][i[0]]===c&&(o[a][l]=s[c]);return s}function xC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=vs(r[a],e,l),u=Math.min(...c);s[a]=u}for(let a=0;a<o.length;a++)for(let c in s)o[a][i[0]]===c&&(o[a][l]=s[c]);return s}import{metadataKeys as vC}from"@vuu-ui/vuu-utils";var{DEPTH:ic,IS_EXPANDED:Sp,KEY:sc}=vC,Cp=(r,e)=>{let t=[];for(let n=0,o=0,i=!1,s=e.length;n<s;n++){let l=e[n],{[ic]:a,[sc]:c}=l;if(c===r){let u=l.slice();for(u[Sp]=!1,t.push(u),o+=1,i=!0;n<s-1&&e[n+1][ic]>a;)n+=1}else if(i){let u=l.slice();u[0]=o,u[1]=o,t.push(u),o+=1}else t.push(l),o+=1}return t},lc=(r,e,t,n,o,i)=>{let s=t.map(l=>n[l]);return Tp(o,s,r,e,void 0,void 0,void 0,i)},Tp=(r,e,t,n=[],o="$root",i=1,s=[],l)=>{let a=Object.keys(r).sort();for(let c of a){let u=s.length,h=`${o}|${c}`,f=[u,u,!1,!1,i,0,h,0];f[e[i-1]]=c,s.push(f),t.includes(h)&&(f[Sp]=!0,Array.isArray(r[c])?wC(s,r[c],n,h,i+1):Tp(r[c],e,t,n,h,i+1,s,l))}for(let c in s)for(let u in s)if(s[c][2]===!1&&l[u]!=null&&s[c][e[0]]===l[u][e[0]]){s[c]=s[c].splice(0,8).concat(l[u].slice(8,l[u].length));break}return s},wC=(r,e,t,n,o)=>{for(let i of e){let s=r.length,l=t[i].slice();l[0]=s,l[1]=s,l[ic]=o,l[sc]=`${n}|${l[sc]}`,r.push(l)}},kp=(r,e,t)=>{let n=e.map(s=>t[s]),o=CC(r,n);return[SC(o,n),o]},SC=(r,e)=>{let n=[],o=0,i=Object.keys(r).sort();for(let s of i){let l=[o,o,!1,!1,1,0,`$root|${s}`,0];l[e[0]]=s,n.push(l),o+=1}return n};function CC(r,e){let t={},n=e.length,o=n-1;for(let i=0,s=r.length;i<s;i++){let l=r[i],a=t,c,u;for(let h=0;h<n;h++){let f=e[h];u=l[f].toString(),c=a[u],c&&h===o?c.push(i):c?a=c:!c&&h<o?a=a[u]={}:c||(a[u]=[i])}}return console.log("!! groups",t),t}var TC=(r,e,[t,n])=>{let o=n==="D"?e[t]:r[t],i=n==="D"?r[t]:e[t];return o===i?0:i===null||o>i?1:-1},kC=r=>r.length===1?MC(r):r.length===2?EC(r):RC(r),MC=([[r,e]])=>(t,n)=>{let o=e==="D"?n[r]:t[r],i=e==="D"?t[r]:n[r];return o>i?1:i>o?-1:0},EC=([[r,e],[t,n]])=>(o,i)=>{let s=e==="D"?i[r]:o[r],l=e==="D"?o[r]:i[r],a=n==="D"?i[t]:o[t],c=n==="D"?o[t]:i[t];return s>l?1:l>s?-1:a>c?1:c>a?-1:0},RC=(r,e=TC)=>(t,n)=>{for(let o of r){let i=e(t,n,o);if(i!==0)return i}return 0},Mp=(r,{sortDefs:e},t)=>{let n=e.map(({column:i,sortType:s})=>[t[i],s]),o=kC(n);return r.slice().sort(o)};var{debug:ht}=AC("ArrayDataSource"),{RENDER_IDX:VC,SELECTED:FC}=OC,BC=(r,e)=>[e,e,!0,!1,1,0,r[0].toString(),0,...r],HC=r=>({columns:r.map(({name:t,serverDataType:n="string"})=>({name:t,serverDataType:n})),key:r[0].name,table:{module:"",table:"Array"}}),_C=(r,e,t)=>{let[n]=r,o=r.slice();return o[VC]=e.keyFor(n),o[FC]=DC(t,n),o},Ko,Pt,Q,Ae,ve,ws,jo,Nr,Ip=class extends PC{constructor({aggregations:t,columnDescriptors:n,data:o,filter:i,groupBy:s,rangeChangeRowset:l="delta",sort:a,title:c,viewport:u}){super();this.status="initialising";this.disabled=!1;this.selectedRows=[];this.suspended=!1;this.lastRangeServed={from:0,to:0};this.openTreeNodes=[];te(this,Ko,[]);te(this,Pt,void 0);te(this,Q,Er);te(this,Ae,void 0);te(this,ve,Ep);te(this,ws,0);te(this,jo,0);te(this,Nr,void 0);this.keys=new LC(T(this,ve));this.processedData=void 0;if(!o||!n)throw Error("ArrayDataSource constructor called without data or without columnDescriptors");this.columnDescriptors=n,z(this,Ko,n.map(h=>h.name)),z(this,Pt,IC(T(this,Ko))),this.rangeChangeRowset=l,this.tableSchema=HC(n),z(this,Ae,o.map(BC)),this.viewport=u||Rp(),z(this,jo,o.length),z(this,Nr,c),this.config={...T(this,Q),aggregations:t||T(this,Q).aggregations,columns:n.map(h=>h.name),filter:i||T(this,Q).filter,groupBy:s||T(this,Q).groupBy,sort:a||T(this,Q).sort},ht==null||ht(`columnMap: ${JSON.stringify(T(this,Pt))}`)}async subscribe({viewport:t=(u=>(u=this.viewport)!=null?u:Rp())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var h;this.clientCallback=c,this.viewport=t,this.status="subscribed",this.lastRangeServed={from:0,to:0},o||n||a||l||s?(i&&z(this,ve,i),this.config={...T(this,Q),aggregations:o||T(this,Q).aggregations,columns:n||T(this,Q).columns,filter:a||T(this,Q).filter,groupBy:l||T(this,Q).groupBy,sort:s||T(this,Q).sort}):((h=this.clientCallback)==null||h.call(this,{...T(this,Q),type:"subscribed",clientViewportId:this.viewport,range:T(this,ve),tableSchema:this.tableSchema}),this.clientCallback({clientViewportId:this.viewport,mode:"size-only",type:"viewport-update",size:T(this,Ae).length}),i?this.range=i:T(this,ve)!==Ep&&this.sendRowsToClient())}unsubscribe(){console.log("unsubscribe noop")}suspend(){return console.log("noop"),this}resume(){return console.log("resume noop"),this}disable(){return console.log("disable noop"),this}enable(){return console.log("enable noop"),this}select(t){ht==null||ht(`select ${JSON.stringify(t)}`),this.selectedRows=t,this.setRange(qo(T(this,ve)),!0)}openTreeNode(t){this.openTreeNodes.push(t),this.processedData=lc(this.openTreeNodes,T(this,Ae),T(this,Q).groupBy,T(this,Pt),this.groupMap,this.processedData),this.setRange(qo(T(this,ve)),!0)}closeTreeNode(t){this.openTreeNodes=this.openTreeNodes.filter(n=>n!==t),this.processedData&&(this.processedData=Cp(t,this.processedData),this.setRange(qo(T(this,ve)),!0))}get data(){return T(this,Ae)}get currentData(){var t;return(t=this.processedData)!=null?t:T(this,Ae)}get config(){return T(this,Q)}set config(t){var n;if(as(T(this,Q),t)){if(t){let o=T(this,Q),i=(n=t==null?void 0:t.filter)!=null&&n.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Jn(t.filter.filter)}}:t;z(this,Q,cs(i));let s;if(Kd(t)){let{filter:l,filterStruct:a=Jn(l)}=t.filter;if(a){let c=xs(T(this,Pt),a);s=T(this,Ae).filter(c)}else throw Error("filter must include filterStruct")}if(jd(t)&&(s=Mp(s!=null?s:T(this,Ae),t.sort,T(this,Pt))),this.openTreeNodes.length>0&&Ha(o,t)&&(T(this,Q).groupBy.length===0?this.openTreeNodes.length=0:console.log("adjust the openTReeNodes groupBy changed ",{originalGroupBy:o.groupBy,newGroupBy:i.groupBy})),qd(t)){let[l,a]=kp(s!=null?s:T(this,Ae),t.groupBy,T(this,Pt));this.groupMap=a,s=l,this.openTreeNodes.length>0&&(s=lc(this.openTreeNodes,T(this,Ae),T(this,Q).groupBy,T(this,Pt),this.groupMap,s))}this.processedData=s==null?void 0:s.map((l,a)=>{let c=l.slice();return c[0]=a,c[1]=a,c})}this.setRange(qo(T(this,ve)),!0),this.emit("config",T(this,Q))}}get selectedRowsCount(){return T(this,ws)}get size(){return T(this,jo)}get range(){return T(this,ve)}set range(t){(t.from!==T(this,ve).from||t.to!==T(this,ve).to)&&this.setRange(t)}setRange(t,n=!1){z(this,ve,t),this.keys.reset(t),this.sendRowsToClient(n)}sendRowsToClient(t=!1){var s,l;let n=this.rangeChangeRowset==="delta"&&!t?NC(this.lastRangeServed,T(this,ve)):T(this,ve),o=(s=this.processedData)!=null?s:T(this,Ae),i=o.slice(n.from,n.to).map(a=>_C(a,this.keys,this.selectedRows));(l=this.clientCallback)==null||l.call(this,{clientViewportId:this.viewport,mode:"batch",rows:i,size:o.length,type:"viewport-update"}),this.lastRangeServed=T(this,ve)}get columns(){return T(this,Q).columns}set columns(t){this.config={...T(this,Q),columns:t}}get aggregations(){return T(this,Q).aggregations}set aggregations(t){var i;z(this,Q,{...T(this,Q),aggregations:t});let n=(i=this.processedData)!=null?i:T(this,Ae),o=T(this,Ae);xp(t,n,T(this,Q).groupBy,o,T(this,Pt),this.groupMap),this.setRange(qo(T(this,ve)),!0),this.emit("config",T(this,Q))}get sort(){return T(this,Q).sort}set sort(t){console.log("set sort",{sort:t}),ht==null||ht(`sort ${JSON.stringify(t)}`),this.config={...T(this,Q),sort:t}}get filter(){return T(this,Q).filter}set filter(t){ht==null||ht(`filter ${JSON.stringify(t)}`),this.config={...T(this,Q),filter:t}}get groupBy(){return T(this,Q).groupBy}set groupBy(t){this.config={...T(this,Q),groupBy:t}}get title(){return T(this,Nr)}set title(t){z(this,Nr,t)}get _clientCallback(){return this.clientCallback}createLink({parentVpId:t,link:{fromColumn:n,toColumn:o}}){console.log("create link",{parentVpId:t,fromColumn:n,toColumn:o})}removeLink(){console.log("remove link")}findRow(t){let n=T(this,Ae)[t];if(n)return n;throw`no row found for key ${t}`}updateRow(t,n,o){let i=this.findRow(parseInt(t));console.log({row:i,colName:n,value:o})}applyEdit(t,n,o){return console.log(`ArrayDataSource applyEdit ${t} ${n} ${o}`),!0}async menuRpcCall(t){return new Promise(n=>{let{type:o}=t;switch(o){case"VP_EDIT_CELL_RPC":{let{rowKey:i,field:s,value:l}=t;try{this.updateRow(i,s,l),n(void 0)}catch(a){n({error:String(a),type:"VP_EDIT_RPC_REJECT"})}}break;default:n(void 0)}})}};Ko=new WeakMap,Pt=new WeakMap,Q=new WeakMap,Ae=new WeakMap,ve=new WeakMap,ws=new WeakMap,jo=new WeakMap,Nr=new WeakMap;import{EventEmitter as zC,isSelected as WC,jsonToDataSourceRows as $C,KeySet as UC,metadataKeys as GC,uuid as Pp}from"@vuu-ui/vuu-utils";var qC={columns:[],key:"",table:{module:"",table:""}},{DEPTH:Vr,IDX:Dp,IS_EXPANDED:KC,IS_LEAF:jC,KEY:Vp,SELECTED:Lp}=GC,Ap=(r,e)=>{let[t]=r,n=r.slice();return n[1]=e.keyFor(t),n},bn,ft,Ye,xn,vn,_t,Ss,Cs,wn,Fr,Op=class extends zC{constructor({aggregations:t,data:n,filter:o,groupBy:i,sort:s,title:l,viewport:a}){super();this.status="initialising";this.expandedRows=new Set;this.visibleRows=[];te(this,bn,[]);te(this,ft,Er);te(this,Ye,void 0);te(this,xn,{filter:""});te(this,vn,[]);te(this,_t,{from:0,to:0});te(this,Ss,0);te(this,Cs,0);te(this,wn,{sortDefs:[]});te(this,Fr,void 0);this.keys=new UC(T(this,_t));if(!n)throw Error("JsonDataSource constructor called without data");[this.columnDescriptors,Nh(this,Ye)._]=$C(n),this.visibleRows=T(this,Ye).filter(c=>c[Vr]===0).map((c,u)=>[u,u].concat(c.slice(2))),this.viewport=a||Pp(),t&&z(this,bn,t),this.columnDescriptors&&z(this,ft,{...T(this,ft),columns:this.columnDescriptors.map(c=>c.name)}),o&&z(this,xn,o),i&&z(this,vn,i),s&&z(this,wn,s),z(this,Fr,l)}async subscribe({viewport:t=(u=>(u=this.viewport)!=null?u:Pp())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var h;this.clientCallback=c,console.log(`subscribe range ${i==null?void 0:i.from} ${i==null?void 0:i.to}`),o&&z(this,bn,o),n&&z(this,ft,{...T(this,ft),columns:n}),a&&z(this,xn,a),l&&z(this,vn,l),i&&z(this,_t,i),s&&z(this,wn,s),this.status==="initialising"&&(this.viewport=t,this.status="subscribed",(h=this.clientCallback)==null||h.call(this,{aggregations:T(this,bn),type:"subscribed",clientViewportId:this.viewport,columns:T(this,ft).columns,filter:T(this,xn),groupBy:T(this,vn),range:T(this,_t),sort:T(this,wn),tableSchema:qC}),this.clientCallback({clientViewportId:this.viewport,mode:"size-only",type:"viewport-update",size:this.visibleRows.length}))}unsubscribe(){console.log("noop")}suspend(){return console.log("noop"),this}resume(){return console.log("noop"),this}disable(){return console.log("noop"),this}enable(){return console.log("noop"),this}select(t){var o;let n=[];for(let i of T(this,Ye)){let{[Dp]:s,[Lp]:l}=i,a=l===1,c=WC(t,s);if(c!==a){let u=i.slice();u[Lp]=c?1:0,T(this,Ye)[s]=u,n.push(u)}}n.length>0&&((o=this.clientCallback)==null||o.call(this,{clientViewportId:this.viewport,mode:"update",type:"viewport-update",rows:n}))}openTreeNode(t){var i;this.expandedRows.add(t),this.visibleRows=Np(T(this,Ye),this.expandedRows);let{from:n,to:o}=T(this,_t);(i=this.clientCallback)==null||i.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(n,o).map(s=>Ap(s,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}closeTreeNode(t,n=!1){if(this.expandedRows.delete(t),n)for(let o of this.expandedRows.keys())o.startsWith(t)&&this.expandedRows.delete(o);this.visibleRows=Np(T(this,Ye),this.expandedRows),this.sendRowsToClient()}get config(){return T(this,ft)}get selectedRowsCount(){return T(this,Ss)}get size(){return T(this,Cs)}get range(){return T(this,_t)}set range(t){z(this,_t,t),this.keys.reset(t),requestAnimationFrame(()=>{this.sendRowsToClient()})}sendRowsToClient(){var o;let{from:t,to:n}=T(this,_t);(o=this.clientCallback)==null||o.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(t,n).map(i=>Ap(i,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}get columns(){return T(this,ft).columns}set columns(t){z(this,ft,{...T(this,ft),columns:t})}get aggregations(){return T(this,bn)}set aggregations(t){z(this,bn,t)}get sort(){return T(this,wn)}set sort(t){z(this,wn,t)}get filter(){return T(this,xn)}set filter(t){z(this,xn,t)}get groupBy(){return T(this,vn)}set groupBy(t){z(this,vn,t)}get title(){return T(this,Fr)}set title(t){z(this,Fr,t)}createLink({parentVpId:t,link:{fromColumn:n,toColumn:o}}){console.log("create link",{parentVpId:t,fromColumn:n,toColumn:o})}removeLink(){console.log("remove link")}async menuRpcCall(t){console.log("rmenuRpcCall",{rpcRequest:t})}applyEdit(t,n,o){return console.log(`ArrayDataSource applyEdit ${t} ${n} ${o}`),!0}getChildRows(t){let n=T(this,Ye).find(o=>o[Vp]===t);if(n){let{[Dp]:o,[Vr]:i}=n,s=o+1,l=[];do{let{[Vr]:a}=T(this,Ye)[s];if(a===i+1)l.push(T(this,Ye)[s]);else if(a<=i)break;s+=1}while(s<T(this,Ye).length);return l}else console.warn(`JsonDataSource getChildRows row not found for key ${t}`);return[]}getRowsAtDepth(t,n=!0){return(n?this.visibleRows:T(this,Ye)).filter(i=>i[Vr]===t)}};bn=new WeakMap,ft=new WeakMap,Ye=new WeakMap,xn=new WeakMap,vn=new WeakMap,_t=new WeakMap,Ss=new WeakMap,Cs=new WeakMap,wn=new WeakMap,Fr=new WeakMap;function Np(r,e){let t=[],n={value:0};for(let o=0;o<r.length;o++){let i=r[o],{[Vr]:s,[Vp]:l,[jC]:a}=i,c=e.has(l);if(t.push(JC(i,n,c)),!a&&!c)do o+=1;while(o<r.length-1&&r[o+1][Vr]>s)}return t}var JC=(r,e,t)=>{let n=r.slice();return n[0]=e.value,n[1]=e.value,t&&(n[KC]=!0),e.value+=1,n};import{debounce as Fp,EventEmitter as QC,itemsOrOrderChanged as YC,logger as XC,throttle as ZC,uuid as eT}from"@vuu-ui/vuu-utils";var{info:Ue}=XC("RemoteDataSource"),W,Ts,Br,tn,Jo,Hr,Yn,ac=class extends QC{constructor({bufferSize:t=100,aggregations:n,columns:o,filter:i,groupBy:s,sort:l,table:a,title:c,viewport:u,visualLink:h}){super();this.server=null;this.status="initialising";te(this,W,Er);te(this,Ts,[]);te(this,Br,"throttle");te(this,tn,{from:0,to:0});te(this,Jo,0);te(this,Hr,0);te(this,Yn,void 0);this.handleMessageFromServer=t=>{var n,o;if(t.type==="subscribed")this.status="subscribed",(n=this.clientCallback)==null||n.call(this,t);else if(t.type==="disabled")this.status="disabled";else if(t.type==="enabled")this.status="enabled";else{if(Qd(t))return;t.type==="debounce-begin"?this.optimize="debounce":(t.type==="viewport-update"&&t.size!==void 0&&t.size!==T(this,Hr)&&(z(this,Hr,t.size),this.emit("resize",t.size)),this.configChangePending&&this.setConfigPending(),(o=this.clientCallback)==null||o.call(this,t),this.optimize==="debounce"&&this.revertDebounce())}};this.revertDebounce=Fp(()=>{this.optimize="throttle"},100);this.rawRangeRequest=t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})};this.debounceRangeRequest=Fp(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},50);this.throttleRangeRequest=ZC(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},80);if(!a)throw Error("RemoteDataSource constructor called without table");this.bufferSize=t,this.table=a,this.viewport=u,z(this,W,{...T(this,W),aggregations:n||T(this,W).aggregations,columns:o||T(this,W).columns,filter:i||T(this,W).filter,groupBy:s||T(this,W).groupBy,sort:l||T(this,W).sort,visualLink:h||T(this,W).visualLink}),z(this,Yn,c),this.rangeRequest=this.throttleRangeRequest}async subscribe({viewport:t=(u=>(u=this.viewport)!=null?u:eT())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var f;if(this.clientCallback=c,(o||n||a||l||s)&&z(this,W,{...T(this,W),aggregations:o||T(this,W).aggregations,columns:n||T(this,W).columns,filter:a||T(this,W).filter,groupBy:l||T(this,W).groupBy,sort:s||T(this,W).sort}),i&&z(this,tn,i),this.status!=="initialising")return;this.status="subscribing",this.viewport=t,this.server=await Ga();let{bufferSize:h}=this;(f=this.server)==null||f.subscribe({...T(this,W),bufferSize:h,viewport:t,table:this.table,range:T(this,tn),title:T(this,Yn)},this.handleMessageFromServer)}unsubscribe(){var t,n;Ue==null||Ue(`unsubscribe #${this.viewport}`),this.viewport&&((t=this.server)==null||t.unsubscribe(this.viewport)),(n=this.server)==null||n.destroy(this.viewport),this.removeAllListeners()}suspend(){var t;return Ue==null||Ue(`suspend #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status="suspended",(t=this.server)==null||t.send({type:"suspend",viewport:this.viewport})),this}resume(){var t;return Ue==null||Ue(`resume #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status==="disabled"||this.status==="disabling"?this.enable():this.status==="suspended"&&((t=this.server)==null||t.send({type:"resume",viewport:this.viewport}),this.status="subscribed")),this}disable(){var t;return Ue==null||Ue(`disable #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status="disabling",(t=this.server)==null||t.send({viewport:this.viewport,type:"disable"})),this}enable(){var t;return Ue==null||Ue(`enable #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status==="disabled"||this.status==="disabling")&&(this.status="enabling",(t=this.server)==null||t.send({viewport:this.viewport,type:"enable"})),this}select(t){var n;z(this,Jo,t.length),this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"select",selected:t}))}openTreeNode(t){var n;this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"openTreeNode",key:t}))}closeTreeNode(t){var n;this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"closeTreeNode",key:t}))}get optimize(){return T(this,Br)}set optimize(t){if(t!==T(this,Br)){switch(z(this,Br,t),t){case"none":this.rangeRequest=this.rawRangeRequest;break;case"debounce":this.rangeRequest=this.debounceRangeRequest;break;case"throttle":this.rangeRequest=this.throttleRangeRequest;break}this.emit("optimize",t)}}get selectedRowsCount(){return T(this,Jo)}get size(){return T(this,Hr)}get range(){return T(this,tn)}set range(t){(t.from!==T(this,tn).from||t.to!==T(this,tn).to)&&(z(this,tn,t),this.rangeRequest(t))}get config(){return T(this,W)}set config(t){var n,o;if(as(T(this,W),t)&&t){let i=(n=t==null?void 0:t.filter)!=null&&n.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Jn(t.filter.filter)}}:t;z(this,W,cs(i)),T(this,W)&&this.viewport&&this.server&&t&&((o=this.server)==null||o.send({viewport:this.viewport,type:"config",config:T(this,W)})),this.emit("config",T(this,W))}}get columns(){return T(this,W).columns}set columns(t){if(z(this,W,{...T(this,W),columns:t}),this.viewport){let n={viewport:this.viewport,type:"setColumns",columns:t};this.server&&this.server.send(n)}this.emit("config",T(this,W))}get aggregations(){return T(this,W).aggregations}set aggregations(t){var n;z(this,W,{...T(this,W),aggregations:t}),this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"aggregate",aggregations:t})),this.emit("config",T(this,W))}get sort(){return T(this,W).sort}set sort(t){if(z(this,W,{...T(this,W),sort:t}),this.viewport){let n={viewport:this.viewport,type:"sort",sort:t};this.server&&this.server.send(n)}this.emit("config",T(this,W))}get filter(){return T(this,W).filter}set filter(t){if(z(this,W,{...T(this,W),filter:t}),this.viewport){let n={viewport:this.viewport,type:"filter",filter:t};this.server&&this.server.send(n)}this.emit("config",T(this,W))}get groupBy(){return T(this,W).groupBy}set groupBy(t){var n;if(YC(this.groupBy,t)){let o=T(this,Ts).length>0;if(z(this,W,{...T(this,W),groupBy:t}),this.viewport){let i={viewport:this.viewport,type:"groupBy",groupBy:T(this,W).groupBy};this.server&&this.server.send(i)}!o&&t.length>0&&this.viewport&&((n=this.clientCallback)==null||n.call(this,{clientViewportId:this.viewport,mode:"batch",type:"viewport-update",size:0,rows:[]})),this.emit("config",T(this,W)),this.setConfigPending({groupBy:t})}}get title(){return T(this,Yn)}set title(t){var n;z(this,Yn,t),this.viewport&&t&&((n=this.server)==null||n.send({type:"setTitle",title:t,viewport:this.viewport}))}get visualLink(){return T(this,W).visualLink}set visualLink(t){var n,o;if(z(this,W,{...T(this,W),visualLink:t}),t){let{parentClientVpId:i,link:{fromColumn:s,toColumn:l}}=t;this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"createLink",parentClientVpId:i,parentColumnName:l,childColumnName:s}))}else this.viewport&&((o=this.server)==null||o.send({type:"removeLink",viewport:this.viewport}));this.emit("config",T(this,W))}setConfigPending(t){let n=this.configChangePending;this.configChangePending=t,t!==void 0?this.emit("config",t,!1):this.emit("config",n,!0)}async menuRpcCall(t){var n;if(this.viewport)return(n=this.server)==null?void 0:n.rpcCall({vpId:this.viewport,...t})}applyEdit(t,n,o){return console.log(`ArrayDataSource applyEdit ${t} ${n} ${o}`),!0}};W=new WeakMap,Ts=new WeakMap,Br=new WeakMap,tn=new WeakMap,Jo=new WeakMap,Hr=new WeakMap,Yn=new WeakMap;import{useCallback as y4,useEffect as b4,useState as x4}from"react";import{useCallback as tT}from"react";var Bp={type:"RPC_CALL",service:"TypeAheadRpcHandler"};var cc=()=>tT(async e=>{let t=e.length===2?{method:"getUniqueFieldValues",params:e,...Bp}:{method:"getUniqueFieldValuesStartingWith",params:e,...Bp};return await ip(t)},[]);import{getRowRecord as I4,isGroupMenuItemDescriptor as P4,metadataKeys as nT}from"@vuu-ui/vuu-utils";import{useCallback as L4}from"react";var{KEY:A4}=nT;import{useCallback as V4,useEffect as F4,useState as B4}from"react";import{ExpandoInput as iT}from"@vuu-ui/vuu-ui-controls";import{jsx as Ms}from"react/jsx-runtime";var sT=rT(function({InputProps:e={},className:t,column:n,onInputComplete:o,operator:i,suggestionProvider:s=cc,table:l,value:a},c){let[u,h]=_p(a!=null?a:""),[f,d]=_p([]),p=s(),m=ks((x,S)=>o(S),[o]),g=ks((x,S)=>{S.length===1?o(S[0]):S.length>1&&o(S)},[o]);Hp(()=>{},[n]),Hp(()=>{if(l){let x=u?[l,n.name,u]:[l,n.name];p(x).then(S=>{d(S)}).catch(S=>{console.error("Error getting suggsetions",S)})}},[l,n,u,p]);let y=ks(x=>{let{value:S}=x.target;h(S)},[]),v=oT(()=>{if(i==="starts"||i==="ends"){let{inputProps:x,...S}=e;return{...S,inputProps:{...x,onKeyDown:b=>{var C;b.key==="Enter"&&u!==""?(b.stopPropagation(),b.preventDefault(),o(u)):(C=x==null?void 0:x.onKeyDown)==null||C.call(x,b)}}}}else return e},[e,o,i,u]);return ks(()=>{switch(i){case"in":return Ms(Ho,{InputProps:v,className:t,initialHighlightedIndex:0,source:f,onInputChange:y,onSelectionChange:g,ref:c,selectionStrategy:"multiple",value:a});case"starts":return Ms(Ho,{InputProps:v,ListProps:{className:"vuuIllustrationsOnly",disabled:!0},allowFreeText:!0,className:t,initialHighlightedIndex:0,source:f,onInputChange:y,onSelectionChange:m,ref:c,value:a});case"ends":return Ms(iT,{...v,className:t,value:u,ref:c,onChange:y});default:return Ms(Ho,{InputProps:v,className:t,initialHighlightedIndex:0,source:f,title:"value",onInputChange:y,onSelectionChange:m,ref:c,value:a})}},[i,v,t,f,y,g,c,a,m,u])()});import{isMultiValueFilter as d_,isSingleValueFilter as p_,isValidFilterClauseOp as m_}from"@vuu-ui/vuu-utils";import{useCallback as v_,useEffect as w_,useMemo as S_,useRef as C_,useState as T_}from"react";import{jsx as q_,jsxs as K_}from"react/jsx-runtime";import{EditableLabel as N3}from"@vuu-ui/vuu-ui-controls";import{filterAsQuery as B3,isMultiClauseFilter as H3}from"@vuu-ui/vuu-utils";import z3 from"classnames";import{useCallback as U3,useRef as G3}from"react";import{PopupMenu as l3}from"@vuu-ui/vuu-popups";import{useMemo as c3}from"react";import h3 from"classnames";import{jsx as g3}from"react/jsx-runtime";import{extractFilterForColumn as w3,isAndFilter as S3,isCompleteFilter as C3,isInFilter as T3,isMultiClauseFilter as k3,isMultiValueFilter as M3,isOrFilter as E3,isSingleValueFilter as R3,partition as I3}from"@vuu-ui/vuu-utils";import{jsx as Q3,jsxs as Y3}from"react/jsx-runtime";import{dispatchMouseEvent as uz,filterAsQuery as hz}from"@vuu-ui/vuu-utils";import{useCallback as mz,useEffect as gz,useMemo as yz,useRef as bz,useState as xz}from"react";import{useControlled as nz}from"@vuu-ui/vuu-ui-controls";import{useCallback as oz}from"react";import{jsx as Jz,jsxs as Qz}from"react/jsx-runtime";import{createElement as jz}from"react";import{Button as K5}from"@salt-ds/core";var Y=class{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){let o=[];return this.decompose(0,e,o,2),n.length&&n.decompose(0,n.length,o,3),this.decompose(t,this.length,o,1),dt.from(o,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let n=[];return this.decompose(e,t,n,0),dt.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),o=new er(this),i=new er(e);for(let s=t,l=t;;){if(o.next(s),i.next(s),s=0,o.lineBreak!=i.lineBreak||o.done!=i.done||o.value!=i.value)return!1;if(l+=o.value.length,o.done||l>=n)return!0}}iter(e=1){return new er(this,e)}iterRange(e,t=this.length){return new Ps(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let o=this.line(e).from;n=this.iterRange(o,Math.max(o,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ds(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Y.empty:e.length<=32?new ce(e):dt.from(ce.split(e,[]))}},ce=class extends Y{constructor(e,t=cT(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,o){for(let i=0;;i++){let s=this.text[i],l=o+s.length;if((t?n:l)>=e)return new hc(o,l,n,s);o=l+1,n++}}decompose(e,t,n,o){let i=e<=0&&t>=this.length?this:new ce(zp(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(o&1){let s=n.pop(),l=Is(i.text,s.text.slice(),0,i.length);if(l.length<=32)n.push(new ce(l,s.length+i.length));else{let a=l.length>>1;n.push(new ce(l.slice(0,a)),new ce(l.slice(a)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof ce))return super.replace(e,t,n);let o=Is(this.text,Is(n.text,zp(this.text,0,e)),t),i=this.length+n.length-(t-e);return o.length<=32?new ce(o,i):dt.from(ce.split(o,[]),i)}sliceString(e,t=this.length,n=`
17
+ `,document.body.insertBefore(e,r)}}var So=class{constructor(){this.currentPath=null;this.tabMode=null;ov()}prepare(e,t="full-view"){document.body.classList.add("drawing"),this.currentPath=null,this.tabMode=t;let n=this.getPoints(0,0,0,0),o=af(n),i=document.getElementById("vuu-drop-outline");i==null||i.setAttribute("d",o),this.currentPath=o}clear(){wo=null,Bi(),document.body.classList.remove("drawing"),ha.hidePopup()}get hoverDropTarget(){return wo}getPoints(e,t,n,o,i=0,s=0,l=0){let a=this.tabMode==="tab-only";if(s===0)return[[e,t+l],[e,t+l],[e,t],[e+s,t],[e+s,t],[e+n,t],[e+n,t+o],[e,t+o]];if(a){let c=i;return[[c,t],[c,t],[c+s,t],[c+s,t],[c+s,t+l],[c+s,t+l],[c,t+l],[c,t+l]]}else return i===0?[[e,t+l],[e,t+l],[e,t],[e+s,t],[e+s,t+l],[e+n,t+l],[e+n,t+o],[e,t+o]]:[[e,t+l],[e+i,t+l],[e+i,t],[e+i,t],[e+i,t+l],[e+n,t+l],[e+n,t+o],[e,t+o]]}draw(e,t){let o=fa;if(wo!==null)this.drawTarget(wo);else if(fa=e.nextDropTarget!=null,e.pos.tab?iv(e):Rt&&Bi(),this.drawTarget(e,t),fa){let[i,s,l]=sf(e);{let a=sv(lf,{dropTarget:e,onHover:ev,orientation:l});ha.showPopup({left:i,top:s,component:a})}}else ha.hidePopup()}drawTarget(e,t){let o=e.getTargetDropOutline(6,t);if(o){let{l:i,t:s,r:l,b:a,tabLeft:c,tabWidth:u,tabHeight:h,guideLines:f}=o,d=l-i,p=a-s;if(this.currentPath){let w=document.getElementById("vuu-drop-outline");w==null||w.setAttribute("d",this.currentPath)}let m=this.getPoints(i,s,d,p,c,u,h),y=af(m),g=document.getElementById("hw-drop-outline-animate");g==null||g.setAttribute("to",y),g==null||g.beginElement(),this.currentPath=y;let v=document.getElementById("hw-drop-guides");v==null||v.setAttribute("d",rv(f))}}},cf="transition:margin-left .4s ease-out;margin-left: 63px",uf="transition:margin-left .4s ease-out;margin-left: 0px";function iv(r){var l,a;let{AFTER:e,BEFORE:t}=vo,{clientRect:{Stack:n},pos:{tab:o}}=r,{id:i}=r.component.props,s=null;if(n&&o&&o.positionRelativeToTab!==e){let c=o.positionRelativeToTab===t?1:2,u=`:scope .hwTabstrip > .hwTabstrip-inner > .hwTab:nth-child(${o.index+c})`;s=(l=document.getElementById(i))==null?void 0:l.querySelector(u),s?(Rt===null||Rt!==s)&&(s.style.cssText=cf,Rt&&(Rt.style.cssText=uf),Rt=s):Bi()}else if((o==null?void 0:o.positionRelativeToTab)===t){if(Rt===null){let c=".vuuHeader-title";s=(a=document.getElementById(i))==null?void 0:a.querySelector(c),s.style.cssText=cf,Rt=s}}else Bi()}function Bi(){Rt&&(Rt.style.cssText=uf,Rt=null)}var Xt,Co,mn,ff,df,_n,Hi,zn=null,pa,pf,zi,mf,da,_i=null,lv=3,Wi=new So,hf=.4;function av(r,e){return e?Te(r,e):Yt(r,t=>t.dropTarget)}var ma={handleMousedown(r,e,t={}){Xt=e,pf=t,ff=r.clientX,df=r.clientY,da=t.dragThreshold===void 0?lv:t.dragThreshold,da===0?Xt(r,0,0):(window.addEventListener("mousemove",$i,!1),window.addEventListener("mouseup",Ui,!1),_i=window.setTimeout(()=>{window.removeEventListener("mousemove",$i,!1),window.removeEventListener("mouseup",Ui,!1),Xt==null||Xt(r,0,0)},500)),r.preventDefault()},initDrag(r,e,{top:t,left:n,right:o,bottom:i},s,l,a,c){return{drag:Co,drop:mn}=l,cv(r,e,{top:t,left:n,right:o,bottom:i},s,a,c)}};function $i(r){let n=r.clientX-ff,o=r.clientY-df;Math.max(Math.abs(n),Math.abs(o))>da&&(window.removeEventListener("mousemove",$i,!1),window.removeEventListener("mouseup",Ui,!1),Xt==null||Xt(r,n,o),Xt=null)}function Ui(){_i&&(window.clearTimeout(_i),_i=null),window.removeEventListener("mousemove",$i,!1),window.removeEventListener("mouseup",Ui,!1)}function cv(r,e,t,n,o,i){_n=av(r,e);let{"data-path":s,path:l=s}=_(_n);i&&(pa=i.map(f=>Yt(r,d=>d.id===f)).map(f=>f.props.path)),zi=Cr.measure(_n,i);let a=zi[l];Hi=new Fi(a,n.x,n.y,t,o);let c=Math.round(Hi.x.mousePct*100),u=Math.round(Hi.y.mousePct*100);return window.addEventListener("mousemove",gf,!1),window.addEventListener("mouseup",bf,!1),window.addEventListener("keydown",yf,!1),mf=!1,Wi.prepare(t,"tab-only"),pf.DoNotTransform?"transform:none":`transform:scale(${hf},${hf});transform-origin:${c}% ${u}%;`}function gf(r){let e=r.clientX,t=r.clientY,n=Hi,o=zn,i,s,l;n.update("x",e)&&(s=n.x.pos),n.update("y",t)&&(l=n.y.pos),s===void 0&&l===void 0||Co==null||Co(s,l),!(mf||_n===void 0)&&(n.inBounds()?i=ca(e,t,_n,zi,n.hasIntrinsicSize(),pa):i=ca(n.dropX(),n.dropY(),_n,zi),o&&(i==null||i.box!==o.box)&&(zn=null),i&&(Wi.draw(i,n),zn=i))}function yf(r){r.key==="Escape"&&(zn=null,xf())}function bf(){xf()}function xf(){if(zn){let r=Wi.hoverDropTarget||pn.getActiveDropTarget(zn);mn==null||mn(r),zn=null}else mn==null||mn();Co=null,mn=null,_n=void 0,Wi.clear(),pa=void 0,window.removeEventListener("mousemove",gf,!1),window.removeEventListener("mouseup",bf,!1),window.removeEventListener("keydown",yf,!1)}import uv from"classnames";import{forwardRef as hv}from"react";import{jsx as fv}from"react/jsx-runtime";var To=hv(function({children:e,className:t,dropTarget:n,resizeable:o,...i},s){let l=uv("DraggableLayout",t);return fv("div",{className:l,ref:s,...i,children:e})}),vf="DraggableLayout";To.displayName=vf;ge(vf,To,"container");import{useForkRef as Nv}from"@salt-ds/core";import Vv from"classnames";import{forwardRef as Fv}from"react";import{getUniqueId as Rv}from"@vuu-ui/vuu-utils";import Io,{useCallback as Qi,useMemo as Lf,useRef as Yi,useState as Iv}from"react";import dv from"classnames";import{jsx as pv}from"react/jsx-runtime";var wf="vuuPlaceholder",Gi=({className:r,closeable:e,flexFill:t,resizeable:n,shim:o,...i})=>pv("div",{className:dv(wf,r,{[`${wf}-shim`]:o}),...i,"data-placeholder":!0,"data-resizeable":!0});Gi.displayName="Placeholder";ge("Placeholder",Gi);import mv from"classnames";import gv,{useCallback as ko,useRef as qi,useState as yv}from"react";import{jsx as Sf}from"react/jsx-runtime";var Ki="vuuSplitter",Cf=gv.memo(function({column:e,index:t,onDrag:n,onDragEnd:o,onDragStart:i,style:s}){let l=qi(),a=qi(null),c=qi(0),[u,h]=yv(!1),f=ko(({key:b,shiftKey:C})=>{let k=C?10:1;e&&b==="ArrowDown"?n(t,k):e&&b==="ArrowUp"||!e&&b==="ArrowLeft"?n(t,-k):!e&&b==="ArrowRight"&&n(t,k)},[e,t,n]),d=ko(b=>{let{key:C}=b;(e&&(C==="ArrowUp"||C==="ArrowDown")||!e&&(C==="ArrowLeft"||C==="ArrowRight"))&&(i(t),f(b),p.current=f)},[e,f,t,i]),p=qi(d),m=b=>p.current(b),y=ko(b=>{l.current=!0;let C=b[e?"clientY":"clientX"],k=C-c.current;C&&C!==c.current&&n(t,k),c.current=C},[e,t,n]),g=ko(()=>{var b;window.removeEventListener("mousemove",y,!1),window.removeEventListener("mouseup",g,!1),o(),h(!1),(b=a.current)==null||b.focus()},[y,o,h]),v=ko(b=>{c.current=e?b.clientY:b.clientX,i(t),window.addEventListener("mousemove",y,!1),window.addEventListener("mouseup",g,!1),b.preventDefault(),h(!0)},[e,y,g,t,i,h]),w=()=>{var b;l.current?l.current=!1:(b=a.current)==null||b.focus()},x=()=>{p.current=d},S=mv(Ki,{[`${Ki}-active`]:u,[`${Ki}-column`]:e});return Sf("div",{className:S,"data-splitter":!0,ref:a,role:"separator",style:s,onBlur:x,onClick:w,onKeyDown:m,onMouseDown:v,tabIndex:0,children:Sf("div",{className:`${Ki}-grab-zone`})})});import{uuid as Tf}from"@vuu-ui/vuu-utils";import kf from"react";var bv={"data-placeholder":!0,"data-resizeable":!0},ji={},gn="auto",ga={flexBasis:0,flexGrow:1,flexShrink:1,height:gn,width:gn},Mf={height:"width",width:"height"},Ef=(r="row")=>r==="row"?["width","height","column"]:["height","width","row"],xv=r=>typeof r=="string"&&r.endsWith("%"),at=r=>{let{style:{width:e=gn,height:t=gn}=ji}=r.props,n=typeof t=="number",o=typeof e=="number";return n&&o?{height:t,width:e}:n?{height:t}:o?{width:e}:void 0};function ya(r,e,t){let n=Mf[e],{style:{[n]:o=gn,...i}=ji}=r.props;return t&&t[e]?{...i,...ga,flexBasis:t[e],flexGrow:0,flexShrink:0}:{...i,...ga,[n]:o}}function Rf(r){let{style:{flex:e,flexGrow:t,flexShrink:n,flexBasis:o}=ji}=r.props;return typeof e=="number"||o===0&&t===1&&n===1?!0:typeof o!="number"}function ba(r,e,t){let n=Mf[e],{style:{[e]:o=gn,[n]:i=gn,...s}=ji}=r.props;return o!==gn?xv(o)?{flexBasis:0,flexGrow:1,flexShrink:1,[e]:void 0,[n]:i}:{flexBasis:o,flexGrow:0,flexShrink:0,[e]:o,[n]:i}:t&&t[e]?{...s,...ga,flexBasis:t[e],flexGrow:0,flexShrink:0}:{...s,[n]:i}}function Mo(r,e,t,n,o){let i=[],s=0,l;if(n&&o){let u,[h,f,d,p]=o;[u,l]=e==="column"?[f-n.top,n.bottom-p]:[h-n.left,n.right-d],u&&i.push(Ft(`${t}.${s++}`,u,{flexGrow:0,flexShrink:0}))}else l=!0;let{version:a=0,style:c}=_(r);return i.push(Ee(r,`${t}.${s++}`,{version:a+1,style:{...c,flexBasis:"auto",flexGrow:0,flexShrink:0}})),l&&i.push(Ft(`${t}.${s++}`,0,void 0,{[`data-${e}-placeholder`]:!0})),xa(e,{resizeable:!1,style:{flexBasis:"auto"}},i,t)}var vv=(r,e)=>{if(!e)return r===0?1:0};function xa(r,e,t,n){let o=Tf(),{flexFill:i,style:s,resizeable:l=!0}=e,{flexBasis:a=i?void 0:"auto"}=s,c=vv(a,i);return kf.createElement(Fn.Flexbox,{id:o,key:o,path:n,flexFill:i,style:{...s,flexDirection:r,flexBasis:a,flexGrow:c,flexShrink:c},resizeable:l},t)}var wv={flexGrow:1,flexShrink:1};function Ft(r,e,t,n){let o=Tf();return kf.createElement("div",{...bv,...n,"data-path":r,id:o,key:o,style:{...wv,...t,flexBasis:e}})}var Sv={},Eo=1,Ro=2,Cv=r=>typeof r.intrinsicSize=="number",Tv=(r,e)=>{let t={};return r.forEach(n=>{t[n]=q(e,n)}),t},Ji=(r,e,t)=>r.map((n,o)=>{var a;let i=q(n,"resizeable"),{[e]:s}=(a=at(n))!=null?a:Sv,l=Rf(n);return t?{index:o,flexOpen:l,intrinsicSize:s,resizeable:i,...Tv(t,n)}:{index:o,flexOpen:l,intrinsicSize:s,resizeable:i}}),If=r=>{let e=r.length,t=r.every(Cv),n=Array(e).fill(0);if(t&&e>0&&(n[0]=Ro,n[e-1]=Ro),e<2)return n;for(let o=0,i=0;o<e-1;o++)r[o].resizeable&&!i&&(i=Eo),n[o]+=i;for(let o=e-1;o>0&&(n[o]&Eo&&(n[o]-=Eo),!r[o].resizeable);o--);return n},Pf=(r,e)=>{let t=Mv(r,e),n=Ev(r,e),o=t!==-1&&n!==-1?[t,n]:void 0,i=kv(r,o);return[o,i]};function kv(r,e){if(e){let t=[];for(let n=0;n<r.length;n++)r[n].flexOpen&&!e.includes(n)&&t.push(n);return t}}function Mv(r,e){let t=e,n=!1;for(;t>=1&&!n;)t=t-1,n=Df(r,t);return t}function Ev(r,e){let t=e,n=!1,o=r.length;for(;t<o-1&&!n;)t=t+1,n=Df(r,t);return t===o?-1:t}function Df(r,e){let{placeholder:t,splitter:n,resizeable:o,intrinsicSize:i}=r[e];return!!(!n&&!i&&(t||o))}var Pv=r=>!r.splitter&&!r.placeholder,Of=({children:r,onSplitterMoved:e,style:t})=>{let n=Yi(null),o=Yi(),i=Yi(),s=Yi([]),[,l]=Iv({}),a=y=>{i.current=y,l({})},c=(t==null?void 0:t.flexDirection)==="column",u=c?"height":"width",h=Lf(()=>Array.isArray(r)?r:Io.isValidElement(r)?[r]:[],[r]),f=Qi(y=>{let{current:g}=o;if(g){let[v,w]=Pf(g,y);v&&(v.forEach(x=>{var b;let S=(b=n.current)==null?void 0:b.childNodes[x];if(S){let{size:C,minSize:k}=Ov(S,u);g[x].currentSize=C,g[x].minSize=k}}),w&&w.forEach(x=>{var b;let S=(b=n.current)==null?void 0:b.childNodes[x];if(S){let{[u]:C}=S.getBoundingClientRect();g[x].flexBasis=C}}))}},[u]),d=Qi((y,g)=>{i.current&&o.current&&a(Lv(i.current,o.current,g,u))},[u]),p=Qi(()=>{let y=o.current;y&&(e==null||e(y.filter(Pv))),y==null||y.forEach(g=>{g.currentSize=void 0,g.flexBasis=void 0,g.flexOpen=!1})},[e]),m=Qi(y=>Io.createElement(Cf,{column:c,index:y,key:`splitter-${y}`,onDrag:d,onDragEnd:p,onDragStart:f}),[d,p,f,c]);return Lf(()=>{let[y,g]=Dv(h,u,m,s.current);o.current=g,i.current=y},[h,m,u]),{content:i.current||[],rootRef:n}};function Dv(r,e,t,n){let o=Ji(r,e),i=If(o),s=[],l=[];for(let a=0;a<r.length;a++){let c=r[a];if(a===0&&i[a]&Ro&&(s.push(Af(a)),l.push({placeholder:!0,shim:!0})),c.key==null){let u=n[a]||(n[a]=Rv());s.push(Io.cloneElement(c,{key:u}))}else s.push(c);l.push(o[a]),a>0&&i[a]&Ro?(s.push(Af(a)),l.push({placeholder:!0})):i[a]&Eo&&(s.push(t(s.length)),l.push({splitter:!0}))}return[s,l]}function Lv(r,e,t,n){return Av(e,t)?r.map((i,s)=>{let l=e[s],{currentSize:a,flexOpen:c,flexBasis:u}=l,h=a!==void 0;if(h||c){let{flexBasis:f}=i.props.style||{},d=h?l.currentSize:u;return d!==f?Io.cloneElement(i,{style:{...i.props.style,flexBasis:d,[n]:"auto"}}):i}else return i}):r}function Av(r,e){let t=[];r.forEach((u,h)=>{u.currentSize!==void 0&&t.push(h)});let n=e<0?t[0]:t[1],{currentSize:o=0,minSize:i=0}=r[n];if(o===i)return!1;if(Math.abs(e)>o-i){let u=e<0?-1:1;e=Math.max(0,o-i)*u}let s=r[t[0]],{currentSize:l=0}=s;s.currentSize=l+e;let a=r[t[1]],{currentSize:c=0}=a;return a.currentSize=c-e,!0}function Af(r){return Io.createElement(Gi,{shim:r===0,key:`placeholder-${r}`})}function Ov(r,e){let{[e]:t}=r.getBoundingClientRect(),o=getComputedStyle(r).getPropertyValue(`min-${e}`),i=o.endsWith("px")?parseInt(o,10):0;return{size:t,minSize:i}}import{jsx as Bv}from"react/jsx-runtime";var va="hwFlexbox",Nf=Fv(function(e,t){let{breakPoints:n,children:o,column:i,className:s,flexFill:l,gap:a,fullPage:c,id:u,onSplitterMoved:h,resizeable:f,row:d,spacing:p,splitterSize:m,style:y,...g}=e,{content:v,rootRef:w}=Of({children:o,onSplitterMoved:h,style:y}),x=Vv(va,s,{[`${va}-column`]:i,[`${va}-row`]:d,"flex-fill":l,"full-page":c});return Bv("div",{...g,className:x,"data-resizeable":f||void 0,id:u,ref:Nv(w,t),style:{...y,gap:a,"--spacing":p},children:v})});Nf.displayName="Flexbox";var Po=Nf;import{useCallback as Rw}from"react";var Wn={ADD:"add",BLUR:"blur",BLUR_SPLITTER:"blur-splitter",DRAG_START:"drag-start",DRAG_STARTED:"drag-started",DRAG_DROP:"drag-drop",FOCUS:"focus",FOCUS_SPLITTER:"focus-splitter",INITIALIZE:"initialize",LAYOUT_RESIZE:"layout-resize",MAXIMIZE:"maximize",MINIMIZE:"minimize",REMOVE:"remove",REPLACE:"replace",RESTORE:"restore",SAVE:"save",SET_TITLE:"set-title",SPLITTER_RESIZE:"splitter-resize",SWITCH_TAB:"switch-tab",TEAR_OUT:"tear-out"};import{useCallback as Ra,useContext as Ia,useEffect as Cw,useRef as hd,useState as Tw}from"react";import Ma from"react";import{uuid as $f}from"@vuu-ui/vuu-utils";import Ao from"react";import{uuid as Hf}from"@vuu-ui/vuu-utils";import Do,{cloneElement as Hv}from"react";import{useCallback as Tr}from"react";var We=new Map,ct=new Map,Vf=r=>We.get(r),Ff=r=>We.has(r),Bf=(r,e)=>We.set(r,e),kr=()=>{let r=Tr((s,l)=>{let a=ct.get(s);if(a)return l!==void 0&&a[l]!==void 0?a[l]:l!==void 0?void 0:a},[]),e=Tr((s,l,a)=>{if(l===void 0)ct.set(s,a);else if(ct.has(s)){let c=ct.get(s);ct.set(s,{...c,[l]:a})}else ct.set(s,{[l]:a})},[]),t=Tr((s,l)=>{if(ct.has(s)){if(l===void 0)ct.delete(s);else if(ct.get(s)[l]){let{[l]:c,...u}=ct.get(s);Object.keys(u).length>0?ct.set(s,u):ct.delete(s)}}},[]),n=Tr((s,l)=>{let a=We.get(s);if(a)return l!==void 0?a[l]:a},[]),o=Tr((s,l,a)=>{if(l===void 0)We.set(s,a);else if(We.has(s)){let c=We.get(s);We.set(s,{...c,[l]:a})}else We.set(s,{[l]:a})},[]),i=Tr((s,l)=>{if(We.has(s)){if(l===void 0)We.delete(s);else if(We.get(s)[l]){let{[l]:c,...u}=We.get(s);Object.keys(u).length>0?We.set(s,u):We.delete(s)}}},[]);return{loadSessionState:r,loadState:n,saveSessionState:e,saveState:o,purgeState:i,purgeSessionState:t}};var _f=r=>r.flexDirection==="column"?["height","width"]:["width","height"],_v={},Lo=(r,e="0")=>{let[t,n]=Xi(K(r),r.props,e);return Do.cloneElement(r,t,n)},Sa=(r,e)=>{let t=K(r),[n,o]=Xi(t,r.props,"0",void 0,e);return Hv(r,n,o)},fO=(r,e,t)=>{let[n,o]=Xi(r,e,"0",void 0,t);return{...e,...n,type:r,children:o}};function zv(r,e,t="0",n=null,o){var m,y;let{active:i=0,"data-path":s,path:l=s,id:a,style:c}=_(o),u=K(o)===r&&t===l,h=u?a:(m=e.id)!=null?m:Hf(),f=r==="Stack"?(y=e.active)!=null?y:i:void 0,d=h,p=u?c:$v(r,e,n);return Vh(r)?{id:h,key:d,path:t,style:p,type:r,active:f}:{id:h,key:d,style:p,"data-path":t}}function Xi(r,e,t,n=null,o){var c,u;let i=zv(r,e,t,n,o);if(e.layout&&!o)return[i,[Mr(e.layout,`${t}.0`)]];let s=(u=o==null?void 0:o.children)!=null?u:(c=o==null?void 0:o.props)==null?void 0:c.children,a=e.dropTarget&&s?s:Wv(r,e.children,t,s);return[i,a]}function Wv(r,e,t="0",n){let o=Array.isArray(e)?e:Do.isValidElement(e)?[e]:[];return ze(r)?o.map((i,s)=>{let l=K(i),a=K(n==null?void 0:n[s]);if(!a||l===a){let[c,u]=Xi(l,i.props,`${t}.${s}`,r,n==null?void 0:n[s]);return Do.cloneElement(i,c,u)}return n==null?void 0:n[s]}):e}var $v=(r,e,t)=>{let{style:n=_v}=e;if(r==="Flexbox"&&(n={flexDirection:e.column?"column":"row",...n,display:"flex"}),n.flex){let{flex:o,...i}=n;n={...i,...oa(typeof o=="number"?o:0)}}else t==="Stack"?n={...n,...oa(1)}:t==="Flexbox"&&(n.width||n.height)&&n.flexBasis===void 0&&(n={...n,flexBasis:"auto",flexGrow:0,flexShrink:0});return n};function Mr({id:r=Hf(),type:e,children:t,props:n,state:o},i){let s=e.match(/^[a-z]/)?e:Fn[e];if(s===void 0)throw Error(`layoutUtils unable to create component from JSON, unknown type ${e}`);return o&&Bf(r,o),Do.createElement(s,{id:r,...n,key:r,path:i},t?t.map((l,a)=>Mr(l,`${i}.${a}`)):void 0)}function zf(r){return Wf(r)}function Wf(r){let e=K(r),{id:t,children:n,type:o,...i}=_(r),s=Ff(t)?Vf(t):void 0;return{id:t,type:e,props:Uv(i),state:s,children:Do.Children.map(n,Wf)}}function Uv(r){if(r){let{path:e,...t}=r,n={};for(let[o,i]of Object.entries(t))n[o]=wa(i);return n}}function wa(r){if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return r;if(Array.isArray(r))return r.map(wa);if(typeof r=="object"&&r!==null){let e={};for(let[t,n]of Object.entries(r))e[t]=wa(n);return e}}function Uf(r,e){var s;let t=r.props.children,n=t.length,{index:o=-1,positionRelativeToTab:i="after"}=e.tab||{};return o===-1||o>=n?[t[n-1],"after"]:[(s=t[o])!=null?s:null,i]}function Zi(r,e,t){let{active:n,children:o=[],path:i}=_(r),s=q(e,"path"),{idx:l,finalStep:a}=Et(i,s,!0),[c,u]=a?Gv(r,o,t):[n,o==null?void 0:o.map((f,d)=>d===l?Zi(f,e,t):f)],h=K(r)==="Stack"?Array.isArray(c)?c[0]:c:n;return Ao.cloneElement(r,{active:h},u)}function Gv(r,e,t){let n=q(r,"path"),o=e==null?void 0:e.length,{id:i=$f()}=_(t);return o?[o,e.concat(Ee(t,`${n}.${o}`,{id:i,key:i}))]:[0,[Ee(t,`${n}.0`,{id:i})]]}function es(r,e,t,n,o,i,s){let{active:l,children:a,path:c}=_(r),u=q(e,"path"),{idx:h,finalStep:f}=Et(c,u),[d,p]=f?qv(r,a,h,t,n,o,i,s):[l,a.map((y,g)=>g===h?es(y,e,t,n,o,i,s):y)],m=K(r)==="Stack"?d:l;return Ao.cloneElement(r,{active:m},p)}function qv(r,e,t,n,o,i,s,l){let a=at(n);return a!=null&&a.width&&(a!=null&&a.height)?jv(r,e,t,n,o,s,l):Gf(r,e,t,n,o,(i==null?void 0:i.width)||(i==null?void 0:i.height),s)}var Kv=(r,e,{top:t,right:n,bottom:o,left:i},[s,l,a,c])=>{if(r==="column"&&e==="before")return l-t;if(r==="column")return o-c;if(r==="row"&&e==="before")return s-i;if(r==="row")return n-a};function jv(r,e,t,n,o,i,s){let{style:{flexDirection:l}}=_(r),[a,c,u]=Ef(l),{[c]:h,[a]:f}=at(n),d=q(e[t],"path"),p=Kv(l,o,i,s),[m,y]=h<i[c]?[Mo(n,u,d,i,s),f]:[n,void 0],g=p?Ft(d,p,{flexGrow:0,flexShrink:0}):void 0;return h>i[c]&&(e=e.map(v=>{if(q(v,"placeholder"))return v;{let{[c]:w}=at(v);return w&&w<h?Mo(v,u,q(v,"path")):v}})),Gf(r,e,t,m,o,y,i,g)}function Gf(r,e,t,n,o,i,s,l){let a=q(r,"path"),c=0,u=!e||e.length===0?[n]:e.reduce((h,f,d)=>{if(t===d){let[p,m]=Jv(r,f,n,s);o==="before"?l?h.push(l,m,p):h.push(m,p):l?h.push(p,m,l):h.push(p,m),c=h.indexOf(m)}else h.push(f);return h},[]).map((h,f)=>f<c?h:Ee(h,`${a}.${f}`));return[c,u]}function Jv(r,e,t,n){let o=$f(),{version:i=0}=_(t);if(i+=1,K(r)==="Flexbox"){let[s]=_f(r.props.style),l=6,a={[s]:(n[s]-l)/2},c=ba(e,s,a),u=ba(t,s,a);return[Ao.cloneElement(e,{style:c}),Ao.cloneElement(t,{id:o,version:i,style:u})]}else{let{style:{left:s,top:l,flex:a,...c}={left:void 0,top:void 0,flex:void 0}}=_(t);return[e,Ao.cloneElement(t,{id:o,version:i,style:c})]}}import{cloneElement as Xv}from"react";import ts from"react";function qf(r,{target:e,replacement:t}){return Ca(r,e,t)}function Ca(r,e,t){let n=q(e,"path"),o=q(e,"resizeable"),{style:i}=_(e),s=Lo(ts.cloneElement(t,{resizeable:o,style:{...i,...t.props.style}}),n);return $e(r,e,s)}function $e(r,e,t,n){if(r===e)return t;let{idx:o,finalStep:i}=Et(q(r,"path"),q(e,"path")),s=r.props.children.slice();return i?n?n===Wn.MINIMIZE?s[o]=Qv(r,s[o]):n===Wn.RESTORE&&(s[o]=Yv(s[o])):s[o]=t:s[o]=$e(s[o],e,t,n),ts.cloneElement(r,void 0,s)}function Qv(r,e){let{style:t}=_(r),{style:n}=_(e),{width:o,height:i,flexBasis:s,flexShrink:l,flexGrow:a,...c}=n,u={width:o,height:i,flexBasis:s,flexShrink:l,flexGrow:a},h={...c,flexBasis:0,flexGrow:0,flexShrink:0},f=t.flexDirection==="row"?"vertical":t.flexDirection==="column"?"horizontal":!1;return f?ts.cloneElement(e,{collapsed:f,restoreStyle:u,style:h}):e}function Yv(r){let{style:e,restoreStyle:t}=_(r),{flexBasis:n,flexShrink:o,flexGrow:i,...s}=e,l={...s,...t};return ts.cloneElement(r,{collapsed:!1,style:l,restoreStyle:void 0})}function Kf(r,{fromIndex:e,path:t,toIndex:n}){let o=Te(r,t,!0),{children:i}=_(o),s=Zv(i,e,n),l=Xv(o,void 0,s);return $e(r,o,l)}function Zv(r,e,t){let n=r.slice(),[o]=n.splice(e,1);return t===-1?n.concat(o):(n.splice(t,0,o),n)}var Re={ADD:"add",DRAG_START:"drag-start",DRAG_DROP:"drag-drop",LAYOUT_RESIZE:"layout-resize",MAXIMIZE:"maximize",MINIMIZE:"minimize",MOVE_CHILD:"move-child",REMOVE:"remove",REPLACE:"replace",RESTORE:"restore",SAVE:"save",SET_PROP:"set-prop",SET_PROPS:"set-props",SET_TITLE:"set-title",SPLITTER_RESIZE:"splitter-resize",SWITCH_TAB:"switch-tab",TEAROUT:"tearout"},VO=r=>["switch-active-layout","open-layout","close-layout","rename-layout"].includes(r),FO=r=>["switch-active-tab","edit-feature-title","save-feature-props","remove-component","resize-component","drag-drop-operation"].includes(r);import $n from"react";function Ta(r,{path:e}){let t=Te(r,e),n=Qt(r,e);if(n===null)return r;let{children:o}=_(n);if(o.length>1&&Jf(o,e)){let{style:{flexBasis:i,display:s,flexDirection:l,...a}}=_(n),c=q(n,"path"),u=$e(r,n,Ft(c,i,a));for(;(n=Qt(u,c))&&q(n,"path")!=="0";){let{children:h}=_(n);if(Jf(h)){c=q(n,"path");let{style:{flexBasis:f,display:d,flexDirection:p,...m}}=_(n);u=$e(r,n,Ft(c,f,m))}else if(rw(h))u=Xf(r,n);else break}return u}return Qf(r,t)}function Qf(r,e){let t=_(r),{children:n,path:o,preserve:i}=t,{active:s}=t,{idx:l,finalStep:a}=Et(o,q(e,"path")),c=K(r),u=n.slice();if(a){if(u.splice(l,1),s!==void 0&&s>=l&&(s=Math.max(0,s-1)),u.length===1&&!i&&o!=="0"&&c.match(/Flexbox|Stack/))return ew(r,u[0]);!u.some(tw)&&u.some(Yf)&&(u=nw(u))}else u[l]=Qf(u[l],e);return u=u.map((h,f)=>Ee(h,`${o}.${f}`)),$n.cloneElement(r,{active:s},u)}function ew(r,e){let t=K(r),{path:n,style:{flexBasis:o,flexGrow:i,flexShrink:s,width:l,height:a}}=_(r),c=Ee(e,n);if(n==="0")c=$n.cloneElement(c,{style:{...e.props.style,width:l,height:a}});else if(t==="Flexbox"){let u=r.props.style.flexDirection==="column"?"height":"width",{style:{[u]:h,...f}}=c.props;c=$n.cloneElement(c,{flexFill:void 0,style:{...f,flexGrow:i,flexShrink:s,flexBasis:o,width:l,height:a}})}return c}var tw=r=>r.props.style.flexGrow>0,Yf=r=>{let{width:e,height:t,flexGrow:n}=r.props.style;return n===0&&typeof e!="number"&&typeof t!="number"},nw=r=>r.map(e=>Yf(e)?$n.cloneElement(e,{style:{...e.props.style,flexGrow:1}}):e),rw=r=>{if(r&&r.length>0){let e=q(r[0],"placeholder"),t=!1;for(let n=1;n<r.length;n++){if(t=q(r[n],"placeholder"),e&&t)return!0;e=t}}},Xf=(r,e)=>{let{children:t,path:n}=_(r),{idx:o,finalStep:i}=Et(n,q(e,"path")),s=t.slice();return i?s[o]=ow(e):s[o]=Xf(s[o],e),s=s.map((l,a)=>Ee(l,`${n}.${a}`)),$n.cloneElement(r,void 0,s)},ow=r=>{let{children:e}=_(r),t=[],n=[];for(let i=0;i<e.length;i++)q(e[i],"placeholder")?n.push(e[i]):(n.length===1?t.push(n.pop()):n.length>0&&(t.push(jf(n)),n.length=0),t.push(e[i]));n.length===1?t.push(n.pop()):n.length>0&&t.push(jf(n));let o=q(r,"path");return $n.cloneElement(r,void 0,t.map((i,s)=>Ee(i,`${o}.${s}`)))},jf=([r,...e])=>{let t=q(r,"style"),{flexBasis:n,flexGrow:o,flexShrink:i}=t;for(let{props:{style:s}}of e)n+=s.flexBasis,o=Math.max(o,s.flexGrow),i=Math.max(i,s.flexShrink);return $n.cloneElement(r,{style:{...t,flexBasis:n,flexGrow:o,flexShrink:i}})},Jf=(r,e)=>r.every(t=>q(t,"placeholder")||e&&q(t,"path")===e);import ka from"react";function Zf(r,{path:e,size:t}){let n=Te(r,e,!0),{style:o}=_(n),i={...o,width:t},s=ka.cloneElement(n,{style:i});return $e(r,n,s)}function ed(r,{path:e,sizes:t}){let n=Te(r,e,!0),{children:o,style:i}=_(n),s=i.flexDirection==="column"?"height":"width",l=iw(o,t,s),a=ka.cloneElement(n,void 0,l);return $e(r,n,a)}function iw(r,e,t){return r.map((n,o)=>{let{style:{[t]:i,flexBasis:s}}=_(n),l=e[o],{currentSize:a,flexBasis:c}=l,h=a!==void 0?l.currentSize:c;return h===void 0||i===h||s===h?n:ka.cloneElement(n,{style:sw(n.props.style,t,h)})})}function sw(r,e,t){let n=typeof r[e]=="number",{flexShrink:o=1,flexGrow:i=1}=r;return{...r,[e]:n?t:"auto",flexBasis:n?"auto":t,flexShrink:o,flexGrow:i}}import{uuid as lw}from"@vuu-ui/vuu-utils";import ns from"react";var td=r=>{let[e]=K(r);return e===e.toLowerCase()};function Oo(r,e,t,n,o,i){let{children:s,path:l}=_(r),a=q(e,"path"),{idx:c,finalStep:u}=Et(l,a),h=u?aw(r,s,e,t,n,o,i):s.map((f,d)=>d===c?Oo(f,e,t,n,o,i):f);return ns.cloneElement(r,void 0,h)}function aw(r,e,t,n,o,i,s){let l=at(n);if(l!=null&&l.width&&(l!=null&&l.height)){if(i===void 0||s===void 0)throw Error("wrap-layout-element, updateChildren clientRect and dropRect must both be available");return uw(e,t,n,o,i,s)}return cw(r,e,t,n,o)}function cw(r,e,t,n,o){var b;let{version:i=0}=_(n),s=q(t,"path"),{type:l,flexDirection:a,showTabs:c}=rd(o),[u,h,f]=hw(l,t,n,a,o),d=nd(o),p=d?1:0,m={resizeable:!0,style:f,version:i+1},g={[td(t)?"data-resizeable":"resizeable"]:!0,style:h},v=l==="Stack"?{showTabs:c}:void 0,w=l==="Flexbox"?{splitterSize:(b=K(r)==="Flexbox"&&r.props.splitterSize)!=null?b:void 0}:void 0,x=lw(),S=ns.createElement(Fn[l],{active:p,id:x,key:x,path:q(t,"path"),flexFill:q(t,"flexFill"),...w,...v,style:u,resizeable:q(t,"resizeable")},d?[Ee(t,`${s}.0`,g),Lo(ns.cloneElement(n,m),`${s}.1`)]:[Lo(ns.cloneElement(n,m),`${s}.0`),Ee(t,`${s}.1`,g)]);return e.map(C=>C===t?S:C)}function uw(r,e,t,n,o,i){let{flexDirection:s}=rd(n),l=s==="column"?"row":"column",a=nd(n),[c,u,h,f]=i,[d,p]=s==="column"?[u-o.top,o.bottom-f]:[c-o.left,o.right-h],m=q(e,"path"),y=0,g=td(e)?"data-resizeable":"resizeable",v=[];d&&v.push(a?Ee(e,`${m}.${y++}`,{[g]:!0,style:{flexBasis:d,flexGrow:1,flexShrink:1}}):Ft(`${m}.${y++}`,d,{flexGrow:0,flexShrink:0})),v.push(Mo(t,l,`${m}.${y++}`,o,i)),p&&v.push(a?Ft(`${m}.${y++}`,0):Ee(e,`${m}.${y++}`,{[g]:!0,style:{flexBasis:0,flexGrow:1,flexShrink:1}}));let w=xa(s,e.props,v,m);return r.map(x=>x===e?w:x)}function hw(r,e,t,n,o){let i={...e.props.style,flexDirection:n},s=r==="Flexbox"&&n==="column"?"height":"width",l=ya(t,s,o),a=ya(e,s);return[i,a,l]}var nd=r=>{var e;return r.position.SouthOrEast?!0:((e=r==null?void 0:r.tab)==null?void 0:e.positionRelativeToTab)==="before"?!1:!!r.position.Header};function rd(r){return r.position.Header?{type:"Stack",flexDirection:"column",showTabs:!0}:{type:"Flexbox",flexDirection:r.position.EastOrWest?"row":"column"}}var ad=(r,e)=>{switch(e.type){case Re.ADD:return gw(r,e);case Re.DRAG_DROP:return mw(r,e);case Re.MAXIMIZE:return pw(r,e);case Re.REMOVE:return Ta(r,e);case Re.REPLACE:return qf(r,e);case Re.SET_PROP:return od(r,e);case Re.SET_PROPS:return dw(r,e);case Re.SET_TITLE:return od(r,{type:"set-prop",path:e.path,propName:"title",propValue:e.title});case Re.SPLITTER_RESIZE:return ed(r,e);case Re.LAYOUT_RESIZE:return Zf(r,e);case Re.SWITCH_TAB:return fw(r,e);case Re.MOVE_CHILD:return Kf(r,e);default:return r}},fw=(r,{path:e,nextIdx:t})=>{let n=Te(r,e,!0),o=Ma.cloneElement(n,{active:t});return $e(r,n,o)},od=(r,{path:e,propName:t,propValue:n})=>{let o=Te(r,e,!0),i=Ma.cloneElement(o,{[t]:n});return $e(r,o,i)},dw=(r,{path:e,props:t})=>{let n=Te(r,e,!0),o=Ma.cloneElement(n,t);return $e(r,n,o)},pw=(r,{path:e,type:t})=>{if(e){let n=Te(r,e,!0);return $e(r,n,n,t)}else return r},mw=(r,e)=>{var p,m;let{draggedReactElement:t,dragInstructions:n,dropTarget:o}=e,i=o.component,{pos:s}=o,l=((p=s==null?void 0:s.position)==null?void 0:p.Header)&&K(i)==="Stack",{id:a,version:c}=_(t),u=at(t),h;if(l){let[y,g]=Uf(i,s);y===void 0?h=Zi(r,i,t):h=es(r,y,t,g)}else!u&&((m=s==null?void 0:s.position)!=null&&m.Centre)?h=Ca(r,i,t):h=yw(r,o,t);if(n.DoNotRemove)return h;let f=Yt(h,y=>y.id===a&&y.version===c),d=q(f,"path");return Ta(h,{path:d,type:"remove"})},gw=(r,{path:e,component:t})=>Zi(r,Te(r,e),t),yw=(r,e,t)=>{let{component:n,pos:o,clientRect:i,dropRect:s}=e,l=q(n,"path");if(l==="0.0")return Oo(r,n,t,o);let a=Qt(r,l);if(id(o,a)){let c=o.position.SouthOrEast?"after":"before";return es(r,n,t,c,o,i,s)}if(!id(o,a))return Oo(r,n,t,o,i,s);if(ze(K(a)))return Oo(r,n,t,o);throw Error(`no support right now for position = ${o.position}`)},id=(r,e)=>r.position.Centre?ld(e)||sd(e):r.position.NorthOrSouth?sd(e):r.position.EastOrWest?ld(e):!1,sd=r=>K(r)==="Flexbox"&&r.props.style.flexDirection==="column",ld=r=>K(r)==="Flexbox"&&r.props.style.flexDirection!=="column";import{createContext as bw}from"react";var xw=r=>console.log(`dispatch ${r.type}, have you forgotten to provide a LayoutProvider ?`),No=bw({dispatchLayoutProvider:xw,version:-1});import{useCallback as rs,useRef as Ea}from"react";var vw={},cd=[0,0],ww=(r,e,t)=>{let n=document.createElement("div");n.className="vuuSimpleDraggableWrapper",n.classList.add("vuuSimpleDraggableWrapper","salt-theme","salt-density-medium"),n.dataset.dragging="true";let o=t!=null?t:document.createElement("div");o.id=e,n.appendChild(o),document.body.appendChild(n);let i=`top:${r.top}px;left:${r.left}px;width:${r.width}px;height:${r.height}px;`;return[n,i,r.left,r.top]},Sw=r=>{let{offsetParent:e}=r;if(e===null)return cd;{let{left:t,top:n}=e.getBoundingClientRect();return[t,n]}},ud=(r,e,t)=>{let n=Ea(),o=Ea(),i=Ea(),s=rs((u,h)=>{if(o.current&&i.current){let{dragOffsets:[f,d],targetPosition:p}=o.current,m=typeof u=="number"?u-f:p.left,y=typeof h=="number"?h-d:p.top;(m!==p.left||y!==p.top)&&(o.current.targetPosition.left=m,o.current.targetPosition.top=y,i.current.style.top=y+"px",i.current.style.left=m+"px")}},[]),l=rs(u=>{if(o.current){let{dragInstructions:h,payload:f,originalCSS:d}=o.current;u&&e({type:"drag-drop",draggedReactElement:f,dragInstructions:h,dropTarget:u}),i.current&&(!u&&h.DriftHomeIfNoDropTarget?(console.log("drift back to start"),document.body.removeChild(i.current)):h.RemoveDraggableOnDragEnd?document.body.removeChild(i.current):(i.current.style.cssText=d,delete i.current.dataset.dragging)),n.current=void 0,o.current=void 0,i.current=void 0}},[e]),a=rs(u=>{if(n.current){let{payload:h,dragContainerPath:f,dragElement:d,dragRect:p,instructions:m=vw,path:y}=n.current,{current:g}=r,v={x:u.clientX,y:u.clientY},w=h!=null?h:Te(g,y,!0),{id:x}=w.props,S=at(w),b="",C="",k="",E=-1,R=-1,M=cd,P=document.getElementById(x);if(P===null)[P,C,E,R]=ww(p,x,d);else{M=Sw(P);let[I,V]=M,{width:B,height:W,left:O,top:N}=P.getBoundingClientRect();E=O-I,R=N-V,C=`width:${B}px;height:${W}px;left:${E}px;top:${R}px;z-index: 100;background-color:#ccc;opacity: 0.6;`,P.dataset.dragging="true",b=P.style.cssText}k=ma.initDrag(r.current,f,p,v,{drag:s,drop:l},S),P.style.cssText=C+k,i.current=P,o.current={payload:w,originalCSS:b,dragRect:p,dragOffsets:M,dragInstructions:m,targetPosition:{left:E,top:R}}}},[s,l,r]);return rs(u=>{let{evt:h,...f}=u;n.current={...f,dragContainerPath:na(r.current,t)},ma.handleMousedown(h,a,f.instructions)},[a,t,r])};import{jsx as md}from"react/jsx-runtime";var fd=r=>r.dropTarget,kw=r=>["drag-drop","remove","set-title","splitter-resize","switch-tab"].includes(r.type),dd=r=>{switch(r.type){case"switch-tab":return r.id==="main-tabs"?"switch-active-layout":"switch-active-tab";case"save":return"save-feature-props";case"drag-drop":return"drag-drop-operation";case"remove":return"remove-component";case"splitter-resize":return"resize-component";case"set-title":return"edit-feature-title";default:throw Error("unknown layout action")}},l2=()=>{let r=Ew();return md("div",{children:`Context: ${r} `})},Mw=r=>{let{children:e,createNewChild:t,pathToDropTarget:n,layout:o,onLayoutChange:i}=r,s=hd(void 0),l=hd(e),[,a]=Tw(null),c=Ra((d,p)=>{if(i){let m=Yt(d,fd)||s.current,g=K(m)==="DraggableLayout"?_(m).children[0]:m,v=zf(g);i(v,p)}},[i]),u=Ra((d,p=!1)=>{let m=ad(s.current,d);m!==s.current&&(s.current=m,a({}),!p&&kw(d)&&c(m,dd(d)))},[a,c]),h=Ra(d=>{switch(d.type){case"drag-start":{f(d);break}case"save":{c(s.current,dd(d));break}default:{u(d);break}}},[u,c]),f=ud(s,h,n);return Cw(()=>{if(o){let d=Yt(s.current,fd);if(d){let p=$h(d),m=Mr(o,`${d.props.path}.0`),y=p?{type:Re.REPLACE,target:p,replacement:m}:{type:Re.ADD,path:d.props.path,component:m};u(y,!0)}else if(o.id===q(s.current,"id")){let p=Mr(o,"0"),m={type:Re.REPLACE,target:s.current,replacement:p};u(m,!0)}}},[u,o]),s.current===void 0?s.current=Sa(e):e!==l.current&&(s.current=Sa(e,s.current),l.current=e),md(No.Provider,{value:{createNewChild:t,dispatchLayoutProvider:h,version:0},children:s.current})},ut=()=>{let{dispatchLayoutProvider:r}=Ia(No);return r},pd=()=>{let{createNewChild:r}=Ia(No);return r},Ew=()=>{let{version:r}=Ia(No);return r};import{jsx as Iw}from"react/jsx-runtime";var gd=function(e){let{path:t}=e,n=ut(),o=Rw(i=>{n({type:Wn.SPLITTER_RESIZE,path:t,sizes:i})},[n,t]);return Iw(Po,{...e,onSplitterMoved:o})};gd.displayName="Flexbox";ge("Flexbox",gd,"container");import{useForkRef as Jw}from"@salt-ds/core";import Qw from"classnames";import{forwardRef as Yw,useMemo as Xw}from"react";import{useCallback as Sd,useEffect as Nw,useRef as La,useState as Vw}from"react";import{useCallback as Pw,useLayoutEffect as yd,useRef as Dw}from"react";var xd=["height","width"],S2=["height"],C2=["width"],Un=new WeakMap,vd=(r,e,t)=>{switch(t){case"height":return e.height;case"scrollHeight":return r.scrollHeight;case"scrollWidth":return r.scrollWidth;case"width":return e.width;default:return 0}},bd=new ResizeObserver(r=>{for(let e of r){let{target:t,contentRect:n}=e,o=Un.get(t);if(o){let{onResize:i,measurements:s}=o,l=!1;for(let[a,c]of Object.entries(s)){let u=vd(t,n,a);u!==c&&(l=!0,s[a]=u)}l&&i&&i(s)}}});function os(r,e,t,n=!1){let o=Dw(e),i=Pw(s=>{let l=s.getBoundingClientRect();return o.current.reduce((a,c)=>(a[c]=vd(s,l,c),a),{})},[]);yd(()=>{let s=r.current,l=!1;async function a(){Un.set(s,{measurements:{}}),l=!1;let{fonts:c}=document;if(c&&await c.ready,!l){let u=Un.get(s);if(u){let h=i(s);u.measurements=h,bd.observe(s),n&&t(h)}}}if(s){if(Un.has(s))throw Error("useResizeObserver attemping to observe same element twice");a()}return()=>{s&&Un.has(s)&&(bd.unobserve(s),Un.delete(s),l=!0)}},[r,i,n,t]),yd(()=>{let s=r.current,l=Un.get(s);if(l){if(o.current!==e){o.current=e;let a=i(s);l.measurements=a}l.onResize=t}},[e,i,r,t])}function Lw(r,e){let t=document.body.querySelector(`.${r}`),n={get:function(o,i){let s=o.getPropertyValue(`--${r}-breakpoint-${i}`);return s?parseInt(s):void 0}};return t?new Proxy(getComputedStyle(t),n):e!=null?e:{}}var Aw=([,r],[,e])=>e-r,Da=r=>Object.entries(r).sort(Aw).map(([e,t],n,o)=>[e,t,n<o.length-1?o[n+1][1]:9999]),Pa=null,Ow=(r="salt")=>{let{xs:e,sm:t,md:n,lg:o,xl:i}=Lw(r);return Da({xs:e,sm:t,md:n,lg:o,xl:i})},wd=r=>(Pa===null&&(Pa=Ow(r)),Pa);var Fw=[],Cd=({breakPoints:r,smallerThan:e},t)=>{let[n,o]=Vw(e?!1:"lg"),i=La(document.body),s=La(r?Da(r):wd()),l=La("lg"),a=Sd(u=>{if(s.current){for(let[h,f]of s.current)if(u>=f)return h}},[s]),c=Sd(u=>{if(e){let h=s.current.find(([f])=>f===e);if(h){let[,,f]=h;return u<f}}else return a(u);return u},[e,a]);return os(t||i,s.current?["width"]:Fw,({width:u})=>{let h=c(u);h!==l.current&&(l.current=h,o(h))},!0),Nw(()=>{let u=t||i;if(u.current){let h=l.current;if(s.current){let{clientWidth:f}=u.current,d=c(f);l.current=d,d!==h&&o(d)}}},[o,c,t]),n};var Td="data-collapsible",Bw={[Td]:!0,"data-pad-start":!0,"data-pad-end":!0},Hw=r=>{var e;return(e=Bw[r])!=null?e:!1},_w=r=>r===Td,zw={dynamic:"dynamic",instant:"instant",true:"instant"},Ww=r=>{var e;return(e=zw[r])!=null?e:"none"},L2=r=>Object.keys(r).reduce((e,t)=>{let[n,o]=e;if(Hw(t)){let i=_w(t)?Ww(r[t]):r[t];n[t]=i,o[t]=void 0}return e},[{},{}]);import{getUniqueId as $w}from"@vuu-ui/vuu-utils";import{cloneElement as Uw,isValidElement as Gw,useCallback as qw,useMemo as kd,useRef as Aa}from"react";var Kw=["xs","sm","md","lg","xl"],jw=12,Md=({children:r,cols:e,style:t})=>{let n=Aa(null),o=Aa(null),i=Aa(),s=e!=null?e:jw,a=(t==null?void 0:t.flexDirection)==="column"?"height":"width",c=kd(()=>Array.isArray(r)?r:Gw(r)?[r]:[],[r]),u=qw((h,f)=>{let d=Ji(h,f,Kw),p=[],m=[];for(let y=0;y<h.length;y++){let g=h[y],{style:{flex:v,...w}}=g.props;p.push(Uw(g,{key:$w(),style:{...w,"--parent-col-count":s}})),m.push(d[y])}return[p,m]},[s]);return kd(()=>{let[h,f]=u(c,a);o.current=f,i.current=h},[u,c,a]),{cols:s,content:i.current,rootRef:n}};import{jsx as Zw}from"react/jsx-runtime";var is="hwFluidGrid",Oa=Yw(function(e,t){let{breakPoints:n,children:o,column:i,cols:s=12,className:l,flexFill:a,gap:c=3,fullPage:u,id:h,onSplitterMoved:f,resizeable:d,row:p,showGrid:m,spacing:y,splitterSize:g,style:v,...w}=e,x=Xw(()=>wr(o),[o]),{cols:S,content:b,rootRef:C}=Md({children:x,cols:s,style:v}),k=Cd({breakPoints:n},C),E=Qw(is,l,{[`${is}-column`]:i,[`${is}-row`]:p,[`${is}-show-grid`]:m,"flex-fill":a,"full-page":u}),R={...v,"--spacing":y,"--grid-col-count":S,"--grid-gap":c};return Zw("div",{...w,className:E,"data-breakpoint":k,"data-cols":S,"data-resizeable":d||void 0,id:h,ref:Jw(C,t),style:R,children:b})});Oa.displayName="FluidGrid";import{jsx as eS}from"react/jsx-runtime";var Ed=function(e){return eS(Oa,{...e})};Ed.displayName="FluidGrid";ge("FluidGrid",Ed,"container");import{EditableLabel as pS}from"@vuu-ui/vuu-ui-controls";import{Button as mS}from"@salt-ds/core";import{default as gS,default as yS}from"classnames";import{cloneElement as Bd,useRef as bS,useState as Hd}from"react";import{useCallback as Vo,useState as tS}from"react";var ss=(r,e,t,n)=>{var y;let{loadSessionState:o,purgeSessionState:i,purgeState:s,saveSessionState:l}=kr(),[a,c]=tS((y=o(r,"contributions"))!=null?y:[]),u=ut(),h=Vo((g,v)=>{let w=a.concat([{location:g,content:v}]);l(r,"contributions",w),c(w)},[a,r,l]),f=Vo(()=>{i(r,"contributions"),c([])},[r,i]),d=Vo(()=>{let g=o(r,"data-source");g&&g.unsubscribe(),i(r),s(r),u({type:"remove",path:t})},[u,r,o,i,s,t]),p=Vo(async(g,v,w)=>{var S;g.stopPropagation();let x=(S=e.current)==null?void 0:S.getBoundingClientRect();return new Promise((b,C)=>{u({type:"drag-start",evt:g,path:v===void 0?t:`${t}.${v}`,dragRect:x,preDragActivity:w,dropTargets:n,resolveDragStart:b,rejectDragStart:C})})},[e,u,t,n]);return[Vo(async(g,v)=>{var x;let{type:w}=g;switch(w){case"maximize":case"minimize":case"restore":return u({type:w,path:(x=g.path)!=null?x:t});case"remove":return d();case"mousedown":return p(v,g.index,g.preDragActivity);case"add-toolbar-contribution":return h(g.location,g.content);case"remove-toolbar-contribution":return f();default:return}},[u,t,d,p,h,f]),a]};import{useForkRef as iS,useIdMemo as sS}from"@salt-ds/core";import lS from"classnames";import Va,{forwardRef as aS,useCallback as cS,useMemo as uS,useRef as Nd,useState as hS}from"react";import{useCallback as Gn,useMemo as Rd}from"react";var Id=({id:r,rootRef:e,path:t,dropTargets:n,title:o})=>{let i=ut(),{loadState:s,loadSessionState:l,purgeState:a,saveState:c,saveSessionState:u}=kr(),[h,f]=ss(r,e,t,n),d=Rd(()=>{var b;return(b=s("view-title"))!=null?b:o},[s,o]),p=Gn(b=>{t&&i({type:"set-title",path:t,title:b})},[i,t]),m=Rd(()=>s(r),[r,s]),y=Gn(b=>s(r,b),[r,s]),g=Gn(b=>{a(r,b),i({type:"save"})},[r,i,a]),v=Gn((b,C)=>{c(r,C,b),i({type:"save"})},[r,i,c]),w=Gn(b=>l(r,b),[r,l]),x=Gn((b,C)=>u(r,C,b),[r,u]),S=Gn(({type:b,...C})=>{let{[b]:k}=C;v(k,b)},[v]);return{contributions:f,dispatchViewAction:h,load:y,loadSession:w,onConfigChange:S,onEditTitle:p,purge:g,restoredState:m,save:v,saveSession:x,title:d}};import{useCallback as Pd,useRef as Dd}from"react";var nS=[],Ld=({mainRef:r,resize:e="responsive",rootRef:t})=>{let n=e==="defer",o=Dd({}),i=Dd(),s=Pd(()=>{r.current&&(r.current.style.height=o.current.height+"px",r.current.style.width=o.current.width+"px"),i.current=void 0},[r]),l=Pd(({height:a,width:c})=>{o.current.height=a,o.current.width=c,i.current!==null&&clearTimeout(i.current),i.current=window.setTimeout(s,40)},[s]);os(t,n?xd:nS,l,n)};import rS,{useContext as Ad}from"react";var oS={dispatch:null},ls=rS.createContext(oS),Od=()=>{var e;let r=Ad(ls);return(e=r==null?void 0:r.dispatch)!=null?e:null},DV=()=>Ad(ls);import{jsx as Na,jsxs as dS}from"react/jsx-runtime";var Fo="vuuView",fS=(r,e)=>r&&e?{...r,...e}:r||e,Vd=aS(function(e,t){let{Header:n=Fd,children:o,className:i,collapsed:s,closeable:l,"data-path":a,"data-resizeable":c,dropTargets:u,expanded:h,flexFill:f,id:d,header:p,orientation:m="horizontal",path:y=a,resize:g="responsive",resizeable:v=c,tearOut:w,style:x={},title:S,...b}=e,C=sS(d),k=Nd(null),E=Nd(null),[R,M]=hS(),{contributions:P,dispatchViewAction:I,load:V,loadSession:B,onConfigChange:W,onEditTitle:O,purge:N,restoredState:F,save:G,saveSession:X,title:te}=Id({id:C,rootRef:k,path:y,dropTargets:u,title:S});Ld({mainRef:E,resize:g,rootRef:k});let _e=cS(Vt=>{M(Vt)},[]),de=()=>Va.isValidElement(o)&&(F||R)?Va.cloneElement(o,fS(F,R)):o,it=uS(()=>({dispatch:I,id:C,path:y,title:te,load:V,loadSession:B,onConfigChange:W,purge:N,save:G,saveSession:X,setComponentProps:_e}),[I,C,V,B,W,y,N,G,X,_e,te]),On=typeof p=="object"?p:{};return Na("div",{...b,className:lS(Fo,i,{[`${Fo}-collapsed`]:s,[`${Fo}-expanded`]:h,[`${Fo}-resize-defer`]:g==="defer"}),"data-resizeable":v,id:C,ref:iS(t,k),style:x,tabIndex:-1,children:dS(ls.Provider,{value:it,children:[p?Na(n,{...On,collapsed:s,contributions:P,expanded:h,closeable:l,onEditTitle:O,orientation:m,tearOut:w,title:te}):null,Na("div",{className:`${Fo}-main`,ref:E,children:de()})]})})});Vd.displayName="View";var qn=Va.memo(Vd);qn.displayName="View";ge("View",qn,"view");import{jsx as Bo}from"react/jsx-runtime";var Fa="vuuHeader",Fd=({className:r,contributions:e,collapsed:t,closeable:n,onEditTitle:o,orientation:i="horizontal",style:s,title:l="Untitled"})=>{let a=bS(null),[c,u]=Hd(l),[h,f]=Hd(!1),d=Od(),p=R=>d==null?void 0:d({type:"remove"},R),m=()=>{var R;(R=a.current)==null||R.focus()},y=R=>{R.stopPropagation()},v=gS(Fa,r,`${Fa}-${t||i}`),w=()=>{f(!0)},x=R=>{R.key==="Enter"&&f(!0)},S=(R="",M="",P=!0,I=!1)=>{var V;f(!1),I?u(R):M!==R&&(u(M),o==null||o(M)),P===!1&&((V=a.current)==null||V.focus())},b=R=>{d==null||d({type:"mousedown"},R)},C=[],k=[],E=[];return e==null||e.forEach((R,M)=>{switch(R.location){case"pre-title":C.push(Bd(R.content,{key:M}));break;default:k.push(Bd(R.content,{key:M}))}}),l&&C.push(Bo(pS,{className:`${Fa}-title`,editing:h,value:c,onChange:u,onMouseDownCapture:m,onEnterEditMode:w,onExitEditMode:S,onKeyDown:x,ref:a,tabIndex:0},"title")),n&&E.push(Bo(mS,{"data-icon":"close",onClick:p,onMouseDown:y,variant:"secondary"},"close")),k.length>0&&C.push(Bo("div",{className:"vuuTooltrayProxy","data-align":"end",children:k},"contributions")),E.length>0&&C.push(Bo("div",{className:"vuuTooltrayProxy","data-align":"end",children:E},"actions")),Bo("div",{className:yS("vuuToolbarProxy",v),style:s,onMouseDown:b,children:C})};var yF={type:"View",props:{style:{height:"calc(100% - 6px)"}},children:[{props:{className:"vuuShell-warningPlaceholder"},type:"Placeholder"}]},Ho={type:"Stack",id:"main-tabs",props:{className:"vuuShell-mainTabs",TabstripProps:{allowAddTab:!0,allowCloseTab:!0,allowRenameTab:!0,animateSelectionThumb:!1,location:"main-tab",tabClassName:"MainTab"},preserve:!0,active:0},children:[{props:{id:"tab1",className:"vuuShell-Placeholder"},type:"Placeholder"}]};import{Prompt as Pz}from"@vuu-ui/vuu-popups";import{Button as Lz}from"@salt-ds/core";import Oz from"classnames";import{useRef as Bz}from"react";import{useCallback as CF,useRef as TF}from"react";import{PopupComponent as MF,Portal as EF}from"@vuu-ui/vuu-popups";import{List as IF,ListItem as PF}from"@vuu-ui/vuu-ui-controls";import{Fragment as NF,jsx as AF,jsxs as OF}from"react/jsx-runtime";import{itemToString as xS}from"@vuu-ui/vuu-utils";import{ComboBox as vS}from"@vuu-ui/vuu-ui-controls";import _d from"classnames";import{forwardRef as wS,useCallback as as,useMemo as SS,useRef as CS,useState as TS}from"react";import{jsx as Wd}from"react/jsx-runtime";var zd="vuuExpandoCombobox",kS={},_o=wS(function({className:e,InputProps:t=kS,ListProps:n,onInputChange:o,onSelectionChange:i,selectionStrategy:s,style:l,value:a="",...c},u){let[h,f]=TS(a),{itemToString:d=xS}=c,p=CS(a),m=as(b=>{let[C,...k]=b;return k.length?`${d(C)} + ${k.length}`:d(C)},[d]),y=as(b=>{let{value:C}=b.target;console.log(`onInputChange ${C}`),f(C),o==null||o(b)},[o]),g=as(b=>{console.log(`handleSetSelectedText ${b}`),f(b)},[]),[v,w]=SS(()=>{let{inputProps:b,...C}=t;return[{...C,className:`${zd}-Input`,endAdornment:null,inputProps:{...b,autoComplete:"off",onInput:y}},{...n,className:_d("vuuMenuList",n==null?void 0:n.className),"data-mode":"light",displayedItemCount:10,itemHeight:22,maxWidth:300,minWidth:100,width:"auto"}]},[t,y,n]),x=as((b,C)=>{Array.isArray(C)?i==null||i(null,C):C&&(f(d(C)),i==null||i(null,C))},[d,i]),S={minWidth:102};return Wd("div",{className:_d(zd,e),"data-text":h,ref:u,style:l,children:Wd(vS,{...c,PopupProps:S,defaultValue:p.current,fullWidth:!0,ListProps:w,InputProps:v,itemsToString:m,onSelectionChange:x,onSetSelectedText:g,selectionStrategy:s})})});import D_ from"classnames";import{useCallback as O_}from"react";import{forwardRef as MS,useState as ES,useCallback as $d}from"react";import{ExpandoInput as RS}from"@vuu-ui/vuu-ui-controls";import{isValidNumber as Ba}from"@vuu-ui/vuu-utils";import{jsx as PS}from"react/jsx-runtime";var IS=MS(function({InputProps:e,className:t,column:n,onInputComplete:o,value:i},s){let[l,a]=ES(Ba(i)?i.toString():""),c=$d(h=>{let{value:f}=h.target,d=parseFloat(f);Ba(d)&&console.log("its valid"),a(f)},[]),u=$d(h=>{if(h.key==="Enter"){let{value:f}=h.target,d=parseFloat(f);Ba(d)&&o(d)}},[o]);return PS(RS,{...e,className:t,value:l,ref:s,onChange:c,onKeyDown:u})});import{isNumericColumn as fB,isTextColumn as dB}from"@vuu-ui/vuu-utils";import{forwardRef as aT,useCallback as Ms,useEffect as Fp,useMemo as cT,useState as Bp}from"react";import{getFullRange as gB,metadataKeys as DS,WindowRange as yB}from"@vuu-ui/vuu-utils";import{useCallback as xB,useEffect as vB,useMemo as wB,useRef as SB,useState as CB}from"react";var{SELECTED:TB}=DS;import{useCallback as u4,useEffect as h4,useState as f4}from"react";import{EventEmitter as qS,getLoggingConfigForWorker as KS,uuid as jS}from"@vuu-ui/vuu-utils";var zo=(r,e)=>r===e?!0:r===void 0&&e===void 0,LS=({filter:r},{filter:e})=>r===void 0&&(e==null?void 0:e.filter)===""||e===void 0&&(r==null?void 0:r.filter)==="",AS=(r,e)=>{var t,n;return LS(r,e)?!1:((t=r.filter)==null?void 0:t.filter)!==((n=e.filter)==null?void 0:n.filter)},OS=({sort:r},{sort:e})=>r===void 0&&(e==null?void 0:e.sortDefs.length)===0||e===void 0&&(r==null?void 0:r.sortDefs.length)===0,NS=(r,e)=>{let{sort:t}=r,{sort:n}=e;return zo(t,n)||OS(r,e)?!1:t===void 0||n===void 0||(t==null?void 0:t.sortDefs.length)!==(n==null?void 0:n.sortDefs.length)?!0:t.sortDefs.some(({column:o,sortType:i},s)=>o!==n.sortDefs[s].column||i!==n.sortDefs[s].sortType)},Ud=r=>r!==void 0&&r.groupBy!==void 0&&r.groupBy.length>0,Gd=r=>(r==null?void 0:r.filter)!==void 0&&r.filter.filter.length>0,qd=r=>{var e;return(r==null?void 0:r.sort)!==void 0&&Array.isArray((e=r.sort)==null?void 0:e.sortDefs)&&r.sort.sortDefs.length>0},VS=({groupBy:r},{groupBy:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,Ha=(r,e)=>{let{groupBy:t}=r,{groupBy:n}=e;return zo(t,n)||VS(r,e)?!1:t===void 0||n===void 0||(t==null?void 0:t.length)!==(n==null?void 0:n.length)?!0:t.some((o,i)=>o!==(n==null?void 0:n[i]))},FS=({columns:r},{columns:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,BS=(r,e)=>{let{columns:t}=r,{columns:n}=e;return zo(t,n)||FS(r,e)?!1:t===void 0||n===void 0||(t==null?void 0:t.length)!==(n==null?void 0:n.length)?!0:t.some((o,i)=>o!==(n==null?void 0:n[i]))},HS=({aggregations:r},{aggregations:e})=>r===void 0&&(e==null?void 0:e.length)===0||e===void 0&&(r==null?void 0:r.length)===0,_S=(r,e)=>{let{aggregations:t}=r,{aggregations:n}=e;return zo(t,n)||HS(r,e)?!1:t===void 0||n===void 0||t.length!==n.length?!0:t.some(({column:o,aggType:i},s)=>o!==n[s].column||i!==n[s].aggType)},zS=()=>!1,cs=(r,e)=>zo(r,e)?!1:r===void 0||e===void 0?!0:BS(r,e)||AS(r,e)||NS(r,e)||Ha(r,e)||_S(r,e)||zS(r,e),WS=["config","aggregate","viewport-update","columns","debounce-begin","disabled","enabled","filter","groupBy","vuu-link-created","vuu-link-removed","vuu-links","vuu-menu","sort","subscribed"],Kd=r=>{let e=r.type;return WS.includes(e)},jd=r=>["config","aggregate","columns","filter","groupBy","sort"].includes(r.type),$S={filter:""},US={sortDefs:[]},Er={aggregations:[],columns:[],filter:$S,groupBy:[],sort:US},us=r=>{if(r.aggregations&&r.columns&&r.filter&&r.groupBy&&r.sort)return r;{let{aggregations:e=[],columns:t=[],filter:n={filter:""},groupBy:o=[],sort:i={sortDefs:[]},visualLink:s}=r;return{aggregations:e,columns:t,filter:n,groupBy:o,sort:i,visualLink:s}}};var Jd="GET_TABLE_LIST",Qd="GET_TABLE_META";var _a=r=>r.type==="connection-status",Yd=r=>r.type==="connection-metrics",Xd=r=>typeof r.result<"u",Zd=r=>r.type==="TABLE_META_RESP";var ep='\nvar fe=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var p=(s,e,t)=>(fe(s,e,"read from private field"),t?t.call(s):e.get(s)),U=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},me=(s,e,t,n)=>(fe(s,e,"write to private field"),n?n.call(s,t):e.set(s,t),t);function he(s,e,t=[],n=[]){for(let r=0,o=s.length;r<o;r++)(e(s[r],r)?t:n).push(s[r]);return[t,n]}var x={IDX:0,RENDER_IDX:1,IS_LEAF:2,IS_EXPANDED:3,DEPTH:4,COUNT:5,KEY:6,SELECTED:7,count:8,PARENT_IDX:"parent_idx",IDX_POINTER:"idx_pointer",FILTER_COUNT:"filter_count",NEXT_FILTER_IDX:"next_filter_idx"};var{DEPTH:nn,IS_LEAF:rn}=x;var be=s=>{var e,t;if(((e=globalThis.document)==null?void 0:e.cookie)!==void 0)return(t=globalThis.document.cookie.split("; ").find(n=>n.startsWith(`${s}=`)))==null?void 0:t.split("=")[1]};function Y({from:s,to:e},t=0,n=Number.MAX_SAFE_INTEGER){if(t===0)return n<s?{from:0,to:0}:{from:s,to:Math.min(e,n)};if(s===0)return{from:s,to:Math.min(e+t,n)};{let r=e-s,o=Math.round(t/2),a=s-o<0,u=n-(e+o)<0;return a&&u?{from:0,to:n}:a?{from:0,to:r+t}:u?{from:Math.max(0,n-(r+t)),to:n}:{from:s-o,to:e+o}}}var lt=(s,{from:e,to:t})=>s>=e&&s<t;var v=class{constructor(e,t){this.from=e,this.to=t}isWithin(e){return lt(e,this)}overlap(e,t){return e>=this.to||t<this.from?[0,0]:[Math.max(e,this.from),Math.min(t,this.to)]}copy(){return new v(this.from,this.to)}};var{KEY:pn}=x;var ct=["error","warn","info","debug"],pt=s=>typeof s=="string"&&ct.includes(s),dt="error",F=()=>{},gt="error",{loggingLevel:N=gt}=ft(),w=s=>{let e=N==="debug",t=e||N==="info",n=t||N==="warn",r=n||N==="error",o=t?g=>console.info(`[${s}] ${g}`):F,a=n?g=>console.warn(`[${s}] ${g}`):F,u=e?g=>console.debug(`[${s}] ${g}`):F;return{errorEnabled:r,error:r?g=>console.error(`[${s}] ${g}`):F}};function ft(){return typeof loggingSettings<"u"?loggingSettings:{loggingLevel:mt()}}function mt(){let s=be("vuu-logging-level");return pt(s)?s:dt}var{debug:ht,debugEnabled:bt}=w("range-monitor"),W=class{constructor(e){this.source=e;this.range={from:0,to:0};this.timestamp=0}isSet(){return this.timestamp!==0}set({from:e,to:t}){let{timestamp:n}=this;if(this.range.from=e,this.range.to=t,this.timestamp=performance.now(),n)bt&&ht(`<${this.source}> [${e}-${t}], ${(this.timestamp-n).toFixed(0)} ms elapsed`);else return 0}};function Ce(s){return Array.isArray(s)}function Ct(s){return!Array.isArray(s)}var y,ye=class{constructor(){U(this,y,new Map)}addListener(e,t){let n=p(this,y).get(e);n?Ce(n)?n.push(t):Ct(n)&&p(this,y).set(e,[n,t]):p(this,y).set(e,t)}removeListener(e,t){if(!p(this,y).has(e))return;let n=p(this,y).get(e),r=-1;if(n===t)p(this,y).delete(e);else if(Array.isArray(n)){for(let o=length;o-- >0;)if(n[o]===t){r=o;break}if(r<0)return;n.length===1?(n.length=0,p(this,y).delete(e)):n.splice(r,1)}}removeAllListeners(e){e&&p(this,y).has(e)?p(this,y).delete(e):e===void 0&&p(this,y).clear()}emit(e,...t){if(p(this,y)){let n=p(this,y).get(e);n&&this.invokeHandler(n,t)}}once(e,t){let n=(...r)=>{this.removeListener(e,n),t(...r)};this.on(e,n)}on(e,t){this.addListener(e,t)}hasListener(e,t){let n=p(this,y).get(e);return Array.isArray(n)?n.includes(t):n===t}invokeHandler(e,t){if(Ce(e))e.slice().forEach(n=>this.invokeHandler(n,t));else switch(t.length){case 0:e();break;case 1:e(t[0]);break;case 2:e(t[0],t[1]);break;default:e.call(null,...t)}}};y=new WeakMap;var $=String.fromCharCode(8200),m=String.fromCharCode(8199);var wn={DIGIT:m,TWO_DIGITS:m+m,THREE_DIGITS:m+m+m,FULL_PADDING:[null,$+m,$+m+m,$+m+m+m,$+m+m+m+m]};var En=m+m+m+m+m+m+m+m+m;var{COUNT:Bn}=x;var q=class{constructor(e){this.keys=new Map,this.free=[],this.nextKeyValue=0,this.reset(e)}next(){return this.free.length>0?this.free.pop():this.nextKeyValue++}reset({from:e,to:t}){this.keys.forEach((r,o)=>{(o<e||o>=t)&&(this.free.push(r),this.keys.delete(o))});let n=t-e;this.keys.size+this.free.length>n&&(this.free.length=Math.max(0,n-this.keys.size));for(let r=e;r<t;r++)if(!this.keys.has(r)){let o=this.next();this.keys.set(r,o)}this.nextKeyValue>this.keys.size&&(this.nextKeyValue=this.keys.size)}keyFor(e){let t=this.keys.get(e);if(t===void 0)throw console.log(`key not found\n keys: ${this.toDebugString()}\n free : ${this.free.join(",")} \n `),Error(`KeySet, no key found for rowIndex ${e}`);return t}toDebugString(){return Array.from(this.keys.entries()).map((e,t)=>`${e}=>${t}`).join(",")}};var{IDX:Zn}=x;var{SELECTED:er}=x,I={False:0,True:1,First:2,Last:4};var yt=(s,e)=>e>=s[0]&&e<=s[1],St=I.True+I.First+I.Last,Tt=I.True+I.First,Rt=I.True+I.Last,Z=(s,e)=>{for(let t of s)if(typeof t=="number"){if(t===e)return St}else if(yt(t,e))return e===t[0]?Tt:e===t[1]?Rt:I.True;return I.False};var Se=s=>{if(s.every(t=>typeof t=="number"))return s;let e=[];for(let t of s)if(typeof t=="number")e.push(t);else for(let n=t[0];n<=t[1];n++)e.push(n);return e};var wt=(()=>{let s=0,e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(s+=1,`u${e()}${s}`)})();var{debug:ks,debugEnabled:As,error:we,info:V,infoEnabled:It,warn:_}=w("websocket-connection"),Ee="ws",vt=s=>s.startsWith(Ee+"://")||s.startsWith(Ee+"s://"),xe={},ee=Symbol("setWebsocket"),B=Symbol("connectionCallback");async function Ie(s,e,t,n=10,r=5){return xe[s]={status:"connecting",connect:{allowed:r,remaining:r},reconnect:{allowed:n,remaining:n}},ve(s,e,t)}async function Q(s){throw Error("connection broken")}async function ve(s,e,t,n){let{status:r,connect:o,reconnect:a}=xe[s],u=r==="connecting"?o:a;try{t({type:"connection-status",status:"connecting"});let c=typeof n<"u",g=await _t(s,e);console.info("%c\u26A1 %cconnected","font-size: 24px;color: green;font-weight: bold;","color:green; font-size: 14px;"),n!==void 0&&n[ee](g);let i=n!=null?n:new te(g,s,e,t),l=c?"reconnected":"connection-open-awaiting-session";return t({type:"connection-status",status:l}),i.status=l,u.remaining=u.allowed,i}catch{let g=--u.remaining>0;if(t({type:"connection-status",status:"disconnected",reason:"failed to connect",retry:g}),g)return Dt(s,e,t,n,2e3);throw Error("Failed to establish connection")}}var Dt=(s,e,t,n,r)=>new Promise(o=>{setTimeout(()=>{o(ve(s,e,t,n))},r)}),_t=(s,e)=>new Promise((t,n)=>{let r=vt(s)?s:`wss://${s}`;It&&e!==void 0&&V(`WebSocket Protocol ${e==null?void 0:e.toString()}`);let o=new WebSocket(r,e);o.onopen=()=>t(o),o.onerror=a=>n(a)}),Ve=()=>{_==null||_("Connection cannot be closed, socket not yet opened")},Me=s=>{_==null||_(`Message cannot be sent, socket closed ${s.body.type}`)},Pt=s=>{try{return JSON.parse(s)}catch{throw Error(`Error parsing JSON response from server ${s}`)}},te=class{constructor(e,t,n,r){this.close=Ve;this.requiresLogin=!0;this.send=Me;this.status="ready";this.messagesCount=0;this.connectionMetricsInterval=null;this.handleWebsocketMessage=e=>{let t=Pt(e.data);this.messagesCount+=1,this[B](t)};this.url=t,this.protocol=n,this[B]=r,this[ee](e)}reconnect(){Q(this)}[(B,ee)](e){let t=this[B];e.onmessage=o=>{this.status="connected",e.onmessage=this.handleWebsocketMessage,this.handleWebsocketMessage(o)},this.connectionMetricsInterval=setInterval(()=>{t({type:"connection-metrics",messagesLength:this.messagesCount}),this.messagesCount=0},2e3),e.onerror=()=>{we("\u26A1 connection error"),t({type:"connection-status",status:"disconnected",reason:"error"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status==="connection-open-awaiting-session"?we("Websocket connection lost before Vuu session established, check websocket configuration"):this.status!=="closed"&&(Q(this),this.send=r)},e.onclose=()=>{V==null||V("\u26A1 connection close"),t({type:"connection-status",status:"disconnected",reason:"close"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status!=="closed"&&(Q(this),this.send=r)};let n=o=>{e.send(JSON.stringify(o))},r=o=>{V==null||V(`TODO queue message until websocket reconnected ${o.body.type}`)};this.send=n,this.close=()=>{this.status="closed",e.close(),this.close=Ve,this.send=Me,V==null||V("close websocket")}}};var Lt=["VIEW_PORT_MENUS_SELECT_RPC","VIEW_PORT_MENU_TABLE_RPC","VIEW_PORT_MENU_ROW_RPC","VIEW_PORT_MENU_CELL_RPC","VP_EDIT_CELL_RPC","VP_EDIT_ROW_RPC","VP_EDIT_ADD_ROW_RPC","VP_EDIT_DELETE_CELL_RPC","VP_EDIT_DELETE_ROW_RPC","VP_EDIT_SUBMIT_FORM_RPC"],De=s=>Lt.includes(s.type),ne=({requestId:s,...e})=>[s,e],_e=s=>{let e=s.at(0);if(e.updateType==="SIZE"){if(s.length===1)return s;e=s.at(1)}let t=s.at(-1);return[e,t]},Pe=s=>{let e={};for(let t of s)(e[t.viewPortId]||(e[t.viewPortId]=[])).push(t);return e};var re=({columns:s,dataTypes:e,key:t,table:n})=>({table:n,columns:s.map((r,o)=>({name:r,serverDataType:e[o]})),key:t});var Le=s=>s.type==="connection-status",Oe=s=>s.type==="connection-metrics";var ke=s=>"viewport"in s,Ae=s=>s.type==="VIEW_PORT_MENU_RESP"&&s.action!==null&&G(s.action.table),G=s=>s!==null&&typeof s=="object"&&"table"in s&&"module"in s?s.table.startsWith("session"):!1;var Ue="CHANGE_VP_SUCCESS",Fe="CHANGE_VP_RANGE_SUCCESS",Ne="CLOSE_TREE_NODE",We="CLOSE_TREE_SUCCESS";var $e="CREATE_VP",qe="CREATE_VP_SUCCESS",Be="DISABLE_VP",Ge="DISABLE_VP_SUCCESS";var Ke="ENABLE_VP",He="ENABLE_VP_SUCCESS";var se="GET_VP_VISUAL_LINKS",je="GET_VIEW_PORT_MENUS";var ze="HB",Je="HB_RESP",Ye="LOGIN",Ze="LOGIN_SUCCESS",Xe="OPEN_TREE_NODE",Qe="OPEN_TREE_SUCCESS";var et="REMOVE_VP";var oe="RPC_RESP";var tt="SET_SELECTION_SUCCESS",ie="TABLE_META_RESP",ae="TABLE_LIST_RESP",nt="TABLE_ROW";var st=s=>{switch(s){case"TypeAheadRpcHandler":return"TYPEAHEAD";default:return"SIMUL"}};var ot=[],T=w("array-backed-moving-window");function Ot(s,e){if(!e||e.data.length!==s.data.length||e.sel!==s.sel)return!1;for(let t=0;t<e.data.length;t++)if(e.data[t]!==s.data[t])return!1;return!0}var h,K=class{constructor({from:e,to:t},{from:n,to:r},o){U(this,h,void 0);this.setRowCount=e=>{var t;if((t=T.info)==null||t.call(T,`setRowCount ${e}`),e<this.internalData.length&&(this.internalData.length=e),e<this.rowCount){this.rowsWithinRange=0;let n=Math.min(e,this.clientRange.to);for(let r=this.clientRange.from;r<n;r++){let o=r-p(this,h).from;this.internalData[o]!==void 0&&(this.rowsWithinRange+=1)}}this.rowCount=e};this.bufferBreakout=(e,t)=>{let n=this.bufferSize*.25;return p(this,h).to-t<n?!0:p(this,h).from>0&&e-p(this,h).from<n};this.bufferSize=o,this.clientRange=new v(e,t),me(this,h,new v(n,r)),this.internalData=new Array(o),this.rowsWithinRange=0,this.rowCount=0}get range(){return p(this,h)}get hasAllRowsWithinRange(){return this.rowsWithinRange===this.clientRange.to-this.clientRange.from||this.rowCount>0&&this.clientRange.from+this.rowsWithinRange===this.rowCount}outOfRange(e,t){let{from:n,to:r}=this.range;if(t<n||e>=r)return!0}setAtIndex(e){let{rowIndex:t}=e,n=t-p(this,h).from;if(Ot(e,this.internalData[n]))return!1;let r=this.isWithinClientRange(t);return(r||this.isWithinRange(t))&&(!this.internalData[n]&&r&&(this.rowsWithinRange+=1),this.internalData[n]=e),r}getAtIndex(e){return p(this,h).isWithin(e)&&this.internalData[e-p(this,h).from]!=null?this.internalData[e-p(this,h).from]:void 0}isWithinRange(e){return p(this,h).isWithin(e)}isWithinClientRange(e){return this.clientRange.isWithin(e)}setClientRange(e,t){var g;(g=T.debug)==null||g.call(T,`setClientRange ${e} - ${t}`);let n=this.clientRange.from,r=Math.min(this.clientRange.to,this.rowCount);if(e===n&&t===r)return[!1,ot];let o=this.clientRange.copy();this.clientRange.from=e,this.clientRange.to=t,this.rowsWithinRange=0;for(let i=e;i<t;i++){let l=i-p(this,h).from;this.internalData[l]&&(this.rowsWithinRange+=1)}let a=ot,u=p(this,h).from;if(this.hasAllRowsWithinRange)if(t>o.to){let i=Math.max(e,o.to);a=this.internalData.slice(i-u,t-u)}else{let i=Math.min(o.from,t);a=this.internalData.slice(e-u,i-u)}return[this.bufferBreakout(e,t),a]}setRange(e,t){var n,r;if(e!==p(this,h).from||t!==p(this,h).to){(n=T.debug)==null||n.call(T,`setRange ${e} - ${t}`);let[o,a]=p(this,h).overlap(e,t),u=new Array(t-e);this.rowsWithinRange=0;for(let c=o;c<a;c++){let g=this.getAtIndex(c);if(g){let i=c-e;u[i]=g,this.isWithinClientRange(c)&&(this.rowsWithinRange+=1)}}this.internalData=u,p(this,h).from=e,p(this,h).to=t}else(r=T.debug)==null||r.call(T,`setRange ${e} - ${t} IGNORED because not changed`)}get data(){return this.internalData}getData(){var u;let{from:e,to:t}=p(this,h),{from:n,to:r}=this.clientRange,o=Math.max(0,n-e),a=Math.min(t-e,t,r-e,(u=this.rowCount)!=null?u:t);return this.internalData.slice(o,a)}clear(){var e;(e=T.debug)==null||e.call(T,"clear"),this.internalData.length=0,this.rowsWithinRange=0,this.setRowCount(0)}getCurrentDataRange(){let e=this.internalData,t=e.length,[n]=this.internalData,r=this.internalData[t-1];if(n&&r)return[n.rowIndex,r.rowIndex];for(let o=0;o<t;o++)if(e[o]!==void 0){n=e[o];break}for(let o=t-1;o>=0;o--)if(e[o]!==void 0){r=e[o];break}return n&&r?[n.rowIndex,r.rowIndex]:[-1,-1]}};h=new WeakMap;var kt=[],{debug:b,debugEnabled:H,error:At,info:d,infoEnabled:Ut,warn:P}=w("viewport"),Ft=({rowKey:s,updateType:e})=>e==="U"&&!s.startsWith("$root"),j=[void 0,void 0],Nt={count:0,mode:void 0,size:0,ts:0},z=class{constructor({aggregations:e,bufferSize:t=50,columns:n,filter:r,groupBy:o=[],table:a,range:u,sort:c,title:g,viewport:i,visualLink:l},f){this.batchMode=!0;this.hasUpdates=!1;this.pendingUpdates=[];this.pendingOperations=new Map;this.pendingRangeRequests=[];this.rowCountChanged=!1;this.selectedRows=[];this.tableSchema=null;this.useBatchMode=!0;this.lastUpdateStatus=Nt;this.updateThrottleTimer=void 0;this.rangeMonitor=new W("ViewPort");this.disabled=!1;this.isTree=!1;this.status="";this.suspended=!1;this.suspendTimer=null;this.setLastSizeOnlyUpdateSize=e=>{this.lastUpdateStatus.size=e};this.setLastUpdate=e=>{let{ts:t,mode:n}=this.lastUpdateStatus,r=0;if(n===e){let o=Date.now();this.lastUpdateStatus.count+=1,this.lastUpdateStatus.ts=o,r=t===0?0:o-t}else this.lastUpdateStatus.count=1,this.lastUpdateStatus.ts=0,r=0;return this.lastUpdateStatus.mode=e,r};this.rangeRequestAlreadyPending=e=>{let{bufferSize:t}=this,n=t*.25,{from:r}=e;for(let{from:o,to:a}of this.pendingRangeRequests)if(r>=o&&r<a){if(e.to+n<=a)return!0;r=a}return!1};this.sendThrottledSizeMessage=()=>{this.updateThrottleTimer=void 0,this.lastUpdateStatus.count=3,this.postMessageToClient({clientViewportId:this.clientViewportId,mode:"size-only",size:this.lastUpdateStatus.size,type:"viewport-update"})};this.shouldThrottleMessage=e=>{let t=this.setLastUpdate(e);return e==="size-only"&&t>0&&t<500&&this.lastUpdateStatus.count>3};this.throttleMessage=e=>this.shouldThrottleMessage(e)?(d==null||d("throttling updates setTimeout to 2000"),this.updateThrottleTimer===void 0&&(this.updateThrottleTimer=setTimeout(this.sendThrottledSizeMessage,2e3)),!0):(this.updateThrottleTimer!==void 0&&(clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),!1);this.getNewRowCount=()=>{if(this.rowCountChanged&&this.dataWindow)return this.rowCountChanged=!1,this.dataWindow.rowCount};this.aggregations=e,this.bufferSize=t,this.clientRange=u,this.clientViewportId=i,this.columns=n,this.filter=r,this.groupBy=o,this.keys=new q(u),this.pendingLinkedParent=l,this.table=a,this.sort=c,this.title=g,Ut&&(d==null||d(`constructor #${i} ${a.table} bufferSize=${t}`)),this.dataWindow=new K(this.clientRange,u,this.bufferSize),this.postMessageToClient=f}get hasUpdatesToProcess(){return this.suspended?!1:this.rowCountChanged||this.hasUpdates}get size(){var e;return(e=this.dataWindow.rowCount)!=null?e:0}subscribe(){let{filter:e}=this.filter;return this.status=this.status==="subscribed"?"resubscribing":"subscribing",{type:$e,table:this.table,range:Y(this.clientRange,this.bufferSize),aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:e}}}handleSubscribed({viewPortId:e,aggregations:t,columns:n,filterSpec:r,range:o,sort:a,groupBy:u}){return this.serverViewportId=e,this.status="subscribed",this.aggregations=t,this.columns=n,this.groupBy=u,this.isTree=u&&u.length>0,this.dataWindow.setRange(o.from,o.to),{aggregations:t,type:"subscribed",clientViewportId:this.clientViewportId,columns:n,filter:r,groupBy:u,range:o,sort:a,tableSchema:this.tableSchema}}awaitOperation(e,t){this.pendingOperations.set(e,t)}completeOperation(e,...t){var u;let{clientViewportId:n,pendingOperations:r}=this,o=r.get(e);if(!o){At("no matching operation found to complete");return}let{type:a}=o;if(d==null||d(`completeOperation ${a}`),r.delete(e),a==="CHANGE_VP_RANGE"){let[c,g]=t;(u=this.dataWindow)==null||u.setRange(c,g);for(let i=this.pendingRangeRequests.length-1;i>=0;i--){let l=this.pendingRangeRequests[i];if(l.requestId===e){l.acked=!0;break}else P==null||P("range requests sent faster than they are being ACKed")}}else if(a==="config"){let{aggregations:c,columns:g,filter:i,groupBy:l,sort:f}=o.data;return this.aggregations=c,this.columns=g,this.filter=i,this.groupBy=l,this.sort=f,l.length>0?this.isTree=!0:this.isTree&&(this.isTree=!1),b==null||b(`config change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:a,config:o.data}}else{if(a==="groupBy")return this.isTree=o.data.length>0,this.groupBy=o.data,b==null||b(`groupBy change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:a,groupBy:o.data};if(a==="columns")return this.columns=o.data,{clientViewportId:n,type:a,columns:o.data};if(a==="filter")return this.filter=o.data,{clientViewportId:n,type:a,filter:o.data};if(a==="aggregate")return this.aggregations=o.data,{clientViewportId:n,type:"aggregate",aggregations:this.aggregations};if(a==="sort")return this.sort=o.data,{clientViewportId:n,type:a,sort:this.sort};if(a!=="selection"){if(a==="disable")return this.disabled=!0,{type:"disabled",clientViewportId:n};if(a==="enable")return this.disabled=!1,{type:"enabled",clientViewportId:n};if(a==="CREATE_VISUAL_LINK"){let[c,g,i]=t;return this.linkedParent={colName:c,parentViewportId:g,parentColName:i},this.pendingLinkedParent=void 0,{type:"vuu-link-created",clientViewportId:n,colName:c,parentViewportId:g,parentColName:i}}else if(a==="REMOVE_VISUAL_LINK")return this.linkedParent=void 0,{type:"vuu-link-removed",clientViewportId:n}}}}rangeRequest(e,t){H&&this.rangeMonitor.set(t);let n="CHANGE_VP_RANGE";if(this.dataWindow){let[r,o]=this.dataWindow.setClientRange(t.from,t.to),a,u=this.dataWindow.rowCount||void 0,c=r&&!this.rangeRequestAlreadyPending(t)?{type:n,viewPortId:this.serverViewportId,...Y(t,this.bufferSize,u)}:null;if(c){H&&(b==null||b(`create CHANGE_VP_RANGE: [${c.from} - ${c.to}]`)),this.awaitOperation(e,{type:n});let i=this.pendingRangeRequests.at(-1);if(i)if(i.acked)console.warn("Range Request before previous request is filled");else{let{from:l,to:f}=i;this.dataWindow.outOfRange(l,f)?a={clientViewportId:this.clientViewportId,type:"debounce-begin"}:P==null||P("Range Request before previous request is acked")}this.pendingRangeRequests.push({...c,requestId:e}),this.useBatchMode&&(this.batchMode=!0)}else o.length>0&&(this.batchMode=!1);this.keys.reset(this.dataWindow.clientRange);let g=this.isTree?le:ue;return o.length?[c,o.map(i=>g(i,this.keys,this.selectedRows))]:a?[c,void 0,a]:[c]}else return[null]}setLinks(e){return this.links=e,[{type:"vuu-links",links:e,clientViewportId:this.clientViewportId},this.pendingLinkedParent]}setMenu(e){return{type:"vuu-menu",menu:e,clientViewportId:this.clientViewportId}}setTableSchema(e){this.tableSchema=e}openTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Xe,vpId:this.serverViewportId,treeKey:t.key}}closeTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Ne,vpId:this.serverViewportId,treeKey:t.key}}createLink(e,t,n,r){let o={type:"CREATE_VISUAL_LINK",parentVpId:n,childVpId:this.serverViewportId,parentColumnName:r,childColumnName:t};return this.awaitOperation(e,o),this.useBatchMode&&(this.batchMode=!0),o}removeLink(e){let t={type:"REMOVE_VISUAL_LINK",childVpId:this.serverViewportId};return this.awaitOperation(e,t),t}suspend(){this.suspended=!0,d==null||d("suspend")}resume(){return this.suspended=!1,H&&(b==null||b(`resume: ${this.currentData()}`)),this.currentData()}currentData(){let e=[];if(this.dataWindow){let t=this.dataWindow.getData(),{keys:n}=this,r=this.isTree?le:ue;for(let o of t)o&&e.push(r(o,n,this.selectedRows))}return e}enable(e){return this.awaitOperation(e,{type:"enable"}),d==null||d(`enable: ${this.serverViewportId}`),{type:Ke,viewPortId:this.serverViewportId}}disable(e){return this.awaitOperation(e,{type:"disable"}),d==null||d(`disable: ${this.serverViewportId}`),this.suspended=!1,{type:Be,viewPortId:this.serverViewportId}}columnRequest(e,t){return this.awaitOperation(e,{type:"columns",data:t}),b==null||b(`columnRequest: ${t}`),this.createRequest({columns:t})}filterRequest(e,t){this.awaitOperation(e,{type:"filter",data:t}),this.useBatchMode&&(this.batchMode=!0);let{filter:n}=t;return d==null||d(`filterRequest: ${n}`),this.createRequest({filterSpec:{filter:n}})}setConfig(e,t){this.awaitOperation(e,{type:"config",data:t});let{filter:n,...r}=t;return this.useBatchMode&&(this.batchMode=!0),H?b==null||b(`setConfig ${JSON.stringify(t)}`):d==null||d("setConfig"),this.createRequest({...r,filterSpec:typeof(n==null?void 0:n.filter)=="string"?{filter:n.filter}:{filter:""}},!0)}aggregateRequest(e,t){return this.awaitOperation(e,{type:"aggregate",data:t}),d==null||d(`aggregateRequest: ${t}`),this.createRequest({aggregations:t})}sortRequest(e,t){return this.awaitOperation(e,{type:"sort",data:t}),d==null||d(`sortRequest: ${JSON.stringify(t.sortDefs)}`),this.createRequest({sort:t})}groupByRequest(e,t=kt){var n;return this.awaitOperation(e,{type:"groupBy",data:t}),this.useBatchMode&&(this.batchMode=!0),this.isTree||(n=this.dataWindow)==null||n.clear(),this.createRequest({groupBy:t})}selectRequest(e,t){return this.selectedRows=t,this.awaitOperation(e,{type:"selection",data:t}),d==null||d(`selectRequest: ${t}`),{type:"SET_SELECTION",vpId:this.serverViewportId,selection:Se(t)}}removePendingRangeRequest(e,t){for(let n=this.pendingRangeRequests.length-1;n>=0;n--){let{from:r,to:o}=this.pendingRangeRequests[n],a=!0;if(e>=r&&e<o||t>r&&t<o){a||console.warn("removePendingRangeRequest TABLE_ROWS are not for latest request"),this.pendingRangeRequests.splice(n,1);break}else a=!1}}updateRows(e){var r,o,a;let[t,n]=_e(e);if(t&&n&&this.removePendingRangeRequest(t.rowIndex,n.rowIndex),e.length===1)if(t.vpSize===0&&this.disabled){b==null||b(`ignore a SIZE=0 message on disabled viewport (${e.length} rows)`);return}else t.updateType==="SIZE"&&this.setLastSizeOnlyUpdateSize(t.vpSize);for(let u of e)this.isTree&&Ft(u)||((u.updateType==="SIZE"||((r=this.dataWindow)==null?void 0:r.rowCount)!==u.vpSize)&&((o=this.dataWindow)==null||o.setRowCount(u.vpSize),this.rowCountChanged=!0),u.updateType==="U"&&(a=this.dataWindow)!=null&&a.setAtIndex(u)&&(this.hasUpdates=!0,this.batchMode||this.pendingUpdates.push(u)))}getClientRows(){let e,t="size-only";if(!this.hasUpdates&&!this.rowCountChanged)return j;if(this.hasUpdates){let{keys:n,selectedRows:r}=this,o=this.isTree?le:ue;if(this.updateThrottleTimer&&(self.clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),this.pendingUpdates.length>0){e=[],t="update";for(let a of this.pendingUpdates)e.push(o(a,n,r));this.pendingUpdates.length=0}else{let a=this.dataWindow.getData();if(this.dataWindow.hasAllRowsWithinRange){e=[],t="batch";for(let u of a)e.push(o(u,n,r));this.batchMode=!1}}this.hasUpdates=!1}return this.throttleMessage(t)?j:[e,t]}createRequest(e,t=!1){return t?{type:"CHANGE_VP",viewPortId:this.serverViewportId,...e}:{type:"CHANGE_VP",viewPortId:this.serverViewportId,aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:this.filter.filter},...e}}},ue=({rowIndex:s,rowKey:e,sel:t,data:n},r,o)=>[s,r.keyFor(s),!0,!1,0,0,e,t?Z(o,s):0].concat(n),le=({rowIndex:s,rowKey:e,sel:t,data:n},r,o)=>{let[a,u,,c,,g,...i]=n;return[s,r.keyFor(s),c,u,a,g,e,t?Z(o,s):0].concat(i)};var it=1;var{debug:E,debugEnabled:L,error:O,info:S,infoEnabled:Wt,warn:k}=w("server-proxy"),C=()=>`${it++}`,$t={},qt=s=>s.disabled!==!0&&s.suspended!==!0,Bt={type:"NO_ACTION"},Gt=(s,e,t)=>s.map(n=>n.parentVpId===e?{...n,label:t}:n);function Kt(s,e){return s.map(t=>{let{parentVpId:n}=t,r=e.get(n);if(r)return{...t,parentClientVpId:r.clientViewportId,label:r.title};throw Error("addLabelsToLinks viewport not found")})}var J=class{constructor(e,t){this.authToken="";this.user="user";this.pendingTableMetaRequests=new Map;this.pendingRequests=new Map;this.queuedRequests=[];this.cachedTableSchemas=new Map;this.connection=e,this.postMessageToClient=t,this.viewports=new Map,this.mapClientToServerViewport=new Map}async reconnect(){await this.login(this.authToken);let[e,t]=he(Array.from(this.viewports.values()),qt);this.viewports.clear(),this.mapClientToServerViewport.clear();let n=r=>{r.forEach(o=>{let{clientViewportId:a}=o;this.viewports.set(a,o),this.sendMessageToServer(o.subscribe(),a)})};n(e),setTimeout(()=>{n(t)},2e3)}async login(e,t="user"){if(e)return this.authToken=e,this.user=t,new Promise((n,r)=>{this.sendMessageToServer({type:Ye,token:this.authToken,user:t},""),this.pendingLogin={resolve:n,reject:r}});this.authToken===""&&O("login, cannot login until auth token has been obtained")}subscribe(e){if(this.mapClientToServerViewport.has(e.viewport))O(`spurious subscribe call ${e.viewport}`);else{if(!this.hasSchemaForTable(e.table)&&!G(e.table)){S==null||S(`subscribe to ${e.table.table}, no metadata yet, request metadata`);let n=C();this.sendMessageToServer({type:"GET_TABLE_META",table:e.table},n),this.pendingTableMetaRequests.set(n,e.viewport)}let t=new z(e,this.postMessageToClient);this.viewports.set(e.viewport,t),this.sendIfReady(t.subscribe(),e.viewport,this.sessionId!=="")}}unsubscribe(e){let t=this.mapClientToServerViewport.get(e);t?(S==null||S(`Unsubscribe Message (Client to Server):\n ${t}`),this.sendMessageToServer({type:et,viewPortId:t})):O(`failed to unsubscribe client viewport ${e}, viewport not found`)}getViewportForClient(e,t=!0){let n=this.mapClientToServerViewport.get(e);if(n){let r=this.viewports.get(n);if(r)return r;if(t)throw Error(`Viewport not found for client viewport ${e}`);return null}else{if(this.viewports.has(e))return this.viewports.get(e);if(t)throw Error(`Viewport server id not found for client viewport ${e}`);return null}}setViewRange(e,t){let n=C(),[r,o,a]=e.rangeRequest(n,t.range);S==null||S(`setViewRange ${t.range.from} - ${t.range.to}`),r&&this.sendIfReady(r,n,e.status==="subscribed"),o?(S==null||S(`setViewRange ${o.length} rows returned from cache`),this.postMessageToClient({mode:"batch",type:"viewport-update",clientViewportId:e.clientViewportId,rows:o})):a&&this.postMessageToClient(a)}setConfig(e,t){let n=C(),r=e.setConfig(n,t.config);this.sendIfReady(r,n,e.status==="subscribed")}aggregate(e,t){let n=C(),r=e.aggregateRequest(n,t.aggregations);this.sendIfReady(r,n,e.status==="subscribed")}sort(e,t){let n=C(),r=e.sortRequest(n,t.sort);this.sendIfReady(r,n,e.status==="subscribed")}groupBy(e,t){let n=C(),r=e.groupByRequest(n,t.groupBy);this.sendIfReady(r,n,e.status==="subscribed")}filter(e,t){let n=C(),{filter:r}=t,o=e.filterRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}setColumns(e,t){let n=C(),{columns:r}=t,o=e.columnRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}setTitle(e,t){e&&(e.title=t.title,this.updateTitleOnVisualLinks(e))}select(e,t){let n=C(),{selected:r}=t,o=e.selectRequest(n,r);this.sendIfReady(o,n,e.status==="subscribed")}disableViewport(e){let t=C(),n=e.disable(t);this.sendIfReady(n,t,e.status==="subscribed")}enableViewport(e){if(e.disabled){let t=C(),n=e.enable(t);this.sendIfReady(n,t,e.status==="subscribed")}}suspendViewport(e){e.suspend(),e.suspendTimer=setTimeout(()=>{S==null||S("suspendTimer expired, escalate suspend to disable"),this.disableViewport(e)},3e3)}resumeViewport(e){e.suspendTimer&&(E==null||E("clear suspend timer"),clearTimeout(e.suspendTimer),e.suspendTimer=null);let t=e.resume();this.postMessageToClient({clientViewportId:e.clientViewportId,mode:"batch",rows:t,type:"viewport-update"})}openTreeNode(e,t){if(e.serverViewportId){let n=C();this.sendIfReady(e.openTreeNode(n,t),n,e.status==="subscribed")}}closeTreeNode(e,t){if(e.serverViewportId){let n=C();this.sendIfReady(e.closeTreeNode(n,t),n,e.status==="subscribed")}}createLink(e,t){let{parentClientVpId:n,parentColumnName:r,childColumnName:o}=t,a=C(),u=this.mapClientToServerViewport.get(n);if(u){let c=e.createLink(a,o,u,r);this.sendMessageToServer(c,a)}else O("ServerProxy unable to create link, viewport not found")}removeLink(e){let t=C(),n=e.removeLink(t);this.sendMessageToServer(n,t)}updateTitleOnVisualLinks(e){var r;let{serverViewportId:t,title:n}=e;for(let o of this.viewports.values())if(o!==e&&o.links&&t&&n&&(r=o.links)!=null&&r.some(a=>a.parentVpId===t)){let[a]=o.setLinks(Gt(o.links,t,n));this.postMessageToClient(a)}}removeViewportFromVisualLinks(e){var t;for(let n of this.viewports.values())if((t=n.links)!=null&&t.some(({parentVpId:r})=>r===e)){let[r]=n.setLinks(n.links.filter(({parentVpId:o})=>o!==e));this.postMessageToClient(r)}}menuRpcCall(e){let t=this.getViewportForClient(e.vpId,!1);if(t!=null&&t.serverViewportId){let[n,r]=ne(e);this.sendMessageToServer({...r,vpId:t.serverViewportId},n)}}rpcCall(e){let[t,n]=ne(e),r=st(n.service);this.sendMessageToServer(n,t,{module:r})}handleMessageFromClient(e){if(E==null||E(`handleMessageFromClient: ${e.type}`),ke(e))if(e.type==="disable"){let t=this.getViewportForClient(e.viewport,!1);return t!==null?this.disableViewport(t):void 0}else{let t=this.getViewportForClient(e.viewport);switch(e.type){case"setViewRange":return this.setViewRange(t,e);case"config":return this.setConfig(t,e);case"aggregate":return this.aggregate(t,e);case"sort":return this.sort(t,e);case"groupBy":return this.groupBy(t,e);case"filter":return this.filter(t,e);case"select":return this.select(t,e);case"suspend":return this.suspendViewport(t);case"resume":return this.resumeViewport(t);case"enable":return this.enableViewport(t);case"openTreeNode":return this.openTreeNode(t,e);case"closeTreeNode":return this.closeTreeNode(t,e);case"createLink":return this.createLink(t,e);case"removeLink":return this.removeLink(t);case"setColumns":return this.setColumns(t,e);case"setTitle":return this.setTitle(t,e);default:}}else{if(De(e))return this.menuRpcCall(e);{let{type:t,requestId:n}=e;switch(t){case"GET_TABLE_LIST":return this.sendMessageToServer({type:t},n);case"GET_TABLE_META":return this.sendMessageToServer({type:t,table:e.table},n);case"RPC_CALL":return this.rpcCall(e);default:}}}O(`Vuu ServerProxy Unexpected message from client ${JSON.stringify(e)}`)}awaitResponseToMessage(e){return new Promise((t,n)=>{let r=C();this.sendMessageToServer(e,r),this.pendingRequests.set(r,{reject:n,resolve:t})})}sendIfReady(e,t,n=!0){return n?this.sendMessageToServer(e,t):this.queuedRequests.push(e),n}sendMessageToServer(e,t=`${it++}`,n=$t){let{module:r="CORE"}=n;this.authToken&&this.connection.send({requestId:t,sessionId:this.sessionId,token:this.authToken,user:this.user,module:r,body:e})}handleMessageFromServer(e){var u;let{body:t,requestId:n,sessionId:r}=e,o=this.pendingRequests.get(n);if(o){let{resolve:i}=o;this.pendingRequests.delete(n),i(t);return}let{viewports:a}=this;switch(t.type){case ze:this.sendMessageToServer({type:Je,ts:+new Date},"NA");break;case Ze:if(r)this.sessionId=r,(u=this.pendingLogin)==null||u.resolve(r),this.pendingLogin=void 0;else throw Error("LOGIN_SUCCESS did not provide sessionId");break;case qe:{let i=a.get(n);if(i){let{status:l}=i,{viewPortId:f}=t;n!==f&&(a.delete(n),a.set(f,i)),this.mapClientToServerViewport.set(n,f);let R=i.handleSubscribed(t);R&&(this.postMessageToClient(R),L&&E(`post DataSourceSubscribedMessage to client: ${JSON.stringify(R)}`)),i.disabled&&this.disableViewport(i),l==="subscribing"&&!G(i.table)&&(this.sendMessageToServer({type:se,vpId:f}),this.sendMessageToServer({type:je,vpId:f}),Array.from(a.entries()).filter(([M,{disabled:A}])=>M!==f&&!A).forEach(([M])=>{this.sendMessageToServer({type:se,vpId:M})}))}}break;case"REMOVE_VP_SUCCESS":{let i=a.get(t.viewPortId);i&&(this.mapClientToServerViewport.delete(i.clientViewportId),a.delete(t.viewPortId),this.removeViewportFromVisualLinks(t.viewPortId))}break;case tt:{let i=this.viewports.get(t.vpId);i&&i.completeOperation(n)}break;case Ue:case Ge:if(a.has(t.viewPortId)){let i=this.viewports.get(t.viewPortId);if(i){let l=i.completeOperation(n);l!==void 0&&(this.postMessageToClient(l),L&&E(`postMessageToClient ${JSON.stringify(l)}`))}}break;case He:{let i=this.viewports.get(t.viewPortId);if(i){let l=i.completeOperation(n);if(l){this.postMessageToClient(l);let f=i.currentData();L&&E(`Enable Response (ServerProxy to Client): ${JSON.stringify(l)}`),i.size===0?L&&E("Viewport Enabled but size 0, resend to server"):(this.postMessageToClient({clientViewportId:i.clientViewportId,mode:"batch",rows:f,size:i.size,type:"viewport-update"}),L&&E(`Enable Response (ServerProxy to Client): send size ${i.size} ${f.length} rows from cache`))}}}break;case nt:{let i=Pe(t.rows);for(let[l,f]of Object.entries(i)){let R=a.get(l);R?R.updateRows(f):k==null||k(`TABLE_ROW message received for non registered viewport ${l}`)}this.processUpdates()}break;case Fe:{let i=this.viewports.get(t.viewPortId);if(i){let{from:l,to:f}=t;i.completeOperation(n,l,f)}}break;case Qe:case We:break;case"CREATE_VISUAL_LINK_SUCCESS":{let i=this.viewports.get(t.childVpId),l=this.viewports.get(t.parentVpId);if(i&&l){let{childColumnName:f,parentColumnName:R}=t,M=i.completeOperation(n,f,l.clientViewportId,R);M&&this.postMessageToClient(M)}}break;case"REMOVE_VISUAL_LINK_SUCCESS":{let i=this.viewports.get(t.childVpId);if(i){let l=i.completeOperation(n);l&&this.postMessageToClient(l)}}break;case ae:this.postMessageToClient({type:ae,tables:t.tables,requestId:n});break;case ie:{let i=this.cacheTableMeta(t),l=this.pendingTableMetaRequests.get(n);if(l){this.pendingTableMetaRequests.delete(n);let f=this.viewports.get(l);f?f.setTableSchema(i):k==null||k("Message has come back AFTER CREATE_VP_SUCCESS, what do we do now")}else this.postMessageToClient({type:ie,tableSchema:i,requestId:n})}break;case"VP_VISUAL_LINKS_RESP":{let i=this.getActiveLinks(t.links),l=this.viewports.get(t.vpId);if(i.length&&l){let f=Kt(i,this.viewports),[R,M]=l.setLinks(f);if(this.postMessageToClient(R),M){let{link:A,parentClientVpId:at}=M,de=C(),ge=this.mapClientToServerViewport.get(at);if(ge){let ut=l.createLink(de,A.fromColumn,ge,A.toColumn);this.sendMessageToServer(ut,de)}}}}break;case"VIEW_PORT_MENUS_RESP":if(t.menu.name){let i=this.viewports.get(t.vpId);if(i){let l=i.setMenu(t.menu);this.postMessageToClient(l)}}break;case"VP_EDIT_RPC_RESPONSE":this.postMessageToClient({action:t.action,requestId:n,rpcName:t.rpcName,type:"VP_EDIT_RPC_RESPONSE"});break;case"VP_EDIT_RPC_REJECT":this.viewports.get(t.vpId)&&this.postMessageToClient({requestId:n,type:"VP_EDIT_RPC_REJECT",error:t.error});break;case"VIEW_PORT_MENU_RESP":if(Ae(t)){let{action:i,rpcName:l}=t;this.awaitResponseToMessage({type:"GET_TABLE_META",table:i.table}).then(f=>{let R=re(f);this.postMessageToClient({rpcName:l,type:"VIEW_PORT_MENU_RESP",action:{...i,tableSchema:R},tableAlreadyOpen:this.isTableOpen(i.table),requestId:n})})}else{let{action:i}=t;this.postMessageToClient({type:"VIEW_PORT_MENU_RESP",action:i||Bt,tableAlreadyOpen:i!==null&&this.isTableOpen(i.table),requestId:n})}break;case oe:{let{method:i,result:l}=t;this.postMessageToClient({type:oe,method:i,result:l,requestId:n})}break;case"ERROR":O(t.msg);break;default:Wt&&S(`handleMessageFromServer ${t.type}.`)}}hasSchemaForTable(e){return this.cachedTableSchemas.has(`${e.module}:${e.table}`)}cacheTableMeta(e){let{module:t,table:n}=e.table,r=`${t}:${n}`,o=this.cachedTableSchemas.get(r);return o||(o=re(e),this.cachedTableSchemas.set(r,o)),o}isTableOpen(e){if(e){let t=e.table;for(let n of this.viewports.values())if(!n.suspended&&n.table.table===t)return!0}}getActiveLinks(e){return e.filter(t=>{let n=this.viewports.get(t.parentVpId);return n&&!n.suspended})}processUpdates(){this.viewports.forEach(e=>{var t;if(e.hasUpdatesToProcess){let n=e.getClientRows();if(n!==j){let[r,o]=n,a=e.getNewRowCount();(a!==void 0||r&&r.length>0)&&(L&&E(`postMessageToClient #${e.clientViewportId} viewport-update ${o}, ${(t=r==null?void 0:r.length)!=null?t:"no"} rows, size ${a}`),o&&this.postMessageToClient({clientViewportId:e.clientViewportId,mode:o,rows:r,size:a,type:"viewport-update"}))}}})}};var D,{info:ce,infoEnabled:pe}=w("worker");async function Ht(s,e,t,n,r,o,a){let u=await Ie(s,e,c=>{Oe(c)?(console.log("post connection metrics"),postMessage({type:"connection-metrics",messages:c})):Le(c)?(r(c),c.status==="reconnected"&&D.reconnect()):D.handleMessageFromServer(c)},o,a);D=new J(u,c=>jt(c)),u.requiresLogin&&await D.login(t,n)}function jt(s){postMessage(s)}var zt=async({data:s})=>{switch(s.type){case"connect":await Ht(s.url,s.protocol,s.token,s.username,postMessage,s.retryLimitDisconnect,s.retryLimitStartup),postMessage({type:"connected"});break;case"subscribe":pe&&ce(`client subscribe: ${JSON.stringify(s)}`),D.subscribe(s);break;case"unsubscribe":pe&&ce(`client unsubscribe: ${JSON.stringify(s)}`),D.unsubscribe(s.viewport);break;default:pe&&ce(`client message: ${JSON.stringify(s)}`),D.handleMessageFromClient(s)}};self.addEventListener("message",zt);postMessage({type:"ready"});\n\n';var JS=new Blob([KS()+ep],{type:"text/javascript"}),QS=URL.createObjectURL(JS),Rr,za,Wa=[],YS,XS,tp=new Promise((r,e)=>{YS=r,XS=e}),Ga=()=>tp,hs=new Map,fs=new Map,ZS=async({handleConnectionStatusChange:r,protocol:e,retryLimitDisconnect:t,retryLimitStartup:n,token:o="",username:i,url:s})=>o===""&&za===void 0?new Promise(l=>{Wa.push({resolve:l})}):za||(za=new Promise(l=>{let a=new Worker(QS),c=window.setTimeout(()=>{console.error("timed out waiting for worker to load")},1e3);a.onmessage=u=>{let{data:h}=u;if(h.type==="ready")window.clearTimeout(c),a.postMessage({protocol:e,retryLimitDisconnect:t,retryLimitStartup:n,token:o,type:"connect",url:s,username:i});else if(h.type==="connected"){a.onmessage=np,l(a);for(let f of Wa)f.resolve(a);Wa.length=0}else _a(h)?r({data:h}):console.warn("ConnectionManager: Unexpected message from the worker")}}));function np({data:r}){if(Kd(r)){let e=hs.get(r.clientViewportId);e?e.postMessageToClientDataSource(r):console.error(`[ConnectionManager] ${r.type} message received, viewport not found`)}else if(_a(r))ds.emit("connection-status",r);else if(Yd(r))ds.emit("connection-metrics",r);else{let e=r.requestId;if(fs.has(e)){let{resolve:t}=fs.get(e);fs.delete(e);let{type:n,requestId:o,...i}=r;Xd(r)?t(r.result):r.type==="VP_EDIT_RPC_RESPONSE"||r.type==="VP_EDIT_RPC_REJECT"?t(r):Zd(r)?t(r.tableSchema):t(i)}else console.warn("%cConnectionManager Unexpected message from the worker","color:red;font-weight:bold;")}}var $a=r=>{let e=jS();return Rr.postMessage({requestId:e,...r}),new Promise((t,n)=>{fs.set(e,{resolve:t,reject:n})})},eC={subscribe:(r,e)=>{hs.set(r.viewport,{status:"subscribing",request:r,postMessageToClientDataSource:e}),Rr.postMessage({type:"subscribe",...r})},unsubscribe:r=>{Rr.postMessage({type:"unsubscribe",viewport:r})},send:r=>{Rr.postMessage(r)},destroy:r=>{r&&hs.has(r)&&hs.delete(r)},rpcCall:async r=>$a(r),getTableList:async()=>$a({type:Jd}),getTableSchema:async r=>$a({type:Qd,table:r})},Ua=class extends qS{async connect({url:e,authToken:t,username:n,protocol:o,retryLimitDisconnect:i,retryLimitStartup:s}){return Rr=await ZS({protocol:o,url:e,token:t,username:n,retryLimitDisconnect:i,retryLimitStartup:s,handleConnectionStatusChange:np}),eC}destroy(){Rr.terminate()}},ds=new Ua;var rp=async r=>{try{return(await tp).rpcCall(r)}catch{throw Error("Error accessing server api")}};var tC=0,Wo=class{constructor(e,t){this.from=e,this.to=t}},J=class{constructor(e={}){this.id=tC++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=ke.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};J.closedBy=new J({deserialize:r=>r.split(" ")});J.openedBy=new J({deserialize:r=>r.split(" ")});J.group=new J({deserialize:r=>r.split(" ")});J.contextHash=new J({perNode:!0});J.lookAhead=new J({perNode:!0});J.mounted=new J({perNode:!0});var nC=Object.create(null),ke=class{constructor(e,t,n,o=0){this.name=e,this.props=t,this.id=n,this.flags=o}static define(e){let t=e.props&&e.props.length?Object.create(null):nC,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),o=new ke(e.name||"",t,e.id,n);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(o)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}}return o}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(J.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let o of n.split(" "))t[o]=e[n];return n=>{for(let o=n.prop(J.group),i=-1;i<(o?o.length:0);i++){let s=t[i<0?n.name:o[i]];if(s)return s}}}};ke.none=new ke("",Object.create(null),0,8);var Kn=class{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let o=null;for(let i of e){let s=i(n);s&&(o||(o=Object.assign({},n.props)),o[s[0].id]=s[1])}t.push(o?new ke(n.name,o,n.id,n.flags):n)}return new Kn(t)}},ps=new WeakMap,op=new WeakMap,ye;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays"})(ye||(ye={}));var le=class{constructor(e,t,n,o,i){if(this.type=e,this.children=t,this.positions=n,this.length=o,this.props=null,i&&i.length){this.props=Object.create(null);for(let[s,l]of i)this.props[typeof s=="number"?s:s.id]=l}}toString(){let e=this.prop(J.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let o=n.toString();o&&(t&&(t+=","),t+=o)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Pr(this.topNode,e)}cursorAt(e,t=0,n=0){let o=ps.get(this)||this.topNode,i=new Pr(o);return i.moveTo(e,t),ps.set(this,i._tree),i}get topNode(){return new It(this,0,0,null)}resolve(e,t=0){let n=Ir(ps.get(this)||this.topNode,e,t,!1);return ps.set(this,n),n}resolveInner(e,t=0){let n=Ir(op.get(this)||this.topNode,e,t,!0);return op.set(this,n),n}iterate(e){let{enter:t,leave:n,from:o=0,to:i=this.length}=e,s=e.mode||0,l=(s&ye.IncludeAnonymous)>0;for(let a=this.cursor(s|ye.IncludeAnonymous);;){let c=!1;if(a.from<=i&&a.to>=o&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ja(ke.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,o)=>new le(this.type,t,n,o,this.propValues),e.makeTree||((t,n,o)=>new le(ke.none,t,n,o)))}static build(e){return rC(e)}};le.empty=new le(ke.none,[],[],0);var $o=class{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new $o(this.buffer,this.index)}},Zt=class{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return ke.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],o=this.set.types[t],i=o.name;if(/\W/.test(i)&&!o.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let s=[];for(;e<n;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,t,n,o,i){let{buffer:s}=this,l=-1;for(let a=e;a!=t&&!(sp(i,o,s[a+1],s[a+2])&&(l=a,n>0));a=s[a+3]);return l}slice(e,t,n){let o=this.buffer,i=new Uint16Array(t-e),s=0;for(let l=e,a=0;l<t;){i[a++]=o[l++],i[a++]=o[l++]-n;let c=i[a++]=o[l++]-n;i[a++]=o[l++]-e,s=Math.max(s,c)}return new Zt(i,s,this.set)}};function sp(r,e,t,n){switch(r){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function lp(r,e){let t=r.childBefore(e);for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(r=t,t=n.prevSibling):t=n}return r}function Ir(r,e,t,n){for(var o;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to<e);){let s=!n&&r instanceof It&&r.index<0?null:r.parent;if(!s)return r;r=s}let i=n?0:ye.IgnoreOverlays;if(n)for(let s=r,l=s.parent;l;s=l,l=s.parent)s instanceof It&&s.index<0&&((o=l.enter(e,t,i))===null||o===void 0?void 0:o.from)!=s.from&&(r=l);for(;;){let s=r.enter(e,t,i);if(!s)return r;r=s}}var It=class{constructor(e,t,n,o){this._tree=e,this.from=t,this.index=n,this._parent=o}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,o,i=0){for(let s=this;;){for(let{children:l,positions:a}=s._tree,c=t>0?l.length:-1;e!=c;e+=t){let u=l[e],h=a[e]+s.from;if(sp(o,n,h,h+u.length)){if(u instanceof Zt){if(i&ye.ExcludeBuffers)continue;let f=u.findChild(0,u.buffer.length,t,n-h,o);if(f>-1)return new Bt(new qa(s,u,e,h),null,f)}else if(i&ye.IncludeAnonymous||!u.type.isAnonymous||ja(u)){let f;if(!(i&ye.IgnoreMounts)&&u.props&&(f=u.prop(J.mounted))&&!f.overlay)return new It(f.tree,h,e,s);let d=new It(u,h,e,s);return i&ye.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?u.children.length-1:0,t,n,o)}}}if(i&ye.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+t:e=t<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let o;if(!(n&ye.IgnoreOverlays)&&(o=this._tree.prop(J.mounted))&&o.overlay){let i=e-this.from;for(let{from:s,to:l}of o.overlay)if((t>0?s<=i:s<i)&&(t<0?l>=i:l>i))return new It(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new Pr(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return Ir(this,e,t,!1)}resolveInner(e,t=0){return Ir(this,e,t,!0)}enterUnfinishedNodesBefore(e){return lp(this,e)}getChild(e,t=null,n=null){let o=gs(this,e,t,n);return o.length?o[0]:null}getChildren(e,t=null,n=null){return gs(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return ys(this,e)}};function gs(r,e,t,n){let o=r.cursor(),i=[];if(!o.firstChild())return i;if(t!=null){for(;!o.type.is(t);)if(!o.nextSibling())return i}for(;;){if(n!=null&&o.type.is(n))return i;if(o.type.is(e)&&i.push(o.node),!o.nextSibling())return n==null?i:[]}}function ys(r,e,t=e.length-1){for(let n=r.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}var qa=class{constructor(e,t,n,o){this.parent=e,this.buffer=t,this.index=n,this.start=o}},Bt=class{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new Bt(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&ye.ExcludeBuffers)return null;let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new Bt(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Bt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Bt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new Pr(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,o=this.index+4,i=n.buffer[this.index+3];if(i>o){let s=n.buffer[this.index+1];e.push(n.slice(o,i,s)),t.push(0)}return new le(this.type,e,t,this.to-this.from)}resolve(e,t=0){return Ir(this,e,t,!1)}resolveInner(e,t=0){return Ir(this,e,t,!0)}enterUnfinishedNodesBefore(e){return lp(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let o=gs(this,e,t,n);return o.length?o[0]:null}getChildren(e,t=null,n=null){return gs(this,e,t,n)}get node(){return this}matchContext(e){return ys(this,e)}},Pr=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof It)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:o}=this.buffer;return this.type=t||o.set.types[o.buffer[e]],this.from=n+o.buffer[e+1],this.to=n+o.buffer[e+2],!0}yield(e){return e?e instanceof It?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:o}=this.buffer,i=o.findChild(this.index+4,o.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&ye.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ye.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ye.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let o=n<0?0:this.stack[n]+4;if(this.index!=o)return this.yieldBuf(t.findChild(o,this.index,-1,0,4))}else{let o=t.buffer[this.index+3];if(o<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(o)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:o}=this;if(o){if(e>0){if(this.index<o.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(o.buffer.buffer[i+3]<this.index)return!1;({index:t,parent:n}=o)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let i=t+e,s=e<0?-1:n._tree.children.length;i!=s;i+=e){let l=n._tree.children[i];if(this.mode&ye.IncludeAnonymous||l instanceof Zt||!l.type.isAnonymous||ja(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let o=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==o){if(o==this.index)return s;t=s,n=i+1;break e}o=this.stack[--i]}for(let o=n;o<this.stack.length;o++)t=new Bt(this.buffer,t,this.stack[o]);return this.bufferNode=new Bt(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let o=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(o=!0)}for(;o&&t&&t(this),o=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,o=!0}}}matchContext(e){if(!this.buffer)return ys(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let o=e.length-1,i=this.stack.length-1;o>=0;i--){if(i<0)return ys(this.node,e,o);let s=n[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[o]&&e[o]!=s.name)return!1;o--}}return!0}};function ja(r){return r.children.some(e=>e instanceof Zt||!e.type.isAnonymous||ja(e))}function rC(r){var e;let{buffer:t,nodeSet:n,maxBufferLength:o=1024,reused:i=[],minRepeatType:s=n.types.length}=r,l=Array.isArray(t)?new $o(t,t.length):t,a=n.types,c=0,u=0;function h(x,S,b,C,k){let{id:E,start:R,end:M,size:P}=l,I=u;for(;P<0;)if(l.next(),P==-1){let N=i[E];b.push(N),C.push(R-x);return}else if(P==-3){c=E;return}else if(P==-4){u=E;return}else throw new RangeError(`Unrecognized record size: ${P}`);let V=a[E],B,W,O=R-x;if(M-R<=o&&(W=m(l.pos-S,k))){let N=new Uint16Array(W.size-W.skip),F=l.pos-W.size,G=N.length;for(;l.pos>F;)G=y(W.start,N,G);B=new Zt(N,M-W.start,n),O=W.start-x}else{let N=l.pos-P;l.next();let F=[],G=[],X=E>=s?E:-1,te=0,_e=M;for(;l.pos>N;)X>=0&&l.id==X&&l.size>=0?(l.end<=_e-o&&(d(F,G,R,te,l.end,_e,X,I),te=F.length,_e=l.end),l.next()):h(R,N,F,G,X);if(X>=0&&te>0&&te<F.length&&d(F,G,R,te,R,_e,X,I),F.reverse(),G.reverse(),X>-1&&te>0){let de=f(V);B=Ja(V,F,G,0,F.length,0,M-R,de,de)}else B=p(V,F,G,M-R,I-M)}b.push(B),C.push(O)}function f(x){return(S,b,C)=>{let k=0,E=S.length-1,R,M;if(E>=0&&(R=S[E])instanceof le){if(!E&&R.type==x&&R.length==C)return R;(M=R.prop(J.lookAhead))&&(k=b[E]+R.length+M)}return p(x,S,b,C,k)}}function d(x,S,b,C,k,E,R,M){let P=[],I=[];for(;x.length>C;)P.push(x.pop()),I.push(S.pop()+b-k);x.push(p(n.types[R],P,I,E-k,M-E)),S.push(k-b)}function p(x,S,b,C,k=0,E){if(c){let R=[J.contextHash,c];E=E?[R].concat(E):[R]}if(k>25){let R=[J.lookAhead,k];E=E?[R].concat(E):[R]}return new le(x,S,b,C,E)}function m(x,S){let b=l.fork(),C=0,k=0,E=0,R=b.end-o,M={size:0,start:0,skip:0};e:for(let P=b.pos-x;b.pos>P;){let I=b.size;if(b.id==S&&I>=0){M.size=C,M.start=k,M.skip=E,E+=4,C+=4,b.next();continue}let V=b.pos-I;if(I<0||V<P||b.start<R)break;let B=b.id>=s?4:0,W=b.start;for(b.next();b.pos>V;){if(b.size<0)if(b.size==-3)B+=4;else break e;else b.id>=s&&(B+=4);b.next()}k=W,C+=I,E+=B}return(S<0||C==x)&&(M.size=C,M.start=k,M.skip=E),M.size>4?M:void 0}function y(x,S,b){let{id:C,start:k,end:E,size:R}=l;if(l.next(),R>=0&&C<s){let M=b;if(R>4){let P=l.pos-(R-4);for(;l.pos>P;)b=y(x,S,b)}S[--b]=M,S[--b]=E-x,S[--b]=k-x,S[--b]=C}else R==-3?c=C:R==-4&&(u=C);return b}let g=[],v=[];for(;l.pos>0;)h(r.start||0,r.bufferStart||0,g,v,-1);let w=(e=r.length)!==null&&e!==void 0?e:g.length?v[0]+g[0].length:0;return new le(a[r.topID],g.reverse(),v.reverse(),w)}var ip=new WeakMap;function ms(r,e){if(!r.isAnonymous||e instanceof Zt||e.type!=r)return 1;let t=ip.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=r||!(n instanceof le)){t=1;break}t+=ms(r,n)}ip.set(e,t)}return t}function Ja(r,e,t,n,o,i,s,l,a){let c=0;for(let p=n;p<o;p++)c+=ms(r,e[p]);let u=Math.ceil(c*1.5/8),h=[],f=[];function d(p,m,y,g,v){for(let w=y;w<g;){let x=w,S=m[w],b=ms(r,p[w]);for(w++;w<g;w++){let C=ms(r,p[w]);if(b+C>=u)break;b+=C}if(w==x+1){if(b>u){let C=p[x];d(C.children,C.positions,0,C.children.length,m[x]+v);continue}h.push(p[x])}else{let C=m[w-1]+p[w-1].length-S;h.push(Ja(r,p,m,x,w,S,C,null,a))}f.push(S+v-i)}}return d(e,t,n,o,0),(l||a)(h,f,s)}var Ht=class{constructor(e,t,n,o,i=!1,s=!1){this.from=e,this.to=t,this.tree=n,this.offset=o,this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let o=[new Ht(0,e.length,e,0,!1,n)];for(let i of t)i.to>e.length&&o.push(i);return o}static applyChanges(e,t,n=128){if(!t.length)return e;let o=[],i=1,s=e.length?e[0]:null;for(let l=0,a=0,c=0;;l++){let u=l<t.length?t[l]:null,h=u?u.fromA:1e9;if(h-a>=n)for(;s&&s.from<h;){let f=s;if(a>=f.from||h<=f.to||c){let d=Math.max(f.from,a)-c,p=Math.min(f.to,h)-c;f=d>=p?null:new Ht(d,p,f.tree,f.offset+c,l>0,!!u)}if(f&&o.push(f),s.to>h)break;s=i<e.length?e[i++]:null}if(!u)break;a=u.toA,c=u.toA-u.toB}return o}},Dr=class{startParse(e,t,n){return typeof e=="string"&&(e=new Ka(e)),n=n?n.length?n.map(o=>new Wo(o.from,o.to)):[new Wo(0,0)]:[new Wo(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let o=this.startParse(e,t,n);for(;;){let i=o.advance();if(i)return i}}},Ka=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var GB=new J({perNode:!0});var Ar=class{constructor(e,t,n,o,i,s,l,a,c,u=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=o,this.pos=i,this.score=s,this.buffer=l,this.bufferBase=a,this.curContext=c,this.lookAhead=u,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let o=e.parser.context;return new Ar(e,[],t,n,n,0,[],0,o?new bs(o,o.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,o=e&65535,{parser:i}=this.p,s=i.dynamicPrecedence(o);if(s&&(this.score+=s),n==0){this.pushState(i.getGoto(this.state,o,!0),this.reducePos),o<i.minRepeatTerm&&this.storeNode(o,this.reducePos,this.reducePos,4,!0),this.reduceContext(o,this.reducePos);return}let l=this.stack.length-(n-1)*3-(e&262144?6:0),a=l?this.stack[l-2]:this.p.ranges[0].from,c=this.reducePos-a;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[o])===null||t===void 0)&&t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=c));let u=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-u;if(o<i.minRepeatTerm||e&131072){let f=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(o,a,f,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=i.getGoto(f,o,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(o,a)}storeNode(e,t,n,o=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,l=this.buffer.length;if(l==0&&s.parent&&(l=s.bufferBase-s.parent.bufferBase,s=s.parent),l>0&&s.buffer[l-4]==0&&s.buffer[l-1]>-1){if(t==n)return;if(s.buffer[l-2]>=t){s.buffer[l-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,o);else{let s=this.buffer.length;if(s>0&&this.buffer[s-4]!=0)for(;s>0&&this.buffer[s-2]>n;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,o>4&&(o-=4);this.buffer[s]=e,this.buffer[s+1]=t,this.buffer[s+2]=n,this.buffer[s+3]=o}}shift(e,t,n){let o=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=n,this.shiftContext(t,o),t<=this.p.parser.maxNode&&this.buffer.push(t,o,n,4);else{let i=e,{parser:s}=this.p;(n>this.pos||t<=s.maxNode)&&(this.pos=n,s.stateFlag(i,1)||(this.reducePos=n)),this.pushState(i,o),this.shiftContext(t,o),t<=s.maxNode&&this.buffer.push(t,o,n,4)}}apply(e,t,n){e&65536?this.reduce(e):this.shift(e,t,n)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let o=this.pos;this.reducePos=this.pos=o+e.length,this.pushState(t,o),this.buffer.push(n,o,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),o=e.bufferBase+t;for(;e&&o==e.bufferBase;)e=e.parent;return new Ar(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,o,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Ya(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>4<<1||this.stack.length>=120){let o=[];for(let i=0,s;i<t.length;i+=2)(s=t[i+1])!=this.state&&this.p.parser.hasAction(s,e)&&o.push(t[i],s);if(this.stack.length<120)for(let i=0;o.length<4<<1&&i<t.length;i+=2){let s=t[i+1];o.some((l,a)=>a&1&&l==s)||o.push(t[i],s)}t=o}let n=[];for(let o=0;o<t.length&&n.length<4;o+=2){let i=t[o+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(t[o],this.pos),s.score-=200,n.push(s)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,o=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],o,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;t=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(o,i)=>{if(!t.includes(o))return t.push(o),e.allActions(o,s=>{if(!(s&393216))if(s&65536){let l=(s>>19)-i;if(l>1){let a=s&65535,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],a,!1)>=0)return l<<19|65536|a}}else{let l=n(s,i+1);if(l!=null)return l}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new bs(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},bs=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},ap;(function(r){r[r.Insert=200]="Insert",r[r.Delete=190]="Delete",r[r.Reduce=100]="Reduce",r[r.MaxNext=4]="MaxNext",r[r.MaxInsertStackDepth=300]="MaxInsertStackDepth",r[r.DampenInsertStackDepth=120]="DampenInsertStackDepth",r[r.MinBigReduction=2e3]="MinBigReduction"})(ap||(ap={}));var Ya=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let o=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=o}},Or=class{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Or(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Or(this.stack,this.pos,this.index)}};function Uo(r,e=Uint16Array){if(typeof r!="string")return r;let t=null;for(let n=0,o=0;n<r.length;){let i=0;for(;;){let s=r.charCodeAt(n++),l=!1;if(s==126){i=65535;break}s>=92&&s--,s>=34&&s--;let a=s-32;if(a>=46&&(a-=46,l=!0),i+=a,l)break;i*=46}t?t[o++]=i:t=new e(i)}return t}var Lr=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},cp=new Lr,Xa=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=cp,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,o=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!o)return null;let s=this.ranges[--o];i-=n.from-s.to,n=s}for(;t<0?i>n.to:i>=n.to;){if(o==this.ranges.length-1)return null;let s=this.ranges[++o];i+=s.from-n.to,n=s}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,o;if(t>=0&&t<this.chunk.length)n=this.pos+e,o=this.chunk.charCodeAt(t);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(n=i,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)o=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let s=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),o=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),o}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=cp,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let o of this.ranges){if(o.from>=t)break;o.to>e&&(n+=this.input.read(Math.max(o.from,e),Math.min(o.to,t)))}return n}},yn=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;gp(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};yn.prototype.contextual=yn.prototype.fallback=yn.prototype.extend=!1;var Za=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?Uo(e):e}token(e,t){let n=e.pos,o=0;for(;;){let i=e.next<0,s=e.resolveOffset(1,1);if(gp(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(i||o++,s==null)break;e.reset(s,e.token)}o&&(e.reset(n,e.token),e.acceptToken(this.elseToken,o))}};Za.prototype.contextual=yn.prototype.fallback=yn.prototype.extend=!1;function gp(r,e,t,n,o,i){let s=0,l=1<<n,{dialect:a}=t.p.parser;e:for(;l&r[s];){let c=r[s+1];for(let d=s+3;d<c;d+=2)if((r[d+1]&l)>0){let p=r[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||iC(p,e.token.value,o,i))){e.acceptToken(p);break}}let u=e.next,h=0,f=r[s+2];if(e.next<0&&f>h&&r[c+f*3-3]==65535&&r[c+f*3-3]==65535){s=r[c+f*3-1];continue e}for(;h<f;){let d=h+f>>1,p=c+d+(d<<1),m=r[p],y=r[p+1]||65536;if(u<m)f=d;else if(u>=y)h=d+1;else{s=r[p+2],e.advance();continue e}}break}}function up(r,e,t){for(let n=e,o;(o=r[n])!=65535;n++)if(o==t)return n-e;return-1}function iC(r,e,t,n){let o=up(t,n,e);return o<0||up(t,n,r)<o}var Pt=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),Qa=null,hp;(function(r){r[r.Margin=25]="Margin"})(hp||(hp={}));function fp(r,e,t){let n=r.cursor(ye.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(r.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:r.length}}var ec=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?fp(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?fp(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],o=this.index[t];if(o==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[o],s=this.start[t]+n.positions[o];if(s>e)return this.nextStart=s,null;if(i instanceof le){if(s==e){if(s<this.safeFrom)return null;let l=s+i.length;if(l<=this.safeTo){let a=i.prop(J.lookAhead);if(!a||l+a<this.fragment.to)return i}}this.index[t]++,s+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+i.length}}},tc=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Lr)}getActions(e){let t=0,n=null,{parser:o}=e.p,{tokenizers:i}=o,s=o.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let c=0;c<i.length;c++){if(!(1<<c&s))continue;let u=i[c],h=this.tokens[c];if(!(n&&!u.fallback)&&((u.contextual||h.start!=e.pos||h.mask!=s||h.context!=l)&&(this.updateCachedToken(h,u,e),h.mask=s,h.context=l),h.lookAhead>h.end+25&&(a=Math.max(h.lookAhead,a)),h.value!=0)){let f=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!u.extend&&(n=h,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Lr,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Lr,{pos:n,p:o}=e;return t.start=n,t.end=Math.min(n+1,o.stream.end),t.value=n==o.stream.end?o.parser.eofTerm:0,t}updateCachedToken(e,t,n){let o=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(o,e),n),e.value>-1){let{parser:i}=n.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==e.value){let l=i.specializers[s](this.stream.read(e.start,e.end),n);if(l>=0&&n.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(o+1)}putAction(e,t,n,o){for(let i=0;i<o;i+=3)if(this.actions[i]==e)return o;return this.actions[o++]=e,this.actions[o++]=t,this.actions[o++]=n,o}addActions(e,t,n,o){let{state:i}=e,{parser:s}=e.p,{data:l}=s;for(let a=0;a<2;a++)for(let c=s.stateSlot(i,a?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=en(l,c+2);else{o==0&&l[c+1]==2&&(o=this.putAction(en(l,c+2),t,n,o));break}l[c]==t&&(o=this.putAction(en(l,c+1),t,n,o))}return o}},dp;(function(r){r[r.Distance=5]="Distance",r[r.MaxRemainingPerStep=3]="MaxRemainingPerStep",r[r.MinBufferLengthPrune=500]="MinBufferLengthPrune",r[r.ForceReduceLimit=10]="ForceReduceLimit",r[r.CutDepth=15e3]="CutDepth",r[r.CutTo=9e3]="CutTo",r[r.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",r[r.MaxStackCount=12]="MaxStackCount"})(dp||(dp={}));var nc=class{constructor(e,t,n,o){this.parser=e,this.input=t,this.ranges=o,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Xa(t,o),this.tokens=new tc(e,this.stream),this.topTerm=e.top[1];let{from:i}=o[0];this.stacks=[Ar.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new ec(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],o,i;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let l=e[s];for(;;){if(this.tokens.mainToken=null,l.pos>t)n.push(l);else{if(this.advanceStack(l,n,e))continue;{o||(o=[],i=[]),o.push(l);let a=this.tokens.getMainToken(l);i.push(a.value,a.end)}}break}}if(!n.length){let s=o&&sC(o);if(s)return this.stackToTree(s);if(this.parser.strict)throw Pt&&o&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&o){let s=this.stoppedAt!=null&&o[0].pos>this.stoppedAt?o[0]:this.runRecovery(o,i,n);if(s)return this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(n.length>s)for(n.sort((l,a)=>a.score-l.score);n.length>s;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let s=0;s<n.length-1;s++){let l=n[s];for(let a=s+1;a<n.length;a++){let c=n[a];if(l.sameState(c)||l.buffer.length>500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.buffer.length)>0)n.splice(a--,1);else{n.splice(s--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let s=1;s<n.length;s++)n[s].pos<this.minStackPos&&(this.minStackPos=n[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let o=e.pos,{parser:i}=this,s=Pt?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&o>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let h=this.fragments.nodeAt(o);h;){let f=this.parser.nodeSet.types[h.type.id]==h.type?i.getGoto(e.state,h.type.id):-1;if(f>-1&&h.length&&(!c||(h.prop(J.contextHash)||0)==u))return e.useNode(h,f),Pt&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(h.type.id)})`),!0;if(!(h instanceof le)||h.children.length==0||h.positions[0]>0)break;let d=h.children[0];if(d instanceof le&&h.positions[0]==0)h=d;else break}}let l=i.stateSlot(e.state,4);if(l>0)return e.reduce(l),Pt&&console.log(s+this.stackID(e)+` (via always-reduce ${i.getName(l&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let c=0;c<a.length;){let u=a[c++],h=a[c++],f=a[c++],d=c==a.length||!n,p=d?e:e.split();if(p.apply(u,h,f),Pt&&console.log(s+this.stackID(p)+` (via ${u&65536?`reduce of ${i.getName(u&65535)}`:"shift"} for ${i.getName(h)} @ ${o}${p==e?"":", split"})`),d)return!0;p.pos>o?t.push(p):n.push(p)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return pp(e,t),!0}}runRecovery(e,t,n){let o=null,i=!1;for(let s=0;s<e.length;s++){let l=e[s],a=t[s<<1],c=t[(s<<1)+1],u=Pt?this.stackID(l)+" -> ":"";if(l.deadEnd&&(i||(i=!0,l.restart(),Pt&&console.log(u+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let h=l.split(),f=u;for(let d=0;h.forceReduce()&&d<10&&(Pt&&console.log(f+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,n));d++)Pt&&(f=this.stackID(h)+" -> ");for(let d of l.recoverByInsert(a))Pt&&console.log(u+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,n);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),Pt&&console.log(u+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),pp(l,n)):(!o||o.score<l.score)&&(o=l)}return o}stackToTree(e){return e.close(),le.build({buffer:Or.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(Qa||(Qa=new WeakMap)).get(e);return t||Qa.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function pp(r,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==r.pos&&n.sameState(r)){e[t].score<r.score&&(e[t]=r);return}}e.push(r)}var rc=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}};var jn=class extends Dr{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let n=Object.keys(e.topRules).map(l=>e.topRules[l][1]),o=[];for(let l=0;l<t.length;l++)o.push([]);function i(l,a,c){o[l].push([a,a.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=J[a]);for(let c=1;c<l.length;){let u=l[c++];if(u>=0)i(u,a,l[c++]);else{let h=l[c+-u];for(let f=-u;f>0;f--)i(l[c++],a,h);c++}}}this.nodeSet=new Kn(t.map((l,a)=>ke.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:o[a],top:n.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let s=Uo(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(mp),this.states=Uo(e.states,Uint32Array),this.data=Uo(e.stateData),this.goto=Uo(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new yn(s,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let o=new nc(this,e,t,n);for(let i of this.wrappers)o=i(o,e,t,n);return o}getGoto(e,t,n=!1){let o=this.goto;if(t>=o[0])return-1;for(let i=o[t+1];;){let s=o[i++],l=s&1,a=o[i++];if(l&&n)return a;for(let c=i+(s>>1);i<c;i++)if(o[i]==e)return a;if(l)return-1}}hasAction(e,t){let n=this.data;for(let o=0;o<2;o++)for(let i=this.stateSlot(e,o?2:1),s;;i+=3){if((s=n[i])==65535)if(n[i+1]==1)s=n[i=en(n,i+2)];else{if(n[i+1]==2)return en(n,i+2);break}if(s==t||s==0)return en(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),o=n?t(n):void 0;for(let i=this.stateSlot(e,1);o==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=en(this.data,i+2);else break;o=t(en(this.data,i+1))}return o}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=en(this.data,n+2);else break;if(!(this.data[n+2]&1)){let o=this.data[n+1];t.some((i,s)=>s&1&&i==o)||t.push(this.data[n],o)}}return t}configure(e){let t=Object.assign(Object.create(jn.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let o=e.tokenizers.find(i=>i.from==n);return o?o.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,o)=>{let i=e.specializers.find(l=>l.from==n.external);if(!i)return n;let s=Object.assign(Object.assign({},n),{external:i.to});return t.specializers[o]=mp(s),s})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let i of e.split(" ")){let s=t.indexOf(i);s>=0&&(n[s]=!0)}let o=null;for(let i=0;i<t.length;i++)if(!n[i])for(let s=this.dialects[t[i]],l;(l=this.data[s++])!=65535;)(o||(o=new Uint8Array(this.maxTerm+1)))[l]=1;return new rc(e,n,o)}static deserialize(e){return new jn(e)}};function en(r,e){return r[e]|r[e+1]<<16}function sC(r){let e=null;for(let t of r){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function mp(r){if(r.external){let e=r.extend?1:0;return(t,n)=>r.external(t,n)<<1|e}return r.get}var Go=jn.deserialize({version:14,states:"%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",stateData:"#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",goto:"#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",nodeNames:"\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:"6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",tokenizers:[0,1],topRules:{Filter:[0,1]},tokenPrec:0});import{isMultiClauseFilter as qo,isMultiValueFilter as lC,isSingleValueFilter as aC}from"@vuu-ui/vuu-utils";var Qe,oc=class{constructor(){ee(this,Qe,void 0)}setFilterCombinatorOp(e,t=T(this,Qe)){qo(t)&&t.op===e||z(this,Qe,{op:e,filters:[T(this,Qe)]})}add(e){if(T(this,Qe)===void 0)z(this,Qe,e);else if(qo(T(this,Qe)))T(this,Qe).filters.push(e);else throw Error("Invalid filter passed to FilterExpression")}setColumn(e,t=T(this,Qe)){if(qo(t)){let n=t.filters.at(-1);n&&this.setColumn(e,n)}else t&&(t.column=e)}setOp(e,t=T(this,Qe)){if(qo(t)){let n=t.filters.at(-1);n&&this.setOp(e,n)}else t&&(t.op=e)}setValue(e,t=T(this,Qe)){var n;if(qo(t)){let o=t.filters.at(-1);o&&this.setValue(e,o)}else lC(t)?((n=t.values)!=null||(t.values=[]),t.values.push(e)):aC(t)&&(t.value=e)}toJSON(e=T(this,Qe)){return this.name?{...e,name:this.name}:e}};Qe=new WeakMap;var xs=(r,e)=>{let t=new oc,n=r.cursor();do{let{name:o,from:i,to:s}=n;switch(o){case"ColumnValueExpression":t.add({});break;case"ColumnSetExpression":t.add({op:"in"});break;case"Or":case"And":t.setFilterCombinatorOp(e.substring(i,s));break;case"Column":t.setColumn(e.substring(i,s));break;case"Operator":t.setOp(e.substring(i,s));break;case"String":t.setValue(e.substring(i+1,s-1));break;case"Number":t.setValue(parseFloat(e.substring(i,s)));break;case"True":t.setValue(!0);break;case"False":t.setValue(!1);break;case"FilterName":t.name=e.substring(i,s);break;default:}}while(n.next());return t.toJSON()};var cC=Go.configure({strict:!0}),Jn=r=>{let e=cC.parse(r);return xs(e,r)};function vs(r,e){switch(e.op){case"in":return uC(r,e);case"=":return hC(r,e);case">":return fC(r,e);case">=":return dC(r,e);case"<":return pC(r,e);case"<=":return mC(r,e);case"starts":return gC(r,e);case"and":return yC(r,e);case"or":return bC(r,e);default:return console.log(`unrecognized filter type ${e.op}`),()=>!0}}var uC=(r,e)=>t=>e.values.indexOf(t[r[e.column]])!==-1,hC=(r,e)=>t=>t[r[e.column]]===e.value,fC=(r,e)=>t=>t[r[e.column]]>e.value,dC=(r,e)=>t=>t[r[e.column]]>=e.value,pC=(r,e)=>t=>t[r[e.column]]<e.value,mC=(r,e)=>t=>t[r[e.column]]<=e.value,gC=(r,e)=>{let t=e.value;if(typeof t!="string")throw Error("string filter applied to value of wrong type");return n=>{let o=n[r[e.column]];if(typeof o!="string")throw Error("string filter applied to value of wrong type");return o.toLowerCase().startsWith(t.toLowerCase())}},yC=(r,e)=>{let t=e.filters.map(n=>vs(r,n));return n=>t.every(o=>o(n))};function bC(r,e){let t=e.filters.map(n=>vs(r,n));return n=>t.some(o=>o(n))}import{buildColumnMap as LC,EventEmitter as AC,getAddedItems as OC,getMissingItems as NC,getSelectionStatus as VC,KeySet as FC,logger as BC,metadataKeys as HC,NULL_RANGE as kp,rangeNewItems as _C,resetRange as Ko,uuid as Mp}from"@vuu-ui/vuu-utils";var yp=(r,e,t,n,o,i)=>{let s=Qn(o,r),l=r[r.length-1].aggType,a=t.map(c=>o[c]);switch(l){case 1:return xp(i,n,o,r,e,a);case 2:return xC(i,n,o,r,e,a);case 3:return bp(i,o,r,e,a);case 4:return wC(i,n,o,r,e,a);case 5:return SC(i,n,o,r,e,a);case 6:return vC(i,n,o,r,e,a)}};function bp(r,e,t,n,o){let i={},s=Qn(e,t);function l(a){if(Array.isArray(a))return a.length;{let c=0;for(let u in a)c+=1+l(a[u]);return c}}for(let a in r){let c=l(r[a]);i[a]=c}for(let a=0;a<n.length;a++)for(let c in i)n[a][o[0]]===c&&(n[a][s]=i[c]);return console.log("!!!! targetData",n),console.log("!!!! counts",i),i}function Qn(r,e){console.log("!!!! aggregation length",e.length);let t=e[e.length-1].column;return r[t]}function xp(r,e,t,n,o,i){let s={},l=Qn(t,n);function a(c,u,h){if(Array.isArray(c)){let f=0;for(let d of c)f+=Number(u[d][h]);return f}else{let f=0;for(let d in c)f+=a(c[d],u,h);return f}}for(let c in r){console.log(c);let u=Number(a(r[c],e,l));s[c]=u}for(let c=0;c<o.length;c++)for(let u in s)o[c][i[0]]===u&&(o[c][l]=s[u]);return console.log("!!!! targetData",o),console.log("!!!! sums",s),s}function xC(r,e,t,n,o,i){let s={},l=Qn(t,n),a=bp(r,t,n,o,i),c=xp(r,e,t,n,o,i);for(let u in a){let h=0;h=c[u]/a[u],s[u]=h}for(let u=0;u<o.length;u++)for(let h in s)o[u][i[0]]===h&&(o[u][l]=s[h]);return console.log("!!!! targetData",o),console.log("!!!! averages",s),s}function ws(r,e,t){let n=[];if(Array.isArray(r))for(let o of r)n.push(e[o][t]);else for(let o in r)n.push(...ws(r[o],e,t));return n}function vC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=ws(r[a],e,l),u=[...new Set(c)];s[a]=u}for(let a=0;a<o.length;a++)for(let c in s)o[a][i[0]]===c&&(o[a][l]=s[c]);return s}function wC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=ws(r[a],e,l),u=Math.max(...c);s[a]=u}for(let a=0;a<o.length;a++)for(let c in s)o[a][i[0]]===c&&(o[a][l]=s[c]);return s}function SC(r,e,t,n,o,i){let s={},l=Qn(t,n);for(let a in r){let c=ws(r[a],e,l),u=Math.min(...c);s[a]=u}for(let a=0;a<o.length;a++)for(let c in s)o[a][i[0]]===c&&(o[a][l]=s[c]);return s}import{metadataKeys as CC}from"@vuu-ui/vuu-utils";var{DEPTH:ic,IS_EXPANDED:vp,KEY:sc}=CC,wp=(r,e)=>{let t=[];for(let n=0,o=0,i=!1,s=e.length;n<s;n++){let l=e[n],{[ic]:a,[sc]:c}=l;if(c===r){let u=l.slice();for(u[vp]=!1,t.push(u),o+=1,i=!0;n<s-1&&e[n+1][ic]>a;)n+=1}else if(i){let u=l.slice();u[0]=o,u[1]=o,t.push(u),o+=1}else t.push(l),o+=1}return t},lc=(r,e,t,n,o,i)=>{let s=t.map(l=>n[l]);return Sp(o,s,r,e,void 0,void 0,void 0,i)},Sp=(r,e,t,n=[],o="$root",i=1,s=[],l)=>{let a=Object.keys(r).sort();for(let c of a){let u=s.length,h=`${o}|${c}`,f=[u,u,!1,!1,i,0,h,0];f[e[i-1]]=c,s.push(f),t.includes(h)&&(f[vp]=!0,Array.isArray(r[c])?TC(s,r[c],n,h,i+1):Sp(r[c],e,t,n,h,i+1,s,l))}for(let c in s)for(let u in s)if(s[c][2]===!1&&l[u]!=null&&s[c][e[0]]===l[u][e[0]]){s[c]=s[c].splice(0,8).concat(l[u].slice(8,l[u].length));break}return s},TC=(r,e,t,n,o)=>{for(let i of e){let s=r.length,l=t[i].slice();l[0]=s,l[1]=s,l[ic]=o,l[sc]=`${n}|${l[sc]}`,r.push(l)}},Cp=(r,e,t)=>{let n=e.map(s=>t[s]),o=MC(r,n);return[kC(o,n),o]},kC=(r,e)=>{let n=[],o=0,i=Object.keys(r).sort();for(let s of i){let l=[o,o,!1,!1,1,0,`$root|${s}`,0];l[e[0]]=s,n.push(l),o+=1}return n};function MC(r,e){let t={},n=e.length,o=n-1;for(let i=0,s=r.length;i<s;i++){let l=r[i],a=t,c,u;for(let h=0;h<n;h++){let f=e[h];u=l[f].toString(),c=a[u],c&&h===o?c.push(i):c?a=c:!c&&h<o?a=a[u]={}:c||(a[u]=[i])}}return console.log("!! groups",t),t}var EC=(r,e,[t,n])=>{let o=n==="D"?e[t]:r[t],i=n==="D"?r[t]:e[t];return o===i?0:i===null||o>i?1:-1},RC=r=>r.length===1?IC(r):r.length===2?PC(r):DC(r),IC=([[r,e]])=>(t,n)=>{let o=e==="D"?n[r]:t[r],i=e==="D"?t[r]:n[r];return o>i?1:i>o?-1:0},PC=([[r,e],[t,n]])=>(o,i)=>{let s=e==="D"?i[r]:o[r],l=e==="D"?o[r]:i[r],a=n==="D"?i[t]:o[t],c=n==="D"?o[t]:i[t];return s>l?1:l>s?-1:a>c?1:c>a?-1:0},DC=(r,e=EC)=>(t,n)=>{for(let o of r){let i=e(t,n,o);if(i!==0)return i}return 0},Tp=(r,{sortDefs:e},t)=>{let n=e.map(({column:i,sortType:s})=>[t[i],s]),o=RC(n);return r.slice().sort(o)};var{debug:ht}=BC("ArrayDataSource"),{RENDER_IDX:zC,SELECTED:WC}=HC,$C=(r,e)=>[e,e,!0,!1,1,0,r[0].toString(),0,...r],UC=r=>({columns:r.map(({name:t,serverDataType:n="string"})=>({name:t,serverDataType:n})),key:r[0].name,table:{module:"",table:"Array"}}),GC=(r,e,t)=>{let[n]=r,o=r.slice();return o[zC]=e.keyFor(n),o[WC]=VC(t,n),o},jo,Dt,Q,Ae,ve,Ss,Jo,Nr,Ep=class extends AC{constructor({aggregations:t,columnDescriptors:n,data:o,filter:i,groupBy:s,rangeChangeRowset:l="delta",sort:a,title:c,viewport:u}){super();this.status="initialising";this.disabled=!1;this.selectedRows=[];this.suspended=!1;this.lastRangeServed={from:0,to:0};this.openTreeNodes=[];ee(this,jo,[]);ee(this,Dt,void 0);ee(this,Q,Er);ee(this,Ae,void 0);ee(this,ve,kp);ee(this,Ss,0);ee(this,Jo,0);ee(this,Nr,void 0);this.keys=new FC(T(this,ve));this.processedData=void 0;if(console.log("ArrayDataSource",{columnDescriptors:n}),!o||!n)throw Error("ArrayDataSource constructor called without data or without columnDescriptors");this.columnDescriptors=n,z(this,jo,n.map(h=>h.name)),z(this,Dt,LC(T(this,jo))),this.rangeChangeRowset=l,this.tableSchema=UC(n),z(this,Ae,o.map($C)),this.viewport=u||Mp(),z(this,Jo,o.length),z(this,Nr,c),this.config={...T(this,Q),aggregations:t||T(this,Q).aggregations,columns:n.map(h=>h.name),filter:i||T(this,Q).filter,groupBy:s||T(this,Q).groupBy,sort:a||T(this,Q).sort},ht==null||ht(`columnMap: ${JSON.stringify(T(this,Dt))}`)}async subscribe({viewport:t=(u=>(u=this.viewport)!=null?u:Mp())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var h;this.clientCallback=c,this.viewport=t,this.status="subscribed",this.lastRangeServed={from:0,to:0},o||n||a||l||s?(i&&z(this,ve,i),this.config={...T(this,Q),aggregations:o||T(this,Q).aggregations,columns:n||T(this,Q).columns,filter:a||T(this,Q).filter,groupBy:l||T(this,Q).groupBy,sort:s||T(this,Q).sort}):((h=this.clientCallback)==null||h.call(this,{...T(this,Q),type:"subscribed",clientViewportId:this.viewport,range:T(this,ve),tableSchema:this.tableSchema}),this.clientCallback({clientViewportId:this.viewport,mode:"size-only",type:"viewport-update",size:T(this,Ae).length}),i?this.range=i:T(this,ve)!==kp&&this.sendRowsToClient())}unsubscribe(){console.log("unsubscribe noop")}suspend(){return console.log("noop"),this}resume(){return console.log("resume noop"),this}disable(){return console.log("disable noop"),this}enable(){return console.log("enable noop"),this}select(t){ht==null||ht(`select ${JSON.stringify(t)}`),this.selectedRows=t,this.setRange(Ko(T(this,ve)),!0)}openTreeNode(t){this.openTreeNodes.push(t),this.processedData=lc(this.openTreeNodes,T(this,Ae),T(this,Q).groupBy,T(this,Dt),this.groupMap,this.processedData),this.setRange(Ko(T(this,ve)),!0)}closeTreeNode(t){this.openTreeNodes=this.openTreeNodes.filter(n=>n!==t),this.processedData&&(this.processedData=wp(t,this.processedData),this.setRange(Ko(T(this,ve)),!0))}get data(){return T(this,Ae)}get currentData(){var t;return(t=this.processedData)!=null?t:T(this,Ae)}get table(){return this.tableSchema.table}get config(){return T(this,Q)}set config(t){var n;if(cs(T(this,Q),t)){if(t){let o=T(this,Q),i=(n=t==null?void 0:t.filter)!=null&&n.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Jn(t.filter.filter)}}:t;z(this,Q,us(i));let s;if(Gd(t)){let{filter:l,filterStruct:a=Jn(l)}=t.filter;if(a){let c=vs(T(this,Dt),a);s=T(this,Ae).filter(c)}else throw Error("filter must include filterStruct")}if(qd(t)&&(s=Tp(s!=null?s:T(this,Ae),t.sort,T(this,Dt))),this.openTreeNodes.length>0&&Ha(o,t)&&(T(this,Q).groupBy.length===0?this.openTreeNodes.length=0:console.log("adjust the openTReeNodes groupBy changed ",{originalGroupBy:o.groupBy,newGroupBy:i.groupBy})),Ud(t)){let[l,a]=Cp(s!=null?s:T(this,Ae),t.groupBy,T(this,Dt));this.groupMap=a,s=l,this.openTreeNodes.length>0&&(s=lc(this.openTreeNodes,T(this,Ae),T(this,Q).groupBy,T(this,Dt),this.groupMap,s))}this.processedData=s==null?void 0:s.map((l,a)=>{let c=l.slice();return c[0]=a,c[1]=a,c})}this.setRange(Ko(T(this,ve)),!0),this.emit("config",T(this,Q))}}get selectedRowsCount(){return T(this,Ss)}get size(){return T(this,Jo)}get range(){return T(this,ve)}set range(t){(t.from!==T(this,ve).from||t.to!==T(this,ve).to)&&this.setRange(t)}setRange(t,n=!1){z(this,ve,t),this.keys.reset(t),this.sendRowsToClient(n)}sendRowsToClient(t=!1){var s,l;let n=this.rangeChangeRowset==="delta"&&!t?_C(this.lastRangeServed,T(this,ve)):T(this,ve),o=(s=this.processedData)!=null?s:T(this,Ae),i=o.slice(n.from,n.to).map(a=>GC(a,this.keys,this.selectedRows));(l=this.clientCallback)==null||l.call(this,{clientViewportId:this.viewport,mode:"batch",rows:i,size:o.length,type:"viewport-update"}),this.lastRangeServed=T(this,ve)}get columns(){return T(this,Q).columns}set columns(t){let n=OC(this.config.columns,t);if(n.length>0){let o=NC(this.columnDescriptors,n,i=>i.name);console.log("columnsWithoutDescriptors",{columnsWithoutDescriptors:o})}this.config={...T(this,Q),columns:t}}get aggregations(){return T(this,Q).aggregations}set aggregations(t){var i;z(this,Q,{...T(this,Q),aggregations:t});let n=(i=this.processedData)!=null?i:T(this,Ae),o=T(this,Ae);yp(t,n,T(this,Q).groupBy,o,T(this,Dt),this.groupMap),this.setRange(Ko(T(this,ve)),!0),this.emit("config",T(this,Q))}get sort(){return T(this,Q).sort}set sort(t){console.log("set sort",{sort:t}),ht==null||ht(`sort ${JSON.stringify(t)}`),this.config={...T(this,Q),sort:t}}get filter(){return T(this,Q).filter}set filter(t){ht==null||ht(`filter ${JSON.stringify(t)}`),this.config={...T(this,Q),filter:t}}get groupBy(){return T(this,Q).groupBy}set groupBy(t){this.config={...T(this,Q),groupBy:t}}get title(){return T(this,Nr)}set title(t){z(this,Nr,t)}get _clientCallback(){return this.clientCallback}createLink({parentVpId:t,link:{fromColumn:n,toColumn:o}}){console.log("create link",{parentVpId:t,fromColumn:n,toColumn:o})}removeLink(){console.log("remove link")}findRow(t){let n=T(this,Ae)[t];if(n)return n;throw`no row found for key ${t}`}updateRow(t,n,o){let i=this.findRow(parseInt(t));console.log({row:i,colName:n,value:o})}applyEdit(t,n,o){return console.log(`ArrayDataSource applyEdit ${t} ${n} ${o}`),!0}async menuRpcCall(t){return new Promise(n=>{let{type:o}=t;switch(o){case"VP_EDIT_CELL_RPC":{let{rowKey:i,field:s,value:l}=t;try{this.updateRow(i,s,l),n(void 0)}catch(a){n({error:String(a),type:"VP_EDIT_RPC_REJECT"})}}break;default:n(void 0)}})}};jo=new WeakMap,Dt=new WeakMap,Q=new WeakMap,Ae=new WeakMap,ve=new WeakMap,Ss=new WeakMap,Jo=new WeakMap,Nr=new WeakMap;import{EventEmitter as qC,isSelected as KC,jsonToDataSourceRows as jC,KeySet as JC,metadataKeys as QC,uuid as Rp}from"@vuu-ui/vuu-utils";var YC={columns:[],key:"",table:{module:"",table:""}},{DEPTH:Vr,IDX:Ip,IS_EXPANDED:XC,IS_LEAF:ZC,KEY:Op,SELECTED:Pp}=QC,Dp=(r,e)=>{let[t]=r,n=r.slice();return n[1]=e.keyFor(t),n},bn,ft,Ye,xn,vn,_t,Cs,Ts,wn,Fr,Lp=class extends qC{constructor({aggregations:t,data:n,filter:o,groupBy:i,sort:s,title:l,viewport:a}){super();this.status="initialising";this.expandedRows=new Set;this.visibleRows=[];ee(this,bn,[]);ee(this,ft,Er);ee(this,Ye,void 0);ee(this,xn,{filter:""});ee(this,vn,[]);ee(this,_t,{from:0,to:0});ee(this,Cs,0);ee(this,Ts,0);ee(this,wn,{sortDefs:[]});ee(this,Fr,void 0);this.keys=new JC(T(this,_t));if(!n)throw Error("JsonDataSource constructor called without data");[this.columnDescriptors,Ah(this,Ye)._]=jC(n),this.visibleRows=T(this,Ye).filter(c=>c[Vr]===0).map((c,u)=>[u,u].concat(c.slice(2))),this.viewport=a||Rp(),t&&z(this,bn,t),this.columnDescriptors&&z(this,ft,{...T(this,ft),columns:this.columnDescriptors.map(c=>c.name)}),o&&z(this,xn,o),i&&z(this,vn,i),s&&z(this,wn,s),z(this,Fr,l)}async subscribe({viewport:t=(u=>(u=this.viewport)!=null?u:Rp())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var h;this.clientCallback=c,o&&z(this,bn,o),n&&z(this,ft,{...T(this,ft),columns:n}),a&&z(this,xn,a),l&&z(this,vn,l),i&&z(this,_t,i),s&&z(this,wn,s),this.status==="initialising"&&(this.viewport=t,this.status="subscribed",(h=this.clientCallback)==null||h.call(this,{aggregations:T(this,bn),type:"subscribed",clientViewportId:this.viewport,columns:T(this,ft).columns,filter:T(this,xn),groupBy:T(this,vn),range:T(this,_t),sort:T(this,wn),tableSchema:YC}),this.clientCallback({clientViewportId:this.viewport,mode:"size-only",type:"viewport-update",size:this.visibleRows.length}))}unsubscribe(){console.log("noop")}suspend(){return console.log("noop"),this}resume(){return console.log("noop"),this}disable(){return console.log("noop"),this}enable(){return console.log("noop"),this}select(t){var o;let n=[];for(let i of T(this,Ye)){let{[Ip]:s,[Pp]:l}=i,a=l===1,c=KC(t,s);if(c!==a){let u=i.slice();u[Pp]=c?1:0,T(this,Ye)[s]=u,n.push(u)}}n.length>0&&((o=this.clientCallback)==null||o.call(this,{clientViewportId:this.viewport,mode:"update",type:"viewport-update",rows:n}))}openTreeNode(t){var i;this.expandedRows.add(t),this.visibleRows=Ap(T(this,Ye),this.expandedRows);let{from:n,to:o}=T(this,_t);(i=this.clientCallback)==null||i.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(n,o).map(s=>Dp(s,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}closeTreeNode(t,n=!1){if(this.expandedRows.delete(t),n)for(let o of this.expandedRows.keys())o.startsWith(t)&&this.expandedRows.delete(o);this.visibleRows=Ap(T(this,Ye),this.expandedRows),this.sendRowsToClient()}get config(){return T(this,ft)}get selectedRowsCount(){return T(this,Cs)}get size(){return T(this,Ts)}get range(){return T(this,_t)}set range(t){z(this,_t,t),this.keys.reset(t),requestAnimationFrame(()=>{this.sendRowsToClient()})}sendRowsToClient(){var o;let{from:t,to:n}=T(this,_t);(o=this.clientCallback)==null||o.call(this,{clientViewportId:this.viewport,mode:"batch",rows:this.visibleRows.slice(t,n).map(i=>Dp(i,this.keys)),size:this.visibleRows.length,type:"viewport-update"})}get columns(){return T(this,ft).columns}set columns(t){z(this,ft,{...T(this,ft),columns:t})}get aggregations(){return T(this,bn)}set aggregations(t){z(this,bn,t)}set data(t){console.log("set JsonDataSource data")}get sort(){return T(this,wn)}set sort(t){z(this,wn,t)}get filter(){return T(this,xn)}set filter(t){z(this,xn,t)}get groupBy(){return T(this,vn)}set groupBy(t){z(this,vn,t)}get title(){return T(this,Fr)}set title(t){z(this,Fr,t)}createLink({parentVpId:t,link:{fromColumn:n,toColumn:o}}){console.log("create link",{parentVpId:t,fromColumn:n,toColumn:o})}removeLink(){console.log("remove link")}async menuRpcCall(t){console.log("rmenuRpcCall",{rpcRequest:t})}applyEdit(t,n,o){return console.log(`ArrayDataSource applyEdit ${t} ${n} ${o}`),!0}getChildRows(t){let n=T(this,Ye).find(o=>o[Op]===t);if(n){let{[Ip]:o,[Vr]:i}=n,s=o+1,l=[];do{let{[Vr]:a}=T(this,Ye)[s];if(a===i+1)l.push(T(this,Ye)[s]);else if(a<=i)break;s+=1}while(s<T(this,Ye).length);return l}else console.warn(`JsonDataSource getChildRows row not found for key ${t}`);return[]}getRowsAtDepth(t,n=!0){return(n?this.visibleRows:T(this,Ye)).filter(i=>i[Vr]===t)}};bn=new WeakMap,ft=new WeakMap,Ye=new WeakMap,xn=new WeakMap,vn=new WeakMap,_t=new WeakMap,Cs=new WeakMap,Ts=new WeakMap,wn=new WeakMap,Fr=new WeakMap;function Ap(r,e){let t=[],n={value:0};for(let o=0;o<r.length;o++){let i=r[o],{[Vr]:s,[Op]:l,[ZC]:a}=i,c=e.has(l);if(t.push(eT(i,n,c)),!a&&!c)do o+=1;while(o<r.length-1&&r[o+1][Vr]>s)}return t}var eT=(r,e,t)=>{let n=r.slice();return n[0]=e.value,n[1]=e.value,t&&(n[XC]=!0),e.value+=1,n};import{debounce as Np,EventEmitter as tT,itemsOrOrderChanged as nT,logger as rT,throttle as oT,uuid as iT}from"@vuu-ui/vuu-utils";var{info:Ue}=rT("RemoteDataSource"),$,ks,Br,tn,Qo,Hr,Yn,ac=class extends tT{constructor({bufferSize:t=100,aggregations:n,columns:o,filter:i,groupBy:s,sort:l,table:a,title:c,viewport:u,visualLink:h}){super();this.server=null;this.status="initialising";ee(this,$,Er);ee(this,ks,[]);ee(this,Br,"throttle");ee(this,tn,{from:0,to:0});ee(this,Qo,0);ee(this,Hr,0);ee(this,Yn,void 0);this.handleMessageFromServer=t=>{var n,o;if(t.type==="subscribed")this.status="subscribed",(n=this.clientCallback)==null||n.call(this,t);else if(t.type==="disabled")this.status="disabled";else if(t.type==="enabled")this.status="enabled";else{if(jd(t))return;t.type==="debounce-begin"?this.optimize="debounce":(t.type==="viewport-update"&&t.size!==void 0&&t.size!==T(this,Hr)&&(z(this,Hr,t.size),this.emit("resize",t.size)),this.configChangePending&&this.setConfigPending(),(o=this.clientCallback)==null||o.call(this,t),this.optimize==="debounce"&&this.revertDebounce())}};this.revertDebounce=Np(()=>{this.optimize="throttle"},100);this.rawRangeRequest=t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})};this.debounceRangeRequest=Np(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},50);this.throttleRangeRequest=oT(t=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:t})},80);if(!a)throw Error("RemoteDataSource constructor called without table");this.bufferSize=t,this.table=a,this.viewport=u,z(this,$,{...T(this,$),aggregations:n||T(this,$).aggregations,columns:o||T(this,$).columns,filter:i||T(this,$).filter,groupBy:s||T(this,$).groupBy,sort:l||T(this,$).sort,visualLink:h||T(this,$).visualLink}),z(this,Yn,c),this.rangeRequest=this.throttleRangeRequest}async subscribe({viewport:t=(u=>(u=this.viewport)!=null?u:iT())(),columns:n,aggregations:o,range:i,sort:s,groupBy:l,filter:a},c){var f;if(console.log("%csubscribe","color:red;font-weight:bold;"),this.clientCallback=c,(o||n||a||l||s)&&z(this,$,{...T(this,$),aggregations:o||T(this,$).aggregations,columns:n||T(this,$).columns,filter:a||T(this,$).filter,groupBy:l||T(this,$).groupBy,sort:s||T(this,$).sort}),i&&z(this,tn,i),this.status!=="initialising"&&this.status!=="unsubscribed")return;this.status="subscribing",this.viewport=t,this.server=await Ga();let{bufferSize:h}=this;(f=this.server)==null||f.subscribe({...T(this,$),bufferSize:h,viewport:t,table:this.table,range:T(this,tn),title:T(this,Yn)},this.handleMessageFromServer)}unsubscribe(){var t,n;console.log("%cunsubscribe","color:red;font-weight:bold;"),Ue==null||Ue(`unsubscribe #${this.viewport}`),this.viewport&&((t=this.server)==null||t.unsubscribe(this.viewport)),(n=this.server)==null||n.destroy(this.viewport),this.removeAllListeners(),this.status="unsubscribed",this.viewport=void 0}suspend(){var t;return Ue==null||Ue(`suspend #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status="suspended",(t=this.server)==null||t.send({type:"suspend",viewport:this.viewport})),this}resume(){var t;return Ue==null||Ue(`resume #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status==="disabled"||this.status==="disabling"?this.enable():this.status==="suspended"&&((t=this.server)==null||t.send({type:"resume",viewport:this.viewport}),this.status="subscribed")),this}disable(){var t;return Ue==null||Ue(`disable #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status="disabling",(t=this.server)==null||t.send({viewport:this.viewport,type:"disable"})),this}enable(){var t;return Ue==null||Ue(`enable #${this.viewport}, current status ${this.status}`),this.viewport&&(this.status==="disabled"||this.status==="disabling")&&(this.status="enabling",(t=this.server)==null||t.send({viewport:this.viewport,type:"enable"})),this}select(t){var n;z(this,Qo,t.length),this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"select",selected:t}))}openTreeNode(t){var n;this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"openTreeNode",key:t}))}closeTreeNode(t){var n;this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"closeTreeNode",key:t}))}get optimize(){return T(this,Br)}set optimize(t){if(t!==T(this,Br)){switch(z(this,Br,t),t){case"none":this.rangeRequest=this.rawRangeRequest;break;case"debounce":this.rangeRequest=this.debounceRangeRequest;break;case"throttle":this.rangeRequest=this.throttleRangeRequest;break}this.emit("optimize",t)}}get selectedRowsCount(){return T(this,Qo)}get size(){return T(this,Hr)}get range(){return T(this,tn)}set range(t){(t.from!==T(this,tn).from||t.to!==T(this,tn).to)&&(z(this,tn,t),this.rangeRequest(t))}get config(){return T(this,$)}set config(t){var n,o;if(cs(T(this,$),t)&&t){let i=(n=t==null?void 0:t.filter)!=null&&n.filter&&(t==null?void 0:t.filter.filterStruct)===void 0?{...t,filter:{filter:t.filter.filter,filterStruct:Jn(t.filter.filter)}}:t;z(this,$,us(i)),T(this,$)&&this.viewport&&this.server&&t&&((o=this.server)==null||o.send({viewport:this.viewport,type:"config",config:T(this,$)})),this.emit("config",T(this,$))}}get columns(){return T(this,$).columns}set columns(t){if(z(this,$,{...T(this,$),columns:t}),this.viewport){let n={viewport:this.viewport,type:"setColumns",columns:t};this.server&&this.server.send(n)}this.emit("config",T(this,$))}get aggregations(){return T(this,$).aggregations}set aggregations(t){var n;z(this,$,{...T(this,$),aggregations:t}),this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"aggregate",aggregations:t})),this.emit("config",T(this,$))}get sort(){return T(this,$).sort}set sort(t){if(z(this,$,{...T(this,$),sort:t}),this.viewport){let n={viewport:this.viewport,type:"sort",sort:t};this.server&&this.server.send(n)}this.emit("config",T(this,$))}get filter(){return T(this,$).filter}set filter(t){if(z(this,$,{...T(this,$),filter:t}),this.viewport){let n={viewport:this.viewport,type:"filter",filter:t};this.server&&this.server.send(n)}this.emit("config",T(this,$))}get groupBy(){return T(this,$).groupBy}set groupBy(t){var n;if(nT(this.groupBy,t)){let o=T(this,ks).length>0;if(z(this,$,{...T(this,$),groupBy:t}),this.viewport){let i={viewport:this.viewport,type:"groupBy",groupBy:T(this,$).groupBy};this.server&&this.server.send(i)}!o&&t.length>0&&this.viewport&&((n=this.clientCallback)==null||n.call(this,{clientViewportId:this.viewport,mode:"batch",type:"viewport-update",size:0,rows:[]})),this.emit("config",T(this,$)),this.setConfigPending({groupBy:t})}}get title(){return T(this,Yn)}set title(t){var n;z(this,Yn,t),this.viewport&&t&&((n=this.server)==null||n.send({type:"setTitle",title:t,viewport:this.viewport}))}get visualLink(){return T(this,$).visualLink}set visualLink(t){var n,o;if(z(this,$,{...T(this,$),visualLink:t}),t){let{parentClientVpId:i,link:{fromColumn:s,toColumn:l}}=t;this.viewport&&((n=this.server)==null||n.send({viewport:this.viewport,type:"createLink",parentClientVpId:i,parentColumnName:l,childColumnName:s}))}else this.viewport&&((o=this.server)==null||o.send({type:"removeLink",viewport:this.viewport}));this.emit("config",T(this,$))}setConfigPending(t){let n=this.configChangePending;this.configChangePending=t,t!==void 0?this.emit("config",t,!1):this.emit("config",n,!0)}async menuRpcCall(t){var n;if(this.viewport)return(n=this.server)==null?void 0:n.rpcCall({vpId:this.viewport,...t})}applyEdit(t,n,o){return console.log(`ArrayDataSource applyEdit ${t} ${n} ${o}`),!0}};$=new WeakMap,ks=new WeakMap,Br=new WeakMap,tn=new WeakMap,Qo=new WeakMap,Hr=new WeakMap,Yn=new WeakMap;import{useCallback as y4,useEffect as b4,useState as x4}from"react";import{useCallback as sT}from"react";var Vp={type:"RPC_CALL",service:"TypeAheadRpcHandler"};var cc=()=>sT(async e=>{let t=e.length===2?{method:"getUniqueFieldValues",params:e,...Vp}:{method:"getUniqueFieldValuesStartingWith",params:e,...Vp};return await rp(t)},[]);import{getRowRecord as I4,isGroupMenuItemDescriptor as P4,metadataKeys as lT}from"@vuu-ui/vuu-utils";import{useCallback as L4}from"react";var{KEY:A4}=lT;import{useCallback as V4,useEffect as F4,useState as B4}from"react";import{ExpandoInput as uT}from"@vuu-ui/vuu-ui-controls";import{jsx as Es}from"react/jsx-runtime";var hT=aT(function({InputProps:e={},className:t,column:n,onInputComplete:o,operator:i,suggestionProvider:s=cc,table:l,value:a},c){let[u,h]=Bp(a!=null?a:""),[f,d]=Bp([]),p=s(),m=Ms((x,S)=>o(S),[o]),y=Ms((x,S)=>{S.length===1?o(S[0]):S.length>1&&o(S)},[o]);Fp(()=>{},[n]),Fp(()=>{if(l){let x=u?[l,n.name,u]:[l,n.name];p(x).then(S=>{d(S)}).catch(S=>{console.error("Error getting suggsetions",S)})}},[l,n,u,p]);let g=Ms(x=>{let{value:S}=x.target;h(S)},[]),v=cT(()=>{if(i==="starts"||i==="ends"){let{inputProps:x,...S}=e;return{...S,inputProps:{...x,onKeyDown:b=>{var C;b.key==="Enter"&&u!==""?(b.stopPropagation(),b.preventDefault(),o(u)):(C=x==null?void 0:x.onKeyDown)==null||C.call(x,b)}}}}else return e},[e,o,i,u]);return Ms(()=>{switch(i){case"in":return Es(_o,{InputProps:v,className:t,initialHighlightedIndex:0,source:f,onInputChange:g,onSelectionChange:y,ref:c,selectionStrategy:"multiple",value:a});case"starts":return Es(_o,{InputProps:v,ListProps:{className:"vuuIllustrationsOnly",disabled:!0},allowFreeText:!0,className:t,initialHighlightedIndex:0,source:f,onInputChange:g,onSelectionChange:m,ref:c,value:a});case"ends":return Es(uT,{...v,className:t,value:u,ref:c,onChange:g});default:return Es(_o,{InputProps:v,className:t,initialHighlightedIndex:0,source:f,title:"value",onInputChange:g,onSelectionChange:m,ref:c,value:a})}},[i,v,t,f,g,y,c,a,m,u])()});import{isMultiValueFilter as d_,isSingleValueFilter as p_,isValidFilterClauseOp as m_}from"@vuu-ui/vuu-utils";import{useCallback as v_,useEffect as w_,useMemo as S_,useRef as C_,useState as T_}from"react";import{Button as W_}from"@salt-ds/core";import{jsx as U_,jsxs as G_}from"react/jsx-runtime";import{EditableLabel as A3}from"@vuu-ui/vuu-ui-controls";import{filterAsQuery as V3,isMultiClauseFilter as F3}from"@vuu-ui/vuu-utils";import H3 from"classnames";import{useCallback as W3,useRef as $3}from"react";import{PopupMenu as i3}from"@vuu-ui/vuu-popups";import{useMemo as l3}from"react";import c3 from"classnames";import{jsx as p3}from"react/jsx-runtime";import{extractFilterForColumn as x3,isAndFilter as v3,isCompleteFilter as w3,isInFilter as S3,isMultiClauseFilter as C3,isMultiValueFilter as T3,isOrFilter as k3,isSingleValueFilter as M3,partition as E3}from"@vuu-ui/vuu-utils";import{jsx as j3,jsxs as J3}from"react/jsx-runtime";import{dispatchMouseEvent as az,filterAsQuery as cz}from"@vuu-ui/vuu-utils";import{useCallback as pz,useEffect as mz,useMemo as gz,useRef as yz,useState as bz}from"react";import{useControlled as ez}from"@vuu-ui/vuu-ui-controls";import{useCallback as nz}from"react";import{jsx as jz,jsxs as Jz}from"react/jsx-runtime";import{createElement as Kz}from"react";import{Button as q5}from"@salt-ds/core";var Y=class{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){let o=[];return this.decompose(0,e,o,2),n.length&&n.decompose(0,n.length,o,3),this.decompose(t,this.length,o,1),dt.from(o,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let n=[];return this.decompose(e,t,n,0),dt.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),o=new er(this),i=new er(e);for(let s=t,l=t;;){if(o.next(s),i.next(s),s=0,o.lineBreak!=i.lineBreak||o.done!=i.done||o.value!=i.value)return!1;if(l+=o.value.length,o.done||l>=n)return!0}}iter(e=1){return new er(this,e)}iterRange(e,t=this.length){return new Ds(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let o=this.line(e).from;n=this.iterRange(o,Math.max(o,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ls(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Y.empty:e.length<=32?new ce(e):dt.from(ce.split(e,[]))}},ce=class extends Y{constructor(e,t=pT(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,o){for(let i=0;;i++){let s=this.text[i],l=o+s.length;if((t?n:l)>=e)return new hc(o,l,n,s);o=l+1,n++}}decompose(e,t,n,o){let i=e<=0&&t>=this.length?this:new ce(Hp(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(o&1){let s=n.pop(),l=Ps(i.text,s.text.slice(),0,i.length);if(l.length<=32)n.push(new ce(l,s.length+i.length));else{let a=l.length>>1;n.push(new ce(l.slice(0,a)),new ce(l.slice(a)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof ce))return super.replace(e,t,n);let o=Ps(this.text,Ps(n.text,Hp(this.text,0,e)),t),i=this.length+n.length-(t-e);return o.length<=32?new ce(o,i):dt.from(ce.split(o,[]),i)}sliceString(e,t=this.length,n=`
18
18
  `){let o="";for(let i=0,s=0;i<=t&&s<this.text.length;s++){let l=this.text[s],a=i+l.length;i>e&&s&&(o+=n),e<a&&t>i&&(o+=l.slice(Math.max(0,e-i),t-i)),i=a+1}return o}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],o=-1;for(let i of e)n.push(i),o+=i.length+1,n.length==32&&(t.push(new ce(n,o)),n=[],o=-1);return o>-1&&t.push(new ce(n,o)),t}},dt=class extends Y{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,o){for(let i=0;;i++){let s=this.children[i],l=o+s.length,a=n+s.lines-1;if((t?a:l)>=e)return s.lineInner(e,t,n,o);o=l+1,n=a+1}}decompose(e,t,n,o){for(let i=0,s=0;s<=t&&i<this.children.length;i++){let l=this.children[i],a=s+l.length;if(e<=a&&t>=s){let c=o&((s<=e?1:0)|(a>=t?2:0));s>=e&&a<=t&&!c?n.push(l):l.decompose(e-s,t-s,n,c)}s=a+1}}replace(e,t,n){if(n.lines<this.lines)for(let o=0,i=0;o<this.children.length;o++){let s=this.children[o],l=i+s.length;if(e>=i&&t<=l){let a=s.replace(e-i,t-i,n),c=this.lines-s.lines+a.lines;if(a.lines<c>>5-1&&a.lines>c>>5+1){let u=this.children.slice();return u[o]=a,new dt(u,this.length-(t-e)+n.length)}return super.replace(i,l,a)}i=l+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
19
- `){let o="";for(let i=0,s=0;i<this.children.length&&s<=t;i++){let l=this.children[i],a=s+l.length;s>e&&i&&(o+=n),e<a&&t>s&&(o+=l.sliceString(e-s,t-s,n)),s=a+1}return o}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof dt))return 0;let n=0,[o,i,s,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;o+=t,i+=t){if(o==s||i==l)return n;let a=this.children[o],c=e.children[i];if(a!=c)return n+a.scanIdentical(c,t);n+=a.length+1}}static from(e,t=e.reduce((n,o)=>n+o.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new ce(d,t)}let o=Math.max(32,n>>5),i=o<<1,s=o>>1,l=[],a=0,c=-1,u=[];function h(d){let p;if(d.lines>i&&d instanceof dt)for(let m of d.children)h(m);else d.lines>s&&(a>s||!a)?(f(),l.push(d)):d instanceof ce&&a&&(p=u[u.length-1])instanceof ce&&d.lines+p.lines<=32?(a+=d.lines,c+=d.length+1,u[u.length-1]=new ce(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>o&&f(),a+=d.lines,c+=d.length+1,u.push(d))}function f(){a!=0&&(l.push(u.length==1?u[0]:dt.from(u,c)),c=-1,a=u.length=0)}for(let d of e)h(d);return f(),l.length==1?l[0]:new dt(l,t)}};Y.empty=new ce([""],0);function cT(r){let e=-1;for(let t of r)e+=t.length+1;return e}function Is(r,e,t=0,n=1e9){for(let o=0,i=0,s=!0;i<r.length&&o<=n;i++){let l=r[i],a=o+l.length;a>=t&&(a>n&&(l=l.slice(0,n-o)),o<t&&(l=l.slice(t-o)),s?(e[e.length-1]+=l,s=!1):e.push(l)),o=a+1}return e}function zp(r,e,t){return Is(r,[""],e,t)}var er=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ce?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,o=this.nodes[n],i=this.offsets[n],s=i>>1,l=o instanceof ce?o.text.length:o.children.length;if(s==(t>0?l:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
20
- `,this;e--}else if(o instanceof ce){let a=o.text[s+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=o.children[s+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ce?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Ps=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new er(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:o}=this.cursor.next(e);return this.pos+=(o.length+e)*t,this.value=o.length<=n?o:t<0?o.slice(o.length-n):o.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Ds=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:o}=this.inner.next(e);return t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(Y.prototype[Symbol.iterator]=function(){return this.iter()},er.prototype[Symbol.iterator]=Ps.prototype[Symbol.iterator]=Ds.prototype[Symbol.iterator]=function(){return this});var hc=class{constructor(e,t,n,o){this.from=e,this.to=t,this.number=n,this.text=o}get length(){return this.to-this.from}},_r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(r=>r?parseInt(r,36):1);for(let r=1;r<_r.length;r++)_r[r]+=_r[r-1];function uT(r){for(let e=1;e<_r.length;e+=2)if(_r[e]>r)return _r[e-1]<=r;return!1}function Wp(r){return r>=127462&&r<=127487}var $p=8205;function Ve(r,e,t=!0,n=!0){return(t?Jp:hT)(r,e,n)}function Jp(r,e,t){if(e==r.length)return e;e&&Qp(r.charCodeAt(e))&&Yp(r.charCodeAt(e-1))&&e--;let n=zt(r,e);for(e+=tr(n);e<r.length;){let o=zt(r,e);if(n==$p||o==$p||t&&uT(o))e+=tr(o),n=o;else if(Wp(o)){let i=0,s=e-2;for(;s>=0&&Wp(zt(r,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function hT(r,e,t){for(;e>0;){let n=Jp(r,e-2,t);if(n<e)return n;e--}return 0}function Qp(r){return r>=56320&&r<57344}function Yp(r){return r>=55296&&r<56320}function zt(r,e){let t=r.charCodeAt(e);if(!Yp(t)||e+1==r.length)return t;let n=r.charCodeAt(e+1);return Qp(n)?(t-55296<<10)+(n-56320)+65536:t}function Xp(r){return r<=65535?String.fromCharCode(r):(r-=65536,String.fromCharCode((r>>10)+55296,(r&1023)+56320))}function tr(r){return r<65536?1:2}var fc=/\r\n?|\n/,Ne=function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r}(Ne||(Ne={})),et=class{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,o=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?(e(n,o,i),o+=i):o+=s,n+=i}}iterChangedRanges(e,t=!1){dc(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],o=this.sections[t++];o<0?e.push(n,o):e.push(o,n)}return new et(e)}composeDesc(e){return this.empty?e:e.empty?this:Zp(this,e)}mapDesc(e,t=!1){return e.empty?this:pc(this,e,t)}mapPos(e,t=-1,n=Ne.Simple){let o=0,i=0;for(let s=0;s<this.sections.length;){let l=this.sections[s++],a=this.sections[s++],c=o+l;if(a<0){if(c>e)return i+(e-o);i+=l}else{if(n!=Ne.Simple&&c>=e&&(n==Ne.TrackDel&&o<e&&c>e||n==Ne.TrackBefore&&o<e||n==Ne.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!l)return e==o||t<0?i:i+a;i+=a}o=c}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return i}touchesRange(e,t=e){for(let n=0,o=0;n<this.sections.length&&o<=t;){let i=this.sections[n++],s=this.sections[n++],l=o+i;if(s>=0&&o<=t&&l>=e)return o<e&&l>t?"cover":!0;o=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],o=this.sections[t++];e+=(e?" ":"")+n+(o>=0?":"+o:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new et(e)}static create(e){return new et(e)}},ue=class extends et{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return dc(this,(t,n,o,i,s)=>e=e.replace(o,o+(n-t),s),!1),e}mapDesc(e,t=!1){return pc(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let o=0,i=0;o<t.length;o+=2){let s=t[o],l=t[o+1];if(l>=0){t[o]=l,t[o+1]=s;let a=o>>1;for(;n.length<a;)n.push(Y.empty);n.push(s?e.slice(i,i+s):Y.empty)}i+=s}return new ue(t,n)}compose(e){return this.empty?e:e.empty?this:Zp(this,e,!0)}map(e,t=!1){return e.empty?this:pc(this,e,t,!0)}iterChanges(e,t=!1){dc(this,e,t)}get desc(){return et.create(this.sections)}filter(e){let t=[],n=[],o=[],i=new nr(this);e:for(let s=0,l=0;;){let a=s==e.length?1e9:e[s++];for(;l<a||l==a&&i.len==0;){if(i.done)break e;let u=Math.min(i.len,a-l);Oe(o,u,-1);let h=i.ins==-1?-1:i.off==0?i.ins:0;Oe(t,u,h),h>0&&Sn(n,t,i.text),i.forward(u),l+=u}let c=e[s++];for(;l<c;){if(i.done)break e;let u=Math.min(i.len,c-l);Oe(t,u,-1),Oe(o,u,i.ins==-1?-1:i.off==0?i.ins:0),i.forward(u),l+=u}}return{changes:new ue(t,n),filtered:et.create(o)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],o=this.sections[t+1];o<0?e.push(n):o==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let o=[],i=[],s=0,l=null;function a(u=!1){if(!u&&!o.length)return;s<t&&Oe(o,t-s,-1);let h=new ue(o,i);l=l?l.compose(h.map(l)):h,o=[],i=[],s=0}function c(u){if(Array.isArray(u))for(let h of u)c(h);else if(u instanceof ue){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);a(),l=l?l.compose(u.map(l)):u}else{let{from:h,to:f=h,insert:d}=u;if(h>f||h<0||f>t)throw new RangeError(`Invalid change range ${h} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?Y.of(d.split(n||fc)):d:Y.empty,m=p.length;if(h==f&&m==0)return;h<s&&a(),h>s&&Oe(o,h-s,-1),Oe(o,f-h,m),Sn(i,o,p),s=f}}return c(e),a(!l),l}static empty(e){return new ue(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let o=0;o<e.length;o++){let i=e[o];if(typeof i=="number")t.push(i,-1);else{if(!Array.isArray(i)||typeof i[0]!="number"||i.some((s,l)=>l&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(i.length==1)t.push(i[0],0);else{for(;n.length<o;)n.push(Y.empty);n[o]=Y.of(i.slice(1)),t.push(i[0],n[o].length)}}}return new ue(t,n)}static createSet(e,t){return new ue(e,t)}};function Oe(r,e,t,n=!1){if(e==0&&t<=0)return;let o=r.length-2;o>=0&&t<=0&&t==r[o+1]?r[o]+=e:e==0&&r[o]==0?r[o+1]+=t:n?(r[o]+=e,r[o+1]+=t):r.push(e,t)}function Sn(r,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<r.length)r[r.length-1]=r[r.length-1].append(t);else{for(;r.length<n;)r.push(Y.empty);r.push(t)}}function dc(r,e,t){let n=r.inserted;for(let o=0,i=0,s=0;s<r.sections.length;){let l=r.sections[s++],a=r.sections[s++];if(a<0)o+=l,i+=l;else{let c=o,u=i,h=Y.empty;for(;c+=l,u+=a,a&&n&&(h=h.append(n[s-2>>1])),!(t||s==r.sections.length||r.sections[s+1]<0);)l=r.sections[s++],a=r.sections[s++];e(o,c,i,u,h),o=c,i=u}}}function pc(r,e,t,n=!1){let o=[],i=n?[]:null,s=new nr(r),l=new nr(e);for(let a=-1;;)if(s.ins==-1&&l.ins==-1){let c=Math.min(s.len,l.len);Oe(o,c,-1),s.forward(c),l.forward(c)}else if(l.ins>=0&&(s.ins<0||a==s.i||s.off==0&&(l.len<s.len||l.len==s.len&&!t))){let c=l.len;for(Oe(o,l.ins,-1);c;){let u=Math.min(s.len,c);s.ins>=0&&a<s.i&&s.len<=u&&(Oe(o,0,s.ins),i&&Sn(i,o,s.text),a=s.i),s.forward(u),c-=u}l.next()}else if(s.ins>=0){let c=0,u=s.len;for(;u;)if(l.ins==-1){let h=Math.min(u,l.len);c+=h,u-=h,l.forward(h)}else if(l.ins==0&&l.len<u)u-=l.len,l.next();else break;Oe(o,c,a<s.i?s.ins:0),i&&a<s.i&&Sn(i,o,s.text),a=s.i,s.forward(s.len-u)}else{if(s.done&&l.done)return i?ue.createSet(o,i):et.create(o);throw new Error("Mismatched change set lengths")}}function Zp(r,e,t=!1){let n=[],o=t?[]:null,i=new nr(r),s=new nr(e);for(let l=!1;;){if(i.done&&s.done)return o?ue.createSet(n,o):et.create(n);if(i.ins==0)Oe(n,i.len,0,l),i.next();else if(s.len==0&&!s.done)Oe(n,0,s.ins,l),o&&Sn(o,n,s.text),s.next();else{if(i.done||s.done)throw new Error("Mismatched change set lengths");{let a=Math.min(i.len2,s.len),c=n.length;if(i.ins==-1){let u=s.ins==-1?-1:s.off?0:s.ins;Oe(n,a,u,l),o&&u&&Sn(o,n,s.text)}else s.ins==-1?(Oe(n,i.off?0:i.len,a,l),o&&Sn(o,n,i.textBit(a))):(Oe(n,i.off?0:i.len,s.off?0:s.ins,l),o&&!s.off&&Sn(o,n,s.text));l=(i.ins>a||s.ins>=0&&s.len>a)&&(l||n.length>c),i.forward2(a),s.forward(a)}}}}var nr=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Y.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Y.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},nn=class{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,t=-1){let n,o;return this.empty?n=o=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),o=e.mapPos(this.to,-1)),n==this.from&&o==this.to?this:new nn(n,o,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return I.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return I.range(this.anchor,n)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return I.range(e.anchor,e.head)}static create(e,t,n){return new nn(e,t,n)}},I=class{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:I.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new I([this.main],0)}addRange(e,t=!0){return I.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,I.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new I(e.ranges.map(t=>nn.fromJSON(t)),e.main)}static single(e,t=e){return new I([I.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,o=0;o<e.length;o++){let i=e[o];if(i.empty?i.from<=n:i.from<n)return I.normalized(e.slice(),t);n=i.to}return new I(e,t)}static cursor(e,t=0,n,o){return nn.create(e,e,(t==0?0:t<0?4:8)|(n==null?3:Math.min(2,n))|(o!=null?o:33554431)<<5)}static range(e,t,n,o){let i=(n!=null?n:33554431)<<5|(o==null?3:Math.min(2,o));return t<e?nn.create(t,e,24|i):nn.create(e,t,(t>e?4:0)|i)}static normalized(e,t=0){let n=e[t];e.sort((o,i)=>o.from-i.from),t=e.indexOf(n);for(let o=1;o<e.length;o++){let i=e[o],s=e[o-1];if(i.empty?i.from<=s.to:i.from<s.to){let l=s.from,a=Math.max(i.to,s.to);o<=t&&t--,e.splice(--o,2,i.anchor>i.head?I.range(a,l):I.range(l,a))}}return new I(e,t)}};function em(r,e){for(let t of r.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var wc=0,$=class{constructor(e,t,n,o,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=o,this.id=wc++,this.default=e([]),this.extensions=typeof i=="function"?i(this):i}static define(e={}){return new $(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:Sc),!!e.static,e.enables)}of(e){return new zr([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new zr(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new zr(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}};function Sc(r,e){return r==e||r.length==e.length&&r.every((t,n)=>t===e[n])}var zr=class{constructor(e,t,n,o){this.dependencies=e,this.facet=t,this.type=n,this.value=o,this.id=wc++}dynamicSlot(e){var t;let n=this.value,o=this.facet.compareInput,i=this.id,s=e[i]>>1,l=this.type==2,a=!1,c=!1,u=[];for(let h of this.dependencies)h=="doc"?a=!0:h=="selection"?c=!0:((t=e[h.id])!==null&&t!==void 0?t:1)&1||u.push(e[h.id]);return{create(h){return h.values[s]=n(h),1},update(h,f){if(a&&f.docChanged||c&&(f.docChanged||f.selection)||mc(h,u)){let d=n(h);if(l?!Up(d,h.values[s],o):!o(d,h.values[s]))return h.values[s]=d,1}return 0},reconfigure:(h,f)=>{let d,p=f.config.address[i];if(p!=null){let m=As(f,p);if(this.dependencies.every(g=>g instanceof $?f.facet(g)===h.facet(g):g instanceof qe?f.field(g,!1)==h.field(g,!1):!0)||(l?Up(d=n(h),m,o):o(d=n(h),m)))return h.values[s]=m,0}else d=n(h);return h.values[s]=d,1}}}};function Up(r,e,t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!t(r[n],e[n]))return!1;return!0}function mc(r,e){let t=!1;for(let n of e)Yo(r,n)&1&&(t=!0);return t}function fT(r,e,t){let n=t.map(a=>r[a.id]),o=t.map(a=>a.type),i=n.filter(a=>!(a&1)),s=r[e.id]>>1;function l(a){let c=[];for(let u=0;u<n.length;u++){let h=As(a,n[u]);if(o[u]==2)for(let f of h)c.push(f);else c.push(h)}return e.combine(c)}return{create(a){for(let c of n)Yo(a,c);return a.values[s]=l(a),1},update(a,c){if(!mc(a,i))return 0;let u=l(a);return e.compare(u,a.values[s])?0:(a.values[s]=u,1)},reconfigure(a,c){let u=mc(a,n),h=c.config.facets[e.id],f=c.facet(e);if(h&&!u&&Sc(t,h))return a.values[s]=f,0;let d=l(a);return e.compare(d,f)?(a.values[s]=f,0):(a.values[s]=d,1)}}}var Gp=$.define({static:!0}),qe=class{constructor(e,t,n,o,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=o,this.spec=i,this.provides=void 0}static define(e){let t=new qe(wc++,e.create,e.update,e.compare||((n,o)=>n===o),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Gp).find(n=>n.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,o)=>{let i=n.values[t],s=this.updateF(i,o);return this.compareF(i,s)?0:(n.values[t]=s,1)},reconfigure:(n,o)=>o.config.address[this.id]!=null?(n.values[t]=o.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,Gp.of({field:this,create:e})]}get extension(){return this}},Xn={lowest:4,low:3,default:2,high:1,highest:0};function Qo(r){return e=>new Ls(e,r)}var ir={highest:Qo(Xn.highest),high:Qo(Xn.high),default:Qo(Xn.default),low:Qo(Xn.low),lowest:Qo(Xn.lowest)},Ls=class{constructor(e,t){this.inner=e,this.prec=t}},$r=class{of(e){return new Xo(this,e)}reconfigure(e){return $r.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Xo=class{constructor(e,t){this.compartment=e,this.inner=t}},Ur=class{constructor(e,t,n,o,i,s){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=o,this.staticValues=i,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let o=[],i=Object.create(null),s=new Map;for(let f of dT(e,t,s))f instanceof qe?o.push(f):(i[f.facet.id]||(i[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],c=[];for(let f of o)l[f.id]=c.length<<1,c.push(d=>f.slot(d));let u=n==null?void 0:n.config.facets;for(let f in i){let d=i[f],p=d[0].facet,m=u&&u[f]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Sc(m,d))a.push(n.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(n&&p.compare(g,n.facet(p))?n.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=c.length<<1,c.push(y=>g.dynamicSlot(y)));l[p.id]=c.length<<1,c.push(g=>fT(g,p,d))}}let h=c.map(f=>f(l));return new Ur(e,s,h,l,a,i)}};function dT(r,e,t){let n=[[],[],[],[],[]],o=new Map;function i(s,l){let a=o.get(s);if(a!=null){if(a<=l)return;let c=n[a].indexOf(s);c>-1&&n[a].splice(c,1),s instanceof Xo&&t.delete(s.compartment)}if(o.set(s,l),Array.isArray(s))for(let c of s)i(c,l);else if(s instanceof Xo){if(t.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;t.set(s.compartment,c),i(c,l)}else if(s instanceof Ls)i(s.inner,s.prec);else if(s instanceof qe)n[l].push(s),s.provides&&i(s.provides,l);else if(s instanceof zr)n[l].push(s),s.facet.extensions&&i(s.facet.extensions,Xn.default);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);i(c,l)}}return i(r,Xn.default),n.reduce((s,l)=>s.concat(l))}function Yo(r,e){if(e&1)return 2;let t=e>>1,n=r.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;r.status[t]=4;let o=r.computeSlot(r,r.config.dynamicSlots[t]);return r.status[t]=2|o}function As(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}var tm=$.define(),nm=$.define({combine:r=>r.some(e=>e),static:!0}),rm=$.define({combine:r=>r.length?r[0]:void 0,static:!0}),om=$.define(),im=$.define(),sm=$.define(),lm=$.define({combine:r=>r.length?r[0]:!1}),tt=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Os}},Os=class{of(e){return new tt(this,e)}},gc=class{constructor(e){this.map=e}of(e){return new ie(this,e)}},ie=class{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new ie(this.type,t)}is(e){return this.type==e}static define(e={}){return new gc(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let o of e){let i=o.map(t);i&&n.push(i)}return n}};ie.reconfigure=ie.define();ie.appendConfig=ie.define();var he=class{constructor(e,t,n,o,i,s){this.startState=e,this.changes=t,this.selection=n,this.effects=o,this.annotations=i,this.scrollIntoView=s,this._doc=null,this._state=null,n&&em(n,t.newLength),i.some(l=>l.type==he.time)||(this.annotations=i.concat(he.time.of(Date.now())))}static create(e,t,n,o,i,s){return new he(e,t,n,o,i,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(he.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};he.time=tt.define();he.userEvent=tt.define();he.addToHistory=tt.define();he.remote=tt.define();function pT(r,e){let t=[];for(let n=0,o=0;;){let i,s;if(n<r.length&&(o==e.length||e[o]>=r[n]))i=r[n++],s=r[n++];else if(o<e.length)i=e[o++],s=e[o++];else return t;!t.length||t[t.length-1]<i?t.push(i,s):t[t.length-1]<s&&(t[t.length-1]=s)}}function am(r,e,t){var n;let o,i,s;return t?(o=e.changes,i=ue.empty(e.changes.length),s=r.changes.compose(e.changes)):(o=e.changes.map(r.changes),i=r.changes.mapDesc(e.changes,!0),s=r.changes.compose(o)),{changes:s,selection:e.selection?e.selection.map(i):(n=r.selection)===null||n===void 0?void 0:n.map(o),effects:ie.mapEffects(r.effects,o).concat(ie.mapEffects(e.effects,i)),annotations:r.annotations.length?r.annotations.concat(e.annotations):e.annotations,scrollIntoView:r.scrollIntoView||e.scrollIntoView}}function yc(r,e,t){let n=e.selection,o=Wr(e.annotations);return e.userEvent&&(o=o.concat(he.userEvent.of(e.userEvent))),{changes:e.changes instanceof ue?e.changes:ue.of(e.changes||[],t,r.facet(rm)),selection:n&&(n instanceof I?n:I.single(n.anchor,n.head)),effects:Wr(e.effects),annotations:o,scrollIntoView:!!e.scrollIntoView}}function cm(r,e,t){let n=yc(r,e.length?e[0]:{},r.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let i=1;i<e.length;i++){e[i].filter===!1&&(t=!1);let s=!!e[i].sequential;n=am(n,yc(r,e[i],s?n.changes.newLength:r.doc.length),s)}let o=he.create(r,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return gT(t?mT(o):o)}function mT(r){let e=r.startState,t=!0;for(let o of e.facet(om)){let i=o(r);if(i===!1){t=!1;break}Array.isArray(i)&&(t=t===!0?i:pT(t,i))}if(t!==!0){let o,i;if(t===!1)i=r.changes.invertedDesc,o=ue.empty(e.doc.length);else{let s=r.changes.filter(t);o=s.changes,i=s.filtered.mapDesc(s.changes).invertedDesc}r=he.create(e,o,r.selection&&r.selection.map(i),ie.mapEffects(r.effects,i),r.annotations,r.scrollIntoView)}let n=e.facet(im);for(let o=n.length-1;o>=0;o--){let i=n[o](r);i instanceof he?r=i:Array.isArray(i)&&i.length==1&&i[0]instanceof he?r=i[0]:r=cm(e,Wr(i),!1)}return r}function gT(r){let e=r.startState,t=e.facet(sm),n=r;for(let o=t.length-1;o>=0;o--){let i=t[o](r);i&&Object.keys(i).length&&(n=am(n,yc(e,i,r.changes.newLength),!0))}return n==r?r:he.create(e,r.changes,r.selection,n.effects,n.annotations,n.scrollIntoView)}var yT=[];function Wr(r){return r==null?yT:Array.isArray(r)?r:[r]}var Ge=function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r}(Ge||(Ge={})),bT=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,bc;try{bc=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function xT(r){if(bc)return bc.test(r);for(let e=0;e<r.length;e++){let t=r[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||bT.test(t)))return!0}return!1}function vT(r){return e=>{if(!/\S/.test(e))return Ge.Space;if(xT(e))return Ge.Word;for(let t=0;t<r.length;t++)if(e.indexOf(r[t])>-1)return Ge.Word;return Ge.Other}}var Z=class{constructor(e,t,n,o,i,s){this.config=e,this.doc=t,this.selection=n,this.values=o,this.status=e.statusTemplate.slice(),this.computeSlot=i,s&&(s._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Yo(this,l<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return Yo(this,n),As(this,n)}update(...e){return cm(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:o}=t;for(let s of e.effects)s.is($r.reconfigure)?(t&&(o=new Map,t.compartments.forEach((l,a)=>o.set(a,l)),t=null),o.set(s.value.compartment,s.value.extension)):s.is(ie.reconfigure)?(t=null,n=s.value):s.is(ie.appendConfig)&&(t=null,n=Wr(n).concat(s.value));let i;t?i=e.startState.values.slice():(t=Ur.resolve(n,o,this),i=new Z(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,a)=>a.reconfigure(l,this),null).values),new Z(t,e.newDoc,e.newSelection,i,(s,l)=>l.update(s,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:I.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),o=this.changes(n.changes),i=[n.range],s=Wr(n.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),c=this.changes(a.changes),u=c.map(o);for(let f=0;f<l;f++)i[f]=i[f].map(u);let h=o.mapDesc(c,!0);i.push(a.range.map(h)),o=o.compose(u),s=ie.mapEffects(s,u).concat(ie.mapEffects(Wr(a.effects),h))}return{changes:o,selection:I.create(i,t.mainIndex),effects:s}}changes(e=[]){return e instanceof ue?e:ue.of(e,this.doc.length,this.facet(Z.lineSeparator))}toText(e){return Y.of(e.split(this.facet(Z.lineSeparator)||fc))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Yo(this,t),As(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let o=e[n];o instanceof qe&&this.config.address[o.id]!=null&&(t[n]=o.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let o=[];if(n){for(let i in n)if(Object.prototype.hasOwnProperty.call(e,i)){let s=n[i],l=e[i];o.push(s.init(a=>s.spec.fromJSON(l,a)))}}return Z.create({doc:e.doc,selection:I.fromJSON(e.selection),extensions:t.extensions?o.concat([t.extensions]):o})}static create(e={}){let t=Ur.resolve(e.extensions||[],new Map),n=e.doc instanceof Y?e.doc:Y.of((e.doc||"").split(t.staticFacet(Z.lineSeparator)||fc)),o=e.selection?e.selection instanceof I?e.selection:I.single(e.selection.anchor,e.selection.head):I.single(0);return em(o,n.length),t.staticFacet(nm)||(o=o.asSingle()),new Z(t,n,o,t.dynamicSlots.map(()=>null),(i,s)=>s.create(i),null)}get tabSize(){return this.facet(Z.tabSize)}get lineBreak(){return this.facet(Z.lineSeparator)||`
21
- `}get readOnly(){return this.facet(lm)}phrase(e,...t){for(let n of this.facet(Z.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,o)=>{if(o=="$")return"$";let i=+(o||1);return!i||i>t.length?n:t[i-1]})),e}languageDataAt(e,t,n=-1){let o=[];for(let i of this.facet(tm))for(let s of i(this,t,n))Object.prototype.hasOwnProperty.call(s,e)&&o.push(s[e]);return o}charCategorizer(e){return vT(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:o}=this.doc.lineAt(e),i=this.charCategorizer(e),s=e-n,l=e-n;for(;s>0;){let a=Ve(t,s,!1);if(i(t.slice(a,s))!=Ge.Word)break;s=a}for(;l<o;){let a=Ve(t,l);if(i(t.slice(l,a))!=Ge.Word)break;l=a}return s==l?null:I.range(s+n,l+n)}};Z.allowMultipleSelections=nm;Z.tabSize=$.define({combine:r=>r.length?r[0]:4});Z.lineSeparator=rm;Z.readOnly=lm;Z.phrases=$.define({compare(r,e){let t=Object.keys(r),n=Object.keys(e);return t.length==n.length&&t.every(o=>r[o]==e[o])}});Z.languageData=tm;Z.changeFilter=om;Z.transactionFilter=im;Z.transactionExtender=sm;$r.reconfigure=ie.define();function sr(r,e,t={}){let n={};for(let o of r)for(let i of Object.keys(o)){let s=o[i],l=n[i];if(l===void 0)n[i]=s;else if(!(l===s||s===void 0))if(Object.hasOwnProperty.call(t,i))n[i]=t[i](l,s);else throw new Error("Config merge conflict for field "+i)}for(let o in e)n[o]===void 0&&(n[o]=e[o]);return n}var Dt=class{eq(e){return this==e}range(e,t=e){return rr.create(e,t,this)}};Dt.prototype.startSide=Dt.prototype.endSide=0;Dt.prototype.point=!1;Dt.prototype.mapMode=Ne.TrackDel;var rr=class{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new rr(e,t,n)}};function xc(r,e){return r.from-e.from||r.value.startSide-e.value.startSide}var Zo=class{constructor(e,t,n,o){this.from=e,this.to=t,this.value=n,this.maxPoint=o}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,o=0){let i=n?this.to:this.from;for(let s=o,l=i.length;;){if(s==l)return s;let a=s+l>>1,c=i[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==s)return c>=0?s:l;c>=0?l=a:s=a+1}}between(e,t,n,o){for(let i=this.findIndex(t,-1e9,!0),s=this.findIndex(n,1e9,!1,i);i<s;i++)if(o(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(e,t){let n=[],o=[],i=[],s=-1,l=-1;for(let a=0;a<this.value.length;a++){let c=this.value[a],u=this.from[a]+e,h=this.to[a]+e,f,d;if(u==h){let p=t.mapPos(u,c.startSide,c.mapMode);if(p==null||(f=d=p,c.startSide!=c.endSide&&(d=t.mapPos(u,c.endSide),d<f)))continue}else if(f=t.mapPos(u,c.startSide),d=t.mapPos(h,c.endSide),f>d||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(s<0&&(s=f),c.point&&(l=Math.max(l,d-f)),n.push(c),o.push(f-s),i.push(d-s))}return{mapped:n.length?new Zo(o,i,n,l):null,pos:s}}},oe=class{constructor(e,t,n,o){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=o}static create(e,t,n,o){return new oe(e,t,n,o)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:o=0,filterTo:i=this.length}=e,s=e.filter;if(t.length==0&&!s)return this;if(n&&(t=t.slice().sort(xc)),this.isEmpty)return t.length?oe.of(t):this;let l=new Ns(this,null,-1).goto(0),a=0,c=[],u=new Wt;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let h=t[a++];u.addInner(h.from,h.to,h.value)||c.push(h)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!s||o>this.chunkEnd(l.chunkIndex)||i<this.chunkPos[l.chunkIndex])&&u.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!s||o>l.to||i<l.from||s(l.from,l.to,l.value))&&(u.addInner(l.from,l.to,l.value)||c.push(rr.create(l.from,l.to,l.value))),l.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?oe.empty:this.nextLayer.update({add:c,filter:s,filterFrom:o,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],o=-1;for(let s=0;s<this.chunk.length;s++){let l=this.chunkPos[s],a=this.chunk[s],c=e.touchesRange(l,l+a.length);if(c===!1)o=Math.max(o,a.maxPoint),t.push(a),n.push(e.mapPos(l));else if(c===!0){let{mapped:u,pos:h}=a.map(l,e);u&&(o=Math.max(o,u.maxPoint),t.push(u),n.push(h))}}let i=this.nextLayer.map(e);return t.length==0?i:new oe(n,t,i||oe.empty,o)}between(e,t,n){if(!this.isEmpty){for(let o=0;o<this.chunk.length;o++){let i=this.chunkPos[o],s=this.chunk[o];if(t>=i&&e<=i+s.length&&s.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return or.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return or.from(e).goto(t)}static compare(e,t,n,o,i=-1){let s=e.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=i),l=t.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=i),a=qp(s,l,n),c=new Zn(s,a,i),u=new Zn(l,a,i);n.iterGaps((h,f,d)=>Kp(c,h,u,f,d,o)),n.empty&&n.length==0&&Kp(c,0,u,0,0,o)}static eq(e,t,n=0,o){o==null&&(o=1e9-1);let i=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),s=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(i.length!=s.length)return!1;if(!i.length)return!0;let l=qp(i,s),a=new Zn(i,l,0).goto(n),c=new Zn(s,l,0).goto(n);for(;;){if(a.to!=c.to||!vc(a.active,c.active)||a.point&&(!c.point||!a.point.eq(c.point)))return!1;if(a.to>o)return!0;a.next(),c.next()}}static spans(e,t,n,o,i=-1){let s=new Zn(e,null,i).goto(t),l=t,a=s.openStart;for(;;){let c=Math.min(s.to,n);if(s.point){let u=s.activeForPoint(s.to),h=s.pointFrom<t?u.length+1:Math.min(u.length,a);o.point(l,c,s.point,u,h,s.pointRank),a=Math.min(s.openEnd(c),u.length)}else c>l&&(o.span(l,c,s.active,a),a=s.openEnd(c));if(s.to>n)return a+(s.point&&s.to>n?1:0);l=s.to,s.next()}}static of(e,t=!1){let n=new Wt;for(let o of e instanceof rr?[e]:t?wT(e):e)n.add(o.from,o.to,o.value);return n.finish()}};oe.empty=new oe([],[],null,-1);function wT(r){if(r.length>1)for(let e=r[0],t=1;t<r.length;t++){let n=r[t];if(xc(e,n)>0)return r.slice().sort(xc);e=n}return r}oe.empty.nextLayer=oe.empty;var Wt=class{finishChunk(e){this.chunks.push(new Zo(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Wt)).add(e,t,n)}addInner(e,t,n){let o=e-this.lastTo||n.startSide-this.last.endSide;if(o<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(oe.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=oe.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function qp(r,e,t){let n=new Map;for(let i of r)for(let s=0;s<i.chunk.length;s++)i.chunk[s].maxPoint<=0&&n.set(i.chunk[s],i.chunkPos[s]);let o=new Set;for(let i of e)for(let s=0;s<i.chunk.length;s++){let l=n.get(i.chunk[s]);l!=null&&(t?t.mapPos(l):l)==i.chunkPos[s]&&!(t!=null&&t.touchesRange(l,l+i.chunk[s].length))&&o.add(i.chunk[s])}return o}var Ns=class{constructor(e,t,n,o=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=o}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let o=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(o)||this.layer.chunkEnd(this.chunkIndex)<e||o.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let o=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<o)&&this.setRangeIndex(o)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},or=class{constructor(e){this.heap=e}static from(e,t=null,n=-1){let o=[];for(let i=0;i<e.length;i++)for(let s=e[i];!s.isEmpty;s=s.nextLayer)s.maxPoint>=n&&o.push(new Ns(s,t,n,i));return o.length==1?o[0]:new or(o)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)uc(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)uc(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),uc(this.heap,0)}}};function uc(r,e){for(let t=r[e];;){let n=(e<<1)+1;if(n>=r.length)break;let o=r[n];if(n+1<r.length&&o.compare(r[n+1])>=0&&(o=r[n+1],n++),t.compare(o)<0)break;r[n]=t,r[e]=o,e=n}}var Zn=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=or.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Es(this.active,e),Es(this.activeTo,e),Es(this.activeRank,e),this.minActive=jp(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:o,rank:i}=this.cursor;for(;t<this.activeRank.length&&this.activeRank[t]<=i;)t++;Rs(this.active,t,n),Rs(this.activeTo,t,o),Rs(this.activeRank,t,i),e&&Rs(e,t,this.cursor.from),this.minActive=jp(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let o=this.minActive;if(o>-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>e){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),n&&Es(n,o)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let i=this.cursor.value;if(!i.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=i,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=i.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let o=n.length-1;o>=0&&n[o]<e;o--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function Kp(r,e,t,n,o,i){r.goto(e),t.goto(n);let s=n+o,l=n,a=n-e;for(;;){let c=r.to+a-t.to||r.endSide-t.endSide,u=c<0?r.to+a:t.to,h=Math.min(u,s);if(r.point||t.point?r.point&&t.point&&(r.point==t.point||r.point.eq(t.point))&&vc(r.activeForPoint(r.to),t.activeForPoint(t.to))||i.comparePoint(l,h,r.point,t.point):h>l&&!vc(r.active,t.active)&&i.compareRange(l,h,r.active,t.active),u>s)break;l=u,c<=0&&r.next(),c>=0&&t.next()}}function vc(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!=e[t]&&!r[t].eq(e[t]))return!1;return!0}function Es(r,e){for(let t=e,n=r.length-1;t<n;t++)r[t]=r[t+1];r.pop()}function Rs(r,e,t){for(let n=r.length-1;n>=e;n--)r[n+1]=r[n];r[e]=t}function jp(r,e){let t=-1,n=1e9;for(let o=0;o<e.length;o++)(e[o]-n||r[o].endSide-r[t].endSide)<0&&(t=o,n=e[o]);return t}function lr(r,e,t=r.length){let n=0;for(let o=0;o<t;)r.charCodeAt(o)==9?(n+=e-n%e,o++):(n++,o=Ve(r,o));return n}function um(r,e,t,n){for(let o=0,i=0;;){if(i>=e)return o;if(o==r.length)break;i+=r.charCodeAt(o)==9?t-i%t:1,o=Ve(r,o)}return n===!0?-1:r.length}var Cc="\u037C",hm=typeof Symbol>"u"?"__"+Cc:Symbol.for(Cc),Tc=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),fm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},pt=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function o(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function i(s,l,a,c){let u=[],h=/^@(\w+)\b/.exec(s[0]),f=h&&h[1]=="keyframes";if(h&&l==null)return a.push(s[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))i(d.split(/,\s*/).map(m=>s.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!h)throw new RangeError("The value of a property ("+d+") should be a primitive value.");i(o(d),p,u,f)}else p!=null&&u.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(u.length||f)&&a.push((n&&!h&&!c?s.map(n):s).join(", ")+" {"+u.join(" ")+"}")}for(let s in e)i(o(s),e[s],this.rules)}getRules(){return this.rules.join(`
22
- `)}static newName(){let e=fm[hm]||1;return fm[hm]=e+1,Cc+e.toString(36)}static mount(e,t){(e[Tc]||new kc(e)).mount(Array.isArray(t)?t:[t])}},dm=new Map,kc=class{constructor(e){let t=e.ownerDocument||e,n=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let o=dm.get(t);if(o)return e.adoptedStyleSheets=[o.sheet,...e.adoptedStyleSheets],e[Tc]=o;this.sheet=new n.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],dm.set(t,this)}else{this.styleTag=t.createElement("style");let o=e.head||e;o.insertBefore(this.styleTag,o.firstChild)}this.modules=[],e[Tc]=this}mount(e){let t=this.sheet,n=0,o=0;for(let i=0;i<e.length;i++){let s=e[i],l=this.modules.indexOf(s);if(l<o&&l>-1&&(this.modules.splice(l,1),o--,l=-1),l==-1){if(this.modules.splice(o++,0,s),t)for(let a=0;a<s.rules.length;a++)t.insertRule(s.rules[a],n++)}else{for(;o<l;)n+=this.modules[o++].rules.length;n+=s.rules.length,o++}}if(!t){let i="";for(let s=0;s<this.modules.length;s++)i+=this.modules[s].getRules()+`
23
- `;this.styleTag.textContent=i}}};var rn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Gr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ST=typeof navigator<"u"&&/Mac/.test(navigator.platform),CT=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(be=0;be<10;be++)rn[48+be]=rn[96+be]=String(be);var be;for(be=1;be<=24;be++)rn[be+111]="F"+be;var be;for(be=65;be<=90;be++)rn[be]=String.fromCharCode(be+32),Gr[be]=String.fromCharCode(be);var be;for(Vs in rn)Gr.hasOwnProperty(Vs)||(Gr[Vs]=rn[Vs]);var Vs;function pm(r){var e=ST&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||CT&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Gr:rn)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Js(r){let e;return r.nodeType==11?e=r.getSelection?r:r.ownerDocument:e=r,e.getSelection()}function Dc(r,e){return e?r==e||r.contains(e.nodeType!=1?e.parentNode:e):!1}function TT(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Us(r,e){if(!e.anchorNode)return!1;try{return Dc(r,e.anchorNode)}catch{return!1}}function ii(r){return r.nodeType==3?cr(r,0,r.nodeValue.length).getClientRects():r.nodeType==1?r.getClientRects():[]}function Qs(r,e,t,n){return t?mm(r,e,t,n,-1)||mm(r,e,t,n,1):!1}function Ys(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e}function mm(r,e,t,n,o){for(;;){if(r==t&&e==n)return!0;if(e==(o<0?0:kn(r))){if(r.nodeName=="DIV")return!1;let i=r.parentNode;if(!i||i.nodeType!=1)return!1;e=Ys(r)+(o<0?0:1),r=i}else if(r.nodeType==1){if(r=r.childNodes[e+(o<0?-1:0)],r.nodeType==1&&r.contentEditable=="false")return!1;e=o<0?kn(r):0}else return!1}}function kn(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function hu(r,e){let t=e?r.left:r.right;return{left:t,right:t,top:r.top,bottom:r.bottom}}function kT(r){return{left:0,right:r.innerWidth,top:0,bottom:r.innerHeight}}function MT(r,e,t,n,o,i,s,l){let a=r.ownerDocument,c=a.defaultView||window;for(let u=r,h=!1;u&&!h;)if(u.nodeType==1){let f,d=u==a.body;if(d)f=kT(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(h=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let g=u.getBoundingClientRect();f={left:g.left,right:g.left+u.clientWidth,top:g.top,bottom:g.top+u.clientHeight}}let p=0,m=0;if(o=="nearest")e.top<f.top?(m=-(f.top-e.top+s),t>0&&e.bottom>f.bottom+m&&(m=e.bottom-f.bottom+m+s)):e.bottom>f.bottom&&(m=e.bottom-f.bottom+s,t<0&&e.top-m<f.top&&(m=-(f.top+m-e.top+s)));else{let g=e.bottom-e.top,y=f.bottom-f.top;m=(o=="center"&&g<=y?e.top+g/2-y/2:o=="start"||o=="center"&&t<0?e.top-s:e.bottom-y+s)-f.top}if(n=="nearest"?e.left<f.left?(p=-(f.left-e.left+i),t>0&&e.right>f.right+p&&(p=e.right-f.right+p+i)):e.right>f.right&&(p=e.right-f.right+i,t<0&&e.left<f.left+p&&(p=-(f.left+p-e.left+i))):p=(n=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:n=="start"==l?e.left-i:e.right-(f.right-f.left)+i)-f.left,p||m)if(d)c.scrollBy(p,m);else{let g=0,y=0;if(m){let v=u.scrollTop;u.scrollTop+=m,y=u.scrollTop-v}if(p){let v=u.scrollLeft;u.scrollLeft+=p,g=u.scrollLeft-v}e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y},g&&Math.abs(g-p)<1&&(n="nearest"),y&&Math.abs(y-m)<1&&(o="nearest")}if(d)break;u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function ET(r){let e=r.ownerDocument;for(let t=r.parentNode;t&&t!=e.body;)if(t.nodeType==1){if(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}var Lc=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?kn(t):0),n,Math.min(e.focusOffset,n?kn(n):0))}set(e,t,n,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=o}},qr=null;function jm(r){if(r.setActive)return r.setActive();if(qr)return r.focus(qr);let e=[];for(let t=r;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(r.focus(qr==null?{get preventScroll(){return qr={preventScroll:!0},!0}}:void 0),!qr){qr=!1;for(let t=0;t<e.length;){let n=e[t++],o=e[t++],i=e[t++];n.scrollTop!=o&&(n.scrollTop=o),n.scrollLeft!=i&&(n.scrollLeft=i)}}}var gm;function cr(r,e,t=e){let n=gm||(gm=document.createRange());return n.setEnd(r,t),n.setStart(r,e),n}function Jr(r,e,t){let n={key:e,code:e,keyCode:t,which:t,cancelable:!0},o=new KeyboardEvent("keydown",n);o.synthetic=!0,r.dispatchEvent(o);let i=new KeyboardEvent("keyup",n);return i.synthetic=!0,r.dispatchEvent(i),o.defaultPrevented||i.defaultPrevented}function RT(r){for(;r;){if(r&&(r.nodeType==9||r.nodeType==11&&r.host))return r;r=r.assignedSlot||r.parentNode}return null}function Jm(r){for(;r.attributes.length;)r.removeAttributeNode(r.attributes[0])}function IT(r,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,kn(t));;)if(n){if(t.nodeType!=1)return!1;let o=t.childNodes[n-1];o.contentEditable=="false"?n--:(t=o,n=kn(t))}else{if(t==r)return!0;n=Ys(t),t=t.parentNode}}function Qm(r){return r.scrollTop>Math.max(1,r.scrollHeight-r.clientHeight-4)}var Pe=class{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Pe(e.parentNode,Ys(e),t)}static after(e,t){return new Pe(e.parentNode,Ys(e)+1,t)}},fu=[],ne=class{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,o=null,i;for(let s of this.children){if(s.flags&7){if(!s.dom&&(i=o?o.nextSibling:n.firstChild)){let l=ne.get(i);(!l||!l.parent&&l.canReuseDOM(s))&&s.reuseDOM(i)}s.sync(e,t),s.flags&=-8}if(i=o?o.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&i!=s.dom&&(t.written=!0),s.dom.parentNode==n)for(;i&&i!=s.dom;)i=ym(i);else n.insertBefore(s.dom,i);o=s.dom}for(i=o?o.nextSibling:n.firstChild,i&&t&&t.node==n&&(t.written=!0);i;)i=ym(i)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let o=kn(e)==0?0:t==0?-1:1;for(;;){let i=e.parentNode;if(i==this.dom)break;o==0&&i.firstChild!=i.lastChild&&(e==i.firstChild?o=-1:o=1),e=i}o<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!ne.get(n);)n=n.nextSibling;if(!n)return this.length;for(let o=0,i=0;;o++){let s=this.children[o];if(s.dom==n)return i;i+=s.length+s.breakAfter}}domBoundsAround(e,t,n=0){let o=-1,i=-1,s=-1,l=-1;for(let a=0,c=n,u=n;a<this.children.length;a++){let h=this.children[a],f=c+h.length;if(c<e&&f>t)return h.domBoundsAround(e,t,c);if(f>=e&&o==-1&&(o=a,i=c),c>t&&h.dom.parentNode==this.dom){s=a,l=u;break}u=f,c=f+h.breakAfter}return{from:i,to:l<0?n+this.length:l,startDOM:(o?this.children[o-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s<this.children.length&&s>=0?this.children[s].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=fu){this.markDirty();for(let o=e;o<t;o++){let i=this.children[o];i.parent==this&&i.destroy()}this.children.splice(e,t-e,...n);for(let o=0;o<n.length;o++)n[o].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Xs(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,o,i,s){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){this.parent=null}};ne.prototype.breakAfter=0;function ym(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}var Xs=class{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}};function Ym(r,e,t,n,o,i,s,l,a){let{children:c}=r,u=c.length?c[e]:null,h=i.length?i[i.length-1]:null,f=h?h.breakAfter:s;if(!(e==n&&u&&!s&&!f&&i.length<2&&u.merge(t,o,i.length?h:null,t==0,l,a))){if(n<c.length){let d=c[n];d&&o<d.length?(e==n&&(d=d.split(o),o=0),!f&&h&&d.merge(0,o,h,!0,0,a)?i[i.length-1]=d:(o&&d.merge(0,o,null,!1,0,a),i.push(d))):d!=null&&d.breakAfter&&(h?h.breakAfter=1:s=1),n++}for(u&&(u.breakAfter=s,t>0&&(!s&&i.length&&u.merge(t,u.length,i[0],!1,l,0)?u.breakAfter=i.shift().breakAfter:(t<u.length||u.children.length&&u.children[u.children.length-1].length==0)&&u.merge(t,u.length,null,!1,l,0),e++));e<n&&i.length;)if(c[n-1].become(i[i.length-1]))n--,i.pop(),a=i.length?0:l;else if(c[e].become(i[0]))e++,i.shift(),l=i.length?0:a;else break;!i.length&&e&&n<c.length&&!c[e-1].breakAfter&&c[n].merge(0,0,c[e-1],!1,l,a)&&e--,(e<n||i.length)&&r.replaceChildren(e,n,i)}}function Xm(r,e,t,n,o,i){let s=r.childCursor(),{i:l,off:a}=s.findPos(t,1),{i:c,off:u}=s.findPos(e,-1),h=e-t;for(let f of n)h+=f.length;r.length+=h,Ym(r,c,u,l,a,n,0,o,i)}var Kr="\uFFFF",Zs=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(Z.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Kr}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let o=e;;){this.findPointBefore(n,o);let i=this.text.length;this.readNode(o);let s=o.nextSibling;if(s==t)break;let l=ne.get(o),a=ne.get(s);(l&&a?l.breakAfter:(l?l.breakAfter:bm(o))||bm(s)&&(o.nodeName!="BR"||o.cmIgnore)&&this.text.length>i)&&this.lineBreak(),o=s}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,s=1,l;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(l=o.exec(t))&&(i=l.index,s=l[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),s>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=s-1);n=i+s}}readNode(e){if(e.cmIgnore)return;let t=ne.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let o=n.iter();!o.next().done;)o.lineBreak?this.lineBreak():this.append(o.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+Math.min(t,n.offset))}};function bm(r){return r.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName)}var el=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},nt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ac=typeof document<"u"?document:{documentElement:{style:{}}},Oc=/Edge\/(\d+)/.exec(nt.userAgent),Zm=/MSIE \d/.test(nt.userAgent),Nc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nt.userAgent),sl=!!(Zm||Nc||Oc),xm=!sl&&/gecko\/(\d+)/i.test(nt.userAgent),Mc=!sl&&/Chrome\/(\d+)/.exec(nt.userAgent),vm="webkitFontSmoothing"in Ac.documentElement.style,eg=!sl&&/Apple Computer/.test(nt.vendor),wm=eg&&(/Mobile\/\w+/.test(nt.userAgent)||nt.maxTouchPoints>2),H={mac:wm||/Mac/.test(nt.platform),windows:/Win/.test(nt.platform),linux:/Linux|X11/.test(nt.platform),ie:sl,ie_version:Zm?Ac.documentMode||6:Nc?+Nc[1]:Oc?+Oc[1]:0,gecko:xm,gecko_version:xm?+(/Firefox\/(\d+)/.exec(nt.userAgent)||[0,0])[1]:0,chrome:!!Mc,chrome_version:Mc?+Mc[1]:0,ios:wm,android:/Android\b/.test(nt.userAgent),webkit:vm,safari:eg,webkit_version:vm?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Ac.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},PT=256,gt=class extends ne{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof gt)||this.length-(t-e)+n.length>PT||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new gt(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Pe(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return DT(this.dom,e,t)}},Lt=class extends ne{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let o of t)o.setParent(this)}setAttrs(e){if(Jm(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,o,i,s){return n&&(!(n instanceof Lt&&n.mark.eq(this.mark))||e&&i<=0||t<this.length&&s<=0)?!1:(Xm(this,e,t,n?n.children:[],i-1,s-1),this.markDirty(),!0)}split(e){let t=[],n=0,o=-1,i=0;for(let l of this.children){let a=n+l.length;a>e&&t.push(n<e?l.split(e-n):l),o<0&&n>=e&&(o=i),n=a,i++}let s=this.length-e;return this.length=e,o>-1&&(this.children.length=o,this.markDirty()),new Lt(this.mark,t,s)}domAtPos(e){return tg(this,e)}coordsAt(e,t){return rg(this,e,t)}};function DT(r,e,t){let n=r.nodeValue.length;e>n&&(e=n);let o=e,i=e,s=0;e==0&&t<0||e==n&&t>=0?H.chrome||H.gecko||(e?(o--,s=1):i<n&&(i++,s=-1)):t<0?o--:i<n&&i++;let l=cr(r,o,i).getClientRects();if(!l.length)return null;let a=l[(s?s<0:t>=0)?0:l.length-1];return H.safari&&!s&&a.width==0&&(a=Array.prototype.find.call(l,c=>c.width)||a),s?hu(a,s<0):a||null}var on=class extends ne{constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}static create(e,t,n){return new on(e,t,n)}split(e){let t=on.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,n,o,i,s){return n&&(!(n instanceof on)||!this.widget.compare(n.widget)||e>0&&i<=0||t<this.length&&s<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof on&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Y.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,o=this.posAtStart;return n?n.slice(o,o+this.length):Y.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Pe.before(this.dom):Pe.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let o=this.dom.getClientRects(),i=null;if(!o.length)return null;let s=this.side?this.side<0:e>0;for(let l=s?o.length-1:0;i=o[l],!(e>0?l==0:l==o.length-1||i.top<i.bottom);l+=s?-1:1);return hu(i,!s)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},Mn=class extends ne{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof Mn&&e.side==this.side}split(){return new Mn(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Pe.before(this.dom):Pe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Y.empty}get isHidden(){return!0}};gt.prototype.children=on.prototype.children=Mn.prototype.children=fu;function tg(r,e){let t=r.dom,{children:n}=r,o=0;for(let i=0;o<n.length;o++){let s=n[o],l=i+s.length;if(!(l==i&&s.getSide()<=0)){if(e>i&&e<l&&s.dom.parentNode==t)return s.domAtPos(e-i);if(e<=i)break;i=l}}for(let i=o;i>0;i--){let s=n[i-1];if(s.dom.parentNode==t)return s.domAtPos(s.length)}for(let i=o;i<n.length;i++){let s=n[i];if(s.dom.parentNode==t)return s.domAtPos(0)}return new Pe(t,0)}function ng(r,e,t){let n,{children:o}=r;t>0&&e instanceof Lt&&o.length&&(n=o[o.length-1])instanceof Lt&&n.mark.eq(e.mark)?ng(n,e.children[0],t-1):(o.push(e),e.setParent(r)),r.length+=e.length}function rg(r,e,t){let n=null,o=-1,i=null,s=-1;function l(c,u){for(let h=0,f=0;h<c.children.length&&f<=u;h++){let d=c.children[h],p=f+d.length;p>=u&&(d.children.length?l(d,u-f):(!i||i.isHidden&&t>0)&&(p>u||f==p&&d.getSide()>0)?(i=d,s=u-f):(f<u||f==p&&d.getSide()<0&&!d.isHidden)&&(n=d,o=u-f)),f=p}}l(r,e);let a=(t<0?n:i)||n||i;return a?a.coordsAt(Math.max(0,a==n?o:s),t):LT(r)}function LT(r){let e=r.dom.lastChild;if(!e)return r.dom.getBoundingClientRect();let t=ii(e);return t[t.length-1]||null}function Vc(r,e){for(let t in r)t=="class"&&e.class?e.class+=" "+r.class:t=="style"&&e.style?e.style+=";"+r.style:e[t]=r[t];return e}var Sm=Object.create(null);function du(r,e,t){if(r==e)return!0;r||(r=Sm),e||(e=Sm);let n=Object.keys(r),o=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=o.length-(t&&o.indexOf(t)>-1?1:0))return!1;for(let i of n)if(i!=t&&(o.indexOf(i)==-1||r[i]!==e[i]))return!1;return!0}function Fc(r,e,t){let n=null;if(e)for(let o in e)t&&o in t||r.removeAttribute(n=o);if(t)for(let o in t)e&&e[o]==t[o]||r.setAttribute(n=o,t[o]);return!!n}function AT(r){let e=Object.create(null);for(let t=0;t<r.attributes.length;t++){let n=r.attributes[t];e[n.name]=n.value}return e}var ln=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}destroy(e){}},me=function(r){return r[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r}(me||(me={})),Se=class extends Dt{constructor(e,t,n,o){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=o}get heightRelevant(){return!1}static mark(e){return new ur(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Gt(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,o;if(e.isBlockGap)n=-5e8,o=4e8;else{let{start:i,end:s}=og(e,t);n=(i?t?-3e8:-1:5e8)-1,o=(s?t?2e8:1:-6e8)+1}return new Gt(e,n,o,t,e.widget||null,!0)}static line(e){return new hr(e)}static set(e,t=!1){return oe.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Se.none=oe.empty;var ur=class extends Se{constructor(e){let{start:t,end:n}=og(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof ur&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&du(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};ur.prototype.point=!1;var hr=class extends Se{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof hr&&this.spec.class==e.spec.class&&du(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};hr.prototype.mapMode=Ne.TrackBefore;hr.prototype.point=!0;var Gt=class extends Se{constructor(e,t,n,o,i,s){super(t,n,i,e),this.block=o,this.isReplace=s,this.mapMode=o?t<=0?Ne.TrackBefore:Ne.TrackAfter:Ne.TrackDel}get type(){return this.startSide<this.endSide?me.WidgetRange:this.startSide<=0?me.WidgetBefore:me.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Gt&&OT(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};Gt.prototype.point=!0;function og(r,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=r;return t==null&&(t=r.inclusive),n==null&&(n=r.inclusive),{start:t!=null?t:e,end:n!=null?n:e}}function OT(r,e){return r==e||!!(r&&e&&r.compare(e))}function Bc(r,e,t,n=0){let o=t.length-1;o>=0&&t[o]+n>=r?t[o]=Math.max(t[o],e):t.push(r,e)}var Ie=class extends ne{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,o,i,s){if(n){if(!(n instanceof Ie))return!1;this.dom||n.transferDOM(this)}return o&&this.setDeco(n?n.attrs:null),Xm(this,e,t,n?n.children:[],i,s),!0}split(e){let t=new Ie;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:o}=this.childPos(e);o&&(t.append(this.children[n].split(o),0),this.children[n].merge(o,this.children[n].length,null,!1,0,0),n++);for(let i=n;i<this.children.length;i++)t.append(this.children[i],0);for(;n>0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){du(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){ng(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Vc(t,this.attrs||{})),n&&(this.attrs=Vc({class:n},this.attrs||{}))}domAtPos(e){return tg(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Jm(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Fc(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let o=this.dom.lastChild;for(;o&&ne.get(o)instanceof Lt;)o=o.lastChild;if(!o||!this.length||o.nodeName!="BR"&&((n=ne.get(o))===null||n===void 0?void 0:n.isEditable)==!1&&(!H.ios||!this.children.some(i=>i instanceof gt))){let i=document.createElement("BR");i.cmIgnore=!0,this.dom.appendChild(i)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof gt)||/[^ -~]/.test(n.text))return null;let o=ii(n.dom);if(o.length!=1)return null;e+=o[0].width,t=o[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=rg(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:o}=this.parent.view.viewState,i=n.bottom-n.top;if(Math.abs(i-o.lineHeight)<2&&o.textHeight<i){let s=(i-o.textHeight)/2;return{top:n.top+s,bottom:n.bottom-s,left:n.left,right:n.left}}}return n}become(e){return!1}get type(){return me.Text}static find(e,t){for(let n=0,o=0;n<e.children.length;n++){let i=e.children[n],s=o+i.length;if(s>=t){if(i instanceof Ie)return i;if(s>t)break}o=s+i.breakAfter}return null}},sn=class extends ne{constructor(e,t,n){super(),this.widget=e,this.length=t,this.type=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,o,i,s){return n&&(!(n instanceof sn)||!this.widget.compare(n.widget)||e>0&&i<=0||t<this.length&&s<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?Pe.before(this.dom):Pe.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new sn(this.widget,t,this.type);return n.breakAfter=this.breakAfter,n}get children(){return fu}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Y.empty}domBoundsAround(){return null}become(e){return e instanceof sn&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.type=e.type,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},ar=class{constructor(e,t,n,o){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=o,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!e.breakAfter&&!(e instanceof sn&&e.type==me.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ie),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Fs(new Mn(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:i,lineBreak:s,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(s){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=i,this.textOff=0}let o=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Fs(new gt(this.text.slice(this.textOff,this.textOff+o)),t),n),this.atCursorPos=!0,this.textOff+=o,e-=o,n=0}}span(e,t,n,o){this.buildText(t-e,n,o),this.pos=t,this.openStart<0&&(this.openStart=o)}point(e,t,n,o,i,s){if(this.disallowBlockEffectsFor[s]&&n instanceof Gt){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(n instanceof Gt)if(n.block){let{type:a}=n;a==me.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new sn(n.widget||new tl("div"),l,a))}else{let a=on.create(n.widget||new tl("span"),l,l?0:n.startSide),c=this.atCursorPos&&!a.isEditable&&i<=o.length&&(e<t||n.startSide>0),u=!a.isEditable&&(e<t||i>o.length||n.startSide<=0),h=this.getLine();this.pendingBuffer==2&&!c&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(o),c&&(h.append(Fs(new Mn(1),o),i),i=o.length+Math.max(0,i-o.length)),h.append(Fs(a,o),i),this.atCursorPos=u,this.pendingBuffer=u?e<t||i>o.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=o.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=i)}static build(e,t,n,o,i){let s=new ar(e,t,n,i);return s.openEnd=oe.spans(o,t,n,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}};function Fs(r,e){for(let t of e)r=new Lt(t,[r],r.length);return r}var tl=class extends ln{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}},ig=$.define(),sg=$.define(),lg=$.define(),ag=$.define(),Hc=$.define(),cg=$.define(),ug=$.define(),hg=$.define({combine:r=>r.some(e=>e)}),fg=$.define({combine:r=>r.some(e=>e)}),Qr=class{constructor(e,t="nearest",n="nearest",o=5,i=5){this.range=e,this.y=t,this.x=n,this.yMargin=o,this.xMargin=i}map(e){return e.empty?this:new Qr(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}},Cm=ie.define({map:(r,e)=>r.map(e)});function Ut(r,e,t){let n=r.facet(ag);n.length?n[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var ll=$.define({combine:r=>r.length?r[0]:!0}),NT=0,ei=$.define(),yt=class{constructor(e,t,n,o){this.id=e,this.create=t,this.domEventHandlers=n,this.extension=o(this)}static define(e,t){let{eventHandlers:n,provide:o,decorations:i}=t||{};return new yt(NT++,e,n,s=>{let l=[ei.of(s)];return i&&l.push(si.of(a=>{let c=a.plugin(s);return c?i(c):Se.none})),o&&l.push(o(s)),l})}static fromClass(e,t){return yt.define(n=>new e(n),t)}},ri=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Ut(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Ut(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Ut(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},dg=$.define(),pu=$.define(),si=$.define(),mu=$.define(),pg=$.define();function mg(r){let e=0,t=0,n=0,o=0;for(let i of r.state.facet(pg)){let s=i(r);s&&(s.left!=null&&(e=Math.max(e,s.left)),s.right!=null&&(t=Math.max(t,s.right)),s.top!=null&&(n=Math.max(n,s.top)),s.bottom!=null&&(o=Math.max(o,s.bottom)))}return{left:e,right:t,top:n,bottom:o}}var ti=$.define(),Xe=class{constructor(e,t,n,o){this.fromA=e,this.toA=t,this.fromB=n,this.toB=o}join(e){return new Xe(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let o=e[t-1];if(!(o.fromA>n.toA)){if(o.toA<n.fromA)break;n=n.join(o),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let o=0,i=0,s=0,l=0;;o++){let a=o==e.length?null:e[o],c=s-l,u=a?a.fromB:1e9;for(;i<t.length&&t[i]<u;){let h=t[i],f=t[i+1],d=Math.max(l,h),p=Math.min(u,f);if(d<=p&&new Xe(d+c,p+c,d,p).addToSet(n),f>u)break;i+=2}if(!a)return n;new Xe(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),s=a.toA,l=a.toB}}},Yr=class{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=ue.empty(this.startState.doc.length);for(let i of n)this.changes=this.changes.compose(i.changes);let o=[];this.changes.iterChangedRanges((i,s,l,a)=>o.push(new Xe(i,s,l,a))),this.changedRanges=o}static create(e,t,n){return new Yr(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},pe=function(r){return r[r.LTR=0]="LTR",r[r.RTL=1]="RTL",r}(pe||(pe={})),_c=pe.LTR,VT=pe.RTL;function gg(r){let e=[];for(let t=0;t<r.length;t++)e.push(1<<+r[t]);return e}var FT=gg("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),BT=gg("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),zc=Object.create(null),$t=[];for(let r of["()","[]","{}"]){let e=r.charCodeAt(0),t=r.charCodeAt(1);zc[e]=t,zc[t]=-e}function HT(r){return r<=247?FT[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?BT[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:r==8204?256:1}var _T=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Tn=class{constructor(e,t,n){this.from=e,this.to=t,this.level=n}get dir(){return this.level%2?VT:_c}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,n,o){let i=-1;for(let s=0;s<e.length;s++){let l=e[s];if(l.from<=t&&l.to>=t){if(l.level==n)return s;(i<0||(o!=0?o<0?l.from<t:l.to>t:e[i].level>l.level))&&(i=s)}}if(i<0)throw new RangeError("Index out of range");return i}},fe=[];function zT(r,e){let t=r.length,n=e==_c?1:2,o=e==_c?2:1;if(!r||n==1&&!_T.test(r))return yg(t);for(let s=0,l=n,a=n;s<t;s++){let c=HT(r.charCodeAt(s));c==512?c=l:c==8&&a==4&&(c=16),fe[s]=c==4?2:c,c&7&&(a=c),l=c}for(let s=0,l=n,a=n;s<t;s++){let c=fe[s];if(c==128)s<t-1&&l==fe[s+1]&&l&24?c=fe[s]=l:fe[s]=256;else if(c==64){let u=s+1;for(;u<t&&fe[u]==64;)u++;let h=s&&l==8||u<t&&fe[u]==8?a==1?1:8:256;for(let f=s;f<u;f++)fe[f]=h;s=u-1}else c==8&&a==1&&(fe[s]=1);l=c,c&7&&(a=c)}for(let s=0,l=0,a=0,c,u,h;s<t;s++)if(u=zc[c=r.charCodeAt(s)])if(u<0){for(let f=l-3;f>=0;f-=3)if($t[f+1]==-u){let d=$t[f+2],p=d&2?n:d&4?d&1?o:n:0;p&&(fe[s]=fe[$t[f]]=p),l=f;break}}else{if($t.length==189)break;$t[l++]=s,$t[l++]=c,$t[l++]=a}else if((h=fe[s])==2||h==1){let f=h==n;a=f?0:1;for(let d=l-3;d>=0;d-=3){let p=$t[d+2];if(p&2)break;if(f)$t[d+2]|=2;else{if(p&4)break;$t[d+2]|=4}}}for(let s=0;s<t;s++)if(fe[s]==256){let l=s+1;for(;l<t&&fe[l]==256;)l++;let a=(s?fe[s-1]:n)==1,c=(l<t?fe[l]:n)==1,u=a==c?a?1:2:n;for(let h=s;h<l;h++)fe[h]=u;s=l-1}let i=[];if(n==1)for(let s=0;s<t;){let l=s,a=fe[s++]!=1;for(;s<t&&a==(fe[s]!=1);)s++;if(a)for(let c=s;c>l;){let u=c,h=fe[--c]!=2;for(;c>l&&h==(fe[c-1]!=2);)c--;i.push(new Tn(c,u,h?2:1))}else i.push(new Tn(l,s,0))}else for(let s=0;s<t;){let l=s,a=fe[s++]==2;for(;s<t&&a==(fe[s]==2);)s++;i.push(new Tn(l,s,a?1:2))}return i}function yg(r){return[new Tn(0,r,0)]}var bg="";function WT(r,e,t,n,o){var i;let s=n.head-r.from,l=-1;if(s==0){if(!o||!r.length)return null;e[0].level!=t&&(s=e[0].side(!1,t),l=0)}else if(s==r.length){if(o)return null;let f=e[e.length-1];f.level!=t&&(s=f.side(!0,t),l=e.length-1)}l<0&&(l=Tn.find(e,s,(i=n.bidiLevel)!==null&&i!==void 0?i:-1,n.assoc));let a=e[l];s==a.side(o,t)&&(a=e[l+=o?1:-1],s=a.side(!o,t));let c=o==(a.dir==t),u=Ve(r.text,s,c);if(bg=r.text.slice(Math.min(s,u),Math.max(s,u)),u!=a.side(o,t))return I.cursor(u+r.from,c?-1:1,a.level);let h=l==(o?e.length-1:0)?null:e[l+(o?1:-1)];return!h&&a.level!=t?I.cursor(o?r.to:r.from,o?-1:1,t):h&&h.level<a.level?I.cursor(h.side(!o,t)+r.from,o?1:-1,h.level):I.cursor(u+r.from,o?-1:1,a.level)}var nl=class extends ne{constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ie],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Xe(0,0,0,e.state.doc.length)],0,null)}get length(){return this.view.state.doc.length}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:l,toA:a})=>a<this.minWidthFrom||l>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let n=this.view.inputState.composing<0?null:UT(this.view,e.changes);if(this.hasComposition){this.markedForComposition.clear();let{from:l,to:a}=this.hasComposition;t=new Xe(l,a,e.changes.mapPos(l,-1),e.changes.mapPos(a,1)).addToSet(t.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(H.ie||H.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,i=this.updateDeco(),s=qT(o,i,e.changes);return t=Xe.extendWithRanges(t,s),!(this.flags&7)&&t.length==0?!1:(this.updateInner(t,e.startState.doc.length,n),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:o}=this.view;o.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=H.chrome||H.ios?{node:o.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,s),this.flags&=-8,s&&(s.written||o.selectionRange.focusNode!=s.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(s=>s.flags&=-9);let i=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.children)s instanceof sn&&s.widget instanceof rl&&i.push(s.dom);o.updateGaps(i)}updateChildren(e,t,n){let o=n?n.range.addToSet(e.slice()):e,i=this.childCursor(t);for(let s=o.length-1;;s--){let l=s>=0?o[s]:null;if(!l)break;let{fromA:a,toA:c,fromB:u,toB:h}=l,f,d,p,m;if(n&&n.range.fromB<h&&n.range.toB>u){let x=ar.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),S=ar.build(this.view.state.doc,n.range.toB,h,this.decorations,this.dynamicDecorationMap);d=x.breakAtStart,p=x.openStart,m=S.openEnd;let b=this.compositionView(n);S.breakAtStart?b.breakAfter=1:S.content.length&&b.merge(b.length,b.length,S.content[0],!1,S.openStart,0)&&(b.breakAfter=S.content[0].breakAfter,S.content.shift()),x.content.length&&b.merge(0,0,x.content[x.content.length-1],!0,0,x.openEnd)&&x.content.pop(),f=x.content.concat(b).concat(S.content)}else({content:f,breakAtStart:d,openStart:p,openEnd:m}=ar.build(this.view.state.doc,u,h,this.decorations,this.dynamicDecorationMap));let{i:g,off:y}=i.findPos(c,1),{i:v,off:w}=i.findPos(a,-1);Ym(this,v,w,g,y,f,d,p,m)}n&&this.fixCompositionDOM(n)}compositionView(e){let t=new gt(e.text.nodeValue);t.flags|=8;for(let{deco:o}of e.marks)t=new Lt(o,[t],t.length);let n=new Ie;return n.append(t,0),n}fixCompositionDOM(e){let t=(i,s)=>{s.flags|=8,this.markedForComposition.add(s);let l=ne.get(i);l!=s&&(l&&(l.dom=null),s.setDOM(i))},n=this.childPos(e.range.fromB,1),o=this.children[n.i];t(e.line,o);for(let i=e.marks.length-1;i>=-1;i--)n=o.childPos(n.off,1),o=o.children[n.i],t(i>=0?e.marks[i].node:e.text,o)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,o=n==this.dom,i=!o&&Us(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(o||t||i))return;let s=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.domAtPos(l.anchor),c=l.empty?a:this.domAtPos(l.head);if(H.gecko&&l.empty&&!this.hasComposition&&$T(a)){let h=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(h,a.node.childNodes[a.offset]||null)),a=c=new Pe(h,0),s=!0}let u=this.view.observer.selectionRange;(s||!u.focusNode||!Qs(a.node,a.offset,u.anchorNode,u.anchorOffset)||!Qs(c.node,c.offset,u.focusNode,u.focusOffset))&&(this.view.observer.ignore(()=>{H.android&&H.chrome&&this.dom.contains(u.focusNode)&&KT(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let h=Js(this.view.root);if(h)if(l.empty){if(H.gecko){let f=GT(a.node,a.offset);if(f&&f!=3){let d=vg(a.node,a.offset,f==1?1:-1);d&&(a=new Pe(d,f==1?0:d.nodeValue.length))}}h.collapse(a.node,a.offset),l.bidiLevel!=null&&u.cursorBidiLevel!=null&&(u.cursorBidiLevel=l.bidiLevel)}else if(h.extend){h.collapse(a.node,a.offset);try{h.extend(c.node,c.offset)}catch{}}else{let f=document.createRange();l.anchor>l.head&&([a,c]=[c,a]),f.setEnd(c.node,c.offset),f.setStart(a.node,a.offset),h.removeAllRanges(),h.addRange(f)}i&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,c)),this.impreciseAnchor=a.precise?null:new Pe(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new Pe(u.focusNode,u.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Js(e.root),{anchorNode:o,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let s=Ie.find(this,t.head);if(!s)return;let l=s.posAtStart;if(t.head==l||t.head==l+s.length)return;let a=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!a||!c||a.bottom>c.top)return;let u=this.domAtPos(t.head+t.assoc);n.collapse(u.node,u.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(o,i)}nearest(e){for(let t=e;t;){let n=ne.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let o=this.children[t];if(n<o.length||o instanceof Ie)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){for(let n=this.length,o=this.children.length-1;;o--){let i=this.children[o],s=n-i.breakAfter-i.length;if(e>s||e==s&&i.type!=me.WidgetBefore&&i.type!=me.WidgetAfter&&(!o||t==2||this.children[o-1].breakAfter||this.children[o-1].type==me.WidgetBefore&&t>-2))return i.coordsAt(e-s,t);n=s}}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),o=this.children[t];if(!(o instanceof Ie))return null;for(;o.children.length;){let{i:l,off:a}=o.childPos(n,1);for(;;l++){if(l==o.children.length)return null;if((o=o.children[l]).length)break}n=a}if(!(o instanceof gt))return null;let i=Ve(o.text,n);if(i==n)return null;let s=cr(o.dom,n,i).getClientRects();return!s.length||s[0].top>=s[0].bottom?null:s[0]}measureVisibleLineHeights(e){let t=[],{from:n,to:o}=e,i=this.view.contentDOM.clientWidth,s=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==pe.LTR;for(let c=0,u=0;u<this.children.length;u++){let h=this.children[u],f=c+h.length;if(f>o)break;if(c>=n){let d=h.dom.getBoundingClientRect();if(t.push(d.height),s){let p=h.dom.lastChild,m=p?ii(p):[];if(m.length){let g=m[m.length-1],y=a?g.right-d.left:d.right-g.left;y>l&&(l=y,this.minWidth=i,this.minWidthFrom=c,this.minWidthTo=f)}}}c=f+h.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?pe.RTL:pe.LTR}measureTextSize(){for(let i of this.children)if(i instanceof Ie){let s=i.measureTextSize();if(s)return s}let e=document.createElement("div"),t,n,o;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let i=ii(e.firstChild)[0];t=e.getBoundingClientRect().height,n=i?i.width/27:7,o=i?i.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:o}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Xs(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,o=0;;o++){let i=o==t.viewports.length?null:t.viewports[o],s=i?i.from-1:this.length;if(s>n){let l=t.lineBlockAt(s).bottom-t.lineBlockAt(n).top;e.push(Se.replace({widget:new rl(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!i)break;n=i.to+1}return Se.set(e)}updateDeco(){let e=this.view.state.facet(si).map((t,n)=>(this.dynamicDecorationMap[n]=typeof t=="function")?t(this.view):t);for(let t=e.length;t<e.length+3;t++)this.dynamicDecorationMap[t]=!1;return this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),o;if(!n)return;!t.empty&&(o=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,o.left),top:Math.min(n.top,o.top),right:Math.max(n.right,o.right),bottom:Math.max(n.bottom,o.bottom)});let i=mg(this.view),s={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom};MT(this.view.scrollDOM,s,t.head<t.anchor?-1:1,e.x,e.y,e.xMargin,e.yMargin,this.view.textDirection==pe.LTR)}};function $T(r){return r.node.nodeType==1&&r.node.firstChild&&(r.offset==0||r.node.childNodes[r.offset-1].contentEditable=="false")&&(r.offset==r.node.childNodes.length||r.node.childNodes[r.offset].contentEditable=="false")}var rl=class extends ln{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}};function xg(r){let e=r.observer.selectionRange,t=e.focusNode&&vg(e.focusNode,e.focusOffset,0);if(!t)return null;let n=ne.get(t),o,i;if(n instanceof gt)o=n.posAtStart,i=o+n.length;else e:for(let s=0,l=t;;){for(let c=l.previousSibling,u;c;c=c.previousSibling){if(u=ne.get(c)){o=i=u.posAtEnd+s;break e}let h=new Zs([],r.state);if(h.readNode(c),h.text.indexOf(Kr)>-1)return null;s+=h.text.length}if(l=l.parentNode,!l)return null;let a=ne.get(l);if(a){o=i=a.posAtStart+s;break}}return{from:o,to:i,node:t}}function UT(r,e){let t=xg(r);if(!t)return null;let{from:n,to:o,node:i}=t,s=e.mapPos(n,-1),l=e.mapPos(o,1),a=i.nodeValue;if(/[\n\r]/.test(a))return null;if(l-s!=a.length){let f=e.mapPos(n,1),d=e.mapPos(o,-1);if(d-f==a.length)s=f,l=d;else if(r.state.doc.sliceString(l-a.length,l)==a)s=l-a.length;else if(r.state.doc.sliceString(s,s+a.length)==a)l=s+a.length;else return null}let{main:c}=r.state.selection;if(r.state.doc.sliceString(s,l)!=a||s>c.head||l<c.head)return null;let u=[],h=new Xe(n,o,s,l);for(let f=i.parentNode;;f=f.parentNode){let d=ne.get(f);if(d instanceof Lt)u.push({node:f,deco:d.mark});else{if(d instanceof Ie||f.nodeName=="DIV"&&f.parentNode==r.contentDOM)return{range:h,text:i,marks:u,line:f};if(f!=r.contentDOM)u.push({node:f,deco:new ur({inclusive:!0,attributes:AT(f),tagName:f.tagName.toLowerCase()})});else return null}}}function vg(r,e,t){if(t<=0)for(let n=r,o=e;;){if(n.nodeType==3)return n;if(n.nodeType==1&&o>0)n=n.childNodes[o-1],o=kn(n);else break}if(t>=0)for(let n=r,o=e;;){if(n.nodeType==3)return n;if(n.nodeType==1&&o<n.childNodes.length&&t>=0)n=n.childNodes[o],o=0;else break}return null}function GT(r,e){return r.nodeType!=1?0:(e&&r.childNodes[e-1].contentEditable=="false"?1:0)|(e<r.childNodes.length&&r.childNodes[e].contentEditable=="false"?2:0)}var Wc=class{constructor(){this.changes=[]}compareRange(e,t){Bc(e,t,this.changes)}comparePoint(e,t){Bc(e,t,this.changes)}};function qT(r,e,t){let n=new Wc;return oe.compare(r,e,t,n),n.changes}function KT(r,e){for(let t=r;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function jT(r,e,t=1){let n=r.charCategorizer(e),o=r.doc.lineAt(e),i=e-o.from;if(o.length==0)return I.cursor(e);i==0?t=1:i==o.length&&(t=-1);let s=i,l=i;t<0?s=Ve(o.text,i,!1):l=Ve(o.text,i);let a=n(o.text.slice(s,l));for(;s>0;){let c=Ve(o.text,s,!1);if(n(o.text.slice(c,s))!=a)break;s=c}for(;l<o.length;){let c=Ve(o.text,l);if(n(o.text.slice(l,c))!=a)break;l=c}return I.range(s+o.from,l+o.from)}function JT(r,e){return e.left>r?e.left-r:Math.max(0,r-e.right)}function QT(r,e){return e.top>r?e.top-r:Math.max(0,r-e.bottom)}function Ec(r,e){return r.top<e.bottom-1&&r.bottom>e.top+1}function Tm(r,e){return e<r.top?{top:e,left:r.left,right:r.right,bottom:r.bottom}:r}function km(r,e){return e>r.bottom?{top:r.top,left:r.left,right:r.right,bottom:e}:r}function $c(r,e,t){let n,o,i,s,l=!1,a,c,u,h;for(let p=r.firstChild;p;p=p.nextSibling){let m=ii(p);for(let g=0;g<m.length;g++){let y=m[g];o&&Ec(o,y)&&(y=Tm(km(y,o.bottom),o.top));let v=JT(e,y),w=QT(t,y);if(v==0&&w==0)return p.nodeType==3?Mm(p,e,t):$c(p,e,t);if(!n||s>w||s==w&&i>v){n=p,o=y,i=v,s=w;let x=w?t<y.top?-1:1:v?e<y.left?-1:1:0;l=!x||(x>0?g<m.length-1:g>0)}v==0?t>y.bottom&&(!u||u.bottom<y.bottom)?(a=p,u=y):t<y.top&&(!h||h.top>y.top)&&(c=p,h=y):u&&Ec(u,y)?u=km(u,y.bottom):h&&Ec(h,y)&&(h=Tm(h,y.top))}}if(u&&u.bottom>=t?(n=a,o=u):h&&h.top<=t&&(n=c,o=h),!n)return{node:r,offset:0};let f=Math.max(o.left,Math.min(o.right,e));if(n.nodeType==3)return Mm(n,f,t);if(l&&n.contentEditable!="false")return $c(n,f,t);let d=Array.prototype.indexOf.call(r.childNodes,n)+(e>=(o.left+o.right)/2?1:0);return{node:r,offset:d}}function Mm(r,e,t){let n=r.nodeValue.length,o=-1,i=1e9,s=0;for(let l=0;l<n;l++){let a=cr(r,l,l+1).getClientRects();for(let c=0;c<a.length;c++){let u=a[c];if(u.top==u.bottom)continue;s||(s=e-u.left);let h=(u.top>t?u.top-t:t-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&h<i){let f=e>=(u.left+u.right)/2,d=f;if((H.chrome||H.gecko)&&cr(r,l).getBoundingClientRect().left==u.right&&(d=!f),h<=0)return{node:r,offset:l+(d?1:0)};o=l+(d?1:0),i=h}}}return{node:r,offset:o>-1?o:s>0?r.nodeValue.length:0}}function wg(r,e,t,n=-1){var o,i;let s=r.contentDOM.getBoundingClientRect(),l=s.top+r.viewState.paddingTop,a,{docHeight:c}=r.viewState,{x:u,y:h}=e,f=h-l;if(f<0)return 0;if(f>c)return r.state.doc.length;for(let x=r.viewState.heightOracle.textHeight/2,S=!1;a=r.elementAtHeight(f),a.type!=me.Text;)for(;f=n>0?a.bottom+x:a.top-x,!(f>=0&&f<=c);){if(S)return t?null:0;S=!0,n=-n}h=l+f;let d=a.from;if(d<r.viewport.from)return r.viewport.from==0?0:t?null:Em(r,s,a,u,h);if(d>r.viewport.to)return r.viewport.to==r.state.doc.length?r.state.doc.length:t?null:Em(r,s,a,u,h);let p=r.dom.ownerDocument,m=r.root.elementFromPoint?r.root:p,g=m.elementFromPoint(u,h);g&&!r.contentDOM.contains(g)&&(g=null),g||(u=Math.max(s.left+1,Math.min(s.right-1,u)),g=m.elementFromPoint(u,h),g&&!r.contentDOM.contains(g)&&(g=null));let y,v=-1;if(g&&((o=r.docView.nearest(g))===null||o===void 0?void 0:o.isEditable)!=!1){if(p.caretPositionFromPoint){let x=p.caretPositionFromPoint(u,h);x&&({offsetNode:y,offset:v}=x)}else if(p.caretRangeFromPoint){let x=p.caretRangeFromPoint(u,h);x&&({startContainer:y,startOffset:v}=x,(!r.contentDOM.contains(y)||H.safari&&YT(y,v,u)||H.chrome&&XT(y,v,u))&&(y=void 0))}}if(!y||!r.docView.dom.contains(y)){let x=Ie.find(r.docView,d);if(!x)return f>a.top+a.height/2?a.to:a.from;({node:y,offset:v}=$c(x.dom,u,h))}let w=r.docView.nearest(y);if(!w)return null;if(w.isWidget&&((i=w.dom)===null||i===void 0?void 0:i.nodeType)==1){let x=w.dom.getBoundingClientRect();return e.y<x.top||e.y<=x.bottom&&e.x<=(x.left+x.right)/2?w.posAtStart:w.posAtEnd}else return w.localPosFromDOM(y,v)+w.posAtStart}function Em(r,e,t,n,o){let i=Math.round((n-e.left)*r.defaultCharacterWidth);if(r.lineWrapping&&t.height>r.defaultLineHeight*1.5){let l=r.viewState.heightOracle.textHeight,a=Math.floor((o-t.top-(r.defaultLineHeight-l)*.5)/l);i+=a*r.viewState.heightOracle.lineLength}let s=r.state.sliceDoc(t.from,t.to);return t.from+um(s,i,r.state.tabSize)}function YT(r,e,t){let n;if(r.nodeType!=3||e!=(n=r.nodeValue.length))return!1;for(let o=r.nextSibling;o;o=o.nextSibling)if(o.nodeType!=1||o.nodeName!="BR")return!1;return cr(r,n-1,n).getBoundingClientRect().left>t}function XT(r,e,t){if(e!=0)return!1;for(let o=r;;){let i=o.parentNode;if(!i||i.nodeType!=1||i.firstChild!=o)return!1;if(i.classList.contains("cm-line"))break;o=i}let n=r.nodeType==1?r.getBoundingClientRect():cr(r,0,Math.max(r.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Uc(r,e){let t=r.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==me.Text))return n}return t}function ZT(r,e,t,n){let o=Uc(r,e.head),i=!n||o.type!=me.Text||!(r.lineWrapping||o.widgetLineBreaks)?null:r.coordsAtPos(e.assoc<0&&e.head>o.from?e.head-1:e.head);if(i){let s=r.dom.getBoundingClientRect(),l=r.textDirectionAt(o.from),a=r.posAtCoords({x:t==(l==pe.LTR)?s.right-1:s.left+1,y:(i.top+i.bottom)/2});if(a!=null)return I.cursor(a,t?-1:1)}return I.cursor(t?o.to:o.from,t?-1:1)}function Rm(r,e,t,n){let o=r.state.doc.lineAt(e.head),i=r.bidiSpans(o),s=r.textDirectionAt(o.from);for(let l=e,a=null;;){let c=WT(o,i,s,l,t),u=bg;if(!c){if(o.number==(t?r.state.doc.lines:1))return l;u=`
24
- `,o=r.state.doc.line(o.number+(t?1:-1)),i=r.bidiSpans(o),c=I.cursor(t?o.from:o.to)}if(a){if(!a(u))return l}else{if(!n)return c;a=n(u)}l=c}}function ek(r,e,t){let n=r.state.charCategorizer(e),o=n(t);return i=>{let s=n(i);return o==Ge.Space&&(o=s),o==s}}function tk(r,e,t,n){let o=e.head,i=t?1:-1;if(o==(t?r.state.doc.length:0))return I.cursor(o,e.assoc);let s=e.goalColumn,l,a=r.contentDOM.getBoundingClientRect(),c=r.coordsAtPos(o),u=r.documentTop;if(c)s==null&&(s=c.left-a.left),l=i<0?c.top:c.bottom;else{let d=r.viewState.lineBlockAt(o);s==null&&(s=Math.min(a.right-a.left,r.defaultCharacterWidth*(o-d.from))),l=(i<0?d.top:d.bottom)+u}let h=a.left+s,f=n!=null?n:r.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=l+(f+d)*i,m=wg(r,{x:h,y:p},!1,i);if(p<a.top||p>a.bottom||(i<0?m<o:m>o))return I.cursor(m,e.assoc,void 0,s)}}function Gs(r,e,t){for(;;){let n=0;for(let o of r)o.between(e-1,e+1,(i,s,l)=>{if(e>i&&e<s){let a=n||t||(e-i<s-e?-1:1);e=a<0?i:s,n=a}});if(!n)return e}}function Rc(r,e,t){let n=Gs(r.state.facet(mu).map(o=>o(r)),t.from,e.head>t.from?-1:1);return n==t.from?t:I.cursor(n,n<t.from?1:-1)}var Gc=class{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let t=(n,o)=>{this.ignoreDuringComposition(o)||o.type=="keydown"&&this.keydown(e,o)||(this.mustFlushObserver(o)&&e.observer.forceFlush(),this.runCustomHandlers(o.type,e,o)?o.preventDefault():n(e,o))};for(let n in xe){let o=xe[n];e.contentDOM.addEventListener(n,i=>{Im(e,i)&&t(o,i)},Kc[n]),this.registeredEvents.push(n)}e.scrollDOM.addEventListener("mousedown",n=>{if(n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&(t(xe.mousedown,n),!n.defaultPrevented&&n.button==2)){let o=e.contentDOM.style.minHeight;e.contentDOM.style.minHeight="100%",setTimeout(()=>e.contentDOM.style.minHeight=o,200)}}),e.scrollDOM.addEventListener("drop",n=>{n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&t(xe.drop,n)}),H.chrome&&H.chrome_version==102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,H.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var n;let o;this.customHandlers=[];for(let i of t)if(o=(n=i.update(e).spec)===null||n===void 0?void 0:n.domEventHandlers){this.customHandlers.push({plugin:i.value,handlers:o});for(let s in o)this.registeredEvents.indexOf(s)<0&&s!="scroll"&&(this.registeredEvents.push(s),e.contentDOM.addEventListener(s,l=>{Im(e,l)&&this.runCustomHandlers(s,e,l)&&l.preventDefault()}))}}runCustomHandlers(e,t,n){for(let o of this.customHandlers){let i=o.handlers[e];if(i)try{if(i.call(o.plugin,n,t)||n.defaultPrevented)return!0}catch(s){Ut(t.state,s)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let n of this.customHandlers){let o=n.handlers.scroll;if(o)try{o.call(n.plugin,t,e)}catch(i){Ut(e.state,i)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(t.keyCode!=27&&Cg.indexOf(t.keyCode)<0&&(e.inputState.lastEscPress=0),H.android&&H.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return e.observer.delayAndroidKey(t.key,t.keyCode),!0;let n;return H.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((n=Sg.find(o=>o.keyCode==t.keyCode))&&!t.ctrlKey||nk.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=n||t,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let t=this.pendingIOSKey;return t?(this.pendingIOSKey=void 0,Jr(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:H.safari&&!H.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}mustFlushObserver(e){return e.type=="keydown"&&e.keyCode!=229}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}},Sg=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],nk="dthko",Cg=[16,17,18,20,91,92,224,225],Bs=6;function Hs(r){return Math.max(0,r)*.7+8}function rk(r,e){return Math.max(Math.abs(r.clientX-e.clientX),Math.abs(r.clientY-e.clientY))}var qc=class{constructor(e,t,n,o){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=ET(e.contentDOM),this.atoms=e.state.facet(mu).map(s=>s(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Z.allowMultipleSelections)&&ok(e,t),this.dragging=sk(e,t)&&Eg(t)==1?null:!1}start(e){this.dragging===!1&&(e.preventDefault(),this.select(e))}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&rk(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,o=0,i=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},s=mg(this.view);e.clientX-s.left<=i.left+Bs?n=-Hs(i.left-e.clientX):e.clientX+s.right>=i.right-Bs&&(n=Hs(e.clientX-i.right)),e.clientY-s.top<=i.top+Bs?o=-Hs(i.top-e.clientY):e.clientY+s.bottom>=i.bottom-Bs&&(o=Hs(e.clientY-i.bottom)),this.setScrollSpeed(n,o)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let o=e.ranges[n],i=null;if(o.empty){let s=Gs(this.atoms,o.from,0);s!=o.from&&(i=I.cursor(s,-1))}else{let s=Gs(this.atoms,o.from,-1),l=Gs(this.atoms,o.to,1);(s!=o.from||l!=o.to)&&(i=I.range(o.from==o.anchor?s:l,o.from==o.head?s:l))}i&&(t||(t=e.ranges.slice()),t[n]=i)}return t?I.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection)||n.main.assoc!=t.state.selection.main.assoc&&this.dragging===!1)&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.docChanged&&this.dragging&&(this.dragging=this.dragging.map(e.changes)),this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function ok(r,e){let t=r.state.facet(ig);return t.length?t[0](e):H.mac?e.metaKey:e.ctrlKey}function ik(r,e){let t=r.state.facet(sg);return t.length?t[0](e):H.mac?!e.altKey:!e.ctrlKey}function sk(r,e){let{main:t}=r.state.selection;if(t.empty)return!1;let n=Js(r.root);if(!n||n.rangeCount==0)return!0;let o=n.getRangeAt(0).getClientRects();for(let i=0;i<o.length;i++){let s=o[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function Im(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=r.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=ne.get(t))&&n.ignoreEvent(e))return!1;return!0}var xe=Object.create(null),Kc=Object.create(null),Tg=H.ie&&H.ie_version<15||H.ios&&H.webkit_version<604;function lk(r){let e=r.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{r.focus(),t.remove(),kg(r,t.value)},50)}function kg(r,e){let{state:t}=r,n,o=1,i=t.toText(e),s=i.lines==t.selection.ranges.length;if(jc!=null&&t.selection.ranges.every(a=>a.empty)&&jc==i.toString()){let a=-1;n=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==a)return{range:c};a=u.from;let h=t.toText((s?i.line(o++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:h},range:I.cursor(c.from+h.length)}})}else s?n=t.changeByRange(a=>{let c=i.line(o++);return{changes:{from:a.from,to:a.to,insert:c.text},range:I.cursor(a.from+c.length)}}):n=t.replaceSelection(i);r.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}xe.keydown=(r,e)=>{r.inputState.setSelectionOrigin("select"),e.keyCode==27&&(r.inputState.lastEscPress=Date.now())};xe.touchstart=(r,e)=>{r.inputState.lastTouchTime=Date.now(),r.inputState.setSelectionOrigin("select.pointer")};xe.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};Kc.touchstart=Kc.touchmove={passive:!0};xe.mousedown=(r,e)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return;let t=null;for(let n of r.state.facet(lg))if(t=n(r,e),t)break;if(!t&&e.button==0&&(t=uk(r,e)),t){let n=!r.hasFocus;r.inputState.startMouseSelection(new qc(r,e,t,n)),n&&r.observer.ignore(()=>jm(r.contentDOM)),r.inputState.mouseSelection&&r.inputState.mouseSelection.start(e)}};function Pm(r,e,t,n){if(n==1)return I.cursor(e,t);if(n==2)return jT(r.state,e,t);{let o=Ie.find(r.docView,e),i=r.state.doc.lineAt(o?o.posAtEnd:e),s=o?o.posAtStart:i.from,l=o?o.posAtEnd:i.to;return l<r.state.doc.length&&l==i.to&&l++,I.range(s,l)}}var Mg=(r,e)=>r>=e.top&&r<=e.bottom,Dm=(r,e,t)=>Mg(e,t)&&r>=t.left&&r<=t.right;function ak(r,e,t,n){let o=Ie.find(r.docView,e);if(!o)return 1;let i=e-o.posAtStart;if(i==0)return 1;if(i==o.length)return-1;let s=o.coordsAt(i,-1);if(s&&Dm(t,n,s))return-1;let l=o.coordsAt(i,1);return l&&Dm(t,n,l)?1:s&&Mg(n,s)?-1:1}function Lm(r,e){let t=r.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:ak(r,t,e.clientX,e.clientY)}}var ck=H.ie&&H.ie_version<=11,Am=null,Om=0,Nm=0;function Eg(r){if(!ck)return r.detail;let e=Am,t=Nm;return Am=r,Nm=Date.now(),Om=!e||t>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(Om+1)%3:1}function uk(r,e){let t=Lm(r,e),n=Eg(e),o=r.state.selection;return{update(i){i.docChanged&&(t.pos=i.changes.mapPos(t.pos),o=o.map(i.changes))},get(i,s,l){let a=Lm(r,i),c,u=Pm(r,a.pos,a.bias,n);if(t.pos!=a.pos&&!s){let h=Pm(r,t.pos,t.bias,n),f=Math.min(h.from,u.from),d=Math.max(h.to,u.to);u=f<u.from?I.range(f,d):I.range(d,f)}return s?o.replaceRange(o.main.extend(u.from,u.to)):l&&n==1&&o.ranges.length>1&&(c=hk(o,a.pos))?c:l?o.addRange(u):I.create([u])}}}function hk(r,e){for(let t=0;t<r.ranges.length;t++){let{from:n,to:o}=r.ranges[t];if(n<=e&&o>=e)return I.create(r.ranges.slice(0,t).concat(r.ranges.slice(t+1)),r.mainIndex==t?0:r.mainIndex-(r.mainIndex>t?1:0))}return null}xe.dragstart=(r,e)=>{let{selection:{main:t}}=r.state,{mouseSelection:n}=r.inputState;n&&(n.dragging=t),e.dataTransfer&&(e.dataTransfer.setData("Text",r.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove")};function Vm(r,e,t,n){if(!t)return;let o=r.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:i}=r.inputState,s=n&&i&&i.dragging&&ik(r,e)?{from:i.dragging.from,to:i.dragging.to}:null,l={from:o,insert:t},a=r.state.changes(s?[s,l]:l);r.focus(),r.dispatch({changes:a,selection:{anchor:a.mapPos(o,-1),head:a.mapPos(o,1)},userEvent:s?"move.drop":"input.drop"})}xe.drop=(r,e)=>{if(!e.dataTransfer)return;if(r.state.readOnly)return e.preventDefault();let t=e.dataTransfer.files;if(t&&t.length){e.preventDefault();let n=Array(t.length),o=0,i=()=>{++o==t.length&&Vm(r,e,n.filter(s=>s!=null).join(r.state.lineBreak),!1)};for(let s=0;s<t.length;s++){let l=new FileReader;l.onerror=i,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[s]=l.result),i()},l.readAsText(t[s])}}else Vm(r,e,e.dataTransfer.getData("Text"),!0)};xe.paste=(r,e)=>{if(r.state.readOnly)return e.preventDefault();r.observer.flush();let t=Tg?null:e.clipboardData;t?(kg(r,t.getData("text/plain")||t.getData("text/uri-text")),e.preventDefault()):lk(r)};function fk(r,e){let t=r.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),r.focus()},50)}function dk(r){let e=[],t=[],n=!1;for(let o of r.selection.ranges)o.empty||(e.push(r.sliceDoc(o.from,o.to)),t.push(o));if(!e.length){let o=-1;for(let{from:i}of r.selection.ranges){let s=r.doc.lineAt(i);s.number>o&&(e.push(s.text),t.push({from:s.from,to:Math.min(r.doc.length,s.to+1)})),o=s.number}n=!0}return{text:e.join(r.lineBreak),ranges:t,linewise:n}}var jc=null;xe.copy=xe.cut=(r,e)=>{let{text:t,ranges:n,linewise:o}=dk(r.state);if(!t&&!o)return;jc=o?t:null;let i=Tg?null:e.clipboardData;i?(e.preventDefault(),i.clearData(),i.setData("text/plain",t)):fk(r,t),e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};var Rg=tt.define();function Ig(r,e){let t=[];for(let n of r.facet(ug)){let o=n(r,e);o&&t.push(o)}return t?r.update({effects:t,annotations:Rg.of(!0)}):null}function Pg(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let t=Ig(r.state,e);t?r.dispatch(t):r.update([])}},10)}xe.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),Pg(r)};xe.blur=r=>{r.observer.clearSelectionRange(),Pg(r)};xe.compositionstart=xe.compositionupdate=r=>{r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0&&(r.inputState.composing=0)};xe.compositionend=r=>{r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,H.chrome&&H.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50)};xe.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};xe.beforeinput=(r,e)=>{var t;let n;if(H.chrome&&H.android&&(n=Sg.find(o=>o.inputType==e.inputType))&&(r.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let o=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var i;(((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0)>o+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}};var Fm=["pre-wrap","normal","pre-line","break-spaces"],Jc=class{constructor(e){this.lineWrapping=e,this.doc=Y.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Fm.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let o=e[n];o<0?n++:this.heightSamples[Math.floor(o*10)]||(t=!0,this.heightSamples[Math.floor(o*10)]=!0)}return t}refresh(e,t,n,o,i,s){let l=Fm.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=n,this.textHeight=o,this.lineLength=i,a){this.heightSamples={};for(let c=0;c<s.length;c++){let u=s[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return a}},Qc=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},mt=class{constructor(e,t,n,o,i){this.from=e,this.length=t,this.top=n,this.height=o,this._content=i}get type(){return typeof this._content=="number"?me.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Gt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new mt(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ae=function(r){return r[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r}(ae||(ae={})),qs=.001,De=class{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>qs&&(e.heightChanged=!0),this.height=t)}replace(e,t,n){return De.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,o){let i=this,s=n.doc;for(let l=o.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:u,toB:h}=o[l],f=i.lineAt(a,ae.ByPosNoHeight,n.setDoc(t),0,0),d=f.to>=c?f:i.lineAt(c,ae.ByPosNoHeight,n,0,0);for(h+=d.to-c,c=d.to;l>0&&f.from<=o[l-1].toA;)a=o[l-1].fromA,u=o[l-1].fromB,l--,a<f.from&&(f=i.lineAt(a,ae.ByPosNoHeight,n,0,0));u+=f.from-a,a=f.from;let p=li.build(n.setDoc(s),e,u,h);i=i.replace(a,c,p)}return i.updateHeight(n,0)}static empty(){return new Ke(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,o=0,i=0;for(;;)if(t==n)if(o>i*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),n+=1+l.break,o-=l.size}else if(i>o*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,i-=l.size}else break;else if(o<i){let l=e[t++];l&&(o+=l.size)}else{let l=e[--n];l&&(i+=l.size)}let s=0;return e[t-1]==null?(s=1,t--):e[t]==null&&(s=1,n++),new Yc(De.of(e.slice(0,t)),s,De.of(e.slice(n)))}};De.prototype.size=1;var ol=class extends De{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,o){return new mt(o,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,o,i){return this.blockAt(0,n,o,i)}forEachLine(e,t,n,o,i,s){e<=i+this.length&&t>=i&&s(this.blockAt(0,n,o,i))}updateHeight(e,t=0,n=!1,o){return o&&o.from<=t&&o.more&&this.setHeight(e,o.heights[o.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},Ke=class extends ol{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,o){return new mt(o,this.length,n,this.height,this.breaks)}replace(e,t,n){let o=n[0];return n.length==1&&(o instanceof Ke||o instanceof we&&o.flags&4)&&Math.abs(this.length-o.length)<10?(o instanceof we?o=new Ke(o.length,this.height):o.height=this.height,this.outdated||(o.outdated=!1),o):De.of(n)}updateHeight(e,t=0,n=!1,o){return o&&o.from<=t&&o.more?this.setHeight(e,o.heights[o.index++]):(n||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},we=class extends De{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,o=e.doc.lineAt(t+this.length).number,i=o-n+1,s,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*i);s=a/i,this.length>i+1&&(l=(this.height-a)/(this.length-i-1))}else s=this.height/i;return{firstLine:n,lastLine:o,perLine:s,perChar:l}}blockAt(e,t,n,o){let{firstLine:i,lastLine:s,perLine:l,perChar:a}=this.heightMetrics(t,o);if(t.lineWrapping){let c=o+Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length),u=t.doc.lineAt(c),h=l+u.length*a,f=Math.max(n,e-h/2);return new mt(u.from,u.length,f,h,0)}else{let c=Math.max(0,Math.min(s-i,Math.floor((e-n)/l))),{from:u,length:h}=t.doc.line(i+c);return new mt(u,h,n+l*c,l,0)}}lineAt(e,t,n,o,i){if(t==ae.ByHeight)return this.blockAt(e,n,o,i);if(t==ae.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new mt(d,p-d,0,0,0)}let{firstLine:s,perLine:l,perChar:a}=this.heightMetrics(n,i),c=n.doc.lineAt(e),u=l+c.length*a,h=c.number-s,f=o+l*h+a*(c.from-i-h);return new mt(c.from,c.length,Math.max(o,Math.min(f,o+this.height-u)),u,0)}forEachLine(e,t,n,o,i,s){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(n,i);for(let u=e,h=o;u<=t;){let f=n.doc.lineAt(u);if(u==e){let p=f.number-l;h+=a*p+c*(e-i-p)}let d=a+c*f.length;s(new mt(f.from,f.length,h,d,0)),h+=d,u=f.to+1}}replace(e,t,n){let o=this.length-t;if(o>0){let i=n[n.length-1];i instanceof we?n[n.length-1]=new we(i.length+o):n.push(null,new we(o-1))}if(e>0){let i=n[0];i instanceof we?n[0]=new we(e+i.length):n.unshift(new we(e-1),null)}return De.of(n)}decomposeLeft(e,t){t.push(new we(e-1),null)}decomposeRight(e,t){t.push(null,new we(this.length-e-1))}updateHeight(e,t=0,n=!1,o){let i=t+this.length;if(o&&o.from<=t+this.length&&o.more){let s=[],l=Math.max(t,o.from),a=-1;for(o.from>t&&s.push(new we(o.from-t-1).updateHeight(e,t));l<=i&&o.more;){let u=e.doc.lineAt(l).length;s.length&&s.push(null);let h=o.heights[o.index++];a==-1?a=h:Math.abs(h-a)>=qs&&(a=-2);let f=new Ke(u,h);f.outdated=!1,s.push(f),l+=u+1}l<=i&&s.push(null,new we(i-l).updateHeight(e,l));let c=De.of(s);return(a<0||Math.abs(c.height-this.height)>=qs||Math.abs(a-this.heightMetrics(e,t).perLine)>=qs)&&(e.heightChanged=!0),c}else(n||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Yc=class extends De{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,o){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,o):this.right.blockAt(e,t,i,o+this.left.length+this.break)}lineAt(e,t,n,o,i){let s=o+this.left.height,l=i+this.left.length+this.break,a=t==ae.ByHeight?e<s:e<l,c=a?this.left.lineAt(e,t,n,o,i):this.right.lineAt(e,t,n,s,l);if(this.break||(a?c.to<l:c.from>l))return c;let u=t==ae.ByPosNoHeight?ae.ByPosNoHeight:ae.ByPos;return a?c.join(this.right.lineAt(l,u,n,s,l)):this.left.lineAt(l,u,n,o,i).join(c)}forEachLine(e,t,n,o,i,s){let l=o+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,o,i,s),t>=a&&this.right.forEachLine(e,t,n,l,a,s);else{let c=this.lineAt(a,ae.ByPos,n,o,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,o,i,s),c.to>=e&&c.from<=t&&s(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,l,a,s)}}replace(e,t,n){let o=this.left.length+this.break;if(t<o)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-o,t-o,n));let i=[];e>0&&this.decomposeLeft(e,i);let s=i.length;for(let l of n)i.push(l);if(e>0&&Bm(i,s-1),t<this.length){let l=i.length;this.decomposeRight(t,i),Bm(i,l)}return De.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,o=n+this.break;if(e>=o)return this.right.decomposeRight(e-o,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<o&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?De.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,o){let{left:i,right:s}=this,l=t+i.length+this.break,a=null;return o&&o.from<=t+i.length&&o.more?a=i=i.updateHeight(e,t,n,o):i.updateHeight(e,t,n),o&&o.from<=l+s.length&&o.more?a=s=s.updateHeight(e,l,n,o):s.updateHeight(e,l,n),a?this.balanced(i,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Bm(r,e){let t,n;r[e]==null&&(t=r[e-1])instanceof we&&(n=r[e+1])instanceof we&&r.splice(e-1,3,new we(t.length+1+n.length))}var pk=5,li=class{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),o=this.nodes[this.nodes.length-1];o instanceof Ke?o.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Ke(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let o=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;o<0&&(o=this.oracle.lineHeight);let s=t-e;n.block?this.addBlock(new ol(s,o,n)):(s||i||o>=pk)&&this.addLineDeco(o,i,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Ke(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new we(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ke)return e;let t=new Ke(0,-1);return this.nodes.push(t),t}addBlock(e){var t;this.enterLine();let n=(t=e.deco)===null||t===void 0?void 0:t.type;n==me.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n!=me.WidgetBefore&&(this.covering=e)}addLineDeco(e,t,n){let o=this.ensureLine();o.length+=n,o.collapsed+=n,o.widgetHeight=Math.max(o.widgetHeight,e),o.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ke)&&!this.isCovered?this.nodes.push(new Ke(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let o of this.nodes)o instanceof Ke&&o.updateHeight(this.oracle,n),n+=o?o.length:1;return this.nodes}static build(e,t,n,o){let i=new li(n,e);return oe.spans(t,n,o,i,0),i.finish(n)}};function mk(r,e,t){let n=new Xc;return oe.compare(r,e,t,n,0),n.changes}var Xc=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,o){(e<t||n&&n.heightRelevant||o&&o.heightRelevant)&&Bc(e,t,this.changes,5)}};function gk(r,e){let t=r.getBoundingClientRect(),n=r.ownerDocument,o=n.defaultView||window,i=Math.max(0,t.left),s=Math.min(o.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(o.innerHeight,t.bottom);for(let c=r.parentNode;c&&c!=n.body;)if(c.nodeType==1){let u=c,h=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&h.overflow!="visible"){let f=u.getBoundingClientRect();i=Math.max(i,f.left),s=Math.min(s,f.right),l=Math.max(l,f.top),a=c==r.parentNode?f.bottom:Math.min(a,f.bottom)}c=h.position=="absolute"||h.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:i-t.left,right:Math.max(i,s)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function yk(r,e){let t=r.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var oi=class{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let o=e[n],i=t[n];if(o.from!=i.from||o.to!=i.to||o.size!=i.size)return!1}return!0}draw(e){return Se.replace({widget:new Zc(this.size,e)}).range(this.from,this.to)}},Zc=class extends ln{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},il=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!0,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Hm,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=pe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(pu).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Jc(t),this.stateDeco=e.facet(si).filter(n=>typeof n!="function"),this.heightMap=De.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle.setDoc(e.doc),[new Xe(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Se.set(this.lineGaps.map(n=>n.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let o=n?t.head:t.anchor;if(!e.some(({from:i,to:s})=>o>=i&&o<=s)){let{from:i,to:s}=this.lineBlockAt(o);e.push(new jr(i,s))}}this.viewports=e.sort((n,o)=>n.from-o.from),this.scaler=this.heightMap.height<=7e6?Hm:new eu(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:ni(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(si).filter(u=>typeof u!="function");let o=e.changedRanges,i=Xe.extendWithRanges(o,mk(n,this.stateDeco,e?e.changes:ue.empty(this.state.doc.length))),s=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),this.heightMap.height!=s&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let c=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),c&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(fg)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),o=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?pe.RTL:pe.LTR;let s=this.heightOracle.mustRefreshForWrapping(i),l=t.getBoundingClientRect(),a=s||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,u=0,h=parseInt(n.paddingTop)||0,f=parseInt(n.paddingBottom)||0;(this.paddingTop!=h||this.paddingBottom!=f)&&(this.paddingTop=h,this.paddingBottom=f,c|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=8),this.scrollTop!=e.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=e.scrollDOM.scrollTop),this.scrolledToBottom=Qm(e.scrollDOM);let d=(this.printing?yk:gk)(t,this.paddingTop),p=d.top-this.pixelViewport.top,m=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let y=l.width;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,c|=8),a){let w=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(w)&&(s=!0),s||o.lineWrapping&&Math.abs(y-this.contentDOMWidth)>o.charWidth){let{lineHeight:x,charWidth:S,textHeight:b}=e.docView.measureTextSize();s=x>0&&o.refresh(i,x,S,b,y/S,w),s&&(e.docView.minWidth=0,c|=8)}p>0&&m>0?u=Math.max(p,m):p<0&&m<0&&(u=Math.min(p,m)),o.heightChanged=!1;for(let x of this.viewports){let S=x.from==this.viewport.from?w:e.docView.measureVisibleLineHeights(x);this.heightMap=(s?De.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle,[new Xe(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,s,new Qc(x.from,S))}o.heightChanged&&(c|=2)}let v=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(c&2||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),o=this.heightMap,i=this.heightOracle,{visibleTop:s,visibleBottom:l}=this,a=new jr(o.lineAt(s-n*1e3,ae.ByHeight,i,0,0).from,o.lineAt(l+(1-n)*1e3,ae.ByHeight,i,0,0).to);if(t){let{head:c}=t.range;if(c<a.from||c>a.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=o.lineAt(c,ae.ByPos,i,0,0),f;t.y=="center"?f=(h.top+h.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c<a.from?f=h.top:f=h.bottom-u,a=new jr(o.lineAt(f-1e3/2,ae.ByHeight,i,0,0).from,o.lineAt(f+u+1e3/2,ae.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),o=t.mapPos(e.to,1);return new jr(this.heightMap.lineAt(n,ae.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(o,ae.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:o}=this.heightMap.lineAt(e,ae.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,ae.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:l}=this;return(e==0||o<=s-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=l+Math.max(10,Math.min(n,250)))&&o>s-2*1e3&&i<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let o of e)t.touchesRange(o.from,o.to)||n.push(new oi(t.mapPos(o.from),t.mapPos(o.to),o.size));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,o=n?1e4:2e3,i=o>>1,s=o<<1;if(this.defaultTextDirection!=pe.LTR&&!n)return[];let l=[],a=(c,u,h,f)=>{if(u-c<i)return;let d=this.state.selection.main,p=[d.from];d.empty||p.push(d.to);for(let g of p)if(g>c&&g<u){a(c,g-10,h,f),a(g+10,u,h,f);return}let m=xk(e,g=>g.from>=h.from&&g.to<=h.to&&Math.abs(g.from-c)<i&&Math.abs(g.to-u)<i&&!p.some(y=>g.from<y&&g.to>y));if(!m){if(u<h.to&&t&&n&&t.visibleRanges.some(g=>g.from<=u&&g.to>=u)){let g=t.moveToLineBoundary(I.cursor(u),!1,!0).head;g>c&&(u=g)}m=new oi(c,u,this.gapSize(h,c,u,f))}l.push(m)};for(let c of this.viewportLines){if(c.length<s)continue;let u=bk(c.from,c.to,this.stateDeco);if(u.total<s)continue;let h=this.scrollTarget?this.scrollTarget.range.head:null,f,d;if(n){let p=o/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,g;if(h!=null){let y=zs(u,h),v=((this.visibleBottom-this.visibleTop)/2+p)/c.height;m=y-v,g=y+v}else m=(this.visibleTop-c.top-p)/c.height,g=(this.visibleBottom-c.top+p)/c.height;f=_s(u,m),d=_s(u,g)}else{let p=u.total*this.heightOracle.charWidth,m=o*this.heightOracle.charWidth,g,y;if(h!=null){let v=zs(u,h),w=((this.pixelViewport.right-this.pixelViewport.left)/2+m)/p;g=v-w,y=v+w}else g=(this.pixelViewport.left-m)/p,y=(this.pixelViewport.right+m)/p;f=_s(u,g),d=_s(u,y)}f>c.from&&a(c.from,f,c,u),d<c.to&&a(d,c.to,c,u)}return l}gapSize(e,t,n,o){let i=zs(o,n)-zs(o,t);return this.heightOracle.lineWrapping?e.height*i:o.total*this.heightOracle.charWidth*i}updateLineGaps(e){oi.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Se.set(e.map(t=>t.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];oe.spans(e,this.viewport.from,this.viewport.to,{span(o,i){t.push({from:o,to:i})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((o,i)=>o.from!=t[i].from||o.to!=t[i].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ni(this.heightMap.lineAt(e,ae.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return ni(this.heightMap.lineAt(this.scaler.fromDOM(e),ae.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ni(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},jr=class{constructor(e,t){this.from=e,this.to=t}};function bk(r,e,t){let n=[],o=r,i=0;return oe.spans(t,r,e,{span(){},point(s,l){s>o&&(n.push({from:o,to:s}),i+=s-o),o=l}},20),o<e&&(n.push({from:o,to:e}),i+=e-o),{total:i,ranges:n}}function _s({total:r,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(r*t);for(let o=0;;o++){let{from:i,to:s}=e[o],l=s-i;if(n<=l)return i+n;n-=l}}function zs(r,e){let t=0;for(let{from:n,to:o}of r.ranges){if(e<=o){t+=e-n;break}t+=o-n}return t/r.total}function xk(r,e){for(let t of r)if(e(t))return t}var Hm={toDOM(r){return r},fromDOM(r){return r},scale:1},eu=class{constructor(e,t,n){let o=0,i=0,s=0;this.viewports=n.map(({from:l,to:a})=>{let c=t.lineAt(l,ae.ByPos,e,0,0).top,u=t.lineAt(a,ae.ByPos,e,0,0).bottom;return o+=u-c,{from:l,to:a,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(t.height-o);for(let l of this.viewports)l.domTop=s+(l.top-i)*this.scale,s=l.domBottom=l.domTop+(l.bottom-l.top),i=l.bottom}toDOM(e){for(let t=0,n=0,o=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return o+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,o=i.domBottom}}fromDOM(e){for(let t=0,n=0,o=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-o)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,o=i.domBottom}}};function ni(r,e){if(e.scale==1)return r;let t=e.toDOM(r.top),n=e.toDOM(r.bottom);return new mt(r.from,r.length,t,n-t,Array.isArray(r._content)?r._content.map(o=>ni(o,e)):r._content)}var Ws=$.define({combine:r=>r.join(" ")}),tu=$.define({combine:r=>r.indexOf(!0)>-1}),nu=pt.newName(),Dg=pt.newName(),Lg=pt.newName(),Ag={"&light":"."+Dg,"&dark":"."+Lg};function ru(r,e,t){return new pt(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,o=>{if(o=="&")return r;if(!t||!t[o])throw new RangeError(`Unsupported selector: ${o}`);return t[o]}):r+" "+n}})}var vk=ru("."+nu,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Ag),ou=class{constructor(e,t,n,o){this.typeOver=o,this.bounds=null,this.text="";let{impreciseHead:i,impreciseAnchor:s}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let l=i||s?[]:Sk(e),a=new Zs(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Ck(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=i&&i.node==l.focusNode&&i.offset==l.focusOffset||!Dc(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),c=s&&s.node==l.anchorNode&&s.offset==l.anchorOffset||!Dc(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=I.single(c,a)}}};function Og(r,e){let t,{newSel:n}=e,o=r.state.selection.main,i=r.inputState.lastKeyTime>Date.now()-100?r.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:l}=e.bounds,a=o.from,c=null;(i===8||H.android&&e.text.length<l-s)&&(a=o.to,c="end");let u=wk(r.state.doc.sliceString(s,l,Kr),e.text,a-s,c);u&&(H.chrome&&i==13&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==Kr+Kr&&u.toB--,t={from:s+u.from,to:s+u.toA,insert:Y.of(e.text.slice(u.from,u.toB).split(Kr))})}else n&&(!r.hasFocus&&r.state.facet(ll)||n.main.eq(o))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!o.empty&&n&&n.main.empty?t={from:o.from,to:o.to,insert:r.state.doc.slice(o.from,o.to)}:t&&t.from>=o.from&&t.to<=o.to&&(t.from!=o.from||t.to!=o.to)&&o.to-o.from-(t.to-t.from)<=4?t={from:o.from,to:o.to,insert:r.state.doc.slice(o.from,t.from).append(t.insert).append(r.state.doc.slice(t.to,o.to))}:(H.mac||H.android)&&t&&t.from==t.to&&t.from==o.head-1&&/^\. ?$/.test(t.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=I.single(n.main.anchor-1,n.main.head-1)),t={from:o.from,to:o.to,insert:Y.of([" "])}):H.chrome&&t&&t.from==t.to&&t.from==o.head&&t.insert.toString()==`
25
- `&&r.lineWrapping&&(n&&(n=I.single(n.main.anchor-1,n.main.head-1)),t={from:o.from,to:o.to,insert:Y.of([" "])}),t){let s=r.state;if(H.ios&&r.inputState.flushIOSKey(r)||H.android&&(t.from==o.from&&t.to==o.to&&t.insert.length==1&&t.insert.lines==2&&Jr(r.contentDOM,"Enter",13)||(t.from==o.from-1&&t.to==o.to&&t.insert.length==0||i==8&&t.insert.length<t.to-t.from)&&Jr(r.contentDOM,"Backspace",8)||t.from==o.from&&t.to==o.to+1&&t.insert.length==0&&Jr(r.contentDOM,"Delete",46)))return!0;let l=t.insert.toString();if(r.state.facet(cg).some(u=>u(r,t.from,t.to,l)))return!0;r.inputState.composing>=0&&r.inputState.composing++;let a;if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&r.inputState.composing<0){let u=o.from<t.from?s.sliceDoc(o.from,t.from):"",h=o.to>t.to?s.sliceDoc(t.to,o.to):"";a=s.replaceSelection(r.state.toText(u+t.insert.sliceString(0,void 0,r.state.lineBreak)+h))}else{let u=s.changes(t),h=n&&n.main.to<=u.newLength?n.main:void 0;if(s.selection.ranges.length>1&&r.inputState.composing>=0&&t.to<=o.to&&t.to>=o.to-10){let f=r.state.sliceDoc(t.from,t.to),d=xg(r)||r.state.doc.lineAt(o.head),p=o.to-t.to,m=o.to-o.from;a=s.changeByRange(g=>{if(g.from==o.from&&g.to==o.to)return{changes:u,range:h||g.map(u)};let y=g.to-p,v=y-f.length;if(g.to-g.from!=m||r.state.sliceDoc(v,y)!=f||d&&g.to>=d.from&&g.from<=d.to)return{range:g};let w=s.changes({from:v,to:y,insert:t.insert}),x=g.to-o.to;return{changes:w,range:h?I.range(Math.max(0,h.anchor+x),Math.max(0,h.head+x)):g.map(w)}})}else a={changes:u,selection:h&&s.selection.replaceRange(h)}}let c="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,c+=".compose",r.inputState.compositionFirstChange&&(c+=".start",r.inputState.compositionFirstChange=!1)),r.dispatch(a,{scrollIntoView:!0,userEvent:c}),!0}else if(n&&!n.main.eq(o)){let s=!1,l="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(s=!0),l=r.inputState.lastSelectionOrigin),r.dispatch({selection:n,scrollIntoView:s,userEvent:l}),!0}else return!1}function wk(r,e,t,n){let o=Math.min(r.length,e.length),i=0;for(;i<o&&r.charCodeAt(i)==e.charCodeAt(i);)i++;if(i==o&&r.length==e.length)return null;let s=r.length,l=e.length;for(;s>0&&l>0&&r.charCodeAt(s-1)==e.charCodeAt(l-1);)s--,l--;if(n=="end"){let a=Math.max(0,i-Math.min(s,l));t-=s+a-i}if(s<i&&r.length<e.length){let a=t<=i&&t>=s?i-t:0;i-=a,l=i+(l-s),s=i}else if(l<i){let a=t<=i&&t>=l?i-t:0;i-=a,s=i+(s-l),l=i}return{from:i,toA:s,toB:l}}function Sk(r){let e=[];if(r.root.activeElement!=r.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:o,focusOffset:i}=r.observer.selectionRange;return t&&(e.push(new el(t,n)),(o!=t||i!=n)&&e.push(new el(o,i))),e}function Ck(r,e){if(r.length==0)return null;let t=r[0].pos,n=r.length==2?r[1].pos:t;return t>-1&&n>-1?I.single(t+e,n+e):null}var Tk={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ic=H.ie&&H.ie_version<=11,iu=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Lc,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(H.ie&&H.ie_version<=11||H.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),Ic&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM),this.resizeContent=new ResizeObserver(()=>this.view.requestMeasure()),this.resizeContent.observe(e.contentDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runScrollHandlers(this.view,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,o=this.selectionRange;if(n.state.facet(ll)?n.root.activeElement!=this.dom:!Us(n.dom,o))return;let i=o.anchorNode&&n.docView.nearest(o.anchorNode);if(i&&i.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(H.ie&&H.ie_version<=11||H.android&&H.chrome)&&!n.state.selection.main.empty&&o.focusNode&&Qs(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=H.safari&&e.root.nodeType==11&&TT(this.dom.ownerDocument)==this.dom&&kk(this.view)||Js(e.root);if(!t||this.selectionRange.eq(t))return!1;let n=Us(this.dom,t);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&IT(this.dom,t)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(t),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Tk),Ic&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ic&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let o=()=>{let i=this.delayedAndroidKey;i&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=i.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&i.force&&Jr(this.dom,i.key,i.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(o)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,o=!1;for(let i of e){let s=this.readMutation(i);s&&(s.typeOver&&(o=!0),t==-1?{from:t,to:n}=s:(t=Math.min(s.from,t),n=Math.max(s.to,n)))}return{from:t,to:n,typeOver:o}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),o=this.selectionChanged&&Us(this.dom,this.selectionRange);return e<0&&!o?null:(e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new ou(this.view,e,t,n))}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return!1;let n=this.view.state,o=Og(this.view,t);return this.view.state==n&&this.view.update([]),o}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=_m(t,e.previousSibling||e.target.previousSibling,-1),o=_m(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:o?t.posBefore(o):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,n,o;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect(),(o=this.resizeContent)===null||o===void 0||o.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}};function _m(r,e,t){for(;e;){let n=ne.get(e);if(n&&n.parent==r)return n;let o=e.parentNode;e=o!=r.dom?o:t>0?e.nextSibling:e.previousSibling}return null}function kk(r){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(r.contentDOM.addEventListener("beforeinput",t,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let n=e.startContainer,o=e.startOffset,i=e.endContainer,s=e.endOffset,l=r.docView.domAtPos(r.state.selection.main.anchor);return Qs(l.node,l.offset,i,s)&&([n,o,i,s]=[i,s,n,o]),{anchorNode:n,anchorOffset:o,focusNode:i,focusOffset:s}}var j=class{constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: fixed; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=e.root||RT(e.parent)||document,this.viewState=new il(e.state||Z.create(e)),this.plugins=this.state.facet(ei).map(t=>new ri(t));for(let t of this.plugins)t.update(this);this.observer=new iu(this),this.inputState=new Gc(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new nl(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...e){let t=e.length==1&&e[0]instanceof he?e[0]:this.state.update(...e);this._dispatch(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,o,i=this.state;for(let f of e){if(f.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=f.state}if(this.destroyed){this.viewState.state=i;return}let s=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(Rg))?(this.inputState.notifiedFocused=s,l=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,a=Ig(i,s),a||(l=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(u=null)):this.observer.clear(),i.facet(Z.phrases)!=this.state.facet(Z.phrases))return this.setState(i);o=Yr.create(this,i,e),o.flags|=l;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(h&&(h=h.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection;h=new Qr(d.empty?d:I.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of f.effects)d.is(Cm)&&(h=d.value)}this.viewState.update(o,h),this.bidiCache=Xr.update(this.bidiCache,o.changes),o.empty||(this.updatePlugins(o),this.inputState.update(o)),t=this.docView.update(o),this.state.facet(ti)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(o.startState.facet(Ws)!=o.state.facet(Ws)&&(this.viewState.mustMeasureContent=!0),(t||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!o.empty)for(let f of this.state.facet(Hc))f(o);(a||u)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),u&&!Og(this,u)&&c.force&&Jr(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new il(e),this.plugins=e.facet(ei).map(n=>new ri(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView=new nl(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(ei),n=e.state.facet(ei);if(t!=n){let o=[];for(let i of n){let s=t.indexOf(i);if(s<0)o.push(new ri(i));else{let l=this.plugins[s];l.mustUpdate=e,o.push(l)}}for(let i of this.plugins)i.mustUpdate!=e&&i.destroy(this);this.plugins=o,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let o of this.plugins)o.mustUpdate=e;for(let o=0;o<this.plugins.length;o++)this.plugins[o].update(this)}measure(e=!0){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,{scrollTop:o}=n,{scrollAnchorPos:i,scrollAnchorHeight:s}=this.viewState;o!=this.viewState.scrollTop&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(s<0)if(Qm(n))i=-1,s=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(o);i=d.from,s=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(d=>{try{return d.read(this)}catch(p){return Ut(this.state,p),zm}}),h=Yr.create(this,this.state,[]),f=!1;h.flags|=a,t?t.flags|=a:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h));for(let d=0;d<c.length;d++)if(u[d]!=zm)try{let p=c[d];p.write&&p.write(u[d],this)}catch(p){Ut(this.state,p)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null;continue}else{let p=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-s;if(p>1||p<-1){o=n.scrollTop=o+p,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Hc))l(t)}get themeClasses(){return nu+" "+(this.state.facet(tu)?Lg:Dg)+" "+this.state.facet(Ws)}updateAttrs(){let e=Wm(this,dg,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ll)?"true":"false",class:"cm-content",style:`${H.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Wm(this,pu,t);let n=this.observer.ignore(()=>{let o=Fc(this.contentDOM,this.contentAttrs,t),i=Fc(this.dom,this.editorAttrs,e);return o||i});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let o of n.effects)if(o.is(j.announce)){t&&(this.announceDOM.textContent=""),t=!1;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=o.value}}mountStyles(){this.styleModules=this.state.facet(ti),pt.mount(this.root,this.styleModules.concat(vk).reverse())}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Rc(this,e,Rm(this,e,t,n))}moveByGroup(e,t){return Rc(this,e,Rm(this,e,t,n=>ek(this,e.head,n)))}moveToLineBoundary(e,t,n=!0){return ZT(this,e,t,n)}moveVertically(e,t,n){return Rc(this,e,tk(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),wg(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let o=this.state.doc.lineAt(e),i=this.bidiSpans(o),s=i[Tn.find(i,e-o.from,-1,t)];return hu(n,s.dir==pe.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(hg)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Mk)return yg(e.length);let t=this.textDirectionAt(e.from);for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t)return o.order;let n=zT(e.text,t);return this.bidiCache.push(new Xr(e.from,e.to,t,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||H.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{jm(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Cm.of(new Qr(typeof e=="number"?I.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return yt.define(()=>({}),{eventHandlers:e})}static theme(e,t){let n=pt.newName(),o=[Ws.of(n),ti.of(ru(`.${n}`,e))];return t&&t.dark&&o.push(tu.of(!0)),o}static baseTheme(e){return ir.lowest(ti.of(ru("."+nu,e,Ag)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),o=n&&ne.get(n)||ne.get(e);return((t=o==null?void 0:o.rootView)===null||t===void 0?void 0:t.view)||null}};j.styleModule=ti;j.inputHandler=cg;j.focusChangeEffect=ug;j.perLineTextDirection=hg;j.exceptionSink=ag;j.updateListener=Hc;j.editable=ll;j.mouseSelectionStyle=lg;j.dragMovesSelection=sg;j.clickAddsSelectionRange=ig;j.decorations=si;j.atomicRanges=mu;j.scrollMargins=pg;j.darkTheme=tu;j.contentAttributes=pu;j.editorAttributes=dg;j.lineWrapping=j.contentAttributes.of({class:"cm-lineWrapping"});j.announce=ie.define();var Mk=4096,zm={},Xr=class{constructor(e,t,n,o){this.from=e,this.to=t,this.dir=n,this.order=o}static update(e,t){if(t.empty)return e;let n=[],o=e.length?e[e.length-1].dir:pe.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let s=e[i];s.dir==o&&!t.touchesRange(s.from,s.to)&&n.push(new Xr(t.mapPos(s.from,1),t.mapPos(s.to,-1),s.dir,s.order))}return n}};function Wm(r,e,t){for(let n=r.state.facet(e),o=n.length-1;o>=0;o--){let i=n[o],s=typeof i=="function"?i(r):i;s&&Vc(s,t)}return t}var Ek=H.mac?"mac":H.windows?"win":H.linux?"linux":"key";function Rk(r,e){let t=r.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let o,i,s,l;for(let a=0;a<t.length-1;++a){let c=t[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))e=="mac"?l=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(n="Alt-"+n),i&&(n="Ctrl-"+n),l&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function $s(r,e,t){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t!==!1&&e.shiftKey&&(r="Shift-"+r),r}var Ik=ir.default(j.domEventHandlers({keydown(r,e){return Ak(Pk(e.state),r,e,"editor")}})),Zr=$.define({enables:Ik}),$m=new WeakMap;function Pk(r){let e=r.facet(Zr),t=$m.get(e);return t||$m.set(e,t=Lk(e.reduce((n,o)=>n.concat(o),[]))),t}var Cn=null,Dk=4e3;function Lk(r,e=Ek){let t=Object.create(null),n=Object.create(null),o=(s,l)=>{let a=n[s];if(a==null)n[s]=l;else if(a!=l)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},i=(s,l,a,c,u)=>{var h,f;let d=t[s]||(t[s]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>Rk(y,e));for(let y=1;y<p.length;y++){let v=p.slice(0,y).join(" ");o(v,!0),d[v]||(d[v]={preventDefault:!0,stopPropagation:!1,run:[w=>{let x=Cn={view:w,prefix:v,scope:s};return setTimeout(()=>{Cn==x&&(Cn=null)},Dk),!0}]})}let m=p.join(" ");o(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((f=(h=d._any)===null||h===void 0?void 0:h.run)===null||f===void 0?void 0:f.slice())||[]});a&&g.run.push(a),c&&(g.preventDefault=!0),u&&(g.stopPropagation=!0)};for(let s of r){let l=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let c of l){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let h in u)u[h].run.push(s.any)}let a=s[e]||s.key;if(a)for(let c of l)i(c,a,s.run,s.preventDefault,s.stopPropagation),s.shift&&i(c,"Shift-"+a,s.shift,s.preventDefault,s.stopPropagation)}return t}function Ak(r,e,t,n){let o=pm(e),i=zt(o,0),s=tr(i)==o.length&&o!=" ",l="",a=!1,c=!1,u=!1;Cn&&Cn.view==t&&Cn.scope==n&&(l=Cn.prefix+" ",Cg.indexOf(e.keyCode)<0&&(c=!0,Cn=null));let h=new Set,f=g=>{if(g){for(let y of g.run)if(!h.has(y)&&(h.add(y),y(t,e)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},d=r[n],p,m;return d&&(f(d[l+$s(o,e,!s)])?a=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(H.windows&&e.ctrlKey&&e.altKey)&&(p=rn[e.keyCode])&&p!=o?(f(d[l+$s(p,e,!0)])||e.shiftKey&&(m=Gr[e.keyCode])!=o&&m!=p&&f(d[l+$s(m,e,!1)]))&&(a=!0):s&&e.shiftKey&&f(d[l+$s(o,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),c&&(a=!0),a&&u&&e.stopPropagation(),a}var fr=class{constructor(e,t,n,o,i){this.className=e,this.left=t,this.top=n,this.width=o,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let o=e.coordsAtPos(n.head,n.assoc||1);if(!o)return[];let i=Ng(e);return[new fr(t,o.left-i.left,o.top-i.top,null,o.bottom-o.top)]}else return Ok(e,t,n)}};function Ng(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==pe.LTR?e.left:e.right-r.scrollDOM.clientWidth)-r.scrollDOM.scrollLeft,top:e.top-r.scrollDOM.scrollTop}}function Um(r,e,t){let n=I.cursor(e);return{from:Math.max(t.from,r.moveToLineBoundary(n,!1,!0).from),to:Math.min(t.to,r.moveToLineBoundary(n,!0,!0).from),type:me.Text}}function Ok(r,e,t){if(t.to<=r.viewport.from||t.from>=r.viewport.to)return[];let n=Math.max(t.from,r.viewport.from),o=Math.min(t.to,r.viewport.to),i=r.textDirection==pe.LTR,s=r.contentDOM,l=s.getBoundingClientRect(),a=Ng(r),c=s.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),h=l.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=l.right-(u?parseInt(u.paddingRight):0),d=Uc(r,n),p=Uc(r,o),m=d.type==me.Text?d:null,g=p.type==me.Text?p:null;if(m&&(r.lineWrapping||d.widgetLineBreaks)&&(m=Um(r,n,m)),g&&(r.lineWrapping||p.widgetLineBreaks)&&(g=Um(r,o,g)),m&&g&&m.from==g.from)return v(w(t.from,t.to,m));{let S=m?w(t.from,null,m):x(d,!1),b=g?w(null,t.to,g):x(p,!0),C=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&S.bottom+r.defaultLineHeight/2<b.top?C.push(y(h,S.bottom,f,b.top)):S.bottom<b.top&&r.elementAtHeight((S.bottom+b.top)/2).type==me.Text&&(S.bottom=b.top=(S.bottom+b.top)/2),v(S).concat(C).concat(v(b))}function y(S,b,C,k){return new fr(e,S-a.left,b-a.top-.01,C-S,k-b+.01)}function v({top:S,bottom:b,horizontal:C}){let k=[];for(let E=0;E<C.length;E+=2)k.push(y(C[E],S,C[E+1],b));return k}function w(S,b,C){let k=1e9,E=-1e9,R=[];function N(D,F,G,A,V){let B=r.coordsAtPos(D,D==C.to?-2:2),U=r.coordsAtPos(G,G==C.from?2:-2);!B||!U||(k=Math.min(B.top,U.top,k),E=Math.max(B.bottom,U.bottom,E),V==pe.LTR?R.push(i&&F?h:B.left,i&&A?f:U.right):R.push(!i&&A?h:U.left,!i&&F?f:B.right))}let O=S!=null?S:C.from,M=b!=null?b:C.to;for(let D of r.visibleRanges)if(D.to>O&&D.from<M)for(let F=Math.max(D.from,O),G=Math.min(D.to,M);;){let A=r.state.doc.lineAt(F);for(let V of r.bidiSpans(A)){let B=V.from+A.from,U=V.to+A.from;if(B>=G)break;U>F&&N(Math.max(B,F),S==null&&B<=O,Math.min(U,G),b==null&&U>=M,V.dir)}if(F=A.to+1,F>=G)break}return R.length==0&&N(O,S==null,M,b==null,r.textDirection),{top:k,bottom:E,horizontal:R}}function x(S,b){let C=l.top+(b?S.top:S.bottom);return{top:C,bottom:C,horizontal:[]}}}function Nk(r,e){return r.constructor==e.constructor&&r.eq(e)}var su=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(Ks)!=e.state.facet(Ks)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&e.view.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(Ks);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!Nk(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let o of e)o.update&&t&&o.constructor&&this.drawn[n].constructor&&o.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(o.draw(),t);for(;t;){let o=t.nextSibling;t.remove(),t=o}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},Ks=$.define();function Vg(r){return[yt.define(e=>new su(e,r)),Ks.of(r)]}var Fg=!H.ios,ai=$.define({combine(r){return sr(r,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function gu(r={}){return[ai.of(r),Vk,Fk,Bk,fg.of(!0)]}function Bg(r){return r.startState.facet(ai)!=r.state.facet(ai)}var Vk=Vg({above:!0,markers(r){let{state:e}=r,t=e.facet(ai),n=[];for(let o of e.selection.ranges){let i=o==e.selection.main;if(o.empty?!i||Fg:t.drawRangeCursor){let s=i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=o.empty?o:I.cursor(o.head,o.head>o.anchor?-1:1);for(let a of fr.forRange(r,s,l))n.push(a)}}return n},update(r,e){r.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Bg(r);return t&&Gm(r.state,e),r.docChanged||r.selectionSet||t},mount(r,e){Gm(e.state,r)},class:"cm-cursorLayer"});function Gm(r,e){e.style.animationDuration=r.facet(ai).cursorBlinkRate+"ms"}var Fk=Vg({above:!1,markers(r){return r.state.selection.ranges.map(e=>e.empty?[]:fr.forRange(r,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(r,e){return r.docChanged||r.selectionSet||r.viewportChanged||Bg(r)},class:"cm-selectionLayer"}),Hg={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Fg&&(Hg[".cm-line"].caretColor="transparent !important");var Bk=ir.highest(j.theme(Hg));function qm(r,e,t,n,o){e.lastIndex=0;for(let i=r.iterRange(t,n),s=t,l;!i.next().done;s+=i.value.length)if(!i.lineBreak)for(;l=e.exec(i.value);)o(s+l.index,l)}function Hk(r,e){let t=r.visibleRanges;if(t.length==1&&t[0].from==r.viewport.from&&t[0].to==r.viewport.to)return t;let n=[];for(let{from:o,to:i}of t)o=Math.max(r.state.doc.lineAt(o).from,o-e),i=Math.min(r.state.doc.lineAt(i).to,i+e),n.length&&n[n.length-1].to>=o?n[n.length-1].to=i:n.push({from:o,to:i});return n}var lu=class{constructor(e){let{regexp:t,decoration:n,decorate:o,boundary:i,maxLength:s=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,o)this.addMatch=(l,a,c,u)=>o(u,c,c+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,c,u)=>{let h=n(l,a,c);h&&u(c,c+l[0].length,h)};else if(n)this.addMatch=(l,a,c,u)=>u(c,c+l[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=i,this.maxLength=s}createDeco(e){let t=new Wt,n=t.add.bind(t);for(let{from:o,to:i}of Hk(e,this.maxLength))qm(e.state.doc,this.regexp,o,i,(s,l)=>this.addMatch(l,e,s,n));return t.finish()}updateDeco(e,t){let n=1e9,o=-1;return e.docChanged&&e.changes.iterChanges((i,s,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(n=Math.min(l,n),o=Math.max(a,o))}),e.viewportChanged||o-n>1e3?this.createDeco(e.view):o>-1?this.updateRange(e.view,t.map(e.changes),n,o):t}updateRange(e,t,n,o){for(let i of e.visibleRanges){let s=Math.max(i.from,n),l=Math.min(i.to,o);if(l>s){let a=e.state.doc.lineAt(s),c=a.to<l?e.state.doc.lineAt(l):a,u=Math.max(i.from,a.from),h=Math.min(i.to,c.to);if(this.boundary){for(;s>a.from;s--)if(this.boundary.test(a.text[s-1-a.from])){u=s;break}for(;l<c.to;l++)if(this.boundary.test(c.text[l-c.from])){h=l;break}}let f=[],d,p=(m,g,y)=>f.push(y.range(m,g));if(a==c)for(this.regexp.lastIndex=u-a.from;(d=this.regexp.exec(a.text))&&d.index<h-a.from;)this.addMatch(d,e,d.index+a.from,p);else qm(e.state.doc,this.regexp,u,h,(m,g)=>this.addMatch(g,e,m,p));t=t.update({filterFrom:u,filterTo:h,filter:(m,g)=>m<u||g>h,add:f})}}return t}},au=/x/.unicode!=null?"gu":"g",_k=new RegExp(`[\0-\b
26
- -\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,au),zk={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},Pc=null;function Wk(){var r;if(Pc==null&&typeof document<"u"&&document.body){let e=document.body.style;Pc=((r=e.tabSize)!==null&&r!==void 0?r:e.MozTabSize)!=null}return Pc||!1}var js=$.define({combine(r){let e=sr(r,{render:null,specialChars:_k,addSpecialChars:null});return(e.replaceTabs=!Wk())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,au)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,au)),e}});function yu(r={}){return[js.of(r),$k()]}var Km=null;function $k(){return Km||(Km=yt.fromClass(class{constructor(r){this.view=r,this.decorations=Se.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(r.state.facet(js)),this.decorations=this.decorator.createDeco(r)}makeDecorator(r){return new lu({regexp:r.specialChars,decoration:(e,t,n)=>{let{doc:o}=t.state,i=zt(e[0],0);if(i==9){let s=o.lineAt(n),l=t.state.tabSize,a=lr(s.text,l,n-s.from);return Se.replace({widget:new uu((l-a%l)*this.view.defaultCharacterWidth)})}return this.decorationCache[i]||(this.decorationCache[i]=Se.replace({widget:new cu(r,i)}))},boundary:r.replaceTabs?void 0:/[^]/})}update(r){let e=r.state.facet(js);r.startState.facet(js)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(r.view)):this.decorations=this.decorator.updateDeco(r,this.decorations)}},{decorations:r=>r.decorations}))}var Uk="\u2022";function Gk(r){return r>=32?Uk:r==10?"\u2424":String.fromCharCode(9216+r)}var cu=class extends ln{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Gk(this.code),n=e.state.phrase("Control character")+" "+(zk[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,n,t);if(o)return o;let i=document.createElement("span");return i.textContent=t,i.title=n,i.setAttribute("aria-label",n),i.className="cm-specialChar",i}ignoreEvent(){return!1}},uu=class extends ln{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};var aW=j.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});var an=class extends Dt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};an.prototype.elementClass="";an.prototype.toDOM=void 0;an.prototype.mapMode=Ne.TrackBefore;an.prototype.startSide=an.prototype.endSide=-1;an.prototype.point=!0;var qk=0,bt=class{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=qk++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new bt([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new eo;return t=>t.modified.indexOf(e)>-1?t:eo.get(t.base||t,t.modified.concat(e).sort((n,o)=>n.id-o.id))}},Kk=0,eo=class{constructor(){this.instances=[],this.id=Kk++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&jk(t,l.modified));if(n)return n;let o=[],i=new bt(o,e,t);for(let l of t)l.instances.push(i);let s=Jk(t);for(let l of e.set)if(!l.modified.length)for(let a of s)o.push(eo.get(l,a));return i}};function jk(r,e){return r.length==e.length&&r.every((t,n)=>t==e[n])}function Jk(r){let e=[[]];for(let t=0;t<r.length;t++)for(let n=0,o=e.length;n<o;n++)e.push(e[n].concat(r[t]));return e.sort((t,n)=>n.length-t.length)}function ui(r){let e=Object.create(null);for(let t in r){let n=r[t];Array.isArray(n)||(n=[n]);for(let o of t.split(" "))if(o){let i=[],s=2,l=o;for(let h=0;;){if(l=="..."&&h>0&&h+3==o.length){s=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+o);if(i.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),h+=f[0].length,h==o.length)break;let d=o[h++];if(h==o.length&&d=="!"){s=0;break}if(d!="/")throw new RangeError("Invalid path: "+o);l=o.slice(h)}let a=i.length-1,c=i[a];if(!c)throw new RangeError("Invalid path: "+o);let u=new to(n,s,a>0?i.slice(0,a):null);e[c]=u.sort(e[c])}}return Wg.add(e)}var Wg=new J,to=class{constructor(e,t,n,o){this.tags=e,this.mode=t,this.context=n,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};to.empty=new to([],2,null);function wu(r,e){let t=Object.create(null);for(let i of r)if(!Array.isArray(i.tag))t[i.tag.id]=i.class;else for(let s of i.tag)t[s.id]=i.class;let{scope:n,all:o=null}=e||{};return{style:i=>{let s=o;for(let l of i)for(let a of l.set){let c=t[a.id];if(c){s=s?s+" "+c:c;break}}return s},scope:n}}function Qk(r,e){let t=null;for(let n of r){let o=n.style(e);o&&(t=t?t+" "+o:o)}return t}function $g(r,e,t,n=0,o=r.length){let i=new xu(n,Array.isArray(e)?e:[e],t);i.highlightRange(r.cursor(),n,o,"",i.highlighters),i.flush(o)}var xu=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,o,i){let{type:s,from:l,to:a}=e;if(l>=n||a<=t)return;s.isTop&&(i=this.highlighters.filter(d=>!d.scope||d.scope(s)));let c=o,u=Yk(e)||to.empty,h=Qk(i,u.tags);if(h&&(c&&(c+=" "),c+=h,u.mode==1&&(o+=(o?" ":"")+h)),this.startSpan(Math.max(t,l),c),u.opaque)return;let f=e.tree&&e.tree.prop(J.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(f.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let v=g<f.overlay.length?f.overlay[g]:null,w=v?v.from+l:a,x=Math.max(t,y),S=Math.min(n,w);if(x<S&&m)for(;e.from<S&&(this.highlightRange(e,x,S,o,i),this.startSpan(Math.min(S,e.to),c),!(e.to>=w||!e.nextSibling())););if(!v||w>n)break;y=v.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,v.from+l),Math.min(n,y),"",p),this.startSpan(Math.min(n,y),c))}m&&e.parent()}else if(e.firstChild()){f&&(o="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,o,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function Yk(r){let e=r.type.prop(Wg);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}var L=bt.define,al=L(),En=L(),_g=L(En),zg=L(En),Rn=L(),cl=L(Rn),bu=L(Rn),jt=L(),dr=L(jt),qt=L(),Kt=L(),vu=L(),ci=L(vu),ul=L(),P={comment:al,lineComment:L(al),blockComment:L(al),docComment:L(al),name:En,variableName:L(En),typeName:_g,tagName:L(_g),propertyName:zg,attributeName:L(zg),className:L(En),labelName:L(En),namespace:L(En),macroName:L(En),literal:Rn,string:cl,docString:L(cl),character:L(cl),attributeValue:L(cl),number:bu,integer:L(bu),float:L(bu),bool:L(Rn),regexp:L(Rn),escape:L(Rn),color:L(Rn),url:L(Rn),keyword:qt,self:L(qt),null:L(qt),atom:L(qt),unit:L(qt),modifier:L(qt),operatorKeyword:L(qt),controlKeyword:L(qt),definitionKeyword:L(qt),moduleKeyword:L(qt),operator:Kt,derefOperator:L(Kt),arithmeticOperator:L(Kt),logicOperator:L(Kt),bitwiseOperator:L(Kt),compareOperator:L(Kt),updateOperator:L(Kt),definitionOperator:L(Kt),typeOperator:L(Kt),controlOperator:L(Kt),punctuation:vu,separator:L(vu),bracket:ci,angleBracket:L(ci),squareBracket:L(ci),paren:L(ci),brace:L(ci),content:jt,heading:dr,heading1:L(dr),heading2:L(dr),heading3:L(dr),heading4:L(dr),heading5:L(dr),heading6:L(dr),contentSeparator:L(jt),list:L(jt),quote:L(jt),emphasis:L(jt),strong:L(jt),link:L(jt),monospace:L(jt),strikethrough:L(jt),inserted:L(),deleted:L(),changed:L(),invalid:L(),meta:ul,documentMeta:L(ul),annotation:L(ul),processingInstruction:L(ul),definition:bt.defineModifier(),constant:bt.defineModifier(),function:bt.defineModifier(),standard:bt.defineModifier(),local:bt.defineModifier(),special:bt.defineModifier()},fW=wu([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var Su,no=new J;function Xk(r){return $.define({combine:r?e=>e.concat(r):void 0})}var Zk=new J,rt=class{constructor(e,t,n=[],o=""){this.data=e,this.name=o,Z.prototype.hasOwnProperty("tree")||Object.defineProperty(Z.prototype,"tree",{get(){return Fe(this)}}),this.parser=t,this.extension=[oo.of(this),Z.languageData.of((i,s,l)=>{let a=Ug(i,s,l),c=a.type.prop(no);if(!c)return[];let u=i.facet(c),h=a.type.prop(Zk);if(h){let f=a.resolve(s-a.from,l);for(let d of h)if(d.test(f,i)){let p=i.facet(d.facet);return d.type=="replace"?p:p.concat(u)}}return u})].concat(n)}isActiveAt(e,t,n=-1){return Ug(e,t,n).type.prop(no)==this.data}findRegions(e){let t=e.facet(oo);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],o=(i,s)=>{if(i.prop(no)==this.data){n.push({from:s,to:s+i.length});return}let l=i.prop(J.mounted);if(l){if(l.tree.prop(no)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+s,to:a.to+s});else n.push({from:s,to:s+i.length});return}else if(l.overlay){let a=n.length;if(o(l.tree,l.overlay[0].from+s),n.length>a)return}}for(let a=0;a<i.children.length;a++){let c=i.children[a];c instanceof le&&o(c,i.positions[a]+s)}};return o(Fe(e),0),n}get allowsNesting(){return!0}};rt.setState=ie.define();function Ug(r,e,t){let n=r.facet(oo),o=Fe(r).topNode;if(!n||n.allowsNesting)for(let i=o;i;i=i.enter(e,t,ye.ExcludeBuffers))i.type.isTop&&(o=i);return o}var In=class extends rt{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=Xk(e.languageData);return new In(t,e.parser.configure({props:[no.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new In(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Fe(r){let e=r.field(rt.state,!1);return e?e.tree:le.empty}var Mu=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},hi=null,ro=class{constructor(e,t,n=[],o,i,s,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=o,this.treeLen=i,this.viewport=s,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new ro(e,t,[],le.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Mu(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=le.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let o=Date.now()+e;e=()=>Date.now()>o}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let o=this.parse.advance();if(o)if(this.fragments=this.withoutTempSkipped(Ht.addTree(o,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=o,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Ht.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=hi;hi=this;try{return e()}finally{hi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Gg(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:o,treeLen:i,viewport:s,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,u,h,f)=>a.push({fromA:c,toA:u,fromB:h,toB:f})),n=Ht.applyChanges(n,a),o=le.empty,i=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),h=e.mapPos(c.to,-1);u<h&&l.push({from:u,to:h})}}}return new ro(this.parser,t,n,o,i,s,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:o,to:i}=this.skipped[n];o<e.to&&i>e.from&&(this.fragments=Gg(this.fragments,o,i),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Dr{createParse(t,n,o){let i=o[0].from,s=o[o.length-1].to;return{parsedPos:i,advance(){let a=hi;if(a){for(let c of o)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=s,new le(ke.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return hi}};function Gg(r,e,t){return Ht.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}var Pn=class{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Pn(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=ro.create(e.facet(oo).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Pn(n)}};rt.state=qe.define({create:Pn.init,update(r,e){for(let t of e.effects)if(t.is(rt.setState))return t.value;return e.startState.facet(oo)!=e.state.facet(oo)?Pn.init(e.state):r.apply(e)}});var jg=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(jg=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:500-100})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Cu=typeof navigator<"u"&&(!((Su=navigator.scheduling)===null||Su===void 0)&&Su.isInputPending)?()=>navigator.scheduling.isInputPending():null,e1=yt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(rt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(rt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=jg(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:o}}=this.view,i=n.field(rt.state);if(i.tree==i.context.tree&&i.context.isDone(o+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!Cu?Math.max(25,e.timeRemaining()-5):1e9),l=i.context.treeLen<o&&n.doc.length>o+1e3,a=i.context.work(()=>Cu&&Cu()||Date.now()>s,o+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:rt.setState.of(new Pn(i.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ut(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),oo=$.define({combine(r){return r.length?r[0]:null},enables:r=>[rt.state,e1,j.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]});var t1=$.define(),di=$.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function pi(r){let e=r.facet(di);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function mi(r,e){let t="",n=r.tabSize,o=r.facet(di)[0];if(o==" "){for(;e>=n;)t+=" ",e-=n;o=" "}for(let i=0;i<e;i++)t+=o;return t}function Du(r,e){r instanceof Z&&(r=new pr(r));for(let n of r.state.facet(t1)){let o=n(r,e);if(o!==void 0)return o}let t=Fe(r.state);return t?r1(r,t,e):null}var pr=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=pi(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:o,simulateDoubleBreak:i}=this.options;return o!=null&&o>=n.from&&o<=n.to?i&&o==e?{text:"",from:e}:(t<0?o<e:o<=e)?{text:n.text.slice(o-n.from),from:o}:{text:n.text.slice(0,o-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:o}=this.lineAt(e,t);return n.slice(e-o,Math.min(n.length,e+100-o))}column(e,t=1){let{text:n,from:o}=this.lineAt(e,t),i=this.countColumn(n,e-o),s=this.options.overrideIndentation?this.options.overrideIndentation(o):-1;return s>-1&&(i+=s-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return lr(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:o}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let s=i(o);if(s>-1)return s}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},n1=new J;function r1(r,e,t){return Jg(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,r)}function o1(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function i1(r){let e=r.type.prop(n1);if(e)return e;let t=r.firstChild,n;if(t&&(n=t.type.prop(J.closedBy))){let o=r.lastChild,i=o&&n.indexOf(o.name)>-1;return s=>c1(s,!0,1,void 0,i&&!o1(s)?o.from:void 0)}return r.parent==null?s1:null}function Jg(r,e,t){for(;r;r=r.parent){let n=i1(r);if(n)return n(fi.create(t,e,r))}return null}function s1(){return 0}var fi=class extends pr{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.node=n}static create(e,t,n){return new fi(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(l1(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){let e=this.node.parent;return e?Jg(e,this.pos,this.base):0}};function l1(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function a1(r){let e=r.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let o=r.options.simulateBreak,i=r.state.doc.lineAt(t.from),s=o==null||o<=i.from?i.to:Math.min(i.to,o);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped)return a.from<s?t:null;l=a.to}}function c1(r,e,t,n,o){let i=r.textAfter,s=i.match(/^\s*/)[0].length,l=n&&i.slice(s,s+n.length)==n||o==r.pos+s,a=e?a1(r):null;return a?l?r.column(a.from):r.column(a.to):r.baseIndent+(l?0:r.unit*t)}var cn=class{constructor(e,t){this.specs=e;let n;function o(l){let a=pt.newName();return(n||(n=Object.create(null)))["."+a]=l,a}let i=typeof t.all=="string"?t.all:t.all?o(t.all):void 0,s=t.scope;this.scope=s instanceof rt?l=>l.prop(no)==s.data:s?l=>l==s:void 0,this.style=wu(e.map(l=>({tag:l.tag,class:l.class||o(Object.assign({},l,{tag:null}))})),{all:i}).style,this.module=n?new pt(n):null,this.themeType=t.themeType}static define(e,t){return new cn(e,t||{})}},Eu=$.define(),Qg=$.define({combine(r){return r.length?[r[0]]:null}});function Tu(r){let e=r.facet(Eu);return e.length?e:r.facet(Qg)}function gi(r,e){let t=[u1],n;return r instanceof cn&&(r.module&&t.push(j.styleModule.of(r.module)),n=r.themeType),e!=null&&e.fallback?t.push(Qg.of(r)):n?t.push(Eu.computeN([j.darkTheme],o=>o.facet(j.darkTheme)==(n=="dark")?[r]:[])):t.push(Eu.of(r)),t}var Ru=class{constructor(e){this.markCache=Object.create(null),this.tree=Fe(e.state),this.decorations=this.buildDeco(e,Tu(e.state))}update(e){let t=Fe(e.state),n=Tu(e.state),o=n!=Tu(e.startState);t.length<e.view.viewport.to&&!o&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||o)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n))}buildDeco(e,t){if(!t||!this.tree.length)return Se.none;let n=new Wt;for(let{from:o,to:i}of e.visibleRanges)$g(this.tree,t,(s,l,a)=>{n.add(s,l,this.markCache[a]||(this.markCache[a]=Se.mark({class:a})))},o,i);return n.finish()}},u1=ir.high(yt.fromClass(Ru,{decorations:r=>r.decorations})),Lu=cn.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]);var h1=1e4,f1="()[]{}";var d1=new J;function Iu(r,e,t){let n=r.prop(e<0?J.openedBy:J.closedBy);if(n)return n;if(r.name.length==1){let o=t.indexOf(r.name);if(o>-1&&o%2==(e<0?1:0))return[t[o+e]]}return null}function Pu(r){let e=r.type.prop(d1);return e?e(r.node):r}function mr(r,e,t,n={}){let o=n.maxScanDistance||h1,i=n.brackets||f1,s=Fe(r),l=s.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=Iu(a.type,t,i);if(c&&a.from<a.to){let u=Pu(a);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return p1(r,e,t,a,u,c,i)}}return m1(r,e,t,s,l.type,o,i)}function p1(r,e,t,n,o,i,s){let l=n.parent,a={from:o.from,to:o.to},c=0,u=l==null?void 0:l.cursor();if(u&&(t<0?u.childBefore(n.from):u.childAfter(n.to)))do if(t<0?u.to<=n.from:u.from>=n.to){if(c==0&&i.indexOf(u.type.name)>-1&&u.from<u.to){let h=Pu(u);return{start:a,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Iu(u.type,t,s))c++;else if(Iu(u.type,-t,s)){if(c==0){let h=Pu(u);return{start:a,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:a,matched:!1}}function m1(r,e,t,n,o,i,s){let l=t<0?r.sliceDoc(e-1,e):r.sliceDoc(e,e+1),a=s.indexOf(l);if(a<0||a%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=r.doc.iterRange(e,t>0?r.doc.length:0),h=0;for(let f=0;!u.next().done&&f<=i;){let d=u.value;t<0&&(f+=d.length);let p=e+f*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let y=s.indexOf(d[m]);if(!(y<0||n.resolveInner(p+m,1).type!=o))if(y%2==0==t>0)h++;else{if(h==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};h--}}t>0&&(f+=d.length)}return u.done?{start:c,matched:!1}:null}var g1=Object.create(null),qg=[ke.none];var Kg=[],y1=Object.create(null);for(let[r,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])y1[r]=b1(g1,e);function ku(r,e){Kg.indexOf(r)>-1||(Kg.push(r),console.warn(e))}function b1(r,e){let t=null;for(let i of e.split(".")){let s=r[i]||P[i];s?typeof s=="function"?t?t=s(t):ku(i,`Modifier ${i} used at start of tag`):t?ku(i,`Tag ${i} used as modifier`):t=s:ku(i,`Unknown highlighting tag ${i}`)}if(!t)return 0;let n=e.replace(/ /g,"_"),o=ke.define({id:qg.length,name:n,props:[ui({[n]:t})]});return qg.push(o),o.id}var hl={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},gr=ie.define({map(r,e){let t=e.mapPos(r,-1,Ne.TrackAfter);return t==null?void 0:t}}),Ou=new class extends Dt{};Ou.startSide=1;Ou.endSide=-1;var Zg=qe.define({create(){return oe.empty},update(r,e){if(e.selection){let t=e.state.doc.lineAt(e.selection.main.head).from,n=e.startState.doc.lineAt(e.startState.selection.main.head).from;t!=e.changes.mapPos(n,-1)&&(r=oe.empty)}r=r.map(e.changes);for(let t of e.effects)t.is(gr)&&(r=r.update({add:[Ou.range(t.value,t.value+1)]}));return r}});function Nu(){return[S1,Zg]}var Au="()[]{}<>";function x1(r){for(let e=0;e<Au.length;e+=2)if(Au.charCodeAt(e)==r)return Au.charAt(e+1);return Xp(r<128?r:r+1)}function v1(r,e){return r.languageDataAt("closeBrackets",e)[0]||hl}var w1=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),S1=j.inputHandler.of((r,e,t,n)=>{if((w1?r.composing:r.compositionStarted)||r.state.readOnly)return!1;let o=r.state.selection.main;if(n.length>2||n.length==2&&tr(zt(n,0))==1||e!=o.from||t!=o.to)return!1;let i=C1(r.state,n);return i?(r.dispatch(i),!0):!1});function C1(r,e){let t=v1(r,r.selection.main.head),n=t.brackets||hl.brackets;for(let o of n){let i=x1(zt(o,0));if(e==o)return i==o?M1(r,o,n.indexOf(o+o+o)>-1,t):T1(r,o,i,t.before||hl.before);if(e==i&&ey(r,r.selection.main.from))return k1(r,o,i)}return null}function ey(r,e){let t=!1;return r.field(Zg).between(0,r.doc.length,n=>{n==e&&(t=!0)}),t}function Vu(r,e){let t=r.sliceString(e,e+2);return t.slice(0,tr(zt(t,0)))}function T1(r,e,t,n){let o=null,i=r.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:t,from:s.to}],effects:gr.of(s.to+e.length),range:I.range(s.anchor+e.length,s.head+e.length)};let l=Vu(r.doc,s.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:s.head},effects:gr.of(s.head+e.length),range:I.cursor(s.head+e.length)}:{range:o=s}});return o?null:r.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function k1(r,e,t){let n=null,o=r.changeByRange(i=>i.empty&&Vu(r.doc,i.head)==t?{changes:{from:i.head,to:i.head+t.length,insert:t},range:I.cursor(i.head+t.length)}:n={range:i});return n?null:r.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function M1(r,e,t,n){let o=n.stringPrefixes||hl.stringPrefixes,i=null,s=r.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:gr.of(l.to+e.length),range:I.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=Vu(r.doc,a),u;if(c==e){if(Yg(r,a))return{changes:{insert:e+e,from:a},effects:gr.of(a+e.length),range:I.cursor(a+e.length)};if(ey(r,a)){let f=t&&r.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+f.length,insert:f},range:I.cursor(a+f.length)}}}else{if(t&&r.sliceDoc(a-2*e.length,a)==e+e&&(u=Xg(r,a-2*e.length,o))>-1&&Yg(r,u))return{changes:{insert:e+e+e+e,from:a},effects:gr.of(a+e.length),range:I.cursor(a+e.length)};if(r.charCategorizer(a)(c)!=Ge.Word&&Xg(r,a,o)>-1&&!E1(r,a,e,o))return{changes:{insert:e+e,from:a},effects:gr.of(a+e.length),range:I.cursor(a+e.length)}}return{range:i=l}});return i?null:r.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Yg(r,e){let t=Fe(r).resolveInner(e+1);return t.parent&&t.from==e}function E1(r,e,t,n){let o=Fe(r).resolveInner(e,-1),i=n.reduce((s,l)=>Math.max(s,l.length),0);for(let s=0;s<5;s++){let l=r.sliceDoc(o.from,Math.min(o.to,o.from+t.length+i)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let u=o.firstChild;for(;u&&u.from==o.from&&u.to-u.from>t.length+a;){if(r.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}function Xg(r,e,t){let n=r.charCategorizer(e);if(n(r.sliceDoc(e-1,e))!=Ge.Word)return e;for(let o of t){let i=e-o.length;if(r.sliceDoc(i,e)==o&&n(r.sliceDoc(i-1,i))!=Ge.Word)return i}return-1}var R1=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),n=$u(r.state,t.from);return n.line?I1(r):n.block?D1(r):!1};function Wu(r,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let o=r(e,t);return o?(n(t.update(o)),!0):!1}}var I1=Wu(O1,0);var P1=Wu(ay,0);var D1=Wu((r,e)=>ay(r,e,A1(e)),0);function $u(r,e){let t=r.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var yi=50;function L1(r,{open:e,close:t},n,o){let i=r.sliceDoc(n-yi,n),s=r.sliceDoc(o,o+yi),l=/\s*$/.exec(i)[0].length,a=/^\s*/.exec(s)[0].length,c=i.length-l;if(i.slice(c-e.length,c)==e&&s.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:o+a,margin:a&&1}};let u,h;o-n<=2*yi?u=h=r.sliceDoc(n,o):(u=r.sliceDoc(n,n+yi),h=r.sliceDoc(o-yi,o));let f=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(h)[0].length,p=h.length-d-t.length;return u.slice(f,f+e.length)==e&&h.slice(p,p+t.length)==t?{open:{pos:n+f+e.length,margin:/\s/.test(u.charAt(f+e.length))?1:0},close:{pos:o-d-t.length,margin:/\s/.test(h.charAt(p-1))?1:0}}:null}function A1(r){let e=[];for(let t of r.selection.ranges){let n=r.doc.lineAt(t.from),o=t.to<=n.to?n:r.doc.lineAt(t.to),i=e.length-1;i>=0&&e[i].to>n.from?e[i].to=o.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:o.to})}return e}function ay(r,e,t=e.selection.ranges){let n=t.map(i=>$u(e,i.from).block);if(!n.every(i=>i))return null;let o=t.map((i,s)=>L1(e,n[s],i.from,i.to));if(r!=2&&!o.every(i=>i))return{changes:e.changes(t.map((i,s)=>o[s]?[]:[{from:i.from,insert:n[s].open+" "},{from:i.to,insert:" "+n[s].close}]))};if(r!=1&&o.some(i=>i)){let i=[];for(let s=0,l;s<o.length;s++)if(l=o[s]){let a=n[s],{open:c,close:u}=l;i.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+a.close.length})}return{changes:i}}return null}function O1(r,e,t=e.selection.ranges){let n=[],o=-1;for(let{from:i,to:s}of t){let l=n.length,a=1e9,c=$u(e,i).line;if(c){for(let u=i;u<=s;){let h=e.doc.lineAt(u);if(h.from>o&&(i==s||s>h.from)){o=h.from;let f=/^\s*/.exec(h.text)[0].length,d=f==h.length,p=h.text.slice(f,f+c.length)==c?f:-1;f<h.text.length&&f<a&&(a=f),n.push({line:h,comment:p,token:c,indent:f,empty:d,single:!1})}u=h.to+1}if(a<1e9)for(let u=l;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=a);n.length==l+1&&(n[l].single=!0)}}if(r!=2&&n.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:l,token:a,indent:c,empty:u,single:h}of n)(h||!u)&&i.push({from:l.from+c,insert:a+" "});let s=e.changes(i);return{changes:s,selection:e.selection.map(s,1)}}else if(r!=1&&n.some(i=>i.comment>=0)){let i=[];for(let{line:s,comment:l,token:a}of n)if(l>=0){let c=s.from+l,u=c+a.length;s.text[u-s.from]==" "&&u++,i.push({from:c,to:u})}return{changes:i}}return null}var Bu=tt.define(),N1=tt.define(),V1=$.define(),cy=$.define({combine(r){return sr(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,o)=>e(n,o)||t(n,o)})}});function F1(r){let e=0;return r.iterChangedRanges((t,n)=>e=n),e}var uy=qe.define({create(){return vt.empty},update(r,e){let t=e.state.facet(cy),n=e.annotation(Bu);if(n){let a=e.docChanged?I.single(F1(e.changes)):void 0,c=Be.fromTransaction(e,a),u=n.side,h=u==0?r.undone:r.done;return c?h=dl(h,h.length,t.minDepth,c):h=dy(h,e.startState.selection),new vt(u==0?n.rest:h,u==0?h:n.rest)}let o=e.annotation(N1);if((o=="full"||o=="before")&&(r=r.isolate()),e.annotation(he.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let i=Be.fromTransaction(e),s=e.annotation(he.time),l=e.annotation(he.userEvent);return i?r=r.addChanges(i,s,l,t,e):e.selection&&(r=r.addSelection(e.startState.selection,s,l,t.newGroupDelay)),(o=="full"||o=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new vt(r.done.map(Be.fromJSON),r.undone.map(Be.fromJSON))}});function Uu(r={}){return[uy,cy.of(r),j.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?hy:e.inputType=="historyRedo"?Hu:null;return n?(e.preventDefault(),n(t)):!1}})]}function pl(r,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let o=t.field(uy,!1);if(!o)return!1;let i=o.pop(r,t,e);return i?(n(i),!0):!1}}var hy=pl(0,!1),Hu=pl(1,!1),B1=pl(0,!0),H1=pl(1,!0);var Be=class{constructor(e,t,n,o,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=o,this.selectionsAfter=i}setSelAfter(e){return new Be(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(o=>o.toJSON())}}static fromJSON(e){return new Be(e.changes&&ue.fromJSON(e.changes),[],e.mapped&&et.fromJSON(e.mapped),e.startSelection&&I.fromJSON(e.startSelection),e.selectionsAfter.map(I.fromJSON))}static fromTransaction(e,t){let n=xt;for(let o of e.startState.facet(V1)){let i=o(e);i.length&&(n=n.concat(i))}return!n.length&&e.changes.empty?null:new Be(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,xt)}static selection(e){return new Be(void 0,xt,void 0,void 0,e)}};function dl(r,e,t,n){let o=e+1>t+20?e-t-1:0,i=r.slice(o,e);return i.push(n),i}function _1(r,e){let t=[],n=!1;return r.iterChangedRanges((o,i)=>t.push(o,i)),e.iterChangedRanges((o,i,s,l)=>{for(let a=0;a<t.length;){let c=t[a++],u=t[a++];l>=c&&s<=u&&(n=!0)}}),n}function z1(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function fy(r,e){return r.length?e.length?r.concat(e):r:e}var xt=[],W1=200;function dy(r,e){if(r.length){let t=r[r.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-W1));return n.length&&n[n.length-1].eq(e)?r:(n.push(e),dl(r,r.length-1,1e9,t.setSelAfter(n)))}else return[Be.selection([e])]}function $1(r){let e=r[r.length-1],t=r.slice();return t[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Fu(r,e){if(!r.length)return r;let t=r.length,n=xt;for(;t;){let o=U1(r[t-1],e,n);if(o.changes&&!o.changes.empty||o.effects.length){let i=r.slice(0,t);return i[t-1]=o,i}else e=o.mapped,t--,n=o.selectionsAfter}return n.length?[Be.selection(n)]:xt}function U1(r,e,t){let n=fy(r.selectionsAfter.length?r.selectionsAfter.map(l=>l.map(e)):xt,t);if(!r.changes)return Be.selection(n);let o=r.changes.map(e),i=e.mapDesc(r.changes,!0),s=r.mapped?r.mapped.composeDesc(i):i;return new Be(o,ie.mapEffects(r.effects,e),s,r.startSelection.map(i),n)}var G1=/^(input\.type|delete)($|\.)/,vt=class{constructor(e,t,n=0,o=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=o}isolate(){return this.prevTime?new vt(this.done,this.undone):this}addChanges(e,t,n,o,i){let s=this.done,l=s[s.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||G1.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<o.newGroupDelay&&o.joinToEvent(i,_1(l.changes,e.changes))||n=="input.type.compose")?s=dl(s,s.length-1,o.minDepth,new Be(e.changes.compose(l.changes),fy(e.effects,l.effects),l.mapped,l.startSelection,xt)):s=dl(s,s.length,o.minDepth,e),new vt(s,xt,t,n)}addSelection(e,t,n,o){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:xt;return i.length>0&&t-this.prevTime<o&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&z1(i[i.length-1],e)?this:new vt(dy(this.done,e),this.undone,t,n)}addMapping(e){return new vt(Fu(this.done,e),Fu(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let o=e==0?this.done:this.undone;if(o.length==0)return null;let i=o[o.length-1];if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Bu.of({side:e,rest:$1(o)}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let s=o.length==1?xt:o.slice(0,o.length-1);return i.mapped&&(s=Fu(s,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Bu.of({side:e,rest:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};vt.empty=new vt(xt,xt);var Gu=[{key:"Mod-z",run:hy,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Hu,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Hu,preventDefault:!0},{key:"Mod-u",run:B1,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:H1,preventDefault:!0}];function io(r,e){return I.create(r.ranges.map(e),r.mainIndex)}function Jt(r,e){return r.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function At({state:r,dispatch:e},t){let n=io(r.selection,t);return n.eq(r.selection)?!1:(e(Jt(r,n)),!0)}function ml(r,e){return I.cursor(e?r.to:r.from)}function py(r,e){return At(r,t=>t.empty?r.moveByChar(t,e):ml(t,e))}function He(r){return r.textDirectionAt(r.state.selection.main.head)==pe.LTR}var my=r=>py(r,!He(r)),gy=r=>py(r,He(r));function yy(r,e){return At(r,t=>t.empty?r.moveByGroup(t,e):ml(t,e))}var q1=r=>yy(r,!He(r)),K1=r=>yy(r,He(r));function j1(r,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function gl(r,e,t){let n=Fe(r).resolveInner(e.head),o=t?J.closedBy:J.openedBy;for(let a=e.head;;){let c=t?n.childAfter(a):n.childBefore(a);if(!c)break;j1(r,c,o)?n=c:a=t?c.to:c.from}let i=n.type.prop(o),s,l;return i&&(s=t?mr(r,n.from,1):mr(r,n.to,-1))&&s.matched?l=t?s.end.to:s.end.from:l=t?n.to:n.from,I.cursor(l,t?-1:1)}var J1=r=>At(r,e=>gl(r.state,e,!He(r))),Q1=r=>At(r,e=>gl(r.state,e,He(r)));function by(r,e){return At(r,t=>{if(!t.empty)return ml(t,e);let n=r.moveVertically(t,e);return n.head!=t.head?n:r.moveToLineBoundary(t,e)})}var xy=r=>by(r,!1),vy=r=>by(r,!0);function wy(r){let e=r.scrollDOM.clientHeight<r.scrollDOM.scrollHeight-2,t=0,n=0,o;if(e){for(let i of r.state.facet(j.scrollMargins)){let s=i(r);s!=null&&s.top&&(t=Math.max(s==null?void 0:s.top,t)),s!=null&&s.bottom&&(n=Math.max(s==null?void 0:s.bottom,n))}o=r.scrollDOM.clientHeight-t-n}else o=(r.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(r.defaultLineHeight,o-5)}}function Sy(r,e){let t=wy(r),{state:n}=r,o=io(n.selection,s=>s.empty?r.moveVertically(s,e,t.height):ml(s,e));if(o.eq(n.selection))return!1;let i;if(t.selfScroll){let s=r.coordsAtPos(n.selection.main.head),l=r.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;s&&s.top>a&&s.bottom<c&&(i=j.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-a}))}return r.dispatch(Jt(n,o),{effects:i}),!0}var ty=r=>Sy(r,!1),_u=r=>Sy(r,!0);function Dn(r,e,t){let n=r.lineBlockAt(e.head),o=r.moveToLineBoundary(e,t);if(o.head==e.head&&o.head!=(t?n.to:n.from)&&(o=r.moveToLineBoundary(e,t,!1)),!t&&o.head==n.from&&n.length){let i=/^\s*/.exec(r.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(o=I.cursor(n.from+i))}return o}var Y1=r=>At(r,e=>Dn(r,e,!0)),X1=r=>At(r,e=>Dn(r,e,!1)),Z1=r=>At(r,e=>Dn(r,e,!He(r))),eM=r=>At(r,e=>Dn(r,e,He(r))),tM=r=>At(r,e=>I.cursor(r.lineBlockAt(e.head).from,1)),nM=r=>At(r,e=>I.cursor(r.lineBlockAt(e.head).to,-1));function rM(r,e,t){let n=!1,o=io(r.selection,i=>{let s=mr(r,i.head,-1)||mr(r,i.head,1)||i.head>0&&mr(r,i.head-1,1)||i.head<r.doc.length&&mr(r,i.head+1,-1);if(!s||!s.end)return i;n=!0;let l=s.start.from==i.head?s.end.to:s.end.from;return t?I.range(i.anchor,l):I.cursor(l)});return n?(e(Jt(r,o)),!0):!1}var oM=({state:r,dispatch:e})=>rM(r,e,!1);function wt(r,e){let t=io(r.state.selection,n=>{let o=e(n);return I.range(n.anchor,o.head,o.goalColumn,o.bidiLevel||void 0)});return t.eq(r.state.selection)?!1:(r.dispatch(Jt(r.state,t)),!0)}function Cy(r,e){return wt(r,t=>r.moveByChar(t,e))}var Ty=r=>Cy(r,!He(r)),ky=r=>Cy(r,He(r));function My(r,e){return wt(r,t=>r.moveByGroup(t,e))}var iM=r=>My(r,!He(r)),sM=r=>My(r,He(r));var lM=r=>wt(r,e=>gl(r.state,e,!He(r))),aM=r=>wt(r,e=>gl(r.state,e,He(r)));function Ey(r,e){return wt(r,t=>r.moveVertically(t,e))}var Ry=r=>Ey(r,!1),Iy=r=>Ey(r,!0);function Py(r,e){return wt(r,t=>r.moveVertically(t,e,wy(r).height))}var ny=r=>Py(r,!1),ry=r=>Py(r,!0),cM=r=>wt(r,e=>Dn(r,e,!0)),uM=r=>wt(r,e=>Dn(r,e,!1)),hM=r=>wt(r,e=>Dn(r,e,!He(r))),fM=r=>wt(r,e=>Dn(r,e,He(r))),dM=r=>wt(r,e=>I.cursor(r.lineBlockAt(e.head).from)),pM=r=>wt(r,e=>I.cursor(r.lineBlockAt(e.head).to)),oy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:0})),!0),iy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.doc.length})),!0),sy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.selection.main.anchor,head:0})),!0),ly=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),mM=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),gM=({state:r,dispatch:e})=>{let t=bl(r).map(({from:n,to:o})=>I.range(n,Math.min(o+1,r.doc.length)));return e(r.update({selection:I.create(t),userEvent:"select"})),!0},yM=({state:r,dispatch:e})=>{let t=io(r.selection,n=>{var o;let i=Fe(r).resolveInner(n.head,1);for(;!(i.from<n.from&&i.to>=n.to||i.to>n.to&&i.from<=n.from||!(!((o=i.parent)===null||o===void 0)&&o.parent));)i=i.parent;return I.range(i.to,i.from)});return e(Jt(r,t)),!0},bM=({state:r,dispatch:e})=>{let t=r.selection,n=null;return t.ranges.length>1?n=I.create([t.main]):t.main.empty||(n=I.create([I.cursor(t.main.head)])),n?(e(Jt(r,n)),!0):!1};function yl(r,e){if(r.state.readOnly)return!1;let t="delete.selection",{state:n}=r,o=n.changeByRange(i=>{let{from:s,to:l}=i;if(s==l){let a=e(s);a<s?(t="delete.backward",a=fl(r,a,!1)):a>s&&(t="delete.forward",a=fl(r,a,!0)),s=Math.min(s,a),l=Math.max(l,a)}else s=fl(r,s,!1),l=fl(r,l,!0);return s==l?{range:i}:{changes:{from:s,to:l},range:I.cursor(s)}});return o.changes.empty?!1:(r.dispatch(n.update(o,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?j.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function fl(r,e,t){if(r instanceof j)for(let n of r.state.facet(j.atomicRanges).map(o=>o(r)))n.between(e,e,(o,i)=>{o<e&&i>e&&(e=t?i:o)});return e}var Dy=(r,e)=>yl(r,t=>{let{state:n}=r,o=n.doc.lineAt(t),i,s;if(!e&&t>o.from&&t<o.from+200&&!/[^ \t]/.test(i=o.text.slice(0,t-o.from))){if(i[i.length-1]==" ")return t-1;let l=lr(i,n.tabSize),a=l%pi(n)||pi(n);for(let c=0;c<a&&i[i.length-1-c]==" ";c++)t--;s=t}else s=Ve(o.text,t-o.from,e,e)+o.from,s==t&&o.number!=(e?n.doc.lines:1)&&(s+=e?1:-1);return s}),zu=r=>Dy(r,!1),Ly=r=>Dy(r,!0),Ay=(r,e)=>yl(r,t=>{let n=t,{state:o}=r,i=o.doc.lineAt(n),s=o.charCategorizer(n);for(let l=null;;){if(n==(e?i.to:i.from)){n==t&&i.number!=(e?o.doc.lines:1)&&(n+=e?1:-1);break}let a=Ve(i.text,n-i.from,e)+i.from,c=i.text.slice(Math.min(n,a)-i.from,Math.max(n,a)-i.from),u=s(c);if(l!=null&&u!=l)break;(c!=" "||n!=t)&&(l=u),n=a}return n}),Oy=r=>Ay(r,!1),xM=r=>Ay(r,!0),Ny=r=>yl(r,e=>{let t=r.lineBlockAt(e).to;return e<t?t:Math.min(r.state.doc.length,e+1)}),vM=r=>yl(r,e=>{let t=r.lineBlockAt(e).from;return e>t?t:Math.max(0,e-1)});var wM=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:Y.of(["",""])},range:I.cursor(n.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},SM=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(n=>{if(!n.empty||n.from==0||n.from==r.doc.length)return{range:n};let o=n.from,i=r.doc.lineAt(o),s=o==i.from?o-1:Ve(i.text,o-i.from,!1)+i.from,l=o==i.to?o+1:Ve(i.text,o-i.from,!0)+i.from;return{changes:{from:s,to:l,insert:r.doc.slice(o,l).append(r.doc.slice(s,o))},range:I.cursor(l)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function bl(r){let e=[],t=-1;for(let n of r.selection.ranges){let o=r.doc.lineAt(n.from),i=r.doc.lineAt(n.to);if(!n.empty&&n.to==i.from&&(i=r.doc.lineAt(n.to-1)),t>=o.number){let s=e[e.length-1];s.to=i.to,s.ranges.push(n)}else e.push({from:o.from,to:i.to,ranges:[n]});t=i.number+1}return e}function Vy(r,e,t){if(r.readOnly)return!1;let n=[],o=[];for(let i of bl(r)){if(t?i.to==r.doc.length:i.from==0)continue;let s=r.doc.lineAt(t?i.to+1:i.from-1),l=s.length+1;if(t){n.push({from:i.to,to:s.to},{from:i.from,insert:s.text+r.lineBreak});for(let a of i.ranges)o.push(I.range(Math.min(r.doc.length,a.anchor+l),Math.min(r.doc.length,a.head+l)))}else{n.push({from:s.from,to:i.from},{from:i.to,insert:r.lineBreak+s.text});for(let a of i.ranges)o.push(I.range(a.anchor-l,a.head-l))}}return n.length?(e(r.update({changes:n,scrollIntoView:!0,selection:I.create(o,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}var CM=({state:r,dispatch:e})=>Vy(r,e,!1),TM=({state:r,dispatch:e})=>Vy(r,e,!0);function Fy(r,e,t){if(r.readOnly)return!1;let n=[];for(let o of bl(r))t?n.push({from:o.from,insert:r.doc.slice(o.from,o.to)+r.lineBreak}):n.push({from:o.to,insert:r.lineBreak+r.doc.slice(o.from,o.to)});return e(r.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var kM=({state:r,dispatch:e})=>Fy(r,e,!1),MM=({state:r,dispatch:e})=>Fy(r,e,!0),EM=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(bl(e).map(({from:o,to:i})=>(o>0?o--:i<e.doc.length&&i++,{from:o,to:i}))),n=io(e.selection,o=>r.moveVertically(o,!0)).map(t);return r.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function RM(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Fe(r).resolveInner(e),n=t.childBefore(e),o=t.childAfter(e),i;return n&&o&&n.to<=e&&o.from>=e&&(i=n.type.prop(J.closedBy))&&i.indexOf(o.name)>-1&&r.doc.lineAt(n.to).from==r.doc.lineAt(o.from).from?{from:n.to,to:o.from}:null}var IM=By(!1),PM=By(!0);function By(r){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(o=>{let{from:i,to:s}=o,l=e.doc.lineAt(i),a=!r&&i==s&&RM(e,i);r&&(i=s=(s<=l.to?l:e.doc.lineAt(s)).to);let c=new pr(e,{simulateBreak:i,simulateDoubleBreak:!!a}),u=Du(c,i);for(u==null&&(u=/^\s*/.exec(e.doc.lineAt(i).text)[0].length);s<l.to&&/\s/.test(l.text[s-l.from]);)s++;a?{from:i,to:s}=a:i>l.from&&i<l.from+100&&!/\S/.test(l.text.slice(0,i))&&(i=l.from);let h=["",mi(e,u)];return a&&h.push(mi(e,c.lineIndent(l.from,-1))),{changes:{from:i,to:s,insert:Y.of(h)},range:I.cursor(i+1+h[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function qu(r,e){let t=-1;return r.changeByRange(n=>{let o=[];for(let s=n.from;s<=n.to;){let l=r.doc.lineAt(s);l.number>t&&(n.empty||n.to>l.from)&&(e(l,o,n),t=l.number),s=l.to+1}let i=r.changes(o);return{changes:o,range:I.range(i.mapPos(n.anchor,1),i.mapPos(n.head,1))}})}var DM=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=Object.create(null),n=new pr(r,{overrideIndentation:i=>{let s=t[i];return s==null?-1:s}}),o=qu(r,(i,s,l)=>{let a=Du(n,i.from);if(a==null)return;/\S/.test(i.text)||(a=0);let c=/^\s*/.exec(i.text)[0],u=mi(r,a);(c!=u||l.from<i.from+c.length)&&(t[i.from]=a,s.push({from:i.from,to:i.from+c.length,insert:u}))});return o.changes.empty||e(r.update(o,{userEvent:"indent"})),!0},LM=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(qu(r,(t,n)=>{n.push({from:t.from,insert:r.facet(di)})}),{userEvent:"input.indent"})),!0),AM=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(qu(r,(t,n)=>{let o=/^\s*/.exec(t.text)[0];if(!o)return;let i=lr(o,r.tabSize),s=0,l=mi(r,Math.max(0,i-pi(r)));for(;s<o.length&&s<l.length&&o.charCodeAt(s)==l.charCodeAt(s);)s++;n.push({from:t.from+s,to:t.from+o.length,insert:l.slice(s)})}),{userEvent:"delete.dedent"})),!0);var OM=[{key:"Ctrl-b",run:my,shift:Ty,preventDefault:!0},{key:"Ctrl-f",run:gy,shift:ky},{key:"Ctrl-p",run:xy,shift:Ry},{key:"Ctrl-n",run:vy,shift:Iy},{key:"Ctrl-a",run:tM,shift:dM},{key:"Ctrl-e",run:nM,shift:pM},{key:"Ctrl-d",run:Ly},{key:"Ctrl-h",run:zu},{key:"Ctrl-k",run:Ny},{key:"Ctrl-Alt-h",run:Oy},{key:"Ctrl-o",run:wM},{key:"Ctrl-t",run:SM},{key:"Ctrl-v",run:_u}],NM=[{key:"ArrowLeft",run:my,shift:Ty,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:q1,shift:iM,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Z1,shift:hM,preventDefault:!0},{key:"ArrowRight",run:gy,shift:ky,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:K1,shift:sM,preventDefault:!0},{mac:"Cmd-ArrowRight",run:eM,shift:fM,preventDefault:!0},{key:"ArrowUp",run:xy,shift:Ry,preventDefault:!0},{mac:"Cmd-ArrowUp",run:oy,shift:sy},{mac:"Ctrl-ArrowUp",run:ty,shift:ny},{key:"ArrowDown",run:vy,shift:Iy,preventDefault:!0},{mac:"Cmd-ArrowDown",run:iy,shift:ly},{mac:"Ctrl-ArrowDown",run:_u,shift:ry},{key:"PageUp",run:ty,shift:ny},{key:"PageDown",run:_u,shift:ry},{key:"Home",run:X1,shift:uM,preventDefault:!0},{key:"Mod-Home",run:oy,shift:sy},{key:"End",run:Y1,shift:cM,preventDefault:!0},{key:"Mod-End",run:iy,shift:ly},{key:"Enter",run:IM},{key:"Mod-a",run:mM},{key:"Backspace",run:zu,shift:zu},{key:"Delete",run:Ly},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Oy},{key:"Mod-Delete",mac:"Alt-Delete",run:xM},{mac:"Mod-Backspace",run:vM},{mac:"Mod-Delete",run:Ny}].concat(OM.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),xl=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:J1,shift:lM},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Q1,shift:aM},{key:"Alt-ArrowUp",run:CM},{key:"Shift-Alt-ArrowUp",run:kM},{key:"Alt-ArrowDown",run:TM},{key:"Shift-Alt-ArrowDown",run:MM},{key:"Escape",run:bM},{key:"Mod-Enter",run:PM},{key:"Alt-l",mac:"Ctrl-l",run:gM},{key:"Mod-i",run:yM,preventDefault:!0},{key:"Mod-[",run:AM},{key:"Mod-]",run:LM},{key:"Mod-Alt-\\",run:DM},{key:"Shift-Mod-k",run:EM},{key:"Shift-Mod-\\",run:oM},{key:"Mod-/",run:R1},{key:"Alt-A",run:P1}].concat(NM);var VM=[...xl,...Gu],FM=(()=>[yu(),Uu(),gu(),Nu(),gi(Lu,{fallback:!0}),Zr.of(VM)])();import{isNumericColumn as $W}from"@vuu-ui/vuu-utils";var Hy=[{label:"=",boost:10,type:"operator"},{label:"!=",boost:9,type:"operator"}],BM=[...Hy,{label:"in",boost:6,type:"operator"},{label:"starts",boost:5,type:"operator"},{label:"ends",boost:4,type:"operator"}],HM=[...Hy,{label:">",boost:8,type:"operator"},{label:"<",boost:7,type:"operator"}];import P5 from"classnames";import{useEffect as A5,useMemo as O5,useRef as N5}from"react";var s5=In.define({name:"VuuFilterQuery",parser:Uo.configure({props:[ui({Identifier:P.variableName,String:P.string,Or:P.emphasis,Operator:P.operator})]})});var UM=cn.define([{tag:P.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:P.comment,color:"green",fontStyle:"italic"}]),GM=gi(UM);var qM=j.theme({"&":{color:"var(--vuuFilterEditor-color)",backgroundColor:"var(--vuuFilterEditor-background)",fontSize:"var(--vuuFilterEditor-fontSize)"},".cm-content":{caretColor:"var(--vuuFilterEditor-cursorColor)",padding:0},".cm-line":{lineHeight:"var(--vuuFilterEditor-lineHeight)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-scroller":{fontFamily:"var(--vuuFilterEditor-fontFamily)"},".cm-tooltip":{background:"var(--vuuFilterEditor-tooltipBackground)",border:"var(--vuuFilterEditor-tooltipBorder)",boxShadow:"var(--vuuFilterEditor-tooltipElevation)","&.cm-tooltip-autocomplete > ul":{fontFamily:"var(--vuuFilterEditor-fontFamily)",fontSize:"var(--vuuFilterEditor-fontSize)",maxHeight:"240px"},"&.cm-tooltip-autocomplete > ul > li":{alignItems:"center",display:"flex",height:"var(--vuuFilterEditor-suggestion-height)",padding:"0 3px",lineHeight:"var(--vuuFilterEditor-suggestion-height)"},"&.cm-tooltip-autocomplete li[aria-selected]":{background:"var(--vuuFilterEditor-suggestion-selectedBackground)",color:"var(--vuuFilterEditor-suggestion-selectedColor)"}},".cm-completionIcon":{height:"18px",flex:"0 0 16px"},".cm-completionLabel":{flex:"1 1 auto"},".cm-completionIcon-filter":{position:"relative","&:after":{background:"var(--salt-text-secondary-foreground)",content:"''","-webkit-mask":"var(--svg-filter) center center/13px 13px","-webkit-mask-repeat":"no-repeat",position:"absolute",height:"18px",left:"0px",top:"0px",width:"16px"}}},{dark:!1});import{useCallback as w5}from"react";import{jsx as Z5,jsxs as e$}from"react/jsx-runtime";import{useCallback as g$,useRef as y$}from"react";import{createEl as r$}from"@vuu-ui/vuu-utils";var vl=r=>{let e=localStorage.getItem(r);return e?JSON.parse(e):void 0};var wl=(r,e)=>{try{return localStorage.setItem(r,JSON.stringify(e)),e}catch{return}};import{getUniqueId as KM}from"@vuu-ui/vuu-utils";var _y="layouts/metadata",zy="layouts/layouts",Sl=class{createLayout(e,t){return new Promise(n=>{console.log(`Saving layout as ${e.name} to group ${e.group}...`),Promise.all([this.loadLayouts(),this.loadMetadata()]).then(([o,i])=>{let s=KM();this.appendAndPersist(s,e,t,o,i),n(s)})})}updateLayout(e,t,n){return new Promise((o,i)=>{this.validateIds(e).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([s,l])=>{let a=s.filter(u=>u.id!==e),c=l.filter(u=>u.id!==e);this.appendAndPersist(e,t,n,a,c),o()}).catch(s=>i(s))})}deleteLayout(e){return new Promise((t,n)=>{this.validateIds(e).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([o,i])=>{let s=o.filter(a=>a.id!==e),l=i.filter(a=>a.id!==e);this.saveLayoutsWithMetadata(s,l),t()}).catch(o=>n(o))})}loadLayout(e){return new Promise((t,n)=>{this.validateId(e,"layout").then(()=>this.loadLayouts()).then(o=>{let i=o.find(s=>s.id===e);t(i.json)}).catch(o=>n(o))})}loadMetadata(){return new Promise(e=>{let t=vl(_y);e(t||[])})}loadApplicationLayout(){return new Promise(e=>{let t=vl("api/vui");e(t||Bo)})}saveApplicationLayout(e){return new Promise((t,n)=>{wl("api/vui",e)?t():n(new Error("Layout failed to save"))})}loadLayouts(){return new Promise(e=>{let t=vl(zy);e(t||[])})}appendAndPersist(e,t,n,o,i){o.push({id:e,json:n}),i.push({id:e,...t}),this.saveLayoutsWithMetadata(o,i)}saveLayoutsWithMetadata(e,t){wl(zy,e),wl(_y,t)}async validateIds(e){return Promise.all([this.validateId(e,"metadata").catch(t=>t.message),this.validateId(e,"layout").catch(t=>t.message)]).then(t=>{let n=t.filter(o=>o!==void 0).join("; ");if(n)throw new Error(n)})}validateId(e,t){return new Promise((n,o)=>{(t==="metadata"?this.loadMetadata:this.loadLayouts)().then(s=>{switch(s.filter(a=>a.id===e).length){case 1:{n();break}case 0:{o(new Error(`No ${t} with ID ${e}`));break}default:o(new Error(`Non-unique ${t} with ID ${e}`))}})})}};import _$,{useEffect as z$,useState as W$}from"react";import U$ from"classnames";import{Fragment as j$,jsx as J$,jsxs as K$}from"react/jsx-runtime";function Wy(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r))for(e=0;e<r.length;e++)r[e]&&(t=Wy(r[e]))&&(n&&(n+=" "),n+=t);else for(e in r)r[e]&&(n&&(n+=" "),n+=e);return n}function yr(){for(var r,e,t=0,n="";t<arguments.length;)(r=arguments[t++])&&(e=Wy(r))&&(n&&(n+=" "),n+=e);return n}var jM=/[.*+?^${}()|[\]\\]/g;function Cl(r){return r.replace(jM,"\\$&")}import{jsx as n8}from"react/jsx-runtime";import{createContext as JM,useContext as QM}from"react";var YM=JM(typeof window<"u"?window:null);function un(){return QM(YM)}import*as Tl from"react";import{jsx as c8}from"react/jsx-runtime";import{createContext as XM,useMemo as h8,useContext as ZM}from"react";var eE=XM(null);function $y(){return ZM(eE)}var Uy,tE=(Uy=Tl.useInsertionEffect)!=null?Uy:Tl.useLayoutEffect,Ku=new WeakMap;function hn({testId:r,css:e,window:t}){let n=$y();tE(()=>{var o,i;if(!t)return;let s=(o=Ku.get(t))!=null?o:new Map,l=(i=s.get(e))!=null?i:{styleElement:null,count:0};return l.styleElement==null?(l.styleElement=t.document.createElement("style"),l.styleElement.setAttribute("type","text/css"),l.styleElement.setAttribute("data-salt-style",r||""),l.styleElement.textContent=e,l.count=1,t.document.head.insertBefore(l.styleElement,n||t.document.head.firstChild)):(l.styleElement.textContent=e,l.count++),s.set(e,l),Ku.set(t,s),()=>{let a=Ku.get(t),c=a==null?void 0:a.get(e);c!=null&&c.styleElement&&(c.count--,c.count<1&&(t.document.head.removeChild(c.styleElement),c.styleElement=null,a==null||a.delete(e)))}},[r,e,t])}import"@salt-ds/core";import"react";import{jsx as b8}from"react/jsx-runtime";import{createContext as nE,cloneElement as v8,useContext as rE}from"react";var oE=nE(void 0);function Gy(){let r=rE(oE);if(r)return r}function iE(r,...e){let t=new Set(r);for(let n of e)for(let o of n)t.add(o);return t}var bi="ArrowUp",xi="ArrowDown",qy="ArrowLeft",Ky="ArrowRight",ju="Enter",kl="Home",vi="End",Ju="PageUp",Ml="PageDown",jy=" ",sE=new Set(["Enter","Delete"," "]),lE=new Set(["Tab"]),aE=new Set(["ArrowRight","ArrowLeft"]),Jy=new Set([kl,vi,Ju,Ml,xi,bi]),cE=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),uE=iE(sE,Jy,aE,cE,lE),El=r=>uE.has(r.key)?!1:r.key.length===1&&!r.ctrlKey&&!r.metaKey&&!r.altKey,Qy=({key:r})=>Jy.has(r);import{useState as SE,useRef as Il,useMemo as Pl,useCallback as St,isValidElement as lb}from"react";import{isValidElement as Qu,Children as fE}from"react";var Yy=r=>null;var Xy=r=>null;var hE=r=>Object.prototype.toString.call(r)==="[object Object]";function so(r){return typeof r=="string"?r:hE(r)?Object.prototype.hasOwnProperty.call(r,"label")?String(r.label):(console.warn(["itemToString: you've likely forgotten to set the label prop on the item object.","You can also provide your own `itemToString` implementation."].join(`
27
- `)),""):String(r)}var Yu=(r,e)=>r!==null&&Object.prototype.hasOwnProperty.call(r,e),Xu=r=>Yu(r,"header"),Zy=r=>Yu(r,"childNodes"),wi=(r,e)=>r&&Object.prototype.hasOwnProperty.call(r.props,e),eb=r=>{if(Qu(r)){if(wi(r,"disabled"))return r.props.disabled===!0}else if(Yu(r,"disabled"))return r.disabled===!0;return!1},tb=r=>Qu(r)&&wi(r,"focusable")?r.props.focusable:!0,nb=(r,e,t)=>{if(r.childNodes)return r.childNodes.length;if(r.header){let n=t+1,o=0;for(;n<e.length&&!e[n].header;)o++,n++;return o}else return 0},dE=r=>{if(typeof r.props.children=="string")return r.props.children;if(r.props.title)return r.props.title;if(r.props.label)return r.props.label},rb=r=>r.type===Xy||wi(r,"data-header"),ob=r=>r.type===Yy||wi(r,"data-group"),pE=r=>wi(r,"selectable")?r.props.selectable===!0:!ob(r)&&!rb(r),mE=r=>{if(ob(r)){let{props:{children:e}}=r;if(typeof e!="string")return eh(e)}},gE=(r,e)=>{let t=[];return fE.forEach(r,n=>{Qu(n)&&t.push(e(n))}),t},Zu=(r,e)=>{if(Array.isArray(r))return r.length===0&&(e!=null&&e.noChildrenLabel)?[{label:e.noChildrenLabel,value:null}]:r.map((t,n)=>{var o,i;return{childNodes:Zu(t.childNodes,e),description:t.description,expanded:t.expanded,value:t,label:(i=(o=e==null?void 0:e.itemToString)==null?void 0:o.call(e,t))!=null?i:so(t)}});if(r)throw Error("list-child-items expects source to be an array")},eh=r=>{if(r)return gE(r,e=>{let{"data-id":t,disabled:n,id:o=t,"data-expanded":i,expanded:s=i}=e.props;return{childNodes:mE(e),disabled:n,expanded:s,header:rb(e),id:o,label:dE(e),selectable:pE(e),value:e}})},yE=new Set(["/","-","."]),bE=r=>yE.has(r),ib=(r,e)=>e.startsWith(r)&&bE(e[r.length]),xE=new Set([".","/"]);function vE(r,e){return e.startsWith(r)?xE.has(e.charAt(r.length)):!1}function Rl(r,e,t){let n;return r.map(i=>i.id===e?{...i,...t}:vE(i.id,e)&&i.childNodes?(n=Rl(i.childNodes,e,t),{...i,childNodes:n}):i)}import"react";import"@salt-ds/core";var wE=r=>r&&r.replace(/^\s+/g,""),th=r=>new RegExp(`(${Cl(wE(r))})`,"gi"),sb=(r="",e=th)=>(t="")=>!!t.length&&!!r.length&&t.match(e(r))!==null;var CE={},ab=({children:r,id:e,label:t="",options:n=CE,source:o})=>{var i;let{getItemId:s}=n,[,l]=SE(null),a=Gy(),c=Il([]),u=Il([]),h=Pl(()=>[],[]),f=Il((i=n.filterPattern)!=null?i:""),{getFilterRegex:d=th,noChildrenLabel:p,itemToString:m=so}=n,g=St(A=>n.defaultExpanded||!1,[n.defaultExpanded]),y=St((A,V,B=1,U="",X=[],ee=[],_e=[])=>(A.forEach((de,it,On)=>{var Vt,re;let se=de.header&&n.collapsibleHeaders,Me=de.childNodes&&n.collapsibleHeaders===!1,Tt=!de.childNodes||de.childNodes.length===0,ho=Me||Tt&&!se,fo=U?`${U}.${it}`:`item-${it}`,po=(Vt=de.id)!=null?Vt:s?s(it):`${e}-${fo}`,kt=ho?void 0:(re=de.expanded)!=null?re:g(po),mo={...de,childNodes:void 0,count:!Me&&kt===void 0?0:nb(de,On,it),description:de.description,disabled:eb(de.value),focusable:tb(de.value)?void 0:!1,id:po,index:V.value,expanded:kt,level:B};if(X.push(mo),ee.push(mo),_e.push(A[it].value),V.value+=1,de.childNodes){let[Ql]=y(de.childNodes,V,B+1,fo,[],ee,_e);mo.childNodes=Ql}}),[X,_e,ee]),[n.collapsibleHeaders,s,e,g]),v=St(()=>f.current?sb(f.current,d):null,[d]),w=St((A,V=v(),B=[],U={value:0})=>{let X=!1;for(let ee of A)X&&!Xu(ee)||(ee.value!==null&&(V===null||V(m(ee.value)))&&(B[U.value]=ee,U.value+=1),X=!1,Xu(ee)&&ee.expanded===!1?X=!0:Zy(ee)&&ee.expanded!==!1&&ee.childNodes&&w(ee.childNodes,V,B,U));return B},[v,m]),x=Pl(()=>a?h:Zu(o,{itemToString:m,noChildrenLabel:p})||eh(r)||[],[a,h,o,m,p,r]),[S,b,C]=Pl(()=>a?[h,h,h]:y(x,{value:0}),[h,y,a,x]);u.current=C,Pl(()=>a?h:c.current=w(S),[h,w,S,a]);let k=Il(S),E=St((A="")=>{typeof A=="string"&&(f.current=A,c.current=w(S),l({}))},[S,w]),R=St((A,V=S)=>{let B=V.find(U=>{var X;return U.id===A||((X=U==null?void 0:U.childNodes)==null?void 0:X.length)&&ib(U.id,A)});if((B==null?void 0:B.id)===A)return b==null?void 0:b[B.index];if(B)return R(A,B.childNodes);throw Error(`useCollectionData itemById, id ${A} not found `)},[b,S]),N=St(A=>{let V=u.current.find(B=>lb(B.value)?B.label===A:B.value===A);if(V)return V;throw Error("useCollectionData toCollectionItem, item not found ")},[]),O=St(A=>{if(A===null)return null;if(Array.isArray(A)){let V=[];for(let B of A){let U=N(B);V.push(U)}return V}else if(A!==void 0)return N(A)},[N]),M=St(A=>{let V=B=>{let U=u.current.find(X=>lb(X.value)?X.label===B:X.value!==null&&m(X.value)===B);if(U)return U};if(A===null)return null;if(Array.isArray(A)){let B=[];for(let U of A){let X=V(U);X&&B.push(X)}return B}else if(A!==void 0)return V(A)},[m]),D=St(A=>{for(let V of k.current)if(A===V.value)return V.id;throw Error("useCollectionData itemToId, item not found")},[]),F=St(A=>{k.current=Rl(k.current,A.id,{expanded:!1}),c.current=w(k.current),l({})},[w]),G=St(A=>{k.current=Rl(k.current,A.id,{expanded:!0}),c.current=w(k.current),l({})},[w]);return a||{collapseGroupItem:F,data:c.current,expandGroupItem:G,setFilterPattern:E,itemById:R,itemToId:D,toCollectionItem:N,itemToCollectionItem:O,stringToCollectionItem:M}};import{useIsomorphicLayoutEffect as cb}from"@salt-ds/core";import{useRef as TE,useCallback as kE}from"react";var ub=["height"];var br=new WeakMap,hb=(r,e,t)=>{switch(t){case"height":return e.height;case"scrollHeight":return r.scrollHeight;case"scrollWidth":return r.scrollWidth;case"width":return e.width;default:return 0}},Dl=typeof ResizeObserver<"u"?new ResizeObserver(r=>{for(let e of r){let{target:t,contentRect:n}=e,o=br.get(t);if(o){let{onResize:i,measurements:s}=o,l=!1;for(let[a,c]of Object.entries(s)){let u=hb(t,n,a);u!==c&&(l=!0,s[a]=u)}l&&i&&i(s)}}}):null;function Si(r,e,t,n=!1){let o=TE(e),i=kE(s=>{let l=s.getBoundingClientRect();return o.current.reduce((a,c)=>(a[c]=hb(s,l,c),a),{})},[]);cb(()=>{if(!Dl)return;let s=r.current,l=!1;async function a(){br.set(s,{measurements:{}}),l=!1;let{fonts:c}=document;if(c&&await c.ready,!l&&Dl){let u=br.get(s);if(u){let h=i(s);u.measurements=h,Dl.observe(s),n&&t(h)}}}if(s){if(br.has(s))throw Error("useResizeObserver attemping to observe same element twice");a()}return()=>{s&&br.has(s)&&(Dl.unobserve(s),br.delete(s),l=!0)}},[r,i]),cb(()=>{let s=r.current,l=br.get(s);if(l){if(o.current!==e){o.current=e;let a=i(s);l.measurements=a}l.onResize=t}},[e,i,r,t])}import{jsxs as iR,jsx as xr,Fragment as sR}from"react/jsx-runtime";import{forwardRef as lR,useRef as uh,createElement as aR,isValidElement as cR,cloneElement as uR}from"react";import{makePrefixer as hR,useIdMemo as fR,useForkRef as dR}from"@salt-ds/core";import{useMemo as ME,useImperativeHandle as EE}from"react";var RE={scrollToIndex:r=>{},scrollToItem:r=>{},scrollTo:r=>{}},fb=({collectionHook:r,forwardedRef:e,scrollableRef:t,scrollIntoView:n})=>{let o=ME(()=>({scrollToIndex:i=>{let s=r.data[i];s&&(n==null||n(s))},scrollToItem:i=>{let s=r.toCollectionItem(i);s&&(n==null||n(s))},scrollTo:i=>{t!=null&&t.current&&(t.current.scrollTop=i)}}),[r.data,r.toCollectionItem,n]);EE(e,()=>t.current?o:RE,[o])};import{useControlled as IE}from"@salt-ds/core";import{useRef as nh,useState as PE,useCallback as lo,useMemo as DE}from"react";var db=r=>Array.isArray(r)?r.length>0:r!=null,pb=r=>Array.isArray(r)?r[0]:r;var oh=-2;function mb(r,e,t){return e===bi||e===vi?t>0?t-1:t:t===null?0:t===r-1?t:t+1}var rh=(r,e)=>{let t=pb(e);return t?r.indexOf(t):-1},LE=(r,e,t,n)=>r===vi?n:r===kl?-1:e!==-1?e:t,yb=r=>{let e=document.getElementById(r.id);if(e)return e.getBoundingClientRect();throw Error(`useKeyboardNavigation.getItemRect no element found for item #${r==null?void 0:r.id}`)},AE=(r,e,t,n)=>{let{top:o}=e.getBoundingClientRect(),{scrollTop:i,clientHeight:s,scrollHeight:l}=r,a=t.length-1,c=Math.min(i+s,l-s);if(c!==i&&n<a){r.scrollTo(0,c);let u=n,h;do u+=1,h=yb(t[u]);while(h.top<o&&u<a);return u}},OE=async(r,e,t,n)=>{let{top:o}=e.getBoundingClientRect(),{scrollTop:i,clientHeight:s}=r,l=Math.max(i-s,0);if(l!==i&&n>0)return r.scrollTo(0,l),new Promise(a=>{requestAnimationFrame(()=>{let c=n,u;do c-=1,u=yb(t[c]);while(u.top>o&&c>0);a(c)})})},NE=r=>!r.header&&!r.childNodes,gb=r=>NE(r)||r.expanded!==void 0,bb=({containerRef:r,defaultHighlightedIndex:e=-1,disableHighlightOnFocus:t,highlightedIndex:n,indexPositions:o,onHighlight:i,onKeyboardNavigation:s,restoreLastFocus:l,selected:a})=>{let c=nh(-1),[,u]=PE({}),[h,f,d]=IE({controlled:n,default:e,name:"UseKeyboardNavigation"}),p=lo((k,E=!1)=>{i==null||i(k),f(k),E&&(c.current=k)},[i,f]),m=lo(async(k,E)=>{let{id:R}=o[E],N;if(R){let O=document.getElementById(R),{current:M}=r;O&&M&&(N=k.key===Ml?AE(M,O,o,E):await OE(M,O,o,E))}return N!=null?N:E},[r,o]),g=lo((k=xi,E=k===xi?-1:o.length)=>{if(o.length===0)return-1;{let R=rh(o,a),N=LE(k,E,R,o.length),O=mb(o.length,k,N);if(O===0&&k===bi&&!gb(o[0]))return E;for(;((k===xi||k===kl)&&O<o.length||(k===bi||k===vi)&&O>0)&&!gb(o[O]);)O=mb(o.length,k,O);return O}},[o,a]),y=nh(!1),v=nh(!1),w=k=>v.current=k,x=lo(k=>{if(v.current)v.current=!1;else if(y.current=!0,o.length===0)p(oh);else if(h!==-1)u({});else if(l)if(c.current!==-1)p(c.current);else{let E=rh(o,a);p(E!==-1?E:0)}else if(db(a)){let E=rh(o,a);p(E)}else t!==!0&&p(g())},[t,h,o,g,l,a,p]),S=lo(async k=>{let E=k.key===Ml||k.key===Ju?await m(k,h):g(k.key,h);E!==h&&p(E,!0),s==null||s(k,E)},[h,g,m,s,p]),b=lo(k=>{o.length>0&&Qy(k)?(k.preventDefault(),k.stopPropagation(),y.current=!0,S(k)):El(k)&&(y.current=!0)},[o,S]),C=DE(()=>({onBlur:k=>{let E=k.target.closest(".saltList"),R=k.relatedTarget;E&&!(E!=null&&E.contains(R))&&(y.current=!1,f(-1),l||(c.current=-1))},onFocus:x,onKeyDown:b,onMouseDownCapture:()=>{y.current=!1,w(!0)},onMouseMove:()=>{y.current&&(y.current=!1)},onMouseLeave:()=>{y.current=!1,w(!1),p(-1)}}),[x,b,l,f,p]);return{focusVisible:y.current?h:-1,controlledHighlighting:d,highlightedIndex:h,setHighlightedIndex:p,keyboardNavigation:y,listProps:C,setIgnoreFocus:w}};function xb(r,e){return Array.isArray(r)?r.includes(e):r===e}import{jsx as Ll,jsxs as HE}from"react/jsx-runtime";import{forwardRef as Cb}from"react";import{makePrefixer as _E,CheckboxIcon as zE}from"@salt-ds/core";import{jsx as ih,Fragment as VE}from"react/jsx-runtime";import{makePrefixer as FE}from"@salt-ds/core";import"react";var vb=`.saltHighlighter-highlight {
19
+ `){let o="";for(let i=0,s=0;i<this.children.length&&s<=t;i++){let l=this.children[i],a=s+l.length;s>e&&i&&(o+=n),e<a&&t>s&&(o+=l.sliceString(e-s,t-s,n)),s=a+1}return o}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof dt))return 0;let n=0,[o,i,s,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;o+=t,i+=t){if(o==s||i==l)return n;let a=this.children[o],c=e.children[i];if(a!=c)return n+a.scanIdentical(c,t);n+=a.length+1}}static from(e,t=e.reduce((n,o)=>n+o.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new ce(d,t)}let o=Math.max(32,n>>5),i=o<<1,s=o>>1,l=[],a=0,c=-1,u=[];function h(d){let p;if(d.lines>i&&d instanceof dt)for(let m of d.children)h(m);else d.lines>s&&(a>s||!a)?(f(),l.push(d)):d instanceof ce&&a&&(p=u[u.length-1])instanceof ce&&d.lines+p.lines<=32?(a+=d.lines,c+=d.length+1,u[u.length-1]=new ce(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>o&&f(),a+=d.lines,c+=d.length+1,u.push(d))}function f(){a!=0&&(l.push(u.length==1?u[0]:dt.from(u,c)),c=-1,a=u.length=0)}for(let d of e)h(d);return f(),l.length==1?l[0]:new dt(l,t)}};Y.empty=new ce([""],0);function pT(r){let e=-1;for(let t of r)e+=t.length+1;return e}function Ps(r,e,t=0,n=1e9){for(let o=0,i=0,s=!0;i<r.length&&o<=n;i++){let l=r[i],a=o+l.length;a>=t&&(a>n&&(l=l.slice(0,n-o)),o<t&&(l=l.slice(t-o)),s?(e[e.length-1]+=l,s=!1):e.push(l)),o=a+1}return e}function Hp(r,e,t){return Ps(r,[""],e,t)}var er=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ce?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,o=this.nodes[n],i=this.offsets[n],s=i>>1,l=o instanceof ce?o.text.length:o.children.length;if(s==(t>0?l:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
20
+ `,this;e--}else if(o instanceof ce){let a=o.text[s+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=o.children[s+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ce?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Ds=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new er(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:o}=this.cursor.next(e);return this.pos+=(o.length+e)*t,this.value=o.length<=n?o:t<0?o.slice(o.length-n):o.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Ls=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:o}=this.inner.next(e);return t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(Y.prototype[Symbol.iterator]=function(){return this.iter()},er.prototype[Symbol.iterator]=Ds.prototype[Symbol.iterator]=Ls.prototype[Symbol.iterator]=function(){return this});var hc=class{constructor(e,t,n,o){this.from=e,this.to=t,this.number=n,this.text=o}get length(){return this.to-this.from}},_r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(r=>r?parseInt(r,36):1);for(let r=1;r<_r.length;r++)_r[r]+=_r[r-1];function mT(r){for(let e=1;e<_r.length;e+=2)if(_r[e]>r)return _r[e-1]<=r;return!1}function _p(r){return r>=127462&&r<=127487}var zp=8205;function Ve(r,e,t=!0,n=!0){return(t?Kp:gT)(r,e,n)}function Kp(r,e,t){if(e==r.length)return e;e&&jp(r.charCodeAt(e))&&Jp(r.charCodeAt(e-1))&&e--;let n=zt(r,e);for(e+=tr(n);e<r.length;){let o=zt(r,e);if(n==zp||o==zp||t&&mT(o))e+=tr(o),n=o;else if(_p(o)){let i=0,s=e-2;for(;s>=0&&_p(zt(r,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function gT(r,e,t){for(;e>0;){let n=Kp(r,e-2,t);if(n<e)return n;e--}return 0}function jp(r){return r>=56320&&r<57344}function Jp(r){return r>=55296&&r<56320}function zt(r,e){let t=r.charCodeAt(e);if(!Jp(t)||e+1==r.length)return t;let n=r.charCodeAt(e+1);return jp(n)?(t-55296<<10)+(n-56320)+65536:t}function Qp(r){return r<=65535?String.fromCharCode(r):(r-=65536,String.fromCharCode((r>>10)+55296,(r&1023)+56320))}function tr(r){return r<65536?1:2}var fc=/\r\n?|\n/,Ne=function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r}(Ne||(Ne={})),et=class{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,o=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?(e(n,o,i),o+=i):o+=s,n+=i}}iterChangedRanges(e,t=!1){dc(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],o=this.sections[t++];o<0?e.push(n,o):e.push(o,n)}return new et(e)}composeDesc(e){return this.empty?e:e.empty?this:Yp(this,e)}mapDesc(e,t=!1){return e.empty?this:pc(this,e,t)}mapPos(e,t=-1,n=Ne.Simple){let o=0,i=0;for(let s=0;s<this.sections.length;){let l=this.sections[s++],a=this.sections[s++],c=o+l;if(a<0){if(c>e)return i+(e-o);i+=l}else{if(n!=Ne.Simple&&c>=e&&(n==Ne.TrackDel&&o<e&&c>e||n==Ne.TrackBefore&&o<e||n==Ne.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!l)return e==o||t<0?i:i+a;i+=a}o=c}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return i}touchesRange(e,t=e){for(let n=0,o=0;n<this.sections.length&&o<=t;){let i=this.sections[n++],s=this.sections[n++],l=o+i;if(s>=0&&o<=t&&l>=e)return o<e&&l>t?"cover":!0;o=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],o=this.sections[t++];e+=(e?" ":"")+n+(o>=0?":"+o:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new et(e)}static create(e){return new et(e)}},ue=class extends et{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return dc(this,(t,n,o,i,s)=>e=e.replace(o,o+(n-t),s),!1),e}mapDesc(e,t=!1){return pc(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let o=0,i=0;o<t.length;o+=2){let s=t[o],l=t[o+1];if(l>=0){t[o]=l,t[o+1]=s;let a=o>>1;for(;n.length<a;)n.push(Y.empty);n.push(s?e.slice(i,i+s):Y.empty)}i+=s}return new ue(t,n)}compose(e){return this.empty?e:e.empty?this:Yp(this,e,!0)}map(e,t=!1){return e.empty?this:pc(this,e,t,!0)}iterChanges(e,t=!1){dc(this,e,t)}get desc(){return et.create(this.sections)}filter(e){let t=[],n=[],o=[],i=new nr(this);e:for(let s=0,l=0;;){let a=s==e.length?1e9:e[s++];for(;l<a||l==a&&i.len==0;){if(i.done)break e;let u=Math.min(i.len,a-l);Oe(o,u,-1);let h=i.ins==-1?-1:i.off==0?i.ins:0;Oe(t,u,h),h>0&&Sn(n,t,i.text),i.forward(u),l+=u}let c=e[s++];for(;l<c;){if(i.done)break e;let u=Math.min(i.len,c-l);Oe(t,u,-1),Oe(o,u,i.ins==-1?-1:i.off==0?i.ins:0),i.forward(u),l+=u}}return{changes:new ue(t,n),filtered:et.create(o)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],o=this.sections[t+1];o<0?e.push(n):o==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let o=[],i=[],s=0,l=null;function a(u=!1){if(!u&&!o.length)return;s<t&&Oe(o,t-s,-1);let h=new ue(o,i);l=l?l.compose(h.map(l)):h,o=[],i=[],s=0}function c(u){if(Array.isArray(u))for(let h of u)c(h);else if(u instanceof ue){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);a(),l=l?l.compose(u.map(l)):u}else{let{from:h,to:f=h,insert:d}=u;if(h>f||h<0||f>t)throw new RangeError(`Invalid change range ${h} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?Y.of(d.split(n||fc)):d:Y.empty,m=p.length;if(h==f&&m==0)return;h<s&&a(),h>s&&Oe(o,h-s,-1),Oe(o,f-h,m),Sn(i,o,p),s=f}}return c(e),a(!l),l}static empty(e){return new ue(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let o=0;o<e.length;o++){let i=e[o];if(typeof i=="number")t.push(i,-1);else{if(!Array.isArray(i)||typeof i[0]!="number"||i.some((s,l)=>l&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(i.length==1)t.push(i[0],0);else{for(;n.length<o;)n.push(Y.empty);n[o]=Y.of(i.slice(1)),t.push(i[0],n[o].length)}}}return new ue(t,n)}static createSet(e,t){return new ue(e,t)}};function Oe(r,e,t,n=!1){if(e==0&&t<=0)return;let o=r.length-2;o>=0&&t<=0&&t==r[o+1]?r[o]+=e:e==0&&r[o]==0?r[o+1]+=t:n?(r[o]+=e,r[o+1]+=t):r.push(e,t)}function Sn(r,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<r.length)r[r.length-1]=r[r.length-1].append(t);else{for(;r.length<n;)r.push(Y.empty);r.push(t)}}function dc(r,e,t){let n=r.inserted;for(let o=0,i=0,s=0;s<r.sections.length;){let l=r.sections[s++],a=r.sections[s++];if(a<0)o+=l,i+=l;else{let c=o,u=i,h=Y.empty;for(;c+=l,u+=a,a&&n&&(h=h.append(n[s-2>>1])),!(t||s==r.sections.length||r.sections[s+1]<0);)l=r.sections[s++],a=r.sections[s++];e(o,c,i,u,h),o=c,i=u}}}function pc(r,e,t,n=!1){let o=[],i=n?[]:null,s=new nr(r),l=new nr(e);for(let a=-1;;)if(s.ins==-1&&l.ins==-1){let c=Math.min(s.len,l.len);Oe(o,c,-1),s.forward(c),l.forward(c)}else if(l.ins>=0&&(s.ins<0||a==s.i||s.off==0&&(l.len<s.len||l.len==s.len&&!t))){let c=l.len;for(Oe(o,l.ins,-1);c;){let u=Math.min(s.len,c);s.ins>=0&&a<s.i&&s.len<=u&&(Oe(o,0,s.ins),i&&Sn(i,o,s.text),a=s.i),s.forward(u),c-=u}l.next()}else if(s.ins>=0){let c=0,u=s.len;for(;u;)if(l.ins==-1){let h=Math.min(u,l.len);c+=h,u-=h,l.forward(h)}else if(l.ins==0&&l.len<u)u-=l.len,l.next();else break;Oe(o,c,a<s.i?s.ins:0),i&&a<s.i&&Sn(i,o,s.text),a=s.i,s.forward(s.len-u)}else{if(s.done&&l.done)return i?ue.createSet(o,i):et.create(o);throw new Error("Mismatched change set lengths")}}function Yp(r,e,t=!1){let n=[],o=t?[]:null,i=new nr(r),s=new nr(e);for(let l=!1;;){if(i.done&&s.done)return o?ue.createSet(n,o):et.create(n);if(i.ins==0)Oe(n,i.len,0,l),i.next();else if(s.len==0&&!s.done)Oe(n,0,s.ins,l),o&&Sn(o,n,s.text),s.next();else{if(i.done||s.done)throw new Error("Mismatched change set lengths");{let a=Math.min(i.len2,s.len),c=n.length;if(i.ins==-1){let u=s.ins==-1?-1:s.off?0:s.ins;Oe(n,a,u,l),o&&u&&Sn(o,n,s.text)}else s.ins==-1?(Oe(n,i.off?0:i.len,a,l),o&&Sn(o,n,i.textBit(a))):(Oe(n,i.off?0:i.len,s.off?0:s.ins,l),o&&!s.off&&Sn(o,n,s.text));l=(i.ins>a||s.ins>=0&&s.len>a)&&(l||n.length>c),i.forward2(a),s.forward(a)}}}}var nr=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Y.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Y.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},nn=class{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,t=-1){let n,o;return this.empty?n=o=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),o=e.mapPos(this.to,-1)),n==this.from&&o==this.to?this:new nn(n,o,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return D.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return D.range(this.anchor,n)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return D.range(e.anchor,e.head)}static create(e,t,n){return new nn(e,t,n)}},D=class{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:D.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new D([this.main],0)}addRange(e,t=!0){return D.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,D.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new D(e.ranges.map(t=>nn.fromJSON(t)),e.main)}static single(e,t=e){return new D([D.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,o=0;o<e.length;o++){let i=e[o];if(i.empty?i.from<=n:i.from<n)return D.normalized(e.slice(),t);n=i.to}return new D(e,t)}static cursor(e,t=0,n,o){return nn.create(e,e,(t==0?0:t<0?4:8)|(n==null?3:Math.min(2,n))|(o!=null?o:33554431)<<5)}static range(e,t,n,o){let i=(n!=null?n:33554431)<<5|(o==null?3:Math.min(2,o));return t<e?nn.create(t,e,24|i):nn.create(e,t,(t>e?4:0)|i)}static normalized(e,t=0){let n=e[t];e.sort((o,i)=>o.from-i.from),t=e.indexOf(n);for(let o=1;o<e.length;o++){let i=e[o],s=e[o-1];if(i.empty?i.from<=s.to:i.from<s.to){let l=s.from,a=Math.max(i.to,s.to);o<=t&&t--,e.splice(--o,2,i.anchor>i.head?D.range(a,l):D.range(l,a))}}return new D(e,t)}};function Xp(r,e){for(let t of r.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var wc=0,U=class{constructor(e,t,n,o,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=o,this.id=wc++,this.default=e([]),this.extensions=typeof i=="function"?i(this):i}static define(e={}){return new U(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:Sc),!!e.static,e.enables)}of(e){return new zr([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new zr(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new zr(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}};function Sc(r,e){return r==e||r.length==e.length&&r.every((t,n)=>t===e[n])}var zr=class{constructor(e,t,n,o){this.dependencies=e,this.facet=t,this.type=n,this.value=o,this.id=wc++}dynamicSlot(e){var t;let n=this.value,o=this.facet.compareInput,i=this.id,s=e[i]>>1,l=this.type==2,a=!1,c=!1,u=[];for(let h of this.dependencies)h=="doc"?a=!0:h=="selection"?c=!0:((t=e[h.id])!==null&&t!==void 0?t:1)&1||u.push(e[h.id]);return{create(h){return h.values[s]=n(h),1},update(h,f){if(a&&f.docChanged||c&&(f.docChanged||f.selection)||mc(h,u)){let d=n(h);if(l?!Wp(d,h.values[s],o):!o(d,h.values[s]))return h.values[s]=d,1}return 0},reconfigure:(h,f)=>{let d,p=f.config.address[i];if(p!=null){let m=Os(f,p);if(this.dependencies.every(y=>y instanceof U?f.facet(y)===h.facet(y):y instanceof qe?f.field(y,!1)==h.field(y,!1):!0)||(l?Wp(d=n(h),m,o):o(d=n(h),m)))return h.values[s]=m,0}else d=n(h);return h.values[s]=d,1}}}};function Wp(r,e,t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!t(r[n],e[n]))return!1;return!0}function mc(r,e){let t=!1;for(let n of e)Xo(r,n)&1&&(t=!0);return t}function yT(r,e,t){let n=t.map(a=>r[a.id]),o=t.map(a=>a.type),i=n.filter(a=>!(a&1)),s=r[e.id]>>1;function l(a){let c=[];for(let u=0;u<n.length;u++){let h=Os(a,n[u]);if(o[u]==2)for(let f of h)c.push(f);else c.push(h)}return e.combine(c)}return{create(a){for(let c of n)Xo(a,c);return a.values[s]=l(a),1},update(a,c){if(!mc(a,i))return 0;let u=l(a);return e.compare(u,a.values[s])?0:(a.values[s]=u,1)},reconfigure(a,c){let u=mc(a,n),h=c.config.facets[e.id],f=c.facet(e);if(h&&!u&&Sc(t,h))return a.values[s]=f,0;let d=l(a);return e.compare(d,f)?(a.values[s]=f,0):(a.values[s]=d,1)}}}var $p=U.define({static:!0}),qe=class{constructor(e,t,n,o,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=o,this.spec=i,this.provides=void 0}static define(e){let t=new qe(wc++,e.create,e.update,e.compare||((n,o)=>n===o),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet($p).find(n=>n.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,o)=>{let i=n.values[t],s=this.updateF(i,o);return this.compareF(i,s)?0:(n.values[t]=s,1)},reconfigure:(n,o)=>o.config.address[this.id]!=null?(n.values[t]=o.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,$p.of({field:this,create:e})]}get extension(){return this}},Xn={lowest:4,low:3,default:2,high:1,highest:0};function Yo(r){return e=>new As(e,r)}var ir={highest:Yo(Xn.highest),high:Yo(Xn.high),default:Yo(Xn.default),low:Yo(Xn.low),lowest:Yo(Xn.lowest)},As=class{constructor(e,t){this.inner=e,this.prec=t}},$r=class{of(e){return new Zo(this,e)}reconfigure(e){return $r.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Zo=class{constructor(e,t){this.compartment=e,this.inner=t}},Ur=class{constructor(e,t,n,o,i,s){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=o,this.staticValues=i,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let o=[],i=Object.create(null),s=new Map;for(let f of bT(e,t,s))f instanceof qe?o.push(f):(i[f.facet.id]||(i[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],c=[];for(let f of o)l[f.id]=c.length<<1,c.push(d=>f.slot(d));let u=n==null?void 0:n.config.facets;for(let f in i){let d=i[f],p=d[0].facet,m=u&&u[f]||[];if(d.every(y=>y.type==0))if(l[p.id]=a.length<<1|1,Sc(m,d))a.push(n.facet(p));else{let y=p.combine(d.map(g=>g.value));a.push(n&&p.compare(y,n.facet(p))?n.facet(p):y)}else{for(let y of d)y.type==0?(l[y.id]=a.length<<1|1,a.push(y.value)):(l[y.id]=c.length<<1,c.push(g=>y.dynamicSlot(g)));l[p.id]=c.length<<1,c.push(y=>yT(y,p,d))}}let h=c.map(f=>f(l));return new Ur(e,s,h,l,a,i)}};function bT(r,e,t){let n=[[],[],[],[],[]],o=new Map;function i(s,l){let a=o.get(s);if(a!=null){if(a<=l)return;let c=n[a].indexOf(s);c>-1&&n[a].splice(c,1),s instanceof Zo&&t.delete(s.compartment)}if(o.set(s,l),Array.isArray(s))for(let c of s)i(c,l);else if(s instanceof Zo){if(t.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;t.set(s.compartment,c),i(c,l)}else if(s instanceof As)i(s.inner,s.prec);else if(s instanceof qe)n[l].push(s),s.provides&&i(s.provides,l);else if(s instanceof zr)n[l].push(s),s.facet.extensions&&i(s.facet.extensions,Xn.default);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);i(c,l)}}return i(r,Xn.default),n.reduce((s,l)=>s.concat(l))}function Xo(r,e){if(e&1)return 2;let t=e>>1,n=r.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;r.status[t]=4;let o=r.computeSlot(r,r.config.dynamicSlots[t]);return r.status[t]=2|o}function Os(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}var Zp=U.define(),em=U.define({combine:r=>r.some(e=>e),static:!0}),tm=U.define({combine:r=>r.length?r[0]:void 0,static:!0}),nm=U.define(),rm=U.define(),om=U.define(),im=U.define({combine:r=>r.length?r[0]:!1}),tt=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Ns}},Ns=class{of(e){return new tt(this,e)}},gc=class{constructor(e){this.map=e}of(e){return new ie(this,e)}},ie=class{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new ie(this.type,t)}is(e){return this.type==e}static define(e={}){return new gc(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let o of e){let i=o.map(t);i&&n.push(i)}return n}};ie.reconfigure=ie.define();ie.appendConfig=ie.define();var he=class{constructor(e,t,n,o,i,s){this.startState=e,this.changes=t,this.selection=n,this.effects=o,this.annotations=i,this.scrollIntoView=s,this._doc=null,this._state=null,n&&Xp(n,t.newLength),i.some(l=>l.type==he.time)||(this.annotations=i.concat(he.time.of(Date.now())))}static create(e,t,n,o,i,s){return new he(e,t,n,o,i,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(he.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};he.time=tt.define();he.userEvent=tt.define();he.addToHistory=tt.define();he.remote=tt.define();function xT(r,e){let t=[];for(let n=0,o=0;;){let i,s;if(n<r.length&&(o==e.length||e[o]>=r[n]))i=r[n++],s=r[n++];else if(o<e.length)i=e[o++],s=e[o++];else return t;!t.length||t[t.length-1]<i?t.push(i,s):t[t.length-1]<s&&(t[t.length-1]=s)}}function sm(r,e,t){var n;let o,i,s;return t?(o=e.changes,i=ue.empty(e.changes.length),s=r.changes.compose(e.changes)):(o=e.changes.map(r.changes),i=r.changes.mapDesc(e.changes,!0),s=r.changes.compose(o)),{changes:s,selection:e.selection?e.selection.map(i):(n=r.selection)===null||n===void 0?void 0:n.map(o),effects:ie.mapEffects(r.effects,o).concat(ie.mapEffects(e.effects,i)),annotations:r.annotations.length?r.annotations.concat(e.annotations):e.annotations,scrollIntoView:r.scrollIntoView||e.scrollIntoView}}function yc(r,e,t){let n=e.selection,o=Wr(e.annotations);return e.userEvent&&(o=o.concat(he.userEvent.of(e.userEvent))),{changes:e.changes instanceof ue?e.changes:ue.of(e.changes||[],t,r.facet(tm)),selection:n&&(n instanceof D?n:D.single(n.anchor,n.head)),effects:Wr(e.effects),annotations:o,scrollIntoView:!!e.scrollIntoView}}function lm(r,e,t){let n=yc(r,e.length?e[0]:{},r.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let i=1;i<e.length;i++){e[i].filter===!1&&(t=!1);let s=!!e[i].sequential;n=sm(n,yc(r,e[i],s?n.changes.newLength:r.doc.length),s)}let o=he.create(r,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return wT(t?vT(o):o)}function vT(r){let e=r.startState,t=!0;for(let o of e.facet(nm)){let i=o(r);if(i===!1){t=!1;break}Array.isArray(i)&&(t=t===!0?i:xT(t,i))}if(t!==!0){let o,i;if(t===!1)i=r.changes.invertedDesc,o=ue.empty(e.doc.length);else{let s=r.changes.filter(t);o=s.changes,i=s.filtered.mapDesc(s.changes).invertedDesc}r=he.create(e,o,r.selection&&r.selection.map(i),ie.mapEffects(r.effects,i),r.annotations,r.scrollIntoView)}let n=e.facet(rm);for(let o=n.length-1;o>=0;o--){let i=n[o](r);i instanceof he?r=i:Array.isArray(i)&&i.length==1&&i[0]instanceof he?r=i[0]:r=lm(e,Wr(i),!1)}return r}function wT(r){let e=r.startState,t=e.facet(om),n=r;for(let o=t.length-1;o>=0;o--){let i=t[o](r);i&&Object.keys(i).length&&(n=sm(n,yc(e,i,r.changes.newLength),!0))}return n==r?r:he.create(e,r.changes,r.selection,n.effects,n.annotations,n.scrollIntoView)}var ST=[];function Wr(r){return r==null?ST:Array.isArray(r)?r:[r]}var Ge=function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r}(Ge||(Ge={})),CT=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,bc;try{bc=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function TT(r){if(bc)return bc.test(r);for(let e=0;e<r.length;e++){let t=r[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||CT.test(t)))return!0}return!1}function kT(r){return e=>{if(!/\S/.test(e))return Ge.Space;if(TT(e))return Ge.Word;for(let t=0;t<r.length;t++)if(e.indexOf(r[t])>-1)return Ge.Word;return Ge.Other}}var Z=class{constructor(e,t,n,o,i,s){this.config=e,this.doc=t,this.selection=n,this.values=o,this.status=e.statusTemplate.slice(),this.computeSlot=i,s&&(s._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Xo(this,l<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return Xo(this,n),Os(this,n)}update(...e){return lm(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:o}=t;for(let s of e.effects)s.is($r.reconfigure)?(t&&(o=new Map,t.compartments.forEach((l,a)=>o.set(a,l)),t=null),o.set(s.value.compartment,s.value.extension)):s.is(ie.reconfigure)?(t=null,n=s.value):s.is(ie.appendConfig)&&(t=null,n=Wr(n).concat(s.value));let i;t?i=e.startState.values.slice():(t=Ur.resolve(n,o,this),i=new Z(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,a)=>a.reconfigure(l,this),null).values),new Z(t,e.newDoc,e.newSelection,i,(s,l)=>l.update(s,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:D.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),o=this.changes(n.changes),i=[n.range],s=Wr(n.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),c=this.changes(a.changes),u=c.map(o);for(let f=0;f<l;f++)i[f]=i[f].map(u);let h=o.mapDesc(c,!0);i.push(a.range.map(h)),o=o.compose(u),s=ie.mapEffects(s,u).concat(ie.mapEffects(Wr(a.effects),h))}return{changes:o,selection:D.create(i,t.mainIndex),effects:s}}changes(e=[]){return e instanceof ue?e:ue.of(e,this.doc.length,this.facet(Z.lineSeparator))}toText(e){return Y.of(e.split(this.facet(Z.lineSeparator)||fc))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Xo(this,t),Os(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let o=e[n];o instanceof qe&&this.config.address[o.id]!=null&&(t[n]=o.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let o=[];if(n){for(let i in n)if(Object.prototype.hasOwnProperty.call(e,i)){let s=n[i],l=e[i];o.push(s.init(a=>s.spec.fromJSON(l,a)))}}return Z.create({doc:e.doc,selection:D.fromJSON(e.selection),extensions:t.extensions?o.concat([t.extensions]):o})}static create(e={}){let t=Ur.resolve(e.extensions||[],new Map),n=e.doc instanceof Y?e.doc:Y.of((e.doc||"").split(t.staticFacet(Z.lineSeparator)||fc)),o=e.selection?e.selection instanceof D?e.selection:D.single(e.selection.anchor,e.selection.head):D.single(0);return Xp(o,n.length),t.staticFacet(em)||(o=o.asSingle()),new Z(t,n,o,t.dynamicSlots.map(()=>null),(i,s)=>s.create(i),null)}get tabSize(){return this.facet(Z.tabSize)}get lineBreak(){return this.facet(Z.lineSeparator)||`
21
+ `}get readOnly(){return this.facet(im)}phrase(e,...t){for(let n of this.facet(Z.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,o)=>{if(o=="$")return"$";let i=+(o||1);return!i||i>t.length?n:t[i-1]})),e}languageDataAt(e,t,n=-1){let o=[];for(let i of this.facet(Zp))for(let s of i(this,t,n))Object.prototype.hasOwnProperty.call(s,e)&&o.push(s[e]);return o}charCategorizer(e){return kT(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:o}=this.doc.lineAt(e),i=this.charCategorizer(e),s=e-n,l=e-n;for(;s>0;){let a=Ve(t,s,!1);if(i(t.slice(a,s))!=Ge.Word)break;s=a}for(;l<o;){let a=Ve(t,l);if(i(t.slice(l,a))!=Ge.Word)break;l=a}return s==l?null:D.range(s+n,l+n)}};Z.allowMultipleSelections=em;Z.tabSize=U.define({combine:r=>r.length?r[0]:4});Z.lineSeparator=tm;Z.readOnly=im;Z.phrases=U.define({compare(r,e){let t=Object.keys(r),n=Object.keys(e);return t.length==n.length&&t.every(o=>r[o]==e[o])}});Z.languageData=Zp;Z.changeFilter=nm;Z.transactionFilter=rm;Z.transactionExtender=om;$r.reconfigure=ie.define();function sr(r,e,t={}){let n={};for(let o of r)for(let i of Object.keys(o)){let s=o[i],l=n[i];if(l===void 0)n[i]=s;else if(!(l===s||s===void 0))if(Object.hasOwnProperty.call(t,i))n[i]=t[i](l,s);else throw new Error("Config merge conflict for field "+i)}for(let o in e)n[o]===void 0&&(n[o]=e[o]);return n}var Lt=class{eq(e){return this==e}range(e,t=e){return rr.create(e,t,this)}};Lt.prototype.startSide=Lt.prototype.endSide=0;Lt.prototype.point=!1;Lt.prototype.mapMode=Ne.TrackDel;var rr=class{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new rr(e,t,n)}};function xc(r,e){return r.from-e.from||r.value.startSide-e.value.startSide}var ei=class{constructor(e,t,n,o){this.from=e,this.to=t,this.value=n,this.maxPoint=o}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,o=0){let i=n?this.to:this.from;for(let s=o,l=i.length;;){if(s==l)return s;let a=s+l>>1,c=i[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==s)return c>=0?s:l;c>=0?l=a:s=a+1}}between(e,t,n,o){for(let i=this.findIndex(t,-1e9,!0),s=this.findIndex(n,1e9,!1,i);i<s;i++)if(o(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(e,t){let n=[],o=[],i=[],s=-1,l=-1;for(let a=0;a<this.value.length;a++){let c=this.value[a],u=this.from[a]+e,h=this.to[a]+e,f,d;if(u==h){let p=t.mapPos(u,c.startSide,c.mapMode);if(p==null||(f=d=p,c.startSide!=c.endSide&&(d=t.mapPos(u,c.endSide),d<f)))continue}else if(f=t.mapPos(u,c.startSide),d=t.mapPos(h,c.endSide),f>d||f==d&&c.startSide>0&&c.endSide<=0)continue;(d-f||c.endSide-c.startSide)<0||(s<0&&(s=f),c.point&&(l=Math.max(l,d-f)),n.push(c),o.push(f-s),i.push(d-s))}return{mapped:n.length?new ei(o,i,n,l):null,pos:s}}},oe=class{constructor(e,t,n,o){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=o}static create(e,t,n,o){return new oe(e,t,n,o)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:o=0,filterTo:i=this.length}=e,s=e.filter;if(t.length==0&&!s)return this;if(n&&(t=t.slice().sort(xc)),this.isEmpty)return t.length?oe.of(t):this;let l=new Vs(this,null,-1).goto(0),a=0,c=[],u=new Wt;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let h=t[a++];u.addInner(h.from,h.to,h.value)||c.push(h)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!s||o>this.chunkEnd(l.chunkIndex)||i<this.chunkPos[l.chunkIndex])&&u.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!s||o>l.to||i<l.from||s(l.from,l.to,l.value))&&(u.addInner(l.from,l.to,l.value)||c.push(rr.create(l.from,l.to,l.value))),l.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?oe.empty:this.nextLayer.update({add:c,filter:s,filterFrom:o,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],o=-1;for(let s=0;s<this.chunk.length;s++){let l=this.chunkPos[s],a=this.chunk[s],c=e.touchesRange(l,l+a.length);if(c===!1)o=Math.max(o,a.maxPoint),t.push(a),n.push(e.mapPos(l));else if(c===!0){let{mapped:u,pos:h}=a.map(l,e);u&&(o=Math.max(o,u.maxPoint),t.push(u),n.push(h))}}let i=this.nextLayer.map(e);return t.length==0?i:new oe(n,t,i||oe.empty,o)}between(e,t,n){if(!this.isEmpty){for(let o=0;o<this.chunk.length;o++){let i=this.chunkPos[o],s=this.chunk[o];if(t>=i&&e<=i+s.length&&s.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return or.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return or.from(e).goto(t)}static compare(e,t,n,o,i=-1){let s=e.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=i),l=t.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=i),a=Up(s,l,n),c=new Zn(s,a,i),u=new Zn(l,a,i);n.iterGaps((h,f,d)=>Gp(c,h,u,f,d,o)),n.empty&&n.length==0&&Gp(c,0,u,0,0,o)}static eq(e,t,n=0,o){o==null&&(o=1e9-1);let i=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),s=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(i.length!=s.length)return!1;if(!i.length)return!0;let l=Up(i,s),a=new Zn(i,l,0).goto(n),c=new Zn(s,l,0).goto(n);for(;;){if(a.to!=c.to||!vc(a.active,c.active)||a.point&&(!c.point||!a.point.eq(c.point)))return!1;if(a.to>o)return!0;a.next(),c.next()}}static spans(e,t,n,o,i=-1){let s=new Zn(e,null,i).goto(t),l=t,a=s.openStart;for(;;){let c=Math.min(s.to,n);if(s.point){let u=s.activeForPoint(s.to),h=s.pointFrom<t?u.length+1:Math.min(u.length,a);o.point(l,c,s.point,u,h,s.pointRank),a=Math.min(s.openEnd(c),u.length)}else c>l&&(o.span(l,c,s.active,a),a=s.openEnd(c));if(s.to>n)return a+(s.point&&s.to>n?1:0);l=s.to,s.next()}}static of(e,t=!1){let n=new Wt;for(let o of e instanceof rr?[e]:t?MT(e):e)n.add(o.from,o.to,o.value);return n.finish()}};oe.empty=new oe([],[],null,-1);function MT(r){if(r.length>1)for(let e=r[0],t=1;t<r.length;t++){let n=r[t];if(xc(e,n)>0)return r.slice().sort(xc);e=n}return r}oe.empty.nextLayer=oe.empty;var Wt=class{finishChunk(e){this.chunks.push(new ei(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Wt)).add(e,t,n)}addInner(e,t,n){let o=e-this.lastTo||n.startSide-this.last.endSide;if(o<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(oe.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=oe.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Up(r,e,t){let n=new Map;for(let i of r)for(let s=0;s<i.chunk.length;s++)i.chunk[s].maxPoint<=0&&n.set(i.chunk[s],i.chunkPos[s]);let o=new Set;for(let i of e)for(let s=0;s<i.chunk.length;s++){let l=n.get(i.chunk[s]);l!=null&&(t?t.mapPos(l):l)==i.chunkPos[s]&&!(t!=null&&t.touchesRange(l,l+i.chunk[s].length))&&o.add(i.chunk[s])}return o}var Vs=class{constructor(e,t,n,o=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=o}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let o=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(o)||this.layer.chunkEnd(this.chunkIndex)<e||o.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let o=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<o)&&this.setRangeIndex(o)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},or=class{constructor(e){this.heap=e}static from(e,t=null,n=-1){let o=[];for(let i=0;i<e.length;i++)for(let s=e[i];!s.isEmpty;s=s.nextLayer)s.maxPoint>=n&&o.push(new Vs(s,t,n,i));return o.length==1?o[0]:new or(o)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)uc(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)uc(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),uc(this.heap,0)}}};function uc(r,e){for(let t=r[e];;){let n=(e<<1)+1;if(n>=r.length)break;let o=r[n];if(n+1<r.length&&o.compare(r[n+1])>=0&&(o=r[n+1],n++),t.compare(o)<0)break;r[n]=t,r[e]=o,e=n}}var Zn=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=or.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Rs(this.active,e),Rs(this.activeTo,e),Rs(this.activeRank,e),this.minActive=qp(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:o,rank:i}=this.cursor;for(;t<this.activeRank.length&&this.activeRank[t]<=i;)t++;Is(this.active,t,n),Is(this.activeTo,t,o),Is(this.activeRank,t,i),e&&Is(e,t,this.cursor.from),this.minActive=qp(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let o=this.minActive;if(o>-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>e){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),n&&Rs(n,o)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let i=this.cursor.value;if(!i.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=i,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=i.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let o=n.length-1;o>=0&&n[o]<e;o--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function Gp(r,e,t,n,o,i){r.goto(e),t.goto(n);let s=n+o,l=n,a=n-e;for(;;){let c=r.to+a-t.to||r.endSide-t.endSide,u=c<0?r.to+a:t.to,h=Math.min(u,s);if(r.point||t.point?r.point&&t.point&&(r.point==t.point||r.point.eq(t.point))&&vc(r.activeForPoint(r.to),t.activeForPoint(t.to))||i.comparePoint(l,h,r.point,t.point):h>l&&!vc(r.active,t.active)&&i.compareRange(l,h,r.active,t.active),u>s)break;l=u,c<=0&&r.next(),c>=0&&t.next()}}function vc(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!=e[t]&&!r[t].eq(e[t]))return!1;return!0}function Rs(r,e){for(let t=e,n=r.length-1;t<n;t++)r[t]=r[t+1];r.pop()}function Is(r,e,t){for(let n=r.length-1;n>=e;n--)r[n+1]=r[n];r[e]=t}function qp(r,e){let t=-1,n=1e9;for(let o=0;o<e.length;o++)(e[o]-n||r[o].endSide-r[t].endSide)<0&&(t=o,n=e[o]);return t}function lr(r,e,t=r.length){let n=0;for(let o=0;o<t;)r.charCodeAt(o)==9?(n+=e-n%e,o++):(n++,o=Ve(r,o));return n}function am(r,e,t,n){for(let o=0,i=0;;){if(i>=e)return o;if(o==r.length)break;i+=r.charCodeAt(o)==9?t-i%t:1,o=Ve(r,o)}return n===!0?-1:r.length}var Cc="\u037C",cm=typeof Symbol>"u"?"__"+Cc:Symbol.for(Cc),Tc=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),um=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},pt=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function o(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function i(s,l,a,c){let u=[],h=/^@(\w+)\b/.exec(s[0]),f=h&&h[1]=="keyframes";if(h&&l==null)return a.push(s[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))i(d.split(/,\s*/).map(m=>s.map(y=>m.replace(/&/,y))).reduce((m,y)=>m.concat(y)),p,a);else if(p&&typeof p=="object"){if(!h)throw new RangeError("The value of a property ("+d+") should be a primitive value.");i(o(d),p,u,f)}else p!=null&&u.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(u.length||f)&&a.push((n&&!h&&!c?s.map(n):s).join(", ")+" {"+u.join(" ")+"}")}for(let s in e)i(o(s),e[s],this.rules)}getRules(){return this.rules.join(`
22
+ `)}static newName(){let e=um[cm]||1;return um[cm]=e+1,Cc+e.toString(36)}static mount(e,t){(e[Tc]||new kc(e)).mount(Array.isArray(t)?t:[t])}},hm=new Map,kc=class{constructor(e){let t=e.ownerDocument||e,n=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let o=hm.get(t);if(o)return e.adoptedStyleSheets=[o.sheet,...e.adoptedStyleSheets],e[Tc]=o;this.sheet=new n.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],hm.set(t,this)}else{this.styleTag=t.createElement("style");let o=e.head||e;o.insertBefore(this.styleTag,o.firstChild)}this.modules=[],e[Tc]=this}mount(e){let t=this.sheet,n=0,o=0;for(let i=0;i<e.length;i++){let s=e[i],l=this.modules.indexOf(s);if(l<o&&l>-1&&(this.modules.splice(l,1),o--,l=-1),l==-1){if(this.modules.splice(o++,0,s),t)for(let a=0;a<s.rules.length;a++)t.insertRule(s.rules[a],n++)}else{for(;o<l;)n+=this.modules[o++].rules.length;n+=s.rules.length,o++}}if(!t){let i="";for(let s=0;s<this.modules.length;s++)i+=this.modules[s].getRules()+`
23
+ `;this.styleTag.textContent=i}}};var rn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Gr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ET=typeof navigator<"u"&&/Mac/.test(navigator.platform),RT=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(be=0;be<10;be++)rn[48+be]=rn[96+be]=String(be);var be;for(be=1;be<=24;be++)rn[be+111]="F"+be;var be;for(be=65;be<=90;be++)rn[be]=String.fromCharCode(be+32),Gr[be]=String.fromCharCode(be);var be;for(Fs in rn)Gr.hasOwnProperty(Fs)||(Gr[Fs]=rn[Fs]);var Fs;function fm(r){var e=ET&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||RT&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Gr:rn)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Qs(r){let e;return r.nodeType==11?e=r.getSelection?r:r.ownerDocument:e=r,e.getSelection()}function Dc(r,e){return e?r==e||r.contains(e.nodeType!=1?e.parentNode:e):!1}function IT(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Gs(r,e){if(!e.anchorNode)return!1;try{return Dc(r,e.anchorNode)}catch{return!1}}function si(r){return r.nodeType==3?cr(r,0,r.nodeValue.length).getClientRects():r.nodeType==1?r.getClientRects():[]}function Ys(r,e,t,n){return t?dm(r,e,t,n,-1)||dm(r,e,t,n,1):!1}function Xs(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e}function dm(r,e,t,n,o){for(;;){if(r==t&&e==n)return!0;if(e==(o<0?0:kn(r))){if(r.nodeName=="DIV")return!1;let i=r.parentNode;if(!i||i.nodeType!=1)return!1;e=Xs(r)+(o<0?0:1),r=i}else if(r.nodeType==1){if(r=r.childNodes[e+(o<0?-1:0)],r.nodeType==1&&r.contentEditable=="false")return!1;e=o<0?kn(r):0}else return!1}}function kn(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function hu(r,e){let t=e?r.left:r.right;return{left:t,right:t,top:r.top,bottom:r.bottom}}function PT(r){return{left:0,right:r.innerWidth,top:0,bottom:r.innerHeight}}function DT(r,e,t,n,o,i,s,l){let a=r.ownerDocument,c=a.defaultView||window;for(let u=r,h=!1;u&&!h;)if(u.nodeType==1){let f,d=u==a.body;if(d)f=PT(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(h=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let y=u.getBoundingClientRect();f={left:y.left,right:y.left+u.clientWidth,top:y.top,bottom:y.top+u.clientHeight}}let p=0,m=0;if(o=="nearest")e.top<f.top?(m=-(f.top-e.top+s),t>0&&e.bottom>f.bottom+m&&(m=e.bottom-f.bottom+m+s)):e.bottom>f.bottom&&(m=e.bottom-f.bottom+s,t<0&&e.top-m<f.top&&(m=-(f.top+m-e.top+s)));else{let y=e.bottom-e.top,g=f.bottom-f.top;m=(o=="center"&&y<=g?e.top+y/2-g/2:o=="start"||o=="center"&&t<0?e.top-s:e.bottom-g+s)-f.top}if(n=="nearest"?e.left<f.left?(p=-(f.left-e.left+i),t>0&&e.right>f.right+p&&(p=e.right-f.right+p+i)):e.right>f.right&&(p=e.right-f.right+i,t<0&&e.left<f.left+p&&(p=-(f.left+p-e.left+i))):p=(n=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:n=="start"==l?e.left-i:e.right-(f.right-f.left)+i)-f.left,p||m)if(d)c.scrollBy(p,m);else{let y=0,g=0;if(m){let v=u.scrollTop;u.scrollTop+=m,g=u.scrollTop-v}if(p){let v=u.scrollLeft;u.scrollLeft+=p,y=u.scrollLeft-v}e={left:e.left-y,top:e.top-g,right:e.right-y,bottom:e.bottom-g},y&&Math.abs(y-p)<1&&(n="nearest"),g&&Math.abs(g-m)<1&&(o="nearest")}if(d)break;u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function LT(r){let e=r.ownerDocument;for(let t=r.parentNode;t&&t!=e.body;)if(t.nodeType==1){if(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}var Lc=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?kn(t):0),n,Math.min(e.focusOffset,n?kn(n):0))}set(e,t,n,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=o}},qr=null;function qm(r){if(r.setActive)return r.setActive();if(qr)return r.focus(qr);let e=[];for(let t=r;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(r.focus(qr==null?{get preventScroll(){return qr={preventScroll:!0},!0}}:void 0),!qr){qr=!1;for(let t=0;t<e.length;){let n=e[t++],o=e[t++],i=e[t++];n.scrollTop!=o&&(n.scrollTop=o),n.scrollLeft!=i&&(n.scrollLeft=i)}}}var pm;function cr(r,e,t=e){let n=pm||(pm=document.createRange());return n.setEnd(r,t),n.setStart(r,e),n}function Jr(r,e,t){let n={key:e,code:e,keyCode:t,which:t,cancelable:!0},o=new KeyboardEvent("keydown",n);o.synthetic=!0,r.dispatchEvent(o);let i=new KeyboardEvent("keyup",n);return i.synthetic=!0,r.dispatchEvent(i),o.defaultPrevented||i.defaultPrevented}function AT(r){for(;r;){if(r&&(r.nodeType==9||r.nodeType==11&&r.host))return r;r=r.assignedSlot||r.parentNode}return null}function Km(r){for(;r.attributes.length;)r.removeAttributeNode(r.attributes[0])}function OT(r,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,kn(t));;)if(n){if(t.nodeType!=1)return!1;let o=t.childNodes[n-1];o.contentEditable=="false"?n--:(t=o,n=kn(t))}else{if(t==r)return!0;n=Xs(t),t=t.parentNode}}function jm(r){return r.scrollTop>Math.max(1,r.scrollHeight-r.clientHeight-4)}var Pe=class{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Pe(e.parentNode,Xs(e),t)}static after(e,t){return new Pe(e.parentNode,Xs(e)+1,t)}},fu=[],ne=class{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,o=null,i;for(let s of this.children){if(s.flags&7){if(!s.dom&&(i=o?o.nextSibling:n.firstChild)){let l=ne.get(i);(!l||!l.parent&&l.canReuseDOM(s))&&s.reuseDOM(i)}s.sync(e,t),s.flags&=-8}if(i=o?o.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&i!=s.dom&&(t.written=!0),s.dom.parentNode==n)for(;i&&i!=s.dom;)i=mm(i);else n.insertBefore(s.dom,i);o=s.dom}for(i=o?o.nextSibling:n.firstChild,i&&t&&t.node==n&&(t.written=!0);i;)i=mm(i)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let o=kn(e)==0?0:t==0?-1:1;for(;;){let i=e.parentNode;if(i==this.dom)break;o==0&&i.firstChild!=i.lastChild&&(e==i.firstChild?o=-1:o=1),e=i}o<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!ne.get(n);)n=n.nextSibling;if(!n)return this.length;for(let o=0,i=0;;o++){let s=this.children[o];if(s.dom==n)return i;i+=s.length+s.breakAfter}}domBoundsAround(e,t,n=0){let o=-1,i=-1,s=-1,l=-1;for(let a=0,c=n,u=n;a<this.children.length;a++){let h=this.children[a],f=c+h.length;if(c<e&&f>t)return h.domBoundsAround(e,t,c);if(f>=e&&o==-1&&(o=a,i=c),c>t&&h.dom.parentNode==this.dom){s=a,l=u;break}u=f,c=f+h.breakAfter}return{from:i,to:l<0?n+this.length:l,startDOM:(o?this.children[o-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s<this.children.length&&s>=0?this.children[s].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=fu){this.markDirty();for(let o=e;o<t;o++){let i=this.children[o];i.parent==this&&i.destroy()}this.children.splice(e,t-e,...n);for(let o=0;o<n.length;o++)n[o].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Zs(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,o,i,s){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){this.parent=null}};ne.prototype.breakAfter=0;function mm(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}var Zs=class{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}};function Jm(r,e,t,n,o,i,s,l,a){let{children:c}=r,u=c.length?c[e]:null,h=i.length?i[i.length-1]:null,f=h?h.breakAfter:s;if(!(e==n&&u&&!s&&!f&&i.length<2&&u.merge(t,o,i.length?h:null,t==0,l,a))){if(n<c.length){let d=c[n];d&&o<d.length?(e==n&&(d=d.split(o),o=0),!f&&h&&d.merge(0,o,h,!0,0,a)?i[i.length-1]=d:(o&&d.merge(0,o,null,!1,0,a),i.push(d))):d!=null&&d.breakAfter&&(h?h.breakAfter=1:s=1),n++}for(u&&(u.breakAfter=s,t>0&&(!s&&i.length&&u.merge(t,u.length,i[0],!1,l,0)?u.breakAfter=i.shift().breakAfter:(t<u.length||u.children.length&&u.children[u.children.length-1].length==0)&&u.merge(t,u.length,null,!1,l,0),e++));e<n&&i.length;)if(c[n-1].become(i[i.length-1]))n--,i.pop(),a=i.length?0:l;else if(c[e].become(i[0]))e++,i.shift(),l=i.length?0:a;else break;!i.length&&e&&n<c.length&&!c[e-1].breakAfter&&c[n].merge(0,0,c[e-1],!1,l,a)&&e--,(e<n||i.length)&&r.replaceChildren(e,n,i)}}function Qm(r,e,t,n,o,i){let s=r.childCursor(),{i:l,off:a}=s.findPos(t,1),{i:c,off:u}=s.findPos(e,-1),h=e-t;for(let f of n)h+=f.length;r.length+=h,Jm(r,c,u,l,a,n,0,o,i)}var Kr="\uFFFF",el=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(Z.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Kr}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let o=e;;){this.findPointBefore(n,o);let i=this.text.length;this.readNode(o);let s=o.nextSibling;if(s==t)break;let l=ne.get(o),a=ne.get(s);(l&&a?l.breakAfter:(l?l.breakAfter:gm(o))||gm(s)&&(o.nodeName!="BR"||o.cmIgnore)&&this.text.length>i)&&this.lineBreak(),o=s}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,o=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,s=1,l;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(l=o.exec(t))&&(i=l.index,s=l[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),s>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=s-1);n=i+s}}readNode(e){if(e.cmIgnore)return;let t=ne.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let o=n.iter();!o.next().done;)o.lineBreak?this.lineBreak():this.append(o.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+Math.min(t,n.offset))}};function gm(r){return r.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName)}var tl=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},nt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ac=typeof document<"u"?document:{documentElement:{style:{}}},Oc=/Edge\/(\d+)/.exec(nt.userAgent),Ym=/MSIE \d/.test(nt.userAgent),Nc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nt.userAgent),ll=!!(Ym||Nc||Oc),ym=!ll&&/gecko\/(\d+)/i.test(nt.userAgent),Mc=!ll&&/Chrome\/(\d+)/.exec(nt.userAgent),bm="webkitFontSmoothing"in Ac.documentElement.style,Xm=!ll&&/Apple Computer/.test(nt.vendor),xm=Xm&&(/Mobile\/\w+/.test(nt.userAgent)||nt.maxTouchPoints>2),H={mac:xm||/Mac/.test(nt.platform),windows:/Win/.test(nt.platform),linux:/Linux|X11/.test(nt.platform),ie:ll,ie_version:Ym?Ac.documentMode||6:Nc?+Nc[1]:Oc?+Oc[1]:0,gecko:ym,gecko_version:ym?+(/Firefox\/(\d+)/.exec(nt.userAgent)||[0,0])[1]:0,chrome:!!Mc,chrome_version:Mc?+Mc[1]:0,ios:xm,android:/Android\b/.test(nt.userAgent),webkit:bm,safari:Xm,webkit_version:bm?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Ac.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},NT=256,gt=class extends ne{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof gt)||this.length-(t-e)+n.length>NT||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new gt(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Pe(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return VT(this.dom,e,t)}},At=class extends ne{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let o of t)o.setParent(this)}setAttrs(e){if(Km(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,o,i,s){return n&&(!(n instanceof At&&n.mark.eq(this.mark))||e&&i<=0||t<this.length&&s<=0)?!1:(Qm(this,e,t,n?n.children:[],i-1,s-1),this.markDirty(),!0)}split(e){let t=[],n=0,o=-1,i=0;for(let l of this.children){let a=n+l.length;a>e&&t.push(n<e?l.split(e-n):l),o<0&&n>=e&&(o=i),n=a,i++}let s=this.length-e;return this.length=e,o>-1&&(this.children.length=o,this.markDirty()),new At(this.mark,t,s)}domAtPos(e){return Zm(this,e)}coordsAt(e,t){return tg(this,e,t)}};function VT(r,e,t){let n=r.nodeValue.length;e>n&&(e=n);let o=e,i=e,s=0;e==0&&t<0||e==n&&t>=0?H.chrome||H.gecko||(e?(o--,s=1):i<n&&(i++,s=-1)):t<0?o--:i<n&&i++;let l=cr(r,o,i).getClientRects();if(!l.length)return null;let a=l[(s?s<0:t>=0)?0:l.length-1];return H.safari&&!s&&a.width==0&&(a=Array.prototype.find.call(l,c=>c.width)||a),s?hu(a,s<0):a||null}var on=class extends ne{constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}static create(e,t,n){return new on(e,t,n)}split(e){let t=on.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,n,o,i,s){return n&&(!(n instanceof on)||!this.widget.compare(n.widget)||e>0&&i<=0||t<this.length&&s<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof on&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Y.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,o=this.posAtStart;return n?n.slice(o,o+this.length):Y.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Pe.before(this.dom):Pe.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let o=this.dom.getClientRects(),i=null;if(!o.length)return null;let s=this.side?this.side<0:e>0;for(let l=s?o.length-1:0;i=o[l],!(e>0?l==0:l==o.length-1||i.top<i.bottom);l+=s?-1:1);return hu(i,!s)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},Mn=class extends ne{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof Mn&&e.side==this.side}split(){return new Mn(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Pe.before(this.dom):Pe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Y.empty}get isHidden(){return!0}};gt.prototype.children=on.prototype.children=Mn.prototype.children=fu;function Zm(r,e){let t=r.dom,{children:n}=r,o=0;for(let i=0;o<n.length;o++){let s=n[o],l=i+s.length;if(!(l==i&&s.getSide()<=0)){if(e>i&&e<l&&s.dom.parentNode==t)return s.domAtPos(e-i);if(e<=i)break;i=l}}for(let i=o;i>0;i--){let s=n[i-1];if(s.dom.parentNode==t)return s.domAtPos(s.length)}for(let i=o;i<n.length;i++){let s=n[i];if(s.dom.parentNode==t)return s.domAtPos(0)}return new Pe(t,0)}function eg(r,e,t){let n,{children:o}=r;t>0&&e instanceof At&&o.length&&(n=o[o.length-1])instanceof At&&n.mark.eq(e.mark)?eg(n,e.children[0],t-1):(o.push(e),e.setParent(r)),r.length+=e.length}function tg(r,e,t){let n=null,o=-1,i=null,s=-1;function l(c,u){for(let h=0,f=0;h<c.children.length&&f<=u;h++){let d=c.children[h],p=f+d.length;p>=u&&(d.children.length?l(d,u-f):(!i||i.isHidden&&t>0)&&(p>u||f==p&&d.getSide()>0)?(i=d,s=u-f):(f<u||f==p&&d.getSide()<0&&!d.isHidden)&&(n=d,o=u-f)),f=p}}l(r,e);let a=(t<0?n:i)||n||i;return a?a.coordsAt(Math.max(0,a==n?o:s),t):FT(r)}function FT(r){let e=r.dom.lastChild;if(!e)return r.dom.getBoundingClientRect();let t=si(e);return t[t.length-1]||null}function Vc(r,e){for(let t in r)t=="class"&&e.class?e.class+=" "+r.class:t=="style"&&e.style?e.style+=";"+r.style:e[t]=r[t];return e}var vm=Object.create(null);function du(r,e,t){if(r==e)return!0;r||(r=vm),e||(e=vm);let n=Object.keys(r),o=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=o.length-(t&&o.indexOf(t)>-1?1:0))return!1;for(let i of n)if(i!=t&&(o.indexOf(i)==-1||r[i]!==e[i]))return!1;return!0}function Fc(r,e,t){let n=null;if(e)for(let o in e)t&&o in t||r.removeAttribute(n=o);if(t)for(let o in t)e&&e[o]==t[o]||r.setAttribute(n=o,t[o]);return!!n}function BT(r){let e=Object.create(null);for(let t=0;t<r.attributes.length;t++){let n=r.attributes[t];e[n.name]=n.value}return e}var ln=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}destroy(e){}},me=function(r){return r[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r}(me||(me={})),Se=class extends Lt{constructor(e,t,n,o){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=o}get heightRelevant(){return!1}static mark(e){return new ur(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Gt(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,o;if(e.isBlockGap)n=-5e8,o=4e8;else{let{start:i,end:s}=ng(e,t);n=(i?t?-3e8:-1:5e8)-1,o=(s?t?2e8:1:-6e8)+1}return new Gt(e,n,o,t,e.widget||null,!0)}static line(e){return new hr(e)}static set(e,t=!1){return oe.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Se.none=oe.empty;var ur=class extends Se{constructor(e){let{start:t,end:n}=ng(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof ur&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&du(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};ur.prototype.point=!1;var hr=class extends Se{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof hr&&this.spec.class==e.spec.class&&du(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};hr.prototype.mapMode=Ne.TrackBefore;hr.prototype.point=!0;var Gt=class extends Se{constructor(e,t,n,o,i,s){super(t,n,i,e),this.block=o,this.isReplace=s,this.mapMode=o?t<=0?Ne.TrackBefore:Ne.TrackAfter:Ne.TrackDel}get type(){return this.startSide<this.endSide?me.WidgetRange:this.startSide<=0?me.WidgetBefore:me.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Gt&&HT(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};Gt.prototype.point=!0;function ng(r,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=r;return t==null&&(t=r.inclusive),n==null&&(n=r.inclusive),{start:t!=null?t:e,end:n!=null?n:e}}function HT(r,e){return r==e||!!(r&&e&&r.compare(e))}function Bc(r,e,t,n=0){let o=t.length-1;o>=0&&t[o]+n>=r?t[o]=Math.max(t[o],e):t.push(r,e)}var Ie=class extends ne{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,o,i,s){if(n){if(!(n instanceof Ie))return!1;this.dom||n.transferDOM(this)}return o&&this.setDeco(n?n.attrs:null),Qm(this,e,t,n?n.children:[],i,s),!0}split(e){let t=new Ie;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:o}=this.childPos(e);o&&(t.append(this.children[n].split(o),0),this.children[n].merge(o,this.children[n].length,null,!1,0,0),n++);for(let i=n;i<this.children.length;i++)t.append(this.children[i],0);for(;n>0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){du(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){eg(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Vc(t,this.attrs||{})),n&&(this.attrs=Vc({class:n},this.attrs||{}))}domAtPos(e){return Zm(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Km(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Fc(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let o=this.dom.lastChild;for(;o&&ne.get(o)instanceof At;)o=o.lastChild;if(!o||!this.length||o.nodeName!="BR"&&((n=ne.get(o))===null||n===void 0?void 0:n.isEditable)==!1&&(!H.ios||!this.children.some(i=>i instanceof gt))){let i=document.createElement("BR");i.cmIgnore=!0,this.dom.appendChild(i)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof gt)||/[^ -~]/.test(n.text))return null;let o=si(n.dom);if(o.length!=1)return null;e+=o[0].width,t=o[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=tg(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:o}=this.parent.view.viewState,i=n.bottom-n.top;if(Math.abs(i-o.lineHeight)<2&&o.textHeight<i){let s=(i-o.textHeight)/2;return{top:n.top+s,bottom:n.bottom-s,left:n.left,right:n.left}}}return n}become(e){return!1}get type(){return me.Text}static find(e,t){for(let n=0,o=0;n<e.children.length;n++){let i=e.children[n],s=o+i.length;if(s>=t){if(i instanceof Ie)return i;if(s>t)break}o=s+i.breakAfter}return null}},sn=class extends ne{constructor(e,t,n){super(),this.widget=e,this.length=t,this.type=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,o,i,s){return n&&(!(n instanceof sn)||!this.widget.compare(n.widget)||e>0&&i<=0||t<this.length&&s<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?Pe.before(this.dom):Pe.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new sn(this.widget,t,this.type);return n.breakAfter=this.breakAfter,n}get children(){return fu}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Y.empty}domBoundsAround(){return null}become(e){return e instanceof sn&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.type=e.type,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},ar=class{constructor(e,t,n,o){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=o,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!e.breakAfter&&!(e instanceof sn&&e.type==me.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ie),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Bs(new Mn(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:i,lineBreak:s,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(s){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=i,this.textOff=0}let o=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Bs(new gt(this.text.slice(this.textOff,this.textOff+o)),t),n),this.atCursorPos=!0,this.textOff+=o,e-=o,n=0}}span(e,t,n,o){this.buildText(t-e,n,o),this.pos=t,this.openStart<0&&(this.openStart=o)}point(e,t,n,o,i,s){if(this.disallowBlockEffectsFor[s]&&n instanceof Gt){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(n instanceof Gt)if(n.block){let{type:a}=n;a==me.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new sn(n.widget||new nl("div"),l,a))}else{let a=on.create(n.widget||new nl("span"),l,l?0:n.startSide),c=this.atCursorPos&&!a.isEditable&&i<=o.length&&(e<t||n.startSide>0),u=!a.isEditable&&(e<t||i>o.length||n.startSide<=0),h=this.getLine();this.pendingBuffer==2&&!c&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(o),c&&(h.append(Bs(new Mn(1),o),i),i=o.length+Math.max(0,i-o.length)),h.append(Bs(a,o),i),this.atCursorPos=u,this.pendingBuffer=u?e<t||i>o.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=o.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=i)}static build(e,t,n,o,i){let s=new ar(e,t,n,i);return s.openEnd=oe.spans(o,t,n,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}};function Bs(r,e){for(let t of e)r=new At(t,[r],r.length);return r}var nl=class extends ln{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}},rg=U.define(),og=U.define(),ig=U.define(),sg=U.define(),Hc=U.define(),lg=U.define(),ag=U.define(),cg=U.define({combine:r=>r.some(e=>e)}),ug=U.define({combine:r=>r.some(e=>e)}),Qr=class{constructor(e,t="nearest",n="nearest",o=5,i=5){this.range=e,this.y=t,this.x=n,this.yMargin=o,this.xMargin=i}map(e){return e.empty?this:new Qr(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}},wm=ie.define({map:(r,e)=>r.map(e)});function Ut(r,e,t){let n=r.facet(sg);n.length?n[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var al=U.define({combine:r=>r.length?r[0]:!0}),_T=0,ti=U.define(),yt=class{constructor(e,t,n,o){this.id=e,this.create=t,this.domEventHandlers=n,this.extension=o(this)}static define(e,t){let{eventHandlers:n,provide:o,decorations:i}=t||{};return new yt(_T++,e,n,s=>{let l=[ti.of(s)];return i&&l.push(li.of(a=>{let c=a.plugin(s);return c?i(c):Se.none})),o&&l.push(o(s)),l})}static fromClass(e,t){return yt.define(n=>new e(n),t)}},oi=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Ut(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Ut(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Ut(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},hg=U.define(),pu=U.define(),li=U.define(),mu=U.define(),fg=U.define();function dg(r){let e=0,t=0,n=0,o=0;for(let i of r.state.facet(fg)){let s=i(r);s&&(s.left!=null&&(e=Math.max(e,s.left)),s.right!=null&&(t=Math.max(t,s.right)),s.top!=null&&(n=Math.max(n,s.top)),s.bottom!=null&&(o=Math.max(o,s.bottom)))}return{left:e,right:t,top:n,bottom:o}}var ni=U.define(),Xe=class{constructor(e,t,n,o){this.fromA=e,this.toA=t,this.fromB=n,this.toB=o}join(e){return new Xe(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let o=e[t-1];if(!(o.fromA>n.toA)){if(o.toA<n.fromA)break;n=n.join(o),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let o=0,i=0,s=0,l=0;;o++){let a=o==e.length?null:e[o],c=s-l,u=a?a.fromB:1e9;for(;i<t.length&&t[i]<u;){let h=t[i],f=t[i+1],d=Math.max(l,h),p=Math.min(u,f);if(d<=p&&new Xe(d+c,p+c,d,p).addToSet(n),f>u)break;i+=2}if(!a)return n;new Xe(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),s=a.toA,l=a.toB}}},Yr=class{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=ue.empty(this.startState.doc.length);for(let i of n)this.changes=this.changes.compose(i.changes);let o=[];this.changes.iterChangedRanges((i,s,l,a)=>o.push(new Xe(i,s,l,a))),this.changedRanges=o}static create(e,t,n){return new Yr(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},pe=function(r){return r[r.LTR=0]="LTR",r[r.RTL=1]="RTL",r}(pe||(pe={})),_c=pe.LTR,zT=pe.RTL;function pg(r){let e=[];for(let t=0;t<r.length;t++)e.push(1<<+r[t]);return e}var WT=pg("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),$T=pg("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),zc=Object.create(null),$t=[];for(let r of["()","[]","{}"]){let e=r.charCodeAt(0),t=r.charCodeAt(1);zc[e]=t,zc[t]=-e}function UT(r){return r<=247?WT[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?$T[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:r==8204?256:1}var GT=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Tn=class{constructor(e,t,n){this.from=e,this.to=t,this.level=n}get dir(){return this.level%2?zT:_c}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,n,o){let i=-1;for(let s=0;s<e.length;s++){let l=e[s];if(l.from<=t&&l.to>=t){if(l.level==n)return s;(i<0||(o!=0?o<0?l.from<t:l.to>t:e[i].level>l.level))&&(i=s)}}if(i<0)throw new RangeError("Index out of range");return i}},fe=[];function qT(r,e){let t=r.length,n=e==_c?1:2,o=e==_c?2:1;if(!r||n==1&&!GT.test(r))return mg(t);for(let s=0,l=n,a=n;s<t;s++){let c=UT(r.charCodeAt(s));c==512?c=l:c==8&&a==4&&(c=16),fe[s]=c==4?2:c,c&7&&(a=c),l=c}for(let s=0,l=n,a=n;s<t;s++){let c=fe[s];if(c==128)s<t-1&&l==fe[s+1]&&l&24?c=fe[s]=l:fe[s]=256;else if(c==64){let u=s+1;for(;u<t&&fe[u]==64;)u++;let h=s&&l==8||u<t&&fe[u]==8?a==1?1:8:256;for(let f=s;f<u;f++)fe[f]=h;s=u-1}else c==8&&a==1&&(fe[s]=1);l=c,c&7&&(a=c)}for(let s=0,l=0,a=0,c,u,h;s<t;s++)if(u=zc[c=r.charCodeAt(s)])if(u<0){for(let f=l-3;f>=0;f-=3)if($t[f+1]==-u){let d=$t[f+2],p=d&2?n:d&4?d&1?o:n:0;p&&(fe[s]=fe[$t[f]]=p),l=f;break}}else{if($t.length==189)break;$t[l++]=s,$t[l++]=c,$t[l++]=a}else if((h=fe[s])==2||h==1){let f=h==n;a=f?0:1;for(let d=l-3;d>=0;d-=3){let p=$t[d+2];if(p&2)break;if(f)$t[d+2]|=2;else{if(p&4)break;$t[d+2]|=4}}}for(let s=0;s<t;s++)if(fe[s]==256){let l=s+1;for(;l<t&&fe[l]==256;)l++;let a=(s?fe[s-1]:n)==1,c=(l<t?fe[l]:n)==1,u=a==c?a?1:2:n;for(let h=s;h<l;h++)fe[h]=u;s=l-1}let i=[];if(n==1)for(let s=0;s<t;){let l=s,a=fe[s++]!=1;for(;s<t&&a==(fe[s]!=1);)s++;if(a)for(let c=s;c>l;){let u=c,h=fe[--c]!=2;for(;c>l&&h==(fe[c-1]!=2);)c--;i.push(new Tn(c,u,h?2:1))}else i.push(new Tn(l,s,0))}else for(let s=0;s<t;){let l=s,a=fe[s++]==2;for(;s<t&&a==(fe[s]==2);)s++;i.push(new Tn(l,s,a?1:2))}return i}function mg(r){return[new Tn(0,r,0)]}var gg="";function KT(r,e,t,n,o){var i;let s=n.head-r.from,l=-1;if(s==0){if(!o||!r.length)return null;e[0].level!=t&&(s=e[0].side(!1,t),l=0)}else if(s==r.length){if(o)return null;let f=e[e.length-1];f.level!=t&&(s=f.side(!0,t),l=e.length-1)}l<0&&(l=Tn.find(e,s,(i=n.bidiLevel)!==null&&i!==void 0?i:-1,n.assoc));let a=e[l];s==a.side(o,t)&&(a=e[l+=o?1:-1],s=a.side(!o,t));let c=o==(a.dir==t),u=Ve(r.text,s,c);if(gg=r.text.slice(Math.min(s,u),Math.max(s,u)),u!=a.side(o,t))return D.cursor(u+r.from,c?-1:1,a.level);let h=l==(o?e.length-1:0)?null:e[l+(o?1:-1)];return!h&&a.level!=t?D.cursor(o?r.to:r.from,o?-1:1,t):h&&h.level<a.level?D.cursor(h.side(!o,t)+r.from,o?1:-1,h.level):D.cursor(u+r.from,o?-1:1,a.level)}var rl=class extends ne{constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ie],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Xe(0,0,0,e.state.doc.length)],0,null)}get length(){return this.view.state.doc.length}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:l,toA:a})=>a<this.minWidthFrom||l>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let n=this.view.inputState.composing<0?null:JT(this.view,e.changes);if(this.hasComposition){this.markedForComposition.clear();let{from:l,to:a}=this.hasComposition;t=new Xe(l,a,e.changes.mapPos(l,-1),e.changes.mapPos(a,1)).addToSet(t.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(H.ie||H.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,i=this.updateDeco(),s=YT(o,i,e.changes);return t=Xe.extendWithRanges(t,s),!(this.flags&7)&&t.length==0?!1:(this.updateInner(t,e.startState.doc.length,n),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:o}=this.view;o.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=H.chrome||H.ios?{node:o.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,s),this.flags&=-8,s&&(s.written||o.selectionRange.focusNode!=s.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(s=>s.flags&=-9);let i=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.children)s instanceof sn&&s.widget instanceof ol&&i.push(s.dom);o.updateGaps(i)}updateChildren(e,t,n){let o=n?n.range.addToSet(e.slice()):e,i=this.childCursor(t);for(let s=o.length-1;;s--){let l=s>=0?o[s]:null;if(!l)break;let{fromA:a,toA:c,fromB:u,toB:h}=l,f,d,p,m;if(n&&n.range.fromB<h&&n.range.toB>u){let x=ar.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),S=ar.build(this.view.state.doc,n.range.toB,h,this.decorations,this.dynamicDecorationMap);d=x.breakAtStart,p=x.openStart,m=S.openEnd;let b=this.compositionView(n);S.breakAtStart?b.breakAfter=1:S.content.length&&b.merge(b.length,b.length,S.content[0],!1,S.openStart,0)&&(b.breakAfter=S.content[0].breakAfter,S.content.shift()),x.content.length&&b.merge(0,0,x.content[x.content.length-1],!0,0,x.openEnd)&&x.content.pop(),f=x.content.concat(b).concat(S.content)}else({content:f,breakAtStart:d,openStart:p,openEnd:m}=ar.build(this.view.state.doc,u,h,this.decorations,this.dynamicDecorationMap));let{i:y,off:g}=i.findPos(c,1),{i:v,off:w}=i.findPos(a,-1);Jm(this,v,w,y,g,f,d,p,m)}n&&this.fixCompositionDOM(n)}compositionView(e){let t=new gt(e.text.nodeValue);t.flags|=8;for(let{deco:o}of e.marks)t=new At(o,[t],t.length);let n=new Ie;return n.append(t,0),n}fixCompositionDOM(e){let t=(i,s)=>{s.flags|=8,this.markedForComposition.add(s);let l=ne.get(i);l!=s&&(l&&(l.dom=null),s.setDOM(i))},n=this.childPos(e.range.fromB,1),o=this.children[n.i];t(e.line,o);for(let i=e.marks.length-1;i>=-1;i--)n=o.childPos(n.off,1),o=o.children[n.i],t(i>=0?e.marks[i].node:e.text,o)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,o=n==this.dom,i=!o&&Gs(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(o||t||i))return;let s=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.domAtPos(l.anchor),c=l.empty?a:this.domAtPos(l.head);if(H.gecko&&l.empty&&!this.hasComposition&&jT(a)){let h=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(h,a.node.childNodes[a.offset]||null)),a=c=new Pe(h,0),s=!0}let u=this.view.observer.selectionRange;(s||!u.focusNode||!Ys(a.node,a.offset,u.anchorNode,u.anchorOffset)||!Ys(c.node,c.offset,u.focusNode,u.focusOffset))&&(this.view.observer.ignore(()=>{H.android&&H.chrome&&this.dom.contains(u.focusNode)&&XT(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let h=Qs(this.view.root);if(h)if(l.empty){if(H.gecko){let f=QT(a.node,a.offset);if(f&&f!=3){let d=bg(a.node,a.offset,f==1?1:-1);d&&(a=new Pe(d,f==1?0:d.nodeValue.length))}}h.collapse(a.node,a.offset),l.bidiLevel!=null&&u.cursorBidiLevel!=null&&(u.cursorBidiLevel=l.bidiLevel)}else if(h.extend){h.collapse(a.node,a.offset);try{h.extend(c.node,c.offset)}catch{}}else{let f=document.createRange();l.anchor>l.head&&([a,c]=[c,a]),f.setEnd(c.node,c.offset),f.setStart(a.node,a.offset),h.removeAllRanges(),h.addRange(f)}i&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,c)),this.impreciseAnchor=a.precise?null:new Pe(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new Pe(u.focusNode,u.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Qs(e.root),{anchorNode:o,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let s=Ie.find(this,t.head);if(!s)return;let l=s.posAtStart;if(t.head==l||t.head==l+s.length)return;let a=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!a||!c||a.bottom>c.top)return;let u=this.domAtPos(t.head+t.assoc);n.collapse(u.node,u.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(o,i)}nearest(e){for(let t=e;t;){let n=ne.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let o=this.children[t];if(n<o.length||o instanceof Ie)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){for(let n=this.length,o=this.children.length-1;;o--){let i=this.children[o],s=n-i.breakAfter-i.length;if(e>s||e==s&&i.type!=me.WidgetBefore&&i.type!=me.WidgetAfter&&(!o||t==2||this.children[o-1].breakAfter||this.children[o-1].type==me.WidgetBefore&&t>-2))return i.coordsAt(e-s,t);n=s}}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),o=this.children[t];if(!(o instanceof Ie))return null;for(;o.children.length;){let{i:l,off:a}=o.childPos(n,1);for(;;l++){if(l==o.children.length)return null;if((o=o.children[l]).length)break}n=a}if(!(o instanceof gt))return null;let i=Ve(o.text,n);if(i==n)return null;let s=cr(o.dom,n,i).getClientRects();return!s.length||s[0].top>=s[0].bottom?null:s[0]}measureVisibleLineHeights(e){let t=[],{from:n,to:o}=e,i=this.view.contentDOM.clientWidth,s=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==pe.LTR;for(let c=0,u=0;u<this.children.length;u++){let h=this.children[u],f=c+h.length;if(f>o)break;if(c>=n){let d=h.dom.getBoundingClientRect();if(t.push(d.height),s){let p=h.dom.lastChild,m=p?si(p):[];if(m.length){let y=m[m.length-1],g=a?y.right-d.left:d.right-y.left;g>l&&(l=g,this.minWidth=i,this.minWidthFrom=c,this.minWidthTo=f)}}}c=f+h.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?pe.RTL:pe.LTR}measureTextSize(){for(let i of this.children)if(i instanceof Ie){let s=i.measureTextSize();if(s)return s}let e=document.createElement("div"),t,n,o;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let i=si(e.firstChild)[0];t=e.getBoundingClientRect().height,n=i?i.width/27:7,o=i?i.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:o}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Zs(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,o=0;;o++){let i=o==t.viewports.length?null:t.viewports[o],s=i?i.from-1:this.length;if(s>n){let l=t.lineBlockAt(s).bottom-t.lineBlockAt(n).top;e.push(Se.replace({widget:new ol(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!i)break;n=i.to+1}return Se.set(e)}updateDeco(){let e=this.view.state.facet(li).map((t,n)=>(this.dynamicDecorationMap[n]=typeof t=="function")?t(this.view):t);for(let t=e.length;t<e.length+3;t++)this.dynamicDecorationMap[t]=!1;return this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),o;if(!n)return;!t.empty&&(o=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,o.left),top:Math.min(n.top,o.top),right:Math.max(n.right,o.right),bottom:Math.max(n.bottom,o.bottom)});let i=dg(this.view),s={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom};DT(this.view.scrollDOM,s,t.head<t.anchor?-1:1,e.x,e.y,e.xMargin,e.yMargin,this.view.textDirection==pe.LTR)}};function jT(r){return r.node.nodeType==1&&r.node.firstChild&&(r.offset==0||r.node.childNodes[r.offset-1].contentEditable=="false")&&(r.offset==r.node.childNodes.length||r.node.childNodes[r.offset].contentEditable=="false")}var ol=class extends ln{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}};function yg(r){let e=r.observer.selectionRange,t=e.focusNode&&bg(e.focusNode,e.focusOffset,0);if(!t)return null;let n=ne.get(t),o,i;if(n instanceof gt)o=n.posAtStart,i=o+n.length;else e:for(let s=0,l=t;;){for(let c=l.previousSibling,u;c;c=c.previousSibling){if(u=ne.get(c)){o=i=u.posAtEnd+s;break e}let h=new el([],r.state);if(h.readNode(c),h.text.indexOf(Kr)>-1)return null;s+=h.text.length}if(l=l.parentNode,!l)return null;let a=ne.get(l);if(a){o=i=a.posAtStart+s;break}}return{from:o,to:i,node:t}}function JT(r,e){let t=yg(r);if(!t)return null;let{from:n,to:o,node:i}=t,s=e.mapPos(n,-1),l=e.mapPos(o,1),a=i.nodeValue;if(/[\n\r]/.test(a))return null;if(l-s!=a.length){let f=e.mapPos(n,1),d=e.mapPos(o,-1);if(d-f==a.length)s=f,l=d;else if(r.state.doc.sliceString(l-a.length,l)==a)s=l-a.length;else if(r.state.doc.sliceString(s,s+a.length)==a)l=s+a.length;else return null}let{main:c}=r.state.selection;if(r.state.doc.sliceString(s,l)!=a||s>c.head||l<c.head)return null;let u=[],h=new Xe(n,o,s,l);for(let f=i.parentNode;;f=f.parentNode){let d=ne.get(f);if(d instanceof At)u.push({node:f,deco:d.mark});else{if(d instanceof Ie||f.nodeName=="DIV"&&f.parentNode==r.contentDOM)return{range:h,text:i,marks:u,line:f};if(f!=r.contentDOM)u.push({node:f,deco:new ur({inclusive:!0,attributes:BT(f),tagName:f.tagName.toLowerCase()})});else return null}}}function bg(r,e,t){if(t<=0)for(let n=r,o=e;;){if(n.nodeType==3)return n;if(n.nodeType==1&&o>0)n=n.childNodes[o-1],o=kn(n);else break}if(t>=0)for(let n=r,o=e;;){if(n.nodeType==3)return n;if(n.nodeType==1&&o<n.childNodes.length&&t>=0)n=n.childNodes[o],o=0;else break}return null}function QT(r,e){return r.nodeType!=1?0:(e&&r.childNodes[e-1].contentEditable=="false"?1:0)|(e<r.childNodes.length&&r.childNodes[e].contentEditable=="false"?2:0)}var Wc=class{constructor(){this.changes=[]}compareRange(e,t){Bc(e,t,this.changes)}comparePoint(e,t){Bc(e,t,this.changes)}};function YT(r,e,t){let n=new Wc;return oe.compare(r,e,t,n),n.changes}function XT(r,e){for(let t=r;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function ZT(r,e,t=1){let n=r.charCategorizer(e),o=r.doc.lineAt(e),i=e-o.from;if(o.length==0)return D.cursor(e);i==0?t=1:i==o.length&&(t=-1);let s=i,l=i;t<0?s=Ve(o.text,i,!1):l=Ve(o.text,i);let a=n(o.text.slice(s,l));for(;s>0;){let c=Ve(o.text,s,!1);if(n(o.text.slice(c,s))!=a)break;s=c}for(;l<o.length;){let c=Ve(o.text,l);if(n(o.text.slice(l,c))!=a)break;l=c}return D.range(s+o.from,l+o.from)}function ek(r,e){return e.left>r?e.left-r:Math.max(0,r-e.right)}function tk(r,e){return e.top>r?e.top-r:Math.max(0,r-e.bottom)}function Ec(r,e){return r.top<e.bottom-1&&r.bottom>e.top+1}function Sm(r,e){return e<r.top?{top:e,left:r.left,right:r.right,bottom:r.bottom}:r}function Cm(r,e){return e>r.bottom?{top:r.top,left:r.left,right:r.right,bottom:e}:r}function $c(r,e,t){let n,o,i,s,l=!1,a,c,u,h;for(let p=r.firstChild;p;p=p.nextSibling){let m=si(p);for(let y=0;y<m.length;y++){let g=m[y];o&&Ec(o,g)&&(g=Sm(Cm(g,o.bottom),o.top));let v=ek(e,g),w=tk(t,g);if(v==0&&w==0)return p.nodeType==3?Tm(p,e,t):$c(p,e,t);if(!n||s>w||s==w&&i>v){n=p,o=g,i=v,s=w;let x=w?t<g.top?-1:1:v?e<g.left?-1:1:0;l=!x||(x>0?y<m.length-1:y>0)}v==0?t>g.bottom&&(!u||u.bottom<g.bottom)?(a=p,u=g):t<g.top&&(!h||h.top>g.top)&&(c=p,h=g):u&&Ec(u,g)?u=Cm(u,g.bottom):h&&Ec(h,g)&&(h=Sm(h,g.top))}}if(u&&u.bottom>=t?(n=a,o=u):h&&h.top<=t&&(n=c,o=h),!n)return{node:r,offset:0};let f=Math.max(o.left,Math.min(o.right,e));if(n.nodeType==3)return Tm(n,f,t);if(l&&n.contentEditable!="false")return $c(n,f,t);let d=Array.prototype.indexOf.call(r.childNodes,n)+(e>=(o.left+o.right)/2?1:0);return{node:r,offset:d}}function Tm(r,e,t){let n=r.nodeValue.length,o=-1,i=1e9,s=0;for(let l=0;l<n;l++){let a=cr(r,l,l+1).getClientRects();for(let c=0;c<a.length;c++){let u=a[c];if(u.top==u.bottom)continue;s||(s=e-u.left);let h=(u.top>t?u.top-t:t-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&h<i){let f=e>=(u.left+u.right)/2,d=f;if((H.chrome||H.gecko)&&cr(r,l).getBoundingClientRect().left==u.right&&(d=!f),h<=0)return{node:r,offset:l+(d?1:0)};o=l+(d?1:0),i=h}}}return{node:r,offset:o>-1?o:s>0?r.nodeValue.length:0}}function xg(r,e,t,n=-1){var o,i;let s=r.contentDOM.getBoundingClientRect(),l=s.top+r.viewState.paddingTop,a,{docHeight:c}=r.viewState,{x:u,y:h}=e,f=h-l;if(f<0)return 0;if(f>c)return r.state.doc.length;for(let x=r.viewState.heightOracle.textHeight/2,S=!1;a=r.elementAtHeight(f),a.type!=me.Text;)for(;f=n>0?a.bottom+x:a.top-x,!(f>=0&&f<=c);){if(S)return t?null:0;S=!0,n=-n}h=l+f;let d=a.from;if(d<r.viewport.from)return r.viewport.from==0?0:t?null:km(r,s,a,u,h);if(d>r.viewport.to)return r.viewport.to==r.state.doc.length?r.state.doc.length:t?null:km(r,s,a,u,h);let p=r.dom.ownerDocument,m=r.root.elementFromPoint?r.root:p,y=m.elementFromPoint(u,h);y&&!r.contentDOM.contains(y)&&(y=null),y||(u=Math.max(s.left+1,Math.min(s.right-1,u)),y=m.elementFromPoint(u,h),y&&!r.contentDOM.contains(y)&&(y=null));let g,v=-1;if(y&&((o=r.docView.nearest(y))===null||o===void 0?void 0:o.isEditable)!=!1){if(p.caretPositionFromPoint){let x=p.caretPositionFromPoint(u,h);x&&({offsetNode:g,offset:v}=x)}else if(p.caretRangeFromPoint){let x=p.caretRangeFromPoint(u,h);x&&({startContainer:g,startOffset:v}=x,(!r.contentDOM.contains(g)||H.safari&&nk(g,v,u)||H.chrome&&rk(g,v,u))&&(g=void 0))}}if(!g||!r.docView.dom.contains(g)){let x=Ie.find(r.docView,d);if(!x)return f>a.top+a.height/2?a.to:a.from;({node:g,offset:v}=$c(x.dom,u,h))}let w=r.docView.nearest(g);if(!w)return null;if(w.isWidget&&((i=w.dom)===null||i===void 0?void 0:i.nodeType)==1){let x=w.dom.getBoundingClientRect();return e.y<x.top||e.y<=x.bottom&&e.x<=(x.left+x.right)/2?w.posAtStart:w.posAtEnd}else return w.localPosFromDOM(g,v)+w.posAtStart}function km(r,e,t,n,o){let i=Math.round((n-e.left)*r.defaultCharacterWidth);if(r.lineWrapping&&t.height>r.defaultLineHeight*1.5){let l=r.viewState.heightOracle.textHeight,a=Math.floor((o-t.top-(r.defaultLineHeight-l)*.5)/l);i+=a*r.viewState.heightOracle.lineLength}let s=r.state.sliceDoc(t.from,t.to);return t.from+am(s,i,r.state.tabSize)}function nk(r,e,t){let n;if(r.nodeType!=3||e!=(n=r.nodeValue.length))return!1;for(let o=r.nextSibling;o;o=o.nextSibling)if(o.nodeType!=1||o.nodeName!="BR")return!1;return cr(r,n-1,n).getBoundingClientRect().left>t}function rk(r,e,t){if(e!=0)return!1;for(let o=r;;){let i=o.parentNode;if(!i||i.nodeType!=1||i.firstChild!=o)return!1;if(i.classList.contains("cm-line"))break;o=i}let n=r.nodeType==1?r.getBoundingClientRect():cr(r,0,Math.max(r.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Uc(r,e){let t=r.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==me.Text))return n}return t}function ok(r,e,t,n){let o=Uc(r,e.head),i=!n||o.type!=me.Text||!(r.lineWrapping||o.widgetLineBreaks)?null:r.coordsAtPos(e.assoc<0&&e.head>o.from?e.head-1:e.head);if(i){let s=r.dom.getBoundingClientRect(),l=r.textDirectionAt(o.from),a=r.posAtCoords({x:t==(l==pe.LTR)?s.right-1:s.left+1,y:(i.top+i.bottom)/2});if(a!=null)return D.cursor(a,t?-1:1)}return D.cursor(t?o.to:o.from,t?-1:1)}function Mm(r,e,t,n){let o=r.state.doc.lineAt(e.head),i=r.bidiSpans(o),s=r.textDirectionAt(o.from);for(let l=e,a=null;;){let c=KT(o,i,s,l,t),u=gg;if(!c){if(o.number==(t?r.state.doc.lines:1))return l;u=`
24
+ `,o=r.state.doc.line(o.number+(t?1:-1)),i=r.bidiSpans(o),c=D.cursor(t?o.from:o.to)}if(a){if(!a(u))return l}else{if(!n)return c;a=n(u)}l=c}}function ik(r,e,t){let n=r.state.charCategorizer(e),o=n(t);return i=>{let s=n(i);return o==Ge.Space&&(o=s),o==s}}function sk(r,e,t,n){let o=e.head,i=t?1:-1;if(o==(t?r.state.doc.length:0))return D.cursor(o,e.assoc);let s=e.goalColumn,l,a=r.contentDOM.getBoundingClientRect(),c=r.coordsAtPos(o),u=r.documentTop;if(c)s==null&&(s=c.left-a.left),l=i<0?c.top:c.bottom;else{let d=r.viewState.lineBlockAt(o);s==null&&(s=Math.min(a.right-a.left,r.defaultCharacterWidth*(o-d.from))),l=(i<0?d.top:d.bottom)+u}let h=a.left+s,f=n!=null?n:r.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=l+(f+d)*i,m=xg(r,{x:h,y:p},!1,i);if(p<a.top||p>a.bottom||(i<0?m<o:m>o))return D.cursor(m,e.assoc,void 0,s)}}function qs(r,e,t){for(;;){let n=0;for(let o of r)o.between(e-1,e+1,(i,s,l)=>{if(e>i&&e<s){let a=n||t||(e-i<s-e?-1:1);e=a<0?i:s,n=a}});if(!n)return e}}function Rc(r,e,t){let n=qs(r.state.facet(mu).map(o=>o(r)),t.from,e.head>t.from?-1:1);return n==t.from?t:D.cursor(n,n<t.from?1:-1)}var Gc=class{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let t=(n,o)=>{this.ignoreDuringComposition(o)||o.type=="keydown"&&this.keydown(e,o)||(this.mustFlushObserver(o)&&e.observer.forceFlush(),this.runCustomHandlers(o.type,e,o)?o.preventDefault():n(e,o))};for(let n in xe){let o=xe[n];e.contentDOM.addEventListener(n,i=>{Em(e,i)&&t(o,i)},Kc[n]),this.registeredEvents.push(n)}e.scrollDOM.addEventListener("mousedown",n=>{if(n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&(t(xe.mousedown,n),!n.defaultPrevented&&n.button==2)){let o=e.contentDOM.style.minHeight;e.contentDOM.style.minHeight="100%",setTimeout(()=>e.contentDOM.style.minHeight=o,200)}}),e.scrollDOM.addEventListener("drop",n=>{n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&t(xe.drop,n)}),H.chrome&&H.chrome_version==102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,H.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var n;let o;this.customHandlers=[];for(let i of t)if(o=(n=i.update(e).spec)===null||n===void 0?void 0:n.domEventHandlers){this.customHandlers.push({plugin:i.value,handlers:o});for(let s in o)this.registeredEvents.indexOf(s)<0&&s!="scroll"&&(this.registeredEvents.push(s),e.contentDOM.addEventListener(s,l=>{Em(e,l)&&this.runCustomHandlers(s,e,l)&&l.preventDefault()}))}}runCustomHandlers(e,t,n){for(let o of this.customHandlers){let i=o.handlers[e];if(i)try{if(i.call(o.plugin,n,t)||n.defaultPrevented)return!0}catch(s){Ut(t.state,s)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let n of this.customHandlers){let o=n.handlers.scroll;if(o)try{o.call(n.plugin,t,e)}catch(i){Ut(e.state,i)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(t.keyCode!=27&&wg.indexOf(t.keyCode)<0&&(e.inputState.lastEscPress=0),H.android&&H.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return e.observer.delayAndroidKey(t.key,t.keyCode),!0;let n;return H.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((n=vg.find(o=>o.keyCode==t.keyCode))&&!t.ctrlKey||lk.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=n||t,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let t=this.pendingIOSKey;return t?(this.pendingIOSKey=void 0,Jr(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:H.safari&&!H.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}mustFlushObserver(e){return e.type=="keydown"&&e.keyCode!=229}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}},vg=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],lk="dthko",wg=[16,17,18,20,91,92,224,225],Hs=6;function _s(r){return Math.max(0,r)*.7+8}function ak(r,e){return Math.max(Math.abs(r.clientX-e.clientX),Math.abs(r.clientY-e.clientY))}var qc=class{constructor(e,t,n,o){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=o,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=LT(e.contentDOM),this.atoms=e.state.facet(mu).map(s=>s(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Z.allowMultipleSelections)&&ck(e,t),this.dragging=hk(e,t)&&kg(t)==1?null:!1}start(e){this.dragging===!1&&(e.preventDefault(),this.select(e))}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&ak(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,o=0,i=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},s=dg(this.view);e.clientX-s.left<=i.left+Hs?n=-_s(i.left-e.clientX):e.clientX+s.right>=i.right-Hs&&(n=_s(e.clientX-i.right)),e.clientY-s.top<=i.top+Hs?o=-_s(i.top-e.clientY):e.clientY+s.bottom>=i.bottom-Hs&&(o=_s(e.clientY-i.bottom)),this.setScrollSpeed(n,o)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let o=e.ranges[n],i=null;if(o.empty){let s=qs(this.atoms,o.from,0);s!=o.from&&(i=D.cursor(s,-1))}else{let s=qs(this.atoms,o.from,-1),l=qs(this.atoms,o.to,1);(s!=o.from||l!=o.to)&&(i=D.range(o.from==o.anchor?s:l,o.from==o.head?s:l))}i&&(t||(t=e.ranges.slice()),t[n]=i)}return t?D.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection)||n.main.assoc!=t.state.selection.main.assoc&&this.dragging===!1)&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.docChanged&&this.dragging&&(this.dragging=this.dragging.map(e.changes)),this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function ck(r,e){let t=r.state.facet(rg);return t.length?t[0](e):H.mac?e.metaKey:e.ctrlKey}function uk(r,e){let t=r.state.facet(og);return t.length?t[0](e):H.mac?!e.altKey:!e.ctrlKey}function hk(r,e){let{main:t}=r.state.selection;if(t.empty)return!1;let n=Qs(r.root);if(!n||n.rangeCount==0)return!0;let o=n.getRangeAt(0).getClientRects();for(let i=0;i<o.length;i++){let s=o[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function Em(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=r.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=ne.get(t))&&n.ignoreEvent(e))return!1;return!0}var xe=Object.create(null),Kc=Object.create(null),Sg=H.ie&&H.ie_version<15||H.ios&&H.webkit_version<604;function fk(r){let e=r.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{r.focus(),t.remove(),Cg(r,t.value)},50)}function Cg(r,e){let{state:t}=r,n,o=1,i=t.toText(e),s=i.lines==t.selection.ranges.length;if(jc!=null&&t.selection.ranges.every(a=>a.empty)&&jc==i.toString()){let a=-1;n=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==a)return{range:c};a=u.from;let h=t.toText((s?i.line(o++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:h},range:D.cursor(c.from+h.length)}})}else s?n=t.changeByRange(a=>{let c=i.line(o++);return{changes:{from:a.from,to:a.to,insert:c.text},range:D.cursor(a.from+c.length)}}):n=t.replaceSelection(i);r.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}xe.keydown=(r,e)=>{r.inputState.setSelectionOrigin("select"),e.keyCode==27&&(r.inputState.lastEscPress=Date.now())};xe.touchstart=(r,e)=>{r.inputState.lastTouchTime=Date.now(),r.inputState.setSelectionOrigin("select.pointer")};xe.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};Kc.touchstart=Kc.touchmove={passive:!0};xe.mousedown=(r,e)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return;let t=null;for(let n of r.state.facet(ig))if(t=n(r,e),t)break;if(!t&&e.button==0&&(t=mk(r,e)),t){let n=!r.hasFocus;r.inputState.startMouseSelection(new qc(r,e,t,n)),n&&r.observer.ignore(()=>qm(r.contentDOM)),r.inputState.mouseSelection&&r.inputState.mouseSelection.start(e)}};function Rm(r,e,t,n){if(n==1)return D.cursor(e,t);if(n==2)return ZT(r.state,e,t);{let o=Ie.find(r.docView,e),i=r.state.doc.lineAt(o?o.posAtEnd:e),s=o?o.posAtStart:i.from,l=o?o.posAtEnd:i.to;return l<r.state.doc.length&&l==i.to&&l++,D.range(s,l)}}var Tg=(r,e)=>r>=e.top&&r<=e.bottom,Im=(r,e,t)=>Tg(e,t)&&r>=t.left&&r<=t.right;function dk(r,e,t,n){let o=Ie.find(r.docView,e);if(!o)return 1;let i=e-o.posAtStart;if(i==0)return 1;if(i==o.length)return-1;let s=o.coordsAt(i,-1);if(s&&Im(t,n,s))return-1;let l=o.coordsAt(i,1);return l&&Im(t,n,l)?1:s&&Tg(n,s)?-1:1}function Pm(r,e){let t=r.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:dk(r,t,e.clientX,e.clientY)}}var pk=H.ie&&H.ie_version<=11,Dm=null,Lm=0,Am=0;function kg(r){if(!pk)return r.detail;let e=Dm,t=Am;return Dm=r,Am=Date.now(),Lm=!e||t>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(Lm+1)%3:1}function mk(r,e){let t=Pm(r,e),n=kg(e),o=r.state.selection;return{update(i){i.docChanged&&(t.pos=i.changes.mapPos(t.pos),o=o.map(i.changes))},get(i,s,l){let a=Pm(r,i),c,u=Rm(r,a.pos,a.bias,n);if(t.pos!=a.pos&&!s){let h=Rm(r,t.pos,t.bias,n),f=Math.min(h.from,u.from),d=Math.max(h.to,u.to);u=f<u.from?D.range(f,d):D.range(d,f)}return s?o.replaceRange(o.main.extend(u.from,u.to)):l&&n==1&&o.ranges.length>1&&(c=gk(o,a.pos))?c:l?o.addRange(u):D.create([u])}}}function gk(r,e){for(let t=0;t<r.ranges.length;t++){let{from:n,to:o}=r.ranges[t];if(n<=e&&o>=e)return D.create(r.ranges.slice(0,t).concat(r.ranges.slice(t+1)),r.mainIndex==t?0:r.mainIndex-(r.mainIndex>t?1:0))}return null}xe.dragstart=(r,e)=>{let{selection:{main:t}}=r.state,{mouseSelection:n}=r.inputState;n&&(n.dragging=t),e.dataTransfer&&(e.dataTransfer.setData("Text",r.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove")};function Om(r,e,t,n){if(!t)return;let o=r.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:i}=r.inputState,s=n&&i&&i.dragging&&uk(r,e)?{from:i.dragging.from,to:i.dragging.to}:null,l={from:o,insert:t},a=r.state.changes(s?[s,l]:l);r.focus(),r.dispatch({changes:a,selection:{anchor:a.mapPos(o,-1),head:a.mapPos(o,1)},userEvent:s?"move.drop":"input.drop"})}xe.drop=(r,e)=>{if(!e.dataTransfer)return;if(r.state.readOnly)return e.preventDefault();let t=e.dataTransfer.files;if(t&&t.length){e.preventDefault();let n=Array(t.length),o=0,i=()=>{++o==t.length&&Om(r,e,n.filter(s=>s!=null).join(r.state.lineBreak),!1)};for(let s=0;s<t.length;s++){let l=new FileReader;l.onerror=i,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[s]=l.result),i()},l.readAsText(t[s])}}else Om(r,e,e.dataTransfer.getData("Text"),!0)};xe.paste=(r,e)=>{if(r.state.readOnly)return e.preventDefault();r.observer.flush();let t=Sg?null:e.clipboardData;t?(Cg(r,t.getData("text/plain")||t.getData("text/uri-text")),e.preventDefault()):fk(r)};function yk(r,e){let t=r.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),r.focus()},50)}function bk(r){let e=[],t=[],n=!1;for(let o of r.selection.ranges)o.empty||(e.push(r.sliceDoc(o.from,o.to)),t.push(o));if(!e.length){let o=-1;for(let{from:i}of r.selection.ranges){let s=r.doc.lineAt(i);s.number>o&&(e.push(s.text),t.push({from:s.from,to:Math.min(r.doc.length,s.to+1)})),o=s.number}n=!0}return{text:e.join(r.lineBreak),ranges:t,linewise:n}}var jc=null;xe.copy=xe.cut=(r,e)=>{let{text:t,ranges:n,linewise:o}=bk(r.state);if(!t&&!o)return;jc=o?t:null;let i=Sg?null:e.clipboardData;i?(e.preventDefault(),i.clearData(),i.setData("text/plain",t)):yk(r,t),e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};var Mg=tt.define();function Eg(r,e){let t=[];for(let n of r.facet(ag)){let o=n(r,e);o&&t.push(o)}return t?r.update({effects:t,annotations:Mg.of(!0)}):null}function Rg(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let t=Eg(r.state,e);t?r.dispatch(t):r.update([])}},10)}xe.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),Rg(r)};xe.blur=r=>{r.observer.clearSelectionRange(),Rg(r)};xe.compositionstart=xe.compositionupdate=r=>{r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0&&(r.inputState.composing=0)};xe.compositionend=r=>{r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,H.chrome&&H.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50)};xe.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};xe.beforeinput=(r,e)=>{var t;let n;if(H.chrome&&H.android&&(n=vg.find(o=>o.inputType==e.inputType))&&(r.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let o=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var i;(((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0)>o+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}};var Nm=["pre-wrap","normal","pre-line","break-spaces"],Jc=class{constructor(e){this.lineWrapping=e,this.doc=Y.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Nm.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let o=e[n];o<0?n++:this.heightSamples[Math.floor(o*10)]||(t=!0,this.heightSamples[Math.floor(o*10)]=!0)}return t}refresh(e,t,n,o,i,s){let l=Nm.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=n,this.textHeight=o,this.lineLength=i,a){this.heightSamples={};for(let c=0;c<s.length;c++){let u=s[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return a}},Qc=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},mt=class{constructor(e,t,n,o,i){this.from=e,this.length=t,this.top=n,this.height=o,this._content=i}get type(){return typeof this._content=="number"?me.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Gt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new mt(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ae=function(r){return r[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r}(ae||(ae={})),Ks=.001,De=class{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>Ks&&(e.heightChanged=!0),this.height=t)}replace(e,t,n){return De.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,o){let i=this,s=n.doc;for(let l=o.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:u,toB:h}=o[l],f=i.lineAt(a,ae.ByPosNoHeight,n.setDoc(t),0,0),d=f.to>=c?f:i.lineAt(c,ae.ByPosNoHeight,n,0,0);for(h+=d.to-c,c=d.to;l>0&&f.from<=o[l-1].toA;)a=o[l-1].fromA,u=o[l-1].fromB,l--,a<f.from&&(f=i.lineAt(a,ae.ByPosNoHeight,n,0,0));u+=f.from-a,a=f.from;let p=ai.build(n.setDoc(s),e,u,h);i=i.replace(a,c,p)}return i.updateHeight(n,0)}static empty(){return new Ke(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,o=0,i=0;for(;;)if(t==n)if(o>i*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),n+=1+l.break,o-=l.size}else if(i>o*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,i-=l.size}else break;else if(o<i){let l=e[t++];l&&(o+=l.size)}else{let l=e[--n];l&&(i+=l.size)}let s=0;return e[t-1]==null?(s=1,t--):e[t]==null&&(s=1,n++),new Yc(De.of(e.slice(0,t)),s,De.of(e.slice(n)))}};De.prototype.size=1;var il=class extends De{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,o){return new mt(o,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,o,i){return this.blockAt(0,n,o,i)}forEachLine(e,t,n,o,i,s){e<=i+this.length&&t>=i&&s(this.blockAt(0,n,o,i))}updateHeight(e,t=0,n=!1,o){return o&&o.from<=t&&o.more&&this.setHeight(e,o.heights[o.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},Ke=class extends il{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,o){return new mt(o,this.length,n,this.height,this.breaks)}replace(e,t,n){let o=n[0];return n.length==1&&(o instanceof Ke||o instanceof we&&o.flags&4)&&Math.abs(this.length-o.length)<10?(o instanceof we?o=new Ke(o.length,this.height):o.height=this.height,this.outdated||(o.outdated=!1),o):De.of(n)}updateHeight(e,t=0,n=!1,o){return o&&o.from<=t&&o.more?this.setHeight(e,o.heights[o.index++]):(n||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},we=class extends De{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,o=e.doc.lineAt(t+this.length).number,i=o-n+1,s,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*i);s=a/i,this.length>i+1&&(l=(this.height-a)/(this.length-i-1))}else s=this.height/i;return{firstLine:n,lastLine:o,perLine:s,perChar:l}}blockAt(e,t,n,o){let{firstLine:i,lastLine:s,perLine:l,perChar:a}=this.heightMetrics(t,o);if(t.lineWrapping){let c=o+Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length),u=t.doc.lineAt(c),h=l+u.length*a,f=Math.max(n,e-h/2);return new mt(u.from,u.length,f,h,0)}else{let c=Math.max(0,Math.min(s-i,Math.floor((e-n)/l))),{from:u,length:h}=t.doc.line(i+c);return new mt(u,h,n+l*c,l,0)}}lineAt(e,t,n,o,i){if(t==ae.ByHeight)return this.blockAt(e,n,o,i);if(t==ae.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new mt(d,p-d,0,0,0)}let{firstLine:s,perLine:l,perChar:a}=this.heightMetrics(n,i),c=n.doc.lineAt(e),u=l+c.length*a,h=c.number-s,f=o+l*h+a*(c.from-i-h);return new mt(c.from,c.length,Math.max(o,Math.min(f,o+this.height-u)),u,0)}forEachLine(e,t,n,o,i,s){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(n,i);for(let u=e,h=o;u<=t;){let f=n.doc.lineAt(u);if(u==e){let p=f.number-l;h+=a*p+c*(e-i-p)}let d=a+c*f.length;s(new mt(f.from,f.length,h,d,0)),h+=d,u=f.to+1}}replace(e,t,n){let o=this.length-t;if(o>0){let i=n[n.length-1];i instanceof we?n[n.length-1]=new we(i.length+o):n.push(null,new we(o-1))}if(e>0){let i=n[0];i instanceof we?n[0]=new we(e+i.length):n.unshift(new we(e-1),null)}return De.of(n)}decomposeLeft(e,t){t.push(new we(e-1),null)}decomposeRight(e,t){t.push(null,new we(this.length-e-1))}updateHeight(e,t=0,n=!1,o){let i=t+this.length;if(o&&o.from<=t+this.length&&o.more){let s=[],l=Math.max(t,o.from),a=-1;for(o.from>t&&s.push(new we(o.from-t-1).updateHeight(e,t));l<=i&&o.more;){let u=e.doc.lineAt(l).length;s.length&&s.push(null);let h=o.heights[o.index++];a==-1?a=h:Math.abs(h-a)>=Ks&&(a=-2);let f=new Ke(u,h);f.outdated=!1,s.push(f),l+=u+1}l<=i&&s.push(null,new we(i-l).updateHeight(e,l));let c=De.of(s);return(a<0||Math.abs(c.height-this.height)>=Ks||Math.abs(a-this.heightMetrics(e,t).perLine)>=Ks)&&(e.heightChanged=!0),c}else(n||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Yc=class extends De{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,o){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,o):this.right.blockAt(e,t,i,o+this.left.length+this.break)}lineAt(e,t,n,o,i){let s=o+this.left.height,l=i+this.left.length+this.break,a=t==ae.ByHeight?e<s:e<l,c=a?this.left.lineAt(e,t,n,o,i):this.right.lineAt(e,t,n,s,l);if(this.break||(a?c.to<l:c.from>l))return c;let u=t==ae.ByPosNoHeight?ae.ByPosNoHeight:ae.ByPos;return a?c.join(this.right.lineAt(l,u,n,s,l)):this.left.lineAt(l,u,n,o,i).join(c)}forEachLine(e,t,n,o,i,s){let l=o+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,o,i,s),t>=a&&this.right.forEachLine(e,t,n,l,a,s);else{let c=this.lineAt(a,ae.ByPos,n,o,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,o,i,s),c.to>=e&&c.from<=t&&s(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,l,a,s)}}replace(e,t,n){let o=this.left.length+this.break;if(t<o)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-o,t-o,n));let i=[];e>0&&this.decomposeLeft(e,i);let s=i.length;for(let l of n)i.push(l);if(e>0&&Vm(i,s-1),t<this.length){let l=i.length;this.decomposeRight(t,i),Vm(i,l)}return De.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,o=n+this.break;if(e>=o)return this.right.decomposeRight(e-o,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<o&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?De.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,o){let{left:i,right:s}=this,l=t+i.length+this.break,a=null;return o&&o.from<=t+i.length&&o.more?a=i=i.updateHeight(e,t,n,o):i.updateHeight(e,t,n),o&&o.from<=l+s.length&&o.more?a=s=s.updateHeight(e,l,n,o):s.updateHeight(e,l,n),a?this.balanced(i,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Vm(r,e){let t,n;r[e]==null&&(t=r[e-1])instanceof we&&(n=r[e+1])instanceof we&&r.splice(e-1,3,new we(t.length+1+n.length))}var xk=5,ai=class{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),o=this.nodes[this.nodes.length-1];o instanceof Ke?o.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Ke(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let o=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;o<0&&(o=this.oracle.lineHeight);let s=t-e;n.block?this.addBlock(new il(s,o,n)):(s||i||o>=xk)&&this.addLineDeco(o,i,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Ke(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new we(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ke)return e;let t=new Ke(0,-1);return this.nodes.push(t),t}addBlock(e){var t;this.enterLine();let n=(t=e.deco)===null||t===void 0?void 0:t.type;n==me.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n!=me.WidgetBefore&&(this.covering=e)}addLineDeco(e,t,n){let o=this.ensureLine();o.length+=n,o.collapsed+=n,o.widgetHeight=Math.max(o.widgetHeight,e),o.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ke)&&!this.isCovered?this.nodes.push(new Ke(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let o of this.nodes)o instanceof Ke&&o.updateHeight(this.oracle,n),n+=o?o.length:1;return this.nodes}static build(e,t,n,o){let i=new ai(n,e);return oe.spans(t,n,o,i,0),i.finish(n)}};function vk(r,e,t){let n=new Xc;return oe.compare(r,e,t,n,0),n.changes}var Xc=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,o){(e<t||n&&n.heightRelevant||o&&o.heightRelevant)&&Bc(e,t,this.changes,5)}};function wk(r,e){let t=r.getBoundingClientRect(),n=r.ownerDocument,o=n.defaultView||window,i=Math.max(0,t.left),s=Math.min(o.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(o.innerHeight,t.bottom);for(let c=r.parentNode;c&&c!=n.body;)if(c.nodeType==1){let u=c,h=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&h.overflow!="visible"){let f=u.getBoundingClientRect();i=Math.max(i,f.left),s=Math.min(s,f.right),l=Math.max(l,f.top),a=c==r.parentNode?f.bottom:Math.min(a,f.bottom)}c=h.position=="absolute"||h.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:i-t.left,right:Math.max(i,s)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Sk(r,e){let t=r.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var ii=class{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let o=e[n],i=t[n];if(o.from!=i.from||o.to!=i.to||o.size!=i.size)return!1}return!0}draw(e){return Se.replace({widget:new Zc(this.size,e)}).range(this.from,this.to)}},Zc=class extends ln{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},sl=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!0,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Fm,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=pe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(pu).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Jc(t),this.stateDeco=e.facet(li).filter(n=>typeof n!="function"),this.heightMap=De.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle.setDoc(e.doc),[new Xe(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Se.set(this.lineGaps.map(n=>n.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let o=n?t.head:t.anchor;if(!e.some(({from:i,to:s})=>o>=i&&o<=s)){let{from:i,to:s}=this.lineBlockAt(o);e.push(new jr(i,s))}}this.viewports=e.sort((n,o)=>n.from-o.from),this.scaler=this.heightMap.height<=7e6?Fm:new eu(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:ri(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(li).filter(u=>typeof u!="function");let o=e.changedRanges,i=Xe.extendWithRanges(o,vk(n,this.stateDeco,e?e.changes:ue.empty(this.state.doc.length))),s=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),this.heightMap.height!=s&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let c=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),c&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(ug)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),o=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?pe.RTL:pe.LTR;let s=this.heightOracle.mustRefreshForWrapping(i),l=t.getBoundingClientRect(),a=s||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,u=0,h=parseInt(n.paddingTop)||0,f=parseInt(n.paddingBottom)||0;(this.paddingTop!=h||this.paddingBottom!=f)&&(this.paddingTop=h,this.paddingBottom=f,c|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=8),this.scrollTop!=e.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=e.scrollDOM.scrollTop),this.scrolledToBottom=jm(e.scrollDOM);let d=(this.printing?Sk:wk)(t,this.paddingTop),p=d.top-this.pixelViewport.top,m=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let g=l.width;if((this.contentDOMWidth!=g||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,c|=8),a){let w=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(w)&&(s=!0),s||o.lineWrapping&&Math.abs(g-this.contentDOMWidth)>o.charWidth){let{lineHeight:x,charWidth:S,textHeight:b}=e.docView.measureTextSize();s=x>0&&o.refresh(i,x,S,b,g/S,w),s&&(e.docView.minWidth=0,c|=8)}p>0&&m>0?u=Math.max(p,m):p<0&&m<0&&(u=Math.min(p,m)),o.heightChanged=!1;for(let x of this.viewports){let S=x.from==this.viewport.from?w:e.docView.measureVisibleLineHeights(x);this.heightMap=(s?De.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle,[new Xe(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,s,new Qc(x.from,S))}o.heightChanged&&(c|=2)}let v=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(c&2||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),o=this.heightMap,i=this.heightOracle,{visibleTop:s,visibleBottom:l}=this,a=new jr(o.lineAt(s-n*1e3,ae.ByHeight,i,0,0).from,o.lineAt(l+(1-n)*1e3,ae.ByHeight,i,0,0).to);if(t){let{head:c}=t.range;if(c<a.from||c>a.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=o.lineAt(c,ae.ByPos,i,0,0),f;t.y=="center"?f=(h.top+h.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c<a.from?f=h.top:f=h.bottom-u,a=new jr(o.lineAt(f-1e3/2,ae.ByHeight,i,0,0).from,o.lineAt(f+u+1e3/2,ae.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),o=t.mapPos(e.to,1);return new jr(this.heightMap.lineAt(n,ae.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(o,ae.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:o}=this.heightMap.lineAt(e,ae.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,ae.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:l}=this;return(e==0||o<=s-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=l+Math.max(10,Math.min(n,250)))&&o>s-2*1e3&&i<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let o of e)t.touchesRange(o.from,o.to)||n.push(new ii(t.mapPos(o.from),t.mapPos(o.to),o.size));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,o=n?1e4:2e3,i=o>>1,s=o<<1;if(this.defaultTextDirection!=pe.LTR&&!n)return[];let l=[],a=(c,u,h,f)=>{if(u-c<i)return;let d=this.state.selection.main,p=[d.from];d.empty||p.push(d.to);for(let y of p)if(y>c&&y<u){a(c,y-10,h,f),a(y+10,u,h,f);return}let m=Tk(e,y=>y.from>=h.from&&y.to<=h.to&&Math.abs(y.from-c)<i&&Math.abs(y.to-u)<i&&!p.some(g=>y.from<g&&y.to>g));if(!m){if(u<h.to&&t&&n&&t.visibleRanges.some(y=>y.from<=u&&y.to>=u)){let y=t.moveToLineBoundary(D.cursor(u),!1,!0).head;y>c&&(u=y)}m=new ii(c,u,this.gapSize(h,c,u,f))}l.push(m)};for(let c of this.viewportLines){if(c.length<s)continue;let u=Ck(c.from,c.to,this.stateDeco);if(u.total<s)continue;let h=this.scrollTarget?this.scrollTarget.range.head:null,f,d;if(n){let p=o/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,y;if(h!=null){let g=Ws(u,h),v=((this.visibleBottom-this.visibleTop)/2+p)/c.height;m=g-v,y=g+v}else m=(this.visibleTop-c.top-p)/c.height,y=(this.visibleBottom-c.top+p)/c.height;f=zs(u,m),d=zs(u,y)}else{let p=u.total*this.heightOracle.charWidth,m=o*this.heightOracle.charWidth,y,g;if(h!=null){let v=Ws(u,h),w=((this.pixelViewport.right-this.pixelViewport.left)/2+m)/p;y=v-w,g=v+w}else y=(this.pixelViewport.left-m)/p,g=(this.pixelViewport.right+m)/p;f=zs(u,y),d=zs(u,g)}f>c.from&&a(c.from,f,c,u),d<c.to&&a(d,c.to,c,u)}return l}gapSize(e,t,n,o){let i=Ws(o,n)-Ws(o,t);return this.heightOracle.lineWrapping?e.height*i:o.total*this.heightOracle.charWidth*i}updateLineGaps(e){ii.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Se.set(e.map(t=>t.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];oe.spans(e,this.viewport.from,this.viewport.to,{span(o,i){t.push({from:o,to:i})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((o,i)=>o.from!=t[i].from||o.to!=t[i].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ri(this.heightMap.lineAt(e,ae.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return ri(this.heightMap.lineAt(this.scaler.fromDOM(e),ae.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ri(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},jr=class{constructor(e,t){this.from=e,this.to=t}};function Ck(r,e,t){let n=[],o=r,i=0;return oe.spans(t,r,e,{span(){},point(s,l){s>o&&(n.push({from:o,to:s}),i+=s-o),o=l}},20),o<e&&(n.push({from:o,to:e}),i+=e-o),{total:i,ranges:n}}function zs({total:r,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(r*t);for(let o=0;;o++){let{from:i,to:s}=e[o],l=s-i;if(n<=l)return i+n;n-=l}}function Ws(r,e){let t=0;for(let{from:n,to:o}of r.ranges){if(e<=o){t+=e-n;break}t+=o-n}return t/r.total}function Tk(r,e){for(let t of r)if(e(t))return t}var Fm={toDOM(r){return r},fromDOM(r){return r},scale:1},eu=class{constructor(e,t,n){let o=0,i=0,s=0;this.viewports=n.map(({from:l,to:a})=>{let c=t.lineAt(l,ae.ByPos,e,0,0).top,u=t.lineAt(a,ae.ByPos,e,0,0).bottom;return o+=u-c,{from:l,to:a,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-o)/(t.height-o);for(let l of this.viewports)l.domTop=s+(l.top-i)*this.scale,s=l.domBottom=l.domTop+(l.bottom-l.top),i=l.bottom}toDOM(e){for(let t=0,n=0,o=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return o+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,o=i.domBottom}}fromDOM(e){for(let t=0,n=0,o=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-o)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,o=i.domBottom}}};function ri(r,e){if(e.scale==1)return r;let t=e.toDOM(r.top),n=e.toDOM(r.bottom);return new mt(r.from,r.length,t,n-t,Array.isArray(r._content)?r._content.map(o=>ri(o,e)):r._content)}var $s=U.define({combine:r=>r.join(" ")}),tu=U.define({combine:r=>r.indexOf(!0)>-1}),nu=pt.newName(),Ig=pt.newName(),Pg=pt.newName(),Dg={"&light":"."+Ig,"&dark":"."+Pg};function ru(r,e,t){return new pt(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,o=>{if(o=="&")return r;if(!t||!t[o])throw new RangeError(`Unsupported selector: ${o}`);return t[o]}):r+" "+n}})}var kk=ru("."+nu,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Dg),ou=class{constructor(e,t,n,o){this.typeOver=o,this.bounds=null,this.text="";let{impreciseHead:i,impreciseAnchor:s}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let l=i||s?[]:Ek(e),a=new el(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Rk(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=i&&i.node==l.focusNode&&i.offset==l.focusOffset||!Dc(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),c=s&&s.node==l.anchorNode&&s.offset==l.anchorOffset||!Dc(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=D.single(c,a)}}};function Lg(r,e){let t,{newSel:n}=e,o=r.state.selection.main,i=r.inputState.lastKeyTime>Date.now()-100?r.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:l}=e.bounds,a=o.from,c=null;(i===8||H.android&&e.text.length<l-s)&&(a=o.to,c="end");let u=Mk(r.state.doc.sliceString(s,l,Kr),e.text,a-s,c);u&&(H.chrome&&i==13&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==Kr+Kr&&u.toB--,t={from:s+u.from,to:s+u.toA,insert:Y.of(e.text.slice(u.from,u.toB).split(Kr))})}else n&&(!r.hasFocus&&r.state.facet(al)||n.main.eq(o))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!o.empty&&n&&n.main.empty?t={from:o.from,to:o.to,insert:r.state.doc.slice(o.from,o.to)}:t&&t.from>=o.from&&t.to<=o.to&&(t.from!=o.from||t.to!=o.to)&&o.to-o.from-(t.to-t.from)<=4?t={from:o.from,to:o.to,insert:r.state.doc.slice(o.from,t.from).append(t.insert).append(r.state.doc.slice(t.to,o.to))}:(H.mac||H.android)&&t&&t.from==t.to&&t.from==o.head-1&&/^\. ?$/.test(t.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=D.single(n.main.anchor-1,n.main.head-1)),t={from:o.from,to:o.to,insert:Y.of([" "])}):H.chrome&&t&&t.from==t.to&&t.from==o.head&&t.insert.toString()==`
25
+ `&&r.lineWrapping&&(n&&(n=D.single(n.main.anchor-1,n.main.head-1)),t={from:o.from,to:o.to,insert:Y.of([" "])}),t){let s=r.state;if(H.ios&&r.inputState.flushIOSKey(r)||H.android&&(t.from==o.from&&t.to==o.to&&t.insert.length==1&&t.insert.lines==2&&Jr(r.contentDOM,"Enter",13)||(t.from==o.from-1&&t.to==o.to&&t.insert.length==0||i==8&&t.insert.length<t.to-t.from)&&Jr(r.contentDOM,"Backspace",8)||t.from==o.from&&t.to==o.to+1&&t.insert.length==0&&Jr(r.contentDOM,"Delete",46)))return!0;let l=t.insert.toString();if(r.state.facet(lg).some(u=>u(r,t.from,t.to,l)))return!0;r.inputState.composing>=0&&r.inputState.composing++;let a;if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&r.inputState.composing<0){let u=o.from<t.from?s.sliceDoc(o.from,t.from):"",h=o.to>t.to?s.sliceDoc(t.to,o.to):"";a=s.replaceSelection(r.state.toText(u+t.insert.sliceString(0,void 0,r.state.lineBreak)+h))}else{let u=s.changes(t),h=n&&n.main.to<=u.newLength?n.main:void 0;if(s.selection.ranges.length>1&&r.inputState.composing>=0&&t.to<=o.to&&t.to>=o.to-10){let f=r.state.sliceDoc(t.from,t.to),d=yg(r)||r.state.doc.lineAt(o.head),p=o.to-t.to,m=o.to-o.from;a=s.changeByRange(y=>{if(y.from==o.from&&y.to==o.to)return{changes:u,range:h||y.map(u)};let g=y.to-p,v=g-f.length;if(y.to-y.from!=m||r.state.sliceDoc(v,g)!=f||d&&y.to>=d.from&&y.from<=d.to)return{range:y};let w=s.changes({from:v,to:g,insert:t.insert}),x=y.to-o.to;return{changes:w,range:h?D.range(Math.max(0,h.anchor+x),Math.max(0,h.head+x)):y.map(w)}})}else a={changes:u,selection:h&&s.selection.replaceRange(h)}}let c="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,c+=".compose",r.inputState.compositionFirstChange&&(c+=".start",r.inputState.compositionFirstChange=!1)),r.dispatch(a,{scrollIntoView:!0,userEvent:c}),!0}else if(n&&!n.main.eq(o)){let s=!1,l="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(s=!0),l=r.inputState.lastSelectionOrigin),r.dispatch({selection:n,scrollIntoView:s,userEvent:l}),!0}else return!1}function Mk(r,e,t,n){let o=Math.min(r.length,e.length),i=0;for(;i<o&&r.charCodeAt(i)==e.charCodeAt(i);)i++;if(i==o&&r.length==e.length)return null;let s=r.length,l=e.length;for(;s>0&&l>0&&r.charCodeAt(s-1)==e.charCodeAt(l-1);)s--,l--;if(n=="end"){let a=Math.max(0,i-Math.min(s,l));t-=s+a-i}if(s<i&&r.length<e.length){let a=t<=i&&t>=s?i-t:0;i-=a,l=i+(l-s),s=i}else if(l<i){let a=t<=i&&t>=l?i-t:0;i-=a,s=i+(s-l),l=i}return{from:i,toA:s,toB:l}}function Ek(r){let e=[];if(r.root.activeElement!=r.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:o,focusOffset:i}=r.observer.selectionRange;return t&&(e.push(new tl(t,n)),(o!=t||i!=n)&&e.push(new tl(o,i))),e}function Rk(r,e){if(r.length==0)return null;let t=r[0].pos,n=r.length==2?r[1].pos:t;return t>-1&&n>-1?D.single(t+e,n+e):null}var Ik={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ic=H.ie&&H.ie_version<=11,iu=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Lc,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(H.ie&&H.ie_version<=11||H.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),Ic&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM),this.resizeContent=new ResizeObserver(()=>this.view.requestMeasure()),this.resizeContent.observe(e.contentDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runScrollHandlers(this.view,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,o=this.selectionRange;if(n.state.facet(al)?n.root.activeElement!=this.dom:!Gs(n.dom,o))return;let i=o.anchorNode&&n.docView.nearest(o.anchorNode);if(i&&i.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(H.ie&&H.ie_version<=11||H.android&&H.chrome)&&!n.state.selection.main.empty&&o.focusNode&&Ys(o.focusNode,o.focusOffset,o.anchorNode,o.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=H.safari&&e.root.nodeType==11&&IT(this.dom.ownerDocument)==this.dom&&Pk(this.view)||Qs(e.root);if(!t||this.selectionRange.eq(t))return!1;let n=Gs(this.dom,t);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&OT(this.dom,t)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(t),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Ik),Ic&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ic&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let o=()=>{let i=this.delayedAndroidKey;i&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=i.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&i.force&&Jr(this.dom,i.key,i.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(o)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,o=!1;for(let i of e){let s=this.readMutation(i);s&&(s.typeOver&&(o=!0),t==-1?{from:t,to:n}=s:(t=Math.min(s.from,t),n=Math.max(s.to,n)))}return{from:t,to:n,typeOver:o}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),o=this.selectionChanged&&Gs(this.dom,this.selectionRange);return e<0&&!o?null:(e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new ou(this.view,e,t,n))}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return!1;let n=this.view.state,o=Lg(this.view,t);return this.view.state==n&&this.view.update([]),o}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=Bm(t,e.previousSibling||e.target.previousSibling,-1),o=Bm(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:o?t.posBefore(o):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,n,o;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect(),(o=this.resizeContent)===null||o===void 0||o.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}};function Bm(r,e,t){for(;e;){let n=ne.get(e);if(n&&n.parent==r)return n;let o=e.parentNode;e=o!=r.dom?o:t>0?e.nextSibling:e.previousSibling}return null}function Pk(r){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(r.contentDOM.addEventListener("beforeinput",t,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let n=e.startContainer,o=e.startOffset,i=e.endContainer,s=e.endOffset,l=r.docView.domAtPos(r.state.selection.main.anchor);return Ys(l.node,l.offset,i,s)&&([n,o,i,s]=[i,s,n,o]),{anchorNode:n,anchorOffset:o,focusNode:i,focusOffset:s}}var j=class{constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: fixed; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=e.root||AT(e.parent)||document,this.viewState=new sl(e.state||Z.create(e)),this.plugins=this.state.facet(ti).map(t=>new oi(t));for(let t of this.plugins)t.update(this);this.observer=new iu(this),this.inputState=new Gc(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new rl(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...e){let t=e.length==1&&e[0]instanceof he?e[0]:this.state.update(...e);this._dispatch(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,o,i=this.state;for(let f of e){if(f.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=f.state}if(this.destroyed){this.viewState.state=i;return}let s=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(Mg))?(this.inputState.notifiedFocused=s,l=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,a=Eg(i,s),a||(l=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(u=null)):this.observer.clear(),i.facet(Z.phrases)!=this.state.facet(Z.phrases))return this.setState(i);o=Yr.create(this,i,e),o.flags|=l;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(h&&(h=h.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection;h=new Qr(d.empty?d:D.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of f.effects)d.is(wm)&&(h=d.value)}this.viewState.update(o,h),this.bidiCache=Xr.update(this.bidiCache,o.changes),o.empty||(this.updatePlugins(o),this.inputState.update(o)),t=this.docView.update(o),this.state.facet(ni)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(o.startState.facet($s)!=o.state.facet($s)&&(this.viewState.mustMeasureContent=!0),(t||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!o.empty)for(let f of this.state.facet(Hc))f(o);(a||u)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),u&&!Lg(this,u)&&c.force&&Jr(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new sl(e),this.plugins=e.facet(ti).map(n=>new oi(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView=new rl(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(ti),n=e.state.facet(ti);if(t!=n){let o=[];for(let i of n){let s=t.indexOf(i);if(s<0)o.push(new oi(i));else{let l=this.plugins[s];l.mustUpdate=e,o.push(l)}}for(let i of this.plugins)i.mustUpdate!=e&&i.destroy(this);this.plugins=o,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let o of this.plugins)o.mustUpdate=e;for(let o=0;o<this.plugins.length;o++)this.plugins[o].update(this)}measure(e=!0){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,{scrollTop:o}=n,{scrollAnchorPos:i,scrollAnchorHeight:s}=this.viewState;o!=this.viewState.scrollTop&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(s<0)if(jm(n))i=-1,s=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(o);i=d.from,s=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(d=>{try{return d.read(this)}catch(p){return Ut(this.state,p),Hm}}),h=Yr.create(this,this.state,[]),f=!1;h.flags|=a,t?t.flags|=a:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h));for(let d=0;d<c.length;d++)if(u[d]!=Hm)try{let p=c[d];p.write&&p.write(u[d],this)}catch(p){Ut(this.state,p)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null;continue}else{let p=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-s;if(p>1||p<-1){o=n.scrollTop=o+p,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Hc))l(t)}get themeClasses(){return nu+" "+(this.state.facet(tu)?Pg:Ig)+" "+this.state.facet($s)}updateAttrs(){let e=_m(this,hg,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(al)?"true":"false",class:"cm-content",style:`${H.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),_m(this,pu,t);let n=this.observer.ignore(()=>{let o=Fc(this.contentDOM,this.contentAttrs,t),i=Fc(this.dom,this.editorAttrs,e);return o||i});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let o of n.effects)if(o.is(j.announce)){t&&(this.announceDOM.textContent=""),t=!1;let i=this.announceDOM.appendChild(document.createElement("div"));i.textContent=o.value}}mountStyles(){this.styleModules=this.state.facet(ni),pt.mount(this.root,this.styleModules.concat(kk).reverse())}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Rc(this,e,Mm(this,e,t,n))}moveByGroup(e,t){return Rc(this,e,Mm(this,e,t,n=>ik(this,e.head,n)))}moveToLineBoundary(e,t,n=!0){return ok(this,e,t,n)}moveVertically(e,t,n){return Rc(this,e,sk(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),xg(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let o=this.state.doc.lineAt(e),i=this.bidiSpans(o),s=i[Tn.find(i,e-o.from,-1,t)];return hu(n,s.dir==pe.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(cg)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Dk)return mg(e.length);let t=this.textDirectionAt(e.from);for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t)return o.order;let n=qT(e.text,t);return this.bidiCache.push(new Xr(e.from,e.to,t,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||H.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{qm(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return wm.of(new Qr(typeof e=="number"?D.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return yt.define(()=>({}),{eventHandlers:e})}static theme(e,t){let n=pt.newName(),o=[$s.of(n),ni.of(ru(`.${n}`,e))];return t&&t.dark&&o.push(tu.of(!0)),o}static baseTheme(e){return ir.lowest(ni.of(ru("."+nu,e,Dg)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),o=n&&ne.get(n)||ne.get(e);return((t=o==null?void 0:o.rootView)===null||t===void 0?void 0:t.view)||null}};j.styleModule=ni;j.inputHandler=lg;j.focusChangeEffect=ag;j.perLineTextDirection=cg;j.exceptionSink=sg;j.updateListener=Hc;j.editable=al;j.mouseSelectionStyle=ig;j.dragMovesSelection=og;j.clickAddsSelectionRange=rg;j.decorations=li;j.atomicRanges=mu;j.scrollMargins=fg;j.darkTheme=tu;j.contentAttributes=pu;j.editorAttributes=hg;j.lineWrapping=j.contentAttributes.of({class:"cm-lineWrapping"});j.announce=ie.define();var Dk=4096,Hm={},Xr=class{constructor(e,t,n,o){this.from=e,this.to=t,this.dir=n,this.order=o}static update(e,t){if(t.empty)return e;let n=[],o=e.length?e[e.length-1].dir:pe.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let s=e[i];s.dir==o&&!t.touchesRange(s.from,s.to)&&n.push(new Xr(t.mapPos(s.from,1),t.mapPos(s.to,-1),s.dir,s.order))}return n}};function _m(r,e,t){for(let n=r.state.facet(e),o=n.length-1;o>=0;o--){let i=n[o],s=typeof i=="function"?i(r):i;s&&Vc(s,t)}return t}var Lk=H.mac?"mac":H.windows?"win":H.linux?"linux":"key";function Ak(r,e){let t=r.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let o,i,s,l;for(let a=0;a<t.length-1;++a){let c=t[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))e=="mac"?l=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(n="Alt-"+n),i&&(n="Ctrl-"+n),l&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function Us(r,e,t){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t!==!1&&e.shiftKey&&(r="Shift-"+r),r}var Ok=ir.default(j.domEventHandlers({keydown(r,e){return Bk(Nk(e.state),r,e,"editor")}})),Zr=U.define({enables:Ok}),zm=new WeakMap;function Nk(r){let e=r.facet(Zr),t=zm.get(e);return t||zm.set(e,t=Fk(e.reduce((n,o)=>n.concat(o),[]))),t}var Cn=null,Vk=4e3;function Fk(r,e=Lk){let t=Object.create(null),n=Object.create(null),o=(s,l)=>{let a=n[s];if(a==null)n[s]=l;else if(a!=l)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},i=(s,l,a,c,u)=>{var h,f;let d=t[s]||(t[s]=Object.create(null)),p=l.split(/ (?!$)/).map(g=>Ak(g,e));for(let g=1;g<p.length;g++){let v=p.slice(0,g).join(" ");o(v,!0),d[v]||(d[v]={preventDefault:!0,stopPropagation:!1,run:[w=>{let x=Cn={view:w,prefix:v,scope:s};return setTimeout(()=>{Cn==x&&(Cn=null)},Vk),!0}]})}let m=p.join(" ");o(m,!1);let y=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((f=(h=d._any)===null||h===void 0?void 0:h.run)===null||f===void 0?void 0:f.slice())||[]});a&&y.run.push(a),c&&(y.preventDefault=!0),u&&(y.stopPropagation=!0)};for(let s of r){let l=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let c of l){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let h in u)u[h].run.push(s.any)}let a=s[e]||s.key;if(a)for(let c of l)i(c,a,s.run,s.preventDefault,s.stopPropagation),s.shift&&i(c,"Shift-"+a,s.shift,s.preventDefault,s.stopPropagation)}return t}function Bk(r,e,t,n){let o=fm(e),i=zt(o,0),s=tr(i)==o.length&&o!=" ",l="",a=!1,c=!1,u=!1;Cn&&Cn.view==t&&Cn.scope==n&&(l=Cn.prefix+" ",wg.indexOf(e.keyCode)<0&&(c=!0,Cn=null));let h=new Set,f=y=>{if(y){for(let g of y.run)if(!h.has(g)&&(h.add(g),g(t,e)))return y.stopPropagation&&(u=!0),!0;y.preventDefault&&(y.stopPropagation&&(u=!0),c=!0)}return!1},d=r[n],p,m;return d&&(f(d[l+Us(o,e,!s)])?a=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(H.windows&&e.ctrlKey&&e.altKey)&&(p=rn[e.keyCode])&&p!=o?(f(d[l+Us(p,e,!0)])||e.shiftKey&&(m=Gr[e.keyCode])!=o&&m!=p&&f(d[l+Us(m,e,!1)]))&&(a=!0):s&&e.shiftKey&&f(d[l+Us(o,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),c&&(a=!0),a&&u&&e.stopPropagation(),a}var fr=class{constructor(e,t,n,o,i){this.className=e,this.left=t,this.top=n,this.width=o,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let o=e.coordsAtPos(n.head,n.assoc||1);if(!o)return[];let i=Ag(e);return[new fr(t,o.left-i.left,o.top-i.top,null,o.bottom-o.top)]}else return Hk(e,t,n)}};function Ag(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==pe.LTR?e.left:e.right-r.scrollDOM.clientWidth)-r.scrollDOM.scrollLeft,top:e.top-r.scrollDOM.scrollTop}}function Wm(r,e,t){let n=D.cursor(e);return{from:Math.max(t.from,r.moveToLineBoundary(n,!1,!0).from),to:Math.min(t.to,r.moveToLineBoundary(n,!0,!0).from),type:me.Text}}function Hk(r,e,t){if(t.to<=r.viewport.from||t.from>=r.viewport.to)return[];let n=Math.max(t.from,r.viewport.from),o=Math.min(t.to,r.viewport.to),i=r.textDirection==pe.LTR,s=r.contentDOM,l=s.getBoundingClientRect(),a=Ag(r),c=s.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),h=l.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=l.right-(u?parseInt(u.paddingRight):0),d=Uc(r,n),p=Uc(r,o),m=d.type==me.Text?d:null,y=p.type==me.Text?p:null;if(m&&(r.lineWrapping||d.widgetLineBreaks)&&(m=Wm(r,n,m)),y&&(r.lineWrapping||p.widgetLineBreaks)&&(y=Wm(r,o,y)),m&&y&&m.from==y.from)return v(w(t.from,t.to,m));{let S=m?w(t.from,null,m):x(d,!1),b=y?w(null,t.to,y):x(p,!0),C=[];return(m||d).to<(y||p).from-(m&&y?1:0)||d.widgetLineBreaks>1&&S.bottom+r.defaultLineHeight/2<b.top?C.push(g(h,S.bottom,f,b.top)):S.bottom<b.top&&r.elementAtHeight((S.bottom+b.top)/2).type==me.Text&&(S.bottom=b.top=(S.bottom+b.top)/2),v(S).concat(C).concat(v(b))}function g(S,b,C,k){return new fr(e,S-a.left,b-a.top-.01,C-S,k-b+.01)}function v({top:S,bottom:b,horizontal:C}){let k=[];for(let E=0;E<C.length;E+=2)k.push(g(C[E],S,C[E+1],b));return k}function w(S,b,C){let k=1e9,E=-1e9,R=[];function M(V,B,W,O,N){let F=r.coordsAtPos(V,V==C.to?-2:2),G=r.coordsAtPos(W,W==C.from?2:-2);!F||!G||(k=Math.min(F.top,G.top,k),E=Math.max(F.bottom,G.bottom,E),N==pe.LTR?R.push(i&&B?h:F.left,i&&O?f:G.right):R.push(!i&&O?h:G.left,!i&&B?f:F.right))}let P=S!=null?S:C.from,I=b!=null?b:C.to;for(let V of r.visibleRanges)if(V.to>P&&V.from<I)for(let B=Math.max(V.from,P),W=Math.min(V.to,I);;){let O=r.state.doc.lineAt(B);for(let N of r.bidiSpans(O)){let F=N.from+O.from,G=N.to+O.from;if(F>=W)break;G>B&&M(Math.max(F,B),S==null&&F<=P,Math.min(G,W),b==null&&G>=I,N.dir)}if(B=O.to+1,B>=W)break}return R.length==0&&M(P,S==null,I,b==null,r.textDirection),{top:k,bottom:E,horizontal:R}}function x(S,b){let C=l.top+(b?S.top:S.bottom);return{top:C,bottom:C,horizontal:[]}}}function _k(r,e){return r.constructor==e.constructor&&r.eq(e)}var su=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(js)!=e.state.facet(js)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&e.view.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(js);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!_k(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let o of e)o.update&&t&&o.constructor&&this.drawn[n].constructor&&o.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(o.draw(),t);for(;t;){let o=t.nextSibling;t.remove(),t=o}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},js=U.define();function Og(r){return[yt.define(e=>new su(e,r)),js.of(r)]}var Ng=!H.ios,ci=U.define({combine(r){return sr(r,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function gu(r={}){return[ci.of(r),zk,Wk,$k,ug.of(!0)]}function Vg(r){return r.startState.facet(ci)!=r.state.facet(ci)}var zk=Og({above:!0,markers(r){let{state:e}=r,t=e.facet(ci),n=[];for(let o of e.selection.ranges){let i=o==e.selection.main;if(o.empty?!i||Ng:t.drawRangeCursor){let s=i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=o.empty?o:D.cursor(o.head,o.head>o.anchor?-1:1);for(let a of fr.forRange(r,s,l))n.push(a)}}return n},update(r,e){r.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Vg(r);return t&&$m(r.state,e),r.docChanged||r.selectionSet||t},mount(r,e){$m(e.state,r)},class:"cm-cursorLayer"});function $m(r,e){e.style.animationDuration=r.facet(ci).cursorBlinkRate+"ms"}var Wk=Og({above:!1,markers(r){return r.state.selection.ranges.map(e=>e.empty?[]:fr.forRange(r,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(r,e){return r.docChanged||r.selectionSet||r.viewportChanged||Vg(r)},class:"cm-selectionLayer"}),Fg={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Ng&&(Fg[".cm-line"].caretColor="transparent !important");var $k=ir.highest(j.theme(Fg));function Um(r,e,t,n,o){e.lastIndex=0;for(let i=r.iterRange(t,n),s=t,l;!i.next().done;s+=i.value.length)if(!i.lineBreak)for(;l=e.exec(i.value);)o(s+l.index,l)}function Uk(r,e){let t=r.visibleRanges;if(t.length==1&&t[0].from==r.viewport.from&&t[0].to==r.viewport.to)return t;let n=[];for(let{from:o,to:i}of t)o=Math.max(r.state.doc.lineAt(o).from,o-e),i=Math.min(r.state.doc.lineAt(i).to,i+e),n.length&&n[n.length-1].to>=o?n[n.length-1].to=i:n.push({from:o,to:i});return n}var lu=class{constructor(e){let{regexp:t,decoration:n,decorate:o,boundary:i,maxLength:s=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,o)this.addMatch=(l,a,c,u)=>o(u,c,c+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,c,u)=>{let h=n(l,a,c);h&&u(c,c+l[0].length,h)};else if(n)this.addMatch=(l,a,c,u)=>u(c,c+l[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=i,this.maxLength=s}createDeco(e){let t=new Wt,n=t.add.bind(t);for(let{from:o,to:i}of Uk(e,this.maxLength))Um(e.state.doc,this.regexp,o,i,(s,l)=>this.addMatch(l,e,s,n));return t.finish()}updateDeco(e,t){let n=1e9,o=-1;return e.docChanged&&e.changes.iterChanges((i,s,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(n=Math.min(l,n),o=Math.max(a,o))}),e.viewportChanged||o-n>1e3?this.createDeco(e.view):o>-1?this.updateRange(e.view,t.map(e.changes),n,o):t}updateRange(e,t,n,o){for(let i of e.visibleRanges){let s=Math.max(i.from,n),l=Math.min(i.to,o);if(l>s){let a=e.state.doc.lineAt(s),c=a.to<l?e.state.doc.lineAt(l):a,u=Math.max(i.from,a.from),h=Math.min(i.to,c.to);if(this.boundary){for(;s>a.from;s--)if(this.boundary.test(a.text[s-1-a.from])){u=s;break}for(;l<c.to;l++)if(this.boundary.test(c.text[l-c.from])){h=l;break}}let f=[],d,p=(m,y,g)=>f.push(g.range(m,y));if(a==c)for(this.regexp.lastIndex=u-a.from;(d=this.regexp.exec(a.text))&&d.index<h-a.from;)this.addMatch(d,e,d.index+a.from,p);else Um(e.state.doc,this.regexp,u,h,(m,y)=>this.addMatch(y,e,m,p));t=t.update({filterFrom:u,filterTo:h,filter:(m,y)=>m<u||y>h,add:f})}}return t}},au=/x/.unicode!=null?"gu":"g",Gk=new RegExp(`[\0-\b
26
+ -\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,au),qk={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},Pc=null;function Kk(){var r;if(Pc==null&&typeof document<"u"&&document.body){let e=document.body.style;Pc=((r=e.tabSize)!==null&&r!==void 0?r:e.MozTabSize)!=null}return Pc||!1}var Js=U.define({combine(r){let e=sr(r,{render:null,specialChars:Gk,addSpecialChars:null});return(e.replaceTabs=!Kk())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,au)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,au)),e}});function yu(r={}){return[Js.of(r),jk()]}var Gm=null;function jk(){return Gm||(Gm=yt.fromClass(class{constructor(r){this.view=r,this.decorations=Se.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(r.state.facet(Js)),this.decorations=this.decorator.createDeco(r)}makeDecorator(r){return new lu({regexp:r.specialChars,decoration:(e,t,n)=>{let{doc:o}=t.state,i=zt(e[0],0);if(i==9){let s=o.lineAt(n),l=t.state.tabSize,a=lr(s.text,l,n-s.from);return Se.replace({widget:new uu((l-a%l)*this.view.defaultCharacterWidth)})}return this.decorationCache[i]||(this.decorationCache[i]=Se.replace({widget:new cu(r,i)}))},boundary:r.replaceTabs?void 0:/[^]/})}update(r){let e=r.state.facet(Js);r.startState.facet(Js)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(r.view)):this.decorations=this.decorator.updateDeco(r,this.decorations)}},{decorations:r=>r.decorations}))}var Jk="\u2022";function Qk(r){return r>=32?Jk:r==10?"\u2424":String.fromCharCode(9216+r)}var cu=class extends ln{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Qk(this.code),n=e.state.phrase("Control character")+" "+(qk[this.code]||"0x"+this.code.toString(16)),o=this.options.render&&this.options.render(this.code,n,t);if(o)return o;let i=document.createElement("span");return i.textContent=t,i.title=n,i.setAttribute("aria-label",n),i.className="cm-specialChar",i}ignoreEvent(){return!1}},uu=class extends ln{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};var lW=j.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});var an=class extends Lt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};an.prototype.elementClass="";an.prototype.toDOM=void 0;an.prototype.mapMode=Ne.TrackBefore;an.prototype.startSide=an.prototype.endSide=-1;an.prototype.point=!0;var Yk=0,bt=class{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=Yk++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new bt([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new eo;return t=>t.modified.indexOf(e)>-1?t:eo.get(t.base||t,t.modified.concat(e).sort((n,o)=>n.id-o.id))}},Xk=0,eo=class{constructor(){this.instances=[],this.id=Xk++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&Zk(t,l.modified));if(n)return n;let o=[],i=new bt(o,e,t);for(let l of t)l.instances.push(i);let s=eM(t);for(let l of e.set)if(!l.modified.length)for(let a of s)o.push(eo.get(l,a));return i}};function Zk(r,e){return r.length==e.length&&r.every((t,n)=>t==e[n])}function eM(r){let e=[[]];for(let t=0;t<r.length;t++)for(let n=0,o=e.length;n<o;n++)e.push(e[n].concat(r[t]));return e.sort((t,n)=>n.length-t.length)}function hi(r){let e=Object.create(null);for(let t in r){let n=r[t];Array.isArray(n)||(n=[n]);for(let o of t.split(" "))if(o){let i=[],s=2,l=o;for(let h=0;;){if(l=="..."&&h>0&&h+3==o.length){s=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+o);if(i.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),h+=f[0].length,h==o.length)break;let d=o[h++];if(h==o.length&&d=="!"){s=0;break}if(d!="/")throw new RangeError("Invalid path: "+o);l=o.slice(h)}let a=i.length-1,c=i[a];if(!c)throw new RangeError("Invalid path: "+o);let u=new to(n,s,a>0?i.slice(0,a):null);e[c]=u.sort(e[c])}}return _g.add(e)}var _g=new J,to=class{constructor(e,t,n,o){this.tags=e,this.mode=t,this.context=n,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};to.empty=new to([],2,null);function wu(r,e){let t=Object.create(null);for(let i of r)if(!Array.isArray(i.tag))t[i.tag.id]=i.class;else for(let s of i.tag)t[s.id]=i.class;let{scope:n,all:o=null}=e||{};return{style:i=>{let s=o;for(let l of i)for(let a of l.set){let c=t[a.id];if(c){s=s?s+" "+c:c;break}}return s},scope:n}}function tM(r,e){let t=null;for(let n of r){let o=n.style(e);o&&(t=t?t+" "+o:o)}return t}function zg(r,e,t,n=0,o=r.length){let i=new xu(n,Array.isArray(e)?e:[e],t);i.highlightRange(r.cursor(),n,o,"",i.highlighters),i.flush(o)}var xu=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,o,i){let{type:s,from:l,to:a}=e;if(l>=n||a<=t)return;s.isTop&&(i=this.highlighters.filter(d=>!d.scope||d.scope(s)));let c=o,u=nM(e)||to.empty,h=tM(i,u.tags);if(h&&(c&&(c+=" "),c+=h,u.mode==1&&(o+=(o?" ":"")+h)),this.startSpan(Math.max(t,l),c),u.opaque)return;let f=e.tree&&e.tree.prop(J.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+l,1),p=this.highlighters.filter(y=>!y.scope||y.scope(f.tree.type)),m=e.firstChild();for(let y=0,g=l;;y++){let v=y<f.overlay.length?f.overlay[y]:null,w=v?v.from+l:a,x=Math.max(t,g),S=Math.min(n,w);if(x<S&&m)for(;e.from<S&&(this.highlightRange(e,x,S,o,i),this.startSpan(Math.min(S,e.to),c),!(e.to>=w||!e.nextSibling())););if(!v||w>n)break;g=v.to+l,g>t&&(this.highlightRange(d.cursor(),Math.max(t,v.from+l),Math.min(n,g),"",p),this.startSpan(Math.min(n,g),c))}m&&e.parent()}else if(e.firstChild()){f&&(o="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,o,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function nM(r){let e=r.type.prop(_g);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}var A=bt.define,cl=A(),En=A(),Bg=A(En),Hg=A(En),Rn=A(),ul=A(Rn),bu=A(Rn),jt=A(),dr=A(jt),qt=A(),Kt=A(),vu=A(),ui=A(vu),hl=A(),L={comment:cl,lineComment:A(cl),blockComment:A(cl),docComment:A(cl),name:En,variableName:A(En),typeName:Bg,tagName:A(Bg),propertyName:Hg,attributeName:A(Hg),className:A(En),labelName:A(En),namespace:A(En),macroName:A(En),literal:Rn,string:ul,docString:A(ul),character:A(ul),attributeValue:A(ul),number:bu,integer:A(bu),float:A(bu),bool:A(Rn),regexp:A(Rn),escape:A(Rn),color:A(Rn),url:A(Rn),keyword:qt,self:A(qt),null:A(qt),atom:A(qt),unit:A(qt),modifier:A(qt),operatorKeyword:A(qt),controlKeyword:A(qt),definitionKeyword:A(qt),moduleKeyword:A(qt),operator:Kt,derefOperator:A(Kt),arithmeticOperator:A(Kt),logicOperator:A(Kt),bitwiseOperator:A(Kt),compareOperator:A(Kt),updateOperator:A(Kt),definitionOperator:A(Kt),typeOperator:A(Kt),controlOperator:A(Kt),punctuation:vu,separator:A(vu),bracket:ui,angleBracket:A(ui),squareBracket:A(ui),paren:A(ui),brace:A(ui),content:jt,heading:dr,heading1:A(dr),heading2:A(dr),heading3:A(dr),heading4:A(dr),heading5:A(dr),heading6:A(dr),contentSeparator:A(jt),list:A(jt),quote:A(jt),emphasis:A(jt),strong:A(jt),link:A(jt),monospace:A(jt),strikethrough:A(jt),inserted:A(),deleted:A(),changed:A(),invalid:A(),meta:hl,documentMeta:A(hl),annotation:A(hl),processingInstruction:A(hl),definition:bt.defineModifier(),constant:bt.defineModifier(),function:bt.defineModifier(),standard:bt.defineModifier(),local:bt.defineModifier(),special:bt.defineModifier()},hW=wu([{tag:L.link,class:"tok-link"},{tag:L.heading,class:"tok-heading"},{tag:L.emphasis,class:"tok-emphasis"},{tag:L.strong,class:"tok-strong"},{tag:L.keyword,class:"tok-keyword"},{tag:L.atom,class:"tok-atom"},{tag:L.bool,class:"tok-bool"},{tag:L.url,class:"tok-url"},{tag:L.labelName,class:"tok-labelName"},{tag:L.inserted,class:"tok-inserted"},{tag:L.deleted,class:"tok-deleted"},{tag:L.literal,class:"tok-literal"},{tag:L.string,class:"tok-string"},{tag:L.number,class:"tok-number"},{tag:[L.regexp,L.escape,L.special(L.string)],class:"tok-string2"},{tag:L.variableName,class:"tok-variableName"},{tag:L.local(L.variableName),class:"tok-variableName tok-local"},{tag:L.definition(L.variableName),class:"tok-variableName tok-definition"},{tag:L.special(L.variableName),class:"tok-variableName2"},{tag:L.definition(L.propertyName),class:"tok-propertyName tok-definition"},{tag:L.typeName,class:"tok-typeName"},{tag:L.namespace,class:"tok-namespace"},{tag:L.className,class:"tok-className"},{tag:L.macroName,class:"tok-macroName"},{tag:L.propertyName,class:"tok-propertyName"},{tag:L.operator,class:"tok-operator"},{tag:L.comment,class:"tok-comment"},{tag:L.meta,class:"tok-meta"},{tag:L.invalid,class:"tok-invalid"},{tag:L.punctuation,class:"tok-punctuation"}]);var Su,no=new J;function rM(r){return U.define({combine:r?e=>e.concat(r):void 0})}var oM=new J,rt=class{constructor(e,t,n=[],o=""){this.data=e,this.name=o,Z.prototype.hasOwnProperty("tree")||Object.defineProperty(Z.prototype,"tree",{get(){return Fe(this)}}),this.parser=t,this.extension=[oo.of(this),Z.languageData.of((i,s,l)=>{let a=Wg(i,s,l),c=a.type.prop(no);if(!c)return[];let u=i.facet(c),h=a.type.prop(oM);if(h){let f=a.resolve(s-a.from,l);for(let d of h)if(d.test(f,i)){let p=i.facet(d.facet);return d.type=="replace"?p:p.concat(u)}}return u})].concat(n)}isActiveAt(e,t,n=-1){return Wg(e,t,n).type.prop(no)==this.data}findRegions(e){let t=e.facet(oo);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],o=(i,s)=>{if(i.prop(no)==this.data){n.push({from:s,to:s+i.length});return}let l=i.prop(J.mounted);if(l){if(l.tree.prop(no)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+s,to:a.to+s});else n.push({from:s,to:s+i.length});return}else if(l.overlay){let a=n.length;if(o(l.tree,l.overlay[0].from+s),n.length>a)return}}for(let a=0;a<i.children.length;a++){let c=i.children[a];c instanceof le&&o(c,i.positions[a]+s)}};return o(Fe(e),0),n}get allowsNesting(){return!0}};rt.setState=ie.define();function Wg(r,e,t){let n=r.facet(oo),o=Fe(r).topNode;if(!n||n.allowsNesting)for(let i=o;i;i=i.enter(e,t,ye.ExcludeBuffers))i.type.isTop&&(o=i);return o}var In=class extends rt{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=rM(e.languageData);return new In(t,e.parser.configure({props:[no.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new In(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Fe(r){let e=r.field(rt.state,!1);return e?e.tree:le.empty}var Mu=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},fi=null,ro=class{constructor(e,t,n=[],o,i,s,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=o,this.treeLen=i,this.viewport=s,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new ro(e,t,[],le.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Mu(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=le.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let o=Date.now()+e;e=()=>Date.now()>o}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let o=this.parse.advance();if(o)if(this.fragments=this.withoutTempSkipped(Ht.addTree(o,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=o,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Ht.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=fi;fi=this;try{return e()}finally{fi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=$g(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:o,treeLen:i,viewport:s,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,u,h,f)=>a.push({fromA:c,toA:u,fromB:h,toB:f})),n=Ht.applyChanges(n,a),o=le.empty,i=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),h=e.mapPos(c.to,-1);u<h&&l.push({from:u,to:h})}}}return new ro(this.parser,t,n,o,i,s,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:o,to:i}=this.skipped[n];o<e.to&&i>e.from&&(this.fragments=$g(this.fragments,o,i),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Dr{createParse(t,n,o){let i=o[0].from,s=o[o.length-1].to;return{parsedPos:i,advance(){let a=fi;if(a){for(let c of o)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=s,new le(ke.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return fi}};function $g(r,e,t){return Ht.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}var Pn=class{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Pn(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=ro.create(e.facet(oo).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Pn(n)}};rt.state=qe.define({create:Pn.init,update(r,e){for(let t of e.effects)if(t.is(rt.setState))return t.value;return e.startState.facet(oo)!=e.state.facet(oo)?Pn.init(e.state):r.apply(e)}});var qg=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(qg=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:500-100})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Cu=typeof navigator<"u"&&(!((Su=navigator.scheduling)===null||Su===void 0)&&Su.isInputPending)?()=>navigator.scheduling.isInputPending():null,iM=yt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(rt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(rt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=qg(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:o}}=this.view,i=n.field(rt.state);if(i.tree==i.context.tree&&i.context.isDone(o+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!Cu?Math.max(25,e.timeRemaining()-5):1e9),l=i.context.treeLen<o&&n.doc.length>o+1e3,a=i.context.work(()=>Cu&&Cu()||Date.now()>s,o+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:rt.setState.of(new Pn(i.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ut(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),oo=U.define({combine(r){return r.length?r[0]:null},enables:r=>[rt.state,iM,j.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]});var sM=U.define(),pi=U.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function mi(r){let e=r.facet(pi);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function gi(r,e){let t="",n=r.tabSize,o=r.facet(pi)[0];if(o==" "){for(;e>=n;)t+=" ",e-=n;o=" "}for(let i=0;i<e;i++)t+=o;return t}function Du(r,e){r instanceof Z&&(r=new pr(r));for(let n of r.state.facet(sM)){let o=n(r,e);if(o!==void 0)return o}let t=Fe(r.state);return t?aM(r,t,e):null}var pr=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=mi(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:o,simulateDoubleBreak:i}=this.options;return o!=null&&o>=n.from&&o<=n.to?i&&o==e?{text:"",from:e}:(t<0?o<e:o<=e)?{text:n.text.slice(o-n.from),from:o}:{text:n.text.slice(0,o-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:o}=this.lineAt(e,t);return n.slice(e-o,Math.min(n.length,e+100-o))}column(e,t=1){let{text:n,from:o}=this.lineAt(e,t),i=this.countColumn(n,e-o),s=this.options.overrideIndentation?this.options.overrideIndentation(o):-1;return s>-1&&(i+=s-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return lr(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:o}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let s=i(o);if(s>-1)return s}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},lM=new J;function aM(r,e,t){return Kg(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,r)}function cM(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function uM(r){let e=r.type.prop(lM);if(e)return e;let t=r.firstChild,n;if(t&&(n=t.type.prop(J.closedBy))){let o=r.lastChild,i=o&&n.indexOf(o.name)>-1;return s=>pM(s,!0,1,void 0,i&&!cM(s)?o.from:void 0)}return r.parent==null?hM:null}function Kg(r,e,t){for(;r;r=r.parent){let n=uM(r);if(n)return n(di.create(t,e,r))}return null}function hM(){return 0}var di=class extends pr{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.node=n}static create(e,t,n){return new di(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(fM(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){let e=this.node.parent;return e?Kg(e,this.pos,this.base):0}};function fM(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function dM(r){let e=r.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let o=r.options.simulateBreak,i=r.state.doc.lineAt(t.from),s=o==null||o<=i.from?i.to:Math.min(i.to,o);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped)return a.from<s?t:null;l=a.to}}function pM(r,e,t,n,o){let i=r.textAfter,s=i.match(/^\s*/)[0].length,l=n&&i.slice(s,s+n.length)==n||o==r.pos+s,a=e?dM(r):null;return a?l?r.column(a.from):r.column(a.to):r.baseIndent+(l?0:r.unit*t)}var cn=class{constructor(e,t){this.specs=e;let n;function o(l){let a=pt.newName();return(n||(n=Object.create(null)))["."+a]=l,a}let i=typeof t.all=="string"?t.all:t.all?o(t.all):void 0,s=t.scope;this.scope=s instanceof rt?l=>l.prop(no)==s.data:s?l=>l==s:void 0,this.style=wu(e.map(l=>({tag:l.tag,class:l.class||o(Object.assign({},l,{tag:null}))})),{all:i}).style,this.module=n?new pt(n):null,this.themeType=t.themeType}static define(e,t){return new cn(e,t||{})}},Eu=U.define(),jg=U.define({combine(r){return r.length?[r[0]]:null}});function Tu(r){let e=r.facet(Eu);return e.length?e:r.facet(jg)}function yi(r,e){let t=[mM],n;return r instanceof cn&&(r.module&&t.push(j.styleModule.of(r.module)),n=r.themeType),e!=null&&e.fallback?t.push(jg.of(r)):n?t.push(Eu.computeN([j.darkTheme],o=>o.facet(j.darkTheme)==(n=="dark")?[r]:[])):t.push(Eu.of(r)),t}var Ru=class{constructor(e){this.markCache=Object.create(null),this.tree=Fe(e.state),this.decorations=this.buildDeco(e,Tu(e.state))}update(e){let t=Fe(e.state),n=Tu(e.state),o=n!=Tu(e.startState);t.length<e.view.viewport.to&&!o&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||o)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n))}buildDeco(e,t){if(!t||!this.tree.length)return Se.none;let n=new Wt;for(let{from:o,to:i}of e.visibleRanges)zg(this.tree,t,(s,l,a)=>{n.add(s,l,this.markCache[a]||(this.markCache[a]=Se.mark({class:a})))},o,i);return n.finish()}},mM=ir.high(yt.fromClass(Ru,{decorations:r=>r.decorations})),Lu=cn.define([{tag:L.meta,color:"#404740"},{tag:L.link,textDecoration:"underline"},{tag:L.heading,textDecoration:"underline",fontWeight:"bold"},{tag:L.emphasis,fontStyle:"italic"},{tag:L.strong,fontWeight:"bold"},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.keyword,color:"#708"},{tag:[L.atom,L.bool,L.url,L.contentSeparator,L.labelName],color:"#219"},{tag:[L.literal,L.inserted],color:"#164"},{tag:[L.string,L.deleted],color:"#a11"},{tag:[L.regexp,L.escape,L.special(L.string)],color:"#e40"},{tag:L.definition(L.variableName),color:"#00f"},{tag:L.local(L.variableName),color:"#30a"},{tag:[L.typeName,L.namespace],color:"#085"},{tag:L.className,color:"#167"},{tag:[L.special(L.variableName),L.macroName],color:"#256"},{tag:L.definition(L.propertyName),color:"#00c"},{tag:L.comment,color:"#940"},{tag:L.invalid,color:"#f00"}]);var gM=1e4,yM="()[]{}";var bM=new J;function Iu(r,e,t){let n=r.prop(e<0?J.openedBy:J.closedBy);if(n)return n;if(r.name.length==1){let o=t.indexOf(r.name);if(o>-1&&o%2==(e<0?1:0))return[t[o+e]]}return null}function Pu(r){let e=r.type.prop(bM);return e?e(r.node):r}function mr(r,e,t,n={}){let o=n.maxScanDistance||gM,i=n.brackets||yM,s=Fe(r),l=s.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=Iu(a.type,t,i);if(c&&a.from<a.to){let u=Pu(a);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return xM(r,e,t,a,u,c,i)}}return vM(r,e,t,s,l.type,o,i)}function xM(r,e,t,n,o,i,s){let l=n.parent,a={from:o.from,to:o.to},c=0,u=l==null?void 0:l.cursor();if(u&&(t<0?u.childBefore(n.from):u.childAfter(n.to)))do if(t<0?u.to<=n.from:u.from>=n.to){if(c==0&&i.indexOf(u.type.name)>-1&&u.from<u.to){let h=Pu(u);return{start:a,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Iu(u.type,t,s))c++;else if(Iu(u.type,-t,s)){if(c==0){let h=Pu(u);return{start:a,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:a,matched:!1}}function vM(r,e,t,n,o,i,s){let l=t<0?r.sliceDoc(e-1,e):r.sliceDoc(e,e+1),a=s.indexOf(l);if(a<0||a%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=r.doc.iterRange(e,t>0?r.doc.length:0),h=0;for(let f=0;!u.next().done&&f<=i;){let d=u.value;t<0&&(f+=d.length);let p=e+f*t;for(let m=t>0?0:d.length-1,y=t>0?d.length:-1;m!=y;m+=t){let g=s.indexOf(d[m]);if(!(g<0||n.resolveInner(p+m,1).type!=o))if(g%2==0==t>0)h++;else{if(h==1)return{start:c,end:{from:p+m,to:p+m+1},matched:g>>1==a>>1};h--}}t>0&&(f+=d.length)}return u.done?{start:c,matched:!1}:null}var wM=Object.create(null),Ug=[ke.none];var Gg=[],SM=Object.create(null);for(let[r,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])SM[r]=CM(wM,e);function ku(r,e){Gg.indexOf(r)>-1||(Gg.push(r),console.warn(e))}function CM(r,e){let t=null;for(let i of e.split(".")){let s=r[i]||L[i];s?typeof s=="function"?t?t=s(t):ku(i,`Modifier ${i} used at start of tag`):t?ku(i,`Tag ${i} used as modifier`):t=s:ku(i,`Unknown highlighting tag ${i}`)}if(!t)return 0;let n=e.replace(/ /g,"_"),o=ke.define({id:Ug.length,name:n,props:[hi({[n]:t})]});return Ug.push(o),o.id}var fl={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},gr=ie.define({map(r,e){let t=e.mapPos(r,-1,Ne.TrackAfter);return t==null?void 0:t}}),Ou=new class extends Lt{};Ou.startSide=1;Ou.endSide=-1;var Yg=qe.define({create(){return oe.empty},update(r,e){if(e.selection){let t=e.state.doc.lineAt(e.selection.main.head).from,n=e.startState.doc.lineAt(e.startState.selection.main.head).from;t!=e.changes.mapPos(n,-1)&&(r=oe.empty)}r=r.map(e.changes);for(let t of e.effects)t.is(gr)&&(r=r.update({add:[Ou.range(t.value,t.value+1)]}));return r}});function Xg(){return[EM,Yg]}var Au="()[]{}<>";function TM(r){for(let e=0;e<Au.length;e+=2)if(Au.charCodeAt(e)==r)return Au.charAt(e+1);return Qp(r<128?r:r+1)}function kM(r,e){return r.languageDataAt("closeBrackets",e)[0]||fl}var MM=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),EM=j.inputHandler.of((r,e,t,n)=>{if((MM?r.composing:r.compositionStarted)||r.state.readOnly)return!1;let o=r.state.selection.main;if(n.length>2||n.length==2&&tr(zt(n,0))==1||e!=o.from||t!=o.to)return!1;let i=RM(r.state,n);return i?(r.dispatch(i),!0):!1});function RM(r,e){let t=kM(r,r.selection.main.head),n=t.brackets||fl.brackets;for(let o of n){let i=TM(zt(o,0));if(e==o)return i==o?DM(r,o,n.indexOf(o+o+o)>-1,t):IM(r,o,i,t.before||fl.before);if(e==i&&Zg(r,r.selection.main.from))return PM(r,o,i)}return null}function Zg(r,e){let t=!1;return r.field(Yg).between(0,r.doc.length,n=>{n==e&&(t=!0)}),t}function Nu(r,e){let t=r.sliceString(e,e+2);return t.slice(0,tr(zt(t,0)))}function IM(r,e,t,n){let o=null,i=r.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:t,from:s.to}],effects:gr.of(s.to+e.length),range:D.range(s.anchor+e.length,s.head+e.length)};let l=Nu(r.doc,s.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:s.head},effects:gr.of(s.head+e.length),range:D.cursor(s.head+e.length)}:{range:o=s}});return o?null:r.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function PM(r,e,t){let n=null,o=r.changeByRange(i=>i.empty&&Nu(r.doc,i.head)==t?{changes:{from:i.head,to:i.head+t.length,insert:t},range:D.cursor(i.head+t.length)}:n={range:i});return n?null:r.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function DM(r,e,t,n){let o=n.stringPrefixes||fl.stringPrefixes,i=null,s=r.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:gr.of(l.to+e.length),range:D.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=Nu(r.doc,a),u;if(c==e){if(Jg(r,a))return{changes:{insert:e+e,from:a},effects:gr.of(a+e.length),range:D.cursor(a+e.length)};if(Zg(r,a)){let f=t&&r.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+f.length,insert:f},range:D.cursor(a+f.length)}}}else{if(t&&r.sliceDoc(a-2*e.length,a)==e+e&&(u=Qg(r,a-2*e.length,o))>-1&&Jg(r,u))return{changes:{insert:e+e+e+e,from:a},effects:gr.of(a+e.length),range:D.cursor(a+e.length)};if(r.charCategorizer(a)(c)!=Ge.Word&&Qg(r,a,o)>-1&&!LM(r,a,e,o))return{changes:{insert:e+e,from:a},effects:gr.of(a+e.length),range:D.cursor(a+e.length)}}return{range:i=l}});return i?null:r.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Jg(r,e){let t=Fe(r).resolveInner(e+1);return t.parent&&t.from==e}function LM(r,e,t,n){let o=Fe(r).resolveInner(e,-1),i=n.reduce((s,l)=>Math.max(s,l.length),0);for(let s=0;s<5;s++){let l=r.sliceDoc(o.from,Math.min(o.to,o.from+t.length+i)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let u=o.firstChild;for(;u&&u.from==o.from&&u.to-u.from>t.length+a;){if(r.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}function Qg(r,e,t){let n=r.charCategorizer(e);if(n(r.sliceDoc(e-1,e))!=Ge.Word)return e;for(let o of t){let i=e-o.length;if(r.sliceDoc(i,e)==o&&n(r.sliceDoc(i-1,i))!=Ge.Word)return i}return-1}var AM=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),n=Wu(r.state,t.from);return n.line?OM(r):n.block?VM(r):!1};function zu(r,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let o=r(e,t);return o?(n(t.update(o)),!0):!1}}var OM=zu(HM,0);var NM=zu(ly,0);var VM=zu((r,e)=>ly(r,e,BM(e)),0);function Wu(r,e){let t=r.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var bi=50;function FM(r,{open:e,close:t},n,o){let i=r.sliceDoc(n-bi,n),s=r.sliceDoc(o,o+bi),l=/\s*$/.exec(i)[0].length,a=/^\s*/.exec(s)[0].length,c=i.length-l;if(i.slice(c-e.length,c)==e&&s.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:o+a,margin:a&&1}};let u,h;o-n<=2*bi?u=h=r.sliceDoc(n,o):(u=r.sliceDoc(n,n+bi),h=r.sliceDoc(o-bi,o));let f=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(h)[0].length,p=h.length-d-t.length;return u.slice(f,f+e.length)==e&&h.slice(p,p+t.length)==t?{open:{pos:n+f+e.length,margin:/\s/.test(u.charAt(f+e.length))?1:0},close:{pos:o-d-t.length,margin:/\s/.test(h.charAt(p-1))?1:0}}:null}function BM(r){let e=[];for(let t of r.selection.ranges){let n=r.doc.lineAt(t.from),o=t.to<=n.to?n:r.doc.lineAt(t.to),i=e.length-1;i>=0&&e[i].to>n.from?e[i].to=o.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:o.to})}return e}function ly(r,e,t=e.selection.ranges){let n=t.map(i=>Wu(e,i.from).block);if(!n.every(i=>i))return null;let o=t.map((i,s)=>FM(e,n[s],i.from,i.to));if(r!=2&&!o.every(i=>i))return{changes:e.changes(t.map((i,s)=>o[s]?[]:[{from:i.from,insert:n[s].open+" "},{from:i.to,insert:" "+n[s].close}]))};if(r!=1&&o.some(i=>i)){let i=[];for(let s=0,l;s<o.length;s++)if(l=o[s]){let a=n[s],{open:c,close:u}=l;i.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+a.close.length})}return{changes:i}}return null}function HM(r,e,t=e.selection.ranges){let n=[],o=-1;for(let{from:i,to:s}of t){let l=n.length,a=1e9,c=Wu(e,i).line;if(c){for(let u=i;u<=s;){let h=e.doc.lineAt(u);if(h.from>o&&(i==s||s>h.from)){o=h.from;let f=/^\s*/.exec(h.text)[0].length,d=f==h.length,p=h.text.slice(f,f+c.length)==c?f:-1;f<h.text.length&&f<a&&(a=f),n.push({line:h,comment:p,token:c,indent:f,empty:d,single:!1})}u=h.to+1}if(a<1e9)for(let u=l;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=a);n.length==l+1&&(n[l].single=!0)}}if(r!=2&&n.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:l,token:a,indent:c,empty:u,single:h}of n)(h||!u)&&i.push({from:l.from+c,insert:a+" "});let s=e.changes(i);return{changes:s,selection:e.selection.map(s,1)}}else if(r!=1&&n.some(i=>i.comment>=0)){let i=[];for(let{line:s,comment:l,token:a}of n)if(l>=0){let c=s.from+l,u=c+a.length;s.text[u-s.from]==" "&&u++,i.push({from:c,to:u})}return{changes:i}}return null}var Fu=tt.define(),_M=tt.define(),zM=U.define(),ay=U.define({combine(r){return sr(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,o)=>e(n,o)||t(n,o)})}});function WM(r){let e=0;return r.iterChangedRanges((t,n)=>e=n),e}var cy=qe.define({create(){return vt.empty},update(r,e){let t=e.state.facet(ay),n=e.annotation(Fu);if(n){let a=e.docChanged?D.single(WM(e.changes)):void 0,c=Be.fromTransaction(e,a),u=n.side,h=u==0?r.undone:r.done;return c?h=pl(h,h.length,t.minDepth,c):h=dy(h,e.startState.selection),new vt(u==0?n.rest:h,u==0?h:n.rest)}let o=e.annotation(_M);if((o=="full"||o=="before")&&(r=r.isolate()),e.annotation(he.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let i=Be.fromTransaction(e),s=e.annotation(he.time),l=e.annotation(he.userEvent);return i?r=r.addChanges(i,s,l,t,e):e.selection&&(r=r.addSelection(e.startState.selection,s,l,t.newGroupDelay)),(o=="full"||o=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new vt(r.done.map(Be.fromJSON),r.undone.map(Be.fromJSON))}});function uy(r={}){return[cy,ay.of(r),j.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?hy:e.inputType=="historyRedo"?Bu:null;return n?(e.preventDefault(),n(t)):!1}})]}function ml(r,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let o=t.field(cy,!1);if(!o)return!1;let i=o.pop(r,t,e);return i?(n(i),!0):!1}}var hy=ml(0,!1),Bu=ml(1,!1),$M=ml(0,!0),UM=ml(1,!0);var Be=class{constructor(e,t,n,o,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=o,this.selectionsAfter=i}setSelAfter(e){return new Be(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(o=>o.toJSON())}}static fromJSON(e){return new Be(e.changes&&ue.fromJSON(e.changes),[],e.mapped&&et.fromJSON(e.mapped),e.startSelection&&D.fromJSON(e.startSelection),e.selectionsAfter.map(D.fromJSON))}static fromTransaction(e,t){let n=xt;for(let o of e.startState.facet(zM)){let i=o(e);i.length&&(n=n.concat(i))}return!n.length&&e.changes.empty?null:new Be(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,xt)}static selection(e){return new Be(void 0,xt,void 0,void 0,e)}};function pl(r,e,t,n){let o=e+1>t+20?e-t-1:0,i=r.slice(o,e);return i.push(n),i}function GM(r,e){let t=[],n=!1;return r.iterChangedRanges((o,i)=>t.push(o,i)),e.iterChangedRanges((o,i,s,l)=>{for(let a=0;a<t.length;){let c=t[a++],u=t[a++];l>=c&&s<=u&&(n=!0)}}),n}function qM(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function fy(r,e){return r.length?e.length?r.concat(e):r:e}var xt=[],KM=200;function dy(r,e){if(r.length){let t=r[r.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-KM));return n.length&&n[n.length-1].eq(e)?r:(n.push(e),pl(r,r.length-1,1e9,t.setSelAfter(n)))}else return[Be.selection([e])]}function jM(r){let e=r[r.length-1],t=r.slice();return t[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Vu(r,e){if(!r.length)return r;let t=r.length,n=xt;for(;t;){let o=JM(r[t-1],e,n);if(o.changes&&!o.changes.empty||o.effects.length){let i=r.slice(0,t);return i[t-1]=o,i}else e=o.mapped,t--,n=o.selectionsAfter}return n.length?[Be.selection(n)]:xt}function JM(r,e,t){let n=fy(r.selectionsAfter.length?r.selectionsAfter.map(l=>l.map(e)):xt,t);if(!r.changes)return Be.selection(n);let o=r.changes.map(e),i=e.mapDesc(r.changes,!0),s=r.mapped?r.mapped.composeDesc(i):i;return new Be(o,ie.mapEffects(r.effects,e),s,r.startSelection.map(i),n)}var QM=/^(input\.type|delete)($|\.)/,vt=class{constructor(e,t,n=0,o=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=o}isolate(){return this.prevTime?new vt(this.done,this.undone):this}addChanges(e,t,n,o,i){let s=this.done,l=s[s.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||QM.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<o.newGroupDelay&&o.joinToEvent(i,GM(l.changes,e.changes))||n=="input.type.compose")?s=pl(s,s.length-1,o.minDepth,new Be(e.changes.compose(l.changes),fy(e.effects,l.effects),l.mapped,l.startSelection,xt)):s=pl(s,s.length,o.minDepth,e),new vt(s,xt,t,n)}addSelection(e,t,n,o){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:xt;return i.length>0&&t-this.prevTime<o&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&qM(i[i.length-1],e)?this:new vt(dy(this.done,e),this.undone,t,n)}addMapping(e){return new vt(Vu(this.done,e),Vu(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let o=e==0?this.done:this.undone;if(o.length==0)return null;let i=o[o.length-1];if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Fu.of({side:e,rest:jM(o)}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let s=o.length==1?xt:o.slice(0,o.length-1);return i.mapped&&(s=Vu(s,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Fu.of({side:e,rest:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};vt.empty=new vt(xt,xt);var py=[{key:"Mod-z",run:hy,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Bu,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Bu,preventDefault:!0},{key:"Mod-u",run:$M,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:UM,preventDefault:!0}];function io(r,e){return D.create(r.ranges.map(e),r.mainIndex)}function Jt(r,e){return r.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Ot({state:r,dispatch:e},t){let n=io(r.selection,t);return n.eq(r.selection)?!1:(e(Jt(r,n)),!0)}function gl(r,e){return D.cursor(e?r.to:r.from)}function my(r,e){return Ot(r,t=>t.empty?r.moveByChar(t,e):gl(t,e))}function He(r){return r.textDirectionAt(r.state.selection.main.head)==pe.LTR}var gy=r=>my(r,!He(r)),yy=r=>my(r,He(r));function by(r,e){return Ot(r,t=>t.empty?r.moveByGroup(t,e):gl(t,e))}var YM=r=>by(r,!He(r)),XM=r=>by(r,He(r));function ZM(r,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function yl(r,e,t){let n=Fe(r).resolveInner(e.head),o=t?J.closedBy:J.openedBy;for(let a=e.head;;){let c=t?n.childAfter(a):n.childBefore(a);if(!c)break;ZM(r,c,o)?n=c:a=t?c.to:c.from}let i=n.type.prop(o),s,l;return i&&(s=t?mr(r,n.from,1):mr(r,n.to,-1))&&s.matched?l=t?s.end.to:s.end.from:l=t?n.to:n.from,D.cursor(l,t?-1:1)}var e1=r=>Ot(r,e=>yl(r.state,e,!He(r))),t1=r=>Ot(r,e=>yl(r.state,e,He(r)));function xy(r,e){return Ot(r,t=>{if(!t.empty)return gl(t,e);let n=r.moveVertically(t,e);return n.head!=t.head?n:r.moveToLineBoundary(t,e)})}var vy=r=>xy(r,!1),wy=r=>xy(r,!0);function Sy(r){let e=r.scrollDOM.clientHeight<r.scrollDOM.scrollHeight-2,t=0,n=0,o;if(e){for(let i of r.state.facet(j.scrollMargins)){let s=i(r);s!=null&&s.top&&(t=Math.max(s==null?void 0:s.top,t)),s!=null&&s.bottom&&(n=Math.max(s==null?void 0:s.bottom,n))}o=r.scrollDOM.clientHeight-t-n}else o=(r.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(r.defaultLineHeight,o-5)}}function Cy(r,e){let t=Sy(r),{state:n}=r,o=io(n.selection,s=>s.empty?r.moveVertically(s,e,t.height):gl(s,e));if(o.eq(n.selection))return!1;let i;if(t.selfScroll){let s=r.coordsAtPos(n.selection.main.head),l=r.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;s&&s.top>a&&s.bottom<c&&(i=j.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-a}))}return r.dispatch(Jt(n,o),{effects:i}),!0}var ey=r=>Cy(r,!1),Hu=r=>Cy(r,!0);function Dn(r,e,t){let n=r.lineBlockAt(e.head),o=r.moveToLineBoundary(e,t);if(o.head==e.head&&o.head!=(t?n.to:n.from)&&(o=r.moveToLineBoundary(e,t,!1)),!t&&o.head==n.from&&n.length){let i=/^\s*/.exec(r.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(o=D.cursor(n.from+i))}return o}var n1=r=>Ot(r,e=>Dn(r,e,!0)),r1=r=>Ot(r,e=>Dn(r,e,!1)),o1=r=>Ot(r,e=>Dn(r,e,!He(r))),i1=r=>Ot(r,e=>Dn(r,e,He(r))),s1=r=>Ot(r,e=>D.cursor(r.lineBlockAt(e.head).from,1)),l1=r=>Ot(r,e=>D.cursor(r.lineBlockAt(e.head).to,-1));function a1(r,e,t){let n=!1,o=io(r.selection,i=>{let s=mr(r,i.head,-1)||mr(r,i.head,1)||i.head>0&&mr(r,i.head-1,1)||i.head<r.doc.length&&mr(r,i.head+1,-1);if(!s||!s.end)return i;n=!0;let l=s.start.from==i.head?s.end.to:s.end.from;return t?D.range(i.anchor,l):D.cursor(l)});return n?(e(Jt(r,o)),!0):!1}var c1=({state:r,dispatch:e})=>a1(r,e,!1);function wt(r,e){let t=io(r.state.selection,n=>{let o=e(n);return D.range(n.anchor,o.head,o.goalColumn,o.bidiLevel||void 0)});return t.eq(r.state.selection)?!1:(r.dispatch(Jt(r.state,t)),!0)}function Ty(r,e){return wt(r,t=>r.moveByChar(t,e))}var ky=r=>Ty(r,!He(r)),My=r=>Ty(r,He(r));function Ey(r,e){return wt(r,t=>r.moveByGroup(t,e))}var u1=r=>Ey(r,!He(r)),h1=r=>Ey(r,He(r));var f1=r=>wt(r,e=>yl(r.state,e,!He(r))),d1=r=>wt(r,e=>yl(r.state,e,He(r)));function Ry(r,e){return wt(r,t=>r.moveVertically(t,e))}var Iy=r=>Ry(r,!1),Py=r=>Ry(r,!0);function Dy(r,e){return wt(r,t=>r.moveVertically(t,e,Sy(r).height))}var ty=r=>Dy(r,!1),ny=r=>Dy(r,!0),p1=r=>wt(r,e=>Dn(r,e,!0)),m1=r=>wt(r,e=>Dn(r,e,!1)),g1=r=>wt(r,e=>Dn(r,e,!He(r))),y1=r=>wt(r,e=>Dn(r,e,He(r))),b1=r=>wt(r,e=>D.cursor(r.lineBlockAt(e.head).from)),x1=r=>wt(r,e=>D.cursor(r.lineBlockAt(e.head).to)),ry=({state:r,dispatch:e})=>(e(Jt(r,{anchor:0})),!0),oy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.doc.length})),!0),iy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.selection.main.anchor,head:0})),!0),sy=({state:r,dispatch:e})=>(e(Jt(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),v1=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),w1=({state:r,dispatch:e})=>{let t=xl(r).map(({from:n,to:o})=>D.range(n,Math.min(o+1,r.doc.length)));return e(r.update({selection:D.create(t),userEvent:"select"})),!0},S1=({state:r,dispatch:e})=>{let t=io(r.selection,n=>{var o;let i=Fe(r).resolveInner(n.head,1);for(;!(i.from<n.from&&i.to>=n.to||i.to>n.to&&i.from<=n.from||!(!((o=i.parent)===null||o===void 0)&&o.parent));)i=i.parent;return D.range(i.to,i.from)});return e(Jt(r,t)),!0},C1=({state:r,dispatch:e})=>{let t=r.selection,n=null;return t.ranges.length>1?n=D.create([t.main]):t.main.empty||(n=D.create([D.cursor(t.main.head)])),n?(e(Jt(r,n)),!0):!1};function bl(r,e){if(r.state.readOnly)return!1;let t="delete.selection",{state:n}=r,o=n.changeByRange(i=>{let{from:s,to:l}=i;if(s==l){let a=e(s);a<s?(t="delete.backward",a=dl(r,a,!1)):a>s&&(t="delete.forward",a=dl(r,a,!0)),s=Math.min(s,a),l=Math.max(l,a)}else s=dl(r,s,!1),l=dl(r,l,!0);return s==l?{range:i}:{changes:{from:s,to:l},range:D.cursor(s)}});return o.changes.empty?!1:(r.dispatch(n.update(o,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?j.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function dl(r,e,t){if(r instanceof j)for(let n of r.state.facet(j.atomicRanges).map(o=>o(r)))n.between(e,e,(o,i)=>{o<e&&i>e&&(e=t?i:o)});return e}var Ly=(r,e)=>bl(r,t=>{let{state:n}=r,o=n.doc.lineAt(t),i,s;if(!e&&t>o.from&&t<o.from+200&&!/[^ \t]/.test(i=o.text.slice(0,t-o.from))){if(i[i.length-1]==" ")return t-1;let l=lr(i,n.tabSize),a=l%mi(n)||mi(n);for(let c=0;c<a&&i[i.length-1-c]==" ";c++)t--;s=t}else s=Ve(o.text,t-o.from,e,e)+o.from,s==t&&o.number!=(e?n.doc.lines:1)&&(s+=e?1:-1);return s}),_u=r=>Ly(r,!1),Ay=r=>Ly(r,!0),Oy=(r,e)=>bl(r,t=>{let n=t,{state:o}=r,i=o.doc.lineAt(n),s=o.charCategorizer(n);for(let l=null;;){if(n==(e?i.to:i.from)){n==t&&i.number!=(e?o.doc.lines:1)&&(n+=e?1:-1);break}let a=Ve(i.text,n-i.from,e)+i.from,c=i.text.slice(Math.min(n,a)-i.from,Math.max(n,a)-i.from),u=s(c);if(l!=null&&u!=l)break;(c!=" "||n!=t)&&(l=u),n=a}return n}),Ny=r=>Oy(r,!1),T1=r=>Oy(r,!0),Vy=r=>bl(r,e=>{let t=r.lineBlockAt(e).to;return e<t?t:Math.min(r.state.doc.length,e+1)}),k1=r=>bl(r,e=>{let t=r.lineBlockAt(e).from;return e>t?t:Math.max(0,e-1)});var M1=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:Y.of(["",""])},range:D.cursor(n.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},E1=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(n=>{if(!n.empty||n.from==0||n.from==r.doc.length)return{range:n};let o=n.from,i=r.doc.lineAt(o),s=o==i.from?o-1:Ve(i.text,o-i.from,!1)+i.from,l=o==i.to?o+1:Ve(i.text,o-i.from,!0)+i.from;return{changes:{from:s,to:l,insert:r.doc.slice(o,l).append(r.doc.slice(s,o))},range:D.cursor(l)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function xl(r){let e=[],t=-1;for(let n of r.selection.ranges){let o=r.doc.lineAt(n.from),i=r.doc.lineAt(n.to);if(!n.empty&&n.to==i.from&&(i=r.doc.lineAt(n.to-1)),t>=o.number){let s=e[e.length-1];s.to=i.to,s.ranges.push(n)}else e.push({from:o.from,to:i.to,ranges:[n]});t=i.number+1}return e}function Fy(r,e,t){if(r.readOnly)return!1;let n=[],o=[];for(let i of xl(r)){if(t?i.to==r.doc.length:i.from==0)continue;let s=r.doc.lineAt(t?i.to+1:i.from-1),l=s.length+1;if(t){n.push({from:i.to,to:s.to},{from:i.from,insert:s.text+r.lineBreak});for(let a of i.ranges)o.push(D.range(Math.min(r.doc.length,a.anchor+l),Math.min(r.doc.length,a.head+l)))}else{n.push({from:s.from,to:i.from},{from:i.to,insert:r.lineBreak+s.text});for(let a of i.ranges)o.push(D.range(a.anchor-l,a.head-l))}}return n.length?(e(r.update({changes:n,scrollIntoView:!0,selection:D.create(o,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}var R1=({state:r,dispatch:e})=>Fy(r,e,!1),I1=({state:r,dispatch:e})=>Fy(r,e,!0);function By(r,e,t){if(r.readOnly)return!1;let n=[];for(let o of xl(r))t?n.push({from:o.from,insert:r.doc.slice(o.from,o.to)+r.lineBreak}):n.push({from:o.to,insert:r.lineBreak+r.doc.slice(o.from,o.to)});return e(r.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var P1=({state:r,dispatch:e})=>By(r,e,!1),D1=({state:r,dispatch:e})=>By(r,e,!0),L1=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(xl(e).map(({from:o,to:i})=>(o>0?o--:i<e.doc.length&&i++,{from:o,to:i}))),n=io(e.selection,o=>r.moveVertically(o,!0)).map(t);return r.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function A1(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Fe(r).resolveInner(e),n=t.childBefore(e),o=t.childAfter(e),i;return n&&o&&n.to<=e&&o.from>=e&&(i=n.type.prop(J.closedBy))&&i.indexOf(o.name)>-1&&r.doc.lineAt(n.to).from==r.doc.lineAt(o.from).from?{from:n.to,to:o.from}:null}var O1=Hy(!1),N1=Hy(!0);function Hy(r){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(o=>{let{from:i,to:s}=o,l=e.doc.lineAt(i),a=!r&&i==s&&A1(e,i);r&&(i=s=(s<=l.to?l:e.doc.lineAt(s)).to);let c=new pr(e,{simulateBreak:i,simulateDoubleBreak:!!a}),u=Du(c,i);for(u==null&&(u=/^\s*/.exec(e.doc.lineAt(i).text)[0].length);s<l.to&&/\s/.test(l.text[s-l.from]);)s++;a?{from:i,to:s}=a:i>l.from&&i<l.from+100&&!/\S/.test(l.text.slice(0,i))&&(i=l.from);let h=["",gi(e,u)];return a&&h.push(gi(e,c.lineIndent(l.from,-1))),{changes:{from:i,to:s,insert:Y.of(h)},range:D.cursor(i+1+h[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function $u(r,e){let t=-1;return r.changeByRange(n=>{let o=[];for(let s=n.from;s<=n.to;){let l=r.doc.lineAt(s);l.number>t&&(n.empty||n.to>l.from)&&(e(l,o,n),t=l.number),s=l.to+1}let i=r.changes(o);return{changes:o,range:D.range(i.mapPos(n.anchor,1),i.mapPos(n.head,1))}})}var V1=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=Object.create(null),n=new pr(r,{overrideIndentation:i=>{let s=t[i];return s==null?-1:s}}),o=$u(r,(i,s,l)=>{let a=Du(n,i.from);if(a==null)return;/\S/.test(i.text)||(a=0);let c=/^\s*/.exec(i.text)[0],u=gi(r,a);(c!=u||l.from<i.from+c.length)&&(t[i.from]=a,s.push({from:i.from,to:i.from+c.length,insert:u}))});return o.changes.empty||e(r.update(o,{userEvent:"indent"})),!0},F1=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update($u(r,(t,n)=>{n.push({from:t.from,insert:r.facet(pi)})}),{userEvent:"input.indent"})),!0),B1=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update($u(r,(t,n)=>{let o=/^\s*/.exec(t.text)[0];if(!o)return;let i=lr(o,r.tabSize),s=0,l=gi(r,Math.max(0,i-mi(r)));for(;s<o.length&&s<l.length&&o.charCodeAt(s)==l.charCodeAt(s);)s++;n.push({from:t.from+s,to:t.from+o.length,insert:l.slice(s)})}),{userEvent:"delete.dedent"})),!0);var H1=[{key:"Ctrl-b",run:gy,shift:ky,preventDefault:!0},{key:"Ctrl-f",run:yy,shift:My},{key:"Ctrl-p",run:vy,shift:Iy},{key:"Ctrl-n",run:wy,shift:Py},{key:"Ctrl-a",run:s1,shift:b1},{key:"Ctrl-e",run:l1,shift:x1},{key:"Ctrl-d",run:Ay},{key:"Ctrl-h",run:_u},{key:"Ctrl-k",run:Vy},{key:"Ctrl-Alt-h",run:Ny},{key:"Ctrl-o",run:M1},{key:"Ctrl-t",run:E1},{key:"Ctrl-v",run:Hu}],_1=[{key:"ArrowLeft",run:gy,shift:ky,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:YM,shift:u1,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:o1,shift:g1,preventDefault:!0},{key:"ArrowRight",run:yy,shift:My,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:XM,shift:h1,preventDefault:!0},{mac:"Cmd-ArrowRight",run:i1,shift:y1,preventDefault:!0},{key:"ArrowUp",run:vy,shift:Iy,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ry,shift:iy},{mac:"Ctrl-ArrowUp",run:ey,shift:ty},{key:"ArrowDown",run:wy,shift:Py,preventDefault:!0},{mac:"Cmd-ArrowDown",run:oy,shift:sy},{mac:"Ctrl-ArrowDown",run:Hu,shift:ny},{key:"PageUp",run:ey,shift:ty},{key:"PageDown",run:Hu,shift:ny},{key:"Home",run:r1,shift:m1,preventDefault:!0},{key:"Mod-Home",run:ry,shift:iy},{key:"End",run:n1,shift:p1,preventDefault:!0},{key:"Mod-End",run:oy,shift:sy},{key:"Enter",run:O1},{key:"Mod-a",run:v1},{key:"Backspace",run:_u,shift:_u},{key:"Delete",run:Ay},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ny},{key:"Mod-Delete",mac:"Alt-Delete",run:T1},{mac:"Mod-Backspace",run:k1},{mac:"Mod-Delete",run:Vy}].concat(H1.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),Uu=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e1,shift:f1},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t1,shift:d1},{key:"Alt-ArrowUp",run:R1},{key:"Shift-Alt-ArrowUp",run:P1},{key:"Alt-ArrowDown",run:I1},{key:"Shift-Alt-ArrowDown",run:D1},{key:"Escape",run:C1},{key:"Mod-Enter",run:N1},{key:"Alt-l",mac:"Ctrl-l",run:w1},{key:"Mod-i",run:S1,preventDefault:!0},{key:"Mod-[",run:B1},{key:"Mod-]",run:F1},{key:"Mod-Alt-\\",run:V1},{key:"Shift-Mod-k",run:L1},{key:"Shift-Mod-\\",run:c1},{key:"Mod-/",run:AM},{key:"Alt-A",run:NM}].concat(_1);var z1=[...Uu,...py],W1=(()=>[yu(),uy(),gu(),Xg(),yi(Lu,{fallback:!0}),Zr.of(z1)])();import{isNumericColumn as GW}from"@vuu-ui/vuu-utils";var _y=[{label:"=",boost:10,type:"operator"},{label:"!=",boost:9,type:"operator"}],$1=[..._y,{label:"in",boost:6,type:"operator"},{label:"starts",boost:5,type:"operator"},{label:"ends",boost:4,type:"operator"}],U1=[..._y,{label:">",boost:8,type:"operator"},{label:"<",boost:7,type:"operator"}];import I5 from"classnames";import{useEffect as L5,useMemo as A5,useRef as O5}from"react";var r5=In.define({name:"VuuFilterQuery",parser:Go.configure({props:[hi({Identifier:L.variableName,String:L.string,Or:L.emphasis,Operator:L.operator})]})});var K1=cn.define([{tag:L.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:L.comment,color:"green",fontStyle:"italic"}]),j1=yi(K1);var J1=j.theme({"&":{color:"var(--vuuFilterEditor-color)",backgroundColor:"var(--vuuFilterEditor-background)",fontSize:"var(--vuuFilterEditor-fontSize)"},".cm-content":{caretColor:"var(--vuuFilterEditor-cursorColor)",padding:0},".cm-line":{lineHeight:"var(--vuuFilterEditor-lineHeight)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--vuuFilterEditor-cursorColor)"},"&.cm-focused .cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-selectionBackground, ::selection":{backgroundColor:"var(--vuuFilterEditor-selectionBackground)"},".cm-scroller":{fontFamily:"var(--vuuFilterEditor-fontFamily)"},".cm-tooltip":{background:"var(--vuuFilterEditor-tooltipBackground)",border:"var(--vuuFilterEditor-tooltipBorder)",boxShadow:"var(--vuuFilterEditor-tooltipElevation)","&.cm-tooltip-autocomplete > ul":{fontFamily:"var(--vuuFilterEditor-fontFamily)",fontSize:"var(--vuuFilterEditor-fontSize)",maxHeight:"240px"},"&.cm-tooltip-autocomplete > ul > li":{alignItems:"center",display:"flex",height:"var(--vuuFilterEditor-suggestion-height)",padding:"0 3px",lineHeight:"var(--vuuFilterEditor-suggestion-height)"},"&.cm-tooltip-autocomplete li[aria-selected]":{background:"var(--vuuFilterEditor-suggestion-selectedBackground)",color:"var(--vuuFilterEditor-suggestion-selectedColor)"}},".cm-completionIcon":{height:"18px",flex:"0 0 16px"},".cm-completionLabel":{flex:"1 1 auto"},".cm-completionIcon-filter":{position:"relative","&:after":{background:"var(--salt-text-secondary-foreground)",content:"''","-webkit-mask":"var(--svg-filter) center center/13px 13px","-webkit-mask-repeat":"no-repeat",position:"absolute",height:"18px",left:"0px",top:"0px",width:"16px"}}},{dark:!1});import{useCallback as b5}from"react";import{jsx as X5,jsxs as Z5}from"react/jsx-runtime";import{useCallback as m$,useRef as g$}from"react";import{createEl as n$}from"@vuu-ui/vuu-utils";var vl=r=>{let e=localStorage.getItem(r);return e?JSON.parse(e):void 0};var wl=(r,e)=>{try{return localStorage.setItem(r,JSON.stringify(e)),e}catch{return}};import{getUniqueId as Q1}from"@vuu-ui/vuu-utils";var zy="layouts/metadata",Wy="layouts/layouts",so,Sl=class{constructor(e){ee(this,so,"api/vui");e&&z(this,so,e)}createLayout(e,t){return new Promise(n=>{Promise.all([this.loadLayouts(),this.loadMetadata()]).then(([o,i])=>{let s=Q1();this.appendAndPersist(s,e,t,o,i),n(s)})})}updateLayout(e,t,n){return new Promise((o,i)=>{this.validateIds(e).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([s,l])=>{let a=s.filter(u=>u.id!==e),c=l.filter(u=>u.id!==e);this.appendAndPersist(e,t,n,a,c),o()}).catch(s=>i(s))})}deleteLayout(e){return new Promise((t,n)=>{this.validateIds(e).then(()=>Promise.all([this.loadLayouts(),this.loadMetadata()])).then(([o,i])=>{let s=o.filter(a=>a.id!==e),l=i.filter(a=>a.id!==e);this.saveLayoutsWithMetadata(s,l),t()}).catch(o=>n(o))})}loadLayout(e){return new Promise((t,n)=>{this.validateId(e,"layout").then(()=>this.loadLayouts()).then(o=>{let i=o.find(s=>s.id===e);t(i.json)}).catch(o=>n(o))})}loadMetadata(){return new Promise(e=>{let t=vl(zy);e(t||[])})}loadApplicationLayout(){return new Promise(e=>{let t=vl(T(this,so));e(t||Ho)})}saveApplicationLayout(e){return new Promise((t,n)=>{wl(T(this,so),e)?t():n(new Error("Layout failed to save"))})}loadLayouts(){return new Promise(e=>{let t=vl(Wy);e(t||[])})}appendAndPersist(e,t,n,o,i){o.push({id:e,json:n}),i.push({id:e,...t}),this.saveLayoutsWithMetadata(o,i)}saveLayoutsWithMetadata(e,t){wl(Wy,e),wl(zy,t)}async validateIds(e){return Promise.all([this.validateId(e,"metadata").catch(t=>t.message),this.validateId(e,"layout").catch(t=>t.message)]).then(t=>{let n=t.filter(o=>o!==void 0).join("; ");if(n)throw new Error(n)})}validateId(e,t){return new Promise((n,o)=>{(t==="metadata"?this.loadMetadata:this.loadLayouts)().then(s=>{switch(s.filter(a=>a.id===e).length){case 1:{n();break}case 0:{o(new Error(`No ${t} with ID ${e}`));break}default:o(new Error(`Non-unique ${t} with ID ${e}`))}})})}};so=new WeakMap;import _$,{useEffect as z$,useState as W$}from"react";import U$ from"classnames";import{Fragment as j$,jsx as J$,jsxs as K$}from"react/jsx-runtime";function $y(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r))for(e=0;e<r.length;e++)r[e]&&(t=$y(r[e]))&&(n&&(n+=" "),n+=t);else for(e in r)r[e]&&(n&&(n+=" "),n+=e);return n}function yr(){for(var r,e,t=0,n="";t<arguments.length;)(r=arguments[t++])&&(e=$y(r))&&(n&&(n+=" "),n+=e);return n}var Y1=/[.*+?^${}()|[\]\\]/g;function Cl(r){return r.replace(Y1,"\\$&")}import{jsx as n8}from"react/jsx-runtime";import{createContext as X1,useContext as Z1}from"react";var eE=X1(typeof window<"u"?window:null);function un(){return Z1(eE)}import*as Tl from"react";import{jsx as c8}from"react/jsx-runtime";import{createContext as tE,useMemo as h8,useContext as nE}from"react";var rE=tE(null);function Uy(){return nE(rE)}var Gy,oE=(Gy=Tl.useInsertionEffect)!=null?Gy:Tl.useLayoutEffect,Gu=new WeakMap;function hn({testId:r,css:e,window:t}){let n=Uy();oE(()=>{var o,i;if(!t)return;let s=(o=Gu.get(t))!=null?o:new Map,l=(i=s.get(e))!=null?i:{styleElement:null,count:0};return l.styleElement==null?(l.styleElement=t.document.createElement("style"),l.styleElement.setAttribute("type","text/css"),l.styleElement.setAttribute("data-salt-style",r||""),l.styleElement.textContent=e,l.count=1,t.document.head.insertBefore(l.styleElement,n||t.document.head.firstChild)):(l.styleElement.textContent=e,l.count++),s.set(e,l),Gu.set(t,s),()=>{let a=Gu.get(t),c=a==null?void 0:a.get(e);c!=null&&c.styleElement&&(c.count--,c.count<1&&(t.document.head.removeChild(c.styleElement),c.styleElement=null,a==null||a.delete(e)))}},[r,e,t])}import"@salt-ds/core";import"react";import{jsx as b8}from"react/jsx-runtime";import{createContext as iE,cloneElement as v8,useContext as sE}from"react";var lE=iE(void 0);function qy(){let r=sE(lE);if(r)return r}function aE(r,...e){let t=new Set(r);for(let n of e)for(let o of n)t.add(o);return t}var xi="ArrowUp",vi="ArrowDown",Ky="ArrowLeft",jy="ArrowRight",qu="Enter",kl="Home",wi="End",Ku="PageUp",Ml="PageDown",Jy=" ",cE=new Set(["Enter","Delete"," "]),uE=new Set(["Tab"]),hE=new Set(["ArrowRight","ArrowLeft"]),Qy=new Set([kl,wi,Ku,Ml,vi,xi]),fE=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),dE=aE(cE,Qy,hE,fE,uE),El=r=>dE.has(r.key)?!1:r.key.length===1&&!r.ctrlKey&&!r.metaKey&&!r.altKey,Yy=({key:r})=>Qy.has(r);import{useState as kE,useRef as Il,useMemo as Pl,useCallback as St,isValidElement as ab}from"react";import{isValidElement as ju,Children as mE}from"react";var Xy=r=>null;var Zy=r=>null;var pE=r=>Object.prototype.toString.call(r)==="[object Object]";function lo(r){return typeof r=="string"?r:pE(r)?Object.prototype.hasOwnProperty.call(r,"label")?String(r.label):(console.warn(["itemToString: you've likely forgotten to set the label prop on the item object.","You can also provide your own `itemToString` implementation."].join(`
27
+ `)),""):String(r)}var Ju=(r,e)=>r!==null&&Object.prototype.hasOwnProperty.call(r,e),Qu=r=>Ju(r,"header"),eb=r=>Ju(r,"childNodes"),Si=(r,e)=>r&&Object.prototype.hasOwnProperty.call(r.props,e),tb=r=>{if(ju(r)){if(Si(r,"disabled"))return r.props.disabled===!0}else if(Ju(r,"disabled"))return r.disabled===!0;return!1},nb=r=>ju(r)&&Si(r,"focusable")?r.props.focusable:!0,rb=(r,e,t)=>{if(r.childNodes)return r.childNodes.length;if(r.header){let n=t+1,o=0;for(;n<e.length&&!e[n].header;)o++,n++;return o}else return 0},gE=r=>{if(typeof r.props.children=="string")return r.props.children;if(r.props.title)return r.props.title;if(r.props.label)return r.props.label},ob=r=>r.type===Zy||Si(r,"data-header"),ib=r=>r.type===Xy||Si(r,"data-group"),yE=r=>Si(r,"selectable")?r.props.selectable===!0:!ib(r)&&!ob(r),bE=r=>{if(ib(r)){let{props:{children:e}}=r;if(typeof e!="string")return Xu(e)}},xE=(r,e)=>{let t=[];return mE.forEach(r,n=>{ju(n)&&t.push(e(n))}),t},Yu=(r,e)=>{if(Array.isArray(r))return r.length===0&&(e!=null&&e.noChildrenLabel)?[{label:e.noChildrenLabel,value:null}]:r.map((t,n)=>{var o,i;return{childNodes:Yu(t.childNodes,e),description:t.description,expanded:t.expanded,value:t,label:(i=(o=e==null?void 0:e.itemToString)==null?void 0:o.call(e,t))!=null?i:lo(t)}});if(r)throw Error("list-child-items expects source to be an array")},Xu=r=>{if(r)return xE(r,e=>{let{"data-id":t,disabled:n,id:o=t,"data-expanded":i,expanded:s=i}=e.props;return{childNodes:bE(e),disabled:n,expanded:s,header:ob(e),id:o,label:gE(e),selectable:yE(e),value:e}})},vE=new Set(["/","-","."]),wE=r=>vE.has(r),sb=(r,e)=>e.startsWith(r)&&wE(e[r.length]),SE=new Set([".","/"]);function CE(r,e){return e.startsWith(r)?SE.has(e.charAt(r.length)):!1}function Rl(r,e,t){let n;return r.map(i=>i.id===e?{...i,...t}:CE(i.id,e)&&i.childNodes?(n=Rl(i.childNodes,e,t),{...i,childNodes:n}):i)}import"react";import"@salt-ds/core";var TE=r=>r&&r.replace(/^\s+/g,""),Zu=r=>new RegExp(`(${Cl(TE(r))})`,"gi"),lb=(r="",e=Zu)=>(t="")=>!!t.length&&!!r.length&&t.match(e(r))!==null;var ME={},cb=({children:r,id:e,label:t="",options:n=ME,source:o})=>{var i;let{getItemId:s}=n,[,l]=kE(null),a=qy(),c=Il([]),u=Il([]),h=Pl(()=>[],[]),f=Il((i=n.filterPattern)!=null?i:""),{getFilterRegex:d=Zu,noChildrenLabel:p,itemToString:m=lo}=n,y=St(O=>n.defaultExpanded||!1,[n.defaultExpanded]),g=St((O,N,F=1,G="",X=[],te=[],_e=[])=>(O.forEach((de,it,On)=>{var Vt,re;let se=de.header&&n.collapsibleHeaders,Me=de.childNodes&&n.collapsibleHeaders===!1,kt=!de.childNodes||de.childNodes.length===0,fo=Me||kt&&!se,po=G?`${G}.${it}`:`item-${it}`,mo=(Vt=de.id)!=null?Vt:s?s(it):`${e}-${po}`,Mt=fo?void 0:(re=de.expanded)!=null?re:y(mo),go={...de,childNodes:void 0,count:!Me&&Mt===void 0?0:rb(de,On,it),description:de.description,disabled:tb(de.value),focusable:nb(de.value)?void 0:!1,id:mo,index:N.value,expanded:Mt,level:F};if(X.push(go),te.push(go),_e.push(O[it].value),N.value+=1,de.childNodes){let[Ql]=g(de.childNodes,N,F+1,po,[],te,_e);go.childNodes=Ql}}),[X,_e,te]),[n.collapsibleHeaders,s,e,y]),v=St(()=>f.current?lb(f.current,d):null,[d]),w=St((O,N=v(),F=[],G={value:0})=>{let X=!1;for(let te of O)X&&!Qu(te)||(te.value!==null&&(N===null||N(m(te.value)))&&(F[G.value]=te,G.value+=1),X=!1,Qu(te)&&te.expanded===!1?X=!0:eb(te)&&te.expanded!==!1&&te.childNodes&&w(te.childNodes,N,F,G));return F},[v,m]),x=Pl(()=>a?h:Yu(o,{itemToString:m,noChildrenLabel:p})||Xu(r)||[],[a,h,o,m,p,r]),[S,b,C]=Pl(()=>a?[h,h,h]:g(x,{value:0}),[h,g,a,x]);u.current=C,Pl(()=>a?h:c.current=w(S),[h,w,S,a]);let k=Il(S),E=St((O="")=>{typeof O=="string"&&(f.current=O,c.current=w(S),l({}))},[S,w]),R=St((O,N=S)=>{let F=N.find(G=>{var X;return G.id===O||((X=G==null?void 0:G.childNodes)==null?void 0:X.length)&&sb(G.id,O)});if((F==null?void 0:F.id)===O)return b==null?void 0:b[F.index];if(F)return R(O,F.childNodes);throw Error(`useCollectionData itemById, id ${O} not found `)},[b,S]),M=St(O=>{let N=u.current.find(F=>ab(F.value)?F.label===O:F.value===O);if(N)return N;throw Error("useCollectionData toCollectionItem, item not found ")},[]),P=St(O=>{if(O===null)return null;if(Array.isArray(O)){let N=[];for(let F of O){let G=M(F);N.push(G)}return N}else if(O!==void 0)return M(O)},[M]),I=St(O=>{let N=F=>{let G=u.current.find(X=>ab(X.value)?X.label===F:X.value!==null&&m(X.value)===F);if(G)return G};if(O===null)return null;if(Array.isArray(O)){let F=[];for(let G of O){let X=N(G);X&&F.push(X)}return F}else if(O!==void 0)return N(O)},[m]),V=St(O=>{for(let N of k.current)if(O===N.value)return N.id;throw Error("useCollectionData itemToId, item not found")},[]),B=St(O=>{k.current=Rl(k.current,O.id,{expanded:!1}),c.current=w(k.current),l({})},[w]),W=St(O=>{k.current=Rl(k.current,O.id,{expanded:!0}),c.current=w(k.current),l({})},[w]);return a||{collapseGroupItem:B,data:c.current,expandGroupItem:W,setFilterPattern:E,itemById:R,itemToId:V,toCollectionItem:M,itemToCollectionItem:P,stringToCollectionItem:I}};import{useIsomorphicLayoutEffect as ub}from"@salt-ds/core";import{useRef as EE,useCallback as RE}from"react";var hb=["height"];var br=new WeakMap,fb=(r,e,t)=>{switch(t){case"height":return e.height;case"scrollHeight":return r.scrollHeight;case"scrollWidth":return r.scrollWidth;case"width":return e.width;default:return 0}},Dl=typeof ResizeObserver<"u"?new ResizeObserver(r=>{for(let e of r){let{target:t,contentRect:n}=e,o=br.get(t);if(o){let{onResize:i,measurements:s}=o,l=!1;for(let[a,c]of Object.entries(s)){let u=fb(t,n,a);u!==c&&(l=!0,s[a]=u)}l&&i&&i(s)}}}):null;function Ci(r,e,t,n=!1){let o=EE(e),i=RE(s=>{let l=s.getBoundingClientRect();return o.current.reduce((a,c)=>(a[c]=fb(s,l,c),a),{})},[]);ub(()=>{if(!Dl)return;let s=r.current,l=!1;async function a(){br.set(s,{measurements:{}}),l=!1;let{fonts:c}=document;if(c&&await c.ready,!l&&Dl){let u=br.get(s);if(u){let h=i(s);u.measurements=h,Dl.observe(s),n&&t(h)}}}if(s){if(br.has(s))throw Error("useResizeObserver attemping to observe same element twice");a()}return()=>{s&&br.has(s)&&(Dl.unobserve(s),br.delete(s),l=!0)}},[r,i]),ub(()=>{let s=r.current,l=br.get(s);if(l){if(o.current!==e){o.current=e;let a=i(s);l.measurements=a}l.onResize=t}},[e,i,r,t])}import{jsxs as aR,jsx as xr,Fragment as cR}from"react/jsx-runtime";import{forwardRef as uR,useRef as ah,createElement as hR,isValidElement as fR,cloneElement as dR}from"react";import{makePrefixer as pR,useIdMemo as mR,useForkRef as gR}from"@salt-ds/core";import{useMemo as IE,useImperativeHandle as PE}from"react";var DE={scrollToIndex:r=>{},scrollToItem:r=>{},scrollTo:r=>{}},db=({collectionHook:r,forwardedRef:e,scrollableRef:t,scrollIntoView:n})=>{let o=IE(()=>({scrollToIndex:i=>{let s=r.data[i];s&&(n==null||n(s))},scrollToItem:i=>{let s=r.toCollectionItem(i);s&&(n==null||n(s))},scrollTo:i=>{t!=null&&t.current&&(t.current.scrollTop=i)}}),[r.data,r.toCollectionItem,n]);PE(e,()=>t.current?o:DE,[o])};import{useControlled as LE}from"@salt-ds/core";import{useRef as eh,useState as AE,useCallback as ao,useMemo as OE}from"react";var pb=r=>Array.isArray(r)?r.length>0:r!=null,mb=r=>Array.isArray(r)?r[0]:r;var nh=-2;function gb(r,e,t){return e===xi||e===wi?t>0?t-1:t:t===null?0:t===r-1?t:t+1}var th=(r,e)=>{let t=mb(e);return t?r.indexOf(t):-1},NE=(r,e,t,n)=>r===wi?n:r===kl?-1:e!==-1?e:t,bb=r=>{let e=document.getElementById(r.id);if(e)return e.getBoundingClientRect();throw Error(`useKeyboardNavigation.getItemRect no element found for item #${r==null?void 0:r.id}`)},VE=(r,e,t,n)=>{let{top:o}=e.getBoundingClientRect(),{scrollTop:i,clientHeight:s,scrollHeight:l}=r,a=t.length-1,c=Math.min(i+s,l-s);if(c!==i&&n<a){r.scrollTo(0,c);let u=n,h;do u+=1,h=bb(t[u]);while(h.top<o&&u<a);return u}},FE=async(r,e,t,n)=>{let{top:o}=e.getBoundingClientRect(),{scrollTop:i,clientHeight:s}=r,l=Math.max(i-s,0);if(l!==i&&n>0)return r.scrollTo(0,l),new Promise(a=>{requestAnimationFrame(()=>{let c=n,u;do c-=1,u=bb(t[c]);while(u.top>o&&c>0);a(c)})})},BE=r=>!r.header&&!r.childNodes,yb=r=>BE(r)||r.expanded!==void 0,xb=({containerRef:r,defaultHighlightedIndex:e=-1,disableHighlightOnFocus:t,highlightedIndex:n,indexPositions:o,onHighlight:i,onKeyboardNavigation:s,restoreLastFocus:l,selected:a})=>{let c=eh(-1),[,u]=AE({}),[h,f,d]=LE({controlled:n,default:e,name:"UseKeyboardNavigation"}),p=ao((k,E=!1)=>{i==null||i(k),f(k),E&&(c.current=k)},[i,f]),m=ao(async(k,E)=>{let{id:R}=o[E],M;if(R){let P=document.getElementById(R),{current:I}=r;P&&I&&(M=k.key===Ml?VE(I,P,o,E):await FE(I,P,o,E))}return M!=null?M:E},[r,o]),y=ao((k=vi,E=k===vi?-1:o.length)=>{if(o.length===0)return-1;{let R=th(o,a),M=NE(k,E,R,o.length),P=gb(o.length,k,M);if(P===0&&k===xi&&!yb(o[0]))return E;for(;((k===vi||k===kl)&&P<o.length||(k===xi||k===wi)&&P>0)&&!yb(o[P]);)P=gb(o.length,k,P);return P}},[o,a]),g=eh(!1),v=eh(!1),w=k=>v.current=k,x=ao(k=>{if(v.current)v.current=!1;else if(g.current=!0,o.length===0)p(nh);else if(h!==-1)u({});else if(l)if(c.current!==-1)p(c.current);else{let E=th(o,a);p(E!==-1?E:0)}else if(pb(a)){let E=th(o,a);p(E)}else t!==!0&&p(y())},[t,h,o,y,l,a,p]),S=ao(async k=>{let E=k.key===Ml||k.key===Ku?await m(k,h):y(k.key,h);E!==h&&p(E,!0),s==null||s(k,E)},[h,y,m,s,p]),b=ao(k=>{o.length>0&&Yy(k)?(k.preventDefault(),k.stopPropagation(),g.current=!0,S(k)):El(k)&&(g.current=!0)},[o,S]),C=OE(()=>({onBlur:k=>{let E=k.target.closest(".saltList"),R=k.relatedTarget;E&&!(E!=null&&E.contains(R))&&(g.current=!1,f(-1),l||(c.current=-1))},onFocus:x,onKeyDown:b,onMouseDownCapture:()=>{g.current=!1,w(!0)},onMouseMove:()=>{g.current&&(g.current=!1)},onMouseLeave:()=>{g.current=!1,w(!1),p(-1)}}),[x,b,l,f,p]);return{focusVisible:g.current?h:-1,controlledHighlighting:d,highlightedIndex:h,setHighlightedIndex:p,keyboardNavigation:g,listProps:C,setIgnoreFocus:w}};function vb(r,e){return Array.isArray(r)?r.includes(e):r===e}import{jsx as Ll,jsxs as WE}from"react/jsx-runtime";import{forwardRef as Tb}from"react";import{makePrefixer as $E,CheckboxIcon as UE}from"@salt-ds/core";import{jsx as rh,Fragment as HE}from"react/jsx-runtime";import{makePrefixer as _E}from"@salt-ds/core";import"react";var wb=`.saltHighlighter-highlight {
28
28
  font-weight: var(--salt-text-fontWeight-strong); /* TODO: Check with design */
29
29
  }
30
- `;var BE=FE("saltHighlighter"),wb=r=>{let{matchPattern:e,text:t=""}=r,n=un();hn({testId:"salt-hightligher",css:vb,window:n});let o=typeof e=="string"?new RegExp(`(${Cl(e)})`,"gi"):e;return o===void 0?ih(VE,{children:t}):ih("span",{children:t.split(o).map((i,s)=>i.match(o)?ih("strong",{className:BE("highlight"),children:i},`${s}-${i}`):i)})};var Sb=`.saltListItem {
30
+ `;var zE=_E("saltHighlighter"),Sb=r=>{let{matchPattern:e,text:t=""}=r,n=un();hn({testId:"salt-hightligher",css:wb,window:n});let o=typeof e=="string"?new RegExp(`(${Cl(e)})`,"gi"):e;return o===void 0?rh(HE,{children:t}):rh("span",{children:t.split(o).map((i,s)=>i.match(o)?rh("strong",{className:zE("highlight"),children:i},`${s}-${i}`):i)})};var Cb=`.saltListItem {
31
31
  /* Color */
32
32
  --list-item-text-color: var(--salt-text-primary-foreground);
33
33
  --list-item-background: var(--saltList-item-background, var(--salt-selectable-background));
@@ -118,7 +118,7 @@ var Oh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var T=(r,e,t)=>(Oh(r
118
118
  position: absolute !important;
119
119
  visibility: hidden;
120
120
  }
121
- `;var Ci=_E("saltListItem"),sh=Cb(function(e,t){return Ll("div",{"aria-hidden":!0,className:yr(Ci(),Ci("proxy")),ref:t})}),Ti=Cb(function({children:e,className:t,disabled:n,tabIndex:o,item:i,itemHeight:s,itemTextHighlightPattern:l,label:a,selectable:c,selected:u,showCheckbox:h,style:f,...d},p){let m=un();hn({testId:"salt-list-item",css:Sb,window:m});let g=yr(Ci(),t,{saltDisabled:n,[Ci("checkbox")]:h}),y=s!==void 0?{...f,height:s}:f;return HE("div",{className:g,...d,"aria-disabled":n||void 0,"aria-selected":u||void 0,ref:p,style:y,children:[h&&Ll(zE,{"aria-hidden":!0,checked:u}),e&&typeof e!="string"?e:l==null?Ll("span",{className:Ci("textWrapper"),children:a||e}):Ll(wb,{matchPattern:l,text:a||e})]})});import{useRef as tR,useCallback as Al,isValidElement as ch}from"react";import"@salt-ds/core";import{useCallback as Tb}from"react";var WE={},$E=r=>Array.isArray(r.childNodes),UE=r=>r.closest("[data-toggle],[aria-expanded]").dataset.toggle==="true",kb=({collapsibleHeaders:r,collectionHook:e,highlightedIdx:t,onToggle:n})=>{let o=Tb(l=>{if(l.key===Ky||l.key===ju){let a=e.data[t];a&&a.expanded===!1&&a.value&&(l.preventDefault(),e.expandGroupItem(a),n==null||n(a.value))}if(l.key===qy||l.key===ju){let a=e.data[t];a&&a.expanded&&a.value&&(l.preventDefault(),e.collapseGroupItem(a),n==null||n(a.value))}},[e.collapseGroupItem,e.data,e.expandGroupItem,t]),s={onClick:Tb(l=>{console.log(`useCollapsibleGroups idx=${t}`);let a=e.data[t];console.log(l.target,l.currentTarget),a&&$E(a)&&UE(l.target)&&(l.stopPropagation(),l.preventDefault(),a.expanded===!1&&a.value?(e.expandGroupItem(a),n==null||n(a.value)):a.expanded===!0&&a.value&&(e.collapseGroupItem(a),n==null||n(a.value)))},[e.collapseGroupItem,e.data,e.expandGroupItem,t]),onKeyDown:o};return r?s:WE};function GE(r){if(r){let e=r.dataset.idx;if(e)return parseInt(e,10);if(e=r.ariaPosInSet)return parseInt(e,10)-1}return-1}var qE=r=>r.closest("[data-idx],[aria-posinset]"),Mb=r=>GE(qE(r));import{useControlled as KE}from"@salt-ds/core";import{useRef as jE,useCallback as Ot}from"react";var JE=["Enter"," "],lh=r=>r&&r.disabled!==!0&&r.selectable!==!1,Eb=(r,e)=>{var t,n;return((t=r.index)!=null?t:0)-((n=e.index)!=null?n:0)},Rb=({defaultSelected:r,disableSelection:e=!1,highlightedIdx:t,indexPositions:n,label:o="",onSelect:i,onSelectionChange:s,selected:l,selectionStrategy:a,selectionKeys:c=JE,tabToSelect:u})=>{let h=a==="deselectable",f=a==="multiple",d=a==="extended",p=jE(-1),m=Ot(M=>c.includes(M.key),[c]),g=Ot(()=>f||d?[]:null,[f,d]),[y,v]=KE({controlled:l,default:r!=null?r:g(),name:"UseSelection",state:"selected"}),w=Ot(M=>Array.isArray(y)?y.includes(M):y===M,[y]),x=Ot(M=>M,[]),S=Ot(M=>w(M)?null:M,[w]),b=Ot(M=>{let D=w(M)?y.filter(F=>F!==M):y.concat(M);return D.sort(Eb),D},[w,y]),C=Ot((M,D)=>{let F=D?y:[],[G]=y.slice(-1),A=G?n.indexOf(G):0,V=Math.min(M,A),B=Math.max(M,A),U=n.slice(V,B+1),X=[...new Set([...F,...U])];return X.sort(Eb),X},[n,y]),k=Ot((M,D,F,G,A)=>{let V;f?V=b(F):d?A&&!G?V=b(F):G?V=C(D,A):V=[F]:h?V=S(F):V=x(F),V!==y&&v(V),i==null||i(M,F),V!==y&&s&&s(M,V)},[f,d,h,y,i,b,C,S,x,v,s]),E=Ot(M=>{let D=n[t];lh(D)&&(m(M)||u&&M.key==="Tab")&&(M.key!=="Tab"&&M.preventDefault(),k(M,t,D,!1,M.ctrlKey||M.metaKey),d&&(p.current=t))},[n,t,m,u,k,d]),R=Ot((M,D)=>{if(d&&M.shiftKey){let F=n[D];lh(F)&&k(M,D,F,!0)}},[d,n,k]);return{listHandlers:{onClick:Ot(M=>{let D=n[t];!e&&lh(D)&&(M.preventDefault(),M.stopPropagation(),k(M,t,D,M.shiftKey,M.ctrlKey||M.metaKey),d&&(p.current=t))},[e,d,t,n,k]),onKeyDown:E,onKeyboardNavigation:R},selected:y,setSelected:v}};import{useRef as ah,useCallback as Ib}from"react";var Pb=({disableTypeToSelect:r,highlightedIdx:e,highlightItemAtIndex:t,typeToNavigate:n,items:o,applyIncrementalSearch:i=!0})=>{let s=ah(null),l=ah(""),a=ah(-1),c=Ib(h=>{if(h||!i){let f=new RegExp(`^${l.current}`,"i"),d=o.findIndex(({label:p},m)=>m>a.current&&f.test(p));d===-1&&(d=o.findIndex(({label:p},m)=>m<=a.current&&f.test(p))),d!==-1&&t(d)}else l.current="",s.current=null,a.current=-1},[i,t,o]),u=Ib(h=>{let f=a.current!==-1;(El(h)||f&&h.key===jy)&&n&&(h.preventDefault(),h.stopPropagation(),(a.current===-1||h.key===l.current)&&(a.current=e),s.current!==null&&(clearTimeout(s.current),s.current=null),h.key!==l.current&&(l.current+=h.key),i&&c(!0),s.current=window.setTimeout(()=>{c()},100))},[n,i,e,c]);return{onKeyDown:r?void 0:u}};import{useRef as Db,useCallback as ao}from"react";import{useIsomorphicLayoutEffect as QE}from"@salt-ds/core";import"react/jsx-runtime";var Lb=["height"],YE=["height","scrollHeight"],XE=[],Ab={containerOnly:[YE,XE],withContent:[Lb,Lb]},ZE=r=>r?Ab.containerOnly:Ab.withContent,Ob={current:null},eR=(r,e)=>{let{transform:t="none"}=getComputedStyle(r);if(t.startsWith("matrix")){let n=t.lastIndexOf(",");return parseInt(t.slice(n+1))}else{let n=r.offsetParent;if(n===e||e===null)return r.offsetTop;{let o=r.offsetTop;for(;n!==null&&n!==e;)o+=n.offsetTop,n=n.offsetParent;return o}}},Nb=({containerRef:r,contentRef:e=Ob,highlightedIdx:t=-1,indexPositions:n,stickyHeaders:o=!1})=>{let i=Db(!1),s=Db({height:0,contentHeight:0}),l=ao(m=>{i.current=!0,r.current&&(r.current.scrollTop=m),setTimeout(()=>{i.current=!1})},[]),a=ao(()=>l(0),[l]),c=ao(()=>{l(s.current.contentHeight-s.current.height)},[l]),u=ao(m=>{let g=e.current||r.current;if(m.id){let y=document.getElementById(m.id);if(y&&r.current){let{height:v}=s.current,w=y.ariaExpanded&&y.firstChild?y.firstChild:y,x=o?36:0,S=eR(w,g),b=w.offsetHeight,{scrollTop:C}=r.current,k=C+x,E=k+v-x;if(S+b>E||S<k){let R=S+b>E?C+(S+b)-E:S-x;l(R)}}}},[r,e,l,o]);QE(()=>{let{height:m,contentHeight:g}=s.current,y=n[t];if(g>m&&y){let[v]=n,[w]=n.slice(-1);y===v?a():y===w?c():u(n[t])}},[t,n,u,c,a]);let h=ao(({height:m,scrollHeight:g})=>{typeof m=="number"&&(s.current.height=m),typeof g=="number"&&(s.current.contentHeight=g)},[]),f=ao(({height:m})=>{typeof m=="number"&&(s.current.contentHeight=m)},[]),[d,p]=ZE(e===Ob);return Si(r,d,h,!0),Si(e,p,f,!0),{isScrolling:i,scrollIntoView:u}};var Vb=({collapsibleHeaders:r,collectionHook:e,containerRef:t,contentRef:n,defaultHighlightedIndex:o,defaultSelected:i,disabled:s,disableAriaActiveDescendant:l,disableHighlightOnFocus:a,disableTypeToSelect:c,highlightedIndex:u,label:h="",listHandlers:f,onSelect:d,onSelectionChange:p,onHighlight:m,onKeyboardNavigation:g,onKeyDown:y,restoreLastFocus:v,selected:w,selectionStrategy:x,selectionKeys:S,stickyHeaders:b,tabToSelect:C})=>{let k=tR(w||i),E=(re,se)=>{var Me,Tt;(Tt=(Me=B.listHandlers).onKeyboardNavigation)==null||Tt.call(Me,re,se),g==null||g(re,se)},R=Al((re,se)=>{d&&(ch(se.value)?d(re,se.label):se.value!==null&&d(re,se.value))},[d]),N=Al((re,se)=>{p&&p(re,Array.isArray(se)?se.map(Me=>ch(Me.value)?Me.label:Me.value):se&&(ch(se.value)?se.label:se.value))},[p]),{highlightedIndex:O,listProps:{onKeyDown:M,onMouseMove:D,...F},setHighlightedIndex:G,...A}=bb({containerRef:t,defaultHighlightedIndex:o,disableHighlightOnFocus:a,highlightedIndex:u,indexPositions:e.data,label:h,onHighlight:m,onKeyboardNavigation:E,restoreLastFocus:v,selected:k.current}),V=kb({collapsibleHeaders:r,highlightedIdx:O,collectionHook:e}),B=Rb({defaultSelected:i,highlightedIdx:O,indexPositions:e.data,label:h,onSelect:R,onSelectionChange:N,selected:w,selectionStrategy:x,selectionKeys:S,tabToSelect:C}),{onKeyDown:U}=Pb({disableTypeToSelect:c,highlightedIdx:O,highlightItemAtIndex:G,typeToNavigate:!0,items:e.data}),X=Al(re=>{var se,Me,Tt;re.defaultPrevented||U==null||U(re),M(re),re.defaultPrevented||(Me=(se=B.listHandlers).onKeyDown)==null||Me.call(se,re),re.defaultPrevented||(Tt=V==null?void 0:V.onKeyDown)==null||Tt.call(V,re),re.defaultPrevented||y==null||y(re)},[V,M,y,B.listHandlers,U]),{isScrolling:ee,scrollIntoView:_e}=Nb({containerRef:t,contentRef:n,highlightedIdx:O,indexPositions:e.data,stickyHeaders:b}),de=Al(re=>{if(!ee.current&&!s){D();let se=Mb(re.target);if(se!==O){let Me=e.data[se];!Me||Me.disabled?G(-1):G(se)}}},[ee,s,G,D,O,e.data]),it=()=>{var re;return O===void 0||O===-1||l||(re=e.data[O])==null?void 0:re.id};k.current=B.selected;let On={"aria-activedescendant":it(),onBlur:F.onBlur,onFocus:F.onFocus,onKeyDown:X,onMouseDownCapture:F.onMouseDownCapture,onMouseLeave:F.onMouseLeave},Vt=f||{onClick:B.listHandlers.onClick,onMouseMove:de};return{focusVisible:A.focusVisible,controlledHighlighting:A.controlledHighlighting,highlightedIndex:O,keyboardNavigation:A.keyboardNavigation,listHandlers:Vt,listItemHeaderHandlers:V,listControlProps:On,scrollIntoView:_e,selected:B.selected,setHighlightedIndex:G,setIgnoreFocus:A.setIgnoreFocus,setSelected:B.setSelected}};import{useState as nR,useMemo as rR,useCallback as oR}from"react";import"@salt-ds/core";import"react/jsx-runtime";var Fb=({borderless:r,displayedItemCount:e,getItemHeight:t,height:n,itemCount:o,itemGapSize:i,itemHeight:s,rowHeightRef:l})=>{let[a,c]=nR(36),u=rR(()=>{let f=r?0:2,d=s!=null?s:a,p=Math.min(e,o)||e;return typeof t=="function"?f+=Array(p).fill(0).reduce((m,g,y)=>m+t(y)+i,0)-i:f+=p*Number(d)+(p-1)*i,isNaN(f)?void 0:f},[r,e,t,o,i,s,a]),h=oR(({height:f})=>{c(f)},[]);return Si(l,ub,h,!0),{preferredHeight:u}};var Bb=`.saltList {
121
+ `;var Ti=$E("saltListItem"),oh=Tb(function(e,t){return Ll("div",{"aria-hidden":!0,className:yr(Ti(),Ti("proxy")),ref:t})}),ki=Tb(function({children:e,className:t,disabled:n,tabIndex:o,item:i,itemHeight:s,itemTextHighlightPattern:l,label:a,selectable:c,selected:u,showCheckbox:h,style:f,...d},p){let m=un();hn({testId:"salt-list-item",css:Cb,window:m});let y=yr(Ti(),t,{saltDisabled:n,[Ti("checkbox")]:h}),g=s!==void 0?{...f,height:s}:f;return WE("div",{className:y,...d,"aria-disabled":n||void 0,"aria-selected":u||void 0,ref:p,style:g,children:[h&&Ll(UE,{"aria-hidden":!0,checked:u}),e&&typeof e!="string"?e:l==null?Ll("span",{className:Ti("textWrapper"),children:a||e}):Ll(Sb,{matchPattern:l,text:a||e})]})});import{useRef as oR,useCallback as Al,isValidElement as lh}from"react";import"@salt-ds/core";import{useCallback as kb}from"react";var GE={},qE=r=>Array.isArray(r.childNodes),KE=r=>r.closest("[data-toggle],[aria-expanded]").dataset.toggle==="true",Mb=({collapsibleHeaders:r,collectionHook:e,highlightedIdx:t,onToggle:n})=>{let o=kb(l=>{if(l.key===jy||l.key===qu){let a=e.data[t];a&&a.expanded===!1&&a.value&&(l.preventDefault(),e.expandGroupItem(a),n==null||n(a.value))}if(l.key===Ky||l.key===qu){let a=e.data[t];a&&a.expanded&&a.value&&(l.preventDefault(),e.collapseGroupItem(a),n==null||n(a.value))}},[e.collapseGroupItem,e.data,e.expandGroupItem,t]),s={onClick:kb(l=>{console.log(`useCollapsibleGroups idx=${t}`);let a=e.data[t];console.log(l.target,l.currentTarget),a&&qE(a)&&KE(l.target)&&(l.stopPropagation(),l.preventDefault(),a.expanded===!1&&a.value?(e.expandGroupItem(a),n==null||n(a.value)):a.expanded===!0&&a.value&&(e.collapseGroupItem(a),n==null||n(a.value)))},[e.collapseGroupItem,e.data,e.expandGroupItem,t]),onKeyDown:o};return r?s:GE};function jE(r){if(r){let e=r.dataset.idx;if(e)return parseInt(e,10);if(e=r.ariaPosInSet)return parseInt(e,10)-1}return-1}var JE=r=>r.closest("[data-idx],[aria-posinset]"),Eb=r=>jE(JE(r));import{useControlled as QE}from"@salt-ds/core";import{useRef as YE,useCallback as Nt}from"react";var XE=["Enter"," "],ih=r=>r&&r.disabled!==!0&&r.selectable!==!1,Rb=(r,e)=>{var t,n;return((t=r.index)!=null?t:0)-((n=e.index)!=null?n:0)},Ib=({defaultSelected:r,disableSelection:e=!1,highlightedIdx:t,indexPositions:n,label:o="",onSelect:i,onSelectionChange:s,selected:l,selectionStrategy:a,selectionKeys:c=XE,tabToSelect:u})=>{let h=a==="deselectable",f=a==="multiple",d=a==="extended",p=YE(-1),m=Nt(I=>c.includes(I.key),[c]),y=Nt(()=>f||d?[]:null,[f,d]),[g,v]=QE({controlled:l,default:r!=null?r:y(),name:"UseSelection",state:"selected"}),w=Nt(I=>Array.isArray(g)?g.includes(I):g===I,[g]),x=Nt(I=>I,[]),S=Nt(I=>w(I)?null:I,[w]),b=Nt(I=>{let V=w(I)?g.filter(B=>B!==I):g.concat(I);return V.sort(Rb),V},[w,g]),C=Nt((I,V)=>{let B=V?g:[],[W]=g.slice(-1),O=W?n.indexOf(W):0,N=Math.min(I,O),F=Math.max(I,O),G=n.slice(N,F+1),X=[...new Set([...B,...G])];return X.sort(Rb),X},[n,g]),k=Nt((I,V,B,W,O)=>{let N;f?N=b(B):d?O&&!W?N=b(B):W?N=C(V,O):N=[B]:h?N=S(B):N=x(B),N!==g&&v(N),i==null||i(I,B),N!==g&&s&&s(I,N)},[f,d,h,g,i,b,C,S,x,v,s]),E=Nt(I=>{let V=n[t];ih(V)&&(m(I)||u&&I.key==="Tab")&&(I.key!=="Tab"&&I.preventDefault(),k(I,t,V,!1,I.ctrlKey||I.metaKey),d&&(p.current=t))},[n,t,m,u,k,d]),R=Nt((I,V)=>{if(d&&I.shiftKey){let B=n[V];ih(B)&&k(I,V,B,!0)}},[d,n,k]);return{listHandlers:{onClick:Nt(I=>{let V=n[t];!e&&ih(V)&&(I.preventDefault(),I.stopPropagation(),k(I,t,V,I.shiftKey,I.ctrlKey||I.metaKey),d&&(p.current=t))},[e,d,t,n,k]),onKeyDown:E,onKeyboardNavigation:R},selected:g,setSelected:v}};import{useRef as sh,useCallback as Pb}from"react";var Db=({disableTypeToSelect:r,highlightedIdx:e,highlightItemAtIndex:t,typeToNavigate:n,items:o,applyIncrementalSearch:i=!0})=>{let s=sh(null),l=sh(""),a=sh(-1),c=Pb(h=>{if(h||!i){let f=new RegExp(`^${l.current}`,"i"),d=o.findIndex(({label:p},m)=>m>a.current&&f.test(p));d===-1&&(d=o.findIndex(({label:p},m)=>m<=a.current&&f.test(p))),d!==-1&&t(d)}else l.current="",s.current=null,a.current=-1},[i,t,o]),u=Pb(h=>{let f=a.current!==-1;(El(h)||f&&h.key===Jy)&&n&&(h.preventDefault(),h.stopPropagation(),(a.current===-1||h.key===l.current)&&(a.current=e),s.current!==null&&(clearTimeout(s.current),s.current=null),h.key!==l.current&&(l.current+=h.key),i&&c(!0),s.current=window.setTimeout(()=>{c()},100))},[n,i,e,c]);return{onKeyDown:r?void 0:u}};import{useRef as Lb,useCallback as co}from"react";import{useIsomorphicLayoutEffect as ZE}from"@salt-ds/core";import"react/jsx-runtime";var Ab=["height"],eR=["height","scrollHeight"],tR=[],Ob={containerOnly:[eR,tR],withContent:[Ab,Ab]},nR=r=>r?Ob.containerOnly:Ob.withContent,Nb={current:null},rR=(r,e)=>{let{transform:t="none"}=getComputedStyle(r);if(t.startsWith("matrix")){let n=t.lastIndexOf(",");return parseInt(t.slice(n+1))}else{let n=r.offsetParent;if(n===e||e===null)return r.offsetTop;{let o=r.offsetTop;for(;n!==null&&n!==e;)o+=n.offsetTop,n=n.offsetParent;return o}}},Vb=({containerRef:r,contentRef:e=Nb,highlightedIdx:t=-1,indexPositions:n,stickyHeaders:o=!1})=>{let i=Lb(!1),s=Lb({height:0,contentHeight:0}),l=co(m=>{i.current=!0,r.current&&(r.current.scrollTop=m),setTimeout(()=>{i.current=!1})},[]),a=co(()=>l(0),[l]),c=co(()=>{l(s.current.contentHeight-s.current.height)},[l]),u=co(m=>{let y=e.current||r.current;if(m.id){let g=document.getElementById(m.id);if(g&&r.current){let{height:v}=s.current,w=g.ariaExpanded&&g.firstChild?g.firstChild:g,x=o?36:0,S=rR(w,y),b=w.offsetHeight,{scrollTop:C}=r.current,k=C+x,E=k+v-x;if(S+b>E||S<k){let R=S+b>E?C+(S+b)-E:S-x;l(R)}}}},[r,e,l,o]);ZE(()=>{let{height:m,contentHeight:y}=s.current,g=n[t];if(y>m&&g){let[v]=n,[w]=n.slice(-1);g===v?a():g===w?c():u(n[t])}},[t,n,u,c,a]);let h=co(({height:m,scrollHeight:y})=>{typeof m=="number"&&(s.current.height=m),typeof y=="number"&&(s.current.contentHeight=y)},[]),f=co(({height:m})=>{typeof m=="number"&&(s.current.contentHeight=m)},[]),[d,p]=nR(e===Nb);return Ci(r,d,h,!0),Ci(e,p,f,!0),{isScrolling:i,scrollIntoView:u}};var Fb=({collapsibleHeaders:r,collectionHook:e,containerRef:t,contentRef:n,defaultHighlightedIndex:o,defaultSelected:i,disabled:s,disableAriaActiveDescendant:l,disableHighlightOnFocus:a,disableTypeToSelect:c,highlightedIndex:u,label:h="",listHandlers:f,onSelect:d,onSelectionChange:p,onHighlight:m,onKeyboardNavigation:y,onKeyDown:g,restoreLastFocus:v,selected:w,selectionStrategy:x,selectionKeys:S,stickyHeaders:b,tabToSelect:C})=>{let k=oR(w||i),E=(re,se)=>{var Me,kt;(kt=(Me=F.listHandlers).onKeyboardNavigation)==null||kt.call(Me,re,se),y==null||y(re,se)},R=Al((re,se)=>{d&&(lh(se.value)?d(re,se.label):se.value!==null&&d(re,se.value))},[d]),M=Al((re,se)=>{p&&p(re,Array.isArray(se)?se.map(Me=>lh(Me.value)?Me.label:Me.value):se&&(lh(se.value)?se.label:se.value))},[p]),{highlightedIndex:P,listProps:{onKeyDown:I,onMouseMove:V,...B},setHighlightedIndex:W,...O}=xb({containerRef:t,defaultHighlightedIndex:o,disableHighlightOnFocus:a,highlightedIndex:u,indexPositions:e.data,label:h,onHighlight:m,onKeyboardNavigation:E,restoreLastFocus:v,selected:k.current}),N=Mb({collapsibleHeaders:r,highlightedIdx:P,collectionHook:e}),F=Ib({defaultSelected:i,highlightedIdx:P,indexPositions:e.data,label:h,onSelect:R,onSelectionChange:M,selected:w,selectionStrategy:x,selectionKeys:S,tabToSelect:C}),{onKeyDown:G}=Db({disableTypeToSelect:c,highlightedIdx:P,highlightItemAtIndex:W,typeToNavigate:!0,items:e.data}),X=Al(re=>{var se,Me,kt;re.defaultPrevented||G==null||G(re),I(re),re.defaultPrevented||(Me=(se=F.listHandlers).onKeyDown)==null||Me.call(se,re),re.defaultPrevented||(kt=N==null?void 0:N.onKeyDown)==null||kt.call(N,re),re.defaultPrevented||g==null||g(re)},[N,I,g,F.listHandlers,G]),{isScrolling:te,scrollIntoView:_e}=Vb({containerRef:t,contentRef:n,highlightedIdx:P,indexPositions:e.data,stickyHeaders:b}),de=Al(re=>{if(!te.current&&!s){V();let se=Eb(re.target);if(se!==P){let Me=e.data[se];!Me||Me.disabled?W(-1):W(se)}}},[te,s,W,V,P,e.data]),it=()=>{var re;return P===void 0||P===-1||l||(re=e.data[P])==null?void 0:re.id};k.current=F.selected;let On={"aria-activedescendant":it(),onBlur:B.onBlur,onFocus:B.onFocus,onKeyDown:X,onMouseDownCapture:B.onMouseDownCapture,onMouseLeave:B.onMouseLeave},Vt=f||{onClick:F.listHandlers.onClick,onMouseMove:de};return{focusVisible:O.focusVisible,controlledHighlighting:O.controlledHighlighting,highlightedIndex:P,keyboardNavigation:O.keyboardNavigation,listHandlers:Vt,listItemHeaderHandlers:N,listControlProps:On,scrollIntoView:_e,selected:F.selected,setHighlightedIndex:W,setIgnoreFocus:O.setIgnoreFocus,setSelected:F.setSelected}};import{useState as iR,useMemo as sR,useCallback as lR}from"react";import"@salt-ds/core";import"react/jsx-runtime";var Bb=({borderless:r,displayedItemCount:e,getItemHeight:t,height:n,itemCount:o,itemGapSize:i,itemHeight:s,rowHeightRef:l})=>{let[a,c]=iR(36),u=sR(()=>{let f=r?0:2,d=s!=null?s:a,p=Math.min(e,o)||e;return typeof t=="function"?f+=Array(p).fill(0).reduce((m,y,g)=>m+t(g)+i,0)-i:f+=p*Number(d)+(p-1)*i,isNaN(f)?void 0:f},[r,e,t,o,i,s,a]),h=lR(({height:f})=>{c(f)},[]);return Ci(l,hb,h,!0),{preferredHeight:u}};var Hb=`.saltList {
122
122
  --list-background: var(--salt-container-primary-background);
123
123
  --list-borderStyle: var(--salt-container-borderStyle);
124
124
  --list-borderWidth: var(--salt-size-border);
@@ -201,9 +201,9 @@ var Oh=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var T=(r,e,t)=>(Oh(r
201
201
  .saltList.saltFocusVisible:after {
202
202
  inset: 2px;
203
203
  }
204
- `;var pR="No data to display",ki=hR("saltList"),hh=lR(function({ListItem:e=Ti,ListPlaceholder:t,borderless:n,children:o,className:i,collapsibleHeaders:s=!1,defaultHighlightedIndex:l,defaultSelected:a,disabled:c=!1,disableFocus:u=!1,disableTypeToSelect:h,displayedItemCount:f=10,emptyMessage:d,focusVisible:p,getItemHeight:m,getItemId:g,height:y,highlightedIndex:v,id:w,itemGapSize:x=0,itemHeight:S,itemTextHighlightPattern:b,itemToString:C=so,listHandlers:k,maxHeight:E,maxWidth:R,minHeight:N,minWidth:O,onSelect:M,onSelectionChange:D,onHighlight:F,restoreLastFocus:G,selected:A,selectionStrategy:V,checkable:B=V==="multiple",scrollingApiRef:U,selectionKeys:X,showEmptyMessage:ee=!1,source:_e,style:de,stickyHeaders:it,tabToSelect:On,width:Vt,...re},se){let Me=un();hn({testId:"salt-list",css:Bb,window:Me});let Tt=fR(w),ho=uh(null),fo=uh(null),po=uh(null),kt=ab({id:Tt,label:"List",source:_e,children:o,options:{collapsibleHeaders:s,getItemId:g,itemToString:C}}),{preferredHeight:mo}=Fb({borderless:n,displayedItemCount:f,getItemHeight:m,height:y,itemCount:kt.data.length,itemGapSize:x,itemHeight:S,rowHeightRef:po}),{focusVisible:Ql,highlightedIndex:Yl,listControlProps:Z0,listHandlers:ex,listItemHeaderHandlers:tx,scrollIntoView:nx,selected:rx}=Vb({collapsibleHeaders:s,collectionHook:kt,containerRef:ho,contentRef:fo,defaultHighlightedIndex:l,defaultSelected:kt.itemToCollectionItem(a),disabled:c,disableTypeToSelect:h,highlightedIndex:v,label:Tt,listHandlers:k,onSelect:M,onSelectionChange:D,onHighlight:F,restoreLastFocus:G,selected:kt.itemToCollectionItem(A),selectionStrategy:V,selectionKeys:X,stickyHeaders:it,tabToSelect:On});fb({collectionHook:kt,forwardedRef:U,scrollableRef:ho,scrollIntoView:nx});let Dh=p!=null?p:Ql,Lh=function(Ce,st,Je,lt){let Vn=aR(e,{...tx,className:yr("saltListItemHeader",{focusVisible:s&&Dh===Ce.value}),"aria-expanded":lt,"data-idx":s?Ce.value:void 0,"data-highlighted":Ce.value===Yl||void 0,"data-sticky":it,"data-selectable":!1,id:st,key:`header-${Ce.value}`,label:Je});return Ce.value+=1,Vn},ox=m===void 0?()=>S:m;function ix(Nn,Ce,st){var Je;let{disabled:lt,value:Vn,id:go,label:Xl}=Ce,yo=cR(Vn),Di={className:yr({saltHighlighted:st.value===Yl,saltFocusVisible:Dh===st.value}),disabled:lt||c,id:go,item:yo?void 0:(Je=Ce==null?void 0:Ce.value)!=null?Je:void 0,itemHeight:ox(st.value),itemTextHighlightPattern:b,key:go,"data-idx":st.value,label:Xl,role:"option",selected:xb(rx,Ce),showCheckbox:B};Nn.push(yo?uR(Vn,Di):xr(e,{...Di})),st.value+=1}let sx=function(Ce,st,Je){let{count:lt=0,id:Vn,expanded:go,label:Xl=""}=st[Je.value],yo=Lh(Je,Vn,Xl,go),Di=go!==!1?[yo].concat(Ah(st,Je,Je.value+lt)||[]):yo;Ce.push(xr("div",{role:"group",children:Di},Vn))},Ah=(Nn,Ce={value:0},st=Nn.length)=>{let Je=[];for(;Ce.value<st;){let lt=Nn[Ce.value];lt.header?Je.push(Lh(Ce,lt.id,lt.label,lt.expanded===!1)):lt.childNodes?sx(Je,Nn,Ce):ix(Je,lt,Ce)}return Je};function lx(){return d||ee?xr("span",{className:ki("empty-message"),children:d!=null?d:pR}):null}let ax=()=>{if(kt.data.length)return Ah(kt.data);lx()},cx="auto",ux={"--list-item-gap":x?`${x}px`:void 0,minWidth:O,minHeight:N,width:Vt!=null?Vt:"100%",height:y!=null?y:"100%",maxWidth:R!=null?R:Vt,maxHeight:E!=null?E:mo};return iR("div",{"aria-multiselectable":V==="multiple"||V==="extended"||V==="extended-multi-range"||void 0,...re,...ex,...Z0,className:yr(ki(),i,{[ki("borderless")]:n,saltDisabled:c,[ki("collapsible")]:s,saltFocusVisible:Yl===oh}),id:`${Tt}`,ref:dR(ho,se),role:"listbox",style:{...de,...ux},tabIndex:c||u?void 0:0,children:[xr(sh,{ref:po}),kt.data.length===0&&t!==void 0?xr(sR,{children:xr(t,{})}):xr("div",{className:ki("scrollingContentContainer"),ref:fo,style:{height:cx},children:ax()})]})});import{useCallback as y9}from"react";import x9 from"classnames";import{jsx as w9}from"react/jsx-runtime";import Wb,{Suspense as xR,useEffect as vR}from"react";import mR from"react";import{Fragment as gR,jsx as Hb,jsxs as yR}from"react/jsx-runtime";var Ol=class extends mR.Component{constructor(e){super(e),this.state={errorMessage:null}}static getDerivedStateFromError(e){return{errorMessage:e.message}}componentDidCatch(e,t){console.log(`error creating component at ${this.props.url}`),console.log(e,t)}render(){return this.state.errorMessage?yR(gR,{children:[Hb("h1",{children:"An error occured while creating component."}),Hb("p",{children:this.state.errorMessage})]}):this.props.children}};import{jsx as bR}from"react/jsx-runtime";var _b=()=>bR("div",{className:"hwLoader",children:"loading"});var zb=async r=>{let e=new CSSStyleSheet;return fetch(r).then(t=>t.text()).then(t=>e.replace(t))};import{jsx as Vl}from"react/jsx-runtime";var Nl=new Map,wR=r=>{vR(()=>()=>{Nl.delete(r)},[r]),Nl.has(r)||Nl.set(r,Wb.lazy(()=>import(r)));let e=Nl.get(r);if(e)return e;throw Error(`Unable to load Lazy Feature at url ${r}`)};function SR({url:r,css:e,ComponentProps:t,...n}){e&&zb(e).then(i=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,i]});let o=wR(r);return Vl(Ol,{url:r,children:Vl(xR,{fallback:Vl(_b,{}),children:Vl(o,{...n,...t})})})}var fh=Wb.memo(SR);fh.displayName="Feature";ge("Feature",fh,"view");import{useEffect as CR,useState as Mi}from"react";import{Input as TR,Button as $b,FormField as Fl,FormFieldLabel as Bl,Text as kR}from"@salt-ds/core";import{ComboBox as MR,Checkbox as ER,RadioButton as RR}from"@vuu-ui/vuu-ui-controls";import{formatDate as IR,takeScreenshot as PR}from"@vuu-ui/vuu-utils";import{jsx as je,jsxs as Ln}from"react/jsx-runtime";var ot="saveLayoutPanel",Hl=`${ot}-formField`,DR=["Group 1","Group 2","Group 3","Group 4","Group 5"],LR=["Value 1","Value 2","Value 3"],Ub=["Value 1","Value 2","Value 3"],Gb=r=>{let{onCancel:e,onSave:t,componentId:n}=r,[o,i]=Mi(""),[s,l]=Mi(""),[a,c]=Mi([]),[u,h]=Mi(Ub[0]),[f,d]=Mi();CR(()=>{n&&PR(document.getElementById(n)).then(m=>d(m))},[n]);let p=()=>{t({name:o,group:s,screenshot:f!=null?f:"",user:"User",date:IR(new Date,"dd.mm.yyyy")})};return Ln("div",{className:`${ot}-panelContainer`,children:[Ln("div",{className:`${ot}-panelContent`,children:[Ln("div",{className:`${ot}-formContainer`,children:[Ln(Fl,{className:Hl,children:[je(Bl,{children:"Group"}),je(MR,{source:DR,allowFreeText:!0,InputProps:{inputProps:{className:`${ot}-inputText`,placeholder:"Select Group or Enter New Name",onChange:m=>l(m.target.value)}},width:120,onSelectionChange:(m,g)=>l(g||"")})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Layout Name"}),je(TR,{inputProps:{className:`${ot}-inputText`,placeholder:"Enter Layout Name"},onChange:m=>i(m.target.value),value:o})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Some Layout Setting"}),je("div",{className:`${ot}-settingsGroup`,children:LR.map((m,g)=>je(ER,{onToggle:()=>c(y=>y.includes(m)?y.filter(v=>v!==m):[...y,m]),checked:a.includes(m),label:m},g))})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Some Layout Setting"}),je("div",{className:`${ot}-settingsGroup`,children:Ub.map((m,g)=>je(RR,{onClick:()=>h(m),checked:u===m,label:m,groupName:"radioGroup"},g))})]})]}),je("div",{className:`${ot}-screenshotContainer`,children:f?je("img",{className:`${ot}-screenshot`,src:f,alt:"screenshot of current layout"}):je(kR,{className:"screenshot",children:"No screenshot available"})})]}),Ln("div",{className:`${ot}-buttonsContainer`,children:[je($b,{className:`${ot}-cancelButton`,onClick:e,children:"Cancel"}),je($b,{className:`${ot}-saveButton`,onClick:p,disabled:o===""||s==="",children:"Save"})]})]})};import{List as f6}from"@vuu-ui/vuu-ui-controls";import AR,{useState as Z9,useCallback as e6,useContext as OR,useEffect as t6}from"react";import{jsx as l6}from"react/jsx-runtime";var i6=new Sl,NR=AR.createContext({layoutMetadata:[],saveLayout:()=>{},applicationLayout:Bo,saveApplicationLayout:()=>{},loadLayoutById:()=>Bo});var _l=()=>OR(NR);import{Fragment as y6,jsx as g6,jsxs as b6}from"react/jsx-runtime";import{memo as VR}from"react";import{jsx as Ct,jsxs as co}from"react/jsx-runtime";var qb=VR(()=>co("svg",{width:"44",height:"45",viewBox:"0 0 44 45",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[co("g",{clipPath:"url(#clip0_217_6990)",children:[Ct("path",{d:"M39.8642 15.5509L35.9196 7.58974L34.3369 6.85464L24.6235 22.0825L39.1628 30.618L42.3152 25.6347L39.8642 15.5509Z",fill:"url(#paint0_linear_217_6990)"}),Ct("path",{d:"M42.6246 24.8716C41.9199 25.9157 40.9625 26.824 39.767 27.4905C38.424 28.2396 36.9563 28.597 35.5081 28.597C32.7541 28.597 30.0715 27.3094 28.4466 24.9855L15.772 3.90967L15.7655 3.9206C13.3615 0.137431 8.25372 -1.13143 4.24754 1.10507C0.178173 3.37435 -1.20852 8.39359 1.14854 12.3125L18.3445 40.9095C19.1108 42.1846 20.1816 43.1834 21.4144 43.8764C21.4241 43.8826 21.4338 43.8889 21.4435 43.8951C21.4484 43.8982 21.4549 43.9013 21.4597 43.9045C22.0332 44.2228 22.6423 44.471 23.2725 44.6536C23.3194 44.6677 23.368 44.6817 23.415 44.6942C23.6418 44.7551 23.8702 44.8097 24.1019 44.8534C24.1456 44.8612 24.1894 44.8659 24.2331 44.8737C24.4194 44.9049 24.6073 44.9314 24.7952 44.9501C24.8698 44.9579 24.9443 44.9658 25.0188 44.9704C25.2342 44.9876 25.4497 44.9985 25.6668 45.0001C25.6781 45.0001 25.6895 45.0001 25.6992 45.0001C25.7024 45.0001 25.704 45.0001 25.7073 45.0001C25.7105 45.0001 25.7121 45.0001 25.7154 45.0001C25.9503 45.0001 26.1868 44.9876 26.4217 44.9689C26.4751 44.9642 26.5286 44.9595 26.5837 44.9533C26.8137 44.9299 27.0438 44.9002 27.2738 44.8596C27.277 44.8596 27.2803 44.8596 27.2835 44.8596C27.5362 44.8144 27.7889 44.7551 28.0384 44.6864C28.0546 44.6817 28.0692 44.677 28.0854 44.6723C28.4483 44.5709 28.8063 44.4445 29.1594 44.2931C29.1659 44.29 29.174 44.2868 29.1805 44.2837C29.4494 44.1682 29.7151 44.0418 29.9759 43.8967C30.24 43.75 30.491 43.5908 30.7308 43.4206C30.9398 43.2739 31.1407 43.1179 31.3367 42.9524C31.5748 42.7495 31.8 42.5373 32.009 42.3141C32.1661 42.1471 32.3168 41.9723 32.4609 41.7913C32.5079 41.732 32.5517 41.6711 32.5954 41.6118C32.6942 41.4807 32.7882 41.3465 32.8789 41.2091C32.9259 41.1373 32.9728 41.0671 33.0182 40.9953C33.036 40.9672 33.0555 40.9407 33.0717 40.9126L42.7153 24.8763H42.6214L42.6246 24.8716Z",fill:"url(#paint1_linear_217_6990)"}),Ct("path",{d:"M42.8402 16.4218L42.1112 15.2232L38.9636 9.58433L37.504 7.19644C37.2286 6.56123 36.579 6.11331 35.8176 6.11331C34.8083 6.11331 33.9919 6.90147 33.9919 7.87223C33.9919 8.20154 34.0907 8.50432 34.2543 8.76808L34.2349 8.78056L39.9048 18.0808C40.5884 19.2186 40.7715 20.5437 40.4199 21.8141C40.0684 23.0845 39.226 24.1458 38.045 24.806C37.2675 25.2398 36.3846 25.4693 35.4936 25.4693C33.6727 25.4693 31.9766 24.5281 31.0662 23.0143L22.9161 9.63271H22.9323L19.4899 3.90958L19.4834 3.92051C19.4235 3.8253 19.3538 3.73947 19.2907 3.64738L19.1935 3.48663C19.1935 3.48663 19.1854 3.49131 19.1821 3.49443C17.5654 1.27666 14.9799 0.0390178 12.3118 0.00936427V0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.961 26.8255 41.9168 25.9156 42.6231 24.8731H42.717L42.6846 24.9261C43.1366 24.2347 43.4833 23.4731 43.7068 22.6615C44.2916 20.5452 43.9871 18.3352 42.8369 16.4234L42.8402 16.4218Z",fill:"#F37880"}),co("g",{opacity:"0.86",children:[Ct("path",{d:"M34.2332 8.78212L39.9031 18.0824C40.5868 19.2202 40.7698 20.5452 40.4183 21.8156C40.2044 22.5897 39.8059 23.2858 39.2616 23.8617C39.9744 23.2343 40.4879 22.4243 40.7423 21.5035C41.0938 20.2331 40.9107 18.908 40.2271 17.7703L34.5572 8.46998L34.5767 8.4575C34.413 8.19374 34.3142 7.89096 34.3142 7.56165C34.3142 7.15586 34.4584 6.78285 34.6982 6.48476C34.2672 6.80626 33.9902 7.30881 33.9902 7.87379C33.9902 8.2031 34.0891 8.50588 34.2527 8.76964L34.2332 8.78212Z",fill:"white"}),Ct("path",{d:"M42.6917 24.9169L42.6863 24.9256C42.6863 24.9256 42.6899 24.9187 42.6935 24.9152C42.6935 24.9152 42.6935 24.9152 42.6935 24.9169H42.6917Z",fill:"white"}),Ct("path",{d:"M40.0911 27.1798C38.7481 27.9289 37.2804 28.2863 35.8322 28.2863C33.0782 28.2863 30.3955 26.9988 28.7707 24.6749L16.0961 3.59744L16.0896 3.60837C14.9281 1.78077 13.1364 0.543128 11.1422 0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.4815 27.0924 41.1084 26.6055 41.6511 26.0561C41.1862 26.479 40.6662 26.8583 40.0894 27.1798H40.0911Z",fill:"white"})]})]}),co("defs",{children:[co("linearGradient",{id:"paint0_linear_217_6990",x1:"24.6235",y1:"18.7363",x2:"42.3152",y2:"18.7363",gradientUnits:"userSpaceOnUse",children:[Ct("stop",{stopColor:"#4906A5"}),Ct("stop",{offset:"1",stopColor:"#D3423A"})]}),co("linearGradient",{id:"paint1_linear_217_6990",x1:"-2.35794e-05",y1:"22.5009",x2:"42.7186",y2:"22.5009",gradientUnits:"userSpaceOnUse",children:[Ct("stop",{stopColor:"#7C06A5"}),Ct("stop",{offset:"1",stopColor:"#D3423A"})]}),Ct("clipPath",{id:"clip0_217_6990",children:Ct("rect",{width:"44",height:"45",fill:"white"})})]})]}));qb.displayName="VuuLogo";import{Tab as o7,Tabstrip as i7}from"@vuu-ui/vuu-ui-controls";import l7 from"classnames";import{useCallback as f7,useState as d7}from"react";import{jsx as F6,jsxs as B6}from"react/jsx-runtime";import{createContext as FR,isValidElement as BR,cloneElement as HR,useContext as _R}from"react";import zR from"classnames";import{jsx as qR}from"react/jsx-runtime";var WR="medium",$R="salt-theme",UR="light",jb=FR({density:"high",theme:"vuu",themeMode:"light"});var GR=(r,e,t,n)=>{var o;return BR(r)?HR(r,{className:zR((o=r.props)==null?void 0:o.className,`${e}-theme`,`${e}-density-${n}`),"data-mode":t}):(console.warn(`
204
+ `;var yR="No data to display",Mi=pR("saltList"),ch=uR(function({ListItem:e=ki,ListPlaceholder:t,borderless:n,children:o,className:i,collapsibleHeaders:s=!1,defaultHighlightedIndex:l,defaultSelected:a,disabled:c=!1,disableFocus:u=!1,disableTypeToSelect:h,displayedItemCount:f=10,emptyMessage:d,focusVisible:p,getItemHeight:m,getItemId:y,height:g,highlightedIndex:v,id:w,itemGapSize:x=0,itemHeight:S,itemTextHighlightPattern:b,itemToString:C=lo,listHandlers:k,maxHeight:E,maxWidth:R,minHeight:M,minWidth:P,onSelect:I,onSelectionChange:V,onHighlight:B,restoreLastFocus:W,selected:O,selectionStrategy:N,checkable:F=N==="multiple",scrollingApiRef:G,selectionKeys:X,showEmptyMessage:te=!1,source:_e,style:de,stickyHeaders:it,tabToSelect:On,width:Vt,...re},se){let Me=un();hn({testId:"salt-list",css:Hb,window:Me});let kt=mR(w),fo=ah(null),po=ah(null),mo=ah(null),Mt=cb({id:kt,label:"List",source:_e,children:o,options:{collapsibleHeaders:s,getItemId:y,itemToString:C}}),{preferredHeight:go}=Bb({borderless:n,displayedItemCount:f,getItemHeight:m,height:g,itemCount:Mt.data.length,itemGapSize:x,itemHeight:S,rowHeightRef:mo}),{focusVisible:Ql,highlightedIndex:Yl,listControlProps:nx,listHandlers:rx,listItemHeaderHandlers:ox,scrollIntoView:ix,selected:sx}=Fb({collapsibleHeaders:s,collectionHook:Mt,containerRef:fo,contentRef:po,defaultHighlightedIndex:l,defaultSelected:Mt.itemToCollectionItem(a),disabled:c,disableTypeToSelect:h,highlightedIndex:v,label:kt,listHandlers:k,onSelect:I,onSelectionChange:V,onHighlight:B,restoreLastFocus:W,selected:Mt.itemToCollectionItem(O),selectionStrategy:N,selectionKeys:X,stickyHeaders:it,tabToSelect:On});db({collectionHook:Mt,forwardedRef:G,scrollableRef:fo,scrollIntoView:ix});let Ih=p!=null?p:Ql,Ph=function(Ce,st,Je,lt){let Vn=hR(e,{...ox,className:yr("saltListItemHeader",{focusVisible:s&&Ih===Ce.value}),"aria-expanded":lt,"data-idx":s?Ce.value:void 0,"data-highlighted":Ce.value===Yl||void 0,"data-sticky":it,"data-selectable":!1,id:st,key:`header-${Ce.value}`,label:Je});return Ce.value+=1,Vn},lx=m===void 0?()=>S:m;function ax(Nn,Ce,st){var Je;let{disabled:lt,value:Vn,id:yo,label:Xl}=Ce,bo=fR(Vn),Li={className:yr({saltHighlighted:st.value===Yl,saltFocusVisible:Ih===st.value}),disabled:lt||c,id:yo,item:bo?void 0:(Je=Ce==null?void 0:Ce.value)!=null?Je:void 0,itemHeight:lx(st.value),itemTextHighlightPattern:b,key:yo,"data-idx":st.value,label:Xl,role:"option",selected:vb(sx,Ce),showCheckbox:F};Nn.push(bo?dR(Vn,Li):xr(e,{...Li})),st.value+=1}let cx=function(Ce,st,Je){let{count:lt=0,id:Vn,expanded:yo,label:Xl=""}=st[Je.value],bo=Ph(Je,Vn,Xl,yo),Li=yo!==!1?[bo].concat(Dh(st,Je,Je.value+lt)||[]):bo;Ce.push(xr("div",{role:"group",children:Li},Vn))},Dh=(Nn,Ce={value:0},st=Nn.length)=>{let Je=[];for(;Ce.value<st;){let lt=Nn[Ce.value];lt.header?Je.push(Ph(Ce,lt.id,lt.label,lt.expanded===!1)):lt.childNodes?cx(Je,Nn,Ce):ax(Je,lt,Ce)}return Je};function ux(){return d||te?xr("span",{className:Mi("empty-message"),children:d!=null?d:yR}):null}let hx=()=>{if(Mt.data.length)return Dh(Mt.data);ux()},fx="auto",dx={"--list-item-gap":x?`${x}px`:void 0,minWidth:P,minHeight:M,width:Vt!=null?Vt:"100%",height:g!=null?g:"100%",maxWidth:R!=null?R:Vt,maxHeight:E!=null?E:go};return aR("div",{"aria-multiselectable":N==="multiple"||N==="extended"||N==="extended-multi-range"||void 0,...re,...rx,...nx,className:yr(Mi(),i,{[Mi("borderless")]:n,saltDisabled:c,[Mi("collapsible")]:s,saltFocusVisible:Yl===nh}),id:`${kt}`,ref:gR(fo,se),role:"listbox",style:{...de,...dx},tabIndex:c||u?void 0:0,children:[xr(oh,{ref:mo}),Mt.data.length===0&&t!==void 0?xr(cR,{children:xr(t,{})}):xr("div",{className:Mi("scrollingContentContainer"),ref:po,style:{height:fx},children:hx()})]})});import{useCallback as y9}from"react";import x9 from"classnames";import{jsx as w9}from"react/jsx-runtime";import $b,{Suspense as SR,useEffect as CR}from"react";import bR from"react";import{Fragment as xR,jsx as _b,jsxs as vR}from"react/jsx-runtime";var Ol=class extends bR.Component{constructor(e){super(e),this.state={errorMessage:null}}static getDerivedStateFromError(e){return{errorMessage:e.message}}componentDidCatch(e,t){console.log(`error creating component at ${this.props.url}`),console.log(e,t)}render(){return this.state.errorMessage?vR(xR,{children:[_b("h1",{children:"An error occured while creating component."}),_b("p",{children:this.state.errorMessage})]}):this.props.children}};import{jsx as wR}from"react/jsx-runtime";var zb=()=>wR("div",{className:"hwLoader",children:"loading"});var Wb=async r=>{let e=new CSSStyleSheet;return fetch(r).then(t=>t.text()).then(t=>e.replace(t))};import{jsx as Vl}from"react/jsx-runtime";var Nl=new Map,TR=r=>{CR(()=>()=>{Nl.delete(r)},[r]),Nl.has(r)||Nl.set(r,$b.lazy(()=>import(r)));let e=Nl.get(r);if(e)return e;throw Error(`Unable to load Lazy Feature at url ${r}`)};function kR({url:r,css:e,ComponentProps:t,...n}){e&&Wb(e).then(i=>{document.adoptedStyleSheets=[...document.adoptedStyleSheets,i]});let o=TR(r);return Vl(Ol,{url:r,children:Vl(SR,{fallback:Vl(zb,{}),children:Vl(o,{...n,...t})})})}var uh=$b.memo(kR);uh.displayName="Feature";ge("Feature",uh,"view");import{useEffect as MR,useState as Ei}from"react";import{Input as ER,Button as Ub,FormField as Fl,FormFieldLabel as Bl,Text as RR}from"@salt-ds/core";import{ComboBox as IR,Checkbox as PR,RadioButton as DR}from"@vuu-ui/vuu-ui-controls";import{formatDate as LR,takeScreenshot as AR}from"@vuu-ui/vuu-utils";import{jsx as je,jsxs as Ln}from"react/jsx-runtime";var ot="saveLayoutPanel",Hl=`${ot}-formField`,OR=["Group 1","Group 2","Group 3","Group 4","Group 5"],NR=["Value 1","Value 2","Value 3"],Gb=["Value 1","Value 2","Value 3"],qb=r=>{let{onCancel:e,onSave:t,componentId:n}=r,[o,i]=Ei(""),[s,l]=Ei(""),[a,c]=Ei([]),[u,h]=Ei(Gb[0]),[f,d]=Ei();MR(()=>{n&&AR(document.getElementById(n)).then(m=>d(m))},[n]);let p=()=>{t({name:o,group:s,screenshot:f!=null?f:"",user:"User",date:LR(new Date,"dd.mm.yyyy")})};return Ln("div",{className:`${ot}-panelContainer`,children:[Ln("div",{className:`${ot}-panelContent`,children:[Ln("div",{className:`${ot}-formContainer`,children:[Ln(Fl,{className:Hl,children:[je(Bl,{children:"Group"}),je(IR,{source:OR,allowFreeText:!0,InputProps:{inputProps:{className:`${ot}-inputText`,placeholder:"Select Group or Enter New Name",onChange:m=>l(m.target.value)}},width:"100%",onSelectionChange:(m,y)=>l(y||"")})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Layout Name"}),je(ER,{inputProps:{className:`${ot}-inputText`,placeholder:"Enter Layout Name"},onChange:m=>i(m.target.value),value:o})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Some Layout Setting"}),je("div",{className:`${ot}-settingsGroup`,children:NR.map((m,y)=>je(PR,{onToggle:()=>c(g=>g.includes(m)?g.filter(v=>v!==m):[...g,m]),checked:a.includes(m),label:m},y))})]}),Ln(Fl,{className:Hl,children:[je(Bl,{children:"Some Layout Setting"}),je("div",{className:`${ot}-settingsGroup`,children:Gb.map((m,y)=>je(DR,{onClick:()=>h(m),checked:u===m,label:m,groupName:"radioGroup"},y))})]})]}),je("div",{className:`${ot}-screenshotContainer`,children:f?je("img",{className:`${ot}-screenshot`,src:f,alt:"screenshot of current layout"}):je(RR,{className:"screenshot",children:"No screenshot available"})})]}),Ln("div",{className:`${ot}-buttonsContainer`,children:[je(Ub,{className:`${ot}-cancelButton`,onClick:e,children:"Cancel"}),je(Ub,{className:`${ot}-saveButton`,onClick:p,disabled:o===""||s==="",children:"Save"})]})]})};import{List as d6}from"@vuu-ui/vuu-ui-controls";import VR,{useState as Z9,useCallback as e6,useContext as FR,useEffect as t6,useRef as n6}from"react";import{jsx as a6}from"react/jsx-runtime";var s6=new Sl,BR=VR.createContext({layoutMetadata:[],saveLayout:()=>{},applicationLayout:Ho,saveApplicationLayout:()=>{},loadLayoutById:()=>Ho});var _l=()=>FR(BR);import{Fragment as b6,jsx as y6,jsxs as x6}from"react/jsx-runtime";import{memo as HR}from"react";import{jsx as Ct,jsxs as uo}from"react/jsx-runtime";var Kb=HR(()=>uo("svg",{width:"44",height:"45",viewBox:"0 0 44 45",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[uo("g",{clipPath:"url(#clip0_217_6990)",children:[Ct("path",{d:"M39.8642 15.5509L35.9196 7.58974L34.3369 6.85464L24.6235 22.0825L39.1628 30.618L42.3152 25.6347L39.8642 15.5509Z",fill:"url(#paint0_linear_217_6990)"}),Ct("path",{d:"M42.6246 24.8716C41.9199 25.9157 40.9625 26.824 39.767 27.4905C38.424 28.2396 36.9563 28.597 35.5081 28.597C32.7541 28.597 30.0715 27.3094 28.4466 24.9855L15.772 3.90967L15.7655 3.9206C13.3615 0.137431 8.25372 -1.13143 4.24754 1.10507C0.178173 3.37435 -1.20852 8.39359 1.14854 12.3125L18.3445 40.9095C19.1108 42.1846 20.1816 43.1834 21.4144 43.8764C21.4241 43.8826 21.4338 43.8889 21.4435 43.8951C21.4484 43.8982 21.4549 43.9013 21.4597 43.9045C22.0332 44.2228 22.6423 44.471 23.2725 44.6536C23.3194 44.6677 23.368 44.6817 23.415 44.6942C23.6418 44.7551 23.8702 44.8097 24.1019 44.8534C24.1456 44.8612 24.1894 44.8659 24.2331 44.8737C24.4194 44.9049 24.6073 44.9314 24.7952 44.9501C24.8698 44.9579 24.9443 44.9658 25.0188 44.9704C25.2342 44.9876 25.4497 44.9985 25.6668 45.0001C25.6781 45.0001 25.6895 45.0001 25.6992 45.0001C25.7024 45.0001 25.704 45.0001 25.7073 45.0001C25.7105 45.0001 25.7121 45.0001 25.7154 45.0001C25.9503 45.0001 26.1868 44.9876 26.4217 44.9689C26.4751 44.9642 26.5286 44.9595 26.5837 44.9533C26.8137 44.9299 27.0438 44.9002 27.2738 44.8596C27.277 44.8596 27.2803 44.8596 27.2835 44.8596C27.5362 44.8144 27.7889 44.7551 28.0384 44.6864C28.0546 44.6817 28.0692 44.677 28.0854 44.6723C28.4483 44.5709 28.8063 44.4445 29.1594 44.2931C29.1659 44.29 29.174 44.2868 29.1805 44.2837C29.4494 44.1682 29.7151 44.0418 29.9759 43.8967C30.24 43.75 30.491 43.5908 30.7308 43.4206C30.9398 43.2739 31.1407 43.1179 31.3367 42.9524C31.5748 42.7495 31.8 42.5373 32.009 42.3141C32.1661 42.1471 32.3168 41.9723 32.4609 41.7913C32.5079 41.732 32.5517 41.6711 32.5954 41.6118C32.6942 41.4807 32.7882 41.3465 32.8789 41.2091C32.9259 41.1373 32.9728 41.0671 33.0182 40.9953C33.036 40.9672 33.0555 40.9407 33.0717 40.9126L42.7153 24.8763H42.6214L42.6246 24.8716Z",fill:"url(#paint1_linear_217_6990)"}),Ct("path",{d:"M42.8402 16.4218L42.1112 15.2232L38.9636 9.58433L37.504 7.19644C37.2286 6.56123 36.579 6.11331 35.8176 6.11331C34.8083 6.11331 33.9919 6.90147 33.9919 7.87223C33.9919 8.20154 34.0907 8.50432 34.2543 8.76808L34.2349 8.78056L39.9048 18.0808C40.5884 19.2186 40.7715 20.5437 40.4199 21.8141C40.0684 23.0845 39.226 24.1458 38.045 24.806C37.2675 25.2398 36.3846 25.4693 35.4936 25.4693C33.6727 25.4693 31.9766 24.5281 31.0662 23.0143L22.9161 9.63271H22.9323L19.4899 3.90958L19.4834 3.92051C19.4235 3.8253 19.3538 3.73947 19.2907 3.64738L19.1935 3.48663C19.1935 3.48663 19.1854 3.49131 19.1821 3.49443C17.5654 1.27666 14.9799 0.0390178 12.3118 0.00936427V0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.961 26.8255 41.9168 25.9156 42.6231 24.8731H42.717L42.6846 24.9261C43.1366 24.2347 43.4833 23.4731 43.7068 22.6615C44.2916 20.5452 43.9871 18.3352 42.8369 16.4234L42.8402 16.4218Z",fill:"#F37880"}),uo("g",{opacity:"0.86",children:[Ct("path",{d:"M34.2332 8.78212L39.9031 18.0824C40.5868 19.2202 40.7698 20.5452 40.4183 21.8156C40.2044 22.5897 39.8059 23.2858 39.2616 23.8617C39.9744 23.2343 40.4879 22.4243 40.7423 21.5035C41.0938 20.2331 40.9107 18.908 40.2271 17.7703L34.5572 8.46998L34.5767 8.4575C34.413 8.19374 34.3142 7.89096 34.3142 7.56165C34.3142 7.15586 34.4584 6.78285 34.6982 6.48476C34.2672 6.80626 33.9902 7.30881 33.9902 7.87379C33.9902 8.2031 34.0891 8.50588 34.2527 8.76964L34.2332 8.78212Z",fill:"white"}),Ct("path",{d:"M42.6917 24.9169L42.6863 24.9256C42.6863 24.9256 42.6899 24.9187 42.6935 24.9152C42.6935 24.9152 42.6935 24.9152 42.6935 24.9169H42.6917Z",fill:"white"}),Ct("path",{d:"M40.0911 27.1798C38.7481 27.9289 37.2804 28.2863 35.8322 28.2863C33.0782 28.2863 30.3955 26.9988 28.7707 24.6749L16.0961 3.59744L16.0896 3.60837C14.9281 1.78077 13.1364 0.543128 11.1422 0H7.91199V0.02185C10.9851 -0.184164 14.0582 1.23296 15.7656 3.92051L15.7721 3.90958L28.4451 24.987C30.0699 27.3093 32.7542 28.5985 35.5066 28.5985C36.9548 28.5985 38.4225 28.2426 39.7655 27.4919C40.4815 27.0924 41.1084 26.6055 41.6511 26.0561C41.1862 26.479 40.6662 26.8583 40.0894 27.1798H40.0911Z",fill:"white"})]})]}),uo("defs",{children:[uo("linearGradient",{id:"paint0_linear_217_6990",x1:"24.6235",y1:"18.7363",x2:"42.3152",y2:"18.7363",gradientUnits:"userSpaceOnUse",children:[Ct("stop",{stopColor:"#4906A5"}),Ct("stop",{offset:"1",stopColor:"#D3423A"})]}),uo("linearGradient",{id:"paint1_linear_217_6990",x1:"-2.35794e-05",y1:"22.5009",x2:"42.7186",y2:"22.5009",gradientUnits:"userSpaceOnUse",children:[Ct("stop",{stopColor:"#7C06A5"}),Ct("stop",{offset:"1",stopColor:"#D3423A"})]}),Ct("clipPath",{id:"clip0_217_6990",children:Ct("rect",{width:"44",height:"45",fill:"white"})})]})]}));Kb.displayName="VuuLogo";import{Tab as i7,Tabstrip as s7}from"@vuu-ui/vuu-ui-controls";import a7 from"classnames";import{useCallback as d7,useState as p7}from"react";import{jsx as B6,jsxs as H6}from"react/jsx-runtime";import{createContext as _R,isValidElement as zR,cloneElement as WR,useContext as $R}from"react";import UR from"classnames";import{jsx as JR}from"react/jsx-runtime";var GR="medium",qR="salt-theme",KR="light",Jb=_R({density:"high",theme:"vuu",themeMode:"light"});var jR=(r,e,t,n)=>{var o;return zR(r)?WR(r,{className:UR((o=r.props)==null?void 0:o.className,`${e}-theme`,`${e}-density-${n}`),"data-mode":t}):(console.warn(`
205
205
  ThemeProvider can only apply CSS classes for theming to a single nested child element of the ThemeProvider.
206
- Wrap elements with a single container`),r)},Jb=({applyThemeClasses:r=!1,children:e,theme:t,themeMode:n,density:o})=>{var f,d,p;let{density:i,themeMode:s,theme:l}=_R(jb),a=(f=o!=null?o:i)!=null?f:WR,c=(d=n!=null?n:s)!=null?d:UR,u=(p=t!=null?t:l)!=null?p:$R,h=r?GR(e,u,c,a):e;return qR(jb.Provider,{value:{themeMode:c,density:a,theme:u},children:h})};Jb.displayName="ThemeProvider";import{jsx as b7,jsxs as x7}from"react/jsx-runtime";import{useState as R7}from"react";import{Button as P7,FormField as D7,FormFieldLabel as L7,Input as A7}from"@salt-ds/core";import{jsx as V7,jsxs as F7}from"react/jsx-runtime";import{getCookieValue as jR}from"@vuu-ui/vuu-utils";var JR=()=>{let r=jR("vuu-auth-mode");return r!=null?r:""};var QR=()=>JR()==="login"?"login.html":"demo.html",YR=(r=QR())=>{window.location.href=r},Qb=r=>{document.cookie="vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT",document.cookie="vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT",YR(r)};import{useCallback as X7,useEffect as Z7,useMemo as eG,useRef as tG,useState as nG}from"react";import oG from"classnames";import{useIdMemo as sG}from"@salt-ds/core";import{Button as aG}from"@salt-ds/core";import{buildColumnMap as dG,isValidNumber as pG,shallowEquals as mG}from"@vuu-ui/vuu-utils";import{jsx as bG,jsxs as xG}from"react/jsx-runtime";import KK from"classnames";import{useCallback as XK,useEffect as ZK,useRef as ej}from"react";import{useCallback as Bq}from"react";import{Button as oq}from"@salt-ds/core";import{jsx as e0}from"react/jsx-runtime";import{forwardRef as XR}from"react";function Yb(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r))for(e=0;e<r.length;e++)r[e]&&(t=Yb(r[e]))&&(n&&(n+=" "),n+=t);else for(e in r)r[e]&&(n&&(n+=" "),n+=e);return n}function Xb(){for(var r,e,t=0,n="";t<arguments.length;)(r=arguments[t++])&&(e=Yb(r))&&(n&&(n+=" "),n+=e);return n}var Zb=`/* Style applied to the root element */
206
+ Wrap elements with a single container`),r)},Qb=({applyThemeClasses:r=!1,children:e,theme:t,themeMode:n,density:o})=>{var f,d,p;let{density:i,themeMode:s,theme:l}=$R(Jb),a=(f=o!=null?o:i)!=null?f:GR,c=(d=n!=null?n:s)!=null?d:KR,u=(p=t!=null?t:l)!=null?p:qR,h=r?jR(e,u,c,a):e;return JR(Jb.Provider,{value:{themeMode:c,density:a,theme:u},children:h})};Qb.displayName="ThemeProvider";import{jsx as x7,jsxs as v7}from"react/jsx-runtime";import{useState as I7}from"react";import{Button as D7,FormField as L7,FormFieldLabel as A7,Input as O7}from"@salt-ds/core";import{jsx as F7,jsxs as B7}from"react/jsx-runtime";import{getCookieValue as YR}from"@vuu-ui/vuu-utils";var XR=()=>{let r=YR("vuu-auth-mode");return r!=null?r:""};var ZR=()=>XR()==="login"?"login.html":"demo.html",eI=(r=ZR())=>{window.location.href=r},Yb=r=>{document.cookie="vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT",document.cookie="vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT",eI(r)};import{useCallback as Z7,useEffect as eG,useMemo as tG,useRef as nG,useState as rG}from"react";import iG from"classnames";import{useIdMemo as lG}from"@salt-ds/core";import{Button as cG}from"@salt-ds/core";import{buildColumnMap as pG,isValidNumber as mG,shallowEquals as gG}from"@vuu-ui/vuu-utils";import{jsx as xG,jsxs as vG}from"react/jsx-runtime";import jK from"classnames";import{useCallback as ZK,useEffect as ej,useRef as tj}from"react";import{useCallback as Hq}from"react";import{Button as iq}from"@salt-ds/core";import{jsx as t0}from"react/jsx-runtime";import{forwardRef as tI}from"react";function Xb(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r))for(e=0;e<r.length;e++)r[e]&&(t=Xb(r[e]))&&(n&&(n+=" "),n+=t);else for(e in r)r[e]&&(n&&(n+=" "),n+=e);return n}function Zb(){for(var r,e,t=0,n="";t<arguments.length;)(r=arguments[t++])&&(e=Xb(r))&&(n&&(n+=" "),n+=e);return n}var e0=`/* Style applied to the root element */
207
207
  .saltIcon {
208
208
  --icon-color: var(--saltIcon-color, var(--salt-text-secondary-foreground));
209
209
  --icon-size-multiplier: var(--saltIcon-size-multiplier, 1);
@@ -234,7 +234,7 @@ ThemeProvider can only apply CSS classes for theming to a single nested child el
234
234
  .saltIcon:active {
235
235
  --icon-color: var(--saltIcon-color-active, var(--salt-text-secondary-foreground));
236
236
  }
237
- `;var ZR=r=>(...e)=>[r,...e].join("-"),eI=ZR("saltIcon"),tI=1,t0=XR(function({children:e,className:t,size:n=tI,style:o,...i},s){let l=un();hn({testId:"salt-icon",css:Zb,window:l});let a={...o,"--saltIcon-size-multiplier":`${n}`};return e0("svg",{className:Xb(eI(),t),style:a,role:"img",...i,ref:s,children:e0("g",{"aria-hidden":!0,children:e})})});import{jsxs as nI,jsx as n0}from"react/jsx-runtime";import{forwardRef as rI}from"react";var ph=rI(function(e,t){return nI(t0,{"data-testid":"ExportIcon","aria-label":"export",viewBox:"0 0 12 12",ref:t,...e,children:[n0("path",{d:"M5 1H1v10h4v-1H2V2h3V1Z"}),n0("path",{d:"M3 5h5V3l4 3-4 3V7H3V5Z"})]})});import{formatDate as oI}from"@vuu-ui/vuu-utils";import{Button as iI}from"@salt-ds/core";import{forwardRef as sI,useCallback as o0,useEffect as lI,useState as aI}from"react";var r0=async r=>await fetch(`api/vui/${r.username}`,{}).then(t=>t.ok?t.json():null).catch(()=>{console.log("error getting history")});import{jsx as Wl,jsxs as i0}from"react/jsx-runtime";var cI=({lastUpdate:r},{lastUpdate:e})=>e===r?0:e<r?-1:1,uI=r=>Wl(Ti,{...r}),hI=sI(function({loginUrl:e,onNavigate:t,user:n,layoutId:o="latest"},i){let[s,l]=aI([]);lI(()=>{async function h(){let d=(await r0(n)).filter(p=>p.id!=="latest").sort(cI).map(({id:p,lastUpdate:m})=>({lastUpdate:m,id:p,label:`Saved at ${oI(new Date(m),"kk:mm:ss")}`}));console.log({sortedHistory:d}),l(d)}h()},[n]);let a=o0((h,f)=>{f&&t(f.id)},[t]),c=o0(()=>{Qb(e)},[e]),u=s.length===0?null:o==="latest"?s[0]:s.find(h=>h.id===o);return i0("div",{className:"vuuUserPanel",ref:i,children:[Wl(hh,{ListItem:uI,className:"vuuUserPanel-history",onSelect:a,selected:u,source:s}),Wl("div",{className:"vuuUserPanel-buttonBar",children:i0(iI,{"aria-label":"logout",onClick:c,children:[Wl(ph,{})," Logout"]})})]})});import{jsx as aq,jsxs as cq}from"react/jsx-runtime";import gq from"classnames";import{ToggleButton as bq,ToggleButtonGroup as xq,useControlled as vq}from"@salt-ds/core";import{useCallback as Tq}from"react";import{jsx as Eq,jsxs as Rq}from"react/jsx-runtime";import Wq from"classnames";import{jsx as Gq,jsxs as qq}from"react/jsx-runtime";import{logger as fI}from"@vuu-ui/vuu-utils";import{Button as Zq}from"@salt-ds/core";import tK from"classnames";import{useCallback as rK,useMemo as oK}from"react";import{jsx as cK,jsxs as uK}from"react/jsx-runtime";import{jsx as bK,jsxs as xK}from"react/jsx-runtime";import{useCallback as kK,useRef as MK,useState as EK}from"react";import{jsx as IK,jsxs as PK}from"react/jsx-runtime";import{jsx as fj,jsxs as dj}from"react/jsx-runtime";var{error:uj}=fI("Shell");import{createContext as dI,useContext as bj}from"react";import{jsx as wj}from"react/jsx-runtime";var pI={},xj=dI(pI);import{useCallback as s0,useMemo as mI,useState as gI}from"react";import{jsx as yI}from"react/jsx-runtime";var Wj=()=>{let[r,e]=gI(),{saveLayout:t}=_l(),n=s0(()=>{e(void 0)},[]),o=s0(l=>{t(l),e(void 0)},[t]),[i,s]=mI(()=>[(l,a)=>{console.log({options:a});let c=l.split(" "),u=[];return c.includes("main-tab")&&u.push({label:"Save Layout",action:"save-layout",options:a},{label:"Layout Settings",action:"layout-settings",options:a}),u},l=>(console.log("menu action",{action:l}),l.menuId==="save-layout"?(e(yI(Gb,{onCancel:n,onSave:o,componentId:l.options.controlledComponentId})),!0):!1)],[n,o]);return{buildMenuOptions:i,dialogContent:r,handleCloseDialog:n,handleMenuAction:s}};import{forwardRef as LI}from"react";import{isValidNumber as An}from"@vuu-ui/vuu-utils";import{useCallback as vI,useEffect as wI,useMemo as SI,useRef as CI,useState as TI}from"react";import{useCallback as bI,useEffect as l0,useRef as xI}from"react";var vr=new Map,c0=(r,e,t)=>{switch(t){case"height":return e.height;case"clientHeight":return r.clientHeight;case"clientWidth":return r.clientWidth;case"contentHeight":return e.contentHeight;case"contentWidth":return e.contentWidth;case"scrollHeight":return Math.ceil(r.scrollHeight);case"scrollWidth":return Math.ceil(r.scrollWidth);case"width":return e.width;default:return 0}},a0=new ResizeObserver(r=>{for(let e of r){let{target:t,borderBoxSize:n,contentBoxSize:o}=e,i=vr.get(t);if(i){let[{blockSize:s,inlineSize:l}]=n,[{blockSize:a,inlineSize:c}]=o,{onResize:u,measurements:h}=i,f=!1;for(let[d,p]of Object.entries(h)){let m=c0(t,{height:s,width:l,contentHeight:a,contentWidth:c},d);m!==p&&(f=!0,h[d]=m)}f&&u&&u(h)}}});function u0(r,e,t,n=!1){let o=xI(e),i=bI(s=>{let{width:l,height:a}=s.getBoundingClientRect(),{clientWidth:c,clientHeight:u}=s;return o.current.reduce((h,f)=>(h[f]=c0(s,{width:l,height:a,contentHeight:u,contentWidth:c},f),h),{})},[]);l0(()=>{let s=r.current;async function l(){vr.set(s,{measurements:{}});let a=vr.get(s);if(a){let c=i(s);a.measurements=c,a0.observe(s),n&&t(c)}else console.log("%cuseResizeObserver an target expected to be under observation wa snot found. This warrants investigation","font-weight:bold; color:red;")}return s&&(vr.has(s)&&console.log("useResizeObserver attemping to observe same element twice",{target:s}),l()),()=>{s&&vr.has(s)&&(a0.unobserve(s),vr.delete(s))}},[i,r]),l0(()=>{let s=r.current,l=vr.get(s);if(l){if(o.current!==e){o.current=e;let a=i(s);l.measurements=a}l.onResize=t}},[e,i,r,t])}var kI=["clientHeight","clientWidth"],MI=["clientWidth"],EI=["clientHeight"],RI=[],$l=r=>Number.isFinite(r),II={height:"100%",width:"100%"},PI=(r,e)=>An(r)&&An(e)?{height:`${r}px`,width:`${e}px`}:typeof r=="string"&&typeof e=="string"?{height:r,width:e}:II,DI=(r,e)=>{if(An(r)&&An(e))return{height:r,width:e}},h0=({defaultHeight:r=0,defaultWidth:e=0,height:t,onResize:n,width:o})=>{let i=CI(null),[s,l]=TI({css:PI(t,o),inner:DI(t,o),outer:{height:t!=null?t:"100%",width:o!=null?o:"100%"}}),a=typeof t=="number",c=typeof o=="number",u=a&&c?RI:a?MI:c?EI:kI;SI(()=>{l(f=>{let{inner:d,outer:p}=f;if(An(t)&&An(o)&&d&&p){let{height:m,width:g}=d,{height:y,width:v}=p;if(y!==t||v!==o){let w=An(y)?y-m:0,x=An(v)?v-g:0;return{...f,outer:{height:t,width:o},inner:{height:t-w,width:o-x}}}}return f})},[t,o]);let h=vI(({clientWidth:f,clientHeight:d})=>{let{css:p,inner:m,outer:g}=s,y=s;a&&$l(f)&&f!==(m==null?void 0:m.width)?y={css:p,outer:g,inner:{width:Math.floor(f)||e,height:t}}:c&&$l(d)&&d!==(m==null?void 0:m.height)?y={css:p,outer:g,inner:{height:Math.floor(d)||r,width:o}}:$l(d)&&$l(f)&&(f!==(m==null?void 0:m.width)||d!==(m==null?void 0:m.height))&&(y={css:p,outer:g,inner:{width:Math.floor(f)||e,height:Math.floor(d)||r}}),y!==s&&l(y)},[r,e,a,c,t,s,o]);return wI(()=>{s.inner&&(n==null||n(s.inner))},[n,s.inner]),u0(i,u,h,!0),{containerRef:i,cssSize:s.css,outerSize:s.outer,innerSize:s.inner}};import{useForkRef as AI}from"@salt-ds/core";import f0 from"classnames";import{jsx as d0}from"react/jsx-runtime";var mh="vuuMeasuredContainer",yJ=LI(function({children:e,className:t,height:n,onResize:o,style:i,width:s,...l},a){let{containerRef:c,...u}=h0({height:n,onResize:o,width:s}),{cssSize:h,innerSize:f}=u,d=f===void 0,p=()=>d?{"--measured-css-height":`${h.height}`,"--measured-css-width":`${h.width}`}:{...i,"--measured-css-height":`${h.height}`,"--measured-css-width":`${h.width}`,"--measured-px-height":`${f==null?void 0:f.height}px`,"--measured-px-width":`${f==null?void 0:f.width}px`},m=AI(c,a);return d?d0("div",{...l,className:f0(mh,`${mh}-ummeasured`),style:p(),ref:c}):d0("div",{...l,className:f0(mh,t),ref:m,style:p(),children:e})});import{PopupMenu as YI}from"@vuu-ui/vuu-popups";import ql from"classnames";import XI,{forwardRef as ZI}from"react";import{useDragDropNext as KI}from"@vuu-ui/vuu-ui-controls";import{isValidNumber as jI,MEASURES as JI}from"@vuu-ui/vuu-utils";import{useCallback as Gl,useMemo as bh,useRef as C0,useState as QI}from"react";import{getElementByDataIndex as p0}from"@vuu-ui/vuu-utils";var OI=".vuuOverflowContainer-item:not(.wrapped)",NI=r=>r.sort((e,t)=>{let{dataset:{index:n="?"}}=e,{dataset:{index:o="?"}}=t,i=e.classList.contains("wrapped"),s=t.classList.contains("wrapped"),l=n==="overflow",a=o==="overflow";return i&&!s?1:!i&&s?-1:l?1:a?-1:parseInt(n)>parseInt(o)?1:-1}),gh=[],Ei=(r,e="horizontal")=>{let t=[],n=[],o=-1,i=!1,s=NI(Array.from(r.children)),l=e==="vertical"?"top":"left";for(let a of s){let c=a,{dataset:{index:u="?",label:h="?",overflowPriority:f="0"}}=c,{[l]:d}=c.getBoundingClientRect();d<=o?(u==="overflow"?n.push(t.pop()):n.push({index:u,label:h,overflowPriority:f}),i=!0):i?n.push({index:u,label:h,overflowPriority:f}):t.push({index:u,label:h,overflowPriority:f}),o=d}return[t,n]},m0=(r,e)=>{let t=!1;e.find(({index:n})=>n==="overflow")&&e.length===1&&(t=!0);for(let n of r.children){let{dataset:{index:o="?"}}=n;e.length===0||t?r.classList.remove("overflowed"):r.classList.add("overflowed"),o!=="overflow"&&e.find(i=>i.index===o)?n.classList.add("wrapped"):n.classList.remove("wrapped")}},VI=(r,{overflowPriority:e})=>Math.max(r,parseInt(e)),FI=(r,{overflowPriority:e})=>Math.min(r,parseInt(e)),g0=r=>{var e;return r.length>1&&((e=r.at(-1))==null?void 0:e.index)==="overflow"},BI=r=>{let[e]=r;for(let t=1;t<r.length;t++){let n=r[t];parseInt(n.overflowPriority)>parseInt(e.overflowPriority)&&(e=n)}return e},y0=(r,e)=>{var o;let t=r.reduce(FI,Number.MAX_SAFE_INTEGER);return e.reduce(VI,0)>t?!0:e.length>1&&((o=e.at(-1))==null?void 0:o.index)==="overflow"},b0=(r,e)=>new Promise(t=>{requestAnimationFrame(()=>{let[,n]=Ei(r);zI(e,n).forEach(i=>HI(r,i)),t(n)})}),x0=(r,e,t)=>new Promise(n=>{requestAnimationFrame(()=>{let[,o]=Ei(r),i=BI(o);if(i){let[s,l]=yh(r,i);n([s,l])}else n([e,t])})}),HI=(r,e)=>{let t=p0(r,e.index);if(t)t.classList.add("wrapped");else throw Error(`markElementAsWrapped element item with index ${e.index} not found`)},_I=r=>Array.from(r.querySelectorAll(".wrapped")),zI=(r,e)=>{let t=[];for(let n of e)r.find(({index:o})=>o===n.index)||t.push(n);return t},WI=(r,e)=>{_I(r).forEach(n=>{let{dataset:{index:o="?"}}=n;e.find(i=>i.index===o)||n.classList.remove("wrapped")})},v0=r=>r.querySelector('[data-index="overflow"]'),$I=r=>r.querySelector(".wrapped"),Ul=r=>parseInt(getComputedStyle(r).getPropertyValue("width")),w0=(r,e)=>{let{right:t}=r.getBoundingClientRect(),n=parseInt(getComputedStyle(r).getPropertyValue("padding-right")),{right:o}=e.getBoundingClientRect();return t-n-o},S0=r=>{let e=v0(r),t=w0(r,e),n=Ul(e),o=$I(r);return Ul(o)<=t+n?(r.classList.remove("overflowed"),o.classList.remove("wrapped"),!0):!1},UI=(r,e)=>{let{dataset:{index:t="0",overflowPriority:n="0"}}=r,{dataset:{index:o="0",overflowPriority:i="0"}}=e;return n>i?-1:n<i?1:parseInt(t)-parseInt(o)},GI=r=>Array.from(r.querySelectorAll(OI)).sort(UI),yh=(r,e)=>{let t=GI(r),n=p0(r,e.index,!0),o=-1,i=t.at(o),s=Ul(i),l=Ul(n),a=v0(r),c=w0(r,a)+s;if(c>=l)qI(n,i);else{let{left:f}=i.getBoundingClientRect(),d=c,p=[i];for(;c<l;){o-=1,i=t.at(o),p.push(i);let{left:m}=i.getBoundingClientRect(),g=f-m;c=d+g}n==null||n.classList.remove("wrapped"),p.forEach(m=>{m.classList.add("wrapped")})}let[u,h]=Ei(r);return WI(r,h),[u,h]},qI=(r,e)=>{if(!r||!e)throw Error("switchWrapOnElements, element undefined");r.classList.remove("wrapped"),e.classList.add("wrapped")};var T0=({allowDragDrop:r=!1,itemCount:e,onMoveItem:t,onSwitchWrappedItemIntoView:n,orientation:o="horizontal"})=>{let[i,s]=QI(null),l=C0(gh),a=C0(null),c=Gl(w=>{var x;a.current&&((x=a.current.querySelector(".vuuOverflowContainer-OverflowIndicator button"))==null||x.setAttribute("tabindex",w))},[]),u=Gl(async()=>{if(i){let[w,x]=Ei(i,o);for(m0(i,x),g0(x)&&(x=await b0(i,x));y0(w,x);)[w,x]=await x0(i,w,x);x.length===1&&S0(i)&&(x=gh),l.current.length===0&&x.length>0?c("0"):l.current.length>0&&x.length===0&&c("-1"),l.current=x}},[i,o,c]),h=w=>typeof w=="object"&&w!==null&&"overflowItem"in w,[f,d]=bh(()=>[()=>{let{current:w}=l;return w.map(x=>({label:x.label,action:`activate-item-${x.index}`,options:{overflowItem:x}}))},({options:w})=>{if(i&&h(w)){let[,x]=yh(i,w.overflowItem);l.current=x,n==null||n(w.overflowItem)}return!0}],[i,n]),p=bh(()=>{let{sizeProp:w}=JI[o],x=0;return new ResizeObserver(S=>{for(let b of S){let{[w]:C}=b.contentRect,k=Math.round(C);jI(k)&&x!==k&&(x=k,u())}})},[u,o]);Xh(()=>{u()},[u,e]),bh(()=>{i&&p.observe(i)},[i,p]);let m=Gl(w=>{s(a.current=w)},[]),g=Gl((w,x)=>{t==null||t(w,x)},[t]),{onMouseDown:y,...v}=KI({allowDragDrop:r,containerRef:a,draggableClassName:"vuuOverflowContainer",onDrop:g,orientation:"horizontal",itemQuery:".vuuOverflowContainer-item"});return{menuActionHandler:d,menuBuilder:f,onItemMouseDown:y,rootRef:m,...v}};import{jsx as Ri,jsxs as eP}from"react/jsx-runtime";var uo="vuuOverflowContainer",k0=XI.memo(({allowDragDrop:r,children:e,className:t,height:n,id:o,onMoveItem:i,onSwitchWrappedItemIntoView:s,orientation:l="horizontal",overflowIcon:a,overflowPosition:c="end"})=>{let u=wr(e),{draggable:h,draggedItemIndex:f,menuActionHandler:d,menuBuilder:p,onItemMouseDown:m,rootRef:g}=T0({allowDragDrop:r,itemCount:u.length,onMoveItem:i,onSwitchWrappedItemIntoView:s,orientation:l}),v={"--overflow-container-height":`${l==="vertical"?"100%":`${n}px`}`},w=ql(`${uo}-wrapContainer`,t,{[`${uo}-horizontal`]:l==="horizontal",[`${uo}-vertical`]:l==="vertical"}),x=u.map((b,C)=>{let{"data-align":k,"data-overflow-priority":E="0",id:R=`${o}-${C}`,label:N=`Item ${C+1}`}=b.props;return Ri("div",{className:ql(`${uo}-item`,{"vuuDraggable-dragAway":f===C}),"data-index":C,"data-align":k,"data-label":N,"data-overflow-priority":E,id:`${R}-wrapper`,onMouseDown:m,children:b},C)}),S=Ri("div",{className:`${uo}-OverflowIndicator`,"data-index":"overflow",children:Ri(YI,{icon:a,menuBuilder:p,menuActionHandler:d,tabIndex:-1})},"overflow");return x.push(S),eP("div",{className:w,ref:g,style:v,children:[x,h]})});k0.displayName="OverflowContainer.InnerContainer";var M0=ZI(function({allowDragDrop:e=!1,children:t,className:n,height:o=44,id:i,onMoveItem:s,onSwitchWrappedItemIntoView:l,orientation:a,overflowIcon:c,overflowPosition:u,...h},f){let d=Sr(i);return Ri("div",{...h,className:ql(ql(uo,n)),id:d,ref:f,children:Ri(k0,{allowDragDrop:e,height:o,id:d,orientation:a,overflowIcon:c,overflowPosition:u,onMoveItem:s,onSwitchWrappedItemIntoView:l,children:t})})});import{uuid as tP}from"@vuu-ui/vuu-utils";import{List as nP,ListItem as rP}from"@vuu-ui/vuu-ui-controls";import E0 from"classnames";import{cloneElement as oP,memo as iP}from"react";import{jsx as xh}from"react/jsx-runtime";var sP=r=>{let e=r.cloneNode(!0);return e.id="",delete e.dataset.idx,e},dh=iP(({className:r,children:e,idx:t,resizeable:n,header:o,closeable:i,...s})=>xh(rP,{className:E0("vuuPaletteItem",r),"data-draggable":!0,"data-icon":"draggable",...s}));dh.displayName="PaletteItem";var Kb=({children:r,className:e,itemHeight:t=41,orientation:n="horizontal",ViewProps:o,...i})=>{let s=ut(),l="vuuPalette";function a(c){var k,E;let h=c.target.closest(".vuuPaletteItem"),f=parseInt((E=(k=h.dataset)==null?void 0:k.index)!=null?E:"-1"),{props:{caption:d,children:p,template:m,...g}}=r[f],{height:y,left:v,top:w,width:x}=h.getBoundingClientRect(),S=tP(),C=m?p:xh(qn,{...o,...{id:S,key:S},...g,title:g.label,children:p});s({dragRect:{left:v,top:w,right:v+x,bottom:w+150,width:x,height:y},dragElement:sP(h),evt:c.nativeEvent,instructions:{DoNotRemove:!0,DoNotTransform:!0,DriftHomeIfNoDropTarget:!0,RemoveDraggableOnDragEnd:!0,dragThreshold:10},path:"*",payload:C,type:"drag-start"})}return xh(nP,{...i,className:E0(l,e,`${l}-${n}`),itemHeight:t,selected:null,children:r.map((c,u)=>c.type===dh?oP(c,{key:u,onMouseDown:a}):c)})};ge("Palette",Kb,"view");import{Tab as lP,Tabstrip as aP}from"@vuu-ui/vuu-ui-controls";import R0 from"classnames";import vh,{forwardRef as cP,useCallback as uP}from"react";import{jsx as P0,jsxs as mP}from"react/jsx-runtime";var I0="Tabs",hP=()=>{},fP=(r,e)=>{var t,n,o,i;return(i=(o=(t=r.props)==null?void 0:t.title)!=null?o:(n=r.props)==null?void 0:n["data-tab-title"])!=null?i:`Tab ${e+1}`},dP=r=>{let e=[];return vh.Children.forEach(r,t=>{vh.isValidElement(t)?e.push(t):console.warn("Stack has unexpected child element type")}),e},pP={allowAddTab:!1,allowCloseTab:!1,allowRenameTab:!1},zl=cP(function({active:e=0,children:t,className:n,getTabIcon:o=hP,getTabLabel:i=fP,id:s,keyBoardActivation:l="manual",onAddTab:a,onMoveTab:c,onTabClose:u,onTabEdit:h,onTabSelectionChanged:f,showTabs:d="top",style:p,TabstripProps:m=pP},g){var N;let y=Sr(s),{allowCloseTab:v,allowRenameTab:w,className:x}=m,S=uP((O,M,D,F)=>{h==null||h(F,M)},[h]),b=()=>{var O;return vh.isValidElement(t)?t:Array.isArray(t)&&(O=t[e])!=null?O:null},C=()=>dP(t).map((O,M)=>{let{closeable:D=v,id:F=`${y}-${M}`,"data-tab-location":G}=O.props;return P0(lP,{ariaControls:F,"data-icon":o(O,M),id:`${F}-tab`,index:M,label:i(O,M),location:G,closeable:D,editable:w},F)}),k=b(),E=d==="left"||d==="right",R=E?"vertical":"horizontal";return mP("div",{className:R0(I0,n,{[`${I0}-horizontal`]:E}),style:p,id:y,ref:g,children:[d?P0(aP,{...m,activeTabIndex:(N=m==null?void 0:m.activeTabIndex)!=null?N:k===null?-1:e,allowDragDrop:m.allowDragDrop!==!1,animateSelectionThumb:!0,className:R0("vuuTabHeader",x),keyBoardActivation:l,onActiveChange:f,onAddTab:a,onCloseTab:u,onExitEditMode:S,onMoveTab:c,orientation:R,children:C()}):null,k]})});zl.displayName="Stack";import{useIdMemo as gP}from"@salt-ds/core";import yP,{useCallback as wh,useRef as bP}from"react";import{jsx as Sh}from"react/jsx-runtime";var xP=r=>Sh(qn,{resizeable:!0,title:`Tab ${r}`,style:{flexGrow:1,flexShrink:0,flexBasis:0},header:!0,closeable:!0,children:Sh(ta,{style:{flex:1}})}),D0=r=>{var S;let e=bP(null),t=ut(),{loadState:n}=kr(),{createNewChild:o,id:i,onTabSelectionChanged:s,path:l,...a}=r,{children:c}=r,u=gP(i),[h]=is(u,e,l),f=gd(),d=(S=o!=null?o:f)!=null?S:xP,p=b=>{l&&(t({type:"switch-tab",id:u,path:l,nextIdx:b}),s==null||s(b))},m=wh(b=>{if(Array.isArray(c)){let{props:{"data-path":C,path:k=C}}=c[b];t({type:"remove",path:k})}},[c,t]),g=wh(()=>{if(l){let b=yP.Children.count(c),C=d(b);t({type:"add",path:l,component:C})}},[c,d,t,l]),y=wh((b,C)=>{l&&t({fromIndex:b,toIndex:C,path:l,type:"move-child"})},[t,l]);return Sh(zl,{...a,id:u,getTabLabel:(b,C)=>{let{id:k,title:E}=b.props;return n(k,"view-title")||E||`Tab ${C+1}`},onMouseDown:async(b,C)=>{let k;await h({type:"mousedown",index:C,preDragActivity:async()=>new Promise(N=>{console.log("preDragActivity: Ok, gonna release the drag"),k=N})},b)&&(k==null||k(void 0))},onMoveTab:y,onAddTab:g,onTabClose:m,onTabEdit:(b,C)=>{t({type:"set-title",path:`${l}.${b}`,title:C})},onTabSelectionChanged:p,ref:e})};D0.displayName="Stack";ge("Stack",D0,"container");import kh from"classnames";import HP,{useMemo as _P,useRef as zP}from"react";import{isValidNumber as FP}from"@vuu-ui/vuu-utils";import{useCallback as Th,useRef as BP}from"react";import{useControlled as SP}from"@salt-ds/core";import{dispatchMouseEvent as CP,getFocusableElement as TP}from"@vuu-ui/vuu-utils";import{useCallback as Nt,useRef as Ch,useState as A0}from"react";import{ArrowDown as F0,ArrowUp as kP,ArrowLeft as MP,ArrowRight as EP,Home as O0,End as N0}from"@vuu-ui/vuu-utils";import{getElementDataIndex as vP}from"@vuu-ui/vuu-utils";var wP=(r,e)=>{if(r){let t=r.querySelector(`[data-index]:has(${e})`);return vP(t)}return-1};var L0=r=>wP(r,".vuuEditableLabel-editing");var B0={horizontal:{[O0]:"start",[N0]:"end",[MP]:"bwd",[EP]:"fwd"},vertical:{[O0]:"start",[N0]:"end",[kP]:"bwd",[F0]:"fwd"}},RP=(r,e="horizontal")=>B0[e][r]!==void 0,IP=r=>r===F0;function V0(r,e,t){return e==="start"?0:e==="end"?r-1:e==="bwd"?t>0?t-1:t:t===null?0:t===r-1?t:t+1}var PP=r=>r!==null&&!r.classList.contains("wrapped"),Ii=(r,e)=>r?r.querySelector(`[data-index="${e}"]`):null,H0=({containerRef:r,defaultHighlightedIdx:e=-1,highlightedIdx:t,keyBoardActivation:n,orientation:o,selectedIndex:i=[]})=>{let s=n==="manual",l=Ch(!1),a=Ch(-1),[c,u]=A0(!1),[,h]=A0({}),[f,d]=SP({controlled:t,default:e,name:"UseKeyboardNavigation"}),p=Nt(M=>{d(a.current=M)},[d]),m=Ch(!1),g=Nt((M,D=!1,F,G=70)=>{p(M),F===!0&&!m.current&&(m.current=!0);let A=()=>{let V=Ii(r.current,M);if(V){let B=TP(V);B==null||B.focus()}};D?A():setTimeout(A,G)},[r,p]),y=M=>{if(a.current===-1&&M.target.tabIndex!==-1){let D=L0(r.current);D!==-1?requestAnimationFrame(()=>{p(D)}):setTimeout(()=>{let[F=null]=i;a.current===-1&&F!==null&&p(F)},200)}},v=Nt(()=>{var M,D;return(D=(M=r.current)==null?void 0:M.querySelectorAll("[data-index]").length)!=null?D:0},[r]),w=Nt((M="fwd",D)=>{let F=v(),A=V0(F,M,typeof D=="number"?D:F),V=M==="start"?"fwd":M==="end"?"bwd":M;for(;(V==="fwd"&&A<F||V==="bwd"&&A>0)&&!PP(Ii(r.current,A));){let B=V0(F,V,A);if(B===A)break;A=B}return A},[r,v]),x=Nt((M,D=!1)=>{let F=B0[o][M.key],G=w(F,f);G!==f?s&&g(G,!0):D&&h({})},[f,s,w,g,o]),S=Nt(()=>{let M=Ii(r.current,f);return M?M.querySelector(".vuuPopupMenu")!=null:!1},[r,f]),b=Nt(()=>{let M=Ii(r.current,f);return M?M.querySelector(".vuuEditableLabel-input")!=null:!1},[r,f]),C=Nt(()=>{let M=Ii(r.current,f),D=M==null?void 0:M.querySelector(".vuuPopupMenu");return D&&CP(D,"click"),!1},[r,f]),k=Nt(M=>{v()>0&&RP(M.key,o)?(M.preventDefault(),m.current?x(M):(m.current=!0,x(M,!0))):IP(M.key)&&S()&&!b()&&C()},[C,v,S,b,x,o]),E=(M,D)=>{p(D)},R=Nt(()=>{c||(u(!0),l.current?l.current=!1:m.current=!0)},[c]),N=Nt(()=>{c||(l.current=!0),m.current=!1},[c]);return{containerProps:{onBlur:M=>{let D=M.target.closest(".vuuTabstrip"),F=M.relatedTarget;D&&!(D!=null&&D.contains(F))&&(p(-1),u(!1))},onMouseDownCapture:N,onFocus:R,onMouseLeave:()=>{m.current=!0,p(-1),l.current=!1}},focusVisible:m.current?f:-1,focusIsWithinComponent:c,highlightedIdx:f,focusItem:g,onClick:E,onFocus:y,onKeyDown:k,setHighlightedIdx:p}};import{isSelectableElement as _0,getClosestIndexItem as DP}from"@vuu-ui/vuu-utils";import{allowMultipleSelection as LP,deselectionIsAllowed as z0,selectionIsDisallowed as AP,useControlled as OP}from"@vuu-ui/vuu-ui-controls";import{useCallback as Pi}from"react";var NP=["Enter"," "],VP={},W0=({containerRef:r,defaultSelected:e,highlightedIdx:t,itemQuery:n,onSelectionChange:o,selected:i,selectionStrategy:s})=>{let[l,a,c]=OP({controlled:i,default:e!=null?e:[],name:"useSelection",state:"selected"}),u=Pi(g=>NP.includes(g.key),[]),h=Pi((g,y=!1)=>{let v=LP(s,y)?l.concat(g):[g];a(v),o==null||o(v)},[o,l,s,a]),f=Pi((g,y=!1)=>{let v=s==="deselectable"||s==="multiple-special-key"&&!y?[]:l.filter(w=>w!==g);a(v),o==null||o(v)},[o,l,s,a]),d=Pi(g=>{u(g)&&_0(g.target)&&(l.includes(t)?z0(s)&&(g.stopPropagation(),g.preventDefault(),f(t,g.shiftKey)):(g.stopPropagation(),g.preventDefault(),h(t,g.shiftKey)))},[u,l,t,s,h,f]),p=Pi((g,y)=>{let v=DP(g.target);_0(v)&&(l.includes(y)?z0(s)&&f(y,g.shiftKey):h(y,g.shiftKey))},[f,h,l,s]),m=AP(s)?VP:{onClick:p,onKeyDown:d};return{activateItem:h,itemHandlers:m,isControlled:c,selected:l}};var $0=({activeItemIndex:r,defaultActiveItemIndex:e,containerRef:t,itemQuery:n="vuuToolbarItem",onActiveChange:o,orientation:i,selectionStrategy:s})=>{var b;let l=BP(r),{focusItem:a,highlightedIdx:c,onClick:u,onKeyDown:h,setHighlightedIdx:f,...d}=H0({containerRef:t,keyBoardActivation:"manual",orientation:i,selectedIndex:(b=l.current)!=null?b:[]}),{activateItem:p,itemHandlers:{onClick:m,onKeyDown:g},selected:y}=W0({containerRef:t,defaultSelected:e,highlightedIdx:c,itemQuery:n,onSelectionChange:o,selected:r,selectionStrategy:s});l.current=y;let v=Th(C=>{var R;let E=C.target.closest("[data-index]");if(E){let N=parseInt((R=E.dataset.index)!=null?R:"-1");N!==-1&&FP(N)&&(u(C,N),m==null||m(C,N))}},[u,m]),w=Th(C=>{h(C),C.defaultPrevented||g==null||g(C)},[h,g]),x=Th(C=>{let k=parseInt(C.index);isNaN(k)||p(k)},[p]),S={onClick:v,onFocus:d.onFocus,onKeyDown:w};return{activeItemIndex:y,focusVisible:d.focusVisible,containerProps:{...d.containerProps,onSwitchWrappedItemIntoView:x},itemProps:S}};import{forwardCallbackProps as WP}from"@vuu-ui/vuu-ui-controls";import{jsx as $P}from"react/jsx-runtime";var Mh="vuuToolbar",aT=({activeItemIndex:r,defaultActiveItemIndex:e,children:t,className:n,id:o,onActiveChange:i,orientation:s="horizontal",selectionStrategy:l="none",...a})=>{let c=zP(null),{activeItemIndex:u,focusVisible:h,itemProps:f,...d}=$0({activeItemIndex:r,defaultActiveItemIndex:e,containerRef:c,onActiveChange:i,orientation:s,selectionStrategy:l}),p=Sr(o),m=kh(Mh,`${Mh}-${s}`,n),g=_P(()=>wr(t).map((y,v)=>{let{id:w=`${p}-tab-${v}`,className:x,...S}=y.props,b=u.includes(v);return HP.cloneElement(y,{...WP(S,f),className:kh("vuuToolbarItem",x,{vuuFocusVisible:h===v}),"data-overflow-priority":b?"1":void 0,id:w,key:v,"aria-selected":b,tabIndex:b?0:-1})}),[u,t,h,p,f]);return $P(M0,{...a,...d.containerProps,className:kh(Mh,m),...a,ref:c,children:g})};import U0,{useState as G0}from"react";import{jsx as Eh,jsxs as q0}from"react/jsx-runtime";var $Y=({children:r})=>{let[t,n]=G0(r),[o,i]=G0(r),s=a=>{let c=Jh(t,a);i(c)},l=(a,c)=>{console.log(`change ${a} -> ${c}`);let u=U0.cloneElement(o,{style:{...o.props.style,[a]:c}});i(u),n(U0.cloneElement(t,{},u))};return q0("div",{"data-design-mode":`${!1}`,children:[t,Eh("br",{}),q0("div",{style:{display:"flex"},children:[Eh(K0,{height:300,managedStyle:o.props.style,width:300,onChange:l,style:void 0}),Eh(j0,{layout:t,onSelect:s,style:{width:300,height:300,backgroundColor:"#ccc"}})]})]})};import{FormField as Kl,Input as jl}from"@salt-ds/core";import{jsx as Le,jsxs as Ih}from"react/jsx-runtime";var Ph={},UP={margin:{top:"marginTop",right:"marginRight",bottom:"marginBottom",left:"marginLeft"},border:{top:"borderTopWidth",right:"borderRightWidth",bottom:"borderBottomWidth",left:"borderLeftWidth"},padding:{top:"paddingTop",right:"paddingRight",bottom:"paddingBottom",left:"paddingLeft"}},Rh=({feature:r,children:e,style:t,onChange:n})=>Ih("div",{className:`LayoutBox layout-${r} layout-outer`,children:[Ih("div",{className:"layout-top",children:[Le("span",{className:"layout-title",children:r}),Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.top,onChange:(o,i)=>n(r,"top",i)})})]}),Ih("div",{className:"layout-inner",children:[Le("div",{className:"layout-left",children:Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.left,onChange:(o,i)=>n(r,"left",i)})})}),e,Le("div",{className:"layout-right",children:Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.right,onChange:(o,i)=>n(r,"right",i)})})})]}),Le("div",{className:"layout-bottom",children:Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.bottom,onChange:(o,i)=>n(r,"bottom",i)})})})]}),XY={margin:!0,marginTop:!0,marginRight:!0,marginBottom:!0,marginLeft:!0},ZY={padding:!0,paddingTop:!0,paddingRight:!0,paddingBottom:!0,paddingLeft:!0},eX={border:!0,borderColor:!0,borderWidth:!0,borderTopWidth:!0,borderRightWidth:!0,borderBottomWidth:!0,borderLeftWidth:!0},Jl="(\\d+)(?:px)?",GP=`^(?:${Jl}(?:\\s${Jl}(?:\\s${Jl}(?:\\s${Jl})?)?)?)$`,J0=new RegExp(GP),qP=/^(?:(\d+)(?:px)\ssolid\s([a-zA-Z,0-9().]+))$/,K0=({height:r,managedStyle:e,onChange:t,style:n,width:o})=>{let i=Q0(e),s=(w,x,S)=>{let b=parseInt(S||"0",10),C=UP[w][x];t(C,b)},{marginTop:l=0,marginRight:a=0,marginBottom:c=0,marginLeft:u=0}=i,{borderTopWidth:h=0,borderRightWidth:f=0,borderBottomWidth:d=0,borderLeftWidth:p=0}=i,{paddingTop:m=0,paddingRight:g=0,paddingBottom:y=0,paddingLeft:v=0}=i;return Le("div",{className:"LayoutConfigurator",style:{width:o,height:r,...n},children:Le(Rh,{feature:"margin",style:{top:l,right:a,bottom:c,left:u},onChange:s,children:Le(Rh,{feature:"border",style:{top:h,right:f,bottom:d,left:p},onChange:s,children:Le(Rh,{feature:"padding",style:{top:m,right:g,bottom:y,left:v},onChange:s,children:Le("div",{className:"layout-content"})})})})})};function tX(r=Ph,e=Ph){let{margin:t,marginTop:n,marginRight:o,marginBottom:i,marginLeft:s,padding:l,paddingTop:a,paddingRight:c,paddingBottom:u,paddingLeft:h,...f}=r;if(typeof t=="number")f.marginTop=f.marginRight=f.marginBottom=f.marginLeft=t;else if(typeof t=="string"){let d=J0.exec(t);if(d===null)console.error(`Invalid css value for margin '${t}'`);else{let[,p,m,g,y]=d,v=p&&m&&g;v&&y?(f.marginTop=parseInt(p,10),f.marginRight=parseInt(m,10),f.marginBottom=parseInt(g,10),f.marginLeft=parseInt(y,10)):v?(f.marginTop=parseInt(p,10),f.marginRight=f.marginLeft=parseInt(m,10),f.marginBottom=parseInt(g,10)):p&&m?(f.marginTop=f.marginBottom=parseInt(p,10),f.marginRight=f.marginLeft=parseInt(m,10)):f.marginTop=f.marginRight=f.marginBottom=f.marginLeft=parseInt(p,10)}}if(typeof n=="number"&&(f.marginTop=n),typeof o=="number"&&(f.marginRight=o),typeof i=="number"&&(f.marginBottom=i),typeof s=="number"&&(f.marginLeft=s),typeof l=="number")f.paddingTop=f.paddingRight=f.paddingBottom=f.paddingLeft=l;else if(typeof l=="string"){let d=J0.exec(l);if(d===null)console.error(`Invalid css value for padding '${l}'`);else{let[,p,m,g,y]=d,v=p&&m&&g;v&&y?(f.paddingTop=parseInt(p,10),f.paddingRight=parseInt(m,10),f.paddingBottom=parseInt(g,10),f.paddingLeft=parseInt(y,10)):v?(f.paddingTop=parseInt(p,10),f.paddingRight=f.paddingLeft=parseInt(m,10),f.paddingBottom=parseInt(g,10)):p&&m?(f.paddingTop=f.paddingBottom=parseInt(p,10),f.paddingRight=f.paddingLeft=parseInt(m,10)):f.paddingTop=f.paddingRight=f.paddingBottom=f.paddinggLeft=parseInt(p,10)}}return typeof a=="number"&&(f.paddingTop=a),typeof c=="number"&&(f.paddingRight=c),typeof u=="number"&&(f.paddingBottom=u),typeof h=="number"&&(f.paddingLeft=h),Q0(f,e)}function Q0(r=Ph){let e={...r},t,{border:n,borderWidth:o,borderTopWidth:i,borderRightWidth:s,borderBottomWidth:l,borderLeftWidth:a,borderColor:c,margin:u,marginTop:h,marginRight:f,marginBottom:d,marginLeft:p,padding:m,paddingTop:g,paddingRight:y,paddingBottom:v,paddingLeft:w,...x}=e,S={},b={};if(typeof u=="number"&&(e.marginTop=e.marginRight=e.marginBottom=e.marginLeft=u,S={marginTop:u,marginRight:u,marginBottom:u,marginLeft:u}),typeof m=="number"&&(e.paddingTop=e.paddingRight=e.paddingBottom=e.paddingLeft=m,b={paddingTop:m,paddingRight:m,paddingBottom:m,paddingLeft:m}),n||o||i||s||l||a){typeof n=="string"&&(t=qP.exec(n))&&([,o,c]=t,o=parseInt(o,10)),o&&(i=i===void 0?o:i,s=s===void 0?o:s,l=l===void 0?o:l,a=a===void 0?o:a),c=c||"black";let C=`
237
+ `;var nI=r=>(...e)=>[r,...e].join("-"),rI=nI("saltIcon"),oI=1,n0=tI(function({children:e,className:t,size:n=oI,style:o,...i},s){let l=un();hn({testId:"salt-icon",css:e0,window:l});let a={...o,"--saltIcon-size-multiplier":`${n}`};return t0("svg",{className:Zb(rI(),t),style:a,role:"img",...i,ref:s,children:t0("g",{"aria-hidden":!0,children:e})})});import{jsxs as iI,jsx as r0}from"react/jsx-runtime";import{forwardRef as sI}from"react";var fh=sI(function(e,t){return iI(n0,{"data-testid":"ExportIcon","aria-label":"export",viewBox:"0 0 12 12",ref:t,...e,children:[r0("path",{d:"M5 1H1v10h4v-1H2V2h3V1Z"}),r0("path",{d:"M3 5h5V3l4 3-4 3V7H3V5Z"})]})});import{formatDate as lI}from"@vuu-ui/vuu-utils";import{Button as aI}from"@salt-ds/core";import{forwardRef as cI,useCallback as i0,useEffect as uI,useState as hI}from"react";var o0=async r=>await fetch(`api/vui/${r.username}`,{}).then(t=>t.ok?t.json():null).catch(()=>{console.log("error getting history")});import{jsx as Wl,jsxs as s0}from"react/jsx-runtime";var fI=({lastUpdate:r},{lastUpdate:e})=>e===r?0:e<r?-1:1,dI=r=>Wl(ki,{...r}),pI=cI(function({loginUrl:e,onNavigate:t,user:n,layoutId:o="latest"},i){let[s,l]=hI([]);uI(()=>{async function h(){let d=(await o0(n)).filter(p=>p.id!=="latest").sort(fI).map(({id:p,lastUpdate:m})=>({lastUpdate:m,id:p,label:`Saved at ${lI(new Date(m),"kk:mm:ss")}`}));console.log({sortedHistory:d}),l(d)}h()},[n]);let a=i0((h,f)=>{f&&t(f.id)},[t]),c=i0(()=>{Yb(e)},[e]),u=s.length===0?null:o==="latest"?s[0]:s.find(h=>h.id===o);return s0("div",{className:"vuuUserPanel",ref:i,children:[Wl(ch,{ListItem:dI,className:"vuuUserPanel-history",onSelect:a,selected:u,source:s}),Wl("div",{className:"vuuUserPanel-buttonBar",children:s0(aI,{"aria-label":"logout",onClick:c,children:[Wl(fh,{})," Logout"]})})]})});import{jsx as cq,jsxs as uq}from"react/jsx-runtime";import yq from"classnames";import{ToggleButton as xq,ToggleButtonGroup as vq,useControlled as wq}from"@salt-ds/core";import{useCallback as kq}from"react";import{jsx as Rq,jsxs as Iq}from"react/jsx-runtime";import $q from"classnames";import{jsx as qq,jsxs as Kq}from"react/jsx-runtime";import{logger as mI}from"@vuu-ui/vuu-utils";import{Button as eK}from"@salt-ds/core";import nK from"classnames";import{useCallback as oK,useMemo as iK}from"react";import{jsx as uK,jsxs as hK}from"react/jsx-runtime";import{jsx as xK,jsxs as vK}from"react/jsx-runtime";import{useCallback as MK,useRef as EK,useState as RK}from"react";import{jsx as PK,jsxs as DK}from"react/jsx-runtime";import{jsx as dj,jsxs as pj}from"react/jsx-runtime";var{error:hj}=mI("Shell");import{createContext as gI,useContext as vj}from"react";import{jsx as Cj}from"react/jsx-runtime";var yI={},wj=gI(yI);import{useCallback as l0,useMemo as bI,useState as xI}from"react";import{jsx as vI}from"react/jsx-runtime";var Uj=()=>{let[r,e]=xI(),{saveLayout:t}=_l(),n=l0(()=>{e(void 0)},[]),o=l0(l=>{t(l),e(void 0)},[t]),[i,s]=bI(()=>[(l,a)=>{let c=l.split(" "),u=[];return c.includes("main-tab")&&u.push({label:"Save Layout",action:"save-layout",options:a},{label:"Layout Settings",action:"layout-settings",options:a}),u},l=>(console.log("menu action",{action:l}),l.menuId==="save-layout"?(e(vI(qb,{onCancel:n,onSave:o,componentId:l.options.controlledComponentId})),!0):!1)],[n,o]);return{buildMenuOptions:i,dialogContent:r,handleCloseDialog:n,handleMenuAction:s}};import{forwardRef as NI}from"react";import{isValidNumber as An}from"@vuu-ui/vuu-utils";import{useCallback as CI,useEffect as TI,useMemo as kI,useRef as MI,useState as EI}from"react";import{useCallback as wI,useEffect as a0,useRef as SI}from"react";var vr=new Map,u0=(r,e,t)=>{switch(t){case"height":return e.height;case"clientHeight":return Math.floor(r.clientHeight);case"clientWidth":return Math.floor(r.clientWidth);case"contentHeight":return e.contentHeight;case"contentWidth":return e.contentWidth;case"scrollHeight":return Math.ceil(Math.floor(r.scrollHeight));case"scrollWidth":return Math.ceil(Math.floor(r.scrollWidth));case"width":return e.width;default:return 0}},c0=new ResizeObserver(r=>{for(let e of r){let{target:t,borderBoxSize:n,contentBoxSize:o}=e,i=vr.get(t);if(i){let[{blockSize:s,inlineSize:l}]=n,[{blockSize:a,inlineSize:c}]=o,{onResize:u,measurements:h}=i,f=!1;for(let[d,p]of Object.entries(h)){let m=u0(t,{height:s,width:l,contentHeight:a,contentWidth:c},d);m!==p&&(f=!0,h[d]=m)}f&&u&&u(h)}}});function h0(r,e,t,n=!1){let o=SI(e),i=wI(s=>{let{width:l,height:a}=s.getBoundingClientRect(),{clientWidth:c,clientHeight:u}=s,h=Math.floor(a),f=Math.floor(l);return o.current.reduce((d,p)=>(d[p]=u0(s,{width:f,height:h,contentHeight:u,contentWidth:c},p),d),{})},[]);a0(()=>{let s=r.current;async function l(){vr.set(s,{measurements:{}});let a=vr.get(s);if(a){let c=i(s);a.measurements=c,c0.observe(s),n&&t(c)}else console.log("%cuseResizeObserver an target expected to be under observation wa snot found. This warrants investigation","font-weight:bold; color:red;")}return s&&(vr.has(s)&&console.log("useResizeObserver attemping to observe same element twice",{target:s}),l()),()=>{s&&vr.has(s)&&(c0.unobserve(s),vr.delete(s))}},[i,r]),a0(()=>{let s=r.current,l=vr.get(s);if(l){if(o.current!==e){o.current=e;let a=i(s);l.measurements=a}l.onResize=t}},[e,i,r,t])}var RI=["clientHeight","clientWidth"],II=["clientWidth"],PI=["clientHeight"],DI=[],$l=r=>Number.isFinite(r),LI={height:"100%",width:"auto"},AI=(r,e)=>An(r)&&An(e)?{height:`${r}px`,width:`${e}px`}:typeof r=="string"||typeof e=="string"?{height:r!=null?r:"100%",width:e!=null?e:"auto"}:LI,OI=(r,e)=>{if(An(r)&&An(e))return{height:r,width:e}},f0=({defaultHeight:r=0,defaultWidth:e=0,height:t,onResize:n,width:o})=>{let i=MI(null),[s,l]=EI({css:AI(t,o),inner:OI(t,o),outer:{height:t!=null?t:"100%",width:o!=null?o:"auto"}}),a=typeof t=="number",c=typeof o=="number",u=a&&c?DI:a?II:c?PI:RI;kI(()=>{l(f=>{let{inner:d,outer:p}=f;if(An(t)&&An(o)&&d&&p){let{height:m,width:y}=d,{height:g,width:v}=p;if(g!==t||v!==o){let w=An(g)?g-m:0,x=An(v)?v-y:0;return{...f,outer:{height:t,width:o},inner:{height:t-w,width:o-x}}}}return f})},[t,o]);let h=CI(({clientWidth:f,clientHeight:d})=>{let{css:p,inner:m,outer:y}=s,g=s;a&&$l(f)&&Math.floor(f)!==(m==null?void 0:m.width)?g={css:p,outer:y,inner:{width:Math.floor(f)||e,height:t}}:c&&$l(d)&&Math.floor(d)!==(m==null?void 0:m.height)?g={css:p,outer:y,inner:{height:Math.floor(d)||r,width:o}}:$l(d)&&$l(f)&&(f!==(m==null?void 0:m.width)||d!==(m==null?void 0:m.height))&&(g={css:p,outer:y,inner:{width:Math.floor(f)||e,height:Math.floor(d)||r}}),g!==s&&l(g)},[r,e,a,c,t,s,o]);return TI(()=>{s.inner&&(n==null||n(s.inner))},[n,s.inner]),h0(i,u,h,!0),{containerRef:i,cssSize:s.css,outerSize:s.outer,innerSize:s.inner}};import{useForkRef as VI}from"@salt-ds/core";import d0 from"classnames";import{jsx as p0}from"react/jsx-runtime";var dh="vuuMeasuredContainer",xJ=NI(function({children:e,className:t,height:n,onResize:o,style:i,width:s,...l},a){let{containerRef:c,...u}=f0({height:n,onResize:o,width:s}),{cssSize:h,innerSize:f}=u,d=f===void 0,p=()=>d?{"--measured-css-height":`${h.height}`,"--measured-css-width":`${h.width}`}:{...i,"--measured-css-height":`${h.height}`,"--measured-css-width":`${h.width}`,"--measured-px-height":`${f==null?void 0:f.height}px`,"--measured-px-width":`${f==null?void 0:f.width}px`},m=VI(c,a);return d?p0("div",{...l,className:d0(dh,`${dh}-ummeasured`),style:p(),ref:c}):p0("div",{...l,className:d0(dh,t),ref:m,style:p(),children:e})});import{PopupMenu as eP}from"@vuu-ui/vuu-popups";import ql from"classnames";import tP,{forwardRef as nP}from"react";import{useDragDropNext as QI}from"@vuu-ui/vuu-ui-controls";import{isValidNumber as YI,MEASURES as XI}from"@vuu-ui/vuu-utils";import{useCallback as Gl,useMemo as gh,useRef as T0,useState as ZI}from"react";import{getElementByDataIndex as m0}from"@vuu-ui/vuu-utils";var FI=".vuuOverflowContainer-item:not(.wrapped)",EJ=r=>r!==null&&r.dataset.index==="overflow"&&r.parentElement!==null&&r.parentElement.classList.contains("vuuOverflowContainer-wrapContainer-overflowed"),BI=r=>r.sort((e,t)=>{let{dataset:{index:n="?"}}=e,{dataset:{index:o="?"}}=t,i=e.classList.contains("wrapped"),s=t.classList.contains("wrapped"),l=n==="overflow",a=o==="overflow";return i&&!s?1:!i&&s?-1:l?1:a?-1:parseInt(n)>parseInt(o)?1:-1}),ph=[],Ri=(r,e="horizontal")=>{let t=[],n=[],o=-1,i=!1,s=BI(Array.from(r.children)),l=e==="vertical"?"top":"left";for(let a of s){let c=a,{dataset:{index:u="?",label:h="?",overflowPriority:f="0"}}=c,{[l]:d}=c.getBoundingClientRect();d<=o?(u==="overflow"?n.push(t.pop()):n.push({index:u,label:h,overflowPriority:f}),i=!0):i?n.push({index:u,label:h,overflowPriority:f}):t.push({index:u,label:h,overflowPriority:f}),o=d}return[t,n]},g0=(r,e,t)=>{let n=!1,o=t?`${t}-overflowed`:"overflow";e.find(({index:i})=>i==="overflow")&&e.length===1&&(n=!0);for(let i of r.children){let{dataset:{index:s="?"}}=i;e.length===0||n?r.classList.remove(o):r.classList.add(o),s!=="overflow"&&e.find(l=>l.index===s)?i.classList.add("wrapped"):i.classList.remove("wrapped")}},HI=(r,{overflowPriority:e})=>Math.max(r,parseInt(e)),_I=(r,{overflowPriority:e})=>Math.min(r,parseInt(e)),y0=r=>{var e;return r.length>1&&((e=r.at(-1))==null?void 0:e.index)==="overflow"},zI=r=>{let[e]=r;for(let t=1;t<r.length;t++){let n=r[t];parseInt(n.overflowPriority)>parseInt(e.overflowPriority)&&(e=n)}return e},b0=(r,e)=>{var o;let t=r.reduce(_I,Number.MAX_SAFE_INTEGER);return e.reduce(HI,0)>t?!0:e.length>1&&((o=e.at(-1))==null?void 0:o.index)==="overflow"},x0=(r,e)=>new Promise(t=>{requestAnimationFrame(()=>{let[,n]=Ri(r);UI(e,n).forEach(i=>WI(r,i)),t(n)})}),v0=(r,e,t)=>new Promise(n=>{requestAnimationFrame(()=>{let[,o]=Ri(r),i=zI(o);if(i){let[s,l]=mh(r,i);n([s,l])}else n([e,t])})}),WI=(r,e)=>{let t=m0(r,e.index);if(t)t.classList.add("wrapped");else throw Error(`markElementAsWrapped element item with index ${e.index} not found`)},$I=r=>Array.from(r.querySelectorAll(".wrapped")),UI=(r,e)=>{let t=[];for(let n of e)r.find(({index:o})=>o===n.index)||t.push(n);return t},GI=(r,e)=>{$I(r).forEach(n=>{let{dataset:{index:o="?"}}=n;e.find(i=>i.index===o)||n.classList.remove("wrapped")})},w0=r=>r.querySelector('[data-index="overflow"]'),qI=r=>r.querySelector(".wrapped"),Ul=r=>parseInt(getComputedStyle(r).getPropertyValue("width")),S0=(r,e)=>{let{right:t}=r.getBoundingClientRect(),n=parseInt(getComputedStyle(r).getPropertyValue("padding-right")),{right:o}=e.getBoundingClientRect();return t-n-o},C0=r=>{let e=w0(r),t=S0(r,e),n=Ul(e),o=qI(r);return Ul(o)<=t+n?(r.classList.remove("overflowed"),o.classList.remove("wrapped"),!0):!1},KI=(r,e)=>{let{dataset:{index:t="0",overflowPriority:n="0"}}=r,{dataset:{index:o="0",overflowPriority:i="0"}}=e;return n>i?-1:n<i?1:parseInt(t)-parseInt(o)},jI=r=>Array.from(r.querySelectorAll(FI)).sort(KI),mh=(r,e)=>{let t=jI(r),n=m0(r,e.index,!0),o=-1,i=t.at(o),s=Ul(i),l=Ul(n),a=w0(r),c=S0(r,a)+s;if(c>=l)JI(n,i);else{let{left:f}=i.getBoundingClientRect(),d=c,p=[i];for(;c<l;){o-=1,i=t.at(o),p.push(i);let{left:m}=i.getBoundingClientRect(),y=f-m;c=d+y}n==null||n.classList.remove("wrapped"),p.forEach(m=>{m.classList.add("wrapped")})}let[u,h]=Ri(r);return GI(r,h),[u,h]},JI=(r,e)=>{if(!r||!e)throw Error("switchWrapOnElements, element undefined");r.classList.remove("wrapped"),e.classList.add("wrapped")};var k0=({allowDragDrop:r=!1,itemCount:e,onMoveItem:t,onSwitchWrappedItemIntoView:n,orientation:o="horizontal"})=>{let[i,s]=ZI(null),l=T0(ph),a=T0(null),c=Gl(w=>{var x;a.current&&((x=a.current.querySelector(".vuuOverflowContainer-OverflowIndicator button"))==null||x.setAttribute("tabindex",w))},[]),u=Gl(async()=>{if(i){let[w,x]=Ri(i,o);for(g0(i,x,"vuuOverflowContainer-wrapContainer"),y0(x)&&(x=await x0(i,x));b0(w,x);)[w,x]=await v0(i,w,x);x.length===1&&C0(i)&&(x=ph),l.current.length===0&&x.length>0?c("0"):l.current.length>0&&x.length===0&&c("-1"),l.current=x}},[i,o,c]),h=w=>typeof w=="object"&&w!==null&&"overflowItem"in w,[f,d]=gh(()=>[()=>{let{current:w}=l;return w.map(x=>({label:x.label,action:`activate-item-${x.index}`,options:{overflowItem:x}}))},({options:w})=>{if(i&&h(w)){let[,x]=mh(i,w.overflowItem);l.current=x,n==null||n(w.overflowItem)}return!0}],[i,n]),p=gh(()=>{let{sizeProp:w}=XI[o],x=0;return new ResizeObserver(S=>{for(let b of S){let{[w]:C}=b.contentRect,k=Math.round(C);YI(k)&&x!==k&&(x=k,u())}})},[u,o]);Qh(()=>{u()},[u,e]),gh(()=>{i&&p.observe(i)},[i,p]);let m=Gl(w=>{s(a.current=w)},[]),y=Gl((w,x)=>{t==null||t(w,x)},[t]),{onMouseDown:g,...v}=QI({allowDragDrop:r,containerRef:a,draggableClassName:"vuuOverflowContainer",onDrop:y,orientation:"horizontal",itemQuery:".vuuOverflowContainer-item"});return{menuActionHandler:d,menuBuilder:f,onItemMouseDown:g,rootRef:m,...v}};import{jsx as Ii,jsxs as rP}from"react/jsx-runtime";var ho="vuuOverflowContainer",M0=tP.memo(({PopupMenuProps:r,allowDragDrop:e,children:t,className:n,height:o,id:i,onMoveItem:s,onSwitchWrappedItemIntoView:l,orientation:a="horizontal",overflowIcon:c,overflowPosition:u="end"})=>{let h=wr(t),{draggable:f,draggedItemIndex:d,menuActionHandler:p,menuBuilder:m,onItemMouseDown:y,rootRef:g}=k0({allowDragDrop:e,itemCount:h.length,onMoveItem:s,onSwitchWrappedItemIntoView:l,orientation:a}),w={"--overflow-container-height":`${a==="vertical"?"100%":`${o}px`}`},x=ql(`${ho}-wrapContainer`,n,{[`${ho}-horizontal`]:a==="horizontal",[`${ho}-vertical`]:a==="vertical"}),S=h.map((C,k)=>{let{"data-align":E,"data-overflow-priority":R="0",id:M=`${i}-${k}`,label:P=`Item ${k+1}`}=C.props;return Ii("div",{className:ql(`${ho}-item`,{"vuuDraggable-dragAway":d===k}),"data-index":k,"data-align":E,"data-label":P,"data-overflow-priority":R,id:`${M}-wrapper`,onMouseDown:y,children:C},k)}),b=Ii("div",{className:`${ho}-OverflowIndicator`,"data-index":"overflow",children:Ii(eP,{...r,icon:c,menuBuilder:m,menuActionHandler:p,tabIndex:-1})},"overflow");return S.push(b),rP("div",{className:x,ref:g,style:w,children:[S,f]})});M0.displayName="OverflowContainer.InnerContainer";var E0=nP(function({PopupMenuProps:e,allowDragDrop:t=!1,children:n,className:o,height:i=44,id:s,onMoveItem:l,onSwitchWrappedItemIntoView:a,orientation:c,overflowIcon:u,overflowPosition:h,...f},d){let p=Sr(s);return Ii("div",{...f,className:ql(ql(ho,o)),id:p,ref:d,children:Ii(M0,{PopupMenuProps:e,allowDragDrop:t,height:i,id:p,orientation:c,overflowIcon:u,overflowPosition:h,onMoveItem:l,onSwitchWrappedItemIntoView:a,children:n})})});import{uuid as oP}from"@vuu-ui/vuu-utils";import{List as iP,ListItem as sP}from"@vuu-ui/vuu-ui-controls";import R0 from"classnames";import{cloneElement as lP,memo as aP}from"react";import{jsx as yh}from"react/jsx-runtime";var cP=r=>{let e=r.cloneNode(!0);return e.id="",delete e.dataset.idx,e},hh=aP(({className:r,children:e,idx:t,resizeable:n,header:o,closeable:i,...s})=>yh(sP,{className:R0("vuuPaletteItem",r),"data-draggable":!0,"data-icon":"draggable",...s}));hh.displayName="PaletteItem";var jb=({ListProps:r,ViewProps:e,children:t,className:n,itemHeight:o=41,orientation:i="horizontal",...s})=>{let l=ut(),a="vuuPalette";function c(u){var E,R;let f=u.target.closest(".vuuPaletteItem"),d=parseInt((R=(E=f.dataset)==null?void 0:E.index)!=null?R:"-1"),{props:{caption:p,children:m,template:y,...g}}=t[d],{height:v,left:w,top:x,width:S}=f.getBoundingClientRect(),b=oP(),k=y?m:yh(qn,{...e,...{id:b,key:b},...g,title:g.label,children:m});l({dragRect:{left:w,top:x,right:w+S,bottom:x+150,width:S,height:v},dragElement:cP(f),evt:u.nativeEvent,instructions:{DoNotRemove:!0,DoNotTransform:!0,DriftHomeIfNoDropTarget:!0,RemoveDraggableOnDragEnd:!0,dragThreshold:10},path:"*",payload:k,type:"drag-start"})}return yh(iP,{...r,...s,className:R0(a,n,`${a}-${i}`),itemHeight:o,selected:null,children:t.map((u,h)=>u.type===hh?lP(u,{key:h,onMouseDown:c}):u)})};ge("Palette",jb,"view");import{Tab as uP,Tabstrip as hP}from"@vuu-ui/vuu-ui-controls";import I0 from"classnames";import bh,{forwardRef as fP,useCallback as dP}from"react";import{jsx as D0,jsxs as bP}from"react/jsx-runtime";var P0="Tabs",pP=()=>{},mP=(r,e)=>{var t,n,o,i;return(i=(o=(t=r.props)==null?void 0:t.title)!=null?o:(n=r.props)==null?void 0:n["data-tab-title"])!=null?i:`Tab ${e+1}`},gP=r=>{let e=[];return bh.Children.forEach(r,t=>{bh.isValidElement(t)?e.push(t):console.warn("Stack has unexpected child element type")}),e},yP={allowAddTab:!1,allowCloseTab:!1,allowRenameTab:!1},zl=fP(function({TabstripProps:e=yP,active:t=0,children:n,className:o,getTabIcon:i=pP,getTabLabel:s=mP,id:l,keyBoardActivation:a="manual",onAddTab:c,onMoveTab:u,onTabClose:h,onTabEdit:f,onTabSelectionChanged:d,showTabs:p="top",style:m},y){var P;let g=Sr(l),{allowCloseTab:v,allowRenameTab:w,className:x,tabClassName:S}=e,b=dP((I,V,B,W)=>{f==null||f(W,V)},[f]),C=()=>{var I;return bh.isValidElement(n)?n:Array.isArray(n)&&(I=n[t])!=null?I:null},k=()=>gP(n).map((I,V)=>{let{closeable:B=v,id:W=`${g}-${V}`,"data-tab-location":O}=I.props;return D0(uP,{ariaControls:W,"data-icon":i(I,V),id:`${W}-tab`,index:V,label:s(I,V),location:O,closeable:B,editable:w},W)}),E=C(),R=p==="left"||p==="right",M=R?"vertical":"horizontal";return bP("div",{className:I0(P0,o,{[`${P0}-horizontal`]:R}),style:m,id:g,ref:y,children:[p?D0(hP,{...e,activeTabIndex:(P=e==null?void 0:e.activeTabIndex)!=null?P:E===null?-1:t,allowDragDrop:e.allowDragDrop!==!1,animateSelectionThumb:!0,className:I0("vuuTabHeader",x),keyBoardActivation:a,onActiveChange:d,onAddTab:c,onCloseTab:h,onExitEditMode:b,onMoveTab:u,orientation:M,children:k()}):null,E]})});zl.displayName="Stack";import{useIdMemo as xP}from"@salt-ds/core";import vP,{useCallback as xh,useRef as wP}from"react";import{jsx as vh}from"react/jsx-runtime";var SP=r=>vh(qn,{resizeable:!0,title:`Tab ${r}`,style:{flexGrow:1,flexShrink:0,flexBasis:0},header:!0,closeable:!0,children:vh(ta,{style:{flex:1}})}),L0=r=>{var S;let e=wP(null),t=ut(),{loadState:n}=kr(),{createNewChild:o,id:i,onTabSelectionChanged:s,path:l,...a}=r,{children:c}=r,u=xP(i),[h]=ss(u,e,l),f=pd(),d=(S=o!=null?o:f)!=null?S:SP,p=b=>{l&&(t({type:"switch-tab",id:u,path:l,nextIdx:b}),s==null||s(b))},m=xh(b=>{if(Array.isArray(c)){let{props:{"data-path":C,path:k=C}}=c[b];t({type:"remove",path:k})}},[c,t]),y=xh(()=>{if(l){let b=vP.Children.count(c),C=d(b);t({type:"add",path:l,component:C})}},[c,d,t,l]),g=xh((b,C)=>{l&&t({fromIndex:b,toIndex:C,path:l,type:"move-child"})},[t,l]);return vh(zl,{...a,id:u,getTabLabel:(b,C)=>{let{id:k,title:E}=b.props;return n(k,"view-title")||E||`Tab ${C+1}`},onMouseDown:async(b,C)=>{let k;await h({type:"mousedown",index:C,preDragActivity:async()=>new Promise(M=>{console.log("preDragActivity: Ok, gonna release the drag"),k=M})},b)&&(k==null||k(void 0))},onMoveTab:g,onAddTab:y,onTabClose:m,onTabEdit:(b,C)=>{t({type:"set-title",path:`${l}.${b}`,title:C})},onTabSelectionChanged:p,ref:e})};L0.displayName="Stack";ge("Stack",L0,"container");import Ch from"classnames";import qP,{useMemo as KP,useRef as jP}from"react";import{isValidNumber as UP}from"@vuu-ui/vuu-utils";import{useCallback as Sh,useRef as GP}from"react";import{useControlled as kP}from"@salt-ds/core";import{dispatchMouseEvent as MP,getClosest as EP,getElementDataIndex as RP,getFocusableElement as IP}from"@vuu-ui/vuu-utils";import{useCallback as Tt,useRef as wh,useState as PP}from"react";import{ArrowDown as B0,ArrowUp as DP,ArrowLeft as LP,ArrowRight as AP,Home as O0,End as N0}from"@vuu-ui/vuu-utils";import{getElementDataIndex as CP}from"@vuu-ui/vuu-utils";var TP=(r,e)=>{if(r){let t=r.querySelector(`[data-index]:has(${e})`);return CP(t)}return-1};var A0=r=>TP(r,".vuuEditableLabel-editing");var H0={horizontal:{[O0]:"start",[N0]:"end",[LP]:"bwd",[AP]:"fwd"},vertical:{[O0]:"start",[N0]:"end",[DP]:"bwd",[B0]:"fwd"}},_0=r=>r!==null&&r.dataset.index==="overflow",OP=(r,e,t,n,o)=>{if(r){let i=e==="bwd"&&n>0,s=e==="fwd"&&n<t,l=i||s,a=Pi(r,n,!0),c=o&&!F0(a),u=!o&&_0(a);return o&&F0(a),l&&(c||u)}else return!1},NP=(r,e="horizontal")=>H0[e][r]!==void 0,VP=r=>r===B0;function V0(r,e,t){return e==="start"?0:e==="end"?r-1:e==="bwd"?t>0?t-1:t:t===null?0:t===r-1?t:t+1}var F0=r=>r!==null&&!r.classList.contains("wrapped"),z0=r=>Array.from(r.querySelectorAll("[data-index]")),FP=r=>r===null?-1:z0(r).map(n=>n.dataset.index).indexOf("overflow"),Pi=(r,e,t=!1)=>{if(r!==null){let o=z0(r)[e];return!t&&_0(o)?null:o}return null},W0=({containerRef:r,defaultHighlightedIdx:e=-1,highlightedIdx:t,onNavigateOutOfBounds:n,orientation:o})=>{let i=wh(!1),s=wh(-1),[l,a]=PP(!1),[c,u]=kP({controlled:t,default:e,name:"UseKeyboardNavigation"}),h=Tt(M=>{u(s.current=M)},[u]),f=wh(!1),d=Tt((M,P=!1,I,V=70)=>{console.log(`focus item ${M}`),h(M),I===!0&&!f.current&&(f.current=!0);let B=()=>{let W=Pi(r.current,M,!0);if(W){let O=IP(W);O==null||O.focus()}};P?B():setTimeout(B,V)},[r,h]),p=M=>{if(s.current===-1){if(M.target.tabIndex===0){let P=RP(EP(M.target,"index"));h(P)}else if(M.target.tabIndex!==-1){let P=A0(r.current);P!==-1&&requestAnimationFrame(()=>{h(P)})}}},m=Tt(()=>{var M,P;return(P=(M=r.current)==null?void 0:M.querySelectorAll("[data-index]").length)!=null?P:0},[r]),y=Tt((M="fwd",P)=>{var N;let I=m(),V=typeof P=="number"?P:I,B=V0(I,M,V),W=M==="start"?"fwd":M==="end"?"bwd":M,O=((N=r.current)==null?void 0:N.querySelector(".vuuOverflowContainer-wrapContainer-overflowed"))!=null;for(;OP(r.current,W,I,B,O);){let F=V0(I,W,B);if(F===B)return V;B=F}return B},[r,m]),g=Tt(M=>{let P=H0[o][M.key],I=y(P,c);console.log(`highlightedIdx = ${c}, nextIdx = ${I} `),I!==c?d(I,!0):n==null||n(P==="bwd"?"start":"end")},[o,y,c,d,n]),v=Tt(()=>{let M=Pi(r.current,c);return M?M.querySelector(".vuuPopupMenu")!=null:!1},[r,c]),w=Tt(()=>{let M=Pi(r.current,c);return M?M.querySelector(".vuuEditableLabel-input")!=null:!1},[r,c]),x=Tt(()=>{let M=Pi(r.current,c),P=M==null?void 0:M.querySelector(".vuuPopupMenu");return P&&MP(P,"click"),!1},[r,c]),S=Tt(M=>{m()>0&&NP(M.key,o)?(M.preventDefault(),f.current||(f.current=!0),g(M)):VP(M.key)&&v()&&!w()&&x()},[x,m,v,w,g,o]),b=(M,P)=>{h(P)},C=Tt(()=>{l||(a(!0),i.current?i.current=!1:f.current=!0)},[l]),k=Tt(()=>{l||(i.current=!0),f.current=!1},[l]),E=Tt(M=>{if((M==null?void 0:M.type)==="escape"){let P=FP(r.current);P!==-1&&d(P)}},[r,d]);return{containerProps:{onBlur:M=>{let P=M.target.closest(".vuuToolbar"),I=M.relatedTarget;P&&!(P!=null&&P.contains(I))&&(h(-1),a(!1))},onMouseDownCapture:k,onFocus:C,onMouseLeave:()=>{f.current=!0,h(-1),i.current=!1}},focusVisible:f.current?c:-1,focusIsWithinComponent:l,highlightedIdx:c,focusableIdx:0,focusItem:d,onClick:b,onFocus:p,onKeyDown:S,onOverflowMenuClose:E,setHighlightedIdx:h}};import{isSelectableElement as $0,getClosestIndexItem as BP}from"@vuu-ui/vuu-utils";import{allowMultipleSelection as HP,deselectionIsAllowed as U0,selectionIsDisallowed as _P,useControlled as zP}from"@vuu-ui/vuu-ui-controls";import{useCallback as Di}from"react";var WP=["Enter"," "],$P={},G0=({containerRef:r,defaultSelected:e,highlightedIdx:t,itemQuery:n,onSelectionChange:o,selected:i,selectionStrategy:s})=>{let[l,a,c]=zP({controlled:i,default:e!=null?e:[],name:"useSelection",state:"selected"}),u=Di(y=>WP.includes(y.key),[]),h=Di((y,g=!1)=>{let v=HP(s,g)?l.concat(y):[y];a(v),o==null||o(v)},[o,l,s,a]),f=Di((y,g=!1)=>{let v=s==="deselectable"||s==="multiple-special-key"&&!g?[]:l.filter(w=>w!==y);a(v),o==null||o(v)},[o,l,s,a]),d=Di(y=>{u(y)&&$0(y.target)&&(l.includes(t)?U0(s)&&(y.stopPropagation(),y.preventDefault(),f(t,y.shiftKey)):(y.stopPropagation(),y.preventDefault(),h(t,y.shiftKey)))},[u,l,t,s,h,f]),p=Di((y,g)=>{let v=BP(y.target);$0(v)&&(l.includes(g)?U0(s)&&f(g,y.shiftKey):h(g,y.shiftKey))},[f,h,l,s]),m=_P(s)?$P:{onClick:p,onKeyDown:d};return{activateItem:h,itemHandlers:m,isControlled:c,selected:l}};var q0=({activeItemIndex:r,defaultActiveItemIndex:e,containerRef:t,itemQuery:n="vuuToolbarItem",onActiveChange:o,onNavigateOutOfBounds:i,orientation:s,selectionStrategy:l})=>{let a=GP(r),{focusItem:c,highlightedIdx:u,onClick:h,onKeyDown:f,setHighlightedIdx:d,...p}=W0({containerRef:t,onNavigateOutOfBounds:i,orientation:s}),{activateItem:m,itemHandlers:{onClick:y,onKeyDown:g},selected:v}=G0({containerRef:t,defaultSelected:e,highlightedIdx:u,itemQuery:n,onSelectionChange:o,selected:r,selectionStrategy:l});a.current=v;let w=Sh(C=>{var R;let E=C.target.closest("[data-index]");if(E){let M=parseInt((R=E.dataset.index)!=null?R:"-1");M!==-1&&UP(M)&&(h(C,M),y==null||y(C,M))}},[h,y]),x=Sh(C=>{f(C),C.defaultPrevented||g==null||g(C)},[f,g]),S=Sh(C=>{let k=parseInt(C.index);isNaN(k)||(m(k),c(k))},[c,m]),b={onClick:w,onFocus:p.onFocus,onKeyDown:x};return{activeItemIndex:v,focusableIdx:p.focusableIdx,focusVisible:p.focusVisible,containerProps:{PopupMenuProps:{onKeyDown:x,onMenuClose:p.onOverflowMenuClose},...p.containerProps,onSwitchWrappedItemIntoView:S},itemProps:b}};import{forwardCallbackProps as JP}from"@vuu-ui/vuu-ui-controls";import{jsx as QP}from"react/jsx-runtime";var Th="vuuToolbar",dT=({activeItemIndex:r,defaultActiveItemIndex:e,children:t,className:n,id:o,onActiveChange:i,onNavigateOutOfBounds:s,orientation:l="horizontal",selectionStrategy:a="none",...c})=>{let u=jP(null),{activeItemIndex:h,focusableIdx:f,focusVisible:d,itemProps:p,...m}=q0({activeItemIndex:r,defaultActiveItemIndex:e,containerRef:u,onActiveChange:i,onNavigateOutOfBounds:s,orientation:l,selectionStrategy:a}),y=Sr(o),g=Ch(Th,`${Th}-${l}`,n),v=KP(()=>wr(t).map((w,x)=>{let{id:S=`${y}-tab-${x}`,className:b,...C}=w.props,k=h.includes(x);return qP.cloneElement(w,{...JP(C,p),className:Ch("vuuToolbarItem",b),"data-overflow-priority":k?"1":void 0,id:S,key:x,"aria-selected":k,tabIndex:f===x?0:-1})}),[h,t,f,y,p]);return QP(E0,{...c,...m.containerProps,className:Ch(Th,g),...c,ref:u,children:v})};import K0,{useState as j0}from"react";import{jsx as kh,jsxs as J0}from"react/jsx-runtime";var jY=({children:r})=>{let[t,n]=j0(r),[o,i]=j0(r),s=a=>{let c=Kh(t,a);i(c)},l=(a,c)=>{console.log(`change ${a} -> ${c}`);let u=K0.cloneElement(o,{style:{...o.props.style,[a]:c}});i(u),n(K0.cloneElement(t,{},u))};return J0("div",{"data-design-mode":`${!1}`,children:[t,kh("br",{}),J0("div",{style:{display:"flex"},children:[kh(Q0,{height:300,managedStyle:o.props.style,width:300,onChange:l,style:void 0}),kh(Y0,{layout:t,onSelect:s,style:{width:300,height:300,backgroundColor:"#ccc"}})]})]})};import{FormField as Kl,Input as jl}from"@salt-ds/core";import{jsx as Le,jsxs as Eh}from"react/jsx-runtime";var Rh={},YP={margin:{top:"marginTop",right:"marginRight",bottom:"marginBottom",left:"marginLeft"},border:{top:"borderTopWidth",right:"borderRightWidth",bottom:"borderBottomWidth",left:"borderLeftWidth"},padding:{top:"paddingTop",right:"paddingRight",bottom:"paddingBottom",left:"paddingLeft"}},Mh=({feature:r,children:e,style:t,onChange:n})=>Eh("div",{className:`LayoutBox layout-${r} layout-outer`,children:[Eh("div",{className:"layout-top",children:[Le("span",{className:"layout-title",children:r}),Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.top,onChange:(o,i)=>n(r,"top",i)})})]}),Eh("div",{className:"layout-inner",children:[Le("div",{className:"layout-left",children:Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.left,onChange:(o,i)=>n(r,"left",i)})})}),e,Le("div",{className:"layout-right",children:Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.right,onChange:(o,i)=>n(r,"right",i)})})})]}),Le("div",{className:"layout-bottom",children:Le(Kl,{className:"layout-input",style:{width:30},children:Le(jl,{value:t.bottom,onChange:(o,i)=>n(r,"bottom",i)})})})]}),rX={margin:!0,marginTop:!0,marginRight:!0,marginBottom:!0,marginLeft:!0},oX={padding:!0,paddingTop:!0,paddingRight:!0,paddingBottom:!0,paddingLeft:!0},iX={border:!0,borderColor:!0,borderWidth:!0,borderTopWidth:!0,borderRightWidth:!0,borderBottomWidth:!0,borderLeftWidth:!0},Jl="(\\d+)(?:px)?",XP=`^(?:${Jl}(?:\\s${Jl}(?:\\s${Jl}(?:\\s${Jl})?)?)?)$`,X0=new RegExp(XP),ZP=/^(?:(\d+)(?:px)\ssolid\s([a-zA-Z,0-9().]+))$/,Q0=({height:r,managedStyle:e,onChange:t,style:n,width:o})=>{let i=Z0(e),s=(w,x,S)=>{let b=parseInt(S||"0",10),C=YP[w][x];t(C,b)},{marginTop:l=0,marginRight:a=0,marginBottom:c=0,marginLeft:u=0}=i,{borderTopWidth:h=0,borderRightWidth:f=0,borderBottomWidth:d=0,borderLeftWidth:p=0}=i,{paddingTop:m=0,paddingRight:y=0,paddingBottom:g=0,paddingLeft:v=0}=i;return Le("div",{className:"LayoutConfigurator",style:{width:o,height:r,...n},children:Le(Mh,{feature:"margin",style:{top:l,right:a,bottom:c,left:u},onChange:s,children:Le(Mh,{feature:"border",style:{top:h,right:f,bottom:d,left:p},onChange:s,children:Le(Mh,{feature:"padding",style:{top:m,right:y,bottom:g,left:v},onChange:s,children:Le("div",{className:"layout-content"})})})})})};function sX(r=Rh,e=Rh){let{margin:t,marginTop:n,marginRight:o,marginBottom:i,marginLeft:s,padding:l,paddingTop:a,paddingRight:c,paddingBottom:u,paddingLeft:h,...f}=r;if(typeof t=="number")f.marginTop=f.marginRight=f.marginBottom=f.marginLeft=t;else if(typeof t=="string"){let d=X0.exec(t);if(d===null)console.error(`Invalid css value for margin '${t}'`);else{let[,p,m,y,g]=d,v=p&&m&&y;v&&g?(f.marginTop=parseInt(p,10),f.marginRight=parseInt(m,10),f.marginBottom=parseInt(y,10),f.marginLeft=parseInt(g,10)):v?(f.marginTop=parseInt(p,10),f.marginRight=f.marginLeft=parseInt(m,10),f.marginBottom=parseInt(y,10)):p&&m?(f.marginTop=f.marginBottom=parseInt(p,10),f.marginRight=f.marginLeft=parseInt(m,10)):f.marginTop=f.marginRight=f.marginBottom=f.marginLeft=parseInt(p,10)}}if(typeof n=="number"&&(f.marginTop=n),typeof o=="number"&&(f.marginRight=o),typeof i=="number"&&(f.marginBottom=i),typeof s=="number"&&(f.marginLeft=s),typeof l=="number")f.paddingTop=f.paddingRight=f.paddingBottom=f.paddingLeft=l;else if(typeof l=="string"){let d=X0.exec(l);if(d===null)console.error(`Invalid css value for padding '${l}'`);else{let[,p,m,y,g]=d,v=p&&m&&y;v&&g?(f.paddingTop=parseInt(p,10),f.paddingRight=parseInt(m,10),f.paddingBottom=parseInt(y,10),f.paddingLeft=parseInt(g,10)):v?(f.paddingTop=parseInt(p,10),f.paddingRight=f.paddingLeft=parseInt(m,10),f.paddingBottom=parseInt(y,10)):p&&m?(f.paddingTop=f.paddingBottom=parseInt(p,10),f.paddingRight=f.paddingLeft=parseInt(m,10)):f.paddingTop=f.paddingRight=f.paddingBottom=f.paddinggLeft=parseInt(p,10)}}return typeof a=="number"&&(f.paddingTop=a),typeof c=="number"&&(f.paddingRight=c),typeof u=="number"&&(f.paddingBottom=u),typeof h=="number"&&(f.paddingLeft=h),Z0(f,e)}function Z0(r=Rh){let e={...r},t,{border:n,borderWidth:o,borderTopWidth:i,borderRightWidth:s,borderBottomWidth:l,borderLeftWidth:a,borderColor:c,margin:u,marginTop:h,marginRight:f,marginBottom:d,marginLeft:p,padding:m,paddingTop:y,paddingRight:g,paddingBottom:v,paddingLeft:w,...x}=e,S={},b={};if(typeof u=="number"&&(e.marginTop=e.marginRight=e.marginBottom=e.marginLeft=u,S={marginTop:u,marginRight:u,marginBottom:u,marginLeft:u}),typeof m=="number"&&(e.paddingTop=e.paddingRight=e.paddingBottom=e.paddingLeft=m,b={paddingTop:m,paddingRight:m,paddingBottom:m,paddingLeft:m}),n||o||i||s||l||a){typeof n=="string"&&(t=ZP.exec(n))&&([,o,c]=t,o=parseInt(o,10)),o&&(i=i===void 0?o:i,s=s===void 0?o:s,l=l===void 0?o:l,a=a===void 0?o:a),c=c||"black";let C=`
238
238
  ${c} ${a||0}px ${i||0}px 0 0 inset,
239
- ${c} ${-s||0}px ${-l||0}px 0 0 inset`;return{...x,...S,...b,borderTopWidth:i,borderRightWidth:s,borderBottomWidth:l,borderLeftWidth:a,borderColor:c,borderStyle:"solid",boxShadow:C}}else return e}import KP from"react";import jP from"classnames";import{Tree as JP}from"@vuu-ui/vuu-ui-controls";import{jsx as Y0}from"react/jsx-runtime";var QP="hwLayoutTreeViewer",X0=(r,e="0")=>({label:K(r),path:e,childNodes:KP.Children.map(r.props.children,(t,n)=>X0(t,e?`${e}.${n}`:`${n}`))}),j0=({layout:r,onSelect:e,style:t})=>{let n=[X0(r)],o=(i,[{path:s}])=>{e(s)};return Y0("div",{className:jP(QP),style:t,children:Y0(JP,{source:n,groupSelection:"single",onSelectionChange:o})})};export{Wn as Action,eX as BORDER_STYLES,ta as Component,Fn as ComponentRegistry,$Y as ConfigWrapper,Uh as DockLayout,ma as Draggable,Co as DraggableLayout,Li as Drawer,cf as DropMenu,pn as DropTarget,Io as Flexbox,bd as FlexboxLayout,Oa as FluidGrid,Id as FluidGridLayout,Hd as Header,p2 as HeightOnly,Re as LayoutActionType,K0 as LayoutConfigurator,Cw as LayoutProvider,Oo as LayoutProviderContext,ZN as LayoutProviderVersion,j0 as LayoutTreeViewer,Sl as LocalLayoutPersistenceManager,XY as MARGIN_STYLES,yJ as MeasuredContainer,gh as NO_WRAPPED_ITEMS,M0 as OverflowContainer,ZY as PADDING_STYLES,Kb as Palette,dh as PaletteItem,Ui as Placeholder,zl as Stack,D0 as StackLayout,aT as Toolbar,qn as View,ss as ViewContext,wd as WidthHeight,m2 as WidthOnly,tX as XXXnormalizeStyles,iO as applyLayout,Do as applyLayoutProps,m0 as applyOverflowClassToWrappedItems,wr as asReactElements,Uf as componentToJson,af as computeMenuPosition,kx as containerOf,x0 as correctForWrappedHighPriorityItems,b0 as correctForWrappedOverflowIndicator,xa as createFlexbox,Ft as createPlaceHolder,Bo as defaultLayout,oa as expandFlex,T2 as extractResponsiveProps,Yt as findTarget,Te as followPath,Jh as followPathToComponent,Qt as followPathToParent,Mx as getChild,Gh as getChildProp,_I as getElementsMarkedAsWrapped,If as getFlexDimensions,ba as getFlexOrIntrinsicStyle,ya as getFlexStyle,at as getIntrinsicSize,Wf as getManagedDimension,Ei as getNonWrappedAndWrappedItems,Bf as getPersistentState,q as getProp,_ as getProps,Hf as hasPersistentState,Pf as hasUnboundedFlexStyle,y0 as highPriorityItemsHaveWrappedButShouldNotHave,ca as identifyDropTarget,IO as isApplicationLevelChange,ze as isContainer,Bh as isLayoutComponent,PO as isLayoutLevelChange,Vw as isResponsiveAttribute,fL as isTabstrip,DD as isTypeOf,hx as isView,Mr as layoutFromJson,ud as layoutReducer,$f as layoutToJSON,HI as markElementAsWrapped,BD as nextLeaf,Mt as nextStep,g0 as overflowIndicatorHasWrappedButShouldNotHave,HD as previousLeaf,Sa as processLayoutElement,ge as registerComponent,S0 as removeOverflowIndicatorIfNoLongerNeeded,Ee as resetPath,vd as resizeObserver,jh as resolveJSONPath,na as resolvePath,zv as serializeProps,_f as setPersistentState,zD as setRef,NI as sortByScreenOrder,yh as switchWrappedItemIntoView,K as typeOf,WI as unmarkItemsWhichAreNoLongerWrapped,kd as useBreakpoints,Sr as useId,Wj as useLayoutContextMenuItems,gd as useLayoutCreateNewChild,Xh as useLayoutEffectSkipFirst,ut as useLayoutProviderDispatch,Tw as useLayoutProviderVersion,h0 as useMeasuredContainer,kr as usePersistentState,rs as useResizeObserver,is as useViewActionDispatcher,CV as useViewContext,Vd as useViewDispatch,cF as warningLayout,ko as wrapIntrinsicSizeComponentWithFlexbox};
239
+ ${c} ${-s||0}px ${-l||0}px 0 0 inset`;return{...x,...S,...b,borderTopWidth:i,borderRightWidth:s,borderBottomWidth:l,borderLeftWidth:a,borderColor:c,borderStyle:"solid",boxShadow:C}}else return e}import eD from"react";import tD from"classnames";import{Tree as nD}from"@vuu-ui/vuu-ui-controls";import{jsx as ex}from"react/jsx-runtime";var rD="hwLayoutTreeViewer",tx=(r,e="0")=>({label:K(r),path:e,childNodes:eD.Children.map(r.props.children,(t,n)=>tx(t,e?`${e}.${n}`:`${n}`))}),Y0=({layout:r,onSelect:e,style:t})=>{let n=[tx(r)],o=(i,[{path:s}])=>{e(s)};return ex("div",{className:tD(rD),style:t,children:ex(nD,{source:n,groupSelection:"single",onSelectionChange:o})})};export{Wn as Action,iX as BORDER_STYLES,ta as Component,Fn as ComponentRegistry,jY as ConfigWrapper,Wh as DockLayout,ma as Draggable,To as DraggableLayout,Ai as Drawer,lf as DropMenu,pn as DropTarget,Po as Flexbox,gd as FlexboxLayout,Oa as FluidGrid,Ed as FluidGridLayout,Fd as Header,S2 as HeightOnly,Re as LayoutActionType,Q0 as LayoutConfigurator,Mw as LayoutProvider,No as LayoutProviderContext,l2 as LayoutProviderVersion,Y0 as LayoutTreeViewer,Sl as LocalLayoutPersistenceManager,rX as MARGIN_STYLES,xJ as MeasuredContainer,ph as NO_WRAPPED_ITEMS,E0 as OverflowContainer,oX as PADDING_STYLES,jb as Palette,hh as PaletteItem,Gi as Placeholder,zl as Stack,L0 as StackLayout,dT as Toolbar,qn as View,ls as ViewContext,xd as WidthHeight,C2 as WidthOnly,sX as XXXnormalizeStyles,fO as applyLayout,Lo as applyLayoutProps,g0 as applyOverflowClassToWrappedItems,wr as asReactElements,Wf as componentToJson,sf as computeMenuPosition,Rx as containerOf,v0 as correctForWrappedHighPriorityItems,x0 as correctForWrappedOverflowIndicator,xa as createFlexbox,Ft as createPlaceHolder,Ho as defaultLayout,oa as expandFlex,L2 as extractResponsiveProps,Yt as findTarget,Te as followPath,Kh as followPathToComponent,Qt as followPathToParent,Ix as getChild,$h as getChildProp,$I as getElementsMarkedAsWrapped,Ef as getFlexDimensions,ba as getFlexOrIntrinsicStyle,ya as getFlexStyle,at as getIntrinsicSize,_f as getManagedDimension,Ri as getNonWrappedAndWrappedItems,Vf as getPersistentState,q as getProp,_ as getProps,Ff as hasPersistentState,Rf as hasUnboundedFlexStyle,b0 as highPriorityItemsHaveWrappedButShouldNotHave,ca as identifyDropTarget,VO as isApplicationLevelChange,ze as isContainer,Vh as isLayoutComponent,FO as isLayoutLevelChange,EJ as isOverflowElement,Hw as isResponsiveAttribute,xL as isTabstrip,BD as isTypeOf,px as isView,Mr as layoutFromJson,ad as layoutReducer,zf as layoutToJSON,WI as markElementAsWrapped,GD as nextLeaf,Et as nextStep,y0 as overflowIndicatorHasWrappedButShouldNotHave,qD as previousLeaf,Sa as processLayoutElement,ge as registerComponent,C0 as removeOverflowIndicatorIfNoLongerNeeded,Ee as resetPath,bd as resizeObserver,qh as resolveJSONPath,na as resolvePath,Uv as serializeProps,Bf as setPersistentState,jD as setRef,BI as sortByScreenOrder,mh as switchWrappedItemIntoView,K as typeOf,GI as unmarkItemsWhichAreNoLongerWrapped,Cd as useBreakpoints,Sr as useId,Uj as useLayoutContextMenuItems,pd as useLayoutCreateNewChild,Qh as useLayoutEffectSkipFirst,ut as useLayoutProviderDispatch,Ew as useLayoutProviderVersion,f0 as useMeasuredContainer,kr as usePersistentState,os as useResizeObserver,ss as useViewActionDispatcher,DV as useViewContext,Od as useViewDispatch,yF as warningLayout,Mo as wrapIntrinsicSizeComponentWithFlexbox};
240
240
  //# sourceMappingURL=index.js.map