@malloydata/render 0.0.238 → 0.0.239-dev250226183425

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.
@@ -54136,7 +54136,7 @@ sh.exploreQueryWalkerBuilder = wDe;
54136
54136
  var Oe = {}, YS = {};
54137
54137
  Object.defineProperty(YS, "__esModule", { value: !0 });
54138
54138
  YS.MALLOY_VERSION = void 0;
54139
- YS.MALLOY_VERSION = "0.0.238";
54139
+ YS.MALLOY_VERSION = "0.0.239";
54140
54140
  Object.defineProperty(Oe, "__esModule", { value: !0 });
54141
54141
  Oe.InMemoryModelCache = Oe.CacheManager = Oe.CSVWriter = Oe.JSONWriter = Oe.DataWriter = Oe.DataRecord = Oe.DataArray = Oe.Result = Oe.ExploreMaterializer = Oe.PreparedResultMaterializer = Oe.QueryMaterializer = Oe.ModelMaterializer = Oe.SingleConnectionRuntime = Oe.ConnectionRuntime = Oe.Runtime = Oe.ExploreField = Oe.JoinRelationship = Oe.QueryField = Oe.Query = Oe.StringField = Oe.UnsupportedField = Oe.JSONField = Oe.BooleanField = Oe.NumberField = Oe.TimestampField = Oe.DateField = Oe.TimestampTimeframe = Oe.DateTimeframe = Oe.AtomicField = Oe.AtomicFieldType = Oe.Explore = Oe.SourceRelationship = Oe.FixedConnectionMap = Oe.InMemoryURLReader = Oe.EmptyURLReader = Oe.PreparedResult = Oe.DocumentCompletion = Oe.DocumentSymbol = Oe.DocumentPosition = Oe.DocumentRange = Oe.DocumentTablePath = Oe.Parse = Oe.PreparedQuery = Oe.Model = Oe.MalloyError = Oe.Malloy = void 0;
54142
54142
  const bj = CN, tr = Xi, Tj = Gw, FR = Ph, LDe = YS, IDe = mm, bn = ds, Rj = "internal://internal.malloy";
@@ -56752,7 +56752,7 @@ function GDe(t) {
56752
56752
  }
56753
56753
  }
