@malloy-publisher/sdk 0.0.79 → 0.0.80
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/index.cjs.js
CHANGED
|
@@ -24,7 +24,7 @@ export default theme;`}function Po(e={},...t){const{breakpoints:n,mixins:r={},sp
|
|
|
24
24
|
\f\r "&'<=>\``.split("")],[`\0
|
|
25
25
|
\f\r "&'<=>\``.split(""),`\0
|
|
26
26
|
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function DE(e,t,n,r){const i=r.schema,s=i.space==="svg"?!1:r.settings.omitOptionalTags;let a=i.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const o=[];let u;i.space==="html"&&e.tagName==="svg"&&(r.schema=kn);const l=wE(r,e.properties),d=r.all(i.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=i,d&&(a=!1),(l||!s||!SE(e,t,n))&&(o.push("<",e.tagName,l?" "+l:""),a&&(i.space==="svg"||r.settings.closeSelfClosing)&&(u=l.charAt(l.length-1),(!r.settings.tightSelfClosing||u==="/"||u&&u!=='"'&&u!=="'")&&o.push(" "),o.push("/")),o.push(">")),o.push(d),!a&&(!s||!Lu(e,t,n))&&o.push("</"+e.tagName+">"),o.join("")}function wE(e,t){const n=[];let r=-1,i;if(t){for(i in t)if(t[i]!==null&&t[i]!==void 0){const s=NE(e,i,t[i]);s&&n.push(s)}}for(;++r<n.length;){const s=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&s!=='"'&&s!=="'"&&(n[r]+=" ")}return n.join("")}function NE(e,t,n){const r=Gi(e.schema,t),i=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1;let a=e.quote,o;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const u=kr(r.attribute,Object.assign({},e.settings.characterReferences,{subset:us.name[i][s]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?xa:ya)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?u:(e.settings.preferUnquoted&&(o=kr(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:us.unquoted[i][s]}))),o!==n&&(e.settings.quoteSmart&&Us(n,a)>Us(n,e.alternative)&&(a=e.alternative),o=a+kr(n,Object.assign({},e.settings.characterReferences,{subset:(a==="'"?us.single:us.double)[i][s],attribute:!0}))+a),u+(o&&"="+o))}const PE=["<","&"];function lf(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:kr(e.value,Object.assign({},r.settings.characterReferences,{subset:PE}))}function RE(e,t,n,r){return r.settings.allowDangerousHtml?e.value:lf(e,t,n,r)}function LE(e,t,n,r){return r.all(e)}const OE=Ea("type",{invalid:FE,unknown:ME,handlers:{comment:aE,doctype:oE,element:DE,raw:RE,root:LE,text:lf}});function FE(e){throw new Error("Expected node, not `"+e+"`")}function ME(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const BE={},jE={},HE=[];function UE(e,t){const n=BE,r=n.quote||'"',i=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:zE,all:$E,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||Kh,characterReferences:n.characterReferences||jE,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?kn:Hr,quote:r,alternative:i}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function zE(e,t,n){return OE(e,t,n,this)}function $E(e){const t=[],n=e&&e.children||HE;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}function qE(e){return Array.isArray(e)?e:[e]}function Ta(e,t=!1){const n=e.split(/(\r?\n)/g);let r=0;const i=[];for(let s=0;s<n.length;s+=2){const a=t?n[s]+(n[s+1]||""):n[s];i.push([a,r]),r+=n[s].length,r+=n[s+1]?.length||0}return i}function Ou(e){return!e||["plaintext","txt","text","plain"].includes(e)}function cf(e){return e==="ansi"||Ou(e)}function Fu(e){return e==="none"}function df(e){return Fu(e)}function hf(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(/\s+/g);for(const r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}function VE(e,t){let n=0;const r=[];for(const i of t)i>n&&r.push({...e,content:e.content.slice(n,i),offset:e.offset+n}),n=i;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function WE(e,t){const n=Array.from(t instanceof Set?t:new Set(t)).sort((r,i)=>r-i);return n.length?e.map(r=>r.flatMap(i=>{const s=n.filter(a=>i.offset<a&&a<i.offset+i.content.length).map(a=>a-i.offset).sort((a,o)=>a-o);return s.length?VE(i,s):i})):e}async function ff(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function zs(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[i,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?n[i]=s:i===r&&Object.assign(n,s);return n}function Gn(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function pf(e){const t={};return e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle&&(e.fontStyle&Tn.Italic&&(t["font-style"]="italic"),e.fontStyle&Tn.Bold&&(t["font-weight"]="bold"),e.fontStyle&Tn.Underline&&(t["text-decoration"]="underline")),t}function GE(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function YE(e){const t=Ta(e,!0).map(([i])=>i);function n(i){if(i===e.length)return{line:t.length-1,character:t[t.length-1].length};let s=i,a=0;for(const o of t){if(s<o.length)break;s-=o.length,a++}return{line:a,character:s}}function r(i,s){let a=0;for(let o=0;o<i;o++)a+=t[o].length;return a+=s,a}return{lines:t,indexToPos:n,posToIndex:r}}class _t extends Error{constructor(t){super(t),this.name="ShikiError"}}const mf=new WeakMap;function Ca(e,t){mf.set(e,t)}function Ri(e){return mf.get(e)}class Ur{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new Ur(Object.fromEntries(qE(n).map(r=>[r,Uo])),t)}constructor(...t){if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,i]=t;this.lang=r,this._stacks={[i]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}get scopes(){return Tc(this._stacks[this.theme])}getScopes(t=this.theme){return Tc(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.scopes}}}function Tc(e){const t=[],n=new Set;function r(i){if(n.has(i))return;n.add(i);const s=i?.nameScopesList?.scopeName;s&&t.push(s),i.parent&&r(i.parent)}return r(e),t}function KE(e,t){if(!(e instanceof Ur))throw new _t("Invalid grammar state");return e.getInternalStack(t)}function QE(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let r=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new _t(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...i.indexToPos(a),offset:a}}else{const o=i.lines[a.line];if(o===void 0)throw new _t(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${i.lines.length}`);if(a.character<0||a.character>o.length)throw new _t(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${o.length}`);return{...a,offset:i.posToIndex(a.line,a.character)}}};const i=YE(n.source),s=(n.options.decorations||[]).map(a=>({...a,start:r(a.start),end:r(a.end)}));XE(s),e.set(n.meta,{decorations:s,converter:i,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;const i=t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]);return WE(n,i)},code(n){if(!this.options.decorations?.length)return;const r=t(this),i=Array.from(n.children).filter(d=>d.type==="element"&&d.tagName==="span");if(i.length!==r.converter.lines.length)throw new _t(`Number of lines in code element (${i.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function s(d,c,m,p){const g=i[d];let b="",T=-1,x=-1;if(c===0&&(T=0),m===0&&(x=0),m===Number.POSITIVE_INFINITY&&(x=g.children.length),T===-1||x===-1)for(let S=0;S<g.children.length;S++)b+=gf(g.children[S]),T===-1&&b.length===c&&(T=S+1),x===-1&&b.length===m&&(x=S+1);if(T===-1)throw new _t(`Failed to find start index for decoration ${JSON.stringify(p.start)}`);if(x===-1)throw new _t(`Failed to find end index for decoration ${JSON.stringify(p.end)}`);const C=g.children.slice(T,x);if(!p.alwaysWrap&&C.length===g.children.length)o(g,p,"line");else if(!p.alwaysWrap&&C.length===1&&C[0].type==="element")o(C[0],p,"token");else{const S={type:"element",tagName:"span",properties:{},children:C};o(S,p,"wrapper"),g.children.splice(T,C.length,S)}}function a(d,c){i[d]=o(i[d],c,"line")}function o(d,c,m){const p=c.properties||{},g=c.transform||(b=>b);return d.tagName=c.tagName||"span",d.properties={...d.properties,...p,class:d.properties.class},c.properties?.class&&hf(d,c.properties.class),d=g(d,m)||d,d}const u=[],l=r.decorations.sort((d,c)=>c.start.offset-d.start.offset);for(const d of l){const{start:c,end:m}=d;if(c.line===m.line)s(c.line,c.character,m.character,d);else if(c.line<m.line){s(c.line,c.character,Number.POSITIVE_INFINITY,d);for(let p=c.line+1;p<m.line;p++)u.unshift(()=>a(p,d));s(m.line,0,m.character,d)}}u.forEach(d=>d())}}}function XE(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new _t(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const i=e[r],s=n.start.offset<i.start.offset&&i.start.offset<n.end.offset,a=n.start.offset<i.end.offset&&i.end.offset<n.end.offset,o=i.start.offset<n.start.offset&&n.start.offset<i.end.offset,u=i.start.offset<n.end.offset&&n.end.offset<i.end.offset;if(s||a||o||u){if(a&&a||o&&u)continue;throw new _t(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(i.start)} intersect.`)}}}}function gf(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(gf).join(""):""}const ZE=[QE()];function $s(e){return[...e.transformers||[],...ZE]}var Yn=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Za={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",9:"strikethrough"};function JE(e,t){const n=e.indexOf("\x1B[",t);if(n!==-1){const r=e.indexOf("m",n);return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function Cc(e,t){let n=1;const r=e[t+n++];let i;if(r==="2"){const s=[e[t+n++],e[t+n++],e[t+n]].map(a=>Number.parseInt(a));s.length===3&&!s.some(a=>Number.isNaN(a))&&(i={type:"rgb",rgb:s})}else if(r==="5"){const s=Number.parseInt(e[t+n]);Number.isNaN(s)||(i={type:"table",index:Number(s)})}return[n,i]}function ex(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n],i=Number.parseInt(r);if(!Number.isNaN(i))if(i===0)t.push({type:"resetAll"});else if(i<=9)Za[i]&&t.push({type:"setDecoration",value:Za[i]});else if(i<=29){const s=Za[i-20];s&&t.push({type:"resetDecoration",value:s})}else if(i<=37)t.push({type:"setForegroundColor",value:{type:"named",name:Yn[i-30]}});else if(i===38){const[s,a]=Cc(e,n);a&&t.push({type:"setForegroundColor",value:a}),n+=s}else if(i===39)t.push({type:"resetForegroundColor"});else if(i<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:Yn[i-40]}});else if(i===48){const[s,a]=Cc(e,n);a&&t.push({type:"setBackgroundColor",value:a}),n+=s}else i===49?t.push({type:"resetBackgroundColor"}):i>=90&&i<=97?t.push({type:"setForegroundColor",value:{type:"named",name:Yn[i-90+8]}}):i>=100&&i<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Yn[i-100+8]}})}return t}function tx(){let e=null,t=null,n=new Set;return{parse(r){const i=[];let s=0;do{const a=JE(r,s),o=a.sequence?r.substring(s,a.startPosition):r.substring(s);if(o.length>0&&i.push({value:o,foreground:e,background:t,decorations:new Set(n)}),a.sequence){const u=ex(a.sequence);for(const l of u)l.type==="resetAll"?(e=null,t=null,n.clear()):l.type==="resetForegroundColor"?e=null:l.type==="resetBackgroundColor"?t=null:l.type==="resetDecoration"&&n.delete(l.value);for(const l of u)l.type==="setForegroundColor"?e=l.value:l.type==="setBackgroundColor"?t=l.value:l.type==="setDecoration"&&n.add(l.value)}s=a.position}while(s<r.length);return i}}}var nx={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function rx(e=nx){function t(o){return e[o]}function n(o){return`#${o.map(u=>Math.max(0,Math.min(u,255)).toString(16).padStart(2,"0")).join("")}`}let r;function i(){if(r)return r;r=[];for(let l=0;l<Yn.length;l++)r.push(t(Yn[l]));let o=[0,95,135,175,215,255];for(let l=0;l<6;l++)for(let d=0;d<6;d++)for(let c=0;c<6;c++)r.push(n([o[l],o[d],o[c]]));let u=8;for(let l=0;l<24;l++,u+=10)r.push(n([u,u,u]));return r}function s(o){return i()[o]}function a(o){switch(o.type){case"named":return t(o.name);case"rgb":return n(o.rgb);case"table":return s(o.index)}}return{value:a}}function ix(e,t,n){const r=zs(e,n),i=Ta(t),s=rx(Object.fromEntries(Yn.map(o=>[o,e.colors?.[`terminal.ansi${o[0].toUpperCase()}${o.substring(1)}`]]))),a=tx();return i.map(o=>a.parse(o[0]).map(u=>{let l,d;u.decorations.has("reverse")?(l=u.background?s.value(u.background):e.bg,d=u.foreground?s.value(u.foreground):e.fg):(l=u.foreground?s.value(u.foreground):e.fg,d=u.background?s.value(u.background):void 0),l=Gn(l,r),d=Gn(d,r),u.decorations.has("dim")&&(l=sx(l));let c=Tn.None;return u.decorations.has("bold")&&(c|=Tn.Bold),u.decorations.has("italic")&&(c|=Tn.Italic),u.decorations.has("underline")&&(c|=Tn.Underline),{content:u.value,offset:o[1],color:l,bgColor:d,fontStyle:c}}))}function sx(e){const t=e.match(/#([0-9a-f]{3})([0-9a-f]{3})?([0-9a-f]{2})?/);if(t)if(t[3]){const r=Math.round(Number.parseInt(t[3],16)/2).toString(16).padStart(2,"0");return`#${t[1]}${t[2]}${r}`}else return t[2]?`#${t[1]}${t[2]}80`:`#${Array.from(t[1]).map(r=>`${r}${r}`).join("")}80`;const n=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:e}function Mu(e,t,n={}){const{lang:r="text",theme:i=e.getLoadedThemes()[0]}=n;if(Ou(r)||Fu(i))return Ta(t).map(u=>[{content:u[0],offset:u[1]}]);const{theme:s,colorMap:a}=e.setTheme(i);if(r==="ansi")return ix(s,t,n);const o=e.getLanguage(r);if(n.grammarState){if(n.grammarState.lang!==o.name)throw new An(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(s.name))throw new An(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return ox(t,o,s,a,n)}function ax(...e){if(e.length===2)return Ri(e[1]);const[t,n,r={}]=e,{lang:i="text",theme:s=t.getLoadedThemes()[0]}=r;if(Ou(i)||Fu(s))throw new An("Plain language does not have grammar state");if(i==="ansi")throw new An("ANSI language does not have grammar state");const{theme:a,colorMap:o}=t.setTheme(s),u=t.getLanguage(i);return new Ur(qs(n,u,a,o,r).stateStack,u.name,a.name)}function ox(e,t,n,r,i){const s=qs(e,t,n,r,i),a=new Ur(qs(e,t,n,r,i).stateStack,t.name,n.name);return Ca(s.tokens,a),s.tokens}function qs(e,t,n,r,i){const s=zs(n,i),{tokenizeMaxLineLength:a=0,tokenizeTimeLimit:o=500}=i,u=Ta(e);let l=i.grammarState?KE(i.grammarState,n.name)??Uo:i.grammarContextCode!=null?qs(i.grammarContextCode,t,n,r,{...i,grammarState:void 0,grammarContextCode:void 0}).stateStack:Uo,d=[];const c=[];for(let m=0,p=u.length;m<p;m++){const[g,b]=u[m];if(g===""){d=[],c.push([]);continue}if(a>0&&g.length>=a){d=[],c.push([{content:g,offset:b,color:"",fontStyle:0}]);continue}let T,x,C;i.includeExplanation&&(T=t.tokenizeLine(g,l),x=T.tokens,C=0);const S=t.tokenizeLine2(g,l,o),w=S.tokens.length/2;for(let D=0;D<w;D++){const N=S.tokens[2*D],B=D+1<w?S.tokens[2*D+2]:g.length;if(N===B)continue;const Z=S.tokens[2*D+1],J=Gn(r[Nr.getForeground(Z)],s),E=Nr.getFontStyle(Z),L={content:g.substring(N,B),offset:b+N,color:J,fontStyle:E};if(i.includeExplanation){const O=[];if(i.includeExplanation!=="scopeName")for(const M of n.settings){let K;switch(typeof M.scope){case"string":K=M.scope.split(/,/).map(se=>se.trim());break;case"object":K=M.scope;break;default:continue}O.push({settings:M,selectors:K.map(se=>se.split(/ /))})}L.explanation=[];let z=0;for(;N+z<B;){const M=x[C],K=g.substring(M.startIndex,M.endIndex);z+=K.length,L.explanation.push({content:K,scopes:i.includeExplanation==="scopeName"?ux(M.scopes):lx(O,M.scopes)}),C+=1}}d.push(L)}c.push(d),d=[],l=S.ruleStack}return{tokens:c,stateStack:l}}function ux(e){return e.map(t=>({scopeName:t}))}function lx(e,t){const n=[];for(let r=0,i=t.length;r<i;r++){const s=t[r];n[r]={scopeName:s,themeMatches:dx(e,s,t.slice(0,r))}}return n}function Sc(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function cx(e,t,n){if(!Sc(e[e.length-1],t))return!1;let r=e.length-2,i=n.length-1;for(;r>=0&&i>=0;)Sc(e[r],n[i])&&(r-=1),i-=1;return r===-1}function dx(e,t,n){const r=[];for(const{selectors:i,settings:s}of e)for(const a of i)if(cx(a,t,n)){r.push(s);break}return r}function bf(e,t,n){const r=Object.entries(n.themes).filter(u=>u[1]).map(u=>({color:u[0],theme:u[1]})),i=r.map(u=>{const l=Mu(e,t,{...n,theme:u.theme}),d=Ri(l),c=typeof u.theme=="string"?u.theme:u.theme.name;return{tokens:l,state:d,theme:c}}),s=hx(...i.map(u=>u.tokens)),a=s[0].map((u,l)=>u.map((d,c)=>{const m={content:d.content,variants:{},offset:d.offset};return"includeExplanation"in n&&n.includeExplanation&&(m.explanation=d.explanation),s.forEach((p,g)=>{const{content:b,explanation:T,offset:x,...C}=p[l][c];m.variants[r[g].color]=C}),m})),o=i[0].state?new Ur(Object.fromEntries(i.map(u=>[u.theme,u.state?.getInternalStack(u.theme)])),i[0].state.lang):void 0;return o&&Ca(a,o),a}function hx(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const i=e.map(u=>u[r]),s=t.map(()=>[]);t.forEach((u,l)=>u.push(s[l]));const a=i.map(()=>0),o=i.map(u=>u[0]);for(;o.every(u=>u);){const u=Math.min(...o.map(l=>l.content.length));for(let l=0;l<n;l++){const d=o[l];d.content.length===u?(s[l].push(d),a[l]+=1,o[l]=i[l][a[l]]):(s[l].push({...d,content:d.content.slice(0,u)}),o[l]={...d,content:d.content.slice(u),offset:d.offset+u})}}}return t}function Vs(e,t,n){let r,i,s,a,o,u;if("themes"in n){const{defaultColor:l="light",cssVariablePrefix:d="--shiki-"}=n,c=Object.entries(n.themes).filter(T=>T[1]).map(T=>({color:T[0],theme:T[1]})).sort((T,x)=>T.color===l?-1:x.color===l?1:0);if(c.length===0)throw new An("`themes` option must not be empty");const m=bf(e,t,n);if(u=Ri(m),l&&!c.find(T=>T.color===l))throw new An(`\`themes\` option must contain the defaultColor key \`${l}\``);const p=c.map(T=>e.getTheme(T.theme)),g=c.map(T=>T.color);s=m.map(T=>T.map(x=>fx(x,g,d,l))),u&&Ca(s,u);const b=c.map(T=>zs(T.theme,n));i=c.map((T,x)=>(x===0&&l?"":`${d+T.color}:`)+(Gn(p[x].fg,b[x])||"inherit")).join(";"),r=c.map((T,x)=>(x===0&&l?"":`${d+T.color}-bg:`)+(Gn(p[x].bg,b[x])||"inherit")).join(";"),a=`shiki-themes ${p.map(T=>T.name).join(" ")}`,o=l?void 0:[i,r].join(";")}else if("theme"in n){const l=zs(n.theme,n);s=Mu(e,t,n);const d=e.getTheme(n.theme);r=Gn(d.bg,l),i=Gn(d.fg,l),a=d.name,u=Ri(s)}else throw new An("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:i,bg:r,themeName:a,rootStyle:o,grammarState:u}}function fx(e,t,n,r){const i={content:e.content,explanation:e.explanation,offset:e.offset},s=t.map(u=>pf(e.variants[u])),a=new Set(s.flatMap(u=>Object.keys(u))),o={};return s.forEach((u,l)=>{for(const d of a){const c=u[d]||"inherit";if(l===0&&r)o[d]=c;else{const m=d==="color"?"":d==="background-color"?"-bg":`-${d}`,p=n+t[l]+(d==="color"?"":m);o[p]=c}}}),i.htmlStyle=o,i}function Ws(e,t,n,r={meta:{},options:n,codeToHast:(i,s)=>Ws(e,i,s),codeToTokens:(i,s)=>Vs(e,i,s)}){let i=t;for(const p of $s(n))i=p.preprocess?.call(r,i,n)||i;let{tokens:s,fg:a,bg:o,themeName:u,rootStyle:l,grammarState:d}=Vs(e,i,n);const{mergeWhitespaces:c=!0}=n;c===!0?s=mx(s):c==="never"&&(s=gx(s));const m={...r,get source(){return i}};for(const p of $s(n))s=p.tokens?.call(m,s)||s;return px(s,{...n,fg:a,bg:o,themeName:u,rootStyle:l},m,d)}function px(e,t,n,r=Ri(e)){const i=$s(t),s=[],a={type:"root",children:[]},{structure:o="classic",tabindex:u="0"}=t;let l={type:"element",tagName:"pre",properties:{class:`shiki ${t.themeName||""}`,style:t.rootStyle||`background-color:${t.bg};color:${t.fg}`,...u!==!1&&u!=null?{tabindex:u.toString()}:{},...Object.fromEntries(Array.from(Object.entries(t.meta||{})).filter(([g])=>!g.startsWith("_")))},children:[]},d={type:"element",tagName:"code",properties:{},children:s};const c=[],m={...n,structure:o,addClassToHast:hf,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return a},get pre(){return l},get code(){return d},get lines(){return c}};if(e.forEach((g,b)=>{b&&(o==="inline"?a.children.push({type:"element",tagName:"br",properties:{},children:[]}):o==="classic"&&s.push({type:"text",value:`
|
|
27
|
-
`}));let T={type:"element",tagName:"span",properties:{class:"line"},children:[]},x=0;for(const C of g){let S={type:"element",tagName:"span",properties:{...C.htmlAttrs},children:[{type:"text",value:C.content}]};C.htmlStyle;const w=GE(C.htmlStyle||pf(C));w&&(S.properties.style=w);for(const D of i)S=D?.span?.call(m,S,b+1,x,T,C)||S;o==="inline"?a.children.push(S):o==="classic"&&T.children.push(S),x+=C.content.length}if(o==="classic"){for(const C of i)T=C?.line?.call(m,T,b+1)||T;c.push(T),s.push(T)}}),o==="classic"){for(const g of i)d=g?.code?.call(m,d)||d;l.children.push(d);for(const g of i)l=g?.pre?.call(m,l)||l;a.children.push(l)}let p=a;for(const g of i)p=g?.root?.call(m,p)||p;return r&&Ca(p,r),p}function mx(e){return e.map(t=>{const n=[];let r="",i=0;return t.forEach((s,a)=>{const u=!(s.fontStyle&&s.fontStyle&Tn.Underline);u&&s.content.match(/^\s+$/)&&t[a+1]?(i||(i=s.offset),r+=s.content):r?(u?n.push({...s,offset:i,content:r+s.content}):n.push({content:r,offset:i},s),i=0,r=""):n.push(s)}),n})}function gx(e){return e.map(t=>t.flatMap(n=>{if(n.content.match(/^\s+$/))return n;const r=n.content.match(/^(\s*)(.*?)(\s*)$/);if(!r)return n;const[,i,s,a]=r;if(!i&&!a)return n;const o=[{...n,offset:n.offset+i.length,content:s}];return i&&o.unshift({content:i,offset:n.offset}),a&&o.push({content:a,offset:n.offset+i.length+s.length}),o}))}function bx(e,t,n){const r={meta:{},options:n,codeToHast:(s,a)=>Ws(e,s,a),codeToTokens:(s,a)=>Vs(e,s,a)};let i=UE(Ws(e,t,n,r));for(const s of $s(n))i=s.postprocess?.call(r,i,n)||i;return i}const Ac={light:"#333333",dark:"#bbbbbb"},Ic={light:"#fffffe",dark:"#1e1e1e"},kc="__shiki_resolved";function Bu(e){if(e?.[kc])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){const o=t.settings?t.settings.find(u=>!u.name&&!u.scope):void 0;o?.settings?.foreground&&(r=o.settings.foreground),o?.settings?.background&&(n=o.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?Ac.light:Ac.dark),n||(n=t.type==="light"?Ic.light:Ic.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0;const s=new Map;function a(o){if(s.has(o))return s.get(o);i+=1;const u=`#${i.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${u}`]?a(o):(s.set(o,u),u)}t.settings=t.settings.map(o=>{const u=o.settings?.foreground&&!o.settings.foreground.startsWith("#"),l=o.settings?.background&&!o.settings.background.startsWith("#");if(!u&&!l)return o;const d={...o,settings:{...o.settings}};if(u){const c=a(o.settings.foreground);t.colorReplacements[c]=o.settings.foreground,d.settings.foreground=c}if(l){const c=a(o.settings.background);t.colorReplacements[c]=o.settings.background,d.settings.background=c}return d});for(const o of Object.keys(t.colors||{}))if((o==="editor.foreground"||o==="editor.background"||o.startsWith("terminal.ansi"))&&!t.colors[o]?.startsWith("#")){const u=a(t.colors[o]);t.colorReplacements[u]=t.colors[o],t.colors[o]=u}return Object.defineProperty(t,kc,{enumerable:!1,writable:!1,value:!0}),t}async function Ef(e){return Array.from(new Set((await Promise.all(e.filter(t=>!cf(t)).map(async t=>await ff(t).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function xf(e){return(await Promise.all(e.map(async n=>df(n)?null:Bu(await ff(n))))).filter(n=>!!n)}class Ex extends P2{constructor(t,n,r,i={}){super(t),this._resolver=t,this._themes=n,this._langs=r,this._alias=i,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=Bu(t);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let n=this._textmateThemeCache.get(t);n||(n=Fs.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){if(this._alias[t]){const n=new Set([t]);for(;this._alias[t];){if(t=this._alias[t],n.has(t))throw new _t(`Circular alias \`${Array.from(n).join(" -> ")} -> ${t}\``);n.add(t)}}return this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const i=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(i.name=t.name,this._resolvedGrammars.set(t.name,i),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,n.size)for(const s of n)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(const i of t)this.resolveEmbeddedLanguages(i);const n=Array.from(this._langGraph.entries()),r=n.filter(([i,s])=>!s);if(r.length){const i=n.filter(([s,a])=>a&&a.embeddedLangs?.some(o=>r.map(([u])=>u).includes(o))).filter(s=>!r.includes(s));throw new _t(`Missing languages ${r.map(([s])=>`\`${s}\``).join(", ")}, required by ${i.map(([s])=>`\`${s}\``).join(", ")}`)}for(const[i,s]of n)this._resolver.addLanguage(s);for(const[i,s]of n)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){if(this._langMap.set(t.name,t),this._langGraph.set(t.name,t),t.embeddedLangs)for(const n of t.embeddedLangs)this._langGraph.set(n,this._langMap.get(n))}}class xx{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,n){this._onigLib={createOnigScanner:r=>t.createScanner(r),createOnigString:r=>t.createString(r)},n.forEach(r=>this.addLanguage(r))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(n=>{this._langs.set(n,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(n=>{this._injections.get(n)||this._injections.set(n,[]),this._injections.get(n).push(t.scopeName)})}getInjections(t){const n=t.split(".");let r=[];for(let i=1;i<=n.length;i++){const s=n.slice(0,i).join(".");r=[...r,...this._injections.get(s)||[]]}return r}}let ei=0;function yx(e){ei+=1,e.warnings!==!1&&ei>=10&&ei%10===0&&console.warn(`[Shiki] ${ei} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new _t("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Bu),i=new xx(e.engine,n),s=new Ex(i,r,n,e.langAlias);let a;function o(C){T();const S=s.getGrammar(typeof C=="string"?C:C.name);if(!S)throw new _t(`Language \`${C}\` not found, you may need to load it first`);return S}function u(C){if(C==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};T();const S=s.getTheme(C);if(!S)throw new _t(`Theme \`${C}\` not found, you may need to load it first`);return S}function l(C){T();const S=u(C);a!==C&&(s.setTheme(S),a=C);const w=s.getColorMap();return{theme:S,colorMap:w}}function d(){return T(),s.getLoadedThemes()}function c(){return T(),s.getLoadedLanguages()}function m(...C){T(),s.loadLanguages(C.flat(1))}async function p(...C){return m(await Ef(C))}function g(...C){T();for(const S of C.flat(1))s.loadTheme(S)}async function b(...C){return T(),g(await xf(C))}function T(){if(t)throw new _t("Shiki instance has been disposed")}function x(){t||(t=!0,s.dispose(),ei-=1)}return{setTheme:l,getTheme:u,getLanguage:o,getLoadedThemes:d,getLoadedLanguages:c,loadLanguage:p,loadLanguageSync:m,loadTheme:b,loadThemeSync:g,dispose:x,[Symbol.dispose]:x}}async function Tx(e={}){e.loadWasm;const[t,n,r]=await Promise.all([xf(e.themes||[]),Ef(e.langs||[]),e.engine||Rh(e.loadWasm||Wb())]);return yx({...e,themes:t,langs:n,engine:r})}async function Cx(e={}){const t=await Tx(e);return{getLastGrammarState:(...n)=>ax(t,...n),codeToTokensBase:(n,r)=>Mu(t,n,r),codeToTokensWithThemes:(n,r)=>bf(t,n,r),codeToTokens:(n,r)=>Vs(t,n,r),codeToHast:(n,r)=>Ws(t,n,r),codeToHtml:(n,r)=>bx(t,n,r),...t,getInternalContext:()=>t}}function Sx(e,t,n){let r,i,s;{const o=e;r=o.langs,i=o.themes,s=o.engine}async function a(o){function u(p){if(typeof p=="string"){if(cf(p))return[];const g=r[p];if(!g)throw new An(`Language \`${p}\` is not included in this bundle. You may want to load it from external source.`);return g}return p}function l(p){if(df(p))return"none";if(typeof p=="string"){const g=i[p];if(!g)throw new An(`Theme \`${p}\` is not included in this bundle. You may want to load it from external source.`);return g}return p}const d=(o.themes??[]).map(p=>l(p)),c=(o.langs??[]).map(p=>u(p)),m=await Cx({engine:o.engine??s(),...o,themes:d,langs:c});return{...m,loadLanguage(...p){return m.loadLanguage(...p.map(u))},loadTheme(...p){return m.loadTheme(...p.map(l))}}}return a}const Ax=Sx({langs:kb,themes:vb,engine:()=>Rh(Promise.resolve().then(()=>require("./wasm-Dw4u1m6u.cjs")))}),Ja={scopeName:"source.malloy",patterns:[{include:"#malloy-language"}],repository:{"malloy-language":{patterns:[{include:"#sql-string"},{include:"#comments"},{include:"#tags"},{include:"#strings"},{include:"#numbers"},{include:"#keywords"},{include:"#properties"},{include:"#functions"},{include:"#datetimes"},{include:"#identifiers-quoted"},{include:"#types"},{include:"#constants"},{include:"#timeframes"},{include:"#identifiers-unquoted"}]},"malloy-matched":{begin:"{",end:"}",patterns:[{include:"#malloy-matched"},{include:"#malloy-language"}]},"malloy-in-sql":{begin:"%{",name:"source.malloy-in-sql",end:"}%?",patterns:[{include:"#malloy-matched"},{include:"#malloy-language"}]},"sql-string":{patterns:[{begin:'(\\b[A-Za-z_][A-Za-z_0-9]*)(\\s*\\.\\s*)(sql)(\\s*\\(\\s*)(""")',end:'"""',beginCaptures:{1:{name:"variable.other"},3:{name:"keyword.control.sql"},5:{name:"punctuation.sql-block.open"}},endCaptures:{0:{name:"punctuation.sql-block.close"}},name:"source.sql",patterns:[{include:"#malloy-in-sql"},{include:"source.sql"}]}]},functions:{patterns:[{match:"(?i)\\b(count)(\\s*\\()(distinct)",captures:{1:{name:"entity.name.function"},3:{name:"entity.name.function.modifier"}}},{match:"(?i)\\b(AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE|UNGROUPED)(\\s*\\()",captures:{1:{name:"entity.name.function"}}},{match:"(?i)\\b([a-zA-Z_][a-zA-Z_0-9]*)(\\s*\\()",captures:{1:{name:"entity.name.function"}}},{match:"(?i)\\b([a-zA-Z_][a-zA-Z_0-9]*)(!)(timestamp|number|string|boolean|date)?(\\s*\\()",captures:{1:{name:"entity.name.function"},3:{name:"entity.name.type"}}}]},datetimes:{patterns:[{match:"(?i)@[0-9]{4}-[0-9]{2}-[0-9]{2}[ T][0-9]{2}:[0-9]{2}((:[0-9]{2})(([\\.,][0-9]+)(\\[[A-Za-z_/]+\\])?)?)?",name:"constant.numeric.timestamp"},{match:"(?i)@[0-9]{4}(-Q[1-4]|-[0-9]{2}(-[0-9]{2}(-WK)?)?)?",name:"constant.numeric.date"}]},"identifiers-quoted":{patterns:[{match:"`[^`]*`",name:"variable.other.quoted"}]},"identifiers-unquoted":{patterns:[{match:"(?i)\\b[A-Za-z_][A-Za-z_0-9]*\\b",name:"variable.other"}]},timeframes:{patterns:[{match:"(?i)\\b((year|quarter|month|week|day|hour|minute|second)s?)\\b",name:"keyword.other.timeframe"},{match:"(?i)\\b(day_of_year|day_of_month)\\b",name:"keyword.other.timeframe"}]},comments:{patterns:[{begin:"/\\*",end:"\\*/",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"comment.block"},{begin:"//",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{begin:"--",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-hyphen"}]},tags:{patterns:[{match:"##\\n",name:"string.quoted",captures:{0:{name:"string.quoted"}}},{begin:'#"',end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{match:"#\\n",name:"string.quoted",captures:{0:{name:"string.quoted"}}},{begin:"#\\s",end:"\\n",beginCaptures:{0:{name:"support.type.property-name.json"}},name:"comment.line.double-slash",patterns:[{include:"#tag-values"}]},{begin:"##\\s",end:"\\n",beginCaptures:{0:{name:"support.type.property-name.json"}},name:"comment.line.double-slash",patterns:[{include:"#tag-values"}]},{begin:"#",end:"\\n",beginCaptures:{0:{name:"string.quoted"}},name:"string.quoted"}],repository:{"tag-values":{name:"support.type.property-name.json",match:'(-)?((?:[^\\s=#]+)|(?:"[^#]+"))(?:\\s*(=)\\s*((?:[^\\s=#]+)|(?:"[^#]+")))?',captures:{1:{name:"keyword.control.negate"},2:{name:"support.type.property-name.json"},3:{name:"keyword.operator.comparison.ts"},4:{name:"string.quoted"}}}}},strings:{patterns:[{begin:"'",end:"'",beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.single",patterns:[{include:"#escapes"}]},{begin:'"',end:'"',beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.double",patterns:[{include:"#escapes"}]},{begin:'"""',end:'"""',beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.triple"},{begin:"(?i)[r|/]'",end:"'",name:"string.regexp",patterns:[{include:"#regex-escapes"}]}],repository:{escapes:{name:"constant.character.escape",match:"\\\\(u[A-Fa-f0-9]{4}|.)",captures:{0:{name:"constant.character.escape"}}},"regex-escapes":{name:"constant.character.escape",match:"\\\\.",captures:{0:{name:"constant.character.escape"}}}}},numbers:{match:"(?i)(\\b((0|[1-9][0-9]*)(E[+-]?[0-9]+|\\.[0-9]*)?)|\\.[0-9]+)",name:"constant.numeric"},constants:{patterns:[{match:"(?i)\\bnull\\b",name:"constant.language.null"},{match:"(?i)\\btrue\\b",name:"constant.language.true"},{match:"(?i)\\bfalse\\b",name:"constant.language.false"}]},types:{patterns:[{match:"(?i)\\bstring\\b",name:"entity.name.type.string"},{match:"(?i)\\bnumber\\b",name:"entity.name.type.number"},{match:"(?i)\\bdate\\b",name:"entity.name.type.date"},{match:"(?i)\\btimestamp\\b",name:"entity.name.type.timestamp"},{match:"(?i)\\bboolean\\b",name:"entity.name.type.boolean"}]},properties:{patterns:[{match:"(?i)\\baccept\\b",name:"keyword.control.accept"},{match:"(?i)\\bselect\\b",name:"keyword.control.select"},{match:"(?i)\\bconnection\\b",name:"keyword.control.connection"},{match:"(?i)\\brun\\b",name:"keyword.control.run"},{match:"(?i)\\bextend\\b",name:"keyword.control.extend"},{match:"(?i)\\brefine\\b",name:"keyword.control.refine"},{match:"(?i)\\baggregate\\b",name:"keyword.control.aggregate"},{match:"(?i)\\bsample\\b",name:"keyword.control.sample"},{match:"(?i)\\bcalculate\\b",name:"keyword.control.calculate"},{match:"(?i)\\btimezone\\b",name:"keyword.control.timezone"},{match:"(?i)\\bdimension\\b",name:"keyword.control.dimension"},{match:"(?i)\\bexcept\\b",name:"keyword.control.except"},{match:"(?i)\\bsource\\b",name:"keyword.control.source"},{match:"(?i)\\bgroup_by\\b",name:"keyword.control.group_by"},{match:"(?i)\\bhaving\\b",name:"keyword.control.having"},{match:"(?i)\\bindex\\b",name:"keyword.control.index"},{match:"(?i)\\bjoin_one\\b",name:"keyword.control.join_one"},{match:"(?i)\\bwith\\b",name:"keyword.control.with"},{match:"(?i)\\bjoin_many\\b",name:"keyword.control.join_many"},{match:"(?i)\\bjoin_cross\\b",name:"keyword.control.join_cross"},{match:"(?i)\\blimit\\b",name:"keyword.control.limit"},{match:"(?i)\\bmeasure\\b",name:"keyword.control.measure"},{match:"(?i)\\bnest\\b",name:"keyword.control.nest"},{match:"(?i)\\border_by\\b",name:"keyword.control.order_by"},{match:"(?i)\\bpartition_by\\b",name:"keyword.control.partition_by"},{match:"(?i)\\bprimary_key\\b",name:"keyword.control.primary_key"},{match:"(?i)\\bproject\\b",name:"keyword.control.project"},{match:"(?i)\\bquery\\b",name:"keyword.control.query"},{match:"(?i)\\brename\\b",name:"keyword.control.rename"},{match:"(?i)\\btop\\b",name:"keyword.control.top"},{match:"(?i)\\bview\\b",name:"keyword.control.view"},{match:"(?i)\\bwhere\\b",name:"keyword.control.where"},{match:"(?i)\\bdeclare\\b",name:"keyword.control.declare"}]},keywords:{patterns:[{match:"(?i)\\bis\\b",name:"keyword.control.is"},{match:"(?i)\\bon\\b",name:"keyword.control.on"},{match:"(?i)\\bnot\\b",name:"keyword.other.not"},{match:"(?i)\\bor\\b",name:"keyword.other.or"},{match:"(?i)\\bdesc\\b",name:"keyword.control.desc"},{match:"(?i)\\bby\\b",name:"keyword.control.by"},{match:"(?i)\\band\\b",name:"keyword.other.and"},{match:"(?i)\\basc\\b",name:"keyword.control.asc"},{match:"(?i)\\bfor\\b",name:"keyword.other.for"},{match:"(?i)\\belse\\b",name:"keyword.other.else"},{match:"(?i)\\bto\\b",name:"keyword.other.to"},{match:"(?i)\\bwhen\\b",name:"keyword.other.when"},{match:"(?i)\\bpick\\b",name:"keyword.other.pick"},{match:"(?i)\\bimport\\b",name:"keyword.control.import"}]}}},Ix={...Ja,patterns:[...Ja.patterns,{include:"#docvar"}],repository:{...Ja.repository,docvar:{patterns:[{match:"\\<\\<[^(\\>\\>)]*\\>\\>",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"markup.italic.markdown"}]}}},kx={name:"Malloy SQL",scopeName:"source.malloy-sql",patterns:[{include:"#malloysql-sql"}],repository:{"malloysql-sql":{beginCaptures:{0:{name:"entity.other.attribute.malloy-sql"},1:{name:"entity.other.attribute.malloy-sql"},3:{name:"comment.line.double-slash"}},name:"meta.embedded.block.malloysql.sql",patterns:[{include:"#comments"},{begin:"%{",end:"}%",beginCaptures:{0:{name:"punctuation.definition.malloy-sql"}},endCaptures:{0:{name:"punctuation.definition.malloy-sql"}},name:"meta.embedded.block.malloy",patterns:[{include:"source.malloy"}]},{include:"source.sql"}]},comments:{patterns:[{begin:"/\\*",end:"\\*/",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"comment.block"},{begin:"//",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{begin:"--",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-hyphen"}]}}},yf="catppuccin-latte",_x=Ax({themes:[yf],langs:["sql","json","typescript",{name:"malloy",scopeName:"source.malloy",embeddedLangs:["sql"],...Ix},{name:"malloysql",scopeName:"source.malloy-sql",embeddedLangs:["sql"],...kx}]});async function nr(e,t){return(await _x).codeToHtml(e,{lang:t,theme:yf})}const ut=y.styled(y.Card)({display:"flex",flexDirection:"column",height:"100%"}),Ut=y.styled(y.CardContent)({display:"flex",flexDirection:"column",padding:"10px",flexGrow:1}),Sa=y.styled(y.CardMedia)({padding:"10px"}),Tf=y.styled("div")({display:"flex",flexDirection:"column",height:"100%"});y.styled("div")({height:"30px",backgroundColor:"rgba(225, 240, 255, 1)",display:"flex",padding:"4px",alignItems:"center"});const Cf=y.styled("div")({display:"flex",height:"75vh",width:"100%",overflowY:"auto"});y.styled("div")({position:"relative",height:"100%",flex:"0 0 auto"});const vx=Me([h.jsx("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 16H5V5h14z"},"0"),h.jsx("path",{d:"M7 12h2v5H7zm8-5h2v10h-2zm-4 7h2v3h-2zm0-4h2v2h-2z"},"1")]),Sf=P.createContext(void 0),Af=({projectName:e,packageName:t,versionId:n,children:r})=>h.jsx(Sf.Provider,{value:{projectName:e,packageName:t,versionId:n},children:r});function gt(e=!0){const t=P.useContext(Sf);if(!t&&e)throw new Error("usePackage must be used within a PackageProvider");return t}function Ct({error:e,context:t}){const n=e.data?.message||"Unknown Error";return h.jsxs(h.Fragment,{children:[t&&h.jsx(y.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:t}),h.jsx("pre",{style:{whiteSpace:"pre-wrap",color:"red",padding:"10px",margin:"auto"},children:n})]})}function St({text:e,size:t=20,color:n="primary",thickness:r=3.6,centered:i=!0,spacing:s=2,textVariant:a="body2"}){const o=h.jsxs(y.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:s},children:[h.jsx(y.CircularProgress,{size:t,color:n,thickness:r}),e&&h.jsx(y.Typography,{variant:a,color:"text.secondary",children:e})]});return i?h.jsx(y.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"200px",width:"100%"},children:o}):o}const If=new mu.QueryClient({defaultOptions:{queries:{retry:!1,throwOnError:!1},mutations:{retry:!1,throwOnError:!1}}}),ju=async(e,t)=>{const n=t?await t():void 0;return{baseURL:e,withCredentials:!n,headers:{Authorization:n&&`Bearer ${n}`}}};function bt(e){const{server:t,getAccessToken:n}=ka(),r={...e,queryKey:[...e.queryKey,t],queryFn:async()=>{try{const i=await ju(t,n);return await e.queryFn(i)}catch(i){if(i&&typeof i=="object"&&"response"in i){const s=i;if(s.response?.data){const a=new Error(s.response.data.message||s.message);throw a.status=s.response.status,a.data=s.response.data,a}}throw i}},retry:!1,throwOnError:!1};return mu.useQuery(r,If)}function Dx(e){const{server:t,getAccessToken:n}=ka(),r={...e,mutationFn:async i=>{try{const s=await ju(t,n);return await e.mutationFn(i,s)}catch(s){if(s&&typeof s=="object"&&"response"in s){const a=s;if(a.response?.data){const o=new Error(a.response.data.message||a.message);throw o.status=a.response.status,o.data=a.response.data,o}}throw s}},retry:!1,throwOnError:!1};return mu.useMutation(r,If)}const wx=P.lazy(()=>Promise.resolve().then(()=>require("./RenderedResult-DW6glKC-.cjs"))),Nx=new wu(new mt);function Hu(e){const{optionalProjectName:t,optionalPackageName:n}=e;if(!t||!n)throw new Error("Project and Package name must be provided for query embedding.");return JSON.stringify({...e})}function Px({embeddedQueryResult:e}){const{modelPath:t,query:n,sourceName:r,queryName:i,optionalProjectName:s,optionalPackageName:a,optionalVersionId:o}=JSON.parse(e);if(!t||!n&&(!i||!r)||typeof t!="string")throw new Error("Invalid embedded query result: "+e);return h.jsx(Uu,{modelPath:t,query:n,sourceName:r,queryName:i,optionalProjectName:s,optionalPackageName:a,optionalVersionId:o})}function Uu({modelPath:e,query:t,sourceName:n,queryName:r,optionalProjectName:i,optionalPackageName:s,optionalVersionId:a}){const o=gt(!1),u=i||o?.projectName,l=s||o?.packageName,d=a||o?.versionId;if(!u||!l)throw new Error("No project or package name provided. Must be set in props or via PackageProvider");const{data:c,isSuccess:m,isError:p,error:g}=bt({queryKey:["queryResult",u,l,e,d,t,n,r],queryFn:b=>Nx.executeQuery(u,l,e,t,n,r,d,b)});return h.jsxs(h.Fragment,{children:[!m&&!p&&h.jsx(St,{text:"Fetching Query Results..."}),m&&h.jsx(P.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(wx,{result:c.data.result})}),p&&h.jsx(Ct,{context:`${u} > ${l} > ${e}`,error:g})]})}const kf=Me(h.jsx("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"})),Rx=P.lazy(()=>Promise.resolve().then(()=>require("./RenderedResult-DW6glKC-.cjs")));function _f({result:e,minHeight:t,maxHeight:n}){const[r,i]=P.useState(!1),[s,a]=P.useState(0),[o,u]=P.useState(!1),l=P.useRef(null),d=P.useRef(null),[c,m]=P.useState(void 0),[p,g]=P.useState(!1),b=P.useCallback(()=>{const w=r;i(!r),w&&d.current&&setTimeout(()=>{d.current?.scrollIntoView({behavior:"smooth",block:"start"})},100)},[r]),T=P.useCallback(w=>{a(w)},[]);if(P.useEffect(()=>{if(p){u(!0);return}if(s===0){u(!1);return}const w=t-20,D=s>w;s<w&&m(s+20),u(D)},[s,p,t]),!e)return null;const x=h.jsx(St,{text:"Loading...",centered:!0,size:32}),C=p?r?n-40:t-40:void 0,S=c?{minHeight:`${c}px`,height:"100%"}:{height:"100%"};return h.jsx(h.Fragment,{children:h.jsxs(y.Box,{ref:d,sx:{position:"relative",minHeight:`${t}px`,maxHeight:`${r?n:t}px`,border:"0px",borderRadius:0,overflow:"hidden",display:"flex",flexDirection:"column",...S},children:[h.jsx(y.Box,{ref:l,sx:{flex:1,overflow:r?"auto":"hidden",p:0,pb:o?"40px":1},children:e&&h.jsx(P.Suspense,{fallback:x,children:h.jsx(Rx,{result:e,height:C,isFillElement:w=>{g(w)},onSizeChange:T})})||x}),o&&h.jsx(y.Box,{sx:{position:"absolute",bottom:0,left:0,right:0,height:"32px",backgroundColor:"rgba(255,255,255,0.75)",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx(y.IconButton,{size:"small",onClick:b,sx:{color:"text.secondary","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)"}},title:r?"Collapse to original size":"Expand to full size",children:r?h.jsx(Ns.ExpandLess,{sx:{fontSize:30}}):h.jsx(Ns.ExpandMore,{sx:{fontSize:30}})})})]})})}const Lx=`
|
|
27
|
+
`}));let T={type:"element",tagName:"span",properties:{class:"line"},children:[]},x=0;for(const C of g){let S={type:"element",tagName:"span",properties:{...C.htmlAttrs},children:[{type:"text",value:C.content}]};C.htmlStyle;const w=GE(C.htmlStyle||pf(C));w&&(S.properties.style=w);for(const D of i)S=D?.span?.call(m,S,b+1,x,T,C)||S;o==="inline"?a.children.push(S):o==="classic"&&T.children.push(S),x+=C.content.length}if(o==="classic"){for(const C of i)T=C?.line?.call(m,T,b+1)||T;c.push(T),s.push(T)}}),o==="classic"){for(const g of i)d=g?.code?.call(m,d)||d;l.children.push(d);for(const g of i)l=g?.pre?.call(m,l)||l;a.children.push(l)}let p=a;for(const g of i)p=g?.root?.call(m,p)||p;return r&&Ca(p,r),p}function mx(e){return e.map(t=>{const n=[];let r="",i=0;return t.forEach((s,a)=>{const u=!(s.fontStyle&&s.fontStyle&Tn.Underline);u&&s.content.match(/^\s+$/)&&t[a+1]?(i||(i=s.offset),r+=s.content):r?(u?n.push({...s,offset:i,content:r+s.content}):n.push({content:r,offset:i},s),i=0,r=""):n.push(s)}),n})}function gx(e){return e.map(t=>t.flatMap(n=>{if(n.content.match(/^\s+$/))return n;const r=n.content.match(/^(\s*)(.*?)(\s*)$/);if(!r)return n;const[,i,s,a]=r;if(!i&&!a)return n;const o=[{...n,offset:n.offset+i.length,content:s}];return i&&o.unshift({content:i,offset:n.offset}),a&&o.push({content:a,offset:n.offset+i.length+s.length}),o}))}function bx(e,t,n){const r={meta:{},options:n,codeToHast:(s,a)=>Ws(e,s,a),codeToTokens:(s,a)=>Vs(e,s,a)};let i=UE(Ws(e,t,n,r));for(const s of $s(n))i=s.postprocess?.call(r,i,n)||i;return i}const Ac={light:"#333333",dark:"#bbbbbb"},Ic={light:"#fffffe",dark:"#1e1e1e"},kc="__shiki_resolved";function Bu(e){if(e?.[kc])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){const o=t.settings?t.settings.find(u=>!u.name&&!u.scope):void 0;o?.settings?.foreground&&(r=o.settings.foreground),o?.settings?.background&&(n=o.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?Ac.light:Ac.dark),n||(n=t.type==="light"?Ic.light:Ic.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let i=0;const s=new Map;function a(o){if(s.has(o))return s.get(o);i+=1;const u=`#${i.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${u}`]?a(o):(s.set(o,u),u)}t.settings=t.settings.map(o=>{const u=o.settings?.foreground&&!o.settings.foreground.startsWith("#"),l=o.settings?.background&&!o.settings.background.startsWith("#");if(!u&&!l)return o;const d={...o,settings:{...o.settings}};if(u){const c=a(o.settings.foreground);t.colorReplacements[c]=o.settings.foreground,d.settings.foreground=c}if(l){const c=a(o.settings.background);t.colorReplacements[c]=o.settings.background,d.settings.background=c}return d});for(const o of Object.keys(t.colors||{}))if((o==="editor.foreground"||o==="editor.background"||o.startsWith("terminal.ansi"))&&!t.colors[o]?.startsWith("#")){const u=a(t.colors[o]);t.colorReplacements[u]=t.colors[o],t.colors[o]=u}return Object.defineProperty(t,kc,{enumerable:!1,writable:!1,value:!0}),t}async function Ef(e){return Array.from(new Set((await Promise.all(e.filter(t=>!cf(t)).map(async t=>await ff(t).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function xf(e){return(await Promise.all(e.map(async n=>df(n)?null:Bu(await ff(n))))).filter(n=>!!n)}class Ex extends P2{constructor(t,n,r,i={}){super(t),this._resolver=t,this._themes=n,this._langs=r,this._alias=i,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const n=Bu(t);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let n=this._textmateThemeCache.get(t);n||(n=Fs.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){if(this._alias[t]){const n=new Set([t]);for(;this._alias[t];){if(t=this._alias[t],n.has(t))throw new _t(`Circular alias \`${Array.from(n).join(" -> ")} -> ${t}\``);n.add(t)}}return this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const i=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(i.name=t.name,this._resolvedGrammars.set(t.name,i),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,n.size)for(const s of n)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(const i of t)this.resolveEmbeddedLanguages(i);const n=Array.from(this._langGraph.entries()),r=n.filter(([i,s])=>!s);if(r.length){const i=n.filter(([s,a])=>a&&a.embeddedLangs?.some(o=>r.map(([u])=>u).includes(o))).filter(s=>!r.includes(s));throw new _t(`Missing languages ${r.map(([s])=>`\`${s}\``).join(", ")}, required by ${i.map(([s])=>`\`${s}\``).join(", ")}`)}for(const[i,s]of n)this._resolver.addLanguage(s);for(const[i,s]of n)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){if(this._langMap.set(t.name,t),this._langGraph.set(t.name,t),t.embeddedLangs)for(const n of t.embeddedLangs)this._langGraph.set(n,this._langMap.get(n))}}class xx{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,n){this._onigLib={createOnigScanner:r=>t.createScanner(r),createOnigString:r=>t.createString(r)},n.forEach(r=>this.addLanguage(r))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(n=>{this._langs.set(n,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(n=>{this._injections.get(n)||this._injections.set(n,[]),this._injections.get(n).push(t.scopeName)})}getInjections(t){const n=t.split(".");let r=[];for(let i=1;i<=n.length;i++){const s=n.slice(0,i).join(".");r=[...r,...this._injections.get(s)||[]]}return r}}let ei=0;function yx(e){ei+=1,e.warnings!==!1&&ei>=10&&ei%10===0&&console.warn(`[Shiki] ${ei} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new _t("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(Bu),i=new xx(e.engine,n),s=new Ex(i,r,n,e.langAlias);let a;function o(C){T();const S=s.getGrammar(typeof C=="string"?C:C.name);if(!S)throw new _t(`Language \`${C}\` not found, you may need to load it first`);return S}function u(C){if(C==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};T();const S=s.getTheme(C);if(!S)throw new _t(`Theme \`${C}\` not found, you may need to load it first`);return S}function l(C){T();const S=u(C);a!==C&&(s.setTheme(S),a=C);const w=s.getColorMap();return{theme:S,colorMap:w}}function d(){return T(),s.getLoadedThemes()}function c(){return T(),s.getLoadedLanguages()}function m(...C){T(),s.loadLanguages(C.flat(1))}async function p(...C){return m(await Ef(C))}function g(...C){T();for(const S of C.flat(1))s.loadTheme(S)}async function b(...C){return T(),g(await xf(C))}function T(){if(t)throw new _t("Shiki instance has been disposed")}function x(){t||(t=!0,s.dispose(),ei-=1)}return{setTheme:l,getTheme:u,getLanguage:o,getLoadedThemes:d,getLoadedLanguages:c,loadLanguage:p,loadLanguageSync:m,loadTheme:b,loadThemeSync:g,dispose:x,[Symbol.dispose]:x}}async function Tx(e={}){e.loadWasm;const[t,n,r]=await Promise.all([xf(e.themes||[]),Ef(e.langs||[]),e.engine||Rh(e.loadWasm||Wb())]);return yx({...e,themes:t,langs:n,engine:r})}async function Cx(e={}){const t=await Tx(e);return{getLastGrammarState:(...n)=>ax(t,...n),codeToTokensBase:(n,r)=>Mu(t,n,r),codeToTokensWithThemes:(n,r)=>bf(t,n,r),codeToTokens:(n,r)=>Vs(t,n,r),codeToHast:(n,r)=>Ws(t,n,r),codeToHtml:(n,r)=>bx(t,n,r),...t,getInternalContext:()=>t}}function Sx(e,t,n){let r,i,s;{const o=e;r=o.langs,i=o.themes,s=o.engine}async function a(o){function u(p){if(typeof p=="string"){if(cf(p))return[];const g=r[p];if(!g)throw new An(`Language \`${p}\` is not included in this bundle. You may want to load it from external source.`);return g}return p}function l(p){if(df(p))return"none";if(typeof p=="string"){const g=i[p];if(!g)throw new An(`Theme \`${p}\` is not included in this bundle. You may want to load it from external source.`);return g}return p}const d=(o.themes??[]).map(p=>l(p)),c=(o.langs??[]).map(p=>u(p)),m=await Cx({engine:o.engine??s(),...o,themes:d,langs:c});return{...m,loadLanguage(...p){return m.loadLanguage(...p.map(u))},loadTheme(...p){return m.loadTheme(...p.map(l))}}}return a}const Ax=Sx({langs:kb,themes:vb,engine:()=>Rh(Promise.resolve().then(()=>require("./wasm-Dw4u1m6u.cjs")))}),Ja={scopeName:"source.malloy",patterns:[{include:"#malloy-language"}],repository:{"malloy-language":{patterns:[{include:"#sql-string"},{include:"#comments"},{include:"#tags"},{include:"#strings"},{include:"#numbers"},{include:"#keywords"},{include:"#properties"},{include:"#functions"},{include:"#datetimes"},{include:"#identifiers-quoted"},{include:"#types"},{include:"#constants"},{include:"#timeframes"},{include:"#identifiers-unquoted"}]},"malloy-matched":{begin:"{",end:"}",patterns:[{include:"#malloy-matched"},{include:"#malloy-language"}]},"malloy-in-sql":{begin:"%{",name:"source.malloy-in-sql",end:"}%?",patterns:[{include:"#malloy-matched"},{include:"#malloy-language"}]},"sql-string":{patterns:[{begin:'(\\b[A-Za-z_][A-Za-z_0-9]*)(\\s*\\.\\s*)(sql)(\\s*\\(\\s*)(""")',end:'"""',beginCaptures:{1:{name:"variable.other"},3:{name:"keyword.control.sql"},5:{name:"punctuation.sql-block.open"}},endCaptures:{0:{name:"punctuation.sql-block.close"}},name:"source.sql",patterns:[{include:"#malloy-in-sql"},{include:"source.sql"}]}]},functions:{patterns:[{match:"(?i)\\b(count)(\\s*\\()(distinct)",captures:{1:{name:"entity.name.function"},3:{name:"entity.name.function.modifier"}}},{match:"(?i)\\b(AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE|UNGROUPED)(\\s*\\()",captures:{1:{name:"entity.name.function"}}},{match:"(?i)\\b([a-zA-Z_][a-zA-Z_0-9]*)(\\s*\\()",captures:{1:{name:"entity.name.function"}}},{match:"(?i)\\b([a-zA-Z_][a-zA-Z_0-9]*)(!)(timestamp|number|string|boolean|date)?(\\s*\\()",captures:{1:{name:"entity.name.function"},3:{name:"entity.name.type"}}}]},datetimes:{patterns:[{match:"(?i)@[0-9]{4}-[0-9]{2}-[0-9]{2}[ T][0-9]{2}:[0-9]{2}((:[0-9]{2})(([\\.,][0-9]+)(\\[[A-Za-z_/]+\\])?)?)?",name:"constant.numeric.timestamp"},{match:"(?i)@[0-9]{4}(-Q[1-4]|-[0-9]{2}(-[0-9]{2}(-WK)?)?)?",name:"constant.numeric.date"}]},"identifiers-quoted":{patterns:[{match:"`[^`]*`",name:"variable.other.quoted"}]},"identifiers-unquoted":{patterns:[{match:"(?i)\\b[A-Za-z_][A-Za-z_0-9]*\\b",name:"variable.other"}]},timeframes:{patterns:[{match:"(?i)\\b((year|quarter|month|week|day|hour|minute|second)s?)\\b",name:"keyword.other.timeframe"},{match:"(?i)\\b(day_of_year|day_of_month)\\b",name:"keyword.other.timeframe"}]},comments:{patterns:[{begin:"/\\*",end:"\\*/",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"comment.block"},{begin:"//",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{begin:"--",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-hyphen"}]},tags:{patterns:[{match:"##\\n",name:"string.quoted",captures:{0:{name:"string.quoted"}}},{begin:'#"',end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{match:"#\\n",name:"string.quoted",captures:{0:{name:"string.quoted"}}},{begin:"#\\s",end:"\\n",beginCaptures:{0:{name:"support.type.property-name.json"}},name:"comment.line.double-slash",patterns:[{include:"#tag-values"}]},{begin:"##\\s",end:"\\n",beginCaptures:{0:{name:"support.type.property-name.json"}},name:"comment.line.double-slash",patterns:[{include:"#tag-values"}]},{begin:"#",end:"\\n",beginCaptures:{0:{name:"string.quoted"}},name:"string.quoted"}],repository:{"tag-values":{name:"support.type.property-name.json",match:'(-)?((?:[^\\s=#]+)|(?:"[^#]+"))(?:\\s*(=)\\s*((?:[^\\s=#]+)|(?:"[^#]+")))?',captures:{1:{name:"keyword.control.negate"},2:{name:"support.type.property-name.json"},3:{name:"keyword.operator.comparison.ts"},4:{name:"string.quoted"}}}}},strings:{patterns:[{begin:"'",end:"'",beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.single",patterns:[{include:"#escapes"}]},{begin:'"',end:'"',beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.double",patterns:[{include:"#escapes"}]},{begin:'"""',end:'"""',beginCaptures:{0:{name:"punctuation.definition.string.begin"}},endCaptures:{0:{name:"punctuation.definition.string.end"}},name:"string.quoted.triple"},{begin:"(?i)[r|/]'",end:"'",name:"string.regexp",patterns:[{include:"#regex-escapes"}]}],repository:{escapes:{name:"constant.character.escape",match:"\\\\(u[A-Fa-f0-9]{4}|.)",captures:{0:{name:"constant.character.escape"}}},"regex-escapes":{name:"constant.character.escape",match:"\\\\.",captures:{0:{name:"constant.character.escape"}}}}},numbers:{match:"(?i)(\\b((0|[1-9][0-9]*)(E[+-]?[0-9]+|\\.[0-9]*)?)|\\.[0-9]+)",name:"constant.numeric"},constants:{patterns:[{match:"(?i)\\bnull\\b",name:"constant.language.null"},{match:"(?i)\\btrue\\b",name:"constant.language.true"},{match:"(?i)\\bfalse\\b",name:"constant.language.false"}]},types:{patterns:[{match:"(?i)\\bstring\\b",name:"entity.name.type.string"},{match:"(?i)\\bnumber\\b",name:"entity.name.type.number"},{match:"(?i)\\bdate\\b",name:"entity.name.type.date"},{match:"(?i)\\btimestamp\\b",name:"entity.name.type.timestamp"},{match:"(?i)\\bboolean\\b",name:"entity.name.type.boolean"}]},properties:{patterns:[{match:"(?i)\\baccept\\b",name:"keyword.control.accept"},{match:"(?i)\\bselect\\b",name:"keyword.control.select"},{match:"(?i)\\bconnection\\b",name:"keyword.control.connection"},{match:"(?i)\\brun\\b",name:"keyword.control.run"},{match:"(?i)\\bextend\\b",name:"keyword.control.extend"},{match:"(?i)\\brefine\\b",name:"keyword.control.refine"},{match:"(?i)\\baggregate\\b",name:"keyword.control.aggregate"},{match:"(?i)\\bsample\\b",name:"keyword.control.sample"},{match:"(?i)\\bcalculate\\b",name:"keyword.control.calculate"},{match:"(?i)\\btimezone\\b",name:"keyword.control.timezone"},{match:"(?i)\\bdimension\\b",name:"keyword.control.dimension"},{match:"(?i)\\bexcept\\b",name:"keyword.control.except"},{match:"(?i)\\bsource\\b",name:"keyword.control.source"},{match:"(?i)\\bgroup_by\\b",name:"keyword.control.group_by"},{match:"(?i)\\bhaving\\b",name:"keyword.control.having"},{match:"(?i)\\bindex\\b",name:"keyword.control.index"},{match:"(?i)\\bjoin_one\\b",name:"keyword.control.join_one"},{match:"(?i)\\bwith\\b",name:"keyword.control.with"},{match:"(?i)\\bjoin_many\\b",name:"keyword.control.join_many"},{match:"(?i)\\bjoin_cross\\b",name:"keyword.control.join_cross"},{match:"(?i)\\blimit\\b",name:"keyword.control.limit"},{match:"(?i)\\bmeasure\\b",name:"keyword.control.measure"},{match:"(?i)\\bnest\\b",name:"keyword.control.nest"},{match:"(?i)\\border_by\\b",name:"keyword.control.order_by"},{match:"(?i)\\bpartition_by\\b",name:"keyword.control.partition_by"},{match:"(?i)\\bprimary_key\\b",name:"keyword.control.primary_key"},{match:"(?i)\\bproject\\b",name:"keyword.control.project"},{match:"(?i)\\bquery\\b",name:"keyword.control.query"},{match:"(?i)\\brename\\b",name:"keyword.control.rename"},{match:"(?i)\\btop\\b",name:"keyword.control.top"},{match:"(?i)\\bview\\b",name:"keyword.control.view"},{match:"(?i)\\bwhere\\b",name:"keyword.control.where"},{match:"(?i)\\bdeclare\\b",name:"keyword.control.declare"}]},keywords:{patterns:[{match:"(?i)\\bis\\b",name:"keyword.control.is"},{match:"(?i)\\bon\\b",name:"keyword.control.on"},{match:"(?i)\\bnot\\b",name:"keyword.other.not"},{match:"(?i)\\bor\\b",name:"keyword.other.or"},{match:"(?i)\\bdesc\\b",name:"keyword.control.desc"},{match:"(?i)\\bby\\b",name:"keyword.control.by"},{match:"(?i)\\band\\b",name:"keyword.other.and"},{match:"(?i)\\basc\\b",name:"keyword.control.asc"},{match:"(?i)\\bfor\\b",name:"keyword.other.for"},{match:"(?i)\\belse\\b",name:"keyword.other.else"},{match:"(?i)\\bto\\b",name:"keyword.other.to"},{match:"(?i)\\bwhen\\b",name:"keyword.other.when"},{match:"(?i)\\bpick\\b",name:"keyword.other.pick"},{match:"(?i)\\bimport\\b",name:"keyword.control.import"}]}}},Ix={...Ja,patterns:[...Ja.patterns,{include:"#docvar"}],repository:{...Ja.repository,docvar:{patterns:[{match:"\\<\\<[^(\\>\\>)]*\\>\\>",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"markup.italic.markdown"}]}}},kx={name:"Malloy SQL",scopeName:"source.malloy-sql",patterns:[{include:"#malloysql-sql"}],repository:{"malloysql-sql":{beginCaptures:{0:{name:"entity.other.attribute.malloy-sql"},1:{name:"entity.other.attribute.malloy-sql"},3:{name:"comment.line.double-slash"}},name:"meta.embedded.block.malloysql.sql",patterns:[{include:"#comments"},{begin:"%{",end:"}%",beginCaptures:{0:{name:"punctuation.definition.malloy-sql"}},endCaptures:{0:{name:"punctuation.definition.malloy-sql"}},name:"meta.embedded.block.malloy",patterns:[{include:"source.malloy"}]},{include:"source.sql"}]},comments:{patterns:[{begin:"/\\*",end:"\\*/",beginCaptures:{0:{name:"punctuation.definition.comment.begin"}},endCaptures:{0:{name:"punctuation.definition.comment.end"}},name:"comment.block"},{begin:"//",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-slash"},{begin:"--",end:"\\n",beginCaptures:{0:{name:"punctuation.definition.comment"}},name:"comment.line.double-hyphen"}]}}},yf="catppuccin-latte",_x=Ax({themes:[yf],langs:["sql","json","typescript",{name:"malloy",scopeName:"source.malloy",embeddedLangs:["sql"],...Ix},{name:"malloysql",scopeName:"source.malloy-sql",embeddedLangs:["sql"],...kx}]});async function nr(e,t){return(await _x).codeToHtml(e,{lang:t,theme:yf})}const ut=y.styled(y.Card)({display:"flex",flexDirection:"column",height:"100%"}),Ut=y.styled(y.CardContent)({display:"flex",flexDirection:"column",padding:"10px",flexGrow:1}),Sa=y.styled(y.CardMedia)({padding:"10px"}),Tf=y.styled("div")({display:"flex",flexDirection:"column",height:"100%"});y.styled("div")({height:"30px",backgroundColor:"rgba(225, 240, 255, 1)",display:"flex",padding:"4px",alignItems:"center"});const Cf=y.styled("div")({display:"flex",height:"75vh",width:"100%",overflowY:"auto"});y.styled("div")({position:"relative",height:"100%",flex:"0 0 auto"});const vx=Me([h.jsx("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 16H5V5h14z"},"0"),h.jsx("path",{d:"M7 12h2v5H7zm8-5h2v10h-2zm-4 7h2v3h-2zm0-4h2v2h-2z"},"1")]),Sf=P.createContext(void 0),Af=({projectName:e,packageName:t,versionId:n,children:r})=>h.jsx(Sf.Provider,{value:{projectName:e,packageName:t,versionId:n},children:r});function gt(e=!0){const t=P.useContext(Sf);if(!t&&e)throw new Error("usePackage must be used within a PackageProvider");return t}function Ct({error:e,context:t}){const n=e.data?.message||"Unknown Error";return h.jsxs(h.Fragment,{children:[t&&h.jsx(y.Typography,{variant:"body2",sx:{p:"10px",m:"auto"},children:t}),h.jsx("pre",{style:{whiteSpace:"pre-wrap",color:"red",padding:"10px",margin:"auto"},children:n})]})}function St({text:e,size:t=20,color:n="primary",thickness:r=3.6,centered:i=!0,spacing:s=2,textVariant:a="body2"}){const o=h.jsxs(y.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:s},children:[h.jsx(y.CircularProgress,{size:t,color:n,thickness:r}),e&&h.jsx(y.Typography,{variant:a,color:"text.secondary",children:e})]});return i?h.jsx(y.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"200px",width:"100%"},children:o}):o}const If=new mu.QueryClient({defaultOptions:{queries:{retry:!1,throwOnError:!1},mutations:{retry:!1,throwOnError:!1}}}),ju=async(e,t)=>{const n=t?await t():void 0,r=n?{Authorization:`Bearer ${n}`}:{};return{baseURL:e,withCredentials:!!n,headers:r}};function bt(e){const{server:t,getAccessToken:n}=ka(),r={...e,queryKey:[...e.queryKey,t],queryFn:async()=>{try{const i=await ju(t,n);return await e.queryFn(i)}catch(i){if(i&&typeof i=="object"&&"response"in i){const s=i;if(s.response?.data){const a=new Error(s.response.data.message||s.message);throw a.status=s.response.status,a.data=s.response.data,a}}throw i}},retry:!1,throwOnError:!1};return mu.useQuery(r,If)}function Dx(e){const{server:t,getAccessToken:n}=ka(),r={...e,mutationFn:async i=>{try{const s=await ju(t,n);return await e.mutationFn(i,s)}catch(s){if(s&&typeof s=="object"&&"response"in s){const a=s;if(a.response?.data){const o=new Error(a.response.data.message||a.message);throw o.status=a.response.status,o.data=a.response.data,o}}throw s}},retry:!1,throwOnError:!1};return mu.useMutation(r,If)}const wx=P.lazy(()=>Promise.resolve().then(()=>require("./RenderedResult-DW6glKC-.cjs"))),Nx=new wu(new mt);function Hu(e){const{optionalProjectName:t,optionalPackageName:n}=e;if(!t||!n)throw new Error("Project and Package name must be provided for query embedding.");return JSON.stringify({...e})}function Px({embeddedQueryResult:e}){const{modelPath:t,query:n,sourceName:r,queryName:i,optionalProjectName:s,optionalPackageName:a,optionalVersionId:o}=JSON.parse(e);if(!t||!n&&(!i||!r)||typeof t!="string")throw new Error("Invalid embedded query result: "+e);return h.jsx(Uu,{modelPath:t,query:n,sourceName:r,queryName:i,optionalProjectName:s,optionalPackageName:a,optionalVersionId:o})}function Uu({modelPath:e,query:t,sourceName:n,queryName:r,optionalProjectName:i,optionalPackageName:s,optionalVersionId:a}){const o=gt(!1),u=i||o?.projectName,l=s||o?.packageName,d=a||o?.versionId;if(!u||!l)throw new Error("No project or package name provided. Must be set in props or via PackageProvider");const{data:c,isSuccess:m,isError:p,error:g}=bt({queryKey:["queryResult",u,l,e,d,t,n,r],queryFn:b=>Nx.executeQuery(u,l,e,t,n,r,d,b)});return h.jsxs(h.Fragment,{children:[!m&&!p&&h.jsx(St,{text:"Fetching Query Results..."}),m&&h.jsx(P.Suspense,{fallback:h.jsx("div",{children:"Loading..."}),children:h.jsx(wx,{result:c.data.result})}),p&&h.jsx(Ct,{context:`${u} > ${l} > ${e}`,error:g})]})}const kf=Me(h.jsx("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"})),Rx=P.lazy(()=>Promise.resolve().then(()=>require("./RenderedResult-DW6glKC-.cjs")));function _f({result:e,minHeight:t,maxHeight:n}){const[r,i]=P.useState(!1),[s,a]=P.useState(0),[o,u]=P.useState(!1),l=P.useRef(null),d=P.useRef(null),[c,m]=P.useState(void 0),[p,g]=P.useState(!1),b=P.useCallback(()=>{const w=r;i(!r),w&&d.current&&setTimeout(()=>{d.current?.scrollIntoView({behavior:"smooth",block:"start"})},100)},[r]),T=P.useCallback(w=>{a(w)},[]);if(P.useEffect(()=>{if(p){u(!0);return}if(s===0){u(!1);return}const w=t-20,D=s>w;s<w&&m(s+20),u(D)},[s,p,t]),!e)return null;const x=h.jsx(St,{text:"Loading...",centered:!0,size:32}),C=p?r?n-40:t-40:void 0,S=c?{minHeight:`${c}px`,height:"100%"}:{height:"100%"};return h.jsx(h.Fragment,{children:h.jsxs(y.Box,{ref:d,sx:{position:"relative",minHeight:`${t}px`,maxHeight:`${r?n:t}px`,border:"0px",borderRadius:0,overflow:"hidden",display:"flex",flexDirection:"column",...S},children:[h.jsx(y.Box,{ref:l,sx:{flex:1,overflow:r?"auto":"hidden",p:0,pb:o?"40px":1},children:e&&h.jsx(P.Suspense,{fallback:x,children:h.jsx(Rx,{result:e,height:C,isFillElement:w=>{g(w)},onSizeChange:T})})||x}),o&&h.jsx(y.Box,{sx:{position:"absolute",bottom:0,left:0,right:0,height:"32px",backgroundColor:"rgba(255,255,255,0.75)",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx(y.IconButton,{size:"small",onClick:b,sx:{color:"text.secondary","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)"}},title:r?"Collapse to original size":"Expand to full size",children:r?h.jsx(Ns.ExpandLess,{sx:{fontSize:30}}):h.jsx(Ns.ExpandMore,{sx:{fontSize:30}})})})]})})}const Lx=`
|
|
28
28
|
.code-display pre {
|
|
29
29
|
margin: 0;
|
|
30
30
|
padding: 0;
|
package/dist/index.es.js
CHANGED
|
@@ -12186,13 +12186,13 @@ const up = new R1({
|
|
|
12186
12186
|
}
|
|
12187
12187
|
}
|
|
12188
12188
|
}), Cl = async (e, t) => {
|
|
12189
|
-
const n = t ? await t() : void 0
|
|
12189
|
+
const n = t ? await t() : void 0, r = n ? {
|
|
12190
|
+
Authorization: `Bearer ${n}`
|
|
12191
|
+
} : {};
|
|
12190
12192
|
return {
|
|
12191
12193
|
baseURL: e,
|
|
12192
|
-
withCredentials:
|
|
12193
|
-
headers:
|
|
12194
|
-
Authorization: n && `Bearer ${n}`
|
|
12195
|
-
}
|
|
12194
|
+
withCredentials: !!n,
|
|
12195
|
+
headers: r
|
|
12196
12196
|
};
|
|
12197
12197
|
};
|
|
12198
12198
|
function kt(e) {
|
package/package.json
CHANGED
|
@@ -30,12 +30,15 @@ export const getAxiosConfig = async (
|
|
|
30
30
|
getAccessToken: () => Promise<string>,
|
|
31
31
|
): Promise<RawAxiosRequestConfig> => {
|
|
32
32
|
const accessToken = getAccessToken ? await getAccessToken() : undefined;
|
|
33
|
+
const headers = accessToken
|
|
34
|
+
? {
|
|
35
|
+
Authorization: `Bearer ${accessToken}`,
|
|
36
|
+
}
|
|
37
|
+
: {};
|
|
33
38
|
return {
|
|
34
39
|
baseURL: server,
|
|
35
|
-
withCredentials:
|
|
36
|
-
headers
|
|
37
|
-
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
38
|
-
},
|
|
40
|
+
withCredentials: !!accessToken,
|
|
41
|
+
headers,
|
|
39
42
|
} as RawAxiosRequestConfig;
|
|
40
43
|
};
|
|
41
44
|
export function useQueryWithApiError<TData = unknown, TError = ApiError>(
|