@malloy-publisher/sdk 0.7.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,27 +1,27 @@
1
- "use strict";var Jd=Object.create;var sa=Object.defineProperty;var eu=Object.getOwnPropertyDescriptor;var tu=Object.getOwnPropertyNames;var nu=Object.getPrototypeOf,ru=Object.prototype.hasOwnProperty;var iu=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of tu(t))!ru.call(e,i)&&i!==n&&sa(e,i,{get:()=>t[i],enumerable:!(r=eu(t,i))||r.enumerable});return e};var oa=(e,t,n)=>(n=e!=null?Jd(nu(e)):{},iu(t||!e||!e.__esModule?sa(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),S=require("react"),su=require("react-dom"),k=require("@mui/material"),j=require("../DocumentStorage-D7yF4_T3.cjs.js"),Be=require("../ServerProvider-CuYLH_Yi.cjs.js"),ou=require("@tanstack/react-query");var au=Symbol.for("preact-signals");function Ci(){if(vt>1)vt--;else{var e,t=!1;for((function(){var i=ui;for(ui=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}})();cr!==void 0;){var n=cr;for(cr=void 0,di++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ol(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(di=0,vt--,t)throw e}}function de(e){if(vt>0)return e();ds=++lu,vt++;try{return e()}finally{Ci()}}var lr,re=void 0;function U(e){var t=re,n=lr;re=void 0,lr=void 0;try{return e()}finally{re=t,lr=n}}var cr=void 0,vt=0,di=0,lu=0,ds=0,ui=void 0,fi=0;function sl(e){if(re!==void 0){var t=e.n;if(t===void 0||t.t!==re)return t={i:0,S:e,p:re.s,n:void 0,t:re,e:void 0,x:void 0,r:t},re.s!==void 0&&(re.s.n=t),re.s=t,e.n=t,32&re.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=re.s,t.n=void 0,re.s.n=t,re.s=t),t}}function Re(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}Re.prototype.brand=au;Re.prototype.h=function(){return!0};Re.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:U(function(){var r;(r=t.W)==null||r.call(t)}))};Re.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&&U(function(){var i;(i=t.Z)==null||i.call(t)}))}};Re.prototype.subscribe=function(e){var t=this;return tt(function(){var n=t.value;U(function(){return e(n)})},{name:"sub"})};Re.prototype.valueOf=function(){return this.value};Re.prototype.toString=function(){return this.value+""};Re.prototype.toJSON=function(){return this.value};Re.prototype.peek=function(){var e=this;return U(function(){return e.value})};Object.defineProperty(Re.prototype,"value",{get:function(){var e=sl(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(di>100)throw new Error("Cycle detected");(function(n){vt!==0&&di===0&&n.l!==ds&&(n.l=ds,ui={S:n,v:n.v,i:n.i,o:ui})})(this),this.v=e,this.i++,fi++,vt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Ci()}}}});function En(e,t){return new Re(e,t)}function ol(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 al(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 ll(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 qt(e,t){Re.call(this,void 0,t),this.x=e,this.s=void 0,this.g=fi-1,this.f=4}qt.prototype=new Re;qt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===fi))return!0;if(this.g=fi,this.f|=1,this.i>0&&!ol(this))return this.f&=-2,!0;var e=re;try{al(this),re=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 re=e,ll(this),this.f&=-2,!0};qt.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)}Re.prototype.S.call(this,e)};qt.prototype.U=function(e){if(this.t!==void 0&&(Re.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)}};qt.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(qt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=sl(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function aa(e,t){return new qt(e,t)}function cl(e){var t=e.m;if(e.m=void 0,typeof t=="function"){vt++;var n=re;re=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,eo(e),r}finally{re=n,Ci()}}}function eo(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,cl(e)}function cu(e){if(re!==this)throw new Error("Out-of-order effect");ll(this),re=e,this.f&=-2,8&this.f&&eo(this),Ci()}function On(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,lr&&lr.push(this)}On.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()}};On.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,cl(this),al(this),vt++;var e=re;return re=this,cu.bind(this,e)};On.prototype.N=function(){2&this.f||(this.f|=2,this.u=cr,cr=this)};On.prototype.d=function(){this.f|=8,1&this.f||eo(this)};On.prototype.dispose=function(){this.d()};function tt(e,t){var n=new On(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var du=Object.create,to=Object.defineProperty,uu=Object.defineProperties,fu=Object.getOwnPropertyDescriptor,hu=Object.getOwnPropertyDescriptors,la=Object.getOwnPropertySymbols,pu=Object.prototype.hasOwnProperty,gu=Object.prototype.propertyIsEnumerable,vu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Dn=e=>{throw TypeError(e)},us=(e,t,n)=>t in e?to(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mu=(e,t)=>{for(var n in t||(t={}))pu.call(t,n)&&us(e,n,t[n]);if(la)for(var n of la(t))gu.call(t,n)&&us(e,n,t[n]);return e},yu=(e,t)=>uu(e,hu(t)),ca=(e,t)=>to(e,"name",{value:t,configurable:!0}),bu=e=>{var t;return[,,,du((t=void 0)!=null?t:null)]},dl=["class","method","getter","setter","accessor","field","value","get","set"],Hn=e=>e!==void 0&&typeof e!="function"?Dn("Function expected"):e,xu=(e,t,n,r,i)=>({kind:dl[e],name:t,metadata:r,addInitializer:s=>n._?Dn("Already initialized"):i.push(Hn(s||null))}),ul=(e,t)=>us(t,vu("metadata"),e[3]),Mt=(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},Tn=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,h=!!(t&8),f=!!(t&16),g=d>3?e.length+1:d?h?1:2:0,v=dl[d+5],w=d>3&&(e[g-1]=[]),x=e[g]||(e[g]=[]),m=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&fu(d<4?i:{get[n](){return Qe(this,s)},set[n](b){return kt(this,s,b)}},n));d?f&&d<4&&ca(s,(d>2?"set ":d>1?"get ":"")+n):ca(i,n);for(var p=r.length-1;p>=0;p--)u=xu(d,n,l={},e[3],x),d&&(u.static=h,u.private=f,c=u.access={has:f?b=>wu(i,b):b=>n in b},d^3&&(c.get=f?b=>(d^1?Qe:_u)(b,i,d^4?s:m.get):b=>b[n]),d>2&&(c.set=f?(b,_)=>kt(b,i,_,d^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[p])(d?d<4?f?s:m[v]:d>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,d^4||a===void 0?Hn(a)&&(d>4?w.unshift(a):d?f?s=a:m[v]=a:i=a):typeof a!="object"||a===null?Dn("Object expected"):(Hn(o=a.get)&&(m.get=o),Hn(o=a.set)&&(m.set=o),Hn(o=a.init)&&w.unshift(o));return d||ul(e,i),m&&to(i,n,m),f?d^4?s:m:i},no=(e,t,n)=>t.has(e)||Dn("Cannot "+n),wu=(e,t)=>Object(t)!==t?Dn('Cannot use the "in" operator on this value'):e.has(t),Qe=(e,t,n)=>(no(e,t,"read from private field"),n?n.call(e):t.get(e)),qn=(e,t,n)=>t.has(e)?Dn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),kt=(e,t,n,r)=>(no(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),_u=(e,t,n)=>(no(e,t,"access private method"),n);function fs(e,t){if(t){let n;return aa(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return aa(e)}function rt(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((r,i)=>!rt(r,t[i]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(s=>!rt(e[s],t[s]))}return!1}function H({get:e},t){return{init(n){return En(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function pe(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=fs(e.bind(this)),n.set(this,r)),r.value}}function Hi(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,yu(mu({},i),{enumerable:e}))})}}function $r(...e){const t=e.map(n=>tt(n));return()=>t.forEach(n=>n())}var fl,hl,pl,gl,vl,ml,Ie,ro,qi,hs,ps,Ce,io,Ki,yl,gs,so,Yi,vs,ms;ml=[H],vl=[H],gl=[H],pl=[Hi()],hl=[Hi()],fl=[Hi()];var Kt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Mt(Ie,5,this),qn(this,Ce),qn(this,ro,Mt(Ie,8,this)),Mt(Ie,11,this),qn(this,io,Mt(Ie,12,this)),Mt(Ie,15,this),qn(this,so,Mt(Ie,16,this)),Mt(Ie,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Qe(this,Ce,vs)}get initial(){return Qe(this,Ce,hs)}get previous(){return Qe(this,Ce,yl)}set current(e){const t=U(()=>Qe(this,Ce,vs));e&&t&&this.equals(t,e)||de(()=>{Qe(this,Ce,hs)||kt(this,Ce,e,ps),kt(this,Ce,t,gs),kt(this,Ce,e,ms)})}reset(e=this.defaultValue){de(()=>{kt(this,Ce,void 0,gs),kt(this,Ce,e,ps),kt(this,Ce,e,ms)})}};Ie=bu();ro=new WeakMap;Ce=new WeakSet;io=new WeakMap;so=new WeakMap;qi=Tn(Ie,20,"#initial",ml,Ce,ro),hs=qi.get,ps=qi.set;Ki=Tn(Ie,20,"#previous",vl,Ce,io),yl=Ki.get,gs=Ki.set;Yi=Tn(Ie,20,"#current",gl,Ce,so),vs=Yi.get,ms=Yi.set;Tn(Ie,2,"current",pl,Kt);Tn(Ie,2,"initial",hl,Kt);Tn(Ie,2,"previous",fl,Kt);ul(Ie,Kt);function Xi(e){return U(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var It,ku=class{constructor(){qn(this,It,new WeakMap)}get(e,t){var n;return e?(n=Qe(this,It).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Qe(this,It).has(e)||Qe(this,It).set(e,new Map),(r=Qe(this,It).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Qe(this,It).get(e))==null?void 0:t.clear():void 0}};It=new WeakMap;var Su=Object.create,bl=Object.defineProperty,$u=Object.getOwnPropertyDescriptor,da=Object.getOwnPropertySymbols,Eu=Object.prototype.hasOwnProperty,Ou=Object.prototype.propertyIsEnumerable,xl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Pi=e=>{throw TypeError(e)},ua=Math.pow,ys=(e,t,n)=>t in e?bl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Du=(e,t)=>{for(var n in t||(t={}))Eu.call(t,n)&&ys(e,n,t[n]);if(da)for(var n of da(t))Ou.call(t,n)&&ys(e,n,t[n]);return e},Tu=e=>{var t;return[,,,Su((t=e?.[xl("metadata")])!=null?t:null)]},wl=["class","method","getter","setter","accessor","field","value","get","set"],_l=e=>e!==void 0&&typeof e!="function"?Pi("Function expected"):e,Cu=(e,t,n,r,i)=>({kind:wl[e],name:t,metadata:r,addInitializer:s=>n._?Pi("Already initialized"):i.push(_l(s||null))}),Pu=(e,t)=>ys(t,xl("metadata"),e[3]),Mu=(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},kl=(e,t,n,r,i,s)=>{for(var o,a,l,u,c=t&7,d=!1,h=!1,f=2,g=wl[c+5],v=e[f]||(e[f]=[]),w=(i=i.prototype,$u(i,n)),x=r.length-1;x>=0;x--)l=Cu(c,n,a={},e[3],v),l.static=d,l.private=h,u=l.access={has:m=>n in m},u.get=m=>m[n],o=(0,r[x])(w[g],l),a._=1,_l(o)&&(w[g]=o);return w&&bl(i,n,w),i},Sl=(e,t,n)=>t.has(e)||Pi("Cannot "+n),Iu=(e,t,n)=>(Sl(e,t,"read from private field"),t.get(e)),ju=(e,t,n)=>t.has(e)?Pi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Au=(e,t,n,r)=>(Sl(e,t,"write to private field"),t.set(e,n),n),Ze=class bs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new bs(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 bs(t,n)}},dt=class jt{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 jt(i+t,r+n,s,o);return l.scale=Du({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new Ze((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof jt))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 jt?Ru(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 jt(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],l=o==="x"?s.left:s.top,u=o==="x"?s.width:s.height;return a=="start"?l:a=="end"?l+u:l+u/2};return Ze.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return jt.from(t).intersectionRatio(jt.from(n))}};function Ru(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 $l,El,xs,Xr,Er,Mi=class extends(xs=Kt,El=[pe],$l=[pe],xs){constructor(t){const n=Ze.from(t);super(n,(r,i)=>Ze.equals(r,i)),Mu(Er,5,this),ju(this,Xr,0),this.velocity={x:0,y:0}}get delta(){return Ze.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Ze.from(t),i={x:r.x-n.x,y:r.y-n.y},s=Date.now(),o=s-Iu(this,Xr),a=l=>Math.round(l/o*100);de(()=>{Au(this,Xr,s),this.velocity={x:a(i.x),y:a(i.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Ze.from(t)),this.velocity={x:0,y:0}}};Er=Tu(xs);Xr=new WeakMap;kl(Er,2,"delta",El,Mi);kl(Er,2,"direction",$l,Mi);Pu(Er,Mi);function ws({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(ua(r,2)+ua(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 Ol=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ol||{}),Dl=Object.values(Ol),Lu=Object.create,oo=Object.defineProperty,Wu=Object.defineProperties,zu=Object.getOwnPropertyDescriptor,Fu=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,Tl=Object.prototype.hasOwnProperty,Cl=Object.prototype.propertyIsEnumerable,Pl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Cn=e=>{throw TypeError(e)},_s=(e,t,n)=>t in e?oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ao=(e,t)=>{for(var n in t||(t={}))Tl.call(t,n)&&_s(e,n,t[n]);if(hi)for(var n of hi(t))Cl.call(t,n)&&_s(e,n,t[n]);return e},lo=(e,t)=>Wu(e,Fu(t)),fa=(e,t)=>oo(e,"name",{value:t,configurable:!0}),Ml=(e,t)=>{var n={};for(var r in e)Tl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&hi)for(var r of hi(e))t.indexOf(r)<0&&Cl.call(e,r)&&(n[r]=e[r]);return n},Pn=e=>{var t;return[,,,Lu((t=e?.[Pl("metadata")])!=null?t:null)]},Il=["class","method","getter","setter","accessor","field","value","get","set"],Kn=e=>e!==void 0&&typeof e!="function"?Cn("Function expected"):e,Nu=(e,t,n,r,i)=>({kind:Il[e],name:t,metadata:r,addInitializer:s=>n._?Cn("Already initialized"):i.push(Kn(s||null))}),Yt=(e,t)=>_s(t,Pl("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},q=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,h=!!(t&8),f=!!(t&16),g=d>3?e.length+1:d?h?1:2:0,v=Il[d+5],w=d>3&&(e[g-1]=[]),x=e[g]||(e[g]=[]),m=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&zu(d<4?i:{get[n](){return he(this,s)},set[n](b){return qe(this,s,b)}},n));d?f&&d<4&&fa(s,(d>2?"set ":d>1?"get ":"")+n):fa(i,n);for(var p=r.length-1;p>=0;p--)u=Nu(d,n,l={},e[3],x),d&&(u.static=h,u.private=f,c=u.access={has:f?b=>Bu(i,b):b=>n in b},d^3&&(c.get=f?b=>(d^1?he:jl)(b,i,d^4?s:m.get):b=>b[n]),d>2&&(c.set=f?(b,_)=>qe(b,i,_,d^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[p])(d?d<4?f?s:m[v]:d>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,d^4||a===void 0?Kn(a)&&(d>4?w.unshift(a):d?f?s=a:m[v]=a:i=a):typeof a!="object"||a===null?Cn("Object expected"):(Kn(o=a.get)&&(m.get=o),Kn(o=a.set)&&(m.set=o),Kn(o=a.init)&&w.unshift(o));return d||Yt(e,i),m&&oo(i,n,m),f?d^4?s:m:i},co=(e,t,n)=>t.has(e)||Cn("Cannot "+n),Bu=(e,t)=>Object(t)!==t?Cn('Cannot use the "in" operator on this value'):e.has(t),he=(e,t,n)=>(co(e,t,"read from private field"),n?n.call(e):t.get(e)),J=(e,t,n)=>t.has(e)?Cn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,r)=>(co(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),jl=(e,t,n)=>(co(e,t,"access private method"),n);function Al(e,t){return{plugin:e,options:t}}function Or(e){return t=>Al(e,t)}function gr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Rl,vr,uo,Qr;Rl=[H];var Pe=class{constructor(e,t){this.manager=e,this.options=t,J(this,uo,N(vr,8,this,!1)),N(vr,11,this),J(this,Qr,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return U(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=tt(e.bind(this));return he(this,Qr).add(t),t}destroy(){he(this,Qr).forEach(e=>e())}static configure(e){return Al(this,e)}};vr=Pn(null);uo=new WeakMap;Qr=new WeakMap;q(vr,4,"disabled",Rl,Pe,uo);Yt(vr,Pe);var Dr=class extends Pe{},Zr,Qi=class{constructor(e){this.manager=e,this.instances=new Map,J(this,Zr,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(gr).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 he(this,Zr))if(!n.includes(r)){if(r.prototype instanceof Dr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);qe(this,Zr,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()}};Zr=new WeakMap;function Vu(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Wr=[],an,ln,Gu=class extends Pe{constructor(e){super(e),J(this,an),J(this,ln),this.computeCollisions=this.computeCollisions.bind(this),qe(this,ln,En(Wr)),this.destroy=$r(()=>{const t=this.computeCollisions(),n=U(()=>this.manager.dragOperation.position.current);if(t!==Wr){const r=he(this,an);if(qe(this,an,n),r&&n.x==r.x&&n.y==r.y)return}else qe(this,an,void 0);he(this,ln).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){U(()=>{e?he(this,ln).value=this.computeCollisions():qe(this,an,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Wr;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=U(()=>c({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return l.length===0?Wr:(a.sort(Vu),a)}get collisions(){return he(this,ln).value}};an=new WeakMap;ln=new WeakMap;var Ll,Wl,zl,fo,Fl,it,ho,pn,po,go;zl=[H],Wl=[H],Ll=[H];var yt=class At{constructor(t,n){J(this,ho,N(it,8,this)),N(it,11,this),J(this,pn),J(this,po,N(it,12,this)),N(it,15,this),J(this,go,N(it,16,this)),N(it,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let l=i;qe(this,pn,En(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=he(this,pn).value;return(n=(t=At.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=At.pendingIdChanges)==null?void 0:n.get(this))!=null?r:he(this,pn).peek();t!==i&&(At.pendingIdChanges||(At.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return jl(s=At,fo,Fl).call(s)})),At.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)}};it=Pn(null);fo=new WeakSet;Fl=function(){const e=yt.pendingIdChanges;yt.pendingIdChanges=null,e&&de(()=>{for(const[t,n]of e)he(t,pn).value=n})};ho=new WeakMap;pn=new WeakMap;po=new WeakMap;go=new WeakMap;q(it,4,"manager",zl,yt,ho);q(it,4,"data",Wl,yt,po);q(it,4,"disabled",Ll,yt,go);J(yt,fo);Yt(it,yt);yt.pendingIdChanges=null;var Ii=yt,ha=class{constructor(){this.map=En(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;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),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=$r(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),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){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Nl,Bl,Vl,Gl,Ul,Hl,ks,je,vo,mo,yo,ut=class extends(ks=Ii,Hl=[H],Ul=[H],Gl=[H],Vl=[pe],Bl=[pe],Nl=[pe],ks){constructor(t,n){var r=t,{modifiers:i,type:s,sensors:o,plugins:a,effects:l}=r,u=Ml(r,["modifiers","type","sensors","plugins","effects"]);super(lo(ao({},u),{effects:()=>{var c;return[...(c=l?.())!=null?c:[],()=>{const{manager:d,plugins:h}=this;if(!(!d||!h))for(const f of h){const{plugin:g}=gr(f);d.registry.plugins.register(g)}}]}}),n),N(je,5,this),J(this,vo,N(je,8,this)),N(je,11,this),J(this,mo,N(je,12,this)),N(je,15,this),J(this,yo,N(je,16,this,this.isDragSource?"dragging":"idle")),N(je,19,this),this.type=s,this.sensors=o,this.modifiers=i,this.alignment=u.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=gr(n);if(r.plugin===t)return r.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};je=Pn(ks);vo=new WeakMap;mo=new WeakMap;yo=new WeakMap;q(je,4,"type",Hl,ut,vo);q(je,4,"modifiers",Ul,ut,mo);q(je,4,"status",Gl,ut,yo);q(je,2,"isDropping",Vl,ut);q(je,2,"isDragging",Bl,ut);q(je,2,"isDragSource",Nl,ut);Yt(je,ut);var ql,Kl,Yl,Xl,Ql,Zl,Ss,xe,bo,xo,wo,_o,ko,ft=class extends(Ss=Ii,Zl=[H],Ql=[H],Xl=[H],Yl=[H],Kl=[H],ql=[pe],Ss){constructor(t,n){var r=t,{accept:i,collisionDetector:s,collisionPriority:o,type:a}=r,l=Ml(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),N(xe,5,this),J(this,bo,N(xe,8,this)),N(xe,11,this),J(this,xo,N(xe,12,this)),N(xe,15,this),J(this,wo,N(xe,16,this)),N(xe,19,this),J(this,_o,N(xe,20,this)),N(xe,23,this),J(this,ko,N(xe,24,this)),N(xe,27,this),this.accept=i,this.collisionDetector=s,this.collisionPriority=o,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};xe=Pn(Ss);bo=new WeakMap;xo=new WeakMap;wo=new WeakMap;_o=new WeakMap;ko=new WeakMap;q(xe,4,"accept",Zl,ft,bo);q(xe,4,"type",Ql,ft,xo);q(xe,4,"collisionDetector",Xl,ft,wo);q(xe,4,"collisionPriority",Yl,ft,_o);q(xe,4,"shape",Kl,ft,ko);q(xe,2,"isDropTarget",ql,ft);Yt(xe,ft);var Uu=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)}},Hu=class extends Uu{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Jr(e,t=!0){let n=!1;return lo(ao({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var qu=class extends Dr{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=$r(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||Ii.pendingIdChanges)return;const o=Jr({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;U(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Mn=(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))(Mn||{}),In=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(In||{}),Jl,ec,tc,nc,rc,ic,sc,et,So;sc=[H],ic=[pe],rc=[pe],nc=[pe],tc=[pe],ec=[pe],Jl=[pe];var bt=class{constructor(){N(et,5,this),J(this,So,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=Pn(null);So=new WeakMap;q(et,4,"value",sc,bt,So);q(et,2,"current",ic,bt);q(et,2,"idle",rc,bt);q(et,2,"initializing",nc,bt);q(et,2,"initialized",tc,bt);q(et,2,"dragging",ec,bt);q(et,2,"dropped",Jl,bt);Yt(et,bt);var Ku=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 U(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Jr({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return U(()=>{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 r=new AbortController,{event:i,coordinates:s}=e;de(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=i??null,t.position.reset(s)});const o=Jr({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:a}=t;a.current==="initializing"&&de(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:i,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return U(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Jr({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 h=(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=h})})}stop(e={}){return U(()=>{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=U(()=>{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=tt(()=>{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()})}},bn=class extends Pe{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Yu=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)}},ei,oc=class{constructor(e){this.options=e,J(this,ei)}set controller(e){qe(this,ei,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=he(this,ei))==null||t.activate(e)}};ei=new WeakMap;var pa=class extends Pe{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Xu=class{constructor(e){this.draggables=new ha,this.droppables=new ha,this.plugins=new Qi(e),this.sensors=new Qi(e),this.modifiers=new Qi(e)}register(e,t){if(e instanceof ut)return this.draggables.register(e.id,e);if(e instanceof ft)return this.droppables.register(e.id,e);if(e.prototype instanceof pa)return this.modifiers.register(e,t);if(e.prototype instanceof bn)return this.sensors.register(e,t);if(e.prototype instanceof Pe)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Ii)return e instanceof ut?this.draggables.unregister(e.id,e):e instanceof ft?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof pa)return this.modifiers.unregister(e);if(e.prototype instanceof bn)return this.sensors.unregister(e);if(e.prototype instanceof Pe)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},ac,lc,cc,dc,uc,fc,hc,pc,gc,Yn,ti,cn,le,$o,Eo,Oo,Do,To,Xn;gc=[pe],pc=[H],hc=[H],fc=[H],uc=[H],dc=[H],cc=[pe],lc=[pe],ac=[pe];var ot=class{constructor(e){N(le,5,this),J(this,Yn),J(this,ti),J(this,cn,new Kt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new bt,J(this,$o,N(le,8,this,!1)),N(le,11,this),J(this,Eo,N(le,12,this,null)),N(le,15,this),J(this,Oo,N(le,16,this,null)),N(le,19,this),J(this,Do,N(le,20,this,null)),N(le,23,this),J(this,To,N(le,24,this,[])),N(le,27,this),this.position=new Mi({x:0,y:0}),J(this,Xn,{x:0,y:0}),qe(this,Yn,e)}get shape(){const{current:e,initial:t,previous:n}=he(this,cn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?he(this,cn).current=e:he(this,cn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=he(this,Yn).registry.draggables.get(t);return n&&qe(this,ti,n),(e=n??he(this,ti))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=he(this,Yn).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(lo(ao({},this.snapshot()),{transform:n}));return qe(this,Xn,n),n}snapshot(){return U(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:he(this,Xn),shape:this.shape?Xi(this.shape):null,position:Xi(this.position),status:Xi(this.status),canceled:this.canceled}))}reset(){de(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,he(this,cn).reset(),this.position.reset({x:0,y:0}),qe(this,Xn,{x:0,y:0}),this.modifiers=[]})}};le=Pn(null);Yn=new WeakMap;ti=new WeakMap;cn=new WeakMap;$o=new WeakMap;Eo=new WeakMap;Oo=new WeakMap;Do=new WeakMap;To=new WeakMap;Xn=new WeakMap;q(le,2,"shape",gc,ot);q(le,4,"canceled",pc,ot,$o);q(le,4,"activatorEvent",hc,ot,Eo);q(le,4,"sourceIdentifier",fc,ot,Oo);q(le,4,"targetIdentifier",uc,ot,Do);q(le,4,"modifiers",dc,ot,To);q(le,2,"source",cc,ot);q(le,2,"target",lc,ot);q(le,2,"transform",ac,ot);Yt(le,ot);var Qu={get rendering(){return Promise.resolve()}};function st(e,t){return typeof e=="function"?e(t):e??t}var Zu=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(h=>h.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},i=st(r.plugins,[]),s=st(r.sensors,[]),o=st(r.modifiers,[]),a=(n=r.renderer)!=null?n:Qu,l=new Hu(this),u=new Xu(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new Ku(this),this.dragOperation=new ot(this),this.collisionObserver=new Gu(this),this.plugins=[qu,...i],this.modifiers=o,this.sensors=s;const{destroy:c}=this,d=$r(()=>{var h,f,g;const v=U(()=>this.dragOperation.modifiers),w=this.modifiers;for(const x of v)w.includes(x)||x.destroy();this.dragOperation.modifiers=(g=(f=(h=this.dragOperation.source)==null?void 0:h.modifiers)==null?void 0:f.map(x=>{const{plugin:m,options:p}=gr(x);return new m(this,p)}))!=null?g:w});this.destroy=()=>{d(),c()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},vc=e=>{throw TypeError(e)},Co=(e,t,n)=>t.has(e)||vc("Cannot "+n),F=(e,t,n)=>(Co(e,t,"read from private field"),t.get(e)),Ne=(e,t,n)=>t.has(e)?vc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),He=(e,t,n,r)=>(Co(e,t,"write to private field"),t.set(e,n),n),mc=(e,t,n)=>(Co(e,t,"access private method"),n);function ji(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function yc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,a=(ji(s)?s.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],i])}return r}function Ai(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 Po(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Tr(e){return"nodeType"in e}function Ke(e){var t,n,r;return e?Po(e)?e:Tr(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 Mo(e){const{Document:t}=Ke(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Dt(e){return!e||Po(e)?!1:e instanceof Ke(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function bc(e){return e instanceof Ke(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function jn(e){return e?Po(e)?e.document:Tr(e)?Mo(e)?e:Dt(e)||bc(e)?e.ownerDocument:document:document:document}function Ju(e){var t,n,r,i;const{documentElement:s}=jn(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 ef(e,t){if(tf(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function tf(e){return e.tagName==="DETAILS"}function mr(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(!ef(d)){const p=d.getBoundingClientRect(),b=n*(p.bottom-p.top),_=n*(p.right-p.left),$=n*(p.bottom-p.top),O=n*(p.right-p.left);l={top:Math.max(l.top,p.top-b),right:Math.min(l.right,p.right+_),bottom:Math.min(l.bottom,p.bottom+$),left:Math.max(l.left,p.left-O),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}d=d.parentElement}const h=c.visualViewport,f=(i=h?.offsetTop)!=null?i:0,g=(s=h?.offsetLeft)!=null?s:0,v=(o=h?.width)!=null?o:c.innerWidth,w=(a=h?.height)!=null?a:c.innerHeight,x=n*w,m=n*v;return l={top:Math.max(l.top,f-x),right:Math.min(l.right,g+v+m),bottom:Math.min(l.bottom,f+w+x),left:Math.max(l.left,g-m),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 xn(e){return{x:e.clientX,y:e.clientY}}var xc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function $s(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const i=r.contentDocument;i&&!t.has(i)&&n.push(...$s(i,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const i=r.parent;i&&i.document&&i.document!==e&&n.push(...$s(i.document,t))}}catch{}return n}function Io(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function wc(){var e,t;const n=Io()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function jo(e){return!e||!Tr(e)?!1:e instanceof Ke(e).ShadowRoot}function pi(e){if(e&&Tr(e)){let t=e.getRootNode();if(jo(t))return t;if(t instanceof Document)return t}return jn(e)}function Ao(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function nf(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((s,o)=>{const a=r[o];if(ga(s)&&ga(a)&&(s.type!=="file"&&(s.value=a.value),s.type==="radio"&&s.name&&(s.name=`Cloned__${s.name}`)),va(s)&&va(a)&&a.width>0&&a.height>0){const l=s.getContext("2d");l?.drawImage(a,0,0)}}),n}function ga(e){return"value"in e}function va(e){return e.tagName==="CANVAS"}function _c(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(rf(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return _c(i,{x:t-s,y:n-o})}}return r}function rf(e){return e?.tagName==="IFRAME"}var Es=new WeakMap;function sf(e){return e.closest(`
1
+ "use strict";var eu=Object.create;var sa=Object.defineProperty;var tu=Object.getOwnPropertyDescriptor;var nu=Object.getOwnPropertyNames;var ru=Object.getPrototypeOf,iu=Object.prototype.hasOwnProperty;var su=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of nu(t))!iu.call(e,i)&&i!==n&&sa(e,i,{get:()=>t[i],enumerable:!(r=tu(t,i))||r.enumerable});return e};var oa=(e,t,n)=>(n=e!=null?eu(ru(e)):{},su(t||!e||!e.__esModule?sa(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),S=require("react"),ou=require("react-dom"),k=require("@mui/material"),j=require("../DocumentStorage-D7yF4_T3.cjs.js"),Be=require("../ServerProvider-CuYLH_Yi.cjs.js"),au=require("@tanstack/react-query");var lu=Symbol.for("preact-signals");function Ci(){if(vt>1)vt--;else{var e,t=!1;for((function(){var i=ui;for(ui=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}})();cr!==void 0;){var n=cr;for(cr=void 0,di++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ol(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(di=0,vt--,t)throw e}}function ue(e){if(vt>0)return e();ds=++cu,vt++;try{return e()}finally{Ci()}}var lr,ie=void 0;function U(e){var t=ie,n=lr;ie=void 0,lr=void 0;try{return e()}finally{ie=t,lr=n}}var cr=void 0,vt=0,di=0,cu=0,ds=0,ui=void 0,fi=0;function sl(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 Re(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}Re.prototype.brand=lu;Re.prototype.h=function(){return!0};Re.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:U(function(){var r;(r=t.W)==null||r.call(t)}))};Re.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&&U(function(){var i;(i=t.Z)==null||i.call(t)}))}};Re.prototype.subscribe=function(e){var t=this;return tt(function(){var n=t.value;U(function(){return e(n)})},{name:"sub"})};Re.prototype.valueOf=function(){return this.value};Re.prototype.toString=function(){return this.value+""};Re.prototype.toJSON=function(){return this.value};Re.prototype.peek=function(){var e=this;return U(function(){return e.value})};Object.defineProperty(Re.prototype,"value",{get:function(){var e=sl(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(di>100)throw new Error("Cycle detected");(function(n){vt!==0&&di===0&&n.l!==ds&&(n.l=ds,ui={S:n,v:n.v,i:n.i,o:ui})})(this),this.v=e,this.i++,fi++,vt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Ci()}}}});function En(e,t){return new Re(e,t)}function ol(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 al(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 ll(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 qt(e,t){Re.call(this,void 0,t),this.x=e,this.s=void 0,this.g=fi-1,this.f=4}qt.prototype=new Re;qt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===fi))return!0;if(this.g=fi,this.f|=1,this.i>0&&!ol(this))return this.f&=-2,!0;var e=ie;try{al(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,ll(this),this.f&=-2,!0};qt.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)}Re.prototype.S.call(this,e)};qt.prototype.U=function(e){if(this.t!==void 0&&(Re.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)}};qt.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(qt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=sl(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function aa(e,t){return new qt(e,t)}function cl(e){var t=e.m;if(e.m=void 0,typeof t=="function"){vt++;var n=ie;ie=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,eo(e),r}finally{ie=n,Ci()}}}function eo(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,cl(e)}function du(e){if(ie!==this)throw new Error("Out-of-order effect");ll(this),ie=e,this.f&=-2,8&this.f&&eo(this),Ci()}function On(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,lr&&lr.push(this)}On.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()}};On.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,cl(this),al(this),vt++;var e=ie;return ie=this,du.bind(this,e)};On.prototype.N=function(){2&this.f||(this.f|=2,this.u=cr,cr=this)};On.prototype.d=function(){this.f|=8,1&this.f||eo(this)};On.prototype.dispose=function(){this.d()};function tt(e,t){var n=new On(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var uu=Object.create,to=Object.defineProperty,fu=Object.defineProperties,hu=Object.getOwnPropertyDescriptor,pu=Object.getOwnPropertyDescriptors,la=Object.getOwnPropertySymbols,gu=Object.prototype.hasOwnProperty,vu=Object.prototype.propertyIsEnumerable,mu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Dn=e=>{throw TypeError(e)},us=(e,t,n)=>t in e?to(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yu=(e,t)=>{for(var n in t||(t={}))gu.call(t,n)&&us(e,n,t[n]);if(la)for(var n of la(t))vu.call(t,n)&&us(e,n,t[n]);return e},bu=(e,t)=>fu(e,pu(t)),ca=(e,t)=>to(e,"name",{value:t,configurable:!0}),xu=e=>{var t;return[,,,uu((t=void 0)!=null?t:null)]},dl=["class","method","getter","setter","accessor","field","value","get","set"],Hn=e=>e!==void 0&&typeof e!="function"?Dn("Function expected"):e,wu=(e,t,n,r,i)=>({kind:dl[e],name:t,metadata:r,addInitializer:s=>n._?Dn("Already initialized"):i.push(Hn(s||null))}),ul=(e,t)=>us(t,mu("metadata"),e[3]),Mt=(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},Tn=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,h=!!(t&8),f=!!(t&16),g=d>3?e.length+1:d?h?1:2:0,v=dl[d+5],w=d>3&&(e[g-1]=[]),x=e[g]||(e[g]=[]),m=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&hu(d<4?i:{get[n](){return Qe(this,s)},set[n](b){return kt(this,s,b)}},n));d?f&&d<4&&ca(s,(d>2?"set ":d>1?"get ":"")+n):ca(i,n);for(var p=r.length-1;p>=0;p--)u=wu(d,n,l={},e[3],x),d&&(u.static=h,u.private=f,c=u.access={has:f?b=>_u(i,b):b=>n in b},d^3&&(c.get=f?b=>(d^1?Qe:ku)(b,i,d^4?s:m.get):b=>b[n]),d>2&&(c.set=f?(b,_)=>kt(b,i,_,d^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[p])(d?d<4?f?s:m[v]:d>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,d^4||a===void 0?Hn(a)&&(d>4?w.unshift(a):d?f?s=a:m[v]=a:i=a):typeof a!="object"||a===null?Dn("Object expected"):(Hn(o=a.get)&&(m.get=o),Hn(o=a.set)&&(m.set=o),Hn(o=a.init)&&w.unshift(o));return d||ul(e,i),m&&to(i,n,m),f?d^4?s:m:i},no=(e,t,n)=>t.has(e)||Dn("Cannot "+n),_u=(e,t)=>Object(t)!==t?Dn('Cannot use the "in" operator on this value'):e.has(t),Qe=(e,t,n)=>(no(e,t,"read from private field"),n?n.call(e):t.get(e)),qn=(e,t,n)=>t.has(e)?Dn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),kt=(e,t,n,r)=>(no(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ku=(e,t,n)=>(no(e,t,"access private method"),n);function fs(e,t){if(t){let n;return aa(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return aa(e)}function rt(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((r,i)=>!rt(r,t[i]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(s=>!rt(e[s],t[s]))}return!1}function H({get:e},t){return{init(n){return En(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function ge(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=fs(e.bind(this)),n.set(this,r)),r.value}}function Hi(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,bu(yu({},i),{enumerable:e}))})}}function $r(...e){const t=e.map(n=>tt(n));return()=>t.forEach(n=>n())}var fl,hl,pl,gl,vl,ml,Ie,ro,qi,hs,ps,Pe,io,Ki,yl,gs,so,Yi,vs,ms;ml=[H],vl=[H],gl=[H],pl=[Hi()],hl=[Hi()],fl=[Hi()];var Kt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Mt(Ie,5,this),qn(this,Pe),qn(this,ro,Mt(Ie,8,this)),Mt(Ie,11,this),qn(this,io,Mt(Ie,12,this)),Mt(Ie,15,this),qn(this,so,Mt(Ie,16,this)),Mt(Ie,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Qe(this,Pe,vs)}get initial(){return Qe(this,Pe,hs)}get previous(){return Qe(this,Pe,yl)}set current(e){const t=U(()=>Qe(this,Pe,vs));e&&t&&this.equals(t,e)||ue(()=>{Qe(this,Pe,hs)||kt(this,Pe,e,ps),kt(this,Pe,t,gs),kt(this,Pe,e,ms)})}reset(e=this.defaultValue){ue(()=>{kt(this,Pe,void 0,gs),kt(this,Pe,e,ps),kt(this,Pe,e,ms)})}};Ie=xu();ro=new WeakMap;Pe=new WeakSet;io=new WeakMap;so=new WeakMap;qi=Tn(Ie,20,"#initial",ml,Pe,ro),hs=qi.get,ps=qi.set;Ki=Tn(Ie,20,"#previous",vl,Pe,io),yl=Ki.get,gs=Ki.set;Yi=Tn(Ie,20,"#current",gl,Pe,so),vs=Yi.get,ms=Yi.set;Tn(Ie,2,"current",pl,Kt);Tn(Ie,2,"initial",hl,Kt);Tn(Ie,2,"previous",fl,Kt);ul(Ie,Kt);function Xi(e){return U(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var It,Su=class{constructor(){qn(this,It,new WeakMap)}get(e,t){var n;return e?(n=Qe(this,It).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Qe(this,It).has(e)||Qe(this,It).set(e,new Map),(r=Qe(this,It).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Qe(this,It).get(e))==null?void 0:t.clear():void 0}};It=new WeakMap;var $u=Object.create,bl=Object.defineProperty,Eu=Object.getOwnPropertyDescriptor,da=Object.getOwnPropertySymbols,Ou=Object.prototype.hasOwnProperty,Du=Object.prototype.propertyIsEnumerable,xl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Pi=e=>{throw TypeError(e)},ua=Math.pow,ys=(e,t,n)=>t in e?bl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tu=(e,t)=>{for(var n in t||(t={}))Ou.call(t,n)&&ys(e,n,t[n]);if(da)for(var n of da(t))Du.call(t,n)&&ys(e,n,t[n]);return e},Cu=e=>{var t;return[,,,$u((t=e?.[xl("metadata")])!=null?t:null)]},wl=["class","method","getter","setter","accessor","field","value","get","set"],_l=e=>e!==void 0&&typeof e!="function"?Pi("Function expected"):e,Pu=(e,t,n,r,i)=>({kind:wl[e],name:t,metadata:r,addInitializer:s=>n._?Pi("Already initialized"):i.push(_l(s||null))}),Mu=(e,t)=>ys(t,xl("metadata"),e[3]),Iu=(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},kl=(e,t,n,r,i,s)=>{for(var o,a,l,u,c=t&7,d=!1,h=!1,f=2,g=wl[c+5],v=e[f]||(e[f]=[]),w=(i=i.prototype,Eu(i,n)),x=r.length-1;x>=0;x--)l=Pu(c,n,a={},e[3],v),l.static=d,l.private=h,u=l.access={has:m=>n in m},u.get=m=>m[n],o=(0,r[x])(w[g],l),a._=1,_l(o)&&(w[g]=o);return w&&bl(i,n,w),i},Sl=(e,t,n)=>t.has(e)||Pi("Cannot "+n),ju=(e,t,n)=>(Sl(e,t,"read from private field"),t.get(e)),Au=(e,t,n)=>t.has(e)?Pi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ru=(e,t,n,r)=>(Sl(e,t,"write to private field"),t.set(e,n),n),Ze=class bs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new bs(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 bs(t,n)}},dt=class jt{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 jt(i+t,r+n,s,o);return l.scale=Tu({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new Ze((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof jt))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 jt?Lu(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 jt(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],l=o==="x"?s.left:s.top,u=o==="x"?s.width:s.height;return a=="start"?l:a=="end"?l+u:l+u/2};return Ze.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return jt.from(t).intersectionRatio(jt.from(n))}};function Lu(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 $l,El,xs,Xr,Er,Mi=class extends(xs=Kt,El=[ge],$l=[ge],xs){constructor(t){const n=Ze.from(t);super(n,(r,i)=>Ze.equals(r,i)),Iu(Er,5,this),Au(this,Xr,0),this.velocity={x:0,y:0}}get delta(){return Ze.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Ze.from(t),i={x:r.x-n.x,y:r.y-n.y},s=Date.now(),o=s-ju(this,Xr),a=l=>Math.round(l/o*100);ue(()=>{Ru(this,Xr,s),this.velocity={x:a(i.x),y:a(i.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Ze.from(t)),this.velocity={x:0,y:0}}};Er=Cu(xs);Xr=new WeakMap;kl(Er,2,"delta",El,Mi);kl(Er,2,"direction",$l,Mi);Mu(Er,Mi);function ws({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(ua(r,2)+ua(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 Ol=(e=>(e.Horizontal="x",e.Vertical="y",e))(Ol||{}),Dl=Object.values(Ol),Wu=Object.create,oo=Object.defineProperty,zu=Object.defineProperties,Fu=Object.getOwnPropertyDescriptor,Nu=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,Tl=Object.prototype.hasOwnProperty,Cl=Object.prototype.propertyIsEnumerable,Pl=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Cn=e=>{throw TypeError(e)},_s=(e,t,n)=>t in e?oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ao=(e,t)=>{for(var n in t||(t={}))Tl.call(t,n)&&_s(e,n,t[n]);if(hi)for(var n of hi(t))Cl.call(t,n)&&_s(e,n,t[n]);return e},lo=(e,t)=>zu(e,Nu(t)),fa=(e,t)=>oo(e,"name",{value:t,configurable:!0}),Ml=(e,t)=>{var n={};for(var r in e)Tl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&hi)for(var r of hi(e))t.indexOf(r)<0&&Cl.call(e,r)&&(n[r]=e[r]);return n},Pn=e=>{var t;return[,,,Wu((t=e?.[Pl("metadata")])!=null?t:null)]},Il=["class","method","getter","setter","accessor","field","value","get","set"],Kn=e=>e!==void 0&&typeof e!="function"?Cn("Function expected"):e,Bu=(e,t,n,r,i)=>({kind:Il[e],name:t,metadata:r,addInitializer:s=>n._?Cn("Already initialized"):i.push(Kn(s||null))}),Yt=(e,t)=>_s(t,Pl("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},q=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,h=!!(t&8),f=!!(t&16),g=d>3?e.length+1:d?h?1:2:0,v=Il[d+5],w=d>3&&(e[g-1]=[]),x=e[g]||(e[g]=[]),m=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&Fu(d<4?i:{get[n](){return pe(this,s)},set[n](b){return qe(this,s,b)}},n));d?f&&d<4&&fa(s,(d>2?"set ":d>1?"get ":"")+n):fa(i,n);for(var p=r.length-1;p>=0;p--)u=Bu(d,n,l={},e[3],x),d&&(u.static=h,u.private=f,c=u.access={has:f?b=>Vu(i,b):b=>n in b},d^3&&(c.get=f?b=>(d^1?pe:jl)(b,i,d^4?s:m.get):b=>b[n]),d>2&&(c.set=f?(b,_)=>qe(b,i,_,d^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[p])(d?d<4?f?s:m[v]:d>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,d^4||a===void 0?Kn(a)&&(d>4?w.unshift(a):d?f?s=a:m[v]=a:i=a):typeof a!="object"||a===null?Cn("Object expected"):(Kn(o=a.get)&&(m.get=o),Kn(o=a.set)&&(m.set=o),Kn(o=a.init)&&w.unshift(o));return d||Yt(e,i),m&&oo(i,n,m),f?d^4?s:m:i},co=(e,t,n)=>t.has(e)||Cn("Cannot "+n),Vu=(e,t)=>Object(t)!==t?Cn('Cannot use the "in" operator on this value'):e.has(t),pe=(e,t,n)=>(co(e,t,"read from private field"),n?n.call(e):t.get(e)),J=(e,t,n)=>t.has(e)?Cn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,r)=>(co(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),jl=(e,t,n)=>(co(e,t,"access private method"),n);function Al(e,t){return{plugin:e,options:t}}function Or(e){return t=>Al(e,t)}function gr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Rl,vr,uo,Qr;Rl=[H];var Me=class{constructor(e,t){this.manager=e,this.options=t,J(this,uo,N(vr,8,this,!1)),N(vr,11,this),J(this,Qr,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return U(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=tt(e.bind(this));return pe(this,Qr).add(t),t}destroy(){pe(this,Qr).forEach(e=>e())}static configure(e){return Al(this,e)}};vr=Pn(null);uo=new WeakMap;Qr=new WeakMap;q(vr,4,"disabled",Rl,Me,uo);Yt(vr,Me);var Dr=class extends Me{},Zr,Qi=class{constructor(e){this.manager=e,this.instances=new Map,J(this,Zr,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(gr).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 pe(this,Zr))if(!n.includes(r)){if(r.prototype instanceof Dr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);qe(this,Zr,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()}};Zr=new WeakMap;function Gu(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Wr=[],an,ln,Uu=class extends Me{constructor(e){super(e),J(this,an),J(this,ln),this.computeCollisions=this.computeCollisions.bind(this),qe(this,ln,En(Wr)),this.destroy=$r(()=>{const t=this.computeCollisions(),n=U(()=>this.manager.dragOperation.position.current);if(t!==Wr){const r=pe(this,an);if(qe(this,an,n),r&&n.x==r.x&&n.y==r.y)return}else qe(this,an,void 0);pe(this,ln).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){U(()=>{e?pe(this,ln).value=this.computeCollisions():qe(this,an,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Wr;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=U(()=>c({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return l.length===0?Wr:(a.sort(Gu),a)}get collisions(){return pe(this,ln).value}};an=new WeakMap;ln=new WeakMap;var Ll,Wl,zl,fo,Fl,it,ho,pn,po,go;zl=[H],Wl=[H],Ll=[H];var yt=class At{constructor(t,n){J(this,ho,N(it,8,this)),N(it,11,this),J(this,pn),J(this,po,N(it,12,this)),N(it,15,this),J(this,go,N(it,16,this)),N(it,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let l=i;qe(this,pn,En(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=pe(this,pn).value;return(n=(t=At.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=At.pendingIdChanges)==null?void 0:n.get(this))!=null?r:pe(this,pn).peek();t!==i&&(At.pendingIdChanges||(At.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return jl(s=At,fo,Fl).call(s)})),At.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)}};it=Pn(null);fo=new WeakSet;Fl=function(){const e=yt.pendingIdChanges;yt.pendingIdChanges=null,e&&ue(()=>{for(const[t,n]of e)pe(t,pn).value=n})};ho=new WeakMap;pn=new WeakMap;po=new WeakMap;go=new WeakMap;q(it,4,"manager",zl,yt,ho);q(it,4,"data",Wl,yt,po);q(it,4,"disabled",Ll,yt,go);J(yt,fo);Yt(it,yt);yt.pendingIdChanges=null;var Ii=yt,ha=class{constructor(){this.map=En(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;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),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=$r(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),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){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Nl,Bl,Vl,Gl,Ul,Hl,ks,je,vo,mo,yo,ut=class extends(ks=Ii,Hl=[H],Ul=[H],Gl=[H],Vl=[ge],Bl=[ge],Nl=[ge],ks){constructor(t,n){var r=t,{modifiers:i,type:s,sensors:o,plugins:a,effects:l}=r,u=Ml(r,["modifiers","type","sensors","plugins","effects"]);super(lo(ao({},u),{effects:()=>{var c;return[...(c=l?.())!=null?c:[],()=>{const{manager:d,plugins:h}=this;if(!(!d||!h))for(const f of h){const{plugin:g}=gr(f);d.registry.plugins.register(g)}}]}}),n),N(je,5,this),J(this,vo,N(je,8,this)),N(je,11,this),J(this,mo,N(je,12,this)),N(je,15,this),J(this,yo,N(je,16,this,this.isDragSource?"dragging":"idle")),N(je,19,this),this.type=s,this.sensors=o,this.modifiers=i,this.alignment=u.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=gr(n);if(r.plugin===t)return r.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};je=Pn(ks);vo=new WeakMap;mo=new WeakMap;yo=new WeakMap;q(je,4,"type",Hl,ut,vo);q(je,4,"modifiers",Ul,ut,mo);q(je,4,"status",Gl,ut,yo);q(je,2,"isDropping",Vl,ut);q(je,2,"isDragging",Bl,ut);q(je,2,"isDragSource",Nl,ut);Yt(je,ut);var ql,Kl,Yl,Xl,Ql,Zl,Ss,xe,bo,xo,wo,_o,ko,ft=class extends(Ss=Ii,Zl=[H],Ql=[H],Xl=[H],Yl=[H],Kl=[H],ql=[ge],Ss){constructor(t,n){var r=t,{accept:i,collisionDetector:s,collisionPriority:o,type:a}=r,l=Ml(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),N(xe,5,this),J(this,bo,N(xe,8,this)),N(xe,11,this),J(this,xo,N(xe,12,this)),N(xe,15,this),J(this,wo,N(xe,16,this)),N(xe,19,this),J(this,_o,N(xe,20,this)),N(xe,23,this),J(this,ko,N(xe,24,this)),N(xe,27,this),this.accept=i,this.collisionDetector=s,this.collisionPriority=o,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};xe=Pn(Ss);bo=new WeakMap;xo=new WeakMap;wo=new WeakMap;_o=new WeakMap;ko=new WeakMap;q(xe,4,"accept",Zl,ft,bo);q(xe,4,"type",Ql,ft,xo);q(xe,4,"collisionDetector",Xl,ft,wo);q(xe,4,"collisionPriority",Yl,ft,_o);q(xe,4,"shape",Kl,ft,ko);q(xe,2,"isDropTarget",ql,ft);Yt(xe,ft);var Hu=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)}},qu=class extends Hu{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Jr(e,t=!0){let n=!1;return lo(ao({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Ku=class extends Dr{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=$r(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||Ii.pendingIdChanges)return;const o=Jr({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;U(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Mn=(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))(Mn||{}),In=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(In||{}),Jl,ec,tc,nc,rc,ic,sc,et,So;sc=[H],ic=[ge],rc=[ge],nc=[ge],tc=[ge],ec=[ge],Jl=[ge];var bt=class{constructor(){N(et,5,this),J(this,So,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=Pn(null);So=new WeakMap;q(et,4,"value",sc,bt,So);q(et,2,"current",ic,bt);q(et,2,"idle",rc,bt);q(et,2,"initializing",nc,bt);q(et,2,"initialized",tc,bt);q(et,2,"dragging",ec,bt);q(et,2,"dropped",Jl,bt);Yt(et,bt);var Yu=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 U(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Jr({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return U(()=>{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 r=new AbortController,{event:i,coordinates:s}=e;ue(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=i??null,t.position.reset(s)});const o=Jr({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:a}=t;a.current==="initializing"&&ue(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:i,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return U(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Jr({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 h=(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=h})})}stop(e={}){return U(()=>{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=U(()=>{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=tt(()=>{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()})}},bn=class extends Me{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Xu=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)}},ei,oc=class{constructor(e){this.options=e,J(this,ei)}set controller(e){qe(this,ei,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=pe(this,ei))==null||t.activate(e)}};ei=new WeakMap;var pa=class extends Me{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Qu=class{constructor(e){this.draggables=new ha,this.droppables=new ha,this.plugins=new Qi(e),this.sensors=new Qi(e),this.modifiers=new Qi(e)}register(e,t){if(e instanceof ut)return this.draggables.register(e.id,e);if(e instanceof ft)return this.droppables.register(e.id,e);if(e.prototype instanceof pa)return this.modifiers.register(e,t);if(e.prototype instanceof bn)return this.sensors.register(e,t);if(e.prototype instanceof Me)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Ii)return e instanceof ut?this.draggables.unregister(e.id,e):e instanceof ft?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof pa)return this.modifiers.unregister(e);if(e.prototype instanceof bn)return this.sensors.unregister(e);if(e.prototype instanceof Me)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()}},ac,lc,cc,dc,uc,fc,hc,pc,gc,Yn,ti,cn,ce,$o,Eo,Oo,Do,To,Xn;gc=[ge],pc=[H],hc=[H],fc=[H],uc=[H],dc=[H],cc=[ge],lc=[ge],ac=[ge];var ot=class{constructor(e){N(ce,5,this),J(this,Yn),J(this,ti),J(this,cn,new Kt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new bt,J(this,$o,N(ce,8,this,!1)),N(ce,11,this),J(this,Eo,N(ce,12,this,null)),N(ce,15,this),J(this,Oo,N(ce,16,this,null)),N(ce,19,this),J(this,Do,N(ce,20,this,null)),N(ce,23,this),J(this,To,N(ce,24,this,[])),N(ce,27,this),this.position=new Mi({x:0,y:0}),J(this,Xn,{x:0,y:0}),qe(this,Yn,e)}get shape(){const{current:e,initial:t,previous:n}=pe(this,cn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?pe(this,cn).current=e:pe(this,cn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=pe(this,Yn).registry.draggables.get(t);return n&&qe(this,ti,n),(e=n??pe(this,ti))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=pe(this,Yn).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(lo(ao({},this.snapshot()),{transform:n}));return qe(this,Xn,n),n}snapshot(){return U(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:pe(this,Xn),shape:this.shape?Xi(this.shape):null,position:Xi(this.position),status:Xi(this.status),canceled:this.canceled}))}reset(){ue(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,pe(this,cn).reset(),this.position.reset({x:0,y:0}),qe(this,Xn,{x:0,y:0}),this.modifiers=[]})}};ce=Pn(null);Yn=new WeakMap;ti=new WeakMap;cn=new WeakMap;$o=new WeakMap;Eo=new WeakMap;Oo=new WeakMap;Do=new WeakMap;To=new WeakMap;Xn=new WeakMap;q(ce,2,"shape",gc,ot);q(ce,4,"canceled",pc,ot,$o);q(ce,4,"activatorEvent",hc,ot,Eo);q(ce,4,"sourceIdentifier",fc,ot,Oo);q(ce,4,"targetIdentifier",uc,ot,Do);q(ce,4,"modifiers",dc,ot,To);q(ce,2,"source",cc,ot);q(ce,2,"target",lc,ot);q(ce,2,"transform",ac,ot);Yt(ce,ot);var Zu={get rendering(){return Promise.resolve()}};function st(e,t){return typeof e=="function"?e(t):e??t}var Ju=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(h=>h.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},i=st(r.plugins,[]),s=st(r.sensors,[]),o=st(r.modifiers,[]),a=(n=r.renderer)!=null?n:Zu,l=new qu(this),u=new Qu(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new Yu(this),this.dragOperation=new ot(this),this.collisionObserver=new Uu(this),this.plugins=[Ku,...i],this.modifiers=o,this.sensors=s;const{destroy:c}=this,d=$r(()=>{var h,f,g;const v=U(()=>this.dragOperation.modifiers),w=this.modifiers;for(const x of v)w.includes(x)||x.destroy();this.dragOperation.modifiers=(g=(f=(h=this.dragOperation.source)==null?void 0:h.modifiers)==null?void 0:f.map(x=>{const{plugin:m,options:p}=gr(x);return new m(this,p)}))!=null?g:w});this.destroy=()=>{d(),c()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},vc=e=>{throw TypeError(e)},Co=(e,t,n)=>t.has(e)||vc("Cannot "+n),F=(e,t,n)=>(Co(e,t,"read from private field"),t.get(e)),Ne=(e,t,n)=>t.has(e)?vc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),He=(e,t,n,r)=>(Co(e,t,"write to private field"),t.set(e,n),n),mc=(e,t,n)=>(Co(e,t,"access private method"),n);function ji(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function yc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,a=(ji(s)?s.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],i])}return r}function Ai(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 Po(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Tr(e){return"nodeType"in e}function Ke(e){var t,n,r;return e?Po(e)?e:Tr(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 Mo(e){const{Document:t}=Ke(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Dt(e){return!e||Po(e)?!1:e instanceof Ke(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function bc(e){return e instanceof Ke(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function jn(e){return e?Po(e)?e.document:Tr(e)?Mo(e)?e:Dt(e)||bc(e)?e.ownerDocument:document:document:document}function ef(e){var t,n,r,i;const{documentElement:s}=jn(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 tf(e,t){if(nf(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function nf(e){return e.tagName==="DETAILS"}function mr(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(!tf(d)){const p=d.getBoundingClientRect(),b=n*(p.bottom-p.top),_=n*(p.right-p.left),$=n*(p.bottom-p.top),O=n*(p.right-p.left);l={top:Math.max(l.top,p.top-b),right:Math.min(l.right,p.right+_),bottom:Math.min(l.bottom,p.bottom+$),left:Math.max(l.left,p.left-O),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}d=d.parentElement}const h=c.visualViewport,f=(i=h?.offsetTop)!=null?i:0,g=(s=h?.offsetLeft)!=null?s:0,v=(o=h?.width)!=null?o:c.innerWidth,w=(a=h?.height)!=null?a:c.innerHeight,x=n*w,m=n*v;return l={top:Math.max(l.top,f-x),right:Math.min(l.right,g+v+m),bottom:Math.min(l.bottom,f+w+x),left:Math.max(l.left,g-m),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 xn(e){return{x:e.clientX,y:e.clientY}}var xc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function $s(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const i=r.contentDocument;i&&!t.has(i)&&n.push(...$s(i,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const i=r.parent;i&&i.document&&i.document!==e&&n.push(...$s(i.document,t))}}catch{}return n}function Io(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function wc(){var e,t;const n=Io()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function jo(e){return!e||!Tr(e)?!1:e instanceof Ke(e).ShadowRoot}function pi(e){if(e&&Tr(e)){let t=e.getRootNode();if(jo(t))return t;if(t instanceof Document)return t}return jn(e)}function Ao(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function rf(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((s,o)=>{const a=r[o];if(ga(s)&&ga(a)&&(s.type!=="file"&&(s.value=a.value),s.type==="radio"&&s.name&&(s.name=`Cloned__${s.name}`)),va(s)&&va(a)&&a.width>0&&a.height>0){const l=s.getContext("2d");l?.drawImage(a,0,0)}}),n}function ga(e){return"value"in e}function va(e){return e.tagName==="CANVAS"}function _c(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(sf(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return _c(i,{x:t-s,y:n-o})}}return r}function sf(e){return e?.tagName==="IFRAME"}var Es=new WeakMap;function of(e){return e.closest(`
2
2
  input:not([disabled]),
3
3
  select:not([disabled]),
4
4
  textarea:not([disabled]),
5
5
  button:not([disabled]),
6
6
  a[href],
7
7
  [contenteditable]:not([contenteditable="false"])
8
- `)}var kc=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 a of i){const[l,{type:u,listener:c,options:d}]=a;l.removeEventListener(u,c,d),s.delete(a)}}}};function wn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function of(e){const t=new Set;let n=wn(e);for(;n;)t.add(n),n=wn(n);return t}function af(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Sc(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=af(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function lf(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 cf(e,t=e.getBoundingClientRect()){const{width:n,height:r}=mr(e,t);return n>0&&r>0}var df=xc?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ni,uf=class extends df{constructor(e){super(t=>{if(!F(this,ni)){He(this,ni,!0);return}e(t,this)}),Ne(this,ni,!1)}};ni=new WeakMap;var ma=Array.from({length:100},(e,t)=>t/100),$c=75,Rt,gi,wt,Lt,Qn,De,dr,Zn,vi,Ec,Oc,Dc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ne(this,vi),this.disconnect=()=>{var s,o,a;He(this,dr,!0),(s=F(this,wt))==null||s.disconnect(),(o=F(this,Lt))==null||o.disconnect(),F(this,Qn).disconnect(),(a=F(this,De))==null||a.remove()},Ne(this,Rt,!0),Ne(this,gi),Ne(this,wt),Ne(this,Lt),Ne(this,Qn),Ne(this,De),Ne(this,dr,!1),Ne(this,Zn,Sc(()=>{var s,o,a;const{element:l}=this;if((s=F(this,Lt))==null||s.disconnect(),F(this,dr)||!F(this,Rt)||!l.isConnected)return;const u=(o=l.ownerDocument)!=null?o:document,{innerHeight:c,innerWidth:d}=(a=u.defaultView)!=null?a:window,h=l.getBoundingClientRect(),f=mr(l,h),{top:g,left:v,bottom:w,right:x}=f,m=-Math.floor(g),p=-Math.floor(v),b=-Math.floor(d-x),_=-Math.floor(c-w),$=`${m}px ${b}px ${_}px ${p}px`;this.boundingClientRect=h,He(this,Lt,new IntersectionObserver(O=>{const[D]=O,{intersectionRect:M}=D;(D.intersectionRatio!==1?D.intersectionRatio:dt.intersectionRatio(M,mr(l)))!==1&&F(this,Zn).call(this)},{threshold:ma,rootMargin:$,root:u})),F(this,Lt).observe(l),mc(this,vi,Ec).call(this)},$c)),this.boundingClientRect=e.getBoundingClientRect(),He(this,Rt,cf(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(He(this,De,document.createElement("div")),F(this,De).style.background="rgba(0,0,0,0.15)",F(this,De).style.position="fixed",F(this,De).style.pointerEvents="none",i.body.appendChild(F(this,De))),He(this,Qn,new IntersectionObserver(s=>{var o,a;const l=s[s.length-1],{boundingClientRect:u,isIntersecting:c}=l,{width:d,height:h}=u,f=F(this,Rt);He(this,Rt,c),!(!d&&!h)&&(f&&!c?((o=F(this,Lt))==null||o.disconnect(),this.callback(null),(a=F(this,wt))==null||a.disconnect(),He(this,wt,void 0),F(this,De)&&(F(this,De).style.visibility="hidden")):F(this,Zn).call(this),c&&!F(this,wt)&&(He(this,wt,new uf(F(this,Zn))),F(this,wt).observe(e)))},{threshold:ma,root:i})),F(this,Rt)&&!n.skipInitial&&this.callback(this.boundingClientRect),F(this,Qn).observe(e)}};Rt=new WeakMap;gi=new WeakMap;wt=new WeakMap;Lt=new WeakMap;Qn=new WeakMap;De=new WeakMap;dr=new WeakMap;Zn=new WeakMap;vi=new WeakSet;Ec=function(){F(this,dr)||(mc(this,vi,Oc).call(this),!lf(this.boundingClientRect,F(this,gi))&&(this.callback(this.boundingClientRect),He(this,gi,this.boundingClientRect)))};Oc=function(){if(F(this,De)){const{top:e,left:t,width:n,height:r}=mr(this.element);F(this,De).style.overflow="hidden",F(this,De).style.visibility="visible",F(this,De).style.top=`${Math.floor(e)}px`,F(this,De).style.left=`${Math.floor(t)}px`,F(this,De).style.width=`${Math.floor(n)}px`,F(this,De).style.height=`${Math.floor(r)}px`}};var zr=new WeakMap,Fr=new WeakMap;function ff(e,t){let n=zr.get(e);return n||(n={disconnect:new Dc(e,i=>{const s=zr.get(e);s&&s.callbacks.forEach(o=>o(i))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),zr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(zr.delete(e),n.disconnect())}}function hf(e,t){const n=new Set;for(const r of e){const i=ff(r,t);n.add(i)}return()=>n.forEach(r=>r())}function pf(e,t){var n;const r=e.ownerDocument;if(!Fr.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}),Fr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=Fr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),Fr.delete(r))})}var Jn,er,ri,Os,gf=class{constructor(e,t,n){this.callback=t,Ne(this,Jn),Ne(this,er,!1),Ne(this,ri),Ne(this,Os,Sc(o=>{if(!F(this,er)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of F(this,ri))if(o.target.contains(a)){this.callback(F(this,Jn).boundingClientRect);break}}},$c));const r=of(e),i=hf(r,t),s=pf(e,F(this,Os));He(this,ri,r),He(this,Jn,new Dc(e,t,n)),this.disconnect=()=>{F(this,er)||(He(this,er,!0),i(),s(),F(this,Jn).disconnect())}}};Jn=new WeakMap;er=new WeakMap;ri=new WeakMap;Os=new WeakMap;function Ds(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function vn(e){try{Ds(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function ya(e){return!xc||!e?!1:e===jn(e).scrollingElement}function Tc(e){var t,n;const r=Ke(e),i=ya(e)?Ju(e):Ai(e),s=r.visualViewport,o=ya(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 vf(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=Tc(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,h=!s&&o.current.x+a<o.max.x;return{top:u,bottom:c,left:d,right:h,x:d||h,y:u||c}}var Ro=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const i of n)i();for(const i of r)i()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},mi=new Ro(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),mf=new Ro(e=>setTimeout(e,50)),yi=new Map,yf=yi.clear.bind(yi);function ht(e,t=!1){if(!t)return ba(e);let n=yi.get(e);return n||(n=ba(e),yi.set(e,n),mf.schedule(yf),n)}function ba(e){return Ke(e).getComputedStyle(e)}function bf(e,t=ht(e,!0)){return t.position==="fixed"||t.position==="sticky"}function xf(e,t=ht(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=t[i];return typeof s=="string"?n.test(s):!1})}var wf={excludeElement:!0,escapeShadowDOM:!0};function Ts(e,t=wf){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(Mo(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&jo(a))return o(a.host);if(!Dt(a))return bc(a)?o(a.parentElement):s;if(s.has(a))return s;const l=ht(a,!0);if(r&&a===e||xf(a,l)&&s.add(a),bf(a,l)){const{scrollingElement:u}=a.ownerDocument;return u&&s.add(u),s}return o(a.parentNode)}return e?o(e):s}function _n(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=wn(e);for(;r;){if(r===t)return n;const i=Ai(r),{x:s,y:o}=_f(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=wn(r)}return n}function _f(e,t=Ai(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=ht(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function kf(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 yr(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 Ri(e){var t,n,r,i,s,o,a,l,u;const{scale:c,transform:d,translate:h}=e,f=kf(c),g=yr(h),v=Sf(d);if(!v&&!f&&!g)return null;const w={x:(t=f?.x)!=null?t:1,y:(n=f?.y)!=null?n:1},x={x:(r=g?.x)!=null?r:0,y:(i=g?.y)!=null?i:0},m={x:(s=v?.x)!=null?s:0,y:(o=v?.y)!=null?o:0,scaleX:(a=v?.scaleX)!=null?a:1,scaleY:(l=v?.scaleY)!=null?l:1};return{x:x.x+m.x,y:x.y+m.y,z:(u=g?.z)!=null?u:0,scaleX:w.x*m.scaleX,scaleY:w.y*m.scaleY}}function Sf(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var Je=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(Je||{}),$f={x:.2,y:.2},Ef={x:10,y:10};function Of(e,t,n,r=25,i=$f,s=Ef){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:c,isLeft:d,isRight:h}=Tc(e),f=_n(e),g=ht(e,!0),v=Ri(g),w=v!==null?v?.scaleX<0:!1,x=v!==null?v?.scaleY<0:!1,m=new dt(l.left*f.scaleX+f.x,l.top*f.scaleY+f.y,l.width*f.scaleX,l.height*f.scaleY),p={x:0,y:0},b={x:0,y:0},_={height:m.height*i.y,width:m.width*i.x};return _.height>0&&(!u||x&&!c)&&a<=m.top+_.height&&n?.y!==1&&o>=m.left-s.x&&o<=m.right+s.x?(p.y=x?1:-1,b.y=r*Math.abs((m.top+_.height-a)/_.height)):_.height>0&&(!c||x&&!u)&&a>=m.bottom-_.height&&n?.y!==-1&&o>=m.left-s.x&&o<=m.right+s.x&&(p.y=x?-1:1,b.y=r*Math.abs((m.bottom-_.height-a)/_.height)),_.width>0&&(!h||w&&!d)&&o>=m.right-_.width&&n?.x!==-1&&a>=m.top-s.y&&a<=m.bottom+s.y?(p.x=w?-1:1,b.x=r*Math.abs((m.right-_.width-o)/_.width)):_.width>0&&(!d||w&&!h)&&o<=m.left+_.width&&n?.x!==1&&a>=m.top-s.y&&a<=m.bottom+s.y&&(p.x=w?1:-1,b.x=r*Math.abs((m.left+_.width-o)/_.width)),{direction:p,speed:b}}function Cc(e,{block:t="nearest",inline:n="nearest"}={}){if(!Dt(e))return;const r=Ts(e),i=[];for(const s of r){if(!Dt(s))continue;const{top:o,left:a}=Df(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 xa(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 Df(e,t){const n=xa(e),r=xa(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Tf(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 Cf(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 Pc({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function wa(e,t=ht(e).translate,n=!0){if(n){const r=yc(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=yr(i);if(s)return s}}}if(t){const r=yr(t);if(r)return r}return{x:0,y:0,z:0}}var Pf=new Ro(e=>setTimeout(e,0)),ur=new Map,Mf=ur.clear.bind(ur);function If(e){const t=e.ownerDocument;let n=ur.get(t);if(n)return n;n=t.getAnimations(),ur.set(t,n),Pf.schedule(Mf);const r=n.filter(i=>ji(i.effect)&&i.effect.target===e);return ur.set(e,r),n}function jf(e,t){const n=If(e).filter(r=>{var i,s;if(ji(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))!=null?s:!0)return r.effect.getKeyframes().some(l=>{for(const u of t.properties)if(l[u])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 ct=class extends dt{constructor(e,t={}){var n,r,i,s;const{frameTransform:o=_n(e),ignoreTransforms:a,getBoundingClientRect:l=Ai}=t,u=jf(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||Io())&&_.contains(e)}),c=l(e);let{top:d,left:h,width:f,height:g}=c,v;const w=ht(e),x=Ri(w),m={x:(n=x?.scaleX)!=null?n:1,y:(r=x?.scaleY)!=null?r:1},p=Af(e,w);u?.(),x&&(v=Cf(c,x,w.transformOrigin),(a||p)&&(d=v.top,h=v.left,f=v.width,g=v.height));const b={width:(i=v?.width)!=null?i:f,height:(s=v?.height)!=null?s:g};if(p&&!a&&v){const _=Tf(v,p,w.transformOrigin);d=_.top,h=_.left,f=_.width,g=_.height,m.x=p.scaleX,m.y=p.scaleY}o&&(a||(h*=o.scaleX,f*=o.scaleX,d*=o.scaleY,g*=o.scaleY),h+=o.x,d+=o.y),super(h,d,f,g),this.scale=m,this.intrinsicWidth=b.width,this.intrinsicHeight=b.height}};function Af(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=ji(a.effect)?a.effect.getKeyframes():[],u=l[l.length-1];if(!u)continue;const{transform:c,translate:d,scale:h}=u;typeof c=="string"&&c&&(r=c,o=!0),typeof d=="string"&&d&&(i=d,o=!0),typeof h=="string"&&h&&(s=h,o=!0)}return o?Ri({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function fr(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 Rf=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(fr(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(fr(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(fr(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||Tr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function br(e){if(!e)return!1;const{KeyboardEvent:t}=Ke(e.target);return e instanceof t}function Lf(e){if(!e)return!1;const{PointerEvent:t}=Ke(e.target);return e instanceof t}function Wf(e){if(!Vt(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||zf(e)}function zf(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Zi={};function Cs(e){const t=Zi[e]==null?0:Zi[e]+1;return Zi[e]=t,`${e}-${t}`}var Lo=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=Ze.distance(t.shape.center,n);return{id:r,value:1/i,type:In.PointerIntersection,priority:Mn.High}}return null},Ff=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=Ze.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:In.ShapeIntersection,priority:Mn.Normal}}return null},Mc=e=>{var t;return(t=Lo(e))!=null?t:Ff(e)},Nf=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;const s=r?dt.from(r.current.boundingRectangle).corners:void 0,a=dt.from(n.shape.boundingRectangle).corners.reduce((l,u,c)=>{var d;return l+Ze.distance(Ze.from(u),(d=s?.[c])!=null?d:i.current)},0)/4;return{id:n.id,value:1/a,type:In.Collision,priority:Mn.Normal}},Bf=Object.create,Wo=Object.defineProperty,Vf=Object.defineProperties,Gf=Object.getOwnPropertyDescriptor,Uf=Object.getOwnPropertyDescriptors,bi=Object.getOwnPropertySymbols,Ic=Object.prototype.hasOwnProperty,jc=Object.prototype.propertyIsEnumerable,Ac=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),An=e=>{throw TypeError(e)},Ps=(e,t,n)=>t in e?Wo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xr=(e,t)=>{for(var n in t||(t={}))Ic.call(t,n)&&Ps(e,n,t[n]);if(bi)for(var n of bi(t))jc.call(t,n)&&Ps(e,n,t[n]);return e},zo=(e,t)=>Vf(e,Uf(t)),_a=(e,t)=>Wo(e,"name",{value:t,configurable:!0}),Rc=(e,t)=>{var n={};for(var r in e)Ic.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&bi)for(var r of bi(e))t.indexOf(r)<0&&jc.call(e,r)&&(n[r]=e[r]);return n},Rn=e=>{var t;return[,,,Bf((t=e?.[Ac("metadata")])!=null?t:null)]},Lc=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?An("Function expected"):e,Hf=(e,t,n,r,i)=>({kind:Lc[e],name:t,metadata:r,addInitializer:s=>n._?An("Already initialized"):i.push(tr(s||null))}),Xt=(e,t)=>Ps(t,Ac("metadata"),e[3]),we=(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},nt=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,h=!!(t&8),f=!!(t&16),g=d>3?e.length+1:d?h?1:2:0,v=Lc[d+5],w=d>3&&(e[g-1]=[]),x=e[g]||(e[g]=[]),m=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&Gf(d<4?i:{get[n](){return ne(this,s)},set[n](b){return Ae(this,s,b)}},n));d?f&&d<4&&_a(s,(d>2?"set ":d>1?"get ":"")+n):_a(i,n);for(var p=r.length-1;p>=0;p--)u=Hf(d,n,l={},e[3],x),d&&(u.static=h,u.private=f,c=u.access={has:f?b=>qf(i,b):b=>n in b},d^3&&(c.get=f?b=>(d^1?ne:Gt)(b,i,d^4?s:m.get):b=>b[n]),d>2&&(c.set=f?(b,_)=>Ae(b,i,_,d^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[p])(d?d<4?f?s:m[v]:d>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,d^4||a===void 0?tr(a)&&(d>4?w.unshift(a):d?f?s=a:m[v]=a:i=a):typeof a!="object"||a===null?An("Object expected"):(tr(o=a.get)&&(m.get=o),tr(o=a.set)&&(m.set=o),tr(o=a.init)&&w.unshift(o));return d||Xt(e,i),m&&Wo(i,n,m),f?d^4?s:m:i},Fo=(e,t,n)=>t.has(e)||An("Cannot "+n),qf=(e,t)=>Object(t)!==t?An('Cannot use the "in" operator on this value'):e.has(t),ne=(e,t,n)=>(Fo(e,t,"read from private field"),n?n.call(e):t.get(e)),ge=(e,t,n)=>t.has(e)?An("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ae=(e,t,n,r)=>(Fo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Gt=(e,t,n)=>(Fo(e,t,"access private method"),n),ka={role:"button",roleDescription:"draggable"},Kf="dnd-kit-description",Yf="dnd-kit-announcement",Xf={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."},Qf={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 Jf(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function eh(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 th=["dragover","dragmove"],nh=class extends Pe{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Kf,announcement:i=Yf}={},announcements:s=Qf,screenReaderInstructions:o=Xf,debounce:a=500}=t??{},l=n?`${r}-${n}`:Cs(r),u=n?`${i}-${n}`:Cs(i);let c,d,h,f;const g=(_=f)=>{!h||!_||h?.nodeValue!==_&&(h.nodeValue=_)},v=()=>mi.schedule(g),w=rh(v,a),x=Object.entries(s).map(([_,$])=>this.manager.monitor.addEventListener(_,(O,D)=>{const M=h;if(!M)return;const I=$?.(O,D);I&&M.nodeValue!==I&&(f=I,th.includes(_)?w():(v(),w.cancel()))})),m=()=>{let _=[];c?.isConnected||(c=Jf(l,o.draggable),_.push(c)),d?.isConnected||(d=eh(u),h=document.createTextNode(""),d.appendChild(h),_.push(d)),_.length>0&&document.body.append(..._)},p=new Set;function b(){for(const _ of p)_()}this.registerEffect(()=>{var _;p.clear();for(const $ of this.manager.registry.draggables.value){const O=(_=$.handle)!=null?_:$.element;if(O){(!c||!d)&&p.add(m),(!Zf(O)||Io())&&!O.hasAttribute("tabindex")&&p.add(()=>O.setAttribute("tabindex","0")),!O.hasAttribute("role")&&O.tagName.toLowerCase()!=="button"&&p.add(()=>O.setAttribute("role",ka.role)),O.hasAttribute("aria-roledescription")||p.add(()=>O.setAttribute("aria-roledescription",ka.roleDescription)),O.hasAttribute("aria-describedby")||p.add(()=>O.setAttribute("aria-describedby",l));for(const M of["aria-pressed","aria-grabbed"]){const I=String($.isDragging);O.getAttribute(M)!==I&&p.add(()=>O.setAttribute(M,I))}const D=String($.disabled);O.getAttribute("aria-disabled")!==D&&p.add(()=>O.setAttribute("aria-disabled",D))}}p.size>0&&mi.schedule(b)}),this.destroy=()=>{super.destroy(),c?.remove(),d?.remove(),x.forEach(_=>_())}}};function rh(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var xi=new Map,Wc,zc,Fc,Nc,Ms,hr,mt,No,kn,Bc,Vc,Gc,Uc,Tt=class extends(Ms=Dr,Nc=[H],Fc=[pe],zc=[pe],Wc=[pe],Ms){constructor(t,n){super(t,n),we(mt,5,this),ge(this,kn),ge(this,hr,new Set),ge(this,No,we(mt,8,this,new Set)),we(mt,11,this),this.registerEffect(Gt(this,kn,Bc))}register(t){return ne(this,hr).add(t),()=>{ne(this,hr).delete(t)}}addRoot(t){return U(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{U(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return pi((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return pi((t=n?.element)!=null?t:null)}get roots(){const{status:t}=this.manager.dragOperation;if(t.initializing||t.initialized){const n=[this.sourceRoot,this.targetRoot].filter(r=>r!=null);return new Set([...n,...this.additionalRoots])}return new Set}};mt=Rn(Ms);hr=new WeakMap;No=new WeakMap;kn=new WeakSet;Bc=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of ne(this,hr))t.push(Gt(this,kn,Vc).call(this,n,r));return()=>{for(const n of t)n()}};Vc=function(e,t){let n=xi.get(e);n||(n=new Map,xi.set(e,n));let r=n.get(t);if(!r){const s=Mo(e)?Gt(this,kn,Gc).call(this,e,n,t):Gt(this,kn,Uc).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())}};Gc=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&&xi.delete(e)}}};Uc=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(jo(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&&xi.delete(e)}}};nt(mt,4,"additionalRoots",Nc,Tt,No);nt(mt,2,"sourceRoot",Fc,Tt);nt(mt,2,"targetRoot",zc,Tt);nt(mt,2,"roots",Wc,Tt);Xt(mt,Tt);Tt.configure=Or(Tt);var Li=Tt,ih=class extends Pe{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Li),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},Cr="data-dnd-",Is=`${Cr}dropping`,Oe="--dnd-",lt=`${Cr}dragging`,wi=`${Cr}placeholder`,sh=[lt,wi,"popover","aria-pressed","aria-grabbing"],oh=["view-transition-name"],ah=`
8
+ `)}var kc=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 a of i){const[l,{type:u,listener:c,options:d}]=a;l.removeEventListener(u,c,d),s.delete(a)}}}};function wn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function af(e){const t=new Set;let n=wn(e);for(;n;)t.add(n),n=wn(n);return t}function lf(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Sc(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=lf(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function cf(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 df(e,t=e.getBoundingClientRect()){const{width:n,height:r}=mr(e,t);return n>0&&r>0}var uf=xc?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ni,ff=class extends uf{constructor(e){super(t=>{if(!F(this,ni)){He(this,ni,!0);return}e(t,this)}),Ne(this,ni,!1)}};ni=new WeakMap;var ma=Array.from({length:100},(e,t)=>t/100),$c=75,Rt,gi,wt,Lt,Qn,Te,dr,Zn,vi,Ec,Oc,Dc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ne(this,vi),this.disconnect=()=>{var s,o,a;He(this,dr,!0),(s=F(this,wt))==null||s.disconnect(),(o=F(this,Lt))==null||o.disconnect(),F(this,Qn).disconnect(),(a=F(this,Te))==null||a.remove()},Ne(this,Rt,!0),Ne(this,gi),Ne(this,wt),Ne(this,Lt),Ne(this,Qn),Ne(this,Te),Ne(this,dr,!1),Ne(this,Zn,Sc(()=>{var s,o,a;const{element:l}=this;if((s=F(this,Lt))==null||s.disconnect(),F(this,dr)||!F(this,Rt)||!l.isConnected)return;const u=(o=l.ownerDocument)!=null?o:document,{innerHeight:c,innerWidth:d}=(a=u.defaultView)!=null?a:window,h=l.getBoundingClientRect(),f=mr(l,h),{top:g,left:v,bottom:w,right:x}=f,m=-Math.floor(g),p=-Math.floor(v),b=-Math.floor(d-x),_=-Math.floor(c-w),$=`${m}px ${b}px ${_}px ${p}px`;this.boundingClientRect=h,He(this,Lt,new IntersectionObserver(O=>{const[D]=O,{intersectionRect:M}=D;(D.intersectionRatio!==1?D.intersectionRatio:dt.intersectionRatio(M,mr(l)))!==1&&F(this,Zn).call(this)},{threshold:ma,rootMargin:$,root:u})),F(this,Lt).observe(l),mc(this,vi,Ec).call(this)},$c)),this.boundingClientRect=e.getBoundingClientRect(),He(this,Rt,df(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(He(this,Te,document.createElement("div")),F(this,Te).style.background="rgba(0,0,0,0.15)",F(this,Te).style.position="fixed",F(this,Te).style.pointerEvents="none",i.body.appendChild(F(this,Te))),He(this,Qn,new IntersectionObserver(s=>{var o,a;const l=s[s.length-1],{boundingClientRect:u,isIntersecting:c}=l,{width:d,height:h}=u,f=F(this,Rt);He(this,Rt,c),!(!d&&!h)&&(f&&!c?((o=F(this,Lt))==null||o.disconnect(),this.callback(null),(a=F(this,wt))==null||a.disconnect(),He(this,wt,void 0),F(this,Te)&&(F(this,Te).style.visibility="hidden")):F(this,Zn).call(this),c&&!F(this,wt)&&(He(this,wt,new ff(F(this,Zn))),F(this,wt).observe(e)))},{threshold:ma,root:i})),F(this,Rt)&&!n.skipInitial&&this.callback(this.boundingClientRect),F(this,Qn).observe(e)}};Rt=new WeakMap;gi=new WeakMap;wt=new WeakMap;Lt=new WeakMap;Qn=new WeakMap;Te=new WeakMap;dr=new WeakMap;Zn=new WeakMap;vi=new WeakSet;Ec=function(){F(this,dr)||(mc(this,vi,Oc).call(this),!cf(this.boundingClientRect,F(this,gi))&&(this.callback(this.boundingClientRect),He(this,gi,this.boundingClientRect)))};Oc=function(){if(F(this,Te)){const{top:e,left:t,width:n,height:r}=mr(this.element);F(this,Te).style.overflow="hidden",F(this,Te).style.visibility="visible",F(this,Te).style.top=`${Math.floor(e)}px`,F(this,Te).style.left=`${Math.floor(t)}px`,F(this,Te).style.width=`${Math.floor(n)}px`,F(this,Te).style.height=`${Math.floor(r)}px`}};var zr=new WeakMap,Fr=new WeakMap;function hf(e,t){let n=zr.get(e);return n||(n={disconnect:new Dc(e,i=>{const s=zr.get(e);s&&s.callbacks.forEach(o=>o(i))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),zr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(zr.delete(e),n.disconnect())}}function pf(e,t){const n=new Set;for(const r of e){const i=hf(r,t);n.add(i)}return()=>n.forEach(r=>r())}function gf(e,t){var n;const r=e.ownerDocument;if(!Fr.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}),Fr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=Fr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),Fr.delete(r))})}var Jn,er,ri,Os,vf=class{constructor(e,t,n){this.callback=t,Ne(this,Jn),Ne(this,er,!1),Ne(this,ri),Ne(this,Os,Sc(o=>{if(!F(this,er)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of F(this,ri))if(o.target.contains(a)){this.callback(F(this,Jn).boundingClientRect);break}}},$c));const r=af(e),i=pf(r,t),s=gf(e,F(this,Os));He(this,ri,r),He(this,Jn,new Dc(e,t,n)),this.disconnect=()=>{F(this,er)||(He(this,er,!0),i(),s(),F(this,Jn).disconnect())}}};Jn=new WeakMap;er=new WeakMap;ri=new WeakMap;Os=new WeakMap;function Ds(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function vn(e){try{Ds(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function ya(e){return!xc||!e?!1:e===jn(e).scrollingElement}function Tc(e){var t,n;const r=Ke(e),i=ya(e)?ef(e):Ai(e),s=r.visualViewport,o=ya(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 mf(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=Tc(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,h=!s&&o.current.x+a<o.max.x;return{top:u,bottom:c,left:d,right:h,x:d||h,y:u||c}}var Ro=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const i of n)i();for(const i of r)i()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},mi=new Ro(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),yf=new Ro(e=>setTimeout(e,50)),yi=new Map,bf=yi.clear.bind(yi);function ht(e,t=!1){if(!t)return ba(e);let n=yi.get(e);return n||(n=ba(e),yi.set(e,n),yf.schedule(bf),n)}function ba(e){return Ke(e).getComputedStyle(e)}function xf(e,t=ht(e,!0)){return t.position==="fixed"||t.position==="sticky"}function wf(e,t=ht(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=t[i];return typeof s=="string"?n.test(s):!1})}var _f={excludeElement:!0,escapeShadowDOM:!0};function Ts(e,t=_f){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(Mo(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&jo(a))return o(a.host);if(!Dt(a))return bc(a)?o(a.parentElement):s;if(s.has(a))return s;const l=ht(a,!0);if(r&&a===e||wf(a,l)&&s.add(a),xf(a,l)){const{scrollingElement:u}=a.ownerDocument;return u&&s.add(u),s}return o(a.parentNode)}return e?o(e):s}function _n(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=wn(e);for(;r;){if(r===t)return n;const i=Ai(r),{x:s,y:o}=kf(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=wn(r)}return n}function kf(e,t=Ai(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=ht(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function Sf(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 yr(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 Ri(e){var t,n,r,i,s,o,a,l,u;const{scale:c,transform:d,translate:h}=e,f=Sf(c),g=yr(h),v=$f(d);if(!v&&!f&&!g)return null;const w={x:(t=f?.x)!=null?t:1,y:(n=f?.y)!=null?n:1},x={x:(r=g?.x)!=null?r:0,y:(i=g?.y)!=null?i:0},m={x:(s=v?.x)!=null?s:0,y:(o=v?.y)!=null?o:0,scaleX:(a=v?.scaleX)!=null?a:1,scaleY:(l=v?.scaleY)!=null?l:1};return{x:x.x+m.x,y:x.y+m.y,z:(u=g?.z)!=null?u:0,scaleX:w.x*m.scaleX,scaleY:w.y*m.scaleY}}function $f(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var Je=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(Je||{}),Ef={x:.2,y:.2},Of={x:10,y:10};function Df(e,t,n,r=25,i=Ef,s=Of){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:c,isLeft:d,isRight:h}=Tc(e),f=_n(e),g=ht(e,!0),v=Ri(g),w=v!==null?v?.scaleX<0:!1,x=v!==null?v?.scaleY<0:!1,m=new dt(l.left*f.scaleX+f.x,l.top*f.scaleY+f.y,l.width*f.scaleX,l.height*f.scaleY),p={x:0,y:0},b={x:0,y:0},_={height:m.height*i.y,width:m.width*i.x};return _.height>0&&(!u||x&&!c)&&a<=m.top+_.height&&n?.y!==1&&o>=m.left-s.x&&o<=m.right+s.x?(p.y=x?1:-1,b.y=r*Math.abs((m.top+_.height-a)/_.height)):_.height>0&&(!c||x&&!u)&&a>=m.bottom-_.height&&n?.y!==-1&&o>=m.left-s.x&&o<=m.right+s.x&&(p.y=x?-1:1,b.y=r*Math.abs((m.bottom-_.height-a)/_.height)),_.width>0&&(!h||w&&!d)&&o>=m.right-_.width&&n?.x!==-1&&a>=m.top-s.y&&a<=m.bottom+s.y?(p.x=w?-1:1,b.x=r*Math.abs((m.right-_.width-o)/_.width)):_.width>0&&(!d||w&&!h)&&o<=m.left+_.width&&n?.x!==1&&a>=m.top-s.y&&a<=m.bottom+s.y&&(p.x=w?1:-1,b.x=r*Math.abs((m.left+_.width-o)/_.width)),{direction:p,speed:b}}function Cc(e,{block:t="nearest",inline:n="nearest"}={}){if(!Dt(e))return;const r=Ts(e),i=[];for(const s of r){if(!Dt(s))continue;const{top:o,left:a}=Tf(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 xa(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 Tf(e,t){const n=xa(e),r=xa(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Cf(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 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 Pc({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function wa(e,t=ht(e).translate,n=!0){if(n){const r=yc(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=yr(i);if(s)return s}}}if(t){const r=yr(t);if(r)return r}return{x:0,y:0,z:0}}var Mf=new Ro(e=>setTimeout(e,0)),ur=new Map,If=ur.clear.bind(ur);function jf(e){const t=e.ownerDocument;let n=ur.get(t);if(n)return n;n=t.getAnimations(),ur.set(t,n),Mf.schedule(If);const r=n.filter(i=>ji(i.effect)&&i.effect.target===e);return ur.set(e,r),n}function Af(e,t){const n=jf(e).filter(r=>{var i,s;if(ji(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))!=null?s:!0)return r.effect.getKeyframes().some(l=>{for(const u of t.properties)if(l[u])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 ct=class extends dt{constructor(e,t={}){var n,r,i,s;const{frameTransform:o=_n(e),ignoreTransforms:a,getBoundingClientRect:l=Ai}=t,u=Af(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||Io())&&_.contains(e)}),c=l(e);let{top:d,left:h,width:f,height:g}=c,v;const w=ht(e),x=Ri(w),m={x:(n=x?.scaleX)!=null?n:1,y:(r=x?.scaleY)!=null?r:1},p=Rf(e,w);u?.(),x&&(v=Pf(c,x,w.transformOrigin),(a||p)&&(d=v.top,h=v.left,f=v.width,g=v.height));const b={width:(i=v?.width)!=null?i:f,height:(s=v?.height)!=null?s:g};if(p&&!a&&v){const _=Cf(v,p,w.transformOrigin);d=_.top,h=_.left,f=_.width,g=_.height,m.x=p.scaleX,m.y=p.scaleY}o&&(a||(h*=o.scaleX,f*=o.scaleX,d*=o.scaleY,g*=o.scaleY),h+=o.x,d+=o.y),super(h,d,f,g),this.scale=m,this.intrinsicWidth=b.width,this.intrinsicHeight=b.height}};function Rf(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=ji(a.effect)?a.effect.getKeyframes():[],u=l[l.length-1];if(!u)continue;const{transform:c,translate:d,scale:h}=u;typeof c=="string"&&c&&(r=c,o=!0),typeof d=="string"&&d&&(i=d,o=!0),typeof h=="string"&&h&&(s=h,o=!0)}return o?Ri({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function fr(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 Lf=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(fr(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(fr(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(fr(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||Tr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function br(e){if(!e)return!1;const{KeyboardEvent:t}=Ke(e.target);return e instanceof t}function Wf(e){if(!e)return!1;const{PointerEvent:t}=Ke(e.target);return e instanceof t}function zf(e){if(!Vt(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||Ff(e)}function Ff(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Zi={};function Cs(e){const t=Zi[e]==null?0:Zi[e]+1;return Zi[e]=t,`${e}-${t}`}var Lo=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=Ze.distance(t.shape.center,n);return{id:r,value:1/i,type:In.PointerIntersection,priority:Mn.High}}return null},Nf=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:i}=e,s=Ze.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:In.ShapeIntersection,priority:Mn.Normal}}return null},Mc=e=>{var t;return(t=Lo(e))!=null?t:Nf(e)},Bf=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;const s=r?dt.from(r.current.boundingRectangle).corners:void 0,a=dt.from(n.shape.boundingRectangle).corners.reduce((l,u,c)=>{var d;return l+Ze.distance(Ze.from(u),(d=s?.[c])!=null?d:i.current)},0)/4;return{id:n.id,value:1/a,type:In.Collision,priority:Mn.Normal}},Vf=Object.create,Wo=Object.defineProperty,Gf=Object.defineProperties,Uf=Object.getOwnPropertyDescriptor,Hf=Object.getOwnPropertyDescriptors,bi=Object.getOwnPropertySymbols,Ic=Object.prototype.hasOwnProperty,jc=Object.prototype.propertyIsEnumerable,Ac=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),An=e=>{throw TypeError(e)},Ps=(e,t,n)=>t in e?Wo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xr=(e,t)=>{for(var n in t||(t={}))Ic.call(t,n)&&Ps(e,n,t[n]);if(bi)for(var n of bi(t))jc.call(t,n)&&Ps(e,n,t[n]);return e},zo=(e,t)=>Gf(e,Hf(t)),_a=(e,t)=>Wo(e,"name",{value:t,configurable:!0}),Rc=(e,t)=>{var n={};for(var r in e)Ic.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&bi)for(var r of bi(e))t.indexOf(r)<0&&jc.call(e,r)&&(n[r]=e[r]);return n},Rn=e=>{var t;return[,,,Vf((t=e?.[Ac("metadata")])!=null?t:null)]},Lc=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?An("Function expected"):e,qf=(e,t,n,r,i)=>({kind:Lc[e],name:t,metadata:r,addInitializer:s=>n._?An("Already initialized"):i.push(tr(s||null))}),Xt=(e,t)=>Ps(t,Ac("metadata"),e[3]),we=(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},nt=(e,t,n,r,i,s)=>{var o,a,l,u,c,d=t&7,h=!!(t&8),f=!!(t&16),g=d>3?e.length+1:d?h?1:2:0,v=Lc[d+5],w=d>3&&(e[g-1]=[]),x=e[g]||(e[g]=[]),m=d&&(!f&&!h&&(i=i.prototype),d<5&&(d>3||!f)&&Uf(d<4?i:{get[n](){return re(this,s)},set[n](b){return Ae(this,s,b)}},n));d?f&&d<4&&_a(s,(d>2?"set ":d>1?"get ":"")+n):_a(i,n);for(var p=r.length-1;p>=0;p--)u=qf(d,n,l={},e[3],x),d&&(u.static=h,u.private=f,c=u.access={has:f?b=>Kf(i,b):b=>n in b},d^3&&(c.get=f?b=>(d^1?re:Gt)(b,i,d^4?s:m.get):b=>b[n]),d>2&&(c.set=f?(b,_)=>Ae(b,i,_,d^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[p])(d?d<4?f?s:m[v]:d>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,d^4||a===void 0?tr(a)&&(d>4?w.unshift(a):d?f?s=a:m[v]=a:i=a):typeof a!="object"||a===null?An("Object expected"):(tr(o=a.get)&&(m.get=o),tr(o=a.set)&&(m.set=o),tr(o=a.init)&&w.unshift(o));return d||Xt(e,i),m&&Wo(i,n,m),f?d^4?s:m:i},Fo=(e,t,n)=>t.has(e)||An("Cannot "+n),Kf=(e,t)=>Object(t)!==t?An('Cannot use the "in" operator on this value'):e.has(t),re=(e,t,n)=>(Fo(e,t,"read from private field"),n?n.call(e):t.get(e)),ve=(e,t,n)=>t.has(e)?An("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ae=(e,t,n,r)=>(Fo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Gt=(e,t,n)=>(Fo(e,t,"access private method"),n),ka={role:"button",roleDescription:"draggable"},Yf="dnd-kit-description",Xf="dnd-kit-announcement",Qf={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 Jf(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function eh(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function th(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 nh=["dragover","dragmove"],rh=class extends Me{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Yf,announcement:i=Xf}={},announcements:s=Zf,screenReaderInstructions:o=Qf,debounce:a=500}=t??{},l=n?`${r}-${n}`:Cs(r),u=n?`${i}-${n}`:Cs(i);let c,d,h,f;const g=(_=f)=>{!h||!_||h?.nodeValue!==_&&(h.nodeValue=_)},v=()=>mi.schedule(g),w=ih(v,a),x=Object.entries(s).map(([_,$])=>this.manager.monitor.addEventListener(_,(O,D)=>{const M=h;if(!M)return;const I=$?.(O,D);I&&M.nodeValue!==I&&(f=I,nh.includes(_)?w():(v(),w.cancel()))})),m=()=>{let _=[];c?.isConnected||(c=eh(l,o.draggable),_.push(c)),d?.isConnected||(d=th(u),h=document.createTextNode(""),d.appendChild(h),_.push(d)),_.length>0&&document.body.append(..._)},p=new Set;function b(){for(const _ of p)_()}this.registerEffect(()=>{var _;p.clear();for(const $ of this.manager.registry.draggables.value){const O=(_=$.handle)!=null?_:$.element;if(O){(!c||!d)&&p.add(m),(!Jf(O)||Io())&&!O.hasAttribute("tabindex")&&p.add(()=>O.setAttribute("tabindex","0")),!O.hasAttribute("role")&&O.tagName.toLowerCase()!=="button"&&p.add(()=>O.setAttribute("role",ka.role)),O.hasAttribute("aria-roledescription")||p.add(()=>O.setAttribute("aria-roledescription",ka.roleDescription)),O.hasAttribute("aria-describedby")||p.add(()=>O.setAttribute("aria-describedby",l));for(const M of["aria-pressed","aria-grabbed"]){const I=String($.isDragging);O.getAttribute(M)!==I&&p.add(()=>O.setAttribute(M,I))}const D=String($.disabled);O.getAttribute("aria-disabled")!==D&&p.add(()=>O.setAttribute("aria-disabled",D))}}p.size>0&&mi.schedule(b)}),this.destroy=()=>{super.destroy(),c?.remove(),d?.remove(),x.forEach(_=>_())}}};function ih(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var xi=new Map,Wc,zc,Fc,Nc,Ms,hr,mt,No,kn,Bc,Vc,Gc,Uc,Tt=class extends(Ms=Dr,Nc=[H],Fc=[ge],zc=[ge],Wc=[ge],Ms){constructor(t,n){super(t,n),we(mt,5,this),ve(this,kn),ve(this,hr,new Set),ve(this,No,we(mt,8,this,new Set)),we(mt,11,this),this.registerEffect(Gt(this,kn,Bc))}register(t){return re(this,hr).add(t),()=>{re(this,hr).delete(t)}}addRoot(t){return U(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{U(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return pi((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return pi((t=n?.element)!=null?t:null)}get roots(){const{status:t}=this.manager.dragOperation;if(t.initializing||t.initialized){const n=[this.sourceRoot,this.targetRoot].filter(r=>r!=null);return new Set([...n,...this.additionalRoots])}return new Set}};mt=Rn(Ms);hr=new WeakMap;No=new WeakMap;kn=new WeakSet;Bc=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of re(this,hr))t.push(Gt(this,kn,Vc).call(this,n,r));return()=>{for(const n of t)n()}};Vc=function(e,t){let n=xi.get(e);n||(n=new Map,xi.set(e,n));let r=n.get(t);if(!r){const s=Mo(e)?Gt(this,kn,Gc).call(this,e,n,t):Gt(this,kn,Uc).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())}};Gc=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&&xi.delete(e)}}};Uc=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(jo(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&&xi.delete(e)}}};nt(mt,4,"additionalRoots",Nc,Tt,No);nt(mt,2,"sourceRoot",Fc,Tt);nt(mt,2,"targetRoot",zc,Tt);nt(mt,2,"roots",Wc,Tt);Xt(mt,Tt);Tt.configure=Or(Tt);var Li=Tt,sh=class extends Me{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Li),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},Cr="data-dnd-",Is=`${Cr}dropping`,De="--dnd-",lt=`${Cr}dragging`,wi=`${Cr}placeholder`,oh=[lt,wi,"popover","aria-pressed","aria-grabbing"],ah=["view-transition-name"],lh=`
9
9
  :is(:root,:host) [${lt}] {
10
10
  position: fixed !important;
11
11
  pointer-events: none !important;
12
12
  touch-action: none;
13
13
  z-index: calc(infinity);
14
14
  will-change: translate;
15
- top: var(${Oe}top, 0px) !important;
16
- left: var(${Oe}left, 0px) !important;
15
+ top: var(${De}top, 0px) !important;
16
+ left: var(${De}left, 0px) !important;
17
17
  right: unset !important;
18
18
  bottom: unset !important;
19
- width: var(${Oe}width, auto);
20
- max-width: var(${Oe}width, auto);
21
- height: var(${Oe}height, auto);
22
- max-height: var(${Oe}height, auto);
23
- transform: var(${Oe}transform, none) !important;
24
- transition: var(${Oe}transition) !important;
19
+ width: var(${De}width, auto);
20
+ max-width: var(${De}width, auto);
21
+ height: var(${De}height, auto);
22
+ max-height: var(${De}height, auto);
23
+ transform: var(${De}transform, none) !important;
24
+ transition: var(${De}transition) !important;
25
25
  }
26
26
 
27
27
  :is(:root,:host) [${wi}] {
@@ -37,12 +37,12 @@
37
37
  }
38
38
 
39
39
  [${lt}]:not([${Is}]) {
40
- translate: var(${Oe}translate) !important;
40
+ translate: var(${De}translate) !important;
41
41
  }
42
42
 
43
- [${lt}][style*='${Oe}scale'] {
44
- scale: var(${Oe}scale) !important;
45
- transform-origin: var(${Oe}transform-origin) !important;
43
+ [${lt}][style*='${De}scale'] {
44
+ scale: var(${De}scale) !important;
45
+ transform-origin: var(${De}transform-origin) !important;
46
46
  }
47
47
 
48
48
  @layer dnd-kit {
@@ -64,22 +64,22 @@
64
64
  display: none;
65
65
  visibility: hidden;
66
66
  }
67
- `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function lh(e,t="hidden"){return U(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=ch(n,r.registry.droppables),s=[],o=nf(n),{remove:a}=o;return dh(i,o,s),uh(o,t),o.remove=()=>{s.forEach(l=>l()),a.call(o)},o})}function ch(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${Cr}${Cs("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function dh(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),Es.set(a,o),n.push(()=>{Es.delete(a),r.proxy=void 0})}}function uh(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(wi,t)}function Hc(e,t){return e===t?!0:wn(e)===wn(t)}function Sa(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Vt(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>vn(t))}function js(e){return e.tagName==="TR"}function fh(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-")||sh.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(fr(e)&&fr(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(oh.includes(c)||c.startsWith(Oe))continue;const d=u.getPropertyValue(c);t.style.setProperty(c,d)}}}else l!==null?t.setAttribute(a,l):t.removeAttribute(a)}s&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function hh(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),vn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),vn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),vn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function ph(e){return new ResizeObserver(()=>{var t,n,r;const i=new ct(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=wc();if(e.styles.set({width:i.width-e.widthOffset,height:i.height-e.heightOffset,top:e.top+a+l.y,left:e.left+o+l.x},Oe),(n=e.getElementMutationObserver())==null||n.takeRecords(),js(e.element)&&js(e.placeholder)){const v=Array.from(e.element.cells),w=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(v.map(x=>x.style.width));for(const[x,m]of v.entries()){const p=w[x];m.style.width=`${p.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,h=i.width-e.widthOffset,f=i.height-e.heightOffset,g=e.frameTransform;e.dragOperation.shape=new dt(c*g.scaleX+g.x,d*g.scaleY+g.y,h*g.scaleX,f*g.scaleY)})}var gh=250,vh="ease";function mh(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const m=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(m).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=gh,easing:a=vh}=s??{};vn(e.feedbackElement);const[,l]=(t=yc(e.feedbackElement,m=>"translate"in m))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,c={frameTransform:Hc(e.feedbackElement,u)?null:void 0},d=new ct(e.feedbackElement,c),h=(r=yr(ht(e.feedbackElement).translate))!=null?r:e.translate,f=new ct(u,c),g=dt.delta(d,f,e.alignment),v={x:h.x-g.x,y:h.y-g.y},w=Math.round(d.intrinsicHeight)!==Math.round(f.intrinsicHeight)?{minHeight:[`${d.intrinsicHeight}px`,`${f.intrinsicHeight}px`],maxHeight:[`${d.intrinsicHeight}px`,`${f.intrinsicHeight}px`]}:{},x=Math.round(d.intrinsicWidth)!==Math.round(f.intrinsicWidth)?{minWidth:[`${d.intrinsicWidth}px`,`${f.intrinsicWidth}px`],maxWidth:[`${d.intrinsicWidth}px`,`${f.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Oe),e.feedbackElement.setAttribute(Is,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),Pc({element:e.feedbackElement,keyframes:zo(xr(xr({},w),x),{translate:[`${h.x}px ${h.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:Ao(Ke(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(Is),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var qc,As,wr,Bo,ii,Kc,Yc,Sn=class extends(As=Pe,qc=[H],As){constructor(t,n){super(t,n),ge(this,ii),ge(this,Bo,we(wr,8,this)),we(wr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(Li),i=r?.register(ah);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}this.registerEffect(Gt(this,ii,Kc).bind(this,r)),this.registerEffect(Gt(this,ii,Yc))}};wr=Rn(As);Bo=new WeakMap;ii=new WeakSet;Kc=function(e){const{overlay:t}=this;if(!t||!e)return;const n=pi(t);if(n)return e.addRoot(n)};Yc=function(){var e,t,n,r,i,s,o;const{state:a,manager:l,options:u}=this,{dragOperation:c}=l,{position:d,source:h,status:f}=c;if(f.idle){a.current={},a.initial={};return}if(!h)return;const{element:g}=h,v=h.pluginConfig(Sn),w=(t=(e=v?.feedback)!=null?e:u?.feedback)!=null?t:"default",x=typeof w=="function"?w(h,l):w;if(!g||x==="none"||!f.initialized||f.initializing)return;const{initial:m}=a,p=(n=this.overlay)!=null?n:g,b=_n(p),_=_n(g),$=!Hc(g,p),O=new ct(g,{frameTransform:$?_:null,ignoreTransforms:!$}),D={x:_.scaleX/b.scaleX,y:_.scaleY/b.scaleY};let{width:M,height:I,top:K,left:z}=O;$&&(M=M/D.x,I=I/D.y);const C=new Rf(p),W=ht(g),{transition:Y,translate:ve,boxSizing:Me,paddingBlockStart:se,paddingBlockEnd:Le,paddingInlineStart:Ve,paddingInlineEnd:Te,borderInlineStartWidth:Ye,borderInlineEndWidth:Ge,borderBlockStartWidth:We,borderBlockEndWidth:Xe}=W,Se=Y.split(",").filter(Z=>!/^\s*(transform|translate|scale)\b/.test(Z)).join(","),ue=Ri(W),L=W.transform,V=x==="clone",_e=Me==="content-box",X=_e?parseInt(Ve)+parseInt(Te)+parseInt(Ye)+parseInt(Ge):0,ze=_e?parseInt(se)+parseInt(Le)+parseInt(We)+parseInt(Xe):0,te=x!=="move"&&!this.overlay?lh(h,V?"clone":"hidden"):null,at=U(()=>br(l.dragOperation.activatorEvent));if(!m.translate){if(this.overlay&&ue)m.translate={x:ue.x,y:ue.y};else if(ve!=="none"){const Z=yr(ve);Z&&(m.translate=Z)}}if(!m.transformOrigin){const Z=U(()=>d.current),R=z+((r=ue?.x)!=null?r:0),ee=K+((i=ue?.y)!=null?i:0);m.transformOrigin={x:(Z.x-R*b.scaleX-b.x)/(M*b.scaleX),y:(Z.y-ee*b.scaleY-b.y)/(I*b.scaleY)}}const{transformOrigin:Fe}=m,xt=K*b.scaleY+b.y,T=z*b.scaleX+b.x;if(!m.coordinates&&(m.coordinates={x:T,y:xt},D.x!==1||D.y!==1)){const{scaleX:Z,scaleY:R}=_,{x:ee,y:Ee}=Fe;m.coordinates.x+=(M*Z-M)*ee,m.coordinates.y+=(I*R-I)*Ee}m.dimensions||(m.dimensions={width:M,height:I}),m.frameTransform||(m.frameTransform=b);const A={x:m.coordinates.x-T,y:m.coordinates.y-xt},G={width:(m.dimensions.width*m.frameTransform.scaleX-M*b.scaleX)*Fe.x,height:(m.dimensions.height*m.frameTransform.scaleY-I*b.scaleY)*Fe.y},E={x:A.x/b.scaleX+G.width,y:A.y/b.scaleY+G.height},P={left:z+E.x,top:K+E.y};p.setAttribute(lt,"true");const B=U(()=>c.transform),Q=(s=m.translate)!=null?s:{x:0,y:0},Ue=B.x*b.scaleX+Q.x,ke=B.y*b.scaleY+Q.y,ie=wc();C.set({width:M-X,height:I-ze,top:P.top+ie.y,left:P.left+ie.x,translate:`${Ue}px ${ke}px 0`,transform:this.overlay?"none":L,transition:Se?`${Se}, translate 0ms linear`:"translate 0ms linear",scale:$?`${D.x} ${D.y}`:"","transform-origin":`${Fe.x*100}% ${Fe.y*100}%`},Oe),te&&(g.insertAdjacentElement("afterend",te),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(h):u.rootElement).appendChild(g)),Ds(p)&&(p.hasAttribute("popover")||p.setAttribute("popover","manual"),vn(p),p.addEventListener("beforetoggle",Sa));let $e,Qt,Ct;const Rr=ph({placeholder:te,element:g,feedbackElement:p,frameTransform:b,transformOrigin:Fe,width:M,height:I,top:K,left:z,widthOffset:X,heightOffset:ze,delta:E,styles:C,dragOperation:c,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>$e,getSavedCellWidths:()=>Ct,setSavedCellWidths:Z=>{Ct=Z}}),Pt=new ct(p);U(()=>c.shape=Pt);const Zt=Ke(p),Wn=Z=>{this.manager.actions.stop({event:Z})},na=Ao(Zt);at&&Zt.addEventListener("resize",Wn),U(()=>h.status)==="idle"&&requestAnimationFrame(()=>h.status="dragging"),te&&(Rr.observe(te),$e=fh(g,te,V),Qt=hh(g,te,p));const Lr=(o=l.dragOperation.source)==null?void 0:o.id,zn=()=>{var Z;if(!at||Lr==null)return;const R=l.registry.draggables.get(Lr),ee=(Z=R?.handle)!=null?Z:R?.element;Dt(ee)&&ee.focus()},Fn=()=>{$e?.disconnect(),Qt?.disconnect(),Rr.disconnect(),Zt.removeEventListener("resize",Wn),Ds(p)&&(p.removeEventListener("beforetoggle",Sa),p.removeAttribute("popover")),p.removeAttribute(lt),C.reset();const Z=()=>{var R;if(Ct&&js(g)){const fe=Array.from(g.cells);for(const[oe,Jt]of fe.entries())Jt.style.width=(R=Ct[oe])!=null?R:""}h.status="idle";const ee=a.current.translate!=null,Ee=c.status.dragging;te&&(!Ee&&ee||te.parentElement!==p.parentElement)&&p.isConnected&&te.replaceWith(p),te?.remove()};p===this.overlay?setTimeout(Z,0):Z()},Vi=u?.dropAnimation,Nn=this,Gi=$r(()=>{var Z,R,ee;const{transform:Ee,status:fe}=c;if(!(!Ee.x&&!Ee.y&&!a.current.translate)&&fe.dragging){const oe=(Z=m.translate)!=null?Z:{x:0,y:0},Jt={x:Ee.x/b.scaleX+oe.x,y:Ee.y/b.scaleY+oe.y},ra=a.current.translate,Zd=U(()=>c.modifiers),Ui=U(()=>{var Vn;return(Vn=c.shape)==null?void 0:Vn.current}),Bn=u?.keyboardTransition,ia=at&&!na&&Bn!==null?`${(R=Bn?.duration)!=null?R:250}ms ${(ee=Bn?.easing)!=null?ee:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(C.set({transition:Se?`${Se}, translate ${ia}`:`translate ${ia}`,translate:`${Jt.x}px ${Jt.y}px 0`},Oe),$e?.takeRecords(),Ui&&Ui!==Pt&&ra&&!Zd.length){const Vn=Ze.delta(Jt,ra);c.shape=dt.from(Ui.boundingRectangle).translate(Vn.x*b.scaleX,Vn.y*b.scaleY)}else c.shape=new ct(p);a.current.translate=Jt}},function(){if(c.status.dropped){this.dispose(),h.status="dropping";const Z=v?.dropAnimation!==void 0?v.dropAnimation:Nn.dropAnimation!==void 0?Nn.dropAnimation:Vi;let R=a.current.translate;const ee=R!=null;if(!R&&g!==p&&(R={x:0,y:0}),!R||Z===null){Fn();return}l.renderer.rendering.then(()=>{mh({source:h,element:g,feedbackElement:p,placeholder:te,translate:R,moved:ee,transition:Y,alignment:h.alignment,styles:C,animation:Z??void 0,getElementMutationObserver:()=>$e,cleanup:Fn,restoreFocus:zn})})}});return()=>{Fn(),Gi()}};nt(wr,4,"overlay",qc,Sn,Bo);Xt(wr,Sn);Sn.configure=Or(Sn);var Vo=Sn,Gn=!0,yh=!1,Xc,Qc,Zc,Jc,St,Go,Uo;Jc=(Zc=[H],Je.Forward),Qc=(Xc=[H],Je.Reverse);var _r=class{constructor(){ge(this,Go,we(St,8,this,Gn)),we(St,11,this),ge(this,Uo,we(St,12,this,Gn)),we(St,15,this)}isLocked(e){return e===Je.Idle?!1:e==null?this[Je.Forward]===Gn&&this[Je.Reverse]===Gn:this[e]===Gn}unlock(e){e!==Je.Idle&&(this[e]=yh)}};St=Rn(null);Go=new WeakMap;Uo=new WeakMap;nt(St,4,Jc,Zc,_r,Go);nt(St,4,Qc,Xc,_r,Uo);Xt(St,_r);var bh=[Je.Forward,Je.Reverse],$a=class{constructor(){this.x=new _r,this.y=new _r}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},xh=class extends Pe{constructor(e){super(e);const t=En(new $a);let n=null;this.signal=t,tt(()=>{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:Ea(i.x,n.x),y:Ea(i.y,n.y)},o=t.peek();de(()=>{for(const a of Dl)for(const l of bh)s[a]===l&&o[a].unlock(l);t.value=o})}n=i})}get current(){return this.signal.peek()}};function Ea(e,t){return Math.sign(e-t)}var ed,Rs,kr,Ho,_t,Ls,Pr=class extends(Rs=Dr,ed=[H],Rs){constructor(e){super(e),ge(this,Ho,we(kr,8,this,!1)),we(kr,11,this),ge(this,_t),ge(this,Ls,()=>{if(!ne(this,_t))return;const{element:s,by:o}=ne(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 Ae(this,_t,void 0),!1;const{position:u}=this.manager.dragOperation,c=u?.current;if(c){const{by:d}=s??{},h=d?{x:Oa(d.x),y:Oa(d.y)}:void 0,f=h?void 0:this.scrollIntentTracker.current;if(f?.isLocked())return!1;for(const g of l){const v=vf(g,d);if(v.x||v.y){const{speed:w,direction:x}=Of(g,c,h,o?.acceleration,o?.threshold);if(f)for(const m of Dl)f[m].isLocked(x[m])&&(w[m]=0,x[m]=0);if(x.x||x.y){const{x:m,y:p}=d??x,b=m*w.x,_=p*w.y;if(b||_){const $=(a=ne(this,_t))==null?void 0:a.by;if(this.autoScrolling&&$&&($.x&&!b||$.y&&!_))continue;return Ae(this,_t,{element:g,by:{x:b,y:_}}),mi.schedule(ne(this,Ls)),!0}}}}}return Ae(this,_t,void 0),!1};let t=null,n=null;const r=fs(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=_c(pi(o?.element),s.current);return a&&(t=a),a??t}),i=fs(()=>{const s=r.value,{documentElement:o}=jn(s);if(!s||s===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const u=Ts(l,{excludeElement:!1});return n=u,u}}if(s){const a=Ts(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},rt);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new xh(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!br(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};kr=Rn(Rs);Ho=new WeakMap;_t=new WeakMap;Ls=new WeakMap;nt(kr,4,"autoScrolling",ed,Pr,Ho);Xt(kr,Pr);function Oa(e){return e>0?Je.Forward:e<0?Je.Reverse:Je.Idle}var wh=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))}},_h=new wh(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),kh=10,Ws=class extends Pe{constructor(t,n){super(t,n);const r=t.registry.plugins.get(Pr);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=tt(()=>{var i,s,o;if(this.disabled)return;const{position:a,status:l}=t.dragOperation;if(l.dragging){const u={acceleration:(i=this.options)==null?void 0:i.acceleration,threshold:typeof((s=this.options)==null?void 0:s.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(o=this.options)==null?void 0:o.threshold};if(r.scroll(void 0,u)){r.autoScrolling=!0;const d=setInterval(()=>_h.schedule(()=>r.scroll(void 0,u)),kh);return()=>{clearInterval(d)}}else r.autoScrolling=!1}})}};Ws.configure=Or(Ws);var td=Ws,Da={capture:!0,passive:!0},nr,Sh=class extends Dr{constructor(e){super(e),ge(this,nr),this.handleScroll=()=>{ne(this,nr)==null&&Ae(this,nr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),Ae(this,nr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=tt(()=>{var n,r,i;if(t.status.dragging){const o=(i=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?i:document;return o.addEventListener("scroll",this.handleScroll,Da),()=>{o.removeEventListener("scroll",this.handleScroll,Da)}}})}};nr=new WeakMap;var $h="* { user-select: none !important; -webkit-user-select: none !important; }",Eh=class extends Pe{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Li),n=t?.register($h);if(this.destroy=tt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return Ji(),document.addEventListener("selectionchange",Ji,{capture:!0}),()=>{document.removeEventListener("selectionchange",Ji,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function Ji(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var rr=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}}),dn,_i=class extends bn{constructor(t,n){super(t),this.manager=t,this.options=n,ge(this,dn,[]),this.listeners=new kc,this.handleSourceKeyDown=(r,i,s)=>{if(this.disabled||r.defaultPrevented||!Vt(r.target)||i.disabled)return;const{keyboardCodes:o=rr.keyboardCodes,preventActivation:a=rr.preventActivation}=s??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(a?.(r,i)||this.handleStart(r,i,s))}}bind(t,n=this.options){return tt(()=>{var i;const s=(i=t.handle)!=null?i:t.element,o=a=>{br(a)&&this.handleSourceKeyDown(a,t,n)};if(s)return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:i}=n;if(!i)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),Cc(i);const{center:s}=new ct(i);if(this.manager.actions.start({event:t,coordinates:{x:s.x,y:s.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const a=jn(i),l=[this.listeners.bind(a,[{type:"keydown",listener:u=>this.handleKeyDown(u,n,r),options:{capture:!0}}])];ne(this,dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:i=rr.keyboardCodes}=r??{};if(en(t,[...i.end,...i.cancel])){t.preventDefault();const s=en(t,i.cancel);this.handleEnd(t,s);return}en(t,i.up)?this.handleMove("up",t):en(t,i.down)&&this.handleMove("down",t),en(t,i.left)?this.handleMove("left",t):en(t,i.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,i;const{shape:s}=this.manager.dragOperation,o=n.shiftKey?5:1;let a={x:0,y:0},l=(i=(r=this.options)==null?void 0:r.offset)!=null?i:rr.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!s){switch(t){case"up":a={x:0,y:-l.y*o};break;case"down":a={x:0,y:l.y*o};break;case"left":a={x:-l.x*o,y:0};break;case"right":a={x:l.x*o,y:0};break}(a.x||a.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:a}))}}sideEffects(){const t=this.manager.registry.plugins.get(td);t?.disabled===!1&&(t.disable(),ne(this,dn).push(()=>{t.enable()}))}cleanup(){ne(this,dn).forEach(t=>t()),Ae(this,dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};dn=new WeakMap;_i.configure=Or(_i);_i.defaults=rr;var nd=_i;function en(e,t){return t.includes(e.code)}var Wt,Oh=class extends oc{constructor(){super(...arguments),ge(this,Wt)}onEvent(e){switch(e.type){case"pointerdown":Ae(this,Wt,xn(e));break;case"pointermove":if(!ne(this,Wt))return;const{x:t,y:n}=xn(e),r={x:t-ne(this,Wt).x,y:n-ne(this,Wt).y},{tolerance:i}=this.options;if(i&&ws(r,i)){this.abort();return}ws(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){Ae(this,Wt,void 0)}};Wt=new WeakMap;var un,zt,Dh=class extends oc{constructor(){super(...arguments),ge(this,un),ge(this,zt)}onEvent(e){switch(e.type){case"pointerdown":Ae(this,zt,xn(e)),Ae(this,un,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!ne(this,zt))return;const{x:t,y:n}=xn(e),r={x:t-ne(this,zt).x,y:n-ne(this,zt).y};ws(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){ne(this,un)&&(clearTimeout(ne(this,un)),Ae(this,zt,void 0),Ae(this,un,void 0))}};un=new WeakMap;zt=new WeakMap;var gn=class{};gn.Delay=Dh;gn.Distance=Oh;var zs=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 gn.Delay({value:250,tolerance:5})]:Wf(i)&&!e.defaultPrevented?[new gn.Delay({value:200,tolerance:0})]:[new gn.Delay({value:200,tolerance:10}),new gn.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=sf(r);return i===t.element?!1:!!i}}),fn,ki=class extends bn{constructor(t,n){super(t),this.manager=t,this.options=n,ge(this,fn,new Set),this.listeners=new kc,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:i}=this.latest;!r||!i||this.manager.actions.move({event:r,to:i})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:i=zs.activationConstraints}=r??{};return typeof i=="function"?i(t,n):i}bind(t,n=this.options){return tt(()=>{var i;const s=new AbortController,{signal:o}=s,a=u=>{Lf(u)&&this.handlePointerDown(u,t,n)};let l=[(i=t.handle)!=null?i:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const u of l)u&&(Ph(u.ownerDocument.defaultView),u.addEventListener("pointerdown",a,{signal:o}));return()=>s.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!Vt(t.target)||n.disabled||Th(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:i=zs.preventActivation}=r??{};if(i?.(t,n))return;const{target:s}=t,o=Dt(s)&&s.draggable&&s.getAttribute("draggable")==="true",a=_n(n.element),{x:l,y:u}=xn(t);this.initialCoordinates={x:l*a.scaleX+a.x,y:u*a.scaleY+a.y};const c=this.activationConstraints(t,n,r);t.sensor=this;const d=new Yu(c,v=>this.handleStart(n,v));d.signal.onabort=()=>this.handleCancel(t),d.onEvent(t),this.controller=d;const h=$s(),f=this.listeners.bind(h,[{type:"pointermove",listener:v=>this.handlePointerMove(v,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Nr,options:{capture:!0}}]),g=()=>{f(),this.initialCoordinates=void 0};ne(this,fn).add(g)}handlePointerMove(t,n){var r,i;if(((r=this.controller)==null?void 0:r.activated)===!1){(i=this.controller)==null||i.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const s=xn(t),o=_n(n.element);s.x=s.x*o.scaleX+o.x,s.y=s.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=s,mi.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:i}=this;if(!i||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:i,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const a=jn(n.target).body;try{a.setPointerCapture(n.pointerId)}catch{this.handleCancel(n);return}const l=Vt(n.target)?[n.target,a]:a,u=this.listeners.bind(l,[{type:"touchmove",listener:Nr,options:{passive:!1}},{type:"click",listener:Nr},{type:"contextmenu",listener:Nr},{type:"keydown",listener:this.handleKeyDown}]);ne(this,fn).add(u)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){const{controller:t}=this;this.controller=void 0,t&&!t.signal.aborted&&t.abort(),this.latest={event:void 0,coordinates:void 0},ne(this,fn).forEach(n=>n()),ne(this,fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};fn=new WeakMap;ki.configure=Or(ki);ki.defaults=zs;var Fs=ki;function Th(e){return"sensor"in e}function Nr(e){e.preventDefault()}function Ch(){}var Ta=new WeakSet;function Ph(e){!e||Ta.has(e)||(e.addEventListener("touchmove",Ch,{capture:!1,passive:!1}),Ta.add(e))}var mn={modifiers:[],plugins:[nh,td,ih,Vo,Eh],sensors:[Fs,nd]},rd=class extends Zu{constructor(e={}){const t=st(e.plugins,mn.plugins),n=st(e.sensors,mn.sensors),r=st(e.modifiers,mn.modifiers);super(zo(xr({},e),{plugins:[Sh,Pr,Li,...t],sensors:n,modifiers:r}))}},id,sd,Ns,$t,qo,Ko,Wi=class extends(Ns=ut,sd=[H],id=[H],Ns){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=Rc(n,["element","effects","handle"]);super(xr({effects:()=>[...i(),()=>{var a,l;const{manager:u}=this;if(!u)return;const d=((l=(a=this.sensors)==null?void 0:a.map(gr))!=null?l:[...u.sensors]).map(h=>{const f=h instanceof bn?h:u.registry.register(h.plugin),g=h instanceof bn?void 0:h.options;return f.bind(this,g)});return function(){d.forEach(f=>f())}}]},o),t),ge(this,qo,we($t,8,this)),we($t,11,this),ge(this,Ko,we($t,12,this)),we($t,15,this),this.element=r,this.handle=s}};$t=Rn(Ns);qo=new WeakMap;Ko=new WeakMap;nt($t,4,"handle",sd,Wi,qo);nt($t,4,"element",id,Wi,Ko);Xt($t,Wi);var od,ad,Bs,Et,Yo,es,ld,cd,pr,Xo,zi=class extends(Bs=ft,ad=[H],od=[H],Bs){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=Rc(n,["element","effects"]);const{collisionDetector:o=Mc}=s,a=u=>{const{manager:c,element:d}=this;if(!d||u===null){this.shape=void 0;return}if(!c)return;const h=new ct(d),f=U(()=>this.shape);return h&&f?.equals(h)?f:(this.shape=h,h)},l=En(!1);super(zo(xr({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:u,manager:c}=this;if(!c)return;const{dragOperation:d}=c,{source:h}=d;l.value=!!(h&&d.status.initialized&&u&&!this.disabled&&this.accepts(h))},()=>{const{element:u}=this;if(l.value&&u){const c=new gf(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,pr),ge(this,Yo,we(Et,8,this)),we(Et,11,this),ge(this,Xo,we(Et,12,this)),we(Et,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){Ae(this,pr,e,cd)}get element(){var e;return(e=this.proxy)!=null?e:ne(this,pr,ld)}};Et=Rn(Bs);Yo=new WeakMap;pr=new WeakSet;Xo=new WeakMap;es=nt(Et,20,"#element",ad,pr,Yo),ld=es.get,cd=es.set;nt(Et,4,"proxy",od,zi,Xo);Xt(Et,zi);function Mh(e){return e!=null&&typeof e=="object"&&"current"in e}function yn(e){var t;if(e!=null)return Mh(e)?(t=e.current)!=null?t:void 0:e}var Ih=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ln=Ih?S.useLayoutEffect:S.useEffect;function jh(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function dd(e,t){const n=S.useRef(new Map),r=jh();return Ln(()=>{if(!e){n.current.clear();return}return tt(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[l]=a,u=U(()=>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(()=>su.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 Ah(e,t){e()}function tn(e){const t=S.useRef(e);return Ln(()=>{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 si(e,t){const n=S.useRef(yn(e));Ln(()=>{const r=yn(e);r!==n.current&&(n.current=r,t(r))})}var Rh=Object.defineProperty,Lh=Object.defineProperties,Wh=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertySymbols,ud=Object.prototype.hasOwnProperty,fd=Object.prototype.propertyIsEnumerable,Ca=(e,t,n)=>t in e?Rh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zh=(e,t)=>{for(var n in t||(t={}))ud.call(t,n)&&Ca(e,n,t[n]);if(Si)for(var n of Si(t))fd.call(t,n)&&Ca(e,n,t[n]);return e},Fh=(e,t)=>Lh(e,Wh(t)),Nh=(e,t)=>{var n={};for(var r in e)ud.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Si)for(var r of Si(e))t.indexOf(r)<0&&fd.call(e,r)&&(n[r]=e[r]);return n},Bh=new rd,hd=S.createContext(Bh),Vh=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 Ln(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),ts=[void 0,rt];function Gh(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=Nh(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const c=S.useRef(null),{plugins:d,modifiers:h,sensors:f}=u,g=st(d,mn.plugins),v=st(f,mn.sensors),w=st(h,mn.modifiers),x=tn(i),m=tn(s),p=tn(a),b=tn(o),_=tn(l),$=tn(r),O=Uh(()=>{var D;return(D=u.manager)!=null?D:new rd(u)});return S.useEffect(()=>{if(!c.current)throw new Error("Renderer not found");const{renderer:D,trackRendering:M}=c.current,{monitor:I}=O;O.renderer=D;const K=[I.addEventListener("beforedragstart",z=>{const C=x.current;C&&M(()=>C(z,O))}),I.addEventListener("dragstart",z=>{var C;return(C=m.current)==null?void 0:C.call(m,z,O)}),I.addEventListener("dragover",z=>{const C=p.current;C&&M(()=>C(z,O))}),I.addEventListener("dragmove",z=>{const C=b.current;C&&M(()=>C(z,O))}),I.addEventListener("dragend",z=>{const C=_.current;C&&M(()=>C(z,O))}),I.addEventListener("collision",z=>{var C;return(C=$.current)==null?void 0:C.call($,z,O)})];return()=>K.forEach(z=>z())},[O]),ae(g,()=>O&&(O.plugins=g),...ts),ae(v,()=>O&&(O.sensors=v),...ts),ae(w,()=>O&&(O.modifiers=w),...ts),y.jsxs(hd.Provider,{value:O,children:[y.jsx(Vh,{ref:c,children:n}),n]})}function Uh(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 Hh(){return S.useContext(hd)}function pd(e){var t;const n=(t=Hh())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ln(r.register,[n,r]),r}var qh=Object.create,gd=Object.defineProperty,Kh=Object.getOwnPropertyDescriptor,vd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Fi=e=>{throw TypeError(e)},Yh=(e,t,n)=>t in e?gd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xh=e=>{var t;return[,,,qh((t=e?.[vd("metadata")])!=null?t:null)]},md=["class","method","getter","setter","accessor","field","value","get","set"],yd=e=>e!==void 0&&typeof e!="function"?Fi("Function expected"):e,Qh=(e,t,n,r,i)=>({kind:md[e],name:t,metadata:r,addInitializer:s=>n._?Fi("Already initialized"):i.push(yd(s||null))}),Zh=(e,t)=>Yh(t,vd("metadata"),e[3]),Jh=(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},bd=(e,t,n,r,i,s)=>{for(var o,a,l,u,c=t&7,d=!1,h=!1,f=2,g=md[c+5],v=e[f]||(e[f]=[]),w=(i=i.prototype,Kh(i,n)),x=r.length-1;x>=0;x--)l=Qh(c,n,a={},e[3],v),l.static=d,l.private=h,u=l.access={has:m=>n in m},u.get=m=>m[n],o=(0,r[x])(w[g],l),a._=1,yd(o)&&(w[g]=o);return w&&gd(i,n,w),i},xd=(e,t,n)=>t.has(e)||Fi("Cannot "+n),ep=(e,t,n)=>(xd(e,t,"read from private field"),t.get(e)),tp=(e,t,n)=>t.has(e)?Fi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),np=(e,t,n,r)=>(xd(e,t,"write to private field"),t.set(e,n),n),Nt=class Vs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Vs(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 Vs(t,n)}},wd,_d,Gs,oi,Mr,Qo=class extends(Gs=Kt,_d=[pe],wd=[pe],Gs){constructor(e){const t=Nt.from(e);super(t,(n,r)=>Nt.equals(n,r)),Jh(Mr,5,this),tp(this,oi,0),this.velocity={x:0,y:0}}get delta(){return Nt.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=Nt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-ep(this,oi),o=a=>Math.round(a/s*100);de(()=>{np(this,oi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Nt.from(e)),this.velocity={x:0,y:0}}};Mr=Xh(Gs);oi=new WeakMap;bd(Mr,2,"delta",_d,Qo);bd(Mr,2,"direction",wd,Qo);Zh(Mr,Qo);var kd=(e=>(e.Horizontal="x",e.Vertical="y",e))(kd||{});Object.values(kd);var rp=({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=Nt.distance(t.shape.center,n);return{id:r,value:1/i,type:In.PointerIntersection,priority:Mn.High}}return null},ip=({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=Nt.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:In.ShapeIntersection,priority:Mn.Normal}}return null},sp=e=>{var t;return(t=rp(e))!=null?t:ip(e)};function op(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,l=pd(c=>new zi(Fh(zh({},e),{register:!1,element:yn(i)}),c)),u=dd(l);return ae(s,()=>l.id=s),si(i,c=>l.element=c),ae(o,()=>l.accept=o,void 0,rt),ae(t,()=>l.collisionDetector=t??sp),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,h;!c&&((d=l.element)!=null&&d.isConnected)&&!((h=l.manager)!=null&&h.dragOperation.status.idle)||(l.element=c??void 0)},[l])}}function ap(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 $i(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function lp(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function ai(e,t){const n=lp(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 Pa(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 cp(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const dp=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function up(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",i=/^[A-Z_]/.test(r)?r:`F_${r}`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const Ma=[{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 Br(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 Us=e=>e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function fp(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}:$i(t.type)!==void 0?{op:$i(t.type)}:{}}})}function hp(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!Us(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 pp(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 gp(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 vp=j.createSvgIcon(y.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),mp=j.createSvgIcon(y.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"})),yp=j.createSvgIcon(y.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"})),bp=j.createSvgIcon(y.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"})),Hs=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),ns=Hs?"⌘":"Ctrl+",xp=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function wp(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=Hs?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!xp(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!Hs&&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 _p({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,actions:a,onAddTile:l,onSettings:u}){const{theme:c}=Be.usePublisherTheme();return y.jsxs(j.DashboardBar,{left:y.jsx(k.Chip,{size:"medium",variant:"outlined",icon:y.jsx(mp,{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&&y.jsx(k.Button,{startIcon:y.jsx(j.AddIcon,{}),onClick:l,"aria-label":"Add tile",children:"Tile"}),y.jsx(k.Button,{startIcon:y.jsx(vp,{}),onClick:d=>u(d.currentTarget),children:"Settings"}),y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),y.jsx(k.Tooltip,{title:`Undo (${ns}Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:y.jsx(bp,{fontSize:"small"})})})}),y.jsx(k.Tooltip,{title:`Redo (${ns}⇧Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:y.jsx(yp,{fontSize:"small"})})})}),o&&y.jsx(y.Fragment,{children:y.jsx(k.Tooltip,{title:i?`Save (${ns}S)`:"",children:y.jsx("span",{children:y.jsx(k.Button,{variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{minWidth:124},children:s?"Saving…":i?"Save changes":"Saved"})})})}),a&&y.jsxs(y.Fragment,{children:[y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const kp=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"];function Vr(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function Ia(e){for(const t of e??[]){const n=/^#\s*([a-z_]+)/.exec(t.trim())?.[1];if(n&&kp.includes(n))return n}}const Sp=1;function Sd(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(...Sd(a,`${t}${s}.`,n-1))}}}return r}function $p(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,Sd(i.schema?.fields,"",Sp))}return t}function ja(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const Ep=e=>(e??"").startsWith("dashboards/"),Op=e=>e.modelPath??e.path??"";function $d(e){const t=[],n=new Set;for(const r of e){const i=Op(r);if(Ep(i))continue;const s=$p(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,...Vr(o.annotations)?{description:Vr(o.annotations)}:{},views:(o.views??[]).filter(u=>typeof u.name=="string").map(u=>({name:u.name,...Vr(u.annotations)?{description:Vr(u.annotations)}:{},...Ia(u.annotations)?{chart:Ia(u.annotations)}:{}})),givens:l,fields:s.get(a)??[]})}}return{sources:t}}const pt=e=>`${e.source}.${e.name}`;function Dp(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 Tp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=Be.usePublisherTheme(),a=S.useMemo(()=>Dp(t,n),[t,n]),[l,u]=S.useState(""),[c,d]=S.useState(""),[h,f]=S.useState(""),[g,v]=S.useState(Math.ceil(r/2));S.useEffect(()=>{e&&(u(t.sources[0]?.base??a[0]?.name??""),d(""),f(""),v(Math.ceil(r/2)))},[e,t,a,r]);const w=a.find(m=>m.name===l),x=l!==""&&c!=="";return y.jsx(j.AppDialog,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of one source this dashboard imports.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",disabled:!x,onClick:()=>s({base:l,view:c,...h.trim()?{label:h.trim()}:{},colspan:g}),children:"Add tile"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:a.length===0?y.jsx(k.Typography,{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."}):y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Source",value:l,onChange:m=>{u(m.target.value),d("")},inputProps:{"aria-label":"Source"},children:a.map(m=>y.jsxs(k.MenuItem,{value:m.name,children:[m.name,m.description&&y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:m.description})]},m.name))}),y.jsxs(k.Box,{children:[y.jsx(k.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),y.jsxs(k.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(m=>y.jsxs(k.ListItemButton,{selected:c===m.name,onClick:()=>d(m.name),"aria-label":`View ${m.name}`,children:[y.jsx(k.ListItemText,{primary:m.name,secondary:m.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),m.chart&&y.jsx(k.Chip,{size:"small",variant:"outlined",label:m.chart.replace(/_chart$/,"")})]},m.name)),w&&w.views.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{p:1.5,color:o.tileTitle},children:"This source declares no views."})]})]}),y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:h,onChange:m=>f(m.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}}),y.jsx(k.TextField,{size:"small",type:"number",label:`Width (of ${r})`,value:g,onChange:m=>v(Math.min(Math.max(Number(m.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})})})}const Aa=4e3;function Cp(e,t){const n=e.split(`
67
+ `.replace(/\n+/g," ").replace(/\s+/g," ").trim();function ch(e,t="hidden"){return U(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=dh(n,r.registry.droppables),s=[],o=rf(n),{remove:a}=o;return uh(i,o,s),fh(o,t),o.remove=()=>{s.forEach(l=>l()),a.call(o)},o})}function dh(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${Cr}${Cs("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function uh(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),Es.set(a,o),n.push(()=>{Es.delete(a),r.proxy=void 0})}}function fh(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(wi,t)}function Hc(e,t){return e===t?!0:wn(e)===wn(t)}function Sa(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Vt(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>vn(t))}function js(e){return e.tagName==="TR"}function hh(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-")||oh.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(fr(e)&&fr(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(ah.includes(c)||c.startsWith(De))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 ph(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),vn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),vn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),vn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function gh(e){return new ResizeObserver(()=>{var t,n,r;const i=new ct(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=wc();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},De),(n=e.getElementMutationObserver())==null||n.takeRecords(),js(e.element)&&js(e.placeholder)){const v=Array.from(e.element.cells),w=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(v.map(x=>x.style.width));for(const[x,m]of v.entries()){const p=w[x];m.style.width=`${p.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,h=i.width-e.widthOffset,f=i.height-e.heightOffset,g=e.frameTransform;e.dragOperation.shape=new dt(c*g.scaleX+g.x,d*g.scaleY+g.y,h*g.scaleX,f*g.scaleY)})}var vh=250,mh="ease";function yh(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const m=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(m).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=vh,easing:a=mh}=s??{};vn(e.feedbackElement);const[,l]=(t=yc(e.feedbackElement,m=>"translate"in m))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,c={frameTransform:Hc(e.feedbackElement,u)?null:void 0},d=new ct(e.feedbackElement,c),h=(r=yr(ht(e.feedbackElement).translate))!=null?r:e.translate,f=new ct(u,c),g=dt.delta(d,f,e.alignment),v={x:h.x-g.x,y:h.y-g.y},w=Math.round(d.intrinsicHeight)!==Math.round(f.intrinsicHeight)?{minHeight:[`${d.intrinsicHeight}px`,`${f.intrinsicHeight}px`],maxHeight:[`${d.intrinsicHeight}px`,`${f.intrinsicHeight}px`]}:{},x=Math.round(d.intrinsicWidth)!==Math.round(f.intrinsicWidth)?{minWidth:[`${d.intrinsicWidth}px`,`${f.intrinsicWidth}px`],maxWidth:[`${d.intrinsicWidth}px`,`${f.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},De),e.feedbackElement.setAttribute(Is,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),Pc({element:e.feedbackElement,keyframes:zo(xr(xr({},w),x),{translate:[`${h.x}px ${h.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:Ao(Ke(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(Is),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var qc,As,wr,Bo,ii,Kc,Yc,Sn=class extends(As=Me,qc=[H],As){constructor(t,n){super(t,n),ve(this,ii),ve(this,Bo,we(wr,8,this)),we(wr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(Li),i=r?.register(lh);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}this.registerEffect(Gt(this,ii,Kc).bind(this,r)),this.registerEffect(Gt(this,ii,Yc))}};wr=Rn(As);Bo=new WeakMap;ii=new WeakSet;Kc=function(e){const{overlay:t}=this;if(!t||!e)return;const n=pi(t);if(n)return e.addRoot(n)};Yc=function(){var e,t,n,r,i,s,o;const{state:a,manager:l,options:u}=this,{dragOperation:c}=l,{position:d,source:h,status:f}=c;if(f.idle){a.current={},a.initial={};return}if(!h)return;const{element:g}=h,v=h.pluginConfig(Sn),w=(t=(e=v?.feedback)!=null?e:u?.feedback)!=null?t:"default",x=typeof w=="function"?w(h,l):w;if(!g||x==="none"||!f.initialized||f.initializing)return;const{initial:m}=a,p=(n=this.overlay)!=null?n:g,b=_n(p),_=_n(g),$=!Hc(g,p),O=new ct(g,{frameTransform:$?_:null,ignoreTransforms:!$}),D={x:_.scaleX/b.scaleX,y:_.scaleY/b.scaleY};let{width:M,height:I,top:K,left:W}=O;$&&(M=M/D.x,I=I/D.y);const T=new Lf(p),z=ht(g),{transition:Y,translate:ne,boxSizing:Se,paddingBlockStart:oe,paddingBlockEnd:Le,paddingInlineStart:Ve,paddingInlineEnd:Ce,borderInlineStartWidth:Ye,borderInlineEndWidth:Ge,borderBlockStartWidth:We,borderBlockEndWidth:Xe}=z,$e=Y.split(",").filter(Z=>!/^\s*(transform|translate|scale)\b/.test(Z)).join(","),fe=Ri(z),L=z.transform,V=x==="clone",_e=Se==="content-box",X=_e?parseInt(Ve)+parseInt(Ce)+parseInt(Ye)+parseInt(Ge):0,ze=_e?parseInt(oe)+parseInt(Le)+parseInt(We)+parseInt(Xe):0,te=x!=="move"&&!this.overlay?ch(h,V?"clone":"hidden"):null,at=U(()=>br(l.dragOperation.activatorEvent));if(!m.translate){if(this.overlay&&fe)m.translate={x:fe.x,y:fe.y};else if(ne!=="none"){const Z=yr(ne);Z&&(m.translate=Z)}}if(!m.transformOrigin){const Z=U(()=>d.current),R=W+((r=fe?.x)!=null?r:0),ee=K+((i=fe?.y)!=null?i:0);m.transformOrigin={x:(Z.x-R*b.scaleX-b.x)/(M*b.scaleX),y:(Z.y-ee*b.scaleY-b.y)/(I*b.scaleY)}}const{transformOrigin:Fe}=m,xt=K*b.scaleY+b.y,C=W*b.scaleX+b.x;if(!m.coordinates&&(m.coordinates={x:C,y:xt},D.x!==1||D.y!==1)){const{scaleX:Z,scaleY:R}=_,{x:ee,y:Oe}=Fe;m.coordinates.x+=(M*Z-M)*ee,m.coordinates.y+=(I*R-I)*Oe}m.dimensions||(m.dimensions={width:M,height:I}),m.frameTransform||(m.frameTransform=b);const A={x:m.coordinates.x-C,y:m.coordinates.y-xt},G={width:(m.dimensions.width*m.frameTransform.scaleX-M*b.scaleX)*Fe.x,height:(m.dimensions.height*m.frameTransform.scaleY-I*b.scaleY)*Fe.y},E={x:A.x/b.scaleX+G.width,y:A.y/b.scaleY+G.height},P={left:W+E.x,top:K+E.y};p.setAttribute(lt,"true");const B=U(()=>c.transform),Q=(s=m.translate)!=null?s:{x:0,y:0},Ue=B.x*b.scaleX+Q.x,ke=B.y*b.scaleY+Q.y,se=wc();T.set({width:M-X,height:I-ze,top:P.top+se.y,left:P.left+se.x,translate:`${Ue}px ${ke}px 0`,transform:this.overlay?"none":L,transition:$e?`${$e}, translate 0ms linear`:"translate 0ms linear",scale:$?`${D.x} ${D.y}`:"","transform-origin":`${Fe.x*100}% ${Fe.y*100}%`},De),te&&(g.insertAdjacentElement("afterend",te),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(h):u.rootElement).appendChild(g)),Ds(p)&&(p.hasAttribute("popover")||p.setAttribute("popover","manual"),vn(p),p.addEventListener("beforetoggle",Sa));let Ee,Qt,Ct;const Rr=gh({placeholder:te,element:g,feedbackElement:p,frameTransform:b,transformOrigin:Fe,width:M,height:I,top:K,left:W,widthOffset:X,heightOffset:ze,delta:E,styles:T,dragOperation:c,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>Ee,getSavedCellWidths:()=>Ct,setSavedCellWidths:Z=>{Ct=Z}}),Pt=new ct(p);U(()=>c.shape=Pt);const Zt=Ke(p),Wn=Z=>{this.manager.actions.stop({event:Z})},na=Ao(Zt);at&&Zt.addEventListener("resize",Wn),U(()=>h.status)==="idle"&&requestAnimationFrame(()=>h.status="dragging"),te&&(Rr.observe(te),Ee=hh(g,te,V),Qt=ph(g,te,p));const Lr=(o=l.dragOperation.source)==null?void 0:o.id,zn=()=>{var Z;if(!at||Lr==null)return;const R=l.registry.draggables.get(Lr),ee=(Z=R?.handle)!=null?Z:R?.element;Dt(ee)&&ee.focus()},Fn=()=>{Ee?.disconnect(),Qt?.disconnect(),Rr.disconnect(),Zt.removeEventListener("resize",Wn),Ds(p)&&(p.removeEventListener("beforetoggle",Sa),p.removeAttribute("popover")),p.removeAttribute(lt),T.reset();const Z=()=>{var R;if(Ct&&js(g)){const he=Array.from(g.cells);for(const[ae,Jt]of he.entries())Jt.style.width=(R=Ct[ae])!=null?R:""}h.status="idle";const ee=a.current.translate!=null,Oe=c.status.dragging;te&&(!Oe&&ee||te.parentElement!==p.parentElement)&&p.isConnected&&te.replaceWith(p),te?.remove()};p===this.overlay?setTimeout(Z,0):Z()},Vi=u?.dropAnimation,Nn=this,Gi=$r(()=>{var Z,R,ee;const{transform:Oe,status:he}=c;if(!(!Oe.x&&!Oe.y&&!a.current.translate)&&he.dragging){const ae=(Z=m.translate)!=null?Z:{x:0,y:0},Jt={x:Oe.x/b.scaleX+ae.x,y:Oe.y/b.scaleY+ae.y},ra=a.current.translate,Jd=U(()=>c.modifiers),Ui=U(()=>{var Vn;return(Vn=c.shape)==null?void 0:Vn.current}),Bn=u?.keyboardTransition,ia=at&&!na&&Bn!==null?`${(R=Bn?.duration)!=null?R:250}ms ${(ee=Bn?.easing)!=null?ee:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(T.set({transition:$e?`${$e}, translate ${ia}`:`translate ${ia}`,translate:`${Jt.x}px ${Jt.y}px 0`},De),Ee?.takeRecords(),Ui&&Ui!==Pt&&ra&&!Jd.length){const Vn=Ze.delta(Jt,ra);c.shape=dt.from(Ui.boundingRectangle).translate(Vn.x*b.scaleX,Vn.y*b.scaleY)}else c.shape=new ct(p);a.current.translate=Jt}},function(){if(c.status.dropped){this.dispose(),h.status="dropping";const Z=v?.dropAnimation!==void 0?v.dropAnimation:Nn.dropAnimation!==void 0?Nn.dropAnimation:Vi;let R=a.current.translate;const ee=R!=null;if(!R&&g!==p&&(R={x:0,y:0}),!R||Z===null){Fn();return}l.renderer.rendering.then(()=>{yh({source:h,element:g,feedbackElement:p,placeholder:te,translate:R,moved:ee,transition:Y,alignment:h.alignment,styles:T,animation:Z??void 0,getElementMutationObserver:()=>Ee,cleanup:Fn,restoreFocus:zn})})}});return()=>{Fn(),Gi()}};nt(wr,4,"overlay",qc,Sn,Bo);Xt(wr,Sn);Sn.configure=Or(Sn);var Vo=Sn,Gn=!0,bh=!1,Xc,Qc,Zc,Jc,St,Go,Uo;Jc=(Zc=[H],Je.Forward),Qc=(Xc=[H],Je.Reverse);var _r=class{constructor(){ve(this,Go,we(St,8,this,Gn)),we(St,11,this),ve(this,Uo,we(St,12,this,Gn)),we(St,15,this)}isLocked(e){return e===Je.Idle?!1:e==null?this[Je.Forward]===Gn&&this[Je.Reverse]===Gn:this[e]===Gn}unlock(e){e!==Je.Idle&&(this[e]=bh)}};St=Rn(null);Go=new WeakMap;Uo=new WeakMap;nt(St,4,Jc,Zc,_r,Go);nt(St,4,Qc,Xc,_r,Uo);Xt(St,_r);var xh=[Je.Forward,Je.Reverse],$a=class{constructor(){this.x=new _r,this.y=new _r}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},wh=class extends Me{constructor(e){super(e);const t=En(new $a);let n=null;this.signal=t,tt(()=>{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:Ea(i.x,n.x),y:Ea(i.y,n.y)},o=t.peek();ue(()=>{for(const a of Dl)for(const l of xh)s[a]===l&&o[a].unlock(l);t.value=o})}n=i})}get current(){return this.signal.peek()}};function Ea(e,t){return Math.sign(e-t)}var ed,Rs,kr,Ho,_t,Ls,Pr=class extends(Rs=Dr,ed=[H],Rs){constructor(e){super(e),ve(this,Ho,we(kr,8,this,!1)),we(kr,11,this),ve(this,_t),ve(this,Ls,()=>{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 Ae(this,_t,void 0),!1;const{position:u}=this.manager.dragOperation,c=u?.current;if(c){const{by:d}=s??{},h=d?{x:Oa(d.x),y:Oa(d.y)}:void 0,f=h?void 0:this.scrollIntentTracker.current;if(f?.isLocked())return!1;for(const g of l){const v=mf(g,d);if(v.x||v.y){const{speed:w,direction:x}=Df(g,c,h,o?.acceleration,o?.threshold);if(f)for(const m of Dl)f[m].isLocked(x[m])&&(w[m]=0,x[m]=0);if(x.x||x.y){const{x:m,y:p}=d??x,b=m*w.x,_=p*w.y;if(b||_){const $=(a=re(this,_t))==null?void 0:a.by;if(this.autoScrolling&&$&&($.x&&!b||$.y&&!_))continue;return Ae(this,_t,{element:g,by:{x:b,y:_}}),mi.schedule(re(this,Ls)),!0}}}}}return Ae(this,_t,void 0),!1};let t=null,n=null;const r=fs(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=_c(pi(o?.element),s.current);return a&&(t=a),a??t}),i=fs(()=>{const s=r.value,{documentElement:o}=jn(s);if(!s||s===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const u=Ts(l,{excludeElement:!1});return n=u,u}}if(s){const a=Ts(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},rt);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new wh(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!br(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};kr=Rn(Rs);Ho=new WeakMap;_t=new WeakMap;Ls=new WeakMap;nt(kr,4,"autoScrolling",ed,Pr,Ho);Xt(kr,Pr);function Oa(e){return e>0?Je.Forward:e<0?Je.Reverse:Je.Idle}var _h=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))}},kh=new _h(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Sh=10,Ws=class extends Me{constructor(t,n){super(t,n);const r=t.registry.plugins.get(Pr);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=tt(()=>{var i,s,o;if(this.disabled)return;const{position:a,status:l}=t.dragOperation;if(l.dragging){const u={acceleration:(i=this.options)==null?void 0:i.acceleration,threshold:typeof((s=this.options)==null?void 0:s.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(o=this.options)==null?void 0:o.threshold};if(r.scroll(void 0,u)){r.autoScrolling=!0;const d=setInterval(()=>kh.schedule(()=>r.scroll(void 0,u)),Sh);return()=>{clearInterval(d)}}else r.autoScrolling=!1}})}};Ws.configure=Or(Ws);var td=Ws,Da={capture:!0,passive:!0},nr,$h=class extends Dr{constructor(e){super(e),ve(this,nr),this.handleScroll=()=>{re(this,nr)==null&&Ae(this,nr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),Ae(this,nr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=tt(()=>{var n,r,i;if(t.status.dragging){const o=(i=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?i:document;return o.addEventListener("scroll",this.handleScroll,Da),()=>{o.removeEventListener("scroll",this.handleScroll,Da)}}})}};nr=new WeakMap;var Eh="* { user-select: none !important; -webkit-user-select: none !important; }",Oh=class extends Me{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Li),n=t?.register(Eh);if(this.destroy=tt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return Ji(),document.addEventListener("selectionchange",Ji,{capture:!0}),()=>{document.removeEventListener("selectionchange",Ji,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function Ji(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var rr=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}}),dn,_i=class extends bn{constructor(t,n){super(t),this.manager=t,this.options=n,ve(this,dn,[]),this.listeners=new kc,this.handleSourceKeyDown=(r,i,s)=>{if(this.disabled||r.defaultPrevented||!Vt(r.target)||i.disabled)return;const{keyboardCodes:o=rr.keyboardCodes,preventActivation:a=rr.preventActivation}=s??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(a?.(r,i)||this.handleStart(r,i,s))}}bind(t,n=this.options){return tt(()=>{var i;const s=(i=t.handle)!=null?i:t.element,o=a=>{br(a)&&this.handleSourceKeyDown(a,t,n)};if(s)return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:i}=n;if(!i)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),Cc(i);const{center:s}=new ct(i);if(this.manager.actions.start({event:t,coordinates:{x:s.x,y:s.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const a=jn(i),l=[this.listeners.bind(a,[{type:"keydown",listener:u=>this.handleKeyDown(u,n,r),options:{capture:!0}}])];re(this,dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:i=rr.keyboardCodes}=r??{};if(en(t,[...i.end,...i.cancel])){t.preventDefault();const s=en(t,i.cancel);this.handleEnd(t,s);return}en(t,i.up)?this.handleMove("up",t):en(t,i.down)&&this.handleMove("down",t),en(t,i.left)?this.handleMove("left",t):en(t,i.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,i;const{shape:s}=this.manager.dragOperation,o=n.shiftKey?5:1;let a={x:0,y:0},l=(i=(r=this.options)==null?void 0:r.offset)!=null?i:rr.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!s){switch(t){case"up":a={x:0,y:-l.y*o};break;case"down":a={x:0,y:l.y*o};break;case"left":a={x:-l.x*o,y:0};break;case"right":a={x:l.x*o,y:0};break}(a.x||a.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:a}))}}sideEffects(){const t=this.manager.registry.plugins.get(td);t?.disabled===!1&&(t.disable(),re(this,dn).push(()=>{t.enable()}))}cleanup(){re(this,dn).forEach(t=>t()),Ae(this,dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};dn=new WeakMap;_i.configure=Or(_i);_i.defaults=rr;var nd=_i;function en(e,t){return t.includes(e.code)}var Wt,Dh=class extends oc{constructor(){super(...arguments),ve(this,Wt)}onEvent(e){switch(e.type){case"pointerdown":Ae(this,Wt,xn(e));break;case"pointermove":if(!re(this,Wt))return;const{x:t,y:n}=xn(e),r={x:t-re(this,Wt).x,y:n-re(this,Wt).y},{tolerance:i}=this.options;if(i&&ws(r,i)){this.abort();return}ws(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){Ae(this,Wt,void 0)}};Wt=new WeakMap;var un,zt,Th=class extends oc{constructor(){super(...arguments),ve(this,un),ve(this,zt)}onEvent(e){switch(e.type){case"pointerdown":Ae(this,zt,xn(e)),Ae(this,un,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!re(this,zt))return;const{x:t,y:n}=xn(e),r={x:t-re(this,zt).x,y:n-re(this,zt).y};ws(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){re(this,un)&&(clearTimeout(re(this,un)),Ae(this,zt,void 0),Ae(this,un,void 0))}};un=new WeakMap;zt=new WeakMap;var gn=class{};gn.Delay=Th;gn.Distance=Dh;var zs=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 gn.Delay({value:250,tolerance:5})]:zf(i)&&!e.defaultPrevented?[new gn.Delay({value:200,tolerance:0})]:[new gn.Delay({value:200,tolerance:10}),new gn.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=of(r);return i===t.element?!1:!!i}}),fn,ki=class extends bn{constructor(t,n){super(t),this.manager=t,this.options=n,ve(this,fn,new Set),this.listeners=new kc,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:i}=this.latest;!r||!i||this.manager.actions.move({event:r,to:i})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:i=zs.activationConstraints}=r??{};return typeof i=="function"?i(t,n):i}bind(t,n=this.options){return tt(()=>{var i;const s=new AbortController,{signal:o}=s,a=u=>{Wf(u)&&this.handlePointerDown(u,t,n)};let l=[(i=t.handle)!=null?i:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const u of l)u&&(Mh(u.ownerDocument.defaultView),u.addEventListener("pointerdown",a,{signal:o}));return()=>s.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!Vt(t.target)||n.disabled||Ch(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:i=zs.preventActivation}=r??{};if(i?.(t,n))return;const{target:s}=t,o=Dt(s)&&s.draggable&&s.getAttribute("draggable")==="true",a=_n(n.element),{x:l,y:u}=xn(t);this.initialCoordinates={x:l*a.scaleX+a.x,y:u*a.scaleY+a.y};const c=this.activationConstraints(t,n,r);t.sensor=this;const d=new Xu(c,v=>this.handleStart(n,v));d.signal.onabort=()=>this.handleCancel(t),d.onEvent(t),this.controller=d;const h=$s(),f=this.listeners.bind(h,[{type:"pointermove",listener:v=>this.handlePointerMove(v,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Nr,options:{capture:!0}}]),g=()=>{f(),this.initialCoordinates=void 0};re(this,fn).add(g)}handlePointerMove(t,n){var r,i;if(((r=this.controller)==null?void 0:r.activated)===!1){(i=this.controller)==null||i.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const s=xn(t),o=_n(n.element);s.x=s.x*o.scaleX+o.x,s.y=s.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=s,mi.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:i}=this;if(!i||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:i,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const a=jn(n.target).body;try{a.setPointerCapture(n.pointerId)}catch{this.handleCancel(n);return}const l=Vt(n.target)?[n.target,a]:a,u=this.listeners.bind(l,[{type:"touchmove",listener:Nr,options:{passive:!1}},{type:"click",listener:Nr},{type:"contextmenu",listener:Nr},{type:"keydown",listener:this.handleKeyDown}]);re(this,fn).add(u)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){const{controller:t}=this;this.controller=void 0,t&&!t.signal.aborted&&t.abort(),this.latest={event:void 0,coordinates:void 0},re(this,fn).forEach(n=>n()),re(this,fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};fn=new WeakMap;ki.configure=Or(ki);ki.defaults=zs;var Fs=ki;function Ch(e){return"sensor"in e}function Nr(e){e.preventDefault()}function Ph(){}var Ta=new WeakSet;function Mh(e){!e||Ta.has(e)||(e.addEventListener("touchmove",Ph,{capture:!1,passive:!1}),Ta.add(e))}var mn={modifiers:[],plugins:[rh,td,sh,Vo,Oh],sensors:[Fs,nd]},rd=class extends Ju{constructor(e={}){const t=st(e.plugins,mn.plugins),n=st(e.sensors,mn.sensors),r=st(e.modifiers,mn.modifiers);super(zo(xr({},e),{plugins:[$h,Pr,Li,...t],sensors:n,modifiers:r}))}},id,sd,Ns,$t,qo,Ko,Wi=class extends(Ns=ut,sd=[H],id=[H],Ns){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=Rc(n,["element","effects","handle"]);super(xr({effects:()=>[...i(),()=>{var a,l;const{manager:u}=this;if(!u)return;const d=((l=(a=this.sensors)==null?void 0:a.map(gr))!=null?l:[...u.sensors]).map(h=>{const f=h instanceof bn?h:u.registry.register(h.plugin),g=h instanceof bn?void 0:h.options;return f.bind(this,g)});return function(){d.forEach(f=>f())}}]},o),t),ve(this,qo,we($t,8,this)),we($t,11,this),ve(this,Ko,we($t,12,this)),we($t,15,this),this.element=r,this.handle=s}};$t=Rn(Ns);qo=new WeakMap;Ko=new WeakMap;nt($t,4,"handle",sd,Wi,qo);nt($t,4,"element",id,Wi,Ko);Xt($t,Wi);var od,ad,Bs,Et,Yo,es,ld,cd,pr,Xo,zi=class extends(Bs=ft,ad=[H],od=[H],Bs){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=Rc(n,["element","effects"]);const{collisionDetector:o=Mc}=s,a=u=>{const{manager:c,element:d}=this;if(!d||u===null){this.shape=void 0;return}if(!c)return;const h=new ct(d),f=U(()=>this.shape);return h&&f?.equals(h)?f:(this.shape=h,h)},l=En(!1);super(zo(xr({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:u,manager:c}=this;if(!c)return;const{dragOperation:d}=c,{source:h}=d;l.value=!!(h&&d.status.initialized&&u&&!this.disabled&&this.accepts(h))},()=>{const{element:u}=this;if(l.value&&u){const c=new vf(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),ve(this,pr),ve(this,Yo,we(Et,8,this)),we(Et,11,this),ve(this,Xo,we(Et,12,this)),we(Et,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){Ae(this,pr,e,cd)}get element(){var e;return(e=this.proxy)!=null?e:re(this,pr,ld)}};Et=Rn(Bs);Yo=new WeakMap;pr=new WeakSet;Xo=new WeakMap;es=nt(Et,20,"#element",ad,pr,Yo),ld=es.get,cd=es.set;nt(Et,4,"proxy",od,zi,Xo);Xt(Et,zi);function Ih(e){return e!=null&&typeof e=="object"&&"current"in e}function yn(e){var t;if(e!=null)return Ih(e)?(t=e.current)!=null?t:void 0:e}var jh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ln=jh?S.useLayoutEffect:S.useEffect;function Ah(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function dd(e,t){const n=S.useRef(new Map),r=Ah();return Ln(()=>{if(!e){n.current.clear();return}return tt(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[l]=a,u=U(()=>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(()=>ou.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 Rh(e,t){e()}function tn(e){const t=S.useRef(e);return Ln(()=>{t.current=e},[e]),t}function le(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 si(e,t){const n=S.useRef(yn(e));Ln(()=>{const r=yn(e);r!==n.current&&(n.current=r,t(r))})}var Lh=Object.defineProperty,Wh=Object.defineProperties,zh=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertySymbols,ud=Object.prototype.hasOwnProperty,fd=Object.prototype.propertyIsEnumerable,Ca=(e,t,n)=>t in e?Lh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fh=(e,t)=>{for(var n in t||(t={}))ud.call(t,n)&&Ca(e,n,t[n]);if(Si)for(var n of Si(t))fd.call(t,n)&&Ca(e,n,t[n]);return e},Nh=(e,t)=>Wh(e,zh(t)),Bh=(e,t)=>{var n={};for(var r in e)ud.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Si)for(var r of Si(e))t.indexOf(r)<0&&fd.call(e,r)&&(n[r]=e[r]);return n},Vh=new rd,hd=S.createContext(Vh),Gh=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 Ln(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),ts=[void 0,rt];function Uh(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=Bh(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const c=S.useRef(null),{plugins:d,modifiers:h,sensors:f}=u,g=st(d,mn.plugins),v=st(f,mn.sensors),w=st(h,mn.modifiers),x=tn(i),m=tn(s),p=tn(a),b=tn(o),_=tn(l),$=tn(r),O=Hh(()=>{var D;return(D=u.manager)!=null?D:new rd(u)});return S.useEffect(()=>{if(!c.current)throw new Error("Renderer not found");const{renderer:D,trackRendering:M}=c.current,{monitor:I}=O;O.renderer=D;const K=[I.addEventListener("beforedragstart",W=>{const T=x.current;T&&M(()=>T(W,O))}),I.addEventListener("dragstart",W=>{var T;return(T=m.current)==null?void 0:T.call(m,W,O)}),I.addEventListener("dragover",W=>{const T=p.current;T&&M(()=>T(W,O))}),I.addEventListener("dragmove",W=>{const T=b.current;T&&M(()=>T(W,O))}),I.addEventListener("dragend",W=>{const T=_.current;T&&M(()=>T(W,O))}),I.addEventListener("collision",W=>{var T;return(T=$.current)==null?void 0:T.call($,W,O)})];return()=>K.forEach(W=>W())},[O]),le(g,()=>O&&(O.plugins=g),...ts),le(v,()=>O&&(O.sensors=v),...ts),le(w,()=>O&&(O.modifiers=w),...ts),y.jsxs(hd.Provider,{value:O,children:[y.jsx(Gh,{ref:c,children:n}),n]})}function Hh(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 qh(){return S.useContext(hd)}function pd(e){var t;const n=(t=qh())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ln(r.register,[n,r]),r}var Kh=Object.create,gd=Object.defineProperty,Yh=Object.getOwnPropertyDescriptor,vd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Fi=e=>{throw TypeError(e)},Xh=(e,t,n)=>t in e?gd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qh=e=>{var t;return[,,,Kh((t=e?.[vd("metadata")])!=null?t:null)]},md=["class","method","getter","setter","accessor","field","value","get","set"],yd=e=>e!==void 0&&typeof e!="function"?Fi("Function expected"):e,Zh=(e,t,n,r,i)=>({kind:md[e],name:t,metadata:r,addInitializer:s=>n._?Fi("Already initialized"):i.push(yd(s||null))}),Jh=(e,t)=>Xh(t,vd("metadata"),e[3]),ep=(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},bd=(e,t,n,r,i,s)=>{for(var o,a,l,u,c=t&7,d=!1,h=!1,f=2,g=md[c+5],v=e[f]||(e[f]=[]),w=(i=i.prototype,Yh(i,n)),x=r.length-1;x>=0;x--)l=Zh(c,n,a={},e[3],v),l.static=d,l.private=h,u=l.access={has:m=>n in m},u.get=m=>m[n],o=(0,r[x])(w[g],l),a._=1,yd(o)&&(w[g]=o);return w&&gd(i,n,w),i},xd=(e,t,n)=>t.has(e)||Fi("Cannot "+n),tp=(e,t,n)=>(xd(e,t,"read from private field"),t.get(e)),np=(e,t,n)=>t.has(e)?Fi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rp=(e,t,n,r)=>(xd(e,t,"write to private field"),t.set(e,n),n),Nt=class Vs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Vs(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 Vs(t,n)}},wd,_d,Gs,oi,Mr,Qo=class extends(Gs=Kt,_d=[ge],wd=[ge],Gs){constructor(e){const t=Nt.from(e);super(t,(n,r)=>Nt.equals(n,r)),ep(Mr,5,this),np(this,oi,0),this.velocity={x:0,y:0}}get delta(){return Nt.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=Nt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-tp(this,oi),o=a=>Math.round(a/s*100);ue(()=>{rp(this,oi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Nt.from(e)),this.velocity={x:0,y:0}}};Mr=Qh(Gs);oi=new WeakMap;bd(Mr,2,"delta",_d,Qo);bd(Mr,2,"direction",wd,Qo);Jh(Mr,Qo);var kd=(e=>(e.Horizontal="x",e.Vertical="y",e))(kd||{});Object.values(kd);var ip=({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=Nt.distance(t.shape.center,n);return{id:r,value:1/i,type:In.PointerIntersection,priority:Mn.High}}return null},sp=({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=Nt.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:In.ShapeIntersection,priority:Mn.Normal}}return null},op=e=>{var t;return(t=ip(e))!=null?t:sp(e)};function ap(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,l=pd(c=>new zi(Nh(Fh({},e),{register:!1,element:yn(i)}),c)),u=dd(l);return le(s,()=>l.id=s),si(i,c=>l.element=c),le(o,()=>l.accept=o,void 0,rt),le(t,()=>l.collisionDetector=t??op),le(n,()=>n&&(l.data=n)),le(r,()=>l.disabled=r===!0),le(a,()=>l.type=a),{droppable:u,get isDropTarget(){return u.isDropTarget},ref:S.useCallback(c=>{var d,h;!c&&((d=l.element)!=null&&d.isConnected)&&!((h=l.manager)!=null&&h.dragOperation.status.idle)||(l.element=c??void 0)},[l])}}function lp(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 $i(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function cp(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function ai(e,t){const n=cp(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 Pa(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 dp(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const up=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function fp(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",i=/^[A-Z_]/.test(r)?r:`F_${r}`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const Ma=[{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 Br(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 Us=e=>e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function hp(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}:$i(t.type)!==void 0?{op:$i(t.type)}:{}}})}function pp(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!Us(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 gp(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 vp(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 mp=j.createSvgIcon(y.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),yp=j.createSvgIcon(y.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"})),bp=j.createSvgIcon(y.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"})),xp=j.createSvgIcon(y.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"})),Hs=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),ns=Hs?"⌘":"Ctrl+",wp=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function _p(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=Hs?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!wp(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!Hs&&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 kp({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,actions:a,onAddTile:l,onSettings:u}){const{theme:c}=Be.usePublisherTheme();return y.jsxs(j.DashboardBar,{left:y.jsx(k.Chip,{size:"medium",variant:"outlined",icon:y.jsx(yp,{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&&y.jsx(k.Button,{startIcon:y.jsx(j.AddIcon,{}),onClick:l,"aria-label":"Add tile",children:"Tile"}),y.jsx(k.Button,{startIcon:y.jsx(mp,{}),onClick:d=>u(d.currentTarget),children:"Settings"}),y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),y.jsx(k.Tooltip,{title:`Undo (${ns}Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:y.jsx(xp,{fontSize:"small"})})})}),y.jsx(k.Tooltip,{title:`Redo (${ns}⇧Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:y.jsx(bp,{fontSize:"small"})})})}),o&&y.jsx(y.Fragment,{children:y.jsx(k.Tooltip,{title:i?`Save (${ns}S)`:"",children:y.jsx("span",{children:y.jsx(k.Button,{variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{minWidth:124},children:s?"Saving…":i?"Save changes":"Saved"})})})}),a&&y.jsxs(y.Fragment,{children:[y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const Sp=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"];function Vr(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function Ia(e){for(const t of e??[]){const n=/^#\s*([a-z_]+)/.exec(t.trim())?.[1];if(n&&Sp.includes(n))return n}}const $p=1;function Sd(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(...Sd(a,`${t}${s}.`,n-1))}}}return r}function Ep(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,Sd(i.schema?.fields,"",$p))}return t}function ja(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const Op=e=>(e??"").startsWith("dashboards/"),$d=e=>e.modelPath??e.path??"";function Ed(e){const t=[],n=new Set;for(const r of e){const i=$d(r);if(Op(i))continue;const s=Ep(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,...Vr(o.annotations)?{description:Vr(o.annotations)}:{},views:(o.views??[]).filter(u=>typeof u.name=="string").map(u=>({name:u.name,...Vr(u.annotations)?{description:Vr(u.annotations)}:{},...Ia(u.annotations)?{chart:Ia(u.annotations)}:{}})),givens:l,fields:s.get(a)??[]})}}return{sources:t}}function Dp(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=>$d(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 pt=e=>`${e.source}.${e.name}`;function Tp(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 Cp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=Be.usePublisherTheme(),a=S.useMemo(()=>Tp(t,n),[t,n]),[l,u]=S.useState(""),[c,d]=S.useState(""),[h,f]=S.useState(""),[g,v]=S.useState(Math.ceil(r/2));S.useEffect(()=>{e&&(u(t.sources[0]?.base??a[0]?.name??""),d(""),f(""),v(Math.ceil(r/2)))},[e,t,a,r]);const w=a.find(m=>m.name===l),x=l!==""&&c!=="";return y.jsx(j.AppDialog,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of one source this dashboard imports.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",disabled:!x,onClick:()=>s({base:l,view:c,...h.trim()?{label:h.trim()}:{},colspan:g}),children:"Add tile"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:a.length===0?y.jsx(k.Typography,{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."}):y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Source",value:l,onChange:m=>{u(m.target.value),d("")},inputProps:{"aria-label":"Source"},children:a.map(m=>y.jsxs(k.MenuItem,{value:m.name,children:[m.name,m.description&&y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:m.description})]},m.name))}),y.jsxs(k.Box,{children:[y.jsx(k.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),y.jsxs(k.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(m=>y.jsxs(k.ListItemButton,{selected:c===m.name,onClick:()=>d(m.name),"aria-label":`View ${m.name}`,children:[y.jsx(k.ListItemText,{primary:m.name,secondary:m.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),m.chart&&y.jsx(k.Chip,{size:"small",variant:"outlined",label:m.chart.replace(/_chart$/,"")})]},m.name)),w&&w.views.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{p:1.5,color:o.tileTitle},children:"This source declares no views."})]})]}),y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:h,onChange:m=>f(m.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}}),y.jsx(k.TextField,{size:"small",type:"number",label:`Width (of ${r})`,value:g,onChange:m=>v(Math.min(Math.max(Number(m.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})})})}const Aa=4e3;function Pp(e,t){const n=e.split(`
68
68
  `),r=t.split(`
69
- `);if(n.length>Aa||r.length>Aa)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 Pp(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 Mp({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=Be.usePublisherTheme(),o=S.useMemo(()=>e?Pp(Cp(t,n)):[],[e,t,n]),a=o.filter(u=>u.kind==="add").length,l=o.filter(u=>u.kind==="del").length;return y.jsx(j.AppDialog,{open:e,onClose:i,maxWidth:"md",title:"Review the change to the file",description:y.jsxs(y.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."," ",y.jsxs(k.Box,{component:"span",sx:{fontVariantNumeric:"tabular-nums"},children:["+",a," −",l]})]}),actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Keep editing"}),y.jsx(k.Button,{variant:"contained",onClick:r,children:"Save this"})]}),children:y.jsx(k.Box,{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"?y.jsx(k.Box,{component:"span",sx:{display:"block",opacity:.55,py:.25},children:`⋯ ${u.count} unchanged line${u.count===1?"":"s"}`},c):y.jsxs(k.Box,{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 rs="self";function Ip({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=Be.usePublisherTheme(),[l,u]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const g=(t.drills??[]).filter(v=>v.source===n.name);u((n.dimensions??[]).map(v=>{const w=g.find(x=>x.name===v.name);return{name:v.name,expression:v.expression,to:w?.to??[],given:w?.given??""}}))},[e,n,t]);const c=(g,v)=>u(w=>w.map((x,m)=>{if(m!==g)return x;const p={...x};return v(p),p})),d=[rs,...i.filter(g=>g!==rs)],h=g=>g===rs?"This dashboard":g,f=()=>{n&&(o(l.filter(g=>g.to.length>0).map(g=>({source:n.name,name:g.name,expression:g.expression,to:g.to,...g.given?{given:g.given}:{}}))),s())};return y.jsx(j.AppDialog,{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:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",onClick:f,disabled:l.length===0,children:"Apply"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:l.length===0?y.jsx(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?y.jsxs(y.Fragment,{children:[y.jsx(k.Box,{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"," ",y.jsx(k.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((g,v)=>y.jsxs(k.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[y.jsxs(k.Box,{sx:{minWidth:0,pt:.75},children:[y.jsx(k.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:g.name}),y.jsxs(k.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:g.expression,children:["is ",g.expression]})]}),y.jsx(k.TextField,{select:!0,size:"small",label:"Clicks go to",value:g.to,inputProps:{"aria-label":`Where ${g.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.length===0?"Not clickable":w.map(h).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:w=>c(v,x=>{const m=w.target.value;x.to=Array.isArray(m)?m:String(m).split(",").filter(Boolean)}),children:d.map(w=>y.jsxs(k.MenuItem,{value:w,children:[y.jsx(k.Checkbox,{size:"small",checked:g.to.includes(w),sx:{p:0,mr:1}}),y.jsx(k.ListItemText,{primary:h(w)})]},w))}),y.jsxs(k.TextField,{select:!0,size:"small",label:"Sets the control",value:g.given,disabled:g.to.length===0,inputProps:{"aria-label":`Control ${g.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:g.given===""?`Named ${g.name}, like the dimension`:void 0,onChange:w=>c(v,x=>{x.given=w.target.value}),children:[y.jsx(k.MenuItem,{value:"",children:y.jsx("em",{children:"Same name as the dimension"})}),r.map(w=>y.jsx(k.MenuItem,{value:w,children:w},w))]})]},g.name))})})}const Ed=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function jp({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,h]=S.useState(""),[f,g]=S.useState("select"),[v,w]=S.useState(""),[x,m]=S.useState(""),[p,b]=S.useState([]),[_,$]=S.useState(!1),O=T=>t.sources.find(A=>A.name===T.source)?.base??T.source;S.useEffect(()=>{if(e)if(n){c({kind:"existing",name:n.name}),h(n.label??"");const T=fp(t,n);b(T);const A=T.filter(E=>E.include),G=new Set(A.map(E=>E.field));m(G.size===1?A[0].field:n.field??""),$(G.size>1)}else c({kind:"new"}),h(""),g("select"),m(""),w(new Date().toISOString().slice(0,10)),b(t.tiles.map(T=>({include:Us(T),field:""}))),$(!1)},[e,n,t]);const D=S.useMemo(()=>[...(t.localGivens??[]).map(T=>T.name),...r.map(T=>T.name)],[t,r]),M=S.useMemo(()=>x.trim()?up(x.trim(),D):"",[x,D]),I=u.kind==="existing"?n??r.find(T=>T.name===u.name):M?{name:M,type:Br({name:M,label:d,kind:f,field:x}).type}:void 0,K=I?.type!==void 0&&!I.type.startsWith("filter<"),z=p.find(T=>T.include)?.op??$i(I?.type),C=(T,A)=>b(G=>G.map((E,P)=>P===T?{...E,...A}:E)),W=T=>b(A=>A.map(G=>({...G,op:T}))),Y=T=>{const A=$i(T);b(G=>G.map(({op:E,...P})=>A?{...P,op:A}:P))},ve=T=>{c({kind:"existing",name:T.name}),m(T.field??""),Y(T.type)},Me=T=>{g(T),Y(Br({name:"X",label:d,kind:T,field:x}).type)},se=t.tiles.map(Us),Le=se.filter(Boolean).length,Ve=p.filter((T,A)=>T.include&&se[A]).length,Te=t.tiles.filter((T,A)=>(p[A]?.include??!1)&&se[A]),Ye=Te.length>0?Te:t.tiles.filter((T,A)=>se[A]),Ge=S.useMemo(()=>{const T=new Map;let A=!1;for(const G of Ye){const E=i?.(G);if(E){A=!0;for(const P of E)T.has(P.name)||T.set(P.name,P)}}return A?[...T.values()]:void 0},[p,t.tiles,i]),We=(()=>{const T=x.trim();for(const A of Te){const G=i?.(A);if(!G||G.some(E=>E.name===T))return O(A)}return Te[0]?O(Te[0]):t.sources[0]?.base})(),Xe=T=>b(A=>A.map((G,E)=>({...G,include:T&&se[E]}))),Se=S.useMemo(()=>_?p:p.map(T=>({...T,field:x})),[_,p,x]),ue=T=>{for(const A of Ye){const G=i?.(A)?.find(E=>E.name===T.trim());if(G?.type)return G.type}},L=T=>ai(I?.type,T.type),V=(T,A)=>{if(T.trim()==="")return"Pick the field this filter compares.";const G=A?i?.(A):void 0;if(!G)return;const E=G.find(P=>P.name===T.trim());if(!E)return`Not a field of ${A?O(A):"the tiles' source"}.`;if(E.type&&!ai(I?.type,E.type))return`${T.trim()} is ${Pa(E.type)}; this filter compares ${Pa(I?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},_e=T=>{if(m(T),l||u.kind!=="new")return;const A=ue(T),G=Br({name:"X",label:d,kind:f,field:T}).type;A&&!ai(G,A)&&Me(cp(A))},X=Se.map((T,A)=>T.include&&se[A]?V(T.field,t.tiles[A]):void 0),ze=X.every(T=>T===void 0),te=!_&&Ve>0?Te.map(T=>V(x,T)).find(Boolean):void 0,at=I!==void 0&&ze&&(u.kind==="existing"||x.trim()!==""&&M!==""),Fe=()=>{if(!(!I||!at))if(u.kind==="new")s(I.name,Se,Br({name:I.name,label:d.trim()||Ed(I.name),kind:f,field:x.trim(),...We?{source:We}:{},...v?{dateDefault:v}:{}}));else if(n?.origin==="dashboard"&&n.local){const T=d.trim(),A=T!==(n.local.label??"");s(I.name,Se,A?{...n.local,...T?{label:T}:{}}:void 0)}else s(I.name,Se)},xt=l&&a.origin==="model";return{editing:l,shown:a,fromModel:xt,source:u,setSource:c,label:d,setLabel:h,kind:f,dateDefault:v,setDateDefault:w,field:x,rows:p,setRows:b,perTile:_,setPerTile:$,newName:M,target:I,valueTyped:K,commonOp:z,setRow:C,setCommonOp:W,pickExisting:ve,pickKind:Me,bindable:se,bindableCount:Le,included:Ve,commonFields:Ge,setAll:Xe,accepts:L,pickField:_e,rowProblems:X,commonProblem:te,canApply:at,apply:Fe}}function Ra({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 h=S.useMemo(()=>(n??[]).filter(g=>r?.(g)??!0).map(g=>g.name),[n,r]),f=S.useMemo(()=>new Map((n??[]).map(g=>[g.name,g.type])),[n]);return y.jsx(k.Autocomplete,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(g,v)=>t(v),value:e,onChange:(g,v)=>t(typeof v=="string"?v:""),disabled:l,disableClearable:!0,renderOption:(g,v)=>S.createElement("li",{...g,key:v},y.jsx(k.Typography,{variant:"body2",sx:{flex:1},children:v}),f.get(v)&&y.jsx(k.Typography,{variant:"caption",sx:{opacity:.6},children:f.get(v)?.replace(/_type$/,"")})),renderInput:g=>y.jsx(k.TextField,{...g,label:i,placeholder:c,autoFocus:u,error:o,helperText:a,inputProps:{...g.inputProps,"aria-label":s}}),sx:d})}const La=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 Ap({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:l}=Be.usePublisherTheme(),{editing:u,shown:c,fromModel:d,source:h,setSource:f,label:g,setLabel:v,kind:w,dateDefault:x,setDateDefault:m,field:p,rows:b,setRows:_,perTile:$,setPerTile:O,newName:D,target:M,valueTyped:I,commonOp:K,setRow:z,setCommonOp:C,pickExisting:W,pickKind:Y,bindable:ve,bindableCount:Me,included:se,commonFields:Le,setAll:Ve,accepts:Te,pickField:Ye,rowProblems:Ge,commonProblem:We,canApply:Xe,apply:Se}=jp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),ue=(L,V,_e)=>y.jsx(k.TextField,{select:!0,size:"small",label:"Compares",value:L??">=",onChange:X=>V(X.target.value),inputProps:{"aria-label":_e},sx:{width:130},children:dp.filter(X=>X.op!=="~").map(X=>y.jsx(k.MenuItem,{value:X.op,children:X.label},X.op))});return y.jsx(j.AppDialog,{open:e,onClose:s,title:u?c.label??c.name:"Add a filter",description:u?y.jsxs(y.Fragment,{children:[y.jsxs(k.Box,{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:y.jsxs(y.Fragment,{children:[u&&y.jsx(k.Button,{color:"error",onClick:()=>a(c.name),"aria-label":`Remove control ${c.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Tooltip,{title:Xe||M===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:y.jsx("span",{children:y.jsx(k.Button,{variant:"contained",onClick:Se,disabled:!Xe,children:u?"Apply":"Add filter"})})})]}),children:y.jsxs(k.Stack,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&y.jsxs(k.ToggleButtonGroup,{exclusive:!0,size:"small",value:h.kind,onChange:(L,V)=>{V==="new"?f({kind:"new"}):V==="existing"&&r[0]&&W(r[0])},"aria-label":"Where the filter comes from",children:[y.jsx(k.ToggleButton,{value:"new",children:"New in this dashboard"}),y.jsx(k.ToggleButton,{value:"existing",children:"From the model"})]}),!u&&h.kind==="existing"?y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:h.name,onChange:L=>{const V=r.find(_e=>_e.name===L.target.value);V&&W(V)},children:r.map(L=>y.jsxs(k.MenuItem,{value:L.name,children:[L.label??L.name,y.jsxs(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",L.name]})]},L.name))}):null,y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!$&&y.jsx(Ra,{value:p,onChange:Ye,fields:Le,accepts:Te,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:We!==void 0,helperText:We??(!u&&D?`Declared as $${D}`:void 0),sx:{flex:1,minWidth:200}}),!d&&y.jsx(k.TextField,{size:"small",label:"Label",placeholder:D?Ed(D):"",value:g,onChange:L=>v(L.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),I&&!$&&ue(K,C,"Comparison")]}),!u&&h.kind==="new"&&y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:w,onChange:L=>Y(L.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:L=>Ma.find(V=>V.kind===L)?.label??String(L)}},sx:{flex:1},children:Ma.map(L=>y.jsxs(k.MenuItem,{value:L.kind,children:[L.label,y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:L.hint})]},L.kind))}),w==="date"&&y.jsx(k.TextField,{size:"small",type:"date",label:"Starts at",value:x,onChange:L=>m(L.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),y.jsxs(k.Box,{children:[y.jsxs(k.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[y.jsx(k.Checkbox,{size:"small",checked:Me>0&&se===Me,indeterminate:se>0&&se<Me,disabled:Me===0,onChange:L=>Ve(L.target.checked),inputProps:{"aria-label":"All tiles"}}),y.jsxs(k.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",se," of ",t.tiles.length," tiles"]}),y.jsx(k.Button,{size:"small",onClick:()=>{$||_(L=>L.map(V=>({...V,field:p}))),O(L=>!L)},children:$?"Same field for all":"Adjust per tile"})]}),y.jsx(k.Stack,{sx:{gap:$?1:0},children:t.tiles.map((L,V)=>{const _e=b[V],X=L.label??L.name,ze=$?Ge[V]:void 0;return y.jsxs(k.Stack,{direction:"row",sx:{gap:1,alignItems:$?"flex-start":"center",opacity:ve[V]?1:.6},children:[y.jsx(k.Checkbox,{size:"small",disabled:!ve[V],checked:(_e?.include??!1)&&ve[V],inputProps:{"aria-label":`Filter ${X}`},onChange:te=>z(V,{include:te.target.checked})}),y.jsx(k.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:$?1:0},noWrap:!0,children:X}),ve[V]?$&&y.jsxs(y.Fragment,{children:[I&&ue(_e?.op,te=>z(V,{op:te}),`Comparison for ${X}`),y.jsx(Ra,{value:_e?.field??"",onChange:te=>z(V,{field:te}),fields:i?.(L),accepts:Te,label:"Field",ariaLabel:`Field for ${X}`,disabled:!_e?.include,error:ze!==void 0,helperText:ze,sx:{width:220}})]}):y.jsx(k.Tooltip,{title:La(t.tiles[V]).reason,children:y.jsx(k.Typography,{variant:"caption",sx:{color:l.tileTitle},children:La(t.tiles[V]).label})})]},`${L.source}.${L.name}`)})}),se===0&&y.jsx(k.Typography,{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 Od(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:u=>s(c=>{if(c===void 0)return c;const d=structuredClone(c);return u(d),d}),close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const Rp=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}}),is=[2,3,4,6,8,12,16,24];function Lp({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=Be.usePublisherTheme(),{draft:s,patch:o,close:a}=Od(t,e!==null,r,n),l=s?.columns!==void 0&&!is.includes(s.columns)?[...is,s.columns].sort((u,c)=>u-c):is;return y.jsx(k.Popover,{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&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsx(k.Typography,{variant:"overline",sx:{color:i.tileTitle,lineHeight:1.5},children:"Dashboard"}),y.jsx(k.TextField,{size:"small",label:"Title",value:s.title,autoFocus:!0,inputProps:{"aria-label":"Dashboard title"},onChange:u=>o(c=>{c.title=u.target.value})}),y.jsx(k.TextField,{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})}),y.jsxs(k.TextField,{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:[y.jsx(k.MenuItem,{value:"",children:"Default (2)"}),l.map(u=>y.jsx(k.MenuItem,{value:u,children:u},u))]}),y.jsx(k.FormControlLabel,{control:y.jsx(k.Switch,{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:y.jsxs(k.Typography,{variant:"body2",children:["Run as controls change",y.jsx(k.Typography,{component:"span",variant:"caption",sx:{display:"block",opacity:.7},children:"Off, readers press Apply. For a page whose queries are slow."})]})})]})})}const Wp=j.createSvgIcon(y.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function zp({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:i,children:s}){const{theme:o}=Be.usePublisherTheme();return y.jsx(y.Fragment,{children:y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsxs(k.Stack,{direction:"row","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",minHeight:32},children:[y.jsx(Wp,{sx:{fontSize:18,color:o.tileTitle,opacity:.7}}),y.jsx(k.Typography,{variant:"subtitle2",sx:{color:o.tileTitle,mr:.5},children:"Filters"}),e.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{color:o.tileTitle,opacity:.8},children:"None yet."}),e.map(a=>{const l=n(a.name,a.type);return y.jsx(k.Tooltip,{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:y.jsx(k.Chip,{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)}),y.jsx(k.Box,{sx:{ml:"auto"},children:y.jsx(j.SecondaryButton,{label:"Filter",icon:y.jsx(j.AddIcon,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const Fp=(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}),Np=(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},Dd=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),Td=e=>`gap.${e}`,Bp=(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:pt(e[o-1]),colspan:t-r}),l&&(r=0),n.push(Dd(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:pt(i),colspan:t-r}),n};var Vp=Object.create,Cd=Object.defineProperty,Gp=Object.defineProperties,Up=Object.getOwnPropertyDescriptor,Hp=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,Pd=Object.prototype.hasOwnProperty,Md=Object.prototype.propertyIsEnumerable,qp=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ir=e=>{throw TypeError(e)},qs=(e,t,n)=>t in e?Cd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ss=(e,t)=>{for(var n in t||(t={}))Pd.call(t,n)&&qs(e,n,t[n]);if(Ei)for(var n of Ei(t))Md.call(t,n)&&qs(e,n,t[n]);return e},os=(e,t)=>Gp(e,Hp(t)),Kp=(e,t)=>{var n={};for(var r in e)Pd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ei)for(var r of Ei(e))t.indexOf(r)<0&&Md.call(e,r)&&(n[r]=e[r]);return n},Yp=e=>{var t;return[,,,Vp((t=void 0)!=null?t:null)]},Id=["class","method","getter","setter","accessor","field","value","get","set"],ir=e=>e!==void 0&&typeof e!="function"?Ir("Function expected"):e,Xp=(e,t,n,r,i)=>({kind:Id[e],name:t,metadata:r,addInitializer:s=>n._?Ir("Already initialized"):i.push(ir(s||null))}),Qp=(e,t)=>qs(t,qp("metadata"),e[3]),Gr=(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},jd=(e,t,n,r,i,s)=>{for(var o,a,l,u,c,d=t&7,h=!1,f=!1,g=e.length+1,v=Id[d+5],w=e[g-1]=[],x=e[g]||(e[g]=[]),m=(i=i.prototype,Up({get[n](){return sr(this,s)},set[n](b){return Ft(this,s,b)}},n)),p=r.length-1;p>=0;p--)u=Xp(d,n,l={},e[3],x),u.static=h,u.private=f,c=u.access={has:b=>n in b},c.get=b=>b[n],c.set=(b,_)=>b[n]=_,a=(0,r[p])({get:m.get,set:m.set},u),l._=1,a===void 0?ir(a)&&(m[v]=a):typeof a!="object"||a===null?Ir("Object expected"):(ir(o=a.get)&&(m.get=o),ir(o=a.set)&&(m.set=o),ir(o=a.init)&&w.unshift(o));return m&&Cd(i,n,m),i},Ad=(e,t,n)=>t.has(e)||Ir("Cannot "+n),sr=(e,t,n)=>(Ad(e,t,"read from private field"),t.get(e)),Un=(e,t,n)=>t.has(e)?Ir("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ft=(e,t,n,r)=>(Ad(e,t,"write to private field"),t.set(e,n),n);function Bt(e){return e instanceof ea||e instanceof zd}var Ur=10,Zp=class extends Pe{constructor(e){super(e);const t=tt(()=>{const{dragOperation:r}=e;if(br(r.activatorEvent)&&Bt(r.source)&&r.status.initialized){const i=e.registry.plugins.get(Pr);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(!br(r.nativeEvent)||!Bt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:l}=i,{by:u}=r;if(!u)return;const c=Jp(u),{source:d,target:h}=s,{center:f}=s.shape.current,g=[],v=[];de(()=>{for(const _ of l.droppables){const{id:$}=_;if(!_.accepts(d)||$===h?.id&&Bt(_)||!_.element)continue;let O=_.shape;const D=new ct(_.element,{getBoundingClientRect:M=>mr(M,void 0,.2)});!D.height||!D.width||(c=="down"&&f.y+Ur<D.center.y||c=="up"&&f.y-Ur>D.center.y||c=="left"&&f.x-Ur>D.center.x||c=="right"&&f.x+Ur<D.center.x)&&(g.push(_),_.shape=D,v.push(()=>_.shape=O))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(g,Nf);de(()=>v.forEach(_=>_()));const[x]=w;if(!x)return;const{id:m}=x,{index:p,group:b}=d.sortable;o.setDropTarget(m).then(()=>{const{source:_,target:$,shape:O}=s;if(!_||!Bt(_)||!O)return;const{index:D,group:M,target:I}=_.sortable,K=p!==D||b!==M,z=K?I:$?.element;if(!z)return;Cc(z);const C=new ct(z);if(!C)return;const W=dt.delta(C,dt.from(O.current.boundingRectangle),_.alignment);o.move({by:W}),K?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Jp(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 eg=Object.defineProperty,tg=Object.defineProperties,ng=Object.getOwnPropertyDescriptors,Wa=Object.getOwnPropertySymbols,rg=Object.prototype.hasOwnProperty,ig=Object.prototype.propertyIsEnumerable,za=(e,t,n)=>t in e?eg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))rg.call(t,n)&&za(e,n,t[n]);if(Wa)for(var n of Wa(t))ig.call(t,n)&&za(e,n,t[n]);return e},rn=(e,t)=>tg(e,ng(t));function sg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Hr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function as(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function og(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,b)=>p===b||p!==null&&typeof p=="object"&&"id"in p&&p.id===b;if(Array.isArray(e)){const p=e.findIndex(_=>l(_,s.id)),b=e.findIndex(_=>l(_,o.id));if(p===-1||b===-1){if(as(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==p)return n(e,p,_)}return n(e,p,b)}const u=Object.entries(e);let c=-1,d,h=-1,f;for(const[p,b]of u)if(c===-1&&(c=b.findIndex(_=>l(_,s.id)),c!==-1&&(d=p)),h===-1&&(h=b.findIndex(_=>l(_,o.id)),h!==-1&&(f=p)),c!==-1&&h!==-1)break;if(c===-1&&as(s)){const p=s.initialGroup==null?void 0:Hr(e,s.initialGroup),b=s.initialIndex,_=s.group==null?void 0:Hr(e,s.group),$=s.index;if(p==null||_==null||p===_&&b===$)return"preventDefault"in t&&t.preventDefault(),e;if(p===_)return rn(nn({},e),{[p]:n(e[p],b,$)});const O=e[p][b];return rn(nn({},e),{[p]:[...e[p].slice(0,b),...e[p].slice(b+1)],[_]:[...e[_].slice(0,$),O,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:g}=s.manager,v=(i=(r=g.shape)==null?void 0:r.current.center)!=null?i:g.position.current;if(f==null){const p=Hr(e,o.id);if(p!=null){const b=o.shape&&v.y>o.shape.center.y?e[p].length:0;f=p,h=b}}if(d==null||f==null||d===f&&c===h){if(d!=null&&d===f&&c===h&&as(s)){const p=s.group==null?void 0:Hr(e,s.group),b=s.group!=null&&p!==d,_=s.index!==c;if(b||_){const $=s.group==null?d:p;if($!=null){if(d===$)return rn(nn({},e),{[d]:n(e[d],c,s.index)});const O=e[d][c];return rn(nn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[$]:[...e[$].slice(0,s.index),O,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===f)return rn(nn({},e),{[d]:n(e[d],c,h)});const x=o.shape&&Math.round(v.y)>Math.round(o.shape.center.y)?1:0,m=e[d][c];return rn(nn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[f]:[...e[f].slice(0,h+x),m,...e[f].slice(h+x)]})}function ag(e,t){return og(e,t,sg)}function Fa(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Na(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 Ba="__default__",lg=class extends Pe{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof ea){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(!Bt(o)||!Bt(a)||o.sortable===a.sortable)return;const l=t(),u=Fa(l),c=o.sortable.group===a.sortable.group,d=l.get(o.sortable.group),h=c?d:l.get(a.sortable.group);!d||!h||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var f,g;const v=t();if(Na(u,l,v))return;const w=o.sortable.element,x=a.sortable.element;if(!x||!w||!c&&a.id===o.sortable.group)return;const m=qr(d),p=c?m:qr(h),b=(f=o.sortable.group)!=null?f:Ba,_=(g=a.sortable.group)!=null?g:Ba,$={[b]:m,[_]:p},O=ag($,r);if($===O)return;const D=O[_].indexOf(o.sortable),M=O[_].indexOf(a.sortable);i.collisionObserver.disable(),Va(w,D,x,M),de(()=>{for(const[I,K]of O[b].entries())K.index=I;if(!c)for(const[I,K]of O[_].entries())K.group=a.sortable.group,K.index=I}),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;Bt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=Fa(a),u=a.get(o.sortable.initialGroup);u&&i.renderer.rendering.then(()=>{const c=t();if(Na(l,a,c))return;const d=qr(u),h=qr(u,dg),f=o.sortable.element,g=h.indexOf(o.sortable),v=d[g],w=v?.element;!v||!w||!f||(Va(f,v.index,w,o.index),de(()=>{for(const x of a.values()){const m=Array.from(x).values();for(const p of m)p.index=p.initialIndex,p.group=p.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function Va(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function cg(e,t){return e.index-t.index}function dg(e,t){return e.initialIndex-t.initialIndex}function qr(e,t=cg){return Array.from(e).sort(t)}var Ga=[Zp,lg],Rd={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function Ua(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 Kr=new ku,Ld,Wd,Ot,Zo,or,ar,Jo,hn;Wd=[H],Ld=[H];var Ni=class{constructor(e,t){Un(this,Zo,Gr(Ot,8,this)),Gr(Ot,11,this),Un(this,or),Un(this,ar),Un(this,Jo,Gr(Ot,12,this)),Gr(Ot,15,this),Un(this,hn),this.register=()=>(de(()=>{var g,v;(g=this.manager)==null||g.registry.register(this.droppable),(v=this.manager)==null||v.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{de(()=>{var g,v;(g=this.manager)==null||g.registry.unregister(this.droppable),(v=this.manager)==null||v.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=Rd,plugins:c}=n,d=Kp(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const h=st(c,Ga),f=Ua(i);this.droppable=new ea(os(ss({},d),{disabled:f.droppable}),t,this),this.draggable=new zd(os(ss({},d),{disabled:f.draggable,plugins:h,effects:()=>[()=>{var g,v,w;const x=(g=this.manager)==null?void 0:g.dragOperation.status;x?.initializing&&this.id===((w=(v=this.manager)==null?void 0:v.dragOperation.source)==null?void 0:w.id)&&Kr.clear(this.manager),x?.dragging&&Kr.set(this.manager,this.id,U(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:g,group:v,manager:w}=this,x=sr(this,ar),m=sr(this,or);(g!==x||v!==m)&&(Ft(this,ar,g),Ft(this,or,v),this.animate())},()=>{var g,v;const{target:w}=this,{isDragSource:x}=this.draggable;((v=(g=this.draggable.pluginConfig(Vo))==null?void 0:g.feedback)!=null?v:"default")==="move"&&x&&(this.droppable.disabled=!w)},...r()],type:l,sensors:a}),t,this),Ft(this,hn,d.element),this.manager=t,this.index=o,Ft(this,ar,o),this.group=s,Ft(this,or,s),this.type=l,this.transition=u}get initialIndex(){var e,t;return(t=(e=Kr.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=Kr.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){U(()=>{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}=ht(i),l=wa(i,a,!1),u=wa(i,a);if(o.x||o.y){const c=Ao(Ke(i))?os(ss({},t),{duration:0}):t;Pc({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=sr(this,hn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),Ft(this,hn,e)})}get element(){var e,t;const n=sr(this,hn);if(n)return(t=(e=Es.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=st(e,Ga)}set disabled(e){const t=Ua(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??Mc}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)}};Ot=Yp();Zo=new WeakMap;or=new WeakMap;ar=new WeakMap;Jo=new WeakMap;hn=new WeakMap;jd(Ot,4,"index",Wd,Ni,Zo);jd(Ot,4,"group",Ld,Ni,Jo);Qp(Ot,Ni);var zd=class extends Wi{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}},ea=class extends zi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},ug=Object.defineProperty,fg=Object.defineProperties,hg=Object.getOwnPropertyDescriptors,Ha=Object.getOwnPropertySymbols,pg=Object.prototype.hasOwnProperty,gg=Object.prototype.propertyIsEnumerable,qa=(e,t,n)=>t in e?ug(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ls=(e,t)=>{for(var n in t||(t={}))pg.call(t,n)&&qa(e,n,t[n]);if(Ha)for(var n of Ha(t))gg.call(t,n)&&qa(e,n,t[n]);return e},vg=(e,t)=>fg(e,hg(t));function mg(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:h,target:f,type:g,plugins:v}=e,w=ls(ls({},Rd),e.transition),x=pd(p=>new Ni(vg(ls({},e),{transition:w,register:!1,handle:yn(a),element:yn(o),target:yn(f)}),p)),m=dd(x,yg);return ae(i,()=>x.id=i),Ln(()=>{de(()=>{x.group=u,x.index=l})},[x,u,l]),ae(g,()=>x.type=g),ae(t,()=>x.accept=t,void 0,rt),ae(s,()=>s&&(x.data=s)),ae(l,()=>{var p;(p=x.manager)!=null&&p.dragOperation.status.idle&&w?.idle&&x.refreshShape()},Ah),si(a,p=>x.handle=p),si(o,p=>x.element=p),si(f,p=>x.target=p),ae(c,()=>x.disabled=c??!1,void 0,rt),ae(h,()=>x.sensors=h,void 0,rt),ae(n,()=>x.collisionDetector=n),ae(r,()=>x.collisionPriority=r),ae(v,()=>x.plugins=v,void 0,rt),ae(w,()=>x.transition=w,void 0,rt),ae(d,()=>x.modifiers=d,void 0,rt),ae(e.alignment,()=>x.alignment=e.alignment),{sortable:m,get isDragging(){return m.isDragging},get isDropping(){return m.isDropping},get isDragSource(){return m.isDragSource},get isDropTarget(){return m.isDropTarget},handleRef:S.useCallback(p=>{x.handle=p??void 0},[x]),ref:S.useCallback(p=>{var b,_;!p&&((b=x.element)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.element=p??void 0)},[x]),sourceRef:S.useCallback(p=>{var b,_;!p&&((b=x.source)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.source=p??void 0)},[x]),targetRef:S.useCallback(p=>{var b,_;!p&&((b=x.target)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.target=p??void 0)},[x])}}function yg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Ks="tile",Fd="gap",bg='[role="separator"]',xg=[Fs.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(Fs.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(bg)!==null}),nd],wg=e=>[...e,Vo.configure({feedback:"clone"})];function _g({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=mg({id:e,index:t,type:Ks,accept:Ks,collisionDetector:Lo,plugins:wg});return y.jsx(y.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function kg({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=op({id:e,type:Fd,accept:Ks,collisionDetector:Lo,data:{after:t}});return y.jsx(y.Fragment,{children:n({ref:r,isDropTarget:i})})}const Sg=j.createSvgIcon(y.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"})),$g=j.createSvgIcon(y.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 Eg({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:h}=Be.usePublisherTheme();return y.jsx(_g,{id:pt(e),index:t,children:({ref:f,handleRef:g,isDragSource:v})=>y.jsxs(k.Box,{ref:f,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 ${h.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 ${h.drillLink}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"&:hover":{outlineColor:n?h.drillLink:h.cardBorder,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.10)"}},children:[d,y.jsx(k.Box,{ref:g,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:h.tileTitle,bgcolor:h.tile,opacity:v||n?.9:0,transition:"opacity 120ms","&:hover":{opacity:1},"&:active":{cursor:"grabbing"},"&:focus-visible":{opacity:1,outline:`2px solid ${h.drillLink}`,outlineOffset:1}},children:y.jsx(Sg,{sx:{fontSize:16}})}),i===void 0&&y.jsx(k.IconButton,{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:h.tileTitle,bgcolor:h.tile,opacity:n||r?.9:0,transition:"opacity 120ms","&:hover":{opacity:1,bgcolor:h.tile}},children:y.jsx($g,{sx:{fontSize:16}})}),i!==void 0&&y.jsxs(k.Box,{"aria-hidden":!0,sx:{position:"absolute",top:"6px",right:"6px",px:.75,py:.25,borderRadius:"4px",bgcolor:h.drillLink,color:h.tile,fontSize:11,fontVariantNumeric:"tabular-nums",zIndex:4,pointerEvents:"none"},children:[i," of ",s," ·"," ",Math.round(i/s*100),"%"]}),e.declaration.kind!=="inherited"&&y.jsx(k.Box,{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:h.drillLink}}})]})})}function Og({tile:e}){const{theme:t}=Be.usePublisherTheme();return y.jsxs(j.TileCard,{sx:{minHeight:140},children:[y.jsx(j.TileHeading,{title:e.label??e.name,subtitle:e.subtitle}),y.jsxs(k.Typography,{variant:"caption",sx:{display:"block",color:t.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function Dg({after:e}){const{theme:t}=Be.usePublisherTheme();return y.jsx(kg,{id:Td(e),after:e,children:({ref:n,isDropTarget:r})=>y.jsx(k.Box,{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 Tg({columns:e}){const{theme:t}=Be.usePublisherTheme();return y.jsx(k.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${j.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>y.jsx(k.Box,{sx:{borderLeft:`1px dashed ${t.drillLink}`,borderRight:r===e-1?`1px dashed ${t.drillLink}`:"none",opacity:.35}},r))})}var Cg=Object.defineProperty,Pg=Object.defineProperties,Mg=Object.getOwnPropertyDescriptors,Ka=Object.getOwnPropertySymbols,Ig=Object.prototype.hasOwnProperty,jg=Object.prototype.propertyIsEnumerable,Ya=(e,t,n)=>t in e?Cg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))Ig.call(t,n)&&Ya(e,n,t[n]);if(Ka)for(var n of Ka(t))jg.call(t,n)&&Ya(e,n,t[n]);return e},on=(e,t)=>Pg(e,Mg(t));function Ag(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Yr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function cs(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Rg(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,b)=>p===b||p!==null&&typeof p=="object"&&"id"in p&&p.id===b;if(Array.isArray(e)){const p=e.findIndex(_=>l(_,s.id)),b=e.findIndex(_=>l(_,o.id));if(p===-1||b===-1){if(cs(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==p)return n(e,p,_)}return n(e,p,b)}const u=Object.entries(e);let c=-1,d,h=-1,f;for(const[p,b]of u)if(c===-1&&(c=b.findIndex(_=>l(_,s.id)),c!==-1&&(d=p)),h===-1&&(h=b.findIndex(_=>l(_,o.id)),h!==-1&&(f=p)),c!==-1&&h!==-1)break;if(c===-1&&cs(s)){const p=s.initialGroup==null?void 0:Yr(e,s.initialGroup),b=s.initialIndex,_=s.group==null?void 0:Yr(e,s.group),$=s.index;if(p==null||_==null||p===_&&b===$)return"preventDefault"in t&&t.preventDefault(),e;if(p===_)return on(sn({},e),{[p]:n(e[p],b,$)});const O=e[p][b];return on(sn({},e),{[p]:[...e[p].slice(0,b),...e[p].slice(b+1)],[_]:[...e[_].slice(0,$),O,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:g}=s.manager,v=(i=(r=g.shape)==null?void 0:r.current.center)!=null?i:g.position.current;if(f==null){const p=Yr(e,o.id);if(p!=null){const b=o.shape&&v.y>o.shape.center.y?e[p].length:0;f=p,h=b}}if(d==null||f==null||d===f&&c===h){if(d!=null&&d===f&&c===h&&cs(s)){const p=s.group==null?void 0:Yr(e,s.group),b=s.group!=null&&p!==d,_=s.index!==c;if(b||_){const $=s.group==null?d:p;if($!=null){if(d===$)return on(sn({},e),{[d]:n(e[d],c,s.index)});const O=e[d][c];return on(sn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[$]:[...e[$].slice(0,s.index),O,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===f)return on(sn({},e),{[d]:n(e[d],c,h)});const x=o.shape&&Math.round(v.y)>Math.round(o.shape.center.y)?1:0,m=e[d][c];return on(sn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[f]:[...e[f].slice(0,h+x),m,...e[f].slice(h+x)]})}function Lg(e,t){return Rg(e,t,Ag)}function Wg({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:d=>{const{source:h,target:f}=d.operation;if(!h||!f)return;const g=s.current??e;let v;if(f.type===Fd){const{after:w}=f.data,x=g.findIndex(b=>pt(b)===h.id);if(x<0||w===h.id)return;const p=g.filter((b,_)=>_!==x).findIndex(b=>pt(b)===w)+1;v=Np(g,x,p)}else{const w=g.map(pt),x=Lg(w,d);if(x.every((p,b)=>p===w[b]))return;const m=new Map(g.map(p=>[pt(p),p]));v=Fp(x.map(p=>m.get(p)),e.map(p=>p.break??!1))}s.current=v,i(v)},onDragEnd:d=>{a(!1);const h=s.current;if(s.current=void 0,i(void 0),d.canceled||!h)return;t(h);const f=h.findIndex(g=>pt(g)===d.operation.source?.id);f>=0&&n(f)}}}const Xa=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function zg({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:(c,d)=>{const h=o.current?.getBoundingClientRect(),f=c.currentTarget.parentElement?.getBoundingClientRect();!h||!f||(c.stopPropagation(),c.preventDefault(),c.currentTarget.setPointerCapture(c.pointerId),Xa(!0),n(d),s({index:d,span:e[d]?.colspan??1,left:f.left,track:(h.width-j.GRID_GAP_PX*(t-1))/t}))},onResize:c=>{if(!i)return;const d=c.clientX-i.left,h=Math.round((d+j.GRID_GAP_PX)/(i.track+j.GRID_GAP_PX)),f=Math.min(Math.max(h,1),t);f!==i.span&&s({...i,span:f})},endResize:c=>{if(c.currentTarget.hasPointerCapture(c.pointerId)&&c.currentTarget.releasePointerCapture(c.pointerId),Xa(!1),!i)return;const{index:d,span:h}=i;s(void 0),r(d,h)}}}function Fg({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,columns:s,onDrills:o}){const{theme:a}=Be.usePublisherTheme(),{draft:l,patch:u,close:c,discard:d}=Od(t,e!==null,r,n),h=l!==void 0&&l.declaration.kind!=="inherited";return y.jsx(k.Popover,{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&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsxs(k.Typography,{variant:"overline",sx:{color:a.tileTitle,lineHeight:1.5},children:[l.source," → ",l.name]}),h?y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{size:"small",label:"Title",value:l.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:f=>u(g=>{const v=f.target.value;v===""?delete g.label:g.label=v})}),y.jsx(k.TextField,{size:"small",label:"Subtitle",value:l.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:f=>u(g=>{const v=f.target.value;v===""?delete g.subtitle:g.subtitle=v})}),y.jsxs(k.Stack,{direction:"row",sx:{gap:.5,alignItems:"center"},children:[y.jsx(k.Typography,{variant:"caption",sx:{color:a.tileTitle,mr:.5},children:"Width"}),[["Full",1],["½",2],["⅓",3],["¼",4]].map(([f,g])=>{const v=Math.max(1,Math.round(s/g)),w=(l.colspan??1)===v;return y.jsx(k.Button,{size:"small",variant:w?"contained":"outlined","aria-label":`Width ${f}`,"aria-pressed":w,onClick:()=>u(x=>{x.colspan=v}),sx:{minWidth:40,px:1},children:f},f)})]})]}):y.jsx(k.Typography,{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"&&y.jsxs(k.Typography,{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."]}),y.jsx(k.Divider,{}),y.jsxs(k.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[h?y.jsx(k.Button,{size:"small",onClick:()=>{c(),o()},children:"Clickable cells…"}):y.jsx("span",{}),y.jsx(k.Button,{color:"error",size:"small",onClick:()=>{d(),i()},children:"Remove tile"})]})]})})}const Nd=e=>e.ok===!1,me=(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=>me(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>me(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>me(e,"VIEW","subQueryDefList"),defDimension:e=>me(e,"defList","DIMENSION"),exploreProperties:e=>me(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>me(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>me(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>me(e,"WHERE","filterClauseList"),givenDef:e=>me(e,"givenNameDef"),givenStatement:e=>me(e,"GIVEN","givenDefList"),importStatement:e=>me(e,"IMPORT","importURL"),vArrow:e=>me(e,"ARROW","vExpr","segExpr"),segRefine:e=>me(e,"PLUS","segExpr"),segOps:e=>me(e,"queryProperties"),segField:e=>me(e,"fieldPath")&&!me(e,"segExpr"),segParen:e=>me(e,"OPAREN","CPAREN","vExpr"),compare:e=>me(e,"fieldExpr","compareOp"),givenRef:e=>me(e,"GIVEN_REF")};function Ng(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 Bg(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
70
- `&&t.push(n+1);return t}class Vg{constructor(t){this.text=t,this.map=Ng(t),this.lineStarts=Bg(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 jr(e,t,n=[]){Bi(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)jr(e.getChild(r),t,n);return n}const Gg=e=>me(e,"OCURLY","CCURLY");function Sr(e,t){const n=[],r=i=>{if(Bi(i)){if(t(i)){n.push(i);return}if(!Gg(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 ye=(e,t)=>e[t]?.call(e),Ut=(e,t)=>e[t]?.call(e)??[];function Ug(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 Bd(e,t){const n=e.positioned(t);if(!n)return;const r=ye(t,"filterClauseList"),i=[];for(const s of r?Ut(r,"fieldExpr"):[]){const o=e.positioned(s);if(!o)continue;const a=jr(s,ce.givenRef).map(l=>e.text_(l)).filter(l=>l!==void 0).map(l=>l.replace(/^\$/,""));i.push({...o,givens:a,binding:Ug(e,s)})}return{...n,clauses:i}}function Ys(e,t){const n=e.span(t);if(!n)return;const r=[],i=[];for(const u of Sr(t,ce.queryStatement)){const c=e.positioned(u);c&&r.push(c);const d=ye(u,"whereStatement");if(d&&ce.whereStatement(d)){const h=Bd(e,d);h&&i.push(h)}}const s=n.start+1,o=n.end-1,a=!e.text.slice(n.start,n.end).includes(`
71
- `),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 ta(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 Hg(e,t){const n=ye(t,"segExpr");if(!n)return{kind:"unsupported",why:"an unreadable expression"};const r=ce.vArrow(t);if(ce.segOps(n)){const i=ye(n,"queryProperties"),s=i&&Ys(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=Ut(n,"segExpr"),s=i[0],o=i[i.length-1];let a=s;for(;ce.segRefine(a);){const h=Ut(a,"segExpr");if(h.some(f=>ce.segOps(f)||ce.segParen(f)))return{kind:"unsupported",why:"a chained refinement"};a=h[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 h=e.span(n);return h?{kind:"reference",from:e.text.slice(h.start,h.end),fromSpan:h}:{kind:"unsupported",why:"an unreadable refinement"}}const u=e.text.slice(l.start,l.end),c=ye(o,"queryProperties"),d=c&&Ys(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 qg(e,t){const n=[];for(const r of Sr(t,ce.defExploreQuery)){const i=e.span(r),s=ye(r,"subQueryDefList");if(!i||!s)continue;const o=Ut(s,"exploreQueryDef").filter(ce.exploreQueryDef),a=e.terminal(ye(r,"VIEW"));for(const l of o){const u=e.span(l),c=ye(l,"exploreQueryNameDef"),d=e.text_(c),h=ye(l,"vExpr");!u||!d||!h||n.push({name:d,span:u,line:e.line(u.start),statement:i,tags:ta(e,i,a?.start??u.start),siblings:o.length,body:Hg(e,h)})}}return n}function Kg(e,t){const n=[];for(const r of Sr(t,ce.defDimension)){const i=e.span(r),s=ye(r,"defList");if(!i||!s)continue;const o=e.terminal(ye(r,"DIMENSION"));for(const a of Ut(s,"fieldDef")){const l=e.span(a),u=e.text_(ye(a,"fieldNameDef"))?.trim(),c=e.text_(ye(a,"fieldExpr"))?.trim();!l||!u||c===void 0||n.push({name:u,expression:c,span:l,line:e.line(l.start),statement:i,tags:ta(e,i,o?.start??l.start)})}}return n}function Yg(e,t){const n=[];for(const r of jr(t,ce.sourceDefinition)){const i=e.span(r),s=e.text_(ye(r,"sourceNameDef")),o=ye(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=Sr(o,ce.exploreProperties)[0],d=c&&Ys(e,c),h={start:e.lineStarts[e.line(i.start)],end:i.end},f=[];if(c)for(const g of Sr(c,ce.whereStatement)){const v=Bd(e,g);v&&f.push(v)}n.push({name:s,base:u,span:i,line:e.line(i.start),statement:h,...d?{properties:d}:{},views:c?qg(e,c):[],dimensions:c?Kg(e,c):[],wheres:f})}return n}function Xg(e,t){const n=[];for(const r of jr(t,ce.givenStatement)){const i=e.terminal(ye(r,"GIVEN")),s=ye(r,"givenDefList"),o=i?e.line(i.start):void 0;for(const a of s?Ut(s,"givenDef"):[]){const l=e.span(a),u=e.span(ye(a,"givenNameDef")),c=u&&e.text.slice(u.start,u.end);if(!l||!u||!c)continue;const d={start:u.start,end:l.end},h=e.line(d.start);n.push({name:c,declaration:e.text.slice(d.start,d.end),span:d,line:h,statement:{start:e.lineStarts[h],end:d.end},tags:ta(e,l,d.start),...o!==void 0&&o!==h?{blockHeader:o}:{}})}}return n}function Qg(e,t){const n=[];for(const r of jr(t,ce.importStatement)){const i=e.span(r),s=e.text_(ye(r,"importURL"));if(!i||s===void 0)continue;const o=ye(r,"importSelect"),a=o?Ut(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 Vd(e){let t;try{t=await Gd(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 Vg(e),l=Zg(a,s);a.commentLines=l.lines;const u=Yg(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:Qg(a,i),sources:u,givens:Xg(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=>Jg(a,l.lines,c)}}}async function Gd(e,t){const{MalloyTranslator:n}=await import("@malloydata/malloy"),r=new n(t,null,{urls:{[t]:e}});return{problems:r.translate().problems??[],parse:r.parseStep?.response?.parse}}function Zg(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 h=e.utf16(c.startIndex);let f=e.utf16(c.stopIndex+1);if(!(h===void 0||f===void 0||f<h)){for(;f>h&&(e.text[f-1]===`
72
- `||e.text[f-1]==="\r");)f--;i.push({start:h,end:f})}}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),h=e.line(c.end-1);for(let v=d;v<=h;v++)u(v).trim()===""&&r.add(v);const f=a.slice(e.lineStarts[d],c.start).trim(),g=a.slice(c.end,e.lineStarts[h+1]??a.length).trim();f!==""&&g===""&&n.set(h,c)}return{trailing:n,lines:r,all:i}}function Jg(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 Oi=e=>e.ok===!1;function Ar(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 Xs=e=>e.map(t=>t.text);function ev(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(`
73
- `):void 0,artifact:n}}function tv(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 nv(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(),...rv(n(Xs(Ar(e,t,i.line).tags)).tag)})}return r.length>0?r:void 0}function rv(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 iv(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(s=>s[1])}async function Di(e){const{parseAnnotation:t}=await import("@malloydata/malloy-tag"),n=e.split(`
74
- `),r=await Vd(e);if(Nd(r))return{ok:!1,reason:r.reason,...r.line?{line:r.line}:{}};const i=r.parsed,{description:s,artifact:o}=ev(n),a=o.find(b=>b.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=iv(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(b=>b.names?{kind:"names",names:b.names,from:b.from}:{kind:"all",from:b.from}),h=[],f=[],g=new Map;for(const b of i.sources){const _={name:b.name,base:b.base};b.dimensions.length>0&&(_.dimensions=b.dimensions.map($=>({name:$.name,expression:$.expression}))),h.push(_);for(const $ of b.dimensions){const O=t(Xs(Ar(i,n,$.line).tags)).tag?.tag("drill");if(!O)continue;const D=O.textArray("to")??[O.text("to")??""];f.push({source:b.name,name:$.name,expression:$.expression,to:D.filter(Boolean),...O.text("given")?{given:O.text("given")}:{}})}g.set(b.name,new Map(b.views.map($=>[$.name,$])))}const v=[];for(const b of c){const _=j.tileSteps(b);if(!_)return{ok:!1,reason:`The tile \`${b}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:$,view:O}=_,D=g.get($)?.get(O);if(D===void 0){v.push({name:O,source:$,declaration:{kind:"inherited"}});continue}const M=t(Xs(D.tags)).tag,I=D.body.kind==="reference"?{kind:"reference",from:D.body.from}:D.body.kind==="inline"?{kind:"inline"}:void 0;if(I===void 0){v.push({name:O,source:$,declaration:{kind:"opaque",why:D.body.kind==="unsupported"?D.body.why:"unreadable"},...M?.text("label")?{label:M.text("label")}:{},...M?.text("subtitle")?{subtitle:M.text("subtitle")}:{},...M?.numeric("colspan")!==void 0?{colspan:M.numeric("colspan")}:{},...M?.has("break")?{break:!0}:{},...M?.has("borderless")?{borderless:!0}:{}});continue}const K=tv(D.body.kind==="reference"?D.body.refinement:D.body.kind==="inline"?D.body.stage:void 0);v.push({name:O,source:$,declaration:I,...K?{filters:K}:{},...M?.text("label")?{label:M.text("label")}:{},...M?.text("subtitle")?{subtitle:M.text("subtitle")}:{},...M?.numeric("colspan")!==void 0?{colspan:M.numeric("colspan")}:{},...M?.has("break")?{break:!0}:{},...M?.has("borderless")?{borderless:!0}:{}})}const w=nv(i,n,t),x={},m=u?.tag("givens");for(const b of Object.keys(m?.dict??{})){const _=m?.text(b);_!==void 0&&(x[b]=_)}const p=l?.tag("dashboard")?.numeric("columns");return{ok:!0,document:{title:u?.text("title")??"",...s?{description:s}:{},...p===void 0?{}:{columns:p},...u?.has("autorun")?{autorun:u.isTrue("autorun")}:{},imports:d,sources:h,...w?{localGivens:w}:{},...Object.keys(x).length>0?{startingGivens:x}:{},...f.length>0?{drills:f}:{},tiles:v}}}async function Qa(e){const{problems:t}=await Gd(e,"file://splice-check.malloy");return t.filter(n=>n.code==="syntax-error").map(n=>n.message??"").sort()}const Qs=e=>e.ok===!1;function be(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 sv(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
75
- `&&t.push(n+1);return t}function ov(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 Ud(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=${$n(e.label)}`),e.subtitle!==void 0&&t.push(`# subtitle=${$n(e.subtitle)}`),t}function li(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const av=new Set(["colspan","break","borderless","label","subtitle"]),lv=new Set(["label","description","control","suggest","range_min","range_max"]),cv=(e,t)=>be(e.imports)===be(t.imports);function Za(e){const t=[];if(e.label!==void 0&&t.push(`label=${$n(e.label)}`),e.description!==void 0&&t.push(`description=${$n(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 Ja=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function dv(e,t,n){const r=e.sources.find(i=>i.name===t)?.views.find(i=>i.name===n);return r?r.line:-1}function el(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(n=>`"${n}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const Ti=e=>`${e.source}.${e.name}`,$n=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Zs=e=>be([e.name,e.source,e.declaration]),gt=Zs,tl=e=>be(e.tiles.map(gt));function uv(e,t){const n=new Set(e.tiles.map(gt)),r=new Set(t.tiles.map(gt)),i=e.tiles.filter(d=>!r.has(gt(d))),s=t.tiles.filter(d=>!n.has(gt(d))),a=i.length>0||s.length>0||tl(e)!==tl(t);for(const d of s)if(d.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${d.name}\` is ${d.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const l=new Map(e.sources.map(d=>[d.name,d])),u=new Set(e.imports.flatMap(d=>d.kind==="names"?d.names:[]));for(const d of e.sources)u.add(d.base);const c=t.sources.filter(d=>!l.has(d.name));for(const d of e.sources){const h=t.sources.find(f=>f.name===d.name);if(!h||h.base!==d.base)return{ok:!1,reason:`The source \`${d.name}\` cannot be changed or removed here.`}}for(const d of c){if(!s.some(h=>h.source===d.name))return{ok:!1,reason:`A new source \`${d.name}\` needs a tile on it.`};if(!u.has(d.base))return{ok:!1,reason:`\`${d.base}\` is not imported by name in this file, so a tile cannot be put on it. The builder does not add imports: import { ${d.base} } from the model first.`}}return cv(e,t)?{currentKeys:n,nextKeys:r,removedTiles:i,addedTiles:s,newSources:c,currentSources:l,reordered:a}:{ok:!1,reason:"The dashboard's imports cannot be changed here."}}function fv(e){const{lines:t,wholeLine:n,next:r,reordered:i,currentKeys:s,nextKeys:o,edits:a}=e;if(i){const l=j.artifactLine(t);if(l<0)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const u=[...t[l].matchAll(/"([^"]+)"/g)].map(g=>g[1]),c=new Map;for(const g of u){const v=g.split("->").map(w=>w.trim());v.length===2&&c.set(`${v[0]}->${v[1]}`,g)}const d=r.tiles.map(g=>c.get(`${g.source}->${g.name}`)??(o.has(gt(g))&&!s.has(gt(g))?`${g.source} -> ${g.name}`:void 0));if(d.some(g=>g===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const h=`tiles=[${d.map(g=>`"${g}"`).join(", ")}]`,f=t[l].replace(/tiles\s*=\s*\[[\s\S]*?\]/,h);f!==t[l]&&a.push({...n(l),text:`${f}
76
- `})}}function hv(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||be(r.startingGivens)!==be(i.startingGivens)){const o=j.artifactLine(t);if(o<0)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=s.find(v=>v.start===n(o).start&&v.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,h=-1;for(let v=c;v<l.length;v++)if(l[v]==="{")d++;else if(l[v]==="}"&&--d===0){h=v;break}if(c<0||h<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let f=l.slice(c+1,h);const g=(v,w)=>{const x=new RegExp(`\\s*\\b${v}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);w===void 0?f=f.replace(x,""):x.test(f)?f=f.replace(x,` ${v}=${w}`):f=`${f.replace(/\s+$/,"")} ${v}=${w} `};if(r.title!==i.title&&g("title",i.title?$n(i.title):void 0),r.autorun!==i.autorun&&g("autorun",i.autorun===void 0?void 0:String(i.autorun)),be(r.startingGivens)!==be(i.startingGivens)){f=f.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const v=Object.entries(i.startingGivens??{});v.length>0&&(f=`${f.replace(/\s+$/,"")} givens { ${v.map(([w,x])=>`${w}=${$n(x)}`).join(" ")} }`)}f=f.replace(/\s{2,}/g," "),l=`${l.slice(0,c+1)}${f.startsWith(" ")?f:` ${f}`}${f.endsWith(" ")?"":" "}${l.slice(h)}`,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}
69
+ `);if(n.length>Aa||r.length>Aa)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 Mp(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 Ip({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=Be.usePublisherTheme(),o=S.useMemo(()=>e?Mp(Pp(t,n)):[],[e,t,n]),a=o.filter(u=>u.kind==="add").length,l=o.filter(u=>u.kind==="del").length;return y.jsx(j.AppDialog,{open:e,onClose:i,maxWidth:"md",title:"Review the change to the file",description:y.jsxs(y.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."," ",y.jsxs(k.Box,{component:"span",sx:{fontVariantNumeric:"tabular-nums"},children:["+",a," −",l]})]}),actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Keep editing"}),y.jsx(k.Button,{variant:"contained",onClick:r,children:"Save this"})]}),children:y.jsx(k.Box,{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"?y.jsx(k.Box,{component:"span",sx:{display:"block",opacity:.55,py:.25},children:`⋯ ${u.count} unchanged line${u.count===1?"":"s"}`},c):y.jsxs(k.Box,{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 rs="self";function jp({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=Be.usePublisherTheme(),[l,u]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const g=(t.drills??[]).filter(v=>v.source===n.name);u((n.dimensions??[]).map(v=>{const w=g.find(x=>x.name===v.name);return{name:v.name,expression:v.expression,to:w?.to??[],given:w?.given??""}}))},[e,n,t]);const c=(g,v)=>u(w=>w.map((x,m)=>{if(m!==g)return x;const p={...x};return v(p),p})),d=[rs,...i.filter(g=>g!==rs)],h=g=>g===rs?"This dashboard":g,f=()=>{n&&(o(l.filter(g=>g.to.length>0).map(g=>({source:n.name,name:g.name,expression:g.expression,to:g.to,...g.given?{given:g.given}:{}}))),s())};return y.jsx(j.AppDialog,{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:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",onClick:f,disabled:l.length===0,children:"Apply"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:l.length===0?y.jsx(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?y.jsxs(y.Fragment,{children:[y.jsx(k.Box,{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"," ",y.jsx(k.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((g,v)=>y.jsxs(k.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[y.jsxs(k.Box,{sx:{minWidth:0,pt:.75},children:[y.jsx(k.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:g.name}),y.jsxs(k.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:g.expression,children:["is ",g.expression]})]}),y.jsx(k.TextField,{select:!0,size:"small",label:"Clicks go to",value:g.to,inputProps:{"aria-label":`Where ${g.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.length===0?"Not clickable":w.map(h).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:w=>c(v,x=>{const m=w.target.value;x.to=Array.isArray(m)?m:String(m).split(",").filter(Boolean)}),children:d.map(w=>y.jsxs(k.MenuItem,{value:w,children:[y.jsx(k.Checkbox,{size:"small",checked:g.to.includes(w),sx:{p:0,mr:1}}),y.jsx(k.ListItemText,{primary:h(w)})]},w))}),y.jsxs(k.TextField,{select:!0,size:"small",label:"Sets the control",value:g.given,disabled:g.to.length===0,inputProps:{"aria-label":`Control ${g.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:g.given===""?`Named ${g.name}, like the dimension`:void 0,onChange:w=>c(v,x=>{x.given=w.target.value}),children:[y.jsx(k.MenuItem,{value:"",children:y.jsx("em",{children:"Same name as the dimension"})}),r.map(w=>y.jsx(k.MenuItem,{value:w,children:w},w))]})]},g.name))})})}const Od=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function Ap({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,h]=S.useState(""),[f,g]=S.useState("select"),[v,w]=S.useState(""),[x,m]=S.useState(""),[p,b]=S.useState([]),[_,$]=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}),h(n.label??"");const C=hp(t,n);b(C);const A=C.filter(E=>E.include),G=new Set(A.map(E=>E.field));m(G.size===1?A[0].field:n.field??""),$(G.size>1)}else c({kind:"new"}),h(""),g("select"),m(""),w(new Date().toISOString().slice(0,10)),b(t.tiles.map(C=>({include:Us(C),field:""}))),$(!1)},[e,n,t]);const D=S.useMemo(()=>[...(t.localGivens??[]).map(C=>C.name),...r.map(C=>C.name)],[t,r]),M=S.useMemo(()=>x.trim()?fp(x.trim(),D):"",[x,D]),I=u.kind==="existing"?n??r.find(C=>C.name===u.name):M?{name:M,type:Br({name:M,label:d,kind:f,field:x}).type}:void 0,K=I?.type!==void 0&&!I.type.startsWith("filter<"),W=p.find(C=>C.include)?.op??$i(I?.type),T=(C,A)=>b(G=>G.map((E,P)=>P===C?{...E,...A}:E)),z=C=>b(A=>A.map(G=>({...G,op:C}))),Y=C=>{const A=$i(C);b(G=>G.map(({op:E,...P})=>A?{...P,op:A}:P))},ne=C=>{c({kind:"existing",name:C.name}),m(C.field??""),Y(C.type)},Se=C=>{g(C),Y(Br({name:"X",label:d,kind:C,field:x}).type)},oe=t.tiles.map(Us),Le=oe.filter(Boolean).length,Ve=p.filter((C,A)=>C.include&&oe[A]).length,Ce=t.tiles.filter((C,A)=>(p[A]?.include??!1)&&oe[A]),Ye=Ce.length>0?Ce:t.tiles.filter((C,A)=>oe[A]),Ge=S.useMemo(()=>{const C=new Map;let A=!1;for(const G of Ye){const E=i?.(G);if(E){A=!0;for(const P of E)C.has(P.name)||C.set(P.name,P)}}return A?[...C.values()]:void 0},[p,t.tiles,i]),We=(()=>{const C=x.trim();for(const A of Ce){const G=i?.(A);if(!G||G.some(E=>E.name===C))return O(A)}return Ce[0]?O(Ce[0]):t.sources[0]?.base})(),Xe=C=>b(A=>A.map((G,E)=>({...G,include:C&&oe[E]}))),$e=S.useMemo(()=>_?p:p.map(C=>({...C,field:x})),[_,p,x]),fe=C=>{for(const A of Ye){const G=i?.(A)?.find(E=>E.name===C.trim());if(G?.type)return G.type}},L=C=>ai(I?.type,C.type),V=(C,A)=>{if(C.trim()==="")return"Pick the field this filter compares.";const G=A?i?.(A):void 0;if(!G)return;const E=G.find(P=>P.name===C.trim());if(!E)return`Not a field of ${A?O(A):"the tiles' source"}.`;if(E.type&&!ai(I?.type,E.type))return`${C.trim()} is ${Pa(E.type)}; this filter compares ${Pa(I?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},_e=C=>{if(m(C),l||u.kind!=="new")return;const A=fe(C),G=Br({name:"X",label:d,kind:f,field:C}).type;A&&!ai(G,A)&&Se(dp(A))},X=$e.map((C,A)=>C.include&&oe[A]?V(C.field,t.tiles[A]):void 0),ze=X.every(C=>C===void 0),te=!_&&Ve>0?Ce.map(C=>V(x,C)).find(Boolean):void 0,at=I!==void 0&&ze&&(u.kind==="existing"||x.trim()!==""&&M!==""),Fe=()=>{if(!(!I||!at))if(u.kind==="new")s(I.name,$e,Br({name:I.name,label:d.trim()||Od(I.name),kind:f,field:x.trim(),...We?{source:We}:{},...v?{dateDefault:v}:{}}));else if(n?.origin==="dashboard"&&n.local){const C=d.trim(),A=C!==(n.local.label??"");s(I.name,$e,A?{...n.local,...C?{label:C}:{}}:void 0)}else s(I.name,$e)},xt=l&&a.origin==="model";return{editing:l,shown:a,fromModel:xt,source:u,setSource:c,label:d,setLabel:h,kind:f,dateDefault:v,setDateDefault:w,field:x,rows:p,setRows:b,perTile:_,setPerTile:$,newName:M,target:I,valueTyped:K,commonOp:W,setRow:T,setCommonOp:z,pickExisting:ne,pickKind:Se,bindable:oe,bindableCount:Le,included:Ve,commonFields:Ge,setAll:Xe,accepts:L,pickField:_e,rowProblems:X,commonProblem:te,canApply:at,apply:Fe}}function Ra({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 h=S.useMemo(()=>(n??[]).filter(g=>r?.(g)??!0).map(g=>g.name),[n,r]),f=S.useMemo(()=>new Map((n??[]).map(g=>[g.name,g.type])),[n]);return y.jsx(k.Autocomplete,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(g,v)=>t(v),value:e,onChange:(g,v)=>t(typeof v=="string"?v:""),disabled:l,disableClearable:!0,renderOption:(g,v)=>S.createElement("li",{...g,key:v},y.jsx(k.Typography,{variant:"body2",sx:{flex:1},children:v}),f.get(v)&&y.jsx(k.Typography,{variant:"caption",sx:{opacity:.6},children:f.get(v)?.replace(/_type$/,"")})),renderInput:g=>y.jsx(k.TextField,{...g,label:i,placeholder:c,autoFocus:u,error:o,helperText:a,inputProps:{...g.inputProps,"aria-label":s}}),sx:d})}const La=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 Rp({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:l}=Be.usePublisherTheme(),{editing:u,shown:c,fromModel:d,source:h,setSource:f,label:g,setLabel:v,kind:w,dateDefault:x,setDateDefault:m,field:p,rows:b,setRows:_,perTile:$,setPerTile:O,newName:D,target:M,valueTyped:I,commonOp:K,setRow:W,setCommonOp:T,pickExisting:z,pickKind:Y,bindable:ne,bindableCount:Se,included:oe,commonFields:Le,setAll:Ve,accepts:Ce,pickField:Ye,rowProblems:Ge,commonProblem:We,canApply:Xe,apply:$e}=Ap({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),fe=(L,V,_e)=>y.jsx(k.TextField,{select:!0,size:"small",label:"Compares",value:L??">=",onChange:X=>V(X.target.value),inputProps:{"aria-label":_e},sx:{width:130},children:up.filter(X=>X.op!=="~").map(X=>y.jsx(k.MenuItem,{value:X.op,children:X.label},X.op))});return y.jsx(j.AppDialog,{open:e,onClose:s,title:u?c.label??c.name:"Add a filter",description:u?y.jsxs(y.Fragment,{children:[y.jsxs(k.Box,{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:y.jsxs(y.Fragment,{children:[u&&y.jsx(k.Button,{color:"error",onClick:()=>a(c.name),"aria-label":`Remove control ${c.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Tooltip,{title:Xe||M===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:y.jsx("span",{children:y.jsx(k.Button,{variant:"contained",onClick:$e,disabled:!Xe,children:u?"Apply":"Add filter"})})})]}),children:y.jsxs(k.Stack,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&y.jsxs(k.ToggleButtonGroup,{exclusive:!0,size:"small",value:h.kind,onChange:(L,V)=>{V==="new"?f({kind:"new"}):V==="existing"&&r[0]&&z(r[0])},"aria-label":"Where the filter comes from",children:[y.jsx(k.ToggleButton,{value:"new",children:"New in this dashboard"}),y.jsx(k.ToggleButton,{value:"existing",children:"From the model"})]}),!u&&h.kind==="existing"?y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:h.name,onChange:L=>{const V=r.find(_e=>_e.name===L.target.value);V&&z(V)},children:r.map(L=>y.jsxs(k.MenuItem,{value:L.name,children:[L.label??L.name,y.jsxs(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",L.name]})]},L.name))}):null,y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!$&&y.jsx(Ra,{value:p,onChange:Ye,fields:Le,accepts:Ce,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:We!==void 0,helperText:We??(!u&&D?`Declared as $${D}`:void 0),sx:{flex:1,minWidth:200}}),!d&&y.jsx(k.TextField,{size:"small",label:"Label",placeholder:D?Od(D):"",value:g,onChange:L=>v(L.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),I&&!$&&fe(K,T,"Comparison")]}),!u&&h.kind==="new"&&y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:w,onChange:L=>Y(L.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:L=>Ma.find(V=>V.kind===L)?.label??String(L)}},sx:{flex:1},children:Ma.map(L=>y.jsxs(k.MenuItem,{value:L.kind,children:[L.label,y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:L.hint})]},L.kind))}),w==="date"&&y.jsx(k.TextField,{size:"small",type:"date",label:"Starts at",value:x,onChange:L=>m(L.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),y.jsxs(k.Box,{children:[y.jsxs(k.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[y.jsx(k.Checkbox,{size:"small",checked:Se>0&&oe===Se,indeterminate:oe>0&&oe<Se,disabled:Se===0,onChange:L=>Ve(L.target.checked),inputProps:{"aria-label":"All tiles"}}),y.jsxs(k.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",oe," of ",t.tiles.length," tiles"]}),y.jsx(k.Button,{size:"small",onClick:()=>{$||_(L=>L.map(V=>({...V,field:p}))),O(L=>!L)},children:$?"Same field for all":"Adjust per tile"})]}),y.jsx(k.Stack,{sx:{gap:$?1:0},children:t.tiles.map((L,V)=>{const _e=b[V],X=L.label??L.name,ze=$?Ge[V]:void 0;return y.jsxs(k.Stack,{direction:"row",sx:{gap:1,alignItems:$?"flex-start":"center",opacity:ne[V]?1:.6},children:[y.jsx(k.Checkbox,{size:"small",disabled:!ne[V],checked:(_e?.include??!1)&&ne[V],inputProps:{"aria-label":`Filter ${X}`},onChange:te=>W(V,{include:te.target.checked})}),y.jsx(k.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:$?1:0},noWrap:!0,children:X}),ne[V]?$&&y.jsxs(y.Fragment,{children:[I&&fe(_e?.op,te=>W(V,{op:te}),`Comparison for ${X}`),y.jsx(Ra,{value:_e?.field??"",onChange:te=>W(V,{field:te}),fields:i?.(L),accepts:Ce,label:"Field",ariaLabel:`Field for ${X}`,disabled:!_e?.include,error:ze!==void 0,helperText:ze,sx:{width:220}})]}):y.jsx(k.Tooltip,{title:La(t.tiles[V]).reason,children:y.jsx(k.Typography,{variant:"caption",sx:{color:l.tileTitle},children:La(t.tiles[V]).label})})]},`${L.source}.${L.name}`)})}),oe===0&&y.jsx(k.Typography,{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 Dd(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:u=>s(c=>{if(c===void 0)return c;const d=structuredClone(c);return u(d),d}),close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const Lp=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}}),is=[2,3,4,6,8,12,16,24];function Wp({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=Be.usePublisherTheme(),{draft:s,patch:o,close:a}=Dd(t,e!==null,r,n),l=s?.columns!==void 0&&!is.includes(s.columns)?[...is,s.columns].sort((u,c)=>u-c):is;return y.jsx(k.Popover,{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&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsx(k.Typography,{variant:"overline",sx:{color:i.tileTitle,lineHeight:1.5},children:"Dashboard"}),y.jsx(k.TextField,{size:"small",label:"Title",value:s.title,autoFocus:!0,inputProps:{"aria-label":"Dashboard title"},onChange:u=>o(c=>{c.title=u.target.value})}),y.jsx(k.TextField,{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})}),y.jsxs(k.TextField,{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:[y.jsx(k.MenuItem,{value:"",children:"Default (2)"}),l.map(u=>y.jsx(k.MenuItem,{value:u,children:u},u))]}),y.jsx(k.FormControlLabel,{control:y.jsx(k.Switch,{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:y.jsxs(k.Typography,{variant:"body2",children:["Run as controls change",y.jsx(k.Typography,{component:"span",variant:"caption",sx:{display:"block",opacity:.7},children:"Off, readers press Apply. For a page whose queries are slow."})]})})]})})}const zp=j.createSvgIcon(y.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function Fp({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:i,children:s}){const{theme:o}=Be.usePublisherTheme();return y.jsx(y.Fragment,{children:y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsxs(k.Stack,{direction:"row","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",minHeight:32},children:[y.jsx(zp,{sx:{fontSize:18,color:o.tileTitle,opacity:.7}}),y.jsx(k.Typography,{variant:"subtitle2",sx:{color:o.tileTitle,mr:.5},children:"Filters"}),e.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{color:o.tileTitle,opacity:.8},children:"None yet."}),e.map(a=>{const l=n(a.name,a.type);return y.jsx(k.Tooltip,{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:y.jsx(k.Chip,{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)}),y.jsx(k.Box,{sx:{ml:"auto"},children:y.jsx(j.SecondaryButton,{label:"Filter",icon:y.jsx(j.AddIcon,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const Np=(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}),Bp=(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},Td=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),Cd=e=>`gap.${e}`,Vp=(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:pt(e[o-1]),colspan:t-r}),l&&(r=0),n.push(Td(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:pt(i),colspan:t-r}),n};var Gp=Object.create,Pd=Object.defineProperty,Up=Object.defineProperties,Hp=Object.getOwnPropertyDescriptor,qp=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,Md=Object.prototype.hasOwnProperty,Id=Object.prototype.propertyIsEnumerable,Kp=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ir=e=>{throw TypeError(e)},qs=(e,t,n)=>t in e?Pd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ss=(e,t)=>{for(var n in t||(t={}))Md.call(t,n)&&qs(e,n,t[n]);if(Ei)for(var n of Ei(t))Id.call(t,n)&&qs(e,n,t[n]);return e},os=(e,t)=>Up(e,qp(t)),Yp=(e,t)=>{var n={};for(var r in e)Md.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ei)for(var r of Ei(e))t.indexOf(r)<0&&Id.call(e,r)&&(n[r]=e[r]);return n},Xp=e=>{var t;return[,,,Gp((t=void 0)!=null?t:null)]},jd=["class","method","getter","setter","accessor","field","value","get","set"],ir=e=>e!==void 0&&typeof e!="function"?Ir("Function expected"):e,Qp=(e,t,n,r,i)=>({kind:jd[e],name:t,metadata:r,addInitializer:s=>n._?Ir("Already initialized"):i.push(ir(s||null))}),Zp=(e,t)=>qs(t,Kp("metadata"),e[3]),Gr=(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},Ad=(e,t,n,r,i,s)=>{for(var o,a,l,u,c,d=t&7,h=!1,f=!1,g=e.length+1,v=jd[d+5],w=e[g-1]=[],x=e[g]||(e[g]=[]),m=(i=i.prototype,Hp({get[n](){return sr(this,s)},set[n](b){return Ft(this,s,b)}},n)),p=r.length-1;p>=0;p--)u=Qp(d,n,l={},e[3],x),u.static=h,u.private=f,c=u.access={has:b=>n in b},c.get=b=>b[n],c.set=(b,_)=>b[n]=_,a=(0,r[p])({get:m.get,set:m.set},u),l._=1,a===void 0?ir(a)&&(m[v]=a):typeof a!="object"||a===null?Ir("Object expected"):(ir(o=a.get)&&(m.get=o),ir(o=a.set)&&(m.set=o),ir(o=a.init)&&w.unshift(o));return m&&Pd(i,n,m),i},Rd=(e,t,n)=>t.has(e)||Ir("Cannot "+n),sr=(e,t,n)=>(Rd(e,t,"read from private field"),t.get(e)),Un=(e,t,n)=>t.has(e)?Ir("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ft=(e,t,n,r)=>(Rd(e,t,"write to private field"),t.set(e,n),n);function Bt(e){return e instanceof ea||e instanceof Fd}var Ur=10,Jp=class extends Me{constructor(e){super(e);const t=tt(()=>{const{dragOperation:r}=e;if(br(r.activatorEvent)&&Bt(r.source)&&r.status.initialized){const i=e.registry.plugins.get(Pr);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(!br(r.nativeEvent)||!Bt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:l}=i,{by:u}=r;if(!u)return;const c=eg(u),{source:d,target:h}=s,{center:f}=s.shape.current,g=[],v=[];ue(()=>{for(const _ of l.droppables){const{id:$}=_;if(!_.accepts(d)||$===h?.id&&Bt(_)||!_.element)continue;let O=_.shape;const D=new ct(_.element,{getBoundingClientRect:M=>mr(M,void 0,.2)});!D.height||!D.width||(c=="down"&&f.y+Ur<D.center.y||c=="up"&&f.y-Ur>D.center.y||c=="left"&&f.x-Ur>D.center.x||c=="right"&&f.x+Ur<D.center.x)&&(g.push(_),_.shape=D,v.push(()=>_.shape=O))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(g,Bf);ue(()=>v.forEach(_=>_()));const[x]=w;if(!x)return;const{id:m}=x,{index:p,group:b}=d.sortable;o.setDropTarget(m).then(()=>{const{source:_,target:$,shape:O}=s;if(!_||!Bt(_)||!O)return;const{index:D,group:M,target:I}=_.sortable,K=p!==D||b!==M,W=K?I:$?.element;if(!W)return;Cc(W);const T=new ct(W);if(!T)return;const z=dt.delta(T,dt.from(O.current.boundingRectangle),_.alignment);o.move({by:z}),K?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function eg(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 tg=Object.defineProperty,ng=Object.defineProperties,rg=Object.getOwnPropertyDescriptors,Wa=Object.getOwnPropertySymbols,ig=Object.prototype.hasOwnProperty,sg=Object.prototype.propertyIsEnumerable,za=(e,t,n)=>t in e?tg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))ig.call(t,n)&&za(e,n,t[n]);if(Wa)for(var n of Wa(t))sg.call(t,n)&&za(e,n,t[n]);return e},rn=(e,t)=>ng(e,rg(t));function og(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Hr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function as(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function ag(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,b)=>p===b||p!==null&&typeof p=="object"&&"id"in p&&p.id===b;if(Array.isArray(e)){const p=e.findIndex(_=>l(_,s.id)),b=e.findIndex(_=>l(_,o.id));if(p===-1||b===-1){if(as(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==p)return n(e,p,_)}return n(e,p,b)}const u=Object.entries(e);let c=-1,d,h=-1,f;for(const[p,b]of u)if(c===-1&&(c=b.findIndex(_=>l(_,s.id)),c!==-1&&(d=p)),h===-1&&(h=b.findIndex(_=>l(_,o.id)),h!==-1&&(f=p)),c!==-1&&h!==-1)break;if(c===-1&&as(s)){const p=s.initialGroup==null?void 0:Hr(e,s.initialGroup),b=s.initialIndex,_=s.group==null?void 0:Hr(e,s.group),$=s.index;if(p==null||_==null||p===_&&b===$)return"preventDefault"in t&&t.preventDefault(),e;if(p===_)return rn(nn({},e),{[p]:n(e[p],b,$)});const O=e[p][b];return rn(nn({},e),{[p]:[...e[p].slice(0,b),...e[p].slice(b+1)],[_]:[...e[_].slice(0,$),O,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:g}=s.manager,v=(i=(r=g.shape)==null?void 0:r.current.center)!=null?i:g.position.current;if(f==null){const p=Hr(e,o.id);if(p!=null){const b=o.shape&&v.y>o.shape.center.y?e[p].length:0;f=p,h=b}}if(d==null||f==null||d===f&&c===h){if(d!=null&&d===f&&c===h&&as(s)){const p=s.group==null?void 0:Hr(e,s.group),b=s.group!=null&&p!==d,_=s.index!==c;if(b||_){const $=s.group==null?d:p;if($!=null){if(d===$)return rn(nn({},e),{[d]:n(e[d],c,s.index)});const O=e[d][c];return rn(nn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[$]:[...e[$].slice(0,s.index),O,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===f)return rn(nn({},e),{[d]:n(e[d],c,h)});const x=o.shape&&Math.round(v.y)>Math.round(o.shape.center.y)?1:0,m=e[d][c];return rn(nn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[f]:[...e[f].slice(0,h+x),m,...e[f].slice(h+x)]})}function lg(e,t){return ag(e,t,og)}function Fa(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Na(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 Ba="__default__",cg=class extends Me{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof ea){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(!Bt(o)||!Bt(a)||o.sortable===a.sortable)return;const l=t(),u=Fa(l),c=o.sortable.group===a.sortable.group,d=l.get(o.sortable.group),h=c?d:l.get(a.sortable.group);!d||!h||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var f,g;const v=t();if(Na(u,l,v))return;const w=o.sortable.element,x=a.sortable.element;if(!x||!w||!c&&a.id===o.sortable.group)return;const m=qr(d),p=c?m:qr(h),b=(f=o.sortable.group)!=null?f:Ba,_=(g=a.sortable.group)!=null?g:Ba,$={[b]:m,[_]:p},O=lg($,r);if($===O)return;const D=O[_].indexOf(o.sortable),M=O[_].indexOf(a.sortable);i.collisionObserver.disable(),Va(w,D,x,M),ue(()=>{for(const[I,K]of O[b].entries())K.index=I;if(!c)for(const[I,K]of O[_].entries())K.group=a.sortable.group,K.index=I}),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;Bt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=Fa(a),u=a.get(o.sortable.initialGroup);u&&i.renderer.rendering.then(()=>{const c=t();if(Na(l,a,c))return;const d=qr(u),h=qr(u,ug),f=o.sortable.element,g=h.indexOf(o.sortable),v=d[g],w=v?.element;!v||!w||!f||(Va(f,v.index,w,o.index),ue(()=>{for(const x of a.values()){const m=Array.from(x).values();for(const p of m)p.index=p.initialIndex,p.group=p.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function Va(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function dg(e,t){return e.index-t.index}function ug(e,t){return e.initialIndex-t.initialIndex}function qr(e,t=dg){return Array.from(e).sort(t)}var Ga=[Jp,cg],Ld={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function Ua(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 Kr=new Su,Wd,zd,Ot,Zo,or,ar,Jo,hn;zd=[H],Wd=[H];var Ni=class{constructor(e,t){Un(this,Zo,Gr(Ot,8,this)),Gr(Ot,11,this),Un(this,or),Un(this,ar),Un(this,Jo,Gr(Ot,12,this)),Gr(Ot,15,this),Un(this,hn),this.register=()=>(ue(()=>{var g,v;(g=this.manager)==null||g.registry.register(this.droppable),(v=this.manager)==null||v.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{ue(()=>{var g,v;(g=this.manager)==null||g.registry.unregister(this.droppable),(v=this.manager)==null||v.registry.unregister(this.draggable)})},this.destroy=()=>{ue(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:i,group:s,index:o,sensors:a,type:l,transition:u=Ld,plugins:c}=n,d=Yp(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const h=st(c,Ga),f=Ua(i);this.droppable=new ea(os(ss({},d),{disabled:f.droppable}),t,this),this.draggable=new Fd(os(ss({},d),{disabled:f.draggable,plugins:h,effects:()=>[()=>{var g,v,w;const x=(g=this.manager)==null?void 0:g.dragOperation.status;x?.initializing&&this.id===((w=(v=this.manager)==null?void 0:v.dragOperation.source)==null?void 0:w.id)&&Kr.clear(this.manager),x?.dragging&&Kr.set(this.manager,this.id,U(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:g,group:v,manager:w}=this,x=sr(this,ar),m=sr(this,or);(g!==x||v!==m)&&(Ft(this,ar,g),Ft(this,or,v),this.animate())},()=>{var g,v;const{target:w}=this,{isDragSource:x}=this.draggable;((v=(g=this.draggable.pluginConfig(Vo))==null?void 0:g.feedback)!=null?v:"default")==="move"&&x&&(this.droppable.disabled=!w)},...r()],type:l,sensors:a}),t,this),Ft(this,hn,d.element),this.manager=t,this.index=o,Ft(this,ar,o),this.group=s,Ft(this,or,s),this.type=l,this.transition=u}get initialIndex(){var e,t;return(t=(e=Kr.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=Kr.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){U(()=>{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}=ht(i),l=wa(i,a,!1),u=wa(i,a);if(o.x||o.y){const c=Ao(Ke(i))?os(ss({},t),{duration:0}):t;Pc({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){ue(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){ue(()=>{const t=sr(this,hn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),Ft(this,hn,e)})}get element(){var e,t;const n=sr(this,hn);if(n)return(t=(e=Es.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=st(e,Ga)}set disabled(e){const t=Ua(e);ue(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){ue(()=>{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??Mc}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){ue(()=>{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)}};Ot=Xp();Zo=new WeakMap;or=new WeakMap;ar=new WeakMap;Jo=new WeakMap;hn=new WeakMap;Ad(Ot,4,"index",zd,Ni,Zo);Ad(Ot,4,"group",Wd,Ni,Jo);Zp(Ot,Ni);var Fd=class extends Wi{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}},ea=class extends zi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},fg=Object.defineProperty,hg=Object.defineProperties,pg=Object.getOwnPropertyDescriptors,Ha=Object.getOwnPropertySymbols,gg=Object.prototype.hasOwnProperty,vg=Object.prototype.propertyIsEnumerable,qa=(e,t,n)=>t in e?fg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ls=(e,t)=>{for(var n in t||(t={}))gg.call(t,n)&&qa(e,n,t[n]);if(Ha)for(var n of Ha(t))vg.call(t,n)&&qa(e,n,t[n]);return e},mg=(e,t)=>hg(e,pg(t));function yg(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:h,target:f,type:g,plugins:v}=e,w=ls(ls({},Ld),e.transition),x=pd(p=>new Ni(mg(ls({},e),{transition:w,register:!1,handle:yn(a),element:yn(o),target:yn(f)}),p)),m=dd(x,bg);return le(i,()=>x.id=i),Ln(()=>{ue(()=>{x.group=u,x.index=l})},[x,u,l]),le(g,()=>x.type=g),le(t,()=>x.accept=t,void 0,rt),le(s,()=>s&&(x.data=s)),le(l,()=>{var p;(p=x.manager)!=null&&p.dragOperation.status.idle&&w?.idle&&x.refreshShape()},Rh),si(a,p=>x.handle=p),si(o,p=>x.element=p),si(f,p=>x.target=p),le(c,()=>x.disabled=c??!1,void 0,rt),le(h,()=>x.sensors=h,void 0,rt),le(n,()=>x.collisionDetector=n),le(r,()=>x.collisionPriority=r),le(v,()=>x.plugins=v,void 0,rt),le(w,()=>x.transition=w,void 0,rt),le(d,()=>x.modifiers=d,void 0,rt),le(e.alignment,()=>x.alignment=e.alignment),{sortable:m,get isDragging(){return m.isDragging},get isDropping(){return m.isDropping},get isDragSource(){return m.isDragSource},get isDropTarget(){return m.isDropTarget},handleRef:S.useCallback(p=>{x.handle=p??void 0},[x]),ref:S.useCallback(p=>{var b,_;!p&&((b=x.element)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.element=p??void 0)},[x]),sourceRef:S.useCallback(p=>{var b,_;!p&&((b=x.source)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.source=p??void 0)},[x]),targetRef:S.useCallback(p=>{var b,_;!p&&((b=x.target)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.target=p??void 0)},[x])}}function bg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Ks="tile",Nd="gap",xg='[role="separator"]',wg=[Fs.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(Fs.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(xg)!==null}),nd],_g=e=>[...e,Vo.configure({feedback:"clone"})];function kg({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=yg({id:e,index:t,type:Ks,accept:Ks,collisionDetector:Lo,plugins:_g});return y.jsx(y.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function Sg({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=ap({id:e,type:Nd,accept:Ks,collisionDetector:Lo,data:{after:t}});return y.jsx(y.Fragment,{children:n({ref:r,isDropTarget:i})})}const $g=j.createSvgIcon(y.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"})),Eg=j.createSvgIcon(y.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 Og({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:h}=Be.usePublisherTheme();return y.jsx(kg,{id:pt(e),index:t,children:({ref:f,handleRef:g,isDragSource:v})=>y.jsxs(k.Box,{ref:f,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 ${h.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 ${h.drillLink}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"&:hover":{outlineColor:n?h.drillLink:h.cardBorder,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.10)"}},children:[d,y.jsx(k.Box,{ref:g,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:h.tileTitle,bgcolor:h.tile,opacity:v||n?.9:0,transition:"opacity 120ms","&:hover":{opacity:1},"&:active":{cursor:"grabbing"},"&:focus-visible":{opacity:1,outline:`2px solid ${h.drillLink}`,outlineOffset:1}},children:y.jsx($g,{sx:{fontSize:16}})}),i===void 0&&y.jsx(k.IconButton,{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:h.tileTitle,bgcolor:h.tile,opacity:n||r?.9:0,transition:"opacity 120ms","&:hover":{opacity:1,bgcolor:h.tile}},children:y.jsx(Eg,{sx:{fontSize:16}})}),i!==void 0&&y.jsxs(k.Box,{"aria-hidden":!0,sx:{position:"absolute",top:"6px",right:"6px",px:.75,py:.25,borderRadius:"4px",bgcolor:h.drillLink,color:h.tile,fontSize:11,fontVariantNumeric:"tabular-nums",zIndex:4,pointerEvents:"none"},children:[i," of ",s," ·"," ",Math.round(i/s*100),"%"]}),e.declaration.kind!=="inherited"&&y.jsx(k.Box,{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:h.drillLink}}})]})})}function Dg({tile:e}){const{theme:t}=Be.usePublisherTheme();return y.jsxs(j.TileCard,{sx:{minHeight:140},children:[y.jsx(j.TileHeading,{title:e.label??e.name,subtitle:e.subtitle}),y.jsxs(k.Typography,{variant:"caption",sx:{display:"block",color:t.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function Tg({after:e}){const{theme:t}=Be.usePublisherTheme();return y.jsx(Sg,{id:Cd(e),after:e,children:({ref:n,isDropTarget:r})=>y.jsx(k.Box,{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 Cg({columns:e}){const{theme:t}=Be.usePublisherTheme();return y.jsx(k.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${j.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>y.jsx(k.Box,{sx:{borderLeft:`1px dashed ${t.drillLink}`,borderRight:r===e-1?`1px dashed ${t.drillLink}`:"none",opacity:.35}},r))})}var Pg=Object.defineProperty,Mg=Object.defineProperties,Ig=Object.getOwnPropertyDescriptors,Ka=Object.getOwnPropertySymbols,jg=Object.prototype.hasOwnProperty,Ag=Object.prototype.propertyIsEnumerable,Ya=(e,t,n)=>t in e?Pg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))jg.call(t,n)&&Ya(e,n,t[n]);if(Ka)for(var n of Ka(t))Ag.call(t,n)&&Ya(e,n,t[n]);return e},on=(e,t)=>Mg(e,Ig(t));function Rg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Yr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function cs(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Lg(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,b)=>p===b||p!==null&&typeof p=="object"&&"id"in p&&p.id===b;if(Array.isArray(e)){const p=e.findIndex(_=>l(_,s.id)),b=e.findIndex(_=>l(_,o.id));if(p===-1||b===-1){if(cs(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==p)return n(e,p,_)}return n(e,p,b)}const u=Object.entries(e);let c=-1,d,h=-1,f;for(const[p,b]of u)if(c===-1&&(c=b.findIndex(_=>l(_,s.id)),c!==-1&&(d=p)),h===-1&&(h=b.findIndex(_=>l(_,o.id)),h!==-1&&(f=p)),c!==-1&&h!==-1)break;if(c===-1&&cs(s)){const p=s.initialGroup==null?void 0:Yr(e,s.initialGroup),b=s.initialIndex,_=s.group==null?void 0:Yr(e,s.group),$=s.index;if(p==null||_==null||p===_&&b===$)return"preventDefault"in t&&t.preventDefault(),e;if(p===_)return on(sn({},e),{[p]:n(e[p],b,$)});const O=e[p][b];return on(sn({},e),{[p]:[...e[p].slice(0,b),...e[p].slice(b+1)],[_]:[...e[_].slice(0,$),O,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:g}=s.manager,v=(i=(r=g.shape)==null?void 0:r.current.center)!=null?i:g.position.current;if(f==null){const p=Yr(e,o.id);if(p!=null){const b=o.shape&&v.y>o.shape.center.y?e[p].length:0;f=p,h=b}}if(d==null||f==null||d===f&&c===h){if(d!=null&&d===f&&c===h&&cs(s)){const p=s.group==null?void 0:Yr(e,s.group),b=s.group!=null&&p!==d,_=s.index!==c;if(b||_){const $=s.group==null?d:p;if($!=null){if(d===$)return on(sn({},e),{[d]:n(e[d],c,s.index)});const O=e[d][c];return on(sn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[$]:[...e[$].slice(0,s.index),O,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===f)return on(sn({},e),{[d]:n(e[d],c,h)});const x=o.shape&&Math.round(v.y)>Math.round(o.shape.center.y)?1:0,m=e[d][c];return on(sn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[f]:[...e[f].slice(0,h+x),m,...e[f].slice(h+x)]})}function Wg(e,t){return Lg(e,t,Rg)}function zg({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:d=>{const{source:h,target:f}=d.operation;if(!h||!f)return;const g=s.current??e;let v;if(f.type===Nd){const{after:w}=f.data,x=g.findIndex(b=>pt(b)===h.id);if(x<0||w===h.id)return;const p=g.filter((b,_)=>_!==x).findIndex(b=>pt(b)===w)+1;v=Bp(g,x,p)}else{const w=g.map(pt),x=Wg(w,d);if(x.every((p,b)=>p===w[b]))return;const m=new Map(g.map(p=>[pt(p),p]));v=Np(x.map(p=>m.get(p)),e.map(p=>p.break??!1))}s.current=v,i(v)},onDragEnd:d=>{a(!1);const h=s.current;if(s.current=void 0,i(void 0),d.canceled||!h)return;t(h);const f=h.findIndex(g=>pt(g)===d.operation.source?.id);f>=0&&n(f)}}}const Xa=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function Fg({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:(c,d)=>{const h=o.current?.getBoundingClientRect(),f=c.currentTarget.parentElement?.getBoundingClientRect();!h||!f||(c.stopPropagation(),c.preventDefault(),c.currentTarget.setPointerCapture(c.pointerId),Xa(!0),n(d),s({index:d,span:e[d]?.colspan??1,left:f.left,track:(h.width-j.GRID_GAP_PX*(t-1))/t}))},onResize:c=>{if(!i)return;const d=c.clientX-i.left,h=Math.round((d+j.GRID_GAP_PX)/(i.track+j.GRID_GAP_PX)),f=Math.min(Math.max(h,1),t);f!==i.span&&s({...i,span:f})},endResize:c=>{if(c.currentTarget.hasPointerCapture(c.pointerId)&&c.currentTarget.releasePointerCapture(c.pointerId),Xa(!1),!i)return;const{index:d,span:h}=i;s(void 0),r(d,h)}}}function Ng({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,columns:s,onDrills:o}){const{theme:a}=Be.usePublisherTheme(),{draft:l,patch:u,close:c,discard:d}=Dd(t,e!==null,r,n),h=l!==void 0&&l.declaration.kind!=="inherited";return y.jsx(k.Popover,{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&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsxs(k.Typography,{variant:"overline",sx:{color:a.tileTitle,lineHeight:1.5},children:[l.source," → ",l.name]}),h?y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{size:"small",label:"Title",value:l.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:f=>u(g=>{const v=f.target.value;v===""?delete g.label:g.label=v})}),y.jsx(k.TextField,{size:"small",label:"Subtitle",value:l.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:f=>u(g=>{const v=f.target.value;v===""?delete g.subtitle:g.subtitle=v})}),y.jsxs(k.Stack,{direction:"row",sx:{gap:.5,alignItems:"center"},children:[y.jsx(k.Typography,{variant:"caption",sx:{color:a.tileTitle,mr:.5},children:"Width"}),[["Full",1],["½",2],["⅓",3],["¼",4]].map(([f,g])=>{const v=Math.max(1,Math.round(s/g)),w=(l.colspan??1)===v;return y.jsx(k.Button,{size:"small",variant:w?"contained":"outlined","aria-label":`Width ${f}`,"aria-pressed":w,onClick:()=>u(x=>{x.colspan=v}),sx:{minWidth:40,px:1},children:f},f)})]})]}):y.jsx(k.Typography,{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"&&y.jsxs(k.Typography,{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."]}),y.jsx(k.Divider,{}),y.jsxs(k.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[h?y.jsx(k.Button,{size:"small",onClick:()=>{c(),o()},children:"Clickable cells…"}):y.jsx("span",{}),y.jsx(k.Button,{color:"error",size:"small",onClick:()=>{d(),i()},children:"Remove tile"})]})]})})}const Bd=e=>e.ok===!1,me=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),Bi=e=>e!==void 0&&e.ruleIndex!==void 0&&(e.childCount??0)>0,de={sourceDefinition:e=>me(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>me(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>me(e,"VIEW","subQueryDefList"),defDimension:e=>me(e,"defList","DIMENSION"),exploreProperties:e=>me(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>me(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>me(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>me(e,"WHERE","filterClauseList"),givenDef:e=>me(e,"givenNameDef"),givenStatement:e=>me(e,"GIVEN","givenDefList"),importStatement:e=>me(e,"IMPORT","importURL"),vArrow:e=>me(e,"ARROW","vExpr","segExpr"),segRefine:e=>me(e,"PLUS","segExpr"),segOps:e=>me(e,"queryProperties"),segField:e=>me(e,"fieldPath")&&!me(e,"segExpr"),segParen:e=>me(e,"OPAREN","CPAREN","vExpr"),compare:e=>me(e,"fieldExpr","compareOp"),givenRef:e=>me(e,"GIVEN_REF")};function Bg(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 Vg(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
70
+ `&&t.push(n+1);return t}class Gg{constructor(t){this.text=t,this.map=Bg(t),this.lineStarts=Vg(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 jr(e,t,n=[]){Bi(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)jr(e.getChild(r),t,n);return n}const Ug=e=>me(e,"OCURLY","CCURLY");function Sr(e,t){const n=[],r=i=>{if(Bi(i)){if(t(i)){n.push(i);return}if(!Ug(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 ye=(e,t)=>e[t]?.call(e),Ut=(e,t)=>e[t]?.call(e)??[];function Hg(e,t){if(!de.compare(t)||(t.childCount??0)!==3)return;const n=t.getChild(2);if(!de.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 Vd(e,t){const n=e.positioned(t);if(!n)return;const r=ye(t,"filterClauseList"),i=[];for(const s of r?Ut(r,"fieldExpr"):[]){const o=e.positioned(s);if(!o)continue;const a=jr(s,de.givenRef).map(l=>e.text_(l)).filter(l=>l!==void 0).map(l=>l.replace(/^\$/,""));i.push({...o,givens:a,binding:Hg(e,s)})}return{...n,clauses:i}}function Ys(e,t){const n=e.span(t);if(!n)return;const r=[],i=[];for(const u of Sr(t,de.queryStatement)){const c=e.positioned(u);c&&r.push(c);const d=ye(u,"whereStatement");if(d&&de.whereStatement(d)){const h=Vd(e,d);h&&i.push(h)}}const s=n.start+1,o=n.end-1,a=!e.text.slice(n.start,n.end).includes(`
71
+ `),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 ta(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 qg(e,t){const n=ye(t,"segExpr");if(!n)return{kind:"unsupported",why:"an unreadable expression"};const r=de.vArrow(t);if(de.segOps(n)){const i=ye(n,"queryProperties"),s=i&&Ys(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(de.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(de.segRefine(n)){const i=Ut(n,"segExpr"),s=i[0],o=i[i.length-1];let a=s;for(;de.segRefine(a);){const h=Ut(a,"segExpr");if(h.some(f=>de.segOps(f)||de.segParen(f)))return{kind:"unsupported",why:"a chained refinement"};a=h[0]}if(!a||!de.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(!de.segOps(o)){const h=e.span(n);return h?{kind:"reference",from:e.text.slice(h.start,h.end),fromSpan:h}:{kind:"unsupported",why:"an unreadable refinement"}}const u=e.text.slice(l.start,l.end),c=ye(o,"queryProperties"),d=c&&Ys(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 Kg(e,t){const n=[];for(const r of Sr(t,de.defExploreQuery)){const i=e.span(r),s=ye(r,"subQueryDefList");if(!i||!s)continue;const o=Ut(s,"exploreQueryDef").filter(de.exploreQueryDef),a=e.terminal(ye(r,"VIEW"));for(const l of o){const u=e.span(l),c=ye(l,"exploreQueryNameDef"),d=e.text_(c),h=ye(l,"vExpr");!u||!d||!h||n.push({name:d,span:u,line:e.line(u.start),statement:i,tags:ta(e,i,a?.start??u.start),siblings:o.length,body:qg(e,h)})}}return n}function Yg(e,t){const n=[];for(const r of Sr(t,de.defDimension)){const i=e.span(r),s=ye(r,"defList");if(!i||!s)continue;const o=e.terminal(ye(r,"DIMENSION"));for(const a of Ut(s,"fieldDef")){const l=e.span(a),u=e.text_(ye(a,"fieldNameDef"))?.trim(),c=e.text_(ye(a,"fieldExpr"))?.trim();!l||!u||c===void 0||n.push({name:u,expression:c,span:l,line:e.line(l.start),statement:i,tags:ta(e,i,o?.start??l.start)})}}return n}function Xg(e,t){const n=[];for(const r of jr(t,de.sourceDefinition)){const i=e.span(r),s=e.text_(ye(r,"sourceNameDef")),o=ye(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=Sr(o,de.exploreProperties)[0],d=c&&Ys(e,c),h={start:e.lineStarts[e.line(i.start)],end:i.end},f=[];if(c)for(const g of Sr(c,de.whereStatement)){const v=Vd(e,g);v&&f.push(v)}n.push({name:s,base:u,span:i,line:e.line(i.start),statement:h,...d?{properties:d}:{},views:c?Kg(e,c):[],dimensions:c?Yg(e,c):[],wheres:f})}return n}function Qg(e,t){const n=[];for(const r of jr(t,de.givenStatement)){const i=e.terminal(ye(r,"GIVEN")),s=ye(r,"givenDefList"),o=i?e.line(i.start):void 0;for(const a of s?Ut(s,"givenDef"):[]){const l=e.span(a),u=e.span(ye(a,"givenNameDef")),c=u&&e.text.slice(u.start,u.end);if(!l||!u||!c)continue;const d={start:u.start,end:l.end},h=e.line(d.start);n.push({name:c,declaration:e.text.slice(d.start,d.end),span:d,line:h,statement:{start:e.lineStarts[h],end:d.end},tags:ta(e,l,d.start),...o!==void 0&&o!==h?{blockHeader:o}:{}})}}return n}function Zg(e,t){const n=[];for(const r of jr(t,de.importStatement)){const i=e.span(r),s=e.text_(ye(r,"importURL"));if(!i||s===void 0)continue;const o=ye(r,"importSelect"),a=o?Ut(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 Gd(e){let t;try{t=await Ud(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 Gg(e),l=Jg(a,s);a.commentLines=l.lines;const u=Xg(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:Zg(a,i),sources:u,givens:Qg(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=>ev(a,l.lines,c)}}}async function Ud(e,t){const{MalloyTranslator:n}=await import("@malloydata/malloy"),r=new n(t,null,{urls:{[t]:e}});return{problems:r.translate().problems??[],parse:r.parseStep?.response?.parse}}function Jg(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 h=e.utf16(c.startIndex);let f=e.utf16(c.stopIndex+1);if(!(h===void 0||f===void 0||f<h)){for(;f>h&&(e.text[f-1]===`
72
+ `||e.text[f-1]==="\r");)f--;i.push({start:h,end:f})}}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),h=e.line(c.end-1);for(let v=d;v<=h;v++)u(v).trim()===""&&r.add(v);const f=a.slice(e.lineStarts[d],c.start).trim(),g=a.slice(c.end,e.lineStarts[h+1]??a.length).trim();f!==""&&g===""&&n.set(h,c)}return{trailing:n,lines:r,all:i}}function ev(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 Oi=e=>e.ok===!1;function Ar(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 Xs=e=>e.map(t=>t.text);function tv(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(`
73
+ `):void 0,artifact:n}}function nv(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 rv(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(),...iv(n(Xs(Ar(e,t,i.line).tags)).tag)})}return r.length>0?r:void 0}function iv(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 sv(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(s=>s[1])}async function Di(e){const{parseAnnotation:t}=await import("@malloydata/malloy-tag"),n=e.split(`
74
+ `),r=await Gd(e);if(Bd(r))return{ok:!1,reason:r.reason,...r.line?{line:r.line}:{}};const i=r.parsed,{description:s,artifact:o}=tv(n),a=o.find(b=>b.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=sv(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(b=>b.names?{kind:"names",names:b.names,from:b.from}:{kind:"all",from:b.from}),h=[],f=[],g=new Map;for(const b of i.sources){const _={name:b.name,base:b.base};b.dimensions.length>0&&(_.dimensions=b.dimensions.map($=>({name:$.name,expression:$.expression}))),h.push(_);for(const $ of b.dimensions){const O=t(Xs(Ar(i,n,$.line).tags)).tag?.tag("drill");if(!O)continue;const D=O.textArray("to")??[O.text("to")??""];f.push({source:b.name,name:$.name,expression:$.expression,to:D.filter(Boolean),...O.text("given")?{given:O.text("given")}:{}})}g.set(b.name,new Map(b.views.map($=>[$.name,$])))}const v=[];for(const b of c){const _=j.tileSteps(b);if(!_)return{ok:!1,reason:`The tile \`${b}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:$,view:O}=_,D=g.get($)?.get(O);if(D===void 0){v.push({name:O,source:$,declaration:{kind:"inherited"}});continue}const M=t(Xs(D.tags)).tag,I=D.body.kind==="reference"?{kind:"reference",from:D.body.from}:D.body.kind==="inline"?{kind:"inline"}:void 0;if(I===void 0){v.push({name:O,source:$,declaration:{kind:"opaque",why:D.body.kind==="unsupported"?D.body.why:"unreadable"},...M?.text("label")?{label:M.text("label")}:{},...M?.text("subtitle")?{subtitle:M.text("subtitle")}:{},...M?.numeric("colspan")!==void 0?{colspan:M.numeric("colspan")}:{},...M?.has("break")?{break:!0}:{},...M?.has("borderless")?{borderless:!0}:{}});continue}const K=nv(D.body.kind==="reference"?D.body.refinement:D.body.kind==="inline"?D.body.stage:void 0);v.push({name:O,source:$,declaration:I,...K?{filters:K}:{},...M?.text("label")?{label:M.text("label")}:{},...M?.text("subtitle")?{subtitle:M.text("subtitle")}:{},...M?.numeric("colspan")!==void 0?{colspan:M.numeric("colspan")}:{},...M?.has("break")?{break:!0}:{},...M?.has("borderless")?{borderless:!0}:{}})}const w=rv(i,n,t),x={},m=u?.tag("givens");for(const b of Object.keys(m?.dict??{})){const _=m?.text(b);_!==void 0&&(x[b]=_)}const p=l?.tag("dashboard")?.numeric("columns");return{ok:!0,document:{title:u?.text("title")??"",...s?{description:s}:{},...p===void 0?{}:{columns:p},...u?.has("autorun")?{autorun:u.isTrue("autorun")}:{},imports:d,sources:h,...w?{localGivens:w}:{},...Object.keys(x).length>0?{startingGivens:x}:{},...f.length>0?{drills:f}:{},tiles:v}}}async function Qa(e){const{problems:t}=await Ud(e,"file://splice-check.malloy");return t.filter(n=>n.code==="syntax-error").map(n=>n.message??"").sort()}const Qs=e=>e.ok===!1;function be(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 ov(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
75
+ `&&t.push(n+1);return t}function av(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 Hd(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=${$n(e.label)}`),e.subtitle!==void 0&&t.push(`# subtitle=${$n(e.subtitle)}`),t}function li(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const lv=new Set(["colspan","break","borderless","label","subtitle"]),cv=new Set(["label","description","control","suggest","range_min","range_max"]),dv=(e,t)=>be(e.imports)===be(t.imports);function Za(e){const t=[];if(e.label!==void 0&&t.push(`label=${$n(e.label)}`),e.description!==void 0&&t.push(`description=${$n(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 Ja=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function uv(e,t,n){const r=e.sources.find(i=>i.name===t)?.views.find(i=>i.name===n);return r?r.line:-1}function el(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(n=>`"${n}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const Ti=e=>`${e.source}.${e.name}`,$n=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Zs=e=>be([e.name,e.source,e.declaration]),gt=Zs,tl=e=>be(e.tiles.map(gt));function fv(e,t){const n=new Set(e.tiles.map(gt)),r=new Set(t.tiles.map(gt)),i=e.tiles.filter(d=>!r.has(gt(d))),s=t.tiles.filter(d=>!n.has(gt(d))),a=i.length>0||s.length>0||tl(e)!==tl(t);for(const d of s)if(d.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${d.name}\` is ${d.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const l=new Map(e.sources.map(d=>[d.name,d])),u=new Set(e.imports.flatMap(d=>d.kind==="names"?d.names:[]));for(const d of e.sources)u.add(d.base);const c=t.sources.filter(d=>!l.has(d.name));for(const d of e.sources){const h=t.sources.find(f=>f.name===d.name);if(!h||h.base!==d.base)return{ok:!1,reason:`The source \`${d.name}\` cannot be changed or removed here.`}}for(const d of c){if(!s.some(h=>h.source===d.name))return{ok:!1,reason:`A new source \`${d.name}\` needs a tile on it.`};if(!u.has(d.base))return{ok:!1,reason:`\`${d.base}\` is not imported by name in this file, so a tile cannot be put on it. The builder does not add imports: import { ${d.base} } from the model first.`}}return dv(e,t)?{currentKeys:n,nextKeys:r,removedTiles:i,addedTiles:s,newSources:c,currentSources:l,reordered:a}:{ok:!1,reason:"The dashboard's imports cannot be changed here."}}function hv(e){const{lines:t,wholeLine:n,next:r,reordered:i,currentKeys:s,nextKeys:o,edits:a}=e;if(i){const l=j.artifactLine(t);if(l<0)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const u=[...t[l].matchAll(/"([^"]+)"/g)].map(g=>g[1]),c=new Map;for(const g of u){const v=g.split("->").map(w=>w.trim());v.length===2&&c.set(`${v[0]}->${v[1]}`,g)}const d=r.tiles.map(g=>c.get(`${g.source}->${g.name}`)??(o.has(gt(g))&&!s.has(gt(g))?`${g.source} -> ${g.name}`:void 0));if(d.some(g=>g===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const h=`tiles=[${d.map(g=>`"${g}"`).join(", ")}]`,f=t[l].replace(/tiles\s*=\s*\[[\s\S]*?\]/,h);f!==t[l]&&a.push({...n(l),text:`${f}
76
+ `})}}function pv(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||be(r.startingGivens)!==be(i.startingGivens)){const o=j.artifactLine(t);if(o<0)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=s.find(v=>v.start===n(o).start&&v.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,h=-1;for(let v=c;v<l.length;v++)if(l[v]==="{")d++;else if(l[v]==="}"&&--d===0){h=v;break}if(c<0||h<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let f=l.slice(c+1,h);const g=(v,w)=>{const x=new RegExp(`\\s*\\b${v}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);w===void 0?f=f.replace(x,""):x.test(f)?f=f.replace(x,` ${v}=${w}`):f=`${f.replace(/\s+$/,"")} ${v}=${w} `};if(r.title!==i.title&&g("title",i.title?$n(i.title):void 0),r.autorun!==i.autorun&&g("autorun",i.autorun===void 0?void 0:String(i.autorun)),be(r.startingGivens)!==be(i.startingGivens)){f=f.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const v=Object.entries(i.startingGivens??{});v.length>0&&(f=`${f.replace(/\s+$/,"")} givens { ${v.map(([w,x])=>`${w}=${$n(x)}`).join(" ")} }`)}f=f.replace(/\s{2,}/g," "),l=`${l.slice(0,c+1)}${f.startsWith(" ")?f:` ${f}`}${f.endsWith(" ")?"":" "}${l.slice(h)}`,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}
77
77
  `:s.push({...n(o),text:`${l}
78
78
  `})}if(r.description!==i.description){const o=t.map((l,u)=>l.trim().startsWith('##"')?u:-1).filter(l=>l>=0),a=(i.description??"").split(`
79
79
  `).map(l=>l.trim()===""?'##"':`##" ${l.trim()}`).join(`
80
80
  `);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}
81
81
  `})}else if(i.description!==void 0){const l=j.artifactLine(t),u=n(l).start;s.push({start:u,end:u,text:`${a}
82
- `})}}}function pv(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,l=new Map((i.localGivens??[]).map(f=>[f.name,f])),u=new Map((s.localGivens??[]).map(f=>[f.name,f])),c=new Map(a.givens.map(f=>[f.name,f])),d=new Set;for(const[f,g]of l){const v=u.get(f);if(v!==void 0&&be(v)===be(g))continue;const w=c.get(f);if(w===void 0)return{ok:!1,reason:`Could not find where the given \`${f}\` is declared.`};const{tags:x}=Ar(a,t,w.line),m=v===void 0?x:x.filter(D=>{const M=li(D.text);return M!==void 0&&lv.has(M)});for(const D of m)o.push({...n(D.line),text:""}),d.add(D.line);const p=Ht(a,w.span.end-1);if(v===void 0){o.push({start:n(w.line).start,end:n(p).end,text:""});for(let C=w.line;C<=p;C++)d.add(C);const D=Math.min(w.line,...x.map(C=>C.line)),M=w.blockHeader??D,I=(t[p+1]??"x").trim()==="",K=M===0||t[M-1].trim()==="",z=w.blockHeader===void 0||![...c.values()].some(C=>C.blockHeader===w.blockHeader&&C.line>w.line&&u.has([...c.entries()].find(([,W])=>W===C)?.[0]??""));I&&K&&z&&!d.has(p+1)&&(o.push({...n(p+1),text:""}),d.add(p+1));continue}const b=r(w.line),_=Za(v),O=v.type!==g.type||v.default!==g.default?w.blockHeader===void 0?Ja(v):`${v.name} :: ${v.type} is ${v.default}`:t.slice(w.line,p+1).join(`
82
+ `})}}}function gv(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,l=new Map((i.localGivens??[]).map(f=>[f.name,f])),u=new Map((s.localGivens??[]).map(f=>[f.name,f])),c=new Map(a.givens.map(f=>[f.name,f])),d=new Set;for(const[f,g]of l){const v=u.get(f);if(v!==void 0&&be(v)===be(g))continue;const w=c.get(f);if(w===void 0)return{ok:!1,reason:`Could not find where the given \`${f}\` is declared.`};const{tags:x}=Ar(a,t,w.line),m=v===void 0?x:x.filter(D=>{const M=li(D.text);return M!==void 0&&cv.has(M)});for(const D of m)o.push({...n(D.line),text:""}),d.add(D.line);const p=Ht(a,w.span.end-1);if(v===void 0){o.push({start:n(w.line).start,end:n(p).end,text:""});for(let T=w.line;T<=p;T++)d.add(T);const D=Math.min(w.line,...x.map(T=>T.line)),M=w.blockHeader??D,I=(t[p+1]??"x").trim()==="",K=M===0||t[M-1].trim()==="",W=w.blockHeader===void 0||![...c.values()].some(T=>T.blockHeader===w.blockHeader&&T.line>w.line&&u.has([...c.entries()].find(([,z])=>z===T)?.[0]??""));I&&K&&W&&!d.has(p+1)&&(o.push({...n(p+1),text:""}),d.add(p+1));continue}const b=r(w.line),_=Za(v),O=v.type!==g.type||v.default!==g.default?w.blockHeader===void 0?Ja(v):`${v.name} :: ${v.type} is ${v.default}`:t.slice(w.line,p+1).join(`
83
83
  `).trim();o.push({start:n(w.line).start,end:n(p).end,text:(_?`${b}${_}
84
84
  `:"")+`${b}${O}
85
85
  `})}for(const[f,g]of c){if(g.blockHeader===void 0||u.has(f))continue;![...c.values()].some(w=>w.blockHeader===g.blockHeader&&!d.has(w.line))&&!d.has(g.blockHeader)&&(o.push({...n(g.blockHeader),text:""}),d.add(g.blockHeader))}const h=[...u.values()].filter(f=>!l.has(f.name));if(h.length>0){const f=Math.max(-1,...[...c.values()].map(p=>p.line)),g=(()=>{let p=-1;for(let b=0;b<t.length;b++){const _=t[b].trim();(_.startsWith("import ")||p>=0&&/^}\s*from\s/.test(_))&&(p=b)}return p})(),v=f>=0?f:g,w=h.map(p=>{const b=Za(p);return(b?`${b}
@@ -87,9 +87,9 @@
87
87
  `}).join(`
88
88
  `),x=v>=0?n(v).end:n(0).end;o.push({start:x,end:x,text:`
89
89
  ${w}`}),t.some(p=>p.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
90
- `})}}function gv(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,l=new Map((i.drills??[]).map(c=>[Ti(c),c])),u=new Map((s.drills??[]).map(c=>[Ti(c),c]));for(const c of new Set([...l.keys(),...u.keys()])){const d=l.get(c),h=u.get(c);if(d&&h&&be(d)===be(h))continue;const f=h??d;if(h&&h.to.length===0)return{ok:!1,reason:`The drill on \`${c}\` names no destination.`};const g=a.sources.find(m=>m.name===f.source)?.dimensions.find(m=>m.name===f.name);if(g===void 0)return{ok:!1,reason:`\`${f.name}\` is not a dimension \`${f.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:v}=Ar(a,t,g.line),w=v.find(m=>/^#\s*drill\b/.test(m.text)),x=r(g.line);if(h===void 0)w&&o.push({...n(w.line),text:""});else if(w)o.push({...n(w.line),text:`${x}${el(h)}
90
+ `})}}function vv(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,l=new Map((i.drills??[]).map(c=>[Ti(c),c])),u=new Map((s.drills??[]).map(c=>[Ti(c),c]));for(const c of new Set([...l.keys(),...u.keys()])){const d=l.get(c),h=u.get(c);if(d&&h&&be(d)===be(h))continue;const f=h??d;if(h&&h.to.length===0)return{ok:!1,reason:`The drill on \`${c}\` names no destination.`};const g=a.sources.find(m=>m.name===f.source)?.dimensions.find(m=>m.name===f.name);if(g===void 0)return{ok:!1,reason:`\`${f.name}\` is not a dimension \`${f.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:v}=Ar(a,t,g.line),w=v.find(m=>/^#\s*drill\b/.test(m.text)),x=r(g.line);if(h===void 0)w&&o.push({...n(w.line),text:""});else if(w)o.push({...n(w.line),text:`${x}${el(h)}
91
91
  `});else{const m=n(g.line).start;o.push({start:m,end:m,text:`${x}${el(h)}
92
- `})}}}function vv(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=Hd(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=Ht(s,a.statement.start),u=Ht(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({...Yd(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 mv(e){const{sourceText:t,lines:n,wholeLine:r,addedTiles:i,newSources:s,currentSources:o,edits:a,parsed:l}=e,u=new Map;for(const h of i){const f=u.get(h.source)??[];f.push(h),u.set(h.source,f)}const c=(h,f)=>{const g=h.declaration.kind==="reference"?h.declaration.from:h.name,v=(h.filters??[]).map(w=>`where: ${w.field} ${w.op??"~"} $${w.given}`).join(", ");return[...Ud(h).map(w=>`${f}${w}`),`${f}view: ${h.name} is ${g}${v?` + { ${v} }`:""}`].join(`
92
+ `})}}}function mv(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=qd(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=Ht(s,a.statement.start),u=Ht(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({...Xd(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 yv(e){const{sourceText:t,lines:n,wholeLine:r,addedTiles:i,newSources:s,currentSources:o,edits:a,parsed:l}=e,u=new Map;for(const h of i){const f=u.get(h.source)??[];f.push(h),u.set(h.source,f)}const c=(h,f)=>{const g=h.declaration.kind==="reference"?h.declaration.from:h.name,v=(h.filters??[]).map(w=>`where: ${w.field} ${w.op??"~"} $${w.given}`).join(", ");return[...Hd(h).map(w=>`${f}${w}`),`${f}view: ${h.name} is ${g}${v?` + { ${v} }`:""}`].join(`
93
93
  `)};let d=-1;for(const h of l.sources)d=Math.max(d,Ht(l,h.span.end-1));for(const[h,f]of u)if(o.has(h)){const g=l.sources.find(b=>b.name===h);if(!g)return{ok:!1,reason:`Could not find where the source \`${h}\` is declared.`};if(!g.properties)return{ok:!1,reason:`\`${h}\` never opens an \`extend { … }\` block, so a new tile cannot be added inside it.`};const v=g.line,w=Ht(l,g.properties.closeStart);let x=" ";for(let b=v+1;b<w;b++){const _=/^(\s+)view:/.exec(n[b]);if(_){x=_[1];break}}const m=r(w).start,p=(n[w-1]??"").trim()==="";a.push({start:m,end:m,text:(p?"":`
94
94
  `)+f.map(b=>c(b,x)).join(`
95
95
 
@@ -102,9 +102,9 @@ source: ${g.name} is ${g.base} extend {
102
102
  }
103
103
  `;let w=d;if(w<0)for(let p=0;p<n.length;p++){const b=n[p].trim();(/^(import\s|given:|}\s*from\s)/.test(b)||/^[A-Z_]+\s*::/.test(b))&&(w=p)}const x=w>=0?r(w).end:t.length,m=x===t.length&&!t.endsWith(`
104
104
  `)?`
105
- `:"";a.push({start:x,end:x,text:m+v}),d=w}}function yv(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=>[gt(c),c]));for(const c of o.tiles){const d=u.get(gt(c));if(d===void 0||be(d)===be(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 h=dv(l,c.source,c.name);if(h<0)return{ok:!1,reason:`Could not find where \`${c.name}\` is declared inside \`${c.source}\`.`};const{tags:f}=Ar(l,t,h),g=i(h),v=Ud(c),w=new Map(v.map($=>[li($)??$,$])),x=new Set;for(const $ of f){const O=li($.text);if(O===void 0||!av.has(O))continue;const D=w.get(O);if(D===void 0){a.push({...r($.line),text:""});continue}x.add(O),D!==$.text&&a.push({...r($.line),text:`${g}${D}
105
+ `:"";a.push({start:x,end:x,text:m+v}),d=w}}function bv(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=>[gt(c),c]));for(const c of o.tiles){const d=u.get(gt(c));if(d===void 0||be(d)===be(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 h=uv(l,c.source,c.name);if(h<0)return{ok:!1,reason:`Could not find where \`${c.name}\` is declared inside \`${c.source}\`.`};const{tags:f}=Ar(l,t,h),g=i(h),v=Hd(c),w=new Map(v.map($=>[li($)??$,$])),x=new Set;for(const $ of f){const O=li($.text);if(O===void 0||!lv.has(O))continue;const D=w.get(O);if(D===void 0){a.push({...r($.line),text:""});continue}x.add(O),D!==$.text&&a.push({...r($.line),text:`${g}${D}
106
106
  `})}const m=v.filter($=>!x.has(li($)??$));if(m.length>0){const $=n[h];a.push({start:$,end:$,text:m.map(O=>`${g}${O}
107
- `).join("")})}if(be(d.filters)===be(c.filters))continue;const p=Hd(e,c);if(!p)return{ok:!1,reason:`Could not find \`${c.name}\`'s declaration to filter it.`};if(p.body.kind==="reference"){const $=wv(e,c,p);if($)return $;continue}if(p.body.kind!=="inline")return{ok:!1,reason:`\`${c.name}\`'s body is ${p.body.why}, so there is no single first stage to write its filter into.`};const b=qd(c.filters,p.body.stage);if(b)return Kd(c.name,b.given);const _=Xd(e,c,p.body.stage);if(_)return _}}const Ht=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function Hd(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function qd(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 Kd(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 ci=e=>`where: ${e.field} ${e.op??"~"} $${e.given}`;function nl(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 bv(e,t,n){const r=e.commentIn(n);if(r)return r;const i=e.trailingComment(Ht(e,t.end-1));return i&&i.start>=t.end&&e.text.slice(t.end,i.start).trim()===""?i:void 0}function xv(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 Yd(e,t){const n=e.lineStarts[e.lineStarts.findLastIndex(a=>a<=t.start)],r=e.text.slice(n,t.start),i=e.text.indexOf(`
108
- `,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 Xd(e,t,n){const{parsed:r,edits:i}=e,s=new Map((t.filters??[]).map(h=>[h.given,h])),o=new Set;let a;for(const h of n.wheres){const f=h.clauses.map((v,w)=>({clause:v,index:w})).filter(({clause:v})=>v.binding!==void 0);if(f.length===0)continue;const g=f.filter(({clause:v})=>s.has(v.binding.given));for(const{clause:v}of f)o.add(v.binding.given);if(g.length===0&&f.length===h.clauses.length){const v=Yd(r,h.span),w=bv(r,h.span,v);if(w)return nl(t.name,r,w);i.push({...v,text:""});continue}g.length>0&&(a=h.span);for(let v=f.length-1;v>=0;v--){const{clause:w,index:x}=f[v],m=s.get(w.binding.given);if(!m){const b=xv(h.clauses,x),_=r.commentIn(b);if(_)return nl(t.name,r,_);i.push({...b,text:""});continue}const p=ci(m).replace(/^where:\s*/,"");p!==r.text.slice(w.span.start,w.span.end)&&i.push({...w.span,text:p})}}const l=(t.filters??[]).filter(h=>!o.has(h.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 h=r.trailingComment(Ht(r,u));h&&h.start>=u&&(u=h.end)}const c=a!==void 0&&!/,\s*$/.test(r.text.slice(0,u))?", ":" ",d=n.oneLine?`${c}${l.map(ci).join(", ")}`:l.map(h=>`
109
- ${n.indent}${ci(h)}`).join("");i.push({start:u,end:u,text:d})}function wv(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:i,refinement:s}=n.body,o=qd(t.filters,s);if(o)return Kd(t.name,o.given);const a=t.filters??[];if(!s){if(a.length===0)return;const c=` + { ${a.map(ci).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 Xd(e,t,s)}async function Js(e,t){const n=await Di(e);if(Oi(n))return{ok:!1,reason:`Cannot edit a file that will not open: ${n.reason}`};const r=n.document,i=uv(r,t);if("reason"in i)return i;const s=await Vd(e);if(Nd(s))return{ok:!1,reason:`Cannot edit a file that will not open: ${s.reason}`};const o=e.split(`
110
- `),a=sv(e),l=v=>({start:a[v],end:v+1<a.length?a[v+1]:e.length}),u=v=>/^\s*/.exec(o[v])?.[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 v of[fv,hv,pv,gv,vv,mv,yv]){const w=v(d);if(w)return w}const h=v=>{const{drills:w,localGivens:x,...m}=v,p=v.tiles.map(b=>{if(b.filters?.length)return b;const{filters:_,...$}=b;return $});return{...m,tiles:p,...w?.length?{drills:[...w].sort((b,_)=>Ti(b).localeCompare(Ti(_)))}:{},...x?.length?{localGivens:x}:{}}};if(c.length===0)return be(h(r))!==be(h(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 f=ov(e,c);if((await Qa(e)).length===0){const v=await Qa(f);if(v.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${v[0]}). Your changes are still here.`}}const g=await Di(f);return Oi(g)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${g.reason}`}:be(h(g.document))!==be(h(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:f}}function _v(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(x=>{o(void 0),n(m=>{const p=structuredClone(m.stack[m.index]);if(x(p),JSON.stringify(p)===JSON.stringify(m.stack[m.index]))return m;const _=[...m.stack.slice(0,m.index+1),p].slice(-100);return{stack:_,index:_.length-1}})},[]),d=S.useCallback(()=>{o(void 0),n(x=>x.index>0?{...x,index:x.index-1}:x)},[]),h=S.useCallback(()=>{o(void 0),n(x=>x.index<x.stack.length-1?{...x,index:x.index+1}:x)},[]),f=S.useCallback(async()=>{const x=await Js(r,u);if(Qs(x))return o(x.reason),{ok:!1,reason:x.reason};try{await e.onSave?.(x.source)}catch(m){const p=`Could not save: ${m}`;return o(p),{ok:!1,reason:p}}return i(x.source),l(u),o(void 0),{ok:!0}},[u,e,r]),g=S.useMemo(()=>JSON.stringify(u)!==JSON.stringify(a),[u,a]),v=S.useMemo(()=>{const x=new Set(a.tiles.map(Zs)),m=new Set(u.tiles.map(Zs));return[...x].some(p=>!m.has(p))||[...m].some(p=>!x.has(p))},[u,a]),w=S.useCallback(async()=>{const x=await Js(r,u);return Qs(x)?{ok:!1,reason:x.reason}:{ok:!0,source:x.source}},[u,r]);return{document:u,source:r,canUndo:t.index>0,canRedo:t.index<t.stack.length-1,dirty:g,...s===void 0?{}:{error:s},update:c,undo:d,redo:h,save:f,preview:w,structural:v}}function Qd({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:h="package"}){const f=_v({source:e,document:t,...n?{onSave:n}:{}}),[g,v]=S.useState(void 0),[w,x]=S.useState(!1),m=f.document.columns??j.DEFAULT_COLUMNS,{resize:p,gridBox:b,startResize:_,onResize:$,endResize:O}=zg({tiles:f.document.tiles,columns:m,onStart:v,commit:(E,P)=>f.update(B=>{B.tiles[E].colspan=P})}),{dragging:D,preview:M,onDragStart:I,onDragOver:K,onDragEnd:z}=Wg({tiles:f.document.tiles,commit:E=>f.update(P=>{P.tiles=E}),onLanded:v}),[C,W]=S.useState(void 0),[Y,ve]=S.useState(void 0),[Me,se]=S.useState(!1),[Le,Ve]=S.useState(void 0),[Te,Ye]=S.useState(null),[Ge,We]=S.useState(void 0);S.useEffect(()=>{r?.(f.document)},[f.document,r]),S.useEffect(()=>{i?.(f.dirty)},[f.dirty,i]);const Xe=S.useMemo(()=>Rp(f.document),[f.document]),Se=S.useMemo(()=>{const E=new Set((t.localGivens??[]).map(P=>P.name));return(a??[]).filter(P=>!E.has(P.name))},[t,a]),ue=S.useMemo(()=>ap(f.document,Se),[f.document,Se]),L=S.useMemo(()=>new Map(f.document.sources.map(E=>[E.name,ja(l,E.base)])),[l,f.document.sources]),V=S.useCallback(E=>L.get(E.source)??ja(l,E.source),[L,l]),_e=(E,P)=>{const B=[];for(const Q of f.document.tiles){const Ue=V(Q);if(!Ue)continue;const ke=new Map(Ue.map(ie=>[ie.name,ie.type]));for(const ie of Q.filters??[])ie.given===E&&(!ke.has(ie.field)||!ai(P,ke.get(ie.field)))&&B.push(`${ie.field} on ${Q.label??Q.name} (${f.document.sources.find($e=>$e.name===Q.source)?.base??Q.source})`)}return B},X=S.useMemo(()=>ue.filter(E=>E.origin==="model"&&E.boundTiles===0),[ue]),ze=S.useCallback(()=>{We(void 0),x(!0);const E=j.now(),{structural:P}=f,B=f.document.tiles.length;f.save().then(Q=>{Q.ok===!0?d?.({type:"dashboard.saved",tiles:B,structural:P,where:h,durationMs:j.now()-E}):d?.({type:"dashboard.save_refused",reason:Q.reason})}).finally(()=>x(!1))},[f,d,h]),te=S.useCallback(()=>{if(!(!n||!f.dirty||w)){if(!f.structural){ze();return}f.preview().then(E=>{E.ok?We({before:f.source,after:E.source}):ze()})}},[n,f,w,ze]),at=E=>{se(!1),f.update(P=>{let B=P.sources.find(ke=>ke.base===E.base);if(!B){const ke=new Set(P.sources.map($e=>$e.name));let ie=`${E.base}_tiles`;for(let $e=2;ke.has(ie);$e++)ie=`${E.base}_tiles_${$e}`;B={name:ie,base:E.base},P.sources.push(B)}const Q=new Set(P.tiles.filter(ke=>ke.source===B.name).map(ke=>ke.name));let Ue=`${E.view}_tile`;for(let ke=2;Q.has(Ue);ke++)Ue=`${E.view}_tile_${ke}`;P.tiles.push({name:Ue,source:B.name,declaration:{kind:"reference",from:E.view},colspan:E.colspan,...E.label?{label:E.label}:{}})}),v(f.document.tiles.length)},Fe=E=>{ve(void 0),v(void 0),f.update(P=>{P.tiles.splice(E,1)})};wp(S.useMemo(()=>({undo:f.undo,redo:f.redo,...n?{save:te}:{},escape:()=>{!Y&&!C&&v(void 0)},nudge:E=>{if(g===void 0)return;const P=f.document.tiles[g];if(!P||P.declaration.kind==="inherited")return;const B=Math.min(Math.max((P.colspan??1)+E,1),m);B!==(P.colspan??1)&&f.update(Q=>{Q.tiles[g].colspan=B})}}),[f,n,te,Y,C,g,m]));const xt=(E,P,B)=>{W(void 0),f.update(Q=>{B&&pp(Q,B),hp(Q,E,P)})},T=E=>{W(void 0),f.update(P=>gp(P,E))},A=(()=>{const E=f.document.tiles;return p!==void 0?E.map((P,B)=>B===p.index?{...P,colspan:p.span}:P):M??E})(),G=D?Bp(A,m):A.map(Dd);return y.jsxs(k.Stack,{sx:{gap:0},children:[y.jsx(_p,{canUndo:f.canUndo,canRedo:f.canRedo,onUndo:f.undo,onRedo:f.redo,dirty:f.dirty,saving:w,...n?{onSave:te}:{},...u?{actions:u}:{},...l?{onAddTile:()=>se(!0)}:{},onSettings:Ye}),y.jsxs(k.Stack,{sx:{gap:2,px:"4px",pb:"4px"},children:[y.jsx(j.DashboardProse,{title:f.document.title||"Untitled dashboard",...f.document.description?{description:f.document.description}:{}}),y.jsx(zp,{controls:ue,tileCount:f.document.tiles.length,unknownFieldsOf:_e,onEdit:E=>W({control:E}),onAdd:()=>W({}),children:o}),f.error&&y.jsx(k.Alert,{severity:"warning",children:f.error}),y.jsx(Gh,{sensors:xg,onDragStart:I,onDragOver:K,onDragEnd:z,children:y.jsxs(k.Box,{ref:b,sx:{position:"relative"},children:[(p!==void 0||D)&&y.jsx(Tg,{columns:m}),y.jsx(j.DashboardGrid,{tiles:G,columns:m,keyOf:E=>E.kind==="gap"?Td(E.after):pt(E.tile),renderTile:E=>{if(E.kind==="gap")return y.jsx(Dg,{after:E.after});const{tile:P,index:B}=E;return y.jsx(Eg,{tile:P,index:B,selected:B===g,menuOpen:Y?.index===B,resizeSpan:p?.index===B?p.span:void 0,columns:m,onSelect:()=>v(B),onOpenMenu:Q=>{v(B),ve({anchor:Q,index:B})},onResizeStart:Q=>_(Q,B),onResizeMove:$,onResizeEnd:O,children:s?s(P):y.jsx(Og,{tile:P})})}})]})}),y.jsx(Ap,{open:C!==void 0,document:f.document,...C?.control?{control:C.control}:{},available:X,...l?{fieldsFor:V}:{},onClose:()=>W(void 0),onApply:xt,onRemove:T}),y.jsx(Fg,{anchor:Y?.anchor??null,tile:Y===void 0?void 0:f.document.tiles[Y.index],onClose:()=>ve(void 0),onCommit:E=>{const P=Y?.index;P!==void 0&&f.update(B=>{B.tiles[P]=E})},onRemove:()=>{Y!==void 0&&Fe(Y.index)},columns:m,onDrills:()=>{Y!==void 0&&Ve(f.document.tiles[Y.index]?.source)}}),y.jsx(Ip,{open:Le!==void 0,document:f.document,source:f.document.sources.find(E=>E.name===Le),givenNames:ue.map(E=>E.name),dashboards:c??[],onClose:()=>Ve(void 0),onApply:E=>f.update(P=>{const Q=[...(P.drills??[]).filter(Ue=>Ue.source!==Le),...E];Q.length===0?delete P.drills:P.drills=Q})}),y.jsx(Lp,{anchor:Te,settings:Xe,onClose:()=>Ye(null),onCommit:E=>f.update(P=>{P.title=E.title,E.description===void 0?delete P.description:P.description=E.description,E.columns===void 0?delete P.columns:P.columns=E.columns,E.autorun===void 0?delete P.autorun:P.autorun=E.autorun})}),y.jsx(Tp,{open:Me,document:f.document,catalog:l,columns:m,onClose:()=>se(!1),onAdd:at}),y.jsx(Mp,{open:Ge!==void 0,before:Ge?.before??"",after:Ge?.after??"",onConfirm:ze,onClose:()=>We(void 0)})]})]})}function kv(e,t){const n=new Set;for(const s of e.tiles)for(const o of s.filters??[])n.add(o.given);const r=[],i=new Set;for(const s of e.localGivens??[])n.has(s.name)&&(i.add(s.name),r.push(Sv(s)));for(const s of t)s.name===void 0||i.has(s.name)||!n.has(s.name)||(i.add(s.name),r.push(s));return r}function Sv(e){return{name:e.name,type:e.type,default:e.default,...e.label===void 0?{}:{label:e.label},...e.description===void 0?{}:{description:e.description},...e.control===void 0?{}:{control:e.control},...e.suggest?{suggest:{...e.suggest.source===void 0?{}:{source:e.suggest.source},...e.suggest.query===void 0?{}:{query:e.suggest.query},dimension:e.suggest.dimension}}:{},...e.rangeMin===void 0?{}:{rangeMin:e.rangeMin},...e.rangeMax===void 0?{}:{rangeMax:e.rangeMax}}}function $v(e,t,n,r=new Map){if(t.declaration.kind==="inherited")return{expression:`${t.source} -> ${t.name}`,givenNames:void 0};const i=t.source,s=t.declaration.kind==="reference"?t.declaration.from:t.name,o=new Map((e.localGivens??[]).map(c=>[c.name,c.type])),a=[],l=[];for(const c of t.filters??[]){const d=`where: ${c.field} ${c.op??"~"}`;if(n.has(c.given)){a.push(c.given),l.push(`${d} $${c.given}`);continue}if(!o.has(c.given))continue;const h=j.malloyLiteral(r.get(c.given),o.get(c.given));h!==void 0&&l.push(`${d} ${h}`)}const u=l.join(", ");return{expression:`${i} -> ${s}`+(u?` + { ${u} }`:""),givenNames:a}}async function Ev(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 rl=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function Ov(e){const{onExit:t,onEvent:n,onDirtyChange:r}=e,i=(()=>{if("resourceUri"in e)try{return j.parseResourceUri(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}=Be.useServer(),h=ou.useQueryClient(),f=S.useRef(j.now()),g=S.useRef(n);g.current=n;const v=S.useRef(r);v.current=r;const w=j.useOptionalDocumentStorage()?.documentStorage,x=`dashboards/${a}.malloy`,m=j.useQueryWithApiError({queryKey:["dashboard-editor-model",s,o,x,l],queryFn:()=>c.models.getModel(s,o,x,l),enabled:u}),p=m.data?.data?.sourceText,[b,_]=S.useState(void 0),[$,O]=S.useState(void 0),[D,M]=S.useState(w===void 0),[I,K]=S.useState(!1),[z,C]=S.useState(void 0);S.useEffect(()=>{if(!w)return;let R=!1;return C(void 0),(async()=>{try{const ee=await w.listWorkspaces(!1),Ee=ee.find(fe=>fe.authoritative)??ee.find(fe=>fe.writeable);if(R)return;if(_(Ee),Ee!==void 0){const fe=await w.getDocument(rl(Ee.name,s,o,x)).catch(oe=>{if(!j.isDocumentNotFound(oe))throw oe});if(R)return;O(fe),K(fe!==void 0)}}catch(ee){if(R)return;C(il(ee))}R||M(!0)})(),()=>{R=!0}},[w,s,o,x]);const W=b?.authoritative===!0,Y=W&&z!==void 0,[ve,Me]=S.useState(void 0),se=(W||ve===!0)&&$!==void 0,[Le,Ve]=S.useState(void 0),[Te,Ye]=S.useState(void 0),Ge=S.useRef(void 0),We=S.useRef(void 0),[Xe,Se]=S.useState(void 0),ue=m.dataUpdatedAt,L=S.useRef(ue);L.current=ue;const V=Xe!==void 0&&Xe.onFetch===ue?Xe.text:p,_e=S.useRef(V);_e.current=V;const X=se?$:V,[ze,te]=S.useState(!1),[at,Fe]=S.useState(void 0),[xt,T]=S.useState(void 0),A=X!==void 0&&X!==xt,G=Le?.source,E=A&&ze&&G!==void 0&&X!==at,P=E?G:A?X:G??X,B=E?X:void 0,Q=S.useRef(G);Q.current=G;const Ue=S.useRef(X);Ue.current=X;const ke=S.useRef("package");ke.current=se?W?"record":"draft":"package",S.useEffect(()=>{if(P===void 0||!D||Y||P===Q.current)return;let R=!1;const ee=_e.current,Ee=Ue.current;return Di(P).then(fe=>{if(!R){if(Oi(fe)){const oe=fe.line?`${fe.reason} (line ${fe.line})`:fe.reason;Ye(oe),g.current?.({type:"dashboard.open_refused",reason:oe});return}Ye(void 0),Ge.current=void 0,We.current=ee,Se(void 0),Fe(void 0),T(Ee),Ve(oe=>({source:P,document:fe.document,generation:(oe?.generation??0)+1})),g.current?.({type:"dashboard.opened",from:ke.current,tiles:fe.document.tiles.length,durationMs:j.now()-f.current})}}),()=>{R=!0}},[P,D,Y]);const ie=b===void 0?void 0:rl(b.name,s,o,x),$e=S.useCallback(async R=>{if(!w||!ie)throw new Error("This host keeps no documents, so there is nowhere to save.");await w.saveDocument(ie,R),Ve(ee=>ee&&{...ee,source:R}),O(R),(W||ve===!0)&&T(R),W||Me(ee=>ee??!1)},[w,ie,W,ve]),[Qt,Ct]=S.useState(void 0),Rr=S.useCallback(async R=>{const ee=We.current,Ee=Ge.current??(ee===void 0?void 0:await Ev(ee));if(Ee===void 0)throw new Error("The package file is still loading; try again.");let fe;try{fe=await c.models.updateModelSource(s,o,x,{source:R,expectedHash:Ee})}catch(oe){throw h.invalidateQueries({queryKey:["dashboard-editor-model",s,o,x,l]}),new Error(Cv(oe))}if(Ve(oe=>oe&&{...oe,source:R}),Se({text:R,onFetch:L.current}),T(R),Ge.current=fe.data.contentHash,Ct(void 0),w&&ie)try{await w.deleteDocument(ie),O(void 0),K(!1)}catch(oe){j.isDocumentNotFound(oe)?(O(void 0),K(!1)):Ct(il(oe))}Me(!1),await h.invalidateQueries({queryKey:["dashboard-editor-model",s,o,x,l]});for(const oe of["dashboard-editor-manifest","dashboards","dashboard"])h.invalidateQueries({queryKey:[oe]})},[c,s,o,x,l,w,ie,h]),Pt=W?"host":d?"package":"browser",Zt=b?.writeable===!0,Wn=l!==void 0&&Pt==="package",Lr=z===void 0?W?w&&ie&&Zt?$e:void 0:Wn?void 0:d?Rr:w&&ie&&Zt?$e:void 0:void 0,zn=b?.name,Fn=S.useCallback(R=>{g.current?.(R.type==="dashboard.saved"&&R.where!=="package"&&zn!==void 0?{...R,workspace:zn}:R)},[zn]),Vi=S.useCallback(R=>{te(R),v.current?.(R)},[]),Nn=R=>{f.current=j.now(),Fe(R?$:V),Me(R)},Gi=()=>{f.current=j.now(),Fe(B)};if(!u&&"resourceUri"in e)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["A dashboard resource URI must name an environment and a package. Received: ",e.resourceUri]});if(m.isError)return y.jsx(j.ApiErrorDisplay,{error:m.error,context:"Opening the dashboard"});if(!p||!D)return y.jsxs(k.Stack,{sx:{gap:2},children:[y.jsx(j.DashboardBar,{}),y.jsx(j.Loading,{text:"Opening the dashboard…"})]});if(Y)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened: ",z]});if(Te)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened in the builder: ",Te]});const Z=$!==void 0&&$!==p;return y.jsxs(k.Stack,{sx:{gap:2},children:[!W&&I&&Z&&ve===void 0&&y.jsx(k.Alert,{severity:"info",action:y.jsxs(k.Stack,{direction:"row",sx:{gap:1},children:[y.jsx(k.Button,{size:"small",onClick:()=>Nn(!0),children:"Resume"}),y.jsx(k.Button,{size:"small",onClick:()=>Nn(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),B!==void 0&&y.jsx(k.Alert,{severity:"warning",action:y.jsx(k.Button,{size:"small",onClick:Gi,children:"Load it"}),children:Pt==="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.":Pt==="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."}),Qt!==void 0&&y.jsxs(k.Alert,{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:"," ",Qt]}),Le&&y.jsx(Tv,{environmentName:s,packageName:o,modelPath:x,slug:a,...l!==void 0?{versionId:l}:{},opened:Le,onSave:Lr,onDirtyChange:Vi,savesTo:Pt,...n?{onEvent:Fn}:{},toolbar:t&&y.jsx(j.SecondaryButton,{label:"Done editing",icon:y.jsx(j.CheckIcon,{}),onClick:t}),note:Dv({authoritative:W,mutable:d,pinnedPackageSave:Wn,...b?{workspace:b}:{},...z!==void 0?{readFailure:z}:{},...l!==void 0?{versionId:l}:{}})},Le.generation)]})}function Dv({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 Tv({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:h}=Be.useServer(),{data:f,isSuccess:g}=j.useQueryWithApiError({queryKey:["dashboard-editor-manifest",e,t,r,i],queryFn:()=>h.dashboards.getDashboard(e,t,r,i)}),v=f?.data,{data:w}=j.useQueryWithApiError({queryKey:["dashboard-editor-dashboards",e,t,i],queryFn:()=>h.dashboards.listDashboards(e,t,i)}),x=S.useMemo(()=>(w?.data??[]).map(C=>C.name).filter(C=>!!C&&C!==r),[w,r]),m=S.useMemo(()=>{const C=n.slice(0,n.lastIndexOf("/")+1),W=new Set;for(const Y of s.document.imports){const ve=new URL(Y.from,`https://malloy.invalid/${C}`);W.add(ve.pathname.slice(1))}return[...W]},[s.document.imports,n]),{data:p}=j.useQueryWithApiError({queryKey:["dashboard-editor-catalog",e,t,...m,i],queryFn:async()=>{const C=await Promise.all(m.map(W=>h.models.getModel(e,t,W,i).then(Y=>Y.data)));return $d(C)},enabled:m.length>0}),[b,_]=S.useState(s.document);S.useEffect(()=>_(s.document),[s.document]);const $=S.useMemo(()=>v?.givens??[],[v]),O=S.useMemo(()=>new Set($.map(C=>C.name).filter(C=>C!==void 0)),[$]),D=S.useMemo(()=>kv(b,$),[b,$]),{declaredTypes:M,applied:I,panel:K}=j.useDocumentControls({specs:D,loaded:g,startingValues:v?.startingGivens,documentKey:`${e}/${t}/${i??""}/${r}/edit`,autorun:v?.autorun!==!1,environmentName:e,packageName:t,modelPath:v?.path,versionId:i,documentName:r}),z=S.useMemo(()=>function(W){const Y=$v(b,W,O,I);return y.jsx(j.DashboardTile,{environmentName:e,packageName:t,versionId:i,modelPath:n,tile:Y.expression,label:W.label??j.tileTitle(`${W.source} -> ${W.name}`),subtitle:W.subtitle,borderless:W.borderless,givens:I,declaredTypes:M,givenNames:Y.givenNames,height:j.TILE_MAX_HEIGHT})},[b,O,e,t,i,n,I,M]);return y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsx(Qd,{source:s.source,document:s.document,renderTile:z,givens:D.filter(C=>C.name!==void 0).map(C=>({name:C.name,...C.label?{label:C.label}:{},...C.type?{type:C.type}:{},...C.suggest?.dimension?{field:C.suggest.dimension}:{}})),onChange:_,onDirtyChange:a,...p?{catalog:p}:{},dashboards:x,...l?{onEvent:l}:{},toolbar:c,controls:g?y.jsx(j.GivensPanel,{...K,layout:"bar"}):void 0,...o?{onSave:o}:{},savesTo:u}),y.jsx(k.Box,{sx:{px:.5},children:y.jsx(k.Typography,{variant:"caption",sx:{opacity:.7},children:d})})]})}function il(e){return e instanceof Error?e.message:String(e)}function Cv(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:{}}:globalThis.process.env===void 0&&(globalThis.process.env={});exports.DashboardBuilder=Qd;exports.DashboardEditor=Ov;exports.buildCatalog=$d;exports.readDashboardDocument=Di;exports.readFailed=Oi;exports.spliceDashboardDocument=Js;exports.spliceFailed=Qs;
107
+ `).join("")})}if(be(d.filters)===be(c.filters))continue;const p=qd(e,c);if(!p)return{ok:!1,reason:`Could not find \`${c.name}\`'s declaration to filter it.`};if(p.body.kind==="reference"){const $=_v(e,c,p);if($)return $;continue}if(p.body.kind!=="inline")return{ok:!1,reason:`\`${c.name}\`'s body is ${p.body.why}, so there is no single first stage to write its filter into.`};const b=Kd(c.filters,p.body.stage);if(b)return Yd(c.name,b.given);const _=Qd(e,c,p.body.stage);if(_)return _}}const Ht=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function qd(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function Kd(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 Yd(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 ci=e=>`where: ${e.field} ${e.op??"~"} $${e.given}`;function nl(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 xv(e,t,n){const r=e.commentIn(n);if(r)return r;const i=e.trailingComment(Ht(e,t.end-1));return i&&i.start>=t.end&&e.text.slice(t.end,i.start).trim()===""?i:void 0}function wv(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 Xd(e,t){const n=e.lineStarts[e.lineStarts.findLastIndex(a=>a<=t.start)],r=e.text.slice(n,t.start),i=e.text.indexOf(`
108
+ `,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 Qd(e,t,n){const{parsed:r,edits:i}=e,s=new Map((t.filters??[]).map(h=>[h.given,h])),o=new Set;let a;for(const h of n.wheres){const f=h.clauses.map((v,w)=>({clause:v,index:w})).filter(({clause:v})=>v.binding!==void 0);if(f.length===0)continue;const g=f.filter(({clause:v})=>s.has(v.binding.given));for(const{clause:v}of f)o.add(v.binding.given);if(g.length===0&&f.length===h.clauses.length){const v=Xd(r,h.span),w=xv(r,h.span,v);if(w)return nl(t.name,r,w);i.push({...v,text:""});continue}g.length>0&&(a=h.span);for(let v=f.length-1;v>=0;v--){const{clause:w,index:x}=f[v],m=s.get(w.binding.given);if(!m){const b=wv(h.clauses,x),_=r.commentIn(b);if(_)return nl(t.name,r,_);i.push({...b,text:""});continue}const p=ci(m).replace(/^where:\s*/,"");p!==r.text.slice(w.span.start,w.span.end)&&i.push({...w.span,text:p})}}const l=(t.filters??[]).filter(h=>!o.has(h.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 h=r.trailingComment(Ht(r,u));h&&h.start>=u&&(u=h.end)}const c=a!==void 0&&!/,\s*$/.test(r.text.slice(0,u))?", ":" ",d=n.oneLine?`${c}${l.map(ci).join(", ")}`:l.map(h=>`
109
+ ${n.indent}${ci(h)}`).join("");i.push({start:u,end:u,text:d})}function _v(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:i,refinement:s}=n.body,o=Kd(t.filters,s);if(o)return Yd(t.name,o.given);const a=t.filters??[];if(!s){if(a.length===0)return;const c=` + { ${a.map(ci).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 Qd(e,t,s)}async function Js(e,t){const n=await Di(e);if(Oi(n))return{ok:!1,reason:`Cannot edit a file that will not open: ${n.reason}`};const r=n.document,i=fv(r,t);if("reason"in i)return i;const s=await Gd(e);if(Bd(s))return{ok:!1,reason:`Cannot edit a file that will not open: ${s.reason}`};const o=e.split(`
110
+ `),a=ov(e),l=v=>({start:a[v],end:v+1<a.length?a[v+1]:e.length}),u=v=>/^\s*/.exec(o[v])?.[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 v of[hv,pv,gv,vv,mv,yv,bv]){const w=v(d);if(w)return w}const h=v=>{const{drills:w,localGivens:x,...m}=v,p=v.tiles.map(b=>{if(b.filters?.length)return b;const{filters:_,...$}=b;return $});return{...m,tiles:p,...w?.length?{drills:[...w].sort((b,_)=>Ti(b).localeCompare(Ti(_)))}:{},...x?.length?{localGivens:x}:{}}};if(c.length===0)return be(h(r))!==be(h(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 f=av(e,c);if((await Qa(e)).length===0){const v=await Qa(f);if(v.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${v[0]}). Your changes are still here.`}}const g=await Di(f);return Oi(g)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${g.reason}`}:be(h(g.document))!==be(h(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:f}}function kv(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(x=>{o(void 0),n(m=>{const p=structuredClone(m.stack[m.index]);if(x(p),JSON.stringify(p)===JSON.stringify(m.stack[m.index]))return m;const _=[...m.stack.slice(0,m.index+1),p].slice(-100);return{stack:_,index:_.length-1}})},[]),d=S.useCallback(()=>{o(void 0),n(x=>x.index>0?{...x,index:x.index-1}:x)},[]),h=S.useCallback(()=>{o(void 0),n(x=>x.index<x.stack.length-1?{...x,index:x.index+1}:x)},[]),f=S.useCallback(async()=>{const x=await Js(r,u);if(Qs(x))return o(x.reason),{ok:!1,reason:x.reason};try{await e.onSave?.(x.source)}catch(m){const p=`Could not save: ${m}`;return o(p),{ok:!1,reason:p}}return i(x.source),l(u),o(void 0),{ok:!0}},[u,e,r]),g=S.useMemo(()=>JSON.stringify(u)!==JSON.stringify(a),[u,a]),v=S.useMemo(()=>{const x=new Set(a.tiles.map(Zs)),m=new Set(u.tiles.map(Zs));return[...x].some(p=>!m.has(p))||[...m].some(p=>!x.has(p))},[u,a]),w=S.useCallback(async()=>{const x=await Js(r,u);return Qs(x)?{ok:!1,reason:x.reason}:{ok:!0,source:x.source}},[u,r]);return{document:u,source:r,canUndo:t.index>0,canRedo:t.index<t.stack.length-1,dirty:g,...s===void 0?{}:{error:s},update:c,undo:d,redo:h,save:f,preview:w,structural:v}}function Zd({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:h="package"}){const f=kv({source:e,document:t,...n?{onSave:n}:{}}),[g,v]=S.useState(void 0),[w,x]=S.useState(!1),m=f.document.columns??j.DEFAULT_COLUMNS,{resize:p,gridBox:b,startResize:_,onResize:$,endResize:O}=Fg({tiles:f.document.tiles,columns:m,onStart:v,commit:(E,P)=>f.update(B=>{B.tiles[E].colspan=P})}),{dragging:D,preview:M,onDragStart:I,onDragOver:K,onDragEnd:W}=zg({tiles:f.document.tiles,commit:E=>f.update(P=>{P.tiles=E}),onLanded:v}),[T,z]=S.useState(void 0),[Y,ne]=S.useState(void 0),[Se,oe]=S.useState(!1),[Le,Ve]=S.useState(void 0),[Ce,Ye]=S.useState(null),[Ge,We]=S.useState(void 0);S.useEffect(()=>{r?.(f.document)},[f.document,r]),S.useEffect(()=>{i?.(f.dirty)},[f.dirty,i]);const Xe=S.useMemo(()=>Lp(f.document),[f.document]),$e=S.useMemo(()=>{const E=new Set((t.localGivens??[]).map(P=>P.name));return(a??[]).filter(P=>!E.has(P.name))},[t,a]),fe=S.useMemo(()=>lp(f.document,$e),[f.document,$e]),L=S.useMemo(()=>new Map(f.document.sources.map(E=>[E.name,ja(l,E.base)])),[l,f.document.sources]),V=S.useCallback(E=>L.get(E.source)??ja(l,E.source),[L,l]),_e=(E,P)=>{const B=[];for(const Q of f.document.tiles){const Ue=V(Q);if(!Ue)continue;const ke=new Map(Ue.map(se=>[se.name,se.type]));for(const se of Q.filters??[])se.given===E&&(!ke.has(se.field)||!ai(P,ke.get(se.field)))&&B.push(`${se.field} on ${Q.label??Q.name} (${f.document.sources.find(Ee=>Ee.name===Q.source)?.base??Q.source})`)}return B},X=S.useMemo(()=>fe.filter(E=>E.origin==="model"&&E.boundTiles===0),[fe]),ze=S.useCallback(()=>{We(void 0),x(!0);const E=j.now(),{structural:P}=f,B=f.document.tiles.length;f.save().then(Q=>{Q.ok===!0?d?.({type:"dashboard.saved",tiles:B,structural:P,where:h,durationMs:j.now()-E}):d?.({type:"dashboard.save_refused",reason:Q.reason})}).finally(()=>x(!1))},[f,d,h]),te=S.useCallback(()=>{if(!(!n||!f.dirty||w)){if(!f.structural){ze();return}f.preview().then(E=>{E.ok?We({before:f.source,after:E.source}):ze()})}},[n,f,w,ze]),at=E=>{oe(!1),f.update(P=>{let B=P.sources.find(ke=>ke.base===E.base);if(!B){const ke=new Set(P.sources.map(Ee=>Ee.name));let se=`${E.base}_tiles`;for(let Ee=2;ke.has(se);Ee++)se=`${E.base}_tiles_${Ee}`;B={name:se,base:E.base},P.sources.push(B)}const Q=new Set(P.tiles.filter(ke=>ke.source===B.name).map(ke=>ke.name));let Ue=`${E.view}_tile`;for(let ke=2;Q.has(Ue);ke++)Ue=`${E.view}_tile_${ke}`;P.tiles.push({name:Ue,source:B.name,declaration:{kind:"reference",from:E.view},colspan:E.colspan,...E.label?{label:E.label}:{}})}),v(f.document.tiles.length)},Fe=E=>{ne(void 0),v(void 0),f.update(P=>{P.tiles.splice(E,1)})};_p(S.useMemo(()=>({undo:f.undo,redo:f.redo,...n?{save:te}:{},escape:()=>{!Y&&!T&&v(void 0)},nudge:E=>{if(g===void 0)return;const P=f.document.tiles[g];if(!P||P.declaration.kind==="inherited")return;const B=Math.min(Math.max((P.colspan??1)+E,1),m);B!==(P.colspan??1)&&f.update(Q=>{Q.tiles[g].colspan=B})}}),[f,n,te,Y,T,g,m]));const xt=(E,P,B)=>{z(void 0),f.update(Q=>{B&&gp(Q,B),pp(Q,E,P)})},C=E=>{z(void 0),f.update(P=>vp(P,E))},A=(()=>{const E=f.document.tiles;return p!==void 0?E.map((P,B)=>B===p.index?{...P,colspan:p.span}:P):M??E})(),G=D?Vp(A,m):A.map(Td);return y.jsxs(k.Stack,{sx:{gap:0},children:[y.jsx(kp,{canUndo:f.canUndo,canRedo:f.canRedo,onUndo:f.undo,onRedo:f.redo,dirty:f.dirty,saving:w,...n?{onSave:te}:{},...u?{actions:u}:{},...l?{onAddTile:()=>oe(!0)}:{},onSettings:Ye}),y.jsxs(k.Stack,{sx:{gap:2,px:"4px",pb:"4px"},children:[y.jsx(j.DashboardProse,{title:f.document.title||"Untitled dashboard",...f.document.description?{description:f.document.description}:{}}),y.jsx(Fp,{controls:fe,tileCount:f.document.tiles.length,unknownFieldsOf:_e,onEdit:E=>z({control:E}),onAdd:()=>z({}),children:o}),f.error&&y.jsx(k.Alert,{severity:"warning",children:f.error}),y.jsx(Uh,{sensors:wg,onDragStart:I,onDragOver:K,onDragEnd:W,children:y.jsxs(k.Box,{ref:b,sx:{position:"relative"},children:[(p!==void 0||D)&&y.jsx(Cg,{columns:m}),y.jsx(j.DashboardGrid,{tiles:G,columns:m,keyOf:E=>E.kind==="gap"?Cd(E.after):pt(E.tile),renderTile:E=>{if(E.kind==="gap")return y.jsx(Tg,{after:E.after});const{tile:P,index:B}=E;return y.jsx(Og,{tile:P,index:B,selected:B===g,menuOpen:Y?.index===B,resizeSpan:p?.index===B?p.span:void 0,columns:m,onSelect:()=>v(B),onOpenMenu:Q=>{v(B),ne({anchor:Q,index:B})},onResizeStart:Q=>_(Q,B),onResizeMove:$,onResizeEnd:O,children:s?s(P):y.jsx(Dg,{tile:P})})}})]})}),y.jsx(Rp,{open:T!==void 0,document:f.document,...T?.control?{control:T.control}:{},available:X,...l?{fieldsFor:V}:{},onClose:()=>z(void 0),onApply:xt,onRemove:C}),y.jsx(Ng,{anchor:Y?.anchor??null,tile:Y===void 0?void 0:f.document.tiles[Y.index],onClose:()=>ne(void 0),onCommit:E=>{const P=Y?.index;P!==void 0&&f.update(B=>{B.tiles[P]=E})},onRemove:()=>{Y!==void 0&&Fe(Y.index)},columns:m,onDrills:()=>{Y!==void 0&&Ve(f.document.tiles[Y.index]?.source)}}),y.jsx(jp,{open:Le!==void 0,document:f.document,source:f.document.sources.find(E=>E.name===Le),givenNames:fe.map(E=>E.name),dashboards:c??[],onClose:()=>Ve(void 0),onApply:E=>f.update(P=>{const Q=[...(P.drills??[]).filter(Ue=>Ue.source!==Le),...E];Q.length===0?delete P.drills:P.drills=Q})}),y.jsx(Wp,{anchor:Ce,settings:Xe,onClose:()=>Ye(null),onCommit:E=>f.update(P=>{P.title=E.title,E.description===void 0?delete P.description:P.description=E.description,E.columns===void 0?delete P.columns:P.columns=E.columns,E.autorun===void 0?delete P.autorun:P.autorun=E.autorun})}),y.jsx(Cp,{open:Se,document:f.document,catalog:l,columns:m,onClose:()=>oe(!1),onAdd:at}),y.jsx(Ip,{open:Ge!==void 0,before:Ge?.before??"",after:Ge?.after??"",onConfirm:ze,onClose:()=>We(void 0)})]})]})}function Sv(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($v(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 $v(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 Ev(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 h=j.malloyLiteral(r.get(c.given),o.get(c.given));h!==void 0&&l.push(`${d} ${h}`)}const u=l.join(", ");return{expression:`${i} -> ${s}`+(u?` + { ${u} }`:""),givenNames:a}}async function Ov(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 rl=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function Dv(e){const{onExit:t,onEvent:n,onDirtyChange:r}=e,i=(()=>{if("resourceUri"in e)try{return j.parseResourceUri(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}=Be.useServer(),h=au.useQueryClient(),f=S.useRef(j.now()),g=S.useRef(n);g.current=n;const v=S.useRef(r);v.current=r;const w=j.useOptionalDocumentStorage()?.documentStorage,x=`dashboards/${a}.malloy`,m=j.useQueryWithApiError({queryKey:["dashboard-editor-model",s,o,x,l],queryFn:()=>c.models.getModel(s,o,x,l),enabled:u}),p=m.data?.data?.sourceText,[b,_]=S.useState(void 0),[$,O]=S.useState(void 0),[D,M]=S.useState(w===void 0),[I,K]=S.useState(!1),[W,T]=S.useState(void 0);S.useEffect(()=>{if(!w)return;let R=!1;return T(void 0),(async()=>{try{const ee=await w.listWorkspaces(!1),Oe=ee.find(he=>he.authoritative)??ee.find(he=>he.writeable);if(R)return;if(_(Oe),Oe!==void 0){const he=await w.getDocument(rl(Oe.name,s,o,x)).catch(ae=>{if(!j.isDocumentNotFound(ae))throw ae});if(R)return;O(he),K(he!==void 0)}}catch(ee){if(R)return;T(il(ee))}R||M(!0)})(),()=>{R=!0}},[w,s,o,x]);const z=b?.authoritative===!0,Y=z&&W!==void 0,[ne,Se]=S.useState(void 0),oe=(z||ne===!0)&&$!==void 0,[Le,Ve]=S.useState(void 0),[Ce,Ye]=S.useState(void 0),Ge=S.useRef(void 0),We=S.useRef(void 0),[Xe,$e]=S.useState(void 0),fe=m.dataUpdatedAt,L=S.useRef(fe);L.current=fe;const V=Xe!==void 0&&Xe.onFetch===fe?Xe.text:p,_e=S.useRef(V);_e.current=V;const X=oe?$:V,[ze,te]=S.useState(!1),[at,Fe]=S.useState(void 0),[xt,C]=S.useState(void 0),A=X!==void 0&&X!==xt,G=Le?.source,E=A&&ze&&G!==void 0&&X!==at,P=E?G:A?X:G??X,B=E?X:void 0,Q=S.useRef(G);Q.current=G;const Ue=S.useRef(X);Ue.current=X;const ke=S.useRef("package");ke.current=oe?z?"record":"draft":"package",S.useEffect(()=>{if(P===void 0||!D||Y||P===Q.current)return;let R=!1;const ee=_e.current,Oe=Ue.current;return Di(P).then(he=>{if(!R){if(Oi(he)){const ae=he.line?`${he.reason} (line ${he.line})`:he.reason;Ye(ae),g.current?.({type:"dashboard.open_refused",reason:ae});return}Ye(void 0),Ge.current=void 0,We.current=ee,$e(void 0),Fe(void 0),C(Oe),Ve(ae=>({source:P,document:he.document,generation:(ae?.generation??0)+1})),g.current?.({type:"dashboard.opened",from:ke.current,tiles:he.document.tiles.length,durationMs:j.now()-f.current})}}),()=>{R=!0}},[P,D,Y]);const se=b===void 0?void 0:rl(b.name,s,o,x),Ee=S.useCallback(async R=>{if(!w||!se)throw new Error("This host keeps no documents, so there is nowhere to save.");await w.saveDocument(se,R),Ve(ee=>ee&&{...ee,source:R}),O(R),(z||ne===!0)&&C(R),z||Se(ee=>ee??!1)},[w,se,z,ne]),[Qt,Ct]=S.useState(void 0),Rr=S.useCallback(async R=>{const ee=We.current,Oe=Ge.current??(ee===void 0?void 0:await Ov(ee));if(Oe===void 0)throw new Error("The package file is still loading; try again.");let he;try{he=await c.models.updateModelSource(s,o,x,{source:R,expectedHash:Oe})}catch(ae){throw h.invalidateQueries({queryKey:["dashboard-editor-model",s,o,x,l]}),new Error(Pv(ae))}if(Ve(ae=>ae&&{...ae,source:R}),$e({text:R,onFetch:L.current}),C(R),Ge.current=he.data.contentHash,Ct(void 0),w&&se)try{await w.deleteDocument(se),O(void 0),K(!1)}catch(ae){j.isDocumentNotFound(ae)?(O(void 0),K(!1)):Ct(il(ae))}Se(!1),await h.invalidateQueries({queryKey:["dashboard-editor-model",s,o,x,l]});for(const ae of["dashboard-editor-manifest","dashboards","dashboard"])h.invalidateQueries({queryKey:[ae]})},[c,s,o,x,l,w,se,h]),Pt=z?"host":d?"package":"browser",Zt=b?.writeable===!0,Wn=l!==void 0&&Pt==="package",Lr=W===void 0?z?w&&se&&Zt?Ee:void 0:Wn?void 0:d?Rr:w&&se&&Zt?Ee:void 0:void 0,zn=b?.name,Fn=S.useCallback(R=>{g.current?.(R.type==="dashboard.saved"&&R.where!=="package"&&zn!==void 0?{...R,workspace:zn}:R)},[zn]),Vi=S.useCallback(R=>{te(R),v.current?.(R)},[]),Nn=R=>{f.current=j.now(),Fe(R?$:V),Se(R)},Gi=()=>{f.current=j.now(),Fe(B)};if(!u&&"resourceUri"in e)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["A dashboard resource URI must name an environment and a package. Received: ",e.resourceUri]});if(m.isError)return y.jsx(j.ApiErrorDisplay,{error:m.error,context:"Opening the dashboard"});if(!p||!D)return y.jsxs(k.Stack,{sx:{gap:2},children:[y.jsx(j.DashboardBar,{}),y.jsx(j.Loading,{text:"Opening the dashboard…"})]});if(Y)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened: ",W]});if(Ce)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened in the builder: ",Ce]});const Z=$!==void 0&&$!==p;return y.jsxs(k.Stack,{sx:{gap:2},children:[!z&&I&&Z&&ne===void 0&&y.jsx(k.Alert,{severity:"info",action:y.jsxs(k.Stack,{direction:"row",sx:{gap:1},children:[y.jsx(k.Button,{size:"small",onClick:()=>Nn(!0),children:"Resume"}),y.jsx(k.Button,{size:"small",onClick:()=>Nn(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),B!==void 0&&y.jsx(k.Alert,{severity:"warning",action:y.jsx(k.Button,{size:"small",onClick:Gi,children:"Load it"}),children:Pt==="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.":Pt==="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."}),Qt!==void 0&&y.jsxs(k.Alert,{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:"," ",Qt]}),Le&&y.jsx(Cv,{environmentName:s,packageName:o,modelPath:x,slug:a,...l!==void 0?{versionId:l}:{},opened:Le,onSave:Lr,onDirtyChange:Vi,savesTo:Pt,...n?{onEvent:Fn}:{},toolbar:t&&y.jsx(j.SecondaryButton,{label:"Done editing",icon:y.jsx(j.CheckIcon,{}),onClick:t}),note:Tv({authoritative:z,mutable:d,pinnedPackageSave:Wn,...b?{workspace:b}:{},...W!==void 0?{readFailure:W}:{},...l!==void 0?{versionId:l}:{}})},Le.generation)]})}function Tv({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 Cv({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:h}=Be.useServer(),{data:f,isSuccess:g}=j.useQueryWithApiError({queryKey:["dashboard-editor-manifest",e,t,r,i],queryFn:()=>h.dashboards.getDashboard(e,t,r,i)}),v=f?.data,{data:w}=j.useQueryWithApiError({queryKey:["dashboard-editor-dashboards",e,t,i],queryFn:()=>h.dashboards.listDashboards(e,t,i)}),x=S.useMemo(()=>(w?.data??[]).map(T=>T.name).filter(T=>!!T&&T!==r),[w,r]),m=S.useMemo(()=>{const T=n.slice(0,n.lastIndexOf("/")+1);return s.document.imports.map(z=>({...z,path:new URL(z.from,`https://malloy.invalid/${T}`).pathname.slice(1)}))},[s.document.imports,n]),{data:p}=j.useQueryWithApiError({queryKey:["dashboard-editor-catalog",e,t,...m.map(T=>T.path),i],queryFn:async()=>{const T=(await h.models.listModels(e,t,i)).data.filter(ne=>ne.path&&!ne.error),Y=(await Promise.allSettled(T.map(ne=>h.models.getModel(e,t,ne.path,i).then(Se=>Se.data)))).flatMap(ne=>ne.status==="fulfilled"?[ne.value]:[]);return Dp(Ed(Y),m,Y)},enabled:m.length>0}),[b,_]=S.useState(s.document);S.useEffect(()=>_(s.document),[s.document]);const $=S.useMemo(()=>v?.givens??[],[v]),O=S.useMemo(()=>new Set($.map(T=>T.name).filter(T=>T!==void 0)),[$]),D=S.useMemo(()=>Sv(b,$),[b,$]),{declaredTypes:M,applied:I,panel:K}=j.useDocumentControls({specs:D,loaded:g,startingValues:v?.startingGivens,documentKey:`${e}/${t}/${i??""}/${r}/edit`,autorun:v?.autorun!==!1,environmentName:e,packageName:t,modelPath:v?.path,versionId:i,documentName:r}),W=S.useMemo(()=>function(z){const Y=Ev(b,z,O,I);return y.jsx(j.DashboardTile,{environmentName:e,packageName:t,versionId:i,modelPath:n,tile:Y.expression,label:z.label??j.tileTitle(`${z.source} -> ${z.name}`),subtitle:z.subtitle,borderless:z.borderless,givens:I,declaredTypes:M,givenNames:Y.givenNames,height:j.TILE_MAX_HEIGHT})},[b,O,e,t,i,n,I,M]);return y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsx(Zd,{source:s.source,document:s.document,renderTile:W,givens:D.filter(T=>T.name!==void 0).map(T=>({name:T.name,...T.label?{label:T.label}:{},...T.type?{type:T.type}:{},...T.suggest?.dimension?{field:T.suggest.dimension}:{}})),onChange:_,onDirtyChange:a,...p?{catalog:p}:{},dashboards:x,...l?{onEvent:l}:{},toolbar:c,controls:g?y.jsx(j.GivensPanel,{...K,layout:"bar"}):void 0,...o?{onSave:o}:{},savesTo:u}),y.jsx(k.Box,{sx:{px:.5},children:y.jsx(k.Typography,{variant:"caption",sx:{opacity:.7},children:d})})]})}function il(e){return e instanceof Error?e.message:String(e)}function Pv(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:{}}:globalThis.process.env===void 0&&(globalThis.process.env={});exports.DashboardBuilder=Zd;exports.DashboardEditor=Dv;exports.buildCatalog=Ed;exports.readDashboardDocument=Di;exports.readFailed=Oi;exports.spliceDashboardDocument=Js;exports.spliceFailed=Qs;