@malloy-publisher/sdk 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -65
- package/dist/Dashboard-ChyylkTD.cjs.js +136 -0
- package/dist/{DocumentStorage-CigwNjz4.es.js → Dashboard-H1kJlDFo.es.js} +23660 -23575
- package/dist/{RenderedResult-DpHdrFtp.cjs.js → RenderedResult-AJPMUkAD.cjs.js} +1 -1
- package/dist/{RenderedResult-BfayOSk1.es.js → RenderedResult-BRgIgxWh.es.js} +18 -18
- package/dist/{ServerProvider-CfUFleYe.es.js → ServerProvider-Boxrv6Ym.es.js} +1481 -1513
- package/dist/ServerProvider-CXrOKD6g.cjs.js +1 -0
- package/dist/builder/index.cjs.js +50 -50
- package/dist/builder/index.es.js +2587 -2511
- package/dist/client/api.d.ts +187 -1803
- package/dist/client/base.d.ts +0 -24
- package/dist/client/common.d.ts +4 -35
- package/dist/client/configuration.d.ts +25 -18
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +62 -59
- package/dist/components/DashboardBuilder/malloyText.d.ts +49 -0
- package/dist/components/DashboardBuilder/malloyTree.d.ts +2 -18
- package/dist/components/DashboardBuilder/readDocument.d.ts +2 -0
- package/dist/components/Notebook/NotebookCell.d.ts +3 -2
- package/dist/components/Notebook/cellKind.d.ts +20 -0
- package/dist/hooks/useQueryResult.d.ts +1 -1
- package/dist/index.cjs.js +15 -12
- package/dist/index.es.js +4528 -4435
- package/openapitools.json +1 -1
- package/package.json +3 -3
- package/src/components/DashboardBuilder/malloyText.spec.ts +70 -1
- package/src/components/DashboardBuilder/malloyText.ts +171 -3
- package/src/components/DashboardBuilder/malloyTree.spec.ts +35 -0
- package/src/components/DashboardBuilder/malloyTree.ts +28 -4
- package/src/components/DashboardBuilder/readDocument.spec.ts +180 -1
- package/src/components/DashboardBuilder/readDocument.ts +52 -14
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +396 -2
- package/src/components/DashboardBuilder/spliceDocument.ts +121 -18
- package/src/components/Notebook/Notebook.served.spec.tsx +179 -0
- package/src/components/Notebook/Notebook.spec.tsx +33 -2
- package/src/components/Notebook/Notebook.tsx +13 -7
- package/src/components/Notebook/NotebookCell.tsx +124 -63
- package/src/components/Notebook/cellKind.spec.ts +191 -0
- package/src/components/Notebook/cellKind.ts +74 -0
- package/src/components/Package/Package.notebooks.spec.tsx +90 -0
- package/src/components/Package/Package.tsx +18 -4
- package/dist/DocumentStorage-DvUNSOiN.cjs.js +0 -134
- package/dist/ServerProvider-CuYLH_Yi.cjs.js +0 -1
|
@@ -1,27 +1,27 @@
|
|
|
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-DvUNSOiN.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(`
|
|
1
|
+
"use strict";var nu=Object.create;var oa=Object.defineProperty;var ru=Object.getOwnPropertyDescriptor;var iu=Object.getOwnPropertyNames;var su=Object.getPrototypeOf,ou=Object.prototype.hasOwnProperty;var au=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of iu(t))!ou.call(e,i)&&i!==n&&oa(e,i,{get:()=>t[i],enumerable:!(r=ru(t,i))||r.enumerable});return e};var aa=(e,t,n)=>(n=e!=null?nu(su(e)):{},au(t||!e||!e.__esModule?oa(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),S=require("react"),lu=require("react-dom"),k=require("@mui/material"),j=require("../Dashboard-ChyylkTD.cjs.js"),Be=require("../ServerProvider-CXrOKD6g.cjs.js"),cu=require("@tanstack/react-query");var du=Symbol.for("preact-signals");function Pi(){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)&&ll(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();us=++uu,vt++;try{return e()}finally{Pi()}}var lr,ie=void 0;function H(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,uu=0,us=0,ui=void 0,fi=0;function al(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=du;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:H(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&&H(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;H(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 H(function(){return e.value})};Object.defineProperty(Re.prototype,"value",{get:function(){var e=al(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!==us&&(n.l=us,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{Pi()}}}});function En(e,t){return new Re(e,t)}function ll(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 cl(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 dl(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 Ht(e,t){Re.call(this,void 0,t),this.x=e,this.s=void 0,this.g=fi-1,this.f=4}Ht.prototype=new Re;Ht.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&&!ll(this))return this.f&=-2,!0;var e=ie;try{cl(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,dl(this),this.f&=-2,!0};Ht.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)};Ht.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)}};Ht.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(Ht.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=al(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function la(e,t){return new Ht(e,t)}function ul(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,to(e),r}finally{ie=n,Pi()}}}function to(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ul(e)}function fu(e){if(ie!==this)throw new Error("Out-of-order effect");dl(this),ie=e,this.f&=-2,8&this.f&&to(this),Pi()}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,ul(this),cl(this),vt++;var e=ie;return ie=this,fu.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||to(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 hu=Object.create,no=Object.defineProperty,pu=Object.defineProperties,gu=Object.getOwnPropertyDescriptor,vu=Object.getOwnPropertyDescriptors,ca=Object.getOwnPropertySymbols,mu=Object.prototype.hasOwnProperty,yu=Object.prototype.propertyIsEnumerable,bu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Tn=e=>{throw TypeError(e)},fs=(e,t,n)=>t in e?no(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xu=(e,t)=>{for(var n in t||(t={}))mu.call(t,n)&&fs(e,n,t[n]);if(ca)for(var n of ca(t))yu.call(t,n)&&fs(e,n,t[n]);return e},wu=(e,t)=>pu(e,vu(t)),da=(e,t)=>no(e,"name",{value:t,configurable:!0}),_u=e=>{var t;return[,,,hu((t=void 0)!=null?t:null)]},fl=["class","method","getter","setter","accessor","field","value","get","set"],qn=e=>e!==void 0&&typeof e!="function"?Tn("Function expected"):e,ku=(e,t,n,r,i)=>({kind:fl[e],name:t,metadata:r,addInitializer:s=>n._?Tn("Already initialized"):i.push(qn(s||null))}),hl=(e,t)=>fs(t,bu("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},Dn=(e,t,n,r,i,s)=>{var o,a,l,u,d,c=t&7,h=!!(t&8),f=!!(t&16),v=c>3?e.length+1:c?h?1:2:0,p=fl[c+5],w=c>3&&(e[v-1]=[]),x=e[v]||(e[v]=[]),m=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&gu(c<4?i:{get[n](){return Qe(this,s)},set[n](b){return kt(this,s,b)}},n));c?f&&c<4&&da(s,(c>2?"set ":c>1?"get ":"")+n):da(i,n);for(var g=r.length-1;g>=0;g--)u=ku(c,n,l={},e[3],x),c&&(u.static=h,u.private=f,d=u.access={has:f?b=>Su(i,b):b=>n in b},c^3&&(d.get=f?b=>(c^1?Qe:$u)(b,i,c^4?s:m.get):b=>b[n]),c>2&&(d.set=f?(b,_)=>kt(b,i,_,c^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?f?s:m[p]:c>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,c^4||a===void 0?qn(a)&&(c>4?w.unshift(a):c?f?s=a:m[p]=a:i=a):typeof a!="object"||a===null?Tn("Object expected"):(qn(o=a.get)&&(m.get=o),qn(o=a.set)&&(m.set=o),qn(o=a.init)&&w.unshift(o));return c||hl(e,i),m&&no(i,n,m),f?c^4?s:m:i},ro=(e,t,n)=>t.has(e)||Tn("Cannot "+n),Su=(e,t)=>Object(t)!==t?Tn('Cannot use the "in" operator on this value'):e.has(t),Qe=(e,t,n)=>(ro(e,t,"read from private field"),n?n.call(e):t.get(e)),Hn=(e,t,n)=>t.has(e)?Tn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),kt=(e,t,n,r)=>(ro(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),$u=(e,t,n)=>(ro(e,t,"access private method"),n);function hs(e,t){if(t){let n;return la(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return la(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 K({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=hs(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,wu(xu({},i),{enumerable:e}))})}}function $r(...e){const t=e.map(n=>tt(n));return()=>t.forEach(n=>n())}var pl,gl,vl,ml,yl,bl,Ie,io,Ki,ps,gs,Pe,so,Yi,xl,vs,oo,Xi,ms,ys;bl=[K],yl=[K],ml=[K],vl=[Hi()],gl=[Hi()],pl=[Hi()];var Kt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Mt(Ie,5,this),Hn(this,Pe),Hn(this,io,Mt(Ie,8,this)),Mt(Ie,11,this),Hn(this,so,Mt(Ie,12,this)),Mt(Ie,15,this),Hn(this,oo,Mt(Ie,16,this)),Mt(Ie,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Qe(this,Pe,ms)}get initial(){return Qe(this,Pe,ps)}get previous(){return Qe(this,Pe,xl)}set current(e){const t=H(()=>Qe(this,Pe,ms));e&&t&&this.equals(t,e)||ue(()=>{Qe(this,Pe,ps)||kt(this,Pe,e,gs),kt(this,Pe,t,vs),kt(this,Pe,e,ys)})}reset(e=this.defaultValue){ue(()=>{kt(this,Pe,void 0,vs),kt(this,Pe,e,gs),kt(this,Pe,e,ys)})}};Ie=_u();io=new WeakMap;Pe=new WeakSet;so=new WeakMap;oo=new WeakMap;Ki=Dn(Ie,20,"#initial",bl,Pe,io),ps=Ki.get,gs=Ki.set;Yi=Dn(Ie,20,"#previous",yl,Pe,so),xl=Yi.get,vs=Yi.set;Xi=Dn(Ie,20,"#current",ml,Pe,oo),ms=Xi.get,ys=Xi.set;Dn(Ie,2,"current",vl,Kt);Dn(Ie,2,"initial",gl,Kt);Dn(Ie,2,"previous",pl,Kt);hl(Ie,Kt);function Qi(e){return H(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var It,Eu=class{constructor(){Hn(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 Ou=Object.create,wl=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,ua=Object.getOwnPropertySymbols,Du=Object.prototype.hasOwnProperty,Cu=Object.prototype.propertyIsEnumerable,_l=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Mi=e=>{throw TypeError(e)},fa=Math.pow,bs=(e,t,n)=>t in e?wl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pu=(e,t)=>{for(var n in t||(t={}))Du.call(t,n)&&bs(e,n,t[n]);if(ua)for(var n of ua(t))Cu.call(t,n)&&bs(e,n,t[n]);return e},Mu=e=>{var t;return[,,,Ou((t=e?.[_l("metadata")])!=null?t:null)]},kl=["class","method","getter","setter","accessor","field","value","get","set"],Sl=e=>e!==void 0&&typeof e!="function"?Mi("Function expected"):e,Iu=(e,t,n,r,i)=>({kind:kl[e],name:t,metadata:r,addInitializer:s=>n._?Mi("Already initialized"):i.push(Sl(s||null))}),ju=(e,t)=>bs(t,_l("metadata"),e[3]),Au=(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},$l=(e,t,n,r,i,s)=>{for(var o,a,l,u,d=t&7,c=!1,h=!1,f=2,v=kl[d+5],p=e[f]||(e[f]=[]),w=(i=i.prototype,Tu(i,n)),x=r.length-1;x>=0;x--)l=Iu(d,n,a={},e[3],p),l.static=c,l.private=h,u=l.access={has:m=>n in m},u.get=m=>m[n],o=(0,r[x])(w[v],l),a._=1,Sl(o)&&(w[v]=o);return w&&wl(i,n,w),i},El=(e,t,n)=>t.has(e)||Mi("Cannot "+n),Ru=(e,t,n)=>(El(e,t,"read from private field"),t.get(e)),Lu=(e,t,n)=>t.has(e)?Mi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Wu=(e,t,n,r)=>(El(e,t,"write to private field"),t.set(e,n),n),Ze=class xs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new xs(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 xs(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=Pu({},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?zu(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 zu(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 Ol,Tl,ws,Xr,Er,Ii=class extends(ws=Kt,Tl=[ge],Ol=[ge],ws){constructor(t){const n=Ze.from(t);super(n,(r,i)=>Ze.equals(r,i)),Au(Er,5,this),Lu(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-Ru(this,Xr),a=l=>Math.round(l/o*100);ue(()=>{Wu(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=Mu(ws);Xr=new WeakMap;$l(Er,2,"delta",Tl,Ii);$l(Er,2,"direction",Ol,Ii);ju(Er,Ii);function _s({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(fa(r,2)+fa(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 Dl=(e=>(e.Horizontal="x",e.Vertical="y",e))(Dl||{}),Cl=Object.values(Dl),Fu=Object.create,ao=Object.defineProperty,Nu=Object.defineProperties,Bu=Object.getOwnPropertyDescriptor,Vu=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,Pl=Object.prototype.hasOwnProperty,Ml=Object.prototype.propertyIsEnumerable,Il=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Cn=e=>{throw TypeError(e)},ks=(e,t,n)=>t in e?ao(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lo=(e,t)=>{for(var n in t||(t={}))Pl.call(t,n)&&ks(e,n,t[n]);if(hi)for(var n of hi(t))Ml.call(t,n)&&ks(e,n,t[n]);return e},co=(e,t)=>Nu(e,Vu(t)),ha=(e,t)=>ao(e,"name",{value:t,configurable:!0}),jl=(e,t)=>{var n={};for(var r in e)Pl.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&&Ml.call(e,r)&&(n[r]=e[r]);return n},Pn=e=>{var t;return[,,,Fu((t=e?.[Il("metadata")])!=null?t:null)]},Al=["class","method","getter","setter","accessor","field","value","get","set"],Kn=e=>e!==void 0&&typeof e!="function"?Cn("Function expected"):e,Gu=(e,t,n,r,i)=>({kind:Al[e],name:t,metadata:r,addInitializer:s=>n._?Cn("Already initialized"):i.push(Kn(s||null))}),Yt=(e,t)=>ks(t,Il("metadata"),e[3]),N=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Y=(e,t,n,r,i,s)=>{var o,a,l,u,d,c=t&7,h=!!(t&8),f=!!(t&16),v=c>3?e.length+1:c?h?1:2:0,p=Al[c+5],w=c>3&&(e[v-1]=[]),x=e[v]||(e[v]=[]),m=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&Bu(c<4?i:{get[n](){return pe(this,s)},set[n](b){return He(this,s,b)}},n));c?f&&c<4&&ha(s,(c>2?"set ":c>1?"get ":"")+n):ha(i,n);for(var g=r.length-1;g>=0;g--)u=Gu(c,n,l={},e[3],x),c&&(u.static=h,u.private=f,d=u.access={has:f?b=>Uu(i,b):b=>n in b},c^3&&(d.get=f?b=>(c^1?pe:Rl)(b,i,c^4?s:m.get):b=>b[n]),c>2&&(d.set=f?(b,_)=>He(b,i,_,c^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?f?s:m[p]:c>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,c^4||a===void 0?Kn(a)&&(c>4?w.unshift(a):c?f?s=a:m[p]=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 c||Yt(e,i),m&&ao(i,n,m),f?c^4?s:m:i},uo=(e,t,n)=>t.has(e)||Cn("Cannot "+n),Uu=(e,t)=>Object(t)!==t?Cn('Cannot use the "in" operator on this value'):e.has(t),pe=(e,t,n)=>(uo(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),He=(e,t,n,r)=>(uo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Rl=(e,t,n)=>(uo(e,t,"access private method"),n);function Ll(e,t){return{plugin:e,options:t}}function Or(e){return t=>Ll(e,t)}function gr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Wl,vr,fo,Qr;Wl=[K];var Me=class{constructor(e,t){this.manager=e,this.options=t,J(this,fo,N(vr,8,this,!1)),N(vr,11,this),J(this,Qr,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return H(()=>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 Ll(this,e)}};vr=Pn(null);fo=new WeakMap;Qr=new WeakMap;Y(vr,4,"disabled",Wl,Me,fo);Yt(vr,Me);var Tr=class extends Me{},Zr,Zi=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 Tr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);He(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 qu(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,Hu=class extends Me{constructor(e){super(e),J(this,an),J(this,ln),this.computeCollisions=this.computeCollisions.bind(this),He(this,ln,En(Wr)),this.destroy=$r(()=>{const t=this.computeCollisions(),n=H(()=>this.manager.dragOperation.position.current);if(t!==Wr){const r=pe(this,an);if(He(this,an,n),r&&n.x==r.x&&n.y==r.y)return}else He(this,an,void 0);pe(this,ln).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){H(()=>{e?pe(this,ln).value=this.computeCollisions():He(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 d=t??u.collisionDetector;if(!d)continue;l.push(u),u.shape;const c=H(()=>d({droppable:u,dragOperation:r}));c&&(u.collisionPriority!=null&&(c.priority=u.collisionPriority),a.push(c))}return l.length===0?Wr:(a.sort(qu),a)}get collisions(){return pe(this,ln).value}};an=new WeakMap;ln=new WeakMap;var zl,Fl,Nl,ho,Bl,it,po,pn,go,vo;Nl=[K],Fl=[K],zl=[K];var yt=class At{constructor(t,n){J(this,po,N(it,8,this)),N(it,11,this),J(this,pn),J(this,go,N(it,12,this)),N(it,15,this),J(this,vo,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;He(this,pn,En(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var u;return[()=>{const{id:d,manager:c}=this;if(d!==l)return l=d,c?.registry.register(this),()=>c?.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 Rl(s=At,ho,Bl).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);ho=new WeakSet;Bl=function(){const e=yt.pendingIdChanges;yt.pendingIdChanges=null,e&&ue(()=>{for(const[t,n]of e)pe(t,pn).value=n})};po=new WeakMap;pn=new WeakMap;go=new WeakMap;vo=new WeakMap;Y(it,4,"manager",Nl,yt,po);Y(it,4,"data",Fl,yt,go);Y(it,4,"disabled",zl,yt,vo);J(yt,ho);Yt(it,yt);yt.pendingIdChanges=null;var ji=yt,pa=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}},Vl,Gl,Ul,ql,Hl,Kl,Ss,je,mo,yo,bo,ut=class extends(Ss=ji,Kl=[K],Hl=[K],ql=[K],Ul=[ge],Gl=[ge],Vl=[ge],Ss){constructor(t,n){var r=t,{modifiers:i,type:s,sensors:o,plugins:a,effects:l}=r,u=jl(r,["modifiers","type","sensors","plugins","effects"]);super(co(lo({},u),{effects:()=>{var d;return[...(d=l?.())!=null?d:[],()=>{const{manager:c,plugins:h}=this;if(!(!c||!h))for(const f of h){const{plugin:v}=gr(f);c.registry.plugins.register(v)}}]}}),n),N(je,5,this),J(this,mo,N(je,8,this)),N(je,11,this),J(this,yo,N(je,12,this)),N(je,15,this),J(this,bo,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(Ss);mo=new WeakMap;yo=new WeakMap;bo=new WeakMap;Y(je,4,"type",Kl,ut,mo);Y(je,4,"modifiers",Hl,ut,yo);Y(je,4,"status",ql,ut,bo);Y(je,2,"isDropping",Ul,ut);Y(je,2,"isDragging",Gl,ut);Y(je,2,"isDragSource",Vl,ut);Yt(je,ut);var Yl,Xl,Ql,Zl,Jl,ec,$s,xe,xo,wo,_o,ko,So,ft=class extends($s=ji,ec=[K],Jl=[K],Zl=[K],Ql=[K],Xl=[K],Yl=[ge],$s){constructor(t,n){var r=t,{accept:i,collisionDetector:s,collisionPriority:o,type:a}=r,l=jl(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),N(xe,5,this),J(this,xo,N(xe,8,this)),N(xe,11,this),J(this,wo,N(xe,12,this)),N(xe,15,this),J(this,_o,N(xe,16,this)),N(xe,19,this),J(this,ko,N(xe,20,this)),N(xe,23,this),J(this,So,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($s);xo=new WeakMap;wo=new WeakMap;_o=new WeakMap;ko=new WeakMap;So=new WeakMap;Y(xe,4,"accept",ec,ft,xo);Y(xe,4,"type",Jl,ft,wo);Y(xe,4,"collisionDetector",Zl,ft,_o);Y(xe,4,"collisionPriority",Ql,ft,ko);Y(xe,4,"shape",Xl,ft,So);Y(xe,2,"isDropTarget",Yl,ft);Yt(xe,ft);var Ku=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)}},Yu=class extends Ku{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 co(lo({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Xu=class extends Tr{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()||ji.pendingIdChanges)return;const o=Jr({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;H(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},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||{}),tc,nc,rc,ic,sc,oc,ac,et,$o;ac=[K],oc=[ge],sc=[ge],ic=[ge],rc=[ge],nc=[ge],tc=[ge];var bt=class{constructor(){N(et,5,this),J(this,$o,N(et,8,this,"idle")),N(et,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};et=Pn(null);$o=new WeakMap;Y(et,4,"value",ac,bt,$o);Y(et,2,"current",oc,bt);Y(et,2,"idle",sc,bt);Y(et,2,"initializing",ic,bt);Y(et,2,"initialized",rc,bt);Y(et,2,"dragging",nc,bt);Y(et,2,"dropped",tc,bt);Yt(et,bt);var Qu=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return H(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Jr({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return H(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const 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 H(()=>{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,d,c;if(o.defaultPrevented)return;const h=(c=e.to)!=null?c:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((d=(u=e.by)==null?void 0:u.y)!=null?d:0)};r.position.current=h})})}stop(e={}){return H(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const l={resume:()=>{},abort:()=>{}};return s=new Promise((u,d)=>{l.resume=u,l.abort=d}),l};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=H(()=>{var d;return((d=r.source)==null?void 0:d.status)==="dropping"}),u=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(l){const{source:d}=r,c=tt(()=>{d?.status==="idle"&&(c(),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}},Zu=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,lc=class{constructor(e){this.options=e,J(this,ei)}set controller(e){He(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 ga=class extends Me{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Ju=class{constructor(e){this.draggables=new pa,this.droppables=new pa,this.plugins=new Zi(e),this.sensors=new Zi(e),this.modifiers=new Zi(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 ga)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 ji)return e instanceof ut?this.draggables.unregister(e.id,e):e instanceof ft?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ga)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()}},cc,dc,uc,fc,hc,pc,gc,vc,mc,Yn,ti,cn,ce,Eo,Oo,To,Do,Co,Xn;mc=[ge],vc=[K],gc=[K],pc=[K],hc=[K],fc=[K],uc=[ge],dc=[ge],cc=[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,Eo,N(ce,8,this,!1)),N(ce,11,this),J(this,Oo,N(ce,12,this,null)),N(ce,15,this),J(this,To,N(ce,16,this,null)),N(ce,19,this),J(this,Do,N(ce,20,this,null)),N(ce,23,this),J(this,Co,N(ce,24,this,[])),N(ce,27,this),this.position=new Ii({x:0,y:0}),J(this,Xn,{x:0,y:0}),He(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&&He(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(co(lo({},this.snapshot()),{transform:n}));return He(this,Xn,n),n}snapshot(){return H(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:pe(this,Xn),shape:this.shape?Qi(this.shape):null,position:Qi(this.position),status:Qi(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}),He(this,Xn,{x:0,y:0}),this.modifiers=[]})}};ce=Pn(null);Yn=new WeakMap;ti=new WeakMap;cn=new WeakMap;Eo=new WeakMap;Oo=new WeakMap;To=new WeakMap;Do=new WeakMap;Co=new WeakMap;Xn=new WeakMap;Y(ce,2,"shape",mc,ot);Y(ce,4,"canceled",vc,ot,Eo);Y(ce,4,"activatorEvent",gc,ot,Oo);Y(ce,4,"sourceIdentifier",pc,ot,To);Y(ce,4,"targetIdentifier",hc,ot,Do);Y(ce,4,"modifiers",fc,ot,Co);Y(ce,2,"source",uc,ot);Y(ce,2,"target",dc,ot);Y(ce,2,"transform",cc,ot);Yt(ce,ot);var ef={get rendering(){return Promise.resolve()}};function st(e,t){return typeof e=="function"?e(t):e??t}var tf=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:ef,l=new Yu(this),u=new Ju(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new Qu(this),this.dragOperation=new ot(this),this.collisionObserver=new Hu(this),this.plugins=[Xu,...i],this.modifiers=o,this.sensors=s;const{destroy:d}=this,c=$r(()=>{var h,f,v;const p=H(()=>this.dragOperation.modifiers),w=this.modifiers;for(const x of p)w.includes(x)||x.destroy();this.dragOperation.modifiers=(v=(f=(h=this.dragOperation.source)==null?void 0:h.modifiers)==null?void 0:f.map(x=>{const{plugin:m,options:g}=gr(x);return new m(this,g)}))!=null?v:w});this.destroy=()=>{c(),d()}}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}},yc=e=>{throw TypeError(e)},Po=(e,t,n)=>t.has(e)||yc("Cannot "+n),F=(e,t,n)=>(Po(e,t,"read from private field"),t.get(e)),Ne=(e,t,n)=>t.has(e)?yc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,r)=>(Po(e,t,"write to private field"),t.set(e,n),n),bc=(e,t,n)=>(Po(e,t,"access private method"),n);function Ai(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function xc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,a=(Ai(s)?s.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],i])}return r}function Ri(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 Mo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Dr(e){return"nodeType"in e}function Ke(e){var t,n,r;return e?Mo(e)?e:Dr(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 Io(e){const{Document:t}=Ke(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Tt(e){return!e||Mo(e)?!1:e instanceof Ke(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function wc(e){return e instanceof Ke(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function jn(e){return e?Mo(e)?e.document:Dr(e)?Io(e)?e:Tt(e)||wc(e)?e.ownerDocument:document:document:document}function nf(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,d=(i=o?.offsetLeft)!=null?i:0;return{top:u,left:d,right:d+a,bottom:u+l,width:a,height:l}}function rf(e,t){if(sf(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function sf(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,d=(r=u.defaultView)!=null?r:window;let c=e.parentElement;for(;c&&c!==u.documentElement;){if(!rf(c)){const g=c.getBoundingClientRect(),b=n*(g.bottom-g.top),_=n*(g.right-g.left),$=n*(g.bottom-g.top),O=n*(g.right-g.left);l={top:Math.max(l.top,g.top-b),right:Math.min(l.right,g.right+_),bottom:Math.min(l.bottom,g.bottom+$),left:Math.max(l.left,g.left-O),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}c=c.parentElement}const h=d.visualViewport,f=(i=h?.offsetTop)!=null?i:0,v=(s=h?.offsetLeft)!=null?s:0,p=(o=h?.width)!=null?o:d.innerWidth,w=(a=h?.height)!=null?a:d.innerHeight,x=n*w,m=n*p;return l={top:Math.max(l.top,f-x),right:Math.min(l.right,v+p+m),bottom:Math.min(l.bottom,f+w+x),left:Math.max(l.left,v-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 _c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Es(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(...Es(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(...Es(i.document,t))}}catch{}return n}function jo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function kc(){var e,t;const n=jo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Ao(e){return!e||!Dr(e)?!1:e instanceof Ke(e).ShadowRoot}function pi(e){if(e&&Dr(e)){let t=e.getRootNode();if(Ao(t))return t;if(t instanceof Document)return t}return jn(e)}function Ro(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function of(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(va(s)&&va(a)&&(s.type!=="file"&&(s.value=a.value),s.type==="radio"&&s.name&&(s.name=`Cloned__${s.name}`)),ma(s)&&ma(a)&&a.width>0&&a.height>0){const l=s.getContext("2d");l?.drawImage(a,0,0)}}),n}function va(e){return"value"in e}function ma(e){return e.tagName==="CANVAS"}function Sc(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(af(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Sc(i,{x:t-s,y:n-o})}}return r}function af(e){return e?.tagName==="IFRAME"}var Os=new WeakMap;function lf(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 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=`
|
|
8
|
+
`)}var $c=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:d}=a,c=[o,a];o.addEventListener(l,u,d),this.entries.add(c),i.push(c)}const s=this.entries;return function(){for(const a of i){const[l,{type:u,listener:d,options:c}]=a;l.removeEventListener(u,d,c),s.delete(a)}}}};function wn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function cf(e){const t=new Set;let n=wn(e);for(;n;)t.add(n),n=wn(n);return t}function df(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Ec(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=df(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function uf(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 ff(e,t=e.getBoundingClientRect()){const{width:n,height:r}=mr(e,t);return n>0&&r>0}var hf=_c?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ni,pf=class extends hf{constructor(e){super(t=>{if(!F(this,ni)){qe(this,ni,!0);return}e(t,this)}),Ne(this,ni,!1)}};ni=new WeakMap;var ya=Array.from({length:100},(e,t)=>t/100),Oc=75,Rt,gi,wt,Lt,Qn,De,dr,Zn,vi,Tc,Dc,Cc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ne(this,vi),this.disconnect=()=>{var s,o,a;qe(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,Ec(()=>{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:d,innerWidth:c}=(a=u.defaultView)!=null?a:window,h=l.getBoundingClientRect(),f=mr(l,h),{top:v,left:p,bottom:w,right:x}=f,m=-Math.floor(v),g=-Math.floor(p),b=-Math.floor(c-x),_=-Math.floor(d-w),$=`${m}px ${b}px ${_}px ${g}px`;this.boundingClientRect=h,qe(this,Lt,new IntersectionObserver(O=>{const[C]=O,{intersectionRect:I}=C;(C.intersectionRatio!==1?C.intersectionRatio:dt.intersectionRatio(I,mr(l)))!==1&&F(this,Zn).call(this)},{threshold:ya,rootMargin:$,root:u})),F(this,Lt).observe(l),bc(this,vi,Tc).call(this)},Oc)),this.boundingClientRect=e.getBoundingClientRect(),qe(this,Rt,ff(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(qe(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))),qe(this,Qn,new IntersectionObserver(s=>{var o,a;const l=s[s.length-1],{boundingClientRect:u,isIntersecting:d}=l,{width:c,height:h}=u,f=F(this,Rt);qe(this,Rt,d),!(!c&&!h)&&(f&&!d?((o=F(this,Lt))==null||o.disconnect(),this.callback(null),(a=F(this,wt))==null||a.disconnect(),qe(this,wt,void 0),F(this,De)&&(F(this,De).style.visibility="hidden")):F(this,Zn).call(this),d&&!F(this,wt)&&(qe(this,wt,new pf(F(this,Zn))),F(this,wt).observe(e)))},{threshold:ya,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;Tc=function(){F(this,dr)||(bc(this,vi,Dc).call(this),!uf(this.boundingClientRect,F(this,gi))&&(this.callback(this.boundingClientRect),qe(this,gi,this.boundingClientRect)))};Dc=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 gf(e,t){let n=zr.get(e);return n||(n={disconnect:new Cc(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 vf(e,t){const n=new Set;for(const r of e){const i=gf(r,t);n.add(i)}return()=>n.forEach(r=>r())}function mf(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,Ts,yf=class{constructor(e,t,n){this.callback=t,Ne(this,Jn),Ne(this,er,!1),Ne(this,ri),Ne(this,Ts,Ec(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}}},Oc));const r=cf(e),i=vf(r,t),s=mf(e,F(this,Ts));qe(this,ri,r),qe(this,Jn,new Cc(e,t,n)),this.disconnect=()=>{F(this,er)||(qe(this,er,!0),i(),s(),F(this,Jn).disconnect())}}};Jn=new WeakMap;er=new WeakMap;ri=new WeakMap;Ts=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 ba(e){return!_c||!e?!1:e===jn(e).scrollingElement}function Pc(e){var t,n;const r=Ke(e),i=ba(e)?nf(e):Ri(e),s=r.visualViewport,o=ba(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,d=a.current.y>=a.max.y,c=a.current.x>=a.max.x;return{rect:i,position:a,isTop:l,isLeft:u,isBottom:d,isRight:c}}function bf(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=Pc(e),{x:a,y:l}=t??{x:0,y:0},u=!n&&o.current.y+l>0,d=!r&&o.current.y+l<o.max.y,c=!i&&o.current.x+a>0,h=!s&&o.current.x+a<o.max.x;return{top:u,bottom:d,left:c,right:h,x:c||h,y:u||d}}var Lo=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 Lo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),xf=new Lo(e=>setTimeout(e,50)),yi=new Map,wf=yi.clear.bind(yi);function ht(e,t=!1){if(!t)return xa(e);let n=yi.get(e);return n||(n=xa(e),yi.set(e,n),xf.schedule(wf),n)}function xa(e){return Ke(e).getComputedStyle(e)}function _f(e,t=ht(e,!0)){return t.position==="fixed"||t.position==="sticky"}function kf(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 Sf={excludeElement:!0,escapeShadowDOM:!0};function Cs(e,t=Sf){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(Io(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&Ao(a))return o(a.host);if(!Tt(a))return wc(a)?o(a.parentElement):s;if(s.has(a))return s;const l=ht(a,!0);if(r&&a===e||kf(a,l)&&s.add(a),_f(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=Ri(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=Ri(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Tt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const i=ht(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function Ef(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 Li(e){var t,n,r,i,s,o,a,l,u;const{scale:d,transform:c,translate:h}=e,f=Ef(d),v=yr(h),p=Of(c);if(!p&&!f&&!v)return null;const w={x:(t=f?.x)!=null?t:1,y:(n=f?.y)!=null?n:1},x={x:(r=v?.x)!=null?r:0,y:(i=v?.y)!=null?i:0},m={x:(s=p?.x)!=null?s:0,y:(o=p?.y)!=null?o:0,scaleX:(a=p?.scaleX)!=null?a:1,scaleY:(l=p?.scaleY)!=null?l:1};return{x:x.x+m.x,y:x.y+m.y,z:(u=v?.z)!=null?u:0,scaleX:w.x*m.scaleX,scaleY:w.y*m.scaleY}}function Of(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||{}),Tf={x:.2,y:.2},Df={x:10,y:10};function Cf(e,t,n,r=25,i=Tf,s=Df){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:d,isLeft:c,isRight:h}=Pc(e),f=_n(e),v=ht(e,!0),p=Li(v),w=p!==null?p?.scaleX<0:!1,x=p!==null?p?.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),g={x:0,y:0},b={x:0,y:0},_={height:m.height*i.y,width:m.width*i.x};return _.height>0&&(!u||x&&!d)&&a<=m.top+_.height&&n?.y!==1&&o>=m.left-s.x&&o<=m.right+s.x?(g.y=x?1:-1,b.y=r*Math.abs((m.top+_.height-a)/_.height)):_.height>0&&(!d||x&&!u)&&a>=m.bottom-_.height&&n?.y!==-1&&o>=m.left-s.x&&o<=m.right+s.x&&(g.y=x?-1:1,b.y=r*Math.abs((m.bottom-_.height-a)/_.height)),_.width>0&&(!h||w&&!c)&&o>=m.right-_.width&&n?.x!==-1&&a>=m.top-s.y&&a<=m.bottom+s.y?(g.x=w?-1:1,b.x=r*Math.abs((m.right-_.width-o)/_.width)):_.width>0&&(!c||w&&!h)&&o<=m.left+_.width&&n?.x!==1&&a>=m.top-s.y&&a<=m.bottom+s.y&&(g.x=w?1:-1,b.x=r*Math.abs((m.left+_.width-o)/_.width)),{direction:g,speed:b}}function Mc(e,{block:t="nearest",inline:n="nearest"}={}){if(!Tt(e))return;const r=Cs(e),i=[];for(const s of r){if(!Tt(s))continue;const{top:o,left:a}=Pf(e,s);let l=o,u=a;for(const d of i)l-=d.scrollTop,u-=d.scrollLeft;if(t!=="none"){const d=l<s.scrollTop,c=l+e.offsetHeight>s.scrollTop+s.clientHeight;d!==c&&(t==="center"?s.scrollTop=l-s.clientHeight/2+e.offsetHeight/2:d?s.scrollTop=l:s.scrollTop=l+e.offsetHeight-s.clientHeight)}if(n!=="none"){const d=u<s.scrollLeft,c=u+e.offsetWidth>s.scrollLeft+s.clientWidth;d!==c&&(n==="center"?s.scrollLeft=u-s.clientWidth/2+e.offsetWidth/2:d?s.scrollLeft=u:s.scrollLeft=u+e.offsetWidth-s.clientWidth)}i.push(s)}}function wa(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!Tt(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function Pf(e,t){const n=wa(e),r=wa(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Mf(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left+s+(1-r)*parseFloat(n),l=e.top+o+(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width*r:e.width,d=i?e.height*i:e.height;return{width:u,height:d,top:l,right:a+u,bottom:l+d,left:a}}function If(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,d=i?e.height/i:e.height;return{width:u,height:d,top:l,right:a+u,bottom:l+d,left:a}}function Ic({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function _a(e,t=ht(e).translate,n=!0){if(n){const r=xc(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 jf=new Lo(e=>setTimeout(e,0)),ur=new Map,Af=ur.clear.bind(ur);function Rf(e){const t=e.ownerDocument;let n=ur.get(t);if(n)return n;n=t.getAnimations(),ur.set(t,n),jf.schedule(Af);const r=n.filter(i=>Ai(i.effect)&&i.effect.target===e);return ur.set(e,r),n}function Lf(e,t){const n=Rf(e).filter(r=>{var i,s;if(Ai(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=Ri}=t,u=Lf(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||jo())&&_.contains(e)}),d=l(e);let{top:c,left:h,width:f,height:v}=d,p;const w=ht(e),x=Li(w),m={x:(n=x?.scaleX)!=null?n:1,y:(r=x?.scaleY)!=null?r:1},g=Wf(e,w);u?.(),x&&(p=If(d,x,w.transformOrigin),(a||g)&&(c=p.top,h=p.left,f=p.width,v=p.height));const b={width:(i=p?.width)!=null?i:f,height:(s=p?.height)!=null?s:v};if(g&&!a&&p){const _=Mf(p,g,w.transformOrigin);c=_.top,h=_.left,f=_.width,v=_.height,m.x=g.scaleX,m.y=g.scaleY}o&&(a||(h*=o.scaleX,f*=o.scaleX,c*=o.scaleY,v*=o.scaleY),h+=o.x,c+=o.y),super(h,c,f,v),this.scale=m,this.intrinsicWidth=b.width,this.intrinsicHeight=b.height}};function Wf(e,t){const n=e.getAnimations();if(!n.length)return null;let r,i,s,o=!1;for(const a of n){if(a.playState!=="running")continue;const l=Ai(a.effect)?a.effect.getKeyframes():[],u=l[l.length-1];if(!u)continue;const{transform:d,translate:c,scale:h}=u;typeof d=="string"&&d&&(r=d,o=!0),typeof c=="string"&&c&&(i=c,o=!0),typeof h=="string"&&h&&(s=h,o=!0)}return o?Li({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 zf=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||Dr(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 Ff(e){if(!e)return!1;const{PointerEvent:t}=Ke(e.target);return e instanceof t}function Nf(e){if(!Vt(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||Bf(e)}function Bf(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Ji={};function Ps(e){const t=Ji[e]==null?0:Ji[e]+1;return Ji[e]=t,`${e}-${t}`}var Wo=({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},Vf=({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},jc=e=>{var t;return(t=Wo(e))!=null?t:Vf(e)},Gf=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,d)=>{var c;return l+Ze.distance(Ze.from(u),(c=s?.[d])!=null?c:i.current)},0)/4;return{id:n.id,value:1/a,type:In.Collision,priority:Mn.Normal}},Uf=Object.create,zo=Object.defineProperty,qf=Object.defineProperties,Hf=Object.getOwnPropertyDescriptor,Kf=Object.getOwnPropertyDescriptors,bi=Object.getOwnPropertySymbols,Ac=Object.prototype.hasOwnProperty,Rc=Object.prototype.propertyIsEnumerable,Lc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),An=e=>{throw TypeError(e)},Ms=(e,t,n)=>t in e?zo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xr=(e,t)=>{for(var n in t||(t={}))Ac.call(t,n)&&Ms(e,n,t[n]);if(bi)for(var n of bi(t))Rc.call(t,n)&&Ms(e,n,t[n]);return e},Fo=(e,t)=>qf(e,Kf(t)),ka=(e,t)=>zo(e,"name",{value:t,configurable:!0}),Wc=(e,t)=>{var n={};for(var r in e)Ac.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&&Rc.call(e,r)&&(n[r]=e[r]);return n},Rn=e=>{var t;return[,,,Uf((t=e?.[Lc("metadata")])!=null?t:null)]},zc=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?An("Function expected"):e,Yf=(e,t,n,r,i)=>({kind:zc[e],name:t,metadata:r,addInitializer:s=>n._?An("Already initialized"):i.push(tr(s||null))}),Xt=(e,t)=>Ms(t,Lc("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,d,c=t&7,h=!!(t&8),f=!!(t&16),v=c>3?e.length+1:c?h?1:2:0,p=zc[c+5],w=c>3&&(e[v-1]=[]),x=e[v]||(e[v]=[]),m=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&Hf(c<4?i:{get[n](){return re(this,s)},set[n](b){return Ae(this,s,b)}},n));c?f&&c<4&&ka(s,(c>2?"set ":c>1?"get ":"")+n):ka(i,n);for(var g=r.length-1;g>=0;g--)u=Yf(c,n,l={},e[3],x),c&&(u.static=h,u.private=f,d=u.access={has:f?b=>Xf(i,b):b=>n in b},c^3&&(d.get=f?b=>(c^1?re:Gt)(b,i,c^4?s:m.get):b=>b[n]),c>2&&(d.set=f?(b,_)=>Ae(b,i,_,c^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?f?s:m[p]:c>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,c^4||a===void 0?tr(a)&&(c>4?w.unshift(a):c?f?s=a:m[p]=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 c||Xt(e,i),m&&zo(i,n,m),f?c^4?s:m:i},No=(e,t,n)=>t.has(e)||An("Cannot "+n),Xf=(e,t)=>Object(t)!==t?An('Cannot use the "in" operator on this value'):e.has(t),re=(e,t,n)=>(No(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)=>(No(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Gt=(e,t,n)=>(No(e,t,"access private method"),n),Sa={role:"button",roleDescription:"draggable"},Qf="dnd-kit-description",Zf="dnd-kit-announcement",Jf={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."},eh={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 th(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function nh(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function rh(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 ih=["dragover","dragmove"],sh=class extends Me{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Qf,announcement:i=Zf}={},announcements:s=eh,screenReaderInstructions:o=Jf,debounce:a=500}=t??{},l=n?`${r}-${n}`:Ps(r),u=n?`${i}-${n}`:Ps(i);let d,c,h,f;const v=(_=f)=>{!h||!_||h?.nodeValue!==_&&(h.nodeValue=_)},p=()=>mi.schedule(v),w=oh(p,a),x=Object.entries(s).map(([_,$])=>this.manager.monitor.addEventListener(_,(O,C)=>{const I=h;if(!I)return;const P=$?.(O,C);P&&I.nodeValue!==P&&(f=P,ih.includes(_)?w():(p(),w.cancel()))})),m=()=>{let _=[];d?.isConnected||(d=nh(l,o.draggable),_.push(d)),c?.isConnected||(c=rh(u),h=document.createTextNode(""),c.appendChild(h),_.push(c)),_.length>0&&document.body.append(..._)},g=new Set;function b(){for(const _ of g)_()}this.registerEffect(()=>{var _;g.clear();for(const $ of this.manager.registry.draggables.value){const O=(_=$.handle)!=null?_:$.element;if(O){(!d||!c)&&g.add(m),(!th(O)||jo())&&!O.hasAttribute("tabindex")&&g.add(()=>O.setAttribute("tabindex","0")),!O.hasAttribute("role")&&O.tagName.toLowerCase()!=="button"&&g.add(()=>O.setAttribute("role",Sa.role)),O.hasAttribute("aria-roledescription")||g.add(()=>O.setAttribute("aria-roledescription",Sa.roleDescription)),O.hasAttribute("aria-describedby")||g.add(()=>O.setAttribute("aria-describedby",l));for(const I of["aria-pressed","aria-grabbed"]){const P=String($.isDragging);O.getAttribute(I)!==P&&g.add(()=>O.setAttribute(I,P))}const C=String($.disabled);O.getAttribute("aria-disabled")!==C&&g.add(()=>O.setAttribute("aria-disabled",C))}}g.size>0&&mi.schedule(b)}),this.destroy=()=>{super.destroy(),d?.remove(),c?.remove(),x.forEach(_=>_())}}};function oh(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var xi=new Map,Fc,Nc,Bc,Vc,Is,hr,mt,Bo,kn,Gc,Uc,qc,Hc,Dt=class extends(Is=Tr,Vc=[K],Bc=[ge],Nc=[ge],Fc=[ge],Is){constructor(t,n){super(t,n),we(mt,5,this),ve(this,kn),ve(this,hr,new Set),ve(this,Bo,we(mt,8,this,new Set)),we(mt,11,this),this.registerEffect(Gt(this,kn,Gc))}register(t){return re(this,hr).add(t),()=>{re(this,hr).delete(t)}}addRoot(t){return H(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{H(()=>{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(Is);hr=new WeakMap;Bo=new WeakMap;kn=new WeakSet;Gc=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of re(this,hr))t.push(Gt(this,kn,Uc).call(this,n,r));return()=>{for(const n of t)n()}};Uc=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=Io(e)?Gt(this,kn,qc).call(this,e,n,t):Gt(this,kn,Hc).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())}};qc=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)}}};Hc=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(Ao(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",Vc,Dt,Bo);nt(mt,2,"sourceRoot",Bc,Dt);nt(mt,2,"targetRoot",Nc,Dt);nt(mt,2,"roots",Fc,Dt);Xt(mt,Dt);Dt.configure=Or(Dt);var Wi=Dt,ah=class extends Me{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Wi),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},Cr="data-dnd-",js=`${Cr}dropping`,Te="--dnd-",lt=`${Cr}dragging`,wi=`${Cr}placeholder`,lh=[lt,wi,"popover","aria-pressed","aria-grabbing"],ch=["view-transition-name"],dh=`
|
|
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(${
|
|
16
|
-
left: var(${
|
|
15
|
+
top: var(${Te}top, 0px) !important;
|
|
16
|
+
left: var(${Te}left, 0px) !important;
|
|
17
17
|
right: unset !important;
|
|
18
18
|
bottom: unset !important;
|
|
19
|
-
width: var(${
|
|
20
|
-
max-width: var(${
|
|
21
|
-
height: var(${
|
|
22
|
-
max-height: var(${
|
|
23
|
-
transform: var(${
|
|
24
|
-
transition: var(${
|
|
19
|
+
width: var(${Te}width, auto);
|
|
20
|
+
max-width: var(${Te}width, auto);
|
|
21
|
+
height: var(${Te}height, auto);
|
|
22
|
+
max-height: var(${Te}height, auto);
|
|
23
|
+
transform: var(${Te}transform, none) !important;
|
|
24
|
+
transition: var(${Te}transition) !important;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
:is(:root,:host) [${wi}] {
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
pointer-events: none !important;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
[${lt}]:not([${
|
|
40
|
-
translate: var(${
|
|
39
|
+
[${lt}]:not([${js}]) {
|
|
40
|
+
translate: var(${Te}translate) !important;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
[${lt}][style*='${
|
|
44
|
-
scale: var(${
|
|
45
|
-
transform-origin: var(${
|
|
43
|
+
[${lt}][style*='${Te}scale'] {
|
|
44
|
+
scale: var(${Te}scale) !important;
|
|
45
|
+
transform-origin: var(${Te}transform-origin) !important;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
@layer dnd-kit {
|
|
@@ -64,47 +64,47 @@
|
|
|
64
64
|
display: none;
|
|
65
65
|
visibility: hidden;
|
|
66
66
|
}
|
|
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(`
|
|
67
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function uh(e,t="hidden"){return H(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=fh(n,r.registry.droppables),s=[],o=of(n),{remove:a}=o;return hh(i,o,s),ph(o,t),o.remove=()=>{s.forEach(l=>l()),a.call(o)},o})}function fh(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${Cr}${Ps("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function hh(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),Os.set(a,o),n.push(()=>{Os.delete(a),r.proxy=void 0})}}function ph(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(wi,t)}function Kc(e,t){return e===t?!0:wn(e)===wn(t)}function $a(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Vt(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>vn(t))}function As(e){return e.tagName==="TR"}function gh(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-")||lh.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(fr(e)&&fr(t)){const u=e.style;for(const d of Array.from(t.style))u.getPropertyValue(d)===""&&t.style.removeProperty(d);for(const d of Array.from(u)){if(ch.includes(d)||d.startsWith(Te))continue;const c=u.getPropertyValue(d);t.style.setProperty(d,c)}}}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 vh(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 mh(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=kc();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},Te),(n=e.getElementMutationObserver())==null||n.takeRecords(),As(e.element)&&As(e.placeholder)){const p=Array.from(e.element.cells),w=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(p.map(x=>x.style.width));for(const[x,m]of p.entries()){const g=w[x];m.style.width=`${g.getBoundingClientRect().width}px`}}const u=(r=e.getTranslate())!=null?r:{x:0,y:0},d=e.left+o+l.x+u.x,c=e.top+a+l.y+u.y,h=i.width-e.widthOffset,f=i.height-e.heightOffset,v=e.frameTransform;e.dragOperation.shape=new dt(d*v.scaleX+v.x,c*v.scaleY+v.y,h*v.scaleX,f*v.scaleY)})}var yh=250,bh="ease";function xh(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=yh,easing:a=bh}=s??{};vn(e.feedbackElement);const[,l]=(t=xc(e.feedbackElement,m=>"translate"in m))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,d={frameTransform:Kc(e.feedbackElement,u)?null:void 0},c=new ct(e.feedbackElement,d),h=(r=yr(ht(e.feedbackElement).translate))!=null?r:e.translate,f=new ct(u,d),v=dt.delta(c,f,e.alignment),p={x:h.x-v.x,y:h.y-v.y},w=Math.round(c.intrinsicHeight)!==Math.round(f.intrinsicHeight)?{minHeight:[`${c.intrinsicHeight}px`,`${f.intrinsicHeight}px`],maxHeight:[`${c.intrinsicHeight}px`,`${f.intrinsicHeight}px`]}:{},x=Math.round(c.intrinsicWidth)!==Math.round(f.intrinsicWidth)?{minWidth:[`${c.intrinsicWidth}px`,`${f.intrinsicWidth}px`],maxWidth:[`${c.intrinsicWidth}px`,`${f.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Te),e.feedbackElement.setAttribute(js,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),Ic({element:e.feedbackElement,keyframes:Fo(xr(xr({},w),x),{translate:[`${h.x}px ${h.y}px 0`,`${p.x}px ${p.y}px 0`]}),options:{duration:Ro(Ke(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(js),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Yc,Rs,wr,Vo,ii,Xc,Qc,Sn=class extends(Rs=Me,Yc=[K],Rs){constructor(t,n){super(t,n),ve(this,ii),ve(this,Vo,we(wr,8,this)),we(wr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(Wi),i=r?.register(dh);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}this.registerEffect(Gt(this,ii,Xc).bind(this,r)),this.registerEffect(Gt(this,ii,Qc))}};wr=Rn(Rs);Vo=new WeakMap;ii=new WeakSet;Xc=function(e){const{overlay:t}=this;if(!t||!e)return;const n=pi(t);if(n)return e.addRoot(n)};Qc=function(){var e,t,n,r,i,s,o;const{state:a,manager:l,options:u}=this,{dragOperation:d}=l,{position:c,source:h,status:f}=d;if(f.idle){a.current={},a.initial={};return}if(!h)return;const{element:v}=h,p=h.pluginConfig(Sn),w=(t=(e=p?.feedback)!=null?e:u?.feedback)!=null?t:"default",x=typeof w=="function"?w(h,l):w;if(!v||x==="none"||!f.initialized||f.initializing)return;const{initial:m}=a,g=(n=this.overlay)!=null?n:v,b=_n(g),_=_n(v),$=!Kc(v,g),O=new ct(v,{frameTransform:$?_:null,ignoreTransforms:!$}),C={x:_.scaleX/b.scaleX,y:_.scaleY/b.scaleY};let{width:I,height:P,top:U,left:W}=O;$&&(I=I/C.x,P=P/C.y);const M=new zf(g),z=ht(v),{transition:V,translate:ee,boxSizing:Se,paddingBlockStart:oe,paddingBlockEnd:Le,paddingInlineStart:Ve,paddingInlineEnd:Ce,borderInlineStartWidth:Ye,borderInlineEndWidth:Ge,borderBlockStartWidth:We,borderBlockEndWidth:Xe}=z,$e=V.split(",").filter(Z=>!/^\s*(transform|translate|scale)\b/.test(Z)).join(","),fe=Li(z),L=z.transform,G=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,ne=x!=="move"&&!this.overlay?uh(h,G?"clone":"hidden"):null,at=H(()=>br(l.dragOperation.activatorEvent));if(!m.translate){if(this.overlay&&fe)m.translate={x:fe.x,y:fe.y};else if(ee!=="none"){const Z=yr(ee);Z&&(m.translate=Z)}}if(!m.transformOrigin){const Z=H(()=>c.current),R=W+((r=fe?.x)!=null?r:0),te=U+((i=fe?.y)!=null?i:0);m.transformOrigin={x:(Z.x-R*b.scaleX-b.x)/(I*b.scaleX),y:(Z.y-te*b.scaleY-b.y)/(P*b.scaleY)}}const{transformOrigin:Fe}=m,xt=U*b.scaleY+b.y,T=W*b.scaleX+b.x;if(!m.coordinates&&(m.coordinates={x:T,y:xt},C.x!==1||C.y!==1)){const{scaleX:Z,scaleY:R}=_,{x:te,y:Oe}=Fe;m.coordinates.x+=(I*Z-I)*te,m.coordinates.y+=(P*R-P)*Oe}m.dimensions||(m.dimensions={width:I,height:P}),m.frameTransform||(m.frameTransform=b);const A={x:m.coordinates.x-T,y:m.coordinates.y-xt},q={width:(m.dimensions.width*m.frameTransform.scaleX-I*b.scaleX)*Fe.x,height:(m.dimensions.height*m.frameTransform.scaleY-P*b.scaleY)*Fe.y},E={x:A.x/b.scaleX+q.width,y:A.y/b.scaleY+q.height},D={left:W+E.x,top:U+E.y};g.setAttribute(lt,"true");const B=H(()=>d.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=kc();M.set({width:I-X,height:P-ze,top:D.top+se.y,left:D.left+se.x,translate:`${Ue}px ${ke}px 0`,transform:this.overlay?"none":L,transition:$e?`${$e}, translate 0ms linear`:"translate 0ms linear",scale:$?`${C.x} ${C.y}`:"","transform-origin":`${Fe.x*100}% ${Fe.y*100}%`},Te),ne&&(v.insertAdjacentElement("afterend",ne),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(h):u.rootElement).appendChild(v)),Ds(g)&&(g.hasAttribute("popover")||g.setAttribute("popover","manual"),vn(g),g.addEventListener("beforetoggle",$a));let Ee,Qt,Ct;const Rr=mh({placeholder:ne,element:v,feedbackElement:g,frameTransform:b,transformOrigin:Fe,width:I,height:P,top:U,left:W,widthOffset:X,heightOffset:ze,delta:E,styles:M,dragOperation:d,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>Ee,getSavedCellWidths:()=>Ct,setSavedCellWidths:Z=>{Ct=Z}}),Pt=new ct(g);H(()=>d.shape=Pt);const Zt=Ke(g),Wn=Z=>{this.manager.actions.stop({event:Z})},ra=Ro(Zt);at&&Zt.addEventListener("resize",Wn),H(()=>h.status)==="idle"&&requestAnimationFrame(()=>h.status="dragging"),ne&&(Rr.observe(ne),Ee=gh(v,ne,G),Qt=vh(v,ne,g));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),te=(Z=R?.handle)!=null?Z:R?.element;Tt(te)&&te.focus()},Fn=()=>{Ee?.disconnect(),Qt?.disconnect(),Rr.disconnect(),Zt.removeEventListener("resize",Wn),Ds(g)&&(g.removeEventListener("beforetoggle",$a),g.removeAttribute("popover")),g.removeAttribute(lt),M.reset();const Z=()=>{var R;if(Ct&&As(v)){const he=Array.from(v.cells);for(const[ae,Jt]of he.entries())Jt.style.width=(R=Ct[ae])!=null?R:""}h.status="idle";const te=a.current.translate!=null,Oe=d.status.dragging;ne&&(!Oe&&te||ne.parentElement!==g.parentElement)&&g.isConnected&&ne.replaceWith(g),ne?.remove()};g===this.overlay?setTimeout(Z,0):Z()},Gi=u?.dropAnimation,Nn=this,Ui=$r(()=>{var Z,R,te;const{transform:Oe,status:he}=d;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},ia=a.current.translate,tu=H(()=>d.modifiers),qi=H(()=>{var Vn;return(Vn=d.shape)==null?void 0:Vn.current}),Bn=u?.keyboardTransition,sa=at&&!ra&&Bn!==null?`${(R=Bn?.duration)!=null?R:250}ms ${(te=Bn?.easing)!=null?te:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(M.set({transition:$e?`${$e}, translate ${sa}`:`translate ${sa}`,translate:`${Jt.x}px ${Jt.y}px 0`},Te),Ee?.takeRecords(),qi&&qi!==Pt&&ia&&!tu.length){const Vn=Ze.delta(Jt,ia);d.shape=dt.from(qi.boundingRectangle).translate(Vn.x*b.scaleX,Vn.y*b.scaleY)}else d.shape=new ct(g);a.current.translate=Jt}},function(){if(d.status.dropped){this.dispose(),h.status="dropping";const Z=p?.dropAnimation!==void 0?p.dropAnimation:Nn.dropAnimation!==void 0?Nn.dropAnimation:Gi;let R=a.current.translate;const te=R!=null;if(!R&&v!==g&&(R={x:0,y:0}),!R||Z===null){Fn();return}l.renderer.rendering.then(()=>{xh({source:h,element:v,feedbackElement:g,placeholder:ne,translate:R,moved:te,transition:V,alignment:h.alignment,styles:M,animation:Z??void 0,getElementMutationObserver:()=>Ee,cleanup:Fn,restoreFocus:zn})})}});return()=>{Fn(),Ui()}};nt(wr,4,"overlay",Yc,Sn,Vo);Xt(wr,Sn);Sn.configure=Or(Sn);var Go=Sn,Gn=!0,wh=!1,Zc,Jc,ed,td,St,Uo,qo;td=(ed=[K],Je.Forward),Jc=(Zc=[K],Je.Reverse);var _r=class{constructor(){ve(this,Uo,we(St,8,this,Gn)),we(St,11,this),ve(this,qo,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]=wh)}};St=Rn(null);Uo=new WeakMap;qo=new WeakMap;nt(St,4,td,ed,_r,Uo);nt(St,4,Jc,Zc,_r,qo);Xt(St,_r);var _h=[Je.Forward,Je.Reverse],Ea=class{constructor(){this.x=new _r,this.y=new _r}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},kh=class extends Me{constructor(e){super(e);const t=En(new Ea);let n=null;this.signal=t,tt(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Ea;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:Oa(i.x,n.x),y:Oa(i.y,n.y)},o=t.peek();ue(()=>{for(const a of Cl)for(const l of _h)s[a]===l&&o[a].unlock(l);t.value=o})}n=i})}get current(){return this.signal.peek()}};function Oa(e,t){return Math.sign(e-t)}var nd,Ls,kr,Ho,_t,Ws,Pr=class extends(Ls=Tr,nd=[K],Ls){constructor(e){super(e),ve(this,Ho,we(kr,8,this,!1)),we(kr,11,this),ve(this,_t),ve(this,Ws,()=>{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,d=u?.current;if(d){const{by:c}=s??{},h=c?{x:Ta(c.x),y:Ta(c.y)}:void 0,f=h?void 0:this.scrollIntentTracker.current;if(f?.isLocked())return!1;for(const v of l){const p=bf(v,c);if(p.x||p.y){const{speed:w,direction:x}=Cf(v,d,h,o?.acceleration,o?.threshold);if(f)for(const m of Cl)f[m].isLocked(x[m])&&(w[m]=0,x[m]=0);if(x.x||x.y){const{x:m,y:g}=c??x,b=m*w.x,_=g*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:v,by:{x:b,y:_}}),mi.schedule(re(this,Ws)),!0}}}}}return Ae(this,_t,void 0),!1};let t=null,n=null;const r=hs(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=Sc(pi(o?.element),s.current);return a&&(t=a),a??t}),i=hs(()=>{const s=r.value,{documentElement:o}=jn(s);if(!s||s===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const u=Cs(l,{excludeElement:!1});return n=u,u}}if(s){const a=Cs(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 kh(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(Ls);Ho=new WeakMap;_t=new WeakMap;Ws=new WeakMap;nt(kr,4,"autoScrolling",nd,Pr,Ho);Xt(kr,Pr);function Ta(e){return e>0?Je.Forward:e<0?Je.Reverse:Je.Idle}var Sh=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 Sh(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Eh=10,zs=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 c=setInterval(()=>$h.schedule(()=>r.scroll(void 0,u)),Eh);return()=>{clearInterval(c)}}else r.autoScrolling=!1}})}};zs.configure=Or(zs);var rd=zs,Da={capture:!0,passive:!0},nr,Oh=class extends Tr{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 Th="* { user-select: none !important; -webkit-user-select: none !important; }",Dh=class extends Me{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Wi),n=t?.register(Th);if(this.destroy=tt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return es(),document.addEventListener("selectionchange",es,{capture:!0}),()=>{document.removeEventListener("selectionchange",es,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function es(){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 $c,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(),Mc(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(rd);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 id=_i;function en(e,t){return t.includes(e.code)}var Wt,Ch=class extends lc{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&&_s(r,i)){this.abort();return}_s(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,Ph=class extends lc{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};_s(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=Ph;gn.Distance=Ch;var Fs=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})]:Nf(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=lf(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 $c,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=Fs.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=>{Ff(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&&(jh(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||Mh(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:i=Fs.preventActivation}=r??{};if(i?.(t,n))return;const{target:s}=t,o=Tt(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 d=this.activationConstraints(t,n,r);t.sensor=this;const c=new Zu(d,p=>this.handleStart(n,p));c.signal.onabort=()=>this.handleCancel(t),c.onEvent(t),this.controller=c;const h=Es(),f=this.listeners.bind(h,[{type:"pointermove",listener:p=>this.handlePointerMove(p,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Nr,options:{capture:!0}}]),v=()=>{f(),this.initialCoordinates=void 0};re(this,fn).add(v)}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=Fs;var Ns=ki;function Mh(e){return"sensor"in e}function Nr(e){e.preventDefault()}function Ih(){}var Ca=new WeakSet;function jh(e){!e||Ca.has(e)||(e.addEventListener("touchmove",Ih,{capture:!1,passive:!1}),Ca.add(e))}var mn={modifiers:[],plugins:[sh,rd,ah,Go,Dh],sensors:[Ns,id]},sd=class extends tf{constructor(e={}){const t=st(e.plugins,mn.plugins),n=st(e.sensors,mn.sensors),r=st(e.modifiers,mn.modifiers);super(Fo(xr({},e),{plugins:[Oh,Pr,Wi,...t],sensors:n,modifiers:r}))}},od,ad,Bs,$t,Ko,Yo,zi=class extends(Bs=ut,ad=[K],od=[K],Bs){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=Wc(n,["element","effects","handle"]);super(xr({effects:()=>[...i(),()=>{var a,l;const{manager:u}=this;if(!u)return;const c=((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),v=h instanceof bn?void 0:h.options;return f.bind(this,v)});return function(){c.forEach(f=>f())}}]},o),t),ve(this,Ko,we($t,8,this)),we($t,11,this),ve(this,Yo,we($t,12,this)),we($t,15,this),this.element=r,this.handle=s}};$t=Rn(Bs);Ko=new WeakMap;Yo=new WeakMap;nt($t,4,"handle",ad,zi,Ko);nt($t,4,"element",od,zi,Yo);Xt($t,zi);var ld,cd,Vs,Et,Xo,ts,dd,ud,pr,Qo,Fi=class extends(Vs=ft,cd=[K],ld=[K],Vs){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=Wc(n,["element","effects"]);const{collisionDetector:o=jc}=s,a=u=>{const{manager:d,element:c}=this;if(!c||u===null){this.shape=void 0;return}if(!d)return;const h=new ct(c),f=H(()=>this.shape);return h&&f?.equals(h)?f:(this.shape=h,h)},l=En(!1);super(Fo(xr({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:u,manager:d}=this;if(!d)return;const{dragOperation:c}=d,{source:h}=c;l.value=!!(h&&c.status.initialized&&u&&!this.disabled&&this.accepts(h))},()=>{const{element:u}=this;if(l.value&&u){const d=new yf(u,a);return()=>{d.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,Xo,we(Et,8,this)),we(Et,11,this),ve(this,Qo,we(Et,12,this)),we(Et,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){Ae(this,pr,e,ud)}get element(){var e;return(e=this.proxy)!=null?e:re(this,pr,dd)}};Et=Rn(Vs);Xo=new WeakMap;pr=new WeakSet;Qo=new WeakMap;ts=nt(Et,20,"#element",cd,pr,Xo),dd=ts.get,ud=ts.set;nt(Et,4,"proxy",ld,Fi,Qo);Xt(Et,Fi);function Ah(e){return e!=null&&typeof e=="object"&&"current"in e}function yn(e){var t;if(e!=null)return Ah(e)?(t=e.current)!=null?t:void 0:e}var Rh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ln=Rh?S.useLayoutEffect:S.useEffect;function Lh(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function fd(e,t){const n=S.useRef(new Map),r=Lh();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=H(()=>a[1]),d=e[l];u!==d&&(s=!0,n.current.set(l,d),o=(i=t?.(l,u,d))!=null?i:!1)}s&&(o?queueMicrotask(()=>lu.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 Wh(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 zh=Object.defineProperty,Fh=Object.defineProperties,Nh=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertySymbols,hd=Object.prototype.hasOwnProperty,pd=Object.prototype.propertyIsEnumerable,Pa=(e,t,n)=>t in e?zh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bh=(e,t)=>{for(var n in t||(t={}))hd.call(t,n)&&Pa(e,n,t[n]);if(Si)for(var n of Si(t))pd.call(t,n)&&Pa(e,n,t[n]);return e},Vh=(e,t)=>Fh(e,Nh(t)),Gh=(e,t)=>{var n={};for(var r in e)hd.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&&pd.call(e,r)&&(n[r]=e[r]);return n},Uh=new sd,gd=S.createContext(Uh),qh=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})),ns=[void 0,rt];function Hh(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=Gh(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const d=S.useRef(null),{plugins:c,modifiers:h,sensors:f}=u,v=st(c,mn.plugins),p=st(f,mn.sensors),w=st(h,mn.modifiers),x=tn(i),m=tn(s),g=tn(a),b=tn(o),_=tn(l),$=tn(r),O=Kh(()=>{var C;return(C=u.manager)!=null?C:new sd(u)});return S.useEffect(()=>{if(!d.current)throw new Error("Renderer not found");const{renderer:C,trackRendering:I}=d.current,{monitor:P}=O;O.renderer=C;const U=[P.addEventListener("beforedragstart",W=>{const M=x.current;M&&I(()=>M(W,O))}),P.addEventListener("dragstart",W=>{var M;return(M=m.current)==null?void 0:M.call(m,W,O)}),P.addEventListener("dragover",W=>{const M=g.current;M&&I(()=>M(W,O))}),P.addEventListener("dragmove",W=>{const M=b.current;M&&I(()=>M(W,O))}),P.addEventListener("dragend",W=>{const M=_.current;M&&I(()=>M(W,O))}),P.addEventListener("collision",W=>{var M;return(M=$.current)==null?void 0:M.call($,W,O)})];return()=>U.forEach(W=>W())},[O]),le(v,()=>O&&(O.plugins=v),...ns),le(p,()=>O&&(O.sensors=p),...ns),le(w,()=>O&&(O.modifiers=w),...ns),y.jsxs(gd.Provider,{value:O,children:[y.jsx(qh,{ref:d,children:n}),n]})}function Kh(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 Yh(){return S.useContext(gd)}function vd(e){var t;const n=(t=Yh())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ln(r.register,[n,r]),r}var Xh=Object.create,md=Object.defineProperty,Qh=Object.getOwnPropertyDescriptor,yd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ni=e=>{throw TypeError(e)},Zh=(e,t,n)=>t in e?md(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jh=e=>{var t;return[,,,Xh((t=e?.[yd("metadata")])!=null?t:null)]},bd=["class","method","getter","setter","accessor","field","value","get","set"],xd=e=>e!==void 0&&typeof e!="function"?Ni("Function expected"):e,ep=(e,t,n,r,i)=>({kind:bd[e],name:t,metadata:r,addInitializer:s=>n._?Ni("Already initialized"):i.push(xd(s||null))}),tp=(e,t)=>Zh(t,yd("metadata"),e[3]),np=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},wd=(e,t,n,r,i,s)=>{for(var o,a,l,u,d=t&7,c=!1,h=!1,f=2,v=bd[d+5],p=e[f]||(e[f]=[]),w=(i=i.prototype,Qh(i,n)),x=r.length-1;x>=0;x--)l=ep(d,n,a={},e[3],p),l.static=c,l.private=h,u=l.access={has:m=>n in m},u.get=m=>m[n],o=(0,r[x])(w[v],l),a._=1,xd(o)&&(w[v]=o);return w&&md(i,n,w),i},_d=(e,t,n)=>t.has(e)||Ni("Cannot "+n),rp=(e,t,n)=>(_d(e,t,"read from private field"),t.get(e)),ip=(e,t,n)=>t.has(e)?Ni("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),sp=(e,t,n,r)=>(_d(e,t,"write to private field"),t.set(e,n),n),Nt=class Gs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Gs(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 Gs(t,n)}},kd,Sd,Us,oi,Mr,Zo=class extends(Us=Kt,Sd=[ge],kd=[ge],Us){constructor(e){const t=Nt.from(e);super(t,(n,r)=>Nt.equals(n,r)),np(Mr,5,this),ip(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-rp(this,oi),o=a=>Math.round(a/s*100);ue(()=>{sp(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=Jh(Us);oi=new WeakMap;wd(Mr,2,"delta",Sd,Zo);wd(Mr,2,"direction",kd,Zo);tp(Mr,Zo);var $d=(e=>(e.Horizontal="x",e.Vertical="y",e))($d||{});Object.values($d);var op=({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},ap=({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},lp=e=>{var t;return(t=op(e))!=null?t:ap(e)};function cp(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,l=vd(d=>new Fi(Vh(Bh({},e),{register:!1,element:yn(i)}),d)),u=fd(l);return le(s,()=>l.id=s),si(i,d=>l.element=d),le(o,()=>l.accept=o,void 0,rt),le(t,()=>l.collisionDetector=t??lp),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(d=>{var c,h;!d&&((c=l.element)!=null&&c.isConnected)&&!((h=l.manager)!=null&&h.dragOperation.status.idle)||(l.element=d??void 0)},[l])}}function dp(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 up(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function ai(e,t){const n=up(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 Ma(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 fp(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const hp=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function pp(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 Ia=[{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 qs=e=>e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function gp(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 vp(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!qs(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 mp(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 yp(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 bp=j.createSvgIcon(y.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),xp=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"})),wp=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"})),_p=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),rs=Hs?"⌘":"Ctrl+",kp=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function Sp(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(!kp(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:d}=Be.usePublisherTheme();return y.jsxs(j.DashboardBar,{left:y.jsx(k.Chip,{size:"medium",variant:"outlined",icon:y.jsx(xp,{sx:{fontSize:20}}),label:"Editing",sx:{height:37,fontSize:"0.875rem",fontWeight:500,border:d.border,color:d.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(bp,{}),onClick:c=>u(c.currentTarget),children:"Settings"}),y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),y.jsx(k.Tooltip,{title:`Undo (${rs}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(_p,{fontSize:"small"})})})}),y.jsx(k.Tooltip,{title:`Redo (${rs}⇧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(wp,{fontSize:"small"})})})}),o&&y.jsx(y.Fragment,{children:y.jsx(k.Tooltip,{title:i?`Save (${rs}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 Ep=["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 ja(e){for(const t of e??[]){const n=/^#\s*([a-z_]+)/.exec(t.trim())?.[1];if(n&&Ep.includes(n))return n}}const Op=1;function Ed(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(...Ed(a,`${t}${s}.`,n-1))}}}return r}function Tp(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,Ed(i.schema?.fields,"",Op))}return t}function Aa(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const Dp=e=>(e??"").startsWith("dashboards/"),Od=e=>e.modelPath??e.path??"";function Td(e){const t=[],n=new Set;for(const r of e){const i=Od(r);if(Dp(i))continue;const s=Tp(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)}:{},...ja(u.annotations)?{chart:ja(u.annotations)}:{}})),givens:l,fields:s.get(a)??[]})}}return{sources:t}}function Cp(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=>Od(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 Pp(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 Mp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=Be.usePublisherTheme(),a=S.useMemo(()=>Pp(t,n),[t,n]),[l,u]=S.useState(""),[d,c]=S.useState(""),[h,f]=S.useState(""),[v,p]=S.useState(Math.ceil(r/2));S.useEffect(()=>{e&&(u(t.sources[0]?.base??a[0]?.name??""),c(""),f(""),p(Math.ceil(r/2)))},[e,t,a,r]);const w=a.find(m=>m.name===l),x=l!==""&&d!=="";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:d,...h.trim()?{label:h.trim()}:{},colspan:v}),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),c("")},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:d===m.name,onClick:()=>c(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:v,onChange:m=>p(Math.min(Math.max(Number(m.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})})})}const Ra=4e3;function Ip(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 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
|
|
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
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
`),r=await
|
|
75
|
-
`&&t.push(n+1);return t}function
|
|
76
|
-
`})}}function
|
|
69
|
+
`);if(n.length>Ra||r.length>Ra)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 jp(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 Ap({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=Be.usePublisherTheme(),o=S.useMemo(()=>e?jp(Ip(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,d)=>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"}`},d):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]},d))})})}const is="self";function Rp({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 v=(t.drills??[]).filter(p=>p.source===n.name);u((n.dimensions??[]).map(p=>{const w=v.find(x=>x.name===p.name);return{name:p.name,expression:p.expression,to:w?.to??[],given:w?.given??""}}))},[e,n,t]);const d=(v,p)=>u(w=>w.map((x,m)=>{if(m!==v)return x;const g={...x};return p(g),g})),c=[is,...i.filter(v=>v!==is)],h=v=>v===is?"This dashboard":v,f=()=>{n&&(o(l.filter(v=>v.to.length>0).map(v=>({source:n.name,name:v.name,expression:v.expression,to:v.to,...v.given?{given:v.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((v,p)=>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:v.name}),y.jsxs(k.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:v.expression,children:["is ",v.expression]})]}),y.jsx(k.TextField,{select:!0,size:"small",label:"Clicks go to",value:v.to,inputProps:{"aria-label":`Where ${v.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.length===0?"Not clickable":w.map(h).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:w=>d(p,x=>{const m=w.target.value;x.to=Array.isArray(m)?m:String(m).split(",").filter(Boolean)}),children:c.map(w=>y.jsxs(k.MenuItem,{value:w,children:[y.jsx(k.Checkbox,{size:"small",checked:v.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:v.given,disabled:v.to.length===0,inputProps:{"aria-label":`Control ${v.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:v.given===""?`Named ${v.name}, like the dimension`:void 0,onChange:w=>d(p,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))]})]},v.name))})})}const Dd=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function Lp({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,d]=S.useState({kind:"new"}),[c,h]=S.useState(""),[f,v]=S.useState("select"),[p,w]=S.useState(""),[x,m]=S.useState(""),[g,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){d({kind:"existing",name:n.name}),h(n.label??"");const T=gp(t,n);b(T);const A=T.filter(E=>E.include),q=new Set(A.map(E=>E.field));m(q.size===1?A[0].field:n.field??""),$(q.size>1)}else d({kind:"new"}),h(""),v("select"),m(""),w(new Date().toISOString().slice(0,10)),b(t.tiles.map(T=>({include:qs(T),field:""}))),$(!1)},[e,n,t]);const C=S.useMemo(()=>[...(t.localGivens??[]).map(T=>T.name),...r.map(T=>T.name)],[t,r]),I=S.useMemo(()=>x.trim()?pp(x.trim(),C):"",[x,C]),P=u.kind==="existing"?n??r.find(T=>T.name===u.name):I?{name:I,type:Br({name:I,label:c,kind:f,field:x}).type}:void 0,U=P?.type!==void 0&&!P.type.startsWith("filter<"),W=g.find(T=>T.include)?.op??$i(P?.type),M=(T,A)=>b(q=>q.map((E,D)=>D===T?{...E,...A}:E)),z=T=>b(A=>A.map(q=>({...q,op:T}))),V=T=>{const A=$i(T);b(q=>q.map(({op:E,...D})=>A?{...D,op:A}:D))},ee=T=>{d({kind:"existing",name:T.name}),m(T.field??""),V(T.type)},Se=T=>{v(T),V(Br({name:"X",label:c,kind:T,field:x}).type)},oe=t.tiles.map(qs),Le=oe.filter(Boolean).length,Ve=g.filter((T,A)=>T.include&&oe[A]).length,Ce=t.tiles.filter((T,A)=>(g[A]?.include??!1)&&oe[A]),Ye=Ce.length>0?Ce:t.tiles.filter((T,A)=>oe[A]),Ge=S.useMemo(()=>{const T=new Map;let A=!1;for(const q of Ye){const E=i?.(q);if(E){A=!0;for(const D of E)T.has(D.name)||T.set(D.name,D)}}return A?[...T.values()]:void 0},[g,t.tiles,i]),We=(()=>{const T=x.trim();for(const A of Ce){const q=i?.(A);if(!q||q.some(E=>E.name===T))return O(A)}return Ce[0]?O(Ce[0]):t.sources[0]?.base})(),Xe=T=>b(A=>A.map((q,E)=>({...q,include:T&&oe[E]}))),$e=S.useMemo(()=>_?g:g.map(T=>({...T,field:x})),[_,g,x]),fe=T=>{for(const A of Ye){const q=i?.(A)?.find(E=>E.name===T.trim());if(q?.type)return q.type}},L=T=>ai(P?.type,T.type),G=(T,A)=>{if(T.trim()==="")return"Pick the field this filter compares.";const q=A?i?.(A):void 0;if(!q)return;const E=q.find(D=>D.name===T.trim());if(!E)return`Not a field of ${A?O(A):"the tiles' source"}.`;if(E.type&&!ai(P?.type,E.type))return`${T.trim()} is ${Ma(E.type)}; this filter compares ${Ma(P?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},_e=T=>{if(m(T),l||u.kind!=="new")return;const A=fe(T),q=Br({name:"X",label:c,kind:f,field:T}).type;A&&!ai(q,A)&&Se(fp(A))},X=$e.map((T,A)=>T.include&&oe[A]?G(T.field,t.tiles[A]):void 0),ze=X.every(T=>T===void 0),ne=!_&&Ve>0?Ce.map(T=>G(x,T)).find(Boolean):void 0,at=P!==void 0&&ze&&(u.kind==="existing"||x.trim()!==""&&I!==""),Fe=()=>{if(!(!P||!at))if(u.kind==="new")s(P.name,$e,Br({name:P.name,label:c.trim()||Dd(P.name),kind:f,field:x.trim(),...We?{source:We}:{},...p?{dateDefault:p}:{}}));else if(n?.origin==="dashboard"&&n.local){const T=c.trim(),A=T!==(n.local.label??"");s(P.name,$e,A?{...n.local,...T?{label:T}:{}}:void 0)}else s(P.name,$e)},xt=l&&a.origin==="model";return{editing:l,shown:a,fromModel:xt,source:u,setSource:d,label:c,setLabel:h,kind:f,dateDefault:p,setDateDefault:w,field:x,rows:g,setRows:b,perTile:_,setPerTile:$,newName:I,target:P,valueTyped:U,commonOp:W,setRow:M,setCommonOp:z,pickExisting:ee,pickKind:Se,bindable:oe,bindableCount:Le,included:Ve,commonFields:Ge,setAll:Xe,accepts:L,pickField:_e,rowProblems:X,commonProblem:ne,canApply:at,apply:Fe}}function La({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:l,autoFocus:u,placeholder:d,sx:c}){const h=S.useMemo(()=>(n??[]).filter(v=>r?.(v)??!0).map(v=>v.name),[n,r]),f=S.useMemo(()=>new Map((n??[]).map(v=>[v.name,v.type])),[n]);return y.jsx(k.Autocomplete,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(v,p)=>t(p),value:e,onChange:(v,p)=>t(typeof p=="string"?p:""),disabled:l,disableClearable:!0,renderOption:(v,p)=>S.createElement("li",{...v,key:p},y.jsx(k.Typography,{variant:"body2",sx:{flex:1},children:p}),f.get(p)&&y.jsx(k.Typography,{variant:"caption",sx:{opacity:.6},children:f.get(p)?.replace(/_type$/,"")})),renderInput:v=>y.jsx(k.TextField,{...v,label:i,placeholder:d,autoFocus:u,error:o,helperText:a,inputProps:{...v.inputProps,"aria-label":s}}),sx:c})}const Wa=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 Wp({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:l}=Be.usePublisherTheme(),{editing:u,shown:d,fromModel:c,source:h,setSource:f,label:v,setLabel:p,kind:w,dateDefault:x,setDateDefault:m,field:g,rows:b,setRows:_,perTile:$,setPerTile:O,newName:C,target:I,valueTyped:P,commonOp:U,setRow:W,setCommonOp:M,pickExisting:z,pickKind:V,bindable:ee,bindableCount:Se,included:oe,commonFields:Le,setAll:Ve,accepts:Ce,pickField:Ye,rowProblems:Ge,commonProblem:We,canApply:Xe,apply:$e}=Lp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),fe=(L,G,_e)=>y.jsx(k.TextField,{select:!0,size:"small",label:"Compares",value:L??">=",onChange:X=>G(X.target.value),inputProps:{"aria-label":_e},sx:{width:130},children:hp.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?d.label??d.name:"Add a filter",description:u?y.jsxs(y.Fragment,{children:[y.jsxs(k.Box,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",d.name]}),c?" · 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(d.name),"aria-label":`Remove control ${d.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Tooltip,{title:Xe||I===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,G)=>{G==="new"?f({kind:"new"}):G==="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 G=r.find(_e=>_e.name===L.target.value);G&&z(G)},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(La,{value:g,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&&C?`Declared as $${C}`:void 0),sx:{flex:1,minWidth:200}}),!c&&y.jsx(k.TextField,{size:"small",label:"Label",placeholder:C?Dd(C):"",value:v,onChange:L=>p(L.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),P&&!$&&fe(U,M,"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=>V(L.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:L=>Ia.find(G=>G.kind===L)?.label??String(L)}},sx:{flex:1},children:Ia.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(G=>({...G,field:g}))),O(L=>!L)},children:$?"Same field for all":"Adjust per tile"})]}),y.jsx(k.Stack,{sx:{gap:$?1:0},children:t.tiles.map((L,G)=>{const _e=b[G],X=L.label??L.name,ze=$?Ge[G]:void 0;return y.jsxs(k.Stack,{direction:"row",sx:{gap:1,alignItems:$?"flex-start":"center",opacity:ee[G]?1:.6},children:[y.jsx(k.Checkbox,{size:"small",disabled:!ee[G],checked:(_e?.include??!1)&&ee[G],inputProps:{"aria-label":`Filter ${X}`},onChange:ne=>W(G,{include:ne.target.checked})}),y.jsx(k.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:$?1:0},noWrap:!0,children:X}),ee[G]?$&&y.jsxs(y.Fragment,{children:[P&&fe(_e?.op,ne=>W(G,{op:ne}),`Comparison for ${X}`),y.jsx(La,{value:_e?.field??"",onChange:ne=>W(G,{field:ne}),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:Wa(t.tiles[G]).reason,children:y.jsx(k.Typography,{variant:"caption",sx:{color:l.tileTitle},children:Wa(t.tiles[G]).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 Cd(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(d=>{if(d===void 0)return d;const c=structuredClone(d);return u(c),c}),close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const zp=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}}),ss=[2,3,4,6,8,12,16,24];function Fp({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=Be.usePublisherTheme(),{draft:s,patch:o,close:a}=Cd(t,e!==null,r,n),l=s?.columns!==void 0&&!ss.includes(s.columns)?[...ss,s.columns].sort((u,d)=>u-d):ss;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(d=>{d.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(d=>{const c=u.target.value;c.trim()===""?delete d.description:d.description=c})}),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(d=>{const c=Number(u.target.value);c?d.columns=c:delete d.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(d=>{u.target.checked?delete d.autorun:d.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 Np=j.createSvgIcon(y.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function Bp({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(Np,{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 Vp=(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}),Gp=(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},Pd=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),Md=e=>`gap.${e}`,Up=(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(Pd(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 qp=Object.create,Id=Object.defineProperty,Hp=Object.defineProperties,Kp=Object.getOwnPropertyDescriptor,Yp=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,jd=Object.prototype.hasOwnProperty,Ad=Object.prototype.propertyIsEnumerable,Xp=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ir=e=>{throw TypeError(e)},Ks=(e,t,n)=>t in e?Id(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,os=(e,t)=>{for(var n in t||(t={}))jd.call(t,n)&&Ks(e,n,t[n]);if(Ei)for(var n of Ei(t))Ad.call(t,n)&&Ks(e,n,t[n]);return e},as=(e,t)=>Hp(e,Yp(t)),Qp=(e,t)=>{var n={};for(var r in e)jd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ei)for(var r of Ei(e))t.indexOf(r)<0&&Ad.call(e,r)&&(n[r]=e[r]);return n},Zp=e=>{var t;return[,,,qp((t=void 0)!=null?t:null)]},Rd=["class","method","getter","setter","accessor","field","value","get","set"],ir=e=>e!==void 0&&typeof e!="function"?Ir("Function expected"):e,Jp=(e,t,n,r,i)=>({kind:Rd[e],name:t,metadata:r,addInitializer:s=>n._?Ir("Already initialized"):i.push(ir(s||null))}),eg=(e,t)=>Ks(t,Xp("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},Ld=(e,t,n,r,i,s)=>{for(var o,a,l,u,d,c=t&7,h=!1,f=!1,v=e.length+1,p=Rd[c+5],w=e[v-1]=[],x=e[v]||(e[v]=[]),m=(i=i.prototype,Kp({get[n](){return sr(this,s)},set[n](b){return Ft(this,s,b)}},n)),g=r.length-1;g>=0;g--)u=Jp(c,n,l={},e[3],x),u.static=h,u.private=f,d=u.access={has:b=>n in b},d.get=b=>b[n],d.set=(b,_)=>b[n]=_,a=(0,r[g])({get:m.get,set:m.set},u),l._=1,a===void 0?ir(a)&&(m[p]=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&&Id(i,n,m),i},Wd=(e,t,n)=>t.has(e)||Ir("Cannot "+n),sr=(e,t,n)=>(Wd(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)=>(Wd(e,t,"write to private field"),t.set(e,n),n);function Bt(e){return e instanceof ta||e instanceof Bd}var Ur=10,tg=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 d=ng(u),{source:c,target:h}=s,{center:f}=s.shape.current,v=[],p=[];ue(()=>{for(const _ of l.droppables){const{id:$}=_;if(!_.accepts(c)||$===h?.id&&Bt(_)||!_.element)continue;let O=_.shape;const C=new ct(_.element,{getBoundingClientRect:I=>mr(I,void 0,.2)});!C.height||!C.width||(d=="down"&&f.y+Ur<C.center.y||d=="up"&&f.y-Ur>C.center.y||d=="left"&&f.x-Ur>C.center.x||d=="right"&&f.x+Ur<C.center.x)&&(v.push(_),_.shape=C,p.push(()=>_.shape=O))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(v,Gf);ue(()=>p.forEach(_=>_()));const[x]=w;if(!x)return;const{id:m}=x,{index:g,group:b}=c.sortable;o.setDropTarget(m).then(()=>{const{source:_,target:$,shape:O}=s;if(!_||!Bt(_)||!O)return;const{index:C,group:I,target:P}=_.sortable,U=g!==C||b!==I,W=U?P:$?.element;if(!W)return;Mc(W);const M=new ct(W);if(!M)return;const z=dt.delta(M,dt.from(O.current.boundingRectangle),_.alignment);o.move({by:z}),U?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function ng(e){const{x:t,y:n}=e;if(t>0)return"right";if(t<0)return"left";if(n>0)return"down";if(n<0)return"up"}var rg=Object.defineProperty,ig=Object.defineProperties,sg=Object.getOwnPropertyDescriptors,za=Object.getOwnPropertySymbols,og=Object.prototype.hasOwnProperty,ag=Object.prototype.propertyIsEnumerable,Fa=(e,t,n)=>t in e?rg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))og.call(t,n)&&Fa(e,n,t[n]);if(za)for(var n of za(t))ag.call(t,n)&&Fa(e,n,t[n]);return e},rn=(e,t)=>ig(e,sg(t));function lg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function qr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function ls(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function cg(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=(g,b)=>g===b||g!==null&&typeof g=="object"&&"id"in g&&g.id===b;if(Array.isArray(e)){const g=e.findIndex(_=>l(_,s.id)),b=e.findIndex(_=>l(_,o.id));if(g===-1||b===-1){if(ls(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(_!==g)return n(e,g,_)}return n(e,g,b)}const u=Object.entries(e);let d=-1,c,h=-1,f;for(const[g,b]of u)if(d===-1&&(d=b.findIndex(_=>l(_,s.id)),d!==-1&&(c=g)),h===-1&&(h=b.findIndex(_=>l(_,o.id)),h!==-1&&(f=g)),d!==-1&&h!==-1)break;if(d===-1&&ls(s)){const g=s.initialGroup==null?void 0:qr(e,s.initialGroup),b=s.initialIndex,_=s.group==null?void 0:qr(e,s.group),$=s.index;if(g==null||_==null||g===_&&b===$)return"preventDefault"in t&&t.preventDefault(),e;if(g===_)return rn(nn({},e),{[g]:n(e[g],b,$)});const O=e[g][b];return rn(nn({},e),{[g]:[...e[g].slice(0,b),...e[g].slice(b+1)],[_]:[...e[_].slice(0,$),O,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:v}=s.manager,p=(i=(r=v.shape)==null?void 0:r.current.center)!=null?i:v.position.current;if(f==null){const g=qr(e,o.id);if(g!=null){const b=o.shape&&p.y>o.shape.center.y?e[g].length:0;f=g,h=b}}if(c==null||f==null||c===f&&d===h){if(c!=null&&c===f&&d===h&&ls(s)){const g=s.group==null?void 0:qr(e,s.group),b=s.group!=null&&g!==c,_=s.index!==d;if(b||_){const $=s.group==null?c:g;if($!=null){if(c===$)return rn(nn({},e),{[c]:n(e[c],d,s.index)});const O=e[c][d];return rn(nn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[$]:[...e[$].slice(0,s.index),O,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===f)return rn(nn({},e),{[c]:n(e[c],d,h)});const x=o.shape&&Math.round(p.y)>Math.round(o.shape.center.y)?1:0,m=e[c][d];return rn(nn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[f]:[...e[f].slice(0,h+x),m,...e[f].slice(h+x)]})}function dg(e,t){return cg(e,t,lg)}function Na(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Ba(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 Va="__default__",ug=class extends Me{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof ta){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=Na(l),d=o.sortable.group===a.sortable.group,c=l.get(o.sortable.group),h=d?c:l.get(a.sortable.group);!c||!h||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var f,v;const p=t();if(Ba(u,l,p))return;const w=o.sortable.element,x=a.sortable.element;if(!x||!w||!d&&a.id===o.sortable.group)return;const m=Hr(c),g=d?m:Hr(h),b=(f=o.sortable.group)!=null?f:Va,_=(v=a.sortable.group)!=null?v:Va,$={[b]:m,[_]:g},O=dg($,r);if($===O)return;const C=O[_].indexOf(o.sortable),I=O[_].indexOf(a.sortable);i.collisionObserver.disable(),Ga(w,C,x,I),ue(()=>{for(const[P,U]of O[b].entries())U.index=P;if(!d)for(const[P,U]of O[_].entries())U.group=a.sortable.group,U.index=P}),i.actions.setDropTarget(o.id).then(()=>i.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(r,i)=>{if(!r.canceled)return;const{dragOperation:s}=i,{source:o}=s;Bt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=Na(a),u=a.get(o.sortable.initialGroup);u&&i.renderer.rendering.then(()=>{const d=t();if(Ba(l,a,d))return;const c=Hr(u),h=Hr(u,hg),f=o.sortable.element,v=h.indexOf(o.sortable),p=c[v],w=p?.element;!p||!w||!f||(Ga(f,p.index,w,o.index),ue(()=>{for(const x of a.values()){const m=Array.from(x).values();for(const g of m)g.index=g.initialIndex,g.group=g.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function Ga(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function fg(e,t){return e.index-t.index}function hg(e,t){return e.initialIndex-t.initialIndex}function Hr(e,t=fg){return Array.from(e).sort(t)}var Ua=[tg,ug],zd={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function qa(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 Eu,Fd,Nd,Ot,Jo,or,ar,ea,hn;Nd=[K],Fd=[K];var Bi=class{constructor(e,t){Un(this,Jo,Gr(Ot,8,this)),Gr(Ot,11,this),Un(this,or),Un(this,ar),Un(this,ea,Gr(Ot,12,this)),Gr(Ot,15,this),Un(this,hn),this.register=()=>(ue(()=>{var v,p;(v=this.manager)==null||v.registry.register(this.droppable),(p=this.manager)==null||p.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{ue(()=>{var v,p;(v=this.manager)==null||v.registry.unregister(this.droppable),(p=this.manager)==null||p.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=zd,plugins:d}=n,c=Qp(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const h=st(d,Ua),f=qa(i);this.droppable=new ta(as(os({},c),{disabled:f.droppable}),t,this),this.draggable=new Bd(as(os({},c),{disabled:f.draggable,plugins:h,effects:()=>[()=>{var v,p,w;const x=(v=this.manager)==null?void 0:v.dragOperation.status;x?.initializing&&this.id===((w=(p=this.manager)==null?void 0:p.dragOperation.source)==null?void 0:w.id)&&Kr.clear(this.manager),x?.dragging&&Kr.set(this.manager,this.id,H(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:v,group:p,manager:w}=this,x=sr(this,ar),m=sr(this,or);(v!==x||p!==m)&&(Ft(this,ar,v),Ft(this,or,p),this.animate())},()=>{var v,p;const{target:w}=this,{isDragSource:x}=this.draggable;((p=(v=this.draggable.pluginConfig(Go))==null?void 0:v.feedback)!=null?p:"default")==="move"&&x&&(this.droppable.disabled=!w)},...r()],type:l,sensors:a}),t,this),Ft(this,hn,c.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(){H(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:r}=e.dragOperation.status;!n||!t||r&&!t.idle||e.renderer.rendering.then(()=>{const{element:i}=this;if(!i)return;for(const d of i.getAnimations())"transitionProperty"in d&&(d.transitionProperty==="transform"||d.transitionProperty==="translate"||d.transitionProperty==="scale")&&d.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=_a(i,a,!1),u=_a(i,a);if(o.x||o.y){const d=Ro(Ke(i))?as(os({},t),{duration:0}):t;Ic({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:d}).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=Os.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,Ua)}set disabled(e){const t=qa(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??jc}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=Zp();Jo=new WeakMap;or=new WeakMap;ar=new WeakMap;ea=new WeakMap;hn=new WeakMap;Ld(Ot,4,"index",Nd,Bi,Jo);Ld(Ot,4,"group",Fd,Bi,ea);eg(Ot,Bi);var Bd=class extends zi{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}},ta=class extends Fi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},pg=Object.defineProperty,gg=Object.defineProperties,vg=Object.getOwnPropertyDescriptors,Ha=Object.getOwnPropertySymbols,mg=Object.prototype.hasOwnProperty,yg=Object.prototype.propertyIsEnumerable,Ka=(e,t,n)=>t in e?pg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cs=(e,t)=>{for(var n in t||(t={}))mg.call(t,n)&&Ka(e,n,t[n]);if(Ha)for(var n of Ha(t))yg.call(t,n)&&Ka(e,n,t[n]);return e},bg=(e,t)=>gg(e,vg(t));function xg(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:i,data:s,element:o,handle:a,index:l,group:u,disabled:d,modifiers:c,sensors:h,target:f,type:v,plugins:p}=e,w=cs(cs({},zd),e.transition),x=vd(g=>new Bi(bg(cs({},e),{transition:w,register:!1,handle:yn(a),element:yn(o),target:yn(f)}),g)),m=fd(x,wg);return le(i,()=>x.id=i),Ln(()=>{ue(()=>{x.group=u,x.index=l})},[x,u,l]),le(v,()=>x.type=v),le(t,()=>x.accept=t,void 0,rt),le(s,()=>s&&(x.data=s)),le(l,()=>{var g;(g=x.manager)!=null&&g.dragOperation.status.idle&&w?.idle&&x.refreshShape()},Wh),si(a,g=>x.handle=g),si(o,g=>x.element=g),si(f,g=>x.target=g),le(d,()=>x.disabled=d??!1,void 0,rt),le(h,()=>x.sensors=h,void 0,rt),le(n,()=>x.collisionDetector=n),le(r,()=>x.collisionPriority=r),le(p,()=>x.plugins=p,void 0,rt),le(w,()=>x.transition=w,void 0,rt),le(c,()=>x.modifiers=c,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(g=>{x.handle=g??void 0},[x]),ref:S.useCallback(g=>{var b,_;!g&&((b=x.element)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.element=g??void 0)},[x]),sourceRef:S.useCallback(g=>{var b,_;!g&&((b=x.source)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.source=g??void 0)},[x]),targetRef:S.useCallback(g=>{var b,_;!g&&((b=x.target)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.target=g??void 0)},[x])}}function wg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Ys="tile",Vd="gap",_g='[role="separator"]',kg=[Ns.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(Ns.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(_g)!==null}),id],Sg=e=>[...e,Go.configure({feedback:"clone"})];function $g({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=xg({id:e,index:t,type:Ys,accept:Ys,collisionDetector:Wo,plugins:Sg});return y.jsx(y.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function Eg({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=cp({id:e,type:Vd,accept:Ys,collisionDetector:Wo,data:{after:t}});return y.jsx(y.Fragment,{children:n({ref:r,isDropTarget:i})})}const Og=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"})),Tg=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 Dg({tile:e,index:t,selected:n,menuOpen:r,resizeSpan:i,columns:s,onSelect:o,onOpenMenu:a,onResizeStart:l,onResizeMove:u,onResizeEnd:d,children:c}){const{theme:h}=Be.usePublisherTheme();return y.jsx($g,{id:pt(e),index:t,children:({ref:f,handleRef:v,isDragSource:p})=>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:[c,y.jsx(k.Box,{ref:v,className:"builder-affordance","aria-label":`Move ${e.label??e.name}`,sx:{position:"absolute",top:"2px",left:"2px",display:"grid",placeItems:"center",width:"22px",height:"22px",borderRadius:"4px",cursor:"grab",touchAction:"none",zIndex:2,color:h.tileTitle,bgcolor:h.tile,opacity:p||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(Og,{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(Tg,{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:d,onPointerCancel:d,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 Cg({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 Pg({after:e}){const{theme:t}=Be.usePublisherTheme();return y.jsx(Eg,{id:Md(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 Mg({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 Ig=Object.defineProperty,jg=Object.defineProperties,Ag=Object.getOwnPropertyDescriptors,Ya=Object.getOwnPropertySymbols,Rg=Object.prototype.hasOwnProperty,Lg=Object.prototype.propertyIsEnumerable,Xa=(e,t,n)=>t in e?Ig(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))Rg.call(t,n)&&Xa(e,n,t[n]);if(Ya)for(var n of Ya(t))Lg.call(t,n)&&Xa(e,n,t[n]);return e},on=(e,t)=>jg(e,Ag(t));function Wg(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 ds(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function zg(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=(g,b)=>g===b||g!==null&&typeof g=="object"&&"id"in g&&g.id===b;if(Array.isArray(e)){const g=e.findIndex(_=>l(_,s.id)),b=e.findIndex(_=>l(_,o.id));if(g===-1||b===-1){if(ds(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(_!==g)return n(e,g,_)}return n(e,g,b)}const u=Object.entries(e);let d=-1,c,h=-1,f;for(const[g,b]of u)if(d===-1&&(d=b.findIndex(_=>l(_,s.id)),d!==-1&&(c=g)),h===-1&&(h=b.findIndex(_=>l(_,o.id)),h!==-1&&(f=g)),d!==-1&&h!==-1)break;if(d===-1&&ds(s)){const g=s.initialGroup==null?void 0:Yr(e,s.initialGroup),b=s.initialIndex,_=s.group==null?void 0:Yr(e,s.group),$=s.index;if(g==null||_==null||g===_&&b===$)return"preventDefault"in t&&t.preventDefault(),e;if(g===_)return on(sn({},e),{[g]:n(e[g],b,$)});const O=e[g][b];return on(sn({},e),{[g]:[...e[g].slice(0,b),...e[g].slice(b+1)],[_]:[...e[_].slice(0,$),O,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:v}=s.manager,p=(i=(r=v.shape)==null?void 0:r.current.center)!=null?i:v.position.current;if(f==null){const g=Yr(e,o.id);if(g!=null){const b=o.shape&&p.y>o.shape.center.y?e[g].length:0;f=g,h=b}}if(c==null||f==null||c===f&&d===h){if(c!=null&&c===f&&d===h&&ds(s)){const g=s.group==null?void 0:Yr(e,s.group),b=s.group!=null&&g!==c,_=s.index!==d;if(b||_){const $=s.group==null?c:g;if($!=null){if(c===$)return on(sn({},e),{[c]:n(e[c],d,s.index)});const O=e[c][d];return on(sn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[$]:[...e[$].slice(0,s.index),O,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===f)return on(sn({},e),{[c]:n(e[c],d,h)});const x=o.shape&&Math.round(p.y)>Math.round(o.shape.center.y)?1:0,m=e[c][d];return on(sn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[f]:[...e[f].slice(0,h+x),m,...e[f].slice(h+x)]})}function Fg(e,t){return zg(e,t,Wg)}function Ng({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:c=>{const{source:h,target:f}=c.operation;if(!h||!f)return;const v=s.current??e;let p;if(f.type===Vd){const{after:w}=f.data,x=v.findIndex(b=>pt(b)===h.id);if(x<0||w===h.id)return;const g=v.filter((b,_)=>_!==x).findIndex(b=>pt(b)===w)+1;p=Gp(v,x,g)}else{const w=v.map(pt),x=Fg(w,c);if(x.every((g,b)=>g===w[b]))return;const m=new Map(v.map(g=>[pt(g),g]));p=Vp(x.map(g=>m.get(g)),e.map(g=>g.break??!1))}s.current=p,i(p)},onDragEnd:c=>{a(!1);const h=s.current;if(s.current=void 0,i(void 0),c.canceled||!h)return;t(h);const f=h.findIndex(v=>pt(v)===c.operation.source?.id);f>=0&&n(f)}}}const Qa=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function Bg({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:(d,c)=>{const h=o.current?.getBoundingClientRect(),f=d.currentTarget.parentElement?.getBoundingClientRect();!h||!f||(d.stopPropagation(),d.preventDefault(),d.currentTarget.setPointerCapture(d.pointerId),Qa(!0),n(c),s({index:c,span:e[c]?.colspan??1,left:f.left,track:(h.width-j.GRID_GAP_PX*(t-1))/t}))},onResize:d=>{if(!i)return;const c=d.clientX-i.left,h=Math.round((c+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:d=>{if(d.currentTarget.hasPointerCapture(d.pointerId)&&d.currentTarget.releasePointerCapture(d.pointerId),Qa(!1),!i)return;const{index:c,span:h}=i;s(void 0),r(c,h)}}}function Vg({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,columns:s,onDrills:o}){const{theme:a}=Be.usePublisherTheme(),{draft:l,patch:u,close:d,discard:c}=Cd(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:d,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(v=>{const p=f.target.value;p===""?delete v.label:v.label=p})}),y.jsx(k.TextField,{size:"small",label:"Subtitle",value:l.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:f=>u(v=>{const p=f.target.value;p===""?delete v.subtitle:v.subtitle=p})}),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,v])=>{const p=Math.max(1,Math.round(s/v)),w=(l.colspan??1)===p;return y.jsx(k.Button,{size:"small",variant:w?"contained":"outlined","aria-label":`Width ${f}`,"aria-pressed":w,onClick:()=>u(x=>{x.colspan=p}),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:()=>{d(),o()},children:"Clickable cells…"}):y.jsx("span",{}),y.jsx(k.Button,{color:"error",size:"small",onClick:()=>{c(),i()},children:"Remove tile"})]})]})})}const Gd=e=>e.ok===!1,me=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),Vi=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 Gg(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 Ug(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
70
|
+
`&&t.push(n+1);return t}class qg{constructor(t){this.text=t,this.map=Gg(t),this.lineStarts=Ug(t)}map;lineStarts;commentLines=new Set;proseLines=new Set;blocks=[];span(t){if(!Vi(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=[]){Vi(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)jr(e.getChild(r),t,n);return n}const Hg=e=>me(e,"OCURLY","CCURLY");function Sr(e,t){const n=[],r=i=>{if(Vi(i)){if(t(i)){n.push(i);return}if(!Hg(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 Kg(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 Ud(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:Kg(e,s)})}return{...n,clauses:i}}function Xs(e,t){const n=e.span(t);if(!n)return;const r=[],i=[];for(const u of Sr(t,de.queryStatement)){const d=e.positioned(u);d&&r.push(d);const c=ye(u,"whereStatement");if(c&&de.whereStatement(c)){const h=Ud(e,c);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 na(e,t,n){const r=[],i=e.line(t.start),s=e.line(n);for(let o=i;o<s;o++){if(e.commentLines.has(o)||e.proseLines.has(o))continue;const a=e.text.slice(e.lineStarts[o],e.lineStarts[o+1]??e.text.length).trim();a.startsWith("#")&&!a.startsWith("##")&&r.push({line:o,text:a})}return r}function Yg(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&&Xs(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),d=ye(o,"queryProperties"),c=d&&Xs(e,d);return c?{kind:"reference",from:u,fromSpan:l,refinement:c}:{kind:"reference",from:u,fromSpan:l}}return{kind:"unsupported",why:"a parenthesized expression"}}function Xg(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),d=ye(l,"exploreQueryNameDef"),c=e.text_(d),h=ye(l,"vExpr");!u||!c||!h||n.push({name:c,span:u,line:e.line(u.start),statement:i,tags:na(e,i,a?.start??u.start),siblings:o.length,body:Yg(e,h)})}}return n}function Qg(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(),d=e.text_(ye(a,"fieldExpr"))?.trim();!l||!u||d===void 0||n.push({name:u,expression:d,span:l,line:e.line(l.start),statement:i,tags:na(e,i,o?.start??l.start)})}}return n}function Zg(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(),d=Sr(o,de.exploreProperties)[0],c=d&&Xs(e,d),h={start:e.lineStarts[e.line(i.start)],end:i.end},f=[];if(d)for(const v of Sr(d,de.whereStatement)){const p=Ud(e,v);p&&f.push(p)}n.push({name:s,base:u,span:i,line:e.line(i.start),statement:h,...c?{properties:c}:{},views:d?Xg(e,d):[],dimensions:d?Qg(e,d):[],wheres:f})}return n}function Jg(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")),d=u&&e.text.slice(u.start,u.end);if(!l||!u||!d)continue;const c={start:u.start,end:l.end},h=e.line(c.start);n.push({name:d,declaration:e.text.slice(c.start,c.end),span:c,line:h,statement:{start:e.lineStarts[h],end:c.end},tags:na(e,l,c.start),...o!==void 0&&o!==h?{blockHeader:o}:{}})}}return n}function ev(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 qd(e){let t;try{t=await Hd(e,"file://dashboard-builder.malloy")}catch(h){return{ok:!1,reason:`Malloy could not read this file: ${h}`}}const n=t.problems.filter(h=>h.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||!Vi(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 qg(e),l=tv(a,s);a.commentLines=l.lines;const u=e.split(`
|
|
72
|
+
`),d=h=>l.lines.has(h);a.proseLines=j.markdownLines(u,d),a.blocks=j.blockSpans(u,d).filter(([h])=>!u[h].trimStart().startsWith("##"));const c=Zg(a,i);return c.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:ev(a,i),sources:c,givens:Jg(a,i),trailingComment:h=>l.trailing.get(h),comments:l.all,commentLine:h=>l.lines.has(h),proseLine:h=>a.proseLines.has(h),commentIn:h=>l.all.find(f=>f.start>=h.start&&f.start<h.end),blockStart:h=>nv(a,l.lines,h)}}}async function Hd(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 tv(e,t){const n=new Map,r=new Set,i=[],s=t.tokenSource?.vocabulary;for(const d of t.getTokens?.()??[]){const c=s?.getSymbolicName(d.type);if(c!=="COMMENT_TO_EOL"&&c!=="BLOCK_COMMENT")continue;const h=e.utf16(d.startIndex);let f=e.utf16(d.stopIndex+1);if(!(h===void 0||f===void 0||f<h)){for(;f>h&&(e.text[f-1]===`
|
|
73
|
+
`||e.text[f-1]==="\r");)f--;i.push({start:h,end:f})}}const o=[...i].sort((d,c)=>d.start-c.start);let a="",l=0;for(const d of o)a+=e.text.slice(l,Math.max(l,d.start)),a+=e.text.slice(Math.max(l,d.start),Math.max(l,d.end)).replace(/[^\n\r]/g," "),l=Math.max(l,d.end);a+=e.text.slice(l);const u=d=>a.slice(e.lineStarts[d],e.lineStarts[d+1]??a.length);for(const d of i){const c=e.line(d.start),h=e.line(d.end-1);for(let p=c;p<=h;p++)u(p).trim()===""&&r.add(p);const f=a.slice(e.lineStarts[c],d.start).trim(),v=a.slice(d.end,e.lineStarts[h+1]??a.length).trim();f!==""&&v===""&&n.set(h,d)}return{trailing:n,lines:r,all:i}}function nv(e,t,n){const r=s=>e.text.slice(e.lineStarts[s],e.lineStarts[s+1]??e.text.length).trim();let i=n;for(let s=n-1;s>=0;s--){const o=r(s),a=e.blocks.find(([,l])=>l===s);if(a){i=s=a[0];continue}if(o===""&&!t.has(s))break;if(o.startsWith("#")||t.has(s))i=s;else break}return i}const Oi=e=>e.ok===!1;function Ar(e,t,n){const r=e.blockStart(n),i=[],s=[];for(let o=r;o<n;o++){if(e.commentLine(o))continue;if(e.proseLine(o)){s.push(o);continue}const a=t[o].trim();a.startsWith("#")&&!a.startsWith("##")&&i.push({line:o,text:a})}return{start:r,tags:i,prose:s}}const Qs=e=>e.map(t=>t.text);function rv(e){const t=[],n=j.blockLines(e);for(const[r,i]of e.entries()){if(n.has(r))continue;const s=i.trim(),o=j.markdownNote(s);s.startsWith("##")&&!s.startsWith('##"')&&!s.startsWith("##!")&&!(o?.level===2&&!o.block)&&t.push(s)}return{description:j.descriptionNotes(e).text,artifact:t}}function iv(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 sv(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(),...ov(n(Qs(Ar(e,t,i.line).tags)).tag)})}return r.length>0?r:void 0}function ov(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 Za(e,t){const n=e?.text(t)?.trim();if(n===void 0||!/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/.test(n))return;const r=Number(n);return Number.isInteger(r)&&r>=1?r:void 0}function av(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 Ti(e){const{parseAnnotation:t}=await import("@malloydata/malloy-tag"),n=e.split(`
|
|
74
|
+
`),r=await qd(e);if(Gd(r))return{ok:!1,reason:r.reason,...r.line?{line:r.line}:{}};const i=r.parsed,{description:s,artifact:o}=rv(n),a=o.find(b=>j.ARTIFACT_LINE.test(b));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"),d=av(a);if(d.length===0)return{ok:!1,reason:"The `## artifact` tag names no tiles, so there is nothing to lay out."};const c=i.imports.map(b=>b.names?{kind:"names",names:b.names,from:b.from}:{kind:"all",from:b.from}),h=[],f=[],v=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(Qs(Ar(i,n,$.line).tags)).tag?.tag("drill");if(!O)continue;const C=O.textArray("to")??[O.text("to")??""];f.push({source:b.name,name:$.name,expression:$.expression,to:C.filter(Boolean),...O.text("given")?{given:O.text("given")}:{}})}v.set(b.name,new Map(b.views.map($=>[$.name,$])))}const p=[];for(const b of d){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}=_,C=v.get($)?.get(O);if(C===void 0){p.push({name:O,source:$,declaration:{kind:"inherited"}});continue}const I=t(Qs(C.tags)).tag,P=C.body.kind==="reference"?{kind:"reference",from:C.body.from}:C.body.kind==="inline"?{kind:"inline"}:void 0;if(P===void 0){p.push({name:O,source:$,declaration:{kind:"opaque",why:C.body.kind==="unsupported"?C.body.why:"unreadable"},...I?.text("label")?{label:I.text("label")}:{},...I?.text("subtitle")?{subtitle:I.text("subtitle")}:{},...I?.numeric("colspan")!==void 0?{colspan:I.numeric("colspan")}:{},...I?.has("break")?{break:!0}:{},...I?.has("borderless")?{borderless:!0}:{}});continue}const U=iv(C.body.kind==="reference"?C.body.refinement:C.body.kind==="inline"?C.body.stage:void 0);p.push({name:O,source:$,declaration:P,...U?{filters:U}:{},...I?.text("label")?{label:I.text("label")}:{},...I?.text("subtitle")?{subtitle:I.text("subtitle")}:{},...I?.numeric("colspan")!==void 0?{colspan:I.numeric("colspan")}:{},...I?.has("break")?{break:!0}:{},...I?.has("borderless")?{borderless:!0}:{}})}const w=sv(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 g=l?.tag("dashboard")?.has("columns")?Za(l.tag("dashboard"),"columns"):u?.array("tiles")?Za(u,"dashboard_columns"):void 0;return{ok:!0,document:{title:u?.text("title")??"",...s?{description:s}:{},...g===void 0?{}:{columns:g},...u?.has("autorun")?{autorun:u.isTrue("autorun")}:{},imports:c,sources:h,...w?{localGivens:w}:{},...Object.keys(x).length>0?{startingGivens:x}:{},...f.length>0?{drills:f}:{},tiles:p}}}async function Ja(e){const{problems:t}=await Hd(e,"file://splice-check.malloy");return t.filter(n=>n.code==="syntax-error").map(n=>n.message??"").sort()}const Zs=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 lv(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
75
|
+
`&&t.push(n+1);return t}function cv(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 Kd(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 dv=new Set(["colspan","break","borderless","label","subtitle"]),uv=new Set(["label","description","control","suggest","range_min","range_max"]),fv=(e,t)=>be(e.imports)===be(t.imports);function el(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 tl=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function hv(e,t,n){const r=e.sources.find(i=>i.name===t)?.views.find(i=>i.name===n);return r?r.line:-1}function nl(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(n=>`"${n}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const Di=e=>`${e.source}.${e.name}`,$n=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Js=e=>be([e.name,e.source,e.declaration]),gt=Js,rl=e=>be(e.tiles.map(gt));function pv(e,t){const n=new Set(e.tiles.map(gt)),r=new Set(t.tiles.map(gt)),i=e.tiles.filter(c=>!r.has(gt(c))),s=t.tiles.filter(c=>!n.has(gt(c))),a=i.length>0||s.length>0||rl(e)!==rl(t);for(const c of s)if(c.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${c.name}\` is ${c.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const l=new Map(e.sources.map(c=>[c.name,c])),u=new Set(e.imports.flatMap(c=>c.kind==="names"?c.names:[]));for(const c of e.sources)u.add(c.base);const d=t.sources.filter(c=>!l.has(c.name));for(const c of e.sources){const h=t.sources.find(f=>f.name===c.name);if(!h||h.base!==c.base)return{ok:!1,reason:`The source \`${c.name}\` cannot be changed or removed here.`}}for(const c of d){if(!s.some(h=>h.source===c.name))return{ok:!1,reason:`A new source \`${c.name}\` needs a tile on it.`};if(!u.has(c.base))return{ok:!1,reason:`\`${c.base}\` is not imported by name in this file, so a tile cannot be put on it. The builder does not add imports: import { ${c.base} } from the model first.`}}return fv(e,t)?{currentKeys:n,nextKeys:r,removedTiles:i,addedTiles:s,newSources:d,currentSources:l,reordered:a}:{ok:!1,reason:"The dashboard's imports cannot be changed here."}}function gv(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."};if(j.hasNonQuotedTiles(t[l]))return{ok:!1,reason:"The `tiles=[…]` list holds an entry the builder does not model, such as a text tile, and rewriting the list would drop it. Reorder, add and remove tiles in the file's text."};const u=[...t[l].matchAll(/"([^"]+)"/g)].map(v=>v[1]),d=new Map;for(const v of u){const p=v.split("->").map(w=>w.trim());p.length===2&&d.set(`${p[0]}->${p[1]}`,v)}const c=r.tiles.map(v=>d.get(`${v.source}->${v.name}`)??(o.has(gt(v))&&!s.has(gt(v))?`${v.source} -> ${v.name}`:void 0));if(c.some(v=>v===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const h=`tiles=[${c.map(v=>`"${v}"`).join(", ")}]`,f=t[l].replace(/tiles\s*=\s*\[[\s\S]*?\]/,h);f!==t[l]&&a.push({...n(l),text:`${f}
|
|
76
|
+
`})}}function vv(e,t){let n=0,r=0;for(let i=0;i<e.length;i++){const s=e[i];if(s==='"')i=Ci(e,i);else if(s==="{"||s==="[")n++===0&&r++;else if(s==="}"||s==="]")n--;else if(r===1&&n===1&&e.startsWith(t,i)&&!/[A-Za-z0-9_]/.test(e[i-1]??" ")){const o=/^\s*=\s*/.exec(e.slice(i+t.length));if(!o)continue;const a=i+t.length+o[0].length,l=e[a]==='"'?Ci(e,a)+1:a+(/^[^\s}]*/.exec(e.slice(a))?.[0].length??0),u=i-(/\s*$/.exec(e.slice(0,i))?.[0].length??0);return e.slice(0,u)+e.slice(l)}}return e}function mv(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(r==='"')n=Ci(e,n);else if(r==="{"||r==="[")t++;else if(r==="}"||r==="]")t--;else if(t===0&&e.startsWith("dashboard",n)&&!/[A-Za-z0-9_]/.test(e[n-1]??" ")){const i=/^dashboard\s*\{/.exec(e.slice(n));if(!i)continue;let s=1,o=n+i[0].length;for(;o<e.length&&s>0;o++)e[o]==='"'?o=Ci(e,o):e[o]==="{"?s++:e[o]==="}"&&s--;const a=n-(/\s*$/.exec(e.slice(0,n))?.[0].length??0);return e.slice(0,a)+e.slice(o)}}return e}function Ci(e,t){for(let n=t+1;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==='"')return n;return e.length}function yv(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(p=>p.start===n(o).start&&p.end===n(o).end);let l=a?a.text.replace(/\n$/,""):t[o];const u=l.indexOf("artifact"),d=l.indexOf("{",u);let c=0,h=-1;for(let p=d;p<l.length;p++)if(l[p]==="{")c++;else if(l[p]==="}"&&--c===0){h=p;break}if(d<0||h<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let f=l.slice(d+1,h);const v=(p,w)=>{const x=new RegExp(`\\s*\\b${p}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);w===void 0?f=f.replace(x,""):x.test(f)?f=f.replace(x,` ${p}=${w}`):f=`${f.replace(/\s+$/,"")} ${p}=${w} `};if(r.title!==i.title&&v("title",i.title?$n(i.title):void 0),r.autorun!==i.autorun&&v("autorun",i.autorun===void 0?void 0:String(i.autorun)),be(r.startingGivens)!==be(i.startingGivens)){f=f.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const p=Object.entries(i.startingGivens??{});p.length>0&&(f=`${f.replace(/\s+$/,"")} givens { ${p.map(([w,x])=>`${w}=${$n(x)}`).join(" ")} }`)}f=f.replace(/\s{2,}/g," "),l=`${l.slice(0,d+1)}${f.startsWith(" ")?f:` ${f}`}${f.endsWith(" ")?"":" "}${l.slice(h)}`,r.columns!==i.columns&&(l=vv(l,"dashboard_columns"),l=mv(l),i.columns!==void 0&&(l=`${l.trimEnd()} dashboard { columns=${i.columns} }`)),a?a.text=`${l}
|
|
77
77
|
`:s.push({...n(o),text:`${l}
|
|
78
|
-
`})}if(r.description!==i.description){const
|
|
79
|
-
`).map(
|
|
80
|
-
`)
|
|
81
|
-
`})
|
|
82
|
-
`})}}}function
|
|
83
|
-
`).trim();o.push({start:n(w.line).start,end:n(
|
|
84
|
-
`:"")+`${
|
|
85
|
-
`})}for(const[f,
|
|
86
|
-
`:"")+`${
|
|
78
|
+
`})}if(r.description!==i.description){const{read:o,blankAbove:a,below:l,belowBlock:u,inBlock:d}=j.descriptionNotes(t);if(d||i.description===void 0&&u)return{ok:!1,reason:"The description is written in a `##|\"` block, which the builder cannot edit in place. Change it in the file's text."};const c=(i.description??"").split(`
|
|
79
|
+
`).map(p=>p.trim()===""?'##"':`##" ${p.trim()}`).join(`
|
|
80
|
+
`),h=o.length>0&&o[0]<j.artifactLine(t),f=i.description===void 0,v=h?[...o.slice(1),...f?l:[]]:[...o,...a];for(const p of v)s.push({...n(p),text:""});if(h)s.push({...n(o[0]),text:i.description===void 0?"":`${c}
|
|
81
|
+
`});else if(i.description!==void 0){const p=n(j.artifactLine(t)).start;s.push({start:p,end:p,text:`${c}
|
|
82
|
+
`})}}}function bv(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])),d=new Map(a.givens.map(f=>[f.name,f])),c=new Set;for(const[f,v]of l){const p=u.get(f);if(p!==void 0&&be(p)===be(v))continue;const w=d.get(f);if(w===void 0)return{ok:!1,reason:`Could not find where the given \`${f}\` is declared.`};const{tags:x,prose:m}=Ar(a,t,w.line),b=[...(p===void 0?x:x.filter(P=>{const U=li(P.text);return U!==void 0&&uv.has(U)})).map(P=>P.line),...p===void 0?m:[]];for(const P of b)o.push({...n(P),text:""}),c.add(P);const _=qt(a,w.span.end-1);if(p===void 0){o.push({start:n(w.line).start,end:n(_).end,text:""});for(let V=w.line;V<=_;V++)c.add(V);const P=Math.min(w.line,...b),U=w.blockHeader??P,W=(t[_+1]??"x").trim()==="",M=U===0||t[U-1].trim()==="",z=w.blockHeader===void 0||![...d.values()].some(V=>V.blockHeader===w.blockHeader&&V.line>w.line&&u.has([...d.entries()].find(([,ee])=>ee===V)?.[0]??""));W&&M&&z&&!c.has(_+1)&&(o.push({...n(_+1),text:""}),c.add(_+1));continue}const $=r(w.line),O=el(p),I=p.type!==v.type||p.default!==v.default?w.blockHeader===void 0?tl(p):`${p.name} :: ${p.type} is ${p.default}`:t.slice(w.line,_+1).join(`
|
|
83
|
+
`).trim();o.push({start:n(w.line).start,end:n(_).end,text:(O?`${$}${O}
|
|
84
|
+
`:"")+`${$}${I}
|
|
85
|
+
`})}for(const[f,v]of d){if(v.blockHeader===void 0||u.has(f))continue;![...d.values()].some(w=>w.blockHeader===v.blockHeader&&!c.has(w.line))&&!c.has(v.blockHeader)&&(o.push({...n(v.blockHeader),text:""}),c.add(v.blockHeader))}const h=[...u.values()].filter(f=>!l.has(f.name));if(h.length>0){const f=Math.max(-1,...[...d.values()].map(g=>g.line)),v=(()=>{let g=-1;for(let b=0;b<t.length;b++){const _=t[b].trim();(_.startsWith("import ")||g>=0&&/^}\s*from\s/.test(_))&&(g=b)}return g})(),p=f>=0?f:v,w=h.map(g=>{const b=el(g);return(b?`${b}
|
|
86
|
+
`:"")+`${tl(g)}
|
|
87
87
|
`}).join(`
|
|
88
|
-
`),x=
|
|
89
|
-
${w}`}),t.some(
|
|
90
|
-
`})}}function
|
|
91
|
-
`});else{const m=n(
|
|
92
|
-
`})}}}function
|
|
93
|
-
`)};let
|
|
94
|
-
`)+f.map(b=>
|
|
88
|
+
`),x=p>=0?n(p).end:n(0).end;o.push({start:x,end:x,text:`
|
|
89
|
+
${w}`}),t.some(g=>g.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
|
|
90
|
+
`})}}function xv(e){const{lines:t,wholeLine:n,indentOf:r,current:i,next:s,edits:o,parsed:a}=e,l=new Map((i.drills??[]).map(d=>[Di(d),d])),u=new Map((s.drills??[]).map(d=>[Di(d),d]));for(const d of new Set([...l.keys(),...u.keys()])){const c=l.get(d),h=u.get(d);if(c&&h&&be(c)===be(h))continue;const f=h??c;if(h&&h.to.length===0)return{ok:!1,reason:`The drill on \`${d}\` names no destination.`};const v=a.sources.find(m=>m.name===f.source)?.dimensions.find(m=>m.name===f.name);if(v===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:p}=Ar(a,t,v.line),w=p.find(m=>/^#\s*drill\b/.test(m.text)),x=r(v.line);if(h===void 0)w&&o.push({...n(w.line),text:""});else if(w)o.push({...n(w.line),text:`${x}${nl(h)}
|
|
91
|
+
`});else{const m=n(v.line).start;o.push({start:m,end:m,text:`${x}${nl(h)}
|
|
92
|
+
`})}}}function wv(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=Yd(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=qt(s,a.statement.start),u=qt(s,a.statement.end-1),d=s.trailingComment(u),c=d&&d.start>=a.statement.end?d.end:a.statement.end;if(s.text.slice(s.lineStarts[l],a.statement.start).trim()!==""||s.text.slice(c,n(u).end).trim()!==""){i.push({...Zd(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 _v(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 d=(h,f)=>{const v=h.declaration.kind==="reference"?h.declaration.from:h.name,p=(h.filters??[]).map(w=>`where: ${w.field} ${w.op??"~"} $${w.given}`).join(", ");return[...Kd(h).map(w=>`${f}${w}`),`${f}view: ${h.name} is ${v}${p?` + { ${p} }`:""}`].join(`
|
|
93
|
+
`)};let c=-1;for(const h of l.sources)c=Math.max(c,qt(l,h.span.end-1));for(const[h,f]of u)if(o.has(h)){const v=l.sources.find(b=>b.name===h);if(!v)return{ok:!1,reason:`Could not find where the source \`${h}\` is declared.`};if(!v.properties)return{ok:!1,reason:`\`${h}\` never opens an \`extend { … }\` block, so a new tile cannot be added inside it.`};const p=v.line,w=qt(l,v.properties.closeStart);let x=" ";for(let b=p+1;b<w;b++){const _=/^(\s+)view:/.exec(n[b]);if(_){x=_[1];break}}const m=r(w).start,g=(n[w-1]??"").trim()==="";a.push({start:m,end:m,text:(g?"":`
|
|
94
|
+
`)+f.map(b=>d(b,x)).join(`
|
|
95
95
|
|
|
96
96
|
`)+`
|
|
97
|
-
`})}else{const
|
|
98
|
-
source: ${
|
|
99
|
-
`+f.map(
|
|
97
|
+
`})}else{const v=s.find(g=>g.name===h);if(!v)return{ok:!1,reason:`The tile's source \`${h}\` is not declared.`};const p=`
|
|
98
|
+
source: ${v.name} is ${v.base} extend {
|
|
99
|
+
`+f.map(g=>d(g," ")).join(`
|
|
100
100
|
|
|
101
101
|
`)+`
|
|
102
102
|
}
|
|
103
|
-
`;let w=
|
|
103
|
+
`;let w=c;if(w<0)for(let g=0;g<n.length;g++){const b=n[g].trim();(/^(import\s|given:|}\s*from\s)/.test(b)||/^[A-Z_]+\s*::/.test(b))&&(w=g)}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+
|
|
106
|
-
`})}const m=
|
|
107
|
-
`).join("")})}if(be(
|
|
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
|
|
109
|
-
${n.indent}${ci(h)}`).join("");i.push({start:u,end:u,text:
|
|
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;
|
|
105
|
+
`:"";a.push({start:x,end:x,text:m+p}),c=w}}function kv(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(d=>[gt(d),d]));for(const d of o.tiles){const c=u.get(gt(d));if(c===void 0||be(c)===be(d))continue;if(d.declaration.kind==="inherited")return{ok:!1,reason:`\`${d.source} -> ${d.name}\` is declared on its source, not in this dashboard, so its presentation cannot be changed here.`};const h=hv(l,d.source,d.name);if(h<0)return{ok:!1,reason:`Could not find where \`${d.name}\` is declared inside \`${d.source}\`.`};const{tags:f}=Ar(l,t,h),v=i(h),p=Kd(d),w=new Map(p.map($=>[li($)??$,$])),x=new Set;for(const $ of f){const O=li($.text);if(O===void 0||!dv.has(O))continue;const C=w.get(O);if(C===void 0){a.push({...r($.line),text:""});continue}x.add(O),C!==$.text&&a.push({...r($.line),text:`${v}${C}
|
|
106
|
+
`})}const m=p.filter($=>!x.has(li($)??$));if(m.length>0){const $=n[h];a.push({start:$,end:$,text:m.map(O=>`${v}${O}
|
|
107
|
+
`).join("")})}if(be(c.filters)===be(d.filters))continue;const g=Yd(e,d);if(!g)return{ok:!1,reason:`Could not find \`${d.name}\`'s declaration to filter it.`};if(g.body.kind==="reference"){const $=Ev(e,d,g);if($)return $;continue}if(g.body.kind!=="inline")return{ok:!1,reason:`\`${d.name}\`'s body is ${g.body.why}, so there is no single first stage to write its filter into.`};const b=Xd(d.filters,g.body.stage);if(b)return Qd(d.name,b.given);const _=Jd(e,d,g.body.stage);if(_)return _}}const qt=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function Yd(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function Xd(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 Qd(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 il(e,t,n){return{ok:!1,reason:`Removing a filter from \`${e}\` would also remove the comment written beside it (\`${t.text.slice(n.start,n.end).trim()}\`), so nothing was written. Delete it in the file first.`}}function Sv(e,t,n){const r=e.commentIn(n);if(r)return r;const i=e.trailingComment(qt(e,t.end-1));return i&&i.start>=t.end&&e.text.slice(t.end,i.start).trim()===""?i:void 0}function $v(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 Zd(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 Jd(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((p,w)=>({clause:p,index:w})).filter(({clause:p})=>p.binding!==void 0);if(f.length===0)continue;const v=f.filter(({clause:p})=>s.has(p.binding.given));for(const{clause:p}of f)o.add(p.binding.given);if(v.length===0&&f.length===h.clauses.length){const p=Zd(r,h.span),w=Sv(r,h.span,p);if(w)return il(t.name,r,w);i.push({...p,text:""});continue}v.length>0&&(a=h.span);for(let p=f.length-1;p>=0;p--){const{clause:w,index:x}=f[p],m=s.get(w.binding.given);if(!m){const b=$v(h.clauses,x),_=r.commentIn(b);if(_)return il(t.name,r,_);i.push({...b,text:""});continue}const g=ci(m).replace(/^where:\s*/,"");g!==r.text.slice(w.span.start,w.span.end)&&i.push({...w.span,text:g})}}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(qt(r,u));h&&h.start>=u&&(u=h.end)}const d=a!==void 0&&!/,\s*$/.test(r.text.slice(0,u))?", ":" ",c=n.oneLine?`${d}${l.map(ci).join(", ")}`:l.map(h=>`
|
|
109
|
+
${n.indent}${ci(h)}`).join("");i.push({start:u,end:u,text:c})}function Ev(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:i,refinement:s}=n.body,o=Xd(t.filters,s);if(o)return Qd(t.name,o.given);const a=t.filters??[];if(!s){if(a.length===0)return;const d=` + { ${a.map(ci).join(", ")} }`;r.push({start:i.end,end:i.end,text:d});return}const l=s.wheres.some(d=>d.clauses.some(c=>!c.binding)),u=s.statements.some(d=>!s.wheres.some(c=>c.span.start===d.span.start));if(a.length===0&&!l&&!u){const d={start:i.end,end:s.span.end},c=e.parsed.commentIn(d);if(c)return{ok:!1,reason:`Removing the last filter from \`${t.name}\` would also remove the comment beside its refinement (\`${e.parsed.text.slice(c.start,c.end).trim()}\`), so nothing was written. Delete it in the file first, or edit the refinement there.`};r.push({...d,text:""});return}return Jd(e,t,s)}async function eo(e,t){const n=await Ti(e);if(Oi(n))return{ok:!1,reason:`Cannot edit a file that will not open: ${n.reason}`};const r=n.document,i=pv(r,t);if("reason"in i)return i;const s=await qd(e);if(Gd(s))return{ok:!1,reason:`Cannot edit a file that will not open: ${s.reason}`};const o=e.split(`
|
|
110
|
+
`),a=lv(e),l=p=>({start:a[p],end:p+1<a.length?a[p+1]:e.length}),u=p=>/^\s*/.exec(o[p])?.[0]??"",d=[],c={...i,sourceText:e,parsed:s.parsed,lines:o,starts:a,wholeLine:l,indentOf:u,current:r,next:t,edits:d};for(const p of[gv,yv,bv,xv,wv,_v,kv]){const w=p(c);if(w)return w}const h=p=>{const{drills:w,localGivens:x,...m}=p,g=p.tiles.map(b=>{if(b.filters?.length)return b;const{filters:_,...$}=b;return $});return{...m,tiles:g,...w?.length?{drills:[...w].sort((b,_)=>Di(b).localeCompare(Di(_)))}:{},...x?.length?{localGivens:x}:{}}};if(d.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=cv(e,d);if((await Ja(e)).length===0){const p=await Ja(f);if(p.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${p[0]}). Your changes are still here.`}}const v=await Ti(f);return Oi(v)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${v.reason}`}:be(h(v.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 Ov(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],d=S.useCallback(x=>{o(void 0),n(m=>{const g=structuredClone(m.stack[m.index]);if(x(g),JSON.stringify(g)===JSON.stringify(m.stack[m.index]))return m;const _=[...m.stack.slice(0,m.index+1),g].slice(-100);return{stack:_,index:_.length-1}})},[]),c=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 eo(r,u);if(Zs(x))return o(x.reason),{ok:!1,reason:x.reason};try{await e.onSave?.(x.source)}catch(m){const g=`Could not save: ${m}`;return o(g),{ok:!1,reason:g}}return i(x.source),l(u),o(void 0),{ok:!0}},[u,e,r]),v=S.useMemo(()=>JSON.stringify(u)!==JSON.stringify(a),[u,a]),p=S.useMemo(()=>{const x=new Set(a.tiles.map(Js)),m=new Set(u.tiles.map(Js));return[...x].some(g=>!m.has(g))||[...m].some(g=>!x.has(g))},[u,a]),w=S.useCallback(async()=>{const x=await eo(r,u);return Zs(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:v,...s===void 0?{}:{error:s},update:d,undo:c,redo:h,save:f,preview:w,structural:p}}function eu({source:e,document:t,onSave:n,onChange:r,onDirtyChange:i,renderTile:s,controls:o,givens:a,catalog:l,toolbar:u,dashboards:d,onEvent:c,savesTo:h="package"}){const f=Ov({source:e,document:t,...n?{onSave:n}:{}}),[v,p]=S.useState(void 0),[w,x]=S.useState(!1),m=f.document.columns??j.DEFAULT_COLUMNS,{resize:g,gridBox:b,startResize:_,onResize:$,endResize:O}=Bg({tiles:f.document.tiles,columns:m,onStart:p,commit:(E,D)=>f.update(B=>{B.tiles[E].colspan=D})}),{dragging:C,preview:I,onDragStart:P,onDragOver:U,onDragEnd:W}=Ng({tiles:f.document.tiles,commit:E=>f.update(D=>{D.tiles=E}),onLanded:p}),[M,z]=S.useState(void 0),[V,ee]=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(()=>zp(f.document),[f.document]),$e=S.useMemo(()=>{const E=new Set((t.localGivens??[]).map(D=>D.name));return(a??[]).filter(D=>!E.has(D.name))},[t,a]),fe=S.useMemo(()=>dp(f.document,$e),[f.document,$e]),L=S.useMemo(()=>new Map(f.document.sources.map(E=>[E.name,Aa(l,E.base)])),[l,f.document.sources]),G=S.useCallback(E=>L.get(E.source)??Aa(l,E.source),[L,l]),_e=(E,D)=>{const B=[];for(const Q of f.document.tiles){const Ue=G(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(D,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:D}=f,B=f.document.tiles.length;f.save().then(Q=>{Q.ok===!0?c?.({type:"dashboard.saved",tiles:B,structural:D,where:h,durationMs:j.now()-E}):c?.({type:"dashboard.save_refused",reason:Q.reason})}).finally(()=>x(!1))},[f,c,h]),ne=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(D=>{let B=D.sources.find(ke=>ke.base===E.base);if(!B){const ke=new Set(D.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},D.sources.push(B)}const Q=new Set(D.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}`;D.tiles.push({name:Ue,source:B.name,declaration:{kind:"reference",from:E.view},colspan:E.colspan,...E.label?{label:E.label}:{}})}),p(f.document.tiles.length)},Fe=E=>{ee(void 0),p(void 0),f.update(D=>{D.tiles.splice(E,1)})};Sp(S.useMemo(()=>({undo:f.undo,redo:f.redo,...n?{save:ne}:{},escape:()=>{!V&&!M&&p(void 0)},nudge:E=>{if(v===void 0)return;const D=f.document.tiles[v];if(!D||D.declaration.kind==="inherited")return;const B=Math.min(Math.max((D.colspan??1)+E,1),m);B!==(D.colspan??1)&&f.update(Q=>{Q.tiles[v].colspan=B})}}),[f,n,ne,V,M,v,m]));const xt=(E,D,B)=>{z(void 0),f.update(Q=>{B&&mp(Q,B),vp(Q,E,D)})},T=E=>{z(void 0),f.update(D=>yp(D,E))},A=(()=>{const E=f.document.tiles;return g!==void 0?E.map((D,B)=>B===g.index?{...D,colspan:g.span}:D):I??E})(),q=C?Up(A,m):A.map(Pd);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:ne}:{},...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(Bp,{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(Hh,{sensors:kg,onDragStart:P,onDragOver:U,onDragEnd:W,children:y.jsxs(k.Box,{ref:b,sx:{position:"relative"},children:[(g!==void 0||C)&&y.jsx(Mg,{columns:m}),y.jsx(j.DashboardGrid,{tiles:q,columns:m,keyOf:E=>E.kind==="gap"?Md(E.after):pt(E.tile),renderTile:E=>{if(E.kind==="gap")return y.jsx(Pg,{after:E.after});const{tile:D,index:B}=E;return y.jsx(Dg,{tile:D,index:B,selected:B===v,menuOpen:V?.index===B,resizeSpan:g?.index===B?g.span:void 0,columns:m,onSelect:()=>p(B),onOpenMenu:Q=>{p(B),ee({anchor:Q,index:B})},onResizeStart:Q=>_(Q,B),onResizeMove:$,onResizeEnd:O,children:s?s(D):y.jsx(Cg,{tile:D})})}})]})}),y.jsx(Wp,{open:M!==void 0,document:f.document,...M?.control?{control:M.control}:{},available:X,...l?{fieldsFor:G}:{},onClose:()=>z(void 0),onApply:xt,onRemove:T}),y.jsx(Vg,{anchor:V?.anchor??null,tile:V===void 0?void 0:f.document.tiles[V.index],onClose:()=>ee(void 0),onCommit:E=>{const D=V?.index;D!==void 0&&f.update(B=>{B.tiles[D]=E})},onRemove:()=>{V!==void 0&&Fe(V.index)},columns:m,onDrills:()=>{V!==void 0&&Ve(f.document.tiles[V.index]?.source)}}),y.jsx(Rp,{open:Le!==void 0,document:f.document,source:f.document.sources.find(E=>E.name===Le),givenNames:fe.map(E=>E.name),dashboards:d??[],onClose:()=>Ve(void 0),onApply:E=>f.update(D=>{const Q=[...(D.drills??[]).filter(Ue=>Ue.source!==Le),...E];Q.length===0?delete D.drills:D.drills=Q})}),y.jsx(Fp,{anchor:Ce,settings:Xe,onClose:()=>Ye(null),onCommit:E=>f.update(D=>{D.title=E.title,E.description===void 0?delete D.description:D.description=E.description,E.columns===void 0?delete D.columns:D.columns=E.columns,E.autorun===void 0?delete D.autorun:D.autorun=E.autorun})}),y.jsx(Mp,{open:Se,document:f.document,catalog:l,columns:m,onClose:()=>oe(!1),onAdd:at}),y.jsx(Ap,{open:Ge!==void 0,before:Ge?.before??"",after:Ge?.after??"",onConfirm:ze,onClose:()=>We(void 0)})]})]})}function Tv(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(Dv(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 Dv(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 Cv(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(d=>[d.name,d.type])),a=[],l=[];for(const d of t.filters??[]){const c=`where: ${d.field} ${d.op??"~"}`;if(n.has(d.given)){a.push(d.given),l.push(`${c} $${d.given}`);continue}if(!o.has(d.given))continue;const h=j.malloyLiteral(r.get(d.given),o.get(d.given));h!==void 0&&l.push(`${c} ${h}`)}const u=l.join(", ");return{expression:`${i} -> ${s}`+(u?` + { ${u} }`:""),givenNames:a}}async function Pv(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}const sl=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function Mv(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:d,mutable:c}=Be.useServer(),h=cu.useQueryClient(),f=S.useRef(j.now()),v=S.useRef(n);v.current=n;const p=S.useRef(r);p.current=r;const w=j.useOptionalDocumentStorage()?.documentStorage,x=`dashboards/${a}.malloy`,m=j.useQueryWithApiError({queryKey:["dashboard-editor-model",s,o,x,l],queryFn:()=>d.models.getModel(s,o,x,l),enabled:u}),g=m.data?.data?.sourceText,[b,_]=S.useState(void 0),[$,O]=S.useState(void 0),[C,I]=S.useState(w===void 0),[P,U]=S.useState(!1),[W,M]=S.useState(void 0);S.useEffect(()=>{if(!w)return;let R=!1;return M(void 0),(async()=>{try{const te=await w.listWorkspaces(!1),Oe=te.find(he=>he.authoritative)??te.find(he=>he.writeable);if(R)return;if(_(Oe),Oe!==void 0){const he=await w.getDocument(sl(Oe.name,s,o,x)).catch(ae=>{if(!j.isDocumentNotFound(ae))throw ae});if(R)return;O(he),U(he!==void 0)}}catch(te){if(R)return;M(ol(te))}R||I(!0)})(),()=>{R=!0}},[w,s,o,x]);const z=b?.authoritative===!0,V=z&&W!==void 0,[ee,Se]=S.useState(void 0),oe=(z||ee===!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 G=Xe!==void 0&&Xe.onFetch===fe?Xe.text:g,_e=S.useRef(G);_e.current=G;const X=oe?$:G,[ze,ne]=S.useState(!1),[at,Fe]=S.useState(void 0),[xt,T]=S.useState(void 0),A=X!==void 0&&X!==xt,q=Le?.source,E=A&&ze&&q!==void 0&&X!==at,D=E?q:A?X:q??X,B=E?X:void 0,Q=S.useRef(q);Q.current=q;const Ue=S.useRef(X);Ue.current=X;const ke=S.useRef("package");ke.current=oe?z?"record":"draft":"package",S.useEffect(()=>{if(D===void 0||!C||V||D===Q.current)return;let R=!1;const te=_e.current,Oe=Ue.current;return Ti(D).then(he=>{if(!R){if(Oi(he)){const ae=he.line?`${he.reason} (line ${he.line})`:he.reason;Ye(ae),v.current?.({type:"dashboard.open_refused",reason:ae});return}Ye(void 0),Ge.current=void 0,We.current=te,$e(void 0),Fe(void 0),T(Oe),Ve(ae=>({source:D,document:he.document,generation:(ae?.generation??0)+1})),v.current?.({type:"dashboard.opened",from:ke.current,tiles:he.document.tiles.length,durationMs:j.now()-f.current})}}),()=>{R=!0}},[D,C,V]);const se=b===void 0?void 0:sl(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(te=>te&&{...te,source:R}),O(R),(z||ee===!0)&&T(R),z||Se(te=>te??!1)},[w,se,z,ee]),[Qt,Ct]=S.useState(void 0),Rr=S.useCallback(async R=>{const te=We.current,Oe=Ge.current??(te===void 0?void 0:await Pv(te));if(Oe===void 0)throw new Error("The package file is still loading; try again.");let he;try{he=await d.models.updateModelSource(s,o,x,{source:R,expectedHash:Oe})}catch(ae){throw h.invalidateQueries({queryKey:["dashboard-editor-model",s,o,x,l]}),new Error(Av(ae))}if(Ve(ae=>ae&&{...ae,source:R}),$e({text:R,onFetch:L.current}),T(R),Ge.current=he.data.contentHash,Ct(void 0),w&&se)try{await w.deleteDocument(se),O(void 0),U(!1)}catch(ae){j.isDocumentNotFound(ae)?(O(void 0),U(!1)):Ct(ol(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]})},[d,s,o,x,l,w,se,h]),Pt=z?"host":c?"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:c?Rr:w&&se&&Zt?Ee:void 0:void 0,zn=b?.name,Fn=S.useCallback(R=>{v.current?.(R.type==="dashboard.saved"&&R.where!=="package"&&zn!==void 0?{...R,workspace:zn}:R)},[zn]),Gi=S.useCallback(R=>{ne(R),p.current?.(R)},[]),Nn=R=>{f.current=j.now(),Fe(R?$:G),Se(R)},Ui=()=>{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(!g||!C)return y.jsxs(k.Stack,{sx:{gap:2},children:[y.jsx(j.DashboardBar,{}),y.jsx(j.Loading,{text:"Opening the dashboard…"})]});if(V)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&&$!==g;return y.jsxs(k.Stack,{sx:{gap:2},children:[!z&&P&&Z&&ee===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:Ui,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(jv,{environmentName:s,packageName:o,modelPath:x,slug:a,...l!==void 0?{versionId:l}:{},opened:Le,onSave:Lr,onDirtyChange:Gi,savesTo:Pt,...n?{onEvent:Fn}:{},toolbar:t&&y.jsx(j.SecondaryButton,{label:"Done editing",icon:y.jsx(j.CheckIcon,{}),onClick:t}),note:Iv({authoritative:z,mutable:c,pinnedPackageSave:Wn,...b?{workspace:b}:{},...W!==void 0?{readFailure:W}:{},...l!==void 0?{versionId:l}:{}})},Le.generation)]})}function Iv({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 jv({environmentName:e,packageName:t,modelPath:n,slug:r,versionId:i,opened:s,onSave:o,onDirtyChange:a,onEvent:l,savesTo:u,toolbar:d,note:c}){const{apiClients:h}=Be.useServer(),{data:f,isSuccess:v}=j.useQueryWithApiError({queryKey:["dashboard-editor-manifest",e,t,r,i],queryFn:()=>h.dashboards.getDashboard(e,t,r,i)}),p=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(M=>M.name).filter(M=>!!M&&M!==r),[w,r]),m=S.useMemo(()=>{const M=n.slice(0,n.lastIndexOf("/")+1);return s.document.imports.map(z=>({...z,path:new URL(z.from,`https://malloy.invalid/${M}`).pathname.slice(1)}))},[s.document.imports,n]),{data:g}=j.useQueryWithApiError({queryKey:["dashboard-editor-catalog",e,t,...m.map(M=>M.path),i],queryFn:async()=>{const M=(await h.models.listModels(e,t,i)).data.filter(ee=>ee.path&&!ee.error),V=(await Promise.allSettled(M.map(ee=>h.models.getModel(e,t,ee.path,i).then(Se=>Se.data)))).flatMap(ee=>ee.status==="fulfilled"?[ee.value]:[]);return Cp(Td(V),m,V)},enabled:m.length>0}),[b,_]=S.useState(s.document);S.useEffect(()=>_(s.document),[s.document]);const $=S.useMemo(()=>p?.givens??[],[p]),O=S.useMemo(()=>new Set($.map(M=>M.name).filter(M=>M!==void 0)),[$]),C=S.useMemo(()=>Tv(b,$),[b,$]),{declaredTypes:I,applied:P,panel:U}=j.useDocumentControls({specs:C,loaded:v,startingValues:p?.startingGivens,documentKey:`${e}/${t}/${i??""}/${r}/edit`,autorun:p?.autorun!==!1,environmentName:e,packageName:t,modelPath:p?.path,versionId:i,documentName:r}),W=S.useMemo(()=>function(z){const V=Cv(b,z,O,P);return y.jsx(j.DashboardTile,{environmentName:e,packageName:t,versionId:i,modelPath:n,tile:V.expression,label:z.label??j.tileTitle(`${z.source} -> ${z.name}`),subtitle:z.subtitle,borderless:z.borderless,givens:P,declaredTypes:I,givenNames:V.givenNames,height:j.TILE_MAX_HEIGHT})},[b,O,e,t,i,n,P,I]);return y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsx(eu,{source:s.source,document:s.document,renderTile:W,givens:C.filter(M=>M.name!==void 0).map(M=>({name:M.name,...M.label?{label:M.label}:{},...M.type?{type:M.type}:{},...M.suggest?.dimension?{field:M.suggest.dimension}:{}})),onChange:_,onDirtyChange:a,...g?{catalog:g}:{},dashboards:x,...l?{onEvent:l}:{},toolbar:d,controls:v?y.jsx(j.GivensPanel,{...U,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:c})})]})}function ol(e){return e instanceof Error?e.message:String(e)}function Av(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=eu;exports.DashboardEditor=Mv;exports.buildCatalog=Td;exports.readDashboardDocument=Ti;exports.readFailed=Oi;exports.spliceDashboardDocument=eo;exports.spliceFailed=Zs;
|