@malloydata/render 0.0.138-dev240404154020 → 0.0.138-dev240404233606
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/dist/module/index.mjs +585 -580
- package/dist/module/index.umd.js +4 -4
- package/dist/webcomponent/malloy-render.mjs +1703 -1698
- package/dist/webcomponent/malloy-render.umd.js +4 -4
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(g3){typeof define=="function"&&define.amd?define(g3):g3()})(function(){"use strict";function g3(t){return Object.keys(t).reduce((n,r)=>{const i=t[r];return n[r]=Object.assign({},i),H7(i.value)&&!lle(i.value)&&!Array.isArray(i.value)&&(n[r].value=Object.assign({},i.value)),Array.isArray(i.value)&&(n[r].value=i.value.slice(0)),n},{})}function sle(t){return t?Object.keys(t).reduce((n,r)=>{const i=t[r];return n[r]=H7(i)&&"value"in i?i:{value:i},n[r].attribute||(n[r].attribute=ale(r)),n[r].parse="parse"in n[r]?n[r].parse:typeof n[r].value!="string",n},{}):{}}function ole(t){return Object.keys(t).reduce((n,r)=>(n[r]=t[r].value,n),{})}function ule(t,e){const n=g3(e);return Object.keys(e).forEach(i=>{const s=n[i],o=t.getAttribute(s.attribute),u=t[i];o&&(s.value=s.parse?U7(o):o),u!=null&&(s.value=Array.isArray(u)?u.slice(0):u),s.reflect&&q7(t,s.attribute,s.value),Object.defineProperty(t,i,{get(){return s.value},set(a){const l=s.value;s.value=a,s.reflect&&q7(this,s.attribute,s.value);for(let c=0,f=this.__propertyChangedCallbacks.length;c<f;c++)this.__propertyChangedCallbacks[c](i,a,l)},enumerable:!0,configurable:!0})}),n}function U7(t){if(t)try{return JSON.parse(t)}catch{return t}}function q7(t,e,n){if(n==null||n===!1)return t.removeAttribute(e);let r=JSON.stringify(n);t.__updating[e]=!0,r==="true"&&(r=""),t.setAttribute(e,r),Promise.resolve().then(()=>delete t.__updating[e])}function ale(t){return t.replace(/\.?([A-Z]+)/g,(e,n)=>"-"+n.toLowerCase()).replace("_","-").replace(/^-/,"")}function H7(t){return t!=null&&(typeof t=="object"||typeof t=="function")}function lle(t){return Object.prototype.toString.call(t)==="[object Function]"}function cle(t){return typeof t=="function"&&t.toString().indexOf("class")===0}let RN;function fle(t,e){const n=Object.keys(e);return class extends t{static get observedAttributes(){return n.map(i=>e[i].attribute)}constructor(){super(),this.__initialized=!1,this.__released=!1,this.__releaseCallbacks=[],this.__propertyChangedCallbacks=[],this.__updating={},this.props={}}connectedCallback(){if(this.__initialized)return;this.__releaseCallbacks=[],this.__propertyChangedCallbacks=[],this.__updating={},this.props=ule(this,e);const i=ole(this.props),s=this.Component,o=RN;try{RN=this,this.__initialized=!0,cle(s)?new s(i,{element:this}):s(i,{element:this})}finally{RN=o}}async disconnectedCallback(){if(await Promise.resolve(),this.isConnected)return;this.__propertyChangedCallbacks.length=0;let i=null;for(;i=this.__releaseCallbacks.pop();)i(this);delete this.__initialized,this.__released=!0}attributeChangedCallback(i,s,o){if(this.__initialized&&!this.__updating[i]&&(i=this.lookupProp(i),i in e)){if(o==null&&!this[i])return;this[i]=e[i].parse?U7(o):o}}lookupProp(i){if(e)return n.find(s=>i===s||i===e[s].attribute)}get renderRoot(){return this.shadowRoot||this.attachShadow({mode:"open"})}addReleaseCallback(i){this.__releaseCallbacks.push(i)}addPropertyChangedCallback(i){this.__propertyChangedCallbacks.push(i)}}}function xle(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function dle(t,e={},n={}){const{BaseElement:r=HTMLElement,extension:i}=n;return s=>{if(!t)throw new Error("tag is required to register a Component");let o=customElements.get(t);return o?(o.prototype.Component=s,o):(o=fle(r,sle(e)),o.prototype.Component=s,o.prototype.registeredTag=t,customElements.define(t,o,i),o)}}const hle=(t,e)=>t===e,ON=Symbol("solid-proxy"),ple=Symbol("solid-track"),m3={equals:hle};let z7=K7;const Kl=1,y3=2,Q7={owned:null,cleanups:null,context:null,owner:null};var Kt=null;let NN=null,gle=null,$n=null,Lr=null,Da=null,E3=0;function A3(t,e){const n=$n,r=Kt,i=t.length===0,s=e===void 0?r:e,o=i?Q7:{owned:null,cleanups:null,context:s?s.context:null,owner:s},u=i?t:()=>t(()=>_o(()=>_3(o)));Kt=o,$n=null;try{return N2(u,!0)}finally{$n=n,Kt=r}}function DN(t,e){e=e?Object.assign({},m3,e):m3;const n={value:t,observers:null,observerSlots:null,comparator:e.equals||void 0},r=i=>(typeof i=="function"&&(i=i(n.value)),X7(n,i));return[Y7.bind(n),r]}function Jl(t,e,n){const r=LN(t,e,!1,Kl);O2(r)}function FN(t,e,n){z7=Ale;const r=LN(t,e,!1,Kl),i=V7&&wN(V7);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),Da?Da.push(r):O2(r)}function Us(t,e,n){n=n?Object.assign({},m3,n):m3;const r=LN(t,e,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,O2(r),Y7.bind(r)}function _o(t){if($n===null)return t();const e=$n;$n=null;try{return t()}finally{$n=e}}function mle(t){return Kt===null||(Kt.cleanups===null?Kt.cleanups=[t]:Kt.cleanups.push(t)),t}function G7(t,e){const n=Symbol("context");return{id:n,Provider:vle(n),defaultValue:t}}function wN(t){return Kt&&Kt.context&&Kt.context[t.id]!==void 0?Kt.context[t.id]:t.defaultValue}function W7(t){const e=Us(t),n=Us(()=>IN(e()));return n.toArray=()=>{const r=n();return Array.isArray(r)?r:r!=null?[r]:[]},n}let V7;function Y7(){if(this.sources&&this.state)if(this.state===Kl)O2(this);else{const t=Lr;Lr=null,N2(()=>v3(this),!1),Lr=t}if($n){const t=this.observers?this.observers.length:0;$n.sources?($n.sources.push(this),$n.sourceSlots.push(t)):($n.sources=[this],$n.sourceSlots=[t]),this.observers?(this.observers.push($n),this.observerSlots.push($n.sources.length-1)):(this.observers=[$n],this.observerSlots=[$n.sources.length-1])}return this.value}function X7(t,e,n){let r=t.value;return(!t.comparator||!t.comparator(r,e))&&(t.value=e,t.observers&&t.observers.length&&N2(()=>{for(let i=0;i<t.observers.length;i+=1){const s=t.observers[i],o=NN&&NN.running;o&&NN.disposed.has(s),(o?!s.tState:!s.state)&&(s.pure?Lr.push(s):Da.push(s),s.observers&&J7(s)),o||(s.state=Kl)}if(Lr.length>1e6)throw Lr=[],new Error},!1)),e}function O2(t){if(!t.fn)return;_3(t);const e=E3;yle(t,t.value,e)}function yle(t,e,n){let r;const i=Kt,s=$n;$n=Kt=t;try{r=t.fn(e)}catch(o){return t.pure&&(t.state=Kl,t.owned&&t.owned.forEach(_3),t.owned=null),t.updatedAt=n+1,Z7(o)}finally{$n=s,Kt=i}(!t.updatedAt||t.updatedAt<=n)&&(t.updatedAt!=null&&"observers"in t?X7(t,r):t.value=r,t.updatedAt=n)}function LN(t,e,n,r=Kl,i){const s={fn:t,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:e,owner:Kt,context:Kt?Kt.context:null,pure:n};return Kt===null||Kt!==Q7&&(Kt.owned?Kt.owned.push(s):Kt.owned=[s]),s}function S3(t){if(t.state===0)return;if(t.state===y3)return v3(t);if(t.suspense&&_o(t.suspense.inFallback))return t.suspense.effects.push(t);const e=[t];for(;(t=t.owner)&&(!t.updatedAt||t.updatedAt<E3);)t.state&&e.push(t);for(let n=e.length-1;n>=0;n--)if(t=e[n],t.state===Kl)O2(t);else if(t.state===y3){const r=Lr;Lr=null,N2(()=>v3(t,e[0]),!1),Lr=r}}function N2(t,e){if(Lr)return t();let n=!1;e||(Lr=[]),Da?n=!0:Da=[],E3++;try{const r=t();return Ele(n),r}catch(r){n||(Da=null),Lr=null,Z7(r)}}function Ele(t){if(Lr&&(K7(Lr),Lr=null),t)return;const e=Da;Da=null,e.length&&N2(()=>z7(e),!1)}function K7(t){for(let e=0;e<t.length;e++)S3(t[e])}function Ale(t){let e,n=0;for(e=0;e<t.length;e++){const r=t[e];r.user?t[n++]=r:S3(r)}for(e=0;e<n;e++)S3(t[e])}function v3(t,e){t.state=0;for(let n=0;n<t.sources.length;n+=1){const r=t.sources[n];if(r.sources){const i=r.state;i===Kl?r!==e&&(!r.updatedAt||r.updatedAt<E3)&&S3(r):i===y3&&v3(r,e)}}}function J7(t){for(let e=0;e<t.observers.length;e+=1){const n=t.observers[e];n.state||(n.state=y3,n.pure?Lr.push(n):Da.push(n),n.observers&&J7(n))}}function _3(t){let e;if(t.sources)for(;t.sources.length;){const n=t.sources.pop(),r=t.sourceSlots.pop(),i=n.observers;if(i&&i.length){const s=i.pop(),o=n.observerSlots.pop();r<i.length&&(s.sourceSlots[o]=r,i[r]=s,n.observerSlots[r]=o)}}if(t.owned){for(e=t.owned.length-1;e>=0;e--)_3(t.owned[e]);t.owned=null}if(t.cleanups){for(e=t.cleanups.length-1;e>=0;e--)t.cleanups[e]();t.cleanups=null}t.state=0}function Sle(t){return t instanceof Error?t:new Error(typeof t=="string"?t:"Unknown error",{cause:t})}function Z7(t,e=Kt){throw Sle(t)}function IN(t){if(typeof t=="function"&&!t.length)return IN(t());if(Array.isArray(t)){const e=[];for(let n=0;n<t.length;n++){const r=IN(t[n]);Array.isArray(r)?e.push.apply(e,r):e.push(r)}return e}return t}function vle(t,e){return function(r){let i;return Jl(()=>i=_o(()=>(Kt.context={...Kt.context,[t]:r.value},W7(()=>r.children))),void 0),i}}const _le=Symbol("fallback");function eP(t){for(let e=0;e<t.length;e++)t[e]()}function Cle(t,e,n={}){let r=[],i=[],s=[],o=0,u=e.length>1?[]:null;return mle(()=>eP(s)),()=>{let a=t()||[],l,c;return a[ple],_o(()=>{let x=a.length,h,p,m,g,y,E,A,S,v;if(x===0)o!==0&&(eP(s),s=[],r=[],i=[],o=0,u&&(u=[])),n.fallback&&(r=[_le],i[0]=A3(C=>(s[0]=C,n.fallback())),o=1);else if(o===0){for(i=new Array(x),c=0;c<x;c++)r[c]=a[c],i[c]=A3(f);o=x}else{for(m=new Array(x),g=new Array(x),u&&(y=new Array(x)),E=0,A=Math.min(o,x);E<A&&r[E]===a[E];E++);for(A=o-1,S=x-1;A>=E&&S>=E&&r[A]===a[S];A--,S--)m[S]=i[A],g[S]=s[A],u&&(y[S]=u[A]);for(h=new Map,p=new Array(S+1),c=S;c>=E;c--)v=a[c],l=h.get(v),p[c]=l===void 0?-1:l,h.set(v,c);for(l=E;l<=A;l++)v=r[l],c=h.get(v),c!==void 0&&c!==-1?(m[c]=i[l],g[c]=s[l],u&&(y[c]=u[l]),c=p[c],h.set(v,c)):s[l]();for(c=E;c<x;c++)c in m?(i[c]=m[c],s[c]=g[c],u&&(u[c]=y[c],u[c](c))):i[c]=A3(f);i=i.slice(0,o=x),r=a.slice(0)}return i});function f(x){if(s[c]=x,u){const[h,p]=DN(c);return u[c]=p,e(a[c],h)}return e(a[c])}}}function kn(t,e){return _o(()=>t(e||{}))}function C3(){return!0}const ble={get(t,e,n){return e===ON?n:t.get(e)},has(t,e){return e===ON?!0:t.has(e)},set:C3,deleteProperty:C3,getOwnPropertyDescriptor(t,e){return{configurable:!0,enumerable:!0,get(){return t.get(e)},set:C3,deleteProperty:C3}},ownKeys(t){return t.keys()}};function BN(t){return(t=typeof t=="function"?t():t)?t:{}}function Tle(){for(let t=0,e=this.length;t<e;++t){const n=this[t]();if(n!==void 0)return n}}function Rle(...t){let e=!1;for(let o=0;o<t.length;o++){const u=t[o];e=e||!!u&&ON in u,t[o]=typeof u=="function"?(e=!0,Us(u)):u}if(e)return new Proxy({get(o){for(let u=t.length-1;u>=0;u--){const a=BN(t[u])[o];if(a!==void 0)return a}},has(o){for(let u=t.length-1;u>=0;u--)if(o in BN(t[u]))return!0;return!1},keys(){const o=[];for(let u=0;u<t.length;u++)o.push(...Object.keys(BN(t[u])));return[...new Set(o)]}},ble);const n={},r=Object.create(null);for(let o=t.length-1;o>=0;o--){const u=t[o];if(!u)continue;const a=Object.getOwnPropertyNames(u);for(let l=a.length-1;l>=0;l--){const c=a[l];if(c==="__proto__"||c==="constructor")continue;const f=Object.getOwnPropertyDescriptor(u,c);if(!r[c])r[c]=f.get?{enumerable:!0,configurable:!0,get:Tle.bind(n[c]=[f.get.bind(u)])}:f.value!==void 0?f:void 0;else{const x=n[c];x&&(f.get?x.push(f.get.bind(u)):f.value!==void 0&&x.push(()=>f.value))}}}const i={},s=Object.keys(r);for(let o=s.length-1;o>=0;o--){const u=s[o],a=r[u];a&&a.get?Object.defineProperty(i,u,a):i[u]=a?a.value:void 0}return i}const tP=t=>`Stale read from <${t}>.`;function Ole(t){const e="fallback"in t&&{fallback:()=>t.fallback};return Us(Cle(()=>t.each,t.children,e||void 0))}function Nle(t){const e=t.keyed,n=Us(()=>t.when,void 0,{equals:(r,i)=>e?r===i:!r==!i});return Us(()=>{const r=n();if(r){const i=t.children;return typeof i=="function"&&i.length>0?_o(()=>i(e?r:()=>{if(!_o(n))throw tP("Show");return t.when})):i}return t.fallback},void 0,void 0)}function nP(t){let e=!1;const n=(s,o)=>(e?s[1]===o[1]:!s[1]==!o[1])&&s[2]===o[2],r=W7(()=>t.children),i=Us(()=>{let s=r();Array.isArray(s)||(s=[s]);for(let o=0;o<s.length;o++){const u=s[o].when;if(u)return e=!!s[o].keyed,[o,u,s[o]]}return[-1]},void 0,{equals:n});return Us(()=>{const[s,o,u]=i();if(s<0)return t.fallback;const a=u.children;return typeof a=="function"&&a.length>0?_o(()=>a(e?o:()=>{if(_o(i)[0]!==s)throw tP("Match");return u.when})):a},void 0,void 0)}function $N(t){return t}function Dle(t,e,n){let r=n.length,i=e.length,s=r,o=0,u=0,a=e[i-1].nextSibling,l=null;for(;o<i||u<s;){if(e[o]===n[u]){o++,u++;continue}for(;e[i-1]===n[s-1];)i--,s--;if(i===o){const c=s<r?u?n[u-1].nextSibling:n[s-u]:a;for(;u<s;)t.insertBefore(n[u++],c)}else if(s===u)for(;o<i;)(!l||!l.has(e[o]))&&e[o].remove(),o++;else if(e[o]===n[s-1]&&n[u]===e[i-1]){const c=e[--i].nextSibling;t.insertBefore(n[u++],e[o++].nextSibling),t.insertBefore(n[--s],c),e[i]=n[s]}else{if(!l){l=new Map;let f=u;for(;f<s;)l.set(n[f],f++)}const c=l.get(e[o]);if(c!=null)if(u<c&&c<s){let f=o,x=1,h;for(;++f<i&&f<s&&!((h=l.get(e[f]))==null||h!==c+x);)x++;if(x>c-u){const p=e[o];for(;u<c;)t.insertBefore(n[u++],p)}else t.replaceChild(n[u++],e[o++])}else o++;else e[o++].remove()}}}function qc(t,e,n){let r;const i=()=>{const o=document.createElement("template");return o.innerHTML=t,n?o.content.firstChild.firstChild:o.content.firstChild},s=e?()=>_o(()=>document.importNode(r||(r=i()),!0)):()=>(r||(r=i())).cloneNode(!0);return s.cloneNode=s,s}function Fle(t,e,n){n==null?t.removeAttribute(e):t.setAttribute(e,n)}function wle(t,e,n){if(!e)return n?Fle(t,"style"):e;const r=t.style;if(typeof e=="string")return r.cssText=e;typeof n=="string"&&(r.cssText=n=void 0),n||(n={}),e||(e={});let i,s;for(s in n)e[s]==null&&r.removeProperty(s),delete n[s];for(s in e)i=e[s],i!==n[s]&&(r.setProperty(s,i),n[s]=i);return n}function Lle(t,e,n){return _o(()=>t(e,n))}function Fa(t,e,n,r){if(n!==void 0&&!r&&(r=[]),typeof e!="function")return b3(t,e,r,n);Jl(i=>b3(t,e(),i,n),r)}function b3(t,e,n,r,i){for(;typeof n=="function";)n=n();if(e===n)return n;const s=typeof e,o=r!==void 0;if(t=o&&n[0]&&n[0].parentNode||t,s==="string"||s==="number")if(s==="number"&&(e=e.toString()),o){let u=n[0];u&&u.nodeType===3?u.data!==e&&(u.data=e):u=document.createTextNode(e),n=vd(t,n,r,u)}else n!==""&&typeof n=="string"?n=t.firstChild.data=e:n=t.textContent=e;else if(e==null||s==="boolean")n=vd(t,n,r);else{if(s==="function")return Jl(()=>{let u=e();for(;typeof u=="function";)u=u();n=b3(t,u,n,r)}),()=>n;if(Array.isArray(e)){const u=[],a=n&&Array.isArray(n);if(kN(u,e,n,i))return Jl(()=>n=b3(t,u,n,r,!0)),()=>n;if(u.length===0){if(n=vd(t,n,r),o)return n}else a?n.length===0?rP(t,u,r):Dle(t,n,u):(n&&vd(t),rP(t,u));n=u}else if(e.nodeType){if(Array.isArray(n)){if(o)return n=vd(t,n,r,e);vd(t,n,null,e)}else n==null||n===""||!t.firstChild?t.appendChild(e):t.replaceChild(e,t.firstChild);n=e}}return n}function kN(t,e,n,r){let i=!1;for(let s=0,o=e.length;s<o;s++){let u=e[s],a=n&&n[t.length],l;if(!(u==null||u===!0||u===!1))if((l=typeof u)=="object"&&u.nodeType)t.push(u);else if(Array.isArray(u))i=kN(t,u,a)||i;else if(l==="function")if(r){for(;typeof u=="function";)u=u();i=kN(t,Array.isArray(u)?u:[u],Array.isArray(a)?a:[a])||i}else t.push(u),i=!0;else{const c=String(u);a&&a.nodeType===3&&a.data===c?t.push(a):t.push(document.createTextNode(c))}}return i}function rP(t,e,n=null){for(let r=0,i=e.length;r<i;r++)t.insertBefore(e[r],n)}function vd(t,e,n,r){if(n===void 0)return t.textContent="";const i=r||document.createTextNode("");if(e.length){let s=!1;for(let o=e.length-1;o>=0;o--){const u=e[o];if(i!==u){const a=u.parentNode===t;!s&&!o?a?t.replaceChild(i,u):t.insertBefore(i,n):a&&u.remove()}else s=!0}}else t.insertBefore(i,n);return[i]}function Ile(t){const e=Object.keys(t),n={};for(let r=0;r<e.length;r++){const[i,s]=DN(t[e[r]]);Object.defineProperty(n,e[r],{get:i,set(o){s(()=>o)}})}return n}function Ble(t){if(t.assignedSlot&&t.assignedSlot._$owner)return t.assignedSlot._$owner;let e=t.parentNode;for(;e&&!e._$owner&&!(e.assignedSlot&&e.assignedSlot._$owner);)e=e.parentNode;return e&&e.assignedSlot?e.assignedSlot._$owner:t._$owner}function $le(t){return(e,n)=>{const{element:r}=n;return A3(i=>{const s=Ile(e);r.addPropertyChangedCallback((u,a)=>s[u]=a),r.addReleaseCallback(()=>{r.renderRoot.textContent="",i()});const o=t(s,n);return Fa(r.renderRoot,o)},Ble(r))}}var N=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function PN(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function kle(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var iP={},T3={},ve={};Object.defineProperty(ve,"__esModule",{value:!0}),ve.overload=ve.minAnalytic=ve.minAggregate=ve.minScalar=ve.maxAnalytic=ve.maxUngroupedAggregate=ve.anyExprType=ve.maxAggregate=ve.maxScalar=ve.makeParam=ve.param=ve.params=ve.literal=ve.output=ve.constant=ve.sql=ve.sqlFragment=ve.spread=ve.arg=void 0;function sP(t){return{type:"function_parameter",name:t}}ve.arg=sP;function Ple(t){return{type:"spread",e:[t]}}ve.spread=Ple;function Mle(...t){return{type:"sql_expression",e:t}}ve.sqlFragment=Mle;function jle(t,...e){return[{type:"sql_expression",e:Ule([...t],e)}]}ve.sql=jle;function Ule(t,e){const n=[];for(let r=0;r<t.length;r++)n.push(t[r]),r<e.length&&n.push(e[r]);return n}function qle(t){return{...t,evalSpace:"constant"}}ve.constant=qle;function Hle(t){return{...t,evalSpace:"output"}}ve.output=Hle;function zle(t){return{...t,evalSpace:"literal"}}ve.literal=zle;function Qle(t,...e){return{name:t,isVariadic:!0,allowedTypes:e}}ve.params=Qle;function oP(t,...e){return{name:t,isVariadic:!1,allowedTypes:e}}ve.param=oP;function Gle(t,...e){return{param:oP(t,...e),arg:sP(t)}}ve.makeParam=Gle;function Wle(t){return{dataType:t,expressionType:"scalar",evalSpace:"input"}}ve.maxScalar=Wle;function Vle(t){return{dataType:t,expressionType:"aggregate",evalSpace:"input"}}ve.maxAggregate=Vle;function Yle(t){return{dataType:t,expressionType:void 0,evalSpace:"input"}}ve.anyExprType=Yle;function Xle(t){return{dataType:t,expressionType:"ungrouped_aggregate",evalSpace:"input"}}ve.maxUngroupedAggregate=Xle;function Kle(t){return{dataType:t,expressionType:"aggregate_analytic",evalSpace:"input"}}ve.maxAnalytic=Kle;function Jle(t){return{dataType:t,expressionType:"scalar",evalSpace:"input"}}ve.minScalar=Jle;function Zle(t){return{dataType:t,expressionType:"aggregate",evalSpace:"input"}}ve.minAggregate=Zle;function e0e(t){return{dataType:t,expressionType:"scalar_analytic",evalSpace:"input"}}ve.minAnalytic=e0e;function t0e(t,e,n,r){return{returnType:t,params:e,e:n,needsWindowOrderBy:r==null?void 0:r.needsWindowOrderBy,between:r==null?void 0:r.between,isSymmetric:r==null?void 0:r.isSymmetric,supportsOrderBy:r==null?void 0:r.supportsOrderBy,defaultOrderByArgIndex:r==null?void 0:r.defaultOrderByArgIndex,supportsLimit:r==null?void 0:r.supportsLimit}}ve.overload=t0e;var Hc={},ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.isIndexSegment=ne.isRawSegment=ne.isSamplingEnable=ne.isSamplingPercent=ne.isSamplingRows=ne.isQuerySegment=ne.isProjectSegment=ne.isPartialSegment=ne.isReduceSegment=ne.refIsStructDef=ne.isByExpression=ne.isByName=ne.ValueType=ne.isExtractUnit=ne.isTimestampUnit=ne.isDateUnit=ne.FieldIsIntrinsic=ne.isCastType=ne.isAtomicFieldType=ne.isTimeFieldType=ne.hasExpression=ne.maxOfExpressionTypes=ne.maxExpressionType=ne.isExpressionTypeLEQ=ne.expressionIsAnalytic=ne.expressionIsCalculation=ne.expressionInvolvesAggregate=ne.expressionIsUngroupedAggregate=ne.expressionIsAggregate=ne.expressionIsScalar=ne.mkExpr=ne.isApplyFragment=ne.isApplyValue=ne.isParameterFragment=ne.isSourceReferenceFragment=ne.isSqlStringFragment=ne.isFieldFragment=ne.isSpreadFragment=ne.isSQLExpressionFragment=ne.isFunctionCallFragment=ne.isFunctionParameterFragment=ne.isUngroupFragment=ne.isAsymmetricFragment=ne.isAggregateFragment=ne.isDialectFragment=ne.isFilterFragment=ne.isOutputFieldFragment=ne.paramHasValue=ne.isConditionParameter=ne.isValueParameter=void 0,ne.isValueDate=ne.isValueTimestamp=ne.isValueBoolean=ne.isValueNumber=ne.isValueString=ne.isMeasureLike=ne.getPhysicalFields=ne.getDimensions=ne.isPhysical=ne.isDimensional=ne.isAtomicField=ne.isTurtleDef=ne.getIdentifier=ne.isFieldStructDef=ne.isFieldTimeBased=ne.isFieldTypeDef=ne.isSQLBlockStruct=ne.mergeEvalSpaces=ne.isLiteral=ne.isSQLFragment=ne.isJoinOn=ne.isMatrixOperation=void 0;function uP(t){return t.value!==void 0}ne.isValueParameter=uP;function n0e(t){return t.condition!==void 0}ne.isConditionParameter=n0e;function r0e(t){return uP(t)||t.condition!==null}ne.paramHasValue=r0e;function i0e(t){return(t==null?void 0:t.type)==="outputField"}ne.isOutputFieldFragment=i0e;function s0e(t){return(t==null?void 0:t.type)==="filterExpression"}ne.isFilterFragment=s0e;function o0e(t){return(t==null?void 0:t.type)==="dialect"}ne.isDialectFragment=o0e;function aP(t){return(t==null?void 0:t.type)==="aggregate"}ne.isAggregateFragment=aP;function u0e(t){return aP(t)&&["sum","avg","count"].includes(t.function)}ne.isAsymmetricFragment=u0e;function a0e(t){const e=t==null?void 0:t.type;return e==="all"||e==="exclude"}ne.isUngroupFragment=a0e;function l0e(t){return(t==null?void 0:t.type)==="function_parameter"}ne.isFunctionParameterFragment=l0e;function c0e(t){return(t==null?void 0:t.type)==="function_call"}ne.isFunctionCallFragment=c0e;function f0e(t){return(t==null?void 0:t.type)==="sql_expression"}ne.isSQLExpressionFragment=f0e;function x0e(t){return(t==null?void 0:t.type)==="spread"}ne.isSpreadFragment=x0e;function d0e(t){return(t==null?void 0:t.type)==="field"}ne.isFieldFragment=d0e;function h0e(t){return(t==null?void 0:t.type)==="sql-string"}ne.isSqlStringFragment=h0e;function p0e(t){return(t==null?void 0:t.type)==="source-reference"}ne.isSourceReferenceFragment=p0e;function g0e(t){return(t==null?void 0:t.type)==="parameter"}ne.isParameterFragment=g0e;function m0e(t){return(t==null?void 0:t.type)==="applyVal"}ne.isApplyValue=m0e;function y0e(t){return(t==null?void 0:t.type)==="apply"}ne.isApplyFragment=y0e;function E0e(t,...e){const n=[];let r;for(r=0;r<e.length;r++){const i=e[r];t[r].length>0&&n.push(t[r]),typeof i=="string"?n.push(i):n.push(...i)}return t[r].length>0&&n.push(t[r]),n}ne.mkExpr=E0e;function A0e(t){return t===void 0||t==="scalar"}ne.expressionIsScalar=A0e;function S0e(t){return t==="aggregate"||t==="ungrouped_aggregate"}ne.expressionIsAggregate=S0e;function v0e(t){return t==="ungrouped_aggregate"}ne.expressionIsUngroupedAggregate=v0e;function _0e(t){return t==="aggregate"||t==="ungrouped_aggregate"||t==="aggregate_analytic"}ne.expressionInvolvesAggregate=_0e;function C0e(t){return t==="aggregate"||t==="scalar_analytic"||t==="aggregate_analytic"||t==="ungrouped_aggregate"}ne.expressionIsCalculation=C0e;function b0e(t){return t==="aggregate_analytic"||t==="scalar_analytic"}ne.expressionIsAnalytic=b0e;function lP(t){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[t]}function T0e(t,e){return t===e||lP(t)<lP(e)}ne.isExpressionTypeLEQ=T0e;function cP(t,e){let n="scalar";return(t==="aggregate"||e==="aggregate")&&(n="aggregate"),(t==="ungrouped_aggregate"||e==="ungrouped_aggregate")&&(n="ungrouped_aggregate"),(t==="scalar_analytic"||e==="scalar_analytic")&&(n="scalar_analytic"),(t==="aggregate_analytic"||e==="aggregate_analytic")&&(n="aggregate_analytic"),(t==="scalar_analytic"&&e==="aggregate"||t==="aggregate"&&e==="scalar_analytic")&&(n="aggregate_analytic"),n}ne.maxExpressionType=cP;function R0e(t){return t.reduce(cP,"scalar")}ne.maxOfExpressionTypes=R0e;function fP(t){return t.e!==void 0}ne.hasExpression=fP;function O0e(t){return t==="date"||t==="timestamp"}ne.isTimeFieldType=O0e;function MN(t){return["string","number","date","timestamp","boolean","json","unsupported","error"].includes(t)}ne.isAtomicFieldType=MN;function N0e(t){return["string","number","date","timestamp","boolean","json"].includes(t)}ne.isCastType=N0e;function D0e(t){return MN(t.type)&&!fP(t)?!0:t.type==="struct"&&(t.structSource.type==="inline"||t.structSource.type==="nested")}ne.FieldIsIntrinsic=D0e;function xP(t){return["day","week","month","quarter","year"].includes(t)}ne.isDateUnit=xP;function dP(t){return xP(t)||["hour","minute","second"].includes(t)}ne.isTimestampUnit=dP;function F0e(t){return dP(t)||t==="day_of_week"||t==="day_of_year"}ne.isExtractUnit=F0e;var hP;(function(t){t.Date="date",t.Timestamp="timestamp",t.Number="number",t.String="string"})(hP||(ne.ValueType=hP={}));function w0e(t){return t===void 0?!1:t.by==="name"}ne.isByName=w0e;function L0e(t){return t===void 0?!1:t.by==="name"}ne.isByExpression=L0e;function I0e(t){return typeof t!="string"&&t.type==="struct"}ne.refIsStructDef=I0e;function pP(t){return t.type==="reduce"}ne.isReduceSegment=pP;function B0e(t){return t.type==="partial"}ne.isPartialSegment=B0e;function gP(t){return t.type==="project"}ne.isProjectSegment=gP;function $0e(t){return gP(t)||pP(t)}ne.isQuerySegment=$0e;function k0e(t){return t.rows!==void 0}ne.isSamplingRows=k0e;function P0e(t){return t.percent!==void 0}ne.isSamplingPercent=P0e;function M0e(t){return t.enable!==void 0}ne.isSamplingEnable=M0e;function j0e(t){return t.type==="raw"}ne.isRawSegment=j0e;function U0e(t){return t.type==="index"}ne.isIndexSegment=U0e;function q0e(t){return["left","right","full","inner"].includes(t)}ne.isMatrixOperation=q0e;function H0e(t){return["one","many","cross"].includes(t.type)}ne.isJoinOn=H0e;function z0e(t){return t.sql!==void 0}ne.isSQLFragment=z0e;function Q0e(t){return t==="literal"}ne.isLiteral=Q0e;function G0e(...t){return t.every(e=>e==="constant"||e==="literal")?"constant":t.every(e=>e==="output"||e==="constant"||e==="literal")?"output":"input"}ne.mergeEvalSpaces=G0e;function W0e(t){const e=t.structSource;return e.type==="sql"&&e.method==="subquery"}ne.isSQLBlockStruct=W0e;function mP(t){return t.type==="string"||t.type==="date"||t.type==="number"||t.type==="timestamp"||t.type==="boolean"||t.type==="json"}ne.isFieldTypeDef=mP;function V0e(t){return t.type==="date"||t.type==="timestamp"}ne.isFieldTimeBased=V0e;function yP(t){return t.type==="struct"}ne.isFieldStructDef=yP;function Y0e(t){return t.as!==void 0?t.as:t.name}ne.getIdentifier=Y0e;function X0e(t){return t.type==="turtle"}ne.isTurtleDef=X0e;function K0e(t){return MN(t.type)}ne.isAtomicField=K0e;function EP(t){var e;return"resultMetadata"in t?((e=t.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="dimension":!1}ne.isDimensional=EP;function AP(t){return mP(t)&&t.e===void 0||yP(t)&&(t.structSource.type==="nested"||t.structSource.type==="inline")}ne.isPhysical=AP;function J0e(t){return t.fields.filter(EP)}ne.getDimensions=J0e;function Z0e(t){return t.fields.filter(AP)}ne.getPhysicalFields=Z0e;function ece(t){var e,n;return"resultMetadata"in t?((e=t.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"||((n=t.resultMetadata)===null||n===void 0?void 0:n.fieldKind)==="struct":!1}ne.isMeasureLike=ece;function tce(t,e){return e.type==="string"}ne.isValueString=tce;function nce(t,e){return e.type==="number"}ne.isValueNumber=nce;function rce(t,e){return e.type==="boolean"}ne.isValueBoolean=rce;function ice(t,e){return e.type==="timestamp"}ne.isValueTimestamp=ice;function sce(t,e){return e.type==="date"}ne.isValueDate=sce,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Dialect=t.qtz=t.inDays=t.dayIndex=t.isDialectFieldStruct=void 0;const e=ne;function n(u){return u.type==="struct"}t.isDialectFieldStruct=n;const r=["microsecond","millisecond","second","minute","hour","day","week","month","quarter","year"];t.dayIndex=r.indexOf("day");function i(u){return r.indexOf(u)>=t.dayIndex}t.inDays=i;function s(u){const a=u.queryTimezone;if(!(a===void 0||a===u.systemTimezone))return a}t.qtz=s;class o{constructor(){this.cantPartitionWindowFunctionsOnExpressions=!1,this.supportsPipelinesInViews=!0,this.supportsArraysInData=!0,this.readsNestedData=!0,this.orderByClause="ordinal"}sqlFinalStage(a,l){throw new Error("Dialect has no final Stage but called Anyway")}sqlDateToString(a){return this.castToString(`DATE(${a})`)}ignoreInProject(a){return!1}sqlLiteralNumber(a){return a}dialectExpr(a,l){switch(l.function){case"now":return this.sqlNow();case"timeDiff":return this.sqlMeasureTime(l.left,l.right,l.units);case"delta":return this.sqlAlterTime(l.op,l.base,l.delta,l.units);case"trunc":return this.sqlTrunc(a,l.expr,l.units);case"extract":return this.sqlExtract(a,l.expr,l.units);case"cast":return this.sqlCast(a,l);case"regexpMatch":return this.sqlRegexpMatch(l.expr,l.regexp);case"div":return this.divisionIsInteger?(0,e.mkExpr)`${l.numerator}*1.0/${l.denominator}`:(0,e.mkExpr)`${l.numerator}/${l.denominator}`;case"timeLiteral":return[this.sqlLiteralTime(a,l.literal,l.literalType,l.timezone)];case"stringLiteral":return[this.sqlLiteralString(l.literal)];case"numberLiteral":return[this.sqlLiteralNumber(l.literal)];case"regexpLiteral":return[this.sqlLiteralRegexp(l.literal)]}}sqlSumDistinct(a,l,c){return"sqlSumDistinct called but not implemented"}sqlAggDistinct(a,l,c){return"sqlAggDistinct called but not implemented"}sqlSampleTable(a,l){if(l!==void 0)throw new Error(`Sampling is not supported on dialect ${this.name}.`);return a}sqlOrderBy(a){return`ORDER BY ${a.join(",")}`}sqlTzStr(a){return`"${a.queryTimezone}"`}}t.Dialect=o}(Hc);var jN={},D2={},Gt={},R3,oce=new Uint8Array(16);function SP(){if(!R3&&(R3=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!R3))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return R3(oce)}const uce=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function O3(t){return typeof t=="string"&&uce.test(t)}for(var Sr=[],UN=0;UN<256;++UN)Sr.push((UN+256).toString(16).substr(1));function N3(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Sr[t[e+0]]+Sr[t[e+1]]+Sr[t[e+2]]+Sr[t[e+3]]+"-"+Sr[t[e+4]]+Sr[t[e+5]]+"-"+Sr[t[e+6]]+Sr[t[e+7]]+"-"+Sr[t[e+8]]+Sr[t[e+9]]+"-"+Sr[t[e+10]]+Sr[t[e+11]]+Sr[t[e+12]]+Sr[t[e+13]]+Sr[t[e+14]]+Sr[t[e+15]]).toLowerCase();if(!O3(n))throw TypeError("Stringified UUID is invalid");return n}var vP,qN,HN=0,zN=0;function ace(t,e,n){var r=e&&n||0,i=e||new Array(16);t=t||{};var s=t.node||vP,o=t.clockseq!==void 0?t.clockseq:qN;if(s==null||o==null){var u=t.random||(t.rng||SP)();s==null&&(s=vP=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),o==null&&(o=qN=(u[6]<<8|u[7])&16383)}var a=t.msecs!==void 0?t.msecs:Date.now(),l=t.nsecs!==void 0?t.nsecs:zN+1,c=a-HN+(l-zN)/1e4;if(c<0&&t.clockseq===void 0&&(o=o+1&16383),(c<0||a>HN)&&t.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");HN=a,zN=l,qN=o,a+=122192928e5;var f=((a&268435455)*1e4+l)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=f&255;var x=a/4294967296*1e4&268435455;i[r++]=x>>>8&255,i[r++]=x&255,i[r++]=x>>>24&15|16,i[r++]=x>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var h=0;h<6;++h)i[r+h]=s[h];return e||N3(i)}function _P(t){if(!O3(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=e&255,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=e&255,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=e&255,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=e&255,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=e&255,n}function lce(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var cce="6ba7b810-9dad-11d1-80b4-00c04fd430c8",fce="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function CP(t,e,n){function r(i,s,o,u){if(typeof i=="string"&&(i=lce(i)),typeof s=="string"&&(s=_P(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+i.length);if(a.set(s),a.set(i,s.length),a=n(a),a[6]=a[6]&15|e,a[8]=a[8]&63|128,o){u=u||0;for(var l=0;l<16;++l)o[u+l]=a[l];return o}return N3(a)}try{r.name=t}catch{}return r.DNS=cce,r.URL=fce,r}function xce(t){if(typeof t=="string"){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return dce(hce(pce(t),t.length*8))}function dce(t){for(var e=[],n=t.length*32,r="0123456789abcdef",i=0;i<n;i+=8){var s=t[i>>5]>>>i%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);e.push(o)}return e}function bP(t){return(t+64>>>9<<4)+14+1}function hce(t,e){t[e>>5]|=128<<e%32,t[bP(e)-1]=e;for(var n=1732584193,r=-271733879,i=-1732584194,s=271733878,o=0;o<t.length;o+=16){var u=n,a=r,l=i,c=s;n=Ir(n,r,i,s,t[o],7,-680876936),s=Ir(s,n,r,i,t[o+1],12,-389564586),i=Ir(i,s,n,r,t[o+2],17,606105819),r=Ir(r,i,s,n,t[o+3],22,-1044525330),n=Ir(n,r,i,s,t[o+4],7,-176418897),s=Ir(s,n,r,i,t[o+5],12,1200080426),i=Ir(i,s,n,r,t[o+6],17,-1473231341),r=Ir(r,i,s,n,t[o+7],22,-45705983),n=Ir(n,r,i,s,t[o+8],7,1770035416),s=Ir(s,n,r,i,t[o+9],12,-1958414417),i=Ir(i,s,n,r,t[o+10],17,-42063),r=Ir(r,i,s,n,t[o+11],22,-1990404162),n=Ir(n,r,i,s,t[o+12],7,1804603682),s=Ir(s,n,r,i,t[o+13],12,-40341101),i=Ir(i,s,n,r,t[o+14],17,-1502002290),r=Ir(r,i,s,n,t[o+15],22,1236535329),n=Br(n,r,i,s,t[o+1],5,-165796510),s=Br(s,n,r,i,t[o+6],9,-1069501632),i=Br(i,s,n,r,t[o+11],14,643717713),r=Br(r,i,s,n,t[o],20,-373897302),n=Br(n,r,i,s,t[o+5],5,-701558691),s=Br(s,n,r,i,t[o+10],9,38016083),i=Br(i,s,n,r,t[o+15],14,-660478335),r=Br(r,i,s,n,t[o+4],20,-405537848),n=Br(n,r,i,s,t[o+9],5,568446438),s=Br(s,n,r,i,t[o+14],9,-1019803690),i=Br(i,s,n,r,t[o+3],14,-187363961),r=Br(r,i,s,n,t[o+8],20,1163531501),n=Br(n,r,i,s,t[o+13],5,-1444681467),s=Br(s,n,r,i,t[o+2],9,-51403784),i=Br(i,s,n,r,t[o+7],14,1735328473),r=Br(r,i,s,n,t[o+12],20,-1926607734),n=$r(n,r,i,s,t[o+5],4,-378558),s=$r(s,n,r,i,t[o+8],11,-2022574463),i=$r(i,s,n,r,t[o+11],16,1839030562),r=$r(r,i,s,n,t[o+14],23,-35309556),n=$r(n,r,i,s,t[o+1],4,-1530992060),s=$r(s,n,r,i,t[o+4],11,1272893353),i=$r(i,s,n,r,t[o+7],16,-155497632),r=$r(r,i,s,n,t[o+10],23,-1094730640),n=$r(n,r,i,s,t[o+13],4,681279174),s=$r(s,n,r,i,t[o],11,-358537222),i=$r(i,s,n,r,t[o+3],16,-722521979),r=$r(r,i,s,n,t[o+6],23,76029189),n=$r(n,r,i,s,t[o+9],4,-640364487),s=$r(s,n,r,i,t[o+12],11,-421815835),i=$r(i,s,n,r,t[o+15],16,530742520),r=$r(r,i,s,n,t[o+2],23,-995338651),n=kr(n,r,i,s,t[o],6,-198630844),s=kr(s,n,r,i,t[o+7],10,1126891415),i=kr(i,s,n,r,t[o+14],15,-1416354905),r=kr(r,i,s,n,t[o+5],21,-57434055),n=kr(n,r,i,s,t[o+12],6,1700485571),s=kr(s,n,r,i,t[o+3],10,-1894986606),i=kr(i,s,n,r,t[o+10],15,-1051523),r=kr(r,i,s,n,t[o+1],21,-2054922799),n=kr(n,r,i,s,t[o+8],6,1873313359),s=kr(s,n,r,i,t[o+15],10,-30611744),i=kr(i,s,n,r,t[o+6],15,-1560198380),r=kr(r,i,s,n,t[o+13],21,1309151649),n=kr(n,r,i,s,t[o+4],6,-145523070),s=kr(s,n,r,i,t[o+11],10,-1120210379),i=kr(i,s,n,r,t[o+2],15,718787259),r=kr(r,i,s,n,t[o+9],21,-343485551),n=Zl(n,u),r=Zl(r,a),i=Zl(i,l),s=Zl(s,c)}return[n,r,i,s]}function pce(t){if(t.length===0)return[];for(var e=t.length*8,n=new Uint32Array(bP(e)),r=0;r<e;r+=8)n[r>>5]|=(t[r/8]&255)<<r%32;return n}function Zl(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function gce(t,e){return t<<e|t>>>32-e}function D3(t,e,n,r,i,s){return Zl(gce(Zl(Zl(e,t),Zl(r,s)),i),n)}function Ir(t,e,n,r,i,s,o){return D3(e&n|~e&r,t,e,i,s,o)}function Br(t,e,n,r,i,s,o){return D3(e&r|n&~r,t,e,i,s,o)}function $r(t,e,n,r,i,s,o){return D3(e^n^r,t,e,i,s,o)}function kr(t,e,n,r,i,s,o){return D3(n^(e|~r),t,e,i,s,o)}var mce=CP("v3",48,xce);const yce=mce;function Ece(t,e,n){t=t||{};var r=t.random||(t.rng||SP)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(var i=0;i<16;++i)e[n+i]=r[i];return e}return N3(r)}function Ace(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:return e^n^r;case 2:return e&n^e&r^n&r;case 3:return e^n^r}}function QN(t,e){return t<<e|t>>>32-e}function Sce(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var r=unescape(encodeURIComponent(t));t=[];for(var i=0;i<r.length;++i)t.push(r.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var s=t.length/4+2,o=Math.ceil(s/16),u=new Array(o),a=0;a<o;++a){for(var l=new Uint32Array(16),c=0;c<16;++c)l[c]=t[a*64+c*4]<<24|t[a*64+c*4+1]<<16|t[a*64+c*4+2]<<8|t[a*64+c*4+3];u[a]=l}u[o-1][14]=(t.length-1)*8/Math.pow(2,32),u[o-1][14]=Math.floor(u[o-1][14]),u[o-1][15]=(t.length-1)*8&4294967295;for(var f=0;f<o;++f){for(var x=new Uint32Array(80),h=0;h<16;++h)x[h]=u[f][h];for(var p=16;p<80;++p)x[p]=QN(x[p-3]^x[p-8]^x[p-14]^x[p-16],1);for(var m=n[0],g=n[1],y=n[2],E=n[3],A=n[4],S=0;S<80;++S){var v=Math.floor(S/20),C=QN(m,5)+Ace(v,g,y,E)+A+e[v]+x[S]>>>0;A=E,E=y,y=QN(g,30)>>>0,g=m,m=C}n[0]=n[0]+m>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+y>>>0,n[3]=n[3]+E>>>0,n[4]=n[4]+A>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var vce=CP("v5",80,Sce);const _ce=vce,Cce="00000000-0000-0000-0000-000000000000";function bce(t){if(!O3(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const TP=kle(Object.freeze(Object.defineProperty({__proto__:null,NIL:Cce,parse:_P,stringify:N3,v1:ace,v3:yce,v4:Ece,v5:_ce,validate:O3,version:bce},Symbol.toStringTag,{value:"Module"})));Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.range=Gt.joinWith=Gt.exprWalk=Gt.exprMap=Gt.generateHash=Gt.AndChain=Gt.generateSQLStringLiteral=Gt.indent=void 0;const Tce=TP;function Rce(t){const e=/(^|\n)/g,n=/\n {2}$/;return t.replace(e,"$1 ").replace(n,`
|
|
1
|
+
(function(g3){typeof define=="function"&&define.amd?define(g3):g3()})(function(){"use strict";function g3(t){return Object.keys(t).reduce((n,r)=>{const i=t[r];return n[r]=Object.assign({},i),H7(i.value)&&!lle(i.value)&&!Array.isArray(i.value)&&(n[r].value=Object.assign({},i.value)),Array.isArray(i.value)&&(n[r].value=i.value.slice(0)),n},{})}function sle(t){return t?Object.keys(t).reduce((n,r)=>{const i=t[r];return n[r]=H7(i)&&"value"in i?i:{value:i},n[r].attribute||(n[r].attribute=ale(r)),n[r].parse="parse"in n[r]?n[r].parse:typeof n[r].value!="string",n},{}):{}}function ole(t){return Object.keys(t).reduce((n,r)=>(n[r]=t[r].value,n),{})}function ule(t,e){const n=g3(e);return Object.keys(e).forEach(i=>{const s=n[i],o=t.getAttribute(s.attribute),u=t[i];o&&(s.value=s.parse?U7(o):o),u!=null&&(s.value=Array.isArray(u)?u.slice(0):u),s.reflect&&q7(t,s.attribute,s.value),Object.defineProperty(t,i,{get(){return s.value},set(a){const l=s.value;s.value=a,s.reflect&&q7(this,s.attribute,s.value);for(let c=0,f=this.__propertyChangedCallbacks.length;c<f;c++)this.__propertyChangedCallbacks[c](i,a,l)},enumerable:!0,configurable:!0})}),n}function U7(t){if(t)try{return JSON.parse(t)}catch{return t}}function q7(t,e,n){if(n==null||n===!1)return t.removeAttribute(e);let r=JSON.stringify(n);t.__updating[e]=!0,r==="true"&&(r=""),t.setAttribute(e,r),Promise.resolve().then(()=>delete t.__updating[e])}function ale(t){return t.replace(/\.?([A-Z]+)/g,(e,n)=>"-"+n.toLowerCase()).replace("_","-").replace(/^-/,"")}function H7(t){return t!=null&&(typeof t=="object"||typeof t=="function")}function lle(t){return Object.prototype.toString.call(t)==="[object Function]"}function cle(t){return typeof t=="function"&&t.toString().indexOf("class")===0}let RN;function fle(t,e){const n=Object.keys(e);return class extends t{static get observedAttributes(){return n.map(i=>e[i].attribute)}constructor(){super(),this.__initialized=!1,this.__released=!1,this.__releaseCallbacks=[],this.__propertyChangedCallbacks=[],this.__updating={},this.props={}}connectedCallback(){if(this.__initialized)return;this.__releaseCallbacks=[],this.__propertyChangedCallbacks=[],this.__updating={},this.props=ule(this,e);const i=ole(this.props),s=this.Component,o=RN;try{RN=this,this.__initialized=!0,cle(s)?new s(i,{element:this}):s(i,{element:this})}finally{RN=o}}async disconnectedCallback(){if(await Promise.resolve(),this.isConnected)return;this.__propertyChangedCallbacks.length=0;let i=null;for(;i=this.__releaseCallbacks.pop();)i(this);delete this.__initialized,this.__released=!0}attributeChangedCallback(i,s,o){if(this.__initialized&&!this.__updating[i]&&(i=this.lookupProp(i),i in e)){if(o==null&&!this[i])return;this[i]=e[i].parse?U7(o):o}}lookupProp(i){if(e)return n.find(s=>i===s||i===e[s].attribute)}get renderRoot(){return this.shadowRoot||this.attachShadow({mode:"open"})}addReleaseCallback(i){this.__releaseCallbacks.push(i)}addPropertyChangedCallback(i){this.__propertyChangedCallbacks.push(i)}}}function xle(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function dle(t,e={},n={}){const{BaseElement:r=HTMLElement,extension:i}=n;return s=>{if(!t)throw new Error("tag is required to register a Component");let o=customElements.get(t);return o?(o.prototype.Component=s,o):(o=fle(r,sle(e)),o.prototype.Component=s,o.prototype.registeredTag=t,customElements.define(t,o,i),o)}}const hle=(t,e)=>t===e,ON=Symbol("solid-proxy"),ple=Symbol("solid-track"),m3={equals:hle};let z7=K7;const Kl=1,y3=2,Q7={owned:null,cleanups:null,context:null,owner:null};var Kt=null;let NN=null,gle=null,$n=null,Lr=null,Da=null,E3=0;function A3(t,e){const n=$n,r=Kt,i=t.length===0,s=e===void 0?r:e,o=i?Q7:{owned:null,cleanups:null,context:s?s.context:null,owner:s},u=i?t:()=>t(()=>_o(()=>_3(o)));Kt=o,$n=null;try{return N2(u,!0)}finally{$n=n,Kt=r}}function DN(t,e){e=e?Object.assign({},m3,e):m3;const n={value:t,observers:null,observerSlots:null,comparator:e.equals||void 0},r=i=>(typeof i=="function"&&(i=i(n.value)),X7(n,i));return[Y7.bind(n),r]}function Jl(t,e,n){const r=LN(t,e,!1,Kl);O2(r)}function FN(t,e,n){z7=Ale;const r=LN(t,e,!1,Kl),i=V7&&wN(V7);i&&(r.suspense=i),(!n||!n.render)&&(r.user=!0),Da?Da.push(r):O2(r)}function Us(t,e,n){n=n?Object.assign({},m3,n):m3;const r=LN(t,e,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,O2(r),Y7.bind(r)}function _o(t){if($n===null)return t();const e=$n;$n=null;try{return t()}finally{$n=e}}function mle(t){return Kt===null||(Kt.cleanups===null?Kt.cleanups=[t]:Kt.cleanups.push(t)),t}function G7(t,e){const n=Symbol("context");return{id:n,Provider:vle(n),defaultValue:t}}function wN(t){return Kt&&Kt.context&&Kt.context[t.id]!==void 0?Kt.context[t.id]:t.defaultValue}function W7(t){const e=Us(t),n=Us(()=>IN(e()));return n.toArray=()=>{const r=n();return Array.isArray(r)?r:r!=null?[r]:[]},n}let V7;function Y7(){if(this.sources&&this.state)if(this.state===Kl)O2(this);else{const t=Lr;Lr=null,N2(()=>v3(this),!1),Lr=t}if($n){const t=this.observers?this.observers.length:0;$n.sources?($n.sources.push(this),$n.sourceSlots.push(t)):($n.sources=[this],$n.sourceSlots=[t]),this.observers?(this.observers.push($n),this.observerSlots.push($n.sources.length-1)):(this.observers=[$n],this.observerSlots=[$n.sources.length-1])}return this.value}function X7(t,e,n){let r=t.value;return(!t.comparator||!t.comparator(r,e))&&(t.value=e,t.observers&&t.observers.length&&N2(()=>{for(let i=0;i<t.observers.length;i+=1){const s=t.observers[i],o=NN&&NN.running;o&&NN.disposed.has(s),(o?!s.tState:!s.state)&&(s.pure?Lr.push(s):Da.push(s),s.observers&&J7(s)),o||(s.state=Kl)}if(Lr.length>1e6)throw Lr=[],new Error},!1)),e}function O2(t){if(!t.fn)return;_3(t);const e=E3;yle(t,t.value,e)}function yle(t,e,n){let r;const i=Kt,s=$n;$n=Kt=t;try{r=t.fn(e)}catch(o){return t.pure&&(t.state=Kl,t.owned&&t.owned.forEach(_3),t.owned=null),t.updatedAt=n+1,Z7(o)}finally{$n=s,Kt=i}(!t.updatedAt||t.updatedAt<=n)&&(t.updatedAt!=null&&"observers"in t?X7(t,r):t.value=r,t.updatedAt=n)}function LN(t,e,n,r=Kl,i){const s={fn:t,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:e,owner:Kt,context:Kt?Kt.context:null,pure:n};return Kt===null||Kt!==Q7&&(Kt.owned?Kt.owned.push(s):Kt.owned=[s]),s}function S3(t){if(t.state===0)return;if(t.state===y3)return v3(t);if(t.suspense&&_o(t.suspense.inFallback))return t.suspense.effects.push(t);const e=[t];for(;(t=t.owner)&&(!t.updatedAt||t.updatedAt<E3);)t.state&&e.push(t);for(let n=e.length-1;n>=0;n--)if(t=e[n],t.state===Kl)O2(t);else if(t.state===y3){const r=Lr;Lr=null,N2(()=>v3(t,e[0]),!1),Lr=r}}function N2(t,e){if(Lr)return t();let n=!1;e||(Lr=[]),Da?n=!0:Da=[],E3++;try{const r=t();return Ele(n),r}catch(r){n||(Da=null),Lr=null,Z7(r)}}function Ele(t){if(Lr&&(K7(Lr),Lr=null),t)return;const e=Da;Da=null,e.length&&N2(()=>z7(e),!1)}function K7(t){for(let e=0;e<t.length;e++)S3(t[e])}function Ale(t){let e,n=0;for(e=0;e<t.length;e++){const r=t[e];r.user?t[n++]=r:S3(r)}for(e=0;e<n;e++)S3(t[e])}function v3(t,e){t.state=0;for(let n=0;n<t.sources.length;n+=1){const r=t.sources[n];if(r.sources){const i=r.state;i===Kl?r!==e&&(!r.updatedAt||r.updatedAt<E3)&&S3(r):i===y3&&v3(r,e)}}}function J7(t){for(let e=0;e<t.observers.length;e+=1){const n=t.observers[e];n.state||(n.state=y3,n.pure?Lr.push(n):Da.push(n),n.observers&&J7(n))}}function _3(t){let e;if(t.sources)for(;t.sources.length;){const n=t.sources.pop(),r=t.sourceSlots.pop(),i=n.observers;if(i&&i.length){const s=i.pop(),o=n.observerSlots.pop();r<i.length&&(s.sourceSlots[o]=r,i[r]=s,n.observerSlots[r]=o)}}if(t.owned){for(e=t.owned.length-1;e>=0;e--)_3(t.owned[e]);t.owned=null}if(t.cleanups){for(e=t.cleanups.length-1;e>=0;e--)t.cleanups[e]();t.cleanups=null}t.state=0}function Sle(t){return t instanceof Error?t:new Error(typeof t=="string"?t:"Unknown error",{cause:t})}function Z7(t,e=Kt){throw Sle(t)}function IN(t){if(typeof t=="function"&&!t.length)return IN(t());if(Array.isArray(t)){const e=[];for(let n=0;n<t.length;n++){const r=IN(t[n]);Array.isArray(r)?e.push.apply(e,r):e.push(r)}return e}return t}function vle(t,e){return function(r){let i;return Jl(()=>i=_o(()=>(Kt.context={...Kt.context,[t]:r.value},W7(()=>r.children))),void 0),i}}const _le=Symbol("fallback");function eP(t){for(let e=0;e<t.length;e++)t[e]()}function Cle(t,e,n={}){let r=[],i=[],s=[],o=0,u=e.length>1?[]:null;return mle(()=>eP(s)),()=>{let a=t()||[],l,c;return a[ple],_o(()=>{let x=a.length,h,p,m,g,y,E,A,S,v;if(x===0)o!==0&&(eP(s),s=[],r=[],i=[],o=0,u&&(u=[])),n.fallback&&(r=[_le],i[0]=A3(C=>(s[0]=C,n.fallback())),o=1);else if(o===0){for(i=new Array(x),c=0;c<x;c++)r[c]=a[c],i[c]=A3(f);o=x}else{for(m=new Array(x),g=new Array(x),u&&(y=new Array(x)),E=0,A=Math.min(o,x);E<A&&r[E]===a[E];E++);for(A=o-1,S=x-1;A>=E&&S>=E&&r[A]===a[S];A--,S--)m[S]=i[A],g[S]=s[A],u&&(y[S]=u[A]);for(h=new Map,p=new Array(S+1),c=S;c>=E;c--)v=a[c],l=h.get(v),p[c]=l===void 0?-1:l,h.set(v,c);for(l=E;l<=A;l++)v=r[l],c=h.get(v),c!==void 0&&c!==-1?(m[c]=i[l],g[c]=s[l],u&&(y[c]=u[l]),c=p[c],h.set(v,c)):s[l]();for(c=E;c<x;c++)c in m?(i[c]=m[c],s[c]=g[c],u&&(u[c]=y[c],u[c](c))):i[c]=A3(f);i=i.slice(0,o=x),r=a.slice(0)}return i});function f(x){if(s[c]=x,u){const[h,p]=DN(c);return u[c]=p,e(a[c],h)}return e(a[c])}}}function kn(t,e){return _o(()=>t(e||{}))}function C3(){return!0}const ble={get(t,e,n){return e===ON?n:t.get(e)},has(t,e){return e===ON?!0:t.has(e)},set:C3,deleteProperty:C3,getOwnPropertyDescriptor(t,e){return{configurable:!0,enumerable:!0,get(){return t.get(e)},set:C3,deleteProperty:C3}},ownKeys(t){return t.keys()}};function BN(t){return(t=typeof t=="function"?t():t)?t:{}}function Tle(){for(let t=0,e=this.length;t<e;++t){const n=this[t]();if(n!==void 0)return n}}function Rle(...t){let e=!1;for(let o=0;o<t.length;o++){const u=t[o];e=e||!!u&&ON in u,t[o]=typeof u=="function"?(e=!0,Us(u)):u}if(e)return new Proxy({get(o){for(let u=t.length-1;u>=0;u--){const a=BN(t[u])[o];if(a!==void 0)return a}},has(o){for(let u=t.length-1;u>=0;u--)if(o in BN(t[u]))return!0;return!1},keys(){const o=[];for(let u=0;u<t.length;u++)o.push(...Object.keys(BN(t[u])));return[...new Set(o)]}},ble);const n={},r=Object.create(null);for(let o=t.length-1;o>=0;o--){const u=t[o];if(!u)continue;const a=Object.getOwnPropertyNames(u);for(let l=a.length-1;l>=0;l--){const c=a[l];if(c==="__proto__"||c==="constructor")continue;const f=Object.getOwnPropertyDescriptor(u,c);if(!r[c])r[c]=f.get?{enumerable:!0,configurable:!0,get:Tle.bind(n[c]=[f.get.bind(u)])}:f.value!==void 0?f:void 0;else{const x=n[c];x&&(f.get?x.push(f.get.bind(u)):f.value!==void 0&&x.push(()=>f.value))}}}const i={},s=Object.keys(r);for(let o=s.length-1;o>=0;o--){const u=s[o],a=r[u];a&&a.get?Object.defineProperty(i,u,a):i[u]=a?a.value:void 0}return i}const tP=t=>`Stale read from <${t}>.`;function Ole(t){const e="fallback"in t&&{fallback:()=>t.fallback};return Us(Cle(()=>t.each,t.children,e||void 0))}function Nle(t){const e=t.keyed,n=Us(()=>t.when,void 0,{equals:(r,i)=>e?r===i:!r==!i});return Us(()=>{const r=n();if(r){const i=t.children;return typeof i=="function"&&i.length>0?_o(()=>i(e?r:()=>{if(!_o(n))throw tP("Show");return t.when})):i}return t.fallback},void 0,void 0)}function nP(t){let e=!1;const n=(s,o)=>(e?s[1]===o[1]:!s[1]==!o[1])&&s[2]===o[2],r=W7(()=>t.children),i=Us(()=>{let s=r();Array.isArray(s)||(s=[s]);for(let o=0;o<s.length;o++){const u=s[o].when;if(u)return e=!!s[o].keyed,[o,u,s[o]]}return[-1]},void 0,{equals:n});return Us(()=>{const[s,o,u]=i();if(s<0)return t.fallback;const a=u.children;return typeof a=="function"&&a.length>0?_o(()=>a(e?o:()=>{if(_o(i)[0]!==s)throw tP("Match");return u.when})):a},void 0,void 0)}function $N(t){return t}function Dle(t,e,n){let r=n.length,i=e.length,s=r,o=0,u=0,a=e[i-1].nextSibling,l=null;for(;o<i||u<s;){if(e[o]===n[u]){o++,u++;continue}for(;e[i-1]===n[s-1];)i--,s--;if(i===o){const c=s<r?u?n[u-1].nextSibling:n[s-u]:a;for(;u<s;)t.insertBefore(n[u++],c)}else if(s===u)for(;o<i;)(!l||!l.has(e[o]))&&e[o].remove(),o++;else if(e[o]===n[s-1]&&n[u]===e[i-1]){const c=e[--i].nextSibling;t.insertBefore(n[u++],e[o++].nextSibling),t.insertBefore(n[--s],c),e[i]=n[s]}else{if(!l){l=new Map;let f=u;for(;f<s;)l.set(n[f],f++)}const c=l.get(e[o]);if(c!=null)if(u<c&&c<s){let f=o,x=1,h;for(;++f<i&&f<s&&!((h=l.get(e[f]))==null||h!==c+x);)x++;if(x>c-u){const p=e[o];for(;u<c;)t.insertBefore(n[u++],p)}else t.replaceChild(n[u++],e[o++])}else o++;else e[o++].remove()}}}function qc(t,e,n){let r;const i=()=>{const o=document.createElement("template");return o.innerHTML=t,n?o.content.firstChild.firstChild:o.content.firstChild},s=e?()=>_o(()=>document.importNode(r||(r=i()),!0)):()=>(r||(r=i())).cloneNode(!0);return s.cloneNode=s,s}function Fle(t,e,n){n==null?t.removeAttribute(e):t.setAttribute(e,n)}function wle(t,e,n){if(!e)return n?Fle(t,"style"):e;const r=t.style;if(typeof e=="string")return r.cssText=e;typeof n=="string"&&(r.cssText=n=void 0),n||(n={}),e||(e={});let i,s;for(s in n)e[s]==null&&r.removeProperty(s),delete n[s];for(s in e)i=e[s],i!==n[s]&&(r.setProperty(s,i),n[s]=i);return n}function Lle(t,e,n){return _o(()=>t(e,n))}function Fa(t,e,n,r){if(n!==void 0&&!r&&(r=[]),typeof e!="function")return b3(t,e,r,n);Jl(i=>b3(t,e(),i,n),r)}function b3(t,e,n,r,i){for(;typeof n=="function";)n=n();if(e===n)return n;const s=typeof e,o=r!==void 0;if(t=o&&n[0]&&n[0].parentNode||t,s==="string"||s==="number")if(s==="number"&&(e=e.toString()),o){let u=n[0];u&&u.nodeType===3?u.data!==e&&(u.data=e):u=document.createTextNode(e),n=vd(t,n,r,u)}else n!==""&&typeof n=="string"?n=t.firstChild.data=e:n=t.textContent=e;else if(e==null||s==="boolean")n=vd(t,n,r);else{if(s==="function")return Jl(()=>{let u=e();for(;typeof u=="function";)u=u();n=b3(t,u,n,r)}),()=>n;if(Array.isArray(e)){const u=[],a=n&&Array.isArray(n);if(kN(u,e,n,i))return Jl(()=>n=b3(t,u,n,r,!0)),()=>n;if(u.length===0){if(n=vd(t,n,r),o)return n}else a?n.length===0?rP(t,u,r):Dle(t,n,u):(n&&vd(t),rP(t,u));n=u}else if(e.nodeType){if(Array.isArray(n)){if(o)return n=vd(t,n,r,e);vd(t,n,null,e)}else n==null||n===""||!t.firstChild?t.appendChild(e):t.replaceChild(e,t.firstChild);n=e}}return n}function kN(t,e,n,r){let i=!1;for(let s=0,o=e.length;s<o;s++){let u=e[s],a=n&&n[t.length],l;if(!(u==null||u===!0||u===!1))if((l=typeof u)=="object"&&u.nodeType)t.push(u);else if(Array.isArray(u))i=kN(t,u,a)||i;else if(l==="function")if(r){for(;typeof u=="function";)u=u();i=kN(t,Array.isArray(u)?u:[u],Array.isArray(a)?a:[a])||i}else t.push(u),i=!0;else{const c=String(u);a&&a.nodeType===3&&a.data===c?t.push(a):t.push(document.createTextNode(c))}}return i}function rP(t,e,n=null){for(let r=0,i=e.length;r<i;r++)t.insertBefore(e[r],n)}function vd(t,e,n,r){if(n===void 0)return t.textContent="";const i=r||document.createTextNode("");if(e.length){let s=!1;for(let o=e.length-1;o>=0;o--){const u=e[o];if(i!==u){const a=u.parentNode===t;!s&&!o?a?t.replaceChild(i,u):t.insertBefore(i,n):a&&u.remove()}else s=!0}}else t.insertBefore(i,n);return[i]}function Ile(t){const e=Object.keys(t),n={};for(let r=0;r<e.length;r++){const[i,s]=DN(t[e[r]]);Object.defineProperty(n,e[r],{get:i,set(o){s(()=>o)}})}return n}function Ble(t){if(t.assignedSlot&&t.assignedSlot._$owner)return t.assignedSlot._$owner;let e=t.parentNode;for(;e&&!e._$owner&&!(e.assignedSlot&&e.assignedSlot._$owner);)e=e.parentNode;return e&&e.assignedSlot?e.assignedSlot._$owner:t._$owner}function $le(t){return(e,n)=>{const{element:r}=n;return A3(i=>{const s=Ile(e);r.addPropertyChangedCallback((u,a)=>s[u]=a),r.addReleaseCallback(()=>{r.renderRoot.textContent="",i()});const o=t(s,n);return Fa(r.renderRoot,o)},Ble(r))}}var N=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function PN(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function kle(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}var iP={},T3={},ve={};Object.defineProperty(ve,"__esModule",{value:!0}),ve.overload=ve.minAnalytic=ve.minAggregate=ve.minScalar=ve.maxAnalytic=ve.maxUngroupedAggregate=ve.anyExprType=ve.maxAggregate=ve.maxScalar=ve.makeParam=ve.param=ve.params=ve.literal=ve.output=ve.constant=ve.sql=ve.sqlFragment=ve.spread=ve.arg=void 0;function sP(t){return{type:"function_parameter",name:t}}ve.arg=sP;function Ple(t){return{type:"spread",e:[t]}}ve.spread=Ple;function Mle(...t){return{type:"sql_expression",e:t}}ve.sqlFragment=Mle;function jle(t,...e){return[{type:"sql_expression",e:Ule([...t],e)}]}ve.sql=jle;function Ule(t,e){const n=[];for(let r=0;r<t.length;r++)n.push(t[r]),r<e.length&&n.push(e[r]);return n}function qle(t){return{...t,evalSpace:"constant"}}ve.constant=qle;function Hle(t){return{...t,evalSpace:"output"}}ve.output=Hle;function zle(t){return{...t,evalSpace:"literal"}}ve.literal=zle;function Qle(t,...e){return{name:t,isVariadic:!0,allowedTypes:e}}ve.params=Qle;function oP(t,...e){return{name:t,isVariadic:!1,allowedTypes:e}}ve.param=oP;function Gle(t,...e){return{param:oP(t,...e),arg:sP(t)}}ve.makeParam=Gle;function Wle(t){return{dataType:t,expressionType:"scalar",evalSpace:"input"}}ve.maxScalar=Wle;function Vle(t){return{dataType:t,expressionType:"aggregate",evalSpace:"input"}}ve.maxAggregate=Vle;function Yle(t){return{dataType:t,expressionType:void 0,evalSpace:"input"}}ve.anyExprType=Yle;function Xle(t){return{dataType:t,expressionType:"ungrouped_aggregate",evalSpace:"input"}}ve.maxUngroupedAggregate=Xle;function Kle(t){return{dataType:t,expressionType:"aggregate_analytic",evalSpace:"input"}}ve.maxAnalytic=Kle;function Jle(t){return{dataType:t,expressionType:"scalar",evalSpace:"input"}}ve.minScalar=Jle;function Zle(t){return{dataType:t,expressionType:"aggregate",evalSpace:"input"}}ve.minAggregate=Zle;function e0e(t){return{dataType:t,expressionType:"scalar_analytic",evalSpace:"input"}}ve.minAnalytic=e0e;function t0e(t,e,n,r){return{returnType:t,params:e,e:n,needsWindowOrderBy:r==null?void 0:r.needsWindowOrderBy,between:r==null?void 0:r.between,isSymmetric:r==null?void 0:r.isSymmetric,supportsOrderBy:r==null?void 0:r.supportsOrderBy,defaultOrderByArgIndex:r==null?void 0:r.defaultOrderByArgIndex,supportsLimit:r==null?void 0:r.supportsLimit}}ve.overload=t0e;var Hc={},ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.isIndexSegment=ne.isRawSegment=ne.isSamplingEnable=ne.isSamplingPercent=ne.isSamplingRows=ne.isQuerySegment=ne.isProjectSegment=ne.isPartialSegment=ne.isReduceSegment=ne.refIsStructDef=ne.isByExpression=ne.isByName=ne.ValueType=ne.isExtractUnit=ne.isTimestampUnit=ne.isDateUnit=ne.FieldIsIntrinsic=ne.isCastType=ne.isAtomicFieldType=ne.isTimeFieldType=ne.hasExpression=ne.maxOfExpressionTypes=ne.maxExpressionType=ne.isExpressionTypeLEQ=ne.expressionIsAnalytic=ne.expressionIsCalculation=ne.expressionInvolvesAggregate=ne.expressionIsUngroupedAggregate=ne.expressionIsAggregate=ne.expressionIsScalar=ne.mkExpr=ne.isApplyFragment=ne.isApplyValue=ne.isParameterFragment=ne.isSourceReferenceFragment=ne.isSqlStringFragment=ne.isFieldFragment=ne.isSpreadFragment=ne.isSQLExpressionFragment=ne.isFunctionCallFragment=ne.isFunctionParameterFragment=ne.isUngroupFragment=ne.isAsymmetricFragment=ne.isAggregateFragment=ne.isDialectFragment=ne.isFilterFragment=ne.isOutputFieldFragment=ne.paramHasValue=ne.isConditionParameter=ne.isValueParameter=void 0,ne.isValueDate=ne.isValueTimestamp=ne.isValueBoolean=ne.isValueNumber=ne.isValueString=ne.isMeasureLike=ne.getPhysicalFields=ne.getDimensions=ne.isPhysical=ne.isDimensional=ne.isAtomicField=ne.isTurtleDef=ne.getIdentifier=ne.isFieldStructDef=ne.isFieldTimeBased=ne.isFieldTypeDef=ne.isSQLBlockStruct=ne.mergeEvalSpaces=ne.isLiteral=ne.isSQLFragment=ne.isJoinOn=ne.isMatrixOperation=void 0;function uP(t){return t.value!==void 0}ne.isValueParameter=uP;function n0e(t){return t.condition!==void 0}ne.isConditionParameter=n0e;function r0e(t){return uP(t)||t.condition!==null}ne.paramHasValue=r0e;function i0e(t){return(t==null?void 0:t.type)==="outputField"}ne.isOutputFieldFragment=i0e;function s0e(t){return(t==null?void 0:t.type)==="filterExpression"}ne.isFilterFragment=s0e;function o0e(t){return(t==null?void 0:t.type)==="dialect"}ne.isDialectFragment=o0e;function aP(t){return(t==null?void 0:t.type)==="aggregate"}ne.isAggregateFragment=aP;function u0e(t){return aP(t)&&["sum","avg","count"].includes(t.function)}ne.isAsymmetricFragment=u0e;function a0e(t){const e=t==null?void 0:t.type;return e==="all"||e==="exclude"}ne.isUngroupFragment=a0e;function l0e(t){return(t==null?void 0:t.type)==="function_parameter"}ne.isFunctionParameterFragment=l0e;function c0e(t){return(t==null?void 0:t.type)==="function_call"}ne.isFunctionCallFragment=c0e;function f0e(t){return(t==null?void 0:t.type)==="sql_expression"}ne.isSQLExpressionFragment=f0e;function x0e(t){return(t==null?void 0:t.type)==="spread"}ne.isSpreadFragment=x0e;function d0e(t){return(t==null?void 0:t.type)==="field"}ne.isFieldFragment=d0e;function h0e(t){return(t==null?void 0:t.type)==="sql-string"}ne.isSqlStringFragment=h0e;function p0e(t){return(t==null?void 0:t.type)==="source-reference"}ne.isSourceReferenceFragment=p0e;function g0e(t){return(t==null?void 0:t.type)==="parameter"}ne.isParameterFragment=g0e;function m0e(t){return(t==null?void 0:t.type)==="applyVal"}ne.isApplyValue=m0e;function y0e(t){return(t==null?void 0:t.type)==="apply"}ne.isApplyFragment=y0e;function E0e(t,...e){const n=[];let r;for(r=0;r<e.length;r++){const i=e[r];t[r].length>0&&n.push(t[r]),typeof i=="string"?n.push(i):n.push(...i)}return t[r].length>0&&n.push(t[r]),n}ne.mkExpr=E0e;function A0e(t){return t===void 0||t==="scalar"}ne.expressionIsScalar=A0e;function S0e(t){return t==="aggregate"||t==="ungrouped_aggregate"}ne.expressionIsAggregate=S0e;function v0e(t){return t==="ungrouped_aggregate"}ne.expressionIsUngroupedAggregate=v0e;function _0e(t){return t==="aggregate"||t==="ungrouped_aggregate"||t==="aggregate_analytic"}ne.expressionInvolvesAggregate=_0e;function C0e(t){return t==="aggregate"||t==="scalar_analytic"||t==="aggregate_analytic"||t==="ungrouped_aggregate"}ne.expressionIsCalculation=C0e;function b0e(t){return t==="aggregate_analytic"||t==="scalar_analytic"}ne.expressionIsAnalytic=b0e;function lP(t){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[t]}function T0e(t,e){return t===e||lP(t)<lP(e)}ne.isExpressionTypeLEQ=T0e;function cP(t,e){let n="scalar";return(t==="aggregate"||e==="aggregate")&&(n="aggregate"),(t==="ungrouped_aggregate"||e==="ungrouped_aggregate")&&(n="ungrouped_aggregate"),(t==="scalar_analytic"||e==="scalar_analytic")&&(n="scalar_analytic"),(t==="aggregate_analytic"||e==="aggregate_analytic")&&(n="aggregate_analytic"),(t==="scalar_analytic"&&e==="aggregate"||t==="aggregate"&&e==="scalar_analytic")&&(n="aggregate_analytic"),n}ne.maxExpressionType=cP;function R0e(t){return t.reduce(cP,"scalar")}ne.maxOfExpressionTypes=R0e;function fP(t){return t.e!==void 0}ne.hasExpression=fP;function O0e(t){return t==="date"||t==="timestamp"}ne.isTimeFieldType=O0e;function MN(t){return["string","number","date","timestamp","boolean","json","unsupported","error"].includes(t)}ne.isAtomicFieldType=MN;function N0e(t){return["string","number","date","timestamp","boolean","json"].includes(t)}ne.isCastType=N0e;function D0e(t){return MN(t.type)&&!fP(t)?!0:t.type==="struct"&&(t.structSource.type==="inline"||t.structSource.type==="nested")}ne.FieldIsIntrinsic=D0e;function xP(t){return["day","week","month","quarter","year"].includes(t)}ne.isDateUnit=xP;function dP(t){return xP(t)||["hour","minute","second"].includes(t)}ne.isTimestampUnit=dP;function F0e(t){return dP(t)||t==="day_of_week"||t==="day_of_year"}ne.isExtractUnit=F0e;var hP;(function(t){t.Date="date",t.Timestamp="timestamp",t.Number="number",t.String="string"})(hP||(ne.ValueType=hP={}));function w0e(t){return t===void 0?!1:t.by==="name"}ne.isByName=w0e;function L0e(t){return t===void 0?!1:t.by==="name"}ne.isByExpression=L0e;function I0e(t){return typeof t!="string"&&t.type==="struct"}ne.refIsStructDef=I0e;function pP(t){return t.type==="reduce"}ne.isReduceSegment=pP;function B0e(t){return t.type==="partial"}ne.isPartialSegment=B0e;function gP(t){return t.type==="project"}ne.isProjectSegment=gP;function $0e(t){return gP(t)||pP(t)}ne.isQuerySegment=$0e;function k0e(t){return t.rows!==void 0}ne.isSamplingRows=k0e;function P0e(t){return t.percent!==void 0}ne.isSamplingPercent=P0e;function M0e(t){return t.enable!==void 0}ne.isSamplingEnable=M0e;function j0e(t){return t.type==="raw"}ne.isRawSegment=j0e;function U0e(t){return t.type==="index"}ne.isIndexSegment=U0e;function q0e(t){return["left","right","full","inner"].includes(t)}ne.isMatrixOperation=q0e;function H0e(t){return["one","many","cross"].includes(t.type)}ne.isJoinOn=H0e;function z0e(t){return t.sql!==void 0}ne.isSQLFragment=z0e;function Q0e(t){return t==="literal"}ne.isLiteral=Q0e;function G0e(...t){return t.every(e=>e==="constant"||e==="literal")?"constant":t.every(e=>e==="output"||e==="constant"||e==="literal")?"output":"input"}ne.mergeEvalSpaces=G0e;function W0e(t){const e=t.structSource;return e.type==="sql"&&e.method==="subquery"}ne.isSQLBlockStruct=W0e;function mP(t){return t.type==="string"||t.type==="date"||t.type==="number"||t.type==="timestamp"||t.type==="boolean"||t.type==="json"}ne.isFieldTypeDef=mP;function V0e(t){return t.type==="date"||t.type==="timestamp"}ne.isFieldTimeBased=V0e;function yP(t){return t.type==="struct"}ne.isFieldStructDef=yP;function Y0e(t){return t.as!==void 0?t.as:t.name}ne.getIdentifier=Y0e;function X0e(t){return t.type==="turtle"}ne.isTurtleDef=X0e;function K0e(t){return MN(t.type)}ne.isAtomicField=K0e;function EP(t){var e;return"resultMetadata"in t?((e=t.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="dimension":!1}ne.isDimensional=EP;function AP(t){return mP(t)&&t.e===void 0||yP(t)&&(t.structSource.type==="nested"||t.structSource.type==="inline")}ne.isPhysical=AP;function J0e(t){return t.fields.filter(EP)}ne.getDimensions=J0e;function Z0e(t){return t.fields.filter(AP)}ne.getPhysicalFields=Z0e;function ece(t){var e,n;return"resultMetadata"in t?((e=t.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"||((n=t.resultMetadata)===null||n===void 0?void 0:n.fieldKind)==="struct":!1}ne.isMeasureLike=ece;function tce(t,e){return e.type==="string"}ne.isValueString=tce;function nce(t,e){return e.type==="number"}ne.isValueNumber=nce;function rce(t,e){return e.type==="boolean"}ne.isValueBoolean=rce;function ice(t,e){return e.type==="timestamp"}ne.isValueTimestamp=ice;function sce(t,e){return e.type==="date"}ne.isValueDate=sce,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Dialect=t.qtz=t.inDays=t.dayIndex=t.isDialectFieldStruct=void 0;const e=ne;function n(u){return u.type==="struct"}t.isDialectFieldStruct=n;const r=["microsecond","millisecond","second","minute","hour","day","week","month","quarter","year"];t.dayIndex=r.indexOf("day");function i(u){return r.indexOf(u)>=t.dayIndex}t.inDays=i;function s(u){const a=u.queryTimezone;if(!(a===void 0||a===u.systemTimezone))return a}t.qtz=s;class o{constructor(){this.cantPartitionWindowFunctionsOnExpressions=!1,this.supportsPipelinesInViews=!0,this.supportsArraysInData=!0,this.readsNestedData=!0,this.orderByClause="ordinal"}sqlFinalStage(a,l){throw new Error("Dialect has no final Stage but called Anyway")}sqlDateToString(a){return this.castToString(`DATE(${a})`)}ignoreInProject(a){return!1}sqlLiteralNumber(a){return a}dialectExpr(a,l){switch(l.function){case"now":return this.sqlNow();case"timeDiff":return this.sqlMeasureTime(l.left,l.right,l.units);case"delta":return this.sqlAlterTime(l.op,l.base,l.delta,l.units);case"trunc":return this.sqlTrunc(a,l.expr,l.units);case"extract":return this.sqlExtract(a,l.expr,l.units);case"cast":return this.sqlCast(a,l);case"regexpMatch":return this.sqlRegexpMatch(l.expr,l.regexp);case"div":return this.divisionIsInteger?(0,e.mkExpr)`${l.numerator}*1.0/${l.denominator}`:(0,e.mkExpr)`${l.numerator}/${l.denominator}`;case"timeLiteral":return[this.sqlLiteralTime(a,l.literal,l.literalType,l.timezone)];case"stringLiteral":return[this.sqlLiteralString(l.literal)];case"numberLiteral":return[this.sqlLiteralNumber(l.literal)];case"regexpLiteral":return[this.sqlLiteralRegexp(l.literal)]}}sqlSumDistinct(a,l,c){return"sqlSumDistinct called but not implemented"}sqlAggDistinct(a,l,c){return"sqlAggDistinct called but not implemented"}sqlSampleTable(a,l){if(l!==void 0)throw new Error(`Sampling is not supported on dialect ${this.name}.`);return a}sqlOrderBy(a){return`ORDER BY ${a.join(",")}`}sqlTzStr(a){return`"${a.queryTimezone}"`}sqlMakeUnnestKey(a,l){return this.concat(a,"'x'",l)}}t.Dialect=o}(Hc);var jN={},D2={},Gt={},R3,oce=new Uint8Array(16);function SP(){if(!R3&&(R3=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!R3))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return R3(oce)}const uce=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function O3(t){return typeof t=="string"&&uce.test(t)}for(var Sr=[],UN=0;UN<256;++UN)Sr.push((UN+256).toString(16).substr(1));function N3(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Sr[t[e+0]]+Sr[t[e+1]]+Sr[t[e+2]]+Sr[t[e+3]]+"-"+Sr[t[e+4]]+Sr[t[e+5]]+"-"+Sr[t[e+6]]+Sr[t[e+7]]+"-"+Sr[t[e+8]]+Sr[t[e+9]]+"-"+Sr[t[e+10]]+Sr[t[e+11]]+Sr[t[e+12]]+Sr[t[e+13]]+Sr[t[e+14]]+Sr[t[e+15]]).toLowerCase();if(!O3(n))throw TypeError("Stringified UUID is invalid");return n}var vP,qN,HN=0,zN=0;function ace(t,e,n){var r=e&&n||0,i=e||new Array(16);t=t||{};var s=t.node||vP,o=t.clockseq!==void 0?t.clockseq:qN;if(s==null||o==null){var u=t.random||(t.rng||SP)();s==null&&(s=vP=[u[0]|1,u[1],u[2],u[3],u[4],u[5]]),o==null&&(o=qN=(u[6]<<8|u[7])&16383)}var a=t.msecs!==void 0?t.msecs:Date.now(),l=t.nsecs!==void 0?t.nsecs:zN+1,c=a-HN+(l-zN)/1e4;if(c<0&&t.clockseq===void 0&&(o=o+1&16383),(c<0||a>HN)&&t.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");HN=a,zN=l,qN=o,a+=122192928e5;var f=((a&268435455)*1e4+l)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=f&255;var x=a/4294967296*1e4&268435455;i[r++]=x>>>8&255,i[r++]=x&255,i[r++]=x>>>24&15|16,i[r++]=x>>>16&255,i[r++]=o>>>8|128,i[r++]=o&255;for(var h=0;h<6;++h)i[r+h]=s[h];return e||N3(i)}function _P(t){if(!O3(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=e&255,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=e&255,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=e&255,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=e&255,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=e&255,n}function lce(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var cce="6ba7b810-9dad-11d1-80b4-00c04fd430c8",fce="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function CP(t,e,n){function r(i,s,o,u){if(typeof i=="string"&&(i=lce(i)),typeof s=="string"&&(s=_P(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+i.length);if(a.set(s),a.set(i,s.length),a=n(a),a[6]=a[6]&15|e,a[8]=a[8]&63|128,o){u=u||0;for(var l=0;l<16;++l)o[u+l]=a[l];return o}return N3(a)}try{r.name=t}catch{}return r.DNS=cce,r.URL=fce,r}function xce(t){if(typeof t=="string"){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return dce(hce(pce(t),t.length*8))}function dce(t){for(var e=[],n=t.length*32,r="0123456789abcdef",i=0;i<n;i+=8){var s=t[i>>5]>>>i%32&255,o=parseInt(r.charAt(s>>>4&15)+r.charAt(s&15),16);e.push(o)}return e}function bP(t){return(t+64>>>9<<4)+14+1}function hce(t,e){t[e>>5]|=128<<e%32,t[bP(e)-1]=e;for(var n=1732584193,r=-271733879,i=-1732584194,s=271733878,o=0;o<t.length;o+=16){var u=n,a=r,l=i,c=s;n=Ir(n,r,i,s,t[o],7,-680876936),s=Ir(s,n,r,i,t[o+1],12,-389564586),i=Ir(i,s,n,r,t[o+2],17,606105819),r=Ir(r,i,s,n,t[o+3],22,-1044525330),n=Ir(n,r,i,s,t[o+4],7,-176418897),s=Ir(s,n,r,i,t[o+5],12,1200080426),i=Ir(i,s,n,r,t[o+6],17,-1473231341),r=Ir(r,i,s,n,t[o+7],22,-45705983),n=Ir(n,r,i,s,t[o+8],7,1770035416),s=Ir(s,n,r,i,t[o+9],12,-1958414417),i=Ir(i,s,n,r,t[o+10],17,-42063),r=Ir(r,i,s,n,t[o+11],22,-1990404162),n=Ir(n,r,i,s,t[o+12],7,1804603682),s=Ir(s,n,r,i,t[o+13],12,-40341101),i=Ir(i,s,n,r,t[o+14],17,-1502002290),r=Ir(r,i,s,n,t[o+15],22,1236535329),n=Br(n,r,i,s,t[o+1],5,-165796510),s=Br(s,n,r,i,t[o+6],9,-1069501632),i=Br(i,s,n,r,t[o+11],14,643717713),r=Br(r,i,s,n,t[o],20,-373897302),n=Br(n,r,i,s,t[o+5],5,-701558691),s=Br(s,n,r,i,t[o+10],9,38016083),i=Br(i,s,n,r,t[o+15],14,-660478335),r=Br(r,i,s,n,t[o+4],20,-405537848),n=Br(n,r,i,s,t[o+9],5,568446438),s=Br(s,n,r,i,t[o+14],9,-1019803690),i=Br(i,s,n,r,t[o+3],14,-187363961),r=Br(r,i,s,n,t[o+8],20,1163531501),n=Br(n,r,i,s,t[o+13],5,-1444681467),s=Br(s,n,r,i,t[o+2],9,-51403784),i=Br(i,s,n,r,t[o+7],14,1735328473),r=Br(r,i,s,n,t[o+12],20,-1926607734),n=$r(n,r,i,s,t[o+5],4,-378558),s=$r(s,n,r,i,t[o+8],11,-2022574463),i=$r(i,s,n,r,t[o+11],16,1839030562),r=$r(r,i,s,n,t[o+14],23,-35309556),n=$r(n,r,i,s,t[o+1],4,-1530992060),s=$r(s,n,r,i,t[o+4],11,1272893353),i=$r(i,s,n,r,t[o+7],16,-155497632),r=$r(r,i,s,n,t[o+10],23,-1094730640),n=$r(n,r,i,s,t[o+13],4,681279174),s=$r(s,n,r,i,t[o],11,-358537222),i=$r(i,s,n,r,t[o+3],16,-722521979),r=$r(r,i,s,n,t[o+6],23,76029189),n=$r(n,r,i,s,t[o+9],4,-640364487),s=$r(s,n,r,i,t[o+12],11,-421815835),i=$r(i,s,n,r,t[o+15],16,530742520),r=$r(r,i,s,n,t[o+2],23,-995338651),n=kr(n,r,i,s,t[o],6,-198630844),s=kr(s,n,r,i,t[o+7],10,1126891415),i=kr(i,s,n,r,t[o+14],15,-1416354905),r=kr(r,i,s,n,t[o+5],21,-57434055),n=kr(n,r,i,s,t[o+12],6,1700485571),s=kr(s,n,r,i,t[o+3],10,-1894986606),i=kr(i,s,n,r,t[o+10],15,-1051523),r=kr(r,i,s,n,t[o+1],21,-2054922799),n=kr(n,r,i,s,t[o+8],6,1873313359),s=kr(s,n,r,i,t[o+15],10,-30611744),i=kr(i,s,n,r,t[o+6],15,-1560198380),r=kr(r,i,s,n,t[o+13],21,1309151649),n=kr(n,r,i,s,t[o+4],6,-145523070),s=kr(s,n,r,i,t[o+11],10,-1120210379),i=kr(i,s,n,r,t[o+2],15,718787259),r=kr(r,i,s,n,t[o+9],21,-343485551),n=Zl(n,u),r=Zl(r,a),i=Zl(i,l),s=Zl(s,c)}return[n,r,i,s]}function pce(t){if(t.length===0)return[];for(var e=t.length*8,n=new Uint32Array(bP(e)),r=0;r<e;r+=8)n[r>>5]|=(t[r/8]&255)<<r%32;return n}function Zl(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function gce(t,e){return t<<e|t>>>32-e}function D3(t,e,n,r,i,s){return Zl(gce(Zl(Zl(e,t),Zl(r,s)),i),n)}function Ir(t,e,n,r,i,s,o){return D3(e&n|~e&r,t,e,i,s,o)}function Br(t,e,n,r,i,s,o){return D3(e&r|n&~r,t,e,i,s,o)}function $r(t,e,n,r,i,s,o){return D3(e^n^r,t,e,i,s,o)}function kr(t,e,n,r,i,s,o){return D3(n^(e|~r),t,e,i,s,o)}var mce=CP("v3",48,xce);const yce=mce;function Ece(t,e,n){t=t||{};var r=t.random||(t.rng||SP)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(var i=0;i<16;++i)e[n+i]=r[i];return e}return N3(r)}function Ace(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:return e^n^r;case 2:return e&n^e&r^n&r;case 3:return e^n^r}}function QN(t,e){return t<<e|t>>>32-e}function Sce(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var r=unescape(encodeURIComponent(t));t=[];for(var i=0;i<r.length;++i)t.push(r.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var s=t.length/4+2,o=Math.ceil(s/16),u=new Array(o),a=0;a<o;++a){for(var l=new Uint32Array(16),c=0;c<16;++c)l[c]=t[a*64+c*4]<<24|t[a*64+c*4+1]<<16|t[a*64+c*4+2]<<8|t[a*64+c*4+3];u[a]=l}u[o-1][14]=(t.length-1)*8/Math.pow(2,32),u[o-1][14]=Math.floor(u[o-1][14]),u[o-1][15]=(t.length-1)*8&4294967295;for(var f=0;f<o;++f){for(var x=new Uint32Array(80),h=0;h<16;++h)x[h]=u[f][h];for(var p=16;p<80;++p)x[p]=QN(x[p-3]^x[p-8]^x[p-14]^x[p-16],1);for(var m=n[0],g=n[1],y=n[2],E=n[3],A=n[4],S=0;S<80;++S){var v=Math.floor(S/20),C=QN(m,5)+Ace(v,g,y,E)+A+e[v]+x[S]>>>0;A=E,E=y,y=QN(g,30)>>>0,g=m,m=C}n[0]=n[0]+m>>>0,n[1]=n[1]+g>>>0,n[2]=n[2]+y>>>0,n[3]=n[3]+E>>>0,n[4]=n[4]+A>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var vce=CP("v5",80,Sce);const _ce=vce,Cce="00000000-0000-0000-0000-000000000000";function bce(t){if(!O3(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const TP=kle(Object.freeze(Object.defineProperty({__proto__:null,NIL:Cce,parse:_P,stringify:N3,v1:ace,v3:yce,v4:Ece,v5:_ce,validate:O3,version:bce},Symbol.toStringTag,{value:"Module"})));Object.defineProperty(Gt,"__esModule",{value:!0}),Gt.range=Gt.joinWith=Gt.exprWalk=Gt.exprMap=Gt.generateHash=Gt.AndChain=Gt.generateSQLStringLiteral=Gt.indent=void 0;const Tce=TP;function Rce(t){const e=/(^|\n)/g,n=/\n {2}$/;return t.replace(e,"$1 ").replace(n,`
|
|
2
2
|
`)}Gt.indent=Rce;function Oce(t){return`'${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`}Gt.generateSQLStringLiteral=Oce;class GN{constructor(e){this.clauses=[],e&&this.clauses.push(e)}clone(){const e=new GN;return e.addChain(this),e}add(e){return this.clauses.push(e),this}addChain(e){return this.clauses.push(...e.clauses),this}empty(){return this.clauses.length===0}present(){return this.clauses.length>0}sqlOr(){return this.empty()?"":this.clauses.map(e=>`(${e})`).join("OR ")+`
|
|
3
3
|
`}sql(e){if(this.empty())return"";let n="",r="";return e&&(n=e.toUpperCase()+" ",r=`
|
|
4
4
|
`),this.clauses.length===1?n+this.clauses[0]+r:n+this.clauses.map(i=>`(${i})`).join(`
|
|
@@ -261,7 +261,7 @@ ${(0,hde.indent)(n)}
|
|
|
261
261
|
WITHIN`.split(/\s/)}quoteTablePath(e){return e}sqlGroupSetTable(e){return`CROSS JOIN (SELECT row_number() OVER() -1 group_set FROM UNNEST(SEQUENCE(0,${e})))`}dialectExpr(e,n){switch(n.function){case"div":return(0,Nn.mkExpr)`CAST(${n.numerator} AS DOUBLE)/${n.denominator}`}return super.dialectExpr(e,n)}sqlAnyValue(e,n){return`ANY_VALUE(CASE WHEN group_set=${e} THEN ${n} END)`}buildTypeExpression(e){const n=[];for(const r of e)if((0,YP.isDialectFieldStruct)(r)){let i=`ROW(${this.buildTypeExpression(r.nestedStruct)})`;r.isArray&&(i=`array(${i})`),n.push(`${r.sqlOutputName} ${i}`)}else n.push(`${r.sqlOutputName} ${Sde[r.type]||r.type}`);return n.join(`,
|
|
262
262
|
`)}sqlAggregateTurtle(e,n,r,i){const s=n.map(a=>a.sqlExpression).join(`,
|
|
263
263
|
`),o=this.buildTypeExpression(n);let u=`ARRAY_AGG(CAST(ROW(${s}) AS ROW(${o})) ${r}) FILTER (WHERE group_set=${e})`;return i!==void 0&&(u=`SLICE(${u}, 1, ${i})`),u}sqlAnyValueTurtle(e,n){const r=n.map(i=>`
|
|
264
|
-
'${i.sqlOutputName}' VALUE ${i.sqlExpression}`).join(", ");return`ANY_VALUE(CASE WHEN group_set=${e} THEN JSON_OBJECT(${r}))`}sqlAnyValueLastTurtle(e,n,r){return`ANY_VALUE(CASE WHEN group_set=${n} THEN ${e} END) as ${r}`}sqlCoaleseMeasuresInline(e,n){const r=n.map(o=>o.sqlExpression).join(", "),i=n.map(o=>"NULL").join(", "),s=this.buildTypeExpression(n);return`COALESCE(ANY_VALUE(CASE WHEN group_set=${e} THEN CAST(ROW(${r}) AS ROW(${s})) END), CAST(ROW(${i}) AS ROW(${s})))`}sqlUnnestAlias(e,n,r,i,s,o){const u=r.map(a=>this.sqlMaybeQuoteIdentifier(a.sqlOutputName));return s?i?`,UNNEST(
|
|
264
|
+
'${i.sqlOutputName}' VALUE ${i.sqlExpression}`).join(", ");return`ANY_VALUE(CASE WHEN group_set=${e} THEN JSON_OBJECT(${r}))`}sqlAnyValueLastTurtle(e,n,r){return`ANY_VALUE(CASE WHEN group_set=${n} THEN ${e} END) as ${r}`}sqlCoaleseMeasuresInline(e,n){const r=n.map(o=>o.sqlExpression).join(", "),i=n.map(o=>"NULL").join(", "),s=this.buildTypeExpression(n);return`COALESCE(ANY_VALUE(CASE WHEN group_set=${e} THEN CAST(ROW(${r}) AS ROW(${s})) END), CAST(ROW(${i}) AS ROW(${s})))`}sqlUnnestAlias(e,n,r,i,s,o){const u=r.map(a=>this.sqlMaybeQuoteIdentifier(a.sqlOutputName));return s?i?`,UNNEST(zip(${e}, SEQUENCE(1,cardinality(${e})))) as words_0(value,__row_id_from_${n})`:`,UNNEST(transform(${e}, x -> ROW(x) )) as ${n}(value)`:i?`,UNNEST(zip_with(a, SEQUENCE(1,cardinality(a)), (r,__row_id) -> (r, __row_id))) as ${n}_outer(${n},__row_id_from_${n})`:`,UNNEST(${e}) as ${n}(${u.join(", ")})`}sqlSumDistinctHashedKey(e){e=`CAST(${e} AS VARCHAR)`;const n=`cast(from_base(substr(to_hex(md5(to_utf8(${e}))), 1, 15),16) as DECIMAL) * DECIMAL '4294967296' `,r=`cast(from_base(substr(to_hex(md5(to_utf8(${e}))), 16, 8),16) as DECIMAL) `;return`(${n} + ${r}) * 0.000000001`}sqlGenerateUUID(){return"UUID()"}sqlFieldReference(e,n,r,i,s){return n==="__row_id"?`__row_id_from_${e}`:`${e}.${n}`}sqlUnnestPipelineHead(e,n){let r=n;return e&&(r=`[${r}]`),`UNNEST(${r})`}sqlCreateFunction(e,n){return`CREATE TEMPORARY FUNCTION ${e}(__param ANY TYPE) AS ((
|
|
265
265
|
${(0,VP.indent)(n)}));
|
|
266
266
|
`}sqlCreateTableAsSelect(e,n){return`
|
|
267
267
|
CREATE TABLE IF NOT EXISTS \`${e}\`
|
|
@@ -272,7 +272,7 @@ AS (
|
|
|
272
272
|
${(0,VP.indent)(n)}
|
|
273
273
|
);
|
|
274
274
|
`}sqlCreateFunctionCombineLastStage(e){return`SELECT ARRAY((SELECT AS STRUCT * FROM ${e}))
|
|
275
|
-
`}sqlSelectAliasAsStruct(e){return`(SELECT AS STRUCT ${e}.*)`}sqlMaybeQuoteIdentifier(e){return'"'+e+'"'}sqlNow(){return(0,Nn.mkExpr)`CURRENT_TIMESTAMP()`}sqlTrunc(e,n,r){const i=WA(e),s=i?`, "${i}"`:"";return n.valueType==="date"?Ede(r)?(0,Nn.mkExpr)`DATE_TRUNC(${n.value},${r})`:(0,Nn.mkExpr)`TIMESTAMP(${n.value}${s})`:(0,Nn.mkExpr)`TIMESTAMP_TRUNC(${n.value},${r}${s})`}sqlExtract(e,n,r){const i=Ade[r]||r,s=n.valueType==="timestamp"&&WA(e),o=s?` AT TIME ZONE '${s}'`:"";return(0,Nn.mkExpr)`EXTRACT(${i} FROM ${n.value}${o})`}sqlAlterTime(e,n,r,i){let s=n.value,o=n.valueType;i!=="day"&&XP(i)?(o="timestamp",n.valueType!=="timestamp"&&(s=(0,Nn.mkExpr)`TIMESTAMP(${s})`)):n.valueType==="timestamp"&&(s=(0,Nn.mkExpr)`DATETIME(${s})`,o="datetime");const u=o.toUpperCase()+(e==="+"?"_ADD":"_SUB"),a=(0,Nn.mkExpr)`${u}(${s}, INTERVAL ${r} ${i})`;return o===n.valueType?a:(0,Nn.mkExpr)`${n.valueType.toUpperCase()}(${a})`}ignoreInProject(e){return e==="_PARTITIONTIME"}sqlCast(e,n){const r=`${n.srcType}::${n.dstType}`,i=WA(e);if(r==="timestamp::date"&&i)return(0,Nn.mkExpr)`DATE(${n.expr},'${i}')`;if(r==="date::timestamp"&&i)return(0,Nn.mkExpr)`TIMESTAMP(${n.expr}, '${i}')`;if(n.srcType!==n.dstType){const s=typeof n.dstType=="string"?this.malloyTypeToSQLType({type:n.dstType}):n.dstType.raw,o=n.safe?"TRY_CAST":"CAST";return(0,Nn.mkExpr)`${o}(${n.expr} AS ${s})`}return n.expr}sqlRegexpMatch(e,n){return(0,Nn.mkExpr)`REGEXP_LIKE(${e}, ${n})`}sqlLiteralTime(e,n,r,i){if(r==="date")return`DATE('${n}')`;if(r==="timestamp"){let s=`'${n}'`;const o=i||WA(e);return o&&o!=="UTC"&&(s+=`,'${o}'`),`TIMESTAMP(${s})`}else throw new Error(`Unsupported Literal time format ${r}`)}sqlMeasureTime(e,n,r){const i={microsecond:{use:"microsecond",ratio:1},millisecond:{use:"microsecond",ratio:1e3},second:{use:"millisecond",ratio:1e3},minute:{use:"second",ratio:60},hour:{use:"minute",ratio:60},day:{use:"hour",ratio:24},week:{use:"day",ratio:7}};let s=e.value,o=n.value;if(i[r]){const{use:u,ratio:a}=i[r];if(!XP(u))throw new Error(`Measure in '${u} not implemented`);if(e.valueType!==n.valueType)throw new Error("Can't measure difference between different types");e.valueType==="date"&&(s=(0,Nn.mkExpr)`TIMESTAMP(${s})`,o=(0,Nn.mkExpr)`TIMESTAMP(${o})`);let l=(0,Nn.mkExpr)`TIMESTAMP_DIFF(${o},${s},${u})`;return a!==1&&(l=(0,Nn.mkExpr)`FLOOR(${l}/${a.toString()}.0)`),l}throw new Error(`Measure '${r} not implemented`)}sqlSampleTable(e,n){if(n!==void 0){if((0,Nn.isSamplingEnable)(n)&&n.enable&&(n=this.defaultSampling),(0,Nn.isSamplingRows)(n))throw new Error("StandardSQL doesn't support sampling by rows only percent");if((0,Nn.isSamplingPercent)(n))return`(SELECT * FROM ${e} TABLESAMPLE SYSTEM (${n.percent} PERCENT))`}return e}sqlLiteralString(e){return"'"+e.replace(/'/g,"''")+"'"}sqlLiteralRegexp(e){return"'"+e.replace(/'/g,"''")+"'"}getGlobalFunctionDef(e){return yde.TRINO_FUNCTIONS.get(e)}malloyTypeToSQLType(e){return e.type==="number"?e.numberType==="integer"?"BIGINT":"DOUBLE":e.type==="string"?"VARCHAR":e.type}sqlTypeToMalloyType(e){}castToString(e){return`CAST(${e} as VARCHAR)`}concat(...e){return e.join(" || ")}validateTypeName(e){return e.match(/^[A-Za-z\s(),<>0-9]*$/)!==null}}GA.TrinoDialect=vde,function(t){var e=N&&N.__createBinding||(Object.create?function(r,i,s,o){o===void 0&&(o=s);var u=Object.getOwnPropertyDescriptor(i,s);(!u||("get"in u?!i.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(r,o,u)}:function(r,i,s,o){o===void 0&&(o=s),r[o]=i[s]}),n=N&&N.__exportStar||function(r,i){for(var s in r)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,r,s)};Object.defineProperty(t,"__esModule",{value:!0}),n(GA,t)}(oD);var mu={};Object.defineProperty(mu,"__esModule",{value:!0}),mu.getDialectFunction=mu.registerDialect=mu.getDialect=void 0;const _de=nD,Cde=eD,bde=iD,Tde=jN,Rde=oD,uD=new Map;function Ode(t){const e=uD.get(t);if(e===void 0)throw new Error(`Unknown Dialect ${t}`);return e}mu.getDialect=Ode;function Wd(t){uD.set(t.name,t)}mu.registerDialect=Wd,Wd(new Cde.PostgresDialect),Wd(new Tde.StandardSQLDialect),Wd(new _de.DuckDBDialect),Wd(new bde.SnowflakeDialect),Wd(new Rde.TrinoDialect);function KP(t,e){return t.params.length===e.params.length&&t.params.every((n,r)=>{const i=e.params[r];return n.isVariadic===i.isVariadic&&n.name===i.name&&n.allowedTypes.length===i.allowedTypes.length&&n.allowedTypes.every(s=>i.allowedTypes.some(o=>s.dataType===o.dataType&&s.expressionType===o.expressionType))})}function Nde(t,e){return KP(t,e)}function Dde(t,e){return t.returnType.dataType===e.returnType.dataType&&t.returnType.expressionType===e.returnType.expressionType}function Fde(t){const e={type:"function",name:t,overloads:[]};let n=!1;for(const r of uD.values()){const i=r.getGlobalFunctionDef(t);if(i){for(const s of i){let o=!1;for(const u of e.overloads)if(Nde(s,u)){if(!KP(s,u))throw new Error("params are compatible but not equal");if(!Dde(s,u))throw new Error("params match but return types differ!");u.dialect[r.name]={e:s.e,supportsOrderBy:s.supportsOrderBy,defaultOrderByArgIndex:s.defaultOrderByArgIndex,supportsLimit:s.supportsLimit},o=!0}o||e.overloads.push({returnType:s.returnType,params:s.params,dialect:{[r.name]:{e:s.e,supportsOrderBy:s.supportsOrderBy,defaultOrderByArgIndex:s.defaultOrderByArgIndex,supportsLimit:s.supportsLimit}},needsWindowOrderBy:s.needsWindowOrderBy,between:s.between,isSymmetric:s.isSymmetric})}n=!0}}return n?e:void 0}mu.getDialectFunction=Fde,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.FUNCTIONS=t.getDialectFunction=t.registerDialect=t.getDialect=t.TrinoDialect=t.SnowflakeDialect=t.DuckDBDialect=t.PostgresDialect=t.StandardSQLDialect=t.qtz=t.Dialect=t.sql=t.literal=t.params=t.param=t.sqlFragment=t.spread=t.maxScalar=t.minAggregate=t.minScalar=t.overload=t.makeParam=t.anyExprType=t.arg=void 0;var e=ve;Object.defineProperty(t,"arg",{enumerable:!0,get:function(){return e.arg}}),Object.defineProperty(t,"anyExprType",{enumerable:!0,get:function(){return e.anyExprType}}),Object.defineProperty(t,"makeParam",{enumerable:!0,get:function(){return e.makeParam}}),Object.defineProperty(t,"overload",{enumerable:!0,get:function(){return e.overload}}),Object.defineProperty(t,"minScalar",{enumerable:!0,get:function(){return e.minScalar}}),Object.defineProperty(t,"minAggregate",{enumerable:!0,get:function(){return e.minAggregate}}),Object.defineProperty(t,"maxScalar",{enumerable:!0,get:function(){return e.maxScalar}}),Object.defineProperty(t,"spread",{enumerable:!0,get:function(){return e.spread}}),Object.defineProperty(t,"sqlFragment",{enumerable:!0,get:function(){return e.sqlFragment}}),Object.defineProperty(t,"param",{enumerable:!0,get:function(){return e.param}}),Object.defineProperty(t,"params",{enumerable:!0,get:function(){return e.params}}),Object.defineProperty(t,"literal",{enumerable:!0,get:function(){return e.literal}}),Object.defineProperty(t,"sql",{enumerable:!0,get:function(){return e.sql}});var n=Hc;Object.defineProperty(t,"Dialect",{enumerable:!0,get:function(){return n.Dialect}}),Object.defineProperty(t,"qtz",{enumerable:!0,get:function(){return n.qtz}});var r=jN;Object.defineProperty(t,"StandardSQLDialect",{enumerable:!0,get:function(){return r.StandardSQLDialect}});var i=eD;Object.defineProperty(t,"PostgresDialect",{enumerable:!0,get:function(){return i.PostgresDialect}});var s=nD;Object.defineProperty(t,"DuckDBDialect",{enumerable:!0,get:function(){return s.DuckDBDialect}});var o=iD;Object.defineProperty(t,"SnowflakeDialect",{enumerable:!0,get:function(){return o.SnowflakeDialect}});var u=oD;Object.defineProperty(t,"TrinoDialect",{enumerable:!0,get:function(){return u.TrinoDialect}});var a=mu;Object.defineProperty(t,"getDialect",{enumerable:!0,get:function(){return a.getDialect}}),Object.defineProperty(t,"registerDialect",{enumerable:!0,get:function(){return a.registerDialect}}),Object.defineProperty(t,"getDialectFunction",{enumerable:!0,get:function(){return a.getDialectFunction}});var l=zc;Object.defineProperty(t,"FUNCTIONS",{enumerable:!0,get:function(){return l.FUNCTIONS}})}(T3);var yu={},cf={};Object.defineProperty(cf,"__esModule",{value:!0}),cf.QueryModel=cf.Segment=void 0;const wde=T3,Lde=D2,je=ne,vr=Gt;function JP(t){return t.map(e=>encodeURIComponent(e)).join("/")}function aD(t){return`'${t}'`}function ZP(t){return t.replace(/[^a-zA-Z0-9_]/g,"_o_")}class Ide extends Set{add_use(e){if(e!==void 0)return this.add(e)}hasAsymetricFunctions(){return this.has("sum")||this.has("avg")||this.has("count")||this.has("generic_asymmetric_aggregate")}}class H2{constructor(e=!0,n){this.parent=n,this.withs=[],this.udfs=[],this.pdts=[],this.stagePrefix="__stage",this.useCTE=e}getName(e){return`${this.stagePrefix}${e}`}root(){return this.parent===void 0?this:this.parent.root()}addStage(e){return this.useCTE?(this.withs.push(e),this.getName(this.withs.length-1)):(this.withs[0]=e,(0,vr.indent)(`
|
|
275
|
+
`}sqlSelectAliasAsStruct(e){return`(SELECT AS STRUCT ${e}.*)`}sqlMaybeQuoteIdentifier(e){return'"'+e+'"'}sqlNow(){return(0,Nn.mkExpr)`CURRENT_TIMESTAMP()`}sqlTrunc(e,n,r){const i=WA(e),s=i?`, "${i}"`:"";return n.valueType==="date"?Ede(r)?(0,Nn.mkExpr)`DATE_TRUNC(${n.value},${r})`:(0,Nn.mkExpr)`TIMESTAMP(${n.value}${s})`:(0,Nn.mkExpr)`TIMESTAMP_TRUNC(${n.value},${r}${s})`}sqlExtract(e,n,r){const i=Ade[r]||r,s=n.valueType==="timestamp"&&WA(e),o=s?` AT TIME ZONE '${s}'`:"";return(0,Nn.mkExpr)`EXTRACT(${i} FROM ${n.value}${o})`}sqlAlterTime(e,n,r,i){let s=n.value,o=n.valueType;i!=="day"&&XP(i)?(o="timestamp",n.valueType!=="timestamp"&&(s=(0,Nn.mkExpr)`TIMESTAMP(${s})`)):n.valueType==="timestamp"&&(s=(0,Nn.mkExpr)`DATETIME(${s})`,o="datetime");const u=o.toUpperCase()+(e==="+"?"_ADD":"_SUB"),a=(0,Nn.mkExpr)`${u}(${s}, INTERVAL ${r} ${i})`;return o===n.valueType?a:(0,Nn.mkExpr)`${n.valueType.toUpperCase()}(${a})`}ignoreInProject(e){return e==="_PARTITIONTIME"}sqlCast(e,n){const r=`${n.srcType}::${n.dstType}`,i=WA(e);if(r==="timestamp::date"&&i)return(0,Nn.mkExpr)`DATE(${n.expr},'${i}')`;if(r==="date::timestamp"&&i)return(0,Nn.mkExpr)`TIMESTAMP(${n.expr}, '${i}')`;if(n.srcType!==n.dstType){const s=typeof n.dstType=="string"?this.malloyTypeToSQLType({type:n.dstType}):n.dstType.raw,o=n.safe?"TRY_CAST":"CAST";return(0,Nn.mkExpr)`${o}(${n.expr} AS ${s})`}return n.expr}sqlRegexpMatch(e,n){return(0,Nn.mkExpr)`REGEXP_LIKE(${e}, ${n})`}sqlLiteralTime(e,n,r,i){if(r==="date")return`DATE('${n}')`;if(r==="timestamp"){let s=`'${n}'`;const o=i||WA(e);return o&&o!=="UTC"&&(s+=`,'${o}'`),`TIMESTAMP(${s})`}else throw new Error(`Unsupported Literal time format ${r}`)}sqlMeasureTime(e,n,r){const i={microsecond:{use:"microsecond",ratio:1},millisecond:{use:"microsecond",ratio:1e3},second:{use:"millisecond",ratio:1e3},minute:{use:"second",ratio:60},hour:{use:"minute",ratio:60},day:{use:"hour",ratio:24},week:{use:"day",ratio:7}};let s=e.value,o=n.value;if(i[r]){const{use:u,ratio:a}=i[r];if(!XP(u))throw new Error(`Measure in '${u} not implemented`);if(e.valueType!==n.valueType)throw new Error("Can't measure difference between different types");e.valueType==="date"&&(s=(0,Nn.mkExpr)`TIMESTAMP(${s})`,o=(0,Nn.mkExpr)`TIMESTAMP(${o})`);let l=(0,Nn.mkExpr)`TIMESTAMP_DIFF(${o},${s},${u})`;return a!==1&&(l=(0,Nn.mkExpr)`FLOOR(${l}/${a.toString()}.0)`),l}throw new Error(`Measure '${r} not implemented`)}sqlSampleTable(e,n){if(n!==void 0){if((0,Nn.isSamplingEnable)(n)&&n.enable&&(n=this.defaultSampling),(0,Nn.isSamplingRows)(n))throw new Error("StandardSQL doesn't support sampling by rows only percent");if((0,Nn.isSamplingPercent)(n))return`(SELECT * FROM ${e} TABLESAMPLE SYSTEM (${n.percent} PERCENT))`}return e}sqlLiteralString(e){return"'"+e.replace(/'/g,"''")+"'"}sqlLiteralRegexp(e){return"'"+e.replace(/'/g,"''")+"'"}getGlobalFunctionDef(e){return yde.TRINO_FUNCTIONS.get(e)}malloyTypeToSQLType(e){return e.type==="number"?e.numberType==="integer"?"BIGINT":"DOUBLE":e.type==="string"?"VARCHAR":e.type}sqlTypeToMalloyType(e){}castToString(e){return`CAST(${e} as VARCHAR)`}concat(...e){return e.join(" || ")}sqlMakeUnnestKey(e,n){return`CAST(${e} as VARCHAR) || 'x' || CAST(${n} as VARCHAR)`}validateTypeName(e){return e.match(/^[A-Za-z\s(),<>0-9]*$/)!==null}}GA.TrinoDialect=vde,function(t){var e=N&&N.__createBinding||(Object.create?function(r,i,s,o){o===void 0&&(o=s);var u=Object.getOwnPropertyDescriptor(i,s);(!u||("get"in u?!i.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(r,o,u)}:function(r,i,s,o){o===void 0&&(o=s),r[o]=i[s]}),n=N&&N.__exportStar||function(r,i){for(var s in r)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,r,s)};Object.defineProperty(t,"__esModule",{value:!0}),n(GA,t)}(oD);var mu={};Object.defineProperty(mu,"__esModule",{value:!0}),mu.getDialectFunction=mu.registerDialect=mu.getDialect=void 0;const _de=nD,Cde=eD,bde=iD,Tde=jN,Rde=oD,uD=new Map;function Ode(t){const e=uD.get(t);if(e===void 0)throw new Error(`Unknown Dialect ${t}`);return e}mu.getDialect=Ode;function Wd(t){uD.set(t.name,t)}mu.registerDialect=Wd,Wd(new Cde.PostgresDialect),Wd(new Tde.StandardSQLDialect),Wd(new _de.DuckDBDialect),Wd(new bde.SnowflakeDialect),Wd(new Rde.TrinoDialect);function KP(t,e){return t.params.length===e.params.length&&t.params.every((n,r)=>{const i=e.params[r];return n.isVariadic===i.isVariadic&&n.name===i.name&&n.allowedTypes.length===i.allowedTypes.length&&n.allowedTypes.every(s=>i.allowedTypes.some(o=>s.dataType===o.dataType&&s.expressionType===o.expressionType))})}function Nde(t,e){return KP(t,e)}function Dde(t,e){return t.returnType.dataType===e.returnType.dataType&&t.returnType.expressionType===e.returnType.expressionType}function Fde(t){const e={type:"function",name:t,overloads:[]};let n=!1;for(const r of uD.values()){const i=r.getGlobalFunctionDef(t);if(i){for(const s of i){let o=!1;for(const u of e.overloads)if(Nde(s,u)){if(!KP(s,u))throw new Error("params are compatible but not equal");if(!Dde(s,u))throw new Error("params match but return types differ!");u.dialect[r.name]={e:s.e,supportsOrderBy:s.supportsOrderBy,defaultOrderByArgIndex:s.defaultOrderByArgIndex,supportsLimit:s.supportsLimit},o=!0}o||e.overloads.push({returnType:s.returnType,params:s.params,dialect:{[r.name]:{e:s.e,supportsOrderBy:s.supportsOrderBy,defaultOrderByArgIndex:s.defaultOrderByArgIndex,supportsLimit:s.supportsLimit}},needsWindowOrderBy:s.needsWindowOrderBy,between:s.between,isSymmetric:s.isSymmetric})}n=!0}}return n?e:void 0}mu.getDialectFunction=Fde,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.FUNCTIONS=t.getDialectFunction=t.registerDialect=t.getDialect=t.TrinoDialect=t.SnowflakeDialect=t.DuckDBDialect=t.PostgresDialect=t.StandardSQLDialect=t.qtz=t.Dialect=t.sql=t.literal=t.params=t.param=t.sqlFragment=t.spread=t.maxScalar=t.minAggregate=t.minScalar=t.overload=t.makeParam=t.anyExprType=t.arg=void 0;var e=ve;Object.defineProperty(t,"arg",{enumerable:!0,get:function(){return e.arg}}),Object.defineProperty(t,"anyExprType",{enumerable:!0,get:function(){return e.anyExprType}}),Object.defineProperty(t,"makeParam",{enumerable:!0,get:function(){return e.makeParam}}),Object.defineProperty(t,"overload",{enumerable:!0,get:function(){return e.overload}}),Object.defineProperty(t,"minScalar",{enumerable:!0,get:function(){return e.minScalar}}),Object.defineProperty(t,"minAggregate",{enumerable:!0,get:function(){return e.minAggregate}}),Object.defineProperty(t,"maxScalar",{enumerable:!0,get:function(){return e.maxScalar}}),Object.defineProperty(t,"spread",{enumerable:!0,get:function(){return e.spread}}),Object.defineProperty(t,"sqlFragment",{enumerable:!0,get:function(){return e.sqlFragment}}),Object.defineProperty(t,"param",{enumerable:!0,get:function(){return e.param}}),Object.defineProperty(t,"params",{enumerable:!0,get:function(){return e.params}}),Object.defineProperty(t,"literal",{enumerable:!0,get:function(){return e.literal}}),Object.defineProperty(t,"sql",{enumerable:!0,get:function(){return e.sql}});var n=Hc;Object.defineProperty(t,"Dialect",{enumerable:!0,get:function(){return n.Dialect}}),Object.defineProperty(t,"qtz",{enumerable:!0,get:function(){return n.qtz}});var r=jN;Object.defineProperty(t,"StandardSQLDialect",{enumerable:!0,get:function(){return r.StandardSQLDialect}});var i=eD;Object.defineProperty(t,"PostgresDialect",{enumerable:!0,get:function(){return i.PostgresDialect}});var s=nD;Object.defineProperty(t,"DuckDBDialect",{enumerable:!0,get:function(){return s.DuckDBDialect}});var o=iD;Object.defineProperty(t,"SnowflakeDialect",{enumerable:!0,get:function(){return o.SnowflakeDialect}});var u=oD;Object.defineProperty(t,"TrinoDialect",{enumerable:!0,get:function(){return u.TrinoDialect}});var a=mu;Object.defineProperty(t,"getDialect",{enumerable:!0,get:function(){return a.getDialect}}),Object.defineProperty(t,"registerDialect",{enumerable:!0,get:function(){return a.registerDialect}}),Object.defineProperty(t,"getDialectFunction",{enumerable:!0,get:function(){return a.getDialectFunction}});var l=zc;Object.defineProperty(t,"FUNCTIONS",{enumerable:!0,get:function(){return l.FUNCTIONS}})}(T3);var yu={},cf={};Object.defineProperty(cf,"__esModule",{value:!0}),cf.QueryModel=cf.Segment=void 0;const wde=T3,Lde=D2,je=ne,vr=Gt;function JP(t){return t.map(e=>encodeURIComponent(e)).join("/")}function aD(t){return`'${t}'`}function ZP(t){return t.replace(/[^a-zA-Z0-9_]/g,"_o_")}class Ide extends Set{add_use(e){if(e!==void 0)return this.add(e)}hasAsymetricFunctions(){return this.has("sum")||this.has("avg")||this.has("count")||this.has("generic_asymmetric_aggregate")}}class H2{constructor(e=!0,n){this.parent=n,this.withs=[],this.udfs=[],this.pdts=[],this.stagePrefix="__stage",this.useCTE=e}getName(e){return`${this.stagePrefix}${e}`}root(){return this.parent===void 0?this:this.parent.root()}addStage(e){return this.useCTE?(this.withs.push(e),this.getName(this.withs.length-1)):(this.withs[0]=e,(0,vr.indent)(`
|
|
276
276
|
(${e})
|
|
277
277
|
`))}addUDF(e,n,r){let{sql:i,lastStageName:s}=e.combineStages(!0);if(s===void 0)throw new Error("Internal Error: no stage to combine");i+=n.sqlCreateFunctionCombineLastStage(s,r);const o=`${n.udfPrefix}${this.root().udfs.length}`;return i=n.sqlCreateFunction(o,i),this.root().udfs.push(i),o}addPDT(e,n){const r=this.combineStages(!1).sql+this.withs[this.withs.length-1],i="scratch."+e+(0,vr.generateHash)(r);return this.root().pdts.push(n.sqlCreateTableAsSelect(i,r)),i}combineStages(e){if(!this.useCTE)return{sql:this.withs[0],lastStageName:this.withs[0]};let n=this.getName(0),r="WITH ",i="";for(let s=0;s<this.withs.length-(e?0:1);s++){const o=this.withs[s];if(n=this.getName(s),o===void 0)throw new Error(`Expected sql WITH to be present for stage ${n}.`);i+=`${r}${n} AS (
|
|
278
278
|
${(0,vr.indent)(o)})
|
|
@@ -284,7 +284,7 @@ ${(0,vr.indent)(o)})
|
|
|
284
284
|
STRING_AGG(DISTINCT ${`concat('${f}', ${s}, '${x}', ${l})`}${c}),
|
|
285
285
|
'${f}.*?${x}',
|
|
286
286
|
''
|
|
287
|
-
)`}getParamForArgIndex(e,n){const r=e.slice(0,n).find(i=>i.isVariadic);return r??e[n]}generateFunctionCallExpression(e,n,r,i){var s,o,u;const a=r.overload,l=r.args,c=(s=r.overload.isSymmetric)!==null&&s!==void 0?s:!1,f=(0,je.expressionIsAggregate)(a.returnType.expressionType)&&!c&&this.generateDistinctKeyIfNecessary(e,n,r.structPath),x=r.limit?`LIMIT ${r.limit}`:void 0;if(r.name==="string_agg"&&f&&!n.dialect.supportsAggDistinct&&n.dialect.name!=="snowflake")return this.generateAsymmetricStringAggExpression(e,n,l[0],l[1],f,r.orderBy,n.dialect.name,i);if(f){if(!n.dialect.supportsAggDistinct)throw new Error(`Function \`${r.name}\` does not support fanning out in ${n.dialect.name}`);const h=l.map(g=>this.generateDimFragment(e,n,g,i)),p=(o=r.orderBy)!==null&&o!==void 0?o:[],m=p.map(g=>{var y,E;const A=(y=a.dialect[n.dialect.name].defaultOrderByArgIndex)!==null&&y!==void 0?y:0,S=(E=g.e)!==null&&E!==void 0?E:l[A];return this.generateDimFragment(e,n,S,i)});return n.dialect.sqlAggDistinct(f,[...h,...m],g=>{const y=g.map((C,_)=>_<l.length&&this.getParamForArgIndex(a.params,_).allowedTypes.every(R=>(0,je.isLiteral)(R.evalSpace))?l[_]:[C]),E=y.slice(0,h.length),A=y.slice(h.length).map((C,_)=>({e:C,dir:p[_].dir})),S=this.getFunctionOrderBy(e,n,i,A,E,a),v=this.expandFunctionCall(n.dialect.name,a,E,S,x);return this.generateExpressionFromExpr(e,n,v,i)})}else{const h=(0,je.expressionIsAggregate)(a.returnType.expressionType)?l.map((g,y)=>this.getParamForArgIndex(a.params,y).allowedTypes.every(A=>(0,je.isLiteral)(A.evalSpace))?g:[this.generateDimFragment(e,n,g,i)]):l,p=r.orderBy?this.getFunctionOrderBy(e,n,i,r.orderBy,l,a):"",m=this.expandFunctionCall(n.dialect.name,a,h,p,x);if((0,je.expressionIsAnalytic)(a.returnType.expressionType)){const g=((u=r.partitionBy)!==null&&u!==void 0?u:[]).map(y=>`(${e.getField(y).getAnalyticalSQL(!1)})`);return this.generateAnalyticFragment(e,n,m,a,i,l,g,p)}return this.generateExpressionFromExpr(e,n,m,i)}}generateSpread(e,n,r,i){throw new Error("Unexpanded spread encountered during SQL generation")}generateParameterFragment(e,n,r,i){throw new Error(`Can't generate SQL, no value for ${r.path}`)}generateFilterFragment(e,n,r,i){const s=new vr.AndChain(i.whereSQL);for(const o of r.filterList)s.add(this.generateExpressionFromExpr(e,n,o.expression,i.withWhere()));return this.generateExpressionFromExpr(e,n,r.e,i.withWhere(s.sql()))}generateDimFragment(e,n,r,i){let s=this.generateExpressionFromExpr(e,n,r,i);return i.whereSQL&&(s=`CASE WHEN ${i.whereSQL} THEN ${s} END`),s}generateUngroupedFragment(e,n,r,i){if(i.totalGroupSet!==-1)throw new Error("Already in ALL. Cannot nest within an all calcuation.");let s,o;if(r.fields&&r.fields.length>0){const f=r.fields.sort().join("|")+r.type;if(o=e.ungroupedSets.get(f),o===void 0)throw new Error(`Internal Error, cannot find groupset with key ${f}`);s=o.groupSet}else s=e.parent?e.parent.groupSet:0;const u=this.generateExpressionFromExpr(e,n,r.e,i.withTotal(s)),a=e.getUngroupPartitions(o);let l="";const c=a.map(f=>f.getAnalyticalSQL(!0)).join(", ");return c.length>0&&(l=`PARTITION BY ${c}`),`MAX(${u}) OVER (${l})`}generateDistinctKeyIfNecessary(e,n,r){let i=n;if(r&&(i=this.parent.root().getStructByName(r)),i.needsSymetricCalculation(e))return i.getDistinctKey().generateExpression(e)}generateSumFragment(e,n,r,i){const s=this.generateDimFragment(e,n,r.e,i),o=this.generateDistinctKeyIfNecessary(e,n,r.structPath);let u;return o?this.parent.dialect.supportsSumDistinctFunction?u=this.parent.dialect.sqlSumDistinct(o,s,"SUM"):u=rM(this.parent.dialect,s,o):u=`SUM(${s})`,`COALESCE(${u},0)`}generateSymmetricFragment(e,n,r,i){const s=this.generateDimFragment(e,n,r.e,i);return`${r.function==="count_distinct"?"count(distinct ":r.function+"("}${s})`}generateAvgFragment(e,n,r,i){const s=this.generateDimFragment(e,n,r.e,i),o=this.generateDistinctKeyIfNecessary(e,n,r.structPath);if(o){let u=o;i.whereSQL&&(u=`CASE WHEN ${i.whereSQL} THEN ${o} END`);let a,l;return this.parent.dialect.supportsSumDistinctFunction?l=this.parent.dialect.sqlSumDistinct(o,s,"AVG"):(a=rM(this.parent.dialect,s,o),l=`(${a})/NULLIF(COUNT(DISTINCT CASE WHEN ${s} IS NOT NULL THEN ${u} END),0)`),l}else return`AVG(${s})`}generateCountFragment(e,n,r,i){let s="COUNT(",o="1",u=n;r.structPath&&(u=this.parent.root().getStructByName(r.structPath));const a=u.getJoinableParent().getIdentifier(),l=e.root().joins.get(a);if(!l)throw new Error(`Join ${a} not found in result set`);return(!l.leafiest||l.makeUniqueKey)&&(s="COUNT(DISTINCT ",o=u.getDistinctKey().generateExpression(e)),i.whereSQL?`${s}CASE WHEN ${i.whereSQL} THEN ${o} END)`:`${s}${o})`}generateDialect(e,n,r,i){return this.generateExpressionFromExpr(e,n,n.dialect.dialectExpr(e.getQueryInfo(),r),i)}generateSqlString(e,n,r,i){return r.e.map(s=>typeof s=="string"?s:this.generateExpressionFromExpr(e,n,[s],i)).join("")}generateSourceReference(e,n,r){return r.path===void 0?n.getSQLIdentifier():n.getFieldByName(r.path).getIdentifier()}getAnalyticPartitions(e,n){const r=[];let i=e.parent;for(;i!==void 0;){const o=i.fields(u=>_r(u.f)&&u.fieldUsage.type==="result").map(u=>u.getAnalyticalSQL(!0));r.push(...o),i=i.parent}return n&&r.push(...n),r}generateAnalyticFragment(e,n,r,i,s,o,u,a){const l=e.root().isComplexQuery,c=this.getAnalyticPartitions(e,u),f=[...l?["group_set"]:[],...c],x=f.length>0?`PARTITION BY ${f.join(", ")}`:"";let h=a??"";if(!a&&i.needsWindowOrderBy){const g=[];let y;const E=e.firstSegment.orderBy||e.calculateDefaultOrderBy();for(const A of E){typeof A.field=="string"?y={name:A.field,fif:e.getField(A.field)}:y=e.getFieldByNumber(A.field);const S=y.fif.f.fieldDef.expressionType;if(!(0,je.expressionIsAnalytic)(S))if(e.firstSegment.type==="reduce"){const v=y.fif.getAnalyticalSQL(!1);g.push(` ${v} ${A.dir||"ASC"}`)}else e.firstSegment.type==="project"&&g.push(` ${y.fif.f.generateExpression(e)} ${A.dir||"ASC"}`)}g.length>0&&(h=" "+this.parent.dialect.sqlOrderBy(g))}let p="";if(i.between){const[g,y]=[i.between.preceding,i.between.following].map(E=>{if(E===-1)return"UNBOUNDED";if(typeof E=="number")return E;const A=i.params.findIndex(v=>v.name===E),S=o[A];if(S.length!==1||typeof S[0]=="string"||S[0].type!=="dialect"||S[0].function!=="numberLiteral")throw new Error("Invalid number of rows for window spec");return S[0].literal});p=`ROWS BETWEEN ${g} PRECEDING AND ${y} FOLLOWING`}return`${this.generateExpressionFromExpr(e,n,r,s)} OVER(${x} ${h} ${p})`}generateExpressionFromExpr(e,n,r,i=new z2){let s="";for(const o of r)if(typeof o=="string")s+=o;else if((0,je.isFieldFragment)(o))s+=this.generateFieldFragment(e,n,o,i);else if((0,je.isParameterFragment)(o))s+=this.generateParameterFragment(e,n,o,i);else if((0,je.isFilterFragment)(o))s+=this.generateFilterFragment(e,n,o,i);else if((0,je.isUngroupFragment)(o))s+=this.generateUngroupedFragment(e,n,o,i);else if((0,je.isAggregateFragment)(o)){let u;if(o.function==="sum")u=this.generateSumFragment(e,n,o,i);else if(o.function==="avg")u=this.generateAvgFragment(e,n,o,i);else if(o.function==="count")u=this.generateCountFragment(e,n,o,i);else if(["count_distinct","min","max"].includes(o.function))u=this.generateSymmetricFragment(e,n,o,i);else throw new Error(`Internal Error: Unknown aggregate function ${o.function}`);if(e.root().isComplexQuery){let a=e.groupSet;i.totalGroupSet!==-1&&(a=i.totalGroupSet),s+=this.caseGroup([a],u)}else s+=u}else if((0,je.isApplyFragment)(o)){const u=this.generateExpressionFromExpr(e,n,o.value,i);s+=this.generateExpressionFromExpr(e,n,o.to,i.withApply(u))}else if((0,je.isApplyValue)(o))if(i.applyValue)s+=i.applyValue;else throw new Error("Internal Error: Partial application value referenced but not provided");else{if((0,je.isFunctionParameterFragment)(o))throw new Error("Internal Error: Function parameter fragment remaining during SQL generation");if((0,je.isOutputFieldFragment)(o))s+=this.generateOutputFieldFragment(e,n,o,i);else if((0,je.isSQLExpressionFragment)(o))s+=this.generateSQLExpression(e,n,o,i);else if((0,je.isFunctionCallFragment)(o))s+=this.generateFunctionCallExpression(e,n,o,i);else if((0,je.isSpreadFragment)(o))s+=this.generateSpread(e,n,o,i);else if(o.type==="dialect")s+=this.generateDialect(e,n,o,i);else if(o.type==="sql-string")s+=this.generateSqlString(e,n,o,i);else if(o.type==="source-reference")s+=this.generateSourceReference(e,n,o);else throw new Error(`Internal Error: Unknown expression fragment ${JSON.stringify(o,void 0,2)}`)}return s}getExpr(){return(0,je.hasExpression)(this.fieldDef)?this.fieldDef.e:[this.parent.dialect.sqlFieldReference(this.parent.getSQLIdentifier(),this.fieldDef.name,this.fieldDef.type,this.parent.fieldDef.structSource.type==="nested"||this.parent.fieldDef.structSource.type==="inline"||this.parent.fieldDef.structSource.type==="sql"&&this.parent.fieldDef.structSource.method==="nested",this.parent.fieldDef.structRelationship.type==="nested"&&this.parent.fieldDef.structRelationship.isArray)]}generateExpression(e){return this.generateExpressionFromExpr(e,this.parent,this.getExpr())}};function YA(t){return t instanceof Pr&&t.isCalculated()}function tM(t){return t instanceof Pr&&t.isAggregate()}function _r(t){return t instanceof Pr&&!t.isCalculated()&&!t.isAggregate()}class Pr extends VA{includeInWildcard(){return!0}isCalculated(){return(0,je.expressionIsCalculation)(this.fieldDef.expressionType)}isAggregate(){return(0,je.expressionIsAggregate)(this.fieldDef.expressionType)}getFilterList(){return[]}hasExpression(){return(0,je.hasExpression)(this.fieldDef)}}class Bde extends Pr{}class $de extends Pr{}class lD extends Pr{}class kde extends Pr{}class Pde extends Pr{}class Mde extends Pr{constructor(e,n,r){super(e,n),this.primaryKey=r}getName(){return(0,je.getIdentifier)(this.fieldDef)}getAsJoinedStructDef(e){return{...this.parent.fieldDef,structRelationship:{type:"one",matrixOperation:"left",onExpression:[{type:"field",path:[this.primaryKey]},"=",{type:"field",path:[e]}]}}}}class cD extends Pr{generateExpression(e){const n=this.fieldDef;if(n.timeframe){const r=this.parent.dialect.sqlTrunc(e.getQueryInfo(),{value:this.getExpr(),valueType:"date"},n.timeframe);return this.generateExpressionFromExpr(e,this.parent,r)}else return super.generateExpression(e)}getChildByName(e){const n={...this.fieldDef,as:`${this.getIdentifier()}_${e}`,timeframe:e};return new cD(n,this.parent)}}class fD extends Pr{getChildByName(e){const n={...this.fieldDef,as:`${this.getIdentifier()}_${e}`,timeframe:e};return new fD(n,this.parent)}}class jde extends Pr{generateExpression(e){var n;if(this.parent.primaryKey())return this.parent.getPrimaryKeyField(this.fieldDef).generateExpression(e);if(this.parent.fieldDef.structSource.type==="nested"){const r=(n=this.parent.parent)===null||n===void 0?void 0:n.getDistinctKey().generateExpression(e);return this.parent.dialect.concat(r||"","'x'",this.parent.dialect.sqlFieldReference(this.parent.getIdentifier(),"__row_id","string",!0,!1))}else return this.parent.dialect.sqlFieldReference(this.parent.getIdentifier(),"__distinct_key","string",this.parent.fieldDef.structRelationship.type==="nested",!1)}includeInWildcard(){return!1}}const nM=9;function rM(t,e,n){const i=t.sqlSumDistinctHashedKey(n),s=10**(9-nM);let u=`(${`
|
|
287
|
+
)`}getParamForArgIndex(e,n){const r=e.slice(0,n).find(i=>i.isVariadic);return r??e[n]}generateFunctionCallExpression(e,n,r,i){var s,o,u;const a=r.overload,l=r.args,c=(s=r.overload.isSymmetric)!==null&&s!==void 0?s:!1,f=(0,je.expressionIsAggregate)(a.returnType.expressionType)&&!c&&this.generateDistinctKeyIfNecessary(e,n,r.structPath),x=r.limit?`LIMIT ${r.limit}`:void 0;if(r.name==="string_agg"&&f&&!n.dialect.supportsAggDistinct&&n.dialect.name!=="snowflake")return this.generateAsymmetricStringAggExpression(e,n,l[0],l[1],f,r.orderBy,n.dialect.name,i);if(f){if(!n.dialect.supportsAggDistinct)throw new Error(`Function \`${r.name}\` does not support fanning out in ${n.dialect.name}`);const h=l.map(g=>this.generateDimFragment(e,n,g,i)),p=(o=r.orderBy)!==null&&o!==void 0?o:[],m=p.map(g=>{var y,E;const A=(y=a.dialect[n.dialect.name].defaultOrderByArgIndex)!==null&&y!==void 0?y:0,S=(E=g.e)!==null&&E!==void 0?E:l[A];return this.generateDimFragment(e,n,S,i)});return n.dialect.sqlAggDistinct(f,[...h,...m],g=>{const y=g.map((C,_)=>_<l.length&&this.getParamForArgIndex(a.params,_).allowedTypes.every(R=>(0,je.isLiteral)(R.evalSpace))?l[_]:[C]),E=y.slice(0,h.length),A=y.slice(h.length).map((C,_)=>({e:C,dir:p[_].dir})),S=this.getFunctionOrderBy(e,n,i,A,E,a),v=this.expandFunctionCall(n.dialect.name,a,E,S,x);return this.generateExpressionFromExpr(e,n,v,i)})}else{const h=(0,je.expressionIsAggregate)(a.returnType.expressionType)?l.map((g,y)=>this.getParamForArgIndex(a.params,y).allowedTypes.every(A=>(0,je.isLiteral)(A.evalSpace))?g:[this.generateDimFragment(e,n,g,i)]):l,p=r.orderBy?this.getFunctionOrderBy(e,n,i,r.orderBy,l,a):"",m=this.expandFunctionCall(n.dialect.name,a,h,p,x);if((0,je.expressionIsAnalytic)(a.returnType.expressionType)){const g=((u=r.partitionBy)!==null&&u!==void 0?u:[]).map(y=>`(${e.getField(y).getAnalyticalSQL(!1)})`);return this.generateAnalyticFragment(e,n,m,a,i,l,g,p)}return this.generateExpressionFromExpr(e,n,m,i)}}generateSpread(e,n,r,i){throw new Error("Unexpanded spread encountered during SQL generation")}generateParameterFragment(e,n,r,i){throw new Error(`Can't generate SQL, no value for ${r.path}`)}generateFilterFragment(e,n,r,i){const s=new vr.AndChain(i.whereSQL);for(const o of r.filterList)s.add(this.generateExpressionFromExpr(e,n,o.expression,i.withWhere()));return this.generateExpressionFromExpr(e,n,r.e,i.withWhere(s.sql()))}generateDimFragment(e,n,r,i){let s=this.generateExpressionFromExpr(e,n,r,i);return i.whereSQL&&(s=`CASE WHEN ${i.whereSQL} THEN ${s} END`),s}generateUngroupedFragment(e,n,r,i){if(i.totalGroupSet!==-1)throw new Error("Already in ALL. Cannot nest within an all calcuation.");let s,o;if(r.fields&&r.fields.length>0){const f=r.fields.sort().join("|")+r.type;if(o=e.ungroupedSets.get(f),o===void 0)throw new Error(`Internal Error, cannot find groupset with key ${f}`);s=o.groupSet}else s=e.parent?e.parent.groupSet:0;const u=this.generateExpressionFromExpr(e,n,r.e,i.withTotal(s)),a=e.getUngroupPartitions(o);let l="";const c=a.map(f=>f.getAnalyticalSQL(!0)).join(", ");return c.length>0&&(l=`PARTITION BY ${c}`),`MAX(${u}) OVER (${l})`}generateDistinctKeyIfNecessary(e,n,r){let i=n;if(r&&(i=this.parent.root().getStructByName(r)),i.needsSymetricCalculation(e))return i.getDistinctKey().generateExpression(e)}generateSumFragment(e,n,r,i){const s=this.generateDimFragment(e,n,r.e,i),o=this.generateDistinctKeyIfNecessary(e,n,r.structPath);let u;return o?this.parent.dialect.supportsSumDistinctFunction?u=this.parent.dialect.sqlSumDistinct(o,s,"SUM"):u=rM(this.parent.dialect,s,o):u=`SUM(${s})`,`COALESCE(${u},0)`}generateSymmetricFragment(e,n,r,i){const s=this.generateDimFragment(e,n,r.e,i);return`${r.function==="count_distinct"?"count(distinct ":r.function+"("}${s})`}generateAvgFragment(e,n,r,i){const s=this.generateDimFragment(e,n,r.e,i),o=this.generateDistinctKeyIfNecessary(e,n,r.structPath);if(o){let u=o;i.whereSQL&&(u=`CASE WHEN ${i.whereSQL} THEN ${o} END`);let a,l;return this.parent.dialect.supportsSumDistinctFunction?l=this.parent.dialect.sqlSumDistinct(o,s,"AVG"):(a=rM(this.parent.dialect,s,o),l=`(${a})/NULLIF(COUNT(DISTINCT CASE WHEN ${s} IS NOT NULL THEN ${u} END),0)`),l}else return`AVG(${s})`}generateCountFragment(e,n,r,i){let s="COUNT(",o="1",u=n;r.structPath&&(u=this.parent.root().getStructByName(r.structPath));const a=u.getJoinableParent().getIdentifier(),l=e.root().joins.get(a);if(!l)throw new Error(`Join ${a} not found in result set`);return(!l.leafiest||l.makeUniqueKey)&&(s="COUNT(DISTINCT ",o=u.getDistinctKey().generateExpression(e)),i.whereSQL?`${s}CASE WHEN ${i.whereSQL} THEN ${o} END)`:`${s}${o})`}generateDialect(e,n,r,i){return this.generateExpressionFromExpr(e,n,n.dialect.dialectExpr(e.getQueryInfo(),r),i)}generateSqlString(e,n,r,i){return r.e.map(s=>typeof s=="string"?s:this.generateExpressionFromExpr(e,n,[s],i)).join("")}generateSourceReference(e,n,r){return r.path===void 0?n.getSQLIdentifier():n.getFieldByName(r.path).getIdentifier()}getAnalyticPartitions(e,n){const r=[];let i=e.parent;for(;i!==void 0;){const o=i.fields(u=>_r(u.f)&&u.fieldUsage.type==="result").map(u=>u.getAnalyticalSQL(!0));r.push(...o),i=i.parent}return n&&r.push(...n),r}generateAnalyticFragment(e,n,r,i,s,o,u,a){const l=e.root().isComplexQuery,c=this.getAnalyticPartitions(e,u),f=[...l?["group_set"]:[],...c],x=f.length>0?`PARTITION BY ${f.join(", ")}`:"";let h=a??"";if(!a&&i.needsWindowOrderBy){const g=[];let y;const E=e.firstSegment.orderBy||e.calculateDefaultOrderBy();for(const A of E){typeof A.field=="string"?y={name:A.field,fif:e.getField(A.field)}:y=e.getFieldByNumber(A.field);const S=y.fif.f.fieldDef.expressionType;if(!(0,je.expressionIsAnalytic)(S))if(e.firstSegment.type==="reduce"){const v=y.fif.getAnalyticalSQL(!1);g.push(` ${v} ${A.dir||"ASC"}`)}else e.firstSegment.type==="project"&&g.push(` ${y.fif.f.generateExpression(e)} ${A.dir||"ASC"}`)}g.length>0&&(h=" "+this.parent.dialect.sqlOrderBy(g))}let p="";if(i.between){const[g,y]=[i.between.preceding,i.between.following].map(E=>{if(E===-1)return"UNBOUNDED";if(typeof E=="number")return E;const A=i.params.findIndex(v=>v.name===E),S=o[A];if(S.length!==1||typeof S[0]=="string"||S[0].type!=="dialect"||S[0].function!=="numberLiteral")throw new Error("Invalid number of rows for window spec");return S[0].literal});p=`ROWS BETWEEN ${g} PRECEDING AND ${y} FOLLOWING`}return`${this.generateExpressionFromExpr(e,n,r,s)} OVER(${x} ${h} ${p})`}generateExpressionFromExpr(e,n,r,i=new z2){let s="";for(const o of r)if(typeof o=="string")s+=o;else if((0,je.isFieldFragment)(o))s+=this.generateFieldFragment(e,n,o,i);else if((0,je.isParameterFragment)(o))s+=this.generateParameterFragment(e,n,o,i);else if((0,je.isFilterFragment)(o))s+=this.generateFilterFragment(e,n,o,i);else if((0,je.isUngroupFragment)(o))s+=this.generateUngroupedFragment(e,n,o,i);else if((0,je.isAggregateFragment)(o)){let u;if(o.function==="sum")u=this.generateSumFragment(e,n,o,i);else if(o.function==="avg")u=this.generateAvgFragment(e,n,o,i);else if(o.function==="count")u=this.generateCountFragment(e,n,o,i);else if(["count_distinct","min","max"].includes(o.function))u=this.generateSymmetricFragment(e,n,o,i);else throw new Error(`Internal Error: Unknown aggregate function ${o.function}`);if(e.root().isComplexQuery){let a=e.groupSet;i.totalGroupSet!==-1&&(a=i.totalGroupSet),s+=this.caseGroup([a],u)}else s+=u}else if((0,je.isApplyFragment)(o)){const u=this.generateExpressionFromExpr(e,n,o.value,i);s+=this.generateExpressionFromExpr(e,n,o.to,i.withApply(u))}else if((0,je.isApplyValue)(o))if(i.applyValue)s+=i.applyValue;else throw new Error("Internal Error: Partial application value referenced but not provided");else{if((0,je.isFunctionParameterFragment)(o))throw new Error("Internal Error: Function parameter fragment remaining during SQL generation");if((0,je.isOutputFieldFragment)(o))s+=this.generateOutputFieldFragment(e,n,o,i);else if((0,je.isSQLExpressionFragment)(o))s+=this.generateSQLExpression(e,n,o,i);else if((0,je.isFunctionCallFragment)(o))s+=this.generateFunctionCallExpression(e,n,o,i);else if((0,je.isSpreadFragment)(o))s+=this.generateSpread(e,n,o,i);else if(o.type==="dialect")s+=this.generateDialect(e,n,o,i);else if(o.type==="sql-string")s+=this.generateSqlString(e,n,o,i);else if(o.type==="source-reference")s+=this.generateSourceReference(e,n,o);else throw new Error(`Internal Error: Unknown expression fragment ${JSON.stringify(o,void 0,2)}`)}return s}getExpr(){return(0,je.hasExpression)(this.fieldDef)?this.fieldDef.e:[this.parent.dialect.sqlFieldReference(this.parent.getSQLIdentifier(),this.fieldDef.name,this.fieldDef.type,this.parent.fieldDef.structSource.type==="nested"||this.parent.fieldDef.structSource.type==="inline"||this.parent.fieldDef.structSource.type==="sql"&&this.parent.fieldDef.structSource.method==="nested",this.parent.fieldDef.structRelationship.type==="nested"&&this.parent.fieldDef.structRelationship.isArray)]}generateExpression(e){return this.generateExpressionFromExpr(e,this.parent,this.getExpr())}};function YA(t){return t instanceof Pr&&t.isCalculated()}function tM(t){return t instanceof Pr&&t.isAggregate()}function _r(t){return t instanceof Pr&&!t.isCalculated()&&!t.isAggregate()}class Pr extends VA{includeInWildcard(){return!0}isCalculated(){return(0,je.expressionIsCalculation)(this.fieldDef.expressionType)}isAggregate(){return(0,je.expressionIsAggregate)(this.fieldDef.expressionType)}getFilterList(){return[]}hasExpression(){return(0,je.hasExpression)(this.fieldDef)}}class Bde extends Pr{}class $de extends Pr{}class lD extends Pr{}class kde extends Pr{}class Pde extends Pr{}class Mde extends Pr{constructor(e,n,r){super(e,n),this.primaryKey=r}getName(){return(0,je.getIdentifier)(this.fieldDef)}getAsJoinedStructDef(e){return{...this.parent.fieldDef,structRelationship:{type:"one",matrixOperation:"left",onExpression:[{type:"field",path:[this.primaryKey]},"=",{type:"field",path:[e]}]}}}}class cD extends Pr{generateExpression(e){const n=this.fieldDef;if(n.timeframe){const r=this.parent.dialect.sqlTrunc(e.getQueryInfo(),{value:this.getExpr(),valueType:"date"},n.timeframe);return this.generateExpressionFromExpr(e,this.parent,r)}else return super.generateExpression(e)}getChildByName(e){const n={...this.fieldDef,as:`${this.getIdentifier()}_${e}`,timeframe:e};return new cD(n,this.parent)}}class fD extends Pr{getChildByName(e){const n={...this.fieldDef,as:`${this.getIdentifier()}_${e}`,timeframe:e};return new fD(n,this.parent)}}class jde extends Pr{generateExpression(e){var n;if(this.parent.primaryKey())return this.parent.getPrimaryKeyField(this.fieldDef).generateExpression(e);if(this.parent.fieldDef.structSource.type==="nested"){const r=(n=this.parent.parent)===null||n===void 0?void 0:n.getDistinctKey().generateExpression(e);return this.parent.dialect.sqlMakeUnnestKey(r||"",this.parent.dialect.sqlFieldReference(this.parent.getIdentifier(),"__row_id","string",!0,!1))}else return this.parent.dialect.sqlFieldReference(this.parent.getIdentifier(),"__distinct_key","string",this.parent.fieldDef.structRelationship.type==="nested",!1)}includeInWildcard(){return!1}}const nM=9;function rM(t,e,n){const i=t.sqlSumDistinctHashedKey(n),s=10**(9-nM);let u=`(${`
|
|
288
288
|
(
|
|
289
289
|
SUM(DISTINCT
|
|
290
290
|
(CAST(ROUND(COALESCE(${e},0)*(${s}*1.0), ${nM}) AS ${t.defaultDecimalType}) +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/render",
|
|
3
|
-
"version": "0.0.138-
|
|
3
|
+
"version": "0.0.138-dev240404233606",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/module/index.umd.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"build-types": "tsc --build --declaration --emitDeclarationOnly"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@malloydata/malloy": "^0.0.138-
|
|
36
|
+
"@malloydata/malloy": "^0.0.138-dev240404233606",
|
|
37
37
|
"@types/luxon": "^2.4.0",
|
|
38
38
|
"component-register": "^0.8.3",
|
|
39
39
|
"lodash": "^4.17.20",
|