@malloy-publisher/app 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Bzqs2UuN.js","assets/index-C1qGlR2a.js","assets/index-DUqldpo0.css","assets/index-w_0OQJgZ.js","assets/index-CRAwrhYM.js","assets/index-C5hv_y6G.js"])))=>i.map(i=>d[i]);
2
- import{r as S,aM as wu,aN as yn,j as b,aa as he,aO as ku,at as Wt,N as pe,aP as Su,aQ as ju,U as kl,ar as $u,aR as Ou,aS as ri,aT as ya,aU as Mu,a4 as Sl,a0 as Cu,ay as ke,a5 as jl,aV as Eu,a8 as $l,aW as Du,aX as ii,G as tt,aY as Ol,aZ as Zt,a_ as xs,H as kn,I as ws,O as go,T as ne,a$ as Pu,b0 as Tu,ax as zi,am as Pe,aq as bt,b1 as ks,an as Ml,Y as Cl,b2 as Au,b3 as Iu,Q as Ru,W as Wu,b4 as zu,b5 as Lu,b6 as Nu,b7 as Fu,b8 as _u,b9 as Ss,ba as qu,bb as Hu,aI as Uu}from"./index-C1qGlR2a.js";import{T as Yu,a as xa}from"./ToggleButtonGroup-Dl_oTC8r.js";var wa={},Gu=Symbol.for("preact-signals");function Li(){if(yt>1)yt--;else{var e,t=!1;for((function(){var i=xi;for(xi=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,yi++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Dl(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(yi=0,yt--,t)throw e}}function de(e){if(yt>0)return e();js=++Vu,yt++;try{return e()}finally{Li()}}var fr,ie=void 0;function H(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,yi=0,Vu=0,js=0,xi=void 0,wi=0;function El(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=Gu;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:H(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&&H(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;H(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 H(function(){return e.value})};Object.defineProperty(Le.prototype,"value",{get:function(){var e=El(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(yi>100)throw new Error("Cycle detected");(function(n){yt!==0&&yi===0&&n.l!==js&&(n.l=js,xi={S:n,v:n.v,i:n.i,o:xi})})(this),this.v=e,this.i++,wi++,yt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Li()}}}});function An(e,t){return new Le(e,t)}function Dl(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 Pl(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 Tl(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 Jt(e,t){Le.call(this,void 0,t),this.x=e,this.s=void 0,this.g=wi-1,this.f=4}Jt.prototype=new Le;Jt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===wi))return!0;if(this.g=wi,this.f|=1,this.i>0&&!Dl(this))return this.f&=-2,!0;var e=ie;try{Pl(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,Tl(this),this.f&=-2,!0};Jt.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)};Jt.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)}};Jt.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(Jt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=El(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function ka(e,t){return new Jt(e,t)}function Al(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,mo(e),r}finally{ie=n,Li()}}}function mo(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Al(e)}function Ku(e){if(ie!==this)throw new Error("Out-of-order effect");Tl(this),ie=e,this.f&=-2,8&this.f&&mo(this),Li()}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,Al(this),Pl(this),yt++;var e=ie;return ie=this,Ku.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||mo(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 Xu=Object.create,vo=Object.defineProperty,Bu=Object.defineProperties,Zu=Object.getOwnPropertyDescriptor,Ju=Object.getOwnPropertyDescriptors,Sa=Object.getOwnPropertySymbols,Qu=Object.prototype.hasOwnProperty,eh=Object.prototype.propertyIsEnumerable,th=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Rn=e=>{throw TypeError(e)},$s=(e,t,n)=>t in e?vo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nh=(e,t)=>{for(var n in t||(t={}))Qu.call(t,n)&&$s(e,n,t[n]);if(Sa)for(var n of Sa(t))eh.call(t,n)&&$s(e,n,t[n]);return e},rh=(e,t)=>Bu(e,Ju(t)),ja=(e,t)=>vo(e,"name",{value:t,configurable:!0}),ih=e=>{var t;return[,,,Xu((t=void 0)!=null?t:null)]},Il=["class","method","getter","setter","accessor","field","value","get","set"],Zn=e=>e!==void 0&&typeof e!="function"?Rn("Function expected"):e,sh=(e,t,n,r,i)=>({kind:Il[e],name:t,metadata:r,addInitializer:s=>n._?Rn("Already initialized"):i.push(Zn(s||null))}),Rl=(e,t)=>$s(t,th("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),m=d>3?e.length+1:d?f?1:2:0,g=Il[d+5],w=d>3&&(e[m-1]=[]),y=e[m]||(e[m]=[]),p=d&&(!h&&!f&&(i=i.prototype),d<5&&(d>3||!h)&&Zu(d<4?i:{get[n](){return Ze(this,s)},set[n](v){return Ot(this,s,v)}},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=sh(d,n,l={},e[3],y),d&&(u.static=f,u.private=h,c=u.access={has:h?v=>oh(i,v):v=>n in v},d^3&&(c.get=h?v=>(d^1?Ze:ah)(v,i,d^4?s:p.get):v=>v[n]),d>2&&(c.set=h?(v,k)=>Ot(v,i,k,d^4?s:p.set):(v,k)=>v[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?Zn(a)&&(d>4?w.unshift(a):d?h?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Rn("Object expected"):(Zn(o=a.get)&&(p.get=o),Zn(o=a.set)&&(p.set=o),Zn(o=a.init)&&w.unshift(o));return d||Rl(e,i),p&&vo(i,n,p),h?d^4?s:p:i},bo=(e,t,n)=>t.has(e)||Rn("Cannot "+n),oh=(e,t)=>Object(t)!==t?Rn('Cannot use the "in" operator on this value'):e.has(t),Ze=(e,t,n)=>(bo(e,t,"read from private field"),n?n.call(e):t.get(e)),Jn=(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),Ot=(e,t,n,r)=>(bo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ah=(e,t,n)=>(bo(e,t,"access private method"),n);function Os(e,t){if(t){let n;return ka(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return ka(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 ns(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,rh(nh({},i),{enumerable:e}))})}}function Dr(...e){const t=e.map(n=>nt(n));return()=>t.forEach(n=>n())}var Wl,zl,Ll,Nl,Fl,_l,Re,yo,rs,Ms,Cs,De,xo,is,ql,Es,wo,ss,Ds,Ps;_l=[U],Fl=[U],Nl=[U],Ll=[ns()],zl=[ns()],Wl=[ns()];var Qt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Rt(Re,5,this),Jn(this,De),Jn(this,yo,Rt(Re,8,this)),Rt(Re,11,this),Jn(this,xo,Rt(Re,12,this)),Rt(Re,15,this),Jn(this,wo,Rt(Re,16,this)),Rt(Re,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Ze(this,De,Ds)}get initial(){return Ze(this,De,Ms)}get previous(){return Ze(this,De,ql)}set current(e){const t=H(()=>Ze(this,De,Ds));e&&t&&this.equals(t,e)||de(()=>{Ze(this,De,Ms)||Ot(this,De,e,Cs),Ot(this,De,t,Es),Ot(this,De,e,Ps)})}reset(e=this.defaultValue){de(()=>{Ot(this,De,void 0,Es),Ot(this,De,e,Cs),Ot(this,De,e,Ps)})}};Re=ih();yo=new WeakMap;De=new WeakSet;xo=new WeakMap;wo=new WeakMap;rs=Wn(Re,20,"#initial",_l,De,yo),Ms=rs.get,Cs=rs.set;is=Wn(Re,20,"#previous",Fl,De,xo),ql=is.get,Es=is.set;ss=Wn(Re,20,"#current",Nl,De,wo),Ds=ss.get,Ps=ss.set;Wn(Re,2,"current",Ll,Qt);Wn(Re,2,"initial",zl,Qt);Wn(Re,2,"previous",Wl,Qt);Rl(Re,Qt);function os(e){return H(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var zt,lh=class{constructor(){Jn(this,zt,new WeakMap)}get(e,t){var n;return e?(n=Ze(this,zt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Ze(this,zt).has(e)||Ze(this,zt).set(e,new Map),(r=Ze(this,zt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Ze(this,zt).get(e))==null?void 0:t.clear():void 0}};zt=new WeakMap;var ch=Object.create,Hl=Object.defineProperty,dh=Object.getOwnPropertyDescriptor,$a=Object.getOwnPropertySymbols,uh=Object.prototype.hasOwnProperty,hh=Object.prototype.propertyIsEnumerable,Ul=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ni=e=>{throw TypeError(e)},Oa=Math.pow,Ts=(e,t,n)=>t in e?Hl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fh=(e,t)=>{for(var n in t||(t={}))uh.call(t,n)&&Ts(e,n,t[n]);if($a)for(var n of $a(t))hh.call(t,n)&&Ts(e,n,t[n]);return e},ph=e=>{var t;return[,,,ch((t=e?.[Ul("metadata")])!=null?t:null)]},Yl=["class","method","getter","setter","accessor","field","value","get","set"],Gl=e=>e!==void 0&&typeof e!="function"?Ni("Function expected"):e,gh=(e,t,n,r,i)=>({kind:Yl[e],name:t,metadata:r,addInitializer:s=>n._?Ni("Already initialized"):i.push(Gl(s||null))}),mh=(e,t)=>Ts(t,Ul("metadata"),e[3]),vh=(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},Vl=(e,t,n,r,i,s)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,h=2,m=Yl[c+5],g=e[h]||(e[h]=[]),w=(i=i.prototype,dh(i,n)),y=r.length-1;y>=0;y--)l=gh(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[m],l),a._=1,Gl(o)&&(w[m]=o);return w&&Hl(i,n,w),i},Kl=(e,t,n)=>t.has(e)||Ni("Cannot "+n),bh=(e,t,n)=>(Kl(e,t,"read from private field"),t.get(e)),yh=(e,t,n)=>t.has(e)?Ni("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),xh=(e,t,n,r)=>(Kl(e,t,"write to private field"),t.set(e,n),n),Je=class As{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new As(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 As(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=fh({},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 Je((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?wh(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 Je.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 wh(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 Xl,Bl,Is,si,Pr,Fi=class extends(Is=Qt,Bl=[fe],Xl=[fe],Is){constructor(e){const t=Je.from(e);super(t,(n,r)=>Je.equals(n,r)),vh(Pr,5,this),yh(this,si,0),this.velocity={x:0,y:0}}get delta(){return Je.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=Je.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-bh(this,si),o=a=>Math.round(a/s*100);de(()=>{xh(this,si,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Je.from(e)),this.velocity={x:0,y:0}}};Pr=ph(Is);si=new WeakMap;Vl(Pr,2,"delta",Bl,Fi);Vl(Pr,2,"direction",Xl,Fi);mh(Pr,Fi);function Rs({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 Zl=(e=>(e.Horizontal="x",e.Vertical="y",e))(Zl||{}),Jl=Object.values(Zl),kh=Object.create,ko=Object.defineProperty,Sh=Object.defineProperties,jh=Object.getOwnPropertyDescriptor,$h=Object.getOwnPropertyDescriptors,ki=Object.getOwnPropertySymbols,Ql=Object.prototype.hasOwnProperty,ec=Object.prototype.propertyIsEnumerable,tc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),zn=e=>{throw TypeError(e)},Ws=(e,t,n)=>t in e?ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,So=(e,t)=>{for(var n in t||(t={}))Ql.call(t,n)&&Ws(e,n,t[n]);if(ki)for(var n of ki(t))ec.call(t,n)&&Ws(e,n,t[n]);return e},jo=(e,t)=>Sh(e,$h(t)),Ma=(e,t)=>ko(e,"name",{value:t,configurable:!0}),nc=(e,t)=>{var n={};for(var r in e)Ql.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ki)for(var r of ki(e))t.indexOf(r)<0&&ec.call(e,r)&&(n[r]=e[r]);return n},Ln=e=>{var t;return[,,,kh((t=e?.[tc("metadata")])!=null?t:null)]},rc=["class","method","getter","setter","accessor","field","value","get","set"],Qn=e=>e!==void 0&&typeof e!="function"?zn("Function expected"):e,Oh=(e,t,n,r,i)=>({kind:rc[e],name:t,metadata:r,addInitializer:s=>n._?zn("Already initialized"):i.push(Qn(s||null))}),en=(e,t)=>Ws(t,tc("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},Y=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),h=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,g=rc[d+5],w=d>3&&(e[m-1]=[]),y=e[m]||(e[m]=[]),p=d&&(!h&&!f&&(i=i.prototype),d<5&&(d>3||!h)&&jh(d<4?i:{get[n](){return ue(this,s)},set[n](v){return Ve(this,s,v)}},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=Oh(d,n,l={},e[3],y),d&&(u.static=f,u.private=h,c=u.access={has:h?v=>Mh(i,v):v=>n in v},d^3&&(c.get=h?v=>(d^1?ue:ic)(v,i,d^4?s:p.get):v=>v[n]),d>2&&(c.set=h?(v,k)=>Ve(v,i,k,d^4?s:p.set):(v,k)=>v[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?zn("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||en(e,i),p&&ko(i,n,p),h?d^4?s:p:i},$o=(e,t,n)=>t.has(e)||zn("Cannot "+n),Mh=(e,t)=>Object(t)!==t?zn('Cannot use the "in" operator on this value'):e.has(t),ue=(e,t,n)=>($o(e,t,"read from private field"),n?n.call(e):t.get(e)),B=(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),Ve=(e,t,n,r)=>($o(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ic=(e,t,n)=>($o(e,t,"access private method"),n);function sc(e,t){return{plugin:e,options:t}}function Tr(e){return t=>sc(e,t)}function xr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var oc,wr,Oo,oi;oc=[U];var Te=class{constructor(e,t){this.manager=e,this.options=t,B(this,Oo,N(wr,8,this,!1)),N(wr,11,this),B(this,oi,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return H(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=nt(e.bind(this));return ue(this,oi).add(t),t}destroy(){ue(this,oi).forEach(e=>e())}static configure(e){return sc(this,e)}};wr=Ln(null);Oo=new WeakMap;oi=new WeakMap;Y(wr,4,"disabled",oc,Te,Oo);en(wr,Te);var Ar=class extends Te{},ai,as=class{constructor(e){this.manager=e,this.instances=new Map,B(this,ai,[])}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,ai))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);Ve(this,ai,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()}};ai=new WeakMap;function Ch(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Yr=[],hn,fn,Eh=class extends Te{constructor(e){super(e),B(this,hn),B(this,fn),this.computeCollisions=this.computeCollisions.bind(this),Ve(this,fn,An(Yr)),this.destroy=Dr(()=>{const t=this.computeCollisions(),n=H(()=>this.manager.dragOperation.position.current);if(t!==Yr){const r=ue(this,hn);if(Ve(this,hn,n),r&&n.x==r.x&&n.y==r.y)return}else Ve(this,hn,void 0);ue(this,fn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){H(()=>{e?ue(this,fn).value=this.computeCollisions():Ve(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 Yr;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=H(()=>c({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return l.length===0?Yr:(a.sort(Ch),a)}get collisions(){return ue(this,fn).value}};hn=new WeakMap;fn=new WeakMap;var ac,lc,cc,Mo,dc,ot,Co,xn,Eo,Do;cc=[U],lc=[U],ac=[U];var wt=class Nt{constructor(t,n){B(this,Co,N(ot,8,this)),N(ot,11,this),B(this,xn),B(this,Eo,N(ot,12,this)),N(ot,15,this),B(this,Do,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;Ve(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 ic(s=Nt,Mo,dc).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;dc=function(){const e=wt.pendingIdChanges;wt.pendingIdChanges=null,e&&de(()=>{for(const[t,n]of e)ue(t,xn).value=n})};Co=new WeakMap;xn=new WeakMap;Eo=new WeakMap;Do=new WeakMap;Y(ot,4,"manager",cc,wt,Co);Y(ot,4,"data",lc,wt,Eo);Y(ot,4,"disabled",ac,wt,Do);B(wt,Mo);en(ot,wt);wt.pendingIdChanges=null;var _i=wt,Ca=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}},uc,hc,fc,pc,gc,mc,zs,We,Po,To,Ao,ft=class extends(zs=_i,mc=[U],gc=[U],pc=[U],fc=[fe],hc=[fe],uc=[fe],zs){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,l=nc(n,["modifiers","type","sensors","plugins","effects"]);super(jo(So({},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),B(this,Po,N(We,8,this)),N(We,11,this),B(this,To,N(We,12,this)),N(We,15,this),B(this,Ao,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(zs);Po=new WeakMap;To=new WeakMap;Ao=new WeakMap;Y(We,4,"type",mc,ft,Po);Y(We,4,"modifiers",gc,ft,To);Y(We,4,"status",pc,ft,Ao);Y(We,2,"isDropping",fc,ft);Y(We,2,"isDragging",hc,ft);Y(We,2,"isDragSource",uc,ft);en(We,ft);var vc,bc,yc,xc,wc,kc,Ls,we,Io,Ro,Wo,zo,Lo,pt=class extends(Ls=_i,kc=[U],wc=[U],xc=[U],yc=[U],bc=[U],vc=[fe],Ls){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=nc(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),N(we,5,this),B(this,Io,N(we,8,this)),N(we,11,this),B(this,Ro,N(we,12,this)),N(we,15,this),B(this,Wo,N(we,16,this)),N(we,19,this),B(this,zo,N(we,20,this)),N(we,23,this),B(this,Lo,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(Ls);Io=new WeakMap;Ro=new WeakMap;Wo=new WeakMap;zo=new WeakMap;Lo=new WeakMap;Y(we,4,"accept",kc,pt,Io);Y(we,4,"type",wc,pt,Ro);Y(we,4,"collisionDetector",xc,pt,Wo);Y(we,4,"collisionPriority",yc,pt,zo);Y(we,4,"shape",bc,pt,Lo);Y(we,2,"isDropTarget",vc,pt);en(we,pt);var Dh=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)}},Ph=class extends Dh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function li(e,t=!0){let n=!1;return jo(So({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Th=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()||_i.pendingIdChanges)return;const o=li({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;H(()=>{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||{}),Fn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Fn||{}),Sc,jc,$c,Oc,Mc,Cc,Ec,et,No;Ec=[U],Cc=[fe],Mc=[fe],Oc=[fe],$c=[fe],jc=[fe],Sc=[fe];var kt=class{constructor(){N(et,5,this),B(this,No,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);No=new WeakMap;Y(et,4,"value",Ec,kt,No);Y(et,2,"current",Cc,kt);Y(et,2,"idle",Mc,kt);Y(et,2,"initializing",Oc,kt);Y(et,2,"initialized",$c,kt);Y(et,2,"dragging",jc,kt);Y(et,2,"dropped",Sc,kt);en(et,kt);var Ah=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 H(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=li({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return H(()=>{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=li({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 H(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=li({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 H(()=>{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=H(()=>{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()})}},On=class extends Te{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Ih=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)}},ci,Dc=class{constructor(e){this.options=e,B(this,ci)}set controller(e){Ve(this,ci,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=ue(this,ci))==null||t.activate(e)}};ci=new WeakMap;var Ea=class extends Te{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Rh=class{constructor(e){this.draggables=new Ca,this.droppables=new Ca,this.plugins=new as(e),this.sensors=new as(e),this.modifiers=new as(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 Ea)return this.modifiers.register(e,t);if(e.prototype instanceof On)return this.sensors.register(e,t);if(e.prototype instanceof Te)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof _i)return e instanceof ft?this.draggables.unregister(e.id,e):e instanceof pt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Ea)return this.modifiers.unregister(e);if(e.prototype instanceof On)return this.sensors.unregister(e);if(e.prototype instanceof Te)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()}},Pc,Tc,Ac,Ic,Rc,Wc,zc,Lc,Nc,er,di,pn,le,Fo,_o,qo,Ho,Uo,tr;Nc=[fe],Lc=[U],zc=[U],Wc=[U],Rc=[U],Ic=[U],Ac=[fe],Tc=[fe],Pc=[fe];var lt=class{constructor(e){N(le,5,this),B(this,er),B(this,di),B(this,pn,new Qt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new kt,B(this,Fo,N(le,8,this,!1)),N(le,11,this),B(this,_o,N(le,12,this,null)),N(le,15,this),B(this,qo,N(le,16,this,null)),N(le,19,this),B(this,Ho,N(le,20,this,null)),N(le,23,this),B(this,Uo,N(le,24,this,[])),N(le,27,this),this.position=new Fi({x:0,y:0}),B(this,tr,{x:0,y:0}),Ve(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&&Ve(this,di,n),(e=n??ue(this,di))!=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(So({},this.snapshot()),{transform:n}));return Ve(this,tr,n),n}snapshot(){return H(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:ue(this,tr),shape:this.shape?os(this.shape):null,position:os(this.position),status:os(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}),Ve(this,tr,{x:0,y:0}),this.modifiers=[]})}};le=Ln(null);er=new WeakMap;di=new WeakMap;pn=new WeakMap;Fo=new WeakMap;_o=new WeakMap;qo=new WeakMap;Ho=new WeakMap;Uo=new WeakMap;tr=new WeakMap;Y(le,2,"shape",Nc,lt);Y(le,4,"canceled",Lc,lt,Fo);Y(le,4,"activatorEvent",zc,lt,_o);Y(le,4,"sourceIdentifier",Wc,lt,qo);Y(le,4,"targetIdentifier",Rc,lt,Ho);Y(le,4,"modifiers",Ic,lt,Uo);Y(le,2,"source",Ac,lt);Y(le,2,"target",Tc,lt);Y(le,2,"transform",Pc,lt);en(le,lt);var Wh={get rendering(){return Promise.resolve()}};function at(e,t){return typeof e=="function"?e(t):e??t}var zh=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:Wh,a=new Ph(this),l=new Rh(this);this.registry=l,this.monitor=a,this.renderer=o,this.actions=new Ah(this),this.dragOperation=new lt(this),this.collisionObserver=new Eh(this),this.plugins=[Th,...r],this.modifiers=s,this.sensors=i;const{destroy:u}=this,c=Dr(()=>{var d,f,h;const m=H(()=>this.dragOperation.modifiers),g=this.modifiers;for(const w of m)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}},Fc=e=>{throw TypeError(e)},Yo=(e,t,n)=>t.has(e)||Fc("Cannot "+n),L=(e,t,n)=>(Yo(e,t,"read from private field"),t.get(e)),He=(e,t,n)=>t.has(e)?Fc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ge=(e,t,n,r)=>(Yo(e,t,"write to private field"),t.set(e,n),n),_c=(e,t,n)=>(Yo(e,t,"access private method"),n);function qi(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function qc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(qi(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function Hi(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 Go(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ir(e){return"nodeType"in e}function Ke(e){var t,n,r;return e?Go(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 Vo(e){const{Document:t}=Ke(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Pt(e){return!e||Go(e)?!1:e instanceof Ke(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Hc(e){return e instanceof Ke(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function _n(e){return e?Go(e)?e.document:Ir(e)?Vo(e)?e:Pt(e)||Hc(e)?e.ownerDocument:document:document:document}function Lh(e){var t,n,r,i;const{documentElement:s}=_n(e),o=Ke(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 Nh(e,t){if(Fh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function Fh(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(!Nh(d)){const x=d.getBoundingClientRect(),v=n*(x.bottom-x.top),k=n*(x.right-x.left),j=n*(x.bottom-x.top),O=n*(x.right-x.left);l={top:Math.max(l.top,x.top-v),right:Math.min(l.right,x.right+k),bottom:Math.min(l.bottom,x.bottom+j),left:Math.max(l.left,x.left-O),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,m=(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,m+g+p),bottom:Math.min(l.bottom,h+w+y),left:Math.max(l.left,m-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 Mn(e){return{x:e.clientX,y:e.clientY}}var Uc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ns(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(...Ns(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(...Ns(i.document,t))}}catch{}return n}function Ko(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Yc(){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 Xo(e){return!e||!Ir(e)?!1:e instanceof Ke(e).ShadowRoot}function Si(e){if(e&&Ir(e)){let t=e.getRootNode();if(Xo(t)||t instanceof Document)return t}return _n(e)}function Bo(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function _h(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];Da(i)&&Da(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 Da(e){return"value"in e}function Pa(e){return e.tagName==="CANVAS"}function Gc(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(qh(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Gc(i,{x:t-s,y:n-o})}}return r}function qh(e){return e?.tagName==="IFRAME"}var Fs=new WeakMap;function Hh(e){return e.closest(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-xgxo45Xn.js","assets/index-CNQ_NxFx.js","assets/index-DUqldpo0.css","assets/index-w_0OQJgZ.js","assets/index-CRAwrhYM.js","assets/index-aXk5ykLp.js"])))=>i.map(i=>d[i]);
2
+ import{r as S,aM as ku,aN as yn,j as b,aa as he,aO as Su,at as Wt,N as pe,aP as ju,aQ as $u,U as kl,ar as Ou,aR as Mu,aS as ri,aT as ya,aU as Cu,a4 as Sl,a0 as Eu,ay as ke,a5 as jl,aV as Pu,a8 as $l,aW as Du,aX as ii,G as tt,aY as Ol,aZ as Zt,a_ as xs,H as kn,I as ws,O as go,T as ne,a$ as Tu,b0 as Au,ax as zi,am as De,aq as bt,b1 as ks,an as Ml,Y as Cl,b2 as Iu,b3 as Ru,Q as Wu,W as zu,b4 as Lu,b5 as Nu,b6 as _u,b7 as Fu,b8 as qu,b9 as Ss,ba as Hu,bb as Uu,aI as Yu}from"./index-CNQ_NxFx.js";import{T as Gu,a as xa}from"./ToggleButtonGroup-CxU1OIGN.js";var wa={},Vu=Symbol.for("preact-signals");function Li(){if(yt>1)yt--;else{var e,t=!1;for((function(){var i=xi;for(xi=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,yi++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Pl(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(yi=0,yt--,t)throw e}}function de(e){if(yt>0)return e();js=++Ku,yt++;try{return e()}finally{Li()}}var fr,ie=void 0;function H(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,yi=0,Ku=0,js=0,xi=void 0,wi=0;function El(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=Vu;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:H(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&&H(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;H(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 H(function(){return e.value})};Object.defineProperty(Le.prototype,"value",{get:function(){var e=El(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(yi>100)throw new Error("Cycle detected");(function(n){yt!==0&&yi===0&&n.l!==js&&(n.l=js,xi={S:n,v:n.v,i:n.i,o:xi})})(this),this.v=e,this.i++,wi++,yt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Li()}}}});function An(e,t){return new Le(e,t)}function Pl(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 Dl(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 Tl(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 Jt(e,t){Le.call(this,void 0,t),this.x=e,this.s=void 0,this.g=wi-1,this.f=4}Jt.prototype=new Le;Jt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===wi))return!0;if(this.g=wi,this.f|=1,this.i>0&&!Pl(this))return this.f&=-2,!0;var e=ie;try{Dl(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,Tl(this),this.f&=-2,!0};Jt.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)};Jt.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)}};Jt.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(Jt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=El(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function ka(e,t){return new Jt(e,t)}function Al(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,mo(e),r}finally{ie=n,Li()}}}function mo(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Al(e)}function Xu(e){if(ie!==this)throw new Error("Out-of-order effect");Tl(this),ie=e,this.f&=-2,8&this.f&&mo(this),Li()}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,Al(this),Dl(this),yt++;var e=ie;return ie=this,Xu.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||mo(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 Bu=Object.create,vo=Object.defineProperty,Zu=Object.defineProperties,Ju=Object.getOwnPropertyDescriptor,Qu=Object.getOwnPropertyDescriptors,Sa=Object.getOwnPropertySymbols,eh=Object.prototype.hasOwnProperty,th=Object.prototype.propertyIsEnumerable,nh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Rn=e=>{throw TypeError(e)},$s=(e,t,n)=>t in e?vo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rh=(e,t)=>{for(var n in t||(t={}))eh.call(t,n)&&$s(e,n,t[n]);if(Sa)for(var n of Sa(t))th.call(t,n)&&$s(e,n,t[n]);return e},ih=(e,t)=>Zu(e,Qu(t)),ja=(e,t)=>vo(e,"name",{value:t,configurable:!0}),sh=e=>{var t;return[,,,Bu((t=void 0)!=null?t:null)]},Il=["class","method","getter","setter","accessor","field","value","get","set"],Zn=e=>e!==void 0&&typeof e!="function"?Rn("Function expected"):e,oh=(e,t,n,r,i)=>({kind:Il[e],name:t,metadata:r,addInitializer:s=>n._?Rn("Already initialized"):i.push(Zn(s||null))}),Rl=(e,t)=>$s(t,nh("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),m=d>3?e.length+1:d?f?1:2:0,g=Il[d+5],w=d>3&&(e[m-1]=[]),y=e[m]||(e[m]=[]),p=d&&(!h&&!f&&(i=i.prototype),d<5&&(d>3||!h)&&Ju(d<4?i:{get[n](){return Ze(this,s)},set[n](v){return Ot(this,s,v)}},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=oh(d,n,l={},e[3],y),d&&(u.static=f,u.private=h,c=u.access={has:h?v=>ah(i,v):v=>n in v},d^3&&(c.get=h?v=>(d^1?Ze:lh)(v,i,d^4?s:p.get):v=>v[n]),d>2&&(c.set=h?(v,k)=>Ot(v,i,k,d^4?s:p.set):(v,k)=>v[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?Zn(a)&&(d>4?w.unshift(a):d?h?s=a:p[g]=a:i=a):typeof a!="object"||a===null?Rn("Object expected"):(Zn(o=a.get)&&(p.get=o),Zn(o=a.set)&&(p.set=o),Zn(o=a.init)&&w.unshift(o));return d||Rl(e,i),p&&vo(i,n,p),h?d^4?s:p:i},bo=(e,t,n)=>t.has(e)||Rn("Cannot "+n),ah=(e,t)=>Object(t)!==t?Rn('Cannot use the "in" operator on this value'):e.has(t),Ze=(e,t,n)=>(bo(e,t,"read from private field"),n?n.call(e):t.get(e)),Jn=(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),Ot=(e,t,n,r)=>(bo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),lh=(e,t,n)=>(bo(e,t,"access private method"),n);function Os(e,t){if(t){let n;return ka(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return ka(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 ns(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,ih(rh({},i),{enumerable:e}))})}}function Pr(...e){const t=e.map(n=>nt(n));return()=>t.forEach(n=>n())}var Wl,zl,Ll,Nl,_l,Fl,Re,yo,rs,Ms,Cs,Pe,xo,is,ql,Es,wo,ss,Ps,Ds;Fl=[U],_l=[U],Nl=[U],Ll=[ns()],zl=[ns()],Wl=[ns()];var Qt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Rt(Re,5,this),Jn(this,Pe),Jn(this,yo,Rt(Re,8,this)),Rt(Re,11,this),Jn(this,xo,Rt(Re,12,this)),Rt(Re,15,this),Jn(this,wo,Rt(Re,16,this)),Rt(Re,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Ze(this,Pe,Ps)}get initial(){return Ze(this,Pe,Ms)}get previous(){return Ze(this,Pe,ql)}set current(e){const t=H(()=>Ze(this,Pe,Ps));e&&t&&this.equals(t,e)||de(()=>{Ze(this,Pe,Ms)||Ot(this,Pe,e,Cs),Ot(this,Pe,t,Es),Ot(this,Pe,e,Ds)})}reset(e=this.defaultValue){de(()=>{Ot(this,Pe,void 0,Es),Ot(this,Pe,e,Cs),Ot(this,Pe,e,Ds)})}};Re=sh();yo=new WeakMap;Pe=new WeakSet;xo=new WeakMap;wo=new WeakMap;rs=Wn(Re,20,"#initial",Fl,Pe,yo),Ms=rs.get,Cs=rs.set;is=Wn(Re,20,"#previous",_l,Pe,xo),ql=is.get,Es=is.set;ss=Wn(Re,20,"#current",Nl,Pe,wo),Ps=ss.get,Ds=ss.set;Wn(Re,2,"current",Ll,Qt);Wn(Re,2,"initial",zl,Qt);Wn(Re,2,"previous",Wl,Qt);Rl(Re,Qt);function os(e){return H(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var zt,ch=class{constructor(){Jn(this,zt,new WeakMap)}get(e,t){var n;return e?(n=Ze(this,zt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Ze(this,zt).has(e)||Ze(this,zt).set(e,new Map),(r=Ze(this,zt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Ze(this,zt).get(e))==null?void 0:t.clear():void 0}};zt=new WeakMap;var dh=Object.create,Hl=Object.defineProperty,uh=Object.getOwnPropertyDescriptor,$a=Object.getOwnPropertySymbols,hh=Object.prototype.hasOwnProperty,fh=Object.prototype.propertyIsEnumerable,Ul=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ni=e=>{throw TypeError(e)},Oa=Math.pow,Ts=(e,t,n)=>t in e?Hl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ph=(e,t)=>{for(var n in t||(t={}))hh.call(t,n)&&Ts(e,n,t[n]);if($a)for(var n of $a(t))fh.call(t,n)&&Ts(e,n,t[n]);return e},gh=e=>{var t;return[,,,dh((t=e?.[Ul("metadata")])!=null?t:null)]},Yl=["class","method","getter","setter","accessor","field","value","get","set"],Gl=e=>e!==void 0&&typeof e!="function"?Ni("Function expected"):e,mh=(e,t,n,r,i)=>({kind:Yl[e],name:t,metadata:r,addInitializer:s=>n._?Ni("Already initialized"):i.push(Gl(s||null))}),vh=(e,t)=>Ts(t,Ul("metadata"),e[3]),bh=(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},Vl=(e,t,n,r,i,s)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,h=2,m=Yl[c+5],g=e[h]||(e[h]=[]),w=(i=i.prototype,uh(i,n)),y=r.length-1;y>=0;y--)l=mh(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[m],l),a._=1,Gl(o)&&(w[m]=o);return w&&Hl(i,n,w),i},Kl=(e,t,n)=>t.has(e)||Ni("Cannot "+n),yh=(e,t,n)=>(Kl(e,t,"read from private field"),t.get(e)),xh=(e,t,n)=>t.has(e)?Ni("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),wh=(e,t,n,r)=>(Kl(e,t,"write to private field"),t.set(e,n),n),Je=class As{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new As(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 As(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=ph({},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 Je((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?kh(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 Je.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 kh(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 Xl,Bl,Is,si,Dr,_i=class extends(Is=Qt,Bl=[fe],Xl=[fe],Is){constructor(e){const t=Je.from(e);super(t,(n,r)=>Je.equals(n,r)),bh(Dr,5,this),xh(this,si,0),this.velocity={x:0,y:0}}get delta(){return Je.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=Je.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-yh(this,si),o=a=>Math.round(a/s*100);de(()=>{wh(this,si,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Je.from(e)),this.velocity={x:0,y:0}}};Dr=gh(Is);si=new WeakMap;Vl(Dr,2,"delta",Bl,_i);Vl(Dr,2,"direction",Xl,_i);vh(Dr,_i);function Rs({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 Zl=(e=>(e.Horizontal="x",e.Vertical="y",e))(Zl||{}),Jl=Object.values(Zl),Sh=Object.create,ko=Object.defineProperty,jh=Object.defineProperties,$h=Object.getOwnPropertyDescriptor,Oh=Object.getOwnPropertyDescriptors,ki=Object.getOwnPropertySymbols,Ql=Object.prototype.hasOwnProperty,ec=Object.prototype.propertyIsEnumerable,tc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),zn=e=>{throw TypeError(e)},Ws=(e,t,n)=>t in e?ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,So=(e,t)=>{for(var n in t||(t={}))Ql.call(t,n)&&Ws(e,n,t[n]);if(ki)for(var n of ki(t))ec.call(t,n)&&Ws(e,n,t[n]);return e},jo=(e,t)=>jh(e,Oh(t)),Ma=(e,t)=>ko(e,"name",{value:t,configurable:!0}),nc=(e,t)=>{var n={};for(var r in e)Ql.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ki)for(var r of ki(e))t.indexOf(r)<0&&ec.call(e,r)&&(n[r]=e[r]);return n},Ln=e=>{var t;return[,,,Sh((t=e?.[tc("metadata")])!=null?t:null)]},rc=["class","method","getter","setter","accessor","field","value","get","set"],Qn=e=>e!==void 0&&typeof e!="function"?zn("Function expected"):e,Mh=(e,t,n,r,i)=>({kind:rc[e],name:t,metadata:r,addInitializer:s=>n._?zn("Already initialized"):i.push(Qn(s||null))}),en=(e,t)=>Ws(t,tc("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},Y=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,f=!!(t&8),h=!!(t&16),m=d>3?e.length+1:d?f?1:2:0,g=rc[d+5],w=d>3&&(e[m-1]=[]),y=e[m]||(e[m]=[]),p=d&&(!h&&!f&&(i=i.prototype),d<5&&(d>3||!h)&&$h(d<4?i:{get[n](){return ue(this,s)},set[n](v){return Ve(this,s,v)}},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=Mh(d,n,l={},e[3],y),d&&(u.static=f,u.private=h,c=u.access={has:h?v=>Ch(i,v):v=>n in v},d^3&&(c.get=h?v=>(d^1?ue:ic)(v,i,d^4?s:p.get):v=>v[n]),d>2&&(c.set=h?(v,k)=>Ve(v,i,k,d^4?s:p.set):(v,k)=>v[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?zn("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||en(e,i),p&&ko(i,n,p),h?d^4?s:p:i},$o=(e,t,n)=>t.has(e)||zn("Cannot "+n),Ch=(e,t)=>Object(t)!==t?zn('Cannot use the "in" operator on this value'):e.has(t),ue=(e,t,n)=>($o(e,t,"read from private field"),n?n.call(e):t.get(e)),Z=(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),Ve=(e,t,n,r)=>($o(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ic=(e,t,n)=>($o(e,t,"access private method"),n);function sc(e,t){return{plugin:e,options:t}}function Tr(e){return t=>sc(e,t)}function xr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var oc,wr,Oo,oi;oc=[U];var Te=class{constructor(e,t){this.manager=e,this.options=t,Z(this,Oo,N(wr,8,this,!1)),N(wr,11,this),Z(this,oi,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return H(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=nt(e.bind(this));return ue(this,oi).add(t),t}destroy(){ue(this,oi).forEach(e=>e())}static configure(e){return sc(this,e)}};wr=Ln(null);Oo=new WeakMap;oi=new WeakMap;Y(wr,4,"disabled",oc,Te,Oo);en(wr,Te);var Ar=class extends Te{},ai,as=class{constructor(e){this.manager=e,this.instances=new Map,Z(this,ai,[])}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,ai))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);Ve(this,ai,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()}};ai=new WeakMap;function Eh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Yr=[],hn,fn,Ph=class extends Te{constructor(e){super(e),Z(this,hn),Z(this,fn),this.computeCollisions=this.computeCollisions.bind(this),Ve(this,fn,An(Yr)),this.destroy=Pr(()=>{const t=this.computeCollisions(),n=H(()=>this.manager.dragOperation.position.current);if(t!==Yr){const r=ue(this,hn);if(Ve(this,hn,n),r&&n.x==r.x&&n.y==r.y)return}else Ve(this,hn,void 0);ue(this,fn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){H(()=>{e?ue(this,fn).value=this.computeCollisions():Ve(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 Yr;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=H(()=>c({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return l.length===0?Yr:(a.sort(Eh),a)}get collisions(){return ue(this,fn).value}};hn=new WeakMap;fn=new WeakMap;var ac,lc,cc,Mo,dc,ot,Co,xn,Eo,Po;cc=[U],lc=[U],ac=[U];var wt=class Nt{constructor(t,n){Z(this,Co,N(ot,8,this)),N(ot,11,this),Z(this,xn),Z(this,Eo,N(ot,12,this)),N(ot,15,this),Z(this,Po,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;Ve(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 ic(s=Nt,Mo,dc).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;dc=function(){const e=wt.pendingIdChanges;wt.pendingIdChanges=null,e&&de(()=>{for(const[t,n]of e)ue(t,xn).value=n})};Co=new WeakMap;xn=new WeakMap;Eo=new WeakMap;Po=new WeakMap;Y(ot,4,"manager",cc,wt,Co);Y(ot,4,"data",lc,wt,Eo);Y(ot,4,"disabled",ac,wt,Po);Z(wt,Mo);en(ot,wt);wt.pendingIdChanges=null;var Fi=wt,Ca=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=Pr(...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}},uc,hc,fc,pc,gc,mc,zs,We,Do,To,Ao,ft=class extends(zs=Fi,mc=[U],gc=[U],pc=[U],fc=[fe],hc=[fe],uc=[fe],zs){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,l=nc(n,["modifiers","type","sensors","plugins","effects"]);super(jo(So({},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),Z(this,Do,N(We,8,this)),N(We,11,this),Z(this,To,N(We,12,this)),N(We,15,this),Z(this,Ao,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(zs);Do=new WeakMap;To=new WeakMap;Ao=new WeakMap;Y(We,4,"type",mc,ft,Do);Y(We,4,"modifiers",gc,ft,To);Y(We,4,"status",pc,ft,Ao);Y(We,2,"isDropping",fc,ft);Y(We,2,"isDragging",hc,ft);Y(We,2,"isDragSource",uc,ft);en(We,ft);var vc,bc,yc,xc,wc,kc,Ls,we,Io,Ro,Wo,zo,Lo,pt=class extends(Ls=Fi,kc=[U],wc=[U],xc=[U],yc=[U],bc=[U],vc=[fe],Ls){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=nc(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),N(we,5,this),Z(this,Io,N(we,8,this)),N(we,11,this),Z(this,Ro,N(we,12,this)),N(we,15,this),Z(this,Wo,N(we,16,this)),N(we,19,this),Z(this,zo,N(we,20,this)),N(we,23,this),Z(this,Lo,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(Ls);Io=new WeakMap;Ro=new WeakMap;Wo=new WeakMap;zo=new WeakMap;Lo=new WeakMap;Y(we,4,"accept",kc,pt,Io);Y(we,4,"type",wc,pt,Ro);Y(we,4,"collisionDetector",xc,pt,Wo);Y(we,4,"collisionPriority",yc,pt,zo);Y(we,4,"shape",bc,pt,Lo);Y(we,2,"isDropTarget",vc,pt);en(we,pt);var Dh=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)}},Th=class extends Dh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function li(e,t=!0){let n=!1;return jo(So({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Ah=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=Pr(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||Fi.pendingIdChanges)return;const o=li({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;H(()=>{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||{}),Sc,jc,$c,Oc,Mc,Cc,Ec,et,No;Ec=[U],Cc=[fe],Mc=[fe],Oc=[fe],$c=[fe],jc=[fe],Sc=[fe];var kt=class{constructor(){N(et,5,this),Z(this,No,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);No=new WeakMap;Y(et,4,"value",Ec,kt,No);Y(et,2,"current",Cc,kt);Y(et,2,"idle",Mc,kt);Y(et,2,"initializing",Oc,kt);Y(et,2,"initialized",$c,kt);Y(et,2,"dragging",jc,kt);Y(et,2,"dropped",Sc,kt);en(et,kt);var Ih=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 H(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=li({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return H(()=>{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=li({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 H(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=li({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 H(()=>{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=H(()=>{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()})}},On=class extends Te{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Rh=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)}},ci,Pc=class{constructor(e){this.options=e,Z(this,ci)}set controller(e){Ve(this,ci,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=ue(this,ci))==null||t.activate(e)}};ci=new WeakMap;var Ea=class extends Te{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Wh=class{constructor(e){this.draggables=new Ca,this.droppables=new Ca,this.plugins=new as(e),this.sensors=new as(e),this.modifiers=new as(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 Ea)return this.modifiers.register(e,t);if(e.prototype instanceof On)return this.sensors.register(e,t);if(e.prototype instanceof Te)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Fi)return e instanceof ft?this.draggables.unregister(e.id,e):e instanceof pt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Ea)return this.modifiers.unregister(e);if(e.prototype instanceof On)return this.sensors.unregister(e);if(e.prototype instanceof Te)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()}},Dc,Tc,Ac,Ic,Rc,Wc,zc,Lc,Nc,er,di,pn,le,_o,Fo,qo,Ho,Uo,tr;Nc=[fe],Lc=[U],zc=[U],Wc=[U],Rc=[U],Ic=[U],Ac=[fe],Tc=[fe],Dc=[fe];var lt=class{constructor(e){N(le,5,this),Z(this,er),Z(this,di),Z(this,pn,new Qt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new kt,Z(this,_o,N(le,8,this,!1)),N(le,11,this),Z(this,Fo,N(le,12,this,null)),N(le,15,this),Z(this,qo,N(le,16,this,null)),N(le,19,this),Z(this,Ho,N(le,20,this,null)),N(le,23,this),Z(this,Uo,N(le,24,this,[])),N(le,27,this),this.position=new _i({x:0,y:0}),Z(this,tr,{x:0,y:0}),Ve(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&&Ve(this,di,n),(e=n??ue(this,di))!=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(So({},this.snapshot()),{transform:n}));return Ve(this,tr,n),n}snapshot(){return H(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:ue(this,tr),shape:this.shape?os(this.shape):null,position:os(this.position),status:os(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}),Ve(this,tr,{x:0,y:0}),this.modifiers=[]})}};le=Ln(null);er=new WeakMap;di=new WeakMap;pn=new WeakMap;_o=new WeakMap;Fo=new WeakMap;qo=new WeakMap;Ho=new WeakMap;Uo=new WeakMap;tr=new WeakMap;Y(le,2,"shape",Nc,lt);Y(le,4,"canceled",Lc,lt,_o);Y(le,4,"activatorEvent",zc,lt,Fo);Y(le,4,"sourceIdentifier",Wc,lt,qo);Y(le,4,"targetIdentifier",Rc,lt,Ho);Y(le,4,"modifiers",Ic,lt,Uo);Y(le,2,"source",Ac,lt);Y(le,2,"target",Tc,lt);Y(le,2,"transform",Dc,lt);en(le,lt);var zh={get rendering(){return Promise.resolve()}};function at(e,t){return typeof e=="function"?e(t):e??t}var Lh=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:zh,a=new Th(this),l=new Wh(this);this.registry=l,this.monitor=a,this.renderer=o,this.actions=new Ih(this),this.dragOperation=new lt(this),this.collisionObserver=new Ph(this),this.plugins=[Ah,...r],this.modifiers=s,this.sensors=i;const{destroy:u}=this,c=Pr(()=>{var d,f,h;const m=H(()=>this.dragOperation.modifiers),g=this.modifiers;for(const w of m)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}},_c=e=>{throw TypeError(e)},Yo=(e,t,n)=>t.has(e)||_c("Cannot "+n),L=(e,t,n)=>(Yo(e,t,"read from private field"),t.get(e)),He=(e,t,n)=>t.has(e)?_c("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ge=(e,t,n,r)=>(Yo(e,t,"write to private field"),t.set(e,n),n),Fc=(e,t,n)=>(Yo(e,t,"access private method"),n);function qi(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function qc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(qi(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function Hi(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 Go(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ir(e){return"nodeType"in e}function Ke(e){var t,n,r;return e?Go(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 Vo(e){const{Document:t}=Ke(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Dt(e){return!e||Go(e)?!1:e instanceof Ke(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Hc(e){return e instanceof Ke(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Fn(e){return e?Go(e)?e.document:Ir(e)?Vo(e)?e:Dt(e)||Hc(e)?e.ownerDocument:document:document:document}function Nh(e){var t,n,r,i;const{documentElement:s}=Fn(e),o=Ke(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 _h(e,t){if(Fh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function Fh(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(!_h(d)){const x=d.getBoundingClientRect(),v=n*(x.bottom-x.top),k=n*(x.right-x.left),j=n*(x.bottom-x.top),O=n*(x.right-x.left);l={top:Math.max(l.top,x.top-v),right:Math.min(l.right,x.right+k),bottom:Math.min(l.bottom,x.bottom+j),left:Math.max(l.left,x.left-O),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,m=(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,m+g+p),bottom:Math.min(l.bottom,h+w+y),left:Math.max(l.left,m-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 Mn(e){return{x:e.clientX,y:e.clientY}}var Uc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ns(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(...Ns(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(...Ns(i.document,t))}}catch{}return n}function Ko(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Yc(){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 Xo(e){return!e||!Ir(e)?!1:e instanceof Ke(e).ShadowRoot}function Si(e){if(e&&Ir(e)){let t=e.getRootNode();if(Xo(t)||t instanceof Document)return t}return Fn(e)}function Bo(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];Pa(i)&&Pa(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Da(i)&&Da(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function Pa(e){return"value"in e}function Da(e){return e.tagName==="CANVAS"}function Gc(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Hh(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Gc(i,{x:t-s,y:n-o})}}return r}function Hh(e){return e?.tagName==="IFRAME"}var _s=new WeakMap;function Uh(e){return e.closest(`
3
3
  input:not([disabled]),
4
4
  select:not([disabled]),
5
5
  textarea:not([disabled]),
6
6
  button:not([disabled]),
7
7
  a[href],
8
8
  [contenteditable]:not([contenteditable="false"])
9
- `)}var Vc=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 Cn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Uh(e){const t=new Set;let n=Cn(e);for(;n;)t.add(n),n=Cn(n);return t}function Yh(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Kc(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=Yh(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function Gh(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 Vh(e,t=e.getBoundingClientRect()){const{width:n,height:r}=kr(e,t);return n>0&&r>0}var Kh=Uc?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ui,Xh=class extends Kh{constructor(e){super(t=>{if(!L(this,ui)){Ge(this,ui,!0);return}e(t,this)}),He(this,ui,!1)}};ui=new WeakMap;var Ta=Array.from({length:100},(e,t)=>t/100),Xc=75,Ft,ji,jt,_t,nr,Ce,gr,rr,$i,Bc,Zc,Jc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,He(this,$i),this.disconnect=()=>{var s,o,a;Ge(this,gr,!0),(s=L(this,jt))==null||s.disconnect(),(o=L(this,_t))==null||o.disconnect(),L(this,nr).disconnect(),(a=L(this,Ce))==null||a.remove()},He(this,Ft,!0),He(this,ji),He(this,jt),He(this,_t),He(this,nr),He(this,Ce),He(this,gr,!1),He(this,rr,Kc(()=>{var s,o,a;const{element:l}=this;if((s=L(this,_t))==null||s.disconnect(),L(this,gr)||!L(this,Ft)||!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:m,left:g,bottom:w,right:y}=h,p=-Math.floor(m),x=-Math.floor(g),v=-Math.floor(d-y),k=-Math.floor(c-w),j=`${p}px ${v}px ${k}px ${x}px`;this.boundingClientRect=f,Ge(this,_t,new IntersectionObserver(O=>{const[M]=O,{intersectionRect:P}=M;(M.intersectionRatio!==1?M.intersectionRatio:ht.intersectionRatio(P,kr(l)))!==1&&L(this,rr).call(this)},{threshold:Ta,rootMargin:j,root:u})),L(this,_t).observe(l),_c(this,$i,Bc).call(this)},Xc)),this.boundingClientRect=e.getBoundingClientRect(),Ge(this,Ft,Vh(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(Ge(this,Ce,document.createElement("div")),L(this,Ce).style.background="rgba(0,0,0,0.15)",L(this,Ce).style.position="fixed",L(this,Ce).style.pointerEvents="none",i.body.appendChild(L(this,Ce))),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,Ft);Ge(this,Ft,c),!(!d&&!f)&&(h&&!c?((o=L(this,_t))==null||o.disconnect(),this.callback(null),(a=L(this,jt))==null||a.disconnect(),Ge(this,jt,void 0),L(this,Ce)&&(L(this,Ce).style.visibility="hidden")):L(this,rr).call(this),c&&!L(this,jt)&&(Ge(this,jt,new Xh(L(this,rr))),L(this,jt).observe(e)))},{threshold:Ta,root:i})),L(this,Ft)&&!n.skipInitial&&this.callback(this.boundingClientRect),L(this,nr).observe(e)}};Ft=new WeakMap;ji=new WeakMap;jt=new WeakMap;_t=new WeakMap;nr=new WeakMap;Ce=new WeakMap;gr=new WeakMap;rr=new WeakMap;$i=new WeakSet;Bc=function(){L(this,gr)||(_c(this,$i,Zc).call(this),!Gh(this.boundingClientRect,L(this,ji))&&(this.callback(this.boundingClientRect),Ge(this,ji,this.boundingClientRect)))};Zc=function(){if(L(this,Ce)){const{top:e,left:t,width:n,height:r}=kr(this.element);L(this,Ce).style.overflow="hidden",L(this,Ce).style.visibility="visible",L(this,Ce).style.top=`${Math.floor(e)}px`,L(this,Ce).style.left=`${Math.floor(t)}px`,L(this,Ce).style.width=`${Math.floor(n)}px`,L(this,Ce).style.height=`${Math.floor(r)}px`}};var Gr=new WeakMap,Vr=new WeakMap;function Bh(e,t){let n=Gr.get(e);return n||(n={disconnect:new Jc(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 Zh(e,t){const n=new Set;for(const r of e){const i=Bh(r,t);n.add(i)}return()=>n.forEach(r=>r())}function Jh(e,t){var n;const r=e.ownerDocument;if(!Vr.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}),Vr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=Vr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),Vr.delete(r))})}var ir,sr,hi,_s,Qh=class{constructor(e,t,n){this.callback=t,He(this,ir),He(this,sr,!1),He(this,hi),He(this,_s,Kc(o=>{if(!L(this,sr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of L(this,hi))if(o.target.contains(a)){this.callback(L(this,ir).boundingClientRect);break}}},Xc));const r=Uh(e),i=Zh(r,t),s=Jh(e,L(this,_s));Ge(this,hi,r),Ge(this,ir,new Jc(e,t,n)),this.disconnect=()=>{L(this,sr)||(Ge(this,sr,!0),i(),s(),L(this,ir).disconnect())}}};ir=new WeakMap;sr=new WeakMap;hi=new WeakMap;_s=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 Aa(e){return!Uc||!e?!1:e===_n(e).scrollingElement}function Qc(e){var t,n;const r=Ke(e),i=Aa(e)?Lh(e):Hi(e),s=r.visualViewport,o=Aa(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 ef(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=Qc(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()}),tf=new Zo(e=>setTimeout(e,50)),Mi=new Map,nf=Mi.clear.bind(Mi);function gt(e,t=!1){if(!t)return Ia(e);let n=Mi.get(e);return n||(n=Ia(e),Mi.set(e,n),tf.schedule(nf),n)}function Ia(e){return Ke(e).getComputedStyle(e)}function rf(e,t=gt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function sf(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 of={excludeElement:!0,escapeShadowDOM:!0};function Hs(e,t=of){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(Vo(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&Xo(a))return o(a.host);if(!Pt(a))return Hc(a)?o(a.parentElement):s;if(s.has(a))return s;const l=gt(a,!0);if(r&&a===e||sf(a,l)&&s.add(a),rf(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=Cn(e);for(;r;){if(r===t)return n;const i=Hi(r),{x:s,y:o}=af(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=Cn(r)}return n}function af(e,t=Hi(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Pt(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 lf(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 Ui(e){var t,n,r,i,s,o,a,l,u;const{scale:c,transform:d,translate:f}=e,h=lf(c),m=Sr(f),g=cf(d);if(!g&&!h&&!m)return null;const w={x:(t=h?.x)!=null?t:1,y:(n=h?.y)!=null?n:1},y={x:(r=m?.x)!=null?r:0,y:(i=m?.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=m?.z)!=null?u:0,scaleX:w.x*p.scaleX,scaleY:w.y*p.scaleY}}function cf(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 Qe=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(Qe||{}),df={x:.2,y:.2},uf={x:10,y:10};function hf(e,t,n,r=25,i=df,s=uf){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:c,isLeft:d,isRight:f}=Qc(e),h=En(e),m=gt(e,!0),g=Ui(m),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},v={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,v.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,v.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,v.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,v.x=r*Math.abs((p.left+k.width-o)/k.width)),{direction:x,speed:v}}function ed(e,{block:t="nearest",inline:n="nearest"}={}){if(!Pt(e))return;const r=Hs(e),i=[];for(const s of r){if(!Pt(s))continue;const{top:o,left:a}=ff(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 Ra(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!Pt(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function ff(e,t){const n=Ra(e),r=Ra(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function pf(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 gf(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 td({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function Wa(e,t=gt(e).translate,n=!0){if(n){const r=qc(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 mf=new Zo(e=>setTimeout(e,0)),mr=new Map,vf=mr.clear.bind(mr);function bf(e){const t=e.ownerDocument;let n=mr.get(t);if(n)return n;n=t.getAnimations(),mr.set(t,n),mf.schedule(vf);const r=n.filter(i=>qi(i.effect)&&i.effect.target===e);return mr.set(e,r),n}function yf(e,t){const n=bf(e).filter(r=>{var i,s;if(qi(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=Hi}=t,u=yf(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:m}=c,g;const w=gt(e),y=Ui(w),p={x:(n=y?.scaleX)!=null?n:1,y:(r=y?.scaleY)!=null?r:1},x=xf(e,w);u?.(),y&&(g=gf(c,y,w.transformOrigin),(a||x)&&(d=g.top,f=g.left,h=g.width,m=g.height));const v={width:(i=g?.width)!=null?i:h,height:(s=g?.height)!=null?s:m};if(x&&!a&&g){const k=pf(g,x,w.transformOrigin);d=k.top,f=k.left,h=k.width,m=k.height,p.x=x.scaleX,p.y=x.scaleY}o&&(a||(f*=o.scaleX,h*=o.scaleX,d*=o.scaleY,m*=o.scaleY),f+=o.x,d+=o.y),super(f,d,h,m),this.scale=p,this.intrinsicWidth=v.width,this.intrinsicHeight=v.height}};function xf(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=qi(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?Ui({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 wf=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 Vt(e){return e?e instanceof Ke(e).Element||Ir(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function jr(e){if(!e)return!1;const{KeyboardEvent:t}=Ke(e.target);return e instanceof t}function kf(e){if(!e)return!1;const{PointerEvent:t}=Ke(e.target);return e instanceof t}function Sf(e){if(!Vt(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||jf(e)}function jf(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var ls={};function Us(e){const t=ls[e]==null?0:ls[e]+1;return ls[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=Je.distance(t.shape.center,n);return{id:r,value:1/i,type:Fn.PointerIntersection,priority:Nn.High}}return null},$f=({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=Je.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:o,type:Fn.ShapeIntersection,priority:Nn.Normal}}return null},nd=e=>{var t;return(t=Jo(e))!=null?t:$f(e)},Of=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+Je.distance(Je.from(l),(c=s?.[u])!=null?c:i.current)},0)/4;return{id:n.id,value:1/o,type:Fn.Collision,priority:Nn.Normal}},Mf=Object.create,Qo=Object.defineProperty,Cf=Object.defineProperties,Ef=Object.getOwnPropertyDescriptor,Df=Object.getOwnPropertyDescriptors,Ci=Object.getOwnPropertySymbols,rd=Object.prototype.hasOwnProperty,id=Object.prototype.propertyIsEnumerable,sd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),qn=e=>{throw TypeError(e)},Ys=(e,t,n)=>t in e?Qo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$r=(e,t)=>{for(var n in t||(t={}))rd.call(t,n)&&Ys(e,n,t[n]);if(Ci)for(var n of Ci(t))id.call(t,n)&&Ys(e,n,t[n]);return e},ea=(e,t)=>Cf(e,Df(t)),za=(e,t)=>Qo(e,"name",{value:t,configurable:!0}),od=(e,t)=>{var n={};for(var r in e)rd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ci)for(var r of Ci(e))t.indexOf(r)<0&&id.call(e,r)&&(n[r]=e[r]);return n},Hn=e=>{var t;return[,,,Mf((t=e?.[sd("metadata")])!=null?t:null)]},ad=["class","method","getter","setter","accessor","field","value","get","set"],or=e=>e!==void 0&&typeof e!="function"?qn("Function expected"):e,Pf=(e,t,n,r,i)=>({kind:ad[e],name:t,metadata:r,addInitializer:s=>n._?qn("Already initialized"):i.push(or(s||null))}),tn=(e,t)=>Ys(t,sd("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),m=d>3?e.length+1:d?f?1:2:0,g=ad[d+5],w=d>3&&(e[m-1]=[]),y=e[m]||(e[m]=[]),p=d&&(!h&&!f&&(i=i.prototype),d<5&&(d>3||!h)&&Ef(d<4?i:{get[n](){return re(this,s)},set[n](v){return ze(this,s,v)}},n));d?h&&d<4&&za(s,(d>2?"set ":d>1?"get ":"")+n):za(i,n);for(var x=r.length-1;x>=0;x--)u=Pf(d,n,l={},e[3],y),d&&(u.static=f,u.private=h,c=u.access={has:h?v=>Tf(i,v):v=>n in v},d^3&&(c.get=h?v=>(d^1?re:Kt)(v,i,d^4?s:p.get):v=>v[n]),d>2&&(c.set=h?(v,k)=>ze(v,i,k,d^4?s:p.set):(v,k)=>v[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?qn("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&&Qo(i,n,p),h?d^4?s:p:i},ta=(e,t,n)=>t.has(e)||qn("Cannot "+n),Tf=(e,t)=>Object(t)!==t?qn('Cannot use the "in" operator on this value'):e.has(t),re=(e,t,n)=>(ta(e,t,"read from private field"),n?n.call(e):t.get(e)),ge=(e,t,n)=>t.has(e)?qn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ze=(e,t,n,r)=>(ta(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Kt=(e,t,n)=>(ta(e,t,"access private method"),n),La={role:"button",roleDescription:"draggable"},Af="dnd-kit-description",If="dnd-kit-announcement",Rf={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."},Wf={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 zf(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Lf(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function Nf(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 Ff=["dragover","dragmove"],_f=class extends Te{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Af,announcement:i=If}={},announcements:s=Wf,screenReaderInstructions:o=Rf,debounce:a=500}=t??{},l=n?`${r}-${n}`:Us(r),u=n?`${i}-${n}`:Us(i);let c,d,f,h;const m=(k=h)=>{!f||!k||f?.nodeValue!==k&&(f.nodeValue=k)},g=()=>Oi.schedule(m),w=qf(g,a),y=Object.entries(s).map(([k,j])=>this.manager.monitor.addEventListener(k,(O,M)=>{const P=f;if(!P)return;const T=j?.(O,M);T&&P.nodeValue!==T&&(h=T,Ff.includes(k)?w():(g(),w.cancel()))})),p=()=>{let k=[];c?.isConnected||(c=Lf(l,o.draggable),k.push(c)),d?.isConnected||(d=Nf(u),f=document.createTextNode(""),d.appendChild(f),k.push(d)),k.length>0&&document.body.append(...k)},x=new Set;function v(){for(const k of x)k()}this.registerEffect(()=>{var k;x.clear();for(const j of this.manager.registry.draggables.value){const O=(k=j.handle)!=null?k:j.element;if(O){(!c||!d)&&x.add(p),(!zf(O)||Ko())&&!O.hasAttribute("tabindex")&&x.add(()=>O.setAttribute("tabindex","0")),!O.hasAttribute("role")&&O.tagName.toLowerCase()!=="button"&&x.add(()=>O.setAttribute("role",La.role)),O.hasAttribute("aria-roledescription")||x.add(()=>O.setAttribute("aria-roledescription",La.roleDescription)),O.hasAttribute("aria-describedby")||x.add(()=>O.setAttribute("aria-describedby",l));for(const P of["aria-pressed","aria-grabbed"]){const T=String(j.isDragging);O.getAttribute(P)!==T&&x.add(()=>O.setAttribute(P,T))}const M=String(j.disabled);O.getAttribute("aria-disabled")!==M&&x.add(()=>O.setAttribute("aria-disabled",M))}}x.size>0&&Oi.schedule(v)}),this.destroy=()=>{super.destroy(),c?.remove(),d?.remove(),y.forEach(k=>k())}}};function qf(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Ei=new Map,ld,cd,dd,ud,Gs,br,xt,na,Dn,hd,fd,pd,gd,Tt=class extends(Gs=Ar,ud=[U],dd=[fe],cd=[fe],ld=[fe],Gs){constructor(e,t){super(e,t),Se(xt,5,this),ge(this,Dn),ge(this,br,new Set),ge(this,na,Se(xt,8,this,new Set)),Se(xt,11,this),this.registerEffect(Kt(this,Dn,hd))}register(e){return re(this,br).add(e),()=>{re(this,br).delete(e)}}addRoot(e){return H(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{H(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return Si((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return Si((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=Hn(Gs);br=new WeakMap;na=new WeakMap;Dn=new WeakSet;hd=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of re(this,br))t.push(Kt(this,Dn,fd).call(this,n,r));return()=>{for(const n of t)n()}};fd=function(e,t){let n=Ei.get(e);n||(n=new Map,Ei.set(e,n));let r=n.get(t);if(!r){const s=Vo(e)?Kt(this,Dn,pd).call(this,e,n,t):Kt(this,Dn,gd).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())}};pd=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&&Ei.delete(e)}}};gd=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(Xo(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&&Ei.delete(e)}}};rt(xt,4,"additionalRoots",ud,Tt,na);rt(xt,2,"sourceRoot",dd,Tt);rt(xt,2,"targetRoot",cd,Tt);rt(xt,2,"roots",ld,Tt);tn(xt,Tt);Tt.configure=Tr(Tt);var Yi=Tt,Hf=class extends Te{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-",Vs=`${Rr}dropping`,Me="--dnd-",dt=`${Rr}dragging`,Di=`${Rr}placeholder`,Uf=[dt,Di,"popover","aria-pressed","aria-grabbing"],Yf=["view-transition-name"],Gf=`
9
+ `)}var Vc=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 Cn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Yh(e){const t=new Set;let n=Cn(e);for(;n;)t.add(n),n=Cn(n);return t}function Gh(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Kc(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=Gh(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function Vh(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 Kh(e,t=e.getBoundingClientRect()){const{width:n,height:r}=kr(e,t);return n>0&&r>0}var Xh=Uc?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ui,Bh=class extends Xh{constructor(e){super(t=>{if(!L(this,ui)){Ge(this,ui,!0);return}e(t,this)}),He(this,ui,!1)}};ui=new WeakMap;var Ta=Array.from({length:100},(e,t)=>t/100),Xc=75,_t,ji,jt,Ft,nr,Ce,gr,rr,$i,Bc,Zc,Jc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,He(this,$i),this.disconnect=()=>{var s,o,a;Ge(this,gr,!0),(s=L(this,jt))==null||s.disconnect(),(o=L(this,Ft))==null||o.disconnect(),L(this,nr).disconnect(),(a=L(this,Ce))==null||a.remove()},He(this,_t,!0),He(this,ji),He(this,jt),He(this,Ft),He(this,nr),He(this,Ce),He(this,gr,!1),He(this,rr,Kc(()=>{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:m,left:g,bottom:w,right:y}=h,p=-Math.floor(m),x=-Math.floor(g),v=-Math.floor(d-y),k=-Math.floor(c-w),j=`${p}px ${v}px ${k}px ${x}px`;this.boundingClientRect=f,Ge(this,Ft,new IntersectionObserver(O=>{const[M]=O,{intersectionRect:D}=M;(M.intersectionRatio!==1?M.intersectionRatio:ht.intersectionRatio(D,kr(l)))!==1&&L(this,rr).call(this)},{threshold:Ta,rootMargin:j,root:u})),L(this,Ft).observe(l),Fc(this,$i,Bc).call(this)},Xc)),this.boundingClientRect=e.getBoundingClientRect(),Ge(this,_t,Kh(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(Ge(this,Ce,document.createElement("div")),L(this,Ce).style.background="rgba(0,0,0,0.15)",L(this,Ce).style.position="fixed",L(this,Ce).style.pointerEvents="none",i.body.appendChild(L(this,Ce))),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,jt))==null||a.disconnect(),Ge(this,jt,void 0),L(this,Ce)&&(L(this,Ce).style.visibility="hidden")):L(this,rr).call(this),c&&!L(this,jt)&&(Ge(this,jt,new Bh(L(this,rr))),L(this,jt).observe(e)))},{threshold:Ta,root:i})),L(this,_t)&&!n.skipInitial&&this.callback(this.boundingClientRect),L(this,nr).observe(e)}};_t=new WeakMap;ji=new WeakMap;jt=new WeakMap;Ft=new WeakMap;nr=new WeakMap;Ce=new WeakMap;gr=new WeakMap;rr=new WeakMap;$i=new WeakSet;Bc=function(){L(this,gr)||(Fc(this,$i,Zc).call(this),!Vh(this.boundingClientRect,L(this,ji))&&(this.callback(this.boundingClientRect),Ge(this,ji,this.boundingClientRect)))};Zc=function(){if(L(this,Ce)){const{top:e,left:t,width:n,height:r}=kr(this.element);L(this,Ce).style.overflow="hidden",L(this,Ce).style.visibility="visible",L(this,Ce).style.top=`${Math.floor(e)}px`,L(this,Ce).style.left=`${Math.floor(t)}px`,L(this,Ce).style.width=`${Math.floor(n)}px`,L(this,Ce).style.height=`${Math.floor(r)}px`}};var Gr=new WeakMap,Vr=new WeakMap;function Zh(e,t){let n=Gr.get(e);return n||(n={disconnect:new Jc(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 Jh(e,t){const n=new Set;for(const r of e){const i=Zh(r,t);n.add(i)}return()=>n.forEach(r=>r())}function Qh(e,t){var n;const r=e.ownerDocument;if(!Vr.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}),Vr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=Vr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),Vr.delete(r))})}var ir,sr,hi,Fs,ef=class{constructor(e,t,n){this.callback=t,He(this,ir),He(this,sr,!1),He(this,hi),He(this,Fs,Kc(o=>{if(!L(this,sr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of L(this,hi))if(o.target.contains(a)){this.callback(L(this,ir).boundingClientRect);break}}},Xc));const r=Yh(e),i=Jh(r,t),s=Qh(e,L(this,Fs));Ge(this,hi,r),Ge(this,ir,new Jc(e,t,n)),this.disconnect=()=>{L(this,sr)||(Ge(this,sr,!0),i(),s(),L(this,ir).disconnect())}}};ir=new WeakMap;sr=new WeakMap;hi=new WeakMap;Fs=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 Aa(e){return!Uc||!e?!1:e===Fn(e).scrollingElement}function Qc(e){var t,n;const r=Ke(e),i=Aa(e)?Nh(e):Hi(e),s=r.visualViewport,o=Aa(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 tf(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=Qc(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()}),nf=new Zo(e=>setTimeout(e,50)),Mi=new Map,rf=Mi.clear.bind(Mi);function gt(e,t=!1){if(!t)return Ia(e);let n=Mi.get(e);return n||(n=Ia(e),Mi.set(e,n),nf.schedule(rf),n)}function Ia(e){return Ke(e).getComputedStyle(e)}function sf(e,t=gt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function of(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 af={excludeElement:!0,escapeShadowDOM:!0};function Hs(e,t=af){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(Vo(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&Xo(a))return o(a.host);if(!Dt(a))return Hc(a)?o(a.parentElement):s;if(s.has(a))return s;const l=gt(a,!0);if(r&&a===e||of(a,l)&&s.add(a),sf(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=Cn(e);for(;r;){if(r===t)return n;const i=Hi(r),{x:s,y:o}=lf(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=Cn(r)}return n}function lf(e,t=Hi(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Dt(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 cf(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 Ui(e){var t,n,r,i,s,o,a,l,u;const{scale:c,transform:d,translate:f}=e,h=cf(c),m=Sr(f),g=df(d);if(!g&&!h&&!m)return null;const w={x:(t=h?.x)!=null?t:1,y:(n=h?.y)!=null?n:1},y={x:(r=m?.x)!=null?r:0,y:(i=m?.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=m?.z)!=null?u:0,scaleX:w.x*p.scaleX,scaleY:w.y*p.scaleY}}function df(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 Qe=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(Qe||{}),uf={x:.2,y:.2},hf={x:10,y:10};function ff(e,t,n,r=25,i=uf,s=hf){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:c,isLeft:d,isRight:f}=Qc(e),h=En(e),m=gt(e,!0),g=Ui(m),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},v={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,v.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,v.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,v.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,v.x=r*Math.abs((p.left+k.width-o)/k.width)),{direction:x,speed:v}}function ed(e,{block:t="nearest",inline:n="nearest"}={}){if(!Dt(e))return;const r=Hs(e),i=[];for(const s of r){if(!Dt(s))continue;const{top:o,left:a}=pf(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 Ra(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!Dt(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function pf(e,t){const n=Ra(e),r=Ra(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function gf(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 mf(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 td({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function Wa(e,t=gt(e).translate,n=!0){if(n){const r=qc(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 vf=new Zo(e=>setTimeout(e,0)),mr=new Map,bf=mr.clear.bind(mr);function yf(e){const t=e.ownerDocument;let n=mr.get(t);if(n)return n;n=t.getAnimations(),mr.set(t,n),vf.schedule(bf);const r=n.filter(i=>qi(i.effect)&&i.effect.target===e);return mr.set(e,r),n}function xf(e,t){const n=yf(e).filter(r=>{var i,s;if(qi(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=Hi}=t,u=xf(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:m}=c,g;const w=gt(e),y=Ui(w),p={x:(n=y?.scaleX)!=null?n:1,y:(r=y?.scaleY)!=null?r:1},x=wf(e,w);u?.(),y&&(g=mf(c,y,w.transformOrigin),(a||x)&&(d=g.top,f=g.left,h=g.width,m=g.height));const v={width:(i=g?.width)!=null?i:h,height:(s=g?.height)!=null?s:m};if(x&&!a&&g){const k=gf(g,x,w.transformOrigin);d=k.top,f=k.left,h=k.width,m=k.height,p.x=x.scaleX,p.y=x.scaleY}o&&(a||(f*=o.scaleX,h*=o.scaleX,d*=o.scaleY,m*=o.scaleY),f+=o.x,d+=o.y),super(f,d,h,m),this.scale=p,this.intrinsicWidth=v.width,this.intrinsicHeight=v.height}};function wf(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=qi(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?Ui({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 kf=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 Vt(e){return e?e instanceof Ke(e).Element||Ir(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function jr(e){if(!e)return!1;const{KeyboardEvent:t}=Ke(e.target);return e instanceof t}function Sf(e){if(!e)return!1;const{PointerEvent:t}=Ke(e.target);return e instanceof t}function jf(e){if(!Vt(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||$f(e)}function $f(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var ls={};function Us(e){const t=ls[e]==null?0:ls[e]+1;return ls[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=Je.distance(t.shape.center,n);return{id:r,value:1/i,type:_n.PointerIntersection,priority:Nn.High}}return null},Of=({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=Je.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},nd=e=>{var t;return(t=Jo(e))!=null?t:Of(e)},Mf=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+Je.distance(Je.from(l),(c=s?.[u])!=null?c:i.current)},0)/4;return{id:n.id,value:1/o,type:_n.Collision,priority:Nn.Normal}},Cf=Object.create,Qo=Object.defineProperty,Ef=Object.defineProperties,Pf=Object.getOwnPropertyDescriptor,Df=Object.getOwnPropertyDescriptors,Ci=Object.getOwnPropertySymbols,rd=Object.prototype.hasOwnProperty,id=Object.prototype.propertyIsEnumerable,sd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),qn=e=>{throw TypeError(e)},Ys=(e,t,n)=>t in e?Qo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$r=(e,t)=>{for(var n in t||(t={}))rd.call(t,n)&&Ys(e,n,t[n]);if(Ci)for(var n of Ci(t))id.call(t,n)&&Ys(e,n,t[n]);return e},ea=(e,t)=>Ef(e,Df(t)),za=(e,t)=>Qo(e,"name",{value:t,configurable:!0}),od=(e,t)=>{var n={};for(var r in e)rd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ci)for(var r of Ci(e))t.indexOf(r)<0&&id.call(e,r)&&(n[r]=e[r]);return n},Hn=e=>{var t;return[,,,Cf((t=e?.[sd("metadata")])!=null?t:null)]},ad=["class","method","getter","setter","accessor","field","value","get","set"],or=e=>e!==void 0&&typeof e!="function"?qn("Function expected"):e,Tf=(e,t,n,r,i)=>({kind:ad[e],name:t,metadata:r,addInitializer:s=>n._?qn("Already initialized"):i.push(or(s||null))}),tn=(e,t)=>Ys(t,sd("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),m=d>3?e.length+1:d?f?1:2:0,g=ad[d+5],w=d>3&&(e[m-1]=[]),y=e[m]||(e[m]=[]),p=d&&(!h&&!f&&(i=i.prototype),d<5&&(d>3||!h)&&Pf(d<4?i:{get[n](){return re(this,s)},set[n](v){return ze(this,s,v)}},n));d?h&&d<4&&za(s,(d>2?"set ":d>1?"get ":"")+n):za(i,n);for(var x=r.length-1;x>=0;x--)u=Tf(d,n,l={},e[3],y),d&&(u.static=f,u.private=h,c=u.access={has:h?v=>Af(i,v):v=>n in v},d^3&&(c.get=h?v=>(d^1?re:Kt)(v,i,d^4?s:p.get):v=>v[n]),d>2&&(c.set=h?(v,k)=>ze(v,i,k,d^4?s:p.set):(v,k)=>v[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?qn("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&&Qo(i,n,p),h?d^4?s:p:i},ta=(e,t,n)=>t.has(e)||qn("Cannot "+n),Af=(e,t)=>Object(t)!==t?qn('Cannot use the "in" operator on this value'):e.has(t),re=(e,t,n)=>(ta(e,t,"read from private field"),n?n.call(e):t.get(e)),ge=(e,t,n)=>t.has(e)?qn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ze=(e,t,n,r)=>(ta(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Kt=(e,t,n)=>(ta(e,t,"access private method"),n),La={role:"button",roleDescription:"draggable"},If="dnd-kit-description",Rf="dnd-kit-announcement",Wf={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."},zf={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 Lf(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function Nf(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function _f(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 Ff=["dragover","dragmove"],qf=class extends Te{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=If,announcement:i=Rf}={},announcements:s=zf,screenReaderInstructions:o=Wf,debounce:a=500}=t??{},l=n?`${r}-${n}`:Us(r),u=n?`${i}-${n}`:Us(i);let c,d,f,h;const m=(k=h)=>{!f||!k||f?.nodeValue!==k&&(f.nodeValue=k)},g=()=>Oi.schedule(m),w=Hf(g,a),y=Object.entries(s).map(([k,j])=>this.manager.monitor.addEventListener(k,(O,M)=>{const D=f;if(!D)return;const T=j?.(O,M);T&&D.nodeValue!==T&&(h=T,Ff.includes(k)?w():(g(),w.cancel()))})),p=()=>{let k=[];c?.isConnected||(c=Nf(l,o.draggable),k.push(c)),d?.isConnected||(d=_f(u),f=document.createTextNode(""),d.appendChild(f),k.push(d)),k.length>0&&document.body.append(...k)},x=new Set;function v(){for(const k of x)k()}this.registerEffect(()=>{var k;x.clear();for(const j of this.manager.registry.draggables.value){const O=(k=j.handle)!=null?k:j.element;if(O){(!c||!d)&&x.add(p),(!Lf(O)||Ko())&&!O.hasAttribute("tabindex")&&x.add(()=>O.setAttribute("tabindex","0")),!O.hasAttribute("role")&&O.tagName.toLowerCase()!=="button"&&x.add(()=>O.setAttribute("role",La.role)),O.hasAttribute("aria-roledescription")||x.add(()=>O.setAttribute("aria-roledescription",La.roleDescription)),O.hasAttribute("aria-describedby")||x.add(()=>O.setAttribute("aria-describedby",l));for(const D of["aria-pressed","aria-grabbed"]){const T=String(j.isDragging);O.getAttribute(D)!==T&&x.add(()=>O.setAttribute(D,T))}const M=String(j.disabled);O.getAttribute("aria-disabled")!==M&&x.add(()=>O.setAttribute("aria-disabled",M))}}x.size>0&&Oi.schedule(v)}),this.destroy=()=>{super.destroy(),c?.remove(),d?.remove(),y.forEach(k=>k())}}};function Hf(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Ei=new Map,ld,cd,dd,ud,Gs,br,xt,na,Pn,hd,fd,pd,gd,Tt=class extends(Gs=Ar,ud=[U],dd=[fe],cd=[fe],ld=[fe],Gs){constructor(e,t){super(e,t),Se(xt,5,this),ge(this,Pn),ge(this,br,new Set),ge(this,na,Se(xt,8,this,new Set)),Se(xt,11,this),this.registerEffect(Kt(this,Pn,hd))}register(e){return re(this,br).add(e),()=>{re(this,br).delete(e)}}addRoot(e){return H(()=>{const t=new Set(this.additionalRoots);t.add(e),this.additionalRoots=t}),()=>{H(()=>{const t=new Set(this.additionalRoots);t.delete(e),this.additionalRoots=t})}}get sourceRoot(){var e;const{source:t}=this.manager.dragOperation;return Si((e=t?.element)!=null?e:null)}get targetRoot(){var e;const{target:t}=this.manager.dragOperation;return Si((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=Hn(Gs);br=new WeakMap;na=new WeakMap;Pn=new WeakSet;hd=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of re(this,br))t.push(Kt(this,Pn,fd).call(this,n,r));return()=>{for(const n of t)n()}};fd=function(e,t){let n=Ei.get(e);n||(n=new Map,Ei.set(e,n));let r=n.get(t);if(!r){const s=Vo(e)?Kt(this,Pn,pd).call(this,e,n,t):Kt(this,Pn,gd).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())}};pd=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&&Ei.delete(e)}}};gd=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(Xo(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&&Ei.delete(e)}}};rt(xt,4,"additionalRoots",ud,Tt,na);rt(xt,2,"sourceRoot",dd,Tt);rt(xt,2,"targetRoot",cd,Tt);rt(xt,2,"roots",ld,Tt);tn(xt,Tt);Tt.configure=Tr(Tt);var Yi=Tt,Uf=class extends Te{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-",Vs=`${Rr}dropping`,Me="--dnd-",dt=`${Rr}dragging`,Pi=`${Rr}placeholder`,Yf=[dt,Pi,"popover","aria-pressed","aria-grabbing"],Gf=["view-transition-name"],Vf=`
10
10
  :is(:root,:host) [${dt}] {
11
11
  position: fixed !important;
12
12
  pointer-events: none !important;
@@ -25,11 +25,11 @@ import{r as S,aM as wu,aN as yn,j as b,aa as he,aO as ku,at as Wt,N as pe,aP as
25
25
  transition: var(${Me}transition) !important;
26
26
  }
27
27
 
28
- :is(:root,:host) [${Di}] {
28
+ :is(:root,:host) [${Pi}] {
29
29
  transition: none;
30
30
  }
31
31
 
32
- :is(:root,:host) [${Di}='hidden'] {
32
+ :is(:root,:host) [${Pi}='hidden'] {
33
33
  visibility: hidden;
34
34
  }
35
35
 
@@ -65,22 +65,22 @@ import{r as S,aM as wu,aN as yn,j as b,aa as he,aO as ku,at as Wt,N as pe,aP as
65
65
  display: none;
66
66
  visibility: hidden;
67
67
  }
68
- `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Vf(e,t="hidden"){return H(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=Kf(n,r.registry.droppables),s=[],o=_h(n),{remove:a}=o;return Xf(i,o,s),Bf(o,t),o.remove=()=>{s.forEach(l=>l()),a.call(o)},o})}function Kf(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${Rr}${Us("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function Xf(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 Bf(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Di,t)}function md(e,t){return e===t?!0:Cn(e)===Cn(t)}function Na(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Vt(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>Sn(t))}function Ks(e){return e.tagName==="TR"}function Zf(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-")||Uf.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(Yf.includes(c)||c.startsWith(Me))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 Jf(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 Qf(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=Yc();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},Me),(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,m=e.frameTransform;e.dragOperation.shape=new ht(c*m.scaleX+m.x,d*m.scaleY+m.y,f*m.scaleX,h*m.scaleY)})}var ep=250,tp="ease";function np(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=ep,easing:a=tp}=s??{};Sn(e.feedbackElement);const[,l]=(t=qc(e.feedbackElement,p=>"translate"in p))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,c={frameTransform:md(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),m=ht.delta(d,h,e.alignment),g={x:f.x-m.x,y:f.y-m.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},Me),e.feedbackElement.setAttribute(Vs,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),td({element:e.feedbackElement,keyframes:ea($r($r({},w),y),{translate:[`${f.x}px ${f.y}px 0`,`${g.x}px ${g.y}px 0`]}),options:{duration:Bo(Ke(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(Vs),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var vd,Xs,Or,ra,fi,bd,yd,Pn=class extends(Xs=Te,vd=[U],Xs){constructor(e,t){super(e,t),ge(this,fi),ge(this,ra,Se(Or,8,this)),Se(Or,11,this),this.state={initial:{},current:{}};const n=e.registry.plugins.get(Yi),r=n?.register(Gf);if(r){const i=this.destroy.bind(this);this.destroy=()=>{r(),i()}}this.registerEffect(Kt(this,fi,bd).bind(this,n)),this.registerEffect(Kt(this,fi,yd))}};Or=Hn(Xs);ra=new WeakMap;fi=new WeakSet;bd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Si(t);if(n)return e.addRoot(n)};yd=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:m}=f,g=f.pluginConfig(Pn),w=(t=(e=g?.feedback)!=null?e:u?.feedback)!=null?t:"default",y=typeof w=="function"?w(f,l):w;if(!m||y==="none"||!h.initialized||h.initializing)return;const{initial:p}=a,x=(n=this.overlay)!=null?n:m,v=En(x),k=En(m),j=!md(m,x),O=new ut(m,{frameTransform:j?k:null,ignoreTransforms:!j}),M={x:k.scaleX/v.scaleX,y:k.scaleY/v.scaleY};let{width:P,height:T,top:G,left:I}=O;j&&(P=P/M.x,T=T/M.y);const E=new wf(x),_=gt(m),{transition:J,translate:me,boxSizing:Ae,paddingBlockStart:oe,paddingBlockEnd:Ne,paddingInlineStart:Ue,paddingInlineEnd:Ee,borderInlineStartWidth:Xe,borderInlineEndWidth:Ye,borderBlockStartWidth:Fe,borderBlockEndWidth:Be}=_,Oe=J.split(",").filter(z=>!/^\s*(transform|translate|scale)\b/.test(z)).join(","),xe=Ui(_),R=_.transform,F=y==="clone",je=Ae==="content-box",X=je?parseInt(Ue)+parseInt(Ee)+parseInt(Xe)+parseInt(Ye):0,_e=je?parseInt(oe)+parseInt(Ne)+parseInt(Fe)+parseInt(Be):0,ee=y!=="move"&&!this.overlay?Vf(f,F?"clone":"hidden"):null,ct=H(()=>jr(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=H(()=>d.current),Q=I+((r=xe?.x)!=null?r:0),K=G+((i=xe?.y)!=null?i:0);p.transformOrigin={x:(z.x-Q*v.scaleX-v.x)/(P*v.scaleX),y:(z.y-K*v.scaleY-v.y)/(T*v.scaleY)}}const{transformOrigin:qe}=p,St=G*v.scaleY+v.y,C=I*v.scaleX+v.x;if(!p.coordinates&&(p.coordinates={x:C,y:St},M.x!==1||M.y!==1)){const{scaleX:z,scaleY:Q}=k,{x:K,y:te}=qe;p.coordinates.x+=(P*z-P)*K,p.coordinates.y+=(T*Q-T)*te}p.dimensions||(p.dimensions={width:P,height:T}),p.frameTransform||(p.frameTransform=v);const A={x:p.coordinates.x-C,y:p.coordinates.y-St},q={width:(p.dimensions.width*p.frameTransform.scaleX-P*v.scaleX)*qe.x,height:(p.dimensions.height*p.frameTransform.scaleY-T*v.scaleY)*qe.y},$={x:A.x/v.scaleX+q.width,y:A.y/v.scaleY+q.height},D={left:I+$.x,top:G+$.y};x.setAttribute(dt,"true");const W=H(()=>c.transform),Z=(s=p.translate)!=null?s:{x:0,y:0},it=W.x*v.scaleX+Z.x,$e=W.y*v.scaleY+Z.y,se=Yc();E.set({width:P-X,height:T-_e,top:D.top+se.y,left:D.left+se.x,translate:`${it}px ${$e}px 0`,transform:this.overlay?"none":R,transition:Oe?`${Oe}, translate 0ms linear`:"translate 0ms linear",scale:j?`${M.x} ${M.y}`:"","transform-origin":`${qe.x*100}% ${qe.y*100}%`},Me),ee&&(m.insertAdjacentElement("afterend",ee),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(f):u.rootElement).appendChild(m)),qs(x)&&(x.hasAttribute("popover")||x.setAttribute("popover","manual"),Sn(x),x.addEventListener("beforetoggle",Na));let Ie,Yn,At;const _r=Qf({placeholder:ee,element:m,feedbackElement:x,frameTransform:v,transformOrigin:qe,width:P,height:T,top:G,left:I,widthOffset:X,heightOffset:_e,delta:$,styles:E,dragOperation:c,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>Ie,getSavedCellWidths:()=>At,setSavedCellWidths:z=>{At=z}}),It=new ut(x);H(()=>c.shape=It);const nn=Ke(x),Gn=z=>{this.manager.actions.stop({event:z})},Zi=Bo(nn);ct&&nn.addEventListener("resize",Gn),H(()=>f.status)==="idle"&&requestAnimationFrame(()=>f.status="dragging"),ee&&(_r.observe(ee),Ie=Zf(m,ee,F),Yn=Jf(m,ee,x));const rn=(o=l.dragOperation.source)==null?void 0:o.id,Ji=()=>{var z;if(!ct||rn==null)return;const Q=l.registry.draggables.get(rn),K=(z=Q?.handle)!=null?z:Q?.element;Pt(K)&&K.focus()},Vn=()=>{Ie?.disconnect(),Yn?.disconnect(),_r.disconnect(),nn.removeEventListener("resize",Gn),qs(x)&&(x.removeEventListener("beforetoggle",Na),x.removeAttribute("popover")),x.removeAttribute(dt),E.reset();const z=()=>{var Q;if(At&&Ks(m)){const Qi=Array.from(m.cells);for(const[Ur,sn]of Qi.entries())sn.style.width=(Q=At[Ur])!=null?Q:""}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()},qr=u?.dropAnimation,Hr=this,V=Dr(()=>{var z,Q,K;const{transform:te,status:Qi}=c;if(!(!te.x&&!te.y&&!a.current.translate)&&Qi.dragging){const Ur=(z=p.translate)!=null?z:{x:0,y:0},sn={x:te.x/v.scaleX+Ur.x,y:te.y/v.scaleY+Ur.y},va=a.current.translate,xu=H(()=>c.modifiers),es=H(()=>{var Kn;return(Kn=c.shape)==null?void 0:Kn.current}),ts=u?.keyboardTransition,ba=ct&&!Zi&&ts!==null?`${(Q=ts?.duration)!=null?Q:250}ms ${(K=ts?.easing)!=null?K:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(E.set({transition:Oe?`${Oe}, translate ${ba}`:`translate ${ba}`,translate:`${sn.x}px ${sn.y}px 0`},Me),Ie?.takeRecords(),es&&es!==It&&va&&!xu.length){const Kn=Je.delta(sn,va);c.shape=ht.from(es.boundingRectangle).translate(Kn.x*v.scaleX,Kn.y*v.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:Hr.dropAnimation!==void 0?Hr.dropAnimation:qr;let Q=a.current.translate;const K=Q!=null;if(!Q&&m!==x&&(Q={x:0,y:0}),!Q||z===null){Vn();return}l.renderer.rendering.then(()=>{np({source:f,element:m,feedbackElement:x,placeholder:ee,translate:Q,moved:K,transition:J,alignment:f.alignment,styles:E,animation:z??void 0,getElementMutationObserver:()=>Ie,cleanup:Vn,restoreFocus:Ji})})}});return()=>{Vn(),V()}};rt(Or,4,"overlay",vd,Pn,ra);tn(Or,Pn);Pn.configure=Tr(Pn);var ia=Pn,Xn=!0,rp=!1,xd,wd,kd,Sd,Mt,sa,oa;Sd=(kd=[U],Qe.Forward),wd=(xd=[U],Qe.Reverse);var Mr=class{constructor(){ge(this,sa,Se(Mt,8,this,Xn)),Se(Mt,11,this),ge(this,oa,Se(Mt,12,this,Xn)),Se(Mt,15,this)}isLocked(e){return e===Qe.Idle?!1:e==null?this[Qe.Forward]===Xn&&this[Qe.Reverse]===Xn:this[e]===Xn}unlock(e){e!==Qe.Idle&&(this[e]=rp)}};Mt=Hn(null);sa=new WeakMap;oa=new WeakMap;rt(Mt,4,Sd,kd,Mr,sa);rt(Mt,4,wd,xd,Mr,oa);tn(Mt,Mr);var ip=[Qe.Forward,Qe.Reverse],Fa=class{constructor(){this.x=new Mr,this.y=new Mr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},sp=class extends Te{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:_a(i.x,n.x),y:_a(i.y,n.y)},o=t.peek();de(()=>{for(const a of Jl)for(const l of ip)s[a]===l&&o[a].unlock(l);t.value=o})}n=i})}get current(){return this.signal.peek()}};function _a(e,t){return Math.sign(e-t)}var jd,Bs,Cr,aa,$t,Zs,Wr=class extends(Bs=Ar,jd=[U],Bs){constructor(e){super(e),ge(this,aa,Se(Cr,8,this,!1)),Se(Cr,11,this),ge(this,$t),ge(this,Zs,()=>{if(!re(this,$t))return;const{element:s,by:o}=re(this,$t);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,$t,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 m of l){const g=ef(m,d);if(g.x||g.y){const{speed:w,direction:y}=hf(m,c,f,o?.acceleration,o?.threshold);if(h)for(const p of Jl)h[p].isLocked(y[p])&&(w[p]=0,y[p]=0);if(y.x||y.y){const{x:p,y:x}=d??y,v=p*w.x,k=x*w.y;if(v||k){const j=(a=re(this,$t))==null?void 0:a.by;if(this.autoScrolling&&j&&(j.x&&!v||j.y&&!k))continue;return ze(this,$t,{element:m,by:{x:v,y:k}}),Oi.schedule(re(this,Zs)),!0}}}}}return ze(this,$t,void 0),!1};let t=null,n=null;const r=Os(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=Gc(Si(o?.element),s.current);return a&&(t=a),a??t}),i=Os(()=>{const s=r.value,{documentElement:o}=_n(s);if(!s||s===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const u=Hs(l,{excludeElement:!1});return n=u,u}}if(s){const a=Hs(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 sp(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!jr(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};Cr=Hn(Bs);aa=new WeakMap;$t=new WeakMap;Zs=new WeakMap;rt(Cr,4,"autoScrolling",jd,Wr,aa);tn(Cr,Wr);function qa(e){return e>0?Qe.Forward:e<0?Qe.Reverse:Qe.Idle}var op=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))}},ap=new op(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),lp=10,Js=class extends Te{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(()=>ap.schedule(()=>n.scroll(void 0,l)),lp);return()=>{clearInterval(u)}}else n.autoScrolling=!1}})}};Js.configure=Tr(Js);var $d=Js,Ha={capture:!0,passive:!0},ar,cp=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,Ha),()=>{s.removeEventListener("scroll",this.handleScroll,Ha)}}})}};ar=new WeakMap;var dp="* { user-select: none !important; -webkit-user-select: none !important; }",up=class extends Te{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Yi),n=t?.register(dp);if(this.destroy=nt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return cs(),document.addEventListener("selectionchange",cs,{capture:!0}),()=>{document.removeEventListener("selectionchange",cs,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function cs(){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 On{constructor(e,t){super(e),this.manager=e,this.options=t,ge(this,gn,[]),this.listeners=new Vc,this.handleSourceKeyDown=(n,r,i)=>{if(this.disabled||n.defaultPrevented||!Vt(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=>{jr(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(),ed(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=_n(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($d);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=Tr(Pi);Pi.defaults=lr;var Od=Pi;function on(e,t){return t.includes(e.code)}var qt,hp=class extends Dc{constructor(){super(...arguments),ge(this,qt)}onEvent(e){switch(e.type){case"pointerdown":ze(this,qt,Mn(e));break;case"pointermove":if(!re(this,qt))return;const{x:t,y:n}=Mn(e),r={x:t-re(this,qt).x,y:n-re(this,qt).y},{tolerance:i}=this.options;if(i&&Rs(r,i)){this.abort();return}Rs(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){ze(this,qt,void 0)}};qt=new WeakMap;var mn,Ht,fp=class extends Dc{constructor(){super(...arguments),ge(this,mn),ge(this,Ht)}onEvent(e){switch(e.type){case"pointerdown":ze(this,Ht,Mn(e)),ze(this,mn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!re(this,Ht))return;const{x:t,y:n}=Mn(e),r={x:t-re(this,Ht).x,y:n-re(this,Ht).y};Rs(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){re(this,mn)&&(clearTimeout(re(this,mn)),ze(this,Ht,void 0),ze(this,mn,void 0))}};mn=new WeakMap;Ht=new WeakMap;var wn=class{};wn.Delay=fp;wn.Distance=hp;var Qs=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&Vt(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new wn.Delay({value:250,tolerance:5})]:Sf(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||!Vt(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=Hh(r);return i===t.element?!1:!!i}}),vn,Ti=class extends On{constructor(e,t){super(e),this.manager=e,this.options=t,ge(this,vn,new Set),this.listeners=new Vc,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=Qs.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=>{kf(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&&(mp(a.ownerDocument.defaultView),a.addEventListener("pointerdown",s,{signal:i}));return()=>r.abort()})}handlePointerDown(e,t,n){if(this.disabled||!e.isPrimary||e.button!==0||!Vt(e.target)||t.disabled||pp(e)||!this.manager.dragOperation.status.idle)return;const{preventActivation:r=Qs.preventActivation}=n??{};if(r?.(e,t))return;const{target:i}=e,s=Pt(i)&&i.draggable&&i.getAttribute("draggable")==="true",o=En(t.element),{x:a,y:l}=Mn(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 Ih(u,m=>this.handleStart(t,m));c.signal.onabort=()=>this.handleCancel(e),c.onEvent(e),this.controller=c;const d=Ns(),f=this.listeners.bind(d,[{type:"pointermove",listener:m=>this.handlePointerMove(m,t)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:s?this.handleCancel:Kr,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=Mn(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=_n(t.target).body;try{i.setPointerCapture(t.pointerId)}catch{this.handleCancel(t);return}const s=Vt(t.target)?[t.target,i]:i,o=this.listeners.bind(s,[{type:"touchmove",listener:Kr,options:{passive:!1}},{type:"click",listener:Kr},{type:"contextmenu",listener:Kr},{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;Ti.configure=Tr(Ti);Ti.defaults=Qs;var eo=Ti;function pp(e){return"sensor"in e}function Kr(e){e.preventDefault()}function gp(){}var Ua=new WeakSet;function mp(e){!e||Ua.has(e)||(e.addEventListener("touchmove",gp,{capture:!1,passive:!1}),Ua.add(e))}var jn={modifiers:[],plugins:[_f,$d,Hf,ia,up],sensors:[eo,Od]},Md=class extends zh{constructor(e={}){const t=at(e.plugins,jn.plugins),n=at(e.sensors,jn.sensors),r=at(e.modifiers,jn.modifiers);super(ea($r({},e),{plugins:[cp,Wr,Yi,...t],sensors:n,modifiers:r}))}},Cd,Ed,to,Ct,la,ca,Gi=class extends(to=ft,Ed=[U],Cd=[U],to){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=od(n,["element","effects","handle"]);super($r({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 On?d:u.registry.register(d.plugin),h=d instanceof On?void 0:d.options;return f.bind(this,h)});return function(){c.forEach(d=>d())}}]},o),t),ge(this,la,Se(Ct,8,this)),Se(Ct,11,this),ge(this,ca,Se(Ct,12,this)),Se(Ct,15,this),this.element=r,this.handle=s}};Ct=Hn(to);la=new WeakMap;ca=new WeakMap;rt(Ct,4,"handle",Ed,Gi,la);rt(Ct,4,"element",Cd,Gi,ca);tn(Ct,Gi);var Dd,Pd,no,Et,da,ds,Td,Ad,yr,ua,Vi=class extends(no=pt,Pd=[U],Dd=[U],no){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=od(n,["element","effects"]);const{collisionDetector:o=nd}=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=H(()=>this.shape);return f&&h?.equals(f)?h:(this.shape=f,f)},l=An(!1);super(ea($r({},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 Qh(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,da,Se(Et,8,this)),Se(Et,11,this),ge(this,ua,Se(Et,12,this)),Se(Et,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){ze(this,yr,e,Ad)}get element(){var e;return(e=this.proxy)!=null?e:re(this,yr,Td)}};Et=Hn(no);da=new WeakMap;yr=new WeakSet;ua=new WeakMap;ds=rt(Et,20,"#element",Pd,yr,da),Td=ds.get,Ad=ds.set;rt(Et,4,"proxy",Dd,Vi,ua);tn(Et,Vi);function vp(e){return e!=null&&typeof e=="object"&&"current"in e}function $n(e){var t;if(e!=null)return vp(e)?(t=e.current)!=null?t:void 0:e}var bp=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Un=bp?S.useLayoutEffect:S.useEffect;function yp(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function Id(e,t){const n=S.useRef(new Map),r=yp();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=H(()=>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(()=>Uu.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 xp(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 pi(e,t){const n=S.useRef($n(e));Un(()=>{const r=$n(e);r!==n.current&&(n.current=r,t(r))})}var wp=Object.defineProperty,kp=Object.defineProperties,Sp=Object.getOwnPropertyDescriptors,Ai=Object.getOwnPropertySymbols,Rd=Object.prototype.hasOwnProperty,Wd=Object.prototype.propertyIsEnumerable,Ya=(e,t,n)=>t in e?wp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jp=(e,t)=>{for(var n in t||(t={}))Rd.call(t,n)&&Ya(e,n,t[n]);if(Ai)for(var n of Ai(t))Wd.call(t,n)&&Ya(e,n,t[n]);return e},$p=(e,t)=>kp(e,Sp(t)),Op=(e,t)=>{var n={};for(var r in e)Rd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ai)for(var r of Ai(e))t.indexOf(r)<0&&Wd.call(e,r)&&(n[r]=e[r]);return n},Mp=new Md,zd=S.createContext(Mp),Cp=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})),us=[void 0,st];function Ep(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=Op(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const c=S.useRef(null),{plugins:d,modifiers:f,sensors:h}=u,m=at(d,jn.plugins),g=at(h,jn.sensors),w=at(f,jn.modifiers),y=an(i),p=an(s),x=an(a),v=an(o),k=an(l),j=an(r),O=Dp(()=>{var M;return(M=u.manager)!=null?M:new Md(u)});return S.useEffect(()=>{if(!c.current)throw new Error("Renderer not found");const{renderer:M,trackRendering:P}=c.current,{monitor:T}=O;O.renderer=M;const G=[T.addEventListener("beforedragstart",I=>{const E=y.current;E&&P(()=>E(I,O))}),T.addEventListener("dragstart",I=>{var E;return(E=p.current)==null?void 0:E.call(p,I,O)}),T.addEventListener("dragover",I=>{const E=x.current;E&&P(()=>E(I,O))}),T.addEventListener("dragmove",I=>{const E=v.current;E&&P(()=>E(I,O))}),T.addEventListener("dragend",I=>{const E=k.current;E&&P(()=>E(I,O))}),T.addEventListener("collision",I=>{var E;return(E=j.current)==null?void 0:E.call(j,I,O)})];return()=>G.forEach(I=>I())},[O]),ae(m,()=>O&&(O.plugins=m),...us),ae(g,()=>O&&(O.sensors=g),...us),ae(w,()=>O&&(O.modifiers=w),...us),b.jsxs(zd.Provider,{value:O,children:[b.jsx(Cp,{ref:c,children:n}),n]})}function Dp(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 Pp(){return S.useContext(zd)}function Ld(e){var t;const n=(t=Pp())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Un(r.register,[n,r]),r}var Tp=Object.create,Nd=Object.defineProperty,Ap=Object.getOwnPropertyDescriptor,Fd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ki=e=>{throw TypeError(e)},Ip=(e,t,n)=>t in e?Nd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rp=e=>{var t;return[,,,Tp((t=e?.[Fd("metadata")])!=null?t:null)]},_d=["class","method","getter","setter","accessor","field","value","get","set"],qd=e=>e!==void 0&&typeof e!="function"?Ki("Function expected"):e,Wp=(e,t,n,r,i)=>({kind:_d[e],name:t,metadata:r,addInitializer:s=>n._?Ki("Already initialized"):i.push(qd(s||null))}),zp=(e,t)=>Ip(t,Fd("metadata"),e[3]),Lp=(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},Hd=(e,t,n,r,i,s)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,h=2,m=_d[c+5],g=e[h]||(e[h]=[]),w=(i=i.prototype,Ap(i,n)),y=r.length-1;y>=0;y--)l=Wp(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[m],l),a._=1,qd(o)&&(w[m]=o);return w&&Nd(i,n,w),i},Ud=(e,t,n)=>t.has(e)||Ki("Cannot "+n),Np=(e,t,n)=>(Ud(e,t,"read from private field"),t.get(e)),Fp=(e,t,n)=>t.has(e)?Ki("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),_p=(e,t,n,r)=>(Ud(e,t,"write to private field"),t.set(e,n),n),Yt=class ro{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ro(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 ro(t,n)}},Yd,Gd,io,gi,zr,ha=class extends(io=Qt,Gd=[fe],Yd=[fe],io){constructor(e){const t=Yt.from(e);super(t,(n,r)=>Yt.equals(n,r)),Lp(zr,5,this),Fp(this,gi,0),this.velocity={x:0,y:0}}get delta(){return Yt.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=Yt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Np(this,gi),o=a=>Math.round(a/s*100);de(()=>{_p(this,gi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Yt.from(e)),this.velocity={x:0,y:0}}};zr=Rp(io);gi=new WeakMap;Hd(zr,2,"delta",Gd,ha);Hd(zr,2,"direction",Yd,ha);zp(zr,ha);var Vd=(e=>(e.Horizontal="x",e.Vertical="y",e))(Vd||{});Object.values(Vd);var qp=({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=Yt.distance(t.shape.center,n);return{id:r,value:1/i,type:Fn.PointerIntersection,priority:Nn.High}}return null},Hp=({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=Yt.distance(t.shape.center,i.current),o=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:o,type:Fn.ShapeIntersection,priority:Nn.Normal}}return null},Up=e=>{var t;return(t=qp(e))!=null?t:Hp(e)};function Yp(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,l=Ld(c=>new Vi($p(jp({},e),{register:!1,element:$n(i)}),c)),u=Id(l);return ae(s,()=>l.id=s),pi(i,c=>l.element=c),ae(o,()=>l.accept=o,void 0,st),ae(t,()=>l.collisionDetector=t??Up),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 Gp(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 Ii(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Vp(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function mi(e,t){const n=Vp(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 Ga(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 Kp(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const Xp=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Bp(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 Va=[{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 Xr(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 so=e=>e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function Zp(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}:Ii(t.type)!==void 0?{op:Ii(t.type)}:{}}})}function Jp(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!so(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 Qp(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 eg(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 tg=Zt(b.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),ng=Zt(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"})),rg=Zt(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"})),ig=Zt(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"})),oo=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),hs=oo?"⌘":"Ctrl+",sg=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function og(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=oo?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!sg(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!oo&&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 ag({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(Sl,{left:b.jsx(go,{size:"medium",variant:"outlined",icon:b.jsx(ng,{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(Ol,{}),onClick:l,"aria-label":"Add tile",children:"Tile"}),b.jsx(ke,{startIcon:b.jsx(tg,{}),onClick:d=>u(d.currentTarget),children:"Settings"}),b.jsx(xs,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),b.jsx(kn,{title:`Undo (${hs}Z)`,children:b.jsx("span",{children:b.jsx(ws,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:b.jsx(ig,{fontSize:"small"})})})}),b.jsx(kn,{title:`Redo (${hs}⇧Z)`,children:b.jsx("span",{children:b.jsx(ws,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:b.jsx(rg,{fontSize:"small"})})})}),o&&b.jsx(b.Fragment,{children:b.jsx(kn,{title:i?`Save (${hs}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(xs,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const lg=["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&&lg.includes(n))return n}}const cg=1;function Kd(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(...Kd(a,`${t}${s}.`,n-1))}}}return r}function dg(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,Kd(i.schema?.fields,"",cg))}return t}function Xa(e,t){return!e||t===void 0?void 0:e.sources.find(n=>n.name===t)?.fields.filter(n=>n.kind==="dimension")}const ug=e=>(e??"").startsWith("dashboards/"),hg=e=>e.modelPath??e.path??"";function fg(e){const t=[],n=new Set;for(const r of e){const i=hg(r);if(ug(i))continue;const s=dg(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}}const mt=e=>`${e.source}.${e.name}`;function pg(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 gg({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=tt(),a=S.useMemo(()=>pg(t,n),[t,n]),[l,u]=S.useState(""),[c,d]=S.useState(""),[f,h]=S.useState(""),[m,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(zi,{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:m}),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(Pe,{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(Ru,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(y=>b.jsxs(Wu,{selected:c===y.name,onClick:()=>d(y.name),"aria-label":`View ${y.name}`,children:[b.jsx(Cl,{primary:y.name,secondary:y.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),y.chart&&b.jsx(go,{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(Pe,{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(Pe,{size:"small",type:"number",label:`Width (of ${r})`,value:m,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 Ba=4e3;function mg(e,t){const n=e.split(`
68
+ `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Kf(e,t="hidden"){return H(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=Xf(n,r.registry.droppables),s=[],o=qh(n),{remove:a}=o;return Bf(i,o,s),Zf(o,t),o.remove=()=>{s.forEach(l=>l()),a.call(o)},o})}function Xf(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${Rr}${Us("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function Bf(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),_s.set(a,o),n.push(()=>{_s.delete(a),r.proxy=void 0})}}function Zf(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Pi,t)}function md(e,t){return e===t?!0:Cn(e)===Cn(t)}function Na(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Vt(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>Sn(t))}function Ks(e){return e.tagName==="TR"}function Jf(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-")||Yf.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(Gf.includes(c)||c.startsWith(Me))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 Qf(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 ep(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=Yc();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},Me),(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,m=e.frameTransform;e.dragOperation.shape=new ht(c*m.scaleX+m.x,d*m.scaleY+m.y,f*m.scaleX,h*m.scaleY)})}var tp=250,np="ease";function rp(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=tp,easing:a=np}=s??{};Sn(e.feedbackElement);const[,l]=(t=qc(e.feedbackElement,p=>"translate"in p))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,c={frameTransform:md(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),m=ht.delta(d,h,e.alignment),g={x:f.x-m.x,y:f.y-m.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},Me),e.feedbackElement.setAttribute(Vs,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),td({element:e.feedbackElement,keyframes:ea($r($r({},w),y),{translate:[`${f.x}px ${f.y}px 0`,`${g.x}px ${g.y}px 0`]}),options:{duration:Bo(Ke(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(Vs),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var vd,Xs,Or,ra,fi,bd,yd,Dn=class extends(Xs=Te,vd=[U],Xs){constructor(e,t){super(e,t),ge(this,fi),ge(this,ra,Se(Or,8,this)),Se(Or,11,this),this.state={initial:{},current:{}};const n=e.registry.plugins.get(Yi),r=n?.register(Vf);if(r){const i=this.destroy.bind(this);this.destroy=()=>{r(),i()}}this.registerEffect(Kt(this,fi,bd).bind(this,n)),this.registerEffect(Kt(this,fi,yd))}};Or=Hn(Xs);ra=new WeakMap;fi=new WeakSet;bd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Si(t);if(n)return e.addRoot(n)};yd=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:m}=f,g=f.pluginConfig(Dn),w=(t=(e=g?.feedback)!=null?e:u?.feedback)!=null?t:"default",y=typeof w=="function"?w(f,l):w;if(!m||y==="none"||!h.initialized||h.initializing)return;const{initial:p}=a,x=(n=this.overlay)!=null?n:m,v=En(x),k=En(m),j=!md(m,x),O=new ut(m,{frameTransform:j?k:null,ignoreTransforms:!j}),M={x:k.scaleX/v.scaleX,y:k.scaleY/v.scaleY};let{width:D,height:T,top:G,left:I}=O;j&&(D=D/M.x,T=T/M.y);const E=new kf(x),F=gt(m),{transition:V,translate:me,boxSizing:Ae,paddingBlockStart:oe,paddingBlockEnd:Ne,paddingInlineStart:Ue,paddingInlineEnd:Ee,borderInlineStartWidth:Xe,borderInlineEndWidth:Ye,borderBlockStartWidth:_e,borderBlockEndWidth:Be}=F,Oe=V.split(",").filter(z=>!/^\s*(transform|translate|scale)\b/.test(z)).join(","),xe=Ui(F),R=F.transform,_=y==="clone",je=Ae==="content-box",B=je?parseInt(Ue)+parseInt(Ee)+parseInt(Xe)+parseInt(Ye):0,Fe=je?parseInt(oe)+parseInt(Ne)+parseInt(_e)+parseInt(Be):0,ee=y!=="move"&&!this.overlay?Kf(f,_?"clone":"hidden"):null,ct=H(()=>jr(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=H(()=>d.current),Q=I+((r=xe?.x)!=null?r:0),X=G+((i=xe?.y)!=null?i:0);p.transformOrigin={x:(z.x-Q*v.scaleX-v.x)/(D*v.scaleX),y:(z.y-X*v.scaleY-v.y)/(T*v.scaleY)}}const{transformOrigin:qe}=p,St=G*v.scaleY+v.y,C=I*v.scaleX+v.x;if(!p.coordinates&&(p.coordinates={x:C,y:St},M.x!==1||M.y!==1)){const{scaleX:z,scaleY:Q}=k,{x:X,y:te}=qe;p.coordinates.x+=(D*z-D)*X,p.coordinates.y+=(T*Q-T)*te}p.dimensions||(p.dimensions={width:D,height:T}),p.frameTransform||(p.frameTransform=v);const A={x:p.coordinates.x-C,y:p.coordinates.y-St},q={width:(p.dimensions.width*p.frameTransform.scaleX-D*v.scaleX)*qe.x,height:(p.dimensions.height*p.frameTransform.scaleY-T*v.scaleY)*qe.y},$={x:A.x/v.scaleX+q.width,y:A.y/v.scaleY+q.height},P={left:I+$.x,top:G+$.y};x.setAttribute(dt,"true");const W=H(()=>c.transform),J=(s=p.translate)!=null?s:{x:0,y:0},it=W.x*v.scaleX+J.x,$e=W.y*v.scaleY+J.y,se=Yc();E.set({width:D-B,height:T-Fe,top:P.top+se.y,left:P.left+se.x,translate:`${it}px ${$e}px 0`,transform:this.overlay?"none":R,transition:Oe?`${Oe}, translate 0ms linear`:"translate 0ms linear",scale:j?`${M.x} ${M.y}`:"","transform-origin":`${qe.x*100}% ${qe.y*100}%`},Me),ee&&(m.insertAdjacentElement("afterend",ee),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(f):u.rootElement).appendChild(m)),qs(x)&&(x.hasAttribute("popover")||x.setAttribute("popover","manual"),Sn(x),x.addEventListener("beforetoggle",Na));let Ie,Yn,At;const Fr=ep({placeholder:ee,element:m,feedbackElement:x,frameTransform:v,transformOrigin:qe,width:D,height:T,top:G,left:I,widthOffset:B,heightOffset:Fe,delta:$,styles:E,dragOperation:c,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>Ie,getSavedCellWidths:()=>At,setSavedCellWidths:z=>{At=z}}),It=new ut(x);H(()=>c.shape=It);const nn=Ke(x),Gn=z=>{this.manager.actions.stop({event:z})},Zi=Bo(nn);ct&&nn.addEventListener("resize",Gn),H(()=>f.status)==="idle"&&requestAnimationFrame(()=>f.status="dragging"),ee&&(Fr.observe(ee),Ie=Jf(m,ee,_),Yn=Qf(m,ee,x));const rn=(o=l.dragOperation.source)==null?void 0:o.id,Ji=()=>{var z;if(!ct||rn==null)return;const Q=l.registry.draggables.get(rn),X=(z=Q?.handle)!=null?z:Q?.element;Dt(X)&&X.focus()},Vn=()=>{Ie?.disconnect(),Yn?.disconnect(),Fr.disconnect(),nn.removeEventListener("resize",Gn),qs(x)&&(x.removeEventListener("beforetoggle",Na),x.removeAttribute("popover")),x.removeAttribute(dt),E.reset();const z=()=>{var Q;if(At&&Ks(m)){const Qi=Array.from(m.cells);for(const[Ur,sn]of Qi.entries())sn.style.width=(Q=At[Ur])!=null?Q:""}f.status="idle";const X=a.current.translate!=null,te=c.status.dragging;ee&&(!te&&X||ee.parentElement!==x.parentElement)&&x.isConnected&&ee.replaceWith(x),ee?.remove()};x===this.overlay?setTimeout(z,0):z()},qr=u?.dropAnimation,Hr=this,K=Pr(()=>{var z,Q,X;const{transform:te,status:Qi}=c;if(!(!te.x&&!te.y&&!a.current.translate)&&Qi.dragging){const Ur=(z=p.translate)!=null?z:{x:0,y:0},sn={x:te.x/v.scaleX+Ur.x,y:te.y/v.scaleY+Ur.y},va=a.current.translate,wu=H(()=>c.modifiers),es=H(()=>{var Kn;return(Kn=c.shape)==null?void 0:Kn.current}),ts=u?.keyboardTransition,ba=ct&&!Zi&&ts!==null?`${(Q=ts?.duration)!=null?Q:250}ms ${(X=ts?.easing)!=null?X:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(E.set({transition:Oe?`${Oe}, translate ${ba}`:`translate ${ba}`,translate:`${sn.x}px ${sn.y}px 0`},Me),Ie?.takeRecords(),es&&es!==It&&va&&!wu.length){const Kn=Je.delta(sn,va);c.shape=ht.from(es.boundingRectangle).translate(Kn.x*v.scaleX,Kn.y*v.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:Hr.dropAnimation!==void 0?Hr.dropAnimation:qr;let Q=a.current.translate;const X=Q!=null;if(!Q&&m!==x&&(Q={x:0,y:0}),!Q||z===null){Vn();return}l.renderer.rendering.then(()=>{rp({source:f,element:m,feedbackElement:x,placeholder:ee,translate:Q,moved:X,transition:V,alignment:f.alignment,styles:E,animation:z??void 0,getElementMutationObserver:()=>Ie,cleanup:Vn,restoreFocus:Ji})})}});return()=>{Vn(),K()}};rt(Or,4,"overlay",vd,Dn,ra);tn(Or,Dn);Dn.configure=Tr(Dn);var ia=Dn,Xn=!0,ip=!1,xd,wd,kd,Sd,Mt,sa,oa;Sd=(kd=[U],Qe.Forward),wd=(xd=[U],Qe.Reverse);var Mr=class{constructor(){ge(this,sa,Se(Mt,8,this,Xn)),Se(Mt,11,this),ge(this,oa,Se(Mt,12,this,Xn)),Se(Mt,15,this)}isLocked(e){return e===Qe.Idle?!1:e==null?this[Qe.Forward]===Xn&&this[Qe.Reverse]===Xn:this[e]===Xn}unlock(e){e!==Qe.Idle&&(this[e]=ip)}};Mt=Hn(null);sa=new WeakMap;oa=new WeakMap;rt(Mt,4,Sd,kd,Mr,sa);rt(Mt,4,wd,xd,Mr,oa);tn(Mt,Mr);var sp=[Qe.Forward,Qe.Reverse],_a=class{constructor(){this.x=new Mr,this.y=new Mr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},op=class extends Te{constructor(e){super(e);const t=An(new _a);let n=null;this.signal=t,nt(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new _a;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:Fa(i.x,n.x),y:Fa(i.y,n.y)},o=t.peek();de(()=>{for(const a of Jl)for(const l of sp)s[a]===l&&o[a].unlock(l);t.value=o})}n=i})}get current(){return this.signal.peek()}};function Fa(e,t){return Math.sign(e-t)}var jd,Bs,Cr,aa,$t,Zs,Wr=class extends(Bs=Ar,jd=[U],Bs){constructor(e){super(e),ge(this,aa,Se(Cr,8,this,!1)),Se(Cr,11,this),ge(this,$t),ge(this,Zs,()=>{if(!re(this,$t))return;const{element:s,by:o}=re(this,$t);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,$t,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 m of l){const g=tf(m,d);if(g.x||g.y){const{speed:w,direction:y}=ff(m,c,f,o?.acceleration,o?.threshold);if(h)for(const p of Jl)h[p].isLocked(y[p])&&(w[p]=0,y[p]=0);if(y.x||y.y){const{x:p,y:x}=d??y,v=p*w.x,k=x*w.y;if(v||k){const j=(a=re(this,$t))==null?void 0:a.by;if(this.autoScrolling&&j&&(j.x&&!v||j.y&&!k))continue;return ze(this,$t,{element:m,by:{x:v,y:k}}),Oi.schedule(re(this,Zs)),!0}}}}}return ze(this,$t,void 0),!1};let t=null,n=null;const r=Os(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=Gc(Si(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=Hs(l,{excludeElement:!1});return n=u,u}}if(s){const a=Hs(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 op(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!jr(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};Cr=Hn(Bs);aa=new WeakMap;$t=new WeakMap;Zs=new WeakMap;rt(Cr,4,"autoScrolling",jd,Wr,aa);tn(Cr,Wr);function qa(e){return e>0?Qe.Forward:e<0?Qe.Reverse:Qe.Idle}var ap=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))}},lp=new ap(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),cp=10,Js=class extends Te{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(()=>lp.schedule(()=>n.scroll(void 0,l)),cp);return()=>{clearInterval(u)}}else n.autoScrolling=!1}})}};Js.configure=Tr(Js);var $d=Js,Ha={capture:!0,passive:!0},ar,dp=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,Ha),()=>{s.removeEventListener("scroll",this.handleScroll,Ha)}}})}};ar=new WeakMap;var up="* { user-select: none !important; -webkit-user-select: none !important; }",hp=class extends Te{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Yi),n=t?.register(up);if(this.destroy=nt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return cs(),document.addEventListener("selectionchange",cs,{capture:!0}),()=>{document.removeEventListener("selectionchange",cs,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function cs(){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,Di=class extends On{constructor(e,t){super(e),this.manager=e,this.options=t,ge(this,gn,[]),this.listeners=new Vc,this.handleSourceKeyDown=(n,r,i)=>{if(this.disabled||n.defaultPrevented||!Vt(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=>{jr(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(),ed(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($d);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;Di.configure=Tr(Di);Di.defaults=lr;var Od=Di;function on(e,t){return t.includes(e.code)}var qt,fp=class extends Pc{constructor(){super(...arguments),ge(this,qt)}onEvent(e){switch(e.type){case"pointerdown":ze(this,qt,Mn(e));break;case"pointermove":if(!re(this,qt))return;const{x:t,y:n}=Mn(e),r={x:t-re(this,qt).x,y:n-re(this,qt).y},{tolerance:i}=this.options;if(i&&Rs(r,i)){this.abort();return}Rs(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){ze(this,qt,void 0)}};qt=new WeakMap;var mn,Ht,pp=class extends Pc{constructor(){super(...arguments),ge(this,mn),ge(this,Ht)}onEvent(e){switch(e.type){case"pointerdown":ze(this,Ht,Mn(e)),ze(this,mn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!re(this,Ht))return;const{x:t,y:n}=Mn(e),r={x:t-re(this,Ht).x,y:n-re(this,Ht).y};Rs(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){re(this,mn)&&(clearTimeout(re(this,mn)),ze(this,Ht,void 0),ze(this,mn,void 0))}};mn=new WeakMap;Ht=new WeakMap;var wn=class{};wn.Delay=pp;wn.Distance=fp;var Qs=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&Vt(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new wn.Delay({value:250,tolerance:5})]:jf(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||!Vt(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=Uh(r);return i===t.element?!1:!!i}}),vn,Ti=class extends On{constructor(e,t){super(e),this.manager=e,this.options=t,ge(this,vn,new Set),this.listeners=new Vc,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=Qs.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=>{Sf(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&&(vp(a.ownerDocument.defaultView),a.addEventListener("pointerdown",s,{signal:i}));return()=>r.abort()})}handlePointerDown(e,t,n){if(this.disabled||!e.isPrimary||e.button!==0||!Vt(e.target)||t.disabled||gp(e)||!this.manager.dragOperation.status.idle)return;const{preventActivation:r=Qs.preventActivation}=n??{};if(r?.(e,t))return;const{target:i}=e,s=Dt(i)&&i.draggable&&i.getAttribute("draggable")==="true",o=En(t.element),{x:a,y:l}=Mn(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 Rh(u,m=>this.handleStart(t,m));c.signal.onabort=()=>this.handleCancel(e),c.onEvent(e),this.controller=c;const d=Ns(),f=this.listeners.bind(d,[{type:"pointermove",listener:m=>this.handlePointerMove(m,t)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:s?this.handleCancel:Kr,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=Mn(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=Vt(t.target)?[t.target,i]:i,o=this.listeners.bind(s,[{type:"touchmove",listener:Kr,options:{passive:!1}},{type:"click",listener:Kr},{type:"contextmenu",listener:Kr},{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;Ti.configure=Tr(Ti);Ti.defaults=Qs;var eo=Ti;function gp(e){return"sensor"in e}function Kr(e){e.preventDefault()}function mp(){}var Ua=new WeakSet;function vp(e){!e||Ua.has(e)||(e.addEventListener("touchmove",mp,{capture:!1,passive:!1}),Ua.add(e))}var jn={modifiers:[],plugins:[qf,$d,Uf,ia,hp],sensors:[eo,Od]},Md=class extends Lh{constructor(e={}){const t=at(e.plugins,jn.plugins),n=at(e.sensors,jn.sensors),r=at(e.modifiers,jn.modifiers);super(ea($r({},e),{plugins:[dp,Wr,Yi,...t],sensors:n,modifiers:r}))}},Cd,Ed,to,Ct,la,ca,Gi=class extends(to=ft,Ed=[U],Cd=[U],to){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=od(n,["element","effects","handle"]);super($r({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 On?d:u.registry.register(d.plugin),h=d instanceof On?void 0:d.options;return f.bind(this,h)});return function(){c.forEach(d=>d())}}]},o),t),ge(this,la,Se(Ct,8,this)),Se(Ct,11,this),ge(this,ca,Se(Ct,12,this)),Se(Ct,15,this),this.element=r,this.handle=s}};Ct=Hn(to);la=new WeakMap;ca=new WeakMap;rt(Ct,4,"handle",Ed,Gi,la);rt(Ct,4,"element",Cd,Gi,ca);tn(Ct,Gi);var Pd,Dd,no,Et,da,ds,Td,Ad,yr,ua,Vi=class extends(no=pt,Dd=[U],Pd=[U],no){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=od(n,["element","effects"]);const{collisionDetector:o=nd}=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=H(()=>this.shape);return f&&h?.equals(f)?h:(this.shape=f,f)},l=An(!1);super(ea($r({},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 ef(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,da,Se(Et,8,this)),Se(Et,11,this),ge(this,ua,Se(Et,12,this)),Se(Et,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){ze(this,yr,e,Ad)}get element(){var e;return(e=this.proxy)!=null?e:re(this,yr,Td)}};Et=Hn(no);da=new WeakMap;yr=new WeakSet;ua=new WeakMap;ds=rt(Et,20,"#element",Dd,yr,da),Td=ds.get,Ad=ds.set;rt(Et,4,"proxy",Pd,Vi,ua);tn(Et,Vi);function bp(e){return e!=null&&typeof e=="object"&&"current"in e}function $n(e){var t;if(e!=null)return bp(e)?(t=e.current)!=null?t:void 0:e}var yp=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Un=yp?S.useLayoutEffect:S.useEffect;function xp(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function Id(e,t){const n=S.useRef(new Map),r=xp();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=H(()=>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(()=>Yu.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 wp(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 pi(e,t){const n=S.useRef($n(e));Un(()=>{const r=$n(e);r!==n.current&&(n.current=r,t(r))})}var kp=Object.defineProperty,Sp=Object.defineProperties,jp=Object.getOwnPropertyDescriptors,Ai=Object.getOwnPropertySymbols,Rd=Object.prototype.hasOwnProperty,Wd=Object.prototype.propertyIsEnumerable,Ya=(e,t,n)=>t in e?kp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$p=(e,t)=>{for(var n in t||(t={}))Rd.call(t,n)&&Ya(e,n,t[n]);if(Ai)for(var n of Ai(t))Wd.call(t,n)&&Ya(e,n,t[n]);return e},Op=(e,t)=>Sp(e,jp(t)),Mp=(e,t)=>{var n={};for(var r in e)Rd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ai)for(var r of Ai(e))t.indexOf(r)<0&&Wd.call(e,r)&&(n[r]=e[r]);return n},Cp=new Md,zd=S.createContext(Cp),Ep=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})),us=[void 0,st];function Pp(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=Mp(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const c=S.useRef(null),{plugins:d,modifiers:f,sensors:h}=u,m=at(d,jn.plugins),g=at(h,jn.sensors),w=at(f,jn.modifiers),y=an(i),p=an(s),x=an(a),v=an(o),k=an(l),j=an(r),O=Dp(()=>{var M;return(M=u.manager)!=null?M:new Md(u)});return S.useEffect(()=>{if(!c.current)throw new Error("Renderer not found");const{renderer:M,trackRendering:D}=c.current,{monitor:T}=O;O.renderer=M;const G=[T.addEventListener("beforedragstart",I=>{const E=y.current;E&&D(()=>E(I,O))}),T.addEventListener("dragstart",I=>{var E;return(E=p.current)==null?void 0:E.call(p,I,O)}),T.addEventListener("dragover",I=>{const E=x.current;E&&D(()=>E(I,O))}),T.addEventListener("dragmove",I=>{const E=v.current;E&&D(()=>E(I,O))}),T.addEventListener("dragend",I=>{const E=k.current;E&&D(()=>E(I,O))}),T.addEventListener("collision",I=>{var E;return(E=j.current)==null?void 0:E.call(j,I,O)})];return()=>G.forEach(I=>I())},[O]),ae(m,()=>O&&(O.plugins=m),...us),ae(g,()=>O&&(O.sensors=g),...us),ae(w,()=>O&&(O.modifiers=w),...us),b.jsxs(zd.Provider,{value:O,children:[b.jsx(Ep,{ref:c,children:n}),n]})}function Dp(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 Tp(){return S.useContext(zd)}function Ld(e){var t;const n=(t=Tp())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Un(r.register,[n,r]),r}var Ap=Object.create,Nd=Object.defineProperty,Ip=Object.getOwnPropertyDescriptor,_d=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ki=e=>{throw TypeError(e)},Rp=(e,t,n)=>t in e?Nd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wp=e=>{var t;return[,,,Ap((t=e?.[_d("metadata")])!=null?t:null)]},Fd=["class","method","getter","setter","accessor","field","value","get","set"],qd=e=>e!==void 0&&typeof e!="function"?Ki("Function expected"):e,zp=(e,t,n,r,i)=>({kind:Fd[e],name:t,metadata:r,addInitializer:s=>n._?Ki("Already initialized"):i.push(qd(s||null))}),Lp=(e,t)=>Rp(t,_d("metadata"),e[3]),Np=(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},Hd=(e,t,n,r,i,s)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,h=2,m=Fd[c+5],g=e[h]||(e[h]=[]),w=(i=i.prototype,Ip(i,n)),y=r.length-1;y>=0;y--)l=zp(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[m],l),a._=1,qd(o)&&(w[m]=o);return w&&Nd(i,n,w),i},Ud=(e,t,n)=>t.has(e)||Ki("Cannot "+n),_p=(e,t,n)=>(Ud(e,t,"read from private field"),t.get(e)),Fp=(e,t,n)=>t.has(e)?Ki("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qp=(e,t,n,r)=>(Ud(e,t,"write to private field"),t.set(e,n),n),Yt=class ro{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ro(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 ro(t,n)}},Yd,Gd,io,gi,zr,ha=class extends(io=Qt,Gd=[fe],Yd=[fe],io){constructor(e){const t=Yt.from(e);super(t,(n,r)=>Yt.equals(n,r)),Np(zr,5,this),Fp(this,gi,0),this.velocity={x:0,y:0}}get delta(){return Yt.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=Yt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-_p(this,gi),o=a=>Math.round(a/s*100);de(()=>{qp(this,gi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Yt.from(e)),this.velocity={x:0,y:0}}};zr=Wp(io);gi=new WeakMap;Hd(zr,2,"delta",Gd,ha);Hd(zr,2,"direction",Yd,ha);Lp(zr,ha);var Vd=(e=>(e.Horizontal="x",e.Vertical="y",e))(Vd||{});Object.values(Vd);var Hp=({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=Yt.distance(t.shape.center,n);return{id:r,value:1/i,type:_n.PointerIntersection,priority:Nn.High}}return null},Up=({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=Yt.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},Yp=e=>{var t;return(t=Hp(e))!=null?t:Up(e)};function Gp(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,l=Ld(c=>new Vi(Op($p({},e),{register:!1,element:$n(i)}),c)),u=Id(l);return ae(s,()=>l.id=s),pi(i,c=>l.element=c),ae(o,()=>l.accept=o,void 0,st),ae(t,()=>l.collisionDetector=t??Yp),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 Vp(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 Ii(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Kp(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function mi(e,t){const n=Kp(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 Ga(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 Xp(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const Bp=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Zp(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 Va=[{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 Xr(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 so=e=>e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function Jp(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}:Ii(t.type)!==void 0?{op:Ii(t.type)}:{}}})}function Qp(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!so(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 eg(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 tg(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 ng=Zt(b.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),rg=Zt(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"})),ig=Zt(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"})),sg=Zt(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"})),oo=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),hs=oo?"⌘":"Ctrl+",og=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function ag(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=oo?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!og(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!oo&&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 lg({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(Sl,{left:b.jsx(go,{size:"medium",variant:"outlined",icon:b.jsx(rg,{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(Ol,{}),onClick:l,"aria-label":"Add tile",children:"Tile"}),b.jsx(ke,{startIcon:b.jsx(ng,{}),onClick:d=>u(d.currentTarget),children:"Settings"}),b.jsx(xs,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),b.jsx(kn,{title:`Undo (${hs}Z)`,children:b.jsx("span",{children:b.jsx(ws,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:b.jsx(sg,{fontSize:"small"})})})}),b.jsx(kn,{title:`Redo (${hs}⇧Z)`,children:b.jsx("span",{children:b.jsx(ws,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:b.jsx(ig,{fontSize:"small"})})})}),o&&b.jsx(b.Fragment,{children:b.jsx(kn,{title:i?`Save (${hs}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(xs,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const cg=["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&&cg.includes(n))return n}}const dg=1;function Kd(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(...Kd(a,`${t}${s}.`,n-1))}}}return r}function ug(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,Kd(i.schema?.fields,"",dg))}return t}function Xa(e,t){return!e||t===void 0?void 0:e.sources.find(n=>n.name===t)?.fields.filter(n=>n.kind==="dimension")}const hg=e=>(e??"").startsWith("dashboards/"),Xd=e=>e.modelPath??e.path??"";function fg(e){const t=[],n=new Set;for(const r of e){const i=Xd(r);if(hg(i))continue;const s=ug(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 pg(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=>Xd(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 gg(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 mg({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=tt(),a=S.useMemo(()=>gg(t,n),[t,n]),[l,u]=S.useState(""),[c,d]=S.useState(""),[f,h]=S.useState(""),[m,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(zi,{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:m}),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(De,{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(Wu,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(y=>b.jsxs(zu,{selected:c===y.name,onClick:()=>d(y.name),"aria-label":`View ${y.name}`,children:[b.jsx(Cl,{primary:y.name,secondary:y.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),y.chart&&b.jsx(go,{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(De,{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(De,{size:"small",type:"number",label:`Width (of ${r})`,value:m,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 Ba=4e3;function vg(e,t){const n=e.split(`
69
69
  `),r=t.split(`
70
- `);if(n.length>Ba||r.length>Ba)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 vg(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 bg({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=tt(),o=S.useMemo(()=>e?vg(mg(t,n)):[],[e,t,n]),a=o.filter(u=>u.kind==="add").length,l=o.filter(u=>u.kind==="del").length;return b.jsx(zi,{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 fs="self";function yg({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(m=>m.source===n.name);u((n.dimensions??[]).map(m=>{const g=h.find(w=>w.name===m.name);return{name:m.name,expression:m.expression,to:g?.to??[],given:g?.given??""}}))},[e,n,t]);const c=(h,m)=>u(g=>g.map((w,y)=>{if(y!==h)return w;const p={...w};return m(p),p})),d=[fs,...i.filter(h=>h!==fs)],f=h=>h===fs?"This dashboard":h;return b.jsx(zi,{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,m)=>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(Pe,{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(m,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(ks,{size:"small",checked:h.to.includes(g),sx:{p:0,mr:1}}),b.jsx(Cl,{primary:f(g)})]},g))}),b.jsxs(Pe,{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(m,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 Xd=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function xg({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,m]=S.useState("select"),[g,w]=S.useState(""),[y,p]=S.useState(""),[x,v]=S.useState([]),[k,j]=S.useState(!1),O=C=>t.sources.find(A=>A.name===C.source)?.base??C.source;S.useEffect(()=>{if(e)if(n){c({kind:"existing",name:n.name}),f(n.label??"");const C=Zp(t,n);v(C);const A=C.filter($=>$.include),q=new Set(A.map($=>$.field));p(q.size===1?A[0].field:n.field??""),j(q.size>1)}else c({kind:"new"}),f(""),m("select"),p(""),w(new Date().toISOString().slice(0,10)),v(t.tiles.map(C=>({include:so(C),field:""}))),j(!1)},[e,n,t]);const M=S.useMemo(()=>[...(t.localGivens??[]).map(C=>C.name),...r.map(C=>C.name)],[t,r]),P=S.useMemo(()=>y.trim()?Bp(y.trim(),M):"",[y,M]),T=u.kind==="existing"?n??r.find(C=>C.name===u.name):P?{name:P,type:Xr({name:P,label:d,kind:h,field:y}).type}:void 0,G=T?.type!==void 0&&!T.type.startsWith("filter<"),I=x.find(C=>C.include)?.op??Ii(T?.type),E=(C,A)=>v(q=>q.map(($,D)=>D===C?{...$,...A}:$)),_=C=>v(A=>A.map(q=>({...q,op:C}))),J=C=>{const A=Ii(C);v(q=>q.map(({op:$,...D})=>A?{...D,op:A}:D))},me=C=>{c({kind:"existing",name:C.name}),p(C.field??""),J(C.type)},Ae=C=>{m(C),J(Xr({name:"X",label:d,kind:C,field:y}).type)},oe=t.tiles.map(so),Ne=oe.filter(Boolean).length,Ue=x.filter((C,A)=>C.include&&oe[A]).length,Ee=t.tiles.filter((C,A)=>(x[A]?.include??!1)&&oe[A]),Xe=Ee.length>0?Ee:t.tiles.filter((C,A)=>oe[A]),Ye=S.useMemo(()=>{const C=new Map;let A=!1;for(const q of Xe){const $=i?.(q);if($){A=!0;for(const D of $)C.has(D.name)||C.set(D.name,D)}}return A?[...C.values()]:void 0},[x,t.tiles,i]),Fe=(()=>{const C=y.trim();for(const A of Ee){const q=i?.(A);if(!q||q.some($=>$.name===C))return O(A)}return Ee[0]?O(Ee[0]):t.sources[0]?.base})(),Be=C=>v(A=>A.map((q,$)=>({...q,include:C&&oe[$]}))),Oe=S.useMemo(()=>k?x:x.map(C=>({...C,field:y})),[k,x,y]),xe=C=>{for(const A of Xe){const q=i?.(A)?.find($=>$.name===C.trim());if(q?.type)return q.type}},R=C=>mi(T?.type,C.type),F=(C,A)=>{if(C.trim()==="")return"Pick the field this filter compares.";const q=A?i?.(A):void 0;if(!q)return;const $=q.find(D=>D.name===C.trim());if(!$)return`Not a field of ${A?O(A):"the tiles' source"}.`;if($.type&&!mi(T?.type,$.type))return`${C.trim()} is ${Ga($.type)}; this filter compares ${Ga(T?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},je=C=>{if(p(C),l||u.kind!=="new")return;const A=xe(C),q=Xr({name:"X",label:d,kind:h,field:C}).type;A&&!mi(q,A)&&Ae(Kp(A))},X=Oe.map((C,A)=>C.include&&oe[A]?F(C.field,t.tiles[A]):void 0),_e=X.every(C=>C===void 0),ee=!k&&Ue>0?Ee.map(C=>F(y,C)).find(Boolean):void 0,ct=T!==void 0&&_e&&(u.kind==="existing"||y.trim()!==""&&P!==""),qe=()=>{if(!(!T||!ct))if(u.kind==="new")s(T.name,Oe,Xr({name:T.name,label:d.trim()||Xd(T.name),kind:h,field:y.trim(),...Fe?{source:Fe}:{},...g?{dateDefault:g}:{}}));else if(n?.origin==="dashboard"&&n.local){const C=d.trim(),A=C!==(n.local.label??"");s(T.name,Oe,A?{...n.local,...C?{label:C}:{}}:void 0)}else s(T.name,Oe)},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:v,perTile:k,setPerTile:j,newName:P,target:T,valueTyped:G,commonOp:I,setRow:E,setCommonOp:_,pickExisting:me,pickKind:Ae,bindable:oe,bindableCount:Ne,included:Ue,commonFields:Ye,setAll:Be,accepts:R,pickField:je,rowProblems:X,commonProblem:ee,canApply:ct,apply:qe}}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(m=>r?.(m)??!0).map(m=>m.name),[n,r]),h=S.useMemo(()=>new Map((n??[]).map(m=>[m.name,m.type])),[n]);return b.jsx(qu,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(m,g)=>t(g),value:e,onChange:(m,g)=>t(typeof g=="string"?g:""),disabled:l,disableClearable:!0,renderOption:(m,g)=>S.createElement("li",{...m,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:m=>b.jsx(Pe,{...m,label:i,placeholder:c,autoFocus:u,error:o,helperText:a,inputProps:{...m.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 wg({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:m,setLabel:g,kind:w,dateDefault:y,setDateDefault:p,field:x,rows:v,setRows:k,perTile:j,setPerTile:O,newName:M,target:P,valueTyped:T,commonOp:G,setRow:I,setCommonOp:E,pickExisting:_,pickKind:J,bindable:me,bindableCount:Ae,included:oe,commonFields:Ne,setAll:Ue,accepts:Ee,pickField:Xe,rowProblems:Ye,commonProblem:Fe,canApply:Be,apply:Oe}=xg({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),xe=(R,F,je)=>b.jsx(Pe,{select:!0,size:"small",label:"Compares",value:R??">=",onChange:X=>F(X.target.value),inputProps:{"aria-label":je},sx:{width:130},children:Xp.filter(X=>X.op!=="~").map(X=>b.jsx(bt,{value:X.op,children:X.label},X.op))});return b.jsx(zi,{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||P===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:Oe,disabled:!Be,children:u?"Apply":"Add filter"})})})]}),children:b.jsxs(he,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&b.jsxs(Yu,{exclusive:!0,size:"small",value:f.kind,onChange:(R,F)=>{F==="new"?h({kind:"new"}):F==="existing"&&r[0]&&_(r[0])},"aria-label":"Where the filter comes from",children:[b.jsx(xa,{value:"new",children:"New in this dashboard"}),b.jsx(xa,{value:"existing",children:"From the model"})]}),!u&&f.kind==="existing"?b.jsx(Pe,{select:!0,size:"small",label:"Control",value:f.name,onChange:R=>{const F=r.find(je=>je.name===R.target.value);F&&_(F)},children:r.map(R=>b.jsxs(bt,{value:R.name,children:[R.label??R.name,b.jsxs(ne,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",R.name]})]},R.name))}):null,b.jsxs(he,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!j&&b.jsx(Za,{value:x,onChange:Xe,fields:Ne,accepts:Ee,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:Fe!==void 0,helperText:Fe??(!u&&M?`Declared as $${M}`:void 0),sx:{flex:1,minWidth:200}}),!d&&b.jsx(Pe,{size:"small",label:"Label",placeholder:M?Xd(M):"",value:m,onChange:R=>g(R.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),T&&!j&&xe(G,E,"Comparison")]}),!u&&f.kind==="new"&&b.jsxs(he,{direction:"row",sx:{gap:1.5},children:[b.jsx(Pe,{select:!0,size:"small",label:"Control",value:w,onChange:R=>J(R.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:R=>Va.find(F=>F.kind===R)?.label??String(R)}},sx:{flex:1},children:Va.map(R=>b.jsxs(bt,{value:R.kind,children:[R.label,b.jsx(ne,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:R.hint})]},R.kind))}),w==="date"&&b.jsx(Pe,{size:"small",type:"date",label:"Starts at",value:y,onChange:R=>p(R.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(ks,{size:"small",checked:Ae>0&&oe===Ae,indeterminate:oe>0&&oe<Ae,disabled:Ae===0,onChange:R=>Ue(R.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:()=>{j||k(R=>R.map(F=>({...F,field:x}))),O(R=>!R)},children:j?"Same field for all":"Adjust per tile"})]}),b.jsx(he,{sx:{gap:j?1:0},children:t.tiles.map((R,F)=>{const je=v[F],X=R.label??R.name,_e=j?Ye[F]:void 0;return b.jsxs(he,{direction:"row",sx:{gap:1,alignItems:j?"flex-start":"center",opacity:me[F]?1:.6},children:[b.jsx(ks,{size:"small",disabled:!me[F],checked:(je?.include??!1)&&me[F],inputProps:{"aria-label":`Filter ${X}`},onChange:ee=>I(F,{include:ee.target.checked})}),b.jsx(ne,{variant:"body2",sx:{flex:1,minWidth:0,pt:j?1:0},noWrap:!0,children:X}),me[F]?j&&b.jsxs(b.Fragment,{children:[T&&xe(je?.op,ee=>I(F,{op:ee}),`Comparison for ${X}`),b.jsx(Za,{value:je?.field??"",onChange:ee=>I(F,{field:ee}),fields:i?.(R),accepts:Ee,label:"Field",ariaLabel:`Field for ${X}`,disabled:!je?.include,error:_e!==void 0,helperText:_e,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})})]},`${R.source}.${R.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 Bd(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 kg=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}}),ps=[2,3,4,6,8,12,16,24];function Sg({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=tt(),{draft:s,patch:o,close:a}=Bd(t,e!==null,r,n),l=s?.columns!==void 0&&!ps.includes(s.columns)?[...ps,s.columns].sort((u,c)=>u-c):ps;return b.jsx(Ml,{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(Pe,{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(Pe,{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(Pe,{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(Au,{control:b.jsx(Iu,{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 jg=Zt(b.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function $g({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(jg,{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(go,{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(jl,{label:"Filter",icon:b.jsx(Ol,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const Og=(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}),Mg=(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},Zd=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),Jd=e=>`gap.${e}`,Cg=(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(Zd(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 Eg=Object.create,Qd=Object.defineProperty,Dg=Object.defineProperties,Pg=Object.getOwnPropertyDescriptor,Tg=Object.getOwnPropertyDescriptors,Ri=Object.getOwnPropertySymbols,eu=Object.prototype.hasOwnProperty,tu=Object.prototype.propertyIsEnumerable,Ag=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Lr=e=>{throw TypeError(e)},ao=(e,t,n)=>t in e?Qd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gs=(e,t)=>{for(var n in t||(t={}))eu.call(t,n)&&ao(e,n,t[n]);if(Ri)for(var n of Ri(t))tu.call(t,n)&&ao(e,n,t[n]);return e},ms=(e,t)=>Dg(e,Tg(t)),Ig=(e,t)=>{var n={};for(var r in e)eu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ri)for(var r of Ri(e))t.indexOf(r)<0&&tu.call(e,r)&&(n[r]=e[r]);return n},Rg=e=>{var t;return[,,,Eg((t=void 0)!=null?t:null)]},nu=["class","method","getter","setter","accessor","field","value","get","set"],cr=e=>e!==void 0&&typeof e!="function"?Lr("Function expected"):e,Wg=(e,t,n,r,i)=>({kind:nu[e],name:t,metadata:r,addInitializer:s=>n._?Lr("Already initialized"):i.push(cr(s||null))}),zg=(e,t)=>ao(t,Ag("metadata"),e[3]),Zr=(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},ru=(e,t,n,r,i,s)=>{for(var o,a,l,u,c,d=t&7,f=!1,h=!1,m=e.length+1,g=nu[d+5],w=e[m-1]=[],y=e[m]||(e[m]=[]),p=(i=i.prototype,Pg({get[n](){return dr(this,s)},set[n](v){return Ut(this,s,v)}},n)),x=r.length-1;x>=0;x--)u=Wg(d,n,l={},e[3],y),u.static=f,u.private=h,c=u.access={has:v=>n in v},c.get=v=>v[n],c.set=(v,k)=>v[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&&Qd(i,n,p),i},iu=(e,t,n)=>t.has(e)||Lr("Cannot "+n),dr=(e,t,n)=>(iu(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)=>(iu(e,t,"write to private field"),t.set(e,n),n);function Gt(e){return e instanceof ga||e instanceof lu}var Jr=10,Lg=class extends Te{constructor(e){super(e);const t=nt(()=>{const{dragOperation:r}=e;if(jr(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(!jr(r.nativeEvent)||!Gt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:l}=i,{by:u}=r;if(!u)return;const c=Ng(u),{source:d,target:f}=s,{center:h}=s.shape.current,m=[],g=[];de(()=>{for(const k of l.droppables){const{id:j}=k;if(!k.accepts(d)||j===f?.id&&Gt(k)||!k.element)continue;let O=k.shape;const M=new ut(k.element,{getBoundingClientRect:P=>kr(P,void 0,.2)});!M.height||!M.width||(c=="down"&&h.y+Jr<M.center.y||c=="up"&&h.y-Jr>M.center.y||c=="left"&&h.x-Jr>M.center.x||c=="right"&&h.x+Jr<M.center.x)&&(m.push(k),k.shape=M,g.push(()=>k.shape=O))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(m,Of);de(()=>g.forEach(k=>k()));const[y]=w;if(!y)return;const{id:p}=y,{index:x,group:v}=d.sortable;o.setDropTarget(p).then(()=>{const{source:k,target:j,shape:O}=s;if(!k||!Gt(k)||!O)return;const{index:M,group:P,target:T}=k.sortable,G=x!==M||v!==P,I=G?T:j?.element;if(!I)return;ed(I);const E=new ut(I);if(!E)return;const _=ht.delta(E,ht.from(O.current.boundingRectangle),k.alignment);o.move({by:_}),G?o.setDropTarget(k.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Ng(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 Fg=Object.defineProperty,_g=Object.defineProperties,qg=Object.getOwnPropertyDescriptors,Qa=Object.getOwnPropertySymbols,Hg=Object.prototype.hasOwnProperty,Ug=Object.prototype.propertyIsEnumerable,el=(e,t,n)=>t in e?Fg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ln=(e,t)=>{for(var n in t||(t={}))Hg.call(t,n)&&el(e,n,t[n]);if(Qa)for(var n of Qa(t))Ug.call(t,n)&&el(e,n,t[n]);return e},cn=(e,t)=>_g(e,qg(t));function Yg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Qr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function vs(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Gg(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(v=>l(v,s.id)),x=e.findIndex(v=>l(v,o.id));if(p===-1||x===-1){if(vs(s)){const v=s.initialIndex,k=s.index;return v===k||v<0||v>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,v,k)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const v=s.index;if(v!==p)return n(e,p,v)}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(v=>l(v,s.id)),c!==-1&&(d=p)),f===-1&&(f=x.findIndex(v=>l(v,o.id)),f!==-1&&(h=p)),c!==-1&&f!==-1)break;if(c===-1&&vs(s)){const p=s.initialGroup==null?void 0:Qr(e,s.initialGroup),x=s.initialIndex,v=s.group==null?void 0:Qr(e,s.group),k=s.index;if(p==null||v==null||p===v&&x===k)return"preventDefault"in t&&t.preventDefault(),e;if(p===v)return cn(ln({},e),{[p]:n(e[p],x,k)});const j=e[p][x];return cn(ln({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[v]:[...e[v].slice(0,k),j,...e[v].slice(k)]})}if(!s.manager)return e;const{dragOperation:m}=s.manager,g=(i=(r=m.shape)==null?void 0:r.current.center)!=null?i:m.position.current;if(h==null){const p=Qr(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&&vs(s)){const p=s.group==null?void 0:Qr(e,s.group),x=s.group!=null&&p!==d,v=s.index!==c;if(x||v){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 j=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),j,...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 Vg(e,t){return Gg(e,t,Yg)}function tl(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function nl(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 rl="__default__",Kg=class extends Te{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof ga){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=tl(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,m;const g=t();if(nl(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),v=(h=o.sortable.group)!=null?h:rl,k=(m=a.sortable.group)!=null?m:rl,j={[v]:p,[k]:x},O=Vg(j,r);if(j===O)return;const M=O[k].indexOf(o.sortable),P=O[k].indexOf(a.sortable);i.collisionObserver.disable(),il(w,M,y,P),de(()=>{for(const[T,G]of O[v].entries())G.index=T;if(!c)for(const[T,G]of O[k].entries())G.group=a.sortable.group,G.index=T}),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=tl(a),u=a.get(o.sortable.initialGroup);u&&i.renderer.rendering.then(()=>{const c=t();if(nl(l,a,c))return;const d=ei(u),f=ei(u,Bg),h=o.sortable.element,m=f.indexOf(o.sortable),g=d[m],w=g?.element;!g||!w||!h||(il(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 il(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function Xg(e,t){return e.index-t.index}function Bg(e,t){return e.initialIndex-t.initialIndex}function ei(e,t=Xg){return Array.from(e).sort(t)}var sl=[Lg,Kg],su={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function ol(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 lh,ou,au,Dt,fa,ur,hr,pa,bn;au=[U],ou=[U];var Xi=class{constructor(e,t){Bn(this,fa,Zr(Dt,8,this)),Zr(Dt,11,this),Bn(this,ur),Bn(this,hr),Bn(this,pa,Zr(Dt,12,this)),Zr(Dt,15,this),Bn(this,bn),this.register=()=>(de(()=>{var m,g;(m=this.manager)==null||m.registry.register(this.droppable),(g=this.manager)==null||g.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{de(()=>{var m,g;(m=this.manager)==null||m.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=su,plugins:c}=n,d=Ig(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const f=at(c,sl),h=ol(i);this.droppable=new ga(ms(gs({},d),{disabled:h.droppable}),t,this),this.draggable=new lu(ms(gs({},d),{disabled:h.draggable,plugins:f,effects:()=>[()=>{var m,g,w;const y=(m=this.manager)==null?void 0:m.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,H(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:m,group:g,manager:w}=this,y=dr(this,hr),p=dr(this,ur);(m!==y||g!==p)&&(Ut(this,hr,m),Ut(this,ur,g),this.animate())},()=>{var m,g;const{target:w}=this,{isDragSource:y}=this.draggable;((g=(m=this.draggable.pluginConfig(ia))==null?void 0:m.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(){H(()=>{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=Wa(i,a,!1),u=Wa(i,a);if(o.x||o.y){const c=Bo(Ke(i))?ms(gs({},t),{duration:0}):t;td({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,sl)}set disabled(e){const t=ol(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??nd}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=Rg();fa=new WeakMap;ur=new WeakMap;hr=new WeakMap;pa=new WeakMap;bn=new WeakMap;ru(Dt,4,"index",au,Xi,fa);ru(Dt,4,"group",ou,Xi,pa);zg(Dt,Xi);var lu=class extends Gi{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}},ga=class extends Vi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},Zg=Object.defineProperty,Jg=Object.defineProperties,Qg=Object.getOwnPropertyDescriptors,al=Object.getOwnPropertySymbols,em=Object.prototype.hasOwnProperty,tm=Object.prototype.propertyIsEnumerable,ll=(e,t,n)=>t in e?Zg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bs=(e,t)=>{for(var n in t||(t={}))em.call(t,n)&&ll(e,n,t[n]);if(al)for(var n of al(t))tm.call(t,n)&&ll(e,n,t[n]);return e},nm=(e,t)=>Jg(e,Qg(t));function rm(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:m,plugins:g}=e,w=bs(bs({},su),e.transition),y=Ld(x=>new Xi(nm(bs({},e),{transition:w,register:!1,handle:$n(a),element:$n(o),target:$n(h)}),x)),p=Id(y,im);return ae(i,()=>y.id=i),Un(()=>{de(()=>{y.group=u,y.index=l})},[y,u,l]),ae(m,()=>y.type=m),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()},xp),pi(a,x=>y.handle=x),pi(o,x=>y.element=x),pi(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 v,k;!x&&(v=y.element)!=null&&v.isConnected&&!((k=y.manager)!=null&&k.dragOperation.status.idle)||(y.element=x??void 0)},[y]),sourceRef:S.useCallback(x=>{var v,k;!x&&(v=y.source)!=null&&v.isConnected&&!((k=y.manager)!=null&&k.dragOperation.status.idle)||(y.source=x??void 0)},[y]),targetRef:S.useCallback(x=>{var v,k;!x&&(v=y.target)!=null&&v.isConnected&&!((k=y.manager)!=null&&k.dragOperation.status.idle)||(y.target=x??void 0)},[y])}}function im(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const lo="tile",cu="gap",sm='[role="separator"]',om=[eo.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(eo.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(sm)!==null}),Od],am=e=>[...e,ia.configure({feedback:"clone"})];function lm({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=rm({id:e,index:t,type:lo,accept:lo,collisionDetector:Jo,plugins:am});return b.jsx(b.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function cm({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=Yp({id:e,type:cu,accept:lo,collisionDetector:Jo,data:{after:t}});return b.jsx(b.Fragment,{children:n({ref:r,isDropTarget:i})})}const dm=Zt(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"})),um=Zt(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 hm({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(lm,{id:mt(e),index:t,children:({ref:h,handleRef:m,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:m,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(dm,{sx:{fontSize:16}})}),i===void 0&&b.jsx(ws,{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(um,{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 fm({tile:e}){const{theme:t}=tt();return b.jsxs(Pu,{sx:{minHeight:140},children:[b.jsx(Tu,{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 pm({after:e}){const{theme:t}=tt();return b.jsx(cm,{id:Jd(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 gm({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 mm=Object.defineProperty,vm=Object.defineProperties,bm=Object.getOwnPropertyDescriptors,cl=Object.getOwnPropertySymbols,ym=Object.prototype.hasOwnProperty,xm=Object.prototype.propertyIsEnumerable,dl=(e,t,n)=>t in e?mm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dn=(e,t)=>{for(var n in t||(t={}))ym.call(t,n)&&dl(e,n,t[n]);if(cl)for(var n of cl(t))xm.call(t,n)&&dl(e,n,t[n]);return e},un=(e,t)=>vm(e,bm(t));function wm(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 ys(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function km(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(v=>l(v,s.id)),x=e.findIndex(v=>l(v,o.id));if(p===-1||x===-1){if(ys(s)){const v=s.initialIndex,k=s.index;return v===k||v<0||v>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,v,k)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const v=s.index;if(v!==p)return n(e,p,v)}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(v=>l(v,s.id)),c!==-1&&(d=p)),f===-1&&(f=x.findIndex(v=>l(v,o.id)),f!==-1&&(h=p)),c!==-1&&f!==-1)break;if(c===-1&&ys(s)){const p=s.initialGroup==null?void 0:ni(e,s.initialGroup),x=s.initialIndex,v=s.group==null?void 0:ni(e,s.group),k=s.index;if(p==null||v==null||p===v&&x===k)return"preventDefault"in t&&t.preventDefault(),e;if(p===v)return un(dn({},e),{[p]:n(e[p],x,k)});const j=e[p][x];return un(dn({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[v]:[...e[v].slice(0,k),j,...e[v].slice(k)]})}if(!s.manager)return e;const{dragOperation:m}=s.manager,g=(i=(r=m.shape)==null?void 0:r.current.center)!=null?i:m.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&&ys(s)){const p=s.group==null?void 0:ni(e,s.group),x=s.group!=null&&p!==d,v=s.index!==c;if(x||v){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 j=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),j,...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 Sm(e,t){return km(e,t,wm)}function jm({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===cu){const{after:h}=c.data,m=d.findIndex(w=>mt(w)===u.id);if(m<0||h===u.id)return;const g=d.filter((w,y)=>y!==m).findIndex(w=>mt(w)===h)+1;f=Mg(d,m,g)}else{const h=d.map(mt),m=Sm(h,l);if(m.every((w,y)=>w===h[y]))return;const g=new Map(d.map(w=>[mt(w),w]));f=Og(m.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 ul=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function $m({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),ul(!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),ul(!1),!i)return;const{index:l,span:u}=i;s(void 0),r(l,u)}}}function Om({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}=Bd(t,e!==null,r,n),f=l!==void 0&&l.declaration.kind!=="inherited";return b.jsx(Ml,{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(Pe,{size:"small",label:"Title",value:l.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:h=>u(m=>{const g=h.target.value;g===""?delete m.label:m.label=g})}),b.jsx(Pe,{size:"small",label:"Subtitle",value:l.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:h=>u(m=>{const g=h.target.value;g===""?delete m.subtitle:m.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,m])=>{const g=Math.max(1,Math.round(s/m)),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(xs,{}),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 du=e=>e.ok===!1,ve=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),Bi=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 Mm(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 Cm(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
71
- `&&t.push(n+1);return t}class Em{constructor(t){this.text=t,this.map=Mm(t),this.lineStarts=Cm(t)}map;lineStarts;commentLines=new Set;span(t){if(!Bi(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=[]){Bi(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)Nr(e.getChild(r),t,n);return n}const Dm=e=>ve(e,"OCURLY","CCURLY");function Er(e,t){const n=[],r=i=>{if(Bi(i)){if(t(i)){n.push(i);return}if(!Dm(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),Xt=(e,t)=>e[t]?.call(e)??[];function Pm(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 uu(e,t){const n=e.positioned(t);if(!n)return;const r=be(t,"filterClauseList"),i=[];for(const s of r?Xt(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:Pm(e,s)})}return{...n,clauses:i}}function co(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=uu(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 ma(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))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 Tm(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&&co(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=Xt(n,"segExpr"),s=i[0],o=i[i.length-1];let a=s;for(;ce.segRefine(a);){const f=Xt(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&&co(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 Am(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=Xt(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:ma(e,i,a?.start??u.start),siblings:o.length,body:Tm(e,f)})}}return n}function Im(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 Xt(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:ma(e,i,o?.start??l.start)})}}return n}function Rm(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&&co(e,c),f={start:e.lineStarts[e.line(i.start)],end:i.end},h=[];if(c)for(const m of Er(c,ce.whereStatement)){const g=uu(e,m);g&&h.push(g)}n.push({name:s,base:u,span:i,line:e.line(i.start),statement:f,...d?{properties:d}:{},views:c?Am(e,c):[],dimensions:c?Im(e,c):[],wheres:h})}return n}function Wm(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?Xt(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:ma(e,l,d.start),...o!==void 0&&o!==f?{blockHeader:o}:{}})}}return n}function zm(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?Xt(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 hu(e){let t;try{t=await fu(e,"file://dashboard-builder.malloy")}catch(c){return{ok:!1,reason:`Malloy could not read this file: ${c}`}}const n=t.problems.filter(c=>c.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||!Bi(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 Em(e),l=Lm(a,s);a.commentLines=l.lines;const u=Rm(a,i);return u.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:zm(a,i),sources:u,givens:Wm(a,i),trailingComment:c=>l.trailing.get(c),comments:l.all,commentLine:c=>l.lines.has(c),commentIn:c=>l.all.find(d=>d.start>=c.start&&d.start<c.end),blockStart:c=>Nm(a,l.lines,c)}}}async function fu(e,t){const{MalloyTranslator:n}=await $l(async()=>{const{MalloyTranslator:i}=await import("./index-Bzqs2UuN.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 Lm(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]===`
73
- `||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(),m=a.slice(c.end,e.lineStarts[f+1]??a.length).trim();h!==""&&m===""&&n.set(f,c)}return{trailing:n,lines:r,all:i}}function Nm(e,t,n){let r=n;for(let i=n-1;i>=0;i--){const s=e.text.slice(e.lineStarts[i],e.lineStarts[i+1]??e.text.length).trim();if(s===""&&!t.has(i))break;if(s.startsWith("#")||t.has(i))r=i;else break}return r}const uo=e=>e.ok===!1;function Fr(e,t,n){const r=e.blockStart(n),i=[];for(let s=r;s<n;s++){if(e.commentLine(s))continue;const o=t[s].trim();o.startsWith("#")&&!o.startsWith("##")&&i.push({line:s,text:o})}return{start:r,tags:i}}const ho=e=>e.map(t=>t.text);function Fm(e){const t=[],n=[];for(const r of e){const i=r.trim();if(i.startsWith('##"'))t.push(i.slice(3).trim());else{if(i.startsWith("##!"))continue;i.startsWith("##")&&n.push(i)}}return{description:t.length>0?t.join(`
74
- `):void 0,artifact:n}}function _m(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 qm(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(),...Hm(n(ho(Fr(e,t,i.line).tags)).tag)})}return r.length>0?r:void 0}function Hm(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 Um(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 fo(e){const{parseAnnotation:t}=await $l(async()=>{const{parseAnnotation:v}=await import("./index-C5hv_y6G.js").then(k=>k.i);return{parseAnnotation:v}},__vite__mapDeps([5,1,2,3])),n=e.split(`
75
- `),r=await hu(e);if(du(r))return{ok:!1,reason:r.reason,...r.line?{line:r.line}:{}};const i=r.parsed,{description:s,artifact:o}=Fm(n),a=o.find(v=>v.includes("artifact"));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=Um(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(v=>v.names?{kind:"names",names:v.names,from:v.from}:{kind:"all",from:v.from}),f=[],h=[],m=new Map;for(const v of i.sources){const k={name:v.name,base:v.base};v.dimensions.length>0&&(k.dimensions=v.dimensions.map(j=>({name:j.name,expression:j.expression}))),f.push(k);for(const j of v.dimensions){const O=t(ho(Fr(i,n,j.line).tags)).tag?.tag("drill");if(!O)continue;const M=O.textArray("to")??[O.text("to")??""];h.push({source:v.name,name:j.name,expression:j.expression,to:M.filter(Boolean),...O.text("given")?{given:O.text("given")}:{}})}m.set(v.name,new Map(v.views.map(j=>[j.name,j])))}const g=[];for(const v of c){const k=Du(v);if(!k)return{ok:!1,reason:`The tile \`${v}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:j,view:O}=k,M=m.get(j)?.get(O);if(M===void 0){g.push({name:O,source:j,declaration:{kind:"inherited"}});continue}const P=t(ho(M.tags)).tag,T=M.body.kind==="reference"?{kind:"reference",from:M.body.from}:M.body.kind==="inline"?{kind:"inline"}:void 0;if(T===void 0){g.push({name:O,source:j,declaration:{kind:"opaque",why:M.body.kind==="unsupported"?M.body.why:"unreadable"},...P?.text("label")?{label:P.text("label")}:{},...P?.text("subtitle")?{subtitle:P.text("subtitle")}:{},...P?.numeric("colspan")!==void 0?{colspan:P.numeric("colspan")}:{},...P?.has("break")?{break:!0}:{},...P?.has("borderless")?{borderless:!0}:{}});continue}const G=_m(M.body.kind==="reference"?M.body.refinement:M.body.kind==="inline"?M.body.stage:void 0);g.push({name:O,source:j,declaration:T,...G?{filters:G}:{},...P?.text("label")?{label:P.text("label")}:{},...P?.text("subtitle")?{subtitle:P.text("subtitle")}:{},...P?.numeric("colspan")!==void 0?{colspan:P.numeric("colspan")}:{},...P?.has("break")?{break:!0}:{},...P?.has("borderless")?{borderless:!0}:{}})}const w=qm(i,n,t),y={},p=u?.tag("givens");for(const v of Object.keys(p?.dict??{})){const k=p?.text(v);k!==void 0&&(y[v]=k)}const x=l?.tag("dashboard")?.numeric("columns");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 hl(e){const{problems:t}=await fu(e,"file://splice-check.malloy");return t.filter(n=>n.code==="syntax-error").map(n=>n.message??"").sort()}const fl=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 Ym(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
76
- `&&t.push(n+1);return t}function Gm(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 pu(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=${Tn(e.label)}`),e.subtitle!==void 0&&t.push(`# subtitle=${Tn(e.subtitle)}`),t}function vi(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const Vm=new Set(["colspan","break","borderless","label","subtitle"]),Km=new Set(["label","description","control","suggest","range_min","range_max"]),Xm=(e,t)=>ye(e.imports)===ye(t.imports);function pl(e){const t=[];if(e.label!==void 0&&t.push(`label=${Tn(e.label)}`),e.description!==void 0&&t.push(`description=${Tn(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 gl=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function Bm(e,t,n){const r=e.sources.find(i=>i.name===t)?.views.find(i=>i.name===n);return r?r.line:-1}function ml(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(t=>`"${t}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const Wi=e=>`${e.source}.${e.name}`,Tn=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,po=e=>ye([e.name,e.source,e.declaration]),vt=po,vl=e=>ye(e.tiles.map(vt));function Zm(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||vl(e)!==vl(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 Xm(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 Jm(e){const{lines:t,wholeLine:n,next:r,reordered:i,currentKeys:s,nextKeys:o,edits:a}=e;if(i){const l=Ss(t);if(l<0)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const u=[...t[l].matchAll(/"([^"]+)"/g)].map(m=>m[1]),c=new Map;for(const m of u){const g=m.split("->").map(w=>w.trim());g.length===2&&c.set(`${g[0]}->${g[1]}`,m)}const d=r.tiles.map(m=>c.get(`${m.source}->${m.name}`)??(o.has(vt(m))&&!s.has(vt(m))?`${m.source} -> ${m.name}`:void 0));if(d.some(m=>m===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const f=`tiles=[${d.map(m=>`"${m}"`).join(", ")}]`,h=t[l].replace(/tiles\s*=\s*\[[\s\S]*?\]/,f);h!==t[l]&&a.push({...n(l),text:`${h}
77
- `})}}function Qm(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=Ss(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 m=(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&&m("title",i.title?Tn(i.title):void 0),r.autorun!==i.autorun&&m("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}=${Tn(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=l.replace(/\s*dashboard\s*\{[^}]*\}/,""),i.columns!==void 0&&(l=`${l.trimEnd()} dashboard { columns=${i.columns} }`)),a?a.text=`${l}
70
+ `);if(n.length>Ba||r.length>Ba)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 bg(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 yg({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=tt(),o=S.useMemo(()=>e?bg(vg(t,n)):[],[e,t,n]),a=o.filter(u=>u.kind==="add").length,l=o.filter(u=>u.kind==="del").length;return b.jsx(zi,{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 fs="self";function xg({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(m=>m.source===n.name);u((n.dimensions??[]).map(m=>{const g=h.find(w=>w.name===m.name);return{name:m.name,expression:m.expression,to:g?.to??[],given:g?.given??""}}))},[e,n,t]);const c=(h,m)=>u(g=>g.map((w,y)=>{if(y!==h)return w;const p={...w};return m(p),p})),d=[fs,...i.filter(h=>h!==fs)],f=h=>h===fs?"This dashboard":h;return b.jsx(zi,{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,m)=>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(De,{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(m,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(ks,{size:"small",checked:h.to.includes(g),sx:{p:0,mr:1}}),b.jsx(Cl,{primary:f(g)})]},g))}),b.jsxs(De,{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(m,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 Bd=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function wg({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,m]=S.useState("select"),[g,w]=S.useState(""),[y,p]=S.useState(""),[x,v]=S.useState([]),[k,j]=S.useState(!1),O=C=>t.sources.find(A=>A.name===C.source)?.base??C.source;S.useEffect(()=>{if(e)if(n){c({kind:"existing",name:n.name}),f(n.label??"");const C=Jp(t,n);v(C);const A=C.filter($=>$.include),q=new Set(A.map($=>$.field));p(q.size===1?A[0].field:n.field??""),j(q.size>1)}else c({kind:"new"}),f(""),m("select"),p(""),w(new Date().toISOString().slice(0,10)),v(t.tiles.map(C=>({include:so(C),field:""}))),j(!1)},[e,n,t]);const M=S.useMemo(()=>[...(t.localGivens??[]).map(C=>C.name),...r.map(C=>C.name)],[t,r]),D=S.useMemo(()=>y.trim()?Zp(y.trim(),M):"",[y,M]),T=u.kind==="existing"?n??r.find(C=>C.name===u.name):D?{name:D,type:Xr({name:D,label:d,kind:h,field:y}).type}:void 0,G=T?.type!==void 0&&!T.type.startsWith("filter<"),I=x.find(C=>C.include)?.op??Ii(T?.type),E=(C,A)=>v(q=>q.map(($,P)=>P===C?{...$,...A}:$)),F=C=>v(A=>A.map(q=>({...q,op:C}))),V=C=>{const A=Ii(C);v(q=>q.map(({op:$,...P})=>A?{...P,op:A}:P))},me=C=>{c({kind:"existing",name:C.name}),p(C.field??""),V(C.type)},Ae=C=>{m(C),V(Xr({name:"X",label:d,kind:C,field:y}).type)},oe=t.tiles.map(so),Ne=oe.filter(Boolean).length,Ue=x.filter((C,A)=>C.include&&oe[A]).length,Ee=t.tiles.filter((C,A)=>(x[A]?.include??!1)&&oe[A]),Xe=Ee.length>0?Ee:t.tiles.filter((C,A)=>oe[A]),Ye=S.useMemo(()=>{const C=new Map;let A=!1;for(const q of Xe){const $=i?.(q);if($){A=!0;for(const P of $)C.has(P.name)||C.set(P.name,P)}}return A?[...C.values()]:void 0},[x,t.tiles,i]),_e=(()=>{const C=y.trim();for(const A of Ee){const q=i?.(A);if(!q||q.some($=>$.name===C))return O(A)}return Ee[0]?O(Ee[0]):t.sources[0]?.base})(),Be=C=>v(A=>A.map((q,$)=>({...q,include:C&&oe[$]}))),Oe=S.useMemo(()=>k?x:x.map(C=>({...C,field:y})),[k,x,y]),xe=C=>{for(const A of Xe){const q=i?.(A)?.find($=>$.name===C.trim());if(q?.type)return q.type}},R=C=>mi(T?.type,C.type),_=(C,A)=>{if(C.trim()==="")return"Pick the field this filter compares.";const q=A?i?.(A):void 0;if(!q)return;const $=q.find(P=>P.name===C.trim());if(!$)return`Not a field of ${A?O(A):"the tiles' source"}.`;if($.type&&!mi(T?.type,$.type))return`${C.trim()} is ${Ga($.type)}; this filter compares ${Ga(T?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},je=C=>{if(p(C),l||u.kind!=="new")return;const A=xe(C),q=Xr({name:"X",label:d,kind:h,field:C}).type;A&&!mi(q,A)&&Ae(Xp(A))},B=Oe.map((C,A)=>C.include&&oe[A]?_(C.field,t.tiles[A]):void 0),Fe=B.every(C=>C===void 0),ee=!k&&Ue>0?Ee.map(C=>_(y,C)).find(Boolean):void 0,ct=T!==void 0&&Fe&&(u.kind==="existing"||y.trim()!==""&&D!==""),qe=()=>{if(!(!T||!ct))if(u.kind==="new")s(T.name,Oe,Xr({name:T.name,label:d.trim()||Bd(T.name),kind:h,field:y.trim(),..._e?{source:_e}:{},...g?{dateDefault:g}:{}}));else if(n?.origin==="dashboard"&&n.local){const C=d.trim(),A=C!==(n.local.label??"");s(T.name,Oe,A?{...n.local,...C?{label:C}:{}}:void 0)}else s(T.name,Oe)},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:v,perTile:k,setPerTile:j,newName:D,target:T,valueTyped:G,commonOp:I,setRow:E,setCommonOp:F,pickExisting:me,pickKind:Ae,bindable:oe,bindableCount:Ne,included:Ue,commonFields:Ye,setAll:Be,accepts:R,pickField:je,rowProblems:B,commonProblem:ee,canApply:ct,apply:qe}}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(m=>r?.(m)??!0).map(m=>m.name),[n,r]),h=S.useMemo(()=>new Map((n??[]).map(m=>[m.name,m.type])),[n]);return b.jsx(Hu,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(m,g)=>t(g),value:e,onChange:(m,g)=>t(typeof g=="string"?g:""),disabled:l,disableClearable:!0,renderOption:(m,g)=>S.createElement("li",{...m,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:m=>b.jsx(De,{...m,label:i,placeholder:c,autoFocus:u,error:o,helperText:a,inputProps:{...m.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 kg({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:m,setLabel:g,kind:w,dateDefault:y,setDateDefault:p,field:x,rows:v,setRows:k,perTile:j,setPerTile:O,newName:M,target:D,valueTyped:T,commonOp:G,setRow:I,setCommonOp:E,pickExisting:F,pickKind:V,bindable:me,bindableCount:Ae,included:oe,commonFields:Ne,setAll:Ue,accepts:Ee,pickField:Xe,rowProblems:Ye,commonProblem:_e,canApply:Be,apply:Oe}=wg({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),xe=(R,_,je)=>b.jsx(De,{select:!0,size:"small",label:"Compares",value:R??">=",onChange:B=>_(B.target.value),inputProps:{"aria-label":je},sx:{width:130},children:Bp.filter(B=>B.op!=="~").map(B=>b.jsx(bt,{value:B.op,children:B.label},B.op))});return b.jsx(zi,{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||D===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:Oe,disabled:!Be,children:u?"Apply":"Add filter"})})})]}),children:b.jsxs(he,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&b.jsxs(Gu,{exclusive:!0,size:"small",value:f.kind,onChange:(R,_)=>{_==="new"?h({kind:"new"}):_==="existing"&&r[0]&&F(r[0])},"aria-label":"Where the filter comes from",children:[b.jsx(xa,{value:"new",children:"New in this dashboard"}),b.jsx(xa,{value:"existing",children:"From the model"})]}),!u&&f.kind==="existing"?b.jsx(De,{select:!0,size:"small",label:"Control",value:f.name,onChange:R=>{const _=r.find(je=>je.name===R.target.value);_&&F(_)},children:r.map(R=>b.jsxs(bt,{value:R.name,children:[R.label??R.name,b.jsxs(ne,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",R.name]})]},R.name))}):null,b.jsxs(he,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!j&&b.jsx(Za,{value:x,onChange:Xe,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(De,{size:"small",label:"Label",placeholder:M?Bd(M):"",value:m,onChange:R=>g(R.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),T&&!j&&xe(G,E,"Comparison")]}),!u&&f.kind==="new"&&b.jsxs(he,{direction:"row",sx:{gap:1.5},children:[b.jsx(De,{select:!0,size:"small",label:"Control",value:w,onChange:R=>V(R.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:R=>Va.find(_=>_.kind===R)?.label??String(R)}},sx:{flex:1},children:Va.map(R=>b.jsxs(bt,{value:R.kind,children:[R.label,b.jsx(ne,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:R.hint})]},R.kind))}),w==="date"&&b.jsx(De,{size:"small",type:"date",label:"Starts at",value:y,onChange:R=>p(R.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(ks,{size:"small",checked:Ae>0&&oe===Ae,indeterminate:oe>0&&oe<Ae,disabled:Ae===0,onChange:R=>Ue(R.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:()=>{j||k(R=>R.map(_=>({..._,field:x}))),O(R=>!R)},children:j?"Same field for all":"Adjust per tile"})]}),b.jsx(he,{sx:{gap:j?1:0},children:t.tiles.map((R,_)=>{const je=v[_],B=R.label??R.name,Fe=j?Ye[_]:void 0;return b.jsxs(he,{direction:"row",sx:{gap:1,alignItems:j?"flex-start":"center",opacity:me[_]?1:.6},children:[b.jsx(ks,{size:"small",disabled:!me[_],checked:(je?.include??!1)&&me[_],inputProps:{"aria-label":`Filter ${B}`},onChange:ee=>I(_,{include:ee.target.checked})}),b.jsx(ne,{variant:"body2",sx:{flex:1,minWidth:0,pt:j?1:0},noWrap:!0,children:B}),me[_]?j&&b.jsxs(b.Fragment,{children:[T&&xe(je?.op,ee=>I(_,{op:ee}),`Comparison for ${B}`),b.jsx(Za,{value:je?.field??"",onChange:ee=>I(_,{field:ee}),fields:i?.(R),accepts:Ee,label:"Field",ariaLabel:`Field for ${B}`,disabled:!je?.include,error:Fe!==void 0,helperText:Fe,sx:{width:220}})]}):b.jsx(kn,{title:Ja(t.tiles[_]).reason,children:b.jsx(ne,{variant:"caption",sx:{color:l.tileTitle},children:Ja(t.tiles[_]).label})})]},`${R.source}.${R.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 Zd(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 Sg=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}}),ps=[2,3,4,6,8,12,16,24];function jg({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=tt(),{draft:s,patch:o,close:a}=Zd(t,e!==null,r,n),l=s?.columns!==void 0&&!ps.includes(s.columns)?[...ps,s.columns].sort((u,c)=>u-c):ps;return b.jsx(Ml,{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(De,{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(De,{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(De,{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(Iu,{control:b.jsx(Ru,{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 $g=Zt(b.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function Og({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($g,{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(go,{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(jl,{label:"Filter",icon:b.jsx(Ol,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const Mg=(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}),Cg=(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},Jd=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),Qd=e=>`gap.${e}`,Eg=(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(Jd(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 Pg=Object.create,eu=Object.defineProperty,Dg=Object.defineProperties,Tg=Object.getOwnPropertyDescriptor,Ag=Object.getOwnPropertyDescriptors,Ri=Object.getOwnPropertySymbols,tu=Object.prototype.hasOwnProperty,nu=Object.prototype.propertyIsEnumerable,Ig=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Lr=e=>{throw TypeError(e)},ao=(e,t,n)=>t in e?eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gs=(e,t)=>{for(var n in t||(t={}))tu.call(t,n)&&ao(e,n,t[n]);if(Ri)for(var n of Ri(t))nu.call(t,n)&&ao(e,n,t[n]);return e},ms=(e,t)=>Dg(e,Ag(t)),Rg=(e,t)=>{var n={};for(var r in e)tu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ri)for(var r of Ri(e))t.indexOf(r)<0&&nu.call(e,r)&&(n[r]=e[r]);return n},Wg=e=>{var t;return[,,,Pg((t=void 0)!=null?t:null)]},ru=["class","method","getter","setter","accessor","field","value","get","set"],cr=e=>e!==void 0&&typeof e!="function"?Lr("Function expected"):e,zg=(e,t,n,r,i)=>({kind:ru[e],name:t,metadata:r,addInitializer:s=>n._?Lr("Already initialized"):i.push(cr(s||null))}),Lg=(e,t)=>ao(t,Ig("metadata"),e[3]),Zr=(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},iu=(e,t,n,r,i,s)=>{for(var o,a,l,u,c,d=t&7,f=!1,h=!1,m=e.length+1,g=ru[d+5],w=e[m-1]=[],y=e[m]||(e[m]=[]),p=(i=i.prototype,Tg({get[n](){return dr(this,s)},set[n](v){return Ut(this,s,v)}},n)),x=r.length-1;x>=0;x--)u=zg(d,n,l={},e[3],y),u.static=f,u.private=h,c=u.access={has:v=>n in v},c.get=v=>v[n],c.set=(v,k)=>v[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&&eu(i,n,p),i},su=(e,t,n)=>t.has(e)||Lr("Cannot "+n),dr=(e,t,n)=>(su(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)=>(su(e,t,"write to private field"),t.set(e,n),n);function Gt(e){return e instanceof ga||e instanceof cu}var Jr=10,Ng=class extends Te{constructor(e){super(e);const t=nt(()=>{const{dragOperation:r}=e;if(jr(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(!jr(r.nativeEvent)||!Gt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:l}=i,{by:u}=r;if(!u)return;const c=_g(u),{source:d,target:f}=s,{center:h}=s.shape.current,m=[],g=[];de(()=>{for(const k of l.droppables){const{id:j}=k;if(!k.accepts(d)||j===f?.id&&Gt(k)||!k.element)continue;let O=k.shape;const M=new ut(k.element,{getBoundingClientRect:D=>kr(D,void 0,.2)});!M.height||!M.width||(c=="down"&&h.y+Jr<M.center.y||c=="up"&&h.y-Jr>M.center.y||c=="left"&&h.x-Jr>M.center.x||c=="right"&&h.x+Jr<M.center.x)&&(m.push(k),k.shape=M,g.push(()=>k.shape=O))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(m,Mf);de(()=>g.forEach(k=>k()));const[y]=w;if(!y)return;const{id:p}=y,{index:x,group:v}=d.sortable;o.setDropTarget(p).then(()=>{const{source:k,target:j,shape:O}=s;if(!k||!Gt(k)||!O)return;const{index:M,group:D,target:T}=k.sortable,G=x!==M||v!==D,I=G?T:j?.element;if(!I)return;ed(I);const E=new ut(I);if(!E)return;const F=ht.delta(E,ht.from(O.current.boundingRectangle),k.alignment);o.move({by:F}),G?o.setDropTarget(k.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function _g(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 Fg=Object.defineProperty,qg=Object.defineProperties,Hg=Object.getOwnPropertyDescriptors,Qa=Object.getOwnPropertySymbols,Ug=Object.prototype.hasOwnProperty,Yg=Object.prototype.propertyIsEnumerable,el=(e,t,n)=>t in e?Fg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ln=(e,t)=>{for(var n in t||(t={}))Ug.call(t,n)&&el(e,n,t[n]);if(Qa)for(var n of Qa(t))Yg.call(t,n)&&el(e,n,t[n]);return e},cn=(e,t)=>qg(e,Hg(t));function Gg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Qr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function vs(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Vg(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(v=>l(v,s.id)),x=e.findIndex(v=>l(v,o.id));if(p===-1||x===-1){if(vs(s)){const v=s.initialIndex,k=s.index;return v===k||v<0||v>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,v,k)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const v=s.index;if(v!==p)return n(e,p,v)}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(v=>l(v,s.id)),c!==-1&&(d=p)),f===-1&&(f=x.findIndex(v=>l(v,o.id)),f!==-1&&(h=p)),c!==-1&&f!==-1)break;if(c===-1&&vs(s)){const p=s.initialGroup==null?void 0:Qr(e,s.initialGroup),x=s.initialIndex,v=s.group==null?void 0:Qr(e,s.group),k=s.index;if(p==null||v==null||p===v&&x===k)return"preventDefault"in t&&t.preventDefault(),e;if(p===v)return cn(ln({},e),{[p]:n(e[p],x,k)});const j=e[p][x];return cn(ln({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[v]:[...e[v].slice(0,k),j,...e[v].slice(k)]})}if(!s.manager)return e;const{dragOperation:m}=s.manager,g=(i=(r=m.shape)==null?void 0:r.current.center)!=null?i:m.position.current;if(h==null){const p=Qr(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&&vs(s)){const p=s.group==null?void 0:Qr(e,s.group),x=s.group!=null&&p!==d,v=s.index!==c;if(x||v){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 j=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),j,...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 Kg(e,t){return Vg(e,t,Gg)}function tl(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function nl(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 rl="__default__",Xg=class extends Te{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof ga){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=tl(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,m;const g=t();if(nl(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),v=(h=o.sortable.group)!=null?h:rl,k=(m=a.sortable.group)!=null?m:rl,j={[v]:p,[k]:x},O=Kg(j,r);if(j===O)return;const M=O[k].indexOf(o.sortable),D=O[k].indexOf(a.sortable);i.collisionObserver.disable(),il(w,M,y,D),de(()=>{for(const[T,G]of O[v].entries())G.index=T;if(!c)for(const[T,G]of O[k].entries())G.group=a.sortable.group,G.index=T}),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=tl(a),u=a.get(o.sortable.initialGroup);u&&i.renderer.rendering.then(()=>{const c=t();if(nl(l,a,c))return;const d=ei(u),f=ei(u,Zg),h=o.sortable.element,m=f.indexOf(o.sortable),g=d[m],w=g?.element;!g||!w||!h||(il(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 il(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function Bg(e,t){return e.index-t.index}function Zg(e,t){return e.initialIndex-t.initialIndex}function ei(e,t=Bg){return Array.from(e).sort(t)}var sl=[Ng,Xg],ou={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function ol(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 ch,au,lu,Pt,fa,ur,hr,pa,bn;lu=[U],au=[U];var Xi=class{constructor(e,t){Bn(this,fa,Zr(Pt,8,this)),Zr(Pt,11,this),Bn(this,ur),Bn(this,hr),Bn(this,pa,Zr(Pt,12,this)),Zr(Pt,15,this),Bn(this,bn),this.register=()=>(de(()=>{var m,g;(m=this.manager)==null||m.registry.register(this.droppable),(g=this.manager)==null||g.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{de(()=>{var m,g;(m=this.manager)==null||m.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=ou,plugins:c}=n,d=Rg(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const f=at(c,sl),h=ol(i);this.droppable=new ga(ms(gs({},d),{disabled:h.droppable}),t,this),this.draggable=new cu(ms(gs({},d),{disabled:h.draggable,plugins:f,effects:()=>[()=>{var m,g,w;const y=(m=this.manager)==null?void 0:m.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,H(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:m,group:g,manager:w}=this,y=dr(this,hr),p=dr(this,ur);(m!==y||g!==p)&&(Ut(this,hr,m),Ut(this,ur,g),this.animate())},()=>{var m,g;const{target:w}=this,{isDragSource:y}=this.draggable;((g=(m=this.draggable.pluginConfig(ia))==null?void 0:m.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(){H(()=>{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=Wa(i,a,!1),u=Wa(i,a);if(o.x||o.y){const c=Bo(Ke(i))?ms(gs({},t),{duration:0}):t;td({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=_s.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,sl)}set disabled(e){const t=ol(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??nd}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)}};Pt=Wg();fa=new WeakMap;ur=new WeakMap;hr=new WeakMap;pa=new WeakMap;bn=new WeakMap;iu(Pt,4,"index",lu,Xi,fa);iu(Pt,4,"group",au,Xi,pa);Lg(Pt,Xi);var cu=class extends Gi{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}},ga=class extends Vi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},Jg=Object.defineProperty,Qg=Object.defineProperties,em=Object.getOwnPropertyDescriptors,al=Object.getOwnPropertySymbols,tm=Object.prototype.hasOwnProperty,nm=Object.prototype.propertyIsEnumerable,ll=(e,t,n)=>t in e?Jg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bs=(e,t)=>{for(var n in t||(t={}))tm.call(t,n)&&ll(e,n,t[n]);if(al)for(var n of al(t))nm.call(t,n)&&ll(e,n,t[n]);return e},rm=(e,t)=>Qg(e,em(t));function im(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:m,plugins:g}=e,w=bs(bs({},ou),e.transition),y=Ld(x=>new Xi(rm(bs({},e),{transition:w,register:!1,handle:$n(a),element:$n(o),target:$n(h)}),x)),p=Id(y,sm);return ae(i,()=>y.id=i),Un(()=>{de(()=>{y.group=u,y.index=l})},[y,u,l]),ae(m,()=>y.type=m),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()},wp),pi(a,x=>y.handle=x),pi(o,x=>y.element=x),pi(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 v,k;!x&&(v=y.element)!=null&&v.isConnected&&!((k=y.manager)!=null&&k.dragOperation.status.idle)||(y.element=x??void 0)},[y]),sourceRef:S.useCallback(x=>{var v,k;!x&&(v=y.source)!=null&&v.isConnected&&!((k=y.manager)!=null&&k.dragOperation.status.idle)||(y.source=x??void 0)},[y]),targetRef:S.useCallback(x=>{var v,k;!x&&(v=y.target)!=null&&v.isConnected&&!((k=y.manager)!=null&&k.dragOperation.status.idle)||(y.target=x??void 0)},[y])}}function sm(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const lo="tile",du="gap",om='[role="separator"]',am=[eo.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(eo.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(om)!==null}),Od],lm=e=>[...e,ia.configure({feedback:"clone"})];function cm({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=im({id:e,index:t,type:lo,accept:lo,collisionDetector:Jo,plugins:lm});return b.jsx(b.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function dm({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=Gp({id:e,type:du,accept:lo,collisionDetector:Jo,data:{after:t}});return b.jsx(b.Fragment,{children:n({ref:r,isDropTarget:i})})}const um=Zt(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"})),hm=Zt(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 fm({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(cm,{id:mt(e),index:t,children:({ref:h,handleRef:m,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:m,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(um,{sx:{fontSize:16}})}),i===void 0&&b.jsx(ws,{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(hm,{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 pm({tile:e}){const{theme:t}=tt();return b.jsxs(Tu,{sx:{minHeight:140},children:[b.jsx(Au,{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 gm({after:e}){const{theme:t}=tt();return b.jsx(dm,{id:Qd(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 mm({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 vm=Object.defineProperty,bm=Object.defineProperties,ym=Object.getOwnPropertyDescriptors,cl=Object.getOwnPropertySymbols,xm=Object.prototype.hasOwnProperty,wm=Object.prototype.propertyIsEnumerable,dl=(e,t,n)=>t in e?vm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dn=(e,t)=>{for(var n in t||(t={}))xm.call(t,n)&&dl(e,n,t[n]);if(cl)for(var n of cl(t))wm.call(t,n)&&dl(e,n,t[n]);return e},un=(e,t)=>bm(e,ym(t));function km(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 ys(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Sm(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(v=>l(v,s.id)),x=e.findIndex(v=>l(v,o.id));if(p===-1||x===-1){if(ys(s)){const v=s.initialIndex,k=s.index;return v===k||v<0||v>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,v,k)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const v=s.index;if(v!==p)return n(e,p,v)}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(v=>l(v,s.id)),c!==-1&&(d=p)),f===-1&&(f=x.findIndex(v=>l(v,o.id)),f!==-1&&(h=p)),c!==-1&&f!==-1)break;if(c===-1&&ys(s)){const p=s.initialGroup==null?void 0:ni(e,s.initialGroup),x=s.initialIndex,v=s.group==null?void 0:ni(e,s.group),k=s.index;if(p==null||v==null||p===v&&x===k)return"preventDefault"in t&&t.preventDefault(),e;if(p===v)return un(dn({},e),{[p]:n(e[p],x,k)});const j=e[p][x];return un(dn({},e),{[p]:[...e[p].slice(0,x),...e[p].slice(x+1)],[v]:[...e[v].slice(0,k),j,...e[v].slice(k)]})}if(!s.manager)return e;const{dragOperation:m}=s.manager,g=(i=(r=m.shape)==null?void 0:r.current.center)!=null?i:m.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&&ys(s)){const p=s.group==null?void 0:ni(e,s.group),x=s.group!=null&&p!==d,v=s.index!==c;if(x||v){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 j=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),j,...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 jm(e,t){return Sm(e,t,km)}function $m({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===du){const{after:h}=c.data,m=d.findIndex(w=>mt(w)===u.id);if(m<0||h===u.id)return;const g=d.filter((w,y)=>y!==m).findIndex(w=>mt(w)===h)+1;f=Cg(d,m,g)}else{const h=d.map(mt),m=jm(h,l);if(m.every((w,y)=>w===h[y]))return;const g=new Map(d.map(w=>[mt(w),w]));f=Mg(m.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 ul=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function Om({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),ul(!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),ul(!1),!i)return;const{index:l,span:u}=i;s(void 0),r(l,u)}}}function Mm({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}=Zd(t,e!==null,r,n),f=l!==void 0&&l.declaration.kind!=="inherited";return b.jsx(Ml,{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(De,{size:"small",label:"Title",value:l.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:h=>u(m=>{const g=h.target.value;g===""?delete m.label:m.label=g})}),b.jsx(De,{size:"small",label:"Subtitle",value:l.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:h=>u(m=>{const g=h.target.value;g===""?delete m.subtitle:m.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,m])=>{const g=Math.max(1,Math.round(s/m)),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(xs,{}),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 uu=e=>e.ok===!1,ve=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),Bi=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 Cm(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 Em(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
71
+ `&&t.push(n+1);return t}class Pm{constructor(t){this.text=t,this.map=Cm(t),this.lineStarts=Em(t)}map;lineStarts;commentLines=new Set;span(t){if(!Bi(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=[]){Bi(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)Nr(e.getChild(r),t,n);return n}const Dm=e=>ve(e,"OCURLY","CCURLY");function Er(e,t){const n=[],r=i=>{if(Bi(i)){if(t(i)){n.push(i);return}if(!Dm(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),Xt=(e,t)=>e[t]?.call(e)??[];function Tm(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 hu(e,t){const n=e.positioned(t);if(!n)return;const r=be(t,"filterClauseList"),i=[];for(const s of r?Xt(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:Tm(e,s)})}return{...n,clauses:i}}function co(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=hu(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 ma(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))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 Am(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&&co(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=Xt(n,"segExpr"),s=i[0],o=i[i.length-1];let a=s;for(;ce.segRefine(a);){const f=Xt(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&&co(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 Im(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=Xt(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:ma(e,i,a?.start??u.start),siblings:o.length,body:Am(e,f)})}}return n}function Rm(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 Xt(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:ma(e,i,o?.start??l.start)})}}return n}function Wm(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&&co(e,c),f={start:e.lineStarts[e.line(i.start)],end:i.end},h=[];if(c)for(const m of Er(c,ce.whereStatement)){const g=hu(e,m);g&&h.push(g)}n.push({name:s,base:u,span:i,line:e.line(i.start),statement:f,...d?{properties:d}:{},views:c?Im(e,c):[],dimensions:c?Rm(e,c):[],wheres:h})}return n}function zm(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?Xt(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:ma(e,l,d.start),...o!==void 0&&o!==f?{blockHeader:o}:{}})}}return n}function Lm(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?Xt(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 fu(e){let t;try{t=await pu(e,"file://dashboard-builder.malloy")}catch(c){return{ok:!1,reason:`Malloy could not read this file: ${c}`}}const n=t.problems.filter(c=>c.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||!Bi(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 Pm(e),l=Nm(a,s);a.commentLines=l.lines;const u=Wm(a,i);return u.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:Lm(a,i),sources:u,givens:zm(a,i),trailingComment:c=>l.trailing.get(c),comments:l.all,commentLine:c=>l.lines.has(c),commentIn:c=>l.all.find(d=>d.start>=c.start&&d.start<c.end),blockStart:c=>_m(a,l.lines,c)}}}async function pu(e,t){const{MalloyTranslator:n}=await $l(async()=>{const{MalloyTranslator:i}=await import("./index-xgxo45Xn.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 Nm(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]===`
73
+ `||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(),m=a.slice(c.end,e.lineStarts[f+1]??a.length).trim();h!==""&&m===""&&n.set(f,c)}return{trailing:n,lines:r,all:i}}function _m(e,t,n){let r=n;for(let i=n-1;i>=0;i--){const s=e.text.slice(e.lineStarts[i],e.lineStarts[i+1]??e.text.length).trim();if(s===""&&!t.has(i))break;if(s.startsWith("#")||t.has(i))r=i;else break}return r}const uo=e=>e.ok===!1;function _r(e,t,n){const r=e.blockStart(n),i=[];for(let s=r;s<n;s++){if(e.commentLine(s))continue;const o=t[s].trim();o.startsWith("#")&&!o.startsWith("##")&&i.push({line:s,text:o})}return{start:r,tags:i}}const ho=e=>e.map(t=>t.text);function Fm(e){const t=[],n=[];for(const r of e){const i=r.trim();if(i.startsWith('##"'))t.push(i.slice(3).trim());else{if(i.startsWith("##!"))continue;i.startsWith("##")&&n.push(i)}}return{description:t.length>0?t.join(`
74
+ `):void 0,artifact:n}}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 Hm(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(),...Um(n(ho(_r(e,t,i.line).tags)).tag)})}return r.length>0?r:void 0}function Um(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 Ym(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 fo(e){const{parseAnnotation:t}=await $l(async()=>{const{parseAnnotation:v}=await import("./index-aXk5ykLp.js").then(k=>k.i);return{parseAnnotation:v}},__vite__mapDeps([5,1,2,3])),n=e.split(`
75
+ `),r=await fu(e);if(uu(r))return{ok:!1,reason:r.reason,...r.line?{line:r.line}:{}};const i=r.parsed,{description:s,artifact:o}=Fm(n),a=o.find(v=>v.includes("artifact"));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=Ym(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(v=>v.names?{kind:"names",names:v.names,from:v.from}:{kind:"all",from:v.from}),f=[],h=[],m=new Map;for(const v of i.sources){const k={name:v.name,base:v.base};v.dimensions.length>0&&(k.dimensions=v.dimensions.map(j=>({name:j.name,expression:j.expression}))),f.push(k);for(const j of v.dimensions){const O=t(ho(_r(i,n,j.line).tags)).tag?.tag("drill");if(!O)continue;const M=O.textArray("to")??[O.text("to")??""];h.push({source:v.name,name:j.name,expression:j.expression,to:M.filter(Boolean),...O.text("given")?{given:O.text("given")}:{}})}m.set(v.name,new Map(v.views.map(j=>[j.name,j])))}const g=[];for(const v of c){const k=Du(v);if(!k)return{ok:!1,reason:`The tile \`${v}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:j,view:O}=k,M=m.get(j)?.get(O);if(M===void 0){g.push({name:O,source:j,declaration:{kind:"inherited"}});continue}const D=t(ho(M.tags)).tag,T=M.body.kind==="reference"?{kind:"reference",from:M.body.from}:M.body.kind==="inline"?{kind:"inline"}:void 0;if(T===void 0){g.push({name:O,source:j,declaration:{kind:"opaque",why:M.body.kind==="unsupported"?M.body.why:"unreadable"},...D?.text("label")?{label:D.text("label")}:{},...D?.text("subtitle")?{subtitle:D.text("subtitle")}:{},...D?.numeric("colspan")!==void 0?{colspan:D.numeric("colspan")}:{},...D?.has("break")?{break:!0}:{},...D?.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:O,source:j,declaration:T,...G?{filters:G}:{},...D?.text("label")?{label:D.text("label")}:{},...D?.text("subtitle")?{subtitle:D.text("subtitle")}:{},...D?.numeric("colspan")!==void 0?{colspan:D.numeric("colspan")}:{},...D?.has("break")?{break:!0}:{},...D?.has("borderless")?{borderless:!0}:{}})}const w=Hm(i,n,t),y={},p=u?.tag("givens");for(const v of Object.keys(p?.dict??{})){const k=p?.text(v);k!==void 0&&(y[v]=k)}const x=l?.tag("dashboard")?.numeric("columns");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 hl(e){const{problems:t}=await pu(e,"file://splice-check.malloy");return t.filter(n=>n.code==="syntax-error").map(n=>n.message??"").sort()}const fl=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 Gm(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
76
+ `&&t.push(n+1);return t}function Vm(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 gu(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=${Tn(e.label)}`),e.subtitle!==void 0&&t.push(`# subtitle=${Tn(e.subtitle)}`),t}function vi(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const Km=new Set(["colspan","break","borderless","label","subtitle"]),Xm=new Set(["label","description","control","suggest","range_min","range_max"]),Bm=(e,t)=>ye(e.imports)===ye(t.imports);function pl(e){const t=[];if(e.label!==void 0&&t.push(`label=${Tn(e.label)}`),e.description!==void 0&&t.push(`description=${Tn(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 gl=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function Zm(e,t,n){const r=e.sources.find(i=>i.name===t)?.views.find(i=>i.name===n);return r?r.line:-1}function ml(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(t=>`"${t}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const Wi=e=>`${e.source}.${e.name}`,Tn=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,po=e=>ye([e.name,e.source,e.declaration]),vt=po,vl=e=>ye(e.tiles.map(vt));function Jm(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||vl(e)!==vl(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 Bm(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 Qm(e){const{lines:t,wholeLine:n,next:r,reordered:i,currentKeys:s,nextKeys:o,edits:a}=e;if(i){const l=Ss(t);if(l<0)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const u=[...t[l].matchAll(/"([^"]+)"/g)].map(m=>m[1]),c=new Map;for(const m of u){const g=m.split("->").map(w=>w.trim());g.length===2&&c.set(`${g[0]}->${g[1]}`,m)}const d=r.tiles.map(m=>c.get(`${m.source}->${m.name}`)??(o.has(vt(m))&&!s.has(vt(m))?`${m.source} -> ${m.name}`:void 0));if(d.some(m=>m===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const f=`tiles=[${d.map(m=>`"${m}"`).join(", ")}]`,h=t[l].replace(/tiles\s*=\s*\[[\s\S]*?\]/,f);h!==t[l]&&a.push({...n(l),text:`${h}
77
+ `})}}function ev(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=Ss(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 m=(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&&m("title",i.title?Tn(i.title):void 0),r.autorun!==i.autorun&&m("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}=${Tn(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=l.replace(/\s*dashboard\s*\{[^}]*\}/,""),i.columns!==void 0&&(l=`${l.trimEnd()} dashboard { columns=${i.columns} }`)),a?a.text=`${l}
78
78
  `:s.push({...n(o),text:`${l}
79
79
  `})}if(r.description!==i.description){const o=t.map((l,u)=>l.trim().startsWith('##"')?u:-1).filter(l=>l>=0),a=(i.description??"").split(`
80
80
  `).map(l=>l.trim()===""?'##"':`##" ${l.trim()}`).join(`
81
81
  `);if(o.length>0){const l=o[0],u=o[o.length-1];s.push({start:n(l).start,end:n(u).end,text:i.description===void 0?"":`${a}
82
82
  `})}else if(i.description!==void 0){const l=Ss(t),u=n(l).start;s.push({start:u,end:u,text:`${a}
83
- `})}}}function ev(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,m]of l){const g=u.get(h);if(g!==void 0&&ye(g)===ye(m))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}=Fr(a,t,w.line),p=g===void 0?y:y.filter(O=>{const M=vi(O.text);return M!==void 0&&Km.has(M)});for(const O of p)o.push({...n(O.line),text:""}),d.add(O.line);const x=Bt(a,w.span.end-1);if(g===void 0){o.push({start:n(w.line).start,end:n(x).end,text:""});for(let I=w.line;I<=x;I++)d.add(I);const O=Math.min(w.line,...y.map(I=>I.line)),M=w.blockHeader??O,P=(t[x+1]??"x").trim()==="",T=M===0||t[M-1].trim()==="",G=w.blockHeader===void 0||![...c.values()].some(I=>I.blockHeader===w.blockHeader&&I.line>w.line&&u.has([...c.entries()].find(([,E])=>E===I)?.[0]??""));P&&T&&G&&!d.has(x+1)&&(o.push({...n(x+1),text:""}),d.add(x+1));continue}const v=r(w.line),k=pl(g),j=g.type!==m.type||g.default!==m.default?w.blockHeader===void 0?gl(g):`${g.name} :: ${g.type} is ${g.default}`:t.slice(w.line,x+1).join(`
83
+ `})}}}function tv(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,m]of l){const g=u.get(h);if(g!==void 0&&ye(g)===ye(m))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}=_r(a,t,w.line),p=g===void 0?y:y.filter(O=>{const M=vi(O.text);return M!==void 0&&Xm.has(M)});for(const O of p)o.push({...n(O.line),text:""}),d.add(O.line);const x=Bt(a,w.span.end-1);if(g===void 0){o.push({start:n(w.line).start,end:n(x).end,text:""});for(let I=w.line;I<=x;I++)d.add(I);const O=Math.min(w.line,...y.map(I=>I.line)),M=w.blockHeader??O,D=(t[x+1]??"x").trim()==="",T=M===0||t[M-1].trim()==="",G=w.blockHeader===void 0||![...c.values()].some(I=>I.blockHeader===w.blockHeader&&I.line>w.line&&u.has([...c.entries()].find(([,E])=>E===I)?.[0]??""));D&&T&&G&&!d.has(x+1)&&(o.push({...n(x+1),text:""}),d.add(x+1));continue}const v=r(w.line),k=pl(g),j=g.type!==m.type||g.default!==m.default?w.blockHeader===void 0?gl(g):`${g.name} :: ${g.type} is ${g.default}`:t.slice(w.line,x+1).join(`
84
84
  `).trim();o.push({start:n(w.line).start,end:n(x).end,text:(k?`${v}${k}
85
85
  `:"")+`${v}${j}
86
86
  `})}for(const[h,m]of c)m.blockHeader===void 0||u.has(h)||![...c.values()].some(g=>g.blockHeader===m.blockHeader&&!d.has(g.line))&&!d.has(m.blockHeader)&&(o.push({...n(m.blockHeader),text:""}),d.add(m.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)),m=(()=>{let p=-1;for(let x=0;x<t.length;x++){const v=t[x].trim();(v.startsWith("import ")||p>=0&&/^}\s*from\s/.test(v))&&(p=x)}return p})(),g=h>=0?h:m,w=f.map(p=>{const x=pl(p);return(x?`${x}
@@ -88,9 +88,9 @@ import{r as S,aM as wu,aN as yn,j as b,aa as he,aO as ku,at as Wt,N as pe,aP as
88
88
  `}).join(`
89
89
  `),y=g>=0?n(g).end:n(0).end;o.push({start:y,end:y,text:`
90
90
  ${w}`}),t.some(p=>p.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
91
- `})}}function tv(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,l=new Map((i.drills??[]).map(c=>[Wi(c),c])),u=new Map((s.drills??[]).map(c=>[Wi(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 m=a.sources.find(p=>p.name===h.source)?.dimensions.find(p=>p.name===h.name);if(m===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}=Fr(a,t,m.line),w=g.find(p=>/^#\s*drill\b/.test(p.text)),y=r(m.line);if(f===void 0)w&&o.push({...n(w.line),text:""});else if(w)o.push({...n(w.line),text:`${y}${ml(f)}
91
+ `})}}function nv(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,l=new Map((i.drills??[]).map(c=>[Wi(c),c])),u=new Map((s.drills??[]).map(c=>[Wi(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 m=a.sources.find(p=>p.name===h.source)?.dimensions.find(p=>p.name===h.name);if(m===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,m.line),w=g.find(p=>/^#\s*drill\b/.test(p.text)),y=r(m.line);if(f===void 0)w&&o.push({...n(w.line),text:""});else if(w)o.push({...n(w.line),text:`${y}${ml(f)}
92
92
  `});else{const p=n(m.line).start;o.push({start:p,end:p,text:`${y}${ml(f)}
93
- `})}}}function nv(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=gu(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({...bu(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 rv(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 m=f.declaration.kind==="reference"?f.declaration.from:f.name,g=(f.filters??[]).map(w=>`where: ${w.field} ${w.op??"~"} $${w.given}`).join(", ");return[...pu(f).map(w=>`${h}${w}`),`${h}view: ${f.name} is ${m}${g?` + { ${g} }`:""}`].join(`
93
+ `})}}}function rv(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=mu(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({...yu(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 iv(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 m=f.declaration.kind==="reference"?f.declaration.from:f.name,g=(f.filters??[]).map(w=>`where: ${w.field} ${w.op??"~"} $${w.given}`).join(", ");return[...gu(f).map(w=>`${h}${w}`),`${h}view: ${f.name} is ${m}${g?` + { ${g} }`:""}`].join(`
94
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 m=l.sources.find(v=>v.name===f);if(!m)return{ok:!1,reason:`Could not find where the source \`${f}\` is declared.`};if(!m.properties)return{ok:!1,reason:`\`${f}\` never opens an \`extend { … }\` block, so a new tile cannot be added inside it.`};const g=m.line,w=Bt(l,m.properties.closeStart);let y=" ";for(let v=g+1;v<w;v++){const k=/^(\s+)view:/.exec(n[v]);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
95
  `)+h.map(v=>c(v,y)).join(`
96
96
 
@@ -103,9 +103,9 @@ source: ${m.name} is ${m.base} extend {
103
103
  }
104
104
  `;let w=d;if(w<0)for(let x=0;x<n.length;x++){const v=n[x].trim();(/^(import\s|given:|}\s*from\s)/.test(v)||/^[A-Z_]+\s*::/.test(v))&&(w=x)}const y=w>=0?r(w).end:t.length,p=y===t.length&&!t.endsWith(`
105
105
  `)?`
106
- `:"";a.push({start:y,end:y,text:p+g}),d=w}}function iv(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=Bm(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}=Fr(l,t,f),m=i(f),g=pu(c),w=new Map(g.map(j=>[vi(j)??j,j])),y=new Set;for(const j of h){const O=vi(j.text);if(O===void 0||!Vm.has(O))continue;const M=w.get(O);if(M===void 0){a.push({...r(j.line),text:""});continue}y.add(O),M!==j.text&&a.push({...r(j.line),text:`${m}${M}
106
+ `:"";a.push({start:y,end:y,text:p+g}),d=w}}function sv(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=Zm(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),m=i(f),g=gu(c),w=new Map(g.map(j=>[vi(j)??j,j])),y=new Set;for(const j of h){const O=vi(j.text);if(O===void 0||!Km.has(O))continue;const M=w.get(O);if(M===void 0){a.push({...r(j.line),text:""});continue}y.add(O),M!==j.text&&a.push({...r(j.line),text:`${m}${M}
107
107
  `})}const p=g.filter(j=>!y.has(vi(j)??j));if(p.length>0){const j=n[f];a.push({start:j,end:j,text:p.map(O=>`${m}${O}
108
- `).join("")})}if(ye(d.filters)===ye(c.filters))continue;const x=gu(e,c);if(!x)return{ok:!1,reason:`Could not find \`${c.name}\`'s declaration to filter it.`};if(x.body.kind==="reference"){const j=av(e,c,x);if(j)return j;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 v=mu(c.filters,x.body.stage);if(v)return vu(c.name,v.given);const k=yu(e,c,x.body.stage);if(k)return k}}const Bt=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function gu(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function mu(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 vu(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 bi=e=>`where: ${e.field} ${e.op??"~"} $${e.given}`;function bl(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 sv(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 ov(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 bu(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 yu(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 m=h.filter(({clause:g})=>s.has(g.binding.given));for(const{clause:g}of h)o.add(g.binding.given);if(m.length===0&&h.length===f.clauses.length){const g=bu(r,f.span),w=sv(r,f.span,g);if(w)return bl(t.name,r,w);i.push({...g,text:""});continue}m.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 v=ov(f.clauses,y),k=r.commentIn(v);if(k)return bl(t.name,r,k);i.push({...v,text:""});continue}const x=bi(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(bi).join(", ")}`:l.map(f=>`
110
- ${n.indent}${bi(f)}`).join("");i.push({start:u,end:u,text:d})}function av(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:i,refinement:s}=n.body,o=mu(t.filters,s);if(o)return vu(t.name,o.given);const a=t.filters??[];if(!s){if(a.length===0)return;const c=` + { ${a.map(bi).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 yu(e,t,s)}async function yl(e,t){const n=await fo(e);if(uo(n))return{ok:!1,reason:`Cannot edit a file that will not open: ${n.reason}`};const r=n.document,i=Zm(r,t);if("reason"in i)return i;const s=await hu(e);if(du(s))return{ok:!1,reason:`Cannot edit a file that will not open: ${s.reason}`};const o=e.split(`
111
- `),a=Ym(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[Jm,Qm,ev,tv,nv,rv,iv]){const w=g(d);if(w)return w}const f=g=>{const{drills:w,localGivens:y,...p}=g,x=g.tiles.map(v=>{if(v.filters?.length)return v;const{filters:k,...j}=v;return j});return{...p,tiles:x,...w?.length?{drills:[...w].sort((v,k)=>Wi(v).localeCompare(Wi(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=Gm(e,c);if((await hl(e)).length===0){const g=await hl(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 m=await fo(h);return uo(m)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${m.reason}`}:ye(f(m.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 lv(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 v=[...p.stack.slice(0,p.index+1),x].slice(-100);return{stack:v,index:v.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 yl(r,u);if(fl(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]),m=S.useMemo(()=>JSON.stringify(u)!==JSON.stringify(a),[u,a]),g=S.useMemo(()=>{const y=new Set(a.tiles.map(po)),p=new Set(u.tiles.map(po));return[...y].some(x=>!p.has(x))||[...p].some(x=>!y.has(x))},[u,a]),w=S.useCallback(async()=>{const y=await yl(r,u);return fl(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:m,...s===void 0?{}:{error:s},update:c,undo:d,redo:f,save:h,preview:w,structural:g}}function cv({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=lv({source:e,document:t,...n?{onSave:n}:{}}),[m,g]=S.useState(void 0),[w,y]=S.useState(!1),p=h.document.columns??wu,{resize:x,gridBox:v,startResize:k,onResize:j,endResize:O}=$m({tiles:h.document.tiles,columns:p,onStart:g,commit:($,D)=>h.update(W=>{W.tiles[$].colspan=D})}),{dragging:M,preview:P,onDragStart:T,onDragOver:G,onDragEnd:I}=jm({tiles:h.document.tiles,commit:$=>h.update(D=>{D.tiles=$}),onLanded:g}),[E,_]=S.useState(void 0),[J,me]=S.useState(void 0),[Ae,oe]=S.useState(!1),[Ne,Ue]=S.useState(void 0),[Ee,Xe]=S.useState(null),[Ye,Fe]=S.useState(void 0);S.useEffect(()=>{r?.(h.document)},[h.document,r]),S.useEffect(()=>{i?.(h.dirty)},[h.dirty,i]);const Be=S.useMemo(()=>kg(h.document),[h.document]),Oe=S.useMemo(()=>{const $=new Set((t.localGivens??[]).map(D=>D.name));return(a??[]).filter(D=>!$.has(D.name))},[t,a]),xe=S.useMemo(()=>Gp(h.document,Oe),[h.document,Oe]),R=S.useMemo(()=>new Map(h.document.sources.map($=>[$.name,Xa(l,$.base)])),[l,h.document.sources]),F=S.useCallback($=>R.get($.source)??Xa(l,$.source),[R,l]),je=($,D)=>{const W=[];for(const Z of h.document.tiles){const it=F(Z);if(!it)continue;const $e=new Map(it.map(se=>[se.name,se.type]));for(const se of Z.filters??[])se.given===$&&(!$e.has(se.field)||!mi(D,$e.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},X=S.useMemo(()=>xe.filter($=>$.origin==="model"&&$.boundTiles===0),[xe]),_e=S.useCallback(()=>{Fe(void 0),y(!0);const $=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()-$}):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){_e();return}h.preview().then($=>{$.ok?Fe({before:h.source,after:$.source}):_e()})}},[n,h,w,_e]),ct=$=>{oe(!1),h.update(D=>{let W=D.sources.find($e=>$e.base===$.base);if(!W){const $e=new Set(D.sources.map(Ie=>Ie.name));let se=`${$.base}_tiles`;for(let Ie=2;$e.has(se);Ie++)se=`${$.base}_tiles_${Ie}`;W={name:se,base:$.base},D.sources.push(W)}const Z=new Set(D.tiles.filter($e=>$e.source===W.name).map($e=>$e.name));let it=`${$.view}_tile`;for(let $e=2;Z.has(it);$e++)it=`${$.view}_tile_${$e}`;D.tiles.push({name:it,source:W.name,declaration:{kind:"reference",from:$.view},colspan:$.colspan,...$.label?{label:$.label}:{}})}),g(h.document.tiles.length)},qe=$=>{me(void 0),g(void 0),h.update(D=>{D.tiles.splice($,1)})};og(S.useMemo(()=>({undo:h.undo,redo:h.redo,...n?{save:ee}:{},escape:()=>{!J&&!E&&g(void 0)},nudge:$=>{if(m===void 0)return;const D=h.document.tiles[m];if(!D||D.declaration.kind==="inherited")return;const W=Math.min(Math.max((D.colspan??1)+$,1),p);W!==(D.colspan??1)&&h.update(Z=>{Z.tiles[m].colspan=W})}}),[h,n,ee,J,E,m,p]));const St=($,D,W)=>{_(void 0),h.update(Z=>{W&&Qp(Z,W),Jp(Z,$,D)})},C=$=>{_(void 0),h.update(D=>eg(D,$))},A=(()=>{const $=h.document.tiles;return x!==void 0?$.map((D,W)=>W===x.index?{...D,colspan:x.span}:D):P??$})(),q=M?Cg(A,p):A.map(Zd);return b.jsxs(he,{sx:{gap:0},children:[b.jsx(ag,{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:Xe}),b.jsxs(he,{sx:{gap:2,px:"4px",pb:"4px"},children:[b.jsx(ku,{title:h.document.title||"Untitled dashboard",...h.document.description?{description:h.document.description}:{}}),b.jsx($g,{controls:xe,tileCount:h.document.tiles.length,unknownFieldsOf:je,onEdit:$=>_({control:$}),onAdd:()=>_({}),children:o}),h.error&&b.jsx(Wt,{severity:"warning",children:h.error}),b.jsx(Ep,{sensors:om,onDragStart:T,onDragOver:G,onDragEnd:I,children:b.jsxs(pe,{ref:v,sx:{position:"relative"},children:[(x!==void 0||M)&&b.jsx(gm,{columns:p}),b.jsx(Su,{tiles:q,columns:p,keyOf:$=>$.kind==="gap"?Jd($.after):mt($.tile),renderTile:$=>{if($.kind==="gap")return b.jsx(pm,{after:$.after});const{tile:D,index:W}=$;return b.jsx(hm,{tile:D,index:W,selected:W===m,menuOpen:J?.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:j,onResizeEnd:O,children:s?s(D):b.jsx(fm,{tile:D})})}})]})}),b.jsx(wg,{open:E!==void 0,document:h.document,...E?.control?{control:E.control}:{},available:X,...l?{fieldsFor:F}:{},onClose:()=>_(void 0),onApply:St,onRemove:C}),b.jsx(Om,{anchor:J?.anchor??null,tile:J===void 0?void 0:h.document.tiles[J.index],onClose:()=>me(void 0),onCommit:$=>{const D=J?.index;D!==void 0&&h.update(W=>{W.tiles[D]=$})},onRemove:()=>{J!==void 0&&qe(J.index)},columns:p,onDrills:()=>{J!==void 0&&Ue(h.document.tiles[J.index]?.source)}}),b.jsx(yg,{open:Ne!==void 0,document:h.document,source:h.document.sources.find($=>$.name===Ne),givenNames:xe.map($=>$.name),dashboards:c??[],onClose:()=>Ue(void 0),onApply:$=>h.update(D=>{const W=[...(D.drills??[]).filter(Z=>Z.source!==Ne),...$];W.length===0?delete D.drills:D.drills=W})}),b.jsx(Sg,{anchor:Ee,settings:Be,onClose:()=>Xe(null),onCommit:$=>h.update(D=>{D.title=$.title,$.description===void 0?delete D.description:D.description=$.description,$.columns===void 0?delete D.columns:D.columns=$.columns,$.autorun===void 0?delete D.autorun:D.autorun=$.autorun})}),b.jsx(gg,{open:Ae,document:h.document,catalog:l,columns:p,onClose:()=>oe(!1),onAdd:ct}),b.jsx(bg,{open:Ye!==void 0,before:Ye?.before??"",after:Ye?.after??"",onConfirm:_e,onClose:()=>Fe(void 0)})]})]})}function dv(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(uv(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 uv(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 hv(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=Hu(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 fv(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 xl=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function yv(e){const{onExit:t,onEvent:n,onDirtyChange:r}=e,i=(()=>{if("resourceUri"in e)try{return ju(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}=kl(),f=$u(),h=S.useRef(yn()),m=S.useRef(n);m.current=n;const g=S.useRef(r);g.current=r;const w=Ou()?.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,[v,k]=S.useState(void 0),[j,O]=S.useState(void 0),[M,P]=S.useState(w===void 0),[T,G]=S.useState(!1),[I,E]=S.useState(void 0);S.useEffect(()=>{if(!w)return;let V=!1;return E(void 0),(async()=>{try{const z=await w.listWorkspaces(!1),Q=z.find(K=>K.authoritative)??z.find(K=>K.writeable);if(V)return;if(k(Q),Q!==void 0){const K=await w.getDocument(xl(Q.name,s,o,y)).catch(te=>{if(!ya(te))throw te});if(V)return;O(K),G(K!==void 0)}}catch(z){if(V)return;E(wl(z))}V||P(!0)})(),()=>{V=!0}},[w,s,o,y]);const _=v?.authoritative===!0,J=_&&I!==void 0,[me,Ae]=S.useState(void 0),oe=(_||me===!0)&&j!==void 0,[Ne,Ue]=S.useState(void 0),[Ee,Xe]=S.useState(void 0),Ye=S.useRef(void 0),Fe=S.useRef(void 0),[Be,Oe]=S.useState(void 0),xe=p.dataUpdatedAt,R=S.useRef(xe);R.current=xe;const F=Be!==void 0&&Be.onFetch===xe?Be.text:x,je=S.useRef(F);je.current=F;const X=oe?j:F,[_e,ee]=S.useState(!1),[ct,qe]=S.useState(void 0),[St,C]=S.useState(void 0),A=X!==void 0&&X!==St,q=Ne?.source,$=A&&_e&&q!==void 0&&X!==ct,D=$?q:A?X:q??X,W=$?X:void 0,Z=S.useRef(q);Z.current=q;const it=S.useRef(X);it.current=X;const $e=S.useRef("package");$e.current=oe?_?"record":"draft":"package",S.useEffect(()=>{if(D===void 0||!M||J||D===Z.current)return;let V=!1;const z=je.current,Q=it.current;return fo(D).then(K=>{if(!V){if(uo(K)){const te=K.line?`${K.reason} (line ${K.line})`:K.reason;Xe(te),m.current?.({type:"dashboard.open_refused",reason:te});return}Xe(void 0),Ye.current=void 0,Fe.current=z,Oe(void 0),qe(void 0),C(Q),Ue(te=>({source:D,document:K.document,generation:(te?.generation??0)+1})),m.current?.({type:"dashboard.opened",from:$e.current,tiles:K.document.tiles.length,durationMs:yn()-h.current})}}),()=>{V=!0}},[D,M,J]);const se=v===void 0?void 0:xl(v.name,s,o,y),Ie=S.useCallback(async V=>{if(!w||!se)throw new Error("This host keeps no documents, so there is nowhere to save.");await w.saveDocument(se,V),Ue(z=>z&&{...z,source:V}),O(V),(_||me===!0)&&C(V),_||Ae(z=>z??!1)},[w,se,_,me]),[Yn,At]=S.useState(void 0),_r=S.useCallback(async V=>{const z=Fe.current,Q=Ye.current??(z===void 0?void 0:await fv(z));if(Q===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:V,expectedHash:Q})}catch(te){throw f.invalidateQueries({queryKey:["dashboard-editor-model",s,o,y,l]}),new Error(mv(te))}if(Ue(te=>te&&{...te,source:V}),Oe({text:V,onFetch:R.current}),C(V),Ye.current=K.data.contentHash,At(void 0),w&&se)try{await w.deleteDocument(se),O(void 0),G(!1)}catch(te){ya(te)?(O(void 0),G(!1)):At(wl(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=v?.writeable===!0,Gn=l!==void 0&&It==="package",Zi=I===void 0?_?w&&se&&nn?Ie:void 0:Gn?void 0:d?_r:w&&se&&nn?Ie:void 0:void 0,rn=v?.name,Ji=S.useCallback(V=>{m.current?.(V.type==="dashboard.saved"&&V.where!=="package"&&rn!==void 0?{...V,workspace:rn}:V)},[rn]),Vn=S.useCallback(V=>{ee(V),g.current?.(V)},[]),qr=V=>{h.current=yn(),qe(V?j:F),Ae(V)},Hr=()=>{h.current=yn(),qe(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(Mu,{error:p.error,context:"Opening the dashboard"}):!x||!M?b.jsxs(he,{sx:{gap:2},children:[b.jsx(Sl,{}),b.jsx(Cu,{text:"Opening the dashboard…"})]}):J?b.jsxs(Wt,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened: ",I]}):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:[!_&&T&&j!==void 0&&j!==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:()=>qr(!0),children:"Resume"}),b.jsx(ke,{size:"small",onClick:()=>qr(!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:Hr,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."}),Yn!==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:"," ",Yn]}),Ne&&b.jsx(gv,{environmentName:s,packageName:o,modelPath:y,slug:a,...l!==void 0?{versionId:l}:{},opened:Ne,onSave:Zi,onDirtyChange:Vn,savesTo:It,...n?{onEvent:Ji}:{},toolbar:t&&b.jsx(jl,{label:"Done editing",icon:b.jsx(Eu,{}),onClick:t}),note:pv({authoritative:_,mutable:d,pinnedPackageSave:Gn,...v?{workspace:v}:{},...I!==void 0?{readFailure:I}:{},...l!==void 0?{versionId:l}:{}})},Ne.generation)]})}function pv({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 gv({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}=kl(),{data:h,isSuccess:m}=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(E=>E.name).filter(E=>!!E&&E!==r),[w,r]),p=S.useMemo(()=>{const E=n.slice(0,n.lastIndexOf("/")+1),_=new Set;for(const J of s.document.imports){const me=new URL(J.from,`https://malloy.invalid/${E}`);_.add(me.pathname.slice(1))}return[..._]},[s.document.imports,n]),{data:x}=ri({queryKey:["dashboard-editor-catalog",e,t,...p,i],queryFn:async()=>{const E=await Promise.all(p.map(_=>f.models.getModel(e,t,_,i).then(J=>J.data)));return fg(E)},enabled:p.length>0}),[v,k]=S.useState(s.document);S.useEffect(()=>k(s.document),[s.document]);const j=S.useMemo(()=>g?.givens??[],[g]),O=S.useMemo(()=>new Set(j.map(E=>E.name).filter(E=>E!==void 0)),[j]),M=S.useMemo(()=>dv(v,j),[v,j]),{declaredTypes:P,applied:T,panel:G}=zu({specs:M,loaded:m,startingValues:g?.startingGivens,documentKey:`${e}/${t}/${i??""}/${r}/edit`,autorun:g?.autorun!==!1,environmentName:e,packageName:t,modelPath:g?.path,versionId:i,documentName:r}),I=S.useMemo(()=>function(E){const _=hv(v,E,O,T);return b.jsx(Lu,{environmentName:e,packageName:t,versionId:i,modelPath:n,tile:_.expression,label:E.label??Fu(`${E.source} -> ${E.name}`),subtitle:E.subtitle,borderless:E.borderless,givens:T,declaredTypes:P,givenNames:_.givenNames,height:Nu})},[v,O,e,t,i,n,T,P]);return b.jsxs(he,{sx:{gap:1},children:[b.jsx(cv,{source:s.source,document:s.document,renderTile:I,givens:M.filter(E=>E.name!==void 0).map(E=>({name:E.name,...E.label?{label:E.label}:{},...E.type?{type:E.type}:{},...E.suggest?.dimension?{field:E.suggest.dimension}:{}})),onChange:k,onDirtyChange:a,...x?{catalog:x}:{},dashboards:y,...l?{onEvent:l}:{},toolbar:c,controls:m?b.jsx(_u,{...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 wl(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:{}}:wa===void 0&&(wa={});export{cv as DashboardBuilder,yv as DashboardEditor,fg as buildCatalog,fo as readDashboardDocument,uo as readFailed,yl as spliceDashboardDocument,fl as spliceFailed};
108
+ `).join("")})}if(ye(d.filters)===ye(c.filters))continue;const x=mu(e,c);if(!x)return{ok:!1,reason:`Could not find \`${c.name}\`'s declaration to filter it.`};if(x.body.kind==="reference"){const j=lv(e,c,x);if(j)return j;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 v=vu(c.filters,x.body.stage);if(v)return bu(c.name,v.given);const k=xu(e,c,x.body.stage);if(k)return k}}const Bt=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function mu(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function vu(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 bu(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 bi=e=>`where: ${e.field} ${e.op??"~"} $${e.given}`;function bl(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 ov(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 av(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 yu(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 xu(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 m=h.filter(({clause:g})=>s.has(g.binding.given));for(const{clause:g}of h)o.add(g.binding.given);if(m.length===0&&h.length===f.clauses.length){const g=yu(r,f.span),w=ov(r,f.span,g);if(w)return bl(t.name,r,w);i.push({...g,text:""});continue}m.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 v=av(f.clauses,y),k=r.commentIn(v);if(k)return bl(t.name,r,k);i.push({...v,text:""});continue}const x=bi(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(bi).join(", ")}`:l.map(f=>`
110
+ ${n.indent}${bi(f)}`).join("");i.push({start:u,end:u,text:d})}function lv(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:i,refinement:s}=n.body,o=vu(t.filters,s);if(o)return bu(t.name,o.given);const a=t.filters??[];if(!s){if(a.length===0)return;const c=` + { ${a.map(bi).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 xu(e,t,s)}async function yl(e,t){const n=await fo(e);if(uo(n))return{ok:!1,reason:`Cannot edit a file that will not open: ${n.reason}`};const r=n.document,i=Jm(r,t);if("reason"in i)return i;const s=await fu(e);if(uu(s))return{ok:!1,reason:`Cannot edit a file that will not open: ${s.reason}`};const o=e.split(`
111
+ `),a=Gm(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[Qm,ev,tv,nv,rv,iv,sv]){const w=g(d);if(w)return w}const f=g=>{const{drills:w,localGivens:y,...p}=g,x=g.tiles.map(v=>{if(v.filters?.length)return v;const{filters:k,...j}=v;return j});return{...p,tiles:x,...w?.length?{drills:[...w].sort((v,k)=>Wi(v).localeCompare(Wi(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=Vm(e,c);if((await hl(e)).length===0){const g=await hl(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 m=await fo(h);return uo(m)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${m.reason}`}:ye(f(m.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 cv(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 v=[...p.stack.slice(0,p.index+1),x].slice(-100);return{stack:v,index:v.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 yl(r,u);if(fl(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]),m=S.useMemo(()=>JSON.stringify(u)!==JSON.stringify(a),[u,a]),g=S.useMemo(()=>{const y=new Set(a.tiles.map(po)),p=new Set(u.tiles.map(po));return[...y].some(x=>!p.has(x))||[...p].some(x=>!y.has(x))},[u,a]),w=S.useCallback(async()=>{const y=await yl(r,u);return fl(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:m,...s===void 0?{}:{error:s},update:c,undo:d,redo:f,save:h,preview:w,structural:g}}function dv({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=cv({source:e,document:t,...n?{onSave:n}:{}}),[m,g]=S.useState(void 0),[w,y]=S.useState(!1),p=h.document.columns??ku,{resize:x,gridBox:v,startResize:k,onResize:j,endResize:O}=Om({tiles:h.document.tiles,columns:p,onStart:g,commit:($,P)=>h.update(W=>{W.tiles[$].colspan=P})}),{dragging:M,preview:D,onDragStart:T,onDragOver:G,onDragEnd:I}=$m({tiles:h.document.tiles,commit:$=>h.update(P=>{P.tiles=$}),onLanded:g}),[E,F]=S.useState(void 0),[V,me]=S.useState(void 0),[Ae,oe]=S.useState(!1),[Ne,Ue]=S.useState(void 0),[Ee,Xe]=S.useState(null),[Ye,_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(()=>Sg(h.document),[h.document]),Oe=S.useMemo(()=>{const $=new Set((t.localGivens??[]).map(P=>P.name));return(a??[]).filter(P=>!$.has(P.name))},[t,a]),xe=S.useMemo(()=>Vp(h.document,Oe),[h.document,Oe]),R=S.useMemo(()=>new Map(h.document.sources.map($=>[$.name,Xa(l,$.base)])),[l,h.document.sources]),_=S.useCallback($=>R.get($.source)??Xa(l,$.source),[R,l]),je=($,P)=>{const W=[];for(const J of h.document.tiles){const it=_(J);if(!it)continue;const $e=new Map(it.map(se=>[se.name,se.type]));for(const se of J.filters??[])se.given===$&&(!$e.has(se.field)||!mi(P,$e.get(se.field)))&&W.push(`${se.field} on ${J.label??J.name} (${h.document.sources.find(Ie=>Ie.name===J.source)?.base??J.source})`)}return W},B=S.useMemo(()=>xe.filter($=>$.origin==="model"&&$.boundTiles===0),[xe]),Fe=S.useCallback(()=>{_e(void 0),y(!0);const $=yn(),{structural:P}=h,W=h.document.tiles.length;h.save().then(J=>{J.ok===!0?d?.({type:"dashboard.saved",tiles:W,structural:P,where:f,durationMs:yn()-$}):d?.({type:"dashboard.save_refused",reason:J.reason})}).finally(()=>y(!1))},[h,d,f]),ee=S.useCallback(()=>{if(!(!n||!h.dirty||w)){if(!h.structural){Fe();return}h.preview().then($=>{$.ok?_e({before:h.source,after:$.source}):Fe()})}},[n,h,w,Fe]),ct=$=>{oe(!1),h.update(P=>{let W=P.sources.find($e=>$e.base===$.base);if(!W){const $e=new Set(P.sources.map(Ie=>Ie.name));let se=`${$.base}_tiles`;for(let Ie=2;$e.has(se);Ie++)se=`${$.base}_tiles_${Ie}`;W={name:se,base:$.base},P.sources.push(W)}const J=new Set(P.tiles.filter($e=>$e.source===W.name).map($e=>$e.name));let it=`${$.view}_tile`;for(let $e=2;J.has(it);$e++)it=`${$.view}_tile_${$e}`;P.tiles.push({name:it,source:W.name,declaration:{kind:"reference",from:$.view},colspan:$.colspan,...$.label?{label:$.label}:{}})}),g(h.document.tiles.length)},qe=$=>{me(void 0),g(void 0),h.update(P=>{P.tiles.splice($,1)})};ag(S.useMemo(()=>({undo:h.undo,redo:h.redo,...n?{save:ee}:{},escape:()=>{!V&&!E&&g(void 0)},nudge:$=>{if(m===void 0)return;const P=h.document.tiles[m];if(!P||P.declaration.kind==="inherited")return;const W=Math.min(Math.max((P.colspan??1)+$,1),p);W!==(P.colspan??1)&&h.update(J=>{J.tiles[m].colspan=W})}}),[h,n,ee,V,E,m,p]));const St=($,P,W)=>{F(void 0),h.update(J=>{W&&eg(J,W),Qp(J,$,P)})},C=$=>{F(void 0),h.update(P=>tg(P,$))},A=(()=>{const $=h.document.tiles;return x!==void 0?$.map((P,W)=>W===x.index?{...P,colspan:x.span}:P):D??$})(),q=M?Eg(A,p):A.map(Jd);return b.jsxs(he,{sx:{gap:0},children:[b.jsx(lg,{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:Xe}),b.jsxs(he,{sx:{gap:2,px:"4px",pb:"4px"},children:[b.jsx(Su,{title:h.document.title||"Untitled dashboard",...h.document.description?{description:h.document.description}:{}}),b.jsx(Og,{controls:xe,tileCount:h.document.tiles.length,unknownFieldsOf:je,onEdit:$=>F({control:$}),onAdd:()=>F({}),children:o}),h.error&&b.jsx(Wt,{severity:"warning",children:h.error}),b.jsx(Pp,{sensors:am,onDragStart:T,onDragOver:G,onDragEnd:I,children:b.jsxs(pe,{ref:v,sx:{position:"relative"},children:[(x!==void 0||M)&&b.jsx(mm,{columns:p}),b.jsx(ju,{tiles:q,columns:p,keyOf:$=>$.kind==="gap"?Qd($.after):mt($.tile),renderTile:$=>{if($.kind==="gap")return b.jsx(gm,{after:$.after});const{tile:P,index:W}=$;return b.jsx(fm,{tile:P,index:W,selected:W===m,menuOpen:V?.index===W,resizeSpan:x?.index===W?x.span:void 0,columns:p,onSelect:()=>g(W),onOpenMenu:J=>{g(W),me({anchor:J,index:W})},onResizeStart:J=>k(J,W),onResizeMove:j,onResizeEnd:O,children:s?s(P):b.jsx(pm,{tile:P})})}})]})}),b.jsx(kg,{open:E!==void 0,document:h.document,...E?.control?{control:E.control}:{},available:B,...l?{fieldsFor:_}:{},onClose:()=>F(void 0),onApply:St,onRemove:C}),b.jsx(Mm,{anchor:V?.anchor??null,tile:V===void 0?void 0:h.document.tiles[V.index],onClose:()=>me(void 0),onCommit:$=>{const P=V?.index;P!==void 0&&h.update(W=>{W.tiles[P]=$})},onRemove:()=>{V!==void 0&&qe(V.index)},columns:p,onDrills:()=>{V!==void 0&&Ue(h.document.tiles[V.index]?.source)}}),b.jsx(xg,{open:Ne!==void 0,document:h.document,source:h.document.sources.find($=>$.name===Ne),givenNames:xe.map($=>$.name),dashboards:c??[],onClose:()=>Ue(void 0),onApply:$=>h.update(P=>{const W=[...(P.drills??[]).filter(J=>J.source!==Ne),...$];W.length===0?delete P.drills:P.drills=W})}),b.jsx(jg,{anchor:Ee,settings:Be,onClose:()=>Xe(null),onCommit:$=>h.update(P=>{P.title=$.title,$.description===void 0?delete P.description:P.description=$.description,$.columns===void 0?delete P.columns:P.columns=$.columns,$.autorun===void 0?delete P.autorun:P.autorun=$.autorun})}),b.jsx(mg,{open:Ae,document:h.document,catalog:l,columns:p,onClose:()=>oe(!1),onAdd:ct}),b.jsx(yg,{open:Ye!==void 0,before:Ye?.before??"",after:Ye?.after??"",onConfirm:Fe,onClose:()=>_e(void 0)})]})]})}function uv(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(hv(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 hv(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 fv(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=Uu(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 pv(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 xl=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function xv(e){const{onExit:t,onEvent:n,onDirtyChange:r}=e,i=(()=>{if("resourceUri"in e)try{return $u(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}=kl(),f=Ou(),h=S.useRef(yn()),m=S.useRef(n);m.current=n;const g=S.useRef(r);g.current=r;const w=Mu()?.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,[v,k]=S.useState(void 0),[j,O]=S.useState(void 0),[M,D]=S.useState(w===void 0),[T,G]=S.useState(!1),[I,E]=S.useState(void 0);S.useEffect(()=>{if(!w)return;let K=!1;return E(void 0),(async()=>{try{const z=await w.listWorkspaces(!1),Q=z.find(X=>X.authoritative)??z.find(X=>X.writeable);if(K)return;if(k(Q),Q!==void 0){const X=await w.getDocument(xl(Q.name,s,o,y)).catch(te=>{if(!ya(te))throw te});if(K)return;O(X),G(X!==void 0)}}catch(z){if(K)return;E(wl(z))}K||D(!0)})(),()=>{K=!0}},[w,s,o,y]);const F=v?.authoritative===!0,V=F&&I!==void 0,[me,Ae]=S.useState(void 0),oe=(F||me===!0)&&j!==void 0,[Ne,Ue]=S.useState(void 0),[Ee,Xe]=S.useState(void 0),Ye=S.useRef(void 0),_e=S.useRef(void 0),[Be,Oe]=S.useState(void 0),xe=p.dataUpdatedAt,R=S.useRef(xe);R.current=xe;const _=Be!==void 0&&Be.onFetch===xe?Be.text:x,je=S.useRef(_);je.current=_;const B=oe?j:_,[Fe,ee]=S.useState(!1),[ct,qe]=S.useState(void 0),[St,C]=S.useState(void 0),A=B!==void 0&&B!==St,q=Ne?.source,$=A&&Fe&&q!==void 0&&B!==ct,P=$?q:A?B:q??B,W=$?B:void 0,J=S.useRef(q);J.current=q;const it=S.useRef(B);it.current=B;const $e=S.useRef("package");$e.current=oe?F?"record":"draft":"package",S.useEffect(()=>{if(P===void 0||!M||V||P===J.current)return;let K=!1;const z=je.current,Q=it.current;return fo(P).then(X=>{if(!K){if(uo(X)){const te=X.line?`${X.reason} (line ${X.line})`:X.reason;Xe(te),m.current?.({type:"dashboard.open_refused",reason:te});return}Xe(void 0),Ye.current=void 0,_e.current=z,Oe(void 0),qe(void 0),C(Q),Ue(te=>({source:P,document:X.document,generation:(te?.generation??0)+1})),m.current?.({type:"dashboard.opened",from:$e.current,tiles:X.document.tiles.length,durationMs:yn()-h.current})}}),()=>{K=!0}},[P,M,V]);const se=v===void 0?void 0:xl(v.name,s,o,y),Ie=S.useCallback(async K=>{if(!w||!se)throw new Error("This host keeps no documents, so there is nowhere to save.");await w.saveDocument(se,K),Ue(z=>z&&{...z,source:K}),O(K),(F||me===!0)&&C(K),F||Ae(z=>z??!1)},[w,se,F,me]),[Yn,At]=S.useState(void 0),Fr=S.useCallback(async K=>{const z=_e.current,Q=Ye.current??(z===void 0?void 0:await pv(z));if(Q===void 0)throw new Error("The package file is still loading; try again.");let X;try{X=await c.models.updateModelSource(s,o,y,{source:K,expectedHash:Q})}catch(te){throw f.invalidateQueries({queryKey:["dashboard-editor-model",s,o,y,l]}),new Error(vv(te))}if(Ue(te=>te&&{...te,source:K}),Oe({text:K,onFetch:R.current}),C(K),Ye.current=X.data.contentHash,At(void 0),w&&se)try{await w.deleteDocument(se),O(void 0),G(!1)}catch(te){ya(te)?(O(void 0),G(!1)):At(wl(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=F?"host":d?"package":"browser",nn=v?.writeable===!0,Gn=l!==void 0&&It==="package",Zi=I===void 0?F?w&&se&&nn?Ie:void 0:Gn?void 0:d?Fr:w&&se&&nn?Ie:void 0:void 0,rn=v?.name,Ji=S.useCallback(K=>{m.current?.(K.type==="dashboard.saved"&&K.where!=="package"&&rn!==void 0?{...K,workspace:rn}:K)},[rn]),Vn=S.useCallback(K=>{ee(K),g.current?.(K)},[]),qr=K=>{h.current=yn(),qe(K?j:_),Ae(K)},Hr=()=>{h.current=yn(),qe(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(Cu,{error:p.error,context:"Opening the dashboard"}):!x||!M?b.jsxs(he,{sx:{gap:2},children:[b.jsx(Sl,{}),b.jsx(Eu,{text:"Opening the dashboard…"})]}):V?b.jsxs(Wt,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened: ",I]}):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:[!F&&T&&j!==void 0&&j!==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:()=>qr(!0),children:"Resume"}),b.jsx(ke,{size:"small",onClick:()=>qr(!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:Hr,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."}),Yn!==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:"," ",Yn]}),Ne&&b.jsx(mv,{environmentName:s,packageName:o,modelPath:y,slug:a,...l!==void 0?{versionId:l}:{},opened:Ne,onSave:Zi,onDirtyChange:Vn,savesTo:It,...n?{onEvent:Ji}:{},toolbar:t&&b.jsx(jl,{label:"Done editing",icon:b.jsx(Pu,{}),onClick:t}),note:gv({authoritative:F,mutable:d,pinnedPackageSave:Gn,...v?{workspace:v}:{},...I!==void 0?{readFailure:I}:{},...l!==void 0?{versionId:l}:{}})},Ne.generation)]})}function gv({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 mv({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}=kl(),{data:h,isSuccess:m}=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(E=>E.name).filter(E=>!!E&&E!==r),[w,r]),p=S.useMemo(()=>{const E=n.slice(0,n.lastIndexOf("/")+1);return s.document.imports.map(F=>({...F,path:new URL(F.from,`https://malloy.invalid/${E}`).pathname.slice(1)}))},[s.document.imports,n]),{data:x}=ri({queryKey:["dashboard-editor-catalog",e,t,...p.map(E=>E.path),i],queryFn:async()=>{const E=(await f.models.listModels(e,t,i)).data.filter(V=>V.path&&!V.error),F=(await Promise.allSettled(E.map(V=>f.models.getModel(e,t,V.path,i).then(me=>me.data)))).flatMap(V=>V.status==="fulfilled"?[V.value]:[]);return pg(fg(F),p,F)},enabled:p.length>0}),[v,k]=S.useState(s.document);S.useEffect(()=>k(s.document),[s.document]);const j=S.useMemo(()=>g?.givens??[],[g]),O=S.useMemo(()=>new Set(j.map(E=>E.name).filter(E=>E!==void 0)),[j]),M=S.useMemo(()=>uv(v,j),[v,j]),{declaredTypes:D,applied:T,panel:G}=Lu({specs:M,loaded:m,startingValues:g?.startingGivens,documentKey:`${e}/${t}/${i??""}/${r}/edit`,autorun:g?.autorun!==!1,environmentName:e,packageName:t,modelPath:g?.path,versionId:i,documentName:r}),I=S.useMemo(()=>function(E){const F=fv(v,E,O,T);return b.jsx(Nu,{environmentName:e,packageName:t,versionId:i,modelPath:n,tile:F.expression,label:E.label??Fu(`${E.source} -> ${E.name}`),subtitle:E.subtitle,borderless:E.borderless,givens:T,declaredTypes:D,givenNames:F.givenNames,height:_u})},[v,O,e,t,i,n,T,D]);return b.jsxs(he,{sx:{gap:1},children:[b.jsx(dv,{source:s.source,document:s.document,renderTile:I,givens:M.filter(E=>E.name!==void 0).map(E=>({name:E.name,...E.label?{label:E.label}:{},...E.type?{type:E.type}:{},...E.suggest?.dimension?{field:E.suggest.dimension}:{}})),onChange:k,onDirtyChange:a,...x?{catalog:x}:{},dashboards:y,...l?{onEvent:l}:{},toolbar:c,controls:m?b.jsx(qu,{...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 wl(e){return e instanceof Error?e.message:String(e)}function vv(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:{}}:wa===void 0&&(wa={});export{dv as DashboardBuilder,xv as DashboardEditor,fg as buildCatalog,fo as readDashboardDocument,uo as readFailed,yl as spliceDashboardDocument,fl as spliceFailed};