@vuu-ui/vuu-shell 0.8.9 → 0.8.10-debug
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/cjs/index.js +1760 -16
- package/cjs/index.js.map +4 -4
- package/esm/index.js +1767 -16
- package/esm/index.js.map +4 -4
- package/index.css +603 -1
- package/index.css.map +3 -3
- package/package.json +8 -4
- package/LICENSE +0 -201
package/esm/index.js
CHANGED
|
@@ -1,18 +1,1769 @@
|
|
|
1
|
-
|
|
2
|
-
`)),""):String(o)}import{useCallback as _0,useEffect as Q0,useLayoutEffect as q0,useRef as j0}from"react";var nh=["width"],oh=["height"],ao=new Map,rh=(o,e,t)=>{switch(t){case"height":return e.height;case"clientHeight":return o.clientHeight;case"clientWidth":return o.clientWidth;case"contentHeight":return e.contentHeight;case"contentWidth":return e.contentWidth;case"scrollHeight":return Math.ceil(o.scrollHeight);case"scrollWidth":return Math.ceil(o.scrollWidth);case"width":return e.width;default:return 0}};var th=new ResizeObserver(o=>{for(let e of o){let{target:t,borderBoxSize:n,contentBoxSize:r}=e,s=ao.get(t);if(s){let[{blockSize:i,inlineSize:l}]=n,[{blockSize:a,inlineSize:c}]=r,{onResize:u,measurements:d}=s,f=!1;for(let[h,p]of Object.entries(d)){let m=rh(t,{height:i,width:l,contentHeight:a,contentWidth:c},h);m!==p&&(f=!0,d[h]=m)}f&&u&&u(d)}}});function Cn(o,e,t,n=!1){let r=j0(e),s=o.current,i=_0(l=>{let{width:a,height:c}=l.getBoundingClientRect(),{clientWidth:u,clientHeight:d}=l;return r.current.reduce((f,h)=>(f[h]=rh(l,{width:a,height:c,contentHeight:d,contentWidth:u},h),f),{})},[]);q0(()=>{async function l(){ao.set(s,{measurements:{}}),await document.fonts.ready;let a=ao.get(s);if(a){let c=i(s);a.measurements=c,th.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&&(ao.has(s)&&console.log("useResizeObserver attemping to observe same element twice",{target:s}),l()),()=>{s&&ao.has(s)&&(th.unobserve(s),ao.delete(s))}},[i,s]),Q0(()=>{let l=o.current,a=ao.get(l);if(a){if(r.current!==e){r.current=e;let c=i(l);a.measurements=c}a.onResize=t}},[e,i,o,t])}var sh=o=>o==="none";var Bn=o=>Array.isArray(o)?o.length>0:o!=null,ih=o=>Array.isArray(o)?o[0]:o;import{useCallback as St,useMemo as li,useRef as ai,useState as dS,isValidElement as xh}from"react";import{isValidElement as xa,Children as X0}from"react";var lh=o=>null;var ah=o=>null;var Ca=(o,e)=>o!==null&&Object.prototype.hasOwnProperty.call(o,e),va=o=>Ca(o,"header"),ch=o=>Ca(o,"childNodes"),Qr=(o,e)=>o&&Object.prototype.hasOwnProperty.call(o.props,e),uh=o=>{if(xa(o)){if(Qr(o,"disabled"))return o.props.disabled===!0}else if(Ca(o,"disabled"))return o.disabled===!0;return!1},dh=o=>xa(o)&&Qr(o,"focusable")?o.props.focusable:!0,fh=(o,e,t)=>{if(o.childNodes)return o.childNodes.length;if(o.header){let n=t+1,r=0;for(;n<e.length&&!e[n].header;)r++,n++;return r}else return 0},J0=o=>{if(typeof o.props.children=="string")return o.props.children;if(o.props.title)return o.props.title;if(o.props.label)return o.props.label},hh=o=>o.type===ah||Qr(o,"data-header"),ph=o=>o.type===lh||Qr(o,"data-group"),Y0=o=>Qr(o,"selectable")?o.props.selectable===!0:!ph(o)&&!hh(o),Z0=o=>{if(ph(o)){let{props:{children:e}}=o;if(typeof e!="string")return wa(e)}},eS=(o,e)=>{let t=[];return X0.forEach(o,n=>{xa(n)&&t.push(e(n))}),t},Sa=(o,e)=>{if(Array.isArray(o))return o.length===0&&(e!=null&&e.noChildrenLabel)?[{label:e.noChildrenLabel,value:null}]:o.map((t,n)=>{var r,s;return{childNodes:Sa(t.childNodes,e),description:t.description,expanded:t.expanded,value:t,label:(s=(r=e==null?void 0:e.itemToString)==null?void 0:r.call(e,t))!=null?s:It(t)}});if(o)throw Error("list-child-items expects source to be an array")},wa=o=>{if(o)return eS(o,e=>{let{"data-id":t,disabled:n,id:r=t,"data-expanded":s,expanded:i=s}=e.props;return{childNodes:Z0(e),disabled:n,expanded:i,header:hh(e),id:r,label:J0(e),selectable:Y0(e),value:e}})},tS=new Set(["/","-","."]),nS=o=>tS.has(o),mh=(o,e)=>e.startsWith(o)&&nS(e[o.length]),oS=new Set([".","/"]);function rS(o,e){return e.startsWith(o)?oS.has(e.charAt(o.length)):!1}function oi(o,e,t){let n;return o.map(s=>s.id===e?{...s,...t}:rS(s.id,e)&&s.childNodes?(n=oi(s.childNodes,e,t),{...s,childNodes:n}):s)}var sS=/[.*+?^${}()|[\]\\]/g;function ri(o){return o.replace(sS,"\\$&")}var si=(o,e)=>Object.keys(o).reduce((n,r)=>{let s=o[r],i=e[r];return typeof s=="function"&&typeof i=="function"&&(n[r]=(...l)=>{s(...l),i(...l)}),n},{...e});var iS=o=>o&&o.replace(/^\s+/g,""),Ta=o=>new RegExp(`(${ri(iS(o))})`,"gi"),gh=(o="",e=Ta)=>(t="")=>!!t.length&&!!o.length&&t.match(e(o))!==null;function ii(o,e){return Array.isArray(o)?o.includes(e.id):o===e.id}import{isValidElement as lS,useCallback as aS,useEffect as bh,useRef as yh,useState as cS}from"react";function ka({controlled:o,default:e,name:t,state:n="value"}){let{current:r}=yh(o!==void 0),[s,i]=cS(e),l=o!==void 0?o:s,{current:a}=yh(e);bh(()=>{},[n,t,o]),bh(()=>{},[JSON.stringify(e,uS)]);let c=aS(u=>{r||i(u)},[r]);return[l,c,r]}function uS(o,e){return lS(e)?null:e}var fS={},Vn=({children:o,id:e,options:t=fS,source:n})=>{var A;let{getItemId:r}=t,[,s]=dS(null),i=eh(),l=ai([]),a=ai([]),c=li(()=>[],[]),u=ai((A=t.filterPattern)!=null?A:""),{getFilterRegex:d=Ta,noChildrenLabel:f,itemToString:h=It}=t,p=St(()=>t.defaultExpanded||!1,[t.defaultExpanded]),m=St((D,I,F=1,N="",V=[],K=[],G=[])=>(D.forEach((Q,X,U)=>{var je,Ee;let Y=Q.header&&t.collapsibleHeaders,ce=Q.childNodes&&t.collapsibleHeaders===!1,ie=!Q.childNodes||Q.childNodes.length===0,Ae=ce||ie&&!Y,me=N?`${N}.${X}`:`item-${X}`,Me=(je=Q.id)!=null?je:r?r(X):`${e}-${me}`,Ce=Ae?void 0:(Ee=Q.expanded)!=null?Ee:p(),ke={...Q,childNodes:void 0,count:!ce&&Ce===void 0?0:fh(Q,U,X),description:Q.description,disabled:uh(Q.value),focusable:dh(Q.value)?void 0:!1,id:Me,index:I.value,expanded:Ce,level:F};if(V.push(ke),K.push(ke),G.push(D[X].value),I.value+=1,Q.childNodes){let[Ge]=m(Q.childNodes,I,F+1,me,[],K,G);ke.childNodes=Ge}}),[V,G,K]),[t.collapsibleHeaders,r,e,p]),g=St(()=>u.current?gh(u.current,d):null,[d]),y=St((D,I=g(),F=[],N={value:0})=>{let V=!1;for(let K of D)V&&!va(K)||(K.value!==null&&(I===null||I(h(K.value)))&&(F[N.value]=K,N.value+=1),V=!1,va(K)&&K.expanded===!1?V=!0:ch(K)&&K.expanded!==!1&&K.childNodes&&y(K.childNodes,I,F,N));return F},[g,h]),E=li(()=>i?c:Sa(n,{itemToString:h,noChildrenLabel:f})||wa(o)||[],[i,c,n,h,f,o]),[v,x,C]=li(()=>i?[c,c,c]:m(E,{value:0}),[c,m,i,E]);a.current=C,li(()=>i?c:l.current=y(v),[c,y,v,i]);let b=ai(v),S=St((D="")=>{typeof D=="string"&&(u.current=D,l.current=y(v),s({}))},[v,y]),M=St((D,I=v)=>{let F=I.find(N=>{var V;return N.id===D||((V=N==null?void 0:N.childNodes)==null?void 0:V.length)&&mh(N.id,D)});if((F==null?void 0:F.id)===D)return x==null?void 0:x[F.index];if(F)return M(D,F.childNodes);throw Error(`useCollectionData itemById, id ${D} not found `)},[x,v]),w=St(D=>{let I=a.current.find(F=>xh(F.value)?F.label===D:F.value===D);if(I)return I;throw Error("useCollectionData toCollectionItem, item not found ")},[]),k=St(D=>{if(D===null)return null;if(Array.isArray(D)){let I=[];for(let F of D){let N=w(F);I.push(N)}return I}else if(D!==void 0)return w(D)},[w]),L=St(D=>{if(D===void 0)return;let I=k(D);return Array.isArray(I)?I.map(F=>F.id):I?I.id:null},[k]),T=St(D=>{let I=F=>{let N=a.current.find(V=>xh(V.value)?V.label===F:V.value!==null&&h(V.value)===F);if(N)return N};if(D===null)return null;if(Array.isArray(D)){let F=[];for(let N of D){let V=I(N);V&&F.push(V)}return F}else if(D!==void 0)return I(D)},[h]),P=St(D=>{for(let I of b.current)if(D===I.value)return I.id;throw Error("useCollectionData itemToId, item not found")},[]),R=St(D=>{b.current=oi(b.current,D.id,{expanded:!1}),l.current=y(b.current),s({})},[y]),O=St(D=>{b.current=oi(b.current,D.id,{expanded:!0}),l.current=y(b.current),s({})},[y]);return i||{collapseGroupItem:R,data:l.current,expandGroupItem:O,setFilterPattern:S,itemById:M,itemToId:P,toCollectionItem:w,itemToCollectionItem:k,itemToCollectionItemId:L,stringToCollectionItem:T}};import np from"classnames";import{useForkRef as Nw}from"@salt-ds/core";import{Children as Hw,cloneElement as op,forwardRef as Fw,useRef as Bw}from"react";import{useControlled as mS,useForkRef as gS}from"@salt-ds/core";import{useCallback as jo,useRef as Sh,useState as bS}from"react";import{useEffect as Ch,useRef as hS}from"react";var pS=[],vh=({popperRef:o,rootRef:e,isOpen:t,onClose:n})=>{let r=hS(t);Ch(()=>{r.current=t},[t]),Ch(()=>{let[s,i]=t?[l=>{var c,u;let a=l.target;!((c=o.current)!=null&&c.contains(a))&&!((u=e.current)!=null&&u.contains(a))&&n()},l=>{l.key==="Escape"&&r.current&&(n(),l.stopPropagation())}]:pS;return s&&i&&(document.body.addEventListener("mousedown",s,!0),document.body.addEventListener("keydown",i,!0)),()=>{s&&i&&(document.body.removeEventListener("mousedown",s,!0),document.body.removeEventListener("keydown",i,!0))}},[t,n,o,e])};var yS=[],wh=({defaultIsOpen:o,disabled:e,fullWidth:t,id:n,isOpen:r,onOpenChange:s,onKeyDown:i,openKeys:l=["Enter","ArrowDown"," "],openOnFocus:a,popupComponent:c,popupWidth:u,rootRef:d,width:f})=>{var O;let h=Sh(null),p=Sh(null),m=jo(A=>{p.current=A},[]),[g,y]=mS({controlled:r,default:!!o,name:"useDropdown",state:"isOpen"}),[E,v]=bS({width:(O=u!=null?u:f)!=null?O:0}),x=jo(()=>{y(!0),s==null||s(!0)},[s,y]),C=jo(()=>{y(!1),s==null||s(!1)},[s,y]);vh({popperRef:p,rootRef:d,isOpen:g,onClose:C});let b=jo(()=>{e||a&&(y(!0),s==null||s(!0),h.current=window.setTimeout(()=>{h.current=null},1e3))},[e,s,a,y]),S=jo(A=>{if(["Enter"," "].indexOf(A.key)===-1){let D=!g;y(D),s==null||s(D)}},[g,y,s]),M=jo(A=>{(A.key==="Tab"||A.key==="Escape")&&g?(A.key==="Escape"&&(A.stopPropagation(),A.preventDefault()),C()):l.includes(A.key)&&!g?(A.preventDefault(),x()):i==null||i(A)},[C,g,i,l,x]),w=t!=null?t:!1;Cn(d,w?nh:yS,v,w);let L=`${n}-dropdown`,T={"aria-expanded":g,"aria-owns":g?L:void 0,id:`${n}-control`,onClick:e||a?void 0:S,onFocus:b,role:"listbox",onKeyDown:e?void 0:M,style:{width:w?void 0:f}},P={id:L,width:E.width},R=gS(m,p);return{componentProps:P,popupComponentRef:R,isOpen:g,label:"Dropdown Button",triggerProps:T}};import{useId as Vw}from"@vuu-ui/vuu-layout";import{Scrim as LV}from"@salt-ds/lab";import{Button as NV,Text as HV}from"@salt-ds/core";import BV from"classnames";import{useCallback as KV,useRef as zV,useState as WV}from"react";import{useLayoutEffect as Eh,useMemo as SS}from"react";import*as Mh from"react-dom";import*as Th from"react-dom";import xS from"classnames";var CS=1,vS=({className:o,dataMode:e,x:t=0,y:n=0,win:r=window})=>{let s=r.document.createElement("div");return s.className=xS(`vuuPopup ${CS++}`,o),s.style.cssText=`left:${t}px; top:${n}px;`,e&&(s.dataset.mode=e),r.document.body.appendChild(s),s},kh=o=>vS(o),ci=(o,e,t,n,r)=>{e.style.cssText=`left:${t}px; top:${n}px;position: absolute;`,Th.render(o,e,r)};import wS from"classnames";var qr=function({children:e,x:t=0,y:n=0,onRender:r}){let[s,i,l]=wt(),a=SS(()=>kh({className:wS(s,i),dataMode:l}),[l,i,s]);return Eh(()=>{ci(e,a,t,n,r)},[e,r,a,t,n]),Eh(()=>()=>{var c;a&&(Mh.unmountComponentAtNode(a),a.classList.contains("vuuPopup")&&((c=a.parentElement)==null||c.removeChild(a)))},[a]),null};import{jsx as QV,jsxs as qV}from"react/jsx-runtime";import{useCallback as Gh,useRef as Aa}from"react";import Bh,{useLayoutEffect as BS,useMemo as VS,useRef as $S}from"react";import Vh from"classnames";import{useId as KS}from"@vuu-ui/vuu-layout";import{useCallback as ui,useMemo as RS,useRef as Ea,useState as AS}from"react";var Ph=o=>o.closest("[data-root='true']")!==null,Dh=(o,e)=>{var t;return o.ariaHasPopup==="true"&&((t=o.dataset)==null?void 0:t.idx)===`${e}`||o.querySelector(`:scope > [data-idx='${e}'][aria-haspopup='true']`)!==null};function TS(o,...e){let t=new Set(o);for(let n of e)for(let r of n)t.add(r);return t}var kS="Enter";var ES="Delete",MS=new Set([kS,ES]),PS=new Set(["Tab"]),DS=new Set(["ArrowRight","ArrowLeft"]),Ih=new Set(["Home","End","ArrowDown","ArrowUp"]),Rh=new Set(["Home","End","ArrowRight","ArrowLeft"]),IS=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),ZV=TS(MS,Rh,Ih,DS,IS,PS);var Ah=({key:o},e="vertical")=>(e==="vertical"?Ih:Rh).has(o);import{isValidNumber as Ma}from"@vuu-ui/vuu-utils";var Lh=({autoHighlightFirstItem:o=!1,count:e,defaultHighlightedIdx:t,highlightedIndex:n,onActivate:r,onHighlight:s,onCloseMenu:i,onOpenMenu:l})=>{var x;if(Ma(n)&&Ma(t))throw Error("useKeyboardNavigation do not pass values for both highlightedIndex and defaultHighlightedIdx");let a=Ma(n),c=Ea((x=t!=null?t:n)!=null?x:o?0:-1),[,u]=AS(null),d=ui(C=>{c.current=C,s==null||s(C),u({})},[s]),f=ui(C=>{C!==c.current&&(a||d(C))},[a,d]),h=Ea(!0),p=Ea(!1),m=C=>p.current=C,g=a?n:c.current,y=ui(C=>{let b=LS(e,C.key,c.current);b!==c.current&&f(b)},[e,f]),E=ui(C=>{if(Ah(C))C.preventDefault(),C.stopPropagation(),h.current=!0,y(C);else if((C.key==="ArrowRight"||C.key==="Enter")&&Dh(C.target,g)){let S=C.target.querySelector(`:scope > [data-idx='${g}']`);S&&(l==null||l(S))}else C.key==="ArrowLeft"&&!Ph(C.target)?i(g):C.key==="Enter"?(C.preventDefault(),C.stopPropagation(),r&&r(g)):C.key==="Tab"&&i(-1)},[g,y,r,i,l]),v=RS(()=>({onFocus:()=>{g===-1&&d(0)},onKeyDown:E,onMouseDownCapture:()=>{h.current=!1,m(!0)},onMouseMove:()=>{h.current&&(h.current=!1)},onMouseLeave:()=>{h.current=!0,m(!1),f(-1)}}),[E,g,d,f]);return{focusVisible:h.current?g:-1,controlledHighlighting:a,highlightedIndex:g,setHighlightedIndex:f,listProps:v,setIgnoreFocus:m}};function LS(o,e,t){return e==="ArrowUp"?t>0?t-1:t:t===null?0:t===o-1?t:t+1}import Oh,{useCallback as OS,useMemo as NS}from"react";var Pa=o=>o.type===di||!!o.props["data-group"],HS=o=>{if(Array.isArray(o)&&Da(o[0]))return o[0]},FS=(o,e,t,n=!1)=>{let{props:{children:r}}=o;return{childWithId:Oh.cloneElement(o,{hasSeparator:n,id:`${e}`,key:e,children:t?HS(r):r}),grandChildren:t?r:void 0}},Nh=(o,e)=>{let t=OS(()=>{let s=(i,l=e,a={},c={})=>{let u=a[l]=[],d=0,f=!1;return Oh.Children.forEach(i,h=>{if(!Da(h))if(h.type===Hh)f=!0;else{let p=Pa(h),m=`${l}-${d}`,{props:{action:g,options:y}}=h,{childWithId:E,grandChildren:v}=FS(h,m,p,f);u.push(E),v?s(v,m,a,c):c[m]={action:g,options:y},d+=1,f=!1}}),[a,c]};return s(o)},[e,o]),[n,r]=NS(()=>t(),[t]);return[n,r]};import{Fragment as GS,jsx as Xo}from"react/jsx-runtime";var Fh="vuuMenuList",Hh=()=>Xo("li",{className:"vuuMenuItem-divider"}),di=()=>null,fi=({children:o,idx:e,...t})=>Xo("div",{...t,children:o}),$h=({children:o})=>Xo(GS,{children:o});$h.displayName="MenuItemLabel";fi.Label=$h;var zS=o=>Bh.isValidElement(o)&&typeof o.type!="string"&&"displayName"in o.type?o.type.displayName:void 0,Da=o=>zS(o)==="MenuItemLabel",WS=o=>o.props["data-icon"],Ia=({activatedByKeyboard:o,childMenuShowing:e,children:t,className:n,defaultHighlightedIdx:r,highlightedIdx:s,id:i,isRoot:l,listItemProps:a,onHighlightMenuItem:c,onActivate:u,onCloseMenu:d,onOpenMenu:f,...h})=>{let p=KS(i),m=$S(null),g=VS(()=>new Map,[]),y=M=>{var k;let w=(k=m.current)==null?void 0:k.querySelector(`:scope > [data-idx='${M}']`);w!=null&&w.id&&(u==null||u(w.id))},{focusVisible:E,highlightedIndex:v,listProps:x}=Lh({count:Bh.Children.count(t),defaultHighlightedIdx:r,highlightedIndex:s,onActivate:y,onHighlight:c,onOpenMenu:f,onCloseMenu:d}),C=e==null?E:-1;BS(()=>{var M;e===void 0&&o&&((M=m.current)==null||M.focus())},[o,e]);let b=()=>v===void 0||v===-1?void 0:g.get(v);function S(){let M={...a,role:"menuitem"},w=(T,P,R)=>P?[Xo("span",{className:"vuuIconContainer","data-icon":R},"icon")].concat(T):T;function k(T,P,R,O){var U;let{children:A,className:D,"data-icon":I,id:F,hasSeparator:N,label:V,...K}=P.props,G=Pa(P),Q=G&&e===F,X=Q?`${p}-${F}`:void 0;T.push(Xo(fi,{...K,...M,...US(F,R,(U=P.key)!=null?U:F,v,C,D,N),"aria-controls":X,"aria-haspopup":G||void 0,"aria-expanded":Q||void 0,children:w(G&&V!=null?V:A,O,I)}))}let L=[];if(t.length>0){let T=t.some(WS);t.forEach((P,R)=>{k(L,P,R,T)})}return L}return Xo("div",{...h,...x,"aria-activedescendant":b(),className:Vh(Fh,n,{[`${Fh}-childMenuShowing`]:e!==void 0}),"data-root":l||void 0,id:p,ref:m,role:"menu",children:S()})},US=(o,e,t,n,r,s,i)=>({id:`menuitem-${o}`,key:t!=null?t:e,"data-idx":e,"data-highlighted":e===n||void 0,className:Vh("vuuMenuItem",s,{"vuuMenuItem-separator":i,focusVisible:r===e})});Ia.displayName="MenuList";import{useCallback as Qt,useMemo as _S,useRef as hi,useState as QS}from"react";var Ra=o=>o==null?void 0:o.closest("[data-idx],[aria-posinset]");var zh=(o,e,t)=>o.map((n,r)=>r===o.length-1?{...n,[t]:n[t]-e}:n),qS=(o,e)=>zh(o,e,"left"),jS=(o,e)=>zh(o,e,"top"),XS=(o,e)=>{let[t,n]=e.slice(-2),r=document.getElementById(`${o}-${n.id}`);if(r===null)throw Error(`useCascade.flipSides element with id ${n.id} not found`);let{width:s}=r.getBoundingClientRect();return e.map(i=>i===n?{...i,left:t.left-(s-2)}:i)},JS=(o,e)=>{let[{left:t,top:n}]=e.slice(-1),{offsetWidth:r,offsetTop:s}=o;return{left:t+r,top:s+n}},Wh=(o,e)=>{let t=o.lastIndexOf("-");return t>-1?o.slice(9,t):e},YS=o=>o.slice(9),Kh=({ariaExpanded:o,ariaHasPopup:e,id:t},n)=>{if(t.startsWith("menuitem"))return{hostMenuId:Wh(t,n),targetMenuId:YS(t),menuItemId:t,isGroup:e==="true",isOpen:o==="true"};throw Error(`getMenuItemDetails #${t} is not a menuitem`)},Uh=({id:o,onActivate:e,onMouseEnterItem:t,position:{x:n,y:r}})=>{let[,s]=QS({}),i=hi([{id:o,left:n,top:r}]),l=Qt(b=>i.current.findIndex(S=>S.id===b)!==-1,[]),a=Qt(b=>{let S=f.current[b];if(S===void 0)throw Error(`getOpenMenuState no entry for menu ${b}`);return S},[]),c=Qt(b=>{i.current=b,s({})},[]),u=hi(),d=hi(),f=hi({[o]:"no-popup"}),h=Qt((b=o,S,M=null)=>{if(b===o&&M===null)c([{id:o,left:n,top:r}]);else{f.current[b]="popup-open";let w=document.getElementById(M);if(w!==null){let{left:k,top:L}=JS(w,i.current);c(i.current.concat({id:S,left:k,top:L}))}else throw Error(`openMenu no menuItem ${M}`)}},[o,n,r,c]),p=Qt(b=>{if(b===o)c([]);else{let S=i.current.slice(),M=S.pop();f.current[M.id]="no-popup";let w=S.at(-1);w&&(f.current[w.id]="no-popup"),c(S)}},[o,c]),m=Qt(b=>{let S=i.current.slice(),M=b.slice(9),{id:w}=S.at(-1);for(;S.length>1&&!M.startsWith(w);){let k=Wh(w,o);S.pop(),f.current[w]="no-popup",f.current[k]="no-popup",{id:w}=S[S.length-1]}S.length<i.current.length&&c(S)},[o,c]),g=Qt(()=>{u.current&&(clearTimeout(u.current),u.current=void 0)},[]),y=Qt((b,S,M)=>{g(),u.current=window.setTimeout(()=>{m(M),f.current[b]="popup-open",f.current[S]="no-popup",h(b,S,M)},400)},[g,m,h]),E=Qt((b,S,M)=>{f.current[S]="pending-close",d.current=window.setTimeout(()=>{m(M)},400)},[m]),v=Qt(()=>{let{current:b}=i,[S]=b.slice(-1),M=document.getElementById(S.id);if(M){let{right:w,bottom:k}=M.getBoundingClientRect(),{clientHeight:L,clientWidth:T}=document.body;if(w>T){let P=b.length>1?XS(o,b):qS(b,w-T);c(P)}else if(k>L){let P=jS(b,k-L);c(P)}typeof M.tabIndex=="number"&&M.focus()}else console.log(`no element found with if ${S.id}`)},[o,c]),x=Qt(b=>{let{hostMenuId:S,targetMenuId:M,menuItemId:w,isGroup:k,isOpen:L}=Kh(b,o),{current:{[S]:T}}=f;if(T==="no-popup"&&k)f.current[S]="popup-pending",y(S,M,w);else if(T==="popup-pending"&&!k)f.current[S]="no-popup",clearTimeout(u.current),u.current=void 0;else if(T==="popup-pending"&&k)clearTimeout(u.current),y(S,M,w);else if(T==="popup-open")if(l(M)){let P=a(M);switch(m(w),P){case"pending-close":clearTimeout(d.current),d.current=void 0,f.current[M]="no-popup",g();break;default:}}else{let[P,R]=i.current.slice(-2);P.id===S&&f.current[R.id]!=="pending-close"?(E(S,R.id,w),k&&!L&&y(S,M,w)):P.id===S&&k&&w!==R.id&&f.current[R.id]==="pending-close"||k?y(S,M,w):f.current[R.id]!=="pending-close"&&m(w)}T==="pending-close"&&(g(),clearTimeout(d.current),d.current=void 0,f.current[S]="popup-open")},[g,m,a,l,o,E,y]),C=_S(()=>({onMouseEnter:b=>{let S=Ra(b.target);x(S),t(b,S.id)},onClick:b=>{let S=Ra(b.target),{isGroup:M,menuItemId:w}=Kh(S,o);M?x(S):e(w)}}),[e,t,o,x]);return{closeMenu:p,handleRender:v,listItemProps:C,openMenu:x,openMenus:i.current}};import{useId as ZS}from"@vuu-ui/vuu-layout";import{Fragment as nw,jsx as _h}from"react/jsx-runtime";import{createElement as tw}from"react";var ew=()=>{},La=({activatedByKeyboard:o,children:e,className:t,id:n,onClose:r=()=>{},position:s={x:0,y:0},style:i,...l})=>{let a=Aa(r);a.current=r;let c=ZS(n),u=Aa(ew),[d,f]=Nh(e,c),h=Aa(o),p=Gh(()=>{h.current=!1},[]),m=Gh(w=>{let k=w.slice(9),{action:L,options:T}=f[k];u.current(c),r({type:"menu-action",menuId:L,options:T})},[f,c,r]),{closeMenu:g,listItemProps:y,openMenu:E,openMenus:v,handleRender:x}=Uh({id:`${c}`,onActivate:m,onMouseEnterItem:p,position:s});u.current=g;let C=()=>{h.current=!0,g()},b=()=>{},S=v.length-1,M=w=>{if(!(w>=S)){let{id:k}=v[w+1];return k}};return _h(nw,{children:v.map(({id:w,left:k,top:L},T,P)=>{let R=M(T);return _h(qr,{x:k,y:L,onRender:x,children:tw(Ia,{...l,activatedByKeyboard:h.current,childMenuShowing:R,className:t,id:w,isRoot:T===0,key:T,listItemProps:y,onActivate:m,onHighlightMenuItem:b,onCloseMenu:C,onOpenMenu:E,style:i,tabIndex:T===P.length-1?0:void 0},d[w])},T)})})};La.displayName="ContextMenu";import{createContext as ow,useCallback as rw,useMemo as sw}from"react";import{jsx as Oa}from"react/jsx-runtime";var pi=ow(null),iw=({children:o,context:e,menuActionHandler:t,menuBuilder:n})=>{let r=sw(()=>e!=null&&e.menuBuilders&&n?e.menuBuilders.concat(n):n?[n]:(e==null?void 0:e.menuBuilders)||[],[e,n]),s=rw(i=>{var l;if(t!=null&&t(i)||(l=e==null?void 0:e.menuActionHandler)!=null&&l.call(e,i))return!0},[e,t]);return Oa(pi.Provider,{value:{menuActionHandler:s,menuBuilders:r},children:o})},Na=({children:o,label:e,menuActionHandler:t,menuBuilder:n})=>Oa(pi.Consumer,{children:r=>Oa(iw,{context:r,label:e,menuActionHandler:t,menuBuilder:n,children:o})});import{isGroupMenuItemDescriptor as gw}from"@vuu-ui/vuu-utils";import bw from"classnames";import{cloneElement as yw,useCallback as $a,useContext as xw}from"react";import lw from"classnames";import e3,{createElement as Qh,useEffect as r3,useRef as s3}from"react";import Ha from"react-dom";var Fa=!1,Rt=[],qh=o=>(o==null?void 0:o.type)==="menu-action",jh=o=>(o==null?void 0:o.type)==="click-away";function Xh(o){if(o.key==="Esc"){if(Rt.length)Yh();else if(Fa){let e=document.body.querySelector(".vuuDialog");e&&Ha.unmountComponentAtNode(e)}}}function Jh(o){if(Rt.length){let e=document.body.querySelectorAll(".vuuPopup");for(let t=0;t<e.length;t++)if(e[t].contains(o.target))return;Yh({mouseEvt:o,type:"click-away"})}}function Yh(o){if(Rt.length===1)ze.hidePopup(o,"anon","all");else if(Rt.length){let e=document.body.querySelectorAll(".vuuPopup");for(let t=0;t<e.length;t++)Ha.unmountComponentAtNode(e[t]);Zh("*")}}function aw(o){Rt.indexOf(o)===-1&&(Rt.push(o),Fa===!1&&(window.addEventListener("keydown",Xh,!0),window.addEventListener("click",Jh,!0)))}function Zh(o){if(Rt.length){if(o==="*")Rt.length=0;else{let e=Rt.indexOf(o);e!==-1&&Rt.splice(e,1)}Rt.length===0&&Fa===!1&&(window.removeEventListener("keydown",Xh,!0),window.removeEventListener("click",Jh,!0))}}var cw=({children:o,position:e,style:t})=>{let n=lw("hwPopup","hwPopupContainer",e);return Qh("div",{className:n,style:t},o)},uw=1,ze=class{static showPopup({group:e="all",name:t="anon",left:n=0,position:r="",right:s="auto",top:i=0,width:l="auto",component:a}){if(!a)throw Error("PopupService showPopup, no component supplied");typeof a.props.onClose=="function"?ze.onClose=a.props.onClose:ze.onClose=void 0,aw(t),document.addEventListener("keydown",ze.escapeKeyListener,!0);let c=document.body.querySelector(".vuuPopup."+e);c===null&&(c=document.createElement("div"),c.className="vuuPopup "+e,document.body.appendChild(c));let u={width:l};ci(Qh(cw,{key:uw++,position:r,style:u},a),c,n,i,()=>{ze.keepWithinThePage(c,s)})}static escapeKeyListener(e){e.key==="Escape"&&ze.hidePopup({type:"escape",event:e})}static hidePopup(e,t="anon",n="all"){var r;if(Rt.indexOf(t)!==-1){Zh(t);let s=document.body.querySelector(`.vuuPopup.${n}`);s&&Ha.unmountComponentAtNode(s)}document.removeEventListener("keydown",ze.escapeKeyListener,!0),(r=ze==null?void 0:ze.onClose)==null||r.call(ze,e)}static keepWithinThePage(e,t="auto"){let n=e.querySelector(".vuuPopupContainer > *");if(n){let{top:r,left:s,width:i,height:l,right:a}=n.getBoundingClientRect(),c=window.innerWidth,d=window.innerHeight-(r+l);d<0&&(n.style.top=Math.round(r)+d+"px");let f=c-(s+i);if(f<0&&(n.style.left=Math.round(s)+f+"px"),typeof t=="number"&&t!==a){let h=t-a;n.style.left=s+h+"px"}}}};import pw from"classnames";import{useLayoutEffect as dw,useState as fw}from"react";var hw=(o,e,t,n)=>{let{bottom:r,left:s,right:i,top:l,width:a}=o.getBoundingClientRect();switch(e){case"below":return{left:s+t,top:r+n};case"right":return{left:i+t,top:l+n};case"below-center":return{left:s+a/2+t,top:r+n};case"below-full-width":return{left:s+t,top:r+n,width:a};default:throw Error("Popup getPositionRelativeToAnchor only supported placement values are below and right")}},Ba=({anchorElement:o,offsetLeft:e=0,offsetTop:t=0,placement:n})=>{let[r,s]=fw();return dw(()=>{if(o.current){let i=hw(o.current,n,e,t);s(i)}},[o,e,t,n]),r};import{jsx as mw}from"react/jsx-runtime";var Va=({children:o,className:e,anchorElement:t,placement:n})=>{let[r,s,i]=wt(),l=Ba({anchorElement:t,placement:n});return l===void 0?null:mw("div",{className:pw("vuuPortal",e,r,s),"data-mode":i,style:l,children:o})};import{jsx as Ka}from"react/jsx-runtime";var vn=(o,e)=>{let t=xw(pi),[n,r,s]=wt(),i=$a((c,u,d)=>{let f=[];for(let h of c)f=f.concat(h(u,d));return f},[]),l=$a((c,u,{ContextMenuProps:d,contextMenu:f,...h})=>{var m,g;if((m=c.stopPropagation)==null||m.call(c),(g=c.preventDefault)==null||g.call(c),f)return vw({x:c.clientX,y:c.clientY},f);let p=[];if(o&&p.push(o),t&&Array.isArray(t==null?void 0:t.menuBuilders)&&t.menuBuilders.length>0&&p.push(...t.menuBuilders),p.length>0){let y=i(p,u,h),E=v=>(e==null?void 0:e(v))===!0?!0:t==null?void 0:t.menuActionHandler(v);y.length&&E&&Sw(c,y,E,{...d,className:bw(d==null?void 0:d.className,n,r),"data-mode":s})}else console.warn("useContextMenu, no menuBuilders configured. These should be supplied via the ContextMenuProvider(s)")},[i,t,s,r,e,o,n]),a=$a(()=>{console.log("hide comnytext menu")},[]);return[l,a]},Cw={},vw=(o,e)=>{ze.showPopup({focus:!0,left:0,top:0,component:yw(e,{position:o})})},Sw=(o,e,t,{position:n,...r}=Cw)=>{let s=c=>{let u=(d,f)=>gw(d)?Ka(di,{label:d.label,children:d.children.map(u)},f):Ka(fi,{action:d.action,className:d.className,"data-icon":d.icon,options:d.options,children:d.label},f);return c.map(u)},i=c=>{var u;qh(c)&&(t(c),ze.hidePopup()),(u=r==null?void 0:r.onClose)==null||u.call(r,c)},l=n!=null?n:{x:o.clientX,y:o.clientY},a=Ka(La,{...r,className:"vuuContextMenu",onClose:i,position:l,children:s(e)});ze.showPopup({left:0,top:0,component:a,focus:!0})};import{useCallback as ep,useRef as tp,useState as ww}from"react";import Tw from"classnames";import{Button as kw}from"@salt-ds/core";import{useId as Ew}from"@vuu-ui/vuu-layout";import{jsx as Pw}from"react/jsx-runtime";var za="vuuPopupMenu",Mw=o=>{if(o){let{bottom:e,left:t}=o.getBoundingClientRect();return{x:t,y:e+6}}},Wa=({className:o,label:e,icon:t=e?"chevron-down":"more-vert",id:n,menuActionHandler:r,menuBuilder:s,menuLocation:i="header",menuOptions:l,onMenuClose:a,tabIndex:c=0,...u})=>{let d=tp(null),f=tp(!1),[h,p]=ww(!1),m=Ew(n),[g]=vn(s,r),y=ep(v=>{p(!1),jh(v)?v.mouseEvt.target===d.current&&(f.current=!0):requestAnimationFrame(()=>{var x;a==null||a(v),c!==-1&&((x=d.current)==null||x.focus())})},[a,c]),E=ep(v=>{f.current?f.current=!1:(p(!0),g(v,i,{ContextMenuProps:{className:"vuuPopupMenuList",id:`${m}-menu`,onClose:y,position:Mw(d.current)},...l}))},[y,m,i,l,g]);return Pw(kw,{...u,"aria-controls":`${m}-menu-root`,"aria-expanded":h,"aria-haspopup":"menu",className:Tw(za,o,{[`${za}-withCaption`]:e!==void 0,[`${za}-open`]:h}),"data-icon":t,id:m,onClick:E,ref:d,tabIndex:c,variant:"secondary",children:e})};import{useLayoutEffect as Dw,useRef as Iw,useState as Rw}from"react";import{createPortal as Aw}from"react-dom";function Lw(o){return typeof o=="function"?o():o}var Ow="vuu-portal-root",mi=({children:o,container:e=document.body,id:t=Ow,open:n=!0})=>{var d;let[r,s]=Rw(!1),i=Iw(null),l=(d=Lw(e))!=null?d:document.body,[a,c,u]=wt();return Dw(()=>{let f=document.getElementById(t);f?i.current=f:(i.current=document.createElement("div"),i.current.id=t);let h=i.current;l.contains(h)||l.appendChild(h),h.classList.add(a,c),h.dataset.mode=u,s(!0)},[t,l,a,c,u]),n&&r&&i.current&&o?Aw(o,i.current):null};import{Button as y$}from"@salt-ds/core";import C$ from"classnames";import{useLayoutEffect as w$,useRef as T$}from"react";import{jsx as I$,jsxs as R$}from"react/jsx-runtime";var P$={current:document.body};import{useLayoutEffect as F$,useState as B$}from"react";import{jsx as q$}from"react/jsx-runtime";import{useCallback as Z$,useRef as e5,useState as t5}from"react";import{useId as o5}from"@vuu-ui/vuu-layout";import{jsx as rp,jsxs as $w}from"react/jsx-runtime";var gi="vuuDropdown",bi=Fw(function({"aria-labelledby":e,children:t,className:n,defaultIsOpen:r,disabled:s,fullWidth:i,id:l,isOpen:a,onKeyDown:c,onOpenChange:u,openKeys:d,openOnFocus:f,placement:h="below",popupWidth:p,width:m,...g},y){let E=Bw(null),v=np(gi,n,{[`${gi}-fullWidth`]:i,[`${gi}-disabled`]:s}),[x,C]=Hw.toArray(t),b=Vw(l),{componentProps:S,isOpen:M,popupComponentRef:w,triggerProps:k}=wh({ariaLabelledBy:e,defaultIsOpen:r,disabled:s,fullWidth:i,id:b,isOpen:a,onOpenChange:u,onKeyDown:c,openKeys:d,openOnFocus:f,popupComponent:C,popupWidth:p,rootRef:E,width:m}),L=()=>{let{id:R,role:O,...A}=k,{id:D=R,role:I=O,...F}=x.props;return op(x,si(F,{...A,id:D,role:I}))},T=()=>{let{id:R,width:O,...A}=S,{className:D,id:I=R,width:F,...N}=C.props;return op(C,{...N,...A,className:np(D,`${gi}-popup-component`),id:I,ref:w,width:F!=null?F:O})},P=Nw(E,y);return $w("div",{...g,className:v,id:l,ref:P,children:[L(),M&&rp(mi,{children:rp(Va,{anchorElement:E,placement:h,children:T()})})]})});import{Button as Kw}from"@salt-ds/core";import zw from"classnames";import{forwardRef as Ww}from"react";import{jsx as Ua,jsxs as Uw}from"react/jsx-runtime";var jr="vuuDropdownButton",sp=Ww(function({ariaHideOptionRole:e,className:t,disabled:n,icon:r="chevron-down",isOpen:s,label:i,labelId:l,fullWidth:a,posInSet:c,setSize:u,labelAriaAttributes:d,...f},h){return Ua(Kw,{className:zw(jr,{[`${jr}-fullWidth`]:a},t),disabled:n,variant:"secondary",...f,ref:h,children:Uw("div",{className:`${jr}-content`,children:[Ua("span",{"aria-hidden":e?"true":void 0,...d,className:`${jr}-buttonLabel`,id:l,role:"option",children:i}),Ua("span",{className:`${jr}-buttonIcon`,"data-icon":r,"aria-hidden":"true"})]})})});import{useForkRef as $k}from"@salt-ds/core";import{cloneElement as Kk,forwardRef as zk,useCallback as Wk,useRef as lm}from"react";import{useId as Uk}from"@vuu-ui/vuu-layout";function Gw(o,...e){let t=new Set(o);for(let n of e)for(let r of n)t.add(r);return t}var Xr="ArrowUp",Jr="ArrowDown",ip="ArrowLeft",lp="ArrowRight",Ga="Enter";var yi="Home",Yr="End",_a="PageUp",xi="PageDown",ap=" ",_w=new Set(["Enter","Delete"," "]),Qw=new Set(["Tab"]),qw=new Set(["ArrowRight","ArrowLeft"]),cp=new Set([yi,Yr,_a,xi,Jr,Xr]),jw=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),Xw=Gw(_w,cp,qw,jw,Qw),Ci=o=>Xw.has(o.key)?!1:o.key.length===1&&!o.ctrlKey&&!o.metaKey&&!o.altKey,up=({key:o})=>cp.has(o);import{useCallback as dp}from"react";var Jw={},Yw=o=>Array.isArray(o.childNodes),Zw=o=>!0,eT=o=>o.closest("[data-toggle],[aria-expanded]").dataset.toggle==="true",fp=({collapsibleHeaders:o,collectionHook:e,highlightedIdx:t,onToggle:n})=>{let r=dp(l=>{if(l.key===lp||l.key===Ga){let a=e.data[t];a&&a.expanded===!1&&a.value&&(l.preventDefault(),e.expandGroupItem(a),n==null||n(a.value))}if(l.key===ip||l.key===Ga){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]),i={onClick:dp(l=>{console.log(`useCollapsibleGroups idx=${t}`);let a=e.data[t];console.log(l.target,l.currentTarget),a&&Yw(a)&&(!Zw(a)||eT(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:r};return o?i:Jw};function tT(o){if(o){let e=o.dataset.index;if(e)return parseInt(e,10);if(e=o.ariaPosInSet)return parseInt(e,10)-1}return-1}var nT=o=>o.closest("[data-index],[aria-posinset]");var hp=o=>tT(nT(o));import{useImperativeHandle as oT,useMemo as rT}from"react";var sT={scrollToIndex:()=>{},scrollToItem:()=>{},scrollTo:()=>{}},vi=({collectionHook:o,forwardedRef:e,scrollableRef:t,scrollIntoView:n})=>{let r=rT(()=>({scrollToIndex:s=>{let i=o.data[s];i&&(n==null||n(i))},scrollToItem:s=>{let i=o.toCollectionItem(s);i&&(n==null||n(i))},scrollTo:s=>{t!=null&&t.current&&(t.current.scrollTop=s)}}),[o,n,t]);oT(e,()=>t.current?r:sT,[r,t])};import{useControlled as iT}from"@salt-ds/core";import{useCallback as Jo,useMemo as lT,useRef as Qa,useState as aT}from"react";import{getElementByDataIndex as ja}from"@vuu-ui/vuu-utils";var Xa=-2;function pp(o,e,t){return e===Xr||e===Yr?t>0?t-1:t:t===null?0:t===o-1?t:t+1}var qa=(o,e)=>{let t=ih(e);return t?o.indexOf(t):-1},cT=(o,e,t,n)=>o===Yr?n:o===yi?-1:e!==-1?e:t,uT=(o,e,t,n)=>{let{top:r}=e.getBoundingClientRect(),{scrollTop:s,clientHeight:i,scrollHeight:l}=o,a=t-1,c=Math.min(s+i,l-i);if(c!==s&&n<a){o.scrollTo(0,c);let u=n,d;do u+=1,d=ja(o,u,!0).getBoundingClientRect();while(d.top<r&&u<a);return u}},dT=async(o,e,t)=>{let{top:n}=e.getBoundingClientRect(),{scrollTop:r,clientHeight:s}=o,i=Math.max(r-s,0);if(i!==r&&t>0)return o.scrollTo(0,i),new Promise(l=>{requestAnimationFrame(()=>{let a=t,c;do a-=1,c=ja(o,a,!0).getBoundingClientRect();while(c.top>n&&a>0);l(a)})})},fT=o=>!o.header&&!o.childNodes,mp=o=>fT(o)||o.expanded!==void 0,gp=({containerRef:o,defaultHighlightedIndex:e=-1,disableHighlightOnFocus:t,highlightedIndex:n,indexPositions:r,itemCount:s,onHighlight:i,onKeyboardNavigation:l,restoreLastFocus:a,selected:c,viewportItemCount:u})=>{let d=Qa(-1),[,f]=aT({}),[h,p,m]=iT({controlled:n,default:e,name:"UseKeyboardNavigation"}),g=Jo((k,L=!1)=>{i==null||i(k),p(k),L&&(d.current=k)},[i,p]),y=Jo(async(k,L)=>{let T=ja(o.current,L,!0),P;if(T){let{current:R}=o;T&&R&&(P=k===xi?uT(R,T,s,L):await dT(R,T,L))}return P!=null?P:L},[o,s]),E=Jo((k=Jr,L=k===Jr?-1:s)=>{if(s===0)return-1;{let T=qa(r,c),P=cT(k,L,T,s),R=pp(s,k,P);if(R===0&&k===Xr&&!mp(r[0]))return L;for(;((k===Jr||k===yi)&&R<s||(k===Xr||k===Yr)&&R>0)&&!mp(r[R]);)R=pp(s,k,R);return R}},[r,s,c]),v=Qa(!1),x=Qa(!1),C=k=>x.current=k,b=Jo(()=>{if(x.current)x.current=!1;else if(v.current=!0,r.length===0)g(Xa);else if(h!==-1)f({});else if(a)if(d.current!==-1)g(d.current);else{let k=qa(r,c);g(k!==-1?k:0)}else if(Bn(c)){let k=qa(r,c);g(k)}else t!==!0&&g(E())},[t,h,r,E,a,c,g]),S=Jo(async k=>{let L=k.key===xi||k.key===_a?await y(k.key,h):E(k.key,h);L!==h&&g(L,!0),l==null||l(k,L)},[h,E,y,l,g]),M=Jo(k=>{s>0&&up(k)?(k.preventDefault(),k.stopPropagation(),v.current=!0,S(k)):Ci(k)&&(v.current=!0)},[s,S]),w=lT(()=>({onBlur:k=>{let L=k.target.closest(".vuuList"),T=k.relatedTarget;L&&!(L!=null&&L.contains(T))&&(v.current=!1,p(-1),a||(d.current=-1))},onFocus:b,onKeyDown:M,onMouseDownCapture:()=>{v.current=!1,C(!0)},onMouseMove:()=>{v.current&&(v.current=!1)},onMouseLeave:()=>{v.current=!1,C(!1),g(-1)}}),[b,M,a,p,g]);return{focusVisible:v.current?h:-1,controlledHighlighting:m,highlightedIndex:h,setHighlightedIndex:g,keyboardNavigation:v,containerProps:w,setIgnoreFocus:C}};import{getElementByDataIndex as Si,getElementDataIndex as hT,isSelectableElement as Ja}from"@vuu-ui/vuu-utils";import{useCallback as nn,useRef as pT}from"react";var mT={},gT=["Enter"," "];var bp=({containerRef:o,defaultSelected:e,disableSelection:t=!1,highlightedIdx:n,itemQuery:r,onSelect:s,onSelectionChange:i,selected:l,selectionStrategy:a,selectionKeys:c=gT,tabToSelect:u})=>{let d=a==="deselectable",f=a==="multiple",h=a==="extended",p=pT(-1),m=nn(T=>c.includes(T.key),[c]),g=nn(()=>f||h?[]:null,[f,h]),[y,E]=ka({controlled:l,default:e!=null?e:g(),name:"UseSelection",state:"selected"}),v=nn(T=>Array.isArray(y)?y.includes(T):y===T,[y]),x=nn(T=>v(T)?null:T,[v]),C=nn(T=>{let P=v(T)?y.filter(R=>R!==T):y.concat(T);return P.sort(),P},[v,y]),b=nn((T,P)=>{let R=P?y:[],[O]=y.slice(-1),A=O?hT(document.getElementById(O)):0,D=Math.min(T,A),I=Math.max(T,A),F=o.current,V=Array.from(F.querySelectorAll(r)).slice(D,I+1).map(G=>G.id),K=[...new Set([...R,...V])];return K.sort(),K},[o,r,y]),S=nn((T,P,R,O)=>{let{current:A}=o,{id:D}=Si(A,P,!0),I;f?I=C(D):h?O&&!R?I=C(D):R?I=b(P,O):I=[D]:d?I=x(D):I=D,I!==y&&E(I),s==null||s(T,D),I!==y&&i&&i(T,I)},[o,f,h,d,y,s,C,b,x,E,i]),M=nn(T=>{let{current:P}=o,R=Si(P,n);Ja(R)&&(m(T)||u&&T.key==="Tab")&&(T.key!=="Tab"&&T.preventDefault(),S(T,n,!1,T.ctrlKey||T.metaKey),h&&(p.current=n))},[n,o,m,u,S,h]),w=nn((T,P)=>{if(h&&T.shiftKey){let{current:R}=o,O=Si(R,P);Ja(O)&&S(T,P,!0)}},[h,o,S]),k=nn(T=>{let{current:P}=o,R=Si(P,n);!t&&Ja(R)&&(T.preventDefault(),T.stopPropagation(),S(T,n,T.shiftKey,T.ctrlKey||T.metaKey),h&&(p.current=n))},[o,n,t,S,h]);return{listHandlers:sh(a)?mT:{onClick:k,onKeyDown:M,onKeyboardNavigation:w},selected:y,setSelected:E}};import{useCallback as yp,useRef as Ya}from"react";var xp=({disableTypeToSelect:o,highlightedIdx:e,highlightItemAtIndex:t,typeToNavigate:n,items:r,applyIncrementalSearch:s=!0})=>{let i=Ya(null),l=Ya(""),a=Ya(-1),c=yp(d=>{if(d||!s){let f=new RegExp(`^${l.current}`,"i"),h=r.findIndex(({label:p},m)=>m>a.current&&f.test(p));h===-1&&(h=r.findIndex(({label:p},m)=>m<=a.current&&f.test(p))),h!==-1&&t(h)}else l.current="",i.current=null,a.current=-1},[s,t,r]),u=yp(d=>{let f=a.current!==-1;(Ci(d)||f&&d.key===ap)&&n&&(d.preventDefault(),d.stopPropagation(),(a.current===-1||d.key===l.current)&&(a.current=e),i.current!==null&&(clearTimeout(i.current),i.current=null),d.key!==l.current&&(l.current+=d.key),s&&c(!0),i.current=window.setTimeout(()=>{c()},100))},[n,s,e,c]);return{onKeyDown:o?void 0:u}};import{useCallback as Yo,useRef as Cp}from"react";import{useIsomorphicLayoutEffect as bT}from"@salt-ds/core";var vp=["height"],yT=["height","scrollHeight"],xT=[],Sp={containerOnly:[yT,xT],withContent:[vp,vp]},CT=o=>o?Sp.containerOnly:Sp.withContent,wp={current:null},vT=(o,e)=>{let{transform:t="none"}=getComputedStyle(o);if(t.startsWith("matrix")){let n=t.lastIndexOf(",");return parseInt(t.slice(n+1))}else{let n=o.offsetParent;if(n===e||e===null)return o.offsetTop;{let r=o.offsetTop;for(;n!==null&&n!==e;)r+=n.offsetTop,n=n.offsetParent;return r}}},Tp=({containerRef:o,contentRef:e=wp,highlightedIdx:t=-1,indexPositions:n,stickyHeaders:r=!1})=>{let s=Cp(!1),i=Cp({height:0,contentHeight:0}),l=Yo(m=>{s.current=!0,o.current&&(o.current.scrollTop=m),setTimeout(()=>{s.current=!1})},[]),a=Yo(()=>l(0),[l]),c=Yo(()=>{l(i.current.contentHeight-i.current.height)},[l]),u=Yo(m=>{let g=e.current||o.current;if(m.id){let y=document.getElementById(m.id);if(y&&o.current){let{height:E}=i.current,v=y.ariaExpanded&&y.firstChild?y.firstChild:y,x=r?36:0,C=vT(v,g),b=v.offsetHeight,{scrollTop:S}=o.current,M=S+x,w=M+E-x;if(C+b>w||C<M){let k=C+b>w?S+(C+b)-w:C-x;l(k)}}}},[o,e,l,r]);bT(()=>{let{height:m,contentHeight:g}=i.current,y=n[t];if(g>m&&y){let[E]=n,[v]=n.slice(-1);y===E?a():y===v?c():u(n[t])}},[t,n,u,c,a]);let d=Yo(({height:m,scrollHeight:g})=>{typeof m=="number"&&(i.current.height=m),typeof g=="number"&&(i.current.contentHeight=g)},[]),f=Yo(({height:m})=>{typeof m=="number"&&(i.current.contentHeight=m)},[]),[h,p]=CT(e===wp);return Cn(o,h,d,!0),Cn(e,p,f,!0),{isScrolling:s,scrollIntoView:u}};import{makePrefixer as ST}from"@salt-ds/core";import{Fragment as TT,jsx as Za}from"react/jsx-runtime";var wT=ST("saltHighlighter"),kp=o=>{let{matchPattern:e,text:t=""}=o,n=typeof e=="string"?new RegExp(`(${ri(e)})`,"gi"):e;return n===void 0?Za(TT,{children:t}):Za("span",{children:t.split(n).map((r,s)=>r.match(n)?Za("strong",{className:wT("highlight"),children:r},`${s}-${r}`):r)})};import{forwardRef as Mp}from"react";import Pp from"classnames";import kT from"classnames";import{jsx as ET}from"react/jsx-runtime";var Ep="vuuCheckboxIcon",wi=({checked:o=!1,...e})=>ET("span",{...e,className:kT(Ep,{[`${Ep}-checked`]:o})});import{jsx as Ti,jsxs as MT}from"react/jsx-runtime";var Zr="vuuListItem",ki=Mp(function({height:e,...t},n){return Ti("div",{...t,"aria-hidden":!0,className:Pp(Zr,`${Zr}-proxy`),ref:n,style:{height:e}})}),Zo=Mp(function({children:e,className:t,disabled:n,tabIndex:r,item:s,itemHeight:i,itemTextHighlightPattern:l,label:a,selectable:c,selected:u,showCheckbox:d,style:f,...h},p){let m=Pp(Zr,t,{vuuDisabled:n,[`${Zr}-checkbox`]:d}),g=i!==void 0?{...f,height:i}:f;return MT("div",{className:m,...h,"aria-disabled":n||void 0,"aria-selected":u||void 0,ref:p,style:g,children:[d&&Ti(wi,{"aria-hidden":!0,checked:u}),e&&typeof e!="string"?e:l==null?Ti("span",{className:`${Zr}-textWrapper`,children:a||e}):Ti(kp,{matchPattern:l,text:a||e})]})});import{MeasuredContainer as mk,useId as gk}from"@vuu-ui/vuu-layout";import{useForkRef as bk}from"@salt-ds/core";import rc from"classnames";import{cloneElement as yk,forwardRef as xk,isValidElement as Ck,useCallback as vk,useRef as sc,useState as Sk}from"react";import{useLayoutEffectSkipFirst as sk}from"@vuu-ui/vuu-layout";import{useCallback as Sn,useEffect as ik,useMemo as lk,useRef as jp}from"react";import{createContext as PT,useCallback as wz,useContext as DT,useMemo as Tz}from"react";import{boxContainsPoint as pz}from"@vuu-ui/vuu-utils";import{useCallback as gz,useRef as bz}from"react";import{jsx as Pz}from"react/jsx-runtime";var IT={isDragSource:!1,isDropTarget:!1,register:()=>{}},RT=()=>console.log("have you forgotten to provide a DragDrop Provider ?"),AT=PT({registerDragDropParty:RT});var Dp=o=>{var i,l;let{dragSources:e,dropTargets:t,onDragOut:n,onEndOfDragOperation:r,registerDragDropParty:s}=DT(AT);if(o){let a=(i=e==null?void 0:e.has(o))!=null?i:!1,c=(l=t==null?void 0:t.has(o))!=null?l:!1;return{isDragSource:a,isDropTarget:c,onDragOut:n,onEndOfDragOperation:r,register:s}}else return IT};var Ei=class{constructor(e,t){this.draggableElement=null;this.payload=null;this.setDraggable=e=>{this.draggableElement=e};this.initialDragElement=t,this.mouseOffset=this.getMouseOffset(e,t)}setPayload(e){this.payload=e}getMouseOffset(e,t){let{clientX:n,clientY:r}=e,s=t.getBoundingClientRect();return{x:n-s.left,y:r-s.top}}};import{useCallback as nr,useMemo as WT,useRef as uo,useState as UT}from"react";import{useCallback as es,useMemo as zT,useRef as Bp}from"react";var LT=["left","right"],OT=["top","bottom"],Mi=":not(.wrapped)",Ip=':not([aria-hidden="true"])',Rp=o=>{let e=o.cloneNode(!0);return e.removeAttribute("id"),e.dataset.index="-1",e},NT=(o,e="width",t=!1)=>{let n=e==="width"?"left":"top",{[e]:r,[n]:s}=o.getBoundingClientRect(),{padEnd:i=!1,padStart:l=!1}=o.dataset,a=getComputedStyle(o),[c,u]=e==="width"?LT:OT,d=l&&!t?0:parseInt(a.getPropertyValue(`margin-${c}`),10),f=i&&!t?0:parseInt(a.getPropertyValue(`margin-${u}`),10),h=r;if(parseInt(a.getPropertyValue("flex-shrink"),10)>0){let m=parseInt(a.getPropertyValue("flex-basis"),10);!isNaN(m)&&m>0&&(h=m)}return[s,d+h+f]},HT={horizontal:{CLIENT_POS:"clientX",CLIENT_SIZE:"clientWidth",CONTRA:"top",CONTRA_CLIENT_POS:"clientY",CONTRA_END:"bottom",CONTRA_POS:"y",DIMENSION:"width",END:"right",POS:"x",SCROLL_POS:"scrollLeft",SCROLL_SIZE:"scrollWidth",START:"left"},vertical:{CLIENT_POS:"clientY",CLIENT_SIZE:"clientHeight",CONTRA:"left",CONTRA_CLIENT_POS:"clientX",CONTRA_END:"right",CONTRA_POS:"x",DIMENSION:"height",END:"bottom",POS:"y",SCROLL_POS:"scrollTop",SCROLL_SIZE:"scrollHeight",START:"top"}},gt=o=>HT[o],Ap=(o,e)=>{let t=o.find(n=>n.id===e);if(t)return t},Lp=(o,e)=>{o.splice(e,1);for(let t=e;t<o.length;t++)o[t].currentIndex-=1},er=(o,e,t,n,r)=>{let s=[],{DIMENSION:i}=gt(e),l=Array.from(t?o.querySelectorAll(t):o.children),a=l.length,c=typeof(n==null?void 0:n.from)=="number"?n.atEnd?Math.max(0,n.from-1):n.from:0,u=typeof(n==null?void 0:n.to)=="number"?Math.min(n.to+2,a-1):a-1;for(let d=c;d<=u;d++){let f=l[d],[h,p]=NT(f,i),m=d===a-1,g=f.id;s.push({currentIndex:d,id:g,index:d,isDraggedItem:r===g,isLast:m,isOverflowIndicator:f.dataset.index==="overflow",element:f,start:h,end:h+p,size:p,mid:h+p/2})}return s},tr=(o,e=!1)=>{let t=o.findIndex(n=>n.isDraggedItem);if(e){let{index:n}=o[t],r=o.filter(i=>!i.isDraggedItem).reduce((i,l)=>Math.min(i,l.index),Number.MAX_SAFE_INTEGER);if(r>0&&!(n===0&&r===1))return r+t}return t},ec=(o,e)=>{let t=tr(o),n=e==="fwd"?t+1:t-1;if(n<0||n>=o.length)throw Error("switchDropTargetPosition index out of range");let r=o.at(t),s=o.at(n),i=s.size-r.size;if(e==="fwd"){let l=s.start+i,a=s.end,c={...r,start:l,mid:Math.floor(l+(a-l)/2),end:a},u=r.start,d=r.end+i,f={...s,start:u,mid:Math.floor(u+(d-u)/2),end:d};o.splice(t,2,f,c)}else{let l=s.start,a=s.end-i,c={...r,start:l,mid:Math.floor(l+(a-l)/2),end:a},u=r.start-i,d=r.end,f={...s,start:u,mid:Math.floor(u+(d-u)/2),end:d};o.splice(n,2,c,f)}},co=(o,e,t,n)=>{let r=o.length,s=tr(o),i=o[s];if(n==="fwd"){let l=Math.round(e+t);for(let a=r-1;a>=0;a--){let c=o[a];if(l>c.mid)return i&&a<s?i:c}}else{let l=Math.round(e);for(let a=0;a<r;a++){let c=o[a];if(l<c.mid)return a>s?i:c}}throw Error("no dropTraget identified")};function Op(o,e){let{height:t,left:n,top:r,width:s}=o,{height:i,width:l}=e;return{height:Math.min(t,i),left:n,top:r,width:Math.min(s,l)}}var tc=o=>o.map((e,t)=>{var n;return`
|
|
3
|
-
${e.isDraggedItem?"*":" "}[${t}] width : ${Math.floor(e.size)} ${Math.floor(e.start)} - ${Math.floor(e.end)} (mid ${Math.floor(e.mid)}) ${(n=e.element)==null?void 0:n.textContent} `}).join("");import{useForkRef as FT}from"@salt-ds/core";import BT from"classnames";import{forwardRef as VT,useCallback as $T}from"react";import{jsx as Np}from"react/jsx-runtime";var KT=o=>o.split(" ").map(e=>`vuuDraggable-${e}`),Pi=VT(function({wrapperClassName:e,element:t,onTransitionEnd:n,style:r,scale:s=1},i){let l=$T(c=>{c&&(c.innerHTML="",c.appendChild(t),s!==1&&(c.style.transform=`scale(${s},${s})`))},[t,s]),a=FT(i,l);return Np(qr,{children:Np("div",{className:BT("vuuDraggable",...KT(e)),ref:a,onTransitionEnd:n,style:r})})}),nc=o=>{let e=document.createElement("div");return e.className="vuuDraggable-spacer",o&&e.addEventListener("transitionend",()=>{o.current=!1}),e},Hp=()=>{let o=document.createElement("div");return o.className="vuuDraggable-dropIndicatorPosition",o},Fp=o=>{let e=document.createElement("div");return e.className="vuuDraggable-dropIndicator",o&&e.addEventListener("transitionend",()=>{o.current=!1}),e};var Vp=(o="horizontal")=>{let e=Bp(0),t=Bp(!1),n=zT(()=>[nc(t),nc()],[]),r=es((c,u="width")=>{let[d,f]=n;e.current=requestAnimationFrame(()=>{t.current=!0,d.style.cssText=`${u}: 0px`,f.style.cssText=`${u}: ${c}px`,n[0]=f,n[1]=d})},[n]),s=es((c=!1)=>{if(c===!0){let[u]=n,d=()=>{u.removeEventListener("transitionend",d),s()},f=o==="horizontal"?"width":"height";u.addEventListener("transitionend",d),r(0,f)}else n.forEach(u=>u.remove())},[r,o,n]),i=es(()=>{e.current&&(cancelAnimationFrame(e.current),e.current=0)},[]),l=es((c,u,d,f=!1,h="static")=>{if(u){let p=o==="horizontal"?"width":"height",[m,g]=n;if(i(),f)t.current?(s(),m.style.cssText=`${p}: ${d}px`,g.style.cssText=`${p}: 0px`,h==="fwd"?(u.element.before(m),u.element.after(g)):(u.element.after(m),u.element.before(g))):h==="fwd"?u.element.after(g):u.element.before(g),r(d,p);else if(h==="static")m.style.cssText=`${p}: ${d}px`,u.element.before(m);else throw Error("useDragDisplacers currently only supports noTransition for static displacement");h!=="static"&&ec(c,h)}},[r,i,s,o,n]),a=es((c,u,d,f=!1,h="static")=>{let p=o==="horizontal"?"width":"height",[m,g]=n;i(),f?(t.current?(s(),m.style.cssText=`${p}: ${d}px`,g.style.cssText=`${p}: 0px`,u.element.before(m),u.element.after(g)):h==="fwd"?u.element.after(g):u.element.before(g),r(d,p)):(m.style.cssText=`${p}: ${d}px`,u.element.after(m)),h!=="static"&&ec(c,h)},[r,i,s,o,n]);return{displaceItem:l,displaceLastItem:a,clearSpacers:s}};import{dispatchMouseEvent as $p}from"@vuu-ui/vuu-utils";var Kp=({onDrop:o,orientation:e="horizontal",containerRef:t,itemQuery:n="*",selected:r,viewportRange:s})=>{let i=uo(),l=uo(!1),a=uo(-1),c=uo([]),u=uo(!1),[d,f]=UT(!1),{clearSpacers:h,displaceItem:p,displaceLastItem:m}=Vp(e),g=uo(),y=`:is(${n}${Mi}${Ip},.vuuOverflowContainer-OverflowIndicator)`,E=T=>c.current.findIndex(P=>P.id===T.id),v=uo();v.current=s;let x=nr(()=>{h()},[h]),C=nr((T,P,R)=>{let{current:O}=t,{current:A}=g;if(O&&A){c.current=er(O,e,y,v.current),T==="fwd"?c.current.push(A):c.current.unshift(A);let{size:D}=A,F=a.current+D/2,{current:N}=c,V=co(N,F,D,"fwd");if(V){let G=E(V),Q=N[G];R&&T==="fwd"?m(N,N[N.length-1],D,!1,"static"):p(N,Q,D,!0,"static")}}},[t,p,m,y,e]),b=nr(T=>{T.ariaSelected&&Array.isArray(r)&&r.length>1&&console.log("its a selected element, and we have a multi select");let{current:P}=t;if(P&&T){let R=P.contains(T),{SCROLL_SIZE:O,CLIENT_SIZE:A}=gt(e),{id:D}=T,{[O]:I,[A]:F}=P;l.current=I>F;let N=c.current=er(P,e,y,s,D);if(R){console.log(tc(N));let V=tr(N),K=N[V];K&&P&&(g.current=K,(K.isLast?m:p)(N,K,K.size,!1,"static"))}else{let{top:V,height:K}=T.getBoundingClientRect(),G=co(N,V,K,"fwd"),Q=N.indexOf(G),{start:X,end:U,mid:Y}=G;console.log(`nextDropTarget ${G.element.textContent}`);let ce=g.current={end:U,mid:Y,start:X,isDraggedItem:!0,isExternal:!0,size:K},ie=N.indexOf(G);console.log({indexOfDropTarget:ie}),N.splice(ie,0,ce);for(let me=Q+1;me<N.length;me++){let Me=N[me];Me.mid+=K,Me.end+=K,Me.start+=K}console.log(tc(N)),(G.isLast?m:p)(N,G,G.size,!0,"static")}}},[t,p,m,y,e,r,s]),[S,M]=WT(()=>{let T=!1;return[O=>{if(!T){T=!0;let A=O.element.querySelector(".vuuPopupMenu");A&&$p(A,"click")}},O=>{if(T){T=!1;let A=O.element.querySelector(".vuuPopupMenu");A&&$p(A,"click")}}]},[]),w=nr((T,P)=>{let{current:R}=g;if(R&&t.current){a.current=T;let{current:O}=c,A=co(O,T,R.size,P);if(A&&!A.isDraggedItem)if(A.isOverflowIndicator)f(u.current=!0),S(A);else{let{size:D}=R;(E(A)===O.length-1?m:p)(O,A,D,!0,P);let N=O.at(-1);M(N),f(u.current=!1)}i.current=P}},[t,p,m,M,S]),k=nr(()=>{var O;h();let{current:T}=c,P=tr(T),R=T[P];if(R)if(i.current=void 0,u.current)o(R.index,-1,{fromIndex:R.index,toIndex:-1,isExternal:R.isExternal});else{let A=tr(T,!0);o(R.index,A,{fromIndex:R.index,toIndex:A,isExternal:R.isExternal})}if(f(!1),t.current){let A=(O=t.current)==null?void 0:O.scrollTop;P<T.length&&(t.current.scrollTop=A)}},[h,t,o]),L=nr(()=>{h(!0)},[h]);return{beginDrag:b,drag:w,drop:k,handleScrollStart:x,handleScrollStop:C,releaseDrag:L,revealOverflowedItems:d}};import{useCallback as or,useRef as on,useState as Up}from"react";import{useCallback as zp,useMemo as GT}from"react";var Wp=()=>{let o=GT(()=>Hp(),[]),e=zp(()=>o.remove(),[o]);return{positionDropIndicator:zp((n,r="end")=>(r==="end"?n.element.after(o):n.element.before(o),o),[o]),clearSpacer:e}};import{jsx as qT}from"react/jsx-runtime";var _T=':not([data-overflowed="true"])',QT=':not([aria-hidden="true"])',Gp=({onDrop:o,orientation:e="horizontal",containerRef:t,itemQuery:n="*",selected:r,viewportRange:s})=>{let i=on(),l=on(null),a=on(null),c=on(""),u=on(!1),d=on(-1),f=on([]),h=on(!1),[p,m]=Up(!1),[g,y]=Up(),{clearSpacer:E,positionDropIndicator:v}=Wp(),x=on(),C=`:is(${n}${_T}${QT},[data-overflow-indicator])`,b=O=>f.current.findIndex(A=>A.id===O.id),S=(O,A,D)=>{O.start+=A,O.mid+=A,O.end+=A,typeof D=="number"&&(O.currentIndex+=D)},M=on();M.current=s;let w=or(()=>{E()},[E]),k=or((O,A,D)=>{let{current:I}=t,{current:F}=x;if(I&&F){f.current=er(I,e,C,M.current);let{size:N}=F,K=d.current+N/2,{current:G}=f,Q=co(G,K,N,"fwd");Q&&v(D&&O==="fwd"?G[G.length-1]:Q,"start")}},[t,v,C,e]),L=or(O=>{O.ariaSelected&&Array.isArray(r)&&r.length>1&&console.log("its a selected element, and we have a multi select");let{current:A}=t;if(A&&O){let{SCROLL_SIZE:D,CLIENT_SIZE:I}=gt(e),{id:F}=O,{[D]:N,[I]:V}=A;u.current=N>V;let K=f.current=er(A,e,C,s),G=Ap(K,F);if(G&&A){let Q=b(G);Lp(K,Q),x.current=G;let{current:X}=M;if(X!=null&&X.atEnd)for(let Ce=0;Ce<K.length;Ce++)S(K[Ce],G.size);for(let Ce=Q;Ce<K.length;Ce++)S(K[Ce],-G.size,-1);let[U,Y]=G.isLast?[K[K.length-1],"end"]:[K[Q],"start"];a.current=U,c.current=Y;let ce=v(U,Y),{top:ie,left:Ae,width:me}=ce.getBoundingClientRect(),Me={top:G.isLast?X!=null&&X.atEnd&&!X.atStart?ie+G.size-2:ie-2:ie-G.size-2,left:Ae,width:me,height:2};y(qT(Pi,{wrapperClassName:"dropIndicatorContainer",style:Me,ref:l,element:Fp()}))}}},[r,t,e,C,s,v]),T=or((O,A)=>{let{current:D}=a,{current:I}=x;if(I&&t.current){let F=e==="horizontal"?"left":"top";d.current=O;let{current:N}=f,V=co(N,O,I.size,A);if(V&&V.index!==(D==null?void 0:D.index)){if(V.isOverflowIndicator)m(h.current=!0);else if(l.current){if(b(V)===N.length-1){let G=N[N.length-1],X=v(G,"start").getBoundingClientRect();l.current.style[F]=`${X.top}px`}else{let Q=v(V,"start").getBoundingClientRect();l.current.style[F]=`${Q.top}px`}m(h.current=!1)}a.current=V,i.current=A}}},[t,e,v]),P=or(()=>{E();let{current:O}=x,{current:A}=a,{current:D}=c,{current:I}=M;if(O&&I&&A){let{index:F}=O,N=D==="start",{index:V,currentIndex:K}=A;a.current=null,i.current=void 0,h.current?o(F,-1,{fromIndex:F,toIndex:-1}):F<V?o(F,N?K:K+1,{fromIndex:F,toIndex:N?K:K+1}):o(F,N?V:V+1,{fromIndex:F,toIndex:N?V:V+1}),y(void 0)}m(!1)},[E,o]),R=or(()=>{},[]);return{beginDrag:L,drag:T,drop:P,dropIndicator:g,handleScrollStart:w,handleScrollStop:k,releaseDrag:R,revealOverflowedItems:p}};import{useCallback as ct,useEffect as jT,useLayoutEffect as XT,useRef as At,useState as JT}from"react";import{useCallback as _p,useRef as Di}from"react";var Qp=({containerRef:o,onScrollingStopped:e,orientation:t="vertical"})=>{let n=Di(null),r=Di(!1),s=Di(0),i=Di("fwd"),l=_p((c=!1)=>{console.log("[useAutoScroll] stopScrolling"),n.current!==null&&(clearTimeout(n.current),n.current=null),r.current=!1,e==null||e(i.current,s.current,c)},[e]),a=_p((c,u,d=30)=>{let{current:f}=o;if(f){let{SCROLL_POS:h,SCROLL_SIZE:p,CLIENT_SIZE:m}=gt(t),{[h]:g,[p]:y,[m]:E}=f,v=c==="fwd"?y-E-g:g,x=Math.min(v,d);c==="fwd"?(i.current="fwd",f[h]=s.current=g+x):(i.current="bwd",f[h]=s.current=g-x),x===v?l(!0):(r.current=!0,n.current=window.setTimeout(()=>{a(c,u,d)},100))}},[o,t,l]);return{isScrolling:r,startScrolling:a,stopScrolling:l}};import{jsx as rk}from"react/jsx-runtime";var YT={beginDrag:()=>{},drag:()=>{},draggableRef:{current:null},drop:()=>{},isDragging:!1,isScrolling:!1,handleScrollStart:()=>{},handleScrollStop:()=>{},revealOverflowedItems:!1},qp={start:0,end:1e3,contraStart:0,contraEnd:1e3},ZT=()=>YT,ek=3,tk=(o,e)=>o.closest(e),nk=o=>o.dataset.index==="overflow"&&o.parentElement!==null&&o.parentElement.classList.contains("overflowed"),ok=(o,e)=>{let t=`:is(${e}${Mi},.vuuOverflowContainer-OverflowIndicator)`,r=Array.from(o.querySelectorAll(t)).pop();return[r,nk(r)]},fo=({allowDragDrop:o,containerRef:e,draggableClassName:t,getDragPayload:n,id:r,itemQuery:s="*",onDragStart:i,onDrop:l,onDropSettle:a,orientation:c,...u})=>{let d=At({start:0,end:0,contraStart:0,contraEnd:0}),[f,h]=JT({draggable:void 0,draggedItemIndex:-1,isDragging:!1}),p=At(null),m=At(null),g=At(!1),y=At({x:0,y:0}),E=At({x:0,y:0}),v=At(null),x=At(-1),C=At(-1),b=At(),{isDragSource:S,isDropTarget:M,onDragOut:w,onEndOfDragOperation:k,register:L}=Dp(r),T=At(),P=At(),R=ct(()=>{let{current:q}=T,{current:ee}=P;q&&ee&&(document.addEventListener("mousemove",q,!1),document.addEventListener("mouseup",ee,!1))},[]),O=ct(()=>{let{current:q}=T,{current:ee}=P;q&&ee&&(document.removeEventListener("mousemove",q,!1),document.removeEventListener("mouseup",ee,!1))},[]),A=ct((q,ee)=>{let{current:ne}=e;if(ne){let[ae,ye]=ok(ne,s),{CONTRA:Le,CONTRA_END:ge,DIMENSION:j,END:Z,START:te}=gt(c),ue=ee[j],{[te]:Oe,[Z]:Qe}=ae.getBoundingClientRect();d.current.start=q[te],d.current.end=ye?Math.max(Oe,q.right-ue):g.current?q[te]+q[j]-ue:Qe-ue,d.current.contraStart=q[Le],d.current.contraEnd=q[ge]}},[e,s,c]),D=ct(()=>{var ne;let{current:q}=C,ee=(ne=e.current)==null?void 0:ne.querySelector(`${s}[data-index="${q}"]`);ee&&ee.classList.remove("vuuDropTarget-settling"),C.current=-1,a==null||a(q),h(ae=>({...ae,draggable:void 0}))},[e,s,a]),I=ct(q=>{if(e.current&&p.current){let{mouseOffset:ee}=p.current,{POS:ne,SCROLL_POS:ae,SCROLL_SIZE:ye,CLIENT_SIZE:Le}=gt(c),{[ae]:ge,[ye]:j,[Le]:Z}=e.current,te=j-Z,ue=ge<te,Oe=d.current.end,Qe=ge>0&&q-ee[ne]<=d.current.start,H=ue&&q-ee[ne]>=Oe;return Qe?"bwd":H?"fwd":""}},[e,c]),F=o===!0||o==="natural-movement"?Kp:o==="drop-indicator"?Gp:ZT,N=ct((q,ee,ne)=>{var ae;(ae=b.current)==null||ae.call(b,q,ee,ne)},[]),{isScrolling:V,startScrolling:K,stopScrolling:G}=Qp({containerRef:e,onScrollingStopped:N,orientation:c}),Q=ct((q,ee,ne)=>{var ae;x.current=ee,ne.isExternal?l==null||l(q,ee,{...ne,payload:(ae=p.current)==null?void 0:ae.payload}):l==null||l(q,ee,ne),C.current=ee,r&&(k==null||k(r)),p.current=null},[r,l,k]),{beginDrag:X,drag:U,drop:Y,handleScrollStart:ce,handleScrollStop:ie,releaseDrag:Ae,...me}=F({...u,containerRef:e,isDragSource:S,isDropTarget:M,itemQuery:s,onDrop:Q,orientation:c});b.current=ie;let Me=ct((q,ee)=>{let{CONTRA_POS:ne}=gt(c),ae=y.current[ne],ye=S?Math.abs(ae-ee):0;if(p.current&&ye-q>5)return w!=null&&w(r,p.current)&&(O(),Ae==null||Ae(),p.current=null),d.current=qp,!0},[r,S,w,c,Ae,O]),Ce=ct(q=>{let{CLIENT_POS:ee,CONTRA_CLIENT_POS:ne,POS:ae}=gt(c),{clientX:ye,clientY:Le}=q,{[ee]:ge,[ne]:j}=q,Z=y.current[ae],te=Math.abs(Z-ge),{current:ue}=p;if(Me(te,j)){console.log("drag handed over to provider");return}if(y.current.x=ye,y.current.y=Le,ue){let{draggableElement:Oe,mouseOffset:Qe}=ue;if(d.current===qp&&Oe){let H=y.current.x-Qe.x,z=y.current.y-Qe.y;Oe.style.top=`${z}px`,Oe.style.left=`${H}px`}else if(te>0&&Oe){let H=Z<ge?"fwd":"bwd",z=I(ge),le=y.current[ae]-Qe[ae];if(z&&g.current&&!V.current?(ce(),K(z,1)):!z&&V.current&&G(),!V.current){let Se=Math.round(Math.max(d.current.start,Math.min(d.current.end,le))),mt=c==="horizontal"?"left":"top";Oe.style[mt]=`${Se}px`,U(Se,H)}}}},[U,I,ce,r,S,V,w,c,K,G]),ke=ct(()=>{O(),p.current&&(v.current=p.current.draggableElement),Y(),h(q=>({...q,draggedItemIndex:-1,isDragging:!1}))},[Y,O]);T.current=Ce,P.current=ke;let je=ct(q=>{p.current=q;let{draggableElement:ee,mouseOffset:ne,initialDragElement:ae}=q,{current:ye}=e;if(console.log({container:ye,draggableElement:ee,initialDragElement:ae}),ye&&ee){let Le=ye.getBoundingClientRect(),ge=ee.getBoundingClientRect();return A(Le,ge),y.current.x=ge.left+ne.x,y.current.y=ge.top+ne.y,X(ee),R(),!0}else return!1},[R,X,e,A]),Ee=ct(q=>{let{target:ee}=q,ne=tk(ee,s),{current:ae}=e;if(ae&&ne){let{SCROLL_SIZE:ye,CLIENT_SIZE:Le}=gt(c),{[ye]:ge,[Le]:j}=ae;g.current=ge>j;let Z=ae.getBoundingClientRect(),te=ne.getBoundingClientRect(),ue=p.current=new Ei(q,ne);A(Z,te),X(ne);let{dataset:{index:Oe="-1"}}=ne;h({isDragging:!0,draggable:rk(Pi,{element:Rp(ne),onTransitionEnd:D,ref:ue.setDraggable,style:Op(te,Z),wrapperClassName:t}),draggedItemIndex:parseInt(Oe)}),i==null||i(ue),R()}},[R,X,e,t,s,i,c,A,D]),Ge=ct(q=>{let{CLIENT_POS:ee,POS:ne}=gt(c),{[ee]:ae}=q;Math.abs(ae-E.current[ne])>ek&&e.current&&(m.current&&(window.clearTimeout(m.current),m.current=null),document.removeEventListener("mousemove",Ge),document.removeEventListener("mouseup",at,!1),Ee(q))},[e,X,c]),at=ct(()=>{m.current&&(window.clearTimeout(m.current),m.current=null),document.removeEventListener("mousemove",Ge,!1),document.removeEventListener("mouseup",at,!1)},[Ge]),ve=ct(q=>{let{current:ee}=e;if(q.stopPropagation(),ee&&!q.defaultPrevented){let{clientX:ne,clientY:ae}=q;y.current.x=E.current.x=ne,y.current.y=E.current.y=ae,document.addEventListener("mousemove",Ge,!1),document.addEventListener("mouseup",at,!1),q.persist(),m.current=window.setTimeout(()=>{document.removeEventListener("mousemove",Ge,!1),document.removeEventListener("mouseup",at,!1),Ee(q.nativeEvent)},500)}},[e,Ee,Ge,at]),{current:_e}=v;return XT(()=>{if(_e&&e.current){let q=x.current,ee=e.current.querySelector(`${s}[data-index="${q}"]`);ee?(ee.classList.add("vuuDropTarget-settling"),requestAnimationFrame(()=>{let{top:ne,left:ae}=ee.getBoundingClientRect(),{top:ye,left:Le}=_e.getBoundingClientRect();Le!==ae||ye!==ne?(_e.classList.add("vuuDraggable-settling"),_e.style.top=`${ne}px`,_e.style.left=`${ae}px`):D()})):console.log(`dont have the dropped item (at ${q})`),v.current=null}},[e,s,_e,D]),jT(()=>{r&&(S||M)&&L(r,je)},[r,S,M,L,je]),{...me,...f,isScrolling:V,onMouseDown:o?ve:void 0}};var $n=({allowDragDrop:o=!1,collapsibleHeaders:e,collectionHook:t,containerRef:n,contentRef:r,defaultHighlightedIndex:s,defaultSelected:i,disabled:l,disableAriaActiveDescendant:a,disableHighlightOnFocus:c,disableTypeToSelect:u,highlightedIndex:d,id:f,label:h="",listHandlers:p,onDragStart:m,onDrop:g,onHighlight:y,onKeyboardNavigation:E,onKeyDown:v,onMoveListItem:x,onSelect:C,onSelectionChange:b,restoreLastFocus:S,scrollContainerRef:M,selected:w,selectionStrategy:k,selectionKeys:L,stickyHeaders:T,tabToSelect:P,viewportRange:R})=>{let O=jp(null),A=jp(w||i),D=(j,Z)=>{var te,ue;(ue=(te=ie.listHandlers).onKeyboardNavigation)==null||ue.call(te,j,Z),E==null||E(j,Z)},I=Sn((j,Z)=>{C&&Z!==null&&C(j,t.itemById(Z))},[t,C]),F=lk(()=>{var j,Z;return M||{current:(Z=(j=n.current)==null?void 0:j.querySelector(".vuuList-scrollContainer"))!=null?Z:null}},[]),N=Sn((j,Z)=>{if(b){if(Array.isArray(Z)){let te=Z.map(ue=>t.itemById(ue));b(j,te)}else if(Z){let te=t.itemById(Z);b(j,te)}}},[t,b]),{highlightedIndex:V,containerProps:{onKeyDown:K,onMouseMove:G,...Q},setHighlightedIndex:X,...U}=gp({containerRef:F,defaultHighlightedIndex:s,disableHighlightOnFocus:c,highlightedIndex:d,indexPositions:t.data,itemCount:t.data.length,label:h,onHighlight:y,onKeyboardNavigation:D,restoreLastFocus:S,selected:A.current,viewportItemCount:10}),Y=fp({collapsibleHeaders:e,highlightedIdx:V,collectionHook:t}),ce=Sn(j=>{X(-1),m==null||m(j)},[m,X]),ie=bp({containerRef:n,defaultSelected:i,highlightedIdx:V,itemQuery:".vuuListItem",label:`${h}:useList`,onSelect:I,onSelectionChange:N,selected:w,selectionStrategy:k,selectionKeys:L,tabToSelect:P}),Ae=Sn((j,Z,te)=>{let ue=t.data.indexOf(j);return ue===Z?te:ue<Math.min(Z,te)||ue>Math.max(Z,te)?ue:Z<ue?ue-1:ue+1},[t.data]),me=Sn((j,Z,te)=>Array.isArray(j)?j.map(ue=>Ae(ue,Z,te)):Ae(j,Z,te),[Ae]),Me=Sn((j,Z,te)=>{Bn(ie.selected)&&(O.current=me(ie.selected,j,Z)),te.isExternal?g==null||g(j,Z,te):x==null||x(j,Z),X(-1)},[ie.selected,X,me,g,x]),Ce=Sn(j=>{X(j)},[X]),{setSelected:ke}=ie;ik(()=>{let{current:j}=O;if(Bn(j)){let Z=Array.isArray(j)?j.map(te=>t.data[te]):t.data[j];O.current=null,ke(Z)}},[t.data,ke]),sk(()=>{Bn(A.current)&&ke(Array.isArray(A.current)?[]:null)},[ke,t.data]);let{onMouseDown:je,isDragging:Ee,isScrolling:Ge,...at}=fo({allowDragDrop:o,draggableClassName:"list-item",orientation:"vertical",containerRef:n,id:f,itemQuery:".vuuListItem",onDragStart:ce,onDrop:Me,onDropSettle:Ce,viewportRange:R}),{onKeyDown:ve}=xp({disableTypeToSelect:u,highlightedIdx:V,highlightItemAtIndex:X,typeToNavigate:!0,items:t.data}),_e=Sn(j=>{var Z,te,ue;j.defaultPrevented||ve==null||ve(j),K(j),j.defaultPrevented||(te=(Z=ie.listHandlers).onKeyDown)==null||te.call(Z,j),j.defaultPrevented||(ue=Y==null?void 0:Y.onKeyDown)==null||ue.call(Y,j),j.defaultPrevented||v==null||v(j)},[Y,K,v,ie.listHandlers,ve]),{isScrolling:q,scrollIntoView:ee}=Tp({containerRef:F,contentRef:r,highlightedIdx:V,indexPositions:t.data,stickyHeaders:T}),ne=q.current||Ge.current,ae=Sn(j=>{if(!ne&&!l&&!Ee){G();let Z=hp(j.target);if(Z!==-1&&Z!==V){let te=t.data[Z];!te||te.disabled?X(-1):X(Z)}}},[Ee,ne,l,X,G,V,t.data]),ye=()=>{var j;return V===void 0||V===-1||a||(j=t.data[V])==null?void 0:j.id};A.current=ie.selected;let Le={"aria-activedescendant":ye(),onBlur:Q.onBlur,onFocus:Q.onFocus,onKeyDown:_e,onMouseDown:je,onMouseDownCapture:Q.onMouseDownCapture,onMouseLeave:Q.onMouseLeave},ge=p||{onClick:ie.listHandlers.onClick,onMouseMove:ae};return{focusVisible:U.focusVisible,controlledHighlighting:U.controlledHighlighting,highlightedIndex:V,keyboardNavigation:U.keyboardNavigation,listHandlers:ge,listItemHeaderHandlers:Y,listControlProps:Le,scrollIntoView:ee,selected:ie.selected,setHighlightedIndex:X,setIgnoreFocus:U.setIgnoreFocus,setSelected:ie.setSelected,...at}};import{useCallback as Xp,useMemo as ak,useRef as ck,useState as Jp}from"react";var uk=(o,e,t=0)=>o===0?0:t===0?o*e:o-1*(e+t)+e,Ii=({displayedItemCount:o,getItemHeight:e,height:t,itemCount:n,itemGapSize:r,itemHeight:s=36,size:i})=>{let[l,a]=Jp(s),[,c]=Jp({}),u=ck(null),[d,f]=ak(()=>{let m=0,g=l!=null?l:s,y=uk(n,g,r);if(console.log(`contentHeight ${y}`),t!==void 0)return[y,void 0];let E=Math.min(o,n)||o;return typeof e=="function"?m+=Array(E).fill(0).reduce((x,C,b)=>x+e(b)+r,0)-r:m+=E*Number(g)+(E-1)*r,[y,m]},[o,e,t,n,r,s,l]),h=Xp(({height:m})=>{typeof m=="number"&&a(m)},[]),p=Xp(m=>{u.current=m,c({})},[]);return Cn(u,oh,h,!0),{computedListHeight:f,contentHeight:d,listClientHeight:i==null?void 0:i.height,listItemHeight:l,rowHeightProxyRef:p}};import{useIsomorphicLayoutEffect as dk}from"@salt-ds/core";import{useCallback as fk,useMemo as hk,useRef as oc,useState as pk}from"react";var Yp=(o,e,t,n)=>{let r=Math.ceil(e/n),s=Math.floor(o/n),i=Math.ceil(s+r-1);return{atStart:s===0,atEnd:i===t-1,from:s,to:i}},Ri=({containerSize:o,itemCount:e,itemGapSize:t=0,itemSize:n,onViewportScroll:r})=>{let s=oc(0),i=oc(0),l=oc(0),a=hk(()=>Yp(l.current,o,e,n+t),[o,e,n,t]),[c,u]=pk(a);return dk(()=>{u(a)},[a]),{onVerticalScroll:fk(f=>{let h=f.target.scrollTop;if(h!==l.current){l.current=h;let p=n+t,m=Yp(h,o,e,p);(m.from!==s.current||m.to!==i.current)&&(s.current=m.from,i.current=m.to,r==null||r(m.from,m.to),u(m))}},[n,t,o,e,r]),viewportRange:c}};import{Fragment as kk,jsx as po,jsxs as Zp}from"react/jsx-runtime";import{createElement as Tk}from"react";var wk="No data to display",ho="vuuList",wn=xk(function({ListItem:e=Zo,ListPlaceholder:t,allowDragDrop:n,children:r,className:s,collapsibleHeaders:i=!1,defaultHighlightedIndex:l,defaultSelected:a,disabled:c=!1,disableFocus:u=!1,disableTypeToSelect:d,displayedItemCount:f=10,emptyMessage:h,focusVisible:p,getItemHeight:m,getItemId:g,height:y,highlightedIndex:E,id:v,itemGapSize:x=0,itemHeight:C,itemTextHighlightPattern:b,itemToString:S=It,listHandlers:M,maxHeight:w,maxWidth:k,minHeight:L,minWidth:T,onDragStart:P,onDrop:R,onMoveListItem:O,onSelect:A,onSelectionChange:D,onHighlight:I,restoreLastFocus:F,selected:N,selectionStrategy:V,checkable:K=V==="multiple",scrollingApiRef:G,selectionKeys:Q,showEmptyMessage:X=!1,source:U,style:Y,stickyHeaders:ce,tabToSelect:ie,...Ae},me){var Vf,$f;let Me=gk(v),Ce=sc(null),ke=sc(null),je=sc(null),[Ee,Ge]=Sk(),at=vk(Gt=>{Ge(Gt)},[]),ve=Vn({id:Me,label:"List",source:U,children:r,options:{collapsibleHeaders:i,getItemId:g,itemToString:S}}),{listClientHeight:_e,computedListHeight:q,listItemHeight:ee,rowHeightProxyRef:ne}=Ii({displayedItemCount:f,getItemHeight:m,height:y,itemCount:ve.data.length,itemGapSize:x,itemHeight:C,rootRef:Ce,size:Ee}),{onVerticalScroll:ae,viewportRange:ye}=Ri({containerSize:($f=(Vf=_e!=null?_e:q)!=null?Vf:Ee==null?void 0:Ee.height)!=null?$f:0,itemCount:ve.data.length,itemGapSize:x,itemSize:ee}),{draggable:Le,draggedItemIndex:ge,dropIndicator:j,focusVisible:Z,highlightedIndex:te,listControlProps:ue,listHandlers:Oe,listItemHeaderHandlers:Qe,scrollIntoView:H,selected:z}=$n({allowDragDrop:n,collapsibleHeaders:i,collectionHook:ve,containerRef:Ce,contentRef:je,defaultHighlightedIndex:l,defaultSelected:ve.itemToCollectionItemId(a),disabled:c,disableTypeToSelect:d,highlightedIndex:E,id:Me,label:"List",listHandlers:M,onDragStart:P,onDrop:R,onMoveListItem:O,onSelect:A,onSelectionChange:D,onHighlight:I,restoreLastFocus:F,scrollContainerRef:ke,selected:ve.itemToCollectionItemId(N),selectionStrategy:V,selectionKeys:Q,stickyHeaders:ce,tabToSelect:ie,viewportRange:ye});vi({collectionHook:ve,forwardedRef:G,scrollableRef:Ce,scrollIntoView:H});let le=p!=null?p:Z,Se=function(Be,xt,Ct,tt){let lo=Tk(e,{...Qe,className:rc(`${ho}Header`,{focusVisible:i&&le===Be.value}),"aria-expanded":tt,"data-idx":i?Be.value:void 0,"data-index":i?Be.value:void 0,"data-highlighted":Be.value===te||void 0,"data-sticky":ce,"data-selectable":!1,id:xt,key:`header-${Be.value}`,label:Ct});return Be.value+=1,lo},mt=m===void 0?()=>C:m;function io(Gt,Be,xt){var Js,Kf;let{disabled:Ct,value:tt,id:lo,label:js}=Be,Xs=Ck(tt),_r={className:rc((Js=tt==null?void 0:tt.props)==null?void 0:Js.className,{vuuHighlighted:xt.value===te,vuuFocusVisible:le===xt.value,["vuuDraggable-dragAway"]:ge===xt.value}),disabled:Ct||c,id:lo,item:Xs?void 0:(Kf=Be==null?void 0:Be.value)!=null?Kf:void 0,itemHeight:mt(xt.value),itemTextHighlightPattern:b,key:lo,"data-index":xt.value,label:js,role:"option",selected:ii(z,Be),showCheckbox:K};Gt.push(Xs?yk(tt,_r):po(e,{..._r})),xt.value+=1}let Ut=function(Be,xt,Ct){let{count:tt=0,id:lo,expanded:js,label:Xs=""}=xt[Ct.value],_r=Se(Ct,lo,Xs,js),Js=js!==!1?[_r].concat(qo(xt,Ct,Ct.value+tt)||[]):_r;Be.push(po("div",{role:"group",children:Js},lo))},qo=(Gt,Be={value:0},xt=Gt.length)=>{let Ct=[];for(;Be.value<xt;){let tt=Gt[Be.value];tt.header?Ct.push(Se(Be,tt.id,tt.label,tt.expanded===!1)):tt.childNodes?Ut(Ct,Gt,Be):io(Ct,tt,Be)}return Ct};function d0(){return h||X?po("span",{className:`${ho}-empty-message`,children:h!=null?h:wk}):null}let f0=()=>{if(ve.data.length){let Gt=ve.data;return qo(Gt)}else d0()},h0="auto",p0={"--list-borderWidth":"var(--vuuList-borderWidth, var(--salt-size-border, 0))","--list-item-gap":x?`${x}px`:void 0,"--computed-list-height":q===void 0?void 0:`${q}px`,minWidth:T,minHeight:L,maxWidth:k,maxHeight:w};return Zp(mk,{"aria-multiselectable":V==="multiple"||V==="extended"||V==="extended-multi-range"||void 0,...Ae,...Oe,...ue,className:rc(ho,s,{[`${ho}-collapsible`]:i,[`${ho}-contentSized`]:q!==void 0,vuuFocusVisible:te===Xa}),height:q!=null?q:y,id:`${Me}`,onResize:at,ref:bk(Ce,me),role:"listbox",onScroll:ae,style:{...Y,...p0},tabIndex:c||u?void 0:0,children:[po(ki,{ref:ne,height:C}),ve.data.length===0&&t!==void 0?po(kk,{children:po(t,{})}):po("div",{className:`${ho}-viewport`,ref:ke,children:Zp("div",{className:`${ho}-scrollingContentContainer`,ref:je,style:{height:h0},children:[f0(),j,Le]})})]})});import{makePrefixer as Pk,useForkRef as Dk,useIdMemo as Ik}from"@salt-ds/core";function em(o){var e,t,n="";if(typeof o=="string"||typeof o=="number")n+=o;else if(typeof o=="object")if(Array.isArray(o))for(e=0;e<o.length;e++)o[e]&&(t=em(o[e]))&&(n&&(n+=" "),n+=t);else for(e in o)o[e]&&(n&&(n+=" "),n+=e);return n}function ic(){for(var o,e,t=0,n="";t<arguments.length;)(o=arguments[t++])&&(e=em(o))&&(n&&(n+=" "),n+=e);return n}import{forwardRef as Rk,memo as Ak,useRef as om}from"react";import{useMemo as Ek}from"react";var Ai=class{constructor(e=0,t=0){this.keys=new Map,this.free=[],this.nextKeyValue=0,this.reset(e,t)}next(){return this.free.length?this.free.pop():this.nextKeyValue++}reset(e,t){this.keys.forEach((r,s)=>{(s<e||s>=t)&&(this.free.push(r),this.keys.delete(s))});let n=t-e;this.keys.size+this.free.length>n&&(this.free.length=n-this.keys.size);for(let r=e;r<t;r++)if(!this.keys.has(r)){let s=this.next();this.keys.set(r,s)}}keyFor(e){return this.keys.get(e)}};var Mk=([o],[e])=>o-e,tm=5,nm=({data:o,listItemGapSize:e=0,listItemHeight:t,viewportRange:n})=>{let r=Ek(()=>new Ai(0,1),[]),s=t+e,i=Math.max(0,n.from-tm),l=Math.min(o.length,n.to+tm);return r.reset(i,l),o.slice(i,l).map((c,u)=>[r.keyFor(u+i),(u+i)*s,u+i+1,c]).sort(Mk)};import{jsx as Oi,jsxs as Nk}from"react/jsx-runtime";var Lk="No data to display",Li=Pk("saltList"),Ok=Ak(Zo),U9=Rk(function({borderless:e,children:t,className:n,collapsibleHeaders:r=!1,defaultHighlightedIndex:s,defaultSelected:i,disabled:l=!1,disableFocus:a=!1,disableTypeToSelect:c,displayedItemCount:u=10,emptyMessage:d,getItemHeight:f,getItemId:h,height:p,highlightedIndex:m,id:g,itemGapSize:y=0,itemHeight:E,itemTextHighlightPattern:v,itemToString:x,maxHeight:C,maxWidth:b,minHeight:S,minWidth:M,onDragStart:w,onDrop:k,onSelect:L,onSelectionChange:T,onViewportScroll:P,onHighlight:R,restoreLastFocus:O,selected:A,selectionStrategy:D,scrollingApiRef:I,selectionKeys:F,showEmptyMessage:N=!1,source:V,style:K,stickyHeaders:G,tabToSelect:Q,width:X,...U},Y){let ce=Ik(g),ie=om(null),Ae=om(null),me=Vn({id:ce,label:"List",source:V,children:t,options:{collapsibleHeaders:r,getItemId:h,itemToString:x}}),{contentHeight:Me,listItemHeight:Ce,listHeight:ke}=Ii({borderless:e,displayedItemCount:u,height:p,itemCount:me.data.length,itemGapSize:y,itemHeight:E,rootRef:ie,rowHeightRef:Ae}),{focusVisible:je,highlightedIndex:Ee,listControlProps:Ge,listHandlers:at,scrollIntoView:ve,selected:_e}=$n({collapsibleHeaders:r,collectionHook:me,containerRef:ie,defaultHighlightedIndex:s,defaultSelected:me.itemToCollectionItem(i),disabled:l,disableTypeToSelect:c,highlightedIndex:m,label:ce,onSelect:L,onSelectionChange:T,onHighlight:R,restoreLastFocus:O,selected:me.itemToCollectionItem(A),selectionStrategy:D,selectionKeys:F,stickyHeaders:G,tabToSelect:Q}),{onVerticalScroll:q,viewportRange:ee}=Ri({containerSize:typeof ke=="number"?ke:0,itemCount:me.data.length,itemGapSize:y,itemSize:Ce});console.log({viewPortRange:ee});let ne=nm({data:me.data,listItemGapSize:y,listItemHeight:Ce,viewportRange:ee});vi({collectionHook:me,forwardedRef:I,scrollableRef:ie,scrollIntoView:ve});function ae(Z,te,ue){let[Oe,Qe,H,z]=te,le=H-1;Z.push(Oi(Ok,{"aria-setsize":me.data.length,"aria-posinset":H,className:ic(n,{saltHighlighted:le===Ee,saltFocusVisible:je===le}),"data-idx":le,item:z,label:z.label,"data-offset":Qe,role:"option",selected:ii(_e,z),id:z.id,translate3d:Qe},Oe)),ue.value+=1}function ye(Z,te={value:0},ue=Z.length){let Oe=[];for(;te.value<ue;){let Qe=Z[te.value];ae(Oe,Qe,te)}return Oe}function Le(){return d||N?Oi("span",{className:Li("empty-message"),children:d!=null?d:Lk}):null}let ge=()=>{if(ne.length)return ye(ne);Le()},j={"--list-item-gap":y?`${y}px`:void 0,minWidth:M,minHeight:S,width:X!=null?X:"100%",height:p!=null?p:"100%",maxWidth:b!=null?b:X,maxHeight:C!=null?C:ke};return Oi("div",{...U,...at,...Ge,className:ic(Li(),n,Li("virtualized")),id:`${ce}`,ref:Dk(ie,Y),role:"listbox",onScroll:q,style:{...K,...j},tabIndex:l||a?void 0:0,children:Nk("div",{className:Li("scrollingContentContainer"),style:{height:Me},children:[Oi(ki,{ref:Ae}),ge()]})})});import Hk from"classnames";import{jsx as Fk}from"react/jsx-runtime";var rm="vuuRadioIcon",sm=({checked:o=!1,...e})=>Fk("span",{...e,className:Hk(rm,{[`${rm}-checked`]:o})});import{useControlled as Bk}from"@salt-ds/core";import{useCallback as lc,useMemo as Vk}from"react";var im=({collectionHook:o,defaultHighlightedIndex:e,defaultIsOpen:t,defaultSelected:n,highlightedIndex:r,isOpen:s,itemToString:i=It,listRef:l,onHighlight:a,onOpenChange:c,onSelectionChange:u,onSelect:d,selected:f,selectionStrategy:h})=>{let p=h==="multiple"||h==="extended",[m,g]=Bk({controlled:s,default:t!=null?t:!1,name:"useDropdownList"}),y=lc((b,S)=>{p||(g(!1),c==null||c(!1)),u==null||u(b,S)},[p,c,u,g]),E=lc((b,S)=>{p||(g(!1),c==null||c(!1)),d==null||d(b,S)},[p,c,d,g]),v=$n({collectionHook:o,defaultHighlightedIndex:(e!=null?e:r===void 0)?0:void 0,defaultSelected:n,label:"DropDown",onSelectionChange:y,onSelect:E,containerRef:l,highlightedIndex:r,onHighlight:a,selected:f,selectionStrategy:h,tabToSelect:!p}),x=lc(b=>{g(b),c==null||c(b)},[c,g]),C=Vk(()=>{if(p&&Array.isArray(v.selected)){let b=v.selected.map(S=>o.itemById(S));if(b.length===0)return;if(b.length===1){let[S]=b;return S===null?void 0:i(S)}else return`${b.length} items selected`}else{let b=v.selected;return b==null?void 0:i(o.itemById(b))}},[o,p,i,v.selected]);return{isOpen:m,onOpenChange:x,triggerLabel:C,...v}};import{jsx as ac,jsxs as Gk}from"react/jsx-runtime";var Ni=zk(function({"aria-label":e,children:t,defaultIsOpen:n,defaultSelected:r,id:s,isOpen:i,itemToString:l=It,onOpenChange:a,onSelectionChange:c,onSelect:u,selected:d,selectionStrategy:f,source:h,triggerComponent:p,ListItem:m,ListProps:g,width:y=180,...E},v){let x=Uk(s),C=lm(null),b=lm(null),S=$k(C,v),M=Vn({id:x,source:h,children:t,options:{itemToString:l}}),{highlightedIndex:w,triggerLabel:k,listHandlers:L,listControlProps:T,selected:P,...R}=im({collectionHook:M,defaultHighlightedIndex:g==null?void 0:g.defaultHighlightedIndex,defaultIsOpen:n,defaultSelected:M.itemToCollectionItemId(r),highlightedIndex:g==null?void 0:g.highlightedIndex,isOpen:i,itemToString:l,label:"Dropdown",listRef:b,onHighlight:g==null?void 0:g.onHighlight,onOpenChange:a,onSelectionChange:c,onSelect:u,selected:M.itemToCollectionItemId(d),selectionStrategy:f}),O=Wk(D=>{if(Array.isArray(D))return D.map(I=>M.itemById(I));if(D)return M.itemById(D)},[M]),A=()=>{let D={"aria-activedescendant":R.isOpen?T==null?void 0:T["aria-activedescendant"]:void 0,"aria-label":e};if(p){let I=p.props;return Kk(p,si(I,{...R.isOpen?T:{},...D}))}else return ac(sp,{label:k,...R.isOpen?T:{},...D})};return ac(ni,{collectionHook:M,children:Gk(bi,{...E,id:x,isOpen:R.isOpen,onOpenChange:R.onOpenChange,placement:(g==null?void 0:g.width)===void 0?"below-full-width":"below",ref:S,width:y,children:[A(),ac(wn,{ListItem:m,itemToString:l,...g,highlightedIndex:w,listHandlers:L,onSelectionChange:c,onSelect:u,ref:b,selected:O(P),selectionStrategy:f})]})})});import{useControlled as am}from"@salt-ds/core";import{useLayoutEffectSkipFirst as _k}from"@vuu-ui/vuu-layout";import{useCallback as Xe,useRef as Hi,useState as cm}from"react";var Qk=["Enter"],um=({allowFreeText:o,ariaLabel:e,collectionHook:t,defaultIsOpen:n,defaultValue:r,onBlur:s,onFocus:i,onChange:l,onSelect:a,id:c,initialHighlightedIndex:u=-1,isOpen:d,itemToString:f=It,listRef:h,onOpenChange:p,onSelectionChange:m,selectionStrategy:g,stringToItem:y,value:E,InputProps:v={onBlur:s,onFocus:i,onChange:l,onSelect:a}})=>{var Qe;let x=g==="multiple"||g==="extended",C=(Qe=t.stringToCollectionItem(E!=null?E:r))!=null?Qe:null,{data:b,itemToCollectionItem:S,setFilterPattern:M,stringToCollectionItem:w}=t,k=Hi(null),L=Hi(null),T=Hi(!0),P=Hi(C),[R,O]=am({controlled:d,default:n!=null?n:!1,name:"useDropdownList"}),[A,D]=am({controlled:void 0,default:r!=null?r:"",name:"ComboBox",state:"value"}),I=Xe(H=>Array.isArray(H)?H.map(z=>z.value):H&&H.value,[]),[F,N]=cm(!0),[V,K]=cm(!1),G=Xe((H=P.current)=>{var z,le;if(Array.isArray(H))console.log("TODO multi selection");else if(H==null)(z=k.current)==null||z.call(k,-1);else{let Se=b.indexOf(H);(le=k.current)==null||le.call(k,Se)}},[b]),Q=Xe(H=>{D(H),M(H===""?void 0:H)},[M,D]),X=Xe((H=P.current)=>{var le;let z="";Array.isArray(H)?console.log("TODO multi selection"):H!=null&&H.value!==null&&(z=f(H.value)),Q(z),z===""?(le=k.current)==null||le.call(k,-1):G(H)},[G,f,Q]),U=Xe((H,z)=>{x||O(!1),P.current=z,X(z),m==null||m(H,I(z!=null?z:null))},[I,x,m,X,O]),Y=Xe((H,z)=>{if(!x){let le=S(z);U(H,le)}},[U,x,S]),ce=Xe(H=>{if(!o&&H.key==="Enter"&&V){let[z]=b;U(H,z)}},[o,U,b,V]),ie=Xe(H=>{H.key==="Escape"?o?Q(""):X():H.key==="Tab"&&(o||X()),ce(H)},[o,ce,X,Q]),Ae=Xe(()=>{N(!1)},[]),{focusVisible:me,setHighlightedIndex:Me,highlightedIndex:Ce,listControlProps:ke,listHandlers:je,selected:Ee,setSelected:Ge}=$n({collectionHook:t,containerRef:h,defaultHighlightedIndex:u,disableAriaActiveDescendant:F,disableHighlightOnFocus:!0,disableTypeToSelect:!0,label:"useComboBox",onKeyboardNavigation:Ae,onKeyDown:ie,onSelectionChange:Y,selected:P.current,selectionKeys:Qk,selectionStrategy:g,tabToSelect:!x});k.current=Me,L.current=Ge;let at=Xe(H=>{O(H),H||K(!1),p==null||p(H)},[p,O]),{onClick:ve}=je,_e=Xe(H=>{var z;(z=document.getElementById(`${c}-input`))==null||z.focus(),ve==null||ve(H)},[c,ve]),q=Xe(H=>{let z=H.target.value;D(z),z&&z.trim().length?M(z):(M(void 0),P.current=null,m==null||m(H,null)),O(!0),K(z.length>0&&!o)},[o,m,M,O,D]),{onFocus:ee=i}=v,{onFocus:ne}=ke,ae=Xe(H=>{N(!1),ne==null||ne(H),ee==null||ee(H)},[ee,ne]),ye=Xe(H=>{let z=H.relatedTarget;return(z==null?void 0:z.id)===`${c}-list`},[c]),Le=Xe(H=>{var le;let z=A.trim();if(z){let Se=w(z);Se?Array.isArray(Se)||Se!==Ee&&((le=L.current)==null||le.call(L,Se),m==null||m(H,Se.value)):y&&y(z)&&console.log("we have a new item")}},[m,Ee,y,w,A]),{onBlur:ge=s}=v,{onBlur:j}=ke,Z=Xe(H=>{ye(H)||(j==null||j(H),ge==null||ge(H),o?Le(H):X(),N(!0),T.current=!0,O(!1))},[ye,j,ge,o,O,Le,X]),{onSelect:te}=v,ue=Xe(H=>{T.current?T.current=!1:N(!0),te==null||te(H)},[te]);_k(()=>{Bn(Ee)?G():Me(u),b.length===0&&O(!1)},[G,b.length,u,Ee,Me,O]);let Oe={...v.inputProps,"aria-label":e};return{focusVisible:me,highlightedIndex:Ce,isOpen:R,onOpenChange:at,inputProps:{...v,id:`${c}-input`,inputProps:Oe,onChange:q,onSelect:ue,role:"combobox",value:A},listControlProps:{...ke,onBlur:Z,onFocus:ae},listHandlers:{...je,onClick:_e},selected:Ee}};import qk from"classnames";import{jsx as Xk}from"react/jsx-runtime";var jk="vuuChevronIcon",dm=o=>{let{direction:e,...t}=o;return Xk("span",{...t,className:qk(jk,e)})};import{jsx as Fi,jsxs as nE}from"react/jsx-runtime";var ts=Zk(function({InputProps:e,ListProps:t,ListItem:n,"aria-label":r,allowFreeText:s,children:i,defaultIsOpen:l,defaultValue:a,disabled:c,onBlur:u,onFocus:d,onChange:f,onSelect:h,getFilterRegex:p,id:m,initialHighlightedIndex:g=-1,isOpen:y,itemToString:E,onOpenChange:v,onSelectionChange:x,selectionStrategy:C,source:b,stringToItem:S,value:M,width:w=180,...k},L){let T=Jk(m),P=tE(null),R=Vn({id:T,source:b,children:i,options:{filterPattern:M!=null?M:a,getFilterRegex:p,itemToString:E}}),{focusVisible:O,highlightedIndex:A,inputProps:{endAdornment:D,...I},isOpen:F,listHandlers:N,listControlProps:V,onOpenChange:K,selected:G}=um({InputProps:e,allowFreeText:s,ariaLabel:r,collectionHook:R,defaultIsOpen:l,defaultValue:a,disabled:c,initialHighlightedIndex:g,listRef:P,onBlur:u,onFocus:d,onChange:f,onSelect:h,id:T,isOpen:y,itemToString:E,label:"ComboBox",onOpenChange:v,onSelectionChange:x,selectionStrategy:C,stringToItem:S,value:M}),Q=eE(U=>Array.isArray(U)?U.map(Y=>Y.value):U&&U.value,[]);return Fi(ni,{collectionHook:R,children:nE(bi,{...k,fullWidth:!0,id:T,isOpen:F,onOpenChange:K,openOnFocus:!0,ref:L,width:w,children:[Fi(Yk,{...I,disabled:c,...V,endAdornment:D===null?null:Fi(dm,{direction:F?"up":"down",onClick:()=>{K(!F)}})}),Fi(wn,{...t,ListItem:n,focusVisible:O,highlightedIndex:A,itemTextHighlightPattern:String(I.value)||void 0,id:`${T}-list`,listHandlers:N,onSelectionChange:x,ref:P,selected:Q(G),selectionStrategy:C})]})})});import{getEditRuleValidator as oE}from"@vuu-ui/vuu-utils";var fm=o=>e=>rE(o,e);function rE(o,e){console.log(`apply rules to ${e}`);let t;for(let n of o){let r=oE(n.name);if(r){let s=r(n,e);switch(s){case!0:break;case!1:t===void 0&&(t=!1);break;default:t===void 0||t===!1?t=s:t+=`::${s}`}}else throw Error(`editable-utils applyRules, no validator registered for rule '${n.name}'`)}return console.log(t),t}import{useCallback as cc,useRef as uc,useState as hm}from"react";var pm=o=>{let e=new Event("vuu-commit");o.dispatchEvent(e)},mm=({clientSideEditValidationCheck:o,initialValue:e,onCommit:t})=>{let[n,r]=hm(),[s,i]=hm(e),l=uc(e),a=uc(!1),c=uc(!1),u=cc(()=>{console.log("blur")},[]),d=cc(h=>{if(h.key==="Enter")if(h.stopPropagation(),a.current){c.current=!0;let p=o==null?void 0:o(s);p?r(p):(r(void 0),t(s)&&(a.current=!1,pm(h.target)))}else pm(h.target),c.current=!1;else h.key==="ArrowRight"||h.key==="ArrowLeft"||h.key==="ArrowUp"||h.key==="ArrowDown"?h.stopPropagation():h.key==="Escape"&&a.current&&(a.current=!1,r(void 0),i(l.current))},[o,t,s]),f=cc(h=>{let{value:p}=h.target;if(a.current=p!==l.current,i(p),console.log(`value changes to ${p} message ${n}`),c.current){let m=o==null?void 0:o(p);console.log({warningMessage:m}),m!==n&&m!==!1&&r(m)}},[o,n]);return{onBlur:u,onChange:f,onKeyDown:d,value:s,warningMessage:n}};import sE from"classnames";import{useCallback as gm,useLayoutEffect as iE,forwardRef as lE,useRef as dc}from"react";import{Input as aE,useControlled as bm}from"@salt-ds/core";import{jsx as fc}from"react/jsx-runtime";var Bi="vuuEditableLabel",ns=lE(function({className:e,defaultEditing:t,defaultValue:n,editing:r,onChange:s,onEnterEditMode:i,onExitEditMode:l,value:a,...c},u){let d=dc(null),f=dc(!1),[h,p]=bm({controlled:a,default:n!=null?n:"",name:"EditableLabel",state:"value"}),[m,g]=bm({controlled:r,default:t!=null?t:!1,name:"EditableLabel",state:"editing"}),y=gm(k=>{g(f.current=k)},[g]),E=dc(h);iE(()=>{m&&d.current!==null&&(d.current.select(),d.current.focus())},[m,d]);let v=gm(()=>{y(!0),i&&i()},[i,y]),x=({cancelEdit:k=!1,allowDeactivation:L=!1}={})=>{y(!1);let T=E.current;T!==h&&(k?p(T):E.current=h),l&&l(T,h,L,k)},C=k=>{let{value:L}=k.target;p(L),s&&s(L)},b=()=>{v()},S=()=>{f.current&&x({allowDeactivation:!0})},M=k=>{m&&k.key==="Enter"?(k.stopPropagation(),x()):k.key==="ArrowRight"||k.key==="ArrowLeft"?k.stopPropagation():k.key==="Escape"&&x({cancelEdit:!0})},w=sE(Bi,e,{[`${Bi}-editing`]:m});return fc("div",{...c,className:w,onDoubleClick:b,"data-text":h,ref:u,children:m?fc(aE,{inputProps:{className:`${Bi}-input`,spellCheck:!1},value:h,onBlur:S,onChange:C,onKeyDown:M,inputRef:d,style:{padding:0},textAlign:"left",variant:"secondary"}):fc("span",{className:`${Bi}-label`,children:h})})});import{Input as cE}from"@salt-ds/core";import uE from"classnames";import{forwardRef as dE}from"react";import{jsx as xm}from"react/jsx-runtime";var ym="vuuExpandoInput",Vi=dE(function({className:e,value:t,inputProps:n,...r},s){return xm("div",{className:uE(ym,e),"data-text":t,children:xm(cE,{...r,inputProps:{...n,className:`${ym}-input`},ref:s,style:{padding:0},textAlign:"left",value:t,variant:"secondary"})})});import{jsx as fE,jsxs as hE}from"react/jsx-runtime";var Cm=o=>{let{onToggle:e,checked:t,label:n}=o;return hE("div",{className:"vuuCheckbox",onClick:e,onKeyUp:r=>r.key===" "&&e(),children:[fE(wi,{tabIndex:0,checked:t}),n]})};import{jsx as vm,jsxs as Sm}from"react/jsx-runtime";var wm=o=>{let{onClick:e,checked:t,label:n,groupName:r}=o;return Sm("div",{className:"vuuRadioButton",onClick:e,children:[Sm("div",{className:"radio",children:[vm("input",{type:"radio",name:r}),vm(sm,{checked:t})]}),n]})};import{registerComponent as MO}from"@vuu-ui/vuu-layout";import{useCallback as BU,useRef as VU}from"react";import{jsx as zU}from"react/jsx-runtime";import{isNumericColumn as pE}from"@vuu-ui/vuu-utils";var gc=o=>(e,t)=>{let n=[];if(o===void 0)return n;if(e==="header"||e==="column-menu")n.push(...mE(t,o)),n.push(...yE(t,o)),n.push(...gE(t,o)),n.push(...bE(t)),n.push({action:"column-settings",icon:"cog",label:"Column Settings",options:t}),n.push({action:"table-settings",icon:"cog",label:"DataGrid Settings",options:t});else if(e==="filter"){let{column:r,filter:s}=t,i=(s==null?void 0:s.column)===(r==null?void 0:r.name);n.push({label:"Edit filter",action:"filter-edit",options:t}),n.push({label:"Remove filter",action:"filter-remove-column",options:t}),r&&!i&&n.push({label:"Remove all filters",action:"remove-filters",options:t})}return n};function mE(o,{sort:{sortDefs:e}}){let{column:t}=o,n=[];if(t===void 0)return n;let r=e.length>0;return t.sorted==="A"?n.push({label:"Reverse Sort (DSC)",action:"sort-dsc",options:o}):t.sorted==="D"?n.push({label:"Reverse Sort (ASC)",action:"sort-asc",options:o}):typeof t.sorted=="number"?(t.sorted>0?n.push({label:"Reverse Sort (DSC)",action:"sort-add-dsc",options:o}):n.push({label:"Reverse Sort (ASC)",action:"sort-add-asc",options:o}),r&&Math.abs(t.sorted)<e.length&&n.push({label:"Remove from sort",action:"sort-remove",options:o}),n.push({label:"New Sort",children:[{label:"Ascending",action:"sort-asc",options:o},{label:"Descending",action:"sort-dsc",options:o}]})):r?(n.push({label:"Add to sort",children:[{label:"Ascending",action:"sort-add-asc",options:o},{label:"Descending",action:"sort-add-dsc",options:o}]}),n.push({label:"New Sort",children:[{label:"Ascending",action:"sort-asc",options:o},{label:"Descending",action:"sort-dsc",options:o}]})):n.push({label:"Sort",children:[{label:"Ascending",action:"sort-asc",options:o},{label:"Descending",action:"sort-dsc",options:o}]}),n}function gE(o,e){let{column:t}=o;if(t===void 0||e.groupBy.length===0)return[];let{name:n,label:r=n}=t;return[{label:`Aggregate ${r}`,children:[{label:"Count",action:"agg-count",options:o},{label:"Distinct",action:"agg-distinct",options:o}].concat(pE(t)?[{label:"Sum",action:"agg-sum",options:o},{label:"Avg",action:"agg-avg",options:o},{label:"High",action:"agg-high",options:o},{label:"Low",action:"agg-low",options:o}]:[])}]}var bc=(o,e)=>({label:`Pin ${e}`,action:`column-pin-${e}`,options:o}),hc=o=>bc(o,"left"),pc=o=>bc(o,"floating"),mc=o=>bc(o,"right");function bE(o){let{column:e}=o;if(e===void 0)return[];let{pin:t}=e,n=[{label:"Hide column",action:"column-hide",options:o},{label:"Remove column",action:"column-remove",options:o}];return t===void 0?n.push({label:"Pin column",children:[hc(o),pc(o),mc(o)]}):t==="left"?n.push({label:"Unpin column",action:"column-unpin",options:o},{label:"Pin column",children:[pc(o),mc(o)]}):t==="right"?n.push({label:"Unpin column",action:"column-unpin",options:o},{label:"Pin column",children:[hc(o),pc(o)]}):t==="floating"&&n.push({label:"Unpin column",action:"column-unpin",options:o},{label:"Pin column",children:[hc(o),mc(o)]}),n}function yE(o,{groupBy:e}){let{column:t}=o,n=[];if(t===void 0)return n;let{name:r,label:s=r}=t;return e.length===0?n.push({label:`Group by ${s}`,action:"group",options:o}):n.push({label:`Add ${s} to group by`,action:"group-add",options:o}),n}import{removeColumnFromFilter as xE}from"@vuu-ui/vuu-utils";import{addGroupColumn as Tm,addSortColumn as km,AggregationType as CE,setAggregations as rr,setSortColumn as Em}from"@vuu-ui/vuu-utils";var vE=(o,e)=>{if(o.filterStruct&&e){let[t,n]=xE(e,o.filterStruct);return{filter:n,filterStruct:t}}else return o},{Average:SE,Count:wE,Distinct:TE,High:kE,Low:EE,Sum:ME}=CE,yc=({dataSource:o,onPersistentColumnOperation:e})=>n=>{let r=n.options;if(r.column&&o){let{column:s}=r;switch(n.menuId){case"sort-asc":return o.sort=Em(o.sort,s,"A"),!0;case"sort-dsc":return o.sort=Em(o.sort,s,"D"),!0;case"sort-add-asc":return o.sort=km(o.sort,s,"A"),!0;case"sort-add-dsc":return o.sort=km(o.sort,s,"D"),!0;case"group":return o.groupBy=Tm(o.groupBy,s),!0;case"group-add":return o.groupBy=Tm(o.groupBy,s),!0;case"column-hide":return e({type:"hideColumns",columns:[s]}),!0;case"column-remove":return o.columns=o.columns.filter(i=>i!==s.name),!0;case"filter-remove-column":return o.filter=vE(o.filter,s),!0;case"remove-filters":return o.filter={filter:""},!0;case"agg-avg":return o.aggregations=rr(o.aggregations,s,SE),!0;case"agg-high":return o.aggregations=rr(o.aggregations,s,kE),!0;case"agg-low":return o.aggregations=rr(o.aggregations,s,EE),!0;case"agg-count":return o.aggregations=rr(o.aggregations,s,wE),!0;case"agg-distinct":return o.aggregations=rr(o.aggregations,s,TE),!0;case"agg-sum":return o.aggregations=rr(o.aggregations,s,ME),!0;case"column-pin-floating":return e({type:"pinColumn",column:s,pin:"floating"}),!0;case"column-pin-left":return e({type:"pinColumn",column:s,pin:"left"}),!0;case"column-pin-right":return e({type:"pinColumn",column:s,pin:"right"}),!0;case"column-unpin":return e({type:"pinColumn",column:s,pin:void 0}),!0;case"column-settings":return e({type:"columnSettings",column:s}),!0;case"table-settings":return e({type:"tableSettings"}),!0;default:}}return!1};import{Button as hX,useIdMemo as pX}from"@salt-ds/core";import{buildColumnMap as zG,getColumnStyle as WG,isGroupColumn as UG,metadataKeys as oM,notHidden as GG,visibleColumnAtIndex as _G}from"@vuu-ui/vuu-utils";import{useCallback as jG,useMemo as XG}from"react";import{isGroupColumn as Im,isJsonColumn as KE,isJsonGroup as zE,metadataKeys as WE,notHidden as UE,RowSelected as GE}from"@vuu-ui/vuu-utils";import _E from"classnames";import{memo as QE,useCallback as Rm}from"react";import{getColumnStyle as PE,metadataKeys as DE}from"@vuu-ui/vuu-utils";import IE from"classnames";import{memo as RE,useCallback as AE,useRef as LE,useState as Mm}from"react";import{jsx as $i}from"react/jsx-runtime";var{KEY:Pm}=DE,xc=RE(({className:o,column:e,columnMap:t,onClick:n,row:r})=>{let s=LE(null),{align:i,CellRenderer:l,key:a,pin:c,editable:u,resizing:d,valueFormatter:f}=e,[h,p]=Mm(!1),m=f(r[a]),[g,y]=Mm(m),E=()=>{var w;(w=s.current)==null||w.focus()},v=w=>{w.key==="Enter"&&p(!0)},x=AE(w=>{n==null||n(w,e)},[e,n]),C=()=>{p(!0)},b=(w="",k="",L=!0,T=!1)=>{var P;p(!1),T?y(w):k!==w&&y(k),L===!1&&((P=s.current)==null||P.focus())},S=IE(o,{vuuAlignRight:i==="right",vuuPinFloating:c==="floating",vuuPinLeft:c==="left",vuuPinRight:c==="right","vuuTableCell-resizing":d})||void 0,M=PE(e);return u?$i("div",{className:S,"data-editable":!0,role:"cell",style:M,onKeyDown:v,children:$i(ns,{editing:h,value:g,onChange:y,onMouseDownCapture:E,onEnterEditMode:C,onExitEditMode:b,onKeyDown:v,ref:s,tabIndex:0},"title")}):$i("div",{className:S,role:"cell",style:M,onClick:x,children:l?$i(l,{column:e,columnMap:t,row:r}):m})},OE);xc.displayName="TableCell";function OE(o,e){return o.column===e.column&&o.onClick===e.onClick&&o.row[Pm]===e.row[Pm]&&o.row[o.column.key]===e.row[e.column.key]}import{getColumnStyle as NE,getGroupValueAndOffset as HE,metadataKeys as FE}from"@vuu-ui/vuu-utils";import{useCallback as BE}from"react";import{jsx as Cc,jsxs as $E}from"react/jsx-runtime";var{IS_LEAF:VE}=FE,Dm=({column:o,onClick:e,row:t})=>{let{columns:n}=o,[r,s]=HE(n,t),i=BE(u=>{e==null||e(u,o)},[o,e]),l=NE(o),a=t[VE],c=Array(s).fill(0).map((u,d)=>Cc("span",{className:"vuuTableGroupCell-spacer"},d));return $E("div",{className:"vuuTableGroupCell vuuPinLeft",onClick:a?void 0:i,role:"cell",style:l,children:[c,a?null:Cc("span",{className:"vuuTableGroupCell-toggle","data-icon":"triangle-right"}),Cc("span",{children:r})]})};import{jsx as Lm,jsxs as eM}from"react/jsx-runtime";var{IDX:qE,IS_EXPANDED:jE,SELECTED:XE}=WE,{True:Am,First:JE,Last:YE}=GE,sr="vuuTableRow",ZE=QE(function({columnMap:e,columns:t,offset:n,onClick:r,onToggleGroup:s,virtualColSpan:i=0,row:l}){let{[qE]:a,[jE]:c,[XE]:u}=l,d=_E(sr,{[`${sr}-even`]:a%2===0,[`${sr}-expanded`]:c,[`${sr}-selected`]:u&Am,[`${sr}-selectedStart`]:u&JE,[`${sr}-selectedEnd`]:u&YE}),f=Rm(p=>{let m=p.shiftKey,g=p.ctrlKey||p.metaKey;r==null||r(l,m,g)},[r,l]),h=Rm((p,m)=>{(Im(m)||zE(m,l))&&(p.stopPropagation(),s==null||s(l,m))},[s,l]);return eM("div",{"aria-selected":u&Am?!0:void 0,"aria-rowindex":a,className:d,onClick:f,role:"row",style:{transform:`translate3d(0px, ${n}px, 0px)`},children:[i>0?Lm("div",{role:"cell",style:{width:i}}):null,t.filter(UE).map(p=>{let m=Im(p),g=KE(p);return Lm(m?Dm:xc,{column:p,columnMap:e,onClick:m||g?h:void 0,row:l},p.name)})]})});import B7 from"classnames";import{useRef as K7}from"react";import{useCallback as A7,useRef as L7}from"react";import{jsx as _7,jsxs as Q7}from"react/jsx-runtime";import vG from"classnames";import{useCallback as kG,useRef as EG}from"react";import Y7 from"classnames";import{jsx as tG,jsxs as nG}from"react/jsx-runtime";import uG from"classnames";import{useCallback as hG}from"react";import{jsx as gG}from"react/jsx-runtime";import{jsx as OG,jsxs as NG}from"react/jsx-runtime";import{jsx as o_,jsxs as r_}from"react/jsx-runtime";var{RENDER_IDX:t_}=oM;import{applySort as Aj,buildColumnMap as Lj,isJsonGroup as Oj,metadataKeys as zM,moveItemDeprecated as Nj}from"@vuu-ui/vuu-utils";import{useCallback as Bj,useEffect as Vj,useMemo as $j,useRef as Kj,useState as zj}from"react";import{getFullRange as l_,metadataKeys as rM,WindowRange as a_}from"@vuu-ui/vuu-utils";import{useCallback as u_,useEffect as d_,useMemo as f_,useRef as h_,useState as p_}from"react";var{SELECTED:m_}=rM;import{useCallback as y_,useEffect as x_,useState as C_}from"react";import{ConnectionManager as S_}from"@vuu-ui/vuu-data";import{useCallback as E_,useEffect as M_,useState as P_}from"react";import{ConnectionManager as I_}from"@vuu-ui/vuu-data";import{useCallback as sM}from"react";import{makeRpcCall as iM}from"@vuu-ui/vuu-data";var Om={type:"RPC_CALL",service:"TypeAheadRpcHandler"};var Ki=()=>sM(async e=>{let t=e.length===2?{method:"getUniqueFieldValues",params:e,...Om}:{method:"getUniqueFieldValuesStartingWith",params:e,...Om};return await iM(t)},[]);var lM=0,os=class{constructor(e,t){this.from=e,this.to=t}},re=class{constructor(e={}){this.id=lM++,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=Ve.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};re.closedBy=new re({deserialize:o=>o.split(" ")});re.openedBy=new re({deserialize:o=>o.split(" ")});re.group=new re({deserialize:o=>o.split(" ")});re.contextHash=new re({perNode:!0});re.lookAhead=new re({perNode:!0});re.mounted=new re({perNode:!0});var aM=Object.create(null),Ve=class{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):aM,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Ve(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}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(re.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 r of n.split(" "))t[r]=e[n];return n=>{for(let r=n.prop(re.group),s=-1;s<(r?r.length:0);s++){let i=t[s<0?n.name:r[s]];if(i)return i}}}};Ve.none=new Ve("",Object.create(null),0,8);var Tn=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 r=null;for(let s of e){let i=s(n);i&&(r||(r=Object.assign({},n.props)),r[i[0].id]=i[1])}t.push(r?new Ve(n.name,r,n.id,n.flags):n)}return new Tn(t)}},zi=new WeakMap,Nm=new WeakMap,Ne;(function(o){o[o.ExcludeBuffers=1]="ExcludeBuffers",o[o.IncludeAnonymous=2]="IncludeAnonymous",o[o.IgnoreMounts=4]="IgnoreMounts",o[o.IgnoreOverlays=8]="IgnoreOverlays"})(Ne||(Ne={}));var pe=class{constructor(e,t,n,r,s){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[i,l]of s)this.props[typeof i=="number"?i:i.id]=l}}toString(){let e=this.prop(re.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let r=n.toString();r&&(t&&(t+=","),t+=r)}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 lr(this.topNode,e)}cursorAt(e,t=0,n=0){let r=zi.get(this)||this.topNode,s=new lr(r);return s.moveTo(e,t),zi.set(this,s._tree),s}get topNode(){return new qt(this,0,0,null)}resolve(e,t=0){let n=ir(zi.get(this)||this.topNode,e,t,!1);return zi.set(this,n),n}resolveInner(e,t=0){let n=ir(Nm.get(this)||this.topNode,e,t,!0);return Nm.set(this,n),n}iterate(e){let{enter:t,leave:n,from:r=0,to:s=this.length}=e,i=e.mode||0,l=(i&Ne.IncludeAnonymous)>0;for(let a=this.cursor(i|Ne.IncludeAnonymous);;){let c=!1;if(a.from<=s&&a.to>=r&&(!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:Tc(Ve.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new pe(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new pe(Ve.none,t,n,r)))}static build(e){return cM(e)}};pe.empty=new pe(Ve.none,[],[],0);var rs=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 rs(this.buffer,this.index)}},kn=class{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Ve.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],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let i=[];for(;e<n;)i.push(this.childString(e)),e=this.buffer[e+3];return s+"("+i.join(",")+")"}findChild(e,t,n,r,s){let{buffer:i}=this,l=-1;for(let a=e;a!=t&&!(Fm(s,r,i[a+1],i[a+2])&&(l=a,n>0));a=i[a+3]);return l}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),i=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-n;let c=s[a++]=r[l++]-n;s[a++]=r[l++]-e,i=Math.max(i,c)}return new kn(s,i,this.set)}};function Fm(o,e,t,n){switch(o){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 Bm(o,e){let t=o.childBefore(e);for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(o=t,t=n.prevSibling):t=n}return o}function ir(o,e,t,n){for(var r;o.from==o.to||(t<1?o.from>=e:o.from>e)||(t>-1?o.to<=e:o.to<e);){let i=!n&&o instanceof qt&&o.index<0?null:o.parent;if(!i)return o;o=i}let s=n?0:Ne.IgnoreOverlays;if(n)for(let i=o,l=i.parent;l;i=l,l=i.parent)i instanceof qt&&i.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=i.from&&(o=l);for(;;){let i=o.enter(e,t,s);if(!i)return o;o=i}}var qt=class{constructor(e,t,n,r){this._tree=e,this.from=t,this.index=n,this._parent=r}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,r,s=0){for(let i=this;;){for(let{children:l,positions:a}=i._tree,c=t>0?l.length:-1;e!=c;e+=t){let u=l[e],d=a[e]+i.from;if(Fm(r,n,d,d+u.length)){if(u instanceof kn){if(s&Ne.ExcludeBuffers)continue;let f=u.findChild(0,u.buffer.length,t,n-d,r);if(f>-1)return new rn(new vc(i,u,e,d),null,f)}else if(s&Ne.IncludeAnonymous||!u.type.isAnonymous||wc(u)){let f;if(!(s&Ne.IgnoreMounts)&&u.props&&(f=u.prop(re.mounted))&&!f.overlay)return new qt(f.tree,d,e,i);let h=new qt(u,d,e,i);return s&Ne.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(t<0?u.children.length-1:0,t,n,r)}}}if(s&Ne.IncludeAnonymous||!i.type.isAnonymous||(i.index>=0?e=i.index+t:e=t<0?-1:i._parent._tree.children.length,i=i._parent,!i))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 r;if(!(n&Ne.IgnoreOverlays)&&(r=this._tree.prop(re.mounted))&&r.overlay){let s=e-this.from;for(let{from:i,to:l}of r.overlay)if((t>0?i<=s:i<s)&&(t<0?l>=s:l>s))return new qt(r.tree,r.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 lr(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 Bm(this,e)}getChild(e,t=null,n=null){let r=Ui(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Ui(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return Gi(this,e)}};function Ui(o,e,t,n){let r=o.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function Gi(o,e,t=e.length-1){for(let n=o.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 vc=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},rn=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:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new rn(this.context,this,s)}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&Ne.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new rn(this.context,this,s)}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 rn(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 rn(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new lr(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let i=n.buffer[this.index+1];e.push(n.slice(r,s,i)),t.push(0)}return new pe(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 Bm(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let r=Ui(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Ui(this,e,t,n)}get node(){return this}matchContext(e){return Gi(this,e)}},lr=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 qt)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:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof qt?(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:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(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&Ne.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ne.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ne.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 r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}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:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,i=e<0?-1:n._tree.children.length;s!=i;s+=e){let l=n._tree.children[s];if(this.mode&Ne.IncludeAnonymous||l instanceof kn||!l.type.isAnonymous||wc(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 r=this.index,s=this.stack.length;s>=0;){for(let i=e;i;i=i._parent)if(i.index==r){if(r==this.index)return i;t=i,n=s+1;break e}r=this.stack[--s]}for(let r=n;r<this.stack.length;r++)t=new rn(this.buffer,t,this.stack[r]);return this.bufferNode=new rn(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return Gi(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return Gi(this.node,e,r);let i=n[t.buffer[this.stack[s]]];if(!i.isAnonymous){if(e[r]&&e[r]!=i.name)return!1;r--}}return!0}};function wc(o){return o.children.some(e=>e instanceof kn||!e.type.isAnonymous||wc(e))}function cM(o){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=1024,reused:s=[],minRepeatType:i=n.types.length}=o,l=Array.isArray(t)?new rs(t,t.length):t,a=n.types,c=0,u=0;function d(x,C,b,S,M){let{id:w,start:k,end:L,size:T}=l,P=u;for(;T<0;)if(l.next(),T==-1){let I=s[w];b.push(I),S.push(k-x);return}else if(T==-3){c=w;return}else if(T==-4){u=w;return}else throw new RangeError(`Unrecognized record size: ${T}`);let R=a[w],O,A,D=k-x;if(L-k<=r&&(A=m(l.pos-C,M))){let I=new Uint16Array(A.size-A.skip),F=l.pos-A.size,N=I.length;for(;l.pos>F;)N=g(A.start,I,N);O=new kn(I,L-A.start,n),D=A.start-x}else{let I=l.pos-T;l.next();let F=[],N=[],V=w>=i?w:-1,K=0,G=L;for(;l.pos>I;)V>=0&&l.id==V&&l.size>=0?(l.end<=G-r&&(h(F,N,k,K,l.end,G,V,P),K=F.length,G=l.end),l.next()):d(k,I,F,N,V);if(V>=0&&K>0&&K<F.length&&h(F,N,k,K,k,G,V,P),F.reverse(),N.reverse(),V>-1&&K>0){let Q=f(R);O=Tc(R,F,N,0,F.length,0,L-k,Q,Q)}else O=p(R,F,N,L-k,P-L)}b.push(O),S.push(D)}function f(x){return(C,b,S)=>{let M=0,w=C.length-1,k,L;if(w>=0&&(k=C[w])instanceof pe){if(!w&&k.type==x&&k.length==S)return k;(L=k.prop(re.lookAhead))&&(M=b[w]+k.length+L)}return p(x,C,b,S,M)}}function h(x,C,b,S,M,w,k,L){let T=[],P=[];for(;x.length>S;)T.push(x.pop()),P.push(C.pop()+b-M);x.push(p(n.types[k],T,P,w-M,L-w)),C.push(M-b)}function p(x,C,b,S,M=0,w){if(c){let k=[re.contextHash,c];w=w?[k].concat(w):[k]}if(M>25){let k=[re.lookAhead,M];w=w?[k].concat(w):[k]}return new pe(x,C,b,S,w)}function m(x,C){let b=l.fork(),S=0,M=0,w=0,k=b.end-r,L={size:0,start:0,skip:0};e:for(let T=b.pos-x;b.pos>T;){let P=b.size;if(b.id==C&&P>=0){L.size=S,L.start=M,L.skip=w,w+=4,S+=4,b.next();continue}let R=b.pos-P;if(P<0||R<T||b.start<k)break;let O=b.id>=i?4:0,A=b.start;for(b.next();b.pos>R;){if(b.size<0)if(b.size==-3)O+=4;else break e;else b.id>=i&&(O+=4);b.next()}M=A,S+=P,w+=O}return(C<0||S==x)&&(L.size=S,L.start=M,L.skip=w),L.size>4?L:void 0}function g(x,C,b){let{id:S,start:M,end:w,size:k}=l;if(l.next(),k>=0&&S<i){let L=b;if(k>4){let T=l.pos-(k-4);for(;l.pos>T;)b=g(x,C,b)}C[--b]=L,C[--b]=w-x,C[--b]=M-x,C[--b]=S}else k==-3?c=S:k==-4&&(u=S);return b}let y=[],E=[];for(;l.pos>0;)d(o.start||0,o.bufferStart||0,y,E,-1);let v=(e=o.length)!==null&&e!==void 0?e:y.length?E[0]+y[0].length:0;return new pe(a[o.topID],y.reverse(),E.reverse(),v)}var Hm=new WeakMap;function Wi(o,e){if(!o.isAnonymous||e instanceof kn||e.type!=o)return 1;let t=Hm.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=o||!(n instanceof pe)){t=1;break}t+=Wi(o,n)}Hm.set(e,t)}return t}function Tc(o,e,t,n,r,s,i,l,a){let c=0;for(let p=n;p<r;p++)c+=Wi(o,e[p]);let u=Math.ceil(c*1.5/8),d=[],f=[];function h(p,m,g,y,E){for(let v=g;v<y;){let x=v,C=m[v],b=Wi(o,p[v]);for(v++;v<y;v++){let S=Wi(o,p[v]);if(b+S>=u)break;b+=S}if(v==x+1){if(b>u){let S=p[x];h(S.children,S.positions,0,S.children.length,m[x]+E);continue}d.push(p[x])}else{let S=m[v-1]+p[v-1].length-C;d.push(Tc(o,p,m,x,v,C,S,null,a))}f.push(C+E-s)}}return h(e,t,n,r,0),(l||a)(d,f,i)}var sn=class{constructor(e,t,n,r,s=!1,i=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(i?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new sn(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,i=e.length?e[0]:null;for(let l=0,a=0,c=0;;l++){let u=l<t.length?t[l]:null,d=u?u.fromA:1e9;if(d-a>=n)for(;i&&i.from<d;){let f=i;if(a>=f.from||d<=f.to||c){let h=Math.max(f.from,a)-c,p=Math.min(f.to,d)-c;f=h>=p?null:new sn(h,p,f.tree,f.offset+c,l>0,!!u)}if(f&&r.push(f),i.to>d)break;i=s<e.length?e[s++]:null}if(!u)break;a=u.toA,c=u.toA-u.toB}return r}},Kn=class{startParse(e,t,n){return typeof e=="string"&&(e=new Sc(e)),n=n?n.length?n.map(r=>new os(r.from,r.to)):[new os(0,0)]:[new os(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}},Sc=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 N_=new re({perNode:!0});var cr=class{constructor(e,t,n,r,s,i,l,a,c,u=0,d){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=s,this.score=i,this.buffer=l,this.bufferBase=a,this.curContext=c,this.lookAhead=u,this.parent=d}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 r=e.parser.context;return new cr(e,[],t,n,n,0,[],0,r?new _i(r,r.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,r=e&65535,{parser:s}=this.p,i=s.dynamicPrecedence(r);if(i&&(this.score+=i),n==0){this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,4,!0),this.reduceContext(r,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[r])===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,d=this.bufferBase+this.buffer.length-u;if(r<s.minRepeatTerm||e&131072){let f=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,a,f,d+4,!0)}if(e&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=s.getGoto(f,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,a)}storeNode(e,t,n,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let i=this,l=this.buffer.length;if(l==0&&i.parent&&(l=i.bufferBase-i.parent.bufferBase,i=i.parent),l>0&&i.buffer[l-4]==0&&i.buffer[l-1]>-1){if(t==n)return;if(i.buffer[l-2]>=t){i.buffer[l-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&this.buffer[i-4]!=0)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4);this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n){let r=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=n,this.shiftContext(t,r),t<=this.p.parser.maxNode&&this.buffer.push(t,r,n,4);else{let s=e,{parser:i}=this.p;(n>this.pos||t<=i.maxNode)&&(this.pos=n,i.stateFlag(s,1)||(this.reducePos=n)),this.pushState(s,r),this.shiftContext(t,r),t<=i.maxNode&&this.buffer.push(t,r,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 r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,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),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new cr(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,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 Ec(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 r=[];for(let s=0,i;s<t.length;s+=2)(i=t[s+1])!=this.state&&this.p.parser.hasAction(i,e)&&r.push(t[s],i);if(this.stack.length<120)for(let s=0;r.length<4<<1&&s<t.length;s+=2){let i=t[s+1];r.some((l,a)=>a&1&&l==i)||r.push(t[s],i)}t=r}let n=[];for(let r=0;r<t.length&&n.length<4;r+=2){let s=t[r+1];if(s==this.state)continue;let i=this.split();i.pushState(s,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[r],this.pos),i.score-=200,n.push(i)}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,r=t&65535,s=this.stack.length-n*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let i=this.findForcedReduction();if(i==null)return!1;t=i}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=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,i=>{if(!(i&393216))if(i&65536){let l=(i>>19)-s;if(l>1){let a=i&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(i,s+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 _i(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()}},_i=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},Vm;(function(o){o[o.Insert=200]="Insert",o[o.Delete=190]="Delete",o[o.Reduce=100]="Reduce",o[o.MaxNext=4]="MaxNext",o[o.MaxInsertStackDepth=300]="MaxInsertStackDepth",o[o.DampenInsertStackDepth=120]="DampenInsertStackDepth",o[o.MinBigReduction=2e3]="MinBigReduction"})(Vm||(Vm={}));var Ec=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 r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},ur=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 ur(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 ur(this.stack,this.pos,this.index)}};function ss(o,e=Uint16Array){if(typeof o!="string")return o;let t=null;for(let n=0,r=0;n<o.length;){let s=0;for(;;){let i=o.charCodeAt(n++),l=!1;if(i==126){s=65535;break}i>=92&&i--,i>=34&&i--;let a=i-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}t?t[r++]=s:t=new e(s)}return t}var ar=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},$m=new ar,Mc=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=$m,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,r=this.rangeIndex,s=this.pos+e;for(;s<n.from;){if(!r)return null;let i=this.ranges[--r];s-=n.from-i.to,n=i}for(;t<0?s>n.to:s>=n.to;){if(r==this.ranges.length-1)return null;let i=this.ranges[++r];s+=i.from-n.to,n=i}return s}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,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(n=s,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let i=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++i];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}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=$m,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 r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},zn=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;Qm(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};zn.prototype.contextual=zn.prototype.fallback=zn.prototype.extend=!1;var Pc=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?ss(e):e}token(e,t){let n=e.pos,r=0;for(;;){let s=e.next<0,i=e.resolveOffset(1,1);if(Qm(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};Pc.prototype.contextual=zn.prototype.fallback=zn.prototype.extend=!1;function Qm(o,e,t,n,r,s){let i=0,l=1<<n,{dialect:a}=t.p.parser;e:for(;l&o[i];){let c=o[i+1];for(let h=i+3;h<c;h+=2)if((o[h+1]&l)>0){let p=o[h];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||uM(p,e.token.value,r,s))){e.acceptToken(p);break}}let u=e.next,d=0,f=o[i+2];if(e.next<0&&f>d&&o[c+f*3-3]==65535&&o[c+f*3-3]==65535){i=o[c+f*3-1];continue e}for(;d<f;){let h=d+f>>1,p=c+h+(h<<1),m=o[p],g=o[p+1]||65536;if(u<m)f=h;else if(u>=g)d=h+1;else{i=o[p+2],e.advance();continue e}}break}}function Km(o,e,t){for(let n=e,r;(r=o[n])!=65535;n++)if(r==t)return n-e;return-1}function uM(o,e,t,n){let r=Km(t,n,e);return r<0||Km(t,n,o)<r}var jt=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),kc=null,zm;(function(o){o[o.Margin=25]="Margin"})(zm||(zm={}));function Wm(o,e,t){let n=o.cursor(Ne.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(o.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:o.length}}var Dc=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?Wm(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Wm(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],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=n.children[r],i=this.start[t]+n.positions[r];if(i>e)return this.nextStart=i,null;if(s instanceof pe){if(i==e){if(i<this.safeFrom)return null;let l=i+s.length;if(l<=this.safeTo){let a=s.prop(re.lookAhead);if(!a||l+a<this.fragment.to)return s}}this.index[t]++,i+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(i),this.index.push(0))}else this.index[t]++,this.nextStart=i+s.length}}},Ic=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new ar)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:s}=r,i=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let c=0;c<s.length;c++){if(!(1<<c&i))continue;let u=s[c],d=this.tokens[c];if(!(n&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=i||d.context!=l)&&(this.updateCachedToken(d,u,e),d.mask=i,d.context=l),d.lookAhead>d.end+25&&(a=Math.max(d.lookAhead,a)),d.value!=0)){let f=t;if(d.extended>-1&&(t=this.addActions(e,d.extended,d.end,t)),t=this.addActions(e,d.value,d.end,t),!u.extend&&(n=d,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new ar,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 ar,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:s}=n.p;for(let i=0;i<s.specialized.length;i++)if(s.specialized[i]==e.value){let l=s.specializers[i](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(r+1)}putAction(e,t,n,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:s}=e,{parser:i}=e.p,{data:l}=i;for(let a=0;a<2;a++)for(let c=i.stateSlot(s,a?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=En(l,c+2);else{r==0&&l[c+1]==2&&(r=this.putAction(En(l,c+2),t,n,r));break}l[c]==t&&(r=this.putAction(En(l,c+1),t,n,r))}return r}},Um;(function(o){o[o.Distance=5]="Distance",o[o.MaxRemainingPerStep=3]="MaxRemainingPerStep",o[o.MinBufferLengthPrune=500]="MinBufferLengthPrune",o[o.ForceReduceLimit=10]="ForceReduceLimit",o[o.CutDepth=15e3]="CutDepth",o[o.CutTo=9e3]="CutTo",o[o.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",o[o.MaxStackCount=12]="MaxStackCount"})(Um||(Um={}));var Rc=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,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 Mc(t,r),this.tokens=new Ic(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[cr.start(this,e.top[0],s)],this.fragments=n.length&&this.stream.end-s>e.bufferLength*4?new Dc(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[i]=e;for(;i.forceReduce()&&i.stack.length&&i.stack[i.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let i=0;i<e.length;i++){let l=e[i];for(;;){if(this.tokens.mainToken=null,l.pos>t)n.push(l);else{if(this.advanceStack(l,n,e))continue;{r||(r=[],s=[]),r.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!n.length){let i=r&&dM(r);if(i)return this.stackToTree(i);if(this.parser.strict)throw jt&&r&&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&&r){let i=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,n);if(i)return this.stackToTree(i.forceAll())}if(this.recovering){let i=this.recovering==1?1:this.recovering*3;if(n.length>i)for(n.sort((l,a)=>a.score-l.score);n.length>i;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let i=0;i<n.length-1;i++){let l=n[i];for(let a=i+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(i--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let i=1;i<n.length;i++)n[i].pos<this.minStackPos&&(this.minStackPos=n[i].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 r=e.pos,{parser:s}=this,i=jt?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>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 d=this.fragments.nodeAt(r);d;){let f=this.parser.nodeSet.types[d.type.id]==d.type?s.getGoto(e.state,d.type.id):-1;if(f>-1&&d.length&&(!c||(d.prop(re.contextHash)||0)==u))return e.useNode(d,f),jt&&console.log(i+this.stackID(e)+` (via reuse of ${s.getName(d.type.id)})`),!0;if(!(d instanceof pe)||d.children.length==0||d.positions[0]>0)break;let h=d.children[0];if(h instanceof pe&&d.positions[0]==0)d=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),jt&&console.log(i+this.stackID(e)+` (via always-reduce ${s.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++],d=a[c++],f=a[c++],h=c==a.length||!n,p=h?e:e.split();if(p.apply(u,d,f),jt&&console.log(i+this.stackID(p)+` (via ${u&65536?`reduce of ${s.getName(u&65535)}`:"shift"} for ${s.getName(d)} @ ${r}${p==e?"":", split"})`),h)return!0;p.pos>r?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 Gm(e,t),!0}}runRecovery(e,t,n){let r=null,s=!1;for(let i=0;i<e.length;i++){let l=e[i],a=t[i<<1],c=t[(i<<1)+1],u=jt?this.stackID(l)+" -> ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),jt&&console.log(u+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let d=l.split(),f=u;for(let h=0;d.forceReduce()&&h<10&&(jt&&console.log(f+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,n));h++)jt&&(f=this.stackID(d)+" -> ");for(let h of l.recoverByInsert(a))jt&&console.log(u+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,n);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),jt&&console.log(u+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Gm(l,n)):(!r||r.score<l.score)&&(r=l)}return r}stackToTree(e){return e.close(),pe.build({buffer:ur.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=(kc||(kc=new WeakMap)).get(e);return t||kc.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function Gm(o,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==o.pos&&n.sameState(o)){e[t].score<o.score&&(e[t]=o);return}}e.push(o)}var Ac=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}};var mo=class extends Kn{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]),r=[];for(let l=0;l<t.length;l++)r.push([]);function s(l,a,c){r[l].push([a,a.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=re[a]);for(let c=1;c<l.length;){let u=l[c++];if(u>=0)s(u,a,l[c++]);else{let d=l[c+-u];for(let f=-u;f>0;f--)s(l[c++],a,d);c++}}}this.nodeSet=new Tn(t.map((l,a)=>Ve.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:r[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 i=ss(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(_m),this.states=ss(e.states,Uint32Array),this.data=ss(e.stateData),this.goto=ss(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new zn(i,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 r=new Rc(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let i=r[s++],l=i&1,a=r[s++];if(l&&n)return a;for(let c=s+(i>>1);s<c;s++)if(r[s]==e)return a;if(l)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),i;;s+=3){if((i=n[s])==65535)if(n[s+1]==1)i=n[s=En(n,s+2)];else{if(n[s+1]==2)return En(n,s+2);break}if(i==t||i==0)return En(n,s+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),r=n?t(n):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=En(this.data,s+2);else break;r=t(En(this.data,s+1))}return r}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 r=this.data[n+1];t.some((s,i)=>i&1&&s==r)||t.push(this.data[n],r)}}return t}configure(e){let t=Object.assign(Object.create(mo.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 r=e.tokenizers.find(s=>s.from==n);return r?r.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let s=e.specializers.find(l=>l.from==n.external);if(!s)return n;let i=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[r]=_m(i),i})),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 s of e.split(" ")){let i=t.indexOf(s);i>=0&&(n[i]=!0)}let r=null;for(let s=0;s<t.length;s++)if(!n[s])for(let i=this.dialects[t[s]],l;(l=this.data[i++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[l]=1;return new Ac(e,n,r)}static deserialize(e){return new mo(e)}};function En(o,e){return o[e]|o[e+1]<<16}function dM(o){let e=null;for(let t of o){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 _m(o){if(o.external){let e=o.extend?1:0;return(t,n)=>o.external(t,n)<<1|e}return o.get}var is=mo.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 ls,isMultiValueFilter as fM,isSingleValueFilter as hM}from"@vuu-ui/vuu-utils";var bt,qm=class{constructor(){vt(this,bt,void 0)}setFilterCombinatorOp(e,t=_(this,bt)){ls(t)&&t.op===e||_t(this,bt,{op:e,filters:[_(this,bt)]})}add(e){if(_(this,bt)===void 0)_t(this,bt,e);else if(ls(_(this,bt)))_(this,bt).filters.push(e);else throw Error("Invalid filter passed to FilterExpression")}setColumn(e,t=_(this,bt)){if(ls(t)){let n=t.filters.at(-1);n&&this.setColumn(e,n)}else t&&(t.column=e)}setOp(e,t=_(this,bt)){if(ls(t)){let n=t.filters.at(-1);n&&this.setOp(e,n)}else t&&(t.op=e)}setValue(e,t=_(this,bt)){var n;if(ls(t)){let r=t.filters.at(-1);r&&this.setValue(e,r)}else fM(t)?((n=t.values)!=null||(t.values=[]),t.values.push(e)):hM(t)&&(t.value=e)}toJSON(e=_(this,bt)){return this.name?{...e,name:this.name}:e}};bt=new WeakMap;var __=is.configure({strict:!0});import{getRowRecord as sQ,isGroupMenuItemDescriptor as iQ,metadataKeys as mM}from"@vuu-ui/vuu-utils";import{useCallback as aQ}from"react";var{KEY:cQ}=mM;var gM=o=>o.type==="vuu-links";var bM=o=>o.type==="vuu-menu",Oc=o=>bM(o)||gM(o),Nc=o=>o.type==="vuu-link-created"||o.type==="vuu-link-removed";import{useCallback as fQ,useEffect as hQ,useState as pQ}from"react";import{getServerAPI as gQ}from"@vuu-ui/vuu-data";import{getFullRange as IQ,metadataKeys as yM,WindowRange as RQ}from"@vuu-ui/vuu-utils";import{useCallback as LQ,useEffect as OQ,useMemo as NQ,useRef as HQ,useState as FQ}from"react";var{SELECTED:BQ}=yM;import{useCallback as WQ,useRef as UQ}from"react";import{withinRange as JQ}from"@vuu-ui/vuu-utils";import{useCallback as nq,useEffect as oq,useLayoutEffect as rq,useMemo as sq,useRef as iq}from"react";function xM(o,...e){let t=new Set(o);for(let n of e)for(let r of n)t.add(r);return t}var Xm="ArrowUp",Jm="ArrowDown",Ym="ArrowLeft",Zm="ArrowRight";var eg="Home",tg="End",ng="PageUp",og="PageDown";var CM=new Set(["Enter","Delete"," "]),vM=new Set(["Tab"]),SM=new Set(["ArrowRight","ArrowLeft"]),wM=new Set([eg,tg,ng,og,Jm,Ym,Zm,Xm]),TM=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),_Q=xM(CM,wM,SM,TM,vM);import{isValidNumber as Cq}from"@vuu-ui/vuu-utils";import{useCallback as wq,useMemo as Tq,useRef as kq,useState as Eq}from"react";import{useCallback as hq,useEffect as pq,useRef as mq}from"react";var kM=new Map,EM=(o,e,t)=>{switch(t){case"height":return e.height;case"clientHeight":return o.clientHeight;case"clientWidth":return o.clientWidth;case"contentHeight":return e.contentHeight;case"contentWidth":return e.contentWidth;case"scrollHeight":return Math.ceil(o.scrollHeight);case"scrollWidth":return Math.ceil(o.scrollWidth);case"width":return e.width;default:return 0}},gq=new ResizeObserver(o=>{for(let e of o){let{target:t,borderBoxSize:n,contentBoxSize:r}=e,s=kM.get(t);if(s){let[{blockSize:i,inlineSize:l}]=n,[{blockSize:a,inlineSize:c}]=r,{onResize:u,measurements:d}=s,f=!1;for(let[h,p]of Object.entries(d)){let m=EM(t,{height:i,width:l,contentHeight:a,contentWidth:c},h);m!==p&&(f=!0,d[h]=m)}f&&u&&u(d)}}});import{deselectItem as MM,isRowSelected as PM,metadataKeys as DM,selectItem as IM}from"@vuu-ui/vuu-utils";import{useCallback as RM,useRef as rg}from"react";var{IDX:AM}=DM,LM=[],Hc=({selectionModel:o,onSelectionChange:e})=>{let t=rg(-1),n=rg(LM);return RM((s,i,l)=>{let{[AM]:a}=s,{current:c}=t,{current:u}=n,f=(PM(s)?MM:IM)(o,u,a,i,l,c);n.current=f,t.current=a,e&&e(f)},[e,o])};import{applyFilterToColumns as Oq,applyGroupByToColumns as Nq,applySortToColumns as Hq,findColumn as Fq,getCellRenderer as Bq,getColumnName as Vq,getTableHeadings as $q,getValueFormatter as Kq,isFilteredColumn as zq,isGroupColumn as Wq,isPinned as Uq,isTypeDescriptor as Gq,metadataKeys as OM,updateColumn as _q,sortPinnedColumns as Qq,stripFilterFromColumns as qq,moveItemDeprecated as jq,getDefaultAlignment as Xq}from"@vuu-ui/vuu-utils";import{useReducer as Zq}from"react";var ej=OM.count;import{useCallback as oj,useRef as rj}from"react";import{useCallback as NM,useMemo as Qi,useRef as HM}from"react";import{actualRowPositioning as FM,virtualRowPositioning as BM}from"@vuu-ui/vuu-utils";var VM=15e5,$M={contentHeight:0,contentWidth:0,getRowAtPosition:()=>-1,getRowOffset:()=>-1,horizontalScrollbarHeight:0,maxScrollContainerScrollHorizontal:0,maxScrollContainerScrollVertical:0,pinnedWidthLeft:0,pinnedWidthRight:0,rowCount:0,setPctScrollTop:()=>{},totalHeaderHeight:0,verticalScrollbarWidth:0,viewportBodyHeight:0},KM=o=>{let e=0,t=0,n=0;for(let r of o){let{hidden:s,pin:i,width:l}=r,a=s?0:l;i==="left"?e+=a:i==="right"?t+=a:n+=a}return{pinnedWidthLeft:e+4,pinnedWidthRight:t+4,unpinnedWidth:n}},Fc=({columns:o,headerHeight:e,headings:t,rowCount:n,rowHeight:r,size:s})=>{let i=HM(0),a=Math.min(n,VM)*r,u=n*r-a,{pinnedWidthLeft:d,pinnedWidthRight:f,unpinnedWidth:h}=Qi(()=>KM(o),[o]),[p,m]=Qi(()=>FM(r),[r]),[g,y]=Qi(()=>u?BM(r,u,i):[p,m],[m,p,u,r]),E=NM(v=>{i.current=v},[]);return Qi(()=>{var v;if(s){let x=t.length,C=15,b=d+h+f,S=b>s.width?C:0,M=e*(1+x),w=a-(((v=s==null?void 0:s.height)!=null?v:0)-S)+M,k=b-s.width+d,L=(s.height-e)/r,T=Number.isInteger(L)?L+1:Math.ceil(L),P=s.height-M,R=a>P?C:0;return{contentHeight:a,getRowAtPosition:y,getRowOffset:g,horizontalScrollbarHeight:S,maxScrollContainerScrollHorizontal:k,maxScrollContainerScrollVertical:w,pinnedWidthLeft:d,pinnedWidthRight:f,rowCount:T,contentWidth:b,setPctScrollTop:E,totalHeaderHeight:M,verticalScrollbarWidth:R,viewportBodyHeight:P}}else return $M},[s,t.length,d,h,f,a,e,r,y,g,E])};import{getColumnsInViewport as hj,itemsChanged as pj}from"@vuu-ui/vuu-utils";import{useCallback as bj,useEffect as yj,useMemo as xj,useRef as Cj,useState as vj}from"react";var{KEY:tX,IS_EXPANDED:nX,IS_LEAF:oX}=zM;import xX from"classnames";import{isDataLoading as wX}from"@vuu-ui/vuu-utils";import{jsx as kX,jsxs as EX}from"react/jsx-runtime";import WM from"classnames";import{isJsonAttribute as UM,metadataKeys as GM,registerComponent as _M}from"@vuu-ui/vuu-utils";import{jsx as Bc,jsxs as JM}from"react/jsx-runtime";var as="vuuJsonCell",{IS_EXPANDED:QM,KEY:qM}=GM,jM=o=>{let e=o.lastIndexOf("|");return e===-1?"":o.slice(e+1)},XM=({column:o,row:e})=>{let{key:t}=o,n=e[t],r=!1;UM(n)&&(n=n.slice(0,-1),r=!0);let s=jM(e[qM]),i=WM({[`${as}-name`]:s===n,[`${as}-value`]:s!==n,[`${as}-group`]:r});if(r){let l=e[QM]?"minus-box":"plus-box";return JM("span",{className:i,children:[Bc("span",{className:`${as}-value`,children:n}),Bc("span",{className:`${as}-toggle`,"data-icon":l})]})}else return n?Bc("span",{className:i,children:n}):null};_M("json",XM,"cell-renderer",{description:"JSON formatter",label:"JSON formatter",serverDataType:"json"});import BJ from"classnames";import{useRef as $J}from"react";import{useCallback as Vc,useRef as YM}from"react";import{jsx as e1}from"react/jsx-runtime";var sg=()=>{},ZM="vuuColumnResizerNext",cs=({onDrag:o,onDragEnd:e=sg,onDragStart:t=sg})=>{let n=YM(0),r=Vc(l=>{l.stopPropagation&&l.stopPropagation(),l.preventDefault&&l.preventDefault();let a=Math.round(l.clientX),c=a-n.current;n.current=a,c!==0&&o(l,c)},[o]),s=Vc(l=>{window.removeEventListener("mouseup",s),window.removeEventListener("mousemove",r),e(l)},[e,r]),i=Vc(l=>{t(l),n.current=Math.round(l.clientX),window.addEventListener("mouseup",s),window.addEventListener("mousemove",r),l.stopPropagation&&l.stopPropagation(),l.preventDefault&&l.preventDefault()},[t,r,s]);return e1("div",{className:ZM,onMouseDown:i})};import{useCallback as $c,useRef as t1,useState as n1}from"react";var us=({column:o,onResize:e,rootRef:t})=>{let n=t1(0),[r,s]=n1(!1),{name:i}=o,l=$c(()=>{if(console.log("onResizeStart"),e&&t.current){console.log("handleResizeStart");let{width:u}=t.current.getBoundingClientRect();n.current=Math.round(u),s(!0),e==null||e("begin",i)}},[i,e,t]),a=$c((u,d)=>{if(t.current&&e){let{width:f}=t.current.getBoundingClientRect(),h=Math.round(f)+d;h!==n.current&&h>0&&(e("resize",i,h),n.current=h)}},[i,e,t]),c=$c(()=>{e&&(e("end",i,n.current),setTimeout(()=>{s(!1)},80))},[i,e]);return{isResizing:r,onDrag:a,onDragStart:l,onDragEnd:c}};import{getColumnStyle as o1}from"@vuu-ui/vuu-utils";import r1 from"classnames";import{useMemo as s1}from"react";var Mn=(o,e,t)=>s1(()=>{let n=r1(e,{vuuPinFloating:o.pin==="floating",vuuPinLeft:o.pin==="left",vuuPinRight:o.pin==="right",vuuEndPin:t&&o.endPin,[`${e}-editable`]:o.editable,[`${e}-right`]:o.align==="right"}),r=o1(o);return{className:n,style:r}},[o,e,t]);import i1 from"classnames";import{useCallback as l1}from"react";import{jsx as a1,jsxs as c1}from"react/jsx-runtime";var ig="vuuColumnHeaderPill",go=({children:o,className:e,column:t,onRemove:n,removable:r,...s})=>{if(r&&typeof n!="function")throw Error("ColumnHeaderPill onRemove prop must be provided if Pill is removable");let i=l1(l=>{l.preventDefault(),l.stopPropagation(),n==null||n(t)},[t,n]);return c1("div",{...s,className:i1(ig,e),children:[o,r?a1("span",{className:`${ig}-removeButton`,role:"button","data-icon":"cross",onClick:i}):null]})};import{jsx as Kc,jsxs as u1}from"react/jsx-runtime";var zc=({column:o,...e})=>{let{name:t,sorted:n}=o,r=typeof n=="number"?n<0?"arrow-down":"arrow-up":n==="A"?"arrow-up":n==="D"?"arrow-down":void 0;return u1(go,{...e,column:o,children:[Kc("span",{className:"vuuGroupColumnPill-label",children:t}),r!==void 0?Kc("span",{"data-icon":r}):null,typeof n=="number"?Kc("span",{className:"vuuSortPosition",children:Math.abs(n)}):null]})};import{jsx as lg,jsxs as d1}from"react/jsx-runtime";var ag=({column:o})=>{if(!o.sorted)return null;let e=typeof o.sorted=="number"?o.sorted<0?"arrow-down":"arrow-up":o.sorted==="A"?"arrow-up":"arrow-down";return d1(go,{column:o,children:[lg("span",{"data-icon":e}),typeof o.sorted=="number"?lg("span",{className:"vuuSortPosition",children:Math.abs(o.sorted)}):null]})};import{jsx as QJ,jsxs as qJ}from"react/jsx-runtime";import{createElement as _J}from"react";import f1 from"classnames";import{useCallback as h1,useRef as p1,useState as m1}from"react";import{OverflowContainer as g1,useLayoutEffectSkipFirst as b1}from"@vuu-ui/vuu-layout";import{jsx as Uc,jsxs as C1}from"react/jsx-runtime";import{createElement as x1}from"react";var Wc="vuuTableNextGroupHeaderCell",y1=(o,e)=>o===e?o:e,qi=({column:o,className:e,onRemoveColumn:t,onResize:n,...r})=>{let s=p1(null),{isResizing:i,...l}=us({column:o,onResize:n,rootRef:s}),[a,c]=m1(o.columns),{className:u,style:d}=Mn(o,Wc,!0),f=a.length>1?{removable:!0,onRemove:t}:void 0,h=h1((p,m)=>{c(g=>{let y=g.slice(),[E]=y.splice(p,1);return m===-1?y.concat(E):(y.splice(m,0,E),y)})},[]);return b1(()=>{c(p=>y1(p,o.columns))},[o.columns]),C1("div",{...r,className:f1(u,"vuuTableNextHeaderCell",e,{[`${Wc}-pending`]:o.groupConfirmed===!1}),ref:s,role:"columnheader",style:d,children:[Uc(g1,{allowDragDrop:!0,className:`${Wc}-inner`,height:24,onMoveItem:h,overflowPosition:"start",children:a.map(p=>x1(zc,{...f,column:p,key:p.key}))}),Uc(go,{column:o,removable:!0,onRemove:t}),o.resizeable!==!1?Uc(cs,{...l}):null]})};import{useCallback as E1,useRef as M1}from"react";import v1 from"classnames";import{useCallback as cg,useRef as S1,useState as w1}from"react";import{jsx as k1}from"react/jsx-runtime";var T1=o=>{if(o){let{bottom:e,left:t}=o.getBoundingClientRect();return{x:t,y:e+6}}},ug=({className:o,column:e,...t})=>{let n=S1(null),[r,s]=w1(!1),[i]=vn(),l=cg(()=>{s(!1)},[]),a=cg(c=>{s(!0),i(c,"column-menu",{column:e,ContextMenuProps:{className:"vuuColumnMenuList",onClose:l,position:T1(n.current)}})},[e,l,i]);return k1("span",{...t,className:v1("vuuTable-columnMenu",o,{"vuuTable-columnMenu-open":r}),"data-icon":"more-vert",onClick:a,ref:n})};import P1 from"classnames";import{jsx as ji,jsxs as D1}from"react/jsx-runtime";var Gc="vuuTableNextHeaderCell",dg=({className:o,column:e,onClick:t,onResize:n,...r})=>{var m;let s=M1(null),{isResizing:i,...l}=us({column:e,onResize:n,rootRef:s}),a=E1(g=>{console.log(`click isResizing ${i}`),!i&&(t==null||t(g))},[i,t]),{className:c,style:u}=Mn(e,Gc,!0),d=ji(ug,{column:e}),f=ji("div",{className:`${Gc}-label`,children:(m=e.label)!=null?m:e.name}),h=ji(ag,{column:e}),p=e.align==="right"?[h,f,d]:[d,f,h];return D1("div",{...r,className:P1(c,o,{[`${Gc}-resizing`]:i}),onClick:a,ref:s,role:"columnheader",style:u,children:[...p,e.resizeable!==!1?ji(cs,{...l}):null]})};import{isGroupColumn as eO,metadataKeys as tO,notHidden as nO}from"@vuu-ui/vuu-utils";import gC from"classnames";import{useRef as oO}from"react";import{isGroupColumn as mg,isJsonColumn as $1,isJsonGroup as K1,metadataKeys as z1,notHidden as W1,RowSelected as U1}from"@vuu-ui/vuu-utils";import G1 from"classnames";import{memo as _1,useCallback as gg}from"react";import{metadataKeys as I1}from"@vuu-ui/vuu-utils";import{useCallback as R1}from"react";import{jsx as fg}from"react/jsx-runtime";var{IDX:A1}=I1,L1="vuuTableNextCell",hg=({column:o,columnMap:e,onDataEdited:t,row:n})=>{let{className:r,style:s}=Mn(o,L1),{CellRenderer:i,name:l,valueFormatter:a}=o,c=e[l],u=R1(d=>(t==null||t(n[A1],l,d),!0),[l,t,n]);return fg("div",{className:r,role:"cell",style:s,children:i?fg(i,{column:o,columnMap:e,onCommit:u,row:n}):a(n[c])})};import{getGroupValueAndOffset as O1,metadataKeys as N1}from"@vuu-ui/vuu-utils";import{useCallback as H1}from"react";import F1 from"classnames";import{jsx as Qc,jsxs as V1}from"react/jsx-runtime";var{IS_LEAF:B1}=N1,_c="vuuTableNextGroupCell",pg=({column:o,onClick:e,row:t})=>{let{columns:n}=o,[r,s]=O1(n,t),{className:i,style:l}=Mn(o,_c),a=H1(d=>{e==null||e(d,o)},[o,e]),c=t[B1],u=Array(s).fill(0).map((d,f)=>Qc("span",{className:`${_c}-spacer`},f));return V1("div",{className:F1(i,"vuuTableNextCell"),role:"cell",style:l,onClick:c?void 0:a,children:[u,c?null:Qc("span",{className:`${_c}-toggle`,"data-icon":"triangle-right"}),Qc("span",{children:r})]})};import{jsx as qc}from"react/jsx-runtime";import{createElement as X1}from"react";var{IDX:Q1,IS_EXPANDED:q1,SELECTED:j1}=z1,Wn="vuuTableNextRow",jc=_1(({className:o,columnMap:e,columns:t,row:n,offset:r,onClick:s,onDataEdited:i,onToggleGroup:l,zebraStripes:a=!1,...c})=>{let{[Q1]:u,[q1]:d,[j1]:f}=n,h=gg(x=>{let C=x.shiftKey,b=x.ctrlKey||x.metaKey;s==null||s(n,C,b)},[s,n]),{True:p,First:m,Last:g}=U1,y=G1(Wn,o,{[`${Wn}-even`]:a&&u%2===0,[`${Wn}-expanded`]:d,[`${Wn}-selected`]:f&p,[`${Wn}-selectedStart`]:f&m,[`${Wn}-selectedEnd`]:f&g}),E={transform:`translate3d(0px, ${r}px, 0px)`},v=gg((x,C)=>{(mg(C)||K1(C,n))&&(x.stopPropagation(),l==null||l(n,C))},[l,n]);return X1("div",{...c,"aria-rowindex":n[0],key:`row-${n[0]}`,role:"row",className:y,onClick:h,style:E},qc("span",{className:`${Wn}-selectionDecorator vuuStickyLeft`}),t.filter(W1).map(x=>{let C=mg(x),b=$1(x);return qc(C?pg:hg,{column:x,columnMap:e,onClick:C||b?v:void 0,onDataEdited:i,row:n},x.key)}),qc("span",{className:`${Wn}-selectionDecorator vuuStickyRight`}))});jc.displayName="Row";import{useLayoutEffectSkipFirst as UL}from"@vuu-ui/vuu-layout";import{registerComponent as J1}from"@vuu-ui/vuu-utils";var Y1=o=>typeof o=="string",Z1=(o,e)=>Y1(e)?e===""?!0:o.value==="lower"&&e.toLowerCase()!==e?"value must be all lowercase":o.value==="upper"&&e.toUpperCase()!==e?"value must be all uppercase":!0:"value must be a string";J1("vuu-case",Z1,"data-edit-validator",{});import{registerComponent as eP}from"@vuu-ui/vuu-utils";var tP=o=>typeof o=="string",nP="value does not match expected pattern",oP=(o,e)=>{if(typeof o.value!="string")throw Error("Pattern validation rule must provide pattern");if(tP(e)){if(e==="")return!0;{let{message:t=nP}=o;return new RegExp(o.value).test(e)||t}}else return"value must be a string"};eP("vuu-pattern",oP,"data-edit-validator",{});import{DOWN1 as cP,DOWN2 as uP,isTypeDescriptor as dP,metadataKeys as fP,registerComponent as hP,UP1 as pP,UP2 as mP}from"@vuu-ui/vuu-utils";import gP from"classnames";import{getMovingValueDirection as rP,isTypeDescriptor as sP,isValidNumber as bg}from"@vuu-ui/vuu-utils";import{useEffect as iP,useRef as lP}from"react";var aP=[void 0,void 0,void 0,void 0];function yg(o,e,t){var d;let n=lP(),[r,s,i,l]=n.current||aP,{type:a}=t,c=sP(a)?(d=a.formatting)==null?void 0:d.decimals:void 0,u=o===r&&bg(e)&&bg(s)&&t===i?rP(e,l,s,c):"";return iP(()=>{n.current=[o,e,t,u]}),u}import{jsx as SP,jsxs as wP}from"react/jsx-runtime";var bP=String.fromCharCode(11014),yP=String.fromCharCode(11015),{KEY:xP}=fP,Xi="vuuBackgroundCellDeprecated",ds={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},CP=o=>dP(o)&&o.renderer&&"flashStyle"in o.renderer?o.renderer.flashStyle:ds.BackgroundOnly,vP=({column:o,row:e})=>{let{key:t,type:n,valueFormatter:r}=o,s=e[t],i=CP(n),l=yg(e[xP],s,o),a=i===ds.ArrowOnly||i===ds.ArrowBackground?l===pP||l===mP?bP:l===cP||l===uP?yP:null:null,c=l?" "+l:"",u=gP(Xi,c,{[`${Xi}-arrowOnly`]:i===ds.ArrowOnly,[`${Xi}-arrowBackground`]:i===ds.ArrowBackground});return wP("div",{className:u,tabIndex:-1,children:[SP("div",{className:`${Xi}-flasher`,children:a}),r(e[o.key])]})};hP("background",vP,"cell-renderer",{description:"Background Cell renderer for VuuTable",label:"Background Cell (deprecated)",serverDataType:["long","int","double"]});import{isColumnTypeRenderer as TP,isTypeDescriptor as kP,isValidNumber as xg,registerComponent as EP}from"@vuu-ui/vuu-utils";import MP from"classnames";import{jsx as Xc,jsxs as Cg}from"react/jsx-runtime";var fs="vuuProgressCell",PP=({column:o,columnMap:e,row:t})=>{let{type:n}=o,r=t[o.key],s=!1,i=0;if(kP(n)&&TP(n.renderer)){let{associatedField:a}=n.renderer;if(a){let c=t[e[a]];if(typeof xg(r)&&xg(c))i=Math.min(Math.round(r/c*100),100),i=Math.min(Math.round(r/c*100),100),s=isFinite(i);else{let u=parseFloat(r);if(Number.isFinite(u)){let d=parseFloat(c);Number.isFinite(d)&&(i=Math.min(Math.round(u/d*100),100),s=isFinite(i))}}}else throw Error("ProgressCell associatedField is required to render")}let l=MP(fs,{});return Cg("div",{className:l,tabIndex:-1,children:[s?Cg("span",{className:`${fs}-track`,children:[Xc("span",{className:`${fs}-bg`}),Xc("span",{className:`${fs}-bar`,style:{"--progress-bar-pct":`-${100-i}%`}})]}):null,Xc("span",{className:`${fs}-text`,children:`${i} %`})]})};EP("vuu.progress",PP,"cell-renderer",{description:"Progress formatter",label:"Progress formatter",serverDataType:["long","int","double"]});import{DOWN1 as OP,DOWN2 as NP,isTypeDescriptor as HP,metadataKeys as FP,registerComponent as BP,UP1 as VP,UP2 as $P}from"@vuu-ui/vuu-utils";import KP from"classnames";import{getMovingValueDirection as DP,isTypeDescriptor as IP,isValidNumber as vg}from"@vuu-ui/vuu-utils";import{useEffect as RP,useRef as AP}from"react";var LP=[void 0,void 0,void 0,void 0];function Sg(o,e,t){var d;let n=AP(),[r,s,i,l]=n.current||LP,{type:a}=t,c=IP(a)?(d=a.formatting)==null?void 0:d.decimals:void 0,u=o===r&&vg(e)&&vg(s)&&t===i?DP(e,l,s,c):"";return RP(()=>{n.current=[o,e,t,u]}),u}import{jsx as QP,jsxs as qP}from"react/jsx-runtime";var zP=String.fromCharCode(11014),WP=String.fromCharCode(11015),{KEY:UP}=FP,Ji="vuuBackgroundCell",hs={ArrowOnly:"arrow",BackgroundOnly:"bg-only",ArrowBackground:"arrow-bg"},GP=o=>HP(o)&&o.renderer&&"flashStyle"in o.renderer?o.renderer.flashStyle:hs.BackgroundOnly,_P=({column:o,row:e})=>{let{key:t,type:n,valueFormatter:r}=o,s=e[t],i=GP(n),l=Sg(e[UP],s,o),a=i===hs.ArrowOnly||i===hs.ArrowBackground?l===VP||l===$P?zP:l===OP||l===NP?WP:null:null,c=l?" "+l:"",u=KP(Ji,c,{[`${Ji}-arrowOnly`]:i===hs.ArrowOnly,[`${Ji}-arrowBackground`]:i===hs.ArrowBackground});return qP("div",{className:u,tabIndex:-1,children:[QP("div",{className:`${Ji}-flasher`,children:a}),r(e[o.key])]})};console.log("register BackgroundCellNext");BP("background-next",_P,"cell-renderer",{description:"Change background color of cell when value changes",label:"Background Flash",serverDataType:["long","int","double"]});import{Checkbox as vee}from"@salt-ds/core";import{Switch as wee}from"@salt-ds/lab";import kee from"classnames";import{useCallback as Dee}from"react";import{jsx as Aee,jsxs as Lee}from"react/jsx-runtime";import{getDefaultAlignment as use,isCalculatedColumn as dse}from"@vuu-ui/vuu-utils";import{Button as hse,FormField as pse,FormFieldLabel as mse,ToggleButton as gse,ToggleButtonGroup as bse}from"@salt-ds/core";import{FormField as ste,FormFieldLabel as ite}from"@salt-ds/core";import ate from"classnames";import{useMemo as dte}from"react";import{FormField as Bee,FormFieldLabel as Vee,Input as $ee}from"@salt-ds/core";import{Switch as zee}from"@salt-ds/lab";import{getTypeSettingsFromColumn as Uee}from"@vuu-ui/vuu-utils";import{useCallback as jee,useState as Xee}from"react";import{jsx as Yee,jsxs as Zee}from"react/jsx-runtime";import{jsx as pte,jsxs as mte}from"react/jsx-runtime";import{getRegisteredCellRenderers as jP,isColumnTypeRenderer as Ste,isTypeDescriptor as wte,isValidColumnAlignment as Tte,isValidPinLocation as kte,setCalculatedColumnName as Ete,updateColumnRenderer as Mte,updateColumnType as Pte}from"@vuu-ui/vuu-utils";import{useCallback as Rte,useMemo as Ate,useRef as Lte,useState as Ote}from"react";var Nte=[{description:"Default formatter for columns with data type double",label:"Default Renderer (data type double)",name:"default-double"},...jP("double")];import{getCalculatedColumnExpression as Bre,getCalculatedColumnName as Vre,getCalculatedColumnType as $re}from"@vuu-ui/vuu-utils";import{Button as zre,FormField as Wre,FormFieldLabel as Ure,Input as Gre}from"@salt-ds/core";import{useCallback as qre,useRef as jre}from"react";var de=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 r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Lt.from(r,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),Lt.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),r=new xo(this),s=new xo(e);for(let i=t,l=t;;){if(r.next(i),s.next(i),i=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=n)return!0}}iter(e=1){return new xo(this,e)}iterRange(e,t=this.length){return new tl(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new nl(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]?de.empty:e.length<=32?new Pe(e):Lt.from(Pe.split(e,[]))}},Pe=class extends de{constructor(e,t=XP(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let i=this.text[s],l=r+i.length;if((t?n:l)>=e)return new Yc(r,l,n,i);r=l+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new Pe(wg(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let i=n.pop(),l=el(s.text,i.text.slice(),0,s.length);if(l.length<=32)n.push(new Pe(l,i.length+s.length));else{let a=l.length>>1;n.push(new Pe(l.slice(0,a)),new Pe(l.slice(a)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof Pe))return super.replace(e,t,n);let r=el(this.text,el(n.text,wg(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new Pe(r,s):Lt.from(Pe.split(r,[]),s)}sliceString(e,t=this.length,n=`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`,this;e--}else if(r instanceof Pe){let a=r.text[i+(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=r.children[i+(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 Pe?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)}},tl=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new xo(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:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.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!=""}},nl=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(de.prototype[Symbol.iterator]=function(){return this.iter()},xo.prototype[Symbol.iterator]=tl.prototype[Symbol.iterator]=nl.prototype[Symbol.iterator]=function(){return this});var Yc=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}},dr="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(o=>o?parseInt(o,36):1);for(let o=1;o<dr.length;o++)dr[o]+=dr[o-1];function JP(o){for(let e=1;e<dr.length;e+=2)if(dr[e]>o)return dr[e-1]<=o;return!1}function Tg(o){return o>=127462&&o<=127487}var kg=8205;function rt(o,e,t=!0,n=!0){return(t?Rg:YP)(o,e,n)}function Rg(o,e,t){if(e==o.length)return e;e&&Ag(o.charCodeAt(e))&&Lg(o.charCodeAt(e-1))&&e--;let n=ln(o,e);for(e+=Co(n);e<o.length;){let r=ln(o,e);if(n==kg||r==kg||t&&JP(r))e+=Co(r),n=r;else if(Tg(r)){let s=0,i=e-2;for(;i>=0&&Tg(ln(o,i));)s++,i-=2;if(s%2==0)break;e+=2}else break}return e}function YP(o,e,t){for(;e>0;){let n=Rg(o,e-2,t);if(n<e)return n;e--}return 0}function Ag(o){return o>=56320&&o<57344}function Lg(o){return o>=55296&&o<56320}function ln(o,e){let t=o.charCodeAt(e);if(!Lg(t)||e+1==o.length)return t;let n=o.charCodeAt(e+1);return Ag(n)?(t-55296<<10)+(n-56320)+65536:t}function Og(o){return o<=65535?String.fromCharCode(o):(o-=65536,String.fromCharCode((o>>10)+55296,(o&1023)+56320))}function Co(o){return o<65536?1:2}var Zc=/\r\n?|\n/,ot=function(o){return o[o.Simple=0]="Simple",o[o.TrackDel=1]="TrackDel",o[o.TrackBefore=2]="TrackBefore",o[o.TrackAfter=3]="TrackAfter",o}(ot||(ot={})),Tt=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,r=0;t<this.sections.length;){let s=this.sections[t++],i=this.sections[t++];i<0?(e(n,r,s),r+=s):r+=i,n+=s}}iterChangedRanges(e,t=!1){eu(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new Tt(e)}composeDesc(e){return this.empty?e:e.empty?this:Ng(this,e)}mapDesc(e,t=!1){return e.empty?this:tu(this,e,t)}mapPos(e,t=-1,n=ot.Simple){let r=0,s=0;for(let i=0;i<this.sections.length;){let l=this.sections[i++],a=this.sections[i++],c=r+l;if(a<0){if(c>e)return s+(e-r);s+=l}else{if(n!=ot.Simple&&c>=e&&(n==ot.TrackDel&&r<e&&c>e||n==ot.TrackBefore&&r<e||n==ot.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let s=this.sections[n++],i=this.sections[n++],l=r+s;if(i>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}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 Tt(e)}static create(e){return new Tt(e)}},De=class extends Tt{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 eu(this,(t,n,r,s,i)=>e=e.replace(r,r+(n-t),i),!1),e}mapDesc(e,t=!1){return tu(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,s=0;r<t.length;r+=2){let i=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=i;let a=r>>1;for(;n.length<a;)n.push(de.empty);n.push(i?e.slice(s,s+i):de.empty)}s+=i}return new De(t,n)}compose(e){return this.empty?e:e.empty?this:Ng(this,e,!0)}map(e,t=!1){return e.empty?this:tu(this,e,t,!0)}iterChanges(e,t=!1){eu(this,e,t)}get desc(){return Tt.create(this.sections)}filter(e){let t=[],n=[],r=[],s=new vo(this);e:for(let i=0,l=0;;){let a=i==e.length?1e9:e[i++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let u=Math.min(s.len,a-l);nt(r,u,-1);let d=s.ins==-1?-1:s.off==0?s.ins:0;nt(t,u,d),d>0&&Un(n,t,s.text),s.forward(u),l+=u}let c=e[i++];for(;l<c;){if(s.done)break e;let u=Math.min(s.len,c-l);nt(t,u,-1),nt(r,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),l+=u}}return{changes:new De(t,n),filtered:Tt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],s=[],i=0,l=null;function a(u=!1){if(!u&&!r.length)return;i<t&&nt(r,t-i,-1);let d=new De(r,s);l=l?l.compose(d.map(l)):d,r=[],s=[],i=0}function c(u){if(Array.isArray(u))for(let d of u)c(d);else if(u instanceof De){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:d,to:f=d,insert:h}=u;if(d>f||d<0||f>t)throw new RangeError(`Invalid change range ${d} to ${f} (in doc of length ${t})`);let p=h?typeof h=="string"?de.of(h.split(n||Zc)):h:de.empty,m=p.length;if(d==f&&m==0)return;d<i&&a(),d>i&&nt(r,d-i,-1),nt(r,f-d,m),Un(s,r,p),i=f}}return c(e),a(!l),l}static empty(e){return new De(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((i,l)=>l&&typeof i!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length<r;)n.push(de.empty);n[r]=de.of(s.slice(1)),t.push(s[0],n[r].length)}}}return new De(t,n)}static createSet(e,t){return new De(e,t)}};function nt(o,e,t,n=!1){if(e==0&&t<=0)return;let r=o.length-2;r>=0&&t<=0&&t==o[r+1]?o[r]+=e:e==0&&o[r]==0?o[r+1]+=t:n?(o[r]+=e,o[r+1]+=t):o.push(e,t)}function Un(o,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<o.length)o[o.length-1]=o[o.length-1].append(t);else{for(;o.length<n;)o.push(de.empty);o.push(t)}}function eu(o,e,t){let n=o.inserted;for(let r=0,s=0,i=0;i<o.sections.length;){let l=o.sections[i++],a=o.sections[i++];if(a<0)r+=l,s+=l;else{let c=r,u=s,d=de.empty;for(;c+=l,u+=a,a&&n&&(d=d.append(n[i-2>>1])),!(t||i==o.sections.length||o.sections[i+1]<0);)l=o.sections[i++],a=o.sections[i++];e(r,c,s,u,d),r=c,s=u}}}function tu(o,e,t,n=!1){let r=[],s=n?[]:null,i=new vo(o),l=new vo(e);for(let a=-1;;)if(i.ins==-1&&l.ins==-1){let c=Math.min(i.len,l.len);nt(r,c,-1),i.forward(c),l.forward(c)}else if(l.ins>=0&&(i.ins<0||a==i.i||i.off==0&&(l.len<i.len||l.len==i.len&&!t))){let c=l.len;for(nt(r,l.ins,-1);c;){let u=Math.min(i.len,c);i.ins>=0&&a<i.i&&i.len<=u&&(nt(r,0,i.ins),s&&Un(s,r,i.text),a=i.i),i.forward(u),c-=u}l.next()}else if(i.ins>=0){let c=0,u=i.len;for(;u;)if(l.ins==-1){let d=Math.min(u,l.len);c+=d,u-=d,l.forward(d)}else if(l.ins==0&&l.len<u)u-=l.len,l.next();else break;nt(r,c,a<i.i?i.ins:0),s&&a<i.i&&Un(s,r,i.text),a=i.i,i.forward(i.len-u)}else{if(i.done&&l.done)return s?De.createSet(r,s):Tt.create(r);throw new Error("Mismatched change set lengths")}}function Ng(o,e,t=!1){let n=[],r=t?[]:null,s=new vo(o),i=new vo(e);for(let l=!1;;){if(s.done&&i.done)return r?De.createSet(n,r):Tt.create(n);if(s.ins==0)nt(n,s.len,0,l),s.next();else if(i.len==0&&!i.done)nt(n,0,i.ins,l),r&&Un(r,n,i.text),i.next();else{if(s.done||i.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,i.len),c=n.length;if(s.ins==-1){let u=i.ins==-1?-1:i.off?0:i.ins;nt(n,a,u,l),r&&u&&Un(r,n,i.text)}else i.ins==-1?(nt(n,s.off?0:s.len,a,l),r&&Un(r,n,s.textBit(a))):(nt(n,s.off?0:s.len,i.off?0:i.ins,l),r&&!i.off&&Un(r,n,i.text));l=(s.ins>a||i.ins>=0&&i.len>a)&&(l||n.length>c),s.forward2(a),i.forward(a)}}}}var vo=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?de.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?de.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)}},Pn=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,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new Pn(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return B.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return B.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 B.range(e.anchor,e.head)}static create(e,t,n){return new Pn(e,t,n)}},B=class{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:B.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 B([this.main],0)}addRange(e,t=!0){return B.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,B.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 B(e.ranges.map(t=>Pn.fromJSON(t)),e.main)}static single(e,t=e){return new B([B.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,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=n:s.from<n)return B.normalized(e.slice(),t);n=s.to}return new B(e,t)}static cursor(e,t=0,n,r){return Pn.create(e,e,(t==0?0:t<0?4:8)|(n==null?3:Math.min(2,n))|(r!=null?r:33554431)<<5)}static range(e,t,n,r){let s=(n!=null?n:33554431)<<5|(r==null?3:Math.min(2,r));return t<e?Pn.create(t,e,24|s):Pn.create(e,t,(t>e?4:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(n);for(let r=1;r<e.length;r++){let s=e[r],i=e[r-1];if(s.empty?s.from<=i.to:s.from<i.to){let l=i.from,a=Math.max(s.to,i.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?B.range(a,l):B.range(l,a))}}return new B(e,t)}};function Hg(o,e){for(let t of o.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var au=0,oe=class{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=au++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}static define(e={}){return new oe(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:cu),!!e.static,e.enables)}of(e){return new fr([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new fr(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new fr(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}};function cu(o,e){return o==e||o.length==e.length&&o.every((t,n)=>t===e[n])}var fr=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=au++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,i=e[s]>>1,l=this.type==2,a=!1,c=!1,u=[];for(let d of this.dependencies)d=="doc"?a=!0:d=="selection"?c=!0:((t=e[d.id])!==null&&t!==void 0?t:1)&1||u.push(e[d.id]);return{create(d){return d.values[i]=n(d),1},update(d,f){if(a&&f.docChanged||c&&(f.docChanged||f.selection)||nu(d,u)){let h=n(d);if(l?!Eg(h,d.values[i],r):!r(h,d.values[i]))return d.values[i]=h,1}return 0},reconfigure:(d,f)=>{let h,p=f.config.address[s];if(p!=null){let m=rl(f,p);if(this.dependencies.every(g=>g instanceof oe?f.facet(g)===d.facet(g):g instanceof dt?f.field(g,!1)==d.field(g,!1):!0)||(l?Eg(h=n(d),m,r):r(h=n(d),m)))return d.values[i]=m,0}else h=n(d);return d.values[i]=h,1}}}};function Eg(o,e,t){if(o.length!=e.length)return!1;for(let n=0;n<o.length;n++)if(!t(o[n],e[n]))return!1;return!0}function nu(o,e){let t=!1;for(let n of e)ms(o,n)&1&&(t=!0);return t}function ZP(o,e,t){let n=t.map(a=>o[a.id]),r=t.map(a=>a.type),s=n.filter(a=>!(a&1)),i=o[e.id]>>1;function l(a){let c=[];for(let u=0;u<n.length;u++){let d=rl(a,n[u]);if(r[u]==2)for(let f of d)c.push(f);else c.push(d)}return e.combine(c)}return{create(a){for(let c of n)ms(a,c);return a.values[i]=l(a),1},update(a,c){if(!nu(a,s))return 0;let u=l(a);return e.compare(u,a.values[i])?0:(a.values[i]=u,1)},reconfigure(a,c){let u=nu(a,n),d=c.config.facets[e.id],f=c.facet(e);if(d&&!u&&cu(t,d))return a.values[i]=f,0;let h=l(a);return e.compare(h,f)?(a.values[i]=f,0):(a.values[i]=h,1)}}}var Mg=oe.define({static:!0}),dt=class{constructor(e,t,n,r,s){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new dt(au++,e.create,e.update,e.compare||((n,r)=>n===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Mg).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,r)=>{let s=n.values[t],i=this.updateF(s,r);return this.compareF(s,i)?0:(n.values[t]=i,1)},reconfigure:(n,r)=>r.config.address[this.id]!=null?(n.values[t]=r.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,Mg.of({field:this,create:e})]}get extension(){return this}},bo={lowest:4,low:3,default:2,high:1,highest:0};function ps(o){return e=>new ol(e,o)}var To={highest:ps(bo.highest),high:ps(bo.high),default:ps(bo.default),low:ps(bo.low),lowest:ps(bo.lowest)},ol=class{constructor(e,t){this.inner=e,this.prec=t}},pr=class{of(e){return new gs(this,e)}reconfigure(e){return pr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},gs=class{constructor(e,t){this.compartment=e,this.inner=t}},mr=class{constructor(e,t,n,r,s,i){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=i,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 r=[],s=Object.create(null),i=new Map;for(let f of eD(e,t,i))f instanceof dt?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],c=[];for(let f of r)l[f.id]=c.length<<1,c.push(h=>f.slot(h));let u=n==null?void 0:n.config.facets;for(let f in s){let h=s[f],p=h[0].facet,m=u&&u[f]||[];if(h.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,cu(m,h))a.push(n.facet(p));else{let g=p.combine(h.map(y=>y.value));a.push(n&&p.compare(g,n.facet(p))?n.facet(p):g)}else{for(let g of h)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=>ZP(g,p,h))}}let d=c.map(f=>f(l));return new mr(e,i,d,l,a,s)}};function eD(o,e,t){let n=[[],[],[],[],[]],r=new Map;function s(i,l){let a=r.get(i);if(a!=null){if(a<=l)return;let c=n[a].indexOf(i);c>-1&&n[a].splice(c,1),i instanceof gs&&t.delete(i.compartment)}if(r.set(i,l),Array.isArray(i))for(let c of i)s(c,l);else if(i instanceof gs){if(t.has(i.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(i.compartment)||i.inner;t.set(i.compartment,c),s(c,l)}else if(i instanceof ol)s(i.inner,i.prec);else if(i instanceof dt)n[l].push(i),i.provides&&s(i.provides,l);else if(i instanceof fr)n[l].push(i),i.facet.extensions&&s(i.facet.extensions,bo.default);else{let c=i.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${i}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,l)}}return s(o,bo.default),n.reduce((i,l)=>i.concat(l))}function ms(o,e){if(e&1)return 2;let t=e>>1,n=o.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;o.status[t]=4;let r=o.computeSlot(o,o.config.dynamicSlots[t]);return o.status[t]=2|r}function rl(o,e){return e&1?o.config.staticValues[e>>1]:o.values[e>>1]}var Fg=oe.define(),Bg=oe.define({combine:o=>o.some(e=>e),static:!0}),Vg=oe.define({combine:o=>o.length?o[0]:void 0,static:!0}),$g=oe.define(),Kg=oe.define(),zg=oe.define(),Wg=oe.define({combine:o=>o.length?o[0]:!1}),kt=class{constructor(e,t){this.type=e,this.value=t}static define(){return new bs}},bs=class{of(e){return new kt(this,e)}},ou=class{constructor(e){this.map=e}of(e){return new we(this,e)}},we=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 we(this.type,t)}is(e){return this.type==e}static define(e={}){return new ou(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(t);s&&n.push(s)}return n}};we.reconfigure=we.define();we.appendConfig=we.define();var Ie=class{constructor(e,t,n,r,s,i){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=i,this._doc=null,this._state=null,n&&Hg(n,t.newLength),s.some(l=>l.type==Ie.time)||(this.annotations=s.concat(Ie.time.of(Date.now())))}static create(e,t,n,r,s,i){return new Ie(e,t,n,r,s,i)}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(Ie.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};Ie.time=kt.define();Ie.userEvent=kt.define();Ie.addToHistory=kt.define();Ie.remote=kt.define();function tD(o,e){let t=[];for(let n=0,r=0;;){let s,i;if(n<o.length&&(r==e.length||e[r]>=o[n]))s=o[n++],i=o[n++];else if(r<e.length)s=e[r++],i=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,i):t[t.length-1]<i&&(t[t.length-1]=i)}}function Ug(o,e,t){var n;let r,s,i;return t?(r=e.changes,s=De.empty(e.changes.length),i=o.changes.compose(e.changes)):(r=e.changes.map(o.changes),s=o.changes.mapDesc(e.changes,!0),i=o.changes.compose(r)),{changes:i,selection:e.selection?e.selection.map(s):(n=o.selection)===null||n===void 0?void 0:n.map(r),effects:we.mapEffects(o.effects,r).concat(we.mapEffects(e.effects,s)),annotations:o.annotations.length?o.annotations.concat(e.annotations):e.annotations,scrollIntoView:o.scrollIntoView||e.scrollIntoView}}function ru(o,e,t){let n=e.selection,r=hr(e.annotations);return e.userEvent&&(r=r.concat(Ie.userEvent.of(e.userEvent))),{changes:e.changes instanceof De?e.changes:De.of(e.changes||[],t,o.facet(Vg)),selection:n&&(n instanceof B?n:B.single(n.anchor,n.head)),effects:hr(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Gg(o,e,t){let n=ru(o,e.length?e[0]:{},o.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let i=!!e[s].sequential;n=Ug(n,ru(o,e[s],i?n.changes.newLength:o.doc.length),i)}let r=Ie.create(o,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return oD(t?nD(r):r)}function nD(o){let e=o.startState,t=!0;for(let r of e.facet($g)){let s=r(o);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:tD(t,s))}if(t!==!0){let r,s;if(t===!1)s=o.changes.invertedDesc,r=De.empty(e.doc.length);else{let i=o.changes.filter(t);r=i.changes,s=i.filtered.mapDesc(i.changes).invertedDesc}o=Ie.create(e,r,o.selection&&o.selection.map(s),we.mapEffects(o.effects,s),o.annotations,o.scrollIntoView)}let n=e.facet(Kg);for(let r=n.length-1;r>=0;r--){let s=n[r](o);s instanceof Ie?o=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Ie?o=s[0]:o=Gg(e,hr(s),!1)}return o}function oD(o){let e=o.startState,t=e.facet(zg),n=o;for(let r=t.length-1;r>=0;r--){let s=t[r](o);s&&Object.keys(s).length&&(n=Ug(n,ru(e,s,o.changes.newLength),!0))}return n==o?o:Ie.create(e,o.changes,o.selection,n.effects,n.annotations,n.scrollIntoView)}var rD=[];function hr(o){return o==null?rD:Array.isArray(o)?o:[o]}var ut=function(o){return o[o.Word=0]="Word",o[o.Space=1]="Space",o[o.Other=2]="Other",o}(ut||(ut={})),sD=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,su;try{su=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function iD(o){if(su)return su.test(o);for(let e=0;e<o.length;e++){let t=o[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||sD.test(t)))return!0}return!1}function lD(o){return e=>{if(!/\S/.test(e))return ut.Space;if(iD(e))return ut.Word;for(let t=0;t<o.length;t++)if(e.indexOf(o[t])>-1)return ut.Word;return ut.Other}}var he=class{constructor(e,t,n,r,s,i){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,i&&(i._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)ms(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 ms(this,n),rl(this,n)}update(...e){return Gg(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:r}=t;for(let i of e.effects)i.is(pr.reconfigure)?(t&&(r=new Map,t.compartments.forEach((l,a)=>r.set(a,l)),t=null),r.set(i.value.compartment,i.value.extension)):i.is(we.reconfigure)?(t=null,n=i.value):i.is(we.appendConfig)&&(t=null,n=hr(n).concat(i.value));let s;t?s=e.startState.values.slice():(t=mr.resolve(n,r,this),s=new he(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,a)=>a.reconfigure(l,this),null).values),new he(t,e.newDoc,e.newSelection,s,(i,l)=>l.update(i,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:B.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),s=[n.range],i=hr(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(r);for(let f=0;f<l;f++)s[f]=s[f].map(u);let d=r.mapDesc(c,!0);s.push(a.range.map(d)),r=r.compose(u),i=we.mapEffects(i,u).concat(we.mapEffects(hr(a.effects),d))}return{changes:r,selection:B.create(s,t.mainIndex),effects:i}}changes(e=[]){return e instanceof De?e:De.of(e,this.doc.length,this.facet(he.lineSeparator))}toText(e){return de.of(e.split(this.facet(he.lineSeparator)||Zc))}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:(ms(this,t),rl(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof dt&&this.config.address[r.id]!=null&&(t[n]=r.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 r=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let i=n[s],l=e[s];r.push(i.init(a=>i.spec.fromJSON(l,a)))}}return he.create({doc:e.doc,selection:B.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=mr.resolve(e.extensions||[],new Map),n=e.doc instanceof de?e.doc:de.of((e.doc||"").split(t.staticFacet(he.lineSeparator)||Zc)),r=e.selection?e.selection instanceof B?e.selection:B.single(e.selection.anchor,e.selection.head):B.single(0);return Hg(r,n.length),t.staticFacet(Bg)||(r=r.asSingle()),new he(t,n,r,t.dynamicSlots.map(()=>null),(s,i)=>i.create(s),null)}get tabSize(){return this.facet(he.tabSize)}get lineBreak(){return this.facet(he.lineSeparator)||`
|
|
7
|
-
`}get readOnly(){return this.facet(Wg)}phrase(e,...t){for(let n of this.facet(he.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet(Fg))for(let i of s(this,t,n))Object.prototype.hasOwnProperty.call(i,e)&&r.push(i[e]);return r}charCategorizer(e){return lD(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),i=e-n,l=e-n;for(;i>0;){let a=rt(t,i,!1);if(s(t.slice(a,i))!=ut.Word)break;i=a}for(;l<r;){let a=rt(t,l);if(s(t.slice(l,a))!=ut.Word)break;l=a}return i==l?null:B.range(i+n,l+n)}};he.allowMultipleSelections=Bg;he.tabSize=oe.define({combine:o=>o.length?o[0]:4});he.lineSeparator=Vg;he.readOnly=Wg;he.phrases=oe.define({compare(o,e){let t=Object.keys(o),n=Object.keys(e);return t.length==n.length&&t.every(r=>o[r]==e[r])}});he.languageData=Fg;he.changeFilter=$g;he.transactionFilter=Kg;he.transactionExtender=zg;pr.reconfigure=we.define();function ko(o,e,t={}){let n={};for(let r of o)for(let s of Object.keys(r)){let i=r[s],l=n[s];if(l===void 0)n[s]=i;else if(!(l===i||i===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](l,i);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}var Xt=class{eq(e){return this==e}range(e,t=e){return So.create(e,t,this)}};Xt.prototype.startSide=Xt.prototype.endSide=0;Xt.prototype.point=!1;Xt.prototype.mapMode=ot.TrackDel;var So=class{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new So(e,t,n)}};function iu(o,e){return o.from-e.from||o.value.startSide-e.value.startSide}var ys=class{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let i=r,l=s.length;;){if(i==l)return i;let a=i+l>>1,c=s[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==i)return c>=0?i:l;c>=0?l=a:i=a+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),i=this.findIndex(n,1e9,!1,s);s<i;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let n=[],r=[],s=[],i=-1,l=-1;for(let a=0;a<this.value.length;a++){let c=this.value[a],u=this.from[a]+e,d=this.to[a]+e,f,h;if(u==d){let p=t.mapPos(u,c.startSide,c.mapMode);if(p==null||(f=h=p,c.startSide!=c.endSide&&(h=t.mapPos(u,c.endSide),h<f)))continue}else if(f=t.mapPos(u,c.startSide),h=t.mapPos(d,c.endSide),f>h||f==h&&c.startSide>0&&c.endSide<=0)continue;(h-f||c.endSide-c.startSide)<0||(i<0&&(i=f),c.point&&(l=Math.max(l,h-f)),n.push(c),r.push(f-i),s.push(h-i))}return{mapped:n.length?new ys(r,s,n,l):null,pos:i}}},xe=class{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new xe(e,t,n,r)}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:r=0,filterTo:s=this.length}=e,i=e.filter;if(t.length==0&&!i)return this;if(n&&(t=t.slice().sort(iu)),this.isEmpty)return t.length?xe.of(t):this;let l=new sl(this,null,-1).goto(0),a=0,c=[],u=new an;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let d=t[a++];u.addInner(d.from,d.to,d.value)||c.push(d)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!i||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&u.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!i||r>l.to||s<l.from||i(l.from,l.to,l.value))&&(u.addInner(l.from,l.to,l.value)||c.push(So.create(l.from,l.to,l.value))),l.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?xe.empty:this.nextLayer.update({add:c,filter:i,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let i=0;i<this.chunk.length;i++){let l=this.chunkPos[i],a=this.chunk[i],c=e.touchesRange(l,l+a.length);if(c===!1)r=Math.max(r,a.maxPoint),t.push(a),n.push(e.mapPos(l));else if(c===!0){let{mapped:u,pos:d}=a.map(l,e);u&&(r=Math.max(r,u.maxPoint),t.push(u),n.push(d))}}let s=this.nextLayer.map(e);return t.length==0?s:new xe(n,t,s||xe.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],i=this.chunk[r];if(t>=s&&e<=s+i.length&&i.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return wo.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return wo.from(e).goto(t)}static compare(e,t,n,r,s=-1){let i=e.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=s),l=t.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=s),a=Pg(i,l,n),c=new yo(i,a,s),u=new yo(l,a,s);n.iterGaps((d,f,h)=>Dg(c,d,u,f,h,r)),n.empty&&n.length==0&&Dg(c,0,u,0,0,r)}static eq(e,t,n=0,r){r==null&&(r=1e9-1);let s=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),i=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(s.length!=i.length)return!1;if(!s.length)return!0;let l=Pg(s,i),a=new yo(s,l,0).goto(n),c=new yo(i,l,0).goto(n);for(;;){if(a.to!=c.to||!lu(a.active,c.active)||a.point&&(!c.point||!a.point.eq(c.point)))return!1;if(a.to>r)return!0;a.next(),c.next()}}static spans(e,t,n,r,s=-1){let i=new yo(e,null,s).goto(t),l=t,a=i.openStart;for(;;){let c=Math.min(i.to,n);if(i.point){let u=i.activeForPoint(i.to),d=i.pointFrom<t?u.length+1:Math.min(u.length,a);r.point(l,c,i.point,u,d,i.pointRank),a=Math.min(i.openEnd(c),u.length)}else c>l&&(r.span(l,c,i.active,a),a=i.openEnd(c));if(i.to>n)return a+(i.point&&i.to>n?1:0);l=i.to,i.next()}}static of(e,t=!1){let n=new an;for(let r of e instanceof So?[e]:t?aD(e):e)n.add(r.from,r.to,r.value);return n.finish()}};xe.empty=new xe([],[],null,-1);function aD(o){if(o.length>1)for(let e=o[0],t=1;t<o.length;t++){let n=o[t];if(iu(e,n)>0)return o.slice().sort(iu);e=n}return o}xe.empty.nextLayer=xe.empty;var an=class{finishChunk(e){this.chunks.push(new ys(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 an)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<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(xe.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=xe.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Pg(o,e,t){let n=new Map;for(let s of o)for(let i=0;i<s.chunk.length;i++)s.chunk[i].maxPoint<=0&&n.set(s.chunk[i],s.chunkPos[i]);let r=new Set;for(let s of e)for(let i=0;i<s.chunk.length;i++){let l=n.get(s.chunk[i]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[i]&&!(t!=null&&t.touchesRange(l,l+s.chunk[i].length))&&r.add(s.chunk[i])}return r}var sl=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}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 r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}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}},wo=class{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let s=0;s<e.length;s++)for(let i=e[s];!i.isEmpty;i=i.nextLayer)i.maxPoint>=n&&r.push(new sl(i,t,n,s));return r.length==1?r[0]:new wo(r)}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--)Jc(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--)Jc(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(),Jc(this.heap,0)}}};function Jc(o,e){for(let t=o[e];;){let n=(e<<1)+1;if(n>=o.length)break;let r=o[n];if(n+1<o.length&&r.compare(o[n+1])>=0&&(r=o[n+1],n++),t.compare(r)<0)break;o[n]=t,o[e]=r,e=n}}var yo=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=wo.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){Yi(this.active,e),Yi(this.activeTo,e),Yi(this.activeRank,e),this.minActive=Ig(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&this.activeRank[t]<=s;)t++;Zi(this.active,t,n),Zi(this.activeTo,t,r),Zi(this.activeRank,t,s),e&&Zi(e,t,this.cursor.from),this.minActive=Ig(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Yi(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.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=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.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 r=n.length-1;r>=0&&n[r]<e;r--)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 Dg(o,e,t,n,r,s){o.goto(e),t.goto(n);let i=n+r,l=n,a=n-e;for(;;){let c=o.to+a-t.to||o.endSide-t.endSide,u=c<0?o.to+a:t.to,d=Math.min(u,i);if(o.point||t.point?o.point&&t.point&&(o.point==t.point||o.point.eq(t.point))&&lu(o.activeForPoint(o.to),t.activeForPoint(t.to))||s.comparePoint(l,d,o.point,t.point):d>l&&!lu(o.active,t.active)&&s.compareRange(l,d,o.active,t.active),u>i)break;l=u,c<=0&&o.next(),c>=0&&t.next()}}function lu(o,e){if(o.length!=e.length)return!1;for(let t=0;t<o.length;t++)if(o[t]!=e[t]&&!o[t].eq(e[t]))return!1;return!0}function Yi(o,e){for(let t=e,n=o.length-1;t<n;t++)o[t]=o[t+1];o.pop()}function Zi(o,e,t){for(let n=o.length-1;n>=e;n--)o[n+1]=o[n];o[e]=t}function Ig(o,e){let t=-1,n=1e9;for(let r=0;r<e.length;r++)(e[r]-n||o[r].endSide-o[t].endSide)<0&&(t=r,n=e[r]);return t}function Eo(o,e,t=o.length){let n=0;for(let r=0;r<t;)o.charCodeAt(r)==9?(n+=e-n%e,r++):(n++,r=rt(o,r));return n}function _g(o,e,t,n){for(let r=0,s=0;;){if(s>=e)return r;if(r==o.length)break;s+=o.charCodeAt(r)==9?t-s%t:1,r=rt(o,r)}return n===!0?-1:o.length}var uu="\u037C",Qg=typeof Symbol>"u"?"__"+uu:Symbol.for(uu),du=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),qg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Ot=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(i){return/^@/.test(i)?[i]:i.split(/,\s*/)}function s(i,l,a,c){let u=[],d=/^@(\w+)\b/.exec(i[0]),f=d&&d[1]=="keyframes";if(d&&l==null)return a.push(i[0]+";");for(let h in l){let p=l[h];if(/&/.test(h))s(h.split(/,\s*/).map(m=>i.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!d)throw new RangeError("The value of a property ("+h+") should be a primitive value.");s(r(h),p,u,f)}else p!=null&&u.push(h.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(u.length||f)&&a.push((n&&!d&&!c?i.map(n):i).join(", ")+" {"+u.join(" ")+"}")}for(let i in e)s(r(i),e[i],this.rules)}getRules(){return this.rules.join(`
|
|
8
|
-
|
|
9
|
-
`;this.styleTag.textContent=s}}};var Dn={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:'"'},cD=typeof navigator<"u"&&/Mac/.test(navigator.platform),uD=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for($e=0;$e<10;$e++)Dn[48+$e]=Dn[96+$e]=String($e);var $e;for($e=1;$e<=24;$e++)Dn[$e+111]="F"+$e;var $e;for($e=65;$e<=90;$e++)Dn[$e]=String.fromCharCode($e+32),gr[$e]=String.fromCharCode($e);var $e;for(il in Dn)gr.hasOwnProperty(il)||(gr[il]=Dn[il]);var il;function Xg(o){var e=cD&&o.metaKey&&o.shiftKey&&!o.ctrlKey&&!o.altKey||uD&&o.shiftKey&&o.key&&o.key.length==1||o.key=="Unidentified",t=!e&&o.key||(o.shiftKey?gr:Dn)[o.keyCode]||o.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 xl(o){let e;return o.nodeType==11?e=o.getSelection?o:o.ownerDocument:e=o,e.getSelection()}function yu(o,e){return e?o==e||o.contains(e.nodeType!=1?e.parentNode:e):!1}function dD(o){let e=o.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function pl(o,e){if(!e.anchorNode)return!1;try{return yu(o,e.anchorNode)}catch{return!1}}function Ts(o){return o.nodeType==3?Po(o,0,o.nodeValue.length).getClientRects():o.nodeType==1?o.getClientRects():[]}function Cl(o,e,t,n){return t?Jg(o,e,t,n,-1)||Jg(o,e,t,n,1):!1}function vl(o){for(var e=0;;e++)if(o=o.previousSibling,!o)return e}function Jg(o,e,t,n,r){for(;;){if(o==t&&e==n)return!0;if(e==(r<0?0:Qn(o))){if(o.nodeName=="DIV")return!1;let s=o.parentNode;if(!s||s.nodeType!=1)return!1;e=vl(o)+(r<0?0:1),o=s}else if(o.nodeType==1){if(o=o.childNodes[e+(r<0?-1:0)],o.nodeType==1&&o.contentEditable=="false")return!1;e=r<0?Qn(o):0}else return!1}}function Qn(o){return o.nodeType==3?o.nodeValue.length:o.childNodes.length}function Yu(o,e){let t=e?o.left:o.right;return{left:t,right:t,top:o.top,bottom:o.bottom}}function fD(o){return{left:0,right:o.innerWidth,top:0,bottom:o.innerHeight}}function hD(o,e,t,n,r,s,i,l){let a=o.ownerDocument,c=a.defaultView||window;for(let u=o,d=!1;u&&!d;)if(u.nodeType==1){let f,h=u==a.body;if(h)f=fD(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!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(r=="nearest")e.top<f.top?(m=-(f.top-e.top+i),t>0&&e.bottom>f.bottom+m&&(m=e.bottom-f.bottom+m+i)):e.bottom>f.bottom&&(m=e.bottom-f.bottom+i,t<0&&e.top-m<f.top&&(m=-(f.top+m-e.top+i)));else{let g=e.bottom-e.top,y=f.bottom-f.top;m=(r=="center"&&g<=y?e.top+g/2-y/2:r=="start"||r=="center"&&t<0?e.top-i:e.bottom-y+i)-f.top}if(n=="nearest"?e.left<f.left?(p=-(f.left-e.left+s),t>0&&e.right>f.right+p&&(p=e.right-f.right+p+s)):e.right>f.right&&(p=e.right-f.right+s,t<0&&e.left<f.left+p&&(p=-(f.left+p-e.left+s))):p=(n=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:n=="start"==l?e.left-s:e.right-(f.right-f.left)+s)-f.left,p||m)if(h)c.scrollBy(p,m);else{let g=0,y=0;if(m){let E=u.scrollTop;u.scrollTop+=m,y=u.scrollTop-E}if(p){let E=u.scrollLeft;u.scrollLeft+=p,g=u.scrollLeft-E}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&&(r="nearest")}if(h)break;u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function pD(o){let e=o.ownerDocument;for(let t=o.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 xu=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?Qn(t):0),n,Math.min(e.focusOffset,n?Qn(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},br=null;function Ib(o){if(o.setActive)return o.setActive();if(br)return o.focus(br);let e=[];for(let t=o;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(o.focus(br==null?{get preventScroll(){return br={preventScroll:!0},!0}}:void 0),!br){br=!1;for(let t=0;t<e.length;){let n=e[t++],r=e[t++],s=e[t++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=s&&(n.scrollLeft=s)}}}var Yg;function Po(o,e,t=e){let n=Yg||(Yg=document.createRange());return n.setEnd(o,t),n.setStart(o,e),n}function Cr(o,e,t){let n={key:e,code:e,keyCode:t,which:t,cancelable:!0},r=new KeyboardEvent("keydown",n);r.synthetic=!0,o.dispatchEvent(r);let s=new KeyboardEvent("keyup",n);return s.synthetic=!0,o.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function mD(o){for(;o;){if(o&&(o.nodeType==9||o.nodeType==11&&o.host))return o;o=o.assignedSlot||o.parentNode}return null}function Rb(o){for(;o.attributes.length;)o.removeAttributeNode(o.attributes[0])}function gD(o,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,Qn(t));;)if(n){if(t.nodeType!=1)return!1;let r=t.childNodes[n-1];r.contentEditable=="false"?n--:(t=r,n=Qn(t))}else{if(t==o)return!0;n=vl(t),t=t.parentNode}}function Ab(o){return o.scrollTop>Math.max(1,o.scrollHeight-o.clientHeight-4)}var Ye=class{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Ye(e.parentNode,vl(e),t)}static after(e,t){return new Ye(e.parentNode,vl(e)+1,t)}},Zu=[],be=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,r=null,s;for(let i of this.children){if(i.flags&7){if(!i.dom&&(s=r?r.nextSibling:n.firstChild)){let l=be.get(s);(!l||!l.parent&&l.canReuseDOM(i))&&i.reuseDOM(s)}i.sync(e,t),i.flags&=-8}if(s=r?r.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&s!=i.dom&&(t.written=!0),i.dom.parentNode==n)for(;s&&s!=i.dom;)s=Zg(s);else n.insertBefore(i.dom,s);r=i.dom}for(s=r?r.nextSibling:n.firstChild,s&&t&&t.node==n&&(t.written=!0);s;)s=Zg(s)}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 r=Qn(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!be.get(n);)n=n.nextSibling;if(!n)return this.length;for(let r=0,s=0;;r++){let i=this.children[r];if(i.dom==n)return s;s+=i.length+i.breakAfter}}domBoundsAround(e,t,n=0){let r=-1,s=-1,i=-1,l=-1;for(let a=0,c=n,u=n;a<this.children.length;a++){let d=this.children[a],f=c+d.length;if(c<e&&f>t)return d.domBoundsAround(e,t,c);if(f>=e&&r==-1&&(r=a,s=c),c>t&&d.dom.parentNode==this.dom){i=a,l=u;break}u=f,c=f+d.breakAfter}return{from:s,to:l<0?n+this.length:l,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:i<this.children.length&&i>=0?this.children[i].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=Zu){this.markDirty();for(let r=e;r<t;r++){let s=this.children[r];s.parent==this&&s.destroy()}this.children.splice(e,t-e,...n);for(let r=0;r<n.length;r++)n[r].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Sl(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,r,s,i){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}};be.prototype.breakAfter=0;function Zg(o){let e=o.nextSibling;return o.parentNode.removeChild(o),e}var Sl=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 Lb(o,e,t,n,r,s,i,l,a){let{children:c}=o,u=c.length?c[e]:null,d=s.length?s[s.length-1]:null,f=d?d.breakAfter:i;if(!(e==n&&u&&!i&&!f&&s.length<2&&u.merge(t,r,s.length?d:null,t==0,l,a))){if(n<c.length){let h=c[n];h&&r<h.length?(e==n&&(h=h.split(r),r=0),!f&&d&&h.merge(0,r,d,!0,0,a)?s[s.length-1]=h:(r&&h.merge(0,r,null,!1,0,a),s.push(h))):h!=null&&h.breakAfter&&(d?d.breakAfter=1:i=1),n++}for(u&&(u.breakAfter=i,t>0&&(!i&&s.length&&u.merge(t,u.length,s[0],!1,l,0)?u.breakAfter=s.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&&s.length;)if(c[n-1].become(s[s.length-1]))n--,s.pop(),a=s.length?0:l;else if(c[e].become(s[0]))e++,s.shift(),l=s.length?0:a;else break;!s.length&&e&&n<c.length&&!c[e-1].breakAfter&&c[n].merge(0,0,c[e-1],!1,l,a)&&e--,(e<n||s.length)&&o.replaceChildren(e,n,s)}}function Ob(o,e,t,n,r,s){let i=o.childCursor(),{i:l,off:a}=i.findPos(t,1),{i:c,off:u}=i.findPos(e,-1),d=e-t;for(let f of n)d+=f.length;o.length+=d,Lb(o,c,u,l,a,n,0,r,s)}var yr="\uFFFF",wl=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(he.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=yr}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let s=this.text.length;this.readNode(r);let i=r.nextSibling;if(i==t)break;let l=be.get(r),a=be.get(i);(l&&a?l.breakAfter:(l?l.breakAfter:eb(r))||eb(i)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=i}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,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,i=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),i=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,i=l[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),i>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=i-1);n=s+i}}readNode(e){if(e.cmIgnore)return;let t=be.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.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 eb(o){return o.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(o.nodeName)}var Tl=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Et=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Cu=typeof document<"u"?document:{documentElement:{style:{}}},vu=/Edge\/(\d+)/.exec(Et.userAgent),Nb=/MSIE \d/.test(Et.userAgent),Su=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Et.userAgent),Il=!!(Nb||Su||vu),tb=!Il&&/gecko\/(\d+)/i.test(Et.userAgent),hu=!Il&&/Chrome\/(\d+)/.exec(Et.userAgent),nb="webkitFontSmoothing"in Cu.documentElement.style,Hb=!Il&&/Apple Computer/.test(Et.vendor),ob=Hb&&(/Mobile\/\w+/.test(Et.userAgent)||Et.maxTouchPoints>2),J={mac:ob||/Mac/.test(Et.platform),windows:/Win/.test(Et.platform),linux:/Linux|X11/.test(Et.platform),ie:Il,ie_version:Nb?Cu.documentMode||6:Su?+Su[1]:vu?+vu[1]:0,gecko:tb,gecko_version:tb?+(/Firefox\/(\d+)/.exec(Et.userAgent)||[0,0])[1]:0,chrome:!!hu,chrome_version:hu?+hu[1]:0,ios:ob,android:/Android\b/.test(Et.userAgent),webkit:nb,safari:Hb,webkit_version:nb?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Cu.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},bD=256,Ht=class extends be{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 Ht)||this.length-(t-e)+n.length>bD||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 Ht(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 Ye(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 yD(this.dom,e,t)}},Jt=class extends be{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let r of t)r.setParent(this)}setAttrs(e){if(Rb(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,r,s,i){return n&&(!(n instanceof Jt&&n.mark.eq(this.mark))||e&&s<=0||t<this.length&&i<=0)?!1:(Ob(this,e,t,n?n.children:[],s-1,i-1),this.markDirty(),!0)}split(e){let t=[],n=0,r=-1,s=0;for(let l of this.children){let a=n+l.length;a>e&&t.push(n<e?l.split(e-n):l),r<0&&n>=e&&(r=s),n=a,s++}let i=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new Jt(this.mark,t,i)}domAtPos(e){return Fb(this,e)}coordsAt(e,t){return Vb(this,e,t)}};function yD(o,e,t){let n=o.nodeValue.length;e>n&&(e=n);let r=e,s=e,i=0;e==0&&t<0||e==n&&t>=0?J.chrome||J.gecko||(e?(r--,i=1):s<n&&(s++,i=-1)):t<0?r--:s<n&&s++;let l=Po(o,r,s).getClientRects();if(!l.length)return null;let a=l[(i?i<0:t>=0)?0:l.length-1];return J.safari&&!i&&a.width==0&&(a=Array.prototype.find.call(l,c=>c.width)||a),i?Yu(a,i<0):a||null}var In=class extends be{constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}static create(e,t,n){return new In(e,t,n)}split(e){let t=In.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,r,s,i){return n&&(!(n instanceof In)||!this.widget.compare(n.widget)||e>0&&s<=0||t<this.length&&i<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof In&&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 de.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,r=this.posAtStart;return n?n.slice(r,r+this.length):de.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Ye.before(this.dom):Ye.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 r=this.dom.getClientRects(),s=null;if(!r.length)return null;let i=this.side?this.side<0:e>0;for(let l=i?r.length-1:0;s=r[l],!(e>0?l==0:l==r.length-1||s.top<s.bottom);l+=i?-1:1);return Yu(s,!i)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},qn=class extends be{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof qn&&e.side==this.side}split(){return new qn(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?Ye.before(this.dom):Ye.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return de.empty}get isHidden(){return!0}};Ht.prototype.children=In.prototype.children=qn.prototype.children=Zu;function Fb(o,e){let t=o.dom,{children:n}=o,r=0;for(let s=0;r<n.length;r++){let i=n[r],l=s+i.length;if(!(l==s&&i.getSide()<=0)){if(e>s&&e<l&&i.dom.parentNode==t)return i.domAtPos(e-s);if(e<=s)break;s=l}}for(let s=r;s>0;s--){let i=n[s-1];if(i.dom.parentNode==t)return i.domAtPos(i.length)}for(let s=r;s<n.length;s++){let i=n[s];if(i.dom.parentNode==t)return i.domAtPos(0)}return new Ye(t,0)}function Bb(o,e,t){let n,{children:r}=o;t>0&&e instanceof Jt&&r.length&&(n=r[r.length-1])instanceof Jt&&n.mark.eq(e.mark)?Bb(n,e.children[0],t-1):(r.push(e),e.setParent(o)),o.length+=e.length}function Vb(o,e,t){let n=null,r=-1,s=null,i=-1;function l(c,u){for(let d=0,f=0;d<c.children.length&&f<=u;d++){let h=c.children[d],p=f+h.length;p>=u&&(h.children.length?l(h,u-f):(!s||s.isHidden&&t>0)&&(p>u||f==p&&h.getSide()>0)?(s=h,i=u-f):(f<u||f==p&&h.getSide()<0&&!h.isHidden)&&(n=h,r=u-f)),f=p}}l(o,e);let a=(t<0?n:s)||n||s;return a?a.coordsAt(Math.max(0,a==n?r:i),t):xD(o)}function xD(o){let e=o.dom.lastChild;if(!e)return o.dom.getBoundingClientRect();let t=Ts(e);return t[t.length-1]||null}function wu(o,e){for(let t in o)t=="class"&&e.class?e.class+=" "+o.class:t=="style"&&e.style?e.style+=";"+o.style:e[t]=o[t];return e}var rb=Object.create(null);function ed(o,e,t){if(o==e)return!0;o||(o=rb),e||(e=rb);let n=Object.keys(o),r=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of n)if(s!=t&&(r.indexOf(s)==-1||o[s]!==e[s]))return!1;return!0}function Tu(o,e,t){let n=null;if(e)for(let r in e)t&&r in t||o.removeAttribute(n=r);if(t)for(let r in t)e&&e[r]==t[r]||o.setAttribute(n=r,t[r]);return!!n}function CD(o){let e=Object.create(null);for(let t=0;t<o.attributes.length;t++){let n=o.attributes[t];e[n.name]=n.value}return e}var An=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){}},Fe=function(o){return o[o.Text=0]="Text",o[o.WidgetBefore=1]="WidgetBefore",o[o.WidgetAfter=2]="WidgetAfter",o[o.WidgetRange=3]="WidgetRange",o}(Fe||(Fe={})),Ue=class extends Xt{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Do(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 dn(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:i}=$b(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(i?t?2e8:1:-6e8)+1}return new dn(e,n,r,t,e.widget||null,!0)}static line(e){return new Io(e)}static set(e,t=!1){return xe.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Ue.none=xe.empty;var Do=class extends Ue{constructor(e){let{start:t,end:n}=$b(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 Do&&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))&&ed(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)}};Do.prototype.point=!1;var Io=class extends Ue{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Io&&this.spec.class==e.spec.class&&ed(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)}};Io.prototype.mapMode=ot.TrackBefore;Io.prototype.point=!0;var dn=class extends Ue{constructor(e,t,n,r,s,i){super(t,n,s,e),this.block=r,this.isReplace=i,this.mapMode=r?t<=0?ot.TrackBefore:ot.TrackAfter:ot.TrackDel}get type(){return this.startSide<this.endSide?Fe.WidgetRange:this.startSide<=0?Fe.WidgetBefore:Fe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof dn&&vD(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)}};dn.prototype.point=!0;function $b(o,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=o;return t==null&&(t=o.inclusive),n==null&&(n=o.inclusive),{start:t!=null?t:e,end:n!=null?n:e}}function vD(o,e){return o==e||!!(o&&e&&o.compare(e))}function ku(o,e,t,n=0){let r=t.length-1;r>=0&&t[r]+n>=o?t[r]=Math.max(t[r],e):t.push(o,e)}var Je=class extends be{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,r,s,i){if(n){if(!(n instanceof Je))return!1;this.dom||n.transferDOM(this)}return r&&this.setDeco(n?n.attrs:null),Ob(this,e,t,n?n.children:[],s,i),!0}split(e){let t=new Je;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:r}=this.childPos(e);r&&(t.append(this.children[n].split(r),0),this.children[n].merge(r,this.children[n].length,null,!1,0,0),n++);for(let s=n;s<this.children.length;s++)t.append(this.children[s],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){ed(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Bb(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=wu(t,this.attrs||{})),n&&(this.attrs=wu({class:n},this.attrs||{}))}domAtPos(e){return Fb(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Rb(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&&(Tu(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&be.get(r)instanceof Jt;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((n=be.get(r))===null||n===void 0?void 0:n.isEditable)==!1&&(!J.ios||!this.children.some(s=>s instanceof Ht))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof Ht)||/[^ -~]/.test(n.text))return null;let r=Ts(n.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=Vb(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=n.bottom-n.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight<s){let i=(s-r.textHeight)/2;return{top:n.top+i,bottom:n.bottom-i,left:n.left,right:n.left}}}return n}become(e){return!1}get type(){return Fe.Text}static find(e,t){for(let n=0,r=0;n<e.children.length;n++){let s=e.children[n],i=r+s.length;if(i>=t){if(s instanceof Je)return s;if(i>t)break}r=i+s.breakAfter}return null}},Rn=class extends be{constructor(e,t,n){super(),this.widget=e,this.length=t,this.type=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,r,s,i){return n&&(!(n instanceof Rn)||!this.widget.compare(n.widget)||e>0&&s<=0||t<this.length&&i<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?Ye.before(this.dom):Ye.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new Rn(this.widget,t,this.type);return n.breakAfter=this.breakAfter,n}get children(){return Zu}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):de.empty}domBoundsAround(){return null}become(e){return e instanceof Rn&&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)}},Mo=class{constructor(e,t,n,r){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=r,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 Rn&&e.type==Fe.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new Je),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ll(new qn(-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:s,lineBreak:i,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(i){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=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(ll(new Ht(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=0}}span(e,t,n,r){this.buildText(t-e,n,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,n,r,s,i){if(this.disallowBlockEffectsFor[i]&&n instanceof dn){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 dn)if(n.block){let{type:a}=n;a==Fe.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Rn(n.widget||new kl("div"),l,a))}else{let a=In.create(n.widget||new kl("span"),l,l?0:n.startSide),c=this.atCursorPos&&!a.isEditable&&s<=r.length&&(e<t||n.startSide>0),u=!a.isEditable&&(e<t||s>r.length||n.startSide<=0),d=this.getLine();this.pendingBuffer==2&&!c&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),c&&(d.append(ll(new qn(1),r),s),s=r.length+Math.max(0,s-r.length)),d.append(ll(a,r),s),this.atCursorPos=u,this.pendingBuffer=u?e<t||s>r.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.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=s)}static build(e,t,n,r,s){let i=new Mo(e,t,n,s);return i.openEnd=xe.spans(r,t,n,i),i.openStart<0&&(i.openStart=i.openEnd),i.finish(i.openEnd),i}};function ll(o,e){for(let t of e)o=new Jt(t,[o],o.length);return o}var kl=class extends An{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}},Kb=oe.define(),zb=oe.define(),Wb=oe.define(),Ub=oe.define(),Eu=oe.define(),Gb=oe.define(),_b=oe.define(),Qb=oe.define({combine:o=>o.some(e=>e)}),qb=oe.define({combine:o=>o.some(e=>e)}),vr=class{constructor(e,t="nearest",n="nearest",r=5,s=5){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=s}map(e){return e.empty?this:new vr(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}},sb=we.define({map:(o,e)=>o.map(e)});function un(o,e,t){let n=o.facet(Ub);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 Rl=oe.define({combine:o=>o.length?o[0]:!0}),SD=0,xs=oe.define(),Ft=class{constructor(e,t,n,r){this.id=e,this.create=t,this.domEventHandlers=n,this.extension=r(this)}static define(e,t){let{eventHandlers:n,provide:r,decorations:s}=t||{};return new Ft(SD++,e,n,i=>{let l=[xs.of(i)];return s&&l.push(ks.of(a=>{let c=a.plugin(i);return c?s(c):Ue.none})),r&&l.push(r(i)),l})}static fromClass(e,t){return Ft.define(n=>new e(n),t)}},Ss=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(un(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){un(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){un(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},jb=oe.define(),td=oe.define(),ks=oe.define(),nd=oe.define(),Xb=oe.define();function Jb(o){let e=0,t=0,n=0,r=0;for(let s of o.state.facet(Xb)){let i=s(o);i&&(i.left!=null&&(e=Math.max(e,i.left)),i.right!=null&&(t=Math.max(t,i.right)),i.top!=null&&(n=Math.max(n,i.top)),i.bottom!=null&&(r=Math.max(r,i.bottom)))}return{left:e,right:t,top:n,bottom:r}}var Cs=oe.define(),yt=class{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new yt(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 r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),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 r=0,s=0,i=0,l=0;;r++){let a=r==e.length?null:e[r],c=i-l,u=a?a.fromB:1e9;for(;s<t.length&&t[s]<u;){let d=t[s],f=t[s+1],h=Math.max(l,d),p=Math.min(u,f);if(h<=p&&new yt(h+c,p+c,h,p).addToSet(n),f>u)break;s+=2}if(!a)return n;new yt(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),i=a.toA,l=a.toB}}},Sr=class{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=De.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,i,l,a)=>r.push(new yt(s,i,l,a))),this.changedRanges=r}static create(e,t,n){return new Sr(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}},He=function(o){return o[o.LTR=0]="LTR",o[o.RTL=1]="RTL",o}(He||(He={})),Mu=He.LTR,wD=He.RTL;function Yb(o){let e=[];for(let t=0;t<o.length;t++)e.push(1<<+o[t]);return e}var TD=Yb("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),kD=Yb("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Pu=Object.create(null),cn=[];for(let o of["()","[]","{}"]){let e=o.charCodeAt(0),t=o.charCodeAt(1);Pu[e]=t,Pu[t]=-e}function ED(o){return o<=247?TD[o]:1424<=o&&o<=1524?2:1536<=o&&o<=1785?kD[o-1536]:1774<=o&&o<=2220?4:8192<=o&&o<=8203?256:64336<=o&&o<=65023?4:o==8204?256:1}var MD=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,_n=class{constructor(e,t,n){this.from=e,this.to=t,this.level=n}get dir(){return this.level%2?wD:Mu}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,n,r){let s=-1;for(let i=0;i<e.length;i++){let l=e[i];if(l.from<=t&&l.to>=t){if(l.level==n)return i;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=i)}}if(s<0)throw new RangeError("Index out of range");return s}},Re=[];function PD(o,e){let t=o.length,n=e==Mu?1:2,r=e==Mu?2:1;if(!o||n==1&&!MD.test(o))return Zb(t);for(let i=0,l=n,a=n;i<t;i++){let c=ED(o.charCodeAt(i));c==512?c=l:c==8&&a==4&&(c=16),Re[i]=c==4?2:c,c&7&&(a=c),l=c}for(let i=0,l=n,a=n;i<t;i++){let c=Re[i];if(c==128)i<t-1&&l==Re[i+1]&&l&24?c=Re[i]=l:Re[i]=256;else if(c==64){let u=i+1;for(;u<t&&Re[u]==64;)u++;let d=i&&l==8||u<t&&Re[u]==8?a==1?1:8:256;for(let f=i;f<u;f++)Re[f]=d;i=u-1}else c==8&&a==1&&(Re[i]=1);l=c,c&7&&(a=c)}for(let i=0,l=0,a=0,c,u,d;i<t;i++)if(u=Pu[c=o.charCodeAt(i)])if(u<0){for(let f=l-3;f>=0;f-=3)if(cn[f+1]==-u){let h=cn[f+2],p=h&2?n:h&4?h&1?r:n:0;p&&(Re[i]=Re[cn[f]]=p),l=f;break}}else{if(cn.length==189)break;cn[l++]=i,cn[l++]=c,cn[l++]=a}else if((d=Re[i])==2||d==1){let f=d==n;a=f?0:1;for(let h=l-3;h>=0;h-=3){let p=cn[h+2];if(p&2)break;if(f)cn[h+2]|=2;else{if(p&4)break;cn[h+2]|=4}}}for(let i=0;i<t;i++)if(Re[i]==256){let l=i+1;for(;l<t&&Re[l]==256;)l++;let a=(i?Re[i-1]:n)==1,c=(l<t?Re[l]:n)==1,u=a==c?a?1:2:n;for(let d=i;d<l;d++)Re[d]=u;i=l-1}let s=[];if(n==1)for(let i=0;i<t;){let l=i,a=Re[i++]!=1;for(;i<t&&a==(Re[i]!=1);)i++;if(a)for(let c=i;c>l;){let u=c,d=Re[--c]!=2;for(;c>l&&d==(Re[c-1]!=2);)c--;s.push(new _n(c,u,d?2:1))}else s.push(new _n(l,i,0))}else for(let i=0;i<t;){let l=i,a=Re[i++]==2;for(;i<t&&a==(Re[i]==2);)i++;s.push(new _n(l,i,a?1:2))}return s}function Zb(o){return[new _n(0,o,0)]}var ey="";function DD(o,e,t,n,r){var s;let i=n.head-o.from,l=-1;if(i==0){if(!r||!o.length)return null;e[0].level!=t&&(i=e[0].side(!1,t),l=0)}else if(i==o.length){if(r)return null;let f=e[e.length-1];f.level!=t&&(i=f.side(!0,t),l=e.length-1)}l<0&&(l=_n.find(e,i,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc));let a=e[l];i==a.side(r,t)&&(a=e[l+=r?1:-1],i=a.side(!r,t));let c=r==(a.dir==t),u=rt(o.text,i,c);if(ey=o.text.slice(Math.min(i,u),Math.max(i,u)),u!=a.side(r,t))return B.cursor(u+o.from,c?-1:1,a.level);let d=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return!d&&a.level!=t?B.cursor(r?o.to:o.from,r?-1:1,t):d&&d.level<a.level?B.cursor(d.side(!r,t)+o.from,r?1:-1,d.level):B.cursor(u+o.from,r?-1:1,a.level)}var El=class extends be{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 Je],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new yt(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:RD(this.view,e.changes);if(this.hasComposition){this.markedForComposition.clear();let{from:l,to:a}=this.hasComposition;t=new yt(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,(J.ie||J.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let r=this.decorations,s=this.updateDeco(),i=LD(r,s,e.changes);return t=yt.extendWithRanges(t,i),!(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:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let i=J.chrome||J.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,i),this.flags&=-8,i&&(i.written||r.selectionRange.focusNode!=i.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(i=>i.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let i of this.children)i instanceof Rn&&i.widget instanceof Ml&&s.push(i.dom);r.updateGaps(s)}updateChildren(e,t,n){let r=n?n.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let i=r.length-1;;i--){let l=i>=0?r[i]:null;if(!l)break;let{fromA:a,toA:c,fromB:u,toB:d}=l,f,h,p,m;if(n&&n.range.fromB<d&&n.range.toB>u){let x=Mo.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),C=Mo.build(this.view.state.doc,n.range.toB,d,this.decorations,this.dynamicDecorationMap);h=x.breakAtStart,p=x.openStart,m=C.openEnd;let b=this.compositionView(n);C.breakAtStart?b.breakAfter=1:C.content.length&&b.merge(b.length,b.length,C.content[0],!1,C.openStart,0)&&(b.breakAfter=C.content[0].breakAfter,C.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(C.content)}else({content:f,breakAtStart:h,openStart:p,openEnd:m}=Mo.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:g,off:y}=s.findPos(c,1),{i:E,off:v}=s.findPos(a,-1);Lb(this,E,v,g,y,f,h,p,m)}n&&this.fixCompositionDOM(n)}compositionView(e){let t=new Ht(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Jt(r,[t],t.length);let n=new Je;return n.append(t,0),n}fixCompositionDOM(e){let t=(s,i)=>{i.flags|=8,this.markedForComposition.add(i);let l=be.get(s);l!=i&&(l&&(l.dom=null),i.setDOM(s))},n=this.childPos(e.range.fromB,1),r=this.children[n.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)n=r.childPos(n.off,1),r=r.children[n.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,r=n==this.dom,s=!r&&pl(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(r||t||s))return;let i=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(J.gecko&&l.empty&&!this.hasComposition&&ID(a)){let d=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(d,a.node.childNodes[a.offset]||null)),a=c=new Ye(d,0),i=!0}let u=this.view.observer.selectionRange;(i||!u.focusNode||!Cl(a.node,a.offset,u.anchorNode,u.anchorOffset)||!Cl(c.node,c.offset,u.focusNode,u.focusOffset))&&(this.view.observer.ignore(()=>{J.android&&J.chrome&&this.dom.contains(u.focusNode)&&OD(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let d=xl(this.view.root);if(d)if(l.empty){if(J.gecko){let f=AD(a.node,a.offset);if(f&&f!=3){let h=ny(a.node,a.offset,f==1?1:-1);h&&(a=new Ye(h,f==1?0:h.nodeValue.length))}}d.collapse(a.node,a.offset),l.bidiLevel!=null&&u.cursorBidiLevel!=null&&(u.cursorBidiLevel=l.bidiLevel)}else if(d.extend){d.collapse(a.node,a.offset);try{d.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),d.removeAllRanges(),d.addRange(f)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,c)),this.impreciseAnchor=a.precise?null:new Ye(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new Ye(u.focusNode,u.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=xl(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let i=Je.find(this,t.head);if(!i)return;let l=i.posAtStart;if(t.head==l||t.head==l+i.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 d=e.observer.selectionRange;e.docView.posFromDOM(d.anchorNode,d.anchorOffset)!=t.from&&n.collapse(r,s)}nearest(e){for(let t=e;t;){let n=be.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 r=this.children[t];if(n<r.length||r instanceof Je)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){for(let n=this.length,r=this.children.length-1;;r--){let s=this.children[r],i=n-s.breakAfter-s.length;if(e>i||e==i&&s.type!=Fe.WidgetBefore&&s.type!=Fe.WidgetAfter&&(!r||t==2||this.children[r-1].breakAfter||this.children[r-1].type==Fe.WidgetBefore&&t>-2))return s.coordsAt(e-i,t);n=i}}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),r=this.children[t];if(!(r instanceof Je))return null;for(;r.children.length;){let{i:l,off:a}=r.childPos(n,1);for(;;l++){if(l==r.children.length)return null;if((r=r.children[l]).length)break}n=a}if(!(r instanceof Ht))return null;let s=rt(r.text,n);if(s==n)return null;let i=Po(r.dom,n,s).getClientRects();return!i.length||i[0].top>=i[0].bottom?null:i[0]}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,s=this.view.contentDOM.clientWidth,i=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==He.LTR;for(let c=0,u=0;u<this.children.length;u++){let d=this.children[u],f=c+d.length;if(f>r)break;if(c>=n){let h=d.dom.getBoundingClientRect();if(t.push(h.height),i){let p=d.dom.lastChild,m=p?Ts(p):[];if(m.length){let g=m[m.length-1],y=a?g.right-h.left:h.right-g.left;y>l&&(l=y,this.minWidth=s,this.minWidthFrom=c,this.minWidthTo=f)}}}c=f+d.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?He.RTL:He.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Je){let i=s.measureTextSize();if(i)return i}let e=document.createElement("div"),t,n,r;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 s=Ts(e.firstChild)[0];t=e.getBoundingClientRect().height,n=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Sl(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],i=s?s.from-1:this.length;if(i>n){let l=t.lineBlockAt(i).bottom-t.lineBlockAt(n).top;e.push(Ue.replace({widget:new Ml(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,i))}if(!s)break;n=s.to+1}return Ue.set(e)}updateDeco(){let e=this.view.state.facet(ks).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),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let s=Jb(this.view),i={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};hD(this.view.scrollDOM,i,t.head<t.anchor?-1:1,e.x,e.y,e.xMargin,e.yMargin,this.view.textDirection==He.LTR)}};function ID(o){return o.node.nodeType==1&&o.node.firstChild&&(o.offset==0||o.node.childNodes[o.offset-1].contentEditable=="false")&&(o.offset==o.node.childNodes.length||o.node.childNodes[o.offset].contentEditable=="false")}var Ml=class extends An{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 ty(o){let e=o.observer.selectionRange,t=e.focusNode&&ny(e.focusNode,e.focusOffset,0);if(!t)return null;let n=be.get(t),r,s;if(n instanceof Ht)r=n.posAtStart,s=r+n.length;else e:for(let i=0,l=t;;){for(let c=l.previousSibling,u;c;c=c.previousSibling){if(u=be.get(c)){r=s=u.posAtEnd+i;break e}let d=new wl([],o.state);if(d.readNode(c),d.text.indexOf(yr)>-1)return null;i+=d.text.length}if(l=l.parentNode,!l)return null;let a=be.get(l);if(a){r=s=a.posAtStart+i;break}}return{from:r,to:s,node:t}}function RD(o,e){let t=ty(o);if(!t)return null;let{from:n,to:r,node:s}=t,i=e.mapPos(n,-1),l=e.mapPos(r,1),a=s.nodeValue;if(/[\n\r]/.test(a))return null;if(l-i!=a.length){let f=e.mapPos(n,1),h=e.mapPos(r,-1);if(h-f==a.length)i=f,l=h;else if(o.state.doc.sliceString(l-a.length,l)==a)i=l-a.length;else if(o.state.doc.sliceString(i,i+a.length)==a)l=i+a.length;else return null}let{main:c}=o.state.selection;if(o.state.doc.sliceString(i,l)!=a||i>c.head||l<c.head)return null;let u=[],d=new yt(n,r,i,l);for(let f=s.parentNode;;f=f.parentNode){let h=be.get(f);if(h instanceof Jt)u.push({node:f,deco:h.mark});else{if(h instanceof Je||f.nodeName=="DIV"&&f.parentNode==o.contentDOM)return{range:d,text:s,marks:u,line:f};if(f!=o.contentDOM)u.push({node:f,deco:new Do({inclusive:!0,attributes:CD(f),tagName:f.tagName.toLowerCase()})});else return null}}}function ny(o,e,t){if(t<=0)for(let n=o,r=e;;){if(n.nodeType==3)return n;if(n.nodeType==1&&r>0)n=n.childNodes[r-1],r=Qn(n);else break}if(t>=0)for(let n=o,r=e;;){if(n.nodeType==3)return n;if(n.nodeType==1&&r<n.childNodes.length&&t>=0)n=n.childNodes[r],r=0;else break}return null}function AD(o,e){return o.nodeType!=1?0:(e&&o.childNodes[e-1].contentEditable=="false"?1:0)|(e<o.childNodes.length&&o.childNodes[e].contentEditable=="false"?2:0)}var Du=class{constructor(){this.changes=[]}compareRange(e,t){ku(e,t,this.changes)}comparePoint(e,t){ku(e,t,this.changes)}};function LD(o,e,t){let n=new Du;return xe.compare(o,e,t,n),n.changes}function OD(o,e){for(let t=o;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function ND(o,e,t=1){let n=o.charCategorizer(e),r=o.doc.lineAt(e),s=e-r.from;if(r.length==0)return B.cursor(e);s==0?t=1:s==r.length&&(t=-1);let i=s,l=s;t<0?i=rt(r.text,s,!1):l=rt(r.text,s);let a=n(r.text.slice(i,l));for(;i>0;){let c=rt(r.text,i,!1);if(n(r.text.slice(c,i))!=a)break;i=c}for(;l<r.length;){let c=rt(r.text,l);if(n(r.text.slice(l,c))!=a)break;l=c}return B.range(i+r.from,l+r.from)}function HD(o,e){return e.left>o?e.left-o:Math.max(0,o-e.right)}function FD(o,e){return e.top>o?e.top-o:Math.max(0,o-e.bottom)}function pu(o,e){return o.top<e.bottom-1&&o.bottom>e.top+1}function ib(o,e){return e<o.top?{top:e,left:o.left,right:o.right,bottom:o.bottom}:o}function lb(o,e){return e>o.bottom?{top:o.top,left:o.left,right:o.right,bottom:e}:o}function Iu(o,e,t){let n,r,s,i,l=!1,a,c,u,d;for(let p=o.firstChild;p;p=p.nextSibling){let m=Ts(p);for(let g=0;g<m.length;g++){let y=m[g];r&&pu(r,y)&&(y=ib(lb(y,r.bottom),r.top));let E=HD(e,y),v=FD(t,y);if(E==0&&v==0)return p.nodeType==3?ab(p,e,t):Iu(p,e,t);if(!n||i>v||i==v&&s>E){n=p,r=y,s=E,i=v;let x=v?t<y.top?-1:1:E?e<y.left?-1:1:0;l=!x||(x>0?g<m.length-1:g>0)}E==0?t>y.bottom&&(!u||u.bottom<y.bottom)?(a=p,u=y):t<y.top&&(!d||d.top>y.top)&&(c=p,d=y):u&&pu(u,y)?u=lb(u,y.bottom):d&&pu(d,y)&&(d=ib(d,y.top))}}if(u&&u.bottom>=t?(n=a,r=u):d&&d.top<=t&&(n=c,r=d),!n)return{node:o,offset:0};let f=Math.max(r.left,Math.min(r.right,e));if(n.nodeType==3)return ab(n,f,t);if(l&&n.contentEditable!="false")return Iu(n,f,t);let h=Array.prototype.indexOf.call(o.childNodes,n)+(e>=(r.left+r.right)/2?1:0);return{node:o,offset:h}}function ab(o,e,t){let n=o.nodeValue.length,r=-1,s=1e9,i=0;for(let l=0;l<n;l++){let a=Po(o,l,l+1).getClientRects();for(let c=0;c<a.length;c++){let u=a[c];if(u.top==u.bottom)continue;i||(i=e-u.left);let d=(u.top>t?u.top-t:t-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&d<s){let f=e>=(u.left+u.right)/2,h=f;if((J.chrome||J.gecko)&&Po(o,l).getBoundingClientRect().left==u.right&&(h=!f),d<=0)return{node:o,offset:l+(h?1:0)};r=l+(h?1:0),s=d}}}return{node:o,offset:r>-1?r:i>0?o.nodeValue.length:0}}function oy(o,e,t,n=-1){var r,s;let i=o.contentDOM.getBoundingClientRect(),l=i.top+o.viewState.paddingTop,a,{docHeight:c}=o.viewState,{x:u,y:d}=e,f=d-l;if(f<0)return 0;if(f>c)return o.state.doc.length;for(let x=o.viewState.heightOracle.textHeight/2,C=!1;a=o.elementAtHeight(f),a.type!=Fe.Text;)for(;f=n>0?a.bottom+x:a.top-x,!(f>=0&&f<=c);){if(C)return t?null:0;C=!0,n=-n}d=l+f;let h=a.from;if(h<o.viewport.from)return o.viewport.from==0?0:t?null:cb(o,i,a,u,d);if(h>o.viewport.to)return o.viewport.to==o.state.doc.length?o.state.doc.length:t?null:cb(o,i,a,u,d);let p=o.dom.ownerDocument,m=o.root.elementFromPoint?o.root:p,g=m.elementFromPoint(u,d);g&&!o.contentDOM.contains(g)&&(g=null),g||(u=Math.max(i.left+1,Math.min(i.right-1,u)),g=m.elementFromPoint(u,d),g&&!o.contentDOM.contains(g)&&(g=null));let y,E=-1;if(g&&((r=o.docView.nearest(g))===null||r===void 0?void 0:r.isEditable)!=!1){if(p.caretPositionFromPoint){let x=p.caretPositionFromPoint(u,d);x&&({offsetNode:y,offset:E}=x)}else if(p.caretRangeFromPoint){let x=p.caretRangeFromPoint(u,d);x&&({startContainer:y,startOffset:E}=x,(!o.contentDOM.contains(y)||J.safari&&BD(y,E,u)||J.chrome&&VD(y,E,u))&&(y=void 0))}}if(!y||!o.docView.dom.contains(y)){let x=Je.find(o.docView,h);if(!x)return f>a.top+a.height/2?a.to:a.from;({node:y,offset:E}=Iu(x.dom,u,d))}let v=o.docView.nearest(y);if(!v)return null;if(v.isWidget&&((s=v.dom)===null||s===void 0?void 0:s.nodeType)==1){let x=v.dom.getBoundingClientRect();return e.y<x.top||e.y<=x.bottom&&e.x<=(x.left+x.right)/2?v.posAtStart:v.posAtEnd}else return v.localPosFromDOM(y,E)+v.posAtStart}function cb(o,e,t,n,r){let s=Math.round((n-e.left)*o.defaultCharacterWidth);if(o.lineWrapping&&t.height>o.defaultLineHeight*1.5){let l=o.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(o.defaultLineHeight-l)*.5)/l);s+=a*o.viewState.heightOracle.lineLength}let i=o.state.sliceDoc(t.from,t.to);return t.from+_g(i,s,o.state.tabSize)}function BD(o,e,t){let n;if(o.nodeType!=3||e!=(n=o.nodeValue.length))return!1;for(let r=o.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return Po(o,n-1,n).getBoundingClientRect().left>t}function VD(o,e,t){if(e!=0)return!1;for(let r=o;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let n=o.nodeType==1?o.getBoundingClientRect():Po(o,0,Math.max(o.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Ru(o,e){let t=o.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==Fe.Text))return n}return t}function $D(o,e,t,n){let r=Ru(o,e.head),s=!n||r.type!=Fe.Text||!(o.lineWrapping||r.widgetLineBreaks)?null:o.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let i=o.dom.getBoundingClientRect(),l=o.textDirectionAt(r.from),a=o.posAtCoords({x:t==(l==He.LTR)?i.right-1:i.left+1,y:(s.top+s.bottom)/2});if(a!=null)return B.cursor(a,t?-1:1)}return B.cursor(t?r.to:r.from,t?-1:1)}function ub(o,e,t,n){let r=o.state.doc.lineAt(e.head),s=o.bidiSpans(r),i=o.textDirectionAt(r.from);for(let l=e,a=null;;){let c=DD(r,s,i,l,t),u=ey;if(!c){if(r.number==(t?o.state.doc.lines:1))return l;u=`
|
|
10
|
-
`,r=o.state.doc.line(r.number+(t?1:-1)),s=o.bidiSpans(r),c=B.cursor(t?r.from:r.to)}if(a){if(!a(u))return l}else{if(!n)return c;a=n(u)}l=c}}function KD(o,e,t){let n=o.state.charCategorizer(e),r=n(t);return s=>{let i=n(s);return r==ut.Space&&(r=i),r==i}}function zD(o,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?o.state.doc.length:0))return B.cursor(r,e.assoc);let i=e.goalColumn,l,a=o.contentDOM.getBoundingClientRect(),c=o.coordsAtPos(r),u=o.documentTop;if(c)i==null&&(i=c.left-a.left),l=s<0?c.top:c.bottom;else{let h=o.viewState.lineBlockAt(r);i==null&&(i=Math.min(a.right-a.left,o.defaultCharacterWidth*(r-h.from))),l=(s<0?h.top:h.bottom)+u}let d=a.left+i,f=n!=null?n:o.viewState.heightOracle.textHeight>>1;for(let h=0;;h+=10){let p=l+(f+h)*s,m=oy(o,{x:d,y:p},!1,s);if(p<a.top||p>a.bottom||(s<0?m<r:m>r))return B.cursor(m,e.assoc,void 0,i)}}function ml(o,e,t){for(;;){let n=0;for(let r of o)r.between(e-1,e+1,(s,i,l)=>{if(e>s&&e<i){let a=n||t||(e-s<i-e?-1:1);e=a<0?s:i,n=a}});if(!n)return e}}function mu(o,e,t){let n=ml(o.state.facet(nd).map(r=>r(o)),t.from,e.head>t.from?-1:1);return n==t.from?t:B.cursor(n,n<t.from?1:-1)}var Au=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,r)=>{this.ignoreDuringComposition(r)||r.type=="keydown"&&this.keydown(e,r)||(this.mustFlushObserver(r)&&e.observer.forceFlush(),this.runCustomHandlers(r.type,e,r)?r.preventDefault():n(e,r))};for(let n in Ke){let r=Ke[n];e.contentDOM.addEventListener(n,s=>{db(e,s)&&t(r,s)},Ou[n]),this.registeredEvents.push(n)}e.scrollDOM.addEventListener("mousedown",n=>{if(n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&(t(Ke.mousedown,n),!n.defaultPrevented&&n.button==2)){let r=e.contentDOM.style.minHeight;e.contentDOM.style.minHeight="100%",setTimeout(()=>e.contentDOM.style.minHeight=r,200)}}),e.scrollDOM.addEventListener("drop",n=>{n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&t(Ke.drop,n)}),J.chrome&&J.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,J.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var n;let r;this.customHandlers=[];for(let s of t)if(r=(n=s.update(e).spec)===null||n===void 0?void 0:n.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:r});for(let i in r)this.registeredEvents.indexOf(i)<0&&i!="scroll"&&(this.registeredEvents.push(i),e.contentDOM.addEventListener(i,l=>{db(e,l)&&this.runCustomHandlers(i,e,l)&&l.preventDefault()}))}}runCustomHandlers(e,t,n){for(let r of this.customHandlers){let s=r.handlers[e];if(s)try{if(s.call(r.plugin,n,t)||n.defaultPrevented)return!0}catch(i){un(t.state,i)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let n of this.customHandlers){let r=n.handlers.scroll;if(r)try{r.call(n.plugin,t,e)}catch(s){un(e.state,s)}}}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&&sy.indexOf(t.keyCode)<0&&(e.inputState.lastEscPress=0),J.android&&J.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return e.observer.delayAndroidKey(t.key,t.keyCode),!0;let n;return J.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((n=ry.find(r=>r.keyCode==t.keyCode))&&!t.ctrlKey||WD.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,Cr(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:J.safari&&!J.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()}},ry=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],WD="dthko",sy=[16,17,18,20,91,92,224,225],al=6;function cl(o){return Math.max(0,o)*.7+8}function UD(o,e){return Math.max(Math.abs(o.clientX-e.clientX),Math.abs(o.clientY-e.clientY))}var Lu=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=pD(e.contentDOM),this.atoms=e.state.facet(nd).map(i=>i(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(he.allowMultipleSelections)&&GD(e,t),this.dragging=QD(e,t)&&cy(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&&UD(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=((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},i=Jb(this.view);e.clientX-i.left<=s.left+al?n=-cl(s.left-e.clientX):e.clientX+i.right>=s.right-al&&(n=cl(e.clientX-s.right)),e.clientY-i.top<=s.top+al?r=-cl(s.top-e.clientY):e.clientY+i.bottom>=s.bottom-al&&(r=cl(e.clientY-s.bottom)),this.setScrollSpeed(n,r)}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 r=e.ranges[n],s=null;if(r.empty){let i=ml(this.atoms,r.from,0);i!=r.from&&(s=B.cursor(i,-1))}else{let i=ml(this.atoms,r.from,-1),l=ml(this.atoms,r.to,1);(i!=r.from||l!=r.to)&&(s=B.range(r.from==r.anchor?i:l,r.from==r.head?i:l))}s&&(t||(t=e.ranges.slice()),t[n]=s)}return t?B.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 GD(o,e){let t=o.state.facet(Kb);return t.length?t[0](e):J.mac?e.metaKey:e.ctrlKey}function _D(o,e){let t=o.state.facet(zb);return t.length?t[0](e):J.mac?!e.altKey:!e.ctrlKey}function QD(o,e){let{main:t}=o.state.selection;if(t.empty)return!1;let n=xl(o.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let i=r[s];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}function db(o,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=o.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=be.get(t))&&n.ignoreEvent(e))return!1;return!0}var Ke=Object.create(null),Ou=Object.create(null),iy=J.ie&&J.ie_version<15||J.ios&&J.webkit_version<604;function qD(o){let e=o.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{o.focus(),t.remove(),ly(o,t.value)},50)}function ly(o,e){let{state:t}=o,n,r=1,s=t.toText(e),i=s.lines==t.selection.ranges.length;if(Nu!=null&&t.selection.ranges.every(a=>a.empty)&&Nu==s.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 d=t.toText((i?s.line(r++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:d},range:B.cursor(c.from+d.length)}})}else i?n=t.changeByRange(a=>{let c=s.line(r++);return{changes:{from:a.from,to:a.to,insert:c.text},range:B.cursor(a.from+c.length)}}):n=t.replaceSelection(s);o.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Ke.keydown=(o,e)=>{o.inputState.setSelectionOrigin("select"),e.keyCode==27&&(o.inputState.lastEscPress=Date.now())};Ke.touchstart=(o,e)=>{o.inputState.lastTouchTime=Date.now(),o.inputState.setSelectionOrigin("select.pointer")};Ke.touchmove=o=>{o.inputState.setSelectionOrigin("select.pointer")};Ou.touchstart=Ou.touchmove={passive:!0};Ke.mousedown=(o,e)=>{if(o.observer.flush(),o.inputState.lastTouchTime>Date.now()-2e3)return;let t=null;for(let n of o.state.facet(Wb))if(t=n(o,e),t)break;if(!t&&e.button==0&&(t=JD(o,e)),t){let n=!o.hasFocus;o.inputState.startMouseSelection(new Lu(o,e,t,n)),n&&o.observer.ignore(()=>Ib(o.contentDOM)),o.inputState.mouseSelection&&o.inputState.mouseSelection.start(e)}};function fb(o,e,t,n){if(n==1)return B.cursor(e,t);if(n==2)return ND(o.state,e,t);{let r=Je.find(o.docView,e),s=o.state.doc.lineAt(r?r.posAtEnd:e),i=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<o.state.doc.length&&l==s.to&&l++,B.range(i,l)}}var ay=(o,e)=>o>=e.top&&o<=e.bottom,hb=(o,e,t)=>ay(e,t)&&o>=t.left&&o<=t.right;function jD(o,e,t,n){let r=Je.find(o.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let i=r.coordsAt(s,-1);if(i&&hb(t,n,i))return-1;let l=r.coordsAt(s,1);return l&&hb(t,n,l)?1:i&&ay(n,i)?-1:1}function pb(o,e){let t=o.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:jD(o,t,e.clientX,e.clientY)}}var XD=J.ie&&J.ie_version<=11,mb=null,gb=0,bb=0;function cy(o){if(!XD)return o.detail;let e=mb,t=bb;return mb=o,bb=Date.now(),gb=!e||t>Date.now()-400&&Math.abs(e.clientX-o.clientX)<2&&Math.abs(e.clientY-o.clientY)<2?(gb+1)%3:1}function JD(o,e){let t=pb(o,e),n=cy(e),r=o.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,i,l){let a=pb(o,s),c,u=fb(o,a.pos,a.bias,n);if(t.pos!=a.pos&&!i){let d=fb(o,t.pos,t.bias,n),f=Math.min(d.from,u.from),h=Math.max(d.to,u.to);u=f<u.from?B.range(f,h):B.range(h,f)}return i?r.replaceRange(r.main.extend(u.from,u.to)):l&&n==1&&r.ranges.length>1&&(c=YD(r,a.pos))?c:l?r.addRange(u):B.create([u])}}}function YD(o,e){for(let t=0;t<o.ranges.length;t++){let{from:n,to:r}=o.ranges[t];if(n<=e&&r>=e)return B.create(o.ranges.slice(0,t).concat(o.ranges.slice(t+1)),o.mainIndex==t?0:o.mainIndex-(o.mainIndex>t?1:0))}return null}Ke.dragstart=(o,e)=>{let{selection:{main:t}}=o.state,{mouseSelection:n}=o.inputState;n&&(n.dragging=t),e.dataTransfer&&(e.dataTransfer.setData("Text",o.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove")};function yb(o,e,t,n){if(!t)return;let r=o.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:s}=o.inputState,i=n&&s&&s.dragging&&_D(o,e)?{from:s.dragging.from,to:s.dragging.to}:null,l={from:r,insert:t},a=o.state.changes(i?[i,l]:l);o.focus(),o.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:i?"move.drop":"input.drop"})}Ke.drop=(o,e)=>{if(!e.dataTransfer)return;if(o.state.readOnly)return e.preventDefault();let t=e.dataTransfer.files;if(t&&t.length){e.preventDefault();let n=Array(t.length),r=0,s=()=>{++r==t.length&&yb(o,e,n.filter(i=>i!=null).join(o.state.lineBreak),!1)};for(let i=0;i<t.length;i++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[i]=l.result),s()},l.readAsText(t[i])}}else yb(o,e,e.dataTransfer.getData("Text"),!0)};Ke.paste=(o,e)=>{if(o.state.readOnly)return e.preventDefault();o.observer.flush();let t=iy?null:e.clipboardData;t?(ly(o,t.getData("text/plain")||t.getData("text/uri-text")),e.preventDefault()):qD(o)};function ZD(o,e){let t=o.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(),o.focus()},50)}function eI(o){let e=[],t=[],n=!1;for(let r of o.selection.ranges)r.empty||(e.push(o.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of o.selection.ranges){let i=o.doc.lineAt(s);i.number>r&&(e.push(i.text),t.push({from:i.from,to:Math.min(o.doc.length,i.to+1)})),r=i.number}n=!0}return{text:e.join(o.lineBreak),ranges:t,linewise:n}}var Nu=null;Ke.copy=Ke.cut=(o,e)=>{let{text:t,ranges:n,linewise:r}=eI(o.state);if(!t&&!r)return;Nu=r?t:null;let s=iy?null:e.clipboardData;s?(e.preventDefault(),s.clearData(),s.setData("text/plain",t)):ZD(o,t),e.type=="cut"&&!o.state.readOnly&&o.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};var uy=kt.define();function dy(o,e){let t=[];for(let n of o.facet(_b)){let r=n(o,e);r&&t.push(r)}return t?o.update({effects:t,annotations:uy.of(!0)}):null}function fy(o){setTimeout(()=>{let e=o.hasFocus;if(e!=o.inputState.notifiedFocused){let t=dy(o.state,e);t?o.dispatch(t):o.update([])}},10)}Ke.focus=o=>{o.inputState.lastFocusTime=Date.now(),!o.scrollDOM.scrollTop&&(o.inputState.lastScrollTop||o.inputState.lastScrollLeft)&&(o.scrollDOM.scrollTop=o.inputState.lastScrollTop,o.scrollDOM.scrollLeft=o.inputState.lastScrollLeft),fy(o)};Ke.blur=o=>{o.observer.clearSelectionRange(),fy(o)};Ke.compositionstart=Ke.compositionupdate=o=>{o.inputState.compositionFirstChange==null&&(o.inputState.compositionFirstChange=!0),o.inputState.composing<0&&(o.inputState.composing=0)};Ke.compositionend=o=>{o.inputState.composing=-1,o.inputState.compositionEndedAt=Date.now(),o.inputState.compositionPendingKey=!0,o.inputState.compositionPendingChange=o.observer.pendingRecords().length>0,o.inputState.compositionFirstChange=null,J.chrome&&J.android?o.observer.flushSoon():o.inputState.compositionPendingChange?Promise.resolve().then(()=>o.observer.flush()):setTimeout(()=>{o.inputState.composing<0&&o.docView.hasComposition&&o.update([])},50)};Ke.contextmenu=o=>{o.inputState.lastContextMenu=Date.now()};Ke.beforeinput=(o,e)=>{var t;let n;if(J.chrome&&J.android&&(n=ry.find(r=>r.inputType==e.inputType))&&(o.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&o.hasFocus&&(o.contentDOM.blur(),o.focus())},100)}};var xb=["pre-wrap","normal","pre-line","break-spaces"],Hu=class{constructor(e){this.lineWrapping=e,this.doc=de.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 xb.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,s,i){let l=xb.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=r,this.lineLength=s,a){this.heightSamples={};for(let c=0;c<i.length;c++){let u=i[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return a}},Fu=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Nt=class{constructor(e,t,n,r,s){this.from=e,this.length=t,this.top=n,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Fe.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 dn?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 Nt(this.from,this.length+e.length,this.top,this.height+e.height,t)}},Te=function(o){return o[o.ByPos=0]="ByPos",o[o.ByHeight=1]="ByHeight",o[o.ByPosNoHeight=2]="ByPosNoHeight",o}(Te||(Te={})),gl=.001,Ze=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)>gl&&(e.heightChanged=!0),this.height=t)}replace(e,t,n){return Ze.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let s=this,i=n.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:c,fromB:u,toB:d}=r[l],f=s.lineAt(a,Te.ByPosNoHeight,n.setDoc(t),0,0),h=f.to>=c?f:s.lineAt(c,Te.ByPosNoHeight,n,0,0);for(d+=h.to-c,c=h.to;l>0&&f.from<=r[l-1].toA;)a=r[l-1].fromA,u=r[l-1].fromB,l--,a<f.from&&(f=s.lineAt(a,Te.ByPosNoHeight,n,0,0));u+=f.from-a,a=f.from;let p=Es.build(n.setDoc(i),e,u,d);s=s.replace(a,c,p)}return s.updateHeight(n,0)}static empty(){return new ft(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,r=0,s=0;for(;;)if(t==n)if(r>s*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,r-=l.size}else if(s>r*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,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--n];l&&(s+=l.size)}let i=0;return e[t-1]==null?(i=1,t--):e[t]==null&&(i=1,n++),new Bu(Ze.of(e.slice(0,t)),i,Ze.of(e.slice(n)))}};Ze.prototype.size=1;var Pl=class extends Ze{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,r){return new Nt(r,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,r,s){return this.blockAt(0,n,r,s)}forEachLine(e,t,n,r,s,i){e<=s+this.length&&t>=s&&i(this.blockAt(0,n,r,s))}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},ft=class extends Pl{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,r){return new Nt(r,this.length,n,this.height,this.breaks)}replace(e,t,n){let r=n[0];return n.length==1&&(r instanceof ft||r instanceof We&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof We?r=new ft(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ze.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.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 Ze{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-n+1,i,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);i=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else i=this.height/s;return{firstLine:n,lastLine:r,perLine:i,perChar:l}}blockAt(e,t,n,r){let{firstLine:s,lastLine:i,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length),u=t.doc.lineAt(c),d=l+u.length*a,f=Math.max(n,e-d/2);return new Nt(u.from,u.length,f,d,0)}else{let c=Math.max(0,Math.min(i-s,Math.floor((e-n)/l))),{from:u,length:d}=t.doc.line(s+c);return new Nt(u,d,n+l*c,l,0)}}lineAt(e,t,n,r,s){if(t==Te.ByHeight)return this.blockAt(e,n,r,s);if(t==Te.ByPosNoHeight){let{from:h,to:p}=n.doc.lineAt(e);return new Nt(h,p-h,0,0,0)}let{firstLine:i,perLine:l,perChar:a}=this.heightMetrics(n,s),c=n.doc.lineAt(e),u=l+c.length*a,d=c.number-i,f=r+l*d+a*(c.from-s-d);return new Nt(c.from,c.length,Math.max(r,Math.min(f,r+this.height-u)),u,0)}forEachLine(e,t,n,r,s,i){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:c}=this.heightMetrics(n,s);for(let u=e,d=r;u<=t;){let f=n.doc.lineAt(u);if(u==e){let p=f.number-l;d+=a*p+c*(e-s-p)}let h=a+c*f.length;i(new Nt(f.from,f.length,d,h,0)),d+=h,u=f.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let s=n[n.length-1];s instanceof We?n[n.length-1]=new We(s.length+r):n.push(null,new We(r-1))}if(e>0){let s=n[0];s instanceof We?n[0]=new We(e+s.length):n.unshift(new We(e-1),null)}return Ze.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,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let i=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&i.push(new We(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let u=e.doc.lineAt(l).length;i.length&&i.push(null);let d=r.heights[r.index++];a==-1?a=d:Math.abs(d-a)>=gl&&(a=-2);let f=new ft(u,d);f.outdated=!1,i.push(f),l+=u+1}l<=s&&i.push(null,new We(s-l).updateHeight(e,l));let c=Ze.of(i);return(a<0||Math.abs(c.height-this.height)>=gl||Math.abs(a-this.heightMetrics(e,t).perLine)>=gl)&&(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})`}},Bu=class extends Ze{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,r){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,n,r,s){let i=r+this.left.height,l=s+this.left.length+this.break,a=t==Te.ByHeight?e<i:e<l,c=a?this.left.lineAt(e,t,n,r,s):this.right.lineAt(e,t,n,i,l);if(this.break||(a?c.to<l:c.from>l))return c;let u=t==Te.ByPosNoHeight?Te.ByPosNoHeight:Te.ByPos;return a?c.join(this.right.lineAt(l,u,n,i,l)):this.left.lineAt(l,u,n,r,s).join(c)}forEachLine(e,t,n,r,s,i){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,s,i),t>=a&&this.right.forEachLine(e,t,n,l,a,i);else{let c=this.lineAt(a,Te.ByPos,n,r,s);e<c.from&&this.left.forEachLine(e,c.from-1,n,r,s,i),c.to>=e&&c.from<=t&&i(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,l,a,i)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)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-r,t-r,n));let s=[];e>0&&this.decomposeLeft(e,s);let i=s.length;for(let l of n)s.push(l);if(e>0&&Cb(s,i-1),t<this.length){let l=s.length;this.decomposeRight(t,s),Cb(s,l)}return Ze.of(s)}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,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ze.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,r){let{left:s,right:i}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,n,r):s.updateHeight(e,t,n),r&&r.from<=l+i.length&&r.more?a=i=i.updateHeight(e,l,n,r):i.updateHeight(e,l,n),a?this.balanced(s,i):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Cb(o,e){let t,n;o[e]==null&&(t=o[e-1])instanceof We&&(n=o[e+1])instanceof We&&o.splice(e-1,3,new We(t.length+1+n.length))}var tI=5,Es=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),r=this.nodes[this.nodes.length-1];r instanceof ft?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new ft(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 r=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let i=t-e;n.block?this.addBlock(new Pl(i,r,n)):(i||s||r>=tI)&&this.addLineDeco(r,s,i)}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 ft(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 ft)return e;let t=new ft(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==Fe.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n!=Fe.WidgetBefore&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.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 ft)&&!this.isCovered?this.nodes.push(new ft(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let r of this.nodes)r instanceof ft&&r.updateHeight(this.oracle,n),n+=r?r.length:1;return this.nodes}static build(e,t,n,r){let s=new Es(n,e);return xe.spans(t,n,r,s,0),s.finish(n)}};function nI(o,e,t){let n=new Vu;return xe.compare(o,e,t,n,0),n.changes}var Vu=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&ku(e,t,this.changes,5)}};function oI(o,e){let t=o.getBoundingClientRect(),n=o.ownerDocument,r=n.defaultView||window,s=Math.max(0,t.left),i=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let c=o.parentNode;c&&c!=n.body;)if(c.nodeType==1){let u=c,d=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&d.overflow!="visible"){let f=u.getBoundingClientRect();s=Math.max(s,f.left),i=Math.min(i,f.right),l=Math.max(l,f.top),a=c==o.parentNode?f.bottom:Math.min(a,f.bottom)}c=d.position=="absolute"||d.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-t.left,right:Math.max(s,i)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function rI(o,e){let t=o.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var ws=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 r=e[n],s=t[n];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e){return Ue.replace({widget:new $u(this.size,e)}).range(this.from,this.to)}},$u=class extends An{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}},Dl=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=vb,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=He.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(td).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Hu(t),this.stateDeco=e.facet(ks).filter(n=>typeof n!="function"),this.heightMap=Ze.empty().applyChanges(this.stateDeco,de.empty,this.heightOracle.setDoc(e.doc),[new yt(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ue.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 r=n?t.head:t.anchor;if(!e.some(({from:s,to:i})=>r>=s&&r<=i)){let{from:s,to:i}=this.lineBlockAt(r);e.push(new xr(s,i))}}this.viewports=e.sort((n,r)=>n.from-r.from),this.scaler=this.heightMap.height<=7e6?vb:new Ku(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:vs(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(ks).filter(u=>typeof u!="function");let r=e.changedRanges,s=yt.extendWithRanges(r,nI(n,this.stateDeco,e?e.changes:De.empty(this.state.doc.length))),i=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),s),this.heightMap.height!=i&&(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=s.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(qb)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?He.RTL:He.LTR;let i=this.heightOracle.mustRefreshForWrapping(s),l=t.getBoundingClientRect(),a=i||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let c=0,u=0,d=parseInt(n.paddingTop)||0,f=parseInt(n.paddingBottom)||0;(this.paddingTop!=d||this.paddingBottom!=f)&&(this.paddingTop=d,this.paddingBottom=f,c|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.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=Ab(e.scrollDOM);let h=(this.printing?rI:oI)(t,this.paddingTop),p=h.top-this.pixelViewport.top,m=h.bottom-this.pixelViewport.bottom;this.pixelViewport=h;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 v=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(v)&&(i=!0),i||r.lineWrapping&&Math.abs(y-this.contentDOMWidth)>r.charWidth){let{lineHeight:x,charWidth:C,textHeight:b}=e.docView.measureTextSize();i=x>0&&r.refresh(s,x,C,b,y/C,v),i&&(e.docView.minWidth=0,c|=8)}p>0&&m>0?u=Math.max(p,m):p<0&&m<0&&(u=Math.min(p,m)),r.heightChanged=!1;for(let x of this.viewports){let C=x.from==this.viewport.from?v:e.docView.measureVisibleLineHeights(x);this.heightMap=(i?Ze.empty().applyChanges(this.stateDeco,de.empty,this.heightOracle,[new yt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,i,new Fu(x.from,C))}r.heightChanged&&(c|=2)}let E=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return E&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(c&2||E)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&this.updateLineGaps(this.ensureLineGaps(i?[]: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)),r=this.heightMap,s=this.heightOracle,{visibleTop:i,visibleBottom:l}=this,a=new xr(r.lineAt(i-n*1e3,Te.ByHeight,s,0,0).from,r.lineAt(l+(1-n)*1e3,Te.ByHeight,s,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),d=r.lineAt(c,Te.ByPos,s,0,0),f;t.y=="center"?f=(d.top+d.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c<a.from?f=d.top:f=d.bottom-u,a=new xr(r.lineAt(f-1e3/2,Te.ByHeight,s,0,0).from,r.lineAt(f+u+1e3/2,Te.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new xr(this.heightMap.lineAt(n,Te.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,Te.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,Te.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,Te.ByPos,this.heightOracle,0,0),{visibleTop:i,visibleBottom:l}=this;return(e==0||r<=i-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(n,250)))&&r>i-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new ws(t.mapPos(r.from),t.mapPos(r.to),r.size));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,s=r>>1,i=r<<1;if(this.defaultTextDirection!=He.LTR&&!n)return[];let l=[],a=(c,u,d,f)=>{if(u-c<s)return;let h=this.state.selection.main,p=[h.from];h.empty||p.push(h.to);for(let g of p)if(g>c&&g<u){a(c,g-10,d,f),a(g+10,u,d,f);return}let m=iI(e,g=>g.from>=d.from&&g.to<=d.to&&Math.abs(g.from-c)<s&&Math.abs(g.to-u)<s&&!p.some(y=>g.from<y&&g.to>y));if(!m){if(u<d.to&&t&&n&&t.visibleRanges.some(g=>g.from<=u&&g.to>=u)){let g=t.moveToLineBoundary(B.cursor(u),!1,!0).head;g>c&&(u=g)}m=new ws(c,u,this.gapSize(d,c,u,f))}l.push(m)};for(let c of this.viewportLines){if(c.length<i)continue;let u=sI(c.from,c.to,this.stateDeco);if(u.total<i)continue;let d=this.scrollTarget?this.scrollTarget.range.head:null,f,h;if(n){let p=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,g;if(d!=null){let y=dl(u,d),E=((this.visibleBottom-this.visibleTop)/2+p)/c.height;m=y-E,g=y+E}else m=(this.visibleTop-c.top-p)/c.height,g=(this.visibleBottom-c.top+p)/c.height;f=ul(u,m),h=ul(u,g)}else{let p=u.total*this.heightOracle.charWidth,m=r*this.heightOracle.charWidth,g,y;if(d!=null){let E=dl(u,d),v=((this.pixelViewport.right-this.pixelViewport.left)/2+m)/p;g=E-v,y=E+v}else g=(this.pixelViewport.left-m)/p,y=(this.pixelViewport.right+m)/p;f=ul(u,g),h=ul(u,y)}f>c.from&&a(c.from,f,c,u),h<c.to&&a(h,c.to,c,u)}return l}gapSize(e,t,n,r){let s=dl(r,n)-dl(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){ws.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Ue.set(e.map(t=>t.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];xe.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].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)||vs(this.heightMap.lineAt(e,Te.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return vs(this.heightMap.lineAt(this.scaler.fromDOM(e),Te.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 vs(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}},xr=class{constructor(e,t){this.from=e,this.to=t}};function sI(o,e,t){let n=[],r=o,s=0;return xe.spans(t,o,e,{span(){},point(i,l){i>r&&(n.push({from:r,to:i}),s+=i-r),r=l}},20),r<e&&(n.push({from:r,to:e}),s+=e-r),{total:s,ranges:n}}function ul({total:o,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(o*t);for(let r=0;;r++){let{from:s,to:i}=e[r],l=i-s;if(n<=l)return s+n;n-=l}}function dl(o,e){let t=0;for(let{from:n,to:r}of o.ranges){if(e<=r){t+=e-n;break}t+=r-n}return t/o.total}function iI(o,e){for(let t of o)if(e(t))return t}var vb={toDOM(o){return o},fromDOM(o){return o},scale:1},Ku=class{constructor(e,t,n){let r=0,s=0,i=0;this.viewports=n.map(({from:l,to:a})=>{let c=t.lineAt(l,Te.ByPos,e,0,0).top,u=t.lineAt(a,Te.ByPos,e,0,0).bottom;return r+=u-c,{from:l,to:a,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=i+(l.top-s)*this.scale,i=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return n+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,r=s.domBottom}}};function vs(o,e){if(e.scale==1)return o;let t=e.toDOM(o.top),n=e.toDOM(o.bottom);return new Nt(o.from,o.length,t,n-t,Array.isArray(o._content)?o._content.map(r=>vs(r,e)):o._content)}var fl=oe.define({combine:o=>o.join(" ")}),zu=oe.define({combine:o=>o.indexOf(!0)>-1}),Wu=Ot.newName(),hy=Ot.newName(),py=Ot.newName(),my={"&light":"."+hy,"&dark":"."+py};function Uu(o,e,t){return new Ot(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return o;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):o+" "+n}})}var lI=Uu("."+Wu,{"&":{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"}},my),Gu=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:i}=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=s||i?[]:cI(e),a=new wl(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=uI(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!yu(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),c=i&&i.node==l.anchorNode&&i.offset==l.anchorOffset||!yu(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=B.single(c,a)}}};function gy(o,e){let t,{newSel:n}=e,r=o.state.selection.main,s=o.inputState.lastKeyTime>Date.now()-100?o.inputState.lastKeyCode:-1;if(e.bounds){let{from:i,to:l}=e.bounds,a=r.from,c=null;(s===8||J.android&&e.text.length<l-i)&&(a=r.to,c="end");let u=aI(o.state.doc.sliceString(i,l,yr),e.text,a-i,c);u&&(J.chrome&&s==13&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==yr+yr&&u.toB--,t={from:i+u.from,to:i+u.toA,insert:de.of(e.text.slice(u.from,u.toB).split(yr))})}else n&&(!o.hasFocus&&o.state.facet(Rl)||n.main.eq(r))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!r.empty&&n&&n.main.empty?t={from:r.from,to:r.to,insert:o.state.doc.slice(r.from,r.to)}:t&&t.from>=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:o.state.doc.slice(r.from,t.from).append(t.insert).append(o.state.doc.slice(t.to,r.to))}:(J.mac||J.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&o.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=B.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:de.of([" "])}):J.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
|
|
11
|
-
`&&o.lineWrapping&&(n&&(n=B.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:de.of([" "])}),t){let i=o.state;if(J.ios&&o.inputState.flushIOSKey(o)||J.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&Cr(o.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.length<t.to-t.from)&&Cr(o.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Cr(o.contentDOM,"Delete",46)))return!0;let l=t.insert.toString();if(o.state.facet(Gb).some(u=>u(o,t.from,t.to,l)))return!0;o.inputState.composing>=0&&o.inputState.composing++;let a;if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&o.inputState.composing<0){let u=r.from<t.from?i.sliceDoc(r.from,t.from):"",d=r.to>t.to?i.sliceDoc(t.to,r.to):"";a=i.replaceSelection(o.state.toText(u+t.insert.sliceString(0,void 0,o.state.lineBreak)+d))}else{let u=i.changes(t),d=n&&n.main.to<=u.newLength?n.main:void 0;if(i.selection.ranges.length>1&&o.inputState.composing>=0&&t.to<=r.to&&t.to>=r.to-10){let f=o.state.sliceDoc(t.from,t.to),h=ty(o)||o.state.doc.lineAt(r.head),p=r.to-t.to,m=r.to-r.from;a=i.changeByRange(g=>{if(g.from==r.from&&g.to==r.to)return{changes:u,range:d||g.map(u)};let y=g.to-p,E=y-f.length;if(g.to-g.from!=m||o.state.sliceDoc(E,y)!=f||h&&g.to>=h.from&&g.from<=h.to)return{range:g};let v=i.changes({from:E,to:y,insert:t.insert}),x=g.to-r.to;return{changes:v,range:d?B.range(Math.max(0,d.anchor+x),Math.max(0,d.head+x)):g.map(v)}})}else a={changes:u,selection:d&&i.selection.replaceRange(d)}}let c="input.type";return(o.composing||o.inputState.compositionPendingChange&&o.inputState.compositionEndedAt>Date.now()-50)&&(o.inputState.compositionPendingChange=!1,c+=".compose",o.inputState.compositionFirstChange&&(c+=".start",o.inputState.compositionFirstChange=!1)),o.dispatch(a,{scrollIntoView:!0,userEvent:c}),!0}else if(n&&!n.main.eq(r)){let i=!1,l="select";return o.inputState.lastSelectionTime>Date.now()-50&&(o.inputState.lastSelectionOrigin=="select"&&(i=!0),l=o.inputState.lastSelectionOrigin),o.dispatch({selection:n,scrollIntoView:i,userEvent:l}),!0}else return!1}function aI(o,e,t,n){let r=Math.min(o.length,e.length),s=0;for(;s<r&&o.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&o.length==e.length)return null;let i=o.length,l=e.length;for(;i>0&&l>0&&o.charCodeAt(i-1)==e.charCodeAt(l-1);)i--,l--;if(n=="end"){let a=Math.max(0,s-Math.min(i,l));t-=i+a-s}if(i<s&&o.length<e.length){let a=t<=s&&t>=i?s-t:0;s-=a,l=s+(l-i),i=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,i=s+(i-l),l=s}return{from:s,toA:i,toB:l}}function cI(o){let e=[];if(o.root.activeElement!=o.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=o.observer.selectionRange;return t&&(e.push(new Tl(t,n)),(r!=t||s!=n)&&e.push(new Tl(r,s))),e}function uI(o,e){if(o.length==0)return null;let t=o[0].pos,n=o.length==2?o[1].pos:t;return t>-1&&n>-1?B.single(t+e,n+e):null}var dI={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},gu=J.ie&&J.ie_version<=11,_u=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new xu,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);(J.ie&&J.ie_version<=11||J.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()}),gu&&(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,r=this.selectionRange;if(n.state.facet(Rl)?n.root.activeElement!=this.dom:!pl(n.dom,r))return;let s=r.anchorNode&&n.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(J.ie&&J.ie_version<=11||J.android&&J.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Cl(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=J.safari&&e.root.nodeType==11&&dD(this.dom.ownerDocument)==this.dom&&fI(this.view)||xl(e.root);if(!t||this.selectionRange.eq(t))return!1;let n=pl(this.dom,t);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&gD(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,dI),gu&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),gu&&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 r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Cr(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!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,r=!1;for(let s of e){let i=this.readMutation(s);i&&(i.typeOver&&(r=!0),t==-1?{from:t,to:n}=i:(t=Math.min(i.from,t),n=Math.max(i.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&pl(this.dom,this.selectionRange);return e<0&&!r?null:(e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new Gu(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,r=gy(this.view,t);return this.view.state==n&&this.view.update([]),r}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=Sb(t,e.previousSibling||e.target.previousSibling,-1),r=Sb(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):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,r;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(),(r=this.resizeContent)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.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 Sb(o,e,t){for(;e;){let n=be.get(e);if(n&&n.parent==o)return n;let r=e.parentNode;e=r!=o.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function fI(o){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(o.contentDOM.addEventListener("beforeinput",t,!0),o.dom.ownerDocument.execCommand("indent"),o.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,l=o.docView.domAtPos(o.state.selection.main.anchor);return Cl(l.node,l.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}var se=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||mD(e.parent)||document,this.viewState=new Dl(e.state||he.create(e)),this.plugins=this.state.facet(xs).map(t=>new Ss(t));for(let t of this.plugins)t.update(this);this.observer=new _u(this),this.inputState=new Au(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new El(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 Ie?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,r,s=this.state;for(let f of e){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let i=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(uy))?(this.inputState.notifiedFocused=i,l=1):i!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=i,a=dy(s,i),a||(l=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(he.phrases)!=this.state.facet(he.phrases))return this.setState(s);r=Sr.create(this,s,e),r.flags|=l;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(d&&(d=d.map(f.changes)),f.scrollIntoView){let{main:h}=f.state.selection;d=new vr(h.empty?h:B.cursor(h.head,h.head>h.anchor?-1:1))}for(let h of f.effects)h.is(sb)&&(d=h.value)}this.viewState.update(r,d),this.bidiCache=wr.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(Cs)!=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(r.startState.facet(fl)!=r.state.facet(fl)&&(this.viewState.mustMeasureContent=!0),(t||n||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let f of this.state.facet(Eu))f(r);(a||u)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),u&&!gy(this,u)&&c.force&&Cr(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 Dl(e),this.plugins=e.facet(xs).map(n=>new Ss(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView=new El(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(xs),n=e.state.facet(xs);if(t!=n){let r=[];for(let s of n){let i=t.indexOf(s);if(i<0)r.push(new Ss(s));else{let l=this.plugins[i];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].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:r}=n,{scrollAnchorPos:s,scrollAnchorHeight:i}=this.viewState;r!=this.viewState.scrollTop&&(i=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(i<0)if(Ab(n))s=-1,i=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(r);s=h.from,i=h.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(h=>{try{return h.read(this)}catch(p){return un(this.state,p),wb}}),d=Sr.create(this,this.state,[]),f=!1;d.flags|=a,t?t.flags|=a:t=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),f=this.docView.update(d));for(let h=0;h<c.length;h++)if(u[h]!=wb)try{let p=c[h];p.write&&p.write(u[h],this)}catch(p){un(this.state,p)}if(f&&this.docView.updateSelection(!0),!d.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null;continue}else{let p=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-i;if(p>1||p<-1){r=n.scrollTop=r+p,i=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Eu))l(t)}get themeClasses(){return Wu+" "+(this.state.facet(zu)?py:hy)+" "+this.state.facet(fl)}updateAttrs(){let e=Tb(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Rl)?"true":"false",class:"cm-content",style:`${J.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Tb(this,td,t);let n=this.observer.ignore(()=>{let r=Tu(this.contentDOM,this.contentAttrs,t),s=Tu(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let r of n.effects)if(r.is(se.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Cs),Ot.mount(this.root,this.styleModules.concat(lI).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 mu(this,e,ub(this,e,t,n))}moveByGroup(e,t){return mu(this,e,ub(this,e,t,n=>KD(this,e.head,n)))}moveToLineBoundary(e,t,n=!0){return $D(this,e,t,n)}moveVertically(e,t,n){return mu(this,e,zD(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(),oy(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 r=this.state.doc.lineAt(e),s=this.bidiSpans(r),i=s[_n.find(s,e-r.from,-1,t)];return Yu(n,i.dir==He.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(Qb)||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>hI)return Zb(e.length);let t=this.textDirectionAt(e.from);for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t)return r.order;let n=PD(e.text,t);return this.bidiCache.push(new wr(e.from,e.to,t,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||J.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ib(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 sb.of(new vr(typeof e=="number"?B.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return Ft.define(()=>({}),{eventHandlers:e})}static theme(e,t){let n=Ot.newName(),r=[fl.of(n),Cs.of(Uu(`.${n}`,e))];return t&&t.dark&&r.push(zu.of(!0)),r}static baseTheme(e){return To.lowest(Cs.of(Uu("."+Wu,e,my)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&be.get(n)||be.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}};se.styleModule=Cs;se.inputHandler=Gb;se.focusChangeEffect=_b;se.perLineTextDirection=Qb;se.exceptionSink=Ub;se.updateListener=Eu;se.editable=Rl;se.mouseSelectionStyle=Wb;se.dragMovesSelection=zb;se.clickAddsSelectionRange=Kb;se.decorations=ks;se.atomicRanges=nd;se.scrollMargins=Xb;se.darkTheme=zu;se.contentAttributes=td;se.editorAttributes=jb;se.lineWrapping=se.contentAttributes.of({class:"cm-lineWrapping"});se.announce=we.define();var hI=4096,wb={},wr=class{constructor(e,t,n,r){this.from=e,this.to=t,this.dir=n,this.order=r}static update(e,t){if(t.empty)return e;let n=[],r=e.length?e[e.length-1].dir:He.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let i=e[s];i.dir==r&&!t.touchesRange(i.from,i.to)&&n.push(new wr(t.mapPos(i.from,1),t.mapPos(i.to,-1),i.dir,i.order))}return n}};function Tb(o,e,t){for(let n=o.state.facet(e),r=n.length-1;r>=0;r--){let s=n[r],i=typeof s=="function"?s(o):s;i&&wu(i,t)}return t}var pI=J.mac?"mac":J.windows?"win":J.linux?"linux":"key";function mI(o,e){let t=o.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,i,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))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),l&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function hl(o,e,t){return e.altKey&&(o="Alt-"+o),e.ctrlKey&&(o="Ctrl-"+o),e.metaKey&&(o="Meta-"+o),t!==!1&&e.shiftKey&&(o="Shift-"+o),o}var gI=To.default(se.domEventHandlers({keydown(o,e){return CI(bI(e.state),o,e,"editor")}})),Ao=oe.define({enables:gI}),kb=new WeakMap;function bI(o){let e=o.facet(Ao),t=kb.get(e);return t||kb.set(e,t=xI(e.reduce((n,r)=>n.concat(r),[]))),t}var Gn=null,yI=4e3;function xI(o,e=pI){let t=Object.create(null),n=Object.create(null),r=(i,l)=>{let a=n[i];if(a==null)n[i]=l;else if(a!=l)throw new Error("Key binding "+i+" is used both as a regular binding and as a multi-stroke prefix")},s=(i,l,a,c,u)=>{var d,f;let h=t[i]||(t[i]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>mI(y,e));for(let y=1;y<p.length;y++){let E=p.slice(0,y).join(" ");r(E,!0),h[E]||(h[E]={preventDefault:!0,stopPropagation:!1,run:[v=>{let x=Gn={view:v,prefix:E,scope:i};return setTimeout(()=>{Gn==x&&(Gn=null)},yI),!0}]})}let m=p.join(" ");r(m,!1);let g=h[m]||(h[m]={preventDefault:!1,stopPropagation:!1,run:((f=(d=h._any)===null||d===void 0?void 0:d.run)===null||f===void 0?void 0:f.slice())||[]});a&&g.run.push(a),c&&(g.preventDefault=!0),u&&(g.stopPropagation=!0)};for(let i of o){let l=i.scope?i.scope.split(" "):["editor"];if(i.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 d in u)u[d].run.push(i.any)}let a=i[e]||i.key;if(a)for(let c of l)s(c,a,i.run,i.preventDefault,i.stopPropagation),i.shift&&s(c,"Shift-"+a,i.shift,i.preventDefault,i.stopPropagation)}return t}function CI(o,e,t,n){let r=Xg(e),s=ln(r,0),i=Co(s)==r.length&&r!=" ",l="",a=!1,c=!1,u=!1;Gn&&Gn.view==t&&Gn.scope==n&&(l=Gn.prefix+" ",sy.indexOf(e.keyCode)<0&&(c=!0,Gn=null));let d=new Set,f=g=>{if(g){for(let y of g.run)if(!d.has(y)&&(d.add(y),y(t,e)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},h=o[n],p,m;return h&&(f(h[l+hl(r,e,!i)])?a=!0:i&&(e.altKey||e.metaKey||e.ctrlKey)&&!(J.windows&&e.ctrlKey&&e.altKey)&&(p=Dn[e.keyCode])&&p!=r?(f(h[l+hl(p,e,!0)])||e.shiftKey&&(m=gr[e.keyCode])!=r&&m!=p&&f(h[l+hl(m,e,!1)]))&&(a=!0):i&&e.shiftKey&&f(h[l+hl(r,e,!0)])&&(a=!0),!a&&f(h._any)&&(a=!0)),c&&(a=!0),a&&u&&e.stopPropagation(),a}var Ro=class{constructor(e,t,n,r,s){this.className=e,this.left=t,this.top=n,this.width=r,this.height=s}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 r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=by(e);return[new Ro(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return vI(e,t,n)}};function by(o){let e=o.scrollDOM.getBoundingClientRect();return{left:(o.textDirection==He.LTR?e.left:e.right-o.scrollDOM.clientWidth)-o.scrollDOM.scrollLeft,top:e.top-o.scrollDOM.scrollTop}}function Eb(o,e,t){let n=B.cursor(e);return{from:Math.max(t.from,o.moveToLineBoundary(n,!1,!0).from),to:Math.min(t.to,o.moveToLineBoundary(n,!0,!0).from),type:Fe.Text}}function vI(o,e,t){if(t.to<=o.viewport.from||t.from>=o.viewport.to)return[];let n=Math.max(t.from,o.viewport.from),r=Math.min(t.to,o.viewport.to),s=o.textDirection==He.LTR,i=o.contentDOM,l=i.getBoundingClientRect(),a=by(o),c=i.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),d=l.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=l.right-(u?parseInt(u.paddingRight):0),h=Ru(o,n),p=Ru(o,r),m=h.type==Fe.Text?h:null,g=p.type==Fe.Text?p:null;if(m&&(o.lineWrapping||h.widgetLineBreaks)&&(m=Eb(o,n,m)),g&&(o.lineWrapping||p.widgetLineBreaks)&&(g=Eb(o,r,g)),m&&g&&m.from==g.from)return E(v(t.from,t.to,m));{let C=m?v(t.from,null,m):x(h,!1),b=g?v(null,t.to,g):x(p,!0),S=[];return(m||h).to<(g||p).from-(m&&g?1:0)||h.widgetLineBreaks>1&&C.bottom+o.defaultLineHeight/2<b.top?S.push(y(d,C.bottom,f,b.top)):C.bottom<b.top&&o.elementAtHeight((C.bottom+b.top)/2).type==Fe.Text&&(C.bottom=b.top=(C.bottom+b.top)/2),E(C).concat(S).concat(E(b))}function y(C,b,S,M){return new Ro(e,C-a.left,b-a.top-.01,S-C,M-b+.01)}function E({top:C,bottom:b,horizontal:S}){let M=[];for(let w=0;w<S.length;w+=2)M.push(y(S[w],C,S[w+1],b));return M}function v(C,b,S){let M=1e9,w=-1e9,k=[];function L(R,O,A,D,I){let F=o.coordsAtPos(R,R==S.to?-2:2),N=o.coordsAtPos(A,A==S.from?2:-2);!F||!N||(M=Math.min(F.top,N.top,M),w=Math.max(F.bottom,N.bottom,w),I==He.LTR?k.push(s&&O?d:F.left,s&&D?f:N.right):k.push(!s&&D?d:N.left,!s&&O?f:F.right))}let T=C!=null?C:S.from,P=b!=null?b:S.to;for(let R of o.visibleRanges)if(R.to>T&&R.from<P)for(let O=Math.max(R.from,T),A=Math.min(R.to,P);;){let D=o.state.doc.lineAt(O);for(let I of o.bidiSpans(D)){let F=I.from+D.from,N=I.to+D.from;if(F>=A)break;N>O&&L(Math.max(F,O),C==null&&F<=T,Math.min(N,A),b==null&&N>=P,I.dir)}if(O=D.to+1,O>=A)break}return k.length==0&&L(T,C==null,P,b==null,o.textDirection),{top:M,bottom:w,horizontal:k}}function x(C,b){let S=l.top+(b?C.top:C.bottom);return{top:S,bottom:S,horizontal:[]}}}function SI(o,e){return o.constructor==e.constructor&&o.eq(e)}var Qu=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(bl)!=e.state.facet(bl)&&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(bl);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)=>!SI(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},bl=oe.define();function yy(o){return[Ft.define(e=>new Qu(e,o)),bl.of(o)]}var xy=!J.ios,Ms=oe.define({combine(o){return ko(o,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function od(o={}){return[Ms.of(o),wI,TI,kI,qb.of(!0)]}function Cy(o){return o.startState.facet(Ms)!=o.state.facet(Ms)}var wI=yy({above:!0,markers(o){let{state:e}=o,t=e.facet(Ms),n=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||xy:t.drawRangeCursor){let i=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:B.cursor(r.head,r.head>r.anchor?-1:1);for(let a of Ro.forRange(o,i,l))n.push(a)}}return n},update(o,e){o.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Cy(o);return t&&Mb(o.state,e),o.docChanged||o.selectionSet||t},mount(o,e){Mb(e.state,o)},class:"cm-cursorLayer"});function Mb(o,e){e.style.animationDuration=o.facet(Ms).cursorBlinkRate+"ms"}var TI=yy({above:!1,markers(o){return o.state.selection.ranges.map(e=>e.empty?[]:Ro.forRange(o,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(o,e){return o.docChanged||o.selectionSet||o.viewportChanged||Cy(o)},class:"cm-selectionLayer"}),vy={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};xy&&(vy[".cm-line"].caretColor="transparent !important");var kI=To.highest(se.theme(vy));function Pb(o,e,t,n,r){e.lastIndex=0;for(let s=o.iterRange(t,n),i=t,l;!s.next().done;i+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(i+l.index,l)}function EI(o,e){let t=o.visibleRanges;if(t.length==1&&t[0].from==o.viewport.from&&t[0].to==o.viewport.to)return t;let n=[];for(let{from:r,to:s}of t)r=Math.max(o.state.doc.lineAt(r).from,r-e),s=Math.min(o.state.doc.lineAt(s).to,s+e),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}var qu=class{constructor(e){let{regexp:t,decoration:n,decorate:r,boundary:s,maxLength:i=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(l,a,c,u)=>r(u,c,c+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,c,u)=>{let d=n(l,a,c);d&&u(c,c+l[0].length,d)};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=s,this.maxLength=i}createDeco(e){let t=new an,n=t.add.bind(t);for(let{from:r,to:s}of EI(e,this.maxLength))Pb(e.state.doc,this.regexp,r,s,(i,l)=>this.addMatch(l,e,i,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,i,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(n=Math.min(l,n),r=Math.max(a,r))}),e.viewportChanged||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let s of e.visibleRanges){let i=Math.max(s.from,n),l=Math.min(s.to,r);if(l>i){let a=e.state.doc.lineAt(i),c=a.to<l?e.state.doc.lineAt(l):a,u=Math.max(s.from,a.from),d=Math.min(s.to,c.to);if(this.boundary){for(;i>a.from;i--)if(this.boundary.test(a.text[i-1-a.from])){u=i;break}for(;l<c.to;l++)if(this.boundary.test(c.text[l-c.from])){d=l;break}}let f=[],h,p=(m,g,y)=>f.push(y.range(m,g));if(a==c)for(this.regexp.lastIndex=u-a.from;(h=this.regexp.exec(a.text))&&h.index<d-a.from;)this.addMatch(h,e,h.index+a.from,p);else Pb(e.state.doc,this.regexp,u,d,(m,g)=>this.addMatch(g,e,m,p));t=t.update({filterFrom:u,filterTo:d,filter:(m,g)=>m<u||g>d,add:f})}}return t}},ju=/x/.unicode!=null?"gu":"g",MI=new RegExp(`[\0-\b
|
|
12
|
-
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,ju),PI={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"},bu=null;function DI(){var o;if(bu==null&&typeof document<"u"&&document.body){let e=document.body.style;bu=((o=e.tabSize)!==null&&o!==void 0?o:e.MozTabSize)!=null}return bu||!1}var yl=oe.define({combine(o){let e=ko(o,{render:null,specialChars:MI,addSpecialChars:null});return(e.replaceTabs=!DI())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,ju)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,ju)),e}});function rd(o={}){return[yl.of(o),II()]}var Db=null;function II(){return Db||(Db=Ft.fromClass(class{constructor(o){this.view=o,this.decorations=Ue.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(o.state.facet(yl)),this.decorations=this.decorator.createDeco(o)}makeDecorator(o){return new qu({regexp:o.specialChars,decoration:(e,t,n)=>{let{doc:r}=t.state,s=ln(e[0],0);if(s==9){let i=r.lineAt(n),l=t.state.tabSize,a=Eo(i.text,l,n-i.from);return Ue.replace({widget:new Ju((l-a%l)*this.view.defaultCharacterWidth)})}return this.decorationCache[s]||(this.decorationCache[s]=Ue.replace({widget:new Xu(o,s)}))},boundary:o.replaceTabs?void 0:/[^]/})}update(o){let e=o.state.facet(yl);o.startState.facet(yl)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(o.view)):this.decorations=this.decorator.updateDeco(o,this.decorations)}},{decorations:o=>o.decorations}))}var RI="\u2022";function AI(o){return o>=32?RI:o==10?"\u2424":String.fromCharCode(9216+o)}var Xu=class extends An{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=AI(this.code),n=e.state.phrase("Control character")+" "+(PI[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}},Ju=class extends An{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 Wte=se.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 Ln=class extends Xt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Ln.prototype.elementClass="";Ln.prototype.toDOM=void 0;Ln.prototype.mapMode=ot.TrackBefore;Ln.prototype.startSide=Ln.prototype.endSide=-1;Ln.prototype.point=!0;var LI=0,Bt=class{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=LI++}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 Tr;return t=>t.modified.indexOf(e)>-1?t:Tr.get(t.base||t,t.modified.concat(e).sort((n,r)=>n.id-r.id))}},OI=0,Tr=class{constructor(){this.instances=[],this.id=OI++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&NI(t,l.modified));if(n)return n;let r=[],s=new Bt(r,e,t);for(let l of t)l.instances.push(s);let i=HI(t);for(let l of e.set)if(!l.modified.length)for(let a of i)r.push(Tr.get(l,a));return s}};function NI(o,e){return o.length==e.length&&o.every((t,n)=>t==e[n])}function HI(o){let e=[[]];for(let t=0;t<o.length;t++)for(let n=0,r=e.length;n<r;n++)e.push(e[n].concat(o[t]));return e.sort((t,n)=>n.length-t.length)}function Oo(o){let e=Object.create(null);for(let t in o){let n=o[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],i=2,l=r;for(let d=0;;){if(l=="..."&&d>0&&d+3==r.length){i=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),d+=f[0].length,d==r.length)break;let h=r[d++];if(d==r.length&&h=="!"){i=0;break}if(h!="/")throw new RangeError("Invalid path: "+r);l=r.slice(d)}let a=s.length-1,c=s[a];if(!c)throw new RangeError("Invalid path: "+r);let u=new kr(n,i,a>0?s.slice(0,a):null);e[c]=u.sort(e[c])}}return Ty.add(e)}var Ty=new re,kr=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}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}};kr.empty=new kr([],2,null);function ad(o,e){let t=Object.create(null);for(let s of o)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let i of s.tag)t[i.id]=s.class;let{scope:n,all:r=null}=e||{};return{style:s=>{let i=r;for(let l of s)for(let a of l.set){let c=t[a.id];if(c){i=i?i+" "+c:c;break}}return i},scope:n}}function FI(o,e){let t=null;for(let n of o){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function ky(o,e,t,n=0,r=o.length){let s=new id(n,Array.isArray(e)?e:[e],t);s.highlightRange(o.cursor(),n,r,"",s.highlighters),s.flush(r)}var id=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,r,s){let{type:i,from:l,to:a}=e;if(l>=n||a<=t)return;i.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(i)));let c=r,u=BI(e)||kr.empty,d=FI(s,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(r+=(r?" ":"")+d)),this.startSpan(Math.max(t,l),c),u.opaque)return;let f=e.tree&&e.tree.prop(re.mounted);if(f&&f.overlay){let h=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 E=g<f.overlay.length?f.overlay[g]:null,v=E?E.from+l:a,x=Math.max(t,y),C=Math.min(n,v);if(x<C&&m)for(;e.from<C&&(this.highlightRange(e,x,C,r,s),this.startSpan(Math.min(C,e.to),c),!(e.to>=v||!e.nextSibling())););if(!E||v>n)break;y=E.to+l,y>t&&(this.highlightRange(h.cursor(),Math.max(t,E.from+l),Math.min(n,y),"",p),this.startSpan(Math.min(n,y),c))}m&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function BI(o){let e=o.type.prop(Ty);for(;e&&e.context&&!o.matchContext(e.context);)e=e.next;return e||null}var W=Bt.define,Al=W(),jn=W(),Sy=W(jn),wy=W(jn),Xn=W(),Ll=W(Xn),sd=W(Xn),pn=W(),Lo=W(pn),fn=W(),hn=W(),ld=W(),Ps=W(ld),Ol=W(),$={comment:Al,lineComment:W(Al),blockComment:W(Al),docComment:W(Al),name:jn,variableName:W(jn),typeName:Sy,tagName:W(Sy),propertyName:wy,attributeName:W(wy),className:W(jn),labelName:W(jn),namespace:W(jn),macroName:W(jn),literal:Xn,string:Ll,docString:W(Ll),character:W(Ll),attributeValue:W(Ll),number:sd,integer:W(sd),float:W(sd),bool:W(Xn),regexp:W(Xn),escape:W(Xn),color:W(Xn),url:W(Xn),keyword:fn,self:W(fn),null:W(fn),atom:W(fn),unit:W(fn),modifier:W(fn),operatorKeyword:W(fn),controlKeyword:W(fn),definitionKeyword:W(fn),moduleKeyword:W(fn),operator:hn,derefOperator:W(hn),arithmeticOperator:W(hn),logicOperator:W(hn),bitwiseOperator:W(hn),compareOperator:W(hn),updateOperator:W(hn),definitionOperator:W(hn),typeOperator:W(hn),controlOperator:W(hn),punctuation:ld,separator:W(ld),bracket:Ps,angleBracket:W(Ps),squareBracket:W(Ps),paren:W(Ps),brace:W(Ps),content:pn,heading:Lo,heading1:W(Lo),heading2:W(Lo),heading3:W(Lo),heading4:W(Lo),heading5:W(Lo),heading6:W(Lo),contentSeparator:W(pn),list:W(pn),quote:W(pn),emphasis:W(pn),strong:W(pn),link:W(pn),monospace:W(pn),strikethrough:W(pn),inserted:W(),deleted:W(),changed:W(),invalid:W(),meta:Ol,documentMeta:W(Ol),annotation:W(Ol),processingInstruction:W(Ol),definition:Bt.defineModifier(),constant:Bt.defineModifier(),function:Bt.defineModifier(),standard:Bt.defineModifier(),local:Bt.defineModifier(),special:Bt.defineModifier()},Qte=ad([{tag:$.link,class:"tok-link"},{tag:$.heading,class:"tok-heading"},{tag:$.emphasis,class:"tok-emphasis"},{tag:$.strong,class:"tok-strong"},{tag:$.keyword,class:"tok-keyword"},{tag:$.atom,class:"tok-atom"},{tag:$.bool,class:"tok-bool"},{tag:$.url,class:"tok-url"},{tag:$.labelName,class:"tok-labelName"},{tag:$.inserted,class:"tok-inserted"},{tag:$.deleted,class:"tok-deleted"},{tag:$.literal,class:"tok-literal"},{tag:$.string,class:"tok-string"},{tag:$.number,class:"tok-number"},{tag:[$.regexp,$.escape,$.special($.string)],class:"tok-string2"},{tag:$.variableName,class:"tok-variableName"},{tag:$.local($.variableName),class:"tok-variableName tok-local"},{tag:$.definition($.variableName),class:"tok-variableName tok-definition"},{tag:$.special($.variableName),class:"tok-variableName2"},{tag:$.definition($.propertyName),class:"tok-propertyName tok-definition"},{tag:$.typeName,class:"tok-typeName"},{tag:$.namespace,class:"tok-namespace"},{tag:$.className,class:"tok-className"},{tag:$.macroName,class:"tok-macroName"},{tag:$.propertyName,class:"tok-propertyName"},{tag:$.operator,class:"tok-operator"},{tag:$.comment,class:"tok-comment"},{tag:$.meta,class:"tok-meta"},{tag:$.invalid,class:"tok-invalid"},{tag:$.punctuation,class:"tok-punctuation"}]);var cd,Er=new re;function VI(o){return oe.define({combine:o?e=>e.concat(o):void 0})}var $I=new re,Mt=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,he.prototype.hasOwnProperty("tree")||Object.defineProperty(he.prototype,"tree",{get(){return et(this)}}),this.parser=t,this.extension=[Pr.of(this),he.languageData.of((s,i,l)=>{let a=Ey(s,i,l),c=a.type.prop(Er);if(!c)return[];let u=s.facet(c),d=a.type.prop($I);if(d){let f=a.resolve(i-a.from,l);for(let h of d)if(h.test(f,s)){let p=s.facet(h.facet);return h.type=="replace"?p:p.concat(u)}}return u})].concat(n)}isActiveAt(e,t,n=-1){return Ey(e,t,n).type.prop(Er)==this.data}findRegions(e){let t=e.facet(Pr);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,i)=>{if(s.prop(Er)==this.data){n.push({from:i,to:i+s.length});return}let l=s.prop(re.mounted);if(l){if(l.tree.prop(Er)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+i,to:a.to+i});else n.push({from:i,to:i+s.length});return}else if(l.overlay){let a=n.length;if(r(l.tree,l.overlay[0].from+i),n.length>a)return}}for(let a=0;a<s.children.length;a++){let c=s.children[a];c instanceof pe&&r(c,s.positions[a]+i)}};return r(et(e),0),n}get allowsNesting(){return!0}};Mt.setState=we.define();function Ey(o,e,t){let n=o.facet(Pr),r=et(o).topNode;if(!n||n.allowsNesting)for(let s=r;s;s=s.enter(e,t,Ne.ExcludeBuffers))s.type.isTop&&(r=s);return r}var mn=class extends Mt{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=VI(e.languageData);return new mn(t,e.parser.configure({props:[Er.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new mn(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function et(o){let e=o.field(Mt.state,!1);return e?e.tree:pe.empty}var hd=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)}},Ds=null,Mr=class{constructor(e,t,n=[],r,s,i,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=i,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Mr(e,t,[],pe.empty,0,n,[],null)}startParse(){return this.parser.startParse(new hd(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=pe.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}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 r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(sn.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=r,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(sn.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Ds;Ds=this;try{return e()}finally{Ds=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=My(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:s,viewport:i,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((c,u,d,f)=>a.push({fromA:c,toA:u,fromB:d,toB:f})),n=sn.applyChanges(n,a),r=pe.empty,s=0,i={from:e.mapPos(i.from,-1),to:e.mapPos(i.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),d=e.mapPos(c.to,-1);u<d&&l.push({from:u,to:d})}}}return new Mr(this.parser,t,n,r,s,i,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:r,to:s}=this.skipped[n];r<e.to&&s>e.from&&(this.fragments=My(this.fragments,r,s),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 Kn{createParse(t,n,r){let s=r[0].from,i=r[r.length-1].to;return{parsedPos:s,advance(){let a=Ds;if(a){for(let c of r)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=i,new pe(Ve.none,[],[],i-s)},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 Ds}};function My(o,e,t){return sn.applyChanges(o,[{fromA:e,toA:t,fromB:e,toB:t}])}var Jn=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 Jn(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Mr.create(e.facet(Pr).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Jn(n)}};Mt.state=dt.define({create:Jn.init,update(o,e){for(let t of e.effects)if(t.is(Mt.setState))return t.value;return e.startState.facet(Pr)!=e.state.facet(Pr)?Jn.init(e.state):o.apply(e)}});var Iy=o=>{let e=setTimeout(()=>o(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Iy=o=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(o,{timeout:500-100})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var ud=typeof navigator<"u"&&(!((cd=navigator.scheduling)===null||cd===void 0)&&cd.isInputPending)?()=>navigator.scheduling.isInputPending():null,KI=Ft.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(Mt.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(Mt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Iy(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:r}}=this.view,s=n.field(Mt.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let i=Date.now()+Math.min(this.chunkBudget,100,e&&!ud?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&n.doc.length>r+1e3,a=s.context.work(()=>ud&&ud()||Date.now()>i,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Mt.setState.of(new Jn(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>un(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()}}}),Pr=oe.define({combine(o){return o.length?o[0]:null},enables:o=>[Mt.state,KI,se.contentAttributes.compute([o],e=>{let t=e.facet(o);return t&&t.name?{"data-language":t.name}:{}})]});var zI=oe.define(),Rs=oe.define({combine:o=>{if(!o.length)return" ";let e=o[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(o[0]));return e}});function As(o){let e=o.facet(Rs);return e.charCodeAt(0)==9?o.tabSize*e.length:e.length}function Ls(o,e){let t="",n=o.tabSize,r=o.facet(Rs)[0];if(r==" "){for(;e>=n;)t+=" ",e-=n;r=" "}for(let s=0;s<e;s++)t+=r;return t}function yd(o,e){o instanceof he&&(o=new No(o));for(let n of o.state.facet(zI)){let r=n(o,e);if(r!==void 0)return r}let t=et(o.state);return t?UI(o,t,e):null}var No=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=As(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.countColumn(n,e-r),i=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return i>-1&&(s+=i-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return Eo(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let i=s(r);if(i>-1)return i}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},WI=new re;function UI(o,e,t){return Ry(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,o)}function GI(o){return o.pos==o.options.simulateBreak&&o.options.simulateDoubleBreak}function _I(o){let e=o.type.prop(WI);if(e)return e;let t=o.firstChild,n;if(t&&(n=t.type.prop(re.closedBy))){let r=o.lastChild,s=r&&n.indexOf(r.name)>-1;return i=>XI(i,!0,1,void 0,s&&!GI(i)?r.from:void 0)}return o.parent==null?QI:null}function Ry(o,e,t){for(;o;o=o.parent){let n=_I(o);if(n)return n(Is.create(t,e,o))}return null}function QI(){return 0}var Is=class extends No{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 Is(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(qI(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){let e=this.node.parent;return e?Ry(e,this.pos,this.base):0}};function qI(o,e){for(let t=e;t;t=t.parent)if(o==t)return!0;return!1}function jI(o){let e=o.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let r=o.options.simulateBreak,s=o.state.doc.lineAt(t.from),i=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped)return a.from<i?t:null;l=a.to}}function XI(o,e,t,n,r){let s=o.textAfter,i=s.match(/^\s*/)[0].length,l=n&&s.slice(i,i+n.length)==n||r==o.pos+i,a=e?jI(o):null;return a?l?o.column(a.from):o.column(a.to):o.baseIndent+(l?0:o.unit*t)}var Yt=class{constructor(e,t){this.specs=e;let n;function r(l){let a=Ot.newName();return(n||(n=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,i=t.scope;this.scope=i instanceof Mt?l=>l.prop(Er)==i.data:i?l=>l==i:void 0,this.style=ad(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=n?new Ot(n):null,this.themeType=t.themeType}static define(e,t){return new Yt(e,t||{})}},pd=oe.define(),Ay=oe.define({combine(o){return o.length?[o[0]]:null}});function dd(o){let e=o.facet(pd);return e.length?e:o.facet(Ay)}function Ho(o,e){let t=[JI],n;return o instanceof Yt&&(o.module&&t.push(se.styleModule.of(o.module)),n=o.themeType),e!=null&&e.fallback?t.push(Ay.of(o)):n?t.push(pd.computeN([se.darkTheme],r=>r.facet(se.darkTheme)==(n=="dark")?[o]:[])):t.push(pd.of(o)),t}var md=class{constructor(e){this.markCache=Object.create(null),this.tree=et(e.state),this.decorations=this.buildDeco(e,dd(e.state))}update(e){let t=et(e.state),n=dd(e.state),r=n!=dd(e.startState);t.length<e.view.viewport.to&&!r&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n))}buildDeco(e,t){if(!t||!this.tree.length)return Ue.none;let n=new an;for(let{from:r,to:s}of e.visibleRanges)ky(this.tree,t,(i,l,a)=>{n.add(i,l,this.markCache[a]||(this.markCache[a]=Ue.mark({class:a})))},r,s);return n.finish()}},JI=To.high(Ft.fromClass(md,{decorations:o=>o.decorations})),xd=Yt.define([{tag:$.meta,color:"#404740"},{tag:$.link,textDecoration:"underline"},{tag:$.heading,textDecoration:"underline",fontWeight:"bold"},{tag:$.emphasis,fontStyle:"italic"},{tag:$.strong,fontWeight:"bold"},{tag:$.strikethrough,textDecoration:"line-through"},{tag:$.keyword,color:"#708"},{tag:[$.atom,$.bool,$.url,$.contentSeparator,$.labelName],color:"#219"},{tag:[$.literal,$.inserted],color:"#164"},{tag:[$.string,$.deleted],color:"#a11"},{tag:[$.regexp,$.escape,$.special($.string)],color:"#e40"},{tag:$.definition($.variableName),color:"#00f"},{tag:$.local($.variableName),color:"#30a"},{tag:[$.typeName,$.namespace],color:"#085"},{tag:$.className,color:"#167"},{tag:[$.special($.variableName),$.macroName],color:"#256"},{tag:$.definition($.propertyName),color:"#00c"},{tag:$.comment,color:"#940"},{tag:$.invalid,color:"#f00"}]);var YI=1e4,ZI="()[]{}";var eR=new re;function gd(o,e,t){let n=o.prop(e<0?re.openedBy:re.closedBy);if(n)return n;if(o.name.length==1){let r=t.indexOf(o.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function bd(o){let e=o.type.prop(eR);return e?e(o.node):o}function Fo(o,e,t,n={}){let r=n.maxScanDistance||YI,s=n.brackets||ZI,i=et(o),l=i.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=gd(a.type,t,s);if(c&&a.from<a.to){let u=bd(a);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return tR(o,e,t,a,u,c,s)}}return nR(o,e,t,i,l.type,r,s)}function tR(o,e,t,n,r,s,i){let l=n.parent,a={from:r.from,to:r.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&&s.indexOf(u.type.name)>-1&&u.from<u.to){let d=bd(u);return{start:a,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(gd(u.type,t,i))c++;else if(gd(u.type,-t,i)){if(c==0){let d=bd(u);return{start:a,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:a,matched:!1}}function nR(o,e,t,n,r,s,i){let l=t<0?o.sliceDoc(e-1,e):o.sliceDoc(e,e+1),a=i.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=o.doc.iterRange(e,t>0?o.doc.length:0),d=0;for(let f=0;!u.next().done&&f<=s;){let h=u.value;t<0&&(f+=h.length);let p=e+f*t;for(let m=t>0?0:h.length-1,g=t>0?h.length:-1;m!=g;m+=t){let y=i.indexOf(h[m]);if(!(y<0||n.resolveInner(p+m,1).type!=r))if(y%2==0==t>0)d++;else{if(d==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};d--}}t>0&&(f+=h.length)}return u.done?{start:c,matched:!1}:null}var oR=Object.create(null),Py=[Ve.none];var Dy=[],rR=Object.create(null);for(let[o,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"]])rR[o]=sR(oR,e);function fd(o,e){Dy.indexOf(o)>-1||(Dy.push(o),console.warn(e))}function sR(o,e){let t=null;for(let s of e.split(".")){let i=o[s]||$[s];i?typeof i=="function"?t?t=i(t):fd(s,`Modifier ${s} used at start of tag`):t?fd(s,`Tag ${s} used as modifier`):t=i:fd(s,`Unknown highlighting tag ${s}`)}if(!t)return 0;let n=e.replace(/ /g,"_"),r=Ve.define({id:Py.length,name:n,props:[Oo({[n]:t})]});return Py.push(r),r.id}var Nl={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Bo=we.define({map(o,e){let t=e.mapPos(o,-1,ot.TrackAfter);return t==null?void 0:t}}),vd=new class extends Xt{};vd.startSide=1;vd.endSide=-1;var Ny=dt.define({create(){return xe.empty},update(o,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)&&(o=xe.empty)}o=o.map(e.changes);for(let t of e.effects)t.is(Bo)&&(o=o.update({add:[vd.range(t.value,t.value+1)]}));return o}});function Sd(){return[cR,Ny]}var Cd="()[]{}<>";function iR(o){for(let e=0;e<Cd.length;e+=2)if(Cd.charCodeAt(e)==o)return Cd.charAt(e+1);return Og(o<128?o:o+1)}function lR(o,e){return o.languageDataAt("closeBrackets",e)[0]||Nl}var aR=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),cR=se.inputHandler.of((o,e,t,n)=>{if((aR?o.composing:o.compositionStarted)||o.state.readOnly)return!1;let r=o.state.selection.main;if(n.length>2||n.length==2&&Co(ln(n,0))==1||e!=r.from||t!=r.to)return!1;let s=uR(o.state,n);return s?(o.dispatch(s),!0):!1});function uR(o,e){let t=lR(o,o.selection.main.head),n=t.brackets||Nl.brackets;for(let r of n){let s=iR(ln(r,0));if(e==r)return s==r?hR(o,r,n.indexOf(r+r+r)>-1,t):dR(o,r,s,t.before||Nl.before);if(e==s&&Hy(o,o.selection.main.from))return fR(o,r,s)}return null}function Hy(o,e){let t=!1;return o.field(Ny).between(0,o.doc.length,n=>{n==e&&(t=!0)}),t}function wd(o,e){let t=o.sliceString(e,e+2);return t.slice(0,Co(ln(t,0)))}function dR(o,e,t,n){let r=null,s=o.changeByRange(i=>{if(!i.empty)return{changes:[{insert:e,from:i.from},{insert:t,from:i.to}],effects:Bo.of(i.to+e.length),range:B.range(i.anchor+e.length,i.head+e.length)};let l=wd(o.doc,i.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:i.head},effects:Bo.of(i.head+e.length),range:B.cursor(i.head+e.length)}:{range:r=i}});return r?null:o.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function fR(o,e,t){let n=null,r=o.changeByRange(s=>s.empty&&wd(o.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:B.cursor(s.head+t.length)}:n={range:s});return n?null:o.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function hR(o,e,t,n){let r=n.stringPrefixes||Nl.stringPrefixes,s=null,i=o.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Bo.of(l.to+e.length),range:B.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=wd(o.doc,a),u;if(c==e){if(Ly(o,a))return{changes:{insert:e+e,from:a},effects:Bo.of(a+e.length),range:B.cursor(a+e.length)};if(Hy(o,a)){let f=t&&o.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+f.length,insert:f},range:B.cursor(a+f.length)}}}else{if(t&&o.sliceDoc(a-2*e.length,a)==e+e&&(u=Oy(o,a-2*e.length,r))>-1&&Ly(o,u))return{changes:{insert:e+e+e+e,from:a},effects:Bo.of(a+e.length),range:B.cursor(a+e.length)};if(o.charCategorizer(a)(c)!=ut.Word&&Oy(o,a,r)>-1&&!pR(o,a,e,r))return{changes:{insert:e+e,from:a},effects:Bo.of(a+e.length),range:B.cursor(a+e.length)}}return{range:s=l}});return s?null:o.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function Ly(o,e){let t=et(o).resolveInner(e+1);return t.parent&&t.from==e}function pR(o,e,t,n){let r=et(o).resolveInner(e,-1),s=n.reduce((i,l)=>Math.max(i,l.length),0);for(let i=0;i<5;i++){let l=o.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let u=r.firstChild;for(;u&&u.from==r.from&&u.to-u.from>t.length+a;){if(o.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=r.to==e&&r.parent;if(!c)break;r=c}return!1}function Oy(o,e,t){let n=o.charCategorizer(e);if(n(o.sliceDoc(e-1,e))!=ut.Word)return e;for(let r of t){let s=e-r.length;if(o.sliceDoc(s,e)==r&&n(o.sliceDoc(s-1,s))!=ut.Word)return s}return-1}var mR=o=>{let{state:e}=o,t=e.doc.lineAt(e.selection.main.from),n=Id(o.state,t.from);return n.line?gR(o):n.block?yR(o):!1};function Dd(o,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=o(e,t);return r?(n(t.update(r)),!0):!1}}var gR=Dd(vR,0);var bR=Dd(Uy,0);var yR=Dd((o,e)=>Uy(o,e,CR(e)),0);function Id(o,e){let t=o.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var Os=50;function xR(o,{open:e,close:t},n,r){let s=o.sliceDoc(n-Os,n),i=o.sliceDoc(r,r+Os),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(i)[0].length,c=s.length-l;if(s.slice(c-e.length,c)==e&&i.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let u,d;r-n<=2*Os?u=d=o.sliceDoc(n,r):(u=o.sliceDoc(n,n+Os),d=o.sliceDoc(r-Os,r));let f=/^\s*/.exec(u)[0].length,h=/\s*$/.exec(d)[0].length,p=d.length-h-t.length;return u.slice(f,f+e.length)==e&&d.slice(p,p+t.length)==t?{open:{pos:n+f+e.length,margin:/\s/.test(u.charAt(f+e.length))?1:0},close:{pos:r-h-t.length,margin:/\s/.test(d.charAt(p-1))?1:0}}:null}function CR(o){let e=[];for(let t of o.selection.ranges){let n=o.doc.lineAt(t.from),r=t.to<=n.to?n:o.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=r.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return e}function Uy(o,e,t=e.selection.ranges){let n=t.map(s=>Id(e,s.from).block);if(!n.every(s=>s))return null;let r=t.map((s,i)=>xR(e,n[i],s.from,s.to));if(o!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,i)=>r[i]?[]:[{from:s.from,insert:n[i].open+" "},{from:s.to,insert:" "+n[i].close}]))};if(o!=1&&r.some(s=>s)){let s=[];for(let i=0,l;i<r.length;i++)if(l=r[i]){let a=n[i],{open:c,close:u}=l;s.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:s}}return null}function vR(o,e,t=e.selection.ranges){let n=[],r=-1;for(let{from:s,to:i}of t){let l=n.length,a=1e9,c=Id(e,s).line;if(c){for(let u=s;u<=i;){let d=e.doc.lineAt(u);if(d.from>r&&(s==i||i>d.from)){r=d.from;let f=/^\s*/.exec(d.text)[0].length,h=f==d.length,p=d.text.slice(f,f+c.length)==c?f:-1;f<d.text.length&&f<a&&(a=f),n.push({line:d,comment:p,token:c,indent:f,empty:h,single:!1})}u=d.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(o!=2&&n.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:c,empty:u,single:d}of n)(d||!u)&&s.push({from:l.from+c,insert:a+" "});let i=e.changes(s);return{changes:i,selection:e.selection.map(i,1)}}else if(o!=1&&n.some(s=>s.comment>=0)){let s=[];for(let{line:i,comment:l,token:a}of n)if(l>=0){let c=i.from+l,u=c+a.length;i.text[u-i.from]==" "&&u++,s.push({from:c,to:u})}return{changes:s}}return null}var kd=kt.define(),SR=kt.define(),wR=oe.define(),Gy=oe.define({combine(o){return ko(o,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}});function TR(o){let e=0;return o.iterChangedRanges((t,n)=>e=n),e}var _y=dt.define({create(){return $t.empty},update(o,e){let t=e.state.facet(Gy),n=e.annotation(kd);if(n){let a=e.docChanged?B.single(TR(e.changes)):void 0,c=st.fromTransaction(e,a),u=n.side,d=u==0?o.undone:o.done;return c?d=Fl(d,d.length,t.minDepth,c):d=jy(d,e.startState.selection),new $t(u==0?n.rest:d,u==0?d:n.rest)}let r=e.annotation(SR);if((r=="full"||r=="before")&&(o=o.isolate()),e.annotation(Ie.addToHistory)===!1)return e.changes.empty?o:o.addMapping(e.changes.desc);let s=st.fromTransaction(e),i=e.annotation(Ie.time),l=e.annotation(Ie.userEvent);return s?o=o.addChanges(s,i,l,t,e):e.selection&&(o=o.addSelection(e.startState.selection,i,l,t.newGroupDelay)),(r=="full"||r=="after")&&(o=o.isolate()),o},toJSON(o){return{done:o.done.map(e=>e.toJSON()),undone:o.undone.map(e=>e.toJSON())}},fromJSON(o){return new $t(o.done.map(st.fromJSON),o.undone.map(st.fromJSON))}});function Rd(o={}){return[_y,Gy.of(o),se.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?Qy:e.inputType=="historyRedo"?Ed:null;return n?(e.preventDefault(),n(t)):!1}})]}function Bl(o,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let r=t.field(_y,!1);if(!r)return!1;let s=r.pop(o,t,e);return s?(n(s),!0):!1}}var Qy=Bl(0,!1),Ed=Bl(1,!1),kR=Bl(0,!0),ER=Bl(1,!0);var st=class{constructor(e,t,n,r,s){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new st(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(r=>r.toJSON())}}static fromJSON(e){return new st(e.changes&&De.fromJSON(e.changes),[],e.mapped&&Tt.fromJSON(e.mapped),e.startSelection&&B.fromJSON(e.startSelection),e.selectionsAfter.map(B.fromJSON))}static fromTransaction(e,t){let n=Vt;for(let r of e.startState.facet(wR)){let s=r(e);s.length&&(n=n.concat(s))}return!n.length&&e.changes.empty?null:new st(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,Vt)}static selection(e){return new st(void 0,Vt,void 0,void 0,e)}};function Fl(o,e,t,n){let r=e+1>t+20?e-t-1:0,s=o.slice(r,e);return s.push(n),s}function MR(o,e){let t=[],n=!1;return o.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,i,l)=>{for(let a=0;a<t.length;){let c=t[a++],u=t[a++];l>=c&&i<=u&&(n=!0)}}),n}function PR(o,e){return o.ranges.length==e.ranges.length&&o.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function qy(o,e){return o.length?e.length?o.concat(e):o:e}var Vt=[],DR=200;function jy(o,e){if(o.length){let t=o[o.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-DR));return n.length&&n[n.length-1].eq(e)?o:(n.push(e),Fl(o,o.length-1,1e9,t.setSelAfter(n)))}else return[st.selection([e])]}function IR(o){let e=o[o.length-1],t=o.slice();return t[o.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Td(o,e){if(!o.length)return o;let t=o.length,n=Vt;for(;t;){let r=RR(o[t-1],e,n);if(r.changes&&!r.changes.empty||r.effects.length){let s=o.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,n=r.selectionsAfter}return n.length?[st.selection(n)]:Vt}function RR(o,e,t){let n=qy(o.selectionsAfter.length?o.selectionsAfter.map(l=>l.map(e)):Vt,t);if(!o.changes)return st.selection(n);let r=o.changes.map(e),s=e.mapDesc(o.changes,!0),i=o.mapped?o.mapped.composeDesc(s):s;return new st(r,we.mapEffects(o.effects,e),i,o.startSelection.map(s),n)}var AR=/^(input\.type|delete)($|\.)/,$t=class{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new $t(this.done,this.undone):this}addChanges(e,t,n,r,s){let i=this.done,l=i[i.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||AR.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,MR(l.changes,e.changes))||n=="input.type.compose")?i=Fl(i,i.length-1,r.minDepth,new st(e.changes.compose(l.changes),qy(e.effects,l.effects),l.mapped,l.startSelection,Vt)):i=Fl(i,i.length,r.minDepth,e),new $t(i,Vt,t,n)}addSelection(e,t,n,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Vt;return s.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&PR(s[s.length-1],e)?this:new $t(jy(this.done,e),this.undone,t,n)}addMapping(e){return new $t(Td(this.done,e),Td(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1];if(n&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:kd.of({side:e,rest:IR(r)}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let i=r.length==1?Vt:r.slice(0,r.length-1);return s.mapped&&(i=Td(i,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:kd.of({side:e,rest:i}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};$t.empty=new $t(Vt,Vt);var Ad=[{key:"Mod-z",run:Qy,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ed,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Ed,preventDefault:!0},{key:"Mod-u",run:kR,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ER,preventDefault:!0}];function Dr(o,e){return B.create(o.ranges.map(e),o.mainIndex)}function gn(o,e){return o.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Zt({state:o,dispatch:e},t){let n=Dr(o.selection,t);return n.eq(o.selection)?!1:(e(gn(o,n)),!0)}function Vl(o,e){return B.cursor(e?o.to:o.from)}function Xy(o,e){return Zt(o,t=>t.empty?o.moveByChar(t,e):Vl(t,e))}function it(o){return o.textDirectionAt(o.state.selection.main.head)==He.LTR}var Jy=o=>Xy(o,!it(o)),Yy=o=>Xy(o,it(o));function Zy(o,e){return Zt(o,t=>t.empty?o.moveByGroup(t,e):Vl(t,e))}var LR=o=>Zy(o,!it(o)),OR=o=>Zy(o,it(o));function NR(o,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(o.sliceDoc(e.from,e.to)))||e.firstChild}function $l(o,e,t){let n=et(o).resolveInner(e.head),r=t?re.closedBy:re.openedBy;for(let a=e.head;;){let c=t?n.childAfter(a):n.childBefore(a);if(!c)break;NR(o,c,r)?n=c:a=t?c.to:c.from}let s=n.type.prop(r),i,l;return s&&(i=t?Fo(o,n.from,1):Fo(o,n.to,-1))&&i.matched?l=t?i.end.to:i.end.from:l=t?n.to:n.from,B.cursor(l,t?-1:1)}var HR=o=>Zt(o,e=>$l(o.state,e,!it(o))),FR=o=>Zt(o,e=>$l(o.state,e,it(o)));function ex(o,e){return Zt(o,t=>{if(!t.empty)return Vl(t,e);let n=o.moveVertically(t,e);return n.head!=t.head?n:o.moveToLineBoundary(t,e)})}var tx=o=>ex(o,!1),nx=o=>ex(o,!0);function ox(o){let e=o.scrollDOM.clientHeight<o.scrollDOM.scrollHeight-2,t=0,n=0,r;if(e){for(let s of o.state.facet(se.scrollMargins)){let i=s(o);i!=null&&i.top&&(t=Math.max(i==null?void 0:i.top,t)),i!=null&&i.bottom&&(n=Math.max(i==null?void 0:i.bottom,n))}r=o.scrollDOM.clientHeight-t-n}else r=(o.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(o.defaultLineHeight,r-5)}}function rx(o,e){let t=ox(o),{state:n}=o,r=Dr(n.selection,i=>i.empty?o.moveVertically(i,e,t.height):Vl(i,e));if(r.eq(n.selection))return!1;let s;if(t.selfScroll){let i=o.coordsAtPos(n.selection.main.head),l=o.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;i&&i.top>a&&i.bottom<c&&(s=se.scrollIntoView(r.main.head,{y:"start",yMargin:i.top-a}))}return o.dispatch(gn(n,r),{effects:s}),!0}var Fy=o=>rx(o,!1),Md=o=>rx(o,!0);function Yn(o,e,t){let n=o.lineBlockAt(e.head),r=o.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?n.to:n.from)&&(r=o.moveToLineBoundary(e,t,!1)),!t&&r.head==n.from&&n.length){let s=/^\s*/.exec(o.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;s&&e.head!=n.from+s&&(r=B.cursor(n.from+s))}return r}var BR=o=>Zt(o,e=>Yn(o,e,!0)),VR=o=>Zt(o,e=>Yn(o,e,!1)),$R=o=>Zt(o,e=>Yn(o,e,!it(o))),KR=o=>Zt(o,e=>Yn(o,e,it(o))),zR=o=>Zt(o,e=>B.cursor(o.lineBlockAt(e.head).from,1)),WR=o=>Zt(o,e=>B.cursor(o.lineBlockAt(e.head).to,-1));function UR(o,e,t){let n=!1,r=Dr(o.selection,s=>{let i=Fo(o,s.head,-1)||Fo(o,s.head,1)||s.head>0&&Fo(o,s.head-1,1)||s.head<o.doc.length&&Fo(o,s.head+1,-1);if(!i||!i.end)return s;n=!0;let l=i.start.from==s.head?i.end.to:i.end.from;return t?B.range(s.anchor,l):B.cursor(l)});return n?(e(gn(o,r)),!0):!1}var GR=({state:o,dispatch:e})=>UR(o,e,!1);function Kt(o,e){let t=Dr(o.state.selection,n=>{let r=e(n);return B.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(o.state.selection)?!1:(o.dispatch(gn(o.state,t)),!0)}function sx(o,e){return Kt(o,t=>o.moveByChar(t,e))}var ix=o=>sx(o,!it(o)),lx=o=>sx(o,it(o));function ax(o,e){return Kt(o,t=>o.moveByGroup(t,e))}var _R=o=>ax(o,!it(o)),QR=o=>ax(o,it(o));var qR=o=>Kt(o,e=>$l(o.state,e,!it(o))),jR=o=>Kt(o,e=>$l(o.state,e,it(o)));function cx(o,e){return Kt(o,t=>o.moveVertically(t,e))}var ux=o=>cx(o,!1),dx=o=>cx(o,!0);function fx(o,e){return Kt(o,t=>o.moveVertically(t,e,ox(o).height))}var By=o=>fx(o,!1),Vy=o=>fx(o,!0),XR=o=>Kt(o,e=>Yn(o,e,!0)),JR=o=>Kt(o,e=>Yn(o,e,!1)),YR=o=>Kt(o,e=>Yn(o,e,!it(o))),ZR=o=>Kt(o,e=>Yn(o,e,it(o))),eA=o=>Kt(o,e=>B.cursor(o.lineBlockAt(e.head).from)),tA=o=>Kt(o,e=>B.cursor(o.lineBlockAt(e.head).to)),$y=({state:o,dispatch:e})=>(e(gn(o,{anchor:0})),!0),Ky=({state:o,dispatch:e})=>(e(gn(o,{anchor:o.doc.length})),!0),zy=({state:o,dispatch:e})=>(e(gn(o,{anchor:o.selection.main.anchor,head:0})),!0),Wy=({state:o,dispatch:e})=>(e(gn(o,{anchor:o.selection.main.anchor,head:o.doc.length})),!0),nA=({state:o,dispatch:e})=>(e(o.update({selection:{anchor:0,head:o.doc.length},userEvent:"select"})),!0),oA=({state:o,dispatch:e})=>{let t=zl(o).map(({from:n,to:r})=>B.range(n,Math.min(r+1,o.doc.length)));return e(o.update({selection:B.create(t),userEvent:"select"})),!0},rA=({state:o,dispatch:e})=>{let t=Dr(o.selection,n=>{var r;let s=et(o).resolveInner(n.head,1);for(;!(s.from<n.from&&s.to>=n.to||s.to>n.to&&s.from<=n.from||!(!((r=s.parent)===null||r===void 0)&&r.parent));)s=s.parent;return B.range(s.to,s.from)});return e(gn(o,t)),!0},sA=({state:o,dispatch:e})=>{let t=o.selection,n=null;return t.ranges.length>1?n=B.create([t.main]):t.main.empty||(n=B.create([B.cursor(t.main.head)])),n?(e(gn(o,n)),!0):!1};function Kl(o,e){if(o.state.readOnly)return!1;let t="delete.selection",{state:n}=o,r=n.changeByRange(s=>{let{from:i,to:l}=s;if(i==l){let a=e(i);a<i?(t="delete.backward",a=Hl(o,a,!1)):a>i&&(t="delete.forward",a=Hl(o,a,!0)),i=Math.min(i,a),l=Math.max(l,a)}else i=Hl(o,i,!1),l=Hl(o,l,!0);return i==l?{range:s}:{changes:{from:i,to:l},range:B.cursor(i)}});return r.changes.empty?!1:(o.dispatch(n.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?se.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function Hl(o,e,t){if(o instanceof se)for(let n of o.state.facet(se.atomicRanges).map(r=>r(o)))n.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var hx=(o,e)=>Kl(o,t=>{let{state:n}=o,r=n.doc.lineAt(t),s,i;if(!e&&t>r.from&&t<r.from+200&&!/[^ \t]/.test(s=r.text.slice(0,t-r.from))){if(s[s.length-1]==" ")return t-1;let l=Eo(s,n.tabSize),a=l%As(n)||As(n);for(let c=0;c<a&&s[s.length-1-c]==" ";c++)t--;i=t}else i=rt(r.text,t-r.from,e,e)+r.from,i==t&&r.number!=(e?n.doc.lines:1)&&(i+=e?1:-1);return i}),Pd=o=>hx(o,!1),px=o=>hx(o,!0),mx=(o,e)=>Kl(o,t=>{let n=t,{state:r}=o,s=r.doc.lineAt(n),i=r.charCategorizer(n);for(let l=null;;){if(n==(e?s.to:s.from)){n==t&&s.number!=(e?r.doc.lines:1)&&(n+=e?1:-1);break}let a=rt(s.text,n-s.from,e)+s.from,c=s.text.slice(Math.min(n,a)-s.from,Math.max(n,a)-s.from),u=i(c);if(l!=null&&u!=l)break;(c!=" "||n!=t)&&(l=u),n=a}return n}),gx=o=>mx(o,!1),iA=o=>mx(o,!0),bx=o=>Kl(o,e=>{let t=o.lineBlockAt(e).to;return e<t?t:Math.min(o.state.doc.length,e+1)}),lA=o=>Kl(o,e=>{let t=o.lineBlockAt(e).from;return e>t?t:Math.max(0,e-1)});var aA=({state:o,dispatch:e})=>{if(o.readOnly)return!1;let t=o.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:de.of(["",""])},range:B.cursor(n.from)}));return e(o.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},cA=({state:o,dispatch:e})=>{if(o.readOnly)return!1;let t=o.changeByRange(n=>{if(!n.empty||n.from==0||n.from==o.doc.length)return{range:n};let r=n.from,s=o.doc.lineAt(r),i=r==s.from?r-1:rt(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:rt(s.text,r-s.from,!0)+s.from;return{changes:{from:i,to:l,insert:o.doc.slice(r,l).append(o.doc.slice(i,r))},range:B.cursor(l)}});return t.changes.empty?!1:(e(o.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function zl(o){let e=[],t=-1;for(let n of o.selection.ranges){let r=o.doc.lineAt(n.from),s=o.doc.lineAt(n.to);if(!n.empty&&n.to==s.from&&(s=o.doc.lineAt(n.to-1)),t>=r.number){let i=e[e.length-1];i.to=s.to,i.ranges.push(n)}else e.push({from:r.from,to:s.to,ranges:[n]});t=s.number+1}return e}function yx(o,e,t){if(o.readOnly)return!1;let n=[],r=[];for(let s of zl(o)){if(t?s.to==o.doc.length:s.from==0)continue;let i=o.doc.lineAt(t?s.to+1:s.from-1),l=i.length+1;if(t){n.push({from:s.to,to:i.to},{from:s.from,insert:i.text+o.lineBreak});for(let a of s.ranges)r.push(B.range(Math.min(o.doc.length,a.anchor+l),Math.min(o.doc.length,a.head+l)))}else{n.push({from:i.from,to:s.from},{from:s.to,insert:o.lineBreak+i.text});for(let a of s.ranges)r.push(B.range(a.anchor-l,a.head-l))}}return n.length?(e(o.update({changes:n,scrollIntoView:!0,selection:B.create(r,o.selection.mainIndex),userEvent:"move.line"})),!0):!1}var uA=({state:o,dispatch:e})=>yx(o,e,!1),dA=({state:o,dispatch:e})=>yx(o,e,!0);function xx(o,e,t){if(o.readOnly)return!1;let n=[];for(let r of zl(o))t?n.push({from:r.from,insert:o.doc.slice(r.from,r.to)+o.lineBreak}):n.push({from:r.to,insert:o.lineBreak+o.doc.slice(r.from,r.to)});return e(o.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var fA=({state:o,dispatch:e})=>xx(o,e,!1),hA=({state:o,dispatch:e})=>xx(o,e,!0),pA=o=>{if(o.state.readOnly)return!1;let{state:e}=o,t=e.changes(zl(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),n=Dr(e.selection,r=>o.moveVertically(r,!0)).map(t);return o.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function mA(o,e){if(/\(\)|\[\]|\{\}/.test(o.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=et(o).resolveInner(e),n=t.childBefore(e),r=t.childAfter(e),s;return n&&r&&n.to<=e&&r.from>=e&&(s=n.type.prop(re.closedBy))&&s.indexOf(r.name)>-1&&o.doc.lineAt(n.to).from==o.doc.lineAt(r.from).from?{from:n.to,to:r.from}:null}var gA=Cx(!1),bA=Cx(!0);function Cx(o){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{let{from:s,to:i}=r,l=e.doc.lineAt(s),a=!o&&s==i&&mA(e,s);o&&(s=i=(i<=l.to?l:e.doc.lineAt(i)).to);let c=new No(e,{simulateBreak:s,simulateDoubleBreak:!!a}),u=yd(c,s);for(u==null&&(u=/^\s*/.exec(e.doc.lineAt(s).text)[0].length);i<l.to&&/\s/.test(l.text[i-l.from]);)i++;a?{from:s,to:i}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let d=["",Ls(e,u)];return a&&d.push(Ls(e,c.lineIndent(l.from,-1))),{changes:{from:s,to:i,insert:de.of(d)},range:B.cursor(s+1+d[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ld(o,e){let t=-1;return o.changeByRange(n=>{let r=[];for(let i=n.from;i<=n.to;){let l=o.doc.lineAt(i);l.number>t&&(n.empty||n.to>l.from)&&(e(l,r,n),t=l.number),i=l.to+1}let s=o.changes(r);return{changes:r,range:B.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}var yA=({state:o,dispatch:e})=>{if(o.readOnly)return!1;let t=Object.create(null),n=new No(o,{overrideIndentation:s=>{let i=t[s];return i==null?-1:i}}),r=Ld(o,(s,i,l)=>{let a=yd(n,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let c=/^\s*/.exec(s.text)[0],u=Ls(o,a);(c!=u||l.from<s.from+c.length)&&(t[s.from]=a,i.push({from:s.from,to:s.from+c.length,insert:u}))});return r.changes.empty||e(o.update(r,{userEvent:"indent"})),!0},xA=({state:o,dispatch:e})=>o.readOnly?!1:(e(o.update(Ld(o,(t,n)=>{n.push({from:t.from,insert:o.facet(Rs)})}),{userEvent:"input.indent"})),!0),CA=({state:o,dispatch:e})=>o.readOnly?!1:(e(o.update(Ld(o,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Eo(r,o.tabSize),i=0,l=Ls(o,Math.max(0,s-As(o)));for(;i<r.length&&i<l.length&&r.charCodeAt(i)==l.charCodeAt(i);)i++;n.push({from:t.from+i,to:t.from+r.length,insert:l.slice(i)})}),{userEvent:"delete.dedent"})),!0);var vA=[{key:"Ctrl-b",run:Jy,shift:ix,preventDefault:!0},{key:"Ctrl-f",run:Yy,shift:lx},{key:"Ctrl-p",run:tx,shift:ux},{key:"Ctrl-n",run:nx,shift:dx},{key:"Ctrl-a",run:zR,shift:eA},{key:"Ctrl-e",run:WR,shift:tA},{key:"Ctrl-d",run:px},{key:"Ctrl-h",run:Pd},{key:"Ctrl-k",run:bx},{key:"Ctrl-Alt-h",run:gx},{key:"Ctrl-o",run:aA},{key:"Ctrl-t",run:cA},{key:"Ctrl-v",run:Md}],SA=[{key:"ArrowLeft",run:Jy,shift:ix,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:LR,shift:_R,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:$R,shift:YR,preventDefault:!0},{key:"ArrowRight",run:Yy,shift:lx,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:OR,shift:QR,preventDefault:!0},{mac:"Cmd-ArrowRight",run:KR,shift:ZR,preventDefault:!0},{key:"ArrowUp",run:tx,shift:ux,preventDefault:!0},{mac:"Cmd-ArrowUp",run:$y,shift:zy},{mac:"Ctrl-ArrowUp",run:Fy,shift:By},{key:"ArrowDown",run:nx,shift:dx,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Ky,shift:Wy},{mac:"Ctrl-ArrowDown",run:Md,shift:Vy},{key:"PageUp",run:Fy,shift:By},{key:"PageDown",run:Md,shift:Vy},{key:"Home",run:VR,shift:JR,preventDefault:!0},{key:"Mod-Home",run:$y,shift:zy},{key:"End",run:BR,shift:XR,preventDefault:!0},{key:"Mod-End",run:Ky,shift:Wy},{key:"Enter",run:gA},{key:"Mod-a",run:nA},{key:"Backspace",run:Pd,shift:Pd},{key:"Delete",run:px},{key:"Mod-Backspace",mac:"Alt-Backspace",run:gx},{key:"Mod-Delete",mac:"Alt-Delete",run:iA},{mac:"Mod-Backspace",run:lA},{mac:"Mod-Delete",run:bx}].concat(vA.map(o=>({mac:o.key,run:o.run,shift:o.shift}))),Ns=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:HR,shift:qR},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:FR,shift:jR},{key:"Alt-ArrowUp",run:uA},{key:"Shift-Alt-ArrowUp",run:fA},{key:"Alt-ArrowDown",run:dA},{key:"Shift-Alt-ArrowDown",run:hA},{key:"Escape",run:sA},{key:"Mod-Enter",run:bA},{key:"Alt-l",mac:"Ctrl-l",run:oA},{key:"Mod-i",run:rA,preventDefault:!0},{key:"Mod-[",run:CA},{key:"Mod-]",run:xA},{key:"Mod-Alt-\\",run:yA},{key:"Shift-Mod-k",run:pA},{key:"Shift-Mod-\\",run:GR},{key:"Mod-/",run:mR},{key:"Alt-A",run:bR}].concat(SA);var wA=[...Ns,...Ad],vx=(()=>[rd(),Rd(),od(),Sd(),Ho(xd,{fallback:!0}),Ao.of(wA)])();import{isNumericColumn as Tne}from"@vuu-ui/vuu-utils";var Sx=[{label:"=",boost:10,type:"operator"},{label:"!=",boost:9,type:"operator"}],wx=[...Sx,{label:"in",boost:6,type:"operator"},{label:"starts",boost:5,type:"operator"},{label:"ends",boost:4,type:"operator"}],Tx=[...Sx,{label:">",boost:8,type:"operator"},{label:"<",boost:7,type:"operator"}];import{createEl as Doe}from"@vuu-ui/vuu-utils";import{useEffect as Aoe,useMemo as Loe,useRef as Ooe}from"react";var Rr=class{constructor(e,t,n,r,s,i,l,a,c,u=0,d){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=s,this.score=i,this.buffer=l,this.bufferBase=a,this.curContext=c,this.lookAhead=u,this.parent=d}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 r=e.parser.context;return new Rr(e,[],t,n,n,0,[],0,r?new Wl(r,r.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,r=e&65535,{parser:s}=this.p,i=s.dynamicPrecedence(r);if(i&&(this.score+=i),n==0){this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,4,!0),this.reduceContext(r,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[r])===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,d=this.bufferBase+this.buffer.length-u;if(r<s.minRepeatTerm||e&131072){let f=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,a,f,d+4,!0)}if(e&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=s.getGoto(f,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,a)}storeNode(e,t,n,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let i=this,l=this.buffer.length;if(l==0&&i.parent&&(l=i.bufferBase-i.parent.bufferBase,i=i.parent),l>0&&i.buffer[l-4]==0&&i.buffer[l-1]>-1){if(t==n)return;if(i.buffer[l-2]>=t){i.buffer[l-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&this.buffer[i-4]!=0)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4);this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n){let r=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=n,this.shiftContext(t,r),t<=this.p.parser.maxNode&&this.buffer.push(t,r,n,4);else{let s=e,{parser:i}=this.p;(n>this.pos||t<=i.maxNode)&&(this.pos=n,i.stateFlag(s,1)||(this.reducePos=n)),this.pushState(s,r),this.shiftContext(t,r),t<=i.maxNode&&this.buffer.push(t,r,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 r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,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),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new Rr(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,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 Nd(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 r=[];for(let s=0,i;s<t.length;s+=2)(i=t[s+1])!=this.state&&this.p.parser.hasAction(i,e)&&r.push(t[s],i);if(this.stack.length<120)for(let s=0;r.length<4<<1&&s<t.length;s+=2){let i=t[s+1];r.some((l,a)=>a&1&&l==i)||r.push(t[s],i)}t=r}let n=[];for(let r=0;r<t.length&&n.length<4;r+=2){let s=t[r+1];if(s==this.state)continue;let i=this.split();i.pushState(s,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[r],this.pos),i.score-=200,n.push(i)}return n}forceReduce(){let e=this.p.parser.stateSlot(this.state,5);if(!(e&65536))return!1;let{parser:t}=this.p;if(!t.validAction(this.state,e)){let n=e>>19,r=e&65535,s=this.stack.length-n*3;if(s<0||t.getGoto(this.stack[s],r,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!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.reducePos,this.reducePos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.reducePos,this.reducePos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Wl(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()}},Wl=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},Dx;(function(o){o[o.Insert=200]="Insert",o[o.Delete=190]="Delete",o[o.Reduce=100]="Reduce",o[o.MaxNext=4]="MaxNext",o[o.MaxInsertStackDepth=300]="MaxInsertStackDepth",o[o.DampenInsertStackDepth=120]="DampenInsertStackDepth",o[o.MinBigReduction=2e3]="MinBigReduction"})(Dx||(Dx={}));var Nd=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 r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},Ar=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 Ar(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 Ar(this.stack,this.pos,this.index)}};function Hs(o,e=Uint16Array){if(typeof o!="string")return o;let t=null;for(let n=0,r=0;n<o.length;){let s=0;for(;;){let i=o.charCodeAt(n++),l=!1;if(i==126){s=65535;break}i>=92&&i--,i>=34&&i--;let a=i-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}t?t[r++]=s:t=new e(s)}return t}var Ir=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},Ix=new Ir,Hd=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=Ix,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,r=this.rangeIndex,s=this.pos+e;for(;s<n.from;){if(!r)return null;let i=this.ranges[--r];s-=n.from-i.to,n=i}for(;t<0?s>n.to:s>=n.to;){if(r==this.ranges.length-1)return null;let i=this.ranges[++r];s+=i.from-n.to,n=i}return s}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,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(n=s,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let i=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++i];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}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=Ix,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 r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},Zn=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;Fx(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};Zn.prototype.contextual=Zn.prototype.fallback=Zn.prototype.extend=!1;var Fd=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?Hs(e):e}token(e,t){let n=e.pos,r=0;for(;Fx(this.data,e,t,0,this.data,this.precTable),!(e.token.value>-1);){if(this.elseToken==null)return;if(e.next<0)break;e.advance(),e.reset(e.pos,e.token),r++}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};Fd.prototype.contextual=Zn.prototype.fallback=Zn.prototype.extend=!1;function Fx(o,e,t,n,r,s){let i=0,l=1<<n,{dialect:a}=t.p.parser;e:for(;l&o[i];){let c=o[i+1];for(let h=i+3;h<c;h+=2)if((o[h+1]&l)>0){let p=o[h];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||TA(p,e.token.value,r,s))){e.acceptToken(p);break}}let u=e.next,d=0,f=o[i+2];if(e.next<0&&f>d&&o[c+f*3-3]==65535&&o[c+f*3-3]==65535){i=o[c+f*3-1];continue e}for(;d<f;){let h=d+f>>1,p=c+h+(h<<1),m=o[p],g=o[p+1]||65536;if(u<m)f=h;else if(u>=g)d=h+1;else{i=o[p+2],e.advance();continue e}}break}}function Rx(o,e,t){for(let n=e,r;(r=o[n])!=65535;n++)if(r==t)return n-e;return-1}function TA(o,e,t,n){let r=Rx(t,n,e);return r<0||Rx(t,n,o)<r}var en=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),Od=null,Ax;(function(o){o[o.Margin=25]="Margin"})(Ax||(Ax={}));function Lx(o,e,t){let n=o.cursor(Ne.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(o.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:o.length}}var Bd=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?Lx(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Lx(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],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=n.children[r],i=this.start[t]+n.positions[r];if(i>e)return this.nextStart=i,null;if(s instanceof pe){if(i==e){if(i<this.safeFrom)return null;let l=i+s.length;if(l<=this.safeTo){let a=s.prop(re.lookAhead);if(!a||l+a<this.fragment.to)return s}}this.index[t]++,i+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(i),this.index.push(0))}else this.index[t]++,this.nextStart=i+s.length}}},Vd=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Ir)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:s}=r,i=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let c=0;c<s.length;c++){if(!(1<<c&i))continue;let u=s[c],d=this.tokens[c];if(!(n&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=i||d.context!=l)&&(this.updateCachedToken(d,u,e),d.mask=i,d.context=l),d.lookAhead>d.end+25&&(a=Math.max(d.lookAhead,a)),d.value!=0)){let f=t;if(d.extended>-1&&(t=this.addActions(e,d.extended,d.end,t)),t=this.addActions(e,d.value,d.end,t),!u.extend&&(n=d,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Ir,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 Ir,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:s}=n.p;for(let i=0;i<s.specialized.length;i++)if(s.specialized[i]==e.value){let l=s.specializers[i](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(r+1)}putAction(e,t,n,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:s}=e,{parser:i}=e.p,{data:l}=i;for(let a=0;a<2;a++)for(let c=i.stateSlot(s,a?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=On(l,c+2);else{r==0&&l[c+1]==2&&(r=this.putAction(On(l,c+2),t,n,r));break}l[c]==t&&(r=this.putAction(On(l,c+1),t,n,r))}return r}},Ox;(function(o){o[o.Distance=5]="Distance",o[o.MaxRemainingPerStep=3]="MaxRemainingPerStep",o[o.MinBufferLengthPrune=500]="MinBufferLengthPrune",o[o.ForceReduceLimit=10]="ForceReduceLimit",o[o.CutDepth=15e3]="CutDepth",o[o.CutTo=9e3]="CutTo",o[o.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",o[o.MaxStackCount=12]="MaxStackCount"})(Ox||(Ox={}));var $d=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,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 Hd(t,r),this.tokens=new Vd(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[Rr.start(this,e.top[0],s)],this.fragments=n.length&&this.stream.end-s>e.bufferLength*4?new Bd(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[i]=e;for(;i.forceReduce()&&i.stack.length&&i.stack[i.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let i=0;i<e.length;i++){let l=e[i];for(;;){if(this.tokens.mainToken=null,l.pos>t)n.push(l);else{if(this.advanceStack(l,n,e))continue;{r||(r=[],s=[]),r.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!n.length){let i=r&&kA(r);if(i)return this.stackToTree(i);if(this.parser.strict)throw en&&r&&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&&r){let i=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,n);if(i)return this.stackToTree(i.forceAll())}if(this.recovering){let i=this.recovering==1?1:this.recovering*3;if(n.length>i)for(n.sort((l,a)=>a.score-l.score);n.length>i;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let i=0;i<n.length-1;i++){let l=n[i];for(let a=i+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(i--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let i=1;i<n.length;i++)n[i].pos<this.minStackPos&&(this.minStackPos=n[i].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 r=e.pos,{parser:s}=this,i=en?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>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 d=this.fragments.nodeAt(r);d;){let f=this.parser.nodeSet.types[d.type.id]==d.type?s.getGoto(e.state,d.type.id):-1;if(f>-1&&d.length&&(!c||(d.prop(re.contextHash)||0)==u))return e.useNode(d,f),en&&console.log(i+this.stackID(e)+` (via reuse of ${s.getName(d.type.id)})`),!0;if(!(d instanceof pe)||d.children.length==0||d.positions[0]>0)break;let h=d.children[0];if(h instanceof pe&&d.positions[0]==0)d=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),en&&console.log(i+this.stackID(e)+` (via always-reduce ${s.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++],d=a[c++],f=a[c++],h=c==a.length||!n,p=h?e:e.split();if(p.apply(u,d,f),en&&console.log(i+this.stackID(p)+` (via ${u&65536?`reduce of ${s.getName(u&65535)}`:"shift"} for ${s.getName(d)} @ ${r}${p==e?"":", split"})`),h)return!0;p.pos>r?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 Nx(e,t),!0}}runRecovery(e,t,n){let r=null,s=!1;for(let i=0;i<e.length;i++){let l=e[i],a=t[i<<1],c=t[(i<<1)+1],u=en?this.stackID(l)+" -> ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),en&&console.log(u+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let d=l.split(),f=u;for(let h=0;d.forceReduce()&&h<10&&(en&&console.log(f+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,n));h++)en&&(f=this.stackID(d)+" -> ");for(let h of l.recoverByInsert(a))en&&console.log(u+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,n);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),en&&console.log(u+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Nx(l,n)):(!r||r.score<l.score)&&(r=l)}return r}stackToTree(e){return e.close(),pe.build({buffer:Ar.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=(Od||(Od=new WeakMap)).get(e);return t||Od.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function Nx(o,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==o.pos&&n.sameState(o)){e[t].score<o.score&&(e[t]=o);return}}e.push(o)}var Kd=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}};var Vo=class extends Kn{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]),r=[];for(let l=0;l<t.length;l++)r.push([]);function s(l,a,c){r[l].push([a,a.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=re[a]);for(let c=1;c<l.length;){let u=l[c++];if(u>=0)s(u,a,l[c++]);else{let d=l[c+-u];for(let f=-u;f>0;f--)s(l[c++],a,d);c++}}}this.nodeSet=new Tn(t.map((l,a)=>Ve.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:r[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 i=Hs(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(Hx),this.states=Hs(e.states,Uint32Array),this.data=Hs(e.stateData),this.goto=Hs(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new Zn(i,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 r=new $d(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let i=r[s++],l=i&1,a=r[s++];if(l&&n)return a;for(let c=s+(i>>1);s<c;s++)if(r[s]==e)return a;if(l)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),i;;s+=3){if((i=n[s])==65535)if(n[s+1]==1)i=n[s=On(n,s+2)];else{if(n[s+1]==2)return On(n,s+2);break}if(i==t||i==0)return On(n,s+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){if(t==this.stateSlot(e,4))return!0;for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=On(this.data,n+2);else return!1;if(t==On(this.data,n+1))return!0}}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=On(this.data,n+2);else break;if(!(this.data[n+2]&1)){let r=this.data[n+1];t.some((s,i)=>i&1&&s==r)||t.push(this.data[n],r)}}return t}configure(e){let t=Object.assign(Object.create(Vo.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 r=e.tokenizers.find(s=>s.from==n);return r?r.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let s=e.specializers.find(l=>l.from==n.external);if(!s)return n;let i=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[r]=Hx(i),i})),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 s of e.split(" ")){let i=t.indexOf(s);i>=0&&(n[i]=!0)}let r=null;for(let s=0;s<t.length;s++)if(!n[s])for(let i=this.dialects[t[s]],l;(l=this.data[i++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[l]=1;return new Kd(e,n,r)}static deserialize(e){return new Vo(e)}};function On(o,e){return o[e]|o[e+1]<<16}function kA(o){let e=null;for(let t of o){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 Hx(o){if(o.external){let e=o.extend?1:0;return(t,n)=>o.external(t,n)<<1|e}return o.get}var Ul=Vo.deserialize({version:14,states:"&fOVQPOOO!SQPO'#C^OVQPO'#CcQ!pQPOOO#OQPO'#CkO#TQPO'#CrOOQO'#Cy'#CyO#YQPO,58}OVQPO,59QOVQPO,59QOVQPO,59VOVQPO'#CtOOQO,59^,59^OOQO1G.i1G.iOOQO1G.l1G.lO#kQPO1G.lO$fQPO'#CmO%WQQO1G.qOOQO'#C{'#C{O%cQPO,59`OOQO'#Cn'#CnO%wQPO,59XOVQPO,59ZOVQPO,59[OVQPO7+$]OVQPO'#CuO&`QPO1G.zOOQO1G.z1G.zO&hQQO'#C^O&rQQO1G.sO'ZQQO1G.uOOQO1G.v1G.vO'fQPO<<GwO'wQPO,59aOOQO-E6s-E6sOOQO7+$f7+$fOVQPOAN=cO(]QQO1G.lO(tQPOG22}OOQOLD(iLD(iO%wQPO,59QO%wQPO,59Q",stateData:")[~OlOS~ORUOSUOTUOUUOWQO`SOnPO~OWgXZQX[QX]QX^QXeQX~OjQXXQXpQXqQXrQXsQXtQXuQX~PnOZWO[WO]XO^XO~OWYO~OWZO~OX]OZWO[WO]XO^XO~OZWO[WO]Yi^YijYiXYipYiqYirYisYitYiuYieYi~OZWO[WO]XO^XOpdOqdOrdOsdOtdOudO~OehOvfOwgO~OXkOZWO[WO]XO^XOeiO~ORUOSUOTUOUUOWQO`SOnlO~OXsOeiO~OvQXwQX~PnOZxO[xO]yO^yOeaivaiwai~OwgOecivci~OZWO[WO]XO^XOetO~OZWO[WO]XO^XOXiaeia~OZxO[xO]Yi^YieYivYiwYi~OXwOZWO[WO]XO^XO~O`UTn~",goto:"#spPPqPPPPqPPqPPPPqP!R!W!R!RPq!Z!k!nPPP!tP#jmUOQWXYZefghitxyVbYfgRe`mTOQWXYZefghitxyR[TQjcRrjQROQVQS^WxQ_XU`YfgQcZQmeQphQqiQuyRvtQaYQnfRog",nodeNames:"\u26A0 ColumnDefinitionExpression Column Number String True False ParenthesizedExpression OpenBrace CloseBrace ArithmeticExpression Divide Times Plus Minus ConditionalExpression If RelationalExpression RelationalOperator AndCondition OrCondition Comma CallExpression Function ArgList",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:".^~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$jz{$o{|$t|}$y}!O%O!O!P%T!P!Q%c!Q![%h!^!_%s!_!`&Q!`!a&V!c!}&d#R#S&d#T#U&u#U#Y&d#Y#Z(Y#Z#]&d#]#^*j#^#c&d#c#d+f#d#h&d#h#i,b#i#o&d~#USl~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOu~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_OS~~$bP;=`<%l#m~$jOW~~$oOX~~$tO[~~$yO]~~%OOe~~%TO^~~%WP!Q![%Z~%`PR~!Q![%Z~%hOZ~~%mQR~!O!P%Z!Q![%h~%xPr~!_!`%{~&QOt~~&VOp~~&[Pq~!_!`&_~&dOs~P&iSnP!Q![&d!c!}&d#R#S&d#T#o&dR&zUnP!Q![&d!c!}&d#R#S&d#T#b&d#b#c'^#c#o&dR'cUnP!Q![&d!c!}&d#R#S&d#T#W&d#W#X'u#X#o&dR'|SvQnP!Q![&d!c!}&d#R#S&d#T#o&d~(_TnP!Q![&d!c!}&d#R#S&d#T#U(n#U#o&d~(sUnP!Q![&d!c!}&d#R#S&d#T#`&d#`#a)V#a#o&d~)[UnP!Q![&d!c!}&d#R#S&d#T#g&d#g#h)n#h#o&d~)sUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y*V#Y#o&d~*^SU~nP!Q![&d!c!}&d#R#S&d#T#o&d~*oUnP!Q![&d!c!}&d#R#S&d#T#Y&d#Y#Z+R#Z#o&d~+YS`~nP!Q![&d!c!}&d#R#S&d#T#o&dR+kUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g+}#g#o&dR,USwQnP!Q![&d!c!}&d#R#S&d#T#o&d~,gUnP!Q![&d!c!}&d#R#S&d#T#f&d#f#g,y#g#o&d~-OUnP!Q![&d!c!}&d#R#S&d#T#i&d#i#j-b#j#o&d~-gUnP!Q![&d!c!}&d#R#S&d#T#X&d#X#Y-y#Y#o&d~.QST~nP!Q![&d!c!}&d#R#S&d#T#o&d",tokenizers:[0,1],topRules:{ColumnDefinitionExpression:[0,1]},tokenPrec:375});var Gne=mn.define({name:"VuuColumnExpression",parser:Ul.configure({props:[Oo({Function:$.variableName,String:$.string,Or:$.emphasis,Operator:$.operator})]})});var zd=class{constructor(e){switch(this.value=e,typeof e){case"boolean":this.type="booleanLiteralExpression";break;case"number":this.type="numericLiteralExpression";break;default:this.type="stringLiteralExpression"}}toJSON(){return{type:this.type,value:this.value}}},Wd=class{constructor(e){this.type="colExpression";this.column=e}toJSON(){return{type:this.type,column:this.column}}},Bs,Ko,Bx=class{constructor(e="unknown"){vt(this,Bs,[{type:"unknown"},{type:"unknown"}]);vt(this,Ko,void 0);this.type="arithmeticExpression";_t(this,Ko,e)}get op(){return _(this,Ko)}set op(e){_t(this,Ko,e)}get expressions(){return _(this,Bs)}toJSON(){return{type:this.type,op:_(this,Ko),expressions:_(this,Bs)}}};Bs=new WeakMap,Ko=new WeakMap;var Hr,Ud=class{constructor(e){vt(this,Hr,[]);this.type="callExpression";this.functionName=e}get expressions(){return _(this,Hr)}get arguments(){return _(this,Hr)}toJSON(){return{type:this.type,functionName:this.functionName,arguments:_(this,Hr).map(e=>{var t;return(t=e.toJSON)==null?void 0:t.call(e)})}}};Hr=new WeakMap;var Vs,Fr,Or=class{constructor(){vt(this,Vs,[{type:"unknown"},{type:"unknown"}]);vt(this,Fr,"unknown");this.type="relationalExpression"}get op(){return _(this,Fr)}set op(e){_t(this,Fr,e)}get expressions(){return _(this,Vs)}toJSON(){return{type:this.type,op:_(this,Fr),expressions:_(this,Vs)}}};Vs=new WeakMap,Fr=new WeakMap;var $s,Br,Nr=class{constructor(e){vt(this,$s,[{type:"unknown"},{type:"unknown"}]);vt(this,Br,void 0);this.type="booleanCondition";_t(this,Br,e)}get op(){return _(this,Br)}get expressions(){return _(this,$s)}toJSON(){return{type:this.type,op:_(this,Br),expressions:_(this,$s).map(e=>{var t;return(t=e.toJSON)==null?void 0:t.call(e)})}}};$s=new WeakMap,Br=new WeakMap;var bn,Fs=class{constructor(e){vt(this,bn,void 0);this.type="conditionalExpression";_t(this,bn,[e?new Nr(e):new Or,{type:"unknown"},{type:"unknown"}])}get expressions(){return _(this,bn)}get condition(){return _(this,bn)[0]}get truthyExpression(){return _(this,bn)[1]}set truthyExpression(e){_(this,bn)[1]=e}get falsyExpression(){return _(this,bn)[2]}set falsyExpression(e){_(this,bn)[2]=e}toJSON(){var e,t,n,r,s;return{type:this.type,condition:(t=(e=this.condition).toJSON)==null?void 0:t.call(e),truthyExpression:this.truthyExpression,falsyExpression:(s=(r=(n=this.falsyExpression)==null?void 0:n.toJSON)==null?void 0:r.call(n))!=null?s:this.falsyExpression}}};bn=new WeakMap;var $o=o=>o.type==="unknown",Gl=o=>o.type==="arithmeticExpression",EA=o=>o.type==="callExpression",Lr=o=>o.type==="conditionalExpression",MA=o=>o.type==="relationalExpression"||o.type==="booleanCondition";var PA=o=>o.type==="booleanCondition",Gd=o=>(o==null?void 0:o.type)==="relationalExpression";var zt=o=>{if($o(o))return o;if(Gd(o)){let[e,t]=o.expressions;if(lt(e))return zt(e);if(o.op==="unknown")return o;if(lt(t))return zt(t)}else if(MA(o)){let{expressions:e=[]}=o;for(let t of e)if(lt(t))return zt(t)}else if(Lr(o)){let{condition:e,truthyExpression:t,falsyExpression:n}=o;if(lt(e))return zt(e);if(lt(t))return zt(t);if(lt(n))return zt(n)}else if(Gl(o)){let{expressions:e=[]}=o;for(let t of e)if(lt(t))return zt(t)}},_l=(o,e,t)=>{let{expressions:n=[]}=o;if(n.includes(e)){let r=n.indexOf(e);return n.splice(r,1,t),!0}else for(let r of n)if(_l(r,e,t))return!0;return!1},lt=o=>$o(o)?!0:Lr(o)?lt(o.condition)||lt(o.truthyExpression)||lt(o.falsyExpression):Gd(o)||PA(o)?o.op===void 0||o.expressions.some(e=>lt(e)):!1,Vx=(o,e)=>{let t=zt(o);t?t.expressions?t.expressions.push(e):console.warn("don't know how to treat targetExpression"):console.error("no target expression found")},fe,zo,$x=class{constructor(){vt(this,fe,void 0);vt(this,zo,[])}setCondition(e){if(_(this,fe)===void 0)this.addExpression(new Fs(e));else if(Lr(_(this,fe))){if(lt(_(this,fe).condition)){let t=e?new Nr(e):new Or;this.addExpression(t)}else if($o(_(this,fe).truthyExpression))_(this,fe).truthyExpression=new Fs(e);else if(lt(_(this,fe).truthyExpression)){let t=e?new Nr(e):new Or;this.addExpression(t)}else if($o(_(this,fe).falsyExpression))_(this,fe).falsyExpression=new Fs(e);else if(lt(_(this,fe).falsyExpression)){let t=e?new Nr(e):new Or;this.addExpression(t)}}else console.error("setCondition called unexpectedly")}addExpression(e){if(_(this,zo).length>0){let t=_(this,zo).at(-1);t==null||t.arguments.push(e)}else if(_(this,fe)===void 0)_t(this,fe,e);else if(Gl(_(this,fe))){let t=zt(_(this,fe));t&&$o(t)&&_l(_(this,fe),t,e)}else if(Lr(_(this,fe))&<(_(this,fe))){let t=zt(_(this,fe));t&&$o(t)?_l(_(this,fe),t,e):t&&Vx(t,e)}}setFunction(e){let t=new Ud(e);this.addExpression(t),_(this,zo).push(t)}setColumn(e){this.addExpression(new Wd(e))}setArithmeticOp(e){let t=e,n=_(this,fe);Gl(n)&&(n.op=t)}setRelationalOperator(e){let t=e;if(_(this,fe)&&Lr(_(this,fe))){let n=zt(_(this,fe));Gd(n)?n.op=t:console.error(`no target expression found (op = ${e})`)}}setValue(e){let t=new zd(e);if(_(this,fe)===void 0)_t(this,fe,t);else if(Gl(_(this,fe)))this.addExpression(t);else if(EA(_(this,fe)))_(this,fe).arguments.push(t);else if(Lr(_(this,fe)))if(lt(_(this,fe))){let n=zt(_(this,fe));n&&$o(n)?_l(_(this,fe),n,t):n&&Vx(n,t)}else console.log("what do we do with value, in a complete expression")}closeBrace(){_(this,zo).pop()}get expression(){return _(this,fe)}toJSON(){var e;return(e=_(this,fe))==null?void 0:e.toJSON()}};fe=new WeakMap,zo=new WeakMap;var Xne=Ul.configure({strict:!0}),DA=["Number","String"],IA=[...DA,"AndCondition","ArithmeticExpression","BooleanOperator","RelationalOperatorOperator","CallExpression","CloseBrace","Column","Comma","ConditionalExpression","Divide","Equal","If","Minus","OpenBrace","OrCondition","ParenthesizedExpression","Plus","RelationalExpression","RelationalOperator","Times"];var RA=Yt.define([{tag:$.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:$.comment,color:"green",fontStyle:"italic"}]),AA=Ho(RA);var LA=se.theme({"&":{border:"solid 1px var(--salt-container-primary-borderColor)",color:"var(--vuuFilterEditor-color)",backgroundColor:"var(--vuuFilterEditor-background)"},".cm-content":{caretColor:"var(--vuuFilterEditor-cursorColor)"},"&.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":{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-tooltip-autocomplete li .cm-completionDetail":{color:"var(--vuuFilterEditor-suggestion-detailColor)"}}},{dark:!1});import{useCallback as xoe}from"react";import{jsx as Xoe}from"react/jsx-runtime";import{isNumericColumn as lre,isTextColumn as are}from"@vuu-ui/vuu-utils";import{useCallback as ure,useRef as dre}from"react";var Kx=[{accepts:"string",description:"Returns multiple string values as a single joined string. Arguments may be string literal values, string columns or other string expressions. Non string arguments may also be included, these will be converted to strings.",example:{expression:'concatenate("example", "-test")',result:'"example-test"'},name:"concatenate",params:{description:"( string, string, [ string* ] )"},type:"string"},{accepts:["string","string"],description:"Tests a string value to determine whether it contains a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> contains one or more occurrences of <target subscring>",example:{expression:'contains("Royal Bank of Scotland", "bank")',result:"true"},name:"contains",params:{description:"( string )"},type:"boolean"},{accepts:["string","number"],description:"Returns the leftmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",example:{expression:'left("USD Benchmark Report", 3)',result:'"USD"'},name:"left",params:{count:2,description:"( string, number )"},type:"string"},{accepts:"string",description:"Returns the number of characters in <string>. Argument may be a string literal, string column or other string expression.",example:{expression:'len("example")',result:"7"},name:"len",params:{description:"(string)"},type:"number"},{accepts:"string",description:"Convert a string value to lowercase. Argument may be a string column or other string expression.",example:{expression:'lower("examPLE")',result:'"example"'},name:"lower",params:{description:"( string )"},type:"string"},{accepts:"string",description:"Convert a string value to uppercase. Argument may be a string column or other string expression.",example:{expression:'upper("example")',result:'"EXAMPLE"'},name:"upper",params:{description:"( string )"},type:"string"},{accepts:["string","number"],description:"Returns the rightmost <number> characters from <string>. First argument may be a string literal, string column or other string expression.",example:{expression:"blah",result:"blah"},name:"right",params:{description:"( string )"},type:"string"},{accepts:["string","string","string"],description:"Replace characters within a string. Accepts three arguments: source text, text to replace and replacement text. Returns a copy of <source text> with any occurrences of <text to replace> replaced by <replacement text>",example:{expression:"blah",result:"blah"},name:"replace",params:{description:"( string )"},type:"string"},{accepts:"number",description:"Converts a number to a string.",example:{expression:"blah",result:"blah"},name:"text",params:{description:"( string )"},type:"string"},{accepts:"string",description:"Tests a string value to determine whether it starts with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> starts with <target subscring>.",example:{expression:"blah",result:"blah"},name:"starts",params:{description:"( string )"},type:"boolean"},{accepts:"string",description:"Tests a string value to determine whether it ends with a given substring. Accepts two arguments: source text and target substring. Returns true if <source text> ends with <target subscring>.",example:{expression:"blah",result:"blah"},name:"ends",params:{description:"( string )"},type:"boolean"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"min",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"max",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"sum",params:{description:"( string )"},type:"number"},{accepts:"number",description:"blah",example:{expression:"blah",result:"blah"},name:"round",params:{description:"( string )"},type:"number"},{accepts:"any",description:"blah",example:{expression:"blah",result:"blah"},name:"or",params:{description:"( string )"},type:"boolean"},{accepts:"any",description:"blah",example:{expression:"blah",result:"blah"},name:"and",params:{description:"( string )"},type:"boolean"},{accepts:"any",description:"Return one of two possible result values, depending on the evaluation of a filter expression. If <filterExpression> resolves to true, result is <expression1>, otherwise <expression2>. ",example:{expression:"blah",result:"blah"},name:"if",params:{description:"( filterExpression, expression1, expression 2)"},type:"variable"}];import{createEl as Nn}from"@vuu-ui/vuu-utils";var zx=({name:o,description:e,example:t,params:n,type:r})=>{let s=Nn("div","vuuFunctionDoc"),i=Nn("div","function-heading"),l=Nn("span","function-name",o),a=Nn("span","param-list",n.description),c=Nn("span","function-type",r);i.appendChild(l),i.appendChild(a),i.appendChild(c);let u=Nn("p",void 0,e);if(s.appendChild(i),s.appendChild(u),t){let d=Nn("div","example-container","Example:"),f=Nn("div","example-expression",t.expression),h=Nn("div","example-result",t.result);d.appendChild(f),d.appendChild(h),s.appendChild(d)}return s};var BA=o=>({apply:`${o.name}( `,boost:2,expressionType:o.type,info:()=>zx(o),label:o.name,type:"function"});var mre=Kx.map(BA);import{getCalculatedColumnDetails as wre,setCalculatedColumnExpression as Tre,setCalculatedColumnName as kre,setCalculatedColumnType as Ere}from"@vuu-ui/vuu-utils";import{useCallback as Dre,useRef as Ire,useState as Rre}from"react";import{jsx as Zre,jsxs as ese}from"react/jsx-runtime";import{jsx as Tse,jsxs as kse}from"react/jsx-runtime";import{useEffect as Ose,useState as Nse}from"react";import Fse from"classnames";import{jsx as Kse,jsxs as zse}from"react/jsx-runtime";var Vse=new Intl.NumberFormat;import{Button as fie,FormField as hie,FormFieldLabel as pie,Input as mie,ToggleButton as gie,ToggleButtonGroup as bie}from"@salt-ds/core";import{useLayoutEffectSkipFirst as Qse}from"@vuu-ui/vuu-layout";import{addColumnToSubscribedColumns as Xse,isCalculatedColumn as Jse,moveItem as Yse,subscribedOnly as Zse}from"@vuu-ui/vuu-utils";import{useCallback as oie,useMemo as rie,useState as sie}from"react";import{jsx as Sie,jsxs as wie}from"react/jsx-runtime";import{useLayoutProviderDispatch as VA}from"@vuu-ui/vuu-layout";import{getCalculatedColumnType as $A}from"@vuu-ui/vuu-utils";import{useCallback as Ks,useRef as KA,useState as zA}from"react";var Wx=({availableColumns:o,onAvailableColumnsChange:e,onConfigChange:t,onCreateCalculatedColumn:n,onDataSourceConfigChange:r,tableConfig:s})=>{let i=VA(),l=KA(),[a,c]=zA(o),u=Ks((p,m,g)=>{i({type:"set-props",path:"#context-panel",props:{expanded:!0,content:{type:p,props:g},title:m}})},[i]),d=Ks(p=>{let m=a.concat({name:p.name,serverDataType:$A(p)});c(m),e==null||e(m),requestAnimationFrame(()=>{var g;(g=l.current)==null||g.call(l)}),n(p)},[a,e,n]),f=Ks(p=>{u("ColumnSettings","Column Settings",{column:p.column,onConfigChange:t,onCreateCalculatedColumn:d,tableConfig:s,vuuTable:p.vuuTable})},[d,t,u,s]),h=Ks(()=>{f({column:{name:"::",serverDataType:"string"},type:"columnSettings",vuuTable:{module:"SIMUL",table:"instruments"}})},[f]);return l.current=Ks(()=>{u("TableSettings","DataGrid Settings",{availableColumns:a!=null?a:s.columns.map(({name:p,serverDataType:m})=>({name:p,serverDataType:m})),onAddCalculatedColumn:h,onConfigChange:t,onDataSourceConfigChange:r,tableConfig:s})},[a,h,t,r,u,s]),{showColumnSettingsPanel:f,showTableSettingsPanel:l.current}};import{useCallback as eo,useEffect as UA,useMemo as GA,useRef as qd}from"react";var _d=o=>`.vuuTableNext-col-headers .vuuTableNextHeaderCell:nth-child(${o})`,Qd=(o,e)=>`.vuuTableNext-body > [aria-rowindex='${o}'] > [role='cell']:nth-child(${e+1})`,Ux=(o,[e,t])=>{var s;let n=e===-1?_d(t):Qd(e,t),r=(s=o.current)==null?void 0:s.querySelector(n);return WA(r)&&r.querySelector("button")||r},WA=o=>o.classList.contains("vuuTableNextCell-editable"),Gx=o=>o.querySelector(".vuuTableInputCell")!==null;var _A=new Set(["Home","End","PageUp","PageDown","ArrowDown","ArrowLeft","ArrowRight","ArrowUp"]),QA=o=>_A.has(o),qA=["Home","End","PageUp","PageDown"],jA=o=>qA.includes(o),XA=[-1,-1],JA=[void 0,void 0],YA=o=>{var t,n;let e=(t=o.closest(".vuuTableNext"))==null?void 0:t.querySelector(".vuuTableNext-scrollbarContainer");if(e){let r=e==null?void 0:e.getBoundingClientRect(),s=(n=o.closest(".vuuTableNextCell"))==null?void 0:n.getBoundingClientRect();if(s)return s.bottom>r.bottom?["down",s.bottom-r.bottom]:s.top<r.top?["up",s.top-r.top]:s.right<r.right?["right",s.right-r.right]:s.left<r.left?["left",s.left-r.left]:JA;throw Error("Whats going on, cell not found")}else throw Error("Whats going on, scrollbar container not found")};function ZA(o,[e,t],n,r){return o==="ArrowUp"?e>-1?[e-1,t]:[e,t]:o==="ArrowDown"?e===-1?[0,t]:e===r-1?[e,t]:[e+1,t]:o==="ArrowRight"?t<n-1?[e,t+1]:[e,t]:o==="ArrowLeft"?t>1?[e,t-1]:[e,t]:[e,t]}var _x=({columnCount:o=0,containerRef:e,disableHighlightOnFocus:t,requestScroll:n,rowCount:r=0,viewportRowCount:s})=>{var C;let i=qd([-1,-1]),l=qd(),a=qd([-1,0]),c=b=>b==null?void 0:b.closest("[role='columnHeader'],[role='cell']"),u=b=>{var S,M;if(b.role==="columnHeader")return[-1,parseInt((S=b.dataset.idx)!=null?S:"-1",10)];{let w=b.closest("[role='row']");if(w){let k=parseInt((M=w.ariaRowIndex)!=null?M:"-1",10),L=Array.from(w.childNodes).indexOf(b);return[k,L]}}return XA},d=eo(b=>{var S;if(e.current){let M=Ux(e,b);if(M){M!==l.current&&((S=l.current)==null||S.removeAttribute("tabindex"),l.current=M,M.setAttribute("tabindex","0"));let[w,k]=YA(M);w&&k&&(n==null||n({type:"scroll-distance",distance:k,direction:w})),M.focus()}}},[e,n]),f=eo((b,S,M=!1)=>{let w=[b,S];a.current=w,d(w),M&&(i.current=w)},[d]),h=eo((b,[S,M])=>new Promise(w=>{let k=S;switch(b){case"PageDown":k=Math.min(r-1,S+s),n==null||n({type:"scroll-page",direction:"down"});break;case"PageUp":k=Math.max(0,S-s),n==null||n({type:"scroll-page",direction:"up"});break;case"Home":k=0,n==null||n({type:"scroll-end",direction:"home"});break;case"End":k=r-1,n==null||n({type:"scroll-end",direction:"end"});break}setTimeout(()=>{w([k,M])},90)}),[n,r,s]),p=eo(()=>{var b;if(t!==!0&&(b=e.current)!=null&&b.contains(document.activeElement)){let S=c(document.activeElement);S&&(console.log({focusedCell:S}),i.current=u(S))}},[t,e]),m=eo(async b=>{console.log(`navigate child items ${b}`);let[S,M]=jA(b)?await h(b,a.current):ZA(b,a.current,o,r);console.log(`nextRowIdx ${S} nextColIdx ${M}`);let[w,k]=a.current;(S!==w||M!==k)&&f(S,M,!0)},[o,h,r,f]),g=eo(b=>{r>0&&QA(b.key)&&(b.preventDefault(),b.stopPropagation(),m(b.key))},[r,m]),y=eo(b=>{let S=b.target,M=c(S);if(M){let[w,k]=u(M);f(w,k)}},[f]),E=eo(()=>{m("ArrowDown")},[m]),v=GA(()=>({navigate:E,onClick:y,onFocus:p,onKeyDown:g}),[y,p,g,E]),x=((C=e.current)==null?void 0:C.firstChild)!=null;return UA(()=>{if(x&&l.current===void 0){let{current:b}=e,S=(b==null?void 0:b.querySelector(_d(0)))||(b==null?void 0:b.querySelector(Qd(0,0)));S&&(S.setAttribute("tabindex","0"),l.current=S)}},[e,x]),v};import{applySort as GL,buildColumnMap as _L,isGroupColumn as QL,isJsonGroup as qL,isValidNumber as dC,metadataKeys as jL,updateColumn as XL,visibleColumnAtIndex as JL}from"@vuu-ui/vuu-utils";import{useCallback as qe,useEffect as fC,useMemo as Yd,useState as Zd}from"react";var Ql=(o,e)=>{switch(e.type){case"col-size":return{...o,columns:o.columns.map(t=>t.name===e.column.name?{...t,width:e.width}:t)};case"column-prop":return{...o,columns:o.columns.map(t=>t.name===e.column.name?{...t,[e.property]:e.value}:t)};default:return o}};import{getFullRange as jd,NULL_RANGE as Qx}from"@vuu-ui/vuu-utils";import{useCallback as Xd,useEffect as qx,useMemo as oL,useRef as jl,useState as rL}from"react";import{metadataKeys as eL,WindowRange as tL}from"@vuu-ui/vuu-utils";var{SELECTED:nL}=eL,ql=class{constructor({from:e,to:t}){this.rowCount=0;this.setRowCount=e=>{e<this.data.length&&(this.data.length=e),this.rowCount=e};this.range=new tL(e,t),this.data=new Array(t-e),this.rowCount=0}add(e){let[t]=e;if(this.isWithinRange(t)){let n=t-this.range.from;this.data[n]=e}}getAtIndex(e){return this.range.isWithin(e)&&this.data[e-this.range.from]!=null?this.data[e-this.range.from]:void 0}isWithinRange(e){return this.range.isWithin(e)}setRange({from:e,to:t}){if(e!==this.range.from||t!==this.range.to){let[n,r]=this.range.overlap(e,t),s=new Array(Math.max(0,t-e));for(let i=n;i<r;i++){let l=this.getAtIndex(i);if(l){let a=i-e;s[a]=l}}this.data=s,this.range.from=e,this.range.to=t}}getSelectedRows(){return this.data.filter(e=>e[nL]===1)}};var jx=({dataSource:o,onFeatureEnabled:e,onFeatureInvocation:t,onSizeChange:n,onSubscribed:r,range:s=Qx,renderBufferSize:i=0})=>{let[,l]=rL(null),a=jl([]),c=jl(!0),u=jl(!1),d=jl(Qx),f=oL(()=>new ql(jd(s,i)),[]),h=Xd(g=>{for(let y of g)f.add(y);a.current=f.data,c.current&&l({})},[f]),p=Xd(g=>{g.type==="subscribed"?r==null||r(g):g.type==="viewport-update"?(typeof g.size=="number"&&(n==null||n(g.size),f.setRowCount(g.size)),g.rows?h(g.rows):typeof g.size=="number"&&(a.current=f.data,u.current=!0)):Oc(g)?e==null||e(g):Nc(g)?t==null||t(g):console.log(`useDataSource unexpected message ${g.type}`)},[f,e,t,n,r,h]);qx(()=>()=>{c.current=!0,c.current=!1},[]),qx(()=>{o==null||o.subscribe({range:jd(s,i)},p)},[o,p,s,i]);let m=Xd(g=>{let y=jd(g,i);f.setRange(y),o.range=d.current=y,o.emit("range",g)},[o,f,i]);return{data:a.current,range:d.current,setRange:m}};import{useMemo as sL,useRef as iL}from"react";var Xx=o=>{let e=iL(o);return sL(()=>e.current,[])};import{buildColumnMap as lL}from"@vuu-ui/vuu-utils";import{useCallback as aL}from"react";var Jx=({columns:o,data:e})=>{let[t]=vn();return aL(r=>{var a;let s=r.target,i=s==null?void 0:s.closest("div[role='cell']"),l=s==null?void 0:s.closest("div[role='row']");if(i&&l){let c=lL(o),u=parseInt((a=l.ariaRowIndex)!=null?a:"-1"),d=Array.from(l.childNodes).indexOf(i),f=e.find(([p])=>p===u),h=o[d];t(r,"grid",{columnMap:c,columnName:h,row:f})}},[o,e,t])};import{isCharacterKey as cL}from"@vuu-ui/vuu-utils";import{useCallback as Xl}from"react";var Yx=({navigate:o})=>{let e=Xl(()=>{o()},[o]),t=Xl(s=>{let i=s.target,l=i.querySelector("input");l&&(l.focus(),l.select()),i.addEventListener("vuu-commit",e,!0)},[e]),n=Xl(s=>{let i=s.target,l=i.querySelector("input");l&&(l.focus(),l.select()),i.addEventListener("vuu-commit",e,!0)},[e]);return{onKeyDown:Xl(s=>{Gx(s.target)&&(cL(s.key)?t(s):s.key==="Enter"&&n(s))},[t,n])}};import{applyFilterToColumns as uL,applyGroupByToColumns as dL,applySortToColumns as fL,getCellRenderer as hL,getTableHeadings as pL,getValueFormatter as mL,hasValidationRules as gL,isFilteredColumn as bL,isGroupColumn as yL,isPinned as xL,isTypeDescriptor as CL,logger as vL,metadataKeys as SL,moveItem as wL,sortPinnedColumns as Zx,stripFilterFromColumns as TL,subscribedOnly as kL}from"@vuu-ui/vuu-utils";import{useReducer as EL}from"react";var{info:Jd}=vL("useTableModel"),ML=100,PL=SL.count,DL=({serverDataType:o})=>o===void 0,IL=o=>{var e;if(CL(o.type))return hL((e=o.type)==null?void 0:e.renderer)},RL=(o,e)=>{var n;let t=e.columns.find(({name:r})=>r===o.name);return t?t.serverDataType:(n=o.serverDataType)!=null?n:"string"},AL=["int","long","double"],eC=o=>o===void 0?void 0:AL.includes(o)?"right":"left",tC=o=>o.type==="columnSettings",nC=o=>o.type==="tableSettings",LL=(o,e)=>{switch(Jd==null||Jd(`TableModelReducer ${e.type}`),console.log(`TableModelReducer ${e.type}`),e.type){case"init":return console.log({init:e}),rC(e);case"moveColumn":return NL(o,e);case"resizeColumn":return BL(o,e);case"setTableSchema":return VL(o,e);case"hideColumns":return HL(o,e);case"showColumns":return FL(o,e);case"pinColumn":return $L(o,e);case"updateColumnProp":return $r(o,e);case"tableConfig":return iC(o,e);default:return console.log(`unhandled action ${e.type}`),o}},oC=(o,e)=>{let[t,n]=EL(LL,{tableConfig:o,dataSourceConfig:e},rC),{columns:r,headings:s,tableConfig:i,...l}=t;return{columns:r,dispatchColumnAction:n,headings:s,tableAttributes:l,tableConfig:i}};function rC({dataSourceConfig:o,tableConfig:e}){let{columns:t,...n}=e,r=t.filter(kL(o==null?void 0:o.columns)).map(sC(n)),s=r.some(xL)?Zx(r):r,i={columns:s,headings:pL(s),tableConfig:e,...n};if(o){let{columns:l,...a}=o;i=iC(i,{type:"tableConfig",...a})}return i}var OL=(o,e)=>e==="uppercase"?o.toUpperCase():e==="capitalize"?o[0].toUpperCase()+o.slice(1).toLowerCase():o,sC=o=>(e,t)=>{let{columnDefaultWidth:n=ML,columnFormatHeader:r}=o,{align:s=eC(e.serverDataType),key:i,name:l,label:a=l,width:c=n,...u}=e,d={...u,align:s,CellRenderer:IL(e),clientSideEditValidationCheck:gL(e.type)?fm(e.type.renderer.rules):void 0,label:OL(a,r),key:i!=null?i:t+PL,name:l,originalIdx:t,valueFormatter:mL(e),width:c};return yL(d)&&(d.columns=d.columns.map(f=>sC(o)(f,f.key))),d};function NL(o,{column:e,moveBy:t,moveTo:n}){let{columns:r}=o;if(typeof t=="number"){let s=r.indexOf(e),i=r.slice(),[l]=i.splice(s,1);return i.splice(s+t,0,l),{...o,columns:i}}else if(typeof n=="number"){let s=r.indexOf(e);return{...o,columns:wL(r,s,n)}}return o}function HL(o,{columns:e}){return e.some(t=>t.hidden!==!0)?e.reduce((t,n)=>n.hidden!==!0?$r(t,{type:"updateColumnProp",column:n,hidden:!0}):t,o):o}function FL(o,{columns:e}){return e.some(t=>t.hidden)?e.reduce((t,n)=>n.hidden?$r(t,{type:"updateColumnProp",column:n,hidden:!1}):t,o):o}function BL(o,{column:e,phase:t,width:n}){let r="updateColumnProp",s=t!=="end";switch(t){case"begin":return $r(o,{type:r,column:e,resizing:s});case"end":return $r(o,{type:r,column:e,resizing:s,width:n});case"resize":return $r(o,{type:r,column:e,width:n});default:throw Error(`useTableModel.resizeColumn, invalid resizePhase ${t}`)}}function VL(o,{tableSchema:e}){let{columns:t}=o;if(t.some(DL)){let n=t.map(r=>{var i;let s=RL(r,e);return{...r,align:(i=r.align)!=null?i:eC(s),serverDataType:s}});return{...o,columns:n}}else return o}function $L(o,e){let{columns:t}=o,{column:n,pin:r}=e,s=t.find(i=>i.name===n.name);return s?(t=Vr(t,{...s,pin:r}),t=Zx(t),{...o,columns:t}):o}function $r(o,e){let{columns:t}=o,{align:n,column:r,hidden:s,label:i,resizing:l,width:a}=e,c=t.find(u=>u.name===r.name);return c&&((n==="left"||n==="right")&&(t=Vr(t,{...c,align:n})),typeof i=="string"&&(t=Vr(t,{...c,label:i})),typeof l=="boolean"&&(t=Vr(t,{...c,resizing:l})),typeof s=="boolean"&&(t=Vr(t,{...c,hidden:s})),typeof a=="number"&&(t=Vr(t,{...c,width:a}))),{...o,columns:t}}function iC(o,{confirmed:e,filter:t,groupBy:n,sort:r}){let s=n!==void 0,i=typeof(t==null?void 0:t.filter)=="string",l=r&&r.sortDefs.length>0,a=o;return s&&(a={...o,columns:dL(a.columns,n,e)}),l&&(a={...o,columns:fL(a.columns,r)}),i?a={...o,columns:uL(a.columns,t)}:a.columns.some(bL)&&(a={...o,columns:TL(a.columns)}),a}function Vr(o,e){return o.map(t=>t.name===e.name?e:t)}import{useCallback as to,useRef as zs}from"react";var lC=o=>{let{scrollLeft:e,scrollTop:t}=o,{clientHeight:n,clientWidth:r,scrollHeight:s,scrollWidth:i}=o,l=e/(i-r),a=t/(s-n);return[l,a]},aC=({onAttach:o,onDetach:e})=>{let t=zs(null);return to(r=>{if(r)t.current=r,o==null||o(r);else if(t.current){let{current:s}=t;t.current=r,e==null||e(s)}},[o,e])},cC=({maxScrollLeft:o,maxScrollTop:e,onHorizontalScroll:t,onVerticalScroll:n,rowHeight:r,viewportRowCount:s})=>{let i=zs(!1),l=zs({scrollTop:0,scrollLeft:0}),a=zs(null),c=zs(null),u=to(()=>{let{current:v}=c,{current:x}=a,{current:C}=i;if(C)i.current=!1;else if(v&&x){let[b,S]=lC(x),M=Math.round(b*o),w=Math.round(S*e);v.scrollTo({left:M,top:w,behavior:"auto"})}},[o,e]),d=to(()=>{let{current:v}=c,{current:x}=a,{current:C}=l;if(v&&x){let{scrollLeft:b,scrollTop:S}=v,[M,w]=lC(v);i.current=!0,x.scrollLeft=Math.round(M*o),x.scrollTop=Math.round(w*e),C.scrollTop!==S&&(C.scrollTop=S,n==null||n(S,w)),C.scrollLeft!==b&&(C.scrollLeft=b,t==null||t(b))}},[o,e,t,n]),f=to(v=>{a.current=v,v.addEventListener("scroll",u,{passive:!0})},[u]),h=to(v=>{a.current=null,v.removeEventListener("scroll",u)},[u]),p=to(v=>{c.current=v,v.addEventListener("scroll",d,{passive:!0})},[d]),m=to(v=>{c.current=null,v.removeEventListener("scroll",d)},[d]),g=aC({onAttach:p,onDetach:m}),y=aC({onAttach:f,onDetach:h}),E=to(v=>{let{current:x}=c;if(x){let{scrollLeft:C,scrollTop:b}=x;if(i.current=!1,v.type==="scroll-distance"){let S=C,M=b;v.direction==="up"||v.direction==="down"?M=Math.min(Math.max(0,b+v.distance),e):S=Math.min(Math.max(0,C+v.distance),o),x.scrollTo({top:M,left:S,behavior:"auto"})}else if(v.type==="scroll-page"){let{direction:S}=v,M=s*(S==="down"?r:-r),w=Math.min(Math.max(0,b+M),e);x.scrollTo({top:w,left:C,behavior:"auto"})}else if(v.type==="scroll-end"){let{direction:S}=v,M=S==="end"?e:0;x.scrollTo({top:M,left:x.scrollLeft,behavior:"auto"})}}},[o,e,r,s]);return{scrollbarContainerRef:y,contentContainerRef:g,requestScroll:E}};import{useCallback as KL,useEffect as zL,useRef as WL}from"react";var uC=({columns:o,getRowAtPosition:e,setRange:t,viewportMeasurements:n})=>{let r=WL(0),{contentWidth:s,rowCount:i}=n,l=KL(a=>{let c=e(a);c!==r.current&&(r.current=c,t({from:c,to:c+i}))},[e,t,i]);return zL(()=>{let{current:a}=r,c={from:a,to:a+i};t(c)},[t,i]),{onVerticalScroll:l}};var{KEY:YL,IS_EXPANDED:hC,IS_LEAF:pC}=jL,ZL=(o,e)=>({...o,columns:o.columns.concat(e)}),mC=({availableColumns:o,config:e,containerRef:t,dataSource:n,headerHeight:r=25,onAvailableColumnsChange:s,onConfigChange:i,onFeatureEnabled:l,onFeatureInvocation:a,onRowClick:c,onSelectionChange:u,renderBufferSize:d=0,rowHeight:f=20,selectionModel:h})=>{let[p,m]=Zd(n.size);if(n===void 0)throw Error("no data source provided to Vuu Table");let[g,y]=Zd(),E=qe(H=>{y(H)},[]),v=Yd(()=>gc(n),[n]),x=qe(H=>{m(H)},[]),{columns:C,dispatchColumnAction:b,headings:S,tableAttributes:M,tableConfig:w}=oC(e,n.config);UL(()=>{b({type:"init",dataSourceConfig:n.config,tableConfig:w})},[w,n.config,b]);let[k,L]=Zd(),[T,P]=Yd(()=>{let H=(z,le)=>{let Se=XL(C,z,{width:le});L(Se)};return[k!=null?k:C,H]},[C,k]),R=Yd(()=>_L(n.columns),[n.columns]),{getRowAtPosition:O,getRowOffset:A,setPctScrollTop:D,...I}=Fc({columns:T,headerHeight:r,headings:S,rowCount:p,rowHeight:f,size:g}),F=Xx({from:0,to:I.rowCount}),N=qe(({tableSchema:H})=>{H||console.log("usbscription message with no schema")},[]),{data:V,range:K,setRange:G}=jx({dataSource:n,onFeatureEnabled:l,onFeatureInvocation:a,renderBufferSize:d,onSizeChange:x,onSubscribed:N,range:F}),Q=qe(H=>{console.log("useTableNext handleConfigChanged",{tableConfig:H}),b({type:"init",tableConfig:H,dataSourceConfig:n.config}),i==null||i(H)},[n.config,b,i]),X=qe(H=>{console.log("config changed",{dataSourceConfig:H}),n.config={...n.config,...H}},[n]),U=qe(H=>{console.log("useTableNext handleCreateCalculatedColumn",{column:H}),n.columns=n.columns.concat(H.name);let z=ZL(w,H);b({type:"init",tableConfig:z,dataSourceConfig:n.config}),i==null||i(z)},[n,b,i,w]);fC(()=>{n.on("config",(H,z)=>{b({type:"tableConfig",...H,confirmed:z})})},[n,b]);let{showColumnSettingsPanel:Y,showTableSettingsPanel:ce}=Wx({availableColumns:o!=null?o:w.columns.map(({name:H,serverDataType:z="string"})=>({name:H,serverDataType:z})),onAvailableColumnsChange:s,onConfigChange:Q,onCreateCalculatedColumn:U,onDataSourceConfigChange:X,tableConfig:w}),ie=qe(H=>{tC(H)?Y(H):nC(H)?ce():b(H)},[b,Y,ce]),Ae=yc({dataSource:n,onPersistentColumnOperation:ie}),me=qe((H,z=!1,le)=>{n&&(n.sort=GL(n.sort,H,z,le))},[n]),Me=qe((H,z,le)=>{let Se=T.find(mt=>mt.name===z);if(Se)H==="resize"?dC(le)&&P(z,le):H==="end"?dC(le)&&(b({type:"resizeColumn",phase:H,column:Se,width:le}),i==null||i(Ql(w,{type:"col-size",column:Se,width:le}))):(L(void 0),b({type:"resizeColumn",phase:H,column:Se,width:le}));else throw Error(`useDataTable.handleColumnResize, column ${z} not found`)},[T,w,b,i,P]),Ce=qe((H,z)=>{let le=qL(z,H),Se=H[YL];if(H[hC]){if(n.closeTreeNode(Se,!0),le){let mt=T.indexOf(z);n.getRowsAtDepth(mt+1).some(Ut=>Ut[hC]||Ut[pC])||b({type:"hideColumns",columns:T.slice(mt+2)})}}else if(n.openTreeNode(Se),le){let mt=n.getChildRows(Se),io=T.indexOf(z)+1,Ut=[T[io]];mt.some(qo=>qo[pC])&&Ut.push(T[io+1]),Ut.some(qo=>qo.hidden)&&b({type:"showColumns",columns:Ut})}},[T,n,b]),{onVerticalScroll:ke}=uC({columns:T,getRowAtPosition:O,setRange:G,viewportMeasurements:I}),je=qe(H=>{ke(H)},[ke]),{requestScroll:Ee,...Ge}=cC({maxScrollLeft:I.maxScrollContainerScrollHorizontal,maxScrollTop:I.maxScrollContainerScrollVertical,rowHeight:f,onVerticalScroll:je,viewportRowCount:I.rowCount}),{navigate:at,onKeyDown:ve,..._e}=_x({columnCount:T.filter(H=>H.hidden!==!0).length,containerRef:t,requestScroll:Ee,rowCount:n==null?void 0:n.size,viewportRange:K,viewportRowCount:I.rowCount}),{onKeyDown:q}=Yx({navigate:at}),ee=qe(H=>{ve(H),H.defaultPrevented||q(H)},[ve,q]),ne=Jx({columns:T,data:V}),ae=qe(H=>{var Ut;let le=H.target.closest(".vuuTableNextHeaderCell"),Se=parseInt((Ut=le==null?void 0:le.dataset.index)!=null?Ut:"-1"),mt=JL(T,Se),io=H.shiftKey;mt&&me(mt,io)},[T,me]),ye=qe(H=>{QL(H)?n.groupBy=[]:n&&n.groupBy.includes(H.name)&&(n.groupBy=n.groupBy.filter(z=>z!==H.name))},[n]),Le=qe(H=>{n.select(H),u==null||u(H)},[n,u]),ge=Hc({onSelectionChange:Le,selectionModel:h}),j=qe((H,z,le)=>{ge(H,z,le),c==null||c(H)},[c,ge]);fC(()=>{n.on("config",(H,z)=>{b({type:"tableConfig",...H,confirmed:z})})},[n,b]);let Z=qe((H,z)=>{let le=T[H];b({type:"moveColumn",column:le,moveTo:z})},[T,b]),te=qe((H,z,le)=>n.applyEdit(H,z,le),[n]),{onMouseDown:ue,...Oe}=fo({allowDragDrop:!0,containerRef:t,draggableClassName:"vuuTableNext",onDrop:Z,orientation:"horizontal",itemQuery:".vuuTableNextHeaderCell"});return{..._e,onKeyDown:ee,columnMap:R,columns:T,data:V,handleContextMenuAction:Ae,headerProps:{onClick:ae,onMouseDown:ue,onResize:Me},menuBuilder:v,onContextMenu:ne,onDataEdited:te,onRemoveGroupColumn:ye,onResize:E,onRowClick:j,onToggleGroup:Ce,scrollProps:Ge,tableAttributes:M,viewportMeasurements:I,dragDropHook:Oe}};import{MeasuredContainer as rO,useId as sO}from"@vuu-ui/vuu-layout";import{jsx as Wo,jsxs as ef}from"react/jsx-runtime";import{createElement as bC}from"react";var tn="vuuTableNext",{IDX:iO,RENDER_IDX:lO}=tO,tf=({Row:o=jc,availableColumns:e,className:t,config:n,dataSource:r,id:s,onAvailableColumnsChange:i,onConfigChange:l,onFeatureEnabled:a,onFeatureInvocation:c,onRowClick:u,onSelectionChange:d,onShowConfigEditor:f,renderBufferSize:h=0,rowHeight:p=20,selectionModel:m="extended",showColumnHeaders:g=!0,headerHeight:y=g?25:0,style:E,...v})=>{let x=sO(s),C=oO(null),{columnMap:b,columns:S,data:M,dragDropHook:w,handleContextMenuAction:k,headerProps:L,onDataEdited:T,onRemoveGroupColumn:P,onResize:R,onRowClick:O,onToggleGroup:A,menuBuilder:D,scrollProps:I,tableAttributes:F,viewportMeasurements:N,...V}=mC({availableColumns:e,config:n,containerRef:C,dataSource:r,headerHeight:y,onAvailableColumnsChange:i,onConfigChange:l,onFeatureEnabled:a,onFeatureInvocation:c,onRowClick:u,onSelectionChange:d,renderBufferSize:h,rowHeight:p,selectionModel:m}),K=()=>({...E,"--content-height":`${N.contentHeight}px`,"--horizontal-scrollbar-height":`${N.horizontalScrollbarHeight}px`,"--content-width":`${N.contentWidth}px`,"--pinned-width-left":`${N.pinnedWidthLeft}px`,"--pinned-width-right":`${N.pinnedWidthRight}px`,"--header-height":`${y}px`,"--row-height":`${p}px`,"--total-header-height":`${N.totalHeaderHeight}px`,"--vertical-scrollbar-width":`${N.verticalScrollbarWidth}px`,"--viewport-body-height":`${N.viewportBodyHeight}px`}),G=gC(tn,t,{[`${tn}-colLines`]:F.columnSeparators,[`${tn}-rowLines`]:F.rowSeparators,[`${tn}-zebra`]:F.zebraStripes});return Wo(Na,{menuActionHandler:k,menuBuilder:D,children:ef(rO,{...v,className:G,onResize:R,ref:C,style:K(),children:[Wo("div",{className:`${tn}-scrollbarContainer`,ref:I.scrollbarContainerRef,children:Wo("div",{className:`${tn}-scrollbarContent`})}),Wo("div",{className:`${tn}-contentContainer`,ref:I.contentContainerRef,children:ef("div",{...V,className:`${tn}-table`,tabIndex:-1,children:[g?Wo("div",{className:`${tn}-col-headings`,children:ef("div",{className:`${tn}-col-headers`,role:"row",children:[S.filter(nO).map((Q,X)=>eO(Q)?bC(qi,{...L,column:Q,"data-index":X,key:Q.name,onRemoveColumn:P}):bC(dg,{...L,className:gC({"vuuDraggable-dragAway":X===w.draggedItemIndex}),column:Q,"data-index":X,id:`${x}-col-${X}`,key:Q.name})),w.draggable]})}):null,Wo("div",{className:`${tn}-body`,children:M.map(Q=>Wo(o,{columnMap:b,columns:S,onClick:O,onDataEdited:T,row:Q,offset:p*Q[iO]+y,onToggleGroup:A,zebraStripes:F.zebraStripes},Q[lO]))})]})})]})})};import{isColumnTypeRenderer as aO,isTypeDescriptor as cO,registerComponent as uO}from"@vuu-ui/vuu-utils";import{useCallback as dO,useState as fO}from"react";import{jsx as gO}from"react/jsx-runtime";var hO="vuuTableDropdownCell",pO=["Enter"," "],mO=({column:o,columnMap:e,row:t})=>{var a,c,u;let n=cO(o.type)&&aO((a=o.type)==null?void 0:a.renderer)?(u=(c=o.type)==null?void 0:c.renderer)==null?void 0:u.values:[],r=e[o.name],[s,i]=fO(t[r]),l=dO((d,f)=>{f&&i(f)},[]);return gO(Ni,{className:hO,onSelectionChange:l,openKeys:pO,selected:s,source:n,width:o.width-17})};uO("dropdown-cell",mO,"cell-renderer",{});import{registerComponent as bO}from"@vuu-ui/vuu-utils";import{Input as yO}from"@salt-ds/core";import xO from"classnames";import{jsx as nf}from"react/jsx-runtime";var Jl="vuuTableInputCell",CO=()=>(console.warn("onCommit handler has not been provided to InputCell cell renderer"),!0),vO=({column:o,columnMap:e,onCommit:t=CO,row:n})=>{let r=e[o.name],{align:s="left",clientSideEditValidationCheck:i,valueFormatter:l}=o,{warningMessage:a,...c}=mm({initialValue:l(n[r]),onCommit:t,clientSideEditValidationCheck:i}),u=a&&s==="left"?nf("span",{className:`${Jl}-icon`,"data-icon":"error"}):void 0,d=a&&s==="right"?nf("span",{className:`${Jl}-icon`,"data-icon":"error"}):void 0;return nf(yO,{...c,className:xO(Jl,{[`${Jl}-error`]:a!==void 0}),endAdornment:u,startAdornment:d})};bO("input-cell",vO,"cell-renderer",{});import{FormField as PO,FormFieldLabel as DO,Input as IO}from"@salt-ds/core";import RO from"classnames";import{useCallback as AO,useState as LO}from"react";import{registerComponent as SO}from"@vuu-ui/vuu-utils";import{jsx as kO,jsxs as EO}from"react/jsx-runtime";var wO="vuuSearchCell",TO=({column:o,columnMap:e,row:t})=>{let n=e[o.name],r=t[n];return EO("div",{className:wO,tabIndex:-1,children:[kO("span",{"data-icon":"draggable"}),r]})};console.log("register SearchCell");SO("search-cell",TO,"cell-renderer",{serverDataType:"private"});import{jsx as Yl,jsxs as yC}from"react/jsx-runtime";var of="vuuInstrumentSearch",OO={columns:[{name:"bbg",hidden:!0},{name:"description",width:200,type:{name:"string",renderer:{name:"search-cell"}}}],rowSeparators:!0},NO=Yl("span",{"data-icon":"search"}),HO=({TableProps:o,className:e,dataSource:t,searchColumn:n="description",...r})=>{let[s,i]=LO({searchText:"",filter:""}),l=AO(a=>{let{value:c}=a.target,u=`name starts "${c}"`;i({searchText:c,filter:u}),t.filter={filter:u,filterStruct:{op:"starts",column:n,value:c}}},[t,n]);return yC("div",{...r,className:RO(of,e),children:[yC(PO,{className:`${of}-inputField`,children:[Yl(DO,{}),Yl(IO,{endAdornment:NO,value:s.searchText,onChange:l})]}),Yl(tf,{rowHeight:25,config:OO,renderBufferSize:100,...o,className:`${of}-list`,dataSource:t,showColumnHeaders:!1})]})};MO("InstrumentSearch",HO,"view");import{getMovingValueDirection as FO,isValidNumber as BO,numericFormatter as VO}from"@vuu-ui/vuu-utils";import{memo as $O,useMemo as KO,useRef as zO}from"react";import WO from"classnames";import{jsx as qO,jsxs as jO}from"react/jsx-runtime";var UO="vuuPriceTicker",GO=o=>VO({type:{name:"number",formatting:{decimals:o,zeroPad:!0}}}),_O=[void 0,void 0],QO=$O(({className:o,decimals:e=2,price:t,showArrow:n,...r})=>{let s=zO(_O),[i,l]=s.current,a=KO(()=>GO(e),[e]),c=BO(i)?FO(t,l,i,e):"";return s.current=[t,c],jO("div",{...r,className:WO(UO,o,c),children:[a(t),n?qO("span",{"data-icon":"price-arrow"}):null]})});QO.displayName="PriceTicker";import{asReactElements as gN,OverflowContainer as bN,useId as yN}from"@vuu-ui/vuu-layout";import{Button as xN}from"@salt-ds/core";import NC from"classnames";import CN,{useMemo as vN,useRef as SN}from"react";import{dispatchMouseEvent as dN}from"@vuu-ui/vuu-utils";import{useCallback as Pt,useRef as fN}from"react";var xC=o=>typeof o=="object"&&o!==null&&"tabIndex"in o&&typeof o.tabIndex=="number",CC=o=>({label:"Close",location:"tab",action:"close-tab",options:o}),vC=o=>({label:"Rename",location:"tab",action:"rename-tab",options:o});import{getElementDataIndex as XO}from"@vuu-ui/vuu-utils";var SC=(o,e)=>{if(o){let t=o.querySelector(`[data-index]:has(${e})`);return XO(t)}return-1},rf=o=>SC(o,'[aria-selected="true"]'),wC=o=>SC(o,".vuuEditableLabel-editing");import{isValidNumber as sf,MEASURES as JO}from"@vuu-ui/vuu-utils";import{useCallback as lf,useMemo as YO,useRef as TC}from"react";var kC=(o,e,t="horizontal")=>{let n=TC(!1),r=lf(()=>{n.current=!0},[]),s=lf(()=>{n.current=!1},[]),i=lf(()=>{var a,c;(a=o.current)==null||a.style.setProperty("--tab-thumb-transition","none"),(c=o.current)==null||c.removeEventListener("transitionend",i)},[o]),l=TC(-1);return YO(()=>{var u,d;let a=0,c=0;if(l.current!==-1){let f=(u=o.current)==null?void 0:u.querySelector(".vuuTab-selected"),h=(d=o.current)==null?void 0:d.querySelector(`[data-index="${e}"] .vuuTab`),{positionProp:p,sizeProp:m}=JO[t];if(f&&h&&!n.current){let{[p]:g,[m]:y}=f.getBoundingClientRect(),{[p]:E}=h.getBoundingClientRect();if(sf(g)&&sf(E)&&sf(y)){console.log({orientation:t,positionProp:p,oldPosition:g,newPosition:E}),a=g-E,c=y;let x=Math.abs(a/(t==="horizontal"?1100:700));requestAnimationFrame(()=>{var C,b,S,M;(C=o.current)==null||C.style.setProperty("--tab-thumb-offset","0px"),(b=o.current)==null||b.style.setProperty("--tab-thumb-size","100%"),(S=o.current)==null||S.style.setProperty("--tab-thumb-transition",`all ${x}s ease`),(M=o.current)==null||M.addEventListener("transitionend",i)})}}}return l.current=e,n.current?{containerStyle:{"--tab-thumb-offset":"0px","--tab-thumb-size":"100%"},resumeAnimation:s,suspendAnimation:r}:{containerStyle:{"--tab-thumb-offset":`${a}px`,"--tab-thumb-size":c?`${c}px`:void 0},resumeAnimation:s,suspendAnimation:r}},[e,o,t,i,s,r])};import{useControlled as ZO}from"@salt-ds/core";import{dispatchMouseEvent as eN,getFocusableElement as tN}from"@vuu-ui/vuu-utils";import{useCallback as yn,useRef as af,useState as EC}from"react";import{ArrowDown as IC,ArrowUp as nN,ArrowLeft as oN,ArrowRight as rN,Home as MC,End as PC}from"@vuu-ui/vuu-utils";var RC={horizontal:{[MC]:"start",[PC]:"end",[oN]:"bwd",[rN]:"fwd"},vertical:{[MC]:"start",[PC]:"end",[nN]:"bwd",[IC]:"fwd"}},sN=(o,e="horizontal")=>RC[e][o]!==void 0,iN=o=>o===IC;function DC(o,e,t){return e==="start"?0:e==="end"?o-1:e==="bwd"?t>0?t-1:t:t===null?0:t===o-1?t:t+1}var lN=o=>o!==null&&!o.classList.contains("wrapped"),Zl=(o,e)=>o?o.querySelector(`[data-index="${e}"]`):null,AC=({containerRef:o,defaultHighlightedIdx:e=-1,highlightedIdx:t,keyBoardActivation:n,orientation:r,selectedIndex:s=0})=>{let i=n==="manual",l=af(!1),a=af(-1),[c,u]=EC(!1),[,d]=EC({}),[f,h]=ZO({controlled:t,default:e,name:"UseKeyboardNavigation"}),p=yn(T=>{h(a.current=T)},[h]),m=af(!1),g=yn((T,P=!1,R,O=70)=>{p(T),R===!0&&!m.current&&(m.current=!0);let A=()=>{let D=Zl(o.current,T);if(D){let I=tN(D);I==null||I.focus()}};P?A():setTimeout(A,O)},[o,p]),y=T=>{if(a.current===-1&&T.target.tabIndex!==-1){let P=wC(o.current);P!==-1?requestAnimationFrame(()=>{p(P)}):setTimeout(()=>{a.current===-1&&s!==null&&p(s)},200)}},E=yn(()=>{var T,P;return(P=(T=o.current)==null?void 0:T.querySelectorAll("[data-index]").length)!=null?P:0},[o]),v=yn((T="fwd",P)=>{let R=E(),A=DC(R,T,typeof P=="number"?P:R),D=T==="start"?"fwd":T==="end"?"bwd":T;for(;(D==="fwd"&&A<R||D==="bwd"&&A>0)&&!lN(Zl(o.current,A));){let I=DC(R,D,A);if(I===A)break;A=I}return A},[o,E]),x=yn((T,P=!1)=>{let R=RC[r][T.key],O=v(R,f);O!==f?i&&g(O,!0):P&&d({})},[f,i,v,g,r]),C=yn(()=>{let T=Zl(o.current,f);return T?T.querySelector(".vuuPopupMenu")!=null:!1},[o,f]),b=yn(()=>{let T=Zl(o.current,f),P=T==null?void 0:T.querySelector(".vuuPopupMenu");return P&&eN(P,"click"),!1},[o,f]),S=yn(T=>{E()>0&&sN(T.key,r)?(T.preventDefault(),m.current?x(T):(m.current=!0,x(T,!0))):iN(T.key)&&C()&&b()},[b,E,C,x,r]),M=(T,P)=>{p(P)},w=yn(()=>{c||(u(!0),l.current?l.current=!1:m.current=!0)},[c]),k=yn(()=>{c||(l.current=!0),m.current=!1},[c]);return{containerProps:{onBlur:T=>{let P=T.target.closest(".vuuTabstrip"),R=T.relatedTarget;P&&!(P!=null&&P.contains(R))&&(p(-1),u(!1))},onMouseDownCapture:k,onFocus:w,onMouseLeave:()=>{m.current=!0,p(-1),l.current=!1}},focusVisible:m.current?f:-1,focusIsWithinComponent:c,highlightedIdx:f,focusTab:g,onClick:M,onFocus:y,onKeyDown:S,setHighlightedIdx:p}};import{useControlled as aN}from"@salt-ds/core";import{useCallback as ea}from"react";var cN=["Enter"," "],uN=o=>o&&o.matches('[class*="vuuTab "]'),LC=({defaultSelected:o,highlightedIdx:e,onSelectionChange:t,selected:n})=>{let[r,s,i]=aN({controlled:n,default:o!=null?o:0,name:"Tabstrip",state:"value"}),l=ea(d=>cN.includes(d.key),[]),a=ea(d=>{s(d),t==null||t(d)},[t,s]),c=ea(d=>{let f=d.target;l(d)&&e!==r&&uN(f)&&(d.stopPropagation(),d.preventDefault(),a(e))},[l,e,r,a]),u=ea((d,f)=>{f!==r&&a(f)},[a,r]);return{activateTab:a,isControlled:i,onClick:u,onKeyDown:c,selected:r}};var hN=new Set(["Enter"," "]),pN=o=>hN.has(o),mN=(o,e)=>o?o.querySelector(`[data-index="${e}"]`):null,OC=({activeTabIndex:o,allowDragDrop:e,animateSelectionThumb:t,containerRef:n,onActiveChange:r,onAddTab:s,onCloseTab:i,onExitEditMode:l,onMoveTab:a,orientation:c,keyBoardActivation:u})=>{let d=fN(o),{focusTab:f,highlightedIdx:h,onClick:p,onKeyDown:m,setHighlightedIdx:g,...y}=AC({containerRef:n,keyBoardActivation:u,orientation:c,selectedIndex:d.current}),{activateTab:E,onClick:v,onKeyDown:x,selected:C}=LC({highlightedIdx:h,onSelectionChange:r,selected:o});d.current=C;let{containerStyle:b,resumeAnimation:S,suspendAnimation:M}=kC(n,t?C:-1,c),w=Pt((U,Y)=>{let{current:ce}=d;console.log(`useTabstrip handleDrop ${U} - ${Y} ${ce}`),a==null||a(U,Y);let ie=-1;Y!==-1&&(ce===U?ie=Y:U>ce&&Y<=ce?ie=ce+1:U<ce&&Y>=ce&&(ie=ce-1),ie!==-1&&(M(),E(ie),requestAnimationFrame(S)),f(Y,!1,!1,350))},[f,a,S,E,M]),{onMouseDown:k,...L}=fo({allowDragDrop:e,containerRef:n,draggableClassName:`tabstrip-${c}`,onDrop:w,orientation:"horizontal",itemQuery:".vuuOverflowContainer-item"}),T=Pt((U,Y,ce,ie)=>{console.log(`handleExitEditMode ${U} ${Y} ${ce} ${ie}`),l==null||l(U,Y,ce,ie),ce||f(ie,!1,!0)},[f,l]),P=Pt((U,Y)=>{p(U,Y),v(U,Y)},[p,v]),R=Pt((U=h)=>{let Y=mN(n.current,U);if(Y)return Y.querySelector(".vuuEditableLabel")},[n,h]),O=Pt((U=h)=>{let Y=R(U);return Y?Y.classList.contains("vuuEditableLabel-editing"):!1},[R,h]),A=Pt((U=h)=>{let Y=R(U);Y&&dN(Y,"dblclick")},[R,h]),D=Pt(U=>{m(U),U.defaultPrevented||x(U),!U.defaultPrevented&&pN(U.key)&&A()},[A,m,x]),I=Pt(U=>{let Y=rf(n.current),ce=Y>U?Y-1:Y===U?0:Y;return M(),i==null||i(U,ce),setTimeout(()=>{S()},200),!0},[n,i,S,M]),F=Pt(U=>(A(U),!0),[A]),N=Pt(U=>{if(xC(U.options))switch(U.menuId){case"close-tab":return I(U.options.tabIndex);case"rename-tab":return F(U.options.tabIndex);default:console.log(`tab menu action ${U.menuId}`)}return!1},[I,F]),V=Pt(()=>{O()?g(h):f(h)},[h,f,g,O]),K=Pt(U=>{let Y=parseInt(U.index);isNaN(Y)||E(Y)},[E]),G={onFocus:y.onFocus,onKeyDown:D},Q=Pt(()=>{s==null||s(),requestAnimationFrame(()=>{let U=rf(n.current);U!==-1&&f(U)})},[n,f,s]),X={onClick:P,onKeyDown:D,onExitEditMode:T,onMenuAction:N,onMenuClose:V,onMouseDown:k};return{activeTabIndex:C,containerStyle:b,focusVisible:y.focusVisible,containerProps:{...y.containerProps,onSwitchWrappedItemIntoView:K},navigationProps:G,onClickAddTab:Q,tabProps:X,...L}};import{Fragment as kN,jsx as TN,jsxs as EN}from"react/jsx-runtime";import{createElement as wN}from"react";var cf="vuuTabstrip",HC=({activeTabIndex:o,allowAddTab:e,allowCloseTab:t,allowDragDrop:n=!1,allowRenameTab:r=!1,animateSelectionThumb:s=!1,children:i,className:l,id:a,keyBoardActivation:c="manual",location:u,onActiveChange:d,onAddTab:f,onCloseTab:h,onExitEditMode:p,onMoveTab:m,orientation:g="horizontal",showTabMenuButton:y,style:E,...v})=>{let x=SN(null),{activeTabIndex:C,focusVisible:b,containerStyle:S,draggedItemIndex:M,onClickAddTab:w,tabProps:k,...L}=OC({activeTabIndex:o,allowDragDrop:n,animateSelectionThumb:s,containerRef:x,keyBoardActivation:c,onActiveChange:d,onAddTab:f,onCloseTab:h,onExitEditMode:p,onMoveTab:m,orientation:g}),T=yN(a),P=NC(cf,`${cf}-${g}`,l),R=E||S?{...E,...S}:void 0,O=vN(()=>gN(i).map((A,D)=>{let{id:I=`${T}-tab-${D}`,closeable:F=t,editable:N=r,location:V,showMenuButton:K=y}=A.props,G=D===C;return CN.cloneElement(A,{...k,...L.navigationProps,closeable:F,"data-overflow-priority":G?"1":void 0,dragging:M===D,editable:N,focusVisible:b===D,id:I,index:D,key:D,location:NC(u,V),selected:G,showMenuButton:K,tabIndex:G?0:-1})}).concat(e?wN(xN,{...L.navigationProps,"aria-label":"Create Tab",className:`${cf}-addTabButton`,"data-icon":"add","data-overflow-priority":"1",key:"addButton",onClick:w,variant:"secondary",tabIndex:-1}):[]),[C,e,t,r,i,b,T,u,w,y,k,M,L.navigationProps]);return EN(kN,{children:[TN(bN,{...v,...L.containerProps,className:P,height:28,id:T,orientation:g,overflowIcon:"more-horiz",ref:x,style:R,children:O}),L.draggable]})};import{useForkRef as RN}from"@salt-ds/core";import AN from"classnames";import{forwardRef as LN,useCallback as ON,useRef as BC}from"react";import{useMemo as MN}from"react";import PN from"classnames";import{jsx as IN}from"react/jsx-runtime";var DN="vuuTabMenu",FC=({allowClose:o,allowRename:e,controlledComponentId:t,location:n,onMenuAction:r,onMenuClose:s,index:i})=>{let[l,a]=MN(()=>[(c,u)=>{let d=[];return e&&d.push(vC(u)),o&&d.push(CC(u)),d},{controlledComponentId:t,tabIndex:i}],[o,e,t,i]);return IN(Wa,{className:DN,menuBuilder:l,menuActionHandler:r,menuLocation:PN("tab",n),menuOptions:a,onMenuClose:s,tabIndex:-1})};import{jsx as ta,jsxs as NN}from"react/jsx-runtime";var Uo="vuuTab",VC=()=>{},Kr=LN(function({ariaControls:e,children:t,className:n,closeable:r=!1,dragging:s,editable:i=!1,editing:l,focusVisible:a,index:c=-1,label:u,location:d,onClick:f,onClose:h,onEnterEditMode:p=VC,onExitEditMode:m=VC,onFocus:g,onKeyUp:y,onMenuAction:E,onMenuClose:v,orientation:x,selected:C,showMenuButton:b=r||i||!!d,tabIndex:S,...M},w){if(b&&typeof E!="function")throw Error("Tab onMenuAction must be provided if showMenuButton is set");let k=BC(null),L=BC(null),T=RN(w,k),P=ON(I=>{l||(I.preventDefault(),f==null||f(I,c))},[l,c,f]),R=(I="",F="",N=!0)=>m(I,F,N,c),O=I=>{switch(I.key){case"Backspace":case"Delete":r&&(I.stopPropagation(),h&&h(c));break;default:y&&y(I,c)}},A=()=>i?ta(ns,{editing:l,defaultValue:u,onEnterEditMode:p,onExitEditMode:R,ref:L},u):u,D=I=>{if(L.current){let N=L.current.querySelector(".vuuEditableLabel-input");N==null||N.focus()}g==null||g(I)};return NN("div",{...M,"aria-controls":e,"aria-selected":C,className:AN(Uo,{[`${Uo}-closeable`]:r,"vuuDraggable-dragAway":s,[`${Uo}-editing`]:l,[`${Uo}-selected`]:C||void 0,[`${Uo}-vertical`]:x==="vertical",vuuFocusVisible:a}),onClick:P,onFocus:D,onKeyUp:O,ref:T,role:"tab",tabIndex:S,children:[ta("div",{className:`${Uo}-main`,children:ta("span",{className:`${Uo}-text`,"data-text":i?void 0:u,children:t!=null?t:A()})}),b?ta(FC,{allowClose:r,allowRename:i,controlledComponentId:e,location:d,onMenuAction:E,onMenuClose:v,index:c}):null]})});import{useForkRef as dH,useIdMemo as fH}from"@salt-ds/core";import yf from"classnames";import{forwardRef as hH,useRef as pH}from"react";function HN(o){var e;if(o){let t=o.dataset.idx;if(t)return parseInt(t,10);if(t=(e=o.ariaPosInSet)!=null?e:"-1")return parseInt(t,10)-1}}var uf=o=>o.closest("[data-idx],[aria-posinset]");var $C=o=>HN(uf(o));import{useCallback as df,useMemo as FN}from"react";var BN=new Set(["/","-","."]),VN=o=>BN.has(o),KC=(o,e)=>e.startsWith(o)&&VN(e[o.length]),zC=(o,e="root",{collapsibleHeaders:t=void 0,defaultExpanded:n=!1,revealSelected:r=!1}={})=>{let s=(f,h,p)=>{if(f.childNodes)return f.childNodes.length;if(f.header){let m=p+1,g=0;for(;m<h.length&&!h[m].header;)g++,m++;return g}else return 0},i=df(f=>Array.isArray(r)?r.some(h=>KC(f,h)):n,[n,r]),l=df((f,h,p=1,m="",g=[],y=[])=>{let E=0;return f.forEach((v,x,C)=>{var R;let b=v.header&&t,S=v.childNodes&&t===!1,M=!v.childNodes||v.childNodes.length===0,w=S||M&&!b,k=m?`${m}.${x}`:`${x}`,L=(R=v.id)!=null?R:`${e}-${k}`,T=w?void 0:i(L),P={...v,childNodes:void 0,id:L,count:!S&&T===void 0?0:s(v,C,x),expanded:T,index:h.index,level:p};if(g.push(P),y.push(f[x]),E+=1,h.index+=1,v.childNodes){let[O,A]=l(v.childNodes,h,p+1,k,[],y);P.childNodes=A,(T===!0||S)&&(E+=O)}}),[E,g,y]},[t,e,i]),[a,c,u]=FN(()=>l(o,{index:0}),[l,o]),d=df((f,h=c)=>{let p=h.find(m=>{var g;return m.id===f||((g=m==null?void 0:m.childNodes)==null?void 0:g.length)&&KC(m.id,f)});if((p==null?void 0:p.id)===f)return u[p.index];if(p)return d(f,p.childNodes)},[u,c]);return[a,c,d]};import{useCallback as Ws,useRef as $N}from"react";import{useControlled as KN}from"@salt-ds/core";var WC="single",zN="checkbox",WN="multi",UN="extended",GN=["Enter"," "],UC={},_N=o=>o.expanded!==void 0,GC=o=>o&&o!=="none",_C=({defaultSelected:o,highlightedIdx:e,treeNodes:t,onChange:n,selected:r,selection:s=WC,selectionKeys:i=GN})=>{let l=s===WC,a=s===WN||s.startsWith(zN),c=s===UN,u=$N(-1),d=Ws(x=>i.includes(x.key),[i]),[f,h]=KN({controlled:r,default:o!=null?o:[],name:"selected"}),p=Ws((x,C,b,S,M=!1)=>{let{current:w}=u,k=f==null?void 0:f.includes(b),T=l||c&&!M&&(!S||w===-1),P=a||c&&M&&!S,R=[];if(T&&k)R=[];else if(T)R=[b];else if(P&&k)R=f.filter(O=>O!==b);else if(P)R=f.concat(b);else if(c){let[O,A]=C>w?[w,C]:[C,w];R=f.slice();for(let D=O;D<=A;D++){let{id:I}=t[D];f.includes(I)||R.push(I)}}h(R),n&&n(x,R)},[c,t,a,n,f,h,l]),m=Ws(x=>{if(~e&&d(x)){x.preventDefault();let C=t[e];p(x,e,C.id,!1,x.ctrlKey||x.metaKey),c&&(u.current=e)}},[c,e,t,d,p]),g=Ws((x,C)=>{if(c&&x.shiftKey){let b=t[C];p(x,C,b.id,!0)}},[c,t,p]),y=s==="none"?UC:{onKeyDown:m,onKeyboardNavigation:g},E=Ws(x=>{if(e!==-1){let C=t[e];_N(C)||(x.preventDefault(),x.stopPropagation(),p(x,e,C.id,x.shiftKey,x.ctrlKey||x.metaKey),c&&(u.current=e))}},[c,e,t,p]);return{listHandlers:y,listItemHandlers:s==="none"?UC:{onClick:E},selected:f,setSelected:h}};import{useCallback as ff,useEffect as QC,useLayoutEffect as QN,useRef as na}from"react";var qN=["height","scrollHeight"],qC=(o,e,t=!1)=>{let n=na(0),r=na(!1),s=na(0),i=na(0),l=ff(u=>{let d=u.ariaExpanded?u.firstChild:u,f=t?30:0,h=d.offsetTop,p=d.offsetHeight,m=n.current+f,g=m+s.current-f;(h+p>g||h<m)&&(n.current=h+p>g?n.current+(h+p)-g:h-f,r.current=!0,o.current&&(o.current.scrollTop=n.current),setTimeout(()=>{r.current=!1}))},[o,t]),a=ff(u=>{n.current=u.target.scrollTop},[]);QC(()=>{let{current:u}=o;return u&&u.addEventListener("scroll",a),()=>{u&&u.removeEventListener("scroll",a)}},[o,a]),QN(()=>{if(e!==-1&&i.current>s.current&&o.current){let u=o.current.querySelector(`
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`);u===null?console.log("[useViewportTracking], is this virtualised ? we're going to have to know rowHeight"):l(u)}},[e,o,l]),QC(()=>{},[t]);let c=ff(({height:u,scrollHeight:d})=>{s.current=u,i.current=d},[]);return Cn(o,qN,c,!0),r};import{useCallback as dv,useRef as cH}from"react";import{useCallback as Us,useMemo as ov,useRef as rv}from"react";var jC=({id:o})=>{let e=o.lastIndexOf("-");if(e!==-1){let n=o.slice(e+1).split(".");return n.length===1?null:(n.pop(),`${o.slice(0,e)}-${n.join(".")}`)}else if((e=o.lastIndexOf("/"))!==-1)return o.slice(0,e)},XC=o=>o.childNodes!==void 0;var hf=o=>o.header===!0,jN=new Set([".","/"]),JC=(o,e)=>e.startsWith(o.id)?jN.has(e.charAt(o.id.length)):!1,Go=(o,e)=>{for(let t of o){if(t.id===e)return t;if(JC(t,e))return Go(t.childNodes,e)}},oa=(o,e)=>{let t=typeof e=="string"?e:e.id;for(let n=0;n<o.length;n++)if(o[n].id===t)return n},ra=(o,e,t)=>{let n;return o.map(s=>s.id===e?{...s,...t}:JC(s,e)?(n=ra(s.childNodes,e,t),{...s,childNodes:n}):s)};import{useControlled as nH}from"@salt-ds/core";function XN(o,...e){let t=new Set(o);for(let n of e)for(let r of n)t.add(r);return t}var pf="ArrowUp",YC="ArrowDown",zr="ArrowLeft";var ZC="ArrowRight",sa="Enter";var JN="Delete",YN=new Set([sa,JN]),ZN=new Set(["Tab"]),eH=new Set(["ArrowRight","ArrowLeft"]),ev=new Set(["Home","End","ArrowDown","ArrowUp"]),tv=new Set(["Home","End","ArrowRight","ArrowLeft"]),tH=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),bde=XN(YN,tv,ev,eH,tH,ZN);var nv=({key:o},e="vertical")=>(e==="vertical"?ev:tv).has(o);function sv(o,e,t){return e===pf||e===zr?t>0?t-1:t:t===null?0:t===o-1?t:t+1}var oH=o=>!o.header&&!o.childNodes,rH=o=>oH(o)||o.expanded!==void 0,iv=({defaultHighlightedIdx:o=-1,highlightedIdx:e,treeNodes:t,onHighlight:n,onKeyboardNavigation:r,selected:s=[]})=>{let{bwd:i,fwd:l}=ov(()=>({bwd:pf,fwd:YC}),[]),[a,c,u]=nH({controlled:e,default:o,name:"highlightedIdx"}),d=Us(x=>{n==null||n(x),c(x)},[n,c]),f=Us((x=l,C=x===l?-1:t.length)=>{let b=sv(t.length,x,C);for(;b!==-1&&(x===l&&b<t.length||x===i&&b>0)&&!rH(t[b]);)b=sv(t.length,x,b);return b},[i,l,t]),h=rv(!0),p=rv(!1),m=x=>p.current=x,g=Us(()=>{if(p.current)p.current=!1;else if(s.length>0){let x=Go(t,s[0]);if(x){let C=oa(t,x);d(C)}}else d(f())},[t,f,s,d]),y=Us(x=>{let C=f(x.key,a);C!==a&&(d(C),r==null||r(x,C))},[a,f,r,d]),E=Us(x=>{t.length>0&&nv(x,"vertical")&&(x.preventDefault(),x.stopPropagation(),h.current=!0,y(x))},[t,y]),v=ov(()=>({onBlur:()=>{d(-1)},onFocus:g,onKeyDown:E,onMouseDownCapture:()=>{h.current=!1,m(!0)},onMouseMove:()=>{h.current&&(h.current=!1)},onMouseLeave:()=>{h.current=!0,m(!1),d(-1)}}),[g,E,d]);return{focusVisible:h.current?a:-1,controlledHighlighting:u,highlightedIdx:a,hiliteItemAtIndex:d,keyBoardNavigation:h,listProps:v,setIgnoreFocus:m}};import{useRef as mf,useState as sH}from"react";var ia=(o,e=[],t={value:0})=>{let n=!1;for(let r of o)n&&!hf(r)||(e[t.value]=r,t.value+=1,n=!1,hf(r)&&r.expanded===!1?n=!0:XC(r)&&gf(r)&&ia(r.childNodes,e,t));return e},lv=o=>{let e=mf(o),t=mf(o),n=mf(ia(o)),[,r]=sH({});o!==e.current&&(e.current=o,t.current=o,n.current=ia(o));let s=i=>{t.current=i,n.current=ia(i),r({})};return{data:t.current,indexPositions:n.current,setData:s}};import{useCallback as Gs,useRef as av}from"react";var iH={},lH=o=>o&&o.hasAttribute("aria-expanded"),cv=({collapsibleHeaders:o,highlightedIdx:e,treeNodes:t,setVisibleData:n,source:r})=>{let s=av(r),i=av(s.current),l=Gs(p=>{n(i.current=p)},[n]),a=Gs((p,{id:m})=>ra(p,m,{expanded:!0}),[]),c=Gs((p,{id:m})=>ra(p,m,{expanded:!1}),[]),u=Gs(p=>{if(p.key===ZC||p.key===sa){let m=t[e];m&&m.expanded===!1&&(p.preventDefault(),l(a(i.current,m)))}if(p.key===zr||p.key===sa){let m=t[e];m&&m.expanded&&(p.preventDefault(),l(c(i.current,m)))}},[c,a,e,t,l]),d=o?{onKeyDown:u}:iH,h={onClick:Gs(p=>{let m=uf(p.target);if(lH(m)){p.stopPropagation(),p.preventDefault();let g=Go(r,m.id);(g==null?void 0:g.expanded)===!1?l(a(r,g)):(g==null?void 0:g.expanded)===!0&&l(c(r,g))}},[c,a,l,r])};return{listHandlers:d,listItemHandlers:h}};import{useCallback as aH}from"react";var uv=({highlightedIdx:o,hiliteItemAtIndex:e,indexPositions:t,source:n})=>({listHandlers:{onKeyDown:aH(i=>{if(i.key===zr){let l=t[o],a=jC(l);if(a){i.preventDefault();let c=Go(n,a);if(c){let u=oa(t,c);u!==void 0&&e(u)}}}},[o,e,t,n])}});var uH=[],fv=({defaultSelected:o,sourceWithIds:e,onChange:t,onHighlight:n,selected:r,selection:s})=>{let i=cH(uH),l=lv(e),a=(v,x)=>{var C,b;(b=(C=f.listHandlers).onKeyboardNavigation)==null||b.call(C,v,x)},{highlightedIdx:c,...u}=iv({treeNodes:l.indexPositions,onHighlight:n,onKeyboardNavigation:a,selected:i.current}),d=cv({collapsibleHeaders:!0,highlightedIdx:c,treeNodes:l.indexPositions,setVisibleData:l.setData,source:l.data}),f=_C({defaultSelected:o,highlightedIdx:c,treeNodes:l.indexPositions,onChange:t,selected:r,selection:s}),h=uv({source:l.data,highlightedIdx:c,hiliteItemAtIndex:u.hiliteItemAtIndex,indexPositions:l.indexPositions}),p=dv(v=>{var x,C,b;(x=d.listItemHandlers)==null||x.onClick(v),v.defaultPrevented||(b=(C=f.listItemHandlers)==null?void 0:C.onClick)==null||b.call(C,v)},[d,f]),m=dv(v=>{var x,C,b,S,M,w,k,L;(C=(x=u.listProps).onKeyDown)==null||C.call(x,v),v.defaultPrevented||(S=(b=f.listHandlers).onKeyDown)==null||S.call(b,v),v.defaultPrevented||(w=(M=d.listHandlers).onKeyDown)==null||w.call(M,v),v.defaultPrevented||(L=(k=h.listHandlers).onKeyDown)==null||L.call(k,v)},[d.listHandlers,u.listProps,f.listHandlers,h.listHandlers]),g=()=>{var v;return c===void 0||c===-1||(v=l.indexPositions[c])==null?void 0:v.id};i.current=f.selected;let y={"aria-activedescendant":g(),onBlur:u.listProps.onBlur,onFocus:u.listProps.onFocus,onKeyDown:m,onMouseDownCapture:u.listProps.onMouseDownCapture,onMouseLeave:u.listProps.onMouseLeave,onMouseMove:u.listProps.onMouseMove},E={onClick:p};return{focusVisible:u.focusVisible,highlightedIdx:c,hiliteItemAtIndex:u.hiliteItemAtIndex,listProps:y,listItemHandlers:E,selected:f.selected,visibleData:l.data}};import{jsx as oo,jsxs as bf}from"react/jsx-runtime";import{createElement as bH}from"react";var no="vuuTree",gf=o=>o.expanded===!0,hv=({children:o,idx:e,...t})=>oo("li",{...t,children:o}),mH=hH(function({allowDragDrop:e,className:t,defaultSelected:n,groupSelection:r="none",id:s,onHighlight:i,onSelectionChange:l,revealSelected:a,selected:c,selection:u="single",source:d,...f},h){var A;let p=fH(s),m=pH(null),[,g,y]=zC(d,p,{revealSelected:a?(A=c!=null?c:n)!=null?A:!1:void 0}),E=(D,I)=>{if(l){let F=I.map(N=>y(N)).filter(N=>N!==void 0);l(F)}},{focusVisible:v,highlightedIdx:x,hiliteItemAtIndex:C,listProps:b,listItemHandlers:S,selected:M,visibleData:w}=fv({defaultSelected:n,groupSelection:r,onChange:E,onHighlight:i,selected:c,selection:u,sourceWithIds:g});qC(m,x);let L={...{onMouseEnter:D=>{let I=D.target,F=$C(I);C(F)}},...S,role:"treeitem"},T=GC(r);function P(D,I,F){D.push(bf(hv,{...L,...gH(I,F,x,M,v),children:[I.icon?oo("span",{className:`${no}Node-icon`,"data-icon":I.icon}):null,oo("span",{children:I.label})]})),F.value+=1}function R(D,I,F,N,V){let{value:K}=F;F.value+=1,D.push(bH(hv,{...S,"aria-expanded":I.expanded,"aria-level":I.level,"aria-selected":M.includes(N)||void 0,className:yf(`${no}Node`,{focusVisible:v===K,[`${no}Node-toggle`]:!T}),"data-idx":K,"data-highlighted":K===x||void 0,"data-selectable":!0,id:N,key:`header-${K}`},T?bf("div",{className:`${no}Node-label`,children:[oo("span",{className:`${no}Node-toggle`}),V]}):bf("div",{className:`${no}Node-label`,children:[I.icon?oo("span",{className:`${no}Node-icon`,"data-icon":I.icon}):null,oo("span",{children:V})]}),oo("ul",{role:"group",children:gf(I)?O(I.childNodes,F):""})))}function O(D,I={value:0}){if((D==null?void 0:D.length)>0){let F=[];for(let N of D)N.childNodes?R(F,N,I,N.id,N.label):P(F,N,I);return F}}return oo("ul",{...f,...b,className:yf(no,t),id:`Tree-${p}`,ref:dH(m,h),role:"tree",tabIndex:0,children:O(w)})}),gH=(o,e,t,n,r,s)=>({id:o.id,key:o.id,"aria-level":o.level,"aria-selected":n.includes(o.id)||void 0,"data-idx":e.value,"data-highlighted":e.value===t||void 0,className:yf("vuuTreeNode",s,{focusVisible:r===e.value})});mH.displayName="Tree";import{Input as Tfe}from"@salt-ds/core";import Mfe from"classnames";import{useCallback as Afe}from"react";import{jsx as Ofe}from"react/jsx-runtime";import{formatDate as vH,takeScreenshot as SH}from"@vuu-ui/vuu-utils";import{jsx as ht,jsxs as ro}from"react/jsx-runtime";var Dt="saveLayoutPanel",ca=`${Dt}-formField`,wH=["Group 1","Group 2","Group 3","Group 4","Group 5"],TH=["Value 1","Value 2","Value 3"],mv=["Value 1","Value 2","Value 3"],ahe=o=>{let{onCancel:e,onSave:t,componentId:n}=o,[r,s]=_s(""),[i,l]=_s(""),[a,c]=_s([]),[u,d]=_s(mv[0]),[f,h]=_s();yH(()=>{n&&SH(document.getElementById(n)).then(m=>h(m))},[]);let p=()=>{t({name:r,group:i,screenshot:f!=null?f:"",user:"User",date:vH(new Date,"dd.mm.yyyy")})};return ro("div",{className:`${Dt}-panelContainer`,children:[ro("div",{className:`${Dt}-panelContent`,children:[ro("div",{className:`${Dt}-formContainer`,children:[ro(la,{className:ca,children:[ht(aa,{children:"Group"}),ht(ts,{ListProps:{style:{zIndex:1e4,border:"1px solid #777C94",borderRadius:10,boxSizing:"border-box"}},source:wH,allowFreeText:!0,InputProps:{inputProps:{className:`${Dt}-inputText`,placeholder:"Select Group or Enter New Name",onChange:m=>l(m.target.value)}},width:120,onSelectionChange:(m,g)=>l(g||"")})]}),ro(la,{className:ca,children:[ht(aa,{children:"Layout Name"}),ht(xH,{inputProps:{className:`${Dt}-inputText`,placeholder:"Enter Layout Name"},onChange:m=>s(m.target.value),value:r})]}),ro(la,{className:ca,children:[ht(aa,{children:"Some Layout Setting"}),ht("div",{className:`${Dt}-settingsGroup`,children:TH.map((m,g)=>ht(Cm,{onToggle:()=>c(y=>y.includes(m)?y.filter(E=>E!==m):[...y,m]),checked:a.includes(m),label:m},g))})]}),ro(la,{className:ca,children:[ht(aa,{children:"Some Layout Setting"}),ht("div",{className:`${Dt}-settingsGroup`,children:mv.map((m,g)=>ht(wm,{onClick:()=>d(m),checked:u===m,label:m,groupName:"radioGroup"},g))})]})]}),ht("div",{className:`${Dt}-screenshotContainer`,children:f?ht("img",{className:`${Dt}-screenshot`,src:f,alt:"screenshot of current layout"}):ht(CH,{className:"screenshot",children:"No screenshot available"})})]}),ro("div",{className:`${Dt}-buttonsContainer`,children:[ht(pv,{className:`${Dt}-cancelButton`,onClick:e,children:"Cancel"}),ht(pv,{className:`${Dt}-saveButton`,onClick:p,disabled:r===""||i==="",children:"Save"})]})]})};import KH,{useState as zH,useCallback as WH,useContext as UH,useEffect as wv}from"react";import{Toolbar as $ge}from"@vuu-ui/vuu-layout";import{Button as Wge}from"@salt-ds/core";import Gge from"classnames";import{useRef as jge}from"react";import{useCallback as mhe,useRef as ghe}from"react";import{Fragment as whe,jsx as vhe,jsxs as She}from"react/jsx-runtime";import{itemToString as kH}from"@vuu-ui/vuu-utils";import gv from"classnames";import{forwardRef as EH,useCallback as xf,useMemo as MH,useRef as PH,useState as bv}from"react";import{jsx as Cf}from"react/jsx-runtime";var yv="vuuExpandoCombobox",DH={},Qs=EH(function({allowMultipleSelection:e=!1,className:t,InputProps:n=DH,ListProps:r,onInputChange:s,onSelectionChange:i,value:l="",...a},c){let[u,d]=bv(l),{itemToString:f=kH}=a,h=PH(l),p=xf(C=>{let{value:b}=C.target;d(b),s==null||s(C)},[s]),[m,g]=MH(()=>{let{inputProps:C,...b}=n;return[{...b,className:`${yv}-Input`,endAdornment:null,inputProps:{...C,autoComplete:"off",onInput:p}},{...r,className:gv("vuuMenuList",r==null?void 0:r.className),"data-mode":"light",displayedItemCount:10,itemHeight:22,maxWidth:300,minWidth:100,width:"auto"}]},[n,p,r]),y=xf((C,b)=>{let S=b===null?"":f(b);d(S),i==null||i(C,b)},[f,i]),[E,v]=bv([]),x=xf((C,b)=>{v(b)},[]);return Cf("div",{className:gv(yv,t),"data-text":u,ref:c,children:e?Cf(ts,{...a,defaultValue:h.current,ListProps:g,InputProps:m,onSelectionChange:y}):Cf(ts,{...a,defaultValue:h.current,ListProps:g,InputProps:m,onSelectionChange:y})})});import Gpe from"classnames";import{useCallback as qpe,useEffect as jpe,useRef as Xpe}from"react";import{Button as Ghe}from"@salt-ds/core";import{jsx as qhe}from"react/jsx-runtime";import{forwardRef as IH,useState as RH,useCallback as xv}from"react";import{isValidNumber as vf}from"@vuu-ui/vuu-utils";import{jsx as LH}from"react/jsx-runtime";var AH=IH(function({InputProps:e,className:t,column:n,onInputComplete:r,value:s},i){let[l,a]=RH(vf(s)?s.toString():""),c=xv(d=>{let{value:f}=d.target,h=parseFloat(f);vf(h)&&console.log("its valid"),a(f)},[]),u=xv(d=>{if(d.key==="Enter"){let{value:f}=d.target,h=parseFloat(f);vf(h)&&r(h)}},[r]);return LH(Vi,{...e,className:t,value:l,ref:i,onChange:c,onKeyDown:u})});import{isNumericColumn as lpe,isTextColumn as ape}from"@vuu-ui/vuu-utils";import{forwardRef as OH,useCallback as Sf,useEffect as Cv,useMemo as NH,useState as vv}from"react";import{jsx as ua}from"react/jsx-runtime";var HH=OH(function({InputProps:e={},className:t,column:n,filterClause:r,onInputComplete:s,operator:i,suggestionProvider:l=Ki,table:a,value:c},u){let[d,f]=vv(c!=null?c:""),[h,p]=vv([]),m=l(),g=Sf((x,C)=>{s(C!=null?C:"")},[s]);Cv(()=>{},[n]),Cv(()=>{if(a){let x=d?[a,n.name,d]:[a,n.name];m(x).then(C=>{p(C)}).catch(C=>{console.error("Error getting suggsetions",C)})}},[a,n,d,m]);let y=Sf(x=>{let{value:C}=x.target;f(C)},[]),E=NH(()=>{if(i==="starts"||i==="ends"){let{inputProps:x,...C}=e;return{...C,inputProps:{...x,onKeyDown:b=>{var S;b.key==="Enter"&&d!==""?(b.stopPropagation(),b.preventDefault(),s(d)):(S=x==null?void 0:x.onKeyDown)==null||S.call(x,b)}}}}else return e},[e,s,i,d]);return Sf(()=>{switch(i){case"in":return ua(Qs,{InputProps:E,className:t,initialHighlightedIndex:0,source:h,onInputChange:y,onSelectionChange:g,ref:u,value:c});case"starts":return ua(Qs,{InputProps:E,ListProps:{className:"vuuIllustrationsOnly",disabled:!0},allowFreeText:!0,className:t,initialHighlightedIndex:0,source:h,onInputChange:y,onSelectionChange:g,ref:u,value:c});case"ends":return ua(Vi,{...E,className:t,value:d,ref:u,onChange:y});default:return ua(Qs,{InputProps:E,className:t,initialHighlightedIndex:0,source:h,onInputChange:y,onSelectionChange:g,ref:u,value:c})}},[i,E,t,h,y,g,u,c,d])()});import{isMultiValueFilter as Epe,isSingleValueFilter as Mpe,isValidFilterClauseOp as Ppe}from"@vuu-ui/vuu-utils";import{getColumnByName as Ipe}from"@vuu-ui/vuu-data";import{useCallback as Npe,useMemo as Hpe,useState as Fpe}from"react";import{jsx as sme,jsxs as ime}from"react/jsx-runtime";import{filterAsQuery as jme,isMultiClauseFilter as Xme}from"@vuu-ui/vuu-utils";import Yme from"classnames";import{useCallback as tge,useRef as nge}from"react";import{useMemo as vme}from"react";import wme from"classnames";import{jsx as Pme}from"react/jsx-runtime";import{extractFilterForColumn as Lme,isAndFilter as Ome,isCompleteFilter as Nme,isInFilter as Hme,isMultiClauseFilter as Fme,isMultiValueFilter as Bme,isOrFilter as Vme,isSingleValueFilter as $me,partition as Kme}from"@vuu-ui/vuu-utils";import{jsx as lge,jsxs as age}from"react/jsx-runtime";import{dispatchMouseEvent as Cge,filterAsQuery as vge}from"@vuu-ui/vuu-utils";import{useCallback as kge,useMemo as Ege,useRef as Mge,useState as Pge}from"react";import{useCallback as pge}from"react";import{jsx as sbe,jsxs as ibe}from"react/jsx-runtime";import{createElement as rbe}from"react";import{Button as eye}from"@salt-ds/core";import Fbe from"classnames";import{useEffect as $be,useMemo as Kbe,useRef as zbe}from"react";var pbe=mn.define({name:"VuuFilterQuery",parser:is.configure({props:[Oo({Identifier:$.variableName,String:$.string,Or:$.emphasis,Operator:$.operator})]})});var BH=Yt.define([{tag:$.variableName,color:"var(--vuuFilterEditor-variableColor)"},{tag:$.comment,color:"green",fontStyle:"italic"}]),VH=Ho(BH);var $H=se.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 Pbe}from"react";import{jsx as iye,jsxs as lye}from"react/jsx-runtime";import{useCallback as Cye,useRef as vye}from"react";import{createEl as uye}from"@vuu-ui/vuu-utils";var wf=o=>{let e=localStorage.getItem(o);return e?JSON.parse(e):void 0};var Sv=(o,e)=>{try{return localStorage.setItem(o,JSON.stringify(e)),e}catch{return}};import{getUniqueId as GH}from"@vuu-ui/vuu-utils";import{jsx as _H}from"react/jsx-runtime";var Tv=KH.createContext({layouts:[],saveLayout:()=>{}}),$ye=o=>{let[e,t]=zH([]);wv(()=>{let r=wf("layouts");t(r||[])},[]),wv(()=>{Sv("layouts",e)},[e]);let n=WH(r=>{let s=wf("api/vui");s&&t(i=>[...i,{metadata:{...r,id:GH()},json:s}])},[]);return _H(Tv.Provider,{value:{layouts:e,saveLayout:n},children:o.children})},kv=()=>UH(Tv);import{Fragment as QH,jsx as so,jsxs as da}from"react/jsx-runtime";var _o="vuuLayoutList",Ev=o=>{let{layouts:e}=kv(),t=e.map(s=>s.metadata),n=s=>{console.log("loading layout with id",s),console.log("json:",e.find(i=>i.metadata.id===s))},r=t.reduce((s,i)=>s[i.group]?{...s,[i.group]:[...s[i.group],i]}:{...s,[i.group]:[i]},{});return da("div",{className:_o,...o,children:[so("div",{className:`${_o}-header`,children:"My Layouts"}),so(wn,{height:"fit-content",source:Object.entries(r),ListItem:({item:s})=>da(QH,{children:[so("div",{className:`${_o}-groupName`,children:s==null?void 0:s[0]}),so(wn,{height:"fit-content",source:s==null?void 0:s[1],ListItem:({item:i})=>da("div",{className:`${_o}-layoutContainer`,onClick:()=>n(i==null?void 0:i.id),children:[so("img",{className:`${_o}-screenshot`,src:i==null?void 0:i.screenshot}),da("div",{children:[so("div",{className:`${_o}-layoutName`,children:i==null?void 0:i.name}),so("div",{className:`${_o}-layoutDetails`,children:so("div",{children:`${i==null?void 0:i.user}, ${i==null?void 0:i.date}`})})]})]},i==null?void 0:i.id)})]})})]})};import{memo as qH}from"react";import{jsx as Wt,jsxs as Wr}from"react/jsx-runtime";var Tf=qH(()=>Wr("svg",{width:"44",height:"45",viewBox:"0 0 44 45",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Wr("g",{clipPath:"url(#clip0_217_6990)",children:[Wt("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)"}),Wt("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)"}),Wt("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"}),Wr("g",{opacity:"0.86",children:[Wt("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"}),Wt("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"}),Wt("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"})]})]}),Wr("defs",{children:[Wr("linearGradient",{id:"paint0_linear_217_6990",x1:"24.6235",y1:"18.7363",x2:"42.3152",y2:"18.7363",gradientUnits:"userSpaceOnUse",children:[Wt("stop",{stopColor:"#4906A5"}),Wt("stop",{offset:"1",stopColor:"#D3423A"})]}),Wr("linearGradient",{id:"paint1_linear_217_6990",x1:"-2.35794e-05",y1:"22.5009",x2:"42.7186",y2:"22.5009",gradientUnits:"userSpaceOnUse",children:[Wt("stop",{stopColor:"#7C06A5"}),Wt("stop",{offset:"1",stopColor:"#D3423A"})]}),Wt("clipPath",{id:"clip0_217_6990",children:Wt("rect",{width:"44",height:"45",fill:"white"})})]})]}));Tf.displayName="VuuLogo";import{Action as Dv,Stack as a2,useLayoutProviderDispatch as c2}from"@vuu-ui/vuu-layout";import Pf from"classnames";import{useCallback as ha,useState as u2}from"react";import{Palette as jH,PaletteItem as XH}from"@vuu-ui/vuu-layout";import{jsx as fa,jsxs as JH}from"react/jsx-runtime";var Mv="vuuFeatureList",kf=({features:o,title:e="VUU TABLES",...t})=>{let n={};return console.log({features:o}),JH("div",{...t,className:Mv,children:[fa("div",{className:`${Mv}-header`,children:e}),fa(jH,{orientation:"vertical",ViewProps:n,children:o.map((r,s)=>fa(XH,{closeable:!0,label:r.title,resizeable:!0,resize:"defer",header:!0,children:fa(ti,{...r})},s))})]})};import{createContext as YH,isValidElement as ZH,cloneElement as e2,useContext as Pv}from"react";import t2 from"classnames";import{jsx as l2}from"react/jsx-runtime";var n2="medium",o2="salt-theme",r2="light",Ef=YH({density:"high",theme:"vuu",themeMode:"light"}),s2=["vuu","vuu-density-high","light"],wt=()=>{let o=Pv(Ef);return o?[`${o.theme}-theme`,`${o.theme}-density-${o.density}`,o.themeMode]:s2},i2=(o,e,t,n)=>{var r;return ZH(o)?e2(o,{className:t2((r=o.props)==null?void 0:r.className,`${e}-theme`,`${e}-density-${n}`),"data-mode":t}):(console.warn(`
|
|
1
|
+
// src/connection-status/ConnectionStatusIcon.tsx
|
|
2
|
+
import React, { useEffect, useState } from "react";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var ConnectionStatusIcon = ({ connectionStatus, className, element = "span", ...props }) => {
|
|
6
|
+
const [classBase11, setClassBase] = useState("vuuConnectingStatus");
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
switch (connectionStatus) {
|
|
9
|
+
case "connected":
|
|
10
|
+
case "reconnected":
|
|
11
|
+
setClassBase("vuuActiveStatus");
|
|
12
|
+
break;
|
|
13
|
+
case "connecting":
|
|
14
|
+
setClassBase("vuuConnectingStatus");
|
|
15
|
+
break;
|
|
16
|
+
case "disconnected":
|
|
17
|
+
setClassBase("vuuDisconnectedStatus");
|
|
18
|
+
break;
|
|
19
|
+
default:
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}, [connectionStatus]);
|
|
23
|
+
const statusIcon = React.createElement(
|
|
24
|
+
element,
|
|
25
|
+
{
|
|
26
|
+
...props,
|
|
27
|
+
className: cx("vuuStatus vuuIcon", classBase11, className)
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "vuuStatus-container salt-theme", children: [
|
|
31
|
+
statusIcon,
|
|
32
|
+
/* @__PURE__ */ jsxs("div", { className: "vuuStatus-text", children: [
|
|
33
|
+
"Status: ",
|
|
34
|
+
connectionStatus.toUpperCase()
|
|
35
|
+
] })
|
|
36
|
+
] }) });
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/density-switch/DensitySwitch.tsx
|
|
40
|
+
import { Dropdown } from "@salt-ds/lab";
|
|
41
|
+
import { useCallback } from "react";
|
|
42
|
+
import cx2 from "classnames";
|
|
43
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
44
|
+
var classBase = "vuuDensitySwitch";
|
|
45
|
+
var densities = ["high", "medium", "low", "touch"];
|
|
46
|
+
var DEFAULT_DENSITY = "high";
|
|
47
|
+
var DensitySwitch = ({
|
|
48
|
+
className: classNameProp,
|
|
49
|
+
defaultDensity = DEFAULT_DENSITY,
|
|
50
|
+
onChange
|
|
51
|
+
}) => {
|
|
52
|
+
const handleSelectionChange = useCallback(
|
|
53
|
+
(_event, selectedItem) => {
|
|
54
|
+
onChange(selectedItem);
|
|
55
|
+
},
|
|
56
|
+
[onChange]
|
|
57
|
+
);
|
|
58
|
+
const className = cx2(classBase, classNameProp);
|
|
59
|
+
return /* @__PURE__ */ jsx2(
|
|
60
|
+
Dropdown,
|
|
61
|
+
{
|
|
62
|
+
className,
|
|
63
|
+
source: densities,
|
|
64
|
+
defaultSelected: defaultDensity,
|
|
65
|
+
onSelectionChange: handleSelectionChange
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/feature/Feature.tsx
|
|
71
|
+
import React3, { Suspense, useEffect as useEffect2 } from "react";
|
|
72
|
+
import { registerComponent } from "@vuu-ui/vuu-layout";
|
|
73
|
+
|
|
74
|
+
// src/feature/FeatureErrorBoundary.tsx
|
|
75
|
+
import React2 from "react";
|
|
76
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
77
|
+
var FeatureErrorBoundary = class extends React2.Component {
|
|
78
|
+
constructor(props) {
|
|
79
|
+
super(props);
|
|
80
|
+
this.state = { errorMessage: null };
|
|
81
|
+
}
|
|
82
|
+
static getDerivedStateFromError(error2) {
|
|
83
|
+
return { errorMessage: error2.message };
|
|
84
|
+
}
|
|
85
|
+
componentDidCatch(error2, errorInfo) {
|
|
86
|
+
console.log(`error creating component at ${this.props.url}`);
|
|
87
|
+
console.log(error2, errorInfo);
|
|
88
|
+
}
|
|
89
|
+
render() {
|
|
90
|
+
if (this.state.errorMessage) {
|
|
91
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
92
|
+
/* @__PURE__ */ jsx3("h1", { children: "An error occured while creating component." }),
|
|
93
|
+
/* @__PURE__ */ jsx3("p", { children: this.state.errorMessage })
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
return this.props.children;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// src/feature/Loader.tsx
|
|
101
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
102
|
+
var Loader = () => /* @__PURE__ */ jsx4("div", { className: "hwLoader", children: "loading" });
|
|
103
|
+
|
|
104
|
+
// src/feature/css-module-loader.ts
|
|
105
|
+
var importCSS = async (path) => {
|
|
106
|
+
const container = new CSSStyleSheet();
|
|
107
|
+
return fetch(path).then((x) => x.text()).then((x) => container.replace(x));
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// src/feature/Feature.tsx
|
|
111
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
112
|
+
var componentsMap = /* @__PURE__ */ new Map();
|
|
113
|
+
var useCachedFeature = (url) => {
|
|
114
|
+
useEffect2(
|
|
115
|
+
() => () => {
|
|
116
|
+
componentsMap.delete(url);
|
|
117
|
+
},
|
|
118
|
+
[url]
|
|
119
|
+
);
|
|
120
|
+
if (!componentsMap.has(url)) {
|
|
121
|
+
componentsMap.set(
|
|
122
|
+
url,
|
|
123
|
+
React3.lazy(() => import(
|
|
124
|
+
/* @vite-ignore */
|
|
125
|
+
url
|
|
126
|
+
))
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const lazyFeature = componentsMap.get(url);
|
|
130
|
+
if (!lazyFeature) {
|
|
131
|
+
throw Error(`Unable to load Lazy Feature at url ${url}`);
|
|
132
|
+
} else {
|
|
133
|
+
return lazyFeature;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
function RawFeature({
|
|
137
|
+
url,
|
|
138
|
+
css,
|
|
139
|
+
ComponentProps: params,
|
|
140
|
+
...props
|
|
141
|
+
}) {
|
|
142
|
+
if (css) {
|
|
143
|
+
importCSS(css).then((styleSheet) => {
|
|
144
|
+
document.adoptedStyleSheets = [
|
|
145
|
+
...document.adoptedStyleSheets,
|
|
146
|
+
styleSheet
|
|
147
|
+
];
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const LazyFeature = useCachedFeature(url);
|
|
151
|
+
return /* @__PURE__ */ jsx5(FeatureErrorBoundary, { url, children: /* @__PURE__ */ jsx5(Suspense, { fallback: /* @__PURE__ */ jsx5(Loader, {}), children: /* @__PURE__ */ jsx5(LazyFeature, { ...props, ...params }) }) });
|
|
152
|
+
}
|
|
153
|
+
var Feature = React3.memo(RawFeature);
|
|
154
|
+
Feature.displayName = "Feature";
|
|
155
|
+
registerComponent("Feature", Feature, "view");
|
|
156
|
+
|
|
157
|
+
// src/layout-config/use-layout-config.ts
|
|
158
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useState as useState2 } from "react";
|
|
159
|
+
|
|
160
|
+
// src/layout-config/local-config.ts
|
|
161
|
+
import { resolveJSONPath } from "@vuu-ui/vuu-layout";
|
|
162
|
+
var loadLocalConfig = (saveUrl, user, id = "latest") => new Promise((resolve, reject) => {
|
|
163
|
+
console.log(
|
|
164
|
+
`load local config at ${saveUrl} for user ${user == null ? void 0 : user.username}, id ${id}`
|
|
165
|
+
);
|
|
166
|
+
const data = localStorage.getItem(saveUrl);
|
|
167
|
+
if (data) {
|
|
168
|
+
const layout = JSON.parse(data);
|
|
169
|
+
resolve(layout);
|
|
170
|
+
} else {
|
|
171
|
+
reject();
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
var saveLocalConfig = (saveUrl, user, data) => new Promise((resolve, reject) => {
|
|
175
|
+
try {
|
|
176
|
+
const layoutJson = resolveJSONPath(data, "#main-tabs.ACTIVE_CHILD");
|
|
177
|
+
console.log(layoutJson);
|
|
178
|
+
localStorage.setItem(saveUrl, JSON.stringify(data));
|
|
179
|
+
resolve(void 0);
|
|
180
|
+
} catch {
|
|
181
|
+
reject();
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// src/layout-config/remote-config.ts
|
|
186
|
+
var loadRemoteConfig = (saveUrl, user, id = "latest") => new Promise((resolve, reject) => {
|
|
187
|
+
if (user === void 0) {
|
|
188
|
+
throw Error("user mustb be provided to load remote config");
|
|
189
|
+
}
|
|
190
|
+
fetch(`${saveUrl}/${user.username}/${id}`, {}).then((response) => {
|
|
191
|
+
if (response.ok) {
|
|
192
|
+
resolve(response.json());
|
|
193
|
+
} else {
|
|
194
|
+
reject(void 0);
|
|
195
|
+
}
|
|
196
|
+
}).catch(() => {
|
|
197
|
+
reject(void 0);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
var saveRemoteConfig = (saveUrl, user, data) => new Promise((resolve, reject) => {
|
|
201
|
+
if (user === void 0) {
|
|
202
|
+
throw Error("user mustb be provided to load remote config");
|
|
203
|
+
}
|
|
204
|
+
fetch(`${saveUrl}/${user.username}`, {
|
|
205
|
+
method: "POST",
|
|
206
|
+
headers: {
|
|
207
|
+
"Content-Type": "application/json"
|
|
208
|
+
},
|
|
209
|
+
body: JSON.stringify(data)
|
|
210
|
+
}).then((response) => {
|
|
211
|
+
if (response.ok) {
|
|
212
|
+
resolve(void 0);
|
|
213
|
+
} else {
|
|
214
|
+
reject();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// src/layout-config/use-layout-config.ts
|
|
220
|
+
var FALLBACK_LAYOUT = { type: "Placeholder" };
|
|
221
|
+
var useLayoutConfig = ({
|
|
222
|
+
saveLocation,
|
|
223
|
+
saveUrl = "api/vui",
|
|
224
|
+
user,
|
|
225
|
+
// TODO this should be an error panel
|
|
226
|
+
defaultLayout = FALLBACK_LAYOUT
|
|
227
|
+
}) => {
|
|
228
|
+
const [layout, _setLayout] = useState2(defaultLayout);
|
|
229
|
+
const usingRemote = saveLocation === "remote";
|
|
230
|
+
const loadConfig = usingRemote ? loadRemoteConfig : loadLocalConfig;
|
|
231
|
+
const saveConfig = usingRemote ? saveRemoteConfig : saveLocalConfig;
|
|
232
|
+
const load = useCallback2(
|
|
233
|
+
async (id = "latest") => {
|
|
234
|
+
try {
|
|
235
|
+
const layout2 = await loadConfig(saveUrl, user, id);
|
|
236
|
+
_setLayout(layout2);
|
|
237
|
+
} catch {
|
|
238
|
+
_setLayout(defaultLayout);
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
[defaultLayout, loadConfig, saveUrl, user]
|
|
242
|
+
);
|
|
243
|
+
useEffect3(() => {
|
|
244
|
+
load();
|
|
245
|
+
}, [load]);
|
|
246
|
+
const saveData = useCallback2(
|
|
247
|
+
(data) => {
|
|
248
|
+
saveConfig(saveUrl, user, data);
|
|
249
|
+
},
|
|
250
|
+
[saveConfig, saveUrl, user]
|
|
251
|
+
);
|
|
252
|
+
const loadLayoutById = useCallback2((id) => load(id), [load]);
|
|
253
|
+
return [layout, saveData, loadLayoutById];
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// src/layout-management/SaveLayoutPanel.tsx
|
|
257
|
+
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
258
|
+
import { Input, Button, FormField, FormFieldLabel, Text } from "@salt-ds/core";
|
|
259
|
+
import { ComboBox, Checkbox, RadioButton } from "@vuu-ui/vuu-ui-controls";
|
|
260
|
+
import { formatDate, takeScreenshot } from "@vuu-ui/vuu-utils";
|
|
261
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
262
|
+
var classBase2 = "saveLayoutPanel";
|
|
263
|
+
var formField = `${classBase2}-formField`;
|
|
264
|
+
var groups = ["Group 1", "Group 2", "Group 3", "Group 4", "Group 5"];
|
|
265
|
+
var checkboxValues = ["Value 1", "Value 2", "Value 3"];
|
|
266
|
+
var radioValues = ["Value 1", "Value 2", "Value 3"];
|
|
267
|
+
var SaveLayoutPanel = (props) => {
|
|
268
|
+
const { onCancel, onSave, componentId } = props;
|
|
269
|
+
const [layoutName, setLayoutName] = useState3("");
|
|
270
|
+
const [group, setGroup] = useState3("");
|
|
271
|
+
const [checkValues, setCheckValues] = useState3([]);
|
|
272
|
+
const [radioValue, setRadioValue] = useState3(radioValues[0]);
|
|
273
|
+
const [screenshot, setScreenshot] = useState3();
|
|
274
|
+
useEffect4(() => {
|
|
275
|
+
if (componentId) {
|
|
276
|
+
takeScreenshot(document.getElementById(componentId)).then(
|
|
277
|
+
(screenshot2) => setScreenshot(screenshot2)
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}, []);
|
|
281
|
+
const handleSubmit = () => {
|
|
282
|
+
onSave({
|
|
283
|
+
name: layoutName,
|
|
284
|
+
group,
|
|
285
|
+
screenshot: screenshot != null ? screenshot : "",
|
|
286
|
+
user: "User",
|
|
287
|
+
date: formatDate(/* @__PURE__ */ new Date(), "dd.mm.yyyy")
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
return /* @__PURE__ */ jsxs3("div", { className: `${classBase2}-panelContainer`, children: [
|
|
291
|
+
/* @__PURE__ */ jsxs3("div", { className: `${classBase2}-panelContent`, children: [
|
|
292
|
+
/* @__PURE__ */ jsxs3("div", { className: `${classBase2}-formContainer`, children: [
|
|
293
|
+
/* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
|
|
294
|
+
/* @__PURE__ */ jsx6(FormFieldLabel, { children: "Group" }),
|
|
295
|
+
/* @__PURE__ */ jsx6(
|
|
296
|
+
ComboBox,
|
|
297
|
+
{
|
|
298
|
+
ListProps: {
|
|
299
|
+
style: {
|
|
300
|
+
zIndex: 1e4,
|
|
301
|
+
border: "1px solid #777C94",
|
|
302
|
+
borderRadius: 10,
|
|
303
|
+
boxSizing: "border-box"
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
source: groups,
|
|
307
|
+
allowFreeText: true,
|
|
308
|
+
InputProps: {
|
|
309
|
+
inputProps: {
|
|
310
|
+
className: `${classBase2}-inputText`,
|
|
311
|
+
placeholder: "Select Group or Enter New Name",
|
|
312
|
+
onChange: (event) => setGroup(event.target.value)
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
width: 120,
|
|
316
|
+
onSelectionChange: (_, value) => setGroup(value || "")
|
|
317
|
+
}
|
|
318
|
+
)
|
|
319
|
+
] }),
|
|
320
|
+
/* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
|
|
321
|
+
/* @__PURE__ */ jsx6(FormFieldLabel, { children: "Layout Name" }),
|
|
322
|
+
/* @__PURE__ */ jsx6(
|
|
323
|
+
Input,
|
|
324
|
+
{
|
|
325
|
+
inputProps: {
|
|
326
|
+
className: `${classBase2}-inputText`,
|
|
327
|
+
placeholder: "Enter Layout Name"
|
|
328
|
+
},
|
|
329
|
+
onChange: (event) => setLayoutName(event.target.value),
|
|
330
|
+
value: layoutName
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
] }),
|
|
334
|
+
/* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
|
|
335
|
+
/* @__PURE__ */ jsx6(FormFieldLabel, { children: "Some Layout Setting" }),
|
|
336
|
+
/* @__PURE__ */ jsx6("div", { className: `${classBase2}-settingsGroup`, children: checkboxValues.map((value, i) => /* @__PURE__ */ jsx6(
|
|
337
|
+
Checkbox,
|
|
338
|
+
{
|
|
339
|
+
onToggle: () => setCheckValues(
|
|
340
|
+
(prev) => prev.includes(value) ? prev.filter((entry) => entry !== value) : [...prev, value]
|
|
341
|
+
),
|
|
342
|
+
checked: checkValues.includes(value),
|
|
343
|
+
label: value
|
|
344
|
+
},
|
|
345
|
+
i
|
|
346
|
+
)) })
|
|
347
|
+
] }),
|
|
348
|
+
/* @__PURE__ */ jsxs3(FormField, { className: formField, children: [
|
|
349
|
+
/* @__PURE__ */ jsx6(FormFieldLabel, { children: "Some Layout Setting" }),
|
|
350
|
+
/* @__PURE__ */ jsx6("div", { className: `${classBase2}-settingsGroup`, children: radioValues.map((value, i) => /* @__PURE__ */ jsx6(
|
|
351
|
+
RadioButton,
|
|
352
|
+
{
|
|
353
|
+
onClick: () => setRadioValue(value),
|
|
354
|
+
checked: radioValue === value,
|
|
355
|
+
label: value,
|
|
356
|
+
groupName: "radioGroup"
|
|
357
|
+
},
|
|
358
|
+
i
|
|
359
|
+
)) })
|
|
360
|
+
] })
|
|
361
|
+
] }),
|
|
362
|
+
/* @__PURE__ */ jsx6("div", { className: `${classBase2}-screenshotContainer`, children: screenshot ? /* @__PURE__ */ jsx6(
|
|
363
|
+
"img",
|
|
364
|
+
{
|
|
365
|
+
className: `${classBase2}-screenshot`,
|
|
366
|
+
src: screenshot,
|
|
367
|
+
alt: "screenshot of current layout"
|
|
368
|
+
}
|
|
369
|
+
) : /* @__PURE__ */ jsx6(Text, { className: "screenshot", children: "No screenshot available" }) })
|
|
370
|
+
] }),
|
|
371
|
+
/* @__PURE__ */ jsxs3("div", { className: `${classBase2}-buttonsContainer`, children: [
|
|
372
|
+
/* @__PURE__ */ jsx6(Button, { className: `${classBase2}-cancelButton`, onClick: onCancel, children: "Cancel" }),
|
|
373
|
+
/* @__PURE__ */ jsx6(
|
|
374
|
+
Button,
|
|
375
|
+
{
|
|
376
|
+
className: `${classBase2}-saveButton`,
|
|
377
|
+
onClick: handleSubmit,
|
|
378
|
+
disabled: layoutName === "" || group === "",
|
|
379
|
+
children: "Save"
|
|
380
|
+
}
|
|
381
|
+
)
|
|
382
|
+
] })
|
|
383
|
+
] });
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// src/layout-management/LayoutList.tsx
|
|
387
|
+
import { List } from "@vuu-ui/vuu-ui-controls";
|
|
388
|
+
|
|
389
|
+
// src/layout-management/useLayoutManager.tsx
|
|
390
|
+
import React4, { useState as useState4, useCallback as useCallback3, useContext, useEffect as useEffect5 } from "react";
|
|
391
|
+
import { getLocalEntity, saveLocalEntity } from "@vuu-ui/vuu-filters";
|
|
392
|
+
import { getUniqueId } from "@vuu-ui/vuu-utils";
|
|
393
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
394
|
+
var LayoutManagementContext = React4.createContext({ layouts: [], saveLayout: () => {
|
|
395
|
+
} });
|
|
396
|
+
var LayoutManagementProvider = (props) => {
|
|
397
|
+
const [layouts, setLayouts] = useState4([]);
|
|
398
|
+
useEffect5(() => {
|
|
399
|
+
const layouts2 = getLocalEntity("layouts");
|
|
400
|
+
setLayouts(layouts2 || []);
|
|
401
|
+
}, []);
|
|
402
|
+
useEffect5(() => {
|
|
403
|
+
saveLocalEntity("layouts", layouts);
|
|
404
|
+
}, [layouts]);
|
|
405
|
+
const saveLayout = useCallback3((metadata) => {
|
|
406
|
+
const json = getLocalEntity("api/vui");
|
|
407
|
+
if (json) {
|
|
408
|
+
setLayouts((prev) => [
|
|
409
|
+
...prev,
|
|
410
|
+
{
|
|
411
|
+
metadata: {
|
|
412
|
+
...metadata,
|
|
413
|
+
id: getUniqueId()
|
|
414
|
+
},
|
|
415
|
+
json
|
|
416
|
+
}
|
|
417
|
+
]);
|
|
418
|
+
}
|
|
419
|
+
}, []);
|
|
420
|
+
return /* @__PURE__ */ jsx7(LayoutManagementContext.Provider, { value: { layouts, saveLayout }, children: props.children });
|
|
421
|
+
};
|
|
422
|
+
var useLayoutManager = () => useContext(LayoutManagementContext);
|
|
423
|
+
|
|
424
|
+
// src/layout-management/LayoutList.tsx
|
|
425
|
+
import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
426
|
+
var classBase3 = "vuuLayoutList";
|
|
427
|
+
var LayoutsList = (props) => {
|
|
428
|
+
const { layouts } = useLayoutManager();
|
|
429
|
+
const layoutMetadata = layouts.map((layout) => layout.metadata);
|
|
430
|
+
const handleLoadLayout = (layoutId) => {
|
|
431
|
+
console.log("loading layout with id", layoutId);
|
|
432
|
+
console.log(
|
|
433
|
+
"json:",
|
|
434
|
+
layouts.find((layout) => layout.metadata.id === layoutId)
|
|
435
|
+
);
|
|
436
|
+
};
|
|
437
|
+
const layoutsByGroup = layoutMetadata.reduce((acc, cur) => {
|
|
438
|
+
if (acc[cur.group]) {
|
|
439
|
+
return {
|
|
440
|
+
...acc,
|
|
441
|
+
[cur.group]: [...acc[cur.group], cur]
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
return {
|
|
445
|
+
...acc,
|
|
446
|
+
[cur.group]: [cur]
|
|
447
|
+
};
|
|
448
|
+
}, {});
|
|
449
|
+
return /* @__PURE__ */ jsxs4("div", { className: classBase3, ...props, children: [
|
|
450
|
+
/* @__PURE__ */ jsx8("div", { className: `${classBase3}-header`, children: "My Layouts" }),
|
|
451
|
+
/* @__PURE__ */ jsx8(
|
|
452
|
+
List,
|
|
453
|
+
{
|
|
454
|
+
height: "fit-content",
|
|
455
|
+
source: Object.entries(layoutsByGroup),
|
|
456
|
+
ListItem: ({ item }) => /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
457
|
+
/* @__PURE__ */ jsx8("div", { className: `${classBase3}-groupName`, children: item == null ? void 0 : item[0] }),
|
|
458
|
+
/* @__PURE__ */ jsx8(
|
|
459
|
+
List,
|
|
460
|
+
{
|
|
461
|
+
height: "fit-content",
|
|
462
|
+
source: item == null ? void 0 : item[1],
|
|
463
|
+
ListItem: ({ item: layout }) => /* @__PURE__ */ jsxs4(
|
|
464
|
+
"div",
|
|
465
|
+
{
|
|
466
|
+
className: `${classBase3}-layoutContainer`,
|
|
467
|
+
onClick: () => handleLoadLayout(layout == null ? void 0 : layout.id),
|
|
468
|
+
children: [
|
|
469
|
+
/* @__PURE__ */ jsx8(
|
|
470
|
+
"img",
|
|
471
|
+
{
|
|
472
|
+
className: `${classBase3}-screenshot`,
|
|
473
|
+
src: layout == null ? void 0 : layout.screenshot
|
|
474
|
+
}
|
|
475
|
+
),
|
|
476
|
+
/* @__PURE__ */ jsxs4("div", { children: [
|
|
477
|
+
/* @__PURE__ */ jsx8("div", { className: `${classBase3}-layoutName`, children: layout == null ? void 0 : layout.name }),
|
|
478
|
+
/* @__PURE__ */ jsx8("div", { className: `${classBase3}-layoutDetails`, children: /* @__PURE__ */ jsx8("div", { children: `${layout == null ? void 0 : layout.user}, ${layout == null ? void 0 : layout.date}` }) })
|
|
479
|
+
] })
|
|
480
|
+
]
|
|
481
|
+
},
|
|
482
|
+
layout == null ? void 0 : layout.id
|
|
483
|
+
)
|
|
484
|
+
}
|
|
485
|
+
)
|
|
486
|
+
] })
|
|
487
|
+
}
|
|
488
|
+
)
|
|
489
|
+
] });
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
// ../vuu-icons/src/VuuLogo.tsx
|
|
493
|
+
import { memo } from "react";
|
|
494
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
495
|
+
var VuuLogo = memo(() => {
|
|
496
|
+
return /* @__PURE__ */ jsxs5(
|
|
497
|
+
"svg",
|
|
498
|
+
{
|
|
499
|
+
width: "44",
|
|
500
|
+
height: "45",
|
|
501
|
+
viewBox: "0 0 44 45",
|
|
502
|
+
fill: "none",
|
|
503
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
504
|
+
children: [
|
|
505
|
+
/* @__PURE__ */ jsxs5("g", { clipPath: "url(#clip0_217_6990)", children: [
|
|
506
|
+
/* @__PURE__ */ jsx9(
|
|
507
|
+
"path",
|
|
508
|
+
{
|
|
509
|
+
d: "M39.8642 15.5509L35.9196 7.58974L34.3369 6.85464L24.6235 22.0825L39.1628 30.618L42.3152 25.6347L39.8642 15.5509Z",
|
|
510
|
+
fill: "url(#paint0_linear_217_6990)"
|
|
511
|
+
}
|
|
512
|
+
),
|
|
513
|
+
/* @__PURE__ */ jsx9(
|
|
514
|
+
"path",
|
|
515
|
+
{
|
|
516
|
+
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",
|
|
517
|
+
fill: "url(#paint1_linear_217_6990)"
|
|
518
|
+
}
|
|
519
|
+
),
|
|
520
|
+
/* @__PURE__ */ jsx9(
|
|
521
|
+
"path",
|
|
522
|
+
{
|
|
523
|
+
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",
|
|
524
|
+
fill: "#F37880"
|
|
525
|
+
}
|
|
526
|
+
),
|
|
527
|
+
/* @__PURE__ */ jsxs5("g", { opacity: "0.86", children: [
|
|
528
|
+
/* @__PURE__ */ jsx9(
|
|
529
|
+
"path",
|
|
530
|
+
{
|
|
531
|
+
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",
|
|
532
|
+
fill: "white"
|
|
533
|
+
}
|
|
534
|
+
),
|
|
535
|
+
/* @__PURE__ */ jsx9(
|
|
536
|
+
"path",
|
|
537
|
+
{
|
|
538
|
+
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",
|
|
539
|
+
fill: "white"
|
|
540
|
+
}
|
|
541
|
+
),
|
|
542
|
+
/* @__PURE__ */ jsx9(
|
|
543
|
+
"path",
|
|
544
|
+
{
|
|
545
|
+
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",
|
|
546
|
+
fill: "white"
|
|
547
|
+
}
|
|
548
|
+
)
|
|
549
|
+
] })
|
|
550
|
+
] }),
|
|
551
|
+
/* @__PURE__ */ jsxs5("defs", { children: [
|
|
552
|
+
/* @__PURE__ */ jsxs5(
|
|
553
|
+
"linearGradient",
|
|
554
|
+
{
|
|
555
|
+
id: "paint0_linear_217_6990",
|
|
556
|
+
x1: "24.6235",
|
|
557
|
+
y1: "18.7363",
|
|
558
|
+
x2: "42.3152",
|
|
559
|
+
y2: "18.7363",
|
|
560
|
+
gradientUnits: "userSpaceOnUse",
|
|
561
|
+
children: [
|
|
562
|
+
/* @__PURE__ */ jsx9("stop", { stopColor: "#4906A5" }),
|
|
563
|
+
/* @__PURE__ */ jsx9("stop", { offset: "1", stopColor: "#D3423A" })
|
|
564
|
+
]
|
|
565
|
+
}
|
|
566
|
+
),
|
|
567
|
+
/* @__PURE__ */ jsxs5(
|
|
568
|
+
"linearGradient",
|
|
569
|
+
{
|
|
570
|
+
id: "paint1_linear_217_6990",
|
|
571
|
+
x1: "-2.35794e-05",
|
|
572
|
+
y1: "22.5009",
|
|
573
|
+
x2: "42.7186",
|
|
574
|
+
y2: "22.5009",
|
|
575
|
+
gradientUnits: "userSpaceOnUse",
|
|
576
|
+
children: [
|
|
577
|
+
/* @__PURE__ */ jsx9("stop", { stopColor: "#7C06A5" }),
|
|
578
|
+
/* @__PURE__ */ jsx9("stop", { offset: "1", stopColor: "#D3423A" })
|
|
579
|
+
]
|
|
580
|
+
}
|
|
581
|
+
),
|
|
582
|
+
/* @__PURE__ */ jsx9("clipPath", { id: "clip0_217_6990", children: /* @__PURE__ */ jsx9("rect", { width: "44", height: "45", fill: "white" }) })
|
|
583
|
+
] })
|
|
584
|
+
]
|
|
585
|
+
}
|
|
586
|
+
);
|
|
587
|
+
});
|
|
588
|
+
VuuLogo.displayName = "VuuLogo";
|
|
589
|
+
|
|
590
|
+
// src/left-nav/LeftNav.tsx
|
|
591
|
+
import { Action, Stack, useLayoutProviderDispatch } from "@vuu-ui/vuu-layout";
|
|
592
|
+
import { Tab, Tabstrip } from "@vuu-ui/vuu-ui-controls";
|
|
593
|
+
import cx4 from "classnames";
|
|
594
|
+
import { useCallback as useCallback4, useState as useState5 } from "react";
|
|
595
|
+
|
|
596
|
+
// src/feature-list/FeatureList.tsx
|
|
597
|
+
import { Palette, PaletteItem } from "@vuu-ui/vuu-layout";
|
|
598
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
599
|
+
var classBase4 = "vuuFeatureList";
|
|
600
|
+
var FeatureList = ({
|
|
601
|
+
features,
|
|
602
|
+
title = "VUU TABLES",
|
|
603
|
+
...htmlAttributes
|
|
604
|
+
}) => {
|
|
605
|
+
const ViewProps = {};
|
|
606
|
+
console.log({ features });
|
|
607
|
+
return /* @__PURE__ */ jsxs6("div", { ...htmlAttributes, className: classBase4, children: [
|
|
608
|
+
/* @__PURE__ */ jsx10("div", { className: `${classBase4}-header`, children: title }),
|
|
609
|
+
/* @__PURE__ */ jsx10(Palette, { orientation: "vertical", ViewProps, children: features.map((featureProps, i) => /* @__PURE__ */ jsx10(
|
|
610
|
+
PaletteItem,
|
|
611
|
+
{
|
|
612
|
+
closeable: true,
|
|
613
|
+
label: featureProps.title,
|
|
614
|
+
resizeable: true,
|
|
615
|
+
resize: "defer",
|
|
616
|
+
header: true,
|
|
617
|
+
children: /* @__PURE__ */ jsx10(Feature, { ...featureProps })
|
|
618
|
+
},
|
|
619
|
+
i
|
|
620
|
+
)) })
|
|
621
|
+
] });
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
// src/theme-provider/ThemeProvider.tsx
|
|
625
|
+
import {
|
|
626
|
+
createContext,
|
|
627
|
+
isValidElement,
|
|
628
|
+
cloneElement,
|
|
629
|
+
useContext as useContext2
|
|
630
|
+
} from "react";
|
|
631
|
+
import cx3 from "classnames";
|
|
632
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
633
|
+
var DEFAULT_DENSITY2 = "medium";
|
|
634
|
+
var DEFAULT_THEME = "salt-theme";
|
|
635
|
+
var DEFAULT_THEME_MODE = "light";
|
|
636
|
+
var ThemeContext = createContext({
|
|
637
|
+
density: "high",
|
|
638
|
+
theme: "vuu",
|
|
639
|
+
themeMode: "light"
|
|
640
|
+
});
|
|
641
|
+
var DEFAULT_THEME_ATTRIBUTES = [
|
|
642
|
+
"vuu",
|
|
643
|
+
"vuu-density-high",
|
|
644
|
+
"light"
|
|
645
|
+
];
|
|
646
|
+
var useThemeAttributes = () => {
|
|
647
|
+
const context = useContext2(ThemeContext);
|
|
648
|
+
if (context) {
|
|
649
|
+
return [
|
|
650
|
+
`${context.theme}-theme`,
|
|
651
|
+
`${context.theme}-density-${context.density}`,
|
|
652
|
+
context.themeMode
|
|
653
|
+
];
|
|
654
|
+
}
|
|
655
|
+
return DEFAULT_THEME_ATTRIBUTES;
|
|
656
|
+
};
|
|
657
|
+
var createThemedChildren = (children, theme, themeMode, density) => {
|
|
658
|
+
var _a;
|
|
659
|
+
if (isValidElement(children)) {
|
|
660
|
+
return cloneElement(children, {
|
|
661
|
+
className: cx3(
|
|
662
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
663
|
+
(_a = children.props) == null ? void 0 : _a.className,
|
|
664
|
+
`${theme}-theme`,
|
|
665
|
+
`${theme}-density-${density}`
|
|
666
|
+
),
|
|
667
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
668
|
+
// @ts-expect-error
|
|
669
|
+
"data-mode": themeMode
|
|
670
|
+
});
|
|
671
|
+
} else {
|
|
672
|
+
console.warn(
|
|
673
|
+
`
|
|
16
674
|
ThemeProvider can only apply CSS classes for theming to a single nested child element of the ThemeProvider.
|
|
17
|
-
Wrap elements with a single container`),o)},Mf=({applyThemeClasses:o=!1,children:e,theme:t,themeMode:n,density:r})=>{var f,h,p;let{density:s,themeMode:i,theme:l}=Pv(Ef),a=(f=r!=null?r:s)!=null?f:n2,c=(h=n!=null?n:i)!=null?h:r2,u=(p=t!=null?t:l)!=null?p:o2,d=o?i2(e,u,c,a):e;return l2(Ef.Provider,{value:{themeMode:c,density:a,theme:u},children:d})};Mf.displayName="ThemeProvider";import{jsx as pt,jsxs as pa}from"react/jsx-runtime";var Ur="vuuLeftNav",Bxe=({"data-path":o,features:e,onResize:t,sizeCollapsed:n=80,sizeContent:r=240,sizeExpanded:s=240,style:i,tableFeatures:l,...a})=>{let c=c2(),[u,d]=u2({activeTabIndex:0,navStatus:"menu-full"}),[f]=wt(),h=ha(v=>{switch(v){case"menu-icons":return s;case"menu-full":return n;case"menu-full-content":return n+r;case"menu-icons-content":return s+r}},[n,r,s]),p=v=>{switch(v){case"menu-icons":return"menu-full";case"menu-full":return"menu-icons";case"menu-full-content":return"menu-icons-content";case"menu-icons-content":return"menu-full-content"}},m=ha((v,x)=>{if(x===0){let C=v==="menu-full-content"?"menu-full":v==="menu-icons-content"?"menu-icons":v;return C==="menu-icons"?[n,C]:[s,C]}else{let C=v==="menu-full"?"menu-full-content":v==="menu-icons"?"menu-icons-content":v;return C==="menu-icons-content"?[n+r,C]:[s+r,C]}},[n,r,s]),g=ha(v=>{let[x,C]=m(u.navStatus,v);d({activeTabIndex:v,navStatus:C}),c({type:Dv.LAYOUT_RESIZE,path:o,size:x})},[c,m,u,o]),y=ha(()=>{let{activeTabIndex:v,navStatus:x}=u;d({activeTabIndex:v,navStatus:p(x)}),c({type:Dv.LAYOUT_RESIZE,path:o,size:h(x)})},[c,u,o,h]),E={...i,"--nav-menu-collapsed-width":`${n}px`,"--nav-menu-expanded-width":`${s}px`};return pa("div",{...a,className:Pf(Ur,`${Ur}-${u.navStatus}`),style:E,children:[pa("div",{className:Pf(`${Ur}-menu-primary`,f),"data-mode":"dark",children:[pt("div",{className:"vuuLeftNav-logo",children:pt(Tf,{})}),pt("div",{className:`${Ur}-main`,children:pa(HC,{activeTabIndex:u.activeTabIndex,animateSelectionThumb:!1,className:`${Ur}-Tabstrip`,onActiveChange:g,orientation:"vertical",children:[pt(Kr,{"data-icon":"demo",label:"DEMO"}),pt(Kr,{"data-icon":"features",label:"VUU FEATURES"}),pt(Kr,{"data-icon":"tables",label:"VUU TABLES"}),pt(Kr,{"data-icon":"templates",label:"LAYOUT TEMPLATES"}),pt(Kr,{"data-icon":"layouts",label:"MY LAYOUTS"})]})}),pt("div",{className:"vuuLeftNav-buttonBar",children:pt("button",{className:Pf("vuuLeftNav-toggleButton",{"vuuLeftNav-toggleButton-open":u.navStatus.startsWith("menu-full"),"vuuLeftNav-toggleButton-closed":u.navStatus.startsWith("menu-icons")}),"data-icon":u.navStatus.startsWith("menu-full")?"chevron-left":"chevron-right",onClick:y})})]}),pa(a2,{active:u.activeTabIndex-1,className:`${Ur}-menu-secondary`,showTabs:!1,children:[pt(kf,{features:e,title:"Vuu Features"}),pt(kf,{features:l,title:"Vuu Tables"}),pt("div",{style:{background:"green",height:"100%"},children:"Layout Templates"}),pt("div",{className:"vuuLeftNav-drawer",children:pt(Ev,{})})]})]})};import{useState as Iv}from"react";import{Button as d2,FormField as Rv,FormFieldLabel as Av,Input as Lv}from"@salt-ds/core";import{jsx as qs,jsxs as Df}from"react/jsx-runtime";var Ov="vuuLoginPanel",Xxe=({requirePassword:o=!0,onSubmit:e})=>{let[t,n]=Iv(""),[r,s]=Iv(""),i=()=>{e(t,r)},l=u=>{n(u.target.value)},a=u=>{s(u.target.value)},c=t.trim()!==""&&(o===!1||r.trim()!=="");return Df("div",{className:Ov,children:[Df(Rv,{style:{width:200},children:[qs(Av,{children:"Username"}),qs(Lv,{value:t,id:"text-username",onChange:l})]}),o?Df(Rv,{style:{width:200},children:[qs(Av,{children:"Password"}),qs(Lv,{inputProps:{type:"password"},value:r,id:"text-password",onChange:a})]}):null,qs(d2,{className:`${Ov}-login`,disabled:!c,onClick:i,variant:"cta",children:"Login"})]})};import{getCookieValue as If}from"@vuu-ui/vuu-utils";var f2=()=>{let o=If("vuu-auth-mode");return o!=null?o:""},eCe=()=>{let o=If("vuu-username"),e=If("vuu-auth-token");return[o,e]},h2=()=>f2()==="login"?"login.html":"demo.html",p2=(o=h2())=>{window.location.href=o},Nv=o=>{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",p2(o)};import{useCallback as Gr,useEffect as Hv,useMemo as m2,useRef as Rf,useState as Fv}from"react";import Bv from"classnames";import{useIdMemo as g2}from"@salt-ds/core";import{Button as Vv}from"@salt-ds/core";import{hasAction as b2,isErrorResponse as y2,RemoteDataSource as x2}from"@vuu-ui/vuu-data";import{buildColumnMap as C2,isValidNumber as $v,shallowEquals as v2}from"@vuu-ui/vuu-utils";import{jsx as Qo,jsxs as Af}from"react/jsx-runtime";var Hn="vuuSessionEditingForm",Kv=(o,e)=>{let t=o.find(n=>n.name===e);if(t)return t;throw Error(`SessionEditingForm, no field '${e}' found`)},zv=o=>{let{dataset:{field:e},value:t}=o.target;if(e===void 0)throw Error("SessionEditingForm, form field has no field name");return[e,t]},Fn={uninitialised:0,unchanged:1,changed:2,invalid:3};function Wv(o,e,t=!1){switch(e){case"int":case"long":{let n=parseInt(o,10);if($v(n))return n;if(t)throw Error("SessionEditingForm getTypedValue");return}case"double":{let n=parseFloat(o);return $v(n)?n:void 0}case"boolean":return o==="true";default:return o}}var S2=(o,e)=>{if(o)return o;if(e)return new x2({bufferSize:0,table:e.table,columns:e.columns.map(t=>t.name)});throw Error("SessionEditingForm: either a DataSource or a TableSchema must be provided")},xCe=({className:o,config:{fields:e,key:t},dataSource:n,id:r,onClose:s,schema:i,...l})=>{let[a,c]=Fv(),[u,d]=Fv(""),f=Rf(null),h=Rf(),p=Rf(Fn.uninitialised),m=m2(()=>{let w=T=>{if(L){let P={};for(let R of m.columns)P[R]=T[L[R]];p.current===Fn.uninitialised&&(p.current=Fn.unchanged,h.current=P),c(P)}},k=S2(n,i),L=C2(k.columns);return k.subscribe({range:{from:0,to:5}},T=>{T.type==="viewport-update"&&T.rows&&(p.current===Fn.uninitialised?w(T.rows[0]):console.log("what do we do with server updates"))}),k},[n,i]),g=g2(r),y=Gr(w=>{let[k,L]=zv(w),{type:T}=Kv(e,k),P=Wv(L,T);c((R={})=>{let O={...R,[k]:P},A=v2(O,h.current);return p.current=A?Fn.unchanged:P!==void 0?Fn.changed:Fn.invalid,O})},[e]),E=Gr(w=>{let[k,L]=zv(w),{type:T}=Kv(e,k),P=a==null?void 0:a[t],R=Wv(L,T,!0);typeof P=="string"&&m.menuRpcCall({rowKey:P,field:k,value:R,type:"VP_EDIT_CELL_RPC"})},[m,e,t,a]),v=Gr(w=>{typeof w=="object"&&w!==null&&"type"in w&&w.type==="CLOSE_DIALOG_ACTION"&&s()},[s]),x=Gr(async()=>{let w=await m.menuRpcCall({type:"VP_EDIT_SUBMIT_FORM_RPC"});y2(w)?d(w.error):b2(w)&&v(w.action)},[v,m]),C=Gr(w=>{w.key==="Enter"&&p.current===Fn.changed&&x()},[x]),b=Gr(()=>{s()},[s]),S=w=>{var L;let k=String((L=a==null?void 0:a[w.name])!=null?L:"");return w.readonly||w.name===t?Qo("div",{className:`${Hn}-fieldValue vuuReadOnly`,children:k}):Qo("input",{className:`${Hn}-fieldValue`,"data-field":w.name,onBlur:E,onChange:y,type:"text",value:k,id:`${g}-input-${w.name}`})};Hv(()=>{if(f.current){let w=f.current.querySelector("input");w&&setTimeout(()=>{w.focus(),w.select()},100)}},[]),Hv(()=>()=>{m&&m.unsubscribe()},[m]);let M=p.current===Fn.changed;return Af("div",{...l,className:Bv(Hn,o),children:[u?Qo("div",{className:`${Hn}-errorBanner`,"data-icon":"error",title:u,children:"Error, edit(s) not saved"}):void 0,Qo("div",{className:`${Hn}-content`,ref:f,onKeyDown:C,children:e.map(w=>{var k;return Af("div",{className:`${Hn}-field`,children:[Qo("label",{className:Bv(`${Hn}-fieldLabel`,{[`${Hn}-required`]:w.required}),htmlFor:`${g}-input-${w.name}`,children:(k=w==null?void 0:w.label)!=null?k:w.description}),S(w)]},w.name)})}),Af("div",{className:`${Hn}-buttonbar salt-theme salt-density-high`,children:[Qo(Vv,{type:"submit",variant:"cta",disabled:!M,onClick:x,children:"Submit"}),Qo(Vv,{variant:"secondary",onClick:b,children:"Cancel"})]})]})};import{connectToServer as lF}from"@vuu-ui/vuu-data";import aF from"classnames";import{useCallback as Of,useEffect as cF,useRef as u0}from"react";import{DraggableLayout as uF,LayoutProvider as dF}from"@vuu-ui/vuu-layout";import{useCallback as W2}from"react";import{Button as L2}from"@salt-ds/core";import{DropdownBase as O2}from"@salt-ds/lab";import{UserSolidIcon as N2}from"@salt-ds/icons";import{formatDate as w2}from"@vuu-ui/vuu-utils";import{List as T2,ListItem as k2}from"@salt-ds/lab";import{Button as E2}from"@salt-ds/core";import{ExportIcon as M2}from"@salt-ds/icons";import{forwardRef as P2,useCallback as Gv,useEffect as D2,useState as I2}from"react";var Uv=async o=>await fetch(`api/vui/${o.username}`,{}).then(t=>t.ok?t.json():null).catch(()=>{console.log("error getting history")});import{jsx as ma,jsxs as _v}from"react/jsx-runtime";var R2=({lastUpdate:o},{lastUpdate:e})=>e===o?0:e<o?-1:1,A2=o=>ma(k2,{...o}),Qv=P2(function({loginUrl:e,onNavigate:t,user:n,layoutId:r="latest"},s){let[i,l]=I2([]);D2(()=>{async function d(){let h=(await Uv(n)).filter(p=>p.id!=="latest").sort(R2).map(({id:p,lastUpdate:m})=>({lastUpdate:m,id:p,label:`Saved at ${w2(new Date(m),"kk:mm:ss")}`}));console.log({sortedHistory:h}),l(h)}d()},[n]);let a=Gv((d,f)=>{f&&t(f.id)},[t]),c=Gv(()=>{Nv(e)},[e]),u=i.length===0?null:r==="latest"?i[0]:i.find(d=>d.id===r);return _v("div",{className:"vuuUserPanel",ref:s,children:[ma(T2,{ListItem:A2,className:"vuuUserPanel-history",onSelect:a,selected:u,source:i}),ma("div",{className:"vuuUserPanel-buttonBar",children:_v(E2,{"aria-label":"logout",onClick:c,children:[ma(M2,{})," Logout"]})})]})});import{jsx as Lf,jsxs as H2}from"react/jsx-runtime";var qv=({layoutId:o,loginUrl:e,onNavigate:t,user:n})=>H2(O2,{className:"vuuUserProfile",placement:"bottom-end",children:[Lf(L2,{variant:"secondary",children:Lf(N2,{})}),Lf(Qv,{layoutId:o,loginUrl:e,onNavigate:s=>{t(s)},user:n})]});import F2 from"classnames";import{ToggleButton as jv,ToggleButtonGroup as B2,useControlled as V2}from"@salt-ds/core";import{useCallback as $2}from"react";import{jsx as Xv,jsxs as z2}from"react/jsx-runtime";var K2="vuuThemeSwitch",Jv=({className:o,defaultMode:e,mode:t,onChange:n,...r})=>{let[s,i]=V2({controlled:t,default:e!=null?e:"light",name:"ThemeSwitch",state:"mode"}),l=$2(c=>{let{value:u}=c.target;i(u),n(u)},[n,i]),a=F2(K2,o);return z2(B2,{className:a,...r,onChange:l,value:s,children:[Xv(jv,{"aria-label":"alert","data-icon":"light",value:"dark"}),Xv(jv,{"aria-label":"home","data-icon":"dark",value:"light"})]})};import U2 from"classnames";import{jsx as Yv,jsxs as _2}from"react/jsx-runtime";var G2="vuuAppHeader",Zv=({className:o,layoutId:e,loginUrl:t,onNavigate:n,onSwitchTheme:r,themeMode:s="light",user:i,...l})=>{let a=U2(G2,o),c=W2(u=>r==null?void 0:r(u),[r]);return _2("header",{className:a,...l,children:[Yv(Jv,{defaultMode:s,onChange:c}),Yv(qv,{layoutId:e,loginUrl:t,onNavigate:n,user:i})]})};import{logger as fF}from"@vuu-ui/vuu-utils";import{Button as Q2}from"@salt-ds/core";import e0 from"classnames";import{useCallback as q2,useMemo as j2}from"react";import{layoutFromJson as X2,useLayoutProviderDispatch as J2}from"@vuu-ui/vuu-layout";import{jsx as ga,jsxs as t0}from"react/jsx-runtime";var xn="vuuContextPanel",n0=({className:o,expanded:e=!1,content:t,overlay:n=!1,title:r})=>{let s=J2(),i=q2(()=>{s({path:"#context-panel",propName:"expanded",propValue:!1,type:"set-prop"})},[s]),l=e0(xn,o,{[`${xn}-expanded`]:e,[`${xn}-inline`]:n!==!0,[`${xn}-overlay`]:n}),a=j2(()=>t?X2(t,"context-0"):null,[t]);return ga("div",{className:e0(xn,l),children:t0("div",{className:`${xn}-inner`,children:[t0("div",{className:`${xn}-header`,children:[ga("h2",{className:`${xn}-title`,children:r}),ga(Q2,{className:`${xn}-close`,"data-icon":"close",onClick:i,variant:"secondary"})]}),ga("div",{className:`${xn}-content`,children:a})]})})};import{DraggableLayout as Y2,Flexbox as o0}from"@vuu-ui/vuu-layout";import{jsx as r0,jsxs as s0}from"react/jsx-runtime";var i0=({appHeader:o,leftSidePanel:e})=>s0(o0,{className:"App",style:{flexDirection:"row",height:"100%",width:"100%"},children:[e,s0(o0,{className:"vuuShell-content",style:{flex:1,flexDirection:"column"},children:[o,r0(Y2,{dropTarget:!0,style:{flex:1}},"main-content")]}),r0(n0,{id:"context-panel",overlay:!0,title:"Column Settings"})]});import{DockLayout as Z2,DraggableLayout as eF,Drawer as tF,Flexbox as nF,View as oF}from"@vuu-ui/vuu-layout";import{useCallback as l0,useRef as rF,useState as sF}from"react";import{jsx as ba,jsxs as iF}from"react/jsx-runtime";var a0=({appHeader:o,leftSidePanel:e})=>{let t=rF(null),[n,r]=sF(!0),s=l0(l=>{var c;let a=l.target;(c=t.current)!=null&&c.contains(a)||r(!n)},[n]),i=l0(l=>{let a=[];return a.push(ba(tF,{onClick:s,open:n,position:"left",inline:!0,peekaboo:!0,sizeOpen:200,toggleButton:"end",children:ba(oF,{className:"vuuShell-palette",id:"vw-app-palette",ref:t,style:{height:"100%"},children:l},"app-palette")},"left-panel")),a},[s,n]);return iF(nF,{className:"App",style:{flexDirection:"column",height:"100%",width:"100%"},children:[o,ba(Z2,{style:{flex:1},children:i(e).concat(ba(eF,{dropTarget:!0,style:{width:"100%",height:"100%"}},"main-content"))})]})};var c0=({leftSidePanelLayout:o="inlay",...e})=>(o==="inlay"?a0:i0)(e);import{jsx as Hf,jsxs as pF}from"react/jsx-runtime";var{error:Nf}=fF("Shell"),hF={type:"View",props:{style:{height:"calc(100% - 6px)"}},children:[{props:{className:"vuuShell-warningPlaceholder"},type:"Placeholder"}]},h0e=({LayoutProps:o,children:e,className:t,defaultLayout:n=hF,leftSidePanel:r,leftSidePanelLayout:s,loginUrl:i,saveLocation:l="remote",saveUrl:a,serverUrl:c,user:u,...d})=>{let f=u0(null),h=u0("latest"),[p,m,g]=Yf({defaultLayout:n,saveLocation:l,saveUrl:a,user:u}),y=Of((w,k)=>{try{console.log(`handle layout changed ${k}`),m(w)}catch{Nf==null||Nf("Failed to save layout")}},[m]),E=Of(w=>{f.current&&(f.current.dataset.mode=w)},[]),v=Of(w=>{h.current=w,g(w)},[g]);cF(()=>{c&&u.token&&lF({authToken:u.token,url:c,username:u.username})},[c,u.token,u.username]);let[x,C,b]=wt(),S=aF("vuuShell",t,x,C),M=c0({leftSidePanelLayout:s,appHeader:Hf(Zv,{layoutId:h.current,loginUrl:i,user:u,onNavigate:v,onSwitchTheme:E}),leftSidePanel:r});return pF(Mf,{children:[Hf(dF,{...o,layout:p,onLayoutChange:y,children:Hf(uF,{className:S,"data-mode":b,ref:f,...d,children:M})}),e]})};import{createContext as mF,useContext as gF}from"react";import{jsx as Ff}from"react/jsx-runtime";var bF={},Bf=mF(bF),yF=({children:o,context:e,inheritedContext:t})=>{let n={...t,...e};return Ff(Bf.Provider,{value:n,children:o})},x0e=({children:o,value:e})=>Ff(Bf.Consumer,{children:t=>Ff(yF,{context:e,inheritedContext:t,children:o})}),C0e=()=>gF(Bf);export{kF as ConnectionStatusIcon,n0 as ContextPanel,n2 as DEFAULT_DENSITY,o2 as DEFAULT_THEME,r2 as DEFAULT_THEME_MODE,OF as DensitySwitch,ti as Feature,kf as FeatureList,Tv as LayoutManagementContext,$ye as LayoutManagementProvider,Ev as LayoutsList,Bxe as LeftNav,Xxe as LoginPanel,ahe as SaveLayoutPanel,xCe as SessionEditingForm,h0e as Shell,x0e as ShellContextProvider,Ef as ThemeContext,Mf as ThemeProvider,Jv as ThemeSwitch,eCe as getAuthDetailsFromCookies,f2 as getAuthModeFromCookies,Nv as logout,p2 as redirectToLogin,Yf as useLayoutConfig,kv as useLayoutManager,C0e as useShellContext,c0 as useShellLayout,wt as useThemeAttributes};
|
|
675
|
+
Wrap elements with a single container`
|
|
676
|
+
);
|
|
677
|
+
return children;
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
var ThemeProvider = ({
|
|
681
|
+
applyThemeClasses = false,
|
|
682
|
+
children,
|
|
683
|
+
theme: themeProp,
|
|
684
|
+
themeMode: themeModeProp,
|
|
685
|
+
density: densityProp
|
|
686
|
+
}) => {
|
|
687
|
+
var _a, _b, _c;
|
|
688
|
+
const {
|
|
689
|
+
density: inheritedDensity,
|
|
690
|
+
themeMode: inheritedThemeMode,
|
|
691
|
+
theme: inheritedTheme
|
|
692
|
+
} = useContext2(ThemeContext);
|
|
693
|
+
const density = (_a = densityProp != null ? densityProp : inheritedDensity) != null ? _a : DEFAULT_DENSITY2;
|
|
694
|
+
const themeMode = (_b = themeModeProp != null ? themeModeProp : inheritedThemeMode) != null ? _b : DEFAULT_THEME_MODE;
|
|
695
|
+
const theme = (_c = themeProp != null ? themeProp : inheritedTheme) != null ? _c : DEFAULT_THEME;
|
|
696
|
+
const themedChildren = applyThemeClasses ? createThemedChildren(children, theme, themeMode, density) : children;
|
|
697
|
+
return /* @__PURE__ */ jsx11(ThemeContext.Provider, { value: { themeMode, density, theme }, children: themedChildren });
|
|
698
|
+
};
|
|
699
|
+
ThemeProvider.displayName = "ThemeProvider";
|
|
700
|
+
|
|
701
|
+
// src/left-nav/LeftNav.tsx
|
|
702
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
703
|
+
var classBase5 = "vuuLeftNav";
|
|
704
|
+
var LeftNav = ({
|
|
705
|
+
"data-path": path,
|
|
706
|
+
features,
|
|
707
|
+
onResize,
|
|
708
|
+
sizeCollapsed = 80,
|
|
709
|
+
sizeContent = 240,
|
|
710
|
+
sizeExpanded = 240,
|
|
711
|
+
style: styleProp,
|
|
712
|
+
tableFeatures,
|
|
713
|
+
...htmlAttributes
|
|
714
|
+
}) => {
|
|
715
|
+
const dispatch = useLayoutProviderDispatch();
|
|
716
|
+
const [navState, setNavState] = useState5({
|
|
717
|
+
activeTabIndex: 0,
|
|
718
|
+
navStatus: "menu-full"
|
|
719
|
+
});
|
|
720
|
+
const [themeClass] = useThemeAttributes();
|
|
721
|
+
const toggleNavWidth = useCallback4(
|
|
722
|
+
(navStatus) => {
|
|
723
|
+
switch (navStatus) {
|
|
724
|
+
case "menu-icons":
|
|
725
|
+
return sizeExpanded;
|
|
726
|
+
case "menu-full":
|
|
727
|
+
return sizeCollapsed;
|
|
728
|
+
case "menu-full-content":
|
|
729
|
+
return sizeCollapsed + sizeContent;
|
|
730
|
+
case "menu-icons-content":
|
|
731
|
+
return sizeExpanded + sizeContent;
|
|
732
|
+
}
|
|
733
|
+
},
|
|
734
|
+
[sizeCollapsed, sizeContent, sizeExpanded]
|
|
735
|
+
);
|
|
736
|
+
const toggleNavStatus = (navStatus) => {
|
|
737
|
+
switch (navStatus) {
|
|
738
|
+
case "menu-icons":
|
|
739
|
+
return "menu-full";
|
|
740
|
+
case "menu-full":
|
|
741
|
+
return "menu-icons";
|
|
742
|
+
case "menu-full-content":
|
|
743
|
+
return "menu-icons-content";
|
|
744
|
+
case "menu-icons-content":
|
|
745
|
+
return "menu-full-content";
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
const getWidthAndStatus = useCallback4(
|
|
749
|
+
(navState2, tabIndex) => {
|
|
750
|
+
if (tabIndex === 0) {
|
|
751
|
+
const newNavState = navState2 === "menu-full-content" ? "menu-full" : navState2 === "menu-icons-content" ? "menu-icons" : navState2;
|
|
752
|
+
return newNavState === "menu-icons" ? [sizeCollapsed, newNavState] : [sizeExpanded, newNavState];
|
|
753
|
+
} else {
|
|
754
|
+
const newNavState = navState2 === "menu-full" ? "menu-full-content" : navState2 === "menu-icons" ? "menu-icons-content" : navState2;
|
|
755
|
+
return newNavState === "menu-icons-content" ? [sizeCollapsed + sizeContent, newNavState] : [sizeExpanded + sizeContent, newNavState];
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
[sizeCollapsed, sizeContent, sizeExpanded]
|
|
759
|
+
);
|
|
760
|
+
const handleTabSelection = useCallback4(
|
|
761
|
+
(value) => {
|
|
762
|
+
const [width, navStatus] = getWidthAndStatus(navState.navStatus, value);
|
|
763
|
+
setNavState({
|
|
764
|
+
activeTabIndex: value,
|
|
765
|
+
navStatus
|
|
766
|
+
});
|
|
767
|
+
dispatch({
|
|
768
|
+
type: Action.LAYOUT_RESIZE,
|
|
769
|
+
path,
|
|
770
|
+
size: width
|
|
771
|
+
});
|
|
772
|
+
},
|
|
773
|
+
[dispatch, getWidthAndStatus, navState, path]
|
|
774
|
+
);
|
|
775
|
+
const toggleSize = useCallback4(() => {
|
|
776
|
+
const { activeTabIndex, navStatus: currentNavStatus } = navState;
|
|
777
|
+
setNavState({
|
|
778
|
+
activeTabIndex,
|
|
779
|
+
navStatus: toggleNavStatus(currentNavStatus)
|
|
780
|
+
});
|
|
781
|
+
dispatch({
|
|
782
|
+
type: Action.LAYOUT_RESIZE,
|
|
783
|
+
path,
|
|
784
|
+
size: toggleNavWidth(currentNavStatus)
|
|
785
|
+
});
|
|
786
|
+
}, [dispatch, navState, path, toggleNavWidth]);
|
|
787
|
+
const style = {
|
|
788
|
+
...styleProp,
|
|
789
|
+
"--nav-menu-collapsed-width": `${sizeCollapsed}px`,
|
|
790
|
+
"--nav-menu-expanded-width": `${sizeExpanded}px`
|
|
791
|
+
};
|
|
792
|
+
return /* @__PURE__ */ jsxs7(
|
|
793
|
+
"div",
|
|
794
|
+
{
|
|
795
|
+
...htmlAttributes,
|
|
796
|
+
className: cx4(classBase5, `${classBase5}-${navState.navStatus}`),
|
|
797
|
+
style,
|
|
798
|
+
children: [
|
|
799
|
+
/* @__PURE__ */ jsxs7(
|
|
800
|
+
"div",
|
|
801
|
+
{
|
|
802
|
+
className: cx4(`${classBase5}-menu-primary`, themeClass),
|
|
803
|
+
"data-mode": "dark",
|
|
804
|
+
children: [
|
|
805
|
+
/* @__PURE__ */ jsx12("div", { className: "vuuLeftNav-logo", children: /* @__PURE__ */ jsx12(VuuLogo, {}) }),
|
|
806
|
+
/* @__PURE__ */ jsx12("div", { className: `${classBase5}-main`, children: /* @__PURE__ */ jsxs7(
|
|
807
|
+
Tabstrip,
|
|
808
|
+
{
|
|
809
|
+
activeTabIndex: navState.activeTabIndex,
|
|
810
|
+
animateSelectionThumb: false,
|
|
811
|
+
className: `${classBase5}-Tabstrip`,
|
|
812
|
+
onActiveChange: handleTabSelection,
|
|
813
|
+
orientation: "vertical",
|
|
814
|
+
children: [
|
|
815
|
+
/* @__PURE__ */ jsx12(Tab, { "data-icon": "demo", label: "DEMO" }),
|
|
816
|
+
/* @__PURE__ */ jsx12(Tab, { "data-icon": "features", label: "VUU FEATURES" }),
|
|
817
|
+
/* @__PURE__ */ jsx12(Tab, { "data-icon": "tables", label: "VUU TABLES" }),
|
|
818
|
+
/* @__PURE__ */ jsx12(Tab, { "data-icon": "templates", label: "LAYOUT TEMPLATES" }),
|
|
819
|
+
/* @__PURE__ */ jsx12(Tab, { "data-icon": "layouts", label: "MY LAYOUTS" })
|
|
820
|
+
]
|
|
821
|
+
}
|
|
822
|
+
) }),
|
|
823
|
+
/* @__PURE__ */ jsx12("div", { className: "vuuLeftNav-buttonBar", children: /* @__PURE__ */ jsx12(
|
|
824
|
+
"button",
|
|
825
|
+
{
|
|
826
|
+
className: cx4("vuuLeftNav-toggleButton", {
|
|
827
|
+
"vuuLeftNav-toggleButton-open": navState.navStatus.startsWith("menu-full"),
|
|
828
|
+
"vuuLeftNav-toggleButton-closed": navState.navStatus.startsWith("menu-icons")
|
|
829
|
+
}),
|
|
830
|
+
"data-icon": navState.navStatus.startsWith("menu-full") ? "chevron-left" : "chevron-right",
|
|
831
|
+
onClick: toggleSize
|
|
832
|
+
}
|
|
833
|
+
) })
|
|
834
|
+
]
|
|
835
|
+
}
|
|
836
|
+
),
|
|
837
|
+
/* @__PURE__ */ jsxs7(
|
|
838
|
+
Stack,
|
|
839
|
+
{
|
|
840
|
+
active: navState.activeTabIndex - 1,
|
|
841
|
+
className: `${classBase5}-menu-secondary`,
|
|
842
|
+
showTabs: false,
|
|
843
|
+
children: [
|
|
844
|
+
/* @__PURE__ */ jsx12(FeatureList, { features, title: "Vuu Features" }),
|
|
845
|
+
/* @__PURE__ */ jsx12(FeatureList, { features: tableFeatures, title: "Vuu Tables" }),
|
|
846
|
+
/* @__PURE__ */ jsx12("div", { style: { background: "green", height: "100%" }, children: "Layout Templates" }),
|
|
847
|
+
/* @__PURE__ */ jsx12("div", { className: "vuuLeftNav-drawer", children: /* @__PURE__ */ jsx12(LayoutsList, {}) })
|
|
848
|
+
]
|
|
849
|
+
}
|
|
850
|
+
)
|
|
851
|
+
]
|
|
852
|
+
}
|
|
853
|
+
);
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
// src/login/LoginPanel.tsx
|
|
857
|
+
import { useState as useState6 } from "react";
|
|
858
|
+
import { Button as Button2, FormField as FormField2, FormFieldLabel as FormFieldLabel2, Input as Input2 } from "@salt-ds/core";
|
|
859
|
+
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
860
|
+
var classBase6 = "vuuLoginPanel";
|
|
861
|
+
var LoginPanel = ({
|
|
862
|
+
requirePassword = true,
|
|
863
|
+
onSubmit
|
|
864
|
+
}) => {
|
|
865
|
+
const [username, setUserName] = useState6("");
|
|
866
|
+
const [password, setPassword] = useState6("");
|
|
867
|
+
const login = () => {
|
|
868
|
+
onSubmit(username, password);
|
|
869
|
+
};
|
|
870
|
+
const handleUsername = (evt) => {
|
|
871
|
+
setUserName(evt.target.value);
|
|
872
|
+
};
|
|
873
|
+
const handlePassword = (evt) => {
|
|
874
|
+
setPassword(evt.target.value);
|
|
875
|
+
};
|
|
876
|
+
const dataIsValid = username.trim() !== "" && (requirePassword === false || password.trim() !== "");
|
|
877
|
+
return /* @__PURE__ */ jsxs8("div", { className: classBase6, children: [
|
|
878
|
+
/* @__PURE__ */ jsxs8(FormField2, { style: { width: 200 }, children: [
|
|
879
|
+
/* @__PURE__ */ jsx13(FormFieldLabel2, { children: "Username" }),
|
|
880
|
+
/* @__PURE__ */ jsx13(Input2, { value: username, id: "text-username", onChange: handleUsername })
|
|
881
|
+
] }),
|
|
882
|
+
requirePassword ? /* @__PURE__ */ jsxs8(FormField2, { style: { width: 200 }, children: [
|
|
883
|
+
/* @__PURE__ */ jsx13(FormFieldLabel2, { children: "Password" }),
|
|
884
|
+
/* @__PURE__ */ jsx13(
|
|
885
|
+
Input2,
|
|
886
|
+
{
|
|
887
|
+
inputProps: {
|
|
888
|
+
type: "password"
|
|
889
|
+
},
|
|
890
|
+
value: password,
|
|
891
|
+
id: "text-password",
|
|
892
|
+
onChange: handlePassword
|
|
893
|
+
}
|
|
894
|
+
)
|
|
895
|
+
] }) : null,
|
|
896
|
+
/* @__PURE__ */ jsx13(
|
|
897
|
+
Button2,
|
|
898
|
+
{
|
|
899
|
+
className: `${classBase6}-login`,
|
|
900
|
+
disabled: !dataIsValid,
|
|
901
|
+
onClick: login,
|
|
902
|
+
variant: "cta",
|
|
903
|
+
children: "Login"
|
|
904
|
+
}
|
|
905
|
+
)
|
|
906
|
+
] });
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
// src/login/login-utils.ts
|
|
910
|
+
import { getCookieValue } from "@vuu-ui/vuu-utils";
|
|
911
|
+
var getAuthModeFromCookies = () => {
|
|
912
|
+
const mode = getCookieValue("vuu-auth-mode");
|
|
913
|
+
return mode != null ? mode : "";
|
|
914
|
+
};
|
|
915
|
+
var getAuthDetailsFromCookies = () => {
|
|
916
|
+
const username = getCookieValue("vuu-username");
|
|
917
|
+
const token = getCookieValue("vuu-auth-token");
|
|
918
|
+
return [username, token];
|
|
919
|
+
};
|
|
920
|
+
var getDefaultLoginUrl = () => {
|
|
921
|
+
const authMode = getAuthModeFromCookies();
|
|
922
|
+
return authMode === "login" ? "login.html" : "demo.html";
|
|
923
|
+
};
|
|
924
|
+
var redirectToLogin = (loginUrl = getDefaultLoginUrl()) => {
|
|
925
|
+
window.location.href = loginUrl;
|
|
926
|
+
};
|
|
927
|
+
var logout = (loginUrl) => {
|
|
928
|
+
document.cookie = "vuu-username= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
|
|
929
|
+
document.cookie = "vuu-auth-token= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
|
|
930
|
+
redirectToLogin(loginUrl);
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
// src/session-editing-form/SessionEditingForm.tsx
|
|
934
|
+
import {
|
|
935
|
+
useCallback as useCallback5,
|
|
936
|
+
useEffect as useEffect6,
|
|
937
|
+
useMemo,
|
|
938
|
+
useRef,
|
|
939
|
+
useState as useState7
|
|
940
|
+
} from "react";
|
|
941
|
+
import cx5 from "classnames";
|
|
942
|
+
import { useIdMemo } from "@salt-ds/core";
|
|
943
|
+
import { Button as Button3 } from "@salt-ds/core";
|
|
944
|
+
import {
|
|
945
|
+
hasAction,
|
|
946
|
+
isErrorResponse,
|
|
947
|
+
RemoteDataSource
|
|
948
|
+
} from "@vuu-ui/vuu-data";
|
|
949
|
+
import {
|
|
950
|
+
buildColumnMap,
|
|
951
|
+
isValidNumber,
|
|
952
|
+
shallowEquals
|
|
953
|
+
} from "@vuu-ui/vuu-utils";
|
|
954
|
+
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
955
|
+
var classBase7 = "vuuSessionEditingForm";
|
|
956
|
+
var getField = (fields, name) => {
|
|
957
|
+
const field = fields.find((f) => f.name === name);
|
|
958
|
+
if (field) {
|
|
959
|
+
return field;
|
|
960
|
+
} else {
|
|
961
|
+
throw Error(`SessionEditingForm, no field '${name}' found`);
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
var getFieldNameAndValue = (evt) => {
|
|
965
|
+
const {
|
|
966
|
+
dataset: { field },
|
|
967
|
+
value
|
|
968
|
+
} = evt.target;
|
|
969
|
+
if (field === void 0) {
|
|
970
|
+
throw Error("SessionEditingForm, form field has no field name");
|
|
971
|
+
}
|
|
972
|
+
return [field, value];
|
|
973
|
+
};
|
|
974
|
+
var Status = {
|
|
975
|
+
uninitialised: 0,
|
|
976
|
+
unchanged: 1,
|
|
977
|
+
changed: 2,
|
|
978
|
+
invalid: 3
|
|
979
|
+
};
|
|
980
|
+
function getTypedValue(value, type, throwIfUndefined = false) {
|
|
981
|
+
switch (type) {
|
|
982
|
+
case "int":
|
|
983
|
+
case "long": {
|
|
984
|
+
const typedValue = parseInt(value, 10);
|
|
985
|
+
if (isValidNumber(typedValue)) {
|
|
986
|
+
return typedValue;
|
|
987
|
+
} else if (throwIfUndefined) {
|
|
988
|
+
throw Error("SessionEditingForm getTypedValue");
|
|
989
|
+
} else {
|
|
990
|
+
return void 0;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
case "double": {
|
|
994
|
+
const typedValue = parseFloat(value);
|
|
995
|
+
if (isValidNumber(typedValue)) {
|
|
996
|
+
return typedValue;
|
|
997
|
+
}
|
|
998
|
+
return void 0;
|
|
999
|
+
}
|
|
1000
|
+
case "boolean":
|
|
1001
|
+
return value === "true" ? true : false;
|
|
1002
|
+
default:
|
|
1003
|
+
return value;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
var getDataSource = (dataSource, schema) => {
|
|
1007
|
+
if (dataSource) {
|
|
1008
|
+
return dataSource;
|
|
1009
|
+
} else if (schema) {
|
|
1010
|
+
return new RemoteDataSource({
|
|
1011
|
+
bufferSize: 0,
|
|
1012
|
+
table: schema.table,
|
|
1013
|
+
columns: schema.columns.map((col) => col.name)
|
|
1014
|
+
});
|
|
1015
|
+
} else {
|
|
1016
|
+
throw Error(
|
|
1017
|
+
"SessionEditingForm: either a DataSource or a TableSchema must be provided"
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
var SessionEditingForm = ({
|
|
1022
|
+
className,
|
|
1023
|
+
config: { fields, key: keyField },
|
|
1024
|
+
dataSource: dataSourceProp,
|
|
1025
|
+
id: idProp,
|
|
1026
|
+
onClose,
|
|
1027
|
+
schema,
|
|
1028
|
+
...htmlAttributes
|
|
1029
|
+
}) => {
|
|
1030
|
+
const [values, setValues] = useState7();
|
|
1031
|
+
const [errorMessage, setErrorMessage] = useState7("");
|
|
1032
|
+
const formContentRef = useRef(null);
|
|
1033
|
+
const initialDataRef = useRef();
|
|
1034
|
+
const dataStatusRef = useRef(Status.uninitialised);
|
|
1035
|
+
const dataSource = useMemo(() => {
|
|
1036
|
+
const applyServerData = (data) => {
|
|
1037
|
+
if (columnMap) {
|
|
1038
|
+
const values2 = {};
|
|
1039
|
+
for (const column of dataSource.columns) {
|
|
1040
|
+
values2[column] = data[columnMap[column]];
|
|
1041
|
+
}
|
|
1042
|
+
if (dataStatusRef.current === Status.uninitialised) {
|
|
1043
|
+
dataStatusRef.current = Status.unchanged;
|
|
1044
|
+
initialDataRef.current = values2;
|
|
1045
|
+
}
|
|
1046
|
+
setValues(values2);
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
const ds = getDataSource(dataSourceProp, schema);
|
|
1050
|
+
const columnMap = buildColumnMap(ds.columns);
|
|
1051
|
+
ds.subscribe({ range: { from: 0, to: 5 } }, (message) => {
|
|
1052
|
+
if (message.type === "viewport-update" && message.rows) {
|
|
1053
|
+
if (dataStatusRef.current === Status.uninitialised) {
|
|
1054
|
+
applyServerData(message.rows[0]);
|
|
1055
|
+
} else {
|
|
1056
|
+
console.log("what do we do with server updates");
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
return ds;
|
|
1061
|
+
}, [dataSourceProp, schema]);
|
|
1062
|
+
const id = useIdMemo(idProp);
|
|
1063
|
+
const handleChange = useCallback5(
|
|
1064
|
+
(evt) => {
|
|
1065
|
+
const [field, value] = getFieldNameAndValue(evt);
|
|
1066
|
+
const { type } = getField(fields, field);
|
|
1067
|
+
const typedValue = getTypedValue(value, type);
|
|
1068
|
+
setValues((values2 = {}) => {
|
|
1069
|
+
const newValues = {
|
|
1070
|
+
...values2,
|
|
1071
|
+
[field]: typedValue
|
|
1072
|
+
};
|
|
1073
|
+
const notUpdated = shallowEquals(newValues, initialDataRef.current);
|
|
1074
|
+
dataStatusRef.current = notUpdated ? Status.unchanged : typedValue !== void 0 ? Status.changed : Status.invalid;
|
|
1075
|
+
return newValues;
|
|
1076
|
+
});
|
|
1077
|
+
},
|
|
1078
|
+
[fields]
|
|
1079
|
+
);
|
|
1080
|
+
const handleBlur = useCallback5(
|
|
1081
|
+
(evt) => {
|
|
1082
|
+
const [field, value] = getFieldNameAndValue(evt);
|
|
1083
|
+
const { type } = getField(fields, field);
|
|
1084
|
+
const rowKey = values == null ? void 0 : values[keyField];
|
|
1085
|
+
const typedValue = getTypedValue(value, type, true);
|
|
1086
|
+
if (typeof rowKey === "string") {
|
|
1087
|
+
dataSource.menuRpcCall({
|
|
1088
|
+
rowKey,
|
|
1089
|
+
field,
|
|
1090
|
+
value: typedValue,
|
|
1091
|
+
type: "VP_EDIT_CELL_RPC"
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
},
|
|
1095
|
+
[dataSource, fields, keyField, values]
|
|
1096
|
+
);
|
|
1097
|
+
const applyAction = useCallback5(
|
|
1098
|
+
(action) => {
|
|
1099
|
+
if (typeof action === "object" && action !== null) {
|
|
1100
|
+
if ("type" in action && action.type === "CLOSE_DIALOG_ACTION") {
|
|
1101
|
+
onClose();
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
},
|
|
1105
|
+
[onClose]
|
|
1106
|
+
);
|
|
1107
|
+
const handleSubmit = useCallback5(async () => {
|
|
1108
|
+
const response = await dataSource.menuRpcCall({
|
|
1109
|
+
type: "VP_EDIT_SUBMIT_FORM_RPC"
|
|
1110
|
+
});
|
|
1111
|
+
if (isErrorResponse(response)) {
|
|
1112
|
+
setErrorMessage(response.error);
|
|
1113
|
+
} else if (hasAction(response)) {
|
|
1114
|
+
applyAction(response.action);
|
|
1115
|
+
}
|
|
1116
|
+
}, [applyAction, dataSource]);
|
|
1117
|
+
const handleKeyDown = useCallback5(
|
|
1118
|
+
(evt) => {
|
|
1119
|
+
if (evt.key === "Enter" && dataStatusRef.current === Status.changed) {
|
|
1120
|
+
handleSubmit();
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
[handleSubmit]
|
|
1124
|
+
);
|
|
1125
|
+
const handleCancel = useCallback5(() => {
|
|
1126
|
+
onClose();
|
|
1127
|
+
}, [onClose]);
|
|
1128
|
+
const getFormControl = (field) => {
|
|
1129
|
+
var _a;
|
|
1130
|
+
const value = String((_a = values == null ? void 0 : values[field.name]) != null ? _a : "");
|
|
1131
|
+
if (field.readonly || field.name === keyField) {
|
|
1132
|
+
return /* @__PURE__ */ jsx14("div", { className: `${classBase7}-fieldValue vuuReadOnly`, children: value });
|
|
1133
|
+
} else {
|
|
1134
|
+
return /* @__PURE__ */ jsx14(
|
|
1135
|
+
"input",
|
|
1136
|
+
{
|
|
1137
|
+
className: `${classBase7}-fieldValue`,
|
|
1138
|
+
"data-field": field.name,
|
|
1139
|
+
onBlur: handleBlur,
|
|
1140
|
+
onChange: handleChange,
|
|
1141
|
+
type: "text",
|
|
1142
|
+
value,
|
|
1143
|
+
id: `${id}-input-${field.name}`
|
|
1144
|
+
}
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
useEffect6(() => {
|
|
1149
|
+
if (formContentRef.current) {
|
|
1150
|
+
const firstInput = formContentRef.current.querySelector(
|
|
1151
|
+
"input"
|
|
1152
|
+
);
|
|
1153
|
+
if (firstInput) {
|
|
1154
|
+
setTimeout(() => {
|
|
1155
|
+
firstInput.focus();
|
|
1156
|
+
firstInput.select();
|
|
1157
|
+
}, 100);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}, []);
|
|
1161
|
+
useEffect6(() => {
|
|
1162
|
+
return () => {
|
|
1163
|
+
if (dataSource) {
|
|
1164
|
+
dataSource.unsubscribe();
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
}, [dataSource]);
|
|
1168
|
+
const isDirty = dataStatusRef.current === Status.changed;
|
|
1169
|
+
return /* @__PURE__ */ jsxs9("div", { ...htmlAttributes, className: cx5(classBase7, className), children: [
|
|
1170
|
+
errorMessage ? /* @__PURE__ */ jsx14(
|
|
1171
|
+
"div",
|
|
1172
|
+
{
|
|
1173
|
+
className: `${classBase7}-errorBanner`,
|
|
1174
|
+
"data-icon": "error",
|
|
1175
|
+
title: errorMessage,
|
|
1176
|
+
children: "Error, edit(s) not saved"
|
|
1177
|
+
}
|
|
1178
|
+
) : void 0,
|
|
1179
|
+
/* @__PURE__ */ jsx14(
|
|
1180
|
+
"div",
|
|
1181
|
+
{
|
|
1182
|
+
className: `${classBase7}-content`,
|
|
1183
|
+
ref: formContentRef,
|
|
1184
|
+
onKeyDown: handleKeyDown,
|
|
1185
|
+
children: fields.map((field) => {
|
|
1186
|
+
var _a;
|
|
1187
|
+
return /* @__PURE__ */ jsxs9("div", { className: `${classBase7}-field`, children: [
|
|
1188
|
+
/* @__PURE__ */ jsx14(
|
|
1189
|
+
"label",
|
|
1190
|
+
{
|
|
1191
|
+
className: cx5(`${classBase7}-fieldLabel`, {
|
|
1192
|
+
[`${classBase7}-required`]: field.required
|
|
1193
|
+
}),
|
|
1194
|
+
htmlFor: `${id}-input-${field.name}`,
|
|
1195
|
+
children: (_a = field == null ? void 0 : field.label) != null ? _a : field.description
|
|
1196
|
+
}
|
|
1197
|
+
),
|
|
1198
|
+
getFormControl(field)
|
|
1199
|
+
] }, field.name);
|
|
1200
|
+
})
|
|
1201
|
+
}
|
|
1202
|
+
),
|
|
1203
|
+
/* @__PURE__ */ jsxs9("div", { className: `${classBase7}-buttonbar salt-theme salt-density-high`, children: [
|
|
1204
|
+
/* @__PURE__ */ jsx14(
|
|
1205
|
+
Button3,
|
|
1206
|
+
{
|
|
1207
|
+
type: "submit",
|
|
1208
|
+
variant: "cta",
|
|
1209
|
+
disabled: !isDirty,
|
|
1210
|
+
onClick: handleSubmit,
|
|
1211
|
+
children: "Submit"
|
|
1212
|
+
}
|
|
1213
|
+
),
|
|
1214
|
+
/* @__PURE__ */ jsx14(Button3, { variant: "secondary", onClick: handleCancel, children: "Cancel" })
|
|
1215
|
+
] })
|
|
1216
|
+
] });
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
// src/shell.tsx
|
|
1220
|
+
import { connectToServer } from "@vuu-ui/vuu-data";
|
|
1221
|
+
import cx9 from "classnames";
|
|
1222
|
+
import {
|
|
1223
|
+
useCallback as useCallback11,
|
|
1224
|
+
useEffect as useEffect8,
|
|
1225
|
+
useRef as useRef3
|
|
1226
|
+
} from "react";
|
|
1227
|
+
import {
|
|
1228
|
+
DraggableLayout as DraggableLayout3,
|
|
1229
|
+
LayoutProvider
|
|
1230
|
+
} from "@vuu-ui/vuu-layout";
|
|
1231
|
+
|
|
1232
|
+
// src/app-header/AppHeader.tsx
|
|
1233
|
+
import { useCallback as useCallback8 } from "react";
|
|
1234
|
+
|
|
1235
|
+
// src/user-profile/UserProfile.tsx
|
|
1236
|
+
import { Button as Button5 } from "@salt-ds/core";
|
|
1237
|
+
import { DropdownBase } from "@salt-ds/lab";
|
|
1238
|
+
import { UserSolidIcon } from "@salt-ds/icons";
|
|
1239
|
+
|
|
1240
|
+
// src/user-profile/UserPanel.tsx
|
|
1241
|
+
import { formatDate as formatDate2 } from "@vuu-ui/vuu-utils";
|
|
1242
|
+
import { List as List2, ListItem } from "@salt-ds/lab";
|
|
1243
|
+
import { Button as Button4 } from "@salt-ds/core";
|
|
1244
|
+
import { ExportIcon } from "@salt-ds/icons";
|
|
1245
|
+
import {
|
|
1246
|
+
forwardRef,
|
|
1247
|
+
useCallback as useCallback6,
|
|
1248
|
+
useEffect as useEffect7,
|
|
1249
|
+
useState as useState8
|
|
1250
|
+
} from "react";
|
|
1251
|
+
|
|
1252
|
+
// src/get-layout-history.ts
|
|
1253
|
+
var getLayoutHistory = async (user) => {
|
|
1254
|
+
const history = await fetch(`api/vui/${user.username}`, {}).then((response) => {
|
|
1255
|
+
return response.ok ? response.json() : null;
|
|
1256
|
+
}).catch(() => {
|
|
1257
|
+
console.log("error getting history");
|
|
1258
|
+
});
|
|
1259
|
+
return history;
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1262
|
+
// src/user-profile/UserPanel.tsx
|
|
1263
|
+
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1264
|
+
var byLastUpdate = ({ lastUpdate: l1 }, { lastUpdate: l2 }) => {
|
|
1265
|
+
return l2 === l1 ? 0 : l2 < l1 ? -1 : 1;
|
|
1266
|
+
};
|
|
1267
|
+
var HistoryListItem = (props) => {
|
|
1268
|
+
return /* @__PURE__ */ jsx15(ListItem, { ...props });
|
|
1269
|
+
};
|
|
1270
|
+
var UserPanel = forwardRef(function UserPanel2({ loginUrl, onNavigate, user, layoutId = "latest" }, forwardedRef) {
|
|
1271
|
+
const [history, setHistory] = useState8([]);
|
|
1272
|
+
useEffect7(() => {
|
|
1273
|
+
async function getHistory() {
|
|
1274
|
+
const history2 = await getLayoutHistory(user);
|
|
1275
|
+
const sortedHistory = history2.filter((item) => item.id !== "latest").sort(byLastUpdate).map(({ id, lastUpdate }) => ({
|
|
1276
|
+
lastUpdate,
|
|
1277
|
+
id,
|
|
1278
|
+
label: `Saved at ${formatDate2(new Date(lastUpdate), "kk:mm:ss")}`
|
|
1279
|
+
}));
|
|
1280
|
+
console.log({ sortedHistory });
|
|
1281
|
+
setHistory(sortedHistory);
|
|
1282
|
+
}
|
|
1283
|
+
getHistory();
|
|
1284
|
+
}, [user]);
|
|
1285
|
+
const handleHisorySelected = useCallback6(
|
|
1286
|
+
(evt, selected2) => {
|
|
1287
|
+
if (selected2) {
|
|
1288
|
+
onNavigate(selected2.id);
|
|
1289
|
+
}
|
|
1290
|
+
},
|
|
1291
|
+
[onNavigate]
|
|
1292
|
+
);
|
|
1293
|
+
const handleLogout = useCallback6(() => {
|
|
1294
|
+
logout(loginUrl);
|
|
1295
|
+
}, [loginUrl]);
|
|
1296
|
+
const selected = history.length === 0 ? null : layoutId === "latest" ? history[0] : history.find((i) => i.id === layoutId);
|
|
1297
|
+
return /* @__PURE__ */ jsxs10("div", { className: "vuuUserPanel", ref: forwardedRef, children: [
|
|
1298
|
+
/* @__PURE__ */ jsx15(
|
|
1299
|
+
List2,
|
|
1300
|
+
{
|
|
1301
|
+
ListItem: HistoryListItem,
|
|
1302
|
+
className: "vuuUserPanel-history",
|
|
1303
|
+
onSelect: handleHisorySelected,
|
|
1304
|
+
selected,
|
|
1305
|
+
source: history
|
|
1306
|
+
}
|
|
1307
|
+
),
|
|
1308
|
+
/* @__PURE__ */ jsx15("div", { className: "vuuUserPanel-buttonBar", children: /* @__PURE__ */ jsxs10(Button4, { "aria-label": "logout", onClick: handleLogout, children: [
|
|
1309
|
+
/* @__PURE__ */ jsx15(ExportIcon, {}),
|
|
1310
|
+
" Logout"
|
|
1311
|
+
] }) })
|
|
1312
|
+
] });
|
|
1313
|
+
});
|
|
1314
|
+
|
|
1315
|
+
// src/user-profile/UserProfile.tsx
|
|
1316
|
+
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1317
|
+
var UserProfile = ({
|
|
1318
|
+
layoutId,
|
|
1319
|
+
loginUrl,
|
|
1320
|
+
onNavigate,
|
|
1321
|
+
user
|
|
1322
|
+
}) => {
|
|
1323
|
+
const handleNavigate = (id) => {
|
|
1324
|
+
onNavigate(id);
|
|
1325
|
+
};
|
|
1326
|
+
return /* @__PURE__ */ jsxs11(DropdownBase, { className: "vuuUserProfile", placement: "bottom-end", children: [
|
|
1327
|
+
/* @__PURE__ */ jsx16(Button5, { variant: "secondary", children: /* @__PURE__ */ jsx16(UserSolidIcon, {}) }),
|
|
1328
|
+
/* @__PURE__ */ jsx16(
|
|
1329
|
+
UserPanel,
|
|
1330
|
+
{
|
|
1331
|
+
layoutId,
|
|
1332
|
+
loginUrl,
|
|
1333
|
+
onNavigate: handleNavigate,
|
|
1334
|
+
user
|
|
1335
|
+
}
|
|
1336
|
+
)
|
|
1337
|
+
] });
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
// src/theme-switch/ThemeSwitch.tsx
|
|
1341
|
+
import cx6 from "classnames";
|
|
1342
|
+
import { ToggleButton, ToggleButtonGroup, useControlled } from "@salt-ds/core";
|
|
1343
|
+
import { useCallback as useCallback7 } from "react";
|
|
1344
|
+
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1345
|
+
var classBase8 = "vuuThemeSwitch";
|
|
1346
|
+
var ThemeSwitch = ({
|
|
1347
|
+
className: classNameProp,
|
|
1348
|
+
defaultMode: defaultModeProp,
|
|
1349
|
+
mode: modeProp,
|
|
1350
|
+
onChange,
|
|
1351
|
+
...htmlAttributes
|
|
1352
|
+
}) => {
|
|
1353
|
+
const [mode, setMode] = useControlled({
|
|
1354
|
+
controlled: modeProp,
|
|
1355
|
+
default: defaultModeProp != null ? defaultModeProp : "light",
|
|
1356
|
+
name: "ThemeSwitch",
|
|
1357
|
+
state: "mode"
|
|
1358
|
+
});
|
|
1359
|
+
const handleChangeSecondary = useCallback7(
|
|
1360
|
+
(evt) => {
|
|
1361
|
+
const { value } = evt.target;
|
|
1362
|
+
setMode(value);
|
|
1363
|
+
onChange(value);
|
|
1364
|
+
},
|
|
1365
|
+
[onChange, setMode]
|
|
1366
|
+
);
|
|
1367
|
+
const className = cx6(classBase8, classNameProp);
|
|
1368
|
+
return /* @__PURE__ */ jsxs12(
|
|
1369
|
+
ToggleButtonGroup,
|
|
1370
|
+
{
|
|
1371
|
+
className,
|
|
1372
|
+
...htmlAttributes,
|
|
1373
|
+
onChange: handleChangeSecondary,
|
|
1374
|
+
value: mode,
|
|
1375
|
+
children: [
|
|
1376
|
+
/* @__PURE__ */ jsx17(ToggleButton, { "aria-label": "alert", "data-icon": "light", value: "dark" }),
|
|
1377
|
+
/* @__PURE__ */ jsx17(ToggleButton, { "aria-label": "home", "data-icon": "dark", value: "light" })
|
|
1378
|
+
]
|
|
1379
|
+
}
|
|
1380
|
+
);
|
|
1381
|
+
};
|
|
1382
|
+
|
|
1383
|
+
// src/app-header/AppHeader.tsx
|
|
1384
|
+
import cx7 from "classnames";
|
|
1385
|
+
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1386
|
+
var classBase9 = "vuuAppHeader";
|
|
1387
|
+
var AppHeader = ({
|
|
1388
|
+
className: classNameProp,
|
|
1389
|
+
layoutId,
|
|
1390
|
+
loginUrl,
|
|
1391
|
+
onNavigate,
|
|
1392
|
+
onSwitchTheme,
|
|
1393
|
+
themeMode = "light",
|
|
1394
|
+
user,
|
|
1395
|
+
...htmlAttributes
|
|
1396
|
+
}) => {
|
|
1397
|
+
const className = cx7(classBase9, classNameProp);
|
|
1398
|
+
const handleSwitchTheme = useCallback8(
|
|
1399
|
+
(mode) => onSwitchTheme == null ? void 0 : onSwitchTheme(mode),
|
|
1400
|
+
[onSwitchTheme]
|
|
1401
|
+
);
|
|
1402
|
+
return /* @__PURE__ */ jsxs13("header", { className, ...htmlAttributes, children: [
|
|
1403
|
+
/* @__PURE__ */ jsx18(ThemeSwitch, { defaultMode: themeMode, onChange: handleSwitchTheme }),
|
|
1404
|
+
/* @__PURE__ */ jsx18(
|
|
1405
|
+
UserProfile,
|
|
1406
|
+
{
|
|
1407
|
+
layoutId,
|
|
1408
|
+
loginUrl,
|
|
1409
|
+
onNavigate,
|
|
1410
|
+
user
|
|
1411
|
+
}
|
|
1412
|
+
)
|
|
1413
|
+
] });
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1416
|
+
// src/shell.tsx
|
|
1417
|
+
import { logger } from "@vuu-ui/vuu-utils";
|
|
1418
|
+
|
|
1419
|
+
// src/shell-layouts/context-panel/ContextPanel.tsx
|
|
1420
|
+
import { Button as Button6 } from "@salt-ds/core";
|
|
1421
|
+
import cx8 from "classnames";
|
|
1422
|
+
import { useCallback as useCallback9, useMemo as useMemo2 } from "react";
|
|
1423
|
+
import {
|
|
1424
|
+
layoutFromJson,
|
|
1425
|
+
useLayoutProviderDispatch as useLayoutProviderDispatch2
|
|
1426
|
+
} from "@vuu-ui/vuu-layout";
|
|
1427
|
+
import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1428
|
+
var classBase10 = "vuuContextPanel";
|
|
1429
|
+
var ContextPanel = ({
|
|
1430
|
+
className: classNameProp,
|
|
1431
|
+
expanded = false,
|
|
1432
|
+
content: contentProp,
|
|
1433
|
+
overlay = false,
|
|
1434
|
+
title
|
|
1435
|
+
}) => {
|
|
1436
|
+
const dispatchLayoutAction = useLayoutProviderDispatch2();
|
|
1437
|
+
const handleClose = useCallback9(() => {
|
|
1438
|
+
dispatchLayoutAction({
|
|
1439
|
+
path: "#context-panel",
|
|
1440
|
+
propName: "expanded",
|
|
1441
|
+
propValue: false,
|
|
1442
|
+
type: "set-prop"
|
|
1443
|
+
});
|
|
1444
|
+
}, [dispatchLayoutAction]);
|
|
1445
|
+
const className = cx8(classBase10, classNameProp, {
|
|
1446
|
+
[`${classBase10}-expanded`]: expanded,
|
|
1447
|
+
[`${classBase10}-inline`]: overlay !== true,
|
|
1448
|
+
[`${classBase10}-overlay`]: overlay
|
|
1449
|
+
});
|
|
1450
|
+
const content = useMemo2(
|
|
1451
|
+
() => contentProp ? layoutFromJson(contentProp, "context-0") : null,
|
|
1452
|
+
[contentProp]
|
|
1453
|
+
);
|
|
1454
|
+
return /* @__PURE__ */ jsx19("div", { className: cx8(classBase10, className), children: /* @__PURE__ */ jsxs14("div", { className: `${classBase10}-inner`, children: [
|
|
1455
|
+
/* @__PURE__ */ jsxs14("div", { className: `${classBase10}-header`, children: [
|
|
1456
|
+
/* @__PURE__ */ jsx19("h2", { className: `${classBase10}-title`, children: title }),
|
|
1457
|
+
/* @__PURE__ */ jsx19(
|
|
1458
|
+
Button6,
|
|
1459
|
+
{
|
|
1460
|
+
className: `${classBase10}-close`,
|
|
1461
|
+
"data-icon": "close",
|
|
1462
|
+
onClick: handleClose,
|
|
1463
|
+
variant: "secondary"
|
|
1464
|
+
}
|
|
1465
|
+
)
|
|
1466
|
+
] }),
|
|
1467
|
+
/* @__PURE__ */ jsx19("div", { className: `${classBase10}-content`, children: content })
|
|
1468
|
+
] }) });
|
|
1469
|
+
};
|
|
1470
|
+
|
|
1471
|
+
// src/shell-layouts/useFullHeightLeftPanel.tsx
|
|
1472
|
+
import { DraggableLayout, Flexbox } from "@vuu-ui/vuu-layout";
|
|
1473
|
+
import { jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1474
|
+
var useFullHeightLeftPanel = ({
|
|
1475
|
+
appHeader,
|
|
1476
|
+
leftSidePanel
|
|
1477
|
+
}) => {
|
|
1478
|
+
return /* @__PURE__ */ jsxs15(
|
|
1479
|
+
Flexbox,
|
|
1480
|
+
{
|
|
1481
|
+
className: "App",
|
|
1482
|
+
style: {
|
|
1483
|
+
flexDirection: "row",
|
|
1484
|
+
height: "100%",
|
|
1485
|
+
width: "100%"
|
|
1486
|
+
},
|
|
1487
|
+
children: [
|
|
1488
|
+
leftSidePanel,
|
|
1489
|
+
/* @__PURE__ */ jsxs15(
|
|
1490
|
+
Flexbox,
|
|
1491
|
+
{
|
|
1492
|
+
className: "vuuShell-content",
|
|
1493
|
+
style: { flex: 1, flexDirection: "column" },
|
|
1494
|
+
children: [
|
|
1495
|
+
appHeader,
|
|
1496
|
+
/* @__PURE__ */ jsx20(DraggableLayout, { dropTarget: true, style: { flex: 1 } }, "main-content")
|
|
1497
|
+
]
|
|
1498
|
+
}
|
|
1499
|
+
),
|
|
1500
|
+
/* @__PURE__ */ jsx20(
|
|
1501
|
+
ContextPanel,
|
|
1502
|
+
{
|
|
1503
|
+
id: "context-panel",
|
|
1504
|
+
overlay: true,
|
|
1505
|
+
title: "Column Settings"
|
|
1506
|
+
}
|
|
1507
|
+
)
|
|
1508
|
+
]
|
|
1509
|
+
}
|
|
1510
|
+
);
|
|
1511
|
+
};
|
|
1512
|
+
|
|
1513
|
+
// src/shell-layouts/useInlayLeftPanel.tsx
|
|
1514
|
+
import {
|
|
1515
|
+
DockLayout,
|
|
1516
|
+
DraggableLayout as DraggableLayout2,
|
|
1517
|
+
Drawer,
|
|
1518
|
+
Flexbox as Flexbox2,
|
|
1519
|
+
View
|
|
1520
|
+
} from "@vuu-ui/vuu-layout";
|
|
1521
|
+
import { useCallback as useCallback10, useRef as useRef2, useState as useState9 } from "react";
|
|
1522
|
+
import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1523
|
+
var useInlayLeftPanel = ({
|
|
1524
|
+
appHeader,
|
|
1525
|
+
leftSidePanel
|
|
1526
|
+
}) => {
|
|
1527
|
+
const paletteView = useRef2(null);
|
|
1528
|
+
const [open, setOpen] = useState9(true);
|
|
1529
|
+
const handleDrawerClick = useCallback10(
|
|
1530
|
+
(e) => {
|
|
1531
|
+
var _a;
|
|
1532
|
+
const target = e.target;
|
|
1533
|
+
if (!((_a = paletteView.current) == null ? void 0 : _a.contains(target))) {
|
|
1534
|
+
setOpen(!open);
|
|
1535
|
+
}
|
|
1536
|
+
},
|
|
1537
|
+
[open]
|
|
1538
|
+
);
|
|
1539
|
+
const getDrawers = useCallback10(
|
|
1540
|
+
(leftSidePanel2) => {
|
|
1541
|
+
const drawers = [];
|
|
1542
|
+
drawers.push(
|
|
1543
|
+
/* @__PURE__ */ jsx21(
|
|
1544
|
+
Drawer,
|
|
1545
|
+
{
|
|
1546
|
+
onClick: handleDrawerClick,
|
|
1547
|
+
open,
|
|
1548
|
+
position: "left",
|
|
1549
|
+
inline: true,
|
|
1550
|
+
peekaboo: true,
|
|
1551
|
+
sizeOpen: 200,
|
|
1552
|
+
toggleButton: "end",
|
|
1553
|
+
children: /* @__PURE__ */ jsx21(
|
|
1554
|
+
View,
|
|
1555
|
+
{
|
|
1556
|
+
className: "vuuShell-palette",
|
|
1557
|
+
id: "vw-app-palette",
|
|
1558
|
+
ref: paletteView,
|
|
1559
|
+
style: { height: "100%" },
|
|
1560
|
+
children: leftSidePanel2
|
|
1561
|
+
},
|
|
1562
|
+
"app-palette"
|
|
1563
|
+
)
|
|
1564
|
+
},
|
|
1565
|
+
"left-panel"
|
|
1566
|
+
)
|
|
1567
|
+
);
|
|
1568
|
+
return drawers;
|
|
1569
|
+
},
|
|
1570
|
+
[handleDrawerClick, open]
|
|
1571
|
+
);
|
|
1572
|
+
return /* @__PURE__ */ jsxs16(
|
|
1573
|
+
Flexbox2,
|
|
1574
|
+
{
|
|
1575
|
+
className: "App",
|
|
1576
|
+
style: { flexDirection: "column", height: "100%", width: "100%" },
|
|
1577
|
+
children: [
|
|
1578
|
+
appHeader,
|
|
1579
|
+
/* @__PURE__ */ jsx21(DockLayout, { style: { flex: 1 }, children: getDrawers(leftSidePanel).concat(
|
|
1580
|
+
/* @__PURE__ */ jsx21(
|
|
1581
|
+
DraggableLayout2,
|
|
1582
|
+
{
|
|
1583
|
+
dropTarget: true,
|
|
1584
|
+
style: { width: "100%", height: "100%" }
|
|
1585
|
+
},
|
|
1586
|
+
"main-content"
|
|
1587
|
+
)
|
|
1588
|
+
) })
|
|
1589
|
+
]
|
|
1590
|
+
}
|
|
1591
|
+
);
|
|
1592
|
+
};
|
|
1593
|
+
|
|
1594
|
+
// src/shell-layouts/useShellLayout.ts
|
|
1595
|
+
var useShellLayout = ({
|
|
1596
|
+
leftSidePanelLayout = "inlay",
|
|
1597
|
+
...props
|
|
1598
|
+
}) => {
|
|
1599
|
+
const useLayoutHook = leftSidePanelLayout === "inlay" ? useInlayLeftPanel : useFullHeightLeftPanel;
|
|
1600
|
+
return useLayoutHook(props);
|
|
1601
|
+
};
|
|
1602
|
+
|
|
1603
|
+
// src/shell.tsx
|
|
1604
|
+
import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1605
|
+
var { error } = logger("Shell");
|
|
1606
|
+
var warningLayout = {
|
|
1607
|
+
type: "View",
|
|
1608
|
+
props: {
|
|
1609
|
+
style: { height: "calc(100% - 6px)" }
|
|
1610
|
+
},
|
|
1611
|
+
children: [
|
|
1612
|
+
{
|
|
1613
|
+
props: {
|
|
1614
|
+
className: "vuuShell-warningPlaceholder"
|
|
1615
|
+
},
|
|
1616
|
+
type: "Placeholder"
|
|
1617
|
+
}
|
|
1618
|
+
]
|
|
1619
|
+
};
|
|
1620
|
+
var Shell = ({
|
|
1621
|
+
LayoutProps,
|
|
1622
|
+
children,
|
|
1623
|
+
className: classNameProp,
|
|
1624
|
+
defaultLayout = warningLayout,
|
|
1625
|
+
leftSidePanel,
|
|
1626
|
+
leftSidePanelLayout,
|
|
1627
|
+
loginUrl,
|
|
1628
|
+
saveLocation = "remote",
|
|
1629
|
+
saveUrl,
|
|
1630
|
+
serverUrl,
|
|
1631
|
+
user,
|
|
1632
|
+
...htmlAttributes
|
|
1633
|
+
}) => {
|
|
1634
|
+
const rootRef = useRef3(null);
|
|
1635
|
+
const layoutId = useRef3("latest");
|
|
1636
|
+
const [layout, saveLayoutConfig, loadLayoutById] = useLayoutConfig({
|
|
1637
|
+
defaultLayout,
|
|
1638
|
+
saveLocation,
|
|
1639
|
+
saveUrl,
|
|
1640
|
+
user
|
|
1641
|
+
});
|
|
1642
|
+
const handleLayoutChange = useCallback11(
|
|
1643
|
+
(layout2, layoutChangeReason) => {
|
|
1644
|
+
try {
|
|
1645
|
+
console.log(`handle layout changed ${layoutChangeReason}`);
|
|
1646
|
+
saveLayoutConfig(layout2);
|
|
1647
|
+
} catch {
|
|
1648
|
+
error == null ? void 0 : error("Failed to save layout");
|
|
1649
|
+
}
|
|
1650
|
+
},
|
|
1651
|
+
[saveLayoutConfig]
|
|
1652
|
+
);
|
|
1653
|
+
const handleSwitchTheme = useCallback11((mode) => {
|
|
1654
|
+
if (rootRef.current) {
|
|
1655
|
+
rootRef.current.dataset.mode = mode;
|
|
1656
|
+
}
|
|
1657
|
+
}, []);
|
|
1658
|
+
const handleNavigate = useCallback11(
|
|
1659
|
+
(id) => {
|
|
1660
|
+
layoutId.current = id;
|
|
1661
|
+
loadLayoutById(id);
|
|
1662
|
+
},
|
|
1663
|
+
[loadLayoutById]
|
|
1664
|
+
);
|
|
1665
|
+
useEffect8(() => {
|
|
1666
|
+
if (serverUrl && user.token) {
|
|
1667
|
+
connectToServer({
|
|
1668
|
+
authToken: user.token,
|
|
1669
|
+
url: serverUrl,
|
|
1670
|
+
username: user.username
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
}, [serverUrl, user.token, user.username]);
|
|
1674
|
+
const [themeClass, densityClass, dataMode] = useThemeAttributes();
|
|
1675
|
+
const className = cx9("vuuShell", classNameProp, themeClass, densityClass);
|
|
1676
|
+
const shellLayout = useShellLayout({
|
|
1677
|
+
leftSidePanelLayout,
|
|
1678
|
+
appHeader: /* @__PURE__ */ jsx22(
|
|
1679
|
+
AppHeader,
|
|
1680
|
+
{
|
|
1681
|
+
layoutId: layoutId.current,
|
|
1682
|
+
loginUrl,
|
|
1683
|
+
user,
|
|
1684
|
+
onNavigate: handleNavigate,
|
|
1685
|
+
onSwitchTheme: handleSwitchTheme
|
|
1686
|
+
}
|
|
1687
|
+
),
|
|
1688
|
+
leftSidePanel
|
|
1689
|
+
});
|
|
1690
|
+
return /* @__PURE__ */ jsxs17(ThemeProvider, { children: [
|
|
1691
|
+
/* @__PURE__ */ jsx22(
|
|
1692
|
+
LayoutProvider,
|
|
1693
|
+
{
|
|
1694
|
+
...LayoutProps,
|
|
1695
|
+
layout,
|
|
1696
|
+
onLayoutChange: handleLayoutChange,
|
|
1697
|
+
children: /* @__PURE__ */ jsx22(
|
|
1698
|
+
DraggableLayout3,
|
|
1699
|
+
{
|
|
1700
|
+
className,
|
|
1701
|
+
"data-mode": dataMode,
|
|
1702
|
+
ref: rootRef,
|
|
1703
|
+
...htmlAttributes,
|
|
1704
|
+
children: shellLayout
|
|
1705
|
+
}
|
|
1706
|
+
)
|
|
1707
|
+
}
|
|
1708
|
+
),
|
|
1709
|
+
children
|
|
1710
|
+
] });
|
|
1711
|
+
};
|
|
1712
|
+
|
|
1713
|
+
// src/ShellContextProvider.tsx
|
|
1714
|
+
import { createContext as createContext2, useContext as useContext3 } from "react";
|
|
1715
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1716
|
+
var defaultConfig = {};
|
|
1717
|
+
var ShellContext = createContext2(defaultConfig);
|
|
1718
|
+
var Provider = ({
|
|
1719
|
+
children,
|
|
1720
|
+
context,
|
|
1721
|
+
inheritedContext
|
|
1722
|
+
}) => {
|
|
1723
|
+
const mergedContext = {
|
|
1724
|
+
...inheritedContext,
|
|
1725
|
+
...context
|
|
1726
|
+
};
|
|
1727
|
+
return /* @__PURE__ */ jsx23(ShellContext.Provider, { value: mergedContext, children });
|
|
1728
|
+
};
|
|
1729
|
+
var ShellContextProvider = ({
|
|
1730
|
+
children,
|
|
1731
|
+
value
|
|
1732
|
+
}) => {
|
|
1733
|
+
return /* @__PURE__ */ jsx23(ShellContext.Consumer, { children: (context) => /* @__PURE__ */ jsx23(Provider, { context: value, inheritedContext: context, children }) });
|
|
1734
|
+
};
|
|
1735
|
+
var useShellContext = () => {
|
|
1736
|
+
return useContext3(ShellContext);
|
|
1737
|
+
};
|
|
1738
|
+
export {
|
|
1739
|
+
ConnectionStatusIcon,
|
|
1740
|
+
ContextPanel,
|
|
1741
|
+
DEFAULT_DENSITY2 as DEFAULT_DENSITY,
|
|
1742
|
+
DEFAULT_THEME,
|
|
1743
|
+
DEFAULT_THEME_MODE,
|
|
1744
|
+
DensitySwitch,
|
|
1745
|
+
Feature,
|
|
1746
|
+
FeatureList,
|
|
1747
|
+
LayoutManagementContext,
|
|
1748
|
+
LayoutManagementProvider,
|
|
1749
|
+
LayoutsList,
|
|
1750
|
+
LeftNav,
|
|
1751
|
+
LoginPanel,
|
|
1752
|
+
SaveLayoutPanel,
|
|
1753
|
+
SessionEditingForm,
|
|
1754
|
+
Shell,
|
|
1755
|
+
ShellContextProvider,
|
|
1756
|
+
ThemeContext,
|
|
1757
|
+
ThemeProvider,
|
|
1758
|
+
ThemeSwitch,
|
|
1759
|
+
getAuthDetailsFromCookies,
|
|
1760
|
+
getAuthModeFromCookies,
|
|
1761
|
+
logout,
|
|
1762
|
+
redirectToLogin,
|
|
1763
|
+
useLayoutConfig,
|
|
1764
|
+
useLayoutManager,
|
|
1765
|
+
useShellContext,
|
|
1766
|
+
useShellLayout,
|
|
1767
|
+
useThemeAttributes
|
|
1768
|
+
};
|
|
18
1769
|
//# sourceMappingURL=index.js.map
|