@malloy-publisher/app 0.0.204 → 0.0.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-doc.yaml +133 -4
- package/dist/assets/{EnvironmentPage-CX06cjOF.js → EnvironmentPage-CAge6UHD.js} +1 -1
- package/dist/assets/HomePage-DhTe8qpa.js +1 -0
- package/dist/assets/{MainPage-nUJ9YatG.js → MainPage-CeTxxGex.js} +2 -2
- package/dist/assets/MaterializationsPage-CpDHB70t.js +1 -0
- package/dist/assets/ModelPage-D9sSMb75.js +1 -0
- package/dist/assets/{PackagePage-BaEVdEAG.js → PackagePage-LRqQWrFY.js} +1 -1
- package/dist/assets/{RouteError-BShQjZio.js → RouteError-xT6kuCNw.js} +1 -1
- package/dist/assets/{WorkbookPage-CBn6ZjJW.js → WorkbookPage-DsIh9svZ.js} +1 -1
- package/dist/assets/{core-DECXYL4E.es-OaRfXwuQ.js → core-C2sQrwVu.es-Bjem0hym.js} +1 -1
- package/dist/assets/{index-BLfPC1gy.js → index-BdOZDcce.js} +1 -1
- package/dist/assets/{index-Dy3YhAZQ.js → index-DHHAcY5o.js} +1 -1
- package/dist/assets/{index-DqiJ0bWp.js → index-RX3QOTde.js} +121 -121
- package/dist/assets/{index.umd-DAN9K8yC.js → index.umd-D2WH3D-f.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/assets/HomePage-CNFt_eUU.js +0 -1
- package/dist/assets/MaterializationsPage-B5goxVXW.js +0 -1
- package/dist/assets/ModelPage-Ba7Xh4lL.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ah as tH,ai as b9,r as F,j as N,aj as Er,R as T9,ak as R9,al as Bo}from"./index-DqiJ0bWp.js";import{r as w9,a as FA,d as Qt}from"./index-BLfPC1gy.js";import{a as yS}from"./index.umd-DAN9K8yC.js";var cu={},nv={},Yr={},iv={},BR;function Ct(){return BR||(BR=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TD=e.ValueType=void 0,e.safeRecordGet=n,e.mkSafeRecord=o,e.exprHasKids=u,e.exprHasE=i,e.exprIsLeaf=l,e.isAsymmetricExpr=c,e.mkTemporal=d,e.isRawCast=r,e.isFilterExprType=f,e.isTimeLiteral=x,e.isParameterType=p,e.paramHasValue=h,e.activeName=y,e.expressionIsScalar=E,e.expressionIsAggregate=g,e.expressionIsUngroupedAggregate=m,e.expressionInvolvesAggregate=v,e.expressionIsCalculation=_,e.expressionIsAnalytic=A,e.isExpressionTypeLEQ=S,e.maxExpressionType=T,e.maxOfExpressionTypes=D,e.hasExpression=w,e.isTemporalType=L,e.isBasicAtomicType=$,e.isAtomicFieldType=H,e.canOrderBy=W,e.fieldIsIntrinsic=ee,e.mkFieldDef=fe,e.mkArrayDef=Ee,e.mkArrayTypeDef=ge,e.isRepeatedRecordFunctionParam=V,e.isRepeatedRecord=ae,e.isRecordOrRepeatedRecord=te,e.isBasicArray=se,e.isMatrixOperation=G,e.isJoinable=Y,e.isJoined=z,e.isJoinedSource=q,e.isDateUnit=B,e.isTimestampUnit=j,e.isExtractUnit=Z,e.refIsStructDef=ie,e.segmentHasErrors=_e,e.structHasErrors=le,e.isReduceSegment=xe,e.isPartialSegment=Se,e.isProjectSegment=Te,e.isQuerySegment=me,e.isSamplingRows=Ie,e.isSamplingPercent=be,e.isSamplingEnable=we,e.isRawSegment=We,e.isIndexSegment=yt,e.bareFieldUsage=At,e.fieldUsageFrom=Re,e.givenUsageFrom=Ne,e.mkRefSummary=Ze,e.mapFieldUsage=et,e.setFieldUsage=he,e.isSegmentSQL=De,e.isSegmentSource=Ke,e.isSourceRegistryReference=Pe,e.sourceBase=st,e.isSourceDef=xt,e.isPersistableSourceDef=$e,e.isBaseTable=ct,e.isLiteral=Nt,e.mergeEvalSpaces=ve,e.isBasicAtomic=Ce,e.isUserTypeDef=Le,e.isCompoundArrayData=Qe,e.isTurtle=ne,e.isAtomic=Ye,e.isValueString=ot,e.isValueNumber=Tt,e.isValueBoolean=je,e.isValueTimestamp=It,e.isValueDate=dt,e.mergeUniqueKeyRequirement=St;const t=Object.prototype.hasOwnProperty;function n(ce,qe){return t.call(ce,qe)?ce[qe]:void 0}function o(){return Object.create(null)}function u(ce){return"kids"in ce}function i(ce){return"e"in ce}function l(ce){return!(u(ce)||i(ce))}function c(ce){return ce.node==="aggregate"&&["sum","avg","count","distinct"].includes(ce.function)}function a(ce){return ce.node!=="arrayLiteral"&&ce.node!=="recordLiteral"}function d(ce,qe){if(!("typeDef"in ce)){const Je=typeof qe=="string"?{type:qe}:qe;if(a(ce))return{...ce,typeDef:{...Je}}}return ce}function r(ce){return"dstSQLType"in ce}function f(ce){return["string","number","boolean","date","timestamp","timestamptz"].includes(ce)}function x(ce){return ce.node==="dateLiteral"||ce.node==="timestampLiteral"||ce.node==="timestamptzLiteral"}function p(ce){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(ce)}function h(ce){return ce.value!==null}function y(ce){var qe;return(qe=ce.as)!==null&&qe!==void 0?qe:ce.name}function E(ce){return ce===void 0||ce==="scalar"}function g(ce){return ce==="aggregate"||ce==="ungrouped_aggregate"}function m(ce){return ce==="ungrouped_aggregate"}function v(ce){return ce==="aggregate"||ce==="ungrouped_aggregate"||ce==="aggregate_analytic"}function _(ce){return ce==="aggregate"||ce==="scalar_analytic"||ce==="aggregate_analytic"||ce==="ungrouped_aggregate"}function A(ce){return ce==="aggregate_analytic"||ce==="scalar_analytic"}function R(ce){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[ce]}function S(ce,qe){return ce===qe||R(ce)<R(qe)}function T(ce,qe){let Je="scalar";return(ce==="aggregate"||qe==="aggregate")&&(Je="aggregate"),(ce==="ungrouped_aggregate"||qe==="ungrouped_aggregate")&&(Je="ungrouped_aggregate"),(ce==="scalar_analytic"||qe==="scalar_analytic")&&(Je="scalar_analytic"),(ce==="aggregate_analytic"||qe==="aggregate_analytic")&&(Je="aggregate_analytic"),(ce==="scalar_analytic"&&qe==="aggregate"||ce==="aggregate"&&qe==="scalar_analytic")&&(Je="aggregate_analytic"),Je}function D(ce){return ce.reduce(T,"scalar")}function w(ce){return"e"in ce&&ce.e!==void 0}function L(ce){return ce==="date"||ce==="timestamp"||ce==="timestamptz"}function $(ce){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(ce)}function H(ce){return $(ce)||ce==="record"||ce==="array"}function W(ce){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(ce)}function ee(ce){return H(ce.type)&&!w(ce)}function fe(ce,qe){if(se(ce))return Ee(ce.elementTypeDef,qe);if(ae(ce)){const{type:at,fields:Ge,elementTypeDef:kt}=ce;return{type:at,fields:Ge,elementTypeDef:kt,join:"many",name:qe}}if(ce.type==="record"){const{type:at,fields:Ge}=ce;return{type:at,fields:Ge,join:"one",name:qe}}const Je={name:qe,type:ce.type};switch(ce.type){case"sql native":return{...Je,rawType:ce.rawType};case"number":{const at=ce.numberType;return at?{...Je,numberType:at}:Je}case"date":{const at=ce.timeframe;return at?{name:qe,type:"date",timeframe:at}:Je}case"timestamp":{const at={name:qe,type:"timestamp"};return ce.timeframe&&(at.timeframe=ce.timeframe),at}case"timestamptz":{const at={name:qe,type:"timestamptz"};return ce.timeframe&&(at.timeframe=ce.timeframe),at}}return Je}function Ee(ce,qe){if(ce.type==="record")return{type:"array",join:"many",name:qe,elementTypeDef:{type:"record_element"},fields:ce.fields};const Je=fe(ce,"value");return{type:"array",join:"many",name:qe,elementTypeDef:ce,fields:[Je,{...Je,name:"each",e:{node:"field",path:["value"]}}]}}function ge(ce){return ce.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ce.fields}:{type:"array",elementTypeDef:ce}}function V(ce){return ce.type==="array"&&ce.elementTypeDef.type==="record_element"}function ae(ce){return ce.type==="array"&&ce.elementTypeDef.type==="record_element"}function te(ce){return ce.type==="record"||ce.type==="array"&&"elementTypeDef"in ce&&ce.elementTypeDef.type==="record_element"}function se(ce){return ce.type==="array"&&ce.elementTypeDef.type!=="record_element"}function G(ce){return["left","right","full","inner"].includes(ce)}function Y(ce){return["composite","table","sql_select","query_source","virtual","array","record"].includes(ce.type)}function z(ce){return"join"in ce}function q(ce){return xt(ce)&&z(ce)}function B(ce){return["day","week","month","quarter","year"].includes(ce)}function j(ce){return B(ce)||["hour","minute","second"].includes(ce)}function Z(ce){return j(ce)||ce==="day_of_week"||ce==="day_of_year"}var re;(function(ce){ce.Date="date",ce.Timestamp="timestamp",ce.Number="number",ce.String="string"})(re||(e.ValueType=re={}));function ie(ce){return typeof ce!="string"}function _e(ce){return!!((ce.type==="reduce"||ce.type==="project"||ce.type==="partial")&&(ce.extendSource&&ce.extendSource.some(qe=>qe.type==="error")||ce.queryFields.some(qe=>qe.type==="error")))}function le(ce){return ce.fields.some(qe=>qe.type==="error")}function xe(ce){return ce.type==="reduce"}function Se(ce){return ce.type==="partial"}function Te(ce){return ce.type==="project"}function me(ce){return Te(ce)||xe(ce)}function Ie(ce){return ce.rows!==void 0}function be(ce){return ce.percent!==void 0}function we(ce){return ce.enable!==void 0}function We(ce){return ce.type==="raw"}function yt(ce){return ce.type==="index"}function At(ce){return ce.uniqueKeyRequirement===void 0&&ce.analyticFunctionUse===void 0}function Re(ce){var qe;return(qe=ce?.fieldUsage)!==null&&qe!==void 0?qe:[]}function Ne(ce){var qe;return(qe=ce?.givenUsage)!==null&&qe!==void 0?qe:[]}function Ze({fieldUsage:ce,givenUsage:qe}){if(!(ce===void 0&&qe===void 0))return{fieldUsage:ce??[],...qe&&{givenUsage:qe}}}function et(ce,qe){return ce&&{...ce,fieldUsage:ce.fieldUsage.map(qe)}}function he(ce,qe){ce.refSummary?ce.refSummary.fieldUsage=qe:ce.refSummary={fieldUsage:qe}}function De(ce){return"sql"in ce}function Ke(ce){return"type"in ce&&(ce.type==="sql_select"||ce.type==="query_source")}function Pe(ce){return ce.type==="source_registry_reference"}function st(ce){return{...ce}}function xt(ce){return ce.type==="table"||ce.type==="sql_select"||ce.type==="query_source"||ce.type==="query_result"||ce.type==="finalize"||ce.type==="nest_source"||ce.type==="virtual"||ce.type==="composite"}function $e(ce){return ce.type==="sql_select"||ce.type==="query_source"}function ct(ce){return q(ce)?!1:!!xt(ce)}function Nt(ce){return ce==="literal"}function ve(...ce){return ce.length<=1&&ce.every(qe=>qe==="literal")?"literal":ce.every(qe=>qe==="constant"||qe==="literal")?"constant":ce.every(qe=>qe==="output"||qe==="constant"||qe==="literal")?"output":"input"}function Ce(ce){return ce.type==="string"||L(ce.type)||ce.type==="number"||ce.type==="boolean"||ce.type==="json"||ce.type==="sql native"||ce.type==="error"}function Le(ce){return ce.type==="userType"}function Qe(ce){return Array.isArray(ce)&&(ce.length===0||typeof ce[0]=="object"&&ce[0]!==null&&!Array.isArray(ce[0]))}function ne(ce){return ce.type==="turtle"}function Ye(ce){return H(ce.type)}function ot(ce,qe){return qe.type==="string"}function Tt(ce,qe){return qe.type==="number"}function je(ce,qe){return qe.type==="boolean"}function It(ce,qe){return qe.type==="timestamp"}function dt(ce,qe){return qe.type==="date"}e.TD={isAtomic(ce){return ce!==void 0&&H(ce.type)},isBasicAtomic(ce){return ce!==void 0&&Ce({type:ce.type})},isString:ce=>ce?.type==="string",isNumber:ce=>ce?.type==="number",isBoolean:ce=>ce?.type==="boolean",isJSON:ce=>ce?.type==="json",isSQL:ce=>ce?.type==="sql native",isDate:ce=>ce?.type==="date",isTimestamp:ce=>ce?.type==="timestamp",isTimestamptz:ce=>ce?.type==="timestamptz",isAnyTimestamp(ce){return ce?.type==="timestamp"||ce?.type==="timestamptz"},isTemporal(ce){var qe;const Je=(qe=ce?.type)!==null&&qe!==void 0?qe:"";return L(Je)},isError:ce=>ce?.type==="error",atomicDef(ce){if(!e.TD.isAtomic(ce))return{type:"error"};switch(ce.type){case"array":return ae(ce)?{type:"array",elementTypeDef:ce.elementTypeDef,fields:ce.fields}:{type:"array",elementTypeDef:ce.elementTypeDef};case"record":return{type:"record",fields:ce.fields};case"number":return ce.numberType?{type:"number",numberType:ce.numberType}:{type:"number"};case"sql native":return ce.rawType?{type:"sql native",rawType:ce.rawType}:{type:"sql native"};case"timestamp":case"timestamptz":return ce.timeframe?{type:ce.type,timeframe:ce.timeframe}:{type:ce.type};default:return{type:ce.type}}},eq(ce,qe){if(ce===void 0||qe===void 0)return!1;function Je(at,Ge){const kt={},Ot=at.fields||[],Pt=Ge.fields||[];if(Ot.length!==Pt.length)return!1;for(const Jt of Ot)if(Jt.name)kt[Jt.name]=Jt;else return!1;for(const Jt of Pt)if(!e.TD.eq(kt[Jt.name],Jt))return!1;return!0}return ce.type==="array"&&qe.type==="array"?ce.elementTypeDef.type!==qe.elementTypeDef.type?!1:ce.elementTypeDef.type!=="record_element"&&qe.elementTypeDef.type!=="record_element"?e.TD.eq(ce.elementTypeDef,qe.elementTypeDef):e.TD.isAtomic(ce)&&e.TD.isAtomic(qe)&&Je(ce,qe):ce.type==="record"&&qe.type==="record"?e.TD.isAtomic(ce)&&e.TD.isAtomic(qe)&&Je(ce,qe):ce.type==="sql native"&&qe.type==="sql native"?ce.rawType!==void 0&&ce.rawType===qe.rawType:ce.type===qe.type}};function St(ce,qe){return ce?qe?{isCount:ce.isCount||qe.isCount}:ce:qe}})(iv)),iv}var $R;function Go(){if($R)return Yr;$R=1,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.arg=t,Yr.spread=n,Yr.sql=o,Yr.constant=u,Yr.output=i,Yr.literal=l,Yr.variadicParam=c,Yr.param=a,Yr.makeParam=d,Yr.maxScalar=r,Yr.maxAggregate=f,Yr.anyExprType=x,Yr.maxUngroupedAggregate=p,Yr.maxAnalytic=h,Yr.minScalar=y,Yr.minAggregate=E,Yr.minAnalytic=g,Yr.overload=m,Yr.expandBlueprintMap=se,Yr.expandOverrideMapFromBase=z,Yr.def=B;const e=Ct();function t(j){return{node:"function_parameter",name:j}}function n(j,Z=void 0,re=void 0){return{node:"spread",e:j,prefix:Z,suffix:re}}function o(j,...Z){const re={node:"genericSQLExpr",kids:{args:[]},src:[]},ie=[...Z];let _e="";for(const le of j){_e+=le;const xe=ie.shift();xe!==void 0&&(typeof xe=="string"?_e+=xe:(re.src.push(_e),re.kids.args.push(xe),_e=""))}return _e.length>0&&re.src.push(_e),re}function u(j){return{...j,evalSpace:"constant"}}function i(j){return{...j,evalSpace:"output"}}function l(j){return{...j,evalSpace:"literal"}}function c(j,...Z){return{name:j,isVariadic:!0,allowedTypes:Z}}function a(j,...Z){return{name:j,isVariadic:!1,allowedTypes:Z}}function d(j,...Z){return{param:a(j,...Z),arg:t(j)}}function r(j){return{...j,expressionType:"scalar",evalSpace:"input"}}function f(j){return{...j,expressionType:"aggregate",evalSpace:"input"}}function x(j){return{...j,expressionType:void 0,evalSpace:"input"}}function p(j){return{...j,expressionType:"ungrouped_aggregate",evalSpace:"input"}}function h(j){return{...j,expressionType:"aggregate_analytic",evalSpace:"input"}}function y(j){return{...j,expressionType:"scalar",evalSpace:"input"}}function E(j){return{...j,expressionType:"aggregate",evalSpace:"input"}}function g(j){return{...j,expressionType:"scalar_analytic",evalSpace:"input"}}function m(j,Z,re,ie){return{returnType:j,params:Z,e:re,needsWindowOrderBy:ie?.needsWindowOrderBy,between:ie?.between,isSymmetric:ie?.isSymmetric,supportsOrderBy:ie?.supportsOrderBy,defaultOrderByArgIndex:ie?.defaultOrderByArgIndex,supportsLimit:ie?.supportsLimit}}function v(j,Z=!0,re=!0){if(!Z&&j==="any")throw new Error("Return type cannot include any");if(typeof j=="string")return{type:j};if("array"in j){const ie=Z?v(j.array,!0):v(j.array,!1);return ie.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ie.fields}:{type:"array",elementTypeDef:ie}}else if("record"in j){const ie=[];for(const[_e,le]of Object.entries(j.record)){const xe=Z?v(le,!0):v(le,!1);e.TD.isAtomic(xe)&&ie.push((0,e.mkFieldDef)(xe,_e))}return{type:"record",fields:ie}}else if("generic"in j){if(!re)throw new Error("Cannot use generic");return{type:"generic",generic:j.generic}}else if("sql_native"in j)return{type:"sql native",rawType:j.sql_native};throw new Error("Cannot figure out type")}function _(j){if(j==="any")throw new Error("Cannot return any type");if(typeof j=="string")return y({type:j});if("array"in j)return x(v(j,!1));if("record"in j)return x(v(j,!1));if("generic"in j)return y(v(j,!1));if("literal"in j)return l(y(v(j.literal,!1)));if("constant"in j)return u(y(v(j.constant,!1)));if("dimension"in j)return y(v(j.dimension,!1));if("measure"in j)return E(v(j.measure,!1));if("sql_native"in j)return x({type:"sql native",rawType:j.sql_native});if("calculation"in j)return g(v(j.calculation,!1));throw new Error("Invalid function blueprint")}function A(j){return typeof j=="string"||"array"in j||"record"in j||"generic"in j||"literal"in j||"constant"in j||"dimension"in j||"measure"in j||"calculation"in j||"sql_native"in j}function R(j){return A(j)?[j]:Array.isArray(j)?j:A(j.variadic)?[j.variadic]:j.variadic}function S(j){if(typeof j=="string")return x({type:j});if("generic"in j)return x(v(j));if("literal"in j)return l(r(v(j.literal)));if("constant"in j)return u(r(v(j.constant)));if("dimension"in j)return r(v(j.dimension));if("measure"in j)return f(v(j.measure));if("array"in j)return x(v(j,!1));if("record"in j)return x(v(j,!1));if("sql_native"in j)return x({type:"sql native",rawType:j.sql_native});if("calculation"in j)return h(v(j.calculation));throw new Error("Invalid function blueprint")}function T(j){return j.map(Z=>S(Z))}function D(j){return typeof j!="string"&&"variadic"in j}function w(j,Z){return{name:j,allowedTypes:T(R(Z)),isVariadic:D(Z)}}function L(j){return Object.entries(j).map(re=>w(re[0],re[1]))}function $(j){const Z=[],re=[];let ie=j;for(;ie.length>0;){const le=ie.indexOf("${");if(le===-1){Z.push(ie);break}const xe=ie.slice(0,le);ie=ie.slice(le);const Se=ie.indexOf("}");if(Se===-1){Z.push(xe+ie);break}const Te=ie.slice(2,Se);ie=ie.slice(Se+1);const me=Te.startsWith("..."),Ie=Te.endsWith(":"),be=me?Te.slice(3):Ie?Te.slice(0,-1):Te,we={node:"function_parameter",name:be};Z.push(xe),me?re.push({node:"spread",e:we,prefix:"",suffix:""}):Ie&&be==="order_by"?re.push({node:"aggregate_order_by"}):Ie&&be==="limit"?re.push({node:"aggregate_limit"}):re.push(we)}return{node:"genericSQLExpr",kids:{args:re},src:Z}}function H(j,Z){return D(Z)?{node:"spread",e:{node:"function_parameter",name:j},prefix:"",suffix:""}:{node:"function_parameter",name:j}}function W(j,Z){const re=Object.entries(Z.takes),ie=re.length>0?re.length-1:0;return{node:"genericSQLExpr",kids:{args:re.map(_e=>H(_e[0],_e[1]))},src:[`${j}(`,...Array(ie).fill(","),")"]}}function ee(j){return"sql"in j.impl?$(j.impl.sql):"expr"in j.impl?j.impl.expr:W(j.impl.function,j)}function fe(j){return{e:ee(j),between:j.impl.between,needsWindowOrderBy:j.impl.needsWindowOrderBy,defaultOrderByArgIndex:j.impl.defaultOrderByArgIndex}}function Ee(j){if(j!==void 0)return Object.entries(j).map(([Z,re])=>({name:Z,acceptibleTypes:re.map(ie=>v(ie,!0,!1))}))}function ge(j){return{returnType:_(j.returns),params:L(j.takes),isSymmetric:j.isSymmetric,supportsOrderBy:j.supportsOrderBy,supportsLimit:j.supportsLimit,genericTypes:Ee(j.generic),...fe(j)}}function V(j){return"takes"in j&&"returns"in j&&"impl"in j}function ae(j){return"function"in j||"sql"in j||"expr"in j}function te(j){return V(j)?[ge(j)]:Object.values(j).flatMap(Z=>ge(Z))}function se(j){const Z={};for(const re in j)Z[re]=te(j[re]);return Z}function G(j,Z){return[ge({...j,impl:Z})]}function Y(j,Z,re){if(ae(re)){if(!V(Z))throw new Error(`Malformed function override: ${j}. Attempt to override multiple overloads with a single overload (missing: ${Object.keys(Z)})`);return G(Z,re)}else{if(V(Z))throw new Error(`Malformed function override: ${j}. Attempt to override a single overload with multiple overloads (extraneous: ${Object.keys(re)})`);return Object.entries(re).flatMap(([ie,_e])=>{const le=Z[ie];if(le===void 0)throw new Error(`Malformed function override: ${j}. No overload named ${ie}`);return G(le,_e)})}}function z(j,Z){const re={};for(const ie in Z){if(!(ie in j))throw new Error(`Malformed function override: ${ie}. No such function in Malloy standard`);re[ie]=Y(ie,j[ie],Z[ie])}return re}function*q(j){if(typeof j!="string"){if("generic"in j)yield j;else if("record"in j)for(const Z of Object.values(j.record))yield*q(Z);else for(const Z of["array","literal","measure","dimension","measure","constant","cacluation"])if(Z in j){yield*q(j[Z]);return}}}function B(j,Z,re,ie={}){let _e=!1;const le={};for(const Se of Object.values(Z))for(const Te of q(Se))le[Te.generic]=["any"],_e=!0;_e&&ie.generic===void 0&&(ie.generic=le);const xe={takes:Z,returns:re,impl:{function:j.toUpperCase()},...ie};return{[j]:xe}}return Yr}var sv={},dh={},qR;function IA(){if(qR)return dh;qR=1,Object.defineProperty(dh,"__esModule",{value:!0}),dh.decodeDottedTablePath=e,dh.validateDottedTablePath=t;function e(u,i){const{quoteChar:l,escapeStyle:c,bareIdentRegex:a,dialectName:d}=i;if(u.length===0)return{ok:!1,error:`${d} table path is empty`};const r=[];let f=0;for(;;){let x,p;if(u[f]===l){const h=n(u,f,l,c);if(h===null)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(u)} — unterminated quoted segment`};x=h.decoded,p=!0,f=h.end}else{const h=u.slice(f).match(a);if(!h||h.index!==0||h[0].length===0)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(u)} — invalid segment at position ${f}`};x=h[0],p=!1,f+=h[0].length}if(x.includes(";")||x.includes("--"))return{ok:!1,error:`Invalid ${d} table path: segment ${JSON.stringify(x)} contains forbidden character; even when quoted, table-path segments may not contain \`;\` or \`--\`.`};if(r.push({value:x,quoted:p}),f===u.length)return{ok:!0,segments:r};if(u[f]!==".")return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(u)} — expected '.' at position ${f}`};if(f++,f===u.length)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(u)} — trailing dot`}}}function t(u,i){const l=e(u,i);return l.ok?{ok:!0,canonical:u}:l}function n(u,i,l,c){let a=i+1,d="";for(;a<u.length;){if(c==="backslash"&&u[a]==="\\"){if(a+1>=u.length)return null;d+=o(u[a+1]),a+=2;continue}if(u[a]===l){if(c==="doubled"&&u[a+1]===l){d+=l,a+=2;continue}return{decoded:d,end:a+1}}d+=u[a],a++}return null}function o(u){switch(u){case"n":return`
|
|
1
|
+
import{ai as tH,aj as b9,r as F,j as N,ak as Er,R as T9,al as R9,am as Bo}from"./index-RX3QOTde.js";import{r as w9,a as FA,d as Qt}from"./index-BdOZDcce.js";import{a as yS}from"./index.umd-D2WH3D-f.js";var cu={},nv={},Yr={},iv={},BR;function Ct(){return BR||(BR=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TD=e.ValueType=void 0,e.safeRecordGet=n,e.mkSafeRecord=o,e.exprHasKids=u,e.exprHasE=i,e.exprIsLeaf=l,e.isAsymmetricExpr=c,e.mkTemporal=d,e.isRawCast=r,e.isFilterExprType=f,e.isTimeLiteral=x,e.isParameterType=p,e.paramHasValue=h,e.activeName=y,e.expressionIsScalar=E,e.expressionIsAggregate=g,e.expressionIsUngroupedAggregate=m,e.expressionInvolvesAggregate=v,e.expressionIsCalculation=_,e.expressionIsAnalytic=A,e.isExpressionTypeLEQ=S,e.maxExpressionType=T,e.maxOfExpressionTypes=D,e.hasExpression=w,e.isTemporalType=L,e.isBasicAtomicType=$,e.isAtomicFieldType=H,e.canOrderBy=W,e.fieldIsIntrinsic=ee,e.mkFieldDef=fe,e.mkArrayDef=Ee,e.mkArrayTypeDef=ge,e.isRepeatedRecordFunctionParam=V,e.isRepeatedRecord=ae,e.isRecordOrRepeatedRecord=te,e.isBasicArray=se,e.isMatrixOperation=G,e.isJoinable=Y,e.isJoined=z,e.isJoinedSource=q,e.isDateUnit=B,e.isTimestampUnit=j,e.isExtractUnit=Z,e.refIsStructDef=ie,e.segmentHasErrors=_e,e.structHasErrors=le,e.isReduceSegment=xe,e.isPartialSegment=Se,e.isProjectSegment=Te,e.isQuerySegment=me,e.isSamplingRows=Ie,e.isSamplingPercent=be,e.isSamplingEnable=we,e.isRawSegment=We,e.isIndexSegment=yt,e.bareFieldUsage=At,e.fieldUsageFrom=Re,e.givenUsageFrom=Ne,e.mkRefSummary=Ze,e.mapFieldUsage=et,e.setFieldUsage=he,e.isSegmentSQL=De,e.isSegmentSource=Ke,e.isSourceRegistryReference=Pe,e.sourceBase=st,e.isSourceDef=xt,e.isPersistableSourceDef=$e,e.isBaseTable=ct,e.isLiteral=Nt,e.mergeEvalSpaces=ve,e.isBasicAtomic=Ce,e.isUserTypeDef=Le,e.isCompoundArrayData=Qe,e.isTurtle=ne,e.isAtomic=Ye,e.isValueString=ot,e.isValueNumber=Tt,e.isValueBoolean=je,e.isValueTimestamp=It,e.isValueDate=dt,e.mergeUniqueKeyRequirement=St;const t=Object.prototype.hasOwnProperty;function n(ce,qe){return t.call(ce,qe)?ce[qe]:void 0}function o(){return Object.create(null)}function u(ce){return"kids"in ce}function i(ce){return"e"in ce}function l(ce){return!(u(ce)||i(ce))}function c(ce){return ce.node==="aggregate"&&["sum","avg","count","distinct"].includes(ce.function)}function a(ce){return ce.node!=="arrayLiteral"&&ce.node!=="recordLiteral"}function d(ce,qe){if(!("typeDef"in ce)){const Je=typeof qe=="string"?{type:qe}:qe;if(a(ce))return{...ce,typeDef:{...Je}}}return ce}function r(ce){return"dstSQLType"in ce}function f(ce){return["string","number","boolean","date","timestamp","timestamptz"].includes(ce)}function x(ce){return ce.node==="dateLiteral"||ce.node==="timestampLiteral"||ce.node==="timestamptzLiteral"}function p(ce){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(ce)}function h(ce){return ce.value!==null}function y(ce){var qe;return(qe=ce.as)!==null&&qe!==void 0?qe:ce.name}function E(ce){return ce===void 0||ce==="scalar"}function g(ce){return ce==="aggregate"||ce==="ungrouped_aggregate"}function m(ce){return ce==="ungrouped_aggregate"}function v(ce){return ce==="aggregate"||ce==="ungrouped_aggregate"||ce==="aggregate_analytic"}function _(ce){return ce==="aggregate"||ce==="scalar_analytic"||ce==="aggregate_analytic"||ce==="ungrouped_aggregate"}function A(ce){return ce==="aggregate_analytic"||ce==="scalar_analytic"}function R(ce){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[ce]}function S(ce,qe){return ce===qe||R(ce)<R(qe)}function T(ce,qe){let Je="scalar";return(ce==="aggregate"||qe==="aggregate")&&(Je="aggregate"),(ce==="ungrouped_aggregate"||qe==="ungrouped_aggregate")&&(Je="ungrouped_aggregate"),(ce==="scalar_analytic"||qe==="scalar_analytic")&&(Je="scalar_analytic"),(ce==="aggregate_analytic"||qe==="aggregate_analytic")&&(Je="aggregate_analytic"),(ce==="scalar_analytic"&&qe==="aggregate"||ce==="aggregate"&&qe==="scalar_analytic")&&(Je="aggregate_analytic"),Je}function D(ce){return ce.reduce(T,"scalar")}function w(ce){return"e"in ce&&ce.e!==void 0}function L(ce){return ce==="date"||ce==="timestamp"||ce==="timestamptz"}function $(ce){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(ce)}function H(ce){return $(ce)||ce==="record"||ce==="array"}function W(ce){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(ce)}function ee(ce){return H(ce.type)&&!w(ce)}function fe(ce,qe){if(se(ce))return Ee(ce.elementTypeDef,qe);if(ae(ce)){const{type:at,fields:Ge,elementTypeDef:kt}=ce;return{type:at,fields:Ge,elementTypeDef:kt,join:"many",name:qe}}if(ce.type==="record"){const{type:at,fields:Ge}=ce;return{type:at,fields:Ge,join:"one",name:qe}}const Je={name:qe,type:ce.type};switch(ce.type){case"sql native":return{...Je,rawType:ce.rawType};case"number":{const at=ce.numberType;return at?{...Je,numberType:at}:Je}case"date":{const at=ce.timeframe;return at?{name:qe,type:"date",timeframe:at}:Je}case"timestamp":{const at={name:qe,type:"timestamp"};return ce.timeframe&&(at.timeframe=ce.timeframe),at}case"timestamptz":{const at={name:qe,type:"timestamptz"};return ce.timeframe&&(at.timeframe=ce.timeframe),at}}return Je}function Ee(ce,qe){if(ce.type==="record")return{type:"array",join:"many",name:qe,elementTypeDef:{type:"record_element"},fields:ce.fields};const Je=fe(ce,"value");return{type:"array",join:"many",name:qe,elementTypeDef:ce,fields:[Je,{...Je,name:"each",e:{node:"field",path:["value"]}}]}}function ge(ce){return ce.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ce.fields}:{type:"array",elementTypeDef:ce}}function V(ce){return ce.type==="array"&&ce.elementTypeDef.type==="record_element"}function ae(ce){return ce.type==="array"&&ce.elementTypeDef.type==="record_element"}function te(ce){return ce.type==="record"||ce.type==="array"&&"elementTypeDef"in ce&&ce.elementTypeDef.type==="record_element"}function se(ce){return ce.type==="array"&&ce.elementTypeDef.type!=="record_element"}function G(ce){return["left","right","full","inner"].includes(ce)}function Y(ce){return["composite","table","sql_select","query_source","virtual","array","record"].includes(ce.type)}function z(ce){return"join"in ce}function q(ce){return xt(ce)&&z(ce)}function B(ce){return["day","week","month","quarter","year"].includes(ce)}function j(ce){return B(ce)||["hour","minute","second"].includes(ce)}function Z(ce){return j(ce)||ce==="day_of_week"||ce==="day_of_year"}var re;(function(ce){ce.Date="date",ce.Timestamp="timestamp",ce.Number="number",ce.String="string"})(re||(e.ValueType=re={}));function ie(ce){return typeof ce!="string"}function _e(ce){return!!((ce.type==="reduce"||ce.type==="project"||ce.type==="partial")&&(ce.extendSource&&ce.extendSource.some(qe=>qe.type==="error")||ce.queryFields.some(qe=>qe.type==="error")))}function le(ce){return ce.fields.some(qe=>qe.type==="error")}function xe(ce){return ce.type==="reduce"}function Se(ce){return ce.type==="partial"}function Te(ce){return ce.type==="project"}function me(ce){return Te(ce)||xe(ce)}function Ie(ce){return ce.rows!==void 0}function be(ce){return ce.percent!==void 0}function we(ce){return ce.enable!==void 0}function We(ce){return ce.type==="raw"}function yt(ce){return ce.type==="index"}function At(ce){return ce.uniqueKeyRequirement===void 0&&ce.analyticFunctionUse===void 0}function Re(ce){var qe;return(qe=ce?.fieldUsage)!==null&&qe!==void 0?qe:[]}function Ne(ce){var qe;return(qe=ce?.givenUsage)!==null&&qe!==void 0?qe:[]}function Ze({fieldUsage:ce,givenUsage:qe}){if(!(ce===void 0&&qe===void 0))return{fieldUsage:ce??[],...qe&&{givenUsage:qe}}}function et(ce,qe){return ce&&{...ce,fieldUsage:ce.fieldUsage.map(qe)}}function he(ce,qe){ce.refSummary?ce.refSummary.fieldUsage=qe:ce.refSummary={fieldUsage:qe}}function De(ce){return"sql"in ce}function Ke(ce){return"type"in ce&&(ce.type==="sql_select"||ce.type==="query_source")}function Pe(ce){return ce.type==="source_registry_reference"}function st(ce){return{...ce}}function xt(ce){return ce.type==="table"||ce.type==="sql_select"||ce.type==="query_source"||ce.type==="query_result"||ce.type==="finalize"||ce.type==="nest_source"||ce.type==="virtual"||ce.type==="composite"}function $e(ce){return ce.type==="sql_select"||ce.type==="query_source"}function ct(ce){return q(ce)?!1:!!xt(ce)}function Nt(ce){return ce==="literal"}function ve(...ce){return ce.length<=1&&ce.every(qe=>qe==="literal")?"literal":ce.every(qe=>qe==="constant"||qe==="literal")?"constant":ce.every(qe=>qe==="output"||qe==="constant"||qe==="literal")?"output":"input"}function Ce(ce){return ce.type==="string"||L(ce.type)||ce.type==="number"||ce.type==="boolean"||ce.type==="json"||ce.type==="sql native"||ce.type==="error"}function Le(ce){return ce.type==="userType"}function Qe(ce){return Array.isArray(ce)&&(ce.length===0||typeof ce[0]=="object"&&ce[0]!==null&&!Array.isArray(ce[0]))}function ne(ce){return ce.type==="turtle"}function Ye(ce){return H(ce.type)}function ot(ce,qe){return qe.type==="string"}function Tt(ce,qe){return qe.type==="number"}function je(ce,qe){return qe.type==="boolean"}function It(ce,qe){return qe.type==="timestamp"}function dt(ce,qe){return qe.type==="date"}e.TD={isAtomic(ce){return ce!==void 0&&H(ce.type)},isBasicAtomic(ce){return ce!==void 0&&Ce({type:ce.type})},isString:ce=>ce?.type==="string",isNumber:ce=>ce?.type==="number",isBoolean:ce=>ce?.type==="boolean",isJSON:ce=>ce?.type==="json",isSQL:ce=>ce?.type==="sql native",isDate:ce=>ce?.type==="date",isTimestamp:ce=>ce?.type==="timestamp",isTimestamptz:ce=>ce?.type==="timestamptz",isAnyTimestamp(ce){return ce?.type==="timestamp"||ce?.type==="timestamptz"},isTemporal(ce){var qe;const Je=(qe=ce?.type)!==null&&qe!==void 0?qe:"";return L(Je)},isError:ce=>ce?.type==="error",atomicDef(ce){if(!e.TD.isAtomic(ce))return{type:"error"};switch(ce.type){case"array":return ae(ce)?{type:"array",elementTypeDef:ce.elementTypeDef,fields:ce.fields}:{type:"array",elementTypeDef:ce.elementTypeDef};case"record":return{type:"record",fields:ce.fields};case"number":return ce.numberType?{type:"number",numberType:ce.numberType}:{type:"number"};case"sql native":return ce.rawType?{type:"sql native",rawType:ce.rawType}:{type:"sql native"};case"timestamp":case"timestamptz":return ce.timeframe?{type:ce.type,timeframe:ce.timeframe}:{type:ce.type};default:return{type:ce.type}}},eq(ce,qe){if(ce===void 0||qe===void 0)return!1;function Je(at,Ge){const kt={},Ot=at.fields||[],Pt=Ge.fields||[];if(Ot.length!==Pt.length)return!1;for(const Jt of Ot)if(Jt.name)kt[Jt.name]=Jt;else return!1;for(const Jt of Pt)if(!e.TD.eq(kt[Jt.name],Jt))return!1;return!0}return ce.type==="array"&&qe.type==="array"?ce.elementTypeDef.type!==qe.elementTypeDef.type?!1:ce.elementTypeDef.type!=="record_element"&&qe.elementTypeDef.type!=="record_element"?e.TD.eq(ce.elementTypeDef,qe.elementTypeDef):e.TD.isAtomic(ce)&&e.TD.isAtomic(qe)&&Je(ce,qe):ce.type==="record"&&qe.type==="record"?e.TD.isAtomic(ce)&&e.TD.isAtomic(qe)&&Je(ce,qe):ce.type==="sql native"&&qe.type==="sql native"?ce.rawType!==void 0&&ce.rawType===qe.rawType:ce.type===qe.type}};function St(ce,qe){return ce?qe?{isCount:ce.isCount||qe.isCount}:ce:qe}})(iv)),iv}var $R;function Go(){if($R)return Yr;$R=1,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.arg=t,Yr.spread=n,Yr.sql=o,Yr.constant=u,Yr.output=i,Yr.literal=l,Yr.variadicParam=c,Yr.param=a,Yr.makeParam=d,Yr.maxScalar=r,Yr.maxAggregate=f,Yr.anyExprType=x,Yr.maxUngroupedAggregate=p,Yr.maxAnalytic=h,Yr.minScalar=y,Yr.minAggregate=E,Yr.minAnalytic=g,Yr.overload=m,Yr.expandBlueprintMap=se,Yr.expandOverrideMapFromBase=z,Yr.def=B;const e=Ct();function t(j){return{node:"function_parameter",name:j}}function n(j,Z=void 0,re=void 0){return{node:"spread",e:j,prefix:Z,suffix:re}}function o(j,...Z){const re={node:"genericSQLExpr",kids:{args:[]},src:[]},ie=[...Z];let _e="";for(const le of j){_e+=le;const xe=ie.shift();xe!==void 0&&(typeof xe=="string"?_e+=xe:(re.src.push(_e),re.kids.args.push(xe),_e=""))}return _e.length>0&&re.src.push(_e),re}function u(j){return{...j,evalSpace:"constant"}}function i(j){return{...j,evalSpace:"output"}}function l(j){return{...j,evalSpace:"literal"}}function c(j,...Z){return{name:j,isVariadic:!0,allowedTypes:Z}}function a(j,...Z){return{name:j,isVariadic:!1,allowedTypes:Z}}function d(j,...Z){return{param:a(j,...Z),arg:t(j)}}function r(j){return{...j,expressionType:"scalar",evalSpace:"input"}}function f(j){return{...j,expressionType:"aggregate",evalSpace:"input"}}function x(j){return{...j,expressionType:void 0,evalSpace:"input"}}function p(j){return{...j,expressionType:"ungrouped_aggregate",evalSpace:"input"}}function h(j){return{...j,expressionType:"aggregate_analytic",evalSpace:"input"}}function y(j){return{...j,expressionType:"scalar",evalSpace:"input"}}function E(j){return{...j,expressionType:"aggregate",evalSpace:"input"}}function g(j){return{...j,expressionType:"scalar_analytic",evalSpace:"input"}}function m(j,Z,re,ie){return{returnType:j,params:Z,e:re,needsWindowOrderBy:ie?.needsWindowOrderBy,between:ie?.between,isSymmetric:ie?.isSymmetric,supportsOrderBy:ie?.supportsOrderBy,defaultOrderByArgIndex:ie?.defaultOrderByArgIndex,supportsLimit:ie?.supportsLimit}}function v(j,Z=!0,re=!0){if(!Z&&j==="any")throw new Error("Return type cannot include any");if(typeof j=="string")return{type:j};if("array"in j){const ie=Z?v(j.array,!0):v(j.array,!1);return ie.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ie.fields}:{type:"array",elementTypeDef:ie}}else if("record"in j){const ie=[];for(const[_e,le]of Object.entries(j.record)){const xe=Z?v(le,!0):v(le,!1);e.TD.isAtomic(xe)&&ie.push((0,e.mkFieldDef)(xe,_e))}return{type:"record",fields:ie}}else if("generic"in j){if(!re)throw new Error("Cannot use generic");return{type:"generic",generic:j.generic}}else if("sql_native"in j)return{type:"sql native",rawType:j.sql_native};throw new Error("Cannot figure out type")}function _(j){if(j==="any")throw new Error("Cannot return any type");if(typeof j=="string")return y({type:j});if("array"in j)return x(v(j,!1));if("record"in j)return x(v(j,!1));if("generic"in j)return y(v(j,!1));if("literal"in j)return l(y(v(j.literal,!1)));if("constant"in j)return u(y(v(j.constant,!1)));if("dimension"in j)return y(v(j.dimension,!1));if("measure"in j)return E(v(j.measure,!1));if("sql_native"in j)return x({type:"sql native",rawType:j.sql_native});if("calculation"in j)return g(v(j.calculation,!1));throw new Error("Invalid function blueprint")}function A(j){return typeof j=="string"||"array"in j||"record"in j||"generic"in j||"literal"in j||"constant"in j||"dimension"in j||"measure"in j||"calculation"in j||"sql_native"in j}function R(j){return A(j)?[j]:Array.isArray(j)?j:A(j.variadic)?[j.variadic]:j.variadic}function S(j){if(typeof j=="string")return x({type:j});if("generic"in j)return x(v(j));if("literal"in j)return l(r(v(j.literal)));if("constant"in j)return u(r(v(j.constant)));if("dimension"in j)return r(v(j.dimension));if("measure"in j)return f(v(j.measure));if("array"in j)return x(v(j,!1));if("record"in j)return x(v(j,!1));if("sql_native"in j)return x({type:"sql native",rawType:j.sql_native});if("calculation"in j)return h(v(j.calculation));throw new Error("Invalid function blueprint")}function T(j){return j.map(Z=>S(Z))}function D(j){return typeof j!="string"&&"variadic"in j}function w(j,Z){return{name:j,allowedTypes:T(R(Z)),isVariadic:D(Z)}}function L(j){return Object.entries(j).map(re=>w(re[0],re[1]))}function $(j){const Z=[],re=[];let ie=j;for(;ie.length>0;){const le=ie.indexOf("${");if(le===-1){Z.push(ie);break}const xe=ie.slice(0,le);ie=ie.slice(le);const Se=ie.indexOf("}");if(Se===-1){Z.push(xe+ie);break}const Te=ie.slice(2,Se);ie=ie.slice(Se+1);const me=Te.startsWith("..."),Ie=Te.endsWith(":"),be=me?Te.slice(3):Ie?Te.slice(0,-1):Te,we={node:"function_parameter",name:be};Z.push(xe),me?re.push({node:"spread",e:we,prefix:"",suffix:""}):Ie&&be==="order_by"?re.push({node:"aggregate_order_by"}):Ie&&be==="limit"?re.push({node:"aggregate_limit"}):re.push(we)}return{node:"genericSQLExpr",kids:{args:re},src:Z}}function H(j,Z){return D(Z)?{node:"spread",e:{node:"function_parameter",name:j},prefix:"",suffix:""}:{node:"function_parameter",name:j}}function W(j,Z){const re=Object.entries(Z.takes),ie=re.length>0?re.length-1:0;return{node:"genericSQLExpr",kids:{args:re.map(_e=>H(_e[0],_e[1]))},src:[`${j}(`,...Array(ie).fill(","),")"]}}function ee(j){return"sql"in j.impl?$(j.impl.sql):"expr"in j.impl?j.impl.expr:W(j.impl.function,j)}function fe(j){return{e:ee(j),between:j.impl.between,needsWindowOrderBy:j.impl.needsWindowOrderBy,defaultOrderByArgIndex:j.impl.defaultOrderByArgIndex}}function Ee(j){if(j!==void 0)return Object.entries(j).map(([Z,re])=>({name:Z,acceptibleTypes:re.map(ie=>v(ie,!0,!1))}))}function ge(j){return{returnType:_(j.returns),params:L(j.takes),isSymmetric:j.isSymmetric,supportsOrderBy:j.supportsOrderBy,supportsLimit:j.supportsLimit,genericTypes:Ee(j.generic),...fe(j)}}function V(j){return"takes"in j&&"returns"in j&&"impl"in j}function ae(j){return"function"in j||"sql"in j||"expr"in j}function te(j){return V(j)?[ge(j)]:Object.values(j).flatMap(Z=>ge(Z))}function se(j){const Z={};for(const re in j)Z[re]=te(j[re]);return Z}function G(j,Z){return[ge({...j,impl:Z})]}function Y(j,Z,re){if(ae(re)){if(!V(Z))throw new Error(`Malformed function override: ${j}. Attempt to override multiple overloads with a single overload (missing: ${Object.keys(Z)})`);return G(Z,re)}else{if(V(Z))throw new Error(`Malformed function override: ${j}. Attempt to override a single overload with multiple overloads (extraneous: ${Object.keys(re)})`);return Object.entries(re).flatMap(([ie,_e])=>{const le=Z[ie];if(le===void 0)throw new Error(`Malformed function override: ${j}. No overload named ${ie}`);return G(le,_e)})}}function z(j,Z){const re={};for(const ie in Z){if(!(ie in j))throw new Error(`Malformed function override: ${ie}. No such function in Malloy standard`);re[ie]=Y(ie,j[ie],Z[ie])}return re}function*q(j){if(typeof j!="string"){if("generic"in j)yield j;else if("record"in j)for(const Z of Object.values(j.record))yield*q(Z);else for(const Z of["array","literal","measure","dimension","measure","constant","cacluation"])if(Z in j){yield*q(j[Z]);return}}}function B(j,Z,re,ie={}){let _e=!1;const le={};for(const Se of Object.values(Z))for(const Te of q(Se))le[Te.generic]=["any"],_e=!0;_e&&ie.generic===void 0&&(ie.generic=le);const xe={takes:Z,returns:re,impl:{function:j.toUpperCase()},...ie};return{[j]:xe}}return Yr}var sv={},dh={},qR;function IA(){if(qR)return dh;qR=1,Object.defineProperty(dh,"__esModule",{value:!0}),dh.decodeDottedTablePath=e,dh.validateDottedTablePath=t;function e(u,i){const{quoteChar:l,escapeStyle:c,bareIdentRegex:a,dialectName:d}=i;if(u.length===0)return{ok:!1,error:`${d} table path is empty`};const r=[];let f=0;for(;;){let x,p;if(u[f]===l){const h=n(u,f,l,c);if(h===null)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(u)} — unterminated quoted segment`};x=h.decoded,p=!0,f=h.end}else{const h=u.slice(f).match(a);if(!h||h.index!==0||h[0].length===0)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(u)} — invalid segment at position ${f}`};x=h[0],p=!1,f+=h[0].length}if(x.includes(";")||x.includes("--"))return{ok:!1,error:`Invalid ${d} table path: segment ${JSON.stringify(x)} contains forbidden character; even when quoted, table-path segments may not contain \`;\` or \`--\`.`};if(r.push({value:x,quoted:p}),f===u.length)return{ok:!0,segments:r};if(u[f]!==".")return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(u)} — expected '.' at position ${f}`};if(f++,f===u.length)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(u)} — trailing dot`}}}function t(u,i){const l=e(u,i);return l.ok?{ok:!0,canonical:u}:l}function n(u,i,l,c){let a=i+1,d="";for(;a<u.length;){if(c==="backslash"&&u[a]==="\\"){if(a+1>=u.length)return null;d+=o(u[a+1]),a+=2;continue}if(u[a]===l){if(c==="doubled"&&u[a+1]===l){d+=l,a+=2;continue}return{decoded:d,end:a+1}}d+=u[a],a++}return null}function o(u){switch(u){case"n":return`
|
|
2
2
|
`;case"t":return" ";case"r":return"\r";default:return u}}return dh}var jR;function kl(){return jR||(jR=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Dialect=e.dayIndex=e.EscapeStyle=e.MAX_DECIMAL38=e.MIN_DECIMAL38=e.MAX_INT128=e.MIN_INT128=e.MAX_INT64=e.MIN_INT64=e.MAX_INT32=e.MIN_INT32=void 0,e.inDays=u,e.qtz=i;const t=Ct(),n=IA();e.MIN_INT32=-2147483648,e.MAX_INT32=2147483647,e.MIN_INT64=BigInt("-9223372036854775808"),e.MAX_INT64=BigInt("9223372036854775807"),e.MIN_INT128=BigInt("-170141183460469231731687303715884105728"),e.MAX_INT128=BigInt("170141183460469231731687303715884105727"),e.MIN_DECIMAL38=BigInt("-99999999999999999999999999999999999999"),e.MAX_DECIMAL38=BigInt("99999999999999999999999999999999999999"),e.EscapeStyle={Doubled:"doubled",Backslash:"backslash",Unset:"unset"};const o=["microsecond","millisecond","second","minute","hour","day","week","month","quarter","year"];e.dayIndex=o.indexOf("day");function u(c){return o.indexOf(c)>=e.dayIndex}function i(c){const a=c.queryTimezone;if(!(a===void 0||a===c.systemTimezone))return a}class l{constructor(){this.cantPartitionWindowFunctionsOnExpressions=!1,this.supportsPipelinesInViews=!0,this.supportsArraysInData=!0,this.hasTimestamptz=!1,this.readsNestedData=!0,this.orderByClause="ordinal",this.nullMatchesFunctionSignature=!0,this.supportsSelectReplace=!0,this.supportsBigIntPrecision=!0,this.supportsComplexFilteredSources=!0,this.supportsTempTables=!0,this.maxIdentifierLength=128,this.hasModOperator=!0,this.supportsLeftJoinUnnest=!0,this.requiresExplicitUnnestOrdering=!1,this.hasLateralColumnAliasInSelect=!1,this.supportsCountApprox=!1,this.supportsHyperLogLog=!1,this.supportsFullJoin=!0,this.nestedArrays=!0,this.compoundObjectInSchema=!0,this.booleanType="supported",this.likeEscape=!0,this.integerTypeMappings=[{min:BigInt(e.MIN_INT32),max:BigInt(e.MAX_INT32),numberType:"integer"},{min:e.MIN_INT64,max:e.MAX_INT64,numberType:"bigint"}],this.tablePathBareIdentRegex=/^[A-Za-z_][A-Za-z0-9_]*/,this.identifierQuoteChar="",this.stringLiteralStyle=e.EscapeStyle.Unset,this.identifierEscapeStyle=e.EscapeStyle.Unset}sqlLateralJoinBag(a){throw this.cantPartitionWindowFunctionsOnExpressions?new Error(`Dialect '${this.name}' sets cantPartitionWindowFunctionsOnExpressions but does not implement sqlLateralJoinBag`):new Error("Internal error: sqlLateralJoinBag called but cantPartitionWindowFunctionsOnExpressions is false")}literalNumberType(a){if(!/^-?\d+$/.test(a))return{type:"number",numberType:"float"};const r=BigInt(a);for(const f of this.integerTypeMappings)if(r>=f.min&&r<=f.max)return{type:"number",numberType:f.numberType};return{type:"number",numberType:"bigint"}}static makeTimeLiteralNode(a,d,r,f,x){var p;const h=(p=a?.hasTimestamptz)!==null&&p!==void 0?p:!1;return x==="date"?{node:"dateLiteral",literal:d,typeDef:{type:"date",timeframe:f!==void 0&&(0,t.isDateUnit)(f)?f:void 0}}:r&&h?{node:"timestamptzLiteral",literal:d,typeDef:{type:"timestamptz",timeframe:f},timezone:r}:r?{node:"timestampLiteral",literal:d,typeDef:{type:"timestamp",timeframe:f},timezone:r}:{node:"timestampLiteral",literal:d,typeDef:{type:"timestamp",timeframe:f}}}sqlValidateTableName(a){if(this.identifierEscapeStyle!==e.EscapeStyle.Doubled&&this.identifierEscapeStyle!==e.EscapeStyle.Backslash)throw new Error(`${this.name}: sqlValidateTableName requires identifierEscapeStyle to be set to Doubled or Backslash (or override sqlValidateTableName).`);return(0,n.validateDottedTablePath)(a,{quoteChar:this.identifierQuoteChar,escapeStyle:this.identifierEscapeStyle,bareIdentRegex:this.tablePathBareIdentRegex,dialectName:this.name})}sqlTurtleOrderByClause(a){const d=a.map(r=>` ${r.field} ${r.dir.toUpperCase()}`);return" "+this.sqlOrderBy(d,"turtle")}sqlFinalStage(a,d){throw new Error("Dialect has no final Stage but called Anyway")}sqlDateToString(a){return this.castToString(`DATE(${a})`)}escapeBackslashStyle(a,d){let r="";for(const f of a)switch(f){case"\\":r+="\\\\";break;case`
|
|
3
3
|
`:r+="\\n";break;case"\r":r+="\\r";break;case" ":r+="\\t";break;case d:r+="\\"+d;break;default:r+=f}return r}sqlQuoteIdentifier(a){const d=this.identifierQuoteChar;if(!d)throw new Error(`${this.name}: identifierQuoteChar is not set. Set it on the dialect (e.g. '"' or "\`"), or override sqlQuoteIdentifier.`);if(this.identifierEscapeStyle===e.EscapeStyle.Doubled)return d+a.split(d).join(d+d)+d;if(this.identifierEscapeStyle===e.EscapeStyle.Backslash)return d+this.escapeBackslashStyle(a,d)+d;throw new Error(`${this.name}: identifierEscapeStyle is not set. Set it to EscapeStyle.Doubled or EscapeStyle.Backslash on the dialect, or override sqlQuoteIdentifier.`)}sqlLiteralNumber(a){return a}ignoreInProject(a){return!1}needsCivilTimeComputation(a,d,r,f){const x=["day","week","month","quarter","year"],p=d!==void 0&&x.includes(d),h=r!==void 0&&x.includes(r),y=i(f);return{needed:t.TD.isAnyTimestamp(a)&&(p||h)&&y!==void 0,tz:y}}sqlTruncAndOffset(a,d,r,f){if(t.TD.isAnyTimestamp(a.typeDef)){const{needed:p,tz:h}=this.needsCivilTimeComputation(a.typeDef,r,f?.unit,d);if(p&&h){const y=this.sqlConvertToCivilTime(a.sql,h,a.typeDef);let E=y.sql;const g=y.typeDef;return r&&(E=this.sqlTruncate(E,r,g,!0,h)),f&&(E=this.sqlOffsetTime(E,f.op,f.magnitude,f.unit,g,!0,h)),this.sqlConvertFromCivilTime(E,h,a.typeDef)}}let x=a.sql;return r&&(x=this.sqlTruncate(x,r,a.typeDef,!1,i(d))),f&&(x=this.sqlOffsetTime(x,f.op,f.magnitude,f.unit,a.typeDef,!1,i(d))),x}sqlLiteralString(a){if(this.stringLiteralStyle==="doubled")return"'"+a.split("'").join("''")+"'";if(this.stringLiteralStyle==="backslash")return"'"+this.escapeBackslashStyle(a,"'")+"'";throw new Error(`${this.name}: stringLiteralStyle is not set. Set it to EscapeStyle.Doubled or EscapeStyle.Backslash on the dialect, or override sqlLiteralString.`)}sqlLiteralRegexp(a){return this.sqlLiteralString(a)}exprToSQL(a,d){switch(d.node){case"now":return this.sqlNowExpr();case"timeDiff":return this.sqlMeasureTimeExpr(d);case"delta":{const r=d.kids.base;return r.node==="trunc"?this.sqlTruncAndOffset(r.e,a,r.units,{op:d.op,magnitude:d.kids.delta.sql,unit:d.units}):this.sqlTruncAndOffset(r,a,void 0,{op:d.op,magnitude:d.kids.delta.sql,unit:d.units})}case"trunc":return this.sqlTruncAndOffset(d.e,a,d.units);case"extract":return this.sqlTimeExtractExpr(a,d);case"cast":return this.sqlCast(a,d);case"regexpMatch":return this.sqlRegexpMatch(d);case"/":return this.divisionIsInteger?`${d.kids.left.sql}*1.0/${d.kids.right.sql}`:void 0;case"%":return this.hasModOperator?void 0:`MOD(${d.kids.left.sql},${d.kids.right.sql})`;case"dateLiteral":return this.sqlDateLiteral(a,d.literal);case"timestampLiteral":return this.sqlTimestampLiteral(a,d.literal,d.timezone);case"timestamptzLiteral":return this.sqlTimestamptzLiteral(a,d.literal,d.timezone);case"stringLiteral":return this.sqlLiteralString(d.literal);case"numberLiteral":return this.sqlLiteralNumber(d.literal);case"regexpLiteral":return this.sqlLiteralRegexp(d.literal);case"recordLiteral":return this.sqlLiteralRecord(d);case"arrayLiteral":return this.sqlLiteralArray(d)}}sqlSumDistinct(a,d,r){return"sqlSumDistinct called but not implemented"}sqlAggDistinct(a,d,r){return"sqlAggDistinct called but not implemented"}sqlSampleTable(a,d){if(d!==void 0)throw new Error(`Sampling is not supported on dialect ${this.name}.`);return a}sqlOrderBy(a,d){return`ORDER BY ${a.join(",")}`}sqlTzStr(a){return`"${a.queryTimezone}"`}sqlMakeUnnestKey(a,d){return this.concat(a,"'x'",d)}sqlStringAggDistinct(a,d,r){const f="__STRING_AGG_KS__",x="__STRING_AGG_KE__";return`REGEXP_REPLACE(
|
|
4
4
|
STRING_AGG(DISTINCT ${`concat('${f}', ${a}, '${x}', ${d})`}${r.length>0?","+r:""}),
|