@malloy-publisher/server 0.9.1 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.docker.md +14 -0
  2. package/dist/app/api-doc.yaml +414 -98
  3. package/dist/app/assets/EnvironmentPage-uo3igcP9.js +1 -0
  4. package/dist/app/assets/{HomePage-D3MvQaZn.js → HomePage-0OQVchl4.js} +1 -1
  5. package/dist/app/assets/MainPage-D4SOACdm.js +1 -0
  6. package/dist/app/assets/ModelPage-B5CpdEDl.js +2 -0
  7. package/dist/app/assets/PackagePage-BzUfTQKy.js +1 -0
  8. package/dist/app/assets/RenderedResult-DwB0-9Yx.es-1MzhmBXH.js +141 -0
  9. package/dist/app/assets/{RouteError-BQnzPJvb.js → RouteError-BXcrPjvD.js} +1 -1
  10. package/dist/app/assets/ThemeEditorPage-FpYg5NPt.js +1 -0
  11. package/dist/app/assets/{ToggleButtonGroup-CJT2JKTC.js → ToggleButtonGroup-Vkkjsbxx.js} +1 -1
  12. package/dist/app/assets/documentRoutes-BWHzvbNO.js +1 -0
  13. package/dist/app/assets/index-BZEvIUf-.js +484 -0
  14. package/dist/app/assets/index-CprgMbE_.js +1 -0
  15. package/dist/app/assets/{index-ufFZR_K-.js → index-DFvJYp4Q.js} +7 -7
  16. package/dist/app/assets/index-NVPzfbUZ.js +1317 -0
  17. package/dist/app/assets/{index-ireHUsv_.js → index-sKcoT1e_.js} +422 -427
  18. package/dist/app/assets/index.es-D2Ts8adM.js +195 -0
  19. package/dist/app/index.html +1 -1
  20. package/dist/package_load_worker.mjs +801 -80
  21. package/dist/server.mjs +21707 -17510
  22. package/package.json +15 -15
  23. package/dist/app/assets/EnvironmentPage-UMS7Py4Q.js +0 -1
  24. package/dist/app/assets/LightMode-e1lNBfpL.js +0 -1
  25. package/dist/app/assets/MainPage-B0ozqtQO.js +0 -2
  26. package/dist/app/assets/ModelPage-lQj4Axqu.js +0 -2
  27. package/dist/app/assets/PackagePage-BT0YKNKU.js +0 -1
  28. package/dist/app/assets/RenderedResult-BRgIgxWh.es-DiE7kPNX.js +0 -136
  29. package/dist/app/assets/ThemeEditorPage-D6t7w9Js.js +0 -1
  30. package/dist/app/assets/index-ByieDZlo.js +0 -23
  31. package/dist/app/assets/index-CCNqF0-G.js +0 -1
  32. package/dist/app/assets/index-CKmZ4HG7.js +0 -1322
  33. package/dist/app/assets/index-CdExa3Pk.js +0 -1
  34. package/dist/app/assets/index-TiWjmdoW.js +0 -450
  35. package/dist/app/assets/index.es-iUV0gCYk.js +0 -111
  36. package/dist/sshcrypto-cqb52edz.node +0 -0