56754
56754
  (function(t) {
56755
- Object.defineProperty(t, "__esModule", { value: !0 }), t.InMemoryURLReader = t.EmptyURLReader = t.SingleConnectionRuntime = t.ConnectionRuntime = t.AtomicFieldType = t.Runtime = t.Malloy = t.Model = t.MalloyTranslator = t.composeSQLExpr = t.indent = t.expressionIsUngroupedAggregate = t.expressionIsScalar = t.expressionIsCalculation = t.expressionIsAnalytic = t.expressionIsAggregate = t.mkFieldDef = t.mkArrayDef = t.isScalarArray = t.isRepeatedRecord = t.isSamplingRows = t.isSamplingPercent = t.isSamplingEnable = t.isJoinedSource = t.isJoined = t.isLeafAtomic = t.Segment = t.isSourceDef = t.TinyParser = t.Dialect = t.spread = t.literal = t.variadicParam = t.param = t.makeParam = t.sql = t.maxScalar = t.minAggregate = t.anyExprType = t.minScalar = t.overload = t.qtz = t.arg = t.registerDialect = t.MySQLDialect = t.SnowflakeDialect = t.PostgresDialect = t.TrinoDialect = t.StandardSQLDialect = t.DuckDBDialect = void 0, t.annotationToTag = t.modelDefToModelInfo = t.toAsyncGenerator = t.CacheManager = t.InMemoryModelCache = t.Explore = t.DataWriter = t.Parse = t.JSONWriter = t.CSVWriter = t.QueryMaterializer = t.Result = t.PreparedResult = t.TimestampTimeframe = t.DateTimeframe = t.SourceRelationship = t.JoinRelationship = t.MalloyError = t.FixedConnectionMap = void 0;
56755
+ Object.defineProperty(t, "__esModule", { value: !0 }), t.InMemoryURLReader = t.EmptyURLReader = t.SingleConnectionRuntime = t.ConnectionRuntime = t.AtomicFieldType = t.Runtime = t.Malloy = t.Model = t.MalloyTranslator = t.composeSQLExpr = t.indent = t.expressionIsUngroupedAggregate = t.expressionIsScalar = t.expressionIsCalculation = t.expressionIsAnalytic = t.expressionIsAggregate = t.mkFieldDef = t.mkArrayDef = t.isScalarArray = t.isRepeatedRecord = t.isSamplingRows = t.isSamplingPercent = t.isSamplingEnable = t.isJoinedSource = t.isJoined = t.isLeafAtomic = t.Segment = t.isSourceDef = t.TinyParser = t.Dialect = t.spread = t.literal = t.variadicParam = t.param = t.makeParam = t.sql = t.maxScalar = t.minAggregate = t.anyExprType = t.minScalar = t.overload = t.qtz = t.arg = t.registerDialect = t.MySQLDialect = t.SnowflakeDialect = t.PostgresDialect = t.TrinoDialect = t.StandardSQLDialect = t.DuckDBDialect = void 0, t.annotationToTaglines = t.annotationToTag = t.modelDefToModelInfo = t.toAsyncGenerator = t.CacheManager = t.InMemoryModelCache = t.Explore = t.DataWriter = t.Parse = t.JSONWriter = t.CSVWriter = t.QueryMaterializer = t.Result = t.PreparedResult = t.TimestampTimeframe = t.DateTimeframe = t.SourceRelationship = t.JoinRelationship = t.MalloyError = t.FixedConnectionMap = void 0;
56756
56756
  var e = Ph;
56757
56757
  Object.defineProperty(t, "DuckDBDialect", { enumerable: !0, get: function() {
56758
56758
  return e.DuckDBDialect;
@@ -56904,6 +56904,8 @@ function GDe(t) {
56904
56904
  var u = ds;
56905
56905
  Object.defineProperty(t, "annotationToTag", { enumerable: !0, get: function() {
56906
56906
  return u.annotationToTag;
56907
+ } }), Object.defineProperty(t, "annotationToTaglines", { enumerable: !0, get: function() {
56908
+ return u.annotationToTaglines;
56907
56909
  } });
56908
56910
  })(Pt);
56909
56911
  function WDe(t, e, n, r) {
@@ -1271,7 +1271,7 @@ QUERY: ${(0,JQ.inspect)(n,{breakLength:72,depth:1/0})}`)}return XQ.ErrorFactory.
1271
1271
  | ${l}`,u>0&&(i=i+`
1272
1272
  | ${" ".repeat(u)}^`)}else i=`line ${o+1}: char ${u}: ${r.message}`}n!==s&&(i=`FILE: ${s}
1273
1273
  `+i,n=s),e!==""?e=`${e}
1274
- ${i}`:e=i}return e}childRequest(e){var n;const r=decodeURI(new URL(e,this.sourceURL).toString()),i=(n=this.childTranslators.get(r))===null||n===void 0?void 0:n.translate();if(i!=null&&i.compileSQL)return{compileSQL:i.compileSQL,partialModel:i.partialModel}}getChildExports(e){const n={},r=decodeURI(new URL(e,this.sourceURL).toString()),i=this.childTranslators.get(r);if(i&&i.translate().modelDef)for(const o of i.modelDef.exports){const u=i.modelDef.contents[o];((0,rDe.isSourceDef)(u)||u.type==="query")&&(n[o]=u)}return n}translate(e){if(this.finalAnswer)return this.finalAnswer;const n=this.translateStep.step(this,e);return n.final&&(this.finalAnswer=n),n}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let n=0;n<this.imports.length;n++){const r=this.imports[n];if((0,xDe.locationContainsPosition)(r.location,e))return r}}metadata(){return this.metadataStep.step(this)}modelAnnotation(e){return this.modelAnnotationStep.step(this,e)}tablePathInfo(){return this.tablePathInfoStep.step(this)}completions(e){return this.completionsStep.step(this,e)}helpContext(e){return this.helpContextStep.step(this,e)}defaultLocation(){return{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}rangeFromContext(e){return this.rangeFromTokens(e.start,e.stop||e.start)}rangeFromTokens(e,n){const r={line:e.line-1,character:e.charPositionInLine};if(this.parseStep.sourceInfo&&n.stopIndex!==-1){const i=this.parseStep.sourceInfo.lines.length-1;for(let s=e.line-1;s<=i;s++){const o=this.parseStep.sourceInfo.at[s];if(n.stopIndex>=o.begin&&n.stopIndex<o.end)return{start:r,end:{line:s,character:n.stopIndex-o.begin+1}}}return{start:r,end:{line:i,character:this.parseStep.sourceInfo.lines[i].length}}}return{start:r,end:r}}rangeFromToken(e){return this.rangeFromTokens(e,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const n=this.compilerFlags.tag("experimental");return n!==void 0&&(n.bare()||n.has("dialect",e))}}n0.MalloyTranslation=JO;class BW extends JO{constructor(e,n){super(e),this.root=n}}n0.MalloyChildTranslator=BW;class ODe extends JO{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new KO.Zone,this.importZone=new KO.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new KO.Zone,this.root=this,this.logger=new IW.BaseMessageLogger(i),r&&this.update(r)}update(e){var n,r,i;this.schemaZone.updateFrom(e.tables,(n=e.errors)===null||n===void 0?void 0:n.tables),this.importZone.updateFrom(e.urls,(r=e.errors)===null||r===void 0?void 0:r.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(i=e.errors)===null||i===void 0?void 0:i.compileSQL);for(const s in e.translations)this.pretranslatedModels.set(s,e.translations[s])}logError(e,n,r){return this.logger.log((0,IW.makeLogMessage)(e,n,{severity:"error",...r})),e}}n0.MalloyTranslator=ODe;function $W(t){return[...Object.keys(t),...Object.keys(t).map(e=>$W(t[e])).flat()]}var mh={};Object.defineProperty(mh,"__esModule",{value:!0}),mh.exploreQueryWalkerBuilder=mh.ExploreQueryWalker=void 0;const FDe=ql;class kW{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(n=>n.range[0]===void 0||n.range[1]===void 0?!1:n.range[0]<=e&&n.range[1]>=e)}filterAtOffset(e){const n=this.exploreQueryAtOffset(e);if(n)return n.filterRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}hasFilterListAtOffset(e){const n=this.exploreQueryAtOffset(e);return n?!!n.filterLists.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}mh.ExploreQueryWalker=kW;function NDe(t,e){const n=new kW(t),r=n;return FDe.ParseTreeWalker.DEFAULT.walk(r,e),n}mh.exploreQueryWalkerBuilder=NDe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=n0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=mh;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(iD);var Oe={},C_={};Object.defineProperty(C_,"__esModule",{value:!0}),C_.MALLOY_VERSION=void 0,C_.MALLOY_VERSION="0.0.238",Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.InMemoryModelCache=Oe.CacheManager=Oe.CSVWriter=Oe.JSONWriter=Oe.DataWriter=Oe.DataRecord=Oe.DataArray=Oe.Result=Oe.ExploreMaterializer=Oe.PreparedResultMaterializer=Oe.QueryMaterializer=Oe.ModelMaterializer=Oe.SingleConnectionRuntime=Oe.ConnectionRuntime=Oe.Runtime=Oe.ExploreField=Oe.JoinRelationship=Oe.QueryField=Oe.Query=Oe.StringField=Oe.UnsupportedField=Oe.JSONField=Oe.BooleanField=Oe.NumberField=Oe.TimestampField=Oe.DateField=Oe.TimestampTimeframe=Oe.DateTimeframe=Oe.AtomicField=Oe.AtomicFieldType=Oe.Explore=Oe.SourceRelationship=Oe.FixedConnectionMap=Oe.InMemoryURLReader=Oe.EmptyURLReader=Oe.PreparedResult=Oe.DocumentCompletion=Oe.DocumentSymbol=Oe.DocumentPosition=Oe.DocumentRange=Oe.DocumentTablePath=Oe.Parse=Oe.PreparedQuery=Oe.Model=Oe.MalloyError=Oe.Malloy=void 0;const PW=iD,rr=Li,MW=K7,XO=Hx,wDe=C_,LDe=K2,Tn=ss,UW="internal://internal.malloy";class Ui{static get version(){return wDe.MALLOY_VERSION}static _parse(e,n,r,i,s){n===void 0&&(n=new URL(UW));let o=n;i!=null&&i.importBaseURL&&(o=i==null?void 0:i.importBaseURL);const u=new PW.MalloyTranslator(n.toString(),o.toString(),{urls:{[n.toString()]:e}},r);return i!=null&&i.testEnvironment&&(u.allDialectsEnabled=!0),new qW(u,s)}static parse({url:e,urlReader:n,source:r,eventStream:i,options:s}){if(r!==void 0)return Ui._parse(r,e,i,s);if(n===void 0)throw new Error("Internal Error: urlReader is required.");if(e===void 0)throw new Error("Internal Error: url is required if source not present.");return F_(n,e).then(({contents:o,invalidationKey:u})=>Ui._parse(o,e,i,s,u))}static async compile({url:e,source:n,parse:r,urlReader:i,connections:s,model:o,refreshSchemaCache:u,noThrowOnError:a,eventStream:l,replaceMaterializedReferences:c,materializedTablePrefix:f,importBaseURL:d,cacheManager:h}){var p,m,g,y,E;let A;if(u&&(A=typeof u=="number"?u:Date.now()),e===void 0&&n===void 0&&r===void 0)throw new Error("Internal Error: url, source, or parse required.");e===void 0&&(r!==void 0?e=new URL(r._translator.sourceURL):e=new URL(UW));const v={};if(n===void 0&&h!==void 0){const _=await h.getCachedModelDef(i,e.toString());if(_)return new yh(_.modelDef,[],[e.toString(),...O_(_.modelDef.dependencies)])}d??(d=e);let C;const S=e.toString();if(r!==void 0){C=r._translator;const _=(p=r._invalidationKey)!==null&&p!==void 0?p:await f8(i,e);v[S]=_}else{if(n===void 0){const{contents:_,invalidationKey:b}=await F_(i,e);v[S]=b,n=_}else{const _=await f8(i,e);v[S]=_}C=new PW.MalloyTranslator(S,d.toString(),{urls:{[S]:n}},l)}for(;;){const _=C.translate(o==null?void 0:o._modelDef);if(_.final)if(_.modelDef){await(h==null?void 0:h.setCachedModelDef(e.toString(),{modelDef:_.modelDef,invalidationKeys:v}));for(const b of C.newlyTranslatedDependencies())await(h==null?void 0:h.setCachedModelDef(b.url,{modelDef:b.modelDef,invalidationKeys:v}));return new yh(_.modelDef,_.problems||[],[...(m=o==null?void 0:o.fromSources)!==null&&m!==void 0?m:[],...(g=_.fromSources)!==null&&g!==void 0?g:[]],b=>C.referenceAt(b),b=>C.importAt(b))}else if(a){const b={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},R=(o==null?void 0:o._modelDef)||b;return new yh(R,_.problems||[],[...(y=o==null?void 0:o.fromSources)!==null&&y!==void 0?y:[],...(E=_.fromSources)!==null&&E!==void 0?E:[]],w=>C.referenceAt(w),w=>C.importAt(w))}else{const b=_.problems||[],R=C.prettyErrors();throw new jW(`Error(s) compiling model:
1274
+ ${i}`:e=i}return e}childRequest(e){var n;const r=decodeURI(new URL(e,this.sourceURL).toString()),i=(n=this.childTranslators.get(r))===null||n===void 0?void 0:n.translate();if(i!=null&&i.compileSQL)return{compileSQL:i.compileSQL,partialModel:i.partialModel}}getChildExports(e){const n={},r=decodeURI(new URL(e,this.sourceURL).toString()),i=this.childTranslators.get(r);if(i&&i.translate().modelDef)for(const o of i.modelDef.exports){const u=i.modelDef.contents[o];((0,rDe.isSourceDef)(u)||u.type==="query")&&(n[o]=u)}return n}translate(e){if(this.finalAnswer)return this.finalAnswer;const n=this.translateStep.step(this,e);return n.final&&(this.finalAnswer=n),n}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let n=0;n<this.imports.length;n++){const r=this.imports[n];if((0,xDe.locationContainsPosition)(r.location,e))return r}}metadata(){return this.metadataStep.step(this)}modelAnnotation(e){return this.modelAnnotationStep.step(this,e)}tablePathInfo(){return this.tablePathInfoStep.step(this)}completions(e){return this.completionsStep.step(this,e)}helpContext(e){return this.helpContextStep.step(this,e)}defaultLocation(){return{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}rangeFromContext(e){return this.rangeFromTokens(e.start,e.stop||e.start)}rangeFromTokens(e,n){const r={line:e.line-1,character:e.charPositionInLine};if(this.parseStep.sourceInfo&&n.stopIndex!==-1){const i=this.parseStep.sourceInfo.lines.length-1;for(let s=e.line-1;s<=i;s++){const o=this.parseStep.sourceInfo.at[s];if(n.stopIndex>=o.begin&&n.stopIndex<o.end)return{start:r,end:{line:s,character:n.stopIndex-o.begin+1}}}return{start:r,end:{line:i,character:this.parseStep.sourceInfo.lines[i].length}}}return{start:r,end:r}}rangeFromToken(e){return this.rangeFromTokens(e,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const n=this.compilerFlags.tag("experimental");return n!==void 0&&(n.bare()||n.has("dialect",e))}}n0.MalloyTranslation=JO;class BW extends JO{constructor(e,n){super(e),this.root=n}}n0.MalloyChildTranslator=BW;class ODe extends JO{constructor(e,n=null,r=null,i=null){super(e,n),this.eventStream=i,this.schemaZone=new KO.Zone,this.importZone=new KO.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new KO.Zone,this.root=this,this.logger=new IW.BaseMessageLogger(i),r&&this.update(r)}update(e){var n,r,i;this.schemaZone.updateFrom(e.tables,(n=e.errors)===null||n===void 0?void 0:n.tables),this.importZone.updateFrom(e.urls,(r=e.errors)===null||r===void 0?void 0:r.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(i=e.errors)===null||i===void 0?void 0:i.compileSQL);for(const s in e.translations)this.pretranslatedModels.set(s,e.translations[s])}logError(e,n,r){return this.logger.log((0,IW.makeLogMessage)(e,n,{severity:"error",...r})),e}}n0.MalloyTranslator=ODe;function $W(t){return[...Object.keys(t),...Object.keys(t).map(e=>$W(t[e])).flat()]}var mh={};Object.defineProperty(mh,"__esModule",{value:!0}),mh.exploreQueryWalkerBuilder=mh.ExploreQueryWalker=void 0;const FDe=ql;class kW{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(n=>n.range[0]===void 0||n.range[1]===void 0?!1:n.range[0]<=e&&n.range[1]>=e)}filterAtOffset(e){const n=this.exploreQueryAtOffset(e);if(n)return n.filterRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}hasFilterListAtOffset(e){const n=this.exploreQueryAtOffset(e);return n?!!n.filterLists.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}mh.ExploreQueryWalker=kW;function NDe(t,e){const n=new kW(t),r=n;return FDe.ParseTreeWalker.DEFAULT.walk(r,e),n}mh.exploreQueryWalkerBuilder=NDe,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=n0;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var n=mh;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return n.exploreQueryWalkerBuilder}})}(iD);var Oe={},C_={};Object.defineProperty(C_,"__esModule",{value:!0}),C_.MALLOY_VERSION=void 0,C_.MALLOY_VERSION="0.0.239",Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.InMemoryModelCache=Oe.CacheManager=Oe.CSVWriter=Oe.JSONWriter=Oe.DataWriter=Oe.DataRecord=Oe.DataArray=Oe.Result=Oe.ExploreMaterializer=Oe.PreparedResultMaterializer=Oe.QueryMaterializer=Oe.ModelMaterializer=Oe.SingleConnectionRuntime=Oe.ConnectionRuntime=Oe.Runtime=Oe.ExploreField=Oe.JoinRelationship=Oe.QueryField=Oe.Query=Oe.StringField=Oe.UnsupportedField=Oe.JSONField=Oe.BooleanField=Oe.NumberField=Oe.TimestampField=Oe.DateField=Oe.TimestampTimeframe=Oe.DateTimeframe=Oe.AtomicField=Oe.AtomicFieldType=Oe.Explore=Oe.SourceRelationship=Oe.FixedConnectionMap=Oe.InMemoryURLReader=Oe.EmptyURLReader=Oe.PreparedResult=Oe.DocumentCompletion=Oe.DocumentSymbol=Oe.DocumentPosition=Oe.DocumentRange=Oe.DocumentTablePath=Oe.Parse=Oe.PreparedQuery=Oe.Model=Oe.MalloyError=Oe.Malloy=void 0;const PW=iD,rr=Li,MW=K7,XO=Hx,wDe=C_,LDe=K2,Tn=ss,UW="internal://internal.malloy";class Ui{static get version(){return wDe.MALLOY_VERSION}static _parse(e,n,r,i,s){n===void 0&&(n=new URL(UW));let o=n;i!=null&&i.importBaseURL&&(o=i==null?void 0:i.importBaseURL);const u=new PW.MalloyTranslator(n.toString(),o.toString(),{urls:{[n.toString()]:e}},r);return i!=null&&i.testEnvironment&&(u.allDialectsEnabled=!0),new qW(u,s)}static parse({url:e,urlReader:n,source:r,eventStream:i,options:s}){if(r!==void 0)return Ui._parse(r,e,i,s);if(n===void 0)throw new Error("Internal Error: urlReader is required.");if(e===void 0)throw new Error("Internal Error: url is required if source not present.");return F_(n,e).then(({contents:o,invalidationKey:u})=>Ui._parse(o,e,i,s,u))}static async compile({url:e,source:n,parse:r,urlReader:i,connections:s,model:o,refreshSchemaCache:u,noThrowOnError:a,eventStream:l,replaceMaterializedReferences:c,materializedTablePrefix:f,importBaseURL:d,cacheManager:h}){var p,m,g,y,E;let A;if(u&&(A=typeof u=="number"?u:Date.now()),e===void 0&&n===void 0&&r===void 0)throw new Error("Internal Error: url, source, or parse required.");e===void 0&&(r!==void 0?e=new URL(r._translator.sourceURL):e=new URL(UW));const v={};if(n===void 0&&h!==void 0){const _=await h.getCachedModelDef(i,e.toString());if(_)return new yh(_.modelDef,[],[e.toString(),...O_(_.modelDef.dependencies)])}d??(d=e);let C;const S=e.toString();if(r!==void 0){C=r._translator;const _=(p=r._invalidationKey)!==null&&p!==void 0?p:await f8(i,e);v[S]=_}else{if(n===void 0){const{contents:_,invalidationKey:b}=await F_(i,e);v[S]=b,n=_}else{const _=await f8(i,e);v[S]=_}C=new PW.MalloyTranslator(S,d.toString(),{urls:{[S]:n}},l)}for(;;){const _=C.translate(o==null?void 0:o._modelDef);if(_.final)if(_.modelDef){await(h==null?void 0:h.setCachedModelDef(e.toString(),{modelDef:_.modelDef,invalidationKeys:v}));for(const b of C.newlyTranslatedDependencies())await(h==null?void 0:h.setCachedModelDef(b.url,{modelDef:b.modelDef,invalidationKeys:v}));return new yh(_.modelDef,_.problems||[],[...(m=o==null?void 0:o.fromSources)!==null&&m!==void 0?m:[],...(g=_.fromSources)!==null&&g!==void 0?g:[]],b=>C.referenceAt(b),b=>C.importAt(b))}else if(a){const b={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},R=(o==null?void 0:o._modelDef)||b;return new yh(R,_.problems||[],[...(y=o==null?void 0:o.fromSources)!==null&&y!==void 0?y:[],...(E=_.fromSources)!==null&&E!==void 0?E:[]],w=>C.referenceAt(w),w=>C.importAt(w))}else{const b=_.problems||[],R=C.prettyErrors();throw new jW(`Error(s) compiling model:
1275
1275
  ${R}`,b)}else{if(_.urls)for(const R of _.urls)try{if(N_(R))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(h!==void 0){const q=await h.getCachedModelDef(i,R);if(q){for(const J in q.invalidationKeys)v[J]=q.invalidationKeys[J];C.update({translations:{[R]:q.modelDef}});continue}}const{contents:w,invalidationKey:I}=await F_(i,new URL(R)),P={[R]:w};v[R]=I,C.update({urls:P})}catch(w){C.update({errors:{urls:{[R]:w.message}}})}const{modelAnnotation:b}=C.modelAnnotation(o==null?void 0:o._modelDef);if(_.tables){const R=new Map;for(const w in _.tables){const{connectionName:I,tablePath:P}=_.tables[w],q=R.get(I);q===void 0?R.set(I,{[w]:P}):q[w]=P}for(const[w,I]of R)try{const P=await s.lookupConnection(w),{schemas:q,errors:J}=await Ui.safelyFetchTableSchema(P,I,{refreshTimestamp:A,modelAnnotation:b});C.update({tables:q,errors:{tables:J}})}catch(P){const q={},J={};for(const G in I)J[G]=P.toString();C.update({tables:q,errors:{tables:J}})}}if(_.compileSQL){const R=_.compileSQL,w=R.connection;try{const I=await s.lookupConnection(w),P=Ui.compileSQLBlock(I.dialectName,_.partialModel,R,{replaceMaterializedReferences:c,materializedTablePrefix:f,eventStream:l}),q=await I.fetchSchemaForSQLStruct(P,{refreshTimestamp:A,modelAnnotation:b});q.error&&C.update({errors:{compileSQL:{[P.name]:q.error}}}),q.structDef&&C.update({compileSQL:{[P.name]:q.structDef}})}catch(I){const P={};P[R.name]=I.toString(),C.update({errors:{compileSQL:P}})}}}}}static async safelyFetchTableSchema(e,n,r){const i=await e.fetchSchemaForTables(n,r);for(const s of Object.keys(n))if(i.schemas[s]===void 0&&i.errors[s]===void 0)throw new Error(`Schema fetch error for ${e.name}, no response for ${s} from ${e.dialectName}`);return i}static compileSQLBlock(e,n,r,i){let s,o="",u=!1;for(const c of r.select)if((0,rr.isSegmentSQL)(c))o+=c.sql,u=c.sql.match(/\(\s*$/)!==null;else{if(!s){if(!n)throw new Error("Internal error: Partial model missing when compiling SQL block");s=new rr.QueryModel(n,i==null?void 0:i.eventStream)}const f=s.compileQuery(c,{...i,defaultRowLimit:void 0},!1).sql;o+=u?f:`(${f})`,u=!1}const{name:a,connection:l}=r;return{type:"sql_select",name:a,connection:l,dialect:e,selectStr:o,fields:[]}}static async run({connections:e,preparedResult:n,sqlStruct:r,connection:i,options:s}){if(!i){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const o=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName);i=await e.lookupConnection(o)}if(r){const o=await i.runSQL(r.selectStr);return new Wg({structs:[r],sql:r.selectStr,result:o.rows,totalRows:o.totalRows,runStats:o.runStats,lastStageName:r.name,malloy:"",connectionName:r.connection,sourceExplore:"",sourceFilters:[],profilingUrl:o.profilingUrl},{name:"empty_model",exports:[],contents:{},queryList:[],dependencies:{}})}else if(n){const o=await i.runSQL(n.sql,s);return new Wg({...n._rawQuery,result:o.rows,totalRows:o.totalRows,runStats:o.runStats,profilingUrl:o.profilingUrl},n._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:e,preparedResult:n,sqlStruct:r,connection:i,options:s}){if(r===void 0&&n===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const o=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName);if(i===void 0){if(e===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");i=await e.lookupConnection(o)}if(!i.canStream())throw new Error(`Connection '${o}' cannot stream results.`);let u,a;if(r)a=new ys(r),u=r.selectStr;else if(n!==void 0)a=n.resultExplore,u=n.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let l=0;for await(const c of i.runSQLStream(u,s))yield new Df(c,l,a,void 0,void 0),l+=1}static async estimateQueryCost({connections:e,preparedResult:n,sqlStruct:r}){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const i=(r==null?void 0:r.connection)||(n==null?void 0:n.connectionName),s=await e.lookupConnection(i);if(r)return await s.estimateQueryCost(r.selectStr);if(n)return await s.estimateQueryCost(n.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}}Oe.Malloy=Ui;class jW extends Error{constructor(e,n=[]){super(e),this.problems=n}}Oe.MalloyError=jW;let yh=class{constructor(e,n,r,i=()=>{},s=()=>{}){this.modelDef=e,this.problems=n,this.fromSources=r,this._referenceAt=i,this._importAt=s}tagParse(e){return(0,Tn.annotationToTag)(this.modelDef.annotation,e)}getTaglines(e){return(0,Tn.annotationToTaglines)(this.modelDef.annotation,e)}getReference(e){return this._referenceAt(e)}getImport(e){return this._importAt(e)}getPreparedQueryByName(e){const n=this.modelDef.contents[e];if((n==null?void 0:n.type)==="query")return new Eh(n,this.modelDef,this.problems,e);throw new Error("Given query name does not refer to a named query.")}getPreparedQueryByIndex(e){if(e<0)throw new Error(`Invalid index ${e}.`);if(e>=this.modelDef.queryList.length)throw new Error(`Query index ${e} is out of bounds.`);return new Eh(this.modelDef.queryList[e],this.modelDef,this.problems)}get preparedQuery(){return this.getPreparedQuery()}getPreparedQuery(){if(this.modelDef.queryList.length===0)throw new Error("Model has no queries.");return new Eh(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const n=this.modelDef.contents[e];if((0,rr.isSourceDef)(n))return new ys(n);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(rr.isSourceDef).map(e=>new ys(e))}get namedQueries(){const e=n=>n.type==="query";return Object.values(this.modelDef.contents).filter(e)}get exportedExplores(){return this.explores.filter(e=>this.modelDef.exports.includes(e.name))}get _modelDef(){return this.modelDef}};Oe.Model=yh;class Eh{constructor(e,n,r,i){this.problems=r,this.name=i,this._query=e,this._modelDef=n}tagParse(e){const n=(0,Tn.annotationToTag)(this._modelDef.annotation).tag;return e=(0,Tn.addModelScope)(e,n),(0,Tn.annotationToTag)(this._query.annotation,e)}getTaglines(e){return(0,Tn.annotationToTaglines)(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const r=new rr.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new Qg({...r,queryName:this.name||r.queryName},this._modelDef)}get dialect(){const e=this._query.structRef,n=typeof e=="string"?this._modelDef.contents[e]:e;if(!(0,rr.isSourceDef)(n))throw new Error("Invalid source for query");return n.dialect}getFlattenedQuery(e){return this}}Oe.PreparedQuery=Eh;class qW{constructor(e,n){this.translator=e,this.invalidationKey=n}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new __(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(r=>new HW(r))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(n=>new zW(n))}helpContext(e){return this.translator.helpContext(e).helpContext}}Oe.Parse=qW;class HW{constructor(e){this._range=Ah.fromJSON(e.range),this._connectionId=e.connectionId,this._tablePath=e.tablePath}get range(){return this._range}get connectionId(){return this._connectionId}get tablePath(){return this._tablePath}}Oe.DocumentTablePath=HW;class Ah{constructor(e,n){this._start=e,this._end=n}get start(){return this._start}get end(){return this._end}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}static fromJSON(e){return new Ah(new ZO(e.start.line,e.start.character),new ZO(e.end.line,e.end.character))}}Oe.DocumentRange=Ah;class ZO{constructor(e,n){this._line=e,this._character=n}get line(){return this._line}get character(){return this._character}toJSON(){return{line:this.line,character:this.character}}}Oe.DocumentPosition=ZO;class __{constructor(e){this._range=Ah.fromJSON(e.range),this._lensRange=e.lensRange?Ah.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(n=>new __(n))}get range(){return this._range}get lensRange(){var e;return(e=this._lensRange)!==null&&e!==void 0?e:this._range}get type(){return this._type}get name(){return this._name}get children(){return this._children}}Oe.DocumentSymbol=__;class zW{constructor(e){this.type=e.type,this.text=e.text}}Oe.DocumentCompletion=zW;class Qg{constructor(e,n){this.modelDef=n,this.inner=e}static fromJson({query:e,modelDef:n}){if(!e||!n)throw new Error("Missing required properties in JSON data");return new Qg(e,n)}tagParse(e){const n=(0,Tn.annotationToTag)(this.modelDef.annotation).tag;return e=(0,Tn.addModelScope)(e,n),(0,Tn.annotationToTag)(this.inner.annotation,e)}getTaglines(e){return(0,Tn.annotationToTaglines)(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return(0,Tn.annotationToTag)(this.modelDef.annotation).tag}get connectionName(){return this.inner.connectionName}get _rawQuery(){return this.inner}get _modelDef(){return this.modelDef}get sql(){return this.inner.sql}get dependenciesToMaterialize(){return this.inner.dependenciesToMaterialize}get materialization(){return this.inner.materialization}get resultExplore(){if(this.inner.structs.length===0)throw new Error("Malformed query result.");const e=this.inner.structs[this.inner.structs.length-1],n={...e,annotation:this.inner.annotation,name:this.inner.queryName||e.name};try{return new ys(n,this.sourceExplore)}catch{return new ys(n)}}get sourceExplore(){const e=this.inner.sourceExplore,n=this.modelDef.contents[e];if(n===void 0)throw new Error("Malformed query result.");if((0,rr.isSourceDef)(n))return new ys(n);throw new Error(`'${e} is not an explore`)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}Oe.PreparedResult=Qg;class QW{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}Oe.EmptyURLReader=QW;class IDe{constructor(e){this.files=e}async readURL(e){const n=this.files.get(e.toString());if(n!==void 0)return Promise.resolve({contents:n,invalidationKey:this.invalidationKey(e,n)});throw new Error(`File not found '${e}'`)}async getInvalidationKey(e){const n=this.files.get(e.toString());if(n!==void 0)return Promise.resolve(this.invalidationKey(e,n));throw new Error(`File not found '${e}'`)}invalidationKey(e,n){return N_(e.toString())?null:oV(n)}}Oe.InMemoryURLReader=IDe;class S_{constructor(e,n){this.connections=e,this.defaultConnectionName=n}async getConnection(e){if(e===void 0)if(this.defaultConnectionName!==void 0)e=this.defaultConnectionName;else throw new Error("No default connection.");const n=this.connections.get(e);if(n!==void 0)return Promise.resolve(n);throw new Error(`No connection found with name ${e}.`)}listConnections(){return Array.from(this.connections.values())}async lookupConnection(e){return this.getConnection(e)}static fromArray(e){return new S_(new Map(e.map(n=>[n.name,n])))}}Oe.FixedConnectionMap=S_;var GW;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(GW||(Oe.SourceRelationship=GW={}));class e8{constructor(e,n,r){this._name=e,this._parent=n,this._source=r}get source(){return this.source}get name(){return this._name}get sourceClasses(){const e=[];return this.source&&e.push(this.source.name),e.push(this.name),e}get fieldPath(){const e=[this.name];let n=this._parent;for(;n;)e.unshift(n.name),n=n._parent;return e}hasParentExplore(){return this._parent!==void 0}isExplore(){return this instanceof ys}isQuery(){return this instanceof u8}}class ys extends e8{constructor(e,n,r){super(e.as||e.name,n,r),this._structDef=e,this._parentExplore=n,this.sourceExplore=r}get source(){return this.sourceExplore}isIntrinsic(){return(0,rr.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return(0,Tn.annotationToTag)(this._structDef.annotation,e)}getTaglines(e){return(0,Tn.annotationToTaglines)(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=(0,Tn.annotationToTag)(this._structDef.modelAnnotation).tag),this.parsedModelTag}get name(){return this.structDef.as||this.structDef.name}getQueryByName(e){const n=this.sourceStructDef;if(!n)throw new Error(`Cannot get query by name from a struct of type ${this.structDef.type}`);const r={type:"query",structRef:n,pipeline:[{type:"reduce",queryFields:[{type:"fieldref",path:[e]}]}]};return new Eh(r,this.modelDef,[],e)}get modelDef(){if(!(0,rr.isSourceDef)(this.structDef))throw new Error(`Cannot create pseudo model for struct type ${this.structDef.type}`);return{name:"generated_model",exports:[],contents:{[this.structDef.name]:this.structDef},queryList:[],dependencies:{}}}getSingleExploreModel(){return new yh(this.modelDef,[],[])}get fieldMap(){var e;if(this._fieldMap===void 0){const n=((e=this.source)===null||e===void 0?void 0:e.fieldMap)||new Map;this._fieldMap=new Map(this.structDef.fields.map(r=>{const i=r.as||r.name,s=n.get(r.name);if((0,rr.isJoined)(r))return[i,new a8(r,this,s)];if(r.type==="turtle")return[i,new u8(r,this,s)];if(r.type==="string")return[i,new o8(r,this,s)];if(r.type==="number")return[i,new b_(r,this,s)];if(r.type==="date")return r.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(r.timeframe)?[i,new b_({...r,type:"number"},this,s)]:[i,new t8(r,this,s)];if(r.type==="timestamp")return[i,new n8(r,this,s)];if(r.type==="boolean")return[i,new r8(r,this,s)];if(r.type==="json")return[i,new i8(r,this,s)];if(r.type==="sql native")return[i,new s8(r,this,s)]}))}return this._fieldMap}get allFields(){return[...this.fieldMap.values()]}get allFieldsWithOrder(){var e,n,r;if(!this._allFieldsWithOrder){const i=[...((r=(n=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||n===void 0?void 0:n.orderBy)===null||r===void 0?void 0:r.map(o=>{if(typeof o.field=="string")return{field:this.fieldMap.get(o.field),dir:o.dir};throw new Error("Does not support mapping order by from number.")}))||[]],s=new Set(i.map(o=>o.field.name));this._allFieldsWithOrder=[...i,...this.allFields.filter(o=>!s.has(o.name)).map(o=>({field:o,dir:"asc"}))]}return this._allFieldsWithOrder}get intrinsicFields(){return[...this.fieldMap.values()].filter(e=>e.isIntrinsic())}get dimensions(){return[...this.allFieldsWithOrder].filter(e=>e.field.isAtomicField()&&e.field.sourceWasDimension())}getFieldByName(e){const n=this.fieldMap.get(e);if(n===void 0)throw new Error(`No such field ${e}.`);return n}getFieldByNameIfExists(e){return this.fieldMap.get(e)}get primaryKey(){var e;return(e=this.sourceStructDef)===null||e===void 0?void 0:e.primaryKey}get parentExplore(){return this._parentExplore}hasParentExplore(){return this instanceof a8}get filters(){var e;return(0,rr.isSourceDef)(this.structDef)?((e=this.structDef.resultMetadata)===null||e===void 0?void 0:e.filterList)||[]:[]}get limit(){var e,n;return(n=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||n===void 0?void 0:n.limit}get structDef(){return this._structDef}get queryTimezone(){var e;return(e=this.sourceStructDef)===null||e===void 0?void 0:e.queryTimezone}get sourceStructDef(){if((0,rr.isSourceDef)(this.structDef))return this.structDef}toJSON(){var e,n;return{_structDef:this._structDef,sourceExplore:(e=this.sourceExplore)===null||e===void 0?void 0:e.toJSON(),_parentExplore:(n=this._parentExplore)===null||n===void 0?void 0:n.toJSON()}}static fromJSON(e){const n=e._parentExplore!==void 0?ys.fromJSON(e._parentExplore):void 0,r=e.sourceExplore!==void 0?ys.fromJSON(e.sourceExplore):void 0;return new ys(e._structDef,n,r)}get location(){return this.structDef.location}}Oe.Explore=ys;var Fu;(function(t){t.String="string",t.Number="number",t.Boolean="boolean",t.Date="date",t.Timestamp="timestamp",t.Json="json",t.NativeUnsupported="sql native",t.Error="error"})(Fu||(Oe.AtomicFieldType=Fu={}));class b0 extends e8{constructor(e,n,r){super(e.as||e.name,n,r),this.fieldTypeDef=e,this.parent=n}get type(){switch(this.fieldTypeDef.type){case"string":return Fu.String;case"boolean":return Fu.Boolean;case"date":return Fu.Date;case"timestamp":return Fu.Timestamp;case"number":return Fu.Number;case"json":return Fu.Json;case"sql native":return Fu.NativeUnsupported;case"error":return Fu.Error;case"record":case"array":throw new Error(`MTOY TODO IMPLEMENT Atomic ${this.fieldTypeDef.type}`);default:{const e=this.fieldTypeDef;throw new Error(`Can't make an atomic field from ${e}`)}}}tagParse(e){return e=(0,Tn.addModelScope)(e,this.parent.modelTag),(0,Tn.annotationToTag)(this.fieldTypeDef.annotation,e)}getTaglines(e){return(0,Tn.annotationToTaglines)(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,rr.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,rr.expressionIsCalculation)(this.fieldTypeDef.expressionType)}get sourceField(){throw new Error}get sourceClasses(){const e=this.fieldTypeDef.name||this.fieldTypeDef.as;return e?[e]:[]}get referenceId(){var e;return(e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.referenceId}sourceWasMeasure(){var e;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"}sourceWasMeasureLike(){var e,n;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"||((n=this.fieldTypeDef.resultMetadata)===null||n===void 0?void 0:n.fieldKind)==="struct"}sourceWasDimension(){var e;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="dimension"}hasParentExplore(){return!0}isString(){return this instanceof o8}isNumber(){return this instanceof b_}isDate(){return this instanceof t8}isBoolean(){return this instanceof r8}isJSON(){return this instanceof i8}isTimestamp(){return this instanceof n8}isUnsupported(){return this instanceof s8}get parentExplore(){return this.parent}get expression(){const e=".",n=this.fieldTypeDef.resultMetadata;return(n==null?void 0:n.sourceExpression)||(n!=null&&n.sourceField.includes(e)?n==null?void 0:n.sourceField:this.name)}get location(){return this.fieldTypeDef.location}}Oe.AtomicField=b0;var Rf;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(Rf||(Oe.DateTimeframe=Rf={}));var Nu;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year",t.Second="second",t.Hour="hour",t.Minute="minute"})(Nu||(Oe.TimestampTimeframe=Nu={}));class t8 extends b0{constructor(e,n,r){super(e,n,r),this.fieldDateDef=e}get timeframe(){if(this.fieldDateDef.timeframe!==void 0)switch(this.fieldDateDef.timeframe){case"day":return Rf.Day;case"week":return Rf.Week;case"month":return Rf.Month;case"quarter":return Rf.Quarter;case"year":return Rf.Year}}}Oe.DateField=t8;class n8 extends b0{constructor(e,n,r){super(e,n,r),this.fieldTimestampDef=e}get timeframe(){if(this.fieldTimestampDef.timeframe!==void 0)switch(this.fieldTimestampDef.timeframe){case"day":return Nu.Day;case"week":return Nu.Week;case"month":return Nu.Month;case"quarter":return Nu.Quarter;case"year":return Nu.Year;case"second":return Nu.Second;case"hour":return Nu.Hour;case"minute":return Nu.Minute}}}Oe.TimestampField=n8;class b_ extends b0{constructor(e,n,r){super(e,n,r),this.fieldNumberDef=e}}Oe.NumberField=b_;class r8 extends b0{constructor(e,n,r){super(e,n,r),this.fieldBooleanDef=e}}Oe.BooleanField=r8;class i8 extends b0{constructor(e,n,r){super(e,n,r),this.fieldJSONDef=e}}Oe.JSONField=i8;class s8 extends b0{constructor(e,n,r){super(e,n,r),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}Oe.UnsupportedField=s8;class o8 extends b0{constructor(e,n,r){super(e,n,r),this.fieldStringDef=e}}Oe.StringField=o8;class WW extends e8{constructor(e,n,r){super(e.as||e.name,n,r),this.turtleDef=e}get source(){return this.sourceQuery}isIntrinsic(){return!1}get location(){return this.turtleDef.location}}Oe.Query=WW;class u8 extends WW{constructor(e,n,r){super(e,n,r),this.parent=n}tagParse(e){return e=(0,Tn.addModelScope)(e,this.parent.modelTag),(0,Tn.annotationToTag)(this.turtleDef.annotation,e)}getTaglines(e){return(0,Tn.annotationToTaglines)(this.turtleDef.annotation,e)}isQueryField(){return!0}isExploreField(){return!1}isAtomicField(){return!1}get sourceClasses(){const e=this.turtleDef.name||this.turtleDef.as;return e?[e]:[]}hasParentExplore(){return!0}get parentExplore(){return this.parent}get expression(){return this.name}}Oe.QueryField=u8;var vh;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(vh||(Oe.JoinRelationship=vh={}));class a8 extends ys{constructor(e,n,r){super(e,n,r),this._parentExplore=n}get joinRelationship(){if((0,rr.isJoined)(this.structDef))switch(this.structDef.join){case"one":return vh.OneToOne;case"many":case"cross":return vh.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===vh.OneToOne}get isArray(){return this.joinRelationship!==vh.OneToOne}tagParse(e){return e=(0,Tn.addModelScope)(e,this._parentExplore.modelTag),(0,Tn.annotationToTag)(this._structDef.annotation,e)}isQueryField(){return!1}isExploreField(){return!0}isAtomicField(){return!1}get parentExplore(){return this._parentExplore}get sourceClasses(){const e=this.structDef.name||this.structDef.as;return e?[e]:[]}}Oe.ExploreField=a8;class l8{constructor({urlReader:e,connections:n,connection:r,eventStream:i,cacheManager:s}){if(this.isTestRuntime=!1,n===void 0){if(r===void 0)throw new Error("A LookupConnection<Connection> or Connection is required.");n={lookupConnection:()=>Promise.resolve(r)}}e===void 0&&(e=new QW),this._urlReader=e,this._connections=n,this._eventStream=i,this._cacheManager=s}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}loadModel(e,n){const{refreshSchemaCache:r,noThrowOnError:i}=n||{};this.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0});const s=e instanceof URL?{url:e}:{source:e};return new Gg(this,async()=>Ui.compile({...s,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:r,noThrowOnError:i,eventStream:this.eventStream,replaceMaterializedReferences:n==null?void 0:n.replaceMaterializedReferences,materializedTablePrefix:n==null?void 0:n.materializedTablePrefix,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,cacheManager:this.cacheManager}),n)}_loadModelFromModelDef(e,n){return new Gg(this,async()=>new yh(e,[],[]),n)}loadQuery(e,n){return this.loadModel(e,n).loadFinalQuery()}loadQueryByIndex(e,n,r){return this.loadModel(e,r).loadQueryByIndex(n,r)}loadQueryByName(e,n,r){return this.loadModel(e,r).loadQueryByName(n,r)}getModel(e,n){return this.loadModel(e,n).getModel()}getQuery(e,n){return this.loadQuery(e,n).getPreparedQuery()}getQueryByIndex(e,n,r){return this.loadQueryByIndex(e,n,r).getPreparedQuery()}getQueryByName(e,n,r){return this.loadQueryByName(e,n,r).getPreparedQuery()}}Oe.Runtime=l8;class BDe extends l8{constructor({urlReader:e,connections:n}){super({connections:S_.fromArray(n),urlReader:e}),this.rawConnections=n}}Oe.ConnectionRuntime=BDe;class $De extends l8{constructor({urlReader:e,connection:n,eventStream:r,cacheManager:i}){super({urlReader:e,eventStream:r,cacheManager:i,connection:n}),this.connection=n}get supportsNesting(){return(0,XO.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,XO.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,XO.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}Oe.SingleConnectionRuntime=$De;class T_{constructor(e,n){this.runtime=e,this._materialize=n}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(e,n){return new VW(this.runtime,e,n)}makeExploreMaterializer(e,n){return new KW(this.runtime,e,n)}makePreparedResultMaterializer(e){return new YW(this.runtime,e)}}class Gg extends T_{constructor(e,n,r){super(e,n),this.runtime=e,this.compileQueryOptions=r}loadFinalQuery(e){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...e})}loadQueryByIndex(e,n){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(e),{...this.compileQueryOptions,...n})}loadQueryByName(e,n){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(e),{...this.compileQueryOptions,...n})}loadQuery(e,n){const{refreshSchemaCache:r,noThrowOnError:i}=n||{};return this.makeQueryMaterializer(async()=>{const s=this.runtime.urlReader,o=this.runtime.connections;this.runtime.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0});const u=e instanceof URL?{url:e}:{source:e},a=await this.getModel();return(await Ui.compile({...u,urlReader:s,connections:o,model:a,refreshSchemaCache:r,noThrowOnError:i,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,...this.compileQueryOptions})).preparedQuery})}extendModel(e,n){return this.runtime.isTestRuntime&&(n===void 0?n={testEnvironment:!0}:n={...n,testEnvironment:!0}),new Gg(this.runtime,async()=>{const r=this.runtime.urlReader,i=this.runtime.connections,s=e instanceof URL?{url:e}:{source:e},o=await this.getModel();return await Ui.compile({...s,urlReader:r,connections:i,model:o,refreshSchemaCache:n==null?void 0:n.refreshSchemaCache,noThrowOnError:n==null?void 0:n.noThrowOnError,importBaseURL:n==null?void 0:n.importBaseURL,testEnvironment:n==null?void 0:n.testEnvironment,...this.compileQueryOptions})},n)}async search(e,n,r=1e3,i=void 0,s){const o=await this.materialize(),u=new rr.QueryModel(o._modelDef,s),a=o.getExploreByName(e).structDef;if(!(0,rr.isSourceDef)(a))throw new Error("Source to be searched was unexpectedly, not a source");const l=a.connection,c=await this.runtime.connections.lookupConnection(l);return await u.searchIndex(c,e,n,r,i)}async searchValueMap(e,n=10,r){const s=(await this.materialize()).getExploreByName(e);if(!(0,rr.isSourceDef)(s.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let o="{index: *}";s.getFieldByNameIfExists("search_index")&&(o="search_index");const u=`
1276
1276
  run: ${e}
1277
1277
  -> ${o}
@@ -1293,7 +1293,7 @@ ${R}`,b)}else{if(_.urls)for(const R of _.urls)try{if(N_(R))throw new Error("In o
1293
1293
  `)}}this.stream.write(`
1294
1294
  ]
1295
1295
  `),this.stream.close()}}Oe.JSONWriter=MDe;class UDe extends c8{constructor(){super(...arguments),this.columnSeparator=",",this.rowSeparator=`
1296
- `,this.quoteCharacter='"',this.includeHeader=!0,this.emptyCell=""}escape(e){const n=e.includes(this.quoteCharacter),r=e.includes(this.columnSeparator),i=e.includes(this.rowSeparator),s=r||n||i;return n&&(e=e.replace(new RegExp(this.quoteCharacter,"g"),this.quoteCharacter+this.quoteCharacter)),s&&(e=this.quoteCharacter+e+this.quoteCharacter),e}stringify(e){return e===null?this.emptyCell:e instanceof Date?e.toISOString():typeof e=="boolean"||typeof e=="number"?JSON.stringify(e):`${e}`}getColWeight(e){let n=e;Array.isArray(e)&&(n=e[0]);let r=0;for(const i in n){r=r+1;const s=n[i];if(Array.isArray(s)){const o=this.getColWeight(s)-1;r=r+o}}return r}getHeaderRow(e){const n=[];let r=0;for(const i in e){n.push(this.escape(i));const s=e[i];if(r++,Array.isArray(s)){const o=this.getColWeight(s)-1;r=r+o;for(let u=0;u<o;u++)n.push(this.emptyCell)}}return{rows:[n.join(this.columnSeparator)],length:1,width:r}}mergeMatrices(e){const n=Math.max(...e.map(s=>s.length)),r=e.reduce((s,o)=>s+o.width,0),i=[];for(let s=0;s<n;s++){const o=[];for(const u of e)if(s<u.length)o.push(u.rows[s]);else{const a=Array(u.width).fill(this.emptyCell);o.push(...a)}i.push(o.join(this.columnSeparator))}return{rows:i,length:n,width:r}}getChildMatrix(e){if(Array.isArray(e)){if(e.length===0)return{rows:[""],length:1,width:1}}else return{rows:["Invalid data found, value is not an array"],length:1,width:1};const n=[],r=this.getHeaderRow(e[0]);n.push(...r.rows);const i=r.width;let s=1;for(const o of e){const u=this.getRowMatrix(o);s=s+u.length,n.push(...u.rows)}return{rows:n,length:s,width:i}}getRowMatrix(e){const n=[];for(const r in e){const i=e[r];if(Array.isArray(i)){const s=this.getChildMatrix(i);n.push(s)}else{const s={rows:[this.stringify(i)],length:1,width:1};n.push(s)}}return this.mergeMatrices(n)}async process(e){let n=!1;for await(const r of e){if(!n&&this.includeHeader){const s=this.getHeaderRow(r.toObject());this.stream.write(s.rows[0]),this.stream.write(this.rowSeparator),n=!0}const i=this.getRowMatrix(r.toObject());for(const s of i.rows)this.stream.write(s),this.stream.write(this.rowSeparator)}this.stream.close()}}Oe.CSVWriter=UDe;class jDe{constructor(e){this.modelCache=e,this.modelDependencies=new Map,this.modelInvalidationKeys=new Map}async getCachedModelDef(e,n){const r=this.modelDependencies.get(n);if(r===void 0)return;const i=[n,...O_(r)],s={};for(const u of i){const a=this.modelInvalidationKeys.get(u);if(a==null)return;s[u]=a}for(const u of i)if(await f8(e,new URL(u))!==s[u])return;const o=await this.modelCache.getModel(new URL(n));if(o!==void 0){for(const u of i)if(o.invalidationKeys[u]!==s[u])return;return{modelDef:o.modelDef,invalidationKeys:s}}}async setCachedModelDef(e,n){this.modelDependencies.set(e,n.modelDef.dependencies);const r={};for(const s of[e,...O_(n.modelDef.dependencies)]){if(n.invalidationKeys[s]===null)return!1;if(n.invalidationKeys[s]===void 0)throw new Error(`Missing invalidation key for dependency ${s}`);this.modelInvalidationKeys.set(s,n.invalidationKeys[s]),r[s]=n.invalidationKeys[s]}return!!await this.modelCache.setModel(new URL(e),{modelDef:n.modelDef,invalidationKeys:r})}}Oe.CacheManager=jDe;function O_(t){return[...Object.keys(t),...Object.values(t).map(O_).flat()]}class qDe{constructor(){this.models=new Map}async getModel(e){return Promise.resolve(this.models.get(e.toString()))}async setModel(e,n){return this.models.set(e.toString(),n),Promise.resolve(!0)}}Oe.InMemoryModelCache=qDe;function oV(t){return(0,LDe.v5)(t,"76c17e9d-f3ce-5f2d-bfde-98ad3d2a37f6")}async function F_(t,e){const n=await t.readURL(e),{contents:r,invalidationKey:i}=typeof n=="string"?{contents:n,invalidationKey:void 0}:n;return{contents:r,invalidationKey:N_(e.toString())?null:i??oV(r)}}async function f8(t,e){return N_(e.toString())?null:t.getInvalidationKey!==void 0?await t.getInvalidationKey(e):(await F_(t,e)).invalidationKey}function N_(t){return t.startsWith("internal://")}var w_={};Object.defineProperty(w_,"__esModule",{value:!0}),w_.toAsyncGenerator=void 0;async function*HDe(t){let e=!1;function n(i){let s;const o=new Promise(u=>{s=u});return i(u=>{s({done:!0,isError:!0,error:u})},u=>{s({done:!1,value:u,isError:!1,next:new Promise(a=>{s=a})})},()=>{s({done:!0,isError:!1})}),o}let r=n(t);for(;!e;){const i=await r;if(i.done){if(e=!0,i.isError)throw i.error;break}else r=i.next,yield i.value}}w_.toAsyncGenerator=HDe;var L_={};Object.defineProperty(L_,"__esModule",{value:!0}),L_.modelDefToModelInfo=void 0;const Ga=Li,uV=Bs;function zDe(t){const e={entries:[],anonymous_queries:[]};for(const[n,r]of Object.entries(t.contents))if(t.exports.includes(n)){if((0,Ga.isSourceDef)(r)){const i={kind:"source",name:n,schema:{fields:I_(r,r.fields)}};e.entries.push(i)}else if(r.type==="query"){const i=(0,uV.getResultStructDefForQuery)(t,r),s={kind:"source",name:n,schema:{fields:I_(i,i.fields)}};e.entries.push(s)}}return e}L_.modelDefToModelInfo=zDe;function I_(t,e){var n,r,i;const s=[];for(const o of e)if((0,Ga.isTurtle)(o)){const u=(0,uV.getResultStructDefForView)(t,o),a={kind:"view",name:(n=o.as)!==null&&n!==void 0?n:o.name,schema:{fields:I_(u,u.fields)}};s.push(a)}else if((0,Ga.isAtomic)(o)){const u=(0,Ga.expressionIsAggregate)(o.expressionType),a=(0,Ga.expressionIsScalar)(o.expressionType);if(!u&&!a||o.type==="error")continue;const l={kind:u?"measure":"dimension",name:(r=o.as)!==null&&r!==void 0?r:o.name,type:x8(o)};s.push(l)}else if((0,Ga.isJoinedSource)(o)){const u={kind:"join",name:(i=o.as)!==null&&i!==void 0?i:o.name,schema:{fields:I_(o,o.fields)},relationship:o.join};s.push(u)}return s}function x8(t){if((0,Ga.isLeafAtomic)(t))switch(t.type){case"string":return{kind:"string_type"};case"number":return{kind:"number_type",subtype:t.numberType==="float"?"decimal":t.numberType==="integer"?"integer":void 0};case"boolean":return{kind:"boolean_type"};case"date":return{kind:"date_type",timeframe:QDe(t.timeframe)};case"timestamp":return{kind:"timestamp_type",timeframe:t.timeframe};case"json":return{kind:"json_type"};case"sql native":return{kind:"sql_native_type",sql_type:t.rawType};case"error":throw new Error("Error type is not supported in stable interface")}else{if((0,Ga.isRepeatedRecord)(t))return{kind:"array_type",element_type:aV(t)};if(t.type==="record")return aV(t);if(t.type==="array")return{kind:"array_type",element_type:x8(t.elementTypeDef)}}throw new Error("Unexpected field type")}function aV(t){return{kind:"record_type",fields:t.fields.map(e=>{if((0,Ga.isAtomic)(e))return{name:e.name,type:x8(e)};throw new Error("Expected record type to not have a table as its child")})}}function QDe(t){switch(t){case void 0:return;case"day":case"week":case"month":case"year":case"quarter":return t;default:throw new Error("Invalid date timeframe")}}function Rlt(t){return t}function Dlt(t){return t}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryURLReader=t.EmptyURLReader=t.SingleConnectionRuntime=t.ConnectionRuntime=t.AtomicFieldType=t.Runtime=t.Malloy=t.Model=t.MalloyTranslator=t.composeSQLExpr=t.indent=t.expressionIsUngroupedAggregate=t.expressionIsScalar=t.expressionIsCalculation=t.expressionIsAnalytic=t.expressionIsAggregate=t.mkFieldDef=t.mkArrayDef=t.isScalarArray=t.isRepeatedRecord=t.isSamplingRows=t.isSamplingPercent=t.isSamplingEnable=t.isJoinedSource=t.isJoined=t.isLeafAtomic=t.Segment=t.isSourceDef=t.TinyParser=t.Dialect=t.spread=t.literal=t.variadicParam=t.param=t.makeParam=t.sql=t.maxScalar=t.minAggregate=t.anyExprType=t.minScalar=t.overload=t.qtz=t.arg=t.registerDialect=t.MySQLDialect=t.SnowflakeDialect=t.PostgresDialect=t.TrinoDialect=t.StandardSQLDialect=t.DuckDBDialect=void 0,t.annotationToTag=t.modelDefToModelInfo=t.toAsyncGenerator=t.CacheManager=t.InMemoryModelCache=t.Explore=t.DataWriter=t.Parse=t.JSONWriter=t.CSVWriter=t.QueryMaterializer=t.Result=t.PreparedResult=t.TimestampTimeframe=t.DateTimeframe=t.SourceRelationship=t.JoinRelationship=t.MalloyError=t.FixedConnectionMap=void 0;var e=Hx;Object.defineProperty(t,"DuckDBDialect",{enumerable:!0,get:function(){return e.DuckDBDialect}}),Object.defineProperty(t,"StandardSQLDialect",{enumerable:!0,get:function(){return e.StandardSQLDialect}}),Object.defineProperty(t,"TrinoDialect",{enumerable:!0,get:function(){return e.TrinoDialect}}),Object.defineProperty(t,"PostgresDialect",{enumerable:!0,get:function(){return e.PostgresDialect}}),Object.defineProperty(t,"SnowflakeDialect",{enumerable:!0,get:function(){return e.SnowflakeDialect}}),Object.defineProperty(t,"MySQLDialect",{enumerable:!0,get:function(){return e.MySQLDialect}}),Object.defineProperty(t,"registerDialect",{enumerable:!0,get:function(){return e.registerDialect}}),Object.defineProperty(t,"arg",{enumerable:!0,get:function(){return e.arg}}),Object.defineProperty(t,"qtz",{enumerable:!0,get:function(){return e.qtz}}),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,"anyExprType",{enumerable:!0,get:function(){return e.anyExprType}}),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,"sql",{enumerable:!0,get:function(){return e.sql}}),Object.defineProperty(t,"makeParam",{enumerable:!0,get:function(){return e.makeParam}}),Object.defineProperty(t,"param",{enumerable:!0,get:function(){return e.param}}),Object.defineProperty(t,"variadicParam",{enumerable:!0,get:function(){return e.variadicParam}}),Object.defineProperty(t,"literal",{enumerable:!0,get:function(){return e.literal}}),Object.defineProperty(t,"spread",{enumerable:!0,get:function(){return e.spread}}),Object.defineProperty(t,"Dialect",{enumerable:!0,get:function(){return e.Dialect}}),Object.defineProperty(t,"TinyParser",{enumerable:!0,get:function(){return e.TinyParser}});var n=Li;Object.defineProperty(t,"isSourceDef",{enumerable:!0,get:function(){return n.isSourceDef}}),Object.defineProperty(t,"Segment",{enumerable:!0,get:function(){return n.Segment}}),Object.defineProperty(t,"isLeafAtomic",{enumerable:!0,get:function(){return n.isLeafAtomic}}),Object.defineProperty(t,"isJoined",{enumerable:!0,get:function(){return n.isJoined}}),Object.defineProperty(t,"isJoinedSource",{enumerable:!0,get:function(){return n.isJoinedSource}}),Object.defineProperty(t,"isSamplingEnable",{enumerable:!0,get:function(){return n.isSamplingEnable}}),Object.defineProperty(t,"isSamplingPercent",{enumerable:!0,get:function(){return n.isSamplingPercent}}),Object.defineProperty(t,"isSamplingRows",{enumerable:!0,get:function(){return n.isSamplingRows}}),Object.defineProperty(t,"isRepeatedRecord",{enumerable:!0,get:function(){return n.isRepeatedRecord}}),Object.defineProperty(t,"isScalarArray",{enumerable:!0,get:function(){return n.isScalarArray}}),Object.defineProperty(t,"mkArrayDef",{enumerable:!0,get:function(){return n.mkArrayDef}}),Object.defineProperty(t,"mkFieldDef",{enumerable:!0,get:function(){return n.mkFieldDef}}),Object.defineProperty(t,"expressionIsAggregate",{enumerable:!0,get:function(){return n.expressionIsAggregate}}),Object.defineProperty(t,"expressionIsAnalytic",{enumerable:!0,get:function(){return n.expressionIsAnalytic}}),Object.defineProperty(t,"expressionIsCalculation",{enumerable:!0,get:function(){return n.expressionIsCalculation}}),Object.defineProperty(t,"expressionIsScalar",{enumerable:!0,get:function(){return n.expressionIsScalar}}),Object.defineProperty(t,"expressionIsUngroupedAggregate",{enumerable:!0,get:function(){return n.expressionIsUngroupedAggregate}}),Object.defineProperty(t,"indent",{enumerable:!0,get:function(){return n.indent}}),Object.defineProperty(t,"composeSQLExpr",{enumerable:!0,get:function(){return n.composeSQLExpr}});var r=iD;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return r.MalloyTranslator}});var i=Oe;Object.defineProperty(t,"Model",{enumerable:!0,get:function(){return i.Model}}),Object.defineProperty(t,"Malloy",{enumerable:!0,get:function(){return i.Malloy}}),Object.defineProperty(t,"Runtime",{enumerable:!0,get:function(){return i.Runtime}}),Object.defineProperty(t,"AtomicFieldType",{enumerable:!0,get:function(){return i.AtomicFieldType}}),Object.defineProperty(t,"ConnectionRuntime",{enumerable:!0,get:function(){return i.ConnectionRuntime}}),Object.defineProperty(t,"SingleConnectionRuntime",{enumerable:!0,get:function(){return i.SingleConnectionRuntime}}),Object.defineProperty(t,"EmptyURLReader",{enumerable:!0,get:function(){return i.EmptyURLReader}}),Object.defineProperty(t,"InMemoryURLReader",{enumerable:!0,get:function(){return i.InMemoryURLReader}}),Object.defineProperty(t,"FixedConnectionMap",{enumerable:!0,get:function(){return i.FixedConnectionMap}}),Object.defineProperty(t,"MalloyError",{enumerable:!0,get:function(){return i.MalloyError}}),Object.defineProperty(t,"JoinRelationship",{enumerable:!0,get:function(){return i.JoinRelationship}}),Object.defineProperty(t,"SourceRelationship",{enumerable:!0,get:function(){return i.SourceRelationship}}),Object.defineProperty(t,"DateTimeframe",{enumerable:!0,get:function(){return i.DateTimeframe}}),Object.defineProperty(t,"TimestampTimeframe",{enumerable:!0,get:function(){return i.TimestampTimeframe}}),Object.defineProperty(t,"PreparedResult",{enumerable:!0,get:function(){return i.PreparedResult}}),Object.defineProperty(t,"Result",{enumerable:!0,get:function(){return i.Result}}),Object.defineProperty(t,"QueryMaterializer",{enumerable:!0,get:function(){return i.QueryMaterializer}}),Object.defineProperty(t,"CSVWriter",{enumerable:!0,get:function(){return i.CSVWriter}}),Object.defineProperty(t,"JSONWriter",{enumerable:!0,get:function(){return i.JSONWriter}}),Object.defineProperty(t,"Parse",{enumerable:!0,get:function(){return i.Parse}}),Object.defineProperty(t,"DataWriter",{enumerable:!0,get:function(){return i.DataWriter}}),Object.defineProperty(t,"Explore",{enumerable:!0,get:function(){return i.Explore}}),Object.defineProperty(t,"InMemoryModelCache",{enumerable:!0,get:function(){return i.InMemoryModelCache}}),Object.defineProperty(t,"CacheManager",{enumerable:!0,get:function(){return i.CacheManager}});var s=w_;Object.defineProperty(t,"toAsyncGenerator",{enumerable:!0,get:function(){return s.toAsyncGenerator}});var o=L_;Object.defineProperty(t,"modelDefToModelInfo",{enumerable:!0,get:function(){return o.modelDefToModelInfo}});var u=ss;Object.defineProperty(t,"annotationToTag",{enumerable:!0,get:function(){return u.annotationToTag}})})(Pt);function GDe(t,e,n,r){var i=-1,s=t==null?0:t.length;for(r&&s&&(n=t[++i]);++i<s;)n=e(n,t[i],i,t);return n}var WDe=GDe;function VDe(t){return function(e){return t==null?void 0:t[e]}}var YDe=VDe,KDe=YDe,JDe={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},XDe=KDe(JDe),ZDe=XDe,e7e=typeof T=="object"&&T&&T.Object===Object&&T,t7e=e7e,n7e=t7e,r7e=typeof self=="object"&&self&&self.Object===Object&&self,i7e=n7e||r7e||Function("return this")(),s7e=i7e,o7e=s7e,u7e=o7e.Symbol,d8=u7e;function a7e(t,e){for(var n=-1,r=t==null?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}var l7e=a7e,c7e=Array.isArray,f7e=c7e,lV=d8,cV=Object.prototype,x7e=cV.hasOwnProperty,d7e=cV.toString,Yg=lV?lV.toStringTag:void 0;function h7e(t){var e=x7e.call(t,Yg),n=t[Yg];try{t[Yg]=void 0;var r=!0}catch{}var i=d7e.call(t);return r&&(e?t[Yg]=n:delete t[Yg]),i}var p7e=h7e,g7e=Object.prototype,m7e=g7e.toString;function y7e(t){return m7e.call(t)}var E7e=y7e,fV=d8,A7e=p7e,v7e=E7e,C7e="[object Null]",_7e="[object Undefined]",xV=fV?fV.toStringTag:void 0;function S7e(t){return t==null?t===void 0?_7e:C7e:xV&&xV in Object(t)?A7e(t):v7e(t)}var b7e=S7e;function T7e(t){return t!=null&&typeof t=="object"}var R7e=T7e,D7e=b7e,O7e=R7e,F7e="[object Symbol]";function N7e(t){return typeof t=="symbol"||O7e(t)&&D7e(t)==F7e}var w7e=N7e,dV=d8,L7e=l7e,I7e=f7e,B7e=w7e,$7e=1/0,hV=dV?dV.prototype:void 0,pV=hV?hV.toString:void 0;function gV(t){if(typeof t=="string")return t;if(I7e(t))return L7e(t,gV)+"";if(B7e(t))return pV?pV.call(t):"";var e=t+"";return e=="0"&&1/t==-$7e?"-0":e}var k7e=gV,P7e=k7e;function M7e(t){return t==null?"":P7e(t)}var h8=M7e,U7e=ZDe,j7e=h8,q7e=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,H7e="\\u0300-\\u036f",z7e="\\ufe20-\\ufe2f",Q7e="\\u20d0-\\u20ff",G7e=H7e+z7e+Q7e,W7e="["+G7e+"]",V7e=RegExp(W7e,"g");function Y7e(t){return t=j7e(t),t&&t.replace(q7e,U7e).replace(V7e,"")}var K7e=Y7e,J7e=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function X7e(t){return t.match(J7e)||[]}var Z7e=X7e,eOe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function tOe(t){return eOe.test(t)}var nOe=tOe,mV="\\ud800-\\udfff",rOe="\\u0300-\\u036f",iOe="\\ufe20-\\ufe2f",sOe="\\u20d0-\\u20ff",oOe=rOe+iOe+sOe,yV="\\u2700-\\u27bf",EV="a-z\\xdf-\\xf6\\xf8-\\xff",uOe="\\xac\\xb1\\xd7\\xf7",aOe="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",lOe="\\u2000-\\u206f",cOe=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",AV="A-Z\\xc0-\\xd6\\xd8-\\xde",fOe="\\ufe0e\\ufe0f",vV=uOe+aOe+lOe+cOe,CV="['’]",_V="["+vV+"]",xOe="["+oOe+"]",SV="\\d+",dOe="["+yV+"]",bV="["+EV+"]",TV="[^"+mV+vV+SV+yV+EV+AV+"]",hOe="\\ud83c[\\udffb-\\udfff]",pOe="(?:"+xOe+"|"+hOe+")",gOe="[^"+mV+"]",RV="(?:\\ud83c[\\udde6-\\uddff]){2}",DV="[\\ud800-\\udbff][\\udc00-\\udfff]",Ch="["+AV+"]",mOe="\\u200d",OV="(?:"+bV+"|"+TV+")",yOe="(?:"+Ch+"|"+TV+")",FV="(?:"+CV+"(?:d|ll|m|re|s|t|ve))?",NV="(?:"+CV+"(?:D|LL|M|RE|S|T|VE))?",wV=pOe+"?",LV="["+fOe+"]?",EOe="(?:"+mOe+"(?:"+[gOe,RV,DV].join("|")+")"+LV+wV+")*",AOe="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",vOe="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",COe=LV+wV+EOe,_Oe="(?:"+[dOe,RV,DV].join("|")+")"+COe,SOe=RegExp([Ch+"?"+bV+"+"+FV+"(?="+[_V,Ch,"$"].join("|")+")",yOe+"+"+NV+"(?="+[_V,Ch+OV,"$"].join("|")+")",Ch+"?"+OV+"+"+FV,Ch+"+"+NV,vOe,AOe,SV,_Oe].join("|"),"g");function bOe(t){return t.match(SOe)||[]}var TOe=bOe,ROe=Z7e,DOe=nOe,OOe=h8,FOe=TOe;function NOe(t,e,n){return t=OOe(t),e=n?void 0:e,e===void 0?DOe(t)?FOe(t):ROe(t):t.match(e)||[]}var wOe=NOe,LOe=WDe,IOe=K7e,BOe=wOe,$Oe="['’]",kOe=RegExp($Oe,"g");function POe(t){return function(e){return LOe(BOe(IOe(e).replace(kOe,"")),t,"")}}var MOe=POe;function UOe(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),n=n>i?i:n,n<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var s=Array(i);++r<i;)s[r]=t[r+e];return s}var jOe=UOe,qOe=jOe;function HOe(t,e,n){var r=t.length;return n=n===void 0?r:n,!e&&n>=r?t:qOe(t,e,n)}var zOe=HOe,QOe="\\ud800-\\udfff",GOe="\\u0300-\\u036f",WOe="\\ufe20-\\ufe2f",VOe="\\u20d0-\\u20ff",YOe=GOe+WOe+VOe,KOe="\\ufe0e\\ufe0f",JOe="\\u200d",XOe=RegExp("["+JOe+QOe+YOe+KOe+"]");function ZOe(t){return XOe.test(t)}var IV=ZOe;function e8e(t){return t.split("")}var t8e=e8e,BV="\\ud800-\\udfff",n8e="\\u0300-\\u036f",r8e="\\ufe20-\\ufe2f",i8e="\\u20d0-\\u20ff",s8e=n8e+r8e+i8e,o8e="\\ufe0e\\ufe0f",u8e="["+BV+"]",p8="["+s8e+"]",g8="\\ud83c[\\udffb-\\udfff]",a8e="(?:"+p8+"|"+g8+")",$V="[^"+BV+"]",kV="(?:\\ud83c[\\udde6-\\uddff]){2}",PV="[\\ud800-\\udbff][\\udc00-\\udfff]",l8e="\\u200d",MV=a8e+"?",UV="["+o8e+"]?",c8e="(?:"+l8e+"(?:"+[$V,kV,PV].join("|")+")"+UV+MV+")*",f8e=UV+MV+c8e,x8e="(?:"+[$V+p8+"?",p8,kV,PV,u8e].join("|")+")",d8e=RegExp(g8+"(?="+g8+")|"+x8e+f8e,"g");function h8e(t){return t.match(d8e)||[]}var p8e=h8e,g8e=t8e,m8e=IV,y8e=p8e;function E8e(t){return m8e(t)?y8e(t):g8e(t)}var A8e=E8e,v8e=zOe,C8e=IV,_8e=A8e,S8e=h8;function b8e(t){return function(e){e=S8e(e);var n=C8e(e)?_8e(e):void 0,r=n?n[0]:e.charAt(0),i=n?v8e(n,1).join(""):e.slice(1);return r[t]()+i}}var T8e=b8e,R8e=T8e,D8e=R8e("toUpperCase"),O8e=D8e,F8e=MOe,N8e=O8e,w8e=F8e(function(t,e,n){return t+(n?" ":"")+N8e(e)}),L8e=w8e;const I8e=ky(L8e);function ji(t,e,n=!1){if(t!==void 0)switch(t){case"ordinal":return{range:["#C2D5EE","#1A73E8"]};case"temporal":case"quantitative":return e?n?{range:["#6BA4EE","#EEA361"]}:{range:["#1A73E8","#E8710A"]}:{range:["#C2D5EE","#1A73E8"]};case"nominal":return n?{range:["#6BA4EE","#66CEDC","#EC72B8","#EEA361","#F9C85B","#AACD85","#B87CED","#ACB0B3"]}:{range:["#1A73E8","#12B5CB","#E52592","#E8710A","#F9AB00","#7CB342","#9334E6","#80868B"]}}}function on(t,e){return t.toString().padStart(e,"0")}function B_(t,e,n){e||(e=Pt.TimestampTimeframe.Second);let r=!1;switch(e){case Pt.TimestampTimeframe.Hour:case Pt.TimestampTimeframe.Minute:case Pt.TimestampTimeframe.Second:r=!0;break}const i=lt.fromJSDate(t,{zone:r&&n?n:"UTC"});switch(e){case Pt.TimestampTimeframe.Year:case Pt.DateTimeframe.Year:return`${on(i.year,4)}`;case Pt.TimestampTimeframe.Quarter:case Pt.DateTimeframe.Quarter:{const s=on(i.year,4),o=Math.floor(i.month/3)+1;return`${s}-Q${o}`}case Pt.TimestampTimeframe.Month:case Pt.DateTimeframe.Month:{const s=on(i.year,2),o=on(i.month,2);return`${s}-${o}`}case Pt.TimestampTimeframe.Week:case Pt.DateTimeframe.Week:{const s=on(i.year,2),o=on(i.month,2),u=on(i.day,2);return`WK${s}-${o}-${u}`}case Pt.DateTimeframe.Day:case Pt.TimestampTimeframe.Day:{const s=on(i.year,2),o=on(i.month,2),u=on(i.day,2);return`${s}-${o}-${u}`}case Pt.TimestampTimeframe.Hour:{const s=on(i.year,2),o=on(i.month,2),u=on(i.day,2),a=on(i.hour,2);return`${s}-${o}-${u} ${a}:00 for 1 hour`}case Pt.TimestampTimeframe.Minute:{const s=on(i.year,2),o=on(i.month,2),u=on(i.day,2),a=on(i.hour,2),l=on(i.minute,2);return`${s}-${o}-${u} ${a}:${l}`}case Pt.TimestampTimeframe.Second:{const s=on(i.year,2),o=on(i.month,2),u=on(i.day,2),a=on(i.hour,2),l=on(i.minute,2),c=on(i.second,2);return`${s}-${o}-${u} ${a}:${l}:${c}`}default:throw new Error("Unknown timeframe.")}}function B8e(t,e){const n=lt.fromJSDate(t,{zone:e??"UTC"});return new Date(n.year,n.month-1,n.day,n.hour,n.minute,n.second,n.millisecond)}let m8;const $8e=100;async function $_(){const t=Date.now();if(!(m8&&t<m8+$8e))return m8=t,new Promise(e=>{setTimeout(e,0)})}function Es(t,e){const n=t.createElement("span");return n.classList.add("error"),n.appendChild(t.createTextNode(typeof e=="string"?e:e.message)),n}function Kg(t){const e=t.createElement("span");return e.appendChild(t.createTextNode("∅")),e.classList.add("value-null"),e}function jV(t){const e=t.createElement("div");return e.classList.add("drill-icon"),e.innerHTML=`
1296
+ `,this.quoteCharacter='"',this.includeHeader=!0,this.emptyCell=""}escape(e){const n=e.includes(this.quoteCharacter),r=e.includes(this.columnSeparator),i=e.includes(this.rowSeparator),s=r||n||i;return n&&(e=e.replace(new RegExp(this.quoteCharacter,"g"),this.quoteCharacter+this.quoteCharacter)),s&&(e=this.quoteCharacter+e+this.quoteCharacter),e}stringify(e){return e===null?this.emptyCell:e instanceof Date?e.toISOString():typeof e=="boolean"||typeof e=="number"?JSON.stringify(e):`${e}`}getColWeight(e){let n=e;Array.isArray(e)&&(n=e[0]);let r=0;for(const i in n){r=r+1;const s=n[i];if(Array.isArray(s)){const o=this.getColWeight(s)-1;r=r+o}}return r}getHeaderRow(e){const n=[];let r=0;for(const i in e){n.push(this.escape(i));const s=e[i];if(r++,Array.isArray(s)){const o=this.getColWeight(s)-1;r=r+o;for(let u=0;u<o;u++)n.push(this.emptyCell)}}return{rows:[n.join(this.columnSeparator)],length:1,width:r}}mergeMatrices(e){const n=Math.max(...e.map(s=>s.length)),r=e.reduce((s,o)=>s+o.width,0),i=[];for(let s=0;s<n;s++){const o=[];for(const u of e)if(s<u.length)o.push(u.rows[s]);else{const a=Array(u.width).fill(this.emptyCell);o.push(...a)}i.push(o.join(this.columnSeparator))}return{rows:i,length:n,width:r}}getChildMatrix(e){if(Array.isArray(e)){if(e.length===0)return{rows:[""],length:1,width:1}}else return{rows:["Invalid data found, value is not an array"],length:1,width:1};const n=[],r=this.getHeaderRow(e[0]);n.push(...r.rows);const i=r.width;let s=1;for(const o of e){const u=this.getRowMatrix(o);s=s+u.length,n.push(...u.rows)}return{rows:n,length:s,width:i}}getRowMatrix(e){const n=[];for(const r in e){const i=e[r];if(Array.isArray(i)){const s=this.getChildMatrix(i);n.push(s)}else{const s={rows:[this.stringify(i)],length:1,width:1};n.push(s)}}return this.mergeMatrices(n)}async process(e){let n=!1;for await(const r of e){if(!n&&this.includeHeader){const s=this.getHeaderRow(r.toObject());this.stream.write(s.rows[0]),this.stream.write(this.rowSeparator),n=!0}const i=this.getRowMatrix(r.toObject());for(const s of i.rows)this.stream.write(s),this.stream.write(this.rowSeparator)}this.stream.close()}}Oe.CSVWriter=UDe;class jDe{constructor(e){this.modelCache=e,this.modelDependencies=new Map,this.modelInvalidationKeys=new Map}async getCachedModelDef(e,n){const r=this.modelDependencies.get(n);if(r===void 0)return;const i=[n,...O_(r)],s={};for(const u of i){const a=this.modelInvalidationKeys.get(u);if(a==null)return;s[u]=a}for(const u of i)if(await f8(e,new URL(u))!==s[u])return;const o=await this.modelCache.getModel(new URL(n));if(o!==void 0){for(const u of i)if(o.invalidationKeys[u]!==s[u])return;return{modelDef:o.modelDef,invalidationKeys:s}}}async setCachedModelDef(e,n){this.modelDependencies.set(e,n.modelDef.dependencies);const r={};for(const s of[e,...O_(n.modelDef.dependencies)]){if(n.invalidationKeys[s]===null)return!1;if(n.invalidationKeys[s]===void 0)throw new Error(`Missing invalidation key for dependency ${s}`);this.modelInvalidationKeys.set(s,n.invalidationKeys[s]),r[s]=n.invalidationKeys[s]}return!!await this.modelCache.setModel(new URL(e),{modelDef:n.modelDef,invalidationKeys:r})}}Oe.CacheManager=jDe;function O_(t){return[...Object.keys(t),...Object.values(t).map(O_).flat()]}class qDe{constructor(){this.models=new Map}async getModel(e){return Promise.resolve(this.models.get(e.toString()))}async setModel(e,n){return this.models.set(e.toString(),n),Promise.resolve(!0)}}Oe.InMemoryModelCache=qDe;function oV(t){return(0,LDe.v5)(t,"76c17e9d-f3ce-5f2d-bfde-98ad3d2a37f6")}async function F_(t,e){const n=await t.readURL(e),{contents:r,invalidationKey:i}=typeof n=="string"?{contents:n,invalidationKey:void 0}:n;return{contents:r,invalidationKey:N_(e.toString())?null:i??oV(r)}}async function f8(t,e){return N_(e.toString())?null:t.getInvalidationKey!==void 0?await t.getInvalidationKey(e):(await F_(t,e)).invalidationKey}function N_(t){return t.startsWith("internal://")}var w_={};Object.defineProperty(w_,"__esModule",{value:!0}),w_.toAsyncGenerator=void 0;async function*HDe(t){let e=!1;function n(i){let s;const o=new Promise(u=>{s=u});return i(u=>{s({done:!0,isError:!0,error:u})},u=>{s({done:!1,value:u,isError:!1,next:new Promise(a=>{s=a})})},()=>{s({done:!0,isError:!1})}),o}let r=n(t);for(;!e;){const i=await r;if(i.done){if(e=!0,i.isError)throw i.error;break}else r=i.next,yield i.value}}w_.toAsyncGenerator=HDe;var L_={};Object.defineProperty(L_,"__esModule",{value:!0}),L_.modelDefToModelInfo=void 0;const Ga=Li,uV=Bs;function zDe(t){const e={entries:[],anonymous_queries:[]};for(const[n,r]of Object.entries(t.contents))if(t.exports.includes(n)){if((0,Ga.isSourceDef)(r)){const i={kind:"source",name:n,schema:{fields:I_(r,r.fields)}};e.entries.push(i)}else if(r.type==="query"){const i=(0,uV.getResultStructDefForQuery)(t,r),s={kind:"source",name:n,schema:{fields:I_(i,i.fields)}};e.entries.push(s)}}return e}L_.modelDefToModelInfo=zDe;function I_(t,e){var n,r,i;const s=[];for(const o of e)if((0,Ga.isTurtle)(o)){const u=(0,uV.getResultStructDefForView)(t,o),a={kind:"view",name:(n=o.as)!==null&&n!==void 0?n:o.name,schema:{fields:I_(u,u.fields)}};s.push(a)}else if((0,Ga.isAtomic)(o)){const u=(0,Ga.expressionIsAggregate)(o.expressionType),a=(0,Ga.expressionIsScalar)(o.expressionType);if(!u&&!a||o.type==="error")continue;const l={kind:u?"measure":"dimension",name:(r=o.as)!==null&&r!==void 0?r:o.name,type:x8(o)};s.push(l)}else if((0,Ga.isJoinedSource)(o)){const u={kind:"join",name:(i=o.as)!==null&&i!==void 0?i:o.name,schema:{fields:I_(o,o.fields)},relationship:o.join};s.push(u)}return s}function x8(t){if((0,Ga.isLeafAtomic)(t))switch(t.type){case"string":return{kind:"string_type"};case"number":return{kind:"number_type",subtype:t.numberType==="float"?"decimal":t.numberType==="integer"?"integer":void 0};case"boolean":return{kind:"boolean_type"};case"date":return{kind:"date_type",timeframe:QDe(t.timeframe)};case"timestamp":return{kind:"timestamp_type",timeframe:t.timeframe};case"json":return{kind:"json_type"};case"sql native":return{kind:"sql_native_type",sql_type:t.rawType};case"error":throw new Error("Error type is not supported in stable interface")}else{if((0,Ga.isRepeatedRecord)(t))return{kind:"array_type",element_type:aV(t)};if(t.type==="record")return aV(t);if(t.type==="array")return{kind:"array_type",element_type:x8(t.elementTypeDef)}}throw new Error("Unexpected field type")}function aV(t){return{kind:"record_type",fields:t.fields.map(e=>{if((0,Ga.isAtomic)(e))return{name:e.name,type:x8(e)};throw new Error("Expected record type to not have a table as its child")})}}function QDe(t){switch(t){case void 0:return;case"day":case"week":case"month":case"year":case"quarter":return t;default:throw new Error("Invalid date timeframe")}}function Rlt(t){return t}function Dlt(t){return t}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryURLReader=t.EmptyURLReader=t.SingleConnectionRuntime=t.ConnectionRuntime=t.AtomicFieldType=t.Runtime=t.Malloy=t.Model=t.MalloyTranslator=t.composeSQLExpr=t.indent=t.expressionIsUngroupedAggregate=t.expressionIsScalar=t.expressionIsCalculation=t.expressionIsAnalytic=t.expressionIsAggregate=t.mkFieldDef=t.mkArrayDef=t.isScalarArray=t.isRepeatedRecord=t.isSamplingRows=t.isSamplingPercent=t.isSamplingEnable=t.isJoinedSource=t.isJoined=t.isLeafAtomic=t.Segment=t.isSourceDef=t.TinyParser=t.Dialect=t.spread=t.literal=t.variadicParam=t.param=t.makeParam=t.sql=t.maxScalar=t.minAggregate=t.anyExprType=t.minScalar=t.overload=t.qtz=t.arg=t.registerDialect=t.MySQLDialect=t.SnowflakeDialect=t.PostgresDialect=t.TrinoDialect=t.StandardSQLDialect=t.DuckDBDialect=void 0,t.annotationToTaglines=t.annotationToTag=t.modelDefToModelInfo=t.toAsyncGenerator=t.CacheManager=t.InMemoryModelCache=t.Explore=t.DataWriter=t.Parse=t.JSONWriter=t.CSVWriter=t.QueryMaterializer=t.Result=t.PreparedResult=t.TimestampTimeframe=t.DateTimeframe=t.SourceRelationship=t.JoinRelationship=t.MalloyError=t.FixedConnectionMap=void 0;var e=Hx;Object.defineProperty(t,"DuckDBDialect",{enumerable:!0,get:function(){return e.DuckDBDialect}}),Object.defineProperty(t,"StandardSQLDialect",{enumerable:!0,get:function(){return e.StandardSQLDialect}}),Object.defineProperty(t,"TrinoDialect",{enumerable:!0,get:function(){return e.TrinoDialect}}),Object.defineProperty(t,"PostgresDialect",{enumerable:!0,get:function(){return e.PostgresDialect}}),Object.defineProperty(t,"SnowflakeDialect",{enumerable:!0,get:function(){return e.SnowflakeDialect}}),Object.defineProperty(t,"MySQLDialect",{enumerable:!0,get:function(){return e.MySQLDialect}}),Object.defineProperty(t,"registerDialect",{enumerable:!0,get:function(){return e.registerDialect}}),Object.defineProperty(t,"arg",{enumerable:!0,get:function(){return e.arg}}),Object.defineProperty(t,"qtz",{enumerable:!0,get:function(){return e.qtz}}),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,"anyExprType",{enumerable:!0,get:function(){return e.anyExprType}}),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,"sql",{enumerable:!0,get:function(){return e.sql}}),Object.defineProperty(t,"makeParam",{enumerable:!0,get:function(){return e.makeParam}}),Object.defineProperty(t,"param",{enumerable:!0,get:function(){return e.param}}),Object.defineProperty(t,"variadicParam",{enumerable:!0,get:function(){return e.variadicParam}}),Object.defineProperty(t,"literal",{enumerable:!0,get:function(){return e.literal}}),Object.defineProperty(t,"spread",{enumerable:!0,get:function(){return e.spread}}),Object.defineProperty(t,"Dialect",{enumerable:!0,get:function(){return e.Dialect}}),Object.defineProperty(t,"TinyParser",{enumerable:!0,get:function(){return e.TinyParser}});var n=Li;Object.defineProperty(t,"isSourceDef",{enumerable:!0,get:function(){return n.isSourceDef}}),Object.defineProperty(t,"Segment",{enumerable:!0,get:function(){return n.Segment}}),Object.defineProperty(t,"isLeafAtomic",{enumerable:!0,get:function(){return n.isLeafAtomic}}),Object.defineProperty(t,"isJoined",{enumerable:!0,get:function(){return n.isJoined}}),Object.defineProperty(t,"isJoinedSource",{enumerable:!0,get:function(){return n.isJoinedSource}}),Object.defineProperty(t,"isSamplingEnable",{enumerable:!0,get:function(){return n.isSamplingEnable}}),Object.defineProperty(t,"isSamplingPercent",{enumerable:!0,get:function(){return n.isSamplingPercent}}),Object.defineProperty(t,"isSamplingRows",{enumerable:!0,get:function(){return n.isSamplingRows}}),Object.defineProperty(t,"isRepeatedRecord",{enumerable:!0,get:function(){return n.isRepeatedRecord}}),Object.defineProperty(t,"isScalarArray",{enumerable:!0,get:function(){return n.isScalarArray}}),Object.defineProperty(t,"mkArrayDef",{enumerable:!0,get:function(){return n.mkArrayDef}}),Object.defineProperty(t,"mkFieldDef",{enumerable:!0,get:function(){return n.mkFieldDef}}),Object.defineProperty(t,"expressionIsAggregate",{enumerable:!0,get:function(){return n.expressionIsAggregate}}),Object.defineProperty(t,"expressionIsAnalytic",{enumerable:!0,get:function(){return n.expressionIsAnalytic}}),Object.defineProperty(t,"expressionIsCalculation",{enumerable:!0,get:function(){return n.expressionIsCalculation}}),Object.defineProperty(t,"expressionIsScalar",{enumerable:!0,get:function(){return n.expressionIsScalar}}),Object.defineProperty(t,"expressionIsUngroupedAggregate",{enumerable:!0,get:function(){return n.expressionIsUngroupedAggregate}}),Object.defineProperty(t,"indent",{enumerable:!0,get:function(){return n.indent}}),Object.defineProperty(t,"composeSQLExpr",{enumerable:!0,get:function(){return n.composeSQLExpr}});var r=iD;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return r.MalloyTranslator}});var i=Oe;Object.defineProperty(t,"Model",{enumerable:!0,get:function(){return i.Model}}),Object.defineProperty(t,"Malloy",{enumerable:!0,get:function(){return i.Malloy}}),Object.defineProperty(t,"Runtime",{enumerable:!0,get:function(){return i.Runtime}}),Object.defineProperty(t,"AtomicFieldType",{enumerable:!0,get:function(){return i.AtomicFieldType}}),Object.defineProperty(t,"ConnectionRuntime",{enumerable:!0,get:function(){return i.ConnectionRuntime}}),Object.defineProperty(t,"SingleConnectionRuntime",{enumerable:!0,get:function(){return i.SingleConnectionRuntime}}),Object.defineProperty(t,"EmptyURLReader",{enumerable:!0,get:function(){return i.EmptyURLReader}}),Object.defineProperty(t,"InMemoryURLReader",{enumerable:!0,get:function(){return i.InMemoryURLReader}}),Object.defineProperty(t,"FixedConnectionMap",{enumerable:!0,get:function(){return i.FixedConnectionMap}}),Object.defineProperty(t,"MalloyError",{enumerable:!0,get:function(){return i.MalloyError}}),Object.defineProperty(t,"JoinRelationship",{enumerable:!0,get:function(){return i.JoinRelationship}}),Object.defineProperty(t,"SourceRelationship",{enumerable:!0,get:function(){return i.SourceRelationship}}),Object.defineProperty(t,"DateTimeframe",{enumerable:!0,get:function(){return i.DateTimeframe}}),Object.defineProperty(t,"TimestampTimeframe",{enumerable:!0,get:function(){return i.TimestampTimeframe}}),Object.defineProperty(t,"PreparedResult",{enumerable:!0,get:function(){return i.PreparedResult}}),Object.defineProperty(t,"Result",{enumerable:!0,get:function(){return i.Result}}),Object.defineProperty(t,"QueryMaterializer",{enumerable:!0,get:function(){return i.QueryMaterializer}}),Object.defineProperty(t,"CSVWriter",{enumerable:!0,get:function(){return i.CSVWriter}}),Object.defineProperty(t,"JSONWriter",{enumerable:!0,get:function(){return i.JSONWriter}}),Object.defineProperty(t,"Parse",{enumerable:!0,get:function(){return i.Parse}}),Object.defineProperty(t,"DataWriter",{enumerable:!0,get:function(){return i.DataWriter}}),Object.defineProperty(t,"Explore",{enumerable:!0,get:function(){return i.Explore}}),Object.defineProperty(t,"InMemoryModelCache",{enumerable:!0,get:function(){return i.InMemoryModelCache}}),Object.defineProperty(t,"CacheManager",{enumerable:!0,get:function(){return i.CacheManager}});var s=w_;Object.defineProperty(t,"toAsyncGenerator",{enumerable:!0,get:function(){return s.toAsyncGenerator}});var o=L_;Object.defineProperty(t,"modelDefToModelInfo",{enumerable:!0,get:function(){return o.modelDefToModelInfo}});var u=ss;Object.defineProperty(t,"annotationToTag",{enumerable:!0,get:function(){return u.annotationToTag}}),Object.defineProperty(t,"annotationToTaglines",{enumerable:!0,get:function(){return u.annotationToTaglines}})})(Pt);function GDe(t,e,n,r){var i=-1,s=t==null?0:t.length;for(r&&s&&(n=t[++i]);++i<s;)n=e(n,t[i],i,t);return n}var WDe=GDe;function VDe(t){return function(e){return t==null?void 0:t[e]}}var YDe=VDe,KDe=YDe,JDe={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},XDe=KDe(JDe),ZDe=XDe,e7e=typeof T=="object"&&T&&T.Object===Object&&T,t7e=e7e,n7e=t7e,r7e=typeof self=="object"&&self&&self.Object===Object&&self,i7e=n7e||r7e||Function("return this")(),s7e=i7e,o7e=s7e,u7e=o7e.Symbol,d8=u7e;function a7e(t,e){for(var n=-1,r=t==null?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}var l7e=a7e,c7e=Array.isArray,f7e=c7e,lV=d8,cV=Object.prototype,x7e=cV.hasOwnProperty,d7e=cV.toString,Yg=lV?lV.toStringTag:void 0;function h7e(t){var e=x7e.call(t,Yg),n=t[Yg];try{t[Yg]=void 0;var r=!0}catch{}var i=d7e.call(t);return r&&(e?t[Yg]=n:delete t[Yg]),i}var p7e=h7e,g7e=Object.prototype,m7e=g7e.toString;function y7e(t){return m7e.call(t)}var E7e=y7e,fV=d8,A7e=p7e,v7e=E7e,C7e="[object Null]",_7e="[object Undefined]",xV=fV?fV.toStringTag:void 0;function S7e(t){return t==null?t===void 0?_7e:C7e:xV&&xV in Object(t)?A7e(t):v7e(t)}var b7e=S7e;function T7e(t){return t!=null&&typeof t=="object"}var R7e=T7e,D7e=b7e,O7e=R7e,F7e="[object Symbol]";function N7e(t){return typeof t=="symbol"||O7e(t)&&D7e(t)==F7e}var w7e=N7e,dV=d8,L7e=l7e,I7e=f7e,B7e=w7e,$7e=1/0,hV=dV?dV.prototype:void 0,pV=hV?hV.toString:void 0;function gV(t){if(typeof t=="string")return t;if(I7e(t))return L7e(t,gV)+"";if(B7e(t))return pV?pV.call(t):"";var e=t+"";return e=="0"&&1/t==-$7e?"-0":e}var k7e=gV,P7e=k7e;function M7e(t){return t==null?"":P7e(t)}var h8=M7e,U7e=ZDe,j7e=h8,q7e=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,H7e="\\u0300-\\u036f",z7e="\\ufe20-\\ufe2f",Q7e="\\u20d0-\\u20ff",G7e=H7e+z7e+Q7e,W7e="["+G7e+"]",V7e=RegExp(W7e,"g");function Y7e(t){return t=j7e(t),t&&t.replace(q7e,U7e).replace(V7e,"")}var K7e=Y7e,J7e=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function X7e(t){return t.match(J7e)||[]}var Z7e=X7e,eOe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function tOe(t){return eOe.test(t)}var nOe=tOe,mV="\\ud800-\\udfff",rOe="\\u0300-\\u036f",iOe="\\ufe20-\\ufe2f",sOe="\\u20d0-\\u20ff",oOe=rOe+iOe+sOe,yV="\\u2700-\\u27bf",EV="a-z\\xdf-\\xf6\\xf8-\\xff",uOe="\\xac\\xb1\\xd7\\xf7",aOe="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",lOe="\\u2000-\\u206f",cOe=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",AV="A-Z\\xc0-\\xd6\\xd8-\\xde",fOe="\\ufe0e\\ufe0f",vV=uOe+aOe+lOe+cOe,CV="['’]",_V="["+vV+"]",xOe="["+oOe+"]",SV="\\d+",dOe="["+yV+"]",bV="["+EV+"]",TV="[^"+mV+vV+SV+yV+EV+AV+"]",hOe="\\ud83c[\\udffb-\\udfff]",pOe="(?:"+xOe+"|"+hOe+")",gOe="[^"+mV+"]",RV="(?:\\ud83c[\\udde6-\\uddff]){2}",DV="[\\ud800-\\udbff][\\udc00-\\udfff]",Ch="["+AV+"]",mOe="\\u200d",OV="(?:"+bV+"|"+TV+")",yOe="(?:"+Ch+"|"+TV+")",FV="(?:"+CV+"(?:d|ll|m|re|s|t|ve))?",NV="(?:"+CV+"(?:D|LL|M|RE|S|T|VE))?",wV=pOe+"?",LV="["+fOe+"]?",EOe="(?:"+mOe+"(?:"+[gOe,RV,DV].join("|")+")"+LV+wV+")*",AOe="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",vOe="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",COe=LV+wV+EOe,_Oe="(?:"+[dOe,RV,DV].join("|")+")"+COe,SOe=RegExp([Ch+"?"+bV+"+"+FV+"(?="+[_V,Ch,"$"].join("|")+")",yOe+"+"+NV+"(?="+[_V,Ch+OV,"$"].join("|")+")",Ch+"?"+OV+"+"+FV,Ch+"+"+NV,vOe,AOe,SV,_Oe].join("|"),"g");function bOe(t){return t.match(SOe)||[]}var TOe=bOe,ROe=Z7e,DOe=nOe,OOe=h8,FOe=TOe;function NOe(t,e,n){return t=OOe(t),e=n?void 0:e,e===void 0?DOe(t)?FOe(t):ROe(t):t.match(e)||[]}var wOe=NOe,LOe=WDe,IOe=K7e,BOe=wOe,$Oe="['’]",kOe=RegExp($Oe,"g");function POe(t){return function(e){return LOe(BOe(IOe(e).replace(kOe,"")),t,"")}}var MOe=POe;function UOe(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),n=n>i?i:n,n<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var s=Array(i);++r<i;)s[r]=t[r+e];return s}var jOe=UOe,qOe=jOe;function HOe(t,e,n){var r=t.length;return n=n===void 0?r:n,!e&&n>=r?t:qOe(t,e,n)}var zOe=HOe,QOe="\\ud800-\\udfff",GOe="\\u0300-\\u036f",WOe="\\ufe20-\\ufe2f",VOe="\\u20d0-\\u20ff",YOe=GOe+WOe+VOe,KOe="\\ufe0e\\ufe0f",JOe="\\u200d",XOe=RegExp("["+JOe+QOe+YOe+KOe+"]");function ZOe(t){return XOe.test(t)}var IV=ZOe;function e8e(t){return t.split("")}var t8e=e8e,BV="\\ud800-\\udfff",n8e="\\u0300-\\u036f",r8e="\\ufe20-\\ufe2f",i8e="\\u20d0-\\u20ff",s8e=n8e+r8e+i8e,o8e="\\ufe0e\\ufe0f",u8e="["+BV+"]",p8="["+s8e+"]",g8="\\ud83c[\\udffb-\\udfff]",a8e="(?:"+p8+"|"+g8+")",$V="[^"+BV+"]",kV="(?:\\ud83c[\\udde6-\\uddff]){2}",PV="[\\ud800-\\udbff][\\udc00-\\udfff]",l8e="\\u200d",MV=a8e+"?",UV="["+o8e+"]?",c8e="(?:"+l8e+"(?:"+[$V,kV,PV].join("|")+")"+UV+MV+")*",f8e=UV+MV+c8e,x8e="(?:"+[$V+p8+"?",p8,kV,PV,u8e].join("|")+")",d8e=RegExp(g8+"(?="+g8+")|"+x8e+f8e,"g");function h8e(t){return t.match(d8e)||[]}var p8e=h8e,g8e=t8e,m8e=IV,y8e=p8e;function E8e(t){return m8e(t)?y8e(t):g8e(t)}var A8e=E8e,v8e=zOe,C8e=IV,_8e=A8e,S8e=h8;function b8e(t){return function(e){e=S8e(e);var n=C8e(e)?_8e(e):void 0,r=n?n[0]:e.charAt(0),i=n?v8e(n,1).join(""):e.slice(1);return r[t]()+i}}var T8e=b8e,R8e=T8e,D8e=R8e("toUpperCase"),O8e=D8e,F8e=MOe,N8e=O8e,w8e=F8e(function(t,e,n){return t+(n?" ":"")+N8e(e)}),L8e=w8e;const I8e=ky(L8e);function ji(t,e,n=!1){if(t!==void 0)switch(t){case"ordinal":return{range:["#C2D5EE","#1A73E8"]};case"temporal":case"quantitative":return e?n?{range:["#6BA4EE","#EEA361"]}:{range:["#1A73E8","#E8710A"]}:{range:["#C2D5EE","#1A73E8"]};case"nominal":return n?{range:["#6BA4EE","#66CEDC","#EC72B8","#EEA361","#F9C85B","#AACD85","#B87CED","#ACB0B3"]}:{range:["#1A73E8","#12B5CB","#E52592","#E8710A","#F9AB00","#7CB342","#9334E6","#80868B"]}}}function on(t,e){return t.toString().padStart(e,"0")}function B_(t,e,n){e||(e=Pt.TimestampTimeframe.Second);let r=!1;switch(e){case Pt.TimestampTimeframe.Hour:case Pt.TimestampTimeframe.Minute:case Pt.TimestampTimeframe.Second:r=!0;break}const i=lt.fromJSDate(t,{zone:r&&n?n:"UTC"});switch(e){case Pt.TimestampTimeframe.Year:case Pt.DateTimeframe.Year:return`${on(i.year,4)}`;case Pt.TimestampTimeframe.Quarter:case Pt.DateTimeframe.Quarter:{const s=on(i.year,4),o=Math.floor(i.month/3)+1;return`${s}-Q${o}`}case Pt.TimestampTimeframe.Month:case Pt.DateTimeframe.Month:{const s=on(i.year,2),o=on(i.month,2);return`${s}-${o}`}case Pt.TimestampTimeframe.Week:case Pt.DateTimeframe.Week:{const s=on(i.year,2),o=on(i.month,2),u=on(i.day,2);return`WK${s}-${o}-${u}`}case Pt.DateTimeframe.Day:case Pt.TimestampTimeframe.Day:{const s=on(i.year,2),o=on(i.month,2),u=on(i.day,2);return`${s}-${o}-${u}`}case Pt.TimestampTimeframe.Hour:{const s=on(i.year,2),o=on(i.month,2),u=on(i.day,2),a=on(i.hour,2);return`${s}-${o}-${u} ${a}:00 for 1 hour`}case Pt.TimestampTimeframe.Minute:{const s=on(i.year,2),o=on(i.month,2),u=on(i.day,2),a=on(i.hour,2),l=on(i.minute,2);return`${s}-${o}-${u} ${a}:${l}`}case Pt.TimestampTimeframe.Second:{const s=on(i.year,2),o=on(i.month,2),u=on(i.day,2),a=on(i.hour,2),l=on(i.minute,2),c=on(i.second,2);return`${s}-${o}-${u} ${a}:${l}:${c}`}default:throw new Error("Unknown timeframe.")}}function B8e(t,e){const n=lt.fromJSDate(t,{zone:e??"UTC"});return new Date(n.year,n.month-1,n.day,n.hour,n.minute,n.second,n.millisecond)}let m8;const $8e=100;async function $_(){const t=Date.now();if(!(m8&&t<m8+$8e))return m8=t,new Promise(e=>{setTimeout(e,0)})}function Es(t,e){const n=t.createElement("span");return n.classList.add("error"),n.appendChild(t.createTextNode(typeof e=="string"?e:e.message)),n}function Kg(t){const e=t.createElement("span");return e.appendChild(t.createTextNode("∅")),e.classList.add("value-null"),e}function jV(t){const e=t.createElement("div");return e.classList.add("drill-icon"),e.innerHTML=`
1297
1297
  <style>
1298
1298
  .drill-icon:hover .copy-circle {
1299
1299
  fill: #eef7f9;