@devtable/dashboard 2.4.0 → 3.0.0
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 +25 -1
- package/dist/api-caller/index.d.ts +13 -7
- package/dist/api-caller/types.d.ts +1 -1
- package/dist/contexts/index.d.ts +1 -3
- package/dist/contexts/model-context.d.ts +24165 -0
- package/dist/contexts/panel-context.d.ts +0 -1
- package/dist/dashboard.es.js +9680 -15352
- package/dist/dashboard.umd.js +38 -19
- package/dist/definition-editor/data-editor-modal.d.ts +2 -2
- package/dist/definition-editor/global-variables-guide.d.ts +2 -2
- package/dist/definition-editor/query-editor/data-preview.d.ts +3 -3
- package/dist/definition-editor/query-editor/editor.d.ts +1 -1
- package/dist/definition-editor/query-editor/form.d.ts +4 -5
- package/dist/definition-editor/query-editor/index.d.ts +2 -2
- package/dist/definition-editor/query-editor/select-or-add-query.d.ts +1 -1
- package/dist/definition-editor/sql-snippet-editor/editor.d.ts +2 -2
- package/dist/filter/filter-checkbox/editor.d.ts +1 -1
- package/dist/filter/filter-checkbox/render.d.ts +1 -1
- package/dist/filter/filter-date-range/editor.d.ts +1 -1
- package/dist/filter/filter-date-range/render.d.ts +1 -1
- package/dist/filter/filter-multi-select/editor.d.ts +1 -1
- package/dist/filter/filter-multi-select/render.d.ts +1 -1
- package/dist/filter/filter-query-field/index.d.ts +1 -1
- package/dist/filter/filter-query-field/select-data-source.d.ts +1 -1
- package/dist/filter/filter-query-field/test-query.d.ts +1 -1
- package/dist/filter/filter-select/editor.d.ts +1 -1
- package/dist/filter/filter-select/render.d.ts +1 -1
- package/dist/filter/filter-settings/filter-settings.d.ts +0 -2
- package/dist/filter/filter-settings/index.d.ts +2 -4
- package/dist/filter/filter-text-input/editor.d.ts +1 -1
- package/dist/filter/filter-text-input/render.d.ts +1 -1
- package/dist/filter/index.d.ts +2 -6
- package/dist/index.d.ts +1 -0
- package/dist/layout/index.d.ts +1 -1
- package/dist/layout/read-only.d.ts +2 -2
- package/dist/main/actions.d.ts +1 -3
- package/dist/main/full-screen-panel.d.ts +2 -2
- package/dist/main/main.d.ts +2 -2
- package/dist/main/read-only.d.ts +2 -2
- package/dist/main/use-sticky-area-style.d.ts +1 -0
- package/dist/model/context.d.ts +11 -0
- package/dist/model/dashboard.d.ts +8579 -684
- package/dist/model/{filter → filters/filter}/checkbox.d.ts +0 -0
- package/dist/model/{filter → filters/filter}/common.d.ts +0 -0
- package/dist/model/{filter → filters/filter}/date-range.d.ts +0 -0
- package/dist/model/{filter → filters/filter}/index.d.ts +0 -0
- package/dist/model/{filter → filters/filter}/multi-select.d.ts +0 -0
- package/dist/model/{filter → filters/filter}/select.d.ts +0 -0
- package/dist/model/{filter → filters/filter}/text-input.d.ts +0 -0
- package/dist/{main/use-filters.d.ts → model/filters/index.d.ts} +1430 -16
- package/dist/model/index.d.ts +4 -1
- package/dist/model/queries/index.d.ts +116 -0
- package/dist/model/queries/mute-query.d.ts +17 -0
- package/dist/model/queries/query.d.ts +31 -0
- package/dist/model/queries/types.d.ts +5 -0
- package/dist/model/sql-snippets/index.d.ts +26 -0
- package/dist/model/sql-snippets/sql-snippet.d.ts +9 -0
- package/dist/panel/index.d.ts +2 -2
- package/dist/panel/plugin-adaptor.d.ts +7 -0
- package/dist/panel/settings/index.d.ts +2 -2
- package/dist/panel/settings/pick-query/index.d.ts +2 -2
- package/dist/panel/title-bar.d.ts +2 -2
- package/dist/panel/viz/index.d.ts +3 -3
- package/dist/plugins/hooks/index.d.ts +2 -0
- package/dist/plugins/hooks/use-channel-event.d.ts +2 -0
- package/dist/plugins/hooks/use-storage-data.d.ts +6 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/json-plugin-storage.d.ts +12 -0
- package/dist/plugins/message-channels.d.ts +7 -0
- package/dist/plugins/plugin-context.d.ts +12 -0
- package/dist/plugins/plugin-data-migrator/index.d.ts +1 -0
- package/dist/plugins/plugin-data-migrator/plugin-data-migrator.d.ts +13 -0
- package/dist/plugins/plugin-manager.d.ts +18 -0
- package/dist/plugins/viz-components/table/index.d.ts +2 -0
- package/dist/{panel/viz → plugins/viz-components}/table/type.d.ts +1 -0
- package/dist/{panel/viz → plugins/viz-components}/table/value-type-selector.d.ts +0 -0
- package/dist/{panel/viz → plugins/viz-components}/table/value.d.ts +0 -0
- package/dist/plugins/viz-components/table/viz-table-panel.d.ts +3 -0
- package/dist/plugins/viz-components/table/viz-table.d.ts +3 -0
- package/dist/plugins/viz-manager/components.d.ts +22 -0
- package/dist/plugins/viz-manager/impl.d.ts +10 -0
- package/dist/plugins/viz-manager/index.d.ts +4 -0
- package/dist/plugins/viz-manager/types.d.ts +12 -0
- package/dist/style.css +1 -1
- package/dist/types/dashboard.d.ts +4 -12
- package/dist/types/plugin/index.d.ts +101 -0
- package/dist/utils/download.d.ts +6 -0
- package/dist/utils/sql.d.ts +7 -6
- package/package.json +25 -6
- package/dist/contexts/context-info-context.d.ts +0 -5
- package/dist/contexts/definition-context.d.ts +0 -7
- package/dist/contexts/filter-values-context.d.ts +0 -4
- package/dist/panel/viz/table/index.d.ts +0 -10
- package/dist/panel/viz/table/panel.d.ts +0 -3
package/dist/dashboard.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(ue,Ae){typeof exports=="object"&&typeof module<"u"?Ae(exports,require("react"),require("lodash"),require("react-grid-layout"),require("@mantine/core"),require("@mantine/modals"),require("mobx-react-lite"),require("tabler-icons-react"),require("@mantine/rte"),require("@mantine/hooks"),require("mobx"),require("numbro"),require("ahooks"),require("@mantine/form"),require("@mantine/prism"),require("echarts-for-react/lib/core"),require("echarts/core"),require("echarts/charts"),require("echarts/renderers"),require("echarts-stat"),require("echarts/components"),require("echarts-gl"),require("react-hook-form"),require("axios"),require("mobx-state-tree"),require("@mantine/dates"),require("stickybits")):typeof define=="function"&&define.amd?define(["exports","react","lodash","react-grid-layout","@mantine/core","@mantine/modals","mobx-react-lite","tabler-icons-react","@mantine/rte","@mantine/hooks","mobx","numbro","ahooks","@mantine/form","@mantine/prism","echarts-for-react/lib/core","echarts/core","echarts/charts","echarts/renderers","echarts-stat","echarts/components","echarts-gl","react-hook-form","axios","mobx-state-tree","@mantine/dates","stickybits"],Ae):(ue=typeof globalThis<"u"?globalThis:ue||self,Ae(ue.dashboard={},ue.React,ue._,ue["react-grid-layout"],ue["@mantine/core"],ue["@mantine/modals"],ue["mobx-react-lite"],ue["tabler-icons-react"],ue["@mantine/rte"],ue["@mantine/hooks"],ue.mobx,ue.numbro,ue.ahooks,ue["@mantine/form"],ue["@mantine/prism"],ue["echarts-for-react/lib/core"],ue["echarts/core"],ue["echarts/charts"],ue["echarts/renderers"],ue["echarts-stat"],ue["echarts/components"],ue["echarts-gl"],ue["react-hook-form"],ue.axios,ue["mobx-state-tree"],ue["@mantine/dates"],ue.stickybits))})(this,function(ue,Ae,Ie,Lt,c,Bt,Se,pe,dr,Be,at,Rn,He,jt,st,Mn,Ln,ht,kt,Bn,ot,ao,be,jn,se,qn,Nn){"use strict";var no=Object.defineProperty;var io=(ue,Ae,Ie)=>Ae in ue?no(ue,Ae,{enumerable:!0,configurable:!0,writable:!0,value:Ie}):ue[Ae]=Ie;var Qe=(ue,Ae,Ie)=>(io(ue,typeof Ae!="symbol"?Ae+"":Ae,Ie),Ie);const et=t=>t&&typeof t=="object"&&"default"in t?t:{default:t};function Gn(t){if(t&&t.__esModule)return t;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const W=et(Ae),ye=et(Ie),fr=et(Lt),qt=et(dr),Ct=et(Rn),St=et(Mn),Ze=Gn(Ln),Un=et(jn),Vn=et(Nn);var Ve=(t=>(t.Use="use",t.Layout="layout",t.Edit="edit",t))(Ve||{});const Wn={layoutFrozen:!1,freezeLayout:()=>{},mode:Ve.Edit,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},$e=W.default.createContext(Wn),$n={id:"",data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},queryID:"",setQueryID:()=>{},viz:{type:"",conf:{}},setViz:()=>{}},je=W.default.createContext($n),hr=W.default.createContext(null),Nt=hr.Provider;function Me(){const t=W.default.useContext(hr);if(!t)throw new Error("Please use ModelContextProvider");return t}const Qn={addPanel:ye.default.noop,duplidatePanel:ye.default.noop,removePanelByID:ye.default.noop,viewPanelInFullScreen:ye.default.noop,inFullScreen:!1},Et=W.default.createContext(Qn);var Ye=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},zt={exports:{}},pt={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,9 +6,33 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var nu=h.default,iu=Symbol.for("react.element"),au=Symbol.for("react.fragment"),ou=Object.prototype.hasOwnProperty,uu=nu.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,lu={key:!0,ref:!0,__self:!0,__source:!0};function zn(e,r,t){var n,i={},a=null,o=null;t!==void 0&&(a=""+t),r.key!==void 0&&(a=""+r.key),r.ref!==void 0&&(o=r.ref);for(n in r)ou.call(r,n)&&!lu.hasOwnProperty(n)&&(i[n]=r[n]);if(e&&e.defaultProps)for(n in r=e.defaultProps,r)i[n]===void 0&&(i[n]=r[n]);return{$$typeof:iu,type:e,key:a,ref:o,props:i,_owner:uu.current}}Xt.Fragment=au,Xt.jsx=zn,Xt.jsxs=zn,Jt.exports=Xt;const l=Jt.exports.jsx,b=Jt.exports.jsxs,Y=Jt.exports.Fragment;function Nn({}){const{freezeLayout:e}=h.default.useContext(be),[r,t]=h.default.useState(!1),{title:n,description:i}=h.default.useContext(se);return h.default.useEffect(()=>{e(r)},[r]),!i||i==="<p><br></p>"?null:b(Y,{children:[l(s.Modal,{opened:r,onClose:()=>t(!1),title:n,withCloseButton:!1,children:l(kr.default,{readOnly:!0,value:i,onChange:C.default.noop,sx:{border:"none"}})}),l(s.Tooltip,{label:"Click to see description",position:"top-start",children:l(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>t(a=>!a),sx:{verticalAlign:"baseline",cursor:"pointer"},children:l(_.InfoCircle,{size:20})})})]})}function su(){const{description:e,setDescription:r}=h.default.useContext(se),[t,n]=h.default.useState(e),i=e!==t,a=h.default.useCallback(()=>{!i||r(t)},[i,t]);return b(s.Stack,{sx:{flexGrow:1},children:[b(s.Group,{align:"end",children:[l(s.Text,{children:"Description"}),l(s.ActionIcon,{variant:"subtle",color:"blue",disabled:!i,onClick:a,children:l(_.DeviceFloppy,{size:20})})]}),l(En.RichTextEditor,{value:t,onChange:n,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class Zt extends h.default.Component{constructor(r){super(r),this.state={error:null}}componentDidCatch(r){this.setState({error:r})}render(){var r;if(this.state.error){const t=()=>{this.setState({error:null})};return b(s.Box,{children:[l(s.Text,{size:"xs",children:(r=this.state.error)==null?void 0:r.message}),l(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:t,children:"Retry"})]})}return this.props.children}}function cu(){const{title:e}=h.default.useContext(se);return l(Zt,{children:b(s.Stack,{mx:"auto",mt:"xl",p:"5px",spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[b(s.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[l(s.Group,{children:l(Nn,{})}),l(s.Group,{grow:!0,position:"center",children:l(s.Text,{lineClamp:1,weight:"bold",children:e})}),l(s.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),l(s.Group,{sx:{background:"#eee",flexGrow:1}})]})})}function fu(){const{title:e,setTitle:r}=h.default.useContext(se),[t,n]=W.useInputState(e),i=e!==t,a=h.default.useCallback(()=>{!i||r(t)},[i,t]);return l(s.TextInput,{value:t,onChange:n,label:b(s.Group,{align:"end",children:[l(s.Text,{children:"Panel Title"}),l(s.ActionIcon,{variant:"subtle",color:"blue",disabled:!i,onClick:a,children:l(_.DeviceFloppy,{size:20})})]})})}function du({}){return b(s.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[b(s.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0,height:"100%"},children:[l(fu,{}),l(su,{})]}),l(s.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:l(cu,{})})]})}function Ln({id:e}){const r=h.default.useContext(ce),t=h.default.useContext(Ye),n=h.default.useContext(Ie),i=h.default.useMemo(()=>r.queries.find(c=>c.id===e),[r.queries,e]),{data:a=[],loading:o,refresh:u}=Be.useRequest(Mn({context:n,definitions:r,filterValues:t,title:e,query:i}),{refreshDeps:[n,r,i,t]});return o?l(s.LoadingOverlay,{visible:o,exitTransitionDuration:0}):a.length===0?l(s.Table,{}):b(s.Stack,{my:"xl",sx:{border:"1px solid #eee"},children:[b(s.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[b(s.Group,{position:"left",children:[l(s.Text,{weight:500,children:"Preview Data"}),a.length>10&&b(s.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",a.length]})]}),l(s.ActionIcon,{mr:15,variant:"subtle",color:"blue",disabled:o,onClick:u,children:l(_.Refresh,{size:15})})]}),b(s.Table,{children:[l("thead",{children:l("tr",{children:Object.keys(a==null?void 0:a[0]).map(c=>l("th",{children:l(s.Text,{weight:700,color:"#000",children:c})},c))})}),l("tbody",{children:a.slice(0,10).map((c,d)=>l("tr",{children:Object.values(c).map((f,p)=>l("td",{children:l(s.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:l(s.Text,{children:f})})},`${f}--${p}`))},`row-${d}`))})]})]})}function pu({}){const{queries:e}=h.default.useContext(ce),{queryID:r,setQueryID:t,data:n,loading:i}=h.default.useContext(se),a=h.default.useMemo(()=>e.map(o=>({value:o.id,label:o.id})),[e]);return b(s.Stack,{children:[b(s.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[l(s.Text,{children:"Select a Query"}),l(s.Select,{data:a,value:r,onChange:t,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}})]}),l(Ln,{id:r})]})}Oe.use([wt.SunburstChart,Yt.CanvasRenderer]);const hu={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function bu({conf:e,data:r,width:t,height:n}){const{label_field:i="name",value_field:a="value",...o}=e,u=h.default.useMemo(()=>r.map(p=>({name:p[i],value:Number(p[a])})),[r,i,a]),c=h.default.useMemo(()=>{var p,v;return(v=(p=C.default.maxBy(u,y=>y.value))==null?void 0:p.value)!=null?v:1},[u]),d=h.default.useMemo(()=>({series:{label:{formatter:({name:p,value:v})=>v/c<.2?" ":p}}}),[c]),f=C.default.merge({},hu,d,o,{series:{data:u}});return l(Qt.default,{echarts:Oe,option:f,style:{width:t,height:n}})}function vu({regressions:e=[]},r){const t=[],n=[],i=[];return r.length===0?{regressionDataSets:t,regressionSeries:n,regressionXAxes:i}:(e.forEach(({transform:a,plot:o,name:u,y_axis_data_key:c})=>{const d=`x-axis-for-${u}`,f=`dataset-for-${u}--raw`,p=`dataset-for-${u}--transformed`;t.push({id:f,source:r.map((v,y)=>[y,v[c]])}),t.push({transform:a,id:p,fromDatasetId:f}),n.push({...o,name:u,datasetId:p,xAxisId:d,showSymbol:!1,tooltip:{show:!1}}),i.push({type:"category",id:d,datasetId:p,show:!1})}),{regressionDataSets:t,regressionSeries:n,regressionXAxes:i})}const mu={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"axis"},xAxis:{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"}},grid:{top:0,left:15,right:15,bottom:30,containLabel:!0}};function yu(e,r){var d;const t=e.y_axes.reduce((f,{label_formatter:p},v)=>(f[v]=function(P){const j=typeof P=="object"?P.value:P;if(!p)return j;try{return Kt.default(j).format(p)}catch(I){return console.error(I),j}},f),{default:({value:f})=>f}),n=e.series.reduce((f,{yAxisIndex:p,name:v})=>(f[v]=p,f),{}),i=e.series.map(({y_axis_data_key:f,yAxisIndex:p,label_position:v,name:y,...P})=>({data:r.map(I=>I[f]),label:{show:!!v,position:v,formatter:t[p!=null?p:"default"]},name:y,xAxisId:"main-x-axis",yAxisIndex:p,...P})),{regressionDataSets:a,regressionSeries:o,regressionXAxes:u}=vu(e,r),c={xAxis:[{data:r.map(f=>f[e.x_axis_data_key]),name:(d=e.x_axis_name)!=null?d:"",id:"main-x-axis"},...u],yAxis:e.y_axes.map(({label_formatter:f,...p},v)=>{var y;return{...p,axisLabel:{show:!0,formatter:(y=t[v])!=null?y:t.default}}}),dataset:[...a],series:[...i,...o],tooltip:{formatter:function(f){const p=Array.isArray(f)?f:[f];if(p.length===0)return"";const v=p.map(({seriesName:y,value:P})=>{var $;if(!y)return P;const j=n[y],I=($=t[j])!=null?$:t.default;return`${y}: ${I({value:P})}`});return v.unshift(`<strong>${p[0].name}</strong>`),v.join("<br />")}}};return C.default.merge({},mu,c)}function gu(e){const r=Array.from(e).sort((n,i)=>n-i),t=Math.floor(r.length/2);return r.length%2===0?(r[t-1]+r[t])/2:r[t]}function _u(e,r,t){var i,a,o;const n=e.map(u=>u[r]);switch(t){case"sum":return C.default.sum(n);case"mean":return C.default.mean(n);case"median":return gu(n);case"max":return(i=C.default.max(n))!=null?i:0;case"min":return(a=C.default.min(n))!=null?a:0;default:return(o=e[0])==null?void 0:o[r]}}var Fn=function(){};const wu=(e,r,t)=>Math.min(Math.max(t,e),r),qn=(e,r,t)=>{const n=r-e;return n===0?1:(t-e)/n},Lr=(e,r,t)=>-t*e+t*r+e,Bn=(e,r)=>t=>Math.max(Math.min(t,r),e),Ot=e=>e%1?Number(e.toFixed(5)):e,er=/(-)?([\d]*\.?[\d])+/g,Fr=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,Su=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function xt(e){return typeof e=="string"}const tr={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Gn=Object.assign(Object.assign({},tr),{transform:Bn(0,1)});Object.assign(Object.assign({},tr),{default:1});const Pt=(e=>({test:r=>xt(r)&&r.endsWith(e)&&r.split(" ").length===1,parse:parseFloat,transform:r=>`${r}${e}`}))("%");Object.assign(Object.assign({},Pt),{parse:e=>Pt.parse(e)/100,transform:e=>Pt.transform(e*100)});const qr=(e,r)=>t=>Boolean(xt(t)&&Su.test(t)&&t.startsWith(e)||r&&Object.prototype.hasOwnProperty.call(t,r)),$n=(e,r,t)=>n=>{if(!xt(n))return n;const[i,a,o,u]=n.match(er);return{[e]:parseFloat(i),[r]:parseFloat(a),[t]:parseFloat(o),alpha:u!==void 0?parseFloat(u):1}},Qe={test:qr("hsl","hue"),parse:$n("hue","saturation","lightness"),transform:({hue:e,saturation:r,lightness:t,alpha:n=1})=>"hsla("+Math.round(e)+", "+Pt.transform(Ot(r))+", "+Pt.transform(Ot(t))+", "+Ot(Gn.transform(n))+")"},Ou=Bn(0,255),Br=Object.assign(Object.assign({},tr),{transform:e=>Math.round(Ou(e))}),De={test:qr("rgb","red"),parse:$n("red","green","blue"),transform:({red:e,green:r,blue:t,alpha:n=1})=>"rgba("+Br.transform(e)+", "+Br.transform(r)+", "+Br.transform(t)+", "+Ot(Gn.transform(n))+")"};function xu(e){let r="",t="",n="",i="";return e.length>5?(r=e.substr(1,2),t=e.substr(3,2),n=e.substr(5,2),i=e.substr(7,2)):(r=e.substr(1,1),t=e.substr(2,1),n=e.substr(3,1),i=e.substr(4,1),r+=r,t+=t,n+=n,i+=i),{red:parseInt(r,16),green:parseInt(t,16),blue:parseInt(n,16),alpha:i?parseInt(i,16)/255:1}}const Gr={test:qr("#"),parse:xu,transform:De.transform},rr={test:e=>De.test(e)||Gr.test(e)||Qe.test(e),parse:e=>De.test(e)?De.parse(e):Qe.test(e)?Qe.parse(e):Gr.parse(e),transform:e=>xt(e)?e:e.hasOwnProperty("red")?De.transform(e):Qe.transform(e)},Un="${c}",Wn="${n}";function Pu(e){var r,t,n,i;return isNaN(e)&&xt(e)&&((t=(r=e.match(er))===null||r===void 0?void 0:r.length)!==null&&t!==void 0?t:0)+((i=(n=e.match(Fr))===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0)>0}function Yn(e){typeof e=="number"&&(e=`${e}`);const r=[];let t=0;const n=e.match(Fr);n&&(t=n.length,e=e.replace(Fr,Un),r.push(...n.map(rr.parse)));const i=e.match(er);return i&&(e=e.replace(er,Wn),r.push(...i.map(tr.parse))),{values:r,numColors:t,tokenised:e}}function Qn(e){return Yn(e).values}function Kn(e){const{values:r,numColors:t,tokenised:n}=Yn(e),i=r.length;return a=>{let o=n;for(let u=0;u<i;u++)o=o.replace(u<t?Un:Wn,u<t?rr.transform(a[u]):Ot(a[u]));return o}}const Cu=e=>typeof e=="number"?0:e;function Au(e){const r=Qn(e);return Kn(e)(r.map(Cu))}const Hn={test:Pu,parse:Qn,createTransformer:Kn,getAnimatableNone:Au};function $r(e,r,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?e+(r-e)*6*t:t<1/2?r:t<2/3?e+(r-e)*(2/3-t)*6:e}function Jn({hue:e,saturation:r,lightness:t,alpha:n}){e/=360,r/=100,t/=100;let i=0,a=0,o=0;if(!r)i=a=o=t;else{const u=t<.5?t*(1+r):t+r-t*r,c=2*t-u;i=$r(c,u,e+1/3),a=$r(c,u,e),o=$r(c,u,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:n}}const ju=(e,r,t)=>{const n=e*e,i=r*r;return Math.sqrt(Math.max(0,t*(i-n)+n))},Tu=[Gr,De,Qe],Xn=e=>Tu.find(r=>r.test(e)),Zn=(e,r)=>{let t=Xn(e),n=Xn(r),i=t.parse(e),a=n.parse(r);t===Qe&&(i=Jn(i),t=De),n===Qe&&(a=Jn(a),n=De);const o=Object.assign({},i);return u=>{for(const c in o)c!=="alpha"&&(o[c]=ju(i[c],a[c],u));return o.alpha=Lr(i.alpha,a.alpha,u),t.transform(o)}},Eu=e=>typeof e=="number",Iu=(e,r)=>t=>r(e(t)),ei=(...e)=>e.reduce(Iu);function ti(e,r){return Eu(e)?t=>Lr(e,r,t):rr.test(e)?Zn(e,r):ii(e,r)}const ri=(e,r)=>{const t=[...e],n=t.length,i=e.map((a,o)=>ti(a,r[o]));return a=>{for(let o=0;o<n;o++)t[o]=i[o](a);return t}},Du=(e,r)=>{const t=Object.assign(Object.assign({},e),r),n={};for(const i in t)e[i]!==void 0&&r[i]!==void 0&&(n[i]=ti(e[i],r[i]));return i=>{for(const a in n)t[a]=n[a](i);return t}};function ni(e){const r=Hn.parse(e),t=r.length;let n=0,i=0,a=0;for(let o=0;o<t;o++)n||typeof r[o]=="number"?n++:r[o].hue!==void 0?a++:i++;return{parsed:r,numNumbers:n,numRGB:i,numHSL:a}}const ii=(e,r)=>{const t=Hn.createTransformer(r),n=ni(e),i=ni(r);return n.numHSL===i.numHSL&&n.numRGB===i.numRGB&&n.numNumbers>=i.numNumbers?ei(ri(n.parsed,i.parsed),t):o=>`${o>0?r:e}`},Mu=(e,r)=>t=>Lr(e,r,t);function Ru(e){if(typeof e=="number")return Mu;if(typeof e=="string")return rr.test(e)?Zn:ii;if(Array.isArray(e))return ri;if(typeof e=="object")return Du}function Vu(e,r,t){const n=[],i=t||Ru(e[0]),a=e.length-1;for(let o=0;o<a;o++){let u=i(e[o],e[o+1]);if(r){const c=Array.isArray(r)?r[o]:r;u=ei(c,u)}n.push(u)}return n}function ku([e,r],[t]){return n=>t(qn(e,r,n))}function zu(e,r){const t=e.length,n=t-1;return i=>{let a=0,o=!1;if(i<=e[0]?o=!0:i>=e[n]&&(a=n-1,o=!0),!o){let c=1;for(;c<t&&!(e[c]>i||c===n);c++);a=c-1}const u=qn(e[a],e[a+1],i);return r[a](u)}}function Nu(e,r,{clamp:t=!0,ease:n,mixer:i}={}){const a=e.length;Fn(a===r.length),Fn(!n||!Array.isArray(n)||n.length===a-1),e[0]>e[a-1]&&(e=[].concat(e),r=[].concat(r),e.reverse(),r.reverse());const o=Vu(r,n,i),u=a===2?ku(e,o):zu(e,o);return t?c=>u(wu(e[0],e[a-1],c)):u}class Lu{constructor({valueRange:r,colorRange:t}){Lo(this,"mapper");this.mapper=Nu(r,t)}getColor(r){return this.mapper(r)}}function Fu(e,r){return e.type==="static"?e.staticColor:e.type==="continuous"?new Lu(e).getColor(r):"black"}function qu(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Bu(e,r){const t={};return e.forEach(({name:n,color:i,data_field:a,aggregation:o,size:u,weight:c,formatter:d})=>{const f=_u(r,a,o);let p="";["string","number"].includes(typeof f)?p=Kt.default(f).format(d):p=qu(f),t[n]=l(s.Text,{sx:{fontSize:u,display:"inline"},color:Fu(i,f),weight:c,children:p})}),t}function Gu(e){return e.split(" ").map(r=>b(Y,{children:[r,"\xA0"]}))}function $u(e){const t=e.replaceAll("<br />","<br/>").replaceAll(`
|
|
10
|
-
|
|
11
|
-
{percentage|{d}%}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{percentage:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},top:10,bottom:10,left:10,right:10}};function tl({conf:e,data:r,width:t,height:n}){const{label_field:i="name",value_field:a="value",...o}=e,u=h.default.useMemo(()=>r.map(f=>({name:f[i],value:Number(f[a])})),[r,i,a]),c=h.default.useMemo(()=>({series:{labelLayout:function(f){const p=f.labelRect.x<t/2,v=f.labelLinePoints;return v[2][0]=p?f.labelRect.x:f.labelRect.x+f.labelRect.width,{labelLinePoints:v}}}}),[t]),d=C.default.merge({},el,c,o,{series:{data:u}});return l(Qt.default,{echarts:Oe,option:d,style:{width:t,height:n}})}function rl({conf:{template:e,variables:r,align:t},data:n}){const i=h.default.useMemo(()=>Wr(e,r,n),[e,r,n]);return l(s.Text,{align:t,children:Object.values(i).map(a=>a)})}function nl({conf:e,width:r,height:t}){return!r||!t?null:l(kr.default,{readOnly:!0,value:e.content,onChange:C.default.noop,sx:{border:"none"}})}function oi(e,r,t,n){const i={width:e,height:r,data:t,conf:n.conf};switch(n.type){case"sunburst":return l(bu,{...i});case"cartesian":return l(Wu,{...i});case"table":return l(Xu,{...i});case"stats":return l(rl,{...i});case"rich-text":return l(nl,{...i});case"bar-3d":return l(Zu,{...i});case"pie":return l(tl,{...i});default:return null}}const il=["rich-text"];function ui({viz:e,data:r,loading:t}){const{ref:n,width:i,height:a}=W.useElementSize(),o=h.default.useMemo(()=>!Array.isArray(r)||r.length===0,[r]);return il.includes(e.type)?l("div",{className:"viz-root",ref:n,children:l(Zt,{children:oi(i,a,r,e)})}):t?l("div",{className:"viz-root",ref:n,children:l(s.LoadingOverlay,{visible:t,exitTransitionDuration:0})}):b("div",{className:"viz-root",ref:n,children:[o&&l(s.Text,{color:"gray",align:"center",children:"nothing to show"}),!o&&l(Zt,{children:oi(i,a,r,e)})]})}function al({}){const{data:e,loading:r,viz:t}=h.default.useContext(se);return l(ui,{viz:t,data:e,loading:r})}function ol({label:e,required:r,value:t,onChange:n,data:i,sx:a},o){const u=h.default.useMemo(()=>!Array.isArray(i)||i.length===0?[]:Object.keys(i[0]).map(d=>({label:d,value:d})),[i]);return l(s.Select,{ref:o,label:e,data:u,value:t,onChange:n,required:r,sx:a})}const Q=h.default.forwardRef(ol);function ul({conf:e,setConf:r,data:t}){const n=C.default.assign({},{x_axis_data_key:"x",y_axis_data_key:"y",z_axis_data_key:"z",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}},e),{control:i,handleSubmit:a,formState:o}=O.useForm({defaultValues:n});return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:a(r),children:[l(s.Text,{children:"X Axis"}),b(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(O.Controller,{name:"x_axis_data_key",control:i,render:({field:u})=>l(Q,{label:"Data Field",required:!0,data:t,...u})}),l(O.Controller,{name:"xAxis3D.name",control:i,render:({field:u})=>l(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(s.Text,{mt:"lg",children:"Y Axis"}),b(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(O.Controller,{name:"y_axis_data_key",control:i,render:({field:u})=>l(Q,{label:"Data Field",required:!0,data:t,...u})}),l(O.Controller,{name:"yAxis3D.name",control:i,render:({field:u})=>l(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(s.Text,{mt:"lg",children:"Z Axis"}),b(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(O.Controller,{name:"z_axis_data_key",control:i,render:({field:u})=>l(Q,{label:"Data Field",required:!0,data:t,...u})}),l(O.Controller,{name:"zAxis3D.name",control:i,render:({field:u})=>l(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:b(s.Button,{color:"blue",type:"submit",children:[l(_.DeviceFloppy,{size:20}),l(s.Text,{ml:"md",children:"Save"})]})})]})})}function ll({value:e,onChange:r},t){const n=s.useMantineTheme(),i=h.default.useMemo(()=>Object.entries(n.colors).map(([o,u])=>({label:o,value:u[6]})),[n]),a=h.default.useMemo(()=>i.some(o=>o.value===e),[e,i]);return b(s.Group,{position:"apart",spacing:4,children:[l(s.TextInput,{placeholder:"Set any color",value:a?"":e,onChange:o=>r(o.currentTarget.value),rightSection:l(s.ColorSwatch,{color:a?"transparent":e,radius:4}),variant:a?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),l(s.Text,{sx:{flexGrow:0},children:"or"}),l(s.Select,{data:i,value:e,onChange:r,variant:a?"default":"filled",placeholder:"Pick a theme color",icon:l(s.ColorSwatch,{color:a?e:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const Yr=h.default.forwardRef(ll);function sl({control:e,index:r}){return b(s.Group,{grow:!0,align:"top",children:[l(O.Controller,{name:`series.${r}.stack`,control:e,render:({field:t})=>l(s.TextInput,{label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1},...t})}),l(O.Controller,{name:`series.${r}.barWidth`,control:e,render:({field:t})=>l(s.TextInput,{label:"Bar Width",sx:{flexGrow:1},...t})})]})}const cl=[{label:"off",value:"false"},{label:"start",value:"start"},{label:"middle",value:"middle"},{label:"end",value:"end"}];function fl({control:e,index:r}){return b(s.Group,{grow:!0,align:"center",children:[l(O.Controller,{name:`series.${r}.step`,control:e,render:({field:t})=>l(s.Select,{label:"Step",data:cl,sx:{flexGrow:1,maxWidth:"48%"},...t,value:String(t.value),onChange:n=>{const i=n==="false"?!1:n;t.onChange(i)}})}),l(O.Controller,{name:`series.${r}.smooth`,control:e,render:({field:t})=>l(s.Box,{sx:{flexGrow:1},children:l(s.Switch,{label:"Smooth Line",checked:t.value,onChange:n=>t.onChange(n.currentTarget.checked)})})})]})}const dl=Array.from(new Array(9),(e,r)=>({label:String(r+1),value:r+1}));function pl({control:e,index:r}){return l(s.Group,{grow:!0,align:"center",children:l(O.Controller,{name:`series.${r}.symbolSize`,control:e,render:({field:t})=>b(s.Stack,{sx:{flexGrow:1},pb:16,spacing:4,children:[l(s.Text,{size:"sm",children:"Size"}),l(s.Slider,{min:1,max:10,marks:dl,...t,sx:{width:"100%"}})]})})})}const hl=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function bl({control:e,index:r,remove:t,seriesItem:n,yAxisOptions:i,data:a}){const o=n.type;return b(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[l(s.Stack,{children:l(O.Controller,{name:`series.${r}.type`,control:e,render:({field:u})=>l(s.SegmentedControl,{data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter"},{label:"Boxplot",value:"boxplot",disabled:!0}],...u})})}),l(O.Controller,{name:`series.${r}.name`,control:e,render:({field:u})=>l(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...u})}),b(s.Group,{grow:!0,noWrap:!0,children:[l(O.Controller,{name:`series.${r}.y_axis_data_key`,control:e,render:({field:u})=>l(Q,{label:"Value Field",required:!0,data:a,sx:{flex:1},...u})}),l(O.Controller,{name:`series.${r}.yAxisIndex`,control:e,render:({field:{value:u,onChange:c,...d}})=>{var f;return l(s.Select,{label:"Y Axis",data:i,disabled:i.length===0,...d,value:(f=u==null?void 0:u.toString())!=null?f:"",onChange:p=>{if(!p){c(0);return}c(Number(p))},sx:{flex:1}})}})]}),o==="line"&&l(fl,{index:r,control:e}),o==="bar"&&l(sl,{index:r,control:e}),o==="scatter"&&l(pl,{index:r,control:e}),l(O.Controller,{name:`series.${r}.label_position`,control:e,render:({field:u})=>l(s.Select,{label:"Label Position",data:hl,...u})}),b(s.Stack,{spacing:4,children:[l(s.Text,{size:"sm",children:"Color"}),l(O.Controller,{name:`series.${r}.color`,control:e,render:({field:u})=>l(Yr,{...u})})]}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t(r),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},r)}function vl({control:e,watch:r,getValues:t,data:n}){const{fields:i,append:a,remove:o}=O.useFieldArray({control:e,name:"series"}),u=r("series"),c=i.map((p,v)=>({...p,...u[v]})),d=()=>a({type:"bar",name:W.randomId(),showSymbol:!1,symbolSize:5,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",stack:"",color:"#000",step:!1,smooth:!1}),f=h.default.useMemo(()=>t().y_axes.map(({name:p},v)=>({label:p,value:v.toString()})),[t]);return b(s.Stack,{children:[c.map((p,v)=>l(bl,{control:e,index:v,remove:o,seriesItem:p,yAxisOptions:f,data:n})),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:d,children:"Add a Series"})})]})}const li={mantissa:0,output:"number"};function ml({value:e,onChange:r},t){const n=o=>{r({...e,output:o})},i=o=>{const u=o===0?!1:e.trimMantissa;r({...e,mantissa:o,trimMantissa:u})},a=o=>{r({...e,trimMantissa:o.currentTarget.checked})};return l(s.Stack,{ref:t,children:b(s.Group,{grow:!0,children:[l(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:n}),l(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:i}),l(s.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:a,disabled:e.mantissa===0})]})})}const si=h.default.forwardRef(ml);function yl({control:e,index:r,remove:t}){return b(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[l(s.Group,{grow:!0,noWrap:!0,children:l(O.Controller,{name:`y_axes.${r}.name`,control:e,render:({field:n})=>l(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...n})})}),l(s.Stack,{children:l(O.Controller,{name:`y_axes.${r}.label_formatter`,control:e,render:({field:n})=>l(si,{...n})})}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t(r),sx:{position:"absolute",top:15,right:5},disabled:r===0,children:l(_.Trash,{size:16})})]},r)}function gl({control:e,watch:r}){const{fields:t,append:n,remove:i}=O.useFieldArray({control:e,name:"y_axes"}),a=r("y_axes"),o=t.map((c,d)=>({...c,...a[d]})),u=()=>n({name:"",label_formatter:li});return b(s.Stack,{children:[o.map((c,d)=>l(yl,{control:e,index:d,remove:i})),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:u,children:"Add a Y Axis"})})]})}const _l=[{label:"Linear",value:"linear"},{label:"Exponential",value:"exponential"},{label:"Logarithmic",value:"logarithmic"},{label:"Polynomial",value:"polynomial"}];function wl({control:e,regressionItem:r,index:t,remove:n,yAxisOptions:i,data:a}){const o=r.transform.config.method;return b(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[l(O.Controller,{name:`regressions.${t}.name`,control:e,render:({field:u})=>l(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...u})}),b(s.Group,{grow:!0,noWrap:!0,children:[l(O.Controller,{name:`regressions.${t}.y_axis_data_key`,control:e,render:({field:u})=>l(Q,{label:"Value Field",required:!0,data:a,sx:{flex:1},...u})}),l(O.Controller,{name:`regressions.${t}.plot.yAxisIndex`,control:e,render:({field:{value:u,onChange:c,...d}})=>{var f;return l(s.Select,{label:"Y Axis",data:i,disabled:i.length===0,...d,value:(f=u==null?void 0:u.toString())!=null?f:"",onChange:p=>{if(!p){c(0);return}c(Number(p))},sx:{flex:1}})}})]}),b(s.Group,{grow:!0,noWrap:!0,children:[l(O.Controller,{name:`regressions.${t}.transform.config.method`,control:e,render:({field:u})=>l(s.Select,{label:"Method",data:_l,sx:{flex:1},...u})}),o==="polynomial"&&l(O.Controller,{name:`regressions.${t}.transform.config.order`,control:e,render:({field:u})=>l(s.NumberInput,{label:"Order",sx:{flex:1},...u})})]}),b(s.Stack,{spacing:4,children:[l(s.Text,{size:"sm",children:"Color"}),l(O.Controller,{name:`regressions.${t}.plot.color`,control:e,render:({field:u})=>l(Yr,{...u})})]}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>n(t),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},t)}function Sl({control:e,watch:r,getValues:t,data:n}){const{fields:i,append:a,remove:o}=O.useFieldArray({control:e,name:"regressions"}),u=r("regressions"),c=i.map((p,v)=>({...p,...u[v]})),d=h.default.useMemo(()=>t().y_axes.map(({name:p},v)=>({label:p,value:v.toString()})),[t]),f=()=>a({transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},name:"",y_axis_data_key:"",plot:{type:"line",yAxisIndex:0,color:"#666666"}});return b(s.Stack,{children:[c.map((p,v)=>l(wl,{regressionItem:p,control:e,index:v,remove:o,yAxisOptions:d,data:n})),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:f,children:"Add a Regression Line"})})]})}const Ol=[{label:"None",value:"none"},{label:"Sum",value:"sum"},{label:"Mean",value:"mean"},{label:"Median",value:"median"},{label:"Max",value:"max"},{label:"Min",value:"min"}];function xl({label:e,value:r,onChange:t},n){return l(s.Select,{ref:n,label:e,data:Ol,value:r,onChange:t})}const Pl=h.default.forwardRef(xl);function Cl({label:e,value:r,onChange:t},n){const[i,a]=h.default.useState(Array.isArray(r)?[...r]:[]),o=h.default.useCallback(()=>{a(v=>[...v,""])},[a]),u=h.default.useCallback(v=>{a(y=>(y.splice(v,1),[...y]))},[a]),c=h.default.useMemo(()=>!C.default.isEqual(i,r),[i,r]),d=()=>{t(i.map(v=>v.toString()))},f=s.useMantineTheme(),p=h.default.useMemo(()=>Object.entries(f.colors).map(([v,y])=>y[6]),[f]);return b(Y,{children:[b(s.Group,{position:"left",ref:n,children:[l(s.Text,{children:e}),l(s.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!c,onClick:d,children:l(_.DeviceFloppy,{size:20})})]}),b(s.Group,{children:[i.map((v,y)=>l(s.ColorInput,{value:v,onChange:P=>{a(j=>(j.splice(y,1,P),[...j]))},swatches:p,rightSection:l(s.ActionIcon,{onClick:()=>u(y),color:"red",children:l(_.Trash,{size:14})}),sx:{width:"45%"}})),l(s.ActionIcon,{onClick:o,color:"blue",variant:"outline",children:l(_.PlaylistAdd,{size:20})})]})]})}const Al=h.default.forwardRef(Cl),nr=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function jl({label:e,value:r,onChange:t},n){var o,u;const[i,a]=h.default.useState((u=(o=nr.find(c=>c.label===r))==null?void 0:o.value)!=null?u:nr[0].value);return h.default.useEffect(()=>{const c=nr.find(d=>d.value===i);c&&t(c.label)},[i]),b(s.Stack,{spacing:0,mt:"sm",mb:"lg",children:[l(s.Text,{size:"sm",children:e}),l(s.Slider,{label:null,marks:nr,value:i,onChange:a,step:25,placeholder:"Pick a font size",ref:n})]})}const Tl=h.default.forwardRef(jl);function El({label:e,value:r,onChange:t},n){const[i,a]=h.default.useState(Array.isArray(r)?[...r]:[]),o=h.default.useCallback(()=>{a(f=>[...f,""])},[a]),u=h.default.useCallback(f=>{a(p=>(p.splice(f,1),[...p]))},[a]),c=h.default.useMemo(()=>!C.default.isEqual(i,r),[i,r]),d=()=>{t(i.map(f=>f.toString()))};return b(Y,{children:[b(s.Group,{position:"left",ref:n,children:[l(s.Text,{children:e}),l(s.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!c,onClick:d,children:l(_.DeviceFloppy,{size:20})})]}),b(s.Group,{children:[i.map((f,p)=>l(s.TextInput,{value:f,onChange:v=>{const y=v.currentTarget.value;a(P=>(P.splice(p,1,y),[...P]))},rightSection:l(s.ActionIcon,{onClick:()=>u(p),color:"red",children:l(_.Trash,{size:14})}),sx:{width:"45%"}})),l(s.ActionIcon,{onClick:o,color:"blue",variant:"outline",children:l(_.PlaylistAdd,{size:20})})]})]})}const Il=h.default.forwardRef(El);function ci(){return{name:W.randomId(),size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:"none",formatter:{output:"number",mantissa:0}}}const Qr=h.default.forwardRef(function({value:r,onChange:t,...n},i){return l(s.TextInput,{ref:i,value:r,onChange:t,...n})}),fi=h.default.forwardRef(function({value:r,onChange:t,data:n},i){const a=r.color.type,o=(u,c)=>{const d=C.default.cloneDeep(r);C.default.set(d,u,c),t(d)};return b(s.Box,{px:"sm",py:"md",children:[l(s.Text,{weight:"bold",pb:0,children:r.name}),l(s.Divider,{my:"xs",label:"Data",labelPosition:"center"}),b(s.Group,{grow:!0,noWrap:!0,children:[l(s.TextInput,{label:"Name",required:!0,value:r.name,onChange:u=>o("name",u.currentTarget.value)}),l(Q,{label:"Data Field",required:!0,data:n,value:r.data_field,onChange:u=>o("data_field",u)}),l(Pl,{label:"Aggregation",value:r.aggregation,onChange:u=>o("aggregation",u)})]}),l(si,{value:r.formatter,onChange:u=>o("formatter",u)}),l(s.Divider,{my:"xs",label:"Typography",labelPosition:"center"}),l(s.Stack,{children:l(s.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},value:r.size,onChange:u=>o("size",u.currentTarget.value)})}),l(s.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:l(Tl,{label:"Font Weight",value:r.weight,onChange:u=>o("weight",u)})}),l(s.Divider,{my:"xs",label:"Style",labelPosition:"center"}),b(s.Stack,{children:[l(s.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:r.color.type,onChange:u=>o("color.type",u)}),a==="static"&&l(Yr,{value:r.color.staticColor,onChange:u=>o("color.staticColor",u)}),a==="continuous"&&b(Y,{children:[l(Il,{label:"Value Range",value:r.color.valueRange,onChange:u=>o("color.valueRange",u)}),l(Al,{label:"Color Range",value:r.color.colorRange,onChange:u=>o("color.colorRange",u)})]})]})]})});function Dl({control:e,index:r,remove:t,data:n}){return b(s.Stack,{my:"sm",p:0,sx:{border:"1px solid #eee",borderTopColor:"#333",borderTopWidth:2,position:"relative"},children:[l(O.Controller,{name:`stats.variables.${r}`,control:e,render:({field:i})=>l(fi,{data:n,...i})}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t(r),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},r)}function Ml({control:e,watch:r,data:t}){const{fields:n,append:i,remove:a}=O.useFieldArray({control:e,name:"stats.variables"});r("stats.templates");const o=r("stats.variables"),u=n.map((d,f)=>({...d,...o[f]})),c=()=>i(ci());return b(s.Stack,{children:[b(s.Stack,{spacing:0,children:[l(O.Controller,{name:"stats.templates.top",control:e,render:({field:d})=>l(Qr,{label:"Template for stats above the chart",py:"md",sx:{flexGrow:1},...d})}),l(O.Controller,{name:"stats.templates.bottom",control:e,render:({field:d})=>l(Qr,{label:"Template for stats under the chart",py:"md",sx:{flexGrow:1},...d})})]}),u.map((d,f)=>l(Dl,{control:e,index:f,remove:a,data:t})),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:c,children:"Add a Variable"})})]})}function Rl(e){function r({type:t,name:n,showSymbol:i,symbolSize:a=5,y_axis_data_key:o="value",yAxisIndex:u=0,label_position:c="top",stack:d="1",color:f="black",barWidth:p="30",smooth:v=!1,step:y=!1}){return{type:t,name:n,showSymbol:i,symbolSize:a,y_axis_data_key:o,yAxisIndex:u,label_position:c,stack:d,color:f,barWidth:p,smooth:v,step:y}}return e.map(r)}function Vl(e){return e||{templates:{top:"",bottom:""},variables:[]}}function kl({conf:e,setConf:r,data:t}){const{series:n,y_axes:i,...a}=e,o=h.default.useMemo(()=>{const{x_axis_name:y="",stats:P,...j}=a;return{series:Rl(n!=null?n:[]),x_axis_name:y,y_axes:i!=null?i:[{name:"Y Axis",label_formatter:li}],stats:Vl(P),...j}},[n,a]);h.default.useEffect(()=>{!C.default.isEqual(e,o)&&r(o)},[e,o]);const{control:u,handleSubmit:c,watch:d,getValues:f}=O.useForm({defaultValues:o});d(["x_axis_data_key","x_axis_name"]);const p=f(),v=h.default.useMemo(()=>!C.default.isEqual(p,e),[p,e]);return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:c(r),children:[b(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(s.Text,{children:"Chart Config"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!v,children:l(_.DeviceFloppy,{size:20})})]}),b(s.Accordion,{multiple:!0,value:["X Axis","Y Axes"],children:[l(s.Accordion.Item,{value:"X Axis",children:b(s.Group,{grow:!0,noWrap:!0,children:[l(O.Controller,{name:"x_axis_data_key",control:u,render:({field:y})=>l(Q,{label:"X Axis Data Field",required:!0,data:t,sx:{flex:1},...y})}),l(O.Controller,{name:"x_axis_name",control:u,render:({field:y})=>l(s.TextInput,{label:"X Axis Name",sx:{flex:1},...y})})]})}),l(s.Accordion.Item,{value:"Y Axes",children:l(gl,{control:u,watch:d})}),l(s.Accordion.Item,{value:"Series",children:l(vl,{control:u,watch:d,getValues:f,data:t})}),l(s.Accordion.Item,{value:"Regression Lines",children:l(Sl,{control:u,watch:d,getValues:f,data:t})}),l(s.Accordion.Item,{value:"Stats",children:l(Ml,{control:u,watch:d,data:t})})]})]})})}function zl({conf:{label_field:e,value_field:r},setConf:t,data:n}){const i=St.useForm({initialValues:{label_field:e,value_field:r}});return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:i.onSubmit(t),children:[b(s.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[l(s.Text,{children:"Pie Config"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:l(_.DeviceFloppy,{size:20})})]}),b(s.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[l(Q,{label:"Label Field",required:!0,data:n,...i.getInputProps("label_field")}),l(Q,{label:"Value Field",required:!0,data:n,...i.getInputProps("value_field")})]})]})})}function Nl({conf:e,setConf:r}){const t=h.default.useMemo(()=>{const{content:d=""}=e;return{content:d}},[e]);h.default.useEffect(()=>{!C.default.isEqual(e,t)&&r(t)},[e,t]);const{control:n,handleSubmit:i,watch:a,getValues:o}=O.useForm({defaultValues:t});a("content");const u=o(),c=h.default.useMemo(()=>!C.default.isEqual(u,e),[u,e]);return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:i(r),children:[b(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(s.Text,{children:"Content"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!c,children:l(_.DeviceFloppy,{size:20})})]}),l(O.Controller,{name:"content",control:n,render:({field:d})=>l(kr.default,{sx:{flex:1},...d})})]})})}function Ll(e){if("variables"in e)return e;const{align:r,size:t,weight:n,color:i,content:{prefix:a="",data_field:o="value",formatter:u={output:"number",mantissa:0},postfix:c=""}={}}=e;return{align:r,template:`${a} \${value} ${c}`,variables:[{name:"value",data_field:o,aggregation:"none",formatter:u,color:i,weight:n,size:t}]}}function Fl({control:e,index:r,remove:t,data:n}){return b(s.Stack,{my:"sm",p:0,sx:{border:"1px solid #eee",borderTopColor:"#333",borderTopWidth:2,position:"relative"},children:[l(O.Controller,{name:`variables.${r}`,control:e,render:({field:i})=>l(fi,{data:n,...i})}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t(r),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},r)}function ql({control:e,watch:r,data:t}){const{fields:n,append:i,remove:a}=O.useFieldArray({control:e,name:"variables"}),o=r("variables"),u=n.map((d,f)=>({...d,...o[f]})),c=()=>i(ci());return b(s.Stack,{children:[u.map((d,f)=>l(Fl,{control:e,index:f,remove:a,data:t})),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:c,children:"Add a Variable"})})]})}function Bl(){return{align:"center",template:"The variable ${value} is defined in Variables section",variables:[{name:"value",size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:"none",formatter:{output:"number",mantissa:0}}]}}function Gl({conf:e,setConf:r,data:t}){const n=h.default.useMemo(()=>{const{align:f,template:p="",variables:v=[]}=Ll(e);return f?{variables:v,template:p,align:f}:Bl()},[e]);h.default.useEffect(()=>{!C.default.isEqual(e,n)&&r(n)},[e,n]);const{control:i,handleSubmit:a,watch:o,getValues:u}=O.useForm({defaultValues:n});o(["variables","template"]);const c=u(),d=h.default.useMemo(()=>!C.default.isEqual(c,e),[c,e]);return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:a(r),children:[b(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(s.Text,{weight:500,children:"Stats Configurations"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!d,children:l(_.DeviceFloppy,{size:20})})]}),l(O.Controller,{name:"template",control:i,render:({field:f})=>l(Qr,{label:"Template",py:"md",sx:{flexGrow:1},...f})}),l(s.Text,{pb:"sm",pt:"md",size:"sm",children:"Variables"}),l(ql,{control:i,watch:o,data:t})]})})}function $l({conf:{label_field:e,value_field:r},setConf:t,data:n}){const i=St.useForm({initialValues:{label_field:e,value_field:r}});return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:i.onSubmit(t),children:[b(s.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[l(s.Text,{children:"Sunburst Config"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:l(_.DeviceFloppy,{size:20})})]}),b(s.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[l(Q,{label:"Label Field",required:!0,data:n,...i.getInputProps("label_field")}),l(Q,{label:"Value Field",required:!0,data:n,...i.getInputProps("value_field")})]})]})})}const Ul=Object.values(Me).map(e=>({label:e,value:e}));function Wl({label:e,value:r,onChange:t,sx:n}){return l(s.Select,{label:e,data:Ul,value:r,onChange:t,sx:n})}function Yl({conf:{columns:e,...r},setConf:t,data:n}){const i=St.useForm({initialValues:{id_field:"id",use_raw_columns:!0,columns:e!=null?e:[],fontSize:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1,...r}}),a=()=>i.insertListItem("columns",{label:W.randomId(),value_field:"value",value_type:Me.string});return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:i.onSubmit(t),children:[b(s.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[l(s.Text,{children:"Table Config"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:l(_.DeviceFloppy,{size:20})})]}),b(s.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[l(Q,{label:"ID Field",required:!0,data:n,...i.getInputProps("id_field")}),b(s.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[l(s.TextInput,{label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...i.getInputProps("horizontalSpacing")}),l(s.TextInput,{label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...i.getInputProps("verticalSpacing")})]}),l(s.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:l(s.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...i.getInputProps("fontSize")})}),b(s.Stack,{children:[l(s.Text,{children:"Other"}),b(s.Group,{position:"apart",grow:!0,children:[l(s.Switch,{label:"Striped",...i.getInputProps("striped",{type:"checkbox"})}),l(s.Switch,{label:"Highlight on hover",...i.getInputProps("highlightOnHover",{type:"checkbox"})})]})]})]}),b(s.Stack,{mt:"xs",spacing:"xs",p:"md",mb:"xl",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[l(s.Switch,{label:"Use Original Data Columns",...i.getInputProps("use_raw_columns",{type:"checkbox"})}),!i.values.use_raw_columns&&b(s.Stack,{children:[l(s.Text,{mt:"xl",mb:0,children:"Custom Columns"}),i.values.columns.map((o,u)=>b(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[b(s.Group,{position:"apart",grow:!0,children:[l(s.TextInput,{label:"Label",required:!0,sx:{flex:1},...i.getInputProps(`columns.${u}.label`)}),l(Q,{label:"Value Field",required:!0,data:n,...i.getInputProps(`columns.${u}.value_field`)}),l(Wl,{label:"Value Type",sx:{flex:1},...i.getInputProps(`columns.${u}.value_type`)})]}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>i.removeListItem("columns",u),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},u)),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:a,children:"Add a Column"})})]})]}),l(s.Text,{weight:500,mb:"md",children:"Current Configuration:"}),l($e.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const Kr=[{value:"stats",label:"Stats",Panel:Gl},{value:"rich-text",label:"Rich Text",Panel:Nl},{value:"table",label:"Table",Panel:Yl},{value:"sunburst",label:"Sunburst",Panel:$l},{value:"bar-3d",label:"Bar Chart (3D)",Panel:ul},{value:"cartesian",label:"Cartesian Chart",Panel:kl},{value:"pie",label:"Pie Chart",Panel:zl}];function Ql(){const{data:e,viz:r,setViz:t}=h.default.useContext(se),[n,i]=W.useInputState(r.type),a=r.type!==n,o=h.default.useCallback(()=>{!a||t(f=>({...f,type:n}))},[a,n]),u=f=>{t(p=>({...p,conf:f}))},c=f=>{try{u(JSON.parse(f))}catch(p){console.error(p)}},d=h.default.useMemo(()=>{var f;return(f=Kr.find(p=>p.value===n))==null?void 0:f.Panel},[n,Kr]);return b(Y,{children:[l(s.Select,{label:"Visualization",value:n,onChange:i,data:Kr,rightSection:l(s.ActionIcon,{disabled:!a,onClick:o,children:l(_.DeviceFloppy,{size:20})})}),d&&l(d,{conf:r.conf,setConf:u,data:e}),!d&&l(s.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(r.conf,null,2),onChange:c})]})}function Kl({}){return b(s.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[l(s.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0},children:l(Ql,{})}),l(s.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:l(al,{})})]})}function Hl({opened:e,close:r}){const{freezeLayout:t}=h.default.useContext(be),{data:n,loading:i,viz:a,title:o}=h.default.useContext(se);return h.default.useEffect(()=>{t(e)},[e]),l(s.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:o,trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:l(s.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:"16px"}},padding:"md",children:b(s.Tabs,{defaultValue:"Visualization",children:[b(s.Tabs.List,{children:[l(s.Tabs.Tab,{value:"Data",children:"Data"}),l(s.Tabs.Tab,{value:"Panel",children:"Panel"}),l(s.Tabs.Tab,{value:"Visualization",children:"Visualization"})]}),b(s.Tabs.Panel,{value:"Data",pt:"sm",children:[l(s.LoadingOverlay,{visible:i,exitTransitionDuration:0}),l(pu,{})]}),l(s.Tabs.Panel,{value:"Panel",pt:"sm",children:l(du,{})}),l(s.Tabs.Panel,{value:"Visualization",pt:"sm",children:l(Kl,{})})]})})})}var Bp="";function Jl({}){const e=Vr.useModals(),[r,t]=h.default.useState(!1),n=()=>t(!0),i=()=>t(!1),{id:a,title:o,refreshData:u}=h.default.useContext(se),{inEditMode:c}=h.default.useContext(be),{duplidatePanel:d,removePanelByID:f,viewPanelInFullScreen:p,inFullScreen:v}=h.default.useContext(Ht),y=h.default.useCallback(()=>{d(a)},[d,a]),P=()=>e.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>f(a)}),j=h.default.useCallback(()=>{p(a)},[a,p]);return b(s.Box,{sx:{position:"relative"},children:[l(s.Box,{sx:{position:"absolute",left:0,top:0,height:28},children:l(Nn,{})}),l(s.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:b(s.Menu,{children:[l(s.Menu.Target,{children:l(s.Text,{lineClamp:1,weight:"bold",children:o})}),b(s.Menu.Dropdown,{children:[l(s.Menu.Item,{onClick:u,icon:l(_.Refresh,{size:14}),children:"Refresh"}),!v&&l(s.Menu.Item,{onClick:j,icon:l(_.ArrowsMaximize,{size:14}),children:"Full Screen"}),c&&b(Y,{children:[l(s.Divider,{label:"Edit",labelPosition:"center"}),l(s.Menu.Item,{onClick:n,icon:l(_.Settings,{size:14}),children:"Settings"}),l(s.Menu.Item,{onClick:y,icon:l(_.Copy,{size:14}),children:"Duplicate"}),l(s.Menu.Item,{color:"red",onClick:P,icon:l(_.Trash,{size:14}),children:"Delete"})]})]})]})}),c&&l(Hl,{opened:r,close:i})]})}var Gp="";function ir({viz:e,queryID:r,title:t,description:n,update:i,layout:a,id:o}){const u=h.default.useContext(Ie),c=h.default.useContext(Ye),d=h.default.useContext(ce),[f,p]=h.default.useState(t),[v,y]=h.default.useState(n),[P,j]=h.default.useState(r),[I,$]=h.default.useState(e),he=h.default.useMemo(()=>{if(!!P)return d.queries.find(_t=>_t.id===P)},[P,d.queries]);h.default.useEffect(()=>{i==null||i({id:o,layout:a,title:f,description:v,queryID:P,viz:I})},[f,v,he,I,o,a,P]);const{data:Z=[],loading:k,refresh:U}=Be.useRequest(Mn({context:u,definitions:d,filterValues:c,title:f,query:he}),{refreshDeps:[u,d,he,c]}),ee=U;return l(se.Provider,{value:{id:o,data:Z,loading:k,title:f,setTitle:p,description:v,setDescription:y,queryID:P,setQueryID:j,viz:I,setViz:$,refreshData:ee},children:b(s.Container,{className:"panel-root",children:[l(Jl,{}),l(ui,{viz:I,data:Z,loading:k})]})})}var $p="";const Xl=Rr.WidthProvider(In.default);function di({panels:e,setPanels:r,className:t="layout",rowHeight:n=10,isDraggable:i,isResizable:a}){const o=h.default.useCallback(u=>{const c=new Map;u.forEach(({i:f,...p})=>{c.set(f,p)});const d=e.map(f=>({...f,layout:c.get(f.id)}));r(d)},[e,r]);return l(Xl,{onLayoutChange:o,className:`dashboard-layout ${t}`,rowHeight:n,isDraggable:i,isResizable:a,children:e.map(({id:u,...c},d)=>l("div",{"data-grid":c.layout,children:l(ir,{id:u,...c,update:f=>{r(p=>(p.splice(d,1,f),[...p]))}})},u))})}function Hr(e,r){return b(s.Text,{size:"xs",sx:{svg:{verticalAlign:"bottom"}},children:[e," ",r]})}function Zl({mode:e,setMode:r}){return l(s.SegmentedControl,{size:"xs",value:e,onChange:r,data:[{label:Hr(l(_.PlayerPlay,{size:20}),"Use"),value:le.Use},{label:Hr(l(_.Resize,{size:20}),"Edit Layout"),value:le.Layout},{label:Hr(l(_.Paint,{size:20}),"Edit Content"),value:le.Edit}]})}const es=`
|
|
9
|
+
*/var pr;function Zn(){if(pr)return pt;pr=1;var t=W.default,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function o(i,d,g){var m,p={},b=null,h=null;g!==void 0&&(b=""+g),d.key!==void 0&&(b=""+d.key),d.ref!==void 0&&(h=d.ref);for(m in d)s.call(d,m)&&!l.hasOwnProperty(m)&&(p[m]=d[m]);if(i&&i.defaultProps)for(m in d=i.defaultProps,d)p[m]===void 0&&(p[m]=d[m]);return{$$typeof:e,type:i,key:b,ref:h,props:p,_owner:a.current}}return pt.Fragment=r,pt.jsx=o,pt.jsxs=o,pt}var mt={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var mr;function Yn(){return mr||(mr=1,process.env.NODE_ENV!=="production"&&function(){var t=W.default,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),E=Symbol.iterator,v="@@iterator";function S(D){if(D===null||typeof D!="object")return null;var te=E&&D[E]||D[v];return typeof te=="function"?te:null}var _=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function z(D){{for(var te=arguments.length,oe=new Array(te>1?te-1:0),ve=1;ve<te;ve++)oe[ve-1]=arguments[ve];I("error",D,oe)}}function I(D,te,oe){{var ve=_.ReactDebugCurrentFrame,Ee=ve.getStackAddendum();Ee!==""&&(te+="%s",oe=oe.concat([Ee]));var Te=oe.map(function(ke){return String(ke)});Te.unshift("Warning: "+te),Function.prototype.apply.call(console[D],console,Te)}}var M=!1,F=!1,Y=!1,$=!1,ee=!1,G;G=Symbol.for("react.module.reference");function ne(D){return!!(typeof D=="string"||typeof D=="function"||D===s||D===l||ee||D===a||D===g||D===m||$||D===h||M||F||Y||typeof D=="object"&&D!==null&&(D.$$typeof===b||D.$$typeof===p||D.$$typeof===o||D.$$typeof===i||D.$$typeof===d||D.$$typeof===G||D.getModuleId!==void 0))}function ce(D,te,oe){var ve=D.displayName;if(ve)return ve;var Ee=te.displayName||te.name||"";return Ee!==""?oe+"("+Ee+")":oe}function A(D){return D.displayName||"Context"}function U(D){if(D==null)return null;if(typeof D.tag=="number"&&z("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof D=="function")return D.displayName||D.name||null;if(typeof D=="string")return D;switch(D){case s:return"Fragment";case r:return"Portal";case l:return"Profiler";case a:return"StrictMode";case g:return"Suspense";case m:return"SuspenseList"}if(typeof D=="object")switch(D.$$typeof){case i:var te=D;return A(te)+".Consumer";case o:var oe=D;return A(oe._context)+".Provider";case d:return ce(D,D.render,"ForwardRef");case p:var ve=D.displayName||null;return ve!==null?ve:U(D.type)||"Memo";case b:{var Ee=D,Te=Ee._payload,ke=Ee._init;try{return U(ke(Te))}catch{return null}}}return null}var f=Object.assign,j=0,ge,H,y,w,O,x,C;function R(){}R.__reactDisabledLog=!0;function L(){{if(j===0){ge=console.log,H=console.info,y=console.warn,w=console.error,O=console.group,x=console.groupCollapsed,C=console.groupEnd;var D={configurable:!0,enumerable:!0,value:R,writable:!0};Object.defineProperties(console,{info:D,log:D,warn:D,error:D,group:D,groupCollapsed:D,groupEnd:D})}j++}}function B(){{if(j--,j===0){var D={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:f({},D,{value:ge}),info:f({},D,{value:H}),warn:f({},D,{value:y}),error:f({},D,{value:w}),group:f({},D,{value:O}),groupCollapsed:f({},D,{value:x}),groupEnd:f({},D,{value:C})})}j<0&&z("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Z=_.ReactCurrentDispatcher,K;function re(D,te,oe){{if(K===void 0)try{throw Error()}catch(Ee){var ve=Ee.stack.trim().match(/\n( *(at )?)/);K=ve&&ve[1]||""}return`
|
|
18
|
+
`+K+D}}var me=!1,fe;{var he=typeof WeakMap=="function"?WeakMap:Map;fe=new he}function _e(D,te){if(!D||me)return"";{var oe=fe.get(D);if(oe!==void 0)return oe}var ve;me=!0;var Ee=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Te;Te=Z.current,Z.current=null,L();try{if(te){var ke=function(){throw Error()};if(Object.defineProperty(ke.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ke,[])}catch(Xe){ve=Xe}Reflect.construct(D,[],ke)}else{try{ke.call()}catch(Xe){ve=Xe}D.call(ke.prototype)}}else{try{throw Error()}catch(Xe){ve=Xe}D()}}catch(Xe){if(Xe&&ve&&typeof Xe.stack=="string"){for(var xe=Xe.stack.split(`
|
|
19
|
+
`),Re=ve.stack.split(`
|
|
20
|
+
`),Oe=xe.length-1,Pe=Re.length-1;Oe>=1&&Pe>=0&&xe[Oe]!==Re[Pe];)Pe--;for(;Oe>=1&&Pe>=0;Oe--,Pe--)if(xe[Oe]!==Re[Pe]){if(Oe!==1||Pe!==1)do if(Oe--,Pe--,Pe<0||xe[Oe]!==Re[Pe]){var Ue=`
|
|
21
|
+
`+xe[Oe].replace(" at new "," at ");return D.displayName&&Ue.includes("<anonymous>")&&(Ue=Ue.replace("<anonymous>",D.displayName)),typeof D=="function"&&fe.set(D,Ue),Ue}while(Oe>=1&&Pe>=0);break}}}finally{me=!1,Z.current=Te,B(),Error.prepareStackTrace=Ee}var ft=D?D.displayName||D.name:"",Fn=ft?re(ft):"";return typeof D=="function"&&fe.set(D,Fn),Fn}function ze(D,te,oe){return _e(D,!1)}function u(D){var te=D.prototype;return!!(te&&te.isReactComponent)}function Q(D,te,oe){if(D==null)return"";if(typeof D=="function")return _e(D,u(D));if(typeof D=="string")return re(D);switch(D){case g:return re("Suspense");case m:return re("SuspenseList")}if(typeof D=="object")switch(D.$$typeof){case d:return ze(D.render);case p:return Q(D.type,te,oe);case b:{var ve=D,Ee=ve._payload,Te=ve._init;try{return Q(Te(Ee),te,oe)}catch{}}}return""}var V=Object.prototype.hasOwnProperty,T={},k=_.ReactDebugCurrentFrame;function P(D){if(D){var te=D._owner,oe=Q(D.type,D._source,te?te.type:null);k.setExtraStackFrame(oe)}else k.setExtraStackFrame(null)}function J(D,te,oe,ve,Ee){{var Te=Function.call.bind(V);for(var ke in D)if(Te(D,ke)){var xe=void 0;try{if(typeof D[ke]!="function"){var Re=Error((ve||"React class")+": "+oe+" type `"+ke+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof D[ke]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Re.name="Invariant Violation",Re}xe=D[ke](te,ke,ve,oe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Oe){xe=Oe}xe&&!(xe instanceof Error)&&(P(Ee),z("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ve||"React class",oe,ke,typeof xe),P(null)),xe instanceof Error&&!(xe.message in T)&&(T[xe.message]=!0,P(Ee),z("Failed %s type: %s",oe,xe.message),P(null))}}}var X=Array.isArray;function q(D){return X(D)}function ie(D){{var te=typeof Symbol=="function"&&Symbol.toStringTag,oe=te&&D[Symbol.toStringTag]||D.constructor.name||"Object";return oe}}function le(D){try{return ae(D),!1}catch{return!0}}function ae(D){return""+D}function de(D){if(le(D))return z("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ie(D)),ae(D)}var Ce=_.ReactCurrentOwner,we={key:!0,ref:!0,__self:!0,__source:!0},Fe,nt,Le;Le={};function ct(D){if(V.call(D,"ref")){var te=Object.getOwnPropertyDescriptor(D,"ref").get;if(te&&te.isReactWarning)return!1}return D.ref!==void 0}function De(D){if(V.call(D,"key")){var te=Object.getOwnPropertyDescriptor(D,"key").get;if(te&&te.isReactWarning)return!1}return D.key!==void 0}function dt(D,te){if(typeof D.ref=="string"&&Ce.current&&te&&Ce.current.stateNode!==te){var oe=U(Ce.current.type);Le[oe]||(z('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',U(Ce.current.type),D.ref),Le[oe]=!0)}}function wt(D,te){{var oe=function(){Fe||(Fe=!0,z("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};oe.isReactWarning=!0,Object.defineProperty(D,"key",{get:oe,configurable:!0})}}function We(D,te){{var oe=function(){nt||(nt=!0,z("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};oe.isReactWarning=!0,Object.defineProperty(D,"ref",{get:oe,configurable:!0})}}var Rt=function(D,te,oe,ve,Ee,Te,ke){var xe={$$typeof:e,type:D,key:te,ref:oe,props:ke,_owner:Te};return xe._store={},Object.defineProperty(xe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(xe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ve}),Object.defineProperty(xe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ee}),Object.freeze&&(Object.freeze(xe.props),Object.freeze(xe)),xe};function cr(D,te,oe,ve,Ee){{var Te,ke={},xe=null,Re=null;oe!==void 0&&(de(oe),xe=""+oe),De(te)&&(de(te.key),xe=""+te.key),ct(te)&&(Re=te.ref,dt(te,Ee));for(Te in te)V.call(te,Te)&&!we.hasOwnProperty(Te)&&(ke[Te]=te[Te]);if(D&&D.defaultProps){var Oe=D.defaultProps;for(Te in Oe)ke[Te]===void 0&&(ke[Te]=Oe[Te])}if(xe||Re){var Pe=typeof D=="function"?D.displayName||D.name||"Unknown":D;xe&&wt(ke,Pe),Re&&We(ke,Pe)}return Rt(D,xe,Re,Ee,ve,Ce.current,ke)}}var xt=_.ReactCurrentOwner,Mt=_.ReactDebugCurrentFrame;function Ke(D){if(D){var te=D._owner,oe=Q(D.type,D._source,te?te.type:null);Mt.setExtraStackFrame(oe)}else Mt.setExtraStackFrame(null)}var Je;Je=!1;function it(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function An(){{if(xt.current){var D=U(xt.current.type);if(D)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+D+"`."}return""}}function Ys(D){{if(D!==void 0){var te=D.fileName.replace(/^.*[\\\/]/,""),oe=D.lineNumber;return`
|
|
24
|
+
|
|
25
|
+
Check your code at `+te+":"+oe+"."}return""}}var Dn={};function Ks(D){{var te=An();if(!te){var oe=typeof D=="string"?D:D.displayName||D.name;oe&&(te=`
|
|
26
|
+
|
|
27
|
+
Check the top-level render call using <`+oe+">.")}return te}}function On(D,te){{if(!D._store||D._store.validated||D.key!=null)return;D._store.validated=!0;var oe=Ks(te);if(Dn[oe])return;Dn[oe]=!0;var ve="";D&&D._owner&&D._owner!==xt.current&&(ve=" It was passed a child from "+U(D._owner.type)+"."),Ke(D),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',oe,ve),Ke(null)}}function In(D,te){{if(typeof D!="object")return;if(q(D))for(var oe=0;oe<D.length;oe++){var ve=D[oe];it(ve)&&On(ve,te)}else if(it(D))D._store&&(D._store.validated=!0);else if(D){var Ee=S(D);if(typeof Ee=="function"&&Ee!==D.entries)for(var Te=Ee.call(D),ke;!(ke=Te.next()).done;)it(ke.value)&&On(ke.value,te)}}}function Js(D){{var te=D.type;if(te==null||typeof te=="string")return;var oe;if(typeof te=="function")oe=te.propTypes;else if(typeof te=="object"&&(te.$$typeof===d||te.$$typeof===p))oe=te.propTypes;else return;if(oe){var ve=U(te);J(oe,D.props,"prop",ve,D)}else if(te.PropTypes!==void 0&&!Je){Je=!0;var Ee=U(te);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ee||"Unknown")}typeof te.getDefaultProps=="function"&&!te.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Xs(D){{for(var te=Object.keys(D.props),oe=0;oe<te.length;oe++){var ve=te[oe];if(ve!=="children"&&ve!=="key"){Ke(D),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ve),Ke(null);break}}D.ref!==null&&(Ke(D),z("Invalid attribute `ref` supplied to `React.Fragment`."),Ke(null))}}function Pn(D,te,oe,ve,Ee,Te){{var ke=ne(D);if(!ke){var xe="";(D===void 0||typeof D=="object"&&D!==null&&Object.keys(D).length===0)&&(xe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Re=Ys(Ee);Re?xe+=Re:xe+=An();var Oe;D===null?Oe="null":q(D)?Oe="array":D!==void 0&&D.$$typeof===e?(Oe="<"+(U(D.type)||"Unknown")+" />",xe=" Did you accidentally export a JSX literal instead of a component?"):Oe=typeof D,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Oe,xe)}var Pe=cr(D,te,oe,Ee,Te);if(Pe==null)return Pe;if(ke){var Ue=te.children;if(Ue!==void 0)if(ve)if(q(Ue)){for(var ft=0;ft<Ue.length;ft++)In(Ue[ft],D);Object.freeze&&Object.freeze(Ue)}else z("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else In(Ue,D)}return D===s?Xs(Pe):Js(Pe),Pe}}function Hs(D,te,oe){return Pn(D,te,oe,!0)}function eo(D,te,oe){return Pn(D,te,oe,!1)}var to=eo,ro=Hs;mt.Fragment=s,mt.jsx=to,mt.jsxs=ro}()),mt}(function(t){process.env.NODE_ENV==="production"?t.exports=Zn():t.exports=Yn()})(zt);const n=zt.exports.jsx,N=zt.exports.jsxs,qe=zt.exports.Fragment;function gr({}){const{freezeLayout:t}=W.default.useContext($e),[e,r]=W.default.useState(!1),{title:s,description:a}=W.default.useContext(je);return W.default.useEffect(()=>{t(e)},[e]),!a||a==="<p><br></p>"?null:N(qe,{children:[n(c.Modal,{opened:e,onClose:()=>r(!1),title:s,withCloseButton:!1,children:n(qt.default,{readOnly:!0,value:a,onChange:ye.default.noop,sx:{border:"none"}})}),n(c.Tooltip,{label:"Click to see description",position:"top-start",children:n(c.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(l=>!l),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n(pe.InfoCircle,{size:20})})})]})}function Kn(){const{description:t,setDescription:e}=W.default.useContext(je),[r,s]=W.default.useState(t),a=t!==r,l=W.default.useCallback(()=>{!a||e(r)},[a,r]);return N(c.Stack,{sx:{flexGrow:1},children:[N(c.Group,{align:"end",children:[n(c.Text,{children:"Description"}),n(c.ActionIcon,{variant:"subtle",color:"blue",disabled:!a,onClick:l,children:n(pe.DeviceFloppy,{size:20})})]}),n(dr.RichTextEditor,{value:r,onChange:s,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class Tt extends W.default.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const r=()=>{this.setState({error:null})};return N(c.Box,{children:[n(c.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),n(c.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}function Jn(){const{title:t}=W.default.useContext(je);return n(Tt,{children:N(c.Stack,{mx:"auto",mt:"xl",p:"5px",spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[N(c.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[n(c.Group,{children:n(gr,{})}),n(c.Group,{grow:!0,position:"center",children:n(c.Text,{lineClamp:1,weight:"bold",children:t})}),n(c.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),n(c.Group,{sx:{background:"#eee",flexGrow:1}})]})})}function Xn(){const{title:t,setTitle:e}=W.default.useContext(je),[r,s]=Be.useInputState(t),a=t!==r,l=W.default.useCallback(()=>{!a||e(r)},[a,r]);return n(c.TextInput,{value:r,onChange:s,label:N(c.Group,{align:"end",children:[n(c.Text,{children:"Panel Title"}),n(c.ActionIcon,{variant:"subtle",color:"blue",disabled:!a,onClick:l,children:n(pe.DeviceFloppy,{size:20})})]})})}function Hn({}){return N(c.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[N(c.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0,height:"100%"},children:[n(Xn,{}),n(Kn,{})]}),n(c.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:n(Jn,{})})]})}function ei({data:t}){return t.length===0?n(c.Box,{sx:{height:"5em"}}):N(c.Table,{children:[n("thead",{children:n("tr",{children:Object.keys(t==null?void 0:t[0]).map(e=>n("th",{children:n(c.Text,{weight:700,color:"#000",children:e})},e))})}),n("tbody",{children:t.slice(0,10).map((e,r)=>n("tr",{children:Object.values(e).map((s,a)=>n("td",{children:n(c.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:n(c.Text,{children:s})})},`${s}--${a}`))},`row-${r}`))})]})}const vr=Se.observer(function({id:e}){const r=Me(),{data:s,state:a,error:l}=r.getDataStuffByID(e),o=a==="loading",i=()=>{r.queries.refetchDataByQueryID(e)};return N(c.Stack,{my:"xl",sx:{border:"1px solid #eee"},children:[N(c.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[N(c.Group,{position:"left",children:[n(c.Text,{weight:500,children:"Preview Data"}),s.length>10&&N(c.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",s.length]})]}),n(c.ActionIcon,{mr:15,variant:"subtle",color:"blue",disabled:o,onClick:i,children:n(pe.Refresh,{size:15})})]}),N(c.Box,{sx:{position:"relative"},children:[n(c.LoadingOverlay,{visible:o}),n(ei,{data:s})]})]})}),ti=Se.observer(function({}){const e=Me(),{queryID:r,setQueryID:s}=W.default.useContext(je),a=W.default.useMemo(()=>e.queries.current.map(l=>({value:l.id,label:l.id})),[e.queries.current]);return N(c.Stack,{children:[N(c.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[n(c.Text,{children:"Select a Query"}),n(c.Select,{data:a,value:r,onChange:s,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}})]}),n(vr,{id:r})]})});class br{constructor(e){Qe(this,"rootRef");this.rootRef=at.observable({current:e})}async deleteItem(e){at.runInAction(()=>{Ie.unset(this.rootRef.current,[e])})}getItem(e){const r=this.getValueFromRoot(e);return Promise.resolve(r)}getValueFromRoot(e){return e===null?at.toJS(this.rootRef.current):Ie.get(this.rootRef.current,[e])}setItem(e,r){if(e===null)if(Ie.isObject(r))at.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else at.runInAction(()=>{Ie.set(this.rootRef.current,[e],r)});return Promise.resolve(this.getItem(e))}watchItem(e,r){return at.reaction(()=>this.getValueFromRoot(e),(s,a)=>{r(s,a)},{requiresObservable:!0})}}var yr={exports:{}};/*!
|
|
28
|
+
* EventEmitter2
|
|
29
|
+
* https://github.com/hij1nx/EventEmitter2
|
|
30
|
+
*
|
|
31
|
+
* Copyright (c) 2013 hij1nx
|
|
32
|
+
* Licensed under the MIT license.
|
|
33
|
+
*/(function(t,e){(function(r){var s=Object.hasOwnProperty,a=Array.isArray?Array.isArray:function(w){return Object.prototype.toString.call(w)==="[object Array]"},l=10,o=typeof process=="object"&&typeof process.nextTick=="function",i=typeof Symbol=="function",d=typeof Reflect=="object",g=typeof setImmediate=="function",m=g?setImmediate:setTimeout,p=i?d&&typeof Reflect.ownKeys=="function"?Reflect.ownKeys:function(y){var w=Object.getOwnPropertyNames(y);return w.push.apply(w,Object.getOwnPropertySymbols(y)),w}:Object.keys;function b(){this._events={},this._conf&&h.call(this,this._conf)}function h(y){y&&(this._conf=y,y.delimiter&&(this.delimiter=y.delimiter),y.maxListeners!==r&&(this._maxListeners=y.maxListeners),y.wildcard&&(this.wildcard=y.wildcard),y.newListener&&(this._newListener=y.newListener),y.removeListener&&(this._removeListener=y.removeListener),y.verboseMemoryLeak&&(this.verboseMemoryLeak=y.verboseMemoryLeak),y.ignoreErrors&&(this.ignoreErrors=y.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function E(y,w){var O="(node) warning: possible EventEmitter memory leak detected. "+y+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(O+=" Event name: "+w+"."),typeof process<"u"&&process.emitWarning){var x=new Error(O);x.name="MaxListenersExceededWarning",x.emitter=this,x.count=y,process.emitWarning(x)}else console.error(O),console.trace&&console.trace()}var v=function(y,w,O){var x=arguments.length;switch(x){case 0:return[];case 1:return[y];case 2:return[y,w];case 3:return[y,w,O];default:for(var C=new Array(x);x--;)C[x]=arguments[x];return C}};function S(y,w){for(var O={},x,C=y.length,R=w?w.length:0,L=0;L<C;L++)x=y[L],O[x]=L<R?w[L]:r;return O}function _(y,w,O){this._emitter=y,this._target=w,this._listeners={},this._listenersCount=0;var x,C;if((O.on||O.off)&&(x=O.on,C=O.off),w.addEventListener?(x=w.addEventListener,C=w.removeEventListener):w.addListener?(x=w.addListener,C=w.removeListener):w.on&&(x=w.on,C=w.off),!x&&!C)throw Error("target does not implement any known event API");if(typeof x!="function")throw TypeError("on method must be a function");if(typeof C!="function")throw TypeError("off method must be a function");this._on=x,this._off=C;var R=y._observers;R?R.push(this):y._observers=[this]}Object.assign(_.prototype,{subscribe:function(y,w,O){var x=this,C=this._target,R=this._emitter,L=this._listeners,B=function(){var Z=v.apply(null,arguments),K={data:Z,name:w,original:y};if(O){var re=O.call(C,K);re!==!1&&R.emit.apply(R,[K.name].concat(Z));return}R.emit.apply(R,[w].concat(Z))};if(L[y])throw Error("Event '"+y+"' is already listening");this._listenersCount++,R._newListener&&R._removeListener&&!x._onNewListener?(this._onNewListener=function(Z){Z===w&&L[y]===null&&(L[y]=B,x._on.call(C,y,B))},R.on("newListener",this._onNewListener),this._onRemoveListener=function(Z){Z===w&&!R.hasListeners(Z)&&L[y]&&(L[y]=null,x._off.call(C,y,B))},L[y]=null,R.on("removeListener",this._onRemoveListener)):(L[y]=B,x._on.call(C,y,B))},unsubscribe:function(y){var w=this,O=this._listeners,x=this._emitter,C,R,L=this._off,B=this._target,Z;if(y&&typeof y!="string")throw TypeError("event must be a string");function K(){w._onNewListener&&(x.off("newListener",w._onNewListener),x.off("removeListener",w._onRemoveListener),w._onNewListener=null,w._onRemoveListener=null);var re=ee.call(x,w);x._observers.splice(re,1)}if(y){if(C=O[y],!C)return;L.call(B,y,C),delete O[y],--this._listenersCount||K()}else{for(R=p(O),Z=R.length;Z-- >0;)y=R[Z],L.call(B,y,O[y]);this._listeners={},this._listenersCount=0,K()}}});function z(y,w,O,x){var C=Object.assign({},w);if(!y)return C;if(typeof y!="object")throw TypeError("options must be an object");var R=Object.keys(y),L=R.length,B,Z,K;function re(fe){throw Error('Invalid "'+B+'" option value'+(fe?". Reason: "+fe:""))}for(var me=0;me<L;me++){if(B=R[me],!x&&!s.call(w,B))throw Error('Unknown "'+B+'" option');Z=y[B],Z!==r&&(K=O[B],C[B]=K?K(Z,re):Z)}return C}function I(y,w){return(typeof y!="function"||!y.hasOwnProperty("prototype"))&&w("value must be a constructor"),y}function M(y){var w="value must be type of "+y.join("|"),O=y.length,x=y[0],C=y[1];return O===1?function(R,L){if(typeof R===x)return R;L(w)}:O===2?function(R,L){var B=typeof R;if(B===x||B===C)return R;L(w)}:function(R,L){for(var B=typeof R,Z=O;Z-- >0;)if(B===y[Z])return R;L(w)}}var F=M(["function"]),Y=M(["object","function"]);function $(y,w,O){var x,C,R=0,L,B=new y(function(Z,K,re){O=z(O,{timeout:0,overload:!1},{timeout:function(_e,ze){return _e*=1,(typeof _e!="number"||_e<0||!Number.isFinite(_e))&&ze("timeout must be a positive number"),_e}}),x=!O.overload&&typeof y.prototype.cancel=="function"&&typeof re=="function";function me(){C&&(C=null),R&&(clearTimeout(R),R=0)}var fe=function(_e){me(),Z(_e)},he=function(_e){me(),K(_e)};x?w(fe,he,re):(C=[function(_e){he(_e||Error("canceled"))}],w(fe,he,function(_e){if(L)throw Error("Unable to subscribe on cancel event asynchronously");if(typeof _e!="function")throw TypeError("onCancel callback must be a function");C.push(_e)}),L=!0),O.timeout>0&&(R=setTimeout(function(){var _e=Error("timeout");_e.code="ETIMEDOUT",R=0,B.cancel(_e),K(_e)},O.timeout))});return x||(B.cancel=function(Z){if(!!C){for(var K=C.length,re=1;re<K;re++)C[re](Z);C[0](Z),C=null}}),B}function ee(y){var w=this._observers;if(!w)return-1;for(var O=w.length,x=0;x<O;x++)if(w[x]._target===y)return x;return-1}function G(y,w,O,x,C){if(!O)return null;if(x===0){var R=typeof w;if(R==="string"){var L,B,Z=0,K=0,re=this.delimiter,me=re.length;if((B=w.indexOf(re))!==-1){L=new Array(5);do L[Z++]=w.slice(K,B),K=B+me;while((B=w.indexOf(re,K))!==-1);L[Z++]=w.slice(K),w=L,C=Z}else w=[w],C=1}else R==="object"?C=w.length:(w=[w],C=1)}var fe=null,he,_e,ze,u,Q,V=w[x],T=w[x+1],k,P;if(x===C)O._listeners&&(typeof O._listeners=="function"?(y&&y.push(O._listeners),fe=[O]):(y&&y.push.apply(y,O._listeners),fe=[O]));else if(V==="*"){for(k=p(O),B=k.length;B-- >0;)he=k[B],he!=="_listeners"&&(P=G(y,w,O[he],x+1,C),P&&(fe?fe.push.apply(fe,P):fe=P));return fe}else if(V==="**"){for(Q=x+1===C||x+2===C&&T==="*",Q&&O._listeners&&(fe=G(y,w,O,C,C)),k=p(O),B=k.length;B-- >0;)he=k[B],he!=="_listeners"&&(he==="*"||he==="**"?(O[he]._listeners&&!Q&&(P=G(y,w,O[he],C,C),P&&(fe?fe.push.apply(fe,P):fe=P)),P=G(y,w,O[he],x,C)):he===T?P=G(y,w,O[he],x+2,C):P=G(y,w,O[he],x,C),P&&(fe?fe.push.apply(fe,P):fe=P));return fe}else O[V]&&(fe=G(y,w,O[V],x+1,C));if(_e=O["*"],_e&&G(y,w,_e,x+1,C),ze=O["**"],ze)if(x<C)for(ze._listeners&&G(y,w,ze,C,C),k=p(ze),B=k.length;B-- >0;)he=k[B],he!=="_listeners"&&(he===T?G(y,w,ze[he],x+2,C):he===V?G(y,w,ze[he],x+1,C):(u={},u[he]=ze[he],G(y,w,{"**":u},x+1,C)));else ze._listeners?G(y,w,ze,C,C):ze["*"]&&ze["*"]._listeners&&G(y,w,ze["*"],C,C);return fe}function ne(y,w,O){var x=0,C=0,R,L=this.delimiter,B=L.length,Z;if(typeof y=="string")if((R=y.indexOf(L))!==-1){Z=new Array(5);do Z[x++]=y.slice(C,R),C=R+B;while((R=y.indexOf(L,C))!==-1);Z[x++]=y.slice(C)}else Z=[y],x=1;else Z=y,x=y.length;if(x>1){for(R=0;R+1<x;R++)if(Z[R]==="**"&&Z[R+1]==="**")return}var K=this.listenerTree,re;for(R=0;R<x;R++)if(re=Z[R],K=K[re]||(K[re]={}),R===x-1)return K._listeners?(typeof K._listeners=="function"&&(K._listeners=[K._listeners]),O?K._listeners.unshift(w):K._listeners.push(w),!K._listeners.warned&&this._maxListeners>0&&K._listeners.length>this._maxListeners&&(K._listeners.warned=!0,E.call(this,K._listeners.length,re))):K._listeners=w,!0;return!0}function ce(y,w,O,x){for(var C=p(y),R=C.length,L,B,Z,K=y._listeners,re;R-- >0;)B=C[R],L=y[B],B==="_listeners"?Z=O:Z=O?O.concat(B):[B],re=x||typeof B=="symbol",K&&w.push(re?Z:Z.join(this.delimiter)),typeof L=="object"&&ce.call(this,L,w,Z,re);return w}function A(y){for(var w=p(y),O=w.length,x,C,R;O-- >0;)C=w[O],x=y[C],x&&(R=!0,C!=="_listeners"&&!A(x)&&delete y[C]);return R}function U(y,w,O){this.emitter=y,this.event=w,this.listener=O}U.prototype.off=function(){return this.emitter.off(this.event,this.listener),this};function f(y,w,O){if(O===!0)C=!0;else if(O===!1)x=!0;else{if(!O||typeof O!="object")throw TypeError("options should be an object or true");var x=O.async,C=O.promisify,R=O.nextTick,L=O.objectify}if(x||R||C){var B=w,Z=w._origin||w;if(R&&!o)throw Error("process.nextTick is not supported");C===r&&(C=w.constructor.name==="AsyncFunction"),w=function(){var K=arguments,re=this,me=this.event;return C?R?Promise.resolve():new Promise(function(fe){m(fe)}).then(function(){return re.event=me,B.apply(re,K)}):(R?process.nextTick:m)(function(){re.event=me,B.apply(re,K)})},w._async=!0,w._origin=Z}return[w,L?new U(this,y,w):this]}function j(y){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,h.call(this,y)}j.EventEmitter2=j,j.prototype.listenTo=function(y,w,O){if(typeof y!="object")throw TypeError("target musts be an object");var x=this;O=z(O,{on:r,off:r,reducers:r},{on:F,off:F,reducers:Y});function C(R){if(typeof R!="object")throw TypeError("events must be an object");var L=O.reducers,B=ee.call(x,y),Z;B===-1?Z=new _(x,y,O):Z=x._observers[B];for(var K=p(R),re=K.length,me,fe=typeof L=="function",he=0;he<re;he++)me=K[he],Z.subscribe(me,R[me]||me,fe?L:L&&L[me])}return a(w)?C(S(w)):C(typeof w=="string"?S(w.split(/\s+/)):w),this},j.prototype.stopListeningTo=function(y,w){var O=this._observers;if(!O)return!1;var x=O.length,C,R=!1;if(y&&typeof y!="object")throw TypeError("target should be an object");for(;x-- >0;)C=O[x],(!y||C._target===y)&&(C.unsubscribe(w),R=!0);return R},j.prototype.delimiter=".",j.prototype.setMaxListeners=function(y){y!==r&&(this._maxListeners=y,this._conf||(this._conf={}),this._conf.maxListeners=y)},j.prototype.getMaxListeners=function(){return this._maxListeners},j.prototype.event="",j.prototype.once=function(y,w,O){return this._once(y,w,!1,O)},j.prototype.prependOnceListener=function(y,w,O){return this._once(y,w,!0,O)},j.prototype._once=function(y,w,O,x){return this._many(y,1,w,O,x)},j.prototype.many=function(y,w,O,x){return this._many(y,w,O,!1,x)},j.prototype.prependMany=function(y,w,O,x){return this._many(y,w,O,!0,x)},j.prototype._many=function(y,w,O,x,C){var R=this;if(typeof O!="function")throw new Error("many only accepts instances of Function");function L(){return--w===0&&R.off(y,L),O.apply(this,arguments)}return L._origin=O,this._on(y,L,x,C)},j.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||b.call(this);var y=arguments[0],w,O=this.wildcard,x,C,R,L,B;if(y==="newListener"&&!this._newListener&&!this._events.newListener)return!1;if(O&&(w=y,y!=="newListener"&&y!=="removeListener"&&typeof y=="object")){if(C=y.length,i){for(R=0;R<C;R++)if(typeof y[R]=="symbol"){B=!0;break}}B||(y=y.join(this.delimiter))}var Z=arguments.length,K;if(this._all&&this._all.length)for(K=this._all.slice(),R=0,C=K.length;R<C;R++)switch(this.event=y,Z){case 1:K[R].call(this,y);break;case 2:K[R].call(this,y,arguments[1]);break;case 3:K[R].call(this,y,arguments[1],arguments[2]);break;default:K[R].apply(this,arguments)}if(O)K=[],G.call(this,K,w,this.listenerTree,0,C);else if(K=this._events[y],typeof K=="function"){switch(this.event=y,Z){case 1:K.call(this);break;case 2:K.call(this,arguments[1]);break;case 3:K.call(this,arguments[1],arguments[2]);break;default:for(x=new Array(Z-1),L=1;L<Z;L++)x[L-1]=arguments[L];K.apply(this,x)}return!0}else K&&(K=K.slice());if(K&&K.length){if(Z>3)for(x=new Array(Z-1),L=1;L<Z;L++)x[L-1]=arguments[L];for(R=0,C=K.length;R<C;R++)switch(this.event=y,Z){case 1:K[R].call(this);break;case 2:K[R].call(this,arguments[1]);break;case 3:K[R].call(this,arguments[1],arguments[2]);break;default:K[R].apply(this,x)}return!0}else if(!this.ignoreErrors&&!this._all&&y==="error")throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},j.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||b.call(this);var y=arguments[0],w=this.wildcard,O,x,C,R,L,B;if(y==="newListener"&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(w&&(O=y,y!=="newListener"&&y!=="removeListener"&&typeof y=="object")){if(R=y.length,i){for(L=0;L<R;L++)if(typeof y[L]=="symbol"){x=!0;break}}x||(y=y.join(this.delimiter))}var Z=[],K=arguments.length,re;if(this._all)for(L=0,R=this._all.length;L<R;L++)switch(this.event=y,K){case 1:Z.push(this._all[L].call(this,y));break;case 2:Z.push(this._all[L].call(this,y,arguments[1]));break;case 3:Z.push(this._all[L].call(this,y,arguments[1],arguments[2]));break;default:Z.push(this._all[L].apply(this,arguments))}if(w?(re=[],G.call(this,re,O,this.listenerTree,0)):re=this._events[y],typeof re=="function")switch(this.event=y,K){case 1:Z.push(re.call(this));break;case 2:Z.push(re.call(this,arguments[1]));break;case 3:Z.push(re.call(this,arguments[1],arguments[2]));break;default:for(C=new Array(K-1),B=1;B<K;B++)C[B-1]=arguments[B];Z.push(re.apply(this,C))}else if(re&&re.length){if(re=re.slice(),K>3)for(C=new Array(K-1),B=1;B<K;B++)C[B-1]=arguments[B];for(L=0,R=re.length;L<R;L++)switch(this.event=y,K){case 1:Z.push(re[L].call(this));break;case 2:Z.push(re[L].call(this,arguments[1]));break;case 3:Z.push(re[L].call(this,arguments[1],arguments[2]));break;default:Z.push(re[L].apply(this,C))}}else if(!this.ignoreErrors&&!this._all&&y==="error")return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(Z)},j.prototype.on=function(y,w,O){return this._on(y,w,!1,O)},j.prototype.prependListener=function(y,w,O){return this._on(y,w,!0,O)},j.prototype.onAny=function(y){return this._onAny(y,!1)},j.prototype.prependAny=function(y){return this._onAny(y,!0)},j.prototype.addListener=j.prototype.on,j.prototype._onAny=function(y,w){if(typeof y!="function")throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),w?this._all.unshift(y):this._all.push(y),this},j.prototype._on=function(y,w,O,x){if(typeof y=="function")return this._onAny(y,w),this;if(typeof w!="function")throw new Error("on only accepts instances of Function");this._events||b.call(this);var C=this,R;return x!==r&&(R=f.call(this,y,w,x),w=R[0],C=R[1]),this._newListener&&this.emit("newListener",y,w),this.wildcard?(ne.call(this,y,w,O),C):(this._events[y]?(typeof this._events[y]=="function"&&(this._events[y]=[this._events[y]]),O?this._events[y].unshift(w):this._events[y].push(w),!this._events[y].warned&&this._maxListeners>0&&this._events[y].length>this._maxListeners&&(this._events[y].warned=!0,E.call(this,this._events[y].length,y))):this._events[y]=w,C)},j.prototype.off=function(y,w){if(typeof w!="function")throw new Error("removeListener only takes instances of Function");var O,x=[];if(this.wildcard){var C=typeof y=="string"?y.split(this.delimiter):y.slice();if(x=G.call(this,null,C,this.listenerTree,0),!x)return this}else{if(!this._events[y])return this;O=this._events[y],x.push({_listeners:O})}for(var R=0;R<x.length;R++){var L=x[R];if(O=L._listeners,a(O)){for(var B=-1,Z=0,K=O.length;Z<K;Z++)if(O[Z]===w||O[Z].listener&&O[Z].listener===w||O[Z]._origin&&O[Z]._origin===w){B=Z;break}if(B<0)continue;return this.wildcard?L._listeners.splice(B,1):this._events[y].splice(B,1),O.length===0&&(this.wildcard?delete L._listeners:delete this._events[y]),this._removeListener&&this.emit("removeListener",y,w),this}else(O===w||O.listener&&O.listener===w||O._origin&&O._origin===w)&&(this.wildcard?delete L._listeners:delete this._events[y],this._removeListener&&this.emit("removeListener",y,w))}return this.listenerTree&&A(this.listenerTree),this},j.prototype.offAny=function(y){var w=0,O=0,x;if(y&&this._all&&this._all.length>0){for(x=this._all,w=0,O=x.length;w<O;w++)if(y===x[w])return x.splice(w,1),this._removeListener&&this.emit("removeListenerAny",y),this}else{if(x=this._all,this._removeListener)for(w=0,O=x.length;w<O;w++)this.emit("removeListenerAny",x[w]);this._all=[]}return this},j.prototype.removeListener=j.prototype.off,j.prototype.removeAllListeners=function(y){if(y===r)return!this._events||b.call(this),this;if(this.wildcard){var w=G.call(this,null,y,this.listenerTree,0),O,x;if(!w)return this;for(x=0;x<w.length;x++)O=w[x],O._listeners=null;this.listenerTree&&A(this.listenerTree)}else this._events&&(this._events[y]=null);return this},j.prototype.listeners=function(y){var w=this._events,O,x,C,R,L;if(y===r){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!w)return[];for(O=p(w),R=O.length,C=[];R-- >0;)x=w[O[R]],typeof x=="function"?C.push(x):C.push.apply(C,x);return C}else{if(this.wildcard){if(L=this.listenerTree,!L)return[];var B=[],Z=typeof y=="string"?y.split(this.delimiter):y.slice();return G.call(this,B,Z,L,0),B}return w?(x=w[y],x?typeof x=="function"?[x]:x:[]):[]}},j.prototype.eventNames=function(y){var w=this._events;return this.wildcard?ce.call(this,this.listenerTree,[],null,y):w?p(w):[]},j.prototype.listenerCount=function(y){return this.listeners(y).length},j.prototype.hasListeners=function(y){if(this.wildcard){var w=[],O=typeof y=="string"?y.split(this.delimiter):y.slice();return G.call(this,w,O,this.listenerTree,0),w.length>0}var x=this._events,C=this._all;return!!(C&&C.length||x&&(y===r?p(x).length:x[y]))},j.prototype.listenersAny=function(){return this._all?this._all:[]},j.prototype.waitFor=function(y,w){var O=this,x=typeof w;return x==="number"?w={timeout:w}:x==="function"&&(w={filter:w}),w=z(w,{timeout:0,filter:r,handleError:!1,Promise,overload:!1},{filter:F,Promise:I}),$(w.Promise,function(C,R,L){function B(){var Z=w.filter;if(!(Z&&!Z.apply(O,arguments)))if(O.off(y,B),w.handleError){var K=arguments[0];K?R(K):C(v.apply(null,arguments).slice(1))}else C(v.apply(null,arguments))}L(function(){O.off(y,B)}),O._on(y,B,!1)},{timeout:w.timeout,overload:w.overload})};function ge(y,w,O){O=z(O,{Promise,timeout:0,overload:!1},{Promise:I});var x=O.Promise;return $(x,function(C,R,L){var B;if(typeof y.addEventListener=="function"){B=function(){C(v.apply(null,arguments))},L(function(){y.removeEventListener(w,B)}),y.addEventListener(w,B,{once:!0});return}var Z=function(){K&&y.removeListener("error",K),C(v.apply(null,arguments))},K;w!=="error"&&(K=function(re){y.removeListener(w,Z),R(re)},y.once("error",K)),L(function(){K&&y.removeListener("error",K),y.removeListener(w,Z)}),y.once(w,Z)},{timeout:O.timeout,overload:O.overload})}var H=j.prototype;Object.defineProperties(j,{defaultMaxListeners:{get:function(){return H._maxListeners},set:function(y){if(typeof y!="number"||y<0||Number.isNaN(y))throw TypeError("n must be a non-negative number");H._maxListeners=y},enumerable:!0},once:{value:ge,writable:!0,configurable:!0}}),Object.defineProperties(H,{_maxListeners:{value:l,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),typeof r=="function"&&r.amd?r(function(){return j}):t.exports=j})()})(yr);const _r=yr.exports;class ri{constructor(){Qe(this,"channels",new Map);Qe(this,"globalChannel",new _r)}getChannel(e){const r=this.channels.get(e);if(r)return r;const s=new _r;return this.channels.set(e,s),s}}class ni{constructor(e){Qe(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const r=this.instances.get(e.id);if(r)return r;const s={id:e.id,name:e.viz.type,type:e.viz.type,messageChannels:new ri,instanceData:new br(e.viz.conf)};return this.instances.set(e.id,s),s}}function wr(t,e){return{locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new br({}),colorPalette:{getColor(){return()=>""}},data:e}}const ii=t=>{const{panel:e,vizManager:r,data:s}=t,a=r.resolveComponent(e.viz.type),l=r.getOrCreateInstance(e),o={...wr(l,s),viewport:{width:e.layout.w,height:e.layout.h}},i=a.viewRender;return n(i,{context:o,instance:l,...Ie.omit(t,["panel","vizManager","data"])})},ai=t=>{const{vizManager:e,panel:r,panelInfoEditor:s,data:a}=t,l=e.resolveComponent(r.viz.type),o=e.getOrCreateInstance(r),i={...wr(o,a),panelInfoEditor:s},d=l.configRender;return n(d,{context:i,instance:o,...Ie.omit(t,["panel","vizManager","data","panelInfoEditor"])})},si="3.0.0";class oi{constructor(){Qe(this,"plugins",new Map);Qe(this,"vizComponents",new Map);Qe(this,"factory",{viz:e=>{const r=this.vizComponents.get(e);if(r)return r;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const r of e.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class li{constructor(){Qe(this,"migrations",[])}version(e,r){return this.migrations.push({version:e,handler:r}),this}run(e,r){var l;if(e.from===e.to)return r;if(e.from>e.to)throw new Error(`Can not downgrade from version '${e.from}' to (${e.to})`);const s=this.migrations.filter(o=>o.version>e.from&&o.version<=e.to),a=Ie.orderBy(s,"version","asc");if(((l=Ie.last(a))==null?void 0:l.version)!==e.to)throw new Error(`Migration to version ${e.to} not found`);return a.reduce((o,i)=>i.handler(o),r)}}var tt=(t=>(t.string="string",t.number="number",t.eloc="eloc",t.percentage="percentage",t))(tt||{});const Gt={columns:[],fontSize:"1rem",highlightOnHover:!1,horizontalSpacing:"1em",id_field:"",striped:!1,use_raw_columns:!1,verticalSpacing:"1em"};function ui({value:t}){return n(c.Text,{component:"span",children:t})}function ci({value:t}){return n(c.Text,{component:"span",children:t})}function di({value:t}){const e=Ct.default(t).format({thousandSeparated:!0});return n(c.Text,{component:"span",children:e})}function fi({value:t}){const e=Ct.default(t).format({output:"percent",mantissa:3});return n(c.Text,{component:"span",children:e})}function hi({value:t,type:e}){switch(e){case tt.string:return n(ui,{value:t});case tt.eloc:return n(ci,{value:t});case tt.number:return n(di,{value:t});case tt.percentage:return n(fi,{value:t})}}function pi({context:t}){var m;const e=(m=t.data)!=null?m:[],r=t.viewport.height,{value:s=Gt}=xr(t.instanceData,"config"),{id_field:a,use_raw_columns:l,columns:o,...i}=s,d=W.default.useMemo(()=>l?Object.keys(e[0]):(o==null?void 0:o.map(p=>p.label))||[],[l,o,e]),g=W.default.useMemo(()=>l?Object.keys(e[0]).map(p=>({label:p,value_field:p,value_type:tt.string})):o,[l,o,e]);return N(c.Table,{sx:{maxHeight:r},...i,children:[n("thead",{children:n("tr",{children:d.map(p=>n("th",{children:p},p))})}),n("tbody",{children:e.slice(0,30).map((p,b)=>n("tr",{children:g==null?void 0:g.map(({value_field:h,value_type:E})=>n("td",{children:n(c.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:i.fontSize}},children:n(hi,{value:p[h],type:E})})},`${h}--${p[h]}`))},a?p[a]:`row-${b}`))}),e.length>100&&n("tfoot",{children:n("tr",{children:n("td",{colSpan:d.length,children:n(c.Text,{color:"red",size:"sm",children:"Showing only the first 30 rows to avoid causing slow performance"})})})})]})}function mi({label:t,required:e,value:r,onChange:s,data:a,sx:l,...o},i){const d=W.default.useMemo(()=>!Array.isArray(a)||a.length===0?[]:Object.keys(a[0]).map(m=>({label:m,value:m})),[a]);return n(c.Select,{ref:i,label:t,data:d,value:r,onChange:s,required:e,sx:l,...o})}const Ne=W.default.forwardRef(mi);function gi(t,e,r){Ae.useEffect(()=>(t.on(e,r),()=>{t.off(e,r)}),[t,e,r])}const xr=(t,e)=>{const[r,{setFalse:s}]=He.useBoolean(!0),[a,l]=Ae.useState();Ae.useEffect(()=>(t.getItem(e).then(i=>{l(i),s()}),t.watchItem(e,i=>{l(i)})));const o=Ae.useCallback(async i=>{await t.setItem(e,i),l(i)},[t,e]);return{loading:r,value:a,set:o}},vi=Object.values(tt).map(t=>({label:t,value:t}));function bi({label:t,value:e,onChange:r,sx:s}){return n(c.Select,{label:t,data:vi,value:e,onChange:r,sx:s})}function yi({context:t}){const{value:e,set:r}=xr(t.instanceData,"config"),s=jt.useForm({initialValues:Gt});Ae.useEffect(()=>{const o=Ie.defaults({},e,s.values,Gt);e&&s.setValues(o)},[e]);const a=t.data||[],l=()=>s.insertListItem("columns",{label:Be.randomId(),value_field:"value",value_type:tt.string});return n(c.Stack,{mt:"md",spacing:"xs",children:N("form",{onSubmit:s.onSubmit(async o=>{await r(o)}),children:[N(c.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[n(c.Text,{children:"Table Config"}),n(c.ActionIcon,{type:"submit","aria-label":"save config",mr:5,variant:"filled",color:"blue",children:n(pe.DeviceFloppy,{size:20})})]}),N(c.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[n(Ne,{label:"ID Field",required:!0,data:a,...s.getInputProps("id_field")}),N(c.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[n(c.TextInput,{label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...s.getInputProps("horizontalSpacing")}),n(c.TextInput,{label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...s.getInputProps("verticalSpacing")})]}),n(c.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:n(c.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...s.getInputProps("fontSize")})}),N(c.Stack,{children:[n(c.Text,{children:"Other"}),N(c.Group,{position:"apart",grow:!0,children:[n(c.Switch,{label:"Striped",...s.getInputProps("striped",{type:"checkbox"})}),n(c.Switch,{label:"Highlight on hover",...s.getInputProps("highlightOnHover",{type:"checkbox"})})]})]})]}),N(c.Stack,{mt:"xs",spacing:"xs",p:"md",mb:"xl",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[n(c.Switch,{label:"Use Original Data Columns",...s.getInputProps("use_raw_columns",{type:"checkbox"})}),!s.values.use_raw_columns&&N(c.Stack,{children:[n(c.Text,{mt:"xl",mb:0,children:"Custom Columns"}),s.values.columns.map((o,i)=>N(c.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[N(c.Group,{position:"apart",grow:!0,children:[n(c.TextInput,{label:"Label",required:!0,id:`col-label-${i}`,sx:{flex:1},...s.getInputProps(`columns.${i}.label`)}),n(Ne,{label:"Value Field",required:!0,data:a,...s.getInputProps(`columns.${i}.value_field`)}),n(bi,{label:"Value Type",sx:{flex:1},...s.getInputProps(`columns.${i}.value_type`)})]}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>s.removeListItem("columns",i),sx:{position:"absolute",top:15,right:5},children:n(pe.Trash,{size:16})})]},i)),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:l,children:"Add a Column"})})]})]}),n(c.Text,{weight:500,mb:"md",children:"Current Configuration:"}),n(st.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(s.values,null,2)})]})})}const Ut=1;class _i extends li{constructor(){super(),this.version(1,e=>({version:1,config:e}))}async migrate({instanceData:e}){const r=await e.getItem(null),s=Ie.get(r,"version",0),a=this.run({from:s,to:Ut},r);await e.setItem(null,a)}async needMigration({instanceData:e}){const r=await e.getItem(null),s=Ie.get(r,"version",0),a=s<Ut;return console.info(`needMigration: ${a}, from: ${s}, to: ${Ut}`),a}}const wi={displayName:"Table",migrator:new _i,name:"table",viewRender:pi,configRender:yi},xi={id:"dashboard",version:si,manifest:{viz:[wi],color:[]}},Vt=new oi,kr=()=>{const t=new ni(Vt);return{pluginManager:Vt,vizManager:t}},Wt=Ae.createContext(kr());Vt.install(xi);function Cr(t,e){const r=t.resolveComponent(e.type),s=e.messageChannels.getChannel(e.id),[a,l]=Ae.useState("checking");return gi(s,"migration-done",()=>{l("done")}),He.useAsyncEffect(async()=>{a==="checking"&&(await r.migrator.needMigration(e)?l("need-migration"):l("done"))}),{migrationState:a,updateConfig:async()=>{await r.migrator.migrate(e),s.emit("migration-done"),l("done")}}}function ki({setVizConf:t,...e}){const{vizManager:r,panel:s}=e,a=r.getOrCreateInstance(s),{migrationState:l,updateConfig:o}=Cr(r,a);return Ae.useEffect(()=>a.instanceData.watchItem(null,i=>{t({type:s.viz.type,conf:i})}),[t]),l==="checking"?n(c.Text,{children:"Checking update..."}):l==="need-migration"?N(c.Stack,{justify:"center",align:"center",children:[n(c.Text,{children:"The configuration of this panel is outdated."}),n(c.Button,{type:"button","aria-label":"update config",onClick:o,children:"Update Config"})]}):n(ai,{...e})}function Ci(t){const{vizManager:e,panel:r}=t,s=e.getOrCreateInstance(r),{migrationState:a}=Cr(e,s);return a==="checking"?n(c.Text,{children:"Checking update"}):a==="need-migration"?n(c.Stack,{justify:"center",align:"center",children:n(c.Text,{children:'The configuration of this panel is outdated, please update config in "Settings"'})}):n(ii,{...t})}Ze.use([ht.SunburstChart,kt.CanvasRenderer]);const Si={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function Ei({conf:t,data:e,width:r,height:s}){const{label_field:a="name",value_field:l="value",...o}=t,i=W.default.useMemo(()=>e.map(p=>({name:p[a],value:Number(p[l])})),[e,a,l]),d=W.default.useMemo(()=>{var p,b;return(b=(p=ye.default.maxBy(i,h=>h.value))==null?void 0:p.value)!=null?b:1},[i]),g=W.default.useMemo(()=>({series:{label:{formatter:({name:p,value:b})=>b/d<.2?" ":p}}}),[d]),m=ye.default.merge({},Si,g,o,{series:{data:i}});return n(St.default,{echarts:Ze,option:m,style:{width:r,height:s}})}function zi({regressions:t=[]},e){const r=[],s=[],a=[];return e.length===0?{regressionDataSets:r,regressionSeries:s,regressionXAxes:a}:(t.forEach(({transform:l,plot:o,name:i,y_axis_data_key:d})=>{const g=`x-axis-for-${i}`,m=`dataset-for-${i}--raw`,p=`dataset-for-${i}--transformed`;r.push({id:m,source:e.map((b,h)=>[h,b[d]])}),r.push({transform:l,id:p,fromDatasetId:m}),s.push({...o,name:i,datasetId:p,xAxisId:g,showSymbol:!1,tooltip:{show:!1}}),a.push({type:"category",id:g,datasetId:p,show:!1})}),{regressionDataSets:r,regressionSeries:s,regressionXAxes:a})}const Ti={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"axis"},xAxis:{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"}},grid:{top:0,left:15,right:15,bottom:30,containLabel:!0}};function Ai(t,e){var g;const r=t.y_axes.reduce((m,{label_formatter:p},b)=>(m[b]=function(E){const v=typeof E=="object"?E.value:E;if(!p)return v;try{return Ct.default(v).format(p)}catch(S){return console.error(S),v}},m),{default:({value:m})=>m}),s=t.series.reduce((m,{yAxisIndex:p,name:b})=>(m[b]=p,m),{}),a=t.series.map(({y_axis_data_key:m,yAxisIndex:p,label_position:b,name:h,...E})=>({data:e.map(S=>S[m]),label:{show:!!b,position:b,formatter:r[p!=null?p:"default"]},name:h,xAxisId:"main-x-axis",yAxisIndex:p,...E})),{regressionDataSets:l,regressionSeries:o,regressionXAxes:i}=zi(t,e),d={xAxis:[{data:e.map(m=>m[t.x_axis_data_key]),name:(g=t.x_axis_name)!=null?g:"",id:"main-x-axis"},...i],yAxis:t.y_axes.map(({label_formatter:m,...p},b)=>{var h;return{...p,axisLabel:{show:!0,formatter:(h=r[b])!=null?h:r.default}}}),dataset:[...l],series:[...a,...o],tooltip:{formatter:function(m){const p=Array.isArray(m)?m:[m];if(p.length===0)return"";const b=p.map(({seriesName:h,value:E})=>{var _;if(!h)return E;const v=s[h],S=(_=r[v])!=null?_:r.default;return`${h}: ${S({value:E})}`});return b.unshift(`<strong>${p[0].name}</strong>`),b.join("<br />")}}};return ye.default.merge({},Ti,d)}function Di(t){const e=Array.from(t).sort((s,a)=>s-a),r=Math.floor(e.length/2);return e.length%2===0?(e[r-1]+e[r])/2:e[r]}function Oi(t,e,r){var a,l,o;const s=t.map(i=>i[e]);switch(r){case"sum":return ye.default.sum(s);case"mean":return ye.default.mean(s);case"median":return Di(s);case"max":return(a=ye.default.max(s))!=null?a:0;case"min":return(l=ye.default.min(s))!=null?l:0;default:return(o=t[0])==null?void 0:o[e]}}var Sr=function(){},gt=function(){};process.env.NODE_ENV!=="production"&&(Sr=function(t,e){!t&&typeof console<"u"&&console.warn(e)},gt=function(t,e){if(!t)throw new Error(e)});const Ii=(t,e,r)=>Math.min(Math.max(r,t),e),Er=(t,e,r)=>{const s=e-t;return s===0?1:(r-t)/s},$t=(t,e,r)=>-r*t+r*e+t,zr=(t,e)=>r=>Math.max(Math.min(r,e),t),vt=t=>t%1?Number(t.toFixed(5)):t,At=/(-)?([\d]*\.?[\d])+/g,Qt=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,Pi=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function bt(t){return typeof t=="string"}const Dt={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Tr=Object.assign(Object.assign({},Dt),{transform:zr(0,1)});Object.assign(Object.assign({},Dt),{default:1});const yt=(t=>({test:e=>bt(e)&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}))("%");Object.assign(Object.assign({},yt),{parse:t=>yt.parse(t)/100,transform:t=>yt.transform(t*100)});const Zt=(t,e)=>r=>Boolean(bt(r)&&Pi.test(r)&&r.startsWith(t)||e&&Object.prototype.hasOwnProperty.call(r,e)),Ar=(t,e,r)=>s=>{if(!bt(s))return s;const[a,l,o,i]=s.match(At);return{[t]:parseFloat(a),[e]:parseFloat(l),[r]:parseFloat(o),alpha:i!==void 0?parseFloat(i):1}},lt={test:Zt("hsl","hue"),parse:Ar("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:r,alpha:s=1})=>"hsla("+Math.round(t)+", "+yt.transform(vt(e))+", "+yt.transform(vt(r))+", "+vt(Tr.transform(s))+")"},Fi=zr(0,255),Yt=Object.assign(Object.assign({},Dt),{transform:t=>Math.round(Fi(t))}),rt={test:Zt("rgb","red"),parse:Ar("red","green","blue"),transform:({red:t,green:e,blue:r,alpha:s=1})=>"rgba("+Yt.transform(t)+", "+Yt.transform(e)+", "+Yt.transform(r)+", "+vt(Tr.transform(s))+")"};function Ri(t){let e="",r="",s="",a="";return t.length>5?(e=t.substr(1,2),r=t.substr(3,2),s=t.substr(5,2),a=t.substr(7,2)):(e=t.substr(1,1),r=t.substr(2,1),s=t.substr(3,1),a=t.substr(4,1),e+=e,r+=r,s+=s,a+=a),{red:parseInt(e,16),green:parseInt(r,16),blue:parseInt(s,16),alpha:a?parseInt(a,16)/255:1}}const Kt={test:Zt("#"),parse:Ri,transform:rt.transform},Ot={test:t=>rt.test(t)||Kt.test(t)||lt.test(t),parse:t=>rt.test(t)?rt.parse(t):lt.test(t)?lt.parse(t):Kt.parse(t),transform:t=>bt(t)?t:t.hasOwnProperty("red")?rt.transform(t):lt.transform(t)},Dr="${c}",Or="${n}";function Mi(t){var e,r,s,a;return isNaN(t)&&bt(t)&&((r=(e=t.match(At))===null||e===void 0?void 0:e.length)!==null&&r!==void 0?r:0)+((a=(s=t.match(Qt))===null||s===void 0?void 0:s.length)!==null&&a!==void 0?a:0)>0}function Ir(t){typeof t=="number"&&(t=`${t}`);const e=[];let r=0;const s=t.match(Qt);s&&(r=s.length,t=t.replace(Qt,Dr),e.push(...s.map(Ot.parse)));const a=t.match(At);return a&&(t=t.replace(At,Or),e.push(...a.map(Dt.parse))),{values:e,numColors:r,tokenised:t}}function Pr(t){return Ir(t).values}function Fr(t){const{values:e,numColors:r,tokenised:s}=Ir(t),a=e.length;return l=>{let o=s;for(let i=0;i<a;i++)o=o.replace(i<r?Dr:Or,i<r?Ot.transform(l[i]):vt(l[i]));return o}}const Li=t=>typeof t=="number"?0:t;function Bi(t){const e=Pr(t);return Fr(t)(e.map(Li))}const Rr={test:Mi,parse:Pr,createTransformer:Fr,getAnimatableNone:Bi};function Jt(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function Mr({hue:t,saturation:e,lightness:r,alpha:s}){t/=360,e/=100,r/=100;let a=0,l=0,o=0;if(!e)a=l=o=r;else{const i=r<.5?r*(1+e):r+e-r*e,d=2*r-i;a=Jt(d,i,t+1/3),l=Jt(d,i,t),o=Jt(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(l*255),blue:Math.round(o*255),alpha:s}}const ji=(t,e,r)=>{const s=t*t,a=e*e;return Math.sqrt(Math.max(0,r*(a-s)+s))},qi=[Kt,rt,lt],Lr=t=>qi.find(e=>e.test(t)),Br=t=>`'${t}' is not an animatable color. Use the equivalent color code instead.`,jr=(t,e)=>{let r=Lr(t),s=Lr(e);gt(!!r,Br(t)),gt(!!s,Br(e));let a=r.parse(t),l=s.parse(e);r===lt&&(a=Mr(a),r=rt),s===lt&&(l=Mr(l),s=rt);const o=Object.assign({},a);return i=>{for(const d in o)d!=="alpha"&&(o[d]=ji(a[d],l[d],i));return o.alpha=$t(a.alpha,l.alpha,i),r.transform(o)}},Ni=t=>typeof t=="number",Gi=(t,e)=>r=>e(t(r)),qr=(...t)=>t.reduce(Gi);function Nr(t,e){return Ni(t)?r=>$t(t,e,r):Ot.test(t)?jr(t,e):Vr(t,e)}const Gr=(t,e)=>{const r=[...t],s=r.length,a=t.map((l,o)=>Nr(l,e[o]));return l=>{for(let o=0;o<s;o++)r[o]=a[o](l);return r}},Ui=(t,e)=>{const r=Object.assign(Object.assign({},t),e),s={};for(const a in r)t[a]!==void 0&&e[a]!==void 0&&(s[a]=Nr(t[a],e[a]));return a=>{for(const l in s)r[l]=s[l](a);return r}};function Ur(t){const e=Rr.parse(t),r=e.length;let s=0,a=0,l=0;for(let o=0;o<r;o++)s||typeof e[o]=="number"?s++:e[o].hue!==void 0?l++:a++;return{parsed:e,numNumbers:s,numRGB:a,numHSL:l}}const Vr=(t,e)=>{const r=Rr.createTransformer(e),s=Ur(t),a=Ur(e);return s.numHSL===a.numHSL&&s.numRGB===a.numRGB&&s.numNumbers>=a.numNumbers?qr(Gr(s.parsed,a.parsed),r):(Sr(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),o=>`${o>0?e:t}`)},Vi=(t,e)=>r=>$t(t,e,r);function Wi(t){if(typeof t=="number")return Vi;if(typeof t=="string")return Ot.test(t)?jr:Vr;if(Array.isArray(t))return Gr;if(typeof t=="object")return Ui}function $i(t,e,r){const s=[],a=r||Wi(t[0]),l=t.length-1;for(let o=0;o<l;o++){let i=a(t[o],t[o+1]);if(e){const d=Array.isArray(e)?e[o]:e;i=qr(d,i)}s.push(i)}return s}function Qi([t,e],[r]){return s=>r(Er(t,e,s))}function Zi(t,e){const r=t.length,s=r-1;return a=>{let l=0,o=!1;if(a<=t[0]?o=!0:a>=t[s]&&(l=s-1,o=!0),!o){let d=1;for(;d<r&&!(t[d]>a||d===s);d++);l=d-1}const i=Er(t[l],t[l+1],a);return e[l](i)}}function Yi(t,e,{clamp:r=!0,ease:s,mixer:a}={}){const l=t.length;gt(l===e.length,"Both input and output ranges must be the same length"),gt(!s||!Array.isArray(s)||s.length===l-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),t[0]>t[l-1]&&(t=[].concat(t),e=[].concat(e),t.reverse(),e.reverse());const o=$i(e,s,a),i=l===2?Qi(t,o):Zi(t,o);return r?d=>i(Ii(t[0],t[l-1],d)):i}class Ki{constructor({valueRange:e,colorRange:r}){Qe(this,"mapper");this.mapper=Yi(e,r)}getColor(e){return this.mapper(e)}}function Ji(t,e){return t.type==="static"?t.staticColor:t.type==="continuous"?new Ki(t).getColor(e):"black"}function Xi(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?`Array(${t.length})`:t.toString()}function Hi(t,e){const r={};return t.forEach(({name:s,color:a,data_field:l,aggregation:o,size:i,weight:d,formatter:g})=>{const m=Oi(e,l,o);let p="";["string","number"].includes(typeof m)?p=Ct.default(m).format(g):p=Xi(m),r[s]=n(c.Text,{sx:{fontSize:i,display:"inline"},color:Ji(a,m),weight:d,children:p})}),r}function ea(t){return t.split(" ").map(e=>N(qe,{children:[e,"\xA0"]}))}function ta(t){const r=t.replaceAll("<br />","<br/>").replaceAll(`
|
|
34
|
+
`,"<br/>").split("<br/>");return r.map((a,l)=>{const o=[ea(a)];return l!==r.length-1&&o.push(n("br",{})),o}).flat().filter(a=>a!==void 0)}function Xt(t){return ta(t)}function Ht(t,e,r){const s=Hi(e,r),a=/^\{(.+)\}(.*)$/;return t.split("$").map(l=>{var g;const o=a.exec(l);if(!o)return Xt(l);const i=s[o[1]];if(!i)return Xt(l);const d=(g=o[2])!=null?g:"";return N(qe,{children:[i,Xt(d)]})})}Ze.use([ht.BarChart,ht.LineChart,ht.ScatterChart,ot.GridComponent,ot.LegendComponent,ot.TooltipComponent,kt.CanvasRenderer]),Ze.registerTransform(Bn.transform.regression);function Wr(t){return t.trim().length>0}function ra({conf:t,data:e,width:r,height:s}){const a=W.default.useMemo(()=>Ai(t,e),[t,e]);return!r||!s?null:n(St.default,{echarts:Ze,option:a,style:{width:r,height:s}})}function na({conf:t,data:e,width:r,height:s}){const{ref:a,height:l}=Be.useElementSize(),{ref:o,height:i}=Be.useElementSize(),d=W.default.useMemo(()=>{const{stats:{templates:m,variables:p}}=t;return{top:Ht(m.top,p,e),bottom:Ht(m.bottom,p,e)}},[t,e]),g=Math.max(0,s-l-i);return N(c.Box,{children:[Wr(t.stats.templates.top)&&n(c.Text,{ref:a,align:"left",size:"xs",pl:"sm",children:Object.values(d.top).map(m=>m)}),n(ra,{width:r,height:g,data:e,conf:t}),Wr(t.stats.templates.bottom)&&n(c.Text,{ref:o,align:"left",size:"xs",pl:"sm",children:Object.values(d.bottom).map(m=>m)})]})}Ze.use([ot.GridComponent,ot.VisualMapComponent,ot.LegendComponent,ot.TooltipComponent,kt.CanvasRenderer]);function ia({conf:t,data:e,width:r,height:s}){const{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:o,...i}=t,d=W.default.useMemo(()=>ye.default.minBy(e,p=>p[o])[o],[e,o]),g=W.default.useMemo(()=>ye.default.maxBy(e,p=>p[o])[o],[e,o]),m={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:d,max:g,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:{type:"value"},yAxis3D:{type:"value"},zAxis3D:{type:"value"},grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},...i,series:[{type:"bar3D",wireframe:{},data:e.map(p=>[p[a],p[l],p[o]])}]};return n(St.default,{echarts:Ze,option:m,style:{width:r,height:s}})}const oo="";Ze.use([ht.PieChart,kt.CanvasRenderer]);const aa={tooltip:{show:!0},series:{type:"pie",radius:["50%","80%"],label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
|
|
35
|
+
{percentage|{d}%}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{percentage:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},top:10,bottom:10,left:10,right:10}};function sa({conf:t,data:e,width:r,height:s}){const{label_field:a="name",value_field:l="value",...o}=t,i=W.default.useMemo(()=>e.map(m=>({name:m[a],value:Number(m[l])})),[e,a,l]),d=W.default.useMemo(()=>({series:{labelLayout:function(m){const p=m.labelRect.x<r/2,b=m.labelLinePoints;return b[2][0]=p?m.labelRect.x:m.labelRect.x+m.labelRect.width,{labelLinePoints:b}}}}),[r]),g=ye.default.merge({},aa,d,o,{series:{data:i}});return n(St.default,{echarts:Ze,option:g,style:{width:r,height:s}})}function oa({conf:{template:t,variables:e,align:r},data:s}){const a=W.default.useMemo(()=>Ht(t,e,s),[t,e,s]);return n(c.Text,{align:r,children:Object.values(a).map(l=>l)})}function la({conf:t,width:e,height:r}){return!e||!r?null:n(qt.default,{readOnly:!0,value:t.content,onChange:ye.default.noop,sx:{border:"none"}})}function ua(t){const{vizManager:e}=Ae.useContext(Wt),{viz:r,title:s,id:a,description:l,queryID:o}=Ae.useContext(je),i={title:s,id:a,description:l,queryID:o,viz:r,layout:{w:0,h:0}};try{return e.resolveComponent(r.type),n(Ci,{panel:i,data:t,vizManager:e})}catch(d){return console.info(Ie.get(d,"message")),null}}function $r(t,e,r,s){const a={width:t,height:e,data:r,conf:s.conf};switch(s.type){case"sunburst":return n(Ei,{...a});case"cartesian":return n(na,{...a});case"stats":return n(oa,{...a});case"rich-text":return n(la,{...a});case"bar-3d":return n(ia,{...a});case"pie":return n(sa,{...a});default:return null}}const ca=["rich-text"],Qr=Se.observer(function({viz:e,data:r,loading:s}){const{ref:a,width:l,height:o}=Be.useElementSize(),i=W.default.useMemo(()=>!Array.isArray(r)||r.length===0,[r]),d=ua(r);if(!(!ca.includes(e.type)||!!d))return n("div",{className:"viz-root",ref:a,children:n(Tt,{children:$r(l,o,r,e)})});const m=d||$r(l,o,r,e);return s?n("div",{className:"viz-root",ref:a,children:n(c.LoadingOverlay,{visible:s,exitTransitionDuration:0})}):N("div",{className:"viz-root",ref:a,children:[i&&n(c.Text,{color:"gray",align:"center",children:"nothing to show"}),!i&&n(Tt,{children:m})]})});function da({}){const{data:t,loading:e,viz:r}=W.default.useContext(je);return n(Qr,{viz:r,data:t,loading:e})}function fa({conf:t,setConf:e,data:r}){const s=ye.default.assign({},{x_axis_data_key:"x",y_axis_data_key:"y",z_axis_data_key:"z",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}},t),{control:a,handleSubmit:l,formState:o}=be.useForm({defaultValues:s});return n(c.Stack,{mt:"md",spacing:"xs",children:N("form",{onSubmit:l(e),children:[n(c.Text,{children:"X Axis"}),N(c.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(be.Controller,{name:"x_axis_data_key",control:a,render:({field:i})=>n(Ne,{label:"Data Field",required:!0,data:r,...i})}),n(be.Controller,{name:"xAxis3D.name",control:a,render:({field:i})=>n(c.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...i})})]}),n(c.Text,{mt:"lg",children:"Y Axis"}),N(c.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(be.Controller,{name:"y_axis_data_key",control:a,render:({field:i})=>n(Ne,{label:"Data Field",required:!0,data:r,...i})}),n(be.Controller,{name:"yAxis3D.name",control:a,render:({field:i})=>n(c.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...i})})]}),n(c.Text,{mt:"lg",children:"Z Axis"}),N(c.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(be.Controller,{name:"z_axis_data_key",control:a,render:({field:i})=>n(Ne,{label:"Data Field",required:!0,data:r,...i})}),n(be.Controller,{name:"zAxis3D.name",control:a,render:({field:i})=>n(c.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...i})})]}),n(c.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:N(c.Button,{color:"blue",type:"submit",children:[n(pe.DeviceFloppy,{size:20}),n(c.Text,{ml:"md",children:"Save"})]})})]})})}function ha({value:t,onChange:e},r){const s=c.useMantineTheme(),a=W.default.useMemo(()=>Object.entries(s.colors).map(([o,i])=>({label:o,value:i[6]})),[s]),l=W.default.useMemo(()=>a.some(o=>o.value===t),[t,a]);return N(c.Group,{position:"apart",spacing:4,children:[n(c.TextInput,{placeholder:"Set any color",value:l?"":t,onChange:o=>e(o.currentTarget.value),rightSection:n(c.ColorSwatch,{color:l?"transparent":t,radius:4}),variant:l?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),n(c.Text,{sx:{flexGrow:0},children:"or"}),n(c.Select,{data:a,value:t,onChange:e,variant:l?"default":"filled",placeholder:"Pick a theme color",icon:n(c.ColorSwatch,{color:l?t:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const er=W.default.forwardRef(ha);function pa({control:t,index:e}){return N(c.Group,{grow:!0,align:"top",children:[n(be.Controller,{name:`series.${e}.stack`,control:t,render:({field:r})=>n(c.TextInput,{label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1},...r})}),n(be.Controller,{name:`series.${e}.barWidth`,control:t,render:({field:r})=>n(c.TextInput,{label:"Bar Width",sx:{flexGrow:1},...r})})]})}const ma=[{label:"off",value:"false"},{label:"start",value:"start"},{label:"middle",value:"middle"},{label:"end",value:"end"}];function ga({control:t,index:e}){return N(c.Group,{grow:!0,align:"center",children:[n(be.Controller,{name:`series.${e}.step`,control:t,render:({field:r})=>n(c.Select,{label:"Step",data:ma,sx:{flexGrow:1,maxWidth:"48%"},...r,value:String(r.value),onChange:s=>{const a=s==="false"?!1:s;r.onChange(a)}})}),n(be.Controller,{name:`series.${e}.smooth`,control:t,render:({field:r})=>n(c.Box,{sx:{flexGrow:1},children:n(c.Switch,{label:"Smooth Line",checked:r.value,onChange:s=>r.onChange(s.currentTarget.checked)})})})]})}const va=Array.from(new Array(9),(t,e)=>({label:String(e+1),value:e+1}));function ba({control:t,index:e}){return n(c.Group,{grow:!0,align:"center",children:n(be.Controller,{name:`series.${e}.symbolSize`,control:t,render:({field:r})=>N(c.Stack,{sx:{flexGrow:1},pb:16,spacing:4,children:[n(c.Text,{size:"sm",children:"Size"}),n(c.Slider,{min:1,max:10,marks:va,...r,sx:{width:"100%"}})]})})})}const ya=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function _a({control:t,index:e,remove:r,seriesItem:s,yAxisOptions:a,data:l}){const o=s.type;return N(c.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n(c.Stack,{children:n(be.Controller,{name:`series.${e}.type`,control:t,render:({field:i})=>n(c.SegmentedControl,{data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter"},{label:"Boxplot",value:"boxplot",disabled:!0}],...i})})}),n(be.Controller,{name:`series.${e}.name`,control:t,render:({field:i})=>n(c.TextInput,{label:"Name",required:!0,sx:{flex:1},...i})}),N(c.Group,{grow:!0,noWrap:!0,children:[n(be.Controller,{name:`series.${e}.y_axis_data_key`,control:t,render:({field:i})=>n(Ne,{label:"Value Field",required:!0,data:l,sx:{flex:1},...i})}),n(be.Controller,{name:`series.${e}.yAxisIndex`,control:t,render:({field:{value:i,onChange:d,...g}})=>{var m;return n(c.Select,{label:"Y Axis",data:a,disabled:a.length===0,...g,value:(m=i==null?void 0:i.toString())!=null?m:"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})}})]}),o==="line"&&n(ga,{index:e,control:t}),o==="bar"&&n(pa,{index:e,control:t}),o==="scatter"&&n(ba,{index:e,control:t}),n(be.Controller,{name:`series.${e}.label_position`,control:t,render:({field:i})=>n(c.Select,{label:"Label Position",data:ya,...i})}),N(c.Stack,{spacing:4,children:[n(c.Text,{size:"sm",children:"Color"}),n(be.Controller,{name:`series.${e}.color`,control:t,render:({field:i})=>n(er,{...i})})]}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r(e),sx:{position:"absolute",top:15,right:5},children:n(pe.Trash,{size:16})})]},e)}function wa({control:t,watch:e,getValues:r,data:s}){const{fields:a,append:l,remove:o}=be.useFieldArray({control:t,name:"series"}),i=e("series"),d=a.map((p,b)=>({...p,...i[b]})),g=()=>l({type:"bar",name:Be.randomId(),showSymbol:!1,symbolSize:5,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",stack:"",color:"#000",step:!1,smooth:!1}),m=W.default.useMemo(()=>r().y_axes.map(({name:p},b)=>({label:p,value:b.toString()})),[r]);return N(c.Stack,{children:[d.map((p,b)=>n(_a,{control:t,index:b,remove:o,seriesItem:p,yAxisOptions:m,data:s})),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:g,children:"Add a Series"})})]})}const Zr={mantissa:0,output:"number"};function xa({value:t,onChange:e},r){const s=o=>{e({...t,output:o})},a=o=>{const i=o===0?!1:t.trimMantissa;e({...t,mantissa:o,trimMantissa:i})},l=o=>{e({...t,trimMantissa:o.currentTarget.checked})};return n(c.Stack,{ref:r,children:N(c.Group,{grow:!0,children:[n(c.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:t.output,onChange:s}),n(c.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:t.mantissa,onChange:a}),n(c.Switch,{label:"Trim mantissa",checked:t.trimMantissa,onChange:l,disabled:t.mantissa===0})]})})}const Yr=W.default.forwardRef(xa);function ka({control:t,index:e,remove:r}){return N(c.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n(c.Group,{grow:!0,noWrap:!0,children:n(be.Controller,{name:`y_axes.${e}.name`,control:t,render:({field:s})=>n(c.TextInput,{label:"Name",required:!0,sx:{flex:1},...s})})}),n(c.Stack,{children:n(be.Controller,{name:`y_axes.${e}.label_formatter`,control:t,render:({field:s})=>n(Yr,{...s})})}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r(e),sx:{position:"absolute",top:15,right:5},disabled:e===0,children:n(pe.Trash,{size:16})})]},e)}function Ca({control:t,watch:e}){const{fields:r,append:s,remove:a}=be.useFieldArray({control:t,name:"y_axes"}),l=e("y_axes"),o=r.map((d,g)=>({...d,...l[g]})),i=()=>s({name:"",label_formatter:Zr});return N(c.Stack,{children:[o.map((d,g)=>n(ka,{control:t,index:g,remove:a})),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:i,children:"Add a Y Axis"})})]})}const Sa=[{label:"Linear",value:"linear"},{label:"Exponential",value:"exponential"},{label:"Logarithmic",value:"logarithmic"},{label:"Polynomial",value:"polynomial"}];function Ea({control:t,regressionItem:e,index:r,remove:s,yAxisOptions:a,data:l}){const o=e.transform.config.method;return N(c.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n(be.Controller,{name:`regressions.${r}.name`,control:t,render:({field:i})=>n(c.TextInput,{label:"Name",required:!0,sx:{flex:1},...i})}),N(c.Group,{grow:!0,noWrap:!0,children:[n(be.Controller,{name:`regressions.${r}.y_axis_data_key`,control:t,render:({field:i})=>n(Ne,{label:"Value Field",required:!0,data:l,sx:{flex:1},...i})}),n(be.Controller,{name:`regressions.${r}.plot.yAxisIndex`,control:t,render:({field:{value:i,onChange:d,...g}})=>{var m;return n(c.Select,{label:"Y Axis",data:a,disabled:a.length===0,...g,value:(m=i==null?void 0:i.toString())!=null?m:"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})}})]}),N(c.Group,{grow:!0,noWrap:!0,children:[n(be.Controller,{name:`regressions.${r}.transform.config.method`,control:t,render:({field:i})=>n(c.Select,{label:"Method",data:Sa,sx:{flex:1},...i})}),o==="polynomial"&&n(be.Controller,{name:`regressions.${r}.transform.config.order`,control:t,render:({field:i})=>n(c.NumberInput,{label:"Order",sx:{flex:1},...i})})]}),N(c.Stack,{spacing:4,children:[n(c.Text,{size:"sm",children:"Color"}),n(be.Controller,{name:`regressions.${r}.plot.color`,control:t,render:({field:i})=>n(er,{...i})})]}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>s(r),sx:{position:"absolute",top:15,right:5},children:n(pe.Trash,{size:16})})]},r)}function za({control:t,watch:e,getValues:r,data:s}){const{fields:a,append:l,remove:o}=be.useFieldArray({control:t,name:"regressions"}),i=e("regressions"),d=a.map((p,b)=>({...p,...i[b]})),g=W.default.useMemo(()=>r().y_axes.map(({name:p},b)=>({label:p,value:b.toString()})),[r]),m=()=>l({transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},name:"",y_axis_data_key:"",plot:{type:"line",yAxisIndex:0,color:"#666666"}});return N(c.Stack,{children:[d.map((p,b)=>n(Ea,{regressionItem:p,control:t,index:b,remove:o,yAxisOptions:g,data:s})),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:m,children:"Add a Regression Line"})})]})}const Ta=[{label:"None",value:"none"},{label:"Sum",value:"sum"},{label:"Mean",value:"mean"},{label:"Median",value:"median"},{label:"Max",value:"max"},{label:"Min",value:"min"}];function Aa({label:t,value:e,onChange:r},s){return n(c.Select,{ref:s,label:t,data:Ta,value:e,onChange:r})}const Da=W.default.forwardRef(Aa);function Oa({label:t,value:e,onChange:r},s){const[a,l]=W.default.useState(Array.isArray(e)?[...e]:[]),o=W.default.useCallback(()=>{l(b=>[...b,""])},[l]),i=W.default.useCallback(b=>{l(h=>(h.splice(b,1),[...h]))},[l]),d=W.default.useMemo(()=>!ye.default.isEqual(a,e),[a,e]),g=()=>{r(a.map(b=>b.toString()))},m=c.useMantineTheme(),p=W.default.useMemo(()=>Object.entries(m.colors).map(([b,h])=>h[6]),[m]);return N(qe,{children:[N(c.Group,{position:"left",ref:s,children:[n(c.Text,{children:t}),n(c.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:g,children:n(pe.DeviceFloppy,{size:20})})]}),N(c.Group,{children:[a.map((b,h)=>n(c.ColorInput,{value:b,onChange:E=>{l(v=>(v.splice(h,1,E),[...v]))},swatches:p,rightSection:n(c.ActionIcon,{onClick:()=>i(h),color:"red",children:n(pe.Trash,{size:14})}),sx:{width:"45%"}})),n(c.ActionIcon,{onClick:o,color:"blue",variant:"outline",children:n(pe.PlaylistAdd,{size:20})})]})]})}const Ia=W.default.forwardRef(Oa),It=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function Pa({label:t,value:e,onChange:r},s){var o,i;const[a,l]=W.default.useState((i=(o=It.find(d=>d.label===e))==null?void 0:o.value)!=null?i:It[0].value);return W.default.useEffect(()=>{const d=It.find(g=>g.value===a);d&&r(d.label)},[a]),N(c.Stack,{spacing:0,mt:"sm",mb:"lg",children:[n(c.Text,{size:"sm",children:t}),n(c.Slider,{label:null,marks:It,value:a,onChange:l,step:25,placeholder:"Pick a font size",ref:s})]})}const Fa=W.default.forwardRef(Pa);function Ra({label:t,value:e,onChange:r},s){const[a,l]=W.default.useState(Array.isArray(e)?[...e]:[]),o=W.default.useCallback(()=>{l(m=>[...m,""])},[l]),i=W.default.useCallback(m=>{l(p=>(p.splice(m,1),[...p]))},[l]),d=W.default.useMemo(()=>!ye.default.isEqual(a,e),[a,e]),g=()=>{r(a.map(m=>m.toString()))};return N(qe,{children:[N(c.Group,{position:"left",ref:s,children:[n(c.Text,{children:t}),n(c.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:g,children:n(pe.DeviceFloppy,{size:20})})]}),N(c.Group,{children:[a.map((m,p)=>n(c.TextInput,{value:m,onChange:b=>{const h=b.currentTarget.value;l(E=>(E.splice(p,1,h),[...E]))},rightSection:n(c.ActionIcon,{onClick:()=>i(p),color:"red",children:n(pe.Trash,{size:14})}),sx:{width:"45%"}})),n(c.ActionIcon,{onClick:o,color:"blue",variant:"outline",children:n(pe.PlaylistAdd,{size:20})})]})]})}const Ma=W.default.forwardRef(Ra);function Kr(){return{name:Be.randomId(),size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:"none",formatter:{output:"number",mantissa:0}}}const tr=W.default.forwardRef(function({value:e,onChange:r,...s},a){return n(c.TextInput,{ref:a,value:e,onChange:r,...s})}),Jr=W.default.forwardRef(function({value:e,onChange:r,data:s},a){const l=e.color.type,o=(i,d)=>{const g=ye.default.cloneDeep(e);ye.default.set(g,i,d),r(g)};return N(c.Box,{px:"sm",py:"md",children:[n(c.Text,{weight:"bold",pb:0,children:e.name}),n(c.Divider,{my:"xs",label:"Data",labelPosition:"center"}),N(c.Group,{grow:!0,noWrap:!0,children:[n(c.TextInput,{label:"Name",required:!0,value:e.name,onChange:i=>o("name",i.currentTarget.value)}),n(Ne,{label:"Data Field",required:!0,data:s,value:e.data_field,onChange:i=>o("data_field",i)}),n(Da,{label:"Aggregation",value:e.aggregation,onChange:i=>o("aggregation",i)})]}),n(Yr,{value:e.formatter,onChange:i=>o("formatter",i)}),n(c.Divider,{my:"xs",label:"Typography",labelPosition:"center"}),n(c.Stack,{children:n(c.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},value:e.size,onChange:i=>o("size",i.currentTarget.value)})}),n(c.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:n(Fa,{label:"Font Weight",value:e.weight,onChange:i=>o("weight",i)})}),n(c.Divider,{my:"xs",label:"Style",labelPosition:"center"}),N(c.Stack,{children:[n(c.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:e.color.type,onChange:i=>o("color.type",i)}),l==="static"&&n(er,{value:e.color.staticColor,onChange:i=>o("color.staticColor",i)}),l==="continuous"&&N(qe,{children:[n(Ma,{label:"Value Range",value:e.color.valueRange,onChange:i=>o("color.valueRange",i)}),n(Ia,{label:"Color Range",value:e.color.colorRange,onChange:i=>o("color.colorRange",i)})]})]})]})});function La({control:t,index:e,remove:r,data:s}){return N(c.Stack,{my:"sm",p:0,sx:{border:"1px solid #eee",borderTopColor:"#333",borderTopWidth:2,position:"relative"},children:[n(be.Controller,{name:`stats.variables.${e}`,control:t,render:({field:a})=>n(Jr,{data:s,...a})}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r(e),sx:{position:"absolute",top:15,right:5},children:n(pe.Trash,{size:16})})]},e)}function Ba({control:t,watch:e,data:r}){const{fields:s,append:a,remove:l}=be.useFieldArray({control:t,name:"stats.variables"});e("stats.templates");const o=e("stats.variables"),i=s.map((g,m)=>({...g,...o[m]})),d=()=>a(Kr());return N(c.Stack,{children:[N(c.Stack,{spacing:0,children:[n(be.Controller,{name:"stats.templates.top",control:t,render:({field:g})=>n(tr,{label:"Template for stats above the chart",py:"md",sx:{flexGrow:1},...g})}),n(be.Controller,{name:"stats.templates.bottom",control:t,render:({field:g})=>n(tr,{label:"Template for stats under the chart",py:"md",sx:{flexGrow:1},...g})})]}),i.map((g,m)=>n(La,{control:t,index:m,remove:l,data:r})),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:d,children:"Add a Variable"})})]})}function ja(t){function e({type:r,name:s,showSymbol:a,symbolSize:l=5,y_axis_data_key:o="value",yAxisIndex:i=0,label_position:d="top",stack:g="1",color:m="black",barWidth:p="30",smooth:b=!1,step:h=!1}){return{type:r,name:s,showSymbol:a,symbolSize:l,y_axis_data_key:o,yAxisIndex:i,label_position:d,stack:g,color:m,barWidth:p,smooth:b,step:h}}return t.map(e)}function qa(t){return t||{templates:{top:"",bottom:""},variables:[]}}function Na({conf:t,setConf:e,data:r}){const{series:s,y_axes:a,...l}=t,o=W.default.useMemo(()=>{const{x_axis_name:h="",stats:E,...v}=l;return{series:ja(s!=null?s:[]),x_axis_name:h,y_axes:a!=null?a:[{name:"Y Axis",label_formatter:Zr}],stats:qa(E),...v}},[s,l]);W.default.useEffect(()=>{!ye.default.isEqual(t,o)&&e(o)},[t,o]);const{control:i,handleSubmit:d,watch:g,getValues:m}=be.useForm({defaultValues:o});g(["x_axis_data_key","x_axis_name"]);const p=m(),b=W.default.useMemo(()=>!ye.default.isEqual(p,t),[p,t]);return n(c.Stack,{mt:"md",spacing:"xs",children:N("form",{onSubmit:d(e),children:[N(c.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n(c.Text,{children:"Chart Config"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!b,children:n(pe.DeviceFloppy,{size:20})})]}),N(c.Accordion,{multiple:!0,value:["X Axis","Y Axes"],children:[n(c.Accordion.Item,{value:"X Axis",children:N(c.Group,{grow:!0,noWrap:!0,children:[n(be.Controller,{name:"x_axis_data_key",control:i,render:({field:h})=>n(Ne,{label:"X Axis Data Field",required:!0,data:r,sx:{flex:1},...h})}),n(be.Controller,{name:"x_axis_name",control:i,render:({field:h})=>n(c.TextInput,{label:"X Axis Name",sx:{flex:1},...h})})]})}),n(c.Accordion.Item,{value:"Y Axes",children:n(Ca,{control:i,watch:g})}),n(c.Accordion.Item,{value:"Series",children:n(wa,{control:i,watch:g,getValues:m,data:r})}),n(c.Accordion.Item,{value:"Regression Lines",children:n(za,{control:i,watch:g,getValues:m,data:r})}),n(c.Accordion.Item,{value:"Stats",children:n(Ba,{control:i,watch:g,data:r})})]})]})})}function Ga({conf:{label_field:t,value_field:e},setConf:r,data:s}){const a=jt.useForm({initialValues:{label_field:t,value_field:e}});return n(c.Stack,{mt:"md",spacing:"xs",children:N("form",{onSubmit:a.onSubmit(r),children:[N(c.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[n(c.Text,{children:"Pie Config"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:n(pe.DeviceFloppy,{size:20})})]}),N(c.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[n(Ne,{label:"Label Field",required:!0,data:s,...a.getInputProps("label_field")}),n(Ne,{label:"Value Field",required:!0,data:s,...a.getInputProps("value_field")})]})]})})}function Ua({conf:t,setConf:e}){const r=W.default.useMemo(()=>{const{content:g=""}=t;return{content:g}},[t]);W.default.useEffect(()=>{!ye.default.isEqual(t,r)&&e(r)},[t,r]);const{control:s,handleSubmit:a,watch:l,getValues:o}=be.useForm({defaultValues:r});l("content");const i=o(),d=W.default.useMemo(()=>!ye.default.isEqual(i,t),[i,t]);return n(c.Stack,{mt:"md",spacing:"xs",children:N("form",{onSubmit:a(e),children:[N(c.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n(c.Text,{children:"Content"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!d,children:n(pe.DeviceFloppy,{size:20})})]}),n(be.Controller,{name:"content",control:s,render:({field:g})=>n(qt.default,{sx:{flex:1},...g})})]})})}function Va(t){if("variables"in t)return t;const{align:e,size:r,weight:s,color:a,content:{prefix:l="",data_field:o="value",formatter:i={output:"number",mantissa:0},postfix:d=""}={}}=t;return{align:e,template:`${l} \${value} ${d}`,variables:[{name:"value",data_field:o,aggregation:"none",formatter:i,color:a,weight:s,size:r}]}}function Wa({control:t,index:e,remove:r,data:s}){return N(c.Stack,{my:"sm",p:0,sx:{border:"1px solid #eee",borderTopColor:"#333",borderTopWidth:2,position:"relative"},children:[n(be.Controller,{name:`variables.${e}`,control:t,render:({field:a})=>n(Jr,{data:s,...a})}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r(e),sx:{position:"absolute",top:15,right:5},children:n(pe.Trash,{size:16})})]},e)}function $a({control:t,watch:e,data:r}){const{fields:s,append:a,remove:l}=be.useFieldArray({control:t,name:"variables"}),o=e("variables"),i=s.map((g,m)=>({...g,...o[m]})),d=()=>a(Kr());return N(c.Stack,{children:[i.map((g,m)=>n(Wa,{control:t,index:m,remove:l,data:r})),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:d,children:"Add a Variable"})})]})}function Qa(){return{align:"center",template:"The variable ${value} is defined in Variables section",variables:[{name:"value",size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:"none",formatter:{output:"number",mantissa:0}}]}}function Za({conf:t,setConf:e,data:r}){const s=W.default.useMemo(()=>{const{align:m,template:p="",variables:b=[]}=Va(t);return m?{variables:b,template:p,align:m}:Qa()},[t]);W.default.useEffect(()=>{!ye.default.isEqual(t,s)&&e(s)},[t,s]);const{control:a,handleSubmit:l,watch:o,getValues:i}=be.useForm({defaultValues:s});o(["variables","template"]);const d=i(),g=W.default.useMemo(()=>!ye.default.isEqual(d,t),[d,t]);return n(c.Stack,{mt:"md",spacing:"xs",children:N("form",{onSubmit:l(e),children:[N(c.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n(c.Text,{weight:500,children:"Stats Configurations"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!g,children:n(pe.DeviceFloppy,{size:20})})]}),n(be.Controller,{name:"template",control:a,render:({field:m})=>n(tr,{label:"Template",py:"md",sx:{flexGrow:1},...m})}),n(c.Text,{pb:"sm",pt:"md",size:"sm",children:"Variables"}),n($a,{control:a,watch:o,data:r})]})})}function Ya({conf:{label_field:t,value_field:e},setConf:r,data:s}){const a=jt.useForm({initialValues:{label_field:t,value_field:e}});return n(c.Stack,{mt:"md",spacing:"xs",children:N("form",{onSubmit:a.onSubmit(r),children:[N(c.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[n(c.Text,{children:"Sunburst Config"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:n(pe.DeviceFloppy,{size:20})})]}),N(c.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[n(Ne,{label:"Label Field",required:!0,data:s,...a.getInputProps("label_field")}),n(Ne,{label:"Value Field",required:!0,data:s,...a.getInputProps("value_field")})]})]})})}const rr=[{value:"stats",label:"Stats",Panel:Za},{value:"rich-text",label:"Rich Text",Panel:Ua},{value:"sunburst",label:"Sunburst",Panel:Ya},{value:"bar-3d",label:"Bar Chart (3D)",Panel:fa},{value:"cartesian",label:"Cartesian Chart",Panel:Na},{value:"pie",label:"Pie Chart",Panel:Ga}];function Ka(){const{viz:t,title:e,data:r,queryID:s,description:a,setDescription:l,setTitle:o,setQueryID:i,setViz:d,id:g}=Ae.useContext(je),{vizManager:m}=Ae.useContext(Wt),p={title:e,description:a,viz:t,queryID:s,id:g},b={setDescription:l,setQueryID:i,setTitle:o};try{return m.resolveComponent(p.viz.type),n(ki,{setVizConf:d,panel:p,panelInfoEditor:b,vizManager:m,data:r})}catch(h){return console.info(Ie.get(h,"message")),null}}function Ja(){const{data:t,viz:e,setViz:r}=W.default.useContext(je),[s,a]=Be.useInputState(e.type),l=e.type!==s,o=W.default.useCallback(()=>{!l||r(h=>({...h,type:s}))},[l,s]),i=h=>{r(E=>({...E,conf:h}))},d=h=>{try{i(JSON.parse(h))}catch(E){console.error(E)}},g=W.default.useMemo(()=>{var h;return(h=rr.find(E=>E.value===s))==null?void 0:h.Panel},[s,rr]),m=Ka(),p=g?Ae.createElement(g,{data:t,conf:e.conf,setConf:i}):null,b=m||p;return N(qe,{children:[n(c.Select,{label:"Visualization",value:s,onChange:a,data:rr,rightSection:n(c.ActionIcon,{disabled:!l,onClick:o,children:n(pe.DeviceFloppy,{size:20})})}),b,!b&&n(c.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:d})]})}function Xa({}){return N(c.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n(c.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0,overflow:"scroll",height:"100%"},children:n(Ja,{})}),n(c.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:n(da,{})})]})}const Ha=Se.observer(function({opened:e,close:r}){const{freezeLayout:s}=W.default.useContext($e),{data:a,loading:l,viz:o,title:i}=W.default.useContext(je);return W.default.useEffect(()=>{s(e)},[e]),n(c.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:i,trapFocus:!0,onDragStart:d=>{d.stopPropagation()},children:n(c.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",minHeight:"unset",maxHeight:"100%",width:"100%",padding:"16px"}},padding:"md",children:N(c.Tabs,{defaultValue:"Visualization",className:"panel-settings-tabs",children:[N(c.Tabs.List,{children:[n(c.Tabs.Tab,{value:"Data",children:"Data"}),n(c.Tabs.Tab,{value:"Panel",children:"Panel"}),n(c.Tabs.Tab,{value:"Visualization",children:"Visualization"})]}),N(c.Tabs.Panel,{value:"Data",pt:"sm",children:[n(c.LoadingOverlay,{visible:l,exitTransitionDuration:0}),n(ti,{})]}),n(c.Tabs.Panel,{value:"Panel",pt:"sm",children:n(Hn,{})}),n(c.Tabs.Panel,{value:"Visualization",pt:"sm",children:n(Xa,{})})]})})})}),lo="",es=Se.observer(function({}){const e=Me(),r=Bt.useModals(),[s,a]=W.default.useState(!1),l=()=>a(!0),o=()=>a(!1),{id:i,title:d,queryID:g}=W.default.useContext(je),{inEditMode:m}=W.default.useContext($e),p=()=>e.queries.refetchDataByQueryID(g),{duplidatePanel:b,removePanelByID:h,viewPanelInFullScreen:E,inFullScreen:v}=W.default.useContext(Et),S=W.default.useCallback(()=>{b(i)},[b,i]),_=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>h(i)}),z=W.default.useCallback(()=>{E(i)},[i,E]);return N(c.Box,{sx:{position:"relative"},children:[n(c.Box,{sx:{position:"absolute",left:0,top:0,height:28},children:n(gr,{})}),n(c.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:N(c.Menu,{children:[n(c.Menu.Target,{children:n(c.Text,{lineClamp:1,weight:"bold",children:d})}),N(c.Menu.Dropdown,{children:[n(c.Menu.Item,{onClick:p,icon:n(pe.Refresh,{size:14}),children:"Refresh"}),n(c.Menu.Item,{onClick:()=>e.queries.downloadDataByQueryID(g),icon:n(pe.Download,{size:14}),children:"Download Data"}),!v&&n(c.Menu.Item,{onClick:z,icon:n(pe.ArrowsMaximize,{size:14}),children:"Full Screen"}),m&&N(qe,{children:[n(c.Divider,{label:"Edit",labelPosition:"center"}),n(c.Menu.Item,{onClick:l,icon:n(pe.Settings,{size:14}),children:"Settings"}),n(c.Menu.Item,{onClick:S,icon:n(pe.Copy,{size:14}),children:"Duplicate"}),n(c.Menu.Item,{color:"red",onClick:_,icon:n(pe.Trash,{size:14}),children:"Delete"})]})]})]})}),m&&n(Ha,{opened:s,close:o})]})}),uo="",Pt=Se.observer(function({viz:e,queryID:r,title:s,description:a,update:l,layout:o,id:i}){const d=Me(),[g,m]=W.default.useState(s),[p,b]=W.default.useState(a),[h,E]=W.default.useState(r),[v,S]=W.default.useState(e);W.default.useEffect(()=>{l==null||l({id:i,layout:o,title:g,description:p,queryID:h,viz:v})},[g,p,v,i,o,h]);const{data:_,state:z,error:I}=d.getDataStuffByID(h),M=z==="loading";return n(je.Provider,{value:{id:i,data:_,loading:M,title:g,setTitle:m,description:p,setDescription:b,queryID:h,setQueryID:E,viz:v,setViz:S},children:N(c.Container,{className:"panel-root",children:[n(es,{}),n(Qr,{viz:v,data:_,loading:M})]})})}),co="",ts=Lt.WidthProvider(fr.default),Xr=Se.observer(function({panels:e,setPanels:r,className:s="layout",rowHeight:a=10,isDraggable:l,isResizable:o}){const i=W.default.useCallback(d=>{const g=new Map;d.forEach(({i:p,...b})=>{g.set(p,b)});const m=e.map(p=>({...p,layout:g.get(p.id)}));r(m)},[e,r]);return n(ts,{onLayoutChange:i,className:`dashboard-layout ${s}`,rowHeight:a,isDraggable:l,isResizable:o,children:e.map(({id:d,...g},m)=>n("div",{"data-grid":g.layout,children:n(Pt,{id:d,...g,update:p=>{r(b=>(b.splice(m,1,p),[...b]))}})},d))})});function nr(t,e){return N(c.Text,{size:"xs",sx:{svg:{verticalAlign:"bottom"}},children:[t," ",e]})}function rs({mode:t,setMode:e}){return n(c.SegmentedControl,{size:"xs",value:t,onChange:e,data:[{label:nr(n(pe.PlayerPlay,{size:20}),"Use"),value:Ve.Use},{label:nr(n(pe.Resize,{size:20}),"Edit Layout"),value:Ve.Layout},{label:nr(n(pe.Paint,{size:20}),"Edit Content"),value:Ve.Edit}]})}const ns=`
|
|
12
36
|
-- You may reference global variables in SQL or VizConfig.
|
|
13
37
|
SELECT *
|
|
14
38
|
FROM commit
|
|
@@ -20,21 +44,16 @@ WHERE
|
|
|
20
44
|
-- SQL snippets
|
|
21
45
|
AND \${sql_snippets.author_email_condition}
|
|
22
46
|
\${sql_snippets.order_by_clause}
|
|
23
|
-
`;function pi({showSQLSnippets:e=!0,sx:r={}}){const t=h.default.useContext(Ie),n=h.default.useContext(Ye),{sqlSnippets:i}=h.default.useContext(ce),a=h.default.useMemo(()=>{const o={context:t,filters:n};if(e){const u=i.reduce((c,d)=>(c[d.key]=d.value,c),{});o.sql_snippets=u}return JSON.stringify(o,null,2)},[t,i,n,e]);return b(s.Stack,{sx:{border:"1px solid #eee",maxWidth:"40%",overflow:"hidden",...r},children:[l(s.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:l(s.Text,{weight:500,children:"Global Variables"})}),b(s.Stack,{px:"md",pb:"md",sx:{width:"100%"},children:[l($e.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:es}),l(s.Text,{weight:500,sx:{flexGrow:0},children:"Current Values"}),l($e.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:a})]})]})}function hi({value:e}){const r=h.default.useContext(Ie),t=h.default.useContext(Ye),n=h.default.useContext(ce),i=h.default.useMemo(()=>Jo(e,r,n,t),[e,r,n,t]);return l($e.Prism,{language:"sql",colorScheme:"light",children:i})}function ts({value:e,onChange:r}){const t=St.useForm({initialValues:e}),n=h.default.useCallback(d=>{r(d)},[r]),i=h.default.useMemo(()=>!C.default.isEqual(e,t.values),[e,t.values]);h.default.useEffect(()=>{t.reset()},[e]);const{data:a=[],loading:o}=Be.useRequest(Rn,{refreshDeps:[]},[]),u=h.default.useMemo(()=>Array.from(new Set(a.map(({type:f})=>f))).map(f=>({label:f,value:f})),[a]),c=h.default.useMemo(()=>{const d=a.filter(({type:f})=>f===t.values.type);return d?d.map(({key:f})=>({label:f,value:f})):[]},[a,t.values.type]);return l(s.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:b("form",{onSubmit:t.onSubmit(n),children:[b(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(s.Text,{weight:500,children:"Edit Query"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!i||o,children:l(_.DeviceFloppy,{size:20})})]}),b(s.Stack,{my:0,p:"md",pr:40,children:[b(s.Group,{grow:!0,children:[l(s.TextInput,{placeholder:"An ID unique in this dashboard",label:"ID",required:!0,sx:{flex:1},disabled:o,...t.getInputProps("id")}),l(s.Select,{label:"Data Source Type",data:u,sx:{flex:1},disabled:o,...t.getInputProps("type")}),l(s.Select,{label:"Data Source Key",data:c,sx:{flex:1},disabled:o,...t.getInputProps("key")})]}),b(s.Tabs,{defaultValue:"SQL",children:[b(s.Tabs.List,{children:[l(s.Tabs.Tab,{value:"SQL",children:"SQL"}),l(s.Tabs.Tab,{value:"Preview",children:"Preview"})]}),l(s.Tabs.Panel,{value:"SQL",pt:"sm",children:l(s.Textarea,{autosize:!0,minRows:12,maxRows:24,...t.getInputProps("sql"),className:"code-textarea"})}),l(s.Tabs.Panel,{value:"Preview",pt:"sm",children:l(hi,{value:t.values.sql})})]})]})]})})}function rs({id:e,setID:r}){const{queries:t,setQueries:n}=h.default.useContext(ce),i=h.default.useMemo(()=>t.find(o=>o.id===e),[t,e]),a=h.default.useCallback(o=>{if(t.findIndex(c=>c.id===e)===-1){console.error(new Error("Invalid data source id when updating by id"));return}n(c=>{const d=c.findIndex(f=>f.id===e);return c.splice(d,1,o),[...c]}),r(o.id)},[e,t,n,r]);return e?i?l(ts,{value:i,onChange:a}):l("span",{children:"Invalid Data Source ID"}):null}function ns({id:e,setID:r}){const{queries:t,setQueries:n}=h.default.useContext(ce),i=h.default.useCallback(()=>{var u,c;r((c=(u=t[0])==null?void 0:u.id)!=null?c:"")},[r,t]);h.default.useEffect(()=>{if(!e){i();return}t.findIndex(c=>c.id===e)===-1&&i()},[e,t,i]);const a=h.default.useMemo(()=>t.map(u=>({value:u.id,label:u.id})),[t]),o=h.default.useCallback(()=>{const u={id:W.randomId(),type:"postgresql",key:"",sql:""};n(c=>[...c,u]),r(u.id)},[n,r]);return l(s.Group,{pb:"xl",children:b(s.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[l(s.Text,{children:"Select a Query"}),l(s.Select,{data:a,value:e,onChange:r,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}}),l(s.Text,{children:"or"}),l(s.Group,{position:"center",mt:"md",children:l(s.Button,{onClick:o,children:"Add a Query"})})]})})}function is({}){const[e,r]=h.default.useState("");return b(s.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:[b(s.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[b(s.Stack,{sx:{flexGrow:1,maxWidth:"calc(60% - 16px)"},children:[l(ns,{id:e,setID:r}),l(rs,{id:e,setID:r})]}),l(pi,{})]}),l(Ln,{id:e})]})}function as({value:e}){const r=h.default.useContext(Ie),t=h.default.useMemo(()=>Ho(e,r),[e,r]);return b(s.Stack,{children:[l(s.Text,{children:"Preview"}),l($e.Prism,{language:"sql",noCopy:!0,colorScheme:"dark",children:t})]})}function os({}){const{sqlSnippets:e,setSQLSnippets:r}=h.default.useContext(ce),t=h.default.useMemo(()=>({snippets:e!=null?e:[]}),[e]),n=St.useForm({initialValues:t}),i=()=>n.insertListItem("snippets",{key:W.randomId(),value:""}),a=h.default.useMemo(()=>!C.default.isEqual(n.values,t),[n.values,t]),o=({snippets:u})=>{r(u)};return l(s.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:b("form",{onSubmit:n.onSubmit(o),children:[b(s.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:[l(s.Text,{weight:500,children:"SQL Snippets"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!a,children:l(_.DeviceFloppy,{size:20})})]}),l(s.Group,{px:"md",pb:"md",pt:"md",children:b(s.Stack,{sx:{width:"100%",position:"relative"},children:[n.values.snippets.map((u,c)=>b(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[l(s.TextInput,{label:"Key",required:!0,...n.getInputProps(`snippets.${c}.key`)}),l(s.Textarea,{minRows:3,label:"Value",required:!0,...n.getInputProps(`snippets.${c}.value`),className:"code-textarea"}),l(as,{value:n.values.snippets[c].value}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>n.removeListItem("snippets",c),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},c)),l(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:l(s.Button,{variant:"default",onClick:i,children:"Add a snippet"})})]})})]})})}function us({}){return l(s.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:b(s.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[l(os,{}),l(pi,{showSQLSnippets:!1})]})})}function ls({opened:e,close:r}){const{freezeLayout:t}=h.default.useContext(be);return h.default.useEffect(()=>{t(e)},[e]),l(s.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:"Data Settings",trapFocus:!0,onDragStart:n=>{n.stopPropagation()},children:b(s.Tabs,{defaultValue:"Queries",children:[b(s.Tabs.List,{children:[l(s.Tabs.Tab,{value:"SQL Snippet",children:"SQL Snippet"}),l(s.Tabs.Tab,{value:"Queries",children:"Queries"})]}),l(s.Tabs.Panel,{value:"SQL Snippet",pt:"sm",children:l(us,{})}),l(s.Tabs.Panel,{value:"Queries",pt:"sm",children:l(is,{})})]})})}function ss({opened:e,close:r,getCurrentSchema:t}){const{freezeLayout:n}=h.default.useContext(be);h.default.useEffect(()=>{n(e)},[e]);const i=h.default.useMemo(()=>JSON.stringify(t(),null,2),[e]);return l(s.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:"This dashboard is described by this schema",trapFocus:!0,onDragStart:a=>{a.stopPropagation()},children:l($e.Prism,{language:"json",sx:{width:"100%"},colorScheme:"dark",children:i})})}function A(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];throw new Error(typeof e=="number"?"[MobX] minified error nr: "+e+(t.length?" "+t.map(String).join(","):"")+". Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts":"[MobX] "+e)}var cs={};function Jr(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:cs}var fs=Object.assign,ar=Object.getOwnPropertyDescriptor,xe=Object.defineProperty,or=Object.prototype,Xr=[];Object.freeze(Xr);var Zr={};Object.freeze(Zr);var ds=typeof Proxy!="undefined",ps=Object.toString();function bi(){ds||A("Proxy not available")}function vi(e){var r=!1;return function(){if(!r)return r=!0,e.apply(this,arguments)}}var nt=function(){};function K(e){return typeof e=="function"}function Ke(e){var r=typeof e;switch(r){case"string":case"symbol":case"number":return!0}return!1}function ur(e){return e!==null&&typeof e=="object"}function Re(e){if(!ur(e))return!1;var r=Object.getPrototypeOf(e);if(r==null)return!0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return typeof t=="function"&&t.toString()===ps}function mi(e){var r=e==null?void 0:e.constructor;return r?r.name==="GeneratorFunction"||r.displayName==="GeneratorFunction":!1}function lr(e,r,t){xe(e,r,{enumerable:!1,writable:!0,configurable:!0,value:t})}function yi(e,r,t){xe(e,r,{enumerable:!1,writable:!1,configurable:!0,value:t})}function Ve(e,r){var t="isMobX"+e;return r.prototype[t]=!0,function(n){return ur(n)&&n[t]===!0}}function it(e){return e instanceof Map}function Ct(e){return e instanceof Set}var gi=typeof Object.getOwnPropertySymbols!="undefined";function hs(e){var r=Object.keys(e);if(!gi)return r;var t=Object.getOwnPropertySymbols(e);return t.length?[].concat(r,t.filter(function(n){return or.propertyIsEnumerable.call(e,n)})):r}var sr=typeof Reflect!="undefined"&&Reflect.ownKeys?Reflect.ownKeys:gi?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function _i(e){return e===null?null:typeof e=="object"?""+e:e}function Pe(e,r){return or.hasOwnProperty.call(e,r)}var bs=Object.getOwnPropertyDescriptors||function(r){var t={};return sr(r).forEach(function(n){t[n]=ar(r,n)}),t};function wi(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function en(e,r,t){return r&&wi(e.prototype,r),t&&wi(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function at(){return at=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},at.apply(this,arguments)}function Si(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,tn(e,r)}function tn(e,r){return tn=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},tn(e,r)}function Oi(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function vs(e,r){if(!!e){if(typeof e=="string")return xi(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return xi(e,r)}}function xi(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function ot(e,r){var t=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=vs(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
24
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var ve=Symbol("mobx-stored-annotations");function me(e){function r(t,n){At(t,n,e)}return Object.assign(r,e)}function At(e,r,t){Pe(e,ve)||lr(e,ve,at({},e[ve])),Ps(t)||(e[ve][r]=t)}function ms(e){return Pe(e,ve)||lr(e,ve,at({},e[ve])),e[ve]}var S=Symbol("mobx administration"),jt=function(){function e(t){t===void 0&&(t="Atom"),this.name_=void 0,this.isPendingUnobservation_=!1,this.isBeingObserved_=!1,this.observers_=new Set,this.diffValue_=0,this.lastAccessedBy_=0,this.lowestObserverState_=T.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=t}var r=e.prototype;return r.onBO=function(){this.onBOL&&this.onBOL.forEach(function(n){return n()})},r.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(n){return n()})},r.reportObserved=function(){return Qi(this)},r.reportChanged=function(){B(),Ki(this),G()},r.toString=function(){return this.name_},e}(),rn=Ve("Atom",jt);function cr(e,r,t){r===void 0&&(r=nt),t===void 0&&(t=nt);var n=new jt(e);return r!==nt&&Pc(n,r),t!==nt&&aa(n,t),n}function ys(e,r){return e===r}function gs(e,r){return mn(e,r)}function _s(e,r){return mn(e,r,1)}function ws(e,r){return Object.is?Object.is(e,r):e===r?e!==0||1/e===1/r:e!==e&&r!==r}var ut={identity:ys,structural:gs,default:ws,shallow:_s};function lt(e,r,t){return da(e)?e:Array.isArray(e)?R.array(e,{name:t}):Re(e)?R.object(e,void 0,{name:t}):it(e)?R.map(e,{name:t}):Ct(e)?R.set(e,{name:t}):typeof e=="function"&&!sn(e)&&!Or(e)?mi(e)?kt(e):Vt(t,e):e}function Ss(e,r,t){if(e==null||ie(e)||ge(e)||ne(e)||pe(e))return e;if(Array.isArray(e))return R.array(e,{name:t,deep:!1});if(Re(e))return R.object(e,void 0,{name:t,deep:!1});if(it(e))return R.map(e,{name:t,deep:!1});if(Ct(e))return R.set(e,{name:t,deep:!1})}function fr(e){return e}function Os(e,r){return mn(e,r)?r:e}var xs="override";function Ps(e){return e.annotationType_===xs}function Tt(e,r){return{annotationType_:e,options_:r,make_:Cs,extend_:As}}function Cs(e,r,t,n){var i;if((i=this.options_)!=null&&i.bound)return this.extend_(e,r,t,!1)===null?0:1;if(n===e.target_)return this.extend_(e,r,t,!1)===null?0:2;if(sn(t.value))return 1;var a=Pi(e,this,r,t,!1);return xe(n,r,a),2}function As(e,r,t,n){var i=Pi(e,this,r,t);return e.defineProperty_(r,i,n)}function js(e,r,t,n){r.annotationType_,n.value}function Pi(e,r,t,n,i){var a,o,u,c,d,f,p;i===void 0&&(i=m.safeDescriptors),js(e,r,t,n);var v=n.value;if((a=r.options_)!=null&&a.bound){var y;v=v.bind((y=e.proxy_)!=null?y:e.target_)}return{value:ct((o=(u=r.options_)==null?void 0:u.name)!=null?o:t.toString(),v,(c=(d=r.options_)==null?void 0:d.autoAction)!=null?c:!1,(f=r.options_)!=null&&f.bound?(p=e.proxy_)!=null?p:e.target_:void 0),configurable:i?e.isPlainObject_:!0,enumerable:!1,writable:!i}}function Ci(e,r){return{annotationType_:e,options_:r,make_:Ts,extend_:Es}}function Ts(e,r,t,n){var i;if(n===e.target_)return this.extend_(e,r,t,!1)===null?0:2;if((i=this.options_)!=null&&i.bound&&(!Pe(e.target_,r)||!Or(e.target_[r]))&&this.extend_(e,r,t,!1)===null)return 0;if(Or(t.value))return 1;var a=Ai(e,this,r,t,!1,!1);return xe(n,r,a),2}function Es(e,r,t,n){var i,a=Ai(e,this,r,t,(i=this.options_)==null?void 0:i.bound);return e.defineProperty_(r,a,n)}function Is(e,r,t,n){r.annotationType_,n.value}function Ai(e,r,t,n,i,a){a===void 0&&(a=m.safeDescriptors),Is(e,r,t,n);var o=n.value;if(Or(o)||(o=kt(o)),i){var u;o=o.bind((u=e.proxy_)!=null?u:e.target_),o.isMobXFlow=!0}return{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function nn(e,r){return{annotationType_:e,options_:r,make_:Ds,extend_:Ms}}function Ds(e,r,t){return this.extend_(e,r,t,!1)===null?0:1}function Ms(e,r,t,n){return Rs(e,this,r,t),e.defineComputedProperty_(r,at({},this.options_,{get:t.get,set:t.set}),n)}function Rs(e,r,t,n){r.annotationType_,n.get}function dr(e,r){return{annotationType_:e,options_:r,make_:Vs,extend_:ks}}function Vs(e,r,t){return this.extend_(e,r,t,!1)===null?0:1}function ks(e,r,t,n){var i,a;return zs(e,this),e.defineObservableProperty_(r,t.value,(i=(a=this.options_)==null?void 0:a.enhancer)!=null?i:lt,n)}function zs(e,r,t,n){r.annotationType_}var Ns="true",Ls=ji();function ji(e){return{annotationType_:Ns,options_:e,make_:Fs,extend_:qs}}function Fs(e,r,t,n){var i,a;if(t.get)return st.make_(e,r,t,n);if(t.set){var o=ct(r.toString(),t.set);return n===e.target_?e.defineProperty_(r,{configurable:m.safeDescriptors?e.isPlainObject_:!0,set:o})===null?0:2:(xe(n,r,{configurable:!0,set:o}),2)}if(n!==e.target_&&typeof t.value=="function"){var u;if(mi(t.value)){var c,d=(c=this.options_)!=null&&c.autoBind?kt.bound:kt;return d.make_(e,r,t,n)}var f=(u=this.options_)!=null&&u.autoBind?Vt.bound:Vt;return f.make_(e,r,t,n)}var p=((i=this.options_)==null?void 0:i.deep)===!1?R.ref:R;if(typeof t.value=="function"&&(a=this.options_)!=null&&a.autoBind){var v;t.value=t.value.bind((v=e.proxy_)!=null?v:e.target_)}return p.make_(e,r,t,n)}function qs(e,r,t,n){var i,a;if(t.get)return st.extend_(e,r,t,n);if(t.set)return e.defineProperty_(r,{configurable:m.safeDescriptors?e.isPlainObject_:!0,set:ct(r.toString(),t.set)},n);if(typeof t.value=="function"&&(i=this.options_)!=null&&i.autoBind){var o;t.value=t.value.bind((o=e.proxy_)!=null?o:e.target_)}var u=((a=this.options_)==null?void 0:a.deep)===!1?R.ref:R;return u.extend_(e,r,t,n)}var Bs="observable",Gs="observable.ref",$s="observable.shallow",Us="observable.struct",Ti={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(Ti);function pr(e){return e||Ti}var Ei=dr(Bs),Ws=dr(Gs,{enhancer:fr}),Ys=dr($s,{enhancer:Ss}),Qs=dr(Us,{enhancer:Os}),Ii=me(Ei);function hr(e){return e.deep===!0?lt:e.deep===!1?fr:Hs(e.defaultDecorator)}function Ks(e){var r;return e?(r=e.defaultDecorator)!=null?r:ji(e):void 0}function Hs(e){var r,t;return e&&(r=(t=e.options_)==null?void 0:t.enhancer)!=null?r:lt}function Di(e,r,t){if(Ke(r)){At(e,r,Ei);return}return da(e)?e:Re(e)?R.object(e,r,t):Array.isArray(e)?R.array(e,r):it(e)?R.map(e,r):Ct(e)?R.set(e,r):typeof e=="object"&&e!==null?e:R.box(e,r)}Object.assign(Di,Ii);var Js={box:function(r,t){var n=pr(t);return new He(r,hr(n),n.name,!0,n.equals)},array:function(r,t){var n=pr(t);return(m.useProxies===!1||n.proxy===!1?tf:Wc)(r,hr(n),n.name)},map:function(r,t){var n=pr(t);return new pn(r,hr(n),n.name)},set:function(r,t){var n=pr(t);return new Oa(r,hr(n),n.name)},object:function(r,t,n){return Tc(m.useProxies===!1||(n==null?void 0:n.proxy)===!1?Ar({},n):Gc({},n),r,t)},ref:me(Ws),shallow:me(Ys),deep:Ii,struct:me(Qs)},R=fs(Di,Js),Mi="computed",Xs="computed.struct",Ri=nn(Mi),Zs=nn(Xs,{equals:ut.structural}),st=function(r,t){if(Ke(t))return At(r,t,Ri);if(Re(r))return me(nn(Mi,r));var n=Re(t)?t:{};return n.get=r,n.name||(n.name=r.name||""),new Dt(n)};Object.assign(st,Ri),st.struct=me(Zs);var Vi,ki,br=0,ec=1,tc=(Vi=(ki=ar(function(){},"name"))==null?void 0:ki.configurable)!=null?Vi:!1,zi={value:"action",configurable:!0,writable:!1,enumerable:!1};function ct(e,r,t,n){t===void 0&&(t=!1);function i(){return Ni(e,t,r,n||this,arguments)}return i.isMobxAction=!0,tc&&(zi.value=e,Object.defineProperty(i,"name",zi)),i}function Ni(e,r,t,n,i){var a=rc(e,r);try{return t.apply(n,i)}catch(o){throw a.error_=o,o}finally{nc(a)}}function rc(e,r,t,n){var i=!1,a=0,o=m.trackingDerivation,u=!r||!o;B();var c=m.allowStateChanges;u&&(ft(),c=Et(!0));var d=un(!0),f={runAsAction_:u,prevDerivation_:o,prevAllowStateChanges_:c,prevAllowStateReads_:d,notifySpy_:i,startTime_:a,actionId_:ec++,parentActionId_:br};return br=f.actionId_,f}function nc(e){br!==e.actionId_&&A(30),br=e.parentActionId_,e.error_!==void 0&&(m.suppressReactionErrors=!0),It(e.prevAllowStateChanges_),Mt(e.prevAllowStateReads_),G(),e.runAsAction_&&ke(e.prevDerivation_),m.suppressReactionErrors=!1}function Li(e,r){var t=Et(e);try{return r()}finally{It(t)}}function Et(e){var r=m.allowStateChanges;return m.allowStateChanges=e,r}function It(e){m.allowStateChanges=e}var Fi;Fi=Symbol.toPrimitive;var He=function(e){Si(r,e);function r(n,i,a,o,u){var c;return a===void 0&&(a="ObservableValue"),u===void 0&&(u=ut.default),c=e.call(this,a)||this,c.enhancer=void 0,c.name_=void 0,c.equals=void 0,c.hasUnreportedChange_=!1,c.interceptors_=void 0,c.changeListeners_=void 0,c.value_=void 0,c.dehancer=void 0,c.enhancer=i,c.name_=a,c.equals=u,c.value_=i(n,void 0,a),c}var t=r.prototype;return t.dehanceValue=function(i){return this.dehancer!==void 0?this.dehancer(i):i},t.set=function(i){this.value_,i=this.prepareNewValue_(i),i!==m.UNCHANGED&&this.setNewValue_(i)},t.prepareNewValue_=function(i){if(te(this)){var a=re(this,{object:this,type:ye,newValue:i});if(!a)return m.UNCHANGED;i=a.newValue}return i=this.enhancer(i,this.value_,this.name_),this.equals(this.value_,i)?m.UNCHANGED:i},t.setNewValue_=function(i){var a=this.value_;this.value_=i,this.reportChanged(),fe(this)&&de(this,{type:ye,object:this,newValue:i,oldValue:a})},t.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},t.intercept_=function(i){return zt(this,i)},t.observe_=function(i,a){return a&&i({observableKind:"value",debugObjectName:this.name_,object:this,type:ye,newValue:this.value_,oldValue:void 0}),Nt(this,i)},t.raw=function(){return this.value_},t.toJSON=function(){return this.get()},t.toString=function(){return this.name_+"["+this.value_+"]"},t.valueOf=function(){return _i(this.get())},t[Fi]=function(){return this.valueOf()},r}(jt),ic=Ve("ObservableValue",He),qi;qi=Symbol.toPrimitive;var Dt=function(){function e(t){this.dependenciesState_=T.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.isBeingObserved_=!1,this.isPendingUnobservation_=!1,this.observers_=new Set,this.diffValue_=0,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=T.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new mr(null),this.name_=void 0,this.triggeredBy_=void 0,this.isComputing_=!1,this.isRunningSetter_=!1,this.derivation=void 0,this.setter_=void 0,this.isTracing_=Je.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,t.get||A(31),this.derivation=t.get,this.name_=t.name||"ComputedValue",t.set&&(this.setter_=ct("ComputedValue-setter",t.set)),this.equals_=t.equals||(t.compareStructural||t.struct?ut.structural:ut.default),this.scope_=t.context,this.requiresReaction_=t.requiresReaction,this.keepAlive_=!!t.keepAlive}var r=e.prototype;return r.onBecomeStale_=function(){cc(this)},r.onBO=function(){this.onBOL&&this.onBOL.forEach(function(n){return n()})},r.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(n){return n()})},r.get=function(){if(this.isComputing_&&A(32,this.name_,this.derivation),m.inBatch===0&&this.observers_.size===0&&!this.keepAlive_)an(this)&&(this.warnAboutUntrackedRead_(),B(),this.value_=this.computeValue_(!1),G());else if(Qi(this),an(this)){var n=m.trackingContext;this.keepAlive_&&!n&&(m.trackingContext=this),this.trackAndCompute()&&sc(this),m.trackingContext=n}var i=this.value_;if(yr(i))throw i.cause;return i},r.set=function(n){if(this.setter_){this.isRunningSetter_&&A(33,this.name_),this.isRunningSetter_=!0;try{this.setter_.call(this.scope_,n)}finally{this.isRunningSetter_=!1}}else A(34,this.name_)},r.trackAndCompute=function(){var n=this.value_,i=this.dependenciesState_===T.NOT_TRACKING_,a=this.computeValue_(!0),o=i||yr(n)||yr(a)||!this.equals_(n,a);return o&&(this.value_=a),o},r.computeValue_=function(n){this.isComputing_=!0;var i=Et(!1),a;if(n)a=Bi(this,this.derivation,this.scope_);else if(m.disableErrorBoundaries===!0)a=this.derivation.call(this.scope_);else try{a=this.derivation.call(this.scope_)}catch(o){a=new mr(o)}return It(i),this.isComputing_=!1,a},r.suspend_=function(){this.keepAlive_||(on(this),this.value_=void 0)},r.observe_=function(n,i){var a=this,o=!0,u=void 0;return gc(function(){var c=a.get();if(!o||i){var d=ft();n({observableKind:"computed",debugObjectName:a.name_,type:ye,object:a,newValue:c,oldValue:u}),ke(d)}o=!1,u=c})},r.warnAboutUntrackedRead_=function(){},r.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},r.valueOf=function(){return _i(this.get())},r[qi]=function(){return this.valueOf()},e}(),vr=Ve("ComputedValue",Dt),T;(function(e){e[e.NOT_TRACKING_=-1]="NOT_TRACKING_",e[e.UP_TO_DATE_=0]="UP_TO_DATE_",e[e.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",e[e.STALE_=2]="STALE_"})(T||(T={}));var Je;(function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"})(Je||(Je={}));var mr=function(r){this.cause=void 0,this.cause=r};function yr(e){return e instanceof mr}function an(e){switch(e.dependenciesState_){case T.UP_TO_DATE_:return!1;case T.NOT_TRACKING_:case T.STALE_:return!0;case T.POSSIBLY_STALE_:{for(var r=un(!0),t=ft(),n=e.observing_,i=n.length,a=0;a<i;a++){var o=n[a];if(vr(o)){if(m.disableErrorBoundaries)o.get();else try{o.get()}catch{return ke(t),Mt(r),!0}if(e.dependenciesState_===T.STALE_)return ke(t),Mt(r),!0}}return $i(e),ke(t),Mt(r),!1}}}function Up(e){}function Bi(e,r,t){var n=un(!0);$i(e),e.newObserving_=new Array(e.observing_.length+100),e.unboundDepsCount_=0,e.runId_=++m.runId;var i=m.trackingDerivation;m.trackingDerivation=e,m.inBatch++;var a;if(m.disableErrorBoundaries===!0)a=r.call(t);else try{a=r.call(t)}catch(o){a=new mr(o)}return m.inBatch--,m.trackingDerivation=i,ac(e),Mt(n),a}function ac(e){for(var r=e.observing_,t=e.observing_=e.newObserving_,n=T.UP_TO_DATE_,i=0,a=e.unboundDepsCount_,o=0;o<a;o++){var u=t[o];u.diffValue_===0&&(u.diffValue_=1,i!==o&&(t[i]=u),i++),u.dependenciesState_>n&&(n=u.dependenciesState_)}for(t.length=i,e.newObserving_=null,a=r.length;a--;){var c=r[a];c.diffValue_===0&&Wi(c,e),c.diffValue_=0}for(;i--;){var d=t[i];d.diffValue_===1&&(d.diffValue_=0,lc(d,e))}n!==T.UP_TO_DATE_&&(e.dependenciesState_=n,e.onBecomeStale_())}function on(e){var r=e.observing_;e.observing_=[];for(var t=r.length;t--;)Wi(r[t],e);e.dependenciesState_=T.NOT_TRACKING_}function Gi(e){var r=ft();try{return e()}finally{ke(r)}}function ft(){var e=m.trackingDerivation;return m.trackingDerivation=null,e}function ke(e){m.trackingDerivation=e}function un(e){var r=m.allowStateReads;return m.allowStateReads=e,r}function Mt(e){m.allowStateReads=e}function $i(e){if(e.dependenciesState_!==T.UP_TO_DATE_){e.dependenciesState_=T.UP_TO_DATE_;for(var r=e.observing_,t=r.length;t--;)r[t].lowestObserverState_=T.UP_TO_DATE_}}var gr=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},_r=!0,Ui=!1,m=function(){var e=Jr();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(_r=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==new gr().version&&(_r=!1),_r?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new gr):(setTimeout(function(){Ui||A(35)},1),new gr)}();function oc(){if((m.pendingReactions.length||m.inBatch||m.isRunningReactions)&&A(36),Ui=!0,_r){var e=Jr();--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),m=new gr}}function uc(){return m}function lc(e,r){e.observers_.add(r),e.lowestObserverState_>r.dependenciesState_&&(e.lowestObserverState_=r.dependenciesState_)}function Wi(e,r){e.observers_.delete(r),e.observers_.size===0&&Yi(e)}function Yi(e){e.isPendingUnobservation_===!1&&(e.isPendingUnobservation_=!0,m.pendingUnobservations.push(e))}function B(){m.inBatch++}function G(){if(--m.inBatch===0){Hi();for(var e=m.pendingUnobservations,r=0;r<e.length;r++){var t=e[r];t.isPendingUnobservation_=!1,t.observers_.size===0&&(t.isBeingObserved_&&(t.isBeingObserved_=!1,t.onBUO()),t instanceof Dt&&t.suspend_())}m.pendingUnobservations=[]}}function Qi(e){var r=m.trackingDerivation;return r!==null?(r.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=r.runId_,r.newObserving_[r.unboundDepsCount_++]=e,!e.isBeingObserved_&&m.trackingContext&&(e.isBeingObserved_=!0,e.onBO())),!0):(e.observers_.size===0&&m.inBatch>0&&Yi(e),!1)}function Ki(e){e.lowestObserverState_!==T.STALE_&&(e.lowestObserverState_=T.STALE_,e.observers_.forEach(function(r){r.dependenciesState_===T.UP_TO_DATE_&&r.onBecomeStale_(),r.dependenciesState_=T.STALE_}))}function sc(e){e.lowestObserverState_!==T.STALE_&&(e.lowestObserverState_=T.STALE_,e.observers_.forEach(function(r){r.dependenciesState_===T.POSSIBLY_STALE_?r.dependenciesState_=T.STALE_:r.dependenciesState_===T.UP_TO_DATE_&&(e.lowestObserverState_=T.UP_TO_DATE_)}))}function cc(e){e.lowestObserverState_===T.UP_TO_DATE_&&(e.lowestObserverState_=T.POSSIBLY_STALE_,e.observers_.forEach(function(r){r.dependenciesState_===T.UP_TO_DATE_&&(r.dependenciesState_=T.POSSIBLY_STALE_,r.onBecomeStale_())}))}var dt=function(){function e(t,n,i,a){t===void 0&&(t="Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=T.NOT_TRACKING_,this.diffValue_=0,this.runId_=0,this.unboundDepsCount_=0,this.isDisposed_=!1,this.isScheduled_=!1,this.isTrackPending_=!1,this.isRunning_=!1,this.isTracing_=Je.NONE,this.name_=t,this.onInvalidate_=n,this.errorHandler_=i,this.requiresObservable_=a}var r=e.prototype;return r.onBecomeStale_=function(){this.schedule_()},r.schedule_=function(){this.isScheduled_||(this.isScheduled_=!0,m.pendingReactions.push(this),Hi())},r.isScheduled=function(){return this.isScheduled_},r.runReaction_=function(){if(!this.isDisposed_){B(),this.isScheduled_=!1;var n=m.trackingContext;if(m.trackingContext=this,an(this)){this.isTrackPending_=!0;try{this.onInvalidate_()}catch(i){this.reportExceptionInDerivation_(i)}}m.trackingContext=n,G()}},r.track=function(n){if(!this.isDisposed_){B(),this.isRunning_=!0;var i=m.trackingContext;m.trackingContext=this;var a=Bi(this,n,void 0);m.trackingContext=i,this.isRunning_=!1,this.isTrackPending_=!1,this.isDisposed_&&on(this),yr(a)&&this.reportExceptionInDerivation_(a.cause),G()}},r.reportExceptionInDerivation_=function(n){var i=this;if(this.errorHandler_){this.errorHandler_(n,this);return}if(m.disableErrorBoundaries)throw n;var a="[mobx] uncaught error in '"+this+"'";m.suppressReactionErrors||console.error(a,n),m.globalReactionErrorHandlers.forEach(function(o){return o(n,i)})},r.dispose=function(){this.isDisposed_||(this.isDisposed_=!0,this.isRunning_||(B(),on(this),G()))},r.getDisposer_=function(){var n=this.dispose.bind(this);return n[S]=this,n},r.toString=function(){return"Reaction["+this.name_+"]"},r.trace=function(n){n===void 0&&(n=!1),Fc(this,n)},e}(),fc=100,ln=function(r){return r()};function Hi(){m.inBatch>0||m.isRunningReactions||ln(dc)}function dc(){m.isRunningReactions=!0;for(var e=m.pendingReactions,r=0;e.length>0;){++r===fc&&(console.error("[mobx] cycle in reaction: "+e[0]),e.splice(0));for(var t=e.splice(0),n=0,i=t.length;n<i;n++)t[n].runReaction_()}m.isRunningReactions=!1}var wr=Ve("Reaction",dt);function pc(e){var r=ln;ln=function(n){return e(function(){return r(n)})}}function Rt(){return!1}function Wp(e){}function Yp(e){}function Qp(e){}function hc(e){return console.warn("[mobx.spy] Is a no-op in production builds"),function(){}}var Ji="action",bc="action.bound",Xi="autoAction",vc="autoAction.bound",Zi="<unnamed action>",ea=Tt(Ji),mc=Tt(bc,{bound:!0}),ta=Tt(Xi,{autoAction:!0}),yc=Tt(vc,{autoAction:!0,bound:!0});function ra(e){var r=function(n,i){if(K(n))return ct(n.name||Zi,n,e);if(K(i))return ct(n,i,e);if(Ke(i))return At(n,i,e?ta:ea);if(Ke(n))return me(Tt(e?Xi:Ji,{name:n,autoAction:e}))};return r}var L=ra(!1);Object.assign(L,ea);var Vt=ra(!0);Object.assign(Vt,ta),L.bound=me(mc),Vt.bound=me(yc);function na(e){return Ni(e.name||Zi,!1,e,this,void 0)}function sn(e){return K(e)&&e.isMobxAction===!0}function gc(e,r){var t,n;r===void 0&&(r=Zr);var i=(t=(n=r)==null?void 0:n.name)!=null?t:"Autorun",a=!r.scheduler&&!r.delay,o;if(a)o=new dt(i,function(){this.track(d)},r.onError,r.requiresObservable);else{var u=ia(r),c=!1;o=new dt(i,function(){c||(c=!0,u(function(){c=!1,o.isDisposed_||o.track(d)}))},r.onError,r.requiresObservable)}function d(){e(o)}return o.schedule_(),o.getDisposer_()}var _c=function(r){return r()};function ia(e){return e.scheduler?e.scheduler:e.delay?function(r){return setTimeout(r,e.delay)}:_c}function wc(e,r,t){var n;t===void 0&&(t=Zr);var i=(n=t.name)!=null?n:"Reaction",a=L(i,t.onError?Sc(t.onError,r):r),o=!t.scheduler&&!t.delay,u=ia(t),c=!0,d=!1,f,p,v=t.compareStructural?ut.structural:t.equals||ut.default,y=new dt(i,function(){c||o?P():d||(d=!0,u(P))},t.onError,t.requiresObservable);function P(){if(d=!1,!y.isDisposed_){var j=!1;y.track(function(){var I=Li(!1,function(){return e(y)});j=c||!v(f,I),p=f,f=I}),(c&&t.fireImmediately||!c&&j)&&a(f,p,y),c=!1}}return y.schedule_(),y.getDisposer_()}function Sc(e,r){return function(){try{return r.apply(this,arguments)}catch(t){e.call(this,t)}}}var Oc="onBO",xc="onBUO";function Pc(e,r,t){return oa(Oc,e,r,t)}function aa(e,r,t){return oa(xc,e,r,t)}function oa(e,r,t,n){var i=typeof n=="function"?je(r,t):je(r),a=K(n)?n:t,o=e+"L";return i[o]?i[o].add(a):i[o]=new Set([a]),function(){var u=i[o];u&&(u.delete(a),u.size===0&&delete i[o])}}var Cc="never",Sr="always",Ac="observed";function jc(e){e.isolateGlobalState===!0&&oc();var r=e.useProxies,t=e.enforceActions;if(r!==void 0&&(m.useProxies=r===Sr?!0:r===Cc?!1:typeof Proxy!="undefined"),r==="ifavailable"&&(m.verifyProxies=!0),t!==void 0){var n=t===Sr?Sr:t===Ac;m.enforceActions=n,m.allowStateChanges=!(n===!0||n===Sr)}["computedRequiresReaction","reactionRequiresObservable","observableRequiresReaction","disableErrorBoundaries","safeDescriptors"].forEach(function(i){i in e&&(m[i]=!!e[i])}),m.allowStateReads=!m.observableRequiresReaction,e.reactionScheduler&&pc(e.reactionScheduler)}function Tc(e,r,t,n){var i=bs(r),a=Ar(e,n)[S];B();try{sr(i).forEach(function(o){a.extend_(o,i[o],t&&o in t?t[o]:!0)})}finally{G()}return e}function Ec(e,r){return ua(je(e,r))}function ua(e){var r={name:e.name_};return e.observing_&&e.observing_.length>0&&(r.dependencies=Ic(e.observing_).map(ua)),r}function Ic(e){return Array.from(new Set(e))}var Dc=0;function la(){this.message="FLOW_CANCELLED"}la.prototype=Object.create(Error.prototype);var sa=Ci("flow"),Mc=Ci("flow.bound",{bound:!0}),kt=Object.assign(function(r,t){if(Ke(t))return At(r,t,sa);var n=r,i=n.name||"<unnamed flow>",a=function(){var u=this,c=arguments,d=++Dc,f=L(i+" - runid: "+d+" - init",n).apply(u,c),p,v=void 0,y=new Promise(function(P,j){var I=0;p=j;function $(k){v=void 0;var U;try{U=L(i+" - runid: "+d+" - yield "+I++,f.next).call(f,k)}catch(ee){return j(ee)}Z(U)}function he(k){v=void 0;var U;try{U=L(i+" - runid: "+d+" - yield "+I++,f.throw).call(f,k)}catch(ee){return j(ee)}Z(U)}function Z(k){if(K(k==null?void 0:k.then)){k.then(Z,j);return}return k.done?P(k.value):(v=Promise.resolve(k.value),v.then($,he))}$(void 0)});return y.cancel=L(i+" - runid: "+d+" - cancel",function(){try{v&&ca(v);var P=f.return(void 0),j=Promise.resolve(P.value);j.then(nt,nt),ca(j),p(new la)}catch(I){p(I)}}),y};return a.isMobXFlow=!0,a},sa);kt.bound=me(Mc);function ca(e){K(e.cancel)&&e.cancel()}function Or(e){return(e==null?void 0:e.isMobXFlow)===!0}function fa(e,r,t){var n;return ne(e)||ge(e)||ic(e)?n=_e(e):ie(e)&&(n=_e(e,r)),n.dehancer=typeof r=="function"?r:t,function(){n.dehancer=void 0}}function cn(e,r,t){return K(t)?Vc(e,r,t):Rc(e,r)}function Rc(e,r){return _e(e).intercept_(r)}function Vc(e,r,t){return _e(e,r).intercept_(t)}function kc(e,r){return e?r!==void 0?ie(e)?e[S].values_.has(r):!1:ie(e)||!!e[S]||rn(e)||wr(e)||vr(e):!1}function da(e){return kc(e)}function xr(e){if(ie(e))return e[S].keys_();if(ne(e)||pe(e))return Array.from(e.keys());if(ge(e))return e.map(function(r,t){return t});A(5)}function pa(e){if(ie(e))return xr(e).map(function(r){return e[r]});if(ne(e))return xr(e).map(function(r){return e.get(r)});if(pe(e))return Array.from(e.values());if(ge(e))return e.slice();A(6)}function zc(e){if(ie(e))return xr(e).map(function(r){return[r,e[r]]});if(ne(e))return xr(e).map(function(r){return[r,e.get(r)]});if(pe(e))return Array.from(e.entries());if(ge(e))return e.map(function(r,t){return[t,r]});A(7)}function ha(e,r,t){if(arguments.length===2&&!pe(e)){B();var n=r;try{for(var i in n)ha(e,i,n[i])}finally{G()}return}ie(e)?e[S].set_(r,t):ne(e)?e.set(r,t):pe(e)?e.add(r):ge(e)?(typeof r!="number"&&(r=parseInt(r,10)),r<0&&A("Invalid index: '"+r+"'"),B(),r>=e.length&&(e.length=r+1),e[r]=t,G()):A(8)}function ba(e,r,t){if(ie(e))return e[S].defineProperty_(r,t);A(39)}function fn(e,r,t,n){return K(t)?Lc(e,r,t,n):Nc(e,r,t)}function Nc(e,r,t){return _e(e).observe_(r,t)}function Lc(e,r,t,n){return _e(e,r).observe_(t,n)}function Fc(){A("trace() is not available in production builds");for(var e=!1,r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];typeof t[t.length-1]=="boolean"&&(e=t.pop());var i=qc(t);if(!i)return A("'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly");i.isTracing_===Je.NONE&&console.log("[mobx.trace] '"+i.name_+"' tracing enabled"),i.isTracing_=e?Je.BREAK:Je.LOG}function qc(e){switch(e.length){case 0:return m.trackingDerivation;case 1:return je(e[0]);case 2:return je(e[0],e[1])}}function Ce(e,r){r===void 0&&(r=void 0),B();try{return e.apply(r)}finally{G()}}function pt(e){return e[S]}var Bc={has:function(r,t){return pt(r).has_(t)},get:function(r,t){return pt(r).get_(t)},set:function(r,t,n){var i;return Ke(t)?(i=pt(r).set_(t,n,!0))!=null?i:!0:!1},deleteProperty:function(r,t){var n;return Ke(t)?(n=pt(r).delete_(t,!0))!=null?n:!0:!1},defineProperty:function(r,t,n){var i;return(i=pt(r).defineProperty_(t,n))!=null?i:!0},ownKeys:function(r){return pt(r).ownKeys_()},preventExtensions:function(r){A(13)}};function Gc(e,r){var t,n;return bi(),e=Ar(e,r),(n=(t=e[S]).proxy_)!=null?n:t.proxy_=new Proxy(e,Bc)}function te(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function zt(e,r){var t=e.interceptors_||(e.interceptors_=[]);return t.push(r),vi(function(){var n=t.indexOf(r);n!==-1&&t.splice(n,1)})}function re(e,r){var t=ft();try{for(var n=[].concat(e.interceptors_||[]),i=0,a=n.length;i<a&&(r=n[i](r),r&&!r.type&&A(14),!!r);i++);return r}finally{ke(t)}}function fe(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function Nt(e,r){var t=e.changeListeners_||(e.changeListeners_=[]);return t.push(r),vi(function(){var n=t.indexOf(r);n!==-1&&t.splice(n,1)})}function de(e,r){var t=ft(),n=e.changeListeners_;if(!!n){n=n.slice();for(var i=0,a=n.length;i<a;i++)n[i](r);ke(t)}}function va(e,r,t){var n=Ar(e,t)[S];B();try{var i;(i=r)!=null||(r=ms(e)),sr(r).forEach(function(a){return n.make_(a,r[a])})}finally{G()}return e}var ma="splice",ye="update",$c=1e4,Uc={get:function(r,t){var n=r[S];return t===S?n:t==="length"?n.getArrayLength_():typeof t=="string"&&!isNaN(t)?n.get_(parseInt(t)):Pe(Pr,t)?Pr[t]:r[t]},set:function(r,t,n){var i=r[S];return t==="length"&&i.setArrayLength_(n),typeof t=="symbol"||isNaN(t)?r[t]=n:i.set_(parseInt(t),n),!0},preventExtensions:function(){A(15)}},dn=function(){function e(t,n,i,a){t===void 0&&(t="ObservableArray"),this.owned_=void 0,this.legacyMode_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=i,this.legacyMode_=a,this.atom_=new jt(t),this.enhancer_=function(o,u){return n(o,u,"ObservableArray[..]")}}var r=e.prototype;return r.dehanceValue_=function(n){return this.dehancer!==void 0?this.dehancer(n):n},r.dehanceValues_=function(n){return this.dehancer!==void 0&&n.length>0?n.map(this.dehancer):n},r.intercept_=function(n){return zt(this,n)},r.observe_=function(n,i){return i===void 0&&(i=!1),i&&n({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),Nt(this,n)},r.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},r.setArrayLength_=function(n){(typeof n!="number"||isNaN(n)||n<0)&&A("Out of range: "+n);var i=this.values_.length;if(n!==i)if(n>i){for(var a=new Array(n-i),o=0;o<n-i;o++)a[o]=void 0;this.spliceWithArray_(i,0,a)}else this.spliceWithArray_(n,i-n)},r.updateArrayLength_=function(n,i){n!==this.lastKnownLength_&&A(16),this.lastKnownLength_+=i,this.legacyMode_&&i>0&&Ea(n+i+1)},r.spliceWithArray_=function(n,i,a){var o=this;this.atom_;var u=this.values_.length;if(n===void 0?n=0:n>u?n=u:n<0&&(n=Math.max(0,u+n)),arguments.length===1?i=u-n:i==null?i=0:i=Math.max(0,Math.min(i,u-n)),a===void 0&&(a=Xr),te(this)){var c=re(this,{object:this.proxy_,type:ma,index:n,removedCount:i,added:a});if(!c)return Xr;i=c.removedCount,a=c.added}if(a=a.length===0?a:a.map(function(p){return o.enhancer_(p,void 0)}),this.legacyMode_){var d=a.length-i;this.updateArrayLength_(u,d)}var f=this.spliceItemsIntoValues_(n,i,a);return(i!==0||a.length!==0)&&this.notifyArraySplice_(n,a,f),this.dehanceValues_(f)},r.spliceItemsIntoValues_=function(n,i,a){if(a.length<$c){var o;return(o=this.values_).splice.apply(o,[n,i].concat(a))}else{var u=this.values_.slice(n,n+i),c=this.values_.slice(n+i);this.values_.length+=a.length-i;for(var d=0;d<a.length;d++)this.values_[n+d]=a[d];for(var f=0;f<c.length;f++)this.values_[n+a.length+f]=c[f];return u}},r.notifyArrayChildUpdate_=function(n,i,a){var o=!this.owned_&&Rt(),u=fe(this),c=u||o?{observableKind:"array",object:this.proxy_,type:ye,debugObjectName:this.atom_.name_,index:n,newValue:i,oldValue:a}:null;this.atom_.reportChanged(),u&&de(this,c)},r.notifyArraySplice_=function(n,i,a){var o=!this.owned_&&Rt(),u=fe(this),c=u||o?{observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:ma,index:n,removed:a,added:i,removedCount:a.length,addedCount:i.length}:null;this.atom_.reportChanged(),u&&de(this,c)},r.get_=function(n){if(n<this.values_.length)return this.atom_.reportObserved(),this.dehanceValue_(this.values_[n]);console.warn("[mobx.array] Attempt to read an array index ("+n+") that is out of bounds ("+this.values_.length+"). Please check length first. Out of bound indices will not be tracked by MobX")},r.set_=function(n,i){var a=this.values_;if(n<a.length){this.atom_;var o=a[n];if(te(this)){var u=re(this,{type:ye,object:this.proxy_,index:n,newValue:i});if(!u)return;i=u.newValue}i=this.enhancer_(i,o);var c=i!==o;c&&(a[n]=i,this.notifyArrayChildUpdate_(n,i,o))}else n===a.length?this.spliceWithArray_(n,0,[i]):A(17,n,a.length)},e}();function Wc(e,r,t,n){t===void 0&&(t="ObservableArray"),n===void 0&&(n=!1),bi();var i=new dn(t,r,n,!1);yi(i.values_,S,i);var a=new Proxy(i.values_,Uc);if(i.proxy_=a,e&&e.length){var o=Et(!0);i.spliceWithArray_(0,0,e),It(o)}return a}var Pr={clear:function(){return this.splice(0)},replace:function(r){var t=this[S];return t.spliceWithArray_(0,t.values_.length,r)},toJSON:function(){return this.slice()},splice:function(r,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++)i[a-2]=arguments[a];var o=this[S];switch(arguments.length){case 0:return[];case 1:return o.spliceWithArray_(r);case 2:return o.spliceWithArray_(r,t)}return o.spliceWithArray_(r,t,i)},spliceWithArray:function(r,t,n){return this[S].spliceWithArray_(r,t,n)},push:function(){for(var r=this[S],t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return r.spliceWithArray_(r.values_.length,0,n),r.values_.length},pop:function(){return this.splice(Math.max(this[S].values_.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){for(var r=this[S],t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return r.spliceWithArray_(0,0,n),r.values_.length},reverse:function(){return m.trackingDerivation&&A(37,"reverse"),this.replace(this.slice().reverse()),this},sort:function(){m.trackingDerivation&&A(37,"sort");var r=this.slice();return r.sort.apply(r,arguments),this.replace(r),this},remove:function(r){var t=this[S],n=t.dehanceValues_(t.values_).indexOf(r);return n>-1?(this.splice(n,1),!0):!1}};N("concat",Ae),N("flat",Ae),N("includes",Ae),N("indexOf",Ae),N("join",Ae),N("lastIndexOf",Ae),N("slice",Ae),N("toString",Ae),N("toLocaleString",Ae),N("every",ze),N("filter",ze),N("find",ze),N("findIndex",ze),N("flatMap",ze),N("forEach",ze),N("map",ze),N("some",ze),N("reduce",ya),N("reduceRight",ya);function N(e,r){typeof Array.prototype[e]=="function"&&(Pr[e]=r(e))}function Ae(e){return function(){var r=this[S];r.atom_.reportObserved();var t=r.dehanceValues_(r.values_);return t[e].apply(t,arguments)}}function ze(e){return function(r,t){var n=this,i=this[S];i.atom_.reportObserved();var a=i.dehanceValues_(i.values_);return a[e](function(o,u){return r.call(t,o,u,n)})}}function ya(e){return function(){var r=this,t=this[S];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_),i=arguments[0];return arguments[0]=function(a,o,u){return i(a,o,u,r)},n[e].apply(n,arguments)}}var Yc=Ve("ObservableArrayAdministration",dn);function ge(e){return ur(e)&&Yc(e[S])}var ga,_a,Qc={},Ne="add",Cr="delete";ga=Symbol.iterator,_a=Symbol.toStringTag;var pn=function(){function e(t,n,i){var a=this;n===void 0&&(n=lt),i===void 0&&(i="ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[S]=Qc,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=n,this.name_=i,K(Map)||A(18),this.keysAtom_=cr("ObservableMap.keys()"),this.data_=new Map,this.hasMap_=new Map,Li(!0,function(){a.merge(t)})}var r=e.prototype;return r.has_=function(n){return this.data_.has(n)},r.has=function(n){var i=this;if(!m.trackingDerivation)return this.has_(n);var a=this.hasMap_.get(n);if(!a){var o=a=new He(this.has_(n),fr,"ObservableMap.key?",!1);this.hasMap_.set(n,o),aa(o,function(){return i.hasMap_.delete(n)})}return a.get()},r.set=function(n,i){var a=this.has_(n);if(te(this)){var o=re(this,{type:a?ye:Ne,object:this,newValue:i,name:n});if(!o)return this;i=o.newValue}return a?this.updateValue_(n,i):this.addValue_(n,i),this},r.delete=function(n){var i=this;if(this.keysAtom_,te(this)){var a=re(this,{type:Cr,object:this,name:n});if(!a)return!1}if(this.has_(n)){var o=Rt(),u=fe(this),c=u||o?{observableKind:"map",debugObjectName:this.name_,type:Cr,object:this,oldValue:this.data_.get(n).value_,name:n}:null;return Ce(function(){var d;i.keysAtom_.reportChanged(),(d=i.hasMap_.get(n))==null||d.setNewValue_(!1);var f=i.data_.get(n);f.setNewValue_(void 0),i.data_.delete(n)}),u&&de(this,c),!0}return!1},r.updateValue_=function(n,i){var a=this.data_.get(n);if(i=a.prepareNewValue_(i),i!==m.UNCHANGED){var o=Rt(),u=fe(this),c=u||o?{observableKind:"map",debugObjectName:this.name_,type:ye,object:this,oldValue:a.value_,name:n,newValue:i}:null;a.setNewValue_(i),u&&de(this,c)}},r.addValue_=function(n,i){var a=this;this.keysAtom_,Ce(function(){var d,f=new He(i,a.enhancer_,"ObservableMap.key",!1);a.data_.set(n,f),i=f.value_,(d=a.hasMap_.get(n))==null||d.setNewValue_(!0),a.keysAtom_.reportChanged()});var o=Rt(),u=fe(this),c=u||o?{observableKind:"map",debugObjectName:this.name_,type:Ne,object:this,name:n,newValue:i}:null;u&&de(this,c)},r.get=function(n){return this.has(n)?this.dehanceValue_(this.data_.get(n).get()):this.dehanceValue_(void 0)},r.dehanceValue_=function(n){return this.dehancer!==void 0?this.dehancer(n):n},r.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},r.values=function(){var n=this,i=this.keys();return Lt({next:function(){var o=i.next(),u=o.done,c=o.value;return{done:u,value:u?void 0:n.get(c)}}})},r.entries=function(){var n=this,i=this.keys();return Lt({next:function(){var o=i.next(),u=o.done,c=o.value;return{done:u,value:u?void 0:[c,n.get(c)]}}})},r[ga]=function(){return this.entries()},r.forEach=function(n,i){for(var a=ot(this),o;!(o=a()).done;){var u=o.value,c=u[0],d=u[1];n.call(i,d,c,this)}},r.merge=function(n){var i=this;return ne(n)&&(n=new Map(n)),Ce(function(){Re(n)?hs(n).forEach(function(a){return i.set(a,n[a])}):Array.isArray(n)?n.forEach(function(a){var o=a[0],u=a[1];return i.set(o,u)}):it(n)?(n.constructor!==Map&&A(19,n),n.forEach(function(a,o){return i.set(o,a)})):n!=null&&A(20,n)}),this},r.clear=function(){var n=this;Ce(function(){Gi(function(){for(var i=ot(n.keys()),a;!(a=i()).done;){var o=a.value;n.delete(o)}})})},r.replace=function(n){var i=this;return Ce(function(){for(var a=Kc(n),o=new Map,u=!1,c=ot(i.data_.keys()),d;!(d=c()).done;){var f=d.value;if(!a.has(f)){var p=i.delete(f);if(p)u=!0;else{var v=i.data_.get(f);o.set(f,v)}}}for(var y=ot(a.entries()),P;!(P=y()).done;){var j=P.value,I=j[0],$=j[1],he=i.data_.has(I);if(i.set(I,$),i.data_.has(I)){var Z=i.data_.get(I);o.set(I,Z),he||(u=!0)}}if(!u)if(i.data_.size!==o.size)i.keysAtom_.reportChanged();else for(var k=i.data_.keys(),U=o.keys(),ee=k.next(),_t=U.next();!ee.done;){if(ee.value!==_t.value){i.keysAtom_.reportChanged();break}ee=k.next(),_t=U.next()}i.data_=o}),this},r.toString=function(){return"[object ObservableMap]"},r.toJSON=function(){return Array.from(this)},r.observe_=function(n,i){return Nt(this,n)},r.intercept_=function(n){return zt(this,n)},en(e,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:_a,get:function(){return"Map"}}]),e}(),ne=Ve("ObservableMap",pn);function Kc(e){if(it(e)||ne(e))return e;if(Array.isArray(e))return new Map(e);if(Re(e)){var r=new Map;for(var t in e)r.set(t,e[t]);return r}else return A(21,e)}var wa,Sa,Hc={};wa=Symbol.iterator,Sa=Symbol.toStringTag;var Oa=function(){function e(t,n,i){n===void 0&&(n=lt),i===void 0&&(i="ObservableSet"),this.name_=void 0,this[S]=Hc,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=i,K(Set)||A(22),this.atom_=cr(this.name_),this.enhancer_=function(a,o){return n(a,o,i)},t&&this.replace(t)}var r=e.prototype;return r.dehanceValue_=function(n){return this.dehancer!==void 0?this.dehancer(n):n},r.clear=function(){var n=this;Ce(function(){Gi(function(){for(var i=ot(n.data_.values()),a;!(a=i()).done;){var o=a.value;n.delete(o)}})})},r.forEach=function(n,i){for(var a=ot(this),o;!(o=a()).done;){var u=o.value;n.call(i,u,u,this)}},r.add=function(n){var i=this;if(this.atom_,te(this)){var a=re(this,{type:Ne,object:this,newValue:n});if(!a)return this}if(!this.has(n)){Ce(function(){i.data_.add(i.enhancer_(n,void 0)),i.atom_.reportChanged()});var o=!1,u=fe(this),c=u||o?{observableKind:"set",debugObjectName:this.name_,type:Ne,object:this,newValue:n}:null;u&&de(this,c)}return this},r.delete=function(n){var i=this;if(te(this)){var a=re(this,{type:Cr,object:this,oldValue:n});if(!a)return!1}if(this.has(n)){var o=!1,u=fe(this),c=u||o?{observableKind:"set",debugObjectName:this.name_,type:Cr,object:this,oldValue:n}:null;return Ce(function(){i.atom_.reportChanged(),i.data_.delete(n)}),u&&de(this,c),!0}return!1},r.has=function(n){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(n))},r.entries=function(){var n=0,i=Array.from(this.keys()),a=Array.from(this.values());return Lt({next:function(){var u=n;return n+=1,u<a.length?{value:[i[u],a[u]],done:!1}:{done:!0}}})},r.keys=function(){return this.values()},r.values=function(){this.atom_.reportObserved();var n=this,i=0,a=Array.from(this.data_.values());return Lt({next:function(){return i<a.length?{value:n.dehanceValue_(a[i++]),done:!1}:{done:!0}}})},r.replace=function(n){var i=this;return pe(n)&&(n=new Set(n)),Ce(function(){Array.isArray(n)?(i.clear(),n.forEach(function(a){return i.add(a)})):Ct(n)?(i.clear(),n.forEach(function(a){return i.add(a)})):n!=null&&A("Cannot initialize set from "+n)}),this},r.observe_=function(n,i){return Nt(this,n)},r.intercept_=function(n){return zt(this,n)},r.toJSON=function(){return Array.from(this)},r.toString=function(){return"[object ObservableSet]"},r[wa]=function(){return this.values()},en(e,[{key:"size",get:function(){return this.atom_.reportObserved(),this.data_.size}},{key:Sa,get:function(){return"Set"}}]),e}(),pe=Ve("ObservableSet",Oa),xa=Object.create(null),Pa="remove",Ca=function(){function e(t,n,i,a){n===void 0&&(n=new Map),a===void 0&&(a=Ls),this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.target_=t,this.values_=n,this.name_=i,this.defaultAnnotation_=a,this.keysAtom_=new jt("ObservableObject.keys"),this.isPlainObject_=Re(this.target_)}var r=e.prototype;return r.getObservablePropValue_=function(n){return this.values_.get(n).get()},r.setObservablePropValue_=function(n,i){var a=this.values_.get(n);if(a instanceof Dt)return a.set(i),!0;if(te(this)){var o=re(this,{type:ye,object:this.proxy_||this.target_,name:n,newValue:i});if(!o)return null;i=o.newValue}if(i=a.prepareNewValue_(i),i!==m.UNCHANGED){var u=fe(this),c=!1,d=u||c?{type:ye,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:a.value_,name:n,newValue:i}:null;a.setNewValue_(i),u&&de(this,d)}return!0},r.get_=function(n){return m.trackingDerivation&&!Pe(this.target_,n)&&this.has_(n),this.target_[n]},r.set_=function(n,i,a){return a===void 0&&(a=!1),Pe(this.target_,n)?this.values_.has(n)?this.setObservablePropValue_(n,i):a?Reflect.set(this.target_,n,i):(this.target_[n]=i,!0):this.extend_(n,{value:i,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,a)},r.has_=function(n){if(!m.trackingDerivation)return n in this.target_;this.pendingKeys_||(this.pendingKeys_=new Map);var i=this.pendingKeys_.get(n);return i||(i=new He(n in this.target_,fr,"ObservableObject.key?",!1),this.pendingKeys_.set(n,i)),i.get()},r.make_=function(n,i){if(i===!0&&(i=this.defaultAnnotation_),i!==!1){if(!(n in this.target_)){var a;if((a=this.target_[ve])!=null&&a[n])return;A(1,i.annotationType_,this.name_+"."+n.toString())}for(var o=this.target_;o&&o!==or;){var u=ar(o,n);if(u){var c=i.make_(this,n,u,o);if(c===0)return;if(c===1)break}o=Object.getPrototypeOf(o)}ja(this,i,n)}},r.extend_=function(n,i,a,o){if(o===void 0&&(o=!1),a===!0&&(a=this.defaultAnnotation_),a===!1)return this.defineProperty_(n,i,o);var u=a.extend_(this,n,i,o);return u&&ja(this,a,n),u},r.defineProperty_=function(n,i,a){a===void 0&&(a=!1);try{B();var o=this.delete_(n);if(!o)return o;if(te(this)){var u=re(this,{object:this.proxy_||this.target_,name:n,type:Ne,newValue:i.value});if(!u)return null;var c=u.newValue;i.value!==c&&(i=at({},i,{value:c}))}if(a){if(!Reflect.defineProperty(this.target_,n,i))return!1}else xe(this.target_,n,i);this.notifyPropertyAddition_(n,i.value)}finally{G()}return!0},r.defineObservableProperty_=function(n,i,a,o){o===void 0&&(o=!1);try{B();var u=this.delete_(n);if(!u)return u;if(te(this)){var c=re(this,{object:this.proxy_||this.target_,name:n,type:Ne,newValue:i});if(!c)return null;i=c.newValue}var d=Aa(n),f={configurable:m.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:d.get,set:d.set};if(o){if(!Reflect.defineProperty(this.target_,n,f))return!1}else xe(this.target_,n,f);var p=new He(i,a,"ObservableObject.key",!1);this.values_.set(n,p),this.notifyPropertyAddition_(n,p.value_)}finally{G()}return!0},r.defineComputedProperty_=function(n,i,a){a===void 0&&(a=!1);try{B();var o=this.delete_(n);if(!o)return o;if(te(this)){var u=re(this,{object:this.proxy_||this.target_,name:n,type:Ne,newValue:void 0});if(!u)return null}i.name||(i.name="ObservableObject.key"),i.context=this.proxy_||this.target_;var c=Aa(n),d={configurable:m.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:c.get,set:c.set};if(a){if(!Reflect.defineProperty(this.target_,n,d))return!1}else xe(this.target_,n,d);this.values_.set(n,new Dt(i)),this.notifyPropertyAddition_(n,void 0)}finally{G()}return!0},r.delete_=function(n,i){if(i===void 0&&(i=!1),!Pe(this.target_,n))return!0;if(te(this)){var a=re(this,{object:this.proxy_||this.target_,name:n,type:Pa});if(!a)return null}try{var o,u;B();var c=fe(this),d=!1,f=this.values_.get(n),p=void 0;if(!f&&(c||d)){var v;p=(v=ar(this.target_,n))==null?void 0:v.value}if(i){if(!Reflect.deleteProperty(this.target_,n))return!1}else delete this.target_[n];if(f&&(this.values_.delete(n),f instanceof He&&(p=f.value_),Ki(f)),this.keysAtom_.reportChanged(),(o=this.pendingKeys_)==null||(u=o.get(n))==null||u.set(n in this.target_),c||d){var y={type:Pa,observableKind:"object",object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:p,name:n};c&&de(this,y)}}finally{G()}return!0},r.observe_=function(n,i){return Nt(this,n)},r.intercept_=function(n){return zt(this,n)},r.notifyPropertyAddition_=function(n,i){var a,o,u=fe(this),c=!1;if(u||c){var d=u||c?{type:Ne,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,name:n,newValue:i}:null;u&&de(this,d)}(a=this.pendingKeys_)==null||(o=a.get(n))==null||o.set(!0),this.keysAtom_.reportChanged()},r.ownKeys_=function(){return this.keysAtom_.reportObserved(),sr(this.target_)},r.keys_=function(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)},e}();function Ar(e,r){var t;if(Pe(e,S))return e;var n=(t=r==null?void 0:r.name)!=null?t:"ObservableObject",i=new Ca(e,new Map,String(n),Ks(r));return lr(e,S,i),e}var Jc=Ve("ObservableObjectAdministration",Ca);function Aa(e){return xa[e]||(xa[e]={get:function(){return this[S].getObservablePropValue_(e)},set:function(t){return this[S].setObservablePropValue_(e,t)}})}function ie(e){return ur(e)?Jc(e[S]):!1}function ja(e,r,t){var n;(n=e.target_[ve])==null||delete n[t]}var hn=0,Ta=function(){};function Xc(e,r){Object.setPrototypeOf?Object.setPrototypeOf(e.prototype,r):e.prototype.__proto__!==void 0?e.prototype.__proto__=r:e.prototype=r}Xc(Ta,Array.prototype);var bn=function(e,r,t){Si(n,e);function n(a,o,u,c){var d;u===void 0&&(u="ObservableArray"),c===void 0&&(c=!1),d=e.call(this)||this;var f=new dn(u,o,c,!0);if(f.proxy_=Oi(d),yi(Oi(d),S,f),a&&a.length){var p=Et(!0);d.spliceWithArray(0,0,a),It(p)}return d}var i=n.prototype;return i.concat=function(){this[S].atom_.reportObserved();for(var o=arguments.length,u=new Array(o),c=0;c<o;c++)u[c]=arguments[c];return Array.prototype.concat.apply(this.slice(),u.map(function(d){return ge(d)?d.slice():d}))},i[t]=function(){var a=this,o=0;return Lt({next:function(){return o<a.length?{value:a[o++],done:!1}:{done:!0,value:void 0}}})},en(n,[{key:"length",get:function(){return this[S].getArrayLength_()},set:function(o){this[S].setArrayLength_(o)}},{key:r,get:function(){return"Array"}}]),n}(Ta,Symbol.toStringTag,Symbol.iterator);Object.entries(Pr).forEach(function(e){var r=e[0],t=e[1];r!=="concat"&&lr(bn.prototype,r,t)});function Zc(e){return{enumerable:!1,configurable:!0,get:function(){return this[S].get_(e)},set:function(t){this[S].set_(e,t)}}}function ef(e){xe(bn.prototype,""+e,Zc(e))}function Ea(e){if(e>hn){for(var r=hn;r<e+100;r++)ef(r);hn=e}}Ea(1e3);function tf(e,r,t){return new bn(e,r,t)}function je(e,r){if(typeof e=="object"&&e!==null){if(ge(e))return r!==void 0&&A(23),e[S].atom_;if(pe(e))return e[S];if(ne(e)){if(r===void 0)return e.keysAtom_;var t=e.data_.get(r)||e.hasMap_.get(r);return t||A(25,r,vn(e)),t}if(ie(e)){if(!r)return A(26);var n=e[S].values_.get(r);return n||A(27,r,vn(e)),n}if(rn(e)||vr(e)||wr(e))return e}else if(K(e)&&wr(e[S]))return e[S];A(28)}function _e(e,r){if(e||A(29),r!==void 0)return _e(je(e,r));if(rn(e)||vr(e)||wr(e)||ne(e)||pe(e))return e;if(e[S])return e[S];A(24,e)}function vn(e,r){var t;if(r!==void 0)t=je(e,r);else{if(sn(e))return e.name;ie(e)||ne(e)||pe(e)?t=_e(e):t=je(e)}return t.name_}var Ia=or.toString;function mn(e,r,t){return t===void 0&&(t=-1),yn(e,r,t)}function yn(e,r,t,n,i){if(e===r)return e!==0||1/e===1/r;if(e==null||r==null)return!1;if(e!==e)return r!==r;var a=typeof e;if(a!=="function"&&a!=="object"&&typeof r!="object")return!1;var o=Ia.call(e);if(o!==Ia.call(r))return!1;switch(o){case"[object RegExp]":case"[object String]":return""+e==""+r;case"[object Number]":return+e!=+e?+r!=+r:+e==0?1/+e===1/r:+e==+r;case"[object Date]":case"[object Boolean]":return+e==+r;case"[object Symbol]":return typeof Symbol!="undefined"&&Symbol.valueOf.call(e)===Symbol.valueOf.call(r);case"[object Map]":case"[object Set]":t>=0&&t++;break}e=Da(e),r=Da(r);var u=o==="[object Array]";if(!u){if(typeof e!="object"||typeof r!="object")return!1;var c=e.constructor,d=r.constructor;if(c!==d&&!(K(c)&&c instanceof c&&K(d)&&d instanceof d)&&"constructor"in e&&"constructor"in r)return!1}if(t===0)return!1;t<0&&(t=-1),n=n||[],i=i||[];for(var f=n.length;f--;)if(n[f]===e)return i[f]===r;if(n.push(e),i.push(r),u){if(f=e.length,f!==r.length)return!1;for(;f--;)if(!yn(e[f],r[f],t-1,n,i))return!1}else{var p=Object.keys(e),v;if(f=p.length,Object.keys(r).length!==f)return!1;for(;f--;)if(v=p[f],!(Pe(r,v)&&yn(e[v],r[v],t-1,n,i)))return!1}return n.pop(),i.pop(),!0}function Da(e){return ge(e)?e.slice():it(e)||ne(e)||Ct(e)||pe(e)?Array.from(e.entries()):e}function Lt(e){return e[Symbol.iterator]=rf,e}function rf(){return this}if(["Symbol","Map","Set"].forEach(function(e){var r=Jr();typeof r[e]=="undefined"&&A("MobX requires global '"+e+"' to be available or polyfilled")}),typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__=="object"&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:hc,extras:{getDebugName:vn},$mobx:S}),!z.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!va)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function nf(e){e()}function af(e){e||(e=nf),jc({reactionScheduler:e})}function of(e){return Ec(e)}var Ma=typeof FinalizationRegistry=="undefined"?void 0:FinalizationRegistry;function Ra(e){var r={reaction:e,mounted:!1,changedBeforeMount:!1,cleanAt:Date.now()+uf};return r}var uf=1e4,lf=1e4;function sf(e){var r=new Map,t=1,n=new e(function(a){var o=r.get(a);o&&(o.reaction.dispose(),r.delete(a))});return{addReactionToTrack:function(i,a,o){var u=t++;return n.register(o,u,i),i.current=Ra(a),i.current.finalizationRegistryCleanupToken=u,r.set(u,i.current),i.current},recordReactionAsCommitted:function(i){n.unregister(i),i.current&&i.current.finalizationRegistryCleanupToken&&r.delete(i.current.finalizationRegistryCleanupToken)},forceCleanupTimerToRunNowForTests:function(){},resetCleanupScheduleForTests:function(){}}}var cf=globalThis&&globalThis.__values||function(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};function ff(){var e=new Set,r;function t(){r&&(clearTimeout(r),u())}function n(){var c,d;if(e.size>0){try{for(var f=cf(e),p=f.next();!p.done;p=f.next()){var v=p.value,y=v.current;y&&(y.reaction.dispose(),v.current=null)}}catch(P){c={error:P}}finally{try{p&&!p.done&&(d=f.return)&&d.call(f)}finally{if(c)throw c.error}}e.clear()}r&&(clearTimeout(r),r=void 0)}function i(){r===void 0&&(r=setTimeout(u,lf))}function a(c){e.add(c),i()}function o(c){e.delete(c)}function u(){r=void 0;var c=Date.now();e.forEach(function(d){var f=d.current;f&&c>=f.cleanAt&&(f.reaction.dispose(),d.current=null,e.delete(d))}),e.size>0&&i()}return{addReactionToTrack:function(c,d,f){return c.current=Ra(d),a(c),c.current},recordReactionAsCommitted:o,forceCleanupTimerToRunNowForTests:t,resetCleanupScheduleForTests:n}}var Va=Ma?sf(Ma):ff(),df=Va.addReactionToTrack,pf=Va.recordReactionAsCommitted,ka=globalThis&&globalThis.__read||function(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,a=[],o;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(u){o={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a};function za(e){return"observer".concat(e)}var hf=function(){function e(){}return e}();function bf(){return new hf}function vf(e,r){r===void 0&&(r="observed");var t=ka(h.default.useState(bf),1),n=t[0],i=ka(h.default.useState(),2),a=i[1],o=function(){return a([])},u=h.default.useRef(null);if(!u.current)var c=new dt(za(r),function(){d.mounted?o():d.changedBeforeMount=!0}),d=df(u,c,n);var f=u.current.reaction;h.default.useDebugValue(f,of),h.default.useEffect(function(){return pf(u),u.current?(u.current.mounted=!0,u.current.changedBeforeMount&&(u.current.changedBeforeMount=!1,o())):(u.current={reaction:new dt(za(r),function(){o()}),mounted:!0,changedBeforeMount:!1,cleanAt:1/0},o()),function(){u.current.reaction.dispose(),u.current=null}},[]);var p,v;if(f.track(function(){try{p=e()}catch(y){v=y}}),v)throw v;return p}var Na=typeof Symbol=="function"&&Symbol.for,La=Na?Symbol.for("react.forward_ref"):typeof z.forwardRef=="function"&&z.forwardRef(function(e){return null}).$$typeof,Fa=Na?Symbol.for("react.memo"):typeof z.memo=="function"&&z.memo(function(e){return null}).$$typeof;function ae(e,r){var t;if(Fa&&e.$$typeof===Fa)throw new Error("[mobx-react-lite] You are trying to use `observer` on a function component wrapped in either another `observer` or `React.memo`. The observer already applies 'React.memo' for you.");var n=(t=r==null?void 0:r.forwardRef)!==null&&t!==void 0?t:!1,i=e,a=e.displayName||e.name;if(La&&e.$$typeof===La&&(n=!0,i=e.render,typeof i!="function"))throw new Error("[mobx-react-lite] `render` property of ForwardRef was not a function");var o=function(u,c){return vf(function(){return i(u,c)},a)};return a!==""&&(o.displayName=a),e.contextTypes&&(o.contextTypes=e.contextTypes),n&&(o=z.forwardRef(o)),o=z.memo(o),yf(e,o),o}var mf={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function yf(e,r){Object.keys(e).forEach(function(t){mf[t]||Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))})}globalThis&&globalThis.__read,af(Uo.unstable_batchedUpdates);var gf="warn";function _f(){return gf}var F;(function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"})(F||(F={}));/*! *****************************************************************************
|
|
25
|
-
Copyright (c) Microsoft Corporation.
|
|
47
|
+
`,Hr=Se.observer(function({showSQLSnippets:e=!0,sx:r={}}){const s=Me(),a=s.context.current,l=W.default.useMemo(()=>{const o={context:a,filters:s.filters.values};if(e){const i=s.sqlSnippets.current.reduce((d,g)=>(d[g.key]=g.value,d),{});o.sql_snippets=i}return JSON.stringify(o,null,2)},[a,s.sqlSnippets.current,s.filters.values,e]);return N(c.Stack,{sx:{border:"1px solid #eee",maxWidth:"40%",overflow:"hidden",...r},children:[n(c.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n(c.Text,{weight:500,children:"Global Variables"})}),N(c.Stack,{px:"md",pb:"md",sx:{width:"100%"},children:[n(st.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:ns}),n(c.Text,{weight:500,sx:{flexGrow:0},children:"Current Values"}),n(st.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:l})]})]})});function is(t,e){const r=Object.keys(e),s=Object.values(e);try{return new Function(...r,`return \`${t}\`;`)(...s)}catch(a){return console.error(a),a.message}}function ir(t,e){const r=Object.keys(e),s=Object.values(e);try{return new Function(...r,`return \`${t}\`;`)(...s)}catch(a){throw r.length===0&&t.includes("$")?new Error("[formatSQL] insufficient params"):a}}function en(t,e,r){const s=e.reduce((a,l)=>(a[l.key]=ir(l.value,t),a),{});return ye.default.merge({},s,t,{filters:r})}function tn(t,e,r,s){try{const a=en(e,r,s);return ir(t,a)}catch(a){return console.error(a),a.message}}const ut={baseURL:"http://localhost:31200",getRequest(t){return(e,r,s={})=>{const a={"X-Requested-With":"XMLHttpRequest","Content-Type":s.string?"application/x-www-form-urlencoded":"application/json",...s.headers},l={baseURL:this.baseURL,method:t,url:e,params:t==="GET"?r:s.params,headers:a};return t==="POST"&&(l.data=s.string?JSON.stringify(r):r),Un.default(l).then(o=>o.data).catch(o=>Promise.reject(o))}}},ar=({type:t,key:e,sql:r})=>async()=>{if(!t||!e||!r)return[];try{return await ut.getRequest("POST")("/query",{type:t,key:e,query:r})}catch(s){return console.error(s),[]}};async function as({context:t,sqlSnippets:e,title:r,query:s,filterValues:a}){if(!s.sql)return[];const{type:l,key:o,sql:i}=s,d=i.includes("$");try{const g=en(t,e,a),m=ir(i,g);return d&&(console.groupCollapsed(`Final SQL for: ${r}`),console.log(m),console.groupEnd()),await ut.getRequest("POST")("/query",{type:l,key:o,query:m})}catch(g){return console.error(g),[]}}async function rn(){try{return(await ut.getRequest("POST")("/datasource/list",{filter:{},sort:{field:"create_time",order:"ASC"},pagination:{page:1,pagesize:100}})).data}catch(t){return console.error(t),[]}}function nn({value:t}){const e=Me(),r=e.context.current,s=W.default.useMemo(()=>tn(t,r,e.sqlSnippets.current,e.filters.values),[t,r,e.sqlSnippets.current,e.filters.values]);return n(st.Prism,{language:"sql",colorScheme:"light",children:s})}const ss=Se.observer(function({queryModel:e}){const{data:r=[],loading:s}=He.useRequest(rn,{refreshDeps:[]},[]),a=W.default.useMemo(()=>Array.from(new Set(r.map(({type:p})=>p))).map(p=>({label:p,value:p})),[r]),l=W.default.useMemo(()=>{const m=r.filter(({type:p})=>p===e.type);return m?m.map(({key:p})=>({label:p,value:p})):[]},[r,e.type]),[o,i]=W.default.useState(e.sql);W.default.useEffect(()=>{i(m=>m!==e.sql?e.sql:m)},[e.sql]);const d=o!==e.sql,g=()=>{e.setSQL(o)};return N(c.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:[n(c.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:n(c.Text,{weight:500,children:"Edit Query"})}),N(c.Stack,{my:0,p:"md",pr:40,children:[N(c.Group,{grow:!0,children:[n(c.TextInput,{placeholder:"An ID unique in this dashboard",label:"ID",required:!0,sx:{flex:1},disabled:s,value:e.id,onChange:m=>{e.setID(m.currentTarget.value)}}),n(c.Select,{label:"Data Source Type",data:a,sx:{flex:1},disabled:s,value:e.type,onChange:e.setType}),n(c.Select,{label:"Data Source Key",data:l,sx:{flex:1},disabled:s,value:e.key,onChange:e.setKey})]}),N(c.Tabs,{defaultValue:"SQL",children:[N(c.Tabs.List,{children:[n(c.Tabs.Tab,{value:"SQL",children:"SQL"}),n(c.Tabs.Tab,{value:"Preview",children:"Preview"})]}),n(c.Tabs.Panel,{value:"SQL",pt:"sm",children:N(c.Box,{sx:{position:"relative"},children:[n(c.Textarea,{autosize:!0,minRows:12,maxRows:24,className:"code-textarea",value:o,onChange:m=>{i(m.currentTarget.value)}}),n(c.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:10,top:10},disabled:!d,onClick:g,children:n(pe.DeviceFloppy,{size:20})})]})}),n(c.Tabs.Panel,{value:"Preview",pt:"sm",children:n(nn,{value:e.sql})})]})]})]})}),os=Se.observer(function({id:e,setID:r}){const s=Me(),a=W.default.useMemo(()=>s.queries.findByID(e),[s.queries,e]);return e?a?n(ss,{queryModel:a}):n("span",{children:"Invalid Query ID"}):null});var _t=(t=>(t.Postgresql="postgresql",t.MySQL="mysql",t.HTTP="http",t))(_t||{});const ls=Se.observer(function({id:e,setID:r}){const s=Me(),a=()=>{var o;r((o=s.queries.firstID)!=null?o:"")};W.default.useEffect(()=>{if(!e){a();return}s.queries.current.findIndex(i=>i.id===e)===-1&&a()},[e,s.queries.current,a]);const l=()=>{const o=Be.randomId();s.queries.append(se.cast({id:o,type:_t.Postgresql,key:"",sql:""})),r(o)};return n(c.Group,{pb:"xl",children:N(c.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[n(c.Text,{children:"Select a Query"}),n(c.Select,{data:s.queries.options,value:e,onChange:r,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}}),n(c.Text,{children:"or"}),n(c.Group,{position:"center",mt:"md",children:n(c.Button,{onClick:l,children:"Add a Query"})})]})})}),us=Se.observer(function({}){const[e,r]=W.default.useState("");return N(c.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:[N(c.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[N(c.Stack,{sx:{flexGrow:1,maxWidth:"calc(60% - 16px)"},children:[n(ls,{id:e,setID:r}),n(os,{id:e,setID:r})]}),n(Hr,{})]}),n(vr,{id:e})]})});function cs({value:t}){const r=Me().context.current,s=W.default.useMemo(()=>is(t,r),[t,r]);return N(c.Stack,{children:[n(c.Text,{children:"Preview"}),n(st.Prism,{language:"sql",noCopy:!0,colorScheme:"dark",children:s})]})}const ds=Se.observer(function({}){const e=Me(),r=()=>e.sqlSnippets.append(se.cast({key:Be.randomId(),value:""}));return N(c.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:[n(c.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n(c.Text,{weight:500,children:"SQL Snippets"})}),n(c.Group,{px:"md",pb:"md",pt:"md",children:N(c.Stack,{sx:{width:"100%",position:"relative"},children:[e.sqlSnippets.current.map((s,a)=>N(c.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n(c.TextInput,{label:"Key",required:!0,value:s.key,onChange:l=>{s.setKey(l.currentTarget.value)}}),n(c.Textarea,{minRows:3,label:"Value",required:!0,value:s.value,onChange:l=>{s.setValue(l.currentTarget.value)},className:"code-textarea"}),n(cs,{value:s.value}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.sqlSnippets.remove(a),sx:{position:"absolute",top:15,right:5},children:n(pe.Trash,{size:16})})]},a)),n(c.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:n(c.Button,{variant:"default",onClick:r,children:"Add a snippet"})})]})})]})});function fs({}){return n(c.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:N(c.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[n(ds,{}),n(Hr,{showSQLSnippets:!1})]})})}const hs=Se.observer(function({opened:e,close:r}){const{freezeLayout:s}=W.default.useContext($e);return W.default.useEffect(()=>{s(e)},[e]),n(c.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:"Data Settings",trapFocus:!0,onDragStart:a=>{a.stopPropagation()},children:N(c.Tabs,{defaultValue:"Queries",children:[N(c.Tabs.List,{children:[n(c.Tabs.Tab,{value:"SQL Snippet",children:"SQL Snippet"}),n(c.Tabs.Tab,{value:"Queries",children:"Queries"})]}),n(c.Tabs.Panel,{value:"SQL Snippet",pt:"sm",children:n(fs,{})}),n(c.Tabs.Panel,{value:"Queries",pt:"sm",children:n(us,{})})]})})});function ps({opened:t,close:e,getCurrentSchema:r}){const{freezeLayout:s}=W.default.useContext($e);W.default.useEffect(()=>{s(t)},[t]);const a=W.default.useMemo(()=>JSON.stringify(r(),null,2),[t]);return n(c.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:e,title:"This dashboard is described by this schema",trapFocus:!0,onDragStart:l=>{l.stopPropagation()},children:n(st.Prism,{language:"json",sx:{width:"100%"},colorScheme:"dark",children:a})})}var Ge=(t=>(t.Select="select",t.MultiSelect="multi-select",t.TextInput="text-input",t.Checkbox="checkbox",t.DateRange="date-range",t))(Ge||{});const an=se.types.model({type:se.types.enumeration("DataSourceType",["postgresql"]),key:se.types.string,sql:se.types.string}),sn=se.types.model("FilterConfigModel_TextInput",{required:se.types.boolean,default_value:se.types.string}).actions(t=>({setRequired(e){t.required=e},setDefaultValue(e){t.default_value=e}})),on=()=>sn.create({required:!1,default_value:""}),ms=Se.observer(function({config:e}){return n(qe,{children:n(c.Checkbox,{checked:e.default_value,onChange:r=>e.setDefaultValue(r.currentTarget.checked),label:"Default Checked"})})}),gs=[{label:"2022",value:"YYYY"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],vs=Se.observer(function({config:e}){return N(qe,{children:[N(c.Group,{children:[n(c.Checkbox,{checked:e.required,onChange:r=>e.setRequired(r.currentTarget.checked),label:"Required"}),n(c.Checkbox,{checked:e.clearable,onChange:r=>e.setClearable(r.currentTarget.checked),label:"Clearable"})]}),n(c.Select,{data:gs,label:"Display Format",value:e.inputFormat,onChange:e.setInputFormat})]})}),bs=Se.observer(function({value:e,onChange:r}){const{data:s=[],loading:a}=He.useRequest(rn,{refreshDeps:[]},[]),l=W.default.useMemo(()=>Array.from(new Set(s.map(({type:d})=>d))).map(d=>({label:d,value:d})),[s]),o=W.default.useMemo(()=>{const i=s.filter(({type:d})=>d===e.type);return i?i.map(({key:d})=>({label:d,value:d})):[]},[s,e.type]);return N(c.Group,{grow:!0,children:[n(c.Select,{label:"Data Source Type",data:l,sx:{flex:1},disabled:a,value:e.type,onChange:i=>{r({...e,type:i})}}),n(c.Select,{label:"Data Source Key",data:o,sx:{flex:1},disabled:a,value:e.key,onChange:i=>{r({...e,key:i})}})]})});function ys({data:t}){return t.length===0?n(c.Box,{sx:{height:"5em"}}):N(c.Table,{children:[n("thead",{children:n("tr",{children:Object.keys(t==null?void 0:t[0]).map(e=>n("th",{children:n(c.Text,{weight:700,color:"#000",children:e})},e))})}),n("tbody",{children:t.slice(0,3).map((e,r)=>n("tr",{children:Object.values(e).map((s,a)=>n("td",{children:n(c.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:n(c.Text,{children:s})})},`${s}--${a}`))},`row-${r}`))}),t.length>3&&n("tfoot",{children:n("tr",{children:n("td",{colSpan:Object.keys(t==null?void 0:t[0]).length,children:N(c.Text,{color:"gray",size:"sm",children:[t.length-3," more row(s) hidden"]})})})})]})}const _s=Se.observer(function({query:e}){const{data:r=[],loading:s,refresh:a}=He.useRequest(ar(e),{refreshDeps:[e]});return N(c.Stack,{my:0,children:[N(c.Group,{position:"apart",children:[n(c.Text,{size:"md",pl:"sm",children:"Fetched Data"}),n(c.Button,{size:"xs",onClick:a,disabled:!e.sql||!e.key,children:"Retry"})]}),N(c.Box,{sx:{position:"relative"},children:[n(c.LoadingOverlay,{visible:s,exitTransitionDuration:0}),n(ys,{data:r})]})]})}),ln=Se.observer(function({value:e,onChange:r}){return N(c.Stack,{my:0,children:[n(bs,{value:e,onChange:r}),N(c.Tabs,{defaultValue:"SQL",children:[N(c.Tabs.List,{children:[n(c.Tabs.Tab,{value:"SQL",children:"SQL"}),n(c.Tabs.Tab,{value:"Preview",children:"Preview"}),n(c.Tabs.Tab,{value:"Data",children:"Data"})]}),n(c.Tabs.Panel,{value:"SQL",pt:"sm",children:n(c.Textarea,{autosize:!0,minRows:12,maxRows:24,className:"code-textarea",value:e.sql,onChange:s=>{r({...e,sql:s.currentTarget.value})},placeholder:"SELECT name AS label, id AS value"})}),n(c.Tabs.Panel,{value:"Preview",pt:"sm",children:n(nn,{value:e.sql})}),n(c.Tabs.Panel,{value:"Data",pt:"sm",children:n(_s,{query:e})})]})]})}),ws=Se.observer(function({config:e}){const r=()=>{e.addStaticOption({label:"",value:""})},s=e.static_options,a=[...s];return N(qe,{children:[n(c.Divider,{label:"Configure options",labelPosition:"center"}),s.length>0&&n(c.MultiSelect,{label:"Default Selection",data:a,value:e.default_value,onChange:e.setDefaultValue}),s.map((l,o)=>N(c.Group,{sx:{position:"relative"},pr:"40px",children:[n(c.TextInput,{label:"Label",required:!0,value:e.static_options[o].label,onChange:i=>{e.static_options[o].setLabel(i.currentTarget.value)},sx:{flexGrow:1}}),n(c.TextInput,{label:"Value",required:!0,value:e.static_options[o].value,onChange:i=>{e.static_options[o].setValue(i.currentTarget.value)},sx:{flexGrow:1}}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(o),sx:{position:"absolute",top:28,right:5},children:n(pe.Trash,{size:16})})]})),n(c.Button,{size:"xs",color:"blue",leftIcon:n(pe.PlaylistAdd,{size:20}),onClick:r,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),n(c.Divider,{label:"Or fetch options from database",labelPosition:"center"}),n(ln,{value:e.options_query,onChange:e.setOptionsQuery})]})}),xs=Se.observer(function({config:e}){const r=()=>{e.addStaticOption({label:"",value:""})},s=e.static_options,a=[{label:"No default selection",value:""},...s];return N(qe,{children:[n(c.Checkbox,{checked:e.required,onChange:l=>e.setRequired(l.currentTarget.checked),label:"Required"}),n(c.Divider,{label:"Configure options",labelPosition:"center"}),s.length>0&&n(c.Select,{label:"Default Selection",data:a,value:e.default_value,onChange:e.setDefaultValue}),s.map((l,o)=>N(c.Group,{sx:{position:"relative"},pr:"40px",children:[n(c.TextInput,{label:"Label",required:!0,value:e.static_options[o].label,onChange:i=>{e.static_options[o].setLabel(i.currentTarget.value)},sx:{flexGrow:1}}),n(c.TextInput,{label:"Value",required:!0,value:e.static_options[o].value,onChange:i=>{e.static_options[o].setValue(i.currentTarget.value)},sx:{flexGrow:1}}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(o),sx:{position:"absolute",top:28,right:5},children:n(pe.Trash,{size:16})})]})),n(c.Button,{size:"xs",color:"blue",leftIcon:n(pe.PlaylistAdd,{size:20}),onClick:r,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),n(c.Divider,{label:"Or fetch options from database",labelPosition:"center"}),n(ln,{value:e.options_query,onChange:e.setOptionsQuery})]})}),ks=Se.observer(function({config:e}){return N(qe,{children:[n(c.TextInput,{label:"Default Value",value:e.default_value,onChange:r=>{e.setDefaultValue(r.currentTarget.value)}}),n(c.Checkbox,{checked:e.required,onChange:r=>e.setRequired(r.currentTarget.checked),label:"Required"})]})});function Cs({label:t,config:{default_value:e,...r},value:s,onChange:a}){return N(c.Box,{children:[n(c.Text,{children:"\xA0"}),n(c.Checkbox,{label:t,checked:s,onChange:l=>a(l.currentTarget.checked),...r})]})}function Ss({label:t,config:e,value:r,onChange:s}){return n(qn.DateRangePicker,{label:t,value:r,onChange:s,icon:n(pe.Calendar,{size:16}),sx:{minWidth:"14em"},...e})}function Es({label:t,config:e,value:r,onChange:s}){const a=!!e.options_query.sql,{data:l=[],loading:o}=He.useRequest(ar(e.options_query),{refreshDeps:[e.options_query,a]});return n(c.MultiSelect,{label:t,data:a?l:e.static_options,disabled:a?o:!1,value:r,onChange:s,sx:{minWidth:"14em"}})}function zs({label:t,config:e,value:r,onChange:s}){const a=!!e.options_query.sql,{data:l=[],loading:o}=He.useRequest(ar(e.options_query),{refreshDeps:[e.options_query,a]});return n(c.Select,{label:t,data:a?l:e.static_options,disabled:a?o:!1,value:r,onChange:s})}function Ts({label:t,config:e,value:r,onChange:s}){return n(c.TextInput,{label:t,value:r,onChange:s,...e})}function As({type:t,config:e,key:r,...s},a){switch(t){case"select":return n(zs,{...s,...a,config:e});case"multi-select":return n(Es,{...s,...a,config:e});case"text-input":return n(Ts,{...s,...a,config:e});case"date-range":return n(Ss,{...s,...a,config:e});case"checkbox":return n(Cs,{...s,...a,config:e});default:return null}}const un=W.default.forwardRef(function({filter:e,...r},s){return n("div",{className:"filter-root",ref:s,children:n(Tt,{children:As(e,r)})})}),Ds=Se.observer(function({filter:e}){const r=e.config.default_value,[s,a]=W.default.useState(r);return W.default.useEffect(()=>{a(r)},[r]),N(c.Box,{sx:{maxWidth:"30em"},children:[n(c.Text,{pb:"md",color:"gray",children:"Preview"}),n(un,{filter:e,value:s,onChange:a}),n(c.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),n(st.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(e,null,4)})]})}),Os={select:xs,"multi-select":ws,"text-input":ks,checkbox:ms,"date-range":vs},Is=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],Ps=Se.observer(function({filter:e,index:r}){const s=W.default.useMemo(()=>Os[e.type],[e.type]);return N(c.SimpleGrid,{cols:2,children:[N(c.Box,{pl:"md",children:[n(c.Text,{pb:"md",color:"gray",children:"Edit"}),N(c.Stack,{sx:{maxWidth:"30em"},children:[n(c.NumberInput,{label:"Placement Order",required:!0,value:e.order,onChange:e.setOrder,hideControls:!0}),n(c.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:e.key,onChange:a=>{e.setKey(a.currentTarget.value)}}),n(c.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:e.label,onChange:a=>{e.setLabel(a.currentTarget.value)}}),n(c.Select,{label:"Widget",data:Is,required:!0,value:e.type,onChange:e.setType}),n(s,{config:e.config,index:r})]})]}),n(Ds,{filter:e})]})}),fo="",Fs=Se.observer(function({}){const e=Me(),r=e.filters.current,s=()=>{const a=Be.randomId(),l={id:a,key:a,label:a,order:r.length+1,type:Ge.TextInput,config:on()};e.filters.append(l)};return N(c.Group,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)"},p:0,children:[n(c.Group,{sx:{position:"absolute",top:"16px",right:"16px"},children:n(c.Button,{size:"xs",color:"red",leftIcon:n(pe.Recycle,{size:20}),disabled:!e.filters.changed,onClick:e.filters.reset,children:"Revert Changes"})}),n(c.Tabs,{className:"filter-settings-tabs",orientation:"vertical",defaultValue:e.filters.firstID,children:N(c.Group,{sx:{height:"100%"},children:[N(c.Stack,{sx:{height:"100%"},children:[n(c.Tabs.List,{position:"left",sx:{flexGrow:1,width:"200px"},children:e.filters.current.map((a,l)=>n(c.Tabs.Tab,{value:a.id,children:a.label},a.id))}),n(c.Button,{size:"xs",color:"blue",leftIcon:n(pe.PlaylistAdd,{size:20}),onClick:s,children:"Add a Filter"})]}),n(c.Box,{sx:{flexGrow:1,height:"100%"},children:e.filters.current.map((a,l)=>n(c.Tabs.Panel,{value:a.id,sx:{height:"100%"},children:N(c.Stack,{sx:{height:"100%"},spacing:"sm",children:[n(c.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"scroll"},children:n(Ps,{filter:a,index:l})}),n(c.Group,{position:"right",pt:10,children:n(c.Button,{size:"xs",color:"red",leftIcon:n(pe.Trash,{size:20}),onClick:()=>e.filters.remove(l),children:"Delete this filter"})})]})},a.id))})]})})]})}),Rs=Se.observer(function({opened:e,close:r}){const{freezeLayout:s}=W.default.useContext($e);return W.default.useEffect(()=>{s(e)},[e]),n(c.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:"Filters",trapFocus:!0,onDragStart:a=>{a.stopPropagation()},withCloseButton:!1,children:n(Fs,{})})}),Ms=Se.observer(function({mode:e,setMode:r,hasChanges:s,saveChanges:a,revertChanges:l,getCurrentSchema:o}){const i=Me(),{addPanel:d}=W.default.useContext(Et),{inLayoutMode:g,inEditMode:m,inUseMode:p}=W.default.useContext($e),[b,h]=W.default.useState(!1),E=()=>h(!0),v=()=>h(!1),[S,_]=W.default.useState(!1),z=()=>_(!0),I=()=>_(!1),[M,F]=W.default.useState(!1),Y=()=>F(!0),$=()=>F(!1);return N(c.Group,{position:"apart",pt:0,pb:"xs",children:[n(c.Group,{position:"left",children:n(rs,{mode:e,setMode:r})}),N(c.Group,{position:"right",children:[!p&&n(c.Button,{variant:"default",size:"xs",onClick:d,leftIcon:n(pe.PlaylistAdd,{size:20}),children:"Add a Panel"}),m&&n(c.Button,{variant:"default",size:"xs",onClick:z,leftIcon:n(pe.Filter,{size:20}),children:"Filters"}),m&&n(c.Button,{variant:"default",size:"xs",onClick:E,leftIcon:n(pe.Database,{size:20}),children:"Data Settings"}),!p&&n(c.Button,{variant:"default",size:"xs",onClick:a,disabled:!s,leftIcon:n(pe.DeviceFloppy,{size:20}),children:"Save Changes"}),!p&&n(c.Button,{color:"red",size:"xs",disabled:!s,onClick:l,leftIcon:n(pe.Recycle,{size:20}),children:"Revert Changes"}),N(c.Menu,{width:180,children:[n(c.Menu.Target,{children:n(c.Button,{variant:"default",size:"xs",leftIcon:n(pe.Share,{size:20}),children:"Export"})}),N(c.Menu.Dropdown,{children:[n(c.Menu.Item,{icon:n(pe.Download,{size:14}),onClick:i.queries.downloadAllData,children:"Download Data"}),n(c.Menu.Item,{icon:n(pe.Code,{size:14}),onClick:Y,children:"View Schema"})]})]})]}),n(Rs,{opened:S,close:I}),n(hs,{opened:b,close:v}),n(ps,{opened:M,close:$,getCurrentSchema:o})]})}),cn=Se.observer(function({panel:e,exitFullScreen:r}){return N(c.Stack,{px:"10px",pb:"5px",sx:{flexGrow:1,justifyContent:"flex-start"},children:[n(c.Group,{mx:"-5px",sx:{flexGrow:0},children:n(c.Button,{variant:"default",size:"sm",onClick:r,leftIcon:n(pe.ArrowLeft,{size:20}),children:"Exit fullscreen"})}),n(c.Group,{mx:"-5px",grow:!0,sx:{flexGrow:1,flexShrink:0},children:n(Pt,{...e})})]})});function dn(t){const[e,r]=W.default.useState(null),s=W.default.useCallback(i=>{r(i)},[]),a=W.default.useCallback(()=>{r(null)},[]),l=W.default.useMemo(()=>t.find(i=>i.id===e),[e,t]);return{viewPanelInFullScreen:s,exitFullScreen:a,inFullScreen:!!l,fullScreenPanel:l}}const fn=Se.observer(function({}){const e=Me(),{control:r,handleSubmit:s}=be.useForm({defaultValues:e.filters.values});return e.filters.empty?null:n("form",{onSubmit:s(e.filters.setValues),children:N(c.Group,{className:"dashboard-filters",position:"apart",p:"md",noWrap:!0,sx:{boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[n(c.Group,{align:"flex-start",children:e.filters.inOrder.map(a=>n(be.Controller,{name:a.key,control:r,render:({field:l})=>n(un,{filter:a,...l})},a.id))}),n(c.Group,{sx:{alignSelf:"flex-end"},children:n(c.Button,{color:"blue",size:"sm",type:"submit",children:"Submit"})})]})})}),hn=se.types.model({label:se.types.string,value:se.types.string}).actions(t=>({setLabel(e){t.label=e},setValue(e){t.value=e}})),pn=se.types.model("FilterConfigModel_Select",{required:se.types.boolean,default_value:se.types.string,static_options:se.types.optional(se.types.array(hn),[]),options_query:an}).actions(t=>({addStaticOption(e){t.static_options.push(e)},removeStaticOption(e){t.static_options.splice(e,1)},setRequired(e){t.required=e},setDefaultValue(e){t.default_value=e},setOptionsQuery(e){t.options_query=e}})),Ls=()=>pn.create({required:!1,default_value:"",static_options:[],options_query:{type:"postgresql",key:"",sql:""}}),mn=se.types.model("FilterConfigModel_MultiSelect",{default_value:se.types.optional(se.types.array(se.types.string),[]),static_options:se.types.optional(se.types.array(hn),[]),options_query:an}).actions(t=>({addStaticOption(e){t.static_options.push(e)},removeStaticOption(e){t.static_options.splice(e,1)},setDefaultValue(e){t.default_value=se.cast(e)},setOptionsQuery(e){t.options_query=e}})),Bs=()=>mn.create({default_value:[],static_options:[],options_query:{type:"postgresql",key:"",sql:""}}),gn=se.types.model("FilterConfigModel_Checkbox",{default_value:se.types.boolean}).actions(t=>({setDefaultValue(e){t.default_value=e}})),js=()=>gn.create({default_value:!1}),vn=se.types.model("FilterConfigModel_DateRange",{required:se.types.boolean,inputFormat:se.types.enumeration("DateRangeInputFormat",["YYYY","YYYY-MM","YYYY-MM-DD"]),clearable:se.types.boolean}).actions(t=>({setRequired(e){t.required=e},setClearable(e){t.clearable=e},setInputFormat(e){t.inputFormat=e}})),qs=()=>vn.create({required:!1,inputFormat:"YYYY-MM-DD",clearable:!1}),sr=se.types.model("FilterModel",{id:se.types.identifier,key:se.types.string,label:se.types.string,order:se.types.number,type:se.types.enumeration("DashboardFilterType",[Ge.Select,Ge.MultiSelect,Ge.TextInput,Ge.Checkbox,Ge.DateRange]),config:se.types.union(pn,mn,sn,gn,vn)}).actions(t=>({setKey(e){t.key=e},setLabel(e){t.label=e},setOrder(e){t.order=e},setType(e){switch(e){case Ge.Select:t.config=Ls();break;case Ge.MultiSelect:t.config=Bs();break;case Ge.TextInput:t.config=on();break;case Ge.Checkbox:t.config=js();break;case Ge.DateRange:t.config=qs();break}t.type=e}})),bn=se.types.model("FiltersModel",{original:se.types.optional(se.types.array(sr),[]),current:se.types.optional(se.types.array(sr),[]),values:se.types.optional(se.types.frozen(),{})}).views(t=>({get changed(){return!ye.default.isEqual(t.original,t.current)},get firstID(){if(t.current.length!==0)return t.current[0].id},get inOrder(){return ye.default.sortBy(t.current,"order")},get empty(){return t.current.length===0}})).actions(t=>({reset(){t.current=ye.default.cloneDeep(t.original)},replace(e){t.current=se.cast(e)},append(e){t.current.push(e)},remove(e){t.current.splice(e,1)},setValues(e){t.values=e},setValueByKey(e,r){t.values[e]=r},getValueByKey(e){return t.values[e]}}));function yn(t){const e=t.reduce((r,s)=>{var a;return r[s.key]=(a=s.config.default_value)!=null?a:"",r},{});return{original:t,current:t,values:e}}function Ft(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var _n={exports:{}};/*!
|
|
26
48
|
|
|
27
|
-
|
|
28
|
-
|
|
49
|
+
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
|
|
50
|
+
<http://stuartk.com/jszip>
|
|
29
51
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
33
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
34
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
35
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
36
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
37
|
-
***************************************************************************** */var gn=function(e,r){return gn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},gn(e,r)};function M(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");gn(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}var Ft=function(){return Ft=Object.assign||function(r){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},Ft.apply(this,arguments)};function wf(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]]);return t}function jr(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function _n(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,a=[],o;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(u){o={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a}function ht(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(_n(arguments[r]));return e}function qa(e){return D(e).type}function Ba(e,r){D(e).applyPatches(Ja(r))}function Ga(e,r){r===void 0&&(r=!0);var t=D(e);return r?t.snapshot:t.type.getSnapshot(t,!1)}function Sf(e){return D(e).root.storedValue}function Of(e){return D(e).path}function xf(e){return D(e).identifier}function Kp(e){return e}var $a=function(){function e(r,t,n,i){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:q.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=i,this.baseSetParent(t,n)}return Object.defineProperty(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(r){var t=this.isAlive;this._state=r;var n=this.isAlive;this.aliveAtom&&t!==n&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(r){this._hookSubscribers&&this._hookSubscribers.emit(r,this,r)}}),Object.defineProperty(e.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){return this._hookSubscribers||(this._hookSubscribers=new Za),this._hookSubscribers.register(r,t)}}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(e.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){this._parent=r,this._subpath=t,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()}}),Object.defineProperty(e.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(r){return r&&(this.pathAtom||(this.pathAtom=cr("path")),this.pathAtom.reportObserved()),this.parent?(this._escapedSubpath===void 0&&(this._escapedSubpath=this._subpath?et(this._subpath):""),this.parent.getEscapedPath(r)+"/"+this._escapedSubpath):""}}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return this.parent===null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==q.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===q.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=cr("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(r){if(this.state===q.CREATED){if(this.parent){if(this.parent.state!==q.FINALIZED)return;this.fireHook(F.afterAttach)}this.state=q.FINALIZED,r&&r()}}}),Object.defineProperty(e.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=q.DEAD}}),Object.defineProperty(e.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(F.beforeDestroy)}}),e}(),qt=function(e){M(r,e);function r(t,n,i,a,o){var u=e.call(this,t,n,i,a)||this;try{u.storedValue=t.createNewInstance(o)}catch(c){throw u.state=q.DEAD,c}return u.state=q.CREATED,u.finalizeCreation(),u}return Object.defineProperty(r.prototype,"root",{get:function(){if(!this.parent)throw g("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this.parent!==t,a=this.subpath!==n;!i&&!a||(this.environment=void 0,this.baseSetParent(this.parent,n))}}),Object.defineProperty(r.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(r.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+t+(this.isAlive?"":" [dead]")}}),Object.defineProperty(r.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){!this.isAlive||this.state===q.DETACHING||(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(r.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(r.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(r.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(r.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.fireInternalHook(t)}}),r}($a);qt.prototype.die=L(qt.prototype.die);var Pf=1,Cf={onError:function(e){throw e}},H=function(e){M(r,e);function r(t,n,i,a,o){var u=e.call(this,t,n,i,a)||this;if(Object.defineProperty(u,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++Pf}),Object.defineProperty(u,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(u,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u._snapshotComputed=st(function(){return u.getSnapshot()}),u.unbox=u.unbox.bind(u),u._initialSnapshot=o,u.identifierAttribute=t.identifierAttribute,n||(u.identifierCache=new qf),u._childNodes=t.initializeChildNodes(u,u._initialSnapshot),u.identifier=null,u.unnormalizedIdentifier=null,u.identifierAttribute&&u._initialSnapshot){var c=u._initialSnapshot[u.identifierAttribute];if(c===void 0){var d=u._childNodes[u.identifierAttribute];d&&(c=d.value)}if(typeof c!="string"&&typeof c!="number")throw g("Instance identifier '"+u.identifierAttribute+"' for type '"+u.type.name+"' must be a string or a number");u.identifier=Wt(c),u.unnormalizedIdentifier=c}return n?n.root.identifierCache.addNodeToCache(u):u.identifierCache.addNodeToCache(u),u}return Object.defineProperty(r.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.createObservableInstanceIfNeeded(),this._applyPatches(t)}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.createObservableInstanceIfNeeded(),this._applySnapshot(t)}}),Object.defineProperty(r.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._observableInstanceState===0&&this.createObservableInstance()}}),Object.defineProperty(r.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t,n;this._observableInstanceState=1;for(var i=[],a=this.parent;a&&a._observableInstanceState===0;)i.unshift(a),a=a.parent;try{for(var o=jr(i),u=o.next();!u.done;u=o.next()){var c=u.value;c.createObservableInstanceIfNeeded()}}catch(f){t={error:f}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}var d=this.type;try{this.storedValue=d.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,d.finalizeNewInstance(this,this.storedValue)}catch(f){throw this.state=q.DEAD,f}finally{this._isRunningAction=!1}this._observableInstanceState=2,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=yt,this.state=q.CREATED,this.fireHook(F.afterCreate),this.finalizeCreation()}}),Object.defineProperty(r.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!!this.parent){this.fireHook(F.beforeDetach);var t=this.state;this.state=q.DETACHING;var n=this.root,i=n.environment,a=n.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=i,this.identifierCache=a}finally{this.state=t}}}}),Object.defineProperty(r.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=t!==this.parent,a=n!==this.subpath;!i&&!a||(i?(this.environment=void 0,t.root.identifierCache.mergeCache(this),this.baseSetParent(t,n),this.fireHook(F.afterAttach)):a&&this.baseSetParent(this.parent,n))}}),Object.defineProperty(r.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;this.fireInternalHook(t);var i=this.storedValue&&typeof this.storedValue=="object"&&this.storedValue[t];typeof i=="function"&&(na?na(function(){i.apply(n.storedValue)}):i.apply(this.storedValue))}}),Object.defineProperty(r.prototype,"snapshot",{get:function(){return this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?this._observableInstanceState===2?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(r.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(r.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var t=this.type,n=this._childNodes,i=this._initialSnapshot;this._cachedInitialSnapshot=t.processInitialSnapshot(n,i),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(r.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isRunningAction?!0:this.isRoot?!1:this.parent.isRunningAction()}}),Object.defineProperty(r.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=_f();if(!this.isAlive&&n!=="ignore"){var i=this._getAssertAliveError(t);switch(n){case"error":throw g(i);case"warn":Zf(i)}}}}),Object.defineProperty(r.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.getEscapedPath(!1)||this.pathUponDeath||"",i=t.subpath&&et(t.subpath)||"",a=t.actionContext||Tf();a&&a.type!=="action"&&a.parentActionEvent&&(a=a.parentActionEvent);var o="";if(a&&a.name!=null){var u=a&&a.context&&Of(a.context)||n;o=u+"."+a.name+"()"}return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '"+this.type.name+"', Path upon death: '"+n+"', Subpath: '"+i+"', Action: '"+o+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.assertAlive({subpath:t}),this._autoUnbox=!1;try{return this._observableInstanceState===2?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(yt),this._autoUnbox=!1;try{return this._observableInstanceState===2?this.type.getChildren(this):Ka(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.type.getChildType(t)}}),Object.defineProperty(r.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(this.assertAlive(t),!this.isRunningAction()&&this.isProtected)throw g("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.type.removeChild(this,t)}}),Object.defineProperty(r.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t&&(this.assertAlive({subpath:t.subpath||t.subpathUponDeath}),this._autoUnbox?t.value:t)}}),Object.defineProperty(r.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>",n=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+t+n+(this.isAlive?"":" [dead]")}}),Object.defineProperty(r.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;this.baseFinalizeCreation(function(){var n,i;try{for(var a=jr(t.getChildren()),o=a.next();!o.done;o=a.next()){var u=o.value;u.finalizeCreation()}}catch(c){n={error:c}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}t.fireInternalHook(F.afterCreationFinalization)})}}),Object.defineProperty(r.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw g("Error while detaching, node is not alive.");this.clearParent()}}),Object.defineProperty(r.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;this._applyPatches=Gt(this.storedValue,"@APPLY_PATCHES",function(n){n.forEach(function(i){if(!i.path){t.type.applySnapshot(t,i.value);return}var a=od(i.path),o=$f(t,a.slice(0,-1));o.applyPatchLocally(a[a.length-1],i)})}),this._applySnapshot=Gt(this.storedValue,"@APPLY_SNAPSHOT",function(n){if(n!==t.snapshot)return t.type.applySnapshot(t,n)}),Ze(this.storedValue,"$treenode",this),Ze(this.storedValue,"toJSON",Gf)}}),Object.defineProperty(r.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){!this.isAlive||this.state===q.DETACHING||(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(r.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._observableInstanceState!==0&&(this.getChildren().forEach(function(t){t.aboutToDie()}),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))}}),Object.defineProperty(r.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach(function(n){n.finalizeDeath()}),this.root.identifierCache.notifyDied(this);var t=this.snapshot;this._snapshotUponDeath=t,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(r.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",t)}}),Object.defineProperty(r.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this._internalEventsEmit("snapshot",t)}}),Object.defineProperty(r.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._internalEventsRegister("patch",t)}}),Object.defineProperty(r.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(this._internalEventsHasSubscribers("patch")){var i=Qf({},t,{path:n.path.substr(this.path.length)+"/"+t.path}),a=_n(td(i),2),o=a[0],u=a[1];this._internalEventsEmit("patch",o,u)}this.parent&&this.parent.emitPatch(t,n)}}),Object.defineProperty(r.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._internalEventsHas("dispose",t)}}),Object.defineProperty(r.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!this.hasDisposer(t)){this._internalEventsRegister("dispose",t,!0);return}throw g("cannot add a disposer when it is already registered for execution")}}),Object.defineProperty(r.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!this._internalEventsHas("dispose",t))throw g("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",t)}}),Object.defineProperty(r.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(this.middlewares){var n=this.middlewares.indexOf(t);n>=0&&this.middlewares.splice(n,1)}}}),Object.defineProperty(r.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this;n===void 0&&(n=!0);var a={handler:t,includeHooks:n};return this.middlewares?this.middlewares.push(a):this.middlewares=[a],function(){i.removeMiddleware(a)}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){this.assertWritable({subpath:t}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,t,n)}}),Object.defineProperty(r.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;if(!this._hasSnapshotReaction){var n=wc(function(){return t.snapshot},function(i){return t.emitSnapshot(i)},Cf);this.addDisposer(n),this._hasSnapshotReaction=!0}}}),Object.defineProperty(r.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return!!this._internalEvents&&this._internalEvents.hasSubscribers(t)}}),Object.defineProperty(r.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){return i===void 0&&(i=!1),this._internalEvents||(this._internalEvents=new Za),this._internalEvents.register(t,n,i)}}),Object.defineProperty(r.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return!!this._internalEvents&&this._internalEvents.has(t,n)}}),Object.defineProperty(r.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){this._internalEvents&&this._internalEvents.unregister(t,n)}}),Object.defineProperty(r.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(t){for(var n,i=[],a=1;a<arguments.length;a++)i[a-1]=arguments[a];this._internalEvents&&(n=this._internalEvents).emit.apply(n,ht([t],i))}}),Object.defineProperty(r.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this._internalEvents&&this._internalEvents.clear(t)}}),Object.defineProperty(r.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),r}($a);H.prototype.createObservableInstance=L(H.prototype.createObservableInstance),H.prototype.detach=L(H.prototype.detach),H.prototype.die=L(H.prototype.die);var Ua,E;(function(e){e[e.String=1]="String",e[e.Number=2]="Number",e[e.Boolean=4]="Boolean",e[e.Date=8]="Date",e[e.Literal=16]="Literal",e[e.Array=32]="Array",e[e.Map=64]="Map",e[e.Object=128]="Object",e[e.Frozen=256]="Frozen",e[e.Optional=512]="Optional",e[e.Reference=1024]="Reference",e[e.Identifier=2048]="Identifier",e[e.Late=4096]="Late",e[e.Refinement=8192]="Refinement",e[e.Union=16384]="Union",e[e.Null=32768]="Null",e[e.Undefined=65536]="Undefined",e[e.Integer=131072]="Integer",e[e.Custom=262144]="Custom",e[e.SnapshotProcessor=524288]="SnapshotProcessor"})(E||(E={}));var Wa="cannotDetermine",Af=Symbol("$type"),Te=function(){function e(r){Object.defineProperty(this,Ua,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){return Ee(this,r),this.instantiate(null,"",t,r).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){throw g("unimplemented method")}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(r){return r===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=Qa(r);if(n){var i=qa(r);return this.isAssignableFrom(i)?J():X(t,r)}return this.isValidSnapshot(r,t)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(r){return this.validate(r,[{path:"",type:this}]).length===0}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw g("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw g("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw g("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw g("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!1,configurable:!0}),e}();Ua=Af,Te.prototype.create=L(Te.prototype.create);var bt=function(e){M(r,e);function r(t){var n=e.call(this,t)||this;return Object.defineProperty(n,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return Object.defineProperty(r.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return t===void 0&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,n)}}),Object.defineProperty(r.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.createObservableInstanceIfNeeded(),t.storedValue}}),Object.defineProperty(r.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return!t.identifierAttribute||t.identifier===Wt(n[t.identifierAttribute])}}),Object.defineProperty(r.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return t.isDetaching?!1:t.snapshot===n||V(n)&&D(n)===t?!0:t.type===this&&Xa(n)&&!V(n)&&this.isMatchingSnapshotId(t,n)?(t.applySnapshot(n),!0):!1}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=this.tryToReconcileNode(t,n);if(o)return t.setParent(i,a),t;if(t.die(),V(n)&&this.isAssignableFrom(qa(n))){var u=D(n);return u.setParent(i,a),u}return this.instantiate(i,a,void 0,n)}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),r}(Te);bt.prototype.create=L(bt.prototype.create);var vt=function(e){M(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t}}),Object.defineProperty(r.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.storedValue}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.storedValue}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){if(!t.isDetaching&&t.type===this&&t.storedValue===n)return t;var o=this.instantiate(i,a,void 0,n);return t.die(),o}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),r}(Te);function Le(e){return typeof e=="object"&&e&&e.isType===!0}var jf=1,Bt;function Tf(){return Bt}function Ef(){return jf++}function If(e,r){var t=D(e.context);e.type==="action"&&t.assertAlive({actionContext:e});var n=t._isRunningAction;t._isRunningAction=!0;var i=Bt;Bt=e;try{return Rf(t,e,r)}finally{Bt=i,t._isRunningAction=n}}function Df(e){if(!!e)return e.type==="action"?e:e.parentActionEvent}function Gt(e,r,t){var n=function(){var i=Ef(),a=Bt,o=Df(a);return If({type:"action",name:r,id:i,args:Xf(arguments),context:e,tree:Sf(e),rootId:a?a.rootId:i,parentId:a?a.id:0,allParentIds:a?ht(a.allParentIds,[a.id]):[],parentEvent:a,parentActionEvent:o},t)};return n._isMSTAction=!0,n}var Mf=function(){function e(r,t){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var n=r;n;)n.middlewares&&this.middlewares.push(n.middlewares),n=n.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(){var r=this.middlewares[this.arrayIndex];if(!!r){var t=r[this.inArrayIndex++];return t||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}}}),e}();function Rf(e,r,t){var n=new Mf(e,t);if(n.isEmpty)return L(t).apply(null,r.args);var i=null;function a(o){var u=n.getNextMiddleware(),c=u&&u.handler;if(!c)return L(t).apply(null,o.args);if(!u.includeHooks&&F[o.name])return a(o);function d(p,v){i=a(p),v&&(i=v(i))}function f(p){i=p}return c(o,d,f),i}return a(r)}function Vf(e){try{return JSON.stringify(e)}catch(r){return"<Unserializable: "+r+">"}}function Ya(e){return typeof e=="function"?"<function"+(e.name?" "+e.name:"")+">":V(e)?"<"+e+">":"`"+Vf(e)+"`"}function kf(e){return e.length<280?e:e.substring(0,272)+"......"+e.substring(e.length-8)}function zf(e){var r=e.value,t=e.context[e.context.length-1].type,n=e.context.map(function(u){var c=u.path;return c}).filter(function(u){return u.length>0}).join("/"),i=n.length>0?'at path "/'+n+'" ':"",a=V(r)?"value of type "+D(r).type.name+":":$t(r)?"value":"snapshot",o=t&&V(r)&&t.is(D(r).snapshot);return""+i+a+" "+Ya(r)+" is not assignable "+(t?"to type: `"+t.name+"`":"")+(e.message?" ("+e.message+")":"")+(t?_d(t)||$t(r)?".":", expected an instance of `"+t.name+"` or a snapshot like `"+t.describe()+"` instead."+(o?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function wn(e,r,t){return e.concat([{path:r,type:t}])}function J(){return mt}function X(e,r,t){return[{context:e,value:r,message:t}]}function Tr(e){return e.reduce(function(r,t){return r.concat(t)},[])}function Ee(e,r){ed()&&Nf(e,r)}function Nf(e,r){var t=e.validate(r,[{path:"",type:e}]);if(t.length>0)throw g(Lf(e,r,t))}function Lf(e,r,t){if(t.length!==0)return"Error while converting "+kf(Ya(r))+" to `"+e.name+`\`:
|
|
52
|
+
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
|
|
53
|
+
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
|
|
38
54
|
|
|
39
|
-
|
|
40
|
-
`)}var Ff=0,qf=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:Ff++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:R.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:R.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this.lastCacheModificationPerId.get(r);this.lastCacheModificationPerId.set(r,t===void 0?1:t+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this.lastCacheModificationPerId.get(r)||0;return this.cacheId+"-"+t}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){if(t===void 0&&(t=!0),r.identifierAttribute){var n=r.identifier;this.cache.has(n)||this.cache.set(n,R.array([],Er));var i=this.cache.get(n);if(i.indexOf(r)!==-1)throw g("Already registered");i.push(r),t&&this.updateLastCacheModificationPerId(n)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this;pa(r.identifierCache.cache).forEach(function(n){return n.forEach(function(i){t.addNodeToCache(i)})})}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(r){if(r.identifierAttribute){var t=r.identifier,n=this.cache.get(t);n&&(n.remove(r),n.length||this.cache.delete(t),this.updateLastCacheModificationPerId(r.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this,n=new e,i=r.path;return zc(this.cache).forEach(function(a){for(var o=_n(a,2),u=o[0],c=o[1],d=!1,f=c.length-1;f>=0;f--)c[f].path.indexOf(i)===0&&(n.addNodeToCache(c[f],!1),c.splice(f,1),d=!0);d&&t.updateLastCacheModificationPerId(u)}),n}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=this.cache.get(t);return n?n.some(function(i){return r.isAssignableFrom(i.type)}):!1}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=this.cache.get(t);if(!n)return null;var i=n.filter(function(a){return r.isAssignableFrom(a.type)});switch(i.length){case 0:return null;case 1:return i[0];default:throw g("Cannot resolve a reference to type '"+r.name+"' with id: '"+t+"' unambigously, there are multiple candidates: "+i.map(function(a){return a.path}).join(", "))}}}),e}();function Sn(e,r,t,n,i){var a=Qa(i);if(a){if(a.parent)throw g("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+(r?r.path:"")+"/"+t+"', but it lives already at '"+a.path+"'");return r&&a.setParent(r,t),a}return new H(e,r,t,n,i)}function Xe(e,r,t,n,i){return new qt(e,r,t,n,i)}function Bf(e){return e instanceof qt||e instanceof H}var q;(function(e){e[e.INITIALIZING=0]="INITIALIZING",e[e.CREATED=1]="CREATED",e[e.FINALIZED=2]="FINALIZED",e[e.DETACHING=3]="DETACHING",e[e.DEAD=4]="DEAD"})(q||(q={}));function V(e){return!!(e&&e.$treenode)}function D(e){if(!V(e))throw g("Value "+e+" is no MST Node");return e.$treenode}function Qa(e){return e&&e.$treenode||null}function Gf(){return D(this).snapshot}function $f(e,r,t){t===void 0&&(t=!0);for(var n=e,i=0;i<r.length;i++){var a=r[i];if(a===".."){if(n=n.parent,n)continue}else{if(a===".")continue;if(n){if(n instanceof qt)try{var o=n.value;V(o)&&(n=D(o))}catch(c){if(!t)return;throw c}if(n instanceof H){var u=n.getChildType(a);if(u&&(n=n.getChildNode(a),n))continue}}}if(t)throw g("Could not resolve '"+a+"' in path '"+(eo(r.slice(0,i))||"/")+"' while resolving '"+eo(r)+"'");return}return n}function Ka(e){if(!e)return mt;var r=Object.keys(e);if(!r.length)return mt;var t=new Array(r.length);return r.forEach(function(n,i){t[i]=e[n]}),t}var Uf=Object.toString(),mt=Object.freeze([]),yt=Object.freeze({}),Er=uc().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Er);function g(e){return e===void 0&&(e="Illegal state"),new Error("[mobx-state-tree] "+e)}function Wf(e){return e}var Yf=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function Ha(e){return Array.isArray(e)||ge(e)}function Ja(e){return e?Ha(e)?e:[e]:mt}function Qf(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];for(var n=0;n<r.length;n++){var i=r[n];for(var a in i)e[a]=i[a]}return e}function gt(e){var r;if(e===null||typeof e!="object")return!1;var t=Object.getPrototypeOf(e);return t==null?!0:((r=t.constructor)===null||r===void 0?void 0:r.toString())===Uf}function Xa(e){return e!==null&&typeof e=="object"&&!(e instanceof Date)&&!(e instanceof RegExp)}function $t(e,r){return r===void 0&&(r=!0),e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||r&&e instanceof Date}function Hp(e){return e}function Jp(e){return e}function Kf(e){return typeof e!="function"}function Hf(e,r,t){ie(e)?ba(e,r,t):Object.defineProperty(e,r,t)}function Ze(e,r,t){Hf(e,r,{enumerable:!1,writable:!1,configurable:!0,value:t})}var Jf=function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=this;return t===void 0&&(t=!1),t?this.handlers.unshift(r):this.handlers.push(r),function(){n.unregister(r)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(r){return this.handlers.indexOf(r)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this.handlers.indexOf(r);t>=0&&this.handlers.splice(t,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var n=this.handlers.slice();n.forEach(function(i){return i.apply(void 0,ht(r))})}}),e}(),Za=function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this.eventHandlers&&this.eventHandlers[r];return!!t&&t.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t,n){n===void 0&&(n=!1),this.eventHandlers||(this.eventHandlers={});var i=this.eventHandlers[r];return i||(i=this.eventHandlers[r]=new Jf),i.register(t,n)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=this.eventHandlers&&this.eventHandlers[r];return!!n&&n.has(t)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=this.eventHandlers&&this.eventHandlers[r];n&&n.unregister(t)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(r){this.eventHandlers&&delete this.eventHandlers[r]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(r){for(var t,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var a=this.eventHandlers&&this.eventHandlers[r];a&&(t=a).emit.apply(t,ht(n))}}),e}();function Xf(e){for(var r=new Array(e.length),t=0;t<e.length;t++)r[t]=e[t];return r}function On(e,r){return e.indexOf(r)===0}function Zf(e){console.warn(new Error("[mobx-state-tree] "+e))}function ed(){return typeof process!="undefined"&&process.env&&{}.ENABLE_TYPE_CHECK==="true"}function td(e){if(!("oldValue"in e))throw g("Patches without `oldValue` field cannot be inversed");return[rd(e),nd(e)]}function rd(e){switch(e.op){case"add":return{op:"add",path:e.path,value:e.value};case"remove":return{op:"remove",path:e.path};case"replace":return{op:"replace",path:e.path,value:e.value}}}function nd(e){switch(e.op){case"add":return{op:"remove",path:e.path};case"remove":return{op:"add",path:e.path,value:e.oldValue};case"replace":return{op:"replace",path:e.path,value:e.oldValue}}}function id(e){return typeof e=="number"}function et(e){return id(e)===!0?""+e:e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function ad(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function eo(e){if(e.length===0)return"";var r=function(t){return t.map(et).join("/")};return e[0]==="."||e[0]===".."?r(e):"/"+r(e)}function od(e){var r=e.split("/").map(ad),t=e===""||e==="."||e===".."||On(e,"/")||On(e,"./")||On(e,"../");if(!t)throw g("a json path must be either rooted, empty or relative, but got '"+e+"'");return r[0]===""&&r.shift(),r}var xn=Symbol("$preProcessorFailed"),ud=function(e){M(r,e);function r(t,n,i){var a=e.call(this,i||t.name)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:n}),a}return Object.defineProperty(r.prototype,"flags",{get:function(){return this._subtype.flags|E.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor("+this._subtype.describe()+")"}}),Object.defineProperty(r.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._processors.preProcessor?this._processors.preProcessor.call(null,t):t}}),Object.defineProperty(r.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(t){try{return this.preProcessSnapshot(t)}catch{return xn}}}),Object.defineProperty(r.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._processors.postProcessor?this._processors.postProcessor.call(null,t):t}}),Object.defineProperty(r.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;ld(t.type,this,"create");var i=t.getSnapshot;t.getSnapshot=function(){return n.postProcessSnapshot(i.call(t))},Cd(this._subtype)||(t.getReconciliationType=function(){return n})}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=V(a)?a:this.preProcessSnapshot(a),u=this._subtype.instantiate(t,n,i,o);return this._fixNode(u),u}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=this._subtype.reconcile(t,V(n)?n:this.preProcessSnapshot(n),i,a);return o!==t&&this._fixNode(o),o}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){n===void 0&&(n=!0);var i=this._subtype.getSnapshot(t);return n?this.postProcessSnapshot(i):i}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this.preProcessSnapshotSafe(t);return i===xn?X(n,t,"Failed to preprocess value"):this._subtype.validate(i,n)}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(r.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=Le(t)?this._subtype:V(t)?Ga(t,!1):this.preProcessSnapshotSafe(t);return n===xn?!1:this._subtype.validate(n,[{path:"",type:this._subtype}]).length===0}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._subtype.isAssignableFrom(t)}}),Object.defineProperty(r.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(!(this._subtype instanceof bt))return!1;var i=this.preProcessSnapshot(n);return this._subtype.isMatchingSnapshotId(t,i)}}),r}(Te);function ld(e,r){for(var t,n,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var o=jr(i),u=o.next();!u.done;u=o.next()){var c=u.value;e[c]=r[c].bind(r)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}}function sd(e,r,t){return new ud(e,r,t)}var to="Map.put can only be used to store complex values that have an identifier type attribute";function ro(e,r){var t,n,i=e.getSubTypes();if(i===Wa)return!1;if(i){var a=Ja(i);try{for(var o=jr(a),u=o.next();!u.done;u=o.next()){var c=u.value;if(!ro(c,r))return!1}}catch(d){t={error:d}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}}return e instanceof Ut&&r.push(e),!0}var Fe;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"})(Fe||(Fe={}));var cd=function(e){M(r,e);function r(t){return e.call(this,t,R.ref.enhancer)||this}return Object.defineProperty(r.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.get.call(this,""+t)}}),Object.defineProperty(r.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.has.call(this,""+t)}}),Object.defineProperty(r.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.delete.call(this,""+t)}}),Object.defineProperty(r.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return e.prototype.set.call(this,""+t,n)}}),Object.defineProperty(r.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!t)throw g("Map.put cannot be used to set empty values");if(V(t)){var n=D(t);if(n.identifier===null)throw g(to);return this.set(n.identifier,t),t}else if(Xa(t)){var i=D(this),a=i.type;if(a.identifierMode!==Fe.YES)throw g(to);var o=a.mapIdentifierAttribute,u=t[o];if(!Cn(u)){var c=this.put(a.getChildType().create(t,i.environment));return this.put(Ga(c))}var d=Wt(u);return this.set(d,t),this.get(d)}else throw g("Map.put can only be used to store complex values")}}),r}(pn),Ir=function(e){M(r,e);function r(t,n,i){i===void 0&&(i=[]);var a=e.call(this,t)||this;return Object.defineProperty(a,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:Fe.UNKNOWN}),Object.defineProperty(a,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Map}),Object.defineProperty(a,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),a._determineIdentifierMode(),a.hookInitializers=i,a}return Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new r(this.name,this._subType,n)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this._determineIdentifierMode(),Sn(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===Fe.UNKNOWN){var t=[];if(ro(this._subType,t)){var n=t.reduce(function(i,a){if(!a.identifierAttribute)return i;if(i&&i!==a.identifierAttribute)throw g("The objects in a map should all have the same identifier attribute, expected '"+i+"', but child of type '"+a.name+"' declared attribute '"+a.identifierAttribute+"' as identifier");return a.identifierAttribute},void 0);n?(this.identifierMode=Fe.YES,this.mapIdentifierAttribute=n):this.identifierMode=Fe.NO}}}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){n===void 0&&(n={});var i=t.type._subType,a={};return Object.keys(n).forEach(function(o){a[o]=i.instantiate(t,o,void 0,n[o])}),a}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return new cd(t)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){fa(n,t.unbox);var i=t.type;i.hookInitializers.forEach(function(a){var o=a(n);Object.keys(o).forEach(function(u){var c=o[u],d=Gt(n,u,c);Ze(n,u,d)})}),cn(n,this.willChange),fn(n,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"Map<string, "+this._subType.describe()+">"}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return pa(t.storedValue)}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=t.storedValue.get(""+n);if(!i)throw g("Not a child "+n);return i}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=D(t.object),i=t.name;n.assertWritable({subpath:i});var a=n.type,o=a._subType;switch(t.type){case"update":{var u=t.newValue,c=t.object.get(i);if(u===c)return null;Ee(o,u),t.newValue=o.reconcile(n.getChildNode(i),t.newValue,n,i),a.processIdentifier(i,t.newValue)}break;case"add":Ee(o,t.newValue),t.newValue=o.instantiate(n,i,void 0,t.newValue),a.processIdentifier(i,t.newValue);break}return t}}),Object.defineProperty(r.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(this.identifierMode===Fe.YES&&n instanceof H){var i=n.identifier;if(i!==t)throw g("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+i+"', but expected: '"+t+"'")}}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n={};return t.getChildren().forEach(function(i){n[i.subpath]=i.snapshot}),n}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n={};return Object.keys(t).forEach(function(i){n[i]=t[i].getSnapshot()}),n}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=D(t.object);switch(t.type){case"update":return void n.emitPatch({op:"replace",path:et(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},n);case"add":return void n.emitPatch({op:"add",path:et(t.name),value:t.newValue.snapshot,oldValue:void 0},n);case"delete":var i=t.oldValue.snapshot;return t.oldValue.die(),void n.emitPatch({op:"remove",path:et(t.name),oldValue:i},n)}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){var a=t.storedValue;switch(i.op){case"add":case"replace":a.set(n,i.value);break;case"remove":a.delete(n);break}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){Ee(this,n);var i=t.storedValue,a={};if(Array.from(i.keys()).forEach(function(u){a[u]=!1}),n)for(var o in n)i.set(o,n[o]),a[""+o]=!0;Object.keys(a).forEach(function(u){a[u]===!1&&i.delete(u)})}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this;return gt(t)?Tr(Object.keys(t).map(function(a){return i._subType.validate(t[a],wn(n,a,i._subType))})):X(n,t,"Value is not a plain object")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return yt}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){t.storedValue.delete(n)}}),r}(bt);Ir.prototype.applySnapshot=L(Ir.prototype.applySnapshot);function fd(e){return new Ir("map<string, "+e.name+">",e)}var Dr=function(e){M(r,e);function r(t,n,i){i===void 0&&(i=[]);var a=e.call(this,t)||this;return Object.defineProperty(a,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Array}),Object.defineProperty(a,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),a.hookInitializers=i,a}return Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new r(this.name,this._subType,n)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return Sn(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){n===void 0&&(n=[]);var i=t.type._subType,a={};return n.forEach(function(o,u){var c=""+u;a[c]=i.instantiate(t,c,void 0,o)}),a}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return R.array(Ka(t),Er)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){_e(n).dehancer=t.unbox;var i=t.type;i.hookInitializers.forEach(function(a){var o=a(n);Object.keys(o).forEach(function(u){var c=o[u],d=Gt(n,u,c);Ze(n,u,d)})}),cn(n,this.willChange),fn(n,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType.describe()+"[]"}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.storedValue.slice()}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=Number(n);if(i<t.storedValue.length)return t.storedValue[i];throw g("Not a child: "+n)}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=D(t.object);n.assertWritable({subpath:""+t.index});var i=n.type._subType,a=n.getChildren();switch(t.type){case"update":{if(t.newValue===t.object[t.index])return null;var o=no(n,i,[a[t.index]],[t.newValue],[t.index]);if(!o)return null;t.newValue=o[0]}break;case"splice":{var u=t.index,c=t.removedCount,d=t.added,f=no(n,i,a.slice(u,u+c),d,d.map(function(v,y){return u+y}));if(!f)return null;t.added=f;for(var p=u+c;p<a.length;p++)a[p].setParent(n,""+(p+d.length-c))}break}return t}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.getChildren().map(function(n){return n.snapshot})}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=[];return Object.keys(t).forEach(function(i){n.push(t[i].getSnapshot())}),n}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=D(t.object);switch(t.type){case"update":return void n.emitPatch({op:"replace",path:""+t.index,value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},n);case"splice":for(var i=t.removedCount-1;i>=0;i--)n.emitPatch({op:"remove",path:""+(t.index+i),oldValue:t.removed[i].snapshot},n);for(var i=0;i<t.addedCount;i++)n.emitPatch({op:"add",path:""+(t.index+i),value:n.getChildNode(""+(t.index+i)).snapshot,oldValue:void 0},n);return}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){var a=t.storedValue,o=n==="-"?a.length:Number(n);switch(i.op){case"replace":a[o]=i.value;break;case"add":a.splice(o,0,i.value);break;case"remove":a.splice(o,1);break}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){Ee(this,n);var i=t.storedValue;i.replace(n)}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this;return Ha(t)?Tr(t.map(function(a,o){return i._subType.validate(a,wn(n,""+o,i._subType))})):X(n,t,"Value is not an array")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return mt}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){t.storedValue.splice(Number(n),1)}}),r}(bt);Dr.prototype.applySnapshot=L(Dr.prototype.applySnapshot);function dd(e){return new Dr(e.name+"[]",e)}function no(e,r,t,n,i){for(var a=!0,o=0;;o++){var u=o<=n.length-1,c=t[o],d=u?n[o]:void 0,f=""+i[o];if(Bf(d)&&(d=d.storedValue),!c&&!u)break;if(!u)a=!1,t.splice(o,1),c instanceof H&&c.createObservableInstanceIfNeeded(),c.die(),o--;else if(c)if(io(c,d))t[o]=Pn(r,e,f,d,c);else{for(var v=void 0,y=o;y<t.length;y++)if(io(t[y],d)){v=t.splice(y,1)[0];break}a=!1;var p=Pn(r,e,f,d,v);t.splice(o,0,p)}else{if(V(d)&&D(d).parent===e)throw g("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+e.path+"/"+f+"', but it lives already at '"+D(d).path+"'");a=!1;var p=Pn(r,e,f,d);t.splice(o,0,p)}}return a?null:t}function Pn(e,r,t,n,i){Ee(e,n);function a(){if(V(n)){var u=D(n);if(u.assertAlive(yt),u.parent!==null&&u.parent===r)return u.setParent(r,t),u}return i?e.reconcile(i,n,r,t):e.instantiate(r,t,void 0,n)}var o=a();return i&&i!==o&&(i instanceof H&&i.createObservableInstanceIfNeeded(),i.die()),o}function io(e,r){if(!e.isAlive)return!1;if(V(r)){var t=D(r);return t.isAlive&&t===e}if(e.snapshot===r)return!0;if(!(e instanceof H))return!1;var n=e.getReconciliationType();return e.identifier!==null&&e.identifierAttribute&>(r)&&n.is(r)&&n.isMatchingSnapshotId(e,r)}var ao="preProcessSnapshot",oo="postProcessSnapshot";function pd(){return D(this).toString()}var uo={name:"AnonymousModel",properties:{},initializers:mt};function hd(e){return Object.keys(e).reduce(function(r,t){var n,i,a;if(t in F)throw g("Hook '"+t+"' was defined as property. Hooks should be defined as part of the actions");var o=Object.getOwnPropertyDescriptor(r,t);if("get"in o)throw g("Getters are not supported as properties. Please use views instead");var u=o.value;if(u==null)throw g("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if($t(u))return Object.assign({},r,(n={},n[t]=rt(gd(u),u),n));if(u instanceof Ir)return Object.assign({},r,(i={},i[t]=rt(u,{}),i));if(u instanceof Dr)return Object.assign({},r,(a={},a[t]=rt(u,[]),a));if(Le(u))return r;throw g("Invalid type definition for property '"+t+"', cannot infer a type from a value like '"+u+"' ("+typeof u+")")},e)}var Ut=function(e){M(r,e);function r(t){var n=e.call(this,t.name||uo.name)||this;return Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Object}),Object.defineProperty(n,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(i){return n.cloneAndEnhance({name:i})}}),Object.defineProperty(n,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(i){return n.cloneAndEnhance({properties:i})}}),Object.defineProperty(n,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(i){var a=n.preProcessor;return a?n.cloneAndEnhance({preProcessor:function(o){return a(i(o))}}):n.cloneAndEnhance({preProcessor:i})}}),Object.defineProperty(n,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(i){var a=n.postProcessor;return a?n.cloneAndEnhance({postProcessor:function(o){return i(a(o))}}):n.cloneAndEnhance({postProcessor:i})}}),Object.assign(n,uo,t),n.properties=hd(n.properties),n.properties,n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return Object.defineProperty(r.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=void 0;return this.forAllProps(function(n,i){if(i.flags&E.Identifier){if(t)throw g("Cannot define property '"+n+"' as object identifier, property '"+t+"' is already defined as identifier property");t=n}}),t}}),Object.defineProperty(r.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return new r({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})}}),Object.defineProperty(r.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=function(a){return n.instantiateActions(a,t(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(r.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(!gt(n))throw g("actions initializer should return a plain object containing actions");Object.keys(n).forEach(function(i){if(i===ao)throw g("Cannot define action '"+ao+"', it should be defined using 'type.preProcessSnapshot(fn)' instead");if(i===oo)throw g("Cannot define action '"+oo+"', it should be defined using 'type.postProcessSnapshot(fn)' instead");var a=n[i],o=t[i];if(i in F&&o){var u=a;a=function(){o.apply(null,arguments),u.apply(null,arguments)}}var c=a.$mst_middleware,d=a.bind(n);d.$mst_middleware=c;var f=Gt(t,i,d);n[i]=f,Ze(t,i,f)})}}),Object.defineProperty(r.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;if(typeof t!="function")throw g("You passed an "+typeof t+" to volatile state as an argument, when function is expected");var i=function(a){return n.instantiateVolatileState(a,t(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(r.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(!gt(n))throw g("volatile state initializer should return a plain object containing state");ha(t,n)}}),Object.defineProperty(r.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=function(a){var o=t(a),u=o.actions,c=o.views,d=o.state,f=wf(o,["actions","views","state"]);for(var p in f)throw g("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+p+"'");return d&&n.instantiateVolatileState(a,d),c&&n.instantiateViews(a,c),u&&n.instantiateActions(a,u),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(r.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=function(a){return n.instantiateViews(a,t(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(r.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(!gt(n))throw g("views initializer should return a plain object containing views");Object.getOwnPropertyNames(n).forEach(function(i){var a,o=Object.getOwnPropertyDescriptor(n,i);if("get"in o)ba(t,i,o),va(t,(a={},a[i]=st,a));else if(typeof o.value=="function")Ze(t,i,o.value);else throw g("A view member should either be a function or getter based property")})}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=V(a)?a:this.applySnapshotPreProcessor(a);return Sn(this,t,n,i,o)}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){n===void 0&&(n={});var i=t.type,a={};return i.forAllProps(function(o,u){a[o]=u.instantiate(t,o,void 0,n[o])}),a}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return R.object(t,yt,Er)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){Ze(n,"toString",pd),this.forAllProps(function(i){fa(n,i,t.unbox)}),this.initializers.reduce(function(i,a){return a(i)},n),cn(n,this.willChange),fn(n,this.didChange)}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t,i=D(n.object),a=n.name;i.assertWritable({subpath:a});var o=i.type.properties[a];return o&&(Ee(o,n.newValue),n.newValue=o.reconcile(i.getChildNode(a),n.newValue,i,a)),n}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t,i=D(n.object),a=i.type.properties[n.name];if(!!a){var o=n.oldValue?n.oldValue.snapshot:void 0;i.emitPatch({op:"replace",path:et(n.name),value:n.newValue.snapshot,oldValue:o},i)}}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=[];return this.forAllProps(function(a){i.push(n.getChildNode(t,a))}),i}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(!(n in this.properties))throw g("Not a value property: "+n);var i=_e(t.storedValue,n),a=i.raw();if(!a)throw g("Node not available for property "+n);return a}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this;n===void 0&&(n=!0);var a={};return this.forAllProps(function(o,u){je(t.storedValue,o).reportObserved(),a[o]=i.getChildNode(t,o).snapshot}),n?this.applySnapshotPostProcessor(a):a}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n={};return Object.keys(t).forEach(function(i){n[i]=t[i].getSnapshot()}),this.applySnapshotPostProcessor(n)}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){if(!(i.op==="replace"||i.op==="add"))throw g("object does not support operation "+i.op);t.storedValue[n]=i.value}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this.applySnapshotPreProcessor(n);Ee(this,i),this.forAllProps(function(a){t.storedValue[a]=i[a]})}}),Object.defineProperty(r.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.preProcessor;return n?n.call(null,t):t}}),Object.defineProperty(r.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.postProcessor;return n?n.call(null,t):t}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.properties[t]}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this,a=this.applySnapshotPreProcessor(t);return gt(a)?Tr(this.propertyNames.map(function(o){return i.properties[o].validate(a[o],wn(n,o,i.properties[o]))})):X(n,a,"Value is not a plain object")}}),Object.defineProperty(r.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;this.propertyNames.forEach(function(i){return t(i,n.properties[i])})}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;return"{ "+this.propertyNames.map(function(n){return n+": "+t.properties[n].describe()}).join("; ")+" }"}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return yt}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){t.storedValue[n]=void 0}}),r}(bt);Ut.prototype.applySnapshot=L(Ut.prototype.applySnapshot);function bd(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=typeof e[0]=="string"?e.shift():"AnonymousModel",n=e.shift()||{};return new Ut({name:t,properties:n})}function vd(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=typeof e[0]=="string",n=t?e[0]:"AnonymousModel";return t&&e.shift(),e.reduce(function(i,a){return i.cloneAndEnhance({name:i.name+"_"+a.name,properties:a.properties,initializers:a.initializers,preProcessor:function(o){return a.applySnapshotPreProcessor(i.applySnapshotPreProcessor(o))},postProcessor:function(o){return a.applySnapshotPostProcessor(i.applySnapshotPostProcessor(o))}})}).named(n)}function md(e){return Le(e)&&(e.flags&E.Object)>0}var tt=function(e){M(r,e);function r(t,n,i,a){a===void 0&&(a=Wf);var o=e.call(this,t)||this;return Object.defineProperty(o,"flags",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"checker",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(o,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:a}),o.flags=n,o}return Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return Xe(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.initializer(t)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if($t(t)&&this.checker(t))return J();var i=this.name==="Date"?"Date or a unix milliseconds timestamp":this.name;return X(n,t,"Value is not a "+i)}}),r}(vt),lo=new tt("string",E.String,function(e){return typeof e=="string"}),so=new tt("number",E.Number,function(e){return typeof e=="number"}),yd=new tt("integer",E.Integer,function(e){return Yf(e)}),co=new tt("boolean",E.Boolean,function(e){return typeof e=="boolean"}),fo=new tt("null",E.Null,function(e){return e===null}),po=new tt("undefined",E.Undefined,function(e){return e===void 0}),ho=new tt("Date",E.Date,function(e){return typeof e=="number"||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});ho.getSnapshot=function(e){return e.storedValue.getTime()};var bo=ho;function gd(e){switch(typeof e){case"string":return lo;case"number":return so;case"boolean":return co;case"object":if(e instanceof Date)return bo}throw g("Cannot determine primitive type from value "+e)}function _d(e){return Le(e)&&(e.flags&(E.String|E.Number|E.Integer|E.Boolean|E.Date))>0}var wd=function(e){M(r,e);function r(t){var n=e.call(this,JSON.stringify(t))||this;return Object.defineProperty(n,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Literal}),n.value=t,n}return Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return Xe(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return $t(t)&&t===this.value?J():X(n,t,"Value is not a literal "+JSON.stringify(this.value))}}),r}(vt);function vo(e){return new wd(e)}var Sd=function(e){M(r,e);function r(t,n,i,a){var o=e.call(this,t)||this;return Object.defineProperty(o,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(o,"_message",{enumerable:!0,configurable:!0,writable:!0,value:a}),o}return Object.defineProperty(r.prototype,"flags",{get:function(){return this._subtype.flags|E.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this._subtype.instantiate(t,n,i,a)}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._subtype.isAssignableFrom(t)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this._subtype.validate(t,n);if(i.length>0)return i;var a=V(t)?D(t).snapshot:t;return this._predicate(a)?J():X(n,t,this._message(t))}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this._subtype.reconcile(t,n,i,a)}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),r}(Te);function Od(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=typeof e[0]=="string"?e.shift():Le(e[0])?e[0].name:null,n=e[0],i=e[1],a=e[2]?e[2]:function(o){return"Value does not respect the refinement predicate"};return new Sd(t,n,i,a)}function xd(e,r){var t=typeof e=="string"?r:e,n=Mr.apply(void 0,ht(t.map(function(i){return vo(""+i)})));return typeof e=="string"&&(n.name=e),n}var Pd=function(e){M(r,e);function r(t,n,i){var a=e.call(this,t)||this;return Object.defineProperty(a,"_types",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),i=Ft({eager:!0,dispatcher:void 0},i),a._dispatcher=i.dispatcher,i.eager||(a._eager=!1),a}return Object.defineProperty(r.prototype,"flags",{get:function(){var t=E.Union;return this._types.forEach(function(n){t|=n.flags}),t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._types.some(function(n){return n.isAssignableFrom(t)})}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map(function(t){return t.describe()}).join(" | ")+")"}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=this.determineType(a,void 0);if(!o)throw g("No matching type for union "+this.describe());return o.instantiate(t,n,i,a)}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=this.determineType(n,t.getReconciliationType());if(!o)throw g("No matching type for union "+this.describe());return o.reconcile(t,n,i,a)}}),Object.defineProperty(r.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return this._dispatcher?this._dispatcher(t):n?n.is(t)?n:this._types.filter(function(i){return i!==n}).find(function(i){return i.is(t)}):this._types.find(function(i){return i.is(t)})}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(this._dispatcher)return this._dispatcher(t).validate(t,n);for(var i=[],a=0,o=0;o<this._types.length;o++){var u=this._types[o],c=u.validate(t,n);if(c.length===0){if(this._eager)return J();a++}else i.push(c)}return a===1?J():X(n,t,"No type is applicable for the union").concat(Tr(i))}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),r}(Te);function Mr(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];var n=Le(e)?void 0:e,i=Le(e)?ht([e],r):r,a="("+i.map(function(o){return o.name}).join(" | ")+")";return new Pd(a,i,n)}function Cd(e){return(e.flags&E.Union)>0}var Ad=function(e){M(r,e);function r(t,n,i){var a=e.call(this,t.name)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:i}),a}return Object.defineProperty(r.prototype,"flags",{get:function(){return this._subtype.flags|E.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){if(this.optionalValues.indexOf(a)>=0){var o=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(t,n,i,o)}return this._subtype.instantiate(t,n,i,a)}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this._subtype.reconcile(t,this.optionalValues.indexOf(n)<0&&this._subtype.is(n)?n:this.getDefaultInstanceOrSnapshot(),i,a)}}),Object.defineProperty(r.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=typeof this._defaultValue=="function"?this._defaultValue():this._defaultValue;return typeof this._defaultValue=="function"&&Ee(this,t),t}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return this.optionalValues.indexOf(t)>=0?J():this._subtype.validate(t,n)}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._subtype.isAssignableFrom(t)}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),r}(Te);function jd(e,r){if(typeof r!="function"&&V(r))throw g("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}function rt(e,r,t){return jd(e,r),new Ad(e,r,t||Td)}var Td=[void 0],Ed=rt(po,void 0),Id=rt(fo,null);function mo(e){return Mr(e,Ed)}function Dd(e){return Mr(e,Id)}var Md=function(e){M(r,e);function r(t,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i}return Object.defineProperty(r.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|E.Late},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!this._subType){var n=void 0;try{n=this._definition()}catch(i){if(i instanceof ReferenceError)n=void 0;else throw i}if(t&&n===void 0)throw g("Late type seems to be used too early, the definition (still) returns undefined");n&&(this._subType=n)}return this._subType}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this.getSubType(!0).instantiate(t,n,i,a)}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this.getSubType(!0).reconcile(t,n,i,a)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this.getSubType(!1);return t?t.name:"<uknown late type>"}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this.getSubType(!1);return i?i.validate(t,n):J()}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.getSubType(!1);return n?n.isAssignableFrom(t):!1}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this.getSubType(!1);return t||Wa}}),r}(Te);function Rd(e,r){var t=typeof e=="string"?e:"late("+e.toString()+")",n=typeof e=="string"?r:e;return new Md(t,n)}var yo=function(e){M(r,e);function r(t){var n=e.call(this,t?"frozen("+t.name+")":"frozen")||this;return Object.defineProperty(n,"subType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Frozen}),n}return Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return Xe(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return Kf(t)?this.subType?this.subType.validate(t,n):J():X(n,t,"Value is not serializable and cannot be frozen")}}),r}(vt),go=new yo;function Vd(e){return arguments.length===0?go:Le(e)?new yo(e):rt(go,e)}function kd(e){switch(e){case F.beforeDestroy:return"destroy";case F.beforeDetach:return"detach";default:return}}var zd=function(){function e(r,t){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Cn(r))this.identifier=r;else if(V(r)){var n=D(r);if(!n.identifierAttribute)throw g("Can only store references with a defined identifier attribute.");var i=n.unnormalizedIdentifier;if(i==null)throw g("Can only store references to tree nodes with a defined identifier.");this.identifier=i}else throw g("Can only store references to tree nodes or identifiers, got: '"+r+"'")}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=Wt(this.identifier),n=r.root,i=n.identifierCache.getLastCacheModificationPerId(t);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==i){var a=this.targetType,o=n.identifierCache.resolve(a,t);if(!o)throw new Nd("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+r.path+")");this.resolvedReference={node:o,lastCacheModification:i}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e}(),Nd=function(e){M(r,e);function r(t){var n=e.call(this,t)||this;return Object.setPrototypeOf(n,r.prototype),n}return r}(Error),_o=function(e){M(r,e);function r(t,n){var i=e.call(this,"reference("+t.name+")")||this;return Object.defineProperty(i,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Reference}),i}return Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.targetType.isAssignableFrom(t)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return Cn(t)?J():X(n,t,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(r.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=n.parent;if(!(!o||!o.isAlive)){var u=o.storedValue;!u||this.onInvalidated({cause:t,parent:u,invalidTarget:a?a.storedValue:void 0,invalidId:i,replaceRef:function(c){Ba(n.root.storedValue,{op:"replace",value:c,path:n.path})},removeRef:function(){md(o.type)?this.replaceRef(void 0):Ba(n.root.storedValue,{op:"remove",path:n.path})}})}}}),Object.defineProperty(r.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this,a=this.getValue(t);if(!!a){var o=D(a),u=function(f,p){var v=kd(p);!v||i.fireInvalidated(v,t,n,o)},c=o.registerHook(F.beforeDetach,u),d=o.registerHook(F.beforeDestroy,u);return function(){c(),d()}}}}),Object.defineProperty(r.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){var a=this;if(!!this.onInvalidated){var o;t.registerHook(F.beforeDestroy,function(){o&&o()});var u=function(c){o&&o();var d=t.parent,f=d&&d.storedValue;if(d&&d.isAlive&&f){var p=void 0;i?p=!!i.get(n,f):p=t.root.identifierCache.has(a.targetType,Wt(n)),p?o=a.addTargetNodeWatcher(t,n):c||a.fireInvalidated("invalidSnapshotReference",t,n,null)}};t.state===q.FINALIZED?u(!0):(t.isRoot||t.root.registerHook(F.afterCreationFinalization,function(){t.parent&&t.parent.createObservableInstanceIfNeeded()}),t.registerHook(F.afterAttach,function(){u(!1)}))}}}),r}(vt),Ld=function(e){M(r,e);function r(t,n){return e.call(this,t,n)||this}return Object.defineProperty(r.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!!t.isAlive){var n=t.storedValue;return n.resolvedValue}}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.storedValue;return n.identifier}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=V(a)?xf(a):a,u=new zd(a,this.targetType),c=Xe(this,t,n,i,u);return u.node=c,this.watchTargetNodeForInvalidations(c,o,void 0),c}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){if(!t.isDetaching&&t.type===this){var o=V(n),u=t.storedValue;if(!o&&u.identifier===n||o&&u.resolvedValue===n)return t.setParent(i,a),t}var c=this.instantiate(i,a,void 0,n);return t.die(),c}}),r}(_o),Fd=function(e){M(r,e);function r(t,n,i){var a=e.call(this,t,i)||this;return Object.defineProperty(a,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),a}return Object.defineProperty(r.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!!t.isAlive){var n=this.options.get(t.storedValue,t.parent?t.parent.storedValue:null);return n}}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.storedValue}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=V(a)?this.options.set(a,t?t.storedValue:null):a,u=Xe(this,t,n,i,o);return this.watchTargetNodeForInvalidations(u,o,this.options),u}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=V(n)?this.options.set(n,t?t.storedValue:null):n;if(!t.isDetaching&&t.type===this&&t.storedValue===o)return t.setParent(i,a),t;var u=this.instantiate(i,a,void 0,o);return t.die(),u}}),r}(_o);function wo(e,r){var t=r||void 0,n=r?r.onInvalidated:void 0;return t&&(t.get||t.set)?new Fd(e,{get:t.get,set:t.set},n):new Ld(e,n)}function qd(e,r){var t=wo(e,Ft(Ft({},r),{onInvalidated:function(n){r&&r.onInvalidated&&r.onInvalidated(n),n.removeRef()}}));return r&&r.acceptsUndefined===!1?t:mo(t)}var So=function(e){M(r,e);function r(t,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"validType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Identifier}),i}return Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){if(!t||!(t.type instanceof Ut))throw g("Identifier types can only be instantiated as direct child of a model type");return Xe(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){if(t.storedValue!==n)throw g("Tried to change identifier from '"+t.storedValue+"' to '"+n+"'. Changing identifiers is not allowed.");return t.setParent(i,a),t}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return typeof t!==this.validType?X(n,t,"Value is not a valid "+this.describe()+", expected a "+this.validType):J()}}),r}(vt),Bd=function(e){M(r,e);function r(){var t=e.call(this,"identifier","string")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Identifier}),t}return Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),r}(So),Gd=function(e){M(r,e);function r(){return e.call(this,"identifierNumber","number")||this}return Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.storedValue}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),r}(So),$d=new Bd,Ud=new Gd;function Wt(e){return""+e}function Cn(e){return typeof e=="string"||typeof e=="number"}function Wd(e){return new Yd(e)}var Yd=function(e){M(r,e);function r(t){var n=e.call(this,t.name)||this;return Object.defineProperty(n,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Custom}),n}return Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(this.options.isTargetType(t))return J();var i=this.options.getValidationMessage(t);return i?X(n,t,"Invalid value for type '"+this.name+"': "+i):J()}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.options.toSnapshot(t.storedValue)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=this.options.isTargetType(a)?a:this.options.fromSnapshot(a,t&&t.root.environment);return Xe(this,t,n,i,o)}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=!this.options.isTargetType(n);if(!t.isDetaching){var u=t.type===this&&(o?n===t.snapshot:n===t.storedValue);if(u)return t.setParent(i,a),t}var c=o?this.options.fromSnapshot(n,i.root.environment):n,d=this.instantiate(i,a,void 0,c);return t.die(),d}}),r}(vt),x={enumeration:xd,model:bd,compose:vd,custom:Wd,reference:wo,safeReference:qd,union:Mr,optional:rt,literal:vo,maybe:mo,maybeNull:Dd,refinement:Od,string:lo,boolean:co,number:so,integer:yd,Date:bo,map:fd,array:dd,frozen:Vd,identifier:$d,identifierNumber:Ud,late:Rd,undefined:po,null:fo,snapshotProcessor:sd},oe=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(oe||{});const Oo=x.model({type:x.enumeration("DataSourceType",["postgresql"]),key:x.string,sql:x.string}),xo=x.model("FilterConfigModel_TextInput",{required:x.boolean,default_value:x.string}).actions(e=>({setRequired(r){e.required=r},setDefaultValue(r){e.default_value=r}})),Po=()=>xo.create({required:!1,default_value:""}),Qd=ae(function({config:r}){return l(Y,{children:l(s.Checkbox,{checked:r.default_value,onChange:t=>r.setDefaultValue(t.currentTarget.checked),label:"Default Checked"})})}),Kd=[{label:"2022",value:"YYYY"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],Hd=ae(function({config:r}){return b(Y,{children:[b(s.Group,{children:[l(s.Checkbox,{checked:r.required,onChange:t=>r.setRequired(t.currentTarget.checked),label:"Required"}),l(s.Checkbox,{checked:r.clearable,onChange:t=>r.setClearable(t.currentTarget.checked),label:"Clearable"})]}),l(s.Select,{data:Kd,label:"Display Format",value:r.inputFormat,onChange:r.setInputFormat})]})}),Jd=ae(function({value:r,onChange:t}){const{data:n=[],loading:i}=Be.useRequest(Rn,{refreshDeps:[]},[]),a=h.default.useMemo(()=>Array.from(new Set(n.map(({type:c})=>c))).map(c=>({label:c,value:c})),[n]),o=h.default.useMemo(()=>{const u=n.filter(({type:c})=>c===r.type);return u?u.map(({key:c})=>({label:c,value:c})):[]},[n,r.type]);return b(s.Group,{grow:!0,children:[l(s.Select,{label:"Data Source Type",data:a,sx:{flex:1},disabled:i,value:r.type,onChange:u=>{t({...r,type:u})}}),l(s.Select,{label:"Data Source Key",data:o,sx:{flex:1},disabled:i,value:r.key,onChange:u=>{t({...r,key:u})}})]})});function Xd({data:e}){return e.length===0?l(s.Table,{}):b(s.Table,{children:[l("thead",{children:l("tr",{children:Object.keys(e==null?void 0:e[0]).map(r=>l("th",{children:l(s.Text,{weight:700,color:"#000",children:r})},r))})}),l("tbody",{children:e.slice(0,3).map((r,t)=>l("tr",{children:Object.values(r).map((n,i)=>l("td",{children:l(s.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:l(s.Text,{children:n})})},`${n}--${i}`))},`row-${t}`))}),e.length>3&&l("tfoot",{children:l("tr",{children:l("td",{colSpan:Object.keys(e==null?void 0:e[0]).length,children:b(s.Text,{color:"gray",size:"sm",children:[e.length-3," more row(s) hidden"]})})})})]})}const Zd=ae(function({query:r}){const{data:t=[],loading:n,refresh:i}=Be.useRequest(Nr(r),{refreshDeps:[r]});return b(s.Stack,{my:0,children:[b(s.Group,{position:"apart",children:[l(s.Text,{size:"md",pl:"sm",children:"Fetched Data"}),l(s.Button,{size:"xs",onClick:i,disabled:!r.sql||!r.key,children:"Retry"})]}),b(s.Box,{sx:{position:"relative"},children:[l(s.LoadingOverlay,{visible:n,exitTransitionDuration:0}),l(Xd,{data:t})]})]})}),Co=ae(function({value:r,onChange:t}){return b(s.Stack,{my:0,children:[l(Jd,{value:r,onChange:t}),b(s.Tabs,{defaultValue:"SQL",children:[b(s.Tabs.List,{children:[l(s.Tabs.Tab,{value:"SQL",children:"SQL"}),l(s.Tabs.Tab,{value:"Preview",children:"Preview"}),l(s.Tabs.Tab,{value:"Data",children:"Data"})]}),l(s.Tabs.Panel,{value:"SQL",pt:"sm",children:l(s.Textarea,{autosize:!0,minRows:12,maxRows:24,className:"code-textarea",value:r.sql,onChange:n=>{t({...r,sql:n.currentTarget.value})},placeholder:"SELECT name AS label, id AS value"})}),l(s.Tabs.Panel,{value:"Preview",pt:"sm",children:l(hi,{value:r.sql})}),l(s.Tabs.Panel,{value:"Data",pt:"sm",children:l(Zd,{query:r})})]})]})}),ep=ae(function({config:r}){const t=()=>{r.addStaticOption({label:"",value:""})},n=r.static_options,i=[...n];return b(Y,{children:[l(s.Divider,{label:"Configure options",labelPosition:"center"}),n.length>0&&l(s.MultiSelect,{label:"Default Selection",data:i,value:r.default_value,onChange:r.setDefaultValue}),n.map((a,o)=>b(s.Group,{sx:{position:"relative"},pr:"40px",children:[l(s.TextInput,{label:"Label",required:!0,value:r.static_options[o].label,onChange:u=>{r.static_options[o].setLabel(u.currentTarget.value)},sx:{flexGrow:1}}),l(s.TextInput,{label:"Value",required:!0,value:r.static_options[o].value,onChange:u=>{r.static_options[o].setValue(u.currentTarget.value)},sx:{flexGrow:1}}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r.removeStaticOption(o),sx:{position:"absolute",top:28,right:5},children:l(_.Trash,{size:16})})]})),l(s.Button,{size:"xs",color:"blue",leftIcon:l(_.PlaylistAdd,{size:20}),onClick:t,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),l(s.Divider,{label:"Or fetch options from database",labelPosition:"center"}),l(Co,{value:r.options_query,onChange:r.setOptionsQuery})]})}),tp=ae(function({config:r}){const t=()=>{r.addStaticOption({label:"",value:""})},n=r.static_options,i=[{label:"No default selection",value:""},...n];return b(Y,{children:[l(s.Checkbox,{checked:r.required,onChange:a=>r.setRequired(a.currentTarget.checked),label:"Required"}),l(s.Divider,{label:"Configure options",labelPosition:"center"}),n.length>0&&l(s.Select,{label:"Default Selection",data:i,value:r.default_value,onChange:r.setDefaultValue}),n.map((a,o)=>b(s.Group,{sx:{position:"relative"},pr:"40px",children:[l(s.TextInput,{label:"Label",required:!0,value:r.static_options[o].label,onChange:u=>{r.static_options[o].setLabel(u.currentTarget.value)},sx:{flexGrow:1}}),l(s.TextInput,{label:"Value",required:!0,value:r.static_options[o].value,onChange:u=>{r.static_options[o].setValue(u.currentTarget.value)},sx:{flexGrow:1}}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r.removeStaticOption(o),sx:{position:"absolute",top:28,right:5},children:l(_.Trash,{size:16})})]})),l(s.Button,{size:"xs",color:"blue",leftIcon:l(_.PlaylistAdd,{size:20}),onClick:t,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),l(s.Divider,{label:"Or fetch options from database",labelPosition:"center"}),l(Co,{value:r.options_query,onChange:r.setOptionsQuery})]})}),rp=ae(function({config:r}){return b(Y,{children:[l(s.TextInput,{label:"Default Value",value:r.default_value,onChange:t=>{r.setDefaultValue(t.currentTarget.value)}}),l(s.Checkbox,{checked:r.required,onChange:t=>r.setRequired(t.currentTarget.checked),label:"Required"})]})});function np({label:e,config:{default_value:r,...t},value:n,onChange:i}){return b(s.Box,{children:[l(s.Text,{children:"\xA0"}),l(s.Checkbox,{label:e,checked:n,onChange:a=>i(a.currentTarget.checked),...t})]})}function ip({label:e,config:r,value:t,onChange:n}){return l(Wo.DateRangePicker,{label:e,value:t,onChange:n,icon:l(_.Calendar,{size:16}),sx:{minWidth:"14em"},...r})}function ap({label:e,config:r,value:t,onChange:n}){const i=!!r.options_query.sql,{data:a=[],loading:o}=Be.useRequest(Nr(r.options_query),{refreshDeps:[r.options_query,i]});return l(s.MultiSelect,{label:e,data:i?a:r.static_options,disabled:i?o:!1,value:t,onChange:n,sx:{minWidth:"14em"}})}function op({label:e,config:r,value:t,onChange:n}){const i=!!r.options_query.sql,{data:a=[],loading:o}=Be.useRequest(Nr(r.options_query),{refreshDeps:[r.options_query,i]});return l(s.Select,{label:e,data:i?a:r.static_options,disabled:i?o:!1,value:t,onChange:n})}function up({label:e,config:r,value:t,onChange:n}){return l(s.TextInput,{label:e,value:t,onChange:n,...r})}function lp({type:e,config:r,key:t,...n},i){switch(e){case"select":return l(op,{...n,...i,config:r});case"multi-select":return l(ap,{...n,...i,config:r});case"text-input":return l(up,{...n,...i,config:r});case"date-range":return l(ip,{...n,...i,config:r});case"checkbox":return l(np,{...n,...i,config:r});default:return null}}const Ao=h.default.forwardRef(function({filter:r,...t},n){return l("div",{className:"filter-root",ref:n,children:l(Zt,{children:lp(r,t)})})}),sp=ae(function({filter:r}){const t=r.config.default_value,[n,i]=h.default.useState(t);return h.default.useEffect(()=>{i(t)},[t]),b(s.Box,{sx:{maxWidth:"30em"},children:[l(s.Text,{pb:"md",color:"gray",children:"Preview"}),l(Ao,{filter:r,value:n,onChange:i}),l(s.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),l($e.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(r,null,4)})]})}),cp={select:tp,"multi-select":ep,"text-input":rp,checkbox:Qd,"date-range":Hd},fp=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],dp=ae(function({filter:r,index:t}){const n=h.default.useMemo(()=>cp[r.type],[r.type]);return b(s.SimpleGrid,{cols:2,children:[b(s.Box,{pl:"md",children:[l(s.Text,{pb:"md",color:"gray",children:"Edit"}),b(s.Stack,{sx:{maxWidth:"30em"},children:[l(s.NumberInput,{label:"Placement Order",required:!0,value:r.order,onChange:r.setOrder,hideControls:!0}),l(s.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:r.key,onChange:i=>{r.setKey(i.currentTarget.value)}}),l(s.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:r.label,onChange:i=>{r.setLabel(i.currentTarget.value)}}),l(s.Select,{label:"Widget",data:fp,required:!0,value:r.type,onChange:r.setType}),l(n,{config:r.config,index:t})]})]}),l(sp,{filter:r})]})}),pp=ae(function({model:r}){const t=r.filters.current,n=()=>{const i=W.randomId(),a={id:i,key:i,label:i,order:t.length+1,type:oe.TextInput,config:Po()};r.filters.append(a)};return b(s.Group,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)"},p:0,children:[l(s.Group,{sx:{position:"absolute",top:"16px",right:"16px"},children:l(s.Button,{size:"xs",color:"red",leftIcon:l(_.Recycle,{size:20}),disabled:!r.filters.changed,onClick:r.filters.reset,children:"Revert Changes"})}),l(s.Tabs,{orientation:"vertical",defaultValue:r.filters.firstID,children:b(s.Group,{sx:{height:"100%"},children:[b(s.Stack,{sx:{height:"100%"},children:[l(s.Tabs.List,{position:"left",sx:{flexGrow:1,width:"200px"},children:r.filters.current.map((i,a)=>l(s.Tabs.Tab,{value:i.id,children:i.label},i.id))}),l(s.Button,{size:"xs",color:"blue",leftIcon:l(_.PlaylistAdd,{size:20}),onClick:n,children:"Add a Filter"})]}),l(s.Box,{sx:{flexGrow:1,height:"100%"},children:r.filters.current.map((i,a)=>l(s.Tabs.Panel,{value:i.id,sx:{height:"100%"},children:b(s.Stack,{sx:{height:"100%"},spacing:"sm",children:[l(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"scroll"},children:l(dp,{filter:i,index:a})}),l(s.Group,{position:"right",pt:10,children:l(s.Button,{size:"xs",color:"red",leftIcon:l(_.Trash,{size:20}),onClick:()=>r.filters.remove(a),children:"Delete this filter"})})]})},i.id))})]})})]})});function hp({opened:e,close:r,model:t}){const{freezeLayout:n}=h.default.useContext(be);return h.default.useEffect(()=>{n(e)},[e]),l(s.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:"Filters",trapFocus:!0,onDragStart:i=>{i.stopPropagation()},withCloseButton:!1,children:l(pp,{model:t})})}function bp({mode:e,setMode:r,hasChanges:t,saveChanges:n,revertChanges:i,getCurrentSchema:a,model:o}){const{addPanel:u}=h.default.useContext(Ht),{inLayoutMode:c,inEditMode:d,inUseMode:f}=h.default.useContext(be),[p,v]=h.default.useState(!1),y=()=>v(!0),P=()=>v(!1),[j,I]=h.default.useState(!1),$=()=>I(!0),he=()=>I(!1),[Z,k]=h.default.useState(!1),U=()=>k(!0),ee=()=>k(!1);return b(s.Group,{position:"apart",pt:0,pb:"xs",children:[l(s.Group,{position:"left",children:l(Zl,{mode:e,setMode:r})}),b(s.Group,{position:"right",children:[!f&&l(s.Button,{variant:"default",size:"xs",onClick:u,leftIcon:l(_.PlaylistAdd,{size:20}),children:"Add a Panel"}),d&&l(s.Button,{variant:"default",size:"xs",onClick:$,leftIcon:l(_.Filter,{size:20}),children:"Filters"}),d&&l(s.Button,{variant:"default",size:"xs",onClick:y,leftIcon:l(_.Database,{size:20}),children:"Data Settings"}),!f&&l(s.Button,{variant:"default",size:"xs",onClick:n,disabled:!t,leftIcon:l(_.DeviceFloppy,{size:20}),children:"Save Changes"}),!f&&l(s.Button,{color:"red",size:"xs",disabled:!t,onClick:i,leftIcon:l(_.Recycle,{size:20}),children:"Revert Changes"}),b(s.Menu,{children:[l(s.Menu.Target,{children:l(s.Button,{variant:"default",size:"xs",leftIcon:l(_.Share,{size:20}),children:"Export"})}),b(s.Menu.Dropdown,{children:[l(s.Menu.Item,{disabled:!0,children:"Download Data"}),l(s.Menu.Item,{onClick:U,children:"View Schema"})]})]})]}),l(hp,{opened:j,close:he,model:o}),l(ls,{opened:p,close:P}),l(ss,{opened:Z,close:ee,getCurrentSchema:a})]})}function jo({panel:e,exitFullScreen:r}){return b(s.Stack,{sx:{flexGrow:1,justifyContent:"flex-start"},children:[l(s.Group,{sx:{flexGrow:0},children:l(s.Button,{variant:"default",size:"sm",onClick:r,leftIcon:l(_.ArrowLeft,{size:20}),children:"Exit fullscreen"})}),l(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:l(ir,{...e})})]})}function To(e){const[r,t]=h.default.useState(null),n=h.default.useCallback(u=>{t(u)},[]),i=h.default.useCallback(()=>{t(null)},[]),a=h.default.useMemo(()=>e.find(u=>u.id===r),[r,e]);return{viewPanelInFullScreen:n,exitFullScreen:i,inFullScreen:!!a,fullScreenPanel:a}}function Eo({filters:e,filterValues:r,setFilterValues:t}){const{control:n,handleSubmit:i}=O.useForm({defaultValues:r}),a=h.default.useMemo(()=>C.default.sortBy(e,"order"),[e]);return e.length===0?null:l("form",{onSubmit:i(t),children:b(s.Group,{className:"dashboard-filters",position:"apart",p:"md",mb:"md",noWrap:!0,sx:{boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[l(s.Group,{align:"flex-start",children:a.map(o=>l(O.Controller,{name:o.key,control:n,render:({field:u})=>l(Ao,{filter:o,...u})},o.id))}),l(s.Group,{sx:{alignSelf:"flex-end"},children:l(s.Button,{color:"blue",size:"sm",type:"submit",children:"Submit"})})]})})}function Io(e){const[r,t]=h.default.useState(e.filters),[n,i]=h.default.useState(()=>e.filters.reduce((o,u)=>{var c;return o[u.key]=(c=u.config.default_value)!=null?c:"",o},{}));return{filters:r,setFilters:t,filterValues:n,setFilterValues:i}}const Do=x.model({label:x.string,value:x.string}).actions(e=>({setLabel(r){e.label=r},setValue(r){e.value=r}})),Mo=x.model("FilterConfigModel_Select",{required:x.boolean,default_value:x.string,static_options:x.optional(x.array(Do),[]),options_query:Oo}).actions(e=>({addStaticOption(r){e.static_options.push(r)},removeStaticOption(r){e.static_options.splice(r,1)},setRequired(r){e.required=r},setDefaultValue(r){e.default_value=r},setOptionsQuery(r){e.options_query=r}})),vp=()=>Mo.create({required:!1,default_value:"",static_options:[],options_query:{type:"postgresql",key:"",sql:""}}),Ro=x.model("FilterConfigModel_MultiSelect",{default_value:x.optional(x.array(x.string),[]),static_options:x.optional(x.array(Do),[]),options_query:Oo}).actions(e=>({addStaticOption(r){e.static_options.push(r)},removeStaticOption(r){e.static_options.splice(r,1)},setDefaultValue(r){e.default_value=r},setOptionsQuery(r){e.options_query=r}})),mp=()=>Ro.create({default_value:[],static_options:[],options_query:{type:"postgresql",key:"",sql:""}}),Vo=x.model("FilterConfigModel_Checkbox",{default_value:x.boolean}).actions(e=>({setDefaultValue(r){e.default_value=r}})),yp=()=>Vo.create({default_value:!1}),ko=x.model("FilterConfigModel_DateRange",{required:x.boolean,inputFormat:x.enumeration("DateRangeInputFormat",["YYYY","YYYY-MM","YYYY-MM-DD"]),clearable:x.boolean}).actions(e=>({setRequired(r){e.required=r},setClearable(r){e.clearable=r},setInputFormat(r){e.inputFormat=r}})),gp=()=>ko.create({required:!1,inputFormat:"YYYY-MM-DD",clearable:!1}),zo=x.model("FilterModel",{id:x.identifier,key:x.string,label:x.string,order:x.number,type:x.enumeration("DashboardFilterType",[oe.Select,oe.MultiSelect,oe.TextInput,oe.Checkbox,oe.DateRange]),config:x.union(Mo,Ro,xo,Vo,ko)}).actions(e=>({setKey(r){e.key=r},setLabel(r){e.label=r},setOrder(r){e.order=r},setType(r){switch(r){case oe.Select:e.config=vp();break;case oe.MultiSelect:e.config=mp();break;case oe.TextInput:e.config=Po();break;case oe.Checkbox:e.config=yp();break;case oe.DateRange:e.config=gp();break}e.type=r}})),_p=x.model("FiltersModel",{original:x.optional(x.array(zo),[]),current:x.optional(x.array(zo),[])}).views(e=>({get changed(){return!C.default.isEqual(e.original,e.current)},get firstID(){if(e.current.length!==0)return e.current[0].id}})).actions(e=>({reset(){e.current=C.default.cloneDeep(e.original)},replace(r){e.current=r},append(r){e.current.push(r)},remove(r){e.current.splice(r,1)}})),wp=x.model({id:x.identifier,name:x.string,filters:_p});function Sp({id:e,name:r,filters:t}){return wp.create({id:e,name:r,filters:{original:t,current:t}})}const Op=ae(function({context:r,dashboard:t,update:n,className:i="dashboard",config:a}){We.baseURL!==a.apiBaseURL&&(We.baseURL=a.apiBaseURL);const[o,u]=h.default.useState(!1),[c,d]=h.default.useState(le.Edit),[f,p]=h.default.useState(t.panels),v=h.default.useMemo(()=>Sp(t),[t]),[y,P]=h.default.useState(t.definition.sqlSnippets),[j,I]=h.default.useState(t.definition.queries),{filters:$,setFilters:he,filterValues:Z,setFilterValues:k}=Io(t),U=h.default.useMemo(()=>{if(v.filters.changed)return!0;const ue=Se=>JSON.parse(JSON.stringify(Se));return!C.default.isEqual(ue(f),ue(t.panels))||!C.default.isEqual(y,t.definition.sqlSnippets)?!0:!C.default.isEqual(j,t.definition.queries)},[t,$,f,y,j,v.filters.changed]),ee=async()=>{const ue={...t,filters:[...v.filters.current],panels:f,definition:{sqlSnippets:y,queries:j}};await n(ue)},_t=()=>{he(t.filters),p(t.panels),P(t.definition.sqlSnippets),I(t.definition.queries)},Ap=()=>{const ue=W.randomId(),we={id:ue,layout:{x:0,y:1/0,w:3,h:15},title:`Panel - ${ue}`,description:"<p><br></p>",queryID:"",viz:{type:"table",conf:{}}};p(Se=>[...Se,we])},jp=ue=>{try{const we=f.find(Tn=>Tn.id===ue);if(!we)throw new Error(`[duplicate panel] Can't find a panel by id[${ue}]`);const Se={...we,id:W.randomId(),layout:{...we.layout,x:0,y:1/0}};p(Tn=>[...Tn,Se])}catch(we){console.error(we)}},Tp=ue=>{const we=f.findIndex(Se=>Se.id===ue);p(Se=>(Se.splice(we,1),[...Se]))},Ep=c===le.Edit,An=c===le.Layout,Ip=c===le.Use,Dp=h.default.useMemo(()=>({sqlSnippets:y,setSQLSnippets:P,queries:j,setQueries:I}),[y,P,j,I]),Mp=h.default.useCallback(()=>({panels:f,definition:{sqlSnippets:y,queries:j}}),[y,j,f]),{viewPanelInFullScreen:Rp,exitFullScreen:Vp,inFullScreen:jn,fullScreenPanel:kp}=To(f);return l(Vr.ModalsProvider,{children:l(Ie.Provider,{value:r,children:l(Ye.Provider,{value:Z,children:l(Ht.Provider,{value:{addPanel:Ap,duplidatePanel:jp,removePanelByID:Tp,viewPanelInFullScreen:Rp,inFullScreen:jn},children:l(ce.Provider,{value:Dp,children:b(be.Provider,{value:{layoutFrozen:o,freezeLayout:u,mode:c,inEditMode:Ep,inLayoutMode:An,inUseMode:Ip},children:[jn&&l(jo,{panel:kp,exitFullScreen:Vp}),b(s.Box,{className:i,sx:{position:"relative",display:jn?"none":"block"},children:[l(bp,{mode:c,setMode:d,hasChanges:U,saveChanges:ee,revertChanges:_t,getCurrentSchema:Mp,model:v}),l(Eo,{filters:$,filterValues:Z,setFilterValues:k}),l(di,{panels:f,setPanels:p,isDraggable:An,isResizable:An})]})]})})})})})})}),xp=Rr.WidthProvider(In.default);function Pp({panels:e,className:r="layout",rowHeight:t=10}){return l(xp,{className:`dashboard-layout ${r}`,rowHeight:t,isDraggable:!1,isResizable:!1,children:e.map(({id:n,...i})=>l("div",{"data-grid":i.layout,children:l(ir,{id:n,...i})},n))})}function Cp({context:e,dashboard:r,className:t="dashboard",config:n}){We.baseURL!==n.apiBaseURL&&(We.baseURL=n.apiBaseURL);const{filters:i,filterValues:a,setFilterValues:o}=Io(r),u=h.default.useMemo(()=>({...r.definition,setSQLSnippets:()=>{},setQueries:()=>{}}),[r]),{viewPanelInFullScreen:c,exitFullScreen:d,inFullScreen:f,fullScreenPanel:p}=To(r.panels);return l(Vr.ModalsProvider,{children:l(Ie.Provider,{value:e,children:l(Ye.Provider,{value:a,children:l(Ht.Provider,{value:{addPanel:C.default.noop,duplidatePanel:C.default.noop,removePanelByID:C.default.noop,viewPanelInFullScreen:c,inFullScreen:f},children:l(ce.Provider,{value:u,children:b(be.Provider,{value:{layoutFrozen:!0,freezeLayout:()=>{},mode:le.Use,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},children:[f&&l(jo,{panel:p,exitFullScreen:d}),b(s.Box,{className:t,sx:{display:f?"none":"block"},children:[l(Eo,{filters:i,filterValues:a,setFilterValues:o}),l(Pp,{panels:r.panels})]})]})})})})})})}var No=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(No||{});w.ContextInfoContext=Ie,w.Dashboard=Op,w.DashboardFilterType=No,w.DashboardLayout=di,w.DashboardMode=le,w.DefinitionContext=ce,w.FilterValuesContext=Ye,w.LayoutStateContext=be,w.Panel=ir,w.PanelContext=se,w.ReadOnlyDashboard=Cp,w.initialContextInfoContext=Xo,w.initialFilterValuesContext=ru,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
55
|
+
JSZip uses the library pako released under the MIT license :
|
|
56
|
+
https://github.com/nodeca/pako/blob/main/LICENSE
|
|
57
|
+
*/(function(t,e){(function(r){t.exports=r()})(function(){return function r(s,a,l){function o(g,m){if(!a[g]){if(!s[g]){var p=typeof Ft=="function"&&Ft;if(!m&&p)return p(g,!0);if(i)return i(g,!0);var b=new Error("Cannot find module '"+g+"'");throw b.code="MODULE_NOT_FOUND",b}var h=a[g]={exports:{}};s[g][0].call(h.exports,function(E){var v=s[g][1][E];return o(v||E)},h,h.exports,r,s,a,l)}return a[g].exports}for(var i=typeof Ft=="function"&&Ft,d=0;d<l.length;d++)o(l[d]);return o}({1:[function(r,s,a){var l=r("./utils"),o=r("./support"),i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a.encode=function(d){for(var g,m,p,b,h,E,v,S=[],_=0,z=d.length,I=z,M=l.getTypeOf(d)!=="string";_<d.length;)I=z-_,p=M?(g=d[_++],m=_<z?d[_++]:0,_<z?d[_++]:0):(g=d.charCodeAt(_++),m=_<z?d.charCodeAt(_++):0,_<z?d.charCodeAt(_++):0),b=g>>2,h=(3&g)<<4|m>>4,E=1<I?(15&m)<<2|p>>6:64,v=2<I?63&p:64,S.push(i.charAt(b)+i.charAt(h)+i.charAt(E)+i.charAt(v));return S.join("")},a.decode=function(d){var g,m,p,b,h,E,v=0,S=0,_="data:";if(d.substr(0,_.length)===_)throw new Error("Invalid base64 input, it looks like a data url.");var z,I=3*(d=d.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(d.charAt(d.length-1)===i.charAt(64)&&I--,d.charAt(d.length-2)===i.charAt(64)&&I--,I%1!=0)throw new Error("Invalid base64 input, bad content length.");for(z=o.uint8array?new Uint8Array(0|I):new Array(0|I);v<d.length;)g=i.indexOf(d.charAt(v++))<<2|(b=i.indexOf(d.charAt(v++)))>>4,m=(15&b)<<4|(h=i.indexOf(d.charAt(v++)))>>2,p=(3&h)<<6|(E=i.indexOf(d.charAt(v++))),z[S++]=g,h!==64&&(z[S++]=m),E!==64&&(z[S++]=p);return z}},{"./support":30,"./utils":32}],2:[function(r,s,a){var l=r("./external"),o=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),d=r("./stream/DataLengthProbe");function g(m,p,b,h,E){this.compressedSize=m,this.uncompressedSize=p,this.crc32=b,this.compression=h,this.compressedContent=E}g.prototype={getContentWorker:function(){var m=new o(l.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new d("data_length")),p=this;return m.on("end",function(){if(this.streamInfo.data_length!==p.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),m},getCompressedWorker:function(){return new o(l.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},g.createWorkerFrom=function(m,p,b){return m.pipe(new i).pipe(new d("uncompressedSize")).pipe(p.compressWorker(b)).pipe(new d("compressedSize")).withStreamInfo("compression",p)},s.exports=g},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,s,a){var l=r("./stream/GenericWorker");a.STORE={magic:"\0\0",compressWorker:function(){return new l("STORE compression")},uncompressWorker:function(){return new l("STORE decompression")}},a.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,s,a){var l=r("./utils"),o=function(){for(var i,d=[],g=0;g<256;g++){i=g;for(var m=0;m<8;m++)i=1&i?3988292384^i>>>1:i>>>1;d[g]=i}return d}();s.exports=function(i,d){return i!==void 0&&i.length?l.getTypeOf(i)!=="string"?function(g,m,p,b){var h=o,E=b+p;g^=-1;for(var v=b;v<E;v++)g=g>>>8^h[255&(g^m[v])];return-1^g}(0|d,i,i.length,0):function(g,m,p,b){var h=o,E=b+p;g^=-1;for(var v=b;v<E;v++)g=g>>>8^h[255&(g^m.charCodeAt(v))];return-1^g}(0|d,i,i.length,0):0}},{"./utils":32}],5:[function(r,s,a){a.base64=!1,a.binary=!1,a.dir=!1,a.createFolders=!0,a.date=null,a.compression=null,a.compressionOptions=null,a.comment=null,a.unixPermissions=null,a.dosPermissions=null},{}],6:[function(r,s,a){var l=null;l=typeof Promise<"u"?Promise:r("lie"),s.exports={Promise:l}},{lie:37}],7:[function(r,s,a){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=r("pako"),i=r("./utils"),d=r("./stream/GenericWorker"),g=l?"uint8array":"array";function m(p,b){d.call(this,"FlateWorker/"+p),this._pako=null,this._pakoAction=p,this._pakoOptions=b,this.meta={}}a.magic="\b\0",i.inherits(m,d),m.prototype.processChunk=function(p){this.meta=p.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(g,p.data),!1)},m.prototype.flush=function(){d.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},m.prototype.cleanUp=function(){d.prototype.cleanUp.call(this),this._pako=null},m.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var p=this;this._pako.onData=function(b){p.push({data:b,meta:p.meta})}},a.compressWorker=function(p){return new m("Deflate",p)},a.uncompressWorker=function(){return new m("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,s,a){function l(h,E){var v,S="";for(v=0;v<E;v++)S+=String.fromCharCode(255&h),h>>>=8;return S}function o(h,E,v,S,_,z){var I,M,F=h.file,Y=h.compression,$=z!==g.utf8encode,ee=i.transformTo("string",z(F.name)),G=i.transformTo("string",g.utf8encode(F.name)),ne=F.comment,ce=i.transformTo("string",z(ne)),A=i.transformTo("string",g.utf8encode(ne)),U=G.length!==F.name.length,f=A.length!==ne.length,j="",ge="",H="",y=F.dir,w=F.date,O={crc32:0,compressedSize:0,uncompressedSize:0};E&&!v||(O.crc32=h.crc32,O.compressedSize=h.compressedSize,O.uncompressedSize=h.uncompressedSize);var x=0;E&&(x|=8),$||!U&&!f||(x|=2048);var C=0,R=0;y&&(C|=16),_==="UNIX"?(R=798,C|=function(B,Z){var K=B;return B||(K=Z?16893:33204),(65535&K)<<16}(F.unixPermissions,y)):(R=20,C|=function(B){return 63&(B||0)}(F.dosPermissions)),I=w.getUTCHours(),I<<=6,I|=w.getUTCMinutes(),I<<=5,I|=w.getUTCSeconds()/2,M=w.getUTCFullYear()-1980,M<<=4,M|=w.getUTCMonth()+1,M<<=5,M|=w.getUTCDate(),U&&(ge=l(1,1)+l(m(ee),4)+G,j+="up"+l(ge.length,2)+ge),f&&(H=l(1,1)+l(m(ce),4)+A,j+="uc"+l(H.length,2)+H);var L="";return L+=`
|
|
58
|
+
\0`,L+=l(x,2),L+=Y.magic,L+=l(I,2),L+=l(M,2),L+=l(O.crc32,4),L+=l(O.compressedSize,4),L+=l(O.uncompressedSize,4),L+=l(ee.length,2),L+=l(j.length,2),{fileRecord:p.LOCAL_FILE_HEADER+L+ee+j,dirRecord:p.CENTRAL_FILE_HEADER+l(R,2)+L+l(ce.length,2)+"\0\0\0\0"+l(C,4)+l(S,4)+ee+j+ce}}var i=r("../utils"),d=r("../stream/GenericWorker"),g=r("../utf8"),m=r("../crc32"),p=r("../signature");function b(h,E,v,S){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=E,this.zipPlatform=v,this.encodeFileName=S,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(b,d),b.prototype.push=function(h){var E=h.meta.percent||0,v=this.entriesCount,S=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,d.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:v?(E+100*(v-S-1))/v:100}}))},b.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var E=this.streamFiles&&!h.file.dir;if(E){var v=o(h,E,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},b.prototype.closedSource=function(h){this.accumulate=!1;var E=this.streamFiles&&!h.file.dir,v=o(h,E,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),E)this.push({data:function(S){return p.DATA_DESCRIPTOR+l(S.crc32,4)+l(S.compressedSize,4)+l(S.uncompressedSize,4)}(h),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},b.prototype.flush=function(){for(var h=this.bytesWritten,E=0;E<this.dirRecords.length;E++)this.push({data:this.dirRecords[E],meta:{percent:100}});var v=this.bytesWritten-h,S=function(_,z,I,M,F){var Y=i.transformTo("string",F(M));return p.CENTRAL_DIRECTORY_END+"\0\0\0\0"+l(_,2)+l(_,2)+l(z,4)+l(I,4)+l(Y.length,2)+Y}(this.dirRecords.length,v,h,this.zipComment,this.encodeFileName);this.push({data:S,meta:{percent:100}})},b.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},b.prototype.registerPrevious=function(h){this._sources.push(h);var E=this;return h.on("data",function(v){E.processChunk(v)}),h.on("end",function(){E.closedSource(E.previous.streamInfo),E._sources.length?E.prepareNextSource():E.end()}),h.on("error",function(v){E.error(v)}),this},b.prototype.resume=function(){return!!d.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},b.prototype.error=function(h){var E=this._sources;if(!d.prototype.error.call(this,h))return!1;for(var v=0;v<E.length;v++)try{E[v].error(h)}catch{}return!0},b.prototype.lock=function(){d.prototype.lock.call(this);for(var h=this._sources,E=0;E<h.length;E++)h[E].lock()},s.exports=b},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(r,s,a){var l=r("../compressions"),o=r("./ZipFileWorker");a.generateWorker=function(i,d,g){var m=new o(d.streamFiles,g,d.platform,d.encodeFileName),p=0;try{i.forEach(function(b,h){p++;var E=function(z,I){var M=z||I,F=l[M];if(!F)throw new Error(M+" is not a valid compression method !");return F}(h.options.compression,d.compression),v=h.options.compressionOptions||d.compressionOptions||{},S=h.dir,_=h.date;h._compressWorker(E,v).withStreamInfo("file",{name:b,dir:S,date:_,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(m)}),m.entriesCount=p}catch(b){m.error(b)}return m}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(r,s,a){function l(){if(!(this instanceof l))return new l;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new l;for(var i in this)typeof this[i]!="function"&&(o[i]=this[i]);return o}}(l.prototype=r("./object")).loadAsync=r("./load"),l.support=r("./support"),l.defaults=r("./defaults"),l.version="3.10.1",l.loadAsync=function(o,i){return new l().loadAsync(o,i)},l.external=r("./external"),s.exports=l},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(r,s,a){var l=r("./utils"),o=r("./external"),i=r("./utf8"),d=r("./zipEntries"),g=r("./stream/Crc32Probe"),m=r("./nodejsUtils");function p(b){return new o.Promise(function(h,E){var v=b.decompressed.getContentWorker().pipe(new g);v.on("error",function(S){E(S)}).on("end",function(){v.streamInfo.crc32!==b.decompressed.crc32?E(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}s.exports=function(b,h){var E=this;return h=l.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:i.utf8decode}),m.isNode&&m.isStream(b)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):l.prepareContent("the loaded zip file",b,!0,h.optimizedBinaryString,h.base64).then(function(v){var S=new d(h);return S.load(v),S}).then(function(v){var S=[o.Promise.resolve(v)],_=v.files;if(h.checkCRC32)for(var z=0;z<_.length;z++)S.push(p(_[z]));return o.Promise.all(S)}).then(function(v){for(var S=v.shift(),_=S.files,z=0;z<_.length;z++){var I=_[z],M=I.fileNameStr,F=l.resolve(I.fileNameStr);E.file(F,I.decompressed,{binary:!0,optimizedBinaryString:!0,date:I.date,dir:I.dir,comment:I.fileCommentStr.length?I.fileCommentStr:null,unixPermissions:I.unixPermissions,dosPermissions:I.dosPermissions,createFolders:h.createFolders}),I.dir||(E.file(F).unsafeOriginalName=M)}return S.zipComment.length&&(E.comment=S.zipComment),E})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(r,s,a){var l=r("../utils"),o=r("../stream/GenericWorker");function i(d,g){o.call(this,"Nodejs stream input adapter for "+d),this._upstreamEnded=!1,this._bindStream(g)}l.inherits(i,o),i.prototype._bindStream=function(d){var g=this;(this._stream=d).pause(),d.on("data",function(m){g.push({data:m,meta:{percent:0}})}).on("error",function(m){g.isPaused?this.generatedError=m:g.error(m)}).on("end",function(){g.isPaused?g._upstreamEnded=!0:g.end()})},i.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},i.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},s.exports=i},{"../stream/GenericWorker":28,"../utils":32}],13:[function(r,s,a){var l=r("readable-stream").Readable;function o(i,d,g){l.call(this,d),this._helper=i;var m=this;i.on("data",function(p,b){m.push(p)||m._helper.pause(),g&&g(b)}).on("error",function(p){m.emit("error",p)}).on("end",function(){m.push(null)})}r("../utils").inherits(o,l),o.prototype._read=function(){this._helper.resume()},s.exports=o},{"../utils":32,"readable-stream":16}],14:[function(r,s,a){s.exports={isNode:typeof Buffer<"u",newBufferFrom:function(l,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(l,o);if(typeof l=="number")throw new Error('The "data" argument must not be a number');return new Buffer(l,o)},allocBuffer:function(l){if(Buffer.alloc)return Buffer.alloc(l);var o=new Buffer(l);return o.fill(0),o},isBuffer:function(l){return Buffer.isBuffer(l)},isStream:function(l){return l&&typeof l.on=="function"&&typeof l.pause=="function"&&typeof l.resume=="function"}}},{}],15:[function(r,s,a){function l(F,Y,$){var ee,G=i.getTypeOf(Y),ne=i.extend($||{},m);ne.date=ne.date||new Date,ne.compression!==null&&(ne.compression=ne.compression.toUpperCase()),typeof ne.unixPermissions=="string"&&(ne.unixPermissions=parseInt(ne.unixPermissions,8)),ne.unixPermissions&&16384&ne.unixPermissions&&(ne.dir=!0),ne.dosPermissions&&16&ne.dosPermissions&&(ne.dir=!0),ne.dir&&(F=_(F)),ne.createFolders&&(ee=S(F))&&z.call(this,ee,!0);var ce=G==="string"&&ne.binary===!1&&ne.base64===!1;$&&$.binary!==void 0||(ne.binary=!ce),(Y instanceof p&&Y.uncompressedSize===0||ne.dir||!Y||Y.length===0)&&(ne.base64=!1,ne.binary=!0,Y="",ne.compression="STORE",G="string");var A=null;A=Y instanceof p||Y instanceof d?Y:E.isNode&&E.isStream(Y)?new v(F,Y):i.prepareContent(F,Y,ne.binary,ne.optimizedBinaryString,ne.base64);var U=new b(F,A,ne);this.files[F]=U}var o=r("./utf8"),i=r("./utils"),d=r("./stream/GenericWorker"),g=r("./stream/StreamHelper"),m=r("./defaults"),p=r("./compressedObject"),b=r("./zipObject"),h=r("./generate"),E=r("./nodejsUtils"),v=r("./nodejs/NodejsStreamInputAdapter"),S=function(F){F.slice(-1)==="/"&&(F=F.substring(0,F.length-1));var Y=F.lastIndexOf("/");return 0<Y?F.substring(0,Y):""},_=function(F){return F.slice(-1)!=="/"&&(F+="/"),F},z=function(F,Y){return Y=Y!==void 0?Y:m.createFolders,F=_(F),this.files[F]||l.call(this,F,null,{dir:!0,createFolders:Y}),this.files[F]};function I(F){return Object.prototype.toString.call(F)==="[object RegExp]"}var M={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(F){var Y,$,ee;for(Y in this.files)ee=this.files[Y],($=Y.slice(this.root.length,Y.length))&&Y.slice(0,this.root.length)===this.root&&F($,ee)},filter:function(F){var Y=[];return this.forEach(function($,ee){F($,ee)&&Y.push(ee)}),Y},file:function(F,Y,$){if(arguments.length!==1)return F=this.root+F,l.call(this,F,Y,$),this;if(I(F)){var ee=F;return this.filter(function(ne,ce){return!ce.dir&&ee.test(ne)})}var G=this.files[this.root+F];return G&&!G.dir?G:null},folder:function(F){if(!F)return this;if(I(F))return this.filter(function(G,ne){return ne.dir&&F.test(G)});var Y=this.root+F,$=z.call(this,Y),ee=this.clone();return ee.root=$.name,ee},remove:function(F){F=this.root+F;var Y=this.files[F];if(Y||(F.slice(-1)!=="/"&&(F+="/"),Y=this.files[F]),Y&&!Y.dir)delete this.files[F];else for(var $=this.filter(function(G,ne){return ne.name.slice(0,F.length)===F}),ee=0;ee<$.length;ee++)delete this.files[$[ee].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(F){var Y,$={};try{if(($=i.extend(F||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=$.type.toLowerCase(),$.compression=$.compression.toUpperCase(),$.type==="binarystring"&&($.type="string"),!$.type)throw new Error("No output type specified.");i.checkSupport($.type),$.platform!=="darwin"&&$.platform!=="freebsd"&&$.platform!=="linux"&&$.platform!=="sunos"||($.platform="UNIX"),$.platform==="win32"&&($.platform="DOS");var ee=$.comment||this.comment||"";Y=h.generateWorker(this,$,ee)}catch(G){(Y=new d("error")).error(G)}return new g(Y,$.type||"string",$.mimeType)},generateAsync:function(F,Y){return this.generateInternalStream(F).accumulate(Y)},generateNodeStream:function(F,Y){return(F=F||{}).type||(F.type="nodebuffer"),this.generateInternalStream(F).toNodejsStream(Y)}};s.exports=M},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(r,s,a){s.exports=r("stream")},{stream:void 0}],17:[function(r,s,a){var l=r("./DataReader");function o(i){l.call(this,i);for(var d=0;d<this.data.length;d++)i[d]=255&i[d]}r("../utils").inherits(o,l),o.prototype.byteAt=function(i){return this.data[this.zero+i]},o.prototype.lastIndexOfSignature=function(i){for(var d=i.charCodeAt(0),g=i.charCodeAt(1),m=i.charCodeAt(2),p=i.charCodeAt(3),b=this.length-4;0<=b;--b)if(this.data[b]===d&&this.data[b+1]===g&&this.data[b+2]===m&&this.data[b+3]===p)return b-this.zero;return-1},o.prototype.readAndCheckSignature=function(i){var d=i.charCodeAt(0),g=i.charCodeAt(1),m=i.charCodeAt(2),p=i.charCodeAt(3),b=this.readData(4);return d===b[0]&&g===b[1]&&m===b[2]&&p===b[3]},o.prototype.readData=function(i){if(this.checkOffset(i),i===0)return[];var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},s.exports=o},{"../utils":32,"./DataReader":18}],18:[function(r,s,a){var l=r("../utils");function o(i){this.data=i,this.length=i.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(i){this.checkIndex(this.index+i)},checkIndex:function(i){if(this.length<this.zero+i||i<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+i+"). Corrupted zip ?")},setIndex:function(i){this.checkIndex(i),this.index=i},skip:function(i){this.setIndex(this.index+i)},byteAt:function(){},readInt:function(i){var d,g=0;for(this.checkOffset(i),d=this.index+i-1;d>=this.index;d--)g=(g<<8)+this.byteAt(d);return this.index+=i,g},readString:function(i){return l.transformTo("string",this.readData(i))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},s.exports=o},{"../utils":32}],19:[function(r,s,a){var l=r("./Uint8ArrayReader");function o(i){l.call(this,i)}r("../utils").inherits(o,l),o.prototype.readData=function(i){this.checkOffset(i);var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},s.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,s,a){var l=r("./DataReader");function o(i){l.call(this,i)}r("../utils").inherits(o,l),o.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},o.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},o.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},o.prototype.readData=function(i){this.checkOffset(i);var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},s.exports=o},{"../utils":32,"./DataReader":18}],21:[function(r,s,a){var l=r("./ArrayReader");function o(i){l.call(this,i)}r("../utils").inherits(o,l),o.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var d=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},s.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(r,s,a){var l=r("../utils"),o=r("../support"),i=r("./ArrayReader"),d=r("./StringReader"),g=r("./NodeBufferReader"),m=r("./Uint8ArrayReader");s.exports=function(p){var b=l.getTypeOf(p);return l.checkSupport(b),b!=="string"||o.uint8array?b==="nodebuffer"?new g(p):o.uint8array?new m(l.transformTo("uint8array",p)):new i(l.transformTo("array",p)):new d(p)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,s,a){a.LOCAL_FILE_HEADER="PK",a.CENTRAL_FILE_HEADER="PK",a.CENTRAL_DIRECTORY_END="PK",a.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",a.ZIP64_CENTRAL_DIRECTORY_END="PK",a.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,s,a){var l=r("./GenericWorker"),o=r("../utils");function i(d){l.call(this,"ConvertWorker to "+d),this.destType=d}o.inherits(i,l),i.prototype.processChunk=function(d){this.push({data:o.transformTo(this.destType,d.data),meta:d.meta})},s.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(r,s,a){var l=r("./GenericWorker"),o=r("../crc32");function i(){l.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(i,l),i.prototype.processChunk=function(d){this.streamInfo.crc32=o(d.data,this.streamInfo.crc32||0),this.push(d)},s.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,s,a){var l=r("../utils"),o=r("./GenericWorker");function i(d){o.call(this,"DataLengthProbe for "+d),this.propName=d,this.withStreamInfo(d,0)}l.inherits(i,o),i.prototype.processChunk=function(d){if(d){var g=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=g+d.data.length}o.prototype.processChunk.call(this,d)},s.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(r,s,a){var l=r("../utils"),o=r("./GenericWorker");function i(d){o.call(this,"DataWorker");var g=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,d.then(function(m){g.dataIsReady=!0,g.data=m,g.max=m&&m.length||0,g.type=l.getTypeOf(m),g.isPaused||g._tickAndRepeat()},function(m){g.error(m)})}l.inherits(i,o),i.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,l.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(l.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var d=null,g=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":d=this.data.substring(this.index,g);break;case"uint8array":d=this.data.subarray(this.index,g);break;case"array":case"nodebuffer":d=this.data.slice(this.index,g)}return this.index=g,this.push({data:d,meta:{percent:this.max?this.index/this.max*100:0}})},s.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(r,s,a){function l(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}l.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,i){return this._listeners[o].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,i){if(this._listeners[o])for(var d=0;d<this._listeners[o].length;d++)this._listeners[o][d].call(this,i)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var i=this;return o.on("data",function(d){i.processChunk(d)}),o.on("end",function(){i.end()}),o.on("error",function(d){i.error(d)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,i){return this.extraStreamInfo[o]=i,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},s.exports=l},{}],29:[function(r,s,a){var l=r("../utils"),o=r("./ConvertWorker"),i=r("./GenericWorker"),d=r("../base64"),g=r("../support"),m=r("../external"),p=null;if(g.nodestream)try{p=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function b(E,v){return new m.Promise(function(S,_){var z=[],I=E._internalType,M=E._outputType,F=E._mimeType;E.on("data",function(Y,$){z.push(Y),v&&v($)}).on("error",function(Y){z=[],_(Y)}).on("end",function(){try{var Y=function($,ee,G){switch($){case"blob":return l.newBlob(l.transformTo("arraybuffer",ee),G);case"base64":return d.encode(ee);default:return l.transformTo($,ee)}}(M,function($,ee){var G,ne=0,ce=null,A=0;for(G=0;G<ee.length;G++)A+=ee[G].length;switch($){case"string":return ee.join("");case"array":return Array.prototype.concat.apply([],ee);case"uint8array":for(ce=new Uint8Array(A),G=0;G<ee.length;G++)ce.set(ee[G],ne),ne+=ee[G].length;return ce;case"nodebuffer":return Buffer.concat(ee);default:throw new Error("concat : unsupported type '"+$+"'")}}(I,z),F);S(Y)}catch($){_($)}z=[]}).resume()})}function h(E,v,S){var _=v;switch(v){case"blob":case"arraybuffer":_="uint8array";break;case"base64":_="string"}try{this._internalType=_,this._outputType=v,this._mimeType=S,l.checkSupport(_),this._worker=E.pipe(new o(_)),E.lock()}catch(z){this._worker=new i("error"),this._worker.error(z)}}h.prototype={accumulate:function(E){return b(this,E)},on:function(E,v){var S=this;return E==="data"?this._worker.on(E,function(_){v.call(S,_.data,_.meta)}):this._worker.on(E,function(){l.delay(v,arguments,S)}),this},resume:function(){return l.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(E){if(l.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new p(this,{objectMode:this._outputType!=="nodebuffer"},E)}},s.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(r,s,a){if(a.base64=!0,a.array=!0,a.string=!0,a.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",a.nodebuffer=typeof Buffer<"u",a.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")a.blob=!1;else{var l=new ArrayBuffer(0);try{a.blob=new Blob([l],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(l),a.blob=o.getBlob("application/zip").size===0}catch{a.blob=!1}}}try{a.nodestream=!!r("readable-stream").Readable}catch{a.nodestream=!1}},{"readable-stream":16}],31:[function(r,s,a){for(var l=r("./utils"),o=r("./support"),i=r("./nodejsUtils"),d=r("./stream/GenericWorker"),g=new Array(256),m=0;m<256;m++)g[m]=252<=m?6:248<=m?5:240<=m?4:224<=m?3:192<=m?2:1;g[254]=g[254]=1;function p(){d.call(this,"utf-8 decode"),this.leftOver=null}function b(){d.call(this,"utf-8 encode")}a.utf8encode=function(h){return o.nodebuffer?i.newBufferFrom(h,"utf-8"):function(E){var v,S,_,z,I,M=E.length,F=0;for(z=0;z<M;z++)(64512&(S=E.charCodeAt(z)))==55296&&z+1<M&&(64512&(_=E.charCodeAt(z+1)))==56320&&(S=65536+(S-55296<<10)+(_-56320),z++),F+=S<128?1:S<2048?2:S<65536?3:4;for(v=o.uint8array?new Uint8Array(F):new Array(F),z=I=0;I<F;z++)(64512&(S=E.charCodeAt(z)))==55296&&z+1<M&&(64512&(_=E.charCodeAt(z+1)))==56320&&(S=65536+(S-55296<<10)+(_-56320),z++),S<128?v[I++]=S:(S<2048?v[I++]=192|S>>>6:(S<65536?v[I++]=224|S>>>12:(v[I++]=240|S>>>18,v[I++]=128|S>>>12&63),v[I++]=128|S>>>6&63),v[I++]=128|63&S);return v}(h)},a.utf8decode=function(h){return o.nodebuffer?l.transformTo("nodebuffer",h).toString("utf-8"):function(E){var v,S,_,z,I=E.length,M=new Array(2*I);for(v=S=0;v<I;)if((_=E[v++])<128)M[S++]=_;else if(4<(z=g[_]))M[S++]=65533,v+=z-1;else{for(_&=z===2?31:z===3?15:7;1<z&&v<I;)_=_<<6|63&E[v++],z--;1<z?M[S++]=65533:_<65536?M[S++]=_:(_-=65536,M[S++]=55296|_>>10&1023,M[S++]=56320|1023&_)}return M.length!==S&&(M.subarray?M=M.subarray(0,S):M.length=S),l.applyFromCharCode(M)}(h=l.transformTo(o.uint8array?"uint8array":"array",h))},l.inherits(p,d),p.prototype.processChunk=function(h){var E=l.transformTo(o.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var v=E;(E=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),E.set(v,this.leftOver.length)}else E=this.leftOver.concat(E);this.leftOver=null}var S=function(z,I){var M;for((I=I||z.length)>z.length&&(I=z.length),M=I-1;0<=M&&(192&z[M])==128;)M--;return M<0||M===0?I:M+g[z[M]]>I?M:I}(E),_=E;S!==E.length&&(o.uint8array?(_=E.subarray(0,S),this.leftOver=E.subarray(S,E.length)):(_=E.slice(0,S),this.leftOver=E.slice(S,E.length))),this.push({data:a.utf8decode(_),meta:h.meta})},p.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:a.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},a.Utf8DecodeWorker=p,l.inherits(b,d),b.prototype.processChunk=function(h){this.push({data:a.utf8encode(h.data),meta:h.meta})},a.Utf8EncodeWorker=b},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,s,a){var l=r("./support"),o=r("./base64"),i=r("./nodejsUtils"),d=r("./external");function g(v){return v}function m(v,S){for(var _=0;_<v.length;++_)S[_]=255&v.charCodeAt(_);return S}r("setimmediate"),a.newBlob=function(v,S){a.checkSupport("blob");try{return new Blob([v],{type:S})}catch{try{var _=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return _.append(v),_.getBlob(S)}catch{throw new Error("Bug : can't construct the Blob.")}}};var p={stringifyByChunk:function(v,S,_){var z=[],I=0,M=v.length;if(M<=_)return String.fromCharCode.apply(null,v);for(;I<M;)S==="array"||S==="nodebuffer"?z.push(String.fromCharCode.apply(null,v.slice(I,Math.min(I+_,M)))):z.push(String.fromCharCode.apply(null,v.subarray(I,Math.min(I+_,M)))),I+=_;return z.join("")},stringifyByChar:function(v){for(var S="",_=0;_<v.length;_++)S+=String.fromCharCode(v[_]);return S},applyCanBeUsed:{uint8array:function(){try{return l.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return l.nodebuffer&&String.fromCharCode.apply(null,i.allocBuffer(1)).length===1}catch{return!1}}()}};function b(v){var S=65536,_=a.getTypeOf(v),z=!0;if(_==="uint8array"?z=p.applyCanBeUsed.uint8array:_==="nodebuffer"&&(z=p.applyCanBeUsed.nodebuffer),z)for(;1<S;)try{return p.stringifyByChunk(v,_,S)}catch{S=Math.floor(S/2)}return p.stringifyByChar(v)}function h(v,S){for(var _=0;_<v.length;_++)S[_]=v[_];return S}a.applyFromCharCode=b;var E={};E.string={string:g,array:function(v){return m(v,new Array(v.length))},arraybuffer:function(v){return E.string.uint8array(v).buffer},uint8array:function(v){return m(v,new Uint8Array(v.length))},nodebuffer:function(v){return m(v,i.allocBuffer(v.length))}},E.array={string:b,array:g,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return i.newBufferFrom(v)}},E.arraybuffer={string:function(v){return b(new Uint8Array(v))},array:function(v){return h(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:g,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return i.newBufferFrom(new Uint8Array(v))}},E.uint8array={string:b,array:function(v){return h(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:g,nodebuffer:function(v){return i.newBufferFrom(v)}},E.nodebuffer={string:b,array:function(v){return h(v,new Array(v.length))},arraybuffer:function(v){return E.nodebuffer.uint8array(v).buffer},uint8array:function(v){return h(v,new Uint8Array(v.length))},nodebuffer:g},a.transformTo=function(v,S){if(S=S||"",!v)return S;a.checkSupport(v);var _=a.getTypeOf(S);return E[_][v](S)},a.resolve=function(v){for(var S=v.split("/"),_=[],z=0;z<S.length;z++){var I=S[z];I==="."||I===""&&z!==0&&z!==S.length-1||(I===".."?_.pop():_.push(I))}return _.join("/")},a.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":l.nodebuffer&&i.isBuffer(v)?"nodebuffer":l.uint8array&&v instanceof Uint8Array?"uint8array":l.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},a.checkSupport=function(v){if(!l[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},a.MAX_VALUE_16BITS=65535,a.MAX_VALUE_32BITS=-1,a.pretty=function(v){var S,_,z="";for(_=0;_<(v||"").length;_++)z+="\\x"+((S=v.charCodeAt(_))<16?"0":"")+S.toString(16).toUpperCase();return z},a.delay=function(v,S,_){setImmediate(function(){v.apply(_||null,S||[])})},a.inherits=function(v,S){function _(){}_.prototype=S.prototype,v.prototype=new _},a.extend=function(){var v,S,_={};for(v=0;v<arguments.length;v++)for(S in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],S)&&_[S]===void 0&&(_[S]=arguments[v][S]);return _},a.prepareContent=function(v,S,_,z,I){return d.Promise.resolve(S).then(function(M){return l.blob&&(M instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(M))!==-1)&&typeof FileReader<"u"?new d.Promise(function(F,Y){var $=new FileReader;$.onload=function(ee){F(ee.target.result)},$.onerror=function(ee){Y(ee.target.error)},$.readAsArrayBuffer(M)}):M}).then(function(M){var F=a.getTypeOf(M);return F?(F==="arraybuffer"?M=a.transformTo("uint8array",M):F==="string"&&(I?M=o.decode(M):_&&z!==!0&&(M=function(Y){return m(Y,l.uint8array?new Uint8Array(Y.length):new Array(Y.length))}(M))),M):d.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(r,s,a){var l=r("./reader/readerFor"),o=r("./utils"),i=r("./signature"),d=r("./zipEntry"),g=r("./support");function m(p){this.files=[],this.loadOptions=p}m.prototype={checkSignature:function(p){if(!this.reader.readAndCheckSignature(p)){this.reader.index-=4;var b=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(b)+", expected "+o.pretty(p)+")")}},isSignature:function(p,b){var h=this.reader.index;this.reader.setIndex(p);var E=this.reader.readString(4)===b;return this.reader.setIndex(h),E},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var p=this.reader.readData(this.zipCommentLength),b=g.uint8array?"uint8array":"array",h=o.transformTo(b,p);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var p,b,h,E=this.zip64EndOfCentralSize-44;0<E;)p=this.reader.readInt(2),b=this.reader.readInt(4),h=this.reader.readData(b),this.zip64ExtensibleData[p]={id:p,length:b,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var p,b;for(p=0;p<this.files.length;p++)b=this.files[p],this.reader.setIndex(b.localHeaderOffset),this.checkSignature(i.LOCAL_FILE_HEADER),b.readLocalPart(this.reader),b.handleUTF8(),b.processAttributes()},readCentralDir:function(){var p;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(i.CENTRAL_FILE_HEADER);)(p=new d({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(p);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var p=this.reader.lastIndexOfSignature(i.CENTRAL_DIRECTORY_END);if(p<0)throw this.isSignature(0,i.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(p);var b=p;if(this.checkSignature(i.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(p=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(p),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,i.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var E=b-h;if(0<E)this.isSignature(b,i.CENTRAL_FILE_HEADER)||(this.reader.zero=E);else if(E<0)throw new Error("Corrupted zip: missing "+Math.abs(E)+" bytes.")},prepareReader:function(p){this.reader=l(p)},load:function(p){this.prepareReader(p),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},s.exports=m},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(r,s,a){var l=r("./reader/readerFor"),o=r("./utils"),i=r("./compressedObject"),d=r("./crc32"),g=r("./utf8"),m=r("./compressions"),p=r("./support");function b(h,E){this.options=h,this.loadOptions=E}b.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var E,v;if(h.skip(22),this.fileNameLength=h.readInt(2),v=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(v),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((E=function(S){for(var _ in m)if(Object.prototype.hasOwnProperty.call(m,_)&&m[_].magic===S)return m[_];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,E,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var E=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(E),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=l(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var E,v,S,_=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<_;)E=h.readInt(2),v=h.readInt(2),S=h.readData(v),this.extraFields[E]={id:E,length:v,value:S};h.setIndex(_)},handleUTF8:function(){var h=p.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=g.utf8decode(this.fileName),this.fileCommentStr=g.utf8decode(this.fileComment);else{var E=this.findExtraFieldUnicodePath();if(E!==null)this.fileNameStr=E;else{var v=o.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var S=this.findExtraFieldUnicodeComment();if(S!==null)this.fileCommentStr=S;else{var _=o.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(_)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var E=l(h.value);return E.readInt(1)!==1||d(this.fileName)!==E.readInt(4)?null:g.utf8decode(E.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var E=l(h.value);return E.readInt(1)!==1||d(this.fileComment)!==E.readInt(4)?null:g.utf8decode(E.readData(h.length-5))}return null}},s.exports=b},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(r,s,a){function l(E,v,S){this.name=E,this.dir=S.dir,this.date=S.date,this.comment=S.comment,this.unixPermissions=S.unixPermissions,this.dosPermissions=S.dosPermissions,this._data=v,this._dataBinary=S.binary,this.options={compression:S.compression,compressionOptions:S.compressionOptions}}var o=r("./stream/StreamHelper"),i=r("./stream/DataWorker"),d=r("./utf8"),g=r("./compressedObject"),m=r("./stream/GenericWorker");l.prototype={internalStream:function(E){var v=null,S="string";try{if(!E)throw new Error("No output type specified.");var _=(S=E.toLowerCase())==="string"||S==="text";S!=="binarystring"&&S!=="text"||(S="string"),v=this._decompressWorker();var z=!this._dataBinary;z&&!_&&(v=v.pipe(new d.Utf8EncodeWorker)),!z&&_&&(v=v.pipe(new d.Utf8DecodeWorker))}catch(I){(v=new m("error")).error(I)}return new o(v,S,"")},async:function(E,v){return this.internalStream(E).accumulate(v)},nodeStream:function(E,v){return this.internalStream(E||"nodebuffer").toNodejsStream(v)},_compressWorker:function(E,v){if(this._data instanceof g&&this._data.compression.magic===E.magic)return this._data.getCompressedWorker();var S=this._decompressWorker();return this._dataBinary||(S=S.pipe(new d.Utf8EncodeWorker)),g.createWorkerFrom(S,E,v)},_decompressWorker:function(){return this._data instanceof g?this._data.getContentWorker():this._data instanceof m?this._data:new i(this._data)}};for(var p=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],b=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<p.length;h++)l.prototype[p[h]]=b;s.exports=l},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(r,s,a){(function(l){var o,i,d=l.MutationObserver||l.WebKitMutationObserver;if(d){var g=0,m=new d(E),p=l.document.createTextNode("");m.observe(p,{characterData:!0}),o=function(){p.data=g=++g%2}}else if(l.setImmediate||l.MessageChannel===void 0)o="document"in l&&"onreadystatechange"in l.document.createElement("script")?function(){var v=l.document.createElement("script");v.onreadystatechange=function(){E(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},l.document.documentElement.appendChild(v)}:function(){setTimeout(E,0)};else{var b=new l.MessageChannel;b.port1.onmessage=E,o=function(){b.port2.postMessage(0)}}var h=[];function E(){var v,S;i=!0;for(var _=h.length;_;){for(S=h,h=[],v=-1;++v<_;)S[v]();_=h.length}i=!1}s.exports=function(v){h.push(v)!==1||i||o()}}).call(this,typeof Ye<"u"?Ye:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(r,s,a){var l=r("immediate");function o(){}var i={},d=["REJECTED"],g=["FULFILLED"],m=["PENDING"];function p(_){if(typeof _!="function")throw new TypeError("resolver must be a function");this.state=m,this.queue=[],this.outcome=void 0,_!==o&&v(this,_)}function b(_,z,I){this.promise=_,typeof z=="function"&&(this.onFulfilled=z,this.callFulfilled=this.otherCallFulfilled),typeof I=="function"&&(this.onRejected=I,this.callRejected=this.otherCallRejected)}function h(_,z,I){l(function(){var M;try{M=z(I)}catch(F){return i.reject(_,F)}M===_?i.reject(_,new TypeError("Cannot resolve promise with itself")):i.resolve(_,M)})}function E(_){var z=_&&_.then;if(_&&(typeof _=="object"||typeof _=="function")&&typeof z=="function")return function(){z.apply(_,arguments)}}function v(_,z){var I=!1;function M($){I||(I=!0,i.reject(_,$))}function F($){I||(I=!0,i.resolve(_,$))}var Y=S(function(){z(F,M)});Y.status==="error"&&M(Y.value)}function S(_,z){var I={};try{I.value=_(z),I.status="success"}catch(M){I.status="error",I.value=M}return I}(s.exports=p).prototype.finally=function(_){if(typeof _!="function")return this;var z=this.constructor;return this.then(function(I){return z.resolve(_()).then(function(){return I})},function(I){return z.resolve(_()).then(function(){throw I})})},p.prototype.catch=function(_){return this.then(null,_)},p.prototype.then=function(_,z){if(typeof _!="function"&&this.state===g||typeof z!="function"&&this.state===d)return this;var I=new this.constructor(o);return this.state!==m?h(I,this.state===g?_:z,this.outcome):this.queue.push(new b(I,_,z)),I},b.prototype.callFulfilled=function(_){i.resolve(this.promise,_)},b.prototype.otherCallFulfilled=function(_){h(this.promise,this.onFulfilled,_)},b.prototype.callRejected=function(_){i.reject(this.promise,_)},b.prototype.otherCallRejected=function(_){h(this.promise,this.onRejected,_)},i.resolve=function(_,z){var I=S(E,z);if(I.status==="error")return i.reject(_,I.value);var M=I.value;if(M)v(_,M);else{_.state=g,_.outcome=z;for(var F=-1,Y=_.queue.length;++F<Y;)_.queue[F].callFulfilled(z)}return _},i.reject=function(_,z){_.state=d,_.outcome=z;for(var I=-1,M=_.queue.length;++I<M;)_.queue[I].callRejected(z);return _},p.resolve=function(_){return _ instanceof this?_:i.resolve(new this(o),_)},p.reject=function(_){var z=new this(o);return i.reject(z,_)},p.all=function(_){var z=this;if(Object.prototype.toString.call(_)!=="[object Array]")return this.reject(new TypeError("must be an array"));var I=_.length,M=!1;if(!I)return this.resolve([]);for(var F=new Array(I),Y=0,$=-1,ee=new this(o);++$<I;)G(_[$],$);return ee;function G(ne,ce){z.resolve(ne).then(function(A){F[ce]=A,++Y!==I||M||(M=!0,i.resolve(ee,F))},function(A){M||(M=!0,i.reject(ee,A))})}},p.race=function(_){var z=this;if(Object.prototype.toString.call(_)!=="[object Array]")return this.reject(new TypeError("must be an array"));var I=_.length,M=!1;if(!I)return this.resolve([]);for(var F=-1,Y=new this(o);++F<I;)$=_[F],z.resolve($).then(function(ee){M||(M=!0,i.resolve(Y,ee))},function(ee){M||(M=!0,i.reject(Y,ee))});var $;return Y}},{immediate:36}],38:[function(r,s,a){var l={};(0,r("./lib/utils/common").assign)(l,r("./lib/deflate"),r("./lib/inflate"),r("./lib/zlib/constants")),s.exports=l},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(r,s,a){var l=r("./zlib/deflate"),o=r("./utils/common"),i=r("./utils/strings"),d=r("./zlib/messages"),g=r("./zlib/zstream"),m=Object.prototype.toString,p=0,b=-1,h=0,E=8;function v(_){if(!(this instanceof v))return new v(_);this.options=o.assign({level:b,method:E,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},_||{});var z=this.options;z.raw&&0<z.windowBits?z.windowBits=-z.windowBits:z.gzip&&0<z.windowBits&&z.windowBits<16&&(z.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var I=l.deflateInit2(this.strm,z.level,z.method,z.windowBits,z.memLevel,z.strategy);if(I!==p)throw new Error(d[I]);if(z.header&&l.deflateSetHeader(this.strm,z.header),z.dictionary){var M;if(M=typeof z.dictionary=="string"?i.string2buf(z.dictionary):m.call(z.dictionary)==="[object ArrayBuffer]"?new Uint8Array(z.dictionary):z.dictionary,(I=l.deflateSetDictionary(this.strm,M))!==p)throw new Error(d[I]);this._dict_set=!0}}function S(_,z){var I=new v(z);if(I.push(_,!0),I.err)throw I.msg||d[I.err];return I.result}v.prototype.push=function(_,z){var I,M,F=this.strm,Y=this.options.chunkSize;if(this.ended)return!1;M=z===~~z?z:z===!0?4:0,typeof _=="string"?F.input=i.string2buf(_):m.call(_)==="[object ArrayBuffer]"?F.input=new Uint8Array(_):F.input=_,F.next_in=0,F.avail_in=F.input.length;do{if(F.avail_out===0&&(F.output=new o.Buf8(Y),F.next_out=0,F.avail_out=Y),(I=l.deflate(F,M))!==1&&I!==p)return this.onEnd(I),!(this.ended=!0);F.avail_out!==0&&(F.avail_in!==0||M!==4&&M!==2)||(this.options.to==="string"?this.onData(i.buf2binstring(o.shrinkBuf(F.output,F.next_out))):this.onData(o.shrinkBuf(F.output,F.next_out)))}while((0<F.avail_in||F.avail_out===0)&&I!==1);return M===4?(I=l.deflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===p):M!==2||(this.onEnd(p),!(F.avail_out=0))},v.prototype.onData=function(_){this.chunks.push(_)},v.prototype.onEnd=function(_){_===p&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=_,this.msg=this.strm.msg},a.Deflate=v,a.deflate=S,a.deflateRaw=function(_,z){return(z=z||{}).raw=!0,S(_,z)},a.gzip=function(_,z){return(z=z||{}).gzip=!0,S(_,z)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(r,s,a){var l=r("./zlib/inflate"),o=r("./utils/common"),i=r("./utils/strings"),d=r("./zlib/constants"),g=r("./zlib/messages"),m=r("./zlib/zstream"),p=r("./zlib/gzheader"),b=Object.prototype.toString;function h(v){if(!(this instanceof h))return new h(v);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},v||{});var S=this.options;S.raw&&0<=S.windowBits&&S.windowBits<16&&(S.windowBits=-S.windowBits,S.windowBits===0&&(S.windowBits=-15)),!(0<=S.windowBits&&S.windowBits<16)||v&&v.windowBits||(S.windowBits+=32),15<S.windowBits&&S.windowBits<48&&(15&S.windowBits)==0&&(S.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new m,this.strm.avail_out=0;var _=l.inflateInit2(this.strm,S.windowBits);if(_!==d.Z_OK)throw new Error(g[_]);this.header=new p,l.inflateGetHeader(this.strm,this.header)}function E(v,S){var _=new h(S);if(_.push(v,!0),_.err)throw _.msg||g[_.err];return _.result}h.prototype.push=function(v,S){var _,z,I,M,F,Y,$=this.strm,ee=this.options.chunkSize,G=this.options.dictionary,ne=!1;if(this.ended)return!1;z=S===~~S?S:S===!0?d.Z_FINISH:d.Z_NO_FLUSH,typeof v=="string"?$.input=i.binstring2buf(v):b.call(v)==="[object ArrayBuffer]"?$.input=new Uint8Array(v):$.input=v,$.next_in=0,$.avail_in=$.input.length;do{if($.avail_out===0&&($.output=new o.Buf8(ee),$.next_out=0,$.avail_out=ee),(_=l.inflate($,d.Z_NO_FLUSH))===d.Z_NEED_DICT&&G&&(Y=typeof G=="string"?i.string2buf(G):b.call(G)==="[object ArrayBuffer]"?new Uint8Array(G):G,_=l.inflateSetDictionary(this.strm,Y)),_===d.Z_BUF_ERROR&&ne===!0&&(_=d.Z_OK,ne=!1),_!==d.Z_STREAM_END&&_!==d.Z_OK)return this.onEnd(_),!(this.ended=!0);$.next_out&&($.avail_out!==0&&_!==d.Z_STREAM_END&&($.avail_in!==0||z!==d.Z_FINISH&&z!==d.Z_SYNC_FLUSH)||(this.options.to==="string"?(I=i.utf8border($.output,$.next_out),M=$.next_out-I,F=i.buf2string($.output,I),$.next_out=M,$.avail_out=ee-M,M&&o.arraySet($.output,$.output,I,M,0),this.onData(F)):this.onData(o.shrinkBuf($.output,$.next_out)))),$.avail_in===0&&$.avail_out===0&&(ne=!0)}while((0<$.avail_in||$.avail_out===0)&&_!==d.Z_STREAM_END);return _===d.Z_STREAM_END&&(z=d.Z_FINISH),z===d.Z_FINISH?(_=l.inflateEnd(this.strm),this.onEnd(_),this.ended=!0,_===d.Z_OK):z!==d.Z_SYNC_FLUSH||(this.onEnd(d.Z_OK),!($.avail_out=0))},h.prototype.onData=function(v){this.chunks.push(v)},h.prototype.onEnd=function(v){v===d.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},a.Inflate=h,a.inflate=E,a.inflateRaw=function(v,S){return(S=S||{}).raw=!0,E(v,S)},a.ungzip=E},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(r,s,a){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";a.assign=function(d){for(var g=Array.prototype.slice.call(arguments,1);g.length;){var m=g.shift();if(m){if(typeof m!="object")throw new TypeError(m+"must be non-object");for(var p in m)m.hasOwnProperty(p)&&(d[p]=m[p])}}return d},a.shrinkBuf=function(d,g){return d.length===g?d:d.subarray?d.subarray(0,g):(d.length=g,d)};var o={arraySet:function(d,g,m,p,b){if(g.subarray&&d.subarray)d.set(g.subarray(m,m+p),b);else for(var h=0;h<p;h++)d[b+h]=g[m+h]},flattenChunks:function(d){var g,m,p,b,h,E;for(g=p=0,m=d.length;g<m;g++)p+=d[g].length;for(E=new Uint8Array(p),g=b=0,m=d.length;g<m;g++)h=d[g],E.set(h,b),b+=h.length;return E}},i={arraySet:function(d,g,m,p,b){for(var h=0;h<p;h++)d[b+h]=g[m+h]},flattenChunks:function(d){return[].concat.apply([],d)}};a.setTyped=function(d){d?(a.Buf8=Uint8Array,a.Buf16=Uint16Array,a.Buf32=Int32Array,a.assign(a,o)):(a.Buf8=Array,a.Buf16=Array,a.Buf32=Array,a.assign(a,i))},a.setTyped(l)},{}],42:[function(r,s,a){var l=r("./common"),o=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{i=!1}for(var d=new l.Buf8(256),g=0;g<256;g++)d[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;function m(p,b){if(b<65537&&(p.subarray&&i||!p.subarray&&o))return String.fromCharCode.apply(null,l.shrinkBuf(p,b));for(var h="",E=0;E<b;E++)h+=String.fromCharCode(p[E]);return h}d[254]=d[254]=1,a.string2buf=function(p){var b,h,E,v,S,_=p.length,z=0;for(v=0;v<_;v++)(64512&(h=p.charCodeAt(v)))==55296&&v+1<_&&(64512&(E=p.charCodeAt(v+1)))==56320&&(h=65536+(h-55296<<10)+(E-56320),v++),z+=h<128?1:h<2048?2:h<65536?3:4;for(b=new l.Buf8(z),v=S=0;S<z;v++)(64512&(h=p.charCodeAt(v)))==55296&&v+1<_&&(64512&(E=p.charCodeAt(v+1)))==56320&&(h=65536+(h-55296<<10)+(E-56320),v++),h<128?b[S++]=h:(h<2048?b[S++]=192|h>>>6:(h<65536?b[S++]=224|h>>>12:(b[S++]=240|h>>>18,b[S++]=128|h>>>12&63),b[S++]=128|h>>>6&63),b[S++]=128|63&h);return b},a.buf2binstring=function(p){return m(p,p.length)},a.binstring2buf=function(p){for(var b=new l.Buf8(p.length),h=0,E=b.length;h<E;h++)b[h]=p.charCodeAt(h);return b},a.buf2string=function(p,b){var h,E,v,S,_=b||p.length,z=new Array(2*_);for(h=E=0;h<_;)if((v=p[h++])<128)z[E++]=v;else if(4<(S=d[v]))z[E++]=65533,h+=S-1;else{for(v&=S===2?31:S===3?15:7;1<S&&h<_;)v=v<<6|63&p[h++],S--;1<S?z[E++]=65533:v<65536?z[E++]=v:(v-=65536,z[E++]=55296|v>>10&1023,z[E++]=56320|1023&v)}return m(z,E)},a.utf8border=function(p,b){var h;for((b=b||p.length)>p.length&&(b=p.length),h=b-1;0<=h&&(192&p[h])==128;)h--;return h<0||h===0?b:h+d[p[h]]>b?h:b}},{"./common":41}],43:[function(r,s,a){s.exports=function(l,o,i,d){for(var g=65535&l|0,m=l>>>16&65535|0,p=0;i!==0;){for(i-=p=2e3<i?2e3:i;m=m+(g=g+o[d++]|0)|0,--p;);g%=65521,m%=65521}return g|m<<16|0}},{}],44:[function(r,s,a){s.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(r,s,a){var l=function(){for(var o,i=[],d=0;d<256;d++){o=d;for(var g=0;g<8;g++)o=1&o?3988292384^o>>>1:o>>>1;i[d]=o}return i}();s.exports=function(o,i,d,g){var m=l,p=g+d;o^=-1;for(var b=g;b<p;b++)o=o>>>8^m[255&(o^i[b])];return-1^o}},{}],46:[function(r,s,a){var l,o=r("../utils/common"),i=r("./trees"),d=r("./adler32"),g=r("./crc32"),m=r("./messages"),p=0,b=4,h=0,E=-2,v=-1,S=4,_=2,z=8,I=9,M=286,F=30,Y=19,$=2*M+1,ee=15,G=3,ne=258,ce=ne+G+1,A=42,U=113,f=1,j=2,ge=3,H=4;function y(u,Q){return u.msg=m[Q],Q}function w(u){return(u<<1)-(4<u?9:0)}function O(u){for(var Q=u.length;0<=--Q;)u[Q]=0}function x(u){var Q=u.state,V=Q.pending;V>u.avail_out&&(V=u.avail_out),V!==0&&(o.arraySet(u.output,Q.pending_buf,Q.pending_out,V,u.next_out),u.next_out+=V,Q.pending_out+=V,u.total_out+=V,u.avail_out-=V,Q.pending-=V,Q.pending===0&&(Q.pending_out=0))}function C(u,Q){i._tr_flush_block(u,0<=u.block_start?u.block_start:-1,u.strstart-u.block_start,Q),u.block_start=u.strstart,x(u.strm)}function R(u,Q){u.pending_buf[u.pending++]=Q}function L(u,Q){u.pending_buf[u.pending++]=Q>>>8&255,u.pending_buf[u.pending++]=255&Q}function B(u,Q){var V,T,k=u.max_chain_length,P=u.strstart,J=u.prev_length,X=u.nice_match,q=u.strstart>u.w_size-ce?u.strstart-(u.w_size-ce):0,ie=u.window,le=u.w_mask,ae=u.prev,de=u.strstart+ne,Ce=ie[P+J-1],we=ie[P+J];u.prev_length>=u.good_match&&(k>>=2),X>u.lookahead&&(X=u.lookahead);do if(ie[(V=Q)+J]===we&&ie[V+J-1]===Ce&&ie[V]===ie[P]&&ie[++V]===ie[P+1]){P+=2,V++;do;while(ie[++P]===ie[++V]&&ie[++P]===ie[++V]&&ie[++P]===ie[++V]&&ie[++P]===ie[++V]&&ie[++P]===ie[++V]&&ie[++P]===ie[++V]&&ie[++P]===ie[++V]&&ie[++P]===ie[++V]&&P<de);if(T=ne-(de-P),P=de-ne,J<T){if(u.match_start=Q,X<=(J=T))break;Ce=ie[P+J-1],we=ie[P+J]}}while((Q=ae[Q&le])>q&&--k!=0);return J<=u.lookahead?J:u.lookahead}function Z(u){var Q,V,T,k,P,J,X,q,ie,le,ae=u.w_size;do{if(k=u.window_size-u.lookahead-u.strstart,u.strstart>=ae+(ae-ce)){for(o.arraySet(u.window,u.window,ae,ae,0),u.match_start-=ae,u.strstart-=ae,u.block_start-=ae,Q=V=u.hash_size;T=u.head[--Q],u.head[Q]=ae<=T?T-ae:0,--V;);for(Q=V=ae;T=u.prev[--Q],u.prev[Q]=ae<=T?T-ae:0,--V;);k+=ae}if(u.strm.avail_in===0)break;if(J=u.strm,X=u.window,q=u.strstart+u.lookahead,ie=k,le=void 0,le=J.avail_in,ie<le&&(le=ie),V=le===0?0:(J.avail_in-=le,o.arraySet(X,J.input,J.next_in,le,q),J.state.wrap===1?J.adler=d(J.adler,X,le,q):J.state.wrap===2&&(J.adler=g(J.adler,X,le,q)),J.next_in+=le,J.total_in+=le,le),u.lookahead+=V,u.lookahead+u.insert>=G)for(P=u.strstart-u.insert,u.ins_h=u.window[P],u.ins_h=(u.ins_h<<u.hash_shift^u.window[P+1])&u.hash_mask;u.insert&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[P+G-1])&u.hash_mask,u.prev[P&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=P,P++,u.insert--,!(u.lookahead+u.insert<G)););}while(u.lookahead<ce&&u.strm.avail_in!==0)}function K(u,Q){for(var V,T;;){if(u.lookahead<ce){if(Z(u),u.lookahead<ce&&Q===p)return f;if(u.lookahead===0)break}if(V=0,u.lookahead>=G&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+G-1])&u.hash_mask,V=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart),V!==0&&u.strstart-V<=u.w_size-ce&&(u.match_length=B(u,V)),u.match_length>=G)if(T=i._tr_tally(u,u.strstart-u.match_start,u.match_length-G),u.lookahead-=u.match_length,u.match_length<=u.max_lazy_match&&u.lookahead>=G){for(u.match_length--;u.strstart++,u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+G-1])&u.hash_mask,V=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart,--u.match_length!=0;);u.strstart++}else u.strstart+=u.match_length,u.match_length=0,u.ins_h=u.window[u.strstart],u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+1])&u.hash_mask;else T=i._tr_tally(u,0,u.window[u.strstart]),u.lookahead--,u.strstart++;if(T&&(C(u,!1),u.strm.avail_out===0))return f}return u.insert=u.strstart<G-1?u.strstart:G-1,Q===b?(C(u,!0),u.strm.avail_out===0?ge:H):u.last_lit&&(C(u,!1),u.strm.avail_out===0)?f:j}function re(u,Q){for(var V,T,k;;){if(u.lookahead<ce){if(Z(u),u.lookahead<ce&&Q===p)return f;if(u.lookahead===0)break}if(V=0,u.lookahead>=G&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+G-1])&u.hash_mask,V=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart),u.prev_length=u.match_length,u.prev_match=u.match_start,u.match_length=G-1,V!==0&&u.prev_length<u.max_lazy_match&&u.strstart-V<=u.w_size-ce&&(u.match_length=B(u,V),u.match_length<=5&&(u.strategy===1||u.match_length===G&&4096<u.strstart-u.match_start)&&(u.match_length=G-1)),u.prev_length>=G&&u.match_length<=u.prev_length){for(k=u.strstart+u.lookahead-G,T=i._tr_tally(u,u.strstart-1-u.prev_match,u.prev_length-G),u.lookahead-=u.prev_length-1,u.prev_length-=2;++u.strstart<=k&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+G-1])&u.hash_mask,V=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart),--u.prev_length!=0;);if(u.match_available=0,u.match_length=G-1,u.strstart++,T&&(C(u,!1),u.strm.avail_out===0))return f}else if(u.match_available){if((T=i._tr_tally(u,0,u.window[u.strstart-1]))&&C(u,!1),u.strstart++,u.lookahead--,u.strm.avail_out===0)return f}else u.match_available=1,u.strstart++,u.lookahead--}return u.match_available&&(T=i._tr_tally(u,0,u.window[u.strstart-1]),u.match_available=0),u.insert=u.strstart<G-1?u.strstart:G-1,Q===b?(C(u,!0),u.strm.avail_out===0?ge:H):u.last_lit&&(C(u,!1),u.strm.avail_out===0)?f:j}function me(u,Q,V,T,k){this.good_length=u,this.max_lazy=Q,this.nice_length=V,this.max_chain=T,this.func=k}function fe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=z,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*$),this.dyn_dtree=new o.Buf16(2*(2*F+1)),this.bl_tree=new o.Buf16(2*(2*Y+1)),O(this.dyn_ltree),O(this.dyn_dtree),O(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(ee+1),this.heap=new o.Buf16(2*M+1),O(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*M+1),O(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function he(u){var Q;return u&&u.state?(u.total_in=u.total_out=0,u.data_type=_,(Q=u.state).pending=0,Q.pending_out=0,Q.wrap<0&&(Q.wrap=-Q.wrap),Q.status=Q.wrap?A:U,u.adler=Q.wrap===2?0:1,Q.last_flush=p,i._tr_init(Q),h):y(u,E)}function _e(u){var Q=he(u);return Q===h&&function(V){V.window_size=2*V.w_size,O(V.head),V.max_lazy_match=l[V.level].max_lazy,V.good_match=l[V.level].good_length,V.nice_match=l[V.level].nice_length,V.max_chain_length=l[V.level].max_chain,V.strstart=0,V.block_start=0,V.lookahead=0,V.insert=0,V.match_length=V.prev_length=G-1,V.match_available=0,V.ins_h=0}(u.state),Q}function ze(u,Q,V,T,k,P){if(!u)return E;var J=1;if(Q===v&&(Q=6),T<0?(J=0,T=-T):15<T&&(J=2,T-=16),k<1||I<k||V!==z||T<8||15<T||Q<0||9<Q||P<0||S<P)return y(u,E);T===8&&(T=9);var X=new fe;return(u.state=X).strm=u,X.wrap=J,X.gzhead=null,X.w_bits=T,X.w_size=1<<X.w_bits,X.w_mask=X.w_size-1,X.hash_bits=k+7,X.hash_size=1<<X.hash_bits,X.hash_mask=X.hash_size-1,X.hash_shift=~~((X.hash_bits+G-1)/G),X.window=new o.Buf8(2*X.w_size),X.head=new o.Buf16(X.hash_size),X.prev=new o.Buf16(X.w_size),X.lit_bufsize=1<<k+6,X.pending_buf_size=4*X.lit_bufsize,X.pending_buf=new o.Buf8(X.pending_buf_size),X.d_buf=1*X.lit_bufsize,X.l_buf=3*X.lit_bufsize,X.level=Q,X.strategy=P,X.method=V,_e(u)}l=[new me(0,0,0,0,function(u,Q){var V=65535;for(V>u.pending_buf_size-5&&(V=u.pending_buf_size-5);;){if(u.lookahead<=1){if(Z(u),u.lookahead===0&&Q===p)return f;if(u.lookahead===0)break}u.strstart+=u.lookahead,u.lookahead=0;var T=u.block_start+V;if((u.strstart===0||u.strstart>=T)&&(u.lookahead=u.strstart-T,u.strstart=T,C(u,!1),u.strm.avail_out===0)||u.strstart-u.block_start>=u.w_size-ce&&(C(u,!1),u.strm.avail_out===0))return f}return u.insert=0,Q===b?(C(u,!0),u.strm.avail_out===0?ge:H):(u.strstart>u.block_start&&(C(u,!1),u.strm.avail_out),f)}),new me(4,4,8,4,K),new me(4,5,16,8,K),new me(4,6,32,32,K),new me(4,4,16,16,re),new me(8,16,32,32,re),new me(8,16,128,128,re),new me(8,32,128,256,re),new me(32,128,258,1024,re),new me(32,258,258,4096,re)],a.deflateInit=function(u,Q){return ze(u,Q,z,15,8,0)},a.deflateInit2=ze,a.deflateReset=_e,a.deflateResetKeep=he,a.deflateSetHeader=function(u,Q){return u&&u.state?u.state.wrap!==2?E:(u.state.gzhead=Q,h):E},a.deflate=function(u,Q){var V,T,k,P;if(!u||!u.state||5<Q||Q<0)return u?y(u,E):E;if(T=u.state,!u.output||!u.input&&u.avail_in!==0||T.status===666&&Q!==b)return y(u,u.avail_out===0?-5:E);if(T.strm=u,V=T.last_flush,T.last_flush=Q,T.status===A)if(T.wrap===2)u.adler=0,R(T,31),R(T,139),R(T,8),T.gzhead?(R(T,(T.gzhead.text?1:0)+(T.gzhead.hcrc?2:0)+(T.gzhead.extra?4:0)+(T.gzhead.name?8:0)+(T.gzhead.comment?16:0)),R(T,255&T.gzhead.time),R(T,T.gzhead.time>>8&255),R(T,T.gzhead.time>>16&255),R(T,T.gzhead.time>>24&255),R(T,T.level===9?2:2<=T.strategy||T.level<2?4:0),R(T,255&T.gzhead.os),T.gzhead.extra&&T.gzhead.extra.length&&(R(T,255&T.gzhead.extra.length),R(T,T.gzhead.extra.length>>8&255)),T.gzhead.hcrc&&(u.adler=g(u.adler,T.pending_buf,T.pending,0)),T.gzindex=0,T.status=69):(R(T,0),R(T,0),R(T,0),R(T,0),R(T,0),R(T,T.level===9?2:2<=T.strategy||T.level<2?4:0),R(T,3),T.status=U);else{var J=z+(T.w_bits-8<<4)<<8;J|=(2<=T.strategy||T.level<2?0:T.level<6?1:T.level===6?2:3)<<6,T.strstart!==0&&(J|=32),J+=31-J%31,T.status=U,L(T,J),T.strstart!==0&&(L(T,u.adler>>>16),L(T,65535&u.adler)),u.adler=1}if(T.status===69)if(T.gzhead.extra){for(k=T.pending;T.gzindex<(65535&T.gzhead.extra.length)&&(T.pending!==T.pending_buf_size||(T.gzhead.hcrc&&T.pending>k&&(u.adler=g(u.adler,T.pending_buf,T.pending-k,k)),x(u),k=T.pending,T.pending!==T.pending_buf_size));)R(T,255&T.gzhead.extra[T.gzindex]),T.gzindex++;T.gzhead.hcrc&&T.pending>k&&(u.adler=g(u.adler,T.pending_buf,T.pending-k,k)),T.gzindex===T.gzhead.extra.length&&(T.gzindex=0,T.status=73)}else T.status=73;if(T.status===73)if(T.gzhead.name){k=T.pending;do{if(T.pending===T.pending_buf_size&&(T.gzhead.hcrc&&T.pending>k&&(u.adler=g(u.adler,T.pending_buf,T.pending-k,k)),x(u),k=T.pending,T.pending===T.pending_buf_size)){P=1;break}P=T.gzindex<T.gzhead.name.length?255&T.gzhead.name.charCodeAt(T.gzindex++):0,R(T,P)}while(P!==0);T.gzhead.hcrc&&T.pending>k&&(u.adler=g(u.adler,T.pending_buf,T.pending-k,k)),P===0&&(T.gzindex=0,T.status=91)}else T.status=91;if(T.status===91)if(T.gzhead.comment){k=T.pending;do{if(T.pending===T.pending_buf_size&&(T.gzhead.hcrc&&T.pending>k&&(u.adler=g(u.adler,T.pending_buf,T.pending-k,k)),x(u),k=T.pending,T.pending===T.pending_buf_size)){P=1;break}P=T.gzindex<T.gzhead.comment.length?255&T.gzhead.comment.charCodeAt(T.gzindex++):0,R(T,P)}while(P!==0);T.gzhead.hcrc&&T.pending>k&&(u.adler=g(u.adler,T.pending_buf,T.pending-k,k)),P===0&&(T.status=103)}else T.status=103;if(T.status===103&&(T.gzhead.hcrc?(T.pending+2>T.pending_buf_size&&x(u),T.pending+2<=T.pending_buf_size&&(R(T,255&u.adler),R(T,u.adler>>8&255),u.adler=0,T.status=U)):T.status=U),T.pending!==0){if(x(u),u.avail_out===0)return T.last_flush=-1,h}else if(u.avail_in===0&&w(Q)<=w(V)&&Q!==b)return y(u,-5);if(T.status===666&&u.avail_in!==0)return y(u,-5);if(u.avail_in!==0||T.lookahead!==0||Q!==p&&T.status!==666){var X=T.strategy===2?function(q,ie){for(var le;;){if(q.lookahead===0&&(Z(q),q.lookahead===0)){if(ie===p)return f;break}if(q.match_length=0,le=i._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++,le&&(C(q,!1),q.strm.avail_out===0))return f}return q.insert=0,ie===b?(C(q,!0),q.strm.avail_out===0?ge:H):q.last_lit&&(C(q,!1),q.strm.avail_out===0)?f:j}(T,Q):T.strategy===3?function(q,ie){for(var le,ae,de,Ce,we=q.window;;){if(q.lookahead<=ne){if(Z(q),q.lookahead<=ne&&ie===p)return f;if(q.lookahead===0)break}if(q.match_length=0,q.lookahead>=G&&0<q.strstart&&(ae=we[de=q.strstart-1])===we[++de]&&ae===we[++de]&&ae===we[++de]){Ce=q.strstart+ne;do;while(ae===we[++de]&&ae===we[++de]&&ae===we[++de]&&ae===we[++de]&&ae===we[++de]&&ae===we[++de]&&ae===we[++de]&&ae===we[++de]&&de<Ce);q.match_length=ne-(Ce-de),q.match_length>q.lookahead&&(q.match_length=q.lookahead)}if(q.match_length>=G?(le=i._tr_tally(q,1,q.match_length-G),q.lookahead-=q.match_length,q.strstart+=q.match_length,q.match_length=0):(le=i._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++),le&&(C(q,!1),q.strm.avail_out===0))return f}return q.insert=0,ie===b?(C(q,!0),q.strm.avail_out===0?ge:H):q.last_lit&&(C(q,!1),q.strm.avail_out===0)?f:j}(T,Q):l[T.level].func(T,Q);if(X!==ge&&X!==H||(T.status=666),X===f||X===ge)return u.avail_out===0&&(T.last_flush=-1),h;if(X===j&&(Q===1?i._tr_align(T):Q!==5&&(i._tr_stored_block(T,0,0,!1),Q===3&&(O(T.head),T.lookahead===0&&(T.strstart=0,T.block_start=0,T.insert=0))),x(u),u.avail_out===0))return T.last_flush=-1,h}return Q!==b?h:T.wrap<=0?1:(T.wrap===2?(R(T,255&u.adler),R(T,u.adler>>8&255),R(T,u.adler>>16&255),R(T,u.adler>>24&255),R(T,255&u.total_in),R(T,u.total_in>>8&255),R(T,u.total_in>>16&255),R(T,u.total_in>>24&255)):(L(T,u.adler>>>16),L(T,65535&u.adler)),x(u),0<T.wrap&&(T.wrap=-T.wrap),T.pending!==0?h:1)},a.deflateEnd=function(u){var Q;return u&&u.state?(Q=u.state.status)!==A&&Q!==69&&Q!==73&&Q!==91&&Q!==103&&Q!==U&&Q!==666?y(u,E):(u.state=null,Q===U?y(u,-3):h):E},a.deflateSetDictionary=function(u,Q){var V,T,k,P,J,X,q,ie,le=Q.length;if(!u||!u.state||(P=(V=u.state).wrap)===2||P===1&&V.status!==A||V.lookahead)return E;for(P===1&&(u.adler=d(u.adler,Q,le,0)),V.wrap=0,le>=V.w_size&&(P===0&&(O(V.head),V.strstart=0,V.block_start=0,V.insert=0),ie=new o.Buf8(V.w_size),o.arraySet(ie,Q,le-V.w_size,V.w_size,0),Q=ie,le=V.w_size),J=u.avail_in,X=u.next_in,q=u.input,u.avail_in=le,u.next_in=0,u.input=Q,Z(V);V.lookahead>=G;){for(T=V.strstart,k=V.lookahead-(G-1);V.ins_h=(V.ins_h<<V.hash_shift^V.window[T+G-1])&V.hash_mask,V.prev[T&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=T,T++,--k;);V.strstart=T,V.lookahead=G-1,Z(V)}return V.strstart+=V.lookahead,V.block_start=V.strstart,V.insert=V.lookahead,V.lookahead=0,V.match_length=V.prev_length=G-1,V.match_available=0,u.next_in=X,u.input=q,u.avail_in=J,V.wrap=P,h},a.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(r,s,a){s.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(r,s,a){s.exports=function(l,o){var i,d,g,m,p,b,h,E,v,S,_,z,I,M,F,Y,$,ee,G,ne,ce,A,U,f,j;i=l.state,d=l.next_in,f=l.input,g=d+(l.avail_in-5),m=l.next_out,j=l.output,p=m-(o-l.avail_out),b=m+(l.avail_out-257),h=i.dmax,E=i.wsize,v=i.whave,S=i.wnext,_=i.window,z=i.hold,I=i.bits,M=i.lencode,F=i.distcode,Y=(1<<i.lenbits)-1,$=(1<<i.distbits)-1;e:do{I<15&&(z+=f[d++]<<I,I+=8,z+=f[d++]<<I,I+=8),ee=M[z&Y];t:for(;;){if(z>>>=G=ee>>>24,I-=G,(G=ee>>>16&255)===0)j[m++]=65535ⅇelse{if(!(16&G)){if((64&G)==0){ee=M[(65535&ee)+(z&(1<<G)-1)];continue t}if(32&G){i.mode=12;break e}l.msg="invalid literal/length code",i.mode=30;break e}ne=65535&ee,(G&=15)&&(I<G&&(z+=f[d++]<<I,I+=8),ne+=z&(1<<G)-1,z>>>=G,I-=G),I<15&&(z+=f[d++]<<I,I+=8,z+=f[d++]<<I,I+=8),ee=F[z&$];r:for(;;){if(z>>>=G=ee>>>24,I-=G,!(16&(G=ee>>>16&255))){if((64&G)==0){ee=F[(65535&ee)+(z&(1<<G)-1)];continue r}l.msg="invalid distance code",i.mode=30;break e}if(ce=65535&ee,I<(G&=15)&&(z+=f[d++]<<I,(I+=8)<G&&(z+=f[d++]<<I,I+=8)),h<(ce+=z&(1<<G)-1)){l.msg="invalid distance too far back",i.mode=30;break e}if(z>>>=G,I-=G,(G=m-p)<ce){if(v<(G=ce-G)&&i.sane){l.msg="invalid distance too far back",i.mode=30;break e}if(U=_,(A=0)===S){if(A+=E-G,G<ne){for(ne-=G;j[m++]=_[A++],--G;);A=m-ce,U=j}}else if(S<G){if(A+=E+S-G,(G-=S)<ne){for(ne-=G;j[m++]=_[A++],--G;);if(A=0,S<ne){for(ne-=G=S;j[m++]=_[A++],--G;);A=m-ce,U=j}}}else if(A+=S-G,G<ne){for(ne-=G;j[m++]=_[A++],--G;);A=m-ce,U=j}for(;2<ne;)j[m++]=U[A++],j[m++]=U[A++],j[m++]=U[A++],ne-=3;ne&&(j[m++]=U[A++],1<ne&&(j[m++]=U[A++]))}else{for(A=m-ce;j[m++]=j[A++],j[m++]=j[A++],j[m++]=j[A++],2<(ne-=3););ne&&(j[m++]=j[A++],1<ne&&(j[m++]=j[A++]))}break}}break}}while(d<g&&m<b);d-=ne=I>>3,z&=(1<<(I-=ne<<3))-1,l.next_in=d,l.next_out=m,l.avail_in=d<g?g-d+5:5-(d-g),l.avail_out=m<b?b-m+257:257-(m-b),i.hold=z,i.bits=I}},{}],49:[function(r,s,a){var l=r("../utils/common"),o=r("./adler32"),i=r("./crc32"),d=r("./inffast"),g=r("./inftrees"),m=1,p=2,b=0,h=-2,E=1,v=852,S=592;function _(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function z(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new l.Buf16(320),this.work=new l.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function I(A){var U;return A&&A.state?(U=A.state,A.total_in=A.total_out=U.total=0,A.msg="",U.wrap&&(A.adler=1&U.wrap),U.mode=E,U.last=0,U.havedict=0,U.dmax=32768,U.head=null,U.hold=0,U.bits=0,U.lencode=U.lendyn=new l.Buf32(v),U.distcode=U.distdyn=new l.Buf32(S),U.sane=1,U.back=-1,b):h}function M(A){var U;return A&&A.state?((U=A.state).wsize=0,U.whave=0,U.wnext=0,I(A)):h}function F(A,U){var f,j;return A&&A.state?(j=A.state,U<0?(f=0,U=-U):(f=1+(U>>4),U<48&&(U&=15)),U&&(U<8||15<U)?h:(j.window!==null&&j.wbits!==U&&(j.window=null),j.wrap=f,j.wbits=U,M(A))):h}function Y(A,U){var f,j;return A?(j=new z,(A.state=j).window=null,(f=F(A,U))!==b&&(A.state=null),f):h}var $,ee,G=!0;function ne(A){if(G){var U;for($=new l.Buf32(512),ee=new l.Buf32(32),U=0;U<144;)A.lens[U++]=8;for(;U<256;)A.lens[U++]=9;for(;U<280;)A.lens[U++]=7;for(;U<288;)A.lens[U++]=8;for(g(m,A.lens,0,288,$,0,A.work,{bits:9}),U=0;U<32;)A.lens[U++]=5;g(p,A.lens,0,32,ee,0,A.work,{bits:5}),G=!1}A.lencode=$,A.lenbits=9,A.distcode=ee,A.distbits=5}function ce(A,U,f,j){var ge,H=A.state;return H.window===null&&(H.wsize=1<<H.wbits,H.wnext=0,H.whave=0,H.window=new l.Buf8(H.wsize)),j>=H.wsize?(l.arraySet(H.window,U,f-H.wsize,H.wsize,0),H.wnext=0,H.whave=H.wsize):(j<(ge=H.wsize-H.wnext)&&(ge=j),l.arraySet(H.window,U,f-j,ge,H.wnext),(j-=ge)?(l.arraySet(H.window,U,f-j,j,0),H.wnext=j,H.whave=H.wsize):(H.wnext+=ge,H.wnext===H.wsize&&(H.wnext=0),H.whave<H.wsize&&(H.whave+=ge))),0}a.inflateReset=M,a.inflateReset2=F,a.inflateResetKeep=I,a.inflateInit=function(A){return Y(A,15)},a.inflateInit2=Y,a.inflate=function(A,U){var f,j,ge,H,y,w,O,x,C,R,L,B,Z,K,re,me,fe,he,_e,ze,u,Q,V,T,k=0,P=new l.Buf8(4),J=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!A||!A.state||!A.output||!A.input&&A.avail_in!==0)return h;(f=A.state).mode===12&&(f.mode=13),y=A.next_out,ge=A.output,O=A.avail_out,H=A.next_in,j=A.input,w=A.avail_in,x=f.hold,C=f.bits,R=w,L=O,Q=b;e:for(;;)switch(f.mode){case E:if(f.wrap===0){f.mode=13;break}for(;C<16;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}if(2&f.wrap&&x===35615){P[f.check=0]=255&x,P[1]=x>>>8&255,f.check=i(f.check,P,2,0),C=x=0,f.mode=2;break}if(f.flags=0,f.head&&(f.head.done=!1),!(1&f.wrap)||(((255&x)<<8)+(x>>8))%31){A.msg="incorrect header check",f.mode=30;break}if((15&x)!=8){A.msg="unknown compression method",f.mode=30;break}if(C-=4,u=8+(15&(x>>>=4)),f.wbits===0)f.wbits=u;else if(u>f.wbits){A.msg="invalid window size",f.mode=30;break}f.dmax=1<<u,A.adler=f.check=1,f.mode=512&x?10:12,C=x=0;break;case 2:for(;C<16;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}if(f.flags=x,(255&f.flags)!=8){A.msg="unknown compression method",f.mode=30;break}if(57344&f.flags){A.msg="unknown header flags set",f.mode=30;break}f.head&&(f.head.text=x>>8&1),512&f.flags&&(P[0]=255&x,P[1]=x>>>8&255,f.check=i(f.check,P,2,0)),C=x=0,f.mode=3;case 3:for(;C<32;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}f.head&&(f.head.time=x),512&f.flags&&(P[0]=255&x,P[1]=x>>>8&255,P[2]=x>>>16&255,P[3]=x>>>24&255,f.check=i(f.check,P,4,0)),C=x=0,f.mode=4;case 4:for(;C<16;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}f.head&&(f.head.xflags=255&x,f.head.os=x>>8),512&f.flags&&(P[0]=255&x,P[1]=x>>>8&255,f.check=i(f.check,P,2,0)),C=x=0,f.mode=5;case 5:if(1024&f.flags){for(;C<16;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}f.length=x,f.head&&(f.head.extra_len=x),512&f.flags&&(P[0]=255&x,P[1]=x>>>8&255,f.check=i(f.check,P,2,0)),C=x=0}else f.head&&(f.head.extra=null);f.mode=6;case 6:if(1024&f.flags&&(w<(B=f.length)&&(B=w),B&&(f.head&&(u=f.head.extra_len-f.length,f.head.extra||(f.head.extra=new Array(f.head.extra_len)),l.arraySet(f.head.extra,j,H,B,u)),512&f.flags&&(f.check=i(f.check,j,B,H)),w-=B,H+=B,f.length-=B),f.length))break e;f.length=0,f.mode=7;case 7:if(2048&f.flags){if(w===0)break e;for(B=0;u=j[H+B++],f.head&&u&&f.length<65536&&(f.head.name+=String.fromCharCode(u)),u&&B<w;);if(512&f.flags&&(f.check=i(f.check,j,B,H)),w-=B,H+=B,u)break e}else f.head&&(f.head.name=null);f.length=0,f.mode=8;case 8:if(4096&f.flags){if(w===0)break e;for(B=0;u=j[H+B++],f.head&&u&&f.length<65536&&(f.head.comment+=String.fromCharCode(u)),u&&B<w;);if(512&f.flags&&(f.check=i(f.check,j,B,H)),w-=B,H+=B,u)break e}else f.head&&(f.head.comment=null);f.mode=9;case 9:if(512&f.flags){for(;C<16;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}if(x!==(65535&f.check)){A.msg="header crc mismatch",f.mode=30;break}C=x=0}f.head&&(f.head.hcrc=f.flags>>9&1,f.head.done=!0),A.adler=f.check=0,f.mode=12;break;case 10:for(;C<32;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}A.adler=f.check=_(x),C=x=0,f.mode=11;case 11:if(f.havedict===0)return A.next_out=y,A.avail_out=O,A.next_in=H,A.avail_in=w,f.hold=x,f.bits=C,2;A.adler=f.check=1,f.mode=12;case 12:if(U===5||U===6)break e;case 13:if(f.last){x>>>=7&C,C-=7&C,f.mode=27;break}for(;C<3;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}switch(f.last=1&x,C-=1,3&(x>>>=1)){case 0:f.mode=14;break;case 1:if(ne(f),f.mode=20,U!==6)break;x>>>=2,C-=2;break e;case 2:f.mode=17;break;case 3:A.msg="invalid block type",f.mode=30}x>>>=2,C-=2;break;case 14:for(x>>>=7&C,C-=7&C;C<32;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}if((65535&x)!=(x>>>16^65535)){A.msg="invalid stored block lengths",f.mode=30;break}if(f.length=65535&x,C=x=0,f.mode=15,U===6)break e;case 15:f.mode=16;case 16:if(B=f.length){if(w<B&&(B=w),O<B&&(B=O),B===0)break e;l.arraySet(ge,j,H,B,y),w-=B,H+=B,O-=B,y+=B,f.length-=B;break}f.mode=12;break;case 17:for(;C<14;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}if(f.nlen=257+(31&x),x>>>=5,C-=5,f.ndist=1+(31&x),x>>>=5,C-=5,f.ncode=4+(15&x),x>>>=4,C-=4,286<f.nlen||30<f.ndist){A.msg="too many length or distance symbols",f.mode=30;break}f.have=0,f.mode=18;case 18:for(;f.have<f.ncode;){for(;C<3;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}f.lens[J[f.have++]]=7&x,x>>>=3,C-=3}for(;f.have<19;)f.lens[J[f.have++]]=0;if(f.lencode=f.lendyn,f.lenbits=7,V={bits:f.lenbits},Q=g(0,f.lens,0,19,f.lencode,0,f.work,V),f.lenbits=V.bits,Q){A.msg="invalid code lengths set",f.mode=30;break}f.have=0,f.mode=19;case 19:for(;f.have<f.nlen+f.ndist;){for(;me=(k=f.lencode[x&(1<<f.lenbits)-1])>>>16&255,fe=65535&k,!((re=k>>>24)<=C);){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}if(fe<16)x>>>=re,C-=re,f.lens[f.have++]=fe;else{if(fe===16){for(T=re+2;C<T;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}if(x>>>=re,C-=re,f.have===0){A.msg="invalid bit length repeat",f.mode=30;break}u=f.lens[f.have-1],B=3+(3&x),x>>>=2,C-=2}else if(fe===17){for(T=re+3;C<T;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}C-=re,u=0,B=3+(7&(x>>>=re)),x>>>=3,C-=3}else{for(T=re+7;C<T;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}C-=re,u=0,B=11+(127&(x>>>=re)),x>>>=7,C-=7}if(f.have+B>f.nlen+f.ndist){A.msg="invalid bit length repeat",f.mode=30;break}for(;B--;)f.lens[f.have++]=u}}if(f.mode===30)break;if(f.lens[256]===0){A.msg="invalid code -- missing end-of-block",f.mode=30;break}if(f.lenbits=9,V={bits:f.lenbits},Q=g(m,f.lens,0,f.nlen,f.lencode,0,f.work,V),f.lenbits=V.bits,Q){A.msg="invalid literal/lengths set",f.mode=30;break}if(f.distbits=6,f.distcode=f.distdyn,V={bits:f.distbits},Q=g(p,f.lens,f.nlen,f.ndist,f.distcode,0,f.work,V),f.distbits=V.bits,Q){A.msg="invalid distances set",f.mode=30;break}if(f.mode=20,U===6)break e;case 20:f.mode=21;case 21:if(6<=w&&258<=O){A.next_out=y,A.avail_out=O,A.next_in=H,A.avail_in=w,f.hold=x,f.bits=C,d(A,L),y=A.next_out,ge=A.output,O=A.avail_out,H=A.next_in,j=A.input,w=A.avail_in,x=f.hold,C=f.bits,f.mode===12&&(f.back=-1);break}for(f.back=0;me=(k=f.lencode[x&(1<<f.lenbits)-1])>>>16&255,fe=65535&k,!((re=k>>>24)<=C);){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}if(me&&(240&me)==0){for(he=re,_e=me,ze=fe;me=(k=f.lencode[ze+((x&(1<<he+_e)-1)>>he)])>>>16&255,fe=65535&k,!(he+(re=k>>>24)<=C);){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}x>>>=he,C-=he,f.back+=he}if(x>>>=re,C-=re,f.back+=re,f.length=fe,me===0){f.mode=26;break}if(32&me){f.back=-1,f.mode=12;break}if(64&me){A.msg="invalid literal/length code",f.mode=30;break}f.extra=15&me,f.mode=22;case 22:if(f.extra){for(T=f.extra;C<T;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}f.length+=x&(1<<f.extra)-1,x>>>=f.extra,C-=f.extra,f.back+=f.extra}f.was=f.length,f.mode=23;case 23:for(;me=(k=f.distcode[x&(1<<f.distbits)-1])>>>16&255,fe=65535&k,!((re=k>>>24)<=C);){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}if((240&me)==0){for(he=re,_e=me,ze=fe;me=(k=f.distcode[ze+((x&(1<<he+_e)-1)>>he)])>>>16&255,fe=65535&k,!(he+(re=k>>>24)<=C);){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}x>>>=he,C-=he,f.back+=he}if(x>>>=re,C-=re,f.back+=re,64&me){A.msg="invalid distance code",f.mode=30;break}f.offset=fe,f.extra=15&me,f.mode=24;case 24:if(f.extra){for(T=f.extra;C<T;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}f.offset+=x&(1<<f.extra)-1,x>>>=f.extra,C-=f.extra,f.back+=f.extra}if(f.offset>f.dmax){A.msg="invalid distance too far back",f.mode=30;break}f.mode=25;case 25:if(O===0)break e;if(B=L-O,f.offset>B){if((B=f.offset-B)>f.whave&&f.sane){A.msg="invalid distance too far back",f.mode=30;break}Z=B>f.wnext?(B-=f.wnext,f.wsize-B):f.wnext-B,B>f.length&&(B=f.length),K=f.window}else K=ge,Z=y-f.offset,B=f.length;for(O<B&&(B=O),O-=B,f.length-=B;ge[y++]=K[Z++],--B;);f.length===0&&(f.mode=21);break;case 26:if(O===0)break e;ge[y++]=f.length,O--,f.mode=21;break;case 27:if(f.wrap){for(;C<32;){if(w===0)break e;w--,x|=j[H++]<<C,C+=8}if(L-=O,A.total_out+=L,f.total+=L,L&&(A.adler=f.check=f.flags?i(f.check,ge,L,y-L):o(f.check,ge,L,y-L)),L=O,(f.flags?x:_(x))!==f.check){A.msg="incorrect data check",f.mode=30;break}C=x=0}f.mode=28;case 28:if(f.wrap&&f.flags){for(;C<32;){if(w===0)break e;w--,x+=j[H++]<<C,C+=8}if(x!==(4294967295&f.total)){A.msg="incorrect length check",f.mode=30;break}C=x=0}f.mode=29;case 29:Q=1;break e;case 30:Q=-3;break e;case 31:return-4;case 32:default:return h}return A.next_out=y,A.avail_out=O,A.next_in=H,A.avail_in=w,f.hold=x,f.bits=C,(f.wsize||L!==A.avail_out&&f.mode<30&&(f.mode<27||U!==4))&&ce(A,A.output,A.next_out,L-A.avail_out)?(f.mode=31,-4):(R-=A.avail_in,L-=A.avail_out,A.total_in+=R,A.total_out+=L,f.total+=L,f.wrap&&L&&(A.adler=f.check=f.flags?i(f.check,ge,L,A.next_out-L):o(f.check,ge,L,A.next_out-L)),A.data_type=f.bits+(f.last?64:0)+(f.mode===12?128:0)+(f.mode===20||f.mode===15?256:0),(R==0&&L===0||U===4)&&Q===b&&(Q=-5),Q)},a.inflateEnd=function(A){if(!A||!A.state)return h;var U=A.state;return U.window&&(U.window=null),A.state=null,b},a.inflateGetHeader=function(A,U){var f;return A&&A.state?(2&(f=A.state).wrap)==0?h:((f.head=U).done=!1,b):h},a.inflateSetDictionary=function(A,U){var f,j=U.length;return A&&A.state?(f=A.state).wrap!==0&&f.mode!==11?h:f.mode===11&&o(1,U,j,0)!==f.check?-3:ce(A,U,j,j)?(f.mode=31,-4):(f.havedict=1,b):h},a.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(r,s,a){var l=r("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],d=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],g=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];s.exports=function(m,p,b,h,E,v,S,_){var z,I,M,F,Y,$,ee,G,ne,ce=_.bits,A=0,U=0,f=0,j=0,ge=0,H=0,y=0,w=0,O=0,x=0,C=null,R=0,L=new l.Buf16(16),B=new l.Buf16(16),Z=null,K=0;for(A=0;A<=15;A++)L[A]=0;for(U=0;U<h;U++)L[p[b+U]]++;for(ge=ce,j=15;1<=j&&L[j]===0;j--);if(j<ge&&(ge=j),j===0)return E[v++]=20971520,E[v++]=20971520,_.bits=1,0;for(f=1;f<j&&L[f]===0;f++);for(ge<f&&(ge=f),A=w=1;A<=15;A++)if(w<<=1,(w-=L[A])<0)return-1;if(0<w&&(m===0||j!==1))return-1;for(B[1]=0,A=1;A<15;A++)B[A+1]=B[A]+L[A];for(U=0;U<h;U++)p[b+U]!==0&&(S[B[p[b+U]]++]=U);if($=m===0?(C=Z=S,19):m===1?(C=o,R-=257,Z=i,K-=257,256):(C=d,Z=g,-1),A=f,Y=v,y=U=x=0,M=-1,F=(O=1<<(H=ge))-1,m===1&&852<O||m===2&&592<O)return 1;for(;;){for(ee=A-y,ne=S[U]<$?(G=0,S[U]):S[U]>$?(G=Z[K+S[U]],C[R+S[U]]):(G=96,0),z=1<<A-y,f=I=1<<H;E[Y+(x>>y)+(I-=z)]=ee<<24|G<<16|ne|0,I!==0;);for(z=1<<A-1;x&z;)z>>=1;if(z!==0?(x&=z-1,x+=z):x=0,U++,--L[A]==0){if(A===j)break;A=p[b+S[U]]}if(ge<A&&(x&F)!==M){for(y===0&&(y=ge),Y+=f,w=1<<(H=A-y);H+y<j&&!((w-=L[H+y])<=0);)H++,w<<=1;if(O+=1<<H,m===1&&852<O||m===2&&592<O)return 1;E[M=x&F]=ge<<24|H<<16|Y-v|0}}return x!==0&&(E[Y+x]=A-y<<24|64<<16|0),_.bits=ge,0}},{"../utils/common":41}],51:[function(r,s,a){s.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(r,s,a){var l=r("../utils/common"),o=0,i=1;function d(k){for(var P=k.length;0<=--P;)k[P]=0}var g=0,m=29,p=256,b=p+1+m,h=30,E=19,v=2*b+1,S=15,_=16,z=7,I=256,M=16,F=17,Y=18,$=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ee=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],G=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],ne=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ce=new Array(2*(b+2));d(ce);var A=new Array(2*h);d(A);var U=new Array(512);d(U);var f=new Array(256);d(f);var j=new Array(m);d(j);var ge,H,y,w=new Array(h);function O(k,P,J,X,q){this.static_tree=k,this.extra_bits=P,this.extra_base=J,this.elems=X,this.max_length=q,this.has_stree=k&&k.length}function x(k,P){this.dyn_tree=k,this.max_code=0,this.stat_desc=P}function C(k){return k<256?U[k]:U[256+(k>>>7)]}function R(k,P){k.pending_buf[k.pending++]=255&P,k.pending_buf[k.pending++]=P>>>8&255}function L(k,P,J){k.bi_valid>_-J?(k.bi_buf|=P<<k.bi_valid&65535,R(k,k.bi_buf),k.bi_buf=P>>_-k.bi_valid,k.bi_valid+=J-_):(k.bi_buf|=P<<k.bi_valid&65535,k.bi_valid+=J)}function B(k,P,J){L(k,J[2*P],J[2*P+1])}function Z(k,P){for(var J=0;J|=1&k,k>>>=1,J<<=1,0<--P;);return J>>>1}function K(k,P,J){var X,q,ie=new Array(S+1),le=0;for(X=1;X<=S;X++)ie[X]=le=le+J[X-1]<<1;for(q=0;q<=P;q++){var ae=k[2*q+1];ae!==0&&(k[2*q]=Z(ie[ae]++,ae))}}function re(k){var P;for(P=0;P<b;P++)k.dyn_ltree[2*P]=0;for(P=0;P<h;P++)k.dyn_dtree[2*P]=0;for(P=0;P<E;P++)k.bl_tree[2*P]=0;k.dyn_ltree[2*I]=1,k.opt_len=k.static_len=0,k.last_lit=k.matches=0}function me(k){8<k.bi_valid?R(k,k.bi_buf):0<k.bi_valid&&(k.pending_buf[k.pending++]=k.bi_buf),k.bi_buf=0,k.bi_valid=0}function fe(k,P,J,X){var q=2*P,ie=2*J;return k[q]<k[ie]||k[q]===k[ie]&&X[P]<=X[J]}function he(k,P,J){for(var X=k.heap[J],q=J<<1;q<=k.heap_len&&(q<k.heap_len&&fe(P,k.heap[q+1],k.heap[q],k.depth)&&q++,!fe(P,X,k.heap[q],k.depth));)k.heap[J]=k.heap[q],J=q,q<<=1;k.heap[J]=X}function _e(k,P,J){var X,q,ie,le,ae=0;if(k.last_lit!==0)for(;X=k.pending_buf[k.d_buf+2*ae]<<8|k.pending_buf[k.d_buf+2*ae+1],q=k.pending_buf[k.l_buf+ae],ae++,X===0?B(k,q,P):(B(k,(ie=f[q])+p+1,P),(le=$[ie])!==0&&L(k,q-=j[ie],le),B(k,ie=C(--X),J),(le=ee[ie])!==0&&L(k,X-=w[ie],le)),ae<k.last_lit;);B(k,I,P)}function ze(k,P){var J,X,q,ie=P.dyn_tree,le=P.stat_desc.static_tree,ae=P.stat_desc.has_stree,de=P.stat_desc.elems,Ce=-1;for(k.heap_len=0,k.heap_max=v,J=0;J<de;J++)ie[2*J]!==0?(k.heap[++k.heap_len]=Ce=J,k.depth[J]=0):ie[2*J+1]=0;for(;k.heap_len<2;)ie[2*(q=k.heap[++k.heap_len]=Ce<2?++Ce:0)]=1,k.depth[q]=0,k.opt_len--,ae&&(k.static_len-=le[2*q+1]);for(P.max_code=Ce,J=k.heap_len>>1;1<=J;J--)he(k,ie,J);for(q=de;J=k.heap[1],k.heap[1]=k.heap[k.heap_len--],he(k,ie,1),X=k.heap[1],k.heap[--k.heap_max]=J,k.heap[--k.heap_max]=X,ie[2*q]=ie[2*J]+ie[2*X],k.depth[q]=(k.depth[J]>=k.depth[X]?k.depth[J]:k.depth[X])+1,ie[2*J+1]=ie[2*X+1]=q,k.heap[1]=q++,he(k,ie,1),2<=k.heap_len;);k.heap[--k.heap_max]=k.heap[1],function(we,Fe){var nt,Le,ct,De,dt,wt,We=Fe.dyn_tree,Rt=Fe.max_code,cr=Fe.stat_desc.static_tree,xt=Fe.stat_desc.has_stree,Mt=Fe.stat_desc.extra_bits,Ke=Fe.stat_desc.extra_base,Je=Fe.stat_desc.max_length,it=0;for(De=0;De<=S;De++)we.bl_count[De]=0;for(We[2*we.heap[we.heap_max]+1]=0,nt=we.heap_max+1;nt<v;nt++)Je<(De=We[2*We[2*(Le=we.heap[nt])+1]+1]+1)&&(De=Je,it++),We[2*Le+1]=De,Rt<Le||(we.bl_count[De]++,dt=0,Ke<=Le&&(dt=Mt[Le-Ke]),wt=We[2*Le],we.opt_len+=wt*(De+dt),xt&&(we.static_len+=wt*(cr[2*Le+1]+dt)));if(it!==0){do{for(De=Je-1;we.bl_count[De]===0;)De--;we.bl_count[De]--,we.bl_count[De+1]+=2,we.bl_count[Je]--,it-=2}while(0<it);for(De=Je;De!==0;De--)for(Le=we.bl_count[De];Le!==0;)Rt<(ct=we.heap[--nt])||(We[2*ct+1]!==De&&(we.opt_len+=(De-We[2*ct+1])*We[2*ct],We[2*ct+1]=De),Le--)}}(k,P),K(ie,Ce,k.bl_count)}function u(k,P,J){var X,q,ie=-1,le=P[1],ae=0,de=7,Ce=4;for(le===0&&(de=138,Ce=3),P[2*(J+1)+1]=65535,X=0;X<=J;X++)q=le,le=P[2*(X+1)+1],++ae<de&&q===le||(ae<Ce?k.bl_tree[2*q]+=ae:q!==0?(q!==ie&&k.bl_tree[2*q]++,k.bl_tree[2*M]++):ae<=10?k.bl_tree[2*F]++:k.bl_tree[2*Y]++,ie=q,Ce=(ae=0)===le?(de=138,3):q===le?(de=6,3):(de=7,4))}function Q(k,P,J){var X,q,ie=-1,le=P[1],ae=0,de=7,Ce=4;for(le===0&&(de=138,Ce=3),X=0;X<=J;X++)if(q=le,le=P[2*(X+1)+1],!(++ae<de&&q===le)){if(ae<Ce)for(;B(k,q,k.bl_tree),--ae!=0;);else q!==0?(q!==ie&&(B(k,q,k.bl_tree),ae--),B(k,M,k.bl_tree),L(k,ae-3,2)):ae<=10?(B(k,F,k.bl_tree),L(k,ae-3,3)):(B(k,Y,k.bl_tree),L(k,ae-11,7));ie=q,Ce=(ae=0)===le?(de=138,3):q===le?(de=6,3):(de=7,4)}}d(w);var V=!1;function T(k,P,J,X){L(k,(g<<1)+(X?1:0),3),function(q,ie,le,ae){me(q),ae&&(R(q,le),R(q,~le)),l.arraySet(q.pending_buf,q.window,ie,le,q.pending),q.pending+=le}(k,P,J,!0)}a._tr_init=function(k){V||(function(){var P,J,X,q,ie,le=new Array(S+1);for(q=X=0;q<m-1;q++)for(j[q]=X,P=0;P<1<<$[q];P++)f[X++]=q;for(f[X-1]=q,q=ie=0;q<16;q++)for(w[q]=ie,P=0;P<1<<ee[q];P++)U[ie++]=q;for(ie>>=7;q<h;q++)for(w[q]=ie<<7,P=0;P<1<<ee[q]-7;P++)U[256+ie++]=q;for(J=0;J<=S;J++)le[J]=0;for(P=0;P<=143;)ce[2*P+1]=8,P++,le[8]++;for(;P<=255;)ce[2*P+1]=9,P++,le[9]++;for(;P<=279;)ce[2*P+1]=7,P++,le[7]++;for(;P<=287;)ce[2*P+1]=8,P++,le[8]++;for(K(ce,b+1,le),P=0;P<h;P++)A[2*P+1]=5,A[2*P]=Z(P,5);ge=new O(ce,$,p+1,b,S),H=new O(A,ee,0,h,S),y=new O(new Array(0),G,0,E,z)}(),V=!0),k.l_desc=new x(k.dyn_ltree,ge),k.d_desc=new x(k.dyn_dtree,H),k.bl_desc=new x(k.bl_tree,y),k.bi_buf=0,k.bi_valid=0,re(k)},a._tr_stored_block=T,a._tr_flush_block=function(k,P,J,X){var q,ie,le=0;0<k.level?(k.strm.data_type===2&&(k.strm.data_type=function(ae){var de,Ce=4093624447;for(de=0;de<=31;de++,Ce>>>=1)if(1&Ce&&ae.dyn_ltree[2*de]!==0)return o;if(ae.dyn_ltree[18]!==0||ae.dyn_ltree[20]!==0||ae.dyn_ltree[26]!==0)return i;for(de=32;de<p;de++)if(ae.dyn_ltree[2*de]!==0)return i;return o}(k)),ze(k,k.l_desc),ze(k,k.d_desc),le=function(ae){var de;for(u(ae,ae.dyn_ltree,ae.l_desc.max_code),u(ae,ae.dyn_dtree,ae.d_desc.max_code),ze(ae,ae.bl_desc),de=E-1;3<=de&&ae.bl_tree[2*ne[de]+1]===0;de--);return ae.opt_len+=3*(de+1)+5+5+4,de}(k),q=k.opt_len+3+7>>>3,(ie=k.static_len+3+7>>>3)<=q&&(q=ie)):q=ie=J+5,J+4<=q&&P!==-1?T(k,P,J,X):k.strategy===4||ie===q?(L(k,2+(X?1:0),3),_e(k,ce,A)):(L(k,4+(X?1:0),3),function(ae,de,Ce,we){var Fe;for(L(ae,de-257,5),L(ae,Ce-1,5),L(ae,we-4,4),Fe=0;Fe<we;Fe++)L(ae,ae.bl_tree[2*ne[Fe]+1],3);Q(ae,ae.dyn_ltree,de-1),Q(ae,ae.dyn_dtree,Ce-1)}(k,k.l_desc.max_code+1,k.d_desc.max_code+1,le+1),_e(k,k.dyn_ltree,k.dyn_dtree)),re(k),X&&me(k)},a._tr_tally=function(k,P,J){return k.pending_buf[k.d_buf+2*k.last_lit]=P>>>8&255,k.pending_buf[k.d_buf+2*k.last_lit+1]=255&P,k.pending_buf[k.l_buf+k.last_lit]=255&J,k.last_lit++,P===0?k.dyn_ltree[2*J]++:(k.matches++,P--,k.dyn_ltree[2*(f[J]+p+1)]++,k.dyn_dtree[2*C(P)]++),k.last_lit===k.lit_bufsize-1},a._tr_align=function(k){L(k,2,3),B(k,I,ce),function(P){P.bi_valid===16?(R(P,P.bi_buf),P.bi_buf=0,P.bi_valid=0):8<=P.bi_valid&&(P.pending_buf[P.pending++]=255&P.bi_buf,P.bi_buf>>=8,P.bi_valid-=8)}(k)}},{"../utils/common":41}],53:[function(r,s,a){s.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,s,a){(function(l){(function(o,i){if(!o.setImmediate){var d,g,m,p,b=1,h={},E=!1,v=o.document,S=Object.getPrototypeOf&&Object.getPrototypeOf(o);S=S&&S.setTimeout?S:o,d={}.toString.call(o.process)==="[object process]"?function(M){process.nextTick(function(){z(M)})}:function(){if(o.postMessage&&!o.importScripts){var M=!0,F=o.onmessage;return o.onmessage=function(){M=!1},o.postMessage("","*"),o.onmessage=F,M}}()?(p="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",I,!1):o.attachEvent("onmessage",I),function(M){o.postMessage(p+M,"*")}):o.MessageChannel?((m=new MessageChannel).port1.onmessage=function(M){z(M.data)},function(M){m.port2.postMessage(M)}):v&&"onreadystatechange"in v.createElement("script")?(g=v.documentElement,function(M){var F=v.createElement("script");F.onreadystatechange=function(){z(M),F.onreadystatechange=null,g.removeChild(F),F=null},g.appendChild(F)}):function(M){setTimeout(z,0,M)},S.setImmediate=function(M){typeof M!="function"&&(M=new Function(""+M));for(var F=new Array(arguments.length-1),Y=0;Y<F.length;Y++)F[Y]=arguments[Y+1];var $={callback:M,args:F};return h[b]=$,d(b),b++},S.clearImmediate=_}function _(M){delete h[M]}function z(M){if(E)setTimeout(z,0,M);else{var F=h[M];if(F){E=!0;try{(function(Y){var $=Y.callback,ee=Y.args;switch(ee.length){case 0:$();break;case 1:$(ee[0]);break;case 2:$(ee[0],ee[1]);break;case 3:$(ee[0],ee[1],ee[2]);break;default:$.apply(i,ee)}})(F)}finally{_(M),E=!1}}}}function I(M){M.source===o&&typeof M.data=="string"&&M.data.indexOf(p)===0&&z(+M.data.slice(p.length))}})(typeof self>"u"?l===void 0?this:l:self)}).call(this,typeof Ye<"u"?Ye:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(_n);const Ns=_n.exports;var or={exports:{}};(function(t,e){(function(r,s){s()})(Ye,function(){function r(g,m){return typeof m>"u"?m={autoBom:!1}:typeof m!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),m={autoBom:!m}),m.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(g.type)?new Blob(["\uFEFF",g],{type:g.type}):g}function s(g,m,p){var b=new XMLHttpRequest;b.open("GET",g),b.responseType="blob",b.onload=function(){d(b.response,m,p)},b.onerror=function(){console.error("could not download file")},b.send()}function a(g){var m=new XMLHttpRequest;m.open("HEAD",g,!1);try{m.send()}catch{}return 200<=m.status&&299>=m.status}function l(g){try{g.dispatchEvent(new MouseEvent("click"))}catch{var m=document.createEvent("MouseEvents");m.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),g.dispatchEvent(m)}}var o=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Ye=="object"&&Ye.global===Ye?Ye:void 0,i=o.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=o.saveAs||(typeof window!="object"||window!==o?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(g,m,p){var b=o.URL||o.webkitURL,h=document.createElement("a");m=m||g.name||"download",h.download=m,h.rel="noopener",typeof g=="string"?(h.href=g,h.origin===location.origin?l(h):a(h.href)?s(g,m,p):l(h,h.target="_blank")):(h.href=b.createObjectURL(g),setTimeout(function(){b.revokeObjectURL(h.href)},4e4),setTimeout(function(){l(h)},0))}:"msSaveOrOpenBlob"in navigator?function(g,m,p){if(m=m||g.name||"download",typeof g!="string")navigator.msSaveOrOpenBlob(r(g,p),m);else if(a(g))s(g,m,p);else{var b=document.createElement("a");b.href=g,b.target="_blank",setTimeout(function(){l(b)})}}:function(g,m,p,b){if(b=b||open("","_blank"),b&&(b.document.title=b.document.body.innerText="downloading..."),typeof g=="string")return s(g,m,p);var h=g.type==="application/octet-stream",E=/constructor/i.test(o.HTMLElement)||o.safari,v=/CriOS\/[\d]+/.test(navigator.userAgent);if((v||h&&E||i)&&typeof FileReader<"u"){var S=new FileReader;S.onloadend=function(){var I=S.result;I=v?I:I.replace(/^data:[^;]*;/,"data:attachment/file;"),b?b.location.href=I:location=I,b=null},S.readAsDataURL(g)}else{var _=o.URL||o.webkitURL,z=_.createObjectURL(g);b?b.location=z:location.href=z,b=null,setTimeout(function(){_.revokeObjectURL(z)},4e4)}});o.saveAs=d.saveAs=d,t.exports=d})})(or);function Gs(t,e){const r=new Blob([e],{type:"text/csv"});or.exports.saveAs(r,`${t}.csv`)}function Us(t){const e=new Ns;t.forEach(({id:r,data:s})=>{e.file(`${r}.csv`,wn(s))}),e.generateAsync({type:"blob"}).then(r=>{or.exports.saveAs(r,"dashboard_data.zip")})}function wn(t){if(!Array.isArray(t)||t.length===0)return"";const e=[],r=Object.keys(t[0]);return e.push(r.join(",")),t.forEach(s=>{const a=Object.values(s).join(",");e.push(a)}),e.join(`
|
|
59
|
+
`)}const xn=se.types.model("QueryModel",{id:se.types.string,type:se.types.enumeration("DataSourceType",[_t.Postgresql,_t.MySQL,_t.HTTP]),key:se.types.string,sql:se.types.string}).views(t=>({get valid(){return t.id&&t.type&&t.key&&t.sql},get configurations(){const{id:e,type:r,key:s,sql:a}=t;return{id:e,type:r,key:s,sql:a}}})),kn=se.types.compose("QueryModel",xn,se.types.model({state:se.types.optional(se.types.enumeration(["idle","loading","error"]),"idle"),data:se.types.optional(se.types.array(se.types.frozen()),[]),error:se.types.frozen()})).views(t=>({get formattedSQL(){const{context:e,sqlSnippets:r,filterValues:s}=se.getRoot(t).payloadForSQL;return tn(t.sql,e,r,s)}})).actions(t=>({setID(e){t.id=e},setKey(e){t.key=e},setType(e){t.type=e},setSQL(e){t.sql=e},fetchData:se.flow(function*(){if(!!t.valid){t.state="loading";try{const e=t.id,{context:r,sqlSnippets:s,filterValues:a}=se.getRoot(t).payloadForSQL;t.data=yield*se.toGenerator(as({context:r,sqlSnippets:s,title:e,query:{type:t.type,key:t.key,sql:t.sql},filterValues:a})),t.state="idle"}catch(e){console.error(e),t.error=e,t.state="error"}}})})).actions(t=>({afterCreate(){se.addDisposer(t,at.reaction(()=>`${t.id}--${t.key}--${t.type}--${t.formattedSQL}`,t.fetchData,{fireImmediately:!0,delay:500}))}})),Cn=se.types.model("QueriesModel",{original:se.types.optional(se.types.array(xn),[]),current:se.types.optional(se.types.array(kn),[])}).views(t=>({get changed(){return t.original.length!==t.current.length?!0:t.original.some((e,r)=>!ye.default.isEqual(e.configurations,t.current[r].configurations))},get firstID(){if(t.current.length!==0)return t.current[0].id},findByID(e){return t.current.find(r=>r.id===e)},get options(){return t.current.map(e=>({value:e.id,label:e.id}))}})).actions(t=>({reset(){t.current=se.cast(t.original)},replace(e){t.current=se.cast(e)},append(e){t.current.push(e)},remove(e){t.current.splice(e,1)},replaceByIndex(e,r){t.current.splice(e,1,r)},downloadAllData(){const e=t.current.map(({id:r,data:s})=>({id:r,data:s.toJSON()}));Us(e)},downloadDataByQueryID(e){const r=t.findByID(e);if(!r){console.log(`[downloadDataByQueryID] query by ID[${e}] not found`);return}const{id:s,data:a}=r,l=wn(a);Gs(s,l)},refetchDataByQueryID(e){const r=t.findByID(e);if(!r){console.error(new Error(`[downloadDataByQueryID] query by ID[${e}] not found`));return}return r.fetchData()}})),lr=se.types.model("SQLSnippetModel",{key:se.types.string,value:se.types.string}).actions(t=>({setKey(e){t.key=e},setValue(e){t.value=e}})),Sn=se.types.model("SQLSnippetsModel",{original:se.types.optional(se.types.array(lr),[]),current:se.types.optional(se.types.array(lr),[])}).views(t=>({get changed(){return!ye.default.isEqual(t.original,t.current)}})).actions(t=>({reset(){t.current=ye.default.cloneDeep(t.original)},replace(e){t.current=se.cast(e)},append(e){t.current.push(e)},remove(e){t.current.splice(e,1)},replaceByIndex(e,r){t.current.splice(e,1,r)}})),En=se.types.model("ContextModel",{current:se.types.optional(se.types.frozen(),{})}).views(t=>({get keys(){return Object.keys(t.current)},get entries(){return Object.entries(t.current)}})).actions(t=>({replace(e){t.current=e},get(e){return t.current[e]},set(e,r){t.current[e]=r}})),Vs=se.types.model({id:se.types.identifier,name:se.types.string,filters:bn,queries:Cn,sqlSnippets:Sn,context:En}).views(t=>({get payloadForSQL(){return{context:t.context.current,sqlSnippets:t.sqlSnippets.current,filterValues:t.filters.values}},get data(){return t.queries.current.map(({id:r,data:s})=>({id:r,data:s})).reduce((r,s)=>(r[s.id]=s.data,r),{})},getDataStuffByID(e){const r=t.queries.findByID(e);return r?{data:r.data.toJSON(),state:r.state,error:void 0}:{data:[],state:"idle",error:void 0}},getDataStateByID(e){var r,s;return(s=(r=t.queries.findByID(e))==null?void 0:r.state)!=null?s:[]},getDataErrorByID(e){var r,s;return(s=(r=t.queries.findByID(e))==null?void 0:r.error)!=null?s:[]}}));function ur({id:t,name:e,filters:r,definition:{queries:s,sqlSnippets:a}},l){return Vs.create({id:t,name:e,filters:yn(r),queries:{original:s,current:s},sqlSnippets:{original:a,current:a},context:l})}function zn(){W.default.useEffect(()=>{const t=Vn.default(".dashboard-sticky-area",{useStickyClasses:!0,parentClass:"dashboard-sticky-parent"});return()=>{t==null||t.cleanup()}},[])}const ho="",Ws=Se.observer(function({context:e,dashboard:r,update:s,className:a="dashboard",config:l}){ut.baseURL!==l.apiBaseURL&&(ut.baseURL=l.apiBaseURL);const[o,i]=W.default.useState(!1),[d,g]=W.default.useState(Ve.Edit),[m,p]=W.default.useState(r.panels),b=W.default.useMemo(()=>ur(r,e),[r]);W.default.useEffect(()=>{b.context.replace(e)},[e]);const h=W.default.useMemo(()=>{if(b.filters.changed||b.queries.changed||b.sqlSnippets.changed)return!0;const A=f=>JSON.parse(JSON.stringify(f));return!ye.default.isEqual(A(m),A(r.panels))},[r,m,b.queries.changed,b.filters.changed]),E=async()=>{const A=[...b.queries.current],U=[...b.sqlSnippets.current],f={...r,filters:[...b.filters.current],panels:m,definition:{sqlSnippets:U,queries:A}};await s(f)},v=()=>{b.filters.reset(),p(r.panels),b.sqlSnippets.reset(),b.queries.reset()},S=()=>{const A=Be.randomId(),U={id:A,layout:{x:0,y:1/0,w:3,h:15},title:`Panel - ${A}`,description:"<p><br></p>",queryID:"",viz:{type:"table",conf:{}}};p(f=>[...f,U])},_=A=>{try{const U=m.find(j=>j.id===A);if(!U)throw new Error(`[duplicate panel] Can't find a panel by id[${A}]`);const f={...U,id:Be.randomId(),layout:{...U.layout,x:0,y:1/0}};p(j=>[...j,f])}catch(U){console.error(U)}},z=A=>{const U=m.findIndex(f=>f.id===A);p(f=>(f.splice(U,1),[...f]))},I=d===Ve.Edit,M=d===Ve.Layout,F=d===Ve.Use,Y=W.default.useCallback(()=>{const A=b.queries.current,U=b.sqlSnippets.current;return{filters:b.filters.current,panels:m,definition:{sqlSnippets:U,queries:A}}},[m,b]);zn();const{viewPanelInFullScreen:$,exitFullScreen:ee,inFullScreen:G,fullScreenPanel:ne}=dn(m),ce=He.useCreation(kr,[]);return n(Bt.ModalsProvider,{children:n(Nt,{value:b,children:n(Et.Provider,{value:{addPanel:S,duplidatePanel:_,removePanelByID:z,viewPanelInFullScreen:$,inFullScreen:G},children:N($e.Provider,{value:{layoutFrozen:o,freezeLayout:i,mode:d,inEditMode:I,inLayoutMode:M,inUseMode:F},children:[G&&n(cn,{panel:ne,exitFullScreen:ee}),N(c.Box,{className:`${a} dashboard-root dashboard-sticky-parent`,sx:{position:"relative",display:G?"none":"block"},children:[N(c.Box,{className:"dashboard-sticky-area",children:[n(Ms,{mode:d,setMode:g,hasChanges:h,saveChanges:E,revertChanges:v,getCurrentSchema:Y}),n(fn,{})]}),n(Wt.Provider,{value:ce,children:n(Xr,{panels:m,setPanels:p,isDraggable:M,isResizable:M})})]})]})})})})}),$s=Lt.WidthProvider(fr.default),Qs=Se.observer(function({panels:e,className:r="layout",rowHeight:s=10}){return n($s,{className:`dashboard-layout ${r}`,rowHeight:s,isDraggable:!1,isResizable:!1,children:e.map(({id:a,...l})=>n("div",{"data-grid":l.layout,children:n(Pt,{id:a,...l})},a))})});function Zs({context:t,dashboard:e,className:r="dashboard",config:s}){ut.baseURL!==s.apiBaseURL&&(ut.baseURL=s.apiBaseURL);const a=W.default.useMemo(()=>ur(e,t),[e]),{viewPanelInFullScreen:l,exitFullScreen:o,inFullScreen:i,fullScreenPanel:d}=dn(e.panels);return zn(),n(Bt.ModalsProvider,{children:n(Nt,{value:a,children:n(Et.Provider,{value:{addPanel:ye.default.noop,duplidatePanel:ye.default.noop,removePanelByID:ye.default.noop,viewPanelInFullScreen:l,inFullScreen:i},children:N($e.Provider,{value:{layoutFrozen:!0,freezeLayout:()=>{},mode:Ve.Use,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},children:[i&&n(cn,{panel:d,exitFullScreen:o}),N(c.Box,{className:`${r} dashboard-root dashboard-sticky-parent`,sx:{display:i?"none":"block"},children:[n(c.Box,{className:"dashboard-sticky-area",children:n(fn,{})}),n(Qs,{panels:e.panels})]})]})})})})}var Tn=(t=>(t.Select="select",t.MultiSelect="multi-select",t.TextInput="text-input",t.Checkbox="checkbox",t.DateRange="date-range",t))(Tn||{});ue.ContextModel=En,ue.Dashboard=Ws,ue.DashboardFilterType=Tn,ue.DashboardLayout=Xr,ue.DashboardMode=Ve,ue.FilterModel=sr,ue.FiltersModel=bn,ue.LayoutStateContext=$e,ue.ModelContextProvider=Nt,ue.Panel=Pt,ue.PanelContext=je,ue.QueriesModel=Cn,ue.QueryModel=kn,ue.ReadOnlyDashboard=Zs,ue.SQLSnippetModel=lr,ue.SQLSnippetsModel=Sn,ue.createDashboardModel=ur,ue.getInitialFiltersPayload=yn,ue.useModelContext=Me,Object.defineProperties(ue,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|