@@ -1,111 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CKmZ4HG7.js","assets/index-TiWjmdoW.js","assets/index-DUqldpo0.css","assets/index-ByieDZlo.js","assets/index-CRAwrhYM.js","assets/index-CdExa3Pk.js"])))=>i.map(i=>d[i]);
2
- import{r as S,aM as ju,aN as yn,j as b,a9 as he,aO as Cu,at as Wt,N as pe,aP as Ou,aQ as Mu,U as $l,ar as Eu,aR as Du,aS as ri,aT as xa,aU as Tu,a4 as jl,a0 as Pu,ay as ke,a5 as Cl,aV as Au,a8 as Ol,aW as Iu,aX as ii,G as tt,aY as Ml,aZ as ks,H as kn,I as Ss,O as mo,T as ne,a_ as Ru,a$ as Wu,ax as Ni,am as Te,aq as bt,b0 as $s,an as El,Y as Dl,b1 as zu,b2 as Lu,Q as Nu,W as _u,b3 as Fu,b4 as Hu,b5 as qu,b6 as Uu,b7 as Vu,b8 as Gu,b9 as Yu,ba as Xu,bb as Ku,bc as Tl,bd as Bu,be as si,bf as Qu,bg as Qt,bh as Zu,bi as Ju,aI as eh}from"./index-TiWjmdoW.js";import{T as th,a as wa}from"./ToggleButtonGroup-CJT2JKTC.js";var ka={},nh=Symbol.for("preact-signals");function _i(){if(yt>1)yt--;else{var e,t=!1;for((function(){var i=wi;for(wi=void 0;i!==void 0;){var s=i.S;if(s.v===i.v)for(var o=s.t;o!==void 0;o=o.x)o.i===i.i&&(o.i=s.i);i=i.o}})();pr!==void 0;){var n=pr;for(pr=void 0,xi++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Al(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(xi=0,yt--,t)throw e}}function de(e){if(yt>0)return e();js=++rh,yt++;try{return e()}finally{_i()}}var fr,ie=void 0;function q(e){var t=ie,n=fr;ie=void 0,fr=void 0;try{return e()}finally{ie=t,fr=n}}var pr=void 0,yt=0,xi=0,rh=0,js=0,wi=void 0,ki=0;function Pl(e){if(ie!==void 0){var t=e.n;if(t===void 0||t.t!==ie)return t={i:0,S:e,p:ie.s,n:void 0,t:ie,e:void 0,x:void 0,r:t},ie.s!==void 0&&(ie.s.n=t),ie.s=t,e.n=t,32&ie.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ie.s,t.n=void 0,ie.s.n=t,ie.s=t),t}}function Le(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}Le.prototype.brand=nh;Le.prototype.h=function(){return!0};Le.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:q(function(){var r;(r=t.W)==null||r.call(t)}))};Le.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&q(function(){var i;(i=t.Z)==null||i.call(t)}))}};Le.prototype.subscribe=function(e){var t=this;return nt(function(){var n=t.value;q(function(){return e(n)})},{name:"sub"})};Le.prototype.valueOf=function(){return this.value};Le.prototype.toString=function(){return this.value+""};Le.prototype.toJSON=function(){return this.value};Le.prototype.peek=function(){var e=this;return q(function(){return e.value})};Object.defineProperty(Le.prototype,"value",{get:function(){var e=Pl(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(xi>100)throw new Error("Cycle detected");(function(n){yt!==0&&xi===0&&n.l!==js&&(n.l=js,wi={S:n,v:n.v,i:n.i,o:wi})})(this),this.v=e,this.i++,ki++,yt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{_i()}}}});function An(e,t){return new Le(e,t)}function Al(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Il(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Rl(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Zt(e,t){Le.call(this,void 0,t),this.x=e,this.s=void 0,this.g=ki-1,this.f=4}Zt.prototype=new Le;Zt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ki))return!0;if(this.g=ki,this.f|=1,this.i>0&&!Al(this))return this.f&=-2,!0;var e=ie;try{Il(this),ie=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ie=e,Rl(this),this.f&=-2,!0};Zt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Le.prototype.S.call(this,e)};Zt.prototype.U=function(e){if(this.t!==void 0&&(Le.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Zt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Zt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Pl(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Sa(e,t){return new Zt(e,t)}function Wl(e){var t=e.m;if(e.m=void 0,typeof t=="function"){yt++;var n=ie;ie=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,vo(e),r}finally{ie=n,_i()}}}function vo(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Wl(e)}function ih(e){if(ie!==this)throw new Error("Out-of-order effect");Rl(this),ie=e,this.f&=-2,8&this.f&&vo(this),_i()}function In(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,fr&&fr.push(this)}In.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};In.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Wl(this),Il(this),yt++;var e=ie;return ie=this,ih.bind(this,e)};In.prototype.N=function(){2&this.f||(this.f|=2,this.u=pr,pr=this)};In.prototype.d=function(){this.f|=8,1&this.f||vo(this)};In.prototype.dispose=function(){this.d()};function nt(e,t){var n=new In(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var sh=Object.create,bo=Object.defineProperty,oh=Object.defineProperties,ah=Object.getOwnPropertyDescriptor,lh=Object.getOwnPropertyDescriptors,$a=Object.getOwnPropertySymbols,ch=Object.prototype.hasOwnProperty,dh=Object.prototype.propertyIsEnumerable,uh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Rn=e=>{throw TypeError(e)},Cs=(e,t,n)=>t in e?bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hh=(e,t)=>{for(var n in t||(t={}))ch.call(t,n)&&Cs(e,n,t[n]);if($a)for(var n of $a(t))dh.call(t,n)&&Cs(e,n,t[n]);return e},fh=(e,t)=>oh(e,lh(t)),ja=(e,t)=>bo(e,"name",{value:t,configurable:!0}),ph=e=>{var t;return[,,,sh((t=void 0)!=null?t:null)]},zl=["class","method","getter","setter","accessor","field","value","get","set"],Qn=e=>e!==void 0&&typeof e!="function"?Rn("Function expected"):e,gh=(e,t,n,r,i)=>({kind:zl[e],name:t,metadata:r,addInitializer:s=>n._?Rn("Already initialized"):i.push(Qn(s||null))}),Ll=(e,t)=>Cs(t,uh("metadata"),e[3]),Rt=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Wn=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),h=!!(t&16),v=d>3?e.length+1:d?f?1:2:0,g=zl[d+5],w=d>3&&(e[v-1]=[]),y=e[v]||(e[v]=[]),p=d&&(!h&&!f&&(i=i.prototype),d<5&&(d>3||!h)&&ah(d<4?i:{get[n](){return Qe(this,s)},set[n](m){return Ct(this,s,m)}},n));d?h&&d<4&&ja(s,(d>2?"set ":d>1?"get ":"")+n):ja(i,n);for(var x=r.length-1;x>=0;x--)u=gh(d,n,l={},e[3],y),d&&(u.static=f,u.private=h,c=u.access={has:h?m=>mh(i,m):m=>n in m},d^3&&(c.get=h?m=>(d^1?Qe:vh)(m,i,d^4?s:p.get):m=>m[n]),d>2&&(c.set=h?(m,k)=>Ct(m,i,k,d^4?s:p.set):(m,k)=>m[n]=k)),a=(0,r[x])(d?d<4?h?s:p[g]:d>4?void 0:{get:p.get,set:p.set}:i,u),l._=1,d^4||a===void 0?Qn(a)&&(d>4?w.unshift(a):d?h?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Rn("Object expected"):(Qn(o=a.get)&&(p.get=o),Qn(o=a.set)&&(p.set=o),Qn(o=a.init)&&w.unshift(o));return d||Ll(e,i),p&&bo(i,n,p),h?d^4?s:p:i},yo=(e,t,n)=>t.has(e)||Rn("Cannot "+n),mh=(e,t)=>Object(t)!==t?Rn('Cannot use the "in" operator on this value'):e.has(t),Qe=(e,t,n)=>(yo(e,t,"read from private field"),n?n.call(e):t.get(e)),Zn=(e,t,n)=>t.has(e)?Rn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ct=(e,t,n,r)=>(yo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),vh=(e,t,n)=>(yo(e,t,"access private method"),n);function Os(e,t){if(t){let n;return Sa(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return Sa(e)}function st(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((n,r)=>!st(n,t[r]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(i=>!st(e[i],t[i]))}return!1}function U({get:e},t){return{init(n){return An(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function fe(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Os(e.bind(this)),n.set(this,r)),r.value}}function is(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),i=Object.getOwnPropertyDescriptor(r,n.name);i&&Object.defineProperty(r,n.name,fh(hh({},i),{enumerable:e}))})}}function Dr(...e){const t=e.map(n=>nt(n));return()=>t.forEach(n=>n())}var Nl,_l,Fl,Hl,ql,Ul,Re,xo,ss,Ms,Es,De,wo,os,Vl,Ds,ko,as,Ts,Ps;Ul=[U],ql=[U],Hl=[U],Fl=[is()],_l=[is()],Nl=[is()];var Jt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Rt(Re,5,this),Zn(this,De),Zn(this,xo,Rt(Re,8,this)),Rt(Re,11,this),Zn(this,wo,Rt(Re,12,this)),Rt(Re,15,this),Zn(this,ko,Rt(Re,16,this)),Rt(Re,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Qe(this,De,Ts)}get initial(){return Qe(this,De,Ms)}get previous(){return Qe(this,De,Vl)}set current(e){const t=q(()=>Qe(this,De,Ts));e&&t&&this.equals(t,e)||de(()=>{Qe(this,De,Ms)||Ct(this,De,e,Es),Ct(this,De,t,Ds),Ct(this,De,e,Ps)})}reset(e=this.defaultValue){de(()=>{Ct(this,De,void 0,Ds),Ct(this,De,e,Es),Ct(this,De,e,Ps)})}};Re=ph();xo=new WeakMap;De=new WeakSet;wo=new WeakMap;ko=new WeakMap;ss=Wn(Re,20,"#initial",Ul,De,xo),Ms=ss.get,Es=ss.set;os=Wn(Re,20,"#previous",ql,De,wo),Vl=os.get,Ds=os.set;as=Wn(Re,20,"#current",Hl,De,ko),Ts=as.get,Ps=as.set;Wn(Re,2,"current",Fl,Jt);Wn(Re,2,"initial",_l,Jt);Wn(Re,2,"previous",Nl,Jt);Ll(Re,Jt);function ls(e){return q(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var zt,bh=class{constructor(){Zn(this,zt,new WeakMap)}get(e,t){var n;return e?(n=Qe(this,zt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Qe(this,zt).has(e)||Qe(this,zt).set(e,new Map),(r=Qe(this,zt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Qe(this,zt).get(e))==null?void 0:t.clear():void 0}};zt=new WeakMap;var yh=Object.create,Gl=Object.defineProperty,xh=Object.getOwnPropertyDescriptor,Ca=Object.getOwnPropertySymbols,wh=Object.prototype.hasOwnProperty,kh=Object.prototype.propertyIsEnumerable,Yl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Fi=e=>{throw TypeError(e)},Oa=Math.pow,As=(e,t,n)=>t in e?Gl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sh=(e,t)=>{for(var n in t||(t={}))wh.call(t,n)&&As(e,n,t[n]);if(Ca)for(var n of Ca(t))kh.call(t,n)&&As(e,n,t[n]);return e},$h=e=>{var t;return[,,,yh((t=e?.[Yl("metadata")])!=null?t:null)]},Xl=["class","method","getter","setter","accessor","field","value","get","set"],Kl=e=>e!==void 0&&typeof e!="function"?Fi("Function expected"):e,jh=(e,t,n,r,i)=>({kind:Xl[e],name:t,metadata:r,addInitializer:s=>n._?Fi("Already initialized"):i.push(Kl(s||null))}),Ch=(e,t)=>As(t,Yl("metadata"),e[3]),Oh=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},Bl=(e,t,n,r,i,s)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,h=2,v=Xl[c+5],g=e[h]||(e[h]=[]),w=(i=i.prototype,xh(i,n)),y=r.length-1;y>=0;y--)l=jh(c,n,a={},e[3],g),l.static=d,l.private=f,u=l.access={has:p=>n in p},u.get=p=>p[n],o=(0,r[y])(w[v],l),a._=1,Kl(o)&&(w[v]=o);return w&&Gl(i,n,w),i},Ql=(e,t,n)=>t.has(e)||Fi("Cannot "+n),Mh=(e,t,n)=>(Ql(e,t,"read from private field"),t.get(e)),Eh=(e,t,n)=>t.has(e)?Fi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Dh=(e,t,n,r)=>(Ql(e,t,"write to private field"),t.set(e,n),n),Ze=class Is{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Is(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Is(t,n)}},ht=class Lt{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,l=new Lt(i+t,r+n,s,o);return l.scale=Sh({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new Ze((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Lt))return!1;const{left:n,top:r,width:i,height:s}=this;return n===t.left&&r===t.top&&i===t.width&&s===t.height}containsPoint(t){const{top:n,left:r,bottom:i,right:s}=this;return n<=t.y&&t.y<=i&&r<=t.x&&t.x<=s}intersectionArea(t){return t instanceof Lt?Th(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:i}){return new Lt(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],l=o==="x"?s.left:s.top,u=o==="x"?s.width:s.height;return a=="start"?l:a=="end"?l+u:l+u/2};return Ze.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return Lt.from(t).intersectionRatio(Lt.from(n))}};function Th(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),o=i-r,a=s-n;return r<i&&n<s?o*a:0}var Zl,Jl,Rs,oi,Tr,Hi=class extends(Rs=Jt,Jl=[fe],Zl=[fe],Rs){constructor(e){const t=Ze.from(e);super(t,(n,r)=>Ze.equals(n,r)),Oh(Tr,5,this),Eh(this,oi,0),this.velocity={x:0,y:0}}get delta(){return Ze.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=Ze.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Mh(this,oi),o=a=>Math.round(a/s*100);de(()=>{Dh(this,oi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Ze.from(e)),this.velocity={x:0,y:0}}};Tr=$h(Rs);oi=new WeakMap;Bl(Tr,2,"delta",Jl,Hi);Bl(Tr,2,"direction",Zl,Hi);Ch(Tr,Hi);function Ws({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(Oa(r,2)+Oa(i,2))>n:"x"in n&&"y"in n?r>n.x&&i>n.y:"x"in n?r>n.x:"y"in n?i>n.y:!1}var ec=(e=>(e.Horizontal="x",e.Vertical="y",e))(ec||{}),tc=Object.values(ec),Ph=Object.create,So=Object.defineProperty,Ah=Object.defineProperties,Ih=Object.getOwnPropertyDescriptor,Rh=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertySymbols,nc=Object.prototype.hasOwnProperty,rc=Object.prototype.propertyIsEnumerable,ic=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),zn=e=>{throw TypeError(e)},zs=(e,t,n)=>t in e?So(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$o=(e,t)=>{for(var n in t||(t={}))nc.call(t,n)&&zs(e,n,t[n]);if(Si)for(var n of Si(t))rc.call(t,n)&&zs(e,n,t[n]);return e},jo=(e,t)=>Ah(e,Rh(t)),Ma=(e,t)=>So(e,"name",{value:t,configurable:!0}),sc=(e,t)=>{var n={};for(var r in e)nc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Si)for(var r of Si(e))t.indexOf(r)<0&&rc.call(e,r)&&(n[r]=e[r]);return n},Ln=e=>{var t;return[,,,Ph((t=e?.[ic("metadata")])!=null?t:null)]},oc=["class","method","getter","setter","accessor","field","value","get","set"],Jn=e=>e!==void 0&&typeof e!="function"?zn("Function expected"):e,Wh=(e,t,n,r,i)=>({kind:oc[e],name:t,metadata:r,addInitializer:s=>n._?zn("Already initialized"):i.push(Jn(s||null))}),en=(e,t)=>zs(t,ic("metadata"),e[3]),N=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},V=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),h=!!(t&16),v=d>3?e.length+1:d?f?1:2:0,g=oc[d+5],w=d>3&&(e[v-1]=[]),y=e[v]||(e[v]=[]),p=d&&(!h&&!f&&(i=i.prototype),d<5&&(d>3||!h)&&Ih(d<4?i:{get[n](){return ue(this,s)},set[n](m){return Ye(this,s,m)}},n));d?h&&d<4&&Ma(s,(d>2?"set ":d>1?"get ":"")+n):Ma(i,n);for(var x=r.length-1;x>=0;x--)u=Wh(d,n,l={},e[3],y),d&&(u.static=f,u.private=h,c=u.access={has:h?m=>zh(i,m):m=>n in m},d^3&&(c.get=h?m=>(d^1?ue:ac)(m,i,d^4?s:p.get):m=>m[n]),d>2&&(c.set=h?(m,k)=>Ye(m,i,k,d^4?s:p.set):(m,k)=>m[n]=k)),a=(0,r[x])(d?d<4?h?s:p[g]:d>4?void 0:{get:p.get,set:p.set}:i,u),l._=1,d^4||a===void 0?Jn(a)&&(d>4?w.unshift(a):d?h?s=a:p[g]=a:i=a):typeof a!="object"||a===null?zn("Object expected"):(Jn(o=a.get)&&(p.get=o),Jn(o=a.set)&&(p.set=o),Jn(o=a.init)&&w.unshift(o));return d||en(e,i),p&&So(i,n,p),h?d^4?s:p:i},Co=(e,t,n)=>t.has(e)||zn("Cannot "+n),zh=(e,t)=>Object(t)!==t?zn('Cannot use the "in" operator on this value'):e.has(t),ue=(e,t,n)=>(Co(e,t,"read from private field"),n?n.call(e):t.get(e)),Q=(e,t,n)=>t.has(e)?zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ye=(e,t,n,r)=>(Co(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ac=(e,t,n)=>(Co(e,t,"access private method"),n);function lc(e,t){return{plugin:e,options:t}}function Pr(e){return t=>lc(e,t)}function xr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var cc,wr,Oo,ai;cc=[U];var Pe=class{constructor(e,t){this.manager=e,this.options=t,Q(this,Oo,N(wr,8,this,!1)),N(wr,11,this),Q(this,ai,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return q(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=nt(e.bind(this));return ue(this,ai).add(t),t}destroy(){ue(this,ai).forEach(e=>e())}static configure(e){return lc(this,e)}};wr=Ln(null);Oo=new WeakMap;ai=new WeakMap;V(wr,4,"disabled",cc,Pe,Oo);en(wr,Pe);var Ar=class extends Pe{},li,cs=class{constructor(e){this.manager=e,this.instances=new Map,Q(this,li,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(xr).reduce((r,i)=>{const s=r.find(({plugin:o})=>o===i.plugin);return s?(s.options=i.options,r):[...r,i]},[]),n=t.map(({plugin:r})=>r);for(const r of ue(this,li))if(!n.includes(r)){if(r.prototype instanceof Ar)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);Ye(this,li,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};li=new WeakMap;function Lh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Vr=[],hn,fn,Nh=class extends Pe{constructor(e){super(e),Q(this,hn),Q(this,fn),this.computeCollisions=this.computeCollisions.bind(this),Ye(this,fn,An(Vr)),this.destroy=Dr(()=>{const t=this.computeCollisions(),n=q(()=>this.manager.dragOperation.position.current);if(t!==Vr){const r=ue(this,hn);if(Ye(this,hn,n),r&&n.x==r.x&&n.y==r.y)return}else Ye(this,hn,void 0);ue(this,fn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){q(()=>{e?ue(this,fn).value=this.computeCollisions():Ye(this,hn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Vr;const a=[],l=[];for(const u of e??n.droppables){if(u.disabled||i&&!u.accepts(i))continue;const c=t??u.collisionDetector;if(!c)continue;l.push(u),u.shape;const d=q(()=>c({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return l.length===0?Vr:(a.sort(Lh),a)}get collisions(){return ue(this,fn).value}};hn=new WeakMap;fn=new WeakMap;var dc,uc,hc,Mo,fc,ot,Eo,xn,Do,To;hc=[U],uc=[U],dc=[U];var wt=class Nt{constructor(t,n){Q(this,Eo,N(ot,8,this)),N(ot,11,this),Q(this,xn),Q(this,Do,N(ot,12,this)),N(ot,15,this),Q(this,To,N(ot,16,this)),N(ot,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let l=i;Ye(this,xn,An(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var u;return[()=>{const{id:c,manager:d}=this;if(c!==l)return l=c,d?.registry.register(this),()=>d?.registry.unregister(this)},...(u=r?.())!=null?u:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),n&&a&&queueMicrotask(this.register)}get id(){var t,n;const r=ue(this,xn).value;return(n=(t=Nt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=Nt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:ue(this,xn).peek();t!==i&&(Nt.pendingIdChanges||(Nt.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return ac(s=Nt,Mo,fc).call(s)})),Nt.pendingIdChanges.set(this,t))}register(){var t;return(t=this.manager)==null?void 0:t.registry.register(this)}unregister(){var t;(t=this.manager)==null||t.registry.unregister(this)}destroy(){var t;(t=this.manager)==null||t.registry.unregister(this)}};ot=Ln(null);Mo=new WeakSet;fc=function(){const e=wt.pendingIdChanges;wt.pendingIdChanges=null,e&&de(()=>{for(const[t,n]of e)ue(t,xn).value=n})};Eo=new WeakMap;xn=new WeakMap;Do=new WeakMap;To=new WeakMap;V(ot,4,"manager",hc,wt,Eo);V(ot,4,"data",uc,wt,Do);V(ot,4,"disabled",dc,wt,To);Q(wt,Mo);en(ot,wt);wt.pendingIdChanges=null;var qi=wt,Ea=class{constructor(){this.map=An(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));const s=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=Dr(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;this.cleanupFunctions.get(t)?.(),this.cleanupFunctions.delete(t);const i=new Map(n);i.delete(e),this.map.value=i}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this)this.cleanupFunctions.get(e)?.(),e.destroy();this.map.value=new Map}},pc,gc,mc,vc,bc,yc,Ls,We,Po,Ao,Io,ft=class extends(Ls=qi,yc=[U],bc=[U],vc=[U],mc=[fe],gc=[fe],pc=[fe],Ls){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,l=sc(n,["modifiers","type","sensors","plugins","effects"]);super(jo($o({},l),{effects:()=>{var u;return[...(u=a?.())!=null?u:[],()=>{const{manager:c,plugins:d}=this;if(!(!c||!d))for(const f of d){const{plugin:h}=xr(f);c.registry.plugins.register(h)}}]}}),t),N(We,5,this),Q(this,Po,N(We,8,this)),N(We,11,this),Q(this,Ao,N(We,12,this)),N(We,15,this),Q(this,Io,N(We,16,this,this.isDragSource?"dragging":"idle")),N(We,19,this),this.type=i,this.sensors=s,this.modifiers=r,this.alignment=l.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(const t of this.plugins){const n=xr(t);if(n.plugin===e)return n.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.source)==null?void 0:t.id)===this.id}};We=Ln(Ls);Po=new WeakMap;Ao=new WeakMap;Io=new WeakMap;V(We,4,"type",yc,ft,Po);V(We,4,"modifiers",bc,ft,Ao);V(We,4,"status",vc,ft,Io);V(We,2,"isDropping",mc,ft);V(We,2,"isDragging",gc,ft);V(We,2,"isDragSource",pc,ft);en(We,ft);var xc,wc,kc,Sc,$c,jc,Ns,we,Ro,Wo,zo,Lo,No,pt=class extends(Ns=qi,jc=[U],$c=[U],Sc=[U],kc=[U],wc=[U],xc=[fe],Ns){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=sc(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),N(we,5,this),Q(this,Ro,N(we,8,this)),N(we,11,this),Q(this,Wo,N(we,12,this)),N(we,15,this),Q(this,zo,N(we,16,this)),N(we,19,this),Q(this,Lo,N(we,20,this)),N(we,23,this),Q(this,No,N(we,24,this)),N(we,27,this),this.accept=r,this.collisionDetector=i,this.collisionPriority=s,this.type=o}accepts(e){const{accept:t}=this;return t?typeof t=="function"?t(e):e.type?Array.isArray(t)?t.includes(e.type):e.type===t:!1:!0}get isDropTarget(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.target)==null?void 0:t.id)===this.id}};we=Ln(Ns);Ro=new WeakMap;Wo=new WeakMap;zo=new WeakMap;Lo=new WeakMap;No=new WeakMap;V(we,4,"accept",jc,pt,Ro);V(we,4,"type",$c,pt,Wo);V(we,4,"collisionDetector",Sc,pt,zo);V(we,4,"collisionPriority",kc,pt,Lo);V(we,4,"shape",wc,pt,No);V(we,2,"isDropTarget",xc,pt);en(we,pt);var _h=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const i of r)i(...t)}},Fh=class extends _h{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ci(e,t=!0){let n=!1;return jo($o({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Hh=class extends Ar{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=Dr(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||qi.pendingIdChanges)return;const o=ci({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;q(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Nn=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(Nn||{}),_n=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(_n||{}),Cc,Oc,Mc,Ec,Dc,Tc,Pc,et,_o;Pc=[U],Tc=[fe],Dc=[fe],Ec=[fe],Mc=[fe],Oc=[fe],Cc=[fe];var kt=class{constructor(){N(et,5,this),Q(this,_o,N(et,8,this,"idle")),N(et,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};et=Ln(null);_o=new WeakMap;V(et,4,"value",Pc,kt,_o);V(et,2,"current",Tc,kt);V(et,2,"idle",Dc,kt);V(et,2,"initializing",Ec,kt);V(et,2,"initialized",Mc,kt);V(et,2,"dragging",Oc,kt);V(et,2,"dropped",Cc,kt);en(et,kt);var qh=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return q(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=ci({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return q(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const n=new AbortController,{event:r,coordinates:i}=e;de(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=ci({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",s),s.defaultPrevented?(t.reset(),n.abort(),n):(t.status.set("initializing"),t.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;const{status:o}=t;o.current==="initializing"&&de(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return q(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=ci({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,l,u,c,d;if(o.defaultPrevented)return;const f=(d=e.to)!=null?d:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((c=(u=e.by)==null?void 0:u.y)!=null?c:0)};r.position.current=f})})}stop(e={}){return q(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const l={resume:()=>{},abort:()=>{}};return s=new Promise((u,c)=>{l.resume=u,l.abort=c}),l};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=q(()=>{var c;return((c=r.source)==null?void 0:c.status)==="dropping"}),u=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(l){const{source:c}=r,d=nt(()=>{c?.status==="idle"&&(d(),u())})}else this.manager.renderer.rendering.then(u)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),s?s.then(a).catch(()=>r.reset()):a()})}},Cn=class extends Pe{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Uh=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},di,Ac=class{constructor(e){this.options=e,Q(this,di)}set controller(e){Ye(this,di,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=ue(this,di))==null||t.activate(e)}};di=new WeakMap;var Da=class extends Pe{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Vh=class{constructor(e){this.draggables=new Ea,this.droppables=new Ea,this.plugins=new cs(e),this.sensors=new cs(e),this.modifiers=new cs(e)}register(e,t){if(e instanceof ft)return this.draggables.register(e.id,e);if(e instanceof pt)return this.droppables.register(e.id,e);if(e.prototype instanceof Da)return this.modifiers.register(e,t);if(e.prototype instanceof Cn)return this.sensors.register(e,t);if(e.prototype instanceof Pe)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof qi)return e instanceof ft?this.draggables.unregister(e.id,e):e instanceof pt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Da)return this.modifiers.unregister(e);if(e.prototype instanceof Cn)return this.sensors.unregister(e);if(e.prototype instanceof Pe)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},Ic,Rc,Wc,zc,Lc,Nc,_c,Fc,Hc,er,ui,pn,le,Fo,Ho,qo,Uo,Vo,tr;Hc=[fe],Fc=[U],_c=[U],Nc=[U],Lc=[U],zc=[U],Wc=[fe],Rc=[fe],Ic=[fe];var lt=class{constructor(e){N(le,5,this),Q(this,er),Q(this,ui),Q(this,pn,new Jt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new kt,Q(this,Fo,N(le,8,this,!1)),N(le,11,this),Q(this,Ho,N(le,12,this,null)),N(le,15,this),Q(this,qo,N(le,16,this,null)),N(le,19,this),Q(this,Uo,N(le,20,this,null)),N(le,23,this),Q(this,Vo,N(le,24,this,[])),N(le,27,this),this.position=new Hi({x:0,y:0}),Q(this,tr,{x:0,y:0}),Ye(this,er,e)}get shape(){const{current:e,initial:t,previous:n}=ue(this,pn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?ue(this,pn).current=e:ue(this,pn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=ue(this,er).registry.draggables.get(t);return n&&Ye(this,ui,n),(e=n??ue(this,ui))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=ue(this,er).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(jo($o({},this.snapshot()),{transform:n}));return Ye(this,tr,n),n}snapshot(){return q(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:ue(this,tr),shape:this.shape?ls(this.shape):null,position:ls(this.position),status:ls(this.status),canceled:this.canceled}))}reset(){de(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,ue(this,pn).reset(),this.position.reset({x:0,y:0}),Ye(this,tr,{x:0,y:0}),this.modifiers=[]})}};le=Ln(null);er=new WeakMap;ui=new WeakMap;pn=new WeakMap;Fo=new WeakMap;Ho=new WeakMap;qo=new WeakMap;Uo=new WeakMap;Vo=new WeakMap;tr=new WeakMap;V(le,2,"shape",Hc,lt);V(le,4,"canceled",Fc,lt,Fo);V(le,4,"activatorEvent",_c,lt,Ho);V(le,4,"sourceIdentifier",Nc,lt,qo);V(le,4,"targetIdentifier",Lc,lt,Uo);V(le,4,"modifiers",zc,lt,Vo);V(le,2,"source",Wc,lt);V(le,2,"target",Rc,lt);V(le,2,"transform",Ic,lt);en(le,lt);var Gh={get rendering(){return Promise.resolve()}};function at(e,t){return typeof e=="function"?e(t):e??t}var Yh=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(d=>d.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var t;const n=e??{},r=at(n.plugins,[]),i=at(n.sensors,[]),s=at(n.modifiers,[]),o=(t=n.renderer)!=null?t:Gh,a=new Fh(this),l=new Vh(this);this.registry=l,this.monitor=a,this.renderer=o,this.actions=new qh(this),this.dragOperation=new lt(this),this.collisionObserver=new Nh(this),this.plugins=[Hh,...r],this.modifiers=s,this.sensors=i;const{destroy:u}=this,c=Dr(()=>{var d,f,h;const v=q(()=>this.dragOperation.modifiers),g=this.modifiers;for(const w of v)g.includes(w)||w.destroy();this.dragOperation.modifiers=(h=(f=(d=this.dragOperation.source)==null?void 0:d.modifiers)==null?void 0:f.map(w=>{const{plugin:y,options:p}=xr(w);return new y(this,p)}))!=null?h:g});this.destroy=()=>{c(),u()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},qc=e=>{throw TypeError(e)},Go=(e,t,n)=>t.has(e)||qc("Cannot "+n),L=(e,t,n)=>(Go(e,t,"read from private field"),t.get(e)),qe=(e,t,n)=>t.has(e)?qc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ge=(e,t,n,r)=>(Go(e,t,"write to private field"),t.set(e,n),n),Uc=(e,t,n)=>(Go(e,t,"access private method"),n);function Ui(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Vc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(Ui(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function Vi(e){const{width:t,height:n,top:r,left:i,bottom:s,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:s,right:o}}function Yo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ir(e){return"nodeType"in e}function Xe(e){var t,n,r;return e?Yo(e)?e:Ir(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function Xo(e){const{Document:t}=Xe(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Tt(e){return!e||Yo(e)?!1:e instanceof Xe(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Gc(e){return e instanceof Xe(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Fn(e){return e?Yo(e)?e.document:Ir(e)?Xo(e)?e:Tt(e)||Gc(e)?e.ownerDocument:document:document:document}function Xh(e){var t,n,r,i;const{documentElement:s}=Fn(e),o=Xe(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,l=(n=o?.height)!=null?n:s.clientHeight,u=(r=o?.offsetTop)!=null?r:0,c=(i=o?.offsetLeft)!=null?i:0;return{top:u,left:c,right:c+a,bottom:u+l,width:a,height:l}}function Kh(e,t){if(Bh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function Bh(e){return e.tagName==="DETAILS"}function kr(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let l=t;const{ownerDocument:u}=e,c=(r=u.defaultView)!=null?r:window;let d=e.parentElement;for(;d&&d!==u.documentElement;){if(!Kh(d)){const x=d.getBoundingClientRect(),m=n*(x.bottom-x.top),k=n*(x.right-x.left),$=n*(x.bottom-x.top),C=n*(x.right-x.left);l={top:Math.max(l.top,x.top-m),right:Math.min(l.right,x.right+k),bottom:Math.min(l.bottom,x.bottom+$),left:Math.max(l.left,x.left-C),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}d=d.parentElement}const f=c.visualViewport,h=(i=f?.offsetTop)!=null?i:0,v=(s=f?.offsetLeft)!=null?s:0,g=(o=f?.width)!=null?o:c.innerWidth,w=(a=f?.height)!=null?a:c.innerHeight,y=n*w,p=n*g;return l={top:Math.max(l.top,h-y),right:Math.min(l.right,v+g+p),bottom:Math.min(l.bottom,h+w+y),left:Math.max(l.left,v-p),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function On(e){return{x:e.clientX,y:e.clientY}}var Yc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function _s(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const i=r.contentDocument;i&&!t.has(i)&&n.push(..._s(i,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const i=r.parent;i&&i.document&&i.document!==e&&n.push(..._s(i.document,t))}}catch{}return n}function Ko(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Xc(){var e,t;const n=Ko()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Bo(e){return!e||!Ir(e)?!1:e instanceof Xe(e).ShadowRoot}function $i(e){if(e&&Ir(e)){let t=e.getRootNode();if(Bo(t)||t instanceof Document)return t}return Fn(e)}function Qo(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Qh(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,s)=>{const o=r[s];Ta(i)&&Ta(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Pa(i)&&Pa(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function Ta(e){return"value"in e}function Pa(e){return e.tagName==="CANVAS"}function Kc(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Zh(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Kc(i,{x:t-s,y:n-o})}}return r}function Zh(e){return e?.tagName==="IFRAME"}var Fs=new WeakMap;function Jh(e){return e.closest(`
3
- input:not([disabled]),
4
- select:not([disabled]),
5
- textarea:not([disabled]),
6
- button:not([disabled]),
7
- a[href],
8
- [contenteditable]:not([contenteditable="false"])
9
- `)}var Bc=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:i}]=e;t.removeEventListener(n,r,i)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],i=[];for(const o of n)for(const a of r){const{type:l,listener:u,options:c}=a,d=[o,a];o.addEventListener(l,u,c),this.entries.add(d),i.push(d)}const s=this.entries;return function(){for(const o of i){const[a,{type:l,listener:u,options:c}]=o;a.removeEventListener(l,u,c),s.delete(o)}}}};function Mn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function ef(e){const t=new Set;let n=Mn(e);for(;n;)t.add(n),n=Mn(n);return t}function tf(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Qc(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=tf(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function nf(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function rf(e,t=e.getBoundingClientRect()){const{width:n,height:r}=kr(e,t);return n>0&&r>0}var sf=Yc?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},hi,of=class extends sf{constructor(e){super(t=>{if(!L(this,hi)){Ge(this,hi,!0);return}e(t,this)}),qe(this,hi,!1)}};hi=new WeakMap;var Aa=Array.from({length:100},(e,t)=>t/100),Zc=75,_t,ji,$t,Ft,nr,Me,gr,rr,Ci,Jc,ed,td=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,qe(this,Ci),this.disconnect=()=>{var s,o,a;Ge(this,gr,!0),(s=L(this,$t))==null||s.disconnect(),(o=L(this,Ft))==null||o.disconnect(),L(this,nr).disconnect(),(a=L(this,Me))==null||a.remove()},qe(this,_t,!0),qe(this,ji),qe(this,$t),qe(this,Ft),qe(this,nr),qe(this,Me),qe(this,gr,!1),qe(this,rr,Qc(()=>{var s,o,a;const{element:l}=this;if((s=L(this,Ft))==null||s.disconnect(),L(this,gr)||!L(this,_t)||!l.isConnected)return;const u=(o=l.ownerDocument)!=null?o:document,{innerHeight:c,innerWidth:d}=(a=u.defaultView)!=null?a:window,f=l.getBoundingClientRect(),h=kr(l,f),{top:v,left:g,bottom:w,right:y}=h,p=-Math.floor(v),x=-Math.floor(g),m=-Math.floor(d-y),k=-Math.floor(c-w),$=`${p}px ${m}px ${k}px ${x}px`;this.boundingClientRect=f,Ge(this,Ft,new IntersectionObserver(C=>{const[M]=C,{intersectionRect:T}=M;(M.intersectionRatio!==1?M.intersectionRatio:ht.intersectionRatio(T,kr(l)))!==1&&L(this,rr).call(this)},{threshold:Aa,rootMargin:$,root:u})),L(this,Ft).observe(l),Uc(this,Ci,Jc).call(this)},Zc)),this.boundingClientRect=e.getBoundingClientRect(),Ge(this,_t,rf(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(Ge(this,Me,document.createElement("div")),L(this,Me).style.background="rgba(0,0,0,0.15)",L(this,Me).style.position="fixed",L(this,Me).style.pointerEvents="none",i.body.appendChild(L(this,Me))),Ge(this,nr,new IntersectionObserver(s=>{var o,a;const l=s[s.length-1],{boundingClientRect:u,isIntersecting:c}=l,{width:d,height:f}=u,h=L(this,_t);Ge(this,_t,c),!(!d&&!f)&&(h&&!c?((o=L(this,Ft))==null||o.disconnect(),this.callback(null),(a=L(this,$t))==null||a.disconnect(),Ge(this,$t,void 0),L(this,Me)&&(L(this,Me).style.visibility="hidden")):L(this,rr).call(this),c&&!L(this,$t)&&(Ge(this,$t,new of(L(this,rr))),L(this,$t).observe(e)))},{threshold:Aa,root:i})),L(this,_t)&&!n.skipInitial&&this.callback(this.boundingClientRect),L(this,nr).observe(e)}};_t=new WeakMap;ji=new WeakMap;$t=new WeakMap;Ft=new WeakMap;nr=new WeakMap;Me=new WeakMap;gr=new WeakMap;rr=new WeakMap;Ci=new WeakSet;Jc=function(){L(this,gr)||(Uc(this,Ci,ed).call(this),!nf(this.boundingClientRect,L(this,ji))&&(this.callback(this.boundingClientRect),Ge(this,ji,this.boundingClientRect)))};ed=function(){if(L(this,Me)){const{top:e,left:t,width:n,height:r}=kr(this.element);L(this,Me).style.overflow="hidden",L(this,Me).style.visibility="visible",L(this,Me).style.top=`${Math.floor(e)}px`,L(this,Me).style.left=`${Math.floor(t)}px`,L(this,Me).style.width=`${Math.floor(n)}px`,L(this,Me).style.height=`${Math.floor(r)}px`}};var Gr=new WeakMap,Yr=new WeakMap;function af(e,t){let n=Gr.get(e);return n||(n={disconnect:new td(e,r=>{const i=Gr.get(e);i&&i.callbacks.forEach(s=>s(r))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),Gr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Gr.delete(e),n.disconnect())}}function lf(e,t){const n=new Set;for(const r of e){const i=af(r,t);n.add(i)}return()=>n.forEach(r=>r())}function cf(e,t){var n;const r=e.ownerDocument;if(!Yr.has(r)){const o=new AbortController,a=new Set;document.addEventListener("scroll",l=>a.forEach(u=>u(l)),{capture:!0,passive:!0,signal:o.signal}),Yr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=Yr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),Yr.delete(r))})}var ir,sr,fi,Hs,df=class{constructor(e,t,n){this.callback=t,qe(this,ir),qe(this,sr,!1),qe(this,fi),qe(this,Hs,Qc(o=>{if(!L(this,sr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of L(this,fi))if(o.target.contains(a)){this.callback(L(this,ir).boundingClientRect);break}}},Zc));const r=ef(e),i=lf(r,t),s=cf(e,L(this,Hs));Ge(this,fi,r),Ge(this,ir,new td(e,t,n)),this.disconnect=()=>{L(this,sr)||(Ge(this,sr,!0),i(),s(),L(this,ir).disconnect())}}};ir=new WeakMap;sr=new WeakMap;fi=new WeakMap;Hs=new WeakMap;function qs(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function Sn(e){try{qs(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function Ia(e){return!Yc||!e?!1:e===Fn(e).scrollingElement}function nd(e){var t,n;const r=Xe(e),i=Ia(e)?Xh(e):Vi(e),s=r.visualViewport,o=Ia(e)?{height:(t=s?.height)!=null?t:r.innerHeight,width:(n=s?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},l=a.current.y<=0,u=a.current.x<=0,c=a.current.y>=a.max.y,d=a.current.x>=a.max.x;return{rect:i,position:a,isTop:l,isLeft:u,isBottom:c,isRight:d}}function uf(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=nd(e),{x:a,y:l}=t??{x:0,y:0},u=!n&&o.current.y+l>0,c=!r&&o.current.y+l<o.max.y,d=!i&&o.current.x+a>0,f=!s&&o.current.x+a<o.max.x;return{top:u,bottom:c,left:d,right:f,x:d||f,y:u||c}}var Zo=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},Oi=new Zo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),hf=new Zo(e=>setTimeout(e,50)),Mi=new Map,ff=Mi.clear.bind(Mi);function gt(e,t=!1){if(!t)return Ra(e);let n=Mi.get(e);return n||(n=Ra(e),Mi.set(e,n),hf.schedule(ff),n)}function Ra(e){return Xe(e).getComputedStyle(e)}function pf(e,t=gt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function gf(e,t=gt(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const i=t[r];return typeof i=="string"?n.test(i):!1})}var mf={excludeElement:!0,escapeShadowDOM:!0};function Us(e,t=mf){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(Xo(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&Bo(a))return o(a.host);if(!Tt(a))return Gc(a)?o(a.parentElement):s;if(s.has(a))return s;const l=gt(a,!0);if(r&&a===e||gf(a,l)&&s.add(a),pf(a,l)){const{scrollingElement:u}=a.ownerDocument;return u&&s.add(u),s}return o(a.parentNode)}return e?o(e):s}function En(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Mn(e);for(;r;){if(r===t)return n;const i=Vi(r),{x:s,y:o}=vf(r,i);n.x=n.x+i.left,n.y=n.y+i.top,n.scaleX=n.scaleX*s,n.scaleY=n.scaleY*o,r=Mn(r)}return n}function vf(e,t=Vi(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Tt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const i=gt(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function bf(e){if(!e||e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function Sr(e){if(!e||e==="none")return null;const[t,n,r="0"]=e.split(" "),i={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(i.x)&&isNaN(i.y)?null:{x:isNaN(i.x)?0:i.x,y:isNaN(i.y)?0:i.y,z:isNaN(i.z)?0:i.z}}function Gi(e){var t,n,r,i,s,o,a,l,u;const{scale:c,transform:d,translate:f}=e,h=bf(c),v=Sr(f),g=yf(d);if(!g&&!h&&!v)return null;const w={x:(t=h?.x)!=null?t:1,y:(n=h?.y)!=null?n:1},y={x:(r=v?.x)!=null?r:0,y:(i=v?.y)!=null?i:0},p={x:(s=g?.x)!=null?s:0,y:(o=g?.y)!=null?o:0,scaleX:(a=g?.scaleX)!=null?a:1,scaleY:(l=g?.scaleY)!=null?l:1};return{x:y.x+p.x,y:y.y+p.y,z:(u=v?.z)!=null?u:0,scaleX:w.x*p.scaleX,scaleY:w.y*p.scaleY}}function yf(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var Je=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(Je||{}),xf={x:.2,y:.2},wf={x:10,y:10};function kf(e,t,n,r=25,i=xf,s=wf){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:c,isLeft:d,isRight:f}=nd(e),h=En(e),v=gt(e,!0),g=Gi(v),w=g!==null?g?.scaleX<0:!1,y=g!==null?g?.scaleY<0:!1,p=new ht(l.left*h.scaleX+h.x,l.top*h.scaleY+h.y,l.width*h.scaleX,l.height*h.scaleY),x={x:0,y:0},m={x:0,y:0},k={height:p.height*i.y,width:p.width*i.x};return k.height>0&&(!u||y&&!c)&&a<=p.top+k.height&&n?.y!==1&&o>=p.left-s.x&&o<=p.right+s.x?(x.y=y?1:-1,m.y=r*Math.abs((p.top+k.height-a)/k.height)):k.height>0&&(!c||y&&!u)&&a>=p.bottom-k.height&&n?.y!==-1&&o>=p.left-s.x&&o<=p.right+s.x&&(x.y=y?-1:1,m.y=r*Math.abs((p.bottom-k.height-a)/k.height)),k.width>0&&(!f||w&&!d)&&o>=p.right-k.width&&n?.x!==-1&&a>=p.top-s.y&&a<=p.bottom+s.y?(x.x=w?-1:1,m.x=r*Math.abs((p.right-k.width-o)/k.width)):k.width>0&&(!d||w&&!f)&&o<=p.left+k.width&&n?.x!==1&&a>=p.top-s.y&&a<=p.bottom+s.y&&(x.x=w?1:-1,m.x=r*Math.abs((p.left+k.width-o)/k.width)),{direction:x,speed:m}}function rd(e,{block:t="nearest",inline:n="nearest"}={}){if(!Tt(e))return;const r=Us(e),i=[];for(const s of r){if(!Tt(s))continue;const{top:o,left:a}=Sf(e,s);let l=o,u=a;for(const c of i)l-=c.scrollTop,u-=c.scrollLeft;if(t!=="none"){const c=l<s.scrollTop,d=l+e.offsetHeight>s.scrollTop+s.clientHeight;c!==d&&(t==="center"?s.scrollTop=l-s.clientHeight/2+e.offsetHeight/2:c?s.scrollTop=l:s.scrollTop=l+e.offsetHeight-s.clientHeight)}if(n!=="none"){const c=u<s.scrollLeft,d=u+e.offsetWidth>s.scrollLeft+s.clientWidth;c!==d&&(n==="center"?s.scrollLeft=u-s.clientWidth/2+e.offsetWidth/2:c?s.scrollLeft=u:s.scrollLeft=u+e.offsetWidth-s.clientWidth)}i.push(s)}}function Wa(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!Tt(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function Sf(e,t){const n=Wa(e),r=Wa(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function $f(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left+s+(1-r)*parseFloat(n),l=e.top+o+(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width*r:e.width,c=i?e.height*i:e.height;return{width:u,height:c,top:l,right:a+u,bottom:l+c,left:a}}function jf(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left-s-(1-r)*parseFloat(n),l=e.top-o-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width/r:e.width,c=i?e.height/i:e.height;return{width:u,height:c,top:l,right:a+u,bottom:l+c,left:a}}function id({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function za(e,t=gt(e).translate,n=!0){if(n){const r=Vc(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=Sr(i);if(s)return s}}}if(t){const r=Sr(t);if(r)return r}return{x:0,y:0,z:0}}var Cf=new Zo(e=>setTimeout(e,0)),mr=new Map,Of=mr.clear.bind(mr);function Mf(e){const t=e.ownerDocument;let n=mr.get(t);if(n)return n;n=t.getAnimations(),mr.set(t,n),Cf.schedule(Of);const r=n.filter(i=>Ui(i.effect)&&i.effect.target===e);return mr.set(e,r),n}function Ef(e,t){const n=Mf(e).filter(r=>{var i,s;if(Ui(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))==null||s)return r.effect.getKeyframes().some(a=>{for(const l of t.properties)if(a[l])return!0})}}).map(r=>{const{effect:i,currentTime:s}=r,o=i?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof s=="number"&&s<o)return r.currentTime=o,()=>{r.currentTime=s}});if(n.length>0)return()=>n.forEach(r=>r?.())}var ut=class extends ht{constructor(e,t={}){var n,r,i,s;const{frameTransform:o=En(e),ignoreTransforms:a,getBoundingClientRect:l=Vi}=t,u=Ef(e,{properties:["transform","translate","scale","width","height"],isValidTarget:k=>(k!==e||Ko())&&k.contains(e)}),c=l(e);let{top:d,left:f,width:h,height:v}=c,g;const w=gt(e),y=Gi(w),p={x:(n=y?.scaleX)!=null?n:1,y:(r=y?.scaleY)!=null?r:1},x=Df(e,w);u?.(),y&&(g=jf(c,y,w.transformOrigin),(a||x)&&(d=g.top,f=g.left,h=g.width,v=g.height));const m={width:(i=g?.width)!=null?i:h,height:(s=g?.height)!=null?s:v};if(x&&!a&&g){const k=$f(g,x,w.transformOrigin);d=k.top,f=k.left,h=k.width,v=k.height,p.x=x.scaleX,p.y=x.scaleY}o&&(a||(f*=o.scaleX,h*=o.scaleX,d*=o.scaleY,v*=o.scaleY),f+=o.x,d+=o.y),super(f,d,h,v),this.scale=p,this.intrinsicWidth=m.width,this.intrinsicHeight=m.height}};function Df(e,t){const n=e.getAnimations();if(!n.length)return null;let r,i,s,o=!1;for(const a of n){if(a.playState!=="running")continue;const l=Ui(a.effect)?a.effect.getKeyframes():[],u=l[l.length-1];if(!u)continue;const{transform:c,translate:d,scale:f}=u;typeof c=="string"&&c&&(r=c,o=!0),typeof d=="string"&&d&&(i=d,o=!0),typeof f=="string"&&f&&(s=f,o=!0)}return o?Gi({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function vr(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var Tf=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(vr(n))for(const[r,i]of Object.entries(e)){const s=`${t}${r}`;this.initial.has(s)||this.initial.set(s,n.style.getPropertyValue(s)),n.style.setProperty(s,typeof i=="string"?i:`${i}px`)}}remove(e,t=""){const{element:n}=this;if(vr(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(vr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Yt(e){return e?e instanceof Xe(e).Element||Ir(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function $r(e){if(!e)return!1;const{KeyboardEvent:t}=Xe(e.target);return e instanceof t}function Pf(e){if(!e)return!1;const{PointerEvent:t}=Xe(e.target);return e instanceof t}function Af(e){if(!Yt(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||If(e)}function If(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var ds={};function Vs(e){const t=ds[e]==null?0:ds[e]+1;return ds[e]=t,`${e}-${t}`}var Jo=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=Ze.distance(t.shape.center,n);return{id:r,value:1/i,type:_n.PointerIntersection,priority:Nn.High}}return null},Rf=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=Ze.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:o,type:_n.ShapeIntersection,priority:Nn.Normal}}return null},sd=e=>{var t;return(t=Jo(e))!=null?t:Rf(e)},Wf=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;const s=r?ht.from(r.current.boundingRectangle).corners:void 0,o=ht.from(n.shape.boundingRectangle).corners.reduce((a,l,u)=>{var c;return a+Ze.distance(Ze.from(l),(c=s?.[u])!=null?c:i.current)},0)/4;return{id:n.id,value:1/o,type:_n.Collision,priority:Nn.Normal}},zf=Object.create,ea=Object.defineProperty,Lf=Object.defineProperties,Nf=Object.getOwnPropertyDescriptor,_f=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,od=Object.prototype.hasOwnProperty,ad=Object.prototype.propertyIsEnumerable,ld=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Hn=e=>{throw TypeError(e)},Gs=(e,t,n)=>t in e?ea(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jr=(e,t)=>{for(var n in t||(t={}))od.call(t,n)&&Gs(e,n,t[n]);if(Ei)for(var n of Ei(t))ad.call(t,n)&&Gs(e,n,t[n]);return e},ta=(e,t)=>Lf(e,_f(t)),La=(e,t)=>ea(e,"name",{value:t,configurable:!0}),cd=(e,t)=>{var n={};for(var r in e)od.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ei)for(var r of Ei(e))t.indexOf(r)<0&&ad.call(e,r)&&(n[r]=e[r]);return n},qn=e=>{var t;return[,,,zf((t=e?.[ld("metadata")])!=null?t:null)]},dd=["class","method","getter","setter","accessor","field","value","get","set"],or=e=>e!==void 0&&typeof e!="function"?Hn("Function expected"):e,Ff=(e,t,n,r,i)=>({kind:dd[e],name:t,metadata:r,addInitializer:s=>n._?Hn("Already initialized"):i.push(or(s||null))}),tn=(e,t)=>Gs(t,ld("metadata"),e[3]),Se=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},rt=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),h=!!(t&16),v=d>3?e.length+1:d?f?1:2:0,g=dd[d+5],w=d>3&&(e[v-1]=[]),y=e[v]||(e[v]=[]),p=d&&(!h&&!f&&(i=i.prototype),d<5&&(d>3||!h)&&Nf(d<4?i:{get[n](){return re(this,s)},set[n](m){return ze(this,s,m)}},n));d?h&&d<4&&La(s,(d>2?"set ":d>1?"get ":"")+n):La(i,n);for(var x=r.length-1;x>=0;x--)u=Ff(d,n,l={},e[3],y),d&&(u.static=f,u.private=h,c=u.access={has:h?m=>Hf(i,m):m=>n in m},d^3&&(c.get=h?m=>(d^1?re:Xt)(m,i,d^4?s:p.get):m=>m[n]),d>2&&(c.set=h?(m,k)=>ze(m,i,k,d^4?s:p.set):(m,k)=>m[n]=k)),a=(0,r[x])(d?d<4?h?s:p[g]:d>4?void 0:{get:p.get,set:p.set}:i,u),l._=1,d^4||a===void 0?or(a)&&(d>4?w.unshift(a):d?h?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Hn("Object expected"):(or(o=a.get)&&(p.get=o),or(o=a.set)&&(p.set=o),or(o=a.init)&&w.unshift(o));return d||tn(e,i),p&&ea(i,n,p),h?d^4?s:p:i},na=(e,t,n)=>t.has(e)||Hn("Cannot "+n),Hf=(e,t)=>Object(t)!==t?Hn('Cannot use the "in" operator on this value'):e.has(t),re=(e,t,n)=>(na(e,t,"read from private field"),n?n.call(e):t.get(e)),ge=(e,t,n)=>t.has(e)?Hn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ze=(e,t,n,r)=>(na(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Xt=(e,t,n)=>(na(e,t,"access private method"),n),Na={role:"button",roleDescription:"draggable"},qf="dnd-kit-description",Uf="dnd-kit-announcement",Vf={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},Gf={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function Yf(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Xf(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function Kf(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var Bf=["dragover","dragmove"],Qf=class extends Pe{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=qf,announcement:i=Uf}={},announcements:s=Gf,screenReaderInstructions:o=Vf,debounce:a=500}=t??{},l=n?`${r}-${n}`:Vs(r),u=n?`${i}-${n}`:Vs(i);let c,d,f,h;const v=(k=h)=>{!f||!k||f?.nodeValue!==k&&(f.nodeValue=k)},g=()=>Oi.schedule(v),w=Zf(g,a),y=Object.entries(s).map(([k,$])=>this.manager.monitor.addEventListener(k,(C,M)=>{const T=f;if(!T)return;const P=$?.(C,M);P&&T.nodeValue!==P&&(h=P,Bf.includes(k)?w():(g(),w.cancel()))})),p=()=>{let k=[];c?.isConnected||(c=Xf(l,o.draggable),k.push(c)),d?.isConnected||(d=Kf(u),f=document.createTextNode(""),d.appendChild(f),k.push(d)),k.length>0&&document.body.append(...k)},x=new Set;function m(){for(const k of x)k()}this.registerEffect(()=>{var k;x.clear();for(const $ of this.manager.registry.draggables.value){const C=(k=$.handle)!=null?k:$.element;if(C){(!c||!d)&&x.add(p),(!Yf(C)||Ko())&&!C.hasAttribute("tabindex")&&x.add(()=>C.setAttribute("tabindex","0")),!C.hasAttribute("role")&&C.tagName.toLowerCase()!=="button"&&x.add(()=>C.setAttribute("role",Na.role)),C.hasAttribute("aria-roledescription")||x.add(()=>C.setAttribute("aria-roledescription",Na.roleDescription)),C.hasAttribute("aria-describedby")||x.add(()=>C.setAttribute("aria-describedby",l));for(const T of["aria-pressed","aria-grabbed"]){const P=String($.isDragging);C.getAttribute(T)!==P&&x.add(()=>C.setAttribute(T,P))}const M=String($.disabled);C.getAttribute("aria-disabled")!==M&&x.add(()=>C.setAttribute("aria-disabled",M))}}x.size>0&&Oi.schedule(m)}),this.destroy=()=>{super.destroy(),c?.remove(),d?.remove(),y.forEach(k=>k())}}};function Zf(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Di=new Map,ud,hd,fd,pd,Ys,br,xt,ra,Dn,gd,md,vd,bd,Pt=class extends(Ys=Ar,pd=[U],fd=[fe],hd=[fe],ud=[fe],Ys){constructor(e,t){super(e,t),Se(xt,5,this),ge(this,Dn),ge(this,br,new Set),ge(this,ra,Se(xt,8,this,new Set)),Se(xt,11,this),this.registerEffect(Xt(this,Dn,gd))}register(e){return re(this,br).add(e),()=>{re(this,br).delete(e)}}addRoot(e){return q(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{q(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return $i((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return $i((e=t?.element)!=null?e:null)}get roots(){const{status:e}=this.manager.dragOperation;if(e.initializing||e.initialized){const t=[this.sourceRoot,this.targetRoot].filter(n=>n!=null);return new Set([...t,...this.additionalRoots])}return new Set}};xt=qn(Ys);br=new WeakMap;ra=new WeakMap;Dn=new WeakSet;gd=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of re(this,br))t.push(Xt(this,Dn,md).call(this,n,r));return()=>{for(const n of t)n()}};md=function(e,t){let n=Di.get(e);n||(n=new Map,Di.set(e,n));let r=n.get(t);if(!r){const s=Xo(e)?Xt(this,Dn,vd).call(this,e,n,t):Xt(this,Dn,bd).call(this,e,n,t);if(!s)return()=>{};r=s,n.set(t,r)}r.refCount++;let i=!1;return()=>{i||(i=!0,r.refCount--,r.refCount===0&&r.cleanup())}};vd=function(e,t,n){var r;const i=e.createElement("style"),{nonce:s}=(r=this.options)!=null?r:{};s&&i.setAttribute("nonce",s),i.textContent=n,e.head.prepend(i);const o=new MutationObserver(a=>{for(const l of a)for(const u of Array.from(l.removedNodes))if(u===i){e.head.prepend(i);return}});return o.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{o.disconnect(),i.remove(),t.delete(n),t.size===0&&Di.delete(e)}}};bd=function(e,t,n){"adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets);const r=e.ownerDocument.defaultView,{CSSStyleSheet:i}=r??{};if(!i)return null;const s=new i;return s.replaceSync(n),e.adoptedStyleSheets.push(s),{refCount:0,cleanup:()=>{var o;if(Bo(e)&&(o=e.host)!=null&&o.isConnected){const a=e.adoptedStyleSheets.indexOf(s);a!==-1&&e.adoptedStyleSheets.splice(a,1)}t.delete(n),t.size===0&&Di.delete(e)}}};rt(xt,4,"additionalRoots",pd,Pt,ra);rt(xt,2,"sourceRoot",fd,Pt);rt(xt,2,"targetRoot",hd,Pt);rt(xt,2,"roots",ud,Pt);tn(xt,Pt);Pt.configure=Pr(Pt);var Yi=Pt,Jf=class extends Pe{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Yi),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},Rr="data-dnd-",Xs=`${Rr}dropping`,Oe="--dnd-",dt=`${Rr}dragging`,Ti=`${Rr}placeholder`,ep=[dt,Ti,"popover","aria-pressed","aria-grabbing"],tp=["view-transition-name"],np=`
10
- :is(:root,:host) [${dt}] {
11
- position: fixed !important;
12
- pointer-events: none !important;
13
- touch-action: none;
14
- z-index: calc(infinity);
15
- will-change: translate;
16
- top: var(${Oe}top, 0px) !important;
17
- left: var(${Oe}left, 0px) !important;
18
- right: unset !important;
19
- bottom: unset !important;
20
- width: var(${Oe}width, auto);
21
- max-width: var(${Oe}width, auto);
22
- height: var(${Oe}height, auto);
23
- max-height: var(${Oe}height, auto);
24
- transform: var(${Oe}transform, none) !important;
25
- transition: var(${Oe}transition) !important;
26
- }
27
-
28
- :is(:root,:host) [${Ti}] {
29
- transition: none;
30
- }
31
-
32
- :is(:root,:host) [${Ti}='hidden'] {
33
- visibility: hidden;
34
- }
35
-
36
- [${dt}] * {
37
- pointer-events: none !important;
38
- }
39
-
40
- [${dt}]:not([${Xs}]) {
41
- translate: var(${Oe}translate) !important;
42
- }
43
-
44
- [${dt}][style*='${Oe}scale'] {
45
- scale: var(${Oe}scale) !important;
46
- transform-origin: var(${Oe}transform-origin) !important;
47
- }
48
-
49
- @layer dnd-kit {
50
- :where([${dt}][popover]) {
51
- overflow: visible;
52
- background: unset;
53
- border: unset;
54
- margin: unset;
55
- padding: unset;
56
- color: inherit;
57
-
58
- &:is(input, button) {
59
- border: revert;
60
- background: revert;
61
- }
62
- }
63
- }
64
- [${dt}]::backdrop, [${Rr}overlay]:not([${dt}]) {
65
- display: none;
66
- visibility: hidden;
67
- }
68
- `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function rp(e,t="hidden"){return q(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=ip(n,r.registry.droppables),s=[],o=Qh(n),{remove:a}=o;return sp(i,o,s),op(o,t),o.remove=()=>{s.forEach(l=>l()),a.call(o)},o})}function ip(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${Rr}${Vs("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function sp(e,t,n){for(const[r,i]of e){if(!r.element)continue;const s=`[${i}]`,o=t.matches(s)?t:t.querySelector(s);if(r.element.removeAttribute(i),!o)continue;const a=r.element;r.proxy=o,o.removeAttribute(i),Fs.set(a,o),n.push(()=>{Fs.delete(a),r.proxy=void 0})}}function op(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Ti,t)}function yd(e,t){return e===t?!0:Mn(e)===Mn(t)}function _a(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Yt(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>Sn(t))}function Ks(e){return e.tagName==="TR"}function ap(e,t,n){const r=new MutationObserver(i=>{let s=!1;for(const o of i){if(o.target!==e){s=!0;continue}if(o.type!=="attributes")continue;const a=o.attributeName;if(a.startsWith("aria-")||ep.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(vr(e)&&vr(t)){const u=e.style;for(const c of Array.from(t.style))u.getPropertyValue(c)===""&&t.style.removeProperty(c);for(const c of Array.from(u)){if(tp.includes(c)||c.startsWith(Oe))continue;const d=u.getPropertyValue(c);t.style.setProperty(c,d)}}}else l!==null?t.setAttribute(a,l):t.removeAttribute(a)}s&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function lp(e,t,n){const r=new MutationObserver(i=>{for(const s of i)if(s.addedNodes.length!==0)for(const o of Array.from(s.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),Sn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),Sn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),Sn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function cp(e){return new ResizeObserver(()=>{var t,n,r;const i=new ut(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-i.width)*s.x+e.delta.x,a=(e.height-i.height)*s.y+e.delta.y,l=Xc();if(e.styles.set({width:i.width-e.widthOffset,height:i.height-e.heightOffset,top:e.top+a+l.y,left:e.left+o+l.x},Oe),(n=e.getElementMutationObserver())==null||n.takeRecords(),Ks(e.element)&&Ks(e.placeholder)){const g=Array.from(e.element.cells),w=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(g.map(y=>y.style.width));for(const[y,p]of g.entries()){const x=w[y];p.style.width=`${x.getBoundingClientRect().width}px`}}const u=(r=e.getTranslate())!=null?r:{x:0,y:0},c=e.left+o+l.x+u.x,d=e.top+a+l.y+u.y,f=i.width-e.widthOffset,h=i.height-e.heightOffset,v=e.frameTransform;e.dragOperation.shape=new ht(c*v.scaleX+v.x,d*v.scaleY+v.y,f*v.scaleX,h*v.scaleY)})}var dp=250,up="ease";function hp(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const p=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(p).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=dp,easing:a=up}=s??{};Sn(e.feedbackElement);const[,l]=(t=Vc(e.feedbackElement,p=>"translate"in p))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,c={frameTransform:yd(e.feedbackElement,u)?null:void 0},d=new ut(e.feedbackElement,c),f=(r=Sr(gt(e.feedbackElement).translate))!=null?r:e.translate,h=new ut(u,c),v=ht.delta(d,h,e.alignment),g={x:f.x-v.x,y:f.y-v.y},w=Math.round(d.intrinsicHeight)!==Math.round(h.intrinsicHeight)?{minHeight:[`${d.intrinsicHeight}px`,`${h.intrinsicHeight}px`],maxHeight:[`${d.intrinsicHeight}px`,`${h.intrinsicHeight}px`]}:{},y=Math.round(d.intrinsicWidth)!==Math.round(h.intrinsicWidth)?{minWidth:[`${d.intrinsicWidth}px`,`${h.intrinsicWidth}px`],maxWidth:[`${d.intrinsicWidth}px`,`${h.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Oe),e.feedbackElement.setAttribute(Xs,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),id({element:e.feedbackElement,keyframes:ta(jr(jr({},w),y),{translate:[`${f.x}px ${f.y}px 0`,`${g.x}px ${g.y}px 0`]}),options:{duration:Qo(Xe(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(Xs),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var xd,Bs,Cr,ia,pi,wd,kd,Tn=class extends(Bs=Pe,xd=[U],Bs){constructor(e,t){super(e,t),ge(this,pi),ge(this,ia,Se(Cr,8,this)),Se(Cr,11,this),this.state={initial:{},current:{}};const n=e.registry.plugins.get(Yi),r=n?.register(np);if(r){const i=this.destroy.bind(this);this.destroy=()=>{r(),i()}}this.registerEffect(Xt(this,pi,wd).bind(this,n)),this.registerEffect(Xt(this,pi,kd))}};Cr=qn(Bs);ia=new WeakMap;pi=new WeakSet;wd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=$i(t);if(n)return e.addRoot(n)};kd=function(){var e,t,n,r,i,s,o;const{state:a,manager:l,options:u}=this,{dragOperation:c}=l,{position:d,source:f,status:h}=c;if(h.idle){a.current={},a.initial={};return}if(!f)return;const{element:v}=f,g=f.pluginConfig(Tn),w=(t=(e=g?.feedback)!=null?e:u?.feedback)!=null?t:"default",y=typeof w=="function"?w(f,l):w;if(!v||y==="none"||!h.initialized||h.initializing)return;const{initial:p}=a,x=(n=this.overlay)!=null?n:v,m=En(x),k=En(v),$=!yd(v,x),C=new ut(v,{frameTransform:$?k:null,ignoreTransforms:!$}),M={x:k.scaleX/m.scaleX,y:k.scaleY/m.scaleY};let{width:T,height:P,top:G,left:R}=C;$&&(T=T/M.x,P=P/M.y);const O=new Tf(x),_=gt(v),{transition:Y,translate:me,boxSizing:Ae,paddingBlockStart:oe,paddingBlockEnd:Ne,paddingInlineStart:Ue,paddingInlineEnd:Ee,borderInlineStartWidth:Ke,borderInlineEndWidth:Ve,borderBlockStartWidth:_e,borderBlockEndWidth:Be}=_,Ce=Y.split(",").filter(z=>!/^\s*(transform|translate|scale)\b/.test(z)).join(","),xe=Gi(_),I=_.transform,F=y==="clone",$e=Ae==="content-box",B=$e?parseInt(Ue)+parseInt(Ee)+parseInt(Ke)+parseInt(Ve):0,Fe=$e?parseInt(oe)+parseInt(Ne)+parseInt(_e)+parseInt(Be):0,ee=y!=="move"&&!this.overlay?rp(f,F?"clone":"hidden"):null,ct=q(()=>$r(l.dragOperation.activatorEvent));if(!p.translate){if(this.overlay&&xe)p.translate={x:xe.x,y:xe.y};else if(me!=="none"){const z=Sr(me);z&&(p.translate=z)}}if(!p.transformOrigin){const z=q(()=>d.current),J=R+((r=xe?.x)!=null?r:0),K=G+((i=xe?.y)!=null?i:0);p.transformOrigin={x:(z.x-J*m.scaleX-m.x)/(T*m.scaleX),y:(z.y-K*m.scaleY-m.y)/(P*m.scaleY)}}const{transformOrigin:He}=p,St=G*m.scaleY+m.y,E=R*m.scaleX+m.x;if(!p.coordinates&&(p.coordinates={x:E,y:St},M.x!==1||M.y!==1)){const{scaleX:z,scaleY:J}=k,{x:K,y:te}=He;p.coordinates.x+=(T*z-T)*K,p.coordinates.y+=(P*J-P)*te}p.dimensions||(p.dimensions={width:T,height:P}),p.frameTransform||(p.frameTransform=m);const A={x:p.coordinates.x-E,y:p.coordinates.y-St},H={width:(p.dimensions.width*p.frameTransform.scaleX-T*m.scaleX)*He.x,height:(p.dimensions.height*p.frameTransform.scaleY-P*m.scaleY)*He.y},j={x:A.x/m.scaleX+H.width,y:A.y/m.scaleY+H.height},D={left:R+j.x,top:G+j.y};x.setAttribute(dt,"true");const W=q(()=>c.transform),Z=(s=p.translate)!=null?s:{x:0,y:0},it=W.x*m.scaleX+Z.x,je=W.y*m.scaleY+Z.y,se=Xc();O.set({width:T-B,height:P-Fe,top:D.top+se.y,left:D.left+se.x,translate:`${it}px ${je}px 0`,transform:this.overlay?"none":I,transition:Ce?`${Ce}, translate 0ms linear`:"translate 0ms linear",scale:$?`${M.x} ${M.y}`:"","transform-origin":`${He.x*100}% ${He.y*100}%`},Oe),ee&&(v.insertAdjacentElement("afterend",ee),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(f):u.rootElement).appendChild(v)),qs(x)&&(x.hasAttribute("popover")||x.setAttribute("popover","manual"),Sn(x),x.addEventListener("beforetoggle",_a));let Ie,Vn,At;const Fr=cp({placeholder:ee,element:v,feedbackElement:x,frameTransform:m,transformOrigin:He,width:T,height:P,top:G,left:R,widthOffset:B,heightOffset:Fe,delta:j,styles:O,dragOperation:c,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>Ie,getSavedCellWidths:()=>At,setSavedCellWidths:z=>{At=z}}),It=new ut(x);q(()=>c.shape=It);const nn=Xe(x),Gn=z=>{this.manager.actions.stop({event:z})},Ji=Qo(nn);ct&&nn.addEventListener("resize",Gn),q(()=>f.status)==="idle"&&requestAnimationFrame(()=>f.status="dragging"),ee&&(Fr.observe(ee),Ie=ap(v,ee,F),Vn=lp(v,ee,x));const rn=(o=l.dragOperation.source)==null?void 0:o.id,es=()=>{var z;if(!ct||rn==null)return;const J=l.registry.draggables.get(rn),K=(z=J?.handle)!=null?z:J?.element;Tt(K)&&K.focus()},Yn=()=>{Ie?.disconnect(),Vn?.disconnect(),Fr.disconnect(),nn.removeEventListener("resize",Gn),qs(x)&&(x.removeEventListener("beforetoggle",_a),x.removeAttribute("popover")),x.removeAttribute(dt),O.reset();const z=()=>{var J;if(At&&Ks(v)){const ts=Array.from(v.cells);for(const[Ur,sn]of ts.entries())sn.style.width=(J=At[Ur])!=null?J:""}f.status="idle";const K=a.current.translate!=null,te=c.status.dragging;ee&&(!te&&K||ee.parentElement!==x.parentElement)&&x.isConnected&&ee.replaceWith(x),ee?.remove()};x===this.overlay?setTimeout(z,0):z()},Hr=u?.dropAnimation,qr=this,X=Dr(()=>{var z,J,K;const{transform:te,status:ts}=c;if(!(!te.x&&!te.y&&!a.current.translate)&&ts.dragging){const Ur=(z=p.translate)!=null?z:{x:0,y:0},sn={x:te.x/m.scaleX+Ur.x,y:te.y/m.scaleY+Ur.y},ba=a.current.translate,$u=q(()=>c.modifiers),ns=q(()=>{var Xn;return(Xn=c.shape)==null?void 0:Xn.current}),rs=u?.keyboardTransition,ya=ct&&!Ji&&rs!==null?`${(J=rs?.duration)!=null?J:250}ms ${(K=rs?.easing)!=null?K:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(O.set({transition:Ce?`${Ce}, translate ${ya}`:`translate ${ya}`,translate:`${sn.x}px ${sn.y}px 0`},Oe),Ie?.takeRecords(),ns&&ns!==It&&ba&&!$u.length){const Xn=Ze.delta(sn,ba);c.shape=ht.from(ns.boundingRectangle).translate(Xn.x*m.scaleX,Xn.y*m.scaleY)}else c.shape=new ut(x);a.current.translate=sn}},function(){if(c.status.dropped){this.dispose(),f.status="dropping";const z=g?.dropAnimation!==void 0?g.dropAnimation:qr.dropAnimation!==void 0?qr.dropAnimation:Hr;let J=a.current.translate;const K=J!=null;if(!J&&v!==x&&(J={x:0,y:0}),!J||z===null){Yn();return}l.renderer.rendering.then(()=>{hp({source:f,element:v,feedbackElement:x,placeholder:ee,translate:J,moved:K,transition:Y,alignment:f.alignment,styles:O,animation:z??void 0,getElementMutationObserver:()=>Ie,cleanup:Yn,restoreFocus:es})})}});return()=>{Yn(),X()}};rt(Cr,4,"overlay",xd,Tn,ia);tn(Cr,Tn);Tn.configure=Pr(Tn);var sa=Tn,Kn=!0,fp=!1,Sd,$d,jd,Cd,Ot,oa,aa;Cd=(jd=[U],Je.Forward),$d=(Sd=[U],Je.Reverse);var Or=class{constructor(){ge(this,oa,Se(Ot,8,this,Kn)),Se(Ot,11,this),ge(this,aa,Se(Ot,12,this,Kn)),Se(Ot,15,this)}isLocked(e){return e===Je.Idle?!1:e==null?this[Je.Forward]===Kn&&this[Je.Reverse]===Kn:this[e]===Kn}unlock(e){e!==Je.Idle&&(this[e]=fp)}};Ot=qn(null);oa=new WeakMap;aa=new WeakMap;rt(Ot,4,Cd,jd,Or,oa);rt(Ot,4,$d,Sd,Or,aa);tn(Ot,Or);var pp=[Je.Forward,Je.Reverse],Fa=class{constructor(){this.x=new Or,this.y=new Or}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},gp=class extends Pe{constructor(e){super(e);const t=An(new Fa);let n=null;this.signal=t,nt(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Fa;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:Ha(i.x,n.x),y:Ha(i.y,n.y)},o=t.peek();de(()=>{for(const a of tc)for(const l of pp)s[a]===l&&o[a].unlock(l);t.value=o})}n=i})}get current(){return this.signal.peek()}};function Ha(e,t){return Math.sign(e-t)}var Od,Qs,Mr,la,jt,Zs,Wr=class extends(Qs=Ar,Od=[U],Qs){constructor(e){super(e),ge(this,la,Se(Mr,8,this,!1)),Se(Mr,11,this),ge(this,jt),ge(this,Zs,()=>{if(!re(this,jt))return;const{element:s,by:o}=re(this,jt);o.y&&(s.scrollTop+=o.y),o.x&&(s.scrollLeft+=o.x)}),this.scroll=(s,o)=>{var a;if(this.disabled)return!1;const l=this.getScrollableElements();if(!l)return ze(this,jt,void 0),!1;const{position:u}=this.manager.dragOperation,c=u?.current;if(c){const{by:d}=s??{},f=d?{x:qa(d.x),y:qa(d.y)}:void 0,h=f?void 0:this.scrollIntentTracker.current;if(h?.isLocked())return!1;for(const v of l){const g=uf(v,d);if(g.x||g.y){const{speed:w,direction:y}=kf(v,c,f,o?.acceleration,o?.threshold);if(h)for(const p of tc)h[p].isLocked(y[p])&&(w[p]=0,y[p]=0);if(y.x||y.y){const{x:p,y:x}=d??y,m=p*w.x,k=x*w.y;if(m||k){const $=(a=re(this,jt))==null?void 0:a.by;if(this.autoScrolling&&$&&($.x&&!m||$.y&&!k))continue;return ze(this,jt,{element:v,by:{x:m,y:k}}),Oi.schedule(re(this,Zs)),!0}}}}}return ze(this,jt,void 0),!1};let t=null,n=null;const r=Os(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=Kc($i(o?.element),s.current);return a&&(t=a),a??t}),i=Os(()=>{const s=r.value,{documentElement:o}=Fn(s);if(!s||s===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const u=Us(l,{excludeElement:!1});return n=u,u}}if(s){const a=Us(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},st);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new gp(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!$r(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};Mr=qn(Qs);la=new WeakMap;jt=new WeakMap;Zs=new WeakMap;rt(Mr,4,"autoScrolling",Od,Wr,la);tn(Mr,Wr);function qa(e){return e>0?Je.Forward:e<0?Je.Reverse:Je.Idle}var mp=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},vp=new mp(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),bp=10,Js=class extends Pe{constructor(e,t){super(e,t);const n=e.registry.plugins.get(Wr);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=nt(()=>{var r,i,s;if(this.disabled)return;const{position:o,status:a}=e.dragOperation;if(a.dragging){const l={acceleration:(r=this.options)==null?void 0:r.acceleration,threshold:typeof((i=this.options)==null?void 0:i.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(s=this.options)==null?void 0:s.threshold};if(n.scroll(void 0,l)){n.autoScrolling=!0;const u=setInterval(()=>vp.schedule(()=>n.scroll(void 0,l)),bp);return()=>{clearInterval(u)}}else n.autoScrolling=!1}})}};Js.configure=Pr(Js);var Md=Js,Ua={capture:!0,passive:!0},ar,yp=class extends Ar{constructor(e){super(e),ge(this,ar),this.handleScroll=()=>{re(this,ar)==null&&ze(this,ar,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),ze(this,ar,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=nt(()=>{var n,r,i;if(t.status.dragging){const s=(i=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?i:document;return s.addEventListener("scroll",this.handleScroll,Ua),()=>{s.removeEventListener("scroll",this.handleScroll,Ua)}}})}};ar=new WeakMap;var xp="* { user-select: none !important; -webkit-user-select: none !important; }",wp=class extends Pe{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Yi),n=t?.register(xp);if(this.destroy=nt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return us(),document.addEventListener("selectionchange",us,{capture:!0}),()=>{document.removeEventListener("selectionchange",us,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function us(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var lr=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),gn,Pi=class extends Cn{constructor(e,t){super(e),this.manager=e,this.options=t,ge(this,gn,[]),this.listeners=new Bc,this.handleSourceKeyDown=(n,r,i)=>{if(this.disabled||n.defaultPrevented||!Yt(n.target)||r.disabled)return;const{keyboardCodes:s=lr.keyboardCodes,preventActivation:o=lr.preventActivation}=i??{};s.start.includes(n.code)&&this.manager.dragOperation.status.idle&&(o?.(n,r)||this.handleStart(n,r,i))}}bind(e,t=this.options){return nt(()=>{var n;const r=(n=e.handle)!=null?n:e.element,i=s=>{$r(s)&&this.handleSourceKeyDown(s,e,t)};if(r)return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}})}handleStart(e,t,n){const{element:r}=t;if(!r)throw new Error("Source draggable does not have an associated element");e.preventDefault(),e.stopImmediatePropagation(),rd(r);const{center:i}=new ut(r);if(this.manager.actions.start({event:e,coordinates:{x:i.x,y:i.y},source:t}).signal.aborted)return this.cleanup();this.sideEffects();const s=Fn(r),o=[this.listeners.bind(s,[{type:"keydown",listener:a=>this.handleKeyDown(a,t,n),options:{capture:!0}}])];re(this,gn).push(...o)}handleKeyDown(e,t,n){const{keyboardCodes:r=lr.keyboardCodes}=n??{};if(on(e,[...r.end,...r.cancel])){e.preventDefault();const i=on(e,r.cancel);this.handleEnd(e,i);return}on(e,r.up)?this.handleMove("up",e):on(e,r.down)&&this.handleMove("down",e),on(e,r.left)?this.handleMove("left",e):on(e,r.right)&&this.handleMove("right",e)}handleEnd(e,t){this.manager.actions.stop({event:e,canceled:t}),this.cleanup()}handleMove(e,t){var n,r;const{shape:i}=this.manager.dragOperation,s=t.shiftKey?5:1;let o={x:0,y:0},a=(r=(n=this.options)==null?void 0:n.offset)!=null?r:lr.offset;if(typeof a=="number"&&(a={x:a,y:a}),!!i){switch(e){case"up":o={x:0,y:-a.y*s};break;case"down":o={x:0,y:a.y*s};break;case"left":o={x:-a.x*s,y:0};break;case"right":o={x:a.x*s,y:0};break}(o.x||o.y)&&(t.preventDefault(),this.manager.actions.move({event:t,by:o}))}}sideEffects(){const e=this.manager.registry.plugins.get(Md);e?.disabled===!1&&(e.disable(),re(this,gn).push(()=>{e.enable()}))}cleanup(){re(this,gn).forEach(e=>e()),ze(this,gn,[])}destroy(){this.cleanup(),this.listeners.clear()}};gn=new WeakMap;Pi.configure=Pr(Pi);Pi.defaults=lr;var Ed=Pi;function on(e,t){return t.includes(e.code)}var Ht,kp=class extends Ac{constructor(){super(...arguments),ge(this,Ht)}onEvent(e){switch(e.type){case"pointerdown":ze(this,Ht,On(e));break;case"pointermove":if(!re(this,Ht))return;const{x:t,y:n}=On(e),r={x:t-re(this,Ht).x,y:n-re(this,Ht).y},{tolerance:i}=this.options;if(i&&Ws(r,i)){this.abort();return}Ws(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){ze(this,Ht,void 0)}};Ht=new WeakMap;var mn,qt,Sp=class extends Ac{constructor(){super(...arguments),ge(this,mn),ge(this,qt)}onEvent(e){switch(e.type){case"pointerdown":ze(this,qt,On(e)),ze(this,mn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!re(this,qt))return;const{x:t,y:n}=On(e),r={x:t-re(this,qt).x,y:n-re(this,qt).y};Ws(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){re(this,mn)&&(clearTimeout(re(this,mn)),ze(this,qt,void 0),ze(this,mn,void 0))}};mn=new WeakMap;qt=new WeakMap;var wn=class{};wn.Delay=Sp;wn.Distance=kp;var eo=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&Yt(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new wn.Delay({value:250,tolerance:5})]:Af(i)&&!e.defaultPrevented?[new wn.Delay({value:200,tolerance:0})]:[new wn.Delay({value:200,tolerance:10}),new wn.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!Yt(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=Jh(r);return i===t.element?!1:!!i}}),vn,Ai=class extends Cn{constructor(e,t){super(e),this.manager=e,this.options=t,ge(this,vn,new Set),this.listeners=new Bc,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:n,coordinates:r}=this.latest;!n||!r||this.manager.actions.move({event:n,to:r})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(e,t,n=this.options){const{activationConstraints:r=eo.activationConstraints}=n??{};return typeof r=="function"?r(e,t):r}bind(e,t=this.options){return nt(()=>{var n;const r=new AbortController,{signal:i}=r,s=a=>{Pf(a)&&this.handlePointerDown(a,e,t)};let o=[(n=e.handle)!=null?n:e.element];t?.activatorElements&&(Array.isArray(t.activatorElements)?o=t.activatorElements:o=t.activatorElements(e));for(const a of o)a&&(Cp(a.ownerDocument.defaultView),a.addEventListener("pointerdown",s,{signal:i}));return()=>r.abort()})}handlePointerDown(e,t,n){if(this.disabled||!e.isPrimary||e.button!==0||!Yt(e.target)||t.disabled||$p(e)||!this.manager.dragOperation.status.idle)return;const{preventActivation:r=eo.preventActivation}=n??{};if(r?.(e,t))return;const{target:i}=e,s=Tt(i)&&i.draggable&&i.getAttribute("draggable")==="true",o=En(t.element),{x:a,y:l}=On(e);this.initialCoordinates={x:a*o.scaleX+o.x,y:l*o.scaleY+o.y};const u=this.activationConstraints(e,t,n);e.sensor=this;const c=new Uh(u,v=>this.handleStart(t,v));c.signal.onabort=()=>this.handleCancel(e),c.onEvent(e),this.controller=c;const d=_s(),f=this.listeners.bind(d,[{type:"pointermove",listener:v=>this.handlePointerMove(v,t)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:s?this.handleCancel:Xr,options:{capture:!0}}]),h=()=>{f(),this.initialCoordinates=void 0};re(this,vn).add(h)}handlePointerMove(e,t){var n,r;if(((n=this.controller)==null?void 0:n.activated)===!1){(r=this.controller)==null||r.onEvent(e);return}if(this.manager.dragOperation.status.dragging){const i=On(e),s=En(t.element);i.x=i.x*s.scaleX+s.x,i.y=i.y*s.scaleY+s.y,e.preventDefault(),e.stopPropagation(),this.latest.event=e,this.latest.coordinates=i,Oi.schedule(this.handleMove)}}handlePointerUp(e){const{status:t}=this.manager.dragOperation;if(!t.idle){e.preventDefault(),e.stopPropagation();const n=!t.initialized;this.manager.actions.stop({event:e,canceled:n})}this.cleanup()}handleKeyDown(e){e.key==="Escape"&&(e.preventDefault(),this.handleCancel(e))}handleStart(e,t){const{manager:n,initialCoordinates:r}=this;if(!r||!n.dragOperation.status.idle||t.defaultPrevented)return;if(n.actions.start({coordinates:r,event:t,source:e}).signal.aborted)return this.cleanup();t.preventDefault();const i=Fn(t.target).body;try{i.setPointerCapture(t.pointerId)}catch{this.handleCancel(t);return}const s=Yt(t.target)?[t.target,i]:i,o=this.listeners.bind(s,[{type:"touchmove",listener:Xr,options:{passive:!1}},{type:"click",listener:Xr},{type:"contextmenu",listener:Xr},{type:"keydown",listener:this.handleKeyDown}]);re(this,vn).add(o)}handleCancel(e){const{dragOperation:t}=this.manager;t.status.initialized&&this.manager.actions.stop({event:e,canceled:!0}),this.cleanup()}cleanup(){const{controller:e}=this;this.controller=void 0,e&&!e.signal.aborted&&e.abort(),this.latest={event:void 0,coordinates:void 0},re(this,vn).forEach(t=>t()),re(this,vn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};vn=new WeakMap;Ai.configure=Pr(Ai);Ai.defaults=eo;var to=Ai;function $p(e){return"sensor"in e}function Xr(e){e.preventDefault()}function jp(){}var Va=new WeakSet;function Cp(e){!e||Va.has(e)||(e.addEventListener("touchmove",jp,{capture:!1,passive:!1}),Va.add(e))}var $n={modifiers:[],plugins:[Qf,Md,Jf,sa,wp],sensors:[to,Ed]},Dd=class extends Yh{constructor(e={}){const t=at(e.plugins,$n.plugins),n=at(e.sensors,$n.sensors),r=at(e.modifiers,$n.modifiers);super(ta(jr({},e),{plugins:[yp,Wr,Yi,...t],sensors:n,modifiers:r}))}},Td,Pd,no,Mt,ca,da,Xi=class extends(no=ft,Pd=[U],Td=[U],no){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=cd(n,["element","effects","handle"]);super(jr({effects:()=>[...i(),()=>{var a,l;const{manager:u}=this;if(!u)return;const c=((l=(a=this.sensors)==null?void 0:a.map(xr))!=null?l:[...u.sensors]).map(d=>{const f=d instanceof Cn?d:u.registry.register(d.plugin),h=d instanceof Cn?void 0:d.options;return f.bind(this,h)});return function(){c.forEach(d=>d())}}]},o),t),ge(this,ca,Se(Mt,8,this)),Se(Mt,11,this),ge(this,da,Se(Mt,12,this)),Se(Mt,15,this),this.element=r,this.handle=s}};Mt=qn(no);ca=new WeakMap;da=new WeakMap;rt(Mt,4,"handle",Pd,Xi,ca);rt(Mt,4,"element",Td,Xi,da);tn(Mt,Xi);var Ad,Id,ro,Et,ua,hs,Rd,Wd,yr,ha,Ki=class extends(ro=pt,Id=[U],Ad=[U],ro){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=cd(n,["element","effects"]);const{collisionDetector:o=sd}=s,a=u=>{const{manager:c,element:d}=this;if(!d||u===null){this.shape=void 0;return}if(!c)return;const f=new ut(d),h=q(()=>this.shape);return f&&h?.equals(f)?h:(this.shape=f,f)},l=An(!1);super(ta(jr({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:u,manager:c}=this;if(!c)return;const{dragOperation:d}=c,{source:f}=d;l.value=!!(f&&d.status.initialized&&u&&!this.disabled&&this.accepts(f))},()=>{const{element:u}=this;if(l.value&&u){const c=new df(u,a);return()=>{c.disconnect(),this.shape=void 0}}},()=>{var u;if((u=this.manager)!=null&&u.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),ge(this,yr),ge(this,ua,Se(Et,8,this)),Se(Et,11,this),ge(this,ha,Se(Et,12,this)),Se(Et,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){ze(this,yr,e,Wd)}get element(){var e;return(e=this.proxy)!=null?e:re(this,yr,Rd)}};Et=qn(ro);ua=new WeakMap;yr=new WeakSet;ha=new WeakMap;hs=rt(Et,20,"#element",Id,yr,ua),Rd=hs.get,Wd=hs.set;rt(Et,4,"proxy",Ad,Ki,ha);tn(Et,Ki);function Op(e){return e!=null&&typeof e=="object"&&"current"in e}function jn(e){var t;if(e!=null)return Op(e)?(t=e.current)!=null?t:void 0:e}var Mp=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Un=Mp?S.useLayoutEffect:S.useEffect;function Ep(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function zd(e,t){const n=S.useRef(new Map),r=Ep();return Un(()=>{if(!e){n.current.clear();return}return nt(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[l]=a,u=q(()=>a[1]),c=e[l];u!==c&&(s=!0,n.current.set(l,c),o=(i=t?.(l,u,c))!=null?i:!1)}s&&(o?queueMicrotask(()=>eh.flushSync(r)):r())})},[e]),S.useMemo(()=>e&&new Proxy(e,{get(i,s){const o=i[s];return n.current.set(s,o),o}}),[e])}function Dp(e,t){e()}function an(e){const t=S.useRef(e);return Un(()=>{t.current=e},[e]),t}function ae(e,t,n=S.useEffect,r=Object.is){const i=S.useRef(e);n(()=>{const s=i.current;r(e,s)||(i.current=e,t(e,s))},[t,e])}function gi(e,t){const n=S.useRef(jn(e));Un(()=>{const r=jn(e);r!==n.current&&(n.current=r,t(r))})}var Tp=Object.defineProperty,Pp=Object.defineProperties,Ap=Object.getOwnPropertyDescriptors,Ii=Object.getOwnPropertySymbols,Ld=Object.prototype.hasOwnProperty,Nd=Object.prototype.propertyIsEnumerable,Ga=(e,t,n)=>t in e?Tp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ip=(e,t)=>{for(var n in t||(t={}))Ld.call(t,n)&&Ga(e,n,t[n]);if(Ii)for(var n of Ii(t))Nd.call(t,n)&&Ga(e,n,t[n]);return e},Rp=(e,t)=>Pp(e,Ap(t)),Wp=(e,t)=>{var n={};for(var r in e)Ld.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ii)for(var r of Ii(e))t.indexOf(r)<0&&Nd.call(e,r)&&(n[r]=e[r]);return n},zp=new Dd,_d=S.createContext(zp),Lp=S.memo(S.forwardRef(({children:e},t)=>{const[n,r]=S.useState(0),i=S.useRef(null),s=S.useRef(null),o=S.useMemo(()=>({renderer:{get rendering(){var a;return(a=i.current)!=null?a:Promise.resolve()}},trackRendering(a){i.current||(i.current=new Promise(l=>{s.current=l})),S.startTransition(()=>{a(),r(l=>l+1)})}}),[]);return Un(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),fs=[void 0,st];function Np(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=Wp(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const c=S.useRef(null),{plugins:d,modifiers:f,sensors:h}=u,v=at(d,$n.plugins),g=at(h,$n.sensors),w=at(f,$n.modifiers),y=an(i),p=an(s),x=an(a),m=an(o),k=an(l),$=an(r),C=_p(()=>{var M;return(M=u.manager)!=null?M:new Dd(u)});return S.useEffect(()=>{if(!c.current)throw new Error("Renderer not found");const{renderer:M,trackRendering:T}=c.current,{monitor:P}=C;C.renderer=M;const G=[P.addEventListener("beforedragstart",R=>{const O=y.current;O&&T(()=>O(R,C))}),P.addEventListener("dragstart",R=>{var O;return(O=p.current)==null?void 0:O.call(p,R,C)}),P.addEventListener("dragover",R=>{const O=x.current;O&&T(()=>O(R,C))}),P.addEventListener("dragmove",R=>{const O=m.current;O&&T(()=>O(R,C))}),P.addEventListener("dragend",R=>{const O=k.current;O&&T(()=>O(R,C))}),P.addEventListener("collision",R=>{var O;return(O=$.current)==null?void 0:O.call($,R,C)})];return()=>G.forEach(R=>R())},[C]),ae(v,()=>C&&(C.plugins=v),...fs),ae(g,()=>C&&(C.sensors=g),...fs),ae(w,()=>C&&(C.modifiers=w),...fs),b.jsxs(_d.Provider,{value:C,children:[b.jsx(Lp,{ref:c,children:n}),n]})}function _p(e){const t=S.useRef(null);return t.current||(t.current=e()),S.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}function Fp(){return S.useContext(_d)}function Fd(e){var t;const n=(t=Fp())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Un(r.register,[n,r]),r}var Hp=Object.create,Hd=Object.defineProperty,qp=Object.getOwnPropertyDescriptor,qd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Bi=e=>{throw TypeError(e)},Up=(e,t,n)=>t in e?Hd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Vp=e=>{var t;return[,,,Hp((t=e?.[qd("metadata")])!=null?t:null)]},Ud=["class","method","getter","setter","accessor","field","value","get","set"],Vd=e=>e!==void 0&&typeof e!="function"?Bi("Function expected"):e,Gp=(e,t,n,r,i)=>({kind:Ud[e],name:t,metadata:r,addInitializer:s=>n._?Bi("Already initialized"):i.push(Vd(s||null))}),Yp=(e,t)=>Up(t,qd("metadata"),e[3]),Xp=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},Gd=(e,t,n,r,i,s)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,h=2,v=Ud[c+5],g=e[h]||(e[h]=[]),w=(i=i.prototype,qp(i,n)),y=r.length-1;y>=0;y--)l=Gp(c,n,a={},e[3],g),l.static=d,l.private=f,u=l.access={has:p=>n in p},u.get=p=>p[n],o=(0,r[y])(w[v],l),a._=1,Vd(o)&&(w[v]=o);return w&&Hd(i,n,w),i},Yd=(e,t,n)=>t.has(e)||Bi("Cannot "+n),Kp=(e,t,n)=>(Yd(e,t,"read from private field"),t.get(e)),Bp=(e,t,n)=>t.has(e)?Bi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Qp=(e,t,n,r)=>(Yd(e,t,"write to private field"),t.set(e,n),n),Vt=class io{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new io(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new io(t,n)}},Xd,Kd,so,mi,zr,fa=class extends(so=Jt,Kd=[fe],Xd=[fe],so){constructor(e){const t=Vt.from(e);super(t,(n,r)=>Vt.equals(n,r)),Xp(zr,5,this),Bp(this,mi,0),this.velocity={x:0,y:0}}get delta(){return Vt.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=Vt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Kp(this,mi),o=a=>Math.round(a/s*100);de(()=>{Qp(this,mi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Vt.from(e)),this.velocity={x:0,y:0}}};zr=Vp(so);mi=new WeakMap;Gd(zr,2,"delta",Kd,fa);Gd(zr,2,"direction",Xd,fa);Yp(zr,fa);var Bd=(e=>(e.Horizontal="x",e.Vertical="y",e))(Bd||{});Object.values(Bd);var Zp=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=Vt.distance(t.shape.center,n);return{id:r,value:1/i,type:_n.PointerIntersection,priority:Nn.High}}return null},Jp=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=Vt.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:o,type:_n.ShapeIntersection,priority:Nn.Normal}}return null},eg=e=>{var t;return(t=Zp(e))!=null?t:Jp(e)};function tg(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,l=Fd(c=>new Ki(Rp(Ip({},e),{register:!1,element:jn(i)}),c)),u=zd(l);return ae(s,()=>l.id=s),gi(i,c=>l.element=c),ae(o,()=>l.accept=o,void 0,st),ae(t,()=>l.collisionDetector=t??eg),ae(n,()=>n&&(l.data=n)),ae(r,()=>l.disabled=r===!0),ae(a,()=>l.type=a),{droppable:u,get isDropTarget(){return u.isDropTarget},ref:S.useCallback(c=>{var d,f;!c&&(d=l.element)!=null&&d.isConnected&&!((f=l.manager)!=null&&f.dragOperation.status.idle)||(l.element=c??void 0)},[l])}}function ng(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of s.filters??[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],i=new Set;for(const s of e.localGivens??[])i.add(s.name),r.push({name:s.name,...s.label===void 0?{}:{label:s.label},type:s.type,...s.suggest?{field:s.suggest.dimension}:{},origin:"dashboard",local:s,boundTiles:n.get(s.name)??0});for(const s of t)i.has(s.name)||(i.add(s.name),r.push({...s,origin:"model",boundTiles:n.get(s.name)??0}));for(const[s,o]of n)i.has(s)||r.push({name:s,origin:"model",boundTiles:o});return r}function Ri(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function rg(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function vi(e,t){const n=rg(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const i=new Set(["date","timestamp"]);return i.has(n)?i.has(r):n===r}function Ya(e){switch(e?.replace(/_type$/,"")){case"string":return"text";case"number":return"a number";case"date":return"a date";case"timestamp":return"a timestamp";case"boolean":return"true or false";default:return e??"an unknown type"}}function ig(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const sg=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function og(e,t){const n=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",r=/^[A-Z_]/.test(n)?n:`F_${n}`,i=new Set(t);if(!i.has(r))return r;for(let s=2;;s++)if(!i.has(`${r}_${s}`))return`${r}_${s}`}const Xa=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"Since a date",hint:"A date picker; tiles keep rows on or after it"}];function Kr(e){const t=e.label.trim()||e.name,n=e.field.split(".").at(-1)??e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const oo=e=>e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function ag(e,t){return e.tiles.map(n=>{const r=(n.filters??[]).find(i=>i.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:Ri(t.type)!==void 0?{op:Ri(t.type)}:{}}})}function lg(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!oo(s))return;const o=(s.filters??[]).filter(l=>l.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function cg(e,t){const n=(e.localGivens??[]).filter(s=>s.name!==t.name),r=(e.localGivens??[]).findIndex(s=>s.name===t.name),i=[...n];i.splice(r>=0?r:i.length,0,t),e.localGivens=i}function dg(e,t){for(const r of e.tiles){const i=(r.filters??[]).filter(s=>s.given!==t);i.length>0?r.filters=i:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const ug=Qt(b.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),hg=Qt(b.jsx("path",{d:"m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z"})),fg=Qt(b.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),pg=Qt(b.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),ao=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),ps=ao?"⌘":"Ctrl+",gg=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function mg(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=ao?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!gg(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!ao&&s&&o==="y"){r.preventDefault(),i.redo();return}if(s&&o==="s"){r.preventDefault(),i.save?.();return}!s&&!r.altKey&&!r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight")&&(r.preventDefault(),i.nudge(r.key==="ArrowRight"?1:-1))}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[])}function vg({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,actions:a,onAddTile:l,onSettings:u}){const{theme:c}=tt();return b.jsxs(jl,{left:b.jsx(mo,{size:"medium",variant:"outlined",icon:b.jsx(hg,{sx:{fontSize:20}}),label:"Editing",sx:{height:37,fontSize:"0.875rem",fontWeight:500,border:c.border,color:c.tileTitle,"& .MuiChip-icon":{color:"inherit"},"& .MuiChip-label":{fontSize:"0.875rem"}}}),children:[l&&b.jsx(ke,{startIcon:b.jsx(Ml,{}),onClick:l,"aria-label":"Add tile",children:"Tile"}),b.jsx(ke,{startIcon:b.jsx(ug,{}),onClick:d=>u(d.currentTarget),children:"Settings"}),b.jsx(ks,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),b.jsx(kn,{title:`Undo (${ps}Z)`,children:b.jsx("span",{children:b.jsx(Ss,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:b.jsx(pg,{fontSize:"small"})})})}),b.jsx(kn,{title:`Redo (${ps}⇧Z)`,children:b.jsx("span",{children:b.jsx(Ss,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:b.jsx(fg,{fontSize:"small"})})})}),o&&b.jsx(b.Fragment,{children:b.jsx(kn,{title:i?`Save (${ps}S)`:"",children:b.jsx("span",{children:b.jsx(ke,{variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{minWidth:124},children:s?"Saving…":i?"Save changes":"Saved"})})})}),a&&b.jsxs(b.Fragment,{children:[b.jsx(ks,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const bg=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"];function Br(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function Ka(e){for(const t of e??[]){const n=/^#\s*([a-z_]+)/.exec(t.trim())?.[1];if(n&&bg.includes(n))return n}}const yg=1;function Qd(e,t,n){const r=[];for(const i of e??[]){const s=i.name,o=i.kind;if(typeof s=="string"){if(o==="dimension"||o==="measure"){const a=i.type?.kind;r.push({name:t+s,kind:o,...a?{type:a}:{}})}else if(o==="join"&&n>0){const a=i.schema?.fields;r.push(...Qd(a,`${t}${s}.`,n-1))}}}return r}function xg(e){const t=new Map;for(const n of e.sourceInfos??[]){let r;try{r=typeof n=="string"?JSON.parse(n):n}catch{continue}const i=r;i?.name&&t.set(i.name,Qd(i.schema?.fields,"",yg))}return t}function Ba(e,t){return!e||t===void 0?void 0:e.sources.find(n=>n.name===t)?.fields.filter(n=>n.kind==="dimension")}const wg=e=>(e??"").startsWith("dashboards/"),Zd=e=>e.modelPath??e.path??"";function kg(e){const t=[],n=new Set;for(const r of e){const i=Zd(r);if(wg(i))continue;const s=xg(r);for(const o of r.sources??[]){const a=o.name;if(!a||n.has(a))continue;n.add(a);const l=(o.givens??[]).map(u=>u.name).filter(u=>typeof u=="string");t.push({name:a,modelPath:i,...Br(o.annotations)?{description:Br(o.annotations)}:{},views:(o.views??[]).filter(u=>typeof u.name=="string").map(u=>({name:u.name,...Br(u.annotations)?{description:Br(u.annotations)}:{},...Ka(u.annotations)?{chart:Ka(u.annotations)}:{}})),givens:l,fields:s.get(a)??[]})}}return{sources:t}}function Sg(e,t,n){const r=new Set;for(const i of t){if(i.kind==="names"){for(const o of i.names)r.add(o);continue}const s=n.find(o=>Zd(o)===i.path);if(!s)return e;for(const o of s.sources??[])o.name&&r.add(o.name)}return{...e,sources:e.sources.filter(i=>r.has(i.name))}}const mt=e=>`${e.source}.${e.name}`;function $g(e,t){if(!t)return[];const n=new Set;for(const r of e.sources)n.add(r.base);for(const r of e.imports)if(r.kind==="names")for(const i of r.names)n.add(i);return t.sources.filter(r=>n.has(r.name))}function jg({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=tt(),a=S.useMemo(()=>$g(t,n),[t,n]),[l,u]=S.useState(""),[c,d]=S.useState(""),[f,h]=S.useState(""),[v,g]=S.useState(Math.ceil(r/2));S.useEffect(()=>{e&&(u(t.sources[0]?.base??a[0]?.name??""),d(""),h(""),g(Math.ceil(r/2)))},[e,t,a,r]);const w=a.find(y=>y.name===l);return b.jsx(Ni,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of one source this dashboard imports.",actions:b.jsxs(b.Fragment,{children:[b.jsx(ke,{onClick:i,children:"Cancel"}),b.jsx(ke,{variant:"contained",disabled:!(l!==""&&c!==""),onClick:()=>s({base:l,view:c,...f.trim()?{label:f.trim()}:{},colspan:v}),children:"Add tile"})]}),children:b.jsx(he,{sx:{gap:2,pt:1},children:a.length===0?b.jsx(ne,{variant:"body2",sx:{color:o.tileTitle},children:n?"This dashboard imports no source by name, so there is nothing to put a tile on. Import a source in the file first.":"The package's sources are still loading."}):b.jsxs(b.Fragment,{children:[b.jsx(Te,{select:!0,size:"small",label:"Source",value:l,onChange:y=>{u(y.target.value),d("")},inputProps:{"aria-label":"Source"},children:a.map(y=>b.jsxs(bt,{value:y.name,children:[y.name,y.description&&b.jsx(ne,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:y.description})]},y.name))}),b.jsxs(pe,{children:[b.jsx(ne,{variant:"subtitle2",sx:{mb:.5},children:"View"}),b.jsxs(Nu,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(y=>b.jsxs(_u,{selected:c===y.name,onClick:()=>d(y.name),"aria-label":`View ${y.name}`,children:[b.jsx(Dl,{primary:y.name,secondary:y.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),y.chart&&b.jsx(mo,{size:"small",variant:"outlined",label:y.chart.replace(/_chart$/,"")})]},y.name)),w&&w.views.length===0&&b.jsx(ne,{variant:"body2",sx:{p:1.5,color:o.tileTitle},children:"This source declares no views."})]})]}),b.jsxs(he,{direction:"row",sx:{gap:1.5},children:[b.jsx(Te,{size:"small",label:"Title",placeholder:"Uses the view's name",value:f,onChange:y=>h(y.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}}),b.jsx(Te,{size:"small",type:"number",label:`Width (of ${r})`,value:v,onChange:y=>g(Math.min(Math.max(Number(y.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})})})}const Qa=4e3;function Cg(e,t){const n=e.split(`
69
- `),r=t.split(`
70
- `);if(n.length>Qa||r.length>Qa)return[...n.map(l=>({kind:"del",text:l})),...r.map(l=>({kind:"add",text:l}))];const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let l=n.length-1;l>=0;l--)for(let u=r.length-1;u>=0;u--)i[l][u]=n[l]===r[u]?i[l+1][u+1]+1:Math.max(i[l+1][u],i[l][u+1]);const s=[];let o=0,a=0;for(;o<n.length&&a<r.length;)n[o]===r[a]?(s.push({kind:"same",text:n[o]}),o++,a++):i[o+1][a]>=i[o][a+1]?s.push({kind:"del",text:n[o++]}):s.push({kind:"add",text:r[a++]});for(;o<n.length;)s.push({kind:"del",text:n[o++]});for(;a<r.length;)s.push({kind:"add",text:r[a++]});return s}function Og(e,t=3){const n=new Array(e.length).fill(!1);e.forEach((s,o)=>{if(s.kind!=="same")for(let a=Math.max(0,o-t);a<=Math.min(e.length-1,o+t);a++)n[a]=!0});const r=[];let i=0;return e.forEach((s,o)=>{n[o]?(i>0&&r.push({kind:"fold",count:i}),i=0,r.push(s)):i++}),i>0&&r.push({kind:"fold",count:i}),r}function Mg({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=tt(),o=S.useMemo(()=>e?Og(Cg(t,n)):[],[e,t,n]),a=o.filter(u=>u.kind==="add").length,l=o.filter(u=>u.kind==="del").length;return b.jsx(Ni,{open:e,onClose:i,maxWidth:"md",title:"Review the change to the file",description:b.jsxs(b.Fragment,{children:["A tile was added or removed, which moves declarations. Lines the builder does not own — comments, other Malloy — are left where they were; check they still read right."," ",b.jsxs(pe,{component:"span",sx:{fontVariantNumeric:"tabular-nums"},children:["+",a," −",l]})]}),actions:b.jsxs(b.Fragment,{children:[b.jsx(ke,{onClick:i,children:"Keep editing"}),b.jsx(ke,{variant:"contained",onClick:r,children:"Save this"})]}),children:b.jsx(pe,{component:"pre","aria-label":"File changes",sx:{m:0,px:2,py:1,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,lineHeight:1.6,overflowX:"auto",bgcolor:s.background,color:s.foreground},children:o.map((u,c)=>u.kind==="fold"?b.jsx(pe,{component:"span",sx:{display:"block",opacity:.55,py:.25},children:`⋯ ${u.count} unchanged line${u.count===1?"":"s"}`},c):b.jsxs(pe,{component:"span",sx:{display:"block",mx:-2,px:2,whiteSpace:"pre",bgcolor:u.kind==="add"?"rgba(46, 125, 91, 0.16)":u.kind==="del"?"rgba(168, 41, 31, 0.14)":"transparent",textDecoration:u.kind==="del"?"line-through":"none",opacity:u.kind==="del"?.8:1},children:[u.kind==="add"?"+ ":u.kind==="del"?"− ":" ",u.text]},c))})})}const gs="self";function Eg({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=tt(),[l,u]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(v=>v.source===n.name);u((n.dimensions??[]).map(v=>{const g=h.find(w=>w.name===v.name);return{name:v.name,expression:v.expression,to:g?.to??[],given:g?.given??""}}))},[e,n,t]);const c=(h,v)=>u(g=>g.map((w,y)=>{if(y!==h)return w;const p={...w};return v(p),p})),d=[gs,...i.filter(h=>h!==gs)],f=h=>h===gs?"This dashboard":h;return b.jsx(Ni,{open:e,onClose:s,title:"Clickable cells",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:b.jsxs(b.Fragment,{children:[b.jsx(ke,{onClick:s,children:"Cancel"}),b.jsx(ke,{variant:"contained",onClick:()=>{n&&(o(l.filter(h=>h.to.length>0).map(h=>({source:n.name,name:h.name,expression:h.expression,to:h.to,...h.given?{given:h.given}:{}}))),s())},disabled:l.length===0,children:"Apply"})]}),children:b.jsx(he,{sx:{gap:2,pt:1},children:l.length===0?b.jsx(ne,{variant:"body2",sx:{color:a.tileTitle},children:n?b.jsxs(b.Fragment,{children:[b.jsx(pe,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",b.jsx(pe,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((h,v)=>b.jsxs(pe,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[b.jsxs(pe,{sx:{minWidth:0,pt:.75},children:[b.jsx(ne,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:h.name}),b.jsxs(ne,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:h.expression,children:["is ",h.expression]})]}),b.jsx(Te,{select:!0,size:"small",label:"Clicks go to",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:g=>g.length===0?"Not clickable":g.map(f).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:g=>c(v,w=>{const y=g.target.value;w.to=Array.isArray(y)?y:String(y).split(",").filter(Boolean)}),children:d.map(g=>b.jsxs(bt,{value:g,children:[b.jsx($s,{size:"small",checked:h.to.includes(g),sx:{p:0,mr:1}}),b.jsx(Dl,{primary:f(g)})]},g))}),b.jsxs(Te,{select:!0,size:"small",label:"Sets the control",value:h.given,disabled:h.to.length===0,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:h.given===""?`Named ${h.name}, like the dimension`:void 0,onChange:g=>c(v,w=>{w.given=g.target.value}),children:[b.jsx(bt,{value:"",children:b.jsx("em",{children:"Same name as the dimension"})}),r.map(g=>b.jsx(bt,{value:g,children:g},g))]})]},h.name))})})}const Jd=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function Dg({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:s}){const o=S.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[u,c]=S.useState({kind:"new"}),[d,f]=S.useState(""),[h,v]=S.useState("select"),[g,w]=S.useState(""),[y,p]=S.useState(""),[x,m]=S.useState([]),[k,$]=S.useState(!1),C=E=>t.sources.find(A=>A.name===E.source)?.base??E.source;S.useEffect(()=>{if(e)if(n){c({kind:"existing",name:n.name}),f(n.label??"");const E=ag(t,n);m(E);const A=E.filter(j=>j.include),H=new Set(A.map(j=>j.field));p(H.size===1?A[0].field:n.field??""),$(H.size>1)}else c({kind:"new"}),f(""),v("select"),p(""),w(new Date().toISOString().slice(0,10)),m(t.tiles.map(E=>({include:oo(E),field:""}))),$(!1)},[e,n,t]);const M=S.useMemo(()=>[...(t.localGivens??[]).map(E=>E.name),...r.map(E=>E.name)],[t,r]),T=S.useMemo(()=>y.trim()?og(y.trim(),M):"",[y,M]),P=u.kind==="existing"?n??r.find(E=>E.name===u.name):T?{name:T,type:Kr({name:T,label:d,kind:h,field:y}).type}:void 0,G=P?.type!==void 0&&!P.type.startsWith("filter<"),R=x.find(E=>E.include)?.op??Ri(P?.type),O=(E,A)=>m(H=>H.map((j,D)=>D===E?{...j,...A}:j)),_=E=>m(A=>A.map(H=>({...H,op:E}))),Y=E=>{const A=Ri(E);m(H=>H.map(({op:j,...D})=>A?{...D,op:A}:D))},me=E=>{c({kind:"existing",name:E.name}),p(E.field??""),Y(E.type)},Ae=E=>{v(E),Y(Kr({name:"X",label:d,kind:E,field:y}).type)},oe=t.tiles.map(oo),Ne=oe.filter(Boolean).length,Ue=x.filter((E,A)=>E.include&&oe[A]).length,Ee=t.tiles.filter((E,A)=>(x[A]?.include??!1)&&oe[A]),Ke=Ee.length>0?Ee:t.tiles.filter((E,A)=>oe[A]),Ve=S.useMemo(()=>{const E=new Map;let A=!1;for(const H of Ke){const j=i?.(H);if(j){A=!0;for(const D of j)E.has(D.name)||E.set(D.name,D)}}return A?[...E.values()]:void 0},[x,t.tiles,i]),_e=(()=>{const E=y.trim();for(const A of Ee){const H=i?.(A);if(!H||H.some(j=>j.name===E))return C(A)}return Ee[0]?C(Ee[0]):t.sources[0]?.base})(),Be=E=>m(A=>A.map((H,j)=>({...H,include:E&&oe[j]}))),Ce=S.useMemo(()=>k?x:x.map(E=>({...E,field:y})),[k,x,y]),xe=E=>{for(const A of Ke){const H=i?.(A)?.find(j=>j.name===E.trim());if(H?.type)return H.type}},I=E=>vi(P?.type,E.type),F=(E,A)=>{if(E.trim()==="")return"Pick the field this filter compares.";const H=A?i?.(A):void 0;if(!H)return;const j=H.find(D=>D.name===E.trim());if(!j)return`Not a field of ${A?C(A):"the tiles' source"}.`;if(j.type&&!vi(P?.type,j.type))return`${E.trim()} is ${Ya(j.type)}; this filter compares ${Ya(P?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},$e=E=>{if(p(E),l||u.kind!=="new")return;const A=xe(E),H=Kr({name:"X",label:d,kind:h,field:E}).type;A&&!vi(H,A)&&Ae(ig(A))},B=Ce.map((E,A)=>E.include&&oe[A]?F(E.field,t.tiles[A]):void 0),Fe=B.every(E=>E===void 0),ee=!k&&Ue>0?Ee.map(E=>F(y,E)).find(Boolean):void 0,ct=P!==void 0&&Fe&&(u.kind==="existing"||y.trim()!==""&&T!==""),He=()=>{if(!(!P||!ct))if(u.kind==="new")s(P.name,Ce,Kr({name:P.name,label:d.trim()||Jd(P.name),kind:h,field:y.trim(),..._e?{source:_e}:{},...g?{dateDefault:g}:{}}));else if(n?.origin==="dashboard"&&n.local){const E=d.trim(),A=E!==(n.local.label??"");s(P.name,Ce,A?{...n.local,...E?{label:E}:{}}:void 0)}else s(P.name,Ce)},St=l&&a.origin==="model";return{editing:l,shown:a,fromModel:St,source:u,setSource:c,label:d,setLabel:f,kind:h,dateDefault:g,setDateDefault:w,field:y,rows:x,setRows:m,perTile:k,setPerTile:$,newName:T,target:P,valueTyped:G,commonOp:R,setRow:O,setCommonOp:_,pickExisting:me,pickKind:Ae,bindable:oe,bindableCount:Ne,included:Ue,commonFields:Ve,setAll:Be,accepts:I,pickField:$e,rowProblems:B,commonProblem:ee,canApply:ct,apply:He}}function Za({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:l,autoFocus:u,placeholder:c,sx:d}){const f=S.useMemo(()=>(n??[]).filter(v=>r?.(v)??!0).map(v=>v.name),[n,r]),h=S.useMemo(()=>new Map((n??[]).map(v=>[v.name,v.type])),[n]);return b.jsx(Zu,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(v,g)=>t(g),value:e,onChange:(v,g)=>t(typeof g=="string"?g:""),disabled:l,disableClearable:!0,renderOption:(v,g)=>S.createElement("li",{...v,key:g},b.jsx(ne,{variant:"body2",sx:{flex:1},children:g}),h.get(g)&&b.jsx(ne,{variant:"caption",sx:{opacity:.6},children:h.get(g)?.replace(/_type$/,"")})),renderInput:v=>b.jsx(Te,{...v,label:i,placeholder:c,autoFocus:u,error:o,helperText:a,inputProps:{...v.inputProps,"aria-label":s}}),sx:d})}const Ja=e=>e?.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this dashboard does not write."};function Tg({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:l}=tt(),{editing:u,shown:c,fromModel:d,source:f,setSource:h,label:v,setLabel:g,kind:w,dateDefault:y,setDateDefault:p,field:x,rows:m,setRows:k,perTile:$,setPerTile:C,newName:M,target:T,valueTyped:P,commonOp:G,setRow:R,setCommonOp:O,pickExisting:_,pickKind:Y,bindable:me,bindableCount:Ae,included:oe,commonFields:Ne,setAll:Ue,accepts:Ee,pickField:Ke,rowProblems:Ve,commonProblem:_e,canApply:Be,apply:Ce}=Dg({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),xe=(I,F,$e)=>b.jsx(Te,{select:!0,size:"small",label:"Compares",value:I??">=",onChange:B=>F(B.target.value),inputProps:{"aria-label":$e},sx:{width:130},children:sg.filter(B=>B.op!=="~").map(B=>b.jsx(bt,{value:B.op,children:B.label},B.op))});return b.jsx(Ni,{open:e,onClose:s,title:u?c.label??c.name:"Add a filter",description:u?b.jsxs(b.Fragment,{children:[b.jsxs(pe,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",c.name]}),d?" · declared in the model, so its label and options are set there":" · declared in this dashboard"]}):"A control on the page, and the tiles it filters.",actions:b.jsxs(b.Fragment,{children:[u&&b.jsx(ke,{color:"error",onClick:()=>a(c.name),"aria-label":`Remove control ${c.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),b.jsx(ke,{onClick:s,children:"Cancel"}),b.jsx(kn,{title:Be||T===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:b.jsx("span",{children:b.jsx(ke,{variant:"contained",onClick:Ce,disabled:!Be,children:u?"Apply":"Add filter"})})})]}),children:b.jsxs(he,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&b.jsxs(th,{exclusive:!0,size:"small",value:f.kind,onChange:(I,F)=>{F==="new"?h({kind:"new"}):F==="existing"&&r[0]&&_(r[0])},"aria-label":"Where the filter comes from",children:[b.jsx(wa,{value:"new",children:"New in this dashboard"}),b.jsx(wa,{value:"existing",children:"From the model"})]}),!u&&f.kind==="existing"?b.jsx(Te,{select:!0,size:"small",label:"Control",value:f.name,onChange:I=>{const F=r.find($e=>$e.name===I.target.value);F&&_(F)},children:r.map(I=>b.jsxs(bt,{value:I.name,children:[I.label??I.name,b.jsxs(ne,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",I.name]})]},I.name))}):null,b.jsxs(he,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!$&&b.jsx(Za,{value:x,onChange:Ke,fields:Ne,accepts:Ee,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:_e!==void 0,helperText:_e??(!u&&M?`Declared as $${M}`:void 0),sx:{flex:1,minWidth:200}}),!d&&b.jsx(Te,{size:"small",label:"Label",placeholder:M?Jd(M):"",value:v,onChange:I=>g(I.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),P&&!$&&xe(G,O,"Comparison")]}),!u&&f.kind==="new"&&b.jsxs(he,{direction:"row",sx:{gap:1.5},children:[b.jsx(Te,{select:!0,size:"small",label:"Control",value:w,onChange:I=>Y(I.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:I=>Xa.find(F=>F.kind===I)?.label??String(I)}},sx:{flex:1},children:Xa.map(I=>b.jsxs(bt,{value:I.kind,children:[I.label,b.jsx(ne,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:I.hint})]},I.kind))}),w==="date"&&b.jsx(Te,{size:"small",type:"date",label:"Starts at",value:y,onChange:I=>p(I.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),b.jsxs(pe,{children:[b.jsxs(he,{direction:"row",sx:{alignItems:"center",gap:.5},children:[b.jsx($s,{size:"small",checked:Ae>0&&oe===Ae,indeterminate:oe>0&&oe<Ae,disabled:Ae===0,onChange:I=>Ue(I.target.checked),inputProps:{"aria-label":"All tiles"}}),b.jsxs(ne,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",oe," of ",t.tiles.length," tiles"]}),b.jsx(ke,{size:"small",onClick:()=>{$||k(I=>I.map(F=>({...F,field:x}))),C(I=>!I)},children:$?"Same field for all":"Adjust per tile"})]}),b.jsx(he,{sx:{gap:$?1:0},children:t.tiles.map((I,F)=>{const $e=m[F],B=I.label??I.name,Fe=$?Ve[F]:void 0;return b.jsxs(he,{direction:"row",sx:{gap:1,alignItems:$?"flex-start":"center",opacity:me[F]?1:.6},children:[b.jsx($s,{size:"small",disabled:!me[F],checked:($e?.include??!1)&&me[F],inputProps:{"aria-label":`Filter ${B}`},onChange:ee=>R(F,{include:ee.target.checked})}),b.jsx(ne,{variant:"body2",sx:{flex:1,minWidth:0,pt:$?1:0},noWrap:!0,children:B}),me[F]?$&&b.jsxs(b.Fragment,{children:[P&&xe($e?.op,ee=>R(F,{op:ee}),`Comparison for ${B}`),b.jsx(Za,{value:$e?.field??"",onChange:ee=>R(F,{field:ee}),fields:i?.(I),accepts:Ee,label:"Field",ariaLabel:`Field for ${B}`,disabled:!$e?.include,error:Fe!==void 0,helperText:Fe,sx:{width:220}})]}):b.jsx(kn,{title:Ja(t.tiles[F]).reason,children:b.jsx(ne,{variant:"caption",sx:{color:l.tileTitle},children:Ja(t.tiles[F]).label})})]},`${I.source}.${I.name}`)})}),oe===0&&b.jsx(ne,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}function eu(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:o=>s(a=>{if(a===void 0)return a;const l=structuredClone(a);return o(l),l}),close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const Pg=e=>({title:e.title,...e.description===void 0?{}:{description:e.description},...e.columns===void 0?{}:{columns:e.columns},...e.autorun===void 0?{}:{autorun:e.autorun}}),ms=[2,3,4,6,8,12,16,24];function Ag({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=tt(),{draft:s,patch:o,close:a}=eu(t,e!==null,r,n),l=s?.columns!==void 0&&!ms.includes(s.columns)?[...ms,s.columns].sort((u,c)=>u-c):ms;return b.jsx(El,{open:e!==null&&s!==void 0,anchorEl:e,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:380,p:2}}},children:s&&b.jsxs(he,{sx:{gap:1.5},children:[b.jsx(ne,{variant:"overline",sx:{color:i.tileTitle,lineHeight:1.5},children:"Dashboard"}),b.jsx(Te,{size:"small",label:"Title",value:s.title,autoFocus:!0,inputProps:{"aria-label":"Dashboard title"},onChange:u=>o(c=>{c.title=u.target.value})}),b.jsx(Te,{size:"small",label:"Description",multiline:!0,minRows:3,maxRows:10,value:s.description??"",helperText:"Markdown. A blank line starts a new paragraph.",inputProps:{"aria-label":"Dashboard description"},onChange:u=>o(c=>{const d=u.target.value;d.trim()===""?delete c.description:c.description=d})}),b.jsxs(Te,{select:!0,size:"small",label:"Grid width",value:s.columns??"",helperText:"Columns across the page. Tiles are placed in these.",inputProps:{"aria-label":"Grid width"},onChange:u=>o(c=>{const d=Number(u.target.value);d?c.columns=d:delete c.columns}),children:[b.jsx(bt,{value:"",children:"Default (2)"}),l.map(u=>b.jsx(bt,{value:u,children:u},u))]}),b.jsx(zu,{control:b.jsx(Lu,{size:"small",checked:s.autorun!==!1,slotProps:{input:{"aria-label":"Run as controls change"}},onChange:u=>o(c=>{u.target.checked?delete c.autorun:c.autorun=!1})}),label:b.jsxs(ne,{variant:"body2",children:["Run as controls change",b.jsx(ne,{component:"span",variant:"caption",sx:{display:"block",opacity:.7},children:"Off, readers press Apply. For a page whose queries are slow."})]})})]})})}const Ig=Qt(b.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function Rg({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:i,children:s}){const{theme:o}=tt();return b.jsx(b.Fragment,{children:b.jsxs(he,{sx:{gap:1},children:[b.jsxs(he,{direction:"row","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",minHeight:32},children:[b.jsx(Ig,{sx:{fontSize:18,color:o.tileTitle,opacity:.7}}),b.jsx(ne,{variant:"subtitle2",sx:{color:o.tileTitle,mr:.5},children:"Filters"}),e.length===0&&b.jsx(ne,{variant:"body2",sx:{color:o.tileTitle,opacity:.8},children:"None yet."}),e.map(a=>{const l=n(a.name,a.type);return b.jsx(kn,{title:l.length>0?`$${a.name} · cannot filter on: ${l.join(", ")}`:`$${a.name} · ${a.origin==="dashboard"?"declared here":"from the model"} · ${a.boundTiles} of ${t} tiles`,children:b.jsx(mo,{size:"small",label:a.label??a.name,"aria-label":`Edit filter ${a.name}`,color:l.length>0?"warning":"default",variant:a.origin==="dashboard"?"filled":"outlined",onClick:()=>r(a),sx:{opacity:a.boundTiles===0?.6:1,cursor:"pointer",transition:"opacity 120ms"}})},a.name)}),b.jsx(pe,{sx:{ml:"auto"},children:b.jsx(Cl,{label:"Filter",icon:b.jsx(Ml,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const Wg=(e,t)=>e.map((n,r)=>{const i=t[r]??!1;if(i===(n.break??!1))return n;const s={...n};return i?s.break=!0:delete s.break,s}),zg=(e,t,n)=>{const r=[...e],[i]=r.splice(t,1);if(!i)return[...e];const s=r[t];i.break&&s&&!s.break&&(r[t]={...s,break:!0});const o={...i};return delete o.break,r.splice(n,0,o),r},tu=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),nu=e=>`gap.${e}`,Lg=(e,t)=>{const n=[];let r=0;e.forEach((s,o)=>{const a=Math.min(s.colspan??1,t),l=o===0||s.break===!0||r+a>t;l&&o>0&&r<t&&n.push({kind:"gap",after:mt(e[o-1]),colspan:t-r}),l&&(r=0),n.push(tu(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:mt(i),colspan:t-r}),n};var Ng=Object.create,ru=Object.defineProperty,_g=Object.defineProperties,Fg=Object.getOwnPropertyDescriptor,Hg=Object.getOwnPropertyDescriptors,Wi=Object.getOwnPropertySymbols,iu=Object.prototype.hasOwnProperty,su=Object.prototype.propertyIsEnumerable,qg=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Lr=e=>{throw TypeError(e)},lo=(e,t,n)=>t in e?ru(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vs=(e,t)=>{for(var n in t||(t={}))iu.call(t,n)&&lo(e,n,t[n]);if(Wi)for(var n of Wi(t))su.call(t,n)&&lo(e,n,t[n]);return e},bs=(e,t)=>_g(e,Hg(t)),Ug=(e,t)=>{var n={};for(var r in e)iu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Wi)for(var r of Wi(e))t.indexOf(r)<0&&su.call(e,r)&&(n[r]=e[r]);return n},Vg=e=>{var t;return[,,,Ng((t=void 0)!=null?t:null)]},ou=["class","method","getter","setter","accessor","field","value","get","set"],cr=e=>e!==void 0&&typeof e!="function"?Lr("Function expected"):e,Gg=(e,t,n,r,i)=>({kind:ou[e],name:t,metadata:r,addInitializer:s=>n._?Lr("Already initialized"):i.push(cr(s||null))}),Yg=(e,t)=>lo(t,qg("metadata"),e[3]),Qr=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},au=(e,t,n,r,i,s)=>{for(var o,a,l,u,c,d=t&7,f=!1,h=!1,v=e.length+1,g=ou[d+5],w=e[v-1]=[],y=e[v]||(e[v]=[]),p=(i=i.prototype,Fg({get[n](){return dr(this,s)},set[n](m){return Ut(this,s,m)}},n)),x=r.length-1;x>=0;x--)u=Gg(d,n,l={},e[3],y),u.static=f,u.private=h,c=u.access={has:m=>n in m},c.get=m=>m[n],c.set=(m,k)=>m[n]=k,a=(0,r[x])({get:p.get,set:p.set},u),l._=1,a===void 0?cr(a)&&(p[g]=a):typeof a!="object"||a===null?Lr("Object expected"):(cr(o=a.get)&&(p.get=o),cr(o=a.set)&&(p.set=o),cr(o=a.init)&&w.unshift(o));return p&&ru(i,n,p),i},lu=(e,t,n)=>t.has(e)||Lr("Cannot "+n),dr=(e,t,n)=>(lu(e,t,"read from private field"),t.get(e)),Bn=(e,t,n)=>t.has(e)?Lr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ut=(e,t,n,r)=>(lu(e,t,"write to private field"),t.set(e,n),n);function Gt(e){return e instanceof ma||e instanceof hu}var Zr=10,Xg=class extends Pe{constructor(e){super(e);const t=nt(()=>{const{dragOperation:r}=e;if($r(r.activatorEvent)&&Gt(r.source)&&r.status.initialized){const i=e.registry.plugins.get(Wr);if(i)return i.disable(),()=>i.enable()}}),n=e.monitor.addEventListener("dragmove",(r,i)=>{queueMicrotask(()=>{if(this.disabled||r.defaultPrevented||!r.nativeEvent)return;const{dragOperation:s}=i;if(!$r(r.nativeEvent)||!Gt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:l}=i,{by:u}=r;if(!u)return;const c=Kg(u),{source:d,target:f}=s,{center:h}=s.shape.current,v=[],g=[];de(()=>{for(const k of l.droppables){const{id:$}=k;if(!k.accepts(d)||$===f?.id&&Gt(k)||!k.element)continue;let C=k.shape;const M=new ut(k.element,{getBoundingClientRect:T=>kr(T,void 0,.2)});!M.height||!M.width||(c=="down"&&h.y+Zr<M.center.y||c=="up"&&h.y-Zr>M.center.y||c=="left"&&h.x-Zr>M.center.x||c=="right"&&h.x+Zr<M.center.x)&&(v.push(k),k.shape=M,g.push(()=>k.shape=C))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(v,Wf);de(()=>g.forEach(k=>k()));const[y]=w;if(!y)return;const{id:p}=y,{index:x,group:m}=d.sortable;o.setDropTarget(p).then(()=>{const{source:k,target:$,shape:C}=s;if(!k||!Gt(k)||!C)return;const{index:M,group:T,target:P}=k.sortable,G=x!==M||m!==T,R=G?P:$?.element;if(!R)return;rd(R);const O=new ut(R);if(!O)return;const _=ht.delta(O,ht.from(C.current.boundingRectangle),k.alignment);o.move({by:_}),G?o.setDropTarget(k.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Kg(e){const{x:t,y:n}=e;if(t>0)return"right";if(t<0)return"left";if(n>0)return"down";if(n<0)return"up"}var Bg=Object.defineProperty,Qg=Object.defineProperties,Zg=Object.getOwnPropertyDescriptors,el=Object.getOwnPropertySymbols,Jg=Object.prototype.hasOwnProperty,em=Object.prototype.propertyIsEnumerable,tl=(e,t,n)=>t in e?Bg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ln=(e,t)=>{for(var n in t||(t={}))Jg.call(t,n)&&tl(e,n,t[n]);if(el)for(var n of el(t))em.call(t,n)&&tl(e,n,t[n]);return e},cn=(e,t)=>Qg(e,Zg(t));function tm(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Jr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function ys(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function nm(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(p,x)=>p===x||p!==null&&typeof p=="object"&&"id"in p&&p.id===x;if(Array.isArray(e)){const p=e.findIndex(m=>l(m,s.id)),x=e.findIndex(m=>l(m,o.id));if(p===-1||x===-1){if(ys(s)){const m=s.initialIndex,k=s.index;return m===k||m<0||m>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,m,k)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const m=s.index;if(m!==p)return n(e,p,m)}return n(e,p,x)}const u=Object.entries(e);let c=-1,d,f=-1,h;for(const[p,x]of u)if(c===-1&&(c=x.findIndex(m=>l(m,s.id)),c!==-1&&(d=p)),f===-1&&(f=x.findIndex(m=>l(m,o.id)),f!==-1&&(h=p)),c!==-1&&f!==-1)break;if(c===-1&&ys(s)){const p=s.initialGroup==null?void 0:Jr(e,s.initialGroup),x=s.initialIndex,m=s.group==null?void 0:Jr(e,s.group),k=s.index;if(p==null||m==null||p===m&&x===k)return"preventDefault"in t&&t.preventDefault(),e;if(p===m)return cn(ln({},e),{[p]:n(e[p],x,k)});const $=e[p][x];return cn(ln({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[m]:[...e[m].slice(0,k),$,...e[m].slice(k)]})}if(!s.manager)return e;const{dragOperation:v}=s.manager,g=(i=(r=v.shape)==null?void 0:r.current.center)!=null?i:v.position.current;if(h==null){const p=Jr(e,o.id);if(p!=null){const x=o.shape&&g.y>o.shape.center.y?e[p].length:0;h=p,f=x}}if(d==null||h==null||d===h&&c===f){if(d!=null&&d===h&&c===f&&ys(s)){const p=s.group==null?void 0:Jr(e,s.group),x=s.group!=null&&p!==d,m=s.index!==c;if(x||m){const k=s.group==null?d:p;if(k!=null){if(d===k)return cn(ln({},e),{[d]:n(e[d],c,s.index)});const $=e[d][c];return cn(ln({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[k]:[...e[k].slice(0,s.index),$,...e[k].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===h)return cn(ln({},e),{[d]:n(e[d],c,f)});const w=o.shape&&Math.round(g.y)>Math.round(o.shape.center.y)?1:0,y=e[d][c];return cn(ln({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[h]:[...e[h].slice(0,f+w),y,...e[h].slice(f+w)]})}function rm(e,t){return nm(e,t,tm)}function nl(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function rl(e,t,n){var r;for(const[i,s]of t)for(const o of s){const a=e.get(o.id);if(o.index!==a||o.group!==i||!((r=n.get(i))!=null&&r.has(o)))return!0}return!1}var il="__default__",im=class extends Pe{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof ma){const{sortable:s}=i,{group:o}=s;let a=r.get(o);a||(a=new Set,r.set(o,a)),a.add(s)}return r},n=[e.monitor.addEventListener("dragover",(r,i)=>{if(this.disabled)return;const{dragOperation:s}=i,{source:o,target:a}=s;if(!Gt(o)||!Gt(a)||o.sortable===a.sortable)return;const l=t(),u=nl(l),c=o.sortable.group===a.sortable.group,d=l.get(o.sortable.group),f=c?d:l.get(a.sortable.group);!d||!f||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var h,v;const g=t();if(rl(u,l,g))return;const w=o.sortable.element,y=a.sortable.element;if(!y||!w||!c&&a.id===o.sortable.group)return;const p=ei(d),x=c?p:ei(f),m=(h=o.sortable.group)!=null?h:il,k=(v=a.sortable.group)!=null?v:il,$={[m]:p,[k]:x},C=rm($,r);if($===C)return;const M=C[k].indexOf(o.sortable),T=C[k].indexOf(a.sortable);i.collisionObserver.disable(),sl(w,M,y,T),de(()=>{for(const[P,G]of C[m].entries())G.index=P;if(!c)for(const[P,G]of C[k].entries())G.group=a.sortable.group,G.index=P}),i.actions.setDropTarget(o.id).then(()=>i.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(r,i)=>{if(!r.canceled)return;const{dragOperation:s}=i,{source:o}=s;Gt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=nl(a),u=a.get(o.sortable.initialGroup);u&&i.renderer.rendering.then(()=>{const c=t();if(rl(l,a,c))return;const d=ei(u),f=ei(u,om),h=o.sortable.element,v=f.indexOf(o.sortable),g=d[v],w=g?.element;!g||!w||!h||(sl(h,g.index,w,o.index),de(()=>{for(const y of a.values()){const p=Array.from(y).values();for(const x of p)x.index=x.initialIndex,x.group=x.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function sl(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function sm(e,t){return e.index-t.index}function om(e,t){return e.initialIndex-t.initialIndex}function ei(e,t=sm){return Array.from(e).sort(t)}var ol=[Xg,im],cu={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function al(e){var t,n;return typeof e=="boolean"?{draggable:e,droppable:e}:{draggable:(t=e?.draggable)!=null?t:!1,droppable:(n=e?.droppable)!=null?n:!1}}var ti=new bh,du,uu,Dt,pa,ur,hr,ga,bn;uu=[U],du=[U];var Qi=class{constructor(e,t){Bn(this,pa,Qr(Dt,8,this)),Qr(Dt,11,this),Bn(this,ur),Bn(this,hr),Bn(this,ga,Qr(Dt,12,this)),Qr(Dt,15,this),Bn(this,bn),this.register=()=>(de(()=>{var v,g;(v=this.manager)==null||v.registry.register(this.droppable),(g=this.manager)==null||g.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{de(()=>{var v,g;(v=this.manager)==null||v.registry.unregister(this.droppable),(g=this.manager)==null||g.registry.unregister(this.draggable)})},this.destroy=()=>{de(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:i,group:s,index:o,sensors:a,type:l,transition:u=cu,plugins:c}=n,d=Ug(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const f=at(c,ol),h=al(i);this.droppable=new ma(bs(vs({},d),{disabled:h.droppable}),t,this),this.draggable=new hu(bs(vs({},d),{disabled:h.draggable,plugins:f,effects:()=>[()=>{var v,g,w;const y=(v=this.manager)==null?void 0:v.dragOperation.status;y?.initializing&&this.id===((w=(g=this.manager)==null?void 0:g.dragOperation.source)==null?void 0:w.id)&&ti.clear(this.manager),y?.dragging&&ti.set(this.manager,this.id,q(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:v,group:g,manager:w}=this,y=dr(this,hr),p=dr(this,ur);(v!==y||g!==p)&&(Ut(this,hr,v),Ut(this,ur,g),this.animate())},()=>{var v,g;const{target:w}=this,{isDragSource:y}=this.draggable;((g=(v=this.draggable.pluginConfig(sa))==null?void 0:v.feedback)!=null?g:"default")==="move"&&y&&(this.droppable.disabled=!w)},...r()],type:l,sensors:a}),t,this),Ut(this,bn,d.element),this.manager=t,this.index=o,Ut(this,hr,o),this.group=s,Ut(this,ur,s),this.type=l,this.transition=u}get initialIndex(){var e,t;return(t=(e=ti.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=ti.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){q(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:r}=e.dragOperation.status;!n||!t||r&&!t.idle||e.renderer.rendering.then(()=>{const{element:i}=this;if(!i)return;for(const c of i.getAnimations())"transitionProperty"in c&&(c.transitionProperty==="transform"||c.transitionProperty==="translate"||c.transitionProperty==="scale")&&c.cancel();const s=this.refreshShape();if(!s)return;const o={x:n.boundingRectangle.left-s.boundingRectangle.left,y:n.boundingRectangle.top-s.boundingRectangle.top},{translate:a}=gt(i),l=za(i,a,!1),u=za(i,a);if(o.x||o.y){const c=Qo(Xe(i))?bs(vs({},t),{duration:0}):t;id({element:i,keyframes:{translate:[`${l.x+o.x}px ${l.y+o.y}px ${l.z}`,`${u.x}px ${u.y}px ${u.z}`]},options:c}).then(()=>{e.dragOperation.status.dragging||(this.droppable.shape=void 0)})}})})}get manager(){return this.draggable.manager}set manager(e){de(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){de(()=>{const t=dr(this,bn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),Ut(this,bn,e)})}get element(){var e,t;const n=dr(this,bn);if(n)return(t=(e=Fs.get(n))!=null?e:n)!=null?t:this.droppable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){const{disabled:e}=this.draggable,{disabled:t}=this.droppable;return e===t?e:{draggable:e,droppable:t}}set plugins(e){this.draggable.plugins=at(e,ol)}set disabled(e){const t=al(e);de(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){de(()=>{this.droppable.data=e,this.draggable.data=e})}set handle(e){this.draggable.handle=e}set id(e){this.droppable.id=e,this.draggable.id=e}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set modifiers(e){this.draggable.modifiers=e}set collisionPriority(e){this.droppable.collisionPriority=e}set collisionDetector(e){this.droppable.collisionDetector=e??sd}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){de(()=>{this.droppable.type=e,this.draggable.type=e})}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts(e){return this.droppable.accepts(e)}};Dt=Vg();pa=new WeakMap;ur=new WeakMap;hr=new WeakMap;ga=new WeakMap;bn=new WeakMap;au(Dt,4,"index",uu,Qi,pa);au(Dt,4,"group",du,Qi,ga);Yg(Dt,Qi);var hu=class extends Xi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get initialIndex(){return this.sortable.initialIndex}get group(){return this.sortable.group}get initialGroup(){return this.sortable.initialGroup}},ma=class extends Ki{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},am=Object.defineProperty,lm=Object.defineProperties,cm=Object.getOwnPropertyDescriptors,ll=Object.getOwnPropertySymbols,dm=Object.prototype.hasOwnProperty,um=Object.prototype.propertyIsEnumerable,cl=(e,t,n)=>t in e?am(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xs=(e,t)=>{for(var n in t||(t={}))dm.call(t,n)&&cl(e,n,t[n]);if(ll)for(var n of ll(t))um.call(t,n)&&cl(e,n,t[n]);return e},hm=(e,t)=>lm(e,cm(t));function fm(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:i,data:s,element:o,handle:a,index:l,group:u,disabled:c,modifiers:d,sensors:f,target:h,type:v,plugins:g}=e,w=xs(xs({},cu),e.transition),y=Fd(x=>new Qi(hm(xs({},e),{transition:w,register:!1,handle:jn(a),element:jn(o),target:jn(h)}),x)),p=zd(y,pm);return ae(i,()=>y.id=i),Un(()=>{de(()=>{y.group=u,y.index=l})},[y,u,l]),ae(v,()=>y.type=v),ae(t,()=>y.accept=t,void 0,st),ae(s,()=>s&&(y.data=s)),ae(l,()=>{var x;(x=y.manager)!=null&&x.dragOperation.status.idle&&w?.idle&&y.refreshShape()},Dp),gi(a,x=>y.handle=x),gi(o,x=>y.element=x),gi(h,x=>y.target=x),ae(c,()=>y.disabled=c??!1,void 0,st),ae(f,()=>y.sensors=f,void 0,st),ae(n,()=>y.collisionDetector=n),ae(r,()=>y.collisionPriority=r),ae(g,()=>y.plugins=g,void 0,st),ae(w,()=>y.transition=w,void 0,st),ae(d,()=>y.modifiers=d,void 0,st),ae(e.alignment,()=>y.alignment=e.alignment),{sortable:p,get isDragging(){return p.isDragging},get isDropping(){return p.isDropping},get isDragSource(){return p.isDragSource},get isDropTarget(){return p.isDropTarget},handleRef:S.useCallback(x=>{y.handle=x??void 0},[y]),ref:S.useCallback(x=>{var m,k;!x&&(m=y.element)!=null&&m.isConnected&&!((k=y.manager)!=null&&k.dragOperation.status.idle)||(y.element=x??void 0)},[y]),sourceRef:S.useCallback(x=>{var m,k;!x&&(m=y.source)!=null&&m.isConnected&&!((k=y.manager)!=null&&k.dragOperation.status.idle)||(y.source=x??void 0)},[y]),targetRef:S.useCallback(x=>{var m,k;!x&&(m=y.target)!=null&&m.isConnected&&!((k=y.manager)!=null&&k.dragOperation.status.idle)||(y.target=x??void 0)},[y])}}function pm(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const co="tile",fu="gap",gm='[role="separator"]',mm=[to.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(to.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(gm)!==null}),Ed],vm=e=>[...e,sa.configure({feedback:"clone"})];function bm({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=fm({id:e,index:t,type:co,accept:co,collisionDetector:Jo,plugins:vm});return b.jsx(b.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function ym({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=tg({id:e,type:fu,accept:co,collisionDetector:Jo,data:{after:t}});return b.jsx(b.Fragment,{children:n({ref:r,isDropTarget:i})})}const xm=Qt(b.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"})),wm=Qt(b.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}));function km({tile:e,index:t,selected:n,menuOpen:r,resizeSpan:i,columns:s,onSelect:o,onOpenMenu:a,onResizeStart:l,onResizeMove:u,onResizeEnd:c,children:d}){const{theme:f}=tt();return b.jsx(bm,{id:mt(e),index:t,children:({ref:h,handleRef:v,isDragSource:g})=>b.jsxs(pe,{ref:h,onClick:o,onPointerDown:w=>{w.button===0&&o()},"aria-label":`Tile ${e.name}`,"aria-current":n,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",borderRadius:1,outline:n?`2px solid ${f.drillLink}`:"2px solid transparent",outlineOffset:2,transition:"outline-color 120ms, opacity 120ms, box-shadow 120ms","&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.22)"},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${f.drillLink}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"&:hover":{outlineColor:n?f.drillLink:f.cardBorder,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.10)"}},children:[d,b.jsx(pe,{ref:v,className:"builder-affordance","aria-label":`Move ${e.label??e.name}`,sx:{position:"absolute",top:"2px",left:"2px",display:"grid",placeItems:"center",width:"22px",height:"22px",borderRadius:"4px",cursor:"grab",touchAction:"none",zIndex:2,color:f.tileTitle,bgcolor:f.tile,opacity:g||n?.9:0,transition:"opacity 120ms","&:hover":{opacity:1},"&:active":{cursor:"grabbing"},"&:focus-visible":{opacity:1,outline:`2px solid ${f.drillLink}`,outlineOffset:1}},children:b.jsx(xm,{sx:{fontSize:16}})}),i===void 0&&b.jsx(Ss,{className:"builder-affordance",size:"small","aria-label":`Settings for ${e.label??e.name}`,onClick:w=>{w.stopPropagation(),a(w.currentTarget)},sx:{position:"absolute",top:"2px",right:"2px",width:22,height:22,zIndex:2,color:f.tileTitle,bgcolor:f.tile,opacity:n||r?.9:0,transition:"opacity 120ms","&:hover":{opacity:1,bgcolor:f.tile}},children:b.jsx(wm,{sx:{fontSize:16}})}),i!==void 0&&b.jsxs(pe,{"aria-hidden":!0,sx:{position:"absolute",top:"6px",right:"6px",px:.75,py:.25,borderRadius:"4px",bgcolor:f.drillLink,color:f.tile,fontSize:11,fontVariantNumeric:"tabular-nums",zIndex:4,pointerEvents:"none"},children:[i," of ",s," ·"," ",Math.round(i/s*100),"%"]}),e.declaration.kind!=="inherited"&&b.jsx(pe,{className:"builder-affordance",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label??e.name}`,onPointerDown:l,onPointerMove:u,onPointerUp:c,onPointerCancel:c,sx:{position:"absolute",top:0,bottom:0,right:"-5px",width:"10px",cursor:"col-resize",touchAction:"none",zIndex:1,opacity:i!==void 0||n?1:0,transition:"opacity 120ms","&:hover":{opacity:1},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"28px",borderRadius:"2px",bgcolor:f.drillLink}}})]})})}function Sm({tile:e}){const{theme:t}=tt();return b.jsxs(Ru,{sx:{minHeight:140},children:[b.jsx(Wu,{title:e.label??e.name,subtitle:e.subtitle}),b.jsxs(ne,{variant:"caption",sx:{display:"block",color:t.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function $m({after:e}){const{theme:t}=tt();return b.jsx(ym,{id:nu(e),after:e,children:({ref:n,isDropTarget:r})=>b.jsx(pe,{ref:n,"aria-hidden":!0,sx:{minHeight:48,borderRadius:1,border:`1px dashed ${t.drillLink}`,bgcolor:r?`color-mix(in srgb, ${t.drillLink} 12%, transparent)`:"transparent",opacity:r?.95:.4,transition:"opacity 120ms, background-color 120ms"}})})}function jm({columns:e}){const{theme:t}=tt();return b.jsx(pe,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${ii}px`},children:Array.from({length:e},(n,r)=>b.jsx(pe,{sx:{borderLeft:`1px dashed ${t.drillLink}`,borderRight:r===e-1?`1px dashed ${t.drillLink}`:"none",opacity:.35}},r))})}var Cm=Object.defineProperty,Om=Object.defineProperties,Mm=Object.getOwnPropertyDescriptors,dl=Object.getOwnPropertySymbols,Em=Object.prototype.hasOwnProperty,Dm=Object.prototype.propertyIsEnumerable,ul=(e,t,n)=>t in e?Cm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dn=(e,t)=>{for(var n in t||(t={}))Em.call(t,n)&&ul(e,n,t[n]);if(dl)for(var n of dl(t))Dm.call(t,n)&&ul(e,n,t[n]);return e},un=(e,t)=>Om(e,Mm(t));function Tm(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function ni(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function ws(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Pm(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(p,x)=>p===x||p!==null&&typeof p=="object"&&"id"in p&&p.id===x;if(Array.isArray(e)){const p=e.findIndex(m=>l(m,s.id)),x=e.findIndex(m=>l(m,o.id));if(p===-1||x===-1){if(ws(s)){const m=s.initialIndex,k=s.index;return m===k||m<0||m>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,m,k)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const m=s.index;if(m!==p)return n(e,p,m)}return n(e,p,x)}const u=Object.entries(e);let c=-1,d,f=-1,h;for(const[p,x]of u)if(c===-1&&(c=x.findIndex(m=>l(m,s.id)),c!==-1&&(d=p)),f===-1&&(f=x.findIndex(m=>l(m,o.id)),f!==-1&&(h=p)),c!==-1&&f!==-1)break;if(c===-1&&ws(s)){const p=s.initialGroup==null?void 0:ni(e,s.initialGroup),x=s.initialIndex,m=s.group==null?void 0:ni(e,s.group),k=s.index;if(p==null||m==null||p===m&&x===k)return"preventDefault"in t&&t.preventDefault(),e;if(p===m)return un(dn({},e),{[p]:n(e[p],x,k)});const $=e[p][x];return un(dn({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[m]:[...e[m].slice(0,k),$,...e[m].slice(k)]})}if(!s.manager)return e;const{dragOperation:v}=s.manager,g=(i=(r=v.shape)==null?void 0:r.current.center)!=null?i:v.position.current;if(h==null){const p=ni(e,o.id);if(p!=null){const x=o.shape&&g.y>o.shape.center.y?e[p].length:0;h=p,f=x}}if(d==null||h==null||d===h&&c===f){if(d!=null&&d===h&&c===f&&ws(s)){const p=s.group==null?void 0:ni(e,s.group),x=s.group!=null&&p!==d,m=s.index!==c;if(x||m){const k=s.group==null?d:p;if(k!=null){if(d===k)return un(dn({},e),{[d]:n(e[d],c,s.index)});const $=e[d][c];return un(dn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[k]:[...e[k].slice(0,s.index),$,...e[k].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===h)return un(dn({},e),{[d]:n(e[d],c,f)});const w=o.shape&&Math.round(g.y)>Math.round(o.shape.center.y)?1:0,y=e[d][c];return un(dn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[h]:[...e[h].slice(0,f+w),y,...e[h].slice(f+w)]})}function Am(e,t){return Pm(e,t,Tm)}function Im({tiles:e,commit:t,onLanded:n}){const[r,i]=S.useState(void 0),s=S.useRef(void 0),[o,a]=S.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),s.current=e},onDragOver:l=>{const{source:u,target:c}=l.operation;if(!u||!c)return;const d=s.current??e;let f;if(c.type===fu){const{after:h}=c.data,v=d.findIndex(w=>mt(w)===u.id);if(v<0||h===u.id)return;const g=d.filter((w,y)=>y!==v).findIndex(w=>mt(w)===h)+1;f=zg(d,v,g)}else{const h=d.map(mt),v=Am(h,l);if(v.every((w,y)=>w===h[y]))return;const g=new Map(d.map(w=>[mt(w),w]));f=Wg(v.map(w=>g.get(w)),e.map(w=>w.break??!1))}s.current=f,i(f)},onDragEnd:l=>{a(!1);const u=s.current;if(s.current=void 0,i(void 0),l.canceled||!u)return;t(u);const c=u.findIndex(d=>mt(d)===l.operation.source?.id);c>=0&&n(c)}}}const hl=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function Rm({tiles:e,columns:t,onStart:n,commit:r}){const[i,s]=S.useState(void 0),o=S.useRef(null);return{resize:i,gridBox:o,startResize:(a,l)=>{const u=o.current?.getBoundingClientRect(),c=a.currentTarget.parentElement?.getBoundingClientRect();!u||!c||(a.stopPropagation(),a.preventDefault(),a.currentTarget.setPointerCapture(a.pointerId),hl(!0),n(l),s({index:l,span:e[l]?.colspan??1,left:c.left,track:(u.width-ii*(t-1))/t}))},onResize:a=>{if(!i)return;const l=a.clientX-i.left,u=Math.round((l+ii)/(i.track+ii)),c=Math.min(Math.max(u,1),t);c!==i.span&&s({...i,span:c})},endResize:a=>{if(a.currentTarget.hasPointerCapture(a.pointerId)&&a.currentTarget.releasePointerCapture(a.pointerId),hl(!1),!i)return;const{index:l,span:u}=i;s(void 0),r(l,u)}}}function Wm({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,columns:s,onDrills:o}){const{theme:a}=tt(),{draft:l,patch:u,close:c,discard:d}=eu(t,e!==null,r,n),f=l!==void 0&&l.declaration.kind!=="inherited";return b.jsx(El,{open:e!==null&&l!==void 0,anchorEl:e,onClose:c,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:l&&b.jsxs(he,{sx:{gap:1.5},children:[b.jsxs(ne,{variant:"overline",sx:{color:a.tileTitle,lineHeight:1.5},children:[l.source," → ",l.name]}),f?b.jsxs(b.Fragment,{children:[b.jsx(Te,{size:"small",label:"Title",value:l.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:h=>u(v=>{const g=h.target.value;g===""?delete v.label:v.label=g})}),b.jsx(Te,{size:"small",label:"Subtitle",value:l.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:h=>u(v=>{const g=h.target.value;g===""?delete v.subtitle:v.subtitle=g})}),b.jsxs(he,{direction:"row",sx:{gap:.5,alignItems:"center"},children:[b.jsx(ne,{variant:"caption",sx:{color:a.tileTitle,mr:.5},children:"Width"}),[["Full",1],["½",2],["⅓",3],["¼",4]].map(([h,v])=>{const g=Math.max(1,Math.round(s/v)),w=(l.colspan??1)===g;return b.jsx(ke,{size:"small",variant:w?"contained":"outlined","aria-label":`Width ${h}`,"aria-pressed":w,onClick:()=>u(y=>{y.colspan=g}),sx:{minWidth:40,px:1},children:h},h)})]})]}):b.jsx(ne,{variant:"body2",sx:{color:a.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),l?.declaration.kind==="opaque"&&b.jsxs(ne,{variant:"body2",sx:{color:a.tileTitle},children:["Its body is ",l.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),b.jsx(ks,{}),b.jsxs(he,{direction:"row",sx:{justifyContent:"space-between"},children:[f?b.jsx(ke,{size:"small",onClick:()=>{c(),o()},children:"Clickable cells…"}):b.jsx("span",{}),b.jsx(ke,{color:"error",size:"small",onClick:()=>{d(),i()},children:"Remove tile"})]})]})})}const pu=e=>e.ok===!1,ve=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),Zi=e=>e!==void 0&&e.ruleIndex!==void 0&&(e.childCount??0)>0,ce={sourceDefinition:e=>ve(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>ve(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>ve(e,"VIEW","subQueryDefList"),defDimension:e=>ve(e,"defList","DIMENSION"),exploreProperties:e=>ve(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>ve(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>ve(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>ve(e,"WHERE","filterClauseList"),givenDef:e=>ve(e,"givenNameDef"),givenStatement:e=>ve(e,"GIVEN","givenDefList"),importStatement:e=>ve(e,"IMPORT","importURL"),vArrow:e=>ve(e,"ARROW","vExpr","segExpr"),segRefine:e=>ve(e,"PLUS","segExpr"),segOps:e=>ve(e,"queryProperties"),segField:e=>ve(e,"fieldPath")&&!ve(e,"segExpr"),segParen:e=>ve(e,"OPAREN","CPAREN","vExpr"),compare:e=>ve(e,"fieldExpr","compareOp"),givenRef:e=>ve(e,"GIVEN_REF")};function zm(e){const t=new Int32Array([...e].length+1);let n=0;for(let r=0;r<e.length;)t[n++]=r,r+=e.codePointAt(r)>65535?2:1;return t[n]=e.length,t}function Lm(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
71
- `&&t.push(n+1);return t}class Nm{constructor(t){this.text=t,this.map=zm(t),this.lineStarts=Lm(t)}map;lineStarts;commentLines=new Set;proseLines=new Set;blocks=[];span(t){if(!Zi(t))return;const n=t.start,r=t.stop;if(!n||!r)return;const i=this.map[n.startIndex],s=this.map[r.stopIndex+1];if(!(i===void 0||s===void 0||s<i))return{start:i,end:s}}terminal(t){const n=t?.symbol;if(!n)return;const r=this.map[n.startIndex],i=this.map[n.stopIndex+1];if(!(r===void 0||i===void 0||i<r))return{start:r,end:i}}utf16(t){return this.map[t]}text_(t){const n=this.span(t);return n&&this.text.slice(n.start,n.end)}line(t){let n=0,r=this.lineStarts.length-1;for(;n<r;){const i=n+r+1>>1;this.lineStarts[i]<=t?n=i:r=i-1}return n}positioned(t){const n=this.span(t);return n&&{span:n,line:this.line(n.start)}}indentAt(t){const n=this.lineStarts[this.line(t)];return/^[ \t]*/.exec(this.text.slice(n))?.[0]??""}}function Nr(e,t,n=[]){Zi(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)Nr(e.getChild(r),t,n);return n}const _m=e=>ve(e,"OCURLY","CCURLY");function Er(e,t){const n=[],r=i=>{if(Zi(i)){if(t(i)){n.push(i);return}if(!_m(i))for(let s=0;s<(i.childCount??0);s++)r(i.getChild(s))}};for(let i=0;i<(e.childCount??0);i++)r(e.getChild(i));return n}const be=(e,t)=>e[t]?.call(e),Kt=(e,t)=>e[t]?.call(e)??[];function Fm(e,t){if(!ce.compare(t)||(t.childCount??0)!==3)return;const n=t.getChild(2);if(!ce.givenRef(n))return;const r=e.text_(t.getChild(0)),i=e.text_(t.getChild(1)),s=e.text_(n)??"";if(!(r===void 0||i===void 0))return{field:r,op:i.trim(),given:s.replace(/^\$/,"")}}function gu(e,t){const n=e.positioned(t);if(!n)return;const r=be(t,"filterClauseList"),i=[];for(const s of r?Kt(r,"fieldExpr"):[]){const o=e.positioned(s);if(!o)continue;const a=Nr(s,ce.givenRef).map(l=>e.text_(l)).filter(l=>l!==void 0).map(l=>l.replace(/^\$/,""));i.push({...o,givens:a,binding:Fm(e,s)})}return{...n,clauses:i}}function uo(e,t){const n=e.span(t);if(!n)return;const r=[],i=[];for(const u of Er(t,ce.queryStatement)){const c=e.positioned(u);c&&r.push(c);const d=be(u,"whereStatement");if(d&&ce.whereStatement(d)){const f=gu(e,d);f&&i.push(f)}}const s=n.start+1,o=n.end-1,a=!e.text.slice(n.start,n.end).includes(`
72
- `),l=r.length?e.indentAt(r[0].span.start):e.indentAt(n.start)+" ";return{span:n,openEnd:s,closeStart:o,statements:r,wheres:i,indent:l,oneLine:a}}function va(e,t,n){const r=[],i=e.line(t.start),s=e.line(n);for(let o=i;o<s;o++){if(e.commentLines.has(o)||e.proseLines.has(o))continue;const a=e.text.slice(e.lineStarts[o],e.lineStarts[o+1]??e.text.length).trim();a.startsWith("#")&&!a.startsWith("##")&&r.push({line:o,text:a})}return r}function Hm(e,t){const n=be(t,"segExpr");if(!n)return{kind:"unsupported",why:"an unreadable expression"};const r=ce.vArrow(t);if(ce.segOps(n)){const i=be(n,"queryProperties"),s=i&&uo(e,i);return s?{kind:"inline",stage:s,...r?{pipeline:!0}:{}}:{kind:"unsupported",why:"an unreadable body"}}if(r)return{kind:"unsupported",why:"a `->` pipeline from a named view"};if(ce.segField(n)){const i=e.span(n);return i?{kind:"reference",from:e.text.slice(i.start,i.end),fromSpan:i}:{kind:"unsupported",why:"an unreadable name"}}if(ce.segRefine(n)){const i=Kt(n,"segExpr"),s=i[0],o=i[i.length-1];let a=s;for(;ce.segRefine(a);){const f=Kt(a,"segExpr");if(f.some(h=>ce.segOps(h)||ce.segParen(h)))return{kind:"unsupported",why:"a chained refinement"};a=f[0]}if(!a||!ce.segField(a))return{kind:"unsupported",why:"a `{ … } + { … }` compound refinement"};const l=e.span(s);if(!l||!o)return{kind:"unsupported",why:"an unreadable refinement"};if(!ce.segOps(o)){const f=e.span(n);return f?{kind:"reference",from:e.text.slice(f.start,f.end),fromSpan:f}:{kind:"unsupported",why:"an unreadable refinement"}}const u=e.text.slice(l.start,l.end),c=be(o,"queryProperties"),d=c&&uo(e,c);return d?{kind:"reference",from:u,fromSpan:l,refinement:d}:{kind:"reference",from:u,fromSpan:l}}return{kind:"unsupported",why:"a parenthesized expression"}}function qm(e,t){const n=[];for(const r of Er(t,ce.defExploreQuery)){const i=e.span(r),s=be(r,"subQueryDefList");if(!i||!s)continue;const o=Kt(s,"exploreQueryDef").filter(ce.exploreQueryDef),a=e.terminal(be(r,"VIEW"));for(const l of o){const u=e.span(l),c=be(l,"exploreQueryNameDef"),d=e.text_(c),f=be(l,"vExpr");!u||!d||!f||n.push({name:d,span:u,line:e.line(u.start),statement:i,tags:va(e,i,a?.start??u.start),siblings:o.length,body:Hm(e,f)})}}return n}function Um(e,t){const n=[];for(const r of Er(t,ce.defDimension)){const i=e.span(r),s=be(r,"defList");if(!i||!s)continue;const o=e.terminal(be(r,"DIMENSION"));for(const a of Kt(s,"fieldDef")){const l=e.span(a),u=e.text_(be(a,"fieldNameDef"))?.trim(),c=e.text_(be(a,"fieldExpr"))?.trim();!l||!u||c===void 0||n.push({name:u,expression:c,span:l,line:e.line(l.start),statement:i,tags:va(e,i,o?.start??l.start)})}}return n}function Vm(e,t){const n=[];for(const r of Nr(t,ce.sourceDefinition)){const i=e.span(r),s=e.text_(be(r,"sourceNameDef")),o=be(r,"sqExplore");if(!i||!s||!o)continue;const a=e.span(o),l=a?e.text.slice(a.start,a.end):"",u=(/^\s*(`[^`]*`|[A-Za-z_][A-Za-z0-9_.]*)/.exec(l)?.[1]??"").trim(),c=Er(o,ce.exploreProperties)[0],d=c&&uo(e,c),f={start:e.lineStarts[e.line(i.start)],end:i.end},h=[];if(c)for(const v of Er(c,ce.whereStatement)){const g=gu(e,v);g&&h.push(g)}n.push({name:s,base:u,span:i,line:e.line(i.start),statement:f,...d?{properties:d}:{},views:c?qm(e,c):[],dimensions:c?Um(e,c):[],wheres:h})}return n}function Gm(e,t){const n=[];for(const r of Nr(t,ce.givenStatement)){const i=e.terminal(be(r,"GIVEN")),s=be(r,"givenDefList"),o=i?e.line(i.start):void 0;for(const a of s?Kt(s,"givenDef"):[]){const l=e.span(a),u=e.span(be(a,"givenNameDef")),c=u&&e.text.slice(u.start,u.end);if(!l||!u||!c)continue;const d={start:u.start,end:l.end},f=e.line(d.start);n.push({name:c,declaration:e.text.slice(d.start,d.end),span:d,line:f,statement:{start:e.lineStarts[f],end:d.end},tags:va(e,l,d.start),...o!==void 0&&o!==f?{blockHeader:o}:{}})}}return n}function Ym(e,t){const n=[];for(const r of Nr(t,ce.importStatement)){const i=e.span(r),s=e.text_(be(r,"importURL"));if(!i||s===void 0)continue;const o=be(r,"importSelect"),a=o?Kt(o,"importItem").map(l=>e.text_(l)).filter(l=>l!==void 0).map(l=>l.trim()):void 0;n.push({from:s.replace(/^['"]|['"]$/g,""),...a&&a.length>0?{names:a}:{},span:i,line:e.line(i.start),statement:i})}return n}async function mu(e){let t;try{t=await vu(e,"file://dashboard-builder.malloy")}catch(f){return{ok:!1,reason:`Malloy could not read this file: ${f}`}}const n=t.problems.filter(f=>f.code==="syntax-error");if(n.length>0)return{ok:!1,reason:`This file has a Malloy syntax error, so it cannot be edited here: ${n[0].message??"unknown"}`};const r=t.parse,i=r?.root;if(!i||!Zi(i)||typeof i.getChild!="function")return{ok:!1,reason:`This build of Malloy does not expose a parse tree the builder can read (malloy ${r?.malloyVersion??"unknown"}), so editing is off.`};const s=r?.tokenStream??{},o=typeof s.getTokens=="function"?s.getTokens():void 0;if(!o||typeof s.tokenSource?.vocabulary?.getSymbolicName!="function"||o.length===0&&e.trim()!=="")return{ok:!1,reason:`This build of Malloy does not expose a token stream the builder can read (malloy ${r?.malloyVersion??"unknown"}), so it cannot tell a comment from code and editing is off.`};const a=new Nm(e),l=Xm(a,s);a.commentLines=l.lines;const u=e.split(`
73
- `),c=f=>l.lines.has(f);a.proseLines=Gu(u,c),a.blocks=Yu(u,c).filter(([f])=>!u[f].trimStart().startsWith("##"));const d=Vm(a,i);return d.length===0&&/^\s*source:/m.test(e)?{ok:!1,reason:`The builder could not locate this file's sources in Malloy's parse tree (malloy ${r?.malloyVersion??"unknown"}), so editing is off.`}:{ok:!0,parsed:{text:e,lineStarts:a.lineStarts,imports:Ym(a,i),sources:d,givens:Gm(a,i),trailingComment:f=>l.trailing.get(f),comments:l.all,commentLine:f=>l.lines.has(f),proseLine:f=>a.proseLines.has(f),commentIn:f=>l.all.find(h=>h.start>=f.start&&h.start<f.end),blockStart:f=>Km(a,l.lines,f)}}}async function vu(e,t){const{MalloyTranslator:n}=await Ol(async()=>{const{MalloyTranslator:i}=await import("./index-CKmZ4HG7.js").then(s=>s.i);return{MalloyTranslator:i}},__vite__mapDeps([0,1,2,3,4])),r=new n(t,null,{urls:{[t]:e}});return{problems:r.translate().problems??[],parse:r.parseStep?.response?.parse}}function Xm(e,t){const n=new Map,r=new Set,i=[],s=t.tokenSource?.vocabulary;for(const c of t.getTokens?.()??[]){const d=s?.getSymbolicName(c.type);if(d!=="COMMENT_TO_EOL"&&d!=="BLOCK_COMMENT")continue;const f=e.utf16(c.startIndex);let h=e.utf16(c.stopIndex+1);if(!(f===void 0||h===void 0||h<f)){for(;h>f&&(e.text[h-1]===`
74
- `||e.text[h-1]==="\r");)h--;i.push({start:f,end:h})}}const o=[...i].sort((c,d)=>c.start-d.start);let a="",l=0;for(const c of o)a+=e.text.slice(l,Math.max(l,c.start)),a+=e.text.slice(Math.max(l,c.start),Math.max(l,c.end)).replace(/[^\n\r]/g," "),l=Math.max(l,c.end);a+=e.text.slice(l);const u=c=>a.slice(e.lineStarts[c],e.lineStarts[c+1]??a.length);for(const c of i){const d=e.line(c.start),f=e.line(c.end-1);for(let g=d;g<=f;g++)u(g).trim()===""&&r.add(g);const h=a.slice(e.lineStarts[d],c.start).trim(),v=a.slice(c.end,e.lineStarts[f+1]??a.length).trim();h!==""&&v===""&&n.set(f,c)}return{trailing:n,lines:r,all:i}}function Km(e,t,n){const r=s=>e.text.slice(e.lineStarts[s],e.lineStarts[s+1]??e.text.length).trim();let i=n;for(let s=n-1;s>=0;s--){const o=r(s),a=e.blocks.find(([,l])=>l===s);if(a){i=s=a[0];continue}if(o===""&&!t.has(s))break;if(o.startsWith("#")||t.has(s))i=s;else break}return i}const ho=e=>e.ok===!1;function _r(e,t,n){const r=e.blockStart(n),i=[],s=[];for(let o=r;o<n;o++){if(e.commentLine(o))continue;if(e.proseLine(o)){s.push(o);continue}const a=t[o].trim();a.startsWith("#")&&!a.startsWith("##")&&i.push({line:o,text:a})}return{start:r,tags:i,prose:s}}const fo=e=>e.map(t=>t.text);function Bm(e){const t=[],n=Xu(e);for(const[r,i]of e.entries()){if(n.has(r))continue;const s=i.trim(),o=Ku(s);s.startsWith("##")&&!s.startsWith('##"')&&!s.startsWith("##!")&&!(o?.level===2&&!o.block)&&t.push(s)}return{description:Tl(e).text,artifact:t}}function Qm(e){if(!e)return;const t=[];for(const n of e.wheres)for(const r of n.clauses){if(!r.binding)continue;const{field:i,op:s,given:o}=r.binding;t.push({field:i,given:o,...s==="~"?{}:{op:s}})}return t.length>0?t:void 0}function Zm(e,t,n){const r=[];for(const i of e.givens){const s=/^([A-Za-z_][A-Za-z0-9_]*)\s*::\s*(\S+)\s+is\s+([\s\S]+)$/.exec(i.declaration);s&&r.push({name:s[1],type:s[2],default:s[3].trim(),...Jm(n(fo(_r(e,t,i.line).tags)).tag)})}return r.length>0?r:void 0}function Jm(e){if(!e)return{};const t=e.tag("suggest"),n=t?.text("dimension"),r=e.numeric("range_min"),i=e.numeric("range_max");return{...e.text("label")===void 0?{}:{label:e.text("label")},...e.text("description")===void 0?{}:{description:e.text("description")},...e.text("control")===void 0?{}:{control:e.text("control")},...t&&n?{suggest:{...t.text("source")===void 0?{}:{source:t.text("source")},...t.text("query")===void 0?{}:{query:t.text("query")},dimension:n}}:{},...r===void 0?{}:{rangeMin:r},...i===void 0?{}:{rangeMax:i}}}function fl(e,t){const n=e?.text(t)?.trim();if(n===void 0||!/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/.test(n))return;const r=Number(n);return Number.isInteger(r)&&r>=1?r:void 0}function ev(e){const t=e.search(/tiles\s*=\s*\[/);if(t<0)return[];const n=e.indexOf("[",t),r=e.indexOf("]",n);return r<0?[]:[...e.slice(n+1,r).matchAll(/"([^"]+)"/g)].map(i=>i[1])}async function po(e){const{parseAnnotation:t}=await Ol(async()=>{const{parseAnnotation:m}=await import("./index-CdExa3Pk.js").then(k=>k.i);return{parseAnnotation:m}},__vite__mapDeps([5,1,2,3])),n=e.split(`
75
- `),r=await mu(e);if(pu(r))return{ok:!1,reason:r.reason,...r.line?{line:r.line}:{}};const i=r.parsed,{description:s,artifact:o}=Bm(n),a=o.find(m=>Bu.test(m));if(a===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a composite dashboard."};const l=t([a.replace(/^##\s*/,"# ")]).tag,u=l?.tag("artifact"),c=ev(a);if(c.length===0)return{ok:!1,reason:"The `## artifact` tag names no tiles, so there is nothing to lay out."};const d=i.imports.map(m=>m.names?{kind:"names",names:m.names,from:m.from}:{kind:"all",from:m.from}),f=[],h=[],v=new Map;for(const m of i.sources){const k={name:m.name,base:m.base};m.dimensions.length>0&&(k.dimensions=m.dimensions.map($=>({name:$.name,expression:$.expression}))),f.push(k);for(const $ of m.dimensions){const C=t(fo(_r(i,n,$.line).tags)).tag?.tag("drill");if(!C)continue;const M=C.textArray("to")??[C.text("to")??""];h.push({source:m.name,name:$.name,expression:$.expression,to:M.filter(Boolean),...C.text("given")?{given:C.text("given")}:{}})}v.set(m.name,new Map(m.views.map($=>[$.name,$])))}const g=[];for(const m of c){const k=Iu(m);if(!k)return{ok:!1,reason:`The tile \`${m}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:$,view:C}=k,M=v.get($)?.get(C);if(M===void 0){g.push({name:C,source:$,declaration:{kind:"inherited"}});continue}const T=t(fo(M.tags)).tag,P=M.body.kind==="reference"?{kind:"reference",from:M.body.from}:M.body.kind==="inline"?{kind:"inline"}:void 0;if(P===void 0){g.push({name:C,source:$,declaration:{kind:"opaque",why:M.body.kind==="unsupported"?M.body.why:"unreadable"},...T?.text("label")?{label:T.text("label")}:{},...T?.text("subtitle")?{subtitle:T.text("subtitle")}:{},...T?.numeric("colspan")!==void 0?{colspan:T.numeric("colspan")}:{},...T?.has("break")?{break:!0}:{},...T?.has("borderless")?{borderless:!0}:{}});continue}const G=Qm(M.body.kind==="reference"?M.body.refinement:M.body.kind==="inline"?M.body.stage:void 0);g.push({name:C,source:$,declaration:P,...G?{filters:G}:{},...T?.text("label")?{label:T.text("label")}:{},...T?.text("subtitle")?{subtitle:T.text("subtitle")}:{},...T?.numeric("colspan")!==void 0?{colspan:T.numeric("colspan")}:{},...T?.has("break")?{break:!0}:{},...T?.has("borderless")?{borderless:!0}:{}})}const w=Zm(i,n,t),y={},p=u?.tag("givens");for(const m of Object.keys(p?.dict??{})){const k=p?.text(m);k!==void 0&&(y[m]=k)}const x=l?.tag("dashboard")?.has("columns")?fl(l.tag("dashboard"),"columns"):u?.array("tiles")?fl(u,"dashboard_columns"):void 0;return{ok:!0,document:{title:u?.text("title")??"",...s?{description:s}:{},...x===void 0?{}:{columns:x},...u?.has("autorun")?{autorun:u.isTrue("autorun")}:{},imports:d,sources:f,...w?{localGivens:w}:{},...Object.keys(y).length>0?{startingGivens:y}:{},...h.length>0?{drills:h}:{},tiles:g}}}async function pl(e){const{problems:t}=await vu(e,"file://splice-check.malloy");return t.filter(n=>n.code==="syntax-error").map(n=>n.message??"").sort()}const gl=e=>e.ok===!1;function ye(e){const t=n=>{if(Array.isArray(n))return n.map(t);if(n&&typeof n=="object"){const r={};for(const i of Object.keys(n).sort())r[i]=t(n[i]);return r}return n};return JSON.stringify(t(e))}function tv(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
76
- `&&t.push(n+1);return t}function nv(e,t){let n=e;for(const r of[...t].sort((i,s)=>s.start-i.start||s.end-i.end))n=n.slice(0,r.start)+r.text+n.slice(r.end);return n}function bu(e){const t=[];return e.colspan!==void 0&&t.push(`# colspan=${e.colspan}`),e.break&&t.push("# break"),e.borderless&&t.push("# borderless"),e.label!==void 0&&t.push(`# label=${Pn(e.label)}`),e.subtitle!==void 0&&t.push(`# subtitle=${Pn(e.subtitle)}`),t}function bi(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const rv=new Set(["colspan","break","borderless","label","subtitle"]),iv=new Set(["label","description","control","suggest","range_min","range_max"]),sv=(e,t)=>ye(e.imports)===ye(t.imports);function ml(e){const t=[];if(e.label!==void 0&&t.push(`label=${Pn(e.label)}`),e.description!==void 0&&t.push(`description=${Pn(e.description)}`),e.control!==void 0&&t.push(`control=${e.control}`),e.suggest){const n=e.suggest.source!==void 0?`source=${e.suggest.source}`:e.suggest.query!==void 0?`query=${e.suggest.query}`:void 0;t.push(`suggest { ${n?`${n} `:""}dimension=${e.suggest.dimension} }`)}return e.rangeMin!==void 0&&t.push(`range_min=${e.rangeMin}`),e.rangeMax!==void 0&&t.push(`range_max=${e.rangeMax}`),t.length>0?`# ${t.join(" ")}`:void 0}const vl=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function ov(e,t,n){const r=e.sources.find(i=>i.name===t)?.views.find(i=>i.name===n);return r?r.line:-1}function bl(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(t=>`"${t}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const zi=e=>`${e.source}.${e.name}`,Pn=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,go=e=>ye([e.name,e.source,e.declaration]),vt=go,yl=e=>ye(e.tiles.map(vt));function av(e,t){const n=new Set(e.tiles.map(vt)),r=new Set(t.tiles.map(vt)),i=e.tiles.filter(c=>!r.has(vt(c))),s=t.tiles.filter(c=>!n.has(vt(c))),o=i.length>0||s.length>0||yl(e)!==yl(t);for(const c of s)if(c.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${c.name}\` is ${c.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const a=new Map(e.sources.map(c=>[c.name,c])),l=new Set(e.imports.flatMap(c=>c.kind==="names"?c.names:[]));for(const c of e.sources)l.add(c.base);const u=t.sources.filter(c=>!a.has(c.name));for(const c of e.sources){const d=t.sources.find(f=>f.name===c.name);if(!d||d.base!==c.base)return{ok:!1,reason:`The source \`${c.name}\` cannot be changed or removed here.`}}for(const c of u){if(!s.some(d=>d.source===c.name))return{ok:!1,reason:`A new source \`${c.name}\` needs a tile on it.`};if(!l.has(c.base))return{ok:!1,reason:`\`${c.base}\` is not imported by name in this file, so a tile cannot be put on it. The builder does not add imports: import { ${c.base} } from the model first.`}}return sv(e,t)?{currentKeys:n,nextKeys:r,removedTiles:i,addedTiles:s,newSources:u,currentSources:a,reordered:o}:{ok:!1,reason:"The dashboard's imports cannot be changed here."}}function lv(e){const{lines:t,wholeLine:n,next:r,reordered:i,currentKeys:s,nextKeys:o,edits:a}=e;if(i){const l=si(t);if(l<0)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};if(Qu(t[l]))return{ok:!1,reason:"The `tiles=[…]` list holds an entry the builder does not model, such as a text tile, and rewriting the list would drop it. Reorder, add and remove tiles in the file's text."};const u=[...t[l].matchAll(/"([^"]+)"/g)].map(v=>v[1]),c=new Map;for(const v of u){const g=v.split("->").map(w=>w.trim());g.length===2&&c.set(`${g[0]}->${g[1]}`,v)}const d=r.tiles.map(v=>c.get(`${v.source}->${v.name}`)??(o.has(vt(v))&&!s.has(vt(v))?`${v.source} -> ${v.name}`:void 0));if(d.some(v=>v===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const f=`tiles=[${d.map(v=>`"${v}"`).join(", ")}]`,h=t[l].replace(/tiles\s*=\s*\[[\s\S]*?\]/,f);h!==t[l]&&a.push({...n(l),text:`${h}
77
- `})}}function cv(e,t){let n=0,r=0;for(let i=0;i<e.length;i++){const s=e[i];if(s==='"')i=Li(e,i);else if(s==="{"||s==="[")n++===0&&r++;else if(s==="}"||s==="]")n--;else if(r===1&&n===1&&e.startsWith(t,i)&&!/[A-Za-z0-9_]/.test(e[i-1]??" ")){const o=/^\s*=\s*/.exec(e.slice(i+t.length));if(!o)continue;const a=i+t.length+o[0].length,l=e[a]==='"'?Li(e,a)+1:a+(/^[^\s}]*/.exec(e.slice(a))?.[0].length??0),u=i-(/\s*$/.exec(e.slice(0,i))?.[0].length??0);return e.slice(0,u)+e.slice(l)}}return e}function dv(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(r==='"')n=Li(e,n);else if(r==="{"||r==="[")t++;else if(r==="}"||r==="]")t--;else if(t===0&&e.startsWith("dashboard",n)&&!/[A-Za-z0-9_]/.test(e[n-1]??" ")){const i=/^dashboard\s*\{/.exec(e.slice(n));if(!i)continue;let s=1,o=n+i[0].length;for(;o<e.length&&s>0;o++)e[o]==='"'?o=Li(e,o):e[o]==="{"?s++:e[o]==="}"&&s--;const a=n-(/\s*$/.exec(e.slice(0,n))?.[0].length??0);return e.slice(0,a)+e.slice(o)}}return e}function Li(e,t){for(let n=t+1;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==='"')return n;return e.length}function uv(e){const{lines:t,wholeLine:n,current:r,next:i,edits:s}=e;if(r.title!==i.title||r.autorun!==i.autorun||r.columns!==i.columns||ye(r.startingGivens)!==ye(i.startingGivens)){const o=si(t);if(o<0)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=s.find(g=>g.start===n(o).start&&g.end===n(o).end);let l=a?a.text.replace(/\n$/,""):t[o];const u=l.indexOf("artifact"),c=l.indexOf("{",u);let d=0,f=-1;for(let g=c;g<l.length;g++)if(l[g]==="{")d++;else if(l[g]==="}"&&--d===0){f=g;break}if(c<0||f<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let h=l.slice(c+1,f);const v=(g,w)=>{const y=new RegExp(`\\s*\\b${g}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);w===void 0?h=h.replace(y,""):y.test(h)?h=h.replace(y,` ${g}=${w}`):h=`${h.replace(/\s+$/,"")} ${g}=${w} `};if(r.title!==i.title&&v("title",i.title?Pn(i.title):void 0),r.autorun!==i.autorun&&v("autorun",i.autorun===void 0?void 0:String(i.autorun)),ye(r.startingGivens)!==ye(i.startingGivens)){h=h.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const g=Object.entries(i.startingGivens??{});g.length>0&&(h=`${h.replace(/\s+$/,"")} givens { ${g.map(([w,y])=>`${w}=${Pn(y)}`).join(" ")} }`)}h=h.replace(/\s{2,}/g," "),l=`${l.slice(0,c+1)}${h.startsWith(" ")?h:` ${h}`}${h.endsWith(" ")?"":" "}${l.slice(f)}`,r.columns!==i.columns&&(l=cv(l,"dashboard_columns"),l=dv(l),i.columns!==void 0&&(l=`${l.trimEnd()} dashboard { columns=${i.columns} }`)),a?a.text=`${l}
78
- `:s.push({...n(o),text:`${l}
79
- `})}if(r.description!==i.description){const{read:o,blankAbove:a,below:l,belowBlock:u,inBlock:c}=Tl(t);if(c||i.description===void 0&&u)return{ok:!1,reason:"The description is written in a `##|\"` block, which the builder cannot edit in place. Change it in the file's text."};const d=(i.description??"").split(`
80
- `).map(g=>g.trim()===""?'##"':`##" ${g.trim()}`).join(`
81
- `),f=o.length>0&&o[0]<si(t),h=i.description===void 0,v=f?[...o.slice(1),...h?l:[]]:[...o,...a];for(const g of v)s.push({...n(g),text:""});if(f)s.push({...n(o[0]),text:i.description===void 0?"":`${d}
82
- `});else if(i.description!==void 0){const g=n(si(t)).start;s.push({start:g,end:g,text:`${d}
83
- `})}}}function hv(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,l=new Map((i.localGivens??[]).map(h=>[h.name,h])),u=new Map((s.localGivens??[]).map(h=>[h.name,h])),c=new Map(a.givens.map(h=>[h.name,h])),d=new Set;for(const[h,v]of l){const g=u.get(h);if(g!==void 0&&ye(g)===ye(v))continue;const w=c.get(h);if(w===void 0)return{ok:!1,reason:`Could not find where the given \`${h}\` is declared.`};const{tags:y,prose:p}=_r(a,t,w.line),x=[...(g===void 0?y:y.filter(M=>{const T=bi(M.text);return T!==void 0&&iv.has(T)})).map(M=>M.line),...g===void 0?p:[]];for(const M of x)o.push({...n(M),text:""}),d.add(M);const m=Bt(a,w.span.end-1);if(g===void 0){o.push({start:n(w.line).start,end:n(m).end,text:""});for(let O=w.line;O<=m;O++)d.add(O);const M=Math.min(w.line,...x),T=w.blockHeader??M,P=(t[m+1]??"x").trim()==="",G=T===0||t[T-1].trim()==="",R=w.blockHeader===void 0||![...c.values()].some(O=>O.blockHeader===w.blockHeader&&O.line>w.line&&u.has([...c.entries()].find(([,_])=>_===O)?.[0]??""));P&&G&&R&&!d.has(m+1)&&(o.push({...n(m+1),text:""}),d.add(m+1));continue}const k=r(w.line),$=ml(g),C=g.type!==v.type||g.default!==v.default?w.blockHeader===void 0?vl(g):`${g.name} :: ${g.type} is ${g.default}`:t.slice(w.line,m+1).join(`
84
- `).trim();o.push({start:n(w.line).start,end:n(m).end,text:($?`${k}${$}
85
- `:"")+`${k}${C}
86
- `})}for(const[h,v]of c)v.blockHeader===void 0||u.has(h)||![...c.values()].some(g=>g.blockHeader===v.blockHeader&&!d.has(g.line))&&!d.has(v.blockHeader)&&(o.push({...n(v.blockHeader),text:""}),d.add(v.blockHeader));const f=[...u.values()].filter(h=>!l.has(h.name));if(f.length>0){const h=Math.max(-1,...[...c.values()].map(p=>p.line)),v=(()=>{let p=-1;for(let x=0;x<t.length;x++){const m=t[x].trim();(m.startsWith("import ")||p>=0&&/^}\s*from\s/.test(m))&&(p=x)}return p})(),g=h>=0?h:v,w=f.map(p=>{const x=ml(p);return(x?`${x}
87
- `:"")+`${vl(p)}
88
- `}).join(`
89
- `),y=g>=0?n(g).end:n(0).end;o.push({start:y,end:y,text:`
90
- ${w}`}),t.some(p=>p.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
91
- `})}}function fv(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,l=new Map((i.drills??[]).map(c=>[zi(c),c])),u=new Map((s.drills??[]).map(c=>[zi(c),c]));for(const c of new Set([...l.keys(),...u.keys()])){const d=l.get(c),f=u.get(c);if(d&&f&&ye(d)===ye(f))continue;const h=f??d;if(f&&f.to.length===0)return{ok:!1,reason:`The drill on \`${c}\` names no destination.`};const v=a.sources.find(p=>p.name===h.source)?.dimensions.find(p=>p.name===h.name);if(v===void 0)return{ok:!1,reason:`\`${h.name}\` is not a dimension \`${h.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:g}=_r(a,t,v.line),w=g.find(p=>/^#\s*drill\b/.test(p.text)),y=r(v.line);if(f===void 0)w&&o.push({...n(w.line),text:""});else if(w)o.push({...n(w.line),text:`${y}${bl(f)}
92
- `});else{const p=n(v.line).start;o.push({start:p,end:p,text:`${y}${bl(f)}
93
- `})}}}function pv(e){const{lines:t,wholeLine:n,removedTiles:r,edits:i,parsed:s}=e;for(const o of r){if(o.declaration.kind==="inherited")continue;const a=yu(e,o);if(!a)return{ok:!1,reason:`Could not find where \`${o.name}\` is declared.`};if(a.siblings>1)return{ok:!1,reason:`\`${o.name}\` is one of several views declared by a single \`view:\` statement, which the builder does not restructure.`};const l=Bt(s,a.statement.start),u=Bt(s,a.statement.end-1),c=s.trailingComment(u),d=c&&c.start>=a.statement.end?c.end:a.statement.end;if(s.text.slice(s.lineStarts[l],a.statement.start).trim()!==""||s.text.slice(d,n(u).end).trim()!==""){i.push({...ku(s,a.statement),text:""});continue}i.push({start:s.lineStarts[l],end:n(u).end,text:""});const f=l===0?"":t[l-1].trim();(t[u+1]??"x").trim()===""&&(l===0||f===""||f.endsWith("{"))&&i.push({...n(u+1),text:""})}}function gv(e){const{sourceText:t,lines:n,wholeLine:r,addedTiles:i,newSources:s,currentSources:o,edits:a,parsed:l}=e,u=new Map;for(const f of i){const h=u.get(f.source)??[];h.push(f),u.set(f.source,h)}const c=(f,h)=>{const v=f.declaration.kind==="reference"?f.declaration.from:f.name,g=(f.filters??[]).map(w=>`where: ${w.field} ${w.op??"~"} $${w.given}`).join(", ");return[...bu(f).map(w=>`${h}${w}`),`${h}view: ${f.name} is ${v}${g?` + { ${g} }`:""}`].join(`
94
- `)};let d=-1;for(const f of l.sources)d=Math.max(d,Bt(l,f.span.end-1));for(const[f,h]of u)if(o.has(f)){const v=l.sources.find(m=>m.name===f);if(!v)return{ok:!1,reason:`Could not find where the source \`${f}\` is declared.`};if(!v.properties)return{ok:!1,reason:`\`${f}\` never opens an \`extend { … }\` block, so a new tile cannot be added inside it.`};const g=v.line,w=Bt(l,v.properties.closeStart);let y=" ";for(let m=g+1;m<w;m++){const k=/^(\s+)view:/.exec(n[m]);if(k){y=k[1];break}}const p=r(w).start,x=(n[w-1]??"").trim()==="";a.push({start:p,end:p,text:(x?"":`
95
- `)+h.map(m=>c(m,y)).join(`
96
-
97
- `)+`
98
- `})}else{const v=s.find(x=>x.name===f);if(!v)return{ok:!1,reason:`The tile's source \`${f}\` is not declared.`};const g=`
99
- source: ${v.name} is ${v.base} extend {
100
- `+h.map(x=>c(x," ")).join(`
101
-
102
- `)+`
103
- }
104
- `;let w=d;if(w<0)for(let x=0;x<n.length;x++){const m=n[x].trim();(/^(import\s|given:|}\s*from\s)/.test(m)||/^[A-Z_]+\s*::/.test(m))&&(w=x)}const y=w>=0?r(w).end:t.length,p=y===t.length&&!t.endsWith(`
105
- `)?`
106
- `:"";a.push({start:y,end:y,text:p+g}),d=w}}function mv(e){const{lines:t,starts:n,wholeLine:r,indentOf:i,current:s,next:o,edits:a,parsed:l}=e,u=new Map(s.tiles.map(c=>[vt(c),c]));for(const c of o.tiles){const d=u.get(vt(c));if(d===void 0||ye(d)===ye(c))continue;if(c.declaration.kind==="inherited")return{ok:!1,reason:`\`${c.source} -> ${c.name}\` is declared on its source, not in this dashboard, so its presentation cannot be changed here.`};const f=ov(l,c.source,c.name);if(f<0)return{ok:!1,reason:`Could not find where \`${c.name}\` is declared inside \`${c.source}\`.`};const{tags:h}=_r(l,t,f),v=i(f),g=bu(c),w=new Map(g.map($=>[bi($)??$,$])),y=new Set;for(const $ of h){const C=bi($.text);if(C===void 0||!rv.has(C))continue;const M=w.get(C);if(M===void 0){a.push({...r($.line),text:""});continue}y.add(C),M!==$.text&&a.push({...r($.line),text:`${v}${M}
107
- `})}const p=g.filter($=>!y.has(bi($)??$));if(p.length>0){const $=n[f];a.push({start:$,end:$,text:p.map(C=>`${v}${C}
108
- `).join("")})}if(ye(d.filters)===ye(c.filters))continue;const x=yu(e,c);if(!x)return{ok:!1,reason:`Could not find \`${c.name}\`'s declaration to filter it.`};if(x.body.kind==="reference"){const $=yv(e,c,x);if($)return $;continue}if(x.body.kind!=="inline")return{ok:!1,reason:`\`${c.name}\`'s body is ${x.body.why}, so there is no single first stage to write its filter into.`};const m=xu(c.filters,x.body.stage);if(m)return wu(c.name,m.given);const k=Su(e,c,x.body.stage);if(k)return k}}const Bt=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function yu(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function xu(e,t){if(!t)return;const n=new Set;for(const r of t.wheres)for(const i of r.clauses)if(!i.binding)for(const s of i.givens)n.add(s);return(e??[]).find(r=>n.has(r.given))}function wu(e,t){return{ok:!1,reason:`\`${e}\` already filters on \`$${t}\` in a \`where:\` the builder does not manage, so binding it again would filter on it twice. Edit that \`where:\` in the file instead.`}}const yi=e=>`where: ${e.field} ${e.op??"~"} $${e.given}`;function xl(e,t,n){return{ok:!1,reason:`Removing a filter from \`${e}\` would also remove the comment written beside it (\`${t.text.slice(n.start,n.end).trim()}\`), so nothing was written. Delete it in the file first.`}}function vv(e,t,n){const r=e.commentIn(n);if(r)return r;const i=e.trailingComment(Bt(e,t.end-1));return i&&i.start>=t.end&&e.text.slice(t.end,i.start).trim()===""?i:void 0}function bv(e,t){const n=e[t].span;return t+1<e.length?{start:n.start,end:e[t+1].span.start}:t>0?{start:e[t-1].span.end,end:n.end}:n}function ku(e,t){const n=e.lineStarts[e.lineStarts.findLastIndex(a=>a<=t.start)],r=e.text.slice(n,t.start),i=e.text.indexOf(`
109
- `,t.end),s=e.text.slice(t.end,i<0?void 0:i);if(r.trim()===""&&s.trim()==="")return{start:n,end:i<0?e.text.length:i+1};if(r.trim()===""){const a=/^\s*/.exec(s)?.[0].length??0;return{start:t.start,end:t.end+a}}const o=r.replace(/[\s,]*$/,"");return{start:n+o.length,end:t.end}}function Su(e,t,n){const{parsed:r,edits:i}=e,s=new Map((t.filters??[]).map(f=>[f.given,f])),o=new Set;let a;for(const f of n.wheres){const h=f.clauses.map((g,w)=>({clause:g,index:w})).filter(({clause:g})=>g.binding!==void 0);if(h.length===0)continue;const v=h.filter(({clause:g})=>s.has(g.binding.given));for(const{clause:g}of h)o.add(g.binding.given);if(v.length===0&&h.length===f.clauses.length){const g=ku(r,f.span),w=vv(r,f.span,g);if(w)return xl(t.name,r,w);i.push({...g,text:""});continue}v.length>0&&(a=f.span);for(let g=h.length-1;g>=0;g--){const{clause:w,index:y}=h[g],p=s.get(w.binding.given);if(!p){const m=bv(f.clauses,y),k=r.commentIn(m);if(k)return xl(t.name,r,k);i.push({...m,text:""});continue}const x=yi(p).replace(/^where:\s*/,"");x!==r.text.slice(w.span.start,w.span.end)&&i.push({...w.span,text:x})}}const l=(t.filters??[]).filter(f=>!o.has(f.given));if(l.length===0)return;let u=a?.end??(n.statements.length>0?n.statements[n.statements.length-1].span.end:n.openEnd);if(!n.oneLine){const f=r.trailingComment(Bt(r,u));f&&f.start>=u&&(u=f.end)}const c=a!==void 0&&!/,\s*$/.test(r.text.slice(0,u))?", ":" ",d=n.oneLine?`${c}${l.map(yi).join(", ")}`:l.map(f=>`
110
- ${n.indent}${yi(f)}`).join("");i.push({start:u,end:u,text:d})}function yv(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:i,refinement:s}=n.body,o=xu(t.filters,s);if(o)return wu(t.name,o.given);const a=t.filters??[];if(!s){if(a.length===0)return;const c=` + { ${a.map(yi).join(", ")} }`;r.push({start:i.end,end:i.end,text:c});return}const l=s.wheres.some(c=>c.clauses.some(d=>!d.binding)),u=s.statements.some(c=>!s.wheres.some(d=>d.span.start===c.span.start));if(a.length===0&&!l&&!u){const c={start:i.end,end:s.span.end},d=e.parsed.commentIn(c);if(d)return{ok:!1,reason:`Removing the last filter from \`${t.name}\` would also remove the comment beside its refinement (\`${e.parsed.text.slice(d.start,d.end).trim()}\`), so nothing was written. Delete it in the file first, or edit the refinement there.`};r.push({...c,text:""});return}return Su(e,t,s)}async function wl(e,t){const n=await po(e);if(ho(n))return{ok:!1,reason:`Cannot edit a file that will not open: ${n.reason}`};const r=n.document,i=av(r,t);if("reason"in i)return i;const s=await mu(e);if(pu(s))return{ok:!1,reason:`Cannot edit a file that will not open: ${s.reason}`};const o=e.split(`
111
- `),a=tv(e),l=g=>({start:a[g],end:g+1<a.length?a[g+1]:e.length}),u=g=>/^\s*/.exec(o[g])?.[0]??"",c=[],d={...i,sourceText:e,parsed:s.parsed,lines:o,starts:a,wholeLine:l,indentOf:u,current:r,next:t,edits:c};for(const g of[lv,uv,hv,fv,pv,gv,mv]){const w=g(d);if(w)return w}const f=g=>{const{drills:w,localGivens:y,...p}=g,x=g.tiles.map(m=>{if(m.filters?.length)return m;const{filters:k,...$}=m;return $});return{...p,tiles:x,...w?.length?{drills:[...w].sort((m,k)=>zi(m).localeCompare(zi(k)))}:{},...y?.length?{localGivens:y}:{}}};if(c.length===0)return ye(f(r))!==ye(f(t))?{ok:!1,reason:"No part of this edit was recognized, so nothing was written. Your changes are still here."}:{ok:!0,source:e};const h=nv(e,c);if((await pl(e)).length===0){const g=await pl(h);if(g.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${g[0]}). Your changes are still here.`}}const v=await po(h);return ho(v)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${v.reason}`}:ye(f(v.document))!==ye(f(t))?{ok:!1,reason:"What was written did not read back as what was asked for, so it was not written. Your changes are still here."}:{ok:!0,source:h}}function xv(e){const[t,n]=S.useState({stack:[e.document],index:0}),[r,i]=S.useState(e.source),[s,o]=S.useState(void 0),[a,l]=S.useState(e.document),u=t.stack[t.index],c=S.useCallback(y=>{o(void 0),n(p=>{const x=structuredClone(p.stack[p.index]);if(y(x),JSON.stringify(x)===JSON.stringify(p.stack[p.index]))return p;const m=[...p.stack.slice(0,p.index+1),x].slice(-100);return{stack:m,index:m.length-1}})},[]),d=S.useCallback(()=>{o(void 0),n(y=>y.index>0?{...y,index:y.index-1}:y)},[]),f=S.useCallback(()=>{o(void 0),n(y=>y.index<y.stack.length-1?{...y,index:y.index+1}:y)},[]),h=S.useCallback(async()=>{const y=await wl(r,u);if(gl(y))return o(y.reason),{ok:!1,reason:y.reason};try{await e.onSave?.(y.source)}catch(p){const x=`Could not save: ${p}`;return o(x),{ok:!1,reason:x}}return i(y.source),l(u),o(void 0),{ok:!0}},[u,e,r]),v=S.useMemo(()=>JSON.stringify(u)!==JSON.stringify(a),[u,a]),g=S.useMemo(()=>{const y=new Set(a.tiles.map(go)),p=new Set(u.tiles.map(go));return[...y].some(x=>!p.has(x))||[...p].some(x=>!y.has(x))},[u,a]),w=S.useCallback(async()=>{const y=await wl(r,u);return gl(y)?{ok:!1,reason:y.reason}:{ok:!0,source:y.source}},[u,r]);return{document:u,source:r,canUndo:t.index>0,canRedo:t.index<t.stack.length-1,dirty:v,...s===void 0?{}:{error:s},update:c,undo:d,redo:f,save:h,preview:w,structural:g}}function wv({source:e,document:t,onSave:n,onChange:r,onDirtyChange:i,renderTile:s,controls:o,givens:a,catalog:l,toolbar:u,dashboards:c,onEvent:d,savesTo:f="package"}){const h=xv({source:e,document:t,...n?{onSave:n}:{}}),[v,g]=S.useState(void 0),[w,y]=S.useState(!1),p=h.document.columns??ju,{resize:x,gridBox:m,startResize:k,onResize:$,endResize:C}=Rm({tiles:h.document.tiles,columns:p,onStart:g,commit:(j,D)=>h.update(W=>{W.tiles[j].colspan=D})}),{dragging:M,preview:T,onDragStart:P,onDragOver:G,onDragEnd:R}=Im({tiles:h.document.tiles,commit:j=>h.update(D=>{D.tiles=j}),onLanded:g}),[O,_]=S.useState(void 0),[Y,me]=S.useState(void 0),[Ae,oe]=S.useState(!1),[Ne,Ue]=S.useState(void 0),[Ee,Ke]=S.useState(null),[Ve,_e]=S.useState(void 0);S.useEffect(()=>{r?.(h.document)},[h.document,r]),S.useEffect(()=>{i?.(h.dirty)},[h.dirty,i]);const Be=S.useMemo(()=>Pg(h.document),[h.document]),Ce=S.useMemo(()=>{const j=new Set((t.localGivens??[]).map(D=>D.name));return(a??[]).filter(D=>!j.has(D.name))},[t,a]),xe=S.useMemo(()=>ng(h.document,Ce),[h.document,Ce]),I=S.useMemo(()=>new Map(h.document.sources.map(j=>[j.name,Ba(l,j.base)])),[l,h.document.sources]),F=S.useCallback(j=>I.get(j.source)??Ba(l,j.source),[I,l]),$e=(j,D)=>{const W=[];for(const Z of h.document.tiles){const it=F(Z);if(!it)continue;const je=new Map(it.map(se=>[se.name,se.type]));for(const se of Z.filters??[])se.given===j&&(!je.has(se.field)||!vi(D,je.get(se.field)))&&W.push(`${se.field} on ${Z.label??Z.name} (${h.document.sources.find(Ie=>Ie.name===Z.source)?.base??Z.source})`)}return W},B=S.useMemo(()=>xe.filter(j=>j.origin==="model"&&j.boundTiles===0),[xe]),Fe=S.useCallback(()=>{_e(void 0),y(!0);const j=yn(),{structural:D}=h,W=h.document.tiles.length;h.save().then(Z=>{Z.ok===!0?d?.({type:"dashboard.saved",tiles:W,structural:D,where:f,durationMs:yn()-j}):d?.({type:"dashboard.save_refused",reason:Z.reason})}).finally(()=>y(!1))},[h,d,f]),ee=S.useCallback(()=>{if(!(!n||!h.dirty||w)){if(!h.structural){Fe();return}h.preview().then(j=>{j.ok?_e({before:h.source,after:j.source}):Fe()})}},[n,h,w,Fe]),ct=j=>{oe(!1),h.update(D=>{let W=D.sources.find(je=>je.base===j.base);if(!W){const je=new Set(D.sources.map(Ie=>Ie.name));let se=`${j.base}_tiles`;for(let Ie=2;je.has(se);Ie++)se=`${j.base}_tiles_${Ie}`;W={name:se,base:j.base},D.sources.push(W)}const Z=new Set(D.tiles.filter(je=>je.source===W.name).map(je=>je.name));let it=`${j.view}_tile`;for(let je=2;Z.has(it);je++)it=`${j.view}_tile_${je}`;D.tiles.push({name:it,source:W.name,declaration:{kind:"reference",from:j.view},colspan:j.colspan,...j.label?{label:j.label}:{}})}),g(h.document.tiles.length)},He=j=>{me(void 0),g(void 0),h.update(D=>{D.tiles.splice(j,1)})};mg(S.useMemo(()=>({undo:h.undo,redo:h.redo,...n?{save:ee}:{},escape:()=>{!Y&&!O&&g(void 0)},nudge:j=>{if(v===void 0)return;const D=h.document.tiles[v];if(!D||D.declaration.kind==="inherited")return;const W=Math.min(Math.max((D.colspan??1)+j,1),p);W!==(D.colspan??1)&&h.update(Z=>{Z.tiles[v].colspan=W})}}),[h,n,ee,Y,O,v,p]));const St=(j,D,W)=>{_(void 0),h.update(Z=>{W&&cg(Z,W),lg(Z,j,D)})},E=j=>{_(void 0),h.update(D=>dg(D,j))},A=(()=>{const j=h.document.tiles;return x!==void 0?j.map((D,W)=>W===x.index?{...D,colspan:x.span}:D):T??j})(),H=M?Lg(A,p):A.map(tu);return b.jsxs(he,{sx:{gap:0},children:[b.jsx(vg,{canUndo:h.canUndo,canRedo:h.canRedo,onUndo:h.undo,onRedo:h.redo,dirty:h.dirty,saving:w,...n?{onSave:ee}:{},...u?{actions:u}:{},...l?{onAddTile:()=>oe(!0)}:{},onSettings:Ke}),b.jsxs(he,{sx:{gap:2,px:"4px",pb:"4px"},children:[b.jsx(Cu,{title:h.document.title||"Untitled dashboard",...h.document.description?{description:h.document.description}:{}}),b.jsx(Rg,{controls:xe,tileCount:h.document.tiles.length,unknownFieldsOf:$e,onEdit:j=>_({control:j}),onAdd:()=>_({}),children:o}),h.error&&b.jsx(Wt,{severity:"warning",children:h.error}),b.jsx(Np,{sensors:mm,onDragStart:P,onDragOver:G,onDragEnd:R,children:b.jsxs(pe,{ref:m,sx:{position:"relative"},children:[(x!==void 0||M)&&b.jsx(jm,{columns:p}),b.jsx(Ou,{tiles:H,columns:p,keyOf:j=>j.kind==="gap"?nu(j.after):mt(j.tile),renderTile:j=>{if(j.kind==="gap")return b.jsx($m,{after:j.after});const{tile:D,index:W}=j;return b.jsx(km,{tile:D,index:W,selected:W===v,menuOpen:Y?.index===W,resizeSpan:x?.index===W?x.span:void 0,columns:p,onSelect:()=>g(W),onOpenMenu:Z=>{g(W),me({anchor:Z,index:W})},onResizeStart:Z=>k(Z,W),onResizeMove:$,onResizeEnd:C,children:s?s(D):b.jsx(Sm,{tile:D})})}})]})}),b.jsx(Tg,{open:O!==void 0,document:h.document,...O?.control?{control:O.control}:{},available:B,...l?{fieldsFor:F}:{},onClose:()=>_(void 0),onApply:St,onRemove:E}),b.jsx(Wm,{anchor:Y?.anchor??null,tile:Y===void 0?void 0:h.document.tiles[Y.index],onClose:()=>me(void 0),onCommit:j=>{const D=Y?.index;D!==void 0&&h.update(W=>{W.tiles[D]=j})},onRemove:()=>{Y!==void 0&&He(Y.index)},columns:p,onDrills:()=>{Y!==void 0&&Ue(h.document.tiles[Y.index]?.source)}}),b.jsx(Eg,{open:Ne!==void 0,document:h.document,source:h.document.sources.find(j=>j.name===Ne),givenNames:xe.map(j=>j.name),dashboards:c??[],onClose:()=>Ue(void 0),onApply:j=>h.update(D=>{const W=[...(D.drills??[]).filter(Z=>Z.source!==Ne),...j];W.length===0?delete D.drills:D.drills=W})}),b.jsx(Ag,{anchor:Ee,settings:Be,onClose:()=>Ke(null),onCommit:j=>h.update(D=>{D.title=j.title,j.description===void 0?delete D.description:D.description=j.description,j.columns===void 0?delete D.columns:D.columns=j.columns,j.autorun===void 0?delete D.autorun:D.autorun=j.autorun})}),b.jsx(jg,{open:Ae,document:h.document,catalog:l,columns:p,onClose:()=>oe(!1),onAdd:ct}),b.jsx(Mg,{open:Ve!==void 0,before:Ve?.before??"",after:Ve?.after??"",onConfirm:Fe,onClose:()=>_e(void 0)})]})]})}function kv(e,t){const n=new Set;for(const s of e.tiles)for(const o of s.filters??[])n.add(o.given);const r=[],i=new Set;for(const s of e.localGivens??[])n.has(s.name)&&(i.add(s.name),r.push(Sv(s)));for(const s of t)s.name===void 0||i.has(s.name)||!n.has(s.name)||(i.add(s.name),r.push(s));return r}function Sv(e){return{name:e.name,type:e.type,default:e.default,...e.label===void 0?{}:{label:e.label},...e.description===void 0?{}:{description:e.description},...e.control===void 0?{}:{control:e.control},...e.suggest?{suggest:{...e.suggest.source===void 0?{}:{source:e.suggest.source},...e.suggest.query===void 0?{}:{query:e.suggest.query},dimension:e.suggest.dimension}}:{},...e.rangeMin===void 0?{}:{rangeMin:e.rangeMin},...e.rangeMax===void 0?{}:{rangeMax:e.rangeMax}}}function $v(e,t,n,r=new Map){if(t.declaration.kind==="inherited")return{expression:`${t.source} -> ${t.name}`,givenNames:void 0};const i=t.source,s=t.declaration.kind==="reference"?t.declaration.from:t.name,o=new Map((e.localGivens??[]).map(c=>[c.name,c.type])),a=[],l=[];for(const c of t.filters??[]){const d=`where: ${c.field} ${c.op??"~"}`;if(n.has(c.given)){a.push(c.given),l.push(`${d} $${c.given}`);continue}if(!o.has(c.given))continue;const f=Ju(r.get(c.given),o.get(c.given));f!==void 0&&l.push(`${d} ${f}`)}const u=l.join(", ");return{expression:`${i} -> ${s}`+(u?` + { ${u} }`:""),givenNames:a}}async function jv(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}const kl=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function Tv(e){const{onExit:t,onEvent:n,onDirtyChange:r}=e,i=(()=>{if("resourceUri"in e)try{return Mu(e.resourceUri)}catch{return}})(),s="resourceUri"in e?i?.environmentName??"":e.environmentName,o="resourceUri"in e?i?.packageName??"":e.packageName,a="resourceUri"in e?e.dashboard:e.dashboardName,l=i?.versionId,u="resourceUri"in e?!!i?.environmentName&&!!i?.packageName:!0,{apiClients:c,mutable:d}=$l(),f=Eu(),h=S.useRef(yn()),v=S.useRef(n);v.current=n;const g=S.useRef(r);g.current=r;const w=Du()?.documentStorage,y=`dashboards/${a}.malloy`,p=ri({queryKey:["dashboard-editor-model",s,o,y,l],queryFn:()=>c.models.getModel(s,o,y,l),enabled:u}),x=p.data?.data?.sourceText,[m,k]=S.useState(void 0),[$,C]=S.useState(void 0),[M,T]=S.useState(w===void 0),[P,G]=S.useState(!1),[R,O]=S.useState(void 0);S.useEffect(()=>{if(!w)return;let X=!1;return O(void 0),(async()=>{try{const z=await w.listWorkspaces(!1),J=z.find(K=>K.authoritative)??z.find(K=>K.writeable);if(X)return;if(k(J),J!==void 0){const K=await w.getDocument(kl(J.name,s,o,y)).catch(te=>{if(!xa(te))throw te});if(X)return;C(K),G(K!==void 0)}}catch(z){if(X)return;O(Sl(z))}X||T(!0)})(),()=>{X=!0}},[w,s,o,y]);const _=m?.authoritative===!0,Y=_&&R!==void 0,[me,Ae]=S.useState(void 0),oe=(_||me===!0)&&$!==void 0,[Ne,Ue]=S.useState(void 0),[Ee,Ke]=S.useState(void 0),Ve=S.useRef(void 0),_e=S.useRef(void 0),[Be,Ce]=S.useState(void 0),xe=p.dataUpdatedAt,I=S.useRef(xe);I.current=xe;const F=Be!==void 0&&Be.onFetch===xe?Be.text:x,$e=S.useRef(F);$e.current=F;const B=oe?$:F,[Fe,ee]=S.useState(!1),[ct,He]=S.useState(void 0),[St,E]=S.useState(void 0),A=B!==void 0&&B!==St,H=Ne?.source,j=A&&Fe&&H!==void 0&&B!==ct,D=j?H:A?B:H??B,W=j?B:void 0,Z=S.useRef(H);Z.current=H;const it=S.useRef(B);it.current=B;const je=S.useRef("package");je.current=oe?_?"record":"draft":"package",S.useEffect(()=>{if(D===void 0||!M||Y||D===Z.current)return;let X=!1;const z=$e.current,J=it.current;return po(D).then(K=>{if(!X){if(ho(K)){const te=K.line?`${K.reason} (line ${K.line})`:K.reason;Ke(te),v.current?.({type:"dashboard.open_refused",reason:te});return}Ke(void 0),Ve.current=void 0,_e.current=z,Ce(void 0),He(void 0),E(J),Ue(te=>({source:D,document:K.document,generation:(te?.generation??0)+1})),v.current?.({type:"dashboard.opened",from:je.current,tiles:K.document.tiles.length,durationMs:yn()-h.current})}}),()=>{X=!0}},[D,M,Y]);const se=m===void 0?void 0:kl(m.name,s,o,y),Ie=S.useCallback(async X=>{if(!w||!se)throw new Error("This host keeps no documents, so there is nowhere to save.");await w.saveDocument(se,X),Ue(z=>z&&{...z,source:X}),C(X),(_||me===!0)&&E(X),_||Ae(z=>z??!1)},[w,se,_,me]),[Vn,At]=S.useState(void 0),Fr=S.useCallback(async X=>{const z=_e.current,J=Ve.current??(z===void 0?void 0:await jv(z));if(J===void 0)throw new Error("The package file is still loading; try again.");let K;try{K=await c.models.updateModelSource(s,o,y,{source:X,expectedHash:J})}catch(te){throw f.invalidateQueries({queryKey:["dashboard-editor-model",s,o,y,l]}),new Error(Mv(te))}if(Ue(te=>te&&{...te,source:X}),Ce({text:X,onFetch:I.current}),E(X),Ve.current=K.data.contentHash,At(void 0),w&&se)try{await w.deleteDocument(se),C(void 0),G(!1)}catch(te){xa(te)?(C(void 0),G(!1)):At(Sl(te))}Ae(!1),await f.invalidateQueries({queryKey:["dashboard-editor-model",s,o,y,l]});for(const te of["dashboard-editor-manifest","dashboards","dashboard"])f.invalidateQueries({queryKey:[te]})},[c,s,o,y,l,w,se,f]),It=_?"host":d?"package":"browser",nn=m?.writeable===!0,Gn=l!==void 0&&It==="package",Ji=R===void 0?_?w&&se&&nn?Ie:void 0:Gn?void 0:d?Fr:w&&se&&nn?Ie:void 0:void 0,rn=m?.name,es=S.useCallback(X=>{v.current?.(X.type==="dashboard.saved"&&X.where!=="package"&&rn!==void 0?{...X,workspace:rn}:X)},[rn]),Yn=S.useCallback(X=>{ee(X),g.current?.(X)},[]),Hr=X=>{h.current=yn(),He(X?$:F),Ae(X)},qr=()=>{h.current=yn(),He(W)};return!u&&"resourceUri"in e?b.jsxs(Wt,{severity:"error",sx:{m:2},children:["A dashboard resource URI must name an environment and a package. Received: ",e.resourceUri]}):p.isError?b.jsx(Tu,{error:p.error,context:"Opening the dashboard"}):!x||!M?b.jsxs(he,{sx:{gap:2},children:[b.jsx(jl,{}),b.jsx(Pu,{text:"Opening the dashboard…"})]}):Y?b.jsxs(Wt,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened: ",R]}):Ee?b.jsxs(Wt,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened in the builder: ",Ee]}):b.jsxs(he,{sx:{gap:2},children:[!_&&P&&$!==void 0&&$!==x&&me===void 0&&b.jsx(Wt,{severity:"info",action:b.jsxs(he,{direction:"row",sx:{gap:1},children:[b.jsx(ke,{size:"small",onClick:()=>Hr(!0),children:"Resume"}),b.jsx(ke,{size:"small",onClick:()=>Hr(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),W!==void 0&&b.jsx(Wt,{severity:"warning",action:b.jsx(ke,{size:"small",onClick:qr,children:"Load it"}),children:It==="package"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and until you do, saving is refused.":It==="host"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it.":"The package's copy of this dashboard changed since you opened it. Your edits are still here; loading the new version replaces them."}),Vn!==void 0&&b.jsxs(Wt,{severity:"warning",children:["The file was saved into the package, but the copy kept beside it could not be cleared, so it will be offered again:"," ",Vn]}),Ne&&b.jsx(Ov,{environmentName:s,packageName:o,modelPath:y,slug:a,...l!==void 0?{versionId:l}:{},opened:Ne,onSave:Ji,onDirtyChange:Yn,savesTo:It,...n?{onEvent:es}:{},toolbar:t&&b.jsx(Cl,{label:"Done editing",icon:b.jsx(Au,{}),onClick:t}),note:Cv({authoritative:_,mutable:d,pinnedPackageSave:Gn,...m?{workspace:m}:{},...R!==void 0?{readFailure:R}:{},...l!==void 0?{versionId:l}:{}})},Ne.generation)]})}function Cv({authoritative:e,mutable:t,pinnedPackageSave:n,workspace:r,readFailure:i,versionId:s}){return i!==void 0?`The saved copy could not be read, so Save is off: ${i}`:e&&r?r.writeable?r.description:`${r.description}: you cannot save into it.`:n?`Reading version ${s}: a version is a fixed point in history, so Save is off.`:t?"Save writes the file into the package.":r?`${r.description}: this server does not take writes.`:"This server does not take writes."}function Ov({environmentName:e,packageName:t,modelPath:n,slug:r,versionId:i,opened:s,onSave:o,onDirtyChange:a,onEvent:l,savesTo:u,toolbar:c,note:d}){const{apiClients:f}=$l(),{data:h,isSuccess:v}=ri({queryKey:["dashboard-editor-manifest",e,t,r,i],queryFn:()=>f.dashboards.getDashboard(e,t,r,i)}),g=h?.data,{data:w}=ri({queryKey:["dashboard-editor-dashboards",e,t,i],queryFn:()=>f.dashboards.listDashboards(e,t,i)}),y=S.useMemo(()=>(w?.data??[]).map(O=>O.name).filter(O=>!!O&&O!==r),[w,r]),p=S.useMemo(()=>{const O=n.slice(0,n.lastIndexOf("/")+1);return s.document.imports.map(_=>({..._,path:new URL(_.from,`https://malloy.invalid/${O}`).pathname.slice(1)}))},[s.document.imports,n]),{data:x}=ri({queryKey:["dashboard-editor-catalog",e,t,...p.map(O=>O.path),i],queryFn:async()=>{const O=(await f.models.listModels(e,t,i)).data.filter(Y=>Y.path&&!Y.error),_=(await Promise.allSettled(O.map(Y=>f.models.getModel(e,t,Y.path,i).then(me=>me.data)))).flatMap(Y=>Y.status==="fulfilled"?[Y.value]:[]);return Sg(kg(_),p,_)},enabled:p.length>0}),[m,k]=S.useState(s.document);S.useEffect(()=>k(s.document),[s.document]);const $=S.useMemo(()=>g?.givens??[],[g]),C=S.useMemo(()=>new Set($.map(O=>O.name).filter(O=>O!==void 0)),[$]),M=S.useMemo(()=>kv(m,$),[m,$]),{declaredTypes:T,applied:P,panel:G}=Fu({specs:M,loaded:v,startingValues:g?.startingGivens,documentKey:`${e}/${t}/${i??""}/${r}/edit`,autorun:g?.autorun!==!1,environmentName:e,packageName:t,modelPath:g?.path,versionId:i,documentName:r}),R=S.useMemo(()=>function(O){const _=$v(m,O,C,P);return b.jsx(Hu,{environmentName:e,packageName:t,versionId:i,modelPath:n,tile:_.expression,label:O.label??Uu(`${O.source} -> ${O.name}`),subtitle:O.subtitle,borderless:O.borderless,givens:P,declaredTypes:T,givenNames:_.givenNames,height:qu})},[m,C,e,t,i,n,P,T]);return b.jsxs(he,{sx:{gap:1},children:[b.jsx(wv,{source:s.source,document:s.document,renderTile:R,givens:M.filter(O=>O.name!==void 0).map(O=>({name:O.name,...O.label?{label:O.label}:{},...O.type?{type:O.type}:{},...O.suggest?.dimension?{field:O.suggest.dimension}:{}})),onChange:k,onDirtyChange:a,...x?{catalog:x}:{},dashboards:y,...l?{onEvent:l}:{},toolbar:c,controls:v?b.jsx(Vu,{...G,layout:"bar"}):void 0,...o?{onSave:o}:{},savesTo:u}),b.jsx(pe,{sx:{px:.5},children:b.jsx(ne,{variant:"caption",sx:{opacity:.7},children:d})})]})}function Sl(e){return e instanceof Error?e.message:String(e)}function Mv(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}typeof globalThis.process>"u"?globalThis.process={env:{}}:ka===void 0&&(ka={});export{wv as DashboardBuilder,Tv as DashboardEditor,kg as buildCatalog,po as readDashboardDocument,ho as readFailed,wl as spliceDashboardDocument,gl as spliceFailed};